staging:iio:imu:adis16400 avoid allocating rx, tx, and state separately from iio_dev.
Uses the iio_allocate_device parameter to set aside space for adis16400_state and
____cacheline_aligned buffers for tx and rx to avoid separatel allocating them.
Signed-off-by: Jonathan Cameron <jic23@cam.ac.uk>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
diff --git a/drivers/staging/iio/imu/adis16400_ring.c b/drivers/staging/iio/imu/adis16400_ring.c
index c56c655..271fe1d 100644
--- a/drivers/staging/iio/imu/adis16400_ring.c
+++ b/drivers/staging/iio/imu/adis16400_ring.c
@@ -27,7 +27,7 @@
{
struct spi_message msg;
struct iio_dev *indio_dev = dev_get_drvdata(dev);
- struct adis16400_state *st = iio_dev_get_devdata(indio_dev);
+ struct adis16400_state *st = iio_priv(indio_dev);
u32 old_speed_hz = st->us->max_speed_hz;
int ret;
@@ -81,20 +81,19 @@
static int adis16350_spi_read_all(struct device *dev, u8 *rx)
{
struct iio_dev *indio_dev = dev_get_drvdata(dev);
- struct adis16400_state *st = iio_dev_get_devdata(indio_dev);
+ struct adis16400_state *st = iio_priv(indio_dev);
struct spi_message msg;
int i, j = 0, ret;
struct spi_transfer *xfers;
- xfers = kzalloc(sizeof(*xfers)*
- st->indio_dev->ring->scan_count + 1,
- GFP_KERNEL);
+ xfers = kzalloc(sizeof(*xfers)*indio_dev->ring->scan_count + 1,
+ GFP_KERNEL);
if (xfers == NULL)
return -ENOMEM;
for (i = 0; i < ARRAY_SIZE(read_all_tx_array); i++)
- if (st->indio_dev->ring->scan_mask & (1 << i)) {
+ if (indio_dev->ring->scan_mask & (1 << i)) {
xfers[j].tx_buf = &read_all_tx_array[i];
xfers[j].bits_per_word = 16;
xfers[j].len = 2;
@@ -105,7 +104,7 @@
xfers[j].len = 2;
spi_message_init(&msg);
- for (j = 0; j < st->indio_dev->ring->scan_count + 1; j++)
+ for (j = 0; j < indio_dev->ring->scan_count + 1; j++)
spi_message_add_tail(&xfers[j], &msg);
ret = spi_sync(st->us, &msg);
@@ -121,7 +120,7 @@
{
struct iio_poll_func *pf = p;
struct iio_dev *indio_dev = pf->private_data;
- struct adis16400_state *st = iio_dev_get_devdata(indio_dev);
+ struct adis16400_state *st = iio_priv(indio_dev);
struct iio_ring_buffer *ring = indio_dev->ring;
int i = 0, j, ret = 0;
s16 *data;
@@ -174,7 +173,7 @@
int adis16400_configure_ring(struct iio_dev *indio_dev)
{
int ret = 0;
- struct adis16400_state *st = iio_dev_get_devdata(indio_dev);
+ struct adis16400_state *st = iio_priv(indio_dev);
struct iio_ring_buffer *ring;
ring = iio_sw_rb_allocate(indio_dev);