Hey Tian,
Thanks for having a look at cleanup patches.
On Thu, 8 Apr 2021 at 04:06, Tian Tao <tiantao6@xxxxxxxxxxxxx> wrote:
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@xxxxxxxxxxxxx>
Signed-off-by: Yicong Yang <yangyicong@xxxxxxxxxxxxx>
---
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;
}
I'm not crazy about this change. In my mind it is harder to read & understand than the current solution. If anyone else feels otherwise, I'm open to have my mind changed.
Rob.
_______________________________________________ dri-devel mailing list dri-devel@xxxxxxxxxxxxxxxxxxxxx https://lists.freedesktop.org/mailman/listinfo/dri-devel