]> www.infradead.org Git - users/dwmw2/linux.git/commitdiff
soundwire: bus_type: fix remove and shutdown support
authorPierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
Fri, 10 Jun 2022 01:51:05 +0000 (09:51 +0800)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Sun, 21 Aug 2022 13:15:56 +0000 (15:15 +0200)
[ Upstream commit df6407782964dc7e35ad84230abb38f46314b245 ]

The bus sdw_drv_remove() and sdw_drv_shutdown() helpers are used
conditionally, if the driver provides these routines.

These helpers already test if the driver provides a .remove or
.shutdown callback, so there's no harm in invoking the
sdw_drv_remove() and sdw_drv_shutdown() unconditionally.

In addition, the current code is imbalanced with
dev_pm_domain_attach() called from sdw_drv_probe(), but
dev_pm_domain_detach() called from sdw_drv_remove() only if the driver
provides a .remove callback.

Fixes: 9251345dca24b ("soundwire: Add SoundWire bus type")
Signed-off-by: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
Reviewed-by: Rander Wang <rander.wang@intel.com>
Signed-off-by: Bard Liao <yung-chuan.liao@linux.intel.com>
Link: https://lore.kernel.org/r/20220610015105.25987-1-yung-chuan.liao@linux.intel.com
Signed-off-by: Vinod Koul <vkoul@kernel.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
drivers/soundwire/bus_type.c

index 575b9bad99d510459fca1fed8fc22bc4e1f2af64..2e8986cccdd499b847caa6f618cabc2171ab2277 100644 (file)
@@ -184,12 +184,8 @@ int __sdw_register_driver(struct sdw_driver *drv, struct module *owner)
 
        drv->driver.owner = owner;
        drv->driver.probe = sdw_drv_probe;
-
-       if (drv->remove)
-               drv->driver.remove = sdw_drv_remove;
-
-       if (drv->shutdown)
-               drv->driver.shutdown = sdw_drv_shutdown;
+       drv->driver.remove = sdw_drv_remove;
+       drv->driver.shutdown = sdw_drv_shutdown;
 
        return driver_register(&drv->driver);
 }