/* Success happens when the "mask" bits have the specified value (hardware handshake done). There are two failure modes: "usec" have passed (major hardware flakeout), or the register reads as all-ones (hardware removed).  */
static int handshake(struct xhci_hcd *xhci, void __iomem *ptr, u32 mask, u32 done, int usec)
/* Success happens when the "mask" bits have the specified value (hardware handshake done). There are two failure modes: "usec" have passed (major hardware flakeout), or the register reads as all-ones (hardware removed).  */
static int handshake(struct xhci_hcd *xhci, void __iomem *ptr, u32 mask, u32 done, int usec)
{
	u32	result;
	do {
		result = xhci_readl(xhci, ptr);
		if (result == ~(u32)0)
			return -ENODEV;
		result &= mask;
		if (result == done)
			return 0;
		udelay(1);
		usec--;
	} while (usec > 0);
	return -ETIMEDOUT;
}