From 4efcb687cd41ad33ad69148d1a76ff574b7a9451 Mon Sep 17 00:00:00 2001 From: huangjq9 Date: Wed, 25 Sep 2019 10:43:04 +0800 Subject: [PATCH] sarsensor: fix usb_cal issue for a96t device When the power state is changing, which causes the USB plug to be mistaken, and the sar sensor is calibrated. Change-Id: Ia844dd891bc1301c7fa2f73617db92ccbdb6a435 Signed-off-by: huangjq9 Reviewed-on: https://gerrit.mot.com/1426418 SME-Granted: SME Approvals Granted SLTApproved: Slta Waiver Tested-by: Jira Key Reviewed-by: Jun Weng Reviewed-by: Jiacheng Ou Reviewed-by: Huosheng Liao Submit-Approved: Jira Key --- drivers/misc/abov_a96t/abov_sar_a96t.c | 22 +++++++++++++--------- 1 file changed, 13 insertions(+), 9 deletions(-) diff --git a/drivers/misc/abov_a96t/abov_sar_a96t.c b/drivers/misc/abov_a96t/abov_sar_a96t.c index 149cdb762942..bb8fd23ef589 100644 --- a/drivers/misc/abov_a96t/abov_sar_a96t.c +++ b/drivers/misc/abov_a96t/abov_sar_a96t.c @@ -35,6 +35,7 @@ #include #include #include +#include #define SLEEP(x) mdelay(x) #define C_I2C_FIFO_SIZE 8 @@ -786,13 +787,13 @@ static int ps_get_state(struct power_supply *psy, bool *present) retval = power_supply_get_property(psy, POWER_SUPPLY_PROP_PRESENT, &pval); - /*if (retval) { - LOG_DBG("%s psy get property failed\n", psy->name); + if (retval) { + LOG_DBG("%s psy get property failed\n", psy->desc->name); return retval; - }*/ + } *present = (pval.intval) ? true : false; - /*LOG_INFO("%s is %s\n", psy->name, - (*present) ? "present" : "not present");*/ + LOG_INFO("%s is %s\n", psy->desc->name, + (*present) ? "present" : "not present"); return 0; } @@ -804,10 +805,13 @@ static int ps_notify_callback(struct notifier_block *self, bool present; int retval; - /*if ((event == PSY_EVENT_PROP_ADDED || event == PSY_EVENT_PROP_CHANGED) - && psy && psy->get_property && psy->name && - !strncmp(psy->name, "usb", sizeof("usb"))) {*/ - if (event == PSY_EVENT_PROP_CHANGED) { +#if LINUX_VERSION_CODE >= KERNEL_VERSION(4,9,0) + if (event == PSY_EVENT_PROP_CHANGED +#else + if ((event == PSY_EVENT_PROP_ADDED || event == PSY_EVENT_PROP_CHANGED) +#endif + && psy && psy->desc->get_property && psy->desc->name && + !strncmp(psy->desc->name, "usb", sizeof("usb"))){ LOG_INFO("ps notification: event = %lu\n", event); retval = ps_get_state(psy, &present); if (retval) {