Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

usb: Change usb_of_get_companion_dev() place to usb/common

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>
Acked-by: Arnd Bergmann <arnd@arndb.de>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

authored by

Yoshihiro Shimoda and committed by
Greg Kroah-Hartman
fa827966 0a3b5330

+25 -26
+25
drivers/usb/common/common.c
··· 246 246 } 247 247 EXPORT_SYMBOL_GPL(of_usb_update_otg_caps); 248 248 249 + /** 250 + * usb_of_get_companion_dev - Find the companion device 251 + * @dev: the device pointer to find a companion 252 + * 253 + * Find the companion device from platform bus. 254 + * 255 + * Takes a reference to the returned struct device which needs to be dropped 256 + * after use. 257 + * 258 + * Return: On success, a pointer to the companion device, %NULL on failure. 259 + */ 260 + struct device *usb_of_get_companion_dev(struct device *dev) 261 + { 262 + struct device_node *node; 263 + struct platform_device *pdev = NULL; 264 + 265 + node = of_parse_phandle(dev->of_node, "companion", 0); 266 + if (node) 267 + pdev = of_find_device_by_node(node); 268 + 269 + of_node_put(node); 270 + 271 + return pdev ? &pdev->dev : NULL; 272 + } 273 + EXPORT_SYMBOL_GPL(usb_of_get_companion_dev); 249 274 #endif 250 275 251 276 MODULE_LICENSE("GPL");
-26
drivers/usb/core/of.c
··· 105 105 return NULL; 106 106 } 107 107 EXPORT_SYMBOL_GPL(usb_of_get_interface_node); 108 - 109 - /** 110 - * usb_of_get_companion_dev - Find the companion device 111 - * @dev: the device pointer to find a companion 112 - * 113 - * Find the companion device from platform bus. 114 - * 115 - * Takes a reference to the returned struct device which needs to be dropped 116 - * after use. 117 - * 118 - * Return: On success, a pointer to the companion device, %NULL on failure. 119 - */ 120 - struct device *usb_of_get_companion_dev(struct device *dev) 121 - { 122 - struct device_node *node; 123 - struct platform_device *pdev = NULL; 124 - 125 - node = of_parse_phandle(dev->of_node, "companion", 0); 126 - if (node) 127 - pdev = of_find_device_by_node(node); 128 - 129 - of_node_put(node); 130 - 131 - return pdev ? &pdev->dev : NULL; 132 - } 133 - EXPORT_SYMBOL_GPL(usb_of_get_companion_dev);