All of lore.kernel.org
 help / color / mirror / Atom feed
From: Jacek Anaszewski <j.anaszewski@samsung.com>
To: Fida Mohammad <fmthoker@gmail.com>
Cc: Bryan Wu <cooloney@gmail.com>, Richard Purdie <rpurdie@rpsys.net>,
	linux-leds@vger.kernel.org, LKML <linux-kernel@vger.kernel.org>,
	Muhammad Falak <falakreyaz@gmail.com>,
	Simon Guinot <sguinot@lacie.com>
Subject: Re: [PATCH] leds: leds-netxbig.c: Use devm_led_classdev_register
Date: Wed, 21 Oct 2015 09:01:00 +0200	[thread overview]
Message-ID: <5627382C.4040207@samsung.com> (raw)
In-Reply-To: <1445371592-24228-1-git-send-email-fmthoker@gmail.com>

Hi Fida,

On 10/20/2015 10:06 PM, Fida Mohammad wrote:
> Use resource managed function devm_led_classdev_register to make
> error path simpler. Consequently, removed a goto call and
> remove function made simpler.
>
> Signed-off-by: Fida Mohammad <fmthoker@gmail.com>
> ---
>   drivers/leds/leds-netxbig.c | 25 +++++--------------------
>   1 file changed, 5 insertions(+), 20 deletions(-)
>
> diff --git a/drivers/leds/leds-netxbig.c b/drivers/leds/leds-netxbig.c
> index 25e4197..639f8bd 100644
> --- a/drivers/leds/leds-netxbig.c
> +++ b/drivers/leds/leds-netxbig.c
> @@ -299,10 +299,6 @@ static struct attribute *netxbig_led_attrs[] = {
>   };
>   ATTRIBUTE_GROUPS(netxbig_led);
>
> -static void delete_netxbig_led(struct netxbig_led_data *led_dat)
> -{
> -	led_classdev_unregister(&led_dat->cdev);
> -}
>
>   static int
>   create_netxbig_led(struct platform_device *pdev,
> @@ -343,7 +339,7 @@ create_netxbig_led(struct platform_device *pdev,
>   	if (led_dat->mode_val[NETXBIG_LED_SATA] != NETXBIG_LED_INVALID_MODE)
>   		led_dat->cdev.groups = netxbig_led_groups;
>
> -	return led_classdev_register(&pdev->dev, &led_dat->cdev);
> +	return devm_led_classdev_register(&pdev->dev, &led_dat->cdev);
>   }
>
>   static int netxbig_led_probe(struct platform_device *pdev)
> @@ -367,32 +363,21 @@ static int netxbig_led_probe(struct platform_device *pdev)
>
>   	for (i = 0; i < pdata->num_leds; i++) {
>   		ret = create_netxbig_led(pdev, &leds_data[i], &pdata->leds[i]);
> -		if (ret < 0)
> -			goto err_free_leds;
> +		if (ret < 0) {
> +			gpio_ext_free(pdata->gpio_ext);
> +			return ret;
> +		}
>   	}
>
>   	platform_set_drvdata(pdev, leds_data);
>
>   	return 0;
>
> -err_free_leds:
> -	for (i = i - 1; i >= 0; i--)
> -		delete_netxbig_led(&leds_data[i]);
> -
> -	gpio_ext_free(pdata->gpio_ext);
> -	return ret;
>   }
>
>   static int netxbig_led_remove(struct platform_device *pdev)
>   {
>   	struct netxbig_led_platform_data *pdata = dev_get_platdata(&pdev->dev);
> -	struct netxbig_led_data *leds_data;
> -	int i;
> -
> -	leds_data = platform_get_drvdata(pdev);
> -
> -	for (i = 0; i < pdata->num_leds; i++)
> -		delete_netxbig_led(&leds_data[i]);
>
>   	gpio_ext_free(pdata->gpio_ext);
>
>

Thanks for the patch.

Always when submitting patches please cc also the author.
I know that this is a simple optimization, but nevertheless
an ack from the author, who can test the patch on the hardware,
is valuable. Cc Simon.
-- 
Best Regards,
Jacek Anaszewski

  reply	other threads:[~2015-10-21  7:01 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-10-20 20:06 [PATCH] leds: leds-netxbig.c: Use devm_led_classdev_register Fida Mohammad
2015-10-21  7:01 ` Jacek Anaszewski [this message]
2015-10-21  8:05   ` Simon Guinot
2015-10-21  8:25     ` Jacek Anaszewski

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=5627382C.4040207@samsung.com \
    --to=j.anaszewski@samsung.com \
    --cc=cooloney@gmail.com \
    --cc=falakreyaz@gmail.com \
    --cc=fmthoker@gmail.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-leds@vger.kernel.org \
    --cc=rpurdie@rpsys.net \
    --cc=sguinot@lacie.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 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.