leds: leds-fsg: Use devm_led_classdev_register
authorVaishali Thakkar <vthakkar1994@gmail.com>
Tue, 18 Aug 2015 14:20:16 +0000 (19:50 +0530)
committerJacek Anaszewski <j.anaszewski@samsung.com>
Fri, 28 Aug 2015 12:06:23 +0000 (14:06 +0200)
Use resource-managed function devm_led_classdev_register instead
of led_classdev_register to make the error-path simpler.

To be compatible with the change, various gotos are replaced with
direct returns and unneeded labels are dropped. Also, remove
fsg_led_remove as it is now redundant.

Signed-off-by: Vaishali Thakkar <vthakkar1994@gmail.com>
Signed-off-by: Jacek Anaszewski <j.anaszewski@samsung.com>
drivers/leds/leds-fsg.c

index 2b4dc738dcd657092176822fc2613349e8066246..257a813c73f31ddf6b336a82895e7ca65fe7974d 100644 (file)
@@ -156,63 +156,35 @@ static int fsg_led_probe(struct platform_device *pdev)
        latch_value = 0xffff;
        *latch_address = latch_value;
 
-       ret = led_classdev_register(&pdev->dev, &fsg_wlan_led);
+       ret = devm_led_classdev_register(&pdev->dev, &fsg_wlan_led);
        if (ret < 0)
-               goto failwlan;
+               return ret;
 
-       ret = led_classdev_register(&pdev->dev, &fsg_wan_led);
+       ret = devm_led_classdev_register(&pdev->dev, &fsg_wan_led);
        if (ret < 0)
-               goto failwan;
+               return ret;
 
-       ret = led_classdev_register(&pdev->dev, &fsg_sata_led);
+       ret = devm_led_classdev_register(&pdev->dev, &fsg_sata_led);
        if (ret < 0)
-               goto failsata;
+               return ret;
 
-       ret = led_classdev_register(&pdev->dev, &fsg_usb_led);
+       ret = devm_led_classdev_register(&pdev->dev, &fsg_usb_led);
        if (ret < 0)
-               goto failusb;
+               return ret;
 
-       ret = led_classdev_register(&pdev->dev, &fsg_sync_led);
+       ret = devm_led_classdev_register(&pdev->dev, &fsg_sync_led);
        if (ret < 0)
-               goto failsync;
+               return ret;
 
-       ret = led_classdev_register(&pdev->dev, &fsg_ring_led);
+       ret = devm_led_classdev_register(&pdev->dev, &fsg_ring_led);
        if (ret < 0)
-               goto failring;
-
-       return ret;
-
- failring:
-       led_classdev_unregister(&fsg_sync_led);
- failsync:
-       led_classdev_unregister(&fsg_usb_led);
- failusb:
-       led_classdev_unregister(&fsg_sata_led);
- failsata:
-       led_classdev_unregister(&fsg_wan_led);
- failwan:
-       led_classdev_unregister(&fsg_wlan_led);
- failwlan:
+               return ret;
 
        return ret;
 }
 
-static int fsg_led_remove(struct platform_device *pdev)
-{
-       led_classdev_unregister(&fsg_wlan_led);
-       led_classdev_unregister(&fsg_wan_led);
-       led_classdev_unregister(&fsg_sata_led);
-       led_classdev_unregister(&fsg_usb_led);
-       led_classdev_unregister(&fsg_sync_led);
-       led_classdev_unregister(&fsg_ring_led);
-
-       return 0;
-}
-
-
 static struct platform_driver fsg_led_driver = {
        .probe          = fsg_led_probe,
-       .remove         = fsg_led_remove,
        .driver         = {
                .name           = "fsg-led",
        },