diff options
author | Kyle Tso <kyletso@google.com> | 2023-11-21 16:21:30 +0800 |
---|---|---|
committer | Cherrypicker Worker QA <android-build-cherrypicker-worker@system.gserviceaccount.com> | 2023-11-28 03:04:19 +0000 |
commit | bae4e3ac7e7af230e3a0d759e369156eeb80223c (patch) | |
tree | e47a5c1f41633b573a912789e22eff89324d941d | |
parent | d89c0da129893b0d62a0a7d25a4038d383be9f0b (diff) | |
download | gs-bae4e3ac7e7af230e3a0d759e369156eeb80223c.tar.gz |
tcpci_max77759: Introduce ovp_lock
There are GPIO get and set inside ovp_operation. Protect it by adding a
dedicated lock to avoid race condition among different contexts.
Bug: 309900468
Signed-off-by: Kyle Tso <kyletso@google.com>
(cherry picked from https://partner-android-review.googlesource.com/q/commit:9a181615591c5728044e99620cf38de828e1e79b)
Merged-In: I217c5b1ccddf6ebff60fef4a3e2aae6972c79903
Change-Id: I217c5b1ccddf6ebff60fef4a3e2aae6972c79903
-rw-r--r-- | drivers/usb/typec/tcpm/google/tcpci_max77759.c | 3 | ||||
-rw-r--r-- | drivers/usb/typec/tcpm/google/tcpci_max77759.h | 1 |
2 files changed, 4 insertions, 0 deletions
diff --git a/drivers/usb/typec/tcpm/google/tcpci_max77759.c b/drivers/usb/typec/tcpm/google/tcpci_max77759.c index aebbfbf98..98658f35c 100644 --- a/drivers/usb/typec/tcpm/google/tcpci_max77759.c +++ b/drivers/usb/typec/tcpm/google/tcpci_max77759.c @@ -1498,6 +1498,7 @@ static void ovp_operation(struct max77759_plat *chip, int operation) { int gpio_val, retry = 0; + mutex_lock(&chip->ovp_lock); if (operation == OVP_RESET || operation == OVP_OFF) { do { gpio_set_value_cansleep(chip->in_switch_gpio, @@ -1523,6 +1524,7 @@ static void ovp_operation(struct max77759_plat *chip, int operation) __func__, gpio_val, chip->in_switch_gpio_active_high, retry++); } while ((gpio_val != chip->in_switch_gpio_active_high) && (retry < OVP_OP_RETRY)); } + mutex_unlock(&chip->ovp_lock); } static void reset_ovp_work(struct kthread_work *work) @@ -3110,6 +3112,7 @@ static int max77759_probe(struct i2c_client *client, mutex_init(&chip->rc_lock); mutex_init(&chip->irq_status_lock); mutex_init(&chip->toggle_lock); + mutex_init(&chip->ovp_lock); spin_lock_init(&g_caps_lock); chip->first_toggle = true; chip->first_rp_missing_timeout = true; diff --git a/drivers/usb/typec/tcpm/google/tcpci_max77759.h b/drivers/usb/typec/tcpm/google/tcpci_max77759.h index 44b258e03..7cb47c4c7 100644 --- a/drivers/usb/typec/tcpm/google/tcpci_max77759.h +++ b/drivers/usb/typec/tcpm/google/tcpci_max77759.h @@ -85,6 +85,7 @@ struct max77759_plat { /* Indicate that the Vbus OVP is restricted to quick ramp-up time for incoming voltage. */ bool quick_ramp_vbus_ovp; int reset_ovp_retry; + struct mutex ovp_lock; /* Set true to vote "limit_accessory_current" on USB ICL */ bool limit_accessory_enable; /* uA */ |