Skip to content

Commit 1f61d73

Browse files
ukleinekthierryreding
authored andcommitted
host1x: Convert to bus methods
The callbacks .probe(), .remove() and .shutdown() for device_drivers should go away. So migrate to bus methods. There are two differences that need addressing: - The bus remove callback returns void while the driver remove callback returns int (the actual value is ignored by the core). - The bus shutdown callback is also called for unbound devices, so an additional check for dev->driver != NULL is needed. Signed-off-by: Uwe Kleine-König <u.kleine-koenig@baylibre.com> Tested-by: Luca Ceresoli <luca.ceresoli@bootlin.com> # tegra20 tegra-video Reviewed-by: Luca Ceresoli <luca.ceresoli@bootlin.com> Signed-off-by: Thierry Reding <treding@nvidia.com> Link: https://patch.msgid.link/dd55d034c68953268ea416aa5c13e41b158fcbb4.1765355236.git.u.kleine-koenig@baylibre.com
1 parent ba35884 commit 1f61d73

1 file changed

Lines changed: 33 additions & 34 deletions

File tree

drivers/gpu/host1x/bus.c

Lines changed: 33 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -346,6 +346,36 @@ static int host1x_device_uevent(const struct device *dev,
346346
return 0;
347347
}
348348

349+
static int host1x_device_probe(struct device *dev)
350+
{
351+
struct host1x_driver *driver = to_host1x_driver(dev->driver);
352+
struct host1x_device *device = to_host1x_device(dev);
353+
354+
if (driver->probe)
355+
return driver->probe(device);
356+
357+
return 0;
358+
}
359+
360+
static void host1x_device_remove(struct device *dev)
361+
{
362+
struct host1x_driver *driver = to_host1x_driver(dev->driver);
363+
struct host1x_device *device = to_host1x_device(dev);
364+
365+
if (driver->remove)
366+
driver->remove(device);
367+
}
368+
369+
static void host1x_device_shutdown(struct device *dev)
370+
{
371+
struct host1x_driver *driver = to_host1x_driver(dev->driver);
372+
struct host1x_device *device = to_host1x_device(dev);
373+
374+
if (dev->driver && driver->shutdown)
375+
driver->shutdown(device);
376+
}
377+
378+
349379
static const struct dev_pm_ops host1x_device_pm_ops = {
350380
.suspend = pm_generic_suspend,
351381
.resume = pm_generic_resume,
@@ -359,6 +389,9 @@ const struct bus_type host1x_bus_type = {
359389
.name = "host1x",
360390
.match = host1x_device_match,
361391
.uevent = host1x_device_uevent,
392+
.probe = host1x_device_probe,
393+
.remove = host1x_device_remove,
394+
.shutdown = host1x_device_shutdown,
362395
.pm = &host1x_device_pm_ops,
363396
};
364397

@@ -623,37 +656,6 @@ int host1x_unregister(struct host1x *host1x)
623656
return 0;
624657
}
625658

626-
static int host1x_device_probe(struct device *dev)
627-
{
628-
struct host1x_driver *driver = to_host1x_driver(dev->driver);
629-
struct host1x_device *device = to_host1x_device(dev);
630-
631-
if (driver->probe)
632-
return driver->probe(device);
633-
634-
return 0;
635-
}
636-
637-
static int host1x_device_remove(struct device *dev)
638-
{
639-
struct host1x_driver *driver = to_host1x_driver(dev->driver);
640-
struct host1x_device *device = to_host1x_device(dev);
641-
642-
if (driver->remove)
643-
driver->remove(device);
644-
645-
return 0;
646-
}
647-
648-
static void host1x_device_shutdown(struct device *dev)
649-
{
650-
struct host1x_driver *driver = to_host1x_driver(dev->driver);
651-
struct host1x_device *device = to_host1x_device(dev);
652-
653-
if (driver->shutdown)
654-
driver->shutdown(device);
655-
}
656-
657659
/**
658660
* host1x_driver_register_full() - register a host1x driver
659661
* @driver: host1x driver
@@ -684,9 +686,6 @@ int host1x_driver_register_full(struct host1x_driver *driver,
684686

685687
driver->driver.bus = &host1x_bus_type;
686688
driver->driver.owner = owner;
687-
driver->driver.probe = host1x_device_probe;
688-
driver->driver.remove = host1x_device_remove;
689-
driver->driver.shutdown = host1x_device_shutdown;
690689

691690
return driver_register(&driver->driver);
692691
}

0 commit comments

Comments
 (0)