diff options
author | Lars-Peter Clausen <lars@metafoo.de> | 2013-01-09 12:31:00 -0500 |
---|---|---|
committer | Jonathan Cameron <jic23@kernel.org> | 2013-02-09 06:08:42 -0500 |
commit | 14543a00fc3ce6dac9f297535c502a0085a50467 (patch) | |
tree | 1c244bcc56bd4a48ee2c305856457d102d6eccbe /drivers/iio/dac | |
parent | 6d9eecd418afb2c12e5db5be3d72f0f1df43bdd9 (diff) |
iio: Use spi_sync_transfer()
Use the new spi_sync_transfer() helper function instead of open-coding it.
Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
Signed-off-by: Jonathan Cameron <jic23@kernel.org>
Diffstat (limited to 'drivers/iio/dac')
-rw-r--r-- | drivers/iio/dac/ad5360.c | 7 | ||||
-rw-r--r-- | drivers/iio/dac/ad5421.c | 7 | ||||
-rw-r--r-- | drivers/iio/dac/ad5504.c | 6 | ||||
-rw-r--r-- | drivers/iio/dac/ad5686.c | 7 | ||||
-rw-r--r-- | drivers/iio/dac/ad5755.c | 7 | ||||
-rw-r--r-- | drivers/iio/dac/ad5764.c | 7 | ||||
-rw-r--r-- | drivers/iio/dac/ad5791.c | 6 |
7 files changed, 7 insertions, 40 deletions
diff --git a/drivers/iio/dac/ad5360.c b/drivers/iio/dac/ad5360.c index 54b46fd3aede..92771217f665 100644 --- a/drivers/iio/dac/ad5360.c +++ b/drivers/iio/dac/ad5360.c | |||
@@ -213,7 +213,6 @@ static int ad5360_read(struct iio_dev *indio_dev, unsigned int type, | |||
213 | unsigned int addr) | 213 | unsigned int addr) |
214 | { | 214 | { |
215 | struct ad5360_state *st = iio_priv(indio_dev); | 215 | struct ad5360_state *st = iio_priv(indio_dev); |
216 | struct spi_message m; | ||
217 | int ret; | 216 | int ret; |
218 | struct spi_transfer t[] = { | 217 | struct spi_transfer t[] = { |
219 | { | 218 | { |
@@ -226,10 +225,6 @@ static int ad5360_read(struct iio_dev *indio_dev, unsigned int type, | |||
226 | }, | 225 | }, |
227 | }; | 226 | }; |
228 | 227 | ||
229 | spi_message_init(&m); | ||
230 | spi_message_add_tail(&t[0], &m); | ||
231 | spi_message_add_tail(&t[1], &m); | ||
232 | |||
233 | mutex_lock(&indio_dev->mlock); | 228 | mutex_lock(&indio_dev->mlock); |
234 | 229 | ||
235 | st->data[0].d32 = cpu_to_be32(AD5360_CMD(AD5360_CMD_SPECIAL_FUNCTION) | | 230 | st->data[0].d32 = cpu_to_be32(AD5360_CMD(AD5360_CMD_SPECIAL_FUNCTION) | |
@@ -237,7 +232,7 @@ static int ad5360_read(struct iio_dev *indio_dev, unsigned int type, | |||
237 | AD5360_READBACK_TYPE(type) | | 232 | AD5360_READBACK_TYPE(type) | |
238 | AD5360_READBACK_ADDR(addr)); | 233 | AD5360_READBACK_ADDR(addr)); |
239 | 234 | ||
240 | ret = spi_sync(st->spi, &m); | 235 | ret = spi_sync_transfer(st->spi, t, ARRAY_SIZE(t)); |
241 | if (ret >= 0) | 236 | if (ret >= 0) |
242 | ret = be32_to_cpu(st->data[1].d32) & 0xffff; | 237 | ret = be32_to_cpu(st->data[1].d32) & 0xffff; |
243 | 238 | ||
diff --git a/drivers/iio/dac/ad5421.c b/drivers/iio/dac/ad5421.c index 43be948db83e..6b86a638dad0 100644 --- a/drivers/iio/dac/ad5421.c +++ b/drivers/iio/dac/ad5421.c | |||
@@ -127,7 +127,6 @@ static int ad5421_write(struct iio_dev *indio_dev, unsigned int reg, | |||
127 | static int ad5421_read(struct iio_dev *indio_dev, unsigned int reg) | 127 | static int ad5421_read(struct iio_dev *indio_dev, unsigned int reg) |
128 | { | 128 | { |
129 | struct ad5421_state *st = iio_priv(indio_dev); | 129 | struct ad5421_state *st = iio_priv(indio_dev); |
130 | struct spi_message m; | ||
131 | int ret; | 130 | int ret; |
132 | struct spi_transfer t[] = { | 131 | struct spi_transfer t[] = { |
133 | { | 132 | { |
@@ -140,15 +139,11 @@ static int ad5421_read(struct iio_dev *indio_dev, unsigned int reg) | |||
140 | }, | 139 | }, |
141 | }; | 140 | }; |
142 | 141 | ||
143 | spi_message_init(&m); | ||
144 | spi_message_add_tail(&t[0], &m); | ||
145 | spi_message_add_tail(&t[1], &m); | ||
146 | |||
147 | mutex_lock(&indio_dev->mlock); | 142 | mutex_lock(&indio_dev->mlock); |
148 | 143 | ||
149 | st->data[0].d32 = cpu_to_be32((1 << 23) | (reg << 16)); | 144 | st->data[0].d32 = cpu_to_be32((1 << 23) | (reg << 16)); |
150 | 145 | ||
151 | ret = spi_sync(st->spi, &m); | 146 | ret = spi_sync_transfer(st->spi, t, ARRAY_SIZE(t)); |
152 | if (ret >= 0) | 147 | if (ret >= 0) |
153 | ret = be32_to_cpu(st->data[1].d32) & 0xffff; | 148 | ret = be32_to_cpu(st->data[1].d32) & 0xffff; |
154 | 149 | ||
diff --git a/drivers/iio/dac/ad5504.c b/drivers/iio/dac/ad5504.c index 0661829f2773..e5e59749f109 100644 --- a/drivers/iio/dac/ad5504.c +++ b/drivers/iio/dac/ad5504.c | |||
@@ -85,11 +85,7 @@ static int ad5504_spi_read(struct spi_device *spi, u8 addr) | |||
85 | .rx_buf = &val, | 85 | .rx_buf = &val, |
86 | .len = 2, | 86 | .len = 2, |
87 | }; | 87 | }; |
88 | struct spi_message m; | 88 | ret = spi_sync_transfer(spi, &t, 1); |
89 | |||
90 | spi_message_init(&m); | ||
91 | spi_message_add_tail(&t, &m); | ||
92 | ret = spi_sync(spi, &m); | ||
93 | 89 | ||
94 | if (ret < 0) | 90 | if (ret < 0) |
95 | return ret; | 91 | return ret; |
diff --git a/drivers/iio/dac/ad5686.c b/drivers/iio/dac/ad5686.c index ca9609d7a15c..5e554af21703 100644 --- a/drivers/iio/dac/ad5686.c +++ b/drivers/iio/dac/ad5686.c | |||
@@ -117,18 +117,13 @@ static int ad5686_spi_read(struct ad5686_state *st, u8 addr) | |||
117 | .len = 3, | 117 | .len = 3, |
118 | }, | 118 | }, |
119 | }; | 119 | }; |
120 | struct spi_message m; | ||
121 | int ret; | 120 | int ret; |
122 | 121 | ||
123 | spi_message_init(&m); | ||
124 | spi_message_add_tail(&t[0], &m); | ||
125 | spi_message_add_tail(&t[1], &m); | ||
126 | |||
127 | st->data[0].d32 = cpu_to_be32(AD5686_CMD(AD5686_CMD_READBACK_ENABLE) | | 122 | st->data[0].d32 = cpu_to_be32(AD5686_CMD(AD5686_CMD_READBACK_ENABLE) | |
128 | AD5686_ADDR(addr)); | 123 | AD5686_ADDR(addr)); |
129 | st->data[1].d32 = cpu_to_be32(AD5686_CMD(AD5686_CMD_NOOP)); | 124 | st->data[1].d32 = cpu_to_be32(AD5686_CMD(AD5686_CMD_NOOP)); |
130 | 125 | ||
131 | ret = spi_sync(st->spi, &m); | 126 | ret = spi_sync_transfer(st->spi, t, ARRAY_SIZE(t)); |
132 | if (ret < 0) | 127 | if (ret < 0) |
133 | return ret; | 128 | return ret; |
134 | 129 | ||
diff --git a/drivers/iio/dac/ad5755.c b/drivers/iio/dac/ad5755.c index 0869bbd27d30..71faabc6b14e 100644 --- a/drivers/iio/dac/ad5755.c +++ b/drivers/iio/dac/ad5755.c | |||
@@ -153,7 +153,6 @@ static int ad5755_write_ctrl(struct iio_dev *indio_dev, unsigned int channel, | |||
153 | static int ad5755_read(struct iio_dev *indio_dev, unsigned int addr) | 153 | static int ad5755_read(struct iio_dev *indio_dev, unsigned int addr) |
154 | { | 154 | { |
155 | struct ad5755_state *st = iio_priv(indio_dev); | 155 | struct ad5755_state *st = iio_priv(indio_dev); |
156 | struct spi_message m; | ||
157 | int ret; | 156 | int ret; |
158 | struct spi_transfer t[] = { | 157 | struct spi_transfer t[] = { |
159 | { | 158 | { |
@@ -167,16 +166,12 @@ static int ad5755_read(struct iio_dev *indio_dev, unsigned int addr) | |||
167 | }, | 166 | }, |
168 | }; | 167 | }; |
169 | 168 | ||
170 | spi_message_init(&m); | ||
171 | spi_message_add_tail(&t[0], &m); | ||
172 | spi_message_add_tail(&t[1], &m); | ||
173 | |||
174 | mutex_lock(&indio_dev->mlock); | 169 | mutex_lock(&indio_dev->mlock); |
175 | 170 | ||
176 | st->data[0].d32 = cpu_to_be32(AD5755_READ_FLAG | (addr << 16)); | 171 | st->data[0].d32 = cpu_to_be32(AD5755_READ_FLAG | (addr << 16)); |
177 | st->data[1].d32 = cpu_to_be32(AD5755_NOOP); | 172 | st->data[1].d32 = cpu_to_be32(AD5755_NOOP); |
178 | 173 | ||
179 | ret = spi_sync(st->spi, &m); | 174 | ret = spi_sync_transfer(st->spi, t, ARRAY_SIZE(t)); |
180 | if (ret >= 0) | 175 | if (ret >= 0) |
181 | ret = be32_to_cpu(st->data[1].d32) & 0xffff; | 176 | ret = be32_to_cpu(st->data[1].d32) & 0xffff; |
182 | 177 | ||
diff --git a/drivers/iio/dac/ad5764.c b/drivers/iio/dac/ad5764.c index 7f9045e6daa4..5b7acd3a2c77 100644 --- a/drivers/iio/dac/ad5764.c +++ b/drivers/iio/dac/ad5764.c | |||
@@ -135,7 +135,6 @@ static int ad5764_read(struct iio_dev *indio_dev, unsigned int reg, | |||
135 | unsigned int *val) | 135 | unsigned int *val) |
136 | { | 136 | { |
137 | struct ad5764_state *st = iio_priv(indio_dev); | 137 | struct ad5764_state *st = iio_priv(indio_dev); |
138 | struct spi_message m; | ||
139 | int ret; | 138 | int ret; |
140 | struct spi_transfer t[] = { | 139 | struct spi_transfer t[] = { |
141 | { | 140 | { |
@@ -148,15 +147,11 @@ static int ad5764_read(struct iio_dev *indio_dev, unsigned int reg, | |||
148 | }, | 147 | }, |
149 | }; | 148 | }; |
150 | 149 | ||
151 | spi_message_init(&m); | ||
152 | spi_message_add_tail(&t[0], &m); | ||
153 | spi_message_add_tail(&t[1], &m); | ||
154 | |||
155 | mutex_lock(&indio_dev->mlock); | 150 | mutex_lock(&indio_dev->mlock); |
156 | 151 | ||
157 | st->data[0].d32 = cpu_to_be32((1 << 23) | (reg << 16)); | 152 | st->data[0].d32 = cpu_to_be32((1 << 23) | (reg << 16)); |
158 | 153 | ||
159 | ret = spi_sync(st->spi, &m); | 154 | ret = spi_sync_transfer(st->spi, t, ARRAY_SIZE(t)); |
160 | if (ret >= 0) | 155 | if (ret >= 0) |
161 | *val = be32_to_cpu(st->data[1].d32) & 0xffff; | 156 | *val = be32_to_cpu(st->data[1].d32) & 0xffff; |
162 | 157 | ||
diff --git a/drivers/iio/dac/ad5791.c b/drivers/iio/dac/ad5791.c index 6407b5407ddd..8dfd3da8a07b 100644 --- a/drivers/iio/dac/ad5791.c +++ b/drivers/iio/dac/ad5791.c | |||
@@ -125,7 +125,6 @@ static int ad5791_spi_read(struct spi_device *spi, u8 addr, u32 *val) | |||
125 | u8 d8[4]; | 125 | u8 d8[4]; |
126 | } data[3]; | 126 | } data[3]; |
127 | int ret; | 127 | int ret; |
128 | struct spi_message msg; | ||
129 | struct spi_transfer xfers[] = { | 128 | struct spi_transfer xfers[] = { |
130 | { | 129 | { |
131 | .tx_buf = &data[0].d8[1], | 130 | .tx_buf = &data[0].d8[1], |
@@ -144,10 +143,7 @@ static int ad5791_spi_read(struct spi_device *spi, u8 addr, u32 *val) | |||
144 | AD5791_ADDR(addr)); | 143 | AD5791_ADDR(addr)); |
145 | data[1].d32 = cpu_to_be32(AD5791_ADDR(AD5791_ADDR_NOOP)); | 144 | data[1].d32 = cpu_to_be32(AD5791_ADDR(AD5791_ADDR_NOOP)); |
146 | 145 | ||
147 | spi_message_init(&msg); | 146 | ret = spi_sync_transfer(spi, xfers, ARRAY_SIZE(xfers)); |
148 | spi_message_add_tail(&xfers[0], &msg); | ||
149 | spi_message_add_tail(&xfers[1], &msg); | ||
150 | ret = spi_sync(spi, &msg); | ||
151 | 147 | ||
152 | *val = be32_to_cpu(data[2].d32); | 148 | *val = be32_to_cpu(data[2].d32); |
153 | 149 | ||