All of lore.kernel.org
 help / color / mirror / Atom feed
From: sven@svenschwermer.de
To: linux-leds@vger.kernel.org, devicetree@vger.kernel.org,
	linux-pwm@vger.kernel.org
Cc: Sven Schwermer <sven.schwermer@disruptive-technologies.com>,
	pavel@ucw.cz, robh+dt@kernel.org, thierry.reding@gmail.com,
	u.kleine-koenig@pengutronix.de, lee.jones@linaro.org,
	post@lespocky.de
Subject: [PATCH v3 0/2] Multicolor PWM LED support
Date: Wed, 26 Jan 2022 11:48:42 +0100	[thread overview]
Message-ID: <20220126104844.246068-1-sven@svenschwermer.de> (raw)

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


             reply	other threads:[~2022-01-26 10:49 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-01-26 10:48 sven [this message]
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

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20220126104844.246068-1-sven@svenschwermer.de \
    --to=sven@svenschwermer.de \
    --cc=devicetree@vger.kernel.org \
    --cc=lee.jones@linaro.org \
    --cc=linux-leds@vger.kernel.org \
    --cc=linux-pwm@vger.kernel.org \
    --cc=pavel@ucw.cz \
    --cc=post@lespocky.de \
    --cc=robh+dt@kernel.org \
    --cc=sven.schwermer@disruptive-technologies.com \
    --cc=thierry.reding@gmail.com \
    --cc=u.kleine-koenig@pengutronix.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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.