File: /usr/include/linux/mtd/compatmac.h

1     
2     /*
3      * mtd/include/compatmac.h
4      *
5      * $Id: compatmac.h,v 1.4 2000/07/03 10:01:38 dwmw2 Exp $
6      *
7      * Extensions and omissions from the normal 'linux/compatmac.h'
8      * files. hopefully this will end up empty as the 'real' one 
9      * becomes fully-featured.
10      */
11     
12     
13     /* First, include the parts which the kernel is good enough to provide 
14      * to us 
15      */
16        
17     #ifndef __LINUX_MTD_COMPATMAC_H__
18     #define __LINUX_MTD_COMPATMAC_H__
19     
20     #include <linux/compatmac.h>
21     #include <linux/types.h> /* used later in this header */
22     #include <linux/module.h>
23     #ifndef LINUX_VERSION_CODE
24     #include <linux/version.h>
25     #endif
26     
27     #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,1,0)
28     #include <linux/vmalloc.h>
29     #endif
30     
31     #if LINUX_VERSION_CODE < KERNEL_VERSION(2,0,0)
32     #  error "This kernel is too old: not supported by this file"
33     #endif
34     
35     /* Modularization issues */
36     #if LINUX_VERSION_CODE < KERNEL_VERSION(2,1,18)
37     #  define __USE_OLD_SYMTAB__
38     #  define EXPORT_NO_SYMBOLS register_symtab(NULL);
39     #  define REGISTER_SYMTAB(tab) register_symtab(tab)
40     #else
41     #  define REGISTER_SYMTAB(tab) /* nothing */
42     #endif
43     
44     #ifdef __USE_OLD_SYMTAB__
45     #  define __MODULE_STRING(s)         /* nothing */
46     #  define MODULE_PARM(v,t)           /* nothing */
47     #  define MODULE_PARM_DESC(v,t)      /* nothing */
48     #  define MODULE_AUTHOR(n)           /* nothing */
49     #  define MODULE_DESCRIPTION(d)      /* nothing */
50     #  define MODULE_SUPPORTED_DEVICE(n) /* nothing */
51     #endif
52     
53     /*
54      * "select" changed in 2.1.23. The implementation is twin, but this
55      * header is new
56      */
57     #if LINUX_VERSION_CODE > KERNEL_VERSION(2,1,22)
58     #  include <linux/poll.h>
59     #else
60     #  define __USE_OLD_SELECT__
61     #endif
62     
63     /* Other change in the fops are solved using pseudo-types */
64     #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,1,0)
65     #  define lseek_t      long long
66     #  define lseek_off_t  long long
67     #else
68     #  define lseek_t      int
69     #  define lseek_off_t  off_t
70     #endif
71     
72     /* changed the prototype of read/write */
73     
74     #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,1,0) || defined(__alpha__)
75     # define count_t unsigned long
76     # define read_write_t long
77     #else
78     # define count_t int
79     # define read_write_t int
80     #endif
81     
82     
83     #if LINUX_VERSION_CODE < KERNEL_VERSION(2,1,31)
84     # define release_t void
85     #  define release_return(x) return
86     #else
87     #  define release_t int
88     #  define release_return(x) return (x)
89     #endif
90     
91     #if LINUX_VERSION_CODE < 0x20300
92     #define __exit
93     #endif
94     #if LINUX_VERSION_CODE < 0x20200
95     #define __init
96     #else
97     #include <linux/init.h>
98     #endif
99     
100     #if LINUX_VERSION_CODE < 0x20300
101     #define init_MUTEX(x) do {*(x) = MUTEX;} while (0)
102     #define RQFUNC_ARG void
103     #define blkdev_dequeue_request(req) do {CURRENT = req->next;} while (0)
104     #else
105     #define RQFUNC_ARG request_queue_t *q
106     #endif
107     
108     #if LINUX_VERSION_CODE < KERNEL_VERSION(2,2,0)
109     #define __MOD_INC_USE_COUNT(mod)                                        \
110             (atomic_inc(&(mod)->uc.usecount), (mod)->flags |= MOD_VISITED|MOD_USED_ONCE)
111     #define __MOD_DEC_USE_COUNT(mod)                                        \
112             (atomic_dec(&(mod)->uc.usecount), (mod)->flags |= MOD_VISITED)
113     #endif
114     
115     
116     
117     #if LINUX_VERSION_CODE < KERNEL_VERSION(2,3,0)
118     
119     #define DECLARE_WAIT_QUEUE_HEAD(x) struct wait_queue *x = NULL
120     #define init_waitqueue_head init_waitqueue
121     
122     static inline int try_inc_mod_count(struct module *mod)
123     {
124     	if (mod)
125     		__MOD_INC_USE_COUNT(mod);
126     	return 1;
127     }
128     #endif
129     
130     
131     /* Yes, I'm aware that it's a fairly ugly hack.
132        Until the __constant_* macros appear in Linus' own kernels, this is
133        the way it has to be done.
134      DW 19/1/00
135      */
136     
137     #include <asm/byteorder.h>
138     
139     #ifndef __constant_cpu_to_le16
140     
141     #ifdef __BIG_ENDIAN
142     #define __constant_cpu_to_le64(x) ___swab64((x))
143     #define __constant_le64_to_cpu(x) ___swab64((x))
144     #define __constant_cpu_to_le32(x) ___swab32((x))
145     #define __constant_le32_to_cpu(x) ___swab32((x))
146     #define __constant_cpu_to_le16(x) ___swab16((x))
147     #define __constant_le16_to_cpu(x) ___swab16((x))
148     #define __constant_cpu_to_be64(x) ((__u64)(x))
149     #define __constant_be64_to_cpu(x) ((__u64)(x))
150     #define __constant_cpu_to_be32(x) ((__u32)(x))
151     #define __constant_be32_to_cpu(x) ((__u32)(x))
152     #define __constant_cpu_to_be16(x) ((__u16)(x))
153     #define __constant_be16_to_cpu(x) ((__u16)(x))
154     #else
155     #ifdef __LITTLE_ENDIAN
156     #define __constant_cpu_to_le64(x) ((__u64)(x))
157     #define __constant_le64_to_cpu(x) ((__u64)(x))
158     #define __constant_cpu_to_le32(x) ((__u32)(x))
159     #define __constant_le32_to_cpu(x) ((__u32)(x))
160     #define __constant_cpu_to_le16(x) ((__u16)(x))
161     #define __constant_le16_to_cpu(x) ((__u16)(x))
162     #define __constant_cpu_to_be64(x) ___swab64((x))
163     #define __constant_be64_to_cpu(x) ___swab64((x))
164     #define __constant_cpu_to_be32(x) ___swab32((x))
165     #define __constant_be32_to_cpu(x) ___swab32((x))
166     #define __constant_cpu_to_be16(x) ___swab16((x))
167     #define __constant_be16_to_cpu(x) ___swab16((x))
168     #else
169     #error No (recognised) endianness defined (unless it,s PDP)
170     #endif /* __LITTLE_ENDIAN */
171     #endif /* __BIG_ENDIAN */
172     
173     #endif /* ifndef __constant_cpu_to_le16 */
174     
175     #if LINUX_VERSION_CODE < KERNEL_VERSION(2,3,0)
176       #define mod_init_t int  __init
177       #define mod_exit_t void  
178     #else
179       #define mod_init_t static int __init
180       #define mod_exit_t static void __exit
181     #endif
182     
183     #ifndef THIS_MODULE
184     #ifdef MODULE
185     #define THIS_MODULE (&__this_module)
186     #else
187     #define THIS_MODULE (NULL)
188     #endif
189     #endif
190     
191     #if LINUX_VERSION_CODE < 0x20300
192     #include <linux/interrupt.h>
193     #define spin_lock_bh(lock) do {start_bh_atomic();spin_lock(lock);}while(0);
194     #define spin_unlock_bh(lock) do {spin_unlock(lock);end_bh_atomic();}while(0);
195     #else
196     #include <asm/softirq.h>
197     #include <linux/spinlock.h>
198     #endif
199     
200     #endif /* __LINUX_MTD_COMPATMAC_H__ */
201     
202     
203