PCI: Add pci_set_vpd_size() to set VPD size
authorHariprasad Shenai <hariprasad@chelsio.com>
Fri, 15 Apr 2016 18:00:11 +0000 (13:00 -0500)
committerBjorn Helgaas <bhelgaas@google.com>
Fri, 15 Apr 2016 18:00:11 +0000 (13:00 -0500)
commitcb92148b58a49455f3a7204eba3aee09a8b7683c
tree0da42a2722827d2b530fdf771d06af7b17cc0ec6
parentb2d7a9cd3ff8ec561348267c2ef7d47b2b91e801
PCI: Add pci_set_vpd_size() to set VPD size

After 104daa71b396 ("PCI: Determine actual VPD size on first access"), the
PCI core computes the valid VPD size by parsing the VPD starting at offset
0x0.  We don't attempt to read past that valid size because that causes
some devices to crash.

However, some devices do have data past that valid size.  For example,
Chelsio adapters contain two VPD structures, and the driver needs both of
them.

Add pci_set_vpd_size().  If a driver knows it is safe to read past the end
of the VPD data structure at offset 0, it can use pci_set_vpd_size() to
allow access to as much data as it needs.

[bhelgaas: changelog, split patches, rename to pci_set_vpd_size() and
return int (not ssize_t)]
Fixes: 104daa71b396 ("PCI: Determine actual VPD size on first access")
Tested-by: Steve Wise <swise@opengridcomputing.com>
Signed-off-by: Casey Leedom <leedom@chelsio.com>
Signed-off-by: Hariprasad Shenai <hariprasad@chelsio.com>
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
drivers/pci/access.c
drivers/pci/pci.h
include/linux/pci.h