staging:iio:adis16080: Perform sign extension
Subsystems (4)
PATCH 1/7 staging:iio:adis16080: Perform sign extension
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.
---
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(-)
drivers/staging/iio/gyro/adis16080_core.c +1 -1
@@ -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);return ret;
Signature · 1 line
1.8.0
PATCH 2/7 staging:iio:adis16080: Add device id table entry for the adis16100
The adis16100 is very similar to the adis16080. The driver description already states that the driver supports the adis16100 as-well. But so far the there is no device id table for the adis16100 and the drivers does not bind to a device named adis16100.
--- drivers/staging/iio/gyro/Kconfig | 4 ++-- drivers/staging/iio/gyro/adis16080_core.c | 9 ++++++++- 2 files changed, 10 insertions(+), 3 deletions(-)
drivers/staging/iio/gyro/Kconfig +2 -2
@@ -14,8 +14,8 @@ config ADIS16080 tristate "Analog Devices ADIS16080/100 Yaw Rate Gyroscope with SPI driver" depends on SPI help - Say yes here to build support for Analog Devices adis16080/100 Yaw Rate - Gyroscope with SPI. + Say yes here to build support for Analog Devices ADIS16080, ADIS16100 Yaw + Rate Gyroscope with SPI. config ADIS16130 tristate "Analog Devices ADIS16130 High Precision Angular Rate Sensor driver"
drivers/staging/iio/gyro/adis16080_core.c +8 -1
@@ -185,6 +185,13 @@ static int adis16080_remove(struct spi_device *spi)return 0 ; } +static const struct spi_device_id adis16080_ids[] = { + {"adis16080" ,0 }, + {"adis16100" ,0 }, + {}, +}; +MODULE_DEVICE_TABLE (spi, adis16080_ids); +static struct spi_driver adis16080_driver = { .driver = { .name ="adis16080" ,
@@ -192,10 +199,10 @@ static struct spi_driver adis16080_driver = { }, .probe = adis16080_probe, .remove = adis16080_remove, + .id_table = adis16080_ids, };module_spi_driver (adis16080_driver);MODULE_AUTHOR ("Barry Song <[email protected]>" );MODULE_DESCRIPTION ("Analog Devices ADIS16080/100 Yaw Rate Gyroscope Driver" );MODULE_LICENSE ("GPL v2" ); -MODULE_ALIAS ("spi:adis16080" );
Signature · 1 line
1.8.0
Re: [PATCH 2/7] staging:iio:adis16080: Add device id table entry for the adis16100
Quoted 6 lines · Lars-Peter Clausen
The adis16100 is very similar to the adis16080. The driver description already states that the driver supports the adis16100 as-well. But so far the there is no device id table for the adis16100 and the drivers does not bind to a device named adis16100.
Signed-off-by Lars-Peter Clausen <[email protected]>
applied to togreg branch of iio.git
Quoted 51 lines
--- drivers/staging/iio/gyro/Kconfig | 4 ++-- drivers/staging/iio/gyro/adis16080_core.c | 9 ++++++++- 2 files changed, 10 insertions(+), 3 deletions(-)drivers/staging/iio/gyro/Kconfig +2
-2@@ -14,8 +14,8 @@ config ADIS16080 tristate "Analog Devices ADIS16080/100 Yaw Rate Gyroscope with SPI driver" depends on SPI help - Say yes here to build support for Analog Devices adis16080/100 Yaw Rate - Gyroscope with SPI. + Say yes here to build support for Analog Devices ADIS16080, ADIS16100 Yaw + Rate Gyroscope with SPI. config ADIS16130 tristate "Analog Devices ADIS16130 High Precision Angular Rate Sensor driver"drivers/staging/iio/gyro/adis16080_core.c +8
-1@@ -185,6 +185,13 @@ static int adis16080_remove(struct spi_device *spi)return 0 ; } +static const struct spi_device_id adis16080_ids[] = { + {"adis16080" ,0 }, + {"adis16100" ,0 }, + {}, +}; +MODULE_DEVICE_TABLE (spi, adis16080_ids); +static struct spi_driver adis16080_driver = { .driver = { .name ="adis16080" ,@@ -192,10 +199,10 @@ static struct spi_driver adis16080_driver = { }, .probe = adis16080_probe, .remove = adis16080_remove, + .id_table = adis16080_ids, };module_spi_driver (adis16080_driver);MODULE_AUTHOR ("Barry Song <[email protected]>" );MODULE_DESCRIPTION ("Analog Devices ADIS16080/100 Yaw Rate Gyroscope Driver" );MODULE_LICENSE ("GPL v2" ); -MODULE_ALIAS ("spi:adis16080" );
PATCH 3/7 staging:iio:adis16080: Cleanup SPI transfer
In reply to Lars-Peter ClausenDuring sampling the driver currently does a spi_read followed by a spi_write. This is not a problem per se, since CS needs to be deasserted between the two transfers. So even if another device claims the bus between the two transfers we should still get a result. But the code is actually spread out over multiple functions. E.g. the spi_read happens in one function the spi_write in another, this makes the code harder to follow. This patch re-factors the code to just use a single spi transaction to do both the read and the write transfer.
--- drivers/staging/iio/gyro/adis16080_core.c | 61 +++++++++++++------------------ 1 file changed, 25 insertions(+), 36 deletions(-)
drivers/staging/iio/gyro/adis16080_core.c +25 -36
@@ -42,32 +42,32 @@ struct adis16080_state {u8 buf[2 ]____cacheline_aligned ; }; -static int adis16080_spi_write (struct iio_dev *indio_dev, -u16 val) +static int adis16080_read_sample (struct iio_dev *indio_dev, +u16 addr,int *val) { -int ret;struct adis16080_state *st =iio_priv (indio_dev); - -mutex_lock (&st->buf_lock); - st->buf[0 ] = val >>8 ; - st->buf[1 ] = val; - - ret =spi_write (st->us, st->buf,2 ); -mutex_unlock (&st->buf_lock); - -return ret; -} - -static int adis16080_spi_read (struct iio_dev *indio_dev, -u16 *val) -{ +struct spi_message m;int ret; -struct adis16080_state *st =iio_priv (indio_dev); +struct spi_transfer t[] = { + { + .tx_buf = &st->buf, + .len =2 , + .cs_change =1 , + }, { + .rx_buf = &st->buf, + .len =2 , + }, + };mutex_lock (&st->buf_lock); + st->buf[0 ] = addr >>8 ; + st->buf[1 ] = addr; - ret =spi_read (st->us, st->buf,2 ); +spi_message_init (&m); +spi_message_add_tail (&t[0 ], &m); +spi_message_add_tail (&t[1 ], &m); + ret =spi_sync (st->us, &m);if (ret ==0 ) *val =sign_extend32 (12 , ((st->buf[0 ] &0xF ) <<8 ) | st->buf[1 ]);mutex_unlock (&st->buf_lock);
@@ -81,28 +81,17 @@ static int adis16080_read_raw(struct iio_dev *indio_dev,int *val2, long mask) { - int ret = -EINVAL; -u16 ut =0 ; -/* Take the iio_dev status lock */ + int ret; -mutex_lock (&indio_dev->mlock);switch (mask) {case IIO_CHAN_INFO_RAW : - ret =adis16080_spi_write (indio_dev, - chan->address | -ADIS16080_DIN_WRITE ); -if (ret <0 ) -break ; - ret =adis16080_spi_read (indio_dev, &ut); -if (ret <0 ) -break ; - *val = ut; - ret =IIO_VAL_INT ; -break ; +mutex_lock (&indio_dev->mlock); + ret =adis16080_read_sample (indio_dev, chan->address, val); +mutex_unlock (&indio_dev->mlock); +return ret ? ret :IIO_VAL_INT ; } -mutex_unlock (&indio_dev->mlock); -return ret; +return -EINVAL ; } static const struct iio_chan_spec adis16080_channels[] = {
Signature · 1 line
1.8.0
Jonathan Cameron
maintainerRe: [PATCH 3/7] staging:iio:adis16080: Cleanup SPI transfer
Quoted 9 lines · Lars-Peter Clausen
During sampling the driver currently does a
spi_readfollowed by aspi_write. This is not a problem per se, since CS needs to be deasserted between the two transfers. So even if another device claims the bus between the two transfers we should still get a result. But the code is actually spread out over multiple functions. E.g. thespi_readhappens in one function thespi_writein another, this makes the code harder to follow. This patch re-factors the code to just use a single spi transaction to do both the read and the write transfer.Signed-off-by Lars-Peter Clausen <[email protected]>
Definitely an improvement.
Added to togreg branch of iio.git There was a bit of fuzz as patch 1 has changed and for that matter is going through a different route so wasn't there. Nothing significant though..
Quoted 96 lines
--- drivers/staging/iio/gyro/adis16080_core.c | 61 +++++++++++++------------------ 1 file changed, 25 insertions(+), 36 deletions(-)drivers/staging/iio/gyro/adis16080_core.c +25
-36@@ -42,32 +42,32 @@ struct adis16080_state {u8 buf[2 ]____cacheline_aligned ; }; -static int adis16080_spi_write (struct iio_dev *indio_dev, -u16 val) +static int adis16080_read_sample (struct iio_dev *indio_dev, +u16 addr,int *val) { -int ret;struct adis16080_state *st =iio_priv (indio_dev); - -mutex_lock (&st->buf_lock); - st->buf[0 ] = val >>8 ; - st->buf[1 ] = val; - - ret =spi_write (st->us, st->buf,2 ); -mutex_unlock (&st->buf_lock); - -return ret; -} - -static int adis16080_spi_read (struct iio_dev *indio_dev, -u16 *val) -{ +struct spi_message m;int ret; -struct adis16080_state *st =iio_priv (indio_dev); +struct spi_transfer t[] = { + { + .tx_buf = &st->buf, + .len =2 , + .cs_change =1 , + }, { + .rx_buf = &st->buf, + .len =2 , + }, + };mutex_lock (&st->buf_lock); + st->buf[0 ] = addr >>8 ; + st->buf[1 ] = addr; - ret =spi_read (st->us, st->buf,2 ); +spi_message_init (&m); +spi_message_add_tail (&t[0 ], &m); +spi_message_add_tail (&t[1 ], &m); + ret =spi_sync (st->us, &m);if (ret ==0 ) *val =sign_extend32 (12 , ((st->buf[0 ] &0xF ) <<8 ) | st->buf[1 ]);mutex_unlock (&st->buf_lock);@@ -81,28 +81,17 @@ static int adis16080_read_raw(struct iio_dev *indio_dev,int *val2, long mask) { - int ret = -EINVAL; -u16 ut =0 ; -/* Take the iio_dev status lock */ + int ret; -mutex_lock (&indio_dev->mlock);switch (mask) {case IIO_CHAN_INFO_RAW : - ret =adis16080_spi_write (indio_dev, - chan->address | -ADIS16080_DIN_WRITE ); -if (ret <0 ) -break ; - ret =adis16080_spi_read (indio_dev, &ut); -if (ret <0 ) -break ; - *val = ut; - ret =IIO_VAL_INT ; -break ; +mutex_lock (&indio_dev->mlock); + ret =adis16080_read_sample (indio_dev, chan->address, val); +mutex_unlock (&indio_dev->mlock); +return ret ? ret :IIO_VAL_INT ; } -mutex_unlock (&indio_dev->mlock); -return ret; +return -EINVAL ; } static const struct iio_chan_spec adis16080_channels[] = {
PATCH 4/7 staging:iio:adis16080: be16 cleanups
In reply to Lars-Peter ClausenThe sample buffer contains big endian 16bit words. So use the be16 datatype for the buffer and use the proper helper functions for endianness conversion instead of openconding it.
--- drivers/staging/iio/gyro/adis16080_core.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-)
drivers/staging/iio/gyro/adis16080_core.c +3 -4
@@ -39,7 +39,7 @@ struct adis16080_state {struct spi_device *us;struct mutex buf_lock; -u8 buf[2 ]____cacheline_aligned ; +__be16 buf____cacheline_aligned ; }; static int adis16080_read_sample(struct iio_dev *indio_dev,
@@ -60,8 +60,7 @@ static int adis16080_read_sample(struct iio_dev *indio_dev, };mutex_lock (&st->buf_lock); - st->buf[0 ] = addr >>8 ; - st->buf[1 ] = addr; + st->buf =cpu_to_be16 (addr |ADIS16080_DIN_WRITE );spi_message_init (&m);spi_message_add_tail (&t[0 ], &m);
@@ -69,7 +68,7 @@ static int adis16080_read_sample(struct iio_dev *indio_dev, ret =spi_sync (st->us, &m);if (ret ==0 ) - *val =sign_extend32 (12 , ((st->buf[0 ] &0xF ) <<8 ) | st->buf[1 ]); + *val =sign_extend32 (12 ,be16_to_cpu (st->buf));mutex_unlock (&st->buf_lock);return ret;
Signature · 1 line
1.8.0
Jonathan Cameron
maintainerRe: [PATCH 4/7] staging:iio:adis16080: be16 cleanups
Quoted 5 lines · Lars-Peter Clausen
The sample buffer contains big endian 16bit words. So use the be16 datatype for the buffer and use the proper helper functions for endianness conversion instead of openconding it.
Signed-off-by Lars-Peter Clausen <[email protected]>
Hmm.. Should have read on. Having seen this I'm going to back out the series and wait for the fix to propogate through to Greg's staging-next tree. Annoying but we are fairly early in the cycle so if I get that out to him sometime in the next few days there should be masses of time to add this series later.
Thanks
Jonathan
Quoted 37 lines
--- drivers/staging/iio/gyro/adis16080_core.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-)drivers/staging/iio/gyro/adis16080_core.c +3
-4@@ -39,7 +39,7 @@ struct adis16080_state {struct spi_device *us;struct mutex buf_lock; -u8 buf[2 ]____cacheline_aligned ; +__be16 buf____cacheline_aligned ; }; static int adis16080_read_sample(struct iio_dev *indio_dev,@@ -60,8 +60,7 @@ static int adis16080_read_sample(struct iio_dev *indio_dev, };mutex_lock (&st->buf_lock); - st->buf[0 ] = addr >>8 ; - st->buf[1 ] = addr; + st->buf =cpu_to_be16 (addr |ADIS16080_DIN_WRITE );spi_message_init (&m);spi_message_add_tail (&t[0 ], &m);@@ -69,7 +68,7 @@ static int adis16080_read_sample(struct iio_dev *indio_dev, ret =spi_sync (st->us, &m);if (ret ==0 ) - *val =sign_extend32 (12 , ((st->buf[0 ] &0xF ) <<8 ) | st->buf[1 ]); + *val =sign_extend32 (12 ,be16_to_cpu (st->buf));mutex_unlock (&st->buf_lock);return ret;
PATCH 5/7 staging:iio:adis16080: Remove unnecessary lock
In reply to Lars-Peter ClausenAll sections in which the transfer buffer is accessed are already protected by the IIO device's mlock. So we do not need the extra mutex protecting the buffer.
--- drivers/staging/iio/gyro/adis16080_core.c | 5 ----- 1 file changed, 5 deletions(-)
drivers/staging/iio/gyro/adis16080_core.c +0 -5
@@ -33,11 +33,9 @@* struct adis16080_state - device instance specific data * @us: actual spi_device to write data * @buf: transmit or receive buffer -* @buf_lock: mutex to protect tx and rx **/ struct adis16080_state {struct spi_device *us; -struct mutex buf_lock;__be16 buf____cacheline_aligned ; };
@@ -59,7 +57,6 @@ static int adis16080_read_sample(struct iio_dev *indio_dev, }, }; -mutex_lock (&st->buf_lock); st->buf =cpu_to_be16 (addr |ADIS16080_DIN_WRITE );spi_message_init (&m);
@@ -69,7 +66,6 @@ static int adis16080_read_sample(struct iio_dev *indio_dev, ret =spi_sync (st->us, &m);if (ret ==0 ) *val =sign_extend32 (12 ,be16_to_cpu (st->buf)); -mutex_unlock (&st->buf_lock);return ret; }
@@ -144,7 +140,6 @@ static int adis16080_probe(struct spi_device *spi)/* Allocate the comms buffers */ st->us = spi; -mutex_init (&st->buf_lock); indio_dev->name = spi->dev.driver->name; indio_dev->channels = adis16080_channels;
Signature · 1 line
1.8.0
PATCH 6/7 staging:iio:adis16080: Add scale and offset attributes
In reply to Lars-Peter ClausenReport scale and offset for the velocity, voltage and temperature channels.
--- drivers/staging/iio/gyro/adis16080_core.c | 81 ++++++++++++++++++++++++++++--- 1 file changed, 75 insertions(+), 6 deletions(-)
drivers/staging/iio/gyro/adis16080_core.c +75 -6
@@ -29,13 +29,20 @@#define ADIS16080_DIN_WRITE (1 << 15) +struct adis16080_chip_info { +int scale_val; +int scale_val2; +}; +/** * struct adis16080_state - device instance specific data * @us: actual spi_device to write data +* @info: chip specific parameters * @buf: transmit or receive buffer **/ struct adis16080_state {struct spi_device *us; +const struct adis16080_chip_info *info;__be16 buf____cacheline_aligned ; };
@@ -76,6 +83,7 @@ static int adis16080_read_raw(struct iio_dev *indio_dev, int *val2, long mask) { +struct adis16080_state *st =iio_priv (indio_dev);int ret;switch (mask) {
@@ -84,6 +92,40 @@ static int adis16080_read_raw(struct iio_dev *indio_dev, ret =adis16080_read_sample (indio_dev, chan->address, val);mutex_unlock (&indio_dev->mlock);return ret ? ret :IIO_VAL_INT ; +case IIO_CHAN_INFO_SCALE : +switch (chan->type) { +case IIO_ANGL_VEL : + *val = st->info->scale_val; + *val2 = st->info->scale_val2; +return IIO_VAL_FRACTIONAL ; +case IIO_VOLTAGE : +/* VREF = 5V, 12 bits */ + *val =5000 ; + *val2 =12 ; +return IIO_VAL_FRACTIONAL_LOG2 ; +case IIO_TEMP : +/* 85 C = 585, 25 C = 0 */ + *val =85000 -25000 ; + *val2 =585 ; +return IIO_VAL_FRACTIONAL ; +default : +return -EINVAL ; + } +case IIO_CHAN_INFO_OFFSET : +switch (chan->type) { +case IIO_VOLTAGE : +/* 2.5 V = 0 */ + *val =2048 ; +return IIO_VAL_INT ; +case IIO_TEMP : +/* 85 C = 585, 25 C = 0 */ + *val =DIV_ROUND_CLOSEST (25 *585 ,85 -25 ); +return IIO_VAL_INT ; +default : +return -EINVAL ; + } +default : +break ; }return -EINVAL ;
@@ -94,25 +136,32 @@ static const struct iio_chan_spec adis16080_channels[] = { .type = IIO_ANGL_VEL, .modified = 1, .channel2 = IIO_MOD_Z, - .info_mask = IIO_CHAN_INFO_RAW_SEPARATE_BIT, + .info_mask = IIO_CHAN_INFO_RAW_SEPARATE_BIT | + IIO_CHAN_INFO_SCALE_SEPARATE_BIT, .address = ADIS16080_DIN_GYRO, }, { .type = IIO_VOLTAGE, .indexed = 1, .channel = 0, - .info_mask = IIO_CHAN_INFO_RAW_SEPARATE_BIT, + .info_mask =IIO_CHAN_INFO_RAW_SEPARATE_BIT | +IIO_CHAN_INFO_SCALE_SEPARATE_BIT | + IIO_CHAN_INFO_OFFSET_SEPARATE_BIT, .address = ADIS16080_DIN_AIN1, }, { .type = IIO_VOLTAGE, .indexed = 1, .channel = 1, - .info_mask = IIO_CHAN_INFO_RAW_SEPARATE_BIT, + .info_mask =IIO_CHAN_INFO_RAW_SEPARATE_BIT | +IIO_CHAN_INFO_SCALE_SEPARATE_BIT | + IIO_CHAN_INFO_OFFSET_SEPARATE_BIT, .address = ADIS16080_DIN_AIN2, }, { .type = IIO_TEMP, .indexed = 1, .channel = 0, - .info_mask = IIO_CHAN_INFO_RAW_SEPARATE_BIT, + .info_mask =IIO_CHAN_INFO_RAW_SEPARATE_BIT | +IIO_CHAN_INFO_SCALE_SEPARATE_BIT | + IIO_CHAN_INFO_OFFSET_SEPARATE_BIT, .address = ADIS16080_DIN_TEMP, } };
@@ -122,8 +171,27 @@ static const struct iio_info adis16080_info = { .driver_module = THIS_MODULE, }; +enum { +ID_ADIS16080 , +ID_ADIS16100 , +}; + +static const struct adis16080_chip_info adis16080_chip_info[] = { + [ID_ADIS16080 ] = { +/* 80 degree = 819, 819 rad = 46925 degree */ + .scale_val =80 , + .scale_val2 =46925 , + }, + [ID_ADIS16100 ] = { +/* 300 degree = 1230, 1230 rad = 70474 degree */ + .scale_val =300 , + .scale_val2 =70474 , + }, +}; +static int adis16080_probe (struct spi_device *spi) { +const struct spi_device_id *id =spi_get_device_id (spi);int ret;struct adis16080_state *st;struct iio_dev *indio_dev;
@@ -140,6 +208,7 @@ static int adis16080_probe(struct spi_device *spi)/* Allocate the comms buffers */ st->us = spi; + st->info = &adis16080_chip_info[id->driver_data]; indio_dev->name = spi->dev.driver->name; indio_dev->channels = adis16080_channels;
@@ -169,8 +238,8 @@ static int adis16080_remove(struct spi_device *spi) }static const struct spi_device_id adis16080_ids[] = { - {"adis16080" ,0 }, - {"adis16100" ,0 }, + {"adis16080" ,ID_ADIS16080 }, + {"adis16100" ,ID_ADIS16100 }, {}, };MODULE_DEVICE_TABLE (spi, adis16080_ids);
Signature · 1 line
1.8.0
PATCH 7/7 staging:iio:adis16080: Move out of staging
In reply to Lars-Peter ClausenThe driver is rather simple and in a good shape. It follows the IIO ABI and the standard codechecker tools do not report any issues, so move it out of staging.
While moving it also remove one outdated 'fixme' comment.
---
drivers/iio/gyro/Kconfig | 7 +++++++
drivers/iio/gyro/Makefile | 1 +
.../{staging/iio/gyro/adis16080_core.c => iio/gyro/adis16080.c} | 1 -
drivers/staging/iio/gyro/Kconfig | 7 -------
drivers/staging/iio/gyro/Makefile | 3 ---
5 files changed, 8 insertions(+), 11 deletions(-)
rename drivers/{staging/iio/gyro/adis16080_core.c => iio/gyro/adis16080.c} (99%)drivers/iio/gyro/Kconfig +7 -0
@@ -3,6 +3,13 @@ # menu "Digital gyroscope sensors" +config ADIS16080 + tristate "Analog Devices ADIS16080/100 Yaw Rate Gyroscope with SPI driver" + depends on SPI + help + Say yes here to build support for Analog Devices ADIS16080, ADIS16100 Yaw + Rate Gyroscope with SPI. + config ADIS16136 tristate "Analog devices ADIS16136 and similar gyroscopes driver" depends on SPI_MASTER
drivers/iio/gyro/Makefile +1 -0
@@ -2,5 +2,6 @@ # Makefile for industrial I/O gyroscope sensor drivers # +obj-$(CONFIG_ADIS16080) += adis16080.o obj-$(CONFIG_ADIS16136) += adis16136.o obj-$(CONFIG_HID_SENSOR_GYRO_3D) += hid-sensor-gyro-3d.o
drivers/iio/gyro/adis16080.c renamed from drivers/staging/iio/gyro/adis16080_core.c +0 -1
@@ -228,7 +228,6 @@ error_ret:return ret; } -/* fixme, confirm ordering in this function */ static int adis16080_remove (struct spi_device *spi) {iio_device_unregister (spi_get_drvdata (spi));
drivers/staging/iio/gyro/Kconfig +0 -7
@@ -10,13 +10,6 @@ config ADIS16060 Say yes here to build support for Analog Devices adis16060 wide bandwidth yaw rate gyroscope with SPI. -config ADIS16080 - tristate "Analog Devices ADIS16080/100 Yaw Rate Gyroscope with SPI driver" - depends on SPI - help - Say yes here to build support for Analog Devices ADIS16080, ADIS16100 Yaw - Rate Gyroscope with SPI. - config ADIS16130 tristate "Analog Devices ADIS16130 High Precision Angular Rate Sensor driver" depends on SPI
drivers/staging/iio/gyro/Makefile +0 -3
@@ -5,9 +5,6 @@ adis16060-y := adis16060_core.o obj-$(CONFIG_ADIS16060) += adis16060.o -adis16080-y := adis16080_core.o -obj-$(CONFIG_ADIS16080) += adis16080.o - adis16130-y := adis16130_core.o obj-$(CONFIG_ADIS16130) += adis16130.o
Signature · 1 line
1.8.0
Jonathan Cameron
maintainerQuoted 5 lines · Lars-Peter Clausen
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 <[email protected]>
Added to fixes-togreg branch of iio.git
Quoted 21 lines
---
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(-)drivers/staging/iio/gyro/adis16080_core.c +1
-1@@ -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);return ret;
Quoted 21 lines · Jonathan Cameron
Quoted 5 lines · Lars-Peter Clausen
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 <[email protected]>Added to fixes-togreg branch of iio.git
Quoted 14 lines
---
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(-)drivers/staging/iio/gyro/adis16080_core.c +0
-0@@ -69,7 +69,7 @@ static int adis16080_spi_read(struct iio_dev *indio_dev, ret =spi_read (st->us, st->buf,2 );
Quoted 5 lines
drivers/staging/iio/gyro/adis16080_core.c static int adis16080_spi_read(struct iio_dev *indio_dev, · line 74
Quoted 5 lines
drivers/staging/iio/gyro/adis16080_core.c +1
-1if (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
Jonathan Cameron
maintainerQuoted 31 lines · Lars-Peter Clausen
Quoted 21 lines · Jonathan Cameron
Quoted 5 lines · Lars-Peter Clausen
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 <[email protected]>Added to fixes-togreg branch of iio.git
Quoted 14 lines
---
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(-)drivers/staging/iio/gyro/adis16080_core.c +0
-0@@ -69,7 +69,7 @@ static int adis16080_spi_read(struct iio_dev *indio_dev, ret =spi_read (st->us, st->buf,2 );Quoted 5 lines
drivers/staging/iio/gyro/adis16080_core.c static int adis16080_spi_read(struct iio_dev *indio_dev, · line 74
Quoted 5 lines
drivers/staging/iio/gyro/adis16080_core.c +1
-1if (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,
Quoted 5 lines
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.
Jonathan Cameron
maintainerQuoted 9 lines · Jonathan Cameron
Quoted 8 lines · Lars-Peter Clausen
Quoted 7 lines · Jonathan Cameron
Quoted 5 lines · Lars-Peter Clausen
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 <[email protected]>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...
Quoted 36 lines
Quoted 23 lines
Quoted 14 lines
Quoted 14 lines
---
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(-)drivers/staging/iio/gyro/adis16080_core.c +0
-0@@ -69,7 +69,7 @@ static int adis16080_spi_read(struct iio_dev *indio_dev, ret =spi_read (st->us, st->buf,2 );Quoted 5 lines
drivers/staging/iio/gyro/adis16080_core.c static int adis16080_spi_read(struct iio_dev *indio_dev, · line 74
Quoted 5 lines
drivers/staging/iio/gyro/adis16080_core.c +1
-1if (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,
Quoted 5 lines
sign_extend32((st->buf[0] & 0xF) << 8)| st->buf[1], 11);Sorry again,
- LarsFixed 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 [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html