If there is an exported system GPIO_X (/sys/class/gpio/gpioX) and new SPI device is registered with chip select as GPIO_X then the registration fails, but the GPIO_X is unexported from system class. Trying to reregister SPI device for second time succeeds.
So far this seems to work:
static void ath79_spi_cleanup(struct spi_device *spi)
{
if (spi->controller_state)
ath79_spi_cleanup_cs(spi);
spi_bitbang_cleanup(spi);
}
If there is an exported system GPIO_X (/sys/class/gpio/gpioX) and new SPI device is registered with chip select as GPIO_X then the registration fails, but the GPIO_X is unexported from system class. Trying to reregister SPI device for second time succeeds.
So far this seems to work: static void ath79_spi_cleanup(struct spi_device *spi) { if (spi->controller_state) ath79_spi_cleanup_cs(spi); spi_bitbang_cleanup(spi); }
TODO: test the fix and create a patch