From: Guenter Roeck <linux@roeck-us.net>
To: Carlos Menin <carlos.menin@outlook.com>
Cc: Jean Delvare <jdelvare@suse.com>, Rob Herring <robh@kernel.org>,
"linux-hwmon@vger.kernel.org" <linux-hwmon@vger.kernel.org>,
"devicetree@vger.kernel.org" <devicetree@vger.kernel.org>
Subject: Re: [PATCH] hwmon: adc128d818: Fix value read from Device Tree
Date: Tue, 12 Mar 2019 10:37:04 -0700 [thread overview]
Message-ID: <20190312173704.GA18161@roeck-us.net> (raw)
In-Reply-To: <FR1P152MB2855A1DEBC01147732B69EC893490@FR1P152MB2855.LAMP152.PROD.OUTLOOK.COM>
On Tue, Mar 12, 2019 at 05:10:48PM +0000, Carlos Menin wrote:
> On Tue, Mar 12, 2019 at 08:26:58AM -0700, Guenter Roeck wrote:
> > On Tue, Mar 12, 2019 at 01:14:39PM +0000, Carlos Menin wrote:
> > > Cells in DT are 32-bits in size. of_property_read_u8() does not work
> > > properly as it returns incorrect values in little-endian architectures.
> > > Fix it by using of_property_read_u32() instead.
> > >
> > Are you saying that pretty much all callers of of_property_read_u8()
> > have this problem ? I would not rule that out, but it seems hard to
> > believe.
> >
> > Guenter
> >
>
> Hi Guenter,
>
> Yes, unless the DT entry specifies the cell size with '/bits/ 8' prefix.
> Not many drivers calls of_property_read_u8() function, almost all of
> them have this prefix in their binding examples, this being one of the
> exceptions. The fix could be a change in the documentation instead, if
> that is preferred.
>
Yes, I would very much prefer that.
Guenter
> Carlos
>
> > > Signed-off-by: Carlos Menin <carlos.menin@outlook.com>
> > > ---
> > > drivers/hwmon/adc128d818.c | 4 ++--
> > > 1 file changed, 2 insertions(+), 2 deletions(-)
> > >
> > > diff --git a/drivers/hwmon/adc128d818.c b/drivers/hwmon/adc128d818.c
> > > index ca794bf..b5eb3c0 100644
> > > --- a/drivers/hwmon/adc128d818.c
> > > +++ b/drivers/hwmon/adc128d818.c
> > > @@ -70,7 +70,7 @@ struct adc128_data {
> > > struct regulator *regulator;
> > > int vref; /* Reference voltage in mV */
> > > struct mutex update_lock;
> > > - u8 mode; /* Operation mode */
> > > + u32 mode; /* Operation mode */
> > > bool valid; /* true if following fields are valid */
> > > unsigned long last_updated; /* In jiffies */
> > >
> > > @@ -467,7 +467,7 @@ static int adc128_probe(struct i2c_client *client,
> > > }
> > >
> > > /* Operation mode is optional. If unspecified, keep current mode */
> > > - if (of_property_read_u8(dev->of_node, "ti,mode", &data->mode) == 0) {
> > > + if (of_property_read_u32(dev->of_node, "ti,mode", &data->mode) == 0) {
> > > if (data->mode > 3) {
> > > dev_err(dev, "invalid operation mode %d\n",
> > > data->mode);
> > > --
> > > 2.7.4
> > >
next prev parent reply other threads:[~2019-03-12 17:37 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <FR1P152MB28554B3FC5B4F6303019337993490@FR1P152MB2855.LAMP152.PROD.OUTLOOK.COM>
2019-03-12 15:26 ` [PATCH] hwmon: adc128d818: Fix value read from Device Tree Guenter Roeck
2019-03-12 16:32 ` Guenter Roeck
2019-03-12 17:10 ` Carlos Menin
2019-03-12 17:37 ` Guenter Roeck [this message]
2019-03-26 12:01 ` Carlos Menin
2019-03-26 18:03 ` Guenter Roeck
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=20190312173704.GA18161@roeck-us.net \
--to=linux@roeck-us.net \
--cc=carlos.menin@outlook.com \
--cc=devicetree@vger.kernel.org \
--cc=jdelvare@suse.com \
--cc=linux-hwmon@vger.kernel.org \
--cc=robh@kernel.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.