From: Sebastian Reichel <sebastian.reichel@collabora.com>
To: Alexey Charkov <alchark@flipper.net>
Cc: Lee Jones <lee@kernel.org>, Rob Herring <robh@kernel.org>,
Krzysztof Kozlowski <krzk+dt@kernel.org>,
Conor Dooley <conor+dt@kernel.org>,
Chris Morgan <macromorgan@hotmail.com>,
Liam Girdwood <lgirdwood@gmail.com>,
Mark Brown <broonie@kernel.org>,
devicetree@vger.kernel.org, linux-kernel@vger.kernel.org,
linux-pm@vger.kernel.org
Subject: Re: [PATCH v3 08/11] power: supply: bq257xx: Add fields for 'charging' and 'overvoltage' states
Date: Wed, 11 Mar 2026 08:09:26 +0100 [thread overview]
Message-ID: <abEVEkdrRbBVJ02w@venus> (raw)
In-Reply-To: <20260310-bq25792-v3-8-02f8e232d63b@flipper.net>
[-- Attachment #1: Type: text/plain, Size: 2813 bytes --]
Hi,
On Tue, Mar 10, 2026 at 01:28:32PM +0400, Alexey Charkov wrote:
> The driver currently reports the 'charging' and 'overvoltage' states based
> on a logical expression in the get_charger_property() wrapper function.
> This doesn't scale well to other chip variants, which may have a different
> number and type of hardware reported conditions which fall into these
> broad power supply states.
>
> Move the logic for determining 'charging' and 'overvoltage' states into
> chip-specific accessors, which can be overridden by each variant as
> needed.
>
> This helps keep the get_charger_property() wrapper function chip-agnostic
> while allowing for new chip variants to be added bringing their own logic.
>
> Tested-by: Chris Morgan <macromorgan@hotmail.com>
> Signed-off-by: Alexey Charkov <alchark@flipper.net>
> ---
Reviewed-by: Sebastian Reichel <sebastian.reichel@collabora.com>
-- Sebastian
> drivers/power/supply/bq257xx_charger.c | 8 ++++++--
> 1 file changed, 6 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/power/supply/bq257xx_charger.c b/drivers/power/supply/bq257xx_charger.c
> index deb60a9bd222..951abd035fc5 100644
> --- a/drivers/power/supply/bq257xx_charger.c
> +++ b/drivers/power/supply/bq257xx_charger.c
> @@ -64,8 +64,10 @@ struct bq257xx_chg {
> struct bq257xx_device *bq;
> struct power_supply *charger;
> bool online;
> + bool charging;
> bool fast_charge;
> bool pre_charge;
> + bool overvoltage;
> bool ov_fault;
> bool batoc_fault;
> bool oc_fault;
> @@ -99,8 +101,10 @@ static int bq25703_get_state(struct bq257xx_chg *pdata)
> pdata->online = reg & BQ25703_STS_AC_STAT;
> pdata->fast_charge = reg & BQ25703_STS_IN_FCHRG;
> pdata->pre_charge = reg & BQ25703_STS_IN_PCHRG;
> + pdata->charging = pdata->fast_charge || pdata->pre_charge;
> pdata->ov_fault = reg & BQ25703_STS_FAULT_ACOV;
> pdata->batoc_fault = reg & BQ25703_STS_FAULT_BATOC;
> + pdata->overvoltage = pdata->ov_fault || pdata->batoc_fault;
> pdata->oc_fault = reg & BQ25703_STS_FAULT_ACOC;
>
> return 0;
> @@ -471,14 +475,14 @@ static int bq257xx_get_charger_property(struct power_supply *psy,
> case POWER_SUPPLY_PROP_STATUS:
> if (!pdata->online)
> val->intval = POWER_SUPPLY_STATUS_DISCHARGING;
> - else if (pdata->fast_charge || pdata->pre_charge)
> + else if (pdata->charging)
> val->intval = POWER_SUPPLY_STATUS_CHARGING;
> else
> val->intval = POWER_SUPPLY_STATUS_NOT_CHARGING;
> break;
>
> case POWER_SUPPLY_PROP_HEALTH:
> - if (pdata->ov_fault || pdata->batoc_fault)
> + if (pdata->overvoltage)
> val->intval = POWER_SUPPLY_HEALTH_OVERVOLTAGE;
> else if (pdata->oc_fault)
> val->intval = POWER_SUPPLY_HEALTH_OVERCURRENT;
>
> --
> 2.52.0
>
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]
next prev parent reply other threads:[~2026-03-11 7:09 UTC|newest]
Thread overview: 20+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-03-10 9:28 [PATCH v3 00/11] Add support for the TI BQ25792 battery charger Alexey Charkov
2026-03-10 9:28 ` [PATCH v3 01/11] dt-bindings: mfd: ti,bq25703a: Expand to include BQ25792 Alexey Charkov
2026-03-10 9:28 ` [PATCH v3 02/11] regulator: bq257xx: Remove reference to the parent MFD's dev Alexey Charkov
2026-03-10 9:28 ` [PATCH v3 03/11] regulator: bq257xx: Drop the regulator_dev from the driver data Alexey Charkov
2026-03-10 9:28 ` [PATCH v3 04/11] regulator: bq257xx: Make OTG enable GPIO really optional Alexey Charkov
2026-03-10 9:28 ` [PATCH v3 05/11] power: supply: bq257xx: Fix VSYSMIN clamping logic Alexey Charkov
2026-03-11 7:08 ` Sebastian Reichel
2026-03-10 9:28 ` [PATCH v3 06/11] power: supply: bq257xx: Make the default current limit a per-chip attribute Alexey Charkov
2026-03-11 7:08 ` Sebastian Reichel
2026-03-10 9:28 ` [PATCH v3 07/11] power: supply: bq257xx: Consistently use indirect get/set helpers Alexey Charkov
2026-03-11 7:09 ` Sebastian Reichel
2026-03-10 9:28 ` [PATCH v3 08/11] power: supply: bq257xx: Add fields for 'charging' and 'overvoltage' states Alexey Charkov
2026-03-11 7:09 ` Sebastian Reichel [this message]
2026-03-10 9:28 ` [PATCH v3 09/11] mfd: bq257xx: Add BQ25792 support Alexey Charkov
2026-03-10 13:03 ` Lee Jones
2026-03-10 13:49 ` Alexey Charkov
2026-03-10 9:28 ` [PATCH v3 10/11] regulator: bq257xx: Add support for BQ25792 Alexey Charkov
2026-03-10 9:28 ` [PATCH v3 11/11] power: supply: " Alexey Charkov
2026-03-11 8:52 ` Sebastian Reichel
2026-03-11 9:22 ` Alexey Charkov
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=abEVEkdrRbBVJ02w@venus \
--to=sebastian.reichel@collabora.com \
--cc=alchark@flipper.net \
--cc=broonie@kernel.org \
--cc=conor+dt@kernel.org \
--cc=devicetree@vger.kernel.org \
--cc=krzk+dt@kernel.org \
--cc=lee@kernel.org \
--cc=lgirdwood@gmail.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-pm@vger.kernel.org \
--cc=macromorgan@hotmail.com \
--cc=robh@kernel.org \
/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