From patchwork Thu Oct 26 05:41:18 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Joe Perches X-Patchwork-Id: 10027451 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id E31D860375 for ; Thu, 26 Oct 2017 05:41:23 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id CCF7028D18 for ; Thu, 26 Oct 2017 05:41:23 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id C09DF28D1B; Thu, 26 Oct 2017 05:41:23 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.9 required=2.0 tests=BAYES_00,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 4563828D18 for ; Thu, 26 Oct 2017 05:41:23 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1750949AbdJZFlW (ORCPT ); Thu, 26 Oct 2017 01:41:22 -0400 Received: from smtprelay0137.hostedemail.com ([216.40.44.137]:49932 "EHLO smtprelay.hostedemail.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1750884AbdJZFlV (ORCPT ); Thu, 26 Oct 2017 01:41:21 -0400 Received: from filter.hostedemail.com (clb03-v110.bra.tucows.net [216.40.38.60]) by smtprelay05.hostedemail.com (Postfix) with ESMTP id A8C621806595A; Thu, 26 Oct 2017 05:41:20 +0000 (UTC) X-Session-Marker: 6A6F6540706572636865732E636F6D X-HE-Tag: loss40_45cc60f8aad27 X-Filterd-Recvd-Size: 2813 Received: from XPS-9350 (unknown [47.151.150.235]) (Authenticated sender: joe@perches.com) by omf06.hostedemail.com (Postfix) with ESMTPA; Thu, 26 Oct 2017 05:41:19 +0000 (UTC) Message-ID: <1508996478.10651.28.camel@perches.com> Subject: Re: [PATCH] power: supply: 88pm860x_battery array_soc first number is in mV From: Joe Perches To: "winton.liu" <18502523564@163.com>, sre@kernel.org Cc: linux-pm@vger.kernel.org, linux-kernel@vger.kernel.org Date: Wed, 25 Oct 2017 22:41:18 -0700 In-Reply-To: <1508995310-3834-1-git-send-email-18502523564@163.com> References: <1508995310-3834-1-git-send-email-18502523564@163.com> X-Mailer: Evolution 3.26.1-1 Mime-Version: 1.0 Sender: linux-pm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-pm@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP 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; } }