Skip to contentSkip to conversation

staging: iio: accel: adis16201: remove local variable addr

PATCH In review Aishwarya Pant 3 participants 3 messages Mar 23, 2017

Subsystems (4)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 staging: iio: accel: adis16201: remove local variable addr

Remove local variable addr from adis_read_reg_16() and adis_write_reg_16() as it is used only once.

---
 drivers/staging/iio/accel/adis16201.c | 12 ++++++------
 1 file changed, 6 insertions(+), 6 deletions(-)
drivers/staging/iio/accel/adis16201.c +6 -6
index fbc2406..b03c4f3 100644
@@ -175,7 +175,6 @@ static int adis16201_read_raw(struct iio_dev *indio_dev,
 	struct adis *st = iio_priv(indio_dev);
 	int ret;
 	int bits;
-	u8 addr;
 	s16 val16;
 
 	switch (mask) {
@@ -223,8 +222,9 @@ static int adis16201_read_raw(struct iio_dev *indio_dev,
 		default:
 			return -EINVAL;
 		}
-		addr = adis16201_addresses[chan->scan_index];
-		ret = adis_read_reg_16(st, addr, &val16);
+		ret = adis_read_reg_16(st,
+				       adis16201_addresses[chan->scan_index],
+				       &val16);
 		if (ret)
 			return ret;
 		val16 &= (1 << bits) - 1;
@@ -244,7 +244,6 @@ static int adis16201_write_raw(struct iio_dev *indio_dev,
 	struct adis *st = iio_priv(indio_dev);
 	int bits;
 	s16 val16;
-	u8 addr;
 
 	switch (mask) {
 	case IIO_CHAN_INFO_CALIBBIAS:
@@ -259,8 +258,9 @@ static int adis16201_write_raw(struct iio_dev *indio_dev,
 			return -EINVAL;
 		}
 		val16 = val & ((1 << bits) - 1);
-		addr = adis16201_addresses[chan->scan_index];
-		return adis_write_reg_16(st, addr, val16);
+		return adis_write_reg_16(st,
+					 adis16201_addresses[chan->scan_index],
+					 val16);
 	}
 	return -EINVAL;
 }
Signature · 1 line
2.7.4
#1 lore raw
Quoted 21 lines · Aishwarya Pant

Remove local variable addr from adis_read_reg_16() and adis_write_reg_16() as it is used only once.

---
 drivers/staging/iio/accel/adis16201.c | 12 ++++++------
 1 file changed, 6 insertions(+), 6 deletions(-)
drivers/staging/iio/accel/adis16201.c +0 -1
index fbc2406..b03c4f3 100644
@@ -175,7 +175,6 @@ static int adis16201_read_raw(struct iio_dev *indio_dev,
 	struct adis *st = iio_priv(indio_dev);
 	int ret;
 	int bits;
-	u8 addr;
 	s16 val16;
 
 	switch (mask) {

drivers/staging/iio/accel/adis16201.c static int adis16201_read_raw(struct iio_dev *indio_dev, · line 227

Quoted 8 lines
drivers/staging/iio/accel/adis16201.c +3 -2
@@ -223,8 +222,9 @@ static int adis16201_read_raw(struct iio_dev *indio_dev,
 		default:
 			return -EINVAL;
 		}
-		addr = adis16201_addresses[chan->scan_index];
-		ret = adis_read_reg_16(st, addr, &val16);
+		ret = adis_read_reg_16(st,
+				       adis16201_addresses[chan->scan_index],
+				       &val16);

The original code was probably nicer. One line shorter in the part that actually does computation.

julia

Quoted 33 lines
drivers/staging/iio/accel/adis16201.c +3 -4
 		if (ret)
 			return ret;
 		val16 &= (1 << bits) - 1;
@@ -244,7 +244,6 @@ static int adis16201_write_raw(struct iio_dev *indio_dev,
 	struct adis *st = iio_priv(indio_dev);
 	int bits;
 	s16 val16;
-	u8 addr;
 
 	switch (mask) {
 	case IIO_CHAN_INFO_CALIBBIAS:
@@ -259,8 +258,9 @@ static int adis16201_write_raw(struct iio_dev *indio_dev,
 			return -EINVAL;
 		}
 		val16 = val & ((1 << bits) - 1);
-		addr = adis16201_addresses[chan->scan_index];
-		return adis_write_reg_16(st, addr, val16);
+		return adis_write_reg_16(st,
+					 adis16201_addresses[chan->scan_index],
+					 val16);
 	}
 	return -EINVAL;
 }
--

2.7.4

--
You received this message because you are subscribed to the Google Groups "outreachy-kernel" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To post to this group, send email to [email protected].
To view this discussion on the web visit https://groups.google.com/d/msgid/outreachy-kernel/20170323144453.GA7093%40aishwarya.
For more options, visit https://groups.google.com/d/optout.

#2 lore raw
Quoted 29 lines · Julia Lawall
Quoted 1 line · Aishwarya Pant

Remove local variable addr from adis_read_reg_16() and

adis_write_reg_16()

Review

Quoted 8 lines

as it is used only once=2E

---
 drivers/staging/iio/accel/adis16201=2Ec | 12 ++++++------
 1 file changed, 6 insertions(+), 6 deletions(-)
(quoted diff) +0 -0

b/drivers/staging/iio/accel/adis16201=2Ec

drivers/staging/iio/accel/adis16201=2Ec static int adis16201_read_raw(struct iio_dev

Quoted 4 lines

index fbc2406=2E=2Eb03c4f3 100644

drivers/staging/iio/accel/adis16201=2Ec +0 -0
@@ -175,7 +175,6 @@ static int adis16201_read_raw(struct iio_dev

*indio_dev,

drivers/staging/iio/accel/adis16201=2Ec static int adis16201_read_raw(struct iio_dev

Quoted 8 lines
drivers/staging/iio/accel/adis16201=2Ec +0 -1
 	struct adis *st =3D iio_priv(indio_dev);
 	int ret;
 	int bits;
-	u8 addr;
 	s16 val16;
 
 	switch (mask) {
@@ -223,8 +222,9 @@ static int adis16201_read_raw(struct iio_dev

*indio_dev,

Quoted 12 lines

drivers/staging/iio/accel/adis16201=2Ec static int adis16201_read_raw(struct iio_dev · line 227

Quoted 8 lines
drivers/staging/iio/accel/adis16201=2Ec +3 -2
 		default:
 			return -EINVAL;
 		}
-		addr =3D adis16201_addresses[chan->scan_index];
-		ret =3D adis_read_reg_16(st, addr, &val16);
+		ret =3D adis_read_reg_16(st,
+				       adis16201_addresses[chan->scan_index],
+				       &val16);

The original code was probably nicer=2E One line shorter in the part that
actually does computation=2E

That did indeed fall out worse than i expected=2E

Sorry Aishwarya, I led you up a blind alley here!

Jonathan

Quoted 34 lines

julia

drivers/staging/iio/accel/adis16201=2Ec static int adis16201_write_raw(struct iio_dev

Quoted 4 lines
drivers/staging/iio/accel/adis16201=2Ec +0 -0
 		if (ret)
 			return ret;
 		val16 &=3D (1 << bits) - 1;
@@ -244,7 +244,6 @@ static int adis16201_write_raw(struct iio_dev

*indio_dev,

drivers/staging/iio/accel/adis16201=2Ec static int adis16201_write_raw(struct iio_dev

Quoted 8 lines
drivers/staging/iio/accel/adis16201=2Ec +0 -1
 	struct adis *st =3D iio_priv(indio_dev);
 	int bits;
 	s16 val16;
-	u8 addr;
 
 	switch (mask) {
 	case IIO_CHAN_INFO_CALIBBIAS:
@@ -259,8 +258,9 @@ static int adis16201_write_raw(struct iio_dev

*indio_dev,

Quoted 14 lines
drivers/staging/iio/accel/adis16201=2Ec +3 -3
 			return -EINVAL;
 		}
 		val16 =3D val & ((1 << bits) - 1);
-		addr =3D adis16201_addresses[chan->scan_index];
-		return adis_write_reg_16(st, addr, val16);
+		return adis_write_reg_16(st,
+					 adis16201_addresses[chan->scan_index],
+					 val16);
 	}
 	return -EINVAL;
 }
--

2=2E7=2E4

Quoted 2 lines

--
You received this message because you are subscribed to the Google

Groups "outreachy-kernel" group=2E

Quoted 6 lines
Quoted 1 line

To unsubscribe from this group and stop receiving emails from it,

send an email to outreachy-kernel+unsubscribe@googlegroups=2Ecom=2E

Quoted 1 line

To post to this group, send email to

outreachy-kernel@googlegroups=2Ecom=2E

Quoted 1 line

To view this discussion on the web visit

https://groups=2Egoogle=2Ecom/d/msgid/outreachy-kernel/20170323144453=2EG=

A7093%40aishwarya=2E

Quoted 6 lines
Quoted 2 lines

For more options, visit https://groups=2Egoogle=2Ecom/d/optout=2E

--
To unsubscribe from this list: send the line "unsubscribe linux-iio" in the body of a message to majordomo@vger=2Ekernel=2Eorg
More majordomo info at http://vger=2Ekernel=2Eorg/majordomo-info=2Ehtml

--=20
Sent from my Android device with K-9 Mail=2E Please excuse my brevity=2E