Commit fe943bd8 authored by Heiner Kallweit's avatar Heiner Kallweit Committed by Bjorn Helgaas

PCI/VPD: Remove struct pci_vpd.flag

The struct pci_vpd.flag member was used only to communicate between
pci_vpd_wait() and its callers.  Remove the flag member and pass the value
directly to pci_vpd_wait() to simplify the code.

[bhelgaas: commit log]
Link: https://lore.kernel.org/r/e4ef6845-6b23-1646-28a0-d5c5a28347b6@gmail.comSigned-off-by: default avatarHeiner Kallweit <hkallweit1@gmail.com>
Signed-off-by: default avatarBjorn Helgaas <bhelgaas@google.com>
parent 91ab5d9d
...@@ -22,7 +22,6 @@ struct pci_vpd { ...@@ -22,7 +22,6 @@ struct pci_vpd {
const struct pci_vpd_ops *ops; const struct pci_vpd_ops *ops;
struct mutex lock; struct mutex lock;
unsigned int len; unsigned int len;
u16 flag;
u8 cap; u8 cap;
unsigned int valid:1; unsigned int valid:1;
}; };
...@@ -117,10 +116,11 @@ static size_t pci_vpd_size(struct pci_dev *dev) ...@@ -117,10 +116,11 @@ static size_t pci_vpd_size(struct pci_dev *dev)
* This code has to spin since there is no other notification from the PCI * 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 * hardware. Since the VPD is often implemented by serial attachment to an
* EEPROM, it may take many milliseconds to complete. * EEPROM, it may take many milliseconds to complete.
* @set: if true wait for flag to be set, else wait for it to be cleared
* *
* Returns 0 on success, negative values indicate error. * Returns 0 on success, negative values indicate error.
*/ */
static int pci_vpd_wait(struct pci_dev *dev) static int pci_vpd_wait(struct pci_dev *dev, bool set)
{ {
struct pci_vpd *vpd = dev->vpd; struct pci_vpd *vpd = dev->vpd;
unsigned long timeout = jiffies + msecs_to_jiffies(125); unsigned long timeout = jiffies + msecs_to_jiffies(125);
...@@ -134,7 +134,7 @@ static int pci_vpd_wait(struct pci_dev *dev) ...@@ -134,7 +134,7 @@ static int pci_vpd_wait(struct pci_dev *dev)
if (ret < 0) if (ret < 0)
return ret; return ret;
if ((status & PCI_VPD_ADDR_F) == vpd->flag) if (!!(status & PCI_VPD_ADDR_F) == set)
return 0; return 0;
if (time_after(jiffies, timeout)) if (time_after(jiffies, timeout))
...@@ -192,8 +192,7 @@ static ssize_t pci_vpd_read(struct pci_dev *dev, loff_t pos, size_t count, ...@@ -192,8 +192,7 @@ static ssize_t pci_vpd_read(struct pci_dev *dev, loff_t pos, size_t count,
pos & ~3); pos & ~3);
if (ret < 0) if (ret < 0)
break; break;
vpd->flag = PCI_VPD_ADDR_F; ret = pci_vpd_wait(dev, true);
ret = pci_vpd_wait(dev);
if (ret < 0) if (ret < 0)
break; break;
...@@ -257,8 +256,7 @@ static ssize_t pci_vpd_write(struct pci_dev *dev, loff_t pos, size_t count, ...@@ -257,8 +256,7 @@ static ssize_t pci_vpd_write(struct pci_dev *dev, loff_t pos, size_t count,
if (ret < 0) if (ret < 0)
break; break;
vpd->flag = 0; ret = pci_vpd_wait(dev, false);
ret = pci_vpd_wait(dev);
if (ret < 0) if (ret < 0)
break; break;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment