diff options
author | chloedai <chloedai@google.com> | 2021-11-12 09:23:12 +0000 |
---|---|---|
committer | chloedai <chloedai@google.com> | 2021-11-15 03:22:28 +0000 |
commit | 5bc9122386af59f1e12798da30327077c0cb172d (patch) | |
tree | fee1e2dc3c2837e4d387fa8a5fe710dc05edf796 | |
parent | 4c5cb689ab259e1bc6251077a63b938856c8caa9 (diff) | |
download | nfc-5bc9122386af59f1e12798da30327077c0cb172d.tar.gz |
Fix wrong state transition in st21nfc_resume
Check the value of pidle_active_low when st21nfc_resume to fit the
right behavior of GPIO when ST21NFC Idle/Active, preventing the
st21nfc_power_stats_switch Error: Switched from IDLE to IDLE
Bug: 206060289
Test: Test pass
Change-Id: Iee56ea070d810e72d993cd9a279ec1e51417f054
-rw-r--r-- | st21nfc.c | 28 |
1 files changed, 11 insertions, 17 deletions
@@ -39,7 +39,7 @@ #define WAKEUP_SRC_TIMEOUT (2000) #define EXYNOS_CLK_MASK 0x01 -#define DRIVER_VERSION "2.0.18" +#define DRIVER_VERSION "2.0.19" #define PROP_PWR_MON_RW_ON_NTF nci_opcode_pack(NCI_GID_PROPRIETARY, 5) #define PROP_PWR_MON_RW_OFF_NTF nci_opcode_pack(NCI_GID_PROPRIETARY, 6) @@ -354,18 +354,12 @@ static void st21nfc_power_stats_switch( static void st21nfc_power_stats_idle_signal(struct st21nfc_device *st21nfc_dev) { uint64_t current_time_ms = ktime_to_ms(ktime_get_boottime()); - int value = gpiod_get_value(st21nfc_dev->gpiod_pidle); + bool is_active = (bool) gpiod_get_value(st21nfc_dev->gpiod_pidle); + is_active = st21nfc_dev->pidle_active_low ? !is_active : is_active; - if (st21nfc_dev->pidle_active_low) - value = !value; - - if (value != 0) { - st21nfc_power_stats_switch(st21nfc_dev, current_time_ms, - st21nfc_dev->pw_current, ST21NFC_ACTIVE, false); - } else { - st21nfc_power_stats_switch(st21nfc_dev, current_time_ms, - st21nfc_dev->pw_current, ST21NFC_IDLE, false); - } + st21nfc_power_stats_switch(st21nfc_dev, current_time_ms, + st21nfc_dev->pw_current, is_active ? ST21NFC_ACTIVE : ST21NFC_IDLE, + false); } static void st21nfc_pstate_wq(struct work_struct *work) @@ -1145,7 +1139,6 @@ static int st21nfc_resume(struct device *device) { struct i2c_client *client = to_i2c_client(device); struct st21nfc_device *st21nfc_dev = i2c_get_clientdata(client); - int pidle; if (device_may_wakeup(&client->dev) && st21nfc_dev->irq_wake_up) { if (!disable_irq_wake(client->irq)) @@ -1153,10 +1146,11 @@ static int st21nfc_resume(struct device *device) } if (!IS_ERR(st21nfc_dev->gpiod_pidle)) { - pidle = gpiod_get_value(st21nfc_dev->gpiod_pidle); - if((st21nfc_dev->p_idle_last != pidle) || - (st21nfc_dev->pw_current == ST21NFC_IDLE && pidle != 0) || - (st21nfc_dev->pw_current == ST21NFC_ACTIVE && pidle == 0)) { + bool is_active = (bool) gpiod_get_value(st21nfc_dev->gpiod_pidle); + is_active = st21nfc_dev->pidle_active_low ? !is_active : is_active; + if((st21nfc_dev->p_idle_last != is_active) || + (st21nfc_dev->pw_current == ST21NFC_IDLE && is_active) || + (st21nfc_dev->pw_current == ST21NFC_ACTIVE && !is_active)) { queue_work(st21nfc_dev->st_p_wq, &(st21nfc_dev->st_p_work)); } |