Skip to content

Commit

Permalink
ASoC: Remove byte swap in 4x12 SPI write
Browse files Browse the repository at this point in the history
snd_soc_4_12_spi_write() contains a byte swap. Since this code was written
for an Analog CODEC on a Blackfin reference board it appears that this is
done because while Blackfin is little endian the CODEC is big endian (as
are most CODECs).

Push this up into the generic 4x12 write function and use cpu_to_be16() to
do the byte swap so things are more regular and things work on both CPU
endiannesses.

Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
Acked-by: Liam Girdwood <lrg@ti.com>
  • Loading branch information
Mark Brown committed May 11, 2011
1 parent 051e994 commit 063b7cc
Showing 1 changed file with 5 additions and 6 deletions.
11 changes: 5 additions & 6 deletions sound/soc/soc-cache.c
Original file line number Diff line number Diff line change
Expand Up @@ -101,12 +101,11 @@ static unsigned int snd_soc_4_12_read(struct snd_soc_codec *codec,
static int snd_soc_4_12_write(struct snd_soc_codec *codec, unsigned int reg,
unsigned int value)
{
u8 data[2];
u16 data;

data[0] = (reg << 4) | ((value >> 8) & 0x000f);
data[1] = value & 0x00ff;
data = cpu_to_be16((reg << 12) | (value & 0xffffff));

return do_hw_write(codec, reg, value, data, 2);
return do_hw_write(codec, reg, value, &data, 2);
}

#if defined(CONFIG_SPI_MASTER)
Expand All @@ -115,8 +114,8 @@ static int snd_soc_4_12_spi_write(void *control_data, const char *data,
{
u8 msg[2];

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

return do_spi_write(control_data, msg, len);
}
Expand Down

0 comments on commit 063b7cc

Please sign in to comment.