Re: [PATCH v5 4/4] rtc: ds1307: add frequency_test_enable sysfs attribute to check tick on m41txx

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On 16/05/2018 23:02:16+0200, Giulio Benetti wrote:
> > > +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");
> 

No, it has to be consistent with what you write.

Here, you'd write 0 or 1 in the file and read off or on...


-- 
Alexandre Belloni, Bootlin (formerly Free Electrons)
Embedded Linux and Kernel engineering
https://bootlin.com
--
To unsubscribe from this list: send the line "unsubscribe devicetree" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html



[Index of Archives]     [Device Tree Compilter]     [Device Tree Spec]     [Linux Driver Backports]     [Video for Linux]     [Linux USB Devel]     [Linux PCI Devel]     [Linux Audio Users]     [Linux Kernel]     [Linux SCSI]     [XFree86]     [Yosemite Backpacking]


  Powered by Linux