summaryrefslogtreecommitdiff
path: root/drivers/fsi
diff options
context:
space:
mode:
authorUwe Kleine-König <u.kleine-koenig@baylibre.com>2025-12-09 12:40:31 +0100
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2026-01-27 16:35:36 +0100
commit69d4ca009005c14068fe358196c38281ec5ee316 (patch)
treeb1b892222db407b933c88998f563fe6315b43d42 /drivers/fsi
parent68cc6588b52359ff9b48516525b463551a4bb315 (diff)
fsi: Create bus specific probe and remove functions
Introduce a bus specific probe and remove function. For now this only allows to get rid of a cast of the generic device to an fsi device in the drivers and changes the remove prototype to return void---a non-zero return value is ignored anyhow. The objective is to get rid of users of struct device callbacks .probe(), .remove() and .shutdown() to eventually remove these. Until all fsi drivers are converted this results in a runtime warning about the drivers needing an update because there is a bus probe function and a driver probe function. Signed-off-by: Uwe Kleine-König <u.kleine-koenig@baylibre.com> Acked-by: Eddie James <eajames@linux.ibm.com> Link: https://patch.msgid.link/3b53adb75a5ae7894736d46cb6eb85f5ef36520e.1765279318.git.u.kleine-koenig@baylibre.com Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'drivers/fsi')
-rw-r--r--drivers/fsi/fsi-core.c50
1 files changed, 50 insertions, 0 deletions
diff --git a/drivers/fsi/fsi-core.c b/drivers/fsi/fsi-core.c
index 4e60d4b17c11..83599a1c548b 100644
--- a/drivers/fsi/fsi-core.c
+++ b/drivers/fsi/fsi-core.c
@@ -128,9 +128,31 @@ static int fsi_bus_match(struct device *dev, const struct device_driver *drv)
return 0;
}
+static int fsi_probe(struct device *dev)
+{
+ struct fsi_device *fsidev = to_fsi_dev(dev);
+ struct fsi_driver *fsidrv = to_fsi_drv(dev->driver);
+
+ if (fsidrv->probe)
+ return fsidrv->probe(fsidev);
+ else
+ return 0;
+}
+
+static void fsi_remove(struct device *dev)
+{
+ struct fsi_device *fsidev = to_fsi_dev(dev);
+ struct fsi_driver *fsidrv = to_fsi_drv(dev->driver);
+
+ if (fsidrv->remove)
+ fsidrv->remove(fsidev);
+}
+
static const struct bus_type fsi_bus_type = {
.name = "fsi",
.match = fsi_bus_match,
+ .probe = fsi_probe,
+ .remove = fsi_remove,
};
/*
@@ -1392,6 +1414,25 @@ void fsi_master_unregister(struct fsi_master *master)
}
EXPORT_SYMBOL_GPL(fsi_master_unregister);
+static int fsi_legacy_probe(struct fsi_device *fsidev)
+{
+ struct device *dev = &fsidev->dev;
+ struct device_driver *driver = dev->driver;
+
+ return driver->probe(dev);
+}
+
+static void fsi_legacy_remove(struct fsi_device *fsidev)
+{
+ struct device *dev = &fsidev->dev;
+ struct device_driver *driver = dev->driver;
+ int ret;
+
+ ret = driver->remove(dev);
+ if (unlikely(ret))
+ dev_warn(dev, "Ignoring return value of remove callback (%pe)\n", ERR_PTR(ret));
+}
+
int fsi_driver_register(struct fsi_driver *fsi_drv)
{
if (!fsi_drv)
@@ -1401,6 +1442,15 @@ int fsi_driver_register(struct fsi_driver *fsi_drv)
fsi_drv->drv.bus = &fsi_bus_type;
+ /*
+ * This driver needs updating. Note that driver_register() warns about
+ * this, so we're not adding another warning here.
+ */
+ if (!fsi_drv->probe && fsi_drv->drv.probe)
+ fsi_drv->probe = fsi_legacy_probe;
+ if (!fsi_drv->remove && fsi_drv->drv.remove)
+ fsi_drv->remove = fsi_legacy_remove;
+
return driver_register(&fsi_drv->drv);
}
EXPORT_SYMBOL_GPL(fsi_driver_register);