summaryrefslogtreecommitdiff
path: root/drivers/usb/core/of.c
diff options
context:
space:
mode:
authorJohan Hovold <johan@kernel.org>2017-11-09 20:07:23 +0300
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2017-11-28 17:12:38 +0300
commit7739376eb1ed68593805e5b4ed359123d0718549 (patch)
tree92bd0a2f9e3d87809c83e92e55d87c7d13f943e4 /drivers/usb/core/of.c
parent03310a15484ab6a8f6d91bbf7fe486b17275c09a (diff)
downloadlinux-7739376eb1ed68593805e5b4ed359123d0718549.tar.xz
USB: of: clean up device-node helper
Clean up the USB device-node helper that is used to look up a device node given a parent hub device and a port number. Also pass in a struct usb_device as first argument to provide some type checking. Give the helper the more descriptive name usb_of_get_device_node(), which matches the new usb_of_get_interface_node() helper that is used to look up a second type of of child node from a USB device. Note that the terms "device node" and "interface node" are defined and used by the OF Recommended Practice for USB. Signed-off-by: Johan Hovold <johan@kernel.org> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'drivers/usb/core/of.c')
-rw-r--r--drivers/usb/core/of.c27
1 files changed, 14 insertions, 13 deletions
diff --git a/drivers/usb/core/of.c b/drivers/usb/core/of.c
index 074fabc26d6c..fd77442c2d12 100644
--- a/drivers/usb/core/of.c
+++ b/drivers/usb/core/of.c
@@ -12,31 +12,32 @@
#include <linux/usb/of.h>
/**
- * usb_of_get_child_node - Find the device node match port number
- * @parent: the parent device node
- * @portnum: the port number which device is connecting
+ * usb_of_get_device_node() - get a USB device node
+ * @hub: hub to which device is connected
+ * @port1: one-based index of port
*
- * Find the node from device tree according to its port number.
+ * Look up the node of a USB device given its parent hub device and one-based
+ * port number.
*
* Return: A pointer to the node with incremented refcount if found, or
* %NULL otherwise.
*/
-struct device_node *usb_of_get_child_node(struct device_node *parent,
- int portnum)
+struct device_node *usb_of_get_device_node(struct usb_device *hub, int port1)
{
struct device_node *node;
- u32 port;
+ u32 reg;
- for_each_child_of_node(parent, node) {
- if (!of_property_read_u32(node, "reg", &port)) {
- if (port == portnum)
- return node;
- }
+ for_each_child_of_node(hub->dev.of_node, node) {
+ if (of_property_read_u32(node, "reg", &reg))
+ continue;
+
+ if (reg == port1)
+ return node;
}
return NULL;
}
-EXPORT_SYMBOL_GPL(usb_of_get_child_node);
+EXPORT_SYMBOL_GPL(usb_of_get_device_node);
/**
* usb_of_has_combined_node() - determine whether a device has a combined node