linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Baolin Wang <baolin.wang@linaro.org>
To: Pavel Machek <pavel@ucw.cz>
Cc: Sebastian Reichel <sre@kernel.org>,
	Rob Herring <robh+dt@kernel.org>,
	Mark Rutland <mark.rutland@arm.com>,
	Linux PM list <linux-pm@vger.kernel.org>,
	DTML <devicetree@vger.kernel.org>,
	LKML <linux-kernel@vger.kernel.org>,
	yuanjiang.yu@unisoc.com, Mark Brown <broonie@kernel.org>
Subject: Re: [PATCH 5/5] power: supply: sc27xx: Save last battery capacity
Date: Mon, 26 Nov 2018 14:18:27 +0800	[thread overview]
Message-ID: <CAMz4kuJ+7J+MYh02YhP9j8Tf6ntdL6tOLiJO6yN0a4Qot4t4Jg@mail.gmail.com> (raw)
In-Reply-To: <20181125214823.GB9913@amd>

Hi Pavel,
On Mon, 26 Nov 2018 at 05:48, Pavel Machek <pavel@ucw.cz> wrote:
>
> Hi!
>
> > Our charger manager can optimize the battery capacity periodically, so
> > we can save last battery capacity into registers. Then next system
> > power-on, we can read the last saved battery capacity as the initial
> > battery capacity, which can make the battery capacity more accurate.
> >
> > Signed-off-by: Yuanjiang Yu <yuanjiang.yu@unisoc.com>
> > Signed-off-by: Baolin Wang <baolin.wang@linaro.org>
> > ---
> >  drivers/power/supply/sc27xx_fuel_gauge.c |  143 +++++++++++++++++++++++++++++-
> >  1 file changed, 142 insertions(+), 1 deletion(-)
> >
>
> > +static int sc27xx_fgu_set_property(struct power_supply *psy,
> > +                                enum power_supply_property psp,
> > +                                const union power_supply_propval *val)
> > +{
> > +     struct sc27xx_fgu_data *data = power_supply_get_drvdata(psy);
> > +     int ret;
> > +
> > +     mutex_lock(&data->lock);
> > +
> > +     switch (psp) {
> > +     case POWER_SUPPLY_PROP_CAPACITY:
> > +             ret = sc27xx_fgu_save_last_cap(data, val->intval);
> > +             if (ret < 0)
> > +                     dev_err(data->dev, "failed to save battery capacity\n");
> > +             break;
> > +
> > +     default:
> > +             ret = -EINVAL;
> > +     }
> > +
> > +     mutex_unlock(&data->lock);
> > +     return ret;
>
> if (psp != ....) return -EINVAL; And you can do that outside
> lock...
>
> Ok, OTOH this is easier to extend in future. Do you expect more
> writable properties?

Until now I think there are no writable properties, I think I can
change it like you suggested.

>
> > +static int sc27xx_fgu_property_is_writeable(struct power_supply *psy,
> > +                                         enum power_supply_property psp)
> > +{
> > +     switch (psp) {
> > +     case POWER_SUPPLY_PROP_CAPACITY:
> > +             return 1;
> > +
> > +     default:
> > +             return 0;
> > +     }
> > +}
>
>
> Same here. return psp == POWER_SUPPLY_PROP_CAPACITY; really looks
> strange written like this.

Sure. Thanks.

-- 
Baolin Wang
Best Regards

  reply	other threads:[~2018-11-26  6:18 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-11-14  9:07 [PATCH 0/5] Add new features for SC27XX fuel gauge driver Baolin Wang
2018-11-14  9:07 ` [PATCH 1/5] dt-bindings: power: supply: Add nvmem properties to calibrate FGU Baolin Wang
2018-12-04 21:09   ` Rob Herring
2018-11-14  9:07 ` [PATCH 2/5] power: supply: sc27xx: Add fuel gauge calibration Baolin Wang
2018-11-14  9:07 ` [PATCH 3/5] power: supply: sc27xx: Add fuel gauge low voltage alarm Baolin Wang
2018-11-25 21:45   ` Pavel Machek
2018-11-26  6:15     ` Baolin Wang
2018-11-14  9:07 ` [PATCH 4/5] power: supply: sc27xx: Add suspend/resume interfaces Baolin Wang
2018-11-14  9:07 ` [PATCH 5/5] power: supply: sc27xx: Save last battery capacity Baolin Wang
2018-11-25 21:48   ` Pavel Machek
2018-11-26  6:18     ` Baolin Wang [this message]
2018-12-06  0:10 ` [PATCH 0/5] Add new features for SC27XX fuel gauge driver Sebastian Reichel
2018-12-06  2:57   ` Baolin Wang

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=CAMz4kuJ+7J+MYh02YhP9j8Tf6ntdL6tOLiJO6yN0a4Qot4t4Jg@mail.gmail.com \
    --to=baolin.wang@linaro.org \
    --cc=broonie@kernel.org \
    --cc=devicetree@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-pm@vger.kernel.org \
    --cc=mark.rutland@arm.com \
    --cc=pavel@ucw.cz \
    --cc=robh+dt@kernel.org \
    --cc=sre@kernel.org \
    --cc=yuanjiang.yu@unisoc.com \
    /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).