From 3850d272a614189f0c5a68e89fc7ae825aedc6be Mon Sep 17 00:00:00 2001 From: Abhijeet Dharmapurikar Date: Fri, 9 Sep 2016 12:00:19 -0700 Subject: [PATCH] qcom-charger: handle get prop errors graciously Currently the code passes on the error value it receives from the individual property getters. This causes the read of uevent to fail. Instead convert those errors to -ENODATA which the power supply framework handles graciously and keeps the read of uevent entry from failing. It simply skips reporting that property in uevent. Change-Id: I997197c7c7315769e49342da7973a9f79ab54c80 Signed-off-by: Abhijeet Dharmapurikar --- drivers/power/qcom-charger/qpnp-smb2.c | 20 ++++++++++++---- drivers/power/qcom-charger/smb138x-charger.c | 24 +++++++++++++------- 2 files changed, 31 insertions(+), 13 deletions(-) diff --git a/drivers/power/qcom-charger/qpnp-smb2.c b/drivers/power/qcom-charger/qpnp-smb2.c index f83b641bcc4f..993856032711 100644 --- a/drivers/power/qcom-charger/qpnp-smb2.c +++ b/drivers/power/qcom-charger/qpnp-smb2.c @@ -392,7 +392,11 @@ static int smb2_usb_get_prop(struct power_supply *psy, rc = -EINVAL; break; } - return rc; + if (rc < 0) { + pr_debug("Couldn't get prop %d rc = %d\n", psp, rc); + return -ENODATA; + } + return 0; } static int smb2_usb_set_prop(struct power_supply *psy, @@ -506,8 +510,11 @@ static int smb2_dc_get_prop(struct power_supply *psy, default: return -EINVAL; } - - return rc; + if (rc < 0) { + pr_debug("Couldn't get prop %d rc = %d\n", psp, rc); + return -ENODATA; + } + return 0; } static int smb2_dc_set_prop(struct power_supply *psy, @@ -633,8 +640,11 @@ static int smb2_batt_get_prop(struct power_supply *psy, pr_err("batt power supply prop %d not supported\n", psp); return -EINVAL; } - - return rc; + if (rc < 0) { + pr_debug("Couldn't get prop %d rc = %d\n", psp, rc); + return -ENODATA; + } + return 0; } static int smb2_batt_set_prop(struct power_supply *psy, diff --git a/drivers/power/qcom-charger/smb138x-charger.c b/drivers/power/qcom-charger/smb138x-charger.c index cc72772dba88..c41ce8c09f86 100644 --- a/drivers/power/qcom-charger/smb138x-charger.c +++ b/drivers/power/qcom-charger/smb138x-charger.c @@ -184,8 +184,11 @@ static int smb138x_usb_get_prop(struct power_supply *psy, pr_err("get prop %d is not supported\n", prop); return -EINVAL; } - - return rc; + if (rc < 0) { + pr_debug("Couldn't get prop %d rc = %d\n", prop, rc); + return -ENODATA; + } + return 0; } static int smb138x_usb_set_prop(struct power_supply *psy, @@ -297,12 +300,14 @@ static int smb138x_batt_get_prop(struct power_supply *psy, rc = smblib_get_prop_batt_capacity(chg, val); break; default: - pr_err("batt power supply get prop %d not supported\n", - prop); + pr_err("batt power supply get prop %d not supported\n", prop); return -EINVAL; } - - return rc; + if (rc < 0) { + pr_debug("Couldn't get prop %d rc = %d\n", prop, rc); + return -ENODATA; + } + return 0; } static int smb138x_batt_set_prop(struct power_supply *psy, @@ -420,8 +425,11 @@ static int smb138x_parallel_get_prop(struct power_supply *psy, prop); return -EINVAL; } - - return rc; + if (rc < 0) { + pr_debug("Couldn't get prop %d rc = %d\n", prop, rc); + return -ENODATA; + } + return 0; } static int smb138x_parallel_set_prop(struct power_supply *psy,