Thread (9 messages) 9 messages, 5 authors, 2021-03-29

Re: [PATCH v2 2/2] leds: leds-multi-gpio: Add multiple GPIOs LED driver

From: Pavel Machek <hidden>
Date: 2021-03-26 13:50:32
Also in: linux-leds, lkml

Hi!
Introduce a new multiple GPIOs LED driver. This LED will made of
multiple GPIOs (up to 8) and will map different brightness to different
GPIOs states which defined in dts file.

Signed-off-by: Hermes Zhang <redacted>
quoted hunk ↗ jump to hunk
index 000000000000..7aef82701f86
--- /dev/null
+++ b/drivers/leds/simple/Kconfig
@@ -0,0 +1,23 @@
+menuconfig LEDS_SIMPLE
+	bool "Simple LED support"
+	depends on LEDS_CLASS
+	help
+	  This option enables simple leds support for the leds class.
+	  If unsure, say Y.
No need for new config symbol.
+	if (ret != 1 << gpios->ndescs) {
I'd do (ret != (1 << gpios->ndescs))
+	priv = devm_kzalloc(dev, sizeof(struct multi_gpio_led_priv)
+			+ sizeof(u8) * nr_states , GFP_KERNEL);
Sizeof(u8) is always 1, no need for space before , . 
+	of_property_read_string(node, "default-state", &state);
+	if (!strcmp(state, "on"))
+		multi_gpio_led_set(&priv->cdev, priv->cdev.max_brightness);
+	else
+		multi_gpio_led_set(&priv->cdev, 0);
No need for default-state handling, unless you are using it.

Best regards,
									Pavel

-- 
http://www.livejournal.com/~pavelmachek

Attachments

Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help