dri-devel.lists.freedesktop.org archive mirror
 help / color / mirror / Atom feed
From: Robert Foss <robert.foss@linaro.org>
To: Tian Tao <tiantao6@hisilicon.com>
Cc: Neil Armstrong <narmstrong@baylibre.com>,
	David Airlie <airlied@linux.ie>,
	dri-devel <dri-devel@lists.freedesktop.org>,
	Yicong Yang <yangyicong@hisilicon.com>,
	Andrzej Hajda <a.hajda@samsung.com>
Subject: Re: [PATCH] drm/bridge: simplify devm_drm_panel_bridge_add_typed
Date: Wed, 28 Apr 2021 18:19:47 +0200	[thread overview]
Message-ID: <CAG3jFysa2yzGnVKaPYfn9_XOpqzoYPa2HM3Y9ChDQWQoAFko8w@mail.gmail.com> (raw)
In-Reply-To: <1617847624-53611-1-git-send-email-tiantao6@hisilicon.com>


[-- Attachment #1.1: Type: text/plain, Size: 2387 bytes --]

Hey Tian,

Thanks for having a look at cleanup patches.

On Thu, 8 Apr 2021 at 04:06, Tian Tao <tiantao6@hisilicon.com> 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@hisilicon.com>
> Signed-off-by: Yicong Yang <yangyicong@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;
>  }
>
>
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.

[-- Attachment #1.2: Type: text/html, Size: 3292 bytes --]

[-- Attachment #2: Type: text/plain, Size: 160 bytes --]

_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

      reply	other threads:[~2021-04-28 16:20 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-04-08  2:07 [PATCH] drm/bridge: simplify devm_drm_panel_bridge_add_typed Tian Tao
2021-04-28 16:19 ` Robert Foss [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=CAG3jFysa2yzGnVKaPYfn9_XOpqzoYPa2HM3Y9ChDQWQoAFko8w@mail.gmail.com \
    --to=robert.foss@linaro.org \
    --cc=a.hajda@samsung.com \
    --cc=airlied@linux.ie \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=narmstrong@baylibre.com \
    --cc=tiantao6@hisilicon.com \
    --cc=yangyicong@hisilicon.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).