All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] staging: iio: accel: adis16201: remove local variable addr
@ 2017-03-23 14:44 Aishwarya Pant
  2017-03-23 14:48 ` [Outreachy kernel] " Julia Lawall
  0 siblings, 1 reply; 4+ messages in thread
From: Aishwarya Pant @ 2017-03-23 14:44 UTC (permalink / raw)
  To: Lars-Peter Clausen, Michael Hennerich, Jonathan Cameron,
	Hartmut Knaack, Peter Meerwald-Stadler, Greg Kroah-Hartman,
	Barry Song
  Cc: outreachy-kernel, linux-iio

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

Signed-off-by: Aishwarya Pant <aishpant@gmail.com>
---
 drivers/staging/iio/accel/adis16201.c | 12 ++++++------
 1 file changed, 6 insertions(+), 6 deletions(-)

diff --git a/drivers/staging/iio/accel/adis16201.c b/drivers/staging/iio/accel/adis16201.c
index fbc2406..b03c4f3 100644
--- a/drivers/staging/iio/accel/adis16201.c
+++ b/drivers/staging/iio/accel/adis16201.c
@@ -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;
 }
-- 
2.7.4



^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [Outreachy kernel] [PATCH] staging: iio: accel: adis16201: remove local variable addr
  2017-03-23 14:44 [PATCH] staging: iio: accel: adis16201: remove local variable addr Aishwarya Pant
@ 2017-03-23 14:48 ` Julia Lawall
  2017-03-23 17:19     ` Jonathan Cameron
  0 siblings, 1 reply; 4+ messages in thread
From: Julia Lawall @ 2017-03-23 14:48 UTC (permalink / raw)
  To: Aishwarya Pant
  Cc: Lars-Peter Clausen, Michael Hennerich, Jonathan Cameron,
	Hartmut Knaack, Peter Meerwald-Stadler, Greg Kroah-Hartman,
	Barry Song, outreachy-kernel, linux-iio



On Thu, 23 Mar 2017, Aishwarya Pant wrote:

> Remove local variable addr from adis_read_reg_16() and adis_write_reg_16()
> as it is used only once.
>
> Signed-off-by: Aishwarya Pant <aishpant@gmail.com>
> ---
>  drivers/staging/iio/accel/adis16201.c | 12 ++++++------
>  1 file changed, 6 insertions(+), 6 deletions(-)
>
> diff --git a/drivers/staging/iio/accel/adis16201.c b/drivers/staging/iio/accel/adis16201.c
> index fbc2406..b03c4f3 100644
> --- a/drivers/staging/iio/accel/adis16201.c
> +++ b/drivers/staging/iio/accel/adis16201.c
> @@ -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);

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

julia

>  		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 outreachy-kernel+unsubscribe@googlegroups.com.
> To post to this group, send email to outreachy-kernel@googlegroups.com.
> 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.
>


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [Outreachy kernel] [PATCH] staging: iio: accel: adis16201: remove local variable addr
  2017-03-23 14:48 ` [Outreachy kernel] " Julia Lawall
