• Lukas Wunner's avatar
    spi: Cleanup on failure of initial setup · 2ec6f20b
    Lukas Wunner authored
    Commit c7299fea ("spi: Fix spi device unregister flow") changed the
    SPI core's behavior if the ->setup() hook returns an error upon adding
    an spi_device:  Before, the ->cleanup() hook was invoked to free any
    allocations that were made by ->setup().  With the commit, that's no
    longer the case, so the ->setup() hook is expected to free the
    allocations itself.
    
    I've identified 5 drivers which depend on the old behavior and am fixing
    them up hereinafter: spi-bitbang.c spi-fsl-spi.c spi-omap-uwire.c
    spi-omap2-mcspi.c spi-pxa2xx.c
    
    Importantly, ->setup() is not only invoked on spi_device *addition*:
    It may subsequently be called to *change* SPI parameters.  If changing
    these SPI parameters fails, freeing memory allocations would be wrong.
    That should only be done if the spi_device is finally destroyed.
    I am therefore using a bool "initial_setup" in 4 of the affected drivers
    to differentiate between the invocation on *adding* the spi_device and
    any subsequent invocati...
    2ec6f20b
spi-fsl-spi.c 21 KB