Skip to content

Multicolor PWM LED support

[email protected] linux-devicetree linux-leds linux-pwm 5 versions – In review

Get series with b4
b4 am [email protected]

Versions newest first · linked by author and title

  1. v5 Latest2 patches 3 repliesIn review
  2. v42 patches 2 repliesSuperseded
  3. v32 patches 11 repliesSuperseded
Earlier versions · 2
VersionPostedPatchesRepliesStatus
v2 RFC2 patches5 repliesSuperseded
v1 RFC2 patches6 repliesSuperseded

Patches in v5 No applies recorded yet

#Subject and filesSizeRepliesApplied
1/2dt-bindings: leds: Add multicolor PWM LED bindingsDocumentation/devicetree/bindings/leds/leds-pwm-multicolor.yaml+75 -03 replies
2/2leds: Add PWM multicolor driverdrivers/leds/Kconfig drivers/leds/Makefile drivers/leds/leds-pwm-multicolor.c+198 -00 replies

Reviews trailers per patch

1 of 2 patches has a Reviewed-by or Acked-by.

PatchAndy Shevchenko
1/2
2/2R-b

Trailers given in replies are filled; those carried in the patches from earlier versions are outlined with dashes.

Read the v5 thread

Cover letter [PATCH v5 0/2] Multicolor PWM LED support

From: Sven Schwermer <[email protected]>

Hi,

This patch series is getting mature. I have removed the RFC tag for this version. The initial discussion happened here [1].

I would appreciate if anyone would test this code. It runs on my i.MX6ULL-based hardware.

Best regards,
Sven

[1]:https://lore.kernel.org/linux-leds/[email protected]/

Sven Schwermer (2):
dt-bindings: leds: Add multicolor PWM LED bindings
leds: Add PWM multicolor driver

 .../bindings/leds/leds-pwm-multicolor.yaml    |  75 +++++++
 drivers/leds/Kconfig                          |  11 ++
 drivers/leds/Makefile                         |   1 +
 drivers/leds/leds-pwm-multicolor.c            | 186 ++++++++++++++++++
 4 files changed, 273 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/leds/leds-pwm-multicolor.yaml
 create mode 100644 drivers/leds/leds-pwm-multicolor.c

Interdiff against v4:

drivers/leds/leds-pwm-multicolor.c +40 -24
index 96712b8ca98e..45e38708ecb1 100644
@@ -58,6 +58,43 @@ static int led_pwm_mc_set(struct led_classdev *cdev,
 	return ret;
 }
 
+static int iterate_subleds(struct device *dev, struct pwm_mc_led *priv,
+			   struct fwnode_handle *mcnode)
+{
+	struct mc_subled *subled = priv->mc_cdev.subled_info;
+	struct fwnode_handle *fwnode;
+	struct pwm_led *pwmled;
+	u32 color;
+	int ret;
+
+	/* iterate over the nodes inside the multi-led node */
+	fwnode_for_each_child_node(mcnode, fwnode) {
+		pwmled = &priv->leds[priv->mc_cdev.num_colors];
+		pwmled->pwm = devm_fwnode_pwm_get(dev, fwnode, NULL);
+		if (IS_ERR(pwmled->pwm)) {
+			ret = PTR_ERR(pwmled->pwm);
+			dev_err(dev, "unable to request PWM: %d\n", ret);
+			goto release_fwnode;
+		}
+		pwm_init_state(pwmled->pwm, &pwmled->state);
+
+		ret = fwnode_property_read_u32(fwnode, "color", &color);
+		if (ret) {
+			dev_err(dev, "cannot read color: %d\n", ret);
+			goto release_fwnode;
+		}
+
+		subled[priv->mc_cdev.num_colors].color_index = color;
+		priv->mc_cdev.num_colors++;
+	}
+
+	return 0;
+
+release_fwnode:
+	fwnode_handle_put(fwnode);
+	return ret;
+}
+
 static int led_pwm_mc_probe(struct platform_device *pdev)
 {
 	struct fwnode_handle *mcnode, *fwnode;
@@ -65,10 +102,8 @@ static int led_pwm_mc_probe(struct platform_device *pdev)
 	struct led_classdev *cdev;
 	struct mc_subled *subled;
 	struct pwm_mc_led *priv;
-	struct pwm_led *pwmled;
 	int count = 0;
 	int ret = 0;
-	u32 color;
 
 	mcnode = device_get_named_child_node(&pdev->dev, "multi-led");
 	if (!mcnode)
@@ -101,28 +136,9 @@ static int led_pwm_mc_probe(struct platform_device *pdev)
 	cdev->flags = LED_CORE_SUSPENDRESUME;
 	cdev->brightness_set_blocking = led_pwm_mc_set;
 
-	/* iterate over the nodes inside the multi-led node */
-	fwnode_for_each_child_node(mcnode, fwnode) {
-		pwmled = &priv->leds[priv->mc_cdev.num_colors];
-		pwmled->pwm = devm_fwnode_pwm_get(&pdev->dev, fwnode, NULL);
-		if (IS_ERR(pwmled->pwm)) {
-			ret = PTR_ERR(pwmled->pwm);
-			dev_err(&pdev->dev, "unable to request PWM: %d\n", ret);
-			fwnode_handle_put(fwnode);
-			goto release_mcnode;
-		}
-		pwm_init_state(pwmled->pwm, &pwmled->state);
-
-		ret = fwnode_property_read_u32(fwnode, "color", &color);
-		if (ret) {
-			dev_err(&pdev->dev, "cannot read color: %d\n", ret);
-			fwnode_handle_put(fwnode);
-			goto release_mcnode;
-		}
-
-		subled[priv->mc_cdev.num_colors].color_index = color;
-		priv->mc_cdev.num_colors++;
-	}
+	ret = iterate_subleds(&pdev->dev, priv, mcnode);
+	if (ret)
+		goto release_mcnode;
 
 	init_data.fwnode = mcnode;
 	ret = devm_led_classdev_multicolor_register_ext(&pdev->dev,
Signature · 1 line
2.35.1