diff options
author | Alan Stern <stern@rowland.harvard.edu> | 2012-10-19 11:03:02 -0400 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@linuxfoundation.org> | 2012-10-24 14:51:21 -0700 |
commit | 969ddcfc95c9a1849114fb72466d2fdea70f1d48 (patch) | |
tree | e5322bb7b06e99461d96bf1091cf74230e811714 /include/linux | |
parent | d39dbc8918be0e6bb850592e334203c9114c0e77 (diff) | |
download | linux-stable-969ddcfc95c9a1849114fb72466d2fdea70f1d48.tar.gz linux-stable-969ddcfc95c9a1849114fb72466d2fdea70f1d48.tar.bz2 linux-stable-969ddcfc95c9a1849114fb72466d2fdea70f1d48.zip |
USB: hub_for_each_child should skip unconnected ports
This patch (as1619) improves the interface to the "hub_for_each_child"
macro. The name clearly suggests that the macro iterates over child
devices; it does not suggest that the loop will also iterate over
unnconnected ports.
The patch changes the macro so that it will skip over unconnected
ports and iterate only the actual child devices. The two existing
call sites are updated to avoid testing for a NULL child pointer,
which is now unnecessary.
Signed-off-by: Alan Stern <stern@rowland.harvard.edu>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'include/linux')
-rw-r--r-- | include/linux/usb.h | 5 |
1 files changed, 3 insertions, 2 deletions
diff --git a/include/linux/usb.h b/include/linux/usb.h index f92cdf0c1457..5df7c87b277f 100644 --- a/include/linux/usb.h +++ b/include/linux/usb.h @@ -588,8 +588,9 @@ extern struct usb_device *usb_hub_find_child(struct usb_device *hdev, */ #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)) + port1 <= hdev->maxchild; \ + child = usb_hub_find_child(hdev, ++port1)) \ + if (!child) continue; else /* USB device locking */ #define usb_lock_device(udev) device_lock(&(udev)->dev) |