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

Commit 470f0be8 authored by Sarah Sharp's avatar Sarah Sharp
Browse files

USB: Refactor hub_port_wait_reset.



Refactor hub_port_wait_reset into a small loop to wait for the port
reset to be complete, and then a larger block to deal with the final
port status.  This patch should not change any current behavior.

Signed-off-by: default avatarSarah Sharp <sarah.a.sharp@linux.intel.com>
Acked-by: default avatarAlan Stern <stern@rowland.harvard.edu>
parent c2f60db7
Loading
Loading
Loading
Loading
+37 −36
Original line number Diff line number Diff line
@@ -2535,8 +2535,20 @@ static int hub_port_wait_reset(struct usb_hub *hub, int port1,
			return ret;

		/* The port state is unknown until the reset completes. */
		if (!(portstatus & USB_PORT_STAT_RESET))
			break;

		/* switch to the long delay after two short delay failures */
		if (delay_time >= 2 * HUB_SHORT_RESET_TIME)
			delay = HUB_LONG_RESET_TIME;

		dev_dbg (hub->intfdev,
			"port %d not %sreset yet, waiting %dms\n",
			port1, warm ? "warm " : "", delay);
	}

	if ((portstatus & USB_PORT_STAT_RESET))
			goto delay;
		return -EBUSY;

	if (hub_port_warm_reset_required(hub, portstatus))
		return -ENOTCONN;
@@ -2553,7 +2565,9 @@ static int hub_port_wait_reset(struct usb_hub *hub, int port1,
			(portchange & USB_PORT_STAT_C_CONNECTION))
		return -ENOTCONN;

		if ((portstatus & USB_PORT_STAT_ENABLE)) {
	if (!(portstatus & USB_PORT_STAT_ENABLE))
		return -EBUSY;

	if (!udev)
		return 0;

@@ -2570,19 +2584,6 @@ static int hub_port_wait_reset(struct usb_hub *hub, int port1,
	return 0;
}

delay:
		/* switch to the long delay after two short delay failures */
		if (delay_time >= 2 * HUB_SHORT_RESET_TIME)
			delay = HUB_LONG_RESET_TIME;

		dev_dbg (hub->intfdev,
			"port %d not %sreset yet, waiting %dms\n",
			port1, warm ? "warm " : "", delay);
	}

	return -EBUSY;
}

static void hub_port_finish_reset(struct usb_hub *hub, int port1,
			struct usb_device *udev, int *status)
{