Devicetree
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "Molnár Máté" <matemolnar88@gmail.com>
Cc: devicetree@vger.kernel.org, linux-input@vger.kernel.org,
	mfd@lists.linux.dev, robh@kernel.org, conor+dt@kernel.org,
	dmitry.torokhov@gmail.com, lee@kernel.org
Subject: Re: [PATCH v7 4/9] power: axp20x_battery: Add constant charge current table
Date: Sun, 06 Dec 2026 03:24:13 +0000	[thread overview]
Message-ID: <sashiko-outbox-252121@kernel.org> (raw)
In-Reply-To: <20261206-axp192-v7-4-0200fc77da53@gmail.com>

Thank you for your contribution! Sashiko AI review found 1 potential
issue to consider:
- [Medium] power: supply: axp20x_battery: missing upper bound check for
  ccc_table
--

commit f993b38bb97cab5bf0e1a39f154f674939512710
Author: Aidan MacDonald <aidanmacdonald.0x0@gmail.com>

power: axp20x_battery: Add constant charge current table

This commit adds a lookup table option for constant charge current on
variants whose values do not follow a linear range, and updates the DT
fallback to use the device's minimum configured current.

> diff --git a/drivers/power/supply/axp20x_battery.c b/drivers/power/supply/axp20x_battery.c
> index 4af1a209c9cf3..f31b735ed6548 100644
> --- a/drivers/power/supply/axp20x_battery.c
> +++ b/drivers/power/supply/axp20x_battery.c

[ ... ]

> @@ -675,16 +686,35 @@ static int axp717_battery_set_max_voltage(struct axp20x_batt_ps *axp20x_batt,
>  				  AXP717_CHRG_CV_VOLT_MASK, val);
>  }
>  
> +static int axp20x_get_constant_charge_current_sel(struct axp20x_batt_ps *axp_batt,
> +						  int charge_current)
> +{
> +	int i;
> +
> +	if (axp_batt->data->ccc_table) {
> +		for (i = AXP20X_CHRG_CTRL1_TGT_CURR; i >= 0; i--) {
> +			if (axp_batt->data->ccc_table[i] <= charge_current)
> +				return i;
> +		}
> +
> +		return -EINVAL;
> +	}
> +
> +	i = (charge_current - axp_batt->data->ccc_offset) / axp_batt->data->ccc_scale;
> +	if (i > AXP20X_CHRG_CTRL1_TGT_CURR || i < 0)
> +		return -EINVAL;
> +
> +	return i;
> +}

[Severity: Medium]
Should the ccc_table path reject charge_current values above
ccc_table[AXP20X_CHRG_CTRL1_TGT_CURR] with -EINVAL?

Unlike the linear branch below, the reverse scan matches any value above
the maximum table entry on the first iteration and returns selector
AXP20X_CHRG_CTRL1_TGT_CURR.  An out-of-range high write to
constant_charge_current_max via axp20x_set_max_constant_charge_current()
then silently raises max_ccc to the hardware maximum instead of returning
-EINVAL, and an unsupported high DT value in axp209_set_battery_info()
programs the hardware maximum instead of falling back to ccc_table[0].

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20261206-axp192-v7-0-0200fc77da53@gmail.com?part=4

  reply	other threads:[~2026-12-06  3:24 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-12-06  3:08 [PATCH v7 0/9] Add the remaining AXP192 PMIC support Molnár Máté via B4 Relay
2026-12-06  3:08 ` [PATCH v7 1/9] dt-bindings: iio: adc: axp209: Add AXP192 compatible Molnár Máté via B4 Relay
2026-12-06  3:08 ` [PATCH v7 2/9] dt-bindings: power: axp20x-battery: " Molnár Máté via B4 Relay
2026-12-06  3:08 ` [PATCH v7 3/9] regulator: axp20x: Add support for AXP192 Molnár Máté via B4 Relay
2026-12-06  3:22   ` sashiko-bot
2026-12-06  3:08 ` [PATCH v7 4/9] power: axp20x_battery: Add constant charge current table Molnár Máté via B4 Relay
2026-12-06  3:24   ` sashiko-bot [this message]
2026-12-06  3:08 ` [PATCH v7 5/9] power: axp20x_battery: Support battery status without fuel gauge Molnár Máté via B4 Relay
2026-12-06  3:23   ` sashiko-bot
2026-12-06  3:08 ` [PATCH v7 6/9] power: axp20x_battery: Add support for AXP192 Molnár Máté via B4 Relay
2026-12-06  3:08 ` [PATCH v7 7/9] power: axp20x_battery: Estimate AXP192 capacity from the OCV table Molnár Máté via B4 Relay
2026-12-06  3:24   ` sashiko-bot
2026-12-06  3:09 ` [PATCH v7 8/9] Input: axp20x-pek: Add AXP192 support Molnár Máté via B4 Relay
2026-12-06  3:21   ` sashiko-bot
2026-12-06  3:09 ` [PATCH v7 9/9] mfd: axp20x: Add the AXP192 power key cell Molnár Máté via B4 Relay
2026-12-06  3:18   ` sashiko-bot

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=sashiko-outbox-252121@kernel.org \
    --to=sashiko-bot@kernel.org \
    --cc=conor+dt@kernel.org \
    --cc=devicetree@vger.kernel.org \
    --cc=dmitry.torokhov@gmail.com \
    --cc=lee@kernel.org \
    --cc=linux-input@vger.kernel.org \
    --cc=matemolnar88@gmail.com \
    --cc=mfd@lists.linux.dev \
    --cc=robh@kernel.org \
    --cc=sashiko-reviews@lists.linux.dev \
    /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