Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

usb: typec: ucsi: Always set number of alternate modes

Providing the number of known alternate modes allows user space to
determine when device registration has completed. Always register a
number of known alternate modes for the partner and cable plug, even
when the number of supported alternate modes is 0.

Reviewed-by: Heikki Krogerus <heikki.krogerus@linux.intel.com>
Reviewed-by: Benson Leung <bleung@chromium.org>
Signed-off-by: Jameson Thies <jthies@google.com>
Reviewed-by: Dmitry Baryshkov <dmitry.baryshkov@linaro.org>
Link: https://lore.kernel.org/r/20240510201244.2968152-5-jthies@google.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

authored by

Jameson Thies and committed by
Greg Kroah-Hartman
c313a44a 4ea9d86d

+11 -3
+11 -3
drivers/usb/typec/ucsi/ucsi.c
··· 812 812 /* Ignoring the errors in this case. */ 813 813 if (con->partner_altmode[0]) { 814 814 num_partner_am = ucsi_get_num_altmode(con->partner_altmode); 815 - if (num_partner_am > 0) 816 - typec_partner_set_num_altmodes(con->partner, num_partner_am); 815 + typec_partner_set_num_altmodes(con->partner, num_partner_am); 817 816 ucsi_altmode_update_active(con); 818 817 return 0; 818 + } else { 819 + typec_partner_set_num_altmodes(con->partner, 0); 819 820 } 820 821 821 822 return ret; ··· 1139 1138 static int ucsi_check_cable(struct ucsi_connector *con) 1140 1139 { 1141 1140 u64 command; 1142 - int ret; 1141 + int ret, num_plug_am; 1143 1142 1144 1143 if (con->cable) 1145 1144 return 0; ··· 1171 1170 ret = ucsi_register_altmodes(con, UCSI_RECIPIENT_SOP_P); 1172 1171 if (ret < 0) 1173 1172 return ret; 1173 + } 1174 + 1175 + if (con->plug_altmode[0]) { 1176 + num_plug_am = ucsi_get_num_altmode(con->plug_altmode); 1177 + typec_plug_set_num_altmodes(con->plug, num_plug_am); 1178 + } else { 1179 + typec_plug_set_num_altmodes(con->plug, 0); 1174 1180 } 1175 1181 1176 1182 return 0;