All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Rafael J. Wysocki" <rafael@kernel.org>
To: Andy Shevchenko <andy.shevchenko@gmail.com>
Cc: "Rafael J. Wysocki" <rafael@kernel.org>,
	"Rafael J. Wysocki" <rjw@rjwysocki.net>,
	ramesh.thomas@intel.com, Linux PM <linux-pm@vger.kernel.org>,
	LKML <linux-kernel@vger.kernel.org>,
	Reinette Chatre <reinette.chatre@intel.com>,
	Alex Shi <alex.shi@linaro.org>,
	Ulf Hansson <ulf.hansson@linaro.org>
Subject: Re: [PATCH] PM / QoS: Fix device resume latency PM QoS
Date: Fri, 27 Oct 2017 21:16:08 +0200	[thread overview]
Message-ID: <CAJZ5v0hH62vFnL0=rK6VHB8LSBB=BD2CG5apw3QCxd=BH_OzYA@mail.gmail.com> (raw)
In-Reply-To: <CAHp75VcdUP-108-ijVubYBXGyJOkpoP6hGz7LLu86NJAaMM3OA@mail.gmail.com>

On Fri, Oct 27, 2017 at 8:52 PM, Andy Shevchenko
<andy.shevchenko@gmail.com> wrote:
> On Thu, Oct 26, 2017 at 11:38 AM, Rafael J. Wysocki <rafael@kernel.org> wrote:
>> On Wed, Oct 25, 2017 at 10:06 PM, Andy Shevchenko
>> <andy.shevchenko@gmail.com> wrote:
>>> On Tue, Oct 24, 2017 at 11:49 AM, Rafael J. Wysocki <rjw@rjwysocki.net> wrote:
>>>> On Tuesday, October 24, 2017 7:54:09 AM CEST Ramesh Thomas wrote:
>>>>> On 2017-10-20 at 13:27:34 +0200, Rafael J. Wysocki wrote:
>>>
>>>>> >  static ssize_t pm_qos_resume_latency_store(struct device *dev,
>>>>> > @@ -228,11 +235,19 @@ static ssize_t pm_qos_resume_latency_sto
>>>>> >     s32 value;
>>>>> >     int ret;
>>>
>>>>> > +   if (!kstrtos32(buf, 0, &value)) {
>>>>> > +           /*
>>>>> > +            * Prevent users from writing negative or "no constraint" values
>>>>> > +            * directly.
>>>>> > +            */
>>>>> > +           if (value < 0 || value == PM_QOS_RESUME_LATENCY_NO_CONSTRAINT)
>>>>> > +                   return -EINVAL;
>>>
>>>>> > +           if (value == 0)
>>>>> > +                   value = PM_QOS_RESUME_LATENCY_NO_CONSTRAINT;
>>>>> > +   } else if (!strcmp(buf, "n/a") || !strcmp(buf, "n/a\n")) {
>>>>>
>>>>> Can the 2 checks for "n/a" be combined by checking first 3 characters?
>>>>
>>>> No, because "n/asomething" would then match too.
>>>
>>> If I don't missed anything, kernfs is aware of \n which means the
>>> first check is enough.
>>> Am I correct?
>>
>> I'm not sure, honestly. :-)
>
> Okay, just a summary:
> 1. kernfs guarantees that buffer is NULL terminated
> 2. sysfs guarantees that the buffer is not empty
> 3. kstrto* are aware of '\n'
> 4. sysfs_streq() and __sysfs_match_string() are aware of '\n'
>
> Thus, we just may use sysfs_streq() for that.
>
> I will prepare a clean up patch on top of this fix if you are okay with it.

OK, but then please cover all similar cases in this file.

Thanks,
Rafael

      reply	other threads:[~2017-10-27 19:16 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-10-20 11:27 [PATCH] PM / QoS: Fix device resume latency PM QoS Rafael J. Wysocki
2017-10-20 22:04 ` Reinette Chatre
2017-10-23  5:12 ` Alex Shi
2017-10-24  5:54 ` Ramesh Thomas
2017-10-24  8:49   ` Rafael J. Wysocki
2017-10-24 11:23     ` Rafael J. Wysocki
2017-10-24 11:35       ` [PATCH v2] " Rafael J. Wysocki
2017-10-25  7:16         ` Ramesh Thomas
2017-10-26  2:00           ` Ramesh Thomas
2017-10-26  8:44             ` Rafael J. Wysocki
2017-10-25  7:27       ` [PATCH] " Ramesh Thomas
2017-10-25 16:28         ` Rafael J. Wysocki
2017-10-26  1:41           ` Ramesh Thomas
2017-10-25 20:06     ` Andy Shevchenko
2017-10-26  8:38       ` Rafael J. Wysocki
2017-10-27 18:52         ` Andy Shevchenko
2017-10-27 19:16           ` Rafael J. Wysocki [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to='CAJZ5v0hH62vFnL0=rK6VHB8LSBB=BD2CG5apw3QCxd=BH_OzYA@mail.gmail.com' \
    --to=rafael@kernel.org \
    --cc=alex.shi@linaro.org \
    --cc=andy.shevchenko@gmail.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-pm@vger.kernel.org \
    --cc=ramesh.thomas@intel.com \
    --cc=reinette.chatre@intel.com \
    --cc=rjw@rjwysocki.net \
    --cc=ulf.hansson@linaro.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.