Dan,max_channel is never set so not sure where that is supposed to come from since each child device has different number of channels. And if the user has to populate that information from the DT then it does not make sense as the user would already be aware of the number of channels. This information would have to come from the child device some how and the children do not have access to the structure to set it.
On 10/25/19 7:57 PM, Dan Murphy wrote:
JacekLet me test that with Qemu first.
On 10/22/19 12:41 PM, Jacek Anaszewski wrote:
Dan,OK I added your patch and it broke a lot of the DT parsing for the LP55xx.
On 10/22/19 6:37 PM, Dan Murphy wrote:
JacekYes, it contains this fix.
On 10/18/19 4:56 PM, Jacek Anaszewski wrote:
On 10/18/19 11:48 PM, Jacek Anaszewski wrote:I applied your DT parser patch from the v13 series. Which eliminates
Dan,+ÂÂÂÂÂÂÂ ret = lp5xx_parse_channel_child(child, cfg, i);
I went into details of this parsing and finally came up withs/, i = 0//
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;
ÂÂÂÂÂÂÂÂÂ for_each_child_of_node(np, child) {Replace above call with below:
ÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂ ret = lp55xx_parse_mutli_led_child(child, cfg,
num_colors,
ÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂ child_number, i))
ret = lp55xx_parse_mutli_led_child(child, cfg, child_number,
num_colors);
this comment correct?
I would prefer to stick with the original code without having to
re-write this again.