lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <c9a704d4-b411-59f1-02bf-3ea7b219c4b4@gmail.com>
Date:   Fri, 18 Oct 2019 23:56:38 +0200
From:   Jacek Anaszewski <jacek.anaszewski@...il.com>
To:     Dan Murphy <dmurphy@...com>, pavel@....cz
Cc:     linux-leds@...r.kernel.org, linux-kernel@...r.kernel.org
Subject: Re: [PATCH v14 13/19] leds: lp55xx: Add multicolor framework support
 to lp55xx


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);

>                 if (ret)
>                         return ret;
>                 num_colors++;
>         }
> }
> 
> static int lp5xx_parse_logical_led(struct device_node *np,
>                                    struct lp55xx_led_config *cfg,
>                                    int child_number)
> {
>         int led_color, ret;
> 
>         cfg[child_number].default_trigger =
>                 of_get_property(np, "linux,default-trigger", NULL);
> 
>         ret = of_property_read_u32(np, "color", &led_color);
> 
>         if (ret) {
>                 int chan_nr;
>                 ret =  lp55xx_parse_common_child(np, cfg, child_number,
>                                                  &chan_nr);
>                 if (ret < 0)
>                        return ret;
>                 cfg[child_number].chan_nr = chan_nr;
>         } else if (led_color == LED_COLOR_ID_MULTI) {
>                 return lp55xx_parse_mutli_led(np, cfg, child_number);
>         } else
>                 return ret;
> 
>         return 0;
> }
> 
> 
> for_each_child_of_node(np, child) {
>         ret = lp55xx_parse_logical_led(child, cfg, i);
>         if (ret)
>                 return ERR_PTR(-EINVAL);
>         i++;
> }
> 
> 

-- 
Best regards,
Jacek Anaszewski

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