linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Pavel Machek <pavel@ucw.cz>
To: Baolin Wang <baolin.wang@linaro.org>
Cc: sre@kernel.org, robh+dt@kernel.org, mark.rutland@arm.com,
	linux-pm@vger.kernel.org, devicetree@vger.kernel.org,
	linux-kernel@vger.kernel.org, yuanjiang.yu@unisoc.com,
	broonie@kernel.org
Subject: Re: [PATCH 5/5] power: supply: sc27xx: Save last battery capacity
Date: Sun, 25 Nov 2018 22:48:23 +0100	[thread overview]
Message-ID: <20181125214823.GB9913@amd> (raw)
In-Reply-To: <db2aa7892d7ecfae563ef22de5bbc7587ea3471f.1542185618.git.baolin.wang@linaro.org>

[-- Attachment #1: Type: text/plain, Size: 1839 bytes --]

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?

> +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.

Best regards,
									Pavel
-- 
(english) http://www.livejournal.com/~pavelmachek
(cesky, pictures) http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blog.html

[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 181 bytes --]

  reply	other threads:[~2018-11-25 21:48 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 [this message]
2018-11-26  6:18     ` Baolin Wang
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=20181125214823.GB9913@amd \
    --to=pavel@ucw.cz \
    --cc=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=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).