Merge branch 'ofed' of git://flatbed.openfabrics.org/~tnikolova/compat/ into ofed
[~tnikolova/compat/.git] / include / linux / compat-3.12.h
1 #ifndef LINUX_3_12_COMPAT_H
2 #define LINUX_3_12_COMPAT_H
3
4 #include <linux/version.h>
5
6 #if (LINUX_VERSION_CODE < KERNEL_VERSION(3,12,0))
7 #include <linux/pci.h>
8
9 #ifndef PTR_ERR_OR_ZERO
10 #define PTR_ERR_OR_ZERO(p) PTR_RET(p)
11 #endif
12
13 #define MODULE_ALIAS_FS(NAME) MODULE_ALIAS("fs-" NAME)
14
15 #define file_inode LINUX_BACKPORT(file_inode)
16 static inline struct inode *file_inode(struct file *f)
17 {
18         return f->f_dentry->d_inode;
19 }
20
21 int pcie_get_minimum_link(struct pci_dev *dev, enum pci_bus_speed *speed,
22                 enum pcie_link_width *width);
23
24 /* These values come from the PCI Express Spec */
25 enum pcie_link_width {
26         PCIE_LNK_WIDTH_RESRV    = 0x00,
27         PCIE_LNK_X1             = 0x01,
28         PCIE_LNK_X2             = 0x02,
29         PCIE_LNK_X4             = 0x04,
30         PCIE_LNK_X8             = 0x08,
31         PCIE_LNK_X12            = 0x0C,
32         PCIE_LNK_X16            = 0x10,
33         PCIE_LNK_X32            = 0x20,
34         PCIE_LNK_WIDTH_UNKNOWN  = 0xFF,
35 };
36
37 /* Based on the PCI Hotplug Spec, but some values are made up by us */
38 enum pci_bus_speed {
39         PCI_SPEED_33MHz                 = 0x00,
40         PCI_SPEED_66MHz                 = 0x01,
41         PCI_SPEED_66MHz_PCIX            = 0x02,
42         PCI_SPEED_100MHz_PCIX           = 0x03,
43         PCI_SPEED_133MHz_PCIX           = 0x04,
44         PCI_SPEED_66MHz_PCIX_ECC        = 0x05,
45         PCI_SPEED_100MHz_PCIX_ECC       = 0x06,
46         PCI_SPEED_133MHz_PCIX_ECC       = 0x07,
47         PCI_SPEED_66MHz_PCIX_266        = 0x09,
48         PCI_SPEED_100MHz_PCIX_266       = 0x0a,
49         PCI_SPEED_133MHz_PCIX_266       = 0x0b,
50         AGP_UNKNOWN                     = 0x0c,
51         AGP_1X                          = 0x0d,
52         AGP_2X                          = 0x0e,
53         AGP_4X                          = 0x0f,
54         AGP_8X                          = 0x10,
55         PCI_SPEED_66MHz_PCIX_533        = 0x11,
56         PCI_SPEED_100MHz_PCIX_533       = 0x12,
57         PCI_SPEED_133MHz_PCIX_533       = 0x13,
58         PCIE_SPEED_2_5GT                = 0x14,
59         PCIE_SPEED_5_0GT                = 0x15,
60         PCIE_SPEED_8_0GT                = 0x16,
61         PCI_SPEED_UNKNOWN               = 0xff,
62 };
63
64 #endif /* (LINUX_VERSION_CODE < KERNEL_VERSION(3,12,0)) */
65
66 #endif /* LINUX_3_12_COMPAT_H */