On Fri, May 15, 2020 at 7:45 PM Lukas Wunner <lukas@xxxxxxxxx> wrote: > On Fri, May 15, 2020 at 05:29:03PM +0100, Mark Brown wrote: > > On Fri, May 15, 2020 at 05:58:02PM +0200, Lukas Wunner wrote: > > > Fix by using the non-devm variant spi_register_controller(). Note that > > > the struct spi_controller as well as the driver-private data are not > > > freed until after bcm2835_spi_remove() has finished, so accessing them > > > is safe. > > > > Why not use managed allocations of clocks and DMA channels? This is a > > standard issue with the devm APIs, if you're using them you basically > > need to use them for *everything* up to the point where you start using > > them. > > There is no devm version of clk_prepare_enable(), dma_request_chan() > and various other functions invoked on ->probe() by spi-bcm2835.c. > So tearing down DMA channels, disabling clocks etc needs to happen > in the ->remove() hook and consequently devm_spi_register_controller() > cannot be used. There is devm_add_action_or_reset (IIRC the name). It does a trick. -- With Best Regards, Andy Shevchenko