* [v2,7/9] usb: typec: Find the ports by also matching against the device node
@ 2019-01-30 16:02 Heikki Krogerus
0 siblings, 0 replies; 5+ messages in thread
From: Heikki Krogerus @ 2019-01-30 16:02 UTC (permalink / raw)
To: Greg Kroah-Hartman
Cc: Andy Shevchenko, Chen Yu, Jun Li, 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 | 24 +++++++++++++++++++++---
1 file changed, 21 insertions(+), 3 deletions(-)
diff --git a/drivers/usb/typec/class.c b/drivers/usb/typec/class.c
index f50278dbef59..88adf0eaad34 100644
--- a/drivers/usb/typec/class.c
+++ b/drivers/usb/typec/class.c
@@ -9,6 +9,7 @@
#include <linux/device.h>
#include <linux/module.h>
#include <linux/mutex.h>
+#include <linux/property.h>
#include <linux/slab.h>
#include "bus.h"
@@ -204,15 +205,32 @@ 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_fwnode(dev) == 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;
+
+ /*
+ * FIXME: Check does the fwnode supports the requested SVID. If it does
+ * we need to return ERR_PTR(-PROBE_DEFER) when there is no device.
+ */
+ if (con->fwnode)
+ return class_find_device(typec_class, NULL, con->fwnode,
+ typec_port_fwnode_match);
+
+ 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] 5+ messages in thread
* [v2,7/9] usb: typec: Find the ports by also matching against the device node
@ 2019-01-30 16:51 Andy Shevchenko
0 siblings, 0 replies; 5+ messages in thread
From: Andy Shevchenko @ 2019-01-30 16:51 UTC (permalink / raw)
To: Heikki Krogerus
Cc: Greg Kroah-Hartman, Chen Yu, Jun Li, Hans de Goede, USB,
Linux Kernel Mailing List
On Wed, Jan 30, 2019 at 6:03 PM Heikki Krogerus
<heikki.krogerus@linux.intel.com> 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.
> + /*
> + * FIXME: Check does the fwnode supports the requested SVID. If it does
> + * we need to return ERR_PTR(-PROBE_DEFER) when there is no device.
> + */
> + if (con->fwnode)
> + return class_find_device(typec_class, NULL, con->fwnode,
> + typec_port_fwnode_match);
> +
> + dev = class_find_device(typec_class, NULL, con->endpoint[ep],
> + typec_port_name_match);
> +
> + return dev ? dev : ERR_PTR(-EPROBE_DEFER);
Just to be clear, this one takes a reference on dev. Is it taken into account?
^ permalink raw reply [flat|nested] 5+ messages in thread
* [v2,7/9] usb: typec: Find the ports by also matching against the device node
@ 2019-01-31 13:35 Heikki Krogerus
0 siblings, 0 replies; 5+ messages in thread
From: Heikki Krogerus @ 2019-01-31 13:35 UTC (permalink / raw)
To: Andy Shevchenko
Cc: Greg Kroah-Hartman, Chen Yu, Jun Li, Hans de Goede, USB,
Linux Kernel Mailing List
On Wed, Jan 30, 2019 at 06:51:56PM +0200, Andy Shevchenko wrote:
> On Wed, Jan 30, 2019 at 6:03 PM Heikki Krogerus
> <heikki.krogerus@linux.intel.com> 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.
>
> > + /*
> > + * FIXME: Check does the fwnode supports the requested SVID. If it does
> > + * we need to return ERR_PTR(-PROBE_DEFER) when there is no device.
> > + */
> > + if (con->fwnode)
> > + return class_find_device(typec_class, NULL, con->fwnode,
> > + typec_port_fwnode_match);
> > +
> > + dev = class_find_device(typec_class, NULL, con->endpoint[ep],
> > + typec_port_name_match);
> > +
> > + return dev ? dev : ERR_PTR(-EPROBE_DEFER);
>
> Just to be clear, this one takes a reference on dev. Is it taken into account?
Yes. That is what we want it to do.
thanks,
^ permalink raw reply [flat|nested] 5+ messages in thread
* [v2,7/9] usb: typec: Find the ports by also matching against the device node
@ 2019-02-11 8:39 Heikki Krogerus
0 siblings, 0 replies; 5+ messages in thread
From: Heikki Krogerus @ 2019-02-11 8:39 UTC (permalink / raw)
To: Andy Shevchenko
Cc: Greg Kroah-Hartman, Chen Yu, Jun Li, Hans de Goede, USB,
Linux Kernel Mailing List
Hi Andy,
On Thu, Jan 31, 2019 at 03:35:37PM +0200, Heikki Krogerus wrote:
> On Wed, Jan 30, 2019 at 06:51:56PM +0200, Andy Shevchenko wrote:
> > On Wed, Jan 30, 2019 at 6:03 PM Heikki Krogerus
> > <heikki.krogerus@linux.intel.com> 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.
> >
> > > + /*
> > > + * FIXME: Check does the fwnode supports the requested SVID. If it does
> > > + * we need to return ERR_PTR(-PROBE_DEFER) when there is no device.
> > > + */
> > > + if (con->fwnode)
> > > + return class_find_device(typec_class, NULL, con->fwnode,
> > > + typec_port_fwnode_match);
> > > +
> > > + dev = class_find_device(typec_class, NULL, con->endpoint[ep],
> > > + typec_port_name_match);
> > > +
> > > + return dev ? dev : ERR_PTR(-EPROBE_DEFER);
> >
> > Just to be clear, this one takes a reference on dev. Is it taken into account?
>
> Yes. That is what we want it to do.
Gentle ping. Is the series OK?
thanks,
^ permalink raw reply [flat|nested] 5+ messages in thread
* [v2,7/9] usb: typec: Find the ports by also matching against the device node
@ 2019-02-11 11:52 Andy Shevchenko
0 siblings, 0 replies; 5+ messages in thread
From: Andy Shevchenko @ 2019-02-11 11:52 UTC (permalink / raw)
To: Heikki Krogerus
Cc: Greg Kroah-Hartman, Chen Yu, Jun Li, Hans de Goede, USB,
Linux Kernel Mailing List
On Mon, Feb 11, 2019 at 10:39 AM Heikki Krogerus
<heikki.krogerus@linux.intel.com> wrote:
> On Thu, Jan 31, 2019 at 03:35:37PM +0200, Heikki Krogerus wrote:
> > On Wed, Jan 30, 2019 at 06:51:56PM +0200, Andy Shevchenko wrote:
> > > On Wed, Jan 30, 2019 at 6:03 PM Heikki Krogerus
> > > <heikki.krogerus@linux.intel.com> 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.
> > >
> > > > + /*
> > > > + * FIXME: Check does the fwnode supports the requested SVID. If it does
> > > > + * we need to return ERR_PTR(-PROBE_DEFER) when there is no device.
> > > > + */
> > > > + if (con->fwnode)
> > > > + return class_find_device(typec_class, NULL, con->fwnode,
> > > > + typec_port_fwnode_match);
> > > > +
> > > > + dev = class_find_device(typec_class, NULL, con->endpoint[ep],
> > > > + typec_port_name_match);
> > > > +
> > > > + return dev ? dev : ERR_PTR(-EPROBE_DEFER);
> > >
> > > Just to be clear, this one takes a reference on dev. Is it taken into account?
> >
> > Yes. That is what we want it to do.
>
> Gentle ping. Is the series OK?
From my prospective it's okay, so, FWIW
Reviewed-by: Andy Shevchenko <andy.shevchenko@gmail.com>
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2019-02-11 11:52 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2019-01-30 16:02 [v2,7/9] usb: typec: Find the ports by also matching against the device node Heikki Krogerus
-- strict thread matches above, loose matches on Subject: below --
2019-01-30 16:51 Andy Shevchenko
2019-01-31 13:35 Heikki Krogerus
2019-02-11 8:39 Heikki Krogerus
2019-02-11 11:52 Andy Shevchenko
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).