Received: by 2002:ac0:98c7:0:0:0:0:0 with SMTP id g7-v6csp5790663imd; Wed, 31 Oct 2018 01:58:29 -0700 (PDT) X-Google-Smtp-Source: AJdET5eegmQEyMWV8tyh0xMZXH/aeL3aFEGTI5yIN3r63f5lxwI6RAZR+tokkdx6ipdW69EE9maW X-Received: by 2002:a63:27c1:: with SMTP id n184-v6mr2281179pgn.334.1540976309859; Wed, 31 Oct 2018 01:58:29 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1540976309; cv=none; d=google.com; s=arc-20160816; b=H0T4gcdD5YdT4jDFpGhoBYT0wPz4OYRCivLVY3rWhwUtrfLLzdUdNX+Ug2eRmJ5S4N Mr+cB7VVvYQtDiIcb/WleAoxi1l+dEN0HElTJnELoGZvvQLDY0x3L3c98n7FENL3Z7jn GKREAy4DeHw2zzku9FXfi+j7p1jmgtJeqavW2Q1IZwixtftCDAZJfQ2rAS69WfY5WeEW 0Yz7Yij/ZKalmP0uGQVX0zk/bqx+FMoAbJvUKXPWCPVNdc1/NcXShcAbcIhmH4LThfK+ dixqenfNwg8KdbFAi0t7SnwOh2oCp64UJkOKxI5WdJUeS3S37GmAbUsjzaSIauODfl61 JmRw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:dkim-signature; bh=u+Via9G3ufkUJQtolb2E/zuM9tSHunQvVk8bkIv2FL4=; b=PInnnpwc+tvFkaMMFlmNbomQUo+7a0R/Oj/SR5zfPBVUk3dqe5TO7fgRNNs8zl9me4 kpteT3s/VeEQrPMJ0/rtaQz5yl9J7cMmsyAteoE6yf215IhhCdAGRBjrjA6akyy+/OEZ ChlrPWatKIJXuan40Oke4yJ3DsZMnXRC3lsoEjphACiJs6ZdM2aQlLP3gFyDQemicSSj 6JN3z5GbWWimyRR1ZfCDpsbS7OaE3dSV5JMSy4B+Qpz0dyOE2YIrsy3vpThsHuz+uL4X UBxUfdWXTVOe5VAHGrmZEXE3blpAunS1fb2Xm4B6YtefhqPeMacdqohrNeebJ9OxgWVd il3w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b="FM3Gp/iP"; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id e9-v6si27895295pln.265.2018.10.31.01.58.14; Wed, 31 Oct 2018 01:58:29 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b="FM3Gp/iP"; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727615AbeJaRxv (ORCPT + 99 others); Wed, 31 Oct 2018 13:53:51 -0400 Received: from mail-lj1-f194.google.com ([209.85.208.194]:46091 "EHLO mail-lj1-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727519AbeJaRxv (ORCPT ); Wed, 31 Oct 2018 13:53:51 -0400 Received: by mail-lj1-f194.google.com with SMTP id x3-v6so14055751lji.13 for ; Wed, 31 Oct 2018 01:56:38 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=u+Via9G3ufkUJQtolb2E/zuM9tSHunQvVk8bkIv2FL4=; b=FM3Gp/iPFI1rb3mWkfwsIb5kph0VuyH6s8f6rOnRnTShCsU8Mg9P1cpoITeofslFjq e7654JrRLulxNgGL8+lM3Lia9SZovB960JHca/pnBh/4tTb5jbtEOZmlWuGKL8LEBk+H P7AriW+Wzin/EVSFLoCfYboT9NzEuacubDKsw= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=u+Via9G3ufkUJQtolb2E/zuM9tSHunQvVk8bkIv2FL4=; b=q+shS+0ECvOJGl3Ry1O55mlDJUG7NkJZgRmkgLheAvQ6F4FiYf6i7abkxHyXiKVaVH BIQyUSWr80t4kkfv9cZBSS6Enj3Lf+Hu4khqTPWhzdkYYkKo5MBj/euHPhmIZfwqlmqK v0oU3KHCE1NsaOKEtaepBlm3ftTxqS7cUBPzv5jC5HRHuYbUj3ZFIUu0n86AidzY6Tij luBSqZaAsYcSTtZqJe+2bGwDZ1DXQVtmQC9NvTol9fiRMQAwybbogdYEq8MKifqh6+zE qjzK9n4s6l0WGLqueZPgUe77XbdZU0Z8Ld+Q6qMIojIgwl2CxmXS8td89BDrr2vpdkgy 2Uog== X-Gm-Message-State: AGRZ1gLaEZxw1kF35OjB3pdZ7jUPINszIjgRAIKXg8LdWUw92DMIuvhN 9Q1ItUsZJVY4Vs/dtdFunOgZcfolCLUjQMaU75Xgsw== X-Received: by 2002:a2e:1510:: with SMTP id s16-v6mr1395987ljd.4.1540976197210; Wed, 31 Oct 2018 01:56:37 -0700 (PDT) MIME-Version: 1.0 References: <6a4c15368e0bf34f8e6aad4d788bc899cfb9d61e.1540189330.git.baolin.wang@linaro.org> In-Reply-To: <6a4c15368e0bf34f8e6aad4d788bc899cfb9d61e.1540189330.git.baolin.wang@linaro.org> From: Linus Walleij Date: Wed, 31 Oct 2018 09:56:24 +0100 Message-ID: Subject: Re: [PATCH v6 6/6] power: supply: Add Spreadtrum SC27XX fuel gauge unit driver To: Baolin Wang Cc: Sebastian Reichel , Rob Herring , Mark Rutland , Linux PM list , "open list:OPEN FIRMWARE AND FLATTENED DEVICE TREE BINDINGS" , "linux-kernel@vger.kernel.org" , yuanjiang.yu@unisoc.com, Mark Brown , Craig Tatlor Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, Oct 22, 2018 at 9:44 AM Baolin Wang wrote: > This patch adds the Spreadtrum SC27XX serial PMICs fuel gauge support, > which is used to calculate the battery capacity. > > Original-by: Yuanjiang Yu > Signed-off-by: Baolin Wang > Acked-by: Linus Walleij > --- > Changes from v5: > - Save the OCV values in micro volts for OCV capacity table. > - Use devm_kmemdup() instead of devm_kzalloc() in sc27xx_fgu_hw_init() Hi Baolin, you can keep my ACK, just adding some nitpicking: > +struct sc27xx_fgu_data { > + struct regmap *regmap; > + struct device *dev; > + struct power_supply *battery; > + u32 base; > + struct mutex lock; > + struct gpio_desc *gpiod; > + struct iio_channel *channel; > + bool bat_present; > + int internal_resist; > + int total_cap; > + int init_cap; > + int init_clbcnt; > + int max_volt; > + int table_len; Can the above really be negative or should these int:s really be unsigned int? > +static int sc27xx_fgu_adc_to_current(int adc) > +{ > + return (adc * 1000) / SC27XX_FGU_1000MA_ADC; > +} > + > +static int sc27xx_fgu_adc_to_voltage(int adc) > +{ > + return (adc * 1000) / SC27XX_FGU_1000MV_ADC; > +} Would you maybe use DIV_ROUND_CLOSEST(adc*1000, SC27XX_FGU_1000MV_ADC) on these? Overall this is a very fine driver and really pretty compared to some other stuff we have in drivers/power. Yours, Linus Walleij