All of lore.kernel.org
 help / color / mirror / Atom feed
From: Marian-Cristian Rotariu <marian-cristian.rotariu.rb@bp.renesas.com>
To: cip-dev@lists.cip-project.org
Subject: [cip-dev] [PATCH v2 4.19.y-cip 05/22] usb: typec: Find the ports by also matching against the device node
Date: Fri, 21 Feb 2020 16:51:52 +0000	[thread overview]
Message-ID: <1582303929-5773-6-git-send-email-marian-cristian.rotariu.rb@bp.renesas.com> (raw)
In-Reply-To: <1582303929-5773-1-git-send-email-marian-cristian.rotariu.rb@bp.renesas.com>

From: Heikki Krogerus <heikki.krogerus@linux.intel.com>

commit 6a0bbcf96b2273f110a14d11a5952527c5921191 upstream.

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.

Acked-by: Hans de Goede <hdegoede@redhat.com>
Reviewed-by: Andy Shevchenko <andy.shevchenko@gmail.com>
Reviewed-by: Jun Li <jun.li@nxp.com>
Signed-off-by: Heikki Krogerus <heikki.krogerus@linux.intel.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: Marian-Cristian Rotariu <marian-cristian.rotariu.rb@bp.renesas.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 1916ee1..65e95b6 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 *
-- 
2.7.4

_______________________________________________
cip-dev mailing list
cip-dev@lists.cip-project.org
https://lists.cip-project.org/mailman/listinfo/cip-dev

  parent reply	other threads:[~2020-02-21 16:52 UTC|newest]

Thread overview: 28+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-02-21 16:51 [cip-dev] [PATCH v2 4.19.y-cip 00/22] Renesas RZ/G2E USB Type-C Backport Marian-Cristian Rotariu
2020-02-21 16:51 ` [cip-dev] [PATCH v2 4.19.y-cip 01/22] device connection: Add fwnode member to struct device_connection Marian-Cristian Rotariu
2020-02-23 20:11   ` Pavel Machek
2020-02-21 16:51 ` [cip-dev] [PATCH v2 4.19.y-cip 02/22] usb: typec: mux: Find the muxes by also matching against the device node Marian-Cristian Rotariu
2020-02-21 16:51 ` [cip-dev] [PATCH v2 4.19.y-cip 03/22] usb: typec: mux: Fix unsigned comparison with less than zero Marian-Cristian Rotariu
2020-02-21 16:51 ` [cip-dev] [PATCH v2 4.19.y-cip 04/22] usb: roles: Find the muxes by also matching against the device node Marian-Cristian Rotariu
2020-02-21 16:51 ` Marian-Cristian Rotariu [this message]
2020-02-21 16:51 ` [cip-dev] [PATCH v2 4.19.y-cip 06/22] device connection: Prepare support for firmware described connections Marian-Cristian Rotariu
2020-02-21 16:51 ` [cip-dev] [PATCH v2 4.19.y-cip 07/22] device connection: Find device connections also from device graphs Marian-Cristian Rotariu
2020-02-21 16:51 ` [cip-dev] [PATCH v2 4.19.y-cip 08/22] device property: Introduce fwnode_find_reference() Marian-Cristian Rotariu
2020-02-21 16:51 ` [cip-dev] [PATCH v2 4.19.y-cip 09/22] device connection: Find connections also by checking the references Marian-Cristian Rotariu
2020-02-21 16:51 ` [cip-dev] [PATCH v2 4.19.y-cip 10/22] usb: roles: Introduce stubs for the exiting functions in role.h Marian-Cristian Rotariu
2020-02-21 16:51 ` [cip-dev] [PATCH v2 4.19.y-cip 11/22] device connection: Add fwnode_connection_find_match() Marian-Cristian Rotariu
2020-02-21 16:51 ` [cip-dev] [PATCH v2 4.19.y-cip 12/22] usb: roles: Add fwnode_usb_role_switch_get() function Marian-Cristian Rotariu
2020-02-21 16:52 ` [cip-dev] [PATCH v2 4.19.y-cip 13/22] dt-bindings: usb: hd3ss3220 device tree binding document Marian-Cristian Rotariu
2020-02-21 16:52 ` [cip-dev] [PATCH v2 4.19.y-cip 14/22] dt-bindings: usb: renesas_usb3: Document usb role switch support Marian-Cristian Rotariu
2020-02-21 16:52 ` [cip-dev] [PATCH v2 4.19.y-cip 15/22] usb: typec: driver for TI HD3SS3220 USB Type-C DRP port controller Marian-Cristian Rotariu
2020-02-23 20:13   ` Pavel Machek
2020-02-21 16:52 ` [cip-dev] [PATCH v2 4.19.y-cip 16/22] usb: typec: hd3ss3220_irq() can be static Marian-Cristian Rotariu
2020-02-21 16:52 ` [cip-dev] [PATCH v2 4.19.y-cip 17/22] usb: typec: add dependency for TYPEC_HD3SS3220 Marian-Cristian Rotariu
2020-02-21 16:52 ` [cip-dev] [PATCH v2 4.19.y-cip 18/22] usb: typec: hd3ss3220: hd3ss3220_probe() warn: passing zero to 'PTR_ERR' Marian-Cristian Rotariu
2020-02-21 16:52 ` [cip-dev] [PATCH v2 4.19.y-cip 19/22] usb: typec: fix an IS_ERR() vs NULL bug in hd3ss3220_probe() Marian-Cristian Rotariu
2020-02-21 16:52 ` [cip-dev] [PATCH v2 4.19.y-cip 20/22] usb: gadget: udc: renesas_usb3: Enhance role switch support Marian-Cristian Rotariu
2020-02-21 16:52 ` [cip-dev] [PATCH v2 4.19.y-cip 21/22] arm64: dts: renesas: cat874: Enable USB3.0 host/peripheral device node Marian-Cristian Rotariu
2020-02-21 16:52 ` [cip-dev] [PATCH v2 4.19.y-cip 22/22] arm64: dts: renesas: cat874: Enable usb role switch support Marian-Cristian Rotariu
2020-02-23 20:21 ` [cip-dev] [PATCH v2 4.19.y-cip 00/22] Renesas RZ/G2E USB Type-C Backport Pavel Machek
2020-02-24 21:29   ` Pavel Machek
2020-02-25  8:58     ` Marian-Cristian Rotariu

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1582303929-5773-6-git-send-email-marian-cristian.rotariu.rb@bp.renesas.com \
    --to=marian-cristian.rotariu.rb@bp.renesas.com \
    --cc=cip-dev@lists.cip-project.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.