aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/pci/vpd.c
diff options
context:
space:
mode:
authorHeiner Kallweit <hkallweit1@gmail.com>2021-05-13 22:56:09 +0200
committerBjorn Helgaas <bhelgaas@google.com>2021-08-09 13:43:43 -0500
commit1285762c07121b449cd60166b813c0084b792736 (patch)
treee3a5d14325558e918cc11232324993513f981f1b /drivers/pci/vpd.c
parentPCI/VPD: Allow access to valid parts of VPD if some is invalid (diff)
downloadlinux-dev-1285762c07121b449cd60166b813c0084b792736.tar.xz
linux-dev-1285762c07121b449cd60166b813c0084b792736.zip
PCI/VPD: Remove pci_vpd_size() old_size argument
vpd->len is initialized to PCI_VPD_MAX_SIZE, and if a quirk is used to set a specific VPD size, then pci_vpd_set_size() sets vpd->valid, resulting in pci_vpd_size() not being called. Therefore we can remove the old_size argument. Note that we don't have to check off < PCI_VPD_MAX_SIZE because that's implicitly done by pci_read_vpd(). Link: https://lore.kernel.org/r/ede36c16-5335-6867-43a1-293641348430@gmail.com Signed-off-by: Heiner Kallweit <hkallweit1@gmail.com> Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
Diffstat (limited to 'drivers/pci/vpd.c')
-rw-r--r--drivers/pci/vpd.c10
1 files changed, 5 insertions, 5 deletions
diff --git a/drivers/pci/vpd.c b/drivers/pci/vpd.c
index a85c8b51703a..4f262f8530ea 100644
--- a/drivers/pci/vpd.c
+++ b/drivers/pci/vpd.c
@@ -68,14 +68,13 @@ EXPORT_SYMBOL(pci_write_vpd);
/**
* pci_vpd_size - determine actual size of Vital Product Data
* @dev: pci device struct
- * @old_size: current assumed size, also maximum allowed size
*/
-static size_t pci_vpd_size(struct pci_dev *dev, size_t old_size)
+static size_t pci_vpd_size(struct pci_dev *dev)
{
size_t off = 0, size;
unsigned char tag, header[1+2]; /* 1 byte tag, 2 bytes length */
- while (off < old_size && pci_read_vpd(dev, off, 1, header) == 1) {
+ while (pci_read_vpd(dev, off, 1, header) == 1) {
size = 0;
if (off == 0 && (header[0] == 0x00 || header[0] == 0xff))
@@ -172,7 +171,7 @@ static ssize_t pci_vpd_read(struct pci_dev *dev, loff_t pos, size_t count,
if (!vpd->valid) {
vpd->valid = 1;
- vpd->len = pci_vpd_size(dev, vpd->len);
+ vpd->len = pci_vpd_size(dev);
}
if (vpd->len == 0)
@@ -239,7 +238,7 @@ static ssize_t pci_vpd_write(struct pci_dev *dev, loff_t pos, size_t count,
if (!vpd->valid) {
vpd->valid = 1;
- vpd->len = pci_vpd_size(dev, vpd->len);
+ vpd->len = pci_vpd_size(dev);
}
if (vpd->len == 0)
@@ -463,6 +462,7 @@ static void quirk_blacklist_vpd(struct pci_dev *dev)
{
if (dev->vpd) {
dev->vpd->len = 0;
+ dev->vpd->valid = 1;
pci_warn(dev, FW_BUG "disabling VPD access (can't determine size of non-standard VPD format)\n");
}
}