host1x: Convert to bus methods
Subsystems (8)
cover host1x: Convert to bus methods
Hello,
with the eventual goal to get rid of the callbacks .probe(), .remove() and .shutdown() in struct device_driver, migrate host1x to use bus callbacks instead.
Best regards
Uwe
Uwe Kleine-König (2):
host1x: Make remove callback return void
host1x: Convert to bus methods
drivers/crypto/tegra/tegra-se-main.c | 4 +- drivers/gpu/drm/tegra/drm.c | 4 +- drivers/gpu/host1x/bus.c | 67 +++++++++++------------ drivers/staging/media/tegra-video/video.c | 4 +- include/linux/host1x.h | 2 +- 5 files changed, 37 insertions(+), 44 deletions(-)
base-commit: 7d0a66e4bb9081d75c82ec4957c50034cb0ea449
Signature · 1 line
2.47.3
PATCH 1/2 host1x: Make remove callback return void
The return value of struct device_driver::remove is ignored by the core (see device_remove() in drivers/base/dd.c). So it doesn't make sense to let the host1x remove callback return an int just to ignore it later.
So make the callback return void. All current implementors return 0, so they are easily converted.
--- drivers/crypto/tegra/tegra-se-main.c | 4 +--- drivers/gpu/drm/tegra/drm.c | 4 +--- drivers/gpu/host1x/bus.c | 2 +- drivers/staging/media/tegra-video/video.c | 4 +--- include/linux/host1x.h | 2 +- 5 files changed, 5 insertions(+), 11 deletions(-)
drivers/crypto/tegra/tegra-se-main.c +1 -3
@@ -401,11 +401,9 @@ static int tegra_se_host1x_probe(struct host1x_device *dev)return host1x_device_init (dev); } -static int tegra_se_host1x_remove (struct host1x_device *dev) +static void tegra_se_host1x_remove (struct host1x_device *dev) {host1x_device_exit (dev); - -return 0 ; }static struct host1x_driver tegra_se_host1x_driver = {
drivers/gpu/drm/tegra/drm.c +1 -3
@@ -1300,7 +1300,7 @@ static int host1x_drm_probe(struct host1x_device *dev)return err; } -static int host1x_drm_remove (struct host1x_device *dev) +static void host1x_drm_remove (struct host1x_device *dev) {struct drm_device *drm =dev_get_drvdata (&dev->dev);struct tegra_drm *tegra = drm->dev_private;
@@ -1329,8 +1329,6 @@ static int host1x_drm_remove(struct host1x_device *dev)kfree (tegra);drm_dev_put (drm); - -return 0 ; }static void host1x_drm_shutdown (struct host1x_device *dev)
drivers/gpu/host1x/bus.c +1 -1
@@ -628,7 +628,7 @@ static int host1x_device_remove(struct device *dev)struct host1x_device *device =to_host1x_device (dev);if (driver->remove) -return driver->remove (device); + driver->remove (device);return 0 ; }
drivers/staging/media/tegra-video/video.c +1 -3
@@ -107,7 +107,7 @@ static int host1x_video_probe(struct host1x_device *dev)return ret; } -static int host1x_video_remove (struct host1x_device *dev) +static void host1x_video_remove (struct host1x_device *dev) {struct tegra_video_device *vid =dev_get_drvdata (&dev->dev);
@@ -118,8 +118,6 @@ static int host1x_video_remove(struct host1x_device *dev)/* This calls v4l2_dev release callback on last reference */ v4l2_device_put (&vid->v4l2_dev); - -return 0 ; }static const struct of_device_id host1x_video_subdevs[] = {
include/linux/host1x.h +1 -1
@@ -380,7 +380,7 @@ struct host1x_driver {struct list_head list;int (*probe)(struct host1x_device *device); -int (*remove)(struct host1x_device *device); +void (*remove)(struct host1x_device *device);void (*shutdown)(struct host1x_device *device); };
Signature · 1 line
2.47.3
Re: [PATCH 1/2] host1x: Make remove callback return void
Hello Uwe,
Quoted 8 lines · Uwe Kleine-König
The return value of struct
device_driver::removeis ignored by the core (seedevice_remove()indrivers/base/dd.c). So it doesn't make sense to let the host1x remove callback return an int just to ignore it later.So make the callback return void. All current implementors return 0, so they are easily converted.
Signed-off-by Uwe Kleine-König <[email protected]>
--
Luca Ceresoli, Bootlin
Embedded Linux and Kernel engineering
https://bootlin.com
PATCH 2/2 host1x: Convert to bus methods
In reply to Uwe Kleine-KönigThe 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.
--- drivers/gpu/host1x/bus.c | 67 ++++++++++++++++++++-------------------- 1 file changed, 33 insertions(+), 34 deletions(-)
drivers/gpu/host1x/bus.c +33 -34
@@ -346,6 +346,36 @@ static int host1x_device_uevent(const struct device *dev,return 0 ; } +static int host1x_device_probe (struct device *dev) +{ +struct host1x_driver *driver =to_host1x_driver (dev->driver); +struct host1x_device *device =to_host1x_device (dev); + +if (driver->probe) +return driver->probe (device); + +return 0 ; +} + +static void host1x_device_remove (struct device *dev) +{ +struct host1x_driver *driver =to_host1x_driver (dev->driver); +struct host1x_device *device =to_host1x_device (dev); + +if (driver->remove) + driver->remove (device); +} + +static void host1x_device_shutdown (struct device *dev) +{ +struct host1x_driver *driver =to_host1x_driver (dev->driver); +struct host1x_device *device =to_host1x_device (dev); + +if (dev->driver && driver->shutdown) + driver->shutdown (device); +} + +static const struct dev_pm_ops host1x_device_pm_ops = { .suspend = pm_generic_suspend, .resume = pm_generic_resume,
@@ -359,6 +389,9 @@ const struct bus_type host1x_bus_type = { .name = "host1x", .match = host1x_device_match, .uevent = host1x_device_uevent, + .probe = host1x_device_probe, + .remove = host1x_device_remove, + .shutdown = host1x_device_shutdown, .pm = &host1x_device_pm_ops, };
@@ -611,37 +644,6 @@ int host1x_unregister(struct host1x *host1x)return 0 ; } -static int host1x_device_probe (struct device *dev) -{ -struct host1x_driver *driver =to_host1x_driver (dev->driver); -struct host1x_device *device =to_host1x_device (dev); - -if (driver->probe) -return driver->probe (device); - -return 0 ; -} - -static int host1x_device_remove (struct device *dev) -{ -struct host1x_driver *driver =to_host1x_driver (dev->driver); -struct host1x_device *device =to_host1x_device (dev); - -if (driver->remove) - driver->remove (device); - -return 0 ; -} - -static void host1x_device_shutdown (struct device *dev) -{ -struct host1x_driver *driver =to_host1x_driver (dev->driver); -struct host1x_device *device =to_host1x_device (dev); - -if (driver->shutdown) - driver->shutdown (device); -} -/** * host1x_driver_register_full() - register a host1x driver * @driver: host1x driver
@@ -672,9 +674,6 @@ int host1x_driver_register_full(struct host1x_driver *driver, driver->driver.bus = &host1x_bus_type; driver->driver.owner = owner; - driver->driver.probe = host1x_device_probe; - driver->driver.remove = host1x_device_remove; - driver->driver.shutdown = host1x_device_shutdown;return driver_register (&driver->driver); }
Signature · 1 line
2.47.3
Quoted 10 lines · Uwe Kleine-König
The callbacks .probe(), .remove() and .shutdown() for
device_driversshould 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 fordev->driver!= NULL is needed.Signed-off-by Uwe Kleine-König <[email protected]>
--
Luca Ceresoli, Bootlin
Embedded Linux and Kernel engineering
https://bootlin.com
Hello,
Quoted 3 lines · Uwe Kleine-König
with the eventual goal to get rid of the callbacks .probe(), .remove() and .shutdown() in struct
device_driver, migrate host1x to use bus callbacks instead.
This series got some positive feedback but nobody picked it up yet. Is this still on someone's radar? The last patches to drivers/gpu/host1x where picked up by Thierry.
Best regards
Uwe
Thierry Reding
AppliedQuoted 13 lines · Uwe Kleine-König
Hello,
with the eventual goal to get rid of the callbacks .probe(), .remove() and .shutdown() in struct
device_driver, migrate host1x to use bus callbacks instead.Best regards
UweUwe Kleine-König (2):
host1x: Make remove callback return void
host1x: Convert to bus methods
Quoted 6 lines
drivers/crypto/tegra/tegra-se-main.c | 4 +- drivers/gpu/drm/tegra/drm.c | 4 +- drivers/gpu/host1x/bus.c | 67 +++++++++++------------ drivers/staging/media/tegra-video/video.c | 4 +- include/linux/host1x.h | 2 +- 5 files changed, 37 insertions(+), 44 deletions(-)
Applied, thanks.
Thierry