Skip to content

Commit 6d71c62

Browse files
ukleinekgregkh
authored andcommitted
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>
1 parent 42eeed6 commit 6d71c62

2 files changed

Lines changed: 22 additions & 0 deletions

File tree

drivers/tty/serdev/core.c

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -414,11 +414,21 @@ static void serdev_drv_remove(struct device *dev)
414414
sdrv->remove(to_serdev_device(dev));
415415
}
416416

417+
static void serdev_drv_shutdown(struct device *dev)
418+
{
419+
const struct serdev_device_driver *sdrv =
420+
to_serdev_device_driver(dev->driver);
421+
422+
if (dev->driver && sdrv->shutdown)
423+
sdrv->shutdown(to_serdev_device(dev));
424+
}
425+
417426
static const struct bus_type serdev_bus_type = {
418427
.name = "serial",
419428
.match = serdev_device_match,
420429
.probe = serdev_drv_probe,
421430
.remove = serdev_drv_remove,
431+
.shutdown = serdev_drv_shutdown,
422432
};
423433

424434
/**
@@ -814,6 +824,14 @@ void serdev_controller_remove(struct serdev_controller *ctrl)
814824
}
815825
EXPORT_SYMBOL_GPL(serdev_controller_remove);
816826

827+
static void serdev_legacy_shutdown(struct serdev_device *serdev)
828+
{
829+
struct device *dev = &serdev->dev;
830+
struct device_driver *driver = dev->driver;
831+
832+
driver->shutdown(dev);
833+
}
834+
817835
/**
818836
* __serdev_device_driver_register() - Register client driver with serdev core
819837
* @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
830848
/* force drivers to async probe so I/O is possible in probe */
831849
sdrv->driver.probe_type = PROBE_PREFER_ASYNCHRONOUS;
832850

851+
if (!sdrv->shutdown && sdrv->driver.shutdown)
852+
sdrv->shutdown = serdev_legacy_shutdown;
853+
833854
return driver_register(&sdrv->driver);
834855
}
835856
EXPORT_SYMBOL_GPL(__serdev_device_driver_register);

include/linux/serdev.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,7 @@ struct serdev_device_driver {
6565
struct device_driver driver;
6666
int (*probe)(struct serdev_device *);
6767
void (*remove)(struct serdev_device *);
68+
void (*shutdown)(struct serdev_device *);
6869
};
6970

7071
static inline struct serdev_device_driver *to_serdev_device_driver(struct device_driver *d)

0 commit comments

Comments
 (0)