leds: leds-netxbig.c: Use devm_led_classdev_register
PATCH 1/1 leds: leds-netxbig.c: Use devm_led_classdev_register
Use resource managed function devm_led_classdev_register to make error path simpler. Consequently, removed a goto call and remove function made simpler.
--- drivers/leds/leds-netxbig.c | 25 +++++-------------------- 1 file changed, 5 insertions(+), 20 deletions(-)
drivers/leds/leds-netxbig.c +5 -20
@@ -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);
Signature · 1 line
1.9.1
Hi Fida,
Quoted 61 lines · Fida Mohammad
Use resource managed function
devm_led_classdev_registerto make error path simpler. Consequently, removed a goto call and remove function made simpler.Signed-off-by Fida Mohammad <[email protected]>--- drivers/leds/leds-netxbig.c | 25 +++++-------------------- 1 file changed, 5 insertions(+), 20 deletions(-)drivers/leds/leds-netxbig.c +5
-13@@ -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);
drivers/leds/leds-netxbig.c static int netxbig_led_probe(struct platform_device *pdev) · line 383
Quoted 10 lines
drivers/leds/leds-netxbig.c +0
-7-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.
Signature · 2 lines
Best Regards, Jacek Anaszewski
Quoted 77 lines · Jacek Anaszewski
Hi Fida,
Quoted 61 lines · Fida Mohammad
Use resource managed function
devm_led_classdev_registerto make error path simpler. Consequently, removed a goto call and remove function made simpler.Signed-off-by Fida Mohammad <[email protected]>--- drivers/leds/leds-netxbig.c | 25 +++++-------------------- 1 file changed, 5 insertions(+), 20 deletions(-)drivers/leds/leds-netxbig.c +5
-13@@ -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);drivers/leds/leds-netxbig.c static int netxbig_led_probe(struct platform_device *pdev) · line 383
Quoted 10 lines
drivers/leds/leds-netxbig.c +0
-7-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.
Quoted 4 lines
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.
Hi Fida and Jacek,
An extended version of this patch (with also the devm_gpio_ conversion) is already sitting in the LED's for-next branch.
deae3c1895c234e17dafea57b0d4ce4d5da16559
leds: netxbig: convert to use the devm_ functions
Thanks,
Simon
Quoted 83 lines · Simon Guinot
Quoted 77 lines · Jacek Anaszewski
Hi Fida,
Quoted 61 lines · Fida Mohammad
Use resource managed function
devm_led_classdev_registerto make error path simpler. Consequently, removed a goto call and remove function made simpler.Signed-off-by Fida Mohammad <[email protected]>--- drivers/leds/leds-netxbig.c | 25 +++++-------------------- 1 file changed, 5 insertions(+), 20 deletions(-)drivers/leds/leds-netxbig.c +5
-13@@ -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);drivers/leds/leds-netxbig.c static int netxbig_led_probe(struct platform_device *pdev) · line 383
Quoted 10 lines
drivers/leds/leds-netxbig.c +0
-7-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.
Quoted 4 lines
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.
Quoted 7 lines
Hi Fida and Jacek,
An extended version of this patch (with also the
devm_gpio_conversion) is already sitting in the LED's for-next branch.
deae3c1895c234e17dafea57b0d4ce4d5da16559
leds: netxbig: convert to use thedevm_functions
Hi Simon, Fida,
Indeed. Fida - please use LED tree as a reference for your patches.
git://git.kernel.org/pub/scm/linux/kernel/git/j.anaszewski/linux-leds.git
Signature · 2 lines
Best Regards, Jacek Anaszewski