Skip to content

Commit

Permalink
staging:iio:adis16260: Fix drvdata inconsistency
Browse files Browse the repository at this point in the history
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:

// <smpl>
@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)
// </smpl>

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
Signed-off-by: Jonathan Cameron <jic23@kernel.org>
  • Loading branch information
Lars-Peter Clausen authored and Jonathan Cameron committed Jul 14, 2012
1 parent 2b6e6b8 commit 97271c3
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion drivers/staging/iio/gyro/adis16260_core.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down

0 comments on commit 97271c3

Please sign in to comment.