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.

IB/hfi1: Convert PCIBIOS_* errors to generic -E* errors

pcie_speeds() and restore_pci_variables() returns PCIBIOS_ error codes
from PCIe capability accessors.

PCIBIOS_ error codes have positive values. Passing on these values is
inconsistent with functions which return only a negative value on failure.

Before passing on the return value of PCIe capability accessors, call
pcibios_err_to_errno() to convert any positive PCIBIOS_ error codes to
negative generic error values.

Link: https://lore.kernel.org/r/20200615073225.24061-3-refactormyself@gmail.com
Suggested-by: Bjorn Helgaas <bjorn@helgaas.com>
Signed-off-by: Bolarinwa Olayemi Saheed <refactormyself@gmail.com>
Reviewed-by: Dennis Dalessandro <dennis.dalessandro@intel.com>
Signed-off-by: Jason Gunthorpe <jgg@nvidia.com>

authored by

Bolarinwa Olayemi Saheed and committed by
Jason Gunthorpe
c4334a99 14c2b896

+15 -7
+15 -7
drivers/infiniband/hw/hfi1/pcie.c
··· 306 306 ret = pcie_capability_read_dword(dd->pcidev, PCI_EXP_LNKCAP, &linkcap); 307 307 if (ret) { 308 308 dd_dev_err(dd, "Unable to read from PCI config\n"); 309 - return ret; 309 + return pcibios_err_to_errno(ret); 310 310 } 311 311 312 312 if ((linkcap & PCI_EXP_LNKCAP_SLS) != PCI_EXP_LNKCAP_SLS_8_0GB) { ··· 334 334 return 0; 335 335 } 336 336 337 - /* restore command and BARs after a reset has wiped them out */ 337 + /** 338 + * Restore command and BARs after a reset has wiped them out 339 + * 340 + * Returns 0 on success, otherwise a negative error value 341 + */ 338 342 int restore_pci_variables(struct hfi1_devdata *dd) 339 343 { 340 - int ret = 0; 344 + int ret; 341 345 342 346 ret = pci_write_config_word(dd->pcidev, PCI_COMMAND, dd->pci_command); 343 347 if (ret) ··· 390 386 391 387 error: 392 388 dd_dev_err(dd, "Unable to write to PCI config\n"); 393 - return ret; 389 + return pcibios_err_to_errno(ret); 394 390 } 395 391 396 - /* Save BARs and command to rewrite after device reset */ 392 + /** 393 + * Save BARs and command to rewrite after device reset 394 + * 395 + * Returns 0 on success, otherwise a negative error value 396 + */ 397 397 int save_pci_variables(struct hfi1_devdata *dd) 398 398 { 399 - int ret = 0; 399 + int ret; 400 400 401 401 ret = pci_read_config_dword(dd->pcidev, PCI_BASE_ADDRESS_0, 402 402 &dd->pcibar0); ··· 449 441 450 442 error: 451 443 dd_dev_err(dd, "Unable to read from PCI config\n"); 452 - return ret; 444 + return pcibios_err_to_errno(ret); 453 445 } 454 446 455 447 /*