Skip to content

Commit

Permalink
ALSA: oxygen: add the separate SPI waiting function
Browse files Browse the repository at this point in the history
The oxygen_wait_spi() function now performs waiting when the
SPI bus completes a transaction. Introduce the timeout error
checking and increase timeout to 200 from 40.

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 d8ec26d commit 10dd44d
Showing 1 changed file with 18 additions and 0 deletions.
18 changes: 18 additions & 0 deletions sound/pci/oxygen/oxygen_io.c
Original file line number Diff line number Diff line change
Expand Up @@ -194,6 +194,24 @@ void oxygen_write_ac97_masked(struct oxygen *chip, unsigned int codec,
}
EXPORT_SYMBOL(oxygen_write_ac97_masked);

static int oxygen_wait_spi(struct oxygen *chip)
{
unsigned int count;

/*
* Higher timeout to be sure: 200 us;
* actual transaction should not need more than 40 us.
*/
for (count = 50; count > 0; count--) {
udelay(4);
if ((oxygen_read8(chip, OXYGEN_SPI_CONTROL) &
OXYGEN_SPI_BUSY) == 0)
return 0;
}
snd_printk(KERN_ERR "oxygen: SPI wait timeout\n");
return -EIO;
}

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

0 comments on commit 10dd44d

Please sign in to comment.