diff mbox series

[v2,2/8] IB/hfi1: Convert PCIBIOS_* errors to generic -E* errors

Message ID 20200615073225.24061-3-refactormyself@gmail.com (mailing list archive)
State Not Applicable, archived
Delegated to: Bjorn Helgaas
Headers show
Series PCI: Align return values of PCIe capability and PCI accessors | expand

Commit Message

Saheed O. Bolarinwa June 15, 2020, 7:32 a.m. UTC
From: Bolarinwa Olayemi Saheed <refactormyself@gmail.com>

pcie_speeds() 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.

Suggested-by: Bjorn Helgaas <bjorn@helgaas.com>
Signed-off-by: Bolarinwa Olayemi Saheed <refactormyself@gmail.com>
---
 drivers/infiniband/hw/hfi1/pcie.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

Dennis Dalessandro June 29, 2020, 8:09 p.m. UTC | #1
On 6/15/2020 3:32 AM, refactormyself@gmail.com wrote:
> From: Bolarinwa Olayemi Saheed <refactormyself@gmail.com>
> 
> pcie_speeds() 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.
> 
> Suggested-by: Bjorn Helgaas <bjorn@helgaas.com>
> Signed-off-by: Bolarinwa Olayemi Saheed <refactormyself@gmail.com>
> ---
>   drivers/infiniband/hw/hfi1/pcie.c | 2 +-
>   1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/drivers/infiniband/hw/hfi1/pcie.c b/drivers/infiniband/hw/hfi1/pcie.c
> index 1a6268d61977..eb53781d0c6a 100644
> --- a/drivers/infiniband/hw/hfi1/pcie.c
> +++ b/drivers/infiniband/hw/hfi1/pcie.c
> @@ -306,7 +306,7 @@ int pcie_speeds(struct hfi1_devdata *dd)
>   	ret = pcie_capability_read_dword(dd->pcidev, PCI_EXP_LNKCAP, &linkcap);
>   	if (ret) {
>   		dd_dev_err(dd, "Unable to read from PCI config\n");
> -		return ret;
> +		return pcibios_err_to_errno(ret);
>   	}
>   
>   	if ((linkcap & PCI_EXP_LNKCAP_SLS) != PCI_EXP_LNKCAP_SLS_8_0GB) {
> 

Reviewed-by: Dennis Dalessandro <dennis.dalessandro@intel.com>
diff mbox series

Patch

diff --git a/drivers/infiniband/hw/hfi1/pcie.c b/drivers/infiniband/hw/hfi1/pcie.c
index 1a6268d61977..eb53781d0c6a 100644
--- a/drivers/infiniband/hw/hfi1/pcie.c
+++ b/drivers/infiniband/hw/hfi1/pcie.c
@@ -306,7 +306,7 @@  int pcie_speeds(struct hfi1_devdata *dd)
 	ret = pcie_capability_read_dword(dd->pcidev, PCI_EXP_LNKCAP, &linkcap);
 	if (ret) {
 		dd_dev_err(dd, "Unable to read from PCI config\n");
-		return ret;
+		return pcibios_err_to_errno(ret);
 	}
 
 	if ((linkcap & PCI_EXP_LNKCAP_SLS) != PCI_EXP_LNKCAP_SLS_8_0GB) {