[PATCH] drm/bridge: simplify devm_drm_panel_bridge_add_typed
Tian Tao
tiantao6 at hisilicon.com
Thu Apr 8 02:07:04 UTC 2021
Use devm_add_action_or_reset() instead of devres_alloc() and
devres_add(), which works the same. This will simplify the
code. There is no functional changes.
Signed-off-by: Tian Tao <tiantao6 at hisilicon.com>
Signed-off-by: Yicong Yang <yangyicong at hisilicon.com>
---
drivers/gpu/drm/bridge/panel.c | 27 +++++++++++----------------
1 file changed, 11 insertions(+), 16 deletions(-)
diff --git a/drivers/gpu/drm/bridge/panel.c b/drivers/gpu/drm/bridge/panel.c
index c916f4b..e5ddefb 100644
--- a/drivers/gpu/drm/bridge/panel.c
+++ b/drivers/gpu/drm/bridge/panel.c
@@ -250,11 +250,9 @@ void drm_panel_bridge_remove(struct drm_bridge *bridge)
}
EXPORT_SYMBOL(drm_panel_bridge_remove);
-static void devm_drm_panel_bridge_release(struct device *dev, void *res)
+static void devm_drm_panel_bridge_release(void *bridge)
{
- struct drm_bridge **bridge = res;
-
- drm_panel_bridge_remove(*bridge);
+ drm_panel_bridge_remove(bridge);
}
/**
@@ -295,20 +293,17 @@ struct drm_bridge *devm_drm_panel_bridge_add_typed(struct device *dev,
struct drm_panel *panel,
u32 connector_type)
{
- struct drm_bridge **ptr, *bridge;
-
- ptr = devres_alloc(devm_drm_panel_bridge_release, sizeof(*ptr),
- GFP_KERNEL);
- if (!ptr)
- return ERR_PTR(-ENOMEM);
+ struct drm_bridge *bridge;
+ int ret;
bridge = drm_panel_bridge_add_typed(panel, connector_type);
- if (!IS_ERR(bridge)) {
- *ptr = bridge;
- devres_add(dev, ptr);
- } else {
- devres_free(ptr);
- }
+ if (IS_ERR(bridge))
+ return bridge;
+
+ ret = devm_add_action_or_reset(dev, devm_drm_panel_bridge_release,
+ bridge);
+ if (ret)
+ return ERR_PTR(ret);
return bridge;
}
--
2.7.4
More information about the dri-devel
mailing list