Skip to contentSkip to conversation

host1x: Convert to bus methods

PATCH Applied Uwe Kleine-König 3 participants 7 messages Dec 10, 2025 – Jan 13

Subsystems (8)
lore
Share & tools
lore
#0 lore raw

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
#1 lore raw

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
index 7237f14eaf5a..4e7115b247e7 100644
@@ -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
index 4596073fe28f..bd0646eae555 100644
@@ -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
index 344cc9e741c1..fd89512d4488 100644
@@ -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
index 074ad0dc56ca..68783d5ffeb1 100644
@@ -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
index 9fa9c30a34e6..5e7a63143a4a 100644
@@ -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
maintainer Tested-by Reviewed-by on v1 1/2
#2 lore raw

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::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.

--
Luca Ceresoli, Bootlin
Embedded Linux and Kernel engineering
https://bootlin.com

#3 lore raw

PATCH 2/2 host1x: Convert to bus methods

In reply to Uwe Kleine-König

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.

---
 drivers/gpu/host1x/bus.c | 67 ++++++++++++++++++++--------------------
 1 file changed, 33 insertions(+), 34 deletions(-)
drivers/gpu/host1x/bus.c +33 -34
index fd89512d4488..c0d7a9b5f07a 100644
@@ -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
maintainer Tested-by Reviewed-by on v1 2/2
#4 lore raw
Quoted 10 lines · Uwe Kleine-König

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.

--
Luca Ceresoli, Bootlin
Embedded Linux and Kernel engineering
https://bootlin.com

#5 lore raw
In reply to Uwe Kleine-König

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

#6 lore raw
In reply to Uwe Kleine-König
Quoted 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
Uwe

Uwe 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