aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMark Brown <broonie@opensource.wolfsonmicro.com>2011-05-10 17:33:48 -0400
committerMark Brown <broonie@opensource.wolfsonmicro.com>2011-05-11 09:56:03 -0400
commit6e28f976ec73aec688bf89a63ac719ba765e9360 (patch)
tree577b6bc78be727a4c6843cbe7e1e9778028e782a
parent063b7cc43fb2413238095b81f9b4a2ee2c52056b (diff)
ASoC: Use spi_write() for SPI writes
do_spi_write() is just an open coded copy of do_spi_write() so we can delete it and just call spi_write() directly. Indeed, as a result of recent refactoring all the SPI write functions are just very long wrappers around spi_write() which don't add anything except for some pointless copies so we can just use spi_write() as the hw_write operation directly. It should be as type safe to do this as it is to do the same thing with I2C and it saves us a bunch of code. Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com> Acked-by: Liam Girdwood <lrg@ti.com>
-rw-r--r--sound/soc/soc-cache.c132
1 files changed, 4 insertions, 128 deletions
diff --git a/sound/soc/soc-cache.c b/sound/soc/soc-cache.c
index 73907e5f078f..01e5b9846436 100644
--- a/sound/soc/soc-cache.c
+++ b/sound/soc/soc-cache.c
@@ -20,30 +20,6 @@
20 20
21#include <trace/events/asoc.h> 21#include <trace/events/asoc.h>
22 22
23#if defined(CONFIG_SPI_MASTER)
24static int do_spi_write(void *control_data, const void *msg,
25 int len)
26{
27 struct spi_device *spi = control_data;
28 struct spi_transfer t;
29 struct spi_message m;
30
31 if (len <= 0)
32 return 0;
33
34 spi_message_init(&m);
35 memset(&t, 0, sizeof t);
36
37 t.tx_buf = msg;
38 t.len = len;
39
40 spi_message_add_tail(&t, &m);
41 spi_sync(spi, &m);
42
43 return len;
44}
45#endif
46
47static int do_hw_write(struct snd_soc_codec *codec, unsigned int reg, 23static int do_hw_write(struct snd_soc_codec *codec, unsigned int reg,
48 unsigned int value, const void *data, int len) 24 unsigned int value, const void *data, int len)
49{ 25{
@@ -108,21 +84,6 @@ static int snd_soc_4_12_write(struct snd_soc_codec *codec, unsigned int reg,
108 return do_hw_write(codec, reg, value, &data, 2); 84 return do_hw_write(codec, reg, value, &data, 2);
109} 85}
110 86
111#if defined(CONFIG_SPI_MASTER)
112static int snd_soc_4_12_spi_write(void *control_data, const char *data,
113 int len)
114{
115 u8 msg[2];
116
117 msg[0] = data[0];
118 msg[1] = data[1];
119
120 return do_spi_write(control_data, msg, len);
121}
122#else
123#define snd_soc_4_12_spi_write NULL
124#endif
125
126static unsigned int snd_soc_7_9_read(struct snd_soc_codec *codec, 87static unsigned int snd_soc_7_9_read(struct snd_soc_codec *codec,
127 unsigned int reg) 88 unsigned int reg)
128{ 89{
@@ -140,21 +101,6 @@ static int snd_soc_7_9_write(struct snd_soc_codec *codec, unsigned int reg,
140 return do_hw_write(codec, reg, value, data, 2); 101 return do_hw_write(codec, reg, value, data, 2);
141} 102}
142 103
143#if defined(CONFIG_SPI_MASTER)
144static int snd_soc_7_9_spi_write(void *control_data, const char *data,
145 int len)
146{
147 u8 msg[2];
148
149 msg[0] = data[0];
150 msg[1] = data[1];
151
152 return do_spi_write(control_data, msg, len);
153}
154#else
155#define snd_soc_7_9_spi_write NULL
156#endif
157
158static int snd_soc_8_8_write(struct snd_soc_codec *codec, unsigned int reg, 104static int snd_soc_8_8_write(struct snd_soc_codec *codec, unsigned int reg,
159 unsigned int value) 105 unsigned int value)
160{ 106{
@@ -173,21 +119,6 @@ static unsigned int snd_soc_8_8_read(struct snd_soc_codec *codec,
173 return do_hw_read(codec, reg); 119 return do_hw_read(codec, reg);
174} 120}
175 121
176#if defined(CONFIG_SPI_MASTER)
177static int snd_soc_8_8_spi_write(void *control_data, const char *data,
178 int len)
179{
180 u8 msg[2];
181
182 msg[0] = data[0];
183 msg[1] = data[1];
184
185 return do_spi_write(control_data, msg, len);
186}
187#else
188#define snd_soc_8_8_spi_write NULL
189#endif
190
191static int snd_soc_8_16_write(struct snd_soc_codec *codec, unsigned int reg, 122static int snd_soc_8_16_write(struct snd_soc_codec *codec, unsigned int reg,
192 unsigned int value) 123 unsigned int value)
193{ 124{
@@ -206,22 +137,6 @@ static unsigned int snd_soc_8_16_read(struct snd_soc_codec *codec,
206 return do_hw_read(codec, reg); 137 return do_hw_read(codec, reg);
207} 138}
208 139
209#if defined(CONFIG_SPI_MASTER)
210static int snd_soc_8_16_spi_write(void *control_data, const char *data,
211 int len)
212{
213 u8 msg[3];
214
215 msg[0] = data[0];
216 msg[1] = data[1];
217 msg[2] = data[2];
218
219 return do_spi_write(control_data, msg, len);
220}
221#else
222#define snd_soc_8_16_spi_write NULL
223#endif
224
225#if defined(CONFIG_I2C) || (defined(CONFIG_I2C_MODULE) && defined(MODULE)) 140#if defined(CONFIG_I2C) || (defined(CONFIG_I2C_MODULE) && defined(MODULE))
226static unsigned int do_i2c_read(struct snd_soc_codec *codec, 141static unsigned int do_i2c_read(struct snd_soc_codec *codec,
227 void *reg, int reglen, 142 void *reg, int reglen,
@@ -322,22 +237,6 @@ static int snd_soc_16_8_write(struct snd_soc_codec *codec, unsigned int reg,
322 return do_hw_write(codec, reg, value, data, 3); 237 return do_hw_write(codec, reg, value, data, 3);
323} 238}
324 239
325#if defined(CONFIG_SPI_MASTER)
326static int snd_soc_16_8_spi_write(void *control_data, const char *data,
327 int len)
328{
329 u8 msg[3];
330
331 msg[0] = data[0];
332 msg[1] = data[1];
333 msg[2] = data[2];
334
335 return do_spi_write(control_data, msg, len);
336}
337#else
338#define snd_soc_16_8_spi_write NULL
339#endif
340
341#if defined(CONFIG_I2C) || (defined(CONFIG_I2C_MODULE) && defined(MODULE)) 240#if defined(CONFIG_I2C) || (defined(CONFIG_I2C_MODULE) && defined(MODULE))
342static unsigned int snd_soc_16_16_read_i2c(struct snd_soc_codec *codec, 241static unsigned int snd_soc_16_16_read_i2c(struct snd_soc_codec *codec,
343 unsigned int r) 242 unsigned int r)
@@ -374,23 +273,6 @@ static int snd_soc_16_16_write(struct snd_soc_codec *codec, unsigned int reg,
374 return do_hw_write(codec, reg, value, data, 4); 273 return do_hw_write(codec, reg, value, data, 4);
375} 274}
376 275
377#if defined(CONFIG_SPI_MASTER)
378static int snd_soc_16_16_spi_write(void *control_data, const char *data,
379 int len)
380{
381 u8 msg[4];
382
383 msg[0] = data[0];
384 msg[1] = data[1];
385 msg[2] = data[2];
386 msg[3] = data[3];
387
388 return do_spi_write(control_data, msg, len);
389}
390#else
391#define snd_soc_16_16_spi_write NULL
392#endif
393
394/* Primitive bulk write support for soc-cache. The data pointed to by 276/* Primitive bulk write support for soc-cache. The data pointed to by
395 * `data' needs to already be in the form the hardware expects 277 * `data' needs to already be in the form the hardware expects
396 * including any leading register specific data. Any data written 278 * including any leading register specific data. Any data written
@@ -420,7 +302,7 @@ static int snd_soc_hw_bulk_write_raw(struct snd_soc_codec *codec, unsigned int r
420#endif 302#endif
421#if defined(CONFIG_SPI_MASTER) 303#if defined(CONFIG_SPI_MASTER)
422 case SND_SOC_SPI: 304 case SND_SOC_SPI:
423 ret = do_spi_write(codec->control_data, data, len); 305 ret = spi_write(codec->control_data, data, len);
424 break; 306 break;
425#endif 307#endif
426 default: 308 default:
@@ -439,43 +321,36 @@ static struct {
439 int addr_bits; 321 int addr_bits;
440 int data_bits; 322 int data_bits;
441 int (*write)(struct snd_soc_codec *codec, unsigned int, unsigned int); 323 int (*write)(struct snd_soc_codec *codec, unsigned int, unsigned int);
442 int (*spi_write)(void *, const char *, int);