From: Stephen Warren <swarren-3lzwWm7+Weoh9ZMKESR00Q@public.gmane.org>
To: Rhyland Klein <rklein-DDmLM1+adcrQT0dZR+AlfA@public.gmane.org>
Cc: Grant Likely
<grant.likely-s3s/WqlpOiPyB63q8FvJNQ@public.gmane.org>,
Anton Vorontsov <cbou-JGs/UdohzUI@public.gmane.org>,
David Woodhouse <dwmw2-wEGCiKHe2LqWVfeAwA7xHQ@public.gmane.org>,
devicetree-discuss-uLR06cmDAlY/bJ5BZ2RsiQ@public.gmane.org,
linux-kernel-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
linux-tegra-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
Subject: Re: [REPOST Patch v1 2/3] power: power_supply: Add core support for supplied_from
Date: Wed, 27 Mar 2013 10:30:10 -0600 [thread overview]
Message-ID: <51531E92.9070805@wwwdotorg.org> (raw)
In-Reply-To: <1364264690-2124-3-git-send-email-rklein-DDmLM1+adcrQT0dZR+AlfA@public.gmane.org>
On 03/25/2013 08:24 PM, Rhyland Klein wrote:
> This patch adds support for supplies to register a list of char *'s
> which represent the list of supplies which supply them. This is the
> opposite as the supplied_to list.
>
> This change maintains support for supplied_to until all drivers which
> make use of it already are converted.
> diff --git a/drivers/power/power_supply_core.c b/drivers/power/power_supply_core.c
> +static int __power_supply_is_supplied_by(struct power_supply *supplier,
> + struct power_supply *supply)
Shouldn't this function return a Boolean since it's "is" something? At
least, 1 for yes 0 for no would be more comprehensible than 0 for yes
and error for no?
> +{
> + int i;
> +
> + if (!supply->supplied_from && !supplier->supplied_to)
> + return -EINVAL;
> +
> + /* Support both supplied_to and supplied_from modes */
> + if (supply->supplied_from) {
> + for (i = 0; i < supply->num_supplies; i++) {
> + if (!supplier->name)
> + continue;
That test is loop invariant. Why put it inside the loop?
Why wouldn't a supply have a name? The loop in
__power_supply_changed_work() that this function replaces doesn't test
for NULL names.
> + if (!strcmp(supplier->name, supply->supplied_from[i]))
> + return 0;
Don't you want to return something true here, so that the if block
inside __power_supply_changed_work() is executed in this case?
Similar comment for the else block.
> static int __power_supply_changed_work(struct device *dev, void *data)
> - for (i = 0; i < psy->num_supplicants; i++)
> - if (!strcmp(psy->supplied_to[i], pst->name)) {
> - if (pst->external_power_changed)
> - pst->external_power_changed(pst);
> - }
> + if (__power_supply_is_supplied_by(psy, pst)) {
> + if (pst->external_power_changed)
> + pst->external_power_changed(pst);
> + }
> +
> return 0;
> }
next prev parent reply other threads:[~2013-03-27 16:30 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-03-26 2:24 [REPOST Patch v1 0/3] Add DT Binding for Power-Supply power-supplies property Rhyland Klein
[not found] ` <1364264690-2124-1-git-send-email-rklein-DDmLM1+adcrQT0dZR+AlfA@public.gmane.org>
2013-03-26 2:24 ` [REPOST Patch v1 1/3] power_supply: Define Binding for power-supplies Rhyland Klein
2013-03-26 2:24 ` [REPOST Patch v1 2/3] power: power_supply: Add core support for supplied_from Rhyland Klein
[not found] ` <1364264690-2124-3-git-send-email-rklein-DDmLM1+adcrQT0dZR+AlfA@public.gmane.org>
2013-03-27 16:30 ` Stephen Warren [this message]
[not found] ` <51531E92.9070805-3lzwWm7+Weoh9ZMKESR00Q@public.gmane.org>
2013-03-27 21:12 ` Rhyland Klein
2013-03-26 2:24 ` [REPOST Patch v1 3/3] power: power_supply_core: Add " Rhyland Klein
[not found] ` <1364264690-2124-4-git-send-email-rklein-DDmLM1+adcrQT0dZR+AlfA@public.gmane.org>
2013-03-30 22:41 ` Anton Vorontsov
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=51531E92.9070805@wwwdotorg.org \
--to=swarren-3lzwwm7+weoh9zmkesr00q@public.gmane.org \
--cc=cbou-JGs/UdohzUI@public.gmane.org \
--cc=devicetree-discuss-uLR06cmDAlY/bJ5BZ2RsiQ@public.gmane.org \
--cc=dwmw2-wEGCiKHe2LqWVfeAwA7xHQ@public.gmane.org \
--cc=grant.likely-s3s/WqlpOiPyB63q8FvJNQ@public.gmane.org \
--cc=linux-kernel-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
--cc=linux-tegra-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
--cc=rklein-DDmLM1+adcrQT0dZR+AlfA@public.gmane.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).