diff options
author | Lars-Peter Clausen <lars@metafoo.de> | 2013-01-31 09:27:00 -0500 |
---|---|---|
committer | Jonathan Cameron <jic23@kernel.org> | 2013-02-02 04:17:26 -0500 |
commit | 6a6df2d9113856a4371ca4f1cb29221790320307 (patch) | |
tree | 1137e5d81c2618740a97a750d4f3d5b29e44322d | |
parent | 999517f6742b4ca4692c041752afc4298fbbf0da (diff) |
Partially revert "staging:iio:gyro:adxrs450 make more use of spi_read and spi_write."
This partially reverts commit cb4496876f03631eff913b3c608c964d48d61eb9. There is
no apparent reason why we should split a transaction which consists out of
multiple transfers into multiple transactions each having one transfer. While
this works it introduces a bunch of unnecessary context switch and additional
setup costs.
Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
Signed-off-by: Jonathan Cameron <jic23@kernel.org>
-rw-r--r-- | drivers/staging/iio/gyro/adxrs450_core.c | 48 |
1 files changed, 34 insertions, 14 deletions
diff --git a/drivers/staging/iio/gyro/adxrs450_core.c b/drivers/staging/iio/gyro/adxrs450_core.c index f0ce81da8aca..318e8c9c6544 100644 --- a/drivers/staging/iio/gyro/adxrs450_core.c +++ b/drivers/staging/iio/gyro/adxrs450_core.c | |||
@@ -34,8 +34,21 @@ static int adxrs450_spi_read_reg_16(struct iio_dev *indio_dev, | |||
34 | u8 reg_address, | 34 | u8 reg_address, |
35 | u16 *val) | 35 | u16 *val) |
36 | { | 36 | { |
37 | struct spi_message msg; | ||
37 | struct adxrs450_state *st = iio_priv(indio_dev); | 38 | struct adxrs450_state *st = iio_priv(indio_dev); |
38 | int ret; | 39 | int ret; |
40 | struct spi_transfer xfers[] = { | ||
41 | { | ||
42 | .tx_buf = st->tx, | ||
43 | .bits_per_word = 8, | ||
44 | .len = 4, | ||
45 | .cs_change = 1, | ||
46 | }, { | ||
47 | .rx_buf = st->rx, | ||
48 | .bits_per_word = 8, | ||
49 | .len = 4, | ||
50 | }, | ||
51 | }; | ||
39 | 52 | ||
40 | mutex_lock(&st->buf_lock); | 53 | mutex_lock(&st->buf_lock); |
41 | st->tx[0] = ADXRS450_READ_DATA | (reg_address >> 7); | 54 | st->tx[0] = ADXRS450_READ_DATA | (reg_address >> 7); |
@@ -46,13 +59,10 @@ static int adxrs450_spi_read_reg_16(struct iio_dev *indio_dev, | |||
46 | if (!(hweight32(be32_to_cpu(*(u32 *)st->tx)) & 1)) | 59 | if (!(hweight32(be32_to_cpu(*(u32 *)st->tx)) & 1)) |
47 | st->tx[3] |= ADXRS450_P; | 60 | st->tx[3] |= ADXRS450_P; |
48 | 61 | ||
49 | ret = spi_write(st->us, st->tx, 4); | 62 | spi_message_init(&msg); |
50 | if (ret) { | 63 | spi_message_add_tail(&xfers[0], &msg); |
51 | dev_err(&st->us->dev, "problem while reading 16 bit register 0x%02x\n", | 64 | spi_message_add_tail(&xfers[1], &msg); |
52 | reg_address); | 65 | ret = spi_sync(st->us, &msg); |
53 | goto error_ret; | ||
54 | } | ||
55 | ret = spi_read(st->us, st->rx, 4); | ||
56 | if (ret) { | 66 | if (ret) { |
57 | dev_err(&st->us->dev, "problem while reading 16 bit register 0x%02x\n", | 67 | dev_err(&st->us->dev, "problem while reading 16 bit register 0x%02x\n", |
58 | reg_address); | 68 | reg_address); |
@@ -105,8 +115,21 @@ static int adxrs450_spi_write_reg_16(struct iio_dev *indio_dev, | |||
105 | **/ | 115 | **/ |
106 | static int adxrs450_spi_sensor_data(struct iio_dev *indio_dev, s16 *val) | 116 | static int adxrs450_spi_sensor_data(struct iio_dev *indio_dev, s16 *val) |
107 | { | 117 | { |
118 | struct spi_message msg; | ||
108 | struct adxrs450_state *st = iio_priv(indio_dev); | 119 | struct adxrs450_state *st = iio_priv(indio_dev); |
109 | int ret; | 120 | int ret; |
121 | struct spi_transfer xfers[] = { | ||
122 | { | ||
123 | .tx_buf = st->tx, | ||
124 | .bits_per_word = 8, | ||
125 | .len = 4, | ||
126 | .cs_change = 1, | ||
127 | }, { | ||
128 | .rx_buf = st->rx, | ||
129 | .bits_per_word = 8, | ||
130 | .len = 4, | ||
131 | }, | ||
132 | }; | ||
110 | 133 | ||
111 | mutex_lock(&st->buf_lock); | 134 | mutex_lock(&st->buf_lock); |
112 | st->tx[0] = ADXRS450_SENSOR_DATA; | 135 | st->tx[0] = ADXRS450_SENSOR_DATA; |
@@ -114,13 +137,10 @@ static int adxrs450_spi_sensor_data(struct iio_dev *indio_dev, s16 *val) | |||
114 | st->tx[2] = 0; | 137 | st->tx[2] = 0; |
115 | st->tx[3] = 0; | 138 | st->tx[3] = 0; |
116 | 139 | ||
117 | ret = spi_write(st->us, st->tx, 4); | 140 | spi_message_init(&msg); |
118 | if (ret) { | 141 | spi_message_add_tail(&xfers[0], &msg); |
119 | dev_err(&st->us->dev, "Problem while reading sensor data\n"); | 142 | spi_message_add_tail(&xfers[1], &msg); |
120 | goto error_ret; | 143 | ret = spi_sync(st->us, &msg); |
121 | } | ||
122 | |||
123 | ret = spi_read(st->us, st->rx, 4); | ||
124 | if (ret) { | 144 | if (ret) { |
125 | dev_err(&st->us->dev, "Problem while reading sensor data\n"); | 145 | dev_err(&st->us->dev, "Problem while reading sensor data\n"); |
126 | goto error_ret; | 146 | goto error_ret; |