lkml.org 
[lkml]   [2018]   [Nov]   [26]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [PATCH 5/5] power: supply: sc27xx: Save last battery capacity
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
[unhandled content-type:application/pgp-signature]
\
 
 \ /
  Last update: 2018-11-25 22:48    [W:0.079 / U:0.204 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site