summaryrefslogtreecommitdiffstats
path: root/include/linux/pci.h
diff options
context:
space:
mode:
authorAlex Williamson <alex.williamson@redhat.com>2012-06-11 05:27:33 +0000
committerBjorn Helgaas <bhelgaas@google.com>2012-06-12 09:21:42 -0600
commita6961651408afa9387d6df43c4a1dc4fd35dcb1b (patch)
tree3ee93b9316123567ebfc65804cb8cc1be95be1e2 /include/linux/pci.h
parentc63587d7f5b9db84e71daf5962dc0394eb657da2 (diff)
downloadop-kernel-dev-a6961651408afa9387d6df43c4a1dc4fd35dcb1b.zip
op-kernel-dev-a6961651408afa9387d6df43c4a1dc4fd35dcb1b.tar.gz
PCI: create common pcibios_err_to_errno
For returning errors out to non-PCI code. Re-name xen's version. Acked-by: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com> Signed-off-by: Alex Williamson <alex.williamson@redhat.com> Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
Diffstat (limited to 'include/linux/pci.h')
-rw-r--r--include/linux/pci.h26
1 files changed, 26 insertions, 0 deletions
diff --git a/include/linux/pci.h b/include/linux/pci.h
index 9d04599..a691f62 100644
--- a/include/linux/pci.h
+++ b/include/linux/pci.h
@@ -474,6 +474,32 @@ static inline bool pci_dev_msi_enabled(struct pci_dev *pci_dev) { return false;
#define PCIBIOS_SET_FAILED 0x88
#define PCIBIOS_BUFFER_TOO_SMALL 0x89
+/*
+ * Translate above to generic errno for passing back through non-pci.
+ */
+static inline int pcibios_err_to_errno(int err)
+{
+ if (err <= PCIBIOS_SUCCESSFUL)
+ return err; /* Assume already errno */
+
+ switch (err) {
+ case PCIBIOS_FUNC_NOT_SUPPORTED:
+ return -ENOENT;
+ case PCIBIOS_BAD_VENDOR_ID:
+ return -EINVAL;
+ 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 -ENOTTY;
+}
+
/* Low-level architecture-dependent routines */
struct pci_ops {
OpenPOWER on IntegriCloud