staging/iio/meter: fix the coding style problem
Subsystems (4)
PATCH 1/1 staging/iio/meter: fix the coding style problem
---
Hi Lars,
Thanks for review. how about the below change?
drivers/staging/iio/meter/ade7854-i2c.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-)
drivers/staging/iio/meter/ade7854-i2c.c +5 -1
@@ -181,6 +181,7 @@ static int ade7854_i2c_read_reg_32(struct device *dev, {struct iio_dev *indio_dev =dev_get_drvdata (dev);struct ade7854_state *st =iio_priv (indio_dev); +uint32_t value;int ret;mutex_lock (&st->buf_lock);
@@ -195,7 +196,10 @@ static int ade7854_i2c_read_reg_32(struct device *dev,if (ret) goto out; - *val = (st->rx[0 ] <<24 ) | (st->rx[1 ] <<16 ) | (st->rx[2 ] <<8 ) | st->rx[3 ]; +memcpy (&value, st->rx,sizeof (uint32_t )); + + *val =be32_to_cpu (value); + out:mutex_unlock (&st->buf_lock);return ret;
Signature · 1 line
1.7.9.5
Quoted 20 lines · joseph daniel
Signed-off-by joseph daniel <[email protected]>---
Hi Lars,
Thanks for review. how about the below change?drivers/staging/iio/meter/ade7854-i2c.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-)drivers/staging/iio/meter/ade7854-i2c.c +1
-0@@ -181,6 +181,7 @@ static int ade7854_i2c_read_reg_32(struct device *dev, {struct iio_dev *indio_dev =dev_get_drvdata (dev);struct ade7854_state *st =iio_priv (indio_dev); +uint32_t value;int ret;mutex_lock (&st->buf_lock);
drivers/staging/iio/meter/ade7854-i2c.c static int ade7854_i2c_read_reg_32(struct device *dev, · line 200
Quoted 6 lines
drivers/staging/iio/meter/ade7854-i2c.c +2
-1@@ -195,7 +196,10 @@ static int ade7854_i2c_read_reg_32(struct device *dev,if (ret) goto out; - *val = (st->rx[0 ] <<24 ) | (st->rx[1 ] <<16 ) | (st->rx[2 ] <<8 ) | st->rx[3 ]; +memcpy (&value, st->rx,sizeof (uint32_t )); +
Uhm, yes, you are right st->rx is unaligned. The memcpy is not necessary though if you use get_unaligned_be32. Sorry for the pointer to the wrong function.
Btw. there are a few other locations in this driver which could use the put_unaligned_be* and get_unaligned_be* functions. Would be great if you could convert these as well.
Quoted 5 lines
drivers/staging/iio/meter/ade7854-i2c.c +2
-0+ *val =be32_to_cpu (value); + out:mutex_unlock (&st->buf_lock);return ret;
Quoted 5 lines · joseph daniel
Signed-off-by joseph daniel <[email protected]>---
Hi Lars,
Thanks for review. how about the below change?
Slow down. There is no rush. It's better to sit on patches overnight so you can review them carefully the next day. Take the time to write a proper changelog...
drivers/staging/iio/meter/ade7854-i2c.c static int ade7854_i2c_read_reg_32(struct device *dev, · line 184
Quoted 12 lines
drivers/staging/iio/meter/ade7854-i2c.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-)drivers/staging/iio/meter/ade7854-i2c.c +1
-0@@ -181,6 +181,7 @@ static int ade7854_i2c_read_reg_32(struct device *dev, {struct iio_dev *indio_dev =dev_get_drvdata (dev);struct ade7854_state *st =iio_priv (indio_dev); +uint32_t value;
Use the endian notation here:
__be32 value;
http://lwn.net/Articles/205624/
The rest looks fine to me. Package it up like a proper patch and resend.
regards,
dan carpenter
Quoted 6 lines · Dan Carpenter
Quoted 5 lines · joseph daniel
Signed-off-by joseph daniel <[email protected]>---
Hi Lars,
Thanks for review. how about the below change?
Lar's review is the correct one. It's cleaner to use get_unaligned_be32(). You'll need to include <asm/unaligned.h>
regards,
dan carpenter
Quoted 9 lines · Lars-Peter Clausen
drivers/staging/i=
Quoted 8 lines · joseph daniel
Signed-off-by joseph daniel <[email protected]>---
Hi Lars,
=A0 =A0 =A0 Thanks for review. how about the below change? =A0drivers/staging/iio/meter/ade7854-i2c.c | =A0 =A06 +++++- =A01 file changed, 5 insertions(+), 1 deletion(-)drivers/staging/i= renamed from drivers/staging/iio/meter/ade7854-i2c.c +0
-0
io/meter/ade7854-i2c.c
Quoted 4 lines
drivers/staging/iio/meter/ade7854-i2c.c static int ade7854_i2c_read_reg_32(struct device *de=
Quoted 4 lines
index 1e1faa0..52bdb05 100644
drivers/staging/iio/meter/ade7854-i2c.c +0
-0@@ -181,6 +181,7 @@ static int ade7854_i2c_read_reg_32(struct device *de=
v,
Quoted 8 lines
drivers/staging/iio/meter/ade7854-i2c.c static int ade7854_i2c_read_reg_32(struct device *d=
Quoted 8 lines
drivers/staging/iio/meter/ade7854-i2c.c +1
-0=A0{ =A0 =A0 =A0 struct iio_dev *indio_dev =3D dev_get_drvdata(dev); =A0 =A0 =A0 struct ade7854_state *st =3D iio_priv(indio_dev); + =A0 =A0 uint32_t value; =A0 =A0 =A0 int ret; =A0 =A0 =A0 mutex_lock(&st->buf_lock);@@ -195,7 +196,10 @@ static int ade7854_i2c_read_reg_32(struct device *d=
ev,
Quoted 4 lines
drivers/staging/iio/meter/ade7854-i2c.c static int ade7854_i2c_read_reg_32(struct device *d= · line 198
Quoted 4 lines
drivers/staging/iio/meter/ade7854-i2c.c +0
-1=A0 =A0 =A0 if (ret) =A0 =A0 =A0 =A0 =A0 =A0 =A0 goto out; - =A0 =A0 *val =3D (st->rx[0] << 24) | (st->rx[1] << 16) | (st->rx[2] <<=
8) | st->rx[3];
Quoted 4 lines
drivers/staging/iio/meter/ade7854-i2c.c static int ade7854_i2c_read_reg_32(struct device *d= · line 200
Quoted 2 lines
drivers/staging/iio/meter/ade7854-i2c.c +2
-0+ =A0 =A0 memcpy(&value, st->rx, sizeof(uint32_t)); +Uhm, yes, you are right
st->rxis unaligned. The memcpy is not necessary =
though
Quoted 1 line
if you use
get_unaligned_be32. Sorry for the pointer to the wrong functio=
n.
Quoted 3 lines
Btw. there are a few other locations in this driver which could use the put_unaligned_be* and get_unaligned_be* functions. Would be great if you =
could
Quoted 8 lines
convert these as well.
Quoted 5 lines
drivers/staging/iio/meter/ade7854-i2c.c +2
-0+ =A0 =A0 *val =3D be32_to_cpu(value); +=A0out:
=A0 =A0 =A0mutex_unlock(&st->buf_lock);
=A0 =A0 =A0 return ret;
Thanks for review. i will be glad doing those changes. i will send patch as soon as i get free.
Thanks.
Joseph.
On Tue, May 1, 2012 at 2:18 AM, Dan Carpenter <[email protected]> wr= ote:
Quoted 11 lines · Dan Carpenter
Quoted 6 lines · joseph daniel
Quoted 5 lines
Signed-off-by joseph daniel <[email protected]>---
Hi Lars,
=A0 =A0 Thanks for review. how about the below change?Lar's review is the correct one. =A0It's cleaner to use
get_unaligned_be32(). =A0You'll need to include <asm/unaligned.h>
Thanks For the info Dan. i will be taking your comments in the code change.
Quoted 3 lines
regards,
dan carpenter
Thanks,
Joseph.
Quoted 24 lines · Lars-Peter Clausen
Quoted 23 lines · joseph daniel
Signed-off-by joseph daniel<[email protected]>---
Hi Lars,
Thanks for review. how about the below change?drivers/staging/iio/meter/ade7854-i2c.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-)drivers/staging/iio/meter/ade7854-i2c.c +1
-0@@ -181,6 +181,7 @@ static int ade7854_i2c_read_reg_32(struct device *dev, {struct iio_dev *indio_dev =dev_get_drvdata (dev);struct ade7854_state *st =iio_priv (indio_dev); +uint32_t value;int ret;mutex_lock (&st->buf_lock);@@ -195,7 +196,10 @@ static int ade7854_i2c_read_reg_32(struct device *dev,if (ret) goto out;
Quoted 5 lines
drivers/staging/iio/meter/ade7854-i2c.c static int ade7854_i2c_read_reg_32(struct device *dev, · line 200
Quoted 3 lines
drivers/staging/iio/meter/ade7854-i2c.c +2
-1- *val = (st->rx[0 ]<<24 ) | (st->rx[1 ]<<16 ) | (st->rx[2 ]<<8 ) | st->rx[3 ]; +memcpy (&value, st->rx,sizeof (uint32_t )); +Uhm, yes, you are right
st->rxis unaligned. The memcpy is not necessary though if you useget_unaligned_be32. Sorry for the pointer to the wrong function.
Or we could just force the alignment of st->rx? Might not be worth bothering.
Quoted 10 lines
Btw. there are a few other locations in this driver which could use the put_unaligned_be* and get_unaligned_be* functions. Would be great if you could convert these as well.
Quoted 5 lines
drivers/staging/iio/meter/ade7854-i2c.c +2
-0+ *val =be32_to_cpu (value); + out:mutex_unlock (&st->buf_lock);return ret;
Quoted 36 lines · Jonathan Cameron
Quoted 27 lines · Lars-Peter Clausen
Quoted 26 lines · joseph daniel
Signed-off-by joseph daniel<[email protected]>---
Hi Lars,
Thanks for review. how about the below change?drivers/staging/iio/meter/ade7854-i2c.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-)drivers/staging/iio/meter/ade7854-i2c.c +1
-0@@ -181,6 +181,7 @@ static int ade7854_i2c_read_reg_32(struct device *dev, {struct iio_dev *indio_dev =dev_get_drvdata (dev);struct ade7854_state *st =iio_priv (indio_dev); +uint32_t value;int ret;mutex_lock(&st->buf_lock);drivers/staging/iio/meter/ade7854-i2c.c +0
-0@@ -195,7 +196,10 @@ static int ade7854_i2c_read_reg_32(struct device *dev, if (ret) goto out;Quoted 8 lines
drivers/staging/iio/meter/ade7854-i2c.c static int ade7854_i2c_read_reg_32(struct device *dev, · line 200
Quoted 4 lines
drivers/staging/iio/meter/ade7854-i2c.c +2
-1- *val = (st->rx[0 ]<<24 ) | (st->rx[1 ]<<16 ) | (st->rx[2 ]<<8 ) | st->rx[3]; +memcpy (&value, st->rx,sizeof (uint32_t )); +Uhm, yes, you are right
st->rxis unaligned. The memcpy is not necessary though
if you useget_unaligned_be32. Sorry for the pointer to the wrong function.
Quoted 2 lines
Or we could just force the alignment of
st->rx? Might not be worth bothering.
Yes, but be32_to_cpu wants a be32 and there is another functions which only does a 16 bit access on rx, so we'd need to cast and things get messy. Also for tx we store first a 16bit value and then a 32bit value and while it is possible to get this properly aligned this gets a bit messy too. I think we are fine with {get,set}_unaligned for now.