devicetree.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Linus Walleij <linus.walleij@linaro.org>
To: Baolin Wang <baolin.wang@linaro.org>
Cc: Sebastian Reichel <sre@kernel.org>,
	Rob Herring <robh+dt@kernel.org>,
	Mark Rutland <mark.rutland@arm.com>,
	Linux PM list <linux-pm@vger.kernel.org>,
	"open list:OPEN FIRMWARE AND FLATTENED DEVICE TREE BINDINGS"
	<devicetree@vger.kernel.org>,
	"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
	yuanjiang.yu@unisoc.com, Mark Brown <broonie@kernel.org>,
	Craig Tatlor <ctatlor97@gmail.com>
Subject: Re: [PATCH v6 6/6] power: supply: Add Spreadtrum SC27XX fuel gauge unit driver
Date: Wed, 31 Oct 2018 09:56:24 +0100	[thread overview]
Message-ID: <CACRpkdaDB2f5FTY-sk6Ak49GMtqFzV_5Jkway49zSLA6XJkq0A@mail.gmail.com> (raw)
In-Reply-To: <6a4c15368e0bf34f8e6aad4d788bc899cfb9d61e.1540189330.git.baolin.wang@linaro.org>

On Mon, Oct 22, 2018 at 9:44 AM Baolin Wang <baolin.wang@linaro.org> wrote:

> This patch adds the Spreadtrum SC27XX serial PMICs fuel gauge support,
> which is used to calculate the battery capacity.
>
> Original-by: Yuanjiang Yu <yuanjiang.yu@unisoc.com>
> Signed-off-by: Baolin Wang <baolin.wang@linaro.org>
> Acked-by: Linus Walleij <linus.walleij@linaro.org>
> ---
> 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

  reply	other threads:[~2018-10-31  8:56 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-10-22  7:43 [PATCH v6 1/6] dt-bindings: power: Introduce one property to present the battery internal resistance Baolin Wang
2018-10-22  7:43 ` [PATCH v6 2/6] power: supply: core: Add one field " Baolin Wang
2018-10-22  7:43 ` [PATCH v6 3/6] dt-bindings: power: Introduce properties to present the battery OCV capacity table Baolin Wang
2018-10-22 22:10   ` Rob Herring
2018-10-22  7:44 ` [PATCH v6 4/6] power: supply: core: Add some helpers to use " Baolin Wang
2018-11-01  7:22   ` Baolin Wang
2018-11-01 13:50     ` Quentin Schulz
2018-11-01 17:30       ` Baolin Wang
2018-10-22  7:44 ` [PATCH v6 5/6] dt-bindings: power: Add Spreadtrum SC27XX fuel gauge unit documentation Baolin Wang
2018-10-22  7:44 ` [PATCH v6 6/6] power: supply: Add Spreadtrum SC27XX fuel gauge unit driver Baolin Wang
2018-10-31  8:56   ` Linus Walleij [this message]
2018-11-01  6:42     ` Baolin Wang
2018-10-25  2:01 ` [PATCH v6 1/6] dt-bindings: power: Introduce one property to present the battery internal resistance Baolin Wang
2018-10-25 20:13   ` Sebastian Reichel
2018-10-26  1:57     ` Baolin Wang

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=CACRpkdaDB2f5FTY-sk6Ak49GMtqFzV_5Jkway49zSLA6XJkq0A@mail.gmail.com \
    --to=linus.walleij@linaro.org \
    --cc=baolin.wang@linaro.org \
    --cc=broonie@kernel.org \
    --cc=ctatlor97@gmail.com \
    --cc=devicetree@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-pm@vger.kernel.org \
    --cc=mark.rutland@arm.com \
    --cc=robh+dt@kernel.org \
    --cc=sre@kernel.org \
    --cc=yuanjiang.yu@unisoc.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).