lkml.org 
[lkml]   [2019]   [Jun]   [6]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [PATCH v6 5/5] leds: lm36274: Introduce the TI LM36274 LED driver
Hi!

> Introduce the LM36274 LED driver. This driver uses the ti-lmu
> MFD driver to probe this LED driver. The driver configures only the
> LED registers and enables the outputs according to the config file.
>
> The driver utilizes the TI LMU (Lighting Management Unit) LED common
> framework to set the brightness bits.

Nothing too bad, but...

> +static int lm36274_parse_dt(struct lm36274 *lm36274_data)
> +{
> + struct fwnode_handle *child = NULL;
> + char label[LED_MAX_NAME_SIZE];
> + struct device *dev = &lm36274_data->pdev->dev;
> + const char *name;
> + int child_cnt;
> + int ret = -EINVAL;
> +
> + /* There should only be 1 node */
> + child_cnt = device_get_child_node_count(dev);
> + if (child_cnt != 1)
> + return ret;

I'd do direct "return -EINVAL" here.

> + device_for_each_child_node(dev, child) {
> + ret = fwnode_property_read_string(child, "label", &name);
> + if (ret)
> + snprintf(label, sizeof(label),
> + "%s::", lm36274_data->pdev->name);
> + else
> + snprintf(label, sizeof(label),
> + "%s:%s", lm36274_data->pdev->name, name);
> +
> + lm36274_data->num_leds = fwnode_property_read_u32_array(child,
> + "led-sources",
> + NULL, 0);
> + if (lm36274_data->num_leds <= 0)
> + return -ENODEV;
> +
> + ret = fwnode_property_read_u32_array(child, "led-sources",
> + lm36274_data->led_sources,
> + lm36274_data->num_leds);
> + if (ret) {
> + dev_err(dev, "led-sources property missing\n");
> + return -EINVAL;

Should it return ret here? If read array failed with -ENOMEM, we may
want to propagate that.

> + }
> +
> + fwnode_property_read_string(child, "linux,default-trigger",
> + &lm36274_data->led_dev.default_trigger);
> +
> + }
> +
> + lm36274_data->lmu_data.regmap = lm36274_data->regmap;
> + lm36274_data->lmu_data.max_brightness = MAX_BRIGHTNESS_11BIT;
> + lm36274_data->lmu_data.msb_brightness_reg = LM36274_REG_BRT_MSB;
> + lm36274_data->lmu_data.lsb_brightness_reg = LM36274_REG_BRT_LSB;
> +
> + lm36274_data->led_dev.name = label;
> + lm36274_data->led_dev.max_brightness = MAX_BRIGHTNESS_11BIT;
> + lm36274_data->led_dev.brightness_set_blocking = lm36274_brightness_set;
> +
> + return ret;

I'd do "return 0" here. It is success. Yes, ret will always have that
value at this moment, but...

> +static int lm36274_probe(struct platform_device *pdev)
> +{
> + struct ti_lmu *lmu = dev_get_drvdata(pdev->dev.parent);
> + struct lm36274 *lm36274_data;
> + int ret;
> +
> + lm36274_data = devm_kzalloc(&pdev->dev, sizeof(*lm36274_data),
> + GFP_KERNEL);
> + if (!lm36274_data) {
> + ret = -ENOMEM;
> + return ret;
> + }

Just do return -ENOMEM;

Acked-by: Pavel Machek <pavel@ucw.cz>
Pavel
--
(english) http://www.livejournal.com/~pavelmachek
(cesky, pictures) http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blog.html
[unhandled content-type:application/pgp-signature]
\
 
 \ /
  Last update: 2019-06-06 12:08    [W:0.162 / U:0.040 seconds]
©2003-2018 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site