/* Wait for last operation to complete. This code has to spin since there is no other notification from the PCI hardware. Since the VPD is often implemented by serial attachment to an EEPROM, it may take many milliseconds to complete.  */
static int pci_vpd_pci22_wait(struct pci_dev *dev)
/* Wait for last operation to complete. This code has to spin since there is no other notification from the PCI hardware. Since the VPD is often implemented by serial attachment to an EEPROM, it may take many milliseconds to complete.  */
static int pci_vpd_pci22_wait(struct pci_dev *dev)
{
	struct pci_vpd_pci22 *vpd =
		container_of(dev->vpd, struct pci_vpd_pci22, base);
	unsigned long timeout = jiffies + HZ/20 + 2;
	u16 status;
	int ret;
	if (!vpd->busy)
		return 0;
	for (;;) {
		ret = pci_user_read_config_word(dev, vpd->cap + PCI_VPD_ADDR,
						&status);
		if (ret)
			return ret;
		if ((status & PCI_VPD_ADDR_F) == vpd->flag) {
			vpd->busy = false;
			return 0;
		}
		if (time_after(jiffies, timeout))
			return -ETIMEDOUT;
		if (fatal_signal_pending(current))
			return -EINTR;
		if (!cond_resched())
			udelay(10);
	}
}