1 #ifndef LINUX_26_36_COMPAT_H
2 #define LINUX_26_36_COMPAT_H
4 #include <linux/version.h>
6 #if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,36))
9 #include <pcmcia/cistpl.h>
10 #include <pcmcia/ds.h>
11 #include <linux/pm_qos_params.h>
12 #include <linux/smp_lock.h>
14 #ifndef CONFIG_COMPAT_RHEL_6_4
15 #define kparam_block_sysfs_write(a)
16 #define kparam_unblock_sysfs_write(a)
17 #endif /* CONFIG_COMPAT_RHEL_6_4 */
19 /* mask va_format as RHEL6 backports this */
20 #define va_format compat_va_format
27 #define device_rename(dev, new_name) device_rename(dev, (char *)new_name)
29 #ifdef CONFIG_COMPAT_USB_URB_THREAD_FIX
30 #define usb_scuttle_anchored_urbs(anchor) compat_usb_scuttle_anchored_urbs(anchor)
31 #define usb_get_from_anchor(anchor) compat_usb_get_from_anchor(anchor)
32 #define usb_unlink_anchored_urbs(anchor) compat_usb_unlink_anchored_urbs(anchor)
34 extern void compat_usb_unlink_anchored_urbs(struct usb_anchor *anchor);
35 extern struct urb *compat_usb_get_from_anchor(struct usb_anchor *anchor);
36 extern void compat_usb_scuttle_anchored_urbs(struct usb_anchor *anchor);
39 #ifndef CONFIG_COMPAT_RHEL_6_4
41 * pcmcia_read_config_byte() - read a byte from a card configuration register
43 * pcmcia_read_config_byte() reads a byte from a configuration register in
46 static inline int pcmcia_read_config_byte(struct pcmcia_device *p_dev, off_t where, u8 *val)
49 conf_reg_t reg = { 0, CS_READ, where, 0 };
50 ret = pcmcia_access_configuration_register(p_dev, ®);
56 * pcmcia_write_config_byte() - write a byte to a card configuration register
58 * pcmcia_write_config_byte() writes a byte to a configuration register in
61 static inline int pcmcia_write_config_byte(struct pcmcia_device *p_dev, off_t where, u8 val)
63 conf_reg_t reg = { 0, CS_WRITE, where, val };
64 return pcmcia_access_configuration_register(p_dev, ®);
66 #endif /* CONFIG_COMPAT_RHEL_6_4 */
68 struct pm_qos_request_list {
73 #if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,35))
75 #define pm_qos_add_request(_req, _class, _value) do { \
76 (_req)->request = #_req; \
77 (_req)->qos = _class; \
78 pm_qos_add_requirement((_class), (_req)->request, (_value)); \
81 #define pm_qos_update_request(_req, _value) \
82 pm_qos_update_requirement((_req)->qos, (_req)->request, (_value))
84 #define pm_qos_remove_request(_req) \
85 pm_qos_remove_requirement((_req)->qos, (_req)->request)
89 #define pm_qos_add_request(_req, _class, _value) do { \
90 (_req)->request = pm_qos_add_request((_class), (_value)); \
93 #define pm_qos_update_request(_req, _value) \
94 pm_qos_update_request((_req)->request, (_value))
96 #define pm_qos_remove_request(_req) \
97 pm_qos_remove_request((_req)->request)
101 #ifdef CONFIG_COMPAT_NO_PRINTK_NEEDED
103 * Dummy printk for disabled debugging statements to use whilst maintaining
104 * gcc's format and side-effect checking.
106 static inline __attribute__ ((format (printf, 1, 2)))
107 int no_printk(const char *s, ...) { return 0; }
108 #endif /* CONFIG_COMPAT_NO_PRINTK_NEEDED */
110 #ifndef alloc_workqueue
111 #define alloc_workqueue(name, flags, max_active) __create_workqueue(name, flags, max_active, 0)
114 #define EXTPROC 0200000
115 #define TIOCPKT_IOCTL 64
117 static inline void tty_lock(void) __acquires(kernel_lock)
119 #ifdef CONFIG_LOCK_KERNEL
120 /* kernel_locked is 1 for !CONFIG_LOCK_KERNEL */
121 WARN_ON(kernel_locked());
125 static inline void tty_unlock(void) __releases(kernel_lock)
129 #define tty_locked() (kernel_locked())
131 #define usleep_range(_min, _max) msleep((_max) / 1000)
135 static inline void pm_wakeup_event(struct device *dev, unsigned int msec) {}
137 static inline bool skb_defer_rx_timestamp(struct sk_buff *skb)
142 #ifndef CONFIG_COMPAT_RHEL_6_4
143 static inline void skb_tx_timestamp(struct sk_buff *skb)
146 #endif /* CONFIG_COMPAT_RHEL_6_4 */
149 * System-wide workqueues which are always present.
151 * system_wq is the one used by schedule[_delayed]_work[_on]().
152 * Multi-CPU multi-threaded. There are users which expect relatively
153 * short queue flush time. Don't queue works which can run for too
156 * system_long_wq is similar to system_wq but may host long running
157 * works. Queue flushing might take relatively long.
159 * system_nrt_wq is non-reentrant and guarantees that any given work
160 * item is never executed in parallel by multiple CPUs. Queue
161 * flushing might take relatively long.
163 extern struct workqueue_struct *system_wq;
164 extern struct workqueue_struct *system_long_wq;
165 extern struct workqueue_struct *system_nrt_wq;
167 void compat_system_workqueue_create(void);
168 void compat_system_workqueue_destroy(void);
170 int compat_schedule_work(struct work_struct *work);
171 int compat_schedule_work_on(int cpu, struct work_struct *work);
172 int compat_schedule_delayed_work(struct delayed_work *dwork,
173 unsigned long delay);
174 int compat_schedule_delayed_work_on(int cpu,
175 struct delayed_work *dwork,
176 unsigned long delay);
177 void compat_flush_scheduled_work(void);
180 /* bit mask for work_busy() return values */
181 WORK_BUSY_PENDING = 1 << 0,
182 WORK_BUSY_RUNNING = 1 << 1,
185 extern unsigned int work_busy(struct work_struct *work);
187 #define schedule_work(work) compat_schedule_work(work)
188 #define schedule_work_on(cpu, work) compat_schedule_work_on(cpu, work)
189 #define schedule_delayed_work(dwork, delay) compat_schedule_delayed_work(dwork, delay)
190 #define schedule_delayed_work_on(cpu, dwork, delay) compat_schedule_delayed_work_on(cpu, dwork, delay)
191 #define flush_scheduled_work(a) compat_flush_scheduled_work(a)
193 #define br_port_exists(dev) (dev->br_port)
197 static inline void compat_system_workqueue_create(void)
201 static inline void compat_system_workqueue_destroy(void)
206 * This is not part of The 2.6.37 kernel yet but we
207 * we use it to optimize the backport code we
208 * need to implement. Instead of using ifdefs
209 * to check what version of the check we use
210 * we just replace all checks on current code
211 * with this. I'll submit this upstream too, that
212 * way all we'd have to do is to implement this
213 * for older kernels, then we would not have to
214 * edit the upstrema code for backport efforts.
216 #define br_port_exists(dev) (dev->priv_flags & IFF_BRIDGE_PORT)
218 #endif /* (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,36)) */
220 #endif /* LINUX_26_36_COMPAT_H */