* [PATCH] power: supply: 88pm860x_battery array_soc first number is in mV
@ 2017-10-26 3:31 刘稳
0 siblings, 0 replies; 4+ messages in thread
From: 刘稳 @ 2017-10-26 3:31 UTC (permalink / raw)
To: sre; +Cc: linux-pm, linux-kernel
[-- Attachment #1: Type: text/plain, Size: 0 bytes --]
[-- Attachment #2: 0001-power-supply-88pm860x_battery-array_soc-first-number.patch --]
[-- Type: application/octet-stream, Size: 987 bytes --]
From ce5b39337ff22ce37311e6150d6cdb1270872bfa Mon Sep 17 00:00:00 2001
From: "winton.liu" <18502523564@163.com>
Date: Thu, 26 Oct 2017 11:06:41 +0800
Subject: [PATCH] power: supply: 88pm860x_battery array_soc first number is in
mV
Fix wrong comments of array_soc description.
First number is mV not mAh.
Signed-off-by: winton.liu <18502523564@163.com>
---
drivers/power/supply/88pm860x_battery.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/power/supply/88pm860x_battery.c b/drivers/power/supply/88pm860x_battery.c
index 63c57dc..8f867fd 100644
--- a/drivers/power/supply/88pm860x_battery.c
+++ b/drivers/power/supply/88pm860x_battery.c
@@ -123,7 +123,7 @@ struct ccnt {
/*
* State of Charge.
- * The first number is mAh(=3.6C), and the second number is percent point.
+ * The first number is mV, and the second number is percent point.
*/
static int array_soc[][2] = {
{4170, 100}, {4154, 99}, {4136, 98}, {4122, 97}, {4107, 96},
--
1.9.1
^ permalink raw reply related [flat|nested] 4+ messages in thread
* [PATCH] power: supply: 88pm860x_battery array_soc first number is in mV
@ 2017-10-26 5:21 winton.liu
2017-10-26 5:41 ` Joe Perches
0 siblings, 1 reply; 4+ messages in thread
From: winton.liu @ 2017-10-26 5:21 UTC (permalink / raw)
To: sre; +Cc: linux-pm, linux-kernel, winton.liu
Fix wrong comments of array_soc description.
First number is mV not mAh.
Signed-off-by: winton.liu <18502523564@163.com>
---
drivers/power/supply/88pm860x_battery.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/power/supply/88pm860x_battery.c b/drivers/power/supply/88pm860x_battery.c
index 63c57dc..8f867fd 100644
--- a/drivers/power/supply/88pm860x_battery.c
+++ b/drivers/power/supply/88pm860x_battery.c
@@ -123,7 +123,7 @@ struct ccnt {
/*
* State of Charge.
- * The first number is mAh(=3.6C), and the second number is percent point.
+ * The first number is mV, and the second number is percent point.
*/
static int array_soc[][2] = {
{4170, 100}, {4154, 99}, {4136, 98}, {4122, 97}, {4107, 96},
--
1.9.1
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH] power: supply: 88pm860x_battery array_soc first number is in mV
2017-10-26 5:21 [PATCH] power: supply: 88pm860x_battery array_soc first number is in mV winton.liu
@ 2017-10-26 5:41 ` Joe Perches
2017-10-27 2:48 ` 刘稳
0 siblings, 1 reply; 4+ messages in thread
From: Joe Perches @ 2017-10-26 5:41 UTC (permalink / raw)
To: winton.liu, sre; +Cc: linux-pm, linux-kernel
On Thu, 2017-10-26 at 13:21 +0800, winton.liu wrote:
> Fix wrong comments of array_soc description.
> First number is mV not mAh.
[]
> diff --git a/drivers/power/supply/88pm860x_battery.c b/drivers/power/supply/88pm860x_battery.c
[]
> @@ -123,7 +123,7 @@ struct ccnt {
>
> /*
> * State of Charge.
> - * The first number is mAh(=3.6C), and the second number is percent point.
> + * The first number is mV, and the second number is percent point.
> */
> static int array_soc[][2] = {
> {4170, 100}, {4154, 99}, {4136, 98}, {4122, 97}, {4107, 96},
OK, but why not change the declaration to a struct
and make it obvious?
Also, the array or struct should be const.
Perhaps:
---
drivers/power/supply/88pm860x_battery.c | 13 ++++++++-----
1 file changed, 8 insertions(+), 5 deletions(-)
diff --git a/drivers/power/supply/88pm860x_battery.c b/drivers/power/supply/88pm860x_battery.c
index 63c57dc82ac1..973c5f7b07ba 100644
--- a/drivers/power/supply/88pm860x_battery.c
+++ b/drivers/power/supply/88pm860x_battery.c
@@ -123,9 +123,12 @@ struct ccnt {
/*
* State of Charge.
- * The first number is mAh(=3.6C), and the second number is percent point.
+ * The first number is mV(=3.6C), and the second number is percent point.
*/
-static int array_soc[][2] = {
+static const struct {
+ u16 mv;
+ u8 percent;
+} array_soc[] = {
{4170, 100}, {4154, 99}, {4136, 98}, {4122, 97}, {4107, 96},
{4102, 95}, {4088, 94}, {4081, 93}, {4070, 92}, {4060, 91},
{4053, 90}, {4044, 89}, {4035, 88}, {4028, 87}, {4019, 86},
@@ -388,14 +391,14 @@ static int calc_soc(struct pm860x_battery_info *info, int state, int *soc)
return ret;
count = ARRAY_SIZE(array_soc);
- if (ocv < array_soc[count - 1][0]) {
+ if (ocv < array_soc[count - 1].mv) {
*soc = 0;
return 0;
}
for (i = 0; i < count; i++) {
- if (ocv >= array_soc[i][0]) {
- *soc = array_soc[i][1];
+ if (ocv >= array_soc[i].mv) {
+ *soc = array_soc[i].percent;
break;
}
}
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re:Re: [PATCH] power: supply: 88pm860x_battery array_soc first number is in mV
2017-10-26 5:41 ` Joe Perches
@ 2017-10-27 2:48 ` 刘稳
0 siblings, 0 replies; 4+ messages in thread
From: 刘稳 @ 2017-10-27 2:48 UTC (permalink / raw)
To: Joe Perches; +Cc: sre, linux-pm, linux-kernel
At 2017-10-26 12:41:18, "Joe Perches" <joe@perches.com> wrote:
>On Thu, 2017-10-26 at 13:21 +0800, winton.liu wrote:
>> Fix wrong comments of array_soc description.
>> First number is mV not mAh.
>[]
>> diff --git a/drivers/power/supply/88pm860x_battery.c b/drivers/power/supply/88pm860x_battery.c
>[]
>> @@ -123,7 +123,7 @@ struct ccnt {
>>
>> /*
>> * State of Charge.
>> - * The first number is mAh(=3.6C), and the second number is percent point.
>> + * The first number is mV, and the second number is percent point.
>> */
>> static int array_soc[][2] = {
>> {4170, 100}, {4154, 99}, {4136, 98}, {4122, 97}, {4107, 96},
>
>OK, but why not change the declaration to a struct
>and make it obvious?
>
>Also, the array or struct should be const.
>
Yes, using a struct makes it more readable.
>Perhaps:
>---
> drivers/power/supply/88pm860x_battery.c | 13 ++++++++-----
> 1 file changed, 8 insertions(+), 5 deletions(-)
>
>diff --git a/drivers/power/supply/88pm860x_battery.c b/drivers/power/supply/88pm860x_battery.c
>index 63c57dc82ac1..973c5f7b07ba 100644
>--- a/drivers/power/supply/88pm860x_battery.c
>+++ b/drivers/power/supply/88pm860x_battery.c
>@@ -123,9 +123,12 @@ struct ccnt {
>
> /*
> * State of Charge.
>- * The first number is mAh(=3.6C), and the second number is percent point.
>+ * The first number is mV(=3.6C), and the second number is percent point3..
'(=3.6C)' is not needed. 1mAh = 1mA *3600s = 3.6C. As first number is mV, 3.6C is not needed.
> */
>-static int array_soc[][2] = {
>+static const struct {
>+ u16 mv;
>+ u8 percent;
>+} array_soc[] = {
> {4170, 100}, {4154, 99}, {4136, 98}, {4122, 97}, {4107, 96},
> {4102, 95}, {4088, 94}, {4081, 93}, {4070, 92}, {4060, 91},
> {4053, 90}, {4044, 89}, {4035, 88}, {4028, 87}, {4019, 86},
>@@ -388,14 +391,14 @@ static int calc_soc(struct pm860x_battery_info *info, int state, int *soc)
> return ret;
>
> count = ARRAY_SIZE(array_soc);
>- if (ocv < array_soc[count - 1][0]) {
>+ if (ocv < array_soc[count - 1].mv) {
> *soc = 0;
> return 0;
> }
>
> for (i = 0; i < count; i++) {
>- if (ocv >= array_soc[i][0]) {
>- *soc = array_soc[i][1];
>+ if (ocv >= array_soc[i].mv) {
>+ *soc = array_soc[i].percent;
> break;
> }
> }
>
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2017-10-27 3:04 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2017-10-26 5:21 [PATCH] power: supply: 88pm860x_battery array_soc first number is in mV winton.liu
2017-10-26 5:41 ` Joe Perches
2017-10-27 2:48 ` 刘稳
-- strict thread matches above, loose matches on Subject: below --
2017-10-26 3:31 刘稳
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.