* Re: [PATCH] hwmon: adc128d818: Fix value read from Device Tree
[not found] ` <20190312152658.GA11644@roeck-us.net>
@ 2019-03-12 16:32 ` Guenter Roeck
2019-03-12 17:10 ` Carlos Menin
1 sibling, 0 replies; 5+ messages in thread
From: Guenter Roeck @ 2019-03-12 16:32 UTC (permalink / raw)
To: Carlos Menin
Cc: Jean Delvare, linux-hwmon@vger.kernel.org, Rob Herring,
devicetree
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
> >
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] hwmon: adc128d818: Fix value read from Device Tree
[not found] ` <20190312152658.GA11644@roeck-us.net>
2019-03-12 16:32 ` [PATCH] hwmon: adc128d818: Fix value read from Device Tree Guenter Roeck
@ 2019-03-12 17:10 ` Carlos Menin
2019-03-12 17:37 ` Guenter Roeck
1 sibling, 1 reply; 5+ messages in thread
From: Carlos Menin @ 2019-03-12 17:10 UTC (permalink / raw)
To: Guenter Roeck
Cc: Jean Delvare, Rob Herring, linux-hwmon@vger.kernel.org,
devicetree@vger.kernel.org
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.
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
> >
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] hwmon: adc128d818: Fix value read from Device Tree
2019-03-12 17:10 ` Carlos Menin
@ 2019-03-12 17:37 ` Guenter Roeck
2019-03-26 12:01 ` Carlos Menin
0 siblings, 1 reply; 5+ messages in thread
From: Guenter Roeck @ 2019-03-12 17:37 UTC (permalink / raw)
To: Carlos Menin
Cc: Jean Delvare, Rob Herring, linux-hwmon@vger.kernel.org,
devicetree@vger.kernel.org
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
> > >
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] hwmon: adc128d818: Fix value read from Device Tree
2019-03-12 17:37 ` Guenter Roeck
@ 2019-03-26 12:01 ` Carlos Menin
2019-03-26 18:03 ` Guenter Roeck
0 siblings, 1 reply; 5+ messages in thread
From: Carlos Menin @ 2019-03-26 12:01 UTC (permalink / raw)
To: Guenter Roeck
Cc: Jean Delvare, Rob Herring, linux-hwmon@vger.kernel.org,
devicetree@vger.kernel.org
On Tue, Mar 12, 2019 at 10:37:04AM -0700, Guenter Roeck wrote:
> 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
>
Hi,
I sent a patch with the modification in the dt binding for this device,
a couple weeks ago, but since e-mails from this address are rejected by
vger.kernel.org, I used a differente e-mail address (one that I made
sure that is accepted), if that is ok.
Best regards,
Carlos.
> > 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
> > > >
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] hwmon: adc128d818: Fix value read from Device Tree
2019-03-26 12:01 ` Carlos Menin
@ 2019-03-26 18:03 ` Guenter Roeck
0 siblings, 0 replies; 5+ messages in thread
From: Guenter Roeck @ 2019-03-26 18:03 UTC (permalink / raw)
To: Carlos Menin
Cc: Jean Delvare, Rob Herring, linux-hwmon@vger.kernel.org,
devicetree@vger.kernel.org
On Tue, Mar 26, 2019 at 12:01:57PM +0000, Carlos Menin wrote:
> On Tue, Mar 12, 2019 at 10:37:04AM -0700, Guenter Roeck wrote:
> > 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
> >
>
> Hi,
>
> I sent a patch with the modification in the dt binding for this device,
> a couple weeks ago, but since e-mails from this address are rejected by
> vger.kernel.org, I used a differente e-mail address (one that I made
> sure that is accepted), if that is ok.
>
Yes, it is available at https://patchwork.kernel.org/patch/10851189/
It is waiting for DT maintainer approval.
Guenter
> Best regards,
> Carlos.
>
>
> > > 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
> > > > >
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2019-03-26 18:03 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
[not found] <FR1P152MB28554B3FC5B4F6303019337993490@FR1P152MB2855.LAMP152.PROD.OUTLOOK.COM>
[not found] ` <20190312152658.GA11644@roeck-us.net>
2019-03-12 16:32 ` [PATCH] hwmon: adc128d818: Fix value read from Device Tree Guenter Roeck
2019-03-12 17:10 ` Carlos Menin
2019-03-12 17:37 ` Guenter Roeck
2019-03-26 12:01 ` Carlos Menin
2019-03-26 18:03 ` Guenter Roeck
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).