Re: [Outreachy kernel] [PATCH] staging: iio: accel: adis16201: remove local variable addr

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 




On 23 March 2017 14:48:10 GMT+00:00, Julia Lawall <julia.lawall@xxxxxxx> 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@xxxxxxxxx>
>> ---
>>  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@xxxxxxxxxxxxxxxx.
>> To post to this group, send email to
>outreachy-kernel@xxxxxxxxxxxxxxxx.
>> 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@xxxxxxxxxxxxxxx
>More majordomo info at  http://vger.kernel.org/majordomo-info.html

-- 
Sent from my Android device with K-9 Mail. Please excuse my brevity.
--
To unsubscribe from this list: send the line "unsubscribe linux-iio" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html



[Index of Archives]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Yosemite News]     [Linux Input]     [Linux Kernel]     [Linux SCSI]     [X.org]

  Powered by Linux