Gentoo Archives: gentoo-commits

From: "Mike Pagano (mpagano)" <mpagano@g.o>
To: gentoo-commits@l.g.o
Subject: [gentoo-commits] linux-patches r1690 - genpatches-2.6/trunk/2.6.33
Date: Thu, 01 Apr 2010 19:40:15
Message-Id: E1NxQFG-0001Ih-1I@stork.gentoo.org
1 Author: mpagano
2 Date: 2010-04-01 19:40:01 +0000 (Thu, 01 Apr 2010)
3 New Revision: 1690
4
5 Added:
6 genpatches-2.6/trunk/2.6.33/1000_linux-2.6.33.1.patch
7 Log:
8 Linux patch 2.6.33.1
9
10 Added: genpatches-2.6/trunk/2.6.33/1000_linux-2.6.33.1.patch
11 ===================================================================
12 --- genpatches-2.6/trunk/2.6.33/1000_linux-2.6.33.1.patch (rev 0)
13 +++ genpatches-2.6/trunk/2.6.33/1000_linux-2.6.33.1.patch 2010-04-01 19:40:01 UTC (rev 1690)
14 @@ -0,0 +1,5513 @@
15 +diff --git a/Documentation/kernel-parameters.txt b/Documentation/kernel-parameters.txt
16 +index e7848a0..e2c7487 100644
17 +--- a/Documentation/kernel-parameters.txt
18 ++++ b/Documentation/kernel-parameters.txt
19 +@@ -2703,6 +2703,13 @@ and is between 256 and 4096 characters. It is defined in the file
20 + medium is write-protected).
21 + Example: quirks=0419:aaf5:rl,0421:0433:rc
22 +
23 ++ userpte=
24 ++ [X86] Flags controlling user PTE allocations.
25 ++
26 ++ nohigh = do not allocate PTE pages in
27 ++ HIGHMEM regardless of setting
28 ++ of CONFIG_HIGHPTE.
29 ++
30 + vdso= [X86,SH]
31 + vdso=2: enable compat VDSO (default with COMPAT_VDSO)
32 + vdso=1: enable VDSO (default)
33 +diff --git a/Documentation/laptops/thinkpad-acpi.txt b/Documentation/laptops/thinkpad-acpi.txt
34 +index 75afa12..39c0a09 100644
35 +--- a/Documentation/laptops/thinkpad-acpi.txt
36 ++++ b/Documentation/laptops/thinkpad-acpi.txt
37 +@@ -650,6 +650,10 @@ LCD, CRT or DVI (if available). The following commands are available:
38 + echo expand_toggle > /proc/acpi/ibm/video
39 + echo video_switch > /proc/acpi/ibm/video
40 +
41 ++NOTE: Access to this feature is restricted to processes owning the
42 ++CAP_SYS_ADMIN capability for safety reasons, as it can interact badly
43 ++enough with some versions of X.org to crash it.
44 ++
45 + Each video output device can be enabled or disabled individually.
46 + Reading /proc/acpi/ibm/video shows the status of each device.
47 +
48 +diff --git a/arch/Kconfig b/arch/Kconfig
49 +index 9d055b4..25e69f7 100644
50 +--- a/arch/Kconfig
51 ++++ b/arch/Kconfig
52 +@@ -6,8 +6,6 @@ config OPROFILE
53 + tristate "OProfile system profiling (EXPERIMENTAL)"
54 + depends on PROFILING
55 + depends on HAVE_OPROFILE
56 +- depends on TRACING_SUPPORT
57 +- select TRACING
58 + select RING_BUFFER
59 + select RING_BUFFER_ALLOW_SWAP
60 + help
61 +diff --git a/arch/x86/ia32/ia32_aout.c b/arch/x86/ia32/ia32_aout.c
62 +index f9f4724..14531ab 100644
63 +--- a/arch/x86/ia32/ia32_aout.c
64 ++++ b/arch/x86/ia32/ia32_aout.c
65 +@@ -327,7 +327,6 @@ static int load_aout_binary(struct linux_binprm *bprm, struct pt_regs *regs)
66 + current->mm->free_area_cache = TASK_UNMAPPED_BASE;
67 + current->mm->cached_hole_size = 0;
68 +
69 +- current->mm->mmap = NULL;
70 + install_exec_creds(bprm);
71 + current->flags &= ~PF_FORKNOEXEC;
72 +
73 +diff --git a/arch/x86/include/asm/io_apic.h b/arch/x86/include/asm/io_apic.h
74 +index 7c7c16c..5f61f6e 100644
75 +--- a/arch/x86/include/asm/io_apic.h
76 ++++ b/arch/x86/include/asm/io_apic.h
77 +@@ -160,6 +160,7 @@ extern int io_apic_get_redir_entries(int ioapic);
78 + struct io_apic_irq_attr;
79 + extern int io_apic_set_pci_routing(struct device *dev, int irq,
80 + struct io_apic_irq_attr *irq_attr);
81 ++void setup_IO_APIC_irq_extra(u32 gsi);
82 + extern int (*ioapic_renumber_irq)(int ioapic, int irq);
83 + extern void ioapic_init_mappings(void);
84 + extern void ioapic_insert_resources(void);
85 +diff --git a/arch/x86/include/asm/pgalloc.h b/arch/x86/include/asm/pgalloc.h
86 +index 0e8c2a0..271de94 100644
87 +--- a/arch/x86/include/asm/pgalloc.h
88 ++++ b/arch/x86/include/asm/pgalloc.h
89 +@@ -23,6 +23,11 @@ static inline void paravirt_release_pud(unsigned long pfn) {}
90 + #endif
91 +
92 + /*
93 ++ * Flags to use when allocating a user page table page.
94 ++ */
95 ++extern gfp_t __userpte_alloc_gfp;
96 ++
97 ++/*
98 + * Allocate and free page tables.
99 + */
100 + extern pgd_t *pgd_alloc(struct mm_struct *);
101 +diff --git a/arch/x86/include/asm/uv/uv_hub.h b/arch/x86/include/asm/uv/uv_hub.h
102 +index 40be813..14cc74b 100644
103 +--- a/arch/x86/include/asm/uv/uv_hub.h
104 ++++ b/arch/x86/include/asm/uv/uv_hub.h
105 +@@ -329,7 +329,8 @@ static inline unsigned long uv_read_global_mmr64(int pnode, unsigned long offset
106 + */
107 + static inline unsigned long uv_global_gru_mmr_address(int pnode, unsigned long offset)
108 + {
109 +- return UV_GLOBAL_GRU_MMR_BASE | offset | (pnode << uv_hub_info->m_val);
110 ++ return UV_GLOBAL_GRU_MMR_BASE | offset |
111 ++ ((unsigned long)pnode << uv_hub_info->m_val);
112 + }
113 +
114 + static inline void uv_write_global_mmr8(int pnode, unsigned long offset, unsigned char val)
115 +diff --git a/arch/x86/include/asm/vmx.h b/arch/x86/include/asm/vmx.h
116 +index 2b49454..8f6b011 100644
117 +--- a/arch/x86/include/asm/vmx.h
118 ++++ b/arch/x86/include/asm/vmx.h
119 +@@ -251,6 +251,7 @@ enum vmcs_field {
120 + #define EXIT_REASON_MSR_READ 31
121 + #define EXIT_REASON_MSR_WRITE 32
122 + #define EXIT_REASON_MWAIT_INSTRUCTION 36
123 ++#define EXIT_REASON_MONITOR_INSTRUCTION 39
124 + #define EXIT_REASON_PAUSE_INSTRUCTION 40
125 + #define EXIT_REASON_MCE_DURING_VMENTRY 41
126 + #define EXIT_REASON_TPR_BELOW_THRESHOLD 43
127 +diff --git a/arch/x86/kernel/acpi/boot.c b/arch/x86/kernel/acpi/boot.c
128 +index af1c583..0a2b21a 100644
129 +--- a/arch/x86/kernel/acpi/boot.c
130 ++++ b/arch/x86/kernel/acpi/boot.c
131 +@@ -446,6 +446,12 @@ void __init acpi_pic_sci_set_trigger(unsigned int irq, u16 trigger)
132 + int acpi_gsi_to_irq(u32 gsi, unsigned int *irq)
133 + {
134 + *irq = gsi;
135 ++
136 ++#ifdef CONFIG_X86_IO_APIC
137 ++ if (acpi_irq_model == ACPI_IRQ_MODEL_IOAPIC)
138 ++ setup_IO_APIC_irq_extra(gsi);
139 ++#endif
140 ++
141 + return 0;
142 + }
143 +
144 +@@ -473,7 +479,8 @@ int acpi_register_gsi(struct device *dev, u32 gsi, int trigger, int polarity)
145 + plat_gsi = mp_register_gsi(dev, gsi, trigger, polarity);
146 + }
147 + #endif
148 +- acpi_gsi_to_irq(plat_gsi, &irq);
149 ++ irq = plat_gsi;
150 ++
151 + return irq;
152 + }
153 +
154 +diff --git a/arch/x86/kernel/apic/io_apic.c b/arch/x86/kernel/apic/io_apic.c
155 +index 53243ca..be37059 100644
156 +--- a/arch/x86/kernel/apic/io_apic.c
157 ++++ b/arch/x86/kernel/apic/io_apic.c
158 +@@ -1539,6 +1539,56 @@ static void __init setup_IO_APIC_irqs(void)
159 + }
160 +
161 + /*
162 ++ * for the gsit that is not in first ioapic
163 ++ * but could not use acpi_register_gsi()
164 ++ * like some special sci in IBM x3330
165 ++ */
166 ++void setup_IO_APIC_irq_extra(u32 gsi)
167 ++{
168 ++ int apic_id = 0, pin, idx, irq;
169 ++ int node = cpu_to_node(boot_cpu_id);
170 ++ struct irq_desc *desc;
171 ++ struct irq_cfg *cfg;
172 ++
173 ++ /*
174 ++ * Convert 'gsi' to 'ioapic.pin'.
175 ++ */
176 ++ apic_id = mp_find_ioapic(gsi);
177 ++ if (apic_id < 0)
178 ++ return;
179 ++
180 ++ pin = mp_find_ioapic_pin(apic_id, gsi);
181 ++ idx = find_irq_entry(apic_id, pin, mp_INT);
182 ++ if (idx == -1)
183 ++ return;
184 ++
185 ++ irq = pin_2_irq(idx, apic_id, pin);
186 ++#ifdef CONFIG_SPARSE_IRQ
187 ++ desc = irq_to_desc(irq);
188 ++ if (desc)
189 ++ return;
190 ++#endif
191 ++ desc = irq_to_desc_alloc_node(irq, node);
192 ++ if (!desc) {
193 ++ printk(KERN_INFO "can not get irq_desc for %d\n", irq);
194 ++ return;
195 ++ }
196 ++
197 ++ cfg = desc->chip_data;
198 ++ add_pin_to_irq_node(cfg, node, apic_id, pin);
199 ++
200 ++ if (test_bit(pin, mp_ioapic_routing[apic_id].pin_programmed)) {
201 ++ pr_debug("Pin %d-%d already programmed\n",
202 ++ mp_ioapics[apic_id].apicid, pin);
203 ++ return;
204 ++ }
205 ++ set_bit(pin, mp_ioapic_routing[apic_id].pin_programmed);
206 ++
207 ++ setup_IO_APIC_irq(apic_id, pin, irq, desc,
208 ++ irq_trigger(idx), irq_polarity(idx));
209 ++}
210 ++
211 ++/*
212 + * Set up the timer pin, possibly with the 8259A-master behind.
213 + */
214 + static void __init setup_timer_IRQ0_pin(unsigned int apic_id, unsigned int pin,
215 +@@ -3228,12 +3278,9 @@ unsigned int create_irq_nr(unsigned int irq_want, int node)
216 + }
217 + spin_unlock_irqrestore(&vector_lock, flags);
218 +
219 +- if (irq > 0) {
220 +- dynamic_irq_init(irq);
221 +- /* restore it, in case dynamic_irq_init clear it */
222 +- if (desc_new)
223 +- desc_new->chip_data = cfg_new;
224 +- }
225 ++ if (irq > 0)
226 ++ dynamic_irq_init_keep_chip_data(irq);
227 ++
228 + return irq;
229 + }
230 +
231 +@@ -3256,17 +3303,12 @@ void destroy_irq(unsigned int irq)
232 + {
233 + unsigned long flags;
234 + struct irq_cfg *cfg;
235 +- struct irq_desc *desc;
236 +
237 +- /* store it, in case dynamic_irq_cleanup clear it */
238 +- desc = irq_to_desc(irq);
239 +- cfg = desc->chip_data;
240 +- dynamic_irq_cleanup(irq);
241 +- /* connect back irq_cfg */
242 +- desc->chip_data = cfg;
243 ++ dynamic_irq_cleanup_keep_chip_data(irq);
244 +
245 + free_irte(irq);
246 + spin_lock_irqsave(&vector_lock, flags);
247 ++ cfg = irq_to_desc(irq)->chip_data;
248 + __clear_irq_vector(irq, cfg);
249 + spin_unlock_irqrestore(&vector_lock, flags);
250 + }
251 +diff --git a/arch/x86/kernel/reboot.c b/arch/x86/kernel/reboot.c
252 +index 704bddc..8e1aac8 100644
253 +--- a/arch/x86/kernel/reboot.c
254 ++++ b/arch/x86/kernel/reboot.c
255 +@@ -461,6 +461,14 @@ static struct dmi_system_id __initdata pci_reboot_dmi_table[] = {
256 + DMI_MATCH(DMI_PRODUCT_NAME, "Macmini3,1"),
257 + },
258 + },
259 ++ { /* Handle problems with rebooting on the iMac9,1. */
260 ++ .callback = set_pci_reboot,
261 ++ .ident = "Apple iMac9,1",
262 ++ .matches = {
263 ++ DMI_MATCH(DMI_SYS_VENDOR, "Apple Inc."),
264 ++ DMI_MATCH(DMI_PRODUCT_NAME, "iMac9,1"),
265 ++ },
266 ++ },
267 + { }
268 + };
269 +
270 +diff --git a/arch/x86/kvm/emulate.c b/arch/x86/kvm/emulate.c
271 +index 7e8faea..c998d27 100644
272 +--- a/arch/x86/kvm/emulate.c
273 ++++ b/arch/x86/kvm/emulate.c
274 +@@ -76,6 +76,7 @@
275 + #define GroupDual (1<<15) /* Alternate decoding of mod == 3 */
276 + #define GroupMask 0xff /* Group number stored in bits 0:7 */
277 + /* Misc flags */
278 ++#define Priv (1<<27) /* instruction generates #GP if current CPL != 0 */
279 + #define No64 (1<<28)
280 + /* Source 2 operand type */
281 + #define Src2None (0<<29)
282 +@@ -88,6 +89,7 @@
283 + enum {
284 + Group1_80, Group1_81, Group1_82, Group1_83,
285 + Group1A, Group3_Byte, Group3, Group4, Group5, Group7,
286 ++ Group8, Group9,
287 + };
288 +
289 + static u32 opcode_table[256] = {
290 +@@ -210,7 +212,7 @@ static u32 opcode_table[256] = {
291 + SrcNone | ByteOp | ImplicitOps, SrcNone | ImplicitOps,
292 + /* 0xF0 - 0xF7 */
293 + 0, 0, 0, 0,
294 +- ImplicitOps, ImplicitOps, Group | Group3_Byte, Group | Group3,
295 ++ ImplicitOps | Priv, ImplicitOps, Group | Group3_Byte, Group | Group3,
296 + /* 0xF8 - 0xFF */
297 + ImplicitOps, 0, ImplicitOps, ImplicitOps,
298 + ImplicitOps, ImplicitOps, Group | Group4, Group | Group5,
299 +@@ -218,16 +220,20 @@ static u32 opcode_table[256] = {
300 +
301 + static u32 twobyte_table[256] = {
302 + /* 0x00 - 0x0F */
303 +- 0, Group | GroupDual | Group7, 0, 0, 0, ImplicitOps, ImplicitOps, 0,
304 +- ImplicitOps, ImplicitOps, 0, 0, 0, ImplicitOps | ModRM, 0, 0,
305 ++ 0, Group | GroupDual | Group7, 0, 0,
306 ++ 0, ImplicitOps, ImplicitOps | Priv, 0,
307 ++ ImplicitOps | Priv, ImplicitOps | Priv, 0, 0,
308 ++ 0, ImplicitOps | ModRM, 0, 0,
309 + /* 0x10 - 0x1F */
310 + 0, 0, 0, 0, 0, 0, 0, 0, ImplicitOps | ModRM, 0, 0, 0, 0, 0, 0, 0,
311 + /* 0x20 - 0x2F */
312 +- ModRM | ImplicitOps, ModRM, ModRM | ImplicitOps, ModRM, 0, 0, 0, 0,
313 ++ ModRM | ImplicitOps | Priv, ModRM | Priv,
314 ++ ModRM | ImplicitOps | Priv, ModRM | Priv,
315 ++ 0, 0, 0, 0,
316 + 0, 0, 0, 0, 0, 0, 0, 0,
317 + /* 0x30 - 0x3F */
318 +- ImplicitOps, 0, ImplicitOps, 0,
319 +- ImplicitOps, ImplicitOps, 0, 0,
320 ++ ImplicitOps | Priv, 0, ImplicitOps | Priv, 0,
321 ++ ImplicitOps, ImplicitOps | Priv, 0, 0,
322 + 0, 0, 0, 0, 0, 0, 0, 0,
323 + /* 0x40 - 0x47 */
324 + DstReg | SrcMem | ModRM | Mov, DstReg | SrcMem | ModRM | Mov,
325 +@@ -267,11 +273,12 @@ static u32 twobyte_table[256] = {
326 + 0, 0, ByteOp | DstReg | SrcMem | ModRM | Mov,
327 + DstReg | SrcMem16 | ModRM | Mov,
328 + /* 0xB8 - 0xBF */
329 +- 0, 0, DstMem | SrcImmByte | ModRM, DstMem | SrcReg | ModRM | BitOp,
330 ++ 0, 0, Group | Group8, DstMem | SrcReg | ModRM | BitOp,
331 + 0, 0, ByteOp | DstReg | SrcMem | ModRM | Mov,
332 + DstReg | SrcMem16 | ModRM | Mov,
333 + /* 0xC0 - 0xCF */
334 +- 0, 0, 0, DstMem | SrcReg | ModRM | Mov, 0, 0, 0, ImplicitOps | ModRM,
335 ++ 0, 0, 0, DstMem | SrcReg | ModRM | Mov,
336 ++ 0, 0, 0, Group | GroupDual | Group9,
337 + 0, 0, 0, 0, 0, 0, 0, 0,
338 + /* 0xD0 - 0xDF */
339 + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
340 +@@ -320,16 +327,24 @@ static u32 group_table[] = {
341 + SrcMem | ModRM | Stack, 0,
342 + SrcMem | ModRM | Stack, 0, SrcMem | ModRM | Stack, 0,
343 + [Group7*8] =
344 +- 0, 0, ModRM | SrcMem, ModRM | SrcMem,
345 ++ 0, 0, ModRM | SrcMem | Priv, ModRM | SrcMem | Priv,
346 + SrcNone | ModRM | DstMem | Mov, 0,
347 +- SrcMem16 | ModRM | Mov, SrcMem | ModRM | ByteOp,
348 ++ SrcMem16 | ModRM | Mov | Priv, SrcMem | ModRM | ByteOp | Priv,
349 ++ [Group8*8] =
350 ++ 0, 0, 0, 0,
351 ++ DstMem | SrcImmByte | ModRM, DstMem | SrcImmByte | ModRM,
352 ++ DstMem | SrcImmByte | ModRM, DstMem | SrcImmByte | ModRM,
353 ++ [Group9*8] =
354 ++ 0, ImplicitOps | ModRM, 0, 0, 0, 0, 0, 0,
355 + };
356 +
357 + static u32 group2_table[] = {
358 + [Group7*8] =
359 +- SrcNone | ModRM, 0, 0, SrcNone | ModRM,
360 ++ SrcNone | ModRM | Priv, 0, 0, SrcNone | ModRM,
361 + SrcNone | ModRM | DstMem | Mov, 0,
362 + SrcMem16 | ModRM | Mov, 0,
363 ++ [Group9*8] =
364 ++ 0, 0, 0, 0, 0, 0, 0, 0,
365 + };
366 +
367 + /* EFLAGS bit definitions. */
368 +@@ -1640,12 +1655,6 @@ emulate_sysexit(struct x86_emulate_ctxt *ctxt)
369 + return -1;
370 + }
371 +
372 +- /* sysexit must be called from CPL 0 */
373 +- if (kvm_x86_ops->get_cpl(ctxt->vcpu) != 0) {
374 +- kvm_inject_gp(ctxt->vcpu, 0);
375 +- return -1;
376 +- }
377 +-
378 + setup_syscalls_segments(ctxt, &cs, &ss);
379 +
380 + if ((c->rex_prefix & 0x8) != 0x0)
381 +@@ -1709,6 +1718,12 @@ x86_emulate_insn(struct x86_emulate_ctxt *ctxt, struct x86_emulate_ops *ops)
382 + memcpy(c->regs, ctxt->vcpu->arch.regs, sizeof c->regs);
383 + saved_eip = c->eip;
384 +
385 ++ /* Privileged instruction can be executed only in CPL=0 */
386 ++ if ((c->d & Priv) && kvm_x86_ops->get_cpl(ctxt->vcpu)) {
387 ++ kvm_inject_gp(ctxt->vcpu, 0);
388 ++ goto done;
389 ++ }
390 ++
391 + if (((c->d & ModRM) && (c->modrm_mod != 3)) || (c->d & MemAbs))
392 + memop = c->modrm_ea;
393 +
394 +@@ -1982,6 +1997,12 @@ special_insn:
395 + int err;
396 +
397 + sel = c->src.val;
398 ++
399 ++ if (c->modrm_reg == VCPU_SREG_CS) {
400 ++ kvm_queue_exception(ctxt->vcpu, UD_VECTOR);
401 ++ goto done;
402 ++ }
403 ++
404 + if (c->modrm_reg == VCPU_SREG_SS)
405 + toggle_interruptibility(ctxt, X86_SHADOW_INT_MOV_SS);
406 +
407 +diff --git a/arch/x86/kvm/vmx.c b/arch/x86/kvm/vmx.c
408 +index d4918d6..8a8e139 100644
409 +--- a/arch/x86/kvm/vmx.c
410 ++++ b/arch/x86/kvm/vmx.c
411 +@@ -1224,6 +1224,8 @@ static __init int setup_vmcs_config(struct vmcs_config *vmcs_conf)
412 + CPU_BASED_USE_IO_BITMAPS |
413 + CPU_BASED_MOV_DR_EXITING |
414 + CPU_BASED_USE_TSC_OFFSETING |
415 ++ CPU_BASED_MWAIT_EXITING |
416 ++ CPU_BASED_MONITOR_EXITING |
417 + CPU_BASED_INVLPG_EXITING;
418 + opt = CPU_BASED_TPR_SHADOW |
419 + CPU_BASED_USE_MSR_BITMAPS |
420 +@@ -3416,6 +3418,12 @@ static int handle_pause(struct kvm_vcpu *vcpu)
421 + return 1;
422 + }
423 +
424 ++static int handle_invalid_op(struct kvm_vcpu *vcpu)
425 ++{
426 ++ kvm_queue_exception(vcpu, UD_VECTOR);
427 ++ return 1;
428 ++}
429 ++
430 + /*
431 + * The exit handlers return 1 if the exit was handled fully and guest execution
432 + * may resume. Otherwise they set the kvm_run parameter to indicate what needs
433 +@@ -3453,6 +3461,8 @@ static int (*kvm_vmx_exit_handlers[])(struct kvm_vcpu *vcpu) = {
434 + [EXIT_REASON_EPT_VIOLATION] = handle_ept_violation,
435 + [EXIT_REASON_EPT_MISCONFIG] = handle_ept_misconfig,
436 + [EXIT_REASON_PAUSE_INSTRUCTION] = handle_pause,
437 ++ [EXIT_REASON_MWAIT_INSTRUCTION] = handle_invalid_op,
438 ++ [EXIT_REASON_MONITOR_INSTRUCTION] = handle_invalid_op,
439 + };
440 +
441 + static const int kvm_vmx_max_exit_handlers =
442 +diff --git a/arch/x86/mm/pgtable.c b/arch/x86/mm/pgtable.c
443 +index ed34f5e..c9ba9de 100644
444 +--- a/arch/x86/mm/pgtable.c
445 ++++ b/arch/x86/mm/pgtable.c
446 +@@ -6,6 +6,14 @@
447 +
448 + #define PGALLOC_GFP GFP_KERNEL | __GFP_NOTRACK | __GFP_REPEAT | __GFP_ZERO
449 +
450 ++#ifdef CONFIG_HIGHPTE
451 ++#define PGALLOC_USER_GFP __GFP_HIGHMEM
452 ++#else
453 ++#define PGALLOC_USER_GFP 0
454 ++#endif
455 ++
456 ++gfp_t __userpte_alloc_gfp = PGALLOC_GFP | PGALLOC_USER_GFP;
457 ++
458 + pte_t *pte_alloc_one_kernel(struct mm_struct *mm, unsigned long address)
459 + {
460 + return (pte_t *)__get_free_page(PGALLOC_GFP);
461 +@@ -15,16 +23,29 @@ pgtable_t pte_alloc_one(struct mm_struct *mm, unsigned long address)
462 + {
463 + struct page *pte;
464 +
465 +-#ifdef CONFIG_HIGHPTE
466 +- pte = alloc_pages(PGALLOC_GFP | __GFP_HIGHMEM, 0);
467 +-#else
468 +- pte = alloc_pages(PGALLOC_GFP, 0);
469 +-#endif
470 ++ pte = alloc_pages(__userpte_alloc_gfp, 0);
471 + if (pte)
472 + pgtable_page_ctor(pte);
473 + return pte;
474 + }
475 +
476 ++static int __init setup_userpte(char *arg)
477 ++{
478 ++ if (!arg)
479 ++ return -EINVAL;
480 ++
481 ++ /*
482 ++ * "userpte=nohigh" disables allocation of user pagetables in
483 ++ * high memory.
484 ++ */
485 ++ if (strcmp(arg, "nohigh") == 0)
486 ++ __userpte_alloc_gfp &= ~__GFP_HIGHMEM;
487 ++ else
488 ++ return -EINVAL;
489 ++ return 0;
490 ++}
491 ++early_param("userpte", setup_userpte);
492 ++
493 + void ___pte_free_tlb(struct mmu_gather *tlb, struct page *pte)
494 + {
495 + pgtable_page_dtor(pte);
496 +diff --git a/arch/x86/oprofile/nmi_int.c b/arch/x86/oprofile/nmi_int.c
497 +index 3347f69..2c505ee 100644
498 +--- a/arch/x86/oprofile/nmi_int.c
499 ++++ b/arch/x86/oprofile/nmi_int.c
500 +@@ -159,7 +159,7 @@ static int nmi_setup_mux(void)
501 +
502 + for_each_possible_cpu(i) {
503 + per_cpu(cpu_msrs, i).multiplex =
504 +- kmalloc(multiplex_size, GFP_KERNEL);
505 ++ kzalloc(multiplex_size, GFP_KERNEL);
506 + if (!per_cpu(cpu_msrs, i).multiplex)
507 + return 0;
508 + }
509 +@@ -179,7 +179,6 @@ static void nmi_cpu_setup_mux(int cpu, struct op_msrs const * const msrs)
510 + if (counter_config[i].enabled) {
511 + multiplex[i].saved = -(u64)counter_config[i].count;
512 + } else {
513 +- multiplex[i].addr = 0;
514 + multiplex[i].saved = 0;
515 + }
516 + }
517 +@@ -189,25 +188,27 @@ static void nmi_cpu_setup_mux(int cpu, struct op_msrs const * const msrs)
518 +
519 + static void nmi_cpu_save_mpx_registers(struct op_msrs *msrs)
520 + {
521 ++ struct op_msr *counters = msrs->counters;
522 + struct op_msr *multiplex = msrs->multiplex;
523 + int i;
524 +
525 + for (i = 0; i < model->num_counters; ++i) {
526 + int virt = op_x86_phys_to_virt(i);
527 +- if (multiplex[virt].addr)
528 +- rdmsrl(multiplex[virt].addr, multiplex[virt].saved);
529 ++ if (counters[i].addr)
530 ++ rdmsrl(counters[i].addr, multiplex[virt].saved);
531 + }
532 + }
533 +
534 + static void nmi_cpu_restore_mpx_registers(struct op_msrs *msrs)
535 + {
536 ++ struct op_msr *counters = msrs->counters;
537 + struct op_msr *multiplex = msrs->multiplex;
538 + int i;
539 +
540 + for (i = 0; i < model->num_counters; ++i) {
541 + int virt = op_x86_phys_to_virt(i);
542 +- if (multiplex[virt].addr)
543 +- wrmsrl(multiplex[virt].addr, multiplex[virt].saved);
544 ++ if (counters[i].addr)
545 ++ wrmsrl(counters[i].addr, multiplex[virt].saved);
546 + }
547 + }
548 +
549 +@@ -303,11 +304,11 @@ static int allocate_msrs(void)
550 +
551 + int i;
552 + for_each_possible_cpu(i) {
553 +- per_cpu(cpu_msrs, i).counters = kmalloc(counters_size,
554 ++ per_cpu(cpu_msrs, i).counters = kzalloc(counters_size,
555 + GFP_KERNEL);
556 + if (!per_cpu(cpu_msrs, i).counters)
557 + return 0;
558 +- per_cpu(cpu_msrs, i).controls = kmalloc(controls_size,
559 ++ per_cpu(cpu_msrs, i).controls = kzalloc(controls_size,
560 + GFP_KERNEL);
561 + if (!per_cpu(cpu_msrs, i).controls)
562 + return 0;
563 +diff --git a/arch/x86/oprofile/op_model_amd.c b/arch/x86/oprofile/op_model_amd.c
564 +index 39686c2..1ed963d 100644
565 +--- a/arch/x86/oprofile/op_model_amd.c
566 ++++ b/arch/x86/oprofile/op_model_amd.c
567 +@@ -76,19 +76,6 @@ static struct op_ibs_config ibs_config;
568 +
569 + #ifdef CONFIG_OPROFILE_EVENT_MULTIPLEX
570 +
571 +-static void op_mux_fill_in_addresses(struct op_msrs * const msrs)
572 +-{
573 +- int i;
574 +-
575 +- for (i = 0; i < NUM_VIRT_COUNTERS; i++) {
576 +- int hw_counter = op_x86_virt_to_phys(i);
577 +- if (reserve_perfctr_nmi(MSR_K7_PERFCTR0 + i))
578 +- msrs->multiplex[i].addr = MSR_K7_PERFCTR0 + hw_counter;
579 +- else
580 +- msrs->multiplex[i].addr = 0;
581 +- }
582 +-}
583 +-
584 + static void op_mux_switch_ctrl(struct op_x86_model_spec const *model,
585 + struct op_msrs const * const msrs)
586 + {
587 +@@ -98,7 +85,7 @@ static void op_mux_switch_ctrl(struct op_x86_model_spec const *model,
588 + /* enable active counters */
589 + for (i = 0; i < NUM_COUNTERS; ++i) {
590 + int virt = op_x86_phys_to_virt(i);
591 +- if (!counter_config[virt].enabled)
592 ++ if (!reset_value[virt])
593 + continue;
594 + rdmsrl(msrs->controls[i].addr, val);
595 + val &= model->reserved;
596 +@@ -107,10 +94,6 @@ static void op_mux_switch_ctrl(struct op_x86_model_spec const *model,
597 + }
598 + }
599 +
600 +-#else
601 +-
602 +-static inline void op_mux_fill_in_addresses(struct op_msrs * const msrs) { }
603 +-
604 + #endif
605 +
606 + /* functions for op_amd_spec */
607 +@@ -122,18 +105,12 @@ static void op_amd_fill_in_addresses(struct op_msrs * const msrs)
608 + for (i = 0; i < NUM_COUNTERS; i++) {
609 + if (reserve_perfctr_nmi(MSR_K7_PERFCTR0 + i))
610 + msrs->counters[i].addr = MSR_K7_PERFCTR0 + i;
611 +- else
612 +- msrs->counters[i].addr = 0;
613 + }
614 +
615 + for (i = 0; i < NUM_CONTROLS; i++) {
616 + if (reserve_evntsel_nmi(MSR_K7_EVNTSEL0 + i))
617 + msrs->controls[i].addr = MSR_K7_EVNTSEL0 + i;
618 +- else
619 +- msrs->controls[i].addr = 0;
620 + }
621 +-
622 +- op_mux_fill_in_addresses(msrs);
623 + }
624 +
625 + static void op_amd_setup_ctrs(struct op_x86_model_spec const *model,
626 +@@ -144,7 +121,8 @@ static void op_amd_setup_ctrs(struct op_x86_model_spec const *model,
627 +
628 + /* setup reset_value */
629 + for (i = 0; i < NUM_VIRT_COUNTERS; ++i) {
630 +- if (counter_config[i].enabled)
631 ++ if (counter_config[i].enabled
632 ++ && msrs->counters[op_x86_virt_to_phys(i)].addr)
633 + reset_value[i] = counter_config[i].count;
634 + else
635 + reset_value[i] = 0;
636 +@@ -169,9 +147,7 @@ static void op_amd_setup_ctrs(struct op_x86_model_spec const *model,
637 + /* enable active counters */
638 + for (i = 0; i < NUM_COUNTERS; ++i) {
639 + int virt = op_x86_phys_to_virt(i);
640 +- if (!counter_config[virt].enabled)
641 +- continue;
642 +- if (!msrs->counters[i].addr)
643 ++ if (!reset_value[virt])
644 + continue;
645 +
646 + /* setup counter registers */
647 +@@ -405,16 +381,6 @@ static int init_ibs_nmi(void)
648 + return 1;
649 + }
650 +
651 +-#ifdef CONFIG_NUMA
652 +- /* Sanity check */
653 +- /* Works only for 64bit with proper numa implementation. */
654 +- if (nodes != num_possible_nodes()) {
655 +- printk(KERN_DEBUG "Failed to setup CPU node(s) for IBS, "
656 +- "found: %d, expected %d",
657 +- nodes, num_possible_nodes());
658 +- return 1;
659 +- }
660 +-#endif
661 + return 0;
662 + }
663 +
664 +diff --git a/arch/x86/oprofile/op_model_p4.c b/arch/x86/oprofile/op_model_p4.c
665 +index ac6b354..e6a160a 100644
666 +--- a/arch/x86/oprofile/op_model_p4.c
667 ++++ b/arch/x86/oprofile/op_model_p4.c
668 +@@ -394,12 +394,6 @@ static void p4_fill_in_addresses(struct op_msrs * const msrs)
669 + setup_num_counters();
670 + stag = get_stagger();
671 +
672 +- /* initialize some registers */
673 +- for (i = 0; i < num_counters; ++i)
674 +- msrs->counters[i].addr = 0;
675 +- for (i = 0; i < num_controls; ++i)
676 +- msrs->controls[i].addr = 0;
677 +-
678 + /* the counter & cccr registers we pay attention to */
679 + for (i = 0; i < num_counters; ++i) {
680 + addr = p4_counters[VIRT_CTR(stag, i)].counter_address;
681 +diff --git a/arch/x86/oprofile/op_model_ppro.c b/arch/x86/oprofile/op_model_ppro.c
682 +index 8eb0587..2873c00 100644
683 +--- a/arch/x86/oprofile/op_model_ppro.c
684 ++++ b/arch/x86/oprofile/op_model_ppro.c
685 +@@ -37,15 +37,11 @@ static void ppro_fill_in_addresses(struct op_msrs * const msrs)
686 + for (i = 0; i < num_counters; i++) {
687 + if (reserve_perfctr_nmi(MSR_P6_PERFCTR0 + i))
688 + msrs->counters[i].addr = MSR_P6_PERFCTR0 + i;
689 +- else
690 +- msrs->counters[i].addr = 0;
691 + }
692 +
693 + for (i = 0; i < num_counters; i++) {
694 + if (reserve_evntsel_nmi(MSR_P6_EVNTSEL0 + i))
695 + msrs->controls[i].addr = MSR_P6_EVNTSEL0 + i;
696 +- else
697 +- msrs->controls[i].addr = 0;
698 + }
699 + }
700 +
701 +@@ -57,7 +53,7 @@ static void ppro_setup_ctrs(struct op_x86_model_spec const *model,
702 + int i;
703 +
704 + if (!reset_value) {
705 +- reset_value = kmalloc(sizeof(reset_value[0]) * num_counters,
706 ++ reset_value = kzalloc(sizeof(reset_value[0]) * num_counters,
707 + GFP_ATOMIC);
708 + if (!reset_value)
709 + return;
710 +diff --git a/arch/x86/pci/mmconfig-shared.c b/arch/x86/pci/mmconfig-shared.c
711 +index b19d1e5..8f3f9a5 100644
712 +--- a/arch/x86/pci/mmconfig-shared.c
713 ++++ b/arch/x86/pci/mmconfig-shared.c
714 +@@ -303,22 +303,17 @@ static void __init pci_mmcfg_check_end_bus_number(void)
715 + {
716 + struct pci_mmcfg_region *cfg, *cfgx;
717 +
718 +- /* last one*/
719 +- cfg = list_entry(pci_mmcfg_list.prev, typeof(*cfg), list);
720 +- if (cfg)
721 +- if (cfg->end_bus < cfg->start_bus)
722 +- cfg->end_bus = 255;
723 +-
724 +- if (list_is_singular(&pci_mmcfg_list))
725 +- return;
726 +-
727 +- /* don't overlap please */
728 ++ /* Fixup overlaps */
729 + list_for_each_entry(cfg, &pci_mmcfg_list, list) {
730 + if (cfg->end_bus < cfg->start_bus)
731 + cfg->end_bus = 255;
732 +
733 ++ /* Don't access the list head ! */
734 ++ if (cfg->list.next == &pci_mmcfg_list)
735 ++ break;
736 ++
737 + cfgx = list_entry(cfg->list.next, typeof(*cfg), list);
738 +- if (cfg != cfgx && cfg->end_bus >= cfgx->start_bus)
739 ++ if (cfg->end_bus >= cfgx->start_bus)
740 + cfg->end_bus = cfgx->start_bus - 1;
741 + }
742 + }
743 +diff --git a/arch/x86/xen/enlighten.c b/arch/x86/xen/enlighten.c
744 +index 36daccb..b607239 100644
745 +--- a/arch/x86/xen/enlighten.c
746 ++++ b/arch/x86/xen/enlighten.c
747 +@@ -50,6 +50,7 @@
748 + #include <asm/traps.h>
749 + #include <asm/setup.h>
750 + #include <asm/desc.h>
751 ++#include <asm/pgalloc.h>
752 + #include <asm/pgtable.h>
753 + #include <asm/tlbflush.h>
754 + #include <asm/reboot.h>
755 +@@ -1094,6 +1095,12 @@ asmlinkage void __init xen_start_kernel(void)
756 +
757 + __supported_pte_mask |= _PAGE_IOMAP;
758 +
759 ++ /*
760 ++ * Prevent page tables from being allocated in highmem, even
761 ++ * if CONFIG_HIGHPTE is enabled.
762 ++ */
763 ++ __userpte_alloc_gfp &= ~__GFP_HIGHMEM;
764 ++
765 + /* Work out if we support NX */
766 + x86_configure_nx();
767 +
768 +diff --git a/arch/x86/xen/mmu.c b/arch/x86/xen/mmu.c
769 +index bf4cd6b..350a3de 100644
770 +--- a/arch/x86/xen/mmu.c
771 ++++ b/arch/x86/xen/mmu.c
772 +@@ -1432,14 +1432,15 @@ static void *xen_kmap_atomic_pte(struct page *page, enum km_type type)
773 + {
774 + pgprot_t prot = PAGE_KERNEL;
775 +
776 ++ /*
777 ++ * We disable highmem allocations for page tables so we should never
778 ++ * see any calls to kmap_atomic_pte on a highmem page.
779 ++ */
780 ++ BUG_ON(PageHighMem(page));
781 ++
782 + if (PagePinned(page))
783 + prot = PAGE_KERNEL_RO;
784 +
785 +- if (0 && PageHighMem(page))
786 +- printk("mapping highpte %lx type %d prot %s\n",
787 +- page_to_pfn(page), type,
788 +- (unsigned long)pgprot_val(prot) & _PAGE_RW ? "WRITE" : "READ");
789 +-
790 + return kmap_atomic_prot(page, type, prot);
791 + }
792 + #endif
793 +diff --git a/drivers/ata/ahci.c b/drivers/ata/ahci.c
794 +index b343903..a6a736a 100644
795 +--- a/drivers/ata/ahci.c
796 ++++ b/drivers/ata/ahci.c
797 +@@ -3082,8 +3082,16 @@ static int ahci_init_one(struct pci_dev *pdev, const struct pci_device_id *ent)
798 + ahci_save_initial_config(pdev, hpriv);
799 +
800 + /* prepare host */
801 +- if (hpriv->cap & HOST_CAP_NCQ)
802 +- pi.flags |= ATA_FLAG_NCQ | ATA_FLAG_FPDMA_AA;
803 ++ if (hpriv->cap & HOST_CAP_NCQ) {
804 ++ pi.flags |= ATA_FLAG_NCQ;
805 ++ /* Auto-activate optimization is supposed to be supported on
806 ++ all AHCI controllers indicating NCQ support, but it seems
807 ++ to be broken at least on some NVIDIA MCP79 chipsets.
808 ++ Until we get info on which NVIDIA chipsets don't have this
809 ++ issue, if any, disable AA on all NVIDIA AHCIs. */
810 ++ if (pdev->vendor != PCI_VENDOR_ID_NVIDIA)
811 ++ pi.flags |= ATA_FLAG_FPDMA_AA;
812 ++ }
813 +
814 + if (hpriv->cap & HOST_CAP_PMP)
815 + pi.flags |= ATA_FLAG_PMP;
816 +diff --git a/drivers/ata/pata_hpt3x2n.c b/drivers/ata/pata_hpt3x2n.c
817 +index dd26bc7..269b5db 100644
818 +--- a/drivers/ata/pata_hpt3x2n.c
819 ++++ b/drivers/ata/pata_hpt3x2n.c
820 +@@ -25,7 +25,7 @@
821 + #include <linux/libata.h>
822 +
823 + #define DRV_NAME "pata_hpt3x2n"
824 +-#define DRV_VERSION "0.3.8"
825 ++#define DRV_VERSION "0.3.9"
826 +
827 + enum {
828 + HPT_PCI_FAST = (1 << 31),
829 +@@ -544,16 +544,16 @@ static int hpt3x2n_init_one(struct pci_dev *dev, const struct pci_device_id *id)
830 + pci_mhz);
831 + /* Set our private data up. We only need a few flags so we use
832 + it directly */
833 +- if (pci_mhz > 60) {
834 ++ if (pci_mhz > 60)
835 + hpriv = (void *)(PCI66 | USE_DPLL);
836 +- /*
837 +- * On HPT371N, if ATA clock is 66 MHz we must set bit 2 in
838 +- * the MISC. register to stretch the UltraDMA Tss timing.
839 +- * NOTE: This register is only writeable via I/O space.
840 +- */
841 +- if (dev->device == PCI_DEVICE_ID_TTI_HPT371)
842 +- outb(inb(iobase + 0x9c) | 0x04, iobase + 0x9c);
843 +- }
844 ++
845 ++ /*
846 ++ * On HPT371N, if ATA clock is 66 MHz we must set bit 2 in
847 ++ * the MISC. register to stretch the UltraDMA Tss timing.
848 ++ * NOTE: This register is only writeable via I/O space.
849 ++ */
850 ++ if (dev->device == PCI_DEVICE_ID_TTI_HPT371)
851 ++ outb(inb(iobase + 0x9c) | 0x04, iobase + 0x9c);
852 +
853 + /* Now kick off ATA set up */
854 + return ata_pci_sff_init_one(dev, ppi, &hpt3x2n_sht, hpriv);
855 +diff --git a/drivers/base/core.c b/drivers/base/core.c
856 +index 2820257..fb4bc4f 100644
857 +--- a/drivers/base/core.c
858 ++++ b/drivers/base/core.c
859 +@@ -607,6 +607,7 @@ static struct kobject *get_device_parent(struct device *dev,
860 + int retval;
861 +
862 + if (dev->class) {
863 ++ static DEFINE_MUTEX(gdp_mutex);
864 + struct kobject *kobj = NULL;
865 + struct kobject *parent_kobj;
866 + struct kobject *k;
867 +@@ -623,6 +624,8 @@ static struct kobject *get_device_parent(struct device *dev,
868 + else
869 + parent_kobj = &parent->kobj;
870 +
871 ++ mutex_lock(&gdp_mutex);
872 ++
873 + /* find our class-directory at the parent and reference it */
874 + spin_lock(&dev->class->p->class_dirs.list_lock);
875 + list_for_each_entry(k, &dev->class->p->class_dirs.list, entry)
876 +@@ -631,20 +634,26 @@ static struct kobject *get_device_parent(struct device *dev,
877 + break;
878 + }
879 + spin_unlock(&dev->class->p->class_dirs.list_lock);
880 +- if (kobj)
881 ++ if (kobj) {
882 ++ mutex_unlock(&gdp_mutex);
883 + return kobj;
884 ++ }
885 +
886 + /* or create a new class-directory at the parent device */
887 + k = kobject_create();
888 +- if (!k)
889 ++ if (!k) {
890 ++ mutex_unlock(&gdp_mutex);
891 + return NULL;
892 ++ }
893 + k->kset = &dev->class->p->class_dirs;
894 + retval = kobject_add(k, parent_kobj, "%s", dev->class->name);
895 + if (retval < 0) {
896 ++ mutex_unlock(&gdp_mutex);
897 + kobject_put(k);
898 + return NULL;
899 + }
900 + /* do not emit an uevent for this simple "glue" directory */
901 ++ mutex_unlock(&gdp_mutex);
902 + return k;
903 + }
904 +
905 +diff --git a/drivers/base/devtmpfs.c b/drivers/base/devtmpfs.c
906 +index 42ae452..dac478c 100644
907 +--- a/drivers/base/devtmpfs.c
908 ++++ b/drivers/base/devtmpfs.c
909 +@@ -301,6 +301,19 @@ int devtmpfs_delete_node(struct device *dev)
910 + if (dentry->d_inode) {
911 + err = vfs_getattr(nd.path.mnt, dentry, &stat);
912 + if (!err && dev_mynode(dev, dentry->d_inode, &stat)) {
913 ++ struct iattr newattrs;
914 ++ /*
915 ++ * before unlinking this node, reset permissions
916 ++ * of possible references like hardlinks
917 ++ */
918 ++ newattrs.ia_uid = 0;
919 ++ newattrs.ia_gid = 0;
920 ++ newattrs.ia_mode = stat.mode & ~0777;
921 ++ newattrs.ia_valid =
922 ++ ATTR_UID|ATTR_GID|ATTR_MODE;
923 ++ mutex_lock(&dentry->d_inode->i_mutex);
924 ++ notify_change(dentry, &newattrs);
925 ++ mutex_unlock(&dentry->d_inode->i_mutex);
926 + err = vfs_unlink(nd.path.dentry->d_inode,
927 + dentry);
928 + if (!err || err == -ENOENT)
929 +diff --git a/drivers/char/tty_ldisc.c b/drivers/char/tty_ldisc.c
930 +index 3f653f7..500e740 100644
931 +--- a/drivers/char/tty_ldisc.c
932 ++++ b/drivers/char/tty_ldisc.c
933 +@@ -706,12 +706,13 @@ static void tty_reset_termios(struct tty_struct *tty)
934 + /**
935 + * tty_ldisc_reinit - reinitialise the tty ldisc
936 + * @tty: tty to reinit
937 ++ * @ldisc: line discipline to reinitialize
938 + *
939 +- * Switch the tty back to N_TTY line discipline and leave the
940 +- * ldisc state closed
941 ++ * Switch the tty to a line discipline and leave the ldisc
942 ++ * state closed
943 + */
944 +
945 +-static void tty_ldisc_reinit(struct tty_struct *tty)
946 ++static void tty_ldisc_reinit(struct tty_struct *tty, int ldisc)
947 + {
948 + struct tty_ldisc *ld;
949 +
950 +@@ -721,10 +722,10 @@ static void tty_ldisc_reinit(struct tty_struct *tty)
951 + /*
952 + * Switch the line discipline back
953 + */
954 +- ld = tty_ldisc_get(N_TTY);
955 ++ ld = tty_ldisc_get(ldisc);
956 + BUG_ON(IS_ERR(ld));
957 + tty_ldisc_assign(tty, ld);
958 +- tty_set_termios_ldisc(tty, N_TTY);
959 ++ tty_set_termios_ldisc(tty, ldisc);
960 + }
961 +
962 + /**
963 +@@ -745,6 +746,8 @@ static void tty_ldisc_reinit(struct tty_struct *tty)
964 + void tty_ldisc_hangup(struct tty_struct *tty)
965 + {
966 + struct tty_ldisc *ld;
967 ++ int reset = tty->driver->flags & TTY_DRIVER_RESET_TERMIOS;
968 ++ int err = 0;
969 +
970 + /*
971 + * FIXME! What are the locking issues here? This may me overdoing
972 +@@ -772,25 +775,32 @@ void tty_ldisc_hangup(struct tty_struct *tty)
973 + wake_up_interruptible_poll(&tty->read_wait, POLLIN);
974 + /*
975 + * Shutdown the current line discipline, and reset it to
976 +- * N_TTY.
977 ++ * N_TTY if need be.
978 ++ *
979 ++ * Avoid racing set_ldisc or tty_ldisc_release
980 + */
981 +- if (tty->driver->flags & TTY_DRIVER_RESET_TERMIOS) {
982 +- /* Avoid racing set_ldisc or tty_ldisc_release */
983 +- mutex_lock(&tty->ldisc_mutex);
984 +- tty_ldisc_halt(tty);
985 +- if (tty->ldisc) { /* Not yet closed */
986 +- /* Switch back to N_TTY */
987 +- tty_ldisc_reinit(tty);
988 +- /* At this point we have a closed ldisc and we want to
989 +- reopen it. We could defer this to the next open but
990 +- it means auditing a lot of other paths so this is
991 +- a FIXME */
992 ++ mutex_lock(&tty->ldisc_mutex);
993 ++ tty_ldisc_halt(tty);
994 ++ /* At this point we have a closed ldisc and we want to
995 ++ reopen it. We could defer this to the next open but
996 ++ it means auditing a lot of other paths so this is
997 ++ a FIXME */
998 ++ if (tty->ldisc) { /* Not yet closed */
999 ++ if (reset == 0) {
1000 ++ tty_ldisc_reinit(tty, tty->termios->c_line);
1001 ++ err = tty_ldisc_open(tty, tty->ldisc);
1002 ++ }
1003 ++ /* If the re-open fails or we reset then go to N_TTY. The
1004 ++ N_TTY open cannot fail */
1005 ++ if (reset || err) {
1006 ++ tty_ldisc_reinit(tty, N_TTY);
1007 + WARN_ON(tty_ldisc_open(tty, tty->ldisc));
1008 +- tty_ldisc_enable(tty);
1009 + }
1010 +- mutex_unlock(&tty->ldisc_mutex);
1011 +- tty_reset_termios(tty);
1012 ++ tty_ldisc_enable(tty);
1013 + }
1014 ++ mutex_unlock(&tty->ldisc_mutex);
1015 ++ if (reset)
1016 ++ tty_reset_termios(tty);
1017 + }
1018 +
1019 + /**
1020 +diff --git a/drivers/clocksource/sh_cmt.c b/drivers/clocksource/sh_cmt.c
1021 +index 6b3e0c2..6fe4f77 100644
1022 +--- a/drivers/clocksource/sh_cmt.c
1023 ++++ b/drivers/clocksource/sh_cmt.c
1024 +@@ -603,18 +603,13 @@ static int sh_cmt_setup(struct sh_cmt_priv *p, struct platform_device *pdev)
1025 + p->irqaction.handler = sh_cmt_interrupt;
1026 + p->irqaction.dev_id = p;
1027 + p->irqaction.flags = IRQF_DISABLED | IRQF_TIMER | IRQF_IRQPOLL;
1028 +- ret = setup_irq(irq, &p->irqaction);
1029 +- if (ret) {
1030 +- pr_err("sh_cmt: failed to request irq %d\n", irq);
1031 +- goto err1;
1032 +- }
1033 +
1034 + /* get hold of clock */
1035 + p->clk = clk_get(&p->pdev->dev, cfg->clk);
1036 + if (IS_ERR(p->clk)) {
1037 + pr_err("sh_cmt: cannot get clock \"%s\"\n", cfg->clk);
1038 + ret = PTR_ERR(p->clk);
1039 +- goto err2;
1040 ++ goto err1;
1041 + }
1042 +
1043 + if (resource_size(res) == 6) {
1044 +@@ -627,14 +622,25 @@ static int sh_cmt_setup(struct sh_cmt_priv *p, struct platform_device *pdev)
1045 + p->clear_bits = ~0xc000;
1046 + }
1047 +
1048 +- return sh_cmt_register(p, cfg->name,
1049 +- cfg->clockevent_rating,
1050 +- cfg->clocksource_rating);
1051 +- err2:
1052 +- remove_irq(irq, &p->irqaction);
1053 +- err1:
1054 ++ ret = sh_cmt_register(p, cfg->name,
1055 ++ cfg->clockevent_rating,
1056 ++ cfg->clocksource_rating);
1057 ++ if (ret) {
1058 ++ pr_err("sh_cmt: registration failed\n");
1059 ++ goto err1;
1060 ++ }
1061 ++
1062 ++ ret = setup_irq(irq, &p->irqaction);
1063 ++ if (ret) {
1064 ++ pr_err("sh_cmt: failed to request irq %d\n", irq);
1065 ++ goto err1;
1066 ++ }
1067 ++
1068 ++ return 0;
1069 ++
1070 ++err1:
1071 + iounmap(p->mapbase);
1072 +- err0:
1073 ++err0:
1074 + return ret;
1075 + }
1076 +
1077 +diff --git a/drivers/clocksource/sh_mtu2.c b/drivers/clocksource/sh_mtu2.c
1078 +index 973e714..4c8a759 100644
1079 +--- a/drivers/clocksource/sh_mtu2.c
1080 ++++ b/drivers/clocksource/sh_mtu2.c
1081 +@@ -221,15 +221,15 @@ static void sh_mtu2_register_clockevent(struct sh_mtu2_priv *p,
1082 + ced->cpumask = cpumask_of(0);
1083 + ced->set_mode = sh_mtu2_clock_event_mode;
1084 +
1085 ++ pr_info("sh_mtu2: %s used for clock events\n", ced->name);
1086 ++ clockevents_register_device(ced);
1087 ++
1088 + ret = setup_irq(p->irqaction.irq, &p->irqaction);
1089 + if (ret) {
1090 + pr_err("sh_mtu2: failed to request irq %d\n",
1091 + p->irqaction.irq);
1092 + return;
1093 + }
1094 +-
1095 +- pr_info("sh_mtu2: %s used for clock events\n", ced->name);
1096 +- clockevents_register_device(ced);
1097 + }
1098 +
1099 + static int sh_mtu2_register(struct sh_mtu2_priv *p, char *name,
1100 +diff --git a/drivers/clocksource/sh_tmu.c b/drivers/clocksource/sh_tmu.c
1101 +index 93c2322..961f5b5 100644
1102 +--- a/drivers/clocksource/sh_tmu.c
1103 ++++ b/drivers/clocksource/sh_tmu.c
1104 +@@ -323,15 +323,15 @@ static void sh_tmu_register_clockevent(struct sh_tmu_priv *p,
1105 + ced->set_next_event = sh_tmu_clock_event_next;
1106 + ced->set_mode = sh_tmu_clock_event_mode;
1107 +
1108 ++ pr_info("sh_tmu: %s used for clock events\n", ced->name);
1109 ++ clockevents_register_device(ced);
1110 ++
1111 + ret = setup_irq(p->irqaction.irq, &p->irqaction);
1112 + if (ret) {
1113 + pr_err("sh_tmu: failed to request irq %d\n",
1114 + p->irqaction.irq);
1115 + return;
1116 + }
1117 +-
1118 +- pr_info("sh_tmu: %s used for clock events\n", ced->name);
1119 +- clockevents_register_device(ced);
1120 + }
1121 +
1122 + static int sh_tmu_register(struct sh_tmu_priv *p, char *name,
1123 +diff --git a/drivers/gpio/cs5535-gpio.c b/drivers/gpio/cs5535-gpio.c
1124 +index 0fdbe94..0c3c498 100644
1125 +--- a/drivers/gpio/cs5535-gpio.c
1126 ++++ b/drivers/gpio/cs5535-gpio.c
1127 +@@ -154,7 +154,7 @@ static int chip_gpio_request(struct gpio_chip *c, unsigned offset)
1128 +
1129 + static int chip_gpio_get(struct gpio_chip *chip, unsigned offset)
1130 + {
1131 +- return cs5535_gpio_isset(offset, GPIO_OUTPUT_VAL);
1132 ++ return cs5535_gpio_isset(offset, GPIO_READ_BACK);
1133 + }
1134 +
1135 + static void chip_gpio_set(struct gpio_chip *chip, unsigned offset, int val)
1136 +@@ -172,6 +172,7 @@ static int chip_direction_input(struct gpio_chip *c, unsigned offset)
1137 +
1138 + spin_lock_irqsave(&chip->lock, flags);
1139 + __cs5535_gpio_set(chip, offset, GPIO_INPUT_ENABLE);
1140 ++ __cs5535_gpio_clear(chip, offset, GPIO_OUTPUT_ENABLE);
1141 + spin_unlock_irqrestore(&chip->lock, flags);
1142 +
1143 + return 0;
1144 +@@ -184,6 +185,7 @@ static int chip_direction_output(struct gpio_chip *c, unsigned offset, int val)
1145 +
1146 + spin_lock_irqsave(&chip->lock, flags);
1147 +
1148 ++ __cs5535_gpio_set(chip, offset, GPIO_INPUT_ENABLE);
1149 + __cs5535_gpio_set(chip, offset, GPIO_OUTPUT_ENABLE);
1150 + if (val)
1151 + __cs5535_gpio_set(chip, offset, GPIO_OUTPUT_VAL);
1152 +diff --git a/drivers/gpio/wm831x-gpio.c b/drivers/gpio/wm831x-gpio.c
1153 +index b4468b6..c5a00f7 100644
1154 +--- a/drivers/gpio/wm831x-gpio.c
1155 ++++ b/drivers/gpio/wm831x-gpio.c
1156 +@@ -60,23 +60,31 @@ static int wm831x_gpio_get(struct gpio_chip *chip, unsigned offset)
1157 + return 0;
1158 + }
1159 +
1160 +-static int wm831x_gpio_direction_out(struct gpio_chip *chip,
1161 +- unsigned offset, int value)
1162 ++static void wm831x_gpio_set(struct gpio_chip *chip, unsigned offset, int value)
1163 + {
1164 + struct wm831x_gpio *wm831x_gpio = to_wm831x_gpio(chip);
1165 + struct wm831x *wm831x = wm831x_gpio->wm831x;
1166 +
1167 +- return wm831x_set_bits(wm831x, WM831X_GPIO1_CONTROL + offset,
1168 +- WM831X_GPN_DIR | WM831X_GPN_TRI, 0);
1169 ++ wm831x_set_bits(wm831x, WM831X_GPIO_LEVEL, 1 << offset,
1170 ++ value << offset);
1171 + }
1172 +
1173 +-static void wm831x_gpio_set(struct gpio_chip *chip, unsigned offset, int value)
1174 ++static int wm831x_gpio_direction_out(struct gpio_chip *chip,
1175 ++ unsigned offset, int value)
1176 + {
1177 + struct wm831x_gpio *wm831x_gpio = to_wm831x_gpio(chip);
1178 + struct wm831x *wm831x = wm831x_gpio->wm831x;
1179 ++ int ret;
1180 +
1181 +- wm831x_set_bits(wm831x, WM831X_GPIO_LEVEL, 1 << offset,
1182 +- value << offset);
1183 ++ ret = wm831x_set_bits(wm831x, WM831X_GPIO1_CONTROL + offset,
1184 ++ WM831X_GPN_DIR | WM831X_GPN_TRI, 0);
1185 ++ if (ret < 0)
1186 ++ return ret;
1187 ++
1188 ++ /* Can only set GPIO state once it's in output mode */
1189 ++ wm831x_gpio_set(chip, offset, value);
1190 ++
1191 ++ return 0;
1192 + }
1193 +
1194 + static int wm831x_gpio_to_irq(struct gpio_chip *chip, unsigned offset)
1195 +diff --git a/drivers/gpu/drm/i915/intel_lvds.c b/drivers/gpu/drm/i915/intel_lvds.c
1196 +index c2e8a45..93031a7 100644
1197 +--- a/drivers/gpu/drm/i915/intel_lvds.c
1198 ++++ b/drivers/gpu/drm/i915/intel_lvds.c
1199 +@@ -655,8 +655,15 @@ static const struct dmi_system_id bad_lid_status[] = {
1200 + */
1201 + static enum drm_connector_status intel_lvds_detect(struct drm_connector *connector)
1202 + {
1203 ++ struct drm_device *dev = connector->dev;
1204 + enum drm_connector_status status = connector_status_connected;
1205 +
1206 ++ /* ACPI lid methods were generally unreliable in this generation, so
1207 ++ * don't even bother.
1208 ++ */
1209 ++ if (IS_I8XX(dev))
1210 ++ return connector_status_connected;
1211 ++
1212 + if (!dmi_check_system(bad_lid_status) && !acpi_lid_open())
1213 + status = connector_status_disconnected;
1214 +
1215 +diff --git a/drivers/gpu/drm/i915/intel_sdvo.c b/drivers/gpu/drm/i915/intel_sdvo.c
1216 +index 82678d3..48daee5 100644
1217 +--- a/drivers/gpu/drm/i915/intel_sdvo.c
1218 ++++ b/drivers/gpu/drm/i915/intel_sdvo.c
1219 +@@ -35,6 +35,7 @@
1220 + #include "i915_drm.h"
1221 + #include "i915_drv.h"
1222 + #include "intel_sdvo_regs.h"
1223 ++#include <linux/dmi.h>
1224 +
1225 + static char *tv_format_names[] = {
1226 + "NTSC_M" , "NTSC_J" , "NTSC_443",
1227 +@@ -2283,6 +2284,25 @@ intel_sdvo_get_slave_addr(struct drm_device *dev, int output_device)
1228 + return 0x72;
1229 + }
1230 +
1231 ++static int intel_sdvo_bad_tv_callback(const struct dmi_system_id *id)
1232 ++{
1233 ++ DRM_DEBUG_KMS("Ignoring bad SDVO TV connector for %s\n", id->ident);
1234 ++ return 1;
1235 ++}
1236 ++
1237 ++static struct dmi_system_id intel_sdvo_bad_tv[] = {
1238 ++ {
1239 ++ .callback = intel_sdvo_bad_tv_callback,
1240 ++ .ident = "IntelG45/ICH10R/DME1737",
1241 ++ .matches = {
1242 ++ DMI_MATCH(DMI_SYS_VENDOR, "IBM CORPORATION"),
1243 ++ DMI_MATCH(DMI_PRODUCT_NAME, "4800784"),
1244 ++ },
1245 ++ },
1246 ++
1247 ++ { } /* terminating entry */
1248 ++};
1249 ++
1250 + static bool
1251 + intel_sdvo_output_setup(struct intel_output *intel_output, uint16_t flags)
1252 + {
1253 +@@ -2323,7 +2343,8 @@ intel_sdvo_output_setup(struct intel_output *intel_output, uint16_t flags)
1254 + (1 << INTEL_SDVO_NON_TV_CLONE_BIT) |
1255 + (1 << INTEL_ANALOG_CLONE_BIT);
1256 + }
1257 +- } else if (flags & SDVO_OUTPUT_SVID0) {
1258 ++ } else if ((flags & SDVO_OUTPUT_SVID0) &&
1259 ++ !dmi_check_system(intel_sdvo_bad_tv)) {
1260 +
1261 + sdvo_priv->controlled_output = SDVO_OUTPUT_SVID0;
1262 + encoder->encoder_type = DRM_MODE_ENCODER_TVDAC;
1263 +diff --git a/drivers/gpu/drm/radeon/atom.c b/drivers/gpu/drm/radeon/atom.c
1264 +index 7f152f6..d75788f 100644
1265 +--- a/drivers/gpu/drm/radeon/atom.c
1266 ++++ b/drivers/gpu/drm/radeon/atom.c
1267 +@@ -881,8 +881,6 @@ static void atom_op_shl(atom_exec_context *ctx, int *ptr, int arg)
1268 + uint8_t attr = U8((*ptr)++), shift;
1269 + uint32_t saved, dst;
1270 + int dptr = *ptr;
1271 +- attr &= 0x38;
1272 +- attr |= atom_def_dst[attr >> 3] << 6;
1273 + SDEBUG(" dst: ");
1274 + dst = atom_get_dst(ctx, arg, attr, ptr, &saved, 1);
1275 + shift = atom_get_src(ctx, attr, ptr);
1276 +@@ -897,8 +895,6 @@ static void atom_op_shr(atom_exec_context *ctx, int *ptr, int arg)
1277 + uint8_t attr = U8((*ptr)++), shift;
1278 + uint32_t saved, dst;
1279 + int dptr = *ptr;
1280 +- attr &= 0x38;
1281 +- attr |= atom_def_dst[attr >> 3] << 6;
1282 + SDEBUG(" dst: ");
1283 + dst = atom_get_dst(ctx, arg, attr, ptr, &saved, 1);
1284 + shift = atom_get_src(ctx, attr, ptr);
1285 +diff --git a/drivers/gpu/drm/ttm/ttm_tt.c b/drivers/gpu/drm/ttm/ttm_tt.c
1286 +index 3d47a2c..a759170 100644
1287 +--- a/drivers/gpu/drm/ttm/ttm_tt.c
1288 ++++ b/drivers/gpu/drm/ttm/ttm_tt.c
1289 +@@ -480,7 +480,7 @@ static int ttm_tt_swapin(struct ttm_tt *ttm)
1290 + void *from_virtual;
1291 + void *to_virtual;
1292 + int i;
1293 +- int ret;
1294 ++ int ret = -ENOMEM;
1295 +
1296 + if (ttm->page_flags & TTM_PAGE_FLAG_USER) {
1297 + ret = ttm_tt_set_user(ttm, ttm->tsk, ttm->start,
1298 +@@ -499,8 +499,10 @@ static int ttm_tt_swapin(struct ttm_tt *ttm)
1299 +
1300 + for (i = 0; i < ttm->num_pages; ++i) {
1301 + from_page = read_mapping_page(swap_space, i, NULL);
1302 +- if (IS_ERR(from_page))
1303 ++ if (IS_ERR(from_page)) {
1304 ++ ret = PTR_ERR(from_page);
1305 + goto out_err;
1306 ++ }
1307 + to_page = __ttm_tt_get_page(ttm, i);
1308 + if (unlikely(to_page == NULL))
1309 + goto out_err;
1310 +@@ -523,7 +525,7 @@ static int ttm_tt_swapin(struct ttm_tt *ttm)
1311 + return 0;
1312 + out_err:
1313 + ttm_tt_free_alloced_pages(ttm);
1314 +- return -ENOMEM;
1315 ++ return ret;
1316 + }
1317 +
1318 + int ttm_tt_swapout(struct ttm_tt *ttm, struct file *persistant_swap_storage)
1319 +@@ -535,6 +537,7 @@ int ttm_tt_swapout(struct ttm_tt *ttm, struct file *persistant_swap_storage)
1320 + void *from_virtual;
1321 + void *to_virtual;
1322 + int i;
1323 ++ int ret = -ENOMEM;
1324 +
1325 + BUG_ON(ttm->state != tt_unbound && ttm->state != tt_unpopulated);
1326 + BUG_ON(ttm->caching_state != tt_cached);
1327 +@@ -557,7 +560,7 @@ int ttm_tt_swapout(struct ttm_tt *ttm, struct file *persistant_swap_storage)
1328 + 0);
1329 + if (unlikely(IS_ERR(swap_storage))) {
1330 + printk(KERN_ERR "Failed allocating swap storage.\n");
1331 +- return -ENOMEM;
1332 ++ return PTR_ERR(swap_storage);
1333 + }
1334 + } else
1335 + swap_storage = persistant_swap_storage;
1336 +@@ -569,9 +572,10 @@ int ttm_tt_swapout(struct ttm_tt *ttm, struct file *persistant_swap_storage)
1337 + if (unlikely(from_page == NULL))
1338 + continue;
1339 + to_page = read_mapping_page(swap_space, i, NULL);
1340 +- if (unlikely(to_page == NULL))
1341 ++ if (unlikely(IS_ERR(to_page))) {
1342 ++ ret = PTR_ERR(to_page);
1343 + goto out_err;
1344 +-
1345 ++ }
1346 + preempt_disable();
1347 + from_virtual = kmap_atomic(from_page, KM_USER0);
1348 + to_virtual = kmap_atomic(to_page, KM_USER1);
1349 +@@ -595,5 +599,5 @@ out_err:
1350 + if (!persistant_swap_storage)
1351 + fput(swap_storage);
1352 +
1353 +- return -ENOMEM;
1354 ++ return ret;
1355 + }
1356 +diff --git a/drivers/hid/hid-core.c b/drivers/hid/hid-core.c
1357 +index eabe5f8..8455f3d 100644
1358 +--- a/drivers/hid/hid-core.c
1359 ++++ b/drivers/hid/hid-core.c
1360 +@@ -1661,8 +1661,6 @@ static const struct hid_device_id hid_ignore_list[] = {
1361 + { HID_USB_DEVICE(USB_VENDOR_ID_PANJIT, 0x0004) },
1362 + { HID_USB_DEVICE(USB_VENDOR_ID_PHILIPS, USB_DEVICE_ID_PHILIPS_IEEE802154_DONGLE) },
1363 + { HID_USB_DEVICE(USB_VENDOR_ID_POWERCOM, USB_DEVICE_ID_POWERCOM_UPS) },
1364 +- { HID_USB_DEVICE(USB_VENDOR_ID_TENX, USB_DEVICE_ID_TENX_IBUDDY1) },
1365 +- { HID_USB_DEVICE(USB_VENDOR_ID_TENX, USB_DEVICE_ID_TENX_IBUDDY2) },
1366 + { HID_USB_DEVICE(USB_VENDOR_ID_VERNIER, USB_DEVICE_ID_VERNIER_LABPRO) },
1367 + { HID_USB_DEVICE(USB_VENDOR_ID_VERNIER, USB_DEVICE_ID_VERNIER_GOTEMP) },
1368 + { HID_USB_DEVICE(USB_VENDOR_ID_VERNIER, USB_DEVICE_ID_VERNIER_SKIP) },
1369 +diff --git a/drivers/hid/hid-ids.h b/drivers/hid/hid-ids.h
1370 +index 010368e..793691f 100644
1371 +--- a/drivers/hid/hid-ids.h
1372 ++++ b/drivers/hid/hid-ids.h
1373 +@@ -402,10 +402,6 @@
1374 + #define USB_VENDOR_ID_SUNPLUS 0x04fc
1375 + #define USB_DEVICE_ID_SUNPLUS_WDESKTOP 0x05d8
1376 +
1377 +-#define USB_VENDOR_ID_TENX 0x1130
1378 +-#define USB_DEVICE_ID_TENX_IBUDDY1 0x0001
1379 +-#define USB_DEVICE_ID_TENX_IBUDDY2 0x0002
1380 +-
1381 + #define USB_VENDOR_ID_THRUSTMASTER 0x044f
1382 +
1383 + #define USB_VENDOR_ID_TOPMAX 0x0663
1384 +diff --git a/drivers/hid/usbhid/hid-core.c b/drivers/hid/usbhid/hid-core.c
1385 +index e2997a8..2f84237 100644
1386 +--- a/drivers/hid/usbhid/hid-core.c
1387 ++++ b/drivers/hid/usbhid/hid-core.c
1388 +@@ -316,6 +316,7 @@ static int hid_submit_out(struct hid_device *hid)
1389 + err_hid("usb_submit_urb(out) failed");
1390 + return -1;
1391 + }
1392 ++ usbhid->last_out = jiffies;
1393 + } else {
1394 + /*
1395 + * queue work to wake up the device.
1396 +@@ -377,6 +378,7 @@ static int hid_submit_ctrl(struct hid_device *hid)
1397 + err_hid("usb_submit_urb(ctrl) failed");
1398 + return -1;
1399 + }
1400 ++ usbhid->last_ctrl = jiffies;
1401 + } else {
1402 + /*
1403 + * queue work to wake up the device.
1404 +@@ -512,9 +514,20 @@ static void __usbhid_submit_report(struct hid_device *hid, struct hid_report *re
1405 + usbhid->out[usbhid->outhead].report = report;
1406 + usbhid->outhead = head;
1407 +
1408 +- if (!test_and_set_bit(HID_OUT_RUNNING, &usbhid->iofl))
1409 ++ if (!test_and_set_bit(HID_OUT_RUNNING, &usbhid->iofl)) {
1410 + if (hid_submit_out(hid))
1411 + clear_bit(HID_OUT_RUNNING, &usbhid->iofl);
1412 ++ } else {
1413 ++ /*
1414 ++ * the queue is known to run
1415 ++ * but an earlier request may be stuck
1416 ++ * we may need to time out
1417 ++ * no race because this is called under
1418 ++ * spinlock
1419 ++ */
1420 ++ if (time_after(jiffies, usbhid->last_out + HZ * 5))
1421 ++ usb_unlink_urb(usbhid->urbout);
1422 ++ }
1423 + return;
1424 + }
1425 +
1426 +@@ -535,9 +548,20 @@ static void __usbhid_submit_report(struct hid_device *hid, struct hid_report *re
1427 + usbhid->ctrl[usbhid->ctrlhead].dir = dir;
1428 + usbhid->ctrlhead = head;
1429 +
1430 +- if (!test_and_set_bit(HID_CTRL_RUNNING, &usbhid->iofl))
1431 ++ if (!test_and_set_bit(HID_CTRL_RUNNING, &usbhid->iofl)) {
1432 + if (hid_submit_ctrl(hid))
1433 + clear_bit(HID_CTRL_RUNNING, &usbhid->iofl);
1434 ++ } else {
1435 ++ /*
1436 ++ * the queue is known to run
1437 ++ * but an earlier request may be stuck
1438 ++ * we may need to time out
1439 ++ * no race because this is called under
1440 ++ * spinlock
1441 ++ */
1442 ++ if (time_after(jiffies, usbhid->last_ctrl + HZ * 5))
1443 ++ usb_unlink_urb(usbhid->urbctrl);
1444 ++ }
1445 + }
1446 +
1447 + void usbhid_submit_report(struct hid_device *hid, struct hid_report *report, unsigned char dir)
1448 +diff --git a/drivers/hid/usbhid/usbhid.h b/drivers/hid/usbhid/usbhid.h
1449 +index 08f505c..ec20400 100644
1450 +--- a/drivers/hid/usbhid/usbhid.h
1451 ++++ b/drivers/hid/usbhid/usbhid.h
1452 +@@ -80,12 +80,14 @@ struct usbhid_device {
1453 + unsigned char ctrlhead, ctrltail; /* Control fifo head & tail */
1454 + char *ctrlbuf; /* Control buffer */
1455 + dma_addr_t ctrlbuf_dma; /* Control buffer dma */
1456 ++ unsigned long last_ctrl; /* record of last output for timeouts */
1457 +
1458 + struct urb *urbout; /* Output URB */
1459 + struct hid_output_fifo out[HID_CONTROL_FIFO_SIZE]; /* Output pipe fifo */
1460 + unsigned char outhead, outtail; /* Output pipe fifo head & tail */
1461 + char *outbuf; /* Output buffer */
1462 + dma_addr_t outbuf_dma; /* Output buffer dma */
1463 ++ unsigned long last_out; /* record of last output for timeouts */
1464 +
1465 + spinlock_t lock; /* fifo spinlock */
1466 + unsigned long iofl; /* I/O flags (CTRL_RUNNING, OUT_RUNNING) */
1467 +diff --git a/drivers/hwmon/ams/ams-core.c b/drivers/hwmon/ams/ams-core.c
1468 +index 6c9ace1..2ad62c3 100644
1469 +--- a/drivers/hwmon/ams/ams-core.c
1470 ++++ b/drivers/hwmon/ams/ams-core.c
1471 +@@ -213,7 +213,7 @@ int __init ams_init(void)
1472 + return -ENODEV;
1473 + }
1474 +
1475 +-void ams_exit(void)
1476 ++void ams_sensor_detach(void)
1477 + {
1478 + /* Remove input device */
1479 + ams_input_exit();
1480 +@@ -221,9 +221,6 @@ void ams_exit(void)
1481 + /* Remove attributes */
1482 + device_remove_file(&ams_info.of_dev->dev, &dev_attr_current);
1483 +
1484 +- /* Shut down implementation */
1485 +- ams_info.exit();
1486 +-
1487 + /* Flush interrupt worker
1488 + *
1489 + * We do this after ams_info.exit(), because an interrupt might
1490 +@@ -239,6 +236,12 @@ void ams_exit(void)
1491 + pmf_unregister_irq_client(&ams_freefall_client);
1492 + }
1493 +
1494 ++static void __exit ams_exit(void)
1495 ++{
1496 ++ /* Shut down implementation */
1497 ++ ams_info.exit();
1498 ++}
1499 ++
1500 + MODULE_AUTHOR("Stelian Pop, Michael Hanselmann");
1501 + MODULE_DESCRIPTION("Apple Motion Sensor driver");
1502 + MODULE_LICENSE("GPL");
1503 +diff --git a/drivers/hwmon/ams/ams-i2c.c b/drivers/hwmon/ams/ams-i2c.c
1504 +index 2cbf8a6..abeecd2 100644
1505 +--- a/drivers/hwmon/ams/ams-i2c.c
1506 ++++ b/drivers/hwmon/ams/ams-i2c.c
1507 +@@ -238,6 +238,8 @@ static int ams_i2c_probe(struct i2c_client *client,
1508 + static int ams_i2c_remove(struct i2c_client *client)
1509 + {
1510 + if (ams_info.has_device) {
1511 ++ ams_sensor_detach();
1512 ++
1513 + /* Disable interrupts */
1514 + ams_i2c_set_irq(AMS_IRQ_ALL, 0);
1515 +
1516 +diff --git a/drivers/hwmon/ams/ams-pmu.c b/drivers/hwmon/ams/ams-pmu.c
1517 +index fb18b3d..4f61b3e 100644
1518 +--- a/drivers/hwmon/ams/ams-pmu.c
1519 ++++ b/drivers/hwmon/ams/ams-pmu.c
1520 +@@ -133,6 +133,8 @@ static void ams_pmu_get_xyz(s8 *x, s8 *y, s8 *z)
1521 +
1522 + static void ams_pmu_exit(void)
1523 + {
1524 ++ ams_sensor_detach();
1525 ++
1526 + /* Disable interrupts */
1527 + ams_pmu_set_irq(AMS_IRQ_ALL, 0);
1528 +
1529 +diff --git a/drivers/hwmon/ams/ams.h b/drivers/hwmon/ams/ams.h
1530 +index 5ed387b..b28d7e2 100644
1531 +--- a/drivers/hwmon/ams/ams.h
1532 ++++ b/drivers/hwmon/ams/ams.h
1533 +@@ -61,6 +61,7 @@ extern struct ams ams_info;
1534 +
1535 + extern void ams_sensors(s8 *x, s8 *y, s8 *z);
1536 + extern int ams_sensor_attach(void);
1537 ++extern void ams_sensor_detach(void);
1538 +
1539 + extern int ams_pmu_init(struct device_node *np);
1540 + extern int ams_i2c_init(struct device_node *np);
1541 +diff --git a/drivers/hwmon/fschmd.c b/drivers/hwmon/fschmd.c
1542 +index fa07282..0627f7a 100644
1543 +--- a/drivers/hwmon/fschmd.c
1544 ++++ b/drivers/hwmon/fschmd.c
1545 +@@ -267,7 +267,7 @@ struct fschmd_data {
1546 + struct list_head list; /* member of the watchdog_data_list */
1547 + struct kref kref;
1548 + struct miscdevice watchdog_miscdev;
1549 +- int kind;
1550 ++ enum chips kind;
1551 + unsigned long watchdog_is_open;
1552 + char watchdog_expect_close;
1553 + char watchdog_name[10]; /* must be unique to avoid sysfs conflict */
1554 +@@ -325,8 +325,7 @@ static ssize_t show_in_value(struct device *dev,
1555 + int index = to_sensor_dev_attr(devattr)->index;
1556 + struct fschmd_data *data = fschmd_update_device(dev);
1557 +
1558 +- /* fscher / fschrc - 1 as data->kind is an array index, not a chips */
1559 +- if (data->kind == (fscher - 1) || data->kind >= (fschrc - 1))
1560 ++ if (data->kind == fscher || data->kind >= fschrc)
1561 + return sprintf(buf, "%d\n", (data->volt[index] * dmi_vref *
1562 + dmi_mult[index]) / 255 + dmi_offset[index]);
1563 + else
1564 +@@ -492,7 +491,7 @@ static ssize_t show_pwm_auto_point1_pwm(struct device *dev,
1565 + int val = data->fan_min[index];
1566 +
1567 + /* 0 = allow turning off (except on the syl), 1-255 = 50-100% */
1568 +- if (val || data->kind == fscsyl - 1)
1569 ++ if (val || data->kind == fscsyl)
1570 + val = val / 2 + 128;
1571 +
1572 + return sprintf(buf, "%d\n", val);
1573 +@@ -506,7 +505,7 @@ static ssize_t store_pwm_auto_point1_pwm(struct device *dev,
1574 + unsigned long v = simple_strtoul(buf, NULL, 10);
1575 +
1576 + /* reg: 0 = allow turning off (except on the syl), 1-255 = 50-100% */
1577 +- if (v || data->kind == fscsyl - 1) {
1578 ++ if (v || data->kind == fscsyl) {
1579 + v = SENSORS_LIMIT(v, 128, 255);
1580 + v = (v - 128) * 2 + 1;
1581 + }
1582 +@@ -1037,7 +1036,7 @@ static int fschmd_detect(struct i2c_client *client,
1583 + else
1584 + return -ENODEV;
1585 +
1586 +- strlcpy(info->type, fschmd_id[kind - 1].name, I2C_NAME_SIZE);
1587 ++ strlcpy(info->type, fschmd_id[kind].name, I2C_NAME_SIZE);
1588 +
1589 + return 0;
1590 + }
1591 +@@ -1065,6 +1064,7 @@ static int fschmd_probe(struct i2c_client *client,
1592 + (where the client is found through a data ptr instead of the
1593 + otherway around) */
1594 + data->client = client;
1595 ++ data->kind = kind;
1596 +
1597 + if (kind == fscpos) {
1598 + /* The Poseidon has hardwired temp limits, fill these
1599 +@@ -1085,9 +1085,6 @@ static int fschmd_probe(struct i2c_client *client,
1600 + }
1601 + }
1602 +
1603 +- /* i2c kind goes from 1-6, we want from 0-5 to address arrays */
1604 +- data->kind = kind - 1;
1605 +-
1606 + /* Read in some never changing registers */
1607 + data->revision = i2c_smbus_read_byte_data(client, FSCHMD_REG_REVISION);
1608 + data->global_control = i2c_smbus_read_byte_data(client,
1609 +diff --git a/drivers/hwmon/tmp401.c b/drivers/hwmon/tmp401.c
1610 +index a13b30e..d14a1af 100644
1611 +--- a/drivers/hwmon/tmp401.c
1612 ++++ b/drivers/hwmon/tmp401.c
1613 +@@ -134,7 +134,7 @@ struct tmp401_data {
1614 + struct mutex update_lock;
1615 + char valid; /* zero until following fields are valid */
1616 + unsigned long last_updated; /* in jiffies */
1617 +- int kind;
1618 ++ enum chips kind;
1619 +
1620 + /* register values */
1621 + u8 status;
1622 +@@ -524,7 +524,7 @@ static int tmp401_detect(struct i2c_client *client,
1623 + if (reg > 15)
1624 + return -ENODEV;
1625 +
1626 +- strlcpy(info->type, tmp401_id[kind - 1].name, I2C_NAME_SIZE);
1627 ++ strlcpy(info->type, tmp401_id[kind].name, I2C_NAME_SIZE);
1628 +
1629 + return 0;
1630 + }
1631 +@@ -572,8 +572,7 @@ static int tmp401_probe(struct i2c_client *client,
1632 + goto exit_remove;
1633 + }
1634 +
1635 +- dev_info(&client->dev, "Detected TI %s chip\n",
1636 +- names[data->kind - 1]);
1637 ++ dev_info(&client->dev, "Detected TI %s chip\n", names[data->kind]);
1638 +
1639 + return 0;
1640 +
1641 +diff --git a/drivers/hwmon/tmp421.c b/drivers/hwmon/tmp421.c
1642 +index 4f7c051..738c472 100644
1643 +--- a/drivers/hwmon/tmp421.c
1644 ++++ b/drivers/hwmon/tmp421.c
1645 +@@ -61,9 +61,9 @@ static const u8 TMP421_TEMP_LSB[4] = { 0x10, 0x11, 0x12, 0x13 };
1646 + #define TMP423_DEVICE_ID 0x23
1647 +
1648 + static const struct i2c_device_id tmp421_id[] = {
1649 +- { "tmp421", tmp421 },
1650 +- { "tmp422", tmp422 },
1651 +- { "tmp423", tmp423 },
1652 ++ { "tmp421", 2 },
1653 ++ { "tmp422", 3 },
1654 ++ { "tmp423", 4 },
1655 + { }
1656 + };
1657 + MODULE_DEVICE_TABLE(i2c, tmp421_id);
1658 +@@ -73,21 +73,23 @@ struct tmp421_data {
1659 + struct mutex update_lock;
1660 + char valid;
1661 + unsigned long last_updated;
1662 +- int kind;
1663 ++ int channels;
1664 + u8 config;
1665 + s16 temp[4];
1666 + };
1667 +
1668 + static int temp_from_s16(s16 reg)
1669 + {
1670 +- int temp = reg;
1671 ++ /* Mask out status bits */
1672 ++ int temp = reg & ~0xf;
1673 +
1674 + return (temp * 1000 + 128) / 256;
1675 + }
1676 +
1677 + static int temp_from_u16(u16 reg)
1678 + {
1679 +- int temp = reg;
1680 ++ /* Mask out status bits */
1681 ++ int temp = reg & ~0xf;
1682 +
1683 + /* Add offset for extended temperature range. */
1684 + temp -= 64 * 256;
1685 +@@ -107,7 +109,7 @@ static struct tmp421_data *tmp421_update_device(struct device *dev)
1686 + data->config = i2c_smbus_read_byte_data(client,
1687 + TMP421_CONFIG_REG_1);
1688 +
1689 +- for (i = 0; i <= data->kind; i++) {
1690 ++ for (i = 0; i < data->channels; i++) {
1691 + data->temp[i] = i2c_smbus_read_byte_data(client,
1692 + TMP421_TEMP_MSB[i]) << 8;
1693 + data->temp[i] |= i2c_smbus_read_byte_data(client,
1694 +@@ -166,7 +168,7 @@ static mode_t tmp421_is_visible(struct kobject *kobj, struct attribute *a,
1695 + devattr = container_of(a, struct device_attribute, attr);
1696 + index = to_sensor_dev_attr(devattr)->index;
1697 +
1698 +- if (data->kind > index)
1699 ++ if (index < data->channels)
1700 + return a->mode;
1701 +
1702 + return 0;
1703 +@@ -252,9 +254,9 @@ static int tmp421_detect(struct i2c_client *client,
1704 + return -ENODEV;
1705 + }
1706 +
1707 +- strlcpy(info->type, tmp421_id[kind - 1].name, I2C_NAME_SIZE);
1708 ++ strlcpy(info->type, tmp421_id[kind].name, I2C_NAME_SIZE);
1709 + dev_info(&adapter->dev, "Detected TI %s chip at 0x%02x\n",
1710 +- names[kind - 1], client->addr);
1711 ++ names[kind], client->addr);
1712 +
1713 + return 0;
1714 + }
1715 +@@ -271,7 +273,7 @@ static int tmp421_probe(struct i2c_client *client,
1716 +
1717 + i2c_set_clientdata(client, data);
1718 + mutex_init(&data->update_lock);
1719 +- data->kind = id->driver_data;
1720 ++ data->channels = id->driver_data;
1721 +
1722 + err = tmp421_init_client(client);
1723 + if (err)
1724 +diff --git a/drivers/macintosh/therm_adt746x.c b/drivers/macintosh/therm_adt746x.c
1725 +index 5ff47ba..58809b0 100644
1726 +--- a/drivers/macintosh/therm_adt746x.c
1727 ++++ b/drivers/macintosh/therm_adt746x.c
1728 +@@ -90,6 +90,8 @@ static struct task_struct *thread_therm = NULL;
1729 +
1730 + static void write_both_fan_speed(struct thermostat *th, int speed);
1731 + static void write_fan_speed(struct thermostat *th, int speed, int fan);
1732 ++static void thermostat_create_files(void);
1733 ++static void thermostat_remove_files(void);
1734 +
1735 + static int
1736 + write_reg(struct thermostat* th, int reg, u8 data)
1737 +@@ -161,6 +163,8 @@ remove_thermostat(struct i2c_client *client)
1738 + struct thermostat *th = i2c_get_clientdata(client);
1739 + int i;
1740 +
1741 ++ thermostat_remove_files();
1742 ++
1743 + if (thread_therm != NULL) {
1744 + kthread_stop(thread_therm);
1745 + }
1746 +@@ -449,6 +453,8 @@ static int probe_thermostat(struct i2c_client *client,
1747 + return -ENOMEM;
1748 + }
1749 +
1750 ++ thermostat_create_files();
1751 ++
1752 + return 0;
1753 + }
1754 +
1755 +@@ -566,7 +572,6 @@ thermostat_init(void)
1756 + struct device_node* np;
1757 + const u32 *prop;
1758 + int i = 0, offset = 0;
1759 +- int err;
1760 +
1761 + np = of_find_node_by_name(NULL, "fan");
1762 + if (!np)
1763 +@@ -633,6 +638,17 @@ thermostat_init(void)
1764 + return -ENODEV;
1765 + }
1766 +
1767 ++#ifndef CONFIG_I2C_POWERMAC
1768 ++ request_module("i2c-powermac");
1769 ++#endif
1770 ++
1771 ++ return i2c_add_driver(&thermostat_driver);
1772 ++}
1773 ++
1774 ++static void thermostat_create_files(void)
1775 ++{
1776 ++ int err;
1777 ++
1778 + err = device_create_file(&of_dev->dev, &dev_attr_sensor1_temperature);
1779 + err |= device_create_file(&of_dev->dev, &dev_attr_sensor2_temperature);
1780 + err |= device_create_file(&of_dev->dev, &dev_attr_sensor1_limit);
1781 +@@ -647,16 +663,9 @@ thermostat_init(void)
1782 + if (err)
1783 + printk(KERN_WARNING
1784 + "Failed to create tempertaure attribute file(s).\n");
1785 +-
1786 +-#ifndef CONFIG_I2C_POWERMAC
1787 +- request_module("i2c-powermac");
1788 +-#endif
1789 +-
1790 +- return i2c_add_driver(&thermostat_driver);
1791 + }
1792 +
1793 +-static void __exit
1794 +-thermostat_exit(void)
1795 ++static void thermostat_remove_files(void)
1796 + {
1797 + if (of_dev) {
1798 + device_remove_file(&of_dev->dev, &dev_attr_sensor1_temperature);
1799 +@@ -673,9 +682,14 @@ thermostat_exit(void)
1800 + device_remove_file(&of_dev->dev,
1801 + &dev_attr_sensor2_fan_speed);
1802 +
1803 +- of_device_unregister(of_dev);
1804 + }
1805 ++}
1806 ++
1807 ++static void __exit
1808 ++thermostat_exit(void)
1809 ++{
1810 + i2c_del_driver(&thermostat_driver);
1811 ++ of_device_unregister(of_dev);
1812 + }
1813 +
1814 + module_init(thermostat_init);
1815 +diff --git a/drivers/md/dm-ioctl.c b/drivers/md/dm-ioctl.c
1816 +index 1d66932..e3cf568 100644
1817 +--- a/drivers/md/dm-ioctl.c
1818 ++++ b/drivers/md/dm-ioctl.c
1819 +@@ -897,16 +897,17 @@ static int do_resume(struct dm_ioctl *param)
1820 + set_disk_ro(dm_disk(md), 1);
1821 + }
1822 +
1823 +- if (dm_suspended_md(md))
1824 ++ if (dm_suspended_md(md)) {
1825 + r = dm_resume(md);
1826 ++ if (!r)
1827 ++ dm_kobject_uevent(md, KOBJ_CHANGE, param->event_nr);
1828 ++ }
1829 +
1830 + if (old_map)
1831 + dm_table_destroy(old_map);
1832 +
1833 +- if (!r) {
1834 +- dm_kobject_uevent(md, KOBJ_CHANGE, param->event_nr);
1835 ++ if (!r)
1836 + r = __dev_status(md, param);
1837 +- }
1838 +
1839 + dm_put(md);
1840 + return r;
1841 +diff --git a/drivers/md/dm.c b/drivers/md/dm.c
1842 +index aa4e2aa..fa786b9 100644
1843 +--- a/drivers/md/dm.c
1844 ++++ b/drivers/md/dm.c
1845 +@@ -635,8 +635,10 @@ static void dec_pending(struct dm_io *io, int error)
1846 + if (!md->barrier_error && io_error != -EOPNOTSUPP)
1847 + md->barrier_error = io_error;
1848 + end_io_acct(io);
1849 ++ free_io(md, io);
1850 + } else {
1851 + end_io_acct(io);
1852 ++ free_io(md, io);
1853 +
1854 + if (io_error != DM_ENDIO_REQUEUE) {
1855 + trace_block_bio_complete(md->queue, bio);
1856 +@@ -644,8 +646,6 @@ static void dec_pending(struct dm_io *io, int error)
1857 + bio_endio(bio, io_error);
1858 + }
1859 + }
1860 +-
1861 +- free_io(md, io);
1862 + }
1863 + }
1864 +
1865 +diff --git a/drivers/media/dvb/dvb-core/dvb_net.c b/drivers/media/dvb/dvb-core/dvb_net.c
1866 +index 8b8558f..b11533f 100644
1867 +--- a/drivers/media/dvb/dvb-core/dvb_net.c
1868 ++++ b/drivers/media/dvb/dvb-core/dvb_net.c
1869 +@@ -504,6 +504,7 @@ static void dvb_net_ule( struct net_device *dev, const u8 *buf, size_t buf_len )
1870 + "bytes left in TS. Resyncing.\n", ts_remain);
1871 + priv->ule_sndu_len = 0;
1872 + priv->need_pusi = 1;
1873 ++ ts += TS_SZ;
1874 + continue;
1875 + }
1876 +
1877 +diff --git a/drivers/media/video/gspca/mr97310a.c b/drivers/media/video/gspca/mr97310a.c
1878 +index 9154870..0493e40 100644
1879 +--- a/drivers/media/video/gspca/mr97310a.c
1880 ++++ b/drivers/media/video/gspca/mr97310a.c
1881 +@@ -697,6 +697,12 @@ static int start_cif_cam(struct gspca_dev *gspca_dev)
1882 + {0x13, 0x00, {0x01}, 1},
1883 + {0, 0, {0}, 0}
1884 + };
1885 ++ /* Without this command the cam won't work with USB-UHCI */
1886 ++ gspca_dev->usb_buf[0] = 0x0a;
1887 ++ gspca_dev->usb_buf[1] = 0x00;
1888 ++ err_code = mr_write(gspca_dev, 2);
1889 ++ if (err_code < 0)
1890 ++ return err_code;
1891 + err_code = sensor_write_regs(gspca_dev, cif_sensor1_init_data,
1892 + ARRAY_SIZE(cif_sensor1_init_data));
1893 + }
1894 +diff --git a/drivers/media/video/soc_mediabus.c b/drivers/media/video/soc_mediabus.c
1895 +index f8d5c87..a4c0ef4 100644
1896 +--- a/drivers/media/video/soc_mediabus.c
1897 ++++ b/drivers/media/video/soc_mediabus.c
1898 +@@ -134,7 +134,8 @@ EXPORT_SYMBOL(soc_mbus_bytes_per_line);
1899 + const struct soc_mbus_pixelfmt *soc_mbus_get_fmtdesc(
1900 + enum v4l2_mbus_pixelcode code)
1901 + {
1902 +- if ((unsigned int)(code - V4L2_MBUS_FMT_FIXED) > ARRAY_SIZE(mbus_fmt))
1903 ++ if (code - V4L2_MBUS_FMT_FIXED > ARRAY_SIZE(mbus_fmt) ||
1904 ++ code <= V4L2_MBUS_FMT_FIXED)
1905 + return NULL;
1906 + return mbus_fmt + code - V4L2_MBUS_FMT_FIXED - 1;
1907 + }
1908 +diff --git a/drivers/mmc/host/s3cmci.c b/drivers/mmc/host/s3cmci.c
1909 +index d96e1ab..2fdf768 100644
1910 +--- a/drivers/mmc/host/s3cmci.c
1911 ++++ b/drivers/mmc/host/s3cmci.c
1912 +@@ -1179,7 +1179,7 @@ static int s3cmci_card_present(struct mmc_host *mmc)
1913 + struct s3c24xx_mci_pdata *pdata = host->pdata;
1914 + int ret;
1915 +
1916 +- if (pdata->gpio_detect == 0)
1917 ++ if (pdata->no_detect)
1918 + return -ENOSYS;
1919 +
1920 + ret = gpio_get_value(pdata->gpio_detect) ? 0 : 1;
1921 +@@ -1360,6 +1360,8 @@ static struct mmc_host_ops s3cmci_ops = {
1922 + static struct s3c24xx_mci_pdata s3cmci_def_pdata = {
1923 + /* This is currently here to avoid a number of if (host->pdata)
1924 + * checks. Any zero fields to ensure reasonable defaults are picked. */
1925 ++ .no_wprotect = 1,
1926 ++ .no_detect = 1,
1927 + };
1928 +
1929 + #ifdef CONFIG_CPU_FREQ
1930 +diff --git a/drivers/net/wireless/airo.c b/drivers/net/wireless/airo.c
1931 +index 4331d67..2a9f029 100644
1932 +--- a/drivers/net/wireless/airo.c
1933 ++++ b/drivers/net/wireless/airo.c
1934 +@@ -5254,11 +5254,7 @@ static int set_wep_key(struct airo_info *ai, u16 index, const char *key,
1935 + WepKeyRid wkr;
1936 + int rc;
1937 +
1938 +- if (keylen == 0) {
1939 +- airo_print_err(ai->dev->name, "%s: key length to set was zero",
1940 +- __func__);
1941 +- return -1;
1942 +- }
1943 ++ WARN_ON(keylen == 0);
1944 +
1945 + memset(&wkr, 0, sizeof(wkr));
1946 + wkr.len = cpu_to_le16(sizeof(wkr));
1947 +@@ -6405,11 +6401,7 @@ static int airo_set_encode(struct net_device *dev,
1948 + if (dwrq->length > MIN_KEY_SIZE)
1949 + key.len = MAX_KEY_SIZE;
1950 + else
1951 +- if (dwrq->length > 0)
1952 +- key.len = MIN_KEY_SIZE;
1953 +- else
1954 +- /* Disable the key */
1955 +- key.len = 0;
1956 ++ key.len = MIN_KEY_SIZE;
1957 + /* Check if the key is not marked as invalid */
1958 + if(!(dwrq->flags & IW_ENCODE_NOKEY)) {
1959 + /* Cleanup */
1960 +@@ -6590,12 +6582,22 @@ static int airo_set_encodeext(struct net_device *dev,
1961 + default:
1962 + return -EINVAL;
1963 + }
1964 +- /* Send the key to the card */
1965 +- rc = set_wep_key(local, idx, key.key, key.len, perm, 1);
1966 +- if (rc < 0) {
1967 +- airo_print_err(local->dev->name, "failed to set WEP key"
1968 +- " at index %d: %d.", idx, rc);
1969 +- return rc;
1970 ++ if (key.len == 0) {
1971 ++ rc = set_wep_tx_idx(local, idx, perm, 1);
1972 ++ if (rc < 0) {
1973 ++ airo_print_err(local->dev->name,
1974 ++ "failed to set WEP transmit index to %d: %d.",
1975 ++ idx, rc);
1976 ++ return rc;
1977 ++ }
1978 ++ } else {
1979 ++ rc = set_wep_key(local, idx, key.key, key.len, perm, 1);
1980 ++ if (rc < 0) {
1981 ++ airo_print_err(local->dev->name,
1982 ++ "failed to set WEP key at index %d: %d.",
1983 ++ idx, rc);
1984 ++ return rc;
1985 ++ }
1986 + }
1987 + }
1988 +
1989 +diff --git a/drivers/net/wireless/ath/ath5k/ath5k.h b/drivers/net/wireless/ath/ath5k/ath5k.h
1990 +index 6a2a967..bbd2f31 100644
1991 +--- a/drivers/net/wireless/ath/ath5k/ath5k.h
1992 ++++ b/drivers/net/wireless/ath/ath5k/ath5k.h
1993 +@@ -541,7 +541,6 @@ struct ath5k_txq_info {
1994 + /*
1995 + * Transmit packet types.
1996 + * used on tx control descriptor
1997 +- * TODO: Use them inside base.c corectly
1998 + */
1999 + enum ath5k_pkt_type {
2000 + AR5K_PKT_TYPE_NORMAL = 0,
2001 +diff --git a/drivers/net/wireless/ath/ath5k/base.c b/drivers/net/wireless/ath/ath5k/base.c
2002 +index e63b7c4..d6ee8ac 100644
2003 +--- a/drivers/net/wireless/ath/ath5k/base.c
2004 ++++ b/drivers/net/wireless/ath/ath5k/base.c
2005 +@@ -1246,6 +1246,29 @@ ath5k_rxbuf_setup(struct ath5k_softc *sc, struct ath5k_buf *bf)
2006 + return 0;
2007 + }
2008 +
2009 ++static enum ath5k_pkt_type get_hw_packet_type(struct sk_buff *skb)
2010 ++{
2011 ++ struct ieee80211_hdr *hdr;
2012 ++ enum ath5k_pkt_type htype;
2013 ++ __le16 fc;
2014 ++
2015 ++ hdr = (struct ieee80211_hdr *)skb->data;
2016 ++ fc = hdr->frame_control;
2017 ++
2018 ++ if (ieee80211_is_beacon(fc))
2019 ++ htype = AR5K_PKT_TYPE_BEACON;
2020 ++ else if (ieee80211_is_probe_resp(fc))
2021 ++ htype = AR5K_PKT_TYPE_PROBE_RESP;
2022 ++ else if (ieee80211_is_atim(fc))
2023 ++ htype = AR5K_PKT_TYPE_ATIM;
2024 ++ else if (ieee80211_is_pspoll(fc))
2025 ++ htype = AR5K_PKT_TYPE_PSPOLL;
2026 ++ else
2027 ++ htype = AR5K_PKT_TYPE_NORMAL;
2028 ++
2029 ++ return htype;
2030 ++}
2031 ++
2032 + static int
2033 + ath5k_txbuf_setup(struct ath5k_softc *sc, struct ath5k_buf *bf,
2034 + struct ath5k_txq *txq)
2035 +@@ -1300,7 +1323,8 @@ ath5k_txbuf_setup(struct ath5k_softc *sc, struct ath5k_buf *bf,
2036 + sc->vif, pktlen, info));
2037 + }
2038 + ret = ah->ah_setup_tx_desc(ah, ds, pktlen,
2039 +- ieee80211_get_hdrlen_from_skb(skb), AR5K_PKT_TYPE_NORMAL,
2040 ++ ieee80211_get_hdrlen_from_skb(skb),
2041 ++ get_hw_packet_type(skb),
2042 + (sc->power_level * 2),
2043 + hw_rate,
2044 + info->control.rates[0].count, keyidx, ah->ah_tx_ant, flags,
2045 +diff --git a/drivers/net/wireless/ath/ath9k/beacon.c b/drivers/net/wireless/ath/ath9k/beacon.c
2046 +index 1660ef1..06eaaa9 100644
2047 +--- a/drivers/net/wireless/ath/ath9k/beacon.c
2048 ++++ b/drivers/net/wireless/ath/ath9k/beacon.c
2049 +@@ -525,16 +525,13 @@ static void ath_beacon_config_ap(struct ath_softc *sc,
2050 + {
2051 + u32 nexttbtt, intval;
2052 +
2053 +- /* Configure the timers only when the TSF has to be reset */
2054 +-
2055 +- if (!(sc->sc_flags & SC_OP_TSF_RESET))
2056 +- return;
2057 +-
2058 + /* NB: the beacon interval is kept internally in TU's */
2059 + intval = conf->beacon_interval & ATH9K_BEACON_PERIOD;
2060 + intval /= ATH_BCBUF; /* for staggered beacons */
2061 + nexttbtt = intval;
2062 +- intval |= ATH9K_BEACON_RESET_TSF;
2063 ++
2064 ++ if (sc->sc_flags & SC_OP_TSF_RESET)
2065 ++ intval |= ATH9K_BEACON_RESET_TSF;
2066 +
2067 + /*
2068 + * In AP mode we enable the beacon timers and SWBA interrupts to
2069 +diff --git a/drivers/net/wireless/ath/ath9k/hw.c b/drivers/net/wireless/ath/ath9k/hw.c
2070 +index ae37144..7c64aa5 100644
2071 +--- a/drivers/net/wireless/ath/ath9k/hw.c
2072 ++++ b/drivers/net/wireless/ath/ath9k/hw.c
2073 +@@ -1345,6 +1345,16 @@ static void ath9k_hw_override_ini(struct ath_hw *ah,
2074 + * Necessary to avoid issues on AR5416 2.0
2075 + */
2076 + REG_WRITE(ah, 0x9800 + (651 << 2), 0x11);
2077 ++
2078 ++ /*
2079 ++ * Disable RIFS search on some chips to avoid baseband
2080 ++ * hang issues.
2081 ++ */
2082 ++ if (AR_SREV_9100(ah) || AR_SREV_9160(ah)) {
2083 ++ val = REG_READ(ah, AR_PHY_HEAVY_CLIP_FACTOR_RIFS);
2084 ++ val &= ~AR_PHY_RIFS_INIT_DELAY;
2085 ++ REG_WRITE(ah, AR_PHY_HEAVY_CLIP_FACTOR_RIFS, val);
2086 ++ }
2087 + }
2088 +
2089 + static u32 ath9k_hw_def_ini_fixup(struct ath_hw *ah,
2090 +diff --git a/drivers/net/wireless/ath/ath9k/main.c b/drivers/net/wireless/ath/ath9k/main.c
2091 +index 643bea3..4faafbd 100644
2092 +--- a/drivers/net/wireless/ath/ath9k/main.c
2093 ++++ b/drivers/net/wireless/ath/ath9k/main.c
2094 +@@ -928,6 +928,7 @@ static void ath_key_delete(struct ath_common *common, struct ieee80211_key_conf
2095 +
2096 + clear_bit(key->hw_key_idx + 64, common->keymap);
2097 + if (common->splitmic) {
2098 ++ ath9k_hw_keyreset(ah, key->hw_key_idx + 32);
2099 + clear_bit(key->hw_key_idx + 32, common->keymap);
2100 + clear_bit(key->hw_key_idx + 64 + 32, common->keymap);
2101 + }
2102 +@@ -1848,6 +1849,8 @@ bad_free_hw:
2103 +
2104 + void ath_set_hw_capab(struct ath_softc *sc, struct ieee80211_hw *hw)
2105 + {
2106 ++ struct ath_hw *ah = sc->sc_ah;
2107 ++
2108 + hw->flags = IEEE80211_HW_RX_INCLUDES_FCS |
2109 + IEEE80211_HW_HOST_BROADCAST_PS_BUFFERING |
2110 + IEEE80211_HW_SIGNAL_DBM |
2111 +@@ -1865,7 +1868,8 @@ void ath_set_hw_capab(struct ath_softc *sc, struct ieee80211_hw *hw)
2112 + BIT(NL80211_IFTYPE_ADHOC) |
2113 + BIT(NL80211_IFTYPE_MESH_POINT);
2114 +
2115 +- hw->wiphy->flags &= ~WIPHY_FLAG_PS_ON_BY_DEFAULT;
2116 ++ if (AR_SREV_5416(ah))
2117 ++ hw->wiphy->flags &= ~WIPHY_FLAG_PS_ON_BY_DEFAULT;
2118 +
2119 + hw->queues = 4;
2120 + hw->max_rates = 4;
2121 +diff --git a/drivers/net/wireless/ath/ath9k/phy.h b/drivers/net/wireless/ath/ath9k/phy.h
2122 +index 31de27d..0999a49 100644
2123 +--- a/drivers/net/wireless/ath/ath9k/phy.h
2124 ++++ b/drivers/net/wireless/ath/ath9k/phy.h
2125 +@@ -384,6 +384,9 @@ bool ath9k_hw_set_rf_regs(struct ath_hw *ah,
2126 +
2127 + #define AR_PHY_HEAVY_CLIP_ENABLE 0x99E0
2128 +
2129 ++#define AR_PHY_HEAVY_CLIP_FACTOR_RIFS 0x99EC
2130 ++#define AR_PHY_RIFS_INIT_DELAY 0x03ff0000
2131 ++
2132 + #define AR_PHY_M_SLEEP 0x99f0
2133 + #define AR_PHY_REFCLKDLY 0x99f4
2134 + #define AR_PHY_REFCLKPD 0x99f8
2135 +diff --git a/drivers/net/wireless/ath/ath9k/rc.c b/drivers/net/wireless/ath/ath9k/rc.c
2136 +index 70fdb9d..1d6cf7d 100644
2137 +--- a/drivers/net/wireless/ath/ath9k/rc.c
2138 ++++ b/drivers/net/wireless/ath/ath9k/rc.c
2139 +@@ -668,7 +668,7 @@ static void ath_get_rate(void *priv, struct ieee80211_sta *sta, void *priv_sta,
2140 + struct ieee80211_tx_rate *rates = tx_info->control.rates;
2141 + struct ieee80211_hdr *hdr = (struct ieee80211_hdr *)skb->data;
2142 + __le16 fc = hdr->frame_control;
2143 +- u8 try_per_rate, i = 0, rix, nrix;
2144 ++ u8 try_per_rate, i = 0, rix;
2145 + int is_probe = 0;
2146 +
2147 + if (rate_control_send_low(sta, priv_sta, txrc))
2148 +@@ -688,26 +688,25 @@ static void ath_get_rate(void *priv, struct ieee80211_sta *sta, void *priv_sta,
2149 +
2150 + rate_table = sc->cur_rate_table;
2151 + rix = ath_rc_get_highest_rix(sc, ath_rc_priv, rate_table, &is_probe);
2152 +- nrix = rix;
2153 +
2154 + if (is_probe) {
2155 + /* set one try for probe rates. For the
2156 + * probes don't enable rts */
2157 + ath_rc_rate_set_series(rate_table, &rates[i++], txrc,
2158 +- 1, nrix, 0);
2159 ++ 1, rix, 0);
2160 +
2161 + /* Get the next tried/allowed rate. No RTS for the next series
2162 + * after the probe rate
2163 + */
2164 +- ath_rc_get_lower_rix(rate_table, ath_rc_priv, rix, &nrix);
2165 ++ ath_rc_get_lower_rix(rate_table, ath_rc_priv, rix, &rix);
2166 + ath_rc_rate_set_series(rate_table, &rates[i++], txrc,
2167 +- try_per_rate, nrix, 0);
2168 ++ try_per_rate, rix, 0);
2169 +
2170 + tx_info->flags |= IEEE80211_TX_CTL_RATE_CTRL_PROBE;
2171 + } else {
2172 + /* Set the choosen rate. No RTS for first series entry. */
2173 + ath_rc_rate_set_series(rate_table, &rates[i++], txrc,
2174 +- try_per_rate, nrix, 0);
2175 ++ try_per_rate, rix, 0);
2176 + }
2177 +
2178 + /* Fill in the other rates for multirate retry */
2179 +@@ -716,10 +715,10 @@ static void ath_get_rate(void *priv, struct ieee80211_sta *sta, void *priv_sta,
2180 + if (i + 1 == 4)
2181 + try_per_rate = 4;
2182 +
2183 +- ath_rc_get_lower_rix(rate_table, ath_rc_priv, rix, &nrix);
2184 ++ ath_rc_get_lower_rix(rate_table, ath_rc_priv, rix, &rix);
2185 + /* All other rates in the series have RTS enabled */
2186 + ath_rc_rate_set_series(rate_table, &rates[i], txrc,
2187 +- try_per_rate, nrix, 1);
2188 ++ try_per_rate, rix, 1);
2189 + }
2190 +
2191 + /*
2192 +diff --git a/drivers/net/wireless/b43/main.c b/drivers/net/wireless/b43/main.c
2193 +index 490fb45..b59166c 100644
2194 +--- a/drivers/net/wireless/b43/main.c
2195 ++++ b/drivers/net/wireless/b43/main.c
2196 +@@ -3970,6 +3970,7 @@ static int b43_wireless_core_start(struct b43_wldev *dev)
2197 + }
2198 +
2199 + /* We are ready to run. */
2200 ++ ieee80211_wake_queues(dev->wl->hw);
2201 + b43_set_status(dev, B43_STAT_STARTED);
2202 +
2203 + /* Start data flow (TX/RX). */
2204 +@@ -4379,8 +4380,6 @@ static int b43_wireless_core_init(struct b43_wldev *dev)
2205 +
2206 + ieee80211_wake_queues(dev->wl->hw);
2207 +
2208 +- ieee80211_wake_queues(dev->wl->hw);
2209 +-
2210 + b43_set_status(dev, B43_STAT_INITIALIZED);
2211 +
2212 + out:
2213 +diff --git a/drivers/net/wireless/b43legacy/main.c b/drivers/net/wireless/b43legacy/main.c
2214 +index 4a905b6..6d21b49 100644
2215 +--- a/drivers/net/wireless/b43legacy/main.c
2216 ++++ b/drivers/net/wireless/b43legacy/main.c
2217 +@@ -2921,6 +2921,7 @@ static int b43legacy_wireless_core_start(struct b43legacy_wldev *dev)
2218 + goto out;
2219 + }
2220 + /* We are ready to run. */
2221 ++ ieee80211_wake_queues(dev->wl->hw);
2222 + b43legacy_set_status(dev, B43legacy_STAT_STARTED);
2223 +
2224 + /* Start data flow (TX/RX) */
2225 +@@ -3341,6 +3342,7 @@ static int b43legacy_wireless_core_init(struct b43legacy_wldev *dev)
2226 + b43legacy_security_init(dev);
2227 + b43legacy_rng_init(wl);
2228 +
2229 ++ ieee80211_wake_queues(dev->wl->hw);
2230 + b43legacy_set_status(dev, B43legacy_STAT_INITIALIZED);
2231 +
2232 + b43legacy_leds_init(dev);
2233 +diff --git a/drivers/net/wireless/p54/p54pci.c b/drivers/net/wireless/p54/p54pci.c
2234 +index a72f7c2..4bf4c21 100644
2235 +--- a/drivers/net/wireless/p54/p54pci.c
2236 ++++ b/drivers/net/wireless/p54/p54pci.c
2237 +@@ -157,6 +157,14 @@ static void p54p_refill_rx_ring(struct ieee80211_hw *dev,
2238 + skb_tail_pointer(skb),
2239 + priv->common.rx_mtu + 32,
2240 + PCI_DMA_FROMDEVICE);
2241 ++
2242 ++ if (pci_dma_mapping_error(priv->pdev, mapping)) {
2243 ++ dev_kfree_skb_any(skb);
2244 ++ dev_err(&priv->pdev->dev,
2245 ++ "RX DMA Mapping error\n");
2246 ++ break;
2247 ++ }
2248 ++
2249 + desc->host_addr = cpu_to_le32(mapping);
2250 + desc->device_addr = 0; // FIXME: necessary?
2251 + desc->len = cpu_to_le16(priv->common.rx_mtu + 32);
2252 +@@ -325,14 +333,20 @@ static void p54p_tx(struct ieee80211_hw *dev, struct sk_buff *skb)
2253 + u32 device_idx, idx, i;
2254 +
2255 + spin_lock_irqsave(&priv->lock, flags);
2256 +-
2257 + device_idx = le32_to_cpu(ring_control->device_idx[1]);
2258 + idx = le32_to_cpu(ring_control->host_idx[1]);
2259 + i = idx % ARRAY_SIZE(ring_control->tx_data);
2260 +
2261 +- priv->tx_buf_data[i] = skb;
2262 + mapping = pci_map_single(priv->pdev, skb->data, skb->len,
2263 + PCI_DMA_TODEVICE);
2264 ++ if (pci_dma_mapping_error(priv->pdev, mapping)) {
2265 ++ spin_unlock_irqrestore(&priv->lock, flags);
2266 ++ p54_free_skb(dev, skb);
2267 ++ dev_err(&priv->pdev->dev, "TX DMA mapping error\n");
2268 ++ return ;
2269 ++ }
2270 ++ priv->tx_buf_data[i] = skb;
2271 ++
2272 + desc = &ring_control->tx_data[i];
2273 + desc->host_addr = cpu_to_le32(mapping);
2274 + desc->device_addr = ((struct p54_hdr *)skb->data)->req_id;
2275 +diff --git a/drivers/net/wireless/p54/p54usb.c b/drivers/net/wireless/p54/p54usb.c
2276 +index 92af9b9..8742640 100644
2277 +--- a/drivers/net/wireless/p54/p54usb.c
2278 ++++ b/drivers/net/wireless/p54/p54usb.c
2279 +@@ -60,6 +60,7 @@ static struct usb_device_id p54u_table[] __devinitdata = {
2280 + {USB_DEVICE(0x06b9, 0x0121)}, /* Thomson SpeedTouch 121g */
2281 + {USB_DEVICE(0x0707, 0xee13)}, /* SMC 2862W-G version 2 */
2282 + {USB_DEVICE(0x083a, 0x4521)}, /* Siemens Gigaset USB Adapter 54 version 2 */
2283 ++ {USB_DEVICE(0x083a, 0xf503)}, /* Accton FD7050E ver 1010ec */
2284 + {USB_DEVICE(0x0846, 0x4240)}, /* Netgear WG111 (v2) */
2285 + {USB_DEVICE(0x0915, 0x2000)}, /* Cohiba Proto board */
2286 + {USB_DEVICE(0x0915, 0x2002)}, /* Cohiba Proto board */
2287 +diff --git a/drivers/pci/hotplug/ibmphp_ebda.c b/drivers/pci/hotplug/ibmphp_ebda.c
2288 +index c1abac8..5becbde 100644
2289 +--- a/drivers/pci/hotplug/ibmphp_ebda.c
2290 ++++ b/drivers/pci/hotplug/ibmphp_ebda.c
2291 +@@ -245,7 +245,7 @@ static void __init print_ebda_hpc (void)
2292 +
2293 + int __init ibmphp_access_ebda (void)
2294 + {
2295 +- u8 format, num_ctlrs, rio_complete, hs_complete;
2296 ++ u8 format, num_ctlrs, rio_complete, hs_complete, ebda_sz;
2297 + u16 ebda_seg, num_entries, next_offset, offset, blk_id, sub_addr, re, rc_id, re_id, base;
2298 + int rc = 0;
2299 +
2300 +@@ -260,7 +260,16 @@ int __init ibmphp_access_ebda (void)
2301 + iounmap (io_mem);
2302 + debug ("returned ebda segment: %x\n", ebda_seg);
2303 +
2304 +- io_mem = ioremap(ebda_seg<<4, 1024);
2305 ++ io_mem = ioremap(ebda_seg<<4, 1);
2306 ++ if (!io_mem)
2307 ++ return -ENOMEM;
2308 ++ ebda_sz = readb(io_mem);
2309 ++ iounmap(io_mem);
2310 ++ debug("ebda size: %d(KiB)\n", ebda_sz);
2311 ++ if (ebda_sz == 0)
2312 ++ return -ENOMEM;
2313 ++
2314 ++ io_mem = ioremap(ebda_seg<<4, (ebda_sz * 1024));
2315 + if (!io_mem )
2316 + return -ENOMEM;
2317 + next_offset = 0x180;
2318 +diff --git a/drivers/platform/x86/Kconfig b/drivers/platform/x86/Kconfig
2319 +index f526e73..11fce79 100644
2320 +--- a/drivers/platform/x86/Kconfig
2321 ++++ b/drivers/platform/x86/Kconfig
2322 +@@ -319,9 +319,15 @@ config THINKPAD_ACPI_VIDEO
2323 + server running, phase of the moon, and the current mood of
2324 + Schroedinger's cat. If you can use X.org's RandR to control
2325 + your ThinkPad's video output ports instead of this feature,
2326 +- don't think twice: do it and say N here to save some memory.
2327 ++ don't think twice: do it and say N here to save memory and avoid
2328 ++ bad interactions with X.org.
2329 +
2330 +- If you are not sure, say Y here.
2331 ++ NOTE: access to this feature is limited to processes with the
2332 ++ CAP_SYS_ADMIN capability, to avoid local DoS issues in platforms
2333 ++ where it interacts badly with X.org.
2334 ++
2335 ++ If you are not sure, say Y here but do try to check if you could
2336 ++ be using X.org RandR instead.
2337 +
2338 + config THINKPAD_ACPI_HOTKEY_POLL
2339 + bool "Support NVRAM polling for hot keys"
2340 +diff --git a/drivers/platform/x86/eeepc-laptop.c b/drivers/platform/x86/eeepc-laptop.c
2341 +index e2be6bb..6a47bb7 100644
2342 +--- a/drivers/platform/x86/eeepc-laptop.c
2343 ++++ b/drivers/platform/x86/eeepc-laptop.c
2344 +@@ -1277,7 +1277,8 @@ static void eeepc_dmi_check(struct eeepc_laptop *eeepc)
2345 + * hotplug code. In fact, current hotplug code seems to unplug another
2346 + * device...
2347 + */
2348 +- if (strcmp(model, "1005HA") == 0 || strcmp(model, "1201N") == 0) {
2349 ++ if (strcmp(model, "1005HA") == 0 || strcmp(model, "1201N") == 0 ||
2350 ++ strcmp(model, "1005PE") == 0) {
2351 + eeepc->hotplug_disabled = true;
2352 + pr_info("wlan hotplug disabled\n");
2353 + }
2354 +diff --git a/drivers/platform/x86/thinkpad_acpi.c b/drivers/platform/x86/thinkpad_acpi.c
2355 +index eb603f1..e7b0c3b 100644
2356 +--- a/drivers/platform/x86/thinkpad_acpi.c
2357 ++++ b/drivers/platform/x86/thinkpad_acpi.c
2358 +@@ -286,6 +286,7 @@ struct ibm_init_struct {
2359 + char param[32];
2360 +
2361 + int (*init) (struct ibm_init_struct *);
2362 ++ mode_t base_procfs_mode;
2363 + struct ibm_struct *data;
2364 + };
2365 +
2366 +@@ -2082,6 +2083,7 @@ static struct attribute_set *hotkey_dev_attributes;
2367 +
2368 + static void tpacpi_driver_event(const unsigned int hkey_event);
2369 + static void hotkey_driver_event(const unsigned int scancode);
2370 ++static void hotkey_poll_setup(const bool may_warn);
2371 +
2372 + /* HKEY.MHKG() return bits */
2373 + #define TP_HOTKEY_TABLET_MASK (1 << 3)
2374 +@@ -2264,6 +2266,8 @@ static int tpacpi_hotkey_driver_mask_set(const u32 mask)
2375 +
2376 + rc = hotkey_mask_set((hotkey_acpi_mask | hotkey_driver_mask) &
2377 + ~hotkey_source_mask);
2378 ++ hotkey_poll_setup(true);
2379 ++
2380 + mutex_unlock(&hotkey_mutex);
2381 +
2382 + return rc;
2383 +@@ -2548,7 +2552,7 @@ static void hotkey_poll_stop_sync(void)
2384 + }
2385 +
2386 + /* call with hotkey_mutex held */
2387 +-static void hotkey_poll_setup(bool may_warn)
2388 ++static void hotkey_poll_setup(const bool may_warn)
2389 + {
2390 + const u32 poll_driver_mask = hotkey_driver_mask & hotkey_source_mask;
2391 + const u32 poll_user_mask = hotkey_user_mask & hotkey_source_mask;
2392 +@@ -2579,7 +2583,7 @@ static void hotkey_poll_setup(bool may_warn)
2393 + }
2394 + }
2395 +
2396 +-static void hotkey_poll_setup_safe(bool may_warn)
2397 ++static void hotkey_poll_setup_safe(const bool may_warn)
2398 + {
2399 + mutex_lock(&hotkey_mutex);
2400 + hotkey_poll_setup(may_warn);
2401 +@@ -2597,7 +2601,11 @@ static void hotkey_poll_set_freq(unsigned int freq)
2402 +
2403 + #else /* CONFIG_THINKPAD_ACPI_HOTKEY_POLL */
2404 +
2405 +-static void hotkey_poll_setup_safe(bool __unused)
2406 ++static void hotkey_poll_setup(const bool __unused)
2407 ++{
2408 ++}
2409 ++
2410 ++static void hotkey_poll_setup_safe(const bool __unused)
2411 + {
2412 + }
2413 +
2414 +@@ -2607,16 +2615,11 @@ static int hotkey_inputdev_open(struct input_dev *dev)
2415 + {
2416 + switch (tpacpi_lifecycle) {
2417 + case TPACPI_LIFE_INIT:
2418 +- /*
2419 +- * hotkey_init will call hotkey_poll_setup_safe
2420 +- * at the appropriate moment
2421 +- */
2422 +- return 0;
2423 +- case TPACPI_LIFE_EXITING:
2424 +- return -EBUSY;
2425 + case TPACPI_LIFE_RUNNING:
2426 + hotkey_poll_setup_safe(false);
2427 + return 0;
2428 ++ case TPACPI_LIFE_EXITING:
2429 ++ return -EBUSY;
2430 + }
2431 +
2432 + /* Should only happen if tpacpi_lifecycle is corrupt */
2433 +@@ -2627,7 +2630,7 @@ static int hotkey_inputdev_open(struct input_dev *dev)
2434 + static void hotkey_inputdev_close(struct input_dev *dev)
2435 + {
2436 + /* disable hotkey polling when possible */
2437 +- if (tpacpi_lifecycle == TPACPI_LIFE_RUNNING &&
2438 ++ if (tpacpi_lifecycle != TPACPI_LIFE_EXITING &&
2439 + !(hotkey_source_mask & hotkey_driver_mask))
2440 + hotkey_poll_setup_safe(false);
2441 + }
2442 +@@ -3655,13 +3658,19 @@ static void hotkey_notify(struct ibm_struct *ibm, u32 event)
2443 + break;
2444 + case 3:
2445 + /* 0x3000-0x3FFF: bay-related wakeups */
2446 +- if (hkey == TP_HKEY_EV_BAYEJ_ACK) {
2447 ++ switch (hkey) {
2448 ++ case TP_HKEY_EV_BAYEJ_ACK:
2449 + hotkey_autosleep_ack = 1;
2450 + printk(TPACPI_INFO
2451 + "bay ejected\n");
2452 + hotkey_wakeup_hotunplug_complete_notify_change();
2453 + known_ev = true;
2454 +- } else {
2455 ++ break;
2456 ++ case TP_HKEY_EV_OPTDRV_EJ:
2457 ++ /* FIXME: kick libata if SATA link offline */
2458 ++ known_ev = true;
2459 ++ break;
2460 ++ default:
2461 + known_ev = false;
2462 + }
2463 + break;
2464 +@@ -3870,7 +3879,7 @@ enum {
2465 + TP_ACPI_BLUETOOTH_HWPRESENT = 0x01, /* Bluetooth hw available */
2466 + TP_ACPI_BLUETOOTH_RADIOSSW = 0x02, /* Bluetooth radio enabled */
2467 + TP_ACPI_BLUETOOTH_RESUMECTRL = 0x04, /* Bluetooth state at resume:
2468 +- off / last state */
2469 ++ 0 = disable, 1 = enable */
2470 + };
2471 +
2472 + enum {
2473 +@@ -3916,10 +3925,11 @@ static int bluetooth_set_status(enum tpacpi_rfkill_state state)
2474 + }
2475 + #endif
2476 +
2477 +- /* We make sure to keep TP_ACPI_BLUETOOTH_RESUMECTRL off */
2478 +- status = TP_ACPI_BLUETOOTH_RESUMECTRL;
2479 + if (state == TPACPI_RFK_RADIO_ON)
2480 +- status |= TP_ACPI_BLUETOOTH_RADIOSSW;
2481 ++ status = TP_ACPI_BLUETOOTH_RADIOSSW
2482 ++ | TP_ACPI_BLUETOOTH_RESUMECTRL;
2483 ++ else
2484 ++ status = 0;
2485 +
2486 + if (!acpi_evalf(hkey_handle, NULL, "SBDC", "vd", status))
2487 + return -EIO;
2488 +@@ -4070,7 +4080,7 @@ enum {
2489 + TP_ACPI_WANCARD_HWPRESENT = 0x01, /* Wan hw available */
2490 + TP_ACPI_WANCARD_RADIOSSW = 0x02, /* Wan radio enabled */
2491 + TP_ACPI_WANCARD_RESUMECTRL = 0x04, /* Wan state at resume:
2492 +- off / last state */
2493 ++ 0 = disable, 1 = enable */
2494 + };
2495 +
2496 + #define TPACPI_RFK_WWAN_SW_NAME "tpacpi_wwan_sw"
2497 +@@ -4107,10 +4117,11 @@ static int wan_set_status(enum tpacpi_rfkill_state state)
2498 + }
2499 + #endif
2500 +
2501 +- /* We make sure to set TP_ACPI_WANCARD_RESUMECTRL */
2502 +- status = TP_ACPI_WANCARD_RESUMECTRL;
2503 + if (state == TPACPI_RFK_RADIO_ON)
2504 +- status |= TP_ACPI_WANCARD_RADIOSSW;
2505 ++ status = TP_ACPI_WANCARD_RADIOSSW
2506 ++ | TP_ACPI_WANCARD_RESUMECTRL;
2507 ++ else
2508 ++ status = 0;
2509 +
2510 + if (!acpi_evalf(hkey_handle, NULL, "SWAN", "vd", status))
2511 + return -EIO;
2512 +@@ -4619,6 +4630,10 @@ static int video_read(struct seq_file *m)
2513 + return 0;
2514 + }
2515 +
2516 ++ /* Even reads can crash X.org, so... */
2517 ++ if (!capable(CAP_SYS_ADMIN))
2518 ++ return -EPERM;
2519 ++
2520 + status = video_outputsw_get();
2521 + if (status < 0)
2522 + return status;
2523 +@@ -4652,6 +4667,10 @@ static int video_write(char *buf)
2524 + if (video_supported == TPACPI_VIDEO_NONE)
2525 + return -ENODEV;
2526 +
2527 ++ /* Even reads can crash X.org, let alone writes... */
2528 ++ if (!capable(CAP_SYS_ADMIN))
2529 ++ return -EPERM;
2530 ++
2531 + enable = 0;
2532 + disable = 0;
2533 +
2534 +@@ -6133,13 +6152,13 @@ static const struct tpacpi_quirk brightness_quirk_table[] __initconst = {
2535 + TPACPI_Q_IBM('1', 'Y', TPACPI_BRGHT_Q_EC), /* T43/p ATI */
2536 +
2537 + /* Models with ATI GPUs that can use ECNVRAM */
2538 +- TPACPI_Q_IBM('1', 'R', TPACPI_BRGHT_Q_EC),
2539 ++ TPACPI_Q_IBM('1', 'R', TPACPI_BRGHT_Q_EC), /* R50,51 T40-42 */
2540 + TPACPI_Q_IBM('1', 'Q', TPACPI_BRGHT_Q_ASK|TPACPI_BRGHT_Q_EC),
2541 +- TPACPI_Q_IBM('7', '6', TPACPI_BRGHT_Q_ASK|TPACPI_BRGHT_Q_EC),
2542 ++ TPACPI_Q_IBM('7', '6', TPACPI_BRGHT_Q_EC), /* R52 */
2543 + TPACPI_Q_IBM('7', '8', TPACPI_BRGHT_Q_ASK|TPACPI_BRGHT_Q_EC),
2544 +
2545 + /* Models with Intel Extreme Graphics 2 */
2546 +- TPACPI_Q_IBM('1', 'U', TPACPI_BRGHT_Q_NOEC),
2547 ++ TPACPI_Q_IBM('1', 'U', TPACPI_BRGHT_Q_NOEC), /* X40 */
2548 + TPACPI_Q_IBM('1', 'V', TPACPI_BRGHT_Q_ASK|TPACPI_BRGHT_Q_EC),
2549 + TPACPI_Q_IBM('1', 'W', TPACPI_BRGHT_Q_ASK|TPACPI_BRGHT_Q_EC),
2550 +
2551 +@@ -6522,7 +6541,8 @@ static int volume_set_status(const u8 status)
2552 + return volume_set_status_ec(status);
2553 + }
2554 +
2555 +-static int volume_set_mute_ec(const bool mute)
2556 ++/* returns < 0 on error, 0 on no change, 1 on change */
2557 ++static int __volume_set_mute_ec(const bool mute)
2558 + {
2559 + int rc;
2560 + u8 s, n;
2561 +@@ -6537,22 +6557,37 @@ static int volume_set_mute_ec(const bool mute)
2562 + n = (mute) ? s | TP_EC_AUDIO_MUTESW_MSK :
2563 + s & ~TP_EC_AUDIO_MUTESW_MSK;
2564 +
2565 +- if (n != s)
2566 ++ if (n != s) {
2567 + rc = volume_set_status_ec(n);
2568 ++ if (!rc)
2569 ++ rc = 1;
2570 ++ }
2571 +
2572 + unlock:
2573 + mutex_unlock(&volume_mutex);
2574 + return rc;
2575 + }
2576 +
2577 ++static int volume_alsa_set_mute(const bool mute)
2578 ++{
2579 ++ dbg_printk(TPACPI_DBG_MIXER, "ALSA: trying to %smute\n",
2580 ++ (mute) ? "" : "un");
2581 ++ return __volume_set_mute_ec(mute);
2582 ++}
2583 ++
2584 + static int volume_set_mute(const bool mute)
2585 + {
2586 ++ int rc;
2587 ++
2588 + dbg_printk(TPACPI_DBG_MIXER, "trying to %smute\n",
2589 + (mute) ? "" : "un");
2590 +- return volume_set_mute_ec(mute);
2591 ++
2592 ++ rc = __volume_set_mute_ec(mute);
2593 ++ return (rc < 0) ? rc : 0;
2594 + }
2595 +
2596 +-static int volume_set_volume_ec(const u8 vol)
2597 ++/* returns < 0 on error, 0 on no change, 1 on change */
2598 ++static int __volume_set_volume_ec(const u8 vol)
2599 + {
2600 + int rc;
2601 + u8 s, n;
2602 +@@ -6569,19 +6604,22 @@ static int volume_set_volume_ec(const u8 vol)
2603 +
2604 + n = (s & ~TP_EC_AUDIO_LVL_MSK) | vol;
2605 +
2606 +- if (n != s)
2607 ++ if (n != s) {
2608 + rc = volume_set_status_ec(n);
2609 ++ if (!rc)
2610 ++ rc = 1;
2611 ++ }
2612 +
2613 + unlock:
2614 + mutex_unlock(&volume_mutex);
2615 + return rc;
2616 + }
2617 +
2618 +-static int volume_set_volume(const u8 vol)
2619 ++static int volume_alsa_set_volume(const u8 vol)
2620 + {
2621 + dbg_printk(TPACPI_DBG_MIXER,
2622 +- "trying to set volume level to %hu\n", vol);
2623 +- return volume_set_volume_ec(vol);
2624 ++ "ALSA: trying to set volume level to %hu\n", vol);
2625 ++ return __volume_set_volume_ec(vol);
2626 + }
2627 +
2628 + static void volume_alsa_notify_change(void)
2629 +@@ -6628,7 +6666,7 @@ static int volume_alsa_vol_get(struct snd_kcontrol *kcontrol,
2630 + static int volume_alsa_vol_put(struct snd_kcontrol *kcontrol,
2631 + struct snd_ctl_elem_value *ucontrol)
2632 + {
2633 +- return volume_set_volume(ucontrol->value.integer.value[0]);
2634 ++ return volume_alsa_set_volume(ucontrol->value.integer.value[0]);
2635 + }
2636 +
2637 + #define volume_alsa_mute_info snd_ctl_boolean_mono_info
2638 +@@ -6651,7 +6689,7 @@ static int volume_alsa_mute_get(struct snd_kcontrol *kcontrol,
2639 + static int volume_alsa_mute_put(struct snd_kcontrol *kcontrol,
2640 + struct snd_ctl_elem_value *ucontrol)
2641 + {
2642 +- return volume_set_mute(!ucontrol->value.integer.value[0]);
2643 ++ return volume_alsa_set_mute(!ucontrol->value.integer.value[0]);
2644 + }
2645 +
2646 + static struct snd_kcontrol_new volume_alsa_control_vol __devinitdata = {
2647 +@@ -8477,9 +8515,10 @@ static int __init ibm_init(struct ibm_init_struct *iibm)
2648 + "%s installed\n", ibm->name);
2649 +
2650 + if (ibm->read) {
2651 +- mode_t mode;
2652 ++ mode_t mode = iibm->base_procfs_mode;
2653 +
2654 +- mode = S_IRUGO;
2655 ++ if (!mode)
2656 ++ mode = S_IRUGO;
2657 + if (ibm->write)
2658 + mode |= S_IWUSR;
2659 + entry = proc_create_data(ibm->name, mode, proc_dir,
2660 +@@ -8670,6 +8709,7 @@ static struct ibm_init_struct ibms_init[] __initdata = {
2661 + #ifdef CONFIG_THINKPAD_ACPI_VIDEO
2662 + {
2663 + .init = video_init,
2664 ++ .base_procfs_mode = S_IRUSR,
2665 + .data = &video_driver_data,
2666 + },
2667 + #endif
2668 +@@ -9032,6 +9072,9 @@ static int __init thinkpad_acpi_module_init(void)
2669 + return ret;
2670 + }
2671 + }
2672 ++
2673 ++ tpacpi_lifecycle = TPACPI_LIFE_RUNNING;
2674 ++
2675 + ret = input_register_device(tpacpi_inputdev);
2676 + if (ret < 0) {
2677 + printk(TPACPI_ERR "unable to register input device\n");
2678 +@@ -9041,7 +9084,6 @@ static int __init thinkpad_acpi_module_init(void)
2679 + tp_features.input_device_registered = 1;
2680 + }
2681 +
2682 +- tpacpi_lifecycle = TPACPI_LIFE_RUNNING;
2683 + return 0;
2684 + }
2685 +
2686 +diff --git a/drivers/rtc/class.c b/drivers/rtc/class.c
2687 +index be5a6b7..40845c7 100644
2688 +--- a/drivers/rtc/class.c
2689 ++++ b/drivers/rtc/class.c
2690 +@@ -226,6 +226,7 @@ static void __exit rtc_exit(void)
2691 + {
2692 + rtc_dev_exit();
2693 + class_destroy(rtc_class);
2694 ++ idr_destroy(&rtc_idr);
2695 + }
2696 +
2697 + subsys_initcall(rtc_init);
2698 +diff --git a/drivers/rtc/rtc-coh901331.c b/drivers/rtc/rtc-coh901331.c
2699 +index 03ea530..44c4399 100644
2700 +--- a/drivers/rtc/rtc-coh901331.c
2701 ++++ b/drivers/rtc/rtc-coh901331.c
2702 +@@ -271,12 +271,13 @@ static int coh901331_resume(struct platform_device *pdev)
2703 + {
2704 + struct coh901331_port *rtap = dev_get_drvdata(&pdev->dev);
2705 +
2706 +- if (device_may_wakeup(&pdev->dev))
2707 ++ if (device_may_wakeup(&pdev->dev)) {
2708 + disable_irq_wake(rtap->irq);
2709 +- else
2710 ++ } else {
2711 + clk_enable(rtap->clk);
2712 + writel(rtap->irqmaskstore, rtap->virtbase + COH901331_IRQ_MASK);
2713 + clk_disable(rtap->clk);
2714 ++ }
2715 + return 0;
2716 + }
2717 + #else
2718 +diff --git a/drivers/scsi/mpt2sas/mpt2sas_scsih.c b/drivers/scsi/mpt2sas/mpt2sas_scsih.c
2719 +index efabea1..cd55176 100644
2720 +--- a/drivers/scsi/mpt2sas/mpt2sas_scsih.c
2721 ++++ b/drivers/scsi/mpt2sas/mpt2sas_scsih.c
2722 +@@ -5998,6 +5998,8 @@ _scsih_remove(struct pci_dev *pdev)
2723 + struct _sas_port *mpt2sas_port;
2724 + struct _sas_device *sas_device;
2725 + struct _sas_node *expander_sibling;
2726 ++ struct _raid_device *raid_device, *next;
2727 ++ struct MPT2SAS_TARGET *sas_target_priv_data;
2728 + struct workqueue_struct *wq;
2729 + unsigned long flags;
2730 +
2731 +@@ -6011,6 +6013,21 @@ _scsih_remove(struct pci_dev *pdev)
2732 + if (wq)
2733 + destroy_workqueue(wq);
2734 +
2735 ++ /* release all the volumes */
2736 ++ list_for_each_entry_safe(raid_device, next, &ioc->raid_device_list,
2737 ++ list) {
2738 ++ if (raid_device->starget) {
2739 ++ sas_target_priv_data =
2740 ++ raid_device->starget->hostdata;
2741 ++ sas_target_priv_data->deleted = 1;
2742 ++ scsi_remove_target(&raid_device->starget->dev);
2743 ++ }
2744 ++ printk(MPT2SAS_INFO_FMT "removing handle(0x%04x), wwid"
2745 ++ "(0x%016llx)\n", ioc->name, raid_device->handle,
2746 ++ (unsigned long long) raid_device->wwid);
2747 ++ _scsih_raid_device_remove(ioc, raid_device);
2748 ++ }
2749 ++
2750 + /* free ports attached to the sas_host */
2751 + retry_again:
2752 + list_for_each_entry(mpt2sas_port,
2753 +diff --git a/drivers/scsi/qla1280.c b/drivers/scsi/qla1280.c
2754 +index 8371d91..49ac414 100644
2755 +--- a/drivers/scsi/qla1280.c
2756 ++++ b/drivers/scsi/qla1280.c
2757 +@@ -1640,8 +1640,10 @@ qla1280_load_firmware_pio(struct scsi_qla_host *ha)
2758 + uint16_t mb[MAILBOX_REGISTER_COUNT], i;
2759 + int err;
2760 +
2761 ++ spin_unlock_irq(ha->host->host_lock);
2762 + err = request_firmware(&fw, ql1280_board_tbl[ha->devnum].fwname,
2763 + &ha->pdev->dev);
2764 ++ spin_lock_irq(ha->host->host_lock);
2765 + if (err) {
2766 + printk(KERN_ERR "Failed to load image \"%s\" err %d\n",
2767 + ql1280_board_tbl[ha->devnum].fwname, err);
2768 +@@ -1699,8 +1701,10 @@ qla1280_load_firmware_dma(struct scsi_qla_host *ha)
2769 + return -ENOMEM;
2770 + #endif
2771 +
2772 ++ spin_unlock_irq(ha->host->host_lock);
2773 + err = request_firmware(&fw, ql1280_board_tbl[ha->devnum].fwname,
2774 + &ha->pdev->dev);
2775 ++ spin_lock_irq(ha->host->host_lock);
2776 + if (err) {
2777 + printk(KERN_ERR "Failed to load image \"%s\" err %d\n",
2778 + ql1280_board_tbl[ha->devnum].fwname, err);
2779 +diff --git a/drivers/serial/imx.c b/drivers/serial/imx.c
2780 +index 60d665a..d00fcf8 100644
2781 +--- a/drivers/serial/imx.c
2782 ++++ b/drivers/serial/imx.c
2783 +@@ -1279,7 +1279,7 @@ static int serial_imx_probe(struct platform_device *pdev)
2784 + sport->use_irda = 1;
2785 + #endif
2786 +
2787 +- if (pdata->init) {
2788 ++ if (pdata && pdata->init) {
2789 + ret = pdata->init(pdev);
2790 + if (ret)
2791 + goto clkput;
2792 +@@ -1292,7 +1292,7 @@ static int serial_imx_probe(struct platform_device *pdev)
2793 +
2794 + return 0;
2795 + deinit:
2796 +- if (pdata->exit)
2797 ++ if (pdata && pdata->exit)
2798 + pdata->exit(pdev);
2799 + clkput:
2800 + clk_put(sport->clk);
2801 +@@ -1321,7 +1321,7 @@ static int serial_imx_remove(struct platform_device *pdev)
2802 +
2803 + clk_disable(sport->clk);
2804 +
2805 +- if (pdata->exit)
2806 ++ if (pdata && pdata->exit)
2807 + pdata->exit(pdev);
2808 +
2809 + iounmap(sport->port.membase);
2810 +diff --git a/drivers/staging/Kconfig b/drivers/staging/Kconfig
2811 +index fc2e963..ed77d88 100644
2812 +--- a/drivers/staging/Kconfig
2813 ++++ b/drivers/staging/Kconfig
2814 +@@ -81,8 +81,6 @@ source "drivers/staging/rtl8192u/Kconfig"
2815 +
2816 + source "drivers/staging/rtl8192e/Kconfig"
2817 +
2818 +-source "drivers/staging/mimio/Kconfig"
2819 +-
2820 + source "drivers/staging/frontier/Kconfig"
2821 +
2822 + source "drivers/staging/dream/Kconfig"
2823 +diff --git a/drivers/staging/Makefile b/drivers/staging/Makefile
2824 +index b5e67b8..6035bff 100644
2825 +--- a/drivers/staging/Makefile
2826 ++++ b/drivers/staging/Makefile
2827 +@@ -23,7 +23,6 @@ obj-$(CONFIG_R8187SE) += rtl8187se/
2828 + obj-$(CONFIG_RTL8192SU) += rtl8192su/
2829 + obj-$(CONFIG_RTL8192U) += rtl8192u/
2830 + obj-$(CONFIG_RTL8192E) += rtl8192e/
2831 +-obj-$(CONFIG_INPUT_MIMIO) += mimio/
2832 + obj-$(CONFIG_TRANZPORT) += frontier/
2833 + obj-$(CONFIG_DREAM) += dream/
2834 + obj-$(CONFIG_POHMELFS) += pohmelfs/
2835 +diff --git a/drivers/staging/hv/vmbus_drv.c b/drivers/staging/hv/vmbus_drv.c
2836 +index 894eecf..6acc49a 100644
2837 +--- a/drivers/staging/hv/vmbus_drv.c
2838 ++++ b/drivers/staging/hv/vmbus_drv.c
2839 +@@ -24,6 +24,8 @@
2840 + #include <linux/irq.h>
2841 + #include <linux/interrupt.h>
2842 + #include <linux/sysctl.h>
2843 ++#include <linux/pci.h>
2844 ++#include <linux/dmi.h>
2845 + #include "osd.h"
2846 + #include "logging.h"
2847 + #include "vmbus.h"
2848 +@@ -946,6 +948,19 @@ static irqreturn_t vmbus_isr(int irq, void *dev_id)
2849 + }
2850 + }
2851 +
2852 ++static struct dmi_system_id __initdata microsoft_hv_dmi_table[] = {
2853 ++ {
2854 ++ .ident = "Hyper-V",
2855 ++ .matches = {
2856 ++ DMI_MATCH(DMI_SYS_VENDOR, "Microsoft Corporation"),
2857 ++ DMI_MATCH(DMI_PRODUCT_NAME, "Virtual Machine"),
2858 ++ DMI_MATCH(DMI_BOARD_NAME, "Virtual Machine"),
2859 ++ },
2860 ++ },
2861 ++ { },
2862 ++};
2863 ++MODULE_DEVICE_TABLE(dmi, microsoft_hv_dmi_table);
2864 ++
2865 + static int __init vmbus_init(void)
2866 + {
2867 + int ret = 0;
2868 +@@ -957,6 +972,9 @@ static int __init vmbus_init(void)
2869 + vmbus_loglevel, HIWORD(vmbus_loglevel), LOWORD(vmbus_loglevel));
2870 + /* Todo: it is used for loglevel, to be ported to new kernel. */
2871 +
2872 ++ if (!dmi_check_system(microsoft_hv_dmi_table))
2873 ++ return -ENODEV;
2874 ++
2875 + ret = vmbus_bus_init(VmbusInitialize);
2876 +
2877 + DPRINT_EXIT(VMBUS_DRV);
2878 +@@ -973,6 +991,18 @@ static void __exit vmbus_exit(void)
2879 + return;
2880 + }
2881 +
2882 ++/*
2883 ++ * We use a PCI table to determine if we should autoload this driver This is
2884 ++ * needed by distro tools to determine if the hyperv drivers should be
2885 ++ * installed and/or configured. We don't do anything else with the table, but
2886 ++ * it needs to be present.
2887 ++ */
2888 ++const static struct pci_device_id microsoft_hv_pci_table[] = {
2889 ++ { PCI_DEVICE(0x1414, 0x5353) }, /* VGA compatible controller */
2890 ++ { 0 }
2891 ++};
2892 ++MODULE_DEVICE_TABLE(pci, microsoft_hv_pci_table);
2893 ++
2894 + MODULE_LICENSE("GPL");
2895 + module_param(vmbus_irq, int, S_IRUGO);
2896 + module_param(vmbus_loglevel, int, S_IRUGO);
2897 +diff --git a/drivers/staging/mimio/Kconfig b/drivers/staging/mimio/Kconfig
2898 +deleted file mode 100644
2899 +index 505dcb2..0000000
2900 +--- a/drivers/staging/mimio/Kconfig
2901 ++++ /dev/null
2902 +@@ -1,10 +0,0 @@
2903 +-config INPUT_MIMIO
2904 +- tristate "Mimio Xi interactive whiteboard support"
2905 +- depends on USB && INPUT
2906 +- default N
2907 +- help
2908 +- Say Y here if you want to use a Mimio Xi interactive
2909 +- whiteboard device.
2910 +-
2911 +- To compile this driver as a module, choose M here: the
2912 +- module will be called mimio.
2913 +diff --git a/drivers/staging/mimio/Makefile b/drivers/staging/mimio/Makefile
2914 +deleted file mode 100644
2915 +index 77807ee..0000000
2916 +--- a/drivers/staging/mimio/Makefile
2917 ++++ /dev/null
2918 +@@ -1 +0,0 @@
2919 +-obj-$(CONFIG_INPUT_MIMIO) += mimio.o
2920 +diff --git a/drivers/staging/mimio/mimio.c b/drivers/staging/mimio/mimio.c
2921 +deleted file mode 100644
2922 +index 1ba8103..0000000
2923 +--- a/drivers/staging/mimio/mimio.c
2924 ++++ /dev/null
2925 +@@ -1,914 +0,0 @@
2926 +-/*
2927 +- * Hardware event => input event mapping:
2928 +- *
2929 +- *
2930 +- *
2931 +- input.h:#define BTN_TOOL_PEN 0x140 black
2932 +- input.h:#define BTN_TOOL_RUBBER 0x141 blue
2933 +- input.h:#define BTN_TOOL_BRUSH 0x142 green
2934 +- input.h:#define BTN_TOOL_PENCIL 0x143 red
2935 +- input.h:#define BTN_TOOL_AIRBRUSH 0x144 eraser
2936 +- input.h:#define BTN_TOOL_FINGER 0x145 small eraser
2937 +- input.h:#define BTN_TOOL_MOUSE 0x146 mimio interactive
2938 +- input.h:#define BTN_TOOL_LENS 0x147 mimio interactive but1
2939 +- input.h:#define LOCALBTN_TOOL_EXTRA1 0x14a mimio interactive but2 == BTN_TOUCH
2940 +- input.h:#define LOCALBTN_TOOL_EXTRA2 0x14b mimio extra pens (orange, brown, yellow, purple) == BTN_STYLUS
2941 +- input.h:#define LOCALBTN_TOOL_EXTRA3 0x14c unused == BTN_STYLUS2
2942 +- input.h:#define BTN_TOOL_DOUBLETAP 0x14d unused
2943 +- input.h:#define BTN_TOOL_TRIPLETAP 0x14e unused
2944 +- *
2945 +- * MIMIO_EV_PENDOWN(MIMIO_PEN_K) => EV_KEY BIT(BTN_TOOL_PEN)
2946 +- * MIMIO_EV_PENDOWN(MIMIO_PEN_B) => EV_KEY BIT(BTN_TOOL_RUBBER)
2947 +- * MIMIO_EV_PENDOWN(MIMIO_PEN_G) => EV_KEY BIT(BTN_TOOL_BRUSH)
2948 +- * MIMIO_EV_PENDOWN(MIMIO_PEN_R) => EV_KEY BIT(BTN_TOOL_PENCIL)
2949 +- * MIMIO_EV_PENDOWN(MIMIO_PEN_E) => EV_KEY BIT(BTN_TOOL_AIRBRUSH)
2950 +- * MIMIO_EV_PENDOWN(MIMIO_PEN_ES) => EV_KEY BIT(BTN_TOOL_FINGER)
2951 +- * MIMIO_EV_PENDOWN(MIMIO_PEN_I) => EV_KEY BIT(BTN_TOOL_MOUSE)
2952 +- * MIMIO_EV_PENDOWN(MIMIO_PEN_IL) => EV_KEY BIT(BTN_TOOL_LENS)
2953 +- * MIMIO_EV_PENDOWN(MIMIO_PEN_IR) => EV_KEY BIT(BTN_TOOL_DOUBLETAP)
2954 +- * MIMIO_EV_PENDOWN(MIMIO_PEN_EX) => EV_KEY BIT(BTN_TOOL_TRIPLETAP)
2955 +- * MIMIO_EV_PENDATA => EV_ABS BIT(ABS_X), BIT(ABS_Y)
2956 +- * MIMIO_EV_MEMRESET => EV_KEY BIT(BTN_0)
2957 +- * MIMIO_EV_ACC(ACC_NEWPAGE) => EV_KEY BIT(BTN_1)
2958 +- * MIMIO_EV_ACC(ACC_TAGPAGE) => EV_KEY BIT(BTN_2)
2959 +- * MIMIO_EV_ACC(ACC_PRINTPAGE) => EV_KEY BIT(BTN_3)
2960 +- * MIMIO_EV_ACC(ACC_MAXIMIZE) => EV_KEY BIT(BTN_4)
2961 +- * MIMIO_EV_ACC(ACC_FINDCTLPNL) => EV_KEY BIT(BTN_5)
2962 +- *
2963 +- *
2964 +- * open issues:
2965 +- * - cold-load of data captured when mimio in standalone mode not yet
2966 +- * supported; need to snoop Win32 box to see datastream for this.
2967 +- * - mimio mouse not yet supported; need to snoop Win32 box to see the
2968 +- * datastream for this.
2969 +- */
2970 +-#include <linux/kernel.h>
2971 +-#include <linux/init.h>
2972 +-#include <linux/slab.h>
2973 +-#include <linux/spinlock.h>
2974 +-#include <linux/input.h>
2975 +-#include <linux/usb.h>
2976 +-
2977 +-#define DRIVER_VERSION "v0.031"
2978 +-#define DRIVER_AUTHOR "mwilder@×××××××.edu"
2979 +-#define DRIVER_DESC "USB mimio-xi driver"
2980 +-
2981 +-enum {UPVALUE, DOWNVALUE, MOVEVALUE};
2982 +-
2983 +-#define MIMIO_XRANGE_MAX 9600
2984 +-#define MIMIO_YRANGE_MAX 4800
2985 +-
2986 +-#define LOCALBTN_TOOL_EXTRA1 BTN_TOUCH
2987 +-#define LOCALBTN_TOOL_EXTRA2 BTN_STYLUS
2988 +-#define LOCALBTN_TOOL_EXTRA3 BTN_STYLUS2
2989 +-
2990 +-#define MIMIO_VENDOR_ID 0x08d3
2991 +-#define MIMIO_PRODUCT_ID 0x0001
2992 +-#define MIMIO_MAXPAYLOAD (8)
2993 +-#define MIMIO_MAXNAMELEN (64)
2994 +-#define MIMIO_TXWAIT (1)
2995 +-#define MIMIO_TXDONE (2)
2996 +-
2997 +-#define MIMIO_EV_PENDOWN (0x22)
2998 +-#define MIMIO_EV_PENDATA (0x24)
2999 +-#define MIMIO_EV_PENUP (0x51)
3000 +-#define MIMIO_EV_MEMRESET (0x45)
3001 +-#define MIMIO_EV_ACC (0xb2)
3002 +-
3003 +-#define MIMIO_PEN_K (1) /* black pen */
3004 +-#define MIMIO_PEN_B (2) /* blue pen */
3005 +-#define MIMIO_PEN_G (3) /* green pen */
3006 +-#define MIMIO_PEN_R (4) /* red pen */
3007 +-/* 5, 6, 7, 8 are extra pens */
3008 +-#define MIMIO_PEN_E (9) /* big eraser */
3009 +-#define MIMIO_PEN_ES (10) /* lil eraser */
3010 +-#define MIMIO_PENJUMP_START (10)
3011 +-#define MIMIO_PENJUMP (6)
3012 +-#define MIMIO_PEN_I (17) /* mimio interactive */
3013 +-#define MIMIO_PEN_IL (18) /* mimio interactive button 1 */
3014 +-#define MIMIO_PEN_IR (19) /* mimio interactive button 2 */
3015 +-
3016 +-#define MIMIO_PEN_MAX (MIMIO_PEN_IR)
3017 +-
3018 +-#define ACC_DONE (0)
3019 +-#define ACC_NEWPAGE (1)
3020 +-#define ACC_TAGPAGE (2)
3021 +-#define ACC_PRINTPAGE (4)
3022 +-#define ACC_MAXIMIZE (8)
3023 +-#define ACC_FINDCTLPNL (16)
3024 +-
3025 +-#define isvalidtxsize(n) ((n) > 0 && (n) <= MIMIO_MAXPAYLOAD)
3026 +-
3027 +-
3028 +-struct pktbuf {
3029 +- unsigned char instr;
3030 +- unsigned char buf[16];
3031 +- unsigned char *p;
3032 +- unsigned char *q;
3033 +-};
3034 +-
3035 +-struct usbintendpt {
3036 +- dma_addr_t dma;
3037 +- struct urb *urb;
3038 +- unsigned char *buf;
3039 +- struct usb_endpoint_descriptor *desc;
3040 +-};
3041 +-
3042 +-struct mimio {
3043 +- struct input_dev *idev;
3044 +- struct usb_device *udev;
3045 +- struct usb_interface *uifc;
3046 +- int open;
3047 +- int present;
3048 +- int greeted;
3049 +- int txflags;
3050 +- char phys[MIMIO_MAXNAMELEN];
3051 +- struct usbintendpt in;
3052 +- struct usbintendpt out;
3053 +- struct pktbuf pktbuf;
3054 +- unsigned char minor;
3055 +- wait_queue_head_t waitq;
3056 +- spinlock_t txlock;
3057 +- void (*rxhandler)(struct mimio *, unsigned char *, unsigned int);
3058 +- int last_pen_down;
3059 +-};
3060 +-
3061 +-static void mimio_close(struct input_dev *);
3062 +-static void mimio_dealloc(struct mimio *);
3063 +-static void mimio_disconnect(struct usb_interface *);
3064 +-static int mimio_greet(struct mimio *);
3065 +-static void mimio_irq_in(struct urb *);
3066 +-static void mimio_irq_out(struct urb *);
3067 +-static int mimio_open(struct input_dev *);
3068 +-static int mimio_probe(struct usb_interface *, const struct usb_device_id *);
3069 +-static void mimio_rx_handler(struct mimio *, unsigned char *, unsigned int);
3070 +-static int mimio_tx(struct mimio *, const char *, int);
3071 +-
3072 +-static char mimio_name[] = "VirtualInk mimio-Xi";
3073 +-static struct usb_device_id mimio_table [] = {
3074 +- { USB_DEVICE(MIMIO_VENDOR_ID, MIMIO_PRODUCT_ID) },
3075 +- { USB_DEVICE(0x0525, 0xa4a0) }, /* gadget zero firmware */
3076 +- { }
3077 +-};
3078 +-
3079 +-MODULE_DEVICE_TABLE(usb, mimio_table);
3080 +-
3081 +-static struct usb_driver mimio_driver = {
3082 +- .name = "mimio",
3083 +- .probe = mimio_probe,
3084 +- .disconnect = mimio_disconnect,
3085 +- .id_table = mimio_table,
3086 +-};
3087 +-
3088 +-static DECLARE_MUTEX(disconnect_sem);
3089 +-
3090 +-static void mimio_close(struct input_dev *idev)
3091 +-{
3092 +- struct mimio *mimio;
3093 +-
3094 +- mimio = input_get_drvdata(idev);
3095 +- if (!mimio) {
3096 +- dev_err(&idev->dev, "null mimio attached to input device\n");
3097 +- return;
3098 +- }
3099 +-
3100 +- if (mimio->open <= 0)
3101 +- dev_err(&idev->dev, "mimio not open.\n");
3102 +- else
3103 +- mimio->open--;
3104 +-
3105 +- if (mimio->present == 0 && mimio->open == 0)
3106 +- mimio_dealloc(mimio);
3107 +-}
3108 +-
3109 +-static void mimio_dealloc(struct mimio *mimio)
3110 +-{
3111 +- if (mimio == NULL)
3112 +- return;
3113 +-
3114 +- usb_kill_urb(mimio->in.urb);
3115 +-
3116 +- usb_kill_urb(mimio->out.urb);
3117 +-
3118 +- if (mimio->idev) {
3119 +- input_unregister_device(mimio->idev);
3120 +- if (mimio->idev->grab)
3121 +- input_close_device(mimio->idev->grab);
3122 +- else
3123 +- dev_dbg(&mimio->idev->dev, "mimio->idev->grab == NULL"
3124 +- " -- didn't call input_close_device\n");
3125 +- }
3126 +-
3127 +- usb_free_urb(mimio->in.urb);
3128 +-
3129 +- usb_free_urb(mimio->out.urb);
3130 +-
3131 +- if (mimio->in.buf) {
3132 +- usb_buffer_free(mimio->udev, MIMIO_MAXPAYLOAD, mimio->in.buf,
3133 +- mimio->in.dma);
3134 +- }
3135 +-
3136 +- if (mimio->out.buf)
3137 +- usb_buffer_free(mimio->udev, MIMIO_MAXPAYLOAD, mimio->out.buf,
3138 +- mimio->out.dma);
3139 +-
3140 +- if (mimio->idev)
3141 +- input_free_device(mimio->idev);
3142 +-
3143 +- kfree(mimio);
3144 +-}
3145 +-
3146 +-static void mimio_disconnect(struct usb_interface *ifc)
3147 +-{
3148 +- struct mimio *mimio;
3149 +-
3150 +- down(&disconnect_sem);
3151 +-
3152 +- mimio = usb_get_intfdata(ifc);
3153 +- usb_set_intfdata(ifc, NULL);
3154 +- dev_dbg(&mimio->idev->dev, "disconnect\n");
3155 +-
3156 +- if (mimio) {
3157 +- mimio->present = 0;
3158 +-
3159 +- if (mimio->open <= 0)
3160 +- mimio_dealloc(mimio);
3161 +- }
3162 +-
3163 +- up(&disconnect_sem);
3164 +-}
3165 +-
3166 +-static int mimio_greet(struct mimio *mimio)
3167 +-{
3168 +- const struct grtpkt {
3169 +- int nbytes;
3170 +- unsigned delay;
3171 +- char data[8];
3172 +- } grtpkts[] = {
3173 +- { 3, 0, { 0x11, 0x55, 0x44, 0x00, 0x00, 0x00, 0x00, 0x00 } },
3174 +- { 5, 0, { 0x53, 0x55, 0x00, 0x00, 0x06, 0x00, 0x00, 0x00 } },
3175 +- { 5, 0, { 0x43, 0x55, 0x00, 0x00, 0x16, 0x00, 0x00, 0x00 } },
3176 +- { 5, 0, { 0x33, 0x55, 0x00, 0x00, 0x66, 0x00, 0x00, 0x00 } },
3177 +- { 5, 0, { 0x13, 0x00, 0x5e, 0x02, 0x4f, 0x00, 0x00, 0x00 } },
3178 +- { 5, 0, { 0x13, 0x00, 0x04, 0x03, 0x14, 0x00, 0x00, 0x00 } },
3179 +- { 5, 2, { 0x13, 0x00, 0x00, 0x04, 0x17, 0x00, 0x00, 0x00 } },
3180 +- { 5, 0, { 0x13, 0x00, 0x0d, 0x08, 0x16, 0x00, 0x00, 0x00 } },
3181 +- { 5, 0, { 0x13, 0x00, 0x4d, 0x01, 0x5f, 0x00, 0x00, 0x00 } },
3182 +- { 3, 0, { 0xf1, 0x55, 0xa4, 0x00, 0x00, 0x00, 0x00, 0x00 } },
3183 +- { 7, 2, { 0x52, 0x55, 0x00, 0x07, 0x31, 0x55, 0x64, 0x00 } },
3184 +- { 0, 0, { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 } },
3185 +- };
3186 +- int rslt;
3187 +- const struct grtpkt *pkt;
3188 +-
3189 +- for (pkt = grtpkts; pkt->nbytes; pkt++) {
3190 +- rslt = mimio_tx(mimio, pkt->data, pkt->nbytes);
3191 +- if (rslt)
3192 +- return rslt;
3193 +- if (pkt->delay)
3194 +- msleep(pkt->delay);
3195 +- }
3196 +-
3197 +- return 0;
3198 +-}
3199 +-
3200 +-static void mimio_irq_in(struct urb *urb)
3201 +-{
3202 +- int rslt;
3203 +- char *data;
3204 +- const char *reason = "going down";
3205 +- struct mimio *mimio;
3206 +-
3207 +- mimio = urb->context;
3208 +-
3209 +- if (mimio == NULL)
3210 +- /* paranoia */
3211 +- return;
3212 +-
3213 +- switch (urb->status) {
3214 +- case 0:
3215 +- /* success */
3216 +- break;
3217 +- case -ETIMEDOUT:
3218 +- reason = "timeout -- unplugged?";
3219 +- case -ECONNRESET:
3220 +- case -ENOENT:
3221 +- case -ESHUTDOWN:
3222 +- dev_dbg(&mimio->idev->dev, "%s.\n", reason);
3223 +- return;
3224 +- default:
3225 +- dev_dbg(&mimio->idev->dev, "unknown urb-status: %d.\n",
3226 +- urb->status);
3227 +- goto exit;
3228 +- }
3229 +- data = mimio->in.buf;
3230 +-
3231 +- if (mimio->rxhandler)
3232 +- mimio->rxhandler(mimio, data, urb->actual_length);
3233 +-exit:
3234 +- /*
3235 +- * Keep listening to device on same urb.
3236 +- */
3237 +- rslt = usb_submit_urb(urb, GFP_ATOMIC);
3238 +- if (rslt)
3239 +- dev_err(&mimio->idev->dev, "usb_submit_urb failure: %d.\n",
3240 +- rslt);
3241 +-}
3242 +-
3243 +-static void mimio_irq_out(struct urb *urb)
3244 +-{
3245 +- unsigned long flags;
3246 +- struct mimio *mimio;
3247 +-
3248 +- mimio = urb->context;
3249 +-
3250 +- if (urb->status)
3251 +- dev_dbg(&mimio->idev->dev, "urb-status: %d.\n", urb->status);
3252 +-
3253 +- spin_lock_irqsave(&mimio->txlock, flags);
3254 +- mimio->txflags |= MIMIO_TXDONE;
3255 +- spin_unlock_irqrestore(&mimio->txlock, flags);
3256 +- wmb();
3257 +- wake_up(&mimio->waitq);
3258 +-}
3259 +-
3260 +-static int mimio_open(struct input_dev *idev)
3261 +-{
3262 +- int rslt;
3263 +- struct mimio *mimio;
3264 +-
3265 +- rslt = 0;
3266 +- down(&disconnect_sem);
3267 +- mimio = input_get_drvdata(idev);
3268 +- dev_dbg(&idev->dev, "mimio_open\n");
3269 +-
3270 +- if (mimio == NULL) {
3271 +- dev_err(&idev->dev, "null mimio.\n");
3272 +- rslt = -ENODEV;
3273 +- goto exit;
3274 +- }
3275 +-
3276 +- if (mimio->open++)
3277 +- goto exit;
3278 +-
3279 +- if (mimio->present && !mimio->greeted) {
3280 +- struct urb *urb = mimio->in.urb;
3281 +- mimio->in.urb->dev = mimio->udev;
3282 +- rslt = usb_submit_urb(mimio->in.urb, GFP_KERNEL);
3283 +- if (rslt) {
3284 +- dev_err(&idev->dev, "usb_submit_urb failure "
3285 +- "(res = %d: %s). Not greeting.\n",
3286 +- rslt,
3287 +- (!urb ? "urb is NULL" :
3288 +- (urb->hcpriv ? "urb->hcpriv is non-NULL" :
3289 +- (!urb->complete ? "urb is not complete" :
3290 +- (urb->number_of_packets <= 0 ? "urb has no packets" :
3291 +- (urb->interval <= 0 ? "urb interval too small" :
3292 +- "urb interval too large or some other error"))))));
3293 +- rslt = -EIO;
3294 +- goto exit;
3295 +- }
3296 +- rslt = mimio_greet(mimio);
3297 +- if (rslt == 0) {
3298 +- dev_dbg(&idev->dev, "Mimio greeted OK.\n");
3299 +- mimio->greeted = 1;
3300 +- } else {
3301 +- dev_dbg(&idev->dev, "Mimio greet Failure (%d)\n",
3302 +- rslt);
3303 +- }
3304 +- }
3305 +-
3306 +-exit:
3307 +- up(&disconnect_sem);
3308 +- return rslt;
3309 +-}
3310 +-
3311 +-static int mimio_probe(struct usb_interface *ifc,
3312 +- const struct usb_device_id *id)
3313 +-{
3314 +- char path[64];
3315 +- int pipe, maxp;
3316 +- struct mimio *mimio;
3317 +- struct usb_device *udev;
3318 +- struct usb_host_interface *hostifc;
3319 +- struct input_dev *input_dev;
3320 +- int res = 0;
3321 +- int i;
3322 +-
3323 +- udev = interface_to_usbdev(ifc);
3324 +-
3325 +- mimio = kzalloc(sizeof(struct mimio), GFP_KERNEL);
3326 +- if (!mimio)
3327 +- return -ENOMEM;
3328 +-
3329 +- input_dev = input_allocate_device();
3330 +- if (!input_dev) {
3331 +- mimio_dealloc(mimio);
3332 +- return -ENOMEM;
3333 +- }
3334 +-
3335 +- mimio->uifc = ifc;
3336 +- mimio->udev = udev;
3337 +- mimio->pktbuf.p = mimio->pktbuf.buf;
3338 +- mimio->pktbuf.q = mimio->pktbuf.buf;
3339 +- /* init_input_dev(mimio->idev); */
3340 +- mimio->idev = input_dev;
3341 +- init_waitqueue_head(&mimio->waitq);
3342 +- spin_lock_init(&mimio->txlock);
3343 +- hostifc = ifc->cur_altsetting;
3344 +-
3345 +- if (hostifc->desc.bNumEndpoints != 2) {
3346 +- dev_err(&udev->dev, "Unexpected endpoint count: %d.\n",
3347 +- hostifc->desc.bNumEndpoints);
3348 +- mimio_dealloc(mimio);
3349 +- return -ENODEV;
3350 +- }
3351 +-
3352 +- mimio->in.desc = &(hostifc->endpoint[0].desc);
3353 +- mimio->out.desc = &(hostifc->endpoint[1].desc);
3354 +-
3355 +- mimio->in.buf = usb_buffer_alloc(udev, MIMIO_MAXPAYLOAD, GFP_KERNEL,
3356 +- &mimio->in.dma);
3357 +- mimio->out.buf = usb_buffer_alloc(udev, MIMIO_MAXPAYLOAD, GFP_KERNEL,
3358 +- &mimio->out.dma);
3359 +-
3360 +- if (mimio->in.buf == NULL || mimio->out.buf == NULL) {
3361 +- dev_err(&udev->dev, "usb_buffer_alloc failure.\n");
3362 +- mimio_dealloc(mimio);
3363 +- return -ENOMEM;
3364 +- }
3365 +-
3366 +- mimio->in.urb = usb_alloc_urb(0, GFP_KERNEL);
3367 +- mimio->out.urb = usb_alloc_urb(0, GFP_KERNEL);
3368 +-
3369 +- if (mimio->in.urb == NULL || mimio->out.urb == NULL) {
3370 +- dev_err(&udev->dev, "usb_alloc_urb failure.\n");
3371 +- mimio_dealloc(mimio);
3372 +- return -ENOMEM;
3373 +- }
3374 +-
3375 +- /*
3376 +- * Build the input urb.
3377 +- */
3378 +- pipe = usb_rcvintpipe(udev, mimio->in.desc->bEndpointAddress);
3379 +- maxp = usb_maxpacket(udev, pipe, usb_pipeout(pipe));
3380 +- if (maxp > MIMIO_MAXPAYLOAD)
3381 +- maxp = MIMIO_MAXPAYLOAD;
3382 +- usb_fill_int_urb(mimio->in.urb, udev, pipe, mimio->in.buf, maxp,
3383 +- mimio_irq_in, mimio, mimio->in.desc->bInterval);
3384 +- mimio->in.urb->transfer_dma = mimio->in.dma;
3385 +- mimio->in.urb->transfer_flags |= URB_NO_TRANSFER_DMA_MAP;
3386 +-
3387 +- /*
3388 +- * Build the output urb.
3389 +- */
3390 +- pipe = usb_sndintpipe(udev, mimio->out.desc->bEndpointAddress);
3391 +- maxp = usb_maxpacket(udev, pipe, usb_pipeout(pipe));
3392 +- if (maxp > MIMIO_MAXPAYLOAD)
3393 +- maxp = MIMIO_MAXPAYLOAD;
3394 +- usb_fill_int_urb(mimio->out.urb, udev, pipe, mimio->out.buf, maxp,
3395 +- mimio_irq_out, mimio, mimio->out.desc->bInterval);
3396 +- mimio->out.urb->transfer_dma = mimio->out.dma;
3397 +- mimio->out.urb->transfer_flags |= URB_NO_TRANSFER_DMA_MAP;
3398 +-
3399 +- /*
3400 +- * Build input device info
3401 +- */
3402 +- usb_make_path(udev, path, 64);
3403 +- snprintf(mimio->phys, MIMIO_MAXNAMELEN, "%s/input0", path);
3404 +- input_set_drvdata(input_dev, mimio);
3405 +- /* input_dev->dev = &ifc->dev; */
3406 +- input_dev->open = mimio_open;
3407 +- input_dev->close = mimio_close;
3408 +- input_dev->name = mimio_name;
3409 +- input_dev->phys = mimio->phys;
3410 +- input_dev->dev.parent = &ifc->dev;
3411 +-
3412 +- input_dev->id.bustype = BUS_USB;
3413 +- input_dev->id.vendor = le16_to_cpu(udev->descriptor.idVendor);
3414 +- input_dev->id.product = le16_to_cpu(udev->descriptor.idProduct);
3415 +- input_dev->id.version = le16_to_cpu(udev->descriptor.bcdDevice);
3416 +-
3417 +- input_dev->evbit[0] |= BIT(EV_KEY) | BIT(EV_ABS);
3418 +- for (i = BTN_TOOL_PEN; i <= LOCALBTN_TOOL_EXTRA2; ++i)
3419 +- set_bit(i, input_dev->keybit);
3420 +-
3421 +- input_dev->keybit[BIT_WORD(BTN_MISC)] |= BIT_MASK(BTN_0) |
3422 +- BIT_MASK(BTN_1) |
3423 +- BIT_MASK(BTN_2) |
3424 +- BIT_MASK(BTN_3) |
3425 +- BIT_MASK(BTN_4) |
3426 +- BIT_MASK(BTN_5);
3427 +- /* input_dev->keybit[BTN_MOUSE] |= BIT(BTN_LEFT); */
3428 +- input_dev->absbit[0] |= BIT_MASK(ABS_X) | BIT_MASK(ABS_Y);
3429 +- input_set_abs_params(input_dev, ABS_X, 0, MIMIO_XRANGE_MAX, 0, 0);
3430 +- input_set_abs_params(input_dev, ABS_Y, 0, MIMIO_YRANGE_MAX, 0, 0);
3431 +- input_dev->absbit[BIT_WORD(ABS_MISC)] |= BIT_MASK(ABS_MISC);
3432 +-
3433 +-#if 0
3434 +- input_dev->absmin[ABS_X] = 0;
3435 +- input_dev->absmin[ABS_Y] = 0;
3436 +- input_dev->absmax[ABS_X] = 9600;
3437 +- input_dev->absmax[ABS_Y] = 4800;
3438 +- input_dev->absfuzz[ABS_X] = 0;
3439 +- input_dev->absfuzz[ABS_Y] = 0;
3440 +- input_dev->absflat[ABS_X] = 0;
3441 +- input_dev->absflat[ABS_Y] = 0;
3442 +-#endif
3443 +-
3444 +-#if 0
3445 +- /* this will just reduce the precision */
3446 +- input_dev->absfuzz[ABS_X] = 8; /* experimental; may need to change */
3447 +- input_dev->absfuzz[ABS_Y] = 8; /* experimental; may need to change */
3448 +-#endif
3449 +-
3450 +- /*
3451 +- * Register the input device.
3452 +- */
3453 +- res = input_register_device(mimio->idev);
3454 +- if (res) {
3455 +- dev_err(&udev->dev, "input_register_device failure (%d)\n",
3456 +- res);
3457 +- mimio_dealloc(mimio);
3458 +- return -EIO;
3459 +- }
3460 +- dev_dbg(&mimio->idev->dev, "input: %s on %s (res = %d).\n",
3461 +- input_dev->name, input_dev->phys, res);
3462 +-
3463 +- usb_set_intfdata(ifc, mimio);
3464 +- mimio->present = 1;
3465 +-
3466 +- /*
3467 +- * Submit the input urb to the usb subsystem.
3468 +- */
3469 +- mimio->in.urb->dev = mimio->udev;
3470 +- res = usb_submit_urb(mimio->in.urb, GFP_KERNEL);
3471 +- if (res) {
3472 +- dev_err(&mimio->idev->dev, "usb_submit_urb failure (%d)\n",
3473 +- res);
3474 +- mimio_dealloc(mimio);
3475 +- return -EIO;
3476 +- }
3477 +-
3478 +- /*
3479 +- * Attempt to greet the mimio after giving
3480 +- * it some post-init settling time.
3481 +- *
3482 +- * note: sometimes this sleep interval isn't
3483 +- * long enough to permit the device to re-init
3484 +- * after a hot-swap; maybe need to bump it up.
3485 +- *
3486 +- * As it is, this probably breaks module unloading support!
3487 +- */
3488 +- msleep(1024);
3489 +-
3490 +- res = mimio_greet(mimio);
3491 +- if (res == 0) {
3492 +- dev_dbg(&mimio->idev->dev, "Mimio greeted OK.\n");
3493 +- mimio->greeted = 1;
3494 +- mimio->rxhandler = mimio_rx_handler;
3495 +- } else {
3496 +- dev_dbg(&mimio->idev->dev, "Mimio greet Failure (%d)\n", res);
3497 +- }
3498 +-
3499 +- return 0;
3500 +-}
3501 +-
3502 +-static int handle_mimio_rx_penupdown(struct mimio *mimio,
3503 +- int down,
3504 +- const char *const instr[],
3505 +- const int instr_ofst[])
3506 +-{
3507 +- int penid, x;
3508 +- if (mimio->pktbuf.q - mimio->pktbuf.p < (down ? 4 : 3))
3509 +- return 1; /* partial pkt */
3510 +-
3511 +- if (down) {
3512 +- x = *mimio->pktbuf.p ^ *(mimio->pktbuf.p + 1) ^
3513 +- *(mimio->pktbuf.p + 2);
3514 +- if (x != *(mimio->pktbuf.p + 3)) {
3515 +- dev_dbg(&mimio->idev->dev, "EV_PEN%s: bad xsum.\n",
3516 +- down ? "DOWN":"UP");
3517 +- /* skip this event data */
3518 +- mimio->pktbuf.p += 4;
3519 +- /* decode any remaining events */
3520 +- return 0;
3521 +- }
3522 +- penid = mimio->pktbuf.instr = *(mimio->pktbuf.p + 2);
3523 +- if (penid > MIMIO_PEN_MAX) {
3524 +- dev_dbg(&mimio->idev->dev,
3525 +- "Unmapped penID (not in [0, %d]): %d\n",
3526 +- MIMIO_PEN_MAX, (int)mimio->pktbuf.instr);
3527 +- penid = mimio->pktbuf.instr = 0;
3528 +- }
3529 +- mimio->last_pen_down = penid;
3530 +- } else {
3531 +- penid = mimio->last_pen_down;
3532 +- }
3533 +- dev_dbg(&mimio->idev->dev, "%s (id %d, code %d) %s.\n", instr[penid],
3534 +- instr_ofst[penid], penid, down ? "down" : "up");
3535 +-
3536 +- if (instr_ofst[penid] >= 0) {
3537 +- int code = BTN_TOOL_PEN + instr_ofst[penid];
3538 +- int value = down ? DOWNVALUE : UPVALUE;
3539 +- if (code > KEY_MAX)
3540 +- dev_dbg(&mimio->idev->dev, "input_event will ignore "
3541 +- "-- code (%d) > KEY_MAX\n", code);
3542 +- if (!test_bit(code, mimio->idev->keybit))
3543 +- dev_dbg(&mimio->idev->dev, "input_event will ignore "
3544 +- "-- bit for code (%d) not enabled\n", code);
3545 +- if (!!test_bit(code, mimio->idev->key) == value)
3546 +- dev_dbg(&mimio->idev->dev, "input_event will ignore "
3547 +- "-- bit for code (%d) already set to %d\n",
3548 +- code, value);
3549 +- if (value != DOWNVALUE) {
3550 +- /* input_regs(mimio->idev, regs); */
3551 +- input_report_key(mimio->idev, code, value);
3552 +- input_sync(mimio->idev);
3553 +- } else {
3554 +- /* wait until we get some coordinates */
3555 +- }
3556 +- } else {
3557 +- dev_dbg(&mimio->idev->dev, "penID offset[%d] == %d is < 0 "
3558 +- "- not sending\n", penid, instr_ofst[penid]);
3559 +- }
3560 +- mimio->pktbuf.p += down ? 4 : 3; /* 3 for up, 4 for down */
3561 +- return 0;
3562 +-}
3563 +-
3564 +-/*
3565 +- * Stay tuned for partial-packet excitement.
3566 +- *
3567 +- * This routine buffers data packets received from the mimio device
3568 +- * in the mimio's data space. This buffering is necessary because
3569 +- * the mimio's in endpoint can serve us partial packets of data, and
3570 +- * we want the driver to support the servicing of multiple mimios.
3571 +- * Empirical evidence gathered so far suggests that the method of
3572 +- * buffering packet data in the mimio's data space works. Previous
3573 +- * versions of this driver did not buffer packet data in each mimio's
3574 +- * data-space, and were therefore not able to service multiple mimios.
3575 +- * Note that since the caller of this routine is running in interrupt
3576 +- * context, care needs to be taken to ensure that this routine does not
3577 +- * become bloated, and it may be that another spinlock is needed in each
3578 +- * mimio to guard the buffered packet data properly.
3579 +- */
3580 +-static void mimio_rx_handler(struct mimio *mimio,
3581 +- unsigned char *data,
3582 +- unsigned int nbytes)
3583 +-{
3584 +- struct device *dev = &mimio->idev->dev;
3585 +- unsigned int x;
3586 +- unsigned int y;
3587 +- static const char * const instr[] = {
3588 +- "?0",
3589 +- "black pen", "blue pen", "green pen", "red pen",
3590 +- "brown pen", "orange pen", "purple pen", "yellow pen",
3591 +- "big eraser", "lil eraser",
3592 +- "?11", "?12", "?13", "?14", "?15", "?16",
3593 +- "mimio interactive", "interactive button1",
3594 +- "interactive button2"
3595 +- };
3596 +-
3597 +- /* Mimio Interactive gives:
3598 +- * down: [0x22 0x01 0x11 0x32 0x24]
3599 +- * b1 : [0x22 0x01 0x12 0x31 0x24]
3600 +- * b2 : [0x22 0x01 0x13 0x30 0x24]
3601 +- */
3602 +- static const int instr_ofst[] = {
3603 +- -1,
3604 +- 0, 1, 2, 3,
3605 +- 9, 9, 9, 9,
3606 +- 4, 5,
3607 +- -1, -1, -1, -1, -1, -1,
3608 +- 6, 7, 8,
3609 +- };
3610 +-
3611 +- memcpy(mimio->pktbuf.q, data, nbytes);
3612 +- mimio->pktbuf.q += nbytes;
3613 +-
3614 +- while (mimio->pktbuf.p < mimio->pktbuf.q) {
3615 +- int t = *mimio->pktbuf.p;
3616 +- switch (t) {
3617 +- case MIMIO_EV_PENUP:
3618 +- case MIMIO_EV_PENDOWN:
3619 +- if (handle_mimio_rx_penupdown(mimio,
3620 +- t == MIMIO_EV_PENDOWN,
3621 +- instr, instr_ofst))
3622 +- return; /* partial packet */
3623 +- break;
3624 +-
3625 +- case MIMIO_EV_PENDATA:
3626 +- if (mimio->pktbuf.q - mimio->pktbuf.p < 6)
3627 +- /* partial pkt */
3628 +- return;
3629 +- x = *mimio->pktbuf.p ^ *(mimio->pktbuf.p + 1) ^
3630 +- *(mimio->pktbuf.p + 2) ^
3631 +- *(mimio->pktbuf.p + 3) ^
3632 +- *(mimio->pktbuf.p + 4);
3633 +- if (x != *(mimio->pktbuf.p + 5)) {
3634 +- dev_dbg(dev, "EV_PENDATA: bad xsum.\n");
3635 +- mimio->pktbuf.p += 6; /* skip this event data */
3636 +- break; /* decode any remaining events */
3637 +- }
3638 +- x = *(mimio->pktbuf.p + 1);
3639 +- x <<= 8;
3640 +- x |= *(mimio->pktbuf.p + 2);
3641 +- y = *(mimio->pktbuf.p + 3);
3642 +- y <<= 8;
3643 +- y |= *(mimio->pktbuf.p + 4);
3644 +- dev_dbg(dev, "coord: (%d, %d)\n", x, y);
3645 +- if (instr_ofst[mimio->pktbuf.instr] >= 0) {
3646 +- int code = BTN_TOOL_PEN +
3647 +- instr_ofst[mimio->last_pen_down];
3648 +-#if 0
3649 +- /* Utter hack to ensure we get forwarded _AND_
3650 +- * so we can identify when a complete signal is
3651 +- * received */
3652 +- mimio->idev->abs[ABS_Y] = -1;
3653 +- mimio->idev->abs[ABS_X] = -1;
3654 +-#endif
3655 +- /* input_regs(mimio->idev, regs); */
3656 +- input_report_abs(mimio->idev, ABS_X, x);
3657 +- input_report_abs(mimio->idev, ABS_Y, y);
3658 +- /* fake a penup */
3659 +- change_bit(code, mimio->idev->key);
3660 +- input_report_key(mimio->idev,
3661 +- code,
3662 +- DOWNVALUE);
3663 +- /* always sync here */
3664 +- mimio->idev->sync = 0;
3665 +- input_sync(mimio->idev);
3666 +- }
3667 +- mimio->pktbuf.p += 6;
3668 +- break;
3669 +- case MIMIO_EV_MEMRESET:
3670 +- if (mimio->pktbuf.q - mimio->pktbuf.p < 7)
3671 +- /* partial pkt */
3672 +- return;
3673 +- dev_dbg(dev, "mem-reset.\n");
3674 +- /* input_regs(mimio->idev, regs); */
3675 +- input_event(mimio->idev, EV_KEY, BTN_0, 1);
3676 +- input_event(mimio->idev, EV_KEY, BTN_0, 0);
3677 +- input_sync(mimio->idev);
3678 +- mimio->pktbuf.p += 7;
3679 +- break;
3680 +- case MIMIO_EV_ACC:
3681 +- if (mimio->pktbuf.q - mimio->pktbuf.p < 4)
3682 +- /* partial pkt */
3683 +- return;
3684 +- x = *mimio->pktbuf.p ^ *(mimio->pktbuf.p + 1) ^
3685 +- *(mimio->pktbuf.p + 2);
3686 +- if (x != *(mimio->pktbuf.p + 3)) {
3687 +- dev_dbg(dev, "EV_ACC: bad xsum.\n");
3688 +- mimio->pktbuf.p += 4; /* skip this event data */
3689 +- break; /* decode any remaining events */
3690 +- }
3691 +- switch (*(mimio->pktbuf.p + 2)) {
3692 +- case ACC_NEWPAGE:
3693 +- dev_dbg(&mimio->idev->dev, "new-page.\n");
3694 +- /* input_regs(mimio->idev, regs); */
3695 +- input_event(mimio->idev, EV_KEY, BTN_1, 1);
3696 +- input_event(mimio->idev, EV_KEY, BTN_1, 0);
3697 +- input_sync(mimio->idev);
3698 +- break;
3699 +- case ACC_TAGPAGE:
3700 +- dev_dbg(&mimio->idev->dev, "tag-page.\n");
3701 +- /* input_regs(mimio->idev, regs); */
3702 +- input_event(mimio->idev, EV_KEY, BTN_2, 1);
3703 +- input_event(mimio->idev, EV_KEY, BTN_2, 0);
3704 +- input_sync(mimio->idev);
3705 +- break;
3706 +- case ACC_PRINTPAGE:
3707 +- dev_dbg(&mimio->idev->dev, "print-page.\n");
3708 +- /* input_regs(mimio->idev, regs);*/
3709 +- input_event(mimio->idev, EV_KEY, BTN_3, 1);
3710 +- input_event(mimio->idev, EV_KEY, BTN_3, 0);
3711 +- input_sync(mimio->idev);
3712 +- break;
3713 +- case ACC_MAXIMIZE:
3714 +- dev_dbg(&mimio->idev->dev,
3715 +- "maximize-window.\n");
3716 +- /* input_regs(mimio->idev, regs); */
3717 +- input_event(mimio->idev, EV_KEY, BTN_4, 1);
3718 +- input_event(mimio->idev, EV_KEY, BTN_4, 0);
3719 +- input_sync(mimio->idev);
3720 +- break;
3721 +- case ACC_FINDCTLPNL:
3722 +- dev_dbg(&mimio->idev->dev, "find-ctl-panel.\n");
3723 +- /* input_regs(mimio->idev, regs); */
3724 +- input_event(mimio->idev, EV_KEY, BTN_5, 1);
3725 +- input_event(mimio->idev, EV_KEY, BTN_5, 0);
3726 +- input_sync(mimio->idev);
3727 +- break;
3728 +- case ACC_DONE:
3729 +- dev_dbg(&mimio->idev->dev, "acc-done.\n");
3730 +- /* no event is dispatched to the input
3731 +- * subsystem for this device event.
3732 +- */
3733 +- break;
3734 +- default:
3735 +- dev_dbg(dev, "unknown acc event.\n");
3736 +- break;
3737 +- }
3738 +- mimio->pktbuf.p += 4;
3739 +- break;
3740 +- default:
3741 +- mimio->pktbuf.p++;
3742 +- break;
3743 +- }
3744 +- }
3745 +-
3746 +- /*
3747 +- * No partial event was received, so reset mimio's pktbuf ptrs.
3748 +- */
3749 +- mimio->pktbuf.p = mimio->pktbuf.q = mimio->pktbuf.buf;
3750 +-}
3751 +-
3752 +-static int mimio_tx(struct mimio *mimio, const char *buf, int nbytes)
3753 +-{
3754 +- int rslt;
3755 +- int timeout;
3756 +- unsigned long flags;
3757 +- DECLARE_WAITQUEUE(wait, current);
3758 +-
3759 +- if (!(isvalidtxsize(nbytes))) {
3760 +- dev_err(&mimio->idev->dev, "invalid arg: nbytes: %d.\n",
3761 +- nbytes);
3762 +- return -EINVAL;
3763 +- }
3764 +-
3765 +- /*
3766 +- * Init the out urb and copy the data to send.
3767 +- */
3768 +- mimio->out.urb->dev = mimio->udev;
3769 +- mimio->out.urb->transfer_buffer_length = nbytes;
3770 +- memcpy(mimio->out.urb->transfer_buffer, buf, nbytes);
3771 +-
3772 +- /*
3773 +- * Send the data.
3774 +- */
3775 +- spin_lock_irqsave(&mimio->txlock, flags);
3776 +- mimio->txflags = MIMIO_TXWAIT;
3777 +- rslt = usb_submit_urb(mimio->out.urb, GFP_ATOMIC);
3778 +- spin_unlock_irqrestore(&mimio->txlock, flags);
3779 +- dev_dbg(&mimio->idev->dev, "rslt: %d.\n", rslt);
3780 +-
3781 +- if (rslt) {
3782 +- dev_err(&mimio->idev->dev, "usb_submit_urb failure: %d.\n",
3783 +- rslt);
3784 +- return rslt;
3785 +- }
3786 +-
3787 +- /*
3788 +- * Wait for completion to be signalled (the mimio_irq_out
3789 +- * completion routine will or MIMIO_TXDONE in with txflags).
3790 +- */
3791 +- timeout = HZ;
3792 +- set_current_state(TASK_INTERRUPTIBLE);
3793 +- add_wait_queue(&mimio->waitq, &wait);
3794 +-
3795 +- while (timeout && ((mimio->txflags & MIMIO_TXDONE) == 0)) {
3796 +- timeout = schedule_timeout(timeout);
3797 +- rmb();
3798 +- }
3799 +-
3800 +- if ((mimio->txflags & MIMIO_TXDONE) == 0)
3801 +- dev_dbg(&mimio->idev->dev, "tx timed out.\n");
3802 +-
3803 +- /*
3804 +- * Now that completion has been signalled,
3805 +- * unlink the urb so that it can be recycled.
3806 +- */
3807 +- set_current_state(TASK_RUNNING);
3808 +- remove_wait_queue(&mimio->waitq, &wait);
3809 +- usb_unlink_urb(mimio->out.urb);
3810 +-
3811 +- return rslt;
3812 +-}
3813 +-
3814 +-static int __init mimio_init(void)
3815 +-{
3816 +- int rslt;
3817 +-
3818 +- rslt = usb_register(&mimio_driver);
3819 +- if (rslt != 0) {
3820 +- err("%s: usb_register failure: %d", __func__, rslt);
3821 +- return rslt;
3822 +- }
3823 +-
3824 +- printk(KERN_INFO KBUILD_MODNAME ":"
3825 +- DRIVER_DESC " " DRIVER_VERSION "\n");
3826 +- return rslt;
3827 +-}
3828 +-
3829 +-static void __exit mimio_exit(void)
3830 +-{
3831 +- usb_deregister(&mimio_driver);
3832 +-}
3833 +-
3834 +-module_init(mimio_init);
3835 +-module_exit(mimio_exit);
3836 +-
3837 +-MODULE_AUTHOR(DRIVER_AUTHOR);
3838 +-MODULE_DESCRIPTION(DRIVER_DESC);
3839 +-MODULE_LICENSE("GPL");
3840 +diff --git a/drivers/staging/pohmelfs/inode.c b/drivers/staging/pohmelfs/inode.c
3841 +index f69b778..cd25811 100644
3842 +--- a/drivers/staging/pohmelfs/inode.c
3843 ++++ b/drivers/staging/pohmelfs/inode.c
3844 +@@ -36,6 +36,7 @@
3845 + #define POHMELFS_MAGIC_NUM 0x504f482e
3846 +
3847 + static struct kmem_cache *pohmelfs_inode_cache;
3848 ++static atomic_t psb_bdi_num = ATOMIC_INIT(0);
3849 +
3850 + /*
3851 + * Removes inode from all trees, drops local name cache and removes all queued
3852 +@@ -1331,6 +1332,8 @@ static void pohmelfs_put_super(struct super_block *sb)
3853 + pohmelfs_crypto_exit(psb);
3854 + pohmelfs_state_exit(psb);
3855 +
3856 ++ bdi_destroy(&psb->bdi);
3857 ++
3858 + kfree(psb);
3859 + sb->s_fs_info = NULL;
3860 + }
3861 +@@ -1815,11 +1818,22 @@ static int pohmelfs_fill_super(struct super_block *sb, void *data, int silent)
3862 + if (!psb)
3863 + goto err_out_exit;
3864 +
3865 ++ err = bdi_init(&psb->bdi);
3866 ++ if (err)
3867 ++ goto err_out_free_sb;
3868 ++
3869 ++ err = bdi_register(&psb->bdi, NULL, "pfs-%d", atomic_inc_return(&psb_bdi_num));
3870 ++ if (err) {
3871 ++ bdi_destroy(&psb->bdi);
3872 ++ goto err_out_free_sb;
3873 ++ }
3874 ++
3875 + sb->s_fs_info = psb;
3876 + sb->s_op = &pohmelfs_sb_ops;
3877 + sb->s_magic = POHMELFS_MAGIC_NUM;
3878 + sb->s_maxbytes = MAX_LFS_FILESIZE;
3879 + sb->s_blocksize = PAGE_SIZE;
3880 ++ sb->s_bdi = &psb->bdi;
3881 +
3882 + psb->sb = sb;
3883 +
3884 +@@ -1863,11 +1877,11 @@ static int pohmelfs_fill_super(struct super_block *sb, void *data, int silent)
3885 +
3886 + err = pohmelfs_parse_options((char *) data, psb, 0);
3887 + if (err)
3888 +- goto err_out_free_sb;
3889 ++ goto err_out_free_bdi;
3890 +
3891 + err = pohmelfs_copy_crypto(psb);
3892 + if (err)
3893 +- goto err_out_free_sb;
3894 ++ goto err_out_free_bdi;
3895 +
3896 + err = pohmelfs_state_init(psb);
3897 + if (err)
3898 +@@ -1916,6 +1930,8 @@ err_out_state_exit:
3899 + err_out_free_strings:
3900 + kfree(psb->cipher_string);
3901 + kfree(psb->hash_string);
3902 ++err_out_free_bdi:
3903 ++ bdi_destroy(&psb->bdi);
3904 + err_out_free_sb:
3905 + kfree(psb);
3906 + err_out_exit:
3907 +diff --git a/drivers/staging/pohmelfs/netfs.h b/drivers/staging/pohmelfs/netfs.h
3908 +index 623a07d..01cba00 100644
3909 +--- a/drivers/staging/pohmelfs/netfs.h
3910 ++++ b/drivers/staging/pohmelfs/netfs.h
3911 +@@ -18,6 +18,7 @@
3912 +
3913 + #include <linux/types.h>
3914 + #include <linux/connector.h>
3915 ++#include <linux/backing-dev.h>
3916 +
3917 + #define POHMELFS_CN_IDX 5
3918 + #define POHMELFS_CN_VAL 0
3919 +@@ -624,6 +625,8 @@ struct pohmelfs_sb {
3920 +
3921 + struct super_block *sb;
3922 +
3923 ++ struct backing_dev_info bdi;
3924 ++
3925 + /*
3926 + * Algorithm strings.
3927 + */
3928 +diff --git a/drivers/staging/wlan-ng/Kconfig b/drivers/staging/wlan-ng/Kconfig
3929 +index f44294b..f1af507 100644
3930 +--- a/drivers/staging/wlan-ng/Kconfig
3931 ++++ b/drivers/staging/wlan-ng/Kconfig
3932 +@@ -1,6 +1,7 @@
3933 + config PRISM2_USB
3934 + tristate "Prism2.5/3 USB driver"
3935 + depends on WLAN && USB && WIRELESS_EXT
3936 ++ select WEXT_PRIV
3937 + default n
3938 + ---help---
3939 + This is the wlan-ng prism 2.5/3 USB driver for a wide range of
3940 +diff --git a/drivers/usb/core/driver.c b/drivers/usb/core/driver.c
3941 +index 60a45f1..ca479a7 100644
3942 +--- a/drivers/usb/core/driver.c
3943 ++++ b/drivers/usb/core/driver.c
3944 +@@ -691,9 +691,6 @@ static int usb_uevent(struct device *dev, struct kobj_uevent_env *env)
3945 + {
3946 + struct usb_device *usb_dev;
3947 +
3948 +- /* driver is often null here; dev_dbg() would oops */
3949 +- pr_debug("usb %s: uevent\n", dev_name(dev));
3950 +-
3951 + if (is_usb_device(dev)) {
3952 + usb_dev = to_usb_device(dev);
3953 + } else if (is_usb_interface(dev)) {
3954 +@@ -705,6 +702,7 @@ static int usb_uevent(struct device *dev, struct kobj_uevent_env *env)
3955 + }
3956 +
3957 + if (usb_dev->devnum < 0) {
3958 ++ /* driver is often null here; dev_dbg() would oops */
3959 + pr_debug("usb %s: already deleted?\n", dev_name(dev));
3960 + return -ENODEV;
3961 + }
3962 +diff --git a/drivers/usb/core/hcd.c b/drivers/usb/core/hcd.c
3963 +index 80995ef..0477616 100644
3964 +--- a/drivers/usb/core/hcd.c
3965 ++++ b/drivers/usb/core/hcd.c
3966 +@@ -141,7 +141,7 @@ static const u8 usb3_rh_dev_descriptor[18] = {
3967 + 0x09, /* __u8 bMaxPacketSize0; 2^9 = 512 Bytes */
3968 +
3969 + 0x6b, 0x1d, /* __le16 idVendor; Linux Foundation */
3970 +- 0x02, 0x00, /* __le16 idProduct; device 0x0002 */
3971 ++ 0x03, 0x00, /* __le16 idProduct; device 0x0003 */
3972 + KERNEL_VER, KERNEL_REL, /* __le16 bcdDevice */
3973 +
3974 + 0x03, /* __u8 iManufacturer; */
3975 +diff --git a/drivers/usb/core/hcd.h b/drivers/usb/core/hcd.h
3976 +index bbe2b92..89613a7 100644
3977 +--- a/drivers/usb/core/hcd.h
3978 ++++ b/drivers/usb/core/hcd.h
3979 +@@ -248,7 +248,7 @@ struct hc_driver {
3980 + /* xHCI specific functions */
3981 + /* Called by usb_alloc_dev to alloc HC device structures */
3982 + int (*alloc_dev)(struct usb_hcd *, struct usb_device *);
3983 +- /* Called by usb_release_dev to free HC device structures */
3984 ++ /* Called by usb_disconnect to free HC device structures */
3985 + void (*free_dev)(struct usb_hcd *, struct usb_device *);
3986 +
3987 + /* Bandwidth computation functions */
3988 +diff --git a/drivers/usb/core/hub.c b/drivers/usb/core/hub.c
3989 +index 35cc8b9..9cc0aba 100644
3990 +--- a/drivers/usb/core/hub.c
3991 ++++ b/drivers/usb/core/hub.c
3992 +@@ -1554,6 +1554,15 @@ static inline void usb_stop_pm(struct usb_device *udev)
3993 +
3994 + #endif
3995 +
3996 ++static void hub_free_dev(struct usb_device *udev)
3997 ++{
3998 ++ struct usb_hcd *hcd = bus_to_hcd(udev->bus);
3999 ++
4000 ++ /* Root hubs aren't real devices, so don't free HCD resources */
4001 ++ if (hcd->driver->free_dev && udev->parent)
4002 ++ hcd->driver->free_dev(hcd, udev);
4003 ++}
4004 ++
4005 + /**
4006 + * usb_disconnect - disconnect a device (usbcore-internal)
4007 + * @pdev: pointer to device being disconnected
4008 +@@ -1624,6 +1633,8 @@ void usb_disconnect(struct usb_device **pdev)
4009 +
4010 + usb_stop_pm(udev);
4011 +
4012 ++ hub_free_dev(udev);
4013 ++
4014 + put_device(&udev->dev);
4015 + }
4016 +
4017 +@@ -3191,6 +3202,7 @@ loop_disable:
4018 + loop:
4019 + usb_ep0_reinit(udev);
4020 + release_address(udev);
4021 ++ hub_free_dev(udev);
4022 + usb_put_dev(udev);
4023 + if ((status == -ENOTCONN) || (status == -ENOTSUPP))
4024 + break;
4025 +diff --git a/drivers/usb/core/usb.c b/drivers/usb/core/usb.c
4026 +index 0daff0d..ced0776 100644
4027 +--- a/drivers/usb/core/usb.c
4028 ++++ b/drivers/usb/core/usb.c
4029 +@@ -228,9 +228,6 @@ static void usb_release_dev(struct device *dev)
4030 + hcd = bus_to_hcd(udev->bus);
4031 +
4032 + usb_destroy_configuration(udev);
4033 +- /* Root hubs aren't real devices, so don't free HCD resources */
4034 +- if (hcd->driver->free_dev && udev->parent)
4035 +- hcd->driver->free_dev(hcd, udev);
4036 + usb_put_hcd(hcd);
4037 + kfree(udev->product);
4038 + kfree(udev->manufacturer);
4039 +diff --git a/drivers/usb/gadget/f_mass_storage.c b/drivers/usb/gadget/f_mass_storage.c
4040 +index a37640e..73f9bbd 100644
4041 +--- a/drivers/usb/gadget/f_mass_storage.c
4042 ++++ b/drivers/usb/gadget/f_mass_storage.c
4043 +@@ -2852,7 +2852,6 @@ error_release:
4044 + /* Call fsg_common_release() directly, ref might be not
4045 + * initialised */
4046 + fsg_common_release(&common->ref);
4047 +- complete(&common->thread_notifier);
4048 + return ERR_PTR(rc);
4049 + }
4050 +
4051 +diff --git a/drivers/usb/host/ohci-pnx4008.c b/drivers/usb/host/ohci-pnx4008.c
4052 +index 2769326..cd74bbd 100644
4053 +--- a/drivers/usb/host/ohci-pnx4008.c
4054 ++++ b/drivers/usb/host/ohci-pnx4008.c
4055 +@@ -327,7 +327,7 @@ static int __devinit usb_hcd_pnx4008_probe(struct platform_device *pdev)
4056 + }
4057 + i2c_adap = i2c_get_adapter(2);
4058 + memset(&i2c_info, 0, sizeof(struct i2c_board_info));
4059 +- strlcpy(i2c_info.name, "isp1301_pnx", I2C_NAME_SIZE);
4060 ++ strlcpy(i2c_info.type, "isp1301_pnx", I2C_NAME_SIZE);
4061 + isp1301_i2c_client = i2c_new_probed_device(i2c_adap, &i2c_info,
4062 + normal_i2c);
4063 + i2c_put_adapter(i2c_adap);
4064 +@@ -411,7 +411,7 @@ out3:
4065 + out2:
4066 + clk_put(usb_clk);
4067 + out1:
4068 +- i2c_unregister_client(isp1301_i2c_client);
4069 ++ i2c_unregister_device(isp1301_i2c_client);
4070 + isp1301_i2c_client = NULL;
4071 + out_i2c_driver:
4072 + i2c_del_driver(&isp1301_driver);
4073 +@@ -430,7 +430,7 @@ static int usb_hcd_pnx4008_remove(struct platform_device *pdev)
4074 + pnx4008_unset_usb_bits();
4075 + clk_disable(usb_clk);
4076 + clk_put(usb_clk);
4077 +- i2c_unregister_client(isp1301_i2c_client);
4078 ++ i2c_unregister_device(isp1301_i2c_client);
4079 + isp1301_i2c_client = NULL;
4080 + i2c_del_driver(&isp1301_driver);
4081 +
4082 +diff --git a/drivers/usb/host/uhci-hcd.c b/drivers/usb/host/uhci-hcd.c
4083 +index 99cd00f..0919706 100644
4084 +--- a/drivers/usb/host/uhci-hcd.c
4085 ++++ b/drivers/usb/host/uhci-hcd.c
4086 +@@ -735,6 +735,7 @@ static void uhci_stop(struct usb_hcd *hcd)
4087 + uhci_hc_died(uhci);
4088 + uhci_scan_schedule(uhci);
4089 + spin_unlock_irq(&uhci->lock);
4090 ++ synchronize_irq(hcd->irq);
4091 +
4092 + del_timer_sync(&uhci->fsbr_timer);
4093 + release_uhci(uhci);
4094 +diff --git a/drivers/usb/host/xhci-ext-caps.h b/drivers/usb/host/xhci-ext-caps.h
4095 +index ecc131c..78c4eda 100644
4096 +--- a/drivers/usb/host/xhci-ext-caps.h
4097 ++++ b/drivers/usb/host/xhci-ext-caps.h
4098 +@@ -101,12 +101,15 @@ static inline int xhci_find_next_cap_offset(void __iomem *base, int ext_offset)
4099 +
4100 + next = readl(base + ext_offset);
4101 +
4102 +- if (ext_offset == XHCI_HCC_PARAMS_OFFSET)
4103 ++ if (ext_offset == XHCI_HCC_PARAMS_OFFSET) {
4104 + /* Find the first extended capability */
4105 + next = XHCI_HCC_EXT_CAPS(next);
4106 +- else
4107 ++ ext_offset = 0;
4108 ++ } else {
4109 + /* Find the next extended capability */
4110 + next = XHCI_EXT_CAPS_NEXT(next);
4111 ++ }
4112 ++
4113 + if (!next)
4114 + return 0;
4115 + /*
4116 +diff --git a/drivers/usb/serial/cp210x.c b/drivers/usb/serial/cp210x.c
4117 +index bd254ec..7d920f2 100644
4118 +--- a/drivers/usb/serial/cp210x.c
4119 ++++ b/drivers/usb/serial/cp210x.c
4120 +@@ -91,11 +91,12 @@ static struct usb_device_id id_table [] = {
4121 + { USB_DEVICE(0x10C4, 0x81C8) }, /* Lipowsky Industrie Elektronik GmbH, Baby-JTAG */
4122 + { USB_DEVICE(0x10C4, 0x81E2) }, /* Lipowsky Industrie Elektronik GmbH, Baby-LIN */
4123 + { USB_DEVICE(0x10C4, 0x81E7) }, /* Aerocomm Radio */
4124 ++ { USB_DEVICE(0x10C4, 0x81E8) }, /* Zephyr Bioharness */
4125 + { USB_DEVICE(0x10C4, 0x81F2) }, /* C1007 HF band RFID controller */
4126 + { USB_DEVICE(0x10C4, 0x8218) }, /* Lipowsky Industrie Elektronik GmbH, HARP-1 */
4127 + { USB_DEVICE(0x10C4, 0x822B) }, /* Modem EDGE(GSM) Comander 2 */
4128 + { USB_DEVICE(0x10C4, 0x826B) }, /* Cygnal Integrated Products, Inc., Fasttrax GPS demostration module */
4129 +- { USB_DEVICE(0x10c4, 0x8293) }, /* Telegesys ETRX2USB */
4130 ++ { USB_DEVICE(0x10C4, 0x8293) }, /* Telegesys ETRX2USB */
4131 + { USB_DEVICE(0x10C4, 0x82F9) }, /* Procyon AVS */
4132 + { USB_DEVICE(0x10C4, 0x8341) }, /* Siemens MC35PU GPRS Modem */
4133 + { USB_DEVICE(0x10C4, 0x8382) }, /* Cygnal Integrated Products, Inc. */
4134 +diff --git a/drivers/usb/serial/ftdi_sio.c b/drivers/usb/serial/ftdi_sio.c
4135 +index 7638828..34acf6c 100644
4136 +--- a/drivers/usb/serial/ftdi_sio.c
4137 ++++ b/drivers/usb/serial/ftdi_sio.c
4138 +@@ -614,6 +614,7 @@ static struct usb_device_id id_table_combined [] = {
4139 + { USB_DEVICE(FTDI_VID, FTDI_OCEANIC_PID) },
4140 + { USB_DEVICE(TTI_VID, TTI_QL355P_PID) },
4141 + { USB_DEVICE(FTDI_VID, FTDI_RM_CANVIEW_PID) },
4142 ++ { USB_DEVICE(CONTEC_VID, CONTEC_COM1USBH_PID) },
4143 + { USB_DEVICE(BANDB_VID, BANDB_USOTL4_PID) },
4144 + { USB_DEVICE(BANDB_VID, BANDB_USTL4_PID) },
4145 + { USB_DEVICE(BANDB_VID, BANDB_USO9ML2_PID) },
4146 +@@ -737,6 +738,10 @@ static struct usb_device_id id_table_combined [] = {
4147 + .driver_info = (kernel_ulong_t)&ftdi_jtag_quirk },
4148 + { USB_DEVICE(FTDI_VID, HAMEG_HO820_PID) },
4149 + { USB_DEVICE(FTDI_VID, HAMEG_HO870_PID) },
4150 ++ { USB_DEVICE(FTDI_VID, MJSG_GENERIC_PID) },
4151 ++ { USB_DEVICE(FTDI_VID, MJSG_SR_RADIO_PID) },
4152 ++ { USB_DEVICE(FTDI_VID, MJSG_HD_RADIO_PID) },
4153 ++ { USB_DEVICE(FTDI_VID, MJSG_XM_RADIO_PID) },
4154 + { }, /* Optional parameter entry */
4155 + { } /* Terminating entry */
4156 + };
4157 +diff --git a/drivers/usb/serial/ftdi_sio_ids.h b/drivers/usb/serial/ftdi_sio_ids.h
4158 +index c8951ae..d10b5a8 100644
4159 +--- a/drivers/usb/serial/ftdi_sio_ids.h
4160 ++++ b/drivers/usb/serial/ftdi_sio_ids.h
4161 +@@ -494,6 +494,13 @@
4162 + #define RATOC_PRODUCT_ID_USB60F 0xb020
4163 +
4164 + /*
4165 ++ * Contec products (http://www.contec.com)
4166 ++ * Submitted by Daniel Sangorrin
4167 ++ */
4168 ++#define CONTEC_VID 0x06CE /* Vendor ID */
4169 ++#define CONTEC_COM1USBH_PID 0x8311 /* COM-1(USB)H */
4170 ++
4171 ++/*
4172 + * Definitions for B&B Electronics products.
4173 + */
4174 + #define BANDB_VID 0x0856 /* B&B Electronics Vendor ID */
4175 +@@ -1002,3 +1009,11 @@
4176 + #define EVO_8U232AM_PID 0x02FF /* Evolution robotics RCM2 (FT232AM)*/
4177 + #define EVO_HYBRID_PID 0x0302 /* Evolution robotics RCM4 PID (FT232BM)*/
4178 + #define EVO_RCM4_PID 0x0303 /* Evolution robotics RCM4 PID */
4179 ++
4180 ++/*
4181 ++ * MJS Gadgets HD Radio / XM Radio / Sirius Radio interfaces (using VID 0x0403)
4182 ++ */
4183 ++#define MJSG_GENERIC_PID 0x9378
4184 ++#define MJSG_SR_RADIO_PID 0x9379
4185 ++#define MJSG_XM_RADIO_PID 0x937A
4186 ++#define MJSG_HD_RADIO_PID 0x937C
4187 +diff --git a/drivers/usb/serial/sierra.c b/drivers/usb/serial/sierra.c
4188 +index 3eb6143..0cfd621 100644
4189 +--- a/drivers/usb/serial/sierra.c
4190 ++++ b/drivers/usb/serial/sierra.c
4191 +@@ -604,14 +604,17 @@ static void sierra_indat_callback(struct urb *urb)
4192 + } else {
4193 + if (urb->actual_length) {
4194 + tty = tty_port_tty_get(&port->port);
4195 +-
4196 +- tty_buffer_request_room(tty, urb->actual_length);
4197 +- tty_insert_flip_string(tty, data, urb->actual_length);
4198 +- tty_flip_buffer_push(tty);
4199 +-
4200 +- tty_kref_put(tty);
4201 +- usb_serial_debug_data(debug, &port->dev, __func__,
4202 +- urb->actual_length, data);
4203 ++ if (tty) {
4204 ++ tty_buffer_request_room(tty,
4205 ++ urb->actual_length);
4206 ++ tty_insert_flip_string(tty, data,
4207 ++ urb->actual_length);
4208 ++ tty_flip_buffer_push(tty);
4209 ++
4210 ++ tty_kref_put(tty);
4211 ++ usb_serial_debug_data(debug, &port->dev,
4212 ++ __func__, urb->actual_length, data);
4213 ++ }
4214 + } else {
4215 + dev_dbg(&port->dev, "%s: empty read urb"
4216 + " received\n", __func__);
4217 +diff --git a/drivers/usb/storage/unusual_devs.h b/drivers/usb/storage/unusual_devs.h
4218 +index 49575fb..98b549b 100644
4219 +--- a/drivers/usb/storage/unusual_devs.h
4220 ++++ b/drivers/usb/storage/unusual_devs.h
4221 +@@ -1147,8 +1147,8 @@ UNUSUAL_DEV( 0x0af0, 0x7401, 0x0000, 0x0000,
4222 + 0 ),
4223 +
4224 + /* Reported by Jan Dumon <j.dumon@××××××.com>
4225 +- * This device (wrongly) has a vendor-specific device descriptor.
4226 +- * The entry is needed so usb-storage can bind to it's mass-storage
4227 ++ * These devices (wrongly) have a vendor-specific device descriptor.
4228 ++ * These entries are needed so usb-storage can bind to their mass-storage
4229 + * interface as an interface driver */
4230 + UNUSUAL_DEV( 0x0af0, 0x7501, 0x0000, 0x0000,
4231 + "Option",
4232 +@@ -1156,6 +1156,90 @@ UNUSUAL_DEV( 0x0af0, 0x7501, 0x0000, 0x0000,
4233 + US_SC_DEVICE, US_PR_DEVICE, NULL,
4234 + 0 ),
4235 +
4236 ++UNUSUAL_DEV( 0x0af0, 0x7701, 0x0000, 0x0000,
4237 ++ "Option",
4238 ++ "GI 0451 SD-Card",
4239 ++ US_SC_DEVICE, US_PR_DEVICE, NULL,
4240 ++ 0 ),
4241 ++
4242 ++UNUSUAL_DEV( 0x0af0, 0x7706, 0x0000, 0x0000,
4243 ++ "Option",
4244 ++ "GI 0451 SD-Card",
4245 ++ US_SC_DEVICE, US_PR_DEVICE, NULL,
4246 ++ 0 ),
4247 ++
4248 ++UNUSUAL_DEV( 0x0af0, 0x7901, 0x0000, 0x0000,
4249 ++ "Option",
4250 ++ "GI 0452 SD-Card",
4251 ++ US_SC_DEVICE, US_PR_DEVICE, NULL,
4252 ++ 0 ),
4253 ++
4254 ++UNUSUAL_DEV( 0x0af0, 0x7A01, 0x0000, 0x0000,
4255 ++ "Option",
4256 ++ "GI 0461 SD-Card",
4257 ++ US_SC_DEVICE, US_PR_DEVICE, NULL,
4258 ++ 0 ),
4259 ++
4260 ++UNUSUAL_DEV( 0x0af0, 0x7A05, 0x0000, 0x0000,
4261 ++ "Option",
4262 ++ "GI 0461 SD-Card",
4263 ++ US_SC_DEVICE, US_PR_DEVICE, NULL,
4264 ++ 0 ),
4265 ++
4266 ++UNUSUAL_DEV( 0x0af0, 0x8300, 0x0000, 0x0000,
4267 ++ "Option",
4268 ++ "GI 033x SD-Card",
4269 ++ US_SC_DEVICE, US_PR_DEVICE, NULL,
4270 ++ 0 ),
4271 ++
4272 ++UNUSUAL_DEV( 0x0af0, 0x8302, 0x0000, 0x0000,
4273 ++ "Option",
4274 ++ "GI 033x SD-Card",
4275 ++ US_SC_DEVICE, US_PR_DEVICE, NULL,
4276 ++ 0 ),
4277 ++
4278 ++UNUSUAL_DEV( 0x0af0, 0x8304, 0x0000, 0x0000,
4279 ++ "Option",
4280 ++ "GI 033x SD-Card",
4281 ++ US_SC_DEVICE, US_PR_DEVICE, NULL,
4282 ++ 0 ),
4283 ++
4284 ++UNUSUAL_DEV( 0x0af0, 0xc100, 0x0000, 0x0000,
4285 ++ "Option",
4286 ++ "GI 070x SD-Card",
4287 ++ US_SC_DEVICE, US_PR_DEVICE, NULL,
4288 ++ 0 ),
4289 ++
4290 ++UNUSUAL_DEV( 0x0af0, 0xd057, 0x0000, 0x0000,
4291 ++ "Option",
4292 ++ "GI 1505 SD-Card",
4293 ++ US_SC_DEVICE, US_PR_DEVICE, NULL,
4294 ++ 0 ),
4295 ++
4296 ++UNUSUAL_DEV( 0x0af0, 0xd058, 0x0000, 0x0000,
4297 ++ "Option",
4298 ++ "GI 1509 SD-Card",
4299 ++ US_SC_DEVICE, US_PR_DEVICE, NULL,
4300 ++ 0 ),
4301 ++
4302 ++UNUSUAL_DEV( 0x0af0, 0xd157, 0x0000, 0x0000,
4303 ++ "Option",
4304 ++ "GI 1515 SD-Card",
4305 ++ US_SC_DEVICE, US_PR_DEVICE, NULL,
4306 ++ 0 ),
4307 ++
4308 ++UNUSUAL_DEV( 0x0af0, 0xd257, 0x0000, 0x0000,
4309 ++ "Option",
4310 ++ "GI 1215 SD-Card",
4311 ++ US_SC_DEVICE, US_PR_DEVICE, NULL,
4312 ++ 0 ),
4313 ++
4314 ++UNUSUAL_DEV( 0x0af0, 0xd357, 0x0000, 0x0000,
4315 ++ "Option",
4316 ++ "GI 1505 SD-Card",
4317 ++ US_SC_DEVICE, US_PR_DEVICE, NULL,
4318 ++ 0 ),
4319 ++
4320 + /* Reported by Ben Efros <ben@×××××××××.com> */
4321 + UNUSUAL_DEV( 0x0bc2, 0x3010, 0x0000, 0x0000,
4322 + "Seagate",
4323 +diff --git a/drivers/video/sunxvr500.c b/drivers/video/sunxvr500.c
4324 +index 18b9507..4cd5049 100644
4325 +--- a/drivers/video/sunxvr500.c
4326 ++++ b/drivers/video/sunxvr500.c
4327 +@@ -400,6 +400,7 @@ static void __devexit e3d_pci_unregister(struct pci_dev *pdev)
4328 +
4329 + static struct pci_device_id e3d_pci_table[] = {
4330 + { PCI_DEVICE(PCI_VENDOR_ID_3DLABS, 0x7a0), },
4331 ++ { PCI_DEVICE(0x1091, 0x7a0), },
4332 + { PCI_DEVICE(PCI_VENDOR_ID_3DLABS, 0x7a2), },
4333 + { .vendor = PCI_VENDOR_ID_3DLABS,
4334 + .device = PCI_ANY_ID,
4335 +diff --git a/fs/file_table.c b/fs/file_table.c
4336 +index b98404b..32d12b7 100644
4337 +--- a/fs/file_table.c
4338 ++++ b/fs/file_table.c
4339 +@@ -393,7 +393,9 @@ retry:
4340 + continue;
4341 + if (!(f->f_mode & FMODE_WRITE))
4342 + continue;
4343 ++ spin_lock(&f->f_lock);
4344 + f->f_mode &= ~FMODE_WRITE;
4345 ++ spin_unlock(&f->f_lock);
4346 + if (file_check_writeable(f) != 0)
4347 + continue;
4348 + file_release_write(f);
4349 +diff --git a/fs/nfs/dns_resolve.c b/fs/nfs/dns_resolve.c
4350 +index 95e1ca7..3f0cd4d 100644
4351 +--- a/fs/nfs/dns_resolve.c
4352 ++++ b/fs/nfs/dns_resolve.c
4353 +@@ -36,6 +36,19 @@ struct nfs_dns_ent {
4354 + };
4355 +
4356 +
4357 ++static void nfs_dns_ent_update(struct cache_head *cnew,
4358 ++ struct cache_head *ckey)
4359 ++{
4360 ++ struct nfs_dns_ent *new;
4361 ++ struct nfs_dns_ent *key;
4362 ++
4363 ++ new = container_of(cnew, struct nfs_dns_ent, h);
4364 ++ key = container_of(ckey, struct nfs_dns_ent, h);
4365 ++
4366 ++ memcpy(&new->addr, &key->addr, key->addrlen);
4367 ++ new->addrlen = key->addrlen;
4368 ++}
4369 ++
4370 + static void nfs_dns_ent_init(struct cache_head *cnew,
4371 + struct cache_head *ckey)
4372 + {
4373 +@@ -49,8 +62,7 @@ static void nfs_dns_ent_init(struct cache_head *cnew,
4374 + new->hostname = kstrndup(key->hostname, key->namelen, GFP_KERNEL);
4375 + if (new->hostname) {
4376 + new->namelen = key->namelen;
4377 +- memcpy(&new->addr, &key->addr, key->addrlen);
4378 +- new->addrlen = key->addrlen;
4379 ++ nfs_dns_ent_update(cnew, ckey);
4380 + } else {
4381 + new->namelen = 0;
4382 + new->addrlen = 0;
4383 +@@ -234,7 +246,7 @@ static struct cache_detail nfs_dns_resolve = {
4384 + .cache_show = nfs_dns_show,
4385 + .match = nfs_dns_match,
4386 + .init = nfs_dns_ent_init,
4387 +- .update = nfs_dns_ent_init,
4388 ++ .update = nfs_dns_ent_update,
4389 + .alloc = nfs_dns_ent_alloc,
4390 + };
4391 +
4392 +diff --git a/fs/nfsd/nfs4state.c b/fs/nfsd/nfs4state.c
4393 +index f19ed86..fcafe60 100644
4394 +--- a/fs/nfsd/nfs4state.c
4395 ++++ b/fs/nfsd/nfs4state.c
4396 +@@ -1998,7 +1998,9 @@ nfs4_file_downgrade(struct file *filp, unsigned int share_access)
4397 + {
4398 + if (share_access & NFS4_SHARE_ACCESS_WRITE) {
4399 + drop_file_write_access(filp);
4400 ++ spin_lock(&filp->f_lock);
4401 + filp->f_mode = (filp->f_mode | FMODE_READ) & ~FMODE_WRITE;
4402 ++ spin_unlock(&filp->f_lock);
4403 + }
4404 + }
4405 +
4406 +diff --git a/fs/ocfs2/aops.c b/fs/ocfs2/aops.c
4407 +index 7e9df11..4c2a6d2 100644
4408 +--- a/fs/ocfs2/aops.c
4409 ++++ b/fs/ocfs2/aops.c
4410 +@@ -577,8 +577,9 @@ static int ocfs2_direct_IO_get_blocks(struct inode *inode, sector_t iblock,
4411 + goto bail;
4412 + }
4413 +
4414 +- /* We should already CoW the refcounted extent. */
4415 +- BUG_ON(ext_flags & OCFS2_EXT_REFCOUNTED);
4416 ++ /* We should already CoW the refcounted extent in case of create. */
4417 ++ BUG_ON(create && (ext_flags & OCFS2_EXT_REFCOUNTED));
4418 ++
4419 + /*
4420 + * get_more_blocks() expects us to describe a hole by clearing
4421 + * the mapped bit on bh_result().
4422 +diff --git a/fs/sysfs/dir.c b/fs/sysfs/dir.c
4423 +index 699f371..5c4703d 100644
4424 +--- a/fs/sysfs/dir.c
4425 ++++ b/fs/sysfs/dir.c
4426 +@@ -837,11 +837,46 @@ static inline unsigned char dt_type(struct sysfs_dirent *sd)
4427 + return (sd->s_mode >> 12) & 15;
4428 + }
4429 +
4430 ++static int sysfs_dir_release(struct inode *inode, struct file *filp)
4431 ++{
4432 ++ sysfs_put(filp->private_data);
4433 ++ return 0;
4434 ++}
4435 ++
4436 ++static struct sysfs_dirent *sysfs_dir_pos(struct sysfs_dirent *parent_sd,
4437 ++ ino_t ino, struct sysfs_dirent *pos)
4438 ++{
4439 ++ if (pos) {
4440 ++ int valid = !(pos->s_flags & SYSFS_FLAG_REMOVED) &&
4441 ++ pos->s_parent == parent_sd &&
4442 ++ ino == pos->s_ino;
4443 ++ sysfs_put(pos);
4444 ++ if (valid)
4445 ++ return pos;
4446 ++ }
4447 ++ pos = NULL;
4448 ++ if ((ino > 1) && (ino < INT_MAX)) {
4449 ++ pos = parent_sd->s_dir.children;
4450 ++ while (pos && (ino > pos->s_ino))
4451 ++ pos = pos->s_sibling;
4452 ++ }
4453 ++ return pos;
4454 ++}
4455 ++
4456 ++static struct sysfs_dirent *sysfs_dir_next_pos(struct sysfs_dirent *parent_sd,
4457 ++ ino_t ino, struct sysfs_dirent *pos)
4458 ++{
4459 ++ pos = sysfs_dir_pos(parent_sd, ino, pos);
4460 ++ if (pos)
4461 ++ pos = pos->s_sibling;
4462 ++ return pos;
4463 ++}
4464 ++
4465 + static int sysfs_readdir(struct file * filp, void * dirent, filldir_t filldir)
4466 + {
4467 + struct dentry *dentry = filp->f_path.dentry;
4468 + struct sysfs_dirent * parent_sd = dentry->d_fsdata;
4469 +- struct sysfs_dirent *pos;
4470 ++ struct sysfs_dirent *pos = filp->private_data;
4471 + ino_t ino;
4472 +
4473 + if (filp->f_pos == 0) {
4474 +@@ -857,29 +892,31 @@ static int sysfs_readdir(struct file * filp, void * dirent, filldir_t filldir)
4475 + if (filldir(dirent, "..", 2, filp->f_pos, ino, DT_DIR) == 0)
4476 + filp->f_pos++;
4477 + }
4478 +- if ((filp->f_pos > 1) && (filp->f_pos < INT_MAX)) {
4479 +- mutex_lock(&sysfs_mutex);
4480 +-
4481 +- /* Skip the dentries we have already reported */
4482 +- pos = parent_sd->s_dir.children;
4483 +- while (pos && (filp->f_pos > pos->s_ino))
4484 +- pos = pos->s_sibling;
4485 +-
4486 +- for ( ; pos; pos = pos->s_sibling) {
4487 +- const char * name;
4488 +- int len;
4489 +-
4490 +- name = pos->s_name;
4491 +- len = strlen(name);
4492 +- filp->f_pos = ino = pos->s_ino;
4493 ++ mutex_lock(&sysfs_mutex);
4494 ++ for (pos = sysfs_dir_pos(parent_sd, filp->f_pos, pos);
4495 ++ pos;
4496 ++ pos = sysfs_dir_next_pos(parent_sd, filp->f_pos, pos)) {
4497 ++ const char * name;
4498 ++ unsigned int type;
4499 ++ int len, ret;
4500 ++
4501 ++ name = pos->s_name;
4502 ++ len = strlen(name);
4503 ++ ino = pos->s_ino;
4504 ++ type = dt_type(pos);
4505 ++ filp->f_pos = ino;
4506 ++ filp->private_data = sysfs_get(pos);
4507 +
4508 +- if (filldir(dirent, name, len, filp->f_pos, ino,
4509 +- dt_type(pos)) < 0)
4510 +- break;
4511 +- }
4512 +- if (!pos)
4513 +- filp->f_pos = INT_MAX;
4514 + mutex_unlock(&sysfs_mutex);
4515 ++ ret = filldir(dirent, name, len, filp->f_pos, ino, type);
4516 ++ mutex_lock(&sysfs_mutex);
4517 ++ if (ret < 0)
4518 ++ break;
4519 ++ }
4520 ++ mutex_unlock(&sysfs_mutex);
4521 ++ if ((filp->f_pos > 1) && !pos) { /* EOF */
4522 ++ filp->f_pos = INT_MAX;
4523 ++ filp->private_data = NULL;
4524 + }
4525 + return 0;
4526 + }
4527 +@@ -888,5 +925,6 @@ static int sysfs_readdir(struct file * filp, void * dirent, filldir_t filldir)
4528 + const struct file_operations sysfs_dir_operations = {
4529 + .read = generic_read_dir,
4530 + .readdir = sysfs_readdir,
4531 ++ .release = sysfs_dir_release,
4532 + .llseek = generic_file_llseek,
4533 + };
4534 +diff --git a/include/linux/fs.h b/include/linux/fs.h
4535 +index ebb1cd5..f2f68ce 100644
4536 +--- a/include/linux/fs.h
4537 ++++ b/include/linux/fs.h
4538 +@@ -87,6 +87,9 @@ struct inodes_stat_t {
4539 + */
4540 + #define FMODE_NOCMTIME ((__force fmode_t)2048)
4541 +
4542 ++/* Expect random access pattern */
4543 ++#define FMODE_RANDOM ((__force fmode_t)4096)
4544 ++
4545 + /*
4546 + * The below are the various read and write types that we support. Some of
4547 + * them include behavioral modifiers that send information down to the
4548 +diff --git a/include/linux/irq.h b/include/linux/irq.h
4549 +index 451481c..4d9b26e 100644
4550 +--- a/include/linux/irq.h
4551 ++++ b/include/linux/irq.h
4552 +@@ -400,7 +400,9 @@ static inline int irq_has_action(unsigned int irq)
4553 +
4554 + /* Dynamic irq helper functions */
4555 + extern void dynamic_irq_init(unsigned int irq);
4556 ++void dynamic_irq_init_keep_chip_data(unsigned int irq);
4557 + extern void dynamic_irq_cleanup(unsigned int irq);
4558 ++void dynamic_irq_cleanup_keep_chip_data(unsigned int irq);
4559 +
4560 + /* Set/get chip/data for an IRQ: */
4561 + extern int set_irq_chip(unsigned int irq, struct irq_chip *chip);
4562 +diff --git a/include/linux/netdevice.h b/include/linux/netdevice.h
4563 +index a3fccc8..99914e6 100644
4564 +--- a/include/linux/netdevice.h
4565 ++++ b/include/linux/netdevice.h
4566 +@@ -136,7 +136,7 @@ static inline bool dev_xmit_complete(int rc)
4567 + * used.
4568 + */
4569 +
4570 +-#if defined(CONFIG_WLAN_80211) || defined(CONFIG_AX25) || defined(CONFIG_AX25_MODULE)
4571 ++#if defined(CONFIG_WLAN) || defined(CONFIG_AX25) || defined(CONFIG_AX25_MODULE)
4572 + # if defined(CONFIG_MAC80211_MESH)
4573 + # define LL_MAX_HEADER 128
4574 + # else
4575 +diff --git a/include/linux/perf_event.h b/include/linux/perf_event.h
4576 +index a177698..c8ea0c7 100644
4577 +--- a/include/linux/perf_event.h
4578 ++++ b/include/linux/perf_event.h
4579 +@@ -496,9 +496,8 @@ struct hw_perf_event {
4580 + atomic64_t period_left;
4581 + u64 interrupts;
4582 +
4583 +- u64 freq_count;
4584 +- u64 freq_interrupts;
4585 +- u64 freq_stamp;
4586 ++ u64 freq_time_stamp;
4587 ++ u64 freq_count_stamp;
4588 + #endif
4589 + };
4590 +
4591 +diff --git a/include/linux/sched.h b/include/linux/sched.h
4592 +index 78efe7c..1f5fa53 100644
4593 +--- a/include/linux/sched.h
4594 ++++ b/include/linux/sched.h
4595 +@@ -878,7 +878,10 @@ static inline int sd_balance_for_mc_power(void)
4596 + if (sched_smt_power_savings)
4597 + return SD_POWERSAVINGS_BALANCE;
4598 +
4599 +- return SD_PREFER_SIBLING;
4600 ++ if (!sched_mc_power_savings)
4601 ++ return SD_PREFER_SIBLING;
4602 ++
4603 ++ return 0;
4604 + }
4605 +
4606 + static inline int sd_balance_for_package_power(void)
4607 +diff --git a/include/linux/skbuff.h b/include/linux/skbuff.h
4608 +index ae836fd..ec226a2 100644
4609 +--- a/include/linux/skbuff.h
4610 ++++ b/include/linux/skbuff.h
4611 +@@ -315,22 +315,23 @@ struct sk_buff {
4612 + struct sk_buff *next;
4613 + struct sk_buff *prev;
4614 +
4615 +- struct sock *sk;
4616 + ktime_t tstamp;
4617 ++
4618 ++ struct sock *sk;
4619 + struct net_device *dev;
4620 +
4621 +- unsigned long _skb_dst;
4622 +-#ifdef CONFIG_XFRM
4623 +- struct sec_path *sp;
4624 +-#endif
4625 + /*
4626 + * This is the control buffer. It is free to use for every
4627 + * layer. Please put your private variables there. If you
4628 + * want to keep them across layers you have to do a skb_clone()
4629 + * first. This is owned by whoever has the skb queued ATM.
4630 + */
4631 +- char cb[48];
4632 ++ char cb[48] __aligned(8);
4633 +
4634 ++ unsigned long _skb_dst;
4635 ++#ifdef CONFIG_XFRM
4636 ++ struct sec_path *sp;
4637 ++#endif
4638 + unsigned int len,
4639 + data_len;
4640 + __u16 mac_len,
4641 +diff --git a/include/linux/syscalls.h b/include/linux/syscalls.h
4642 +index 207466a..2540770 100644
4643 +--- a/include/linux/syscalls.h
4644 ++++ b/include/linux/syscalls.h
4645 +@@ -132,7 +132,8 @@ struct perf_event_attr;
4646 +
4647 + #define SYSCALL_TRACE_ENTER_EVENT(sname) \
4648 + static const struct syscall_metadata __syscall_meta_##sname; \
4649 +- static struct ftrace_event_call event_enter_##sname; \
4650 ++ static struct ftrace_event_call \
4651 ++ __attribute__((__aligned__(4))) event_enter_##sname; \
4652 + static struct trace_event enter_syscall_print_##sname = { \
4653 + .trace = print_syscall_enter, \
4654 + }; \
4655 +@@ -154,7 +155,8 @@ struct perf_event_attr;
4656 +
4657 + #define SYSCALL_TRACE_EXIT_EVENT(sname) \
4658 + static const struct syscall_metadata __syscall_meta_##sname; \
4659 +- static struct ftrace_event_call event_exit_##sname; \
4660 ++ static struct ftrace_event_call \
4661 ++ __attribute__((__aligned__(4))) event_exit_##sname; \
4662 + static struct trace_event exit_syscall_print_##sname = { \
4663 + .trace = print_syscall_exit, \
4664 + }; \
4665 +diff --git a/include/trace/ftrace.h b/include/trace/ftrace.h
4666 +index c6fe03e..1ca4990 100644
4667 +--- a/include/trace/ftrace.h
4668 ++++ b/include/trace/ftrace.h
4669 +@@ -65,7 +65,8 @@
4670 + };
4671 + #undef DEFINE_EVENT
4672 + #define DEFINE_EVENT(template, name, proto, args) \
4673 +- static struct ftrace_event_call event_##name
4674 ++ static struct ftrace_event_call \
4675 ++ __attribute__((__aligned__(4))) event_##name
4676 +
4677 + #undef DEFINE_EVENT_PRINT
4678 + #define DEFINE_EVENT_PRINT(template, name, proto, args, print) \
4679 +diff --git a/kernel/irq/chip.c b/kernel/irq/chip.c
4680 +index ecc3fa2..d70394f 100644
4681 +--- a/kernel/irq/chip.c
4682 ++++ b/kernel/irq/chip.c
4683 +@@ -18,11 +18,7 @@
4684 +
4685 + #include "internals.h"
4686 +
4687 +-/**
4688 +- * dynamic_irq_init - initialize a dynamically allocated irq
4689 +- * @irq: irq number to initialize
4690 +- */
4691 +-void dynamic_irq_init(unsigned int irq)
4692 ++static void dynamic_irq_init_x(unsigned int irq, bool keep_chip_data)
4693 + {
4694 + struct irq_desc *desc;
4695 + unsigned long flags;
4696 +@@ -41,7 +37,8 @@ void dynamic_irq_init(unsigned int irq)
4697 + desc->depth = 1;
4698 + desc->msi_desc = NULL;
4699 + desc->handler_data = NULL;
4700 +- desc->chip_data = NULL;
4701 ++ if (!keep_chip_data)
4702 ++ desc->chip_data = NULL;
4703 + desc->action = NULL;
4704 + desc->irq_count = 0;
4705 + desc->irqs_unhandled = 0;
4706 +@@ -55,10 +52,26 @@ void dynamic_irq_init(unsigned int irq)
4707 + }
4708 +
4709 + /**
4710 +- * dynamic_irq_cleanup - cleanup a dynamically allocated irq
4711 ++ * dynamic_irq_init - initialize a dynamically allocated irq
4712 + * @irq: irq number to initialize
4713 + */
4714 +-void dynamic_irq_cleanup(unsigned int irq)
4715 ++void dynamic_irq_init(unsigned int irq)
4716 ++{
4717 ++ dynamic_irq_init_x(irq, false);
4718 ++}
4719 ++
4720 ++/**
4721 ++ * dynamic_irq_init_keep_chip_data - initialize a dynamically allocated irq
4722 ++ * @irq: irq number to initialize
4723 ++ *
4724 ++ * does not set irq_to_desc(irq)->chip_data to NULL
4725 ++ */
4726 ++void dynamic_irq_init_keep_chip_data(unsigned int irq)
4727 ++{
4728 ++ dynamic_irq_init_x(irq, true);
4729 ++}
4730 ++
4731 ++static void dynamic_irq_cleanup_x(unsigned int irq, bool keep_chip_data)
4732 + {
4733 + struct irq_desc *desc = irq_to_desc(irq);
4734 + unsigned long flags;
4735 +@@ -77,7 +90,8 @@ void dynamic_irq_cleanup(unsigned int irq)
4736 + }
4737 + desc->msi_desc = NULL;
4738 + desc->handler_data = NULL;
4739 +- desc->chip_data = NULL;
4740 ++ if (!keep_chip_data)
4741 ++ desc->chip_data = NULL;
4742 + desc->handle_irq = handle_bad_irq;
4743 + desc->chip = &no_irq_chip;
4744 + desc->name = NULL;
4745 +@@ -85,6 +99,26 @@ void dynamic_irq_cleanup(unsigned int irq)
4746 + raw_spin_unlock_irqrestore(&desc->lock, flags);
4747 + }
4748 +
4749 ++/**
4750 ++ * dynamic_irq_cleanup - cleanup a dynamically allocated irq
4751 ++ * @irq: irq number to initialize
4752 ++ */
4753 ++void dynamic_irq_cleanup(unsigned int irq)
4754 ++{
4755 ++ dynamic_irq_cleanup_x(irq, false);
4756 ++}
4757 ++
4758 ++/**
4759 ++ * dynamic_irq_cleanup_keep_chip_data - cleanup a dynamically allocated irq
4760 ++ * @irq: irq number to initialize
4761 ++ *
4762 ++ * does not set irq_to_desc(irq)->chip_data to NULL
4763 ++ */
4764 ++void dynamic_irq_cleanup_keep_chip_data(unsigned int irq)
4765 ++{
4766 ++ dynamic_irq_cleanup_x(irq, true);
4767 ++}
4768 ++
4769 +
4770 + /**
4771 + * set_irq_chip - set the irq chip for an irq
4772 +diff --git a/kernel/perf_event.c b/kernel/perf_event.c
4773 +index 2ae7409..b707465 100644
4774 +--- a/kernel/perf_event.c
4775 ++++ b/kernel/perf_event.c
4776 +@@ -248,7 +248,7 @@ static void perf_unpin_context(struct perf_event_context *ctx)
4777 +
4778 + static inline u64 perf_clock(void)
4779 + {
4780 +- return cpu_clock(smp_processor_id());
4781 ++ return cpu_clock(raw_smp_processor_id());
4782 + }
4783 +
4784 + /*
4785 +@@ -1350,14 +1350,83 @@ static void perf_event_cpu_sched_in(struct perf_cpu_context *cpuctx, int cpu)
4786 +
4787 + static void perf_log_throttle(struct perf_event *event, int enable);
4788 +
4789 +-static void perf_adjust_period(struct perf_event *event, u64 events)
4790 ++static u64 perf_calculate_period(struct perf_event *event, u64 nsec, u64 count)
4791 ++{
4792 ++ u64 frequency = event->attr.sample_freq;
4793 ++ u64 sec = NSEC_PER_SEC;
4794 ++ u64 divisor, dividend;
4795 ++
4796 ++ int count_fls, nsec_fls, frequency_fls, sec_fls;
4797 ++
4798 ++ count_fls = fls64(count);
4799 ++ nsec_fls = fls64(nsec);
4800 ++ frequency_fls = fls64(frequency);
4801 ++ sec_fls = 30;
4802 ++
4803 ++ /*
4804 ++ * We got @count in @nsec, with a target of sample_freq HZ
4805 ++ * the target period becomes:
4806 ++ *
4807 ++ * @count * 10^9
4808 ++ * period = -------------------
4809 ++ * @nsec * sample_freq
4810 ++ *
4811 ++ */
4812 ++
4813 ++ /*
4814 ++ * Reduce accuracy by one bit such that @a and @b converge
4815 ++ * to a similar magnitude.
4816 ++ */
4817 ++#define REDUCE_FLS(a, b) \
4818 ++do { \
4819 ++ if (a##_fls > b##_fls) { \
4820 ++ a >>= 1; \
4821 ++ a##_fls--; \
4822 ++ } else { \
4823 ++ b >>= 1; \
4824 ++ b##_fls--; \
4825 ++ } \
4826 ++} while (0)
4827 ++
4828 ++ /*
4829 ++ * Reduce accuracy until either term fits in a u64, then proceed with
4830 ++ * the other, so that finally we can do a u64/u64 division.
4831 ++ */
4832 ++ while (count_fls + sec_fls > 64 && nsec_fls + frequency_fls > 64) {
4833 ++ REDUCE_FLS(nsec, frequency);
4834 ++ REDUCE_FLS(sec, count);
4835 ++ }
4836 ++
4837 ++ if (count_fls + sec_fls > 64) {
4838 ++ divisor = nsec * frequency;
4839 ++
4840 ++ while (count_fls + sec_fls > 64) {
4841 ++ REDUCE_FLS(count, sec);
4842 ++ divisor >>= 1;
4843 ++ }
4844 ++
4845 ++ dividend = count * sec;
4846 ++ } else {
4847 ++ dividend = count * sec;
4848 ++
4849 ++ while (nsec_fls + frequency_fls > 64) {
4850 ++ REDUCE_FLS(nsec, frequency);
4851 ++ dividend >>= 1;
4852 ++ }
4853 ++
4854 ++ divisor = nsec * frequency;
4855 ++ }
4856 ++
4857 ++ return div64_u64(dividend, divisor);
4858 ++}
4859 ++
4860 ++static void perf_adjust_period(struct perf_event *event, u64 nsec, u64 count)
4861 + {
4862 + struct hw_perf_event *hwc = &event->hw;
4863 + u64 period, sample_period;
4864 + s64 delta;
4865 +
4866 +- events *= hwc->sample_period;
4867 +- period = div64_u64(events, event->attr.sample_freq);
4868 ++ period = perf_calculate_period(event, nsec, count);
4869 +
4870 + delta = (s64)(period - hwc->sample_period);
4871 + delta = (delta + 7) / 8; /* low pass filter */
4872 +@@ -1368,13 +1437,22 @@ static void perf_adjust_period(struct perf_event *event, u64 events)
4873 + sample_period = 1;
4874 +
4875 + hwc->sample_period = sample_period;
4876 ++
4877 ++ if (atomic64_read(&hwc->period_left) > 8*sample_period) {
4878 ++ perf_disable();
4879 ++ event->pmu->disable(event);
4880 ++ atomic64_set(&hwc->period_left, 0);
4881 ++ event->pmu->enable(event);
4882 ++ perf_enable();
4883 ++ }
4884 + }
4885 +
4886 + static void perf_ctx_adjust_freq(struct perf_event_context *ctx)
4887 + {
4888 + struct perf_event *event;
4889 + struct hw_perf_event *hwc;
4890 +- u64 interrupts, freq;
4891 ++ u64 interrupts, now;
4892 ++ s64 delta;
4893 +
4894 + raw_spin_lock(&ctx->lock);
4895 + list_for_each_entry_rcu(event, &ctx->event_list, event_entry) {
4896 +@@ -1395,44 +1473,18 @@ static void perf_ctx_adjust_freq(struct perf_event_context *ctx)
4897 + if (interrupts == MAX_INTERRUPTS) {
4898 + perf_log_throttle(event, 1);
4899 + event->pmu->unthrottle(event);
4900 +- interrupts = 2*sysctl_perf_event_sample_rate/HZ;
4901 + }
4902 +
4903 + if (!event->attr.freq || !event->attr.sample_freq)
4904 + continue;
4905 +
4906 +- /*
4907 +- * if the specified freq < HZ then we need to skip ticks
4908 +- */
4909 +- if (event->attr.sample_freq < HZ) {
4910 +- freq = event->attr.sample_freq;
4911 +-
4912 +- hwc->freq_count += freq;
4913 +- hwc->freq_interrupts += interrupts;
4914 +-
4915 +- if (hwc->freq_count < HZ)
4916 +- continue;
4917 +-
4918 +- interrupts = hwc->freq_interrupts;
4919 +- hwc->freq_interrupts = 0;
4920 +- hwc->freq_count -= HZ;
4921 +- } else
4922 +- freq = HZ;
4923 +-
4924 +- perf_adjust_period(event, freq * interrupts);
4925 ++ event->pmu->read(event);
4926 ++ now = atomic64_read(&event->count);
4927 ++ delta = now - hwc->freq_count_stamp;
4928 ++ hwc->freq_count_stamp = now;
4929 +
4930 +- /*
4931 +- * In order to avoid being stalled by an (accidental) huge
4932 +- * sample period, force reset the sample period if we didn't
4933 +- * get any events in this freq period.
4934 +- */
4935 +- if (!interrupts) {
4936 +- perf_disable();
4937 +- event->pmu->disable(event);
4938 +- atomic64_set(&hwc->period_left, 0);
4939 +- event->pmu->enable(event);
4940 +- perf_enable();
4941 +- }
4942 ++ if (delta > 0)
4943 ++ perf_adjust_period(event, TICK_NSEC, delta);
4944 + }
4945 + raw_spin_unlock(&ctx->lock);
4946 + }
4947 +@@ -3688,12 +3740,12 @@ static int __perf_event_overflow(struct perf_event *event, int nmi,
4948 +
4949 + if (event->attr.freq) {
4950 + u64 now = perf_clock();
4951 +- s64 delta = now - hwc->freq_stamp;
4952 ++ s64 delta = now - hwc->freq_time_stamp;
4953 +
4954 +- hwc->freq_stamp = now;
4955 ++ hwc->freq_time_stamp = now;
4956 +
4957 +- if (delta > 0 && delta < TICK_NSEC)
4958 +- perf_adjust_period(event, NSEC_PER_SEC / (int)delta);
4959 ++ if (delta > 0 && delta < 2*TICK_NSEC)
4960 ++ perf_adjust_period(event, delta, hwc->last_period);
4961 + }
4962 +
4963 + /*
4964 +diff --git a/kernel/power/snapshot.c b/kernel/power/snapshot.c
4965 +index 36cb168..fc9ed15 100644
4966 +--- a/kernel/power/snapshot.c
4967 ++++ b/kernel/power/snapshot.c
4968 +@@ -1181,7 +1181,7 @@ static void free_unnecessary_pages(void)
4969 +
4970 + memory_bm_position_reset(&copy_bm);
4971 +
4972 +- while (to_free_normal > 0 && to_free_highmem > 0) {
4973 ++ while (to_free_normal > 0 || to_free_highmem > 0) {
4974 + unsigned long pfn = memory_bm_next_pfn(&copy_bm);
4975 + struct page *page = pfn_to_page(pfn);
4976 +
4977 +diff --git a/kernel/sched.c b/kernel/sched.c
4978 +index 3a8fb30..00a59b0 100644
4979 +--- a/kernel/sched.c
4980 ++++ b/kernel/sched.c
4981 +@@ -4119,12 +4119,23 @@ find_busiest_queue(struct sched_group *group, enum cpu_idle_type idle,
4982 + continue;
4983 +
4984 + rq = cpu_rq(i);
4985 +- wl = weighted_cpuload(i) * SCHED_LOAD_SCALE;
4986 +- wl /= power;
4987 ++ wl = weighted_cpuload(i);
4988 +
4989 ++ /*
4990 ++ * When comparing with imbalance, use weighted_cpuload()
4991 ++ * which is not scaled with the cpu power.
4992 ++ */
4993 + if (capacity && rq->nr_running == 1 && wl > imbalance)
4994 + continue;
4995 +
4996 ++ /*
4997 ++ * For the load comparisons with the other cpu's, consider
4998 ++ * the weighted_cpuload() scaled with the cpu power, so that
4999 ++ * the load can be moved away from the cpu that is potentially
5000 ++ * running at a lower capacity.
5001 ++ */
5002 ++ wl = (wl * SCHED_LOAD_SCALE) / power;
5003 ++
5004 + if (wl > max_load) {
5005 + max_load = wl;
5006 + busiest = rq;
5007 +@@ -6054,7 +6065,7 @@ void rt_mutex_setprio(struct task_struct *p, int prio)
5008 + unsigned long flags;
5009 + int oldprio, on_rq, running;
5010 + struct rq *rq;
5011 +- const struct sched_class *prev_class = p->sched_class;
5012 ++ const struct sched_class *prev_class;
5013 +
5014 + BUG_ON(prio < 0 || prio > MAX_PRIO);
5015 +
5016 +@@ -6062,6 +6073,7 @@ void rt_mutex_setprio(struct task_struct *p, int prio)
5017 + update_rq_clock(rq);
5018 +
5019 + oldprio = p->prio;
5020 ++ prev_class = p->sched_class;
5021 + on_rq = p->se.on_rq;
5022 + running = task_current(rq, p);
5023 + if (on_rq)
5024 +@@ -6281,7 +6293,7 @@ static int __sched_setscheduler(struct task_struct *p, int policy,
5025 + {
5026 + int retval, oldprio, oldpolicy = -1, on_rq, running;
5027 + unsigned long flags;
5028 +- const struct sched_class *prev_class = p->sched_class;
5029 ++ const struct sched_class *prev_class;
5030 + struct rq *rq;
5031 + int reset_on_fork;
5032 +
5033 +@@ -6395,6 +6407,7 @@ recheck:
5034 + p->sched_reset_on_fork = reset_on_fork;
5035 +
5036 + oldprio = p->prio;
5037 ++ prev_class = p->sched_class;
5038 + __setscheduler(rq, p, policy, param->sched_priority);
5039 +
5040 + if (running)
5041 +diff --git a/kernel/trace/trace.h b/kernel/trace/trace.h
5042 +index 4df6a77..a1edaa8 100644
5043 +--- a/kernel/trace/trace.h
5044 ++++ b/kernel/trace/trace.h
5045 +@@ -791,7 +791,8 @@ extern const char *__stop___trace_bprintk_fmt[];
5046 +
5047 + #undef FTRACE_ENTRY
5048 + #define FTRACE_ENTRY(call, struct_name, id, tstruct, print) \
5049 +- extern struct ftrace_event_call event_##call;
5050 ++ extern struct ftrace_event_call \
5051 ++ __attribute__((__aligned__(4))) event_##call;
5052 + #undef FTRACE_ENTRY_DUP
5053 + #define FTRACE_ENTRY_DUP(call, struct_name, id, tstruct, print) \
5054 + FTRACE_ENTRY(call, struct_name, id, PARAMS(tstruct), PARAMS(print))
5055 +diff --git a/mm/fadvise.c b/mm/fadvise.c
5056 +index e433592..8d723c9 100644
5057 +--- a/mm/fadvise.c
5058 ++++ b/mm/fadvise.c
5059 +@@ -77,12 +77,20 @@ SYSCALL_DEFINE(fadvise64_64)(int fd, loff_t offset, loff_t len, int advice)
5060 + switch (advice) {
5061 + case POSIX_FADV_NORMAL:
5062 + file->f_ra.ra_pages = bdi->ra_pages;
5063 ++ spin_lock(&file->f_lock);
5064 ++ file->f_mode &= ~FMODE_RANDOM;
5065 ++ spin_unlock(&file->f_lock);
5066 + break;
5067 + case POSIX_FADV_RANDOM:
5068 +- file->f_ra.ra_pages = 0;
5069 ++ spin_lock(&file->f_lock);
5070 ++ file->f_mode |= FMODE_RANDOM;
5071 ++ spin_unlock(&file->f_lock);
5072 + break;
5073 + case POSIX_FADV_SEQUENTIAL:
5074 + file->f_ra.ra_pages = bdi->ra_pages * 2;
5075 ++ spin_lock(&file->f_lock);
5076 ++ file->f_mode &= ~FMODE_RANDOM;
5077 ++ spin_unlock(&file->f_lock);
5078 + break;
5079 + case POSIX_FADV_WILLNEED:
5080 + if (!mapping->a_ops->readpage) {
5081 +diff --git a/mm/readahead.c b/mm/readahead.c
5082 +index 033bc13..337b20e 100644
5083 +--- a/mm/readahead.c
5084 ++++ b/mm/readahead.c
5085 +@@ -501,6 +501,12 @@ void page_cache_sync_readahead(struct address_space *mapping,
5086 + if (!ra->ra_pages)
5087 + return;
5088 +
5089 ++ /* be dumb */
5090 ++ if (filp->f_mode & FMODE_RANDOM) {
5091 ++ force_page_cache_readahead(mapping, filp, offset, req_size);
5092 ++ return;
5093 ++ }
5094 ++
5095 + /* do read-ahead */
5096 + ondemand_readahead(mapping, ra, filp, false, offset, req_size);
5097 + }
5098 +diff --git a/mm/slab.c b/mm/slab.c
5099 +index 7451bda..ff44eb2 100644
5100 +--- a/mm/slab.c
5101 ++++ b/mm/slab.c
5102 +@@ -983,13 +983,11 @@ static struct array_cache **alloc_alien_cache(int node, int limit, gfp_t gfp)
5103 +
5104 + if (limit > 1)
5105 + limit = 12;
5106 +- ac_ptr = kmalloc_node(memsize, gfp, node);
5107 ++ ac_ptr = kzalloc_node(memsize, gfp, node);
5108 + if (ac_ptr) {
5109 + for_each_node(i) {
5110 +- if (i == node || !node_online(i)) {
5111 +- ac_ptr[i] = NULL;
5112 ++ if (i == node || !node_online(i))
5113 + continue;
5114 +- }
5115 + ac_ptr[i] = alloc_arraycache(node, limit, 0xbaadf00d, gfp);
5116 + if (!ac_ptr[i]) {
5117 + for (i--; i >= 0; i--)
5118 +diff --git a/net/core/scm.c b/net/core/scm.c
5119 +index b7ba91b..9b26463 100644
5120 +--- a/net/core/scm.c
5121 ++++ b/net/core/scm.c
5122 +@@ -156,6 +156,8 @@ int __scm_send(struct socket *sock, struct msghdr *msg, struct scm_cookie *p)
5123 + switch (cmsg->cmsg_type)
5124 + {
5125 + case SCM_RIGHTS:
5126 ++ if (!sock->ops || sock->ops->family != PF_UNIX)
5127 ++ goto error;
5128 + err=scm_fp_copy(cmsg, &p->fp);
5129 + if (err<0)
5130 + goto error;
5131 +diff --git a/net/mac80211/agg-tx.c b/net/mac80211/agg-tx.c
5132 +index 5e3a7ec..304b0b6 100644
5133 +--- a/net/mac80211/agg-tx.c
5134 ++++ b/net/mac80211/agg-tx.c
5135 +@@ -179,7 +179,8 @@ static void sta_addba_resp_timer_expired(unsigned long data)
5136 +
5137 + /* check if the TID waits for addBA response */
5138 + spin_lock_bh(&sta->lock);
5139 +- if ((*state & (HT_ADDBA_REQUESTED_MSK | HT_ADDBA_RECEIVED_MSK)) !=
5140 ++ if ((*state & (HT_ADDBA_REQUESTED_MSK | HT_ADDBA_RECEIVED_MSK |
5141 ++ HT_AGG_STATE_REQ_STOP_BA_MSK)) !=
5142 + HT_ADDBA_REQUESTED_MSK) {
5143 + spin_unlock_bh(&sta->lock);
5144 + *state = HT_AGG_STATE_IDLE;
5145 +diff --git a/net/mac80211/rx.c b/net/mac80211/rx.c
5146 +index 82a30c1..da92cde 100644
5147 +--- a/net/mac80211/rx.c
5148 ++++ b/net/mac80211/rx.c
5149 +@@ -1788,6 +1788,7 @@ static ieee80211_rx_result debug_noinline
5150 + ieee80211_rx_h_data(struct ieee80211_rx_data *rx)
5151 + {
5152 + struct ieee80211_sub_if_data *sdata = rx->sdata;
5153 ++ struct ieee80211_local *local = rx->local;
5154 + struct net_device *dev = sdata->dev;
5155 + struct ieee80211_hdr *hdr = (struct ieee80211_hdr *)rx->skb->data;
5156 + __le16 fc = hdr->frame_control;
5157 +@@ -1819,6 +1820,13 @@ ieee80211_rx_h_data(struct ieee80211_rx_data *rx)
5158 + dev->stats.rx_packets++;
5159 + dev->stats.rx_bytes += rx->skb->len;
5160 +
5161 ++ if (ieee80211_is_data(hdr->frame_control) &&
5162 ++ !is_multicast_ether_addr(hdr->addr1) &&
5163 ++ local->hw.conf.dynamic_ps_timeout > 0 && local->ps_sdata) {
5164 ++ mod_timer(&local->dynamic_ps_timer, jiffies +
5165 ++ msecs_to_jiffies(local->hw.conf.dynamic_ps_timeout));
5166 ++ }
5167 ++
5168 + ieee80211_deliver_skb(rx);
5169 +
5170 + return RX_QUEUED;
5171 +diff --git a/net/mac80211/tx.c b/net/mac80211/tx.c
5172 +index ac210b5..70c79c3 100644
5173 +--- a/net/mac80211/tx.c
5174 ++++ b/net/mac80211/tx.c
5175 +@@ -1052,8 +1052,11 @@ ieee80211_tx_prepare(struct ieee80211_sub_if_data *sdata,
5176 +
5177 + hdr = (struct ieee80211_hdr *) skb->data;
5178 +
5179 +- if (sdata->vif.type == NL80211_IFTYPE_AP_VLAN)
5180 ++ if (sdata->vif.type == NL80211_IFTYPE_AP_VLAN) {
5181 + tx->sta = rcu_dereference(sdata->u.vlan.sta);
5182 ++ if (!tx->sta && sdata->dev->ieee80211_ptr->use_4addr)
5183 ++ return TX_DROP;
5184 ++ }
5185 + if (!tx->sta)
5186 + tx->sta = sta_info_get(local, hdr->addr1);
5187 +
5188 +diff --git a/net/netfilter/xt_recent.c b/net/netfilter/xt_recent.c
5189 +index fc70a49..43e83a4 100644
5190 +--- a/net/netfilter/xt_recent.c
5191 ++++ b/net/netfilter/xt_recent.c
5192 +@@ -173,10 +173,10 @@ recent_entry_init(struct recent_table *t, const union nf_inet_addr *addr,
5193 +
5194 + static void recent_entry_update(struct recent_table *t, struct recent_entry *e)
5195 + {
5196 ++ e->index %= ip_pkt_list_tot;
5197 + e->stamps[e->index++] = jiffies;
5198 + if (e->index > e->nstamps)
5199 + e->nstamps = e->index;
5200 +- e->index %= ip_pkt_list_tot;
5201 + list_move_tail(&e->lru_list, &t->lru_list);
5202 + }
5203 +
5204 +@@ -260,7 +260,7 @@ recent_mt(const struct sk_buff *skb, const struct xt_match_param *par)
5205 + for (i = 0; i < e->nstamps; i++) {
5206 + if (info->seconds && time_after(time, e->stamps[i]))
5207 + continue;
5208 +- if (++hits >= info->hit_count) {
5209 ++ if (info->hit_count && ++hits >= info->hit_count) {
5210 + ret = !ret;
5211 + break;
5212 + }
5213 +diff --git a/net/sunrpc/svc_xprt.c b/net/sunrpc/svc_xprt.c
5214 +index 7d1f9e9..4f30336 100644
5215 +--- a/net/sunrpc/svc_xprt.c
5216 ++++ b/net/sunrpc/svc_xprt.c
5217 +@@ -889,11 +889,8 @@ void svc_delete_xprt(struct svc_xprt *xprt)
5218 + if (test_bit(XPT_TEMP, &xprt->xpt_flags))
5219 + serv->sv_tmpcnt--;
5220 +
5221 +- for (dr = svc_deferred_dequeue(xprt); dr;
5222 +- dr = svc_deferred_dequeue(xprt)) {
5223 +- svc_xprt_put(xprt);
5224 ++ while ((dr = svc_deferred_dequeue(xprt)) != NULL)
5225 + kfree(dr);
5226 +- }
5227 +
5228 + svc_xprt_put(xprt);
5229 + spin_unlock_bh(&serv->sv_lock);
5230 +diff --git a/net/sunrpc/xprtsock.c b/net/sunrpc/xprtsock.c
5231 +index 3d739e5..4df801d 100644
5232 +--- a/net/sunrpc/xprtsock.c
5233 ++++ b/net/sunrpc/xprtsock.c
5234 +@@ -1912,6 +1912,11 @@ static void xs_tcp_setup_socket(struct rpc_xprt *xprt,
5235 + case -EALREADY:
5236 + xprt_clear_connecting(xprt);
5237 + return;
5238 ++ case -EINVAL:
5239 ++ /* Happens, for instance, if the user specified a link
5240 ++ * local IPv6 address without a scope-id.
5241 ++ */
5242 ++ goto out;
5243 + }
5244 + out_eagain:
5245 + status = -EAGAIN;
5246 +diff --git a/scripts/get_maintainer.pl b/scripts/get_maintainer.pl
5247 +index 2f3230d..049c419 100755
5248 +--- a/scripts/get_maintainer.pl
5249 ++++ b/scripts/get_maintainer.pl
5250 +@@ -314,6 +314,7 @@ foreach my $file (@files) {
5251 + if ($type eq 'X') {
5252 + if (file_match_pattern($file, $value)) {
5253 + $exclude = 1;
5254 ++ last;
5255 + }
5256 + }
5257 + }
5258 +@@ -340,8 +341,7 @@ foreach my $file (@files) {
5259 + }
5260 + }
5261 +
5262 +- $tvi += ($end - $start);
5263 +-
5264 ++ $tvi = $end + 1;
5265 + }
5266 +
5267 + foreach my $line (sort {$hash{$b} <=> $hash{$a}} keys %hash) {
5268 +diff --git a/security/integrity/ima/ima_iint.c b/security/integrity/ima/ima_iint.c
5269 +index 0d83edc..2d4d05d 100644
5270 +--- a/security/integrity/ima/ima_iint.c
5271 ++++ b/security/integrity/ima/ima_iint.c
5272 +@@ -63,12 +63,11 @@ int ima_inode_alloc(struct inode *inode)
5273 + spin_lock(&ima_iint_lock);
5274 + rc = radix_tree_insert(&ima_iint_store, (unsigned long)inode, iint);
5275 + spin_unlock(&ima_iint_lock);
5276 ++ radix_tree_preload_end();
5277 + out:
5278 + if (rc < 0)
5279 + kmem_cache_free(iint_cache, iint);
5280 +
5281 +- radix_tree_preload_end();
5282 +-
5283 + return rc;
5284 + }
5285 +
5286 +diff --git a/security/selinux/ss/ebitmap.c b/security/selinux/ss/ebitmap.c
5287 +index 68c7348..04b6145 100644
5288 +--- a/security/selinux/ss/ebitmap.c
5289 ++++ b/security/selinux/ss/ebitmap.c
5290 +@@ -128,7 +128,7 @@ int ebitmap_netlbl_export(struct ebitmap *ebmap,
5291 + cmap_idx = delta / NETLBL_CATMAP_MAPSIZE;
5292 + cmap_sft = delta % NETLBL_CATMAP_MAPSIZE;
5293 + c_iter->bitmap[cmap_idx]
5294 +- |= e_iter->maps[cmap_idx] << cmap_sft;
5295 ++ |= e_iter->maps[i] << cmap_sft;
5296 + }
5297 + e_iter = e_iter->next;
5298 + }
5299 +diff --git a/sound/core/pcm_native.c b/sound/core/pcm_native.c
5300 +index 25b0641..f7e1c9f 100644
5301 +--- a/sound/core/pcm_native.c
5302 ++++ b/sound/core/pcm_native.c
5303 +@@ -315,10 +315,10 @@ int snd_pcm_hw_refine(struct snd_pcm_substream *substream,
5304 + if (!params->info)
5305 + params->info = hw->info & ~SNDRV_PCM_INFO_FIFO_IN_FRAMES;
5306 + if (!params->fifo_size) {
5307 +- if (snd_mask_min(&params->masks[SNDRV_PCM_HW_PARAM_FORMAT]) ==
5308 +- snd_mask_max(&params->masks[SNDRV_PCM_HW_PARAM_FORMAT]) &&
5309 +- snd_mask_min(&params->masks[SNDRV_PCM_HW_PARAM_CHANNELS]) ==
5310 +- snd_mask_max(&params->masks[SNDRV_PCM_HW_PARAM_CHANNELS])) {
5311 ++ m = hw_param_mask(params, SNDRV_PCM_HW_PARAM_FORMAT);
5312 ++ i = hw_param_interval(params, SNDRV_PCM_HW_PARAM_CHANNELS);
5313 ++ if (snd_mask_min(m) == snd_mask_max(m) &&
5314 ++ snd_interval_min(i) == snd_interval_max(i)) {
5315 + changed = substream->ops->ioctl(substream,
5316 + SNDRV_PCM_IOCTL1_FIFO_SIZE, params);
5317 + if (changed < 0)
5318 +diff --git a/sound/pci/hda/hda_intel.c b/sound/pci/hda/hda_intel.c
5319 +index ff6da6f..6d6e307 100644
5320 +--- a/sound/pci/hda/hda_intel.c
5321 ++++ b/sound/pci/hda/hda_intel.c
5322 +@@ -2261,9 +2261,12 @@ static int azx_dev_free(struct snd_device *device)
5323 + static struct snd_pci_quirk position_fix_list[] __devinitdata = {
5324 + SND_PCI_QUIRK(0x1028, 0x01cc, "Dell D820", POS_FIX_LPIB),
5325 + SND_PCI_QUIRK(0x1028, 0x01de, "Dell Precision 390", POS_FIX_LPIB),
5326 ++ SND_PCI_QUIRK(0x1028, 0x01f6, "Dell Latitude 131L", POS_FIX_LPIB),
5327 + SND_PCI_QUIRK(0x103c, 0x306d, "HP dv3", POS_FIX_LPIB),
5328 ++ SND_PCI_QUIRK(0x1106, 0x3288, "ASUS M2V-MX SE", POS_FIX_LPIB),
5329 + SND_PCI_QUIRK(0x1043, 0x813d, "ASUS P5AD2", POS_FIX_LPIB),
5330 + SND_PCI_QUIRK(0x1462, 0x1002, "MSI Wind U115", POS_FIX_LPIB),
5331 ++ SND_PCI_QUIRK(0x1565, 0x820f, "Biostar Microtech", POS_FIX_LPIB),
5332 + {}
5333 + };
5334 +
5335 +diff --git a/sound/pci/hda/patch_analog.c b/sound/pci/hda/patch_analog.c
5336 +index 69a941c..7069441 100644
5337 +--- a/sound/pci/hda/patch_analog.c
5338 ++++ b/sound/pci/hda/patch_analog.c
5339 +@@ -1008,7 +1008,7 @@ static struct snd_pci_quirk ad1986a_cfg_tbl[] = {
5340 + SND_PCI_QUIRK(0x1043, 0x81cb, "ASUS M2N", AD1986A_3STACK),
5341 + SND_PCI_QUIRK(0x1043, 0x8234, "ASUS M2N", AD1986A_3STACK),
5342 + SND_PCI_QUIRK(0x10de, 0xcb84, "ASUS A8N-VM", AD1986A_3STACK),
5343 +- SND_PCI_QUIRK(0x1179, 0xff40, "Toshiba", AD1986A_LAPTOP_EAPD),
5344 ++ SND_PCI_QUIRK(0x1179, 0xff40, "Toshiba Satellite L40-10Q", AD1986A_3STACK),
5345 + SND_PCI_QUIRK(0x144d, 0xb03c, "Samsung R55", AD1986A_3STACK),
5346 + SND_PCI_QUIRK(0x144d, 0xc01e, "FSC V2060", AD1986A_LAPTOP),
5347 + SND_PCI_QUIRK(0x144d, 0xc024, "Samsung P50", AD1986A_SAMSUNG_P50),
5348 +diff --git a/sound/pci/via82xx.c b/sound/pci/via82xx.c
5349 +index 8a332d2..03d6aea 100644
5350 +--- a/sound/pci/via82xx.c
5351 ++++ b/sound/pci/via82xx.c
5352 +@@ -1791,6 +1791,12 @@ static struct ac97_quirk ac97_quirks[] = {
5353 + .type = AC97_TUNE_HP_ONLY
5354 + },
5355 + {
5356 ++ .subvendor = 0x110a,
5357 ++ .subdevice = 0x0079,
5358 ++ .name = "Fujitsu Siemens D1289",
5359 ++ .type = AC97_TUNE_HP_ONLY
5360 ++ },
5361 ++ {
5362 + .subvendor = 0x1019,
5363 + .subdevice = 0x0a81,
5364 + .name = "ECS K7VTA3",
5365 +diff --git a/sound/soc/codecs/ak4104.c b/sound/soc/codecs/ak4104.c
5366 +index 3a14c6f..0f439ab 100644
5367 +--- a/sound/soc/codecs/ak4104.c
5368 ++++ b/sound/soc/codecs/ak4104.c
5369 +@@ -90,12 +90,10 @@ static int ak4104_spi_write(struct snd_soc_codec *codec, unsigned int reg,
5370 + if (reg >= codec->reg_cache_size)
5371 + return -EINVAL;
5372 +
5373 +- reg &= AK4104_REG_MASK;
5374 +- reg |= AK4104_WRITE;
5375 +-
5376 + /* only write to the hardware if value has changed */
5377 + if (cache[reg] != value) {
5378 +- u8 tmp[2] = { reg, value };
5379 ++ u8 tmp[2] = { (reg & AK4104_REG_MASK) | AK4104_WRITE, value };
5380 ++
5381 + if (spi_write(spi, tmp, sizeof(tmp))) {
5382 + dev_err(&spi->dev, "SPI write failed\n");
5383 + return -EIO;
5384 +diff --git a/sound/usb/usbaudio.c b/sound/usb/usbaudio.c
5385 +index 9edef46..3c81add 100644
5386 +--- a/sound/usb/usbaudio.c
5387 ++++ b/sound/usb/usbaudio.c
5388 +@@ -3327,6 +3327,32 @@ static int snd_usb_cm6206_boot_quirk(struct usb_device *dev)
5389 + }
5390 +
5391 + /*
5392 ++ * This call will put the synth in "USB send" mode, i.e it will send MIDI
5393 ++ * messages through USB (this is disabled at startup). The synth will
5394 ++ * acknowledge by sending a sysex on endpoint 0x85 and by displaying a USB
5395 ++ * sign on its LCD. Values here are chosen based on sniffing USB traffic
5396 ++ * under Windows.
5397 ++ */
5398 ++static int snd_usb_accessmusic_boot_quirk(struct usb_device *dev)
5399 ++{
5400 ++ int err, actual_length;
5401 ++
5402 ++ /* "midi send" enable */
5403 ++ static const u8 seq[] = { 0x4e, 0x73, 0x52, 0x01 };
5404 ++
5405 ++ void *buf = kmemdup(seq, ARRAY_SIZE(seq), GFP_KERNEL);
5406 ++ if (!buf)
5407 ++ return -ENOMEM;
5408 ++ err = usb_interrupt_msg(dev, usb_sndintpipe(dev, 0x05), buf,
5409 ++ ARRAY_SIZE(seq), &actual_length, 1000);
5410 ++ kfree(buf);
5411 ++ if (err < 0)
5412 ++ return err;
5413 ++
5414 ++ return 0;
5415 ++}
5416 ++
5417 ++/*
5418 + * Setup quirks
5419 + */
5420 + #define AUDIOPHILE_SET 0x01 /* if set, parse device_setup */
5421 +@@ -3624,6 +3650,12 @@ static void *snd_usb_audio_probe(struct usb_device *dev,
5422 + goto __err_val;
5423 + }
5424 +
5425 ++ /* Access Music VirusTI Desktop */
5426 ++ if (id == USB_ID(0x133e, 0x0815)) {
5427 ++ if (snd_usb_accessmusic_boot_quirk(dev) < 0)
5428 ++ goto __err_val;
5429 ++ }
5430 ++
5431 + /*
5432 + * found a config. now register to ALSA
5433 + */
5434 +diff --git a/sound/usb/usbmidi.c b/sound/usb/usbmidi.c
5435 +index 6e89b83..b2da478 100644
5436 +--- a/sound/usb/usbmidi.c
5437 ++++ b/sound/usb/usbmidi.c
5438 +@@ -1162,10 +1162,22 @@ static int snd_usbmidi_out_endpoint_create(struct snd_usb_midi* umidi,
5439 + pipe = usb_sndintpipe(umidi->dev, ep_info->out_ep);
5440 + else
5441 + pipe = usb_sndbulkpipe(umidi->dev, ep_info->out_ep);
5442 +- if (umidi->usb_id == USB_ID(0x0a92, 0x1020)) /* ESI M4U */
5443 +- ep->max_transfer = 4;
5444 +- else
5445 ++ switch (umidi->usb_id) {
5446 ++ default:
5447 + ep->max_transfer = usb_maxpacket(umidi->dev, pipe, 1);
5448 ++ break;
5449 ++ /*
5450 ++ * Various chips declare a packet size larger than 4 bytes, but
5451 ++ * do not actually work with larger packets:
5452 ++ */
5453 ++ case USB_ID(0x0a92, 0x1020): /* ESI M4U */
5454 ++ case USB_ID(0x1430, 0x474b): /* RedOctane GH MIDI INTERFACE */
5455 ++ case USB_ID(0x15ca, 0x0101): /* Textech USB Midi Cable */
5456 ++ case USB_ID(0x15ca, 0x1806): /* Textech USB Midi Cable */
5457 ++ case USB_ID(0x1a86, 0x752d): /* QinHeng CH345 "USB2.0-MIDI" */
5458 ++ ep->max_transfer = 4;
5459 ++ break;
5460 ++ }
5461 + for (i = 0; i < OUTPUT_URBS; ++i) {
5462 + buffer = usb_buffer_alloc(umidi->dev,
5463 + ep->max_transfer, GFP_KERNEL,
5464 +@@ -1407,6 +1419,12 @@ static struct port_info {
5465 + EXTERNAL_PORT(0x086a, 0x0001, 8, "%s Broadcast"),
5466 + EXTERNAL_PORT(0x086a, 0x0002, 8, "%s Broadcast"),
5467 + EXTERNAL_PORT(0x086a, 0x0003, 4, "%s Broadcast"),
5468 ++ /* Access Music Virus TI */
5469 ++ EXTERNAL_PORT(0x133e, 0x0815, 0, "%s MIDI"),
5470 ++ PORT_INFO(0x133e, 0x0815, 1, "%s Synth", 0,
5471 ++ SNDRV_SEQ_PORT_TYPE_MIDI_GENERIC |
5472 ++ SNDRV_SEQ_PORT_TYPE_HARDWARE |
5473 ++ SNDRV_SEQ_PORT_TYPE_SYNTHESIZER),
5474 + };
5475 +
5476 + static struct port_info *find_port_info(struct snd_usb_midi* umidi, int number)
5477 +diff --git a/sound/usb/usbquirks.h b/sound/usb/usbquirks.h
5478 +index a892bda..406b74b 100644
5479 +--- a/sound/usb/usbquirks.h
5480 ++++ b/sound/usb/usbquirks.h
5481 +@@ -2073,6 +2073,33 @@ YAMAHA_DEVICE(0x7010, "UB99"),
5482 + }
5483 + },
5484 +
5485 ++/* Access Music devices */
5486 ++{
5487 ++ /* VirusTI Desktop */
5488 ++ USB_DEVICE_VENDOR_SPEC(0x133e, 0x0815),
5489 ++ .driver_info = (unsigned long) &(const struct snd_usb_audio_quirk) {
5490 ++ .ifnum = QUIRK_ANY_INTERFACE,
5491 ++ .type = QUIRK_COMPOSITE,
5492 ++ .data = &(const struct snd_usb_audio_quirk[]) {
5493 ++ {
5494 ++ .ifnum = 3,
5495 ++ .type = QUIRK_MIDI_FIXED_ENDPOINT,
5496 ++ .data = &(const struct snd_usb_midi_endpoint_info) {
5497 ++ .out_cables = 0x0003,
5498 ++ .in_cables = 0x0003
5499 ++ }
5500 ++ },
5501 ++ {
5502 ++ .ifnum = 4,
5503 ++ .type = QUIRK_IGNORE_INTERFACE
5504 ++ },
5505 ++ {
5506 ++ .ifnum = -1
5507 ++ }
5508 ++ }
5509 ++ }
5510 ++},
5511 ++
5512 + /* */
5513 + {
5514 + /* aka. Serato Scratch Live DJ Box */
5515 +diff --git a/tools/perf/util/symbol.c b/tools/perf/util/symbol.c
5516 +index ab92763..72547b9 100644
5517 +--- a/tools/perf/util/symbol.c
5518 ++++ b/tools/perf/util/symbol.c
5519 +@@ -503,7 +503,7 @@ static int dso__split_kallsyms(struct dso *self, struct map *map,
5520 + return -1;
5521 +
5522 + curr_map = map__new2(pos->start, dso, map->type);
5523 +- if (map == NULL) {
5524 ++ if (curr_map == NULL) {
5525 + dso__delete(dso);
5526 + return -1;
5527 + }