From: Heikki Krogerus <heikki.krogerus@linux.intel.com>
To: Andy Yan <andyshrk@163.com>, Badhri Jagan Sridharan <badhri@google.com>
Cc: gregkh@linuxfoundation.org, linux-usb@vger.kernel.org,
linux@roeck-us.net
Subject: Re: [PATCH 2/15] usb: typec: Add parameter for the VDO to typec_altmode_enter()
Date: Mon, 26 Jan 2026 16:13:54 +0200 [thread overview]
Message-ID: <aXd2ogJCAxTjvLDd@kuha> (raw)
In-Reply-To: <20260125035457.354349-1-andyshrk@163.com>
+Badhri
Sun, Jan 25, 2026 at 11:54:22AM +0800, Andy Yan wrote:
> > diff --git a/drivers/usb/typec/tcpm/tcpm.c b/drivers/usb/typec/tcpm/tcpm.c
> > index 56fc356bc55c..f3087ef8265c 100644
> > --- a/drivers/usb/typec/tcpm/tcpm.c
> > +++ b/drivers/usb/typec/tcpm/tcpm.c
> > @@ -1475,16 +1475,16 @@ static int tcpm_validate_caps(struct tcpm_port *port, const u32 *pdo,
> > return 0;
> > }
> >
> > -static int tcpm_altmode_enter(struct typec_altmode *altmode)
> > +static int tcpm_altmode_enter(struct typec_altmode *altmode, u32 *vdo)
> > {
> > struct tcpm_port *port = typec_altmode_get_drvdata(altmode);
> > u32 header;
> >
> > mutex_lock(&port->lock);
> > - header = VDO(altmode->svid, 1, CMD_ENTER_MODE);
> > + header = VDO(altmode->svid, vdo ? 2 : 1, CMD_ENTER_MODE);
> > header |= VDO_OPOS(altmode->mode);
>
> Sorry to bother you. I happened to come across this piece of code and
> I'm not quite clear about this part: vdo ? 2 : 1
>
> According to the definition of the VDO macro(pd_vdo.h), the type here is
> only 1 bit wide, located at bit 15. If the type value is set to 2 here,
> wouldn’t that overwrite bit 16?
That looks like just an obvious bug to me.
thanks,
> /*
> * VDM header
> * ----------
> * <31:16> :: SVID
> * <15> :: VDM type ( 1b == structured, 0b == unstructured )
> * <14:13> :: Structured VDM version
> * <12:11> :: reserved
> * <10:8> :: object position (1-7 valid ... used for enter/exit mode only)
> * <7:6> :: command type (SVDM only?)
> * <5> :: reserved (SVDM), command type (UVDM)
> * <4:0> :: command
> */
> #define VDO(vid, type, ver, custom) \
> (((vid) << 16) | \
> ((type) << 15) | \
> ((ver) << 13) | \
> ((custom) & 0x7FFF))
>
>
> >- tcpm_queue_vdm(port, header, NULL, 0);
> >+ tcpm_queue_vdm(port, header, vdo, vdo ? 1 : 0);
> > mod_delayed_work(port->wq, &port->vdm_state_machine, 0);
--
heikki
next prev parent reply other threads:[~2026-01-26 14:14 UTC|newest]
Thread overview: 24+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-12-30 14:25 [PATCH 00/15] USB Type-C changes Heikki Krogerus
2019-12-30 14:25 ` [PATCH 01/15] usb: typec: Block mode entry if the port has the mode disabled Heikki Krogerus
2019-12-30 14:25 ` [PATCH 02/15] usb: typec: Add parameter for the VDO to typec_altmode_enter() Heikki Krogerus
2026-01-25 3:54 ` [PATCH 2/15] " Andy Yan
2026-01-26 14:13 ` Heikki Krogerus [this message]
2026-01-26 14:26 ` Heikki Krogerus
2026-01-28 2:38 ` Badhri Jagan Sridharan
2019-12-30 14:25 ` [PATCH 03/15] usb: typec: More API for cable handling Heikki Krogerus
2019-12-30 14:26 ` [PATCH 04/15] usb: typec: Make the attributes read-only when writing is not possible Heikki Krogerus
2020-01-09 9:46 ` Greg Kroah-Hartman
2020-01-09 11:28 ` Heikki Krogerus
2019-12-30 14:26 ` [PATCH 05/15] usb: typec: Hide the port_type attribute when it's not supported Heikki Krogerus
2019-12-30 14:26 ` [PATCH 06/15] usb: typec: Allow power role swapping even without USB PD Heikki Krogerus
2019-12-30 14:26 ` [PATCH 07/15] usb: typec: Fix the description of struct typec_capability Heikki Krogerus
2019-12-30 14:26 ` [PATCH 08/15] usb: pd: Add definitions for the Enter_USB message Heikki Krogerus
2019-12-30 14:26 ` [PATCH 09/15] usb: pd: Add definition for DFP and UFP1 VDOs Heikki Krogerus
2019-12-30 14:26 ` [PATCH 10/15] usb: typec: Add the Product Type VDOs to struct usb_pd_identity Heikki Krogerus
2019-12-30 14:26 ` [PATCH 11/15] usb: typec: Add definitions for the latest specification releases Heikki Krogerus
2019-12-30 14:26 ` [PATCH 12/15] usb: typec: Give the mux drivers all the details regarding the port state Heikki Krogerus
2019-12-30 14:26 ` [PATCH 13/15] usb: typec: Provide definitions for the USB modes Heikki Krogerus
2019-12-30 14:26 ` [PATCH 14/15] usb: typec: Add member for the supported USB modes to struct typec_capability Heikki Krogerus
2020-01-09 9:52 ` Greg Kroah-Hartman
2020-01-09 11:30 ` Heikki Krogerus
2019-12-30 14:26 ` [PATCH 15/15] usb: typec: ucsi: Store the supported USB modes Heikki Krogerus
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=aXd2ogJCAxTjvLDd@kuha \
--to=heikki.krogerus@linux.intel.com \
--cc=andyshrk@163.com \
--cc=badhri@google.com \
--cc=gregkh@linuxfoundation.org \
--cc=linux-usb@vger.kernel.org \
--cc=linux@roeck-us.net \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox