/[linux-patches]/genpatches-2.6/tags/2.6.20-9/1001_linux-2.6.20.2.patch
Gentoo

Contents of /genpatches-2.6/tags/2.6.20-9/1001_linux-2.6.20.2.patch

Parent Directory Parent Directory | Revision Log Revision Log


Revision 927 - (show annotations) (download)
Thu Apr 26 15:33:43 2007 UTC (7 years, 7 months ago) by phreak
File size: 152350 byte(s)
2.6.20-9 release
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/sched.c b/kernel/sched.c
3780 index cca93cc..62db30c 100644
3781 --- a/kernel/sched.c
3782 +++ b/kernel/sched.c
3783 @@ -3528,7 +3528,7 @@ need_resched_nonpreemptible:
3784 }
3785 }
3786 next->sleep_type = SLEEP_NORMAL;
3787 - if (dependent_sleeper(cpu, rq, next))
3788 + if (rq->nr_running == 1 && dependent_sleeper(cpu, rq, next))
3789 next = rq->idle;
3790 switch_tasks:
3791 if (next == rq->idle)
3792 @@ -3547,7 +3547,7 @@ switch_tasks:
3793
3794 sched_info_switch(prev, next);
3795 if (likely(prev != next)) {
3796 - next->timestamp = now;
3797 + next->timestamp = next->last_ran = now;
3798 rq->nr_switches++;
3799 rq->curr = next;
3800 ++*switch_count;
3801 diff --git a/kernel/time/clocksource.c b/kernel/time/clocksource.c
3802 index 22504af..d9ef176 100644
3803 --- a/kernel/time/clocksource.c
3804 +++ b/kernel/time/clocksource.c
3805 @@ -28,6 +28,7 @@
3806 #include <linux/sysdev.h>
3807 #include <linux/init.h>
3808 #include <linux/module.h>
3809 +#include <linux/sched.h> /* for spin_unlock_irq() using preempt_count() m68k */
3810
3811 /* XXX - Would like a better way for initializing curr_clocksource */
3812 extern struct clocksource clocksource_jiffies;
3813 diff --git a/lib/Kconfig.debug b/lib/Kconfig.debug
3814 index 5c26818..330bff8 100644
3815 --- a/lib/Kconfig.debug
3816 +++ b/lib/Kconfig.debug
3817 @@ -399,8 +399,8 @@ config LKDTM
3818
3819 config FAULT_INJECTION
3820 bool "Fault-injection framework"
3821 - depends on DEBUG_KERNEL
3822 - depends on STACKTRACE
3823 + depends on DEBUG_KERNEL && STACKTRACE_SUPPORT
3824 + select STACKTRACE
3825 select FRAME_POINTER
3826 help
3827 Provide fault-injection framework.
3828 diff --git a/lib/swiotlb.c b/lib/swiotlb.c
3829 index 1062578..d6d57fb 100644
3830 --- a/lib/swiotlb.c
3831 +++ b/lib/swiotlb.c
3832 @@ -750,7 +750,7 @@ swiotlb_sync_sg(struct device *hwdev, struct scatterlist *sg,
3833
3834 for (i = 0; i < nelems; i++, sg++)
3835 if (sg->dma_address != SG_ENT_PHYS_ADDRESS(sg))
3836 - sync_single(hwdev, (void *) sg->dma_address,
3837 + sync_single(hwdev, phys_to_virt(sg->dma_address),
3838 sg->dma_length, dir, target);
3839 }
3840
3841 diff --git a/mm/hugetlb.c b/mm/hugetlb.c
3842 index cb362f7..36db012 100644
3843 --- a/mm/hugetlb.c
3844 +++ b/mm/hugetlb.c
3845 @@ -389,6 +389,8 @@ void __unmap_hugepage_range(struct vm_area_struct *vma, unsigned long start,
3846 continue;
3847
3848 page = pte_page(pte);
3849 + if (pte_dirty(pte))
3850 + set_page_dirty(page);
3851 list_add(&page->lru, &page_list);
3852 }
3853 spin_unlock(&mm->page_table_lock);
3854 diff --git a/mm/page-writeback.c b/mm/page-writeback.c
3855 index be0efbd..17255ab 100644
3856 --- a/mm/page-writeback.c
3857 +++ b/mm/page-writeback.c
3858 @@ -296,11 +296,21 @@ void balance_dirty_pages_ratelimited_nr(struct address_space *mapping,
3859 }
3860 EXPORT_SYMBOL(balance_dirty_pages_ratelimited_nr);
3861
3862 -void throttle_vm_writeout(void)
3863 +void throttle_vm_writeout(gfp_t gfp_mask)
3864 {
3865 long background_thresh;
3866 long dirty_thresh;
3867
3868 + if ((gfp_mask & (__GFP_FS|__GFP_IO)) != (__GFP_FS|__GFP_IO)) {
3869 + /*
3870 + * The caller might hold locks which can prevent IO completion
3871 + * or progress in the filesystem. So we cannot just sit here
3872 + * waiting for IO to complete.
3873 + */
3874 + congestion_wait(WRITE, HZ/10);
3875 + return;
3876 + }
3877 +
3878 for ( ; ; ) {
3879 get_dirty_limits(&background_thresh, &dirty_thresh, NULL);
3880
3881 @@ -317,7 +327,6 @@ void throttle_vm_writeout(void)
3882 }
3883 }
3884
3885 -
3886 /*
3887 * writeback at least _min_pages, and keep writing until the amount of dirty
3888 * memory is less than the background threshold, or until we're all clean.
3889 diff --git a/mm/vmscan.c b/mm/vmscan.c
3890 index 7430df6..5b4528a 100644
3891 --- a/mm/vmscan.c
3892 +++ b/mm/vmscan.c
3893 @@ -949,7 +949,7 @@ static unsigned long shrink_zone(int priority, struct zone *zone,
3894 }
3895 }
3896
3897 - throttle_vm_writeout();
3898 + throttle_vm_writeout(sc->gfp_mask);
3899
3900 atomic_dec(&zone->reclaim_in_progress);
3901 return nr_reclaimed;
3902 diff --git a/net/atm/common.c b/net/atm/common.c
3903 index fbabff4..a2878e9 100644
3904 --- a/net/atm/common.c
3905 +++ b/net/atm/common.c
3906 @@ -816,7 +816,8 @@ static void __exit atm_exit(void)
3907 proto_unregister(&vcc_proto);
3908 }
3909
3910 -module_init(atm_init);
3911 +subsys_initcall(atm_init);
3912 +
3913 module_exit(atm_exit);
3914
3915 MODULE_LICENSE("GPL");
3916 diff --git a/net/ipv4/igmp.c b/net/ipv4/igmp.c
3917 index 0017ccb..024ae56 100644
3918 --- a/net/ipv4/igmp.c
3919 +++ b/net/ipv4/igmp.c
3920 @@ -455,6 +455,8 @@ static struct sk_buff *add_grec(struct sk_buff *skb, struct ip_mc_list *pmc,
3921 skb = add_grhead(skb, pmc, type, &pgr);
3922 first = 0;
3923 }
3924 + if (!skb)
3925 + return NULL;
3926 psrc = (__be32 *)skb_put(skb, sizeof(__be32));
3927 *psrc = psf->sf_inaddr;
3928 scount++; stotal++;
3929 diff --git a/net/ipv4/netfilter/ipt_REJECT.c b/net/ipv4/netfilter/ipt_REJECT.c
3930 index f0319e5..6714bd1 100644
3931 --- a/net/ipv4/netfilter/ipt_REJECT.c
3932 +++ b/net/ipv4/netfilter/ipt_REJECT.c
3933 @@ -79,6 +79,10 @@ static void send_reset(struct sk_buff *oldskb, int hook)
3934 nskb->mark = 0;
3935 skb_init_secmark(nskb);
3936
3937 + skb_shinfo(nskb)->gso_size = 0;
3938 + skb_shinfo(nskb)->gso_segs = 0;
3939 + skb_shinfo(nskb)->gso_type = 0;
3940 +
3941 tcph = (struct tcphdr *)((u_int32_t*)nskb->nh.iph + nskb->nh.iph->ihl);
3942
3943 /* Swap source and dest */
3944 diff --git a/net/ipv4/tcp.c b/net/ipv4/tcp.c
3945 index b67e0dd..ebe9d0d 100644
3946 --- a/net/ipv4/tcp.c
3947 +++ b/net/ipv4/tcp.c
3948 @@ -2266,12 +2266,12 @@ void tcp_free_md5sig_pool(void)
3949 {
3950 struct tcp_md5sig_pool **pool = NULL;
3951
3952 - spin_lock(&tcp_md5sig_pool_lock);
3953 + spin_lock_bh(&tcp_md5sig_pool_lock);
3954 if (--tcp_md5sig_users == 0) {
3955 pool = tcp_md5sig_pool;
3956 tcp_md5sig_pool = NULL;
3957 }
3958 - spin_unlock(&tcp_md5sig_pool_lock);
3959 + spin_unlock_bh(&tcp_md5sig_pool_lock);
3960 if (pool)
3961 __tcp_free_md5sig_pool(pool);
3962 }
3963 @@ -2314,36 +2314,36 @@ struct tcp_md5sig_pool **tcp_alloc_md5sig_pool(void)
3964 int alloc = 0;
3965
3966 retry:
3967 - spin_lock(&tcp_md5sig_pool_lock);
3968 + spin_lock_bh(&tcp_md5sig_pool_lock);
3969 pool = tcp_md5sig_pool;
3970 if (tcp_md5sig_users++ == 0) {
3971 alloc = 1;
3972 - spin_unlock(&tcp_md5sig_pool_lock);
3973 + spin_unlock_bh(&tcp_md5sig_pool_lock);
3974 } else if (!pool) {
3975 tcp_md5sig_users--;
3976 - spin_unlock(&tcp_md5sig_pool_lock);
3977 + spin_unlock_bh(&tcp_md5sig_pool_lock);
3978 cpu_relax();
3979 goto retry;
3980 } else
3981 - spin_unlock(&tcp_md5sig_pool_lock);
3982 + spin_unlock_bh(&tcp_md5sig_pool_lock);
3983
3984 if (alloc) {
3985 /* we cannot hold spinlock here because this may sleep. */
3986 struct tcp_md5sig_pool **p = __tcp_alloc_md5sig_pool();
3987 - spin_lock(&tcp_md5sig_pool_lock);
3988 + spin_lock_bh(&tcp_md5sig_pool_lock);
3989 if (!p) {
3990 tcp_md5sig_users--;
3991 - spin_unlock(&tcp_md5sig_pool_lock);
3992 + spin_unlock_bh(&tcp_md5sig_pool_lock);
3993 return NULL;
3994 }
3995 pool = tcp_md5sig_pool;
3996 if (pool) {
3997 /* oops, it has already been assigned. */
3998 - spin_unlock(&tcp_md5sig_pool_lock);
3999 + spin_unlock_bh(&tcp_md5sig_pool_lock);
4000 __tcp_free_md5sig_pool(p);
4001 } else {
4002 tcp_md5sig_pool = pool = p;
4003 - spin_unlock(&tcp_md5sig_pool_lock);
4004 + spin_unlock_bh(&tcp_md5sig_pool_lock);
4005 }
4006 }
4007 return pool;
4008 @@ -2354,11 +2354,11 @@ EXPORT_SYMBOL(tcp_alloc_md5sig_pool);
4009 struct tcp_md5sig_pool *__tcp_get_md5sig_pool(int cpu)
4010 {
4011 struct tcp_md5sig_pool **p;
4012 - spin_lock(&tcp_md5sig_pool_lock);
4013 + spin_lock_bh(&tcp_md5sig_pool_lock);
4014 p = tcp_md5sig_pool;
4015 if (p)
4016 tcp_md5sig_users++;
4017 - spin_unlock(&tcp_md5sig_pool_lock);
4018 + spin_unlock_bh(&tcp_md5sig_pool_lock);
4019 return (p ? *per_cpu_ptr(p, cpu) : NULL);
4020 }
4021
4022 diff --git a/net/ipv4/tcp_minisocks.c b/net/ipv4/tcp_minisocks.c
4023 index 4a3889d..aa54ad4 100644
4024 --- a/net/ipv4/tcp_minisocks.c
4025 +++ b/net/ipv4/tcp_minisocks.c
4026 @@ -381,7 +381,7 @@ struct sock *tcp_create_openreq_child(struct sock *sk, struct request_sock *req,
4027 if (newsk != NULL) {
4028 const struct inet_request_sock *ireq = inet_rsk(req);
4029 struct tcp_request_sock *treq = tcp_rsk(req);
4030 - struct inet_connection_sock *newicsk = inet_csk(sk);
4031 + struct inet_connection_sock *newicsk = inet_csk(newsk);
4032 struct tcp_sock *newtp;
4033
4034 /* Now setup tcp_sock */
4035 diff --git a/net/ipv4/tcp_output.c b/net/ipv4/tcp_output.c
4036 index 975f447..1951eaa 100644
4037 --- a/net/ipv4/tcp_output.c
4038 +++ b/net/ipv4/tcp_output.c
4039 @@ -481,7 +481,7 @@ static int tcp_transmit_skb(struct sock *sk, struct sk_buff *skb, int clone_it,
4040 /* RFC1323: The window in SYN & SYN/ACK segments
4041 * is never scaled.
4042 */
4043 - th->window = htons(tp->rcv_wnd);
4044 + th->window = htons(min(tp->rcv_wnd, 65535U));
4045 } else {
4046 th->window = htons(tcp_select_window(sk));
4047 }
4048 @@ -965,7 +965,8 @@ static inline unsigned int tcp_cwnd_test(struct tcp_sock *tp, struct sk_buff *sk
4049 u32 in_flight, cwnd;
4050
4051 /* Don't be strict about the congestion window for the final FIN. */
4052 - if (TCP_SKB_CB(skb)->flags & TCPCB_FLAG_FIN)
4053 + if ((TCP_SKB_CB(skb)->flags & TCPCB_FLAG_FIN) &&
4054 + tcp_skb_pcount(skb) == 1)
4055 return 1;
4056
4057 in_flight = tcp_packets_in_flight(tp);
4058 @@ -2159,7 +2160,7 @@ struct sk_buff * tcp_make_synack(struct sock *sk, struct dst_entry *dst,
4059 }
4060
4061 /* RFC1323: The window in SYN & SYN/ACK segments is never scaled. */
4062 - th->window = htons(req->rcv_wnd);
4063 + th->window = htons(min(req->rcv_wnd, 65535U));
4064
4065 TCP_SKB_CB(skb)->when = tcp_time_stamp;
4066 tcp_syn_build_options((__be32 *)(th + 1), dst_metric(dst, RTAX_ADVMSS), ireq->tstamp_ok,
4067 diff --git a/net/ipv4/xfrm4_mode_tunnel.c b/net/ipv4/xfrm4_mode_tunnel.c
4068 index e23c21d..21ed667 100644
4069 --- a/net/ipv4/xfrm4_mode_tunnel.c
4070 +++ b/net/ipv4/xfrm4_mode_tunnel.c
4071 @@ -84,6 +84,7 @@ static int xfrm4_tunnel_input(struct xfrm_state *x, struct sk_buff *skb)
4072 (err = pskb_expand_head(skb, 0, 0, GFP_ATOMIC)))
4073 goto out;
4074
4075 + iph = skb->nh.iph;
4076 if (x->props.flags & XFRM_STATE_DECAP_DSCP)
4077 ipv4_copy_dscp(iph, skb->h.ipiph);
4078 if (!(x->props.flags & XFRM_STATE_NOECN))
4079 diff --git a/net/ipv6/addrconf.c b/net/ipv6/addrconf.c
4080 index e385469..58cb669 100644
4081 --- a/net/ipv6/addrconf.c
4082 +++ b/net/ipv6/addrconf.c
4083 @@ -469,6 +469,8 @@ static void dev_forward_change(struct inet6_dev *idev)
4084 ipv6_dev_mc_dec(dev, &addr);
4085 }
4086 for (ifa=idev->addr_list; ifa; ifa=ifa->if_next) {
4087 + if (ifa->flags&IFA_F_TENTATIVE)
4088 + continue;
4089 if (idev->cnf.forwarding)
4090 addrconf_join_anycast(ifa);
4091 else
4092 diff --git a/net/ipv6/anycast.c b/net/ipv6/anycast.c
4093 index a960476..fe0c895 100644
4094 --- a/net/ipv6/anycast.c
4095 +++ b/net/ipv6/anycast.c
4096 @@ -462,6 +462,7 @@ static inline struct ifacaddr6 *ac6_get_first(struct seq_file *seq)
4097 break;
4098 }
4099 read_unlock_bh(&idev->lock);
4100 + in6_dev_put(idev);
4101 }
4102 return im;
4103 }
4104 diff --git a/net/ipv6/inet6_hashtables.c b/net/ipv6/inet6_hashtables.c
4105 index b7e5bae..ba13f74 100644
4106 --- a/net/ipv6/inet6_hashtables.c
4107 +++ b/net/ipv6/inet6_hashtables.c
4108 @@ -172,7 +172,7 @@ static int __inet6_check_established(struct inet_timewait_death_row *death_row,
4109 const struct in6_addr *saddr = &np->daddr;
4110 const int dif = sk->sk_bound_dev_if;
4111 const __portpair ports = INET_COMBINED_PORTS(inet->dport, lport);
4112 - const unsigned int hash = inet6_ehashfn(daddr, inet->num, saddr,
4113 + const unsigned int hash = inet6_ehashfn(daddr, lport, saddr,
4114 inet->dport);
4115 struct inet_ehash_bucket *head = inet_ehash_bucket(hinfo, hash);
4116 struct sock *sk2;
4117 diff --git a/net/ipv6/ipv6_sockglue.c b/net/ipv6/ipv6_sockglue.c
4118 index 352690e..23db88e 100644
4119 --- a/net/ipv6/ipv6_sockglue.c
4120 +++ b/net/ipv6/ipv6_sockglue.c
4121 @@ -796,11 +796,15 @@ int compat_ipv6_setsockopt(struct sock *sk, int level, int optname,
4122 EXPORT_SYMBOL(compat_ipv6_setsockopt);
4123 #endif
4124
4125 -static int ipv6_getsockopt_sticky(struct sock *sk, struct ipv6_opt_hdr *hdr,
4126 +static int ipv6_getsockopt_sticky(struct sock *sk, struct ipv6_txoptions *opt,
4127 char __user *optval, int len)
4128 {
4129 - if (!hdr)
4130 + struct ipv6_opt_hdr *hdr;
4131 +
4132 + if (!opt || !opt->hopopt)
4133 return 0;
4134 + hdr = opt->hopopt;
4135 +
4136 len = min_t(int, len, ipv6_optlen(hdr));
4137 if (copy_to_user(optval, hdr, ipv6_optlen(hdr)))
4138 return -EFAULT;
4139 @@ -941,7 +945,7 @@ static int do_ipv6_getsockopt(struct sock *sk, int level, int optname,
4140 {
4141
4142 lock_sock(sk);
4143 - len = ipv6_getsockopt_sticky(sk, np->opt->hopopt,
4144 + len = ipv6_getsockopt_sticky(sk, np->opt,
4145 optval, len);
4146 release_sock(sk);
4147 return put_user(len, optlen);
4148 diff --git a/net/ipv6/mcast.c b/net/ipv6/mcast.c
4149 index 882cde4..e3ec216 100644
4150 --- a/net/ipv6/mcast.c
4151 +++ b/net/ipv6/mcast.c
4152 @@ -1582,6 +1582,8 @@ static struct sk_buff *add_grec(struct sk_buff *skb, struct ifmcaddr6 *pmc,
4153 skb = add_grhead(skb, pmc, type, &pgr);
4154 first = 0;
4155 }
4156 + if (!skb)
4157 + return NULL;
4158 psrc = (struct in6_addr *)skb_put(skb, sizeof(*psrc));
4159 *psrc = psf->sf_addr;
4160 scount++; stotal++;
4161 diff --git a/net/ipx/af_ipx.c b/net/ipx/af_ipx.c
4162 index 76c6615..89f283c 100644
4163 --- a/net/ipx/af_ipx.c
4164 +++ b/net/ipx/af_ipx.c
4165 @@ -2035,19 +2035,27 @@ static void __exit ipx_proto_finito(void)
4166
4167 ipxitf_cleanup();
4168
4169 - unregister_snap_client(pSNAP_datalink);
4170 - pSNAP_datalink = NULL;
4171 + if (pSNAP_datalink) {
4172 + unregister_snap_client(pSNAP_datalink);
4173 + pSNAP_datalink = NULL;
4174 + }
4175
4176 - unregister_8022_client(p8022_datalink);
4177 - p8022_datalink = NULL;
4178 + if (p8022_datalink) {
4179 + unregister_8022_client(p8022_datalink);
4180 + p8022_datalink = NULL;
4181 + }
4182
4183 dev_remove_pack(&ipx_8023_packet_type);
4184 - destroy_8023_client(p8023_datalink);
4185 - p8023_datalink = NULL;
4186 + if (p8023_datalink) {
4187 + destroy_8023_client(p8023_datalink);
4188 + p8023_datalink = NULL;
4189 + }
4190
4191 dev_remove_pack(&ipx_dix_packet_type);
4192 - destroy_EII_client(pEII_datalink);
4193 - pEII_datalink = NULL;
4194 + if (pEII_datalink) {
4195 + destroy_EII_client(pEII_datalink);
4196 + pEII_datalink = NULL;
4197 + }
4198
4199 proto_unregister(&ipx_proto);
4200 sock_unregister(ipx_family_ops.family);
4201 diff --git a/net/key/af_key.c b/net/key/af_key.c
4202 index 5dd5094..3b4a1f4 100644
4203 --- a/net/key/af_key.c
4204 +++ b/net/key/af_key.c
4205 @@ -2297,16 +2297,17 @@ static int pfkey_spddelete(struct sock *sk, struct sk_buff *skb, struct sadb_msg
4206 &sel, tmp.security, 1);
4207 security_xfrm_policy_free(&tmp);
4208
4209 - xfrm_audit_log(audit_get_loginuid(current->audit_context), 0,
4210 - AUDIT_MAC_IPSEC_DELSPD, (xp) ? 1 : 0, xp, NULL);
4211 -
4212 if (xp == NULL)
4213 return -ENOENT;
4214
4215 - err = 0;
4216 + err = security_xfrm_policy_delete(xp);
4217
4218 - if ((err = security_xfrm_policy_delete(xp)))
4219 + xfrm_audit_log(audit_get_loginuid(current->audit_context), 0,
4220 + AUDIT_MAC_IPSEC_DELSPD, err ? 0 : 1, xp, NULL);
4221 +
4222 + if (err)
4223 goto out;
4224 +
4225 c.seq = hdr->sadb_msg_seq;
4226 c.pid = hdr->sadb_msg_pid;
4227 c.event = XFRM_MSG_DELPOLICY;
4228 diff --git a/net/netfilter/nfnetlink_log.c b/net/netfilter/nfnetlink_log.c
4229 index d1505dd..24c1d29 100644
4230 --- a/net/netfilter/nfnetlink_log.c
4231 +++ b/net/netfilter/nfnetlink_log.c
4232 @@ -217,6 +217,11 @@ _instance_destroy2(struct nfulnl_instance *inst, int lock)
4233
4234 spin_lock_bh(&inst->lock);
4235 if (inst->skb) {
4236 + /* timer "holds" one reference (we have one more) */
4237 + if (timer_pending(&inst->timer)) {
4238 + del_timer(&inst->timer);
4239 + instance_put(inst);
4240 + }
4241 if (inst->qlen)
4242 __nfulnl_send(inst);
4243 if (inst->skb) {
4244 @@ -363,9 +368,6 @@ __nfulnl_send(struct nfulnl_instance *inst)
4245 {
4246 int status;
4247
4248 - if (timer_pending(&inst->timer))
4249 - del_timer(&inst->timer);
4250 -
4251 if (!inst->skb)
4252 return 0;
4253
4254 @@ -392,6 +394,8 @@ static void nfulnl_timer(unsigned long data)
4255 UDEBUG("timer function called, flushing buffer\n");
4256
4257 spin_lock_bh(&inst->lock);
4258 + if (timer_pending(&inst->timer)) /* is it always true or false here? */
4259 + del_timer(&inst->timer);
4260 __nfulnl_send(inst);
4261 instance_put(inst);
4262 spin_unlock_bh(&inst->lock);
4263 @@ -689,6 +693,11 @@ nfulnl_log_packet(unsigned int pf,
4264 * enough room in the skb left. flush to userspace. */
4265 UDEBUG("flushing old skb\n");
4266
4267 + /* timer "holds" one reference (we have another one) */
4268 + if (timer_pending(&inst->timer)) {
4269 + del_timer(&inst->timer);
4270 + instance_put(inst);
4271 + }
4272 __nfulnl_send(inst);
4273
4274 if (!(inst->skb = nfulnl_alloc_skb(nlbufsiz, size))) {
4275 diff --git a/net/sunrpc/pmap_clnt.c b/net/sunrpc/pmap_clnt.c
4276 index 3946ec3..76e59e9 100644
4277 --- a/net/sunrpc/pmap_clnt.c
4278 +++ b/net/sunrpc/pmap_clnt.c
4279 @@ -62,7 +62,10 @@ static inline void pmap_map_free(struct portmap_args *map)
4280
4281 static void pmap_map_release(void *data)
4282 {
4283 - pmap_map_free(data);
4284 + struct portmap_args *map = data;
4285 +
4286 + xprt_put(map->pm_xprt);
4287 + pmap_map_free(map);
4288 }
4289
4290 static const struct rpc_call_ops pmap_getport_ops = {
4291 @@ -133,7 +136,7 @@ void rpc_getport(struct rpc_task *task)
4292 status = -EIO;
4293 child = rpc_run_task(pmap_clnt, RPC_TASK_ASYNC, &pmap_getport_ops, map);
4294 if (IS_ERR(child))
4295 - goto bailout;
4296 + goto bailout_nofree;
4297 rpc_put_task(child);
4298
4299 task->tk_xprt->stat.bind_count++;
4300 @@ -222,7 +225,6 @@ static void pmap_getport_done(struct rpc_task *child, void *data)
4301 child->tk_pid, status, map->pm_port);
4302
4303 pmap_wake_portmap_waiters(xprt, status);
4304 - xprt_put(xprt);
4305 }
4306
4307 /**
4308 diff --git a/net/sunrpc/svc.c b/net/sunrpc/svc.c
4309 index 4c16112..baf27a9 100644
4310 --- a/net/sunrpc/svc.c
4311 +++ b/net/sunrpc/svc.c
4312 @@ -79,7 +79,11 @@ svc_pool_map_choose_mode(void)
4313 * x86_64 kernel on Xeons. In this case we
4314 * want to divide the pools on cpu boundaries.
4315 */
4316 - return SVC_POOL_PERCPU;
4317 + /* actually, unless your IRQs round-robin nicely,
4318 + * this turns out to be really bad, so just
4319 + * go GLOBAL for now until a better fix can be developped
4320 + */
4321 + return SVC_POOL_GLOBAL;
4322 }
4323
4324 /* default: one global pool */
4325 @@ -367,6 +371,7 @@ void
4326 svc_destroy(struct svc_serv *serv)
4327 {
4328 struct svc_sock *svsk;
4329 + struct svc_sock *tmp;
4330
4331 dprintk("RPC: svc_destroy(%s, %d)\n",
4332 serv->sv_program->pg_name,
4333 @@ -382,22 +387,18 @@ svc_destroy(struct svc_serv *serv)
4334
4335 del_timer_sync(&serv->sv_temptimer);
4336
4337 - while (!list_empty(&serv->sv_tempsocks)) {
4338 - svsk = list_entry(serv->sv_tempsocks.next,
4339 - struct svc_sock,
4340 - sk_list);
4341 - svc_delete_socket(svsk);
4342 - }
4343 + list_for_each_entry_safe(svsk, tmp, &serv->sv_tempsocks, sk_list)
4344 + svc_force_close_socket(svsk);
4345 +
4346 if (serv->sv_shutdown)
4347 serv->sv_shutdown(serv);
4348
4349 - while (!list_empty(&serv->sv_permsocks)) {
4350 - svsk = list_entry(serv->sv_permsocks.next,
4351 - struct svc_sock,
4352 - sk_list);
4353 - svc_delete_socket(svsk);
4354 - }
4355 -
4356 + list_for_each_entry_safe(svsk, tmp, &serv->sv_permsocks, sk_list)
4357 + svc_force_close_socket(svsk);
4358 +
4359 + BUG_ON(!list_empty(&serv->sv_permsocks));
4360 + BUG_ON(!list_empty(&serv->sv_tempsocks));
4361 +
4362 cache_clean_deferred(serv);
4363
4364 /* Unregister service with the portmapper */
4365 diff --git a/net/sunrpc/svcsock.c b/net/sunrpc/svcsock.c
4366 index ff1f8bf..cd296a5 100644
4367 --- a/net/sunrpc/svcsock.c
4368 +++ b/net/sunrpc/svcsock.c
4369 @@ -62,6 +62,12 @@
4370 * after a clear, the socket must be read/accepted
4371 * if this succeeds, it must be set again.
4372 * SK_CLOSE can set at any time. It is never cleared.
4373 + * sk_inuse contains a bias of '1' until SK_DEAD is set.
4374 + * so when sk_inuse hits zero, we know the socket is dead
4375 + * and no-one is using it.
4376 + * SK_DEAD can only be set while SK_BUSY is held which ensures
4377 + * no other thread will be using the socket or will try to
4378 + * set SK_DEAD.
4379 *
4380 */
4381
4382 @@ -70,9 +76,11 @@
4383
4384 static struct svc_sock *svc_setup_socket(struct svc_serv *, struct socket *,
4385 int *errp, int pmap_reg);
4386 +static void svc_delete_socket(struct svc_sock *svsk);
4387 static void svc_udp_data_ready(struct sock *, int);
4388 static int svc_udp_recvfrom(struct svc_rqst *);
4389 static int svc_udp_sendto(struct svc_rqst *);
4390 +static void svc_close_socket(struct svc_sock *svsk);
4391
4392 static struct svc_deferred_req *svc_deferred_dequeue(struct svc_sock *svsk);
4393 static int svc_deferred_recv(struct svc_rqst *rqstp);
4394 @@ -329,8 +337,9 @@ void svc_reserve(struct svc_rqst *rqstp, int space)
4395 static inline void
4396 svc_sock_put(struct svc_sock *svsk)
4397 {
4398 - if (atomic_dec_and_test(&svsk->sk_inuse) &&
4399 - test_bit(SK_DEAD, &svsk->sk_flags)) {
4400 + if (atomic_dec_and_test(&svsk->sk_inuse)) {
4401 + BUG_ON(! test_bit(SK_DEAD, &svsk->sk_flags));
4402 +
4403 dprintk("svc: releasing dead socket\n");
4404 if (svsk->sk_sock->file)
4405 sockfd_put(svsk->sk_sock);
4406 @@ -520,7 +529,7 @@ svc_sock_names(char *buf, struct svc_serv *serv, char *toclose)
4407
4408 if (!serv)
4409 return 0;
4410 - spin_lock(&serv->sv_lock);
4411 + spin_lock_bh(&serv->sv_lock);
4412 list_for_each_entry(svsk, &serv->sv_permsocks, sk_list) {
4413 int onelen = one_sock_name(buf+len, svsk);
4414 if (toclose && strcmp(toclose, buf+len) == 0)
4415 @@ -528,12 +537,12 @@ svc_sock_names(char *buf, struct svc_serv *serv, char *toclose)
4416 else
4417 len += onelen;
4418 }
4419 - spin_unlock(&serv->sv_lock);
4420 + spin_unlock_bh(&serv->sv_lock);
4421 if (closesk)
4422 /* Should unregister with portmap, but you cannot
4423 * unregister just one protocol...
4424 */
4425 - svc_delete_socket(closesk);
4426 + svc_close_socket(closesk);
4427 else if (toclose)
4428 return -ENOENT;
4429 return len;
4430 @@ -683,6 +692,11 @@ svc_udp_recvfrom(struct svc_rqst *rqstp)
4431 return svc_deferred_recv(rqstp);
4432 }
4433
4434 + if (test_bit(SK_CLOSE, &svsk->sk_flags)) {
4435 + svc_delete_socket(svsk);
4436 + return 0;
4437 + }
4438 +
4439 clear_bit(SK_DATA, &svsk->sk_flags);
4440 while ((skb = skb_recv_datagram(svsk->sk_sk, 0, 1, &err)) == NULL) {
4441 if (err == -EAGAIN) {
4442 @@ -1176,7 +1190,8 @@ svc_tcp_sendto(struct svc_rqst *rqstp)
4443 rqstp->rq_sock->sk_server->sv_name,
4444 (sent<0)?"got error":"sent only",
4445 sent, xbufp->len);
4446 - svc_delete_socket(rqstp->rq_sock);
4447 + set_bit(SK_CLOSE, &rqstp->rq_sock->sk_flags);
4448 + svc_sock_enqueue(rqstp->rq_sock);
4449 sent = -EAGAIN;
4450 }
4451 return sent;
4452 @@ -1495,7 +1510,7 @@ svc_setup_socket(struct svc_serv *serv, struct socket *sock,
4453 svsk->sk_odata = inet->sk_data_ready;
4454 svsk->sk_owspace = inet->sk_write_space;
4455 svsk->sk_server = serv;
4456 - atomic_set(&svsk->sk_inuse, 0);
4457 + atomic_set(&svsk->sk_inuse, 1);
4458 svsk->sk_lastrecv = get_seconds();
4459 spin_lock_init(&svsk->sk_defer_lock);
4460 INIT_LIST_HEAD(&svsk->sk_deferred);
4461 @@ -1618,7 +1633,7 @@ bummer:
4462 /*
4463 * Remove a dead socket
4464 */
4465 -void
4466 +static void
4467 svc_delete_socket(struct svc_sock *svsk)
4468 {
4469 struct svc_serv *serv;
4470 @@ -1644,19 +1659,42 @@ svc_delete_socket(struct svc_sock *svsk)
4471 * while still attached to a queue, the queue itself
4472 * is about to be destroyed (in svc_destroy).
4473 */
4474 - if (!test_and_set_bit(SK_DEAD, &svsk->sk_flags))
4475 + if (!test_and_set_bit(SK_DEAD, &svsk->sk_flags)) {
4476 + BUG_ON(atomic_read(&svsk->sk_inuse)<2);
4477 + atomic_dec(&svsk->sk_inuse);
4478 if (test_bit(SK_TEMP, &svsk->sk_flags))
4479 serv->sv_tmpcnt--;
4480 + }
4481
4482 - /* This atomic_inc should be needed - svc_delete_socket
4483 - * should have the semantic of dropping a reference.
4484 - * But it doesn't yet....
4485 - */
4486 - atomic_inc(&svsk->sk_inuse);
4487 spin_unlock_bh(&serv->sv_lock);
4488 +}
4489 +
4490 +static void svc_close_socket(struct svc_sock *svsk)
4491 +{
4492 + set_bit(SK_CLOSE, &svsk->sk_flags);
4493 + if (test_and_set_bit(SK_BUSY, &svsk->sk_flags))
4494 + /* someone else will have to effect the close */
4495 + return;
4496 +
4497 + atomic_inc(&svsk->sk_inuse);
4498 + svc_delete_socket(svsk);
4499 + clear_bit(SK_BUSY, &svsk->sk_flags);
4500 svc_sock_put(svsk);
4501 }
4502
4503 +void svc_force_close_socket(struct svc_sock *svsk)
4504 +{
4505 + set_bit(SK_CLOSE, &svsk->sk_flags);
4506 + if (test_bit(SK_BUSY, &svsk->sk_flags)) {
4507 + /* Waiting to be processed, but no threads left,
4508 + * So just remove it from the waiting list
4509 + */
4510 + list_del_init(&svsk->sk_ready);
4511 + clear_bit(SK_BUSY, &svsk->sk_flags);
4512 + }
4513 + svc_close_socket(svsk);
4514 +}
4515 +
4516 /*
4517 * Make a socket for nfsd and lockd
4518 */
4519 diff --git a/net/xfrm/xfrm_policy.c b/net/xfrm/xfrm_policy.c
4520 index b7e537f..9704e05 100644
4521 --- a/net/xfrm/xfrm_policy.c
4522 +++ b/net/xfrm/xfrm_policy.c
4523 @@ -1997,9 +1997,14 @@ void xfrm_audit_log(uid_t auid, u32 sid, int type, int result,
4524 if (audit_enabled == 0)
4525 return;
4526
4527 + BUG_ON((type == AUDIT_MAC_IPSEC_ADDSA ||
4528 + type == AUDIT_MAC_IPSEC_DELSA) && !x);
4529 + BUG_ON((type == AUDIT_MAC_IPSEC_ADDSPD ||
4530 + type == AUDIT_MAC_IPSEC_DELSPD) && !xp);
4531 +
4532 audit_buf = audit_log_start(current->audit_context, GFP_ATOMIC, type);
4533 if (audit_buf == NULL)
4534 - return;
4535 + return;
4536
4537 switch(type) {
4538 case AUDIT_MAC_IPSEC_ADDSA:
4539 diff --git a/net/xfrm/xfrm_user.c b/net/xfrm/xfrm_user.c
4540 index 82f36d3..24d15f2 100644
4541 --- a/net/xfrm/xfrm_user.c
4542 +++ b/net/xfrm/xfrm_user.c
4543 @@ -1273,10 +1273,6 @@ static int xfrm_get_policy(struct sk_buff *skb, struct nlmsghdr *nlh,
4544 xp = xfrm_policy_bysel_ctx(type, p->dir, &p->sel, tmp.security, delete);
4545 security_xfrm_policy_free(&tmp);
4546 }
4547 - if (delete)
4548 - xfrm_audit_log(NETLINK_CB(skb).loginuid, NETLINK_CB(skb).sid,
4549 - AUDIT_MAC_IPSEC_DELSPD, (xp) ? 1 : 0, xp, NULL);
4550 -
4551 if (xp == NULL)
4552 return -ENOENT;
4553
4554 @@ -1292,8 +1288,14 @@ static int xfrm_get_policy(struct sk_buff *skb, struct nlmsghdr *nlh,
4555 MSG_DONTWAIT);
4556 }
4557 } else {
4558 - if ((err = security_xfrm_policy_delete(xp)) != 0)
4559 + err = security_xfrm_policy_delete(xp);
4560 +
4561 + xfrm_audit_log(NETLINK_CB(skb).loginuid, NETLINK_CB(skb).sid,
4562 + AUDIT_MAC_IPSEC_DELSPD, err ? 0 : 1, xp, NULL);
4563 +
4564 + if (err != 0)
4565 goto out;
4566 +
4567 c.data.byid = p->index;
4568 c.event = nlh->nlmsg_type;
4569 c.seq = nlh->nlmsg_seq;
4570 @@ -1555,14 +1557,13 @@ static int xfrm_add_sa_expire(struct sk_buff *skb, struct nlmsghdr *nlh,
4571 struct xfrm_usersa_info *p = &ue->state;
4572
4573 x = xfrm_state_lookup(&p->id.daddr, p->id.spi, p->id.proto, p->family);
4574 - err = -ENOENT;
4575
4576 + err = -ENOENT;
4577 if (x == NULL)
4578 return err;
4579
4580 - err = -EINVAL;
4581 -
4582 spin_lock_bh(&x->lock);
4583 + err = -EINVAL;
4584 if (x->km.state != XFRM_STATE_VALID)
4585 goto out;
4586 km_state_expired(x, ue->hard, current->pid);
4587 @@ -1572,6 +1573,7 @@ static int xfrm_add_sa_expire(struct sk_buff *skb, struct nlmsghdr *nlh,
4588 xfrm_audit_log(NETLINK_CB(skb).loginuid, NETLINK_CB(skb).sid,
4589 AUDIT_MAC_IPSEC_DELSA, 1, NULL, x);
4590 }
4591 + err = 0;
4592 out:
4593 spin_unlock_bh(&x->lock);
4594 xfrm_state_put(x);
4595 diff --git a/security/keys/key.c b/security/keys/key.c
4596 index ac9326c..700400d 100644
4597 --- a/security/keys/key.c
4598 +++ b/security/keys/key.c
4599 @@ -188,6 +188,7 @@ static inline void key_alloc_serial(struct key *key)
4600
4601 spin_lock(&key_serial_lock);
4602
4603 +attempt_insertion:
4604 parent = NULL;
4605 p = &key_serial_tree.rb_node;
4606
4607 @@ -202,39 +203,33 @@ static inline void key_alloc_serial(struct key *key)
4608 else
4609 goto serial_exists;
4610 }
4611 - goto insert_here;
4612 +
4613 + /* we've found a suitable hole - arrange for this key to occupy it */
4614 + rb_link_node(&key->serial_node, parent, p);
4615 + rb_insert_color(&key->serial_node, &key_serial_tree);
4616 +
4617 + spin_unlock(&key_serial_lock);
4618 + return;
4619
4620 /* we found a key with the proposed serial number - walk the tree from
4621 * that point looking for the next unused serial number */
4622 serial_exists:
4623 for (;;) {
4624 key->serial++;
4625 - if (key->serial < 2)
4626 - key->serial = 2;
4627 -
4628 - if (!rb_parent(parent))
4629 - p = &key_serial_tree.rb_node;
4630 - else if (rb_parent(parent)->rb_left == parent)
4631 - p = &(rb_parent(parent)->rb_left);
4632 - else
4633 - p = &(rb_parent(parent)->rb_right);
4634 + if (key->serial < 3) {
4635 + key->serial = 3;
4636 + goto attempt_insertion;
4637 + }
4638
4639 parent = rb_next(parent);
4640 if (!parent)
4641 - break;
4642 + goto attempt_insertion;
4643
4644 xkey = rb_entry(parent, struct key, serial_node);
4645 if (key->serial < xkey->serial)
4646 - goto insert_here;
4647 + goto attempt_insertion;
4648 }
4649
4650 - /* we've found a suitable hole - arrange for this key to occupy it */
4651 -insert_here:
4652 - rb_link_node(&key->serial_node, parent, p);
4653 - rb_insert_color(&key->serial_node, &key_serial_tree);
4654 -
4655 - spin_unlock(&key_serial_lock);
4656 -
4657 } /* end key_alloc_serial() */
4658
4659 /*****************************************************************************/
4660 diff --git a/sound/pci/hda/hda_intel.c b/sound/pci/hda/hda_intel.c
4661 index 1a7e821..77f8ec7 100644
4662 --- a/sound/pci/hda/hda_intel.c
4663 +++ b/sound/pci/hda/hda_intel.c
4664 @@ -199,7 +199,7 @@ enum { SDI0, SDI1, SDI2, SDI3, SDO0, SDO1, SDO2, SDO3 };
4665
4666 /* STATESTS int mask: SD2,SD1,SD0 */
4667 #define STATESTS_INT_MASK 0x07
4668 -#define AZX_MAX_CODECS 4
4669 +#define AZX_MAX_CODECS 3
4670
4671 /* SD_CTL bits */
4672 #define SD_CTL_STREAM_RESET 0x01 /* stream reset bit */
4673 diff --git a/sound/usb/usbaudio.c b/sound/usb/usbaudio.c
4674 index 19bdcc7..1bd9af6 100644
4675 --- a/sound/usb/usbaudio.c
4676 +++ b/sound/usb/usbaudio.c
4677 @@ -186,6 +186,7 @@ struct snd_usb_substream {
4678 u64 formats; /* format bitmasks (all or'ed) */
4679 unsigned int num_formats; /* number of supported audio formats (list) */
4680 struct list_head fmt_list; /* format list */
4681 + struct snd_pcm_hw_constraint_list rate_list; /* limited rates */
4682 spinlock_t lock;
4683
4684 struct snd_urb_ops ops; /* callbacks (must be filled at init) */
4685 @@ -1810,28 +1811,33 @@ static int check_hw_params_convention(struct snd_usb_substream *subs)
4686 static int snd_usb_pcm_check_knot(struct snd_pcm_runtime *runtime,
4687 struct snd_usb_substream *subs)
4688 {
4689 - struct list_head *p;
4690 - struct snd_pcm_hw_constraint_list constraints_rates;
4691 + struct audioformat *fp;
4692 + int count = 0, needs_knot = 0;
4693 int err;
4694
4695 - list_for_each(p, &subs->fmt_list) {
4696 - struct audioformat *fp;
4697 - fp = list_entry(p, struct audioformat, list);
4698 -
4699 - if (!fp->needs_knot)
4700 - continue;
4701 -
4702 - constraints_rates.count = fp->nr_rates;
4703 - constraints_rates.list = fp->rate_table;
4704 - constraints_rates.mask = 0;
4705 -
4706 - err = snd_pcm_hw_constraint_list(runtime, 0,
4707 - SNDRV_PCM_HW_PARAM_RATE,
4708 - &constraints_rates);
4709 -
4710 - if (err < 0)
4711 - return err;
4712 + list_for_each_entry(fp, &subs->fmt_list, list) {
4713 + if (fp->rates & SNDRV_PCM_RATE_CONTINUOUS)
4714 + return 0;
4715 + count += fp->nr_rates;
4716 + if (fp->needs_knot)
4717 + needs_knot = 1;
4718 }
4719 + if (!needs_knot)
4720 + return 0;
4721 +
4722 + subs->rate_list.count = count;
4723 + subs->rate_list.list = kmalloc(sizeof(int) * count, GFP_KERNEL);
4724 + subs->rate_list.mask = 0;
4725 + count = 0;
4726 + list_for_each_entry(fp, &subs->fmt_list, list) {
4727 + int i;
4728 + for (i = 0; i < fp->nr_rates; i++)
4729 + subs->rate_list.list[count++] = fp->rate_table[i];
4730 + }
4731 + err = snd_pcm_hw_constraint_list(runtime, 0, SNDRV_PCM_HW_PARAM_RATE,
4732 + &subs->rate_list);
4733 + if (err < 0)
4734 + return err;
4735
4736 return 0;
4737 }
4738 @@ -2231,6 +2237,7 @@ static void free_substream(struct snd_usb_substream *subs)
4739 kfree(fp->rate_table);
4740 kfree(fp);
4741 }
4742 + kfree(subs->rate_list.list);
4743 }
4744
4745
4746 @@ -2456,6 +2463,7 @@ static int parse_audio_format_rates(struct snd_usb_audio *chip, struct audioform
4747 * build the rate table and bitmap flags
4748 */
4749 int r, idx, c;
4750 + unsigned int nonzero_rates = 0;
4751 /* this table corresponds to the SNDRV_PCM_RATE_XXX bit */
4752 static unsigned int conv_rates[] = {
4753 5512, 8000, 11025, 16000, 22050, 32000, 44100, 48000,
4754 @@ -2478,6 +2486,7 @@ static int parse_audio_format_rates(struct snd_usb_audio *chip, struct audioform
4755 fp->altsetting == 5 && fp->maxpacksize == 392)
4756 rate = 96000;
4757 fp->rate_table[r] = rate;
4758 + nonzero_rates |= rate;
4759 if (rate < fp->rate_min)
4760 fp->rate_min = rate;
4761 else if (rate > fp->rate_max)
4762 @@ -2493,6 +2502,10 @@ static int parse_audio_format_rates(struct snd_usb_audio *chip, struct audioform
4763 if (!found)
4764 fp->needs_knot = 1;
4765 }
4766 + if (!nonzero_rates) {
4767 + hwc_debug("All rates were zero. Skipping format!\n");
4768 + return -1;
4769 + }
4770 if (fp->needs_knot)
4771 fp->rates |= SNDRV_PCM_RATE_KNOT;
4772 } else {

  ViewVC Help
Powered by ViewVC 1.1.20