[<prev] [next>] [day] [month] [year] [list]
Message-Id: <20251118-ucsi-v2-1-d314d50333e2@chromium.org>
Date: Tue, 18 Nov 2025 15:06:53 +0800
From: Hsin-Te Yuan <yuanhsinte@...omium.org>
To: Heikki Krogerus <heikki.krogerus@...ux.intel.com>,
Greg Kroah-Hartman <gregkh@...uxfoundation.org>
Cc: linux-usb@...r.kernel.org, linux-kernel@...r.kernel.org,
Hsin-Te Yuan <yuanhsinte@...omium.org>
Subject: [PATCH v2] usb: typec: ucsi: Monitor connector change before
getting connector status
Originally, the notification for connector change will be enabled after
the first read of the connector status. Therefore, if the event happens
during this window, it will be missing and make the status unsynced.
Enable the notification for connector change before getting the
connector status to ensure the status is synced.
Signed-off-by: Hsin-Te Yuan <yuanhsinte@...omium.org>
---
Changes in v2:
- Remove unnecessary braces.
- Link to v1: https://lore.kernel.org/r/20251117-ucsi-v1-1-1dcbc5ea642b@chromium.org
---
drivers/usb/typec/ucsi/ucsi.c | 10 +++++++++-
1 file changed, 9 insertions(+), 1 deletion(-)
diff --git a/drivers/usb/typec/ucsi/ucsi.c b/drivers/usb/typec/ucsi/ucsi.c
index 3f568f790f39b0271667e80816270274b8dd3008..a7e0023d6504921d5be3795aecf84b83d33c66d1 100644
--- a/drivers/usb/typec/ucsi/ucsi.c
+++ b/drivers/usb/typec/ucsi/ucsi.c
@@ -1565,7 +1565,7 @@ static int ucsi_register_port(struct ucsi *ucsi, struct ucsi_connector *con)
struct typec_capability *cap = &con->typec_cap;
enum typec_accessory *accessory = cap->accessory;
enum usb_role u_role = USB_ROLE_NONE;
- u64 command;
+ u64 command, ntfy;
char *name;
int ret;
@@ -1659,6 +1659,14 @@ static int ucsi_register_port(struct ucsi *ucsi, struct ucsi_connector *con)
goto out;
}
+ /* Enable the notification for connector change before getting the connector status */
+ ntfy = UCSI_ENABLE_NTFY_CMD_COMPLETE | UCSI_ENABLE_NTFY_ERROR | UCSI_ENABLE_NTFY_CONNECTOR_CHANGE;
+ command = UCSI_SET_NOTIFICATION_ENABLE | ntfy;
+ ret = ucsi_send_command(ucsi, command, NULL, 0);
+ if (ret < 0)
+ dev_warn(ucsi->dev, "con%d: failed to enable the notification for connector change\n",
+ con->num);
+
/* Get the status */
ret = ucsi_get_connector_status(con, false);
if (ret) {
---
base-commit: 6a23ae0a96a600d1d12557add110e0bb6e32730c
change-id: 20251117-ucsi-c2dfe8c006d7
Best regards,
--
Hsin-Te Yuan <yuanhsinte@...omium.org>
Powered by blists - more mailing lists