[PATCH 3/4] of/gpio: Support gpio-line-names property

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



GPIOs can be given names with the gpio-line-names device tree property.
This patch adds support for it.

Signed-off-by: Sascha Hauer <s.hauer@xxxxxxxxxxxxxx>
---
 drivers/gpio/gpiolib.c | 16 +++++++++++++++-
 1 file changed, 15 insertions(+), 1 deletion(-)

diff --git a/drivers/gpio/gpiolib.c b/drivers/gpio/gpiolib.c
index 057cea43cc..9764ddf0f0 100644
--- a/drivers/gpio/gpiolib.c
+++ b/drivers/gpio/gpiolib.c
@@ -428,11 +428,25 @@ static int of_hog_gpio(struct device_node *np, struct gpio_chip *chip,
 static int of_gpiochip_scan_hogs(struct gpio_chip *chip)
 {
 	struct device_node *np;
-	int ret, i;
+	int ret, i, count;
 
 	if (!IS_ENABLED(CONFIG_OFDEVICE) || !chip->dev->device_node)
 		return 0;
 
+	count = of_property_count_strings(chip->dev->device_node, "gpio-line-names");
+
+	if (count > 0) {
+		const char **arr = xzalloc(count * sizeof(char *));
+
+		of_property_read_string_array(chip->dev->device_node,
+					      "gpio-line-names", arr, count);
+
+		for (i = 0; i < chip->ngpio && i < count; i++)
+			gpio_desc[chip->base + i].name = xstrdup(arr[i]);
+
+		free(arr);
+	}
+
 	for_each_available_child_of_node(chip->dev->device_node, np) {
 		if (!of_property_read_bool(np, "gpio-hog"))
 			continue;
-- 
2.24.0


_______________________________________________
barebox mailing list
barebox@xxxxxxxxxxxxxxxxxxx
http://lists.infradead.org/mailman/listinfo/barebox



[Index of Archives]     [Linux Embedded]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]     [XFree86]

  Powered by Linux