iio: proximity: as3935: fix major drivers
cover iio: proximity: as3935: fix major drivers
This series has some major ABI changes, and bugfixes related to stack corruption.
Seems these partly are to blame from the driver's author being in one the least active thunderstorm parts of the world (Oregon has almost none).
Matt Ranostay (3):
iio: proximity: as3935: correct IIO_CHAN_INFO_RAW output
iio: proximity: as3935: remove triggered buffer processing
iio: proximity: as3935: fix buffer stack trashing
.../ABI/testing/sysfs-bus-iio-proximity-as3935 | 2 +- drivers/iio/proximity/as3935.c | 17 ++++++++++++----- 2 files changed, 13 insertions(+), 6 deletions(-)
Signature · 1 line
2.7.4
PATCH 1/3 iio: proximity: as3935: correct IIO_CHAN_INFO_RAW output
IIO_CHAN_INFO_RAW was returning processed data which was incorrect. This also adds the IIO_CHAN_INFO_SCALE value to convert to a processed value.
--- Documentation/ABI/testing/sysfs-bus-iio-proximity-as3935 | 2 +- drivers/iio/proximity/as3935.c | 10 ++++++++-- 2 files changed, 9 insertions(+), 3 deletions(-)
Documentation/ABI/testing/sysfs-bus-iio-proximity-as3935 +1 -1
@@ -1,4 +1,4 @@ -What /sys/bus/iio/devices/iio:deviceX/in_proximity_raw +What /sys/bus/iio/devices/iio:deviceX/in_proximity_input Date: March 2014 KernelVersion: 3.15 Contact: Matt Ranostay <[email protected]>
drivers/iio/proximity/as3935.c +8 -2
@@ -72,7 +72,8 @@ static const struct iio_chan_spec as3935_channels[] = { .type = IIO_PROXIMITY, .info_mask_separate =BIT (IIO_CHAN_INFO_RAW ) | - BIT(IIO_CHAN_INFO_PROCESSED), +BIT (IIO_CHAN_INFO_PROCESSED ) | + BIT(IIO_CHAN_INFO_SCALE), .scan_index = 0, .scan_type = { .sign = 'u',
@@ -181,7 +182,12 @@ static int as3935_read_raw(struct iio_dev *indio_dev,/* storm out of range */ if (*val ==AS3935_DATA_MASK )return -EINVAL ; - *val *=1000 ; + +if (m ==IIO_CHAN_INFO_PROCESSED ) + *val *=1000 ; +break ; +case IIO_CHAN_INFO_SCALE : + *val =1000 ;break ;default :return -EINVAL ;
Signature · 1 line
2.7.4
PATCH 2/3 iio: proximity: as3935: remove triggered buffer processing
In reply to Matt RanostayTriggered buffers shouldn't return processed data, and the respective conversion was overflowing the defined .realbits for the channel.
--- drivers/iio/proximity/as3935.c | 1 - 1 file changed, 1 deletion(-)
drivers/iio/proximity/as3935.c +0 -1
@@ -213,7 +213,6 @@ static irqreturn_t as3935_trigger_handler(int irq, void *private)if (ret) goto err_read; val &=AS3935_DATA_MASK ; - val *=1000 ;iio_push_to_buffers_with_timestamp (indio_dev, &val, pf->timestamp); err_read:
Signature · 1 line
2.7.4
PATCH 3/3 iio: proximity: as3935: fix buffer stack trashing
In reply to Matt RanostayBuffer wasn't of a valid size to allow the timestamp, and correct padding. This patchset also moves the buffer off the stack, and onto the heap.
--- drivers/iio/proximity/as3935.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-)
drivers/iio/proximity/as3935.c +4 -2
@@ -64,6 +64,7 @@ struct as3935_state {struct delayed_work work;u32 tune_cap; +u8 buffer[16 ];/* 8-bit data + 54-bit padding + 64-bit timestamp */ u8 buf[2 ]____cacheline_aligned ; };
@@ -212,9 +213,10 @@ static irqreturn_t as3935_trigger_handler(int irq, void *private) ret =as3935_read (st,AS3935_DATA , &val);if (ret) goto err_read; - val &=AS3935_DATA_MASK ; -iio_push_to_buffers_with_timestamp (indio_dev, &val, pf->timestamp); + st->buffer[0 ] = val &AS3935_DATA_MASK ; +iio_push_to_buffers_with_timestamp (indio_dev, &st->buffer, + pf->timestamp); err_read:iio_trigger_notify_done (indio_dev->trig);
Signature · 1 line
2.7.4
Re: [PATCH 3/3] iio: proximity: as3935: fix buffer stack trashing
Quoted 17 lines · Matt Ranostay
Buffer wasn't of a valid size to allow the timestamp, and correct padding. This patchset also moves the buffer off the stack, and onto the heap.
Signed-off-by Matt Ranostay <[email protected]>---
drivers/iio/proximity/as3935.c| 6 ++++--1 file changed, 4 insertions(+), 2 deletions(-)drivers/iio/proximity/as3935.c +0
-0
drivers/iio/proximity/as3935.c struct as3935_state { · line 67
Quoted 4 lines
drivers/iio/proximity/as3935.c +1
-0@@ -64,6 +64,7 @@ struct as3935_state {struct delayed_work work;u32 tune_cap; +u8 buffer[16 ];/* 8-bit data + 54-bit padding + 64-bit timestamp */
Just noticed that should be noted as 56-bit
Quoted 19 lines
drivers/iio/proximity/as3935.c +3
-2u8 buf[2 ]____cacheline_aligned ; };@@ -212,9 +213,10 @@ static irqreturn_t as3935_trigger_handler(int irq, void *private) ret =as3935_read (st,AS3935_DATA , &val);if (ret) goto err_read; - val &=AS3935_DATA_MASK ; -iio_push_to_buffers_with_timestamp (indio_dev, &val, pf->timestamp); + st->buffer[0 ] = val &AS3935_DATA_MASK ; +iio_push_to_buffers_with_timestamp (indio_dev, &st->buffer, + pf->timestamp);
err_read:iio_trigger_notify_done(indio_dev->trig);Signature · 1 line
2.7.4
Re: [PATCH 1/3] iio: proximity: as3935: correct IIO_CHAN_INFO_RAW output
In reply to Matt RanostayQuoted 4 lines · Matt Ranostay
IIO_CHAN_INFO_RAWwas returning processed data which was incorrect. This also adds theIIO_CHAN_INFO_SCALEvalue to convert to a processed value.Signed-off-by Matt Ranostay <[email protected]>
Applied to the fixes-togreg-post-rc1 branch of iio.git and marked for stable.
Thanks,
Jonathan
Quoted 44 lines
--- Documentation/ABI/testing/sysfs-bus-iio-proximity-as3935 | 2 +- drivers/iio/proximity/as3935.c | 10 ++++++++-- 2 files changed, 9 insertions(+), 3 deletions(-)Documentation/ABI/testing/sysfs-bus-iio-proximity-as3935 +1
-1@@ -1,4 +1,4 @@ -What /sys/bus/iio/devices/iio:deviceX/in_proximity_raw +What /sys/bus/iio/devices/iio:deviceX/in_proximity_input Date: March 2014 KernelVersion: 3.15 Contact: Matt Ranostay <[email protected]>drivers/iio/proximity/as3935.c +8
-2@@ -72,7 +72,8 @@ static const struct iio_chan_spec as3935_channels[] = { .type = IIO_PROXIMITY, .info_mask_separate =BIT (IIO_CHAN_INFO_RAW ) | - BIT(IIO_CHAN_INFO_PROCESSED), +BIT (IIO_CHAN_INFO_PROCESSED ) | + BIT(IIO_CHAN_INFO_SCALE), .scan_index = 0, .scan_type = { .sign = 'u',@@ -181,7 +182,12 @@ static int as3935_read_raw(struct iio_dev *indio_dev,/* storm out of range */ if (*val ==AS3935_DATA_MASK )return -EINVAL ; - *val *=1000 ; + +if (m ==IIO_CHAN_INFO_PROCESSED ) + *val *=1000 ; +break ; +case IIO_CHAN_INFO_SCALE : + *val =1000 ;break ;default :return -EINVAL ;
Re: [PATCH 2/3] iio: proximity: as3935: remove triggered buffer processing
In reply to Matt RanostayQuoted 5 lines · Matt Ranostay
Triggered buffers shouldn't return processed data, and the respective conversion was overflowing the defined .realbits for the channel.
Signed-off-by Matt Ranostay <[email protected]>
Applied to the fixes-togreg-post-rc1 branch of iio.git (because it was handy) and marked for stable.
Quoted 17 lines
--- drivers/iio/proximity/as3935.c | 1 - 1 file changed, 1 deletion(-)drivers/iio/proximity/as3935.c +0
-1@@ -213,7 +213,6 @@ static irqreturn_t as3935_trigger_handler(int irq, void *private)if (ret) goto err_read; val &=AS3935_DATA_MASK ; - val *=1000 ;iio_push_to_buffers_with_timestamp (indio_dev, &val, pf->timestamp); err_read:
Re: [PATCH 3/3] iio: proximity: as3935: fix buffer stack trashing
In reply to Matt RanostayQuoted 8 lines · Matt Ranostay
Quoted 8 lines · Matt Ranostay
Buffer wasn't of a valid size to allow the timestamp, and correct padding. This patchset also moves the buffer off the stack, and onto the heap.
Signed-off-by Matt Ranostay <[email protected]>
Applied as per the other 2.
Quoted 11 lines
Quoted 11 lines
---
drivers/iio/proximity/as3935.c| 6 ++++--1 file changed, 4 insertions(+), 2 deletions(-)drivers/iio/proximity/as3935.c +0
-0@@ -64,6 +64,7 @@ struct as3935_state {struct delayed_work work;
Quoted 4 lines
drivers/iio/proximity/as3935.c struct as3935_state { · line 67
Quoted 2 lines
drivers/iio/proximity/as3935.c +1
-0u32 tune_cap; +u8 buffer[16 ];/* 8-bit data + 54-bit padding + 64-bit timestamp */ Just noticed that should be noted as 56-bit
Fixed up.
Quoted 25 lines
Quoted 15 lines
drivers/iio/proximity/as3935.c +3
-2u8 buf[2 ]____cacheline_aligned ; };@@ -212,9 +213,10 @@ static irqreturn_t as3935_trigger_handler(int irq, void *private) ret =as3935_read (st,AS3935_DATA , &val);if (ret) goto err_read; - val &=AS3935_DATA_MASK ; -iio_push_to_buffers_with_timestamp (indio_dev, &val, pf->timestamp); + st->buffer[0 ] = val &AS3935_DATA_MASK ; +iio_push_to_buffers_with_timestamp (indio_dev, &st->buffer, + pf->timestamp);
err_read:Quoted 5 lines
iio_trigger_notify_done(indio_dev->trig);Signature · 1 line
2.7.4--
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