Re: [PATCH v14 13/19] leds: lp55xx: Add multicolor framework support to lp55xx

From: Jacek Anaszewski
Date: Tue Oct 22 2019 - 13:41:57 EST


Dan,

On 10/22/19 6:37 PM, Dan Murphy wrote:
> Jacek
>
> On 10/18/19 4:56 PM, Jacek Anaszewski wrote:
>> On 10/18/19 11:48 PM, Jacek Anaszewski wrote:
>>> Dan,
>> +ÂÂÂÂÂÂÂ ret = lp5xx_parse_channel_child(child, cfg, i);
>>> I went into details of this parsing and finally came up with
>>> the code which is a bit greater in size, but IMHO cleaner.
>>> Note changes in variable naming. It is not even compile-tested.
>>>
>>> static int lp55xx_parse_common_child(struct device_node *np,
>>> ÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂ struct lp55xx_led_config *cfg,
>>> ÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂ int led_number, int *chan_nr)
>>> {
>>> ÂÂÂÂÂÂÂÂ int ret;
>>>
>>> ÂÂÂÂÂÂÂÂ of_property_read_string(np, "chan-name",
>>> ÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂ &cfg[led_number].name);
>>> ÂÂÂÂÂÂÂÂ of_property_read_u8(np, "led-cur",
>>> ÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂ &cfg[led_number].led_current);
>>> ÂÂÂÂÂÂÂÂ of_property_read_u8(np, "max-cur",
>>> ÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂ &cfg[led_number].max_current);
>>>
>>> ÂÂÂÂÂÂÂÂ ret = of_property_read_u32(np, "reg", chan_nr);
>>> ÂÂÂÂÂÂÂÂ if (ret)
>>> ÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂ return ret;
>>>
>>> ÂÂÂÂÂÂÂÂ if (chan_nr < 0 || chan_nr > cfg->max_chan_nr) /* side note:
>>> new
>>> max_chan_nr property needed in cfg */
>>> ÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂ return -EINVAL;
>>>
>>> ÂÂÂÂÂÂÂÂ return 0;
>>> }
>>>
>>> static int lp55xx_parse_mutli_led_child(struct device_node *np,
>>> ÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂ struct lp55xx_led_config *cfg,
>>> ÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂ int child_number,
>>> ÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂ int color_number)
>>> {
>>> ÂÂÂÂÂÂÂÂ int chan_nr, color_id;
>>>
>>> ÂÂÂÂÂÂÂÂ ret = lp55xx_parse_common_child(child, cfg, child_number,
>>> color_number,
>>> ÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂ &chan_nr);
>>> ÂÂÂÂÂÂÂÂ if (ret)
>>> ÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂ return ret;
>>>
>>> ÂÂÂÂÂÂÂÂ ret = of_property_read_u32(child, "color", &color_id);
>>> ÂÂÂÂÂÂÂÂ if (ret)
>>> ÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂ return ret;
>>>
>>> ÂÂÂÂÂÂÂÂ cfg[child_number].color_components[color_number].color_id =
>>> color_id;
>>> ÂÂÂÂÂÂÂÂ cfg[child_number].color_components[color_number].output_num =
>>> chan_nr;
>>> ÂÂÂÂÂÂÂÂ set_bit(color_id, &cfg[child_number].available_colors);
>>>
>>> ÂÂÂÂÂÂÂÂ return 0;
>>> }
>>>
>>> staitc int lp55xx_parse_mutli_led(struct device_node *np,
>>> ÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂ struct lp55xx_led_config *cfg,
>>> ÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂ int child_number)
>>> {
>>> ÂÂÂÂÂÂÂÂ struct device_node *child;
>>> ÂÂÂÂÂÂÂÂ int num_colors = 0, i = 0;
>> s/, i = 0//
>>
>>> ÂÂÂÂÂÂÂÂ for_each_child_of_node(np, child) {
>>> ÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂ ret = lp55xx_parse_mutli_led_child(child, cfg,
>>> num_colors,
>>> ÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂ child_number, i))
>> Replace above call with below:
>>
>> ret = lp55xx_parse_mutli_led_child(child, cfg, child_number, num_colors);
>>
> I applied your DT parser patch from the v13 series. Which eliminates
> this comment correct?

Yes, it contains this fix.

--
Best regards,
Jacek Anaszewski