From e90672c3011fc7232b67d80fdbe1e6b18571c764 Mon Sep 17 00:00:00 2001 From: Mark Salyzyn Date: Mon, 24 Feb 2020 14:40:49 -0800 Subject: [PATCH] ANDROID: GKI: power: supply: Add POWER_SUPPLY_PROP_CHARGE_DISABLE Partially taken from commit 7c4bd0cdf4eff0dd6774183435fc8139743cd6e4 ("power_supply: support for CHARGE_DISABLE") Change-Id: Icd7574696ada4ea5c7d8811787461bc04c922b3c Signed-off-by: AleX Pelosi Signed-off-by: Jack Wu Bug: 139264914 Bug: 141347448 (cherry picked from commit 7c4bd0cdf4eff0dd6774183435fc8139743cd6e4) Signed-off-by: Mark Salyzyn Bug: 150789066 Change-Id: I178c16fe01fb262e7d9cca777c49e8ad586e8eba --- drivers/power/supply/power_supply_sysfs.c | 7 +++++++ include/linux/power_supply.h | 1 + 2 files changed, 8 insertions(+) diff --git a/drivers/power/supply/power_supply_sysfs.c b/drivers/power/supply/power_supply_sysfs.c index 775de75a096e..d8036f8ed384 100644 --- a/drivers/power/supply/power_supply_sysfs.c +++ b/drivers/power/supply/power_supply_sysfs.c @@ -464,6 +464,7 @@ static struct device_attribute power_supply_attrs[] = { POWER_SUPPLY_ATTR(comp_clamp_level), POWER_SUPPLY_ATTR(adapter_cc_mode), POWER_SUPPLY_ATTR(skin_health), + POWER_SUPPLY_ATTR(charge_disable), /* Charge pump properties */ POWER_SUPPLY_ATTR(cp_status1), POWER_SUPPLY_ATTR(cp_status2), @@ -577,6 +578,12 @@ int power_supply_uevent(struct device *dev, struct kobj_uevent_env *env) attr = &power_supply_attrs[psy->desc->properties[j]]; + if (!attr->attr.name) { + dev_info(dev, "%s:%d FAKE attr.name=NULL skip\n", + __FILE__, __LINE__, __func__); + continue; + } + ret = power_supply_show_property(dev, attr, prop_buf); if (ret == -ENODEV || ret == -ENODATA) { /* When a battery is absent, we expect -ENODEV. Don't abort; diff --git a/include/linux/power_supply.h b/include/linux/power_supply.h index a85d86387352..36132db6f7aa 100644 --- a/include/linux/power_supply.h +++ b/include/linux/power_supply.h @@ -335,6 +335,7 @@ enum power_supply_property { POWER_SUPPLY_PROP_COMP_CLAMP_LEVEL, POWER_SUPPLY_PROP_ADAPTER_CC_MODE, POWER_SUPPLY_PROP_SKIN_HEALTH, + POWER_SUPPLY_PROP_CHARGE_DISABLE, /* Charge pump properties */ POWER_SUPPLY_PROP_CP_STATUS1, POWER_SUPPLY_PROP_CP_STATUS2,