linux-usb.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [RFC,4/5] usb: typec: Find the ports by also matching against the device node
@ 2018-10-24 15:05 Heikki Krogerus
  0 siblings, 0 replies; 4+ messages in thread
From: Heikki Krogerus @ 2018-10-24 15:05 UTC (permalink / raw)
  To: Heiko Stuebner; +Cc: Guenter Roeck, Hans de Goede, linux-usb, linux-kernel

When the connections are defined in firmware, struct
device_connection will have the fwnode member pointing to
the device node (struct fwnode_handle) of the requested
device, and the endpoint will not be used at all in that
case.

Signed-off-by: Heikki Krogerus <heikki.krogerus@linux.intel.com>
---
 drivers/usb/typec/class.c | 19 ++++++++++++++++---
 1 file changed, 16 insertions(+), 3 deletions(-)

diff --git a/drivers/usb/typec/class.c b/drivers/usb/typec/class.c
index 5db0593ca0bd..fe6f3a932a88 100644
--- a/drivers/usb/typec/class.c
+++ b/drivers/usb/typec/class.c
@@ -204,15 +204,28 @@ static void typec_altmode_put_partner(struct altmode *altmode)
 	put_device(&adev->dev);
 }
 
-static int __typec_port_match(struct device *dev, const void *name)
+static int typec_port_fwnode_match(struct device *dev, const void *fwnode)
+{
+	return dev_name(fwnode) == fwnode;
+}
+
+static int typec_port_name_match(struct device *dev, const void *name)
 {
 	return !strcmp((const char *)name, dev_name(dev));
 }
 
 static void *typec_port_match(struct device_connection *con, int ep, void *data)
 {
-	return class_find_device(typec_class, NULL, con->endpoint[ep],
-				 __typec_port_match);
+	struct device *dev;
+
+	if (con->fwnode)
+		dev = class_find_device(typec_class, NULL, con->fwnode,
+					typec_port_fwnode_match);
+	else
+		dev = class_find_device(typec_class, NULL, con->endpoint[ep],
+					typec_port_name_match);
+
+	return dev ? dev : ERR_PTR(-EPROBE_DEFER);
 }
 
 struct typec_altmode *

^ permalink raw reply related	[flat|nested] 4+ messages in thread
* [RFC,4/5] usb: typec: Find the ports by also matching against the device node
@ 2018-10-24 17:07 Sergei Shtylyov
  0 siblings, 0 replies; 4+ messages in thread
From: Sergei Shtylyov @ 2018-10-24 17:07 UTC (permalink / raw)
  To: Heikki Krogerus, Heiko Stuebner
  Cc: Guenter Roeck, Hans de Goede, linux-usb, linux-kernel

Hello!

On 10/24/2018 06:05 PM, Heikki Krogerus wrote:

> When the connections are defined in firmware, struct
> device_connection will have the fwnode member pointing to
> the device node (struct fwnode_handle) of the requested
> device, and the endpoint will not be used at all in that
> case.
> 
> Signed-off-by: Heikki Krogerus <heikki.krogerus@linux.intel.com>
> ---
>  drivers/usb/typec/class.c | 19 ++++++++++++++++---
>  1 file changed, 16 insertions(+), 3 deletions(-)
> 
> diff --git a/drivers/usb/typec/class.c b/drivers/usb/typec/class.c
> index 5db0593ca0bd..fe6f3a932a88 100644
> --- a/drivers/usb/typec/class.c
> +++ b/drivers/usb/typec/class.c
> @@ -204,15 +204,28 @@ static void typec_altmode_put_partner(struct altmode *altmode)
>  	put_device(&adev->dev);
>  }
>  
> -static int __typec_port_match(struct device *dev, const void *name)
> +static int typec_port_fwnode_match(struct device *dev, const void *fwnode)
> +{
> +	return dev_name(fwnode) == fwnode;

   dev_name(dev), maybe?

[...]

MBR, Sergei

^ permalink raw reply	[flat|nested] 4+ messages in thread
* [RFC,4/5] usb: typec: Find the ports by also matching against the device node
@ 2018-10-25  7:27 Heikki Krogerus
  0 siblings, 0 replies; 4+ messages in thread
From: Heikki Krogerus @ 2018-10-25  7:27 UTC (permalink / raw)
  To: Sergei Shtylyov
  Cc: Heiko Stuebner, Guenter Roeck, Hans de Goede, linux-usb,
	linux-kernel

On Wed, Oct 24, 2018 at 08:07:09PM +0300, Sergei Shtylyov wrote:
> Hello!
> 
> On 10/24/2018 06:05 PM, Heikki Krogerus wrote:
> 
> > When the connections are defined in firmware, struct
> > device_connection will have the fwnode member pointing to
> > the device node (struct fwnode_handle) of the requested
> > device, and the endpoint will not be used at all in that
> > case.
> > 
> > Signed-off-by: Heikki Krogerus <heikki.krogerus@linux.intel.com>
> > ---
> >  drivers/usb/typec/class.c | 19 ++++++++++++++++---
> >  1 file changed, 16 insertions(+), 3 deletions(-)
> > 
> > diff --git a/drivers/usb/typec/class.c b/drivers/usb/typec/class.c
> > index 5db0593ca0bd..fe6f3a932a88 100644
> > --- a/drivers/usb/typec/class.c
> > +++ b/drivers/usb/typec/class.c
> > @@ -204,15 +204,28 @@ static void typec_altmode_put_partner(struct altmode *altmode)
> >  	put_device(&adev->dev);
> >  }
> >  
> > -static int __typec_port_match(struct device *dev, const void *name)
> > +static int typec_port_fwnode_match(struct device *dev, const void *fwnode)
> > +{
> > +	return dev_name(fwnode) == fwnode;
> 
>    dev_name(dev), maybe?

Yes.

thanks,

^ permalink raw reply	[flat|nested] 4+ messages in thread
* [RFC,4/5] usb: typec: Find the ports by also matching against the device node
@ 2018-10-25  9:02 Heikki Krogerus
  0 siblings, 0 replies; 4+ messages in thread
From: Heikki Krogerus @ 2018-10-25  9:02 UTC (permalink / raw)
  To: Sergei Shtylyov
  Cc: Heiko Stuebner, Guenter Roeck, Hans de Goede, linux-usb,
	linux-kernel

On Thu, Oct 25, 2018 at 10:27:20AM +0300, Heikki Krogerus wrote:
> On Wed, Oct 24, 2018 at 08:07:09PM +0300, Sergei Shtylyov wrote:
> > Hello!
> > 
> > On 10/24/2018 06:05 PM, Heikki Krogerus wrote:
> > 
> > > When the connections are defined in firmware, struct
> > > device_connection will have the fwnode member pointing to
> > > the device node (struct fwnode_handle) of the requested
> > > device, and the endpoint will not be used at all in that
> > > case.
> > > 
> > > Signed-off-by: Heikki Krogerus <heikki.krogerus@linux.intel.com>
> > > ---
> > >  drivers/usb/typec/class.c | 19 ++++++++++++++++---
> > >  1 file changed, 16 insertions(+), 3 deletions(-)
> > > 
> > > diff --git a/drivers/usb/typec/class.c b/drivers/usb/typec/class.c
> > > index 5db0593ca0bd..fe6f3a932a88 100644
> > > --- a/drivers/usb/typec/class.c
> > > +++ b/drivers/usb/typec/class.c
> > > @@ -204,15 +204,28 @@ static void typec_altmode_put_partner(struct altmode *altmode)
> > >  	put_device(&adev->dev);
> > >  }
> > >  
> > > -static int __typec_port_match(struct device *dev, const void *name)
> > > +static int typec_port_fwnode_match(struct device *dev, const void *fwnode)
> > > +{
> > > +	return dev_name(fwnode) == fwnode;
> > 
> >    dev_name(dev), maybe?

Actually:

        dev_fwnode(dev) == fwnode;


Cheers,

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2018-10-25  9:02 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2018-10-24 15:05 [RFC,4/5] usb: typec: Find the ports by also matching against the device node Heikki Krogerus
  -- strict thread matches above, loose matches on Subject: below --
2018-10-24 17:07 Sergei Shtylyov
2018-10-25  7:27 Heikki Krogerus
2018-10-25  9:02 Heikki Krogerus

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).