mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/netdev/net.git/
synced 2026-04-03 23:37:40 -04:00
serdev: Provide a bustype shutdown function
To prepare serdev driver to migrate away from struct device_driver::shutdown (and then eventually remove that callback) create a serdev driver shutdown callback and migration code to keep the existing behaviour. Note this introduces a warning for each driver at register time that isn't converted yet to that callback. Signed-off-by: Uwe Kleine-König <u.kleine-koenig@baylibre.com> Link: https://patch.msgid.link/ab518883e3ed0976a19cb5b5b5faf42bd3a655b7.1765526117.git.u.kleine-koenig@baylibre.com Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
This commit is contained in:
committed by
Greg Kroah-Hartman
parent
42eeed6d9f
commit
6d71c62b13
@@ -414,11 +414,21 @@ static void serdev_drv_remove(struct device *dev)
|
||||
sdrv->remove(to_serdev_device(dev));
|
||||
}
|
||||
|
||||
static void serdev_drv_shutdown(struct device *dev)
|
||||
{
|
||||
const struct serdev_device_driver *sdrv =
|
||||
to_serdev_device_driver(dev->driver);
|
||||
|
||||
if (dev->driver && sdrv->shutdown)
|
||||
sdrv->shutdown(to_serdev_device(dev));
|
||||
}
|
||||
|
||||
static const struct bus_type serdev_bus_type = {
|
||||
.name = "serial",
|
||||
.match = serdev_device_match,
|
||||
.probe = serdev_drv_probe,
|
||||
.remove = serdev_drv_remove,
|
||||
.shutdown = serdev_drv_shutdown,
|
||||
};
|
||||
|
||||
/**
|
||||
@@ -814,6 +824,14 @@ void serdev_controller_remove(struct serdev_controller *ctrl)
|
||||
}
|
||||
EXPORT_SYMBOL_GPL(serdev_controller_remove);
|
||||
|
||||
static void serdev_legacy_shutdown(struct serdev_device *serdev)
|
||||
{
|
||||
struct device *dev = &serdev->dev;
|
||||
struct device_driver *driver = dev->driver;
|
||||
|
||||
driver->shutdown(dev);
|
||||
}
|
||||
|
||||
/**
|
||||
* __serdev_device_driver_register() - Register client driver with serdev core
|
||||
* @sdrv: client driver to be associated with client-device.
|
||||
@@ -830,6 +848,9 @@ int __serdev_device_driver_register(struct serdev_device_driver *sdrv, struct mo
|
||||
/* force drivers to async probe so I/O is possible in probe */
|
||||
sdrv->driver.probe_type = PROBE_PREFER_ASYNCHRONOUS;
|
||||
|
||||
if (!sdrv->shutdown && sdrv->driver.shutdown)
|
||||
sdrv->shutdown = serdev_legacy_shutdown;
|
||||
|
||||
return driver_register(&sdrv->driver);
|
||||
}
|
||||
EXPORT_SYMBOL_GPL(__serdev_device_driver_register);
|
||||
|
||||
@@ -65,6 +65,7 @@ struct serdev_device_driver {
|
||||
struct device_driver driver;
|
||||
int (*probe)(struct serdev_device *);
|
||||
void (*remove)(struct serdev_device *);
|
||||
void (*shutdown)(struct serdev_device *);
|
||||
};
|
||||
|
||||
static inline struct serdev_device_driver *to_serdev_device_driver(struct device_driver *d)
|
||||
|
||||
Reference in New Issue
Block a user