From: Roman Volkov Date: Fri, 24 Jan 2014 12:18:02 +0000 (+0400) Subject: ALSA: oxygen: add the separate SPI waiting function X-Git-Tag: v3.14-rc1~16^2~2^2~18 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=10dd44dc88419ba5278435669ac9e35f9f410c7e;p=profile%2Fivi%2Fkernel-x86-ivi.git ALSA: oxygen: add the separate SPI waiting function 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 Signed-off-by: Clemens Ladisch --- diff --git a/sound/pci/oxygen/oxygen_io.c b/sound/pci/oxygen/oxygen_io.c index 521eae4..4b88c7a 100644 --- a/sound/pci/oxygen/oxygen_io.c +++ b/sound/pci/oxygen/oxygen_io.c @@ -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;