@ 2017-03-23 17:19     ` Jonathan Cameron
  0 siblings, 0 replies; 4+ messages in thread
From: Jonathan Cameron @ 2017-03-23 17:19 UTC (permalink / raw)
  To: Julia Lawall, Aishwarya Pant
  Cc: Lars-Peter Clausen, Michael Hennerich, Jonathan Cameron,
	Hartmut Knaack, Peter Meerwald-Stadler, Greg Kroah-Hartman,
	Barry Song, outreachy-kernel, linux-iio



On 23 March 2017 14:48:10 GMT+00:00, Julia Lawall <julia=2Elawall@lip6=2Ef=
r> wrote:
>
>
>On Thu, 23 Mar 2017, Aishwarya Pant wrote:
>
>> Remove local variable addr from adis_read_reg_16() and
>adis_write_reg_16()
>> as it is used only once=2E
>>
>> Signed-off-by: Aishwarya Pant <aishpant@gmail=2Ecom>
>> ---
>>  drivers/staging/iio/accel/adis16201=2Ec | 12 ++++++------
>>  1 file changed, 6 insertions(+), 6 deletions(-)
>>
>> diff --git a/drivers/staging/iio/accel/adis16201=2Ec
>b/drivers/staging/iio/accel/adis16201=2Ec
>> index fbc2406=2E=2Eb03c4f3 100644
>> --- a/drivers/staging/iio/accel/adis16201=2Ec
>> +++ b/drivers/staging/iio/accel/adis16201=2Ec
>> @@ -175,7 +175,6 @@ static int adis16201_read_raw(struct iio_dev
>*indio_dev,
>>  	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,
>>  		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
>
>julia
>
>>  		if (ret)
>>  			return ret;
>>  		val16 &=3D (1 << bits) - 1;
>> @@ -244,7 +244,6 @@ static int adis16201_write_raw(struct iio_dev
>*indio_dev,
>>  	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,
>>  			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
>>
>> --
>> You received this message because you are subscribed to the Google
>Groups "outreachy-kernel" group=2E
>> To unsubscribe from this group and stop receiving emails from it,
>send an email to outreachy-kernel+unsubscribe@googlegroups=2Ecom=2E
>> To post to this group, send email to
>outreachy-kernel@googlegroups=2Ecom=2E
>> To view this discussion on the web visit
>https://groups=2Egoogle=2Ecom/d/msgid/outreachy-kernel/20170323144453=2EG=
A7093%40aishwarya=2E
>> 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

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [Outreachy kernel] [PATCH] staging: iio: accel: adis16201: remove local variable addr
@ 2017-03-23 17:19     ` Jonathan Cameron
  0 siblings, 0 replies; 4+ messages in thread
From: Jonathan Cameron @ 2017-03-23 17:19 UTC (permalink / raw)
  To: Julia Lawall, Aishwarya Pant
  Cc: Lars-Peter Clausen, Michael Hennerich, Jonathan Cameron,
	Hartmut Knaack, Peter Meerwald-Stadler, Greg Kroah-Hartman,
	Barry Song, outreachy-kernel, linux-iio



On 23 March 2017 14:48:10 GMT+00:00, Julia Lawall <julia.lawall@lip6.fr> wrote:
>
>
>On Thu, 23 Mar 2017, Aishwarya Pant wrote:
>
>> Remove local variable addr from adis_read_reg_16() and
>adis_write_reg_16()
>> as it is used only once.
>>
>> Signed-off-by: Aishwarya Pant <aishpant@gmail.com>
>> ---
>>  drivers/staging/iio/accel/adis16201.c | 12 ++++++------
>>  1 file changed, 6 insertions(+), 6 deletions(-)
>>
>> diff --git a/drivers/staging/iio/accel/adis16201.c
>b/drivers/staging/iio/accel/adis16201.c
>> index fbc2406..b03c4f3 100644
>> --- a/drivers/staging/iio/accel/adis16201.c
>> +++ b/drivers/staging/iio/accel/adis16201.c
>> @@ -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);
>
>The original code was probably nicer.  One line shorter in the part
>that
>actually does computation.
That did indeed fall out worse than i expected.

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

Jonathan
>
>julia
>
>>  		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 outreachy-kernel+unsubscribe@googlegroups.com.
>> To post to this group, send email to
>outreachy-kernel@googlegroups.com.
>> 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.
>>
>--
>To unsubscribe from this list: send the line "unsubscribe linux-iio" in
>the body of a message to majordomo@vger.kernel.org
>More majordomo info at  http://vger.kernel.org/majordomo-info.html

-- 
Sent from my Android device with K-9 Mail. Please excuse my brevity.


^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2017-03-23 17:19 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-03-23 14:44 [PATCH] staging: iio: accel: adis16201: remove local variable addr Aishwarya Pant
2017-03-23 14:48 ` [Outreachy kernel] " Julia Lawall
2017-03-23 17:19   ` Jonathan Cameron
2017-03-23 17:19     ` Jonathan Cameron

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.