power: supply: axp288-charger: cleanups + fixes
cover power: supply: axp288-charger: cleanups + fixes
Hi All,
Here are 3 patches for the axp288-charger driver which apply on top of commit ed229454856e ("power: supply: axp288-charger: Optimize register reading method") in linux-power-supply/for-next .
The first patch is a build fix and the other 2 are 2 small cleanups.
Regards,
Hans
Hans de Goede (3):
power: supply: axp288-charger: Add depends on IOSF_MBIO to Kconfig
power: supply: axp288-charger: Remove unnecessary is_present and
is_online helpers
power: supply: axp288-charger: Simplify axp288_get_charger_health()
drivers/power/supply/Kconfig | 2 +- drivers/power/supply/axp288_charger.c | 37 +++++---------------------- 2 files changed, 8 insertions(+), 31 deletions(-)
Signature · 1 line
2.31.1
PATCH 1/3 power: supply: axp288-charger: Add depends on IOSF_MBIO to Kconfig
Add "depends on IOSF_MBI" to CONFIG_AXP288_CHARGER as the changes from commit ed229454856e ("power: supply: axp288-charger: Optimize register reading method") use symbols which are only defined when IOSF_MBI support is enabled.
Depending on this is ok since IOSF_MBI support should always be enabled on devices which use the AXP288 PMIC.
--- drivers/power/supply/Kconfig | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/power/supply/Kconfig +1 -1
@@ -351,7 +351,7 @@ config AXP20X_POWER config AXP288_CHARGER tristate "X-Powers AXP288 Charger" - depends on MFD_AXP20X && EXTCON_AXP288 + depends on MFD_AXP20X && EXTCON_AXP288 && IOSF_MBI help Say yes here to have support X-Power AXP288 power management IC (PMIC) integrated charger.
Signature · 1 line
2.31.1
PATCH 2/3 power: supply: axp288-charger: Remove unnecessary is_present and is_online helpers
In reply to Hans de GoedeNow that axp288_charger_usb_update_property() reads and caches all relevant registers, the axp288_charger_is_present() and axp288_charger_is_online() helpers are not necessary anymore.
Directly check the cached input_status instead, allowing the removal of these 2 helpers.
--- drivers/power/supply/axp288_charger.c | 22 ++-------------------- 1 file changed, 2 insertions(+), 20 deletions(-)
drivers/power/supply/axp288_charger.c +2 -20
@@ -302,24 +302,6 @@ static int axp288_charger_enable_charger(struct axp288_chrg_info *info,return ret; } -static int axp288_charger_is_present (struct axp288_chrg_info *info) -{ -int present =0 ; - -if (info->input_status &PS_STAT_VBUS_PRESENT ) - present =1 ; -return present; -} - -static int axp288_charger_is_online (struct axp288_chrg_info *info) -{ -int online =0 ; - -if (info->input_status &PS_STAT_VBUS_VALID ) - online =1 ; -return online; -} -static int axp288_get_charger_health (struct axp288_chrg_info *info) {int health =POWER_SUPPLY_HEALTH_UNKNOWN ;
@@ -447,7 +429,7 @@ static int axp288_charger_usb_get_property(struct power_supply *psy, val->intval =0 ;break ; } - val->intval =axp288_charger_is_present (info); + val->intval = (info->input_status &PS_STAT_VBUS_PRESENT ) ?1 :0 ;break ;case POWER_SUPPLY_PROP_ONLINE :/* Check for OTG case first */
@@ -455,7 +437,7 @@ static int axp288_charger_usb_get_property(struct power_supply *psy, val->intval =0 ;break ; } - val->intval =axp288_charger_is_online (info); + val->intval = (info->input_status &PS_STAT_VBUS_VALID ) ?1 :0 ;break ;case POWER_SUPPLY_PROP_HEALTH : val->intval =axp288_get_charger_health (info);
Signature · 1 line
2.31.1
PATCH 3/3 power: supply: axp288-charger: Simplify axp288_get_charger_health()
In reply to Hans de GoedeNow that axp288_charger_usb_update_property() reads and caches all relevant registers, axp288_get_charger_health() can be simplified by directly returning the health.
--- drivers/power/supply/axp288_charger.c | 15 +++++---------- 1 file changed, 5 insertions(+), 10 deletions(-)
drivers/power/supply/axp288_charger.c +5 -10
@@ -304,22 +304,17 @@ static int axp288_charger_enable_charger(struct axp288_chrg_info *info,static int axp288_get_charger_health (struct axp288_chrg_info *info) { -int health =POWER_SUPPLY_HEALTH_UNKNOWN ; -if (!(info->input_status &PS_STAT_VBUS_PRESENT )) - goto health_read_fail; +return POWER_SUPPLY_HEALTH_UNKNOWN ;if (!(info->input_status &PS_STAT_VBUS_VALID )) - health =POWER_SUPPLY_HEALTH_DEAD ; +return POWER_SUPPLY_HEALTH_DEAD ;else if (info->op_mode &CHRG_STAT_PMIC_OTP ) - health =POWER_SUPPLY_HEALTH_OVERHEAT ; +return POWER_SUPPLY_HEALTH_OVERHEAT ;else if (info->op_mode &CHRG_STAT_BAT_SAFE_MODE ) - health =POWER_SUPPLY_HEALTH_SAFETY_TIMER_EXPIRE ; +return POWER_SUPPLY_HEALTH_SAFETY_TIMER_EXPIRE ;else - health =POWER_SUPPLY_HEALTH_GOOD ; - -health_read_fail: -return health; +return POWER_SUPPLY_HEALTH_GOOD ; } static int axp288_charger_usb_set_property(struct power_supply *psy,
Signature · 1 line
2.31.1
Hi,
Quoted 17 lines · Hans de Goede
Here are 3 patches for the axp288-charger driver which apply on top of commit
ed229454856e("power: supply: axp288-charger: Optimize register reading method") in linux-power-supply/for-next .The first patch is a build fix and the other 2 are 2 small cleanups.
Regards,
Hans
Hans de Goede (3):
power: supply: axp288-charger: Add depends onIOSF_MBIOtoKconfig
power: supply: axp288-charger: Remove unnecessaryis_presentand
is_onlinehelpers
power: supply: axp288-charger: Simplifyaxp288_get_charger_health()
Quoted 3 lines
drivers/power/supply/Kconfig | 2 +- drivers/power/supply/axp288_charger.c | 37 +++++---------------------- 2 files changed, 8 insertions(+), 31 deletions(-)
Thanks, queued.
-- Sebastian