* [PATCH v2] power: supply: bq2415x_charger: report online status
@ 2024-02-28 6:58 Sicelo A. Mhlongo
2024-02-28 22:08 ` Sebastian Reichel
0 siblings, 1 reply; 2+ messages in thread
From: Sicelo A. Mhlongo @ 2024-02-28 6:58 UTC (permalink / raw)
To: sre, linux-pm; +Cc: maemo-leste, pali, Sicelo A. Mhlongo
Provide the Online property. This chip does not have specific flags to
indicate the presence of an input voltage, but this is implied by all valid
charging states. Fault states also imply the presence of VBUS, therefore
set Online true for those as well, taking care to not set it when i2c
reads have failed.
Signed-off-by: Sicelo A. Mhlongo <absicsz@gmail.com>
---
drivers/power/supply/bq2415x_charger.c | 9 +++++++++
1 file changed, 9 insertions(+)
diff --git a/drivers/power/supply/bq2415x_charger.c b/drivers/power/supply/bq2415x_charger.c
index 6a4798a62588..8f24a33f0338 100644
--- a/drivers/power/supply/bq2415x_charger.c
+++ b/drivers/power/supply/bq2415x_charger.c
@@ -991,6 +991,7 @@ static enum power_supply_property bq2415x_power_supply_props[] = {
/* TODO: maybe add more power supply properties */
POWER_SUPPLY_PROP_STATUS,
POWER_SUPPLY_PROP_MODEL_NAME,
+ POWER_SUPPLY_PROP_ONLINE,
};
static int bq2415x_power_supply_get_property(struct power_supply *psy,
@@ -1017,6 +1018,14 @@ static int bq2415x_power_supply_get_property(struct power_supply *psy,
case POWER_SUPPLY_PROP_MODEL_NAME:
val->strval = bq->model;
break;
+ case POWER_SUPPLY_PROP_ONLINE:
+ /* VBUS is present for all charging and fault states,
+ * except the 'Ready' state. On all i2c read errors, the
+ * Online state cannot be determined.
+ */
+ ret = bq2415x_exec_command(bq, BQ2415X_CHARGE_STATUS);
+ val->intval = ret > 0;
+ break;
default:
return -EINVAL;
}
--
2.43.0
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH v2] power: supply: bq2415x_charger: report online status
2024-02-28 6:58 [PATCH v2] power: supply: bq2415x_charger: report online status Sicelo A. Mhlongo
@ 2024-02-28 22:08 ` Sebastian Reichel
0 siblings, 0 replies; 2+ messages in thread
From: Sebastian Reichel @ 2024-02-28 22:08 UTC (permalink / raw)
To: Sicelo A. Mhlongo; +Cc: linux-pm, maemo-leste, pali
[-- Attachment #1: Type: text/plain, Size: 1820 bytes --]
Hi,
On Wed, Feb 28, 2024 at 08:58:41AM +0200, Sicelo A. Mhlongo wrote:
> Provide the Online property. This chip does not have specific flags to
> indicate the presence of an input voltage, but this is implied by all valid
> charging states. Fault states also imply the presence of VBUS, therefore
> set Online true for those as well, taking care to not set it when i2c
> reads have failed.
>
> Signed-off-by: Sicelo A. Mhlongo <absicsz@gmail.com>
> ---
> drivers/power/supply/bq2415x_charger.c | 9 +++++++++
> 1 file changed, 9 insertions(+)
>
> diff --git a/drivers/power/supply/bq2415x_charger.c b/drivers/power/supply/bq2415x_charger.c
> index 6a4798a62588..8f24a33f0338 100644
> --- a/drivers/power/supply/bq2415x_charger.c
> +++ b/drivers/power/supply/bq2415x_charger.c
> @@ -991,6 +991,7 @@ static enum power_supply_property bq2415x_power_supply_props[] = {
> /* TODO: maybe add more power supply properties */
> POWER_SUPPLY_PROP_STATUS,
> POWER_SUPPLY_PROP_MODEL_NAME,
> + POWER_SUPPLY_PROP_ONLINE,
> };
>
> static int bq2415x_power_supply_get_property(struct power_supply *psy,
> @@ -1017,6 +1018,14 @@ static int bq2415x_power_supply_get_property(struct power_supply *psy,
> case POWER_SUPPLY_PROP_MODEL_NAME:
> val->strval = bq->model;
> break;
> + case POWER_SUPPLY_PROP_ONLINE:
> + /* VBUS is present for all charging and fault states,
> + * except the 'Ready' state. On all i2c read errors, the
> + * Online state cannot be determined.
> + */
> + ret = bq2415x_exec_command(bq, BQ2415X_CHARGE_STATUS);
Please forward errors, instead of silently ignoring them.
if (ret < 0)
return ret;
Otherwise LGTM.
-- Sebastian
> + val->intval = ret > 0;
> + break;
> default:
> return -EINVAL;
> }
> --
> 2.43.0
>
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2024-02-28 22:08 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-02-28 6:58 [PATCH v2] power: supply: bq2415x_charger: report online status Sicelo A. Mhlongo
2024-02-28 22:08 ` Sebastian Reichel
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).