From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751918AbdJ0DEt (ORCPT ); Thu, 26 Oct 2017 23:04:49 -0400 Received: from m13-43.163.com ([220.181.13.43]:10471 "EHLO m13-43.163.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751399AbdJ0DEq (ORCPT ); Thu, 26 Oct 2017 23:04:46 -0400 X-Greylist: delayed 957 seconds by postgrey-1.27 at vger.kernel.org; Thu, 26 Oct 2017 23:04:45 EDT X-Originating-IP: [122.96.42.191] Date: Fri, 27 Oct 2017 10:48:00 +0800 (CST) From: =?GBK?B?wfXOyA==?= <18502523564@163.com> To: "Joe Perches" Cc: sre@kernel.org, linux-pm@vger.kernel.org, linux-kernel@vger.kernel.org Subject: Re:Re: [PATCH] power: supply: 88pm860x_battery array_soc first number is in mV X-Priority: 3 X-Mailer: Coremail Webmail Server Version SP_ntes V3.5 build 20160729(86883.8884) Copyright (c) 2002-2017 www.mailtech.cn 163com In-Reply-To: <1508996478.10651.28.camel@perches.com> References: <1508995310-3834-1-git-send-email-18502523564@163.com> <1508996478.10651.28.camel@perches.com> Content-Type: text/plain; charset=GBK MIME-Version: 1.0 Message-ID: <3a3b3c7c.4645.15f5bbaa714.Coremail.18502523564@163.com> X-Coremail-Locale: zh_CN X-CM-TRANSID: K8GowAC3SS1gnvJZobvFAA--.30657W X-CM-SenderInfo: jprykiysvsjkiwu6il2tof0z/1tbiTRx99Vc6-n0bKgACsE X-Coremail-Antispam: 1U5529EdanIXcx71UUUUU7vcSsGvfC2KfnxnUU== Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Transfer-Encoding: 8bit X-MIME-Autoconverted: from base64 to 8bit by nfs id v9R34siV028852 At 2017-10-26 12:41:18, "Joe Perches" 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; > } > } >