Skip to content

Commit c8dff80

Browse files
ukleinekChristophe Leroy (CS GROUP)
authored andcommitted
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>
1 parent f4aff53 commit c8dff80

1 file changed

Lines changed: 32 additions & 38 deletions

File tree

drivers/bus/fsl-mc/fsl-mc-bus.c

Lines changed: 32 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -137,6 +137,35 @@ static int fsl_mc_bus_uevent(const struct device *dev, struct kobj_uevent_env *e
137137
return 0;
138138
}
139139

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+
140169
static int fsl_mc_dma_configure(struct device *dev)
141170
{
142171
const struct device_driver *drv = READ_ONCE(dev->driver);
@@ -314,6 +343,9 @@ const struct bus_type fsl_mc_bus_type = {
314343
.name = "fsl-mc",
315344
.match = fsl_mc_bus_match,
316345
.uevent = fsl_mc_bus_uevent,
346+
.probe = fsl_mc_probe,
347+
.remove = fsl_mc_remove,
348+
.shutdown = fsl_mc_shutdown,
317349
.dma_configure = fsl_mc_dma_configure,
318350
.dma_cleanup = fsl_mc_dma_cleanup,
319351
.dev_groups = fsl_mc_dev_groups,
@@ -434,35 +466,6 @@ static const struct device_type *fsl_mc_get_device_type(const char *type)
434466
return NULL;
435467
}
436468

437-
static int fsl_mc_driver_probe(struct device *dev)
438-
{
439-
struct fsl_mc_driver *mc_drv;
440-
struct fsl_mc_device *mc_dev = to_fsl_mc_device(dev);
441-
int error;
442-
443-
mc_drv = to_fsl_mc_driver(dev->driver);
444-
445-
return mc_drv->probe(mc_dev);
446-
}
447-
448-
static int fsl_mc_driver_remove(struct device *dev)
449-
{
450-
struct fsl_mc_driver *mc_drv = to_fsl_mc_driver(dev->driver);
451-
struct fsl_mc_device *mc_dev = to_fsl_mc_device(dev);
452-
453-
mc_drv->remove(mc_dev);
454-
455-
return 0;
456-
}
457-
458-
static void fsl_mc_driver_shutdown(struct device *dev)
459-
{
460-
struct fsl_mc_driver *mc_drv = to_fsl_mc_driver(dev->driver);
461-
struct fsl_mc_device *mc_dev = to_fsl_mc_device(dev);
462-
463-
mc_drv->shutdown(mc_dev);
464-
}
465-
466469
/*
467470
* __fsl_mc_driver_register - registers a child device driver with the
468471
* MC bus
@@ -479,15 +482,6 @@ int __fsl_mc_driver_register(struct fsl_mc_driver *mc_driver,
479482
mc_driver->driver.owner = owner;
480483
mc_driver->driver.bus = &fsl_mc_bus_type;
481484

482-
if (mc_driver->probe)
483-
mc_driver->driver.probe = fsl_mc_driver_probe;
484-
485-
if (mc_driver->remove)
486-
mc_driver->driver.remove = fsl_mc_driver_remove;
487-
488-
if (mc_driver->shutdown)
489-
mc_driver->driver.shutdown = fsl_mc_driver_shutdown;
490-
491485
error = driver_register(&mc_driver->driver);
492486
if (error < 0) {
493487
pr_err("driver_register() failed for %s: %d\n",

0 commit comments

Comments
 (0)