diff mbox series

[v3] power: supply: bq2415x_charger: report online status

Message ID 20240229063721.2592069-2-absicsz@gmail.com (mailing list archive)
State Handled Elsewhere, archived
Headers show
Series [v3] power: supply: bq2415x_charger: report online status | expand

Commit Message

Sicelo Feb. 29, 2024, 6:37 a.m. UTC
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 only occur when VBUS is present, so set
Online true for those as well.

Signed-off-by: Sicelo A. Mhlongo <absicsz@gmail.com>
---
 drivers/power/supply/bq2415x_charger.c | 11 +++++++++++
 1 file changed, 11 insertions(+)

Comments

Sebastian Reichel March 1, 2024, 1:31 a.m. UTC | #1
On Thu, 29 Feb 2024 08:37:21 +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 only occur when VBUS is present, so set
> Online true for those as well.
> 
> 

Applied, thanks!

[1/1] power: supply: bq2415x_charger: report online status
      commit: 9a451f1b028e116d037a93bf13eb8f8620994205

Best regards,
Sebastian Reichel March 1, 2024, 1:34 a.m. UTC | #2
Hi,

On Thu, Feb 29, 2024 at 08:37:21AM +0200, Sicelo A. Mhlongo wrote:
> +		ret = bq2415x_exec_command(bq, BQ2415X_CHARGE_STATUS);
> +		if (ret < 0)
> +			return ret;
> +		else

The else is not needed, since the if returns. I dropped it
while applying.

Greetings,

-- Sebastian
diff mbox series

Patch

diff --git a/drivers/power/supply/bq2415x_charger.c b/drivers/power/supply/bq2415x_charger.c
index 6a4798a62588..7b93ba20348a 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,16 @@  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.
+		 */
+		ret = bq2415x_exec_command(bq, BQ2415X_CHARGE_STATUS);
+		if (ret < 0)
+			return ret;
+		else
+			val->intval = ret > 0;
+		break;
 	default:
 		return -EINVAL;
 	}