diff options
author | Christian A. Ehrhardt <lk@c--e.de> | 2024-04-02 00:05:15 +0300 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@linuxfoundation.org> | 2024-05-17 12:51:02 +0300 |
commit | a6b9bffbcbb8ef083666a4a65bf9c34d4ef45efa (patch) | |
tree | 8e8226aadbe6dd9ae2c928b330988099020d752a | |
parent | 5f499d7421ace7169fed5636243d0a2613cb7a49 (diff) | |
download | linux-a6b9bffbcbb8ef083666a4a65bf9c34d4ef45efa.tar.xz |
usb: typec: ucsi: Fix connector check on init
commit ce4c8d21054ae9396cd759fe6e8157b525616dc4 upstream.
Fix issues when initially checking for a connector change:
- Use the correct connector number not the entire CCI.
- Call ->read under the PPM lock.
- Remove a bogus READ_ONCE.
Fixes: 808a8b9e0b87 ("usb: typec: ucsi: Check for notifications after init")
Cc: stable@kernel.org
Signed-off-by: Christian A. Ehrhardt <lk@c--e.de>
Reviewed-by: Heikki Krogerus <heikki.krogerus@linux.intel.com>
Link: https://lore.kernel.org/r/20240401210515.1902048-1-lk@c--e.de
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
-rw-r--r-- | drivers/usb/typec/ucsi/ucsi.c | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/drivers/usb/typec/ucsi/ucsi.c b/drivers/usb/typec/ucsi/ucsi.c index df7c42df9ea0..cb6458ec042c 100644 --- a/drivers/usb/typec/ucsi/ucsi.c +++ b/drivers/usb/typec/ucsi/ucsi.c @@ -1294,11 +1294,13 @@ static int ucsi_init(struct ucsi *ucsi) ucsi->ntfy = ntfy; + mutex_lock(&ucsi->ppm_lock); ret = ucsi->ops->read(ucsi, UCSI_CCI, &cci, sizeof(cci)); + mutex_unlock(&ucsi->ppm_lock); if (ret) return ret; - if (UCSI_CCI_CONNECTOR(READ_ONCE(cci))) - ucsi_connector_change(ucsi, cci); + if (UCSI_CCI_CONNECTOR(cci)) + ucsi_connector_change(ucsi, UCSI_CCI_CONNECTOR(cci)); return 0; |