]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
soundwire: Use bus methods for .probe(), .remove() and .shutdown()
authorUwe Kleine-König <u.kleine-koenig@baylibre.com>
Mon, 15 Dec 2025 17:49:26 +0000 (18:49 +0100)
committerVinod Koul <vkoul@kernel.org>
Tue, 23 Dec 2025 06:42:49 +0000 (12:12 +0530)
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 <u.kleine-koenig@baylibre.com>
Link: https://patch.msgid.link/20251215174925.1327021-6-u.kleine-koenig@baylibre.com
Signed-off-by: Vinod Koul <vkoul@kernel.org>
drivers/soundwire/bus_type.c

index c40de98f1485606f733eaca2bef474447ce6b43c..80ed3468e860e5b1527ec1f7816c11490d539802 100644 (file)
@@ -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);