linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Sven Van Asbroeck <thesven73@gmail.com>
To: Tian Tao <tiantao6@hisilicon.com>
Cc: Greg KH <gregkh@linuxfoundation.org>,
	linux-staging@lists.linux.dev,
	Linux Kernel Mailing List <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH] staging: fieldbus: simplify devm_anybuss_host_common_probe
Date: Fri, 9 Apr 2021 07:58:59 -0400	[thread overview]
Message-ID: <CAGngYiVfattJKO7npMHTagxNfzU-B=rP3FoZ89_yzy-c=Zw2RQ@mail.gmail.com> (raw)
In-Reply-To: <1617957240-53633-1-git-send-email-tiantao6@hisilicon.com>

Hello Tian, thank you for the contribution. See below.

On Fri, Apr 9, 2021 at 4:33 AM 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>
> ---
>  drivers/staging/fieldbus/anybuss/host.c | 20 ++++++++------------
>  1 file changed, 8 insertions(+), 12 deletions(-)
>
> diff --git a/drivers/staging/fieldbus/anybuss/host.c b/drivers/staging/fieldbus/anybuss/host.c
> index 549cb7d5..2924e68 100644
> --- a/drivers/staging/fieldbus/anybuss/host.c
> +++ b/drivers/staging/fieldbus/anybuss/host.c
> @@ -1406,7 +1406,7 @@ void anybuss_host_common_remove(struct anybuss_host *host)
>  }
>  EXPORT_SYMBOL_GPL(anybuss_host_common_remove);
>
> -static void host_release(struct device *dev, void *res)
> +static void host_release(void *res)
>  {
>         struct anybuss_host **dr = res;

You're expecting a double pointer as the argument here...

>
> @@ -1417,21 +1417,17 @@ struct anybuss_host * __must_check
>  devm_anybuss_host_common_probe(struct device *dev,
>                                const struct anybuss_ops *ops)
>  {
> -       struct anybuss_host **dr;
>         struct anybuss_host *host;
> -
> -       dr = devres_alloc(host_release, sizeof(struct anybuss_host *),
> -                         GFP_KERNEL);
> -       if (!dr)
> -               return ERR_PTR(-ENOMEM);
> +       int ret;
>
>         host = anybuss_host_common_probe(dev, ops);
> -       if (IS_ERR(host)) {
> -               devres_free(dr);
> +       if (IS_ERR(host))
>                 return host;
> -       }
> -       *dr = host;
> -       devres_add(dev, dr);
> +
> +       ret = devm_add_action_or_reset(dev, host_release, host);

... yet you pass in a single pointer here. Is that going to work?

> +       if (ret)
> +               return ERR_PTR(ret);
> +
>         return host;
>  }
>  EXPORT_SYMBOL_GPL(devm_anybuss_host_common_probe);
> --
> 2.7.4
>

       reply	other threads:[~2021-04-09 11:59 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <1617957240-53633-1-git-send-email-tiantao6@hisilicon.com>
2021-04-09 11:58 ` Sven Van Asbroeck [this message]
2021-04-12  1:14   ` [PATCH] staging: fieldbus: simplify devm_anybuss_host_common_probe tiantao (H)
2021-04-12 12:40     ` Sven Van Asbroeck
2021-04-12 13:05       ` tiantao (H)

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='CAGngYiVfattJKO7npMHTagxNfzU-B=rP3FoZ89_yzy-c=Zw2RQ@mail.gmail.com' \
    --to=thesven73@gmail.com \
    --cc=gregkh@linuxfoundation.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-staging@lists.linux.dev \
    --cc=tiantao6@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).