diff options
author | Roman Volkov <v1ron@mail.ru> | 2014-01-24 07:18:03 -0500 |
---|---|---|
committer | Clemens Ladisch <clemens@ladisch.de> | 2014-01-29 14:45:44 -0500 |
commit | 303cff30d36e6a450c3ced1e3bed034038d87a86 (patch) | |
tree | d7dfa1fe1c0a0a1ac98ddc953620ff35c6b92598 | |
parent | 10dd44dc88419ba5278435669ac9e35f9f410c7e (diff) |
ALSA: oxygen: modify the SPI writing function
Modify the oxygen_write_spi() function to use the newly
introduced oxygen_wait_spi() function. Change return value
from void to int, so it can return error codes. Older
drivers just ignore that return value, new drivers can
check this value. We need to wait AFTER
initiating the SPI transaction, otherwise read
operation will not work.
Signed-off-by: Roman Volkov <v1ron@mail.ru>
Signed-off-by: Clemens Ladisch <clemens@ladisch.de>
-rw-r--r-- | sound/pci/oxygen/oxygen.h | 2 | ||||
-rw-r--r-- | sound/pci/oxygen/oxygen_io.c | 17 |
2 files changed, 7 insertions, 12 deletions
diff --git a/sound/pci/oxygen/oxygen.h b/sound/pci/oxygen/oxygen.h index 09a24b24958b..c10ab077afd8 100644 --- a/sound/pci/oxygen/oxygen.h +++ b/sound/pci/oxygen/oxygen.h | |||
@@ -198,7 +198,7 @@ void oxygen_write_ac97(struct oxygen *chip, unsigned int codec, | |||
198 | void oxygen_write_ac97_masked(struct oxygen *chip, unsigned int codec, | 198 | void oxygen_write_ac97_masked(struct oxygen *chip, unsigned int codec, |
199 | unsigned int index, u16 data, u16 mask); | 199 | unsigned int index, u16 data, u16 mask); |
200 | 200 | ||
201 | void oxygen_write_spi(struct oxygen *chip, u8 control, unsigned int data); | 201 | int oxygen_write_spi(struct oxygen *chip, u8 control, unsigned int data); |
202 | void oxygen_write_i2c(struct oxygen *chip, u8 device, u8 map, u8 data); | 202 | void oxygen_write_i2c(struct oxygen *chip, u8 device, u8 map, u8 data); |
203 | 203 | ||
204 | void oxygen_reset_uart(struct oxygen *chip); | 204 | void oxygen_reset_uart(struct oxygen *chip); |
diff --git a/sound/pci/oxygen/oxygen_io.c b/sound/pci/oxygen/oxygen_io.c index 4b88c7a332e4..3274907189fe 100644 --- a/sound/pci/oxygen/oxygen_io.c +++ b/sound/pci/oxygen/oxygen_io.c | |||
@@ -212,23 +212,18 @@ static int oxygen_wait_spi(struct oxygen *chip) | |||
212 | return -EIO; | 212 | return -EIO; |
213 | } | 213 | } |
214 | 214 | ||
215 | void oxygen_write_spi(struct oxygen *chip, u8 control, unsigned int data) | 215 | int oxygen_write_spi(struct oxygen *chip, u8 control, unsigned int data) |
216 | { | 216 | { |
217 | unsigned int count; | 217 | /* |
218 | 218 | * We need to wait AFTER initiating the SPI transaction, | |
219 | /* should not need more than 30.72 us (24 * 1.28 us) */ | 219 | * otherwise read operations will not work. |
220 | count = 10; | 220 | */ |
221 | while ((oxygen_read8(chip, OXYGEN_SPI_CONTROL) & OXYGEN_SPI_BUSY) | ||
222 | && count > 0) { | ||
223 | udelay(4); | ||
224 | --count; | ||
225 | } | ||
226 | |||
227 | oxygen_write8(chip, OXYGEN_SPI_DATA1, data); | 221 | oxygen_write8(chip, OXYGEN_SPI_DATA1, data); |
228 | oxygen_write8(chip, OXYGEN_SPI_DATA2, data >> 8); | 222 | oxygen_write8(chip, OXYGEN_SPI_DATA2, data >> 8); |
229 | if (control & OXYGEN_SPI_DATA_LENGTH_3) | 223 | if (control & OXYGEN_SPI_DATA_LENGTH_3) |
230 | oxygen_write8(chip, OXYGEN_SPI_DATA3, data >> 16); | 224 | oxygen_write8(chip, OXYGEN_SPI_DATA3, data >> 16); |
231 | oxygen_write8(chip, OXYGEN_SPI_CONTROL, control); | 225 | oxygen_write8(chip, OXYGEN_SPI_CONTROL, control); |
226 | return oxygen_wait_spi(chip); | ||
232 | } | 227 | } |
233 | EXPORT_SYMBOL(oxygen_write_spi); | 228 | EXPORT_SYMBOL(oxygen_write_spi); |
234 | 229 | ||