Skip to contentSkip to conversation

led: Move OF "label" property parsing to core

PATCH In review Marek Vasut 2 participants 16 messages Apr 3, 2022 – Apr 15, 2022 Broadcom bcmbca Arm architecture

lore
Share & tools
lore
#0 lore raw

PATCH 1/6 led: Move OF "label" property parsing to core

Every driver in drivers/led/ currently does some form of "label" OF property parsing in its bind() callback. Move this label parsing to LED core, since this "label" OF property is a generic property. This permits code deduplication in subseuqent patches.

Cc Alex Nemirovsky <[email protected]>
Cc Patrick Delaunay <[email protected]>
Cc Philippe Reynes <[email protected]>
Cc Sean Anderson <[email protected]>
Cc Simon Glass <[email protected]>
Cc Steven Lawrance <[email protected]>
---
 drivers/led/led-uclass.c | 12 ++++++++++++
 1 file changed, 12 insertions(+)
drivers/led/led-uclass.c +12 -0
index 7e298dbb06f..2f4aa18fb10 100644
@@ -95,8 +95,20 @@ int led_default_state(void)
 	return ret;
 }
 
+static int led_post_bind(struct udevice *dev)
+{
+	struct led_uc_plat *uc_plat = dev_get_uclass_plat(dev);
+
+	uc_plat->label = dev_read_string(dev, "label");
+	if (!uc_plat->label)
+		uc_plat->label = ofnode_get_name(dev_ofnode(dev));
+
+	return 0;
+}
+
 UCLASS_DRIVER(led) = {
 	.id		= UCLASS_LED,
 	.name		= "led",
 	.per_device_plat_auto	= sizeof(struct led_uc_plat),
+	.post_bind	= led_post_bind,
 };
Signature · 1 line
2.35.1
#1 lore raw

PATCH 2/6 led: bcm6328: Drop duplicate OF "label" property parsing

The OF "label" property parsing is now handled in LED core, drop the duplicate implementation from this driver.

Cc Alex Nemirovsky <[email protected]>
Cc Patrick Delaunay <[email protected]>
Cc Philippe Reynes <[email protected]>
Cc Sean Anderson <[email protected]>
Cc Simon Glass <[email protected]>
Cc Steven Lawrance <[email protected]>
---
 drivers/led/led_bcm6328.c | 12 ------------
 1 file changed, 12 deletions(-)
drivers/led/led_bcm6328.c +0 -12
index bf8207d638d..f59a92fb1fd 100644
@@ -204,26 +204,14 @@ static int bcm6328_led_bind(struct udevice *parent)
 	ofnode node;
 
 	dev_for_each_subnode(node, parent) {
-		struct led_uc_plat *uc_plat;
 		struct udevice *dev;
-		const char *label;
 		int ret;
 
-		label = ofnode_read_string(node, "label");
-		if (!label) {
-			debug("%s: node %s has no label\n", __func__,
-			      ofnode_get_name(node));
-			return -EINVAL;
-		}
-
 		ret = device_bind_driver_to_node(parent, "bcm6328-led",
 						 ofnode_get_name(node),
 						 node, &dev);
 		if (ret)
 			return ret;
-
-		uc_plat = dev_get_uclass_plat(dev);
-		uc_plat->label = label;
 	}
 
 	return 0;
Signature · 1 line
2.35.1
#2 lore raw

Re: [PATCH 2/6] led: bcm6328: Drop duplicate OF "label" property parsing

Quoted 10 lines · Marek Vasut

The OF "label" property parsing is now handled in LED core, drop the duplicate implementation from this driver.

Cc Alex Nemirovsky <[email protected]>
Cc Patrick Delaunay <[email protected]>
Cc Philippe Reynes <[email protected]>
Cc Sean Anderson <[email protected]>
Cc Simon Glass <[email protected]>
Cc Steven Lawrance <[email protected]>

Applied to u-boot/master, thanks!

Signature · 1 line
Tom
#3 lore raw

PATCH 3/6 led: bcm6358: Drop duplicate OF "label" property parsing

