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 198 void oxygen_write_ac97_masked(struct oxygen *chip, unsigned int codec, 199 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 202 void oxygen_write_i2c(struct oxygen *chip, u8 device, u8 map, u8 data); 203 203 204 204 void oxygen_reset_uart(struct oxygen *chip);
+6 -11
sound/pci/oxygen/oxygen_io.c
··· 212 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; 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 - 217 + /* 218 + * We need to wait AFTER initiating the SPI transaction, 219 + * otherwise read operations will not work. 220 + */ 227 221 oxygen_write8(chip, OXYGEN_SPI_DATA1, data); 228 222 oxygen_write8(chip, OXYGEN_SPI_DATA2, data >> 8); 229 223 if (control & OXYGEN_SPI_DATA_LENGTH_3) 230 224 oxygen_write8(chip, OXYGEN_SPI_DATA3, data >> 16); 231 225 oxygen_write8(chip, OXYGEN_SPI_CONTROL, control); 226 + return oxygen_wait_spi(chip); 232 227 } 233 228 EXPORT_SYMBOL(oxygen_write_spi); 234 229