diff options
| author | Michael Hennerich <michael.hennerich@analog.com> | 2011-05-18 09:42:36 -0400 |
|---|---|---|
| committer | Greg Kroah-Hartman <gregkh@suse.de> | 2011-05-19 19:15:05 -0400 |
| commit | a3f02370c9fa6d85fbee2c11649ebc9c84bae919 (patch) | |
| tree | 137f547f29e7f5e5954e5d82174b91bcebe8dca6 | |
| parent | 7df86302f4258764a3b8b1d63848dab3aa292654 (diff) | |
staging:iio:meter:ade7758: Use private data space from iio_allocate_device
Use private data space from iio_allocate_device.
Drop dev_data in favor of iio_priv().
Fix indention issues from previous patches.
Signed-off-by: Michael Hennerich <michael.hennerich@analog.com>
Acked-by: Jonathan Cameron <jic23@cam.ac.uk>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
| -rw-r--r-- | drivers/staging/iio/meter/ade7758.h | 10 | ||||
| -rw-r--r-- | drivers/staging/iio/meter/ade7758_core.c | 92 | ||||
| -rw-r--r-- | drivers/staging/iio/meter/ade7758_ring.c | 12 | ||||
| -rw-r--r-- | drivers/staging/iio/meter/ade7758_trigger.c | 18 |
4 files changed, 62 insertions, 70 deletions
diff --git a/drivers/staging/iio/meter/ade7758.h b/drivers/staging/iio/meter/ade7758.h index 372a9f62b3b2..fd74e156abf9 100644 --- a/drivers/staging/iio/meter/ade7758.h +++ b/drivers/staging/iio/meter/ade7758.h | |||
| @@ -111,7 +111,6 @@ | |||
| 111 | /** | 111 | /** |
| 112 | * struct ade7758_state - device instance specific data | 112 | * struct ade7758_state - device instance specific data |
| 113 | * @us: actual spi_device | 113 | * @us: actual spi_device |
| 114 | * @indio_dev: industrial I/O device structure | ||
| 115 | * @trig: data ready trigger registered with iio | 114 | * @trig: data ready trigger registered with iio |
| 116 | * @tx: transmit buffer | 115 | * @tx: transmit buffer |
| 117 | * @rx: receive buffer | 116 | * @rx: receive buffer |
| @@ -119,21 +118,20 @@ | |||
| 119 | **/ | 118 | **/ |
| 120 | struct ade7758_state { | 119 | struct ade7758_state { |
| 121 | struct spi_device *us; | 120 | struct spi_device *us; |
| 122 | struct iio_dev *indio_dev; | ||
| 123 | struct iio_trigger *trig; | 121 | struct iio_trigger *trig; |
| 124 | u8 *tx; | 122 | u8 *tx; |
| 125 | u8 *rx; | 123 | u8 *rx; |
| 126 | struct mutex buf_lock; | 124 | struct mutex buf_lock; |
| 127 | u32 available_scan_masks[AD7758_NUM_WAVESRC]; | 125 | u32 available_scan_masks[AD7758_NUM_WAVESRC]; |
| 128 | struct iio_chan_spec *ade7758_ring_channels; | 126 | struct iio_chan_spec *ade7758_ring_channels; |
| 129 | struct spi_transfer ring_xfer[4]; | 127 | struct spi_transfer ring_xfer[4]; |
| 130 | struct spi_message ring_msg; | 128 | struct spi_message ring_msg; |
| 131 | /* | 129 | /* |
| 132 | * DMA (thus cache coherency maintenance) requires the | 130 | * DMA (thus cache coherency maintenance) requires the |
| 133 | * transfer buffers to live in their own cache lines. | 131 | * transfer buffers to live in their own cache lines. |
| 134 | */ | 132 | */ |
| 135 | unsigned char rx_buf[8] ____cacheline_aligned; | 133 | unsigned char rx_buf[8] ____cacheline_aligned; |
| 136 | unsigned char tx_buf[8]; | 134 | unsigned char tx_buf[8]; |
| 137 | 135 | ||
| 138 | }; | 136 | }; |
| 139 | #ifdef CONFIG_IIO_RING_BUFFER | 137 | #ifdef CONFIG_IIO_RING_BUFFER |
diff --git a/drivers/staging/iio/meter/ade7758_core.c b/drivers/staging/iio/meter/ade7758_core.c index 42682ad0b26c..d9dfd8321222 100644 --- a/drivers/staging/iio/meter/ade7758_core.c +++ b/drivers/staging/iio/meter/ade7758_core.c | |||
| @@ -30,7 +30,7 @@ int ade7758_spi_write_reg_8(struct device *dev, | |||
| 30 | { | 30 | { |
| 31 | int ret; | 31 | int ret; |
| 32 | struct iio_dev *indio_dev = dev_get_drvdata(dev); | 32 | struct iio_dev *indio_dev = dev_get_drvdata(dev); |
| 33 | struct ade7758_state *st = iio_dev_get_devdata(indio_dev); | 33 | struct ade7758_state *st = iio_priv(indio_dev); |
| 34 | 34 | ||
| 35 | mutex_lock(&st->buf_lock); | 35 | mutex_lock(&st->buf_lock); |
| 36 | st->tx[0] = ADE7758_WRITE_REG(reg_address); | 36 | st->tx[0] = ADE7758_WRITE_REG(reg_address); |
| @@ -49,7 +49,7 @@ static int ade7758_spi_write_reg_16(struct device *dev, | |||
| 49 | int ret; | 49 | int ret; |
| 50 | struct spi_message msg; | 50 | struct spi_message msg; |
| 51 | struct iio_dev *indio_dev = dev_get_drvdata(dev); | 51 | struct iio_dev *indio_dev = dev_get_drvdata(dev); |
| 52 | struct ade7758_state *st = iio_dev_get_devdata(indio_dev); | 52 | struct ade7758_state *st = iio_priv(indio_dev); |
| 53 | struct spi_transfer xfers[] = { | 53 | struct spi_transfer xfers[] = { |
| 54 | { | 54 | { |
| 55 | .tx_buf = st->tx, | 55 | .tx_buf = st->tx, |
| @@ -78,7 +78,7 @@ static int ade7758_spi_write_reg_24(struct device *dev, | |||
| 78 | int ret; | 78 | int ret; |
| 79 | struct spi_message msg; | 79 | struct spi_message msg; |
| 80 | struct iio_dev *indio_dev = dev_get_drvdata(dev); | 80 | struct iio_dev *indio_dev = dev_get_drvdata(dev); |
| 81 | struct ade7758_state *st = iio_dev_get_devdata(indio_dev); | 81 | struct ade7758_state *st = iio_priv(indio_dev); |
| 82 | struct spi_transfer xfers[] = { | 82 | struct spi_transfer xfers[] = { |
| 83 | { | 83 | { |
| 84 | .tx_buf = st->tx, | 84 | .tx_buf = st->tx, |
| @@ -107,7 +107,7 @@ int ade7758_spi_read_reg_8(struct device *dev, | |||
| 107 | { | 107 | { |
| 108 | struct spi_message msg; | 108 | struct spi_message msg; |
| 109 | struct iio_dev *indio_dev = dev_get_drvdata(dev); | 109 | struct iio_dev *indio_dev = dev_get_drvdata(dev); |
| 110 | struct ade7758_state *st = iio_dev_get_devdata(indio_dev); | 110 | struct ade7758_state *st = iio_priv(indio_dev); |
| 111 | int ret; | 111 | int ret; |
| 112 | struct spi_transfer xfers[] = { | 112 | struct spi_transfer xfers[] = { |
| 113 | { | 113 | { |
| @@ -150,7 +150,7 @@ static int ade7758_spi_read_reg_16(struct device *dev, | |||
| 150 | { | 150 | { |
| 151 | struct spi_message msg; | 151 | struct spi_message msg; |
| 152 | struct iio_dev *indio_dev = dev_get_drvdata(dev); | 152 | struct iio_dev *indio_dev = dev_get_drvdata(dev); |
| 153 | struct ade7758_state *st = iio_dev_get_devdata(indio_dev); | 153 | struct ade7758_state *st = iio_priv(indio_dev); |
| 154 | int ret; | 154 | int ret; |
| 155 | struct spi_transfer xfers[] = { | 155 | struct spi_transfer xfers[] = { |
| 156 | { | 156 | { |
| @@ -196,7 +196,7 @@ static int ade7758_spi_read_reg_24(struct device *dev, | |||
| 196 | { | 196 | { |
| 197 | struct spi_message msg; | 197 | struct spi_message msg; |
| 198 | struct iio_dev *indio_dev = dev_get_drvdata(dev); | 198 | struct iio_dev *indio_dev = dev_get_drvdata(dev); |
| 199 | struct ade7758_state *st = iio_dev_get_devdata(indio_dev); | 199 | struct ade7758_state *st = iio_priv(indio_dev); |
| 200 | int ret; | 200 | int ret; |
| 201 | struct spi_transfer xfers[] = { | 201 | struct spi_transfer xfers[] = { |
| 202 | { | 202 | { |
| @@ -485,10 +485,11 @@ static int ade7758_stop_device(struct device *dev) | |||
| 485 | return ret; | 485 | return ret; |
| 486 | } | 486 | } |
| 487 | 487 | ||
| 488 | static int ade7758_initial_setup(struct ade7758_state *st) | 488 | static int ade7758_initial_setup(struct iio_dev *indio_dev) |
| 489 | { | 489 | { |
| 490 | struct ade7758_state *st = iio_priv(indio_dev); | ||
| 491 | struct device *dev = &indio_dev->dev; | ||
| 490 | int ret; | 492 | int ret; |
| 491 | struct device *dev = &st->indio_dev->dev; | ||
| 492 | 493 | ||
| 493 | /* use low spi speed for init */ | 494 | /* use low spi speed for init */ |
| 494 | st->us->mode = SPI_MODE_1; | 495 | st->us->mode = SPI_MODE_1; |
| @@ -727,19 +728,23 @@ static struct iio_chan_spec ade7758_channels[] = { | |||
| 727 | static int __devinit ade7758_probe(struct spi_device *spi) | 728 | static int __devinit ade7758_probe(struct spi_device *spi) |
| 728 | { | 729 | { |
| 729 | int i, ret, regdone = 0; | 730 | int i, ret, regdone = 0; |
| 730 | struct ade7758_state *st = kzalloc(sizeof *st, GFP_KERNEL); | 731 | struct ade7758_state *st; |
| 731 | if (!st) { | 732 | struct iio_dev *indio_dev = iio_allocate_device(sizeof(*st)); |
| 732 | ret = -ENOMEM; | 733 | |
| 734 | if (indio_dev == NULL) { | ||
| 735 | ret = -ENOMEM; | ||
| 733 | goto error_ret; | 736 | goto error_ret; |
| 734 | } | 737 | } |
| 738 | |||
| 739 | st = iio_priv(indio_dev); | ||
| 735 | /* this is only used for removal purposes */ | 740 | /* this is only used for removal purposes */ |
| 736 | spi_set_drvdata(spi, st); | 741 | spi_set_drvdata(spi, indio_dev); |
| 737 | 742 | ||
| 738 | /* Allocate the comms buffers */ | 743 | /* Allocate the comms buffers */ |
| 739 | st->rx = kzalloc(sizeof(*st->rx)*ADE7758_MAX_RX, GFP_KERNEL); | 744 | st->rx = kzalloc(sizeof(*st->rx)*ADE7758_MAX_RX, GFP_KERNEL); |
| 740 | if (st->rx == NULL) { | 745 | if (st->rx == NULL) { |
| 741 | ret = -ENOMEM; | 746 | ret = -ENOMEM; |
| 742 | goto error_free_st; | 747 | goto error_free_dev; |
| 743 | } | 748 | } |
| 744 | st->tx = kzalloc(sizeof(*st->tx)*ADE7758_MAX_TX, GFP_KERNEL); | 749 | st->tx = kzalloc(sizeof(*st->tx)*ADE7758_MAX_TX, GFP_KERNEL); |
| 745 | if (st->tx == NULL) { | 750 | if (st->tx == NULL) { |
| @@ -749,35 +754,28 @@ static int __devinit ade7758_probe(struct spi_device *spi) | |||
| 749 | st->us = spi; | 754 | st->us = spi; |
| 750 | st->ade7758_ring_channels = &ade7758_channels[0]; | 755 | st->ade7758_ring_channels = &ade7758_channels[0]; |
| 751 | mutex_init(&st->buf_lock); | 756 | mutex_init(&st->buf_lock); |
| 752 | /* setup the industrialio driver allocated elements */ | ||
| 753 | st->indio_dev = iio_allocate_device(0); | ||
| 754 | if (st->indio_dev == NULL) { | ||
| 755 | ret = -ENOMEM; | ||
| 756 | |||
