Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > linux.kernel > #1665079 > unrolled thread
| Started by | Shawn Nematbakhsh <shawnn@chromium.org> |
|---|---|
| First post | 2017-06-13 20:00 +0200 |
| Last post | 2017-06-15 18:50 +0200 |
| Articles | 3 — 3 participants |
Back to article view | Back to linux.kernel
This discussion starts older than the indexed window; earlier articles aren't shown. The article labeled Started by
below is the oldest one visible, not the original post.
[PATCH 2/2] power: supply: sbs-battery: Don't needlessly set CAPACITY_MODE Shawn Nematbakhsh <shawnn@chromium.org> - 2017-06-13 20:00 +0200
Re: [PATCH 2/2] power: supply: sbs-battery: Don't needlessly set CAPACITY_MODE Guenter Roeck <groeck@google.com> - 2017-06-13 20:20 +0200
Re: [PATCH 2/2] power: supply: sbs-battery: Don't needlessly set CAPACITY_MODE Sebastian Reichel <sebastian.reichel@collabora.co.uk> - 2017-06-15 18:50 +0200
| From | Shawn Nematbakhsh <shawnn@chromium.org> |
|---|---|
| Date | 2017-06-13 20:00 +0200 |
| Subject | [PATCH 2/2] power: supply: sbs-battery: Don't needlessly set CAPACITY_MODE |
| Message-ID | <tRYgG-2x8-27@gated-at.bofh.it> |
According to the smart battery spec (1), the CAPACITY_MODE bit does not
influence the value read from RelativeStateOfCharge(), so don't bother
changing CAPACITY_MODE when doing such a read.
(1) - Smart Battery Data Specification, Rev 1.1, Dec. 11, 1998
Signed-off-by: Shawn Nematbakhsh <shawnn@chromium.org>
---
drivers/power/supply/sbs-battery.c | 14 +++++++-------
1 file changed, 7 insertions(+), 7 deletions(-)
diff --git a/drivers/power/supply/sbs-battery.c b/drivers/power/supply/sbs-battery.c
index d7e68fd97099..4bae210d5a8a 100644
--- a/drivers/power/supply/sbs-battery.c
+++ b/drivers/power/supply/sbs-battery.c
@@ -439,6 +439,11 @@ static int sbs_get_battery_property(struct i2c_client *client,
} else {
if (psp == POWER_SUPPLY_PROP_STATUS)
val->intval = POWER_SUPPLY_STATUS_UNKNOWN;
+ else if (psp == POWER_SUPPLY_PROP_CAPACITY)
+ /* sbs spec says that this can be >100 %
+ * even if max value is 100 %
+ */
+ val->intval = min(ret, 100);
else
val->intval = 0;
}
@@ -549,12 +554,7 @@ static int sbs_get_battery_capacity(struct i2c_client *client,
if (ret < 0)
return ret;
- if (psp == POWER_SUPPLY_PROP_CAPACITY) {
- /* sbs spec says that this can be >100 %
- * even if max value is 100 % */
- val->intval = min(ret, 100);
- } else
- val->intval = ret;
+ val->intval = ret;
ret = sbs_set_battery_mode(client, mode);
if (ret < 0)
@@ -619,7 +619,6 @@ static int sbs_get_property(struct power_supply *psy,
case POWER_SUPPLY_PROP_CHARGE_NOW:
case POWER_SUPPLY_PROP_CHARGE_FULL:
case POWER_SUPPLY_PROP_CHARGE_FULL_DESIGN:
- case POWER_SUPPLY_PROP_CAPACITY:
ret = sbs_get_property_index(client, psp);
if (ret < 0)
break;
@@ -647,6 +646,7 @@ static int sbs_get_property(struct power_supply *psy,
case POWER_SUPPLY_PROP_TIME_TO_FULL_AVG:
case POWER_SUPPLY_PROP_VOLTAGE_MIN_DESIGN:
case POWER_SUPPLY_PROP_VOLTAGE_MAX_DESIGN:
+ case POWER_SUPPLY_PROP_CAPACITY:
ret = sbs_get_property_index(client, psp);
if (ret < 0)
break;
--
2.13.1.508.gb3defc5cc-goog
[toc] | [next] | [standalone]
| From | Guenter Roeck <groeck@google.com> |
|---|---|
| Date | 2017-06-13 20:20 +0200 |
| Message-ID | <tRYA1-2SW-7@gated-at.bofh.it> |
| In reply to | #1665079 |
On Tue, Jun 13, 2017 at 10:53 AM, Shawn Nematbakhsh <shawnn@chromium.org> wrote:
> According to the smart battery spec (1), the CAPACITY_MODE bit does not
> influence the value read from RelativeStateOfCharge(), so don't bother
> changing CAPACITY_MODE when doing such a read.
>
> (1) - Smart Battery Data Specification, Rev 1.1, Dec. 11, 1998
>
> Signed-off-by: Shawn Nematbakhsh <shawnn@chromium.org>
Reviewed-by: Guenter Roeck <groeck@chromium.org>
> ---
> drivers/power/supply/sbs-battery.c | 14 +++++++-------
> 1 file changed, 7 insertions(+), 7 deletions(-)
>
> diff --git a/drivers/power/supply/sbs-battery.c b/drivers/power/supply/sbs-battery.c
> index d7e68fd97099..4bae210d5a8a 100644
> --- a/drivers/power/supply/sbs-battery.c
> +++ b/drivers/power/supply/sbs-battery.c
> @@ -439,6 +439,11 @@ static int sbs_get_battery_property(struct i2c_client *client,
> } else {
> if (psp == POWER_SUPPLY_PROP_STATUS)
> val->intval = POWER_SUPPLY_STATUS_UNKNOWN;
> + else if (psp == POWER_SUPPLY_PROP_CAPACITY)
> + /* sbs spec says that this can be >100 %
> + * even if max value is 100 %
> + */
> + val->intval = min(ret, 100);
> else
> val->intval = 0;
> }
> @@ -549,12 +554,7 @@ static int sbs_get_battery_capacity(struct i2c_client *client,
> if (ret < 0)
> return ret;
>
> - if (psp == POWER_SUPPLY_PROP_CAPACITY) {
> - /* sbs spec says that this can be >100 %
> - * even if max value is 100 % */
> - val->intval = min(ret, 100);
> - } else
> - val->intval = ret;
> + val->intval = ret;
>
> ret = sbs_set_battery_mode(client, mode);
> if (ret < 0)
> @@ -619,7 +619,6 @@ static int sbs_get_property(struct power_supply *psy,
> case POWER_SUPPLY_PROP_CHARGE_NOW:
> case POWER_SUPPLY_PROP_CHARGE_FULL:
> case POWER_SUPPLY_PROP_CHARGE_FULL_DESIGN:
> - case POWER_SUPPLY_PROP_CAPACITY:
> ret = sbs_get_property_index(client, psp);
> if (ret < 0)
> break;
> @@ -647,6 +646,7 @@ static int sbs_get_property(struct power_supply *psy,
> case POWER_SUPPLY_PROP_TIME_TO_FULL_AVG:
> case POWER_SUPPLY_PROP_VOLTAGE_MIN_DESIGN:
> case POWER_SUPPLY_PROP_VOLTAGE_MAX_DESIGN:
> + case POWER_SUPPLY_PROP_CAPACITY:
> ret = sbs_get_property_index(client, psp);
> if (ret < 0)
> break;
> --
> 2.13.1.508.gb3defc5cc-goog
>
[toc] | [prev] | [next] | [standalone]
| From | Sebastian Reichel <sebastian.reichel@collabora.co.uk> |
|---|---|
| Date | 2017-06-15 18:50 +0200 |
| Subject | Re: [PATCH 2/2] power: supply: sbs-battery: Don't needlessly set CAPACITY_MODE |
| Message-ID | <tSG82-4QO-13@gated-at.bofh.it> |
| In reply to | #1665079 |
[Multipart message — attachments visible in raw view] — view raw
Hi,
On Tue, Jun 13, 2017 at 10:53:26AM -0700, Shawn Nematbakhsh wrote:
> According to the smart battery spec (1), the CAPACITY_MODE bit does not
> influence the value read from RelativeStateOfCharge(), so don't bother
> changing CAPACITY_MODE when doing such a read.
>
> (1) - Smart Battery Data Specification, Rev 1.1, Dec. 11, 1998
>
> Signed-off-by: Shawn Nematbakhsh <shawnn@chromium.org>
Thanks, queued.
-- Sebastian
> ---
> drivers/power/supply/sbs-battery.c | 14 +++++++-------
> 1 file changed, 7 insertions(+), 7 deletions(-)
>
> diff --git a/drivers/power/supply/sbs-battery.c b/drivers/power/supply/sbs-battery.c
> index d7e68fd97099..4bae210d5a8a 100644
> --- a/drivers/power/supply/sbs-battery.c
> +++ b/drivers/power/supply/sbs-battery.c
> @@ -439,6 +439,11 @@ static int sbs_get_battery_property(struct i2c_client *client,
> } else {
> if (psp == POWER_SUPPLY_PROP_STATUS)
> val->intval = POWER_SUPPLY_STATUS_UNKNOWN;
> + else if (psp == POWER_SUPPLY_PROP_CAPACITY)
> + /* sbs spec says that this can be >100 %
> + * even if max value is 100 %
> + */
> + val->intval = min(ret, 100);
> else
> val->intval = 0;
> }
> @@ -549,12 +554,7 @@ static int sbs_get_battery_capacity(struct i2c_client *client,
> if (ret < 0)
> return ret;
>
> - if (psp == POWER_SUPPLY_PROP_CAPACITY) {
> - /* sbs spec says that this can be >100 %
> - * even if max value is 100 % */
> - val->intval = min(ret, 100);
> - } else
> - val->intval = ret;
> + val->intval = ret;
>
> ret = sbs_set_battery_mode(client, mode);
> if (ret < 0)
> @@ -619,7 +619,6 @@ static int sbs_get_property(struct power_supply *psy,
> case POWER_SUPPLY_PROP_CHARGE_NOW:
> case POWER_SUPPLY_PROP_CHARGE_FULL:
> case POWER_SUPPLY_PROP_CHARGE_FULL_DESIGN:
> - case POWER_SUPPLY_PROP_CAPACITY:
> ret = sbs_get_property_index(client, psp);
> if (ret < 0)
> break;
> @@ -647,6 +646,7 @@ static int sbs_get_property(struct power_supply *psy,
> case POWER_SUPPLY_PROP_TIME_TO_FULL_AVG:
> case POWER_SUPPLY_PROP_VOLTAGE_MIN_DESIGN:
> case POWER_SUPPLY_PROP_VOLTAGE_MAX_DESIGN:
> + case POWER_SUPPLY_PROP_CAPACITY:
> ret = sbs_get_property_index(client, psp);
> if (ret < 0)
> break;
> --
> 2.13.1.508.gb3defc5cc-goog
>
[toc] | [prev] | [standalone]
Back to top | Article view | linux.kernel
csiph-web