spi: fix resource leak for drivers without .remove callback
authorUwe Kleine-König <u.kleine-koenig@pengutronix.de>
Thu, 19 Nov 2020 16:16:02 +0000 (17:16 +0100)
committerMark Brown <broonie@kernel.org>
Fri, 20 Nov 2020 13:49:10 +0000 (13:49 +0000)
commit440408dbadfe47a615afd0a0a4a402e629be658a
treee377ee9a66425d67efb78ad2cfc6319128644643
parent03fc41afaa6549baa2dab7a84e1afaf5cadb5b18
spi: fix resource leak for drivers without .remove callback

Consider an spi driver with a .probe but without a .remove callback (e.g.
rtc-ds1347). The function spi_drv_probe() is called to bind a device and
so dev_pm_domain_attach() is called. As there is no remove callback
spi_drv_remove() isn't called at unbind time however and so calling
dev_pm_domain_detach() is missed and the pm domain keeps active.

To fix this always use both spi_drv_probe() and spi_drv_remove() and
make them handle the respective callback not being set. This has the
side effect that for a (hypothetical) driver that has neither .probe nor
remove the clk and pm domain setup is done.

Fixes: 33cf00e57082 ("spi: attach/detach SPI device to the ACPI power domain")
Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
Link: https://lore.kernel.org/r/20201119161604.2633521-1-u.kleine-koenig@pengutronix.de
Signed-off-by: Mark Brown <broonie@kernel.org>
drivers/spi/spi.c