Commit 866160a5 authored by Uwe Kleine-König's avatar Uwe Kleine-König Committed by Vinod Koul
Browse files

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: default avatarUwe Kleine-König <u.kleine-koenig@baylibre.com>
Link: https://patch.msgid.link/20251215174925.1327021-6-u.kleine-koenig@baylibre.com


Signed-off-by: default avatarVinod Koul <vkoul@kernel.org>
parent 478f3890
Loading
Loading
Loading
Loading
+13 −15
Original line number Diff line number Diff line
@@ -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);