From: Dmitry Baryshkov Date: Sat, 21 Jun 2025 18:13:01 +0000 (+0300) Subject: usb: typec: ucsi: yoga-c630: correct response for GET_CURRENT_CAM X-Git-Url: https://www.infradead.org/git/?a=commitdiff_plain;h=e943c93333e305d1c02f946473227de06caed702;p=users%2Fjedix%2Flinux-maple.git usb: typec: ucsi: yoga-c630: correct response for GET_CURRENT_CAM On Lenovo Yoga C630 the EC handles GET_CURRENT_CAM command, but it returns 1 if DisplayPort is active and 0 otherwise. However in order to let UCSI drivers handle AltModes correctly, it should return 0 / 0xff. Correct returned value. Signed-off-by: Dmitry Baryshkov Reviewed-by: Heikki Krogerus Link: https://lore.kernel.org/r/20250621-c630-ucsi-v1-6-a86de5e11361@oss.qualcomm.com Signed-off-by: Greg Kroah-Hartman --- diff --git a/drivers/usb/typec/ucsi/ucsi_yoga_c630.c b/drivers/usb/typec/ucsi/ucsi_yoga_c630.c index 506faf31b6e3..76afd128d42a 100644 --- a/drivers/usb/typec/ucsi/ucsi_yoga_c630.c +++ b/drivers/usb/typec/ucsi/ucsi_yoga_c630.c @@ -111,7 +111,15 @@ static int yoga_c630_ucsi_sync_control(struct ucsi *ucsi, return 0; } - return ucsi_sync_control_common(ucsi, command, cci, data, size); + ret = ucsi_sync_control_common(ucsi, command, cci, data, size); + if (ret < 0) + return ret; + + /* UCSI_GET_CURRENT_CAM is off-by-one on all ports */ + if (UCSI_COMMAND(command) == UCSI_GET_CURRENT_CAM && data) + ((u8 *)data)[0]--; + + return ret; } static bool yoga_c630_ucsi_update_altmodes(struct ucsi *ucsi,