diff mbox series

usb: Change usb_of_get_companion_dev() place to usb/common

Message ID 1534734626-16767-1-git-send-email-yoshihiro.shimoda.uh@renesas.com (mailing list archive)
State Accepted
Delegated to: Geert Uytterhoeven
Headers show
Series usb: Change usb_of_get_companion_dev() place to usb/common | expand

Commit Message

Yoshihiro Shimoda Aug. 20, 2018, 3:10 a.m. UTC
Since renesas_usb3 udc driver calls usb_of_get_companion_dev()
which is on usb/core/of.c, build error like below happens if we
disable CONFIG_USB because the usb/core/ needs CONFIG_USB:

ERROR: "usb_of_get_companion_dev" [drivers/usb/gadget/udc/renesas_usb3.ko] undefined!

According to the usb/gadget/Kconfig, "NOTE:  Gadget support
** DOES NOT ** depend on host-side CONFIG_USB !!".
So, to fix the issue, this patch changes the usb_of_get_companion_dev()
place from usb/core/of.c to usb/common/common.c to be called by both
host and gadget.

Reported-by: John Garry <john.garry@huawei.com>
Fixes: 39facfa01c9f ("usb: gadget: udc: renesas_usb3: Add register of usb role switch")
Signed-off-by: Yoshihiro Shimoda <yoshihiro.shimoda.uh@renesas.com>
---
 drivers/usb/common/common.c | 25 +++++++++++++++++++++++++
 drivers/usb/core/of.c       | 26 --------------------------
 2 files changed, 25 insertions(+), 26 deletions(-)

Comments

Yoshihiro Shimoda Aug. 21, 2018, 1:59 a.m. UTC | #1
Hi,

> From: Yoshihiro Shimoda, Sent: Monday, August 20, 2018 12:10 PM
> 
> Since renesas_usb3 udc driver calls usb_of_get_companion_dev()
> which is on usb/core/of.c, build error like below happens if we
> disable CONFIG_USB because the usb/core/ needs CONFIG_USB:
> 
> ERROR: "usb_of_get_companion_dev" [drivers/usb/gadget/udc/renesas_usb3.ko] undefined!
> 
> According to the usb/gadget/Kconfig, "NOTE:  Gadget support
> ** DOES NOT ** depend on host-side CONFIG_USB !!".
> So, to fix the issue, this patch changes the usb_of_get_companion_dev()
> place from usb/core/of.c to usb/common/common.c to be called by both
> host and gadget.
> 
> Reported-by: John Garry <john.garry@huawei.com>
> Fixes: 39facfa01c9f ("usb: gadget: udc: renesas_usb3: Add register of usb role switch")
> Signed-off-by: Yoshihiro Shimoda <yoshihiro.shimoda.uh@renesas.com>

On other email thread [1], Arnd said I have his Ack on this patch.
So,

Acked-by: Arnd Bergmann <arnd@arndb.de>

[1]
https://lkml.org/lkml/2018/8/20/216

Best regards,
Yoshihiro Shimoda
Yoshihiro Shimoda Sept. 6, 2018, 4:42 a.m. UTC | #2
Hi Greg, Felipe,
(Add John's email to CC)

> From: Yoshihiro Shimoda, Sent: Tuesday, August 21, 2018 10:59 AM
> 
> Hi,
> 
> > From: Yoshihiro Shimoda, Sent: Monday, August 20, 2018 12:10 PM
> >
> > Since renesas_usb3 udc driver calls usb_of_get_companion_dev()
> > which is on usb/core/of.c, build error like below happens if we
> > disable CONFIG_USB because the usb/core/ needs CONFIG_USB:
> >
> > ERROR: "usb_of_get_companion_dev" [drivers/usb/gadget/udc/renesas_usb3.ko] undefined!
> >
> > According to the usb/gadget/Kconfig, "NOTE:  Gadget support
> > ** DOES NOT ** depend on host-side CONFIG_USB !!".
> > So, to fix the issue, this patch changes the usb_of_get_companion_dev()
> > place from usb/core/of.c to usb/common/common.c to be called by both
> > host and gadget.
> >
> > Reported-by: John Garry <john.garry@huawei.com>
> > Fixes: 39facfa01c9f ("usb: gadget: udc: renesas_usb3: Add register of usb role switch")
> > Signed-off-by: Yoshihiro Shimoda <yoshihiro.shimoda.uh@renesas.com>
> 
> On other email thread [1], Arnd said I have his Ack on this patch.
> So,
> 
> Acked-by: Arnd Bergmann <arnd@arndb.de>
> 
> [1]
> https://lkml.org/lkml/2018/8/20/216

I'm afraid but, would you apply this patch for linux v4.19?

Best regards,
Yoshihiro Shimoda
diff mbox series

Patch

diff --git a/drivers/usb/common/common.c b/drivers/usb/common/common.c
index 50a2362ed..48277bb 100644
--- a/drivers/usb/common/common.c
+++ b/drivers/usb/common/common.c
@@ -246,6 +246,31 @@  int of_usb_update_otg_caps(struct device_node *np,
 }
 EXPORT_SYMBOL_GPL(of_usb_update_otg_caps);
 
+/**
+ * usb_of_get_companion_dev - Find the companion device
+ * @dev: the device pointer to find a companion
+ *
+ * Find the companion device from platform bus.
+ *
+ * Takes a reference to the returned struct device which needs to be dropped
+ * after use.
+ *
+ * Return: On success, a pointer to the companion device, %NULL on failure.
+ */
+struct device *usb_of_get_companion_dev(struct device *dev)
+{
+	struct device_node *node;
+	struct platform_device *pdev = NULL;
+
+	node = of_parse_phandle(dev->of_node, "companion", 0);
+	if (node)
+		pdev = of_find_device_by_node(node);
+
+	of_node_put(node);
+
+	return pdev ? &pdev->dev : NULL;
+}
+EXPORT_SYMBOL_GPL(usb_of_get_companion_dev);
 #endif
 
 MODULE_LICENSE("GPL");
diff --git a/drivers/usb/core/of.c b/drivers/usb/core/of.c
index fd77442..651708d 100644
--- a/drivers/usb/core/of.c
+++ b/drivers/usb/core/of.c
@@ -105,29 +105,3 @@  struct device_node *
 	return NULL;
 }
 EXPORT_SYMBOL_GPL(usb_of_get_interface_node);
-
-/**
- * usb_of_get_companion_dev - Find the companion device
- * @dev: the device pointer to find a companion
- *
- * Find the companion device from platform bus.
- *
- * Takes a reference to the returned struct device which needs to be dropped
- * after use.
- *
- * Return: On success, a pointer to the companion device, %NULL on failure.
- */
-struct device *usb_of_get_companion_dev(struct device *dev)
-{
-	struct device_node *node;
-	struct platform_device *pdev = NULL;
-
-	node = of_parse_phandle(dev->of_node, "companion", 0);
-	if (node)
-		pdev = of_find_device_by_node(node);
-
-	of_node_put(node);
-
-	return pdev ? &pdev->dev : NULL;
-}
-EXPORT_SYMBOL_GPL(usb_of_get_companion_dev);