public inbox for linux-usb@vger.kernel.org
 help / color / mirror / Atom feed
From: Arnaud Ferraris <arnaud.ferraris@collabora.com>
To: Xu Yang <xu.yang_2@nxp.com>,
	badhri@google.com, heikki.krogerus@linux.intel.com,
	gregkh@linuxfoundation.org, dsimic@manjaro.org
Cc: linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org,
	imx@lists.linux.dev, jun.li@nxp.com
Subject: Re: [PATCH v2 2/2] usb: roles: get usb role switch from parent only for usb-b-connector
Date: Mon, 9 Mar 2026 10:12:52 +0100	[thread overview]
Message-ID: <0b3b80ac-5cc2-4c19-a8f1-b8b44992eec4@collabora.com> (raw)
In-Reply-To: <20260309074313.2809867-3-xu.yang_2@nxp.com>



Le 09/03/2026 à 08:43, Xu Yang a écrit :
> usb_role_switch_is_parent() was walking up to the parent node and checking
> for the "usb-role-switch" property regardless of the type of the passed
> fwnode. This could cause unrelated device nodes to be probed as potential
> role switch parent, leading to spurious matches and "-EPROBE_DEFER" being
> returned infinitely.
> 
> Till now only Type-B connector node will have a parent node which may
> present "usb-role-switch" property and register the role switch device.
> For Type-C connector node, its parent node will always be a Type-C chip
> device which will never register the role switch device. However, it may
> still present a non-boolean "usb-role-switch = <&usb_controller>" property
> for historical compatibility.
> 
> So restrict the helper to only operate on Type-B connector when attempting
> to get the role switch from parent node.
> 
> Fixes: 6fadd72943b8 ("usb: roles: get usb-role-switch from parent")
> Cc: stable@vger.kernel.org
> Signed-off-by: Xu Yang <xu.yang_2@nxp.com>
> 
> ---
> Changes in v2:
>   - new patch
> ---
>   drivers/usb/roles/class.c | 7 ++++++-
>   1 file changed, 6 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/usb/roles/class.c b/drivers/usb/roles/class.c
> index b8e28ceca51e..edec139b68b5 100644
> --- a/drivers/usb/roles/class.c
> +++ b/drivers/usb/roles/class.c
> @@ -139,9 +139,14 @@ static void *usb_role_switch_match(const struct fwnode_handle *fwnode, const cha
>   static struct usb_role_switch *
>   usb_role_switch_is_parent(struct fwnode_handle *fwnode)
>   {
> -	struct fwnode_handle *parent = fwnode_get_parent(fwnode);
> +	struct fwnode_handle *parent;
>   	struct device *dev;
>   
> +	if (!fwnode_device_is_compatible(fwnode, "usb-b-connector"))
> +		return NULL;
> +
> +	parent = fwnode_get_parent(fwnode);
> +
>   	if (!fwnode_property_present(parent, "usb-role-switch")) {
>   		fwnode_handle_put(parent);
>   		return NULL;

Tested-by: Arnaud Ferraris <arnaud.ferraris@collabora.com>

Cheers,
Arnaud

  reply	other threads:[~2026-03-09  9:12 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-03-09  7:43 [PATCH v2 0/2] improve usb_role_switch_is_parent() Xu Yang
2026-03-09  7:43 ` [PATCH v2 1/2] Revert "tcpm: allow looking for role_sw device in the main node" Xu Yang
2026-03-09  9:12   ` Arnaud Ferraris
2026-03-09  7:43 ` [PATCH v2 2/2] usb: roles: get usb role switch from parent only for usb-b-connector Xu Yang
2026-03-09  9:12   ` Arnaud Ferraris [this message]
2026-03-09 19:48   ` Frank Li
2026-03-10  2:47     ` Xu Yang
2026-03-09 11:32 ` [PATCH v2 0/2] improve usb_role_switch_is_parent() 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=0b3b80ac-5cc2-4c19-a8f1-b8b44992eec4@collabora.com \
    --to=arnaud.ferraris@collabora.com \
    --cc=badhri@google.com \
    --cc=dsimic@manjaro.org \
    --cc=gregkh@linuxfoundation.org \
    --cc=heikki.krogerus@linux.intel.com \
    --cc=imx@lists.linux.dev \
    --cc=jun.li@nxp.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-usb@vger.kernel.org \
    --cc=xu.yang_2@nxp.com \
    /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