diff mbox series

[RFC,2/2] pci: Set all PCIBIOS_* error codes to generic error codes

Message ID 20200504051812.22662-3-refactormyself@gmail.com
State New
Headers show
Series pci: Make return value of pcie_capability_*() consistent | expand

Commit Message

Saheed O. Bolarinwa May 4, 2020, 5:18 a.m. UTC
From: Bolarinwa Olayemi Saheed <refactormyself@gmail.com>

PCIBIOS_* error codes now set to negative value generic codes.
pcibios_err_to_errno() is modified to reflect this changes and the function
is now marked deprecated. The function now only returns negative error
codes.

These changes effect the consistency across pci and pcie accessors.
Now they all return 0 on success and < 0, otherwise.

Signed-off-by: Bolarinwa Olayemi Saheed <refactormyself@gmail.com>
Suggested-by: Yicong Yang <yangyicong@hisilicon.com>
---
 include/linux/pci.h | 31 +++++++++++++++----------------
 1 file changed, 15 insertions(+), 16 deletions(-)
diff mbox series

Patch

diff --git a/include/linux/pci.h b/include/linux/pci.h
index 3840a541a9de..ee87def7242a 100644
--- a/include/linux/pci.h
+++ b/include/linux/pci.h
@@ -661,32 +661,31 @@  static inline bool pci_dev_msi_enabled(struct pci_dev *pci_dev) { return false;
 
 /* Error values that may be returned by PCI functions */
 #define PCIBIOS_SUCCESSFUL		0x00
-#define PCIBIOS_FUNC_NOT_SUPPORTED	0x81
-#define PCIBIOS_BAD_VENDOR_ID		0x83
-#define PCIBIOS_DEVICE_NOT_FOUND	0x86
-#define PCIBIOS_BAD_REGISTER_NUMBER	0x87
-#define PCIBIOS_SET_FAILED		0x88
-#define PCIBIOS_BUFFER_TOO_SMALL	0x89
-
-/* Translate above to generic errno for passing back through non-PCI code */
+#define PCIBIOS_FUNC_NOT_SUPPORTED	-ENOENT
+#define PCIBIOS_BAD_VENDOR_ID		-ENOTTY
+#define PCIBIOS_DEVICE_NOT_FOUND	-ENODEV
+#define PCIBIOS_BAD_REGISTER_NUMBER	-EFAULT
+#define PCIBIOS_SET_FAILED		-EIO
+#define PCIBIOS_BUFFER_TOO_SMALL	-ENOSPC
+
+/* *
+ * Translate above to generic errno for passing back through non-PCI code
+ *
+ * Deprecated. Use the PCIBIOS_* directly without a translation.
+ */
 static inline int pcibios_err_to_errno(int err)
 {
-	if (err <= PCIBIOS_SUCCESSFUL)
-		return err; /* Assume already errno */
+	if (err == PCIBIOS_SUCCESSFUL)
+		return err; /* preserve success */
 
 	switch (err) {
 	case PCIBIOS_FUNC_NOT_SUPPORTED:
-		return -ENOENT;
 	case PCIBIOS_BAD_VENDOR_ID:
-		return -ENOTTY;
 	case PCIBIOS_DEVICE_NOT_FOUND:
-		return -ENODEV;
 	case PCIBIOS_BAD_REGISTER_NUMBER:
-		return -EFAULT;
 	case PCIBIOS_SET_FAILED:
-		return -EIO;
 	case PCIBIOS_BUFFER_TOO_SMALL:
-		return -ENOSPC;
+		return err;
 	}
 
 	return -ERANGE;