staging:iio:adis16260: Fix drvdata inconsistency

Author: Lars-Peter Clausen <lars@metafoo.de>

The SPI drvdata is set to adis16260_state struct in probe(), but assumed to be
the iio_dev struct in remove(). Fix this by setting it to the iio_dev in
probe().

The issue has been discovered using the following coccinelle patch:

// 
@r1@
type T;
T data;
expression dev;
@@
(
spi_set_drvdata(dev, (void *)data)
|
spi_set_drvdata(dev, data)
)

@r2@
type r1.T;
T data;
position p;
expression dev;
@@
data = spi_get_drvdata@p(dev)

@depends on r1@
position p != r2.p;
expression dev;
identifier data;
@@
*data = spi_get_drvdata@p(dev)
// 

Signed-off-by: Lars-Peter Clausen 
Signed-off-by: Jonathan Cameron 
---
 drivers/staging/iio/gyro/adis16260_core.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
 
diff --git a/drivers/staging/iio/gyro/adis16260_core.c b/drivers/staging/iio/gyro/adis16260_core.c
index f16b393..93aa431 100644
--- a/drivers/staging/iio/gyro/adis16260_core.c
+++ b/drivers/staging/iio/gyro/adis16260_core.c
@@ -617,7 +617,7 @@ static int __devinit adis16260_probe(struct spi_device *spi)
 	if (pd)
 		st->negate = pd->negate;
 	/* this is only used for removal purposes */
-	spi_set_drvdata(spi, st);
+	spi_set_drvdata(spi, indio_dev);
 
 	st->us = spi;
 	mutex_init(&st->buf_lock);
BtrLinux
Privacy Overview

This website uses cookies so that we can provide you with the best user experience possible. Cookie information is stored in your browser and performs functions such as recognising you when you return to our website and helping our team to understand which sections of the website you find most interesting and useful.