Ignore:
Timestamp:
Jun 6, 2009, 4:22:27 AM (16 years ago)
Author:
Paul Smedley
Message:

Move functions out of config.h into appropriate linux header

File:
1 edited

Legend:

Unmodified
Added
Removed
  • GPL/trunk/alsa-kernel/include/sound/config.h

    r438 r441  
    2727#include <linux/fs.h>
    2828#include <linux/err.h>
     29#include <linux/gfp.h>
     30#include <linux/workqueue.h>
    2931#include <linux/byteorder/little_endian.h>
     32#include <linux/lockdep.h>
     33#include <linux/string.h>
    3034#include <asm/ioctl.h>
    3135#include <asm/hardirq.h>
     
    3539#include <limits.h>
    3640#include <sys/cdefs.h>
    37 
    38 #ifndef __iomem
    39 #define __iomem
    40 #endif
    41 
    42 #ifndef __deprecated
    43 # define __deprecated           /* unimplemented */
    44 #endif
     41#include <stdio.h>
    4542
    4643typedef unsigned int fmode_t;
    47 
    48 #ifndef cond_resched
    49 #define cond_resched() \
    50         do { \
    51                 if (1) { \
    52                         set_current_state(TASK_RUNNING); \
    53                         schedule(); \
    54                 } \
    55         } while (0)
    56 #endif
    5744
    5845/*
     
    6855#include <linux/version.h>
    6956
    70 #if LINUX_VERSION_CODE < KERNEL_VERSION(2, 2, 3)
    71 #error "This driver requires Linux 2.2.3 and higher."
    72 #endif
    73 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 2, 0)
    7457#define LINUX_2_2
    75 #endif
    76 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 3, 1)
    77 #define LINUX_2_3
    78 #endif
    79 #if defined(LINUX_2_3) && LINUX_VERSION_CODE < KERNEL_VERSION(2, 4, 0)
    80 #error "This code requires Linux 2.4.0-test1 and higher."
    81 #endif
    8258
    8359#ifdef ALSA_BUILD
     
    8662#include <linux/modversions.h>
    8763#include "sndversions.h"
    88 #endif
    89 #ifdef SNDRV_NO_MODVERS
    90 #undef MODVERSIONS
    91 #undef _set_ver
    9264#endif
    9365#endif /* ALSA_BUILD */
     
    12294#include <linux/poll.h>
    12395#include <linux/reboot.h>
    124 
    125 #ifdef LINUX_2_2
    126 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 2, 18)
    12796#include <linux/init.h>
    128 #endif
    12997#include "compat_22.h"
    130 #endif
    131 #ifdef LINUX_2_3
    132 #include <linux/init.h>
    133 #include <linux/pm.h>
    134 #define PCI_GET_DRIVER_DATA(pci) pci->driver_data
    135 #define PCI_SET_DRIVER_DATA(pci, data) pci->driver_data = data
    136 #if LINUX_VERSION_CODE < KERNEL_VERSION(2, 4, 3)
    137 //#define pci_set_dma_mask(pci, mask) pci->dma_mask = mask
    138 #endif
    139 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 4, 7)
    140 #define PCI_NEW_SUSPEND
    141 #endif
    142 #ifndef virt_to_page
    143 #define virt_to_page(x) (&mem_map[MAP_NR(x)])
    144 #endif
    145 #define snd_request_region request_region
    146 #ifndef rwlock_init
    147 #define rwlock_init(x) do { *(x) = RW_LOCK_UNLOCKED; } while(0)
    148 #endif
    149 #define snd_kill_fasync(fp, sig, band) kill_fasync(fp, sig, band)
    150 #if defined(__i386__) || defined(__ppc__)
    151 /*
    152  * Here a dirty hack for 2.4 kernels.. See kernel/memory.c.
    153  */
    154 #define HACK_PCI_ALLOC_CONSISTENT
    155 void *snd_pci_hack_alloc_consistent(struct pci_dev *hwdev, size_t size,
    156                                     dma_addr_t *dma_handle);
    157 #undef pci_alloc_consistent
    158 #define pci_alloc_consistent snd_pci_hack_alloc_consistent
    159 #endif /* i386 or ppc */
    160 #endif
    16198
    16299#if defined(CONFIG_ISAPNP) || (defined(CONFIG_ISAPNP_MODULE) && defined(MODULE))
     
    172109#endif
    173110
    174 #ifndef PCI_D0
    175 #define PCI_D0     0
    176 #define PCI_D1     1
    177 #define PCI_D2     2
    178 #define PCI_D3hot  3
    179 #define PCI_D3cold 4
    180 #define pci_choose_state(pci,state)     ((state) ? PCI_D3hot : PCI_D0)
    181 #endif
    182 
    183 
    184111#include <sound/asound.h>
    185112#include <sound/asoundef.h>
    186113
    187 /* wrapper for getnstimeofday()
    188  * it's needed for recent 2.6 kernels, too, due to lack of EXPORT_SYMBOL
    189  */
    190 #define getnstimeofday(x) do { \
    191         struct timeval __x; \
    192         do_gettimeofday(&__x); \
    193         (x)->tv_sec = __x.tv_sec;       \
    194         (x)->tv_nsec = __x.tv_usec * 1000; \
    195 } while (0)
    196 
    197 struct work_struct {
    198         unsigned long pending;
    199         struct list_head entry;
    200         void (*func)(void *);
    201         void *data;
    202         void *wq_data;
    203         struct timer_list timer;
    204 };
    205 
    206 struct delayed_work {
    207         struct work_struct work;
    208 };
    209 
    210 #define INIT_WORK(_work, _func, _data)                  \
    211         do {                                            \
    212                 (_work)->func = _func;                  \
    213                 (_work)->data = _data;                  \
    214                 init_timer(&(_work)->timer);            \
    215         } while (0)
    216 #define __WORK_INITIALIZER(n, f, d) {                   \
    217                 .func = (f),                            \
    218                 .data = (d),                            \
    219         }
    220 #define DECLARE_WORK(n, f, d)                           \
    221         struct work_struct n = __WORK_INITIALIZER(n, f, d)
     114
    222115int snd_compat_schedule_work(struct work_struct *work);
    223116#define schedule_work(w) snd_compat_schedule_work(w)
     
    227120/* Name change */
    228121typedef struct timeval snd_timestamp_t;
    229 #ifndef TARGET_OS2
    230 typedef enum sndrv_card_type snd_card_type;
    231 #endif
    232122typedef union sndrv_pcm_sync_id snd_pcm_sync_id_t;
    233 #ifndef TARGET_OS2
    234 typedef enum sndrv_pcm_xrun snd_pcm_xrun_t;
    235 #endif
    236 #ifdef TARGET_OS2
    237 //typedef struct snd_pcm_volume snd_pcm_volume_t;
    238 #else
    239 typedef enum sndrv_timer_global snd_timer_global_t;
    240 #endif
    241 
    242 /* redefine INIT_WORK() */
    243 static inline void snd_INIT_WORK(struct work_struct *w, void (*f)(struct work_struct *))
    244 {
    245         INIT_WORK(w, (void(*)(void*))(f), w);
    246 }
    247 #undef INIT_WORK
    248 #define INIT_WORK(w,f) snd_INIT_WORK(w,f)
    249123
    250124#ifdef CONFIG_SND_DEBUG_MEMORY
     
    257131void snd_wrapper_vfree(void *);
    258132#undef vfree
    259 #endif
    260 
    261 #if defined(__alpha__) && LINUX_VERSION_CODE < KERNEL_VERSION(2, 3, 14)
    262 #undef writeb
    263 #define writeb(v, a) do { __writeb((v),(a)); mb(); } while(0)
    264 #undef writew
    265 #define writew(v, a) do {__writew((v),(a)); mb(); } while(0)
    266 #undef writel
    267 #define writel(v, a) do {__writel((v),(a)); mb(); } while(0)
    268 #undef writeq
    269 #define writeq(v, a) do {__writeq((v),(a)); mb(); } while(0)
    270 #endif
    271 
    272 /* do we have virt_to_bus? */
    273 #if defined(CONFIG_SPARC64)
    274 #undef HAVE_VIRT_TO_BUS
    275 #else
    276 #define HAVE_VIRT_TO_BUS  1
    277133#endif
    278134
     
    314170#undef interrupt
    315171
    316 #define fops_get(x) (x)
    317 #define fops_put(x) do { ; } while (0)
    318172#define __builtin_return_address(a)     0
    319 #define SetPageReserved(a)              a
    320 #define ClearPageReserved(a)            a
    321 #define set_current_state(a)
    322 #define try_inc_mod_count(x)            ++(*(unsigned long *)x)
    323 #define try_module_get(x) try_inc_mod_count(x)
    324 static inline void module_put(struct module *module)
    325 {
    326     if (module)
    327         do {} while(0);
    328 }
    329 
    330 #define rwlock_init(x) *(x) = RW_LOCK_UNLOCKED;
    331 
    332 #define suser() 1
    333 
    334 #define snd_kill_fasync(fp, sig, band) kill_fasync(*(fp), sig, band)
    335 
    336 
    337 //what's this??
    338 #define capable(a)      1
    339 #define CAP_SYS_ADMIN   0
    340 
    341 #define BITS_PER_LONG   32
    342 
    343 #ifndef bitmap_member
    344 #define bitmap_member(name,bits) \
    345         unsigned long name[((bits)+BITS_PER_LONG-1)/BITS_PER_LONG]
    346 #endif
    347 
    348 #ifndef snd_card_set_dev
    349 #define snd_card_set_dev(card,devptr) ((card)->dev = (devptr))
    350 #endif
    351 
    352 /* for easier backward-porting */
    353 #if defined(CONFIG_GAMEPORT) || defined(CONFIG_GAMEPORT_MODULE)
    354 #ifndef gameport_set_dev_parent
    355 #define gameport_set_dev_parent(gp,xdev) ((gp)->dev.parent = (xdev))
    356 #define gameport_set_port_data(gp,r) ((gp)->port_data = (r))
    357 #define gameport_get_port_data(gp) (gp)->port_data
    358 #endif
    359 #endif
    360 
    361 /* misc.c */
    362 struct resource;
    363 void release_and_free_resource(struct resource *res);
    364 
    365 #include "typedefs.h"
    366 #define container_of(ptr, type, member) \
    367 ( (type *)( (char *)ptr - offsetof(type,member) ) )
    368 _WCRTLINK extern int     snprintf( char *__buf, size_t __bufsize,
    369                                    const char *__fmt, ... );
    370 #define offsetof(__typ,__id) ((size_t)&(((__typ*)0)->__id))
    371 #define list_for_each_entry(itemptr, headptr, struct_listmember_name, container_type) \
    372     for (itemptr=(container_type *) \
    373          (((char *)((headptr)->next))-offsetof(container_type, struct_listmember_name)); \
    374          &(itemptr->struct_listmember_name)!=(headptr); \
    375          itemptr=(container_type *) \
    376          (((char *)(itemptr->struct_listmember_name.next))-offsetof(container_type, struct_listmember_name)))
    377 
    378 #define list_for_each_entry_safe(itemptr, n, headptr, struct_listmember_name, container_type) \
    379     for (itemptr=(container_type *) \
    380          (((char *)((headptr)->next))-offsetof(container_type, struct_listmember_name)), \
    381          n=(container_type *) \
    382          (((char *)(itemptr->struct_listmember_name.next))-offsetof(container_type, struct_listmember_name)); \
    383          &(itemptr->struct_listmember_name)!=(headptr); \
    384          itemptr=n, \
    385          n=(container_type *) \
    386          (((char *)(n->struct_listmember_name.next))-offsetof(container_type, struct_listmember_name)))
    387 #define flush_scheduled_work()
    388 
    389 /* schedule_timeout_[un]interruptible() wrappers */
    390 #include <linux/sched.h>
    391 #define schedule_timeout_interruptible(x) \
    392         set_current_state(TASK_INTERRUPTIBLE); \
    393         schedule_timeout(x);
    394 
    395 #define schedule_timeout_uninterruptible(x) \
    396         set_current_state(TASK_UNINTERRUPTIBLE); \
    397         schedule_timeout(x);
    398 
    399 
    400 /* pm_message_t type */
    401 #if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 11)
    402 #include <linux/pm.h>
    403 #ifndef PMSG_FREEZE
    404 typedef u32 pm_message_t;
    405 #define PMSG_FREEZE     3
    406 #define PMSG_SUSPEND    3
    407 #define PMSG_ON         0
    408 #endif
    409 #endif
    410 
    411 #ifndef imajor
    412 #define imajor(x) major((x)->i_rdev)
    413 #endif
    414 
    415 #ifndef __nocast
    416 #define __nocast
    417 #endif
    418 
    419 typedef unsigned __nocast gfp_t;
     173#define __builtin_expect(x, expected_value) (x)
     174
    420175
    421176#ifndef CONFIG_HAVE_KZALLOC
    422177void *snd_compat_kzalloc(size_t n, gfp_t gfp_flags);
    423178#define kzalloc(s,f) snd_compat_kzalloc(s,f)
    424 
    425 #endif
    426 
    427 static inline struct proc_dir_entry *PDE(const struct inode *inode)
    428 {
    429         return (struct proc_dir_entry *) inode->u.generic_ip;
    430 }
     179#endif
    431180
    432181#ifndef CONFIG_HAVE_KSTRDUP
     
    450199#define BUG_ON(x) /* nothing */
    451200#endif
    452 #define MODULE_ALIAS_CHARDEV_MAJOR(x)
    453 typedef unsigned gfp_t;
    454 
    455 #ifndef __devexit_p
    456 #define __devexit_p(x) x
    457 #endif
    458 
    459 #define printk_ratelimit()      1
    460 #define __builtin_expect(x, expected_value) (x)
    461 #define likely(x)       __builtin_expect((x),1)
    462 #define unlikely(x)     __builtin_expect((x),0)
    463 
    464 #define smp_mb__after_clear_bit()       
     201
    465202int snd_compat_devfs_mk_dir(const char *dir, ...);
    466203#define devfs_mk_dir snd_compat_devfs_mk_dir
     
    471208#define SINGLE_DEPTH_NESTING                    1
    472209
    473 struct iovec {
    474         char    *iov_base;      /* Base address. */
    475 #ifdef __32BIT__
    476         size_t   iov_len;       /* Length. */
    477 #else
    478         long     iov_len;       /* Length. */
    479 #endif
    480 };
    481 #define SEEK_SET        0
    482 #define SEEK_CUR        1
    483 #define SEEK_END        2
    484 
    485 #ifndef IRQF_SHARED
    486 #include <linux/signal.h>
    487 #define IRQF_SHARED                     SA_SHIRQ
    488 #define IRQF_DISABLED                   SA_INTERRUPT
    489 #define IRQF_SAMPLE_RANDOM              SA_SAMPLE_RANDOM
    490 #define IRQF_PERCPU                     SA_PERCPU
    491 #ifdef SA_PROBEIRQ
    492 #define IRQF_PROBE_SHARED               SA_PROBEIRQ
    493 #else
    494 #define IRQF_PROBE_SHARED               0 /* dummy */
    495 #endif
    496 #endif /* IRQ_SHARED */
    497 
    498 #ifndef MODULE_FIRMWARE
    499 #define MODULE_FIRMWARE(x)
    500 #endif
    501 
    502 typedef irqreturn_t (*snd_irq_handler_t)(int, void *);
    503 #define irq_handler_t snd_irq_handler_t
    504 #undef irq_handler_t
    505 #define irq_handler_t snd_irq_handler_t
    506 int request_irq(unsigned int, irq_handler_t handler,
    507                     unsigned long, const char *, void *);
    508 
    509 #ifndef MODULE_ALIAS
    510 #define MODULE_ALIAS(x)
    511 #define MODULE_ALIAS_CHARDEV_MAJOR(x)
    512 #endif
    513 
    514 #ifndef cpu_relax
    515 #define cpu_relax()
    516 #endif
    517 
    518210#ifndef roundup
    519211#define roundup(x, y) ((((x) + ((y) - 1)) / (y)) * (y))
    520212#endif
    521213
    522 /*
    523  * lockdep macros
    524  */
    525 #if LINUX_VERSION_CODE <= KERNEL_VERSION(2, 6, 17)
    526 #define lockdep_set_class(lock, key)            do { (void)(key); } while (0)
    527 #define down_read_nested(sem, subclass)         down_read(sem)
    528 #define down_write_nested(sem, subclass)        down_write(sem)
    529 #define down_read_non_owner(sem)                down_read(sem)
    530 #define up_read_non_owner(sem)                  up_read(sem)
    531 #define spin_lock_nested(lock, x)               spin_lock(lock)
    532 #define spin_lock_irqsave_nested(lock, f, x)    spin_lock_irqsave(lock, f)
    533 #endif
    534214
    535215/* msleep */
     
    539219#endif
    540220
    541 #define do_posix_clock_monotonic_gettime getnstimeofday
    542 
    543 static inline unsigned char snd_pci_revision(struct pci_dev *pci)
    544 {
    545         unsigned char rev;
    546         pci_read_config_byte(pci, PCI_REVISION_ID, &rev);
    547         return rev;
    548 }
    549 
    550 #ifndef ALIGN
    551 #define ALIGN(x,a) (((x)+(a)-1)&~((a)-1))
    552 #endif
    553 
    554 /* pci_intx() wrapper */
    555 #if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 14)
    556 #ifdef CONFIG_PCI
    557 #undef pci_intx
    558 #define pci_intx(pci,x)
    559 #endif
    560 #endif
    561 
    562 /* MSI */
    563 #if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 8)
    564 static inline int snd_pci_enable_msi(struct pci_dev *dev) { return -1; }
    565 #undef pci_enable_msi
    566 #define pci_enable_msi(dev) snd_pci_enable_msi(dev)
    567 #undef pci_disable_msi
    568 #define pci_disable_msi(dev)
    569 #endif
    570 
    571 /**
    572  * list_move_tail - delete from one list and add as another's tail
    573  * @list: the entry to move
    574  * @head: the head that will follow our entry
    575  */
    576 static inline void list_move_tail(struct list_head *list,
    577                                   struct list_head *head)
    578 {
    579         __list_del(list->prev, list->next);
    580         list_add_tail(list, head);
    581 }
    582 
    583221#define assert(a)
    584 
    585 #ifndef fastcall
    586 #define fastcall
    587 #endif
    588 
    589 /* dump_stack hack */
    590 #ifndef CONFIG_HAVE_DUMP_STACK
    591 #undef dump_stack
    592 #define dump_stack()
    593 #endif
    594 
    595 #define pci_dev_present(x) snd_pci_dev_present(x)
    596 
    597 /* definitions for functions in pci_iomap_compat.c */
    598 #ifndef fastcall
    599 #define fastcall
    600 #endif
    601 
    602 unsigned int fastcall ioread8(void __iomem *addr);
    603 unsigned int fastcall ioread16(void __iomem *addr);
    604 unsigned int fastcall ioread32(void __iomem *addr);
    605 void fastcall iowrite8(u8 val, void __iomem *addr);
    606 void fastcall iowrite16(u16 val, void __iomem *addr);
    607 void fastcall iowrite32(u32 val, void __iomem *addr);
    608 void __iomem *ioport_map(unsigned long port, unsigned int nr);
    609 void ioport_unmap(void __iomem *addr);
    610 void __iomem *pci_iomap(struct pci_dev *dev, int bar, unsigned long maxlen);
    611 void pci_iounmap(struct pci_dev *dev, void __iomem * addr);
    612 
    613 #ifndef upper_32_bits
    614 #define upper_32_bits(n) ((u32)(((n) >> 16) >> 16))
    615 #endif
    616 
    617 #ifdef __SMP__
    618 #define smp_mb()        mb()
    619 #define smp_rmb()       rmb()
    620 #define smp_wmb()       wmb()
    621 #else
    622 #define smp_mb()        barrier()
    623 #define smp_rmb()       barrier()
    624 #define smp_wmb()       barrier()
    625 #endif
    626 
    627 #define GFP_DMA32 0             /* driver must check for 32-bit address */
    628 #define __GFP_COMP      0
    629 #define __GFP_NOWARN    0
    630 #define __GFP_NORETRY   0
    631 
    632 #define page_to_pfn(page)       (page_to_phys(page) >> PAGE_SHIFT)
    633 typedef __u32 __le32;
    634 
    635 /*
    636  * pci_ioremap_bar() wrapper
    637  */
    638 #ifdef CONFIG_PCI
    639 #ifndef CONFIG_HAVE_PCI_IOREMAP_BAR
    640 extern void * __ioremap(unsigned long offset, unsigned long size, unsigned long flags);
    641 #include <linux/pci.h>
    642 static inline void *pci_ioremap_bar(struct pci_dev *pdev, int bar)
    643 {
    644 #if 0
    645         return ioremap_nocache(pci_resource_start(pdev, bar),
    646                                pci_resource_len(pdev, bar));
    647 #else
    648         return __ioremap(pci_resource_start(pdev, bar),
    649                                pci_resource_len(pdev, bar),0x010);
    650 #endif
    651 }
    652 #endif
    653 #endif
    654 
    655 #ifndef DMA_BIT_MASK
    656 #define DMA_BIT_MASK(n) (((n) == 64) ? ~0ULL : ((1ULL<<(n))-1))
    657 #endif
    658222
    659223/* memdup_user() wrapper */
     
    674238#endif
    675239
    676 #if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 6)
    677 #include <linux/workqueue.h>
    678 #ifndef create_singlethread_workqueue
    679 #define create_singlethread_workqueue(name) create_workqueue(name)
    680 #endif
    681 #endif
    682 
    683240#endif //__ALSA_CONFIG_H__
     241
Note: See TracChangeset for help on using the changeset viewer.