usb: typec: ucsi: Fix connector check on init
Subsystems (2)
PATCH 1/1 usb: typec: ucsi: Fix connector check on init
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")
Signed-off-by Christian A. Ehrhardt <[email protected]>
--- drivers/usb/typec/ucsi/ucsi.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-)
drivers/usb/typec/ucsi/ucsi.c +4 -2
@@ -1736,11 +1736,13 @@ static int ucsi_init(struct ucsi *ucsi) ucsi->connector = connector; 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 ;
Signature · 1 line
2.40.1
Quoted 8 lines · Christian A. Ehrhardt
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 bogusREAD_ONCE.Fixes 808a8b9e0b87 ("usb: typec: ucsi: Check for notifications after init")Signed-off-by Christian A. Ehrhardt <[email protected]>
Reviewed-by Heikki Krogerus <[email protected]>
Quoted 26 lines
--- drivers/usb/typec/ucsi/ucsi.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-)drivers/usb/typec/ucsi/ucsi.c +4
-2@@ -1736,11 +1736,13 @@ static int ucsi_init(struct ucsi *ucsi) ucsi->connector = connector; 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 ;Signature · 1 line
2.40.1
Signature · 1 line
heikki