Re: [PATCH v20 03/17] leds: multicolor: Introduce a multicolor class definition

From: Jacek Anaszewski
Date: Sun Apr 26 2020 - 12:48:23 EST


Hi Dan,

On 4/23/20 5:55 PM, Dan Murphy wrote:
Introduce a multicolor class that groups colored LEDs
within a LED node.

The multi color class groups monochrome LEDs and allows controlling two
aspects of the final combined color: hue and lightness. The former is
controlled via color_intensity file and the latter is controlled
via brightness file.

Signed-off-by: Dan Murphy <dmurphy@xxxxxx>
---

v20 - Change color_ file names to multi_led, dynamically allocate the
multicolor_info struct. Fixed documentation issues from Randy D.

[...]
+MODULE_AUTHOR("Dan Murphy <dmurphy@xxxxxx>");
+MODULE_DESCRIPTION("Multi Color LED class interface");
+MODULE_LICENSE("GPL v2");
diff --git a/include/linux/led-class-multicolor.h b/include/linux/led-class-multicolor.h
new file mode 100644
index 000000000000..7c5befb270f8
--- /dev/null
+++ b/include/linux/led-class-multicolor.h
@@ -0,0 +1,121 @@
+/* SPDX-License-Identifier: GPL-2.0 */
+/* LED Multicolor class interface
+ * Copyright (C) 2019-20 Texas Instruments Incorporated - http://www.ti.com/
+ */
+
+#ifndef __LINUX_MULTICOLOR_LEDS_H_INCLUDED
+#define __LINUX_MULTICOLOR_LEDS_H_INCLUDED
+
+#include <linux/leds.h>
+#include <dt-bindings/leds/common.h>
+
+struct led_mc_subled {
+ int color_index;
+ int color_brightness;
+ int color_led_intensity;
+ int color_channel;
+};
+
+struct led_classdev_mc {
+ /* led class device */
+ struct led_classdev led_cdev;
+ int num_colors;
+
+ struct led_mc_subled *multicolor_info;

I think mc_subleds (or even subleds alone - we are already in
led_classdev_*mc*) would be way more informative name for this
property.

And as already proposed in the other message:

s/color_led_intensity/color_intensity/

Also, I would like to have just "brightness" instead
of color_brightness, which is ambiguous. And having brightness
in this struct led_mc_subled would clearly state that this is
the value to be written to the hardware similarly as is
struct led_classdev's brightness for monochrome LEDs.

--
Best regards,
Jacek Anaszewski