lkml.org 
[lkml]   [2014]   [Feb]   [14]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [PATCH 08/10] leds: Add LM3633 driver
On Fri, Feb 14, 2014 at 06:32:20AM +0000, Milo Kim wrote:
> LM3633 LED driver supports generic LED functions and pattern generation.
> Pattern is generated by using LMU effect driver APIs.
> Sysfs documentation is added.
>
> Cc: Bryan Wu <cooloney@gmail.com>
> Signed-off-by: Milo Kim <milo.kim@ti.com>
> ---
> Documentation/leds/leds-lm3633.txt | 38 +++
> drivers/leds/Kconfig | 10 +
> drivers/leds/Makefile | 1 +
> drivers/leds/leds-lm3633.c | 661 ++++++++++++++++++++++++++++++++++++
> 4 files changed, 710 insertions(+)
> create mode 100644 Documentation/leds/leds-lm3633.txt
> create mode 100644 drivers/leds/leds-lm3633.c

[...]

> +static int lm3633_led_parse_dt(struct device *dev, struct ti_lmu *lmu)
> +{
> + struct ti_lmu_led_platform_data *pdata;
> + struct device_node *node = dev->of_node;
> + struct device_node *child;
> + int num_leds;
> + int i = 0;
> + u8 imax_mA;
> +
> + if (!node) {
> + dev_err(dev, "No device node exists\n");
> + return -ENODEV;
> + }
> +
> + num_leds = of_get_child_count(node);
> + if (num_leds == 0) {
> + dev_err(dev, "No LED channels\n");
> + return -EINVAL;
> + }
> +
> + pdata = devm_kzalloc(dev, sizeof(*pdata) * num_leds, GFP_KERNEL);
> + if (!pdata)
> + return -ENOMEM;
> +
> + for_each_child_of_node(node, child) {
> + of_property_read_string(child, "chan-name", &pdata[i].name);

What if this is missing from a node.?

> +
> + /* Make LED strings */
> + pdata[i].led_string = 0;
> + if (of_find_property(child, "lvled1-used", NULL))
> + pdata[i].led_string |= LMU_LVLED1;
> + if (of_find_property(child, "lvled2-used", NULL))
> + pdata[i].led_string |= LMU_LVLED2;
> + if (of_find_property(child, "lvled3-used", NULL))
> + pdata[i].led_string |= LMU_LVLED3;
> + if (of_find_property(child, "lvled4-used", NULL))
> + pdata[i].led_string |= LMU_LVLED4;
> + if (of_find_property(child, "lvled5-used", NULL))
> + pdata[i].led_string |= LMU_LVLED5;
> + if (of_find_property(child, "lvled6-used", NULL))
> + pdata[i].led_string |= LMU_LVLED6;

You can use of_property_read_bool for these.

> +
> + of_property_read_u8(child, "max-current-milliamp", &imax_mA);
> + pdata[i].imax = ti_lmu_get_current_code(imax_mA);

What happens if this is missing from a node?

Cheers,
Mark.


\
 
 \ /
  Last update: 2014-02-14 11:41    [W:0.044 / U:0.248 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site