mirror of
https://github.com/BobTheBlinker/android_kernel_motorola_sm6375.git
synced 2026-10-10 22:40:54 -04:00
Revert "(CR) sx937x:mv ps_get_state to work callback"
This reverts commit c2f744d014225db0494144bcc874be8d0c3dbf13. Change-Id: I14be7ed2aefdd0522d70f6eb2ac2d7c9e2d8e254 Reviewed-on: https://gerrit.mot.com/1991079 SLTApproved: Slta Waiver SME-Granted: SME Approvals Granted Tested-by: Jira Key Reviewed-by: Tao Sun <suntao2@motorola.com> Submit-Approved: Jira Key
This commit is contained in:
parent
409613e8c7
commit
908e2bdb8b
2 changed files with 33 additions and 66 deletions
|
|
@ -1174,6 +1174,16 @@ static int capsensor_set_enable(struct sensors_classdev *sensors_cdev,
|
|||
}
|
||||
|
||||
#ifdef CONFIG_CAPSENSE_USB_CAL
|
||||
static void ps_notify_callback_work(struct work_struct *work)
|
||||
{
|
||||
u32 temp = 0;
|
||||
sx937x_i2c_read_16bit(global_sx937x, SX937X_GENERAL_SETUP, &temp);
|
||||
if (temp & 0x000000FF) {
|
||||
LOG_DBG("USB state change, Going to force calibrate\n");
|
||||
manual_offset_calibration(global_sx937x);
|
||||
}
|
||||
}
|
||||
|
||||
static int ps_get_state(struct power_supply *psy, bool *present)
|
||||
{
|
||||
union power_supply_propval pval = {0};
|
||||
|
|
@ -1204,63 +1214,14 @@ static int ps_get_state(struct power_supply *psy, bool *present)
|
|||
return 0;
|
||||
}
|
||||
|
||||
static void ps_notify_callback_work(struct work_struct *work)
|
||||
{
|
||||
u32 temp = 0;
|
||||
bool present;
|
||||
int retval;
|
||||
struct sx937x_platform_data *data =
|
||||
container_of(work, struct sx937x_platform_data, ps_notify_work);
|
||||
|
||||
|
||||
if (global_sx937x->psy_event == SX93XX_PSY_EVENT_USB)
|
||||
{
|
||||
retval = ps_get_state(global_sx937x->psy, &present);
|
||||
if (retval) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (data->ps_is_present == present) {
|
||||
LOG_DBG("ps present state not change\n");
|
||||
return;
|
||||
}
|
||||
data->ps_is_present = present;
|
||||
sx937x_i2c_read_16bit(global_sx937x, SX937X_GENERAL_SETUP, &temp);
|
||||
if (temp & 0x000000FF) {
|
||||
LOG_ERR("USB state change, Going to force calibrate\n");
|
||||
manual_offset_calibration(global_sx937x);
|
||||
}
|
||||
global_sx937x->psy_event = SX93XX_PSY_EVENT_UNKNOWN;
|
||||
}
|
||||
|
||||
#ifdef CONFIG_CAPSENSE_ATTACH_CAL
|
||||
if (global_sx937x->psy_event == SX93XX_PSY_EVENT_PHONE)
|
||||
{
|
||||
retval = ps_get_state(global_sx937x->psy, &present);
|
||||
if (retval)
|
||||
return retval;
|
||||
|
||||
if (data->phone_is_present != present) {
|
||||
data->phone_is_present = present;
|
||||
sx937x_i2c_read_16bit(global_sx937x, SX937X_GENERAL_SETUP, &temp);
|
||||
if (temp & 0x000000FF) {
|
||||
LOG_ERR("Phone state change, Going to force calibrate\n");
|
||||
manual_offset_calibration(global_sx937x);
|
||||
}
|
||||
}
|
||||
global_sx937x->psy_event = SX93XX_PSY_EVENT_UNKNOWN;
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
static int ps_notify_callback(struct notifier_block *self,
|
||||
unsigned long event, void *p)
|
||||
{
|
||||
struct sx937x_platform_data *data =
|
||||
container_of(self, struct sx937x_platform_data, ps_notif);
|
||||
struct power_supply *psy = p;
|
||||
global_sx937x->psy = p;
|
||||
global_sx937x->psy_event = SX93XX_PSY_EVENT_UNKNOWN;
|
||||
bool present;
|
||||
int retval;
|
||||
|
||||
#if LINUX_VERSION_CODE >= KERNEL_VERSION(4,9,0)
|
||||
if (event == PSY_EVENT_PROP_CHANGED
|
||||
|
|
@ -1270,7 +1231,18 @@ static int ps_notify_callback(struct notifier_block *self,
|
|||
&& psy && psy->desc->get_property && psy->desc->name &&
|
||||
!strncmp(psy->desc->name, "usb", sizeof("usb")) && data) {
|
||||
LOG_DBG("ps notification: event = %lu\n", event);
|
||||
global_sx937x->psy_event = SX93XX_PSY_EVENT_USB;
|
||||
retval = ps_get_state(psy, &present);
|
||||
if (retval) {
|
||||
return retval;
|
||||
}
|
||||
|
||||
if (event == PSY_EVENT_PROP_CHANGED) {
|
||||
if (data->ps_is_present == present) {
|
||||
LOG_DBG("ps present state not change\n");
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
data->ps_is_present = present;
|
||||
schedule_work(&data->ps_notify_work);
|
||||
}
|
||||
|
||||
|
|
@ -1279,8 +1251,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_DBG("phone ps notification: event = %lu\n", event);
|
||||
global_sx937x->psy_event = SX93XX_PSY_EVENT_PHONE;
|
||||
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
|
||||
|
||||
|
|
|
|||
|
|
@ -481,15 +481,6 @@ typedef struct sx937x_platform_data *psx937x_platform_data_t;
|
|||
|
||||
#define MAX_NUM_STATUS_BITS (8)
|
||||
|
||||
|
||||
typedef enum{
|
||||
SX93XX_PSY_EVENT_UNKNOWN = 0,
|
||||
SX93XX_PSY_EVENT_USB,
|
||||
#ifdef CONFIG_CAPSENSE_ATTACH_CAL
|
||||
SX93XX_PSY_EVENT_PHONE,
|
||||
#endif
|
||||
}sx93xx_psy_supply_type_t;
|
||||
|
||||
typedef struct sx93XX sx93XX_t, *psx93XX_t;
|
||||
struct sx93XX
|
||||
{
|
||||
|
|
@ -539,9 +530,6 @@ struct sx93XX
|
|||
atomic_t init_busy;
|
||||
struct delayed_work i2c_watchdog_work;
|
||||
int suspended;
|
||||
|
||||
struct power_supply *psy;
|
||||
sx93xx_psy_supply_type_t psy_event;
|
||||
};
|
||||
|
||||
int sx93XX_IRQ_init(psx93XX_t this);
|
||||
|
|
|
|||
Loading…
Reference in a new issue