From: Brian Norris <briannorris@chromium.org>
To: Guenter Roeck <linux@roeck-us.net>
Cc: Sebastian Reichel <sre@kernel.org>,
linux-kernel@vger.kernel.org, Rob Herring <robh+dt@kernel.org>,
linux-pm@vger.kernel.org, devicetree@vger.kernel.org,
Rhyland Klein <rklein@nvidia.com>,
Alexandru Stan <amstan@chromium.org>,
Doug Anderson <dianders@chromium.org>
Subject: Re: [PATCH v2 1/2] power: supply: sbs-battery: don't assume MANUFACTURER_DATA formats
Date: Fri, 1 Jun 2018 11:31:28 -0700 [thread overview]
Message-ID: <20180601183126.GA72050@rodete-desktop-imager.corp.google.com> (raw)
In-Reply-To: <20180601173434.GA22509@roeck-us.net>
Hi,
On Fri, Jun 01, 2018 at 10:34:34AM -0700, Guenter Roeck wrote:
> On Fri, Jun 01, 2018 at 10:23:59AM -0700, Brian Norris wrote:
> > drivers/power/supply/sbs-battery.c | 54 +++++++++++++++++++++++++-----
> > 1 file changed, 46 insertions(+), 8 deletions(-)
> >
> > diff --git a/drivers/power/supply/sbs-battery.c b/drivers/power/supply/sbs-battery.c
> > index 83d7b4115857..8dea63464a3f 100644
> > --- a/drivers/power/supply/sbs-battery.c
> > +++ b/drivers/power/supply/sbs-battery.c
...
> > @@ -315,6 +320,27 @@ static int sbs_status_correct(struct i2c_client *client, int *intval)
> > static int sbs_get_battery_presence_and_health(
> > struct i2c_client *client, enum power_supply_property psp,
> > union power_supply_propval *val)
> > +{
> > + int ret;
> > +
> > + if (psp == POWER_SUPPLY_PROP_PRESENT) {
> > + /* Dummy command; if it succeeds, battery is present. */
> > + ret = sbs_read_word_data(client, sbs_data[REG_STATUS].addr);
> > + if (ret < 0)
> > + val->intval = 0; /* battery disconnected */
> > + else
> > + val->intval = 1; /* battery present */
> > + return 0;
> > + } else { /* POWER_SUPPLY_PROP_HEALTH */
>
> Static analyzers may complain that else after return is unnecessary.
I noticed (checkpatch complains) but decided I didn't care. It would be
worse to promote the 'else' to top-level (things would look asymmetric).
I suppose I could pull the 'return 0' out, but I'm not sure that would
make the code any better.
> Other than that
>
> Reviewed-by: Guenter Roeck <linux@roeck-us.net>
>
> > + /* SBS spec doesn't have a general health command. */
> > + val->intval = POWER_SUPPLY_HEALTH_UNKNOWN;
> > + return 0;
> > + }
> > +}
> > +
Brian
next prev parent reply other threads:[~2018-06-01 18:31 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-06-01 17:23 [PATCH v2 1/2] power: supply: sbs-battery: don't assume MANUFACTURER_DATA formats Brian Norris
2018-06-01 17:24 ` [PATCH v2 2/2] dt-bindings: power: sbs-battery: re-document "ti,bq20z75" Brian Norris
2018-06-01 17:35 ` Guenter Roeck
2018-06-01 17:34 ` [PATCH v2 1/2] power: supply: sbs-battery: don't assume MANUFACTURER_DATA formats Guenter Roeck
2018-06-01 18:31 ` Brian Norris [this message]
2018-06-01 22:08 ` Rhyland Klein
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=20180601183126.GA72050@rodete-desktop-imager.corp.google.com \
--to=briannorris@chromium.org \
--cc=amstan@chromium.org \
--cc=devicetree@vger.kernel.org \
--cc=dianders@chromium.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-pm@vger.kernel.org \
--cc=linux@roeck-us.net \
--cc=rklein@nvidia.com \
--cc=robh+dt@kernel.org \
--cc=sre@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