From: Marek Behun <marek.behun@nic.cz>
To: Dan Murphy <dmurphy@ti.com>
Cc: <linux-leds@vger.kernel.org>, Pavel Machek <pavel@ucw.cz>
Subject: Re: [PATCH leds v3 2/9] leds: lm36274: don't iterate through children since there is only one
Date: Tue, 22 Sep 2020 17:58:56 +0200 [thread overview]
Message-ID: <20200922175856.7efeb161@nic.cz> (raw)
In-Reply-To: <a2db44c8-9153-3b0e-b3fe-cb96821116ab@ti.com>
On Tue, 22 Sep 2020 10:42:49 -0500
Dan Murphy <dmurphy@ti.com> wrote:
> Hello
>
> On 9/19/20 1:02 PM, Marek Behún wrote:
> > Do not use device_for_each_child_node. Since this driver works only with
> > once child node present, use device_get_next_child_node instead.
> > This also saves one level of indentation.
> >
> > Signed-off-by: Marek Behún <marek.behun@nic.cz>
> > Cc: Dan Murphy <dmurphy@ti.com>
> > ---
> > drivers/leds/leds-lm36274.c | 50 +++++++++++++++++--------------------
> > 1 file changed, 23 insertions(+), 27 deletions(-)
> >
> > diff --git a/drivers/leds/leds-lm36274.c b/drivers/leds/leds-lm36274.c
> > index 4a9f786bb9727..e0fce74a76675 100644
> > --- a/drivers/leds/leds-lm36274.c
> > +++ b/drivers/leds/leds-lm36274.c
> > @@ -72,40 +72,36 @@ static int lm36274_parse_dt(struct lm36274 *chip)
> > char label[LED_MAX_NAME_SIZE];
> > struct device *dev = &chip->pdev->dev;
> > const char *name;
> > - int child_cnt;
> > - int ret = -EINVAL;
> > + int ret;
> >
> > /* There should only be 1 node */
> > - child_cnt = device_get_child_node_count(dev);
> > - if (child_cnt != 1)
> > + if (device_get_child_node_count(dev) != 1)
> > return -EINVAL;
> >
> > - device_for_each_child_node(dev, child) {
> > - ret = fwnode_property_read_string(child, "label", &name);
> > - if (ret)
> > - snprintf(label, sizeof(label), "%s::",
> > - chip->pdev->name);
> > - else
> > - snprintf(label, sizeof(label), "%s:%s",
> > - chip->pdev->name, name);
> > -
> > - chip->num_leds = fwnode_property_count_u32(child, "led-sources");
> > - if (chip->num_leds <= 0)
> > - return -ENODEV;
> > -
> > - ret = fwnode_property_read_u32_array(child, "led-sources",
> > - chip->led_sources,
> > - chip->num_leds);
> > - if (ret) {
> > - dev_err(dev, "led-sources property missing\n");
> > - return ret;
> > - }
> > -
> > - fwnode_property_read_string(child, "linux,default-trigger",
> > - &chip->led_dev.default_trigger);
> > + child = device_get_next_child_node(dev, NULL);
> > +
> > + ret = fwnode_property_read_string(child, "label", &name);
> > + if (ret)
> > + snprintf(label, sizeof(label), "%s::", chip->pdev->name);
> > + else
> > + snprintf(label, sizeof(label), "%s:%s", chip->pdev->name, name);
> >
> > + chip->num_leds = fwnode_property_count_u32(child, "led-sources");
> > + if (chip->num_leds <= 0)
> > + return -ENODEV;
> > +
> > + ret = fwnode_property_read_u32_array(child, "led-sources",
> > + chip->led_sources, chip->num_leds);
> > + if (ret) {
> > + dev_err(dev, "led-sources property missing\n");
> > + return ret;
> > }
> >
> > + fwnode_property_read_string(child, "linux,default-trigger",
> > + &chip->led_dev.default_trigger);
> > +
> > + fwnode_handle_put(child);
> > +
> > chip->lmu_data.regmap = chip->regmap;
> > chip->lmu_data.max_brightness = MAX_BRIGHTNESS_11BIT;
> > chip->lmu_data.msb_brightness_reg = LM36274_REG_BRT_MSB;
>
> Question is this device on a piece of hardware you are testing on?
No, unfortunately. But this driver is rather simple, in comparison to
the others.
As Linus said:
"If it compiles, it is good; if it boots up, it is perfect."
:D
So if someone tested it, it would be perfect.
Marek
> Just wondering how you functionally tested all these changes you submitted
>
> Reviewed-by: Dan Murphy <dmurphy@ti.com>
>
next prev parent reply other threads:[~2020-09-22 15:59 UTC|newest]
Thread overview: 23+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-09-19 18:02 [PATCH leds v3 0/9] Start moving parsing of `linux,default-trigger` to LED core (a cleanup of LED drivers) Marek Behún
2020-09-19 18:02 ` [PATCH leds v3 1/9] leds: lm36274: cosmetic: rename lm36274_data to chip Marek Behún
2020-09-22 15:39 ` Dan Murphy
2020-09-22 16:32 ` Pavel Machek
2020-09-19 18:02 ` [PATCH leds v3 2/9] leds: lm36274: don't iterate through children since there is only one Marek Behún
2020-09-22 15:42 ` Dan Murphy
2020-09-22 15:58 ` Marek Behun [this message]
2020-09-22 19:12 ` Dan Murphy
2020-09-19 18:02 ` [PATCH leds v3 3/9] leds: lm36274: use struct led_init_data when registering Marek Behún
2020-09-24 12:06 ` Pavel Machek
2020-09-19 18:02 ` [PATCH leds v3 4/9] leds: lm36274: do not set chip settings in DT parsing function Marek Behún
2020-09-19 18:03 ` [PATCH leds v3 5/9] leds: lm36274: use platform device as parent of LED Marek Behún
2020-09-19 18:03 ` [PATCH leds v3 6/9] leds: lm36274: use devres LED registering function Marek Behún
2020-09-20 21:45 ` Pavel Machek
2020-09-20 21:54 ` Marek Behun
2020-09-22 16:38 ` Pavel Machek
2020-09-22 16:58 ` Marek Behun
2020-09-22 19:09 ` Dan Murphy
2020-09-19 18:03 ` [PATCH leds v3 7/9] leds: lm3532: don't parse label DT property Marek Behún
2020-09-19 18:03 ` [PATCH leds v3 8/9] leds: syscon: use struct led_init_data when registering Marek Behún
2020-09-29 13:17 ` Linus Walleij
2020-09-19 18:03 ` [PATCH leds v3 9/9] leds: parse linux,default-trigger DT property in LED core Marek Behún
2020-09-24 12:10 ` Pavel Machek
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=20200922175856.7efeb161@nic.cz \
--to=marek.behun@nic.cz \
--cc=dmurphy@ti.com \
--cc=linux-leds@vger.kernel.org \
--cc=pavel@ucw.cz \
/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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.