In reply to Marek Vasut

The OF "label" property parsing is now handled in LED core, drop the duplicate implementation from this driver.

Cc Alex Nemirovsky <[email protected]>
Cc Patrick Delaunay <[email protected]>
Cc Philippe Reynes <[email protected]>
Cc Sean Anderson <[email protected]>
Cc Simon Glass <[email protected]>
Cc Steven Lawrance <[email protected]>
---
 drivers/led/led_bcm6358.c | 12 ------------
 1 file changed, 12 deletions(-)
drivers/led/led_bcm6358.c +0 -12
index 3e57cdfd17d..25aa3994d0e 100644
@@ -174,26 +174,14 @@ static int bcm6358_led_bind(struct udevice *parent)
 	ofnode node;
 
 	dev_for_each_subnode(node, parent) {
-		struct led_uc_plat *uc_plat;
 		struct udevice *dev;
-		const char *label;
 		int ret;
 
-		label = ofnode_read_string(node, "label");
-		if (!label) {
-			debug("%s: node %s has no label\n", __func__,
-			      ofnode_get_name(node));
-			return -EINVAL;
-		}
-
 		ret = device_bind_driver_to_node(parent, "bcm6358-led",
 						 ofnode_get_name(node),
 						 node, &dev);
 		if (ret)
 			return ret;
-
-		uc_plat = dev_get_uclass_plat(dev);
-		uc_plat->label = label;
 	}
 
 	return 0;
Signature · 1 line
2.35.1
#4 lore raw

Re: [PATCH 3/6] led: bcm6358: Drop duplicate OF "label" property parsing

Quoted 10 lines · Marek Vasut

The OF "label" property parsing is now handled in LED core, drop the duplicate implementation from this driver.

Cc Alex Nemirovsky <[email protected]>
Cc Patrick Delaunay <[email protected]>
Cc Philippe Reynes <[email protected]>
Cc Sean Anderson <[email protected]>
Cc Simon Glass <[email protected]>
Cc Steven Lawrance <[email protected]>

Applied to u-boot/master, thanks!

Signature · 1 line
Tom
#5 lore raw

PATCH 4/6 led: bcm6858: Drop duplicate OF "label" property parsing

In reply to Marek Vasut

The OF "label" property parsing is now handled in LED core, drop the duplicate implementation from this driver.

Cc Alex Nemirovsky <[email protected]>
Cc Patrick Delaunay <[email protected]>
Cc Philippe Reynes <[email protected]>
Cc Sean Anderson <[email protected]>
Cc Simon Glass <[email protected]>
Cc Steven Lawrance <[email protected]>
---
 drivers/led/led_bcm6858.c | 12 ------------
 1 file changed, 12 deletions(-)
drivers/led/led_bcm6858.c +0 -12
index fbf46a114c5..4fd840b42f5 100644
@@ -211,26 +211,14 @@ static int bcm6858_led_bind(struct udevice *parent)
 	ofnode node;
 
 	dev_for_each_subnode(node, parent) {
-		struct led_uc_plat *uc_plat;
 		struct udevice *dev;
-		const char *label;
 		int ret;
 
-		label = ofnode_read_string(node, "label");
-		if (!label) {
-			debug("%s: node %s has no label\n", __func__,
-			      ofnode_get_name(node));
-			return -EINVAL;
-		}
-
 		ret = device_bind_driver_to_node(parent, "bcm6858-led",
 						 ofnode_get_name(node),
 						 node, &dev);
 		if (ret)
 			return ret;
-
-		uc_plat = dev_get_uclass_plat(dev);
-		uc_plat->label = label;
 	}
 
 	return 0;
Signature · 1 line
2.35.1
#6 lore raw

Re: [PATCH 4/6] led: bcm6858: Drop duplicate OF "label" property parsing

Quoted 10 lines · Marek Vasut

The OF "label" property parsing is now handled in LED core, drop the duplicate implementation from this driver.

Cc Alex Nemirovsky <[email protected]>
Cc Patrick Delaunay <[email protected]>
Cc Philippe Reynes <[email protected]>
Cc Sean Anderson <[email protected]>
Cc Simon Glass <[email protected]>
Cc Steven Lawrance <[email protected]>

