From: Guenter Roeck <linux@roeck-us.net>
To: Carlos Menin <carlos.menin@outlook.com>
Cc: Jean Delvare <jdelvare@suse.com>,
"linux-hwmon@vger.kernel.org" <linux-hwmon@vger.kernel.org>,
Rob Herring <robh@kernel.org>,
devicetree@vger.kernel.org
Subject: Re: [PATCH] hwmon: adc128d818: Fix value read from Device Tree
Date: Tue, 12 Mar 2019 09:32:49 -0700 [thread overview]
Message-ID: <20190312163248.GA14603@roeck-us.net> (raw)
In-Reply-To: <20190312152658.GA11644@roeck-us.net>
Copying DT maintainer and mailing list.
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
>
> > 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 16:32 UTC|newest]
Thread overview: 4+ 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 [this message]
[not found] ` <FR1P152MB2855A1DEBC01147732B69EC893490@FR1P152MB2855.LAMP152.PROD.OUTLOOK.COM>
2019-03-12 17:37 ` Guenter Roeck
[not found] ` <RO1P152MB18680981A9B2DF488642C825935F0@RO1P152MB1868.LAMP152.PROD.OUTLOOK.COM>
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=20190312163248.GA14603@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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox