usb: move children to struct usb_port
The usb_device structure contains an array of usb_device "children". This array is only valid if the usb_device is a hub, so it makes no sense to store it there. Instead, store the usb_device child in its parent usb_port structure. Since usb_port is an internal USB core structure, add a new function to get the USB device child, usb_hub_find_child(). Add a new macro, usb_hub_get_each_child(), to iterate over all the children attached to a particular USB hub. Remove the printing the USB children array pointer from the usb-ip driver, since it's really not necessary. Acked-by: Alan Stern <stern@rowland.harvard.edu> Signed-off-by: Lan Tianyu <tianyu.lan@intel.com> Signed-off-by: Sarah Sharp <sarah.a.sharp@linux.intel.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
This commit is contained in:
parent
fa2a956625
commit
ff823c79a5
5 changed files with 68 additions and 35 deletions
|
@ -469,7 +469,6 @@ struct usb3_lpm_parameters {
|
|||
* access from userspace
|
||||
* @usbfs_dentry: usbfs dentry entry for the device
|
||||
* @maxchild: number of ports if hub
|
||||
* @children: child devices - USB devices that are attached to this hub
|
||||
* @quirks: quirks of the whole device
|
||||
* @urbnum: number of URBs submitted for the whole device
|
||||
* @active_duration: total time device is not suspended
|
||||
|
@ -543,7 +542,6 @@ struct usb_device {
|
|||
struct list_head filelist;
|
||||
|
||||
int maxchild;
|
||||
struct usb_device **children;
|
||||
|
||||
u32 quirks;
|
||||
atomic_t urbnum;
|
||||
|
@ -572,6 +570,19 @@ static inline struct usb_device *interface_to_usbdev(struct usb_interface *intf)
|
|||
|
||||
extern struct usb_device *usb_get_dev(struct usb_device *dev);
|
||||
extern void usb_put_dev(struct usb_device *dev);
|
||||
extern struct usb_device *usb_hub_find_child(struct usb_device *hdev,
|
||||
int port1);
|
||||
|
||||
/**
|
||||
* usb_hub_for_each_child - iterate over all child devices on the hub
|
||||
* @hdev: USB device belonging to the usb hub
|
||||
* @port1: portnum associated with child device
|
||||
* @child: child device pointer
|
||||
*/
|
||||
#define usb_hub_for_each_child(hdev, port1, child) \
|
||||
for (port1 = 1, child = usb_hub_find_child(hdev, port1); \
|
||||
port1 <= hdev->maxchild; \
|
||||
child = usb_hub_find_child(hdev, ++port1))
|
||||
|
||||
/* USB device locking */
|
||||
#define usb_lock_device(udev) device_lock(&(udev)->dev)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue