Re: [PATCH v2 6/9] usb: roles: Find the muxes by also matching against the device node
Hi, On Tue, Feb 12, 2019 at 10:41:28AM +, Jun Li wrote: > > @@ -32,6 +32,7 @@ typedef enum usb_role (*usb_role_switch_get_t)(struct > > device *dev); > > * usb_role_switch_register() before registering the switch. > > */ > > struct usb_role_switch_desc { > > + struct fwnode_handle *fwnode; > You may add some description for this new member > /** > * struct usb_role_switch_desc - USB Role Switch Descriptor > * @ fwnode You are correct. I need to fix that one. thanks, -- heikki
RE: [PATCH v2 6/9] usb: roles: Find the muxes by also matching against the device node
Hi > -Original Message- > From: Heikki Krogerus > Sent: 2019年2月12日 16:51 > To: Jun Li > Cc: Greg Kroah-Hartman ; Andy Shevchenko > ; Chen Yu ; Hans de > Goede ; linux-...@vger.kernel.org; > linux-kernel@vger.kernel.org > Subject: Re: [PATCH v2 6/9] usb: roles: Find the muxes by also matching > against the > device node > > Hi, > > On Tue, Feb 12, 2019 at 06:03:42AM +, Jun Li wrote: > > > > return dev_fwnode(dev->parent) == fwnode; > > > > > > That's actually not the case. struct usb_role_switch_desc has a > > > member for fwnode, and that's what we use with the actual mux > > > device. Check > > > usb_role_switch_register(): > > > > > > ... > > > sw->dev.fwnode = desc->fwnode; > > > ... > > > > > > Sorry for not realizing it before. > > > > So desc->fwnode should be initialized before do usb_role_switch_register()? > > But seems usb_role_switch_desc is a read-only object so can't be set at > > runtime. > > It can. Even though usb_role_switch_register() takes read-only parameter, > nothing's > preventing you from passing data even from the stack (the content of the > descriptor > is copied in any case). > > Expecting the descriptor to be read-only just means it can be read-only, but > it does > not have to be. Understood, thanks. > @@ -32,6 +32,7 @@ typedef enum usb_role (*usb_role_switch_get_t)(struct > device *dev); > * usb_role_switch_register() before registering the switch. > */ > struct usb_role_switch_desc { > + struct fwnode_handle *fwnode; You may add some description for this new member /** * struct usb_role_switch_desc - USB Role Switch Descriptor * @ fwnode > > > usb_controller_node { > > ... > > usb-role-switch; > > > > port { > > sw_provider_node: endpoint { > > remote-endpoint = <_consumer_node>; > > }; > > }; > > }; > > > > typec_node { > > ... > > port { > > sw_consumer_node: endpoint { > > remote-endpoint = <_provider_node>; > > }; > > }; > > }; > > That looks roughly correct to me. > > > thanks, > > -- > heikki
Re: [PATCH v2 6/9] usb: roles: Find the muxes by also matching against the device node
Hi, On Tue, Feb 12, 2019 at 06:03:42AM +, Jun Li wrote: > > > return dev_fwnode(dev->parent) == fwnode; > > > > That's actually not the case. struct usb_role_switch_desc has a member for > > fwnode, > > and that's what we use with the actual mux device. Check > > usb_role_switch_register(): > > > > ... > > sw->dev.fwnode = desc->fwnode; > > ... > > > > Sorry for not realizing it before. > > So desc->fwnode should be initialized before do usb_role_switch_register()? > But seems usb_role_switch_desc is a read-only object so can't be set at > runtime. It can. Even though usb_role_switch_register() takes read-only parameter, nothing's preventing you from passing data even from the stack (the content of the descriptor is copied in any case). Expecting the descriptor to be read-only just means it can be read-only, but it does not have to be. > usb_controller_node { > ... > usb-role-switch; > > port { > sw_provider_node: endpoint { > remote-endpoint = <_consumer_node>; > }; > }; > }; > > typec_node { > ... > port { > sw_consumer_node: endpoint { > remote-endpoint = <_provider_node>; > }; > }; > }; That looks roughly correct to me. thanks, -- heikki
RE: [PATCH v2 6/9] usb: roles: Find the muxes by also matching against the device node
> -Original Message- > From: Heikki Krogerus > Sent: 2019年2月11日 18:46 > To: Jun Li > Cc: Greg Kroah-Hartman ; Andy Shevchenko > ; Chen Yu ; Hans de > Goede ; linux-...@vger.kernel.org; > linux-kernel@vger.kernel.org > Subject: Re: [PATCH v2 6/9] usb: roles: Find the muxes by also matching > against the > device node > > On Mon, Feb 11, 2019 at 09:58:04AM +, Jun Li wrote: > > Hi Heikki, > > > > > @@ -84,7 +85,12 @@ enum usb_role usb_role_switch_get_role(struct > > > usb_role_switch *sw) } > > > EXPORT_SYMBOL_GPL(usb_role_switch_get_role); > > > > > > -static int __switch_match(struct device *dev, const void *name) > > > +static int switch_fwnode_match(struct device *dev, const void > > > +*fwnode) { > > > + return dev_fwnode(dev) == fwnode; > > > > You missed the comment > > https://emea01.safelinks.protection.outlook.com/?url=https%3A%2F%2Flkm > > > l.org%2Flkml%2F2019%2F1%2F22%2F437data=02%7C01%7Cjun.li%40nx > p.com > > %7C8c2d40d5e5d246da34ad08d6900e31cf%7C686ea1d3bc2b4c6fa92cd99c5 > c301635 > > %7C0%7C0%7C636854788040965224sdata=db4gvXKc9InWiltsweetxXYr > tPbtfX > > jshPh%2FnvA24ig%3Dreserved=0 > > > > return dev_fwnode(dev->parent) == fwnode; > > That's actually not the case. struct usb_role_switch_desc has a member for > fwnode, > and that's what we use with the actual mux device. Check > usb_role_switch_register(): > > ... > sw->dev.fwnode = desc->fwnode; > ... > > Sorry for not realizing it before. So desc->fwnode should be initialized before do usb_role_switch_register()? But seems usb_role_switch_desc is a read-only object so can't be set at runtime. usb_controller_node { ... usb-role-switch; port { sw_provider_node: endpoint { remote-endpoint = <_consumer_node>; }; }; }; typec_node { ... port { sw_consumer_node: endpoint { remote-endpoint = <_provider_node>; }; }; }; Is my understanding correct? Thanks Jun > > > thanks, > > -- > heikki
Re: [PATCH v2 6/9] usb: roles: Find the muxes by also matching against the device node
On Mon, Feb 11, 2019 at 12:46:29PM +0200, Heikki Krogerus wrote: > On Mon, Feb 11, 2019 at 09:58:04AM +, Jun Li wrote: > > Hi Heikki, > > > > > @@ -84,7 +85,12 @@ enum usb_role usb_role_switch_get_role(struct > > > usb_role_switch *sw) } EXPORT_SYMBOL_GPL(usb_role_switch_get_role); > > > > > > -static int __switch_match(struct device *dev, const void *name) > > > +static int switch_fwnode_match(struct device *dev, const void *fwnode) > > > +{ > > > + return dev_fwnode(dev) == fwnode; > > > > You missed the comment > > https://lkml.org/lkml/2019/1/22/437 > > > > return dev_fwnode(dev->parent) == fwnode; > > That's actually not the case. struct usb_role_switch_desc has a member > for fwnode, and that's what we use with the actual mux device. Check > usb_role_switch_register(): > > ... > sw->dev.fwnode = desc->fwnode; > ... > > Sorry for not realizing it before. Just to clarify. The current patch is OK. No changes needed. thanks, -- heikki
Re: [PATCH v2 6/9] usb: roles: Find the muxes by also matching against the device node
On Mon, Feb 11, 2019 at 09:58:04AM +, Jun Li wrote: > Hi Heikki, > > > @@ -84,7 +85,12 @@ enum usb_role usb_role_switch_get_role(struct > > usb_role_switch *sw) } EXPORT_SYMBOL_GPL(usb_role_switch_get_role); > > > > -static int __switch_match(struct device *dev, const void *name) > > +static int switch_fwnode_match(struct device *dev, const void *fwnode) > > +{ > > + return dev_fwnode(dev) == fwnode; > > You missed the comment > https://lkml.org/lkml/2019/1/22/437 > > return dev_fwnode(dev->parent) == fwnode; That's actually not the case. struct usb_role_switch_desc has a member for fwnode, and that's what we use with the actual mux device. Check usb_role_switch_register(): ... sw->dev.fwnode = desc->fwnode; ... Sorry for not realizing it before. thanks, -- heikki
RE: [PATCH v2 6/9] usb: roles: Find the muxes by also matching against the device node
Hi Heikki, > @@ -84,7 +85,12 @@ enum usb_role usb_role_switch_get_role(struct > usb_role_switch *sw) } EXPORT_SYMBOL_GPL(usb_role_switch_get_role); > > -static int __switch_match(struct device *dev, const void *name) > +static int switch_fwnode_match(struct device *dev, const void *fwnode) > +{ > + return dev_fwnode(dev) == fwnode; You missed the comment https://lkml.org/lkml/2019/1/22/437 return dev_fwnode(dev->parent) == fwnode; Jun