Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

PCI: Align PCIe capability and PCI accessor return values

The PCI config accessors (pci_read_config_word(), et al) return
PCIBIOS_SUCCESSFUL (zero) or positive error values like
PCIBIOS_FUNC_NOT_SUPPORTED.

The PCIe capability accessors similarly return PCIBIOS errors, but in
addition, they can return -EINVAL. This makes it harder than it should be
to check for errors.

Return PCIBIOS_BAD_REGISTER_NUMBER instead of -EINVAL in all PCIe
capability accessors.

Suggested-by: Bjorn Helgaas <bjorn@helgaas.com>
Link: https://lore.kernel.org/r/20200615073225.24061-9-refactormyself@gmail.com
Signed-off-by: Bolarinwa Olayemi Saheed <refactormyself@gmail.com>
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>

authored by

Bolarinwa Olayemi Saheed and committed by
Bjorn Helgaas
b9153581 d20df83b

+4 -4
+4 -4
drivers/pci/access.c
··· 409 409 410 410 *val = 0; 411 411 if (pos & 1) 412 - return -EINVAL; 412 + return PCIBIOS_BAD_REGISTER_NUMBER; 413 413 414 414 if (pcie_capability_reg_implemented(dev, pos)) { 415 415 ret = pci_read_config_word(dev, pci_pcie_cap(dev) + pos, val); ··· 444 444 445 445 *val = 0; 446 446 if (pos & 3) 447 - return -EINVAL; 447 + return PCIBIOS_BAD_REGISTER_NUMBER; 448 448 449 449 if (pcie_capability_reg_implemented(dev, pos)) { 450 450 ret = pci_read_config_dword(dev, pci_pcie_cap(dev) + pos, val); ··· 469 469 int pcie_capability_write_word(struct pci_dev *dev, int pos, u16 val) 470 470 { 471 471 if (pos & 1) 472 - return -EINVAL; 472 + return PCIBIOS_BAD_REGISTER_NUMBER; 473 473 474 474 if (!pcie_capability_reg_implemented(dev, pos)) 475 475 return 0; ··· 481 481 int pcie_capability_write_dword(struct pci_dev *dev, int pos, u32 val) 482 482 { 483 483 if (pos & 3) 484 - return -EINVAL; 484 + return PCIBIOS_BAD_REGISTER_NUMBER; 485 485 486 486 if (!pcie_capability_reg_implemented(dev, pos)) 487 487 return 0;