Skip to content

Commit 87eb3cb

Browse files
Heikki Krogerusgregkh
authored andcommitted
usb: typec: ucsi: Fix cable registration
The Cable PD Revision field in GET_CABLE_PROPERTY was introduced in UCSI v2.1, so adding check for that. The cable properties are also not used anywhere after the cable is registered, so removing the cable_prop member from struct ucsi_connector while at it. Fixes: 38ca416 ("usb: typec: ucsi: Register cables based on GET_CABLE_PROPERTY") Cc: [email protected] Signed-off-by: Heikki Krogerus <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Greg Kroah-Hartman <[email protected]>
1 parent de3d796 commit 87eb3cb

File tree

2 files changed

+15
-16
lines changed

2 files changed

+15
-16
lines changed

drivers/usb/typec/ucsi/ucsi.c

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -965,10 +965,20 @@ static void ucsi_unregister_plug(struct ucsi_connector *con)
965965

966966
static int ucsi_register_cable(struct ucsi_connector *con)
967967
{
968+
struct ucsi_cable_property cable_prop;
968969
struct typec_cable *cable;
969970
struct typec_cable_desc desc = {};
971+
u64 command;
972+
int ret;
973+
974+
command = UCSI_GET_CABLE_PROPERTY | UCSI_CONNECTOR_NUMBER(con->num);
975+
ret = ucsi_send_command(con->ucsi, command, &cable_prop, sizeof(cable_prop));
976+
if (ret < 0) {
977+
dev_err(con->ucsi->dev, "GET_CABLE_PROPERTY failed (%d)\n", ret);
978+
return ret;
979+
}
970980

971-
switch (UCSI_CABLE_PROP_FLAG_PLUG_TYPE(con->cable_prop.flags)) {
981+
switch (UCSI_CABLE_PROP_FLAG_PLUG_TYPE(cable_prop.flags)) {
972982
case UCSI_CABLE_PROPERTY_PLUG_TYPE_A:
973983
desc.type = USB_PLUG_TYPE_A;
974984
break;
@@ -984,10 +994,10 @@ static int ucsi_register_cable(struct ucsi_connector *con)
984994
}
985995

986996
desc.identity = &con->cable_identity;
987-
desc.active = !!(UCSI_CABLE_PROP_FLAG_ACTIVE_CABLE &
988-
con->cable_prop.flags);
989-
desc.pd_revision = UCSI_CABLE_PROP_FLAG_PD_MAJOR_REV_AS_BCD(
990-
con->cable_prop.flags);
997+
desc.active = !!(UCSI_CABLE_PROP_FLAG_ACTIVE_CABLE & cable_prop.flags);
998+
999+
if (con->ucsi->version >= UCSI_VERSION_2_1)
1000+
desc.pd_revision = UCSI_CABLE_PROP_FLAG_PD_MAJOR_REV_AS_BCD(cable_prop.flags);
9911001

9921002
cable = typec_register_cable(con->port, &desc);
9931003
if (IS_ERR(cable)) {
@@ -1193,21 +1203,11 @@ static int ucsi_check_connection(struct ucsi_connector *con)
11931203

11941204
static int ucsi_check_cable(struct ucsi_connector *con)
11951205
{
1196-
u64 command;
11971206
int ret, num_plug_am;
11981207

11991208
if (con->cable)
12001209
return 0;
12011210

1202-
command = UCSI_GET_CABLE_PROPERTY | UCSI_CONNECTOR_NUMBER(con->num);
1203-
ret = ucsi_send_command(con->ucsi, command, &con->cable_prop,
1204-
sizeof(con->cable_prop));
1205-
if (ret < 0) {
1206-
dev_err(con->ucsi->dev, "GET_CABLE_PROPERTY failed (%d)\n",
1207-
ret);
1208-
return ret;
1209-
}
1210-
12111211
ret = ucsi_register_cable(con);
12121212
if (ret < 0)
12131213
return ret;

drivers/usb/typec/ucsi/ucsi.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -465,7 +465,6 @@ struct ucsi_connector {
465465

466466
struct ucsi_connector_status status;
467467
struct ucsi_connector_capability cap;
468-
struct ucsi_cable_property cable_prop;
469468
struct power_supply *psy;
470469
struct power_supply_desc psy_desc;
471470
u32 rdo;

0 commit comments

Comments
 (0)