From: Uwe Kleine-König Date: Mon, 15 Dec 2025 17:49:26 +0000 (+0100) Subject: soundwire: Use bus methods for .probe(), .remove() and .shutdown() X-Git-Tag: v7.0-rc1~61^2~2 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=866160a51f5586d53e17ceab36029c8805ffea28;p=thirdparty%2Fkernel%2Flinux.git soundwire: Use bus methods for .probe(), .remove() and .shutdown() These are nearly identical to the respective driver callbacks. The only differences are that .remove() returns void instead of int and .shutdown() has to cope for unbound devices. The objective is to get rid of users of struct device_driver callbacks .probe(), .remove() and .shutdown() to eventually remove these. Signed-off-by: Uwe Kleine-König Link: https://patch.msgid.link/20251215174925.1327021-6-u.kleine-koenig@baylibre.com Signed-off-by: Vinod Koul --- diff --git a/drivers/soundwire/bus_type.c b/drivers/soundwire/bus_type.c index c40de98f14856..80ed3468e860e 100644 --- a/drivers/soundwire/bus_type.c +++ b/drivers/soundwire/bus_type.c @@ -72,13 +72,7 @@ int sdw_slave_uevent(const struct device *dev, struct kobj_uevent_env *env) return 0; } -const struct bus_type sdw_bus_type = { - .name = "soundwire", - .match = sdw_bus_match, -}; -EXPORT_SYMBOL_GPL(sdw_bus_type); - -static int sdw_drv_probe(struct device *dev) +static int sdw_bus_probe(struct device *dev) { struct sdw_slave *slave = dev_to_sdw_dev(dev); struct sdw_driver *drv = drv_to_sdw_driver(dev->driver); @@ -164,7 +158,7 @@ static int sdw_drv_probe(struct device *dev) return 0; } -static int sdw_drv_remove(struct device *dev) +static void sdw_bus_remove(struct device *dev) { struct sdw_slave *slave = dev_to_sdw_dev(dev); struct sdw_driver *drv = drv_to_sdw_driver(dev->driver); @@ -179,19 +173,26 @@ static int sdw_drv_remove(struct device *dev) drv->remove(slave); ida_free(&slave->bus->slave_ida, slave->index); - - return 0; } -static void sdw_drv_shutdown(struct device *dev) +static void sdw_bus_shutdown(struct device *dev) { struct sdw_slave *slave = dev_to_sdw_dev(dev); struct sdw_driver *drv = drv_to_sdw_driver(dev->driver); - if (drv->shutdown) + if (dev->driver && drv->shutdown) drv->shutdown(slave); } +const struct bus_type sdw_bus_type = { + .name = "soundwire", + .match = sdw_bus_match, + .probe = sdw_bus_probe, + .remove = sdw_bus_remove, + .shutdown = sdw_bus_shutdown, +}; +EXPORT_SYMBOL_GPL(sdw_bus_type); + /** * __sdw_register_driver() - register a SoundWire Slave driver * @drv: driver to register @@ -210,9 +211,6 @@ int __sdw_register_driver(struct sdw_driver *drv, struct module *owner) } drv->driver.owner = owner; - drv->driver.probe = sdw_drv_probe; - drv->driver.remove = sdw_drv_remove; - drv->driver.shutdown = sdw_drv_shutdown; drv->driver.dev_groups = sdw_attr_groups; return driver_register(&drv->driver);