aboutsummaryrefslogtreecommitdiffstats
path: root/target/linux/bcm27xx/patches-5.4/950-0427-of-overlay-Correct-symbol-path-fixups.patch
blob: 4b005876de13210ca10513be656432e980c2ca36 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
From 8f22c4228bbb91697ab3510f5a6176e530c0d639 Mon Sep 17 00:00:00 2001
From: Phil Elwell <phil@raspberrypi.com>
Date: Thu, 6 Feb 2020 12:23:15 +0000
Subject: [PATCH] of: overlay: Correct symbol path fixups

When symbols from overlays are added to the live tree their paths must
be rebased. The translated symbol is normally the result of joining
the fragment-relative path (with a leading "/") to the target path
(either copied directly from the "target-path" property or resolved
from the phandle). This translation fails when the target is the root
node (a common case for Raspberry Pi overlays) because the resulting
path starts with a double slash. For example, if target-path is "/" and
the fragment adds a node called "newnode", the label associated with
that node will be assigned the path "//newnode", which can't be found
in the tree.

Fix the failure case by explicitly replacing a target path of "/" with
an empty string.

Fixes: d1651b03c2df ("of: overlay: add overlay symbols to live device tree")

Signed-off-by: Phil Elwell <phil@raspberrypi.com>
---
 drivers/of/overlay.c | 2 ++
 1 file changed, 2 insertions(+)

--- a/drivers/of/overlay.c
+++ b/drivers/of/overlay.c
@@ -245,6 +245,8 @@ static struct property *dup_and_fixup_sy
 	if (!target_path)
 		return NULL;
 	target_path_len = strlen(target_path);
+	if (!strcmp(target_path, "/"))
+		target_path_len = 0;
 
 	new_prop = kzalloc(sizeof(*new_prop), GFP_KERNEL);
 	if (!new_prop)
{ color: #0000DD; font-weight: bold } /* Literal.Number.Integer.Long */
--- a/arch/mips/ath25/ar2315.c
+++ b/arch/mips/ath25/ar2315.c
@@ -23,6 +23,7 @@
 #include <linux/reboot.h>
 #include <linux/delay.h>
 #include <linux/gpio.h>
+#include <linux/leds.h>
 #include <asm/bootinfo.h>
 #include <asm/reboot.h>
 #include <asm/time.h>
@@ -260,6 +261,50 @@ static struct platform_device ar2315_spi
 	.num_resources = ARRAY_SIZE(ar2315_spiflash_res)
 };
 
+#ifdef CONFIG_LEDS_GPIO
+static struct gpio_led ar2315_leds[6];
+static struct gpio_led_platform_data ar2315_led_data = {
+	.leds = (void *)ar2315_leds,
+};
+
+static struct platform_device ar2315_gpio_leds = {
+	.name = "leds-gpio",
+	.id = -1,
+	.dev = {
+		.platform_data = (void *)&ar2315_led_data,
+	}
+};
+
+static void __init ar2315_init_gpio_leds(void)
+{
+	static char led_names[6][6];
+	int i, led = 0;
+
+	ar2315_led_data.num_leds = 0;
+	for (i = 1; i < 8; i++) {
+		if ((i == AR2315_RESET_GPIO) ||
+		    (i == ath25_board.config->reset_config_gpio))
+			continue;
+
+		if (i == ath25_board.config->sys_led_gpio)
+			strcpy(led_names[led], "wlan");
+		else
+			sprintf(led_names[led], "gpio%d", i);
+
+		ar2315_leds[led].name = led_names[led];
+		ar2315_leds[led].gpio = i;
+		ar2315_leds[led].active_low = 0;
+		led++;
+	}
+	ar2315_led_data.num_leds = led;
+	platform_device_register(&ar2315_gpio_leds);
+}
+#else
+static inline void ar2315_init_gpio_leds(void)
+{
+}
+#endif
+
 void __init ar2315_init_devices(void)
 {
 	/* Find board configuration */
@@ -270,6 +315,8 @@ void __init ar2315_init_devices(void)
 	ar2315_gpio_res[1].end = ar2315_gpio_res[1].start;
 	platform_device_register(&ar2315_gpio);
 
+	ar2315_init_gpio_leds();
+
 	ar2315_wdt_res[1].start = irq_create_mapping(ar2315_misc_irq_domain,
 						     AR2315_MISC_IRQ_WATCHDOG);
 	ar2315_wdt_res[1].end = ar2315_wdt_res[1].start;
--- a/arch/mips/ath25/ar5312.c
+++ b/arch/mips/ath25/ar5312.c
@@ -23,6 +23,7 @@
 #include <linux/mtd/physmap.h>
 #include <linux/reboot.h>
 #include <linux/gpio.h>
+#include <linux/leds.h>
 #include <asm/bootinfo.h>
 #include <asm/reboot.h>
 #include <asm/time.h>
@@ -231,6 +232,23 @@ static struct platform_device ar5312_gpi
 	.num_resources = ARRAY_SIZE(ar5312_gpio_res),
 };
 
+#ifdef CONFIG_LEDS_GPIO
+static struct gpio_led ar5312_leds[] = {
+	{ .name = "wlan", .gpio = 0, .active_low = 1, },
+};
+
+static const struct gpio_led_platform_data ar5312_led_data = {
+	.num_leds = ARRAY_SIZE(ar5312_leds),
+	.leds = (void *)ar5312_leds,
+};
+
+static struct platform_device ar5312_gpio_leds = {
+	.name = "leds-gpio",
+	.id = -1,
+	.dev.platform_data = (void *)&ar5312_led_data,
+};
+#endif
+
 static void __init ar5312_flash_init(void)
 {
 	void __iomem *flashctl_base;
@@ -301,6 +319,11 @@ void __init ar5312_init_devices(void)
 
 	platform_device_register(&ar5312_gpio);
 
+#ifdef CONFIG_LEDS_GPIO
+	ar5312_leds[0].gpio = config->sys_led_gpio;
+	platform_device_register(&ar5312_gpio_leds);
+#endif
+
 	/* Fix up MAC addresses if necessary */
 	if (is_broadcast_ether_addr(config->enet0_mac))
 		ether_addr_copy(config->enet0_mac, config->enet1_mac);