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 #define kparam_block_sysfs_write(a)
15 #define kparam_unblock_sysfs_write(a)
17 /* mask va_format as RHEL6 backports this */
18 #define va_format compat_va_format
25 #define device_rename(dev, new_name) device_rename(dev, (char *)new_name)
27 #ifdef CONFIG_COMPAT_USB_URB_THREAD_FIX
28 #define usb_scuttle_anchored_urbs(anchor) compat_usb_scuttle_anchored_urbs(anchor)
29 #define usb_get_from_anchor(anchor) compat_usb_get_from_anchor(anchor)
30 #define usb_unlink_anchored_urbs(anchor) compat_usb_unlink_anchored_urbs(anchor)
32 extern void compat_usb_unlink_anchored_urbs(struct usb_anchor *anchor);
33 extern struct urb *compat_usb_get_from_anchor(struct usb_anchor *anchor);
34 extern void compat_usb_scuttle_anchored_urbs(struct usb_anchor *anchor);
38 * pcmcia_read_config_byte() - read a byte from a card configuration register
40 * pcmcia_read_config_byte() reads a byte from a configuration register in
43 static inline int pcmcia_read_config_byte(struct pcmcia_device *p_dev, off_t where, u8 *val)
46 conf_reg_t reg = { 0, CS_READ, where, 0 };
47 ret = pcmcia_access_configuration_register(p_dev, ®);
53 * pcmcia_write_config_byte() - write a byte to a card configuration register
55 * pcmcia_write_config_byte() writes a byte to a configuration register in
58 static inline int pcmcia_write_config_byte(struct pcmcia_device *p_dev, off_t where, u8 val)
60 conf_reg_t reg = { 0, CS_WRITE, where, val };
61 return pcmcia_access_configuration_register(p_dev, ®);
64 struct pm_qos_request_list {
69 #if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,35))
71 #define pm_qos_add_request(_req, _class, _value) do { \
72 (_req)->request = #_req; \
73 (_req)->qos = _class; \
74 pm_qos_add_requirement((_class), (_req)->request, (_value)); \
77 #define pm_qos_update_request(_req, _value) \
78 pm_qos_update_requirement((_req)->qos, (_req)->request, (_value))
80 #define pm_qos_remove_request(_req) \
81 pm_qos_remove_requirement((_req)->qos, (_req)->request)
85 #define pm_qos_add_request(_req, _class, _value) do { \
86 (_req)->request = pm_qos_add_request((_class), (_value)); \
89 #define pm_qos_update_request(_req, _value) \
90 pm_qos_update_request((_req)->request, (_value))
92 #define pm_qos_remove_request(_req) \
93 pm_qos_remove_request((_req)->request)
98 * Dummy printk for disabled debugging statements to use whilst maintaining
99 * gcc's format and side-effect checking.
101 static inline __attribute__ ((format (printf, 1, 2)))
102 int no_printk(const char *s, ...) { return 0; }
104 #ifndef alloc_workqueue
105 #define alloc_workqueue(name, flags, max_active) __create_workqueue(name, flags, max_active, 0)
108 #define EXTPROC 0200000
109 #define TIOCPKT_IOCTL 64
111 static inline void tty_lock(void) __acquires(kernel_lock)
113 #ifdef CONFIG_LOCK_KERNEL
114 /* kernel_locked is 1 for !CONFIG_LOCK_KERNEL */
115 WARN_ON(kernel_locked());
119 static inline void tty_unlock(void) __releases(kernel_lock)
123 #define tty_locked() (kernel_locked())
125 #define usleep_range(_min, _max) msleep((_max) / 1000)
129 static inline void pm_wakeup_event(struct device *dev, unsigned int msec) {}
131 static inline bool skb_defer_rx_timestamp(struct sk_buff *skb)
136 static inline void skb_tx_timestamp(struct sk_buff *skb)
141 * System-wide workqueues which are always present.
143 * system_wq is the one used by schedule[_delayed]_work[_on]().
144 * Multi-CPU multi-threaded. There are users which expect relatively
145 * short queue flush time. Don't queue works which can run for too
148 * system_long_wq is similar to system_wq but may host long running
149 * works. Queue flushing might take relatively long.
151 * system_nrt_wq is non-reentrant and guarantees that any given work
152 * item is never executed in parallel by multiple CPUs. Queue
153 * flushing might take relatively long.
155 extern struct workqueue_struct *system_wq;
156 extern struct workqueue_struct *system_long_wq;
157 extern struct workqueue_struct *system_nrt_wq;
159 void compat_system_workqueue_create(void);
160 void compat_system_workqueue_destroy(void);
162 int compat_schedule_work(struct work_struct *work);
163 int compat_schedule_work_on(int cpu, struct work_struct *work);
164 int compat_schedule_delayed_work(struct delayed_work *dwork,
165 unsigned long delay);
166 int compat_schedule_delayed_work_on(int cpu,
167 struct delayed_work *dwork,
168 unsigned long delay);
169 void compat_flush_scheduled_work(void);
172 /* bit mask for work_busy() return values */
173 WORK_BUSY_PENDING = 1 << 0,
174 WORK_BUSY_RUNNING = 1 << 1,
177 extern unsigned int work_busy(struct work_struct *work);
179 #define schedule_work(work) compat_schedule_work(work)
180 #define schedule_work_on(cpu, work) compat_schedule_work_on(cpu, work)
181 #define schedule_delayed_work(dwork, delay) compat_schedule_delayed_work(dwork, delay)
182 #define schedule_delayed_work_on(cpu, dwork, delay) compat_schedule_delayed_work_on(cpu, dwork, delay)
183 #define flush_scheduled_work(a) compat_flush_scheduled_work(a)
185 #define br_port_exists(dev) (dev->br_port)
189 static inline void compat_system_workqueue_create(void)
193 static inline void compat_system_workqueue_destroy(void)
198 * This is not part of The 2.6.37 kernel yet but we
199 * we use it to optimize the backport code we
200 * need to implement. Instead of using ifdefs
201 * to check what version of the check we use
202 * we just replace all checks on current code
203 * with this. I'll submit this upstream too, that
204 * way all we'd have to do is to implement this
205 * for older kernels, then we would not have to
206 * edit the upstrema code for backport efforts.
208 #define br_port_exists(dev) (dev->priv_flags & IFF_BRIDGE_PORT)
210 #endif /* (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,36)) */
212 #endif /* LINUX_26_36_COMPAT_H */