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.

bus: fsl-mc: Convert to bus callbacks

With the eventual goal to drop .probe(), .remove() and .shutdown() from
struct device_driver, convert the fsl bus to use bus methods.

Other than a driver's shutdown callback the bus shutdown callback is
also called for unbound drivers. So check for the device being bound
before following the pointer to its driver.

Signed-off-by: Uwe Kleine-König <u.kleine-koenig@baylibre.com>
Reviewed-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Tested-by: Ioana Ciornei <ioana.ciornei@nxp.com>
Reviewed-by: Ioana Ciornei <ioana.ciornei@nxp.com>
Link: https://lore.kernel.org/r/848fffe5c479d899c04a4c99ccb5f0128ccc942d.1764684327.git.u.kleine-koenig@baylibre.com
Link: https://lore.kernel.org/r/20251209115950.3382308-2-u.kleine-koenig@baylibre.com
[chleroy: squashed the two patches]
Signed-off-by: Christophe Leroy (CS GROUP) <chleroy@kernel.org>

authored by

Uwe Kleine-König and committed by
Christophe Leroy (CS GROUP)
c8dff80a f4aff53c

+32 -38
+32 -38
drivers/bus/fsl-mc/fsl-mc-bus.c
··· 137 137 return 0; 138 138 } 139 139 140 + static int fsl_mc_probe(struct device *dev) 141 + { 142 + struct fsl_mc_driver *mc_drv = to_fsl_mc_driver(dev->driver); 143 + struct fsl_mc_device *mc_dev = to_fsl_mc_device(dev); 144 + 145 + if (mc_drv->probe) 146 + return mc_drv->probe(mc_dev); 147 + 148 + return 0; 149 + } 150 + 151 + static void fsl_mc_remove(struct device *dev) 152 + { 153 + struct fsl_mc_driver *mc_drv = to_fsl_mc_driver(dev->driver); 154 + struct fsl_mc_device *mc_dev = to_fsl_mc_device(dev); 155 + 156 + if (mc_drv->remove) 157 + mc_drv->remove(mc_dev); 158 + } 159 + 160 + static void fsl_mc_shutdown(struct device *dev) 161 + { 162 + struct fsl_mc_driver *mc_drv = to_fsl_mc_driver(dev->driver); 163 + struct fsl_mc_device *mc_dev = to_fsl_mc_device(dev); 164 + 165 + if (dev->driver && mc_drv->shutdown) 166 + mc_drv->shutdown(mc_dev); 167 + } 168 + 140 169 static int fsl_mc_dma_configure(struct device *dev) 141 170 { 142 171 const struct device_driver *drv = READ_ONCE(dev->driver); ··· 343 314 .name = "fsl-mc", 344 315 .match = fsl_mc_bus_match, 345 316 .uevent = fsl_mc_bus_uevent, 317 + .probe = fsl_mc_probe, 318 + .remove = fsl_mc_remove, 319 + .shutdown = fsl_mc_shutdown, 346 320 .dma_configure = fsl_mc_dma_configure, 347 321 .dma_cleanup = fsl_mc_dma_cleanup, 348 322 .dev_groups = fsl_mc_dev_groups, ··· 466 434 return NULL; 467 435 } 468 436 469 - static int fsl_mc_driver_probe(struct device *dev) 470 - { 471 - struct fsl_mc_driver *mc_drv; 472 - struct fsl_mc_device *mc_dev = to_fsl_mc_device(dev); 473 - int error; 474 - 475 - mc_drv = to_fsl_mc_driver(dev->driver); 476 - 477 - return mc_drv->probe(mc_dev); 478 - } 479 - 480 - static int fsl_mc_driver_remove(struct device *dev) 481 - { 482 - struct fsl_mc_driver *mc_drv = to_fsl_mc_driver(dev->driver); 483 - struct fsl_mc_device *mc_dev = to_fsl_mc_device(dev); 484 - 485 - mc_drv->remove(mc_dev); 486 - 487 - return 0; 488 - } 489 - 490 - static void fsl_mc_driver_shutdown(struct device *dev) 491 - { 492 - struct fsl_mc_driver *mc_drv = to_fsl_mc_driver(dev->driver); 493 - struct fsl_mc_device *mc_dev = to_fsl_mc_device(dev); 494 - 495 - mc_drv->shutdown(mc_dev); 496 - } 497 - 498 437 /* 499 438 * __fsl_mc_driver_register - registers a child device driver with the 500 439 * MC bus ··· 481 478 482 479 mc_driver->driver.owner = owner; 483 480 mc_driver->driver.bus = &fsl_mc_bus_type; 484 - 485 - if (mc_driver->probe) 486 - mc_driver->driver.probe = fsl_mc_driver_probe; 487 - 488 - if (mc_driver->remove) 489 - mc_driver->driver.remove = fsl_mc_driver_remove; 490 - 491 - if (mc_driver->shutdown) 492 - mc_driver->driver.shutdown = fsl_mc_driver_shutdown; 493 481 494 482 error = driver_register(&mc_driver->driver); 495 483 if (error < 0) {