From: Pavel Machek <pavel@ucw.cz>
To: Dan Murphy <dmurphy@ti.com>
Cc: jacek.anaszewski@gmail.com, broonie@kernel.org,
lgirdwood@gmail.com, lee.jones@linaro.org,
linux-leds@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH v6 5/5] leds: lm36274: Introduce the TI LM36274 LED driver
Date: Thu, 6 Jun 2019 12:07:06 +0200 [thread overview]
Message-ID: <20190606100706.GA1825@amd> (raw)
In-Reply-To: <20190605125634.7042-6-dmurphy@ti.com>
[-- Attachment #1: Type: text/plain, Size: 2941 bytes --]
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
[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 181 bytes --]
next prev parent reply other threads:[~2019-06-06 10:07 UTC|newest]
Thread overview: 18+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-06-05 12:56 [PATCH v6 0/5] LM36274 Introduction Dan Murphy
2019-06-05 12:56 ` [PATCH v6 1/5] dt-bindings: mfd: Add lm36274 bindings to ti-lmu Dan Murphy
2019-06-05 12:56 ` [PATCH v6 2/5] mfd: ti-lmu: Add LM36274 support to the ti-lmu Dan Murphy
2019-06-06 9:52 ` Pavel Machek
2019-06-05 12:56 ` [PATCH v6 3/5] regulator: lm363x: Add support for LM36274 Dan Murphy
2019-06-05 18:17 ` Mark Brown
2019-06-06 9:53 ` Pavel Machek
2019-06-05 12:56 ` [PATCH v6 4/5] dt-bindings: leds: Add LED bindings for the LM36274 Dan Murphy
2019-06-06 10:01 ` Pavel Machek
2019-06-05 12:56 ` [PATCH v6 5/5] leds: lm36274: Introduce the TI LM36274 LED driver Dan Murphy
2019-06-06 10:07 ` Pavel Machek [this message]
2019-06-06 10:07 ` Pavel Machek
2019-06-06 11:25 ` Dan Murphy
2019-06-05 19:31 ` [PATCH v6 0/5] LM36274 Introduction Jacek Anaszewski
2019-06-11 12:17 ` Dan Murphy
2019-06-24 14:42 ` Lee Jones
2019-06-24 17:20 ` Dan Murphy
2019-06-25 6:30 ` Lee Jones
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20190606100706.GA1825@amd \
--to=pavel@ucw.cz \
--cc=broonie@kernel.org \
--cc=dmurphy@ti.com \
--cc=jacek.anaszewski@gmail.com \
--cc=lee.jones@linaro.org \
--cc=lgirdwood@gmail.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-leds@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).