Applied to u-boot/master, thanks!

Signature · 1 line
Tom
#7 lore raw

PATCH 5/6 led: cortina: Drop duplicate OF "label" property parsing

In reply to Marek Vasut

The OF "label" property parsing is now handled in LED core, drop the duplicate implementation from this driver.

Cc Alex Nemirovsky <[email protected]>
Cc Patrick Delaunay <[email protected]>
Cc Philippe Reynes <[email protected]>
Cc Sean Anderson <[email protected]>
Cc Simon Glass <[email protected]>
Cc Steven Lawrance <[email protected]>
---
 drivers/led/led_cortina.c | 11 -----------
 1 file changed, 11 deletions(-)
drivers/led/led_cortina.c +0 -11
index 598c0a03db5..bcbe78d632a 100644
@@ -256,25 +256,14 @@ static int cortina_led_bind(struct udevice *parent)
 	ofnode node;
 
 	dev_for_each_subnode(node, parent) {
-		struct led_uc_plat *uc_plat;
 		struct udevice *dev;
-		const char *label;
 		int ret;
 
-		label = ofnode_read_string(node, "label");
-		if (!label) {
-			debug("%s: node %s has no label\n", __func__,
-			      ofnode_get_name(node));
-			return -EINVAL;
-		}
-
 		ret = device_bind_driver_to_node(parent, "ca-leds",
 						 ofnode_get_name(node),
 						 node, &dev);
 		if (ret)
 			return ret;
-		uc_plat = dev_get_uclass_plat(dev);
-		uc_plat->label = label;
 	}
 
 	return 0;
Signature · 1 line
2.35.1
#8 lore raw

Re: [PATCH 5/6] led: cortina: Drop duplicate OF "label" property parsing

Quoted 10 lines · Marek Vasut

The OF "label" property parsing is now handled in LED core, drop the duplicate implementation from this driver.

Cc Alex Nemirovsky <[email protected]>
Cc Patrick Delaunay <[email protected]>
Cc Philippe Reynes <[email protected]>
Cc Sean Anderson <[email protected]>
Cc Simon Glass <[email protected]>
Cc Steven Lawrance <[email protected]>

Applied to u-boot/master, thanks!

Signature · 1 line
Tom
#9 lore raw

PATCH 6/6 led: gpio: Drop duplicate OF "label" property parsing

In reply to Marek Vasut

The OF "label" property parsing is now handled in LED core, drop the duplicate implementation from this driver.

Cc Alex Nemirovsky <[email protected]>
Cc Patrick Delaunay <[email protected]>
Cc Philippe Reynes <[email protected]>
Cc Sean Anderson <[email protected]>
Cc Simon Glass <[email protected]>
Cc Steven Lawrance <[email protected]>
---
 drivers/led/led_gpio.c | 8 --------
 1 file changed, 8 deletions(-)
drivers/led/led_gpio.c +0 -8
index 67ece3cbcd0..958dbd31e77 100644
@@ -95,19 +95,11 @@ static int led_gpio_bind(struct udevice *parent)
 	int ret;
 
 	dev_for_each_subnode(node, parent) {
-		struct led_uc_plat *uc_plat;
-		const char *label;
-
-		label = ofnode_read_string(node, "label");
-		if (!label)
-			label = ofnode_get_name(node);
 		ret = device_bind_driver_to_node(parent, "gpio_led",
 						 ofnode_get_name(node),
 						 node, &dev);
 		if (ret)
 			return ret;
-		uc_plat = dev_get_uclass_plat(dev);
-		uc_plat->label = label;
 	}
 
 	return 0;
Signature · 1 line
2.35.1
#10 lore raw

Re: [PATCH 6/6] led: gpio: Drop duplicate OF "label" property parsing

Quoted 10 lines · Marek Vasut

The OF "label" property parsing is now handled in LED core, drop the duplicate implementation from this driver.

