lkml.org 
[lkml]   [2018]   [Jul]   [20]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
SubjectRe: [PATCH v9 4/4] rtc: ds1307: add frequency_test_enable sysfs attribute to check tick on m41txx
From
Date
Il 20/07/2018 14:53, Andy Shevchenko ha scritto:
> On Thu, Jul 19, 2018 at 9:19 PM, Giulio Benetti
> <giulio.benetti@micronovasrl.com> wrote:
>> Hi Andy,
>>
>> Il 18/07/2018 18:26, Andy Shevchenko ha scritto:
>>>
>>> On Wed, Jul 18, 2018 at 5:06 PM, Giulio Benetti
>>> <giulio.benetti@micronovasrl.com> wrote:
>>>
>>>>>> + int ret;
>>>>>> +
>>>>>> + ret = kstrtobool(buf, &freq_test_en);
>>>>>> + if (ret == -EINVAL) {
>>>
>>>
>>>>> What kind of other error code you may expect and why they are not
>>>>> considered as no error?
>>>
>>>
>>>> According to documentation, kstrtobool can only fail with -EINVAL.
>>>> See:
>>>> https://elixir.bootlin.com/linux/v4.18-rc5/source/lib/kstrtox.c#L332
>>>
>>>
>>> That's correct. So, what do you want to show by explicitly mentioned
>>> an error code in the condition?
>>>
>>
>> So you mean I should check for negative values instead of specific error,
>> right?
>
> Learn from the existing code.
>
> As you found kstrtobool() returns either 0 (no error), or -EINVAL (the
> only possible error code for now).
> Checking ret for non-zero is enough.
> Thus,
>
> if (ret) {
> ...
> return ret;
> }
>
> should do a job.
>

Oh, I was pretty sure I've found an example of kstrtobool() in the way
I've used, instead no.
Thanks for pointing me.
I correct it.

Best regards
Giulio

\
 
 \ /
  Last update: 2018-07-20 15:07    [W:0.078 / U:0.532 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site