All the mail mirrored from lore.kernel.org
 help / color / mirror / Atom feed
From: Dmitry Baryshkov <dmitry.baryshkov@linaro.org>
To: R SUNDAR <prosunofficial@gmail.com>
Cc: heikki.krogerus@linux.intel.com, gregkh@linuxfoundation.org,
	 neil.armstrong@linaro.org, christophe.jaillet@wanadoo.fr,
	 u.kleine-koenig@pengutronix.de, skhan@linuxfoundation.org,
	 javier.carrasco.cruz@gmail.com, linux-usb@vger.kernel.org,
	 linux-kernel@vger.kernel.org,
	Julia Lawall <julia.lawall@inria.fr>
Subject: Re: [PATCH] usb: typec: mux: replace of_node_put() with __free [linux-next]
Date: Wed, 10 Apr 2024 20:13:24 +0300	[thread overview]
Message-ID: <CAA8EJppfzXEzzrQ_11O94MVn2dhcF2kGd9RR8ctJ1GmK=6C+ZQ@mail.gmail.com> (raw)
In-Reply-To: <20240410165222.5192-1-prosunofficial@gmail.com>

On Wed, 10 Apr 2024 at 19:52, R SUNDAR <prosunofficial@gmail.com> wrote:
>
> use the new cleanup magic to replace of_node_put() with
> __free(device_node) marking to auto release and to simplify the error
> paths.
>
> Suggested-by: Julia Lawall <julia.lawall@inria.fr>
> Signed-off-by: R SUNDAR <prosunofficial@gmail.com>
> ---
>  drivers/usb/typec/mux/nb7vpq904m.c | 25 ++++++++-----------------
>  1 file changed, 8 insertions(+), 17 deletions(-)
>
> diff --git a/drivers/usb/typec/mux/nb7vpq904m.c b/drivers/usb/typec/mux/nb7vpq904m.c
> index b17826713753..72ec9ef3ac58 100644
> --- a/drivers/usb/typec/mux/nb7vpq904m.c
> +++ b/drivers/usb/typec/mux/nb7vpq904m.c
> @@ -315,29 +315,27 @@ static const int supported_data_lane_mapping[][DATA_LANES_COUNT] = {
>
>  static int nb7vpq904m_parse_data_lanes_mapping(struct nb7vpq904m *nb7)
>  {
> -       struct device_node *ep;
>         u32 data_lanes[4];
>         int ret, i, j;
> -
> -       ep = of_graph_get_endpoint_by_regs(nb7->client->dev.of_node, 1, 0);
> +       struct device_node *ep __free(device_node) =
> +               of_graph_get_endpoint_by_regs(nb7->client->dev.of_node, 1, 0);

Please stick this to the top of the function. Otherwise LGTM.

>
>         if (ep) {
>                 ret = of_property_count_u32_elems(ep, "data-lanes");
>                 if (ret == -EINVAL)
>                         /* Property isn't here, consider default mapping */
> -                       goto out_done;
> +                       return 0;
>                 if (ret < 0)
> -                       goto out_error;
> +                       return ret;
>
>                 if (ret != DATA_LANES_COUNT) {
>                         dev_err(&nb7->client->dev, "expected 4 data lanes\n");
> -                       ret = -EINVAL;
> -                       goto out_error;
> +                       return -EINVAL;
>                 }
>
>                 ret = of_property_read_u32_array(ep, "data-lanes", data_lanes, DATA_LANES_COUNT);
>                 if (ret)
> -                       goto out_error;
> +                       return ret;
>
>                 for (i = 0; i < ARRAY_SIZE(supported_data_lane_mapping); i++) {
>                         for (j = 0; j < DATA_LANES_COUNT; j++) {
> @@ -358,18 +356,11 @@ static int nb7vpq904m_parse_data_lanes_mapping(struct nb7vpq904m *nb7)
>                         break;
>                 default:
>                         dev_err(&nb7->client->dev, "invalid data lanes mapping\n");
> -                       ret = -EINVAL;
> -                       goto out_error;
> +                       return -EINVAL;
>                 }
>         }
>
> -out_done:
> -       ret = 0;
> -
> -out_error:
> -       of_node_put(ep);
> -
> -       return ret;
> +       return 0;
>  }
>
>  static int nb7vpq904m_probe(struct i2c_client *client)
> --
> 2.34.1
>


-- 
With best wishes
Dmitry

  reply	other threads:[~2024-04-10 17:13 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-04-10 16:52 [PATCH] usb: typec: mux: replace of_node_put() with __free [linux-next] R SUNDAR
2024-04-10 17:13 ` Dmitry Baryshkov [this message]
2024-04-11 12:17 ` Greg KH
2024-04-12  3:47   ` sundar.R

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='CAA8EJppfzXEzzrQ_11O94MVn2dhcF2kGd9RR8ctJ1GmK=6C+ZQ@mail.gmail.com' \
    --to=dmitry.baryshkov@linaro.org \
    --cc=christophe.jaillet@wanadoo.fr \
    --cc=gregkh@linuxfoundation.org \
    --cc=heikki.krogerus@linux.intel.com \
    --cc=javier.carrasco.cruz@gmail.com \
    --cc=julia.lawall@inria.fr \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-usb@vger.kernel.org \
    --cc=neil.armstrong@linaro.org \
    --cc=prosunofficial@gmail.com \
    --cc=skhan@linuxfoundation.org \
    --cc=u.kleine-koenig@pengutronix.de \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.