Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

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>

authored by

Uwe Kleine-König and committed by
Greg Kroah-Hartman
69d4ca00 68cc6588

+52
+50
drivers/fsi/fsi-core.c
··· 128 128 return 0; 129 129 } 130 130 131 + static int fsi_probe(struct device *dev) 132 + { 133 + struct fsi_device *fsidev = to_fsi_dev(dev); 134 + struct fsi_driver *fsidrv = to_fsi_drv(dev->driver); 135 + 136 + if (fsidrv->probe) 137 + return fsidrv->probe(fsidev); 138 + else 139 + return 0; 140 + } 141 + 142 + static void fsi_remove(struct device *dev) 143 + { 144 + struct fsi_device *fsidev = to_fsi_dev(dev); 145 + struct fsi_driver *fsidrv = to_fsi_drv(dev->driver); 146 + 147 + if (fsidrv->remove) 148 + fsidrv->remove(fsidev); 149 + } 150 + 131 151 static const struct bus_type fsi_bus_type = { 132 152 .name = "fsi", 133 153 .match = fsi_bus_match, 154 + .probe = fsi_probe, 155 + .remove = fsi_remove, 134 156 }; 135 157 136 158 /* ··· 1414 1392 } 1415 1393 EXPORT_SYMBOL_GPL(fsi_master_unregister); 1416 1394 1395 + static int fsi_legacy_probe(struct fsi_device *fsidev) 1396 + { 1397 + struct device *dev = &fsidev->dev; 1398 + struct device_driver *driver = dev->driver; 1399 + 1400 + return driver->probe(dev); 1401 + } 1402 + 1403 + static void fsi_legacy_remove(struct fsi_device *fsidev) 1404 + { 1405 + struct device *dev = &fsidev->dev; 1406 + struct device_driver *driver = dev->driver; 1407 + int ret; 1408 + 1409 + ret = driver->remove(dev); 1410 + if (unlikely(ret)) 1411 + dev_warn(dev, "Ignoring return value of remove callback (%pe)\n", ERR_PTR(ret)); 1412 + } 1413 + 1417 1414 int fsi_driver_register(struct fsi_driver *fsi_drv) 1418 1415 { 1419 1416 if (!fsi_drv) ··· 1441 1400 return -EINVAL; 1442 1401 1443 1402 fsi_drv->drv.bus = &fsi_bus_type; 1403 + 1404 + /* 1405 + * This driver needs updating. Note that driver_register() warns about 1406 + * this, so we're not adding another warning here. 1407 + */ 1408 + if (!fsi_drv->probe && fsi_drv->drv.probe) 1409 + fsi_drv->probe = fsi_legacy_probe; 1410 + if (!fsi_drv->remove && fsi_drv->drv.remove) 1411 + fsi_drv->remove = fsi_legacy_remove; 1444 1412 1445 1413 return driver_register(&fsi_drv->drv); 1446 1414 }
+2
include/linux/fsi.h
··· 49 49 .engine_type = (t), .version = (v), 50 50 51 51 struct fsi_driver { 52 + int (*probe)(struct fsi_device *fsidev); 53 + void (*remove)(struct fsi_device *fsidev); 52 54 struct device_driver drv; 53 55 const struct fsi_device_id *id_table; 54 56 };