* [PATCH] usb: typec: ucsi: Fix cable registration
@ 2024-08-30 13:02 Heikki Krogerus
2024-09-03 8:06 ` Greg Kroah-Hartman
0 siblings, 1 reply; 3+ messages in thread
From: Heikki Krogerus @ 2024-08-30 13:02 UTC (permalink / raw)
To: Greg Kroah-Hartman
Cc: Benson Leung, Jameson Thies, Abhishek Pandit-Subedi, linux-usb,
stable
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: 38ca416597b0 ("usb: typec: ucsi: Register cables based on GET_CABLE_PROPERTY")
Cc: stable@vger.kernel.org
Signed-off-by: Heikki Krogerus <heikki.krogerus@linux.intel.com>
---
drivers/usb/typec/ucsi/ucsi.c | 30 +++++++++++++++---------------
drivers/usb/typec/ucsi/ucsi.h | 1 -
2 files changed, 15 insertions(+), 16 deletions(-)
diff --git a/drivers/usb/typec/ucsi/ucsi.c b/drivers/usb/typec/ucsi/ucsi.c
index fad43f292e7f..35dce4057c25 100644
--- a/drivers/usb/typec/ucsi/ucsi.c
+++ b/drivers/usb/typec/ucsi/ucsi.c
@@ -911,10 +911,20 @@ static void ucsi_unregister_plug(struct ucsi_connector *con)
static int ucsi_register_cable(struct ucsi_connector *con)
{
+ struct ucsi_cable_property cable_prop;
struct typec_cable *cable;
struct typec_cable_desc desc = {};
+ u64 command;
+ int ret;
+
+ command = UCSI_GET_CABLE_PROPERTY | UCSI_CONNECTOR_NUMBER(con->num);
+ ret = ucsi_send_command(con->ucsi, command, &cable_prop, sizeof(cable_prop));
+ if (ret < 0) {
+ dev_err(con->ucsi->dev, "GET_CABLE_PROPERTY failed (%d)\n", ret);
+ return ret;
+ }
- switch (UCSI_CABLE_PROP_FLAG_PLUG_TYPE(con->cable_prop.flags)) {
+ switch (UCSI_CABLE_PROP_FLAG_PLUG_TYPE(cable_prop.flags)) {
case UCSI_CABLE_PROPERTY_PLUG_TYPE_A:
desc.type = USB_PLUG_TYPE_A;
break;
@@ -931,10 +941,10 @@ static int ucsi_register_cable(struct ucsi_connector *con)
if (con->ucsi->cap.features & UCSI_CAP_GET_PD_MESSAGE)
desc.identity = &con->cable_identity;
- desc.active = !!(UCSI_CABLE_PROP_FLAG_ACTIVE_CABLE &
- con->cable_prop.flags);
- desc.pd_revision = UCSI_CABLE_PROP_FLAG_PD_MAJOR_REV_AS_BCD(
- con->cable_prop.flags);
+ desc.active = !!(UCSI_CABLE_PROP_FLAG_ACTIVE_CABLE & cable_prop.flags);
+
+ if (con->ucsi->version >= UCSI_VERSION_2_1)
+ desc.pd_revision = UCSI_CABLE_PROP_FLAG_PD_MAJOR_REV_AS_BCD(cable_prop.flags);
cable = typec_register_cable(con->port, &desc);
if (IS_ERR(cable)) {
@@ -1141,21 +1151,11 @@ static int ucsi_check_connection(struct ucsi_connector *con)
static int ucsi_check_cable(struct ucsi_connector *con)
{
- u64 command;
int ret, num_plug_am;
if (con->cable)
return 0;
- command = UCSI_GET_CABLE_PROPERTY | UCSI_CONNECTOR_NUMBER(con->num);
- ret = ucsi_send_command(con->ucsi, command, &con->cable_prop,
- sizeof(con->cable_prop));
- if (ret < 0) {
- dev_err(con->ucsi->dev, "GET_CABLE_PROPERTY failed (%d)\n",
- ret);
- return ret;
- }
-
ret = ucsi_register_cable(con);
if (ret < 0)
return ret;
diff --git a/drivers/usb/typec/ucsi/ucsi.h b/drivers/usb/typec/ucsi/ucsi.h
index 63cc7f982663..4a017eb6a65b 100644
--- a/drivers/usb/typec/ucsi/ucsi.h
+++ b/drivers/usb/typec/ucsi/ucsi.h
@@ -435,7 +435,6 @@ struct ucsi_connector {
struct ucsi_connector_status status;
struct ucsi_connector_capability cap;
- struct ucsi_cable_property cable_prop;
struct power_supply *psy;
struct power_supply_desc psy_desc;
u32 rdo;
--
2.45.2
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH] usb: typec: ucsi: Fix cable registration
2024-08-30 13:02 [PATCH] usb: typec: ucsi: Fix cable registration Heikki Krogerus
@ 2024-09-03 8:06 ` Greg Kroah-Hartman
2024-09-03 11:58 ` Heikki Krogerus
0 siblings, 1 reply; 3+ messages in thread
From: Greg Kroah-Hartman @ 2024-09-03 8:06 UTC (permalink / raw)
To: Heikki Krogerus
Cc: Benson Leung, Jameson Thies, Abhishek Pandit-Subedi, linux-usb,
stable
On Fri, Aug 30, 2024 at 04:02:17PM +0300, Heikki Krogerus wrote:
> 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: 38ca416597b0 ("usb: typec: ucsi: Register cables based on GET_CABLE_PROPERTY")
> Cc: stable@vger.kernel.org
> Signed-off-by: Heikki Krogerus <heikki.krogerus@linux.intel.com>
> ---
> drivers/usb/typec/ucsi/ucsi.c | 30 +++++++++++++++---------------
> drivers/usb/typec/ucsi/ucsi.h | 1 -
> 2 files changed, 15 insertions(+), 16 deletions(-)
This doesn't apply to my usb-linus branch at all:
checking file drivers/usb/typec/ucsi/ucsi.c
Hunk #1 succeeded at 965 (offset 54 lines).
Hunk #2 FAILED at 941.
Hunk #3 succeeded at 1203 (offset 52 lines).
1 out of 3 hunks FAILED
checking file drivers/usb/typec/ucsi/ucsi.h
Hunk #1 succeeded at 465 (offset 30 lines).
Can you rebase and resend?
thanks,
greg k-h
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] usb: typec: ucsi: Fix cable registration
2024-09-03 8:06 ` Greg Kroah-Hartman
@ 2024-09-03 11:58 ` Heikki Krogerus
0 siblings, 0 replies; 3+ messages in thread
From: Heikki Krogerus @ 2024-09-03 11:58 UTC (permalink / raw)
To: Greg Kroah-Hartman
Cc: Benson Leung, Jameson Thies, Abhishek Pandit-Subedi, linux-usb,
stable
On Tue, Sep 03, 2024 at 10:06:59AM +0200, Greg Kroah-Hartman wrote:
> On Fri, Aug 30, 2024 at 04:02:17PM +0300, Heikki Krogerus wrote:
> > 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: 38ca416597b0 ("usb: typec: ucsi: Register cables based on GET_CABLE_PROPERTY")
> > Cc: stable@vger.kernel.org
> > Signed-off-by: Heikki Krogerus <heikki.krogerus@linux.intel.com>
> > ---
> > drivers/usb/typec/ucsi/ucsi.c | 30 +++++++++++++++---------------
> > drivers/usb/typec/ucsi/ucsi.h | 1 -
> > 2 files changed, 15 insertions(+), 16 deletions(-)
>
> This doesn't apply to my usb-linus branch at all:
>
> checking file drivers/usb/typec/ucsi/ucsi.c
> Hunk #1 succeeded at 965 (offset 54 lines).
> Hunk #2 FAILED at 941.
> Hunk #3 succeeded at 1203 (offset 52 lines).
> 1 out of 3 hunks FAILED
> checking file drivers/usb/typec/ucsi/ucsi.h
> Hunk #1 succeeded at 465 (offset 30 lines).
>
> Can you rebase and resend?
Will do. Thanks.
--
heikki
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2024-09-03 11:58 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-08-30 13:02 [PATCH] usb: typec: ucsi: Fix cable registration Heikki Krogerus
2024-09-03 8:06 ` Greg Kroah-Hartman
2024-09-03 11:58 ` Heikki Krogerus
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).