From 336bc343e754aa1b30c877eec59b3fa1e905aa1e Mon Sep 17 00:00:00 2001 From: Tobias Schramm Date: Thu, 28 May 2020 14:12:56 +0200 Subject: [PATCH 03/22] tty: serdev: support shutdown op Allow serdev drivers to register a shutdown handler Signed-off-by: Tobias Schramm --- drivers/tty/serdev/core.c | 11 +++++++++++ include/linux/serdev.h | 1 + 2 files changed, 12 insertions(+) diff --git a/drivers/tty/serdev/core.c b/drivers/tty/serdev/core.c index c5f0d936b003..37e45c356540 100644 --- a/drivers/tty/serdev/core.c +++ b/drivers/tty/serdev/core.c @@ -432,11 +432,22 @@ static int serdev_drv_remove(struct device *dev) return 0; } +static void serdev_drv_shutdown(struct device *dev) +{ + const struct serdev_device_driver *sdrv; + if (dev->driver) { + sdrv = to_serdev_device_driver(dev->driver); + if (sdrv->shutdown) + sdrv->shutdown(to_serdev_device(dev)); + } +} + static struct bus_type serdev_bus_type = { .name = "serial", .match = serdev_device_match, .probe = serdev_drv_probe, .remove = serdev_drv_remove, + .shutdown = serdev_drv_shutdown, }; /** diff --git a/include/linux/serdev.h b/include/linux/serdev.h index 9f14f9c12ec4..94050561325c 100644 --- a/include/linux/serdev.h +++ b/include/linux/serdev.h @@ -63,6 +63,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) -- 2.30.0