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>

authored by Roman Volkov and committed by Clemens Ladisch 303cff30 10dd44dc

+7 -12
+1 -1
sound/pci/oxygen/oxygen.h
··· 198 void oxygen_write_ac97_masked(struct oxygen *chip, unsigned int codec, 199 unsigned int index, u16 data, u16 mask); 200 201 - void 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); 203 204 void oxygen_reset_uart(struct oxygen *chip);
··· 198 void oxygen_write_ac97_masked(struct oxygen *chip, unsigned int codec, 199 unsigned int index, u16 data, u16 mask); 200 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); 203 204 void oxygen_reset_uart(struct oxygen *chip);
+6 -11
sound/pci/oxygen/oxygen_io.c
··· 212 return -EIO; 213 } 214 215 - void oxygen_write_spi(struct oxygen *chip, u8 control, unsigned int data) 216 { 217 - unsigned int count; 218 - 219 - /* should not need more than 30.72 us (24 * 1.28 us) */ 220 - count = 10; 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); 228 oxygen_write8(chip, OXYGEN_SPI_DATA2, data >> 8); 229 if (control & OXYGEN_SPI_DATA_LENGTH_3) 230 oxygen_write8(chip, OXYGEN_SPI_DATA3, data >> 16); 231 oxygen_write8(chip, OXYGEN_SPI_CONTROL, control); 232 } 233 EXPORT_SYMBOL(oxygen_write_spi); 234
··· 212 return -EIO; 213 } 214 215 + int oxygen_write_spi(struct oxygen *chip, u8 control, unsigned int data) 216 { 217 + /* 218 + * We need to wait AFTER initiating the SPI transaction, 219 + * otherwise read operations will not work. 220 + */ 221 oxygen_write8(chip, OXYGEN_SPI_DATA1, data); 222 oxygen_write8(chip, OXYGEN_SPI_DATA2, data >> 8); 223 if (control & OXYGEN_SPI_DATA_LENGTH_3) 224 oxygen_write8(chip, OXYGEN_SPI_DATA3, data >> 16); 225 oxygen_write8(chip, OXYGEN_SPI_CONTROL, control); 226 + return oxygen_wait_spi(chip); 227 } 228 EXPORT_SYMBOL(oxygen_write_spi); 229