RE: [PATCH v2 5/9] usb: roles: Provide the switch drivers handle to the switch in the API

Peter Chen
2020-03-02T10:14:17Z

>
> On Mon, Mar 02, 2020 at 06:22:59AM +0000, Peter Chen wrote:
> > > > @@ -613,9 +613,10 @@ static enum usb_role ci_usb_role_switch_get(struct
> device *dev)
> > > > return role;
> > > > }
> > > >
> > > > -static int ci_usb_role_switch_set(struct device *dev, enum
> > > > usb_role role)
> > > > +static int ci_usb_role_switch_set(struct usb_role_switch *sw,
> > > > + enum usb_role role)
> > > > {
> > > > - struct ci_hdrc *ci = dev_get_drvdata(dev);
> > > > + struct ci_hdrc *ci = usb_role_switch_get_drvdata(sw);
> > > > struct ci_hdrc_cable *cable = NULL;
> > > > enum usb_role current_role = ci_role_to_usb_role(ci);
> > > > enum ci_role ci_role = usb_role_to_ci_role(role); @@ -1118,6
> > > > +1119,7 @@ static int ci_hdrc_probe(struct platform_device *pdev)
> > > > }
> > > >
> > > > if (ci_role_switch.fwnode) {
> > > > + ci_role_switch.driver_data = ci;
> >
> > And chipidea code, better change it like cdns3's, otherwise, the
> > switch desc for all controllers have the same driver_data.
>
> That I'll skip after all...
>
> Note that since the context of the switch descriptor is always copied during
> registration, the driver_data is not going to be the same for every switch.
>

Yes, there is no problem now, just to avoid the issue if usb switch core will use
each descriptor in future.

> The structure is actually filled in two separate functions, so the change is not
> straightforward. We can still change that of course, but it's out side the scope of this
> series, so it needs to be done separately.
>

Ok, you could leave it like this v2, and I will do it in future.

Peter