aboutsummaryrefslogtreecommitdiffstats
path: root/include
diff options
context:
space:
mode:
Diffstat (limited to 'include')
-rw-r--r--include/asm-alpha/atomic.h12
-rw-r--r--include/asm-arm/arch-pxa/akita.h2
-rw-r--r--include/asm-arm/atomic.h42
-rw-r--r--include/asm-arm26/atomic.h29
-rw-r--r--include/asm-cris/atomic.h27
-rw-r--r--include/asm-frv/atomic.h12
-rw-r--r--include/asm-h8300/atomic.h27
-rw-r--r--include/asm-i386/atomic.h21
-rw-r--r--include/asm-i386/system.h42
-rw-r--r--include/asm-ia64/atomic.h12
-rw-r--r--include/asm-m68k/atomic.h12
-rw-r--r--include/asm-m68k/processor.h14
-rw-r--r--include/asm-m68k/thread_info.h91
-rw-r--r--include/asm-m68knommu/atomic.h12
-rw-r--r--include/asm-mips/atomic.h21
-rw-r--r--include/asm-parisc/atomic.h20
-rw-r--r--include/asm-powerpc/atomic.h27
-rw-r--r--include/asm-powerpc/kexec.h1
-rw-r--r--include/asm-powerpc/machdep.h4
-rw-r--r--include/asm-powerpc/page.h179
-rw-r--r--include/asm-powerpc/page_32.h38
-rw-r--r--include/asm-powerpc/page_64.h174
-rw-r--r--include/asm-powerpc/vdso_datapage.h2
-rw-r--r--include/asm-ppc/immap_85xx.h2
-rw-r--r--include/asm-ppc/ipic.h2
-rw-r--r--include/asm-ppc/mpc83xx.h2
-rw-r--r--include/asm-ppc/mpc85xx.h2
-rw-r--r--include/asm-ppc/ppc_sys.h2
-rw-r--r--include/asm-s390/atomic.h12
-rw-r--r--include/asm-sh/atomic.h29
-rw-r--r--include/asm-sh64/atomic.h29
-rw-r--r--include/asm-sparc/atomic.h4
-rw-r--r--include/asm-sparc64/atomic.h12
-rw-r--r--include/asm-v850/atomic.h30
-rw-r--r--include/asm-x86_64/atomic.h21
-rw-r--r--include/asm-x86_64/desc.h13
-rw-r--r--include/asm-xtensa/atomic.h20
-rw-r--r--include/linux/acct.h2
-rw-r--r--include/linux/aio.h13
-rw-r--r--include/linux/cm4000_cs.h66
-rw-r--r--include/linux/file.h10
-rw-r--r--include/linux/fsl_devices.h2
-rw-r--r--include/linux/gfp.h5
-rw-r--r--include/linux/hardirq.h2
-rw-r--r--include/linux/hugetlb.h4
-rw-r--r--include/linux/i2c-id.h1
-rw-r--r--include/linux/init_task.h1
-rw-r--r--include/linux/interrupt.h1
-rw-r--r--include/linux/mmzone.h2
-rw-r--r--include/linux/pagemap.h4
-rw-r--r--include/linux/pci_ids.h4
-rw-r--r--include/linux/percpu.h2
-rw-r--r--include/linux/pm.h49
-rw-r--r--include/linux/pm_legacy.h56
-rw-r--r--include/linux/preempt.h1
-rw-r--r--include/linux/sched.h32
-rw-r--r--include/linux/smp_lock.h3
-rw-r--r--include/linux/thread_info.h47
-rw-r--r--include/linux/time.h2
-rw-r--r--include/linux/usb.h6
-rw-r--r--include/linux/videodev2.h1
-rw-r--r--include/media/ir-common.h1
-rw-r--r--include/media/ir-kbd-i2c.h2
-rw-r--r--include/media/tuner.h1
-rw-r--r--include/media/v4l2-common.h110
65 files changed, 1216 insertions, 215 deletions
diff --git a/include/asm-alpha/atomic.h b/include/asm-alpha/atomic.h
index 20ac3d95ecd9..36505bb4e8cb 100644
--- a/include/asm-alpha/atomic.h
+++ b/include/asm-alpha/atomic.h
@@ -177,6 +177,18 @@ static __inline__ long atomic64_sub_return(long i, atomic64_t * v)
177 return result; 177 return result;
178} 178}
179 179
180#define atomic_cmpxchg(v, o, n) ((int)cmpxchg(&((v)->counter), (o), (n)))
181
182#define atomic_add_unless(v, a, u) \
183({ \
184 int c, old; \
185 c = atomic_read(v); \
186 while (c != (u) && (old = atomic_cmpxchg((v), c, c + (a))) != c) \
187 c = old; \
188 c != (u); \
189})
190#define atomic_inc_not_zero(v) atomic_add_unless((v), 1, 0)
191
180#define atomic_dec_return(v) atomic_sub_return(1,(v)) 192#define atomic_dec_return(v) atomic_sub_return(1,(v))
181#define atomic64_dec_return(v) atomic64_sub_return(1,(v)) 193#define atomic64_dec_return(v) atomic64_sub_return(1,(v))
182 194
diff --git a/include/asm-arm/arch-pxa/akita.h b/include/asm-arm/arch-pxa/akita.h
index 4a1fbcfccc39..5d8cc1d9cb10 100644
--- a/include/asm-arm/arch-pxa/akita.h
+++ b/include/asm-arm/arch-pxa/akita.h
@@ -25,6 +25,8 @@
25/* Default Values */ 25/* Default Values */
26#define AKITA_IOEXP_IO_OUT (AKITA_IOEXP_IR_ON | AKITA_IOEXP_AKIN_PULLUP) 26#define AKITA_IOEXP_IO_OUT (AKITA_IOEXP_IR_ON | AKITA_IOEXP_AKIN_PULLUP)
27 27
28extern struct platform_device akitaioexp_device;
29
28void akita_set_ioexp(struct device *dev, unsigned char bitmask); 30void akita_set_ioexp(struct device *dev, unsigned char bitmask);
29void akita_reset_ioexp(struct device *dev, unsigned char bitmask); 31void akita_reset_ioexp(struct device *dev, unsigned char bitmask);
30 32
diff --git a/include/asm-arm/atomic.h b/include/asm-arm/atomic.h
index 2885972b0855..75b802719723 100644
--- a/include/asm-arm/atomic.h
+++ b/include/asm-arm/atomic.h
@@ -80,6 +80,23 @@ static inline int atomic_sub_return(int i, atomic_t *v)
80 return result; 80 return result;
81} 81}
82 82
83static inline int atomic_cmpxchg(atomic_t *ptr, int old, int new)
84{
85 u32 oldval, res;
86
87 do {
88 __asm__ __volatile__("@ atomic_cmpxchg\n"
89 "ldrex %1, [%2]\n"
90 "teq %1, %3\n"
91 "strexeq %0, %4, [%2]\n"
92 : "=&r" (res), "=&r" (oldval)
93 : "r" (&ptr->counter), "Ir" (old), "r" (new)
94 : "cc");
95 } while (res);
96
97 return oldval;
98}
99
83static inline void atomic_clear_mask(unsigned long mask, unsigned long *addr) 100static inline void atomic_clear_mask(unsigned long mask, unsigned long *addr)
84{ 101{
85 unsigned long tmp, tmp2; 102 unsigned long tmp, tmp2;
@@ -131,6 +148,20 @@ static inline int atomic_sub_return(int i, atomic_t *v)
131 return val; 148 return val;
132} 149}
133 150
151static inline int atomic_cmpxchg(atomic_t *v, int old, int new)
152{
153 int ret;
154 unsigned long flags;
155
156 local_irq_save(flags);
157 ret = v->counter;
158 if (likely(ret == old))
159 v->counter = new;
160 local_irq_restore(flags);
161
162 return ret;
163}
164
134static inline void atomic_clear_mask(unsigned long mask, unsigned long *addr) 165static inline void atomic_clear_mask(unsigned long mask, unsigned long *addr)
135{ 166{
136 unsigned long flags; 167 unsigned long flags;
@@ -142,6 +173,17 @@ static inline void atomic_clear_mask(unsigned long mask, unsigned long *addr)
142 173
143#endif /* __LINUX_ARM_ARCH__ */ 174#endif /* __LINUX_ARM_ARCH__ */
144 175
176static inline int atomic_add_unless(atomic_t *v, int a, int u)
177{
178 int c, old;
179
180 c = atomic_read(v);
181 while (c != u && (old = atomic_cmpxchg((v), c, c + a)) != c)
182 c = old;
183 return c != u;
184}
185#define atomic_inc_not_zero(v) atomic_add_unless((v), 1, 0)
186
145#define atomic_add(i, v) (void) atomic_add_return(i, v) 187#define atomic_add(i, v) (void) atomic_add_return(i, v)
146#define atomic_inc(v) (void) atomic_add_return(1, v) 188#define atomic_inc(v) (void) atomic_add_return(1, v)
147#define atomic_sub(i, v) (void) atomic_sub_return(i, v) 189#define atomic_sub(i, v) (void) atomic_sub_return(i, v)
diff --git a/include/asm-arm26/atomic.h b/include/asm-arm26/atomic.h
index 4a88235c0e76..a47cadc59686 100644
--- a/include/asm-arm26/atomic.h
+++ b/include/asm-arm26/atomic.h
@@ -62,6 +62,35 @@ static inline int atomic_sub_return(int i, atomic_t *v)
62 return val; 62 return val;
63} 63}
64 64
65static inline int atomic_cmpxchg(atomic_t *v, int old, int new)
66{
67 int ret;
68 unsigned long flags;
69
70 local_irq_save(flags);
71 ret = v->counter;
72 if (likely(ret == old))
73 v->counter = new;
74 local_irq_restore(flags);
75
76 return ret;
77}
78
79static inline int atomic_add_unless(atomic_t *v, int a, int u)
80{
81 int ret;
82 unsigned long flags;
83
84 local_irq_save(flags);
85 ret = v->counter;
86 if (ret != u)
87 v->counter += a;
88 local_irq_restore(flags);
89
90 return ret != u;
91}
92#define atomic_inc_not_zero(v) atomic_add_unless((v), 1, 0)
93
65static inline void atomic_clear_mask(unsigned long mask, unsigned long *addr) 94static inline void atomic_clear_mask(unsigned long mask, unsigned long *addr)
66{ 95{
67 unsigned long flags; 96 unsigned long flags;
diff --git a/include/asm-cris/atomic.h b/include/asm-cris/atomic.h
index 8c2e78304523..683b05a57d88 100644
--- a/include/asm-cris/atomic.h
+++ b/include/asm-cris/atomic.h
@@ -123,6 +123,33 @@ static inline int atomic_inc_and_test(volatile atomic_t *v)
123 return retval; 123 return retval;
124} 124}
125 125
126static inline int atomic_cmpxchg(atomic_t *v, int old, int new)
127{
128 int ret;
129 unsigned long flags;
130
131 cris_atomic_save(v, flags);
132 ret = v->counter;
133 if (likely(ret == old))
134 v->counter = new;
135 cris_atomic_restore(v, flags);
136 return ret;
137}
138
139static inline int atomic_add_unless(atomic_t *v, int a, int u)
140{
141 int ret;
142 unsigned long flags;
143
144 cris_atomic_save(v, flags);
145 ret = v->counter;
146 if (ret != u)
147 v->counter += a;
148 cris_atomic_restore(v, flags);
149 return ret != u;
150}
151#define atomic_inc_not_zero(v) atomic_add_unless((v), 1, 0)
152
126/* Atomic operations are already serializing */ 153/* Atomic operations are already serializing */
127#define smp_mb__before_atomic_dec() barrier() 154#define smp_mb__before_atomic_dec() barrier()
128#define smp_mb__after_atomic_dec() barrier() 155#define smp_mb__after_atomic_dec() barrier()
diff --git a/include/asm-frv/atomic.h b/include/asm-frv/atomic.h
index e75968463428..f6539ff569c5 100644
--- a/include/asm-frv/atomic.h
+++ b/include/asm-frv/atomic.h
@@ -414,4 +414,16 @@ extern uint32_t __cmpxchg_32(uint32_t *v, uint32_t test, uint32_t new);
414 414
415#endif 415#endif
416 416
417#define atomic_cmpxchg(v, old, new) ((int)cmpxchg(&((v)->counter), old, new))
418
419#define atomic_add_unless(v, a, u) \
420({ \
421 int c, old; \
422 c = atomic_read(v); \
423 while (c != (u) && (old = atomic_cmpxchg((v), c, c + (a))) != c) \
424 c = old; \
425 c != (u); \
426})
427#define atomic_inc_not_zero(v) atomic_add_unless((v), 1, 0)
428
417#endif /* _ASM_ATOMIC_H */ 429#endif /* _ASM_ATOMIC_H */
diff --git a/include/asm-h8300/atomic.h b/include/asm-h8300/atomic.h
index 7230f6507995..f23d86819ea8 100644
--- a/include/asm-h8300/atomic.h
+++ b/include/asm-h8300/atomic.h
@@ -82,6 +82,33 @@ static __inline__ int atomic_dec_and_test(atomic_t *v)
82 return ret == 0; 82 return ret == 0;
83} 83}
84 84
85static inline int atomic_cmpxchg(atomic_t *v, int old, int new)
86{
87 int ret;
88 unsigned long flags;
89
90 local_irq_save(flags);
91 ret = v->counter;
92 if (likely(ret == old))
93 v->counter = new;
94 local_irq_restore(flags);
95 return ret;
96}
97
98static inline int atomic_add_unless(atomic_t *v, int a, int u)
99{
100 int ret;
101 unsigned long flags;
102
103 local_irq_save(flags);
104 ret = v->counter;
105 if (ret != u)
106 v->counter += a;
107 local_irq_restore(flags);
108 return ret != u;
109}
110#define atomic_inc_not_zero(v) atomic_add_unless((v), 1, 0)
111
85static __inline__ void atomic_clear_mask(unsigned long mask, unsigned long *v) 112static __inline__ void atomic_clear_mask(unsigned long mask, unsigned long *v)
86{ 113{
87 __asm__ __volatile__("stc ccr,r1l\n\t" 114 __asm__ __volatile__("stc ccr,r1l\n\t"
diff --git a/include/asm-i386/atomic.h b/include/asm-i386/atomic.h
index 509720be772a..c68557aa04b2 100644
--- a/include/asm-i386/atomic.h
+++ b/include/asm-i386/atomic.h
@@ -215,6 +215,27 @@ static __inline__ int atomic_sub_return(int i, atomic_t *v)
215 return atomic_add_return(-i,v); 215 return atomic_add_return(-i,v);
216} 216}
217 217
218#define atomic_cmpxchg(v, old, new) ((int)cmpxchg(&((v)->counter), old, new))
219
220/**
221 * atomic_add_unless - add unless the number is a given value
222 * @v: pointer of type atomic_t
223 * @a: the amount to add to v...
224 * @u: ...unless v is equal to u.
225 *
226 * Atomically adds @a to @v, so long as it was not @u.
227 * Returns non-zero if @v was not @u, and zero otherwise.
228 */
229#define atomic_add_unless(v, a, u) \
230({ \
231 int c, old; \
232 c = atomic_read(v); \
233 while (c != (u) && (old = atomic_cmpxchg((v), c, c + (a))) != c) \
234 c = old; \
235 c != (u); \
236})
237#define atomic_inc_not_zero(v) atomic_add_unless((v), 1, 0)
238
218#define atomic_inc_return(v) (atomic_add_return(1,v)) 239#define atomic_inc_return(v) (atomic_add_return(1,v))
219#define atomic_dec_return(v) (atomic_sub_return(1,v)) 240#define atomic_dec_return(v) (atomic_sub_return(1,v))
220 241
diff --git a/include/asm-i386/system.h b/include/asm-i386/system.h
index 97d52ac49e46..772f85da1206 100644
--- a/include/asm-i386/system.h
+++ b/include/asm-i386/system.h
@@ -263,6 +263,10 @@ static inline unsigned long __xchg(unsigned long x, volatile void * ptr, int siz
263 263
264#ifdef CONFIG_X86_CMPXCHG 264#ifdef CONFIG_X86_CMPXCHG
265#define __HAVE_ARCH_CMPXCHG 1 265#define __HAVE_ARCH_CMPXCHG 1
266#define cmpxchg(ptr,o,n)\
267 ((__typeof__(*(ptr)))__cmpxchg((ptr),(unsigned long)(o),\
268 (unsigned long)(n),sizeof(*(ptr))))
269#endif
266 270
267static inline unsigned long __cmpxchg(volatile void *ptr, unsigned long old, 271static inline unsigned long __cmpxchg(volatile void *ptr, unsigned long old,
268 unsigned long new, int size) 272 unsigned long new, int size)
@@ -291,10 +295,42 @@ static inline unsigned long __cmpxchg(volatile void *ptr, unsigned long old,
291 return old; 295 return old;
292} 296}
293 297
294#define cmpxchg(ptr,o,n)\ 298#ifndef CONFIG_X86_CMPXCHG
295 ((__typeof__(*(ptr)))__cmpxchg((ptr),(unsigned long)(o),\ 299/*
296 (unsigned long)(n),sizeof(*(ptr)))) 300 * Building a kernel capable running on 80386. It may be necessary to
301 * simulate the cmpxchg on the 80386 CPU. For that purpose we define
302 * a function for each of the sizes we support.
303 */
297 304
305extern unsigned long cmpxchg_386_u8(volatile void *, u8, u8);
306extern unsigned long cmpxchg_386_u16(volatile void *, u16, u16);
307extern unsigned long cmpxchg_386_u32(volatile void *, u32, u32);
308
309static inline unsigned long cmpxchg_386(volatile void *ptr, unsigned long old,
310 unsigned long new, int size)
311{
312 switch (size) {
313 case 1:
314 return cmpxchg_386_u8(ptr, old, new);
315 case 2:
316 return cmpxchg_386_u16(ptr, old, new);
317 case 4:
318 return cmpxchg_386_u32(ptr, old, new);
319 }
320 return old;
321}
322
323#define cmpxchg(ptr,o,n) \
324({ \
325 __typeof__(*(ptr)) __ret; \
326 if (likely(boot_cpu_data.x86 > 3)) \
327 __ret = __cmpxchg((ptr), (unsigned long)(o), \
328 (unsigned long)(n), sizeof(*(ptr))); \
329 else \
330 __ret = cmpxchg_386((ptr), (unsigned long)(o), \
331 (unsigned long)(n), sizeof(*(ptr))); \
332 __ret; \
333})
298#endif 334#endif
299 335
300#ifdef CONFIG_X86_CMPXCHG64 336#ifdef CONFIG_X86_CMPXCHG64
diff --git a/include/asm-ia64/atomic.h b/include/asm-ia64/atomic.h
index 874a6f890e75..2fbebf85c31d 100644
--- a/include/asm-ia64/atomic.h
+++ b/include/asm-ia64/atomic.h
@@ -88,6 +88,18 @@ ia64_atomic64_sub (__s64 i, atomic64_t *v)
88 return new; 88 return new;
89} 89}
90 90
91#define atomic_cmpxchg(v, old, new) ((int)cmpxchg(&((v)->counter), old, new))
92
93#define atomic_add_unless(v, a, u) \
94({ \
95 int c, old; \
96 c = atomic_read(v); \
97 while (c != (u) && (old = atomic_cmpxchg((v), c, c + (a))) != c) \
98 c = old; \
99 c != (u); \
100})
101#define atomic_inc_not_zero(v) atomic_add_unless((v), 1, 0)
102
91#define atomic_add_return(i,v) \ 103#define atomic_add_return(i,v) \
92({ \ 104({ \
93 int __ia64_aar_i = (i); \ 105 int __ia64_aar_i = (i); \
diff --git a/include/asm-m68k/atomic.h b/include/asm-m68k/atomic.h
index 38f3043e7fe1..e3c962eeabf3 100644
--- a/include/asm-m68k/atomic.h
+++ b/include/asm-m68k/atomic.h
@@ -139,6 +139,18 @@ static inline void atomic_set_mask(unsigned long mask, unsigned long *v)
139 __asm__ __volatile__("orl %1,%0" : "+m" (*v) : "id" (mask)); 139 __asm__ __volatile__("orl %1,%0" : "+m" (*v) : "id" (mask));
140} 140}
141 141
142#define atomic_cmpxchg(v, o, n) ((int)cmpxchg(&((v)->counter), (o), (n)))
143
144#define atomic_add_unless(v, a, u) \
145({ \
146 int c, old; \
147 c = atomic_read(v); \
148 while (c != (u) && (old = atomic_cmpxchg((v), c, c + (a))) != c) \
149 c = old; \
150 c != (u); \
151})
152#define atomic_inc_not_zero(v) atomic_add_unless((v), 1, 0)
153
142/* Atomic operations are already serializing */ 154/* Atomic operations are already serializing */
143#define smp_mb__before_atomic_dec() barrier() 155#define smp_mb__before_atomic_dec() barrier()
144#define smp_mb__after_atomic_dec() barrier() 156#define smp_mb__after_atomic_dec() barrier()
diff --git a/include/asm-m68k/processor.h b/include/asm-m68k/processor.h
index df1575db32af..7982285e84ed 100644
--- a/include/asm-m68k/processor.h
+++ b/include/asm-m68k/processor.h
@@ -14,6 +14,7 @@
14#define current_text_addr() ({ __label__ _l; _l: &&_l;}) 14#define current_text_addr() ({ __label__ _l; _l: &&_l;})
15 15
16#include <linux/config.h> 16#include <linux/config.h>
17#include <linux/thread_info.h>
17#include <asm/segment.h> 18#include <asm/segment.h>
18#include <asm/fpu.h> 19#include <asm/fpu.h>
19#include <asm/ptrace.h> 20#include <asm/ptrace.h>
@@ -55,17 +56,6 @@ static inline void wrusp(unsigned long usp)
55#endif 56#endif
56#define TASK_UNMAPPED_ALIGN(addr, off) PAGE_ALIGN(addr) 57#define TASK_UNMAPPED_ALIGN(addr, off) PAGE_ALIGN(addr)
57 58
58struct task_work {
59 unsigned char sigpending;
60 unsigned char notify_resume; /* request for notification on
61 userspace execution resumption */
62 char need_resched;
63 unsigned char delayed_trace; /* single step a syscall */
64 unsigned char syscall_trace; /* count of syscall interceptors */
65 unsigned char memdie; /* task was selected to be killed */
66 unsigned char pad[2];
67};
68
69struct thread_struct { 59struct thread_struct {
70 unsigned long ksp; /* kernel stack pointer */ 60 unsigned long ksp; /* kernel stack pointer */
71 unsigned long usp; /* user stack pointer */ 61 unsigned long usp; /* user stack pointer */
@@ -78,7 +68,7 @@ struct thread_struct {
78 unsigned long fp[8*3]; 68 unsigned long fp[8*3];
79 unsigned long fpcntl[3]; /* fp control regs */ 69 unsigned long fpcntl[3]; /* fp control regs */
80 unsigned char fpstate[FPSTATESIZE]; /* floating point state */ 70 unsigned char fpstate[FPSTATESIZE]; /* floating point state */
81 struct task_work work; 71 struct thread_info info;
82}; 72};
83 73
84#define INIT_THREAD { \ 74#define INIT_THREAD { \
diff --git a/include/asm-m68k/thread_info.h b/include/asm-m68k/thread_info.h
index 2aed24f6fd2e..9532ca3c45cb 100644
--- a/include/asm-m68k/thread_info.h
+++ b/include/asm-m68k/thread_info.h
@@ -2,17 +2,15 @@
2#define _ASM_M68K_THREAD_INFO_H 2#define _ASM_M68K_THREAD_INFO_H
3 3
4#include <asm/types.h> 4#include <asm/types.h>
5#include <asm/processor.h>
6#include <asm/page.h> 5#include <asm/page.h>
7 6
8struct thread_info { 7struct thread_info {
9 struct task_struct *task; /* main task structure */ 8 struct task_struct *task; /* main task structure */
9 unsigned long flags;
10 struct exec_domain *exec_domain; /* execution domain */ 10 struct exec_domain *exec_domain; /* execution domain */
11 int preempt_count; /* 0 => preemptable, <0 => BUG */ 11 int preempt_count; /* 0 => preemptable, <0 => BUG */
12 __u32 cpu; /* should always be 0 on m68k */ 12 __u32 cpu; /* should always be 0 on m68k */
13 struct restart_block restart_block; 13 struct restart_block restart_block;
14
15 __u8 supervisor_stack[0];
16}; 14};
17 15
18#define PREEMPT_ACTIVE 0x4000000 16#define PREEMPT_ACTIVE 0x4000000
@@ -35,84 +33,29 @@ struct thread_info {
35#define free_thread_info(ti) free_pages((unsigned long)(ti),1) 33#define free_thread_info(ti) free_pages((unsigned long)(ti),1)
36#endif /* PAGE_SHIFT == 13 */ 34#endif /* PAGE_SHIFT == 13 */
37 35
38//#define init_thread_info (init_task.thread.info) 36#define init_thread_info (init_task.thread.info)
39#define init_stack (init_thread_union.stack) 37#define init_stack (init_thread_union.stack)
40 38
41#define current_thread_info() (current->thread_info) 39#define task_thread_info(tsk) (&(tsk)->thread.info)
42 40#define current_thread_info() task_thread_info(current)
43 41
44#define __HAVE_THREAD_FUNCTIONS 42#define __HAVE_THREAD_FUNCTIONS
45 43
46#define TIF_SYSCALL_TRACE 0 /* syscall trace active */ 44#define setup_thread_stack(p, org) ({ \
47#define TIF_DELAYED_TRACE 1 /* single step a syscall */ 45 *(struct task_struct **)(p)->thread_info = (p); \
48#define TIF_NOTIFY_RESUME 2 /* resumption notification requested */ 46 task_thread_info(p)->task = (p); \
49#define TIF_SIGPENDING 3 /* signal pending */
50#define TIF_NEED_RESCHED 4 /* rescheduling necessary */
51#define TIF_MEMDIE 5
52
53extern int thread_flag_fixme(void);
54
55/*
56 * flag set/clear/test wrappers
57 * - pass TIF_xxxx constants to these functions
58 */
59
60#define __set_tsk_thread_flag(tsk, flag, val) ({ \
61 switch (flag) { \
62 case TIF_SIGPENDING: \
63 tsk->thread.work.sigpending = val; \
64 break; \
65 case TIF_NEED_RESCHED: \
66 tsk->thread.work.need_resched = val; \
67 break; \
68 case TIF_SYSCALL_TRACE: \
69 tsk->thread.work.syscall_trace = val; \
70 break; \
71 case TIF_MEMDIE: \
72 tsk->thread.work.memdie = val; \
73 break; \
74 default: \
75 thread_flag_fixme(); \
76 } \
77}) 47})
78 48
79#define __get_tsk_thread_flag(tsk, flag) ({ \ 49#define end_of_stack(p) ((unsigned long *)(p)->thread_info + 1)
80 int ___res; \
81 switch (flag) { \
82 case TIF_SIGPENDING: \
83 ___res = tsk->thread.work.sigpending; \
84 break; \
85 case TIF_NEED_RESCHED: \
86 ___res = tsk->thread.work.need_resched; \
87 break; \
88 case TIF_SYSCALL_TRACE: \
89 ___res = tsk->thread.work.syscall_trace;\
90 break; \
91 case TIF_MEMDIE: \
92 ___res = tsk->thread.work.memdie;\
93 break; \
94 default: \
95 ___res = thread_flag_fixme(); \
96 } \
97 ___res; \
98})
99
100#define __get_set_tsk_thread_flag(tsk, flag, val) ({ \
101 int __res = __get_tsk_thread_flag(tsk, flag); \
102 __set_tsk_thread_flag(tsk, flag, val); \
103 __res; \
104})
105 50
106#define set_tsk_thread_flag(tsk, flag) __set_tsk_thread_flag(tsk, flag, ~0) 51/* entry.S relies on these definitions!
107#define clear_tsk_thread_flag(tsk, flag) __set_tsk_thread_flag(tsk, flag, 0) 52 * bits 0-7 are tested at every exception exit
108#define test_and_set_tsk_thread_flag(tsk, flag) __get_set_tsk_thread_flag(tsk, flag, ~0) 53 * bits 8-15 are also tested at syscall exit
109#define test_tsk_thread_flag(tsk, flag) __get_tsk_thread_flag(tsk, flag) 54 */
110 55#define TIF_SIGPENDING 6 /* signal pending */
111#define set_thread_flag(flag) set_tsk_thread_flag(current, flag) 56#define TIF_NEED_RESCHED 7 /* rescheduling necessary */
112#define clear_thread_flag(flag) clear_tsk_thread_flag(current, flag) 57#define TIF_DELAYED_TRACE 14 /* single step a syscall */
113#define test_thread_flag(flag) test_tsk_thread_flag(current, flag) 58#define TIF_SYSCALL_TRACE 15 /* syscall trace active */
114 59#define TIF_MEMDIE 16
115#define set_need_resched() set_thread_flag(TIF_NEED_RESCHED)
116#define clear_need_resched() clear_thread_flag(TIF_NEED_RESCHED)
117 60
118#endif /* _ASM_M68K_THREAD_INFO_H */ 61#endif /* _ASM_M68K_THREAD_INFO_H */
diff --git a/include/asm-m68knommu/atomic.h b/include/asm-m68knommu/atomic.h
index a83631ed8c8f..3c1cc153c415 100644
--- a/include/asm-m68knommu/atomic.h
+++ b/include/asm-m68knommu/atomic.h
@@ -128,6 +128,18 @@ static inline int atomic_sub_return(int i, atomic_t * v)
128 return temp; 128 return temp;
129} 129}
130 130
131#define atomic_cmpxchg(v, o, n) ((int)cmpxchg(&((v)->counter), (o), (n)))
132
133#define atomic_add_unless(v, a, u) \
134({ \
135 int c, old; \
136 c = atomic_read(v); \
137 while (c != (u) && (old = atomic_cmpxchg((v), c, c + (a))) != c) \
138 c = old; \
139 c != (u); \
140})
141#define atomic_inc_not_zero(v) atomic_add_unless((v), 1, 0)
142
131#define atomic_dec_return(v) atomic_sub_return(1,(v)) 143#define atomic_dec_return(v) atomic_sub_return(1,(v))
132#define atomic_inc_return(v) atomic_add_return(1,(v)) 144#define atomic_inc_return(v) atomic_add_return(1,(v))
133 145
diff --git a/include/asm-mips/atomic.h b/include/asm-mips/atomic.h
index 6202eb8a14b7..2c87b41e69ba 100644
--- a/include/asm-mips/atomic.h
+++ b/include/asm-mips/atomic.h
@@ -287,6 +287,27 @@ static __inline__ int atomic_sub_if_positive(int i, atomic_t * v)
287 return result; 287 return result;
288} 288}
289 289
290#define atomic_cmpxchg(v, o, n) ((int)cmpxchg(&((v)->counter), (o), (n)))
291
292/**
293 * atomic_add_unless - add unless the number is a given value
294 * @v: pointer of type atomic_t
295 * @a: the amount to add to v...
296 * @u: ...unless v is equal to u.
297 *
298 * Atomically adds @a to @v, so long as it was not @u.
299 * Returns non-zero if @v was not @u, and zero otherwise.
300 */
301#define atomic_add_unless(v, a, u) \
302({ \
303 int c, old; \
304 c = atomic_read(v); \
305 while (c != (u) && (old = atomic_cmpxchg((v), c, c + (a))) != c) \
306 c = old; \
307 c != (u); \
308})
309#define atomic_inc_not_zero(v) atomic_add_unless((v), 1, 0)
310
290#define atomic_dec_return(v) atomic_sub_return(1,(v)) 311#define atomic_dec_return(v) atomic_sub_return(1,(v))
291#define atomic_inc_return(v) atomic_add_return(1,(v)) 312#define atomic_inc_return(v) atomic_add_return(1,(v))
292 313
diff --git a/include/asm-parisc/atomic.h b/include/asm-parisc/atomic.h
index 048a2c7fd0c0..983e9a2b6042 100644
--- a/include/asm-parisc/atomic.h
+++ b/include/asm-parisc/atomic.h
@@ -164,6 +164,26 @@ static __inline__ int atomic_read(const atomic_t *v)
164} 164}
165 165
166/* exported interface */ 166/* exported interface */
167#define atomic_cmpxchg(v, o, n) ((int)cmpxchg(&((v)->counter), (o), (n)))
168
169/**
170 * atomic_add_unless - add unless the number is a given value
171 * @v: pointer of type atomic_t
172 * @a: the amount to add to v...
173 * @u: ...unless v is equal to u.
174 *
175 * Atomically adds @a to @v, so long as it was not @u.
176 * Returns non-zero if @v was not @u, and zero otherwise.
177 */
178#define atomic_add_unless(v, a, u) \
179({ \
180 int c, old; \
181 c = atomic_read(v); \
182 while (c != (u) && (old = atomic_cmpxchg((v), c, c + (a))) != c) \
183 c = old; \
184 c != (u); \
185})
186#define atomic_inc_not_zero(v) atomic_add_unless((v), 1, 0)
167 187
168#define atomic_add(i,v) ((void)(__atomic_add_return( ((int)i),(v)))) 188#define atomic_add(i,v) ((void)(__atomic_add_return( ((int)i),(v))))
169#define atomic_sub(i,v) ((void)(__atomic_add_return(-((int)i),(v)))) 189#define atomic_sub(i,v) ((void)(__atomic_add_return(-((int)i),(v))))
diff --git a/include/asm-powerpc/atomic.h b/include/asm-powerpc/atomic.h
index 9c0b372a46e1..ec4b14468959 100644
--- a/include/asm-powerpc/atomic.h
+++ b/include/asm-powerpc/atomic.h
@@ -164,6 +164,33 @@ static __inline__ int atomic_dec_return(atomic_t *v)
164 return t; 164 return t;
165} 165}
166 166
167#define atomic_cmpxchg(v, o, n) ((int)cmpxchg(&((v)->counter), (o), (n)))
168
169/**
170 * atomic_add_unless - add unless the number is a given value
171 * @v: pointer of type atomic_t
172 * @a: the amount to add to v...
173 * @u: ...unless v is equal to u.
174 *
175 * Atomically adds @a to @v, so long as it was not @u.
176 * Returns non-zero if @v was not @u, and zero otherwise.
177 */
178#define atomic_add_unless(v, a, u) \
179({ \
180 int c, old; \
181 c = atomic_read(v); \
182 for (;;) { \
183 if (unlikely(c == (u))) \
184 break; \
185 old = atomic_cmpxchg((v), c, c + (a)); \
186 if (likely(old == c)) \
187 break; \
188 c = old; \
189 } \
190 c != (u); \
191})
192#define atomic_inc_not_zero(v) atomic_add_unless((v), 1, 0)
193
167#define atomic_sub_and_test(a, v) (atomic_sub_return((a), (v)) == 0) 194#define atomic_sub_and_test(a, v) (atomic_sub_return((a), (v)) == 0)
168#define atomic_dec_and_test(v) (atomic_dec_return((v)) == 0) 195#define atomic_dec_and_test(v) (atomic_dec_return((v)) == 0)
169 196
diff --git a/include/asm-powerpc/kexec.h b/include/asm-powerpc/kexec.h
index 062ab9ba68eb..c72ffc709ea8 100644
--- a/include/asm-powerpc/kexec.h
+++ b/include/asm-powerpc/kexec.h
@@ -40,6 +40,7 @@ extern note_buf_t crash_notes[];
40#ifdef __powerpc64__ 40#ifdef __powerpc64__
41extern void kexec_smp_wait(void); /* get and clear naca physid, wait for 41extern void kexec_smp_wait(void); /* get and clear naca physid, wait for
42 master to copy new code to 0 */ 42 master to copy new code to 0 */
43extern void __init kexec_setup(void);
43#else 44#else
44struct kimage; 45struct kimage;
45extern void machine_kexec_simple(struct kimage *image); 46extern void machine_kexec_simple(struct kimage *image);
diff --git a/include/asm-powerpc/machdep.h b/include/asm-powerpc/machdep.h
index 5670f0cd6143..c011abb8b600 100644
--- a/include/asm-powerpc/machdep.h
+++ b/include/asm-powerpc/machdep.h
@@ -93,7 +93,9 @@ struct machdep_calls {
93 93
94 void (*init_IRQ)(void); 94 void (*init_IRQ)(void);
95 int (*get_irq)(struct pt_regs *); 95 int (*get_irq)(struct pt_regs *);
96 void (*cpu_irq_down)(int secondary); 96#ifdef CONFIG_KEXEC
97 void (*kexec_cpu_down)(int crash_shutdown, int secondary);
98#endif
97 99
98 /* PCI stuff */ 100 /* PCI stuff */
99 /* Called after scanning the bus, before allocating resources */ 101 /* Called after scanning the bus, before allocating resources */
diff --git a/include/asm-powerpc/page.h b/include/asm-powerpc/page.h
new file mode 100644
index 000000000000..18c1e5ee81a3
--- /dev/null
+++ b/include/asm-powerpc/page.h
@@ -0,0 +1,179 @@
1#ifndef _ASM_POWERPC_PAGE_H
2#define _ASM_POWERPC_PAGE_H
3
4/*
5 * Copyright (C) 2001,2005 IBM Corporation.
6 *
7 * This program is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU General Public License
9 * as published by the Free Software Foundation; either version
10 * 2 of the License, or (at your option) any later version.
11 */
12
13#ifdef __KERNEL__
14#include <linux/config.h>
15#include <asm/asm-compat.h>
16
17/*
18 * On PPC32 page size is 4K. For PPC64 we support either 4K or 64K software
19 * page size. When using 64K pages however, whether we are really supporting
20 * 64K pages in HW or not is irrelevant to those definitions.
21 */
22#ifdef CONFIG_PPC_64K_PAGES
23#define PAGE_SHIFT 16
24#else
25#define PAGE_SHIFT 12
26#endif
27
28#define PAGE_SIZE (ASM_CONST(1) << PAGE_SHIFT)
29
30/* We do define AT_SYSINFO_EHDR but don't use the gate mechanism */
31#define __HAVE_ARCH_GATE_AREA 1
32
33/*
34 * Subtle: (1 << PAGE_SHIFT) is an int, not an unsigned long. So if we
35 * assign PAGE_MASK to a larger type it gets extended the way we want
36 * (i.e. with 1s in the high bits)
37 */
38#define PAGE_MASK (~((1 << PAGE_SHIFT) - 1))
39
40#define PAGE_OFFSET ASM_CONST(CONFIG_KERNEL_START)
41#define KERNELBASE PAGE_OFFSET
42
43#ifdef CONFIG_DISCONTIGMEM
44#define page_to_pfn(page) discontigmem_page_to_pfn(page)
45#define pfn_to_page(pfn) discontigmem_pfn_to_page(pfn)
46#define pfn_valid(pfn) discontigmem_pfn_valid(pfn)
47#endif
48
49#ifdef CONFIG_FLATMEM
50#define pfn_to_page(pfn) (mem_map + (pfn))
51#define page_to_pfn(page) ((unsigned long)((page) - mem_map))
52#define pfn_valid(pfn) ((pfn) < max_mapnr)
53#endif
54
55#define virt_to_page(kaddr) pfn_to_page(__pa(kaddr) >> PAGE_SHIFT)
56#define pfn_to_kaddr(pfn) __va((pfn) << PAGE_SHIFT)
57#define virt_addr_valid(kaddr) pfn_valid(__pa(kaddr) >> PAGE_SHIFT)
58
59#define __va(x) ((void *)((unsigned long)(x) + KERNELBASE))
60#define __pa(x) ((unsigned long)(x) - PAGE_OFFSET)
61
62/*
63 * Unfortunately the PLT is in the BSS in the PPC32 ELF ABI,
64 * and needs to be executable. This means the whole heap ends
65 * up being executable.
66 */
67#define VM_DATA_DEFAULT_FLAGS32 (VM_READ | VM_WRITE | VM_EXEC | \
68 VM_MAYREAD | VM_MAYWRITE | VM_MAYEXEC)
69
70#define VM_DATA_DEFAULT_FLAGS64 (VM_READ | VM_WRITE | \
71 VM_MAYREAD | VM_MAYWRITE | VM_MAYEXEC)
72
73#ifdef __powerpc64__
74#include <asm/page_64.h>
75#else
76#include <asm/page_32.h>
77#endif
78
79/* align addr on a size boundary - adjust address up/down if needed */
80#define _ALIGN_UP(addr,size) (((addr)+((size)-1))&(~((size)-1)))
81#define _ALIGN_DOWN(addr,size) ((addr)&(~((size)-1)))
82
83/* align addr on a size boundary - adjust address up if needed */
84#define _ALIGN(addr,size) _ALIGN_UP(addr,size)
85
86/* to align the pointer to the (next) page boundary */
87#define PAGE_ALIGN(addr) _ALIGN(addr, PAGE_SIZE)
88
89#ifndef __ASSEMBLY__
90
91#undef STRICT_MM_TYPECHECKS
92
93#ifdef STRICT_MM_TYPECHECKS
94/* These are used to make use of C type-checking. */
95
96/* PTE level */
97typedef struct { pte_basic_t pte; } pte_t;
98#define pte_val(x) ((x).pte)
99#define __pte(x) ((pte_t) { (x) })
100
101/* 64k pages additionally define a bigger "real PTE" type that gathers
102 * the "second half" part of the PTE for pseudo 64k pages
103 */
104#ifdef CONFIG_PPC_64K_PAGES
105typedef struct { pte_t pte; unsigned long hidx; } real_pte_t;
106#else
107typedef struct { pte_t pte; } real_pte_t;
108#endif
109
110/* PMD level */
111typedef struct { unsigned long pmd; } pmd_t;
112#define pmd_val(x) ((x).pmd)
113#define __pmd(x) ((pmd_t) { (x) })
114
115/* PUD level exusts only on 4k pages */
116#ifndef CONFIG_PPC_64K_PAGES
117typedef struct { unsigned long pud; } pud_t;
118#define pud_val(x) ((x).pud)
119#define __pud(x) ((pud_t) { (x) })
120#endif
121
122/* PGD level */
123typedef struct { unsigned long pgd; } pgd_t;
124#define pgd_val(x) ((x).pgd)
125#define __pgd(x) ((pgd_t) { (x) })
126
127/* Page protection bits */
128typedef struct { unsigned long pgprot; } pgprot_t;
129#define pgprot_val(x) ((x).pgprot)
130#define __pgprot(x) ((pgprot_t) { (x) })
131
132#else
133
134/*
135 * .. while these make it easier on the compiler
136 */
137
138typedef pte_basic_t pte_t;
139#define pte_val(x) (x)
140#define __pte(x) (x)
141
142#ifdef CONFIG_PPC_64K_PAGES
143typedef struct { pte_t pte; unsigned long hidx; } real_pte_t;
144#else
145typedef unsigned long real_pte_t;
146#endif
147
148
149typedef unsigned long pmd_t;
150#define pmd_val(x) (x)
151#define __pmd(x) (x)
152
153#ifndef CONFIG_PPC_64K_PAGES
154typedef unsigned long pud_t;
155#define pud_val(x) (x)
156#define __pud(x) (x)
157#endif
158
159typedef unsigned long pgd_t;
160#define pgd_val(x) (x)
161#define pgprot_val(x) (x)
162
163typedef unsigned long pgprot_t;
164#define __pgd(x) (x)
165#define __pgprot(x) (x)
166
167#endif
168
169struct page;
170extern void clear_user_page(void *page, unsigned long vaddr, struct page *pg);
171extern void copy_user_page(void *to, void *from, unsigned long vaddr,
172 struct page *p);
173extern int page_is_ram(unsigned long pfn);
174
175#endif /* __ASSEMBLY__ */
176
177#endif /* __KERNEL__ */
178
179#endif /* _ASM_POWERPC_PAGE_H */
diff --git a/include/asm-powerpc/page_32.h b/include/asm-powerpc/page_32.h
new file mode 100644
index 000000000000..35221300a2ce
--- /dev/null
+++ b/include/asm-powerpc/page_32.h
@@ -0,0 +1,38 @@
1#ifndef _ASM_POWERPC_PAGE_32_H
2#define _ASM_POWERPC_PAGE_32_H
3
4#define VM_DATA_DEFAULT_FLAGS VM_DATA_DEFAULT_FLAGS32
5
6#ifndef __ASSEMBLY__
7/*
8 * The basic type of a PTE - 64 bits for those CPUs with > 32 bit
9 * physical addressing. For now this just the IBM PPC440.
10 */
11#ifdef CONFIG_PTE_64BIT
12typedef unsigned long long pte_basic_t;
13#define PTE_SHIFT (PAGE_SHIFT - 3) /* 512 ptes per page */
14#define PTE_FMT "%16Lx"
15#else
16typedef unsigned long pte_basic_t;
17#define PTE_SHIFT (PAGE_SHIFT - 2) /* 1024 ptes per page */
18#define PTE_FMT "%.8lx"
19#endif
20
21struct page;
22extern void clear_pages(void *page, int order);
23static inline void clear_page(void *page) { clear_pages(page, 0); }
24extern void copy_page(void *to, void *from);
25
26/* Pure 2^n version of get_order */
27extern __inline__ int get_order(unsigned long size)
28{
29 int lz;
30
31 size = (size-1) >> PAGE_SHIFT;
32 asm ("cntlzw %0,%1" : "=r" (lz) : "r" (size));
33 return 32 - lz;
34}
35
36#endif /* __ASSEMBLY__ */
37
38#endif /* _ASM_POWERPC_PAGE_32_H */
diff --git a/include/asm-powerpc/page_64.h b/include/asm-powerpc/page_64.h
new file mode 100644
index 000000000000..c16f106b5373
--- /dev/null
+++ b/include/asm-powerpc/page_64.h
@@ -0,0 +1,174 @@
1#ifndef _ASM_POWERPC_PAGE_64_H
2#define _ASM_POWERPC_PAGE_64_H
3
4/*
5 * Copyright (C) 2001 PPC64 Team, IBM Corp
6 *
7 * This program is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU General Public License
9 * as published by the Free Software Foundation; either version
10 * 2 of the License, or (at your option) any later version.
11 */
12
13/*
14 * We always define HW_PAGE_SHIFT to 12 as use of 64K pages remains Linux
15 * specific, every notion of page number shared with the firmware, TCEs,
16 * iommu, etc... still uses a page size of 4K.
17 */
18#define HW_PAGE_SHIFT 12
19#define HW_PAGE_SIZE (ASM_CONST(1) << HW_PAGE_SHIFT)
20#define HW_PAGE_MASK (~(HW_PAGE_SIZE-1))
21
22/*
23 * PAGE_FACTOR is the number of bits factor between PAGE_SHIFT and
24 * HW_PAGE_SHIFT, that is 4K pages.
25 */
26#define PAGE_FACTOR (PAGE_SHIFT - HW_PAGE_SHIFT)
27
28#define REGION_SIZE 4UL
29#define REGION_SHIFT 60UL
30#define REGION_MASK (((1UL<<REGION_SIZE)-1UL)<<REGION_SHIFT)
31
32#define VMALLOCBASE ASM_CONST(0xD000000000000000)
33#define VMALLOC_REGION_ID (VMALLOCBASE >> REGION_SHIFT)
34#define KERNEL_REGION_ID (KERNELBASE >> REGION_SHIFT)
35#define USER_REGION_ID (0UL)
36#define REGION_ID(ea) (((unsigned long)(ea)) >> REGION_SHIFT)
37
38/* Segment size */
39#define SID_SHIFT 28
40#define SID_MASK 0xfffffffffUL
41#define ESID_MASK 0xfffffffff0000000UL
42#define GET_ESID(x) (((x) >> SID_SHIFT) & SID_MASK)
43
44#ifndef __ASSEMBLY__
45#include <asm/cache.h>
46
47typedef unsigned long pte_basic_t;
48
49static __inline__ void clear_page(void *addr)
50{
51 unsigned long lines, line_size;
52
53 line_size = ppc64_caches.dline_size;
54 lines = ppc64_caches.dlines_per_page;
55
56 __asm__ __volatile__(
57 "mtctr %1 # clear_page\n\
581: dcbz 0,%0\n\
59 add %0,%0,%3\n\
60 bdnz+ 1b"
61 : "=r" (addr)
62 : "r" (lines), "0" (addr), "r" (line_size)
63 : "ctr", "memory");
64}
65
66extern void copy_4K_page(void *to, void *from);
67
68#ifdef CONFIG_PPC_64K_PAGES
69static inline void copy_page(void *to, void *from)
70{
71 unsigned int i;
72 for (i=0; i < (1 << (PAGE_SHIFT - 12)); i++) {
73 copy_4K_page(to, from);
74 to += 4096;
75 from += 4096;
76 }
77}
78#else /* CONFIG_PPC_64K_PAGES */
79static inline void copy_page(void *to, void *from)
80{
81 copy_4K_page(to, from);
82}
83#endif /* CONFIG_PPC_64K_PAGES */
84
85/* Log 2 of page table size */
86extern u64 ppc64_pft_size;
87
88/* Large pages size */
89extern unsigned int HPAGE_SHIFT;
90#define HPAGE_SIZE ((1UL) << HPAGE_SHIFT)
91#define HPAGE_MASK (~(HPAGE_SIZE - 1))
92#define HUGETLB_PAGE_ORDER (HPAGE_SHIFT - PAGE_SHIFT)
93
94#endif /* __ASSEMBLY__ */
95
96#ifdef CONFIG_HUGETLB_PAGE
97
98#define HTLB_AREA_SHIFT 40
99#define HTLB_AREA_SIZE (1UL << HTLB_AREA_SHIFT)
100#define GET_HTLB_AREA(x) ((x) >> HTLB_AREA_SHIFT)
101
102#define LOW_ESID_MASK(addr, len) (((1U << (GET_ESID(addr+len-1)+1)) \
103 - (1U << GET_ESID(addr))) & 0xffff)
104#define HTLB_AREA_MASK(addr, len) (((1U << (GET_HTLB_AREA(addr+len-1)+1)) \
105 - (1U << GET_HTLB_AREA(addr))) & 0xffff)
106
107#define ARCH_HAS_HUGEPAGE_ONLY_RANGE
108#define ARCH_HAS_PREPARE_HUGEPAGE_RANGE
109#define ARCH_HAS_SETCLEAR_HUGE_PTE
110
111#define touches_hugepage_low_range(mm, addr, len) \
112 (LOW_ESID_MASK((addr), (len)) & (mm)->context.low_htlb_areas)
113#define touches_hugepage_high_range(mm, addr, len) \
114 (HTLB_AREA_MASK((addr), (len)) & (mm)->context.high_htlb_areas)
115
116#define __within_hugepage_low_range(addr, len, segmask) \
117 ((LOW_ESID_MASK((addr), (len)) | (segmask)) == (segmask))
118#define within_hugepage_low_range(addr, len) \
119 __within_hugepage_low_range((addr), (len), \
120 current->mm->context.low_htlb_areas)
121#define __within_hugepage_high_range(addr, len, zonemask) \
122 ((HTLB_AREA_MASK((addr), (len)) | (zonemask)) == (zonemask))
123#define within_hugepage_high_range(addr, len) \
124 __within_hugepage_high_range((addr), (len), \
125 current->mm->context.high_htlb_areas)
126
127#define is_hugepage_only_range(mm, addr, len) \
128 (touches_hugepage_high_range((mm), (addr), (len)) || \
129 touches_hugepage_low_range((mm), (addr), (len)))
130#define HAVE_ARCH_HUGETLB_UNMAPPED_AREA
131
132#define in_hugepage_area(context, addr) \
133 (cpu_has_feature(CPU_FTR_16M_PAGE) && \
134 ( ((1 << GET_HTLB_AREA(addr)) & (context).high_htlb_areas) || \
135 ( ((addr) < 0x100000000L) && \
136 ((1 << GET_ESID(addr)) & (context).low_htlb_areas) ) ) )
137
138#else /* !CONFIG_HUGETLB_PAGE */
139
140#define in_hugepage_area(mm, addr) 0
141
142#endif /* !CONFIG_HUGETLB_PAGE */
143
144#ifdef MODULE
145#define __page_aligned __attribute__((__aligned__(PAGE_SIZE)))
146#else
147#define __page_aligned \
148 __attribute__((__aligned__(PAGE_SIZE), \
149 __section__(".data.page_aligned")))
150#endif
151
152#define VM_DATA_DEFAULT_FLAGS \
153 (test_thread_flag(TIF_32BIT) ? \
154 VM_DATA_DEFAULT_FLAGS32 : VM_DATA_DEFAULT_FLAGS64)
155
156/*
157 * This is the default if a program doesn't have a PT_GNU_STACK
158 * program header entry. The PPC64 ELF ABI has a non executable stack
159 * stack by default, so in the absense of a PT_GNU_STACK program header
160 * we turn execute permission off.
161 */
162#define VM_STACK_DEFAULT_FLAGS32 (VM_READ | VM_WRITE | VM_EXEC | \
163 VM_MAYREAD | VM_MAYWRITE | VM_MAYEXEC)
164
165#define VM_STACK_DEFAULT_FLAGS64 (VM_READ | VM_WRITE | \
166 VM_MAYREAD | VM_MAYWRITE | VM_MAYEXEC)
167
168#define VM_STACK_DEFAULT_FLAGS \
169 (test_thread_flag(TIF_32BIT) ? \
170 VM_STACK_DEFAULT_FLAGS32 : VM_STACK_DEFAULT_FLAGS64)
171
172#include <asm-generic/page.h>
173
174#endif /* _ASM_POWERPC_PAGE_64_H */
diff --git a/include/asm-powerpc/vdso_datapage.h b/include/asm-powerpc/vdso_datapage.h
index fc323b51366b..411832d5bbdb 100644
--- a/include/asm-powerpc/vdso_datapage.h
+++ b/include/asm-powerpc/vdso_datapage.h
@@ -73,7 +73,7 @@ struct vdso_data {
73 /* those additional ones don't have to be located anywhere 73 /* those additional ones don't have to be located anywhere
74 * special as they were not part of the original systemcfg 74 * special as they were not part of the original systemcfg
75 */ 75 */
76 __s64 wtom_clock_sec; /* Wall to monotonic clock */ 76 __s32 wtom_clock_sec; /* Wall to monotonic clock */
77 __s32 wtom_clock_nsec; 77 __s32 wtom_clock_nsec;
78 __u32 syscall_map_64[SYSCALL_MAP_SIZE]; /* map of syscalls */ 78 __u32 syscall_map_64[SYSCALL_MAP_SIZE]; /* map of syscalls */
79 __u32 syscall_map_32[SYSCALL_MAP_SIZE]; /* map of syscalls */ 79 __u32 syscall_map_32[SYSCALL_MAP_SIZE]; /* map of syscalls */
diff --git a/include/asm-ppc/immap_85xx.h b/include/asm-ppc/immap_85xx.h
index 50fb5e47094a..9383d0c13ff8 100644
--- a/include/asm-ppc/immap_85xx.h
+++ b/include/asm-ppc/immap_85xx.h
@@ -3,7 +3,7 @@
3 * 3 *
4 * MPC85xx Internal Memory Map 4 * MPC85xx Internal Memory Map
5 * 5 *
6 * Maintainer: Kumar Gala <kumar.gala@freescale.com> 6 * Maintainer: Kumar Gala <galak@kernel.crashing.org>
7 * 7 *
8 * Copyright 2004 Freescale Semiconductor, Inc 8 * Copyright 2004 Freescale Semiconductor, Inc
9 * 9 *
diff --git a/include/asm-ppc/ipic.h b/include/asm-ppc/ipic.h
index 9092b920997a..0fe396a2b666 100644
--- a/include/asm-ppc/ipic.h
+++ b/include/asm-ppc/ipic.h
@@ -3,7 +3,7 @@
3 * 3 *
4 * IPIC external definitions and structure. 4 * IPIC external definitions and structure.
5 * 5 *
6 * Maintainer: Kumar Gala <kumar.gala@freescale.com> 6 * Maintainer: Kumar Gala <galak@kernel.crashing.org>
7 * 7 *
8 * Copyright 2005 Freescale Semiconductor, Inc 8 * Copyright 2005 Freescale Semiconductor, Inc
9 * 9 *
diff --git a/include/asm-ppc/mpc83xx.h b/include/asm-ppc/mpc83xx.h
index ce212201db2a..7cdf60fa69b6 100644
--- a/include/asm-ppc/mpc83xx.h
+++ b/include/asm-ppc/mpc83xx.h
@@ -3,7 +3,7 @@
3 * 3 *
4 * MPC83xx definitions 4 * MPC83xx definitions
5 * 5 *
6 * Maintainer: Kumar Gala <kumar.gala@freescale.com> 6 * Maintainer: Kumar Gala <galak@kernel.crashing.org>
7 * 7 *
8 * Copyright 2005 Freescale Semiconductor, Inc 8 * Copyright 2005 Freescale Semiconductor, Inc
9 * 9 *
diff --git a/include/asm-ppc/mpc85xx.h b/include/asm-ppc/mpc85xx.h
index d98db980cd49..9d14baea3d71 100644
--- a/include/asm-ppc/mpc85xx.h
+++ b/include/asm-ppc/mpc85xx.h
@@ -3,7 +3,7 @@
3 * 3 *
4 * MPC85xx definitions 4 * MPC85xx definitions
5 * 5 *
6 * Maintainer: Kumar Gala <kumar.gala@freescale.com> 6 * Maintainer: Kumar Gala <galak@kernel.crashing.org>
7 * 7 *
8 * Copyright 2004 Freescale Semiconductor, Inc 8 * Copyright 2004 Freescale Semiconductor, Inc
9 * 9 *
diff --git a/include/asm-ppc/ppc_sys.h b/include/asm-ppc/ppc_sys.h
index bba5305c29ed..83d8c77c124d 100644
--- a/include/asm-ppc/ppc_sys.h
+++ b/include/asm-ppc/ppc_sys.h
@@ -3,7 +3,7 @@
3 * 3 *
4 * PPC system definitions and library functions 4 * PPC system definitions and library functions
5 * 5 *
6 * Maintainer: Kumar Gala <kumar.gala@freescale.com> 6 * Maintainer: Kumar Gala <galak@kernel.crashing.org>
7 * 7 *
8 * Copyright 2005 Freescale Semiconductor, Inc 8 * Copyright 2005 Freescale Semiconductor, Inc
9 * 9 *
diff --git a/include/asm-s390/atomic.h b/include/asm-s390/atomic.h
index 9d86ba6f12d0..b3bd4f679f72 100644
--- a/include/asm-s390/atomic.h
+++ b/include/asm-s390/atomic.h
@@ -198,6 +198,18 @@ atomic_compare_and_swap(int expected_oldval,int new_val,atomic_t *v)
198 return retval; 198 return retval;
199} 199}
200 200
201#define atomic_cmpxchg(v, o, n) (atomic_compare_and_swap((o), (n), &((v)->counter)))
202
203#define atomic_add_unless(v, a, u) \
204({ \
205 int c, old; \
206 c = atomic_read(v); \
207 while (c != (u) && (old = atomic_cmpxchg((v), c, c + (a))) != c) \
208 c = old; \
209 c != (u); \
210})
211#define atomic_inc_not_zero(v) atomic_add_unless((v), 1, 0)
212
201#define smp_mb__before_atomic_dec() smp_mb() 213#define smp_mb__before_atomic_dec() smp_mb()
202#define smp_mb__after_atomic_dec() smp_mb() 214#define smp_mb__after_atomic_dec() smp_mb()
203#define smp_mb__before_atomic_inc() smp_mb() 215#define smp_mb__before_atomic_inc() smp_mb()
diff --git a/include/asm-sh/atomic.h b/include/asm-sh/atomic.h
index 3c4f805da1ac..aabfd334462c 100644
--- a/include/asm-sh/atomic.h
+++ b/include/asm-sh/atomic.h
@@ -87,6 +87,35 @@ static __inline__ int atomic_sub_return(int i, atomic_t * v)
87#define atomic_inc(v) atomic_add(1,(v)) 87#define atomic_inc(v) atomic_add(1,(v))
88#define atomic_dec(v) atomic_sub(1,(v)) 88#define atomic_dec(v) atomic_sub(1,(v))
89 89
90static inline int atomic_cmpxchg(atomic_t *v, int old, int new)
91{
92 int ret;
93 unsigned long flags;
94
95 local_irq_save(flags);
96 ret = v->counter;
97 if (likely(ret == old))
98 v->counter = new;
99 local_irq_restore(flags);
100
101 return ret;
102}
103
104static inline int atomic_add_unless(atomic_t *v, int a, int u)
105{
106 int ret;
107 unsigned long flags;
108
109 local_irq_save(flags);
110 ret = v->counter;
111 if (ret != u)
112 v->counter += a;
113 local_irq_restore(flags);
114
115 return ret != u;
116}
117#define atomic_inc_not_zero(v) atomic_add_unless((v), 1, 0)
118
90static __inline__ void atomic_clear_mask(unsigned int mask, atomic_t *v) 119static __inline__ void atomic_clear_mask(unsigned int mask, atomic_t *v)
91{ 120{
92 unsigned long flags; 121 unsigned long flags;
diff --git a/include/asm-sh64/atomic.h b/include/asm-sh64/atomic.h
index 8c3872d3e65f..927a2bc27b30 100644
--- a/include/asm-sh64/atomic.h
+++ b/include/asm-sh64/atomic.h
@@ -99,6 +99,35 @@ static __inline__ int atomic_sub_return(int i, atomic_t * v)
99#define atomic_inc(v) atomic_add(1,(v)) 99#define atomic_inc(v) atomic_add(1,(v))
100#define atomic_dec(v) atomic_sub(1,(v)) 100#define atomic_dec(v) atomic_sub(1,(v))
101 101
102static inline int atomic_cmpxchg(atomic_t *v, int old, int new)
103{
104 int ret;
105 unsigned long flags;
106
107 local_irq_save(flags);
108 ret = v->counter;
109 if (likely(ret == old))
110 v->counter = new;
111 local_irq_restore(flags);
112
113 return ret;
114}
115
116static inline int atomic_add_unless(atomic_t *v, int a, int u)
117{
118 int ret;
119 unsigned long flags;
120
121 local_irq_save(flags);
122 ret = v->counter;
123 if (ret != u)
124 v->counter += a;
125 local_irq_restore(flags);
126
127 return ret != u;
128}
129#define atomic_inc_not_zero(v) atomic_add_unless((v), 1, 0)
130
102static __inline__ void atomic_clear_mask(unsigned int mask, atomic_t *v) 131static __inline__ void atomic_clear_mask(unsigned int mask, atomic_t *v)
103{ 132{
104 unsigned long flags; 133 unsigned long flags;
diff --git a/include/asm-sparc/atomic.h b/include/asm-sparc/atomic.h
index 37f6ab601c3d..62bec7ad271c 100644
--- a/include/asm-sparc/atomic.h
+++ b/include/asm-sparc/atomic.h
@@ -19,6 +19,8 @@ typedef struct { volatile int counter; } atomic_t;
19#define ATOMIC_INIT(i) { (i) } 19#define ATOMIC_INIT(i) { (i) }
20 20
21extern int __atomic_add_return(int, atomic_t *); 21extern int __atomic_add_return(int, atomic_t *);
22extern int atomic_cmpxchg(atomic_t *, int, int);
23extern int atomic_add_unless(atomic_t *, int, int);
22extern void atomic_set(atomic_t *, int); 24extern void atomic_set(atomic_t *, int);
23 25
24#define atomic_read(v) ((v)->counter) 26#define atomic_read(v) ((v)->counter)
@@ -48,6 +50,8 @@ extern void atomic_set(atomic_t *, int);
48#define atomic_dec_and_test(v) (atomic_dec_return(v) == 0) 50#define atomic_dec_and_test(v) (atomic_dec_return(v) == 0)
49#define atomic_sub_and_test(i, v) (atomic_sub_return(i, v) == 0) 51#define atomic_sub_and_test(i, v) (atomic_sub_return(i, v) == 0)
50 52
53#define atomic_inc_not_zero(v) atomic_add_unless((v), 1, 0)
54
51/* This is the old 24-bit implementation. It's still used internally 55/* This is the old 24-bit implementation. It's still used internally
52 * by some sparc-specific code, notably the semaphore implementation. 56 * by some sparc-specific code, notably the semaphore implementation.
53 */ 57 */
diff --git a/include/asm-sparc64/atomic.h b/include/asm-sparc64/atomic.h
index e175afcf2cde..8198c3d0d007 100644
--- a/include/asm-sparc64/atomic.h
+++ b/include/asm-sparc64/atomic.h
@@ -70,6 +70,18 @@ extern int atomic64_sub_ret(int, atomic64_t *);
70#define atomic_add_negative(i, v) (atomic_add_ret(i, v) < 0) 70#define atomic_add_negative(i, v) (atomic_add_ret(i, v) < 0)
71#define atomic64_add_negative(i, v) (atomic64_add_ret(i, v) < 0) 71#define atomic64_add_negative(i, v) (atomic64_add_ret(i, v) < 0)
72 72
73#define atomic_cmpxchg(v, o, n) ((int)cmpxchg(&((v)->counter), (o), (n)))
74
75#define atomic_add_unless(v, a, u) \
76({ \
77 int c, old; \
78 c = atomic_read(v); \
79 while (c != (u) && (old = atomic_cmpxchg((v), c, c + (a))) != c) \
80 c = old; \
81 c != (u); \
82})
83#define atomic_inc_not_zero(v) atomic_add_unless((v), 1, 0)
84
73/* Atomic operations are already serializing */ 85/* Atomic operations are already serializing */
74#ifdef CONFIG_SMP 86#ifdef CONFIG_SMP
75#define smp_mb__before_atomic_dec() membar_storeload_loadload(); 87#define smp_mb__before_atomic_dec() membar_storeload_loadload();
diff --git a/include/asm-v850/atomic.h b/include/asm-v850/atomic.h
index 395268a8c0de..bede3172ce7f 100644
--- a/include/asm-v850/atomic.h
+++ b/include/asm-v850/atomic.h
@@ -90,6 +90,36 @@ static __inline__ void atomic_clear_mask (unsigned long mask, unsigned long *add
90#define atomic_dec_and_test(v) (atomic_sub_return (1, (v)) == 0) 90#define atomic_dec_and_test(v) (atomic_sub_return (1, (v)) == 0)
91#define atomic_add_negative(i,v) (atomic_add_return ((i), (v)) < 0) 91#define atomic_add_negative(i,v) (atomic_add_return ((i), (v)) < 0)
92 92
93static inline int atomic_cmpxchg(atomic_t *v, int old, int new)
94{
95 int ret;
96 unsigned long flags;
97
98 local_irq_save(flags);
99 ret = v->counter;
100 if (likely(ret == old))
101 v->counter = new;
102 local_irq_restore(flags);
103
104 return ret;
105}
106
107static inline int atomic_add_unless(atomic_t *v, int a, int u)
108{
109 int ret;
110 unsigned long flags;
111
112 local_irq_save(flags);
113 ret = v->counter;
114 if (ret != u)
115 v->counter += a;
116 local_irq_restore(flags);
117
118 return ret != u;
119}
120
121#define atomic_inc_not_zero(v) atomic_add_unless((v), 1, 0)
122
93/* Atomic operations are already serializing on ARM */ 123/* Atomic operations are already serializing on ARM */
94#define smp_mb__before_atomic_dec() barrier() 124#define smp_mb__before_atomic_dec() barrier()
95#define smp_mb__after_atomic_dec() barrier() 125#define smp_mb__after_atomic_dec() barrier()
diff --git a/include/asm-x86_64/atomic.h b/include/asm-x86_64/atomic.h
index fc4c5956e1ea..0866ef67f198 100644
--- a/include/asm-x86_64/atomic.h
+++ b/include/asm-x86_64/atomic.h
@@ -360,6 +360,27 @@ static __inline__ int atomic_sub_return(int i, atomic_t *v)
360 return atomic_add_return(-i,v); 360 return atomic_add_return(-i,v);
361} 361}
362 362
363#define atomic_cmpxchg(v, old, new) ((int)cmpxchg(&((v)->counter), old, new))
364
365/**
366 * atomic_add_unless - add unless the number is a given value
367 * @v: pointer of type atomic_t
368 * @a: the amount to add to v...
369 * @u: ...unless v is equal to u.
370 *
371 * Atomically adds @a to @v, so long as it was not @u.
372 * Returns non-zero if @v was not @u, and zero otherwise.
373 */
374#define atomic_add_unless(v, a, u) \
375({ \
376 int c, old; \
377 c = atomic_read(v); \
378 while (c != (u) && (old = atomic_cmpxchg((v), c, c + (a))) != c) \
379 c = old; \
380 c != (u); \
381})
382#define atomic_inc_not_zero(v) atomic_add_unless((v), 1, 0)
383
363#define atomic_inc_return(v) (atomic_add_return(1,v)) 384#define atomic_inc_return(v) (atomic_add_return(1,v))
364#define atomic_dec_return(v) (atomic_sub_return(1,v)) 385#define atomic_dec_return(v) (atomic_sub_return(1,v))
365 386
diff --git a/include/asm-x86_64/desc.h b/include/asm-x86_64/desc.h
index 68ac3c62fe3d..b837820c9073 100644
--- a/include/asm-x86_64/desc.h
+++ b/include/asm-x86_64/desc.h
@@ -129,9 +129,16 @@ static inline void set_tssldt_descriptor(void *ptr, unsigned long tss, unsigned
129 129
130static inline void set_tss_desc(unsigned cpu, void *addr) 130static inline void set_tss_desc(unsigned cpu, void *addr)
131{ 131{
132 set_tssldt_descriptor(&cpu_gdt_table[cpu][GDT_ENTRY_TSS], (unsigned long)addr, 132 /*
133 DESC_TSS, 133 * sizeof(unsigned long) coming from an extra "long" at the end
134 sizeof(struct tss_struct) - 1); 134 * of the iobitmap. See tss_struct definition in processor.h
135 *
136 * -1? seg base+limit should be pointing to the address of the
137 * last valid byte
138 */
139 set_tssldt_descriptor(&cpu_gdt_table[cpu][GDT_ENTRY_TSS],
140 (unsigned long)addr, DESC_TSS,
141 IO_BITMAP_OFFSET + IO_BITMAP_BYTES + sizeof(unsigned long) - 1);
135} 142}
136 143
137static inline void set_ldt_desc(unsigned cpu, void *addr, int size) 144static inline void set_ldt_desc(unsigned cpu, void *addr, int size)
diff --git a/include/asm-xtensa/atomic.h b/include/asm-xtensa/atomic.h
index 12b5732dc6e5..3670cc7695da 100644
--- a/include/asm-xtensa/atomic.h
+++ b/include/asm-xtensa/atomic.h
@@ -223,6 +223,26 @@ static inline int atomic_sub_return(int i, atomic_t * v)
223 */ 223 */
224#define atomic_add_negative(i,v) (atomic_add_return((i),(v)) < 0) 224#define atomic_add_negative(i,v) (atomic_add_return((i),(v)) < 0)
225 225
226#define atomic_cmpxchg(v, o, n) ((int)cmpxchg(&((v)->counter), (o), (n)))
227
228/**
229 * atomic_add_unless - add unless the number is a given value
230 * @v: pointer of type atomic_t
231 * @a: the amount to add to v...
232 * @u: ...unless v is equal to u.
233 *
234 * Atomically adds @a to @v, so long as it was not @u.
235 * Returns non-zero if @v was not @u, and zero otherwise.
236 */
237#define atomic_add_unless(v, a, u) \
238({ \
239 int c, old; \
240 c = atomic_read(v); \
241 while (c != (u) && (old = atomic_cmpxchg((v), c, c + (a))) != c) \
242 c = old; \
243 c != (u); \
244})
245#define atomic_inc_not_zero(v) atomic_add_unless((v), 1, 0)
226 246
227static inline void atomic_clear_mask(unsigned int mask, atomic_t *v) 247static inline void atomic_clear_mask(unsigned int mask, atomic_t *v)
228{ 248{
diff --git a/include/linux/acct.h b/include/linux/acct.h
index 93c5b3cdf951..9a66401073fc 100644
--- a/include/linux/acct.h
+++ b/include/linux/acct.h
@@ -16,6 +16,8 @@
16#define _LINUX_ACCT_H 16#define _LINUX_ACCT_H
17 17
18#include <linux/types.h> 18#include <linux/types.h>
19#include <linux/jiffies.h>
20
19#include <asm/param.h> 21#include <asm/param.h>
20#include <asm/byteorder.h> 22#include <asm/byteorder.h>
21 23
diff --git a/include/linux/aio.h b/include/linux/aio.h
index 403d71dcb7c8..49fd37629ee4 100644
--- a/include/linux/aio.h
+++ b/include/linux/aio.h
@@ -124,7 +124,7 @@ struct kiocb {
124 (x)->ki_users = 1; \ 124 (x)->ki_users = 1; \
125 (x)->ki_key = KIOCB_SYNC_KEY; \ 125 (x)->ki_key = KIOCB_SYNC_KEY; \
126 (x)->ki_filp = (filp); \ 126 (x)->ki_filp = (filp); \
127 (x)->ki_ctx = &tsk->active_mm->default_kioctx; \ 127 (x)->ki_ctx = NULL; \
128 (x)->ki_cancel = NULL; \ 128 (x)->ki_cancel = NULL; \
129 (x)->ki_dtor = NULL; \ 129 (x)->ki_dtor = NULL; \
130 (x)->ki_obj.tsk = tsk; \ 130 (x)->ki_obj.tsk = tsk; \
@@ -210,8 +210,15 @@ struct kioctx *lookup_ioctx(unsigned long ctx_id);
210int FASTCALL(io_submit_one(struct kioctx *ctx, struct iocb __user *user_iocb, 210int FASTCALL(io_submit_one(struct kioctx *ctx, struct iocb __user *user_iocb,
211 struct iocb *iocb)); 211 struct iocb *iocb));
212 212
213#define get_ioctx(kioctx) do { if (unlikely(atomic_read(&(kioctx)->users) <= 0)) BUG(); atomic_inc(&(kioctx)->users); } while (0) 213#define get_ioctx(kioctx) do { \
214#define put_ioctx(kioctx) do { if (unlikely(atomic_dec_and_test(&(kioctx)->users))) __put_ioctx(kioctx); else if (unlikely(atomic_read(&(kioctx)->users) < 0)) BUG(); } while (0) 214 BUG_ON(unlikely(atomic_read(&(kioctx)->users) <= 0)); \
215 atomic_inc(&(kioctx)->users); \
216} while (0)
217#define put_ioctx(kioctx) do { \
218 BUG_ON(unlikely(atomic_read(&(kioctx)->users) <= 0)); \
219 if (unlikely(atomic_dec_and_test(&(kioctx)->users))) \
220 __put_ioctx(kioctx); \
221} while (0)
215 222
216#define in_aio() !is_sync_wait(current->io_wait) 223#define in_aio() !is_sync_wait(current->io_wait)
217/* may be used for debugging */ 224/* may be used for debugging */
diff --git a/include/linux/cm4000_cs.h b/include/linux/cm4000_cs.h
new file mode 100644
index 000000000000..605ebe24bb2e
--- /dev/null
+++ b/include/linux/cm4000_cs.h
@@ -0,0 +1,66 @@
1#ifndef _CM4000_H_
2#define _CM4000_H_
3
4#define MAX_ATR 33
5
6#define CM4000_MAX_DEV 4
7
8/* those two structures are passed via ioctl() from/to userspace. They are
9 * used by existing userspace programs, so I kepth the awkward "bIFSD" naming
10 * not to break compilation of userspace apps. -HW */
11
12typedef struct atreq {
13 int32_t atr_len;
14 unsigned char atr[64];
15 int32_t power_act;
16 unsigned char bIFSD;
17 unsigned char bIFSC;
18} atreq_t;
19
20
21/* what is particularly stupid in the original driver is the arch-dependant
22 * member sizes. This leads to CONFIG_COMPAT breakage, since 32bit userspace
23 * will lay out the structure members differently than the 64bit kernel.
24 *
25 * I've changed "ptsreq.protocol" from "unsigned long" to "u_int32_t".
26 * On 32bit this will make no difference. With 64bit kernels, it will make
27 * 32bit apps work, too.
28 */
29
30typedef struct ptsreq {
31 u_int32_t protocol; /*T=0: 2^0, T=1: 2^1*/
32 unsigned char flags;
33 unsigned char pts1;
34 unsigned char pts2;
35 unsigned char pts3;
36} ptsreq_t;
37
38#define CM_IOC_MAGIC 'c'
39#define CM_IOC_MAXNR 255
40
41#define CM_IOCGSTATUS _IOR (CM_IOC_MAGIC, 0, unsigned char *)
42#define CM_IOCGATR _IOWR(CM_IOC_MAGIC, 1, atreq_t *)
43#define CM_IOCSPTS _IOW (CM_IOC_MAGIC, 2, ptsreq_t *)
44#define CM_IOCSRDR _IO (CM_IOC_MAGIC, 3)
45#define CM_IOCARDOFF _IO (CM_IOC_MAGIC, 4)
46
47#define CM_IOSDBGLVL _IOW(CM_IOC_MAGIC, 250, int*)
48
49/* card and device states */
50#define CM_CARD_INSERTED 0x01
51#define CM_CARD_POWERED 0x02
52#define CM_ATR_PRESENT 0x04
53#define CM_ATR_VALID 0x08
54#define CM_STATE_VALID 0x0f
55/* extra info only from CM4000 */
56#define CM_NO_READER 0x10
57#define CM_BAD_CARD 0x20
58
59
60#ifdef __KERNEL__
61
62#define DEVICE_NAME "cmm"
63#define MODULE_NAME "cm4000_cs"
64
65#endif /* __KERNEL__ */
66#endif /* _CM4000_H_ */
diff --git a/include/linux/file.h b/include/linux/file.h
index d3b1a15d5f21..418b6101b59a 100644
--- a/include/linux/file.h
+++ b/include/linux/file.h
@@ -33,13 +33,13 @@ struct fdtable {
33 * Open file table structure 33 * Open file table structure
34 */ 34 */
35struct files_struct { 35struct files_struct {
36 atomic_t count; 36 atomic_t count;
37 spinlock_t file_lock; /* Protects all the below members. Nests inside tsk->alloc_lock */
38 struct fdtable *fdt; 37 struct fdtable *fdt;
39 struct fdtable fdtab; 38 struct fdtable fdtab;
40 fd_set close_on_exec_init; 39 fd_set close_on_exec_init;
41 fd_set open_fds_init; 40 fd_set open_fds_init;
42 struct file * fd_array[NR_OPEN_DEFAULT]; 41 struct file * fd_array[NR_OPEN_DEFAULT];
42 spinlock_t file_lock; /* Protects concurrent writers. Nests inside tsk->alloc_lock */
43}; 43};
44 44
45#define files_fdtable(files) (rcu_dereference((files)->fdt)) 45#define files_fdtable(files) (rcu_dereference((files)->fdt))
diff --git a/include/linux/fsl_devices.h b/include/linux/fsl_devices.h
index 114d5d59f695..934aa9bda481 100644
--- a/include/linux/fsl_devices.h
+++ b/include/linux/fsl_devices.h
@@ -4,7 +4,7 @@
4 * Definitions for any platform device related flags or structures for 4 * Definitions for any platform device related flags or structures for
5 * Freescale processor devices 5 * Freescale processor devices
6 * 6 *
7 * Maintainer: Kumar Gala (kumar.gala@freescale.com) 7 * Maintainer: Kumar Gala <galak@kernel.crashing.org>
8 * 8 *
9 * Copyright 2004 Freescale Semiconductor, Inc 9 * Copyright 2004 Freescale Semiconductor, Inc
10 * 10 *
diff --git a/include/linux/gfp.h b/include/linux/gfp.h
index c3779432a723..23279d8f19b1 100644
--- a/include/linux/gfp.h
+++ b/include/linux/gfp.h
@@ -39,8 +39,7 @@ struct vm_area_struct;
39#define __GFP_COMP ((__force gfp_t)0x4000u)/* Add compound page metadata */ 39#define __GFP_COMP ((__force gfp_t)0x4000u)/* Add compound page metadata */
40#define __GFP_ZERO ((__force gfp_t)0x8000u)/* Return zeroed page on success */ 40#define __GFP_ZERO ((__force gfp_t)0x8000u)/* Return zeroed page on success */
41#define __GFP_NOMEMALLOC ((__force gfp_t)0x10000u) /* Don't use emergency reserves */ 41#define __GFP_NOMEMALLOC ((__force gfp_t)0x10000u) /* Don't use emergency reserves */
42#define __GFP_NORECLAIM ((__force gfp_t)0x20000u) /* No realy zone reclaim during allocation */ 42#define __GFP_HARDWALL ((__force gfp_t)0x20000u) /* Enforce hardwall cpuset memory allocs */
43#define __GFP_HARDWALL ((__force gfp_t)0x40000u) /* Enforce hardwall cpuset memory allocs */
44 43
45#define __GFP_BITS_SHIFT 20 /* Room for 20 __GFP_FOO bits */ 44#define __GFP_BITS_SHIFT 20 /* Room for 20 __GFP_FOO bits */
46#define __GFP_BITS_MASK ((__force gfp_t)((1 << __GFP_BITS_SHIFT) - 1)) 45#define __GFP_BITS_MASK ((__force gfp_t)((1 << __GFP_BITS_SHIFT) - 1))
@@ -49,7 +48,7 @@ struct vm_area_struct;
49#define GFP_LEVEL_MASK (__GFP_WAIT|__GFP_HIGH|__GFP_IO|__GFP_FS| \ 48#define GFP_LEVEL_MASK (__GFP_WAIT|__GFP_HIGH|__GFP_IO|__GFP_FS| \
50 __GFP_COLD|__GFP_NOWARN|__GFP_REPEAT| \ 49 __GFP_COLD|__GFP_NOWARN|__GFP_REPEAT| \
51 __GFP_NOFAIL|__GFP_NORETRY|__GFP_NO_GROW|__GFP_COMP| \ 50 __GFP_NOFAIL|__GFP_NORETRY|__GFP_NO_GROW|__GFP_COMP| \
52 __GFP_NOMEMALLOC|__GFP_NORECLAIM|__GFP_HARDWALL) 51 __GFP_NOMEMALLOC|__GFP_HARDWALL)
53 52
54#define GFP_ATOMIC (__GFP_HIGH) 53#define GFP_ATOMIC (__GFP_HIGH)
55#define GFP_NOIO (__GFP_WAIT) 54#define GFP_NOIO (__GFP_WAIT)
diff --git a/include/linux/hardirq.h b/include/linux/hardirq.h
index 5912874ca83c..71d2b8a723b9 100644
--- a/include/linux/hardirq.h
+++ b/include/linux/hardirq.h
@@ -90,6 +90,8 @@ extern void synchronize_irq(unsigned int irq);
90#define nmi_enter() irq_enter() 90#define nmi_enter() irq_enter()
91#define nmi_exit() sub_preempt_count(HARDIRQ_OFFSET) 91#define nmi_exit() sub_preempt_count(HARDIRQ_OFFSET)
92 92
93struct task_struct;
94
93#ifndef CONFIG_VIRT_CPU_ACCOUNTING 95#ifndef CONFIG_VIRT_CPU_ACCOUNTING
94static inline void account_user_vtime(struct task_struct *tsk) 96static inline void account_user_vtime(struct task_struct *tsk)
95{ 97{
diff --git a/include/linux/hugetlb.h b/include/linux/hugetlb.h
index 0cea162b08c0..1056717ee501 100644
--- a/include/linux/hugetlb.h
+++ b/include/linux/hugetlb.h
@@ -102,8 +102,8 @@ static inline unsigned long hugetlb_total_pages(void)
102#define hugetlb_fault(mm, vma, addr, write) ({ BUG(); 0; }) 102#define hugetlb_fault(mm, vma, addr, write) ({ BUG(); 0; })
103 103
104#ifndef HPAGE_MASK 104#ifndef HPAGE_MASK
105#define HPAGE_MASK 0 /* Keep the compiler happy */ 105#define HPAGE_MASK PAGE_MASK /* Keep the compiler happy */
106#define HPAGE_SIZE 0 106#define HPAGE_SIZE PAGE_SIZE
107#endif 107#endif
108 108
109#endif /* !CONFIG_HUGETLB_PAGE */ 109#endif /* !CONFIG_HUGETLB_PAGE */
diff --git a/include/linux/i2c-id.h b/include/linux/i2c-id.h
index 74abaecdb572..1543daaa9c5e 100644
--- a/include/linux/i2c-id.h
+++ b/include/linux/i2c-id.h
@@ -107,6 +107,7 @@
107#define I2C_DRIVERID_CX25840 71 /* cx2584x video encoder */ 107#define I2C_DRIVERID_CX25840 71 /* cx2584x video encoder */
108#define I2C_DRIVERID_SAA7127 72 /* saa7124 video encoder */ 108#define I2C_DRIVERID_SAA7127 72 /* saa7124 video encoder */
109#define I2C_DRIVERID_SAA711X 73 /* saa711x video encoders */ 109#define I2C_DRIVERID_SAA711X 73 /* saa711x video encoders */
110#define I2C_DRIVERID_AKITAIOEXP 74 /* IO Expander on Sharp SL-C1000 */
110 111
111#define I2C_DRIVERID_EXP0 0xF0 /* experimental use id's */ 112#define I2C_DRIVERID_EXP0 0xF0 /* experimental use id's */
112#define I2C_DRIVERID_EXP1 0xF1 113#define I2C_DRIVERID_EXP1 0xF1
diff --git a/include/linux/init_task.h b/include/linux/init_task.h
index 68ab5f2ab9cd..dcfd2ecccb5d 100644
--- a/include/linux/init_task.h
+++ b/include/linux/init_task.h
@@ -51,7 +51,6 @@
51 .page_table_lock = SPIN_LOCK_UNLOCKED, \ 51 .page_table_lock = SPIN_LOCK_UNLOCKED, \
52 .mmlist = LIST_HEAD_INIT(name.mmlist), \ 52 .mmlist = LIST_HEAD_INIT(name.mmlist), \
53 .cpu_vm_mask = CPU_MASK_ALL, \ 53 .cpu_vm_mask = CPU_MASK_ALL, \
54 .default_kioctx = INIT_KIOCTX(name.default_kioctx, name), \
55} 54}
56 55
57#define INIT_SIGNALS(sig) { \ 56#define INIT_SIGNALS(sig) { \
diff --git a/include/linux/interrupt.h b/include/linux/interrupt.h
index 0a90205184b0..41f150a3d2dd 100644
--- a/include/linux/interrupt.h
+++ b/include/linux/interrupt.h
@@ -9,6 +9,7 @@
9#include <linux/preempt.h> 9#include <linux/preempt.h>
10#include <linux/cpumask.h> 10#include <linux/cpumask.h>
11#include <linux/hardirq.h> 11#include <linux/hardirq.h>
12#include <linux/sched.h>
12#include <asm/atomic.h> 13#include <asm/atomic.h>
13#include <asm/ptrace.h> 14#include <asm/ptrace.h>
14#include <asm/system.h> 15#include <asm/system.h>
diff --git a/include/linux/mmzone.h b/include/linux/mmzone.h
index f5fa3082fd6a..6cfb114a0c34 100644
--- a/include/linux/mmzone.h
+++ b/include/linux/mmzone.h
@@ -329,7 +329,7 @@ void get_zone_counts(unsigned long *active, unsigned long *inactive,
329void build_all_zonelists(void); 329void build_all_zonelists(void);
330void wakeup_kswapd(struct zone *zone, int order); 330void wakeup_kswapd(struct zone *zone, int order);
331int zone_watermark_ok(struct zone *z, int order, unsigned long mark, 331int zone_watermark_ok(struct zone *z, int order, unsigned long mark,
332 int alloc_type, int can_try_harder, gfp_t gfp_high); 332 int classzone_idx, int alloc_flags);
333 333
334#ifdef CONFIG_HAVE_MEMORY_PRESENT 334#ifdef CONFIG_HAVE_MEMORY_PRESENT
335void memory_present(int nid, unsigned long start, unsigned long end); 335void memory_present(int nid, unsigned long start, unsigned long end);
diff --git a/include/linux/pagemap.h b/include/linux/pagemap.h
index ba6c310a055f..ee700c6eb442 100644
--- a/include/linux/pagemap.h
+++ b/include/linux/pagemap.h
@@ -53,12 +53,12 @@ void release_pages(struct page **pages, int nr, int cold);
53 53
54static inline struct page *page_cache_alloc(struct address_space *x) 54static inline struct page *page_cache_alloc(struct address_space *x)
55{ 55{
56 return alloc_pages(mapping_gfp_mask(x)|__GFP_NORECLAIM, 0); 56 return alloc_pages(mapping_gfp_mask(x), 0);
57} 57}
58 58
59static inline struct page *page_cache_alloc_cold(struct address_space *x) 59static inline struct page *page_cache_alloc_cold(struct address_space *x)
60{ 60{
61 return alloc_pages(mapping_gfp_mask(x)|__GFP_COLD|__GFP_NORECLAIM, 0); 61 return alloc_pages(mapping_gfp_mask(x)|__GFP_COLD, 0);
62} 62}
63 63
64typedef int filler_t(void *, struct page *); 64typedef int filler_t(void *, struct page *);
diff --git a/include/linux/pci_ids.h b/include/linux/pci_ids.h
index d00f8ba7f22b..d4c1c8fd2925 100644
--- a/include/linux/pci_ids.h
+++ b/include/linux/pci_ids.h
@@ -805,6 +805,10 @@
805#define PCI_DEVICE_ID_APPLE_SH_SUNGEM 0x0051 805#define PCI_DEVICE_ID_APPLE_SH_SUNGEM 0x0051
806#define PCI_DEVICE_ID_APPLE_U3L_AGP 0x0058 806#define PCI_DEVICE_ID_APPLE_U3L_AGP 0x0058
807#define PCI_DEVICE_ID_APPLE_U3H_AGP 0x0059 807#define PCI_DEVICE_ID_APPLE_U3H_AGP 0x0059
808#define PCI_DEVICE_ID_APPLE_IPID2_AGP 0x0066
809#define PCI_DEVICE_ID_APPLE_IPID2_ATA 0x0069
810#define PCI_DEVICE_ID_APPLE_IPID2_FW 0x006a
811#define PCI_DEVICE_ID_APPLE_IPID2_GMAC 0x006b
808#define PCI_DEVICE_ID_APPLE_TIGON3 0x1645 812#define PCI_DEVICE_ID_APPLE_TIGON3 0x1645
809 813
810#define PCI_VENDOR_ID_YAMAHA 0x1073 814#define PCI_VENDOR_ID_YAMAHA 0x1073
diff --git a/include/linux/percpu.h b/include/linux/percpu.h
index 5451eb1e781d..fb8d2d24e4bb 100644
--- a/include/linux/percpu.h
+++ b/include/linux/percpu.h
@@ -38,7 +38,7 @@ extern void free_percpu(const void *);
38 38
39#else /* CONFIG_SMP */ 39#else /* CONFIG_SMP */
40 40
41#define per_cpu_ptr(ptr, cpu) (ptr) 41#define per_cpu_ptr(ptr, cpu) ({ (void)(cpu); (ptr); })
42 42
43static inline void *__alloc_percpu(size_t size, size_t align) 43static inline void *__alloc_percpu(size_t size, size_t align)
44{ 44{
diff --git a/include/linux/pm.h b/include/linux/pm.h
index 1514098d156d..5be87ba3b7ac 100644
--- a/include/linux/pm.h
+++ b/include/linux/pm.h
@@ -94,55 +94,6 @@ struct pm_dev
94 struct list_head entry; 94 struct list_head entry;
95}; 95};
96 96
97#ifdef CONFIG_PM
98
99extern int pm_active;
100
101#define PM_IS_ACTIVE() (pm_active != 0)
102
103/*
104 * Register a device with power management
105 */
106struct pm_dev __deprecated *
107pm_register(pm_dev_t type, unsigned long id, pm_callback callback);
108
109/*
110 * Unregister a device with power management
111 */
112void __deprecated pm_unregister(struct pm_dev *dev);
113
114/*
115 * Unregister all devices with matching callback
116 */
117void __deprecated pm_unregister_all(pm_callback callback);
118
119/*
120 * Send a request to all devices
121 */
122int __deprecated pm_send_all(pm_request_t rqst, void *data);
123
124#else /* CONFIG_PM */
125
126#define PM_IS_ACTIVE() 0
127
128static inline struct pm_dev *pm_register(pm_dev_t type,
129 unsigned long id,
130 pm_callback callback)
131{
132 return NULL;
133}
134
135static inline void pm_unregister(struct pm_dev *dev) {}
136
137static inline void pm_unregister_all(pm_callback callback) {}
138
139static inline int pm_send_all(pm_request_t rqst, void *data)
140{
141 return 0;
142}
143
144#endif /* CONFIG_PM */
145
146/* Functions above this comment are list-based old-style power 97/* Functions above this comment are list-based old-style power
147 * managment. Please avoid using them. */ 98 * managment. Please avoid using them. */
148 99
diff --git a/include/linux/pm_legacy.h b/include/linux/pm_legacy.h
new file mode 100644
index 000000000000..1252b45face1
--- /dev/null
+++ b/include/linux/pm_legacy.h
@@ -0,0 +1,56 @@
1#ifndef __LINUX_PM_LEGACY_H__
2#define __LINUX_PM_LEGACY_H__
3
4#include <linux/config.h>
5
6#ifdef CONFIG_PM_LEGACY
7
8extern int pm_active;
9
10#define PM_IS_ACTIVE() (pm_active != 0)
11
12/*
13 * Register a device with power management
14 */
15struct pm_dev __deprecated *
16pm_register(pm_dev_t type, unsigned long id, pm_callback callback);
17
18/*
19 * Unregister a device with power management
20 */
21void __deprecated pm_unregister(struct pm_dev *dev);
22
23/*
24 * Unregister all devices with matching callback
25 */
26void __deprecated pm_unregister_all(pm_callback callback);
27
28/*
29 * Send a request to all devices
30 */
31int __deprecated pm_send_all(pm_request_t rqst, void *data);
32
33#else /* CONFIG_PM_LEGACY */
34
35#define PM_IS_ACTIVE() 0
36
37static inline struct pm_dev *pm_register(pm_dev_t type,
38 unsigned long id,
39 pm_callback callback)
40{
41 return NULL;
42}
43
44static inline void pm_unregister(struct pm_dev *dev) {}
45
46static inline void pm_unregister_all(pm_callback callback) {}
47
48static inline int pm_send_all(pm_request_t rqst, void *data)
49{
50 return 0;
51}
52
53#endif /* CONFIG_PM_LEGACY */
54
55#endif /* __LINUX_PM_LEGACY_H__ */
56
diff --git a/include/linux/preempt.h b/include/linux/preempt.h
index dd98c54a23b4..d9a2f5254a51 100644
--- a/include/linux/preempt.h
+++ b/include/linux/preempt.h
@@ -7,6 +7,7 @@
7 */ 7 */
8 8
9#include <linux/config.h> 9#include <linux/config.h>
10#include <linux/thread_info.h>
10#include <linux/linkage.h> 11#include <linux/linkage.h>
11 12
12#ifdef CONFIG_DEBUG_PREEMPT 13#ifdef CONFIG_DEBUG_PREEMPT
diff --git a/include/linux/sched.h b/include/linux/sched.h
index 2bbf968b23d9..2038bd27b041 100644
--- a/include/linux/sched.h
+++ b/include/linux/sched.h
@@ -357,7 +357,6 @@ struct mm_struct {
357 /* aio bits */ 357 /* aio bits */
358 rwlock_t ioctx_list_lock; 358 rwlock_t ioctx_list_lock;
359 struct kioctx *ioctx_list; 359 struct kioctx *ioctx_list;
360 struct kioctx default_kioctx;
361}; 360};
362 361
363struct sighand_struct { 362struct sighand_struct {
@@ -1233,32 +1232,49 @@ static inline void task_unlock(struct task_struct *p)
1233 spin_unlock(&p->alloc_lock); 1232 spin_unlock(&p->alloc_lock);
1234} 1233}
1235 1234
1235#ifndef __HAVE_THREAD_FUNCTIONS
1236
1237#define task_thread_info(task) (task)->thread_info
1238
1239static inline void setup_thread_stack(struct task_struct *p, struct task_struct *org)
1240{
1241 *task_thread_info(p) = *task_thread_info(org);
1242 task_thread_info(p)->task = p;
1243}
1244
1245static inline unsigned long *end_of_stack(struct task_struct *p)
1246{
1247 return (unsigned long *)(p->thread_info + 1);
1248}
1249
1250#endif
1251
1236/* set thread flags in other task's structures 1252/* set thread flags in other task's structures
1237 * - see asm/thread_info.h for TIF_xxxx flags available 1253 * - see asm/thread_info.h for TIF_xxxx flags available
1238 */ 1254 */
1239static inline void set_tsk_thread_flag(struct task_struct *tsk, int flag) 1255static inline void set_tsk_thread_flag(struct task_struct *tsk, int flag)
1240{ 1256{
1241 set_ti_thread_flag(tsk->thread_info,flag); 1257 set_ti_thread_flag(task_thread_info(tsk), flag);
1242} 1258}
1243 1259
1244static inline void clear_tsk_thread_flag(struct task_struct *tsk, int flag) 1260static inline void clear_tsk_thread_flag(struct task_struct *tsk, int flag)
1245{ 1261{
1246 clear_ti_thread_flag(tsk->thread_info,flag); 1262 clear_ti_thread_flag(task_thread_info(tsk), flag);
1247} 1263}
1248 1264
1249static inline int test_and_set_tsk_thread_flag(struct task_struct *tsk, int flag) 1265static inline int test_and_set_tsk_thread_flag(struct task_struct *tsk, int flag)
1250{ 1266{
1251 return test_and_set_ti_thread_flag(tsk->thread_info,flag); 1267 return test_and_set_ti_thread_flag(task_thread_info(tsk), flag);
1252} 1268}
1253 1269
1254static inline int test_and_clear_tsk_thread_flag(struct task_struct *tsk, int flag) 1270static inline int test_and_clear_tsk_thread_flag(struct task_struct *tsk, int flag)
1255{ 1271{
1256 return test_and_clear_ti_thread_flag(tsk->thread_info,flag); 1272 return test_and_clear_ti_thread_flag(task_thread_info(tsk), flag);
1257} 1273}
1258 1274
1259static inline int test_tsk_thread_flag(struct task_struct *tsk, int flag) 1275static inline int test_tsk_thread_flag(struct task_struct *tsk, int flag)
1260{ 1276{
1261 return test_ti_thread_flag(tsk->thread_info,flag); 1277 return test_ti_thread_flag(task_thread_info(tsk), flag);
1262} 1278}
1263 1279
1264static inline void set_tsk_need_resched(struct task_struct *tsk) 1280static inline void set_tsk_need_resched(struct task_struct *tsk)
@@ -1329,12 +1345,12 @@ extern void signal_wake_up(struct task_struct *t, int resume_stopped);
1329 1345
1330static inline unsigned int task_cpu(const struct task_struct *p) 1346static inline unsigned int task_cpu(const struct task_struct *p)
1331{ 1347{
1332 return p->thread_info->cpu; 1348 return task_thread_info(p)->cpu;
1333} 1349}
1334 1350
1335static inline void set_task_cpu(struct task_struct *p, unsigned int cpu) 1351static inline void set_task_cpu(struct task_struct *p, unsigned int cpu)
1336{ 1352{
1337 p->thread_info->cpu = cpu; 1353 task_thread_info(p)->cpu = cpu;
1338} 1354}
1339 1355
1340#else 1356#else
diff --git a/include/linux/smp_lock.h b/include/linux/smp_lock.h
index b63ce7014093..fa1ff3b165fe 100644
--- a/include/linux/smp_lock.h
+++ b/include/linux/smp_lock.h
@@ -2,11 +2,10 @@
2#define __LINUX_SMPLOCK_H 2#define __LINUX_SMPLOCK_H
3 3
4#include <linux/config.h> 4#include <linux/config.h>
5#ifdef CONFIG_LOCK_KERNEL
5#include <linux/sched.h> 6#include <linux/sched.h>
6#include <linux/spinlock.h> 7#include <linux/spinlock.h>
7 8
8#ifdef CONFIG_LOCK_KERNEL
9
10#define kernel_locked() (current->lock_depth >= 0) 9#define kernel_locked() (current->lock_depth >= 0)
11 10
12extern int __lockfunc __reacquire_kernel_lock(void); 11extern int __lockfunc __reacquire_kernel_lock(void);
diff --git a/include/linux/thread_info.h b/include/linux/thread_info.h
index d252f45a0f9b..1c4eb41dbd89 100644
--- a/include/linux/thread_info.h
+++ b/include/linux/thread_info.h
@@ -27,31 +27,6 @@ extern long do_no_restart_syscall(struct restart_block *parm);
27 * - pass TIF_xxxx constants to these functions 27 * - pass TIF_xxxx constants to these functions
28 */ 28 */
29 29
30static inline void set_thread_flag(int flag)
31{
32 set_bit(flag,&current_thread_info()->flags);
33}
34
35static inline void clear_thread_flag(int flag)
36{
37 clear_bit(flag,&current_thread_info()->flags);
38}
39
40static inline int test_and_set_thread_flag(int flag)
41{
42 return test_and_set_bit(flag,&current_thread_info()->flags);
43}
44
45static inline int test_and_clear_thread_flag(int flag)
46{
47 return test_and_clear_bit(flag,&current_thread_info()->flags);
48}
49
50static inline int test_thread_flag(int flag)
51{
52 return test_bit(flag,&current_thread_info()->flags);
53}
54
55static inline void set_ti_thread_flag(struct thread_info *ti, int flag) 30static inline void set_ti_thread_flag(struct thread_info *ti, int flag)
56{ 31{
57 set_bit(flag,&ti->flags); 32 set_bit(flag,&ti->flags);
@@ -77,15 +52,19 @@ static inline int test_ti_thread_flag(struct thread_info *ti, int flag)
77 return test_bit(flag,&ti->flags); 52 return test_bit(flag,&ti->flags);
78} 53}
79 54
80static inline void set_need_resched(void) 55#define set_thread_flag(flag) \
81{ 56 set_ti_thread_flag(current_thread_info(), flag)
82 set_thread_flag(TIF_NEED_RESCHED); 57#define clear_thread_flag(flag) \
83} 58 clear_ti_thread_flag(current_thread_info(), flag)
84 59#define test_and_set_thread_flag(flag) \
85static inline void clear_need_resched(void) 60 test_and_set_ti_thread_flag(current_thread_info(), flag)
86{ 61#define test_and_clear_thread_flag(flag) \
87 clear_thread_flag(TIF_NEED_RESCHED); 62 test_and_clear_ti_thread_flag(current_thread_info(), flag)
88} 63#define test_thread_flag(flag) \
64 test_ti_thread_flag(current_thread_info(), flag)
65
66#define set_need_resched() set_thread_flag(TIF_NEED_RESCHED)
67#define clear_need_resched() clear_thread_flag(TIF_NEED_RESCHED)
89 68
90#endif 69#endif
91 70
diff --git a/include/linux/time.h b/include/linux/time.h
index 8e83f4e778bb..bfbe92d0767c 100644
--- a/include/linux/time.h
+++ b/include/linux/time.h
@@ -101,7 +101,7 @@ extern struct timespec timespec_trunc(struct timespec t, unsigned gran);
101static inline void 101static inline void
102set_normalized_timespec (struct timespec *ts, time_t sec, long nsec) 102set_normalized_timespec (struct timespec *ts, time_t sec, long nsec)
103{ 103{
104 while (nsec > NSEC_PER_SEC) { 104 while (nsec >= NSEC_PER_SEC) {
105 nsec -= NSEC_PER_SEC; 105 nsec -= NSEC_PER_SEC;
106 ++sec; 106 ++sec;
107 } 107 }
diff --git a/include/linux/usb.h b/include/linux/usb.h
index 748d04385256..856d232c7562 100644
--- a/include/linux/usb.h
+++ b/include/linux/usb.h
@@ -819,7 +819,7 @@ typedef void (*usb_complete_t)(struct urb *, struct pt_regs *);
819 */ 819 */
820struct urb 820struct urb
821{ 821{
822 /* private, usb core and host controller only fields in the urb */ 822 /* private: usb core and host controller only fields in the urb */
823 struct kref kref; /* reference count of the URB */ 823 struct kref kref; /* reference count of the URB */
824 spinlock_t lock; /* lock for the URB */ 824 spinlock_t lock; /* lock for the URB */
825 void *hcpriv; /* private data for host controller */ 825 void *hcpriv; /* private data for host controller */
@@ -827,7 +827,7 @@ struct urb
827 atomic_t use_count; /* concurrent submissions counter */ 827 atomic_t use_count; /* concurrent submissions counter */
828 u8 reject; /* submissions will fail */ 828 u8 reject; /* submissions will fail */
829 829
830 /* public, documented fields in the urb that can be used by drivers */ 830 /* public: documented fields in the urb that can be used by drivers */
831 struct list_head urb_list; /* list head for use by the urb's 831 struct list_head urb_list; /* list head for use by the urb's
832 * current owner */ 832 * current owner */
833 struct usb_device *dev; /* (in) pointer to associated device */ 833 struct usb_device *dev; /* (in) pointer to associated device */
@@ -1045,7 +1045,7 @@ struct usb_sg_request {
1045 size_t bytes; 1045 size_t bytes;
1046 1046
1047 /* 1047 /*
1048 * members below are private to usbcore, 1048 * members below are private: to usbcore,
1049 * and are not provided for driver access! 1049 * and are not provided for driver access!
1050 */ 1050 */
1051 spinlock_t lock; 1051 spinlock_t lock;
diff --git a/include/linux/videodev2.h b/include/linux/videodev2.h
index a114fff6568b..1cded681eb6d 100644
--- a/include/linux/videodev2.h
+++ b/include/linux/videodev2.h
@@ -636,6 +636,7 @@ typedef __u64 v4l2_std_id;
636#define V4L2_STD_SECAM_K ((v4l2_std_id)0x00100000) 636#define V4L2_STD_SECAM_K ((v4l2_std_id)0x00100000)
637#define V4L2_STD_SECAM_K1 ((v4l2_std_id)0x00200000) 637#define V4L2_STD_SECAM_K1 ((v4l2_std_id)0x00200000)
638#define V4L2_STD_SECAM_L ((v4l2_std_id)0x00400000) 638#define V4L2_STD_SECAM_L ((v4l2_std_id)0x00400000)
639#define V4L2_STD_SECAM_LC ((v4l2_std_id)0x00800000)
639 640
640/* ATSC/HDTV */ 641/* ATSC/HDTV */
641#define V4L2_STD_ATSC_8_VSB ((v4l2_std_id)0x01000000) 642#define V4L2_STD_ATSC_8_VSB ((v4l2_std_id)0x01000000)
diff --git a/include/media/ir-common.h b/include/media/ir-common.h
index 0f1ba95ec8d6..ad3e9bb670c3 100644
--- a/include/media/ir-common.h
+++ b/include/media/ir-common.h
@@ -49,6 +49,7 @@ struct ir_input_state {
49 49
50extern IR_KEYTAB_TYPE ir_codes_rc5_tv[IR_KEYTAB_SIZE]; 50extern IR_KEYTAB_TYPE ir_codes_rc5_tv[IR_KEYTAB_SIZE];
51extern IR_KEYTAB_TYPE ir_codes_winfast[IR_KEYTAB_SIZE]; 51extern IR_KEYTAB_TYPE ir_codes_winfast[IR_KEYTAB_SIZE];
52extern IR_KEYTAB_TYPE ir_codes_pinnacle[IR_KEYTAB_SIZE];
52extern IR_KEYTAB_TYPE ir_codes_empty[IR_KEYTAB_SIZE]; 53extern IR_KEYTAB_TYPE ir_codes_empty[IR_KEYTAB_SIZE];
53extern IR_KEYTAB_TYPE ir_codes_hauppauge_new[IR_KEYTAB_SIZE]; 54extern IR_KEYTAB_TYPE ir_codes_hauppauge_new[IR_KEYTAB_SIZE];
54extern IR_KEYTAB_TYPE ir_codes_pixelview[IR_KEYTAB_SIZE]; 55extern IR_KEYTAB_TYPE ir_codes_pixelview[IR_KEYTAB_SIZE];
diff --git a/include/media/ir-kbd-i2c.h b/include/media/ir-kbd-i2c.h
index 00fa57eb9fde..730f21ed91db 100644
--- a/include/media/ir-kbd-i2c.h
+++ b/include/media/ir-kbd-i2c.h
@@ -19,4 +19,6 @@ struct IR_i2c {
19 char phys[32]; 19 char phys[32];
20 int (*get_key)(struct IR_i2c*, u32*, u32*); 20 int (*get_key)(struct IR_i2c*, u32*, u32*);
21}; 21};
22
23int get_key_pinnacle(struct IR_i2c *ir, u32 *ir_key, u32 *ir_raw);
22#endif 24#endif
diff --git a/include/media/tuner.h b/include/media/tuner.h
index 9184e534b7ef..faa0f8e3091b 100644
--- a/include/media/tuner.h
+++ b/include/media/tuner.h
@@ -113,6 +113,7 @@
113#define TUNER_PHILIPS_TD1316 67 113#define TUNER_PHILIPS_TD1316 67
114 114
115#define TUNER_PHILIPS_TUV1236D 68 /* ATI HDTV Wonder */ 115#define TUNER_PHILIPS_TUV1236D 68 /* ATI HDTV Wonder */
116#define TUNER_TNF_5335MF 69 /* Sabrent Bt848 */
116 117
117#define NOTUNER 0 118#define NOTUNER 0
118#define PAL 1 /* PAL_BG */ 119#define PAL 1 /* PAL_BG */
diff --git a/include/media/v4l2-common.h b/include/media/v4l2-common.h
new file mode 100644
index 000000000000..d3fd48157eb8
--- /dev/null
+++ b/include/media/v4l2-common.h
@@ -0,0 +1,110 @@
1/*
2 v4l2 common internal API header
3
4 This header contains internal shared ioctl definitions for use by the
5 internal low-level v4l2 drivers.
6 Each ioctl begins with VIDIOC_INT_ to clearly mark that it is an internal
7 define,
8
9 Copyright (C) 2005 Hans Verkuil <hverkuil@xs4all.nl>
10
11 This program is free software; you can redistribute it and/or modify
12 it under the terms of the GNU General Public License as published by
13 the Free Software Foundation; either version 2 of the License, or
14 (at your option) any later version.
15
16 This program is distributed in the hope that it will be useful,
17 but WITHOUT ANY WARRANTY; without even the implied warranty of
18 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 GNU General Public License for more details.
20
21 You should have received a copy of the GNU General Public License
22 along with this program; if not, write to the Free Software
23 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
24 */
25
26#ifndef V4L2_COMMON_H_
27#define V4L2_COMMON_H_
28
29/* VIDIOC_INT_AUDIO_CLOCK_FREQ */
30enum v4l2_audio_clock_freq {
31 V4L2_AUDCLK_32_KHZ = 32000,
32 V4L2_AUDCLK_441_KHZ = 44100,
33 V4L2_AUDCLK_48_KHZ = 48000,
34};
35
36/* VIDIOC_INT_G_REGISTER and VIDIOC_INT_S_REGISTER */
37struct v4l2_register {
38 u32 i2c_id; /* I2C driver ID of the I2C chip. 0 for the I2C adapter. */
39 unsigned long reg;
40 u32 val;
41};
42
43/* VIDIOC_INT_DECODE_VBI_LINE */
44struct v4l2_decode_vbi_line {
45 u32 is_second_field; /* Set to 0 for the first (odd) field,
46 set to 1 for the second (even) field. */
47 u8 *p; /* Pointer to the sliced VBI data from the decoder.
48 On exit points to the start of the payload. */
49 u32 line; /* Line number of the sliced VBI data (1-23) */
50 u32 type; /* VBI service type (V4L2_SLICED_*). 0 if no service found */
51};
52
53/* VIDIOC_INT_G_CHIP_IDENT: identifies the actual chip installed on the board */
54enum v4l2_chip_ident {
55 /* general idents: reserved range 0-49 */
56 V4L2_IDENT_UNKNOWN = 0,
57
58 /* module saa7115: reserved range 100-149 */
59 V4L2_IDENT_SAA7114 = 104,
60 V4L2_IDENT_SAA7115 = 105,
61
62 /* module saa7127: reserved range 150-199 */
63 V4L2_IDENT_SAA7127 = 157,
64 V4L2_IDENT_SAA7129 = 159,
65
66 /* module cx25840: reserved range 200-249 */
67 V4L2_IDENT_CX25840 = 240,
68 V4L2_IDENT_CX25841 = 241,
69 V4L2_IDENT_CX25842 = 242,
70 V4L2_IDENT_CX25843 = 243,
71};
72
73/* only implemented if CONFIG_VIDEO_ADV_DEBUG is defined */
74#define VIDIOC_INT_S_REGISTER _IOR ('d', 100, struct v4l2_register)
75#define VIDIOC_INT_G_REGISTER _IOWR('d', 101, struct v4l2_register)
76
77/* Reset the I2C chip */
78#define VIDIOC_INT_RESET _IO ('d', 102)
79
80/* Set the frequency of the audio clock output.
81 Used to slave an audio processor to the video decoder, ensuring that audio
82 and video remain synchronized. */
83#define VIDIOC_INT_AUDIO_CLOCK_FREQ _IOR ('d', 103, enum v4l2_audio_clock_freq)
84
85/* Video decoders that support sliced VBI need to implement this ioctl.
86 Field p of the v4l2_sliced_vbi_line struct is set to the start of the VBI
87 data that was generated by the decoder. The driver then parses the sliced
88 VBI data and sets the other fields in the struct accordingly. The pointer p
89 is updated to point to the start of the payload which can be copied
90 verbatim into the data field of the v4l2_sliced_vbi_data struct. If no
91 valid VBI data was found, then the type field is set to 0 on return. */
92#define VIDIOC_INT_DECODE_VBI_LINE _IOWR('d', 104, struct v4l2_decode_vbi_line)
93
94/* Used to generate VBI signals on a video signal. v4l2_sliced_vbi_data is
95 filled with the data packets that should be output. Note that if you set
96 the line field to 0, then that VBI signal is disabled. */
97#define VIDIOC_INT_S_VBI_DATA _IOW ('d', 105, struct v4l2_sliced_vbi_data)
98
99/* Used to obtain the sliced VBI packet from a readback register. Not all
100 video decoders support this. If no data is available because the readback
101 register contains invalid or erroneous data -EIO is returned. Note that
102 you must fill in the 'id' member and the 'field' member (to determine
103 whether CC data from the first or second field should be obtained). */
104#define VIDIOC_INT_G_VBI_DATA _IOWR('d', 106, struct v4l2_sliced_vbi_data *)
105
106/* Returns the chip identifier or V4L2_IDENT_UNKNOWN if no identification can
107 be made. */
108#define VIDIOC_INT_G_CHIP_IDENT _IOR ('d', 107, enum v4l2_chip_ident *)
109
110#endif /* V4L2_COMMON_H_ */