[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <836407b4-8c51-5efa-8e29-f487bbcb528d@micronovasrl.com>
Date: Wed, 16 May 2018 23:02:16 +0200
From: Giulio Benetti <giulio.benetti@...ronovasrl.com>
To: Andy Shevchenko <andy.shevchenko@...il.com>
Cc: Alessandro Zummo <a.zummo@...ertech.it>,
alexandre.belloni@...tlin.com, Rob Herring <robh+dt@...nel.org>,
Mark Rutland <mark.rutland@....com>, linux-rtc@...r.kernel.org,
devicetree <devicetree@...r.kernel.org>,
Linux Kernel Mailing List <linux-kernel@...r.kernel.org>
Subject: Re: [PATCH v5 4/4] rtc: ds1307: add frequency_test_enable sysfs
attribute to check tick on m41txx
Hi,
Il 16/05/2018 22:22, Andy Shevchenko ha scritto:
> On Wed, May 16, 2018 at 1:32 PM, Giulio Benetti
> <giulio.benetti@...ronovasrl.com> wrote:
>> On m41txx you can enable open-drain OUT pin to check if offset is ok.
>> Enabling OUT pin with frequency_test_enable attribute, OUT pin will tick
>> 512 times faster than 1s tick base.
>>
>> Enable or Disable FT bit on CONTROL register if freq_test is 1 or 0.
>>
>> Signed-off-by: Giulio Benetti <giulio.benetti@...ronovasrl.com>
>
>> +static ssize_t frequency_test_enable_store(struct device *dev,
>> + struct device_attribute *attr,
>> + const char *buf, size_t count)
>> +{
>> + struct ds1307 *ds1307 = dev_get_drvdata(dev);
>> + unsigned long freq_test = 0;
>> + int retval;
>> +
>> + retval = kstrtoul(buf, 10, &freq_test);
>> + if ((retval < 0) || (retval > 1)) {
>
> kstrtobool() then?
Yes, you're right.
>
>> + dev_err(dev, "Failed to store RTC Frequency Test attribute\n");
>
>> + return -EINVAL;
>
> ...and do not shadow actual error code.
Ok
>
>> + }
>> +
>> + regmap_update_bits(ds1307->regmap, M41TXX_REG_CONTROL, M41TXX_BIT_FT,
>> + freq_test ? M41TXX_BIT_FT : 0);
>> +
>
>> + return retval ? retval : count;
>
> Does the condition make any sense?
You're right, not at all.
I changed it into:
"return count;"
>
>> +}
>
>> +static ssize_t frequency_test_enable_show(struct device *dev,
>> + struct device_attribute *attr,
>> + char *buf)
>> +{
>
>> + int freq_test_en = 0;
>
>> + if (ctrl_reg & M41TXX_BIT_FT)
>> + freq_test_en = true;
>> + else
>> + freq_test_en = false;
>> +
>> + return sprintf(buf, "%d\n", freq_test_en);
>
> So, is it boolean or integer? This code makes it confusing a lot.
It is a boolean, so now I've updated with this:
if (ctrl_reg & M41TXX_BIT_FT)
return scnprintf(buf, PAGE_SIZE, "on\n");
else
return scnprintf(buf, PAGE_SIZE, "off\n");
>
>> +}
>
Thank you very much for review
Giulio Benetti
Powered by blists - more mailing lists