Cc Alex Nemirovsky <[email protected]>
Cc Patrick Delaunay <[email protected]>
Cc Philippe Reynes <[email protected]>
Cc Sean Anderson <[email protected]>
Cc Simon Glass <[email protected]>
Cc Steven Lawrance <[email protected]>

Applied to u-boot/master, thanks!

Signature · 1 line
Tom
#11 lore raw

PATCH 1/2 led: bcm6753: Drop duplicate OF "label" property parsing

In reply to Marek Vasut

The OF "label" property parsing is now handled in LED core, drop the duplicate implementation from this driver.

---
 drivers/led/led_bcm6753.c | 12 ------------
 1 file changed, 12 deletions(-)
drivers/led/led_bcm6753.c +0 -12
index a32bd8204fa0..88b650cbfca3 100644
@@ -229,26 +229,14 @@ static int bcm6753_led_bind(struct udevice *parent)
 	ofnode node;
 
 	dev_for_each_subnode(node, parent) {
-		struct led_uc_plat *uc_plat;
 		struct udevice *dev;
-		const char *label;
 		int ret;
 
-		label = ofnode_read_string(node, "label");
-		if (!label) {
-			debug("%s: node %s has no label\n", __func__,
-			      ofnode_get_name(node));
-			return -EINVAL;
-		}
-
 		ret = device_bind_driver_to_node(parent, "bcm6753-led",
 						 ofnode_get_name(node),
 						 node, &dev);
 		if (ret)
 			return ret;
-
-		uc_plat = dev_get_uclass_plat(dev);
-		uc_plat->label = label;
 	}
 
 	return 0;
Signature · 1 line
2.25.1
#12 lore raw

PATCH 2/2 led: pwm: Drop duplicate OF "label" property parsing

The OF "label" property parsing is now handled in LED core, drop the duplicate implementation from this driver.

---
 drivers/led/led_pwm.c | 10 ----------
 1 file changed, 10 deletions(-)
drivers/led/led_pwm.c +0 -10
index 4e5027225870..10bd1636c386 100644
@@ -151,21 +151,11 @@ static int led_pwm_bind(struct udevice *parent)
 	int ret;
 
 	dev_for_each_subnode(node, parent) {
-		struct led_uc_plat *uc_plat;
-		const char *label;
-
-		label = ofnode_read_string(node, "label");
-		if (!label)
-			label = ofnode_get_name(node);
-
 		ret = device_bind_driver_to_node(parent, LEDS_PWM_DRIVER_NAME,
 						 ofnode_get_name(node),
 						 node, &dev);
 		if (ret)
 			return ret;
-
-		uc_plat = dev_get_uclass_plat(dev);
-		uc_plat->label = label;
 	}
 	return 0;
 }
Signature · 1 line
2.25.1
#13 lore raw

Re: [PATCH 2/2] led: pwm: Drop duplicate OF "label" property parsing

Quoted 4 lines · Tom Rini

The OF "label" property parsing is now handled in LED core, drop the duplicate implementation from this driver.

Applied to u-boot/master, thanks!

Signature · 1 line
Tom
#14 lore raw

Re: [PATCH 1/2] led: bcm6753: Drop duplicate OF "label" property parsing

In reply to Tom Rini
Quoted 4 lines · Tom Rini

The OF "label" property parsing is now handled in LED core, drop the duplicate implementation from this driver.

Applied to u-boot/master, thanks!

Signature · 1 line
Tom
#15 lore raw
In reply to Marek Vasut
Quoted 5 lines · Marek Vasut

Every driver in drivers/led/ currently does some form of "label" OF property parsing in its bind() callback. Move this label parsing to LED core, since this "label" OF property is a generic property. This permits code deduplication in subseuqent patches.

Quoted 7 lines
Cc Alex Nemirovsky <[email protected]>
Cc Patrick Delaunay <[email protected]>
Cc Philippe Reynes <[email protected]>
Cc Sean Anderson <[email protected]>
Cc Simon Glass <[email protected]>
Cc Steven Lawrance <[email protected]>

Applied to u-boot/master, thanks!

Signature · 1 line
Tom