Skip to content

Commit b915358

Browse files
refactormyselfbjorn-helgaas
authored andcommitted
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 <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Bolarinwa Olayemi Saheed <[email protected]> Signed-off-by: Bjorn Helgaas <[email protected]>
1 parent d20df83 commit b915358

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

drivers/pci/access.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -409,7 +409,7 @@ int pcie_capability_read_word(struct pci_dev *dev, int pos, u16 *val)
409409

410410
*val = 0;
411411
if (pos & 1)
412-
return -EINVAL;
412+
return PCIBIOS_BAD_REGISTER_NUMBER;
413413

414414
if (pcie_capability_reg_implemented(dev, pos)) {
415415
ret = pci_read_config_word(dev, pci_pcie_cap(dev) + pos, val);
@@ -444,7 +444,7 @@ int pcie_capability_read_dword(struct pci_dev *dev, int pos, u32 *val)
444444

445445
*val = 0;
446446
if (pos & 3)
447-
return -EINVAL;
447+
return PCIBIOS_BAD_REGISTER_NUMBER;
448448

449449
if (pcie_capability_reg_implemented(dev, pos)) {
450450
ret = pci_read_config_dword(dev, pci_pcie_cap(dev) + pos, val);
@@ -469,7 +469,7 @@ EXPORT_SYMBOL(pcie_capability_read_dword);
469469
int pcie_capability_write_word(struct pci_dev *dev, int pos, u16 val)
470470
{
471471
if (pos & 1)
472-
return -EINVAL;
472+
return PCIBIOS_BAD_REGISTER_NUMBER;
473473

474474
if (!pcie_capability_reg_implemented(dev, pos))
475475
return 0;
@@ -481,7 +481,7 @@ EXPORT_SYMBOL(pcie_capability_write_word);
481481
int pcie_capability_write_dword(struct pci_dev *dev, int pos, u32 val)
482482
{
483483
if (pos & 3)
484-
return -EINVAL;
484+
return PCIBIOS_BAD_REGISTER_NUMBER;
485485

486486
if (!pcie_capability_reg_implemented(dev, pos))
487487
return 0;

0 commit comments

Comments
 (0)