From: Dan Murphy <dmurphy@ti.com>
To: Brian Masney <masneyb@onstation.org>
Cc: lee.jones@linaro.org, daniel.thompson@linaro.org,
jingoohan1@gmail.com, robh+dt@kernel.org,
jacek.anaszewski@gmail.com, pavel@ucw.cz, mark.rutland@arm.com,
b.zolnierkie@samsung.com, dri-devel@lists.freedesktop.org,
linux-leds@vger.kernel.org, devicetree@vger.kernel.org,
linux-kernel@vger.kernel.org, linux-fbdev@vger.kernel.org,
jonathan@marek.ca
Subject: Re: [PATCH v5 3/3] backlight: lm3630a: add firmware node support
Date: Tue, 23 Apr 2019 14:02:51 -0500 [thread overview]
Message-ID: <f8499848-1490-cee5-c943-fa7fb77236ce@ti.com> (raw)
In-Reply-To: <20190423160019.GA10501@basecamp>
Brian
On 4/23/19 11:00 AM, Brian Masney wrote:
> On Tue, Apr 23, 2019 at 10:31:41AM -0500, Dan Murphy wrote:
>> On 4/23/19 9:01 AM, Brian Masney wrote:
>>> On Tue, Apr 23, 2019 at 08:49:20AM -0500, Dan Murphy wrote:
>>>>> +static int lm3630a_parse_led_sources(struct fwnode_handle *node,
>>>>> + int default_led_sources)
>>>>> +{
>>>>> + u32 sources[LM3630A_NUM_SINKS];
>>>>> + int ret, num_sources, i;
>>>>> +
>>>>> + num_sources = fwnode_property_read_u32_array(node, "led-sources", NULL,
>>>>> + 0);
>>>>> + if (num_sources < 0)
>>>>> + return default_led_sources;
>>>>> + else if (num_sources > ARRAY_SIZE(sources))
>>>>> + return -EINVAL;
>>>>> +
>>>>> + ret = fwnode_property_read_u32_array(node, "led-sources", sources,
>>>>> + num_sources);
>>>>> + if (ret)
>>>>> + return ret;
>>>>> +
>>>>> + for (i = 0; i < num_sources; i++) {
>>>>> + if (sources[i] < LM3630A_SINK_0 || sources[i] > LM3630A_SINK_1)
>>>>> + return -EINVAL;
>>>>> +
>>>>> + ret |= BIT(sources[i]);
>>>>> + }
>>>>> +
>>>>> + return ret;
>>>>> +}
>>>>> +
>>>>> +static int lm3630a_parse_bank(struct lm3630a_platform_data *pdata,
>>>>> + struct fwnode_handle *node, int *seen_led_sources)
>>>>
>>>> Why is seen_led_sources passed in here?
>>>> It is initialized on the stack in lm3630a_parse_node but the variable is never referenced in that API.
>>>
>>> It's to see all of the led-sources that are configured across all of the
>>> banks. If it is just in lm3630a_parse_bank(), then it won't catch the
>>> following invalid configuration:
>>>
>>
>> Ok I see what it is for now.
>>
>> Not sure why it is declared as a pointer though.
>
> It's so that lm3630a_parse_bank() can update that value with the
> led-sources that have been seen. Otherwise, the changes wouldn't make
> their way back out to the outer function.
>
OK. Thats another way to do it. I may have just done a return with the value.
Otherwise
Reviewed-by: Dan Murphy <dmurphy@ti.com>
> Brian
>
prev parent reply other threads:[~2019-04-23 19:02 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-04-18 15:11 [PATCH v5 0/3] backlight: lm3630a: bug fix and fwnode support Brian Masney
2019-04-18 15:11 ` [PATCH v5 1/3] backlight: lm3630a: return 0 on success in update_status functions Brian Masney
2019-04-18 15:11 ` [PATCH v5 2/3] dt-bindings: backlight: add lm3630a bindings Brian Masney
2019-04-24 1:52 ` Rob Herring
2019-04-18 15:11 ` [PATCH v5 3/3] backlight: lm3630a: add firmware node support Brian Masney
2019-04-23 13:49 ` Dan Murphy
2019-04-23 14:01 ` Brian Masney
2019-04-23 15:31 ` Dan Murphy
2019-04-23 16:00 ` Brian Masney
2019-04-23 19:02 ` Dan Murphy [this message]
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=f8499848-1490-cee5-c943-fa7fb77236ce@ti.com \
--to=dmurphy@ti.com \
--cc=b.zolnierkie@samsung.com \
--cc=daniel.thompson@linaro.org \
--cc=devicetree@vger.kernel.org \
--cc=dri-devel@lists.freedesktop.org \
--cc=jacek.anaszewski@gmail.com \
--cc=jingoohan1@gmail.com \
--cc=jonathan@marek.ca \
--cc=lee.jones@linaro.org \
--cc=linux-fbdev@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-leds@vger.kernel.org \
--cc=mark.rutland@arm.com \
--cc=masneyb@onstation.org \
--cc=pavel@ucw.cz \
--cc=robh+dt@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