[alsa-devel] [PATCH v3 01/16] ALSA: Oxygen: Add the separate SPI waiting function

Clemens Ladisch clemens at ladisch.de
Sat Jan 18 11:26:49 CET 2014


Roman Volkov wrote:
> This function performs waiting when the SPI bus completes
> a transaction. Timeout error checking introduced and
> the timeout increased to 400 from 40.

Why 400?  SPI does not allow the codec to delay reads.

> +	for (count = 100; count > 0; count--) {
> +		if ((oxygen_read8(chip, OXYGEN_SPI_CONTROL) &
> +						OXYGEN_SPI_BUSY) == 0)
> +			return 0;
> +		udelay(4);
> +		--count;
> +	}

This loop waits for 200 µs.

The SPI transaction will not be finished for the first 30 µs or so, so
polling is not needed for that time.

With the wait coming after the transaction, it makes more sense to have
the busy check not before but after the udelay.


Regards,
Clemens


More information about the Alsa-devel mailing list