2
0

085-0001-leds-leds-gpio-Set-of_node-for-created-LED-devices.patch 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. From bff23714bc36a1322d0f14519022df0d1a4b21f3 Mon Sep 17 00:00:00 2001
  2. From: =?UTF-8?q?Rafa=C5=82=20Mi=C5=82ecki?= <zajec5@gmail.com>
  3. Date: Fri, 8 Jul 2016 14:53:38 +0200
  4. Subject: [PATCH] leds: leds-gpio: Set of_node for created LED devices
  5. MIME-Version: 1.0
  6. Content-Type: text/plain; charset=UTF-8
  7. Content-Transfer-Encoding: 8bit
  8. When working with Device Tree we iterate over children of "gpio-leds"
  9. compatible node and create LED device for each of them. We take care of
  10. all common DT properties (label, default trigger, state, etc.), however
  11. some triggers may want to support more of them.
  12. It could be useful for timer trigger to support setting delay on/off
  13. values with Device Tree property. Or for transient trigger to support
  14. e.g. duration property.
  15. We obviously should handle such properties in triggers, not in generic
  16. code. To let trigger drivers read properties from DT node we need to set
  17. of_node to point the relevant node. This change allows using all kind of
  18. of helpers in e.g. "activate" callbacks.
  19. Signed-off-by: Rafał Miłecki <zajec5@gmail.com>
  20. Signed-off-by: Jacek Anaszewski <j.anaszewski@samsung.com>
  21. ---
  22. drivers/leds/leds-gpio.c | 5 +++--
  23. 1 file changed, 3 insertions(+), 2 deletions(-)
  24. --- a/drivers/leds/leds-gpio.c
  25. +++ b/drivers/leds/leds-gpio.c
  26. @@ -182,6 +182,7 @@ static struct gpio_leds_priv *gpio_leds_
  27. return ERR_PTR(-ENOMEM);
  28. device_for_each_child_node(dev, child) {
  29. + struct gpio_led_data *led_dat = &priv->leds[priv->num_leds];
  30. struct gpio_led led = {};
  31. const char *state = NULL;
  32. @@ -220,12 +221,12 @@ static struct gpio_leds_priv *gpio_leds_
  33. if (fwnode_property_present(child, "retain-state-suspended"))
  34. led.retain_state_suspended = 1;
  35. - ret = create_gpio_led(&led, &priv->leds[priv->num_leds],
  36. - dev, NULL);
  37. + ret = create_gpio_led(&led, led_dat, dev, NULL);
  38. if (ret < 0) {
  39. fwnode_handle_put(child);
  40. goto err;
  41. }
  42. + led_dat->cdev.dev->of_node = np;
  43. priv->num_leds++;
  44. }