Skip to content

Commit

Permalink
ALSA: oxygen: modify the SPI writing function
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
Roman Volkov authored and Clemens Ladisch committed Jan 29, 2014
1 parent 10dd44d commit 303cff3
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 12 deletions.
2 changes: 1 addition & 1 deletion sound/pci/oxygen/oxygen.h
Original file line number Diff line number Diff line change
Expand Up @@ -198,7 +198,7 @@ void oxygen_write_ac97(struct oxygen *chip, unsigned int codec,
void oxygen_write_ac97_masked(struct oxygen *chip, unsigned int codec,
unsigned int index, u16 data, u16 mask);

void oxygen_write_spi(struct oxygen *chip, u8 control, unsigned int data);
int oxygen_write_spi(struct oxygen *chip, u8 control, unsigned int data);
void oxygen_write_i2c(struct oxygen *chip, u8 device, u8 map, u8 data);

void oxygen_reset_uart(struct oxygen *chip);
Expand Down
17 changes: 6 additions & 11 deletions sound/pci/oxygen/oxygen_io.c
Original file line number Diff line number Diff line change
Expand Up @@ -212,23 +212,18 @@ static int oxygen_wait_spi(struct oxygen *chip)
return -EIO;
}

void oxygen_write_spi(struct oxygen *chip, u8 control, unsigned int data)
int oxygen_write_spi(struct oxygen *chip, u8 control, unsigned int data)
{
unsigned int count;

/* should not need more than 30.72 us (24 * 1.28 us) */
count = 10;
while ((oxygen_read8(chip, OXYGEN_SPI_CONTROL) & OXYGEN_SPI_BUSY)
&& count > 0) {
udelay(4);
--count;
}

/*
* We need to wait AFTER initiating the SPI transaction,
* otherwise read operations will not work.
*/
oxygen_write8(chip, OXYGEN_SPI_DATA1, data);
oxygen_write8(chip, OXYGEN_SPI_DATA2, data >> 8);
if (control & OXYGEN_SPI_DATA_LENGTH_3)
oxygen_write8(chip, OXYGEN_SPI_DATA3, data >> 16);
oxygen_write8(chip, OXYGEN_SPI_CONTROL, control);
return oxygen_wait_spi(chip);
}
EXPORT_SYMBOL(oxygen_write_spi);

Expand Down

0 comments on commit 303cff3

Please sign in to comment.