From: Dan Murphy <dmurphy@ti.com>
To: Jacek Anaszewski <jacek.anaszewski@gmail.com>, <pavel@ucw.cz>
Cc: <linux-leds@vger.kernel.org>, <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH v11 12/16] leds: lp55xx: Add multicolor framework support to lp55xx
Date: Wed, 9 Oct 2019 19:47:31 -0500 [thread overview]
Message-ID: <a5c59e36-85b9-ad90-25f8-4ac160b5b661@ti.com> (raw)
In-Reply-To: <1f0ac6f3-a822-84f0-d398-2f16751c3b1b@gmail.com>
Jacek
On 10/9/19 5:04 PM, Jacek Anaszewski wrote:
> Dan,
>
> On 10/8/19 10:47 PM, Dan Murphy wrote:
>> Add multicolor framework support for the lp55xx family.
>>
>> Signed-off-by: Dan Murphy <dmurphy@ti.com>
>> ---
>> drivers/leds/Kconfig | 1 +
>> drivers/leds/leds-lp55xx-common.c | 176 +++++++++++++++++++---
>> drivers/leds/leds-lp55xx-common.h | 11 ++
>> include/linux/platform_data/leds-lp55xx.h | 5 +
>> 4 files changed, 169 insertions(+), 24 deletions(-)
>>
> [...]
>>
>> +static int lp5xx_parse_common_child(struct device_node *np,
>> + struct lp55xx_led_config *cfg,
>> + int chan_num, bool is_multicolor,
>> + int color_num)
>> +{
>> + u32 led_number;
>> + int ret;
>> +
>> + of_property_read_string(np, "chan-name",
>> + &cfg[chan_num].name);
>> + of_property_read_u8(np, "led-cur",
>> + &cfg[chan_num].led_current);
>> + of_property_read_u8(np, "max-cur",
>> + &cfg[chan_num].max_current);
>> +
>> + ret = of_property_read_u32(np, "reg", &led_number);
>> + if (ret)
>> + return ret;
>> +
>> + if (led_number < 0 || led_number > 6)
>> + return -EINVAL;
>> +
>> + if (is_multicolor)
>> + cfg[chan_num].color_component[color_num].output_num =
>> + led_number;
>> + else
>> + cfg[chan_num].chan_nr = led_number;
>> +
>> + return 0;
>> +}
>> +
>> +static int lp5xx_parse_channel_child(struct device_node *np,
>> + struct lp55xx_led_config *cfg,
>> + int child_number)
>> +{
>> + struct device_node *child;
>> + int channel_color;
>> + int num_colors = 0;
>> + u32 color_id;
>> + int ret;
>> +
>> + cfg[child_number].default_trigger =
>> + of_get_property(np, "linux,default-trigger", NULL);
>> +
>> + ret = of_property_read_u32(np, "color", &channel_color);
>> + if (ret)
>> + channel_color = ret;
>> +
>> +
>> + if (channel_color == LED_COLOR_ID_MULTI) {
>> + for_each_child_of_node(np, child) {
>> + ret = lp5xx_parse_common_child(child, cfg,
>> + child_number, true,
>> + num_colors);
>> + if (ret)
>> + return ret;
>> +
>> + ret = of_property_read_u32(child, "color", &color_id);
>> + if (ret)
>> + return ret;
>> +
>> + cfg[child_number].color_component[num_colors].color_id =
>> + color_id;
>> + set_bit(color_id, &cfg[child_number].available_colors);
>> + num_colors++;
>> + }
>> +
>> + cfg[child_number].num_colors = num_colors;
>> + } else {
>> + return lp5xx_parse_common_child(np, cfg, child_number, false,
>> + num_colors);
>> + }
>> +
>> + return 0;
>> +}
>> +
>> struct lp55xx_platform_data *lp55xx_of_populate_pdata(struct device *dev,
>> struct device_node *np)
>> {
>> @@ -546,6 +678,7 @@ struct lp55xx_platform_data *lp55xx_of_populate_pdata(struct device *dev,
>> struct lp55xx_led_config *cfg;
>> int num_channels;
>> int i = 0;
>> + int ret;
>>
>> pdata = devm_kzalloc(dev, sizeof(*pdata), GFP_KERNEL);
>> if (!pdata)
>> @@ -565,14 +698,9 @@ struct lp55xx_platform_data *lp55xx_of_populate_pdata(struct device *dev,
>> pdata->num_channels = num_channels;
>>
>> for_each_child_of_node(np, child) {
>> - cfg[i].chan_nr = i;
>> -
>> - of_property_read_string(child, "chan-name", &cfg[i].name);
>> - of_property_read_u8(child, "led-cur", &cfg[i].led_current);
>> - of_property_read_u8(child, "max-cur", &cfg[i].max_current);
>> - cfg[i].default_trigger =
>> - of_get_property(child, "linux,default-trigger", NULL);
>> -
>> + ret = lp5xx_parse_channel_child(child, cfg, i);
>> + if (ret)
>> + return ERR_PTR(-EINVAL);
>> i++;
>> }
>>
>> diff --git a/drivers/leds/leds-lp55xx-common.h b/drivers/leds/leds-lp55xx-common.h
>> index 783ed5103ce5..55d420f704d1 100644
>> --- a/drivers/leds/leds-lp55xx-common.h
>> +++ b/drivers/leds/leds-lp55xx-common.h
>> @@ -12,6 +12,10 @@
>> #ifndef _LEDS_LP55XX_COMMON_H
>> #define _LEDS_LP55XX_COMMON_H
>>
>> +#include <linux/led-class-multicolor.h>
>> +
>> +#define LP55XX_MAX_GROUPED_CHAN 4
>> +
>> enum lp55xx_engine_index {
>> LP55XX_ENGINE_INVALID,
>> LP55XX_ENGINE_1,
>> @@ -109,6 +113,9 @@ struct lp55xx_device_config {
>> /* access brightness register */
>> int (*brightness_fn)(struct lp55xx_led *led);
>>
>> + /* access specific brightness register */
>> + int (*color_intensity_fn)(struct lp55xx_led *led);
>> +
>> /* current setting function */
>> void (*set_led_current) (struct lp55xx_led *led, u8 led_current);
>>
>> @@ -159,6 +166,8 @@ struct lp55xx_chip {
>> * struct lp55xx_led
>> * @chan_nr : Channel number
>> * @cdev : LED class device
>> + * @mc_cdev : Multi color class device
>> + * @color_component : Multi color LED map information
>> * @led_current : Current setting at each led channel
>> * @max_current : Maximun current at each led channel
>> * @brightness : Brightness value
>> @@ -167,6 +176,8 @@ struct lp55xx_chip {
>> struct lp55xx_led {
>> int chan_nr;
>> struct led_classdev cdev;
>> + struct led_classdev_mc mc_cdev;
>> + struct led_mc_color_conversion color_component[LP55XX_MAX_GROUPED_CHAN];
>> u8 led_current;
>> u8 max_current;
>> u8 brightness;
>> diff --git a/include/linux/platform_data/leds-lp55xx.h b/include/linux/platform_data/leds-lp55xx.h
>> index 96a787100fda..1e7a25ed9a87 100644
>> --- a/include/linux/platform_data/leds-lp55xx.h
>> +++ b/include/linux/platform_data/leds-lp55xx.h
>> @@ -12,6 +12,8 @@
>> #ifndef _LEDS_LP55XX_H
>> #define _LEDS_LP55XX_H
>>
>> +#include <linux/led-class-multicolor.h>
>> +
>> /* Clock configuration */
>> #define LP55XX_CLOCK_AUTO 0
>> #define LP55XX_CLOCK_INT 1
>> @@ -23,6 +25,9 @@ struct lp55xx_led_config {
>> u8 chan_nr;
>> u8 led_current; /* mA x10, 0 if led is not connected */
>> u8 max_current;
>> + int num_colors;
>> + unsigned long available_colors;
>> + struct led_mc_color_conversion color_component[LED_COLOR_ID_MAX];
> I can't see why the array length can't be LP55XX_MAX_GROUPED_CHAN here
> too. You're indexing it with num_colors counter and not with color_id.
Ack
Dan
next prev parent reply other threads:[~2019-10-10 0:47 UTC|newest]
Thread overview: 32+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-10-08 20:47 [PATCH v11 00/16] Multicolor Framework v11 Dan Murphy
2019-10-08 20:47 ` [PATCH v11 01/16] dt: bindings: Add multicolor class dt bindings documention Dan Murphy
2019-10-09 22:07 ` Jacek Anaszewski
2019-10-10 0:49 ` Dan Murphy
2019-10-10 18:42 ` Jacek Anaszewski
2019-10-08 20:47 ` [PATCH v11 02/16] dt-bindings: leds: Add multicolor ID to the color ID list Dan Murphy
2019-10-08 20:47 ` [PATCH v11 03/16] " Dan Murphy
2019-10-08 20:47 ` [PATCH v11 04/16] leds: multicolor: Introduce a multicolor class definition Dan Murphy
2019-10-09 20:11 ` Bjorn Andersson
2019-10-09 20:44 ` Dan Murphy
2019-10-09 23:25 ` Bjorn Andersson
2019-10-10 0:43 ` Dan Murphy
2019-10-09 21:47 ` Jacek Anaszewski
2019-10-10 0:27 ` Dan Murphy
2019-10-10 18:36 ` Jacek Anaszewski
2019-10-10 18:37 ` Jacek Anaszewski
2019-10-08 20:47 ` [PATCH v11 05/16] dt: bindings: lp50xx: Introduce the lp50xx family of RGB drivers Dan Murphy
2019-10-08 20:47 ` [PATCH v11 06/16] leds: lp50xx: Add the LP50XX family of the RGB LED driver Dan Murphy
2019-10-08 20:47 ` [PATCH v11 07/16] dt: bindings: lp55xx: Be consistent in the document with LED acronym Dan Murphy
2019-10-08 20:47 ` [PATCH v11 08/16] dt: bindings: lp55xx: Update binding for Multicolor Framework Dan Murphy
2019-10-16 11:25 ` Linus Walleij
2019-10-08 20:47 ` [PATCH v11 09/16] ARM: dts: n900: Add reg property to the LP5523 channel node Dan Murphy
2019-10-08 20:47 ` [PATCH v11 10/16] ARM: dts: imx6dl-yapp4: Add reg property to the lp5562 " Dan Murphy
2019-10-08 20:47 ` [PATCH v11 11/16] ARM: dts: ste-href: Add reg property to the LP5521 channel nodes Dan Murphy
2019-10-16 11:24 ` Linus Walleij
2019-10-08 20:47 ` [PATCH v11 12/16] leds: lp55xx: Add multicolor framework support to lp55xx Dan Murphy
2019-10-09 22:04 ` Jacek Anaszewski
2019-10-10 0:47 ` Dan Murphy [this message]
2019-10-08 20:47 ` [PATCH v11 13/16] leds: lp5523: Update the lp5523 code to add intensity function Dan Murphy
2019-10-08 20:47 ` [PATCH v11 14/16] leds: lp5521: Add multicolor framework intensity support Dan Murphy
2019-10-08 20:47 ` [PATCH v11 15/16] leds: lp55xx: Fix checkpatch file permissions issues Dan Murphy
2019-10-08 20:48 ` [PATCH v11 16/16] leds: lp5523: Fix checkpatch issues in the code Dan Murphy
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=a5c59e36-85b9-ad90-25f8-4ac160b5b661@ti.com \
--to=dmurphy@ti.com \
--cc=jacek.anaszewski@gmail.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-leds@vger.kernel.org \
--cc=pavel@ucw.cz \
/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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®