Hi, > > IMO that case should be handled in USB role switch API initially, not > > in the device connection API. If there is another user for it one day, > > then we can move it to device connection API, but not before that. > Ok > > > > How about this on top of the two patches I sent: > I just test it, it works well. > I'll prepare a patch and put into this series. > > > > > diff --git a/drivers/usb/roles/class.c b/drivers/usb/roles/class.c > > index aab795b54c7f..36ac9d181e09 100644 > > --- a/drivers/usb/roles/class.c > > +++ b/drivers/usb/roles/class.c > > @@ -114,6 +114,19 @@ static void *usb_role_switch_match(struct device_connection *con, int ep, > > return dev ? to_role_switch(dev) : ERR_PTR(-EPROBE_DEFER); > > } > > > > +static struct usb_role_switch * > > +usb_role_switch_is_parent(struct fwnode_handle *parent) > > +{ > > + struct device *dev; > > + > > + if (!parent || !fwnode_property_present(parent, "usb-role-switch")) > > + return NULL; > > + > > + dev = class_find_device(role_class, NULL, parent, switch_fwnode_match); > > + > > + return dev ? to_role_switch(dev) : ERR_PTR(-EPROBE_DEFER); > > +} > > + > > /** > > * usb_role_switch_get - Find USB role switch linked with the caller > > * @dev: The caller device > > @@ -125,6 +138,10 @@ struct usb_role_switch *usb_role_switch_get(struct device *dev) > > { > > struct usb_role_switch *sw; > > > > + sw = usb_role_switch_is_parent(fwnode_get_parent(dev_fwnode(dev))); > > + if (sw) > > + return sw; > Do we also need to get parent module before return? Yes. thanks, -- heikki