linux-leds.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: "Rafał Miłecki" <zajec5@gmail.com>
To: Richard Purdie <rpurdie@rpsys.net>,
	Jacek Anaszewski <j.anaszewski@samsung.com>,
	Pavel Machek <pavel@ucw.cz>
Cc: linux-leds@vger.kernel.org, "Rafał Miłecki" <rafal@milecki.pl>
Subject: [PATCH 2/2] leds: gpio: set of_node before calling led_classdev_register
Date: Mon, 27 Feb 2017 23:23:00 +0100	[thread overview]
Message-ID: <20170227222300.2060-2-zajec5@gmail.com> (raw)
In-Reply-To: <20170227222300.2060-1-zajec5@gmail.com>

From: Rafał Miłecki <rafal@milecki.pl>

This allows core code to access DT info earlier, during LED registration
process. Thanks to this we will be able to support DT bindings in LEDs
core code.

Signed-off-by: Rafał Miłecki <rafal@milecki.pl>
---
 drivers/leds/leds-gpio.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/drivers/leds/leds-gpio.c b/drivers/leds/leds-gpio.c
index d400dcaf4d29..7bdce5df658b 100644
--- a/drivers/leds/leds-gpio.c
+++ b/drivers/leds/leds-gpio.c
@@ -172,7 +172,8 @@ static struct gpio_leds_priv *gpio_leds_create(struct platform_device *pdev)
 		struct gpio_led_data *led_dat = &priv->leds[priv->num_leds];
 		struct gpio_led led = {};
 		const char *state = NULL;
-		struct device_node *np = to_of_node(child);
+
+		led_dat->cdev.of_node = to_of_node(child);
 
 		led.gpiod = devm_get_gpiod_from_child(dev, NULL, child);
 		if (IS_ERR(led.gpiod)) {
@@ -181,8 +182,8 @@ static struct gpio_leds_priv *gpio_leds_create(struct platform_device *pdev)
 		}
 
 		ret = fwnode_property_read_string(child, "label", &led.name);
-		if (ret && IS_ENABLED(CONFIG_OF) && np)
-			led.name = np->name;
+		if (ret && IS_ENABLED(CONFIG_OF) && led_dat->cdev.of_node)
+			led.name = led_dat->cdev.of_node->name;
 		if (!led.name) {
 			fwnode_handle_put(child);
 			return ERR_PTR(-EINVAL);
@@ -211,7 +212,6 @@ static struct gpio_leds_priv *gpio_leds_create(struct platform_device *pdev)
 			fwnode_handle_put(child);
 			return ERR_PTR(ret);
 		}
-		led_dat->cdev.dev->of_node = np;
 		priv->num_leds++;
 	}
 
-- 
2.11.0

  reply	other threads:[~2017-02-27 22:56 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-02-27 22:22 [PATCH 1/2] leds: core: add struct device_node pointer to the struct led_classdev Rafał Miłecki
2017-02-27 22:23 ` Rafał Miłecki [this message]
2017-02-27 22:27 ` Rafał Miłecki
2017-02-28 21:20 ` Jacek Anaszewski
2017-03-02 17:42   ` Rafał Miłecki
2017-03-02 20:29     ` Jacek Anaszewski
2017-03-02 22:45       ` Rafał Miłecki
2017-03-03 22:20         ` 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=20170227222300.2060-2-zajec5@gmail.com \
    --to=zajec5@gmail.com \
    --cc=j.anaszewski@samsung.com \
    --cc=linux-leds@vger.kernel.org \
    --cc=pavel@ucw.cz \
    --cc=rafal@milecki.pl \
    --cc=rpurdie@rpsys.net \
    /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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).