* [PATCH v1 0/4] serdev: Stop using device_driver callbacks
@ 2025-12-12 8:09 Uwe Kleine-König
2025-12-12 8:09 ` [PATCH v1 1/4] serdev: Provide a bustype shutdown function Uwe Kleine-König
2025-12-12 8:09 ` [PATCH v1 4/4] platform/surface: Migrate to serdev specific " Uwe Kleine-König
0 siblings, 2 replies; 4+ messages in thread
From: Uwe Kleine-König @ 2025-12-12 8:09 UTC (permalink / raw)
To: Rob Herring, Greg Kroah-Hartman, Jiri Slaby, Yang Li,
Marcel Holtmann, Luiz Augusto von Dentz, Maximilian Luz,
Hans de Goede, Ilpo Järvinen
Cc: linux-serial, linux-bluetooth, linux-arm-msm, platform-driver-x86
Hello,
the serdev subsystem currently doesn't provide a shutdown callback, thus
drivers that want being notified on shutdown have to implement the
respective callback in struct device_driver. This (and more)
functionality can be provided by a bus method as it already done for
.probe() and .remove().
The eventual goal is to remove .shutdown() (and .probe() and .remove())
from struct device_driver.
Note that the first patch introduces a warning when the three affected
drivers are registered (in driver_register() because `drv->bus->shutdown
&& drv->shutdown`). Patches #2 - #4 fix these warnings. So from a user
perspective it would be good to get the whole series in during a single
merge window---either by creating an immutable branch containing patch
#1 that is merged into the respective subsystems before applying the
following patches, or merging the complete series via a single tree.
At a later point in time the added check in
__serdev_device_driver_register() and the function
serdev_legacy_shutdown() can be dropped. I intend to cope for that in
the merge window that removes the callbacks from struct device_driver
because drivers that I might have missed to convert or that are rebased
over that change break silently as long as struct
device_driver::shutdown exists.
Best regards
Uwe
Uwe Kleine-König (4):
serdev: Provide a bustype shutdown function
Bluetooth: hci_aml: Migrate to serdev specific shutdown function
Bluetooth: hci_qca: Migrate to serdev specific shutdown function
platform/surface: Migrate to serdev specific shutdown function
drivers/bluetooth/hci_aml.c | 16 ++++++++--------
drivers/bluetooth/hci_qca.c | 5 ++---
drivers/platform/surface/aggregator/core.c | 6 +++---
drivers/tty/serdev/core.c | 21 +++++++++++++++++++++
include/linux/serdev.h | 1 +
5 files changed, 35 insertions(+), 14 deletions(-)
base-commit: 7d0a66e4bb9081d75c82ec4957c50034cb0ea449
--
2.47.3
^ permalink raw reply [flat|nested] 4+ messages in thread
* [PATCH v1 1/4] serdev: Provide a bustype shutdown function
2025-12-12 8:09 [PATCH v1 0/4] serdev: Stop using device_driver callbacks Uwe Kleine-König
@ 2025-12-12 8:09 ` Uwe Kleine-König
2025-12-12 8:09 ` [PATCH v1 4/4] platform/surface: Migrate to serdev specific " Uwe Kleine-König
1 sibling, 0 replies; 4+ messages in thread
From: Uwe Kleine-König @ 2025-12-12 8:09 UTC (permalink / raw)
To: Rob Herring, Greg Kroah-Hartman, Jiri Slaby, Yang Li,
Marcel Holtmann, Luiz Augusto von Dentz, Maximilian Luz,
Hans de Goede, Ilpo Järvinen
Cc: linux-serial, linux-bluetooth, linux-arm-msm, platform-driver-x86
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>
---
drivers/tty/serdev/core.c | 21 +++++++++++++++++++++
include/linux/serdev.h | 1 +
2 files changed, 22 insertions(+)
diff --git a/drivers/tty/serdev/core.c b/drivers/tty/serdev/core.c
index b33e708cb245..40eedc15277c 100644
--- a/drivers/tty/serdev/core.c
+++ b/drivers/tty/serdev/core.c
@@ -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);
diff --git a/include/linux/serdev.h b/include/linux/serdev.h
index 34562eb99931..5654c58eb73c 100644
--- a/include/linux/serdev.h
+++ b/include/linux/serdev.h
@@ -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)
--
2.47.3
^ permalink raw reply related [flat|nested] 4+ messages in thread
* [PATCH v1 4/4] platform/surface: Migrate to serdev specific shutdown function
2025-12-12 8:09 [PATCH v1 0/4] serdev: Stop using device_driver callbacks Uwe Kleine-König
2025-12-12 8:09 ` [PATCH v1 1/4] serdev: Provide a bustype shutdown function Uwe Kleine-König
@ 2025-12-12 8:09 ` Uwe Kleine-König
2026-01-05 15:11 ` Ilpo Järvinen
1 sibling, 1 reply; 4+ messages in thread
From: Uwe Kleine-König @ 2025-12-12 8:09 UTC (permalink / raw)
To: Rob Herring, Greg Kroah-Hartman, Maximilian Luz, Hans de Goede,
Ilpo Järvinen
Cc: linux-serial, platform-driver-x86
The motivation is stop using the callback .shutdown in
qca_serdev_driver.driver to make it possible to drop that.
Signed-off-by: Uwe Kleine-König <u.kleine-koenig@baylibre.com>
---
drivers/platform/surface/aggregator/core.c | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/drivers/platform/surface/aggregator/core.c b/drivers/platform/surface/aggregator/core.c
index c58e1fdd1a5f..860702c4266f 100644
--- a/drivers/platform/surface/aggregator/core.c
+++ b/drivers/platform/surface/aggregator/core.c
@@ -380,9 +380,9 @@ static int ssam_serdev_setup(struct acpi_device *ssh, struct serdev_device *serd
/* -- Power management. ----------------------------------------------------- */
-static void ssam_serial_hub_shutdown(struct device *dev)
+static void ssam_serial_hub_shutdown(struct serdev_device *serdev)
{
- struct ssam_controller *c = dev_get_drvdata(dev);
+ struct ssam_controller *c = dev_get_drvdata(&serdev->dev);
int status;
/*
@@ -834,12 +834,12 @@ MODULE_DEVICE_TABLE(of, ssam_serial_hub_of_match);
static struct serdev_device_driver ssam_serial_hub = {
.probe = ssam_serial_hub_probe,
.remove = ssam_serial_hub_remove,
+ .shutdown = ssam_serial_hub_shutdown,
.driver = {
.name = "surface_serial_hub",
.acpi_match_table = ACPI_PTR(ssam_serial_hub_acpi_match),
.of_match_table = of_match_ptr(ssam_serial_hub_of_match),
.pm = &ssam_serial_hub_pm_ops,
- .shutdown = ssam_serial_hub_shutdown,
.probe_type = PROBE_PREFER_ASYNCHRONOUS,
},
};
--
2.47.3
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH v1 4/4] platform/surface: Migrate to serdev specific shutdown function
2025-12-12 8:09 ` [PATCH v1 4/4] platform/surface: Migrate to serdev specific " Uwe Kleine-König
@ 2026-01-05 15:11 ` Ilpo Järvinen
0 siblings, 0 replies; 4+ messages in thread
From: Ilpo Järvinen @ 2026-01-05 15:11 UTC (permalink / raw)
To: Uwe Kleine-König, Greg Kroah-Hartman
Cc: Rob Herring, Maximilian Luz, Hans de Goede, linux-serial,
platform-driver-x86
[-- Attachment #1: Type: text/plain, Size: 1809 bytes --]
On Fri, 12 Dec 2025, Uwe Kleine-König wrote:
> The motivation is stop using the callback .shutdown in
> qca_serdev_driver.driver to make it possible to drop that.
>
> Signed-off-by: Uwe Kleine-König <u.kleine-koenig@baylibre.com>
In case somebody wants to take the entire series,
Acked-by: Ilpo Järvinen <ilpo.jarvinen@linux.intel.com>
--
i.
> ---
> drivers/platform/surface/aggregator/core.c | 6 +++---
> 1 file changed, 3 insertions(+), 3 deletions(-)
>
> diff --git a/drivers/platform/surface/aggregator/core.c b/drivers/platform/surface/aggregator/core.c
> index c58e1fdd1a5f..860702c4266f 100644
> --- a/drivers/platform/surface/aggregator/core.c
> +++ b/drivers/platform/surface/aggregator/core.c
> @@ -380,9 +380,9 @@ static int ssam_serdev_setup(struct acpi_device *ssh, struct serdev_device *serd
>
> /* -- Power management. ----------------------------------------------------- */
>
> -static void ssam_serial_hub_shutdown(struct device *dev)
> +static void ssam_serial_hub_shutdown(struct serdev_device *serdev)
> {
> - struct ssam_controller *c = dev_get_drvdata(dev);
> + struct ssam_controller *c = dev_get_drvdata(&serdev->dev);
> int status;
>
> /*
> @@ -834,12 +834,12 @@ MODULE_DEVICE_TABLE(of, ssam_serial_hub_of_match);
> static struct serdev_device_driver ssam_serial_hub = {
> .probe = ssam_serial_hub_probe,
> .remove = ssam_serial_hub_remove,
> + .shutdown = ssam_serial_hub_shutdown,
> .driver = {
> .name = "surface_serial_hub",
> .acpi_match_table = ACPI_PTR(ssam_serial_hub_acpi_match),
> .of_match_table = of_match_ptr(ssam_serial_hub_of_match),
> .pm = &ssam_serial_hub_pm_ops,
> - .shutdown = ssam_serial_hub_shutdown,
> .probe_type = PROBE_PREFER_ASYNCHRONOUS,
> },
> };
>
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2026-01-05 15:11 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-12-12 8:09 [PATCH v1 0/4] serdev: Stop using device_driver callbacks Uwe Kleine-König
2025-12-12 8:09 ` [PATCH v1 1/4] serdev: Provide a bustype shutdown function Uwe Kleine-König
2025-12-12 8:09 ` [PATCH v1 4/4] platform/surface: Migrate to serdev specific " Uwe Kleine-König
2026-01-05 15:11 ` Ilpo Järvinen
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox