power: supply: bq2415x_charger: report online status
Subsystems (2)
PATCH v2 1/1 power: supply: bq2415x_charger: report online status
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.
--- drivers/power/supply/bq2415x_charger.c | 9 +++++++++ 1 file changed, 9 insertions(+)
drivers/power/supply/bq2415x_charger.c +9 -0
@@ -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 ; }
Signature · 1 line
2.43.0
Hi,
Quoted 24 lines · 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 <[email protected]>--- drivers/power/supply/bq2415x_charger.c | 9 +++++++++ 1 file changed, 9 insertions(+)drivers/power/supply/bq2415x_charger.c +1
-0@@ -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,
drivers/power/supply/bq2415x_charger.c static int bq2415x_power_supply_get_property(struct power_supply *psy, · line 1026
Quoted 9 lines
drivers/power/supply/bq2415x_charger.c +6
-0@@ -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
Quoted 8 lines
drivers/power/supply/bq2415x_charger.c +2
-0+ val->intval = ret >0 ; +break ;default :return -EINVAL ; }Signature · 1 line
2.43.0