Magellan Linux

Contents of /trunk/kernel26-magellan/patches-2.6.20-r3/0101-2.6.20.2-all-fixes.patch

Parent Directory Parent Directory | Revision Log Revision Log


Revision 132 - (show annotations) (download)
Fri Apr 27 15:24:56 2007 UTC (17 years ago) by niro
File size: 151744 byte(s)
files for 2.6.20-r4

1 diff --git a/arch/i386/kernel/cpu/mtrr/if.c b/arch/i386/kernel/cpu/mtrr/if.c
2 index 5ae1705..590d99e 100644
3 --- a/arch/i386/kernel/cpu/mtrr/if.c
4 +++ b/arch/i386/kernel/cpu/mtrr/if.c
5 @@ -158,8 +158,9 @@ mtrr_ioctl(struct file *file, unsigned int cmd, unsigned long __arg)
6 struct mtrr_sentry sentry;
7 struct mtrr_gentry gentry;
8 void __user *arg = (void __user *) __arg;
9 + unsigned int compat_cmd = cmd;
10
11 - switch (cmd) {
12 + switch (compat_cmd) {
13 case MTRRIOC_ADD_ENTRY:
14 case MTRRIOC_SET_ENTRY:
15 case MTRRIOC_DEL_ENTRY:
16 @@ -177,14 +178,20 @@ mtrr_ioctl(struct file *file, unsigned int cmd, unsigned long __arg)
17 return -EFAULT;
18 break;
19 #ifdef CONFIG_COMPAT
20 - case MTRRIOC32_ADD_ENTRY:
21 - case MTRRIOC32_SET_ENTRY:
22 - case MTRRIOC32_DEL_ENTRY:
23 - case MTRRIOC32_KILL_ENTRY:
24 - case MTRRIOC32_ADD_PAGE_ENTRY:
25 - case MTRRIOC32_SET_PAGE_ENTRY:
26 - case MTRRIOC32_DEL_PAGE_ENTRY:
27 - case MTRRIOC32_KILL_PAGE_ENTRY: {
28 +#define MTRR_COMPAT_OP(op, type)\
29 + case MTRRIOC32_##op: \
30 + cmd = MTRRIOC_##op; \
31 + goto compat_get_##type
32 +
33 + MTRR_COMPAT_OP(ADD_ENTRY, sentry);
34 + MTRR_COMPAT_OP(SET_ENTRY, sentry);
35 + MTRR_COMPAT_OP(DEL_ENTRY, sentry);
36 + MTRR_COMPAT_OP(KILL_ENTRY, sentry);
37 + MTRR_COMPAT_OP(ADD_PAGE_ENTRY, sentry);
38 + MTRR_COMPAT_OP(SET_PAGE_ENTRY, sentry);
39 + MTRR_COMPAT_OP(DEL_PAGE_ENTRY, sentry);
40 + MTRR_COMPAT_OP(KILL_PAGE_ENTRY, sentry);
41 +compat_get_sentry: {
42 struct mtrr_sentry32 __user *s32 = (struct mtrr_sentry32 __user *)__arg;
43 err = get_user(sentry.base, &s32->base);
44 err |= get_user(sentry.size, &s32->size);
45 @@ -193,8 +200,9 @@ mtrr_ioctl(struct file *file, unsigned int cmd, unsigned long __arg)
46 return err;
47 break;
48 }
49 - case MTRRIOC32_GET_ENTRY:
50 - case MTRRIOC32_GET_PAGE_ENTRY: {
51 + MTRR_COMPAT_OP(GET_ENTRY, gentry);
52 + MTRR_COMPAT_OP(GET_PAGE_ENTRY, gentry);
53 +compat_get_gentry: {
54 struct mtrr_gentry32 __user *g32 = (struct mtrr_gentry32 __user *)__arg;
55 err = get_user(gentry.regnum, &g32->regnum);
56 err |= get_user(gentry.base, &g32->base);
57 @@ -204,6 +212,7 @@ mtrr_ioctl(struct file *file, unsigned int cmd, unsigned long __arg)
58 return err;
59 break;
60 }
61 +#undef MTRR_COMPAT_OP
62 #endif
63 }
64
65 @@ -287,7 +296,7 @@ mtrr_ioctl(struct file *file, unsigned int cmd, unsigned long __arg)
66 if (err)
67 return err;
68
69 - switch(cmd) {
70 + switch(compat_cmd) {
71 case MTRRIOC_GET_ENTRY:
72 case MTRRIOC_GET_PAGE_ENTRY:
73 if (copy_to_user(arg, &gentry, sizeof gentry))
74 diff --git a/arch/i386/kernel/signal.c b/arch/i386/kernel/signal.c
75 index 65d7620..f654505 100644
76 --- a/arch/i386/kernel/signal.c
77 +++ b/arch/i386/kernel/signal.c
78 @@ -21,6 +21,7 @@
79 #include <linux/suspend.h>
80 #include <linux/ptrace.h>
81 #include <linux/elf.h>
82 +#include <linux/binfmts.h>
83 #include <asm/processor.h>
84 #include <asm/ucontext.h>
85 #include <asm/uaccess.h>
86 @@ -349,7 +350,10 @@ static int setup_frame(int sig, struct k_sigaction *ka,
87 goto give_sigsegv;
88 }
89
90 - restorer = (void *)VDSO_SYM(&__kernel_sigreturn);
91 + if (current->binfmt->hasvdso)
92 + restorer = (void *)VDSO_SYM(&__kernel_sigreturn);
93 + else
94 + restorer = (void *)&frame->retcode;
95 if (ka->sa.sa_flags & SA_RESTORER)
96 restorer = ka->sa.sa_restorer;
97
98 diff --git a/arch/i386/kernel/sysenter.c b/arch/i386/kernel/sysenter.c
99 index 5da7442..666f70d 100644
100 --- a/arch/i386/kernel/sysenter.c
101 +++ b/arch/i386/kernel/sysenter.c
102 @@ -77,7 +77,7 @@ int __init sysenter_setup(void)
103 syscall_page = (void *)get_zeroed_page(GFP_ATOMIC);
104
105 #ifdef CONFIG_COMPAT_VDSO
106 - __set_fixmap(FIX_VDSO, __pa(syscall_page), PAGE_READONLY);
107 + __set_fixmap(FIX_VDSO, __pa(syscall_page), PAGE_READONLY_EXEC);
108 printk("Compat vDSO mapped to %08lx.\n", __fix_to_virt(FIX_VDSO));
109 #endif
110
111 diff --git a/arch/ia64/Kconfig b/arch/ia64/Kconfig
112 index fcacfe2..c085199 100644
113 --- a/arch/ia64/Kconfig
114 +++ b/arch/ia64/Kconfig
115 @@ -11,6 +11,7 @@ menu "Processor type and features"
116
117 config IA64
118 bool
119 + select ATA_NONSTANDARD if ATA
120 default y
121 help
122 The Itanium Processor Family is Intel's 64-bit successor to
123 diff --git a/arch/ia64/kernel/crash.c b/arch/ia64/kernel/crash.c
124 index bc2f64d..2018e62 100644
125 --- a/arch/ia64/kernel/crash.c
126 +++ b/arch/ia64/kernel/crash.c
127 @@ -79,6 +79,7 @@ crash_save_this_cpu()
128 final_note(buf);
129 }
130
131 +#ifdef CONFIG_SMP
132 static int
133 kdump_wait_cpu_freeze(void)
134 {
135 @@ -91,6 +92,7 @@ kdump_wait_cpu_freeze(void)
136 }
137 return 1;
138 }
139 +#endif
140
141 void
142 machine_crash_shutdown(struct pt_regs *pt)
143 @@ -132,11 +134,12 @@ kdump_cpu_freeze(struct unw_frame_info *info, void *arg)
144 atomic_inc(&kdump_cpu_freezed);
145 kdump_status[cpuid] = 1;
146 mb();
147 - if (cpuid == 0) {
148 - for (;;)
149 - cpu_relax();
150 - } else
151 +#ifdef CONFIG_HOTPLUG_CPU
152 + if (cpuid != 0)
153 ia64_jump_to_sal(&sal_boot_rendez_state[cpuid]);
154 +#endif
155 + for (;;)
156 + cpu_relax();
157 }
158
159 static int
160 diff --git a/arch/ia64/kernel/machine_kexec.c b/arch/ia64/kernel/machine_kexec.c
161 index e2ccc9f..7141795 100644
162 --- a/arch/ia64/kernel/machine_kexec.c
163 +++ b/arch/ia64/kernel/machine_kexec.c
164 @@ -70,12 +70,14 @@ void machine_kexec_cleanup(struct kimage *image)
165
166 void machine_shutdown(void)
167 {
168 +#ifdef CONFIG_HOTPLUG_CPU
169 int cpu;
170
171 for_each_online_cpu(cpu) {
172 if (cpu != smp_processor_id())
173 cpu_down(cpu);
174 }
175 +#endif
176 kexec_disable_iosapic();
177 }
178
179 diff --git a/arch/m32r/kernel/process.c b/arch/m32r/kernel/process.c
180 index 44cbe0c..a689e29 100644
181 --- a/arch/m32r/kernel/process.c
182 +++ b/arch/m32r/kernel/process.c
183 @@ -174,7 +174,7 @@ void show_regs(struct pt_regs * regs)
184 regs->acc1h, regs->acc1l);
185 #elif defined(CONFIG_ISA_M32R2) || defined(CONFIG_ISA_M32R)
186 printk("ACCH[%08lx]:ACCL[%08lx]\n", \
187 - regs->acch, regs->accl);
188 + regs->acc0h, regs->acc0l);
189 #else
190 #error unknown isa configuration
191 #endif
192 diff --git a/arch/m32r/kernel/signal.c b/arch/m32r/kernel/signal.c
193 index 092ea86..4b15605 100644
194 --- a/arch/m32r/kernel/signal.c
195 +++ b/arch/m32r/kernel/signal.c
196 @@ -109,19 +109,10 @@ restore_sigcontext(struct pt_regs *regs, struct sigcontext __user *sc,
197 COPY(r10);
198 COPY(r11);
199 COPY(r12);
200 -#if defined(CONFIG_ISA_M32R2) && defined(CONFIG_ISA_DSP_LEVEL2)
201 COPY(acc0h);
202 COPY(acc0l);
203 - COPY(acc1h);
204 - COPY(acc1l);
205 -#elif defined(CONFIG_ISA_M32R2) || defined(CONFIG_ISA_M32R)
206 - COPY(acch);
207 - COPY(accl);
208 - COPY(dummy_acc1h);
209 - COPY(dummy_acc1l);
210 -#else
211 -#error unknown isa configuration
212 -#endif
213 + COPY(acc1h); /* ISA_DSP_LEVEL2 only */
214 + COPY(acc1l); /* ISA_DSP_LEVEL2 only */
215 COPY(psw);
216 COPY(bpc);
217 COPY(bbpsw);
218 @@ -196,19 +187,10 @@ setup_sigcontext(struct sigcontext __user *sc, struct pt_regs *regs,
219 COPY(r10);
220 COPY(r11);
221 COPY(r12);
222 -#if defined(CONFIG_ISA_M32R2) && defined(CONFIG_ISA_DSP_LEVEL2)
223 COPY(acc0h);
224 COPY(acc0l);
225 - COPY(acc1h);
226 - COPY(acc1l);
227 -#elif defined(CONFIG_ISA_M32R2) || defined(CONFIG_ISA_M32R)
228 - COPY(acch);
229 - COPY(accl);
230 - COPY(dummy_acc1h);
231 - COPY(dummy_acc1l);
232 -#else
233 -#error unknown isa configuration
234 -#endif
235 + COPY(acc1h); /* ISA_DSP_LEVEL2 only */
236 + COPY(acc1l); /* ISA_DSP_LEVEL2 only */
237 COPY(psw);
238 COPY(bpc);
239 COPY(bbpsw);
240 diff --git a/arch/powerpc/kernel/head_64.S b/arch/powerpc/kernel/head_64.S
241 index 71b1fe5..97cedcd 100644
242 --- a/arch/powerpc/kernel/head_64.S
243 +++ b/arch/powerpc/kernel/head_64.S
244 @@ -613,7 +613,7 @@ system_call_pSeries:
245 /*** pSeries interrupt support ***/
246
247 /* moved from 0xf00 */
248 - MASKABLE_EXCEPTION_PSERIES(., performance_monitor)
249 + STD_EXCEPTION_PSERIES(., performance_monitor)
250
251 /*
252 * An interrupt came in while soft-disabled; clear EE in SRR1,
253 diff --git a/arch/ppc/kernel/ppc_ksyms.c b/arch/ppc/kernel/ppc_ksyms.c
254 index c8b65ca..6d9857c 100644
255 --- a/arch/ppc/kernel/ppc_ksyms.c
256 +++ b/arch/ppc/kernel/ppc_ksyms.c
257 @@ -270,7 +270,7 @@ EXPORT_SYMBOL(mmu_hash_lock); /* For MOL */
258 extern long *intercept_table;
259 EXPORT_SYMBOL(intercept_table);
260 #endif /* CONFIG_PPC_STD_MMU */
261 -#if defined(CONFIG_40x) || defined(CONFIG_BOOKE)
262 +#ifdef CONFIG_PPC_DCR_NATIVE
263 EXPORT_SYMBOL(__mtdcr);
264 EXPORT_SYMBOL(__mfdcr);
265 #endif
266 diff --git a/arch/sparc64/kernel/of_device.c b/arch/sparc64/kernel/of_device.c
267 index b0f3e00..ad74e5e 100644
268 --- a/arch/sparc64/kernel/of_device.c
269 +++ b/arch/sparc64/kernel/of_device.c
270 @@ -708,7 +708,7 @@ static unsigned int __init pci_irq_swizzle(struct device_node *dp,
271 unsigned int irq)
272 {
273 struct linux_prom_pci_registers *regs;
274 - unsigned int devfn, slot, ret;
275 + unsigned int bus, devfn, slot, ret;
276
277 if (irq < 1 || irq > 4)
278 return irq;
279 @@ -717,10 +717,46 @@ static unsigned int __init pci_irq_swizzle(struct device_node *dp,
280 if (!regs)
281 return irq;
282
283 + bus = (regs->phys_hi >> 16) & 0xff;
284 devfn = (regs->phys_hi >> 8) & 0xff;
285 slot = (devfn >> 3) & 0x1f;
286
287 - ret = ((irq - 1 + (slot & 3)) & 3) + 1;
288 + if (pp->irq_trans) {
289 + /* Derived from Table 8-3, U2P User's Manual. This branch
290 + * is handling a PCI controller that lacks a proper set of
291 + * interrupt-map and interrupt-map-mask properties. The
292 + * Ultra-E450 is one example.
293 + *
294 + * The bit layout is BSSLL, where:
295 + * B: 0 on bus A, 1 on bus B
296 + * D: 2-bit slot number, derived from PCI device number as
297 + * (dev - 1) for bus A, or (dev - 2) for bus B
298 + * L: 2-bit line number
299 + *
300 + * Actually, more "portable" way to calculate the funky
301 + * slot number is to subtract pbm->pci_first_slot from the
302 + * device number, and that's exactly what the pre-OF
303 + * sparc64 code did, but we're building this stuff generically
304 + * using the OBP tree, not in the PCI controller layer.
305 + */
306 + if (bus & 0x80) {
307 + /* PBM-A */
308 + bus = 0x00;
309 + slot = (slot - 1) << 2;
310 + } else {
311 + /* PBM-B */
312 + bus = 0x10;
313 + slot = (slot - 2) << 2;
314 + }
315 + irq -= 1;
316 +
317 + ret = (bus | slot | irq);
318 + } else {
319 + /* Going through a PCI-PCI bridge that lacks a set of
320 + * interrupt-map and interrupt-map-mask properties.
321 + */
322 + ret = ((irq - 1 + (slot & 3)) & 3) + 1;
323 + }
324
325 return ret;
326 }
327 diff --git a/arch/um/os-Linux/sigio.c b/arch/um/os-Linux/sigio.c
328 index 925a652..b2e1fd8 100644
329 --- a/arch/um/os-Linux/sigio.c
330 +++ b/arch/um/os-Linux/sigio.c
331 @@ -97,20 +97,22 @@ static int write_sigio_thread(void *unused)
332
333 static int need_poll(struct pollfds *polls, int n)
334 {
335 - if(n <= polls->size){
336 - polls->used = n;
337 + struct pollfd *new;
338 +
339 + if(n <= polls->size)
340 return 0;
341 - }
342 - kfree(polls->poll);
343 - polls->poll = um_kmalloc_atomic(n * sizeof(struct pollfd));
344 - if(polls->poll == NULL){
345 +
346 + new = um_kmalloc_atomic(n * sizeof(struct pollfd));
347 + if(new == NULL){
348 printk("need_poll : failed to allocate new pollfds\n");
349 - polls->size = 0;
350 - polls->used = 0;
351 return -ENOMEM;
352 }
353 +
354 + memcpy(new, polls->poll, polls->used * sizeof(struct pollfd));
355 + kfree(polls->poll);
356 +
357 + polls->poll = new;
358 polls->size = n;
359 - polls->used = n;
360 return 0;
361 }
362
363 @@ -171,15 +173,15 @@ int add_sigio_fd(int fd)
364 goto out;
365 }
366
367 - n = current_poll.used + 1;
368 - err = need_poll(&next_poll, n);
369 + n = current_poll.used;
370 + err = need_poll(&next_poll, n + 1);
371 if(err)
372 goto out;
373
374 - for(i = 0; i < current_poll.used; i++)
375 - next_poll.poll[i] = current_poll.poll[i];
376 -
377 - next_poll.poll[n - 1] = *p;
378 + memcpy(next_poll.poll, current_poll.poll,
379 + current_poll.used * sizeof(struct pollfd));
380 + next_poll.poll[n] = *p;
381 + next_poll.used = n + 1;
382 update_thread();
383 out:
384 sigio_unlock();
385 @@ -214,6 +216,7 @@ int ignore_sigio_fd(int fd)
386 if(p->fd != fd)
387 next_poll.poll[n++] = *p;
388 }
389 + next_poll.used = current_poll.used - 1;
390
391 update_thread();
392 out:
393 @@ -331,10 +334,9 @@ void maybe_sigio_broken(int fd, int read)
394
395 sigio_lock();
396 err = need_poll(&all_sigio_fds, all_sigio_fds.used + 1);
397 - if(err){
398 - printk("maybe_sigio_broken - failed to add pollfd\n");
399 + if(err)
400 goto out;
401 - }
402 +
403 all_sigio_fds.poll[all_sigio_fds.used++] =
404 ((struct pollfd) { .fd = fd,
405 .events = read ? POLLIN : POLLOUT,
406 diff --git a/arch/x86_64/ia32/ia32_signal.c b/arch/x86_64/ia32/ia32_signal.c
407 index ff499ef..c7beadf 100644
408 --- a/arch/x86_64/ia32/ia32_signal.c
409 +++ b/arch/x86_64/ia32/ia32_signal.c
410 @@ -21,6 +21,7 @@
411 #include <linux/stddef.h>
412 #include <linux/personality.h>
413 #include <linux/compat.h>
414 +#include <linux/binfmts.h>
415 #include <asm/ucontext.h>
416 #include <asm/uaccess.h>
417 #include <asm/i387.h>
418 @@ -449,7 +450,11 @@ int ia32_setup_frame(int sig, struct k_sigaction *ka,
419
420 /* Return stub is in 32bit vsyscall page */
421 {
422 - void __user *restorer = VSYSCALL32_SIGRETURN;
423 + void __user *restorer;
424 + if (current->binfmt->hasvdso)
425 + restorer = VSYSCALL32_SIGRETURN;
426 + else
427 + restorer = (void *)&frame->retcode;
428 if (ka->sa.sa_flags & SA_RESTORER)
429 restorer = ka->sa.sa_restorer;
430 err |= __put_user(ptr_to_compat(restorer), &frame->pretcode);
431 diff --git a/arch/x86_64/ia32/ptrace32.c b/arch/x86_64/ia32/ptrace32.c
432 index 04566fe..4de3a54 100644
433 --- a/arch/x86_64/ia32/ptrace32.c
434 +++ b/arch/x86_64/ia32/ptrace32.c
435 @@ -243,6 +243,7 @@ asmlinkage long sys32_ptrace(long request, u32 pid, u32 addr, u32 data)
436 case PTRACE_SINGLESTEP:
437 case PTRACE_DETACH:
438 case PTRACE_SYSCALL:
439 + case PTRACE_OLDSETOPTIONS:
440 case PTRACE_SETOPTIONS:
441 case PTRACE_SET_THREAD_AREA:
442 case PTRACE_GET_THREAD_AREA:
443 diff --git a/arch/x86_64/kernel/irq.c b/arch/x86_64/kernel/irq.c
444 index 0c06af6..3bc30d2 100644
445 --- a/arch/x86_64/kernel/irq.c
446 +++ b/arch/x86_64/kernel/irq.c
447 @@ -18,6 +18,7 @@
448 #include <asm/uaccess.h>
449 #include <asm/io_apic.h>
450 #include <asm/idle.h>
451 +#include <asm/smp.h>
452
453 atomic_t irq_err_count;
454
455 @@ -120,9 +121,14 @@ asmlinkage unsigned int do_IRQ(struct pt_regs *regs)
456
457 if (likely(irq < NR_IRQS))
458 generic_handle_irq(irq);
459 - else if (printk_ratelimit())
460 - printk(KERN_EMERG "%s: %d.%d No irq handler for vector\n",
461 - __func__, smp_processor_id(), vector);
462 + else {
463 + if (!disable_apic)
464 + ack_APIC_irq();
465 +
466 + if (printk_ratelimit())
467 + printk(KERN_EMERG "%s: %d.%d No irq handler for vector\n",
468 + __func__, smp_processor_id(), vector);
469 + }
470
471 irq_exit();
472
473 diff --git a/block/ll_rw_blk.c b/block/ll_rw_blk.c
474 index fb67897..38c293b 100644
475 --- a/block/ll_rw_blk.c
476 +++ b/block/ll_rw_blk.c
477 @@ -1264,7 +1264,7 @@ new_hw_segment:
478 bio->bi_hw_segments = nr_hw_segs;
479 bio->bi_flags |= (1 << BIO_SEG_VALID);
480 }
481 -
482 +EXPORT_SYMBOL(blk_recount_segments);
483
484 static int blk_phys_contig_segment(request_queue_t *q, struct bio *bio,
485 struct bio *nxt)
486 diff --git a/drivers/Makefile b/drivers/Makefile
487 index 0dd96d1..f28dcb4 100644
488 --- a/drivers/Makefile
489 +++ b/drivers/Makefile
490 @@ -30,7 +30,7 @@ obj-$(CONFIG_PARPORT) += parport/
491 obj-y += base/ block/ misc/ mfd/ net/ media/
492 obj-$(CONFIG_NUBUS) += nubus/
493 obj-$(CONFIG_ATM) += atm/
494 -obj-$(CONFIG_PPC_PMAC) += macintosh/
495 +obj-y += macintosh/
496 obj-$(CONFIG_IDE) += ide/
497 obj-$(CONFIG_FC4) += fc4/
498 obj-$(CONFIG_SCSI) += scsi/
499 diff --git a/drivers/ata/ahci.c b/drivers/ata/ahci.c
500 index 48616c6..dc2c082 100644
501 --- a/drivers/ata/ahci.c
502 +++ b/drivers/ata/ahci.c
503 @@ -225,10 +225,12 @@ static void ahci_thaw(struct ata_port *ap);
504 static void ahci_error_handler(struct ata_port *ap);
505 static void ahci_vt8251_error_handler(struct ata_port *ap);
506 static void ahci_post_internal_cmd(struct ata_queued_cmd *qc);
507 +#ifdef CONFIG_PM
508 static int ahci_port_suspend(struct ata_port *ap, pm_message_t mesg);
509 static int ahci_port_resume(struct ata_port *ap);
510 static int ahci_pci_device_suspend(struct pci_dev *pdev, pm_message_t mesg);
511 static int ahci_pci_device_resume(struct pci_dev *pdev);
512 +#endif
513 static void ahci_remove_one (struct pci_dev *pdev);
514
515 static struct scsi_host_template ahci_sht = {
516 @@ -248,8 +250,10 @@ static struct scsi_host_template ahci_sht = {
517 .slave_configure = ata_scsi_slave_config,
518 .slave_destroy = ata_scsi_slave_destroy,
519 .bios_param = ata_std_bios_param,
520 +#ifdef CONFIG_PM
521 .suspend = ata_scsi_device_suspend,
522 .resume = ata_scsi_device_resume,
523 +#endif
524 };
525
526 static const struct ata_port_operations ahci_ops = {
527 @@ -276,8 +280,10 @@ static const struct ata_port_operations ahci_ops = {
528 .error_handler = ahci_error_handler,
529 .post_internal_cmd = ahci_post_internal_cmd,
530
531 +#ifdef CONFIG_PM
532 .port_suspend = ahci_port_suspend,
533 .port_resume = ahci_port_resume,
534 +#endif
535
536 .port_start = ahci_port_start,
537 .port_stop = ahci_port_stop,
538 @@ -307,8 +313,10 @@ static const struct ata_port_operations ahci_vt8251_ops = {
539 .error_handler = ahci_vt8251_error_handler,
540 .post_internal_cmd = ahci_post_internal_cmd,
541
542 +#ifdef CONFIG_PM
543 .port_suspend = ahci_port_suspend,
544 .port_resume = ahci_port_resume,
545 +#endif
546
547 .port_start = ahci_port_start,
548 .port_stop = ahci_port_stop,
549 @@ -441,8 +449,10 @@ static struct pci_driver ahci_pci_driver = {
550 .name = DRV_NAME,
551 .id_table = ahci_pci_tbl,
552 .probe = ahci_init_one,
553 +#ifdef CONFIG_PM
554 .suspend = ahci_pci_device_suspend,
555 .resume = ahci_pci_device_resume,
556 +#endif
557 .remove = ahci_remove_one,
558 };
559
560 @@ -587,6 +597,7 @@ static void ahci_power_up(void __iomem *port_mmio, u32 cap)
561 writel(cmd | PORT_CMD_ICC_ACTIVE, port_mmio + PORT_CMD);
562 }
563
564 +#ifdef CONFIG_PM
565 static void ahci_power_down(void __iomem *port_mmio, u32 cap)
566 {
567 u32 cmd, scontrol;
568 @@ -604,6 +615,7 @@ static void ahci_power_down(void __iomem *port_mmio, u32 cap)
569 cmd &= ~PORT_CMD_SPIN_UP;
570 writel(cmd, port_mmio + PORT_CMD);
571 }
572 +#endif
573
574 static void ahci_init_port(void __iomem *port_mmio, u32 cap,
575 dma_addr_t cmd_slot_dma, dma_addr_t rx_fis_dma)
576 @@ -1336,6 +1348,7 @@ static void ahci_post_internal_cmd(struct ata_queued_cmd *qc)
577 }
578 }
579
580 +#ifdef CONFIG_PM
581 static int ahci_port_suspend(struct ata_port *ap, pm_message_t mesg)
582 {
583 struct ahci_host_priv *hpriv = ap->host->private_data;
584 @@ -1412,6 +1425,7 @@ static int ahci_pci_device_resume(struct pci_dev *pdev)
585
586 return 0;
587 }
588 +#endif
589
590 static int ahci_port_start(struct ata_port *ap)
591 {
592 diff --git a/drivers/ata/ata_generic.c b/drivers/ata/ata_generic.c
593 index 24af560..91ccc20 100644
594 --- a/drivers/ata/ata_generic.c
595 +++ b/drivers/ata/ata_generic.c
596 @@ -119,8 +119,10 @@ static struct scsi_host_template generic_sht = {
597 .slave_configure = ata_scsi_slave_config,
598 .slave_destroy = ata_scsi_slave_destroy,
599 .bios_param = ata_std_bios_param,
600 +#ifdef CONFIG_PM
601 .resume = ata_scsi_device_resume,
602 .suspend = ata_scsi_device_suspend,
603 +#endif
604 };
605
606 static struct ata_port_operations generic_port_ops = {
607 @@ -230,8 +232,10 @@ static struct pci_driver ata_generic_pci_driver = {
608 .id_table = ata_generic,
609 .probe = ata_generic_init_one,
610 .remove = ata_pci_remove_one,
611 +#ifdef CONFIG_PM
612 .suspend = ata_pci_device_suspend,
613 .resume = ata_pci_device_resume,
614 +#endif
615 };
616
617 static int __init ata_generic_init(void)
618 diff --git a/drivers/ata/ata_piix.c b/drivers/ata/ata_piix.c
619 index 47701b2..57c0db3 100644
620 --- a/drivers/ata/ata_piix.c
621 +++ b/drivers/ata/ata_piix.c
622 @@ -255,8 +255,10 @@ static struct pci_driver piix_pci_driver = {
623 .id_table = piix_pci_tbl,
624 .probe = piix_init_one,
625 .remove = ata_pci_remove_one,
626 +#ifdef CONFIG_PM
627 .suspend = ata_pci_device_suspend,
628 .resume = ata_pci_device_resume,
629 +#endif
630 };
631
632 static struct scsi_host_template piix_sht = {
633 @@ -275,8 +277,10 @@ static struct scsi_host_template piix_sht = {
634 .slave_configure = ata_scsi_slave_config,
635 .slave_destroy = ata_scsi_slave_destroy,
636 .bios_param = ata_std_bios_param,
637 +#ifdef CONFIG_PM
638 .resume = ata_scsi_device_resume,
639 .suspend = ata_scsi_device_suspend,
640 +#endif
641 };
642
643 static const struct ata_port_operations piix_pata_ops = {
644 diff --git a/drivers/ata/pata_ali.c b/drivers/ata/pata_ali.c
645 index c5d61d1..765c932 100644
646 --- a/drivers/ata/pata_ali.c
647 +++ b/drivers/ata/pata_ali.c
648 @@ -345,8 +345,10 @@ static struct scsi_host_template ali_sht = {
649 .slave_configure = ata_scsi_slave_config,
650 .slave_destroy = ata_scsi_slave_destroy,
651 .bios_param = ata_std_bios_param,
652 +#ifdef CONFIG_PM
653 .resume = ata_scsi_device_resume,
654 .suspend = ata_scsi_device_suspend,
655 +#endif
656 };
657
658 /*
659 @@ -667,11 +669,13 @@ static int ali_init_one(struct pci_dev *pdev, const struct pci_device_id *id)
660 return ata_pci_init_one(pdev, port_info, 2);
661 }
662
663 +#ifdef CONFIG_PM
664 static int ali_reinit_one(struct pci_dev *pdev)
665 {
666 ali_init_chipset(pdev);
667 return ata_pci_device_resume(pdev);
668 }
669 +#endif
670
671 static const struct pci_device_id ali[] = {
672 { PCI_VDEVICE(AL, PCI_DEVICE_ID_AL_M5228), },
673 @@ -685,8 +689,10 @@ static struct pci_driver ali_pci_driver = {
674 .id_table = ali,
675 .probe = ali_init_one,
676 .remove = ata_pci_remove_one,
677 +#ifdef CONFIG_PM
678 .suspend = ata_pci_device_suspend,
679 .resume = ali_reinit_one,
680 +#endif
681 };
682
683 static int __init ali_init(void)
684 diff --git a/drivers/ata/pata_amd.c b/drivers/ata/pata_amd.c
685 index a6b3300..f7c493b 100644
686 --- a/drivers/ata/pata_amd.c
687 +++ b/drivers/ata/pata_amd.c
688 @@ -128,7 +128,7 @@ static void timing_setup(struct ata_port *ap, struct ata_device *adev, int offse
689
690 static int amd_pre_reset(struct ata_port *ap)
691 {
692 - static const u32 bitmask[2] = {0x03, 0xC0};
693 + static const u32 bitmask[2] = {0x03, 0x0C};
694 static const struct pci_bits amd_enable_bits[] = {
695 { 0x40, 1, 0x02, 0x02 },
696 { 0x40, 1, 0x01, 0x01 }
697 @@ -247,7 +247,7 @@ static void amd133_set_dmamode(struct ata_port *ap, struct ata_device *adev)
698 */
699
700 static int nv_pre_reset(struct ata_port *ap) {
701 - static const u8 bitmask[2] = {0x03, 0xC0};
702 + static const u8 bitmask[2] = {0x03, 0x0C};
703 static const struct pci_bits nv_enable_bits[] = {
704 { 0x50, 1, 0x02, 0x02 },
705 { 0x50, 1, 0x01, 0x01 }
706 @@ -334,8 +334,10 @@ static struct scsi_host_template amd_sht = {
707 .slave_configure = ata_scsi_slave_config,
708 .slave_destroy = ata_scsi_slave_destroy,
709 .bios_param = ata_std_bios_param,
710 +#ifdef CONFIG_PM
711 .resume = ata_scsi_device_resume,
712 .suspend = ata_scsi_device_suspend,
713 +#endif
714 };
715
716 static struct ata_port_operations amd33_port_ops = {
717 @@ -663,6 +665,7 @@ static int amd_init_one(struct pci_dev *pdev, const struct pci_device_id *id)
718 return ata_pci_init_one(pdev, port_info, 2);
719 }
720
721 +#ifdef CONFIG_PM
722 static int amd_reinit_one(struct pci_dev *pdev)
723 {
724 if (pdev->vendor == PCI_VENDOR_ID_AMD) {
725 @@ -679,6 +682,7 @@ static int amd_reinit_one(struct pci_dev *pdev)
726 }
727 return ata_pci_device_resume(pdev);
728 }
729 +#endif
730
731 static const struct pci_device_id amd[] = {
732 { PCI_VDEVICE(AMD, PCI_DEVICE_ID_AMD_COBRA_7401), 0 },
733 @@ -708,8 +712,10 @@ static struct pci_driver amd_pci_driver = {
734 .id_table = amd,
735 .probe = amd_init_one,
736 .remove = ata_pci_remove_one,
737 +#ifdef CONFIG_PM
738 .suspend = ata_pci_device_suspend,
739 .resume = amd_reinit_one,
740 +#endif
741 };
742
743 static int __init amd_init(void)
744 diff --git a/drivers/ata/pata_atiixp.c b/drivers/ata/pata_atiixp.c
745 index 504e1db..b50ebb6 100644
746 --- a/drivers/ata/pata_atiixp.c
747 +++ b/drivers/ata/pata_atiixp.c
748 @@ -224,8 +224,10 @@ static struct scsi_host_template atiixp_sht = {
749 .slave_configure = ata_scsi_slave_config,
750 .slave_destroy = ata_scsi_slave_destroy,
751 .bios_param = ata_std_bios_param,
752 +#ifdef CONFIG_PM
753 .resume = ata_scsi_device_resume,
754 .suspend = ata_scsi_device_suspend,
755 +#endif
756 };
757
758 static struct ata_port_operations atiixp_port_ops = {
759 @@ -290,8 +292,10 @@ static struct pci_driver atiixp_pci_driver = {
760 .id_table = atiixp,
761 .probe = atiixp_init_one,
762 .remove = ata_pci_remove_one,
763 +#ifdef CONFIG_PM
764 .resume = ata_pci_device_resume,
765 .suspend = ata_pci_device_suspend,
766 +#endif
767 };
768
769 static int __init atiixp_init(void)
770 diff --git a/drivers/ata/pata_cmd64x.c b/drivers/ata/pata_cmd64x.c
771 index 449162c..90ff580 100644
772 --- a/drivers/ata/pata_cmd64x.c
773 +++ b/drivers/ata/pata_cmd64x.c
774 @@ -285,8 +285,10 @@ static struct scsi_host_template cmd64x_sht = {
775 .slave_configure = ata_scsi_slave_config,
776 .slave_destroy = ata_scsi_slave_destroy,
777 .bios_param = ata_std_bios_param,
778 +#ifdef CONFIG_PM
779 .resume = ata_scsi_device_resume,
780 .suspend = ata_scsi_device_suspend,
781 +#endif
782 };
783
784 static struct ata_port_operations cmd64x_port_ops = {
785 @@ -479,6 +481,7 @@ static int cmd64x_init_one(struct pci_dev *pdev, const struct pci_device_id *id)
786 return ata_pci_init_one(pdev, port_info, 2);
787 }
788
789 +#ifdef CONFIG_PM
790 static int cmd64x_reinit_one(struct pci_dev *pdev)
791 {
792 u8 mrdmode;
793 @@ -492,6 +495,7 @@ static int cmd64x_reinit_one(struct pci_dev *pdev)
794 #endif
795 return ata_pci_device_resume(pdev);
796 }
797 +#endif
798
799 static const struct pci_device_id cmd64x[] = {
800 { PCI_VDEVICE(CMD, PCI_DEVICE_ID_CMD_643), 0 },
801 @@ -507,8 +511,10 @@ static struct pci_driver cmd64x_pci_driver = {
802 .id_table = cmd64x,
803 .probe = cmd64x_init_one,
804 .remove = ata_pci_remove_one,
805 +#ifdef CONFIG_PM
806 .suspend = ata_pci_device_suspend,
807 .resume = cmd64x_reinit_one,
808 +#endif
809 };
810
811 static int __init cmd64x_init(void)
812 diff --git a/drivers/ata/pata_cs5520.c b/drivers/ata/pata_cs5520.c
813 index 9f165a8..383975c 100644
814 --- a/drivers/ata/pata_cs5520.c
815 +++ b/drivers/ata/pata_cs5520.c
816 @@ -167,8 +167,10 @@ static struct scsi_host_template cs5520_sht = {
817 .slave_configure = ata_scsi_slave_config,
818 .slave_destroy = ata_scsi_slave_destroy,
819 .bios_param = ata_std_bios_param,
820 +#ifdef CONFIG_PM
821 .resume = ata_scsi_device_resume,
822 .suspend = ata_scsi_device_suspend,
823 +#endif
824 };
825
826 static struct ata_port_operations cs5520_port_ops = {
827 @@ -298,6 +300,7 @@ static void __devexit cs5520_remove_one(struct pci_dev *pdev)
828 dev_set_drvdata(dev, NULL);
829 }
830
831 +#ifdef CONFIG_PM
832 /**
833 * cs5520_reinit_one - device resume
834 * @pdev: PCI device
835 @@ -314,6 +317,8 @@ static int cs5520_reinit_one(struct pci_dev *pdev)
836 pci_write_config_byte(pdev, 0x60, pcicfg | 0x40);
837 return ata_pci_device_resume(pdev);
838 }
839 +#endif
840 +
841 /* For now keep DMA off. We can set it for all but A rev CS5510 once the
842 core ATA code can handle it */
843
844 @@ -329,8 +334,10 @@ static struct pci_driver cs5520_pci_driver = {
845 .id_table = pata_cs5520,
846 .probe = cs5520_init_one,
847 .remove = cs5520_remove_one,
848 +#ifdef CONFIG_PM
849 .suspend = ata_pci_device_suspend,
850 .resume = cs5520_reinit_one,
851 +#endif
852 };
853
854 static int __init cs5520_init(void)
855 diff --git a/drivers/ata/pata_cs5530.c b/drivers/ata/pata_cs5530.c
856 index b1ca207..fddef81 100644
857 --- a/drivers/ata/pata_cs5530.c
858 +++ b/drivers/ata/pata_cs5530.c
859 @@ -181,8 +181,10 @@ static struct scsi_host_template cs5530_sht = {
860 .slave_configure = ata_scsi_slave_config,
861 .slave_destroy = ata_scsi_slave_destroy,
862 .bios_param = ata_std_bios_param,
863 +#ifdef CONFIG_PM
864 .resume = ata_scsi_device_resume,
865 .suspend = ata_scsi_device_suspend,
866 +#endif
867 };
868
869 static struct ata_port_operations cs5530_port_ops = {
870 @@ -369,6 +371,7 @@ static int cs5530_init_one(struct pci_dev *pdev, const struct pci_device_id *id)
871 return ata_pci_init_one(pdev, port_info, 2);
872 }
873
874 +#ifdef CONFIG_PM
875 static int cs5530_reinit_one(struct pci_dev *pdev)
876 {
877 /* If we fail on resume we are doomed */
878 @@ -376,6 +379,7 @@ static int cs5530_reinit_one(struct pci_dev *pdev)
879 BUG();
880 return ata_pci_device_resume(pdev);
881 }
882 +#endif
883
884 static const struct pci_device_id cs5530[] = {
885 { PCI_VDEVICE(CYRIX, PCI_DEVICE_ID_CYRIX_5530_IDE), },
886 @@ -388,8 +392,10 @@ static struct pci_driver cs5530_pci_driver = {
887 .id_table = cs5530,
888 .probe = cs5530_init_one,
889 .remove = ata_pci_remove_one,
890 +#ifdef CONFIG_PM
891 .suspend = ata_pci_device_suspend,
892 .resume = cs5530_reinit_one,
893 +#endif
894 };
895
896 static int __init cs5530_init(void)
897 diff --git a/drivers/ata/pata_cs5535.c b/drivers/ata/pata_cs5535.c
898 index e3efec4..80d0ed1 100644
899 --- a/drivers/ata/pata_cs5535.c
900 +++ b/drivers/ata/pata_cs5535.c
901 @@ -185,8 +185,10 @@ static struct scsi_host_template cs5535_sht = {
902 .slave_configure = ata_scsi_slave_config,
903 .slave_destroy = ata_scsi_slave_destroy,
904 .bios_param = ata_std_bios_param,
905 +#ifdef CONFIG_PM
906 .resume = ata_scsi_device_resume,
907 .suspend = ata_scsi_device_suspend,
908 +#endif
909 };
910
911 static struct ata_port_operations cs5535_port_ops = {
912 @@ -270,8 +272,10 @@ static struct pci_driver cs5535_pci_driver = {
913 .id_table = cs5535,
914 .probe = cs5535_init_one,
915 .remove = ata_pci_remove_one,
916 +#ifdef CONFIG_PM
917 .suspend = ata_pci_device_suspend,
918 .resume = ata_pci_device_resume,
919 +#endif
920 };
921
922 static int __init cs5535_init(void)
923 diff --git a/drivers/ata/pata_cypress.c b/drivers/ata/pata_cypress.c
924 index e2a9569..0da1715 100644
925 --- a/drivers/ata/pata_cypress.c
926 +++ b/drivers/ata/pata_cypress.c
927 @@ -136,8 +136,10 @@ static struct scsi_host_template cy82c693_sht = {
928 .slave_configure = ata_scsi_slave_config,
929 .slave_destroy = ata_scsi_slave_destroy,
930 .bios_param = ata_std_bios_param,
931 +#ifdef CONFIG_PM
932 .resume = ata_scsi_device_resume,
933 .suspend = ata_scsi_device_suspend,
934 +#endif
935 };
936
937 static struct ata_port_operations cy82c693_port_ops = {
938 @@ -206,8 +208,10 @@ static struct pci_driver cy82c693_pci_driver = {
939 .id_table = cy82c693,
940 .probe = cy82c693_init_one,
941 .remove = ata_pci_remove_one,
942 +#ifdef CONFIG_PM
943 .suspend = ata_pci_device_suspend,
944 .resume = ata_pci_device_resume,
945 +#endif
946 };
947
948 static int __init cy82c693_init(void)
949 diff --git a/drivers/ata/pata_efar.c b/drivers/ata/pata_efar.c
950 index edf8a63..4d4575e 100644
951 --- a/drivers/ata/pata_efar.c
952 +++ b/drivers/ata/pata_efar.c
953 @@ -234,8 +234,10 @@ static struct scsi_host_template efar_sht = {
954 .slave_configure = ata_scsi_slave_config,
955 .slave_destroy = ata_scsi_slave_destroy,
956 .bios_param = ata_std_bios_param,
957 +#ifdef CONFIG_PM
958 .resume = ata_scsi_device_resume,
959 .suspend = ata_scsi_device_suspend,
960 +#endif
961 };
962
963 static const struct ata_port_operations efar_ops = {
964 @@ -317,8 +319,10 @@ static struct pci_driver efar_pci_driver = {
965 .id_table = efar_pci_tbl,
966 .probe = efar_init_one,
967 .remove = ata_pci_remove_one,
968 +#ifdef CONFIG_PM
969 .suspend = ata_pci_device_suspend,
970 .resume = ata_pci_device_resume,
971 +#endif
972 };
973
974 static int __init efar_init(void)
975 diff --git a/drivers/ata/pata_hpt366.c b/drivers/ata/pata_hpt366.c
976 index 2663599..878696a 100644
977 --- a/drivers/ata/pata_hpt366.c
978 +++ b/drivers/ata/pata_hpt366.c
979 @@ -338,8 +338,10 @@ static struct scsi_host_template hpt36x_sht = {
980 .slave_configure = ata_scsi_slave_config,
981 .slave_destroy = ata_scsi_slave_destroy,
982 .bios_param = ata_std_bios_param,
983 +#ifdef CONFIG_PM
984 .resume = ata_scsi_device_resume,
985 .suspend = ata_scsi_device_suspend,
986 +#endif
987 };
988
989 /*
990 @@ -467,12 +469,13 @@ static int hpt36x_init_one(struct pci_dev *dev, const struct pci_device_id *id)
991 return ata_pci_init_one(dev, port_info, 2);
992 }
993
994 +#ifdef CONFIG_PM
995 static int hpt36x_reinit_one(struct pci_dev *dev)
996 {
997 hpt36x_init_chipset(dev);
998 return ata_pci_device_resume(dev);
999 }
1000 -
1001 +#endif
1002
1003 static const struct pci_device_id hpt36x[] = {
1004 { PCI_VDEVICE(TTI, PCI_DEVICE_ID_TTI_HPT366), },
1005 @@ -484,8 +487,10 @@ static struct pci_driver hpt36x_pci_driver = {
1006 .id_table = hpt36x,
1007 .probe = hpt36x_init_one,
1008 .remove = ata_pci_remove_one,
1009 +#ifdef CONFIG_PM
1010 .suspend = ata_pci_device_suspend,
1011 .resume = hpt36x_reinit_one,
1012 +#endif
1013 };
1014
1015 static int __init hpt36x_init(void)
1016 diff --git a/drivers/ata/pata_hpt3x3.c b/drivers/ata/pata_hpt3x3.c
1017 index 5f1d385..f99c77c 100644
1018 --- a/drivers/ata/pata_hpt3x3.c
1019 +++ b/drivers/ata/pata_hpt3x3.c
1020 @@ -119,8 +119,10 @@ static struct scsi_host_template hpt3x3_sht = {
1021 .slave_configure = ata_scsi_slave_config,
1022 .slave_destroy = ata_scsi_slave_destroy,
1023 .bios_param = ata_std_bios_param,
1024 +#ifdef CONFIG_PM
1025 .resume = ata_scsi_device_resume,
1026 .suspend = ata_scsi_device_suspend,
1027 +#endif
1028 };
1029
1030 static struct ata_port_operations hpt3x3_port_ops = {
1031 @@ -206,11 +208,13 @@ static int hpt3x3_init_one(struct pci_dev *dev, const struct pci_device_id *id)
1032 return ata_pci_init_one(dev, port_info, 2);
1033 }
1034
1035 +#ifdef CONFIG_PM
1036 static int hpt3x3_reinit_one(struct pci_dev *dev)
1037 {
1038 hpt3x3_init_chipset(dev);
1039 return ata_pci_device_resume(dev);
1040 }
1041 +#endif
1042
1043 static const struct pci_device_id hpt3x3[] = {
1044 { PCI_VDEVICE(TTI, PCI_DEVICE_ID_TTI_HPT343), },
1045 @@ -223,8 +227,10 @@ static struct pci_driver hpt3x3_pci_driver = {
1046 .id_table = hpt3x3,
1047 .probe = hpt3x3_init_one,
1048 .remove = ata_pci_remove_one,
1049 +#ifdef CONFIG_PM
1050 .suspend = ata_pci_device_suspend,
1051 .resume = hpt3x3_reinit_one,
1052 +#endif
1053 };
1054
1055 static int __init hpt3x3_init(void)
1056 diff --git a/drivers/ata/pata_it821x.c b/drivers/ata/pata_it821x.c
1057 index e8afd48..7958177 100644
1058 --- a/drivers/ata/pata_it821x.c
1059 +++ b/drivers/ata/pata_it821x.c
1060 @@ -676,8 +676,10 @@ static struct scsi_host_template it821x_sht = {
1061 .slave_configure = ata_scsi_slave_config,
1062 .slave_destroy = ata_scsi_slave_destroy,
1063 .bios_param = ata_std_bios_param,
1064 +#ifdef CONFIG_PM
1065 .resume = ata_scsi_device_resume,
1066 .suspend = ata_scsi_device_suspend,
1067 +#endif
1068 };
1069
1070 static struct ata_port_operations it821x_smart_port_ops = {
1071 @@ -810,6 +812,7 @@ static int it821x_init_one(struct pci_dev *pdev, const struct pci_device_id *id)
1072 return ata_pci_init_one(pdev, port_info, 2);
1073 }
1074
1075 +#ifdef CONFIG_PM
1076 static int it821x_reinit_one(struct pci_dev *pdev)
1077 {
1078 /* Resume - turn raid back off if need be */
1079 @@ -817,6 +820,7 @@ static int it821x_reinit_one(struct pci_dev *pdev)
1080 it821x_disable_raid(pdev);
1081 return ata_pci_device_resume(pdev);
1082 }
1083 +#endif
1084
1085 static const struct pci_device_id it821x[] = {
1086 { PCI_VDEVICE(ITE, PCI_DEVICE_ID_ITE_8211), },
1087 @@ -830,8 +834,10 @@ static struct pci_driver it821x_pci_driver = {
1088 .id_table = it821x,
1089 .probe = it821x_init_one,
1090 .remove = ata_pci_remove_one,
1091 +#ifdef CONFIG_PM
1092 .suspend = ata_pci_device_suspend,
1093 .resume = it821x_reinit_one,
1094 +#endif
1095 };
1096
1097 static int __init it821x_init(void)
1098 diff --git a/drivers/ata/pata_jmicron.c b/drivers/ata/pata_jmicron.c
1099 index d50264a..9e4558a 100644
1100 --- a/drivers/ata/pata_jmicron.c
1101 +++ b/drivers/ata/pata_jmicron.c
1102 @@ -137,6 +137,10 @@ static struct scsi_host_template jmicron_sht = {
1103 .slave_destroy = ata_scsi_slave_destroy,
1104 /* Use standard CHS mapping rules */
1105 .bios_param = ata_std_bios_param,
1106 +#ifdef CONFIG_PM
1107 + .suspend = ata_scsi_device_suspend,
1108 + .resume = ata_scsi_device_resume,
1109 +#endif
1110 };
1111
1112 static const struct ata_port_operations jmicron_ops = {
1113 @@ -218,6 +222,7 @@ static int jmicron_init_one (struct pci_dev *pdev, const struct pci_device_id *i
1114 return ata_pci_init_one(pdev, port_info, 2);
1115 }
1116
1117 +#ifdef CONFIG_PM
1118 static int jmicron_reinit_one(struct pci_dev *pdev)
1119 {
1120 u32 reg;
1121 @@ -238,6 +243,7 @@ static int jmicron_reinit_one(struct pci_dev *pdev)
1122 }
1123 return ata_pci_device_resume(pdev);
1124 }
1125 +#endif
1126
1127 static const struct pci_device_id jmicron_pci_tbl[] = {
1128 { PCI_VDEVICE(JMICRON, PCI_DEVICE_ID_JMICRON_JMB361), 361},
1129 @@ -254,8 +260,10 @@ static struct pci_driver jmicron_pci_driver = {
1130 .id_table = jmicron_pci_tbl,
1131 .probe = jmicron_init_one,
1132 .remove = ata_pci_remove_one,
1133 +#ifdef CONFIG_PM
1134 .suspend = ata_pci_device_suspend,
1135 .resume = jmicron_reinit_one,
1136 +#endif
1137 };
1138
1139 static int __init jmicron_init(void)
1140 diff --git a/drivers/ata/pata_marvell.c b/drivers/ata/pata_marvell.c
1141 index 1c810ea..3d76e06 100644
1142 --- a/drivers/ata/pata_marvell.c
1143 +++ b/drivers/ata/pata_marvell.c
1144 @@ -103,8 +103,10 @@ static struct scsi_host_template marvell_sht = {
1145 .slave_destroy = ata_scsi_slave_destroy,
1146 /* Use standard CHS mapping rules */
1147 .bios_param = ata_std_bios_param,
1148 +#ifdef CONFIG_PM
1149 .resume = ata_scsi_device_resume,
1150 .suspend = ata_scsi_device_suspend,
1151 +#endif
1152 };
1153
1154 static const struct ata_port_operations marvell_ops = {
1155 @@ -199,8 +201,10 @@ static struct pci_driver marvell_pci_driver = {
1156 .id_table = marvell_pci_tbl,
1157 .probe = marvell_init_one,
1158 .remove = ata_pci_remove_one,
1159 +#ifdef CONFIG_PM
1160 .suspend = ata_pci_device_suspend,
1161 .resume = ata_pci_device_resume,
1162 +#endif
1163 };
1164
1165 static int __init marvell_init(void)
1166 diff --git a/drivers/ata/pata_mpiix.c b/drivers/ata/pata_mpiix.c
1167 index 4ccca93..c707320 100644
1168 --- a/drivers/ata/pata_mpiix.c
1169 +++ b/drivers/ata/pata_mpiix.c
1170 @@ -167,8 +167,10 @@ static struct scsi_host_template mpiix_sht = {
1171 .slave_configure = ata_scsi_slave_config,
1172 .slave_destroy = ata_scsi_slave_destroy,
1173 .bios_param = ata_std_bios_param,
1174 +#ifdef CONFIG_PM
1175 .resume = ata_scsi_device_resume,
1176 .suspend = ata_scsi_device_suspend,
1177 +#endif
1178 };
1179
1180 static struct ata_port_operations mpiix_port_ops = {
1181 @@ -287,8 +289,10 @@ static struct pci_driver mpiix_pci_driver = {
1182 .id_table = mpiix,
1183 .probe = mpiix_init_one,
1184 .remove = mpiix_remove_one,
1185 +#ifdef CONFIG_PM
1186 .suspend = ata_pci_device_suspend,
1187 .resume = ata_pci_device_resume,
1188 +#endif
1189 };
1190
1191 static int __init mpiix_init(void)
1192 diff --git a/drivers/ata/pata_netcell.c b/drivers/ata/pata_netcell.c
1193 index cf7fe03..d0e7ac3 100644
1194 --- a/drivers/ata/pata_netcell.c
1195 +++ b/drivers/ata/pata_netcell.c
1196 @@ -63,8 +63,10 @@ static struct scsi_host_template netcell_sht = {
1197 .slave_destroy = ata_scsi_slave_destroy,
1198 /* Use standard CHS mapping rules */
1199 .bios_param = ata_std_bios_param,
1200 +#ifdef CONFIG_PM
1201 .resume = ata_scsi_device_resume,
1202 .suspend = ata_scsi_device_suspend,
1203 +#endif
1204 };
1205
1206 static const struct ata_port_operations netcell_ops = {
1207 @@ -153,8 +155,10 @@ static struct pci_driver netcell_pci_driver = {
1208 .id_table = netcell_pci_tbl,
1209 .probe = netcell_init_one,
1210 .remove = ata_pci_remove_one,
1211 +#ifdef CONFIG_PM
1212 .suspend = ata_pci_device_suspend,
1213 .resume = ata_pci_device_resume,
1214 +#endif
1215 };
1216
1217 static int __init netcell_init(void)
1218 diff --git a/drivers/ata/pata_ns87410.c b/drivers/ata/pata_ns87410.c
1219 index c3032eb..a4d4eb6 100644
1220 --- a/drivers/ata/pata_ns87410.c
1221 +++ b/drivers/ata/pata_ns87410.c
1222 @@ -157,8 +157,10 @@ static struct scsi_host_template ns87410_sht = {
1223 .slave_configure = ata_scsi_slave_config,
1224 .slave_destroy = ata_scsi_slave_destroy,
1225 .bios_param = ata_std_bios_param,
1226 +#ifdef CONFIG_PM
1227 .resume = ata_scsi_device_resume,
1228 .suspend = ata_scsi_device_suspend,
1229 +#endif
1230 };
1231
1232 static struct ata_port_operations ns87410_port_ops = {
1233 @@ -212,8 +214,10 @@ static struct pci_driver ns87410_pci_driver = {
1234 .id_table = ns87410,
1235 .probe = ns87410_init_one,
1236 .remove = ata_pci_remove_one,
1237 +#ifdef CONFIG_PM
1238 .suspend = ata_pci_device_suspend,
1239 .resume = ata_pci_device_resume,
1240 +#endif
1241 };
1242
1243 static int __init ns87410_init(void)
1244 diff --git a/drivers/ata/pata_oldpiix.c b/drivers/ata/pata_oldpiix.c
1245 index 10ac3cc..ad84c51 100644
1246 --- a/drivers/ata/pata_oldpiix.c
1247 +++ b/drivers/ata/pata_oldpiix.c
1248 @@ -232,8 +232,10 @@ static struct scsi_host_template oldpiix_sht = {
1249 .slave_configure = ata_scsi_slave_config,
1250 .slave_destroy = ata_scsi_slave_destroy,
1251 .bios_param = ata_std_bios_param,
1252 +#ifdef CONFIG_PM
1253 .resume = ata_scsi_device_resume,
1254 .suspend = ata_scsi_device_suspend,
1255 +#endif
1256 };
1257
1258 static const struct ata_port_operations oldpiix_pata_ops = {
1259 @@ -315,8 +317,10 @@ static struct pci_driver oldpiix_pci_driver = {
1260 .id_table = oldpiix_pci_tbl,
1261 .probe = oldpiix_init_one,
1262 .remove = ata_pci_remove_one,
1263 +#ifdef CONFIG_PM
1264 .suspend = ata_pci_device_suspend,
1265 .resume = ata_pci_device_resume,
1266 +#endif
1267 };
1268
1269 static int __init oldpiix_init(void)
1270 diff --git a/drivers/ata/pata_opti.c b/drivers/ata/pata_opti.c
1271 index c2988b0..0a023b8 100644
1272 --- a/drivers/ata/pata_opti.c
1273 +++ b/drivers/ata/pata_opti.c
1274 @@ -179,8 +179,10 @@ static struct scsi_host_template opti_sht = {
1275 .slave_configure = ata_scsi_slave_config,
1276 .slave_destroy = ata_scsi_slave_destroy,
1277 .bios_param = ata_std_bios_param,
1278 +#ifdef CONFIG_PM
1279 .resume = ata_scsi_device_resume,
1280 .suspend = ata_scsi_device_suspend,
1281 +#endif
1282 };
1283
1284 static struct ata_port_operations opti_port_ops = {
1285 @@ -244,8 +246,10 @@ static struct pci_driver opti_pci_driver = {
1286 .id_table = opti,
1287 .probe = opti_init_one,
1288 .remove = ata_pci_remove_one,
1289 +#ifdef CONFIG_PM
1290 .suspend = ata_pci_device_suspend,
1291 .resume = ata_pci_device_resume,
1292 +#endif
1293 };
1294
1295 static int __init opti_init(void)
1296 diff --git a/drivers/ata/pata_optidma.c b/drivers/ata/pata_optidma.c
1297 index 80d111c..6797ffa 100644
1298 --- a/drivers/ata/pata_optidma.c
1299 +++ b/drivers/ata/pata_optidma.c
1300 @@ -360,8 +360,10 @@ static struct scsi_host_template optidma_sht = {
1301 .slave_configure = ata_scsi_slave_config,
1302 .slave_destroy = ata_scsi_slave_destroy,
1303 .bios_param = ata_std_bios_param,
1304 +#ifdef CONFIG_PM
1305 .resume = ata_scsi_device_resume,
1306 .suspend = ata_scsi_device_suspend,
1307 +#endif
1308 };
1309
1310 static struct ata_port_operations optidma_port_ops = {
1311 @@ -524,8 +526,10 @@ static struct pci_driver optidma_pci_driver = {
1312 .id_table = optidma,
1313 .probe = optidma_init_one,
1314 .remove = ata_pci_remove_one,
1315 +#ifdef CONFIG_PM
1316 .suspend = ata_pci_device_suspend,
1317 .resume = ata_pci_device_resume,
1318 +#endif
1319 };
1320
1321 static int __init optidma_init(void)
1322 diff --git a/drivers/ata/pata_pdc202xx_old.c b/drivers/ata/pata_pdc202xx_old.c
1323 index ad691b9..f18b67e 100644
1324 --- a/drivers/ata/pata_pdc202xx_old.c
1325 +++ b/drivers/ata/pata_pdc202xx_old.c
1326 @@ -270,8 +270,10 @@ static struct scsi_host_template pdc202xx_sht = {
1327 .slave_configure = ata_scsi_slave_config,
1328 .slave_destroy = ata_scsi_slave_destroy,
1329 .bios_param = ata_std_bios_param,
1330 +#ifdef CONFIG_PM
1331 .resume = ata_scsi_device_resume,
1332 .suspend = ata_scsi_device_suspend,
1333 +#endif
1334 };
1335
1336 static struct ata_port_operations pdc2024x_port_ops = {
1337 @@ -402,8 +404,10 @@ static struct pci_driver pdc202xx_pci_driver = {
1338 .id_table = pdc202xx,
1339 .probe = pdc202xx_init_one,
1340 .remove = ata_pci_remove_one,
1341 +#ifdef CONFIG_PM
1342 .suspend = ata_pci_device_suspend,
1343 .resume = ata_pci_device_resume,
1344 +#endif
1345 };
1346
1347 static int __init pdc202xx_init(void)
1348 diff --git a/drivers/ata/pata_radisys.c b/drivers/ata/pata_radisys.c
1349 index 065541d..45c5d50 100644
1350 --- a/drivers/ata/pata_radisys.c
1351 +++ b/drivers/ata/pata_radisys.c
1352 @@ -228,8 +228,10 @@ static struct scsi_host_template radisys_sht = {
1353 .slave_configure = ata_scsi_slave_config,
1354 .slave_destroy = ata_scsi_slave_destroy,
1355 .bios_param = ata_std_bios_param,
1356 +#ifdef CONFIG_PM
1357 .resume = ata_scsi_device_resume,
1358 .suspend = ata_scsi_device_suspend,
1359 +#endif
1360 };
1361
1362 static const struct ata_port_operations radisys_pata_ops = {
1363 @@ -312,8 +314,10 @@ static struct pci_driver radisys_pci_driver = {
1364 .id_table = radisys_pci_tbl,
1365 .probe = radisys_init_one,
1366 .remove = ata_pci_remove_one,
1367 +#ifdef CONFIG_PM
1368 .suspend = ata_pci_device_suspend,
1369 .resume = ata_pci_device_resume,
1370 +#endif
1371 };
1372
1373 static int __init radisys_init(void)
1374 diff --git a/drivers/ata/pata_rz1000.c b/drivers/ata/pata_rz1000.c
1375 index cec0729..8fcddfb 100644
1376 --- a/drivers/ata/pata_rz1000.c
1377 +++ b/drivers/ata/pata_rz1000.c
1378 @@ -93,8 +93,10 @@ static struct scsi_host_template rz1000_sht = {
1379 .slave_configure = ata_scsi_slave_config,
1380 .slave_destroy = ata_scsi_slave_destroy,
1381 .bios_param = ata_std_bios_param,
1382 +#ifdef CONFIG_PM
1383 .resume = ata_scsi_device_resume,
1384 .suspend = ata_scsi_device_suspend,
1385 +#endif
1386 };
1387
1388 static struct ata_port_operations rz1000_port_ops = {
1389 @@ -177,6 +179,7 @@ static int rz1000_init_one (struct pci_dev *pdev, const struct pci_device_id *en
1390 return -ENODEV;
1391 }
1392
1393 +#ifdef CONFIG_PM
1394 static int rz1000_reinit_one(struct pci_dev *pdev)
1395 {
1396 /* If this fails on resume (which is a "cant happen" case), we
1397 @@ -185,6 +188,7 @@ static int rz1000_reinit_one(struct pci_dev *pdev)
1398 panic("rz1000 fifo");
1399 return ata_pci_device_resume(pdev);
1400 }
1401 +#endif
1402
1403 static const struct pci_device_id pata_rz1000[] = {
1404 { PCI_VDEVICE(PCTECH, PCI_DEVICE_ID_PCTECH_RZ1000), },
1405 @@ -198,8 +202,10 @@ static struct pci_driver rz1000_pci_driver = {
1406 .id_table = pata_rz1000,
1407 .probe = rz1000_init_one,
1408 .remove = ata_pci_remove_one,
1409 +#ifdef CONFIG_PM
1410 .suspend = ata_pci_device_suspend,
1411 .resume = rz1000_reinit_one,
1412 +#endif
1413 };
1414
1415 static int __init rz1000_init(void)
1416 diff --git a/drivers/ata/pata_sc1200.c b/drivers/ata/pata_sc1200.c
1417 index a3b35bc..19328a8 100644
1418 --- a/drivers/ata/pata_sc1200.c
1419 +++ b/drivers/ata/pata_sc1200.c
1420 @@ -194,8 +194,10 @@ static struct scsi_host_template sc1200_sht = {
1421 .slave_configure = ata_scsi_slave_config,
1422 .slave_destroy = ata_scsi_slave_destroy,
1423 .bios_param = ata_std_bios_param,
1424 +#ifdef CONFIG_PM
1425 .resume = ata_scsi_device_resume,
1426 .suspend = ata_scsi_device_suspend,
1427 +#endif
1428 };
1429
1430 static struct ata_port_operations sc1200_port_ops = {
1431 @@ -266,8 +268,10 @@ static struct pci_driver sc1200_pci_driver = {
1432 .id_table = sc1200,
1433 .probe = sc1200_init_one,
1434 .remove = ata_pci_remove_one,
1435 +#ifdef CONFIG_PM
1436 .suspend = ata_pci_device_suspend,
1437 .resume = ata_pci_device_resume,
1438 +#endif
1439 };
1440
1441 static int __init sc1200_init(void)
1442 diff --git a/drivers/ata/pata_serverworks.c b/drivers/ata/pata_serverworks.c
1443 index f02b6a3..95f5202 100644
1444 --- a/drivers/ata/pata_serverworks.c
1445 +++ b/drivers/ata/pata_serverworks.c
1446 @@ -326,8 +326,10 @@ static struct scsi_host_template serverworks_sht = {
1447 .slave_configure = ata_scsi_slave_config,
1448 .slave_destroy = ata_scsi_slave_destroy,
1449 .bios_param = ata_std_bios_param,
1450 +#ifdef CONFIG_PM
1451 .resume = ata_scsi_device_resume,
1452 .suspend = ata_scsi_device_suspend,
1453 +#endif
1454 };
1455
1456 static struct ata_port_operations serverworks_osb4_port_ops = {
1457 @@ -555,6 +557,7 @@ static int serverworks_init_one(struct pci_dev *pdev, const struct pci_device_id
1458 return ata_pci_init_one(pdev, port_info, ports);
1459 }
1460
1461 +#ifdef CONFIG_PM
1462 static int serverworks_reinit_one(struct pci_dev *pdev)
1463 {
1464 /* Force master latency timer to 64 PCI clocks */
1465 @@ -578,6 +581,7 @@ static int serverworks_reinit_one(struct pci_dev *pdev)
1466 }
1467 return ata_pci_device_resume(pdev);
1468 }
1469 +#endif
1470
1471 static const struct pci_device_id serverworks[] = {
1472 { PCI_VDEVICE(SERVERWORKS, PCI_DEVICE_ID_SERVERWORKS_OSB4IDE), 0},
1473 @@ -594,8 +598,10 @@ static struct pci_driver serverworks_pci_driver = {
1474 .id_table = serverworks,
1475 .probe = serverworks_init_one,
1476 .remove = ata_pci_remove_one,
1477 +#ifdef CONFIG_PM
1478 .suspend = ata_pci_device_suspend,
1479 .resume = serverworks_reinit_one,
1480 +#endif
1481 };
1482
1483 static int __init serverworks_init(void)
1484 diff --git a/drivers/ata/pata_sil680.c b/drivers/ata/pata_sil680.c
1485 index e8dfd8f..653fe34 100644
1486 --- a/drivers/ata/pata_sil680.c
1487 +++ b/drivers/ata/pata_sil680.c
1488 @@ -226,6 +226,10 @@ static struct scsi_host_template sil680_sht = {
1489 .slave_configure = ata_scsi_slave_config,
1490 .slave_destroy = ata_scsi_slave_destroy,
1491 .bios_param = ata_std_bios_param,
1492 +#ifdef CONFIG_PM
1493 + .suspend = ata_scsi_device_suspend,
1494 + .resume = ata_scsi_device_resume,
1495 +#endif
1496 };
1497
1498 static struct ata_port_operations sil680_port_ops = {
1499 @@ -367,11 +371,13 @@ static int sil680_init_one(struct pci_dev *pdev, const struct pci_device_id *id)
1500 return ata_pci_init_one(pdev, port_info, 2);
1501 }
1502
1503 +#ifdef CONFIG_PM
1504 static int sil680_reinit_one(struct pci_dev *pdev)
1505 {
1506 sil680_init_chip(pdev);
1507 return ata_pci_device_resume(pdev);
1508 }
1509 +#endif
1510
1511 static const struct pci_device_id sil680[] = {
1512 { PCI_VDEVICE(CMD, PCI_DEVICE_ID_SII_680), },
1513 @@ -384,8 +390,10 @@ static struct pci_driver sil680_pci_driver = {
1514 .id_table = sil680,
1515 .probe = sil680_init_one,
1516 .remove = ata_pci_remove_one,
1517 +#ifdef CONFIG_PM
1518 .suspend = ata_pci_device_suspend,
1519 .resume = sil680_reinit_one,
1520 +#endif
1521 };
1522
1523 static int __init sil680_init(void)
1524 diff --git a/drivers/ata/pata_sis.c b/drivers/ata/pata_sis.c
1525 index 916cedb..e1fdea6 100644
1526 --- a/drivers/ata/pata_sis.c
1527 +++ b/drivers/ata/pata_sis.c
1528 @@ -546,8 +546,10 @@ static struct scsi_host_template sis_sht = {
1529 .slave_configure = ata_scsi_slave_config,
1530 .slave_destroy = ata_scsi_slave_destroy,
1531 .bios_param = ata_std_bios_param,
1532 +#ifdef CONFIG_PM
1533 .resume = ata_scsi_device_resume,
1534 .suspend = ata_scsi_device_suspend,
1535 +#endif
1536 };
1537
1538 static const struct ata_port_operations sis_133_ops = {
1539 @@ -1001,8 +1003,10 @@ static struct pci_driver sis_pci_driver = {
1540 .id_table = sis_pci_tbl,
1541 .probe = sis_init_one,
1542 .remove = ata_pci_remove_one,
1543 +#ifdef CONFIG_PM
1544 .suspend = ata_pci_device_suspend,
1545 .resume = ata_pci_device_resume,
1546 +#endif
1547 };
1548
1549 static int __init sis_init(void)
1550 diff --git a/drivers/ata/pata_triflex.c b/drivers/ata/pata_triflex.c
1551 index a142971..02c84a1 100644
1552 --- a/drivers/ata/pata_triflex.c
1553 +++ b/drivers/ata/pata_triflex.c
1554 @@ -193,8 +193,10 @@ static struct scsi_host_template triflex_sht = {
1555 .slave_configure = ata_scsi_slave_config,
1556 .slave_destroy = ata_scsi_slave_destroy,
1557 .bios_param = ata_std_bios_param,
1558 +#ifdef CONFIG_PM
1559 .resume = ata_scsi_device_resume,
1560 .suspend = ata_scsi_device_suspend,
1561 +#endif
1562 };
1563
1564 static struct ata_port_operations triflex_port_ops = {
1565 @@ -260,8 +262,10 @@ static struct pci_driver triflex_pci_driver = {
1566 .id_table = triflex,
1567 .probe = triflex_init_one,
1568 .remove = ata_pci_remove_one,
1569 +#ifdef CONFIG_PM
1570 .suspend = ata_pci_device_suspend,
1571 .resume = ata_pci_device_resume,
1572 +#endif
1573 };
1574
1575 static int __init triflex_init(void)
1576 diff --git a/drivers/ata/pata_via.c b/drivers/ata/pata_via.c
1577 index f0b6c3b..ee3b36a 100644
1578 --- a/drivers/ata/pata_via.c
1579 +++ b/drivers/ata/pata_via.c
1580 @@ -305,8 +305,10 @@ static struct scsi_host_template via_sht = {
1581 .slave_configure = ata_scsi_slave_config,
1582 .slave_destroy = ata_scsi_slave_destroy,
1583 .bios_param = ata_std_bios_param,
1584 +#ifdef CONFIG_PM
1585 .resume = ata_scsi_device_resume,
1586 .suspend = ata_scsi_device_suspend,
1587 +#endif
1588 };
1589
1590 static struct ata_port_operations via_port_ops = {
1591 @@ -560,6 +562,7 @@ static int via_init_one(struct pci_dev *pdev, const struct pci_device_id *id)
1592 return ata_pci_init_one(pdev, port_info, 2);
1593 }
1594
1595 +#ifdef CONFIG_PM
1596 /**
1597 * via_reinit_one - reinit after resume
1598 * @pdev; PCI device
1599 @@ -592,6 +595,7 @@ static int via_reinit_one(struct pci_dev *pdev)
1600 }
1601 return ata_pci_device_resume(pdev);
1602 }
1603 +#endif
1604
1605 static const struct pci_device_id via[] = {
1606 { PCI_VDEVICE(VIA, PCI_DEVICE_ID_VIA_82C576_1), },
1607 @@ -607,8 +611,10 @@ static struct pci_driver via_pci_driver = {
1608 .id_table = via,
1609 .probe = via_init_one,
1610 .remove = ata_pci_remove_one,
1611 +#ifdef CONFIG_PM
1612 .suspend = ata_pci_device_suspend,
1613 .resume = via_reinit_one,
1614 +#endif
1615 };
1616
1617 static int __init via_init(void)
1618 diff --git a/drivers/ata/sata_sil.c b/drivers/ata/sata_sil.c
1619 index 7808d03..a12d638 100644
1620 --- a/drivers/ata/sata_sil.c
1621 +++ b/drivers/ata/sata_sil.c
1622 @@ -181,8 +181,10 @@ static struct scsi_host_template sil_sht = {
1623 .slave_configure = ata_scsi_slave_config,
1624 .slave_destroy = ata_scsi_slave_destroy,
1625 .bios_param = ata_std_bios_param,
1626 +#ifdef CONFIG_PM
1627 .suspend = ata_scsi_device_suspend,
1628 .resume = ata_scsi_device_resume,
1629 +#endif
1630 };
1631
1632 static const struct ata_port_operations sil_ops = {
1633 @@ -383,9 +385,15 @@ static void sil_host_intr(struct ata_port *ap, u32 bmdma2)
1634 goto freeze;
1635 }
1636
1637 - if (unlikely(!qc || qc->tf.ctl & ATA_NIEN))
1638 + if (unlikely(!qc))
1639 goto freeze;
1640
1641 + if (unlikely(qc->tf.flags & ATA_TFLAG_POLLING)) {
1642 + /* this sometimes happens, just clear IRQ */
1643 + ata_chk_status(ap);
1644 + return;
1645 + }
1646 +
1647 /* Check whether we are expecting interrupt in this state */
1648 switch (ap->hsm_task_state) {
1649 case HSM_ST_FIRST:
1650 diff --git a/drivers/ata/sata_sil24.c b/drivers/ata/sata_sil24.c
1651 index 5aa288d..c159bae 100644
1652 --- a/drivers/ata/sata_sil24.c
1653 +++ b/drivers/ata/sata_sil24.c
1654 @@ -386,8 +386,10 @@ static struct scsi_host_template sil24_sht = {
1655 .slave_configure = ata_scsi_slave_config,
1656 .slave_destroy = ata_scsi_slave_destroy,
1657 .bios_param = ata_std_bios_param,
1658 +#ifdef CONFIG_PM
1659 .suspend = ata_scsi_device_suspend,
1660 .resume = ata_scsi_device_resume,
1661 +#endif
1662 };
1663
1664 static const struct ata_port_operations sil24_ops = {
1665 diff --git a/drivers/block/pktcdvd.c b/drivers/block/pktcdvd.c
1666 index 6246219..dd38c30 100644
1667 --- a/drivers/block/pktcdvd.c
1668 +++ b/drivers/block/pktcdvd.c
1669 @@ -777,7 +777,7 @@ static int pkt_generic_packet(struct pktcdvd_device *pd, struct packet_command *
1670 goto out;
1671 }
1672
1673 - rq->cmd_len = COMMAND_SIZE(rq->cmd[0]);
1674 + rq->cmd_len = COMMAND_SIZE(cgc->cmd[0]);
1675 memcpy(rq->cmd, cgc->cmd, CDROM_PACKET_SIZE);
1676 if (sizeof(rq->cmd) > CDROM_PACKET_SIZE)
1677 memset(rq->cmd + CDROM_PACKET_SIZE, 0, sizeof(rq->cmd) - CDROM_PACKET_SIZE);
1678 diff --git a/drivers/char/agp/intel-agp.c b/drivers/char/agp/intel-agp.c
1679 index a3011de..84787ce 100644
1680 --- a/drivers/char/agp/intel-agp.c
1681 +++ b/drivers/char/agp/intel-agp.c
1682 @@ -117,13 +117,15 @@ static int intel_i810_configure(void)
1683
1684 current_size = A_SIZE_FIX(agp_bridge->current_size);
1685
1686 - pci_read_config_dword(intel_i810_private.i810_dev, I810_MMADDR, &temp);
1687 - temp &= 0xfff80000;
1688 -
1689 - intel_i810_private.registers = ioremap(temp, 128 * 4096);
1690 if (!intel_i810_private.registers) {
1691 - printk(KERN_ERR PFX "Unable to remap memory.\n");
1692 - return -ENOMEM;
1693 + pci_read_config_dword(intel_i810_private.i810_dev, I810_MMADDR, &temp);
1694 + temp &= 0xfff80000;
1695 +
1696 + intel_i810_private.registers = ioremap(temp, 128 * 4096);
1697 + if (!intel_i810_private.registers) {
1698 + printk(KERN_ERR PFX "Unable to remap memory.\n");
1699 + return -ENOMEM;
1700 + }
1701 }
1702
1703 if ((readl(intel_i810_private.registers+I810_DRAM_CTL)
1704 diff --git a/drivers/char/pcmcia/cm4040_cs.c b/drivers/char/pcmcia/cm4040_cs.c
1705 index 9b1ff7e..3a6d05b 100644
1706 --- a/drivers/char/pcmcia/cm4040_cs.c
1707 +++ b/drivers/char/pcmcia/cm4040_cs.c
1708 @@ -273,6 +273,7 @@ static ssize_t cm4040_read(struct file *filp, char __user *buf,
1709 DEBUGP(6, dev, "BytesToRead=%lu\n", bytes_to_read);
1710
1711 min_bytes_to_read = min(count, bytes_to_read + 5);
1712 + min_bytes_to_read = min_t(size_t, min_bytes_to_read, READ_WRITE_BUFFER_SIZE);
1713
1714 DEBUGP(6, dev, "Min=%lu\n", min_bytes_to_read);
1715
1716 @@ -340,7 +341,7 @@ static ssize_t cm4040_write(struct file *filp, const char __user *buf,
1717 return 0;
1718 }
1719
1720 - if (count < 5) {
1721 + if ((count < 5) || (count > READ_WRITE_BUFFER_SIZE)) {
1722 DEBUGP(2, dev, "<- cm4040_write buffersize=%Zd < 5\n", count);
1723 return -EIO;
1724 }
1725 diff --git a/drivers/char/specialix.c b/drivers/char/specialix.c
1726 index 20946f5..0b3044d 100644
1727 --- a/drivers/char/specialix.c
1728 +++ b/drivers/char/specialix.c
1729 @@ -459,7 +459,7 @@ void missed_irq (unsigned long data)
1730 if (irq) {
1731 printk (KERN_INFO "Missed interrupt... Calling int from timer. \n");
1732 sx_interrupt (((struct specialix_board *)data)->irq,
1733 - (void*)data, NULL);
1734 + (void*)data);
1735 }
1736 missed_irq_timer.expires = jiffies + sx_poll;
1737 add_timer (&missed_irq_timer);
1738 diff --git a/drivers/char/tty_io.c b/drivers/char/tty_io.c
1739 index 47a6eac..2370908 100644
1740 --- a/drivers/char/tty_io.c
1741 +++ b/drivers/char/tty_io.c
1742 @@ -1891,6 +1891,20 @@ static int init_dev(struct tty_driver *driver, int idx,
1743 /* check whether we're reopening an existing tty */
1744 if (driver->flags & TTY_DRIVER_DEVPTS_MEM) {
1745 tty = devpts_get_tty(idx);
1746 + /*
1747 + * If we don't have a tty here on a slave open, it's because
1748 + * the master already started the close process and there's
1749 + * no relation between devpts file and tty anymore.
1750 + */
1751 + if (!tty && driver->subtype == PTY_TYPE_SLAVE) {
1752 + retval = -EIO;
1753 + goto end_init;
1754 + }
1755 + /*
1756 + * It's safe from now on because init_dev() is called with
1757 + * tty_mutex held and release_dev() won't change tty->count
1758 + * or tty->flags without having to grab tty_mutex
1759 + */
1760 if (tty && driver->subtype == PTY_TYPE_MASTER)
1761 tty = tty->link;
1762 } else {
1763 diff --git a/drivers/hid/hid-core.c b/drivers/hid/hid-core.c
1764 index 49f18f5..5cb2500 100644
1765 --- a/drivers/hid/hid-core.c
1766 +++ b/drivers/hid/hid-core.c
1767 @@ -670,7 +670,6 @@ struct hid_device *hid_parse_report(__u8 *start, unsigned size)
1768
1769 if (item.format != HID_ITEM_FORMAT_SHORT) {
1770 dbg("unexpected long global item");
1771 - kfree(device->collection);
1772 hid_free_device(device);
1773 kfree(parser);
1774 return NULL;
1775 @@ -679,7 +678,6 @@ struct hid_device *hid_parse_report(__u8 *start, unsigned size)
1776 if (dispatch_type[item.type](parser, &item)) {
1777 dbg("item %u %u %u %u parsing failed\n",
1778 item.format, (unsigned)item.size, (unsigned)item.type, (unsigned)item.tag);
1779 - kfree(device->collection);
1780 hid_free_device(device);
1781 kfree(parser);
1782 return NULL;
1783 @@ -688,14 +686,12 @@ struct hid_device *hid_parse_report(__u8 *start, unsigned size)
1784 if (start == end) {
1785 if (parser->collection_stack_ptr) {
1786 dbg("unbalanced collection at end of report description");
1787 - kfree(device->collection);
1788 hid_free_device(device);
1789 kfree(parser);
1790 return NULL;
1791 }
1792 if (parser->local.delimiter_depth) {
1793 dbg("unbalanced delimiter at end of report description");
1794 - kfree(device->collection);
1795 hid_free_device(device);
1796 kfree(parser);
1797 return NULL;
1798 @@ -706,7 +702,6 @@ struct hid_device *hid_parse_report(__u8 *start, unsigned size)
1799 }
1800
1801 dbg("item fetching failed at offset %d\n", (int)(end - start));
1802 - kfree(device->collection);
1803 hid_free_device(device);
1804 kfree(parser);
1805 return NULL;
1806 diff --git a/drivers/ide/ide-iops.c b/drivers/ide/ide-iops.c
1807 index badde63..6558055 100644
1808 --- a/drivers/ide/ide-iops.c
1809 +++ b/drivers/ide/ide-iops.c
1810 @@ -607,6 +607,8 @@ u8 eighty_ninty_three (ide_drive_t *drive)
1811 if(!(drive->id->hw_config & 0x4000))
1812 return 0;
1813 #endif /* CONFIG_IDEDMA_IVB */
1814 + if (!(drive->id->hw_config & 0x2000))
1815 + return 0;
1816 return 1;
1817 }
1818
1819 diff --git a/drivers/ieee1394/nodemgr.c b/drivers/ieee1394/nodemgr.c
1820 index 61307ca..e2e0771 100644
1821 --- a/drivers/ieee1394/nodemgr.c
1822 +++ b/drivers/ieee1394/nodemgr.c
1823 @@ -274,7 +274,6 @@ static struct device_driver nodemgr_mid_layer_driver = {
1824 struct device nodemgr_dev_template_host = {
1825 .bus = &ieee1394_bus_type,
1826 .release = nodemgr_release_host,
1827 - .driver = &nodemgr_mid_layer_driver,
1828 };
1829
1830
1831 @@ -1889,22 +1888,31 @@ int init_ieee1394_nodemgr(void)
1832
1833 error = class_register(&nodemgr_ne_class);
1834 if (error)
1835 - return error;
1836 -
1837 + goto fail_ne;
1838 error = class_register(&nodemgr_ud_class);
1839 - if (error) {
1840 - class_unregister(&nodemgr_ne_class);
1841 - return error;
1842 - }
1843 + if (error)
1844 + goto fail_ud;
1845 error = driver_register(&nodemgr_mid_layer_driver);
1846 + if (error)
1847 + goto fail_ml;
1848 + /* This driver is not used if nodemgr is off (disable_nodemgr=1). */
1849 + nodemgr_dev_template_host.driver = &nodemgr_mid_layer_driver;
1850 +
1851 hpsb_register_highlevel(&nodemgr_highlevel);
1852 return 0;
1853 +
1854 +fail_ml:
1855 + class_unregister(&nodemgr_ud_class);
1856 +fail_ud:
1857 + class_unregister(&nodemgr_ne_class);
1858 +fail_ne:
1859 + return error;
1860 }
1861
1862 void cleanup_ieee1394_nodemgr(void)
1863 {
1864 hpsb_unregister_highlevel(&nodemgr_highlevel);
1865 -
1866 + driver_unregister(&nodemgr_mid_layer_driver);
1867 class_unregister(&nodemgr_ud_class);
1868 class_unregister(&nodemgr_ne_class);
1869 }
1870 diff --git a/drivers/ieee1394/video1394.c b/drivers/ieee1394/video1394.c
1871 index 598b19f..f4d1ec0 100644
1872 --- a/drivers/ieee1394/video1394.c
1873 +++ b/drivers/ieee1394/video1394.c
1874 @@ -489,6 +489,9 @@ static void wakeup_dma_ir_ctx(unsigned long l)
1875 reset_ir_status(d, i);
1876 d->buffer_status[d->buffer_prg_assignment[i]] = VIDEO1394_BUFFER_READY;
1877 do_gettimeofday(&d->buffer_time[d->buffer_prg_assignment[i]]);
1878 + dma_region_sync_for_cpu(&d->dma,
1879 + d->buffer_prg_assignment[i] * d->buf_size,
1880 + d->buf_size);
1881 }
1882 }
1883
1884 @@ -1096,6 +1099,8 @@ static long video1394_ioctl(struct file *file,
1885 DBGMSG(ohci->host->id, "Starting iso transmit DMA ctx=%d",
1886 d->ctx);
1887 put_timestamp(ohci, d, d->last_buffer);
1888 + dma_region_sync_for_device(&d->dma,
1889 + v.buffer * d->buf_size, d->buf_size);
1890
1891 /* Tell the controller where the first program is */
1892 reg_write(ohci, d->cmdPtr,
1893 @@ -1111,6 +1116,9 @@ static long video1394_ioctl(struct file *file,
1894 "Waking up iso transmit dma ctx=%d",
1895 d->ctx);
1896 put_timestamp(ohci, d, d->last_buffer);
1897 + dma_region_sync_for_device(&d->dma,
1898 + v.buffer * d->buf_size, d->buf_size);
1899 +
1900 reg_write(ohci, d->ctrlSet, 0x1000);
1901 }
1902 }
1903 diff --git a/drivers/input/mouse/psmouse-base.c b/drivers/input/mouse/psmouse-base.c
1904 index a0e4a03..9a6e4b6 100644
1905 --- a/drivers/input/mouse/psmouse-base.c
1906 +++ b/drivers/input/mouse/psmouse-base.c
1907 @@ -987,8 +987,36 @@ static void psmouse_resync(struct work_struct *work)
1908 static void psmouse_cleanup(struct serio *serio)
1909 {
1910 struct psmouse *psmouse = serio_get_drvdata(serio);
1911 + struct psmouse *parent = NULL;
1912 +
1913 + mutex_lock(&psmouse_mutex);
1914 +
1915 + if (serio->parent && serio->id.type == SERIO_PS_PSTHRU) {
1916 + parent = serio_get_drvdata(serio->parent);
1917 + psmouse_deactivate(parent);
1918 + }
1919 +
1920 + psmouse_deactivate(psmouse);
1921 +
1922 + if (psmouse->cleanup)
1923 + psmouse->cleanup(psmouse);
1924
1925 psmouse_reset(psmouse);
1926 +
1927 +/*
1928 + * Some boxes, such as HP nx7400, get terribly confused if mouse
1929 + * is not fully enabled before suspending/shutting down.
1930 + */
1931 + ps2_command(&psmouse->ps2dev, NULL, PSMOUSE_CMD_ENABLE);
1932 +
1933 + if (parent) {
1934 + if (parent->pt_deactivate)
1935 + parent->pt_deactivate(parent);
1936 +
1937 + psmouse_activate(parent);
1938 + }
1939 +
1940 + mutex_unlock(&psmouse_mutex);
1941 }
1942
1943 /*
1944 diff --git a/drivers/input/mouse/psmouse.h b/drivers/input/mouse/psmouse.h
1945 index 1b74cae..cf1de95 100644
1946 --- a/drivers/input/mouse/psmouse.h
1947 +++ b/drivers/input/mouse/psmouse.h
1948 @@ -68,6 +68,7 @@ struct psmouse {
1949
1950 int (*reconnect)(struct psmouse *psmouse);
1951 void (*disconnect)(struct psmouse *psmouse);
1952 + void (*cleanup)(struct psmouse *psmouse);
1953 int (*poll)(struct psmouse *psmouse);
1954
1955 void (*pt_activate)(struct psmouse *psmouse);
1956 diff --git a/drivers/input/mouse/synaptics.c b/drivers/input/mouse/synaptics.c
1957 index 49ac696..f0f9413 100644
1958 --- a/drivers/input/mouse/synaptics.c
1959 +++ b/drivers/input/mouse/synaptics.c
1960 @@ -652,6 +652,7 @@ int synaptics_init(struct psmouse *psmouse)
1961 psmouse->set_rate = synaptics_set_rate;
1962 psmouse->disconnect = synaptics_disconnect;
1963 psmouse->reconnect = synaptics_reconnect;
1964 + psmouse->cleanup = synaptics_reset;
1965 psmouse->pktsize = 6;
1966 /* Synaptics can usually stay in sync without extra help */
1967 psmouse->resync_time = 0;
1968 diff --git a/drivers/kvm/kvm.h b/drivers/kvm/kvm.h
1969 index 2db1ca4..4ccb343 100644
1970 --- a/drivers/kvm/kvm.h
1971 +++ b/drivers/kvm/kvm.h
1972 @@ -558,7 +558,7 @@ static inline void load_gs(u16 sel)
1973 #ifndef load_ldt
1974 static inline void load_ldt(u16 sel)
1975 {
1976 - asm ("lldt %0" : : "g"(sel));
1977 + asm ("lldt %0" : : "rm"(sel));
1978 }
1979 #endif
1980
1981 diff --git a/drivers/macintosh/Kconfig b/drivers/macintosh/Kconfig
1982 index a9e747c..1a86387 100644
1983 --- a/drivers/macintosh/Kconfig
1984 +++ b/drivers/macintosh/Kconfig
1985 @@ -1,6 +1,6 @@
1986
1987 menu "Macintosh device drivers"
1988 - depends on PPC || MAC
1989 + depends on PPC || MAC || X86
1990
1991 config ADB
1992 bool "Apple Desktop Bus (ADB) support"
1993 diff --git a/drivers/md/bitmap.c b/drivers/md/bitmap.c
1994 index 1110816..059704f 100644
1995 --- a/drivers/md/bitmap.c
1996 +++ b/drivers/md/bitmap.c
1997 @@ -1160,6 +1160,22 @@ int bitmap_startwrite(struct bitmap *bitmap, sector_t offset, unsigned long sect
1998 return 0;
1999 }
2000
2001 + if (unlikely((*bmc & COUNTER_MAX) == COUNTER_MAX)) {
2002 + DEFINE_WAIT(__wait);
2003 + /* note that it is safe to do the prepare_to_wait
2004 + * after the test as long as we do it before dropping
2005 + * the spinlock.
2006 + */
2007 + prepare_to_wait(&bitmap->overflow_wait, &__wait,
2008 + TASK_UNINTERRUPTIBLE);
2009 + spin_unlock_irq(&bitmap->lock);
2010 + bitmap->mddev->queue
2011 + ->unplug_fn(bitmap->mddev->queue);
2012 + schedule();
2013 + finish_wait(&bitmap->overflow_wait, &__wait);
2014 + continue;
2015 + }
2016 +
2017 switch(*bmc) {
2018 case 0:
2019 bitmap_file_set_bit(bitmap, offset);
2020 @@ -1169,7 +1185,7 @@ int bitmap_startwrite(struct bitmap *bitmap, sector_t offset, unsigned long sect
2021 case 1:
2022 *bmc = 2;
2023 }
2024 - BUG_ON((*bmc & COUNTER_MAX) == COUNTER_MAX);
2025 +
2026 (*bmc)++;
2027
2028 spin_unlock_irq(&bitmap->lock);
2029 @@ -1207,6 +1223,9 @@ void bitmap_endwrite(struct bitmap *bitmap, sector_t offset, unsigned long secto
2030 if (!success && ! (*bmc & NEEDED_MASK))
2031 *bmc |= NEEDED_MASK;
2032
2033 + if ((*bmc & COUNTER_MAX) == COUNTER_MAX)
2034 + wake_up(&bitmap->overflow_wait);
2035 +
2036 (*bmc)--;
2037 if (*bmc <= 2) {
2038 set_page_attr(bitmap,
2039 @@ -1431,6 +1450,7 @@ int bitmap_create(mddev_t *mddev)
2040 spin_lock_init(&bitmap->lock);
2041 atomic_set(&bitmap->pending_writes, 0);
2042 init_waitqueue_head(&bitmap->write_wait);
2043 + init_waitqueue_head(&bitmap->overflow_wait);
2044
2045 bitmap->mddev = mddev;
2046
2047 diff --git a/drivers/md/raid10.c b/drivers/md/raid10.c
2048 index a9401c0..82249a6 100644
2049 --- a/drivers/md/raid10.c
2050 +++ b/drivers/md/raid10.c
2051 @@ -429,7 +429,7 @@ static sector_t raid10_find_virt(conf_t *conf, sector_t sector, int dev)
2052 if (dev < 0)
2053 dev += conf->raid_disks;
2054 } else {
2055 - while (sector > conf->stride) {
2056 + while (sector >= conf->stride) {
2057 sector -= conf->stride;
2058 if (dev < conf->near_copies)
2059 dev += conf->raid_disks - conf->near_copies;
2060 @@ -1801,6 +1801,7 @@ static sector_t sync_request(mddev_t *mddev, sector_t sector_nr, int *skipped, i
2061 for (k=0; k<conf->copies; k++)
2062 if (r10_bio->devs[k].devnum == i)
2063 break;
2064 + BUG_ON(k == conf->copies);
2065 bio = r10_bio->devs[1].bio;
2066 bio->bi_next = biolist;
2067 biolist = bio;
2068 @@ -2021,19 +2022,30 @@ static int run(mddev_t *mddev)
2069 if (!conf->tmppage)
2070 goto out_free_conf;
2071
2072 + conf->mddev = mddev;
2073 + conf->raid_disks = mddev->raid_disks;
2074 conf->near_copies = nc;
2075 conf->far_copies = fc;
2076 conf->copies = nc*fc;
2077 conf->far_offset = fo;
2078 conf->chunk_mask = (sector_t)(mddev->chunk_size>>9)-1;
2079 conf->chunk_shift = ffz(~mddev->chunk_size) - 9;
2080 + size = mddev->size >> (conf->chunk_shift-1);
2081 + sector_div(size, fc);
2082 + size = size * conf->raid_disks;
2083 + sector_div(size, nc);
2084 + /* 'size' is now the number of chunks in the array */
2085 + /* calculate "used chunks per device" in 'stride' */
2086 + stride = size * conf->copies;
2087 + sector_div(stride, conf->raid_disks);
2088 + mddev->size = stride << (conf->chunk_shift-1);
2089 +
2090 if (fo)
2091 - conf->stride = 1 << conf->chunk_shift;
2092 - else {
2093 - stride = mddev->size >> (conf->chunk_shift-1);
2094 + stride = 1;
2095 + else
2096 sector_div(stride, fc);
2097 - conf->stride = stride << conf->chunk_shift;
2098 - }
2099 + conf->stride = stride << conf->chunk_shift;
2100 +
2101 conf->r10bio_pool = mempool_create(NR_RAID10_BIOS, r10bio_pool_alloc,
2102 r10bio_pool_free, conf);
2103 if (!conf->r10bio_pool) {
2104 @@ -2063,8 +2075,6 @@ static int run(mddev_t *mddev)
2105
2106 disk->head_position = 0;
2107 }
2108 - conf->raid_disks = mddev->raid_disks;
2109 - conf->mddev = mddev;
2110 spin_lock_init(&conf->device_lock);
2111 INIT_LIST_HEAD(&conf->retry_list);
2112
2113 @@ -2106,16 +2116,8 @@ static int run(mddev_t *mddev)
2114 /*
2115 * Ok, everything is just fine now
2116 */
2117 - if (conf->far_offset) {
2118 - size = mddev->size >> (conf->chunk_shift-1);
2119 - size *= conf->raid_disks;
2120 - size <<= conf->chunk_shift;
2121 - sector_div(size, conf->far_copies);
2122 - } else
2123 - size = conf->stride * conf->raid_disks;
2124 - sector_div(size, conf->near_copies);
2125 - mddev->array_size = size/2;
2126 - mddev->resync_max_sectors = size;
2127 + mddev->array_size = size << (conf->chunk_shift-1);
2128 + mddev->resync_max_sectors = size << conf->chunk_shift;
2129
2130 mddev->queue->unplug_fn = raid10_unplug;
2131 mddev->queue->issue_flush_fn = raid10_issue_flush;
2132 diff --git a/drivers/md/raid5.c b/drivers/md/raid5.c
2133 index 467c169..11c3d7b 100644
2134 --- a/drivers/md/raid5.c
2135 +++ b/drivers/md/raid5.c
2136 @@ -2620,7 +2620,7 @@ static struct bio *remove_bio_from_retry(raid5_conf_t *conf)
2137 }
2138 bi = conf->retry_read_aligned_list;
2139 if(bi) {
2140 - conf->retry_read_aligned = bi->bi_next;
2141 + conf->retry_read_aligned_list = bi->bi_next;
2142 bi->bi_next = NULL;
2143 bi->bi_phys_segments = 1; /* biased count of active stripes */
2144 bi->bi_hw_segments = 0; /* count of processed stripes */
2145 @@ -2669,6 +2669,27 @@ static int raid5_align_endio(struct bio *bi, unsigned int bytes, int error)
2146 return 0;
2147 }
2148
2149 +static int bio_fits_rdev(struct bio *bi)
2150 +{
2151 + request_queue_t *q = bdev_get_queue(bi->bi_bdev);
2152 +
2153 + if ((bi->bi_size>>9) > q->max_sectors)
2154 + return 0;
2155 + blk_recount_segments(q, bi);
2156 + if (bi->bi_phys_segments > q->max_phys_segments ||
2157 + bi->bi_hw_segments > q->max_hw_segments)
2158 + return 0;
2159 +
2160 + if (q->merge_bvec_fn)
2161 + /* it's too hard to apply the merge_bvec_fn at this stage,
2162 + * just just give up
2163 + */
2164 + return 0;
2165 +
2166 + return 1;
2167 +}
2168 +
2169 +
2170 static int chunk_aligned_read(request_queue_t *q, struct bio * raid_bio)
2171 {
2172 mddev_t *mddev = q->queuedata;
2173 @@ -2715,6 +2736,13 @@ static int chunk_aligned_read(request_queue_t *q, struct bio * raid_bio)
2174 align_bi->bi_flags &= ~(1 << BIO_SEG_VALID);
2175 align_bi->bi_sector += rdev->data_offset;
2176
2177 + if (!bio_fits_rdev(align_bi)) {
2178 + /* too big in some way */
2179 + bio_put(align_bi);
2180 + rdev_dec_pending(rdev, mddev);
2181 + return 0;
2182 + }
2183 +
2184 spin_lock_irq(&conf->device_lock);
2185 wait_event_lock_irq(conf->wait_for_stripe,
2186 conf->quiesce == 0,
2187 @@ -3107,7 +3135,9 @@ static int retry_aligned_read(raid5_conf_t *conf, struct bio *raid_bio)
2188 last_sector = raid_bio->bi_sector + (raid_bio->bi_size>>9);
2189
2190 for (; logical_sector < last_sector;
2191 - logical_sector += STRIPE_SECTORS, scnt++) {
2192 + logical_sector += STRIPE_SECTORS,
2193 + sector += STRIPE_SECTORS,
2194 + scnt++) {
2195
2196 if (scnt < raid_bio->bi_hw_segments)
2197 /* already done this stripe */
2198 @@ -3123,7 +3153,13 @@ static int retry_aligned_read(raid5_conf_t *conf, struct bio *raid_bio)
2199 }
2200
2201 set_bit(R5_ReadError, &sh->dev[dd_idx].flags);
2202 - add_stripe_bio(sh, raid_bio, dd_idx, 0);
2203 + if (!add_stripe_bio(sh, raid_bio, dd_idx, 0)) {
2204 + release_stripe(sh);
2205 + raid_bio->bi_hw_segments = scnt;
2206 + conf->retry_read_aligned = raid_bio;
2207 + return handled;
2208 + }
2209 +
2210 handle_stripe(sh, NULL);
2211 release_stripe(sh);
2212 handled++;
2213 diff --git a/drivers/media/dvb/dvb-core/dvbdev.c b/drivers/media/dvb/dvb-core/dvbdev.c
2214 index 40774fe..af35f30 100644
2215 --- a/drivers/media/dvb/dvb-core/dvbdev.c
2216 +++ b/drivers/media/dvb/dvb-core/dvbdev.c
2217 @@ -200,6 +200,8 @@ int dvb_register_device(struct dvb_adapter *adap, struct dvb_device **pdvbdev,
2218 const struct dvb_device *template, void *priv, int type)
2219 {
2220 struct dvb_device *dvbdev;
2221 + struct file_operations *dvbdevfops;
2222 +
2223 int id;
2224
2225 if (mutex_lock_interruptible(&dvbdev_register_lock))
2226 @@ -219,12 +221,22 @@ int dvb_register_device(struct dvb_adapter *adap, struct dvb_device **pdvbdev,
2227 return -ENOMEM;
2228 }
2229
2230 + dvbdevfops = kzalloc(sizeof(struct file_operations), GFP_KERNEL);
2231 +
2232 + if (!dvbdevfops) {
2233 + kfree (dvbdev);
2234 + mutex_unlock(&dvbdev_register_lock);
2235 + return -ENOMEM;
2236 + }
2237 +
2238 memcpy(dvbdev, template, sizeof(struct dvb_device));
2239 dvbdev->type = type;
2240 dvbdev->id = id;
2241 dvbdev->adapter = adap;
2242 dvbdev->priv = priv;
2243 + dvbdev->fops = dvbdevfops;
2244
2245 + memcpy(dvbdev->fops, template->fops, sizeof(struct file_operations));
2246 dvbdev->fops->owner = adap->module;
2247
2248 list_add_tail (&dvbdev->list_head, &adap->device_list);
2249 @@ -252,6 +264,7 @@ void dvb_unregister_device(struct dvb_device *dvbdev)
2250 dvbdev->type, dvbdev->id)));
2251
2252 list_del (&dvbdev->list_head);
2253 + kfree (dvbdev->fops);
2254 kfree (dvbdev);
2255 }
2256 EXPORT_SYMBOL(dvb_unregister_device);
2257 diff --git a/drivers/media/dvb/dvb-usb/cxusb.c b/drivers/media/dvb/dvb-usb/cxusb.c
2258 index 15d12fc..127a94b 100644
2259 --- a/drivers/media/dvb/dvb-usb/cxusb.c
2260 +++ b/drivers/media/dvb/dvb-usb/cxusb.c
2261 @@ -469,9 +469,9 @@ static int bluebird_patch_dvico_firmware_download(struct usb_device *udev,
2262 fw->data[BLUEBIRD_01_ID_OFFSET + 1] == USB_VID_DVICO >> 8) {
2263
2264 fw->data[BLUEBIRD_01_ID_OFFSET + 2] =
2265 - udev->descriptor.idProduct + 1;
2266 + le16_to_cpu(udev->descriptor.idProduct) + 1;
2267 fw->data[BLUEBIRD_01_ID_OFFSET + 3] =
2268 - udev->descriptor.idProduct >> 8;
2269 + le16_to_cpu(udev->descriptor.idProduct) >> 8;
2270
2271 return usb_cypress_load_firmware(udev, fw, CYPRESS_FX2);
2272 }
2273 diff --git a/drivers/media/dvb/dvb-usb/digitv.c b/drivers/media/dvb/dvb-usb/digitv.c
2274 index 4a198d4..b5acb11 100644
2275 --- a/drivers/media/dvb/dvb-usb/digitv.c
2276 +++ b/drivers/media/dvb/dvb-usb/digitv.c
2277 @@ -119,6 +119,8 @@ static int digitv_nxt6000_tuner_set_params(struct dvb_frontend *fe, struct dvb_f
2278 struct dvb_usb_adapter *adap = fe->dvb->priv;
2279 u8 b[5];
2280 dvb_usb_tuner_calc_regs(fe,fep,b, 5);
2281 + if (fe->ops.i2c_gate_ctrl)
2282 + fe->ops.i2c_gate_ctrl(fe, 1);
2283 return digitv_ctrl_msg(adap->dev, USB_WRITE_TUNER, 0, &b[1], 4, NULL, 0);
2284 }
2285
2286 diff --git a/drivers/media/video/cx25840/cx25840-core.c b/drivers/media/video/cx25840/cx25840-core.c
2287 index 7bb7589..2f29ba4 100644
2288 --- a/drivers/media/video/cx25840/cx25840-core.c
2289 +++ b/drivers/media/video/cx25840/cx25840-core.c
2290 @@ -907,13 +907,13 @@ static int cx25840_detect_client(struct i2c_adapter *adapter, int address,
2291 state->vbi_line_offset = 8;
2292 state->id = id;
2293
2294 + i2c_attach_client(client);
2295 +
2296 if (state->is_cx25836)
2297 cx25836_initialize(client);
2298 else
2299 cx25840_initialize(client, 1);
2300
2301 - i2c_attach_client(client);
2302 -
2303 return 0;
2304 }
2305
2306 diff --git a/drivers/media/video/cx25840/cx25840-firmware.c b/drivers/media/video/cx25840/cx25840-firmware.c
2307 index 1958d40..0e86b9d 100644
2308 --- a/drivers/media/video/cx25840/cx25840-firmware.c
2309 +++ b/drivers/media/video/cx25840/cx25840-firmware.c
2310 @@ -37,7 +37,7 @@
2311 */
2312 #define FWSEND 48
2313
2314 -#define FWDEV(x) &((x)->adapter->dev)
2315 +#define FWDEV(x) &((x)->dev)
2316
2317 static char *firmware = FWFILE;
2318
2319 diff --git a/drivers/media/video/cx88/cx88-blackbird.c b/drivers/media/video/cx88/cx88-blackbird.c
2320 index 0cf0360..1c04516 100644
2321 --- a/drivers/media/video/cx88/cx88-blackbird.c
2322 +++ b/drivers/media/video/cx88/cx88-blackbird.c
2323 @@ -53,7 +53,8 @@ MODULE_PARM_DESC(debug,"enable debug messages [blackbird]");
2324
2325 /* ------------------------------------------------------------------ */
2326
2327 -#define BLACKBIRD_FIRM_IMAGE_SIZE 256*1024
2328 +#define OLD_BLACKBIRD_FIRM_IMAGE_SIZE 262144
2329 +#define BLACKBIRD_FIRM_IMAGE_SIZE 376836
2330
2331 /* defines below are from ivtv-driver.h */
2332
2333 @@ -401,7 +402,7 @@ static int blackbird_find_mailbox(struct cx8802_dev *dev)
2334 u32 value;
2335 int i;
2336
2337 - for (i = 0; i < BLACKBIRD_FIRM_IMAGE_SIZE; i++) {
2338 + for (i = 0; i < dev->fw_size; i++) {
2339 memory_read(dev->core, i, &value);
2340 if (value == signature[signaturecnt])
2341 signaturecnt++;
2342 @@ -449,12 +450,15 @@ static int blackbird_load_firmware(struct cx8802_dev *dev)
2343 return -1;
2344 }
2345
2346 - if (firmware->size != BLACKBIRD_FIRM_IMAGE_SIZE) {
2347 - dprintk(0, "ERROR: Firmware size mismatch (have %zd, expected %d)\n",
2348 - firmware->size, BLACKBIRD_FIRM_IMAGE_SIZE);
2349 + if ((firmware->size != BLACKBIRD_FIRM_IMAGE_SIZE) &&
2350 + (firmware->size != OLD_BLACKBIRD_FIRM_IMAGE_SIZE)) {
2351 + dprintk(0, "ERROR: Firmware size mismatch (have %zd, expected %d or %d)\n",
2352 + firmware->size, BLACKBIRD_FIRM_IMAGE_SIZE,
2353 + OLD_BLACKBIRD_FIRM_IMAGE_SIZE);
2354 release_firmware(firmware);
2355 return -1;
2356 }
2357 + dev->fw_size = firmware->size;
2358
2359 if (0 != memcmp(firmware->data, magic, 8)) {
2360 dprintk(0, "ERROR: Firmware magic mismatch, wrong file?\n");
2361 diff --git a/drivers/media/video/cx88/cx88.h b/drivers/media/video/cx88/cx88.h
2362 index a9575ad..e775b4b 100644
2363 --- a/drivers/media/video/cx88/cx88.h
2364 +++ b/drivers/media/video/cx88/cx88.h
2365 @@ -459,6 +459,7 @@ struct cx8802_dev {
2366 u32 mailbox;
2367 int width;
2368 int height;
2369 + int fw_size;
2370
2371 /* for dvb only */
2372 struct videobuf_dvb dvb;
2373 diff --git a/drivers/media/video/pvrusb2/pvrusb2-encoder.c b/drivers/media/video/pvrusb2/pvrusb2-encoder.c
2374 index c94f97b..aec1a00 100644
2375 --- a/drivers/media/video/pvrusb2/pvrusb2-encoder.c
2376 +++ b/drivers/media/video/pvrusb2/pvrusb2-encoder.c
2377 @@ -288,6 +288,44 @@ static int pvr2_encoder_vcmd(struct pvr2_hdw *hdw, int cmd,
2378 return pvr2_encoder_cmd(hdw,cmd,args,0,data);
2379 }
2380
2381 +
2382 +/* This implements some extra setup for the encoder that seems to be
2383 + specific to the PVR USB2 hardware. */
2384 +int pvr2_encoder_prep_config(struct pvr2_hdw *hdw)
2385 +{
2386 + int ret = 0;
2387 + int encMisc3Arg = 0;
2388 +
2389 + /* Mike Isely <isely@pobox.com> 22-Feb-2007 The windows driver
2390 + sends the following list of ENC_MISC commands (for both
2391 + 24xxx and 29xxx devices). Meanings are not entirely clear,
2392 + however without the ENC_MISC(3,encMisc3Arg) command then we risk
2393 + random perpetual video corruption whenever the video input
2394 + breaks up for a moment (like when switching channels). */
2395 +
2396 +
2397 + /* This ENC_MISC(3,encMisc3Arg) command is critical - without
2398 + it there will eventually be video corruption. Also, the
2399 + 29xxx case is strange - the Windows driver is passing 1
2400 + regardless of device type but if we have 1 for 29xxx device
2401 + the video turns sluggish. */
2402 + switch (hdw->hdw_type) {
2403 + case PVR2_HDW_TYPE_24XXX: encMisc3Arg = 1; break;
2404 + case PVR2_HDW_TYPE_29XXX: encMisc3Arg = 0; break;
2405 + default: break;
2406 + }
2407 + ret |= pvr2_encoder_vcmd(hdw, CX2341X_ENC_MISC,4, 3,
2408 + encMisc3Arg,0,0);
2409 +
2410 + ret |= pvr2_encoder_vcmd(hdw, CX2341X_ENC_MISC,4, 8,0,0,0);
2411 +
2412 + ret |= pvr2_encoder_vcmd(hdw, CX2341X_ENC_MISC,4, 0,3,0,0);
2413 + ret |= pvr2_encoder_vcmd(hdw, CX2341X_ENC_MISC,4,15,0,0,0);
2414 +
2415 + return ret;
2416 +}
2417 +
2418 +
2419 int pvr2_encoder_configure(struct pvr2_hdw *hdw)
2420 {
2421 int ret;
2422 @@ -302,6 +340,8 @@ int pvr2_encoder_configure(struct pvr2_hdw *hdw)
2423
2424 ret = 0;
2425
2426 + ret |= pvr2_encoder_prep_config(hdw);
2427 +
2428 if (!ret) ret = pvr2_encoder_vcmd(
2429 hdw,CX2341X_ENC_SET_NUM_VSYNC_LINES, 2,
2430 0xf0, 0xf0);
2431 diff --git a/drivers/media/video/pvrusb2/pvrusb2-hdw.c b/drivers/media/video/pvrusb2/pvrusb2-hdw.c
2432 index d200496..2fbd24c 100644
2433 --- a/drivers/media/video/pvrusb2/pvrusb2-hdw.c
2434 +++ b/drivers/media/video/pvrusb2/pvrusb2-hdw.c
2435 @@ -1041,7 +1041,7 @@ int pvr2_upload_firmware2(struct pvr2_hdw *hdw)
2436 {
2437 const struct firmware *fw_entry = NULL;
2438 void *fw_ptr;
2439 - unsigned int pipe, fw_len, fw_done;
2440 + unsigned int pipe, fw_len, fw_done, bcnt, icnt;
2441 int actual_length;
2442 int ret = 0;
2443 int fwidx;
2444 @@ -1093,11 +1093,11 @@ int pvr2_upload_firmware2(struct pvr2_hdw *hdw)
2445
2446 fw_len = fw_entry->size;
2447
2448 - if (fw_len % FIRMWARE_CHUNK_SIZE) {
2449 + if (fw_len % sizeof(u32)) {
2450 pvr2_trace(PVR2_TRACE_ERROR_LEGS,
2451 "size of %s firmware"
2452 - " must be a multiple of 8192B",
2453 - fw_files[fwidx]);
2454 + " must be a multiple of %zu bytes",
2455 + fw_files[fwidx],sizeof(u32));
2456 release_firmware(fw_entry);
2457 return -1;
2458 }
2459 @@ -1112,18 +1112,21 @@ int pvr2_upload_firmware2(struct pvr2_hdw *hdw)
2460
2461 pipe = usb_sndbulkpipe(hdw->usb_dev, PVR2_FIRMWARE_ENDPOINT);
2462
2463 - for (fw_done = 0 ; (fw_done < fw_len) && !ret ;
2464 - fw_done += FIRMWARE_CHUNK_SIZE ) {
2465 - int i;
2466 - memcpy(fw_ptr, fw_entry->data + fw_done, FIRMWARE_CHUNK_SIZE);
2467 - /* Usbsnoop log shows that we must swap bytes... */
2468 - for (i = 0; i < FIRMWARE_CHUNK_SIZE/4 ; i++)
2469 - ((u32 *)fw_ptr)[i] = ___swab32(((u32 *)fw_ptr)[i]);
2470 -
2471 - ret |= usb_bulk_msg(hdw->usb_dev, pipe, fw_ptr,
2472 - FIRMWARE_CHUNK_SIZE,
2473 + fw_done = 0;
2474 + for (fw_done = 0; fw_done < fw_len;) {
2475 + bcnt = fw_len - fw_done;
2476 + if (bcnt > FIRMWARE_CHUNK_SIZE) bcnt = FIRMWARE_CHUNK_SIZE;
2477 + memcpy(fw_ptr, fw_entry->data + fw_done, bcnt);
2478 + /* Usbsnoop log shows that we must swap bytes... */
2479 + for (icnt = 0; icnt < bcnt/4 ; icnt++)
2480 + ((u32 *)fw_ptr)[icnt] =
2481 + ___swab32(((u32 *)fw_ptr)[icnt]);
2482 +
2483 + ret |= usb_bulk_msg(hdw->usb_dev, pipe, fw_ptr,bcnt,
2484 &actual_length, HZ);
2485 - ret |= (actual_length != FIRMWARE_CHUNK_SIZE);
2486 + ret |= (actual_length != bcnt);
2487 + if (ret) break;
2488 + fw_done += bcnt;
2489 }
2490
2491 trace_firmware("upload of %s : %i / %i ",
2492 diff --git a/drivers/mmc/sdhci.c b/drivers/mmc/sdhci.c
2493 index c2d13d7..175a942 100644
2494 --- a/drivers/mmc/sdhci.c
2495 +++ b/drivers/mmc/sdhci.c
2496 @@ -37,6 +37,7 @@ static unsigned int debug_quirks = 0;
2497 #define SDHCI_QUIRK_FORCE_DMA (1<<1)
2498 /* Controller doesn't like some resets when there is no card inserted. */
2499 #define SDHCI_QUIRK_NO_CARD_NO_RESET (1<<2)
2500 +#define SDHCI_QUIRK_SINGLE_POWER_WRITE (1<<3)
2501
2502 static const struct pci_device_id pci_ids[] __devinitdata = {
2503 {
2504 @@ -65,6 +66,14 @@ static const struct pci_device_id pci_ids[] __devinitdata = {
2505 .driver_data = SDHCI_QUIRK_FORCE_DMA,
2506 },
2507
2508 + {
2509 + .vendor = PCI_VENDOR_ID_ENE,
2510 + .device = PCI_DEVICE_ID_ENE_CB712_SD,
2511 + .subvendor = PCI_ANY_ID,
2512 + .subdevice = PCI_ANY_ID,
2513 + .driver_data = SDHCI_QUIRK_SINGLE_POWER_WRITE,
2514 + },
2515 +
2516 { /* Generic SD host controller */
2517 PCI_DEVICE_CLASS((PCI_CLASS_SYSTEM_SDHCI << 8), 0xFFFF00)
2518 },
2519 @@ -674,10 +683,17 @@ static void sdhci_set_power(struct sdhci_host *host, unsigned short power)
2520 if (host->power == power)
2521 return;
2522
2523 - writeb(0, host->ioaddr + SDHCI_POWER_CONTROL);
2524 -
2525 - if (power == (unsigned short)-1)
2526 + if (power == (unsigned short)-1) {
2527 + writeb(0, host->ioaddr + SDHCI_POWER_CONTROL);
2528 goto out;
2529 + }
2530 +
2531 + /*
2532 + * Spec says that we should clear the power reg before setting
2533 + * a new value. Some controllers don't seem to like this though.
2534 + */
2535 + if (!(host->chip->quirks & SDHCI_QUIRK_SINGLE_POWER_WRITE))
2536 + writeb(0, host->ioaddr + SDHCI_POWER_CONTROL);
2537
2538 pwr = SDHCI_POWER_ON;
2539
2540 diff --git a/drivers/mtd/redboot.c b/drivers/mtd/redboot.c
2541 index 035cd9b..a61351f 100644
2542 --- a/drivers/mtd/redboot.c
2543 +++ b/drivers/mtd/redboot.c
2544 @@ -94,8 +94,19 @@ static int parse_redboot_partitions(struct mtd_info *master,
2545 * (NOTE: this is 'size' not 'data_length'; size is
2546 * the full size of the entry.)
2547 */
2548 - if (swab32(buf[i].size) == master->erasesize) {
2549 +
2550 + /* RedBoot can combine the FIS directory and
2551 + config partitions into a single eraseblock;
2552 + we assume wrong-endian if either the swapped
2553 + 'size' matches the eraseblock size precisely,
2554 + or if the swapped size actually fits in an
2555 + eraseblock while the unswapped size doesn't. */
2556 + if (swab32(buf[i].size) == master->erasesize ||
2557 + (buf[i].size > master->erasesize
2558 + && swab32(buf[i].size) < master->erasesize)) {
2559 int j;
2560 + /* Update numslots based on actual FIS directory size */
2561 + numslots = swab32(buf[i].size) / sizeof (struct fis_image_desc);
2562 for (j = 0; j < numslots; ++j) {
2563
2564 /* A single 0xff denotes a deleted entry.
2565 @@ -120,11 +131,11 @@ static int parse_redboot_partitions(struct mtd_info *master,
2566 swab32s(&buf[j].desc_cksum);
2567 swab32s(&buf[j].file_cksum);
2568 }
2569 + } else if (buf[i].size < master->erasesize) {
2570 + /* Update numslots based on actual FIS directory size */
2571 + numslots = buf[i].size / sizeof(struct fis_image_desc);
2572 }
2573 break;
2574 - } else {
2575 - /* re-calculate of real numslots */
2576 - numslots = buf[i].size / sizeof(struct fis_image_desc);
2577 }
2578 }
2579 if (i == numslots) {
2580 diff --git a/drivers/net/forcedeth.c b/drivers/net/forcedeth.c
2581 index 93f2b7a..952a6bd 100644
2582 --- a/drivers/net/forcedeth.c
2583 +++ b/drivers/net/forcedeth.c
2584 @@ -825,7 +825,7 @@ enum {
2585 NV_MSIX_INT_DISABLED,
2586 NV_MSIX_INT_ENABLED
2587 };
2588 -static int msix = NV_MSIX_INT_ENABLED;
2589 +static int msix = NV_MSIX_INT_DISABLED;
2590
2591 /*
2592 * DMA 64bit
2593 diff --git a/drivers/net/sky2.c b/drivers/net/sky2.c
2594 index 822dd0b..f44c397 100644
2595 --- a/drivers/net/sky2.c
2596 +++ b/drivers/net/sky2.c
2597 @@ -1796,6 +1796,7 @@ out:
2598
2599 /* Transmit timeout is only called if we are running, carries is up
2600 * and tx queue is full (stopped).
2601 + * Called with netif_tx_lock held.
2602 */
2603 static void sky2_tx_timeout(struct net_device *dev)
2604 {
2605 @@ -1821,17 +1822,14 @@ static void sky2_tx_timeout(struct net_device *dev)
2606 sky2_write8(hw, STAT_TX_TIMER_CTRL, TIM_START);
2607 } else if (report != sky2->tx_cons) {
2608 printk(KERN_INFO PFX "status report lost?\n");
2609 -
2610 - netif_tx_lock_bh(dev);
2611 sky2_tx_complete(sky2, report);
2612 - netif_tx_unlock_bh(dev);
2613 } else {
2614 printk(KERN_INFO PFX "hardware hung? flushing\n");
2615
2616 sky2_write32(hw, Q_ADDR(txq, Q_CSR), BMU_STOP);
2617 sky2_write32(hw, Y2_QADDR(txq, PREF_UNIT_CTRL), PREF_UNIT_RST_SET);
2618
2619 - sky2_tx_clean(dev);
2620 + sky2_tx_complete(sky2, sky2->tx_prod);
2621
2622 sky2_qset(hw, txq);
2623 sky2_prefetch_init(hw, txq, sky2->tx_le_map, TX_RING_SIZE - 1);
2624 diff --git a/drivers/net/sky2.h b/drivers/net/sky2.h
2625 index 6ed1d47..148aab2 100644
2626 --- a/drivers/net/sky2.h
2627 +++ b/drivers/net/sky2.h
2628 @@ -1579,7 +1579,7 @@ enum {
2629
2630 GMR_FS_ANY_ERR = GMR_FS_RX_FF_OV | GMR_FS_CRC_ERR |
2631 GMR_FS_FRAGMENT | GMR_FS_LONG_ERR |
2632 - GMR_FS_MII_ERR | GMR_FS_GOOD_FC | GMR_FS_BAD_FC |
2633 + GMR_FS_MII_ERR | GMR_FS_BAD_FC |
2634 GMR_FS_UN_SIZE | GMR_FS_JABBER,
2635 };
2636
2637 diff --git a/drivers/net/tulip/dmfe.c b/drivers/net/tulip/dmfe.c
2638 index 7f59a3d..4dd8a0b 100644
2639 --- a/drivers/net/tulip/dmfe.c
2640 +++ b/drivers/net/tulip/dmfe.c
2641 @@ -187,7 +187,7 @@ struct rx_desc {
2642 struct dmfe_board_info {
2643 u32 chip_id; /* Chip vendor/Device ID */
2644 u32 chip_revision; /* Chip revision */
2645 - struct DEVICE *dev; /* net device */
2646 + struct DEVICE *next_dev; /* next device */
2647 struct pci_dev *pdev; /* PCI device */
2648 spinlock_t lock;
2649
2650 @@ -399,8 +399,6 @@ static int __devinit dmfe_init_one (struct pci_dev *pdev,
2651 /* Init system & device */
2652 db = netdev_priv(dev);
2653
2654 - db->dev = dev;
2655 -
2656 /* Allocate Tx/Rx descriptor memory */
2657 db->desc_pool_ptr = pci_alloc_consistent(pdev, sizeof(struct tx_desc) * DESC_ALL_CNT + 0x20, &db->desc_pool_dma_ptr);
2658 db->buf_pool_ptr = pci_alloc_consistent(pdev, TX_BUF_ALLOC * TX_DESC_CNT + 4, &db->buf_pool_dma_ptr);
2659 @@ -428,7 +426,6 @@ static int __devinit dmfe_init_one (struct pci_dev *pdev,
2660 dev->poll_controller = &poll_dmfe;
2661 #endif
2662 dev->ethtool_ops = &netdev_ethtool_ops;
2663 - netif_carrier_off(db->dev);
2664 spin_lock_init(&db->lock);
2665
2666 pci_read_config_dword(pdev, 0x50, &pci_pmr);
2667 @@ -1053,7 +1050,6 @@ static void netdev_get_drvinfo(struct net_device *dev,
2668
2669 static const struct ethtool_ops netdev_ethtool_ops = {
2670 .get_drvinfo = netdev_get_drvinfo,
2671 - .get_link = ethtool_op_get_link,
2672 };
2673
2674 /*
2675 @@ -1148,7 +1144,6 @@ static void dmfe_timer(unsigned long data)
2676 /* Link Failed */
2677 DMFE_DBUG(0, "Link Failed", tmp_cr12);
2678 db->link_failed = 1;
2679 - netif_carrier_off(db->dev);
2680
2681 /* For Force 10/100M Half/Full mode: Enable Auto-Nego mode */
2682 /* AUTO or force 1M Homerun/Longrun don't need */
2683 @@ -1171,8 +1166,6 @@ static void dmfe_timer(unsigned long data)
2684 if ( (db->media_mode & DMFE_AUTO) &&
2685 dmfe_sense_speed(db) )
2686 db->link_failed = 1;
2687 - else
2688 - netif_carrier_on(db->dev);
2689 dmfe_process_mode(db);
2690 /* SHOW_MEDIA_TYPE(db->op_mode); */
2691 }
2692 diff --git a/drivers/net/wireless/bcm43xx/bcm43xx.h b/drivers/net/wireless/bcm43xx/bcm43xx.h
2693 index 8286678..02ad9b1 100644
2694 --- a/drivers/net/wireless/bcm43xx/bcm43xx.h
2695 +++ b/drivers/net/wireless/bcm43xx/bcm43xx.h
2696 @@ -21,7 +21,7 @@
2697 #define PFX KBUILD_MODNAME ": "
2698
2699 #define BCM43xx_SWITCH_CORE_MAX_RETRIES 50
2700 -#define BCM43xx_IRQWAIT_MAX_RETRIES 50
2701 +#define BCM43xx_IRQWAIT_MAX_RETRIES 100
2702
2703 #define BCM43xx_IO_SIZE 8192
2704
2705 diff --git a/drivers/net/wireless/bcm43xx/bcm43xx_main.c b/drivers/net/wireless/bcm43xx/bcm43xx_main.c
2706 index 91b752e..629ba91 100644
2707 --- a/drivers/net/wireless/bcm43xx/bcm43xx_main.c
2708 +++ b/drivers/net/wireless/bcm43xx/bcm43xx_main.c
2709 @@ -1453,12 +1453,10 @@ static void handle_irq_transmit_status(struct bcm43xx_private *bcm)
2710
2711 bcm43xx_debugfs_log_txstat(bcm, &stat);
2712
2713 - if (stat.flags & BCM43xx_TXSTAT_FLAG_IGNORE)
2714 + if (stat.flags & BCM43xx_TXSTAT_FLAG_AMPDU)
2715 + continue;
2716 + if (stat.flags & BCM43xx_TXSTAT_FLAG_INTER)
2717 continue;
2718 - if (!(stat.flags & BCM43xx_TXSTAT_FLAG_ACK)) {
2719 - //TODO: packet was not acked (was lost)
2720 - }
2721 - //TODO: There are more (unknown) flags to test. see bcm43xx_main.h
2722
2723 if (bcm43xx_using_pio(bcm))
2724 bcm43xx_pio_handle_xmitstatus(bcm, &stat);
2725 @@ -1866,9 +1864,6 @@ static irqreturn_t bcm43xx_interrupt_handler(int irq, void *dev_id)
2726
2727 spin_lock(&bcm->irq_lock);
2728
2729 - assert(bcm43xx_status(bcm) == BCM43xx_STAT_INITIALIZED);
2730 - assert(bcm->current_core->id == BCM43xx_COREID_80211);
2731 -
2732 reason = bcm43xx_read32(bcm, BCM43xx_MMIO_GEN_IRQ_REASON);
2733 if (reason == 0xffffffff) {
2734 /* irq not for us (shared irq) */
2735 @@ -1879,6 +1874,9 @@ static irqreturn_t bcm43xx_interrupt_handler(int irq, void *dev_id)
2736 if (!reason)
2737 goto out;
2738
2739 + assert(bcm43xx_status(bcm) == BCM43xx_STAT_INITIALIZED);
2740 + assert(bcm->current_core->id == BCM43xx_COREID_80211);
2741 +
2742 bcm->dma_reason[0] = bcm43xx_read32(bcm, BCM43xx_MMIO_DMA0_REASON)
2743 & 0x0001DC00;
2744 bcm->dma_reason[1] = bcm43xx_read32(bcm, BCM43xx_MMIO_DMA1_REASON)
2745 @@ -2738,8 +2736,9 @@ static int bcm43xx_probe_cores(struct bcm43xx_private *bcm)
2746 * dangling pins on the second core. Be careful
2747 * and ignore these cores here.
2748 */
2749 - if (bcm->pci_dev->device != 0x4324) {
2750 - dprintk(KERN_INFO PFX "Ignoring additional 802.11 core.\n");
2751 + if (1 /*bcm->pci_dev->device != 0x4324*/ ) {
2752 + /* TODO: A PHY */
2753 + dprintk(KERN_INFO PFX "Ignoring additional 802.11a core.\n");
2754 continue;
2755 }
2756 }
2757 diff --git a/drivers/net/wireless/bcm43xx/bcm43xx_xmit.h b/drivers/net/wireless/bcm43xx/bcm43xx_xmit.h
2758 index 2aed19e..9ecf2bf 100644
2759 --- a/drivers/net/wireless/bcm43xx/bcm43xx_xmit.h
2760 +++ b/drivers/net/wireless/bcm43xx/bcm43xx_xmit.h
2761 @@ -137,14 +137,8 @@ struct bcm43xx_xmitstatus {
2762 u16 unknown; //FIXME
2763 };
2764
2765 -#define BCM43xx_TXSTAT_FLAG_ACK 0x01
2766 -//TODO #define BCM43xx_TXSTAT_FLAG_??? 0x02
2767 -//TODO #define BCM43xx_TXSTAT_FLAG_??? 0x04
2768 -//TODO #define BCM43xx_TXSTAT_FLAG_??? 0x08
2769 -//TODO #define BCM43xx_TXSTAT_FLAG_??? 0x10
2770 -#define BCM43xx_TXSTAT_FLAG_IGNORE 0x20
2771 -//TODO #define BCM43xx_TXSTAT_FLAG_??? 0x40
2772 -//TODO #define BCM43xx_TXSTAT_FLAG_??? 0x80
2773 +#define BCM43xx_TXSTAT_FLAG_AMPDU 0x10
2774 +#define BCM43xx_TXSTAT_FLAG_INTER 0x20
2775
2776 u8 bcm43xx_plcp_get_ratecode_cck(const u8 bitrate);
2777 u8 bcm43xx_plcp_get_ratecode_ofdm(const u8 bitrate);
2778 diff --git a/drivers/net/wireless/prism54/isl_ioctl.c b/drivers/net/wireless/prism54/isl_ioctl.c
2779 index 838d510..a5396c1 100644
2780 --- a/drivers/net/wireless/prism54/isl_ioctl.c
2781 +++ b/drivers/net/wireless/prism54/isl_ioctl.c
2782 @@ -1395,11 +1395,16 @@ static int prism54_set_auth(struct net_device *ndev,
2783 break;
2784
2785 case IW_AUTH_RX_UNENCRYPTED_EAPOL:
2786 - dot1x = param->value ? 1 : 0;
2787 + /* dot1x should be the opposite of RX_UNENCRYPTED_EAPOL;
2788 + * turn off dot1x when allowing recepit of unencrypted eapol
2789 + * frames, turn on dot1x when we disallow receipt
2790 + */
2791 + dot1x = param->value ? 0x00 : 0x01;
2792 break;
2793
2794 case IW_AUTH_PRIVACY_INVOKED:
2795 privinvoked = param->value ? 1 : 0;
2796 + break;
2797
2798 case IW_AUTH_DROP_UNENCRYPTED:
2799 exunencrypt = param->value ? 1 : 0;
2800 @@ -1589,6 +1594,7 @@ static int prism54_set_encodeext(struct net_device *ndev,
2801 }
2802 key.type = DOT11_PRIV_TKIP;
2803 key.length = KEY_SIZE_TKIP;
2804 + break;
2805 default:
2806 return -EINVAL;
2807 }
2808 diff --git a/drivers/rtc/rtc-pcf8563.c b/drivers/rtc/rtc-pcf8563.c
2809 index 4b72b8e..038118b 100644
2810 --- a/drivers/rtc/rtc-pcf8563.c
2811 +++ b/drivers/rtc/rtc-pcf8563.c
2812 @@ -53,6 +53,25 @@ I2C_CLIENT_INSMOD;
2813 #define PCF8563_SC_LV 0x80 /* low voltage */
2814 #define PCF8563_MO_C 0x80 /* century */
2815
2816 +struct pcf8563 {
2817 + struct i2c_client client;
2818 + /*
2819 + * The meaning of MO_C bit varies by the chip type.
2820 + * From PCF8563 datasheet: this bit is toggled when the years
2821 + * register overflows from 99 to 00
2822 + * 0 indicates the century is 20xx
2823 + * 1 indicates the century is 19xx
2824 + * From RTC8564 datasheet: this bit indicates change of
2825 + * century. When the year digit data overflows from 99 to 00,
2826 + * this bit is set. By presetting it to 0 while still in the
2827 + * 20th century, it will be set in year 2000, ...
2828 + * There seems no reliable way to know how the system use this
2829 + * bit. So let's do it heuristically, assuming we are live in
2830 + * 1970...2069.
2831 + */
2832 + int c_polarity; /* 0: MO_C=1 means 19xx, otherwise MO_C=1 means 20xx */
2833 +};
2834 +
2835 static int pcf8563_probe(struct i2c_adapter *adapter, int address, int kind);
2836 static int pcf8563_detach(struct i2c_client *client);
2837
2838 @@ -62,6 +81,7 @@ static int pcf8563_detach(struct i2c_client *client);
2839 */
2840 static int pcf8563_get_datetime(struct i2c_client *client, struct rtc_time *tm)
2841 {
2842 + struct pcf8563 *pcf8563 = container_of(client, struct pcf8563, client);
2843 unsigned char buf[13] = { PCF8563_REG_ST1 };
2844
2845 struct i2c_msg msgs[] = {
2846 @@ -94,8 +114,12 @@ static int pcf8563_get_datetime(struct i2c_client *client, struct rtc_time *tm)
2847 tm->tm_mday = BCD2BIN(buf[PCF8563_REG_DM] & 0x3F);
2848 tm->tm_wday = buf[PCF8563_REG_DW] & 0x07;
2849 tm->tm_mon = BCD2BIN(buf[PCF8563_REG_MO] & 0x1F) - 1; /* rtc mn 1-12 */
2850 - tm->tm_year = BCD2BIN(buf[PCF8563_REG_YR])
2851 - + (buf[PCF8563_REG_MO] & PCF8563_MO_C ? 0 : 100);
2852 + tm->tm_year = BCD2BIN(buf[PCF8563_REG_YR]);
2853 + if (tm->tm_year < 70)
2854 + tm->tm_year += 100; /* assume we are in 1970...2069 */
2855 + /* detect the polarity heuristically. see note above. */
2856 + pcf8563->c_polarity = (buf[PCF8563_REG_MO] & PCF8563_MO_C) ?
2857 + (tm->tm_year >= 100) : (tm->tm_year < 100);
2858
2859 dev_dbg(&client->dev, "%s: tm is secs=%d, mins=%d, hours=%d, "
2860 "mday=%d, mon=%d, year=%d, wday=%d\n",
2861 @@ -114,6 +138,7 @@ static int pcf8563_get_datetime(struct i2c_client *client, struct rtc_time *tm)
2862
2863 static int pcf8563_set_datetime(struct i2c_client *client, struct rtc_time *tm)
2864 {
2865 + struct pcf8563 *pcf8563 = container_of(client, struct pcf8563, client);
2866 int i, err;
2867 unsigned char buf[9];
2868
2869 @@ -135,7 +160,7 @@ static int pcf8563_set_datetime(struct i2c_client *client, struct rtc_time *tm)
2870
2871 /* year and century */
2872 buf[PCF8563_REG_YR] = BIN2BCD(tm->tm_year % 100);
2873 - if (tm->tm_year < 100)
2874 + if (pcf8563->c_polarity ? (tm->tm_year >= 100) : (tm->tm_year < 100))
2875 buf[PCF8563_REG_MO] |= PCF8563_MO_C;
2876
2877 buf[PCF8563_REG_DW] = tm->tm_wday & 0x07;
2878 @@ -248,6 +273,7 @@ static struct i2c_driver pcf8563_driver = {
2879
2880 static int pcf8563_probe(struct i2c_adapter *adapter, int address, int kind)
2881 {
2882 + struct pcf8563 *pcf8563;
2883 struct i2c_client *client;
2884 struct rtc_device *rtc;
2885
2886 @@ -260,11 +286,12 @@ static int pcf8563_probe(struct i2c_adapter *adapter, int address, int kind)
2887 goto exit;
2888 }
2889
2890 - if (!(client = kzalloc(sizeof(struct i2c_client), GFP_KERNEL))) {
2891 + if (!(pcf8563 = kzalloc(sizeof(struct pcf8563), GFP_KERNEL))) {
2892 err = -ENOMEM;
2893 goto exit;
2894 }
2895
2896 + client = &pcf8563->client;
2897 client->addr = address;
2898 client->driver = &pcf8563_driver;
2899 client->adapter = adapter;
2900 @@ -301,7 +328,7 @@ exit_detach:
2901 i2c_detach_client(client);
2902
2903 exit_kfree:
2904 - kfree(client);
2905 + kfree(pcf8563);
2906
2907 exit:
2908 return err;
2909 @@ -309,6 +336,7 @@ exit:
2910
2911 static int pcf8563_detach(struct i2c_client *client)
2912 {
2913 + struct pcf8563 *pcf8563 = container_of(client, struct pcf8563, client);
2914 int err;
2915 struct rtc_device *rtc = i2c_get_clientdata(client);
2916
2917 @@ -318,7 +346,7 @@ static int pcf8563_detach(struct i2c_client *client)
2918 if ((err = i2c_detach_client(client)))
2919 return err;
2920
2921 - kfree(client);
2922 + kfree(pcf8563);
2923
2924 return 0;
2925 }
2926 diff --git a/drivers/sbus/char/bbc_i2c.c b/drivers/sbus/char/bbc_i2c.c
2927 index 22631f8..8410587 100644
2928 --- a/drivers/sbus/char/bbc_i2c.c
2929 +++ b/drivers/sbus/char/bbc_i2c.c
2930 @@ -187,19 +187,20 @@ static int wait_for_pin(struct bbc_i2c_bus *bp, u8 *status)
2931 bp->waiting = 1;
2932 add_wait_queue(&bp->wq, &wait);
2933 while (limit-- > 0) {
2934 - u8 val;
2935 -
2936 - set_current_state(TASK_INTERRUPTIBLE);
2937 - *status = val = readb(bp->i2c_control_regs + 0);
2938 - if ((val & I2C_PCF_PIN) == 0) {
2939 + unsigned long val;
2940 +
2941 + val = wait_event_interruptible_timeout(
2942 + bp->wq,
2943 + (((*status = readb(bp->i2c_control_regs + 0))
2944 + & I2C_PCF_PIN) == 0),
2945 + msecs_to_jiffies(250));
2946 + if (val > 0) {
2947 ret = 0;
2948 break;
2949 }
2950 - msleep_interruptible(250);
2951 }
2952 remove_wait_queue(&bp->wq, &wait);
2953 bp->waiting = 0;
2954 - current->state = TASK_RUNNING;
2955
2956 return ret;
2957 }
2958 @@ -340,7 +341,7 @@ static irqreturn_t bbc_i2c_interrupt(int irq, void *dev_id)
2959 */
2960 if (bp->waiting &&
2961 !(readb(bp->i2c_control_regs + 0x0) & I2C_PCF_PIN))
2962 - wake_up(&bp->wq);
2963 + wake_up_interruptible(&bp->wq);
2964
2965 return IRQ_HANDLED;
2966 }
2967 diff --git a/drivers/usb/atm/ueagle-atm.c b/drivers/usb/atm/ueagle-atm.c
2968 index dae4ef1..4973e14 100644
2969 --- a/drivers/usb/atm/ueagle-atm.c
2970 +++ b/drivers/usb/atm/ueagle-atm.c
2971 @@ -61,6 +61,7 @@
2972 #include <linux/usb.h>
2973 #include <linux/firmware.h>
2974 #include <linux/ctype.h>
2975 +#include <linux/sched.h>
2976 #include <linux/kthread.h>
2977 #include <linux/version.h>
2978 #include <linux/mutex.h>
2979 diff --git a/drivers/usb/core/hub.c b/drivers/usb/core/hub.c
2980 index 1988224..8ddeed3 100644
2981 --- a/drivers/usb/core/hub.c
2982 +++ b/drivers/usb/core/hub.c
2983 @@ -44,6 +44,7 @@ struct usb_hub {
2984 struct usb_hub_status hub;
2985 struct usb_port_status port;
2986 } *status; /* buffer for status reports */
2987 + struct mutex status_mutex; /* for the status buffer */
2988
2989 int error; /* last reported error */
2990 int nerrors; /* track consecutive errors */
2991 @@ -538,6 +539,7 @@ static int hub_hub_status(struct usb_hub *hub,
2992 {
2993 int ret;
2994
2995 + mutex_lock(&hub->status_mutex);
2996 ret = get_hub_status(hub->hdev, &hub->status->hub);
2997 if (ret < 0)
2998 dev_err (hub->intfdev,
2999 @@ -547,6 +549,7 @@ static int hub_hub_status(struct usb_hub *hub,
3000 *change = le16_to_cpu(hub->status->hub.wHubChange);
3001 ret = 0;
3002 }
3003 + mutex_unlock(&hub->status_mutex);
3004 return ret;
3005 }
3006
3007 @@ -620,6 +623,7 @@ static int hub_configure(struct usb_hub *hub,
3008 ret = -ENOMEM;
3009 goto fail;
3010 }
3011 + mutex_init(&hub->status_mutex);
3012
3013 hub->descriptor = kmalloc(sizeof(*hub->descriptor), GFP_KERNEL);
3014 if (!hub->descriptor) {
3015 @@ -1418,6 +1422,7 @@ static int hub_port_status(struct usb_hub *hub, int port1,
3016 {
3017 int ret;
3018
3019 + mutex_lock(&hub->status_mutex);
3020 ret = get_port_status(hub->hdev, port1, &hub->status->port);
3021 if (ret < 4) {
3022 dev_err (hub->intfdev,
3023 @@ -1429,6 +1434,7 @@ static int hub_port_status(struct usb_hub *hub, int port1,
3024 *change = le16_to_cpu(hub->status->port.wPortChange);
3025 ret = 0;
3026 }
3027 + mutex_unlock(&hub->status_mutex);
3028 return ret;
3029 }
3030
3031 diff --git a/drivers/usb/host/ehci-hcd.c b/drivers/usb/host/ehci-hcd.c
3032 index 025d333..6e9fdd6 100644
3033 --- a/drivers/usb/host/ehci-hcd.c
3034 +++ b/drivers/usb/host/ehci-hcd.c
3035 @@ -296,6 +296,18 @@ static void ehci_watchdog (unsigned long param)
3036 spin_unlock_irqrestore (&ehci->lock, flags);
3037 }
3038
3039 +/* On some systems, leaving remote wakeup enabled prevents system shutdown.
3040 + * The firmware seems to think that powering off is a wakeup event!
3041 + * This routine turns off remote wakeup and everything else, on all ports.
3042 + */
3043 +static void ehci_turn_off_all_ports(struct ehci_hcd *ehci)
3044 +{
3045 + int port = HCS_N_PORTS(ehci->hcs_params);
3046 +
3047 + while (port--)
3048 + writel(PORT_RWC_BITS, &ehci->regs->port_status[port]);
3049 +}
3050 +
3051 /* ehci_shutdown kick in for silicon on any bus (not just pci, etc).
3052 * This forcibly disables dma and IRQs, helping kexec and other cases
3053 * where the next system software may expect clean state.
3054 @@ -307,9 +319,13 @@ ehci_shutdown (struct usb_hcd *hcd)
3055
3056 ehci = hcd_to_ehci (hcd);
3057 (void) ehci_halt (ehci);
3058 + ehci_turn_off_all_ports(ehci);
3059
3060 /* make BIOS/etc use companion controller during reboot */
3061 writel (0, &ehci->regs->configured_flag);
3062 +
3063 + /* unblock posted writes */
3064 + readl(&ehci->regs->configured_flag);
3065 }
3066
3067 static void ehci_port_power (struct ehci_hcd *ehci, int is_on)
3068 diff --git a/drivers/usb/host/uhci-hub.c b/drivers/usb/host/uhci-hub.c
3069 index bacc25c..8e4427a 100644
3070 --- a/drivers/usb/host/uhci-hub.c
3071 +++ b/drivers/usb/host/uhci-hub.c
3072 @@ -33,6 +33,9 @@ static __u8 root_hub_hub_des[] =
3073 /* status change bits: nonzero writes will clear */
3074 #define RWC_BITS (USBPORTSC_OCC | USBPORTSC_PEC | USBPORTSC_CSC)
3075
3076 +/* suspend/resume bits: port suspended or port resuming */
3077 +#define SUSPEND_BITS (USBPORTSC_SUSP | USBPORTSC_RD)
3078 +
3079 /* A port that either is connected or has a changed-bit set will prevent
3080 * us from AUTO_STOPPING.
3081 */
3082 @@ -96,8 +99,8 @@ static void uhci_finish_suspend(struct uhci_hcd *uhci, int port,
3083 int status;
3084 int i;
3085
3086 - if (inw(port_addr) & (USBPORTSC_SUSP | USBPORTSC_RD)) {
3087 - CLR_RH_PORTSTAT(USBPORTSC_SUSP | USBPORTSC_RD);
3088 + if (inw(port_addr) & SUSPEND_BITS) {
3089 + CLR_RH_PORTSTAT(SUSPEND_BITS);
3090 if (test_bit(port, &uhci->resuming_ports))
3091 set_bit(port, &uhci->port_c_suspend);
3092
3093 @@ -107,7 +110,7 @@ static void uhci_finish_suspend(struct uhci_hcd *uhci, int port,
3094 * Experiments show that some controllers take longer, so
3095 * we'll poll for completion. */
3096 for (i = 0; i < 10; ++i) {
3097 - if (!(inw(port_addr) & USBPORTSC_RD))
3098 + if (!(inw(port_addr) & SUSPEND_BITS))
3099 break;
3100 udelay(1);
3101 }
3102 @@ -289,7 +292,7 @@ static int uhci_hub_control(struct usb_hcd *hcd, u16 typeReq, u16 wValue,
3103 wPortStatus |= USB_PORT_STAT_CONNECTION;
3104 if (status & USBPORTSC_PE) {
3105 wPortStatus |= USB_PORT_STAT_ENABLE;
3106 - if (status & (USBPORTSC_SUSP | USBPORTSC_RD))
3107 + if (status & SUSPEND_BITS)
3108 wPortStatus |= USB_PORT_STAT_SUSPEND;
3109 }
3110 if (status & USBPORTSC_OC)
3111 diff --git a/drivers/usb/input/hid-core.c b/drivers/usb/input/hid-core.c
3112 index c6c9e72..dd9e546 100644
3113 --- a/drivers/usb/input/hid-core.c
3114 +++ b/drivers/usb/input/hid-core.c
3115 @@ -1212,8 +1212,8 @@ static struct hid_device *usb_hid_configure(struct usb_interface *intf)
3116 le16_to_cpu(dev->descriptor.idProduct));
3117
3118 hid->bus = BUS_USB;
3119 - hid->vendor = dev->descriptor.idVendor;
3120 - hid->product = dev->descriptor.idProduct;
3121 + hid->vendor = le16_to_cpu(dev->descriptor.idVendor);
3122 + hid->product = le16_to_cpu(dev->descriptor.idProduct);
3123
3124 usb_make_path(dev, hid->phys, sizeof(hid->phys));
3125 strlcat(hid->phys, "/input", sizeof(hid->phys));
3126 diff --git a/drivers/usb/misc/appledisplay.c b/drivers/usb/misc/appledisplay.c
3127 index a7932a7..32f0e3a 100644
3128 --- a/drivers/usb/misc/appledisplay.c
3129 +++ b/drivers/usb/misc/appledisplay.c
3130 @@ -281,8 +281,8 @@ static int appledisplay_probe(struct usb_interface *iface,
3131 /* Register backlight device */
3132 snprintf(bl_name, sizeof(bl_name), "appledisplay%d",
3133 atomic_inc_return(&count_displays) - 1);
3134 - pdata->bd = backlight_device_register(bl_name, NULL, NULL,
3135 - &appledisplay_bl_data);
3136 + pdata->bd = backlight_device_register(bl_name, NULL,
3137 + pdata, &appledisplay_bl_data);
3138 if (IS_ERR(pdata->bd)) {
3139 err("appledisplay: Backlight registration failed");
3140 goto error;
3141 diff --git a/drivers/usb/net/usbnet.c b/drivers/usb/net/usbnet.c
3142 index 6e39e99..d2acc15 100644
3143 --- a/drivers/usb/net/usbnet.c
3144 +++ b/drivers/usb/net/usbnet.c
3145 @@ -1182,6 +1182,9 @@ usbnet_probe (struct usb_interface *udev, const struct usb_device_id *prod)
3146 // NOTE net->name still not usable ...
3147 if (info->bind) {
3148 status = info->bind (dev, udev);
3149 + if (status < 0)
3150 + goto out1;
3151 +
3152 // heuristic: "usb%d" for links we know are two-host,
3153 // else "eth%d" when there's reasonable doubt. userspace
3154 // can rename the link if it knows better.
3155 @@ -1208,12 +1211,12 @@ usbnet_probe (struct usb_interface *udev, const struct usb_device_id *prod)
3156 if (status == 0 && dev->status)
3157 status = init_status (dev, udev);
3158 if (status < 0)
3159 - goto out1;
3160 + goto out3;
3161
3162 if (!dev->rx_urb_size)
3163 dev->rx_urb_size = dev->hard_mtu;
3164 dev->maxpacket = usb_maxpacket (dev->udev, dev->out, 1);
3165 -
3166 +
3167 SET_NETDEV_DEV(net, &udev->dev);
3168 status = register_netdev (net);
3169 if (status)
3170 diff --git a/drivers/video/aty/mach64_ct.c b/drivers/video/aty/mach64_ct.c
3171 index f3b487b..1fdcfdb 100644
3172 --- a/drivers/video/aty/mach64_ct.c
3173 +++ b/drivers/video/aty/mach64_ct.c
3174 @@ -598,7 +598,6 @@ static void aty_resume_pll_ct(const struct fb_info *info,
3175 struct atyfb_par *par = info->par;
3176
3177 if (par->mclk_per != par->xclk_per) {
3178 - int i;
3179 /*
3180 * This disables the sclk, crashes the computer as reported:
3181 * aty_st_pll_ct(SPLL_CNTL2, 3, info);
3182 @@ -614,7 +613,7 @@ static void aty_resume_pll_ct(const struct fb_info *info,
3183 * helps for Rage Mobilities that sometimes crash when
3184 * we switch to sclk. (Daniel Mantione, 13-05-2003)
3185 */
3186 - for (i=0;i<=0x1ffff;i++);
3187 + udelay(500);
3188 }
3189
3190 aty_st_pll_ct(PLL_REF_DIV, pll->ct.pll_ref_div, par);
3191 diff --git a/fs/9p/vfs_inode.c b/fs/9p/vfs_inode.c
3192 index 9109ba1..378767c 100644
3193 --- a/fs/9p/vfs_inode.c
3194 +++ b/fs/9p/vfs_inode.c
3195 @@ -585,17 +585,14 @@ static int v9fs_vfs_mkdir(struct inode *dir, struct dentry *dentry, int mode)
3196 if (IS_ERR(inode)) {
3197 err = PTR_ERR(inode);
3198 inode = NULL;
3199 - goto clean_up_fids;
3200 + v9fs_fid_destroy(vfid);
3201 + goto error;
3202 }
3203
3204 dentry->d_op = &v9fs_dentry_operations;
3205 d_instantiate(dentry, inode);
3206 return 0;
3207
3208 -clean_up_fids:
3209 - if (vfid)
3210 - v9fs_fid_destroy(vfid);
3211 -
3212 clean_up_dfid:
3213 v9fs_fid_clunk(v9ses, dfid);
3214
3215 diff --git a/fs/binfmt_elf.c b/fs/binfmt_elf.c
3216 index 669dbe5..51db118 100644
3217 --- a/fs/binfmt_elf.c
3218 +++ b/fs/binfmt_elf.c
3219 @@ -76,7 +76,8 @@ static struct linux_binfmt elf_format = {
3220 .load_binary = load_elf_binary,
3221 .load_shlib = load_elf_library,
3222 .core_dump = elf_core_dump,
3223 - .min_coredump = ELF_EXEC_PAGESIZE
3224 + .min_coredump = ELF_EXEC_PAGESIZE,
3225 + .hasvdso = 1
3226 };
3227
3228 #define BAD_ADDR(x) ((unsigned long)(x) >= TASK_SIZE)
3229 diff --git a/fs/buffer.c b/fs/buffer.c
3230 index 1ad674f..05c5d02 100644
3231 --- a/fs/buffer.c
3232 +++ b/fs/buffer.c
3233 @@ -78,6 +78,7 @@ EXPORT_SYMBOL(__lock_buffer);
3234
3235 void fastcall unlock_buffer(struct buffer_head *bh)
3236 {
3237 + smp_mb__before_clear_bit();
3238 clear_buffer_locked(bh);
3239 smp_mb__after_clear_bit();
3240 wake_up_bit(&bh->b_state, BH_Lock);
3241 diff --git a/fs/ext2/super.c b/fs/ext2/super.c
3242 index 6347c2d..daaa243 100644
3243 --- a/fs/ext2/super.c
3244 +++ b/fs/ext2/super.c
3245 @@ -708,10 +708,14 @@ static int ext2_fill_super(struct super_block *sb, void *data, int silent)
3246 set_opt(sbi->s_mount_opt, GRPID);
3247 if (def_mount_opts & EXT2_DEFM_UID16)
3248 set_opt(sbi->s_mount_opt, NO_UID32);
3249 +#ifdef CONFIG_EXT2_FS_XATTR
3250 if (def_mount_opts & EXT2_DEFM_XATTR_USER)
3251 set_opt(sbi->s_mount_opt, XATTR_USER);
3252 +#endif
3253 +#ifdef CONFIG_EXT2_FS_POSIX_ACL
3254 if (def_mount_opts & EXT2_DEFM_ACL)
3255 set_opt(sbi->s_mount_opt, POSIX_ACL);
3256 +#endif
3257
3258 if (le16_to_cpu(sbi->s_es->s_errors) == EXT2_ERRORS_PANIC)
3259 set_opt(sbi->s_mount_opt, ERRORS_PANIC);
3260 diff --git a/fs/ext3/super.c b/fs/ext3/super.c
3261 index b348867..1c0a51b 100644
3262 --- a/fs/ext3/super.c
3263 +++ b/fs/ext3/super.c
3264 @@ -1459,10 +1459,14 @@ static int ext3_fill_super (struct super_block *sb, void *data, int silent)
3265 set_opt(sbi->s_mount_opt, GRPID);
3266 if (def_mount_opts & EXT3_DEFM_UID16)
3267 set_opt(sbi->s_mount_opt, NO_UID32);
3268 +#ifdef CONFIG_EXT3_FS_XATTR
3269 if (def_mount_opts & EXT3_DEFM_XATTR_USER)
3270 set_opt(sbi->s_mount_opt, XATTR_USER);
3271 +#endif
3272 +#ifdef CONFIG_EXT3_FS_POSIX_ACL
3273 if (def_mount_opts & EXT3_DEFM_ACL)
3274 set_opt(sbi->s_mount_opt, POSIX_ACL);
3275 +#endif
3276 if ((def_mount_opts & EXT3_DEFM_JMODE) == EXT3_DEFM_JMODE_DATA)
3277 sbi->s_mount_opt |= EXT3_MOUNT_JOURNAL_DATA;
3278 else if ((def_mount_opts & EXT3_DEFM_JMODE) == EXT3_DEFM_JMODE_ORDERED)
3279 diff --git a/fs/ext4/super.c b/fs/ext4/super.c
3280 index 486a641..fa1d1f3 100644
3281 --- a/fs/ext4/super.c
3282 +++ b/fs/ext4/super.c
3283 @@ -1518,10 +1518,14 @@ static int ext4_fill_super (struct super_block *sb, void *data, int silent)
3284 set_opt(sbi->s_mount_opt, GRPID);
3285 if (def_mount_opts & EXT4_DEFM_UID16)
3286 set_opt(sbi->s_mount_opt, NO_UID32);
3287 +#ifdef CONFIG_EXT4DEV_FS_XATTR
3288 if (def_mount_opts & EXT4_DEFM_XATTR_USER)
3289 set_opt(sbi->s_mount_opt, XATTR_USER);
3290 +#endif
3291 +#ifdef CONFIG_EXT4DEV_FS_POSIX_ACL
3292 if (def_mount_opts & EXT4_DEFM_ACL)
3293 set_opt(sbi->s_mount_opt, POSIX_ACL);
3294 +#endif
3295 if ((def_mount_opts & EXT4_DEFM_JMODE) == EXT4_DEFM_JMODE_DATA)
3296 sbi->s_mount_opt |= EXT4_MOUNT_JOURNAL_DATA;
3297 else if ((def_mount_opts & EXT4_DEFM_JMODE) == EXT4_DEFM_JMODE_ORDERED)
3298 diff --git a/fs/gfs2/quota.c b/fs/gfs2/quota.c
3299 index d0db881..c186857 100644
3300 --- a/fs/gfs2/quota.c
3301 +++ b/fs/gfs2/quota.c
3302 @@ -279,7 +279,7 @@ static int bh_get(struct gfs2_quota_data *qd)
3303 (bh->b_data + sizeof(struct gfs2_meta_header) +
3304 offset * sizeof(struct gfs2_quota_change));
3305
3306 - mutex_lock(&sdp->sd_quota_mutex);
3307 + mutex_unlock(&sdp->sd_quota_mutex);
3308
3309 return 0;
3310
3311 diff --git a/fs/hugetlbfs/inode.c b/fs/hugetlbfs/inode.c
3312 index 4f4cd13..e6bd553 100644
3313 --- a/fs/hugetlbfs/inode.c
3314 +++ b/fs/hugetlbfs/inode.c
3315 @@ -449,10 +449,13 @@ static int hugetlbfs_symlink(struct inode *dir,
3316 }
3317
3318 /*
3319 - * For direct-IO reads into hugetlb pages
3320 + * mark the head page dirty
3321 */
3322 static int hugetlbfs_set_page_dirty(struct page *page)
3323 {
3324 + struct page *head = (struct page *)page_private(page);
3325 +
3326 + SetPageDirty(head);
3327 return 0;
3328 }
3329
3330 diff --git a/fs/lockd/clntproc.c b/fs/lockd/clntproc.c
3331 index 0b4acc1..a5c019e 100644
3332 --- a/fs/lockd/clntproc.c
3333 +++ b/fs/lockd/clntproc.c
3334 @@ -361,7 +361,6 @@ static int __nlm_async_call(struct nlm_rqst *req, u32 proc, struct rpc_message *
3335 {
3336 struct nlm_host *host = req->a_host;
3337 struct rpc_clnt *clnt;
3338 - int status = -ENOLCK;
3339
3340 dprintk("lockd: call procedure %d on %s (async)\n",
3341 (int)proc, host->h_name);
3342 @@ -373,12 +372,10 @@ static int __nlm_async_call(struct nlm_rqst *req, u32 proc, struct rpc_message *
3343 msg->rpc_proc = &clnt->cl_procinfo[proc];
3344
3345 /* bootstrap and kick off the async RPC call */
3346 - status = rpc_call_async(clnt, msg, RPC_TASK_ASYNC, tk_ops, req);
3347 - if (status == 0)
3348 - return 0;
3349 + return rpc_call_async(clnt, msg, RPC_TASK_ASYNC, tk_ops, req);
3350 out_err:
3351 - nlm_release_call(req);
3352 - return status;
3353 + tk_ops->rpc_release(req);
3354 + return -ENOLCK;
3355 }
3356
3357 int nlm_async_call(struct nlm_rqst *req, u32 proc, const struct rpc_call_ops *tk_ops)
3358 diff --git a/fs/lockd/svclock.c b/fs/lockd/svclock.c
3359 index c7db0a5..cf51f84 100644
3360 --- a/fs/lockd/svclock.c
3361 +++ b/fs/lockd/svclock.c
3362 @@ -593,9 +593,7 @@ callback:
3363
3364 /* Call the client */
3365 kref_get(&block->b_count);
3366 - if (nlm_async_call(block->b_call, NLMPROC_GRANTED_MSG,
3367 - &nlmsvc_grant_ops) < 0)
3368 - nlmsvc_release_block(block);
3369 + nlm_async_call(block->b_call, NLMPROC_GRANTED_MSG, &nlmsvc_grant_ops);
3370 }
3371
3372 /*
3373 diff --git a/fs/ocfs2/journal.h b/fs/ocfs2/journal.h
3374 index e121636..d026b4f 100644
3375 --- a/fs/ocfs2/journal.h
3376 +++ b/fs/ocfs2/journal.h
3377 @@ -306,8 +306,8 @@ int ocfs2_journal_dirty_data(handle_t *handle,
3378 * for the dinode, one for the new block. */
3379 #define OCFS2_SIMPLE_DIR_EXTEND_CREDITS (2)
3380
3381 -/* file update (nlink, etc) + dir entry block */
3382 -#define OCFS2_LINK_CREDITS (OCFS2_INODE_UPDATE_CREDITS + 1)
3383 +/* file update (nlink, etc) + directory mtime/ctime + dir entry block */
3384 +#define OCFS2_LINK_CREDITS (2*OCFS2_INODE_UPDATE_CREDITS + 1)
3385
3386 /* inode + dir inode (if we unlink a dir), + dir entry block + orphan
3387 * dir inode link */
3388 diff --git a/fs/ufs/dir.c b/fs/ufs/dir.c
3389 index 433b6f6..a6c0ca9 100644
3390 --- a/fs/ufs/dir.c
3391 +++ b/fs/ufs/dir.c
3392 @@ -106,12 +106,13 @@ static void ufs_check_page(struct page *page)
3393 char *kaddr = page_address(page);
3394 unsigned offs, rec_len;
3395 unsigned limit = PAGE_CACHE_SIZE;
3396 + const unsigned chunk_mask = UFS_SB(sb)->s_uspi->s_dirblksize - 1;
3397 struct ufs_dir_entry *p;
3398 char *error;
3399
3400 if ((dir->i_size >> PAGE_CACHE_SHIFT) == page->index) {
3401 limit = dir->i_size & ~PAGE_CACHE_MASK;
3402 - if (limit & (UFS_SECTOR_SIZE - 1))
3403 + if (limit & chunk_mask)
3404 goto Ebadsize;
3405 if (!limit)
3406 goto out;
3407 @@ -126,7 +127,7 @@ static void ufs_check_page(struct page *page)
3408 goto Ealign;
3409 if (rec_len < UFS_DIR_REC_LEN(ufs_get_de_namlen(sb, p)))
3410 goto Enamelen;
3411 - if (((offs + rec_len - 1) ^ offs) & ~(UFS_SECTOR_SIZE-1))
3412 + if (((offs + rec_len - 1) ^ offs) & ~chunk_mask)
3413 goto Espan;
3414 if (fs32_to_cpu(sb, p->d_ino) > (UFS_SB(sb)->s_uspi->s_ipg *
3415 UFS_SB(sb)->s_uspi->s_ncg))
3416 @@ -310,6 +311,7 @@ int ufs_add_link(struct dentry *dentry, struct inode *inode)
3417 int namelen = dentry->d_name.len;
3418 struct super_block *sb = dir->i_sb;
3419 unsigned reclen = UFS_DIR_REC_LEN(namelen);
3420 + const unsigned int chunk_size = UFS_SB(sb)->s_uspi->s_dirblksize;
3421 unsigned short rec_len, name_len;
3422 struct page *page = NULL;
3423 struct ufs_dir_entry *de;
3424 @@ -342,8 +344,8 @@ int ufs_add_link(struct dentry *dentry, struct inode *inode)
3425 if ((char *)de == dir_end) {
3426 /* We hit i_size */
3427 name_len = 0;
3428 - rec_len = UFS_SECTOR_SIZE;
3429 - de->d_reclen = cpu_to_fs16(sb, UFS_SECTOR_SIZE);
3430 + rec_len = chunk_size;
3431 + de->d_reclen = cpu_to_fs16(sb, chunk_size);
3432 de->d_ino = 0;
3433 goto got_it;
3434 }
3435 @@ -431,7 +433,7 @@ ufs_readdir(struct file *filp, void *dirent, filldir_t filldir)
3436 unsigned int offset = pos & ~PAGE_CACHE_MASK;
3437 unsigned long n = pos >> PAGE_CACHE_SHIFT;
3438 unsigned long npages = ufs_dir_pages(inode);
3439 - unsigned chunk_mask = ~(UFS_SECTOR_SIZE - 1);
3440 + unsigned chunk_mask = ~(UFS_SB(sb)->s_uspi->s_dirblksize - 1);
3441 int need_revalidate = filp->f_version != inode->i_version;
3442 unsigned flags = UFS_SB(sb)->s_flags;
3443
3444 @@ -511,7 +513,7 @@ int ufs_delete_entry(struct inode *inode, struct ufs_dir_entry *dir,
3445 struct super_block *sb = inode->i_sb;
3446 struct address_space *mapping = page->mapping;
3447 char *kaddr = page_address(page);
3448 - unsigned from = ((char*)dir - kaddr) & ~(UFS_SECTOR_SIZE - 1);
3449 + unsigned from = ((char*)dir - kaddr) & ~(UFS_SB(sb)->s_uspi->s_dirblksize - 1);
3450 unsigned to = ((char*)dir - kaddr) + fs16_to_cpu(sb, dir->d_reclen);
3451 struct ufs_dir_entry *pde = NULL;
3452 struct ufs_dir_entry *de = (struct ufs_dir_entry *) (kaddr + from);
3453 @@ -556,6 +558,7 @@ int ufs_make_empty(struct inode * inode, struct inode *dir)
3454 struct super_block * sb = dir->i_sb;
3455 struct address_space *mapping = inode->i_mapping;
3456 struct page *page = grab_cache_page(mapping, 0);
3457 + const unsigned int chunk_size = UFS_SB(sb)->s_uspi->s_dirblksize;
3458 struct ufs_dir_entry * de;
3459 char *base;
3460 int err;
3461 @@ -563,7 +566,7 @@ int ufs_make_empty(struct inode * inode, struct inode *dir)
3462 if (!page)
3463 return -ENOMEM;
3464 kmap(page);
3465 - err = mapping->a_ops->prepare_write(NULL, page, 0, UFS_SECTOR_SIZE);
3466 + err = mapping->a_ops->prepare_write(NULL, page, 0, chunk_size);
3467 if (err) {
3468 unlock_page(page);
3469 goto fail;
3470 @@ -584,11 +587,11 @@ int ufs_make_empty(struct inode * inode, struct inode *dir)
3471 ((char *)de + fs16_to_cpu(sb, de->d_reclen));
3472 de->d_ino = cpu_to_fs32(sb, dir->i_ino);
3473 ufs_set_de_type(sb, de, dir->i_mode);
3474 - de->d_reclen = cpu_to_fs16(sb, UFS_SECTOR_SIZE - UFS_DIR_REC_LEN(1));
3475 + de->d_reclen = cpu_to_fs16(sb, chunk_size - UFS_DIR_REC_LEN(1));
3476 ufs_set_de_namlen(sb, de, 2);
3477 strcpy (de->d_name, "..");
3478
3479 - err = ufs_commit_chunk(page, 0, UFS_SECTOR_SIZE);
3480 + err = ufs_commit_chunk(page, 0, chunk_size);
3481 fail:
3482 kunmap(page);
3483 page_cache_release(page);
3484 diff --git a/fs/ufs/super.c b/fs/ufs/super.c
3485 index 8a8e938..209be95 100644
3486 --- a/fs/ufs/super.c
3487 +++ b/fs/ufs/super.c
3488 @@ -649,7 +649,7 @@ static int ufs_fill_super(struct super_block *sb, void *data, int silent)
3489 kmalloc (sizeof(struct ufs_sb_private_info), GFP_KERNEL);
3490 if (!uspi)
3491 goto failed;
3492 -
3493 + uspi->s_dirblksize = UFS_SECTOR_SIZE;
3494 super_block_offset=UFS_SBLOCK;
3495
3496 /* Keep 2Gig file limit. Some UFS variants need to override
3497 @@ -718,6 +718,7 @@ static int ufs_fill_super(struct super_block *sb, void *data, int silent)
3498 break;
3499
3500 case UFS_MOUNT_UFSTYPE_NEXTSTEP:
3501 + /*TODO: check may be we need set special dir block size?*/
3502 UFSD("ufstype=nextstep\n");
3503 uspi->s_fsize = block_size = 1024;
3504 uspi->s_fmask = ~(1024 - 1);
3505 @@ -733,6 +734,7 @@ static int ufs_fill_super(struct super_block *sb, void *data, int silent)
3506 break;
3507
3508 case UFS_MOUNT_UFSTYPE_NEXTSTEP_CD:
3509 + /*TODO: check may be we need set special dir block size?*/
3510 UFSD("ufstype=nextstep-cd\n");
3511 uspi->s_fsize = block_size = 2048;
3512 uspi->s_fmask = ~(2048 - 1);
3513 @@ -754,6 +756,7 @@ static int ufs_fill_super(struct super_block *sb, void *data, int silent)
3514 uspi->s_fshift = 10;
3515 uspi->s_sbsize = super_block_size = 2048;
3516 uspi->s_sbbase = 0;
3517 + uspi->s_dirblksize = 1024;
3518 flags |= UFS_DE_44BSD | UFS_UID_44BSD | UFS_ST_44BSD | UFS_CG_44BSD;
3519 if (!(sb->s_flags & MS_RDONLY)) {
3520 if (!silent)
3521 diff --git a/include/asm-generic/page.h b/include/asm-generic/page.h
3522 index b55052c..a96b5d9 100644
3523 --- a/include/asm-generic/page.h
3524 +++ b/include/asm-generic/page.h
3525 @@ -4,51 +4,21 @@
3526 #ifdef __KERNEL__
3527 #ifndef __ASSEMBLY__
3528
3529 -#include <linux/log2.h>
3530 +#include <linux/compiler.h>
3531
3532 -/*
3533 - * non-const pure 2^n version of get_order
3534 - * - the arch may override these in asm/bitops.h if they can be implemented
3535 - * more efficiently than using the arch log2 routines
3536 - * - we use the non-const log2() instead if the arch has defined one suitable
3537 - */
3538 -#ifndef ARCH_HAS_GET_ORDER
3539 -static inline __attribute__((const))
3540 -int __get_order(unsigned long size, int page_shift)
3541 +/* Pure 2^n version of get_order */
3542 +static __inline__ __attribute_const__ int get_order(unsigned long size)
3543 {
3544 -#if BITS_PER_LONG == 32 && defined(ARCH_HAS_ILOG2_U32)
3545 - int order = __ilog2_u32(size) - page_shift;
3546 - return order >= 0 ? order : 0;
3547 -#elif BITS_PER_LONG == 64 && defined(ARCH_HAS_ILOG2_U64)
3548 - int order = __ilog2_u64(size) - page_shift;
3549 - return order >= 0 ? order : 0;
3550 -#else
3551 int order;
3552
3553 - size = (size - 1) >> (page_shift - 1);
3554 + size = (size - 1) >> (PAGE_SHIFT - 1);
3555 order = -1;
3556 do {
3557 size >>= 1;
3558 order++;
3559 } while (size);
3560 return order;
3561 -#endif
3562 }
3563 -#endif
3564 -
3565 -/**
3566 - * get_order - calculate log2(pages) to hold a block of the specified size
3567 - * @n - size
3568 - *
3569 - * calculate allocation order based on the current page size
3570 - * - this can be used to initialise global variables from constant data
3571 - */
3572 -#define get_order(n) \
3573 -( \
3574 - __builtin_constant_p(n) ? \
3575 - ((n < (1UL << PAGE_SHIFT)) ? 0 : ilog2(n) - PAGE_SHIFT) : \
3576 - __get_order(n, PAGE_SHIFT) \
3577 - )
3578
3579 #endif /* __ASSEMBLY__ */
3580 #endif /* __KERNEL__ */
3581 diff --git a/include/asm-ia64/libata-portmap.h b/include/asm-ia64/libata-portmap.h
3582 new file mode 100644
3583 index 0000000..0e00c9a
3584 --- /dev/null
3585 +++ b/include/asm-ia64/libata-portmap.h
3586 @@ -0,0 +1,12 @@
3587 +#ifndef __ASM_IA64_LIBATA_PORTMAP_H
3588 +#define __ASM_IA64_LIBATA_PORTMAP_H
3589 +
3590 +#define ATA_PRIMARY_CMD 0x1F0
3591 +#define ATA_PRIMARY_CTL 0x3F6
3592 +#define ATA_PRIMARY_IRQ(dev) isa_irq_to_vector(14)
3593 +
3594 +#define ATA_SECONDARY_CMD 0x170
3595 +#define ATA_SECONDARY_CTL 0x376
3596 +#define ATA_SECONDARY_IRQ(dev) isa_irq_to_vector(15)
3597 +
3598 +#endif
3599 diff --git a/include/asm-x86_64/bitops.h b/include/asm-x86_64/bitops.h
3600 index 8da9609..d4dbbe5 100644
3601 --- a/include/asm-x86_64/bitops.h
3602 +++ b/include/asm-x86_64/bitops.h
3603 @@ -7,7 +7,7 @@
3604
3605 #include <asm/alternative.h>
3606
3607 -#if __GNUC__ < 4 || __GNUC_MINOR__ < 1
3608 +#if __GNUC__ < 4 || (__GNUC__ == 4 && __GNUC_MINOR__ < 1)
3609 /* Technically wrong, but this avoids compilation errors on some gcc
3610 versions. */
3611 #define ADDR "=m" (*(volatile long *) addr)
3612 diff --git a/include/linux/atmarp.h b/include/linux/atmarp.h
3613 index ee108f9..231f4bd 100644
3614 --- a/include/linux/atmarp.h
3615 +++ b/include/linux/atmarp.h
3616 @@ -6,9 +6,7 @@
3617 #ifndef _LINUX_ATMARP_H
3618 #define _LINUX_ATMARP_H
3619
3620 -#ifdef __KERNEL__
3621 #include <linux/types.h>
3622 -#endif
3623 #include <linux/atmapi.h>
3624 #include <linux/atmioc.h>
3625
3626 diff --git a/include/linux/binfmts.h b/include/linux/binfmts.h
3627 index c1e82c5..2d956cd 100644
3628 --- a/include/linux/binfmts.h
3629 +++ b/include/linux/binfmts.h
3630 @@ -59,6 +59,7 @@ struct linux_binfmt {
3631 int (*load_shlib)(struct file *);
3632 int (*core_dump)(long signr, struct pt_regs * regs, struct file * file);
3633 unsigned long min_coredump; /* minimal dump size */
3634 + int hasvdso;
3635 };
3636
3637 extern int register_binfmt(struct linux_binfmt *);
3638 diff --git a/include/linux/lockdep.h b/include/linux/lockdep.h
3639 index ea097dd..782abaf 100644
3640 --- a/include/linux/lockdep.h
3641 +++ b/include/linux/lockdep.h
3642 @@ -8,6 +8,8 @@
3643 #ifndef __LINUX_LOCKDEP_H
3644 #define __LINUX_LOCKDEP_H
3645
3646 +struct task_struct;
3647 +
3648 #ifdef CONFIG_LOCKDEP
3649
3650 #include <linux/linkage.h>
3651 diff --git a/include/linux/pci_ids.h b/include/linux/pci_ids.h
3652 index 3d1d210..d37f46a 100644
3653 --- a/include/linux/pci_ids.h
3654 +++ b/include/linux/pci_ids.h
3655 @@ -1971,6 +1971,7 @@
3656 #define PCI_DEVICE_ID_TOPIC_TP560 0x0000
3657
3658 #define PCI_VENDOR_ID_ENE 0x1524
3659 +#define PCI_DEVICE_ID_ENE_CB712_SD 0x0550
3660 #define PCI_DEVICE_ID_ENE_1211 0x1211
3661 #define PCI_DEVICE_ID_ENE_1225 0x1225
3662 #define PCI_DEVICE_ID_ENE_1410 0x1410
3663 diff --git a/include/linux/raid/bitmap.h b/include/linux/raid/bitmap.h
3664 index ebd42a3..6db9a4c 100644
3665 --- a/include/linux/raid/bitmap.h
3666 +++ b/include/linux/raid/bitmap.h
3667 @@ -247,6 +247,7 @@ struct bitmap {
3668
3669 atomic_t pending_writes; /* pending writes to the bitmap file */
3670 wait_queue_head_t write_wait;
3671 + wait_queue_head_t overflow_wait;
3672
3673 };
3674
3675 diff --git a/include/linux/sunrpc/svcsock.h b/include/linux/sunrpc/svcsock.h
3676 index 98b21ad..523fb3a 100644
3677 --- a/include/linux/sunrpc/svcsock.h
3678 +++ b/include/linux/sunrpc/svcsock.h
3679 @@ -63,7 +63,7 @@ struct svc_sock {
3680 * Function prototypes.
3681 */
3682 int svc_makesock(struct svc_serv *, int, unsigned short);
3683 -void svc_delete_socket(struct svc_sock *);
3684 +void svc_force_close_socket(struct svc_sock *);
3685 int svc_recv(struct svc_rqst *, long);
3686 int svc_send(struct svc_rqst *);
3687 void svc_drop(struct svc_rqst *);
3688 diff --git a/include/linux/ufs_fs.h b/include/linux/ufs_fs.h
3689 index 28967ed..d3a4f99 100644
3690 --- a/include/linux/ufs_fs.h
3691 +++ b/include/linux/ufs_fs.h
3692 @@ -789,6 +789,7 @@ struct ufs_sb_private_info {
3693
3694 __u32 s_maxsymlinklen;/* upper limit on fast symlinks' size */
3695 __s32 fs_magic; /* filesystem magic */
3696 + unsigned int s_dirblksize;
3697 };
3698
3699 /*
3700 diff --git a/include/linux/writeback.h b/include/linux/writeback.h
3701 index fc35e6b..0c78f7f 100644
3702 --- a/include/linux/writeback.h
3703 +++ b/include/linux/writeback.h
3704 @@ -84,7 +84,7 @@ static inline void wait_on_inode(struct inode *inode)
3705 int wakeup_pdflush(long nr_pages);
3706 void laptop_io_completion(void);
3707 void laptop_sync_completion(void);
3708 -void throttle_vm_writeout(void);
3709 +void throttle_vm_writeout(gfp_t gfp_mask);
3710
3711 /* These are exported to sysctl. */
3712 extern int dirty_background_ratio;
3713 diff --git a/kernel/lockdep.c b/kernel/lockdep.c
3714 index 509efd4..33c9eeb 100644
3715 --- a/kernel/lockdep.c
3716 +++ b/kernel/lockdep.c
3717 @@ -2577,7 +2577,7 @@ out_restore:
3718 raw_local_irq_restore(flags);
3719 }
3720
3721 -void __init lockdep_init(void)
3722 +void lockdep_init(void)
3723 {
3724 int i;
3725
3726 diff --git a/kernel/power/user.c b/kernel/power/user.c
3727 index f7b7a78..38418cd 100644
3728 --- a/kernel/power/user.c
3729 +++ b/kernel/power/user.c
3730 @@ -292,7 +292,7 @@ static int snapshot_ioctl(struct inode *inode, struct file *filp,
3731 break;
3732 }
3733
3734 - if (pm_ops->prepare) {
3735 + if (pm_ops && pm_ops->prepare) {
3736 error = pm_ops->prepare(PM_SUSPEND_MEM);
3737 if (error)
3738 goto OutS3;
3739 @@ -311,7 +311,7 @@ static int snapshot_ioctl(struct inode *inode, struct file *filp,
3740 device_resume();
3741 }
3742 resume_console();
3743 - if (pm_ops->finish)
3744 + if (pm_ops && pm_ops->finish)
3745 pm_ops->finish(PM_SUSPEND_MEM);
3746
3747 OutS3:
3748 @@ -322,20 +322,25 @@ static int snapshot_ioctl(struct inode *inode, struct file *filp,
3749 switch (arg) {
3750
3751 case PMOPS_PREPARE:
3752 - if (pm_ops->prepare) {
3753 + if (pm_ops && pm_ops->prepare)
3754 error = pm_ops->prepare(PM_SUSPEND_DISK);
3755 - }
3756 + else
3757 + error = -ENOSYS;
3758 break;
3759
3760 case PMOPS_ENTER:
3761 kernel_shutdown_prepare(SYSTEM_SUSPEND_DISK);
3762 - error = pm_ops->enter(PM_SUSPEND_DISK);
3763 + if (pm_ops && pm_ops->enter)
3764 + error = pm_ops->enter(PM_SUSPEND_DISK);
3765 + else
3766 + error = -ENOSYS;
3767 break;
3768
3769 case PMOPS_FINISH:
3770 - if (pm_ops && pm_ops->finish) {
3771 + if (pm_ops && pm_ops->finish)
3772 pm_ops->finish(PM_SUSPEND_DISK);
3773 - }
3774 + else
3775 + error = -ENOSYS;
3776 break;
3777
3778 default:
3779 diff --git a/kernel/time/clocksource.c b/kernel/time/clocksource.c
3780 index 22504af..d9ef176 100644
3781 --- a/kernel/time/clocksource.c
3782 +++ b/kernel/time/clocksource.c
3783 @@ -28,6 +28,7 @@
3784 #include <linux/sysdev.h>
3785 #include <linux/init.h>
3786 #include <linux/module.h>
3787 +#include <linux/sched.h> /* for spin_unlock_irq() using preempt_count() m68k */
3788
3789 /* XXX - Would like a better way for initializing curr_clocksource */
3790 extern struct clocksource clocksource_jiffies;
3791 diff --git a/lib/Kconfig.debug b/lib/Kconfig.debug
3792 index 5c26818..330bff8 100644
3793 --- a/lib/Kconfig.debug
3794 +++ b/lib/Kconfig.debug
3795 @@ -399,8 +399,8 @@ config LKDTM
3796
3797 config FAULT_INJECTION
3798 bool "Fault-injection framework"
3799 - depends on DEBUG_KERNEL
3800 - depends on STACKTRACE
3801 + depends on DEBUG_KERNEL && STACKTRACE_SUPPORT
3802 + select STACKTRACE
3803 select FRAME_POINTER
3804 help
3805 Provide fault-injection framework.
3806 diff --git a/lib/swiotlb.c b/lib/swiotlb.c
3807 index 1062578..d6d57fb 100644
3808 --- a/lib/swiotlb.c
3809 +++ b/lib/swiotlb.c
3810 @@ -750,7 +750,7 @@ swiotlb_sync_sg(struct device *hwdev, struct scatterlist *sg,
3811
3812 for (i = 0; i < nelems; i++, sg++)
3813 if (sg->dma_address != SG_ENT_PHYS_ADDRESS(sg))
3814 - sync_single(hwdev, (void *) sg->dma_address,
3815 + sync_single(hwdev, phys_to_virt(sg->dma_address),
3816 sg->dma_length, dir, target);
3817 }
3818
3819 diff --git a/mm/hugetlb.c b/mm/hugetlb.c
3820 index cb362f7..36db012 100644
3821 --- a/mm/hugetlb.c
3822 +++ b/mm/hugetlb.c
3823 @@ -389,6 +389,8 @@ void __unmap_hugepage_range(struct vm_area_struct *vma, unsigned long start,
3824 continue;
3825
3826 page = pte_page(pte);
3827 + if (pte_dirty(pte))
3828 + set_page_dirty(page);
3829 list_add(&page->lru, &page_list);
3830 }
3831 spin_unlock(&mm->page_table_lock);
3832 diff --git a/mm/page-writeback.c b/mm/page-writeback.c
3833 index be0efbd..17255ab 100644
3834 --- a/mm/page-writeback.c
3835 +++ b/mm/page-writeback.c
3836 @@ -296,11 +296,21 @@ void balance_dirty_pages_ratelimited_nr(struct address_space *mapping,
3837 }
3838 EXPORT_SYMBOL(balance_dirty_pages_ratelimited_nr);
3839
3840 -void throttle_vm_writeout(void)
3841 +void throttle_vm_writeout(gfp_t gfp_mask)
3842 {
3843 long background_thresh;
3844 long dirty_thresh;
3845
3846 + if ((gfp_mask & (__GFP_FS|__GFP_IO)) != (__GFP_FS|__GFP_IO)) {
3847 + /*
3848 + * The caller might hold locks which can prevent IO completion
3849 + * or progress in the filesystem. So we cannot just sit here
3850 + * waiting for IO to complete.
3851 + */
3852 + congestion_wait(WRITE, HZ/10);
3853 + return;
3854 + }
3855 +
3856 for ( ; ; ) {
3857 get_dirty_limits(&background_thresh, &dirty_thresh, NULL);
3858
3859 @@ -317,7 +327,6 @@ void throttle_vm_writeout(void)
3860 }
3861 }
3862
3863 -
3864 /*
3865 * writeback at least _min_pages, and keep writing until the amount of dirty
3866 * memory is less than the background threshold, or until we're all clean.
3867 diff --git a/mm/vmscan.c b/mm/vmscan.c
3868 index 7430df6..5b4528a 100644
3869 --- a/mm/vmscan.c
3870 +++ b/mm/vmscan.c
3871 @@ -949,7 +949,7 @@ static unsigned long shrink_zone(int priority, struct zone *zone,
3872 }
3873 }
3874
3875 - throttle_vm_writeout();
3876 + throttle_vm_writeout(sc->gfp_mask);
3877
3878 atomic_dec(&zone->reclaim_in_progress);
3879 return nr_reclaimed;
3880 diff --git a/net/atm/common.c b/net/atm/common.c
3881 index fbabff4..a2878e9 100644
3882 --- a/net/atm/common.c
3883 +++ b/net/atm/common.c
3884 @@ -816,7 +816,8 @@ static void __exit atm_exit(void)
3885 proto_unregister(&vcc_proto);
3886 }
3887
3888 -module_init(atm_init);
3889 +subsys_initcall(atm_init);
3890 +
3891 module_exit(atm_exit);
3892
3893 MODULE_LICENSE("GPL");
3894 diff --git a/net/ipv4/igmp.c b/net/ipv4/igmp.c
3895 index 0017ccb..024ae56 100644
3896 --- a/net/ipv4/igmp.c
3897 +++ b/net/ipv4/igmp.c
3898 @@ -455,6 +455,8 @@ static struct sk_buff *add_grec(struct sk_buff *skb, struct ip_mc_list *pmc,
3899 skb = add_grhead(skb, pmc, type, &pgr);
3900 first = 0;
3901 }
3902 + if (!skb)
3903 + return NULL;
3904 psrc = (__be32 *)skb_put(skb, sizeof(__be32));
3905 *psrc = psf->sf_inaddr;
3906 scount++; stotal++;
3907 diff --git a/net/ipv4/netfilter/ipt_REJECT.c b/net/ipv4/netfilter/ipt_REJECT.c
3908 index f0319e5..6714bd1 100644
3909 --- a/net/ipv4/netfilter/ipt_REJECT.c
3910 +++ b/net/ipv4/netfilter/ipt_REJECT.c
3911 @@ -79,6 +79,10 @@ static void send_reset(struct sk_buff *oldskb, int hook)
3912 nskb->mark = 0;
3913 skb_init_secmark(nskb);
3914
3915 + skb_shinfo(nskb)->gso_size = 0;
3916 + skb_shinfo(nskb)->gso_segs = 0;
3917 + skb_shinfo(nskb)->gso_type = 0;
3918 +
3919 tcph = (struct tcphdr *)((u_int32_t*)nskb->nh.iph + nskb->nh.iph->ihl);
3920
3921 /* Swap source and dest */
3922 diff --git a/net/ipv4/tcp.c b/net/ipv4/tcp.c
3923 index b67e0dd..ebe9d0d 100644
3924 --- a/net/ipv4/tcp.c
3925 +++ b/net/ipv4/tcp.c
3926 @@ -2266,12 +2266,12 @@ void tcp_free_md5sig_pool(void)
3927 {
3928 struct tcp_md5sig_pool **pool = NULL;
3929
3930 - spin_lock(&tcp_md5sig_pool_lock);
3931 + spin_lock_bh(&tcp_md5sig_pool_lock);
3932 if (--tcp_md5sig_users == 0) {
3933 pool = tcp_md5sig_pool;
3934 tcp_md5sig_pool = NULL;
3935 }
3936 - spin_unlock(&tcp_md5sig_pool_lock);
3937 + spin_unlock_bh(&tcp_md5sig_pool_lock);
3938 if (pool)
3939 __tcp_free_md5sig_pool(pool);
3940 }
3941 @@ -2314,36 +2314,36 @@ struct tcp_md5sig_pool **tcp_alloc_md5sig_pool(void)
3942 int alloc = 0;
3943
3944 retry:
3945 - spin_lock(&tcp_md5sig_pool_lock);
3946 + spin_lock_bh(&tcp_md5sig_pool_lock);
3947 pool = tcp_md5sig_pool;
3948 if (tcp_md5sig_users++ == 0) {
3949 alloc = 1;
3950 - spin_unlock(&tcp_md5sig_pool_lock);
3951 + spin_unlock_bh(&tcp_md5sig_pool_lock);
3952 } else if (!pool) {
3953 tcp_md5sig_users--;
3954 - spin_unlock(&tcp_md5sig_pool_lock);
3955 + spin_unlock_bh(&tcp_md5sig_pool_lock);
3956 cpu_relax();
3957 goto retry;
3958 } else
3959 - spin_unlock(&tcp_md5sig_pool_lock);
3960 + spin_unlock_bh(&tcp_md5sig_pool_lock);
3961
3962 if (alloc) {
3963 /* we cannot hold spinlock here because this may sleep. */
3964 struct tcp_md5sig_pool **p = __tcp_alloc_md5sig_pool();
3965 - spin_lock(&tcp_md5sig_pool_lock);
3966 + spin_lock_bh(&tcp_md5sig_pool_lock);
3967 if (!p) {
3968 tcp_md5sig_users--;
3969 - spin_unlock(&tcp_md5sig_pool_lock);
3970 + spin_unlock_bh(&tcp_md5sig_pool_lock);
3971 return NULL;
3972 }
3973 pool = tcp_md5sig_pool;
3974 if (pool) {
3975 /* oops, it has already been assigned. */
3976 - spin_unlock(&tcp_md5sig_pool_lock);
3977 + spin_unlock_bh(&tcp_md5sig_pool_lock);
3978 __tcp_free_md5sig_pool(p);
3979 } else {
3980 tcp_md5sig_pool = pool = p;
3981 - spin_unlock(&tcp_md5sig_pool_lock);
3982 + spin_unlock_bh(&tcp_md5sig_pool_lock);
3983 }
3984 }
3985 return pool;
3986 @@ -2354,11 +2354,11 @@ EXPORT_SYMBOL(tcp_alloc_md5sig_pool);
3987 struct tcp_md5sig_pool *__tcp_get_md5sig_pool(int cpu)
3988 {
3989 struct tcp_md5sig_pool **p;
3990 - spin_lock(&tcp_md5sig_pool_lock);
3991 + spin_lock_bh(&tcp_md5sig_pool_lock);
3992 p = tcp_md5sig_pool;
3993 if (p)
3994 tcp_md5sig_users++;
3995 - spin_unlock(&tcp_md5sig_pool_lock);
3996 + spin_unlock_bh(&tcp_md5sig_pool_lock);
3997 return (p ? *per_cpu_ptr(p, cpu) : NULL);
3998 }
3999
4000 diff --git a/net/ipv4/tcp_minisocks.c b/net/ipv4/tcp_minisocks.c
4001 index 4a3889d..aa54ad4 100644
4002 --- a/net/ipv4/tcp_minisocks.c
4003 +++ b/net/ipv4/tcp_minisocks.c
4004 @@ -381,7 +381,7 @@ struct sock *tcp_create_openreq_child(struct sock *sk, struct request_sock *req,
4005 if (newsk != NULL) {
4006 const struct inet_request_sock *ireq = inet_rsk(req);
4007 struct tcp_request_sock *treq = tcp_rsk(req);
4008 - struct inet_connection_sock *newicsk = inet_csk(sk);
4009 + struct inet_connection_sock *newicsk = inet_csk(newsk);
4010 struct tcp_sock *newtp;
4011
4012 /* Now setup tcp_sock */
4013 diff --git a/net/ipv4/tcp_output.c b/net/ipv4/tcp_output.c
4014 index 975f447..1951eaa 100644
4015 --- a/net/ipv4/tcp_output.c
4016 +++ b/net/ipv4/tcp_output.c
4017 @@ -481,7 +481,7 @@ static int tcp_transmit_skb(struct sock *sk, struct sk_buff *skb, int clone_it,
4018 /* RFC1323: The window in SYN & SYN/ACK segments
4019 * is never scaled.
4020 */
4021 - th->window = htons(tp->rcv_wnd);
4022 + th->window = htons(min(tp->rcv_wnd, 65535U));
4023 } else {
4024 th->window = htons(tcp_select_window(sk));
4025 }
4026 @@ -965,7 +965,8 @@ static inline unsigned int tcp_cwnd_test(struct tcp_sock *tp, struct sk_buff *sk
4027 u32 in_flight, cwnd;
4028
4029 /* Don't be strict about the congestion window for the final FIN. */
4030 - if (TCP_SKB_CB(skb)->flags & TCPCB_FLAG_FIN)
4031 + if ((TCP_SKB_CB(skb)->flags & TCPCB_FLAG_FIN) &&
4032 + tcp_skb_pcount(skb) == 1)
4033 return 1;
4034
4035 in_flight = tcp_packets_in_flight(tp);
4036 @@ -2159,7 +2160,7 @@ struct sk_buff * tcp_make_synack(struct sock *sk, struct dst_entry *dst,
4037 }
4038
4039 /* RFC1323: The window in SYN & SYN/ACK segments is never scaled. */
4040 - th->window = htons(req->rcv_wnd);
4041 + th->window = htons(min(req->rcv_wnd, 65535U));
4042
4043 TCP_SKB_CB(skb)->when = tcp_time_stamp;
4044 tcp_syn_build_options((__be32 *)(th + 1), dst_metric(dst, RTAX_ADVMSS), ireq->tstamp_ok,
4045 diff --git a/net/ipv4/xfrm4_mode_tunnel.c b/net/ipv4/xfrm4_mode_tunnel.c
4046 index e23c21d..21ed667 100644
4047 --- a/net/ipv4/xfrm4_mode_tunnel.c
4048 +++ b/net/ipv4/xfrm4_mode_tunnel.c
4049 @@ -84,6 +84,7 @@ static int xfrm4_tunnel_input(struct xfrm_state *x, struct sk_buff *skb)
4050 (err = pskb_expand_head(skb, 0, 0, GFP_ATOMIC)))
4051 goto out;
4052
4053 + iph = skb->nh.iph;
4054 if (x->props.flags & XFRM_STATE_DECAP_DSCP)
4055 ipv4_copy_dscp(iph, skb->h.ipiph);
4056 if (!(x->props.flags & XFRM_STATE_NOECN))
4057 diff --git a/net/ipv6/addrconf.c b/net/ipv6/addrconf.c
4058 index e385469..58cb669 100644
4059 --- a/net/ipv6/addrconf.c
4060 +++ b/net/ipv6/addrconf.c
4061 @@ -469,6 +469,8 @@ static void dev_forward_change(struct inet6_dev *idev)
4062 ipv6_dev_mc_dec(dev, &addr);
4063 }
4064 for (ifa=idev->addr_list; ifa; ifa=ifa->if_next) {
4065 + if (ifa->flags&IFA_F_TENTATIVE)
4066 + continue;
4067 if (idev->cnf.forwarding)
4068 addrconf_join_anycast(ifa);
4069 else
4070 diff --git a/net/ipv6/anycast.c b/net/ipv6/anycast.c
4071 index a960476..fe0c895 100644
4072 --- a/net/ipv6/anycast.c
4073 +++ b/net/ipv6/anycast.c
4074 @@ -462,6 +462,7 @@ static inline struct ifacaddr6 *ac6_get_first(struct seq_file *seq)
4075 break;
4076 }
4077 read_unlock_bh(&idev->lock);
4078 + in6_dev_put(idev);
4079 }
4080 return im;
4081 }
4082 diff --git a/net/ipv6/inet6_hashtables.c b/net/ipv6/inet6_hashtables.c
4083 index b7e5bae..ba13f74 100644
4084 --- a/net/ipv6/inet6_hashtables.c
4085 +++ b/net/ipv6/inet6_hashtables.c
4086 @@ -172,7 +172,7 @@ static int __inet6_check_established(struct inet_timewait_death_row *death_row,
4087 const struct in6_addr *saddr = &np->daddr;
4088 const int dif = sk->sk_bound_dev_if;
4089 const __portpair ports = INET_COMBINED_PORTS(inet->dport, lport);
4090 - const unsigned int hash = inet6_ehashfn(daddr, inet->num, saddr,
4091 + const unsigned int hash = inet6_ehashfn(daddr, lport, saddr,
4092 inet->dport);
4093 struct inet_ehash_bucket *head = inet_ehash_bucket(hinfo, hash);
4094 struct sock *sk2;
4095 diff --git a/net/ipv6/ipv6_sockglue.c b/net/ipv6/ipv6_sockglue.c
4096 index 352690e..23db88e 100644
4097 --- a/net/ipv6/ipv6_sockglue.c
4098 +++ b/net/ipv6/ipv6_sockglue.c
4099 @@ -796,11 +796,15 @@ int compat_ipv6_setsockopt(struct sock *sk, int level, int optname,
4100 EXPORT_SYMBOL(compat_ipv6_setsockopt);
4101 #endif
4102
4103 -static int ipv6_getsockopt_sticky(struct sock *sk, struct ipv6_opt_hdr *hdr,
4104 +static int ipv6_getsockopt_sticky(struct sock *sk, struct ipv6_txoptions *opt,
4105 char __user *optval, int len)
4106 {
4107 - if (!hdr)
4108 + struct ipv6_opt_hdr *hdr;
4109 +
4110 + if (!opt || !opt->hopopt)
4111 return 0;
4112 + hdr = opt->hopopt;
4113 +
4114 len = min_t(int, len, ipv6_optlen(hdr));
4115 if (copy_to_user(optval, hdr, ipv6_optlen(hdr)))
4116 return -EFAULT;
4117 @@ -941,7 +945,7 @@ static int do_ipv6_getsockopt(struct sock *sk, int level, int optname,
4118 {
4119
4120 lock_sock(sk);
4121 - len = ipv6_getsockopt_sticky(sk, np->opt->hopopt,
4122 + len = ipv6_getsockopt_sticky(sk, np->opt,
4123 optval, len);
4124 release_sock(sk);
4125 return put_user(len, optlen);
4126 diff --git a/net/ipv6/mcast.c b/net/ipv6/mcast.c
4127 index 882cde4..e3ec216 100644
4128 --- a/net/ipv6/mcast.c
4129 +++ b/net/ipv6/mcast.c
4130 @@ -1582,6 +1582,8 @@ static struct sk_buff *add_grec(struct sk_buff *skb, struct ifmcaddr6 *pmc,
4131 skb = add_grhead(skb, pmc, type, &pgr);
4132 first = 0;
4133 }
4134 + if (!skb)
4135 + return NULL;
4136 psrc = (struct in6_addr *)skb_put(skb, sizeof(*psrc));
4137 *psrc = psf->sf_addr;
4138 scount++; stotal++;
4139 diff --git a/net/ipx/af_ipx.c b/net/ipx/af_ipx.c
4140 index 76c6615..89f283c 100644
4141 --- a/net/ipx/af_ipx.c
4142 +++ b/net/ipx/af_ipx.c
4143 @@ -2035,19 +2035,27 @@ static void __exit ipx_proto_finito(void)
4144
4145 ipxitf_cleanup();
4146
4147 - unregister_snap_client(pSNAP_datalink);
4148 - pSNAP_datalink = NULL;
4149 + if (pSNAP_datalink) {
4150 + unregister_snap_client(pSNAP_datalink);
4151 + pSNAP_datalink = NULL;
4152 + }
4153
4154 - unregister_8022_client(p8022_datalink);
4155 - p8022_datalink = NULL;
4156 + if (p8022_datalink) {
4157 + unregister_8022_client(p8022_datalink);
4158 + p8022_datalink = NULL;
4159 + }
4160
4161 dev_remove_pack(&ipx_8023_packet_type);
4162 - destroy_8023_client(p8023_datalink);
4163 - p8023_datalink = NULL;
4164 + if (p8023_datalink) {
4165 + destroy_8023_client(p8023_datalink);
4166 + p8023_datalink = NULL;
4167 + }
4168
4169 dev_remove_pack(&ipx_dix_packet_type);
4170 - destroy_EII_client(pEII_datalink);
4171 - pEII_datalink = NULL;
4172 + if (pEII_datalink) {
4173 + destroy_EII_client(pEII_datalink);
4174 + pEII_datalink = NULL;
4175 + }
4176
4177 proto_unregister(&ipx_proto);
4178 sock_unregister(ipx_family_ops.family);
4179 diff --git a/net/key/af_key.c b/net/key/af_key.c
4180 index 5dd5094..3b4a1f4 100644
4181 --- a/net/key/af_key.c
4182 +++ b/net/key/af_key.c
4183 @@ -2297,16 +2297,17 @@ static int pfkey_spddelete(struct sock *sk, struct sk_buff *skb, struct sadb_msg
4184 &sel, tmp.security, 1);
4185 security_xfrm_policy_free(&tmp);
4186
4187 - xfrm_audit_log(audit_get_loginuid(current->audit_context), 0,
4188 - AUDIT_MAC_IPSEC_DELSPD, (xp) ? 1 : 0, xp, NULL);
4189 -
4190 if (xp == NULL)
4191 return -ENOENT;
4192
4193 - err = 0;
4194 + err = security_xfrm_policy_delete(xp);
4195
4196 - if ((err = security_xfrm_policy_delete(xp)))
4197 + xfrm_audit_log(audit_get_loginuid(current->audit_context), 0,
4198 + AUDIT_MAC_IPSEC_DELSPD, err ? 0 : 1, xp, NULL);
4199 +
4200 + if (err)
4201 goto out;
4202 +
4203 c.seq = hdr->sadb_msg_seq;
4204 c.pid = hdr->sadb_msg_pid;
4205 c.event = XFRM_MSG_DELPOLICY;
4206 diff --git a/net/netfilter/nfnetlink_log.c b/net/netfilter/nfnetlink_log.c
4207 index d1505dd..24c1d29 100644
4208 --- a/net/netfilter/nfnetlink_log.c
4209 +++ b/net/netfilter/nfnetlink_log.c
4210 @@ -217,6 +217,11 @@ _instance_destroy2(struct nfulnl_instance *inst, int lock)
4211
4212 spin_lock_bh(&inst->lock);
4213 if (inst->skb) {
4214 + /* timer "holds" one reference (we have one more) */
4215 + if (timer_pending(&inst->timer)) {
4216 + del_timer(&inst->timer);
4217 + instance_put(inst);
4218 + }
4219 if (inst->qlen)
4220 __nfulnl_send(inst);
4221 if (inst->skb) {
4222 @@ -363,9 +368,6 @@ __nfulnl_send(struct nfulnl_instance *inst)
4223 {
4224 int status;
4225
4226 - if (timer_pending(&inst->timer))
4227 - del_timer(&inst->timer);
4228 -
4229 if (!inst->skb)
4230 return 0;
4231
4232 @@ -392,6 +394,8 @@ static void nfulnl_timer(unsigned long data)
4233 UDEBUG("timer function called, flushing buffer\n");
4234
4235 spin_lock_bh(&inst->lock);
4236 + if (timer_pending(&inst->timer)) /* is it always true or false here? */
4237 + del_timer(&inst->timer);
4238 __nfulnl_send(inst);
4239 instance_put(inst);
4240 spin_unlock_bh(&inst->lock);
4241 @@ -689,6 +693,11 @@ nfulnl_log_packet(unsigned int pf,
4242 * enough room in the skb left. flush to userspace. */
4243 UDEBUG("flushing old skb\n");
4244
4245 + /* timer "holds" one reference (we have another one) */
4246 + if (timer_pending(&inst->timer)) {
4247 + del_timer(&inst->timer);
4248 + instance_put(inst);
4249 + }
4250 __nfulnl_send(inst);
4251
4252 if (!(inst->skb = nfulnl_alloc_skb(nlbufsiz, size))) {
4253 diff --git a/net/sunrpc/pmap_clnt.c b/net/sunrpc/pmap_clnt.c
4254 index 3946ec3..76e59e9 100644
4255 --- a/net/sunrpc/pmap_clnt.c
4256 +++ b/net/sunrpc/pmap_clnt.c
4257 @@ -62,7 +62,10 @@ static inline void pmap_map_free(struct portmap_args *map)
4258
4259 static void pmap_map_release(void *data)
4260 {
4261 - pmap_map_free(data);
4262 + struct portmap_args *map = data;
4263 +
4264 + xprt_put(map->pm_xprt);
4265 + pmap_map_free(map);
4266 }
4267
4268 static const struct rpc_call_ops pmap_getport_ops = {
4269 @@ -133,7 +136,7 @@ void rpc_getport(struct rpc_task *task)
4270 status = -EIO;
4271 child = rpc_run_task(pmap_clnt, RPC_TASK_ASYNC, &pmap_getport_ops, map);
4272 if (IS_ERR(child))
4273 - goto bailout;
4274 + goto bailout_nofree;
4275 rpc_put_task(child);
4276
4277 task->tk_xprt->stat.bind_count++;
4278 @@ -222,7 +225,6 @@ static void pmap_getport_done(struct rpc_task *child, void *data)
4279 child->tk_pid, status, map->pm_port);
4280
4281 pmap_wake_portmap_waiters(xprt, status);
4282 - xprt_put(xprt);
4283 }
4284
4285 /**
4286 diff --git a/net/sunrpc/svc.c b/net/sunrpc/svc.c
4287 index 4c16112..baf27a9 100644
4288 --- a/net/sunrpc/svc.c
4289 +++ b/net/sunrpc/svc.c
4290 @@ -79,7 +79,11 @@ svc_pool_map_choose_mode(void)
4291 * x86_64 kernel on Xeons. In this case we
4292 * want to divide the pools on cpu boundaries.
4293 */
4294 - return SVC_POOL_PERCPU;
4295 + /* actually, unless your IRQs round-robin nicely,
4296 + * this turns out to be really bad, so just
4297 + * go GLOBAL for now until a better fix can be developped
4298 + */
4299 + return SVC_POOL_GLOBAL;
4300 }
4301
4302 /* default: one global pool */
4303 @@ -367,6 +371,7 @@ void
4304 svc_destroy(struct svc_serv *serv)
4305 {
4306 struct svc_sock *svsk;
4307 + struct svc_sock *tmp;
4308
4309 dprintk("RPC: svc_destroy(%s, %d)\n",
4310 serv->sv_program->pg_name,
4311 @@ -382,22 +387,18 @@ svc_destroy(struct svc_serv *serv)
4312
4313 del_timer_sync(&serv->sv_temptimer);
4314
4315 - while (!list_empty(&serv->sv_tempsocks)) {
4316 - svsk = list_entry(serv->sv_tempsocks.next,
4317 - struct svc_sock,
4318 - sk_list);
4319 - svc_delete_socket(svsk);
4320 - }
4321 + list_for_each_entry_safe(svsk, tmp, &serv->sv_tempsocks, sk_list)
4322 + svc_force_close_socket(svsk);
4323 +
4324 if (serv->sv_shutdown)
4325 serv->sv_shutdown(serv);
4326
4327 - while (!list_empty(&serv->sv_permsocks)) {
4328 - svsk = list_entry(serv->sv_permsocks.next,
4329 - struct svc_sock,
4330 - sk_list);
4331 - svc_delete_socket(svsk);
4332 - }
4333 -
4334 + list_for_each_entry_safe(svsk, tmp, &serv->sv_permsocks, sk_list)
4335 + svc_force_close_socket(svsk);
4336 +
4337 + BUG_ON(!list_empty(&serv->sv_permsocks));
4338 + BUG_ON(!list_empty(&serv->sv_tempsocks));
4339 +
4340 cache_clean_deferred(serv);
4341
4342 /* Unregister service with the portmapper */
4343 diff --git a/net/sunrpc/svcsock.c b/net/sunrpc/svcsock.c
4344 index ff1f8bf..cd296a5 100644
4345 --- a/net/sunrpc/svcsock.c
4346 +++ b/net/sunrpc/svcsock.c
4347 @@ -62,6 +62,12 @@
4348 * after a clear, the socket must be read/accepted
4349 * if this succeeds, it must be set again.
4350 * SK_CLOSE can set at any time. It is never cleared.
4351 + * sk_inuse contains a bias of '1' until SK_DEAD is set.
4352 + * so when sk_inuse hits zero, we know the socket is dead
4353 + * and no-one is using it.
4354 + * SK_DEAD can only be set while SK_BUSY is held which ensures
4355 + * no other thread will be using the socket or will try to
4356 + * set SK_DEAD.
4357 *
4358 */
4359
4360 @@ -70,9 +76,11 @@
4361
4362 static struct svc_sock *svc_setup_socket(struct svc_serv *, struct socket *,
4363 int *errp, int pmap_reg);
4364 +static void svc_delete_socket(struct svc_sock *svsk);
4365 static void svc_udp_data_ready(struct sock *, int);
4366 static int svc_udp_recvfrom(struct svc_rqst *);
4367 static int svc_udp_sendto(struct svc_rqst *);
4368 +static void svc_close_socket(struct svc_sock *svsk);
4369
4370 static struct svc_deferred_req *svc_deferred_dequeue(struct svc_sock *svsk);
4371 static int svc_deferred_recv(struct svc_rqst *rqstp);
4372 @@ -329,8 +337,9 @@ void svc_reserve(struct svc_rqst *rqstp, int space)
4373 static inline void
4374 svc_sock_put(struct svc_sock *svsk)
4375 {
4376 - if (atomic_dec_and_test(&svsk->sk_inuse) &&
4377 - test_bit(SK_DEAD, &svsk->sk_flags)) {
4378 + if (atomic_dec_and_test(&svsk->sk_inuse)) {
4379 + BUG_ON(! test_bit(SK_DEAD, &svsk->sk_flags));
4380 +
4381 dprintk("svc: releasing dead socket\n");
4382 if (svsk->sk_sock->file)
4383 sockfd_put(svsk->sk_sock);
4384 @@ -520,7 +529,7 @@ svc_sock_names(char *buf, struct svc_serv *serv, char *toclose)
4385
4386 if (!serv)
4387 return 0;
4388 - spin_lock(&serv->sv_lock);
4389 + spin_lock_bh(&serv->sv_lock);
4390 list_for_each_entry(svsk, &serv->sv_permsocks, sk_list) {
4391 int onelen = one_sock_name(buf+len, svsk);
4392 if (toclose && strcmp(toclose, buf+len) == 0)
4393 @@ -528,12 +537,12 @@ svc_sock_names(char *buf, struct svc_serv *serv, char *toclose)
4394 else
4395 len += onelen;
4396 }
4397 - spin_unlock(&serv->sv_lock);
4398 + spin_unlock_bh(&serv->sv_lock);
4399 if (closesk)
4400 /* Should unregister with portmap, but you cannot
4401 * unregister just one protocol...
4402 */
4403 - svc_delete_socket(closesk);
4404 + svc_close_socket(closesk);
4405 else if (toclose)
4406 return -ENOENT;
4407 return len;
4408 @@ -683,6 +692,11 @@ svc_udp_recvfrom(struct svc_rqst *rqstp)
4409 return svc_deferred_recv(rqstp);
4410 }
4411
4412 + if (test_bit(SK_CLOSE, &svsk->sk_flags)) {
4413 + svc_delete_socket(svsk);
4414 + return 0;
4415 + }
4416 +
4417 clear_bit(SK_DATA, &svsk->sk_flags);
4418 while ((skb = skb_recv_datagram(svsk->sk_sk, 0, 1, &err)) == NULL) {
4419 if (err == -EAGAIN) {
4420 @@ -1176,7 +1190,8 @@ svc_tcp_sendto(struct svc_rqst *rqstp)
4421 rqstp->rq_sock->sk_server->sv_name,
4422 (sent<0)?"got error":"sent only",
4423 sent, xbufp->len);
4424 - svc_delete_socket(rqstp->rq_sock);
4425 + set_bit(SK_CLOSE, &rqstp->rq_sock->sk_flags);
4426 + svc_sock_enqueue(rqstp->rq_sock);
4427 sent = -EAGAIN;
4428 }
4429 return sent;
4430 @@ -1495,7 +1510,7 @@ svc_setup_socket(struct svc_serv *serv, struct socket *sock,
4431 svsk->sk_odata = inet->sk_data_ready;
4432 svsk->sk_owspace = inet->sk_write_space;
4433 svsk->sk_server = serv;
4434 - atomic_set(&svsk->sk_inuse, 0);
4435 + atomic_set(&svsk->sk_inuse, 1);
4436 svsk->sk_lastrecv = get_seconds();
4437 spin_lock_init(&svsk->sk_defer_lock);
4438 INIT_LIST_HEAD(&svsk->sk_deferred);
4439 @@ -1618,7 +1633,7 @@ bummer:
4440 /*
4441 * Remove a dead socket
4442 */
4443 -void
4444 +static void
4445 svc_delete_socket(struct svc_sock *svsk)
4446 {
4447 struct svc_serv *serv;
4448 @@ -1644,19 +1659,42 @@ svc_delete_socket(struct svc_sock *svsk)
4449 * while still attached to a queue, the queue itself
4450 * is about to be destroyed (in svc_destroy).
4451 */
4452 - if (!test_and_set_bit(SK_DEAD, &svsk->sk_flags))
4453 + if (!test_and_set_bit(SK_DEAD, &svsk->sk_flags)) {
4454 + BUG_ON(atomic_read(&svsk->sk_inuse)<2);
4455 + atomic_dec(&svsk->sk_inuse);
4456 if (test_bit(SK_TEMP, &svsk->sk_flags))
4457 serv->sv_tmpcnt--;
4458 + }
4459
4460 - /* This atomic_inc should be needed - svc_delete_socket
4461 - * should have the semantic of dropping a reference.
4462 - * But it doesn't yet....
4463 - */
4464 - atomic_inc(&svsk->sk_inuse);
4465 spin_unlock_bh(&serv->sv_lock);
4466 +}
4467 +
4468 +static void svc_close_socket(struct svc_sock *svsk)
4469 +{
4470 + set_bit(SK_CLOSE, &svsk->sk_flags);
4471 + if (test_and_set_bit(SK_BUSY, &svsk->sk_flags))
4472 + /* someone else will have to effect the close */
4473 + return;
4474 +
4475 + atomic_inc(&svsk->sk_inuse);
4476 + svc_delete_socket(svsk);
4477 + clear_bit(SK_BUSY, &svsk->sk_flags);
4478 svc_sock_put(svsk);
4479 }
4480
4481 +void svc_force_close_socket(struct svc_sock *svsk)
4482 +{
4483 + set_bit(SK_CLOSE, &svsk->sk_flags);
4484 + if (test_bit(SK_BUSY, &svsk->sk_flags)) {
4485 + /* Waiting to be processed, but no threads left,
4486 + * So just remove it from the waiting list
4487 + */
4488 + list_del_init(&svsk->sk_ready);
4489 + clear_bit(SK_BUSY, &svsk->sk_flags);
4490 + }
4491 + svc_close_socket(svsk);
4492 +}
4493 +
4494 /*
4495 * Make a socket for nfsd and lockd
4496 */
4497 diff --git a/net/xfrm/xfrm_policy.c b/net/xfrm/xfrm_policy.c
4498 index b7e537f..9704e05 100644
4499 --- a/net/xfrm/xfrm_policy.c
4500 +++ b/net/xfrm/xfrm_policy.c
4501 @@ -1997,9 +1997,14 @@ void xfrm_audit_log(uid_t auid, u32 sid, int type, int result,
4502 if (audit_enabled == 0)
4503 return;
4504
4505 + BUG_ON((type == AUDIT_MAC_IPSEC_ADDSA ||
4506 + type == AUDIT_MAC_IPSEC_DELSA) && !x);
4507 + BUG_ON((type == AUDIT_MAC_IPSEC_ADDSPD ||
4508 + type == AUDIT_MAC_IPSEC_DELSPD) && !xp);
4509 +
4510 audit_buf = audit_log_start(current->audit_context, GFP_ATOMIC, type);
4511 if (audit_buf == NULL)
4512 - return;
4513 + return;
4514
4515 switch(type) {
4516 case AUDIT_MAC_IPSEC_ADDSA:
4517 diff --git a/net/xfrm/xfrm_user.c b/net/xfrm/xfrm_user.c
4518 index 82f36d3..24d15f2 100644
4519 --- a/net/xfrm/xfrm_user.c
4520 +++ b/net/xfrm/xfrm_user.c
4521 @@ -1273,10 +1273,6 @@ static int xfrm_get_policy(struct sk_buff *skb, struct nlmsghdr *nlh,
4522 xp = xfrm_policy_bysel_ctx(type, p->dir, &p->sel, tmp.security, delete);
4523 security_xfrm_policy_free(&tmp);
4524 }
4525 - if (delete)
4526 - xfrm_audit_log(NETLINK_CB(skb).loginuid, NETLINK_CB(skb).sid,
4527 - AUDIT_MAC_IPSEC_DELSPD, (xp) ? 1 : 0, xp, NULL);
4528 -
4529 if (xp == NULL)
4530 return -ENOENT;
4531
4532 @@ -1292,8 +1288,14 @@ static int xfrm_get_policy(struct sk_buff *skb, struct nlmsghdr *nlh,
4533 MSG_DONTWAIT);
4534 }
4535 } else {
4536 - if ((err = security_xfrm_policy_delete(xp)) != 0)
4537 + err = security_xfrm_policy_delete(xp);
4538 +
4539 + xfrm_audit_log(NETLINK_CB(skb).loginuid, NETLINK_CB(skb).sid,
4540 + AUDIT_MAC_IPSEC_DELSPD, err ? 0 : 1, xp, NULL);
4541 +
4542 + if (err != 0)
4543 goto out;
4544 +
4545 c.data.byid = p->index;
4546 c.event = nlh->nlmsg_type;
4547 c.seq = nlh->nlmsg_seq;
4548 @@ -1555,14 +1557,13 @@ static int xfrm_add_sa_expire(struct sk_buff *skb, struct nlmsghdr *nlh,
4549 struct xfrm_usersa_info *p = &ue->state;
4550
4551 x = xfrm_state_lookup(&p->id.daddr, p->id.spi, p->id.proto, p->family);
4552 - err = -ENOENT;
4553
4554 + err = -ENOENT;
4555 if (x == NULL)
4556 return err;
4557
4558 - err = -EINVAL;
4559 -
4560 spin_lock_bh(&x->lock);
4561 + err = -EINVAL;
4562 if (x->km.state != XFRM_STATE_VALID)
4563 goto out;
4564 km_state_expired(x, ue->hard, current->pid);
4565 @@ -1572,6 +1573,7 @@ static int xfrm_add_sa_expire(struct sk_buff *skb, struct nlmsghdr *nlh,
4566 xfrm_audit_log(NETLINK_CB(skb).loginuid, NETLINK_CB(skb).sid,
4567 AUDIT_MAC_IPSEC_DELSA, 1, NULL, x);
4568 }
4569 + err = 0;
4570 out:
4571 spin_unlock_bh(&x->lock);
4572 xfrm_state_put(x);
4573 diff --git a/security/keys/key.c b/security/keys/key.c
4574 index ac9326c..700400d 100644
4575 --- a/security/keys/key.c
4576 +++ b/security/keys/key.c
4577 @@ -188,6 +188,7 @@ static inline void key_alloc_serial(struct key *key)
4578
4579 spin_lock(&key_serial_lock);
4580
4581 +attempt_insertion:
4582 parent = NULL;
4583 p = &key_serial_tree.rb_node;
4584
4585 @@ -202,39 +203,33 @@ static inline void key_alloc_serial(struct key *key)
4586 else
4587 goto serial_exists;
4588 }
4589 - goto insert_here;
4590 +
4591 + /* we've found a suitable hole - arrange for this key to occupy it */
4592 + rb_link_node(&key->serial_node, parent, p);
4593 + rb_insert_color(&key->serial_node, &key_serial_tree);
4594 +
4595 + spin_unlock(&key_serial_lock);
4596 + return;
4597
4598 /* we found a key with the proposed serial number - walk the tree from
4599 * that point looking for the next unused serial number */
4600 serial_exists:
4601 for (;;) {
4602 key->serial++;
4603 - if (key->serial < 2)
4604 - key->serial = 2;
4605 -
4606 - if (!rb_parent(parent))
4607 - p = &key_serial_tree.rb_node;
4608 - else if (rb_parent(parent)->rb_left == parent)
4609 - p = &(rb_parent(parent)->rb_left);
4610 - else
4611 - p = &(rb_parent(parent)->rb_right);
4612 + if (key->serial < 3) {
4613 + key->serial = 3;
4614 + goto attempt_insertion;
4615 + }
4616
4617 parent = rb_next(parent);
4618 if (!parent)
4619 - break;
4620 + goto attempt_insertion;
4621
4622 xkey = rb_entry(parent, struct key, serial_node);
4623 if (key->serial < xkey->serial)
4624 - goto insert_here;
4625 + goto attempt_insertion;
4626 }
4627
4628 - /* we've found a suitable hole - arrange for this key to occupy it */
4629 -insert_here:
4630 - rb_link_node(&key->serial_node, parent, p);
4631 - rb_insert_color(&key->serial_node, &key_serial_tree);
4632 -
4633 - spin_unlock(&key_serial_lock);
4634 -
4635 } /* end key_alloc_serial() */
4636
4637 /*****************************************************************************/
4638 diff --git a/sound/pci/hda/hda_intel.c b/sound/pci/hda/hda_intel.c
4639 index 1a7e821..77f8ec7 100644
4640 --- a/sound/pci/hda/hda_intel.c
4641 +++ b/sound/pci/hda/hda_intel.c
4642 @@ -199,7 +199,7 @@ enum { SDI0, SDI1, SDI2, SDI3, SDO0, SDO1, SDO2, SDO3 };
4643
4644 /* STATESTS int mask: SD2,SD1,SD0 */
4645 #define STATESTS_INT_MASK 0x07
4646 -#define AZX_MAX_CODECS 4
4647 +#define AZX_MAX_CODECS 3
4648
4649 /* SD_CTL bits */
4650 #define SD_CTL_STREAM_RESET 0x01 /* stream reset bit */
4651 diff --git a/sound/usb/usbaudio.c b/sound/usb/usbaudio.c
4652 index 19bdcc7..1bd9af6 100644
4653 --- a/sound/usb/usbaudio.c
4654 +++ b/sound/usb/usbaudio.c
4655 @@ -186,6 +186,7 @@ struct snd_usb_substream {
4656 u64 formats; /* format bitmasks (all or'ed) */
4657 unsigned int num_formats; /* number of supported audio formats (list) */
4658 struct list_head fmt_list; /* format list */
4659 + struct snd_pcm_hw_constraint_list rate_list; /* limited rates */
4660 spinlock_t lock;
4661
4662 struct snd_urb_ops ops; /* callbacks (must be filled at init) */
4663 @@ -1810,28 +1811,33 @@ static int check_hw_params_convention(struct snd_usb_substream *subs)
4664 static int snd_usb_pcm_check_knot(struct snd_pcm_runtime *runtime,
4665 struct snd_usb_substream *subs)
4666 {
4667 - struct list_head *p;
4668 - struct snd_pcm_hw_constraint_list constraints_rates;
4669 + struct audioformat *fp;
4670 + int count = 0, needs_knot = 0;
4671 int err;
4672
4673 - list_for_each(p, &subs->fmt_list) {
4674 - struct audioformat *fp;
4675 - fp = list_entry(p, struct audioformat, list);
4676 -
4677 - if (!fp->needs_knot)
4678 - continue;
4679 -
4680 - constraints_rates.count = fp->nr_rates;
4681 - constraints_rates.list = fp->rate_table;
4682 - constraints_rates.mask = 0;
4683 -
4684 - err = snd_pcm_hw_constraint_list(runtime, 0,
4685 - SNDRV_PCM_HW_PARAM_RATE,
4686 - &constraints_rates);
4687 -
4688 - if (err < 0)
4689 - return err;
4690 + list_for_each_entry(fp, &subs->fmt_list, list) {
4691 + if (fp->rates & SNDRV_PCM_RATE_CONTINUOUS)
4692 + return 0;
4693 + count += fp->nr_rates;
4694 + if (fp->needs_knot)
4695 + needs_knot = 1;
4696 }
4697 + if (!needs_knot)
4698 + return 0;
4699 +
4700 + subs->rate_list.count = count;
4701 + subs->rate_list.list = kmalloc(sizeof(int) * count, GFP_KERNEL);
4702 + subs->rate_list.mask = 0;
4703 + count = 0;
4704 + list_for_each_entry(fp, &subs->fmt_list, list) {
4705 + int i;
4706 + for (i = 0; i < fp->nr_rates; i++)
4707 + subs->rate_list.list[count++] = fp->rate_table[i];
4708 + }
4709 + err = snd_pcm_hw_constraint_list(runtime, 0, SNDRV_PCM_HW_PARAM_RATE,
4710 + &subs->rate_list);
4711 + if (err < 0)
4712 + return err;
4713
4714 return 0;
4715 }
4716 @@ -2231,6 +2237,7 @@ static void free_substream(struct snd_usb_substream *subs)
4717 kfree(fp->rate_table);
4718 kfree(fp);
4719 }
4720 + kfree(subs->rate_list.list);
4721 }
4722
4723
4724 @@ -2456,6 +2463,7 @@ static int parse_audio_format_rates(struct snd_usb_audio *chip, struct audioform
4725 * build the rate table and bitmap flags
4726 */
4727 int r, idx, c;
4728 + unsigned int nonzero_rates = 0;
4729 /* this table corresponds to the SNDRV_PCM_RATE_XXX bit */
4730 static unsigned int conv_rates[] = {
4731 5512, 8000, 11025, 16000, 22050, 32000, 44100, 48000,
4732 @@ -2478,6 +2486,7 @@ static int parse_audio_format_rates(struct snd_usb_audio *chip, struct audioform
4733 fp->altsetting == 5 && fp->maxpacksize == 392)
4734 rate = 96000;
4735 fp->rate_table[r] = rate;
4736 + nonzero_rates |= rate;
4737 if (rate < fp->rate_min)
4738 fp->rate_min = rate;
4739 else if (rate > fp->rate_max)
4740 @@ -2493,6 +2502,10 @@ static int parse_audio_format_rates(struct snd_usb_audio *chip, struct audioform
4741 if (!found)
4742 fp->needs_knot = 1;
4743 }
4744 + if (!nonzero_rates) {
4745 + hwc_debug("All rates were zero. Skipping format!\n");
4746 + return -1;
4747 + }
4748 if (fp->needs_knot)
4749 fp->rates |= SNDRV_PCM_RATE_KNOT;
4750 } else {