source: GPL/trunk/include/compat_22.h@ 587

Last change on this file since 587 was 587, checked in by David Azarewicz, 9 years ago

Rearrange directory structure
rework makefiles
cleanup files

File size: 13.0 KB
Line 
1#ifndef __COMPAT_22__
2#define __COMPAT_22__
3
4/*
5 * Missing Linux 2.2.x features
6 */
7#if LINUX_VERSION_CODE < KERNEL_VERSION(2,3,0)
8
9#ifndef CONFIG_HAVE_DMA_ADDR_T
10typedef unsigned long dma_addr_t;
11#endif
12
13/*
14 */
15
16#ifndef CONFIG_HAVE_MUTEX_MACROS
17#define init_MUTEX(x) *(x) = MUTEX
18#define DECLARE_MUTEX(x) struct semaphore x = MUTEX
19typedef struct wait_queue wait_queue_t;
20typedef struct wait_queue * wait_queue_head_t;
21#define init_waitqueue_head(x) *(x) = NULL
22#define init_waitqueue_entry(q,p) ((q)->task = (p))
23#define set_current_state(xstate) do { current->state = xstate; } while (0)
24
25/*
26 * Insert a new entry before the specified head..
27 */
28static __inline__ void list_add_tail(struct list_head *new, struct list_head *head)
29{
30 __list_add(new, head->prev, head);
31}
32
33#endif /* !CONFIG_HAVE_MUTEX_MACROS */
34
35
36#define virt_to_page(x) (&mem_map[MAP_NR(x)])
37#define get_page(p) atomic_inc(&(p)->count)
38#define SetPageReserved(p) set_bit(PG_reserved, &(p)->flags)
39#define ClearPageReserved(p) clear_bit(PG_reserved, &(p)->flags)
40#define vm_private_data vm_pte
41#define NOPAGE_OOM 0
42#define NOPAGE_SIGBUS (-1)
43#define fops_get(x) ((struct file_operations *)x)
44#define fops_put(x) do { ; } while (0)
45
46#define local_irq_save(flags) \
47 do { __save_flags(flags); __cli(); } while (0)
48#define local_irq_restore(flags) \
49 do { __restore_flags(flags); } while (0)
50
51/* Some distributions use modified kill_fasync */
52#ifdef CONFIG_OLD_KILL_FASYNC
53#define snd_kill_fasync(fp, sig, band) kill_fasync(*(fp), sig)
54#else
55#define snd_kill_fasync(fp, sig, band) kill_fasync(*(fp), sig, band)
56#endif
57
58/* this is identical with tq_struct but the "routine" field is renamed to "func" */
59struct tasklet_struct {
60 struct tasklet_struct *next; /* linked list of active bh's */
61 unsigned long sync; /* must be initialized to zero */
62 void (*func)(void *); /* function to call */
63 void *data; /* argument to function */
64};
65
66#define tasklet_schedule(t) do { \
67 queue_task((struct tq_struct *)(t), &tq_immediate);\
68 mark_bh(IMMEDIATE_BH); \
69} while (0)
70
71#define tasklet_hi_schedule(t) tasklet_schedule(t)
72
73#define tasklet_init(t,f,d) do { \
74 (t)->next = NULL; \
75 (t)->sync = 0; \
76 (t)->func = (void (*)(void *))(f); \
77 (t)->data = (void *)(d); \
78} while (0)
79
80#define tasklet_unlock_wait(t) while (test_bit(0, &(t)->sync)) { }
81#define tasklet_kill(t) tasklet_unlock_wait(t) /* FIXME: world is not perfect... */
82
83#define rwlock_init(x) do { *(x) = RW_LOCK_UNLOCKED; } while(0)
84
85#define __init
86#define __initdata
87#define __exit
88#define __exitdata
89#define __devinit
90#define __devinitdata
91#define __devexit
92#define __devexitdata
93
94#ifdef MODULE
95 #ifndef module_init
96 #define module_init(x) int init_module(void) { return x(); }
97 #define module_exit(x) void cleanup_module(void) { x(); }
98 #endif
99 #ifndef THIS_MODULE
100 #define THIS_MODULE (&__this_module)
101 #endif
102 int try_inc_mod_count(struct module *mod);
103#else
104 #define module_init(x)
105 #define module_exit(x)
106 #define THIS_MODULE NULL
107 #define try_inc_mod_count(x) do { ; } while (0)
108#endif
109
110#define try_module_get(x) try_inc_mod_count(x)
111
112static inline void module_put(struct module *module)
113{
114 if (module)
115 do {} while(0);
116}
117
118#define MODULE_GENERIC_TABLE(gtype,name)
119#define MODULE_DEVICE_TABLE(type,name)
120
121/**
122 * list_for_each - iterate over a list
123 * @pos: the &struct list_head to use as a loop counter.
124 * @head: the head for your list.
125 */
126#define list_for_each(pos, head) \
127 for (pos = (head)->next; pos != (head); pos = pos->next)
128
129/**
130 * list_for_each_safe - iterate over a list safely (actual pointer can be invalidated)
131 * @pos: the &struct list_head to use as a loop counter.
132 * @next: the &struct list_head to use to save next.
133 * @head: the head for your list.
134 */
135#define list_for_each_safe(pos, npos, head) \
136 for (pos = (head)->next, npos = pos->next ; pos != (head); pos = npos, npos = pos->next)
137
138/**
139 * list_for_each_entry - iterate over list of given type
140 * @pos: the type * to use as a loop counter.
141 * @head: the head for your list.
142 * @member: the name of the list_struct within the struct.
143 */
144#define list_for_each_entry(pos, head, member) \
145 for (pos = list_entry((head)->next, typeof(*pos), member); \
146 pos->member.next, &pos->member != (head); \
147 pos = list_entry(pos->member.next, typeof(*pos), member))
148
149#ifndef IORESOURCE_IO
150struct resource {
151 const char *name;
152 unsigned long start, end;
153 unsigned long flags;
154 struct resource *parent, *sibling, *child;
155};
156
157#define IORESOURCE_IO 0x00000100 /* Resource type */
158#define IORESOURCE_MEM 0x00000200
159#endif
160
161void snd_wrapper_request_region(unsigned long from, unsigned long extent, const char *name);
162#undef request_region
163#define request_region snd_compat_request_region
164#define release_resource snd_compat_release_resource
165#define request_mem_region(from, size, name) (&snd_compat_mem_region)
166
167extern struct resource snd_compat_mem_region;
168
169struct resource *snd_compat_request_region(unsigned long start, unsigned long size, const char *name);
170int snd_compat_release_resource(struct resource *resource);
171
172#if 0
173//#ifdef CONFIG_PCI
174
175/* New-style probing supporting hot-pluggable devices */
176
177#define PCI_PM_CTRL 4 /* PM control and status register */
178#define PCI_PM_CTRL_STATE_MASK 0x0003 /* Current power state (D0 to D3) */
179
180#define PCI_ANY_ID (~0)
181
182#define PCI_GET_DRIVER_DATA snd_pci_compat_get_driver_data
183#define PCI_SET_DRIVER_DATA snd_pci_compat_set_driver_data
184
185#define pci_set_dma_mask snd_pci_compat_set_dma_mask
186
187#define pci_enable_device snd_pci_compat_enable_device
188#define pci_register_driver snd_pci_compat_register_driver
189#define pci_unregister_driver snd_pci_compat_unregister_driver
190//#define pci_set_power_state snd_pci_compat_set_power_state
191
192#define pci_alloc_consistent snd_pci_compat_alloc_consistent
193#define pci_free_consistent snd_pci_compat_free_consistent
194#define pci_dma_supported snd_pci_compat_dma_supported
195
196#define pci_dev_g(n) list_entry(n, struct pci_dev, global_list)
197#define pci_dev_b(n) list_entry(n, struct pci_dev, bus_list)
198
199#define pci_for_each_dev(dev) \
200 for(dev = pci_devices; dev; dev = dev->next)
201
202#define pci_resource_start(dev,bar) \
203 (((dev)->base_address[(bar)] & PCI_BASE_ADDRESS_SPACE) ? \
204 ((dev)->base_address[(bar)] & PCI_BASE_ADDRESS_IO_MASK) : \
205 ((dev)->base_address[(bar)] & PCI_BASE_ADDRESS_MEM_MASK))
206#define pci_resource_end(dev,bar) \
207 (pci_resource_start(dev,bar) + snd_pci_compat_get_size((dev),(bar)))
208#define pci_resource_flags(dev,bar) (snd_pci_compat_get_flags((dev),(bar)))
209
210struct pci_device_id {
211 unsigned int vendor, device; /* Vendor and device ID or PCI_ANY_ID */
212 unsigned int subvendor, subdevice; /* Subsystem ID's or PCI_ANY_ID */
213 unsigned int class, class_mask; /* (class,subclass,prog-if) triplet */
214 unsigned long driver_data; /* Data private to the driver */
215};
216
217struct pci_driver {
218 struct list_head node;
219 struct pci_dev *dev;
220 char *name;
221 const struct pci_device_id *id_table; /* NULL if wants all devices */
222 int (*probe)(struct pci_dev *dev, const struct pci_device_id *id); /* New device inserted */
223 void (*remove)(struct pci_dev *dev); /* Device removed (NULL if not a hot-plug capable driver) */
224 int (*suspend)(struct pci_dev *dev, u32 stgate); /* Device suspended */
225 int (*resume)(struct pci_dev *dev); /* Device woken up */
226};
227
228
229/*
230 *
231 */
232const struct pci_device_id * snd_pci_compat_match_device(const struct pci_device_id *ids, struct pci_dev *dev);
233int snd_pci_compat_register_driver(struct pci_driver *drv);
234void snd_pci_compat_unregister_driver(struct pci_driver *drv);
235unsigned long snd_pci_compat_get_size (struct pci_dev *dev, int n_base);
236int snd_pci_compat_get_flags (struct pci_dev *dev, int n_base);
237int snd_pci_compat_set_power_state(struct pci_dev *dev, int new_state);
238int snd_pci_compat_enable_device(struct pci_dev *dev);
239int snd_pci_compat_find_capability(struct pci_dev *dev, int cap);
240void *snd_pci_compat_alloc_consistent(struct pci_dev *, long, dma_addr_t *);
241void snd_pci_compat_free_consistent(struct pci_dev *, long, void *, dma_addr_t);
242int snd_pci_compat_dma_supported(struct pci_dev *, dma_addr_t mask);
243unsigned long snd_pci_compat_get_dma_mask(struct pci_dev *);
244void snd_pci_compat_set_dma_mask(struct pci_dev *, unsigned long mask);
245void * snd_pci_compat_get_driver_data (struct pci_dev *dev);
246void snd_pci_compat_set_driver_data (struct pci_dev *dev, void *driver_data);
247static inline int pci_module_init(struct pci_driver *drv)
248{
249 int res = snd_pci_compat_register_driver(drv);
250 if (res < 0)
251 return res;
252 if (res == 0)
253 return -ENODEV;
254 return 0;
255}
256#endif /* CONFIG_PCI */
257
258/*
259 * Power management requests
260 */
261enum
262{
263 PM_SUSPEND, /* enter D1-D3 */
264 PM_RESUME, /* enter D0 */
265
266 /* enable wake-on */
267 PM_SET_WAKEUP,
268
269 /* bus resource management */
270 PM_GET_RESOURCES,
271 PM_SET_RESOURCES,
272
273 /* base station management */
274 PM_EJECT,
275 PM_LOCK,
276};
277
278typedef int pm_request_t;
279
280/*
281 * Device types
282 */
283enum
284{
285 PM_UNKNOWN_DEV = 0, /* generic */
286 PM_SYS_DEV, /* system device (fan, KB controller, ...) */
287 PM_PCI_DEV, /* PCI device */
288 PM_USB_DEV, /* USB device */
289 PM_SCSI_DEV, /* SCSI device */
290 PM_ISA_DEV, /* ISA device */
291};
292
293typedef int pm_dev_t;
294
295/*
296 * System device hardware ID (PnP) values
297 */
298enum
299{
300 PM_SYS_UNKNOWN = 0x00000000, /* generic */
301 PM_SYS_KBC = 0x41d00303, /* keyboard controller */
302 PM_SYS_COM = 0x41d00500, /* serial port */
303 PM_SYS_IRDA = 0x41d00510, /* IRDA controller */
304 PM_SYS_FDC = 0x41d00700, /* floppy controller */
305 PM_SYS_VGA = 0x41d00900, /* VGA controller */
306 PM_SYS_PCMCIA = 0x41d00e00, /* PCMCIA controller */
307};
308
309/*
310 * Device identifier
311 */
312#define PM_PCI_ID(dev) ((dev)->bus->number << 16 | (dev)->devfn)
313
314/*
315 * Request handler callback
316 */
317struct pm_dev;
318
319typedef int (*pm_callback)(struct pm_dev *dev, pm_request_t rqst, void *data);
320
321/*
322 * Dynamic device information
323 */
324struct pm_dev
325{
326 pm_dev_t type;
327 unsigned long id;
328 pm_callback callback;
329 void *data;
330
331 unsigned long flags;
332 int state;
333 int prev_state;
334
335 struct list_head entry;
336};
337
338#ifdef CONFIG_APM
339
340int pm_init(void);
341void pm_done(void);
342
343#define CONFIG_PM
344
345#define PM_IS_ACTIVE() 1
346
347/*
348 * Register a device with power management
349 */
350struct pm_dev *pm_register(pm_dev_t type,
351 unsigned long id,
352 pm_callback callback);
353
354/*
355 * Unregister a device with power management
356 */
357void pm_unregister(struct pm_dev *dev);
358
359/*
360 * Send a request to a single device
361 */
362int pm_send(struct pm_dev *dev, pm_request_t rqst, void *data);
363
364#else /* CONFIG_APM */
365
366#define PM_IS_ACTIVE() 0
367
368extern inline struct pm_dev *pm_register(pm_dev_t type,
369 unsigned long id,
370 pm_callback callback)
371{
372 return 0;
373}
374
375extern inline void pm_unregister(struct pm_dev *dev) {}
376
377extern inline int pm_send(struct pm_dev *dev, pm_request_t rqst, void *data)
378{
379 return 0;
380}
381
382#endif /* CONFIG_APM */
383
384#endif /* <2.3.0 */
385
386/* rw_semaphore - replaced with mutex */
387#define rw_semaphore semaphore
388#define init_rwsem(x) init_MUTEX(x)
389#define DECLARE_RWSEM(x) DECLARE_MUTEX(x)
390#define down_read(x) down(x)
391#define down_write(x) down(x)
392#define up_read(x) up(x)
393#define up_write(x) up(x)
394
395#define tasklet_unlock_wait(t) while (test_bit(0, &(t)->sync)) { }
396#define tasklet_kill(t) tasklet_unlock_wait(t) /* FIXME: world is not perfect... */
397
398#ifndef DECLARE_BITMAP
399#define DECLARE_BITMAP(name,bits) \
400 unsigned long name[((bits)+BITS_PER_LONG-1)/BITS_PER_LONG]
401#endif
402#ifndef __user
403#define __user
404#endif
405
406/**
407 * list_for_each_safe - iterate over a list safe against removal of list entry
408 * @pos: the &struct list_head to use as a loop counter.
409 * @n: another &struct list_head to use as temporary storage
410 * @head: the head for your list.
411 */
412#define list_for_each_safe(pos, n, head) \
413 for (pos = (head)->next, n = pos->next; pos != (head); \
414 pos = n, n = pos->next)
415
416/**
417 * list_del_init - deletes entry from list and reinitialize it.
418 * @entry: the element to delete from the list.
419 */
420static __inline__ void list_del_init(struct list_head *entry)
421{
422 __list_del(entry->prev, entry->next);
423 INIT_LIST_HEAD(entry);
424}
425
426#define local_irq_save(flags) \
427 { save_flags(flags); cli(); }
428#define local_irq_restore(flags) \
429 { restore_flags(flags); }
430
431#ifndef CONFIG_HAVE_PCI_CONSISTENT_DMA_MASK
432#define pci_set_consistent_dma_mask(p,x) pci_set_dma_mask(p,x)
433#endif
434
435struct completion {
436 unsigned int done;
437 wait_queue_head_t wait;
438};
439
440#if 0
441struct workqueue_struct {
442 spinlock_t lock;
443 const char *name;
444 struct list_head worklist;
445 int task_pid;
446 wait_queue_head_t more_work;
447 wait_queue_head_t work_done;
448 struct completion thread_exited;
449};
450
451struct workqueue_struct *create_workqueue(const char *name);
452int queue_work(struct workqueue_struct *wq, struct work_struct *work);
453
454void destroy_workqueue(struct workqueue_struct *wq);
455#endif
456
457#endif //__COMPAT_22__
Note: See TracBrowser for help on using the repository browser.