All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v3 0/2] Multicolor PWM LED support
@ 2022-01-26 10:48 sven
  2022-01-26 10:48 ` [PATCH v3 1/2] dt-bindings: leds: Add multicolor PWM LED bindings sven
  2022-01-26 10:48 ` [PATCH v3 2/2] leds: Add PWM multicolor driver sven
  0 siblings, 2 replies; 14+ messages in thread
From: sven @ 2022-01-26 10:48 UTC (permalink / raw)
  To: linux-leds, devicetree, linux-pwm
  Cc: Sven Schwermer, pavel, robh+dt, thierry.reding, u.kleine-koenig,
	lee.jones, post

From: Sven Schwermer <sven.schwermer@disruptive-technologies.com>

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/37540afd-f2f1-52dd-f4f1-6e7b436e9595@svenschwermer.de/

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                          |   8 +
 drivers/leds/Makefile                         |   1 +
 drivers/leds/leds-pwm-multicolor.c            | 184 ++++++++++++++++++
 4 files changed, 268 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/leds/leds-pwm-multicolor.yaml
 create mode 100644 drivers/leds/leds-pwm-multicolor.c

Interdiff against v2:
diff --git a/Documentation/devicetree/bindings/leds/leds-pwm-multicolor.yaml b/Documentation/devicetree/bindings/leds/leds-pwm-multicolor.yaml
index b82b26f2e140..5a7ed5e1bb9f 100644
--- a/Documentation/devicetree/bindings/leds/leds-pwm-multicolor.yaml
+++ b/Documentation/devicetree/bindings/leds/leds-pwm-multicolor.yaml
@@ -17,8 +17,7 @@ properties:
   compatible:
     const: pwm-leds-multicolor
 
-patternProperties:
-  '^multi-led@[0-9a-f]$':
+  multi-led:
     type: object
     allOf:
       - $ref: leds-class-multicolor.yaml#
@@ -51,7 +50,7 @@ examples:
     rgb-led {
         compatible = "pwm-leds-multicolor";
 
-        multi-led@0 {
+        multi-led {
           color = <LED_COLOR_ID_RGB>;
           function = LED_FUNCTION_INDICATOR;
           max-brightness = <65535>;
diff --git a/drivers/leds/leds-pwm-multicolor.c b/drivers/leds/leds-pwm-multicolor.c
index c54bed4536d3..bc4d21ddd74a 100644
--- a/drivers/leds/leds-pwm-multicolor.c
+++ b/drivers/leds/leds-pwm-multicolor.c
@@ -5,18 +5,18 @@
  * Copyright 2022 Sven Schwermer <sven.schwermer@disruptive-technologies.com>
  */
 
-#include <linux/module.h>
+#include <linux/err.h>
 #include <linux/kernel.h>
-#include <linux/platform_device.h>
 #include <linux/led-class-multicolor.h>
 #include <linux/leds.h>
-#include <linux/err.h>
-#include <linux/pwm.h>
+#include <linux/module.h>
 #include <linux/mutex.h>
+#include <linux/platform_device.h>
+#include <linux/pwm.h>
 
 struct pwm_led {
 	struct pwm_device *pwm;
-	struct pwm_state pwmstate;
+	struct pwm_state state;
 };
 
 struct pwm_mc_led {
@@ -39,14 +39,14 @@ static int led_pwm_mc_set(struct led_classdev *cdev,
 	mutex_lock(&priv->lock);
 
 	for (i = 0; i < mc_cdev->num_colors; ++i) {
-		duty = priv->leds[i].pwmstate.period;
+		duty = priv->leds[i].state.period;
 		duty *= mc_cdev->subled_info[i].brightness;
 		do_div(duty, cdev->max_brightness);
 
-		priv->leds[i].pwmstate.duty_cycle = duty;
-		priv->leds[i].pwmstate.enabled = duty > 0;
+		priv->leds[i].state.duty_cycle = duty;
+		priv->leds[i].state.enabled = duty > 0;
 		ret = pwm_apply_state(priv->leds[i].pwm,
-				      &priv->leds[i].pwmstate);
+				      &priv->leds[i].state);
 		if (ret)
 			break;
 	}
@@ -83,7 +83,7 @@ static int led_pwm_mc_probe(struct platform_device *pdev)
 			    GFP_KERNEL);
 	if (!priv) {
 		ret = -ENOMEM;
-		goto out;
+		goto release_mcnode;
 	}
 	mutex_init(&priv->lock);
 
@@ -96,8 +96,6 @@ static int led_pwm_mc_probe(struct platform_device *pdev)
 
 	/* init the multicolor's LED class device */
 	cdev = &priv->mc_cdev.led_cdev;
-	fwnode_property_read_string(mcnode, "label", &cdev->name);
-	cdev->brightness = LED_OFF;
 	fwnode_property_read_u32(mcnode, "max-brightness",
 				 &cdev->max_brightness);
 	cdev->flags = LED_CORE_SUSPENDRESUME;
@@ -110,19 +108,19 @@ static int led_pwm_mc_probe(struct platform_device *pdev)
 		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 destroy_mutex;
 		}
-		pwm_init_state(pwmled->pwm, &pwmled->pwmstate);
+		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 destroy_mutex;
 		}
 
 		subled[priv->mc_cdev.num_colors].color_index = color;
-		subled[priv->mc_cdev.num_colors].channel =
-			priv->mc_cdev.num_colors;
 		++priv->mc_cdev.num_colors;
 	}
 
@@ -149,6 +147,8 @@ static int led_pwm_mc_probe(struct platform_device *pdev)
 
 destroy_mutex:
 	mutex_destroy(&priv->lock);
+release_mcnode:
+	fwnode_handle_put(mcnode);
 out:
 	return ret;
 }
-- 
2.35.0


^ permalink raw reply related	[flat|nested] 14+ messages in thread

end of thread, other threads:[~2022-02-12 11:54 UTC | newest]

Thread overview: 14+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-01-26 10:48 [PATCH v3 0/2] Multicolor PWM LED support sven
2022-01-26 10:48 ` [PATCH v3 1/2] dt-bindings: leds: Add multicolor PWM LED bindings sven
2022-01-27 21:24   ` Jacek Anaszewski
2022-01-28 20:36     ` Marek Behún
2022-01-28 23:04       ` Jacek Anaszewski
2022-01-28 23:26         ` Marek Behún
2022-01-31  7:10           ` Alexander Dahl
2022-01-31  8:55             ` Sven Schwermer
2022-02-12 11:54         ` Pavel Machek
2022-01-26 10:48 ` [PATCH v3 2/2] leds: Add PWM multicolor driver sven
2022-02-02 12:33   ` Andy Shevchenko
2022-02-06  9:17     ` Sven Schwermer
     [not found]       ` <CAHp75VeSD5bYERp=s9Dzd0xScVc+sYSdc8W4XBfCVXJgyWMPyA@mail.gmail.com>
2022-02-06 11:04         ` Sven Schwermer
2022-02-06 12:25           ` Andy Shevchenko

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.