summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorHeiner Kallweit <hkallweit1@gmail.com>2021-08-08 19:23:57 +0200
committerBjorn Helgaas <bhelgaas@google.com>2021-08-12 19:48:51 +0200
commitfe7568cf2f2dc3a0783f6ffdb3802c1ce2085466 (patch)
treedf6dfd8b6a3591a78a1756465be14f44eb81db0f
parentPCI/VPD: Determine VPD size in pci_vpd_init() (diff)
downloadlinux-fe7568cf2f2dc3a0783f6ffdb3802c1ce2085466.tar.xz
linux-fe7568cf2f2dc3a0783f6ffdb3802c1ce2085466.zip
PCI/VPD: Treat invalid VPD like missing VPD capability
Exporting sysfs files that can't be accessed doesn't make much sense. Therefore, if either a quirk or the dynamic size calculation result in VPD being marked as invalid, treat this as though the device has no VPD capability. One consequence is that the "vpd" sysfs file is not visible. Link: https://lore.kernel.org/r/6a02b204-4ed2-4553-c3b2-eacf9554fa8d@gmail.com Signed-off-by: Heiner Kallweit <hkallweit1@gmail.com> Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
-rw-r--r--drivers/pci/vpd.c9
1 files changed, 3 insertions, 6 deletions
diff --git a/drivers/pci/vpd.c b/drivers/pci/vpd.c
index a62251a3c7a1..3b0425fb49f5 100644
--- a/drivers/pci/vpd.c
+++ b/drivers/pci/vpd.c
@@ -124,9 +124,6 @@ static ssize_t pci_vpd_read(struct pci_dev *dev, loff_t pos, size_t count,
if (pos < 0)
return -EINVAL;
- if (vpd->len == PCI_VPD_SZ_INVALID)
- return -EIO;
-
if (pos > vpd->len)
return 0;
@@ -188,9 +185,6 @@ static ssize_t pci_vpd_write(struct pci_dev *dev, loff_t pos, size_t count,
if (pos < 0 || (pos & 3) || (count & 3))
return -EINVAL;
- if (vpd->len == PCI_VPD_SZ_INVALID)
- return -EIO;
-
if (end > vpd->len)
return -EINVAL;
@@ -231,6 +225,9 @@ void pci_vpd_init(struct pci_dev *dev)
if (!dev->vpd.len)
dev->vpd.len = pci_vpd_size(dev);
+
+ if (dev->vpd.len == PCI_VPD_SZ_INVALID)
+ dev->vpd.cap = 0;
}
static ssize_t vpd_read(struct file *filp, struct kobject *kobj,