linux-gpio.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Christophe Leroy <christophe.leroy@c-s.fr>
To: Linus Walleij <linus.walleij@linaro.org>,
	Mika Westerberg <mika.westerberg@linux.intel.com>
Cc: linux-kernel@vger.kernel.org, linux-gpio@vger.kernel.org,
	stable@vger.kernel.org
Subject: [PATCH] gpio: fix "gpio-line-names" property retrieval
Date: Fri, 15 Dec 2017 09:09:15 +0100 (CET)	[thread overview]
Message-ID: <20171215080915.DDA106C974@localhost.localdomain> (raw)

Following commit 9427ecbed46cc ("gpio: Rework of_gpiochip_set_names()
to use device property accessors"), "gpio-line-names" DT property is
not retrieved anymore when chip->parent is not set by the driver.

This patch fixes that.

Fixes: 9427ecbed46cc ("gpio: Rework of_gpiochip_set_names()
to use device property accessors")
Cc: stable@vger.kernel.org
Signed-off-by: Christophe Leroy <christophe.leroy@c-s.fr>
---
 drivers/gpio/gpiolib-devprop.c | 16 ++++++++++------
 1 file changed, 10 insertions(+), 6 deletions(-)

diff --git a/drivers/gpio/gpiolib-devprop.c b/drivers/gpio/gpiolib-devprop.c
index 27f383bda7d9..310dbc451a85 100644
--- a/drivers/gpio/gpiolib-devprop.c
+++ b/drivers/gpio/gpiolib-devprop.c
@@ -30,20 +30,24 @@ void devprop_gpiochip_set_names(struct gpio_chip *chip)
 	struct gpio_device *gdev = chip->gpiodev;
 	const char **names;
 	int ret, i;
+	struct device *dev;
 
-	if (!chip->parent) {
+	if (chip->parent) {
+		dev = chip->parent;
+	} else if (gdev->dev.of_node) {
+		dev = &gdev->dev;
+	} else {
 		dev_warn(&gdev->dev, "GPIO chip parent is NULL\n");
 		return;
 	}
 
-	ret = device_property_read_string_array(chip->parent, "gpio-line-names",
+	ret = device_property_read_string_array(dev, "gpio-line-names",
 						NULL, 0);
 	if (ret < 0)
 		return;
 
 	if (ret != gdev->ngpio) {
-		dev_warn(chip->parent,
-			 "names %d do not match number of GPIOs %d\n", ret,
+		dev_warn(dev, "names %d do not match number of GPIOs %d\n", ret,
 			 gdev->ngpio);
 		return;
 	}
@@ -52,10 +56,10 @@ void devprop_gpiochip_set_names(struct gpio_chip *chip)
 	if (!names)
 		return;
 
-	ret = device_property_read_string_array(chip->parent, "gpio-line-names",
+	ret = device_property_read_string_array(dev, "gpio-line-names",
 						names, gdev->ngpio);
 	if (ret < 0) {
-		dev_warn(chip->parent, "failed to read GPIO line names\n");
+		dev_warn(dev, "failed to read GPIO line names\n");
 		kfree(names);
 		return;
 	}
-- 
2.13.3

             reply	other threads:[~2017-12-15  8:09 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-12-15  8:09 Christophe Leroy [this message]
2017-12-15  9:44 ` [PATCH] gpio: fix "gpio-line-names" property retrieval Mika Westerberg

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=20171215080915.DDA106C974@localhost.localdomain \
    --to=christophe.leroy@c-s.fr \
    --cc=linus.walleij@linaro.org \
    --cc=linux-gpio@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mika.westerberg@linux.intel.com \
    --cc=stable@vger.kernel.org \
    /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).