mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Ayush Singh <ayushdevel1325@gmail.com>
To: Bartosz Golaszewski <brgl@bgdev.pl>,
	Johan Hovold <johan@kernel.org>, Alex Elder <elder@kernel.org>,
	Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Cc: greybus-dev@lists.linaro.org, linux-kernel@vger.kernel.org,
	Bartosz Golaszewski <bartosz.golaszewski@linaro.org>
Subject: Re: [PATCH] greybus: gb-beagleplay: remove unneeded calls to devm_gpiod_put()
Date: Tue, 24 Jun 2025 00:28:17 +0530	[thread overview]
Message-ID: <85286090-e8da-4189-ad07-84876e0cf283@gmail.com> (raw)
In-Reply-To: <20250618082000.36039-1-brgl@bgdev.pl>

On 6/18/25 13:50, Bartosz Golaszewski wrote:

> From: Bartosz Golaszewski <bartosz.golaszewski@linaro.org>
>
> gb_fw_init() is only called in this driver's probe() and we abort the
> probing if it fails. This means that calling devm_gpiod_put() in error
> path is not required as devres will already manage the releasing of the
> resources when the device is detached.
>
> Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@linaro.org>
> ---
>   drivers/greybus/gb-beagleplay.c | 21 ++++-----------------
>   1 file changed, 4 insertions(+), 17 deletions(-)
>
> diff --git a/drivers/greybus/gb-beagleplay.c b/drivers/greybus/gb-beagleplay.c
> index da31f1131afc..1ea48b71a030 100644
> --- a/drivers/greybus/gb-beagleplay.c
> +++ b/drivers/greybus/gb-beagleplay.c
> @@ -1041,7 +1041,6 @@ static const struct fw_upload_ops cc1352_bootloader_ops = {
>   
>   static int gb_fw_init(struct gb_beagleplay *bg)
>   {
> -	int ret;
>   	struct fw_upload *fwl;
>   	struct gpio_desc *desc;
>   
> @@ -1060,29 +1059,17 @@ static int gb_fw_init(struct gb_beagleplay *bg)
>   	bg->bootloader_backdoor_gpio = desc;
>   
>   	desc = devm_gpiod_get(&bg->sd->dev, "reset", GPIOD_IN);
> -	if (IS_ERR(desc)) {
> -		ret = PTR_ERR(desc);
> -		goto free_boot;
> -	}
> +	if (IS_ERR(desc))
> +		return PTR_ERR(desc);
>   	bg->rst_gpio = desc;
>   
>   	fwl = firmware_upload_register(THIS_MODULE, &bg->sd->dev, "cc1352p7",
>   				       &cc1352_bootloader_ops, bg);
> -	if (IS_ERR(fwl)) {
> -		ret = PTR_ERR(fwl);
> -		goto free_reset;
> -	}
> +	if (IS_ERR(fwl))
> +		return PTR_ERR(fwl);
>   	bg->fwl = fwl;
>   
>   	return 0;
> -
> -free_reset:
> -	devm_gpiod_put(&bg->sd->dev, bg->rst_gpio);
> -	bg->rst_gpio = NULL;
> -free_boot:
> -	devm_gpiod_put(&bg->sd->dev, bg->bootloader_backdoor_gpio);
> -	bg->bootloader_backdoor_gpio = NULL;
> -	return ret;
>   }
>   
>   static void gb_fw_deinit(struct gb_beagleplay *bg)


Can you add a comment above the function that it should only ever be 
called from probing code since it does not free up the resources? I 
might end up forgetting and using it improperly in the future.


Best Regards,

Ayush Singh


      reply	other threads:[~2025-06-23 18:58 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-06-18  8:20 Bartosz Golaszewski
2025-06-23 18:58 ` Ayush Singh [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=85286090-e8da-4189-ad07-84876e0cf283@gmail.com \
    --to=ayushdevel1325@gmail.com \
    --cc=bartosz.golaszewski@linaro.org \
    --cc=brgl@bgdev.pl \
    --cc=elder@kernel.org \
    --cc=gregkh@linuxfoundation.org \
    --cc=greybus-dev@lists.linaro.org \
    --cc=johan@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    /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

all inboxes | Powered by JetHome®