From mboxrd@z Thu Jan 1 00:00:00 1970 From: Mark Rutland Subject: Re: [PATCH 08/10] leds: Add LM3633 driver Date: Fri, 14 Feb 2014 10:09:30 +0000 Message-ID: <20140214100930.GE25107@e106331-lin.cambridge.arm.com> References: <1392359540-7135-1-git-send-email-milo.kim@ti.com> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Return-path: Content-Disposition: inline In-Reply-To: <1392359540-7135-1-git-send-email-milo.kim@ti.com> Sender: linux-kernel-owner@vger.kernel.org To: Milo Kim Cc: Lee Jones , Jingoo Han , Bryan Wu , Mark Brown , "linux-kernel@vger.kernel.org" , "devicetree@vger.kernel.org" , Samuel Ortiz List-Id: devicetree@vger.kernel.org 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 > Signed-off-by: Milo Kim > --- > 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.