1 #ifndef LINUX_3_7_COMPAT_H
2 #define LINUX_3_7_COMPAT_H
4 #include <linux/version.h>
6 #if (LINUX_VERSION_CODE < KERNEL_VERSION(3,7,0))
8 #include <linux/workqueue.h>
9 #include <linux/timer.h>
10 #include <linux/pci.h>
11 #include <linux/pci_regs.h>
13 #include <linux/user_namespace.h>
14 #include <linux/file.h>
15 #include <linux/fdtable.h>
16 #include <linux/seq_file.h>
18 #define VM_DONTDUMP VM_NODUMP
22 #if (LINUX_VERSION_CODE > KERNEL_VERSION(2,6,38))
23 static inline struct user_namespace *seq_user_ns(struct seq_file *seq)
25 struct file *f = container_of((void *) seq, struct file, private_data);
27 return f->f_cred->user_ns;
30 static inline struct user_namespace *seq_user_ns(struct seq_file *seq)
32 return current_user_ns();
34 #endif /* (LINUX_VERSION_CODE > KERNEL_VERSION(2,6,38)) */
37 static inline struct user_namespace *seq_user_ns(struct seq_file *seq)
39 extern struct user_namespace init_user_ns;
42 #endif /* CONFIG_USER_NS */
44 #define netlink_notify_portid(__notify) (__notify->pid)
45 #define genl_info_snd_portid(__genl_info) (__genl_info->snd_pid)
46 #define NETLINK_CB_PORTID(__skb) NETLINK_CB(cb->skb).pid
48 #define mod_delayed_work LINUX_BACKPORT(mod_delayed_work)
49 bool mod_delayed_work(struct workqueue_struct *wq, struct delayed_work *dwork,
52 /* Backports tty_lock: Localise the lock */
53 #define tty_lock(__tty) tty_lock()
54 #define tty_unlock(__tty) tty_unlock()
56 #define tty_port_register_device(port, driver, index, device) \
57 tty_register_device(driver, index, device)
59 #define pcie_capability_read_word LINUX_BACKPORT(pcie_capability_read_word)
60 int pcie_capability_read_word(struct pci_dev *dev, int pos, u16 *val);
61 #define pcie_capability_read_dword LINUX_BACKPORT(pcie_capability_read_dword)
62 int pcie_capability_read_dword(struct pci_dev *dev, int pos, u32 *val);
63 #define pcie_capability_write_word LINUX_BACKPORT(pcie_capability_write_word)
64 int pcie_capability_write_word(struct pci_dev *dev, int pos, u16 val);
65 #define pcie_capability_write_dword LINUX_BACKPORT(pcie_capability_write_dword)
66 int pcie_capability_write_dword(struct pci_dev *dev, int pos, u32 val);
67 #define pcie_capability_clear_and_set_word LINUX_BACKPORT(pcie_capability_clear_and_set_word)
68 int pcie_capability_clear_and_set_word(struct pci_dev *dev, int pos,
70 #define pcie_capability_clear_and_set_dword LINUX_BACKPORT(pcie_capability_clear_and_set_dword)
71 int pcie_capability_clear_and_set_dword(struct pci_dev *dev, int pos,
73 #define pcie_capability_set_word LINUX_BACKPORT(pcie_capability_set_word)
74 static inline int pcie_capability_set_word(struct pci_dev *dev, int pos,
77 return pcie_capability_clear_and_set_word(dev, pos, 0, set);
80 #define pcie_capability_set_dword LINUX_BACKPORT(pcie_capability_set_dword)
81 static inline int pcie_capability_set_dword(struct pci_dev *dev, int pos,
84 return pcie_capability_clear_and_set_dword(dev, pos, 0, set);
87 #define pcie_capability_clear_word LINUX_BACKPORT(pcie_capability_clear_word)
88 static inline int pcie_capability_clear_word(struct pci_dev *dev, int pos,
91 return pcie_capability_clear_and_set_word(dev, pos, clear, 0);
94 #define pcie_capability_clear_dword LINUX_BACKPORT(pcie_capability_clear_dword)
95 static inline int pcie_capability_clear_dword(struct pci_dev *dev, int pos,
98 return pcie_capability_clear_and_set_dword(dev, pos, clear, 0);
101 #define PCI_EXP_LNKSTA2 50 /* Link Status 2 */
103 #define MAX_IDR_SHIFT (sizeof(int)*8 - 1)
104 #define MAX_IDR_BIT (1U << MAX_IDR_SHIFT)
105 #define MAX_IDR_MASK (MAX_IDR_BIT - 1)
118 IPOIB_MODE_DATAGRAM = 0, /* using unreliable datagram QPs */
119 IPOIB_MODE_CONNECTED = 1, /* using connected QPs */
122 #define IFLA_IPOIB_MAX (__IFLA_IPOIB_MAX - 1)
124 #define FMODE_PATH ((__force fmode_t)0x4000)
126 #define fget_light LINUX_BACKPORT(fget_light)
127 extern struct file *fget_light(unsigned int fd, int *fput_needed);
129 #else /* (LINUX_VERSION_CODE > KERNEL_VERSION(3,7,0)) */
130 #define netlink_notify_portid(__notify) (__notify->portid)
131 #define genl_info_snd_portid(__genl_info) (__genl_info->snd_portid)
132 #define NETLINK_CB_PORTID(__skb) NETLINK_CB(cb->skb).portid
133 #endif /* (LINUX_VERSION_CODE < KERNEL_VERSION(3,7,0)) */
135 #endif /* LINUX_3_7_COMPAT_H */