Re: [PATCH 1/7] staging:iio:adis16080: Perform sign extension

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

 



On 01/09/2013 09:16 PM, Jonathan Cameron wrote:
> On 01/09/2013 08:34 PM, Lars-Peter Clausen wrote:
>> On 01/09/2013 09:09 PM, Jonathan Cameron wrote:
>>> On 01/09/2013 02:01 PM, Lars-Peter Clausen wrote:
>>>> The adis16080 reports sample values in twos complement. So we need to perform a
>>>> sign extension on the result, otherwise negative values will be reported
>>>> incorrectly as large positive values.
>>>>
>>>> Signed-off-by: Lars-Peter Clausen <lars@xxxxxxxxxx>
>>> Added to fixes-togreg branch of iio.git
All now applied was a little fiddly as somehow the small change
here propogated to the context of about half the remaining patches.

Result all looks fine though...

>>>>
>>>> ---
>>>> This one should go into 3.8 if possible, the rest of the series is for 3.9
>>>> ---
>>>>  drivers/staging/iio/gyro/adis16080_core.c | 2 +-
>>>>  1 file changed, 1 insertion(+), 1 deletion(-)
>>>>
>>>> diff --git a/drivers/staging/iio/gyro/adis16080_core.c b/drivers/staging/iio/gyro/adis16080_core.c
>>>> index 3525a68..149ff99 100644
>>>> --- a/drivers/staging/iio/gyro/adis16080_core.c
>>>> +++ b/drivers/staging/iio/gyro/adis16080_core.c
>>>> @@ -69,7 +69,7 @@ static int adis16080_spi_read(struct iio_dev *indio_dev,
>>>>  	ret = spi_read(st->us, st->buf, 2);
>>>>  
>>>>  	if (ret == 0)
>>>> -		*val = ((st->buf[0] & 0xF) << 8) | st->buf[1];
>>>> +		*val = sign_extend32(12, ((st->buf[0] & 0xF) << 8) | st->buf[1]);
>>>>  	mutex_unlock(&st->buf_lock);
>>>>  
>>
>> Sorry, now that I look at it from a distance: This is completely wrong...
>> It needs to be,
>>
>> sign_extend32((st->buf[0] & 0xF) << 8) | st->buf[1], 11);
>>
>> Sorry again,
>> - Lars
>>
> Fixed up.
> 
> Hadn't pushed out yet anyway so only messing in my local tree.
> --
> 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
> 
--
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