085-0003-leds-gpio-switch-to-managed-version-of-led_classdev_.patch 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  1. From bc2c0dd85a0a31505ca2f92bef891ddac9126725 Mon Sep 17 00:00:00 2001
  2. From: Heiner Kallweit <hkallweit1@gmail.com>
  3. Date: Wed, 14 Sep 2016 20:55:27 +0200
  4. Subject: [PATCH] leds: gpio: switch to managed version of
  5. led_classdev_register
  6. Using the managed version of led_classdev_register allows to
  7. significantly simplify the code.
  8. Signed-off-by: Heiner Kallweit <hkallweit1@gmail.com>
  9. Signed-off-by: Jacek Anaszewski <j.anaszewski@samsung.com>
  10. ---
  11. drivers/leds/leds-gpio.c | 23 ++---------------------
  12. 1 file changed, 2 insertions(+), 21 deletions(-)
  13. --- a/drivers/leds/leds-gpio.c
  14. +++ b/drivers/leds/leds-gpio.c
  15. @@ -143,7 +143,7 @@ static int create_gpio_led(const struct
  16. INIT_WORK(&led_dat->work, gpio_led_work);
  17. - return led_classdev_register(parent, &led_dat->cdev);
  18. + return devm_led_classdev_register(parent, &led_dat->cdev);
  19. }
  20. static void delete_gpio_led(struct gpio_led_data *led)
  21. @@ -231,8 +231,6 @@ static struct gpio_leds_priv *gpio_leds_
  22. return priv;
  23. err:
  24. - for (count = priv->num_leds - 1; count >= 0; count--)
  25. - delete_gpio_led(&priv->leds[count]);
  26. return ERR_PTR(ret);
  27. }
  28. @@ -261,12 +259,8 @@ static int gpio_led_probe(struct platfor
  29. ret = create_gpio_led(&pdata->leds[i],
  30. &priv->leds[i],
  31. &pdev->dev, pdata->gpio_blink_set);
  32. - if (ret < 0) {
  33. - /* On failure: unwind the led creations */
  34. - for (i = i - 1; i >= 0; i--)
  35. - delete_gpio_led(&priv->leds[i]);
  36. + if (ret < 0)
  37. return ret;
  38. - }
  39. }
  40. } else {
  41. priv = gpio_leds_create(pdev);
  42. @@ -279,17 +273,6 @@ static int gpio_led_probe(struct platfor
  43. return 0;
  44. }
  45. -static int gpio_led_remove(struct platform_device *pdev)
  46. -{
  47. - struct gpio_leds_priv *priv = platform_get_drvdata(pdev);
  48. - int i;
  49. -
  50. - for (i = 0; i < priv->num_leds; i++)
  51. - delete_gpio_led(&priv->leds[i]);
  52. -
  53. - return 0;
  54. -}
  55. -
  56. static void gpio_led_shutdown(struct platform_device *pdev)
  57. {
  58. struct gpio_leds_priv *priv = platform_get_drvdata(pdev);
  59. @@ -304,7 +287,6 @@ static void gpio_led_shutdown(struct pla
  60. static struct platform_driver gpio_led_driver = {
  61. .probe = gpio_led_probe,
  62. - .remove = gpio_led_remove,
  63. .shutdown = gpio_led_shutdown,
  64. .driver = {
  65. .name = "leds-gpio",