From 53d25de0609fbab36e1325f88f19cde18b16edb5 Mon Sep 17 00:00:00 2001 From: Ryan Lattrel Date: Wed, 5 Dec 2018 16:27:39 -0600 Subject: [PATCH] sx933x: calibrate on phone present Limit the recalibration on phone power supply events to present changed. Change-Id: I6c6a49820ef93c3062c13c56aa3322b495ea40b4 Signed-off-by: Ryan Lattrel Reviewed-on: https://gerrit.mot.com/1279109 SLTApproved: Slta Waiver SME-Granted: SME Approvals Granted Tested-by: Jira Key Reviewed-by: Kenneth Kessler Submit-Approved: Jira Key --- drivers/misc/sx933x/sx933x_sar.c | 10 +++++++++- include/linux/input/sx933x.h | 3 +++ 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/drivers/misc/sx933x/sx933x_sar.c b/drivers/misc/sx933x/sx933x_sar.c index 02d2ddd8d746..7ecabe192ede 100644 --- a/drivers/misc/sx933x/sx933x_sar.c +++ b/drivers/misc/sx933x/sx933x_sar.c @@ -831,7 +831,15 @@ static int ps_notify_callback(struct notifier_block *self, && psy && psy->desc->get_property && psy->desc->name && !strncmp(psy->desc->name, "phone", sizeof("phone")) && data) { LOG_INFO("phone ps notification: event = %lu\n", event); - schedule_work(&data->ps_notify_work); + + retval = ps_get_state(psy, &present); + if (retval) + return retval; + + if (data->phone_is_present != present) { + data->phone_is_present = present; + schedule_work(&data->ps_notify_work); + } } #endif diff --git a/include/linux/input/sx933x.h b/include/linux/input/sx933x.h index a570f569aa4a..01f9745fba33 100644 --- a/include/linux/input/sx933x.h +++ b/include/linux/input/sx933x.h @@ -700,6 +700,9 @@ struct sx933x_platform_data struct work_struct ps_notify_work; struct notifier_block ps_notif; bool ps_is_present; +#ifdef CONFIG_CAPSENSE_ATTACH_CAL + bool phone_is_present; +#endif #endif pbuttonInformation_t pbuttonInformation;