]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
serdev: Provide a bustype shutdown function
authorUwe Kleine-König <u.kleine-koenig@baylibre.com>
Fri, 12 Dec 2025 08:09:06 +0000 (09:09 +0100)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Wed, 17 Dec 2025 14:08:18 +0000 (15:08 +0100)
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>
drivers/tty/serdev/core.c
include/linux/serdev.h

index b33e708cb2455fc144a9fd4ac40ce9118e1a8faa..40eedc15277c36d849e2b64a962869c18340fd35 100644 (file)
@@ -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);
index 34562eb99931d808e885ce5022b8aa4577566885..5654c58eb73c07634a47d120d4074944c95c0c8b 100644 (file)
@@ -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)