From: Krzysztof Kozlowski <k.kozlowski@samsung.com>
To: Vladimir Barinov <vladimir.barinov@cogentembedded.com>
Cc: anton@enomsg.org, dwmw2@infradead.org,
linux-kernel@vger.kernel.org, devicetree@vger.kernel.org,
mk7.kang@samsung.com, mark.rutland@arm.com
Subject: Re: [PATCH v2 1/3] power_supply: modelgauge_battery: Maxim ModelGauge ICs gauge
Date: Tue, 04 Mar 2014 13:05:48 +0100 [thread overview]
Message-ID: <1393934748.1222.10.camel@AMDC1943> (raw)
In-Reply-To: <1391293385-27539-2-git-send-email-vladimir.barinov@cogentembedded.com>
And one more comment:
On Sun, 2014-02-02 at 02:23 +0400, Vladimir Barinov wrote:
> +static int modelgauge_get_property(struct power_supply *psy,
> + enum power_supply_property psp,
> + union power_supply_propval *val)
> +{
> + struct modelgauge_priv *priv = container_of(psy,
> + struct modelgauge_priv,
> + battery);
> + struct regmap *regmap = priv->regmap;
> + struct modelgauge_platform_data *pdata = priv->pdata;
> + int reg;
> + int ret;
> +
> + switch (psp) {
> + case POWER_SUPPLY_PROP_STATUS:
> + if (pdata && pdata->get_charging_status)
> + val->intval = pdata->get_charging_status();
> + else
> + val->intval = POWER_SUPPLY_STATUS_UNKNOWN;
> + break;
> + case POWER_SUPPLY_PROP_VOLTAGE_NOW:
> + ret = regmap_read(regmap, MODELGAUGE_VCELL_REG, ®);
> + if (ret < 0)
> + return ret;
> +
> + val->intval = modelgauge_lsb_to_uvolts(priv, reg);
> + break;
> + case POWER_SUPPLY_PROP_VOLTAGE_OCV:
> + /* Unlock model access */
> + regmap_write(regmap, MODELGAUGE_UNLOCK_REG,
> + MODELGAUGE_UNLOCK_VALUE);
> + ret = regmap_read(regmap, MODELGAUGE_OCV_REG, ®);
> + /* Lock model access */
> + regmap_write(regmap, MODELGAUGE_UNLOCK_REG, 0);
> + if (ret < 0)
> + return ret;
> +
> + val->intval = modelgauge_lsb_to_uvolts(priv, reg);
> + break;
> + case POWER_SUPPLY_PROP_CAPACITY:
> + ret = regmap_read(regmap, MODELGAUGE_SOC_REG, ®);
> + if (ret < 0)
> + return ret;
> +
> + val->intval = reg / (1 << priv->soc_shift);
> + break;
> + case POWER_SUPPLY_PROP_TEMP:
> + if (pdata && pdata->get_temperature)
> + val->intval = pdata->get_temperature();
> + else
> + val->intval = 25;
If pdata->get_temperature() is not supplied then probably the driver
should not support POWER_SUPPLY_PROP_TEMP at all. I think it is better
not to report any temperature than to report a wrong one.
Best regards,
Krzysztof
next prev parent reply other threads:[~2014-03-04 12:05 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-02-01 22:23 [PATCH v2 0/3] power_supply: modelgauge_battery: Add Maxim ModelGauge ICs gauge Vladimir Barinov
2014-02-01 22:23 ` [PATCH v2 1/3] power_supply: modelgauge_battery: " Vladimir Barinov
2014-03-04 10:48 ` Krzysztof Kozlowski
2014-03-04 12:05 ` Krzysztof Kozlowski [this message]
2014-02-01 22:23 ` [PATCH v2 2/3] dt: Document ModelGauge gauge bindings Vladimir Barinov
2014-02-01 22:23 ` [PATCH v2 3/3] power_supply: modelgauge_battery: Remove Maxim MAX17040 gauge Vladimir Barinov
2014-02-26 10:21 ` [PATCH v2 0/3] power_supply: modelgauge_battery: Add Maxim ModelGauge ICs gauge Vladimir Barinov
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=1393934748.1222.10.camel@AMDC1943 \
--to=k.kozlowski@samsung.com \
--cc=anton@enomsg.org \
--cc=devicetree@vger.kernel.org \
--cc=dwmw2@infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=mark.rutland@arm.com \
--cc=mk7.kang@samsung.com \
--cc=vladimir.barinov@cogentembedded.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).