[PATCH 20/20] drm/bridge: tc358775: use devm_drm_bridge_add()

Michael Walle mwalle at kernel.org
Mon May 6 13:34:49 UTC 2024


Use the device resource managed version of drm_bridge_add(). This
simplifies the error handling and we can get rid of tc_remove_bridge().
Also, add a check for the return code.

Signed-off-by: Michael Walle <mwalle at kernel.org>
---
 drivers/gpu/drm/bridge/tc358775.c | 21 ++++-----------------
 1 file changed, 4 insertions(+), 17 deletions(-)

diff --git a/drivers/gpu/drm/bridge/tc358775.c b/drivers/gpu/drm/bridge/tc358775.c
index 31f89b7d5a3a..1d2547e4c4e3 100644
--- a/drivers/gpu/drm/bridge/tc358775.c
+++ b/drivers/gpu/drm/bridge/tc358775.c
@@ -762,26 +762,14 @@ static int tc_probe(struct i2c_client *client)
 	tc->bridge.funcs = &tc_bridge_funcs;
 	tc->bridge.of_node = dev->of_node;
 	tc->bridge.pre_enable_prev_first = true;
-	drm_bridge_add(&tc->bridge);
 
-	i2c_set_clientdata(client, tc);
-
-	ret = tc_attach_host(tc);
+	ret = devm_drm_bridge_add(tc->dev, &tc->bridge);
 	if (ret)
-		goto err_bridge_remove;
-
-	return 0;
-
-err_bridge_remove:
-	drm_bridge_remove(&tc->bridge);
-	return ret;
-}
+		return ret;
 
-static void tc_remove(struct i2c_client *client)
-{
-	struct tc_data *tc = i2c_get_clientdata(client);
+	i2c_set_clientdata(client, tc);
 
-	drm_bridge_remove(&tc->bridge);
+	return tc_attach_host(tc);
 }
 
 static const struct i2c_device_id tc358775_i2c_ids[] = {
@@ -805,7 +793,6 @@ static struct i2c_driver tc358775_driver = {
 	},
 	.id_table = tc358775_i2c_ids,
 	.probe = tc_probe,
-	.remove	= tc_remove,
 };
 module_i2c_driver(tc358775_driver);
 

-- 
2.39.2



More information about the dri-devel mailing list