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
20 #ifndef INIT_DEFERRABLE_WORK
21 #define INIT_DEFERRABLE_WORK(_work, _func) INIT_DELAYED_WORK_DEFERRABLE(_work, _func)
24 #ifndef DECLARE_DEFERRABLE_WORK
25 #define DECLARE_DEFERRABLE_WORK(n, f) DECLARE_DEFERRED_WORK(n, f)
30 #if (LINUX_VERSION_CODE > KERNEL_VERSION(2,6,38))
31 static inline struct user_namespace *seq_user_ns(struct seq_file *seq)
33 struct file *f = container_of((void *) seq, struct file, private_data);
35 return f->f_cred->user_ns;
38 static inline struct user_namespace *seq_user_ns(struct seq_file *seq)
40 return current_user_ns();
42 #endif /* (LINUX_VERSION_CODE > KERNEL_VERSION(2,6,38)) */
45 static inline struct user_namespace *seq_user_ns(struct seq_file *seq)
47 extern struct user_namespace init_user_ns;
50 #endif /* CONFIG_USER_NS */
52 #define netlink_notify_portid(__notify) (__notify->pid)
53 #define genl_info_snd_portid(__genl_info) (__genl_info->snd_pid)
54 #define NETLINK_CB_PORTID(__skb) NETLINK_CB(cb->skb).pid
56 #define mod_delayed_work LINUX_BACKPORT(mod_delayed_work)
57 bool mod_delayed_work(struct workqueue_struct *wq, struct delayed_work *dwork,
60 /* Backports tty_lock: Localise the lock */
61 #define tty_lock(__tty) tty_lock()
62 #define tty_unlock(__tty) tty_unlock()
64 #define tty_port_register_device(port, driver, index, device) \
65 tty_register_device(driver, index, device)
67 #define pcie_capability_read_word LINUX_BACKPORT(pcie_capability_read_word)
68 int pcie_capability_read_word(struct pci_dev *dev, int pos, u16 *val);
69 #define pcie_capability_read_dword LINUX_BACKPORT(pcie_capability_read_dword)
70 int pcie_capability_read_dword(struct pci_dev *dev, int pos, u32 *val);
71 #define pcie_capability_write_word LINUX_BACKPORT(pcie_capability_write_word)
72 int pcie_capability_write_word(struct pci_dev *dev, int pos, u16 val);
73 #define pcie_capability_write_dword LINUX_BACKPORT(pcie_capability_write_dword)
74 int pcie_capability_write_dword(struct pci_dev *dev, int pos, u32 val);
75 #define pcie_capability_clear_and_set_word LINUX_BACKPORT(pcie_capability_clear_and_set_word)
76 int pcie_capability_clear_and_set_word(struct pci_dev *dev, int pos,
78 #define pcie_capability_clear_and_set_dword LINUX_BACKPORT(pcie_capability_clear_and_set_dword)
79 int pcie_capability_clear_and_set_dword(struct pci_dev *dev, int pos,
81 #define pcie_capability_set_word LINUX_BACKPORT(pcie_capability_set_word)
82 static inline int pcie_capability_set_word(struct pci_dev *dev, int pos,
85 return pcie_capability_clear_and_set_word(dev, pos, 0, set);
88 #define pcie_capability_set_dword LINUX_BACKPORT(pcie_capability_set_dword)
89 static inline int pcie_capability_set_dword(struct pci_dev *dev, int pos,
92 return pcie_capability_clear_and_set_dword(dev, pos, 0, set);
95 #define pcie_capability_clear_word LINUX_BACKPORT(pcie_capability_clear_word)
96 static inline int pcie_capability_clear_word(struct pci_dev *dev, int pos,
99 return pcie_capability_clear_and_set_word(dev, pos, clear, 0);
102 #define pcie_capability_clear_dword LINUX_BACKPORT(pcie_capability_clear_dword)
103 static inline int pcie_capability_clear_dword(struct pci_dev *dev, int pos,
106 return pcie_capability_clear_and_set_dword(dev, pos, clear, 0);
109 #define PCI_EXP_LNKSTA2 50 /* Link Status 2 */
111 #define MAX_IDR_SHIFT (sizeof(int)*8 - 1)
112 #define MAX_IDR_BIT (1U << MAX_IDR_SHIFT)
113 #define MAX_IDR_MASK (MAX_IDR_BIT - 1)
116 #ifndef IFLA_IPOIB_MAX
126 IPOIB_MODE_DATAGRAM = 0, /* using unreliable datagram QPs */
127 IPOIB_MODE_CONNECTED = 1, /* using connected QPs */
130 #define IFLA_IPOIB_MAX (__IFLA_IPOIB_MAX - 1)
133 #define FMODE_PATH ((__force fmode_t)0x4000)
135 #define fget_light LINUX_BACKPORT(fget_light)
136 extern struct file *fget_light(unsigned int fd, int *fput_needed);
138 #else /* (LINUX_VERSION_CODE > KERNEL_VERSION(3,7,0)) */
139 #define netlink_notify_portid(__notify) (__notify->portid)
140 #define genl_info_snd_portid(__genl_info) (__genl_info->snd_portid)
141 #define NETLINK_CB_PORTID(__skb) NETLINK_CB(cb->skb).portid
142 #endif /* (LINUX_VERSION_CODE < KERNEL_VERSION(3,7,0)) */
144 #endif /* LINUX_3_7_COMPAT_H */