Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 248211
b: refs/heads/master
c: 30539a1
h: refs/heads/master
i:
  248209: 79bf578
  248207: 16925d3
v: v3
  • Loading branch information
Dimitris Papastamos authored and Mark Brown committed Mar 26, 2011
1 parent 147d6e2 commit 220b7bf
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 97 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: b8cbc195202d05efcda6af81c669577e3cb793e5
refs/heads/master: 30539a18d366cff6b21f66a81e4d9dccc4a90c89
126 changes: 30 additions & 96 deletions trunk/sound/soc/soc-cache.c
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,30 @@

#include <trace/events/asoc.h>

#if defined(CONFIG_SPI_MASTER)
static int do_spi_write(void *control_data, const void *msg,
int len)
{
struct spi_device *spi = control_data;
struct spi_transfer t;
struct spi_message m;

if (len <= 0)
return 0;

spi_message_init(&m);
memset(&t, 0, sizeof t);

t.tx_buf = msg;
t.len = len;

spi_message_add_tail(&t, &m);
spi_sync(spi, &m);

return len;
}
#endif

static int do_hw_write(struct snd_soc_codec *codec, unsigned int reg,
unsigned int value, const void *data, int len)
{
Expand Down Expand Up @@ -89,27 +113,12 @@ static int snd_soc_4_12_write(struct snd_soc_codec *codec, unsigned int reg,
static int snd_soc_4_12_spi_write(void *control_data, const char *data,
int len)
{
struct spi_device *spi = control_data;
struct spi_transfer t;
struct spi_message m;
u8 msg[2];

if (len <= 0)
return 0;

msg[0] = data[1];
msg[1] = data[0];

spi_message_init(&m);
memset(&t, 0, sizeof t);

t.tx_buf = &msg[0];
t.len = len;

spi_message_add_tail(&t, &m);
spi_sync(spi, &m);

return len;
return do_spi_write(control_data, msg, len);
}
#else
#define snd_soc_4_12_spi_write NULL
Expand All @@ -136,27 +145,12 @@ static int snd_soc_7_9_write(struct snd_soc_codec *codec, unsigned int reg,
static int snd_soc_7_9_spi_write(void *control_data, const char *data,
int len)
{
struct spi_device *spi = control_data;
struct spi_transfer t;
struct spi_message m;
u8 msg[2];

if (len <= 0)
return 0;

msg[0] = data[0];
msg[1] = data[1];

spi_message_init(&m);
memset(&t, 0, sizeof t);

t.tx_buf = &msg[0];
t.len = len;

spi_message_add_tail(&t, &m);
spi_sync(spi, &m);

return len;
return do_spi_write(control_data, msg, len);
}
#else
#define snd_soc_7_9_spi_write NULL
Expand Down Expand Up @@ -184,27 +178,12 @@ static unsigned int snd_soc_8_8_read(struct snd_soc_codec *codec,
static int snd_soc_8_8_spi_write(void *control_data, const char *data,
int len)
{
struct spi_device *spi = control_data;
struct spi_transfer t;
struct spi_message m;
u8 msg[2];

if (len <= 0)
return 0;

msg[0] = data[0];
msg[1] = data[1];

spi_message_init(&m);
memset(&t, 0, sizeof t);

t.tx_buf = &msg[0];
t.len = len;

spi_message_add_tail(&t, &m);
spi_sync(spi, &m);

return len;
return do_spi_write(control_data, msg, len);
}
#else
#define snd_soc_8_8_spi_write NULL
Expand Down Expand Up @@ -232,28 +211,13 @@ static unsigned int snd_soc_8_16_read(struct snd_soc_codec *codec,
static int snd_soc_8_16_spi_write(void *control_data, const char *data,
int len)
{
struct spi_device *spi = control_data;
struct spi_transfer t;
struct spi_message m;
u8 msg[3];

if (len <= 0)
return 0;

msg[0] = data[0];
msg[1] = data[1];
msg[2] = data[2];

spi_message_init(&m);
memset(&t, 0, sizeof t);

t.tx_buf = &msg[0];
t.len = len;

spi_message_add_tail(&t, &m);
spi_sync(spi, &m);

return len;
return do_spi_write(control_data, msg, len);
}
#else
#define snd_soc_8_16_spi_write NULL
Expand Down Expand Up @@ -365,28 +329,13 @@ static int snd_soc_16_8_write(struct snd_soc_codec *codec, unsigned int reg,
static int snd_soc_16_8_spi_write(void *control_data, const char *data,
int len)
{
struct spi_device *spi = control_data;
struct spi_transfer t;
struct spi_message m;
u8 msg[3];

if (len <= 0)
return 0;

msg[0] = data[0];
msg[1] = data[1];
msg[2] = data[2];

spi_message_init(&m);
memset(&t, 0, sizeof t);

t.tx_buf = &msg[0];
t.len = len;

spi_message_add_tail(&t, &m);
spi_sync(spi, &m);

return len;
return do_spi_write(control_data, msg, len);
}
#else
#define snd_soc_16_8_spi_write NULL
Expand Down Expand Up @@ -432,29 +381,14 @@ static int snd_soc_16_16_write(struct snd_soc_codec *codec, unsigned int reg,
static int snd_soc_16_16_spi_write(void *control_data, const char *data,
int len)
{
struct spi_device *spi = control_data;
struct spi_transfer t;
struct spi_message m;
u8 msg[4];

if (len <= 0)
return 0;

msg[0] = data[0];
msg[1] = data[1];
msg[2] = data[2];
msg[3] = data[3];

spi_message_init(&m);
memset(&t, 0, sizeof t);

t.tx_buf = &msg[0];
t.len = len;

spi_message_add_tail(&t, &m);
spi_sync(spi, &m);

return len;
return do_spi_write(control_data, msg, len);
}
#else
#define snd_soc_16_16_spi_write NULL
Expand Down

0 comments on commit 220b7bf

Please sign in to comment.