Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 969ddcfc authored by Alan Stern's avatar Alan Stern Committed by Greg Kroah-Hartman
Browse files

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: default avatarAlan Stern <stern@rowland.harvard.edu>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
parent d39dbc89
Loading
Loading
Loading
Loading
+8 −10
Original line number Diff line number Diff line
@@ -591,7 +591,6 @@ static ssize_t usb_device_dump(char __user **buffer, size_t *nbytes,

	/* Now look at all of this device's children. */
	usb_hub_for_each_child(usbdev, chix, childdev) {
		if (childdev) {
		usb_lock_device(childdev);
		ret = usb_device_dump(buffer, nbytes, skip_bytes,
				      file_offset, childdev, bus,
@@ -601,7 +600,6 @@ static ssize_t usb_device_dump(char __user **buffer, size_t *nbytes,
			return total_written;
		total_written += ret;
	}
	}
	return total_written;
}

+2 −4
Original line number Diff line number Diff line
@@ -2036,11 +2036,9 @@ static void collect_usb_address_map(struct usb_device *udev, unsigned long *map)
	    udev->parent->descriptor.bDeviceClass == USB_CLASS_HUB)
		map[udev->devnum/32] |= (1 << (udev->devnum % 32));

	usb_hub_for_each_child(udev, chix, childdev) {
		if (childdev)
	usb_hub_for_each_child(udev, chix, childdev)
		collect_usb_address_map(childdev, map);
}
}

/* this function must be called with interrupt disabled */
static struct r8a66597_device *get_r8a66597_device(struct r8a66597 *r8a66597,
+3 −2
Original line number Diff line number Diff line
@@ -589,7 +589,8 @@ 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))
			child = usb_hub_find_child(hdev, ++port1)) \
		if (!child) continue; else

/* USB device locking */
#define usb_lock_device(udev)		device_lock(&(udev)->dev)