/[linux-patches]/genpatches-2.6/tags/3.0-30/1008_linux-3.0.9.patch
Gentoo

Contents of /genpatches-2.6/tags/3.0-30/1008_linux-3.0.9.patch

Parent Directory Parent Directory | Revision Log Revision Log


Revision 2206 - (show annotations) (download)
Mon Sep 17 18:58:14 2012 UTC (2 years, 1 month ago) by mpagano
File size: 377426 byte(s)
3.0-30 release
<
1 diff --git a/Documentation/hwspinlock.txt b/Documentation/hwspinlock.txt
2 index 7dcd1a4..6996681 100644
3 --- a/Documentation/hwspinlock.txt
4 +++ b/Documentation/hwspinlock.txt
5 @@ -39,23 +39,20 @@ independent, drivers.
6 in case an unused hwspinlock isn't available. Users of this
7 API will usually want to communicate the lock's id to the remote core
8 before it can be used to achieve synchronization.
9 - Can be called from an atomic context (this function will not sleep) but
10 - not from within interrupt context.
11 + Should be called from a process context (might sleep).
12
13 struct hwspinlock *hwspin_lock_request_specific(unsigned int id);
14 - assign a specific hwspinlock id and return its address, or NULL
15 if that hwspinlock is already in use. Usually board code will
16 be calling this function in order to reserve specific hwspinlock
17 ids for predefined purposes.
18 - Can be called from an atomic context (this function will not sleep) but
19 - not from within interrupt context.
20 + Should be called from a process context (might sleep).
21
22 int hwspin_lock_free(struct hwspinlock *hwlock);
23 - free a previously-assigned hwspinlock; returns 0 on success, or an
24 appropriate error code on failure (e.g. -EINVAL if the hwspinlock
25 is already free).
26 - Can be called from an atomic context (this function will not sleep) but
27 - not from within interrupt context.
28 + Should be called from a process context (might sleep).
29
30 int hwspin_lock_timeout(struct hwspinlock *hwlock, unsigned int timeout);
31 - lock a previously-assigned hwspinlock with a timeout limit (specified in
32 @@ -232,15 +229,14 @@ int hwspinlock_example2(void)
33
34 int hwspin_lock_register(struct hwspinlock *hwlock);
35 - to be called from the underlying platform-specific implementation, in
36 - order to register a new hwspinlock instance. Can be called from an atomic
37 - context (this function will not sleep) but not from within interrupt
38 - context. Returns 0 on success, or appropriate error code on failure.
39 + order to register a new hwspinlock instance. Should be called from
40 + a process context (this function might sleep).
41 + Returns 0 on success, or appropriate error code on failure.
42
43 struct hwspinlock *hwspin_lock_unregister(unsigned int id);
44 - to be called from the underlying vendor-specific implementation, in order
45 to unregister an existing (and unused) hwspinlock instance.
46 - Can be called from an atomic context (will not sleep) but not from
47 - within interrupt context.
48 + Should be called from a process context (this function might sleep).
49 Returns the address of hwspinlock on success, or NULL on error (e.g.
50 if the hwspinlock is sill in use).
51
52 diff --git a/Documentation/power/runtime_pm.txt b/Documentation/power/runtime_pm.txt
53 index b24875b..6ade987 100644
54 --- a/Documentation/power/runtime_pm.txt
55 +++ b/Documentation/power/runtime_pm.txt
56 @@ -708,6 +708,16 @@ will behave normally, not taking the autosuspend delay into account.
57 Similarly, if the power.use_autosuspend field isn't set then the autosuspend
58 helper functions will behave just like the non-autosuspend counterparts.
59
60 +Under some circumstances a driver or subsystem may want to prevent a device
61 +from autosuspending immediately, even though the usage counter is zero and the
62 +autosuspend delay time has expired. If the ->runtime_suspend() callback
63 +returns -EAGAIN or -EBUSY, and if the next autosuspend delay expiration time is
64 +in the future (as it normally would be if the callback invoked
65 +pm_runtime_mark_last_busy()), the PM core will automatically reschedule the
66 +autosuspend. The ->runtime_suspend() callback can't do this rescheduling
67 +itself because no suspend requests of any kind are accepted while the device is
68 +suspending (i.e., while the callback is running).
69 +
70 The implementation is well suited for asynchronous use in interrupt contexts.
71 However such use inevitably involves races, because the PM core can't
72 synchronize ->runtime_suspend() callbacks with the arrival of I/O requests.
73 diff --git a/Documentation/stable_kernel_rules.txt b/Documentation/stable_kernel_rules.txt
74 index e213f45..21fd05c 100644
75 --- a/Documentation/stable_kernel_rules.txt
76 +++ b/Documentation/stable_kernel_rules.txt
77 @@ -24,10 +24,10 @@ Rules on what kind of patches are accepted, and which ones are not, into the
78 Procedure for submitting patches to the -stable tree:
79
80 - Send the patch, after verifying that it follows the above rules, to
81 - stable@kernel.org. You must note the upstream commit ID in the changelog
82 - of your submission.
83 + stable@vger.kernel.org. You must note the upstream commit ID in the
84 + changelog of your submission.
85 - To have the patch automatically included in the stable tree, add the tag
86 - Cc: stable@kernel.org
87 + Cc: stable@vger.kernel.org
88 in the sign-off area. Once the patch is merged it will be applied to
89 the stable tree without anything else needing to be done by the author
90 or subsystem maintainer.
91 @@ -35,10 +35,10 @@ Procedure for submitting patches to the -stable tree:
92 cherry-picked than this can be specified in the following format in
93 the sign-off area:
94
95 - Cc: <stable@kernel.org> # .32.x: a1f84a3: sched: Check for idle
96 - Cc: <stable@kernel.org> # .32.x: 1b9508f: sched: Rate-limit newidle
97 - Cc: <stable@kernel.org> # .32.x: fd21073: sched: Fix affinity logic
98 - Cc: <stable@kernel.org> # .32.x
99 + Cc: <stable@vger.kernel.org> # .32.x: a1f84a3: sched: Check for idle
100 + Cc: <stable@vger.kernel.org> # .32.x: 1b9508f: sched: Rate-limit newidle
101 + Cc: <stable@vger.kernel.org> # .32.x: fd21073: sched: Fix affinity logic
102 + Cc: <stable@vger.kernel.org> # .32.x
103 Signed-off-by: Ingo Molnar <mingo@elte.hu>
104
105 The tag sequence has the meaning of:
106 diff --git a/MAINTAINERS b/MAINTAINERS
107 index 187282d..34e2418 100644
108 --- a/MAINTAINERS
109 +++ b/MAINTAINERS
110 @@ -1221,7 +1221,7 @@ F: Documentation/aoe/
111 F: drivers/block/aoe/
112
113 ATHEROS ATH GENERIC UTILITIES
114 -M: "Luis R. Rodriguez" <lrodriguez@atheros.com>
115 +M: "Luis R. Rodriguez" <mcgrof@qca.qualcomm.com>
116 L: linux-wireless@vger.kernel.org
117 S: Supported
118 F: drivers/net/wireless/ath/*
119 @@ -1229,7 +1229,7 @@ F: drivers/net/wireless/ath/*
120 ATHEROS ATH5K WIRELESS DRIVER
121 M: Jiri Slaby <jirislaby@gmail.com>
122 M: Nick Kossifidis <mickflemm@gmail.com>
123 -M: "Luis R. Rodriguez" <lrodriguez@atheros.com>
124 +M: "Luis R. Rodriguez" <mcgrof@qca.qualcomm.com>
125 M: Bob Copeland <me@bobcopeland.com>
126 L: linux-wireless@vger.kernel.org
127 L: ath5k-devel@lists.ath5k.org
128 @@ -1238,10 +1238,10 @@ S: Maintained
129 F: drivers/net/wireless/ath/ath5k/
130
131 ATHEROS ATH9K WIRELESS DRIVER
132 -M: "Luis R. Rodriguez" <lrodriguez@atheros.com>
133 -M: Jouni Malinen <jmalinen@atheros.com>
134 -M: Vasanthakumar Thiagarajan <vasanth@atheros.com>
135 -M: Senthil Balasubramanian <senthilkumar@atheros.com>
136 +M: "Luis R. Rodriguez" <mcgrof@qca.qualcomm.com>
137 +M: Jouni Malinen <jouni@qca.qualcomm.com>
138 +M: Vasanthakumar Thiagarajan <vthiagar@qca.qualcomm.com>
139 +M: Senthil Balasubramanian <senthilb@qca.qualcomm.com>
140 L: linux-wireless@vger.kernel.org
141 L: ath9k-devel@lists.ath9k.org
142 W: http://wireless.kernel.org/en/users/Drivers/ath9k
143 @@ -1269,7 +1269,7 @@ F: drivers/input/misc/ati_remote2.c
144 ATLX ETHERNET DRIVERS
145 M: Jay Cliburn <jcliburn@gmail.com>
146 M: Chris Snook <chris.snook@gmail.com>
147 -M: Jie Yang <jie.yang@atheros.com>
148 +M: Jie Yang <yangjie@qca.qualcomm.com>
149 L: netdev@vger.kernel.org
150 W: http://sourceforge.net/projects/atl1
151 W: http://atl1.sourceforge.net
152 diff --git a/Makefile b/Makefile
153 index 9f6e3cd..438c11a 100644
154 --- a/Makefile
155 +++ b/Makefile
156 @@ -1,6 +1,6 @@
157 VERSION = 3
158 PATCHLEVEL = 0
159 -SUBLEVEL = 8
160 +SUBLEVEL = 9
161 EXTRAVERSION =
162 NAME = Sneaky Weasel
163
164 diff --git a/arch/arm/mach-ux500/cpu.c b/arch/arm/mach-ux500/cpu.c
165 index 1da23bb..8aa104a 100644
166 --- a/arch/arm/mach-ux500/cpu.c
167 +++ b/arch/arm/mach-ux500/cpu.c
168 @@ -99,7 +99,27 @@ static void ux500_l2x0_inv_all(void)
169 ux500_cache_sync();
170 }
171
172 -static int ux500_l2x0_init(void)
173 +static int __init ux500_l2x0_unlock(void)
174 +{
175 + int i;
176 +
177 + /*
178 + * Unlock Data and Instruction Lock if locked. Ux500 U-Boot versions
179 + * apparently locks both caches before jumping to the kernel. The
180 + * l2x0 core will not touch the unlock registers if the l2x0 is
181 + * already enabled, so we do it right here instead. The PL310 has
182 + * 8 sets of registers, one per possible CPU.
183 + */
184 + for (i = 0; i < 8; i++) {
185 + writel_relaxed(0x0, l2x0_base + L2X0_LOCKDOWN_WAY_D_BASE +
186 + i * L2X0_LOCKDOWN_STRIDE);
187 + writel_relaxed(0x0, l2x0_base + L2X0_LOCKDOWN_WAY_I_BASE +
188 + i * L2X0_LOCKDOWN_STRIDE);
189 + }
190 + return 0;
191 +}
192 +
193 +static int __init ux500_l2x0_init(void)
194 {
195 if (cpu_is_u5500())
196 l2x0_base = __io_address(U5500_L2CC_BASE);
197 @@ -108,6 +128,9 @@ static int ux500_l2x0_init(void)
198 else
199 ux500_unknown_soc();
200
201 + /* Unlock before init */
202 + ux500_l2x0_unlock();
203 +
204 /* 64KB way size, 8 way associativity, force WA */
205 l2x0_init(l2x0_base, 0x3e060000, 0xc0000fff);
206
207 diff --git a/arch/arm/plat-mxc/include/mach/iomux-v3.h b/arch/arm/plat-mxc/include/mach/iomux-v3.h
208 index ebbce33..4509956 100644
209 --- a/arch/arm/plat-mxc/include/mach/iomux-v3.h
210 +++ b/arch/arm/plat-mxc/include/mach/iomux-v3.h
211 @@ -89,11 +89,11 @@ typedef u64 iomux_v3_cfg_t;
212 #define PAD_CTL_HYS (1 << 8)
213
214 #define PAD_CTL_PKE (1 << 7)
215 -#define PAD_CTL_PUE (1 << 6)
216 -#define PAD_CTL_PUS_100K_DOWN (0 << 4)
217 -#define PAD_CTL_PUS_47K_UP (1 << 4)
218 -#define PAD_CTL_PUS_100K_UP (2 << 4)
219 -#define PAD_CTL_PUS_22K_UP (3 << 4)
220 +#define PAD_CTL_PUE (1 << 6 | PAD_CTL_PKE)
221 +#define PAD_CTL_PUS_100K_DOWN (0 << 4 | PAD_CTL_PUE)
222 +#define PAD_CTL_PUS_47K_UP (1 << 4 | PAD_CTL_PUE)
223 +#define PAD_CTL_PUS_100K_UP (2 << 4 | PAD_CTL_PUE)
224 +#define PAD_CTL_PUS_22K_UP (3 << 4 | PAD_CTL_PUE)
225
226 #define PAD_CTL_ODE (1 << 3)
227
228 diff --git a/arch/powerpc/include/asm/sparsemem.h b/arch/powerpc/include/asm/sparsemem.h
229 index 54a47ea..0c5fa31 100644
230 --- a/arch/powerpc/include/asm/sparsemem.h
231 +++ b/arch/powerpc/include/asm/sparsemem.h
232 @@ -16,7 +16,7 @@
233 #endif /* CONFIG_SPARSEMEM */
234
235 #ifdef CONFIG_MEMORY_HOTPLUG
236 -extern void create_section_mapping(unsigned long start, unsigned long end);
237 +extern int create_section_mapping(unsigned long start, unsigned long end);
238 extern int remove_section_mapping(unsigned long start, unsigned long end);
239 #ifdef CONFIG_NUMA
240 extern int hot_add_scn_to_nid(unsigned long scn_addr);
241 diff --git a/arch/powerpc/mm/gup.c b/arch/powerpc/mm/gup.c
242 index fec1320..d7efdbf 100644
243 --- a/arch/powerpc/mm/gup.c
244 +++ b/arch/powerpc/mm/gup.c
245 @@ -16,16 +16,6 @@
246
247 #ifdef __HAVE_ARCH_PTE_SPECIAL
248
249 -static inline void get_huge_page_tail(struct page *page)
250 -{
251 - /*
252 - * __split_huge_page_refcount() cannot run
253 - * from under us.
254 - */
255 - VM_BUG_ON(atomic_read(&page->_count) < 0);
256 - atomic_inc(&page->_count);
257 -}
258 -
259 /*
260 * The performance critical leaf functions are made noinline otherwise gcc
261 * inlines everything into a single function which results in too much
262 @@ -57,8 +47,6 @@ static noinline int gup_pte_range(pmd_t pmd, unsigned long addr,
263 put_page(page);
264 return 0;
265 }
266 - if (PageTail(page))
267 - get_huge_page_tail(page);
268 pages[*nr] = page;
269 (*nr)++;
270
271 diff --git a/arch/powerpc/mm/hash_utils_64.c b/arch/powerpc/mm/hash_utils_64.c
272 index 26b2872..07f9e9f 100644
273 --- a/arch/powerpc/mm/hash_utils_64.c
274 +++ b/arch/powerpc/mm/hash_utils_64.c
275 @@ -534,11 +534,11 @@ static unsigned long __init htab_get_table_size(void)
276 }
277
278 #ifdef CONFIG_MEMORY_HOTPLUG
279 -void create_section_mapping(unsigned long start, unsigned long end)
280 +int create_section_mapping(unsigned long start, unsigned long end)
281 {
282 - BUG_ON(htab_bolt_mapping(start, end, __pa(start),
283 + return htab_bolt_mapping(start, end, __pa(start),
284 pgprot_val(PAGE_KERNEL), mmu_linear_psize,
285 - mmu_kernel_ssize));
286 + mmu_kernel_ssize);
287 }
288
289 int remove_section_mapping(unsigned long start, unsigned long end)
290 diff --git a/arch/powerpc/mm/hugetlbpage.c b/arch/powerpc/mm/hugetlbpage.c
291 index 0b9a5c1..da5eb38 100644
292 --- a/arch/powerpc/mm/hugetlbpage.c
293 +++ b/arch/powerpc/mm/hugetlbpage.c
294 @@ -390,7 +390,7 @@ static noinline int gup_hugepte(pte_t *ptep, unsigned long sz, unsigned long add
295 {
296 unsigned long mask;
297 unsigned long pte_end;
298 - struct page *head, *page;
299 + struct page *head, *page, *tail;
300 pte_t pte;
301 int refs;
302
303 @@ -413,6 +413,7 @@ static noinline int gup_hugepte(pte_t *ptep, unsigned long sz, unsigned long add
304 head = pte_page(pte);
305
306 page = head + ((addr & (sz-1)) >> PAGE_SHIFT);
307 + tail = page;
308 do {
309 VM_BUG_ON(compound_head(page) != head);
310 pages[*nr] = page;
311 @@ -428,10 +429,20 @@ static noinline int gup_hugepte(pte_t *ptep, unsigned long sz, unsigned long add
312
313 if (unlikely(pte_val(pte) != pte_val(*ptep))) {
314 /* Could be optimized better */
315 - while (*nr) {
316 - put_page(page);
317 - (*nr)--;
318 - }
319 + *nr -= refs;
320 + while (refs--)
321 + put_page(head);
322 + return 0;
323 + }
324 +
325 + /*
326 + * Any tail page need their mapcount reference taken before we
327 + * return.
328 + */
329 + while (refs--) {
330 + if (PageTail(tail))
331 + get_huge_page_tail(tail);
332 + tail++;
333 }
334
335 return 1;
336 diff --git a/arch/powerpc/mm/mem.c b/arch/powerpc/mm/mem.c
337 index 29d4dde..278ec8e 100644
338 --- a/arch/powerpc/mm/mem.c
339 +++ b/arch/powerpc/mm/mem.c
340 @@ -123,7 +123,8 @@ int arch_add_memory(int nid, u64 start, u64 size)
341 pgdata = NODE_DATA(nid);
342
343 start = (unsigned long)__va(start);
344 - create_section_mapping(start, start + size);
345 + if (create_section_mapping(start, start + size))
346 + return -EINVAL;
347
348 /* this should work for most non-highmem platforms */
349 zone = pgdata->node_zones;
350 diff --git a/arch/powerpc/mm/mmu_context_hash64.c b/arch/powerpc/mm/mmu_context_hash64.c
351 index 3bafc3d..4ff587e 100644
352 --- a/arch/powerpc/mm/mmu_context_hash64.c
353 +++ b/arch/powerpc/mm/mmu_context_hash64.c
354 @@ -136,8 +136,8 @@ int use_cop(unsigned long acop, struct mm_struct *mm)
355 if (!mm || !acop)
356 return -EINVAL;
357
358 - /* We need to make sure mm_users doesn't change */
359 - down_read(&mm->mmap_sem);
360 + /* The page_table_lock ensures mm_users won't change under us */
361 + spin_lock(&mm->page_table_lock);
362 spin_lock(mm->context.cop_lockp);
363
364 if (mm->context.cop_pid == COP_PID_NONE) {
365 @@ -164,7 +164,7 @@ int use_cop(unsigned long acop, struct mm_struct *mm)
366
367 out:
368 spin_unlock(mm->context.cop_lockp);
369 - up_read(&mm->mmap_sem);
370 + spin_unlock(&mm->page_table_lock);
371
372 return ret;
373 }
374 @@ -185,8 +185,8 @@ void drop_cop(unsigned long acop, struct mm_struct *mm)
375 if (WARN_ON_ONCE(!mm))
376 return;
377
378 - /* We need to make sure mm_users doesn't change */
379 - down_read(&mm->mmap_sem);
380 + /* The page_table_lock ensures mm_users won't change under us */
381 + spin_lock(&mm->page_table_lock);
382 spin_lock(mm->context.cop_lockp);
383
384 mm->context.acop &= ~acop;
385 @@ -213,7 +213,7 @@ void drop_cop(unsigned long acop, struct mm_struct *mm)
386 }
387
388 spin_unlock(mm->context.cop_lockp);
389 - up_read(&mm->mmap_sem);
390 + spin_unlock(&mm->page_table_lock);
391 }
392 EXPORT_SYMBOL_GPL(drop_cop);
393
394 diff --git a/arch/powerpc/mm/numa.c b/arch/powerpc/mm/numa.c
395 index 2164006..2c1ae7a 100644
396 --- a/arch/powerpc/mm/numa.c
397 +++ b/arch/powerpc/mm/numa.c
398 @@ -1214,11 +1214,12 @@ int hot_add_node_scn_to_nid(unsigned long scn_addr)
399 break;
400 }
401
402 - of_node_put(memory);
403 if (nid >= 0)
404 break;
405 }
406
407 + of_node_put(memory);
408 +
409 return nid;
410 }
411
412 diff --git a/arch/powerpc/platforms/pseries/dlpar.c b/arch/powerpc/platforms/pseries/dlpar.c
413 index 57ceb92..82766e5 100644
414 --- a/arch/powerpc/platforms/pseries/dlpar.c
415 +++ b/arch/powerpc/platforms/pseries/dlpar.c
416 @@ -112,6 +112,7 @@ void dlpar_free_cc_nodes(struct device_node *dn)
417 dlpar_free_one_cc_node(dn);
418 }
419
420 +#define COMPLETE 0
421 #define NEXT_SIBLING 1
422 #define NEXT_CHILD 2
423 #define NEXT_PROPERTY 3
424 @@ -158,6 +159,9 @@ struct device_node *dlpar_configure_connector(u32 drc_index)
425 spin_unlock(&rtas_data_buf_lock);
426
427 switch (rc) {
428 + case COMPLETE:
429 + break;
430 +
431 case NEXT_SIBLING:
432 dn = dlpar_parse_cc_node(ccwa);
433 if (!dn)
434 diff --git a/arch/powerpc/platforms/pseries/eeh.c b/arch/powerpc/platforms/pseries/eeh.c
435 index 46b55cf..3608704 100644
436 --- a/arch/powerpc/platforms/pseries/eeh.c
437 +++ b/arch/powerpc/platforms/pseries/eeh.c
438 @@ -1338,7 +1338,7 @@ static const struct file_operations proc_eeh_operations = {
439 static int __init eeh_init_proc(void)
440 {
441 if (machine_is(pseries))
442 - proc_create("ppc64/eeh", 0, NULL, &proc_eeh_operations);
443 + proc_create("powerpc/eeh", 0, NULL, &proc_eeh_operations);
444 return 0;
445 }
446 __initcall(eeh_init_proc);
447 diff --git a/arch/s390/kernel/ptrace.c b/arch/s390/kernel/ptrace.c
448 index ef86ad2..ae0e14b 100644
449 --- a/arch/s390/kernel/ptrace.c
450 +++ b/arch/s390/kernel/ptrace.c
451 @@ -47,29 +47,31 @@ enum s390_regset {
452
453 void update_per_regs(struct task_struct *task)
454 {
455 - static const struct per_regs per_single_step = {
456 - .control = PER_EVENT_IFETCH,
457 - .start = 0,
458 - .end = PSW_ADDR_INSN,
459 - };
460 struct pt_regs *regs = task_pt_regs(task);
461 struct thread_struct *thread = &task->thread;
462 - const struct per_regs *new;
463 - struct per_regs old;
464 + struct per_regs old, new;
465
466 - /* TIF_SINGLE_STEP overrides the user specified PER registers. */
467 - new = test_tsk_thread_flag(task, TIF_SINGLE_STEP) ?
468 - &per_single_step : &thread->per_user;
469 + /* Copy user specified PER registers */
470 + new.control = thread->per_user.control;
471 + new.start = thread->per_user.start;
472 + new.end = thread->per_user.end;
473 +
474 + /* merge TIF_SINGLE_STEP into user specified PER registers. */
475 + if (test_tsk_thread_flag(task, TIF_SINGLE_STEP)) {
476 + new.control |= PER_EVENT_IFETCH;
477 + new.start = 0;
478 + new.end = PSW_ADDR_INSN;
479 + }
480
481 /* Take care of the PER enablement bit in the PSW. */
482 - if (!(new->control & PER_EVENT_MASK)) {
483 + if (!(new.control & PER_EVENT_MASK)) {
484 regs->psw.mask &= ~PSW_MASK_PER;
485 return;
486 }
487 regs->psw.mask |= PSW_MASK_PER;
488 __ctl_store(old, 9, 11);
489 - if (memcmp(new, &old, sizeof(struct per_regs)) != 0)
490 - __ctl_load(*new, 9, 11);
491 + if (memcmp(&new, &old, sizeof(struct per_regs)) != 0)
492 + __ctl_load(new, 9, 11);
493 }
494
495 void user_enable_single_step(struct task_struct *task)
496 diff --git a/arch/s390/kvm/kvm-s390.c b/arch/s390/kvm/kvm-s390.c
497 index 67345ae..2ada634 100644
498 --- a/arch/s390/kvm/kvm-s390.c
499 +++ b/arch/s390/kvm/kvm-s390.c
500 @@ -301,11 +301,17 @@ int kvm_arch_vcpu_setup(struct kvm_vcpu *vcpu)
501 struct kvm_vcpu *kvm_arch_vcpu_create(struct kvm *kvm,
502 unsigned int id)
503 {
504 - struct kvm_vcpu *vcpu = kzalloc(sizeof(struct kvm_vcpu), GFP_KERNEL);
505 - int rc = -ENOMEM;
506 + struct kvm_vcpu *vcpu;
507 + int rc = -EINVAL;
508 +
509 + if (id >= KVM_MAX_VCPUS)
510 + goto out;
511 +
512 + rc = -ENOMEM;
513
514 + vcpu = kzalloc(sizeof(struct kvm_vcpu), GFP_KERNEL);
515 if (!vcpu)
516 - goto out_nomem;
517 + goto out;
518
519 vcpu->arch.sie_block = (struct kvm_s390_sie_block *)
520 get_zeroed_page(GFP_KERNEL);
521 @@ -341,7 +347,7 @@ out_free_sie_block:
522 free_page((unsigned long)(vcpu->arch.sie_block));
523 out_free_cpu:
524 kfree(vcpu);
525 -out_nomem:
526 +out:
527 return ERR_PTR(rc);
528 }
529
530 diff --git a/arch/s390/mm/gup.c b/arch/s390/mm/gup.c
531 index 45b405c..65cb06e 100644
532 --- a/arch/s390/mm/gup.c
533 +++ b/arch/s390/mm/gup.c
534 @@ -52,7 +52,7 @@ static inline int gup_huge_pmd(pmd_t *pmdp, pmd_t pmd, unsigned long addr,
535 unsigned long end, int write, struct page **pages, int *nr)
536 {
537 unsigned long mask, result;
538 - struct page *head, *page;
539 + struct page *head, *page, *tail;
540 int refs;
541
542 result = write ? 0 : _SEGMENT_ENTRY_RO;
543 @@ -64,6 +64,7 @@ static inline int gup_huge_pmd(pmd_t *pmdp, pmd_t pmd, unsigned long addr,
544 refs = 0;
545 head = pmd_page(pmd);
546 page = head + ((addr & ~PMD_MASK) >> PAGE_SHIFT);
547 + tail = page;
548 do {
549 VM_BUG_ON(compound_head(page) != head);
550 pages[*nr] = page;
551 @@ -81,6 +82,17 @@ static inline int gup_huge_pmd(pmd_t *pmdp, pmd_t pmd, unsigned long addr,
552 *nr -= refs;
553 while (refs--)
554 put_page(head);
555 + return 0;
556 + }
557 +
558 + /*
559 + * Any tail page need their mapcount reference taken before we
560 + * return.
561 + */
562 + while (refs--) {
563 + if (PageTail(tail))
564 + get_huge_page_tail(tail);
565 + tail++;
566 }
567
568 return 1;
569 diff --git a/arch/s390/mm/pgtable.c b/arch/s390/mm/pgtable.c
570 index 37a23c22..458893f 100644
571 --- a/arch/s390/mm/pgtable.c
572 +++ b/arch/s390/mm/pgtable.c
573 @@ -291,8 +291,9 @@ void page_table_free_rcu(struct mmu_gather *tlb, unsigned long *table)
574
575 void __tlb_remove_table(void *_table)
576 {
577 - void *table = (void *)((unsigned long) _table & PAGE_MASK);
578 - unsigned type = (unsigned long) _table & ~PAGE_MASK;
579 + const unsigned long mask = (FRAG_MASK << 4) | FRAG_MASK;
580 + void *table = (void *)((unsigned long) _table & ~mask);
581 + unsigned type = (unsigned long) _table & mask;
582
583 if (type)
584 __page_table_free_rcu(table, type);
585 diff --git a/arch/um/drivers/ubd_kern.c b/arch/um/drivers/ubd_kern.c
586 index 620f5b7..0491e40 100644
587 --- a/arch/um/drivers/ubd_kern.c
588 +++ b/arch/um/drivers/ubd_kern.c
589 @@ -513,8 +513,37 @@ __uml_exitcall(kill_io_thread);
590 static inline int ubd_file_size(struct ubd *ubd_dev, __u64 *size_out)
591 {
592 char *file;
593 + int fd;
594 + int err;
595 +
596 + __u32 version;
597 + __u32 align;
598 + char *backing_file;
599 + time_t mtime;
600 + unsigned long long size;
601 + int sector_size;
602 + int bitmap_offset;
603 +
604 + if (ubd_dev->file && ubd_dev->cow.file) {
605 + file = ubd_dev->cow.file;
606 +
607 + goto out;
608 + }
609
610 - file = ubd_dev->cow.file ? ubd_dev->cow.file : ubd_dev->file;
611 + fd = os_open_file(ubd_dev->file, global_openflags, 0);
612 + if (fd < 0)
613 + return fd;
614 +
615 + err = read_cow_header(file_reader, &fd, &version, &backing_file, \
616 + &mtime, &size, &sector_size, &align, &bitmap_offset);
617 + os_close_file(fd);
618 +
619 + if(err == -EINVAL)
620 + file = ubd_dev->file;
621 + else
622 + file = backing_file;
623 +
624 +out:
625 return os_file_size(file, size_out);
626 }
627
628 diff --git a/arch/x86/include/asm/apic.h b/arch/x86/include/asm/apic.h
629 index 4a0b7c7..244ac77 100644
630 --- a/arch/x86/include/asm/apic.h
631 +++ b/arch/x86/include/asm/apic.h
632 @@ -495,7 +495,7 @@ static inline void default_wait_for_init_deassert(atomic_t *deassert)
633 return;
634 }
635
636 -extern struct apic *generic_bigsmp_probe(void);
637 +extern void generic_bigsmp_probe(void);
638
639
640 #ifdef CONFIG_X86_LOCAL_APIC
641 diff --git a/arch/x86/include/asm/uv/uv_bau.h b/arch/x86/include/asm/uv/uv_bau.h
642 index a291c40..5d62d65 100644
643 --- a/arch/x86/include/asm/uv/uv_bau.h
644 +++ b/arch/x86/include/asm/uv/uv_bau.h
645 @@ -55,6 +55,7 @@
646 #define UV_BAU_TUNABLES_DIR "sgi_uv"
647 #define UV_BAU_TUNABLES_FILE "bau_tunables"
648 #define WHITESPACE " \t\n"
649 +#define uv_mmask ((1UL << uv_hub_info->m_val) - 1)
650 #define uv_physnodeaddr(x) ((__pa((unsigned long)(x)) & uv_mmask))
651 #define cpubit_isset(cpu, bau_local_cpumask) \
652 test_bit((cpu), (bau_local_cpumask).bits)
653 diff --git a/arch/x86/include/asm/uv/uv_hub.h b/arch/x86/include/asm/uv/uv_hub.h
654 index f26544a..54a13aa 100644
655 --- a/arch/x86/include/asm/uv/uv_hub.h
656 +++ b/arch/x86/include/asm/uv/uv_hub.h
657 @@ -46,6 +46,13 @@
658 * PNODE - the low N bits of the GNODE. The PNODE is the most useful variant
659 * of the nasid for socket usage.
660 *
661 + * GPA - (global physical address) a socket physical address converted
662 + * so that it can be used by the GRU as a global address. Socket
663 + * physical addresses 1) need additional NASID (node) bits added
664 + * to the high end of the address, and 2) unaliased if the
665 + * partition does not have a physical address 0. In addition, on
666 + * UV2 rev 1, GPAs need the gnode left shifted to bits 39 or 40.
667 + *
668 *
669 * NumaLink Global Physical Address Format:
670 * +--------------------------------+---------------------+
671 @@ -141,6 +148,8 @@ struct uv_hub_info_s {
672 unsigned int gnode_extra;
673 unsigned char hub_revision;
674 unsigned char apic_pnode_shift;
675 + unsigned char m_shift;
676 + unsigned char n_lshift;
677 unsigned long gnode_upper;
678 unsigned long lowmem_remap_top;
679 unsigned long lowmem_remap_base;
680 @@ -177,6 +186,16 @@ static inline int is_uv2_hub(void)
681 return uv_hub_info->hub_revision >= UV2_HUB_REVISION_BASE;
682 }
683
684 +static inline int is_uv2_1_hub(void)
685 +{
686 + return uv_hub_info->hub_revision == UV2_HUB_REVISION_BASE;
687 +}
688 +
689 +static inline int is_uv2_2_hub(void)
690 +{
691 + return uv_hub_info->hub_revision == UV2_HUB_REVISION_BASE + 1;
692 +}
693 +
694 union uvh_apicid {
695 unsigned long v;
696 struct uvh_apicid_s {
697 @@ -276,7 +295,10 @@ static inline unsigned long uv_soc_phys_ram_to_gpa(unsigned long paddr)
698 {
699 if (paddr < uv_hub_info->lowmem_remap_top)
700 paddr |= uv_hub_info->lowmem_remap_base;
701 - return paddr | uv_hub_info->gnode_upper;
702 + paddr |= uv_hub_info->gnode_upper;
703 + paddr = ((paddr << uv_hub_info->m_shift) >> uv_hub_info->m_shift) |
704 + ((paddr >> uv_hub_info->m_val) << uv_hub_info->n_lshift);
705 + return paddr;
706 }
707
708
709 @@ -300,16 +322,19 @@ static inline unsigned long uv_gpa_to_soc_phys_ram(unsigned long gpa)
710 unsigned long remap_base = uv_hub_info->lowmem_remap_base;
711 unsigned long remap_top = uv_hub_info->lowmem_remap_top;
712
713 + gpa = ((gpa << uv_hub_info->m_shift) >> uv_hub_info->m_shift) |
714 + ((gpa >> uv_hub_info->n_lshift) << uv_hub_info->m_val);
715 + gpa = gpa & uv_hub_info->gpa_mask;
716 if (paddr >= remap_base && paddr < remap_base + remap_top)
717 paddr -= remap_base;
718 return paddr;
719 }
720
721
722 -/* gnode -> pnode */
723 +/* gpa -> pnode */
724 static inline unsigned long uv_gpa_to_gnode(unsigned long gpa)
725 {
726 - return gpa >> uv_hub_info->m_val;
727 + return gpa >> uv_hub_info->n_lshift;
728 }
729
730 /* gpa -> pnode */
731 @@ -320,6 +345,12 @@ static inline int uv_gpa_to_pnode(unsigned long gpa)
732 return uv_gpa_to_gnode(gpa) & n_mask;
733 }
734
735 +/* gpa -> node offset*/
736 +static inline unsigned long uv_gpa_to_offset(unsigned long gpa)
737 +{
738 + return (gpa << uv_hub_info->m_shift) >> uv_hub_info->m_shift;
739 +}
740 +
741 /* pnode, offset --> socket virtual */
742 static inline void *uv_pnode_offset_to_vaddr(int pnode, unsigned long offset)
743 {
744 diff --git a/arch/x86/kernel/amd_iommu.c b/arch/x86/kernel/amd_iommu.c
745 index d3d9d50..bfd75ff 100644
746 --- a/arch/x86/kernel/amd_iommu.c
747 +++ b/arch/x86/kernel/amd_iommu.c
748 @@ -1203,7 +1203,7 @@ static int alloc_new_range(struct dma_ops_domain *dma_dom,
749 if (!pte || !IOMMU_PTE_PRESENT(*pte))
750 continue;
751
752 - dma_ops_reserve_addresses(dma_dom, i << PAGE_SHIFT, 1);
753 + dma_ops_reserve_addresses(dma_dom, i >> PAGE_SHIFT, 1);
754 }
755
756 update_domain(&dma_dom->domain);
757 diff --git a/arch/x86/kernel/apic/bigsmp_32.c b/arch/x86/kernel/apic/bigsmp_32.c
758 index efd737e..521bead 100644
759 --- a/arch/x86/kernel/apic/bigsmp_32.c
760 +++ b/arch/x86/kernel/apic/bigsmp_32.c
761 @@ -255,12 +255,24 @@ static struct apic apic_bigsmp = {
762 .x86_32_early_logical_apicid = bigsmp_early_logical_apicid,
763 };
764
765 -struct apic * __init generic_bigsmp_probe(void)
766 +void __init generic_bigsmp_probe(void)
767 {
768 - if (probe_bigsmp())
769 - return &apic_bigsmp;
770 + unsigned int cpu;
771
772 - return NULL;
773 + if (!probe_bigsmp())
774 + return;
775 +
776 + apic = &apic_bigsmp;
777 +
778 + for_each_possible_cpu(cpu) {
779 + if (early_per_cpu(x86_cpu_to_logical_apicid,
780 + cpu) == BAD_APICID)
781 + continue;
782 + early_per_cpu(x86_cpu_to_logical_apicid, cpu) =
783 + bigsmp_early_logical_apicid(cpu);
784 + }
785 +
786 + pr_info("Overriding APIC driver with %s\n", apic_bigsmp.name);
787 }
788
789 apic_driver(apic_bigsmp);
790 diff --git a/arch/x86/kernel/apic/probe_32.c b/arch/x86/kernel/apic/probe_32.c
791 index b5254ad..0787bb3 100644
792 --- a/arch/x86/kernel/apic/probe_32.c
793 +++ b/arch/x86/kernel/apic/probe_32.c
794 @@ -200,14 +200,8 @@ void __init default_setup_apic_routing(void)
795 * - we find more than 8 CPUs in acpi LAPIC listing with xAPIC support
796 */
797
798 - if (!cmdline_apic && apic == &apic_default) {
799 - struct apic *bigsmp = generic_bigsmp_probe();
800 - if (bigsmp) {
801 - apic = bigsmp;
802 - printk(KERN_INFO "Overriding APIC driver with %s\n",
803 - apic->name);
804 - }
805 - }
806 + if (!cmdline_apic && apic == &apic_default)
807 + generic_bigsmp_probe();
808 #endif
809
810 if (apic->setup_apic_routing)
811 diff --git a/arch/x86/kernel/apic/x2apic_uv_x.c b/arch/x86/kernel/apic/x2apic_uv_x.c
812 index 34b1859..cfeb978 100644
813 --- a/arch/x86/kernel/apic/x2apic_uv_x.c
814 +++ b/arch/x86/kernel/apic/x2apic_uv_x.c
815 @@ -832,6 +832,10 @@ void __init uv_system_init(void)
816 uv_cpu_hub_info(cpu)->apic_pnode_shift = uvh_apicid.s.pnode_shift;
817 uv_cpu_hub_info(cpu)->hub_revision = uv_hub_info->hub_revision;
818
819 + uv_cpu_hub_info(cpu)->m_shift = 64 - m_val;
820 + uv_cpu_hub_info(cpu)->n_lshift = is_uv2_1_hub() ?
821 + (m_val == 40 ? 40 : 39) : m_val;
822 +
823 pnode = uv_apicid_to_pnode(apicid);
824 blade = boot_pnode_to_blade(pnode);
825 lcpu = uv_blade_info[blade].nr_possible_cpus;
826 @@ -862,8 +866,7 @@ void __init uv_system_init(void)
827 if (uv_node_to_blade[nid] >= 0)
828 continue;
829 paddr = node_start_pfn(nid) << PAGE_SHIFT;
830 - paddr = uv_soc_phys_ram_to_gpa(paddr);
831 - pnode = (paddr >> m_val) & pnode_mask;
832 + pnode = uv_gpa_to_pnode(uv_soc_phys_ram_to_gpa(paddr));
833 blade = boot_pnode_to_blade(pnode);
834 uv_node_to_blade[nid] = blade;
835 }
836 diff --git a/arch/x86/kernel/kprobes.c b/arch/x86/kernel/kprobes.c
837 index f1a6244..794bc95 100644
838 --- a/arch/x86/kernel/kprobes.c
839 +++ b/arch/x86/kernel/kprobes.c
840 @@ -75,8 +75,10 @@ DEFINE_PER_CPU(struct kprobe_ctlblk, kprobe_ctlblk);
841 /*
842 * Undefined/reserved opcodes, conditional jump, Opcode Extension
843 * Groups, and some special opcodes can not boost.
844 + * This is non-const to keep gcc from statically optimizing it out, as
845 + * variable_test_bit makes gcc think only *(unsigned long*) is used.
846 */
847 -static const u32 twobyte_is_boostable[256 / 32] = {
848 +static u32 twobyte_is_boostable[256 / 32] = {
849 /* 0 1 2 3 4 5 6 7 8 9 a b c d e f */
850 /* ---------------------------------------------- */
851 W(0x00, 0, 0, 1, 1, 0, 0, 1, 0, 1, 1, 0, 0, 0, 0, 0, 0) | /* 00 */
852 diff --git a/arch/x86/mm/gup.c b/arch/x86/mm/gup.c
853 index dbe34b9..ea30585 100644
854 --- a/arch/x86/mm/gup.c
855 +++ b/arch/x86/mm/gup.c
856 @@ -108,16 +108,6 @@ static inline void get_head_page_multiple(struct page *page, int nr)
857 SetPageReferenced(page);
858 }
859
860 -static inline void get_huge_page_tail(struct page *page)
861 -{
862 - /*
863 - * __split_huge_page_refcount() cannot run
864 - * from under us.
865 - */
866 - VM_BUG_ON(atomic_read(&page->_count) < 0);
867 - atomic_inc(&page->_count);
868 -}
869 -
870 static noinline int gup_huge_pmd(pmd_t pmd, unsigned long addr,
871 unsigned long end, int write, struct page **pages, int *nr)
872 {
873 diff --git a/arch/x86/platform/uv/tlb_uv.c b/arch/x86/platform/uv/tlb_uv.c
874 index 68e467f..82cff4a 100644
875 --- a/arch/x86/platform/uv/tlb_uv.c
876 +++ b/arch/x86/platform/uv/tlb_uv.c
877 @@ -115,9 +115,6 @@ early_param("nobau", setup_nobau);
878
879 /* base pnode in this partition */
880 static int uv_base_pnode __read_mostly;
881 -/* position of pnode (which is nasid>>1): */
882 -static int uv_nshift __read_mostly;
883 -static unsigned long uv_mmask __read_mostly;
884
885 static DEFINE_PER_CPU(struct ptc_stats, ptcstats);
886 static DEFINE_PER_CPU(struct bau_control, bau_control);
887 @@ -1426,7 +1423,7 @@ static void activation_descriptor_init(int node, int pnode, int base_pnode)
888 {
889 int i;
890 int cpu;
891 - unsigned long pa;
892 + unsigned long gpa;
893 unsigned long m;
894 unsigned long n;
895 size_t dsize;
896 @@ -1442,9 +1439,9 @@ static void activation_descriptor_init(int node, int pnode, int base_pnode)
897 bau_desc = kmalloc_node(dsize, GFP_KERNEL, node);
898 BUG_ON(!bau_desc);
899
900 - pa = uv_gpa(bau_desc); /* need the real nasid*/
901 - n = pa >> uv_nshift;
902 - m = pa & uv_mmask;
903 + gpa = uv_gpa(bau_desc);
904 + n = uv_gpa_to_gnode(gpa);
905 + m = uv_gpa_to_offset(gpa);
906
907 /* the 14-bit pnode */
908 write_mmr_descriptor_base(pnode, (n << UV_DESC_PSHIFT | m));
909 @@ -1516,9 +1513,9 @@ static void pq_init(int node, int pnode)
910 bcp->queue_last = pqp + (DEST_Q_SIZE - 1);
911 }
912 /*
913 - * need the pnode of where the memory was really allocated
914 + * need the gnode of where the memory was really allocated
915 */
916 - pn = uv_gpa(pqp) >> uv_nshift;
917 + pn = uv_gpa_to_gnode(uv_gpa(pqp));
918 first = uv_physnodeaddr(pqp);
919 pn_first = ((unsigned long)pn << UV_PAYLOADQ_PNODE_SHIFT) | first;
920 last = uv_physnodeaddr(pqp + (DEST_Q_SIZE - 1));
921 @@ -1812,8 +1809,6 @@ static int __init uv_bau_init(void)
922 zalloc_cpumask_var_node(mask, GFP_KERNEL, cpu_to_node(cur_cpu));
923 }
924
925 - uv_nshift = uv_hub_info->m_val;
926 - uv_mmask = (1UL << uv_hub_info->m_val) - 1;
927 nuvhubs = uv_num_possible_blades();
928 spin_lock_init(&disable_lock);
929 congested_cycles = usec_2_cycles(congested_respns_us);
930 diff --git a/block/genhd.c b/block/genhd.c
931 index 3608289..8c0829a 100644
932 --- a/block/genhd.c
933 +++ b/block/genhd.c
934 @@ -611,6 +611,12 @@ void add_disk(struct gendisk *disk)
935 register_disk(disk);
936 blk_register_queue(disk);
937
938 + /*
939 + * Take an extra ref on queue which will be put on disk_release()
940 + * so that it sticks around as long as @disk is there.
941 + */
942 + WARN_ON_ONCE(blk_get_queue(disk->queue));
943 +
944 retval = sysfs_create_link(&disk_to_dev(disk)->kobj, &bdi->dev->kobj,
945 "bdi");
946 WARN_ON(retval);
947 @@ -1103,6 +1109,8 @@ static void disk_release(struct device *dev)
948 disk_replace_part_tbl(disk, NULL);
949 free_part_stats(&disk->part0);
950 free_part_info(&disk->part0);
951 + if (disk->queue)
952 + blk_put_queue(disk->queue);
953 kfree(disk);
954 }
955 struct class block_class = {
956 diff --git a/crypto/cryptd.c b/crypto/cryptd.c
957 index e46d21a..671d4d6 100644
958 --- a/crypto/cryptd.c
959 +++ b/crypto/cryptd.c
960 @@ -945,7 +945,7 @@ static void __exit cryptd_exit(void)
961 crypto_unregister_template(&cryptd_tmpl);
962 }
963
964 -module_init(cryptd_init);
965 +subsys_initcall(cryptd_init);
966 module_exit(cryptd_exit);
967
968 MODULE_LICENSE("GPL");
969 diff --git a/drivers/acpi/atomicio.c b/drivers/acpi/atomicio.c
970 index 7489b89..f151afe 100644
971 --- a/drivers/acpi/atomicio.c
972 +++ b/drivers/acpi/atomicio.c
973 @@ -76,7 +76,7 @@ static void __iomem *__acpi_ioremap_fast(phys_addr_t paddr,
974 {
975 struct acpi_iomap *map;
976
977 - map = __acpi_find_iomap(paddr, size);
978 + map = __acpi_find_iomap(paddr, size/8);
979 if (map)
980 return map->vaddr + (paddr - map->paddr);
981 else
982 diff --git a/drivers/ata/ata_piix.c b/drivers/ata/ata_piix.c
983 index 6f6e771..6da6deb 100644
984 --- a/drivers/ata/ata_piix.c
985 +++ b/drivers/ata/ata_piix.c
986 @@ -113,6 +113,8 @@ enum {
987 PIIX_PATA_FLAGS = ATA_FLAG_SLAVE_POSS,
988 PIIX_SATA_FLAGS = ATA_FLAG_SATA | PIIX_FLAG_CHECKINTR,
989
990 + PIIX_FLAG_PIO16 = (1 << 30), /*support 16bit PIO only*/
991 +
992 PIIX_80C_PRI = (1 << 5) | (1 << 4),
993 PIIX_80C_SEC = (1 << 7) | (1 << 6),
994
995 @@ -147,6 +149,7 @@ enum piix_controller_ids {
996 ich8m_apple_sata, /* locks up on second port enable */
997 tolapai_sata,
998 piix_pata_vmw, /* PIIX4 for VMware, spurious DMA_ERR */
999 + ich8_sata_snb,
1000 };
1001
1002 struct piix_map_db {
1003 @@ -177,6 +180,7 @@ static int piix_sidpr_scr_write(struct ata_link *link,
1004 static int piix_sidpr_set_lpm(struct ata_link *link, enum ata_lpm_policy policy,
1005 unsigned hints);
1006 static bool piix_irq_check(struct ata_port *ap);
1007 +static int piix_port_start(struct ata_port *ap);
1008 #ifdef CONFIG_PM
1009 static int piix_pci_device_suspend(struct pci_dev *pdev, pm_message_t mesg);
1010 static int piix_pci_device_resume(struct pci_dev *pdev);
1011 @@ -298,21 +302,21 @@ static const struct pci_device_id piix_pci_tbl[] = {
1012 /* SATA Controller IDE (PCH) */
1013 { 0x8086, 0x3b2e, PCI_ANY_ID, PCI_ANY_ID, 0, 0, ich8_sata },
1014 /* SATA Controller IDE (CPT) */
1015 - { 0x8086, 0x1c00, PCI_ANY_ID, PCI_ANY_ID, 0, 0, ich8_sata },
1016 + { 0x8086, 0x1c00, PCI_ANY_ID, PCI_ANY_ID, 0, 0, ich8_sata_snb },
1017 /* SATA Controller IDE (CPT) */
1018 - { 0x8086, 0x1c01, PCI_ANY_ID, PCI_ANY_ID, 0, 0, ich8_sata },
1019 + { 0x8086, 0x1c01, PCI_ANY_ID, PCI_ANY_ID, 0, 0, ich8_sata_snb },
1020 /* SATA Controller IDE (CPT) */
1021 { 0x8086, 0x1c08, PCI_ANY_ID, PCI_ANY_ID, 0, 0, ich8_2port_sata },
1022 /* SATA Controller IDE (CPT) */
1023 { 0x8086, 0x1c09, PCI_ANY_ID, PCI_ANY_ID, 0, 0, ich8_2port_sata },
1024 /* SATA Controller IDE (PBG) */
1025 - { 0x8086, 0x1d00, PCI_ANY_ID, PCI_ANY_ID, 0, 0, ich8_sata },
1026 + { 0x8086, 0x1d00, PCI_ANY_ID, PCI_ANY_ID, 0, 0, ich8_sata_snb },
1027 /* SATA Controller IDE (PBG) */
1028 { 0x8086, 0x1d08, PCI_ANY_ID, PCI_ANY_ID, 0, 0, ich8_2port_sata },
1029 /* SATA Controller IDE (Panther Point) */
1030 - { 0x8086, 0x1e00, PCI_ANY_ID, PCI_ANY_ID, 0, 0, ich8_sata },
1031 + { 0x8086, 0x1e00, PCI_ANY_ID, PCI_ANY_ID, 0, 0, ich8_sata_snb },
1032 /* SATA Controller IDE (Panther Point) */
1033 - { 0x8086, 0x1e01, PCI_ANY_ID, PCI_ANY_ID, 0, 0, ich8_sata },
1034 + { 0x8086, 0x1e01, PCI_ANY_ID, PCI_ANY_ID, 0, 0, ich8_sata_snb },
1035 /* SATA Controller IDE (Panther Point) */
1036 { 0x8086, 0x1e08, PCI_ANY_ID, PCI_ANY_ID, 0, 0, ich8_2port_sata },
1037 /* SATA Controller IDE (Panther Point) */
1038 @@ -338,6 +342,7 @@ static struct scsi_host_template piix_sht = {
1039 static struct ata_port_operations piix_sata_ops = {
1040 .inherits = &ata_bmdma32_port_ops,
1041 .sff_irq_check = piix_irq_check,
1042 + .port_start = piix_port_start,
1043 };
1044
1045 static struct ata_port_operations piix_pata_ops = {
1046 @@ -478,6 +483,7 @@ static const struct piix_map_db *piix_map_db_table[] = {
1047 [ich8_2port_sata] = &ich8_2port_map_db,
1048 [ich8m_apple_sata] = &ich8m_apple_map_db,
1049 [tolapai_sata] = &tolapai_map_db,
1050 + [ich8_sata_snb] = &ich8_map_db,
1051 };
1052
1053 static struct ata_port_info piix_port_info[] = {
1054 @@ -606,6 +612,19 @@ static struct ata_port_info piix_port_info[] = {
1055 .port_ops = &piix_vmw_ops,
1056 },
1057
1058 + /*
1059 + * some Sandybridge chipsets have broken 32 mode up to now,
1060 + * see https://bugzilla.kernel.org/show_bug.cgi?id=40592
1061 + */
1062 + [ich8_sata_snb] =
1063 + {
1064 + .flags = PIIX_SATA_FLAGS | PIIX_FLAG_SIDPR | PIIX_FLAG_PIO16,
1065 + .pio_mask = ATA_PIO4,
1066 + .mwdma_mask = ATA_MWDMA2,
1067 + .udma_mask = ATA_UDMA6,
1068 + .port_ops = &piix_sata_ops,
1069 + },
1070 +
1071 };
1072
1073 static struct pci_bits piix_enable_bits[] = {
1074 @@ -649,6 +668,14 @@ static const struct ich_laptop ich_laptop[] = {
1075 { 0, }
1076 };
1077
1078 +static int piix_port_start(struct ata_port *ap)
1079 +{
1080 + if (!(ap->flags & PIIX_FLAG_PIO16))
1081 + ap->pflags |= ATA_PFLAG_PIO32 | ATA_PFLAG_PIO32CHANGE;
1082 +
1083 + return ata_bmdma_port_start(ap);
1084 +}
1085 +
1086 /**
1087 * ich_pata_cable_detect - Probe host controller cable detect info
1088 * @ap: Port for which cable detect info is desired
1089 diff --git a/drivers/base/power/runtime.c b/drivers/base/power/runtime.c
1090 index 0d4587b..1023392 100644
1091 --- a/drivers/base/power/runtime.c
1092 +++ b/drivers/base/power/runtime.c
1093 @@ -278,6 +278,9 @@ static int rpm_callback(int (*cb)(struct device *), struct device *dev)
1094 * If a deferred resume was requested while the callback was running then carry
1095 * it out; otherwise send an idle notification for the device (if the suspend
1096 * failed) or for its parent (if the suspend succeeded).
1097 + * If ->runtime_suspend failed with -EAGAIN or -EBUSY, and if the RPM_AUTO
1098 + * flag is set and the next autosuspend-delay expiration time is in the
1099 + * future, schedule another autosuspend attempt.
1100 *
1101 * This function must be called under dev->power.lock with interrupts disabled.
1102 */
1103 @@ -389,10 +392,21 @@ static int rpm_suspend(struct device *dev, int rpmflags)
1104 if (retval) {
1105 __update_runtime_status(dev, RPM_ACTIVE);
1106 dev->power.deferred_resume = 0;
1107 - if (retval == -EAGAIN || retval == -EBUSY)
1108 + if (retval == -EAGAIN || retval == -EBUSY) {
1109 dev->power.runtime_error = 0;
1110 - else
1111 +
1112 + /*
1113 + * If the callback routine failed an autosuspend, and
1114 + * if the last_busy time has been updated so that there
1115 + * is a new autosuspend expiration time, automatically
1116 + * reschedule another autosuspend.
1117 + */
1118 + if ((rpmflags & RPM_AUTO) &&
1119 + pm_runtime_autosuspend_expiration(dev) != 0)
1120 + goto repeat;
1121 + } else {
1122 pm_runtime_cancel_pending(dev);
1123 + }
1124 } else {
1125 no_callback:
1126 __update_runtime_status(dev, RPM_SUSPENDED);
1127 diff --git a/drivers/block/cciss.c b/drivers/block/cciss.c
1128 index 8f4ef65..c2f9b3e 100644
1129 --- a/drivers/block/cciss.c
1130 +++ b/drivers/block/cciss.c
1131 @@ -4533,6 +4533,13 @@ static int cciss_controller_hard_reset(struct pci_dev *pdev,
1132 pmcsr &= ~PCI_PM_CTRL_STATE_MASK;
1133 pmcsr |= PCI_D0;
1134 pci_write_config_word(pdev, pos + PCI_PM_CTRL, pmcsr);
1135 +
1136 + /*
1137 + * The P600 requires a small delay when changing states.
1138 + * Otherwise we may think the board did not reset and we bail.
1139 + * This for kdump only and is particular to the P600.
1140 + */
1141 + msleep(500);
1142 }
1143 return 0;
1144 }
1145 diff --git a/drivers/block/xen-blkback/blkback.c b/drivers/block/xen-blkback/blkback.c
1146 index 5cf2993..54139d0 100644
1147 --- a/drivers/block/xen-blkback/blkback.c
1148 +++ b/drivers/block/xen-blkback/blkback.c
1149 @@ -667,7 +667,7 @@ static int dispatch_rw_block_io(struct xen_blkif *blkif,
1150
1151 if (operation == READ)
1152 blkif->st_rd_sect += preq.nr_sects;
1153 - else if (operation == WRITE || operation == WRITE_FLUSH)
1154 + else if (operation & WRITE)
1155 blkif->st_wr_sect += preq.nr_sects;
1156
1157 return 0;
1158 diff --git a/drivers/bluetooth/ath3k.c b/drivers/bluetooth/ath3k.c
1159 index 6bacef3..db7cb81 100644
1160 --- a/drivers/bluetooth/ath3k.c
1161 +++ b/drivers/bluetooth/ath3k.c
1162 @@ -63,6 +63,7 @@ static struct usb_device_id ath3k_table[] = {
1163 /* Atheros AR3011 with sflash firmware*/
1164 { USB_DEVICE(0x0CF3, 0x3002) },
1165 { USB_DEVICE(0x13d3, 0x3304) },
1166 + { USB_DEVICE(0x0930, 0x0215) },
1167
1168 /* Atheros AR9285 Malbec with sflash firmware */
1169 { USB_DEVICE(0x03F0, 0x311D) },
1170 @@ -375,6 +376,11 @@ static int ath3k_probe(struct usb_interface *intf,
1171
1172 /* load patch and sysconfig files for AR3012 */
1173 if (id->driver_info & BTUSB_ATH3012) {
1174 +
1175 + /* New firmware with patch and sysconfig files already loaded */
1176 + if (le16_to_cpu(udev->descriptor.bcdDevice) > 0x0001)
1177 + return -ENODEV;
1178 +
1179 ret = ath3k_load_patch(udev);
1180 if (ret < 0) {
1181 BT_ERR("Loading patch file failed");
1182 diff --git a/drivers/bluetooth/btusb.c b/drivers/bluetooth/btusb.c
1183 index c2de895..b9af6db 100644
1184 --- a/drivers/bluetooth/btusb.c
1185 +++ b/drivers/bluetooth/btusb.c
1186 @@ -54,11 +54,15 @@ static struct usb_driver btusb_driver;
1187 #define BTUSB_BCM92035 0x10
1188 #define BTUSB_BROKEN_ISOC 0x20
1189 #define BTUSB_WRONG_SCO_MTU 0x40
1190 +#define BTUSB_ATH3012 0x80
1191
1192 static struct usb_device_id btusb_table[] = {
1193 /* Generic Bluetooth USB device */
1194 { USB_DEVICE_INFO(0xe0, 0x01, 0x01) },
1195
1196 + /* Broadcom SoftSailing reporting vendor specific */
1197 + { USB_DEVICE(0x05ac, 0x21e1) },
1198 +
1199 /* Apple MacBookPro 7,1 */
1200 { USB_DEVICE(0x05ac, 0x8213) },
1201
1202 @@ -71,9 +75,15 @@ static struct usb_device_id btusb_table[] = {
1203 /* Apple MacBookAir3,1, MacBookAir3,2 */
1204 { USB_DEVICE(0x05ac, 0x821b) },
1205
1206 + /* Apple MacBookAir4,1 */
1207 + { USB_DEVICE(0x05ac, 0x821f) },
1208 +
1209 /* Apple MacBookPro8,2 */
1210 { USB_DEVICE(0x05ac, 0x821a) },
1211
1212 + /* Apple MacMini5,1 */
1213 + { USB_DEVICE(0x05ac, 0x8281) },
1214 +
1215 /* AVM BlueFRITZ! USB v2.0 */
1216 { USB_DEVICE(0x057c, 0x3800) },
1217
1218 @@ -105,12 +115,13 @@ static struct usb_device_id blacklist_table[] = {
1219 /* Atheros 3011 with sflash firmware */
1220 { USB_DEVICE(0x0cf3, 0x3002), .driver_info = BTUSB_IGNORE },
1221 { USB_DEVICE(0x13d3, 0x3304), .driver_info = BTUSB_IGNORE },
1222 + { USB_DEVICE(0x0930, 0x0215), .driver_info = BTUSB_IGNORE },
1223
1224 /* Atheros AR9285 Malbec with sflash firmware */
1225 { USB_DEVICE(0x03f0, 0x311d), .driver_info = BTUSB_IGNORE },
1226
1227 /* Atheros 3012 with sflash firmware */
1228 - { USB_DEVICE(0x0cf3, 0x3004), .driver_info = BTUSB_IGNORE },
1229 + { USB_DEVICE(0x0cf3, 0x3004), .driver_info = BTUSB_ATH3012 },
1230
1231 /* Atheros AR5BBU12 with sflash firmware */
1232 { USB_DEVICE(0x0489, 0xe02c), .driver_info = BTUSB_IGNORE },
1233 @@ -914,6 +925,15 @@ static int btusb_probe(struct usb_interface *intf,
1234 if (ignore_sniffer && id->driver_info & BTUSB_SNIFFER)
1235 return -ENODEV;
1236
1237 + if (id->driver_info & BTUSB_ATH3012) {
1238 + struct usb_device *udev = interface_to_usbdev(intf);
1239 +
1240 + /* Old firmware would otherwise let ath3k driver load
1241 + * patch and sysconfig files */
1242 + if (le16_to_cpu(udev->descriptor.bcdDevice) <= 0x0001)
1243 + return -ENODEV;
1244 + }
1245 +
1246 data = kzalloc(sizeof(*data), GFP_KERNEL);
1247 if (!data)
1248 return -ENOMEM;
1249 diff --git a/drivers/gpu/drm/i915/intel_dp.c b/drivers/gpu/drm/i915/intel_dp.c
1250 index e2aced6..14264a8 100644
1251 --- a/drivers/gpu/drm/i915/intel_dp.c
1252 +++ b/drivers/gpu/drm/i915/intel_dp.c
1253 @@ -1658,6 +1658,31 @@ g4x_dp_detect(struct intel_dp *intel_dp)
1254 return status;
1255 }
1256
1257 +static struct edid *
1258 +intel_dp_get_edid(struct drm_connector *connector, struct i2c_adapter *adapter)
1259 +{
1260 + struct intel_dp *intel_dp = intel_attached_dp(connector);
1261 + struct edid *edid;
1262 +
1263 + ironlake_edp_panel_vdd_on(intel_dp);
1264 + edid = drm_get_edid(connector, adapter);
1265 + ironlake_edp_panel_vdd_off(intel_dp);
1266 + return edid;
1267 +}
1268 +
1269 +static int
1270 +intel_dp_get_edid_modes(struct drm_connector *connector, struct i2c_adapter *adapter)
1271 +{
1272 + struct intel_dp *intel_dp = intel_attached_dp(connector);
1273 + int ret;
1274 +
1275 + ironlake_edp_panel_vdd_on(intel_dp);
1276 + ret = intel_ddc_get_modes(connector, adapter);
1277 + ironlake_edp_panel_vdd_off(intel_dp);
1278 + return ret;
1279 +}
1280 +
1281 +
1282 /**
1283 * Uses CRT_HOTPLUG_EN and CRT_HOTPLUG_STAT to detect DP connection.
1284 *
1285 @@ -1684,7 +1709,7 @@ intel_dp_detect(struct drm_connector *connector, bool force)
1286 if (intel_dp->force_audio) {
1287 intel_dp->has_audio = intel_dp->force_audio > 0;
1288 } else {
1289 - edid = drm_get_edid(connector, &intel_dp->adapter);
1290 + edid = intel_dp_get_edid(connector, &intel_dp->adapter);
1291 if (edid) {
1292 intel_dp->has_audio = drm_detect_monitor_audio(edid);
1293 connector->display_info.raw_edid = NULL;
1294 @@ -1705,7 +1730,7 @@ static int intel_dp_get_modes(struct drm_connector *connector)
1295 /* We should parse the EDID data and find out if it has an audio sink
1296 */
1297
1298 - ret = intel_ddc_get_modes(connector, &intel_dp->adapter);
1299 + ret = intel_dp_get_edid_modes(connector, &intel_dp->adapter);
1300 if (ret) {
1301 if (is_edp(intel_dp) && !dev_priv->panel_fixed_mode) {
1302 struct drm_display_mode *newmode;
1303 @@ -1741,7 +1766,7 @@ intel_dp_detect_audio(struct drm_connector *connector)
1304 struct edid *edid;
1305 bool has_audio = false;
1306
1307 - edid = drm_get_edid(connector, &intel_dp->adapter);
1308 + edid = intel_dp_get_edid(connector, &intel_dp->adapter);
1309 if (edid) {
1310 has_audio = drm_detect_monitor_audio(edid);
1311
1312 diff --git a/drivers/gpu/drm/i915/intel_panel.c b/drivers/gpu/drm/i915/intel_panel.c
1313 index 05f500c..f8aa821 100644
1314 --- a/drivers/gpu/drm/i915/intel_panel.c
1315 +++ b/drivers/gpu/drm/i915/intel_panel.c
1316 @@ -226,7 +226,7 @@ static void intel_pch_panel_set_backlight(struct drm_device *dev, u32 level)
1317 I915_WRITE(BLC_PWM_CPU_CTL, val | level);
1318 }
1319
1320 -void intel_panel_set_backlight(struct drm_device *dev, u32 level)
1321 +static void intel_panel_actually_set_backlight(struct drm_device *dev, u32 level)
1322 {
1323 struct drm_i915_private *dev_priv = dev->dev_private;
1324 u32 tmp;
1325 @@ -254,16 +254,21 @@ void intel_panel_set_backlight(struct drm_device *dev, u32 level)
1326 I915_WRITE(BLC_PWM_CTL, tmp | level);
1327 }
1328
1329 -void intel_panel_disable_backlight(struct drm_device *dev)
1330 +void intel_panel_set_backlight(struct drm_device *dev, u32 level)
1331 {
1332 struct drm_i915_private *dev_priv = dev->dev_private;
1333
1334 - if (dev_priv->backlight_enabled) {
1335 - dev_priv->backlight_level = intel_panel_get_backlight(dev);
1336 - dev_priv->backlight_enabled = false;
1337 - }
1338 + dev_priv->backlight_level = level;
1339 + if (dev_priv->backlight_enabled)
1340 + intel_panel_actually_set_backlight(dev, level);
1341 +}
1342 +
1343 +void intel_panel_disable_backlight(struct drm_device *dev)
1344 +{
1345 + struct drm_i915_private *dev_priv = dev->dev_private;
1346
1347 - intel_panel_set_backlight(dev, 0);
1348 + dev_priv->backlight_enabled = false;
1349 + intel_panel_actually_set_backlight(dev, 0);
1350 }
1351
1352 void intel_panel_enable_backlight(struct drm_device *dev)
1353 @@ -273,8 +278,8 @@ void intel_panel_enable_backlight(struct drm_device *dev)
1354 if (dev_priv->backlight_level == 0)
1355 dev_priv->backlight_level = intel_panel_get_max_backlight(dev);
1356
1357 - intel_panel_set_backlight(dev, dev_priv->backlight_level);
1358 dev_priv->backlight_enabled = true;
1359 + intel_panel_actually_set_backlight(dev, dev_priv->backlight_level);
1360 }
1361
1362 void intel_panel_setup_backlight(struct drm_device *dev)
1363 diff --git a/drivers/gpu/drm/radeon/atombios_dp.c b/drivers/gpu/drm/radeon/atombios_dp.c
1364 index 79e8ebc..b5628ce 100644
1365 --- a/drivers/gpu/drm/radeon/atombios_dp.c
1366 +++ b/drivers/gpu/drm/radeon/atombios_dp.c
1367 @@ -553,6 +553,7 @@ static void radeon_dp_set_panel_mode(struct drm_encoder *encoder,
1368 {
1369 struct drm_device *dev = encoder->dev;
1370 struct radeon_device *rdev = dev->dev_private;
1371 + struct radeon_connector *radeon_connector = to_radeon_connector(connector);
1372 int panel_mode = DP_PANEL_MODE_EXTERNAL_DP_MODE;
1373
1374 if (!ASIC_IS_DCE4(rdev))
1375 @@ -560,10 +561,20 @@ static void radeon_dp_set_panel_mode(struct drm_encoder *encoder,
1376
1377 if (radeon_connector_encoder_is_dp_bridge(connector))
1378 panel_mode = DP_PANEL_MODE_INTERNAL_DP1_MODE;
1379 + else if (connector->connector_type == DRM_MODE_CONNECTOR_eDP) {
1380 + u8 tmp = radeon_read_dpcd_reg(radeon_connector, DP_EDP_CONFIGURATION_CAP);
1381 + if (tmp & 1)
1382 + panel_mode = DP_PANEL_MODE_INTERNAL_DP2_MODE;
1383 + }
1384
1385 atombios_dig_encoder_setup(encoder,
1386 ATOM_ENCODER_CMD_SETUP_PANEL_MODE,
1387 panel_mode);
1388 +
1389 + if ((connector->connector_type == DRM_MODE_CONNECTOR_eDP) &&
1390 + (panel_mode == DP_PANEL_MODE_INTERNAL_DP2_MODE)) {
1391 + radeon_write_dpcd_reg(radeon_connector, DP_EDP_CONFIGURATION_SET, 1);
1392 + }
1393 }
1394
1395 void radeon_dp_set_link_config(struct drm_connector *connector,
1396 diff --git a/drivers/gpu/drm/radeon/evergreen.c b/drivers/gpu/drm/radeon/evergreen.c
1397 index ea7a24e..f1bdb58 100644
1398 --- a/drivers/gpu/drm/radeon/evergreen.c
1399 +++ b/drivers/gpu/drm/radeon/evergreen.c
1400 @@ -353,6 +353,7 @@ void evergreen_hpd_init(struct radeon_device *rdev)
1401 default:
1402 break;
1403 }
1404 + radeon_hpd_set_polarity(rdev, radeon_connector->hpd.hpd);
1405 }
1406 if (rdev->irq.installed)
1407 evergreen_irq_set(rdev);
1408 diff --git a/drivers/gpu/drm/radeon/r100.c b/drivers/gpu/drm/radeon/r100.c
1409 index 7fcdbbb..c9a0dae 100644
1410 --- a/drivers/gpu/drm/radeon/r100.c
1411 +++ b/drivers/gpu/drm/radeon/r100.c
1412 @@ -434,6 +434,7 @@ void r100_hpd_init(struct radeon_device *rdev)
1413 default:
1414 break;
1415 }
1416 + radeon_hpd_set_polarity(rdev, radeon_connector->hpd.hpd);
1417 }
1418 if (rdev->irq.installed)
1419 r100_irq_set(rdev);
1420 diff --git a/drivers/gpu/drm/radeon/r600.c b/drivers/gpu/drm/radeon/r600.c
1421 index 1dea9d6..1a4ed43 100644
1422 --- a/drivers/gpu/drm/radeon/r600.c
1423 +++ b/drivers/gpu/drm/radeon/r600.c
1424 @@ -762,13 +762,14 @@ void r600_hpd_init(struct radeon_device *rdev)
1425 struct drm_device *dev = rdev->ddev;
1426 struct drm_connector *connector;
1427
1428 - if (ASIC_IS_DCE3(rdev)) {
1429 - u32 tmp = DC_HPDx_CONNECTION_TIMER(0x9c4) | DC_HPDx_RX_INT_TIMER(0xfa);
1430 - if (ASIC_IS_DCE32(rdev))
1431 - tmp |= DC_HPDx_EN;
1432 + list_for_each_entry(connector, &dev->mode_config.connector_list, head) {
1433 + struct radeon_connector *radeon_connector = to_radeon_connector(connector);
1434 +
1435 + if (ASIC_IS_DCE3(rdev)) {
1436 + u32 tmp = DC_HPDx_CONNECTION_TIMER(0x9c4) | DC_HPDx_RX_INT_TIMER(0xfa);
1437 + if (ASIC_IS_DCE32(rdev))
1438 + tmp |= DC_HPDx_EN;
1439
1440 - list_for_each_entry(connector, &dev->mode_config.connector_list, head) {
1441 - struct radeon_connector *radeon_connector = to_radeon_connector(connector);
1442 switch (radeon_connector->hpd.hpd) {
1443 case RADEON_HPD_1:
1444 WREG32(DC_HPD1_CONTROL, tmp);
1445 @@ -798,10 +799,7 @@ void r600_hpd_init(struct radeon_device *rdev)
1446 default:
1447 break;
1448 }
1449 - }
1450 - } else {
1451 - list_for_each_entry(connector, &dev->mode_config.connector_list, head) {
1452 - struct radeon_connector *radeon_connector = to_radeon_connector(connector);
1453 + } else {
1454 switch (radeon_connector->hpd.hpd) {
1455 case RADEON_HPD_1:
1456 WREG32(DC_HOT_PLUG_DETECT1_CONTROL, DC_HOT_PLUG_DETECTx_EN);
1457 @@ -819,6 +817,7 @@ void r600_hpd_init(struct radeon_device *rdev)
1458 break;
1459 }
1460 }
1461 + radeon_hpd_set_polarity(rdev, radeon_connector->hpd.hpd);
1462 }
1463 if (rdev->irq.installed)
1464 r600_irq_set(rdev);
1465 diff --git a/drivers/gpu/drm/radeon/radeon.h b/drivers/gpu/drm/radeon/radeon.h
1466 index 0bb4ddf..59d72d0 100644
1467 --- a/drivers/gpu/drm/radeon/radeon.h
1468 +++ b/drivers/gpu/drm/radeon/radeon.h
1469 @@ -93,6 +93,7 @@ extern int radeon_audio;
1470 extern int radeon_disp_priority;
1471 extern int radeon_hw_i2c;
1472 extern int radeon_pcie_gen2;
1473 +extern int radeon_msi;
1474
1475 /*
1476 * Copy from radeon_drv.h so we don't have to include both and have conflicting
1477 diff --git a/drivers/gpu/drm/radeon/radeon_combios.c b/drivers/gpu/drm/radeon/radeon_combios.c
1478 index cd3c86c..859df6b 100644
1479 --- a/drivers/gpu/drm/radeon/radeon_combios.c
1480 +++ b/drivers/gpu/drm/radeon/radeon_combios.c
1481 @@ -620,8 +620,8 @@ static struct radeon_i2c_bus_rec combios_setup_i2c_bus(struct radeon_device *rde
1482 i2c.y_data_mask = 0x80;
1483 } else {
1484 /* default masks for ddc pads */
1485 - i2c.mask_clk_mask = RADEON_GPIO_EN_1;
1486 - i2c.mask_data_mask = RADEON_GPIO_EN_0;
1487 + i2c.mask_clk_mask = RADEON_GPIO_MASK_1;
1488 + i2c.mask_data_mask = RADEON_GPIO_MASK_0;
1489 i2c.a_clk_mask = RADEON_GPIO_A_1;
1490 i2c.a_data_mask = RADEON_GPIO_A_0;
1491 i2c.en_clk_mask = RADEON_GPIO_EN_1;
1492 diff --git a/drivers/gpu/drm/radeon/radeon_connectors.c b/drivers/gpu/drm/radeon/radeon_connectors.c
1493 index 05b8b2c..2109c17 100644
1494 --- a/drivers/gpu/drm/radeon/radeon_connectors.c
1495 +++ b/drivers/gpu/drm/radeon/radeon_connectors.c
1496 @@ -715,6 +715,7 @@ radeon_vga_detect(struct drm_connector *connector, bool force)
1497 dret = radeon_ddc_probe(radeon_connector,
1498 radeon_connector->requires_extended_probe);
1499 if (dret) {
1500 + radeon_connector->detected_by_load = false;
1501 if (radeon_connector->edid) {
1502 kfree(radeon_connector->edid);
1503 radeon_connector->edid = NULL;
1504 @@ -741,12 +742,21 @@ radeon_vga_detect(struct drm_connector *connector, bool force)
1505 } else {
1506
1507 /* if we aren't forcing don't do destructive polling */
1508 - if (!force)
1509 - return connector->status;
1510 + if (!force) {
1511 + /* only return the previous status if we last
1512 + * detected a monitor via load.
1513 + */
1514 + if (radeon_connector->detected_by_load)
1515 + return connector->status;
1516 + else
1517 + return ret;
1518 + }
1519
1520 if (radeon_connector->dac_load_detect && encoder) {
1521 encoder_funcs = encoder->helper_private;
1522 ret = encoder_funcs->detect(encoder, connector);
1523 + if (ret != connector_status_disconnected)
1524 + radeon_connector->detected_by_load = true;
1525 }
1526 }
1527
1528 @@ -888,6 +898,7 @@ radeon_dvi_detect(struct drm_connector *connector, bool force)
1529 dret = radeon_ddc_probe(radeon_connector,
1530 radeon_connector->requires_extended_probe);
1531 if (dret) {
1532 + radeon_connector->detected_by_load = false;
1533 if (radeon_connector->edid) {
1534 kfree(radeon_connector->edid);
1535 radeon_connector->edid = NULL;
1536 @@ -950,8 +961,18 @@ radeon_dvi_detect(struct drm_connector *connector, bool force)
1537 if ((ret == connector_status_connected) && (radeon_connector->use_digital == true))
1538 goto out;
1539
1540 + /* DVI-D and HDMI-A are digital only */
1541 + if ((connector->connector_type == DRM_MODE_CONNECTOR_DVID) ||
1542 + (connector->connector_type == DRM_MODE_CONNECTOR_HDMIA))
1543 + goto out;
1544 +
1545 + /* if we aren't forcing don't do destructive polling */
1546 if (!force) {
1547 - ret = connector->status;
1548 + /* only return the previous status if we last
1549 + * detected a monitor via load.
1550 + */
1551 + if (radeon_connector->detected_by_load)
1552 + ret = connector->status;
1553 goto out;
1554 }
1555
1556 @@ -976,6 +997,8 @@ radeon_dvi_detect(struct drm_connector *connector, bool force)
1557 if (ret == connector_status_connected) {
1558 radeon_connector->use_digital = false;
1559 }
1560 + if (ret != connector_status_disconnected)
1561 + radeon_connector->detected_by_load = true;
1562 }
1563 break;
1564 }
1565 diff --git a/drivers/gpu/drm/radeon/radeon_drv.c b/drivers/gpu/drm/radeon/radeon_drv.c
1566 index 73dfbe8..60e1605 100644
1567 --- a/drivers/gpu/drm/radeon/radeon_drv.c
1568 +++ b/drivers/gpu/drm/radeon/radeon_drv.c
1569 @@ -117,6 +117,7 @@ int radeon_audio = 0;
1570 int radeon_disp_priority = 0;
1571 int radeon_hw_i2c = 0;
1572 int radeon_pcie_gen2 = 0;
1573 +int radeon_msi = -1;
1574
1575 MODULE_PARM_DESC(no_wb, "Disable AGP writeback for scratch registers");
1576 module_param_named(no_wb, radeon_no_wb, int, 0444);
1577 @@ -163,6 +164,9 @@ module_param_named(hw_i2c, radeon_hw_i2c, int, 0444);
1578 MODULE_PARM_DESC(pcie_gen2, "PCIE Gen2 mode (1 = enable)");
1579 module_param_named(pcie_gen2, radeon_pcie_gen2, int, 0444);
1580
1581 +MODULE_PARM_DESC(msi, "MSI support (1 = enable, 0 = disable, -1 = auto)");
1582 +module_param_named(msi, radeon_msi, int, 0444);
1583 +
1584 static int radeon_suspend(struct drm_device *dev, pm_message_t state)
1585 {
1586 drm_radeon_private_t *dev_priv = dev->dev_private;
1587 diff --git a/drivers/gpu/drm/radeon/radeon_irq_kms.c b/drivers/gpu/drm/radeon/radeon_irq_kms.c
1588 index 9ec830c..fecc1aa 100644
1589 --- a/drivers/gpu/drm/radeon/radeon_irq_kms.c
1590 +++ b/drivers/gpu/drm/radeon/radeon_irq_kms.c
1591 @@ -108,6 +108,46 @@ void radeon_driver_irq_uninstall_kms(struct drm_device *dev)
1592 radeon_irq_set(rdev);
1593 }
1594
1595 +static bool radeon_msi_ok(struct radeon_device *rdev)
1596 +{
1597 + /* RV370/RV380 was first asic with MSI support */
1598 + if (rdev->family < CHIP_RV380)
1599 + return false;
1600 +
1601 + /* MSIs don't work on AGP */
1602 + if (rdev->flags & RADEON_IS_AGP)
1603 + return false;
1604 +
1605 + /* force MSI on */
1606 + if (radeon_msi == 1)
1607 + return true;
1608 + else if (radeon_msi == 0)
1609 + return false;
1610 +
1611 + /* Quirks */
1612 + /* HP RS690 only seems to work with MSIs. */
1613 + if ((rdev->pdev->device == 0x791f) &&
1614 + (rdev->pdev->subsystem_vendor == 0x103c) &&
1615 + (rdev->pdev->subsystem_device == 0x30c2))
1616 + return true;
1617 +
1618 + /* Dell RS690 only seems to work with MSIs. */
1619 + if ((rdev->pdev->device == 0x791f) &&
1620 + (rdev->pdev->subsystem_vendor == 0x1028) &&
1621 + (rdev->pdev->subsystem_device == 0x01fd))
1622 + return true;
1623 +
1624 + if (rdev->flags & RADEON_IS_IGP) {
1625 + /* APUs work fine with MSIs */
1626 + if (rdev->family >= CHIP_PALM)
1627 + return true;
1628 + /* lots of IGPs have problems with MSIs */
1629 + return false;
1630 + }
1631 +
1632 + return true;
1633 +}
1634 +
1635 int radeon_irq_kms_init(struct radeon_device *rdev)
1636 {
1637 int i;
1638 @@ -124,12 +164,8 @@ int radeon_irq_kms_init(struct radeon_device *rdev)
1639 }
1640 /* enable msi */
1641 rdev->msi_enabled = 0;
1642 - /* MSIs don't seem to work reliably on all IGP
1643 - * chips. Disable MSI on them for now.
1644 - */
1645 - if ((rdev->family >= CHIP_RV380) &&
1646 - ((!(rdev->flags & RADEON_IS_IGP)) || (rdev->family >= CHIP_PALM)) &&
1647 - (!(rdev->flags & RADEON_IS_AGP))) {
1648 +
1649 + if (radeon_msi_ok(rdev)) {
1650 int ret = pci_enable_msi(rdev->pdev);
1651 if (!ret) {
1652 rdev->msi_enabled = 1;
1653 diff --git a/drivers/gpu/drm/radeon/radeon_mode.h b/drivers/gpu/drm/radeon/radeon_mode.h
1654 index 68820f5..ed0178f 100644
1655 --- a/drivers/gpu/drm/radeon/radeon_mode.h
1656 +++ b/drivers/gpu/drm/radeon/radeon_mode.h
1657 @@ -447,6 +447,7 @@ struct radeon_connector {
1658 struct edid *edid;
1659 void *con_priv;
1660 bool dac_load_detect;
1661 + bool detected_by_load; /* if the connection status was determined by load */
1662 uint16_t connector_object_id;
1663 struct radeon_hpd hpd;
1664 struct radeon_router router;
1665 diff --git a/drivers/gpu/drm/radeon/rs600.c b/drivers/gpu/drm/radeon/rs600.c
1666 index 1f5850e..aea28c3 100644
1667 --- a/drivers/gpu/drm/radeon/rs600.c
1668 +++ b/drivers/gpu/drm/radeon/rs600.c
1669 @@ -287,6 +287,7 @@ void rs600_hpd_init(struct radeon_device *rdev)
1670 default:
1671 break;
1672 }
1673 + radeon_hpd_set_polarity(rdev, radeon_connector->hpd.hpd);
1674 }
1675 if (rdev->irq.installed)
1676 rs600_irq_set(rdev);
1677 diff --git a/drivers/hid/Kconfig b/drivers/hid/Kconfig
1678 index 36ca465..7e0acf4 100644
1679 --- a/drivers/hid/Kconfig
1680 +++ b/drivers/hid/Kconfig
1681 @@ -69,7 +69,7 @@ config HID_ACRUX
1682 Say Y here if you want to enable support for ACRUX game controllers.
1683
1684 config HID_ACRUX_FF
1685 - tristate "ACRUX force feedback support"
1686 + bool "ACRUX force feedback support"
1687 depends on HID_ACRUX
1688 select INPUT_FF_MEMLESS
1689 ---help---
1690 @@ -314,6 +314,7 @@ config HID_MULTITOUCH
1691 - Hanvon dual touch panels
1692 - Ilitek dual touch panels
1693 - IrTouch Infrared USB panels
1694 + - LG Display panels (Dell ST2220Tc)
1695 - Lumio CrystalTouch panels
1696 - MosArt dual-touch panels
1697 - PenMount dual touch panels
1698 diff --git a/drivers/hid/hid-apple.c b/drivers/hid/hid-apple.c
1699 index b85744f..299d238 100644
1700 --- a/drivers/hid/hid-apple.c
1701 +++ b/drivers/hid/hid-apple.c
1702 @@ -444,11 +444,20 @@ static const struct hid_device_id apple_devices[] = {
1703 { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_GEYSER4_HF_JIS),
1704 .driver_data = APPLE_NUMLOCK_EMULATION | APPLE_HAS_FN |
1705 APPLE_RDESC_JIS },
1706 + { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_ALU_REVB_ANSI),
1707 + .driver_data = APPLE_HAS_FN },
1708 + { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_ALU_REVB_ISO),
1709 + .driver_data = APPLE_HAS_FN | APPLE_ISO_KEYBOARD },
1710 + { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_ALU_REVB_JIS),
1711 + .driver_data = APPLE_HAS_FN },
1712 { HID_BLUETOOTH_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_ALU_WIRELESS_ANSI),
1713 .driver_data = APPLE_NUMLOCK_EMULATION | APPLE_HAS_FN },
1714 { HID_BLUETOOTH_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_ALU_WIRELESS_ISO),
1715 .driver_data = APPLE_NUMLOCK_EMULATION | APPLE_HAS_FN |
1716 APPLE_ISO_KEYBOARD },
1717 + { HID_BLUETOOTH_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_ALU_WIRELESS_2011_ISO),
1718 + .driver_data = APPLE_NUMLOCK_EMULATION | APPLE_HAS_FN |
1719 + APPLE_ISO_KEYBOARD },
1720 { HID_BLUETOOTH_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_ALU_WIRELESS_JIS),
1721 .driver_data = APPLE_NUMLOCK_EMULATION | APPLE_HAS_FN },
1722 { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING_ANSI),
1723 @@ -487,6 +496,24 @@ static const struct hid_device_id apple_devices[] = {
1724 .driver_data = APPLE_HAS_FN | APPLE_ISO_KEYBOARD },
1725 { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING5_JIS),
1726 .driver_data = APPLE_HAS_FN | APPLE_RDESC_JIS },
1727 + { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING6_ANSI),
1728 + .driver_data = APPLE_HAS_FN },
1729 + { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING6_ISO),
1730 + .driver_data = APPLE_HAS_FN | APPLE_ISO_KEYBOARD },
1731 + { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING6_JIS),
1732 + .driver_data = APPLE_HAS_FN | APPLE_RDESC_JIS },
1733 + { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING6A_ANSI),
1734 + .driver_data = APPLE_HAS_FN },
1735 + { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING6A_ISO),
1736 + .driver_data = APPLE_HAS_FN | APPLE_ISO_KEYBOARD },
1737 + { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING6A_JIS),
1738 + .driver_data = APPLE_HAS_FN | APPLE_RDESC_JIS },
1739 + { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING5A_ANSI),
1740 + .driver_data = APPLE_HAS_FN },
1741 + { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING5A_ISO),
1742 + .driver_data = APPLE_HAS_FN | APPLE_ISO_KEYBOARD },
1743 + { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING5A_JIS),
1744 + .driver_data = APPLE_HAS_FN | APPLE_RDESC_JIS },
1745 { HID_BLUETOOTH_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_ALU_WIRELESS_2009_ANSI),
1746 .driver_data = APPLE_NUMLOCK_EMULATION | APPLE_HAS_FN },
1747 { HID_BLUETOOTH_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_ALU_WIRELESS_2009_ISO),
1748 diff --git a/drivers/hid/hid-core.c b/drivers/hid/hid-core.c
1749 index 6f3289a..4f81d20 100644
1750 --- a/drivers/hid/hid-core.c
1751 +++ b/drivers/hid/hid-core.c
1752 @@ -1340,9 +1340,22 @@ static const struct hid_device_id hid_have_special_driver[] = {
1753 { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING5_ANSI) },
1754 { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING5_ISO) },
1755 { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING5_JIS) },
1756 + { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING5A_ANSI) },
1757 + { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING5A_ISO) },
1758 + { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING5A_JIS) },
1759 + { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING6_ANSI) },
1760 + { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING6_ISO) },
1761 + { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING6_JIS) },
1762 + { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING6A_ANSI) },
1763 + { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING6A_ISO) },
1764 + { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING6A_JIS) },
1765 + { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_ALU_REVB_ANSI) },
1766 + { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_ALU_REVB_ISO) },
1767 + { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_ALU_REVB_JIS) },
1768 { HID_BLUETOOTH_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_ALU_WIRELESS_2009_ANSI) },
1769 { HID_BLUETOOTH_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_ALU_WIRELESS_2009_ISO) },
1770 { HID_BLUETOOTH_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_ALU_WIRELESS_2009_JIS) },
1771 + { HID_BLUETOOTH_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_ALU_WIRELESS_2011_ISO) },
1772 { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_FOUNTAIN_TP_ONLY) },
1773 { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_GEYSER1_TP_ONLY) },
1774 { HID_USB_DEVICE(USB_VENDOR_ID_ASUS, USB_DEVICE_ID_ASUS_T91MT) },
1775 @@ -1395,6 +1408,7 @@ static const struct hid_device_id hid_have_special_driver[] = {
1776 { HID_USB_DEVICE(USB_VENDOR_ID_KYE, USB_DEVICE_ID_KYE_ERGO_525V) },
1777 { HID_USB_DEVICE(USB_VENDOR_ID_LABTEC, USB_DEVICE_ID_LABTEC_WIRELESS_KEYBOARD) },
1778 { HID_USB_DEVICE(USB_VENDOR_ID_LCPOWER, USB_DEVICE_ID_LCPOWER_LC1000 ) },
1779 + { HID_USB_DEVICE(USB_VENDOR_ID_LG, USB_DEVICE_ID_LG_MULTITOUCH) },
1780 { HID_USB_DEVICE(USB_VENDOR_ID_LOGITECH, USB_DEVICE_ID_MX3000_RECEIVER) },
1781 { HID_USB_DEVICE(USB_VENDOR_ID_LOGITECH, USB_DEVICE_ID_S510_RECEIVER) },
1782 { HID_USB_DEVICE(USB_VENDOR_ID_LOGITECH, USB_DEVICE_ID_S510_RECEIVER_2) },
1783 @@ -1883,6 +1897,9 @@ static const struct hid_device_id hid_mouse_ignore_list[] = {
1784 { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING5_ANSI) },
1785 { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING5_ISO) },
1786 { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING5_JIS) },
1787 + { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING5A_ANSI) },
1788 + { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING5A_ISO) },
1789 + { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING5A_JIS) },
1790 { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_FOUNTAIN_TP_ONLY) },
1791 { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_GEYSER1_TP_ONLY) },
1792 { }
1793 diff --git a/drivers/hid/hid-ids.h b/drivers/hid/hid-ids.h
1794 index c946d90..c97003c 100644
1795 --- a/drivers/hid/hid-ids.h
1796 +++ b/drivers/hid/hid-ids.h
1797 @@ -109,9 +109,22 @@
1798 #define USB_DEVICE_ID_APPLE_WELLSPRING5_ANSI 0x0245
1799 #define USB_DEVICE_ID_APPLE_WELLSPRING5_ISO 0x0246
1800 #define USB_DEVICE_ID_APPLE_WELLSPRING5_JIS 0x0247
1801 +#define USB_DEVICE_ID_APPLE_WELLSPRING6A_ANSI 0x0249
1802 +#define USB_DEVICE_ID_APPLE_WELLSPRING6A_ISO 0x024a
1803 +#define USB_DEVICE_ID_APPLE_WELLSPRING6A_JIS 0x024b
1804 +#define USB_DEVICE_ID_APPLE_WELLSPRING6_ANSI 0x024c
1805 +#define USB_DEVICE_ID_APPLE_WELLSPRING6_ISO 0x024d
1806 +#define USB_DEVICE_ID_APPLE_WELLSPRING6_JIS 0x024e
1807 +#define USB_DEVICE_ID_APPLE_ALU_REVB_ANSI 0x024f
1808 +#define USB_DEVICE_ID_APPLE_ALU_REVB_ISO 0x0250
1809 +#define USB_DEVICE_ID_APPLE_ALU_REVB_JIS 0x0251
1810 +#define USB_DEVICE_ID_APPLE_WELLSPRING5A_ANSI 0x0252
1811 +#define USB_DEVICE_ID_APPLE_WELLSPRING5A_ISO 0x0253
1812 +#define USB_DEVICE_ID_APPLE_WELLSPRING5A_JIS 0x0254
1813 #define USB_DEVICE_ID_APPLE_ALU_WIRELESS_2009_ANSI 0x0239
1814 #define USB_DEVICE_ID_APPLE_ALU_WIRELESS_2009_ISO 0x023a
1815 #define USB_DEVICE_ID_APPLE_ALU_WIRELESS_2009_JIS 0x023b
1816 +#define USB_DEVICE_ID_APPLE_ALU_WIRELESS_2011_ISO 0x0256
1817 #define USB_DEVICE_ID_APPLE_FOUNTAIN_TP_ONLY 0x030a
1818 #define USB_DEVICE_ID_APPLE_GEYSER1_TP_ONLY 0x030b
1819 #define USB_DEVICE_ID_APPLE_ATV_IRCONTROL 0x8241
1820 @@ -274,6 +287,7 @@
1821 #define USB_DEVICE_ID_PENPOWER 0x00f4
1822
1823 #define USB_VENDOR_ID_GREENASIA 0x0e8f
1824 +#define USB_DEVICE_ID_GREENASIA_DUAL_USB_JOYPAD 0x3013
1825
1826 #define USB_VENDOR_ID_GRETAGMACBETH 0x0971
1827 #define USB_DEVICE_ID_GRETAGMACBETH_HUEY 0x2005
1828 @@ -416,6 +430,9 @@
1829 #define USB_DEVICE_ID_LD_HYBRID 0x2090
1830 #define USB_DEVICE_ID_LD_HEATCONTROL 0x20A0
1831
1832 +#define USB_VENDOR_ID_LG 0x1fd2
1833 +#define USB_DEVICE_ID_LG_MULTITOUCH 0x0064
1834 +
1835 #define USB_VENDOR_ID_LOGITECH 0x046d
1836 #define USB_DEVICE_ID_LOGITECH_RECEIVER 0xc101
1837 #define USB_DEVICE_ID_LOGITECH_HARMONY_FIRST 0xc110
1838 diff --git a/drivers/hid/hid-multitouch.c b/drivers/hid/hid-multitouch.c
1839 index 62cac4d..685d8e4 100644
1840 --- a/drivers/hid/hid-multitouch.c
1841 +++ b/drivers/hid/hid-multitouch.c
1842 @@ -672,6 +672,11 @@ static const struct hid_device_id mt_devices[] = {
1843 HID_USB_DEVICE(USB_VENDOR_ID_IRTOUCHSYSTEMS,
1844 USB_DEVICE_ID_IRTOUCH_INFRARED_USB) },
1845
1846 + /* LG Display panels */
1847 + { .driver_data = MT_CLS_DEFAULT,
1848 + HID_USB_DEVICE(USB_VENDOR_ID_LG,
1849 + USB_DEVICE_ID_LG_MULTITOUCH) },
1850 +
1851 /* Lumio panels */
1852 { .driver_data = MT_CLS_CONFIDENCE_MINUS_ONE,
1853 HID_USB_DEVICE(USB_VENDOR_ID_LUMIO,
1854 diff --git a/drivers/hid/usbhid/hid-quirks.c b/drivers/hid/usbhid/hid-quirks.c
1855 index 4bdb5d4..3146fdc 100644
1856 --- a/drivers/hid/usbhid/hid-quirks.c
1857 +++ b/drivers/hid/usbhid/hid-quirks.c
1858 @@ -47,6 +47,7 @@ static const struct hid_blacklist {
1859 { USB_VENDOR_ID_AFATECH, USB_DEVICE_ID_AFATECH_AF9016, HID_QUIRK_FULLSPEED_INTERVAL },
1860
1861 { USB_VENDOR_ID_ETURBOTOUCH, USB_DEVICE_ID_ETURBOTOUCH, HID_QUIRK_MULTI_INPUT },
1862 + { USB_VENDOR_ID_GREENASIA, USB_DEVICE_ID_GREENASIA_DUAL_USB_JOYPAD, HID_QUIRK_MULTI_INPUT },
1863 { USB_VENDOR_ID_PANTHERLORD, USB_DEVICE_ID_PANTHERLORD_TWIN_USB_JOYSTICK, HID_QUIRK_MULTI_INPUT | HID_QUIRK_SKIP_OUTPUT_REPORTS },
1864 { USB_VENDOR_ID_PLAYDOTCOM, USB_DEVICE_ID_PLAYDOTCOM_EMS_USBII, HID_QUIRK_MULTI_INPUT },
1865 { USB_VENDOR_ID_TOUCHPACK, USB_DEVICE_ID_TOUCHPACK_RTS, HID_QUIRK_MULTI_INPUT },
1866 diff --git a/drivers/hwmon/coretemp.c b/drivers/hwmon/coretemp.c
1867 index 0070d54..f642194 100644
1868 --- a/drivers/hwmon/coretemp.c
1869 +++ b/drivers/hwmon/coretemp.c
1870 @@ -50,14 +50,13 @@
1871 #ifdef CONFIG_SMP
1872 #define TO_PHYS_ID(cpu) cpu_data(cpu).phys_proc_id
1873 #define TO_CORE_ID(cpu) cpu_data(cpu).cpu_core_id
1874 -#define TO_ATTR_NO(cpu) (TO_CORE_ID(cpu) + BASE_SYSFS_ATTR_NO)
1875 #define for_each_sibling(i, cpu) for_each_cpu(i, cpu_sibling_mask(cpu))
1876 #else
1877 #define TO_PHYS_ID(cpu) (cpu)
1878 #define TO_CORE_ID(cpu) (cpu)
1879 -#define TO_ATTR_NO(cpu) (cpu)
1880 #define for_each_sibling(i, cpu) for (i = 0; false; )
1881 #endif
1882 +#define TO_ATTR_NO(cpu) (TO_CORE_ID(cpu) + BASE_SYSFS_ATTR_NO)
1883
1884 /*
1885 * Per-Core Temperature Data
1886 diff --git a/drivers/hwmon/w83627ehf.c b/drivers/hwmon/w83627ehf.c
1887 index 36d7f27..4b2fc50 100644
1888 --- a/drivers/hwmon/w83627ehf.c
1889 +++ b/drivers/hwmon/w83627ehf.c
1890 @@ -1756,7 +1756,17 @@ static inline void __devinit w83627ehf_init_device(struct w83627ehf_data *data,
1891 diode = 0x70;
1892 }
1893 for (i = 0; i < 3; i++) {
1894 - if ((tmp & (0x02 << i)))
1895 + const char *label = NULL;
1896 +
1897 + if (data->temp_label)
1898 + label = data->temp_label[data->temp_src[i]];
1899 +
1900 + /* Digital source overrides analog type */
1901 + if (label && strncmp(label, "PECI", 4) == 0)
1902 + data->temp_type[i] = 6;
1903 + else if (label && strncmp(label, "AMD", 3) == 0)
1904 + data->temp_type[i] = 5;
1905 + else if ((tmp & (0x02 << i)))
1906 data->temp_type[i] = (diode & (0x10 << i)) ? 1 : 3;
1907 else
1908 data->temp_type[i] = 4; /* thermistor */
1909 diff --git a/drivers/hwspinlock/hwspinlock_core.c b/drivers/hwspinlock/hwspinlock_core.c
1910 index 43a6271..12f7c83 100644
1911 --- a/drivers/hwspinlock/hwspinlock_core.c
1912 +++ b/drivers/hwspinlock/hwspinlock_core.c
1913 @@ -26,6 +26,7 @@
1914 #include <linux/radix-tree.h>
1915 #include <linux/hwspinlock.h>
1916 #include <linux/pm_runtime.h>
1917 +#include <linux/mutex.h>
1918
1919 #include "hwspinlock_internal.h"
1920
1921 @@ -52,10 +53,12 @@
1922 static RADIX_TREE(hwspinlock_tree, GFP_KERNEL);
1923
1924 /*
1925 - * Synchronization of access to the tree is achieved using this spinlock,
1926 + * Synchronization of access to the tree is achieved using this mutex,
1927 * as the radix-tree API requires that users provide all synchronisation.
1928 + * A mutex is needed because we're using non-atomic radix tree allocations.
1929 */
1930 -static DEFINE_SPINLOCK(hwspinlock_tree_lock);
1931 +static DEFINE_MUTEX(hwspinlock_tree_lock);
1932 +
1933
1934 /**
1935 * __hwspin_trylock() - attempt to lock a specific hwspinlock
1936 @@ -261,8 +264,7 @@ EXPORT_SYMBOL_GPL(__hwspin_unlock);
1937 * This function should be called from the underlying platform-specific
1938 * implementation, to register a new hwspinlock instance.
1939 *
1940 - * Can be called from an atomic context (will not sleep) but not from
1941 - * within interrupt context.
1942 + * Should be called from a process context (might sleep)
1943 *
1944 * Returns 0 on success, or an appropriate error code on failure
1945 */
1946 @@ -279,7 +281,7 @@ int hwspin_lock_register(struct hwspinlock *hwlock)
1947
1948 spin_lock_init(&hwlock->lock);
1949
1950 - spin_lock(&hwspinlock_tree_lock);
1951 + mutex_lock(&hwspinlock_tree_lock);
1952
1953 ret = radix_tree_insert(&hwspinlock_tree, hwlock->id, hwlock);
1954 if (ret)
1955 @@ -293,7 +295,7 @@ int hwspin_lock_register(struct hwspinlock *hwlock)
1956 WARN_ON(tmp != hwlock);
1957
1958 out:
1959 - spin_unlock(&hwspinlock_tree_lock);
1960 + mutex_unlock(&hwspinlock_tree_lock);
1961 return ret;
1962 }
1963 EXPORT_SYMBOL_GPL(hwspin_lock_register);
1964 @@ -305,8 +307,7 @@ EXPORT_SYMBOL_GPL(hwspin_lock_register);
1965 * This function should be called from the underlying platform-specific
1966 * implementation, to unregister an existing (and unused) hwspinlock.
1967 *
1968 - * Can be called from an atomic context (will not sleep) but not from
1969 - * within interrupt context.
1970 + * Should be called from a process context (might sleep)
1971 *
1972 * Returns the address of hwspinlock @id on success, or NULL on failure
1973 */
1974 @@ -315,7 +316,7 @@ struct hwspinlock *hwspin_lock_unregister(unsigned int id)
1975 struct hwspinlock *hwlock = NULL;
1976 int ret;
1977
1978 - spin_lock(&hwspinlock_tree_lock);
1979 + mutex_lock(&hwspinlock_tree_lock);
1980
1981 /* make sure the hwspinlock is not in use (tag is set) */
1982 ret = radix_tree_tag_get(&hwspinlock_tree, id, HWSPINLOCK_UNUSED);
1983 @@ -331,7 +332,7 @@ struct hwspinlock *hwspin_lock_unregister(unsigned int id)
1984 }
1985
1986 out:
1987 - spin_unlock(&hwspinlock_tree_lock);
1988 + mutex_unlock(&hwspinlock_tree_lock);
1989 return hwlock;
1990 }
1991 EXPORT_SYMBOL_GPL(hwspin_lock_unregister);
1992 @@ -400,9 +401,7 @@ EXPORT_SYMBOL_GPL(hwspin_lock_get_id);
1993 * to the remote core before it can be used for synchronization (to get the
1994 * id of a given hwlock, use hwspin_lock_get_id()).
1995 *
1996 - * Can be called from an atomic context (will not sleep) but not from
1997 - * within interrupt context (simply because there is no use case for
1998 - * that yet).
1999 + * Should be called from a process context (might sleep)
2000 *
2001 * Returns the address of the assigned hwspinlock, or NULL on error
2002 */
2003 @@ -411,7 +410,7 @@ struct hwspinlock *hwspin_lock_request(void)
2004 struct hwspinlock *hwlock;
2005 int ret;
2006
2007 - spin_lock(&hwspinlock_tree_lock);
2008 + mutex_lock(&hwspinlock_tree_lock);
2009
2010 /* look for an unused lock */
2011 ret = radix_tree_gang_lookup_tag(&hwspinlock_tree, (void **)&hwlock,
2012 @@ -431,7 +430,7 @@ struct hwspinlock *hwspin_lock_request(void)
2013 hwlock = NULL;
2014
2015 out:
2016 - spin_unlock(&hwspinlock_tree_lock);
2017 + mutex_unlock(&hwspinlock_tree_lock);
2018 return hwlock;
2019 }
2020 EXPORT_SYMBOL_GPL(hwspin_lock_request);
2021 @@ -445,9 +444,7 @@ EXPORT_SYMBOL_GPL(hwspin_lock_request);
2022 * Usually early board code will be calling this function in order to
2023 * reserve specific hwspinlock ids for predefined purposes.
2024 *
2025 - * Can be called from an atomic context (will not sleep) but not from
2026 - * within interrupt context (simply because there is no use case for
2027 - * that yet).
2028 + * Should be called from a process context (might sleep)
2029 *
2030 * Returns the address of the assigned hwspinlock, or NULL on error
2031 */
2032 @@ -456,7 +453,7 @@ struct hwspinlock *hwspin_lock_request_specific(unsigned int id)
2033 struct hwspinlock *hwlock;
2034 int ret;
2035
2036 - spin_lock(&hwspinlock_tree_lock);
2037 + mutex_lock(&hwspinlock_tree_lock);
2038
2039 /* make sure this hwspinlock exists */
2040 hwlock = radix_tree_lookup(&hwspinlock_tree, id);
2041 @@ -482,7 +479,7 @@ struct hwspinlock *hwspin_lock_request_specific(unsigned int id)
2042 hwlock = NULL;
2043
2044 out:
2045 - spin_unlock(&hwspinlock_tree_lock);
2046 + mutex_unlock(&hwspinlock_tree_lock);
2047 return hwlock;
2048 }
2049 EXPORT_SYMBOL_GPL(hwspin_lock_request_specific);
2050 @@ -495,9 +492,7 @@ EXPORT_SYMBOL_GPL(hwspin_lock_request_specific);
2051 * Should only be called with an @hwlock that was retrieved from
2052 * an earlier call to omap_hwspin_lock_request{_specific}.
2053 *
2054 - * Can be called from an atomic context (will not sleep) but not from
2055 - * within interrupt context (simply because there is no use case for
2056 - * that yet).
2057 + * Should be called from a process context (might sleep)
2058 *
2059 * Returns 0 on success, or an appropriate error code on failure
2060 */
2061 @@ -511,7 +506,7 @@ int hwspin_lock_free(struct hwspinlock *hwlock)
2062 return -EINVAL;
2063 }
2064
2065 - spin_lock(&hwspinlock_tree_lock);
2066 + mutex_lock(&hwspinlock_tree_lock);
2067
2068 /* make sure the hwspinlock is used */
2069 ret = radix_tree_tag_get(&hwspinlock_tree, hwlock->id,
2070 @@ -538,7 +533,7 @@ int hwspin_lock_free(struct hwspinlock *hwlock)
2071 module_put(hwlock->owner);
2072
2073 out:
2074 - spin_unlock(&hwspinlock_tree_lock);
2075 + mutex_unlock(&hwspinlock_tree_lock);
2076 return ret;
2077 }
2078 EXPORT_SYMBOL_GPL(hwspin_lock_free);
2079 diff --git a/drivers/leds/led-class.c b/drivers/leds/led-class.c
2080 index dc3d3d8..661b692 100644
2081 --- a/drivers/leds/led-class.c
2082 +++ b/drivers/leds/led-class.c
2083 @@ -267,9 +267,14 @@ void led_blink_set(struct led_classdev *led_cdev,
2084 unsigned long *delay_on,
2085 unsigned long *delay_off)
2086 {
2087 + del_timer_sync(&led_cdev->blink_timer);
2088 +
2089 if (led_cdev->blink_set &&
2090 - !led_cdev->blink_set(led_cdev, delay_on, delay_off))
2091 + !led_cdev->blink_set(led_cdev, delay_on, delay_off)) {
2092 + led_cdev->blink_delay_on = *delay_on;
2093 + led_cdev->blink_delay_off = *delay_off;
2094 return;
2095 + }
2096
2097 /* blink with 1 Hz as default if nothing specified */
2098 if (!*delay_on && !*delay_off)
2099 diff --git a/drivers/md/raid5.c b/drivers/md/raid5.c
2100 index 2581ba1..e509147 100644
2101 --- a/drivers/md/raid5.c
2102 +++ b/drivers/md/raid5.c
2103 @@ -3369,7 +3369,7 @@ static void handle_stripe6(struct stripe_head *sh)
2104 /* Not in-sync */;
2105 else if (test_bit(In_sync, &rdev->flags))
2106 set_bit(R5_Insync, &dev->flags);
2107 - else {
2108 + else if (!test_bit(Faulty, &rdev->flags)) {
2109 /* in sync if before recovery_offset */
2110 if (sh->sector + STRIPE_SECTORS <= rdev->recovery_offset)
2111 set_bit(R5_Insync, &dev->flags);
2112 diff --git a/drivers/media/dvb/dvb-usb/dib0700_core.c b/drivers/media/dvb/dvb-usb/dib0700_core.c
2113 index 5eb91b4..a224e94 100644
2114 --- a/drivers/media/dvb/dvb-usb/dib0700_core.c
2115 +++ b/drivers/media/dvb/dvb-usb/dib0700_core.c
2116 @@ -30,6 +30,11 @@ int dib0700_get_version(struct dvb_usb_device *d, u32 *hwversion,
2117 struct dib0700_state *st = d->priv;
2118 int ret;
2119
2120 + if (mutex_lock_interruptible(&d->usb_mutex) < 0) {
2121 + deb_info("could not acquire lock");
2122 + return 0;
2123 + }
2124 +
2125 ret = usb_control_msg(d->udev, usb_rcvctrlpipe(d->udev, 0),
2126 REQUEST_GET_VERSION,
2127 USB_TYPE_VENDOR | USB_DIR_IN, 0, 0,
2128 @@ -46,6 +51,7 @@ int dib0700_get_version(struct dvb_usb_device *d, u32 *hwversion,
2129 if (fwtype != NULL)
2130 *fwtype = (st->buf[12] << 24) | (st->buf[13] << 16) |
2131 (st->buf[14] << 8) | st->buf[15];
2132 + mutex_unlock(&d->usb_mutex);
2133 return ret;
2134 }
2135
2136 @@ -108,7 +114,12 @@ int dib0700_ctrl_rd(struct dvb_usb_device *d, u8 *tx, u8 txlen, u8 *rx, u8 rxlen
2137 int dib0700_set_gpio(struct dvb_usb_device *d, enum dib07x0_gpios gpio, u8 gpio_dir, u8 gpio_val)
2138 {
2139 struct dib0700_state *st = d->priv;
2140 - s16 ret;
2141 + int ret;
2142 +
2143 + if (mutex_lock_interruptible(&d->usb_mutex) < 0) {
2144 + deb_info("could not acquire lock");
2145 + return 0;
2146 + }
2147
2148 st->buf[0] = REQUEST_SET_GPIO;
2149 st->buf[1] = gpio;
2150 @@ -116,6 +127,7 @@ int dib0700_set_gpio(struct dvb_usb_device *d, enum dib07x0_gpios gpio, u8 gpio_
2151
2152 ret = dib0700_ctrl_wr(d, st->buf, 3);
2153
2154 + mutex_unlock(&d->usb_mutex);
2155 return ret;
2156 }
2157
2158 @@ -125,6 +137,11 @@ static int dib0700_set_usb_xfer_len(struct dvb_usb_device *d, u16 nb_ts_packets)
2159 int ret;
2160
2161 if (st->fw_version >= 0x10201) {
2162 + if (mutex_lock_interruptible(&d->usb_mutex) < 0) {
2163 + deb_info("could not acquire lock");
2164 + return 0;
2165 + }
2166 +
2167 st->buf[0] = REQUEST_SET_USB_XFER_LEN;
2168 st->buf[1] = (nb_ts_packets >> 8) & 0xff;
2169 st->buf[2] = nb_ts_packets & 0xff;
2170 @@ -132,6 +149,7 @@ static int dib0700_set_usb_xfer_len(struct dvb_usb_device *d, u16 nb_ts_packets)
2171 deb_info("set the USB xfer len to %i Ts packet\n", nb_ts_packets);
2172
2173 ret = dib0700_ctrl_wr(d, st->buf, 3);
2174 + mutex_unlock(&d->usb_mutex);
2175 } else {
2176 deb_info("this firmware does not allow to change the USB xfer len\n");
2177 ret = -EIO;
2178 @@ -208,6 +226,10 @@ static int dib0700_i2c_xfer_new(struct i2c_adapter *adap, struct i2c_msg *msg,
2179
2180 } else {
2181 /* Write request */
2182 + if (mutex_lock_interruptible(&d->usb_mutex) < 0) {
2183 + deb_info("could not acquire lock");
2184 + return 0;
2185 + }
2186 st->buf[0] = REQUEST_NEW_I2C_WRITE;
2187 st->buf[1] = msg[i].addr << 1;
2188 st->buf[2] = (en_start << 7) | (en_stop << 6) |
2189 @@ -227,6 +249,7 @@ static int dib0700_i2c_xfer_new(struct i2c_adapter *adap, struct i2c_msg *msg,
2190 USB_TYPE_VENDOR | USB_DIR_OUT,
2191 0, 0, st->buf, msg[i].len + 4,
2192 USB_CTRL_GET_TIMEOUT);
2193 + mutex_unlock(&d->usb_mutex);
2194 if (result < 0) {
2195 deb_info("i2c write error (status = %d)\n", result);
2196 break;
2197 @@ -249,6 +272,10 @@ static int dib0700_i2c_xfer_legacy(struct i2c_adapter *adap,
2198
2199 if (mutex_lock_interruptible(&d->i2c_mutex) < 0)
2200 return -EAGAIN;
2201 + if (mutex_lock_interruptible(&d->usb_mutex) < 0) {
2202 + deb_info("could not acquire lock");
2203 + return 0;
2204 + }
2205
2206 for (i = 0; i < num; i++) {
2207 /* fill in the address */
2208 @@ -279,6 +306,7 @@ static int dib0700_i2c_xfer_legacy(struct i2c_adapter *adap,
2209 break;
2210 }
2211 }
2212 + mutex_unlock(&d->usb_mutex);
2213 mutex_unlock(&d->i2c_mutex);
2214
2215 return i;
2216 @@ -337,7 +365,12 @@ static int dib0700_set_clock(struct dvb_usb_device *d, u8 en_pll,
2217 u16 pll_loopdiv, u16 free_div, u16 dsuScaler)
2218 {
2219 struct dib0700_state *st = d->priv;
2220 - s16 ret;
2221 + int ret;
2222 +
2223 + if (mutex_lock_interruptible(&d->usb_mutex) < 0) {
2224 + deb_info("could not acquire lock");
2225 + return 0;
2226 + }
2227
2228 st->buf[0] = REQUEST_SET_CLOCK;
2229 st->buf[1] = (en_pll << 7) | (pll_src << 6) |
2230 @@ -352,6 +385,7 @@ static int dib0700_set_clock(struct dvb_usb_device *d, u8 en_pll,
2231 st->buf[9] = dsuScaler & 0xff; /* LSB */
2232
2233 ret = dib0700_ctrl_wr(d, st->buf, 10);
2234 + mutex_unlock(&d->usb_mutex);
2235
2236 return ret;
2237 }
2238 @@ -360,10 +394,16 @@ int dib0700_set_i2c_speed(struct dvb_usb_device *d, u16 scl_kHz)
2239 {
2240 struct dib0700_state *st = d->priv;
2241 u16 divider;
2242 + int ret;
2243
2244 if (scl_kHz == 0)
2245 return -EINVAL;
2246
2247 + if (mutex_lock_interruptible(&d->usb_mutex) < 0) {
2248 + deb_info("could not acquire lock");
2249 + return 0;
2250 + }
2251 +
2252 st->buf[0] = REQUEST_SET_I2C_PARAM;
2253 divider = (u16) (30000 / scl_kHz);
2254 st->buf[1] = 0;
2255 @@ -379,7 +419,11 @@ int dib0700_set_i2c_speed(struct dvb_usb_device *d, u16 scl_kHz)
2256 deb_info("setting I2C speed: %04x %04x %04x (%d kHz).",
2257 (st->buf[2] << 8) | (st->buf[3]), (st->buf[4] << 8) |
2258 st->buf[5], (st->buf[6] << 8) | st->buf[7], scl_kHz);
2259 - return dib0700_ctrl_wr(d, st->buf, 8);
2260 +
2261 + ret = dib0700_ctrl_wr(d, st->buf, 8);
2262 + mutex_unlock(&d->usb_mutex);
2263 +
2264 + return ret;
2265 }
2266
2267
2268 @@ -515,6 +559,11 @@ int dib0700_streaming_ctrl(struct dvb_usb_adapter *adap, int onoff)
2269 }
2270 }
2271
2272 + if (mutex_lock_interruptible(&adap->dev->usb_mutex) < 0) {
2273 + deb_info("could not acquire lock");
2274 + return 0;
2275 + }
2276 +
2277 st->buf[0] = REQUEST_ENABLE_VIDEO;
2278 /* this bit gives a kind of command,
2279 * rather than enabling something or not */
2280 @@ -548,7 +597,10 @@ int dib0700_streaming_ctrl(struct dvb_usb_adapter *adap, int onoff)
2281
2282 deb_info("data for streaming: %x %x\n", st->buf[1], st->buf[2]);
2283
2284 - return dib0700_ctrl_wr(adap->dev, st->buf, 4);
2285 + ret = dib0700_ctrl_wr(adap->dev, st->buf, 4);
2286 + mutex_unlock(&adap->dev->usb_mutex);
2287 +
2288 + return ret;
2289 }
2290
2291 int dib0700_change_protocol(struct rc_dev *rc, u64 rc_type)
2292 @@ -557,6 +609,11 @@ int dib0700_change_protocol(struct rc_dev *rc, u64 rc_type)
2293 struct dib0700_state *st = d->priv;
2294 int new_proto, ret;
2295
2296 + if (mutex_lock_interruptible(&d->usb_mutex) < 0) {
2297 + deb_info("could not acquire lock");
2298 + return 0;
2299 + }
2300 +
2301 st->buf[0] = REQUEST_SET_RC;
2302 st->buf[1] = 0;
2303 st->buf[2] = 0;
2304 @@ -567,23 +624,29 @@ int dib0700_change_protocol(struct rc_dev *rc, u64 rc_type)
2305 else if (rc_type == RC_TYPE_NEC)
2306 new_proto = 0;
2307 else if (rc_type == RC_TYPE_RC6) {
2308 - if (st->fw_version < 0x10200)
2309 - return -EINVAL;
2310 + if (st->fw_version < 0x10200) {
2311 + ret = -EINVAL;
2312 + goto out;
2313 + }
2314
2315 new_proto = 2;
2316 - } else
2317 - return -EINVAL;
2318 + } else {
2319 + ret = -EINVAL;
2320 + goto out;
2321 + }
2322
2323 st->buf[1] = new_proto;
2324
2325 ret = dib0700_ctrl_wr(d, st->buf, 3);
2326 if (ret < 0) {
2327 err("ir protocol setup failed");
2328 - return ret;
2329 + goto out;
2330 }
2331
2332 d->props.rc.core.protocol = rc_type;
2333
2334 +out:
2335 + mutex_unlock(&d->usb_mutex);
2336 return ret;
2337 }
2338
2339 diff --git a/drivers/media/dvb/frontends/dib0070.c b/drivers/media/dvb/frontends/dib0070.c
2340 index 1d47d4d..dc1cb17 100644
2341 --- a/drivers/media/dvb/frontends/dib0070.c
2342 +++ b/drivers/media/dvb/frontends/dib0070.c
2343 @@ -27,6 +27,7 @@
2344 #include <linux/kernel.h>
2345 #include <linux/slab.h>
2346 #include <linux/i2c.h>
2347 +#include <linux/mutex.h>
2348
2349 #include "dvb_frontend.h"
2350
2351 @@ -78,10 +79,18 @@ struct dib0070_state {
2352 struct i2c_msg msg[2];
2353 u8 i2c_write_buffer[3];
2354 u8 i2c_read_buffer[2];
2355 + struct mutex i2c_buffer_lock;
2356 };
2357
2358 -static uint16_t dib0070_read_reg(struct dib0070_state *state, u8 reg)
2359 +static u16 dib0070_read_reg(struct dib0070_state *state, u8 reg)
2360 {
2361 + u16 ret;
2362 +
2363 + if (mutex_lock_interruptible(&state->i2c_buffer_lock) < 0) {
2364 + dprintk("could not acquire lock");
2365 + return 0;
2366 + }
2367 +
2368 state->i2c_write_buffer[0] = reg;
2369
2370 memset(state->msg, 0, 2 * sizeof(struct i2c_msg));
2371 @@ -96,13 +105,23 @@ static uint16_t dib0070_read_reg(struct dib0070_state *state, u8 reg)
2372
2373 if (i2c_transfer(state->i2c, state->msg, 2) != 2) {
2374 printk(KERN_WARNING "DiB0070 I2C read failed\n");
2375 - return 0;
2376 - }
2377 - return (state->i2c_read_buffer[0] << 8) | state->i2c_read_buffer[1];
2378 + ret = 0;
2379 + } else
2380 + ret = (state->i2c_read_buffer[0] << 8)
2381 + | state->i2c_read_buffer[1];
2382 +
2383 + mutex_unlock(&state->i2c_buffer_lock);
2384 + return ret;
2385 }
2386
2387 static int dib0070_write_reg(struct dib0070_state *state, u8 reg, u16 val)
2388 {
2389 + int ret;
2390 +
2391 + if (mutex_lock_interruptible(&state->i2c_buffer_lock) < 0) {
2392 + dprintk("could not acquire lock");
2393 + return -EINVAL;
2394 + }
2395 state->i2c_write_buffer[0] = reg;
2396 state->i2c_write_buffer[1] = val >> 8;
2397 state->i2c_write_buffer[2] = val & 0xff;
2398 @@ -115,9 +134,12 @@ static int dib0070_write_reg(struct dib0070_state *state, u8 reg, u16 val)
2399
2400 if (i2c_transfer(state->i2c, state->msg, 1) != 1) {
2401 printk(KERN_WARNING "DiB0070 I2C write failed\n");
2402 - return -EREMOTEIO;
2403 - }
2404 - return 0;
2405 + ret = -EREMOTEIO;
2406 + } else
2407 + ret = 0;
2408 +
2409 + mutex_unlock(&state->i2c_buffer_lock);
2410 + return ret;
2411 }
2412
2413 #define HARD_RESET(state) do { \
2414 @@ -734,6 +756,7 @@ struct dvb_frontend *dib0070_attach(struct dvb_frontend *fe, struct i2c_adapter
2415 state->cfg = cfg;
2416 state->i2c = i2c;
2417 state->fe = fe;
2418 + mutex_init(&state->i2c_buffer_lock);
2419 fe->tuner_priv = state;
2420
2421 if (dib0070_reset(fe) != 0)
2422 diff --git a/drivers/media/dvb/frontends/dib0090.c b/drivers/media/dvb/frontends/dib0090.c
2423 index c9c935a..b174d1c 100644
2424 --- a/drivers/media/dvb/frontends/dib0090.c
2425 +++ b/drivers/media/dvb/frontends/dib0090.c
2426 @@ -27,6 +27,7 @@
2427 #include <linux/kernel.h>
2428 #include <linux/slab.h>
2429 #include <linux/i2c.h>
2430 +#include <linux/mutex.h>
2431
2432 #include "dvb_frontend.h"
2433
2434 @@ -196,6 +197,7 @@ struct dib0090_state {
2435 struct i2c_msg msg[2];
2436 u8 i2c_write_buffer[3];
2437 u8 i2c_read_buffer[2];
2438 + struct mutex i2c_buffer_lock;
2439 };
2440
2441 struct dib0090_fw_state {
2442 @@ -208,10 +210,18 @@ struct dib0090_fw_state {
2443 struct i2c_msg msg;
2444 u8 i2c_write_buffer[2];
2445 u8 i2c_read_buffer[2];
2446 + struct mutex i2c_buffer_lock;
2447 };
2448
2449 static u16 dib0090_read_reg(struct dib0090_state *state, u8 reg)
2450 {
2451 + u16 ret;
2452 +
2453 + if (mutex_lock_interruptible(&state->i2c_buffer_lock) < 0) {
2454 + dprintk("could not acquire lock");
2455 + return 0;
2456 + }
2457 +
2458 state->i2c_write_buffer[0] = reg;
2459
2460 memset(state->msg, 0, 2 * sizeof(struct i2c_msg));
2461 @@ -226,14 +236,24 @@ static u16 dib0090_read_reg(struct dib0090_state *state, u8 reg)
2462
2463 if (i2c_transfer(state->i2c, state->msg, 2) != 2) {
2464 printk(KERN_WARNING "DiB0090 I2C read failed\n");
2465 - return 0;
2466 - }
2467 + ret = 0;
2468 + } else
2469 + ret = (state->i2c_read_buffer[0] << 8)
2470 + | state->i2c_read_buffer[1];
2471
2472 - return (state->i2c_read_buffer[0] << 8) | state->i2c_read_buffer[1];
2473 + mutex_unlock(&state->i2c_buffer_lock);
2474 + return ret;
2475 }
2476
2477 static int dib0090_write_reg(struct dib0090_state *state, u32 reg, u16 val)
2478 {
2479 + int ret;
2480 +
2481 + if (mutex_lock_interruptible(&state->i2c_buffer_lock) < 0) {
2482 + dprintk("could not acquire lock");
2483 + return -EINVAL;
2484 + }
2485 +
2486 state->i2c_write_buffer[0] = reg & 0xff;
2487 state->i2c_write_buffer[1] = val >> 8;
2488 state->i2c_write_buffer[2] = val & 0xff;
2489 @@ -246,13 +266,23 @@ static int dib0090_write_reg(struct dib0090_state *state, u32 reg, u16 val)
2490
2491 if (i2c_transfer(state->i2c, state->msg, 1) != 1) {
2492 printk(KERN_WARNING "DiB0090 I2C write failed\n");
2493 - return -EREMOTEIO;
2494 - }
2495 - return 0;
2496 + ret = -EREMOTEIO;
2497 + } else
2498 + ret = 0;
2499 +
2500 + mutex_unlock(&state->i2c_buffer_lock);
2501 + return ret;
2502 }
2503
2504 static u16 dib0090_fw_read_reg(struct dib0090_fw_state *state, u8 reg)
2505 {
2506 + u16 ret;
2507 +
2508 + if (mutex_lock_interruptible(&state->i2c_buffer_lock) < 0) {
2509 + dprintk("could not acquire lock");
2510 + return 0;
2511 + }
2512 +
2513 state->i2c_write_buffer[0] = reg;
2514
2515 memset(&state->msg, 0, sizeof(struct i2c_msg));
2516 @@ -262,13 +292,24 @@ static u16 dib0090_fw_read_reg(struct dib0090_fw_state *state, u8 reg)
2517 state->msg.len = 2;
2518 if (i2c_transfer(state->i2c, &state->msg, 1) != 1) {
2519 printk(KERN_WARNING "DiB0090 I2C read failed\n");
2520 - return 0;
2521 - }
2522 - return (state->i2c_read_buffer[0] << 8) | state->i2c_read_buffer[1];
2523 + ret = 0;
2524 + } else
2525 + ret = (state->i2c_read_buffer[0] << 8)
2526 + | state->i2c_read_buffer[1];
2527 +
2528 + mutex_unlock(&state->i2c_buffer_lock);
2529 + return ret;
2530 }
2531
2532 static int dib0090_fw_write_reg(struct dib0090_fw_state *state, u8 reg, u16 val)
2533 {
2534 + int ret;
2535 +
2536 + if (mutex_lock_interruptible(&state->i2c_buffer_lock) < 0) {
2537 + dprintk("could not acquire lock");
2538 + return -EINVAL;
2539 + }
2540 +
2541 state->i2c_write_buffer[0] = val >> 8;
2542 state->i2c_write_buffer[1] = val & 0xff;
2543
2544 @@ -279,9 +320,12 @@ static int dib0090_fw_write_reg(struct dib0090_fw_state *state, u8 reg, u16 val)
2545 state->msg.len = 2;
2546 if (i2c_transfer(state->i2c, &state->msg, 1) != 1) {
2547 printk(KERN_WARNING "DiB0090 I2C write failed\n");
2548 - return -EREMOTEIO;
2549 - }
2550 - return 0;
2551 + ret = -EREMOTEIO;
2552 + } else
2553 + ret = 0;
2554 +
2555 + mutex_unlock(&state->i2c_buffer_lock);
2556 + return ret;
2557 }
2558
2559 #define HARD_RESET(state) do { if (cfg->reset) { if (cfg->sleep) cfg->sleep(fe, 0); msleep(10); cfg->reset(fe, 1); msleep(10); cfg->reset(fe, 0); msleep(10); } } while (0)
2560 @@ -2440,6 +2484,7 @@ struct dvb_frontend *dib0090_register(struct dvb_frontend *fe, struct i2c_adapte
2561 st->config = config;
2562 st->i2c = i2c;
2563 st->fe = fe;
2564 + mutex_init(&st->i2c_buffer_lock);
2565 fe->tuner_priv = st;
2566
2567 if (config->wbd == NULL)
2568 @@ -2471,6 +2516,7 @@ struct dvb_frontend *dib0090_fw_register(struct dvb_frontend *fe, struct i2c_ada
2569 st->config = config;
2570 st->i2c = i2c;
2571 st->fe = fe;
2572 + mutex_init(&st->i2c_buffer_lock);
2573 fe->tuner_priv = st;
2574
2575 if (dib0090_fw_reset_digital(fe, st->config) != 0)
2576 diff --git a/drivers/media/dvb/frontends/dib7000m.c b/drivers/media/dvb/frontends/dib7000m.c
2577 index 79cb1c2..dbb76d7 100644
2578 --- a/drivers/media/dvb/frontends/dib7000m.c
2579 +++ b/drivers/media/dvb/frontends/dib7000m.c
2580 @@ -11,6 +11,7 @@
2581 #include <linux/kernel.h>
2582 #include <linux/slab.h>
2583 #include <linux/i2c.h>
2584 +#include <linux/mutex.h>
2585
2586 #include "dvb_frontend.h"
2587
2588 @@ -55,6 +56,7 @@ struct dib7000m_state {
2589 struct i2c_msg msg[2];
2590 u8 i2c_write_buffer[4];
2591 u8 i2c_read_buffer[2];
2592 + struct mutex i2c_buffer_lock;
2593 };
2594
2595 enum dib7000m_power_mode {
2596 @@ -69,6 +71,13 @@ enum dib7000m_power_mode {
2597
2598 static u16 dib7000m_read_word(struct dib7000m_state *state, u16 reg)
2599 {
2600 + u16 ret;
2601 +
2602 + if (mutex_lock_interruptible(&state->i2c_buffer_lock) < 0) {
2603 + dprintk("could not acquire lock");
2604 + return 0;
2605 + }
2606 +
2607 state->i2c_write_buffer[0] = (reg >> 8) | 0x80;
2608 state->i2c_write_buffer[1] = reg & 0xff;
2609
2610 @@ -85,11 +94,21 @@ static u16 dib7000m_read_word(struct dib7000m_state *state, u16 reg)
2611 if (i2c_transfer(state->i2c_adap, state->msg, 2) != 2)
2612 dprintk("i2c read error on %d",reg);
2613
2614 - return (state->i2c_read_buffer[0] << 8) | state->i2c_read_buffer[1];
2615 + ret = (state->i2c_read_buffer[0] << 8) | state->i2c_read_buffer[1];
2616 + mutex_unlock(&state->i2c_buffer_lock);
2617 +
2618 + return ret;
2619 }
2620
2621 static int dib7000m_write_word(struct dib7000m_state *state, u16 reg, u16 val)
2622 {
2623 + int ret;
2624 +
2625 + if (mutex_lock_interruptible(&state->i2c_buffer_lock) < 0) {
2626 + dprintk("could not acquire lock");
2627 + return -EINVAL;
2628 + }
2629 +
2630 state->i2c_write_buffer[0] = (reg >> 8) & 0xff;
2631 state->i2c_write_buffer[1] = reg & 0xff;
2632 state->i2c_write_buffer[2] = (val >> 8) & 0xff;
2633 @@ -101,7 +120,10 @@ static int dib7000m_write_word(struct dib7000m_state *state, u16 reg, u16 val)
2634 state->msg[0].buf = state->i2c_write_buffer;
2635 state->msg[0].len = 4;
2636
2637 - return i2c_transfer(state->i2c_adap, state->msg, 1) != 1 ? -EREMOTEIO : 0;
2638 + ret = (i2c_transfer(state->i2c_adap, state->msg, 1) != 1 ?
2639 + -EREMOTEIO : 0);
2640 + mutex_unlock(&state->i2c_buffer_lock);
2641 + return ret;
2642 }
2643 static void dib7000m_write_tab(struct dib7000m_state *state, u16 *buf)
2644 {
2645 @@ -1385,6 +1407,7 @@ struct dvb_frontend * dib7000m_attach(struct i2c_adapter *i2c_adap, u8 i2c_addr,
2646 demod = &st->demod;
2647 demod->demodulator_priv = st;
2648 memcpy(&st->demod.ops, &dib7000m_ops, sizeof(struct dvb_frontend_ops));
2649 + mutex_init(&st->i2c_buffer_lock);
2650
2651 st->timf_default = cfg->bw->timf;
2652
2653 diff --git a/drivers/media/dvb/frontends/dib7000p.c b/drivers/media/dvb/frontends/dib7000p.c
2654 index 0c9f40c..292bc19 100644
2655 --- a/drivers/media/dvb/frontends/dib7000p.c
2656 +++ b/drivers/media/dvb/frontends/dib7000p.c
2657 @@ -10,6 +10,7 @@
2658 #include <linux/kernel.h>
2659 #include <linux/slab.h>
2660 #include <linux/i2c.h>
2661 +#include <linux/mutex.h>
2662
2663 #include "dvb_math.h"
2664 #include "dvb_frontend.h"
2665 @@ -68,6 +69,7 @@ struct dib7000p_state {
2666 struct i2c_msg msg[2];
2667 u8 i2c_write_buffer[4];
2668 u8 i2c_read_buffer[2];
2669 + struct mutex i2c_buffer_lock;
2670 };
2671
2672 enum dib7000p_power_mode {
2673 @@ -81,6 +83,13 @@ static int dib7090_set_diversity_in(struct dvb_frontend *fe, int onoff);
2674
2675 static u16 dib7000p_read_word(struct dib7000p_state *state, u16 reg)
2676 {
2677 + u16 ret;
2678 +
2679 + if (mutex_lock_interruptible(&state->i2c_buffer_lock) < 0) {
2680 + dprintk("could not acquire lock");
2681 + return 0;
2682 + }
2683 +
2684 state->i2c_write_buffer[0] = reg >> 8;
2685 state->i2c_write_buffer[1] = reg & 0xff;
2686
2687 @@ -97,11 +106,20 @@ static u16 dib7000p_read_word(struct dib7000p_state *state, u16 reg)
2688 if (i2c_transfer(state->i2c_adap, state->msg, 2) != 2)
2689 dprintk("i2c read error on %d", reg);
2690
2691 - return (state->i2c_read_buffer[0] << 8) | state->i2c_read_buffer[1];
2692 + ret = (state->i2c_read_buffer[0] << 8) | state->i2c_read_buffer[1];
2693 + mutex_unlock(&state->i2c_buffer_lock);
2694 + return ret;
2695 }
2696
2697 static int dib7000p_write_word(struct dib7000p_state *state, u16 reg, u16 val)
2698 {
2699 + int ret;
2700 +
2701 + if (mutex_lock_interruptible(&state->i2c_buffer_lock) < 0) {
2702 + dprintk("could not acquire lock");
2703 + return -EINVAL;
2704 + }
2705 +
2706 state->i2c_write_buffer[0] = (reg >> 8) & 0xff;
2707 state->i2c_write_buffer[1] = reg & 0xff;
2708 state->i2c_write_buffer[2] = (val >> 8) & 0xff;
2709 @@ -113,7 +131,10 @@ static int dib7000p_write_word(struct dib7000p_state *state, u16 reg, u16 val)
2710 state->msg[0].buf = state->i2c_write_buffer;
2711 state->msg[0].len = 4;
2712
2713 - return i2c_transfer(state->i2c_adap, state->msg, 1) != 1 ? -EREMOTEIO : 0;
2714 + ret = (i2c_transfer(state->i2c_adap, state->msg, 1) != 1 ?
2715 + -EREMOTEIO : 0);
2716 + mutex_unlock(&state->i2c_buffer_lock);
2717 + return ret;
2718 }
2719
2720 static void dib7000p_write_tab(struct dib7000p_state *state, u16 * buf)
2721 @@ -1646,6 +1667,7 @@ int dib7000p_i2c_enumeration(struct i2c_adapter *i2c, int no_of_demods, u8 defau
2722 return -ENOMEM;
2723
2724 dpst->i2c_adap = i2c;
2725 + mutex_init(&dpst->i2c_buffer_lock);
2726
2727 for (k = no_of_demods - 1; k >= 0; k--) {
2728 dpst->cfg = cfg[k];
2729 @@ -2324,6 +2346,7 @@ struct dvb_frontend *dib7000p_attach(struct i2c_adapter *i2c_adap, u8 i2c_addr,
2730 demod = &st->demod;
2731 demod->demodulator_priv = st;
2732 memcpy(&st->demod.ops, &dib7000p_ops, sizeof(struct dvb_frontend_ops));
2733 + mutex_init(&st->i2c_buffer_lock);
2734
2735 dib7000p_write_word(st, 1287, 0x0003); /* sram lead in, rdy */
2736
2737 @@ -2333,8 +2356,9 @@ struct dvb_frontend *dib7000p_attach(struct i2c_adapter *i2c_adap, u8 i2c_addr,
2738 st->version = dib7000p_read_word(st, 897);
2739
2740 /* FIXME: make sure the dev.parent field is initialized, or else
2741 - request_firmware() will hit an OOPS (this should be moved somewhere
2742 - more common) */
2743 + request_firmware() will hit an OOPS (this should be moved somewhere
2744 + more common) */
2745 + st->i2c_master.gated_tuner_i2c_adap.dev.parent = i2c_adap->dev.parent;
2746
2747 dibx000_init_i2c_master(&st->i2c_master, DIB7000P, st->i2c_adap, st->i2c_addr);
2748
2749 diff --git a/drivers/media/dvb/frontends/dib8000.c b/drivers/media/dvb/frontends/dib8000.c
2750 index 7d2ea11..fe284d5 100644
2751 --- a/drivers/media/dvb/frontends/dib8000.c
2752 +++ b/drivers/media/dvb/frontends/dib8000.c
2753 @@ -10,6 +10,8 @@
2754 #include <linux/kernel.h>
2755 #include <linux/slab.h>
2756 #include <linux/i2c.h>
2757 +#include <linux/mutex.h>
2758 +
2759 #include "dvb_math.h"
2760
2761 #include "dvb_frontend.h"
2762 @@ -37,6 +39,7 @@ struct i2c_device {
2763 u8 addr;
2764 u8 *i2c_write_buffer;
2765 u8 *i2c_read_buffer;
2766 + struct mutex *i2c_buffer_lock;
2767 };
2768
2769 struct dib8000_state {
2770 @@ -77,6 +80,7 @@ struct dib8000_state {
2771 struct i2c_msg msg[2];
2772 u8 i2c_write_buffer[4];
2773 u8 i2c_read_buffer[2];
2774 + struct mutex i2c_buffer_lock;
2775 };
2776
2777 enum dib8000_power_mode {
2778 @@ -86,24 +90,39 @@ enum dib8000_power_mode {
2779
2780 static u16 dib8000_i2c_read16(struct i2c_device *i2c, u16 reg)
2781 {
2782 + u16 ret;
2783 struct i2c_msg msg[2] = {
2784 - {.addr = i2c->addr >> 1, .flags = 0,
2785 - .buf = i2c->i2c_write_buffer, .len = 2},
2786 - {.addr = i2c->addr >> 1, .flags = I2C_M_RD,
2787 - .buf = i2c->i2c_read_buffer, .len = 2},
2788 + {.addr = i2c->addr >> 1, .flags = 0, .len = 2},
2789 + {.addr = i2c->addr >> 1, .flags = I2C_M_RD, .len = 2},
2790 };
2791
2792 + if (mutex_lock_interruptible(i2c->i2c_buffer_lock) < 0) {
2793 + dprintk("could not acquire lock");
2794 + return 0;
2795 + }
2796 +
2797 + msg[0].buf = i2c->i2c_write_buffer;
2798 msg[0].buf[0] = reg >> 8;
2799 msg[0].buf[1] = reg & 0xff;
2800 + msg[1].buf = i2c->i2c_read_buffer;
2801
2802 if (i2c_transfer(i2c->adap, msg, 2) != 2)
2803 dprintk("i2c read error on %d", reg);
2804
2805 - return (msg[1].buf[0] << 8) | msg[1].buf[1];
2806 + ret = (msg[1].buf[0] << 8) | msg[1].buf[1];
2807 + mutex_unlock(i2c->i2c_buffer_lock);
2808 + return ret;
2809 }
2810
2811 static u16 dib8000_read_word(struct dib8000_state *state, u16 reg)
2812 {
2813 + u16 ret;
2814 +
2815 + if (mutex_lock_interruptible(&state->i2c_buffer_lock) < 0) {
2816 + dprintk("could not acquire lock");
2817 + return 0;
2818 + }
2819 +
2820 state->i2c_write_buffer[0] = reg >> 8;
2821 state->i2c_write_buffer[1] = reg & 0xff;
2822
2823 @@ -120,7 +139,10 @@ static u16 dib8000_read_word(struct dib8000_state *state, u16 reg)
2824 if (i2c_transfer(state->i2c.adap, state->msg, 2) != 2)
2825 dprintk("i2c read error on %d", reg);
2826
2827 - return (state->i2c_read_buffer[0] << 8) | state->i2c_read_buffer[1];
2828 + ret = (state->i2c_read_buffer[0] << 8) | state->i2c_read_buffer[1];
2829 + mutex_unlock(&state->i2c_buffer_lock);
2830 +
2831 + return ret;
2832 }
2833
2834 static u32 dib8000_read32(struct dib8000_state *state, u16 reg)
2835 @@ -135,22 +157,35 @@ static u32 dib8000_read32(struct dib8000_state *state, u16 reg)
2836
2837 static int dib8000_i2c_write16(struct i2c_device *i2c, u16 reg, u16 val)
2838 {
2839 - struct i2c_msg msg = {.addr = i2c->addr >> 1, .flags = 0,
2840 - .buf = i2c->i2c_write_buffer, .len = 4};
2841 + struct i2c_msg msg = {.addr = i2c->addr >> 1, .flags = 0, .len = 4};
2842 int ret = 0;
2843
2844 + if (mutex_lock_interruptible(i2c->i2c_buffer_lock) < 0) {
2845 + dprintk("could not acquire lock");
2846 + return -EINVAL;
2847 + }
2848 +
2849 + msg.buf = i2c->i2c_write_buffer;
2850 msg.buf[0] = (reg >> 8) & 0xff;
2851 msg.buf[1] = reg & 0xff;
2852 msg.buf[2] = (val >> 8) & 0xff;
2853 msg.buf[3] = val & 0xff;
2854
2855 ret = i2c_transfer(i2c->adap, &msg, 1) != 1 ? -EREMOTEIO : 0;
2856 + mutex_unlock(i2c->i2c_buffer_lock);
2857
2858 return ret;
2859 }
2860
2861 static int dib8000_write_word(struct dib8000_state *state, u16 reg, u16 val)
2862 {
2863 + int ret;
2864 +
2865 + if (mutex_lock_interruptible(&state->i2c_buffer_lock) < 0) {
2866 + dprintk("could not acquire lock");
2867 + return -EINVAL;
2868 + }
2869 +
2870 state->i2c_write_buffer[0] = (reg >> 8) & 0xff;
2871 state->i2c_write_buffer[1] = reg & 0xff;
2872 state->i2c_write_buffer[2] = (val >> 8) & 0xff;
2873 @@ -162,7 +197,11 @@ static int dib8000_write_word(struct dib8000_state *state, u16 reg, u16 val)
2874 state->msg[0].buf = state->i2c_write_buffer;
2875 state->msg[0].len = 4;
2876
2877 - return i2c_transfer(state->i2c.adap, state->msg, 1) != 1 ? -EREMOTEIO : 0;
2878 + ret = (i2c_transfer(state->i2c.adap, state->msg, 1) != 1 ?
2879 + -EREMOTEIO : 0);
2880 + mutex_unlock(&state->i2c_buffer_lock);
2881 +
2882 + return ret;
2883 }
2884
2885 static const s16 coeff_2k_sb_1seg_dqpsk[8] = {
2886 @@ -2434,8 +2473,15 @@ int dib8000_i2c_enumeration(struct i2c_adapter *host, int no_of_demods, u8 defau
2887 if (!client.i2c_read_buffer) {
2888 dprintk("%s: not enough memory", __func__);
2889 ret = -ENOMEM;
2890 - goto error_memory;
2891 + goto error_memory_read;
2892 + }
2893 + client.i2c_buffer_lock = kzalloc(sizeof(struct mutex), GFP_KERNEL);
2894 + if (!client.i2c_buffer_lock) {
2895 + dprintk("%s: not enough memory", __func__);
2896 + ret = -ENOMEM;
2897 + goto error_memory_lock;
2898 }
2899 + mutex_init(client.i2c_buffer_lock);
2900
2901 for (k = no_of_demods - 1; k >= 0; k--) {
2902 /* designated i2c address */
2903 @@ -2476,8 +2522,10 @@ int dib8000_i2c_enumeration(struct i2c_adapter *host, int no_of_demods, u8 defau
2904 }
2905
2906 error:
2907 + kfree(client.i2c_buffer_lock);
2908 +error_memory_lock:
2909 kfree(client.i2c_read_buffer);
2910 -error_memory:
2911 +error_memory_read:
2912 kfree(client.i2c_write_buffer);
2913
2914 return ret;
2915 @@ -2581,6 +2629,8 @@ struct dvb_frontend *dib8000_attach(struct i2c_adapter *i2c_adap, u8 i2c_addr, s
2916 state->i2c.addr = i2c_addr;
2917 state->i2c.i2c_write_buffer = state->i2c_write_buffer;
2918 state->i2c.i2c_read_buffer = state->i2c_read_buffer;
2919 + mutex_init(&state->i2c_buffer_lock);
2920 + state->i2c.i2c_buffer_lock = &state->i2c_buffer_lock;
2921 state->gpio_val = cfg->gpio_val;
2922 state->gpio_dir = cfg->gpio_dir;
2923
2924 diff --git a/drivers/media/dvb/frontends/dib9000.c b/drivers/media/dvb/frontends/dib9000.c
2925 index a085588..b931074 100644
2926 --- a/drivers/media/dvb/frontends/dib9000.c
2927 +++ b/drivers/media/dvb/frontends/dib9000.c
2928 @@ -38,6 +38,15 @@ struct i2c_device {
2929 #define DibInitLock(lock) mutex_init(lock)
2930 #define DibFreeLock(lock)
2931
2932 +struct dib9000_pid_ctrl {
2933 +#define DIB9000_PID_FILTER_CTRL 0
2934 +#define DIB9000_PID_FILTER 1
2935 + u8 cmd;
2936 + u8 id;
2937 + u16 pid;
2938 + u8 onoff;
2939 +};
2940 +
2941 struct dib9000_state {
2942 struct i2c_device i2c;
2943
2944 @@ -99,6 +108,10 @@ struct dib9000_state {
2945 struct i2c_msg msg[2];
2946 u8 i2c_write_buffer[255];
2947 u8 i2c_read_buffer[255];
2948 + DIB_LOCK demod_lock;
2949 + u8 get_frontend_internal;
2950 + struct dib9000_pid_ctrl pid_ctrl[10];
2951 + s8 pid_ctrl_index; /* -1: empty list; -2: do not use the list */
2952 };
2953
2954 static const u32 fe_info[44] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
2955 @@ -1743,19 +1756,56 @@ EXPORT_SYMBOL(dib9000_set_gpio);
2956 int dib9000_fw_pid_filter_ctrl(struct dvb_frontend *fe, u8 onoff)
2957 {
2958 struct dib9000_state *state = fe->demodulator_priv;
2959 - u16 val = dib9000_read_word(state, 294 + 1) & 0xffef;
2960 + u16 val;
2961 + int ret;
2962 +
2963 + if ((state->pid_ctrl_index != -2) && (state->pid_ctrl_index < 9)) {
2964 + /* postpone the pid filtering cmd */
2965 + dprintk("pid filter cmd postpone");
2966 + state->pid_ctrl_index++;
2967 + state->pid_ctrl[state->pid_ctrl_index].cmd = DIB9000_PID_FILTER_CTRL;
2968 + state->pid_ctrl[state->pid_ctrl_index].onoff = onoff;
2969 + return 0;
2970 + }
2971 +
2972 + DibAcquireLock(&state->demod_lock);
2973 +
2974 + val = dib9000_read_word(state, 294 + 1) & 0xffef;
2975 val |= (onoff & 0x1) << 4;
2976
2977 dprintk("PID filter enabled %d", onoff);
2978 - return dib9000_write_word(state, 294 + 1, val);
2979 + ret = dib9000_write_word(state, 294 + 1, val);
2980 + DibReleaseLock(&state->demod_lock);
2981 + return ret;
2982 +
2983 }
2984 EXPORT_SYMBOL(dib9000_fw_pid_filter_ctrl);
2985
2986 int dib9000_fw_pid_filter(struct dvb_frontend *fe, u8 id, u16 pid, u8 onoff)
2987 {
2988 struct dib9000_state *state = fe->demodulator_priv;
2989 + int ret;
2990 +
2991 + if (state->pid_ctrl_index != -2) {
2992 + /* postpone the pid filtering cmd */
2993 + dprintk("pid filter postpone");
2994 + if (state->pid_ctrl_index < 9) {
2995 + state->pid_ctrl_index++;
2996 + state->pid_ctrl[state->pid_ctrl_index].cmd = DIB9000_PID_FILTER;
2997 + state->pid_ctrl[state->pid_ctrl_index].id = id;
2998 + state->pid_ctrl[state->pid_ctrl_index].pid = pid;
2999 + state->pid_ctrl[state->pid_ctrl_index].onoff = onoff;
3000 + } else
3001 + dprintk("can not add any more pid ctrl cmd");
3002 + return 0;
3003 + }
3004 +
3005 + DibAcquireLock(&state->demod_lock);
3006 dprintk("Index %x, PID %d, OnOff %d", id, pid, onoff);
3007 - return dib9000_write_word(state, 300 + 1 + id, onoff ? (1 << 13) | pid : 0);
3008 + ret = dib9000_write_word(state, 300 + 1 + id,
3009 + onoff ? (1 << 13) | pid : 0);
3010 + DibReleaseLock(&state->demod_lock);
3011 + return ret;
3012 }
3013 EXPORT_SYMBOL(dib9000_fw_pid_filter);
3014
3015 @@ -1778,6 +1828,7 @@ static void dib9000_release(struct dvb_frontend *demod)
3016 DibFreeLock(&state->platform.risc.mbx_lock);
3017 DibFreeLock(&state->platform.risc.mem_lock);
3018 DibFreeLock(&state->platform.risc.mem_mbx_lock);
3019 + DibFreeLock(&state->demod_lock);
3020 dibx000_exit_i2c_master(&st->i2c_master);
3021
3022 i2c_del_adapter(&st->tuner_adap);
3023 @@ -1795,14 +1846,19 @@ static int dib9000_sleep(struct dvb_frontend *fe)
3024 {
3025 struct dib9000_state *state = fe->demodulator_priv;
3026 u8 index_frontend;
3027 - int ret;
3028 + int ret = 0;
3029
3030 + DibAcquireLock(&state->demod_lock);
3031 for (index_frontend = 1; (index_frontend < MAX_NUMBER_OF_FRONTENDS) && (state->fe[index_frontend] != NULL); index_frontend++) {
3032 ret = state->fe[index_frontend]->ops.sleep(state->fe[index_frontend]);
3033 if (ret < 0)
3034 - return ret;
3035 + goto error;
3036 }
3037 - return dib9000_mbx_send(state, OUT_MSG_FE_SLEEP, NULL, 0);
3038 + ret = dib9000_mbx_send(state, OUT_MSG_FE_SLEEP, NULL, 0);
3039 +
3040 +error:
3041 + DibReleaseLock(&state->demod_lock);
3042 + return ret;
3043 }
3044
3045 static int dib9000_fe_get_tune_settings(struct dvb_frontend *fe, struct dvb_frontend_tune_settings *tune)
3046 @@ -1816,7 +1872,10 @@ static int dib9000_get_frontend(struct dvb_frontend *fe, struct dvb_frontend_par
3047 struct dib9000_state *state = fe->demodulator_priv;
3048 u8 index_frontend, sub_index_frontend;
3049 fe_status_t stat;
3050 - int ret;
3051 + int ret = 0;
3052 +
3053 + if (state->get_frontend_internal == 0)
3054 + DibAcquireLock(&state->demod_lock);
3055
3056 for (index_frontend = 1; (index_frontend < MAX_NUMBER_OF_FRONTENDS) && (state->fe[index_frontend] != NULL); index_frontend++) {
3057 state->fe[index_frontend]->ops.read_status(state->fe[index_frontend], &stat);
3058 @@ -1846,14 +1905,15 @@ static int dib9000_get_frontend(struct dvb_frontend *fe, struct dvb_frontend_par
3059 state->fe[index_frontend]->dtv_property_cache.rolloff;
3060 }
3061 }
3062 - return 0;
3063 + ret = 0;
3064 + goto return_value;
3065 }
3066 }
3067
3068 /* get the channel from master chip */
3069 ret = dib9000_fw_get_channel(fe, fep);
3070 if (ret != 0)
3071 - return ret;
3072 + goto return_value;
3073
3074 /* synchronize the cache with the other frontends */
3075 for (index_frontend = 1; (index_frontend < MAX_NUMBER_OF_FRONTENDS) && (state->fe[index_frontend] != NULL); index_frontend++) {
3076 @@ -1866,8 +1926,12 @@ static int dib9000_get_frontend(struct dvb_frontend *fe, struct dvb_frontend_par
3077 state->fe[index_frontend]->dtv_property_cache.code_rate_LP = fe->dtv_property_cache.code_rate_LP;
3078 state->fe[index_frontend]->dtv_property_cache.rolloff = fe->dtv_property_cache.rolloff;
3079 }
3080 + ret = 0;
3081
3082 - return 0;
3083 +return_value:
3084 + if (state->get_frontend_internal == 0)
3085 + DibReleaseLock(&state->demod_lock);
3086 + return ret;
3087 }
3088
3089 static int dib9000_set_tune_state(struct dvb_frontend *fe, enum frontend_tune_state tune_state)
3090 @@ -1912,6 +1976,10 @@ static int dib9000_set_frontend(struct dvb_frontend *fe, struct dvb_frontend_par
3091 dprintk("dib9000: must specify bandwidth ");
3092 return 0;
3093 }
3094 +
3095 + state->pid_ctrl_index = -1; /* postpone the pid filtering cmd */
3096 + DibAcquireLock(&state->demod_lock);
3097 +
3098 fe->dtv_property_cache.delivery_system = SYS_DVBT;
3099
3100 /* set the master status */
3101 @@ -1974,13 +2042,18 @@ static int dib9000_set_frontend(struct dvb_frontend *fe, struct dvb_frontend_par
3102 /* check the tune result */
3103 if (exit_condition == 1) { /* tune failed */
3104 dprintk("tune failed");
3105 + DibReleaseLock(&state->demod_lock);
3106 + /* tune failed; put all the pid filtering cmd to junk */
3107 + state->pid_ctrl_index = -1;
3108 return 0;
3109 }
3110
3111 dprintk("tune success on frontend%i", index_frontend_success);
3112
3113 /* synchronize all the channel cache */
3114 + state->get_frontend_internal = 1;
3115 dib9000_get_frontend(state->fe[0], fep);
3116 + state->get_frontend_internal = 0;
3117
3118 /* retune the other frontends with the found channel */
3119 channel_status.status = CHANNEL_STATUS_PARAMETERS_SET;
3120 @@ -2025,6 +2098,28 @@ static int dib9000_set_frontend(struct dvb_frontend *fe, struct dvb_frontend_par
3121 /* turn off the diversity for the last frontend */
3122 dib9000_fw_set_diversity_in(state->fe[index_frontend - 1], 0);
3123
3124 + DibReleaseLock(&state->demod_lock);
3125 + if (state->pid_ctrl_index >= 0) {
3126 + u8 index_pid_filter_cmd;
3127 + u8 pid_ctrl_index = state->pid_ctrl_index;
3128 +
3129 + state->pid_ctrl_index = -2;
3130 + for (index_pid_filter_cmd = 0;
3131 + index_pid_filter_cmd <= pid_ctrl_index;
3132 + index_pid_filter_cmd++) {
3133 + if (state->pid_ctrl[index_pid_filter_cmd].cmd == DIB9000_PID_FILTER_CTRL)
3134 + dib9000_fw_pid_filter_ctrl(state->fe[0],
3135 + state->pid_ctrl[index_pid_filter_cmd].onoff);
3136 + else if (state->pid_ctrl[index_pid_filter_cmd].cmd == DIB9000_PID_FILTER)
3137 + dib9000_fw_pid_filter(state->fe[0],
3138 + state->pid_ctrl[index_pid_filter_cmd].id,
3139 + state->pid_ctrl[index_pid_filter_cmd].pid,
3140 + state->pid_ctrl[index_pid_filter_cmd].onoff);
3141 + }
3142 + }
3143 + /* do not postpone any more the pid filtering */
3144 + state->pid_ctrl_index = -2;
3145 +
3146 return 0;
3147 }
3148
3149 @@ -2041,6 +2136,7 @@ static int dib9000_read_status(struct dvb_frontend *fe, fe_status_t * stat)
3150 u8 index_frontend;
3151 u16 lock = 0, lock_slave = 0;
3152
3153 + DibAcquireLock(&state->demod_lock);
3154 for (index_frontend = 1; (index_frontend < MAX_NUMBER_OF_FRONTENDS) && (state->fe[index_frontend] != NULL); index_frontend++)
3155 lock_slave |= dib9000_read_lock(state->fe[index_frontend]);
3156
3157 @@ -2059,6 +2155,8 @@ static int dib9000_read_status(struct dvb_frontend *fe, fe_status_t * stat)
3158 if ((lock & 0x0008) || (lock_slave & 0x0008))
3159 *stat |= FE_HAS_LOCK;
3160
3161 + DibReleaseLock(&state->demod_lock);
3162 +
3163 return 0;
3164 }
3165
3166 @@ -2066,10 +2164,14 @@ static int dib9000_read_ber(struct dvb_frontend *fe, u32 * ber)
3167 {
3168 struct dib9000_state *state = fe->demodulator_priv;
3169 u16 *c;
3170 + int ret = 0;
3171
3172 + DibAcquireLock(&state->demod_lock);
3173 DibAcquireLock(&state->platform.risc.mem_mbx_lock);
3174 - if (dib9000_fw_memmbx_sync(state, FE_SYNC_CHANNEL) < 0)
3175 - return -EIO;
3176 + if (dib9000_fw_memmbx_sync(state, FE_SYNC_CHANNEL) < 0) {
3177 + ret = -EIO;
3178 + goto error;
3179 + }
3180 dib9000_risc_mem_read(state, FE_MM_R_FE_MONITOR,
3181 state->i2c_read_buffer, 16 * 2);
3182 DibReleaseLock(&state->platform.risc.mem_mbx_lock);
3183 @@ -2077,7 +2179,10 @@ static int dib9000_read_ber(struct dvb_frontend *fe, u32 * ber)
3184 c = (u16 *)state->i2c_read_buffer;
3185
3186 *ber = c[10] << 16 | c[11];
3187 - return 0;
3188 +
3189 +error:
3190 + DibReleaseLock(&state->demod_lock);
3191 + return ret;
3192 }
3193
3194 static int dib9000_read_signal_strength(struct dvb_frontend *fe, u16 * strength)
3195 @@ -2086,7 +2191,9 @@ static int dib9000_read_signal_strength(struct dvb_frontend *fe, u16 * strength)
3196 u8 index_frontend;
3197 u16 *c = (u16 *)state->i2c_read_buffer;
3198 u16 val;
3199 + int ret = 0;
3200
3201 + DibAcquireLock(&state->demod_lock);
3202 *strength = 0;
3203 for (index_frontend = 1; (index_frontend < MAX_NUMBER_OF_FRONTENDS) && (state->fe[index_frontend] != NULL); index_frontend++) {
3204 state->fe[index_frontend]->ops.read_signal_strength(state->fe[index_frontend], &val);
3205 @@ -2097,8 +2204,10 @@ static int dib9000_read_signal_strength(struct dvb_frontend *fe, u16 * strength)
3206 }
3207
3208 DibAcquireLock(&state->platform.risc.mem_mbx_lock);
3209 - if (dib9000_fw_memmbx_sync(state, FE_SYNC_CHANNEL) < 0)
3210 - return -EIO;
3211 + if (dib9000_fw_memmbx_sync(state, FE_SYNC_CHANNEL) < 0) {
3212 + ret = -EIO;
3213 + goto error;
3214 + }
3215 dib9000_risc_mem_read(state, FE_MM_R_FE_MONITOR, (u8 *) c, 16 * 2);
3216 DibReleaseLock(&state->platform.risc.mem_mbx_lock);
3217
3218 @@ -2107,7 +2216,10 @@ static int dib9000_read_signal_strength(struct dvb_frontend *fe, u16 * strength)
3219 *strength = 65535;
3220 else
3221 *strength += val;
3222 - return 0;
3223 +
3224 +error:
3225 + DibReleaseLock(&state->demod_lock);
3226 + return ret;
3227 }
3228
3229 static u32 dib9000_get_snr(struct dvb_frontend *fe)
3230 @@ -2151,6 +2263,7 @@ static int dib9000_read_snr(struct dvb_frontend *fe, u16 * snr)
3231 u8 index_frontend;
3232 u32 snr_master;
3233
3234 + DibAcquireLock(&state->demod_lock);
3235 snr_master = dib9000_get_snr(fe);
3236 for (index_frontend = 1; (index_frontend < MAX_NUMBER_OF_FRONTENDS) && (state->fe[index_frontend] != NULL); index_frontend++)
3237 snr_master += dib9000_get_snr(state->fe[index_frontend]);
3238 @@ -2161,6 +2274,8 @@ static int dib9000_read_snr(struct dvb_frontend *fe, u16 * snr)
3239 } else
3240 *snr = 0;
3241
3242 + DibReleaseLock(&state->demod_lock);
3243 +
3244 return 0;
3245 }
3246
3247 @@ -2168,15 +2283,22 @@ static int dib9000_read_unc_blocks(struct dvb_frontend *fe, u32 * unc)
3248 {
3249 struct dib9000_state *state = fe->demodulator_priv;
3250 u16 *c = (u16 *)state->i2c_read_buffer;
3251 + int ret = 0;
3252
3253 + DibAcquireLock(&state->demod_lock);
3254 DibAcquireLock(&state->platform.risc.mem_mbx_lock);
3255 - if (dib9000_fw_memmbx_sync(state, FE_SYNC_CHANNEL) < 0)
3256 - return -EIO;
3257 + if (dib9000_fw_memmbx_sync(state, FE_SYNC_CHANNEL) < 0) {
3258 + ret = -EIO;
3259 + goto error;
3260 + }
3261 dib9000_risc_mem_read(state, FE_MM_R_FE_MONITOR, (u8 *) c, 16 * 2);
3262 DibReleaseLock(&state->platform.risc.mem_mbx_lock);
3263
3264 *unc = c[12];
3265 - return 0;
3266 +
3267 +error:
3268 + DibReleaseLock(&state->demod_lock);
3269 + return ret;
3270 }
3271
3272 int dib9000_i2c_enumeration(struct i2c_adapter *i2c, int no_of_demods, u8 default_addr, u8 first_addr)
3273 @@ -2322,6 +2444,10 @@ struct dvb_frontend *dib9000_attach(struct i2c_adapter *i2c_adap, u8 i2c_addr, c
3274 DibInitLock(&st->platform.risc.mbx_lock);
3275 DibInitLock(&st->platform.risc.mem_lock);
3276 DibInitLock(&st->platform.risc.mem_mbx_lock);
3277 + DibInitLock(&st->demod_lock);
3278 + st->get_frontend_internal = 0;
3279 +
3280 + st->pid_ctrl_index = -2;
3281
3282 st->fe[0] = fe;
3283 fe->demodulator_priv = st;
3284 diff --git a/drivers/media/dvb/frontends/dibx000_common.c b/drivers/media/dvb/frontends/dibx000_common.c
3285 index dc5d17a..774d507 100644
3286 --- a/drivers/media/dvb/frontends/dibx000_common.c
3287 +++ b/drivers/media/dvb/frontends/dibx000_common.c
3288 @@ -1,4 +1,5 @@
3289 #include <linux/i2c.h>
3290 +#include <linux/mutex.h>
3291
3292 #include "dibx000_common.h"
3293
3294 @@ -10,6 +11,13 @@ MODULE_PARM_DESC(debug, "turn on debugging (default: 0)");
3295
3296 static int dibx000_write_word(struct dibx000_i2c_master *mst, u16 reg, u16 val)
3297 {
3298 + int ret;
3299 +
3300 + if (mutex_lock_interruptible(&mst->i2c_buffer_lock) < 0) {
3301 + dprintk("could not acquire lock");
3302 + return -EINVAL;
3303 + }
3304 +
3305 mst->i2c_write_buffer[0] = (reg >> 8) & 0xff;
3306 mst->i2c_write_buffer[1] = reg & 0xff;
3307 mst->i2c_write_buffer[2] = (val >> 8) & 0xff;
3308 @@ -21,11 +29,21 @@ static int dibx000_write_word(struct dibx000_i2c_master *mst, u16 reg, u16 val)
3309 mst->msg[0].buf = mst->i2c_write_buffer;
3310 mst->msg[0].len = 4;
3311
3312 - return i2c_transfer(mst->i2c_adap, mst->msg, 1) != 1 ? -EREMOTEIO : 0;
3313 + ret = i2c_transfer(mst->i2c_adap, mst->msg, 1) != 1 ? -EREMOTEIO : 0;
3314 + mutex_unlock(&mst->i2c_buffer_lock);
3315 +
3316 + return ret;
3317 }
3318
3319 static u16 dibx000_read_word(struct dibx000_i2c_master *mst, u16 reg)
3320 {
3321 + u16 ret;
3322 +
3323 + if (mutex_lock_interruptible(&mst->i2c_buffer_lock) < 0) {
3324 + dprintk("could not acquire lock");
3325 + return 0;
3326 + }
3327 +
3328 mst->i2c_write_buffer[0] = reg >> 8;
3329 mst->i2c_write_buffer[1] = reg & 0xff;
3330
3331 @@ -42,7 +60,10 @@ static u16 dibx000_read_word(struct dibx000_i2c_master *mst, u16 reg)
3332 if (i2c_transfer(mst->i2c_adap, mst->msg, 2) != 2)
3333 dprintk("i2c read error on %d", reg);
3334
3335 - return (mst->i2c_read_buffer[0] << 8) | mst->i2c_read_buffer[1];
3336 + ret = (mst->i2c_read_buffer[0] << 8) | mst->i2c_read_buffer[1];
3337 + mutex_unlock(&mst->i2c_buffer_lock);
3338 +
3339 + return ret;
3340 }
3341
3342 static int dibx000_is_i2c_done(struct dibx000_i2c_master *mst)
3343 @@ -257,6 +278,7 @@ static int dibx000_i2c_gated_gpio67_xfer(struct i2c_adapter *i2c_adap,
3344 struct i2c_msg msg[], int num)
3345 {
3346 struct dibx000_i2c_master *mst = i2c_get_adapdata(i2c_adap);
3347 + int ret;
3348
3349 if (num > 32) {
3350 dprintk("%s: too much I2C message to be transmitted (%i).\
3351 @@ -264,10 +286,15 @@ static int dibx000_i2c_gated_gpio67_xfer(struct i2c_adapter *i2c_adap,
3352 return -ENOMEM;
3353 }
3354
3355 - memset(mst->msg, 0, sizeof(struct i2c_msg) * (2 + num));
3356 -
3357 dibx000_i2c_select_interface(mst, DIBX000_I2C_INTERFACE_GPIO_6_7);
3358
3359 + if (mutex_lock_interruptible(&mst->i2c_buffer_lock) < 0) {
3360 + dprintk("could not acquire lock");
3361 + return -EINVAL;
3362 + }
3363 +
3364 + memset(mst->msg, 0, sizeof(struct i2c_msg) * (2 + num));
3365 +
3366 /* open the gate */
3367 dibx000_i2c_gate_ctrl(mst, &mst->i2c_write_buffer[0], msg[0].addr, 1);
3368 mst->msg[0].addr = mst->i2c_addr;
3369 @@ -282,7 +309,11 @@ static int dibx000_i2c_gated_gpio67_xfer(struct i2c_adapter *i2c_adap,
3370 mst->msg[num + 1].buf = &mst->i2c_write_buffer[4];
3371 mst->msg[num + 1].len = 4;
3372
3373 - return i2c_transfer(mst->i2c_adap, mst->msg, 2 + num) == 2 + num ? num : -EIO;
3374 + ret = (i2c_transfer(mst->i2c_adap, mst->msg, 2 + num) == 2 + num ?
3375 + num : -EIO);
3376 +
3377 + mutex_unlock(&mst->i2c_buffer_lock);
3378 + return ret;
3379 }
3380
3381 static struct i2c_algorithm dibx000_i2c_gated_gpio67_algo = {
3382 @@ -294,6 +325,7 @@ static int dibx000_i2c_gated_tuner_xfer(struct i2c_adapter *i2c_adap,
3383 struct i2c_msg msg[], int num)
3384 {
3385 struct dibx000_i2c_master *mst = i2c_get_adapdata(i2c_adap);
3386 + int ret;
3387
3388 if (num > 32) {
3389 dprintk("%s: too much I2C message to be transmitted (%i).\
3390 @@ -301,10 +333,14 @@ static int dibx000_i2c_gated_tuner_xfer(struct i2c_adapter *i2c_adap,
3391 return -ENOMEM;
3392 }
3393
3394 - memset(mst->msg, 0, sizeof(struct i2c_msg) * (2 + num));
3395 -
3396 dibx000_i2c_select_interface(mst, DIBX000_I2C_INTERFACE_TUNER);
3397
3398 + if (mutex_lock_interruptible(&mst->i2c_buffer_lock) < 0) {
3399 + dprintk("could not acquire lock");
3400 + return -EINVAL;
3401 + }
3402 + memset(mst->msg, 0, sizeof(struct i2c_msg) * (2 + num));
3403 +
3404 /* open the gate */
3405 dibx000_i2c_gate_ctrl(mst, &mst->i2c_write_buffer[0], msg[0].addr, 1);
3406 mst->msg[0].addr = mst->i2c_addr;
3407 @@ -319,7 +355,10 @@ static int dibx000_i2c_gated_tuner_xfer(struct i2c_adapter *i2c_adap,
3408 mst->msg[num + 1].buf = &mst->i2c_write_buffer[4];
3409 mst->msg[num + 1].len = 4;
3410
3411 - return i2c_transfer(mst->i2c_adap, mst->msg, 2 + num) == 2 + num ? num : -EIO;
3412 + ret = (i2c_transfer(mst->i2c_adap, mst->msg, 2 + num) == 2 + num ?
3413 + num : -EIO);
3414 + mutex_unlock(&mst->i2c_buffer_lock);
3415 + return ret;
3416 }
3417
3418 static struct i2c_algorithm dibx000_i2c_gated_tuner_algo = {
3419 @@ -390,8 +429,18 @@ static int i2c_adapter_init(struct i2c_adapter *i2c_adap,
3420 int dibx000_init_i2c_master(struct dibx000_i2c_master *mst, u16 device_rev,
3421 struct i2c_adapter *i2c_adap, u8 i2c_addr)
3422 {
3423 - u8 tx[4];
3424 - struct i2c_msg m = {.addr = i2c_addr >> 1,.buf = tx,.len = 4 };
3425 + int ret;
3426 +
3427 + mutex_init(&mst->i2c_buffer_lock);
3428 + if (mutex_lock_interruptible(&mst->i2c_buffer_lock) < 0) {
3429 + dprintk("could not acquire lock");
3430 + return -EINVAL;
3431 + }
3432 + memset(mst->msg, 0, sizeof(struct i2c_msg));
3433 + mst->msg[0].addr = i2c_addr >> 1;
3434 + mst->msg[0].flags = 0;
3435 + mst->msg[0].buf = mst->i2c_write_buffer;
3436 + mst->msg[0].len = 4;
3437
3438 mst->device_rev = device_rev;
3439 mst->i2c_adap = i2c_adap;
3440 @@ -431,9 +480,12 @@ int dibx000_init_i2c_master(struct dibx000_i2c_master *mst, u16 device_rev,
3441 "DiBX000: could not initialize the master i2c_adapter\n");
3442
3443 /* initialize the i2c-master by closing the gate */
3444 - dibx000_i2c_gate_ctrl(mst, tx, 0, 0);
3445 + dibx000_i2c_gate_ctrl(mst, mst->i2c_write_buffer, 0, 0);
3446 +
3447 + ret = (i2c_transfer(i2c_adap, mst->msg, 1) == 1);
3448 + mutex_unlock(&mst->i2c_buffer_lock);
3449
3450 - return i2c_transfer(i2c_adap, &m, 1) == 1;
3451 + return ret;
3452 }
3453
3454 EXPORT_SYMBOL(dibx000_init_i2c_master);
3455 diff --git a/drivers/media/dvb/frontends/dibx000_common.h b/drivers/media/dvb/frontends/dibx000_common.h
3456 index f031165..5e01147 100644
3457 --- a/drivers/media/dvb/frontends/dibx000_common.h
3458 +++ b/drivers/media/dvb/frontends/dibx000_common.h
3459 @@ -33,6 +33,7 @@ struct dibx000_i2c_master {
3460 struct i2c_msg msg[34];
3461 u8 i2c_write_buffer[8];
3462 u8 i2c_read_buffer[2];
3463 + struct mutex i2c_buffer_lock;
3464 };
3465
3466 extern int dibx000_init_i2c_master(struct dibx000_i2c_master *mst,
3467 diff --git a/drivers/media/video/cx23885/cx23885-dvb.c b/drivers/media/video/cx23885/cx23885-dvb.c
3468 index 3c315f9..2b5cd21 100644
3469 --- a/drivers/media/video/cx23885/cx23885-dvb.c
3470 +++ b/drivers/media/video/cx23885/cx23885-dvb.c
3471 @@ -843,7 +843,7 @@ static int dvb_register(struct cx23885_tsport *port)
3472 static struct xc2028_ctrl ctl = {
3473 .fname = XC3028L_DEFAULT_FIRMWARE,
3474 .max_len = 64,
3475 - .demod = 5000,
3476 + .demod = XC3028_FE_DIBCOM52,
3477 /* This is true for all demods with
3478 v36 firmware? */
3479 .type = XC2028_D2633,
3480 diff --git a/drivers/media/video/uvc/uvc_driver.c b/drivers/media/video/uvc/uvc_driver.c
3481 index b6eae48..1f962dc 100644
3482 --- a/drivers/media/video/uvc/uvc_driver.c
3483 +++ b/drivers/media/video/uvc/uvc_driver.c
3484 @@ -1960,7 +1960,7 @@ static int __uvc_resume(struct usb_interface *intf, int reset)
3485
3486 list_for_each_entry(stream, &dev->streams, list) {
3487 if (stream->intf == intf)
3488 - return uvc_video_resume(stream);
3489 + return uvc_video_resume(stream, reset);
3490 }
3491
3492 uvc_trace(UVC_TRACE_SUSPEND, "Resume: video streaming USB interface "
3493 diff --git a/drivers/media/video/uvc/uvc_video.c b/drivers/media/video/uvc/uvc_video.c
3494 index 4999479..6f147de 100644
3495 --- a/drivers/media/video/uvc/uvc_video.c
3496 +++ b/drivers/media/video/uvc/uvc_video.c
3497 @@ -1104,10 +1104,18 @@ int uvc_video_suspend(struct uvc_streaming *stream)
3498 * buffers, making sure userspace applications are notified of the problem
3499 * instead of waiting forever.
3500 */
3501 -int uvc_video_resume(struct uvc_streaming *stream)
3502 +int uvc_video_resume(struct uvc_streaming *stream, int reset)
3503 {
3504 int ret;
3505
3506 + /* If the bus has been reset on resume, set the alternate setting to 0.
3507 + * This should be the default value, but some devices crash or otherwise
3508 + * misbehave if they don't receive a SET_INTERFACE request before any
3509 + * other video control request.
3510 + */
3511 + if (reset)
3512 + usb_set_interface(stream->dev->udev, stream->intfnum, 0);
3513 +
3514 stream->frozen = 0;
3515
3516 ret = uvc_commit_video(stream, &stream->ctrl);
3517 diff --git a/drivers/media/video/uvc/uvcvideo.h b/drivers/media/video/uvc/uvcvideo.h
3518 index 20107fd..2a38d5e 100644
3519 --- a/drivers/media/video/uvc/uvcvideo.h
3520 +++ b/drivers/media/video/uvc/uvcvideo.h
3521 @@ -639,7 +639,7 @@ extern void uvc_mc_cleanup_entity(struct uvc_entity *entity);
3522 /* Video */
3523 extern int uvc_video_init(struct uvc_streaming *stream);
3524 extern int uvc_video_suspend(struct uvc_streaming *stream);
3525 -extern int uvc_video_resume(struct uvc_streaming *stream);
3526 +extern int uvc_video_resume(struct uvc_streaming *stream, int reset);
3527 extern int uvc_video_enable(struct uvc_streaming *stream, int enable);
3528 extern int uvc_probe_video(struct uvc_streaming *stream,
3529 struct uvc_streaming_control *probe);
3530 diff --git a/drivers/mmc/core/core.c b/drivers/mmc/core/core.c
3531 index 38089b2..75db30e6 100644
3532 --- a/drivers/mmc/core/core.c
3533 +++ b/drivers/mmc/core/core.c
3534 @@ -1057,7 +1057,7 @@ static void mmc_power_up(struct mmc_host *host)
3535 mmc_host_clk_release(host);
3536 }
3537
3538 -static void mmc_power_off(struct mmc_host *host)
3539 +void mmc_power_off(struct mmc_host *host)
3540 {
3541 mmc_host_clk_hold(host);
3542
3543 @@ -1147,8 +1147,7 @@ void mmc_attach_bus(struct mmc_host *host, const struct mmc_bus_ops *ops)
3544 }
3545
3546 /*
3547 - * Remove the current bus handler from a host. Assumes that there are
3548 - * no interesting cards left, so the bus is powered down.
3549 + * Remove the current bus handler from a host.
3550 */
3551 void mmc_detach_bus(struct mmc_host *host)
3552 {
3553 @@ -1165,8 +1164,6 @@ void mmc_detach_bus(struct mmc_host *host)
3554
3555 spin_unlock_irqrestore(&host->lock, flags);
3556
3557 - mmc_power_off(host);
3558 -
3559 mmc_bus_put(host);
3560 }
3561
3562 @@ -1675,6 +1672,7 @@ void mmc_stop_host(struct mmc_host *host)
3563
3564 mmc_claim_host(host);
3565 mmc_detach_bus(host);
3566 + mmc_power_off(host);
3567 mmc_release_host(host);
3568 mmc_bus_put(host);
3569 return;
3570 @@ -1796,6 +1794,7 @@ int mmc_suspend_host(struct mmc_host *host)
3571 host->bus_ops->remove(host);
3572 mmc_claim_host(host);
3573 mmc_detach_bus(host);
3574 + mmc_power_off(host);
3575 mmc_release_host(host);
3576 host->pm_flags = 0;
3577 err = 0;
3578 @@ -1883,6 +1882,7 @@ int mmc_pm_notify(struct notifier_block *notify_block,
3579 host->bus_ops->remove(host);
3580
3581 mmc_detach_bus(host);
3582 + mmc_power_off(host);
3583 mmc_release_host(host);
3584 host->pm_flags = 0;
3585 break;
3586 diff --git a/drivers/mmc/core/core.h b/drivers/mmc/core/core.h
3587 index d9411ed..14664f1 100644
3588 --- a/drivers/mmc/core/core.h
3589 +++ b/drivers/mmc/core/core.h
3590 @@ -43,6 +43,7 @@ int mmc_set_signal_voltage(struct mmc_host *host, int signal_voltage,
3591 bool cmd11);
3592 void mmc_set_timing(struct mmc_host *host, unsigned int timing);
3593 void mmc_set_driver_type(struct mmc_host *host, unsigned int drv_type);
3594 +void mmc_power_off(struct mmc_host *host);
3595
3596 static inline void mmc_delay(unsigned int ms)
3597 {
3598 diff --git a/drivers/mmc/core/mmc.c b/drivers/mmc/core/mmc.c
3599 index aa7d1d7..20b42c8 100644
3600 --- a/drivers/mmc/core/mmc.c
3601 +++ b/drivers/mmc/core/mmc.c
3602 @@ -359,6 +359,7 @@ static int mmc_read_ext_csd(struct mmc_card *card, u8 *ext_csd)
3603 * card has the Enhanced area enabled. If so, export enhanced
3604 * area offset and size to user by adding sysfs interface.
3605 */
3606 + card->ext_csd.raw_partition_support = ext_csd[EXT_CSD_PARTITION_SUPPORT];
3607 if ((ext_csd[EXT_CSD_PARTITION_SUPPORT] & 0x2) &&
3608 (ext_csd[EXT_CSD_PARTITION_ATTRIBUTE] & 0x1)) {
3609 u8 hc_erase_grp_sz =
3610 @@ -405,6 +406,7 @@ static int mmc_read_ext_csd(struct mmc_card *card, u8 *ext_csd)
3611 if (card->ext_csd.rev >= 5)
3612 card->ext_csd.rel_param = ext_csd[EXT_CSD_WR_REL_PARAM];
3613
3614 + card->ext_csd.raw_erased_mem_count = ext_csd[EXT_CSD_ERASED_MEM_CONT];
3615 if (ext_csd[EXT_CSD_ERASED_MEM_CONT])
3616 card->erased_byte = 0xFF;
3617 else
3618 @@ -891,6 +893,7 @@ static void mmc_detect(struct mmc_host *host)
3619
3620 mmc_claim_host(host);
3621 mmc_detach_bus(host);
3622 + mmc_power_off(host);
3623 mmc_release_host(host);
3624 }
3625 }
3626 diff --git a/drivers/mmc/core/sd.c b/drivers/mmc/core/sd.c
3627 index ff27741..bd8805c 100644
3628 --- a/drivers/mmc/core/sd.c
3629 +++ b/drivers/mmc/core/sd.c
3630 @@ -1008,6 +1008,7 @@ static void mmc_sd_detect(struct mmc_host *host)
3631
3632 mmc_claim_host(host);
3633 mmc_detach_bus(host);
3634 + mmc_power_off(host);
3635 mmc_release_host(host);
3636 }
3637 }
3638 diff --git a/drivers/mmc/core/sdio.c b/drivers/mmc/core/sdio.c
3639 index 262fff0..ac492ac 100644
3640 --- a/drivers/mmc/core/sdio.c
3641 +++ b/drivers/mmc/core/sdio.c
3642 @@ -597,6 +597,7 @@ out:
3643
3644 mmc_claim_host(host);
3645 mmc_detach_bus(host);
3646 + mmc_power_off(host);
3647 mmc_release_host(host);
3648 }
3649 }
3650 diff --git a/drivers/mtd/mtdchar.c b/drivers/mtd/mtdchar.c
3651 index 3f92731..9f8658e 100644
3652 --- a/drivers/mtd/mtdchar.c
3653 +++ b/drivers/mtd/mtdchar.c
3654 @@ -320,6 +320,7 @@ static ssize_t mtd_write(struct file *file, const char __user *buf, size_t count
3655 ops.mode = MTD_OOB_RAW;
3656 ops.datbuf = kbuf;
3657 ops.oobbuf = NULL;
3658 + ops.ooboffs = 0;
3659 ops.len = len;
3660
3661 ret = mtd->write_oob(mtd, *ppos, &ops);
3662 diff --git a/drivers/mtd/nand/nand_base.c b/drivers/mtd/nand/nand_base.c
3663 index a46e9bb..86f05f4 100644
3664 --- a/drivers/mtd/nand/nand_base.c
3665 +++ b/drivers/mtd/nand/nand_base.c
3666 @@ -2097,14 +2097,22 @@ static int nand_write_page(struct mtd_info *mtd, struct nand_chip *chip,
3667
3668 /**
3669 * nand_fill_oob - [Internal] Transfer client buffer to oob
3670 - * @chip: nand chip structure
3671 + * @mtd: MTD device structure
3672 * @oob: oob data buffer
3673 * @len: oob data write length
3674 * @ops: oob ops structure
3675 */
3676 -static uint8_t *nand_fill_oob(struct nand_chip *chip, uint8_t *oob, size_t len,
3677 - struct mtd_oob_ops *ops)
3678 +static uint8_t *nand_fill_oob(struct mtd_info *mtd, uint8_t *oob, size_t len,
3679 + struct mtd_oob_ops *ops)
3680 {
3681 + struct nand_chip *chip = mtd->priv;
3682 +
3683 + /*
3684 + * Initialise to all 0xFF, to avoid the possibility of left over OOB
3685 + * data from a previous OOB read.
3686 + */
3687 + memset(chip->oob_poi, 0xff, mtd->oobsize);
3688 +
3689 switch (ops->mode) {
3690
3691 case MTD_OOB_PLACE:
3692 @@ -2201,10 +2209,6 @@ static int nand_do_write_ops(struct mtd_info *mtd, loff_t to,
3693 (chip->pagebuf << chip->page_shift) < (to + ops->len))
3694 chip->pagebuf = -1;
3695
3696 - /* If we're not given explicit OOB data, let it be 0xFF */
3697 - if (likely(!oob))
3698 - memset(chip->oob_poi, 0xff, mtd->oobsize);
3699 -
3700 /* Don't allow multipage oob writes with offset */
3701 if (oob && ops->ooboffs && (ops->ooboffs + ops->ooblen > oobmaxlen))
3702 return -EINVAL;
3703 @@ -2226,8 +2230,11 @@ static int nand_do_write_ops(struct mtd_info *mtd, loff_t to,
3704
3705 if (unlikely(oob)) {
3706 size_t len = min(oobwritelen, oobmaxlen);
3707 - oob = nand_fill_oob(chip, oob, len, ops);
3708 + oob = nand_fill_oob(mtd, oob, len, ops);
3709 oobwritelen -= len;
3710 + } else {
3711 + /* We still need to erase leftover OOB data */
3712 + memset(chip->oob_poi, 0xff, mtd->oobsize);
3713 }
3714
3715 ret = chip->write_page(mtd, chip, wbuf, page, cached,
3716 @@ -2401,10 +2408,8 @@ static int nand_do_write_oob(struct mtd_info *mtd, loff_t to,
3717 if (page == chip->pagebuf)
3718 chip->pagebuf = -1;
3719
3720 - memset(chip->oob_poi, 0xff, mtd->oobsize);
3721 - nand_fill_oob(chip, ops->oobbuf, ops->ooblen, ops);
3722 + nand_fill_oob(mtd, ops->oobbuf, ops->ooblen, ops);
3723 status = chip->ecc.write_oob(mtd, chip, page & chip->pagemask);
3724 - memset(chip->oob_poi, 0xff, mtd->oobsize);
3725
3726 if (status)
3727 return status;
3728 diff --git a/drivers/mtd/nand/pxa3xx_nand.c b/drivers/mtd/nand/pxa3xx_nand.c
3729 index 1fb3b3a..30689cc 100644
3730 --- a/drivers/mtd/nand/pxa3xx_nand.c
3731 +++ b/drivers/mtd/nand/pxa3xx_nand.c
3732 @@ -685,6 +685,8 @@ static int pxa3xx_nand_read_page_hwecc(struct mtd_info *mtd,
3733 * OOB, ignore such double bit errors
3734 */
3735 if (is_buf_blank(buf, mtd->writesize))
3736 + info->retcode = ERR_NONE;
3737 + else
3738 mtd->ecc_stats.failed++;
3739 }
3740
3741 @@ -813,7 +815,7 @@ static int pxa3xx_nand_detect_config(struct pxa3xx_nand_info *info)
3742 info->page_size = ndcr & NDCR_PAGE_SZ ? 2048 : 512;
3743 /* set info fields needed to read id */
3744 info->read_id_bytes = (info->page_size == 2048) ? 4 : 2;
3745 - info->reg_ndcr = ndcr;
3746 + info->reg_ndcr = ndcr & ~NDCR_INT_MASK;
3747 info->cmdset = &default_cmdset;
3748
3749 info->ndtr0cs0 = nand_readl(info, NDTR0CS0);
3750 @@ -882,7 +884,7 @@ static int pxa3xx_nand_scan(struct mtd_info *mtd)
3751 struct pxa3xx_nand_info *info = mtd->priv;
3752 struct platform_device *pdev = info->pdev;
3753 struct pxa3xx_nand_platform_data *pdata = pdev->dev.platform_data;
3754 - struct nand_flash_dev pxa3xx_flash_ids[2] = { {NULL,}, {NULL,} };
3755 + struct nand_flash_dev pxa3xx_flash_ids[2], *def = NULL;
3756 const struct pxa3xx_nand_flash *f = NULL;
3757 struct nand_chip *chip = mtd->priv;
3758 uint32_t id = -1;
3759 @@ -942,8 +944,10 @@ static int pxa3xx_nand_scan(struct mtd_info *mtd)
3760 pxa3xx_flash_ids[0].erasesize = f->page_size * f->page_per_block;
3761 if (f->flash_width == 16)
3762 pxa3xx_flash_ids[0].options = NAND_BUSWIDTH_16;
3763 + pxa3xx_flash_ids[1].name = NULL;
3764 + def = pxa3xx_flash_ids;
3765 KEEP_CONFIG:
3766 - if (nand_scan_ident(mtd, 1, pxa3xx_flash_ids))
3767 + if (nand_scan_ident(mtd, 1, def))
3768 return -ENODEV;
3769 /* calculate addressing information */
3770 info->col_addr_cycles = (mtd->writesize >= 2048) ? 2 : 1;
3771 @@ -954,9 +958,9 @@ KEEP_CONFIG:
3772 info->row_addr_cycles = 2;
3773 mtd->name = mtd_names[0];
3774 chip->ecc.mode = NAND_ECC_HW;
3775 - chip->ecc.size = f->page_size;
3776 + chip->ecc.size = info->page_size;
3777
3778 - chip->options = (f->flash_width == 16) ? NAND_BUSWIDTH_16 : 0;
3779 + chip->options = (info->reg_ndcr & NDCR_DWIDTH_M) ? NAND_BUSWIDTH_16 : 0;
3780 chip->options |= NAND_NO_AUTOINCR;
3781 chip->options |= NAND_NO_READRDY;
3782
3783 diff --git a/drivers/mtd/redboot.c b/drivers/mtd/redboot.c
3784 index 7a87d07..4938bd0 100644
3785 --- a/drivers/mtd/redboot.c
3786 +++ b/drivers/mtd/redboot.c
3787 @@ -297,6 +297,9 @@ static struct mtd_part_parser redboot_parser = {
3788 .name = "RedBoot",
3789 };
3790
3791 +/* mtd parsers will request the module by parser name */
3792 +MODULE_ALIAS("RedBoot");
3793 +
3794 static int __init redboot_parser_init(void)
3795 {
3796 return register_mtd_parser(&redboot_parser);
3797 diff --git a/drivers/net/bonding/bond_main.c b/drivers/net/bonding/bond_main.c
3798 index 9ea2f21..2065cb4 100644
3799 --- a/drivers/net/bonding/bond_main.c
3800 +++ b/drivers/net/bonding/bond_main.c
3801 @@ -1500,6 +1500,8 @@ static rx_handler_result_t bond_handle_frame(struct sk_buff **pskb)
3802 struct sk_buff *skb = *pskb;
3803 struct slave *slave;
3804 struct bonding *bond;
3805 + void (*recv_probe)(struct sk_buff *, struct bonding *,
3806 + struct slave *);
3807
3808 skb = skb_share_check(skb, GFP_ATOMIC);
3809 if (unlikely(!skb))
3810 @@ -1513,11 +1515,12 @@ static rx_handler_result_t bond_handle_frame(struct sk_buff **pskb)
3811 if (bond->params.arp_interval)
3812 slave->dev->last_rx = jiffies;
3813
3814 - if (bond->recv_probe) {
3815 + recv_probe = ACCESS_ONCE(bond->recv_probe);
3816 + if (recv_probe) {
3817 struct sk_buff *nskb = skb_clone(skb, GFP_ATOMIC);
3818
3819 if (likely(nskb)) {
3820 - bond->recv_probe(nskb, bond, slave);
3821 + recv_probe(nskb, bond, slave);
3822 dev_kfree_skb(nskb);
3823 }
3824 }
3825 diff --git a/drivers/net/enic/enic_main.c b/drivers/net/enic/enic_main.c
3826 index 2f433fb..51fba5f 100644
3827 --- a/drivers/net/enic/enic_main.c
3828 +++ b/drivers/net/enic/enic_main.c
3829 @@ -1718,8 +1718,12 @@ static void enic_poll_controller(struct net_device *netdev)
3830 enic_isr_msix_rq(enic->msix_entry[intr].vector,
3831 &enic->napi[i]);
3832 }
3833 - intr = enic_msix_wq_intr(enic, i);
3834 - enic_isr_msix_wq(enic->msix_entry[intr].vector, enic);
3835 +
3836 + for (i = 0; i < enic->wq_count; i++) {
3837 + intr = enic_msix_wq_intr(enic, i);
3838 + enic_isr_msix_wq(enic->msix_entry[intr].vector, enic);
3839 + }
3840 +
3841 break;
3842 case VNIC_DEV_INTR_MODE_MSI:
3843 enic_isr_msi(enic->pdev->irq, enic);
3844 diff --git a/drivers/net/macvlan.c b/drivers/net/macvlan.c
3845 index 2f3c48d..ab4723d 100644
3846 --- a/drivers/net/macvlan.c
3847 +++ b/drivers/net/macvlan.c
3848 @@ -239,7 +239,7 @@ static int macvlan_queue_xmit(struct sk_buff *skb, struct net_device *dev)
3849 dest = macvlan_hash_lookup(port, eth->h_dest);
3850 if (dest && dest->mode == MACVLAN_MODE_BRIDGE) {
3851 /* send to lowerdev first for its network taps */
3852 - vlan->forward(vlan->lowerdev, skb);
3853 + dev_forward_skb(vlan->lowerdev, skb);
3854
3855 return NET_XMIT_SUCCESS;
3856 }
3857 diff --git a/drivers/net/netconsole.c b/drivers/net/netconsole.c
3858 index dfc8272..4840ab7 100644
3859 --- a/drivers/net/netconsole.c
3860 +++ b/drivers/net/netconsole.c
3861 @@ -307,6 +307,11 @@ static ssize_t store_enabled(struct netconsole_target *nt,
3862 return err;
3863 if (enabled < 0 || enabled > 1)
3864 return -EINVAL;
3865 + if (enabled == nt->enabled) {
3866 + printk(KERN_INFO "netconsole: network logging has already %s\n",
3867 + nt->enabled ? "started" : "stopped");
3868 + return -EINVAL;
3869 + }
3870
3871 if (enabled) { /* 1 */
3872
3873 diff --git a/drivers/net/phy/dp83640.c b/drivers/net/phy/dp83640.c
3874 index cb6e0b4..364cd67 100644
3875 --- a/drivers/net/phy/dp83640.c
3876 +++ b/drivers/net/phy/dp83640.c
3877 @@ -875,6 +875,7 @@ static void dp83640_remove(struct phy_device *phydev)
3878 struct dp83640_clock *clock;
3879 struct list_head *this, *next;
3880 struct dp83640_private *tmp, *dp83640 = phydev->priv;
3881 + struct sk_buff *skb;
3882
3883 if (phydev->addr == BROADCAST_ADDR)
3884 return;
3885 @@ -882,6 +883,12 @@ static void dp83640_remove(struct phy_device *phydev)
3886 enable_status_frames(phydev, false);
3887 cancel_work_sync(&dp83640->ts_work);
3888
3889 + while ((skb = skb_dequeue(&dp83640->rx_queue)) != NULL)
3890 + kfree_skb(skb);
3891 +
3892 + while ((skb = skb_dequeue(&dp83640->tx_queue)) != NULL)
3893 + skb_complete_tx_timestamp(skb, NULL);
3894 +
3895 clock = dp83640_clock_get(dp83640->clock);
3896
3897 if (dp83640 == clock->chosen) {
3898 @@ -1060,7 +1067,7 @@ static void dp83640_txtstamp(struct phy_device *phydev,
3899 struct dp83640_private *dp83640 = phydev->priv;
3900
3901 if (!dp83640->hwts_tx_en) {
3902 - kfree_skb(skb);
3903 + skb_complete_tx_timestamp(skb, NULL);
3904 return;
3905 }
3906 skb_queue_tail(&dp83640->tx_queue, skb);
3907 diff --git a/drivers/net/rionet.c b/drivers/net/rionet.c
3908 index ca4694e..1f421d7 100644
3909 --- a/drivers/net/rionet.c
3910 +++ b/drivers/net/rionet.c
3911 @@ -88,8 +88,8 @@ static struct rio_dev **rionet_active;
3912 #define dev_rionet_capable(dev) \
3913 is_rionet_capable(dev->src_ops, dev->dst_ops)
3914
3915 -#define RIONET_MAC_MATCH(x) (*(u32 *)x == 0x00010001)
3916 -#define RIONET_GET_DESTID(x) (*(u16 *)(x + 4))
3917 +#define RIONET_MAC_MATCH(x) (!memcmp((x), "\00\01\00\01", 4))
3918 +#define RIONET_GET_DESTID(x) ((*((u8 *)x + 4) << 8) | *((u8 *)x + 5))
3919
3920 static int rionet_rx_clean(struct net_device *ndev)
3921 {
3922 diff --git a/drivers/net/tg3.c b/drivers/net/tg3.c
3923 index 38f6859..bc8c183 100644
3924 --- a/drivers/net/tg3.c
3925 +++ b/drivers/net/tg3.c
3926 @@ -15278,7 +15278,7 @@ static void __devexit tg3_remove_one(struct pci_dev *pdev)
3927
3928 cancel_work_sync(&tp->reset_task);
3929
3930 - if (!tg3_flag(tp, USE_PHYLIB)) {
3931 + if (tg3_flag(tp, USE_PHYLIB)) {
3932 tg3_phy_fini(tp);
3933 tg3_mdio_fini(tp);
3934 }
3935 diff --git a/drivers/net/usb/asix.c b/drivers/net/usb/asix.c
3936 index 5250288..c5c4b4d 100644
3937 --- a/drivers/net/usb/asix.c
3938 +++ b/drivers/net/usb/asix.c
3939 @@ -314,12 +314,11 @@ static int asix_rx_fixup(struct usbnet *dev, struct sk_buff *skb)
3940 skb_pull(skb, 4);
3941
3942 while (skb->len > 0) {
3943 - if ((short)(header & 0x0000ffff) !=
3944 - ~((short)((header & 0xffff0000) >> 16))) {
3945 + if ((header & 0x07ff) != ((~header >> 16) & 0x07ff))
3946 netdev_err(dev->net, "asix_rx_fixup() Bad Header Length\n");
3947 - }
3948 +
3949 /* get the packet length */
3950 - size = (u16) (header & 0x0000ffff);
3951 + size = (u16) (header & 0x000007ff);
3952
3953 if ((skb->len) - ((size + 1) & 0xfffe) == 0) {
3954 u8 alignment = (unsigned long)skb->data & 0x3;
3955 diff --git a/drivers/net/usb/cdc_ncm.c b/drivers/net/usb/cdc_ncm.c
3956 index d3b9e95..6a53161 100644
3957 --- a/drivers/net/usb/cdc_ncm.c
3958 +++ b/drivers/net/usb/cdc_ncm.c
3959 @@ -229,23 +229,40 @@ static u8 cdc_ncm_setup(struct cdc_ncm_ctx *ctx)
3960 if (ctx->rx_max != le32_to_cpu(ctx->ncm_parm.dwNtbInMaxSize)) {
3961
3962 if (flags & USB_CDC_NCM_NCAP_NTB_INPUT_SIZE) {
3963 - struct usb_cdc_ncm_ndp_input_size ndp_in_sz;
3964 + struct usb_cdc_ncm_ndp_input_size *ndp_in_sz;
3965 +
3966 + ndp_in_sz = kzalloc(sizeof(*ndp_in_sz), GFP_KERNEL);
3967 + if (!ndp_in_sz) {
3968 + err = -ENOMEM;
3969 + goto size_err;
3970 + }
3971 +
3972 err = usb_control_msg(ctx->udev,
3973 usb_sndctrlpipe(ctx->udev, 0),
3974 USB_CDC_SET_NTB_INPUT_SIZE,
3975 USB_TYPE_CLASS | USB_DIR_OUT
3976 | USB_RECIP_INTERFACE,
3977 - 0, iface_no, &ndp_in_sz, 8, 1000);
3978 + 0, iface_no, ndp_in_sz, 8, 1000);
3979 + kfree(ndp_in_sz);
3980 } else {
3981 - __le32 dwNtbInMaxSize = cpu_to_le32(ctx->rx_max);
3982 + __le32 *dwNtbInMaxSize;
3983 + dwNtbInMaxSize = kzalloc(sizeof(*dwNtbInMaxSize),
3984 + GFP_KERNEL);
3985 + if (!dwNtbInMaxSize) {
3986 + err = -ENOMEM;
3987 + goto size_err;
3988 + }
3989 + *dwNtbInMaxSize = cpu_to_le32(ctx->rx_max);
3990 +
3991 err = usb_control_msg(ctx->udev,
3992 usb_sndctrlpipe(ctx->udev, 0),
3993 USB_CDC_SET_NTB_INPUT_SIZE,
3994 USB_TYPE_CLASS | USB_DIR_OUT
3995 | USB_RECIP_INTERFACE,
3996 - 0, iface_no, &dwNtbInMaxSize, 4, 1000);
3997 + 0, iface_no, dwNtbInMaxSize, 4, 1000);
3998 + kfree(dwNtbInMaxSize);
3999 }
4000 -
4001 +size_err:
4002 if (err < 0)
4003 pr_debug("Setting NTB Input Size failed\n");
4004 }
4005 @@ -326,19 +343,29 @@ static u8 cdc_ncm_setup(struct cdc_ncm_ctx *ctx)
4006
4007 /* set Max Datagram Size (MTU) */
4008 if (flags & USB_CDC_NCM_NCAP_MAX_DATAGRAM_SIZE) {
4009 - __le16 max_datagram_size;
4010 + __le16 *max_datagram_size;
4011 u16 eth_max_sz = le16_to_cpu(ctx->ether_desc->wMaxSegmentSize);
4012 +
4013 + max_datagram_size = kzalloc(sizeof(*max_datagram_size),
4014 + GFP_KERNEL);
4015 + if (!max_datagram_size) {
4016 + err = -ENOMEM;
4017 + goto max_dgram_err;
4018 + }
4019 +
4020 err = usb_control_msg(ctx->udev, usb_rcvctrlpipe(ctx->udev, 0),
4021 USB_CDC_GET_MAX_DATAGRAM_SIZE,
4022 USB_TYPE_CLASS | USB_DIR_IN
4023 | USB_RECIP_INTERFACE,
4024 - 0, iface_no, &max_datagram_size,
4025 + 0, iface_no, max_datagram_size,
4026 2, 1000);
4027 if (err < 0) {
4028 pr_debug("GET_MAX_DATAGRAM_SIZE failed, use size=%u\n",
4029 CDC_NCM_MIN_DATAGRAM_SIZE);
4030 + kfree(max_datagram_size);
4031 } else {
4032 - ctx->max_datagram_size = le16_to_cpu(max_datagram_size);
4033 + ctx->max_datagram_size =
4034 + le16_to_cpu(*max_datagram_size);
4035 /* Check Eth descriptor value */
4036 if (eth_max_sz < CDC_NCM_MAX_DATAGRAM_SIZE) {
4037 if (ctx->max_datagram_size > eth_max_sz)
4038 @@ -361,8 +388,10 @@ static u8 cdc_ncm_setup(struct cdc_ncm_ctx *ctx)
4039 USB_TYPE_CLASS | USB_DIR_OUT
4040 | USB_RECIP_INTERFACE,
4041 0,
4042 - iface_no, &max_datagram_size,
4043 + iface_no, max_datagram_size,
4044 2, 1000);
4045 + kfree(max_datagram_size);
4046 +max_dgram_err:
4047 if (err < 0)
4048 pr_debug("SET_MAX_DATAGRAM_SIZE failed\n");
4049 }
4050 diff --git a/drivers/net/usb/ipheth.c b/drivers/net/usb/ipheth.c
4051 index 81126ff..8f9b7f7 100644
4052 --- a/drivers/net/usb/ipheth.c
4053 +++ b/drivers/net/usb/ipheth.c
4054 @@ -59,6 +59,7 @@
4055 #define USB_PRODUCT_IPHONE_3G 0x1292
4056 #define USB_PRODUCT_IPHONE_3GS 0x1294
4057 #define USB_PRODUCT_IPHONE_4 0x1297
4058 +#define USB_PRODUCT_IPHONE_4_VZW 0x129c
4059
4060 #define IPHETH_USBINTF_CLASS 255
4061 #define IPHETH_USBINTF_SUBCLASS 253
4062 @@ -98,6 +99,10 @@ static struct usb_device_id ipheth_table[] = {
4063 USB_VENDOR_APPLE, USB_PRODUCT_IPHONE_4,
4064 IPHETH_USBINTF_CLASS, IPHETH_USBINTF_SUBCLASS,
4065 IPHETH_USBINTF_PROTO) },
4066 + { USB_DEVICE_AND_INTERFACE_INFO(
4067 + USB_VENDOR_APPLE, USB_PRODUCT_IPHONE_4_VZW,
4068 + IPHETH_USBINTF_CLASS, IPHETH_USBINTF_SUBCLASS,
4069 + IPHETH_USBINTF_PROTO) },
4070 { }
4071 };
4072 MODULE_DEVICE_TABLE(usb, ipheth_table);
4073 diff --git a/drivers/net/usb/rtl8150.c b/drivers/net/usb/rtl8150.c
4074 index 041fb7d..ef3b236 100644
4075 --- a/drivers/net/usb/rtl8150.c
4076 +++ b/drivers/net/usb/rtl8150.c
4077 @@ -977,7 +977,6 @@ static void rtl8150_disconnect(struct usb_interface *intf)
4078 usb_set_intfdata(intf, NULL);
4079 if (dev) {
4080 set_bit(RTL8150_UNPLUG, &dev->flags);
4081 - tasklet_disable(&dev->tl);
4082 tasklet_kill(&dev->tl);
4083 unregister_netdev(dev->netdev);
4084 unlink_all_urbs(dev);
4085 diff --git a/drivers/net/wireless/ath/ath9k/ani.c b/drivers/net/wireless/ath/ath9k/ani.c
4086 index bfb6481..4e4e7c3 100644
4087 --- a/drivers/net/wireless/ath/ath9k/ani.c
4088 +++ b/drivers/net/wireless/ath/ath9k/ani.c
4089 @@ -502,9 +502,6 @@ static void ath9k_ani_reset_old(struct ath_hw *ah, bool is_scanning)
4090 ath9k_hw_ani_control(ah, ATH9K_ANI_CCK_WEAK_SIGNAL_THR,
4091 ATH9K_ANI_CCK_WEAK_SIG_THR);
4092
4093 - ath9k_hw_setrxfilter(ah, ath9k_hw_getrxfilter(ah) |
4094 - ATH9K_RX_FILTER_PHYERR);
4095 -
4096 ath9k_ani_restart(ah);
4097 return;
4098 }
4099 @@ -525,8 +522,6 @@ static void ath9k_ani_reset_old(struct ath_hw *ah, bool is_scanning)
4100 ath9k_hw_ani_control(ah, ATH9K_ANI_FIRSTEP_LEVEL,
4101 aniState->firstepLevel);
4102
4103 - ath9k_hw_setrxfilter(ah, ath9k_hw_getrxfilter(ah) &
4104 - ~ATH9K_RX_FILTER_PHYERR);
4105 ath9k_ani_restart(ah);
4106
4107 ENABLE_REGWRITE_BUFFER(ah);
4108 diff --git a/drivers/net/wireless/ath/ath9k/ar9003_calib.c b/drivers/net/wireless/ath/ath9k/ar9003_calib.c
4109 index f48051c..7c2aaad 100644
4110 --- a/drivers/net/wireless/ath/ath9k/ar9003_calib.c
4111 +++ b/drivers/net/wireless/ath/ath9k/ar9003_calib.c
4112 @@ -643,8 +643,9 @@ static void ar9003_hw_detect_outlier(int *mp_coeff, int nmeasurement,
4113 outlier_idx = max_idx;
4114 else
4115 outlier_idx = min_idx;
4116 +
4117 + mp_coeff[outlier_idx] = mp_avg;
4118 }
4119 - mp_coeff[outlier_idx] = mp_avg;
4120 }
4121
4122 static void ar9003_hw_tx_iqcal_load_avg_2_passes(struct ath_hw *ah,
4123 diff --git a/drivers/net/wireless/ath/ath9k/ar9003_mac.c b/drivers/net/wireless/ath/ath9k/ar9003_mac.c
4124 index 1f99249..7880dca 100644
4125 --- a/drivers/net/wireless/ath/ath9k/ar9003_mac.c
4126 +++ b/drivers/net/wireless/ath/ath9k/ar9003_mac.c
4127 @@ -255,8 +255,6 @@ static int ar9003_hw_proc_txdesc(struct ath_hw *ah, void *ds,
4128 return -EIO;
4129 }
4130
4131 - if (status & AR_TxOpExceeded)
4132 - ts->ts_status |= ATH9K_TXERR_XTXOP;
4133 ts->ts_rateindex = MS(status, AR_FinalTxIdx);
4134 ts->ts_seqnum = MS(status, AR_SeqNum);
4135 ts->tid = MS(status, AR_TxTid);
4136 @@ -267,6 +265,8 @@ static int ar9003_hw_proc_txdesc(struct ath_hw *ah, void *ds,
4137 ts->ts_status = 0;
4138 ts->ts_flags = 0;
4139
4140 + if (status & AR_TxOpExceeded)
4141 + ts->ts_status |= ATH9K_TXERR_XTXOP;
4142 status = ACCESS_ONCE(ads->status2);
4143 ts->ts_rssi_ctl0 = MS(status, AR_TxRSSIAnt00);
4144 ts->ts_rssi_ctl1 = MS(status, AR_TxRSSIAnt01);
4145 diff --git a/drivers/net/wireless/ath/ath9k/ar9003_phy.h b/drivers/net/wireless/ath/ath9k/ar9003_phy.h
4146 index efdbe98..2364b5f 100644
4147 --- a/drivers/net/wireless/ath/ath9k/ar9003_phy.h
4148 +++ b/drivers/net/wireless/ath/ath9k/ar9003_phy.h
4149 @@ -570,12 +570,12 @@
4150
4151 #define AR_PHY_TXGAIN_TABLE (AR_SM_BASE + 0x300)
4152
4153 -#define AR_PHY_TX_IQCAL_CONTROL_1 (AR_SM_BASE + AR_SREV_9485(ah) ? \
4154 - 0x3c8 : 0x448)
4155 -#define AR_PHY_TX_IQCAL_START (AR_SM_BASE + AR_SREV_9485(ah) ? \
4156 - 0x3c4 : 0x440)
4157 -#define AR_PHY_TX_IQCAL_STATUS_B0 (AR_SM_BASE + AR_SREV_9485(ah) ? \
4158 - 0x3f0 : 0x48c)
4159 +#define AR_PHY_TX_IQCAL_CONTROL_1 (AR_SM_BASE + (AR_SREV_9485(ah) ? \
4160 + 0x3c8 : 0x448))
4161 +#define AR_PHY_TX_IQCAL_START (AR_SM_BASE + (AR_SREV_9485(ah) ? \
4162 + 0x3c4 : 0x440))
4163 +#define AR_PHY_TX_IQCAL_STATUS_B0 (AR_SM_BASE + (AR_SREV_9485(ah) ? \
4164 + 0x3f0 : 0x48c))
4165 #define AR_PHY_TX_IQCAL_CORR_COEFF_B0(_i) (AR_SM_BASE + \
4166 (AR_SREV_9485(ah) ? \
4167 0x3d0 : 0x450) + ((_i) << 2))
4168 diff --git a/drivers/net/wireless/ath/ath9k/ar9485_initvals.h b/drivers/net/wireless/ath/ath9k/ar9485_initvals.h
4169 index 611ea6c..d16d029 100644
4170 --- a/drivers/net/wireless/ath/ath9k/ar9485_initvals.h
4171 +++ b/drivers/net/wireless/ath/ath9k/ar9485_initvals.h
4172 @@ -521,7 +521,7 @@ static const u32 ar9485_1_1_radio_postamble[][2] = {
4173 {0x000160ac, 0x24611800},
4174 {0x000160b0, 0x03284f3e},
4175 {0x0001610c, 0x00170000},
4176 - {0x00016140, 0x10804008},
4177 + {0x00016140, 0x50804008},
4178 };
4179
4180 static const u32 ar9485_1_1_mac_postamble[][5] = {
4181 @@ -603,7 +603,7 @@ static const u32 ar9485_1_1_radio_core[][2] = {
4182
4183 static const u32 ar9485_1_1_pcie_phy_pll_on_clkreq_enable_L1[][2] = {
4184 /* Addr allmodes */
4185 - {0x00018c00, 0x10052e5e},
4186 + {0x00018c00, 0x18052e5e},
4187 {0x00018c04, 0x000801d8},
4188 {0x00018c08, 0x0000080c},
4189 };
4190 @@ -776,7 +776,7 @@ static const u32 ar9485_modes_green_ob_db_tx_gain_1_1[][5] = {
4191
4192 static const u32 ar9485_1_1_pcie_phy_clkreq_disable_L1[][2] = {
4193 /* Addr allmodes */
4194 - {0x00018c00, 0x10013e5e},
4195 + {0x00018c00, 0x18013e5e},
4196 {0x00018c04, 0x000801d8},
4197 {0x00018c08, 0x0000080c},
4198 };
4199 @@ -882,7 +882,7 @@ static const u32 ar9485_fast_clock_1_1_baseband_postamble[][3] = {
4200
4201 static const u32 ar9485_1_1_pcie_phy_pll_on_clkreq_disable_L1[][2] = {
4202 /* Addr allmodes */
4203 - {0x00018c00, 0x10012e5e},
4204 + {0x00018c00, 0x18012e5e},
4205 {0x00018c04, 0x000801d8},
4206 {0x00018c08, 0x0000080c},
4207 };
4208 @@ -1021,7 +1021,7 @@ static const u32 ar9485_common_rx_gain_1_1[][2] = {
4209
4210 static const u32 ar9485_1_1_pcie_phy_clkreq_enable_L1[][2] = {
4211 /* Addr allmodes */
4212 - {0x00018c00, 0x10053e5e},
4213 + {0x00018c00, 0x18053e5e},
4214 {0x00018c04, 0x000801d8},
4215 {0x00018c08, 0x0000080c},
4216 };
4217 diff --git a/drivers/net/wireless/ath/ath9k/hif_usb.c b/drivers/net/wireless/ath/ath9k/hif_usb.c
4218 index 260f1f3..5513c0a 100644
4219 --- a/drivers/net/wireless/ath/ath9k/hif_usb.c
4220 +++ b/drivers/net/wireless/ath/ath9k/hif_usb.c
4221 @@ -37,6 +37,7 @@ static struct usb_device_id ath9k_hif_usb_ids[] = {
4222 { USB_DEVICE(0x04CA, 0x4605) }, /* Liteon */
4223 { USB_DEVICE(0x040D, 0x3801) }, /* VIA */
4224 { USB_DEVICE(0x0cf3, 0xb003) }, /* Ubiquiti WifiStation Ext */
4225 + { USB_DEVICE(0x057c, 0x8403) }, /* AVM FRITZ!WLAN 11N v2 USB */
4226
4227 { USB_DEVICE(0x0cf3, 0x7015),
4228 .driver_info = AR9287_USB }, /* Atheros */
4229 diff --git a/drivers/net/wireless/ath/ath9k/hw.c b/drivers/net/wireless/ath/ath9k/hw.c
4230 index 03900ca..7c2f06e 100644
4231 --- a/drivers/net/wireless/ath/ath9k/hw.c
4232 +++ b/drivers/net/wireless/ath/ath9k/hw.c
4233 @@ -1931,6 +1931,10 @@ int ath9k_hw_fill_cap_info(struct ath_hw *ah)
4234 pCap->num_gpio_pins = AR9271_NUM_GPIO;
4235 else if (AR_DEVID_7010(ah))
4236 pCap->num_gpio_pins = AR7010_NUM_GPIO;
4237 + else if (AR_SREV_9300_20_OR_LATER(ah))
4238 + pCap->num_gpio_pins = AR9300_NUM_GPIO;
4239 + else if (AR_SREV_9287_11_OR_LATER(ah))
4240 + pCap->num_gpio_pins = AR9287_NUM_GPIO;
4241 else if (AR_SREV_9285_12_OR_LATER(ah))
4242 pCap->num_gpio_pins = AR9285_NUM_GPIO;
4243 else if (AR_SREV_9280_20_OR_LATER(ah))
4244 diff --git a/drivers/net/wireless/ath/ath9k/recv.c b/drivers/net/wireless/ath/ath9k/recv.c
4245 index 07e35e5..3b5f9d6 100644
4246 --- a/drivers/net/wireless/ath/ath9k/recv.c
4247 +++ b/drivers/net/wireless/ath/ath9k/recv.c
4248 @@ -423,12 +423,9 @@ void ath_rx_cleanup(struct ath_softc *sc)
4249
4250 u32 ath_calcrxfilter(struct ath_softc *sc)
4251 {
4252 -#define RX_FILTER_PRESERVE (ATH9K_RX_FILTER_PHYERR | ATH9K_RX_FILTER_PHYRADAR)
4253 -
4254 u32 rfilt;
4255
4256 - rfilt = (ath9k_hw_getrxfilter(sc->sc_ah) & RX_FILTER_PRESERVE)
4257 - | ATH9K_RX_FILTER_UCAST | ATH9K_RX_FILTER_BCAST
4258 + rfilt = ATH9K_RX_FILTER_UCAST | ATH9K_RX_FILTER_BCAST
4259 | ATH9K_RX_FILTER_MCAST;
4260
4261 if (sc->rx.rxfilter & FIF_PROBE_REQ)
4262 diff --git a/drivers/net/wireless/iwlwifi/iwl-agn-ucode.c b/drivers/net/wireless/iwlwifi/iwl-agn-ucode.c
4263 index 97de5d9..a03dbcc 100644
4264 --- a/drivers/net/wireless/iwlwifi/iwl-agn-ucode.c
4265 +++ b/drivers/net/wireless/iwlwifi/iwl-agn-ucode.c
4266 @@ -144,13 +144,8 @@ static int iwlagn_load_section(struct iwl_priv *priv, const char *name,
4267 FH_TCSR_TX_CONFIG_REG_VAL_CIRQ_HOST_ENDTFD);
4268
4269 IWL_DEBUG_INFO(priv, "%s uCode section being loaded...\n", name);
4270 - ret = wait_event_interruptible_timeout(priv->wait_command_queue,
4271 - priv->ucode_write_complete, 5 * HZ);
4272 - if (ret == -ERESTARTSYS) {
4273 - IWL_ERR(priv, "Could not load the %s uCode section due "
4274 - "to interrupt\n", name);
4275 - return ret;
4276 - }
4277 + ret = wait_event_timeout(priv->wait_command_queue,
4278 + priv->ucode_write_complete, 5 * HZ);
4279 if (!ret) {
4280 IWL_ERR(priv, "Could not load the %s uCode section\n",
4281 name);
4282 diff --git a/drivers/net/wireless/iwlwifi/iwl-agn.c b/drivers/net/wireless/iwlwifi/iwl-agn.c
4283 index f24165d..baec52d 100644
4284 --- a/drivers/net/wireless/iwlwifi/iwl-agn.c
4285 +++ b/drivers/net/wireless/iwlwifi/iwl-agn.c
4286 @@ -797,7 +797,7 @@ static void iwl_irq_tasklet(struct iwl_priv *priv)
4287 handled |= CSR_INT_BIT_FH_TX;
4288 /* Wake up uCode load routine, now that load is complete */
4289 priv->ucode_write_complete = 1;
4290 - wake_up_interruptible(&priv->wait_command_queue);
4291 + wake_up(&priv->wait_command_queue);
4292 }
4293
4294 if (inta & ~handled) {
4295 diff --git a/drivers/net/wireless/iwlwifi/iwl-core.c b/drivers/net/wireless/iwlwifi/iwl-core.c
4296 index 45cc51c..5638407 100644
4297 --- a/drivers/net/wireless/iwlwifi/iwl-core.c
4298 +++ b/drivers/net/wireless/iwlwifi/iwl-core.c
4299 @@ -899,7 +899,7 @@ void iwlagn_fw_error(struct iwl_priv *priv, bool ondemand)
4300 * commands by clearing the ready bit */
4301 clear_bit(STATUS_READY, &priv->status);
4302
4303 - wake_up_interruptible(&priv->wait_command_queue);
4304 + wake_up(&priv->wait_command_queue);
4305
4306 if (!ondemand) {
4307 /*
4308 @@ -950,7 +950,7 @@ void iwl_irq_handle_error(struct iwl_priv *priv)
4309 */
4310 clear_bit(STATUS_READY, &priv->status);
4311 clear_bit(STATUS_HCMD_ACTIVE, &priv->status);
4312 - wake_up_interruptible(&priv->wait_command_queue);
4313 + wake_up(&priv->wait_command_queue);
4314 IWL_ERR(priv, "RF is used by WiMAX\n");
4315 return;
4316 }
4317 diff --git a/drivers/net/wireless/iwlwifi/iwl-hcmd.c b/drivers/net/wireless/iwlwifi/iwl-hcmd.c
4318 index 76f9966..fc11277 100644
4319 --- a/drivers/net/wireless/iwlwifi/iwl-hcmd.c
4320 +++ b/drivers/net/wireless/iwlwifi/iwl-hcmd.c
4321 @@ -194,7 +194,7 @@ int iwl_send_cmd_sync(struct iwl_priv *priv, struct iwl_host_cmd *cmd)
4322 return ret;
4323 }
4324
4325 - ret = wait_event_interruptible_timeout(priv->wait_command_queue,
4326 + ret = wait_event_timeout(priv->wait_command_queue,
4327 !test_bit(STATUS_HCMD_ACTIVE, &priv->status),
4328 HOST_COMPLETE_TIMEOUT);
4329 if (!ret) {
4330 diff --git a/drivers/net/wireless/iwlwifi/iwl-rx.c b/drivers/net/wireless/iwlwifi/iwl-rx.c
4331 index b774517..865ac1a 100644
4332 --- a/drivers/net/wireless/iwlwifi/iwl-rx.c
4333 +++ b/drivers/net/wireless/iwlwifi/iwl-rx.c
4334 @@ -738,7 +738,7 @@ static void iwl_rx_card_state_notif(struct iwl_priv *priv,
4335 wiphy_rfkill_set_hw_state(priv->hw->wiphy,
4336 test_bit(STATUS_RF_KILL_HW, &priv->status));
4337 else
4338 - wake_up_interruptible(&priv->wait_command_queue);
4339 + wake_up(&priv->wait_command_queue);
4340 }
4341
4342 static void iwl_rx_missed_beacon_notif(struct iwl_priv *priv,
4343 diff --git a/drivers/net/wireless/iwlwifi/iwl-tx.c b/drivers/net/wireless/iwlwifi/iwl-tx.c
4344 index c368c50..93152c3 100644
4345 --- a/drivers/net/wireless/iwlwifi/iwl-tx.c
4346 +++ b/drivers/net/wireless/iwlwifi/iwl-tx.c
4347 @@ -821,7 +821,7 @@ void iwl_tx_cmd_complete(struct iwl_priv *priv, struct iwl_rx_mem_buffer *rxb)
4348 clear_bit(STATUS_HCMD_ACTIVE, &priv->status);
4349 IWL_DEBUG_INFO(priv, "Clearing HCMD_ACTIVE for command %s\n",
4350 get_cmd_string(cmd->hdr.cmd));
4351 - wake_up_interruptible(&priv->wait_command_queue);
4352 + wake_up(&priv->wait_command_queue);
4353 }
4354
4355 /* Mark as unmapped */
4356 diff --git a/drivers/net/wireless/wl12xx/scan.c b/drivers/net/wireless/wl12xx/scan.c
4357 index 56f76ab..9542e46 100644
4358 --- a/drivers/net/wireless/wl12xx/scan.c
4359 +++ b/drivers/net/wireless/wl12xx/scan.c
4360 @@ -83,14 +83,18 @@ static int wl1271_get_scan_channels(struct wl1271 *wl,
4361 for (i = 0, j = 0;
4362 i < req->n_channels && j < WL1271_SCAN_MAX_CHANNELS;
4363 i++) {
4364 -
4365 flags = req->channels[i]->flags;
4366
4367 if (!test_bit(i, wl->scan.scanned_ch) &&
4368 !(flags & IEEE80211_CHAN_DISABLED) &&
4369 - ((!!(flags & IEEE80211_CHAN_PASSIVE_SCAN)) == passive) &&
4370 - (req->channels[i]->band == band)) {
4371 -
4372 + (req->channels[i]->band == band) &&
4373 + /*
4374 + * In passive scans, we scan all remaining
4375 + * channels, even if not marked as such.
4376 + * In active scans, we only scan channels not
4377 + * marked as passive.
4378 + */
4379 + (passive || !(flags & IEEE80211_CHAN_PASSIVE_SCAN))) {
4380 wl1271_debug(DEBUG_SCAN, "band %d, center_freq %d ",
4381 req->channels[i]->band,
4382 req->channels[i]->center_freq);
4383 @@ -142,6 +146,10 @@ static int wl1271_scan_send(struct wl1271 *wl, enum ieee80211_band band,
4384 int ret;
4385 u16 scan_options = 0;
4386
4387 + /* skip active scans if we don't have SSIDs */
4388 + if (!passive && wl->scan.req->n_ssids == 0)
4389 + return WL1271_NOTHING_TO_SCAN;
4390 +
4391 cmd = kzalloc(sizeof(*cmd), GFP_KERNEL);
4392 trigger = kzalloc(sizeof(*trigger), GFP_KERNEL);
4393 if (!cmd || !trigger) {
4394 @@ -152,8 +160,7 @@ static int wl1271_scan_send(struct wl1271 *wl, enum ieee80211_band band,
4395 /* We always use high priority scans */
4396 scan_options = WL1271_SCAN_OPT_PRIORITY_HIGH;
4397
4398 - /* No SSIDs means that we have a forced passive scan */
4399 - if (passive || wl->scan.req->n_ssids == 0)
4400 + if (passive)
4401 scan_options |= WL1271_SCAN_OPT_PASSIVE;
4402
4403 cmd->params.scan_options = cpu_to_le16(scan_options);
4404 diff --git a/drivers/net/xen-netback/interface.c b/drivers/net/xen-netback/interface.c
4405 index 0ca86f9..1825629 100644
4406 --- a/drivers/net/xen-netback/interface.c
4407 +++ b/drivers/net/xen-netback/interface.c
4408 @@ -327,12 +327,12 @@ int xenvif_connect(struct xenvif *vif, unsigned long tx_ring_ref,
4409 xenvif_get(vif);
4410
4411 rtnl_lock();
4412 - if (netif_running(vif->dev))
4413 - xenvif_up(vif);
4414 if (!vif->can_sg && vif->dev->mtu > ETH_DATA_LEN)
4415 dev_set_mtu(vif->dev, ETH_DATA_LEN);
4416 netdev_update_features(vif->dev);
4417 netif_carrier_on(vif->dev);
4418 + if (netif_running(vif->dev))
4419 + xenvif_up(vif);
4420 rtnl_unlock();
4421
4422 return 0;
4423 diff --git a/drivers/pci/quirks.c b/drivers/pci/quirks.c
4424 index 1196f61..cec4629 100644
4425 --- a/drivers/pci/quirks.c
4426 +++ b/drivers/pci/quirks.c
4427 @@ -2745,20 +2745,6 @@ static void ricoh_mmc_fixup_r5c832(struct pci_dev *dev)
4428 /* disable must be done via function #0 */
4429 if (PCI_FUNC(dev->devfn))
4430 return;
4431 -
4432 - pci_read_config_byte(dev, 0xCB, &disable);
4433 -
4434 - if (disable & 0x02)
4435 - return;
4436 -
4437 - pci_read_config_byte(dev, 0xCA, &write_enable);
4438 - pci_write_config_byte(dev, 0xCA, 0x57);
4439 - pci_write_config_byte(dev, 0xCB, disable | 0x02);
4440 - pci_write_config_byte(dev, 0xCA, write_enable);
4441 -
4442 - dev_notice(&dev->dev, "proprietary Ricoh MMC controller disabled (via firewire function)\n");
4443 - dev_notice(&dev->dev, "MMC cards are now supported by standard SDHCI controller\n");
4444 -
4445 /*
4446 * RICOH 0xe823 SD/MMC card reader fails to recognize
4447 * certain types of SD/MMC cards. Lowering the SD base
4448 @@ -2781,6 +2767,20 @@ static void ricoh_mmc_fixup_r5c832(struct pci_dev *dev)
4449
4450 dev_notice(&dev->dev, "MMC controller base frequency changed to 50Mhz.\n");
4451 }
4452 +
4453 + pci_read_config_byte(dev, 0xCB, &disable);
4454 +
4455 + if (disable & 0x02)
4456 + return;
4457 +
4458 + pci_read_config_byte(dev, 0xCA, &write_enable);
4459 + pci_write_config_byte(dev, 0xCA, 0x57);
4460 + pci_write_config_byte(dev, 0xCB, disable | 0x02);
4461 + pci_write_config_byte(dev, 0xCA, write_enable);
4462 +
4463 + dev_notice(&dev->dev, "proprietary Ricoh MMC controller disabled (via firewire function)\n");
4464 + dev_notice(&dev->dev, "MMC cards are now supported by standard SDHCI controller\n");
4465 +
4466 }
4467 DECLARE_PCI_FIXUP_EARLY(PCI_VENDOR_ID_RICOH, PCI_DEVICE_ID_RICOH_R5C832, ricoh_mmc_fixup_r5c832);
4468 DECLARE_PCI_FIXUP_RESUME_EARLY(PCI_VENDOR_ID_RICOH, PCI_DEVICE_ID_RICOH_R5C832, ricoh_mmc_fixup_r5c832);
4469 diff --git a/drivers/pci/xen-pcifront.c b/drivers/pci/xen-pcifront.c
4470 index 492b7d8..d4e7a10 100644
4471 --- a/drivers/pci/xen-pcifront.c
4472 +++ b/drivers/pci/xen-pcifront.c
4473 @@ -400,9 +400,8 @@ static int pcifront_claim_resource(struct pci_dev *dev, void *data)
4474 dev_info(&pdev->xdev->dev, "claiming resource %s/%d\n",
4475 pci_name(dev), i);
4476 if (pci_claim_resource(dev, i)) {
4477 - dev_err(&pdev->xdev->dev, "Could not claim "
4478 - "resource %s/%d! Device offline. Try "
4479 - "giving less than 4GB to domain.\n",
4480 + dev_err(&pdev->xdev->dev, "Could not claim resource %s/%d! "
4481 + "Device offline. Try using e820_host=1 in the guest config.\n",
4482 pci_name(dev), i);
4483 }
4484 }
4485 diff --git a/drivers/platform/x86/samsung-laptop.c b/drivers/platform/x86/samsung-laptop.c
4486 index 1658575..ec85987 100644
4487 --- a/drivers/platform/x86/samsung-laptop.c
4488 +++ b/drivers/platform/x86/samsung-laptop.c
4489 @@ -370,15 +370,17 @@ static u8 read_brightness(void)
4490 &sretval);
4491 if (!retval) {
4492 user_brightness = sretval.retval[0];
4493 - if (user_brightness != 0)
4494 + if (user_brightness > sabi_config->min_brightness)
4495 user_brightness -= sabi_config->min_brightness;
4496 + else
4497 + user_brightness = 0;
4498 }
4499 return user_brightness;
4500 }
4501
4502 static void set_brightness(u8 user_brightness)
4503 {
4504 - u8 user_level = user_brightness - sabi_config->min_brightness;
4505 + u8 user_level = user_brightness + sabi_config->min_brightness;
4506
4507 sabi_set_command(sabi_config->commands.set_brightness, user_level);
4508 }
4509 @@ -631,6 +633,15 @@ static struct dmi_system_id __initdata samsung_dmi_table[] = {
4510 .callback = dmi_check_cb,
4511 },
4512 {
4513 + .ident = "R700",
4514 + .matches = {
4515 + DMI_MATCH(DMI_SYS_VENDOR, "SAMSUNG ELECTRONICS CO., LTD."),
4516 + DMI_MATCH(DMI_PRODUCT_NAME, "SR700"),
4517 + DMI_MATCH(DMI_BOARD_NAME, "SR700"),
4518 + },
4519 + .callback = dmi_check_cb,
4520 + },
4521 + {
4522 .ident = "R530/R730",
4523 .matches = {
4524 DMI_MATCH(DMI_SYS_VENDOR, "SAMSUNG ELECTRONICS CO., LTD."),
4525 @@ -676,6 +687,24 @@ static struct dmi_system_id __initdata samsung_dmi_table[] = {
4526 },
4527 .callback = dmi_check_cb,
4528 },
4529 + {
4530 + .ident = "X520",
4531 + .matches = {
4532 + DMI_MATCH(DMI_SYS_VENDOR, "SAMSUNG ELECTRONICS CO., LTD."),
4533 + DMI_MATCH(DMI_PRODUCT_NAME, "X520"),
4534 + DMI_MATCH(DMI_BOARD_NAME, "X520"),
4535 + },
4536 + .callback = dmi_check_cb,
4537 + },
4538 + {
4539 + .ident = "R528/R728",
4540 + .matches = {
4541 + DMI_MATCH(DMI_SYS_VENDOR, "SAMSUNG ELECTRONICS CO., LTD."),
4542 + DMI_MATCH(DMI_PRODUCT_NAME, "R528/R728"),
4543 + DMI_MATCH(DMI_BOARD_NAME, "R528/R728"),
4544 + },
4545 + .callback = dmi_check_cb,
4546 + },
4547 { },
4548 };
4549 MODULE_DEVICE_TABLE(dmi, samsung_dmi_table);
4550 @@ -760,7 +789,7 @@ static int __init samsung_init(void)
4551 sabi_iface = ioremap_nocache(ifaceP, 16);
4552 if (!sabi_iface) {
4553 pr_err("Can't remap %x\n", ifaceP);
4554 - goto exit;
4555 + goto error_no_signature;
4556 }
4557 if (debug) {
4558 printk(KERN_DEBUG "ifaceP = 0x%08x\n", ifaceP);
4559 @@ -792,7 +821,8 @@ static int __init samsung_init(void)
4560 /* create a backlight device to talk to this one */
4561 memset(&props, 0, sizeof(struct backlight_properties));
4562 props.type = BACKLIGHT_PLATFORM;
4563 - props.max_brightness = sabi_config->max_brightness;
4564 + props.max_brightness = sabi_config->max_brightness -
4565 + sabi_config->min_brightness;
4566 backlight_device = backlight_device_register("samsung", &sdev->dev,
4567 NULL, &backlight_ops,
4568 &props);
4569 @@ -811,7 +841,6 @@ static int __init samsung_init(void)
4570 if (retval)
4571 goto error_file_create;
4572
4573 -exit:
4574 return 0;
4575
4576 error_file_create:
4577 diff --git a/drivers/platform/x86/wmi.c b/drivers/platform/x86/wmi.c
4578 index f23d5a8..9b88be4 100644
4579 --- a/drivers/platform/x86/wmi.c
4580 +++ b/drivers/platform/x86/wmi.c
4581 @@ -754,9 +754,13 @@ static void wmi_free_devices(void)
4582 struct wmi_block *wblock, *next;
4583
4584 /* Delete devices for all the GUIDs */
4585 - list_for_each_entry_safe(wblock, next, &wmi_block_list, list)
4586 + list_for_each_entry_safe(wblock, next, &wmi_block_list, list) {
4587 + list_del(&wblock->list);
4588 if (wblock->dev.class)
4589 device_unregister(&wblock->dev);
4590 + else
4591 + kfree(wblock);
4592 + }
4593 }
4594
4595 static bool guid_already_parsed(const char *guid_string)
4596 diff --git a/drivers/power/ds2780_battery.c b/drivers/power/ds2780_battery.c
4597 index 1fefe82..91a783d 100644
4598 --- a/drivers/power/ds2780_battery.c
4599 +++ b/drivers/power/ds2780_battery.c
4600 @@ -39,6 +39,7 @@ struct ds2780_device_info {
4601 struct device *dev;
4602 struct power_supply bat;
4603 struct device *w1_dev;
4604 + struct task_struct *mutex_holder;
4605 };
4606
4607 enum current_types {
4608 @@ -49,8 +50,8 @@ enum current_types {
4609 static const char model[] = "DS2780";
4610 static const char manufacturer[] = "Maxim/Dallas";
4611
4612 -static inline struct ds2780_device_info *to_ds2780_device_info(
4613 - struct power_supply *psy)
4614 +static inline struct ds2780_device_info *
4615 +to_ds2780_device_info(struct power_supply *psy)
4616 {
4617 return container_of(psy, struct ds2780_device_info, bat);
4618 }
4619 @@ -60,17 +61,28 @@ static inline struct power_supply *to_power_supply(struct device *dev)
4620 return dev_get_drvdata(dev);
4621 }
4622
4623 -static inline int ds2780_read8(struct device *dev, u8 *val, int addr)
4624 +static inline int ds2780_battery_io(struct ds2780_device_info *dev_info,
4625 + char *buf, int addr, size_t count, int io)
4626 {
4627 - return w1_ds2780_io(dev, val, addr, sizeof(u8), 0);
4628 + if (dev_info->mutex_holder == current)
4629 + return w1_ds2780_io_nolock(dev_info->w1_dev, buf, addr, count, io);
4630 + else
4631 + return w1_ds2780_io(dev_info->w1_dev, buf, addr, count, io);
4632 +}
4633 +
4634 +static inline int ds2780_read8(struct ds2780_device_info *dev_info, u8 *val,
4635 + int addr)
4636 +{
4637 + return ds2780_battery_io(dev_info, val, addr, sizeof(u8), 0);
4638 }
4639
4640 -static int ds2780_read16(struct device *dev, s16 *val, int addr)
4641 +static int ds2780_read16(struct ds2780_device_info *dev_info, s16 *val,
4642 + int addr)
4643 {
4644 int ret;
4645 u8 raw[2];
4646
4647 - ret = w1_ds2780_io(dev, raw, addr, sizeof(u8) * 2, 0);
4648 + ret = ds2780_battery_io(dev_info, raw, addr, sizeof(raw), 0);
4649 if (ret < 0)
4650 return ret;
4651
4652 @@ -79,16 +91,16 @@ static int ds2780_read16(struct device *dev, s16 *val, int addr)
4653 return 0;
4654 }
4655
4656 -static inline int ds2780_read_block(struct device *dev, u8 *val, int addr,
4657 - size_t count)
4658 +static inline int ds2780_read_block(struct ds2780_device_info *dev_info,
4659 + u8 *val, int addr, size_t count)
4660 {
4661 - return w1_ds2780_io(dev, val, addr, count, 0);
4662 + return ds2780_battery_io(dev_info, val, addr, count, 0);
4663 }
4664
4665 -static inline int ds2780_write(struct device *dev, u8 *val, int addr,
4666 - size_t count)
4667 +static inline int ds2780_write(struct ds2780_device_info *dev_info, u8 *val,
4668 + int addr, size_t count)
4669 {
4670 - return w1_ds2780_io(dev, val, addr, count, 1);
4671 + return ds2780_battery_io(dev_info, val, addr, count, 1);
4672 }
4673
4674 static inline int ds2780_store_eeprom(struct device *dev, int addr)
4675 @@ -122,7 +134,7 @@ static int ds2780_set_sense_register(struct ds2780_device_info *dev_info,
4676 {
4677 int ret;
4678
4679 - ret = ds2780_write(dev_info->w1_dev, &conductance,
4680 + ret = ds2780_write(dev_info, &conductance,
4681 DS2780_RSNSP_REG, sizeof(u8));
4682 if (ret < 0)
4683 return ret;
4684 @@ -134,7 +146,7 @@ static int ds2780_set_sense_register(struct ds2780_device_info *dev_info,
4685 static int ds2780_get_rsgain_register(struct ds2780_device_info *dev_info,
4686 u16 *rsgain)
4687 {
4688 - return ds2780_read16(dev_info->w1_dev, rsgain, DS2780_RSGAIN_MSB_REG);
4689 + return ds2780_read16(dev_info, rsgain, DS2780_RSGAIN_MSB_REG);
4690 }
4691
4692 /* Set RSGAIN value from 0 to 1.999 in steps of 0.001 */
4693 @@ -144,8 +156,8 @@ static int ds2780_set_rsgain_register(struct ds2780_device_info *dev_info,
4694 int ret;
4695 u8 raw[] = {rsgain >> 8, rsgain & 0xFF};
4696
4697 - ret = ds2780_write(dev_info->w1_dev, raw,
4698 - DS2780_RSGAIN_MSB_REG, sizeof(u8) * 2);
4699 + ret = ds2780_write(dev_info, raw,
4700 + DS2780_RSGAIN_MSB_REG, sizeof(raw));
4701 if (ret < 0)
4702 return ret;
4703
4704 @@ -167,7 +179,7 @@ static int ds2780_get_voltage(struct ds2780_device_info *dev_info,
4705 * Bits 2 - 0 of the voltage value are in bits 7 - 5 of the
4706 * voltage LSB register
4707 */
4708 - ret = ds2780_read16(dev_info->w1_dev, &voltage_raw,
4709 + ret = ds2780_read16(dev_info, &voltage_raw,
4710 DS2780_VOLT_MSB_REG);
4711 if (ret < 0)
4712 return ret;
4713 @@ -196,7 +208,7 @@ static int ds2780_get_temperature(struct ds2780_device_info *dev_info,
4714 * Bits 2 - 0 of the temperature value are in bits 7 - 5 of the
4715 * temperature LSB register
4716 */
4717 - ret = ds2780_read16(dev_info->w1_dev, &temperature_raw,
4718 + ret = ds2780_read16(dev_info, &temperature_raw,
4719 DS2780_TEMP_MSB_REG);
4720 if (ret < 0)
4721 return ret;
4722 @@ -222,13 +234,13 @@ static int ds2780_get_current(struct ds2780_device_info *dev_info,
4723 * The units of measurement for current are dependent on the value of
4724 * the sense resistor.
4725 */
4726 - ret = ds2780_read8(dev_info->w1_dev, &sense_res_raw, DS2780_RSNSP_REG);
4727 + ret = ds2780_read8(dev_info, &sense_res_raw, DS2780_RSNSP_REG);
4728 if (ret < 0)
4729 return ret;
4730
4731 if (sense_res_raw == 0) {
4732 dev_err(dev_info->dev, "sense resistor value is 0\n");
4733 - return -ENXIO;
4734 + return -EINVAL;
4735 }
4736 sense_res = 1000 / sense_res_raw;
4737
4738 @@ -248,7 +260,7 @@ static int ds2780_get_current(struct ds2780_device_info *dev_info,
4739 * Bits 7 - 0 of the current value are in bits 7 - 0 of the current
4740 * LSB register
4741 */
4742 - ret = ds2780_read16(dev_info->w1_dev, &current_raw, reg_msb);
4743 + ret = ds2780_read16(dev_info, &current_raw, reg_msb);
4744 if (ret < 0)
4745 return ret;
4746
4747 @@ -267,7 +279,7 @@ static int ds2780_get_accumulated_current(struct ds2780_device_info *dev_info,
4748 * The units of measurement for accumulated current are dependent on
4749 * the value of the sense resistor.
4750 */
4751 - ret = ds2780_read8(dev_info->w1_dev, &sense_res_raw, DS2780_RSNSP_REG);
4752 + ret = ds2780_read8(dev_info, &sense_res_raw, DS2780_RSNSP_REG);
4753 if (ret < 0)
4754 return ret;
4755
4756 @@ -285,7 +297,7 @@ static int ds2780_get_accumulated_current(struct ds2780_device_info *dev_info,
4757 * Bits 7 - 0 of the ACR value are in bits 7 - 0 of the ACR
4758 * LSB register
4759 */
4760 - ret = ds2780_read16(dev_info->w1_dev, &current_raw, DS2780_ACR_MSB_REG);
4761 + ret = ds2780_read16(dev_info, &current_raw, DS2780_ACR_MSB_REG);
4762 if (ret < 0)
4763 return ret;
4764
4765 @@ -299,7 +311,7 @@ static int ds2780_get_capacity(struct ds2780_device_info *dev_info,
4766 int ret;
4767 u8 raw;
4768
4769 - ret = ds2780_read8(dev_info->w1_dev, &raw, DS2780_RARC_REG);
4770 + ret = ds2780_read8(dev_info, &raw, DS2780_RARC_REG);
4771 if (ret < 0)
4772 return ret;
4773
4774 @@ -345,7 +357,7 @@ static int ds2780_get_charge_now(struct ds2780_device_info *dev_info,
4775 * Bits 7 - 0 of the RAAC value are in bits 7 - 0 of the RAAC
4776 * LSB register
4777 */
4778 - ret = ds2780_read16(dev_info->w1_dev, &charge_raw, DS2780_RAAC_MSB_REG);
4779 + ret = ds2780_read16(dev_info, &charge_raw, DS2780_RAAC_MSB_REG);
4780 if (ret < 0)
4781 return ret;
4782
4783 @@ -356,7 +368,7 @@ static int ds2780_get_charge_now(struct ds2780_device_info *dev_info,
4784 static int ds2780_get_control_register(struct ds2780_device_info *dev_info,
4785 u8 *control_reg)
4786 {
4787 - return ds2780_read8(dev_info->w1_dev, control_reg, DS2780_CONTROL_REG);
4788 + return ds2780_read8(dev_info, control_reg, DS2780_CONTROL_REG);
4789 }
4790
4791 static int ds2780_set_control_register(struct ds2780_device_info *dev_info,
4792 @@ -364,7 +376,7 @@ static int ds2780_set_control_register(struct ds2780_device_info *dev_info,
4793 {
4794 int ret;
4795
4796 - ret = ds2780_write(dev_info->w1_dev, &control_reg,
4797 + ret = ds2780_write(dev_info, &control_reg,
4798 DS2780_CONTROL_REG, sizeof(u8));
4799 if (ret < 0)
4800 return ret;
4801 @@ -503,7 +515,7 @@ static ssize_t ds2780_get_sense_resistor_value(struct device *dev,
4802 struct power_supply *psy = to_power_supply(dev);
4803 struct ds2780_device_info *dev_info = to_ds2780_device_info(psy);
4804
4805 - ret = ds2780_read8(dev_info->w1_dev, &sense_resistor, DS2780_RSNSP_REG);
4806 + ret = ds2780_read8(dev_info, &sense_resistor, DS2780_RSNSP_REG);
4807 if (ret < 0)
4808 return ret;
4809
4810 @@ -584,7 +596,7 @@ static ssize_t ds2780_get_pio_pin(struct device *dev,
4811 struct power_supply *psy = to_power_supply(dev);
4812 struct ds2780_device_info *dev_info = to_ds2780_device_info(psy);
4813
4814 - ret = ds2780_read8(dev_info->w1_dev, &sfr, DS2780_SFR_REG);
4815 + ret = ds2780_read8(dev_info, &sfr, DS2780_SFR_REG);
4816 if (ret < 0)
4817 return ret;
4818
4819 @@ -611,7 +623,7 @@ static ssize_t ds2780_set_pio_pin(struct device *dev,
4820 return -EINVAL;
4821 }
4822
4823 - ret = ds2780_write(dev_info->w1_dev, &new_setting,
4824 + ret = ds2780_write(dev_info, &new_setting,
4825 DS2780_SFR_REG, sizeof(u8));
4826 if (ret < 0)
4827 return ret;
4828 @@ -632,7 +644,7 @@ static ssize_t ds2780_read_param_eeprom_bin(struct file *filp,
4829 DS2780_EEPROM_BLOCK1_END -
4830 DS2780_EEPROM_BLOCK1_START + 1 - off);
4831
4832 - return ds2780_read_block(dev_info->w1_dev, buf,
4833 + return ds2780_read_block(dev_info, buf,
4834 DS2780_EEPROM_BLOCK1_START + off, count);
4835 }
4836
4837 @@ -650,7 +662,7 @@ static ssize_t ds2780_write_param_eeprom_bin(struct file *filp,
4838 DS2780_EEPROM_BLOCK1_END -
4839 DS2780_EEPROM_BLOCK1_START + 1 - off);
4840
4841 - ret = ds2780_write(dev_info->w1_dev, buf,
4842 + ret = ds2780_write(dev_info, buf,
4843 DS2780_EEPROM_BLOCK1_START + off, count);
4844 if (ret < 0)
4845 return ret;
4846 @@ -685,9 +697,8 @@ static ssize_t ds2780_read_user_eeprom_bin(struct file *filp,
4847 DS2780_EEPROM_BLOCK0_END -
4848 DS2780_EEPROM_BLOCK0_START + 1 - off);
4849
4850 - return ds2780_read_block(dev_info->w1_dev, buf,
4851 + return ds2780_read_block(dev_info, buf,
4852 DS2780_EEPROM_BLOCK0_START + off, count);
4853 -
4854 }
4855
4856 static ssize_t ds2780_write_user_eeprom_bin(struct file *filp,
4857 @@ -704,7 +715,7 @@ static ssize_t ds2780_write_user_eeprom_bin(struct file *filp,
4858 DS2780_EEPROM_BLOCK0_END -
4859 DS2780_EEPROM_BLOCK0_START + 1 - off);
4860
4861 - ret = ds2780_write(dev_info->w1_dev, buf,
4862 + ret = ds2780_write(dev_info, buf,
4863 DS2780_EEPROM_BLOCK0_START + off, count);
4864 if (ret < 0)
4865 return ret;
4866 @@ -768,6 +779,7 @@ static int __devinit ds2780_battery_probe(struct platform_device *pdev)
4867 dev_info->bat.properties = ds2780_battery_props;
4868 dev_info->bat.num_properties = ARRAY_SIZE(ds2780_battery_props);
4869 dev_info->bat.get_property = ds2780_battery_get_property;
4870 + dev_info->mutex_holder = current;
4871
4872 ret = power_supply_register(&pdev->dev, &dev_info->bat);
4873 if (ret) {
4874 @@ -797,6 +809,8 @@ static int __devinit ds2780_battery_probe(struct platform_device *pdev)
4875 goto fail_remove_bin_file;
4876 }
4877
4878 + dev_info->mutex_holder = NULL;
4879 +
4880 return 0;
4881
4882 fail_remove_bin_file:
4883 @@ -816,6 +830,8 @@ static int __devexit ds2780_battery_remove(struct platform_device *pdev)
4884 {
4885 struct ds2780_device_info *dev_info = platform_get_drvdata(pdev);
4886
4887 + dev_info->mutex_holder = current;
4888 +
4889 /* remove attributes */
4890 sysfs_remove_group(&dev_info->bat.dev->kobj, &ds2780_attr_group);
4891
4892 diff --git a/drivers/s390/cio/ccwgroup.c b/drivers/s390/cio/ccwgroup.c
4893 index 5c56741..cda9bd6 100644
4894 --- a/drivers/s390/cio/ccwgroup.c
4895 +++ b/drivers/s390/cio/ccwgroup.c
4896 @@ -87,6 +87,12 @@ static void __ccwgroup_remove_cdev_refs(struct ccwgroup_device *gdev)
4897 }
4898 }
4899
4900 +static ssize_t ccwgroup_online_store(struct device *dev,
4901 + struct device_attribute *attr,
4902 + const char *buf, size_t count);
4903 +static ssize_t ccwgroup_online_show(struct device *dev,
4904 + struct device_attribute *attr,
4905 + char *buf);
4906 /*
4907 * Provide an 'ungroup' attribute so the user can remove group devices no
4908 * longer needed or accidentially created. Saves memory :)
4909 @@ -134,6 +140,20 @@ out:
4910 }
4911
4912 static DEVICE_ATTR(ungroup, 0200, NULL, ccwgroup_ungroup_store);
4913 +static DEVICE_ATTR(online, 0644, ccwgroup_online_show, ccwgroup_online_store);
4914 +
4915 +static struct attribute *ccwgroup_attrs[] = {
4916 + &dev_attr_online.attr,
4917 + &dev_attr_ungroup.attr,
4918 + NULL,
4919 +};
4920 +static struct attribute_group ccwgroup_attr_group = {
4921 + .attrs = ccwgroup_attrs,
4922 +};
4923 +static const struct attribute_group *ccwgroup_attr_groups[] = {
4924 + &ccwgroup_attr_group,
4925 + NULL,
4926 +};
4927
4928 static void
4929 ccwgroup_release (struct device *dev)
4930 @@ -293,25 +313,17 @@ int ccwgroup_create_from_string(struct device *root, unsigned int creator_id,
4931 }
4932
4933 dev_set_name(&gdev->dev, "%s", dev_name(&gdev->cdev[0]->dev));
4934 -
4935 + gdev->dev.groups = ccwgroup_attr_groups;
4936 rc = device_add(&gdev->dev);
4937 if (rc)
4938 goto error;
4939 get_device(&gdev->dev);
4940 - rc = device_create_file(&gdev->dev, &dev_attr_ungroup);
4941 -
4942 - if (rc) {
4943 - device_unregister(&gdev->dev);
4944 - goto error;
4945 - }
4946 -
4947 rc = __ccwgroup_create_symlinks(gdev);
4948 if (!rc) {
4949 mutex_unlock(&gdev->reg_mutex);
4950 put_device(&gdev->dev);
4951 return 0;
4952 }
4953 - device_remove_file(&gdev->dev, &dev_attr_ungroup);
4954 device_unregister(&gdev->dev);
4955 error:
4956 for (i = 0; i < num_devices; i++)
4957 @@ -423,7 +435,7 @@ ccwgroup_online_store (struct device *dev, struct device_attribute *attr, const
4958 int ret;
4959
4960 if (!dev->driver)
4961 - return -ENODEV;
4962 + return -EINVAL;
4963
4964 gdev = to_ccwgroupdev(dev);
4965 gdrv = to_ccwgroupdrv(dev->driver);
4966 @@ -456,8 +468,6 @@ ccwgroup_online_show (struct device *dev, struct device_attribute *attr, char *b
4967 return sprintf(buf, online ? "1\n" : "0\n");
4968 }
4969
4970 -static DEVICE_ATTR(online, 0644, ccwgroup_online_show, ccwgroup_online_store);
4971 -
4972 static int
4973 ccwgroup_probe (struct device *dev)
4974 {
4975 @@ -469,12 +479,7 @@ ccwgroup_probe (struct device *dev)
4976 gdev = to_ccwgroupdev(dev);
4977 gdrv = to_ccwgroupdrv(dev->driver);
4978
4979 - if ((ret = device_create_file(dev, &dev_attr_online)))
4980 - return ret;
4981 -
4982 ret = gdrv->probe ? gdrv->probe(gdev) : -ENODEV;
4983 - if (ret)
4984 - device_remove_file(dev, &dev_attr_online);
4985
4986 return ret;
4987 }
4988 @@ -485,9 +490,6 @@ ccwgroup_remove (struct device *dev)
4989 struct ccwgroup_device *gdev;
4990 struct ccwgroup_driver *gdrv;
4991
4992 - device_remove_file(dev, &dev_attr_online);
4993 - device_remove_file(dev, &dev_attr_ungroup);
4994 -
4995 if (!dev->driver)
4996 return 0;
4997
4998 diff --git a/drivers/scsi/device_handler/scsi_dh.c b/drivers/scsi/device_handler/scsi_dh.c
4999 index 0119b81..d973325 100644
5000 --- a/drivers/scsi/device_handler/scsi_dh.c
5001 +++ b/drivers/scsi/device_handler/scsi_dh.c
5002 @@ -398,7 +398,15 @@ int scsi_dh_activate(struct request_queue *q, activate_complete fn, void *data)
5003
5004 spin_lock_irqsave(q->queue_lock, flags);
5005 sdev = q->queuedata;
5006 - if (sdev && sdev->scsi_dh_data)
5007 + if (!sdev) {
5008 + spin_unlock_irqrestore(q->queue_lock, flags);
5009 + err = SCSI_DH_NOSYS;
5010 + if (fn)
5011 + fn(data, err);
5012 + return err;
5013 + }
5014 +
5015 + if (sdev->scsi_dh_data)
5016 scsi_dh = sdev->scsi_dh_data->scsi_dh;
5017 dev = get_device(&sdev->sdev_gendev);
5018 if (!scsi_dh || !dev ||
5019 diff --git a/drivers/scsi/hosts.c b/drivers/scsi/hosts.c
5020 index 4f7a582..351dc0b 100644
5021 --- a/drivers/scsi/hosts.c
5022 +++ b/drivers/scsi/hosts.c
5023 @@ -286,6 +286,7 @@ static void scsi_host_dev_release(struct device *dev)
5024 {
5025 struct Scsi_Host *shost = dev_to_shost(dev);
5026 struct device *parent = dev->parent;
5027 + struct request_queue *q;
5028
5029 scsi_proc_hostdir_rm(shost->hostt);
5030
5031 @@ -293,9 +294,11 @@ static void scsi_host_dev_release(struct device *dev)
5032 kthread_stop(shost->ehandler);
5033 if (shost->work_q)
5034 destroy_workqueue(shost->work_q);
5035 - if (shost->uspace_req_q) {
5036 - kfree(shost->uspace_req_q->queuedata);
5037 - scsi_free_queue(shost->uspace_req_q);
5038 + q = shost->uspace_req_q;
5039 + if (q) {
5040 + kfree(q->queuedata);
5041 + q->queuedata = NULL;
5042 + scsi_free_queue(q);
5043 }
5044
5045 scsi_destroy_command_freelist(shost);
5046 diff --git a/drivers/scsi/hpsa.c b/drivers/scsi/hpsa.c
5047 index 78c2e20..6689d5d 100644
5048 --- a/drivers/scsi/hpsa.c
5049 +++ b/drivers/scsi/hpsa.c
5050 @@ -3300,6 +3300,13 @@ static int hpsa_controller_hard_reset(struct pci_dev *pdev,
5051 pmcsr &= ~PCI_PM_CTRL_STATE_MASK;
5052 pmcsr |= PCI_D0;
5053 pci_write_config_word(pdev, pos + PCI_PM_CTRL, pmcsr);
5054 +
5055 + /*
5056 + * The P600 requires a small delay when changing states.
5057 + * Otherwise we may think the board did not reset and we bail.
5058 + * This for kdump only and is particular to the P600.
5059 + */
5060 + msleep(500);
5061 }
5062 return 0;
5063 }
5064 diff --git a/drivers/scsi/ipr.c b/drivers/scsi/ipr.c
5065 index 888086c..c5c7c3a 100644
5066 --- a/drivers/scsi/ipr.c
5067 +++ b/drivers/scsi/ipr.c
5068 @@ -8812,7 +8812,7 @@ static int __devinit ipr_probe_ioa(struct pci_dev *pdev,
5069 uproc = readl(ioa_cfg->regs.sense_uproc_interrupt_reg32);
5070 if ((mask & IPR_PCII_HRRQ_UPDATED) == 0 || (uproc & IPR_UPROCI_RESET_ALERT))
5071 ioa_cfg->needs_hard_reset = 1;
5072 - if (interrupts & IPR_PCII_ERROR_INTERRUPTS)
5073 + if ((interrupts & IPR_PCII_ERROR_INTERRUPTS) || reset_devices)
5074 ioa_cfg->needs_hard_reset = 1;
5075 if (interrupts & IPR_PCII_IOA_UNIT_CHECKED)
5076 ioa_cfg->ioa_unit_checked = 1;
5077 diff --git a/drivers/scsi/isci/isci.h b/drivers/scsi/isci/isci.h
5078 index d1de633..8efeb6b 100644
5079 --- a/drivers/scsi/isci/isci.h
5080 +++ b/drivers/scsi/isci/isci.h
5081 @@ -97,7 +97,7 @@
5082 #define SCU_MAX_COMPLETION_QUEUE_SHIFT (ilog2(SCU_MAX_COMPLETION_QUEUE_ENTRIES))
5083
5084 #define SCU_ABSOLUTE_MAX_UNSOLICITED_FRAMES (4096)
5085 -#define SCU_UNSOLICITED_FRAME_BUFFER_SIZE (1024)
5086 +#define SCU_UNSOLICITED_FRAME_BUFFER_SIZE (1024U)
5087 #define SCU_INVALID_FRAME_INDEX (0xFFFF)
5088
5089 #define SCU_IO_REQUEST_MAX_SGE_SIZE (0x00FFFFFF)
5090 diff --git a/drivers/scsi/isci/port_config.c b/drivers/scsi/isci/port_config.c
5091 index 486b113..38a99d2 100644
5092 --- a/drivers/scsi/isci/port_config.c
5093 +++ b/drivers/scsi/isci/port_config.c
5094 @@ -678,7 +678,7 @@ static void apc_agent_timeout(unsigned long data)
5095 configure_phy_mask = ~port_agent->phy_configured_mask & port_agent->phy_ready_mask;
5096
5097 if (!configure_phy_mask)
5098 - return;
5099 + goto done;
5100
5101 for (index = 0; index < SCI_MAX_PHYS; index++) {
5102 if ((configure_phy_mask & (1 << index)) == 0)
5103 diff --git a/drivers/scsi/isci/request.c b/drivers/scsi/isci/request.c
5104 index b5d3a8c..225b196 100644
5105 --- a/drivers/scsi/isci/request.c
5106 +++ b/drivers/scsi/isci/request.c
5107 @@ -1490,29 +1490,30 @@ sci_io_request_frame_handler(struct isci_request *ireq,
5108 return SCI_SUCCESS;
5109
5110 case SCI_REQ_SMP_WAIT_RESP: {
5111 - struct smp_resp *rsp_hdr = &ireq->smp.rsp;
5112 - void *frame_header;
5113 + struct sas_task *task = isci_request_access_task(ireq);
5114 + struct scatterlist *sg = &task->smp_task.smp_resp;
5115 + void *frame_header, *kaddr;
5116 + u8 *rsp;
5117
5118 sci_unsolicited_frame_control_get_header(&ihost->uf_control,
5119 - frame_index,
5120 - &frame_header);
5121 -
5122 - /* byte swap the header. */
5123 - word_cnt = SMP_RESP_HDR_SZ / sizeof(u32);
5124 - sci_swab32_cpy(rsp_hdr, frame_header, word_cnt);
5125 + frame_index,
5126 + &frame_header);
5127 + kaddr = kmap_atomic(sg_page(sg), KM_IRQ0);
5128 + rsp = kaddr + sg->offset;
5129 + sci_swab32_cpy(rsp, frame_header, 1);
5130
5131 - if (rsp_hdr->frame_type == SMP_RESPONSE) {
5132 + if (rsp[0] == SMP_RESPONSE) {
5133 void *smp_resp;
5134
5135 sci_unsolicited_frame_control_get_buffer(&ihost->uf_control,
5136 - frame_index,
5137 - &smp_resp);
5138 + frame_index,
5139 + &smp_resp);
5140
5141 - word_cnt = (sizeof(struct smp_resp) - SMP_RESP_HDR_SZ) /
5142 - sizeof(u32);
5143 -
5144 - sci_swab32_cpy(((u8 *) rsp_hdr) + SMP_RESP_HDR_SZ,
5145 - smp_resp, word_cnt);
5146 + word_cnt = (sg->length/4)-1;
5147 + if (word_cnt > 0)
5148 + word_cnt = min_t(unsigned int, word_cnt,
5149 + SCU_UNSOLICITED_FRAME_BUFFER_SIZE/4);
5150 + sci_swab32_cpy(rsp + 4, smp_resp, word_cnt);
5151
5152 ireq->scu_status = SCU_TASK_DONE_GOOD;
5153 ireq->sci_status = SCI_SUCCESS;
5154 @@ -1528,12 +1529,13 @@ sci_io_request_frame_handler(struct isci_request *ireq,
5155 __func__,
5156 ireq,
5157 frame_index,
5158 - rsp_hdr->frame_type);
5159 + rsp[0]);
5160
5161 ireq->scu_status = SCU_TASK_DONE_SMP_FRM_TYPE_ERR;
5162 ireq->sci_status = SCI_FAILURE_CONTROLLER_SPECIFIC_IO_ERR;
5163 sci_change_state(&ireq->sm, SCI_REQ_COMPLETED);
5164 }
5165 + kunmap_atomic(kaddr, KM_IRQ0);
5166
5167 sci_controller_release_frame(ihost, frame_index);
5168
5169 @@ -2603,18 +2605,7 @@ static void isci_request_io_request_complete(struct isci_host *ihost,
5170 status = SAM_STAT_GOOD;
5171 set_bit(IREQ_COMPLETE_IN_TARGET, &request->flags);
5172
5173 - if (task->task_proto == SAS_PROTOCOL_SMP) {
5174 - void *rsp = &request->smp.rsp;
5175 -
5176 - dev_dbg(&ihost->pdev->dev,
5177 - "%s: SMP protocol completion\n",
5178 - __func__);
5179 -
5180 - sg_copy_from_buffer(
5181 - &task->smp_task.smp_resp, 1,
5182 - rsp, sizeof(struct smp_resp));
5183 - } else if (completion_status
5184 - == SCI_IO_SUCCESS_IO_DONE_EARLY) {
5185 + if (completion_status == SCI_IO_SUCCESS_IO_DONE_EARLY) {
5186
5187 /* This was an SSP / STP / SATA transfer.
5188 * There is a possibility that less data than
5189 diff --git a/drivers/scsi/isci/request.h b/drivers/scsi/isci/request.h
5190 index 7a1d5a9..58d70b6 100644
5191 --- a/drivers/scsi/isci/request.h
5192 +++ b/drivers/scsi/isci/request.h
5193 @@ -174,9 +174,6 @@ struct isci_request {
5194 };
5195 } ssp;
5196 struct {
5197 - struct smp_resp rsp;
5198 - } smp;
5199 - struct {
5200 struct isci_stp_request req;
5201 struct host_to_dev_fis cmd;
5202 struct dev_to_host_fis rsp;
5203 diff --git a/drivers/scsi/isci/sas.h b/drivers/scsi/isci/sas.h
5204 index 462b151..dc26b4a 100644
5205 --- a/drivers/scsi/isci/sas.h
5206 +++ b/drivers/scsi/isci/sas.h
5207 @@ -204,8 +204,6 @@ struct smp_req {
5208 u8 req_data[0];
5209 } __packed;
5210
5211 -#define SMP_RESP_HDR_SZ 4
5212 -
5213 /*
5214 * struct sci_sas_address - This structure depicts how a SAS address is
5215 * represented by SCI.
5216 diff --git a/drivers/scsi/libsas/sas_expander.c b/drivers/scsi/libsas/sas_expander.c
5217 index 16ad97d..37cbe4d 100644
5218 --- a/drivers/scsi/libsas/sas_expander.c
5219 +++ b/drivers/scsi/libsas/sas_expander.c
5220 @@ -199,6 +199,8 @@ static void sas_set_ex_phy(struct domain_device *dev, int phy_id,
5221 phy->virtual = dr->virtual;
5222 phy->last_da_index = -1;
5223
5224 + phy->phy->identify.sas_address = SAS_ADDR(phy->attached_sas_addr);
5225 + phy->phy->identify.device_type = phy->attached_dev_type;
5226 phy->phy->identify.initiator_port_protocols = phy->attached_iproto;
5227 phy->phy->identify.target_port_protocols = phy->attached_tproto;
5228 phy->phy->identify.phy_identifier = phy_id;
5229 diff --git a/drivers/scsi/megaraid/megaraid_sas_base.c b/drivers/scsi/megaraid/megaraid_sas_base.c
5230 index 2d8cdce..e6e30f4 100644
5231 --- a/drivers/scsi/megaraid/megaraid_sas_base.c
5232 +++ b/drivers/scsi/megaraid/megaraid_sas_base.c
5233 @@ -1906,7 +1906,6 @@ static int megasas_generic_reset(struct scsi_cmnd *scmd)
5234 static enum
5235 blk_eh_timer_return megasas_reset_timer(struct scsi_cmnd *scmd)
5236 {
5237 - struct megasas_cmd *cmd = (struct megasas_cmd *)scmd->SCp.ptr;
5238 struct megasas_instance *instance;
5239 unsigned long flags;
5240
5241 @@ -1915,7 +1914,7 @@ blk_eh_timer_return megasas_reset_timer(struct scsi_cmnd *scmd)
5242 return BLK_EH_NOT_HANDLED;
5243 }
5244
5245 - instance = cmd->instance;
5246 + instance = (struct megasas_instance *)scmd->device->host->hostdata;
5247 if (!(instance->flag & MEGASAS_FW_BUSY)) {
5248 /* FW is busy, throttle IO */
5249 spin_lock_irqsave(instance->host->host_lock, flags);
5250 diff --git a/drivers/scsi/mpt2sas/mpt2sas_scsih.c b/drivers/scsi/mpt2sas/mpt2sas_scsih.c
5251 index 8dc2ad4..5690f09 100644
5252 --- a/drivers/scsi/mpt2sas/mpt2sas_scsih.c
5253 +++ b/drivers/scsi/mpt2sas/mpt2sas_scsih.c
5254 @@ -7318,22 +7318,27 @@ _scsih_probe_sas(struct MPT2SAS_ADAPTER *ioc)
5255 /* SAS Device List */
5256 list_for_each_entry_safe(sas_device, next, &ioc->sas_device_init_list,
5257 list) {
5258 - spin_lock_irqsave(&ioc->sas_device_lock, flags);
5259 - list_move_tail(&sas_device->list, &ioc->sas_device_list);
5260 - spin_unlock_irqrestore(&ioc->sas_device_lock, flags);
5261
5262 if (ioc->hide_drives)
5263 continue;
5264
5265 if (!mpt2sas_transport_port_add(ioc, sas_device->handle,
5266 sas_device->sas_address_parent)) {
5267 - _scsih_sas_device_remove(ioc, sas_device);
5268 + list_del(&sas_device->list);
5269 + kfree(sas_device);
5270 + continue;
5271 } else if (!sas_device->starget) {
5272 mpt2sas_transport_port_remove(ioc,
5273 sas_device->sas_address,
5274 sas_device->sas_address_parent);
5275 - _scsih_sas_device_remove(ioc, sas_device);
5276 + list_del(&sas_device->list);
5277 + kfree(sas_device);
5278 + continue;
5279 +
5280 }
5281 + spin_lock_irqsave(&ioc->sas_device_lock, flags);
5282 + list_move_tail(&sas_device->list, &ioc->sas_device_list);
5283 + spin_unlock_irqrestore(&ioc->sas_device_lock, flags);
5284 }
5285 }
5286
5287 diff --git a/drivers/scsi/scsi_lib.c b/drivers/scsi/scsi_lib.c
5288 index 28d9c9d..f97acff 100644
5289 --- a/drivers/scsi/scsi_lib.c
5290 +++ b/drivers/scsi/scsi_lib.c
5291 @@ -1697,6 +1697,15 @@ struct request_queue *scsi_alloc_queue(struct scsi_device *sdev)
5292
5293 void scsi_free_queue(struct request_queue *q)
5294 {
5295 + unsigned long flags;
5296 +
5297 + WARN_ON(q->queuedata);
5298 +
5299 + /* cause scsi_request_fn() to kill all non-finished requests */
5300 + spin_lock_irqsave(q->queue_lock, flags);
5301 + q->request_fn(q);
5302 + spin_unlock_irqrestore(q->queue_lock, flags);
5303 +
5304 blk_cleanup_queue(q);
5305 }
5306
5307 diff --git a/drivers/scsi/scsi_scan.c b/drivers/scsi/scsi_scan.c
5308 index 44e8ca3..72273a0 100644
5309 --- a/drivers/scsi/scsi_scan.c
5310 +++ b/drivers/scsi/scsi_scan.c
5311 @@ -322,6 +322,7 @@ out_device_destroy:
5312 scsi_device_set_state(sdev, SDEV_DEL);
5313 transport_destroy_device(&sdev->sdev_gendev);
5314 put_device(&sdev->sdev_dev);
5315 + scsi_free_queue(sdev->request_queue);
5316 put_device(&sdev->sdev_gendev);
5317 out:
5318 if (display_failure_msg)
5319 diff --git a/drivers/scsi/st.c b/drivers/scsi/st.c
5320 index 1871b8a..9b28f39 100644
5321 --- a/drivers/scsi/st.c
5322 +++ b/drivers/scsi/st.c
5323 @@ -462,14 +462,16 @@ static void st_scsi_execute_end(struct request *req, int uptodate)
5324 {
5325 struct st_request *SRpnt = req->end_io_data;
5326 struct scsi_tape *STp = SRpnt->stp;
5327 + struct bio *tmp;
5328
5329 STp->buffer->cmdstat.midlevel_result = SRpnt->result = req->errors;
5330 STp->buffer->cmdstat.residual = req->resid_len;
5331
5332 + tmp = SRpnt->bio;
5333 if (SRpnt->waiting)
5334 complete(SRpnt->waiting);
5335
5336 - blk_rq_unmap_user(SRpnt->bio);
5337 + blk_rq_unmap_user(tmp);
5338 __blk_put_request(req->q, req);
5339 }
5340
5341 diff --git a/drivers/staging/hv/hyperv_storage.h b/drivers/staging/hv/hyperv_storage.h
5342 index a01f9a0..5af82f4 100644
5343 --- a/drivers/staging/hv/hyperv_storage.h
5344 +++ b/drivers/staging/hv/hyperv_storage.h
5345 @@ -218,6 +218,7 @@ struct vstor_packet {
5346 #define STORVSC_MAX_LUNS_PER_TARGET 64
5347 #define STORVSC_MAX_TARGETS 1
5348 #define STORVSC_MAX_CHANNELS 1
5349 +#define STORVSC_MAX_CMD_LEN 16
5350
5351 struct hv_storvsc_request;
5352
5353 diff --git a/drivers/staging/hv/storvsc_drv.c b/drivers/staging/hv/storvsc_drv.c
5354 index cb4a25b..734076b 100644
5355 --- a/drivers/staging/hv/storvsc_drv.c
5356 +++ b/drivers/staging/hv/storvsc_drv.c
5357 @@ -729,6 +729,8 @@ static int storvsc_probe(struct hv_device *device)
5358 host->max_id = STORVSC_MAX_TARGETS;
5359 /* max # of channels */
5360 host->max_channel = STORVSC_MAX_CHANNELS - 1;
5361 + /* max cmd length */
5362 + host->max_cmd_len = STORVSC_MAX_CMD_LEN;
5363
5364 /* Register the HBA and start the scsi bus scan */
5365 ret = scsi_add_host(host, &device->device);
5366 diff --git a/drivers/staging/quatech_usb2/quatech_usb2.c b/drivers/staging/quatech_usb2/quatech_usb2.c
5367 index ca098ca..02fafec 100644
5368 --- a/drivers/staging/quatech_usb2/quatech_usb2.c
5369 +++ b/drivers/staging/quatech_usb2/quatech_usb2.c
5370 @@ -916,9 +916,10 @@ static int qt2_ioctl(struct tty_struct *tty,
5371 dbg("%s() port %d, cmd == TIOCMIWAIT enter",
5372 __func__, port->number);
5373 prev_msr_value = port_extra->shadowMSR & QT2_SERIAL_MSR_MASK;
5374 + barrier();
5375 + __set_current_state(TASK_INTERRUPTIBLE);
5376 while (1) {
5377 add_wait_queue(&port_extra->wait, &wait);
5378 - set_current_state(TASK_INTERRUPTIBLE);
5379 schedule();
5380 dbg("%s(): port %d, cmd == TIOCMIWAIT here\n",
5381 __func__, port->number);
5382 @@ -926,9 +927,12 @@ static int qt2_ioctl(struct tty_struct *tty,
5383 /* see if a signal woke us up */
5384 if (signal_pending(current))
5385 return -ERESTARTSYS;
5386 + set_current_state(TASK_INTERRUPTIBLE);
5387 msr_value = port_extra->shadowMSR & QT2_SERIAL_MSR_MASK;
5388 - if (msr_value == prev_msr_value)
5389 + if (msr_value == prev_msr_value) {
5390 + __set_current_state(TASK_RUNNING);
5391 return -EIO; /* no change - error */
5392 + }
5393 if ((arg & TIOCM_RNG &&
5394 ((prev_msr_value & QT2_SERIAL_MSR_RI) ==
5395 (msr_value & QT2_SERIAL_MSR_RI))) ||
5396 @@ -941,6 +945,7 @@ static int qt2_ioctl(struct tty_struct *tty,
5397 (arg & TIOCM_CTS &&
5398 ((prev_msr_value & QT2_SERIAL_MSR_CTS) ==
5399 (msr_value & QT2_SERIAL_MSR_CTS)))) {
5400 + __set_current_state(TASK_RUNNING);
5401 return 0;
5402 }
5403 } /* end inifinite while */
5404 diff --git a/drivers/staging/serqt_usb2/serqt_usb2.c b/drivers/staging/serqt_usb2/serqt_usb2.c
5405 index 12f5eba..48aa61e 100644
5406 --- a/drivers/staging/serqt_usb2/serqt_usb2.c
5407 +++ b/drivers/staging/serqt_usb2/serqt_usb2.c
5408 @@ -24,7 +24,6 @@ static int debug;
5409 #define DRIVER_DESC "Quatech USB to Serial Driver"
5410
5411 #define USB_VENDOR_ID_QUATECH 0x061d /* Quatech VID */
5412 -#define QUATECH_SSU100 0xC020 /* SSU100 */
5413 #define QUATECH_SSU200 0xC030 /* SSU200 */
5414 #define QUATECH_DSU100 0xC040 /* DSU100 */
5415 #define QUATECH_DSU200 0xC050 /* DSU200 */
5416 @@ -127,7 +126,6 @@ static int debug;
5417 #define RS232_MODE 0x00
5418
5419 static const struct usb_device_id serqt_id_table[] = {
5420 - {USB_DEVICE(USB_VENDOR_ID_QUATECH, QUATECH_SSU100)},
5421 {USB_DEVICE(USB_VENDOR_ID_QUATECH, QUATECH_SSU200)},
5422 {USB_DEVICE(USB_VENDOR_ID_QUATECH, QUATECH_DSU100)},
5423 {USB_DEVICE(USB_VENDOR_ID_QUATECH, QUATECH_DSU200)},
5424 @@ -775,7 +773,6 @@ static int qt_startup(struct usb_serial *serial)
5425 }
5426
5427 switch (serial->dev->descriptor.idProduct) {
5428 - case QUATECH_SSU100:
5429 case QUATECH_DSU100:
5430 case QUATECH_QSU100:
5431 case QUATECH_ESU100A:
5432 diff --git a/drivers/target/loopback/tcm_loop.c b/drivers/target/loopback/tcm_loop.c
5433 index 70c2e7f..4b5421b 100644
5434 --- a/drivers/target/loopback/tcm_loop.c
5435 +++ b/drivers/target/loopback/tcm_loop.c
5436 @@ -127,6 +127,24 @@ static struct se_cmd *tcm_loop_allocate_core_cmd(
5437 set_host_byte(sc, DID_NO_CONNECT);
5438 return NULL;
5439 }
5440 + /*
5441 + * Because some userspace code via scsi-generic do not memset their
5442 + * associated read buffers, go ahead and do that here for type
5443 + * SCF_SCSI_CONTROL_SG_IO_CDB. Also note that this is currently
5444 + * guaranteed to be a single SGL for SCF_SCSI_CONTROL_SG_IO_CDB
5445 + * by target core in transport_generic_allocate_tasks() ->
5446 + * transport_generic_cmd_sequencer().
5447 + */
5448 + if (se_cmd->se_cmd_flags & SCF_SCSI_CONTROL_SG_IO_CDB &&
5449 + se_cmd->data_direction == DMA_FROM_DEVICE) {
5450 + struct scatterlist *sg = scsi_sglist(sc);
5451 + unsigned char *buf = kmap(sg_page(sg)) + sg->offset;
5452 +
5453 + if (buf != NULL) {
5454 + memset(buf, 0, sg->length);
5455 + kunmap(sg_page(sg));
5456 + }
5457 + }
5458
5459 transport_device_setup_cmd(se_cmd);
5460 return se_cmd;
5461 diff --git a/drivers/target/target_core_alua.c b/drivers/target/target_core_alua.c
5462 index 47abb42..86b3660 100644
5463 --- a/drivers/target/target_core_alua.c
5464 +++ b/drivers/target/target_core_alua.c
5465 @@ -60,11 +60,31 @@ int core_emulate_report_target_port_groups(struct se_cmd *cmd)
5466 unsigned char *buf = (unsigned char *)T_TASK(cmd)->t_task_buf;
5467 u32 rd_len = 0, off = 4; /* Skip over RESERVED area to first
5468 Target port group descriptor */
5469 + /*
5470 + * Need at least 4 bytes of response data or else we can't
5471 + * even fit the return data length.
5472 + */
5473 + if (cmd->data_length < 4) {
5474 + pr_warn("REPORT TARGET PORT GROUPS allocation length %u"
5475 + " too small\n", cmd->data_length);
5476 + return -EINVAL;
5477 + }
5478
5479 spin_lock(&T10_ALUA(su_dev)->tg_pt_gps_lock);
5480 list_for_each_entry(tg_pt_gp, &T10_ALUA(su_dev)->tg_pt_gps_list,
5481 tg_pt_gp_list) {
5482 /*
5483 + * Check if the Target port group and Target port descriptor list
5484 + * based on tg_pt_gp_members count will fit into the response payload.
5485 + * Otherwise, bump rd_len to let the initiator know we have exceeded
5486 + * the allocation length and the response is truncated.
5487 + */
5488 + if ((off + 8 + (tg_pt_gp->tg_pt_gp_members * 4)) >
5489 + cmd->data_length) {
5490 + rd_len += 8 + (tg_pt_gp->tg_pt_gp_members * 4);
5491 + continue;
5492 + }
5493 + /*
5494 * PREF: Preferred target port bit, determine if this
5495 * bit should be set for port group.
5496 */
5497 diff --git a/drivers/tty/pty.c b/drivers/tty/pty.c
5498 index e809e9d..e18604b 100644
5499 --- a/drivers/tty/pty.c
5500 +++ b/drivers/tty/pty.c
5501 @@ -670,12 +670,18 @@ static int ptmx_open(struct inode *inode, struct file *filp)
5502
5503 nonseekable_open(inode, filp);
5504
5505 + retval = tty_alloc_file(filp);
5506 + if (retval)
5507 + return retval;
5508 +
5509 /* find a device that is not in use. */
5510 tty_lock();
5511 index = devpts_new_index(inode);
5512 tty_unlock();
5513 - if (index < 0)
5514 - return index;
5515 + if (index < 0) {
5516 + retval = index;
5517 + goto err_file;
5518 + }
5519
5520 mutex_lock(&tty_mutex);
5521 tty_lock();
5522 @@ -689,27 +695,27 @@ static int ptmx_open(struct inode *inode, struct file *filp)
5523
5524 set_bit(TTY_PTY_LOCK, &tty->flags); /* LOCK THE SLAVE */
5525
5526 - retval = tty_add_file(tty, filp);
5527 - if (retval)
5528 - goto out;
5529 + tty_add_file(tty, filp);
5530
5531 retval = devpts_pty_new(inode, tty->link);
5532 if (retval)
5533 - goto out1;
5534 + goto err_release;
5535
5536 retval = ptm_driver->ops->open(tty, filp);
5537 if (retval)
5538 - goto out2;
5539 -out1:
5540 + goto err_release;
5541 +
5542 tty_unlock();
5543 - return retval;
5544 -out2:
5545 + return 0;
5546 +err_release:
5547 tty_unlock();
5548 tty_release(inode, filp);
5549 return retval;
5550 out:
5551 devpts_kill_index(inode, index);
5552 tty_unlock();
5553 +err_file:
5554 + tty_free_file(filp);
5555 return retval;
5556 }
5557
5558 diff --git a/drivers/tty/serial/crisv10.c b/drivers/tty/serial/crisv10.c
5559 index 225123b..58be715 100644
5560 --- a/drivers/tty/serial/crisv10.c
5561 +++ b/drivers/tty/serial/crisv10.c
5562 @@ -4450,7 +4450,7 @@ static int __init rs_init(void)
5563
5564 #if defined(CONFIG_ETRAX_RS485)
5565 #if defined(CONFIG_ETRAX_RS485_ON_PA)
5566 - if (cris_io_interface_allocate_pins(if_ser0, 'a', rs485_pa_bit,
5567 + if (cris_io_interface_allocate_pins(if_serial_0, 'a', rs485_pa_bit,
5568 rs485_pa_bit)) {
5569 printk(KERN_CRIT "ETRAX100LX serial: Could not allocate "
5570 "RS485 pin\n");
5571 @@ -4459,7 +4459,7 @@ static int __init rs_init(void)
5572 }
5573 #endif
5574 #if defined(CONFIG_ETRAX_RS485_ON_PORT_G)
5575 - if (cris_io_interface_allocate_pins(if_ser0, 'g', rs485_pa_bit,
5576 + if (cris_io_interface_allocate_pins(if_serial_0, 'g', rs485_pa_bit,
5577 rs485_port_g_bit)) {
5578 printk(KERN_CRIT "ETRAX100LX serial: Could not allocate "
5579 "RS485 pin\n");
5580 diff --git a/drivers/tty/serial/jsm/jsm.h b/drivers/tty/serial/jsm/jsm.h
5581 index b704c8c..5b837e7 100644
5582 --- a/drivers/tty/serial/jsm/jsm.h
5583 +++ b/drivers/tty/serial/jsm/jsm.h
5584 @@ -183,10 +183,8 @@ struct jsm_board
5585 /* Our Read/Error/Write queue sizes */
5586 #define RQUEUEMASK 0x1FFF /* 8 K - 1 */
5587 #define EQUEUEMASK 0x1FFF /* 8 K - 1 */
5588 -#define WQUEUEMASK 0x0FFF /* 4 K - 1 */
5589 #define RQUEUESIZE (RQUEUEMASK + 1)
5590 #define EQUEUESIZE RQUEUESIZE
5591 -#define WQUEUESIZE (WQUEUEMASK + 1)
5592
5593
5594 /************************************************************************
5595 @@ -226,10 +224,6 @@ struct jsm_channel {
5596 u16 ch_e_head; /* Head location of the error queue */
5597 u16 ch_e_tail; /* Tail location of the error queue */
5598
5599 - u8 *ch_wqueue; /* Our write queue buffer - malloc'ed */
5600 - u16 ch_w_head; /* Head location of the write queue */
5601 - u16 ch_w_tail; /* Tail location of the write queue */
5602 -
5603 u64 ch_rxcount; /* total of data received so far */
5604 u64 ch_txcount; /* total of data transmitted so far */
5605
5606 @@ -378,7 +372,6 @@ extern int jsm_debug;
5607 * Prototypes for non-static functions used in more than one module
5608 *
5609 *************************************************************************/
5610 -int jsm_tty_write(struct uart_port *port);
5611 int jsm_tty_init(struct jsm_board *);
5612 int jsm_uart_port_init(struct jsm_board *);
5613 int jsm_remove_uart_port(struct jsm_board *);
5614 diff --git a/drivers/tty/serial/jsm/jsm_driver.c b/drivers/tty/serial/jsm/jsm_driver.c
5615 index 96da178..2aaafa9 100644
5616 --- a/drivers/tty/serial/jsm/jsm_driver.c
5617 +++ b/drivers/tty/serial/jsm/jsm_driver.c
5618 @@ -211,7 +211,6 @@ static void __devexit jsm_remove_one(struct pci_dev *pdev)
5619 if (brd->channels[i]) {
5620 kfree(brd->channels[i]->ch_rqueue);
5621 kfree(brd->channels[i]->ch_equeue);
5622 - kfree(brd->channels[i]->ch_wqueue);
5623 kfree(brd->channels[i]);
5624 }
5625 }
5626 diff --git a/drivers/tty/serial/jsm/jsm_neo.c b/drivers/tty/serial/jsm/jsm_neo.c
5627 index 4538c3e..bd6e846 100644
5628 --- a/drivers/tty/serial/jsm/jsm_neo.c
5629 +++ b/drivers/tty/serial/jsm/jsm_neo.c
5630 @@ -496,12 +496,15 @@ static void neo_copy_data_from_queue_to_uart(struct jsm_channel *ch)
5631 int s;
5632 int qlen;
5633 u32 len_written = 0;
5634 + struct circ_buf *circ;
5635
5636 if (!ch)
5637 return;
5638
5639 + circ = &ch->uart_port.state->xmit;
5640 +
5641 /* No data to write to the UART */
5642 - if (ch->ch_w_tail == ch->ch_w_head)
5643 + if (uart_circ_empty(circ))
5644 return;
5645
5646 /* If port is "stopped", don't send any data to the UART */
5647 @@ -517,11 +520,10 @@ static void neo_copy_data_from_queue_to_uart(struct jsm_channel *ch)
5648 if (ch->ch_cached_lsr & UART_LSR_THRE) {
5649 ch->ch_cached_lsr &= ~(UART_LSR_THRE);
5650
5651 - writeb(ch->ch_wqueue[ch->ch_w_tail], &ch->ch_neo_uart->txrx);
5652 + writeb(circ->buf[circ->tail], &ch->ch_neo_uart->txrx);
5653 jsm_printk(WRITE, INFO, &ch->ch_bd->pci_dev,
5654 - "Tx data: %x\n", ch->ch_wqueue[ch->ch_w_head]);
5655 - ch->ch_w_tail++;
5656 - ch->ch_w_tail &= WQUEUEMASK;
5657 + "Tx data: %x\n", circ->buf[circ->head]);
5658 + circ->tail = (circ->tail + 1) & (UART_XMIT_SIZE - 1);
5659 ch->ch_txcount++;
5660 }
5661 return;
5662 @@ -536,36 +538,36 @@ static void neo_copy_data_from_queue_to_uart(struct jsm_channel *ch)
5663 n = UART_17158_TX_FIFOSIZE - ch->ch_t_tlevel;
5664
5665 /* cache head and tail of queue */
5666 - head = ch->ch_w_head & WQUEUEMASK;
5667 - tail = ch->ch_w_tail & WQUEUEMASK;
5668 - qlen = (head - tail) & WQUEUEMASK;
5669 + head = circ->head & (UART_XMIT_SIZE - 1);
5670 + tail = circ->tail & (UART_XMIT_SIZE - 1);
5671 + qlen = uart_circ_chars_pending(circ);
5672
5673 /* Find minimum of the FIFO space, versus queue length */
5674 n = min(n, qlen);
5675
5676 while (n > 0) {
5677
5678 - s = ((head >= tail) ? head : WQUEUESIZE) - tail;
5679 + s = ((head >= tail) ? head : UART_XMIT_SIZE) - tail;
5680 s = min(s, n);
5681
5682 if (s <= 0)
5683 break;
5684
5685 - memcpy_toio(&ch->ch_neo_uart->txrxburst, ch->ch_wqueue + tail, s);
5686 + memcpy_toio(&ch->ch_neo_uart->txrxburst, circ->buf + tail, s);
5687 /* Add and flip queue if needed */
5688 - tail = (tail + s) & WQUEUEMASK;
5689 + tail = (tail + s) & (UART_XMIT_SIZE - 1);
5690 n -= s;
5691 ch->ch_txcount += s;
5692 len_written += s;
5693 }
5694
5695 /* Update the final tail */
5696 - ch->ch_w_tail = tail & WQUEUEMASK;
5697 + circ->tail = tail & (UART_XMIT_SIZE - 1);
5698
5699 if (len_written >= ch->ch_t_tlevel)
5700 ch->ch_flags &= ~(CH_TX_FIFO_EMPTY | CH_TX_FIFO_LWM);
5701
5702 - if (!jsm_tty_write(&ch->uart_port))
5703 + if (uart_circ_empty(circ))
5704 uart_write_wakeup(&ch->uart_port);
5705 }
5706
5707 @@ -946,7 +948,6 @@ static void neo_param(struct jsm_channel *ch)
5708 if ((ch->ch_c_cflag & (CBAUD)) == 0) {
5709 ch->ch_r_head = ch->ch_r_tail = 0;
5710 ch->ch_e_head = ch->ch_e_tail = 0;
5711 - ch->ch_w_head = ch->ch_w_tail = 0;
5712
5713 neo_flush_uart_write(ch);
5714 neo_flush_uart_read(ch);
5715 diff --git a/drivers/tty/serial/jsm/jsm_tty.c b/drivers/tty/serial/jsm/jsm_tty.c
5716 index 7a4a914..434bd88 100644
5717 --- a/drivers/tty/serial/jsm/jsm_tty.c
5718 +++ b/drivers/tty/serial/jsm/jsm_tty.c
5719 @@ -118,6 +118,19 @@ static void jsm_tty_set_mctrl(struct uart_port *port, unsigned int mctrl)
5720 udelay(10);
5721 }
5722
5723 +/*
5724 + * jsm_tty_write()
5725 + *
5726 + * Take data from the user or kernel and send it out to the FEP.
5727 + * In here exists all the Transparent Print magic as well.
5728 + */
5729 +static void jsm_tty_write(struct uart_port *port)
5730 +{
5731 + struct jsm_channel *channel;
5732 + channel = container_of(port, struct jsm_channel, uart_port);
5733 + channel->ch_bd->bd_ops->copy_data_from_queue_to_uart(channel);
5734 +}
5735 +
5736 static void jsm_tty_start_tx(struct uart_port *port)
5737 {
5738 struct jsm_channel *channel = (struct jsm_channel *)port;
5739 @@ -216,14 +229,6 @@ static int jsm_tty_open(struct uart_port *port)
5740 return -ENOMEM;
5741 }
5742 }
5743 - if (!channel->ch_wqueue) {
5744 - channel->ch_wqueue = kzalloc(WQUEUESIZE, GFP_KERNEL);
5745 - if (!channel->ch_wqueue) {
5746 - jsm_printk(INIT, ERR, &channel->ch_bd->pci_dev,
5747 - "unable to allocate write queue buf");
5748 - return -ENOMEM;
5749 - }
5750 - }
5751
5752 channel->ch_flags &= ~(CH_OPENING);
5753 /*
5754 @@ -237,7 +242,6 @@ static int jsm_tty_open(struct uart_port *port)
5755 */
5756 channel->ch_r_head = channel->ch_r_tail = 0;
5757 channel->ch_e_head = channel->ch_e_tail = 0;
5758 - channel->ch_w_head = channel->ch_w_tail = 0;
5759
5760 brd->bd_ops->flush_uart_write(channel);
5761 brd->bd_ops->flush_uart_read(channel);
5762 @@ -836,75 +840,3 @@ void jsm_check_queue_flow_control(struct jsm_channel *ch)
5763 }
5764 }
5765 }
5766 -
5767 -/*
5768 - * jsm_tty_write()
5769 - *
5770 - * Take data from the user or kernel and send it out to the FEP.
5771 - * In here exists all the Transparent Print magic as well.
5772 - */
5773 -int jsm_tty_write(struct uart_port *port)
5774 -{
5775 - int bufcount;
5776 - int data_count = 0,data_count1 =0;
5777 - u16 head;
5778 - u16 tail;
5779 - u16 tmask;
5780 - u32 remain;
5781 - int temp_tail = port->state->xmit.tail;
5782 - struct jsm_channel *channel = (struct jsm_channel *)port;
5783 -
5784 - tmask = WQUEUEMASK;
5785 - head = (channel->ch_w_head) & tmask;
5786 - tail = (channel->ch_w_tail) & tmask;
5787 -
5788 - if ((bufcount = tail - head - 1) < 0)
5789 - bufcount += WQUEUESIZE;
5790 -
5791 - bufcount = min(bufcount, 56);
5792 - remain = WQUEUESIZE - head;
5793 -
5794 - data_count = 0;
5795 - if (bufcount >= remain) {
5796 - bufcount -= remain;
5797 - while ((port->state->xmit.head != temp_tail) &&
5798 - (data_count < remain)) {
5799 - channel->ch_wqueue[head++] =
5800 - port->state->xmit.buf[temp_tail];
5801 -
5802 - temp_tail++;
5803 - temp_tail &= (UART_XMIT_SIZE - 1);
5804 - data_count++;
5805 - }
5806 - if (data_count == remain) head = 0;
5807 - }
5808 -
5809 - data_count1 = 0;
5810 - if (bufcount > 0) {
5811 - remain = bufcount;
5812 - while ((port->state->xmit.head != temp_tail) &&
5813 - (data_count1 < remain)) {
5814 - channel->ch_wqueue[head++] =
5815 - port->state->xmit.buf[temp_tail];
5816 -
5817 - temp_tail++;
5818 - temp_tail &= (UART_XMIT_SIZE - 1);
5819 - data_count1++;
5820 -
5821 - }
5822 - }
5823 -
5824 - port->state->xmit.tail = temp_tail;
5825 -
5826 - data_count += data_count1;
5827 - if (data_count) {
5828 - head &= tmask;
5829 - channel->ch_w_head = head;
5830 - }
5831 -
5832 - if (data_count) {
5833 - channel->ch_bd->bd_ops->copy_data_from_queue_to_uart(channel);
5834 - }
5835 -
5836 - return data_count;
5837 -}
5838 diff --git a/drivers/tty/serial/pxa.c b/drivers/tty/serial/pxa.c
5839 index 4302e6e..81243a6 100644
5840 --- a/drivers/tty/serial/pxa.c
5841 +++ b/drivers/tty/serial/pxa.c
5842 @@ -100,6 +100,16 @@ static inline void receive_chars(struct uart_pxa_port *up, int *status)
5843 int max_count = 256;
5844
5845 do {
5846 + /* work around Errata #20 according to
5847 + * Intel(R) PXA27x Processor Family
5848 + * Specification Update (May 2005)
5849 + *
5850 + * Step 2
5851 + * Disable the Reciever Time Out Interrupt via IER[RTOEI]
5852 + */
5853 + up->ier &= ~UART_IER_RTOIE;
5854 + serial_out(up, UART_IER, up->ier);
5855 +
5856 ch = serial_in(up, UART_RX);
5857 flag = TTY_NORMAL;
5858 up->port.icount.rx++;
5859 @@ -156,6 +166,16 @@ static inline void receive_chars(struct uart_pxa_port *up, int *status)
5860 *status = serial_in(up, UART_LSR);
5861 } while ((*status & UART_LSR_DR) && (max_count-- > 0));
5862 tty_flip_buffer_push(tty);
5863 +
5864 + /* work around Errata #20 according to
5865 + * Intel(R) PXA27x Processor Family
5866 + * Specification Update (May 2005)
5867 + *
5868 + * Step 6:
5869 + * No more data in FIFO: Re-enable RTO interrupt via IER[RTOIE]
5870 + */
5871 + up->ier |= UART_IER_RTOIE;
5872 + serial_out(up, UART_IER, up->ier);
5873 }
5874
5875 static void transmit_chars(struct uart_pxa_port *up)
5876 diff --git a/drivers/tty/serial/serial_core.c b/drivers/tty/serial/serial_core.c
5877 index db7912c..6bc20d7 100644
5878 --- a/drivers/tty/serial/serial_core.c
5879 +++ b/drivers/tty/serial/serial_core.c
5880 @@ -2003,6 +2003,8 @@ int uart_resume_port(struct uart_driver *drv, struct uart_port *uport)
5881 if (port->tty && port->tty->termios && termios.c_cflag == 0)
5882 termios = *(port->tty->termios);
5883
5884 + if (console_suspend_enabled)
5885 + uart_change_pm(state, 0);
5886 uport->ops->set_termios(uport, &termios, NULL);
5887 if (console_suspend_enabled)
5888 console_start(uport->cons);
5889 diff --git a/drivers/tty/tty_io.c b/drivers/tty/tty_io.c
5890 index b6f92d3..b44aef0 100644
5891 --- a/drivers/tty/tty_io.c
5892 +++ b/drivers/tty/tty_io.c
5893 @@ -193,8 +193,7 @@ static inline struct tty_struct *file_tty(struct file *file)
5894 return ((struct tty_file_private *)file->private_data)->tty;
5895 }
5896
5897 -/* Associate a new file with the tty structure */
5898 -int tty_add_file(struct tty_struct *tty, struct file *file)
5899 +int tty_alloc_file(struct file *file)
5900 {
5901 struct tty_file_private *priv;
5902
5903 @@ -202,15 +201,36 @@ int tty_add_file(struct tty_struct *tty, struct file *file)
5904 if (!priv)
5905 return -ENOMEM;
5906
5907 + file->private_data = priv;
5908 +
5909 + return 0;
5910 +}
5911 +
5912 +/* Associate a new file with the tty structure */
5913 +void tty_add_file(struct tty_struct *tty, struct file *file)
5914 +{
5915 + struct tty_file_private *priv = file->private_data;
5916 +
5917 priv->tty = tty;
5918 priv->file = file;
5919 - file->private_data = priv;
5920
5921 spin_lock(&tty_files_lock);
5922 list_add(&priv->list, &tty->tty_files);
5923 spin_unlock(&tty_files_lock);
5924 +}
5925
5926 - return 0;
5927 +/**
5928 + * tty_free_file - free file->private_data
5929 + *
5930 + * This shall be used only for fail path handling when tty_add_file was not
5931 + * called yet.
5932 + */
5933 +void tty_free_file(struct file *file)
5934 +{
5935 + struct tty_file_private *priv = file->private_data;
5936 +
5937 + file->private_data = NULL;
5938 + kfree(priv);
5939 }
5940
5941 /* Delete file from its tty */
5942 @@ -221,8 +241,7 @@ void tty_del_file(struct file *file)
5943 spin_lock(&tty_files_lock);
5944 list_del(&priv->list);
5945 spin_unlock(&tty_files_lock);
5946 - file->private_data = NULL;
5947 - kfree(priv);
5948 + tty_free_file(file);
5949 }
5950
5951
5952 @@ -1811,6 +1830,10 @@ static int tty_open(struct inode *inode, struct file *filp)
5953 nonseekable_open(inode, filp);
5954
5955 retry_open:
5956 + retval = tty_alloc_file(filp);
5957 + if (retval)
5958 + return -ENOMEM;
5959 +
5960 noctty = filp->f_flags & O_NOCTTY;
5961 index = -1;
5962 retval = 0;
5963 @@ -1823,6 +1846,7 @@ retry_open:
5964 if (!tty) {
5965 tty_unlock();
5966 mutex_unlock(&tty_mutex);
5967 + tty_free_file(filp);
5968 return -ENXIO;
5969 }
5970 driver = tty_driver_kref_get(tty->driver);
5971 @@ -1855,6 +1879,7 @@ retry_open:
5972 }
5973 tty_unlock();
5974 mutex_unlock(&tty_mutex);
5975 + tty_free_file(filp);
5976 return -ENODEV;
5977 }
5978
5979 @@ -1862,6 +1887,7 @@ retry_open:
5980 if (!driver) {
5981 tty_unlock();
5982 mutex_unlock(&tty_mutex);
5983 + tty_free_file(filp);
5984 return -ENODEV;
5985 }
5986 got_driver:
5987 @@ -1872,6 +1898,8 @@ got_driver:
5988 if (IS_ERR(tty)) {
5989 tty_unlock();
5990 mutex_unlock(&tty_mutex);
5991 + tty_driver_kref_put(driver);
5992 + tty_free_file(filp);
5993 return PTR_ERR(tty);
5994 }
5995 }
5996 @@ -1887,15 +1915,11 @@ got_driver:
5997 tty_driver_kref_put(driver);
5998 if (IS_ERR(tty)) {
5999 tty_unlock();
6000 + tty_free_file(filp);
6001 return PTR_ERR(tty);
6002 }
6003
6004 - retval = tty_add_file(tty, filp);
6005 - if (retval) {
6006 - tty_unlock();
6007 - tty_release(inode, filp);
6008 - return retval;
6009 - }
6010 + tty_add_file(tty, filp);
6011
6012 check_tty_count(tty, "tty_open");
6013 if (tty->driver->type == TTY_DRIVER_TYPE_PTY &&
6014 diff --git a/drivers/usb/class/cdc-acm.c b/drivers/usb/class/cdc-acm.c
6015 index dac7676..5112f57 100644
6016 --- a/drivers/usb/class/cdc-acm.c
6017 +++ b/drivers/usb/class/cdc-acm.c
6018 @@ -1534,6 +1534,9 @@ static const struct usb_device_id acm_ids[] = {
6019 { NOKIA_PCSUITE_ACM_INFO(0x03cd), }, /* Nokia C7 */
6020 { SAMSUNG_PCSUITE_ACM_INFO(0x6651), }, /* Samsung GTi8510 (INNOV8) */
6021
6022 + /* Support for Owen devices */
6023 + { USB_DEVICE(0x03eb, 0x0030), }, /* Owen SI30 */
6024 +
6025 /* NOTE: non-Nokia COMM/ACM/0xff is likely MSFT RNDIS... NOT a modem! */
6026
6027 /* Support Lego NXT using pbLua firmware */
6028 diff --git a/drivers/usb/core/devio.c b/drivers/usb/core/devio.c
6029 index 37518df..0ca54e2 100644
6030 --- a/drivers/usb/core/devio.c
6031 +++ b/drivers/usb/core/devio.c
6032 @@ -407,7 +407,7 @@ static void async_completed(struct urb *urb)
6033 sinfo.si_errno = as->status;
6034 sinfo.si_code = SI_ASYNCIO;
6035 sinfo.si_addr = as->userurb;
6036 - pid = as->pid;
6037 + pid = get_pid(as->pid);
6038 uid = as->uid;
6039 euid = as->euid;
6040 secid = as->secid;
6041 @@ -422,9 +422,11 @@ static void async_completed(struct urb *urb)
6042 cancel_bulk_urbs(ps, as->bulk_addr);
6043 spin_unlock(&ps->lock);
6044
6045 - if (signr)
6046 + if (signr) {
6047 kill_pid_info_as_uid(sinfo.si_signo, &sinfo, pid, uid,
6048 euid, secid);
6049 + put_pid(pid);
6050 + }
6051
6052 wake_up(&ps->wait);
6053 }
6054 @@ -607,9 +609,10 @@ static int findintfep(struct usb_device *dev, unsigned int ep)
6055 }
6056
6057 static int check_ctrlrecip(struct dev_state *ps, unsigned int requesttype,
6058 - unsigned int index)
6059 + unsigned int request, unsigned int index)
6060 {
6061 int ret = 0;
6062 + struct usb_host_interface *alt_setting;
6063
6064 if (ps->dev->state != USB_STATE_UNAUTHENTICATED
6065 && ps->dev->state != USB_STATE_ADDRESS
6066 @@ -618,6 +621,19 @@ static int check_ctrlrecip(struct dev_state *ps, unsigned int requesttype,
6067 if (USB_TYPE_VENDOR == (USB_TYPE_MASK & requesttype))
6068 return 0;
6069
6070 + /*
6071 + * check for the special corner case 'get_device_id' in the printer
6072 + * class specification, where wIndex is (interface << 8 | altsetting)
6073 + * instead of just interface
6074 + */
6075 + if (requesttype == 0xa1 && request == 0) {
6076 + alt_setting = usb_find_alt_setting(ps->dev->actconfig,
6077 + index >> 8, index & 0xff);
6078 + if (alt_setting
6079 + && alt_setting->desc.bInterfaceClass == USB_CLASS_PRINTER)
6080 + index >>= 8;
6081 + }
6082 +
6083 index &= 0xff;
6084 switch (requesttype & USB_RECIP_MASK) {
6085 case USB_RECIP_ENDPOINT:
6086 @@ -770,7 +786,8 @@ static int proc_control(struct dev_state *ps, void __user *arg)
6087
6088 if (copy_from_user(&ctrl, arg, sizeof(ctrl)))
6089 return -EFAULT;
6090 - ret = check_ctrlrecip(ps, ctrl.bRequestType, ctrl.wIndex);
6091 + ret = check_ctrlrecip(ps, ctrl.bRequestType, ctrl.bRequest,
6092 + ctrl.wIndex);
6093 if (ret)
6094 return ret;
6095 wLength = ctrl.wLength; /* To suppress 64k PAGE_SIZE warning */
6096 @@ -1100,7 +1117,7 @@ static int proc_do_submiturb(struct dev_state *ps, struct usbdevfs_urb *uurb,
6097 kfree(dr);
6098 return -EINVAL;
6099 }
6100 - ret = check_ctrlrecip(ps, dr->bRequestType,
6101 + ret = check_ctrlrecip(ps, dr->bRequestType, dr->bRequest,
6102 le16_to_cpup(&dr->wIndex));
6103 if (ret) {
6104 kfree(dr);
6105 diff --git a/drivers/usb/core/driver.c b/drivers/usb/core/driver.c
6106 index 34e3da5..75b4bc0 100644
6107 --- a/drivers/usb/core/driver.c
6108 +++ b/drivers/usb/core/driver.c
6109 @@ -1583,7 +1583,7 @@ int usb_autopm_get_interface_async(struct usb_interface *intf)
6110 dev_vdbg(&intf->dev, "%s: cnt %d -> %d\n",
6111 __func__, atomic_read(&intf->dev.power.usage_count),
6112 status);
6113 - if (status > 0)
6114 + if (status > 0 || status == -EINPROGRESS)
6115 status = 0;
6116 return status;
6117 }
6118 @@ -1668,6 +1668,11 @@ int usb_runtime_suspend(struct device *dev)
6119 return -EAGAIN;
6120
6121 status = usb_suspend_both(udev, PMSG_AUTO_SUSPEND);
6122 +
6123 + /* Allow a retry if autosuspend failed temporarily */
6124 + if (status == -EAGAIN || status == -EBUSY)
6125 + usb_mark_last_busy(udev);
6126 +
6127 /* The PM core reacts badly unless the return code is 0,
6128 * -EAGAIN, or -EBUSY, so always return -EBUSY on an error.
6129 */
6130 diff --git a/drivers/usb/core/hcd.c b/drivers/usb/core/hcd.c
6131 index ace9f84..39ea00b 100644
6132 --- a/drivers/usb/core/hcd.c
6133 +++ b/drivers/usb/core/hcd.c
6134 @@ -1764,6 +1764,8 @@ int usb_hcd_alloc_bandwidth(struct usb_device *udev,
6135 struct usb_interface *iface = usb_ifnum_to_if(udev,
6136 cur_alt->desc.bInterfaceNumber);
6137
6138 + if (!iface)
6139 + return -EINVAL;
6140 if (iface->resetting_device) {
6141 /*
6142 * The USB core just reset the device, so the xHCI host
6143 diff --git a/drivers/usb/core/quirks.c b/drivers/usb/core/quirks.c
6144 index 81ce6a8..d6a8d82 100644
6145 --- a/drivers/usb/core/quirks.c
6146 +++ b/drivers/usb/core/quirks.c
6147 @@ -38,6 +38,27 @@ static const struct usb_device_id usb_quirk_list[] = {
6148 /* Creative SB Audigy 2 NX */
6149 { USB_DEVICE(0x041e, 0x3020), .driver_info = USB_QUIRK_RESET_RESUME },
6150
6151 + /* Logitech Webcam C200 */
6152 + { USB_DEVICE(0x046d, 0x0802), .driver_info = USB_QUIRK_RESET_RESUME },
6153 +
6154 + /* Logitech Webcam C250 */
6155 + { USB_DEVICE(0x046d, 0x0804), .driver_info = USB_QUIRK_RESET_RESUME },
6156 +
6157 + /* Logitech Webcam C300 */
6158 + { USB_DEVICE(0x046d, 0x0805), .driver_info = USB_QUIRK_RESET_RESUME },
6159 +
6160 + /* Logitech Webcam B/C500 */
6161 + { USB_DEVICE(0x046d, 0x0807), .driver_info = USB_QUIRK_RESET_RESUME },
6162 +
6163 + /* Logitech Webcam Pro 9000 */
6164 + { USB_DEVICE(0x046d, 0x0809), .driver_info = USB_QUIRK_RESET_RESUME },
6165 +
6166 + /* Logitech Webcam C310 */
6167 + { USB_DEVICE(0x046d, 0x081b), .driver_info = USB_QUIRK_RESET_RESUME },
6168 +
6169 + /* Logitech Webcam C270 */
6170 + { USB_DEVICE(0x046d, 0x0825), .driver_info = USB_QUIRK_RESET_RESUME },
6171 +
6172 /* Logitech Harmony 700-series */
6173 { USB_DEVICE(0x046d, 0xc122), .driver_info = USB_QUIRK_DELAY_INIT },
6174
6175 @@ -69,6 +90,9 @@ static const struct usb_device_id usb_quirk_list[] = {
6176 { USB_DEVICE(0x06a3, 0x0006), .driver_info =
6177 USB_QUIRK_CONFIG_INTF_STRINGS },
6178
6179 + /* Guillemot Webcam Hercules Dualpix Exchange*/
6180 + { USB_DEVICE(0x06f8, 0x0804), .driver_info = USB_QUIRK_RESET_RESUME },
6181 +
6182 /* M-Systems Flash Disk Pioneers */
6183 { USB_DEVICE(0x08ec, 0x1000), .driver_info = USB_QUIRK_RESET_RESUME },
6184
6185 diff --git a/drivers/usb/gadget/printer.c b/drivers/usb/gadget/printer.c
6186 index 271ef94..88a464c 100644
6187 --- a/drivers/usb/gadget/printer.c
6188 +++ b/drivers/usb/gadget/printer.c
6189 @@ -1602,7 +1602,7 @@ cleanup(void)
6190 if (status)
6191 ERROR(dev, "usb_gadget_unregister_driver %x\n", status);
6192
6193 - unregister_chrdev_region(g_printer_devno, 2);
6194 + unregister_chrdev_region(g_printer_devno, 1);
6195 class_destroy(usb_gadget_class);
6196 mutex_unlock(&usb_printer_gadget.lock_printer_io);
6197 }
6198 diff --git a/drivers/usb/host/ehci-dbg.c b/drivers/usb/host/ehci-dbg.c
6199 index 40a844c..3e2ccb0 100644
6200 --- a/drivers/usb/host/ehci-dbg.c
6201 +++ b/drivers/usb/host/ehci-dbg.c
6202 @@ -808,7 +808,7 @@ static ssize_t fill_registers_buffer(struct debug_buffer *buf)
6203 next += temp;
6204
6205 temp = scnprintf (next, size, "uframe %04x\n",
6206 - ehci_readl(ehci, &ehci->regs->frame_index));
6207 + ehci_read_frame_index(ehci));
6208 size -= temp;
6209 next += temp;
6210
6211 diff --git a/drivers/usb/host/ehci-hcd.c b/drivers/usb/host/ehci-hcd.c
6212 index 9ff9abc..b27ceab 100644
6213 --- a/drivers/usb/host/ehci-hcd.c
6214 +++ b/drivers/usb/host/ehci-hcd.c
6215 @@ -761,6 +761,35 @@ static int ehci_run (struct usb_hcd *hcd)
6216 return 0;
6217 }
6218
6219 +static int __maybe_unused ehci_setup (struct usb_hcd *hcd)
6220 +{
6221 + struct ehci_hcd *ehci = hcd_to_ehci(hcd);
6222 + int retval;
6223 +
6224 + ehci->regs = (void __iomem *)ehci->caps +
6225 + HC_LENGTH(ehci, ehci_readl(ehci, &ehci->caps->hc_capbase));
6226 + dbg_hcs_params(ehci, "reset");
6227 + dbg_hcc_params(ehci, "reset");
6228 +
6229 + /* cache this readonly data; minimize chip reads */
6230 + ehci->hcs_params = ehci_readl(ehci, &ehci->caps->hcs_params);
6231 +
6232 + ehci->sbrn = HCD_USB2;
6233 +
6234 + retval = ehci_halt(ehci);
6235 + if (retval)
6236 + return retval;
6237 +
6238 + /* data structure init */
6239 + retval = ehci_init(hcd);
6240 + if (retval)
6241 + return retval;
6242 +
6243 + ehci_reset(ehci);
6244 +
6245 + return 0;
6246 +}
6247 +
6248 /*-------------------------------------------------------------------------*/
6249
6250 static irqreturn_t ehci_irq (struct usb_hcd *hcd)
6251 @@ -1159,8 +1188,7 @@ ehci_endpoint_reset(struct usb_hcd *hcd, struct usb_host_endpoint *ep)
6252 static int ehci_get_frame (struct usb_hcd *hcd)
6253 {
6254 struct ehci_hcd *ehci = hcd_to_ehci (hcd);
6255 - return (ehci_readl(ehci, &ehci->regs->frame_index) >> 3) %
6256 - ehci->periodic_size;
6257 + return (ehci_read_frame_index(ehci) >> 3) % ehci->periodic_size;
6258 }
6259
6260 /*-------------------------------------------------------------------------*/
6261 diff --git a/drivers/usb/host/ehci-hub.c b/drivers/usb/host/ehci-hub.c
6262 index 0f3a724..f5d7fed 100644
6263 --- a/drivers/usb/host/ehci-hub.c
6264 +++ b/drivers/usb/host/ehci-hub.c
6265 @@ -1120,7 +1120,19 @@ static int ehci_hub_control (
6266 if (!selector || selector > 5)
6267 goto error;
6268 ehci_quiesce(ehci);
6269 +
6270 + /* Put all enabled ports into suspend */
6271 + while (ports--) {
6272 + u32 __iomem *sreg =
6273 + &ehci->regs->port_status[ports];
6274 +
6275 + temp = ehci_readl(ehci, sreg) & ~PORT_RWC_BITS;
6276 + if (temp & PORT_PE)
6277 + ehci_writel(ehci, temp | PORT_SUSPEND,
6278 + sreg);
6279 + }
6280 ehci_halt(ehci);
6281 + temp = ehci_readl(ehci, status_reg);
6282 temp |= selector << 16;
6283 ehci_writel(ehci, temp, status_reg);
6284 break;
6285 diff --git a/drivers/usb/host/ehci-pci.c b/drivers/usb/host/ehci-pci.c
6286 index 1102ce6..1d1caa6 100644
6287 --- a/drivers/usb/host/ehci-pci.c
6288 +++ b/drivers/usb/host/ehci-pci.c
6289 @@ -224,6 +224,11 @@ static int ehci_pci_setup(struct usb_hcd *hcd)
6290 pci_dev_put(p_smbus);
6291 }
6292 break;
6293 + case PCI_VENDOR_ID_NETMOS:
6294 + /* MosChip frame-index-register bug */
6295 + ehci_info(ehci, "applying MosChip frame-index workaround\n");
6296 + ehci->frame_index_bug = 1;
6297 + break;
6298 }
6299
6300 /* optional debug port, normally in the first BAR */
6301 diff --git a/drivers/usb/host/ehci-sched.c b/drivers/usb/host/ehci-sched.c
6302 index 6c9fbe3..063c630 100644
6303 --- a/drivers/usb/host/ehci-sched.c
6304 +++ b/drivers/usb/host/ehci-sched.c
6305 @@ -36,6 +36,27 @@
6306
6307 static int ehci_get_frame (struct usb_hcd *hcd);
6308
6309 +#ifdef CONFIG_PCI
6310 +
6311 +static unsigned ehci_read_frame_index(struct ehci_hcd *ehci)
6312 +{
6313 + unsigned uf;
6314 +
6315 + /*
6316 + * The MosChip MCS9990 controller updates its microframe counter
6317 + * a little before the frame counter, and occasionally we will read
6318 + * the invalid intermediate value. Avoid problems by checking the
6319 + * microframe number (the low-order 3 bits); if they are 0 then
6320 + * re-read the register to get the correct value.
6321 + */
6322 + uf = ehci_readl(ehci, &ehci->regs->frame_index);
6323 + if (unlikely(ehci->frame_index_bug && ((uf & 7) == 0)))
6324 + uf = ehci_readl(ehci, &ehci->regs->frame_index);
6325 + return uf;
6326 +}
6327 +
6328 +#endif
6329 +
6330 /*-------------------------------------------------------------------------*/
6331
6332 /*
6333 @@ -482,7 +503,7 @@ static int enable_periodic (struct ehci_hcd *ehci)
6334 ehci_to_hcd(ehci)->state = HC_STATE_RUNNING;
6335
6336 /* make sure ehci_work scans these */
6337 - ehci->next_uframe = ehci_readl(ehci, &ehci->regs->frame_index)
6338 + ehci->next_uframe = ehci_read_frame_index(ehci)
6339 % (ehci->periodic_size << 3);
6340 if (unlikely(ehci->broken_periodic))
6341 ehci->last_periodic_enable = ktime_get_real();
6342 @@ -1412,7 +1433,7 @@ iso_stream_schedule (
6343 goto fail;
6344 }
6345
6346 - now = ehci_readl(ehci, &ehci->regs->frame_index) & (mod - 1);
6347 + now = ehci_read_frame_index(ehci) & (mod - 1);
6348
6349 /* Typical case: reuse current schedule, stream is still active.
6350 * Hopefully there are no gaps from the host falling behind
6351 @@ -2279,7 +2300,7 @@ scan_periodic (struct ehci_hcd *ehci)
6352 */
6353 now_uframe = ehci->next_uframe;
6354 if (HC_IS_RUNNING(ehci_to_hcd(ehci)->state)) {
6355 - clock = ehci_readl(ehci, &ehci->regs->frame_index);
6356 + clock = ehci_read_frame_index(ehci);
6357 clock_frame = (clock >> 3) & (ehci->periodic_size - 1);
6358 } else {
6359 clock = now_uframe + mod - 1;
6360 @@ -2458,8 +2479,7 @@ restart: