Gentoo Archives: gentoo-commits

From: "Mike Pagano (mpagano)" <mpagano@g.o>
To: gentoo-commits@l.g.o
Subject: [gentoo-commits] linux-patches r2604 - genpatches-2.6/trunk/3.10
Date: Sat, 07 Dec 2013 00:57:13
Message-Id: 20131207005703.E90952004B@flycatcher.gentoo.org
1 Author: mpagano
2 Date: 2013-12-07 00:57:03 +0000 (Sat, 07 Dec 2013)
3 New Revision: 2604
4
5 Added:
6 genpatches-2.6/trunk/3.10/1021_linux-3.10.22.patch
7 Modified:
8 genpatches-2.6/trunk/3.10/0000_README
9 Log:
10 Linux patch 3.10.22
11
12 Modified: genpatches-2.6/trunk/3.10/0000_README
13 ===================================================================
14 --- genpatches-2.6/trunk/3.10/0000_README 2013-12-06 23:53:32 UTC (rev 2603)
15 +++ genpatches-2.6/trunk/3.10/0000_README 2013-12-07 00:57:03 UTC (rev 2604)
16 @@ -126,6 +126,10 @@
17 From: http://www.kernel.org
18 Desc: Linux 3.10.21
19
20 +Patch: 1021_linux-3.10.22.patch
21 +From: http://www.kernel.org
22 +Desc: Linux 3.10.22
23 +
24 Patch: 1500_XATTR_USER_PREFIX.patch
25 From: https://bugs.gentoo.org/show_bug.cgi?id=470644
26 Desc: Support for namespace user.pax.* on tmpfs.
27
28 Added: genpatches-2.6/trunk/3.10/1021_linux-3.10.22.patch
29 ===================================================================
30 --- genpatches-2.6/trunk/3.10/1021_linux-3.10.22.patch (rev 0)
31 +++ genpatches-2.6/trunk/3.10/1021_linux-3.10.22.patch 2013-12-07 00:57:03 UTC (rev 2604)
32 @@ -0,0 +1,7544 @@
33 +diff --git a/Documentation/sysctl/kernel.txt b/Documentation/sysctl/kernel.txt
34 +index ccd42589..9b34b168 100644
35 +--- a/Documentation/sysctl/kernel.txt
36 ++++ b/Documentation/sysctl/kernel.txt
37 +@@ -289,13 +289,24 @@ Default value is "/sbin/hotplug".
38 + kptr_restrict:
39 +
40 + This toggle indicates whether restrictions are placed on
41 +-exposing kernel addresses via /proc and other interfaces. When
42 +-kptr_restrict is set to (0), there are no restrictions. When
43 +-kptr_restrict is set to (1), the default, kernel pointers
44 +-printed using the %pK format specifier will be replaced with 0's
45 +-unless the user has CAP_SYSLOG. When kptr_restrict is set to
46 +-(2), kernel pointers printed using %pK will be replaced with 0's
47 +-regardless of privileges.
48 ++exposing kernel addresses via /proc and other interfaces.
49 ++
50 ++When kptr_restrict is set to (0), the default, there are no restrictions.
51 ++
52 ++When kptr_restrict is set to (1), kernel pointers printed using the %pK
53 ++format specifier will be replaced with 0's unless the user has CAP_SYSLOG
54 ++and effective user and group ids are equal to the real ids. This is
55 ++because %pK checks are done at read() time rather than open() time, so
56 ++if permissions are elevated between the open() and the read() (e.g via
57 ++a setuid binary) then %pK will not leak kernel pointers to unprivileged
58 ++users. Note, this is a temporary solution only. The correct long-term
59 ++solution is to do the permission checks at open() time. Consider removing
60 ++world read permissions from files that use %pK, and using dmesg_restrict
61 ++to protect against uses of %pK in dmesg(8) if leaking kernel pointer
62 ++values to unprivileged users is a concern.
63 ++
64 ++When kptr_restrict is set to (2), kernel pointers printed using
65 ++%pK will be replaced with 0's regardless of privileges.
66 +
67 + ==============================================================
68 +
69 +diff --git a/Makefile b/Makefile
70 +index c0635fba..001188ce 100644
71 +--- a/Makefile
72 ++++ b/Makefile
73 +@@ -1,6 +1,6 @@
74 + VERSION = 3
75 + PATCHLEVEL = 10
76 +-SUBLEVEL = 21
77 ++SUBLEVEL = 22
78 + EXTRAVERSION =
79 + NAME = TOSSUG Baby Fish
80 +
81 +diff --git a/arch/arm/boot/dts/bcm2835.dtsi b/arch/arm/boot/dts/bcm2835.dtsi
82 +index 1e12aeff..aa537ed1 100644
83 +--- a/arch/arm/boot/dts/bcm2835.dtsi
84 ++++ b/arch/arm/boot/dts/bcm2835.dtsi
85 +@@ -85,6 +85,8 @@
86 + reg = <0x7e205000 0x1000>;
87 + interrupts = <2 21>;
88 + clocks = <&clk_i2c>;
89 ++ #address-cells = <1>;
90 ++ #size-cells = <0>;
91 + status = "disabled";
92 + };
93 +
94 +@@ -93,6 +95,8 @@
95 + reg = <0x7e804000 0x1000>;
96 + interrupts = <2 21>;
97 + clocks = <&clk_i2c>;
98 ++ #address-cells = <1>;
99 ++ #size-cells = <0>;
100 + status = "disabled";
101 + };
102 +
103 +diff --git a/arch/arm/boot/dts/cros5250-common.dtsi b/arch/arm/boot/dts/cros5250-common.dtsi
104 +index 3f0239ec..49d8da27 100644
105 +--- a/arch/arm/boot/dts/cros5250-common.dtsi
106 ++++ b/arch/arm/boot/dts/cros5250-common.dtsi
107 +@@ -27,6 +27,13 @@
108 + i2c2_bus: i2c2-bus {
109 + samsung,pin-pud = <0>;
110 + };
111 ++
112 ++ max77686_irq: max77686-irq {
113 ++ samsung,pins = "gpx3-2";
114 ++ samsung,pin-function = <0>;
115 ++ samsung,pin-pud = <0>;
116 ++ samsung,pin-drv = <0>;
117 ++ };
118 + };
119 +
120 + i2c@12C60000 {
121 +@@ -35,6 +42,11 @@
122 +
123 + max77686@09 {
124 + compatible = "maxim,max77686";
125 ++ interrupt-parent = <&gpx3>;
126 ++ interrupts = <2 0>;
127 ++ pinctrl-names = "default";
128 ++ pinctrl-0 = <&max77686_irq>;
129 ++ wakeup-source;
130 + reg = <0x09>;
131 +
132 + voltage-regulators {
133 +diff --git a/arch/arm/kernel/entry-armv.S b/arch/arm/kernel/entry-armv.S
134 +index d43c7e54..32640ae7 100644
135 +--- a/arch/arm/kernel/entry-armv.S
136 ++++ b/arch/arm/kernel/entry-armv.S
137 +@@ -192,6 +192,7 @@ __dabt_svc:
138 + svc_entry
139 + mov r2, sp
140 + dabt_helper
141 ++ THUMB( ldr r5, [sp, #S_PSR] ) @ potentially updated CPSR
142 + svc_exit r5 @ return from exception
143 + UNWIND(.fnend )
144 + ENDPROC(__dabt_svc)
145 +diff --git a/arch/arm/mach-at91/Makefile b/arch/arm/mach-at91/Makefile
146 +index 788562dc..c336efdf 100644
147 +--- a/arch/arm/mach-at91/Makefile
148 ++++ b/arch/arm/mach-at91/Makefile
149 +@@ -2,7 +2,7 @@
150 + # Makefile for the linux kernel.
151 + #
152 +
153 +-obj-y := irq.o gpio.o setup.o
154 ++obj-y := irq.o gpio.o setup.o sysirq_mask.o
155 + obj-m :=
156 + obj-n :=
157 + obj- :=
158 +diff --git a/arch/arm/mach-at91/at91sam9260.c b/arch/arm/mach-at91/at91sam9260.c
159 +index a8ce2453..cdb1fb69 100644
160 +--- a/arch/arm/mach-at91/at91sam9260.c
161 ++++ b/arch/arm/mach-at91/at91sam9260.c
162 +@@ -351,6 +351,8 @@ static void __init at91sam9260_initialize(void)
163 + at91_extern_irq = (1 << AT91SAM9260_ID_IRQ0) | (1 << AT91SAM9260_ID_IRQ1)
164 + | (1 << AT91SAM9260_ID_IRQ2);
165 +
166 ++ at91_sysirq_mask_rtt(AT91SAM9260_BASE_RTT);
167 ++
168 + /* Register GPIO subsystem */
169 + at91_gpio_init(at91sam9260_gpio, 3);
170 + }
171 +diff --git a/arch/arm/mach-at91/at91sam9261.c b/arch/arm/mach-at91/at91sam9261.c
172 +index 25efb5ac..7c9d2ea5 100644
173 +--- a/arch/arm/mach-at91/at91sam9261.c
174 ++++ b/arch/arm/mach-at91/at91sam9261.c
175 +@@ -293,6 +293,8 @@ static void __init at91sam9261_initialize(void)
176 + at91_extern_irq = (1 << AT91SAM9261_ID_IRQ0) | (1 << AT91SAM9261_ID_IRQ1)
177 + | (1 << AT91SAM9261_ID_IRQ2);
178 +
179 ++ at91_sysirq_mask_rtt(AT91SAM9261_BASE_RTT);
180 ++
181 + /* Register GPIO subsystem */
182 + at91_gpio_init(at91sam9261_gpio, 3);
183 + }
184 +diff --git a/arch/arm/mach-at91/at91sam9263.c b/arch/arm/mach-at91/at91sam9263.c
185 +index f44ffd21..c6b2f477 100644
186 +--- a/arch/arm/mach-at91/at91sam9263.c
187 ++++ b/arch/arm/mach-at91/at91sam9263.c
188 +@@ -329,6 +329,9 @@ static void __init at91sam9263_initialize(void)
189 + arm_pm_restart = at91sam9_alt_restart;
190 + at91_extern_irq = (1 << AT91SAM9263_ID_IRQ0) | (1 << AT91SAM9263_ID_IRQ1);
191 +
192 ++ at91_sysirq_mask_rtt(AT91SAM9263_BASE_RTT0);
193 ++ at91_sysirq_mask_rtt(AT91SAM9263_BASE_RTT1);
194 ++
195 + /* Register GPIO subsystem */
196 + at91_gpio_init(at91sam9263_gpio, 5);
197 + }
198 +diff --git a/arch/arm/mach-at91/at91sam9g45.c b/arch/arm/mach-at91/at91sam9g45.c
199 +index 8b7fce06..e381fa12 100644
200 +--- a/arch/arm/mach-at91/at91sam9g45.c
201 ++++ b/arch/arm/mach-at91/at91sam9g45.c
202 +@@ -376,6 +376,9 @@ static void __init at91sam9g45_initialize(void)
203 + arm_pm_restart = at91sam9g45_restart;
204 + at91_extern_irq = (1 << AT91SAM9G45_ID_IRQ0);
205 +
206 ++ at91_sysirq_mask_rtc(AT91SAM9G45_BASE_RTC);
207 ++ at91_sysirq_mask_rtt(AT91SAM9G45_BASE_RTT);
208 ++
209 + /* Register GPIO subsystem */
210 + at91_gpio_init(at91sam9g45_gpio, 5);
211 + }
212 +diff --git a/arch/arm/mach-at91/at91sam9n12.c b/arch/arm/mach-at91/at91sam9n12.c
213 +index c7d670d1..4d6001c3 100644
214 +--- a/arch/arm/mach-at91/at91sam9n12.c
215 ++++ b/arch/arm/mach-at91/at91sam9n12.c
216 +@@ -223,7 +223,13 @@ static void __init at91sam9n12_map_io(void)
217 + at91_init_sram(0, AT91SAM9N12_SRAM_BASE, AT91SAM9N12_SRAM_SIZE);
218 + }
219 +
220 ++static void __init at91sam9n12_initialize(void)
221 ++{
222 ++ at91_sysirq_mask_rtc(AT91SAM9N12_BASE_RTC);
223 ++}
224 ++
225 + AT91_SOC_START(at91sam9n12)
226 + .map_io = at91sam9n12_map_io,
227 + .register_clocks = at91sam9n12_register_clocks,
228 ++ .init = at91sam9n12_initialize,
229 + AT91_SOC_END
230 +diff --git a/arch/arm/mach-at91/at91sam9rl.c b/arch/arm/mach-at91/at91sam9rl.c
231 +index f77fae55..5615d28a 100644
232 +--- a/arch/arm/mach-at91/at91sam9rl.c
233 ++++ b/arch/arm/mach-at91/at91sam9rl.c
234 +@@ -295,6 +295,9 @@ static void __init at91sam9rl_initialize(void)
235 + arm_pm_restart = at91sam9_alt_restart;
236 + at91_extern_irq = (1 << AT91SAM9RL_ID_IRQ0);
237 +
238 ++ at91_sysirq_mask_rtc(AT91SAM9RL_BASE_RTC);
239 ++ at91_sysirq_mask_rtt(AT91SAM9RL_BASE_RTT);
240 ++
241 + /* Register GPIO subsystem */
242 + at91_gpio_init(at91sam9rl_gpio, 4);
243 + }
244 +diff --git a/arch/arm/mach-at91/at91sam9x5.c b/arch/arm/mach-at91/at91sam9x5.c
245 +index e631fec0..7b4f8483 100644
246 +--- a/arch/arm/mach-at91/at91sam9x5.c
247 ++++ b/arch/arm/mach-at91/at91sam9x5.c
248 +@@ -318,6 +318,11 @@ static void __init at91sam9x5_map_io(void)
249 + at91_init_sram(0, AT91SAM9X5_SRAM_BASE, AT91SAM9X5_SRAM_SIZE);
250 + }
251 +
252 ++static void __init at91sam9x5_initialize(void)
253 ++{
254 ++ at91_sysirq_mask_rtc(AT91SAM9X5_BASE_RTC);
255 ++}
256 ++
257 + /* --------------------------------------------------------------------
258 + * Interrupt initialization
259 + * -------------------------------------------------------------------- */
260 +@@ -325,4 +330,5 @@ static void __init at91sam9x5_map_io(void)
261 + AT91_SOC_START(at91sam9x5)
262 + .map_io = at91sam9x5_map_io,
263 + .register_clocks = at91sam9x5_register_clocks,
264 ++ .init = at91sam9x5_initialize,
265 + AT91_SOC_END
266 +diff --git a/arch/arm/mach-at91/generic.h b/arch/arm/mach-at91/generic.h
267 +index 78ab0654..d949ab4e 100644
268 +--- a/arch/arm/mach-at91/generic.h
269 ++++ b/arch/arm/mach-at91/generic.h
270 +@@ -33,6 +33,8 @@ extern int __init at91_aic_of_init(struct device_node *node,
271 + struct device_node *parent);
272 + extern int __init at91_aic5_of_init(struct device_node *node,
273 + struct device_node *parent);
274 ++extern void __init at91_sysirq_mask_rtc(u32 rtc_base);
275 ++extern void __init at91_sysirq_mask_rtt(u32 rtt_base);
276 +
277 +
278 + /* Timer */
279 +diff --git a/arch/arm/mach-at91/include/mach/at91sam9n12.h b/arch/arm/mach-at91/include/mach/at91sam9n12.h
280 +index d374b87c..0151bcf6 100644
281 +--- a/arch/arm/mach-at91/include/mach/at91sam9n12.h
282 ++++ b/arch/arm/mach-at91/include/mach/at91sam9n12.h
283 +@@ -49,6 +49,11 @@
284 + #define AT91SAM9N12_BASE_USART3 0xf8028000
285 +
286 + /*
287 ++ * System Peripherals
288 ++ */
289 ++#define AT91SAM9N12_BASE_RTC 0xfffffeb0
290 ++
291 ++/*
292 + * Internal Memory.
293 + */
294 + #define AT91SAM9N12_SRAM_BASE 0x00300000 /* Internal SRAM base address */
295 +diff --git a/arch/arm/mach-at91/include/mach/at91sam9x5.h b/arch/arm/mach-at91/include/mach/at91sam9x5.h
296 +index c75ee19b..2fc76c49 100644
297 +--- a/arch/arm/mach-at91/include/mach/at91sam9x5.h
298 ++++ b/arch/arm/mach-at91/include/mach/at91sam9x5.h
299 +@@ -55,6 +55,11 @@
300 + #define AT91SAM9X5_BASE_USART2 0xf8024000
301 +
302 + /*
303 ++ * System Peripherals
304 ++ */
305 ++#define AT91SAM9X5_BASE_RTC 0xfffffeb0
306 ++
307 ++/*
308 + * Internal Memory.
309 + */
310 + #define AT91SAM9X5_SRAM_BASE 0x00300000 /* Internal SRAM base address */
311 +diff --git a/arch/arm/mach-at91/include/mach/sama5d3.h b/arch/arm/mach-at91/include/mach/sama5d3.h
312 +index 6dc81ee3..3abbc428 100644
313 +--- a/arch/arm/mach-at91/include/mach/sama5d3.h
314 ++++ b/arch/arm/mach-at91/include/mach/sama5d3.h
315 +@@ -65,6 +65,11 @@
316 + #define SAMA5D3_ID_IRQ0 47 /* Advanced Interrupt Controller (IRQ0) */
317 +
318 + /*
319 ++ * System Peripherals
320 ++ */
321 ++#define SAMA5D3_BASE_RTC 0xfffffeb0
322 ++
323 ++/*
324 + * Internal Memory
325 + */
326 + #define SAMA5D3_SRAM_BASE 0x00300000 /* Internal SRAM base address */
327 +diff --git a/arch/arm/mach-at91/sama5d3.c b/arch/arm/mach-at91/sama5d3.c
328 +index 40127971..3ea86428 100644
329 +--- a/arch/arm/mach-at91/sama5d3.c
330 ++++ b/arch/arm/mach-at91/sama5d3.c
331 +@@ -371,7 +371,13 @@ static void __init sama5d3_map_io(void)
332 + at91_init_sram(0, SAMA5D3_SRAM_BASE, SAMA5D3_SRAM_SIZE);
333 + }
334 +
335 ++static void __init sama5d3_initialize(void)
336 ++{
337 ++ at91_sysirq_mask_rtc(SAMA5D3_BASE_RTC);
338 ++}
339 ++
340 + AT91_SOC_START(sama5d3)
341 + .map_io = sama5d3_map_io,
342 + .register_clocks = sama5d3_register_clocks,
343 ++ .init = sama5d3_initialize,
344 + AT91_SOC_END
345 +diff --git a/arch/arm/mach-at91/sysirq_mask.c b/arch/arm/mach-at91/sysirq_mask.c
346 +new file mode 100644
347 +index 00000000..2ba694f9
348 +--- /dev/null
349 ++++ b/arch/arm/mach-at91/sysirq_mask.c
350 +@@ -0,0 +1,71 @@
351 ++/*
352 ++ * sysirq_mask.c - System-interrupt masking
353 ++ *
354 ++ * Copyright (C) 2013 Johan Hovold <jhovold@×××××.com>
355 ++ *
356 ++ * Functions to disable system interrupts from backup-powered peripherals.
357 ++ *
358 ++ * The RTC and RTT-peripherals are generally powered by backup power (VDDBU)
359 ++ * and are not reset on wake-up, user, watchdog or software reset. This means
360 ++ * that their interrupts may be enabled during early boot (e.g. after a user
361 ++ * reset).
362 ++ *
363 ++ * As the RTC and RTT share the system-interrupt line with the PIT, an
364 ++ * interrupt occurring before a handler has been installed would lead to the
365 ++ * system interrupt being disabled and prevent the system from booting.
366 ++ *
367 ++ * This program is free software; you can redistribute it and/or modify
368 ++ * it under the terms of the GNU General Public License as published by
369 ++ * the Free Software Foundation; either version 2 of the License, or
370 ++ * (at your option) any later version.
371 ++ */
372 ++
373 ++#include <linux/io.h>
374 ++#include <mach/at91_rtt.h>
375 ++
376 ++#include "generic.h"
377 ++
378 ++#define AT91_RTC_IDR 0x24 /* Interrupt Disable Register */
379 ++#define AT91_RTC_IMR 0x28 /* Interrupt Mask Register */
380 ++
381 ++void __init at91_sysirq_mask_rtc(u32 rtc_base)
382 ++{
383 ++ void __iomem *base;
384 ++ u32 mask;
385 ++
386 ++ base = ioremap(rtc_base, 64);
387 ++ if (!base)
388 ++ return;
389 ++
390 ++ mask = readl_relaxed(base + AT91_RTC_IMR);
391 ++ if (mask) {
392 ++ pr_info("AT91: Disabling rtc irq\n");
393 ++ writel_relaxed(mask, base + AT91_RTC_IDR);
394 ++ (void)readl_relaxed(base + AT91_RTC_IMR); /* flush */
395 ++ }
396 ++
397 ++ iounmap(base);
398 ++}
399 ++
400 ++void __init at91_sysirq_mask_rtt(u32 rtt_base)
401 ++{
402 ++ void __iomem *base;
403 ++ void __iomem *reg;
404 ++ u32 mode;
405 ++
406 ++ base = ioremap(rtt_base, 16);
407 ++ if (!base)
408 ++ return;
409 ++
410 ++ reg = base + AT91_RTT_MR;
411 ++
412 ++ mode = readl_relaxed(reg);
413 ++ if (mode & (AT91_RTT_ALMIEN | AT91_RTT_RTTINCIEN)) {
414 ++ pr_info("AT91: Disabling rtt irq\n");
415 ++ mode &= ~(AT91_RTT_ALMIEN | AT91_RTT_RTTINCIEN);
416 ++ writel_relaxed(mode, reg);
417 ++ (void)readl_relaxed(reg); /* flush */
418 ++ }
419 ++
420 ++ iounmap(base);
421 ++}
422 +diff --git a/arch/arm/mach-imx/clk-imx6q.c b/arch/arm/mach-imx/clk-imx6q.c
423 +index 4e3148ce..0b9e4377 100644
424 +--- a/arch/arm/mach-imx/clk-imx6q.c
425 ++++ b/arch/arm/mach-imx/clk-imx6q.c
426 +@@ -424,7 +424,7 @@ int __init mx6q_clocks_init(void)
427 + clk[asrc_podf] = imx_clk_divider("asrc_podf", "asrc_pred", base + 0x30, 9, 3);
428 + clk[spdif_pred] = imx_clk_divider("spdif_pred", "spdif_sel", base + 0x30, 25, 3);
429 + clk[spdif_podf] = imx_clk_divider("spdif_podf", "spdif_pred", base + 0x30, 22, 3);
430 +- clk[can_root] = imx_clk_divider("can_root", "pll3_usb_otg", base + 0x20, 2, 6);
431 ++ clk[can_root] = imx_clk_divider("can_root", "pll3_60m", base + 0x20, 2, 6);
432 + clk[ecspi_root] = imx_clk_divider("ecspi_root", "pll3_60m", base + 0x38, 19, 6);
433 + clk[gpu2d_core_podf] = imx_clk_divider("gpu2d_core_podf", "gpu2d_core_sel", base + 0x18, 23, 3);
434 + clk[gpu3d_core_podf] = imx_clk_divider("gpu3d_core_podf", "gpu3d_core_sel", base + 0x18, 26, 3);
435 +diff --git a/arch/arm/mach-integrator/integrator_cp.c b/arch/arm/mach-integrator/integrator_cp.c
436 +index 8c60fcb0..2f4c9248 100644
437 +--- a/arch/arm/mach-integrator/integrator_cp.c
438 ++++ b/arch/arm/mach-integrator/integrator_cp.c
439 +@@ -199,7 +199,8 @@ static struct mmci_platform_data mmc_data = {
440 + static void cp_clcd_enable(struct clcd_fb *fb)
441 + {
442 + struct fb_var_screeninfo *var = &fb->fb.var;
443 +- u32 val = CM_CTRL_STATIC1 | CM_CTRL_STATIC2;
444 ++ u32 val = CM_CTRL_STATIC1 | CM_CTRL_STATIC2
445 ++ | CM_CTRL_LCDEN0 | CM_CTRL_LCDEN1;
446 +
447 + if (var->bits_per_pixel <= 8 ||
448 + (var->bits_per_pixel == 16 && var->green.length == 5))
449 +diff --git a/arch/arm/mach-omap2/irq.c b/arch/arm/mach-omap2/irq.c
450 +index 3926f370..e022a869 100644
451 +--- a/arch/arm/mach-omap2/irq.c
452 ++++ b/arch/arm/mach-omap2/irq.c
453 +@@ -233,7 +233,7 @@ static inline void omap_intc_handle_irq(void __iomem *base_addr, struct pt_regs
454 + goto out;
455 +
456 + irqnr = readl_relaxed(base_addr + 0xd8);
457 +-#ifdef CONFIG_SOC_TI81XX
458 ++#if IS_ENABLED(CONFIG_SOC_TI81XX) || IS_ENABLED(CONFIG_SOC_AM33XX)
459 + if (irqnr)
460 + goto out;
461 + irqnr = readl_relaxed(base_addr + 0xf8);
462 +diff --git a/arch/arm/mach-sa1100/assabet.c b/arch/arm/mach-sa1100/assabet.c
463 +index e838ba27..c9808c68 100644
464 +--- a/arch/arm/mach-sa1100/assabet.c
465 ++++ b/arch/arm/mach-sa1100/assabet.c
466 +@@ -512,6 +512,9 @@ static void __init assabet_map_io(void)
467 + * Its called GPCLKR0 in my SA1110 manual.
468 + */
469 + Ser1SDCR0 |= SDCR0_SUS;
470 ++ MSC1 = (MSC1 & ~0xffff) |
471 ++ MSC_NonBrst | MSC_32BitStMem |
472 ++ MSC_RdAcc(2) | MSC_WrAcc(2) | MSC_Rec(0);
473 +
474 + if (!machine_has_neponset())
475 + sa1100_register_uart_fns(&assabet_port_fns);
476 +diff --git a/arch/arm/mm/extable.c b/arch/arm/mm/extable.c
477 +index 9d285626..312e15e6 100644
478 +--- a/arch/arm/mm/extable.c
479 ++++ b/arch/arm/mm/extable.c
480 +@@ -9,8 +9,13 @@ int fixup_exception(struct pt_regs *regs)
481 + const struct exception_table_entry *fixup;
482 +
483 + fixup = search_exception_tables(instruction_pointer(regs));
484 +- if (fixup)
485 ++ if (fixup) {
486 + regs->ARM_pc = fixup->fixup;
487 ++#ifdef CONFIG_THUMB2_KERNEL
488 ++ /* Clear the IT state to avoid nasty surprises in the fixup */
489 ++ regs->ARM_cpsr &= ~PSR_IT_MASK;
490 ++#endif
491 ++ }
492 +
493 + return fixup != NULL;
494 + }
495 +diff --git a/arch/avr32/boot/u-boot/head.S b/arch/avr32/boot/u-boot/head.S
496 +index 4488fa27..2ffc298f 100644
497 +--- a/arch/avr32/boot/u-boot/head.S
498 ++++ b/arch/avr32/boot/u-boot/head.S
499 +@@ -8,6 +8,8 @@
500 + * published by the Free Software Foundation.
501 + */
502 + #include <asm/setup.h>
503 ++#include <asm/thread_info.h>
504 ++#include <asm/sysreg.h>
505 +
506 + /*
507 + * The kernel is loaded where we want it to be and all caches
508 +@@ -20,11 +22,6 @@
509 + .section .init.text,"ax"
510 + .global _start
511 + _start:
512 +- /* Check if the boot loader actually provided a tag table */
513 +- lddpc r0, magic_number
514 +- cp.w r12, r0
515 +- brne no_tag_table
516 +-
517 + /* Initialize .bss */
518 + lddpc r2, bss_start_addr
519 + lddpc r3, end_addr
520 +@@ -34,6 +31,25 @@ _start:
521 + cp r2, r3
522 + brlo 1b
523 +
524 ++ /* Initialize status register */
525 ++ lddpc r0, init_sr
526 ++ mtsr SYSREG_SR, r0
527 ++
528 ++ /* Set initial stack pointer */
529 ++ lddpc sp, stack_addr
530 ++ sub sp, -THREAD_SIZE
531 ++
532 ++#ifdef CONFIG_FRAME_POINTER
533 ++ /* Mark last stack frame */
534 ++ mov lr, 0
535 ++ mov r7, 0
536 ++#endif
537 ++
538 ++ /* Check if the boot loader actually provided a tag table */
539 ++ lddpc r0, magic_number
540 ++ cp.w r12, r0
541 ++ brne no_tag_table
542 ++
543 + /*
544 + * Save the tag table address for later use. This must be done
545 + * _after_ .bss has been initialized...
546 +@@ -53,8 +69,15 @@ bss_start_addr:
547 + .long __bss_start
548 + end_addr:
549 + .long _end
550 ++init_sr:
551 ++ .long 0x007f0000 /* Supervisor mode, everything masked */
552 ++stack_addr:
553 ++ .long init_thread_union
554 ++panic_addr:
555 ++ .long panic
556 +
557 + no_tag_table:
558 + sub r12, pc, (. - 2f)
559 +- bral panic
560 ++ /* branch to panic() which can be far away with that construct */
561 ++ lddpc pc, panic_addr
562 + 2: .asciz "Boot loader didn't provide correct magic number\n"
563 +diff --git a/arch/avr32/kernel/entry-avr32b.S b/arch/avr32/kernel/entry-avr32b.S
564 +index 9899d3cc..7301f480 100644
565 +--- a/arch/avr32/kernel/entry-avr32b.S
566 ++++ b/arch/avr32/kernel/entry-avr32b.S
567 +@@ -401,9 +401,10 @@ handle_critical:
568 + /* We should never get here... */
569 + bad_return:
570 + sub r12, pc, (. - 1f)
571 +- bral panic
572 ++ lddpc pc, 2f
573 + .align 2
574 + 1: .asciz "Return from critical exception!"
575 ++2: .long panic
576 +
577 + .align 1
578 + do_bus_error_write:
579 +diff --git a/arch/avr32/kernel/head.S b/arch/avr32/kernel/head.S
580 +index 6163bd0a..59eae6df 100644
581 +--- a/arch/avr32/kernel/head.S
582 ++++ b/arch/avr32/kernel/head.S
583 +@@ -10,33 +10,13 @@
584 + #include <linux/linkage.h>
585 +
586 + #include <asm/page.h>
587 +-#include <asm/thread_info.h>
588 +-#include <asm/sysreg.h>
589 +
590 + .section .init.text,"ax"
591 + .global kernel_entry
592 + kernel_entry:
593 +- /* Initialize status register */
594 +- lddpc r0, init_sr
595 +- mtsr SYSREG_SR, r0
596 +-
597 +- /* Set initial stack pointer */
598 +- lddpc sp, stack_addr
599 +- sub sp, -THREAD_SIZE
600 +-
601 +-#ifdef CONFIG_FRAME_POINTER
602 +- /* Mark last stack frame */
603 +- mov lr, 0
604 +- mov r7, 0
605 +-#endif
606 +-
607 + /* Start the show */
608 + lddpc pc, kernel_start_addr
609 +
610 + .align 2
611 +-init_sr:
612 +- .long 0x007f0000 /* Supervisor mode, everything masked */
613 +-stack_addr:
614 +- .long init_thread_union
615 + kernel_start_addr:
616 + .long start_kernel
617 +diff --git a/arch/parisc/include/asm/socket.h b/arch/parisc/include/asm/socket.h
618 +new file mode 100644
619 +index 00000000..748016cb
620 +--- /dev/null
621 ++++ b/arch/parisc/include/asm/socket.h
622 +@@ -0,0 +1,11 @@
623 ++#ifndef _ASM_SOCKET_H
624 ++#define _ASM_SOCKET_H
625 ++
626 ++#include <uapi/asm/socket.h>
627 ++
628 ++/* O_NONBLOCK clashes with the bits used for socket types. Therefore we
629 ++ * have to define SOCK_NONBLOCK to a different value here.
630 ++ */
631 ++#define SOCK_NONBLOCK 0x40000000
632 ++
633 ++#endif /* _ASM_SOCKET_H */
634 +diff --git a/arch/parisc/include/uapi/asm/socket.h b/arch/parisc/include/uapi/asm/socket.h
635 +index 70c512a3..4fecb262 100644
636 +--- a/arch/parisc/include/uapi/asm/socket.h
637 ++++ b/arch/parisc/include/uapi/asm/socket.h
638 +@@ -1,5 +1,5 @@
639 +-#ifndef _ASM_SOCKET_H
640 +-#define _ASM_SOCKET_H
641 ++#ifndef _UAPI_ASM_SOCKET_H
642 ++#define _UAPI_ASM_SOCKET_H
643 +
644 + #include <asm/sockios.h>
645 +
646 +@@ -73,9 +73,4 @@
647 +
648 + #define SO_SELECT_ERR_QUEUE 0x4026
649 +
650 +-/* O_NONBLOCK clashes with the bits used for socket types. Therefore we
651 +- * have to define SOCK_NONBLOCK to a different value here.
652 +- */
653 +-#define SOCK_NONBLOCK 0x40000000
654 +-
655 +-#endif /* _ASM_SOCKET_H */
656 ++#endif /* _UAPI_ASM_SOCKET_H */
657 +diff --git a/arch/powerpc/kernel/signal_32.c b/arch/powerpc/kernel/signal_32.c
658 +index 32330996..7e9dff80 100644
659 +--- a/arch/powerpc/kernel/signal_32.c
660 ++++ b/arch/powerpc/kernel/signal_32.c
661 +@@ -442,6 +442,12 @@ static int save_user_regs(struct pt_regs *regs, struct mcontext __user *frame,
662 + #endif /* CONFIG_ALTIVEC */
663 + if (copy_fpr_to_user(&frame->mc_fregs, current))
664 + return 1;
665 ++
666 ++ /*
667 ++ * Clear the MSR VSX bit to indicate there is no valid state attached
668 ++ * to this context, except in the specific case below where we set it.
669 ++ */
670 ++ msr &= ~MSR_VSX;
671 + #ifdef CONFIG_VSX
672 + /*
673 + * Copy VSR 0-31 upper half from thread_struct to local
674 +@@ -454,15 +460,7 @@ static int save_user_regs(struct pt_regs *regs, struct mcontext __user *frame,
675 + if (copy_vsx_to_user(&frame->mc_vsregs, current))
676 + return 1;
677 + msr |= MSR_VSX;
678 +- } else if (!ctx_has_vsx_region)
679 +- /*
680 +- * With a small context structure we can't hold the VSX
681 +- * registers, hence clear the MSR value to indicate the state
682 +- * was not saved.
683 +- */
684 +- msr &= ~MSR_VSX;
685 +-
686 +-
687 ++ }
688 + #endif /* CONFIG_VSX */
689 + #ifdef CONFIG_SPE
690 + /* save spe registers */
691 +diff --git a/arch/powerpc/kernel/signal_64.c b/arch/powerpc/kernel/signal_64.c
692 +index 887e99d8..35c20a1f 100644
693 +--- a/arch/powerpc/kernel/signal_64.c
694 ++++ b/arch/powerpc/kernel/signal_64.c
695 +@@ -121,6 +121,12 @@ static long setup_sigcontext(struct sigcontext __user *sc, struct pt_regs *regs,
696 + flush_fp_to_thread(current);
697 + /* copy fpr regs and fpscr */
698 + err |= copy_fpr_to_user(&sc->fp_regs, current);
699 ++
700 ++ /*
701 ++ * Clear the MSR VSX bit to indicate there is no valid state attached
702 ++ * to this context, except in the specific case below where we set it.
703 ++ */
704 ++ msr &= ~MSR_VSX;
705 + #ifdef CONFIG_VSX
706 + /*
707 + * Copy VSX low doubleword to local buffer for formatting,
708 +diff --git a/arch/s390/lib/uaccess_pt.c b/arch/s390/lib/uaccess_pt.c
709 +index 50ea137a..1bf40ef5 100644
710 +--- a/arch/s390/lib/uaccess_pt.c
711 ++++ b/arch/s390/lib/uaccess_pt.c
712 +@@ -78,11 +78,14 @@ static size_t copy_in_kernel(size_t count, void __user *to,
713 + * contains the (negative) exception code.
714 + */
715 + #ifdef CONFIG_64BIT
716 ++
717 + static unsigned long follow_table(struct mm_struct *mm,
718 + unsigned long address, int write)
719 + {
720 + unsigned long *table = (unsigned long *)__pa(mm->pgd);
721 +
722 ++ if (unlikely(address > mm->context.asce_limit - 1))
723 ++ return -0x38UL;
724 + switch (mm->context.asce_bits & _ASCE_TYPE_MASK) {
725 + case _ASCE_TYPE_REGION1:
726 + table = table + ((address >> 53) & 0x7ff);
727 +diff --git a/block/blk-core.c b/block/blk-core.c
728 +index 45f3a51f..acf3bf6a 100644
729 +--- a/block/blk-core.c
730 ++++ b/block/blk-core.c
731 +@@ -645,10 +645,12 @@ struct request_queue *blk_alloc_queue_node(gfp_t gfp_mask, int node_id)
732 + __set_bit(QUEUE_FLAG_BYPASS, &q->queue_flags);
733 +
734 + if (blkcg_init_queue(q))
735 +- goto fail_id;
736 ++ goto fail_bdi;
737 +
738 + return q;
739 +
740 ++fail_bdi:
741 ++ bdi_destroy(&q->backing_dev_info);
742 + fail_id:
743 + ida_simple_remove(&blk_queue_ida, q->id);
744 + fail_q:
745 +diff --git a/crypto/asymmetric_keys/x509_public_key.c b/crypto/asymmetric_keys/x509_public_key.c
746 +index 06007f0e..52222a2f 100644
747 +--- a/crypto/asymmetric_keys/x509_public_key.c
748 ++++ b/crypto/asymmetric_keys/x509_public_key.c
749 +@@ -106,7 +106,6 @@ error_no_sig:
750 + static int x509_key_preparse(struct key_preparsed_payload *prep)
751 + {
752 + struct x509_certificate *cert;
753 +- struct tm now;
754 + size_t srlen, sulen;
755 + char *desc = NULL;
756 + int ret;
757 +@@ -137,43 +136,6 @@ static int x509_key_preparse(struct key_preparsed_payload *prep)
758 + goto error_free_cert;
759 + }
760 +
761 +- time_to_tm(CURRENT_TIME.tv_sec, 0, &now);
762 +- pr_devel("Now: %04ld-%02d-%02d %02d:%02d:%02d\n",
763 +- now.tm_year + 1900, now.tm_mon + 1, now.tm_mday,
764 +- now.tm_hour, now.tm_min, now.tm_sec);
765 +- if (now.tm_year < cert->valid_from.tm_year ||
766 +- (now.tm_year == cert->valid_from.tm_year &&
767 +- (now.tm_mon < cert->valid_from.tm_mon ||
768 +- (now.tm_mon == cert->valid_from.tm_mon &&
769 +- (now.tm_mday < cert->valid_from.tm_mday ||
770 +- (now.tm_mday == cert->valid_from.tm_mday &&
771 +- (now.tm_hour < cert->valid_from.tm_hour ||
772 +- (now.tm_hour == cert->valid_from.tm_hour &&
773 +- (now.tm_min < cert->valid_from.tm_min ||
774 +- (now.tm_min == cert->valid_from.tm_min &&
775 +- (now.tm_sec < cert->valid_from.tm_sec
776 +- ))))))))))) {
777 +- pr_warn("Cert %s is not yet valid\n", cert->fingerprint);
778 +- ret = -EKEYREJECTED;
779 +- goto error_free_cert;
780 +- }
781 +- if (now.tm_year > cert->valid_to.tm_year ||
782 +- (now.tm_year == cert->valid_to.tm_year &&
783 +- (now.tm_mon > cert->valid_to.tm_mon ||
784 +- (now.tm_mon == cert->valid_to.tm_mon &&
785 +- (now.tm_mday > cert->valid_to.tm_mday ||
786 +- (now.tm_mday == cert->valid_to.tm_mday &&
787 +- (now.tm_hour > cert->valid_to.tm_hour ||
788 +- (now.tm_hour == cert->valid_to.tm_hour &&
789 +- (now.tm_min > cert->valid_to.tm_min ||
790 +- (now.tm_min == cert->valid_to.tm_min &&
791 +- (now.tm_sec > cert->valid_to.tm_sec
792 +- ))))))))))) {
793 +- pr_warn("Cert %s has expired\n", cert->fingerprint);
794 +- ret = -EKEYEXPIRED;
795 +- goto error_free_cert;
796 +- }
797 +-
798 + cert->pub->algo = x509_public_key_algorithms[cert->pkey_algo];
799 + cert->pub->id_type = PKEY_ID_X509;
800 +
801 +diff --git a/drivers/acpi/pci_root.c b/drivers/acpi/pci_root.c
802 +index e36842b9..a02a91cd 100644
803 +--- a/drivers/acpi/pci_root.c
804 ++++ b/drivers/acpi/pci_root.c
805 +@@ -63,6 +63,9 @@ static struct acpi_scan_handler pci_root_handler = {
806 + .ids = root_device_ids,
807 + .attach = acpi_pci_root_add,
808 + .detach = acpi_pci_root_remove,
809 ++ .hotplug = {
810 ++ .ignore = true,
811 ++ },
812 + };
813 +
814 + /* Lock to protect both acpi_pci_roots lists */
815 +diff --git a/drivers/acpi/scan.c b/drivers/acpi/scan.c
816 +index 362f0c2a..cca761e8 100644
817 +--- a/drivers/acpi/scan.c
818 ++++ b/drivers/acpi/scan.c
819 +@@ -1790,7 +1790,7 @@ static void acpi_scan_init_hotplug(acpi_handle handle, int type)
820 + */
821 + list_for_each_entry(hwid, &pnp.ids, list) {
822 + handler = acpi_scan_match_handler(hwid->id, NULL);
823 +- if (handler) {
824 ++ if (handler && !handler->hotplug.ignore) {
825 + acpi_install_notify_handler(handle, ACPI_SYSTEM_NOTIFY,
826 + acpi_hotplug_notify_cb, handler);
827 + break;
828 +diff --git a/drivers/ata/ahci.c b/drivers/ata/ahci.c
829 +index b1126254..3d67f764 100644
830 +--- a/drivers/ata/ahci.c
831 ++++ b/drivers/ata/ahci.c
832 +@@ -292,6 +292,10 @@ static const struct pci_device_id ahci_pci_tbl[] = {
833 + { PCI_VDEVICE(INTEL, 0x8d66), board_ahci }, /* Wellsburg RAID */
834 + { PCI_VDEVICE(INTEL, 0x8d6e), board_ahci }, /* Wellsburg RAID */
835 + { PCI_VDEVICE(INTEL, 0x23a3), board_ahci }, /* Coleto Creek AHCI */
836 ++ { PCI_VDEVICE(INTEL, 0x9c83), board_ahci }, /* Wildcat Point-LP AHCI */
837 ++ { PCI_VDEVICE(INTEL, 0x9c85), board_ahci }, /* Wildcat Point-LP RAID */
838 ++ { PCI_VDEVICE(INTEL, 0x9c87), board_ahci }, /* Wildcat Point-LP RAID */
839 ++ { PCI_VDEVICE(INTEL, 0x9c8f), board_ahci }, /* Wildcat Point-LP RAID */
840 +
841 + /* JMicron 360/1/3/5/6, match class to avoid IDE function */
842 + { PCI_VENDOR_ID_JMICRON, PCI_ANY_ID, PCI_ANY_ID, PCI_ANY_ID,
843 +@@ -431,6 +435,8 @@ static const struct pci_device_id ahci_pci_tbl[] = {
844 + .driver_data = board_ahci_yes_fbs }, /* 88se9172 on some Gigabyte */
845 + { PCI_DEVICE(PCI_VENDOR_ID_MARVELL_EXT, 0x91a3),
846 + .driver_data = board_ahci_yes_fbs },
847 ++ { PCI_DEVICE(PCI_VENDOR_ID_MARVELL_EXT, 0x9230),
848 ++ .driver_data = board_ahci_yes_fbs },
849 +
850 + /* Promise */
851 + { PCI_VDEVICE(PROMISE, 0x3f20), board_ahci }, /* PDC42819 */
852 +diff --git a/drivers/ata/libahci.c b/drivers/ata/libahci.c
853 +index 7b9bdd82..8905e03a 100644
854 +--- a/drivers/ata/libahci.c
855 ++++ b/drivers/ata/libahci.c
856 +@@ -1266,9 +1266,11 @@ int ahci_do_softreset(struct ata_link *link, unsigned int *class,
857 + {
858 + struct ata_port *ap = link->ap;
859 + struct ahci_host_priv *hpriv = ap->host->private_data;
860 ++ struct ahci_port_priv *pp = ap->private_data;
861 + const char *reason = NULL;
862 + unsigned long now, msecs;
863 + struct ata_taskfile tf;
864 ++ bool fbs_disabled = false;
865 + int rc;
866 +
867 + DPRINTK("ENTER\n");
868 +@@ -1278,6 +1280,16 @@ int ahci_do_softreset(struct ata_link *link, unsigned int *class,
869 + if (rc && rc != -EOPNOTSUPP)
870 + ata_link_warn(link, "failed to reset engine (errno=%d)\n", rc);
871 +
872 ++ /*
873 ++ * According to AHCI-1.2 9.3.9: if FBS is enable, software shall
874 ++ * clear PxFBS.EN to '0' prior to issuing software reset to devices
875 ++ * that is attached to port multiplier.
876 ++ */
877 ++ if (!ata_is_host_link(link) && pp->fbs_enabled) {
878 ++ ahci_disable_fbs(ap);
879 ++ fbs_disabled = true;
880 ++ }
881 ++
882 + ata_tf_init(link->device, &tf);
883 +
884 + /* issue the first D2H Register FIS */
885 +@@ -1318,6 +1330,10 @@ int ahci_do_softreset(struct ata_link *link, unsigned int *class,
886 + } else
887 + *class = ahci_dev_classify(ap);
888 +
889 ++ /* re-enable FBS if disabled before */
890 ++ if (fbs_disabled)
891 ++ ahci_enable_fbs(ap);
892 ++
893 + DPRINTK("EXIT, class=%u\n", *class);
894 + return 0;
895 +
896 +diff --git a/drivers/ata/libata-core.c b/drivers/ata/libata-core.c
897 +index adf002a3..cd6aa28a 100644
898 +--- a/drivers/ata/libata-core.c
899 ++++ b/drivers/ata/libata-core.c
900 +@@ -4110,6 +4110,7 @@ static const struct ata_blacklist_entry ata_device_blacklist [] = {
901 + { "TORiSAN DVD-ROM DRD-N216", NULL, ATA_HORKAGE_MAX_SEC_128 },
902 + { "QUANTUM DAT DAT72-000", NULL, ATA_HORKAGE_ATAPI_MOD16_DMA },
903 + { "Slimtype DVD A DS8A8SH", NULL, ATA_HORKAGE_MAX_SEC_LBA48 },
904 ++ { "Slimtype DVD A DS8A9SH", NULL, ATA_HORKAGE_MAX_SEC_LBA48 },
905 +
906 + /* Devices we expect to fail diagnostics */
907 +
908 +diff --git a/drivers/ata/libata-transport.c b/drivers/ata/libata-transport.c
909 +index c04d393d..08e67285 100644
910 +--- a/drivers/ata/libata-transport.c
911 ++++ b/drivers/ata/libata-transport.c
912 +@@ -319,25 +319,25 @@ int ata_tport_add(struct device *parent,
913 + /*
914 + * ATA link attributes
915 + */
916 ++static int noop(int x) { return x; }
917 +
918 +-
919 +-#define ata_link_show_linkspeed(field) \
920 ++#define ata_link_show_linkspeed(field, format) \
921 + static ssize_t \
922 + show_ata_link_##field(struct device *dev, \
923 + struct device_attribute *attr, char *buf) \
924 + { \
925 + struct ata_link *link = transport_class_to_link(dev); \
926 + \
927 +- return sprintf(buf,"%s\n", sata_spd_string(fls(link->field))); \
928 ++ return sprintf(buf, "%s\n", sata_spd_string(format(link->field))); \
929 + }
930 +
931 +-#define ata_link_linkspeed_attr(field) \
932 +- ata_link_show_linkspeed(field) \
933 ++#define ata_link_linkspeed_attr(field, format) \
934 ++ ata_link_show_linkspeed(field, format) \
935 + static DEVICE_ATTR(field, S_IRUGO, show_ata_link_##field, NULL)
936 +
937 +-ata_link_linkspeed_attr(hw_sata_spd_limit);
938 +-ata_link_linkspeed_attr(sata_spd_limit);
939 +-ata_link_linkspeed_attr(sata_spd);
940 ++ata_link_linkspeed_attr(hw_sata_spd_limit, fls);
941 ++ata_link_linkspeed_attr(sata_spd_limit, fls);
942 ++ata_link_linkspeed_attr(sata_spd, noop);
943 +
944 +
945 + static DECLARE_TRANSPORT_CLASS(ata_link_class,
946 +diff --git a/drivers/base/dd.c b/drivers/base/dd.c
947 +index 35fa3689..06051767 100644
948 +--- a/drivers/base/dd.c
949 ++++ b/drivers/base/dd.c
950 +@@ -499,7 +499,7 @@ static void __device_release_driver(struct device *dev)
951 + BUS_NOTIFY_UNBIND_DRIVER,
952 + dev);
953 +
954 +- pm_runtime_put(dev);
955 ++ pm_runtime_put_sync(dev);
956 +
957 + if (dev->bus && dev->bus->remove)
958 + dev->bus->remove(dev);
959 +diff --git a/drivers/block/loop.c b/drivers/block/loop.c
960 +index 00559736..4a811654 100644
961 +--- a/drivers/block/loop.c
962 ++++ b/drivers/block/loop.c
963 +@@ -894,13 +894,6 @@ static int loop_set_fd(struct loop_device *lo, fmode_t mode,
964 +
965 + bio_list_init(&lo->lo_bio_list);
966 +
967 +- /*
968 +- * set queue make_request_fn, and add limits based on lower level
969 +- * device
970 +- */
971 +- blk_queue_make_request(lo->lo_queue, loop_make_request);
972 +- lo->lo_queue->queuedata = lo;
973 +-
974 + if (!(lo_flags & LO_FLAGS_READ_ONLY) && file->f_op->fsync)
975 + blk_queue_flush(lo->lo_queue, REQ_FLUSH);
976 +
977 +@@ -1618,6 +1611,8 @@ static int loop_add(struct loop_device **l, int i)
978 + if (!lo)
979 + goto out;
980 +
981 ++ lo->lo_state = Lo_unbound;
982 ++
983 + /* allocate id, if @id >= 0, we're requesting that specific id */
984 + if (i >= 0) {
985 + err = idr_alloc(&loop_index_idr, lo, i, i + 1, GFP_KERNEL);
986 +@@ -1633,7 +1628,13 @@ static int loop_add(struct loop_device **l, int i)
987 + err = -ENOMEM;
988 + lo->lo_queue = blk_alloc_queue(GFP_KERNEL);
989 + if (!lo->lo_queue)
990 +- goto out_free_dev;
991 ++ goto out_free_idr;
992 ++
993 ++ /*
994 ++ * set queue make_request_fn
995 ++ */
996 ++ blk_queue_make_request(lo->lo_queue, loop_make_request);
997 ++ lo->lo_queue->queuedata = lo;
998 +
999 + disk = lo->lo_disk = alloc_disk(1 << part_shift);
1000 + if (!disk)
1001 +@@ -1678,6 +1679,8 @@ static int loop_add(struct loop_device **l, int i)
1002 +
1003 + out_free_queue:
1004 + blk_cleanup_queue(lo->lo_queue);
1005 ++out_free_idr:
1006 ++ idr_remove(&loop_index_idr, i);
1007 + out_free_dev:
1008 + kfree(lo);
1009 + out:
1010 +diff --git a/drivers/block/xen-blkback/blkback.c b/drivers/block/xen-blkback/blkback.c
1011 +index d81dfca7..03dd4aa6 100644
1012 +--- a/drivers/block/xen-blkback/blkback.c
1013 ++++ b/drivers/block/xen-blkback/blkback.c
1014 +@@ -649,6 +649,8 @@ static int dispatch_discard_io(struct xen_blkif *blkif,
1015 + unsigned long secure;
1016 + struct phys_req preq;
1017 +
1018 ++ xen_blkif_get(blkif);
1019 ++
1020 + preq.sector_number = req->u.discard.sector_number;
1021 + preq.nr_sects = req->u.discard.nr_sectors;
1022 +
1023 +@@ -661,7 +663,6 @@ static int dispatch_discard_io(struct xen_blkif *blkif,
1024 + }
1025 + blkif->st_ds_req++;
1026 +
1027 +- xen_blkif_get(blkif);
1028 + secure = (blkif->vbd.discard_secure &&
1029 + (req->u.discard.flag & BLKIF_DISCARD_SECURE)) ?
1030 + BLKDEV_DISCARD_SECURE : 0;
1031 +diff --git a/drivers/clk/mvebu/clk-core.c b/drivers/clk/mvebu/clk-core.c
1032 +index 0a53edba..e5c477b4 100644
1033 +--- a/drivers/clk/mvebu/clk-core.c
1034 ++++ b/drivers/clk/mvebu/clk-core.c
1035 +@@ -126,8 +126,8 @@ static void __init mvebu_clk_core_setup(struct device_node *np,
1036 + #define SARH_AXP_FAB_FREQ_OPT_SHIFT 4
1037 +
1038 + static const u32 __initconst armada_370_tclk_frequencies[] = {
1039 +- 16600000,
1040 +- 20000000,
1041 ++ 166000000,
1042 ++ 200000000,
1043 + };
1044 +
1045 + static u32 __init armada_370_get_tclk_freq(void __iomem *sar)
1046 +diff --git a/drivers/cpufreq/highbank-cpufreq.c b/drivers/cpufreq/highbank-cpufreq.c
1047 +index b61b5a3f..8c4771da 100644
1048 +--- a/drivers/cpufreq/highbank-cpufreq.c
1049 ++++ b/drivers/cpufreq/highbank-cpufreq.c
1050 +@@ -66,7 +66,8 @@ static int hb_cpufreq_driver_init(void)
1051 + struct device_node *np;
1052 + int ret;
1053 +
1054 +- if (!of_machine_is_compatible("calxeda,highbank"))
1055 ++ if ((!of_machine_is_compatible("calxeda,highbank")) &&
1056 ++ (!of_machine_is_compatible("calxeda,ecx-2000")))
1057 + return -ENODEV;
1058 +
1059 + for_each_child_of_node(of_find_node_by_path("/cpus"), np)
1060 +diff --git a/drivers/dma/ioat/dma_v3.c b/drivers/dma/ioat/dma_v3.c
1061 +index ca6ea9b3..fa43a42c 100644
1062 +--- a/drivers/dma/ioat/dma_v3.c
1063 ++++ b/drivers/dma/ioat/dma_v3.c
1064 +@@ -87,13 +87,6 @@ static const u8 pq_idx_to_field[] = { 1, 4, 5, 0, 1, 2, 4, 5 };
1065 + static const u8 pq16_idx_to_field[] = { 1, 4, 1, 2, 3, 4, 5, 6, 7,
1066 + 0, 1, 2, 3, 4, 5, 6 };
1067 +
1068 +-/*
1069 +- * technically sources 1 and 2 do not require SED, but the op will have
1070 +- * at least 9 descriptors so that's irrelevant.
1071 +- */
1072 +-static const u8 pq16_idx_to_sed[] = { 0, 0, 0, 0, 0, 0, 0, 0, 0,
1073 +- 1, 1, 1, 1, 1, 1, 1 };
1074 +-
1075 + static void ioat3_eh(struct ioat2_dma_chan *ioat);
1076 +
1077 + static dma_addr_t xor_get_src(struct ioat_raw_descriptor *descs[2], int idx)
1078 +@@ -135,12 +128,6 @@ static void pq_set_src(struct ioat_raw_descriptor *descs[2],
1079 + pq->coef[idx] = coef;
1080 + }
1081 +
1082 +-static int sed_get_pq16_pool_idx(int src_cnt)
1083 +-{
1084 +-
1085 +- return pq16_idx_to_sed[src_cnt];
1086 +-}
1087 +-
1088 + static bool is_jf_ioat(struct pci_dev *pdev)
1089 + {
1090 + switch (pdev->device) {
1091 +@@ -1182,9 +1169,6 @@ __ioat3_prep_pq16_lock(struct dma_chan *c, enum sum_check_flags *result,
1092 + u8 op;
1093 + int i, s, idx, num_descs;
1094 +
1095 +- /* this function only handles src_cnt 9 - 16 */
1096 +- BUG_ON(src_cnt < 9);
1097 +-
1098 + /* this function is only called with 9-16 sources */
1099 + op = result ? IOAT_OP_PQ_VAL_16S : IOAT_OP_PQ_16S;
1100 +
1101 +@@ -1212,8 +1196,7 @@ __ioat3_prep_pq16_lock(struct dma_chan *c, enum sum_check_flags *result,
1102 +
1103 + descs[0] = (struct ioat_raw_descriptor *) pq;
1104 +
1105 +- desc->sed = ioat3_alloc_sed(device,
1106 +- sed_get_pq16_pool_idx(src_cnt));
1107 ++ desc->sed = ioat3_alloc_sed(device, (src_cnt-2) >> 3);
1108 + if (!desc->sed) {
1109 + dev_err(to_dev(chan),
1110 + "%s: no free sed entries\n", __func__);
1111 +@@ -1271,13 +1254,21 @@ __ioat3_prep_pq16_lock(struct dma_chan *c, enum sum_check_flags *result,
1112 + return &desc->txd;
1113 + }
1114 +
1115 ++static int src_cnt_flags(unsigned int src_cnt, unsigned long flags)
1116 ++{
1117 ++ if (dmaf_p_disabled_continue(flags))
1118 ++ return src_cnt + 1;
1119 ++ else if (dmaf_continue(flags))
1120 ++ return src_cnt + 3;
1121 ++ else
1122 ++ return src_cnt;
1123 ++}
1124 ++
1125 + static struct dma_async_tx_descriptor *
1126 + ioat3_prep_pq(struct dma_chan *chan, dma_addr_t *dst, dma_addr_t *src,
1127 + unsigned int src_cnt, const unsigned char *scf, size_t len,
1128 + unsigned long flags)
1129 + {
1130 +- struct dma_device *dma = chan->device;
1131 +-
1132 + /* specify valid address for disabled result */
1133 + if (flags & DMA_PREP_PQ_DISABLE_P)
1134 + dst[0] = dst[1];
1135 +@@ -1297,7 +1288,7 @@ ioat3_prep_pq(struct dma_chan *chan, dma_addr_t *dst, dma_addr_t *src,
1136 + single_source_coef[0] = scf[0];
1137 + single_source_coef[1] = 0;
1138 +
1139 +- return (src_cnt > 8) && (dma->max_pq > 8) ?
1140 ++ return src_cnt_flags(src_cnt, flags) > 8 ?
1141 + __ioat3_prep_pq16_lock(chan, NULL, dst, single_source,
1142 + 2, single_source_coef, len,
1143 + flags) :
1144 +@@ -1305,7 +1296,7 @@ ioat3_prep_pq(struct dma_chan *chan, dma_addr_t *dst, dma_addr_t *src,
1145 + single_source_coef, len, flags);
1146 +
1147 + } else {
1148 +- return (src_cnt > 8) && (dma->max_pq > 8) ?
1149 ++ return src_cnt_flags(src_cnt, flags) > 8 ?
1150 + __ioat3_prep_pq16_lock(chan, NULL, dst, src, src_cnt,
1151 + scf, len, flags) :
1152 + __ioat3_prep_pq_lock(chan, NULL, dst, src, src_cnt,
1153 +@@ -1318,8 +1309,6 @@ ioat3_prep_pq_val(struct dma_chan *chan, dma_addr_t *pq, dma_addr_t *src,
1154 + unsigned int src_cnt, const unsigned char *scf, size_t len,
1155 + enum sum_check_flags *pqres, unsigned long flags)
1156 + {
1157 +- struct dma_device *dma = chan->device;
1158 +-
1159 + /* specify valid address for disabled result */
1160 + if (flags & DMA_PREP_PQ_DISABLE_P)
1161 + pq[0] = pq[1];
1162 +@@ -1331,7 +1320,7 @@ ioat3_prep_pq_val(struct dma_chan *chan, dma_addr_t *pq, dma_addr_t *src,
1163 + */
1164 + *pqres = 0;
1165 +
1166 +- return (src_cnt > 8) && (dma->max_pq > 8) ?
1167 ++ return src_cnt_flags(src_cnt, flags) > 8 ?
1168 + __ioat3_prep_pq16_lock(chan, pqres, pq, src, src_cnt, scf, len,
1169 + flags) :
1170 + __ioat3_prep_pq_lock(chan, pqres, pq, src, src_cnt, scf, len,
1171 +@@ -1342,7 +1331,6 @@ static struct dma_async_tx_descriptor *
1172 + ioat3_prep_pqxor(struct dma_chan *chan, dma_addr_t dst, dma_addr_t *src,
1173 + unsigned int src_cnt, size_t len, unsigned long flags)
1174 + {
1175 +- struct dma_device *dma = chan->device;
1176 + unsigned char scf[src_cnt];
1177 + dma_addr_t pq[2];
1178 +
1179 +@@ -1351,7 +1339,7 @@ ioat3_prep_pqxor(struct dma_chan *chan, dma_addr_t dst, dma_addr_t *src,
1180 + flags |= DMA_PREP_PQ_DISABLE_Q;
1181 + pq[1] = dst; /* specify valid address for disabled result */
1182 +
1183 +- return (src_cnt > 8) && (dma->max_pq > 8) ?
1184 ++ return src_cnt_flags(src_cnt, flags) > 8 ?
1185 + __ioat3_prep_pq16_lock(chan, NULL, pq, src, src_cnt, scf, len,
1186 + flags) :
1187 + __ioat3_prep_pq_lock(chan, NULL, pq, src, src_cnt, scf, len,
1188 +@@ -1363,7 +1351,6 @@ ioat3_prep_pqxor_val(struct dma_chan *chan, dma_addr_t *src,
1189 + unsigned int src_cnt, size_t len,
1190 + enum sum_check_flags *result, unsigned long flags)
1191 + {
1192 +- struct dma_device *dma = chan->device;
1193 + unsigned char scf[src_cnt];
1194 + dma_addr_t pq[2];
1195 +
1196 +@@ -1377,8 +1364,7 @@ ioat3_prep_pqxor_val(struct dma_chan *chan, dma_addr_t *src,
1197 + flags |= DMA_PREP_PQ_DISABLE_Q;
1198 + pq[1] = pq[0]; /* specify valid address for disabled result */
1199 +
1200 +-
1201 +- return (src_cnt > 8) && (dma->max_pq > 8) ?
1202 ++ return src_cnt_flags(src_cnt, flags) > 8 ?
1203 + __ioat3_prep_pq16_lock(chan, result, pq, &src[1], src_cnt - 1,
1204 + scf, len, flags) :
1205 + __ioat3_prep_pq_lock(chan, result, pq, &src[1], src_cnt - 1,
1206 +diff --git a/drivers/edac/highbank_l2_edac.c b/drivers/edac/highbank_l2_edac.c
1207 +index c2bd8c6a..10d3d298 100644
1208 +--- a/drivers/edac/highbank_l2_edac.c
1209 ++++ b/drivers/edac/highbank_l2_edac.c
1210 +@@ -90,28 +90,30 @@ static int highbank_l2_err_probe(struct platform_device *pdev)
1211 + goto err;
1212 + }
1213 +
1214 ++ dci->mod_name = dev_name(&pdev->dev);
1215 ++ dci->dev_name = dev_name(&pdev->dev);
1216 ++
1217 ++ if (edac_device_add_device(dci))
1218 ++ goto err;
1219 ++
1220 + drvdata->db_irq = platform_get_irq(pdev, 0);
1221 + res = devm_request_irq(&pdev->dev, drvdata->db_irq,
1222 + highbank_l2_err_handler,
1223 + 0, dev_name(&pdev->dev), dci);
1224 + if (res < 0)
1225 +- goto err;
1226 ++ goto err2;
1227 +
1228 + drvdata->sb_irq = platform_get_irq(pdev, 1);
1229 + res = devm_request_irq(&pdev->dev, drvdata->sb_irq,
1230 + highbank_l2_err_handler,
1231 + 0, dev_name(&pdev->dev), dci);
1232 + if (res < 0)
1233 +- goto err;
1234 +-
1235 +- dci->mod_name = dev_name(&pdev->dev);
1236 +- dci->dev_name = dev_name(&pdev->dev);
1237 +-
1238 +- if (edac_device_add_device(dci))
1239 +- goto err;
1240 ++ goto err2;
1241 +
1242 + devres_close_group(&pdev->dev, NULL);
1243 + return 0;
1244 ++err2:
1245 ++ edac_device_del_device(&pdev->dev);
1246 + err:
1247 + devres_release_group(&pdev->dev, NULL);
1248 + edac_device_free_ctl_info(dci);
1249 +diff --git a/drivers/edac/highbank_mc_edac.c b/drivers/edac/highbank_mc_edac.c
1250 +index 4695dd2d..7a783075 100644
1251 +--- a/drivers/edac/highbank_mc_edac.c
1252 ++++ b/drivers/edac/highbank_mc_edac.c
1253 +@@ -189,14 +189,6 @@ static int highbank_mc_probe(struct platform_device *pdev)
1254 + goto err;
1255 + }
1256 +
1257 +- irq = platform_get_irq(pdev, 0);
1258 +- res = devm_request_irq(&pdev->dev, irq, highbank_mc_err_handler,
1259 +- 0, dev_name(&pdev->dev), mci);
1260 +- if (res < 0) {
1261 +- dev_err(&pdev->dev, "Unable to request irq %d\n", irq);
1262 +- goto err;
1263 +- }
1264 +-
1265 + mci->mtype_cap = MEM_FLAG_DDR3;
1266 + mci->edac_ctl_cap = EDAC_FLAG_NONE | EDAC_FLAG_SECDED;
1267 + mci->edac_cap = EDAC_FLAG_SECDED;
1268 +@@ -217,10 +209,20 @@ static int highbank_mc_probe(struct platform_device *pdev)
1269 + if (res < 0)
1270 + goto err;
1271 +
1272 ++ irq = platform_get_irq(pdev, 0);
1273 ++ res = devm_request_irq(&pdev->dev, irq, highbank_mc_err_handler,
1274 ++ 0, dev_name(&pdev->dev), mci);
1275 ++ if (res < 0) {
1276 ++ dev_err(&pdev->dev, "Unable to request irq %d\n", irq);
1277 ++ goto err2;
1278 ++ }
1279 ++
1280 + highbank_mc_create_debugfs_nodes(mci);
1281 +
1282 + devres_close_group(&pdev->dev, NULL);
1283 + return 0;
1284 ++err2:
1285 ++ edac_mc_del_mc(&pdev->dev);
1286 + err:
1287 + devres_release_group(&pdev->dev, NULL);
1288 + edac_mc_free(mci);
1289 +diff --git a/drivers/gpio/gpio-mvebu.c b/drivers/gpio/gpio-mvebu.c
1290 +index 3a4816ad..5c27da6a 100644
1291 +--- a/drivers/gpio/gpio-mvebu.c
1292 ++++ b/drivers/gpio/gpio-mvebu.c
1293 +@@ -79,7 +79,7 @@ struct mvebu_gpio_chip {
1294 + spinlock_t lock;
1295 + void __iomem *membase;
1296 + void __iomem *percpu_membase;
1297 +- unsigned int irqbase;
1298 ++ int irqbase;
1299 + struct irq_domain *domain;
1300 + int soc_variant;
1301 + };
1302 +diff --git a/drivers/gpio/gpio-pl061.c b/drivers/gpio/gpio-pl061.c
1303 +index 6a4bd0da..4fbe12d2 100644
1304 +--- a/drivers/gpio/gpio-pl061.c
1305 ++++ b/drivers/gpio/gpio-pl061.c
1306 +@@ -286,11 +286,6 @@ static int pl061_probe(struct amba_device *adev, const struct amba_id *id)
1307 + if (!chip->base)
1308 + return -ENOMEM;
1309 +
1310 +- chip->domain = irq_domain_add_simple(adev->dev.of_node, PL061_GPIO_NR,
1311 +- irq_base, &pl061_domain_ops, chip);
1312 +- if (!chip->domain)
1313 +- return -ENODEV;
1314 +-
1315 + spin_lock_init(&chip->lock);
1316 +
1317 + chip->gc.request = pl061_gpio_request;
1318 +@@ -320,6 +315,11 @@ static int pl061_probe(struct amba_device *adev, const struct amba_id *id)
1319 + irq_set_chained_handler(irq, pl061_irq_handler);
1320 + irq_set_handler_data(irq, chip);
1321 +
1322 ++ chip->domain = irq_domain_add_simple(adev->dev.of_node, PL061_GPIO_NR,
1323 ++ irq_base, &pl061_domain_ops, chip);
1324 ++ if (!chip->domain)
1325 ++ return -ENODEV;
1326 ++
1327 + for (i = 0; i < PL061_GPIO_NR; i++) {
1328 + if (pdata) {
1329 + if (pdata->directions & (1 << i))
1330 +diff --git a/drivers/gpio/gpio-rcar.c b/drivers/gpio/gpio-rcar.c
1331 +index b4ca4509..c45ad478 100644
1332 +--- a/drivers/gpio/gpio-rcar.c
1333 ++++ b/drivers/gpio/gpio-rcar.c
1334 +@@ -329,7 +329,7 @@ static int gpio_rcar_probe(struct platform_device *pdev)
1335 + if (!p->irq_domain) {
1336 + ret = -ENXIO;
1337 + dev_err(&pdev->dev, "cannot initialize irq domain\n");
1338 +- goto err1;
1339 ++ goto err0;
1340 + }
1341 +
1342 + if (devm_request_irq(&pdev->dev, irq->start,
1343 +diff --git a/drivers/gpio/gpio-twl4030.c b/drivers/gpio/gpio-twl4030.c
1344 +index 4d330e36..ed1d10ae 100644
1345 +--- a/drivers/gpio/gpio-twl4030.c
1346 ++++ b/drivers/gpio/gpio-twl4030.c
1347 +@@ -354,17 +354,18 @@ static void twl_set(struct gpio_chip *chip, unsigned offset, int value)
1348 + static int twl_direction_out(struct gpio_chip *chip, unsigned offset, int value)
1349 + {
1350 + struct gpio_twl4030_priv *priv = to_gpio_twl4030(chip);
1351 ++ int ret = -EINVAL;
1352 +
1353 + mutex_lock(&priv->mutex);
1354 + if (offset < TWL4030_GPIO_MAX)
1355 +- twl4030_set_gpio_dataout(offset, value);
1356 ++ ret = twl4030_set_gpio_direction(offset, 0);
1357 +
1358 + priv->direction |= BIT(offset);
1359 + mutex_unlock(&priv->mutex);
1360 +
1361 + twl_set(chip, offset, value);
1362 +
1363 +- return 0;
1364 ++ return ret;
1365 + }
1366 +
1367 + static int twl_to_irq(struct gpio_chip *chip, unsigned offset)
1368 +diff --git a/drivers/gpu/drm/i915/intel_display.c b/drivers/gpu/drm/i915/intel_display.c
1369 +index ab952595..c714d4d5 100644
1370 +--- a/drivers/gpu/drm/i915/intel_display.c
1371 ++++ b/drivers/gpu/drm/i915/intel_display.c
1372 +@@ -6262,7 +6262,9 @@ static void i9xx_update_cursor(struct drm_crtc *crtc, u32 base)
1373 + intel_crtc->cursor_visible = visible;
1374 + }
1375 + /* and commit changes on next vblank */
1376 ++ POSTING_READ(CURCNTR(pipe));
1377 + I915_WRITE(CURBASE(pipe), base);
1378 ++ POSTING_READ(CURBASE(pipe));
1379 + }
1380 +
1381 + static void ivb_update_cursor(struct drm_crtc *crtc, u32 base)
1382 +@@ -6289,7 +6291,9 @@ static void ivb_update_cursor(struct drm_crtc *crtc, u32 base)
1383 + intel_crtc->cursor_visible = visible;
1384 + }
1385 + /* and commit changes on next vblank */
1386 ++ POSTING_READ(CURCNTR_IVB(pipe));
1387 + I915_WRITE(CURBASE_IVB(pipe), base);
1388 ++ POSTING_READ(CURBASE_IVB(pipe));
1389 + }
1390 +
1391 + /* If no-part of the cursor is visible on the framebuffer, then the GPU may hang... */
1392 +diff --git a/drivers/gpu/drm/nouveau/nouveau_gem.c b/drivers/gpu/drm/nouveau/nouveau_gem.c
1393 +index b4b4d0c1..5bccf31c 100644
1394 +--- a/drivers/gpu/drm/nouveau/nouveau_gem.c
1395 ++++ b/drivers/gpu/drm/nouveau/nouveau_gem.c
1396 +@@ -287,7 +287,8 @@ validate_fini_list(struct list_head *list, struct nouveau_fence *fence)
1397 + list_for_each_safe(entry, tmp, list) {
1398 + nvbo = list_entry(entry, struct nouveau_bo, entry);
1399 +
1400 +- nouveau_bo_fence(nvbo, fence);
1401 ++ if (likely(fence))
1402 ++ nouveau_bo_fence(nvbo, fence);
1403 +
1404 + if (unlikely(nvbo->validate_mapped)) {
1405 + ttm_bo_kunmap(&nvbo->kmap);
1406 +diff --git a/drivers/gpu/drm/qxl/qxl_fb.c b/drivers/gpu/drm/qxl/qxl_fb.c
1407 +index b3c51275..7002de79 100644
1408 +--- a/drivers/gpu/drm/qxl/qxl_fb.c
1409 ++++ b/drivers/gpu/drm/qxl/qxl_fb.c
1410 +@@ -91,7 +91,7 @@ static void qxl_fb_dirty_flush(struct fb_info *info)
1411 + u32 x1, x2, y1, y2;
1412 +
1413 + /* TODO: hard coding 32 bpp */
1414 +- int stride = qfbdev->qfb.base.pitches[0] * 4;
1415 ++ int stride = qfbdev->qfb.base.pitches[0];
1416 +
1417 + x1 = qfbdev->dirty.x1;
1418 + x2 = qfbdev->dirty.x2;
1419 +diff --git a/drivers/gpu/drm/radeon/atombios_crtc.c b/drivers/gpu/drm/radeon/atombios_crtc.c
1420 +index d5df8fd1..22f06c8d 100644
1421 +--- a/drivers/gpu/drm/radeon/atombios_crtc.c
1422 ++++ b/drivers/gpu/drm/radeon/atombios_crtc.c
1423 +@@ -1683,7 +1683,7 @@ static int radeon_atom_pick_pll(struct drm_crtc *crtc)
1424 + if (pll != ATOM_PPLL_INVALID)
1425 + return pll;
1426 + }
1427 +- } else {
1428 ++ } else if (!ASIC_IS_DCE41(rdev)) { /* Don't share PLLs on DCE4.1 chips */
1429 + /* use the same PPLL for all monitors with the same clock */
1430 + pll = radeon_get_shared_nondp_ppll(crtc);
1431 + if (pll != ATOM_PPLL_INVALID)
1432 +diff --git a/drivers/gpu/drm/radeon/evergreen_hdmi.c b/drivers/gpu/drm/radeon/evergreen_hdmi.c
1433 +index bb9ea364..067cc1fc 100644
1434 +--- a/drivers/gpu/drm/radeon/evergreen_hdmi.c
1435 ++++ b/drivers/gpu/drm/radeon/evergreen_hdmi.c
1436 +@@ -219,8 +219,7 @@ void evergreen_hdmi_setmode(struct drm_encoder *encoder, struct drm_display_mode
1437 + /* fglrx clears sth in AFMT_AUDIO_PACKET_CONTROL2 here */
1438 +
1439 + WREG32(HDMI_ACR_PACKET_CONTROL + offset,
1440 +- HDMI_ACR_AUTO_SEND | /* allow hw to sent ACR packets when required */
1441 +- HDMI_ACR_SOURCE); /* select SW CTS value */
1442 ++ HDMI_ACR_AUTO_SEND); /* allow hw to sent ACR packets when required */
1443 +
1444 + evergreen_hdmi_update_ACR(encoder, mode->clock);
1445 +
1446 +diff --git a/drivers/gpu/drm/radeon/r600_hdmi.c b/drivers/gpu/drm/radeon/r600_hdmi.c
1447 +index 0efe2a93..635e8f2e 100644
1448 +--- a/drivers/gpu/drm/radeon/r600_hdmi.c
1449 ++++ b/drivers/gpu/drm/radeon/r600_hdmi.c
1450 +@@ -57,15 +57,15 @@ enum r600_hdmi_iec_status_bits {
1451 + static const struct radeon_hdmi_acr r600_hdmi_predefined_acr[] = {
1452 + /* 32kHz 44.1kHz 48kHz */
1453 + /* Clock N CTS N CTS N CTS */
1454 +- { 25174, 4576, 28125, 7007, 31250, 6864, 28125 }, /* 25,20/1.001 MHz */
1455 ++ { 25175, 4576, 28125, 7007, 31250, 6864, 28125 }, /* 25,20/1.001 MHz */
1456 + { 25200, 4096, 25200, 6272, 28000, 6144, 25200 }, /* 25.20 MHz */
1457 + { 27000, 4096, 27000, 6272, 30000, 6144, 27000 }, /* 27.00 MHz */
1458 + { 27027, 4096, 27027, 6272, 30030, 6144, 27027 }, /* 27.00*1.001 MHz */
1459 + { 54000, 4096, 54000, 6272, 60000, 6144, 54000 }, /* 54.00 MHz */
1460 + { 54054, 4096, 54054, 6272, 60060, 6144, 54054 }, /* 54.00*1.001 MHz */
1461 +- { 74175, 11648, 210937, 17836, 234375, 11648, 140625 }, /* 74.25/1.001 MHz */
1462 ++ { 74176, 11648, 210937, 17836, 234375, 11648, 140625 }, /* 74.25/1.001 MHz */
1463 + { 74250, 4096, 74250, 6272, 82500, 6144, 74250 }, /* 74.25 MHz */
1464 +- { 148351, 11648, 421875, 8918, 234375, 5824, 140625 }, /* 148.50/1.001 MHz */
1465 ++ { 148352, 11648, 421875, 8918, 234375, 5824, 140625 }, /* 148.50/1.001 MHz */
1466 + { 148500, 4096, 148500, 6272, 165000, 6144, 148500 }, /* 148.50 MHz */
1467 + { 0, 4096, 0, 6272, 0, 6144, 0 } /* Other */
1468 + };
1469 +@@ -75,8 +75,15 @@ static const struct radeon_hdmi_acr r600_hdmi_predefined_acr[] = {
1470 + */
1471 + static void r600_hdmi_calc_cts(uint32_t clock, int *CTS, int N, int freq)
1472 + {
1473 +- if (*CTS == 0)
1474 +- *CTS = clock * N / (128 * freq) * 1000;
1475 ++ u64 n;
1476 ++ u32 d;
1477 ++
1478 ++ if (*CTS == 0) {
1479 ++ n = (u64)clock * (u64)N * 1000ULL;
1480 ++ d = 128 * freq;
1481 ++ do_div(n, d);
1482 ++ *CTS = n;
1483 ++ }
1484 + DRM_DEBUG("Using ACR timing N=%d CTS=%d for frequency %d\n",
1485 + N, *CTS, freq);
1486 + }
1487 +@@ -313,8 +320,8 @@ void r600_hdmi_setmode(struct drm_encoder *encoder, struct drm_display_mode *mod
1488 + }
1489 +
1490 + WREG32(HDMI0_ACR_PACKET_CONTROL + offset,
1491 +- HDMI0_ACR_AUTO_SEND | /* allow hw to sent ACR packets when required */
1492 +- HDMI0_ACR_SOURCE); /* select SW CTS value */
1493 ++ HDMI0_ACR_SOURCE | /* select SW CTS value - XXX verify that hw CTS works on all families */
1494 ++ HDMI0_ACR_AUTO_SEND); /* allow hw to sent ACR packets when required */
1495 +
1496 + WREG32(HDMI0_VBI_PACKET_CONTROL + offset,
1497 + HDMI0_NULL_SEND | /* send null packets when required */
1498 +diff --git a/drivers/gpu/drm/radeon/radeon_gart.c b/drivers/gpu/drm/radeon/radeon_gart.c
1499 +index 5ce190b8..2915a1c5 100644
1500 +--- a/drivers/gpu/drm/radeon/radeon_gart.c
1501 ++++ b/drivers/gpu/drm/radeon/radeon_gart.c
1502 +@@ -1157,6 +1157,8 @@ int radeon_vm_bo_update_pte(struct radeon_device *rdev,
1503 + return -ENOMEM;
1504 +
1505 + r = radeon_ib_get(rdev, ridx, &ib, NULL, ndw * 4);
1506 ++ if (r)
1507 ++ return r;
1508 + ib.length_dw = 0;
1509 +
1510 + r = radeon_vm_update_pdes(rdev, vm, &ib, bo_va->soffset, bo_va->eoffset);
1511 +diff --git a/drivers/gpu/drm/radeon/radeon_legacy_crtc.c b/drivers/gpu/drm/radeon/radeon_legacy_crtc.c
1512 +index 7cb178a3..bc73021d 100644
1513 +--- a/drivers/gpu/drm/radeon/radeon_legacy_crtc.c
1514 ++++ b/drivers/gpu/drm/radeon/radeon_legacy_crtc.c
1515 +@@ -422,6 +422,7 @@ int radeon_crtc_do_set_base(struct drm_crtc *crtc,
1516 + /* Pin framebuffer & get tilling informations */
1517 + obj = radeon_fb->obj;
1518 + rbo = gem_to_radeon_bo(obj);
1519 ++retry:
1520 + r = radeon_bo_reserve(rbo, false);
1521 + if (unlikely(r != 0))
1522 + return r;
1523 +@@ -430,6 +431,33 @@ int radeon_crtc_do_set_base(struct drm_crtc *crtc,
1524 + &base);
1525 + if (unlikely(r != 0)) {
1526 + radeon_bo_unreserve(rbo);
1527 ++
1528 ++ /* On old GPU like RN50 with little vram pining can fails because
1529 ++ * current fb is taking all space needed. So instead of unpining
1530 ++ * the old buffer after pining the new one, first unpin old one
1531 ++ * and then retry pining new one.
1532 ++ *
1533 ++ * As only master can set mode only master can pin and it is
1534 ++ * unlikely the master client will race with itself especialy
1535 ++ * on those old gpu with single crtc.
1536 ++ *
1537 ++ * We don't shutdown the display controller because new buffer
1538 ++ * will end up in same spot.
1539 ++ */
1540 ++ if (!atomic && fb && fb != crtc->fb) {
1541 ++ struct radeon_bo *old_rbo;
1542 ++ unsigned long nsize, osize;
1543 ++
1544 ++ old_rbo = gem_to_radeon_bo(to_radeon_framebuffer(fb)->obj);
1545 ++ osize = radeon_bo_size(old_rbo);
1546 ++ nsize = radeon_bo_size(rbo);
1547 ++ if (nsize <= osize && !radeon_bo_reserve(old_rbo, false)) {
1548 ++ radeon_bo_unpin(old_rbo);
1549 ++ radeon_bo_unreserve(old_rbo);
1550 ++ fb = NULL;
1551 ++ goto retry;
1552 ++ }
1553 ++ }
1554 + return -EINVAL;
1555 + }
1556 + radeon_bo_get_tiling_flags(rbo, &tiling_flags, NULL);
1557 +diff --git a/drivers/gpu/drm/radeon/radeon_uvd.c b/drivers/gpu/drm/radeon/radeon_uvd.c
1558 +index f3ccf6d4..a809b173 100644
1559 +--- a/drivers/gpu/drm/radeon/radeon_uvd.c
1560 ++++ b/drivers/gpu/drm/radeon/radeon_uvd.c
1561 +@@ -242,6 +242,8 @@ void radeon_uvd_free_handles(struct radeon_device *rdev, struct drm_file *filp)
1562 + if (handle != 0 && rdev->uvd.filp[i] == filp) {
1563 + struct radeon_fence *fence;
1564 +
1565 ++ radeon_uvd_note_usage(rdev);
1566 ++
1567 + r = radeon_uvd_get_destroy_msg(rdev,
1568 + R600_RING_TYPE_UVD_INDEX, handle, &fence);
1569 + if (r) {
1570 +diff --git a/drivers/gpu/drm/radeon/sid.h b/drivers/gpu/drm/radeon/sid.h
1571 +index 495f41f2..108c8d25 100644
1572 +--- a/drivers/gpu/drm/radeon/sid.h
1573 ++++ b/drivers/gpu/drm/radeon/sid.h
1574 +@@ -247,7 +247,7 @@
1575 + #define NOOFGROUPS_SHIFT 12
1576 + #define NOOFGROUPS_MASK 0x00001000
1577 +
1578 +-#define MC_SEQ_TRAIN_WAKEUP_CNTL 0x2808
1579 ++#define MC_SEQ_TRAIN_WAKEUP_CNTL 0x28e8
1580 + #define TRAIN_DONE_D0 (1 << 30)
1581 + #define TRAIN_DONE_D1 (1 << 31)
1582 +
1583 +diff --git a/drivers/gpu/drm/ttm/ttm_bo.c b/drivers/gpu/drm/ttm/ttm_bo.c
1584 +index 9b07b7d4..8697abd7 100644
1585 +--- a/drivers/gpu/drm/ttm/ttm_bo.c
1586 ++++ b/drivers/gpu/drm/ttm/ttm_bo.c
1587 +@@ -1153,24 +1153,32 @@ out_unlock:
1588 + return ret;
1589 + }
1590 +
1591 +-static int ttm_bo_mem_compat(struct ttm_placement *placement,
1592 +- struct ttm_mem_reg *mem)
1593 ++static bool ttm_bo_mem_compat(struct ttm_placement *placement,
1594 ++ struct ttm_mem_reg *mem,
1595 ++ uint32_t *new_flags)
1596 + {
1597 + int i;
1598 +
1599 + if (mem->mm_node && placement->lpfn != 0 &&
1600 + (mem->start < placement->fpfn ||
1601 + mem->start + mem->num_pages > placement->lpfn))
1602 +- return -1;
1603 ++ return false;
1604 +
1605 + for (i = 0; i < placement->num_placement; i++) {
1606 +- if ((placement->placement[i] & mem->placement &
1607 +- TTM_PL_MASK_CACHING) &&
1608 +- (placement->placement[i] & mem->placement &
1609 +- TTM_PL_MASK_MEM))
1610 +- return i;
1611 ++ *new_flags = placement->placement[i];
1612 ++ if ((*new_flags & mem->placement & TTM_PL_MASK_CACHING) &&
1613 ++ (*new_flags & mem->placement & TTM_PL_MASK_MEM))
1614 ++ return true;
1615 ++ }
1616 ++
1617 ++ for (i = 0; i < placement->num_busy_placement; i++) {
1618 ++ *new_flags = placement->busy_placement[i];
1619 ++ if ((*new_flags & mem->placement & TTM_PL_MASK_CACHING) &&
1620 ++ (*new_flags & mem->placement & TTM_PL_MASK_MEM))
1621 ++ return true;
1622 + }
1623 +- return -1;
1624 ++
1625 ++ return false;
1626 + }
1627 +
1628 + int ttm_bo_validate(struct ttm_buffer_object *bo,
1629 +@@ -1179,6 +1187,7 @@ int ttm_bo_validate(struct ttm_buffer_object *bo,
1630 + bool no_wait_gpu)
1631 + {
1632 + int ret;
1633 ++ uint32_t new_flags;
1634 +
1635 + BUG_ON(!ttm_bo_is_reserved(bo));
1636 + /* Check that range is valid */
1637 +@@ -1189,8 +1198,7 @@ int ttm_bo_validate(struct ttm_buffer_object *bo,
1638 + /*
1639 + * Check whether we need to move buffer.
1640 + */
1641 +- ret = ttm_bo_mem_compat(placement, &bo->mem);
1642 +- if (ret < 0) {
1643 ++ if (!ttm_bo_mem_compat(placement, &bo->mem, &new_flags)) {
1644 + ret = ttm_bo_move_buffer(bo, placement, interruptible,
1645 + no_wait_gpu);
1646 + if (ret)
1647 +@@ -1200,7 +1208,7 @@ int ttm_bo_validate(struct ttm_buffer_object *bo,
1648 + * Use the access and other non-mapping-related flag bits from
1649 + * the compatible memory placement flags to the active flags
1650 + */
1651 +- ttm_flag_masked(&bo->mem.placement, placement->placement[ret],
1652 ++ ttm_flag_masked(&bo->mem.placement, new_flags,
1653 + ~TTM_PL_MASK_MEMTYPE);
1654 + }
1655 + /*
1656 +diff --git a/drivers/gpu/drm/ttm/ttm_bo_util.c b/drivers/gpu/drm/ttm/ttm_bo_util.c
1657 +index af894584..b7f75715 100644
1658 +--- a/drivers/gpu/drm/ttm/ttm_bo_util.c
1659 ++++ b/drivers/gpu/drm/ttm/ttm_bo_util.c
1660 +@@ -342,19 +342,25 @@ int ttm_bo_move_memcpy(struct ttm_buffer_object *bo,
1661 + if (ret)
1662 + goto out;
1663 +
1664 ++ /*
1665 ++ * Single TTM move. NOP.
1666 ++ */
1667 + if (old_iomap == NULL && new_iomap == NULL)
1668 + goto out2;
1669 ++
1670 ++ /*
1671 ++ * Move nonexistent data. NOP.
1672 ++ */
1673 + if (old_iomap == NULL && ttm == NULL)
1674 + goto out2;
1675 +
1676 +- if (ttm->state == tt_unpopulated) {
1677 ++ /*
1678 ++ * TTM might be null for moves within the same region.
1679 ++ */
1680 ++ if (ttm && ttm->state == tt_unpopulated) {
1681 + ret = ttm->bdev->driver->ttm_tt_populate(ttm);
1682 +- if (ret) {
1683 +- /* if we fail here don't nuke the mm node
1684 +- * as the bo still owns it */
1685 +- old_copy.mm_node = NULL;
1686 ++ if (ret)
1687 + goto out1;
1688 +- }
1689 + }
1690 +
1691 + add = 0;
1692 +@@ -380,11 +386,8 @@ int ttm_bo_move_memcpy(struct ttm_buffer_object *bo,
1693 + prot);
1694 + } else
1695 + ret = ttm_copy_io_page(new_iomap, old_iomap, page);
1696 +- if (ret) {
1697 +- /* failing here, means keep old copy as-is */
1698 +- old_copy.mm_node = NULL;
1699 ++ if (ret)
1700 + goto out1;
1701 +- }
1702 + }
1703 + mb();
1704 + out2:
1705 +@@ -402,7 +405,12 @@ out1:
1706 + ttm_mem_reg_iounmap(bdev, old_mem, new_iomap);
1707 + out:
1708 + ttm_mem_reg_iounmap(bdev, &old_copy, old_iomap);
1709 +- ttm_bo_mem_put(bo, &old_copy);
1710 ++
1711 ++ /*
1712 ++ * On error, keep the mm node!
1713 ++ */
1714 ++ if (!ret)
1715 ++ ttm_bo_mem_put(bo, &old_copy);
1716 + return ret;
1717 + }
1718 + EXPORT_SYMBOL(ttm_bo_move_memcpy);
1719 +diff --git a/drivers/hid/Kconfig b/drivers/hid/Kconfig
1720 +index fb52f3f6..bee88ee8 100644
1721 +--- a/drivers/hid/Kconfig
1722 ++++ b/drivers/hid/Kconfig
1723 +@@ -352,12 +352,14 @@ config LOGITECH_FF
1724 + force feedback.
1725 +
1726 + config LOGIRUMBLEPAD2_FF
1727 +- bool "Logitech RumblePad/Rumblepad 2 force feedback support"
1728 ++ bool "Logitech force feedback support (variant 2)"
1729 + depends on HID_LOGITECH
1730 + select INPUT_FF_MEMLESS
1731 + help
1732 +- Say Y here if you want to enable force feedback support for Logitech
1733 +- RumblePad and Rumblepad 2 devices.
1734 ++ Say Y here if you want to enable force feedback support for:
1735 ++ - Logitech RumblePad
1736 ++ - Logitech Rumblepad 2
1737 ++ - Logitech Formula Vibration Feedback Wheel
1738 +
1739 + config LOGIG940_FF
1740 + bool "Logitech Flight System G940 force feedback support"
1741 +@@ -436,9 +438,11 @@ config HID_MULTITOUCH
1742 + - Pixcir dual touch panels
1743 + - Quanta panels
1744 + - eGalax dual-touch panels, including the Joojoo and Wetab tablets
1745 ++ - SiS multitouch panels
1746 + - Stantum multitouch panels
1747 + - Touch International Panels
1748 + - Unitec Panels
1749 ++ - Wistron optical touch panels
1750 + - XAT optical touch panels
1751 + - Xiroku optical touch panels
1752 + - Zytronic touch panels
1753 +diff --git a/drivers/hid/hid-apple.c b/drivers/hid/hid-apple.c
1754 +index c7710b5c..d54e1d0a 100644
1755 +--- a/drivers/hid/hid-apple.c
1756 ++++ b/drivers/hid/hid-apple.c
1757 +@@ -46,6 +46,12 @@ module_param(iso_layout, uint, 0644);
1758 + MODULE_PARM_DESC(iso_layout, "Enable/Disable hardcoded ISO-layout of the keyboard. "
1759 + "(0 = disabled, [1] = enabled)");
1760 +
1761 ++static unsigned int swap_opt_cmd = 0;
1762 ++module_param(swap_opt_cmd, uint, 0644);
1763 ++MODULE_PARM_DESC(swap_opt_cmd, "Swap the Option (\"Alt\") and Command (\"Flag\") keys. "
1764 ++ "(For people who want to keep Windows PC keyboard muscle memory. "
1765 ++ "[0] = as-is, Mac layout. 1 = swapped, Windows layout.)");
1766 ++
1767 + struct apple_sc {
1768 + unsigned long quirks;
1769 + unsigned int fn_on;
1770 +@@ -150,6 +156,14 @@ static const struct apple_key_translation apple_iso_keyboard[] = {
1771 + { }
1772 + };
1773 +
1774 ++static const struct apple_key_translation swapped_option_cmd_keys[] = {
1775 ++ { KEY_LEFTALT, KEY_LEFTMETA },
1776 ++ { KEY_LEFTMETA, KEY_LEFTALT },
1777 ++ { KEY_RIGHTALT, KEY_RIGHTMETA },
1778 ++ { KEY_RIGHTMETA,KEY_RIGHTALT },
1779 ++ { }
1780 ++};
1781 ++
1782 + static const struct apple_key_translation *apple_find_translation(
1783 + const struct apple_key_translation *table, u16 from)
1784 + {
1785 +@@ -242,6 +256,14 @@ static int hidinput_apple_event(struct hid_device *hid, struct input_dev *input,
1786 + }
1787 + }
1788 +
1789 ++ if (swap_opt_cmd) {
1790 ++ trans = apple_find_translation(swapped_option_cmd_keys, usage->code);
1791 ++ if (trans) {
1792 ++ input_event(input, usage->type, trans->to, value);
1793 ++ return 1;
1794 ++ }
1795 ++ }
1796 ++
1797 + return 0;
1798 + }
1799 +
1800 +diff --git a/drivers/hid/hid-axff.c b/drivers/hid/hid-axff.c
1801 +index 64ab94a5..a594e478 100644
1802 +--- a/drivers/hid/hid-axff.c
1803 ++++ b/drivers/hid/hid-axff.c
1804 +@@ -95,7 +95,7 @@ static int axff_init(struct hid_device *hid)
1805 + }
1806 + }
1807 +
1808 +- if (field_count < 4) {
1809 ++ if (field_count < 4 && hid->product != 0xf705) {
1810 + hid_err(hid, "not enough fields in the report: %d\n",
1811 + field_count);
1812 + return -ENODEV;
1813 +@@ -180,6 +180,7 @@ static void ax_remove(struct hid_device *hdev)
1814 +
1815 + static const struct hid_device_id ax_devices[] = {
1816 + { HID_USB_DEVICE(USB_VENDOR_ID_ACRUX, 0x0802), },
1817 ++ { HID_USB_DEVICE(USB_VENDOR_ID_ACRUX, 0xf705), },
1818 + { }
1819 + };
1820 + MODULE_DEVICE_TABLE(hid, ax_devices);
1821 +diff --git a/drivers/hid/hid-core.c b/drivers/hid/hid-core.c
1822 +index e04bf0ef..c4e5cdfa 100644
1823 +--- a/drivers/hid/hid-core.c
1824 ++++ b/drivers/hid/hid-core.c
1825 +@@ -1562,6 +1562,7 @@ static const struct hid_device_id hid_have_special_driver[] = {
1826 + { HID_USB_DEVICE(USB_VENDOR_ID_A4TECH, USB_DEVICE_ID_A4TECH_X5_005D) },
1827 + { HID_USB_DEVICE(USB_VENDOR_ID_A4TECH, USB_DEVICE_ID_A4TECH_RP_649) },
1828 + { HID_USB_DEVICE(USB_VENDOR_ID_ACRUX, 0x0802) },
1829 ++ { HID_USB_DEVICE(USB_VENDOR_ID_ACRUX, 0xf705) },
1830 + { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_MIGHTYMOUSE) },
1831 + { HID_BLUETOOTH_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_MAGICMOUSE) },
1832 + { HID_BLUETOOTH_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_MAGICTRACKPAD) },
1833 +@@ -1703,6 +1704,7 @@ static const struct hid_device_id hid_have_special_driver[] = {
1834 + { HID_USB_DEVICE(USB_VENDOR_ID_LOGITECH, USB_DEVICE_ID_LOGITECH_FLIGHT_SYSTEM_G940) },
1835 + { HID_USB_DEVICE(USB_VENDOR_ID_LOGITECH, USB_DEVICE_ID_LOGITECH_MOMO_WHEEL) },
1836 + { HID_USB_DEVICE(USB_VENDOR_ID_LOGITECH, USB_DEVICE_ID_LOGITECH_MOMO_WHEEL2) },
1837 ++ { HID_USB_DEVICE(USB_VENDOR_ID_LOGITECH, USB_DEVICE_ID_LOGITECH_VIBRATION_WHEEL) },
1838 + { HID_USB_DEVICE(USB_VENDOR_ID_LOGITECH, USB_DEVICE_ID_LOGITECH_DFP_WHEEL) },
1839 + { HID_USB_DEVICE(USB_VENDOR_ID_LOGITECH, USB_DEVICE_ID_LOGITECH_DFGT_WHEEL) },
1840 + { HID_USB_DEVICE(USB_VENDOR_ID_LOGITECH, USB_DEVICE_ID_LOGITECH_G25_WHEEL) },
1841 +@@ -1750,12 +1752,14 @@ static const struct hid_device_id hid_have_special_driver[] = {
1842 + { HID_USB_DEVICE(USB_VENDOR_ID_PETALYNX, USB_DEVICE_ID_PETALYNX_MAXTER_REMOTE) },
1843 + { HID_USB_DEVICE(USB_VENDOR_ID_PRIMAX, USB_DEVICE_ID_PRIMAX_KEYBOARD) },
1844 + #if IS_ENABLED(CONFIG_HID_ROCCAT)
1845 +- { HID_USB_DEVICE(USB_VENDOR_ID_ROCCAT, USB_DEVICE_ID_ROCCAT_KONE) },
1846 + { HID_USB_DEVICE(USB_VENDOR_ID_ROCCAT, USB_DEVICE_ID_ROCCAT_ARVO) },
1847 + { HID_USB_DEVICE(USB_VENDOR_ID_ROCCAT, USB_DEVICE_ID_ROCCAT_ISKU) },
1848 ++ { HID_USB_DEVICE(USB_VENDOR_ID_ROCCAT, USB_DEVICE_ID_ROCCAT_ISKUFX) },
1849 ++ { HID_USB_DEVICE(USB_VENDOR_ID_ROCCAT, USB_DEVICE_ID_ROCCAT_KONE) },
1850 + { HID_USB_DEVICE(USB_VENDOR_ID_ROCCAT, USB_DEVICE_ID_ROCCAT_KONEPLUS) },
1851 + { HID_USB_DEVICE(USB_VENDOR_ID_ROCCAT, USB_DEVICE_ID_ROCCAT_KONEPURE) },
1852 + { HID_USB_DEVICE(USB_VENDOR_ID_ROCCAT, USB_DEVICE_ID_ROCCAT_KONEPURE_OPTICAL) },
1853 ++ { HID_USB_DEVICE(USB_VENDOR_ID_ROCCAT, USB_DEVICE_ID_ROCCAT_KONEXTD) },
1854 + { HID_USB_DEVICE(USB_VENDOR_ID_ROCCAT, USB_DEVICE_ID_ROCCAT_KOVAPLUS) },
1855 + { HID_USB_DEVICE(USB_VENDOR_ID_ROCCAT, USB_DEVICE_ID_ROCCAT_LUA) },
1856 + { HID_USB_DEVICE(USB_VENDOR_ID_ROCCAT, USB_DEVICE_ID_ROCCAT_PYRA_WIRED) },
1857 +@@ -1765,6 +1769,8 @@ static const struct hid_device_id hid_have_special_driver[] = {
1858 + { HID_USB_DEVICE(USB_VENDOR_ID_SAITEK, USB_DEVICE_ID_SAITEK_PS1000) },
1859 + { HID_USB_DEVICE(USB_VENDOR_ID_SAMSUNG, USB_DEVICE_ID_SAMSUNG_IR_REMOTE) },
1860 + { HID_USB_DEVICE(USB_VENDOR_ID_SAMSUNG, USB_DEVICE_ID_SAMSUNG_WIRELESS_KBD_MOUSE) },
1861 ++ { HID_USB_DEVICE(USB_VENDOR_ID_SIS2_TOUCH, USB_DEVICE_ID_SIS9200_TOUCH) },
1862 ++ { HID_USB_DEVICE(USB_VENDOR_ID_SIS2_TOUCH, USB_DEVICE_ID_SIS817_TOUCH) },
1863 + { HID_USB_DEVICE(USB_VENDOR_ID_SKYCABLE, USB_DEVICE_ID_SKYCABLE_WIRELESS_PRESENTER) },
1864 + { HID_BLUETOOTH_DEVICE(USB_VENDOR_ID_SONY, USB_DEVICE_ID_SONY_PS3_BDREMOTE) },
1865 + { HID_USB_DEVICE(USB_VENDOR_ID_SONY, USB_DEVICE_ID_SONY_PS3_CONTROLLER) },
1866 +@@ -2317,15 +2323,6 @@ bool hid_ignore(struct hid_device *hdev)
1867 + hdev->type == HID_TYPE_USBNONE)
1868 + return true;
1869 + break;
1870 +- case USB_VENDOR_ID_DWAV:
1871 +- /* These are handled by usbtouchscreen. hdev->type is probably
1872 +- * HID_TYPE_USBNONE, but we say !HID_TYPE_USBMOUSE to match
1873 +- * usbtouchscreen. */
1874 +- if ((hdev->product == USB_DEVICE_ID_EGALAX_TOUCHCONTROLLER ||
1875 +- hdev->product == USB_DEVICE_ID_DWAV_TOUCHCONTROLLER) &&
1876 +- hdev->type != HID_TYPE_USBMOUSE)
1877 +- return true;
1878 +- break;
1879 + case USB_VENDOR_ID_VELLEMAN:
1880 + /* These are not HID devices. They are handled by comedi. */
1881 + if ((hdev->product >= USB_DEVICE_ID_VELLEMAN_K8055_FIRST &&
1882 +diff --git a/drivers/hid/hid-ids.h b/drivers/hid/hid-ids.h
1883 +index 114fd166..799dbec2 100644
1884 +--- a/drivers/hid/hid-ids.h
1885 ++++ b/drivers/hid/hid-ids.h
1886 +@@ -330,6 +330,11 @@
1887 + #define USB_VENDOR_ID_GENERAL_TOUCH 0x0dfc
1888 + #define USB_DEVICE_ID_GENERAL_TOUCH_WIN7_TWOFINGERS 0x0003
1889 + #define USB_DEVICE_ID_GENERAL_TOUCH_WIN8_PWT_TENFINGERS 0x0100
1890 ++#define USB_DEVICE_ID_GENERAL_TOUCH_WIN8_PIT_0101 0x0101
1891 ++#define USB_DEVICE_ID_GENERAL_TOUCH_WIN8_PIT_0102 0x0102
1892 ++#define USB_DEVICE_ID_GENERAL_TOUCH_WIN8_PIT_0106 0x0106
1893 ++#define USB_DEVICE_ID_GENERAL_TOUCH_WIN8_PIT_010A 0x010a
1894 ++#define USB_DEVICE_ID_GENERAL_TOUCH_WIN8_PIT_E100 0xe100
1895 +
1896 + #define USB_VENDOR_ID_GLAB 0x06c2
1897 + #define USB_DEVICE_ID_4_PHIDGETSERVO_30 0x0038
1898 +@@ -557,6 +562,7 @@
1899 + #define USB_DEVICE_ID_DINOVO_EDGE 0xc714
1900 + #define USB_DEVICE_ID_DINOVO_MINI 0xc71f
1901 + #define USB_DEVICE_ID_LOGITECH_MOMO_WHEEL2 0xca03
1902 ++#define USB_DEVICE_ID_LOGITECH_VIBRATION_WHEEL 0xca04
1903 +
1904 + #define USB_VENDOR_ID_LUMIO 0x202e
1905 + #define USB_DEVICE_ID_CRYSTALTOUCH 0x0006
1906 +@@ -730,6 +736,10 @@
1907 + #define USB_VENDOR_ID_SIGMATEL 0x066F
1908 + #define USB_DEVICE_ID_SIGMATEL_STMP3780 0x3780
1909 +
1910 ++#define USB_VENDOR_ID_SIS2_TOUCH 0x0457
1911 ++#define USB_DEVICE_ID_SIS9200_TOUCH 0x9200
1912 ++#define USB_DEVICE_ID_SIS817_TOUCH 0x0817
1913 ++
1914 + #define USB_VENDOR_ID_SKYCABLE 0x1223
1915 + #define USB_DEVICE_ID_SKYCABLE_WIRELESS_PRESENTER 0x3F07
1916 +
1917 +@@ -869,6 +879,9 @@
1918 + #define USB_DEVICE_ID_SUPER_DUAL_BOX_PRO 0x8802
1919 + #define USB_DEVICE_ID_SUPER_JOY_BOX_5_PRO 0x8804
1920 +
1921 ++#define USB_VENDOR_ID_WISTRON 0x0fb8
1922 ++#define USB_DEVICE_ID_WISTRON_OPTICAL_TOUCH 0x1109
1923 ++
1924 + #define USB_VENDOR_ID_X_TENSIONS 0x1ae7
1925 + #define USB_DEVICE_ID_SPEEDLINK_VAD_CEZANNE 0x9001
1926 +
1927 +diff --git a/drivers/hid/hid-lg.c b/drivers/hid/hid-lg.c
1928 +index 6f12ecd3..1bfd292c 100644
1929 +--- a/drivers/hid/hid-lg.c
1930 ++++ b/drivers/hid/hid-lg.c
1931 +@@ -45,6 +45,7 @@
1932 + /* Size of the original descriptors of the Driving Force (and Pro) wheels */
1933 + #define DF_RDESC_ORIG_SIZE 130
1934 + #define DFP_RDESC_ORIG_SIZE 97
1935 ++#define FV_RDESC_ORIG_SIZE 130
1936 + #define MOMO_RDESC_ORIG_SIZE 87
1937 +
1938 + /* Fixed report descriptors for Logitech Driving Force (and Pro)
1939 +@@ -170,6 +171,73 @@ static __u8 dfp_rdesc_fixed[] = {
1940 + 0xC0 /* End Collection */
1941 + };
1942 +
1943 ++static __u8 fv_rdesc_fixed[] = {
1944 ++0x05, 0x01, /* Usage Page (Desktop), */
1945 ++0x09, 0x04, /* Usage (Joystik), */
1946 ++0xA1, 0x01, /* Collection (Application), */
1947 ++0xA1, 0x02, /* Collection (Logical), */
1948 ++0x95, 0x01, /* Report Count (1), */
1949 ++0x75, 0x0A, /* Report Size (10), */
1950 ++0x15, 0x00, /* Logical Minimum (0), */
1951 ++0x26, 0xFF, 0x03, /* Logical Maximum (1023), */
1952 ++0x35, 0x00, /* Physical Minimum (0), */
1953 ++0x46, 0xFF, 0x03, /* Physical Maximum (1023), */
1954 ++0x09, 0x30, /* Usage (X), */
1955 ++0x81, 0x02, /* Input (Variable), */
1956 ++0x95, 0x0C, /* Report Count (12), */
1957 ++0x75, 0x01, /* Report Size (1), */
1958 ++0x25, 0x01, /* Logical Maximum (1), */
1959 ++0x45, 0x01, /* Physical Maximum (1), */
1960 ++0x05, 0x09, /* Usage Page (Button), */
1961 ++0x19, 0x01, /* Usage Minimum (01h), */
1962 ++0x29, 0x0C, /* Usage Maximum (0Ch), */
1963 ++0x81, 0x02, /* Input (Variable), */
1964 ++0x95, 0x02, /* Report Count (2), */
1965 ++0x06, 0x00, 0xFF, /* Usage Page (FF00h), */
1966 ++0x09, 0x01, /* Usage (01h), */
1967 ++0x81, 0x02, /* Input (Variable), */
1968 ++0x09, 0x02, /* Usage (02h), */
1969 ++0x26, 0xFF, 0x00, /* Logical Maximum (255), */
1970 ++0x46, 0xFF, 0x00, /* Physical Maximum (255), */
1971 ++0x95, 0x01, /* Report Count (1), */
1972 ++0x75, 0x08, /* Report Size (8), */
1973 ++0x81, 0x02, /* Input (Variable), */
1974 ++0x05, 0x01, /* Usage Page (Desktop), */
1975 ++0x25, 0x07, /* Logical Maximum (7), */
1976 ++0x46, 0x3B, 0x01, /* Physical Maximum (315), */
1977 ++0x75, 0x04, /* Report Size (4), */
1978 ++0x65, 0x14, /* Unit (Degrees), */
1979 ++0x09, 0x39, /* Usage (Hat Switch), */
1980 ++0x81, 0x42, /* Input (Variable, Null State), */
1981 ++0x75, 0x01, /* Report Size (1), */
1982 ++0x95, 0x04, /* Report Count (4), */
1983 ++0x65, 0x00, /* Unit, */
1984 ++0x06, 0x00, 0xFF, /* Usage Page (FF00h), */
1985 ++0x09, 0x01, /* Usage (01h), */
1986 ++0x25, 0x01, /* Logical Maximum (1), */
1987 ++0x45, 0x01, /* Physical Maximum (1), */
1988 ++0x81, 0x02, /* Input (Variable), */
1989 ++0x05, 0x01, /* Usage Page (Desktop), */
1990 ++0x95, 0x01, /* Report Count (1), */
1991 ++0x75, 0x08, /* Report Size (8), */
1992 ++0x26, 0xFF, 0x00, /* Logical Maximum (255), */
1993 ++0x46, 0xFF, 0x00, /* Physical Maximum (255), */
1994 ++0x09, 0x31, /* Usage (Y), */
1995 ++0x81, 0x02, /* Input (Variable), */
1996 ++0x09, 0x32, /* Usage (Z), */
1997 ++0x81, 0x02, /* Input (Variable), */
1998 ++0xC0, /* End Collection, */
1999 ++0xA1, 0x02, /* Collection (Logical), */
2000 ++0x26, 0xFF, 0x00, /* Logical Maximum (255), */
2001 ++0x46, 0xFF, 0x00, /* Physical Maximum (255), */
2002 ++0x95, 0x07, /* Report Count (7), */
2003 ++0x75, 0x08, /* Report Size (8), */
2004 ++0x09, 0x03, /* Usage (03h), */
2005 ++0x91, 0x02, /* Output (Variable), */
2006 ++0xC0, /* End Collection, */
2007 ++0xC0 /* End Collection */
2008 ++};
2009 ++
2010 + static __u8 momo_rdesc_fixed[] = {
2011 + 0x05, 0x01, /* Usage Page (Desktop), */
2012 + 0x09, 0x04, /* Usage (Joystik), */
2013 +@@ -275,6 +343,15 @@ static __u8 *lg_report_fixup(struct hid_device *hdev, __u8 *rdesc,
2014 + }
2015 + break;
2016 +
2017 ++ case USB_DEVICE_ID_LOGITECH_VIBRATION_WHEEL:
2018 ++ if (*rsize == FV_RDESC_ORIG_SIZE) {
2019 ++ hid_info(hdev,
2020 ++ "fixing up Logitech Formula Vibration report descriptor\n");
2021 ++ rdesc = fv_rdesc_fixed;
2022 ++ *rsize = sizeof(fv_rdesc_fixed);
2023 ++ }
2024 ++ break;
2025 ++
2026 + case USB_DEVICE_ID_LOGITECH_DFP_WHEEL:
2027 + if (*rsize == DFP_RDESC_ORIG_SIZE) {
2028 + hid_info(hdev,
2029 +@@ -492,6 +569,7 @@ static int lg_input_mapped(struct hid_device *hdev, struct hid_input *hi,
2030 + case USB_DEVICE_ID_LOGITECH_G27_WHEEL:
2031 + case USB_DEVICE_ID_LOGITECH_WII_WHEEL:
2032 + case USB_DEVICE_ID_LOGITECH_MOMO_WHEEL2:
2033 ++ case USB_DEVICE_ID_LOGITECH_VIBRATION_WHEEL:
2034 + field->application = HID_GD_MULTIAXIS;
2035 + break;
2036 + default:
2037 +@@ -639,6 +717,8 @@ static const struct hid_device_id lg_devices[] = {
2038 + .driver_data = LG_NOGET | LG_FF4 },
2039 + { HID_USB_DEVICE(USB_VENDOR_ID_LOGITECH, USB_DEVICE_ID_LOGITECH_MOMO_WHEEL2),
2040 + .driver_data = LG_FF4 },
2041 ++ { HID_USB_DEVICE(USB_VENDOR_ID_LOGITECH, USB_DEVICE_ID_LOGITECH_VIBRATION_WHEEL),
2042 ++ .driver_data = LG_FF2 },
2043 + { HID_USB_DEVICE(USB_VENDOR_ID_LOGITECH, USB_DEVICE_ID_LOGITECH_G25_WHEEL),
2044 + .driver_data = LG_FF4 },
2045 + { HID_USB_DEVICE(USB_VENDOR_ID_LOGITECH, USB_DEVICE_ID_LOGITECH_DFGT_WHEEL),
2046 +diff --git a/drivers/hid/hid-lg2ff.c b/drivers/hid/hid-lg2ff.c
2047 +index 1a42eaa6..0e3fb1a7 100644
2048 +--- a/drivers/hid/hid-lg2ff.c
2049 ++++ b/drivers/hid/hid-lg2ff.c
2050 +@@ -95,7 +95,7 @@ int lg2ff_init(struct hid_device *hid)
2051 +
2052 + hid_hw_request(hid, report, HID_REQ_SET_REPORT);
2053 +
2054 +- hid_info(hid, "Force feedback for Logitech RumblePad/Rumblepad 2 by Anssi Hannula <anssi.hannula@×××××.com>\n");
2055 ++ hid_info(hid, "Force feedback for Logitech variant 2 rumble devices by Anssi Hannula <anssi.hannula@×××××.com>\n");
2056 +
2057 + return 0;
2058 + }
2059 +diff --git a/drivers/hid/hid-lg4ff.c b/drivers/hid/hid-lg4ff.c
2060 +index 8782fe1a..35180536 100644
2061 +--- a/drivers/hid/hid-lg4ff.c
2062 ++++ b/drivers/hid/hid-lg4ff.c
2063 +@@ -218,12 +218,46 @@ static void hid_lg4ff_set_autocenter_default(struct input_dev *dev, u16 magnitud
2064 + struct list_head *report_list = &hid->report_enum[HID_OUTPUT_REPORT].report_list;
2065 + struct hid_report *report = list_entry(report_list->next, struct hid_report, list);
2066 + __s32 *value = report->field[0]->value;
2067 ++ __u32 expand_a, expand_b;
2068 ++
2069 ++ /* De-activate Auto-Center */
2070 ++ if (magnitude == 0) {
2071 ++ value[0] = 0xf5;
2072 ++ value[1] = 0x00;
2073 ++ value[2] = 0x00;
2074 ++ value[3] = 0x00;
2075 ++ value[4] = 0x00;
2076 ++ value[5] = 0x00;
2077 ++ value[6] = 0x00;
2078 ++
2079 ++ hid_hw_request(hid, report, HID_REQ_SET_REPORT);
2080 ++ return;
2081 ++ }
2082 ++
2083 ++ if (magnitude <= 0xaaaa) {
2084 ++ expand_a = 0x0c * magnitude;
2085 ++ expand_b = 0x80 * magnitude;
2086 ++ } else {
2087 ++ expand_a = (0x0c * 0xaaaa) + 0x06 * (magnitude - 0xaaaa);
2088 ++ expand_b = (0x80 * 0xaaaa) + 0xff * (magnitude - 0xaaaa);
2089 ++ }
2090 +
2091 + value[0] = 0xfe;
2092 + value[1] = 0x0d;
2093 +- value[2] = magnitude >> 13;
2094 +- value[3] = magnitude >> 13;
2095 +- value[4] = magnitude >> 8;
2096 ++ value[2] = expand_a / 0xaaaa;
2097 ++ value[3] = expand_a / 0xaaaa;
2098 ++ value[4] = expand_b / 0xaaaa;
2099 ++ value[5] = 0x00;
2100 ++ value[6] = 0x00;
2101 ++
2102 ++ hid_hw_request(hid, report, HID_REQ_SET_REPORT);
2103 ++
2104 ++ /* Activate Auto-Center */
2105 ++ value[0] = 0x14;
2106 ++ value[1] = 0x00;
2107 ++ value[2] = 0x00;
2108 ++ value[3] = 0x00;
2109 ++ value[4] = 0x00;
2110 + value[5] = 0x00;
2111 + value[6] = 0x00;
2112 +
2113 +@@ -540,17 +574,6 @@ int lg4ff_init(struct hid_device *hid)
2114 + if (error)
2115 + return error;
2116 +
2117 +- /* Check if autocentering is available and
2118 +- * set the centering force to zero by default */
2119 +- if (test_bit(FF_AUTOCENTER, dev->ffbit)) {
2120 +- if (rev_maj == FFEX_REV_MAJ && rev_min == FFEX_REV_MIN) /* Formula Force EX expects different autocentering command */
2121 +- dev->ff->set_autocenter = hid_lg4ff_set_autocenter_ffex;
2122 +- else
2123 +- dev->ff->set_autocenter = hid_lg4ff_set_autocenter_default;
2124 +-
2125 +- dev->ff->set_autocenter(dev, 0);
2126 +- }
2127 +-
2128 + /* Get private driver data */
2129 + drv_data = hid_get_drvdata(hid);
2130 + if (!drv_data) {
2131 +@@ -571,6 +594,17 @@ int lg4ff_init(struct hid_device *hid)
2132 + entry->max_range = lg4ff_devices[i].max_range;
2133 + entry->set_range = lg4ff_devices[i].set_range;
2134 +
2135 ++ /* Check if autocentering is available and
2136 ++ * set the centering force to zero by default */
2137 ++ if (test_bit(FF_AUTOCENTER, dev->ffbit)) {
2138 ++ if (rev_maj == FFEX_REV_MAJ && rev_min == FFEX_REV_MIN) /* Formula Force EX expects different autocentering command */
2139 ++ dev->ff->set_autocenter = hid_lg4ff_set_autocenter_ffex;
2140 ++ else
2141 ++ dev->ff->set_autocenter = hid_lg4ff_set_autocenter_default;
2142 ++
2143 ++ dev->ff->set_autocenter(dev, 0);
2144 ++ }
2145 ++
2146 + /* Create sysfs interface */
2147 + error = device_create_file(&hid->dev, &dev_attr_range);
2148 + if (error)
2149 +diff --git a/drivers/hid/hid-multitouch.c b/drivers/hid/hid-multitouch.c
2150 +index b6701cec..3d8e58ac 100644
2151 +--- a/drivers/hid/hid-multitouch.c
2152 ++++ b/drivers/hid/hid-multitouch.c
2153 +@@ -244,12 +244,12 @@ static struct mt_class mt_classes[] = {
2154 + { .name = MT_CLS_GENERALTOUCH_TWOFINGERS,
2155 + .quirks = MT_QUIRK_NOT_SEEN_MEANS_UP |
2156 + MT_QUIRK_VALID_IS_INRANGE |
2157 +- MT_QUIRK_SLOT_IS_CONTACTNUMBER,
2158 ++ MT_QUIRK_SLOT_IS_CONTACTID,
2159 + .maxcontacts = 2
2160 + },
2161 + { .name = MT_CLS_GENERALTOUCH_PWT_TENFINGERS,
2162 + .quirks = MT_QUIRK_NOT_SEEN_MEANS_UP |
2163 +- MT_QUIRK_SLOT_IS_CONTACTNUMBER
2164 ++ MT_QUIRK_SLOT_IS_CONTACTID
2165 + },
2166 +
2167 + { .name = MT_CLS_FLATFROG,
2168 +@@ -1191,6 +1191,21 @@ static const struct hid_device_id mt_devices[] = {
2169 + { .driver_data = MT_CLS_GENERALTOUCH_PWT_TENFINGERS,
2170 + MT_USB_DEVICE(USB_VENDOR_ID_GENERAL_TOUCH,
2171 + USB_DEVICE_ID_GENERAL_TOUCH_WIN8_PWT_TENFINGERS) },
2172 ++ { .driver_data = MT_CLS_GENERALTOUCH_TWOFINGERS,
2173 ++ MT_USB_DEVICE(USB_VENDOR_ID_GENERAL_TOUCH,
2174 ++ USB_DEVICE_ID_GENERAL_TOUCH_WIN8_PIT_0101) },
2175 ++ { .driver_data = MT_CLS_GENERALTOUCH_PWT_TENFINGERS,
2176 ++ MT_USB_DEVICE(USB_VENDOR_ID_GENERAL_TOUCH,
2177 ++ USB_DEVICE_ID_GENERAL_TOUCH_WIN8_PIT_0102) },
2178 ++ { .driver_data = MT_CLS_GENERALTOUCH_PWT_TENFINGERS,
2179 ++ MT_USB_DEVICE(USB_VENDOR_ID_GENERAL_TOUCH,
2180 ++ USB_DEVICE_ID_GENERAL_TOUCH_WIN8_PIT_0106) },
2181 ++ { .driver_data = MT_CLS_GENERALTOUCH_PWT_TENFINGERS,
2182 ++ MT_USB_DEVICE(USB_VENDOR_ID_GENERAL_TOUCH,
2183 ++ USB_DEVICE_ID_GENERAL_TOUCH_WIN8_PIT_010A) },
2184 ++ { .driver_data = MT_CLS_GENERALTOUCH_PWT_TENFINGERS,
2185 ++ MT_USB_DEVICE(USB_VENDOR_ID_GENERAL_TOUCH,
2186 ++ USB_DEVICE_ID_GENERAL_TOUCH_WIN8_PIT_E100) },
2187 +
2188 + /* Gametel game controller */
2189 + { .driver_data = MT_CLS_NSMU,
2190 +@@ -1302,6 +1317,14 @@ static const struct hid_device_id mt_devices[] = {
2191 + MT_USB_DEVICE(USB_VENDOR_ID_QUANTA,
2192 + USB_DEVICE_ID_QUANTA_OPTICAL_TOUCH_3008) },
2193 +
2194 ++ /* SiS panels */
2195 ++ { .driver_data = MT_CLS_DEFAULT,
2196 ++ HID_USB_DEVICE(USB_VENDOR_ID_SIS2_TOUCH,
2197 ++ USB_DEVICE_ID_SIS9200_TOUCH) },
2198 ++ { .driver_data = MT_CLS_DEFAULT,
2199 ++ HID_USB_DEVICE(USB_VENDOR_ID_SIS2_TOUCH,
2200 ++ USB_DEVICE_ID_SIS817_TOUCH) },
2201 ++
2202 + /* Stantum panels */
2203 + { .driver_data = MT_CLS_CONFIDENCE,
2204 + MT_USB_DEVICE(USB_VENDOR_ID_STANTUM,
2205 +@@ -1330,6 +1353,12 @@ static const struct hid_device_id mt_devices[] = {
2206 + { .driver_data = MT_CLS_NSMU,
2207 + MT_USB_DEVICE(USB_VENDOR_ID_UNITEC,
2208 + USB_DEVICE_ID_UNITEC_USB_TOUCH_0A19) },
2209 ++
2210 ++ /* Wistron panels */
2211 ++ { .driver_data = MT_CLS_NSMU,
2212 ++ MT_USB_DEVICE(USB_VENDOR_ID_WISTRON,
2213 ++ USB_DEVICE_ID_WISTRON_OPTICAL_TOUCH) },
2214 ++
2215 + /* XAT */
2216 + { .driver_data = MT_CLS_NSMU,
2217 + MT_USB_DEVICE(USB_VENDOR_ID_XAT,
2218 +diff --git a/drivers/hid/hid-roccat-common.c b/drivers/hid/hid-roccat-common.c
2219 +index 74f70403..e8408999 100644
2220 +--- a/drivers/hid/hid-roccat-common.c
2221 ++++ b/drivers/hid/hid-roccat-common.c
2222 +@@ -65,10 +65,11 @@ int roccat_common2_send(struct usb_device *usb_dev, uint report_id,
2223 + EXPORT_SYMBOL_GPL(roccat_common2_send);
2224 +
2225 + enum roccat_common2_control_states {
2226 +- ROCCAT_COMMON_CONTROL_STATUS_OVERLOAD = 0,
2227 ++ ROCCAT_COMMON_CONTROL_STATUS_CRITICAL = 0,
2228 + ROCCAT_COMMON_CONTROL_STATUS_OK = 1,
2229 + ROCCAT_COMMON_CONTROL_STATUS_INVALID = 2,
2230 +- ROCCAT_COMMON_CONTROL_STATUS_WAIT = 3,
2231 ++ ROCCAT_COMMON_CONTROL_STATUS_BUSY = 3,
2232 ++ ROCCAT_COMMON_CONTROL_STATUS_CRITICAL_NEW = 4,
2233 + };
2234 +
2235 + static int roccat_common2_receive_control_status(struct usb_device *usb_dev)
2236 +@@ -88,13 +89,12 @@ static int roccat_common2_receive_control_status(struct usb_device *usb_dev)
2237 + switch (control.value) {
2238 + case ROCCAT_COMMON_CONTROL_STATUS_OK:
2239 + return 0;
2240 +- case ROCCAT_COMMON_CONTROL_STATUS_WAIT:
2241 ++ case ROCCAT_COMMON_CONTROL_STATUS_BUSY:
2242 + msleep(500);
2243 + continue;
2244 + case ROCCAT_COMMON_CONTROL_STATUS_INVALID:
2245 +-
2246 +- case ROCCAT_COMMON_CONTROL_STATUS_OVERLOAD:
2247 +- /* seems to be critical - replug necessary */
2248 ++ case ROCCAT_COMMON_CONTROL_STATUS_CRITICAL:
2249 ++ case ROCCAT_COMMON_CONTROL_STATUS_CRITICAL_NEW:
2250 + return -EINVAL;
2251 + default:
2252 + dev_err(&usb_dev->dev,
2253 +diff --git a/drivers/hid/hid-roccat-kovaplus.c b/drivers/hid/hid-roccat-kovaplus.c
2254 +index b8b37789..2c571dad 100644
2255 +--- a/drivers/hid/hid-roccat-kovaplus.c
2256 ++++ b/drivers/hid/hid-roccat-kovaplus.c
2257 +@@ -577,9 +577,13 @@ static void kovaplus_keep_values_up_to_date(struct kovaplus_device *kovaplus,
2258 + break;
2259 + case KOVAPLUS_MOUSE_REPORT_BUTTON_TYPE_CPI:
2260 + kovaplus->actual_cpi = kovaplus_convert_event_cpi(button_report->data1);
2261 ++ break;
2262 + case KOVAPLUS_MOUSE_REPORT_BUTTON_TYPE_SENSITIVITY:
2263 + kovaplus->actual_x_sensitivity = button_report->data1;
2264 + kovaplus->actual_y_sensitivity = button_report->data2;
2265 ++ break;
2266 ++ default:
2267 ++ break;
2268 + }
2269 + }
2270 +
2271 +diff --git a/drivers/hid/hid-sensor-hub.c b/drivers/hid/hid-sensor-hub.c
2272 +index aa34755c..b189feb6 100644
2273 +--- a/drivers/hid/hid-sensor-hub.c
2274 ++++ b/drivers/hid/hid-sensor-hub.c
2275 +@@ -327,7 +327,8 @@ int sensor_hub_input_get_attribute_info(struct hid_sensor_hub_device *hsdev,
2276 + field->logical == attr_usage_id) {
2277 + sensor_hub_fill_attr_info(info, i, report->id,
2278 + field->unit, field->unit_exponent,
2279 +- field->report_size);
2280 ++ field->report_size *
2281 ++ field->report_count);
2282 + ret = 0;
2283 + } else {
2284 + for (j = 0; j < field->maxusage; ++j) {
2285 +@@ -339,7 +340,8 @@ int sensor_hub_input_get_attribute_info(struct hid_sensor_hub_device *hsdev,
2286 + i, report->id,
2287 + field->unit,
2288 + field->unit_exponent,
2289 +- field->report_size);
2290 ++ field->report_size *
2291 ++ field->report_count);
2292 + ret = 0;
2293 + break;
2294 + }
2295 +@@ -426,9 +428,10 @@ static int sensor_hub_raw_event(struct hid_device *hdev,
2296 + hid_dbg(hdev, "%d collection_index:%x hid:%x sz:%x\n",
2297 + i, report->field[i]->usage->collection_index,
2298 + report->field[i]->usage->hid,
2299 +- report->field[i]->report_size/8);
2300 +-
2301 +- sz = report->field[i]->report_size/8;
2302 ++ (report->field[i]->report_size *
2303 ++ report->field[i]->report_count)/8);
2304 ++ sz = (report->field[i]->report_size *
2305 ++ report->field[i]->report_count)/8;
2306 + if (pdata->pending.status && pdata->pending.attr_usage_id ==
2307 + report->field[i]->usage->hid) {
2308 + hid_dbg(hdev, "data was pending ...\n");
2309 +diff --git a/drivers/hid/uhid.c b/drivers/hid/uhid.c
2310 +index 145a4cb5..0bb3bb88 100644
2311 +--- a/drivers/hid/uhid.c
2312 ++++ b/drivers/hid/uhid.c
2313 +@@ -312,7 +312,7 @@ static int uhid_event_from_user(const char __user *buffer, size_t len,
2314 + */
2315 + struct uhid_create_req_compat *compat;
2316 +
2317 +- compat = kmalloc(sizeof(*compat), GFP_KERNEL);
2318 ++ compat = kzalloc(sizeof(*compat), GFP_KERNEL);
2319 + if (!compat)
2320 + return -ENOMEM;
2321 +
2322 +diff --git a/drivers/hid/usbhid/hid-quirks.c b/drivers/hid/usbhid/hid-quirks.c
2323 +index 07345521..ae5c6347 100644
2324 +--- a/drivers/hid/usbhid/hid-quirks.c
2325 ++++ b/drivers/hid/usbhid/hid-quirks.c
2326 +@@ -84,6 +84,8 @@ static const struct hid_blacklist {
2327 + { USB_VENDOR_ID_REALTEK, USB_DEVICE_ID_REALTEK_READER, HID_QUIRK_NO_INIT_REPORTS },
2328 + { USB_VENDOR_ID_SENNHEISER, USB_DEVICE_ID_SENNHEISER_BTD500USB, HID_QUIRK_NOGET },
2329 + { USB_VENDOR_ID_SIGMATEL, USB_DEVICE_ID_SIGMATEL_STMP3780, HID_QUIRK_NOGET },
2330 ++ { USB_VENDOR_ID_SIS2_TOUCH, USB_DEVICE_ID_SIS9200_TOUCH, HID_QUIRK_NOGET },
2331 ++ { USB_VENDOR_ID_SIS2_TOUCH, USB_DEVICE_ID_SIS817_TOUCH, HID_QUIRK_NOGET },
2332 + { USB_VENDOR_ID_SUN, USB_DEVICE_ID_RARITAN_KVM_DONGLE, HID_QUIRK_NOGET },
2333 + { USB_VENDOR_ID_SYMBOL, USB_DEVICE_ID_SYMBOL_SCANNER_1, HID_QUIRK_NOGET },
2334 + { USB_VENDOR_ID_SYMBOL, USB_DEVICE_ID_SYMBOL_SCANNER_2, HID_QUIRK_NOGET },
2335 +diff --git a/drivers/i2c/muxes/i2c-mux-gpio.c b/drivers/i2c/muxes/i2c-mux-gpio.c
2336 +index 5a0ce008..bb4f69f7 100644
2337 +--- a/drivers/i2c/muxes/i2c-mux-gpio.c
2338 ++++ b/drivers/i2c/muxes/i2c-mux-gpio.c
2339 +@@ -31,15 +31,15 @@ static void i2c_mux_gpio_set(const struct gpiomux *mux, unsigned val)
2340 + int i;
2341 +
2342 + for (i = 0; i < mux->data.n_gpios; i++)
2343 +- gpio_set_value(mux->gpio_base + mux->data.gpios[i],
2344 +- val & (1 << i));
2345 ++ gpio_set_value_cansleep(mux->gpio_base + mux->data.gpios[i],
2346 ++ val & (1 << i));
2347 + }
2348 +
2349 + static int i2c_mux_gpio_select(struct i2c_adapter *adap, void *data, u32 chan)
2350 + {
2351 + struct gpiomux *mux = data;
2352 +
2353 +- i2c_mux_gpio_set(mux, mux->data.values[chan]);
2354 ++ i2c_mux_gpio_set(mux, chan);
2355 +
2356 + return 0;
2357 + }
2358 +@@ -223,7 +223,7 @@ static int i2c_mux_gpio_probe(struct platform_device *pdev)
2359 + unsigned int class = mux->data.classes ? mux->data.classes[i] : 0;
2360 +
2361 + mux->adap[i] = i2c_add_mux_adapter(parent, &pdev->dev, mux, nr,
2362 +- i, class,
2363 ++ mux->data.values[i], class,
2364 + i2c_mux_gpio_select, deselect);
2365 + if (!mux->adap[i]) {
2366 + ret = -ENODEV;
2367 +diff --git a/drivers/iio/accel/kxsd9.c b/drivers/iio/accel/kxsd9.c
2368 +index 7229645b..7c9a1d97 100644
2369 +--- a/drivers/iio/accel/kxsd9.c
2370 ++++ b/drivers/iio/accel/kxsd9.c
2371 +@@ -112,9 +112,10 @@ static int kxsd9_read(struct iio_dev *indio_dev, u8 address)
2372 + mutex_lock(&st->buf_lock);
2373 + st->tx[0] = KXSD9_READ(address);
2374 + ret = spi_sync_transfer(st->us, xfers, ARRAY_SIZE(xfers));
2375 +- if (ret)
2376 +- return ret;
2377 +- return (((u16)(st->rx[0])) << 8) | (st->rx[1] & 0xF0);
2378 ++ if (!ret)
2379 ++ ret = (((u16)(st->rx[0])) << 8) | (st->rx[1] & 0xF0);
2380 ++ mutex_unlock(&st->buf_lock);
2381 ++ return ret;
2382 + }
2383 +
2384 + static IIO_CONST_ATTR(accel_scale_available,
2385 +diff --git a/drivers/infiniband/hw/ipath/ipath_user_sdma.c b/drivers/infiniband/hw/ipath/ipath_user_sdma.c
2386 +index f5cb13b2..cc04b7ba 100644
2387 +--- a/drivers/infiniband/hw/ipath/ipath_user_sdma.c
2388 ++++ b/drivers/infiniband/hw/ipath/ipath_user_sdma.c
2389 +@@ -280,9 +280,7 @@ static int ipath_user_sdma_pin_pages(const struct ipath_devdata *dd,
2390 + int j;
2391 + int ret;
2392 +
2393 +- ret = get_user_pages(current, current->mm, addr,
2394 +- npages, 0, 1, pages, NULL);
2395 +-
2396 ++ ret = get_user_pages_fast(addr, npages, 0, pages);
2397 + if (ret != npages) {
2398 + int i;
2399 +
2400 +@@ -811,10 +809,7 @@ int ipath_user_sdma_writev(struct ipath_devdata *dd,
2401 + while (dim) {
2402 + const int mxp = 8;
2403 +
2404 +- down_write(&current->mm->mmap_sem);
2405 + ret = ipath_user_sdma_queue_pkts(dd, pq, &list, iov, dim, mxp);
2406 +- up_write(&current->mm->mmap_sem);
2407 +-
2408 + if (ret <= 0)
2409 + goto done_unlock;
2410 + else {
2411 +diff --git a/drivers/infiniband/hw/qib/qib_iba7322.c b/drivers/infiniband/hw/qib/qib_iba7322.c
2412 +index 3f6b21e9..bd8cb0f8 100644
2413 +--- a/drivers/infiniband/hw/qib/qib_iba7322.c
2414 ++++ b/drivers/infiniband/hw/qib/qib_iba7322.c
2415 +@@ -5853,21 +5853,20 @@ static int setup_txselect(const char *str, struct kernel_param *kp)
2416 + {
2417 + struct qib_devdata *dd;
2418 + unsigned long val;
2419 +- int ret;
2420 +-
2421 ++ char *n;
2422 + if (strlen(str) >= MAX_ATTEN_LEN) {
2423 + pr_info("txselect_values string too long\n");
2424 + return -ENOSPC;
2425 + }
2426 +- ret = kstrtoul(str, 0, &val);
2427 +- if (ret || val >= (TXDDS_TABLE_SZ + TXDDS_EXTRA_SZ +
2428 ++ val = simple_strtoul(str, &n, 0);
2429 ++ if (n == str || val >= (TXDDS_TABLE_SZ + TXDDS_EXTRA_SZ +
2430 + TXDDS_MFG_SZ)) {
2431 + pr_info("txselect_values must start with a number < %d\n",
2432 + TXDDS_TABLE_SZ + TXDDS_EXTRA_SZ + TXDDS_MFG_SZ);
2433 +- return ret ? ret : -EINVAL;
2434 ++ return -EINVAL;
2435 + }
2436 +-
2437 + strcpy(txselect_list, str);
2438 ++
2439 + list_for_each_entry(dd, &qib_dev_list, list)
2440 + if (dd->deviceid == PCI_DEVICE_ID_QLOGIC_IB_7322)
2441 + set_no_qsfp_atten(dd, 1);
2442 +diff --git a/drivers/infiniband/ulp/srp/ib_srp.c b/drivers/infiniband/ulp/srp/ib_srp.c
2443 +index 7ccf3284..793ac5dc 100644
2444 +--- a/drivers/infiniband/ulp/srp/ib_srp.c
2445 ++++ b/drivers/infiniband/ulp/srp/ib_srp.c
2446 +@@ -1300,14 +1300,13 @@ static void srp_handle_recv(struct srp_target_port *target, struct ib_wc *wc)
2447 + PFX "Recv failed with error code %d\n", res);
2448 + }
2449 +
2450 +-static void srp_handle_qp_err(enum ib_wc_status wc_status,
2451 +- enum ib_wc_opcode wc_opcode,
2452 ++static void srp_handle_qp_err(enum ib_wc_status wc_status, bool send_err,
2453 + struct srp_target_port *target)
2454 + {
2455 + if (target->connected && !target->qp_in_error) {
2456 + shost_printk(KERN_ERR, target->scsi_host,
2457 + PFX "failed %s status %d\n",
2458 +- wc_opcode & IB_WC_RECV ? "receive" : "send",
2459 ++ send_err ? "send" : "receive",
2460 + wc_status);
2461 + }
2462 + target->qp_in_error = true;
2463 +@@ -1323,7 +1322,7 @@ static void srp_recv_completion(struct ib_cq *cq, void *target_ptr)
2464 + if (likely(wc.status == IB_WC_SUCCESS)) {
2465 + srp_handle_recv(target, &wc);
2466 + } else {
2467 +- srp_handle_qp_err(wc.status, wc.opcode, target);
2468 ++ srp_handle_qp_err(wc.status, false, target);
2469 + }
2470 + }
2471 + }
2472 +@@ -1339,7 +1338,7 @@ static void srp_send_completion(struct ib_cq *cq, void *target_ptr)
2473 + iu = (struct srp_iu *) (uintptr_t) wc.wr_id;
2474 + list_add(&iu->list, &target->free_tx);
2475 + } else {
2476 +- srp_handle_qp_err(wc.status, wc.opcode, target);
2477 ++ srp_handle_qp_err(wc.status, true, target);
2478 + }
2479 + }
2480 + }
2481 +diff --git a/drivers/input/evdev.c b/drivers/input/evdev.c
2482 +index f0f8928b..c122dd2a 100644
2483 +--- a/drivers/input/evdev.c
2484 ++++ b/drivers/input/evdev.c
2485 +@@ -18,6 +18,8 @@
2486 + #include <linux/poll.h>
2487 + #include <linux/sched.h>
2488 + #include <linux/slab.h>
2489 ++#include <linux/vmalloc.h>
2490 ++#include <linux/mm.h>
2491 + #include <linux/module.h>
2492 + #include <linux/init.h>
2493 + #include <linux/input/mt.h>
2494 +@@ -289,7 +291,11 @@ static int evdev_release(struct inode *inode, struct file *file)
2495 + mutex_unlock(&evdev->mutex);
2496 +
2497 + evdev_detach_client(evdev, client);
2498 +- kfree(client);
2499 ++
2500 ++ if (is_vmalloc_addr(client))
2501 ++ vfree(client);
2502 ++ else
2503 ++ kfree(client);
2504 +
2505 + evdev_close_device(evdev);
2506 +
2507 +@@ -309,12 +315,14 @@ static int evdev_open(struct inode *inode, struct file *file)
2508 + {
2509 + struct evdev *evdev = container_of(inode->i_cdev, struct evdev, cdev);
2510 + unsigned int bufsize = evdev_compute_buffer_size(evdev->handle.dev);
2511 ++ unsigned int size = sizeof(struct evdev_client) +
2512 ++ bufsize * sizeof(struct input_event);
2513 + struct evdev_client *client;
2514 + int error;
2515 +
2516 +- client = kzalloc(sizeof(struct evdev_client) +
2517 +- bufsize * sizeof(struct input_event),
2518 +- GFP_KERNEL);
2519 ++ client = kzalloc(size, GFP_KERNEL | __GFP_NOWARN);
2520 ++ if (!client)
2521 ++ client = vzalloc(size);
2522 + if (!client)
2523 + return -ENOMEM;
2524 +
2525 +diff --git a/drivers/input/mouse/cypress_ps2.c b/drivers/input/mouse/cypress_ps2.c
2526 +index f51765ff..888a81a7 100644
2527 +--- a/drivers/input/mouse/cypress_ps2.c
2528 ++++ b/drivers/input/mouse/cypress_ps2.c
2529 +@@ -439,7 +439,7 @@ static int cypress_get_finger_count(unsigned char header_byte)
2530 + case 2: return 5;
2531 + default:
2532 + /* Invalid contact (e.g. palm). Ignore it. */
2533 +- return -1;
2534 ++ return 0;
2535 + }
2536 + }
2537 +
2538 +@@ -452,17 +452,10 @@ static int cypress_parse_packet(struct psmouse *psmouse,
2539 + {
2540 + unsigned char *packet = psmouse->packet;
2541 + unsigned char header_byte = packet[0];
2542 +- int contact_cnt;
2543 +
2544 + memset(report_data, 0, sizeof(struct cytp_report_data));
2545 +
2546 +- contact_cnt = cypress_get_finger_count(header_byte);
2547 +-
2548 +- if (contact_cnt < 0) /* e.g. palm detect */
2549 +- return -EINVAL;
2550 +-
2551 +- report_data->contact_cnt = contact_cnt;
2552 +-
2553 ++ report_data->contact_cnt = cypress_get_finger_count(header_byte);
2554 + report_data->tap = (header_byte & ABS_MULTIFINGER_TAP) ? 1 : 0;
2555 +
2556 + if (report_data->contact_cnt == 1) {
2557 +@@ -535,11 +528,9 @@ static void cypress_process_packet(struct psmouse *psmouse, bool zero_pkt)
2558 + int slots[CYTP_MAX_MT_SLOTS];
2559 + int n;
2560 +
2561 +- if (cypress_parse_packet(psmouse, cytp, &report_data))
2562 +- return;
2563 ++ cypress_parse_packet(psmouse, cytp, &report_data);
2564 +
2565 + n = report_data.contact_cnt;
2566 +-
2567 + if (n > CYTP_MAX_MT_SLOTS)
2568 + n = CYTP_MAX_MT_SLOTS;
2569 +
2570 +@@ -605,10 +596,6 @@ static psmouse_ret_t cypress_validate_byte(struct psmouse *psmouse)
2571 + return PSMOUSE_BAD_DATA;
2572 +
2573 + contact_cnt = cypress_get_finger_count(packet[0]);
2574 +-
2575 +- if (contact_cnt < 0)
2576 +- return PSMOUSE_BAD_DATA;
2577 +-
2578 + if (cytp->mode & CYTP_BIT_ABS_NO_PRESSURE)
2579 + cypress_set_packet_size(psmouse, contact_cnt == 2 ? 7 : 4);
2580 + else
2581 +diff --git a/drivers/input/serio/i8042-x86ia64io.h b/drivers/input/serio/i8042-x86ia64io.h
2582 +index 5f306f79..0ec9abbe 100644
2583 +--- a/drivers/input/serio/i8042-x86ia64io.h
2584 ++++ b/drivers/input/serio/i8042-x86ia64io.h
2585 +@@ -765,6 +765,7 @@ static struct pnp_device_id pnp_kbd_devids[] = {
2586 + { .id = "CPQA0D7", .driver_data = 0 },
2587 + { .id = "", },
2588 + };
2589 ++MODULE_DEVICE_TABLE(pnp, pnp_kbd_devids);
2590 +
2591 + static struct pnp_driver i8042_pnp_kbd_driver = {
2592 + .name = "i8042 kbd",
2593 +@@ -786,6 +787,7 @@ static struct pnp_device_id pnp_aux_devids[] = {
2594 + { .id = "SYN0801", .driver_data = 0 },
2595 + { .id = "", },
2596 + };
2597 ++MODULE_DEVICE_TABLE(pnp, pnp_aux_devids);
2598 +
2599 + static struct pnp_driver i8042_pnp_aux_driver = {
2600 + .name = "i8042 aux",
2601 +diff --git a/drivers/input/touchscreen/usbtouchscreen.c b/drivers/input/touchscreen/usbtouchscreen.c
2602 +index 721fdb35..ae4b6b90 100644
2603 +--- a/drivers/input/touchscreen/usbtouchscreen.c
2604 ++++ b/drivers/input/touchscreen/usbtouchscreen.c
2605 +@@ -146,12 +146,10 @@ enum {
2606 +
2607 + #define USB_DEVICE_HID_CLASS(vend, prod) \
2608 + .match_flags = USB_DEVICE_ID_MATCH_INT_CLASS \
2609 +- | USB_DEVICE_ID_MATCH_INT_PROTOCOL \
2610 + | USB_DEVICE_ID_MATCH_DEVICE, \
2611 + .idVendor = (vend), \
2612 + .idProduct = (prod), \
2613 +- .bInterfaceClass = USB_INTERFACE_CLASS_HID, \
2614 +- .bInterfaceProtocol = USB_INTERFACE_PROTOCOL_MOUSE
2615 ++ .bInterfaceClass = USB_INTERFACE_CLASS_HID
2616 +
2617 + static const struct usb_device_id usbtouch_devices[] = {
2618 + #ifdef CONFIG_TOUCHSCREEN_USB_EGALAX
2619 +diff --git a/drivers/md/dm-cache-target.c b/drivers/md/dm-cache-target.c
2620 +index df44b60e..516f9c92 100644
2621 +--- a/drivers/md/dm-cache-target.c
2622 ++++ b/drivers/md/dm-cache-target.c
2623 +@@ -151,6 +151,9 @@ struct cache {
2624 + atomic_t nr_migrations;
2625 + wait_queue_head_t migration_wait;
2626 +
2627 ++ wait_queue_head_t quiescing_wait;
2628 ++ atomic_t quiescing_ack;
2629 ++
2630 + /*
2631 + * cache_size entries, dirty if set
2632 + */
2633 +@@ -742,8 +745,9 @@ static void cell_defer(struct cache *cache, struct dm_bio_prison_cell *cell,
2634 +
2635 + static void cleanup_migration(struct dm_cache_migration *mg)
2636 + {
2637 +- dec_nr_migrations(mg->cache);
2638 ++ struct cache *cache = mg->cache;
2639 + free_migration(mg);
2640 ++ dec_nr_migrations(cache);
2641 + }
2642 +
2643 + static void migration_failure(struct dm_cache_migration *mg)
2644 +@@ -1340,34 +1344,51 @@ static void writeback_some_dirty_blocks(struct cache *cache)
2645 + /*----------------------------------------------------------------
2646 + * Main worker loop
2647 + *--------------------------------------------------------------*/
2648 +-static void start_quiescing(struct cache *cache)
2649 ++static bool is_quiescing(struct cache *cache)
2650 + {
2651 ++ int r;
2652 + unsigned long flags;
2653 +
2654 + spin_lock_irqsave(&cache->lock, flags);
2655 +- cache->quiescing = 1;
2656 ++ r = cache->quiescing;
2657 + spin_unlock_irqrestore(&cache->lock, flags);
2658 ++
2659 ++ return r;
2660 + }
2661 +
2662 +-static void stop_quiescing(struct cache *cache)
2663 ++static void ack_quiescing(struct cache *cache)
2664 ++{
2665 ++ if (is_quiescing(cache)) {
2666 ++ atomic_inc(&cache->quiescing_ack);
2667 ++ wake_up(&cache->quiescing_wait);
2668 ++ }
2669 ++}
2670 ++
2671 ++static void wait_for_quiescing_ack(struct cache *cache)
2672 ++{
2673 ++ wait_event(cache->quiescing_wait, atomic_read(&cache->quiescing_ack));
2674 ++}
2675 ++
2676 ++static void start_quiescing(struct cache *cache)
2677 + {
2678 + unsigned long flags;
2679 +
2680 + spin_lock_irqsave(&cache->lock, flags);
2681 +- cache->quiescing = 0;
2682 ++ cache->quiescing = true;
2683 + spin_unlock_irqrestore(&cache->lock, flags);
2684 ++
2685 ++ wait_for_quiescing_ack(cache);
2686 + }
2687 +
2688 +-static bool is_quiescing(struct cache *cache)
2689 ++static void stop_quiescing(struct cache *cache)
2690 + {
2691 +- int r;
2692 + unsigned long flags;
2693 +
2694 + spin_lock_irqsave(&cache->lock, flags);
2695 +- r = cache->quiescing;
2696 ++ cache->quiescing = false;
2697 + spin_unlock_irqrestore(&cache->lock, flags);
2698 +
2699 +- return r;
2700 ++ atomic_set(&cache->quiescing_ack, 0);
2701 + }
2702 +
2703 + static void wait_for_migrations(struct cache *cache)
2704 +@@ -1414,16 +1435,15 @@ static void do_worker(struct work_struct *ws)
2705 + struct cache *cache = container_of(ws, struct cache, worker);
2706 +
2707 + do {
2708 +- if (!is_quiescing(cache))
2709 ++ if (!is_quiescing(cache)) {
2710 ++ writeback_some_dirty_blocks(cache);
2711 ++ process_deferred_writethrough_bios(cache);
2712 + process_deferred_bios(cache);
2713 ++ }
2714 +
2715 + process_migrations(cache, &cache->quiesced_migrations, issue_copy);
2716 + process_migrations(cache, &cache->completed_migrations, complete_migration);
2717 +
2718 +- writeback_some_dirty_blocks(cache);
2719 +-
2720 +- process_deferred_writethrough_bios(cache);
2721 +-
2722 + if (commit_if_needed(cache)) {
2723 + process_deferred_flush_bios(cache, false);
2724 +
2725 +@@ -1436,6 +1456,9 @@ static void do_worker(struct work_struct *ws)
2726 + process_migrations(cache, &cache->need_commit_migrations,
2727 + migration_success_post_commit);
2728 + }
2729 ++
2730 ++ ack_quiescing(cache);
2731 ++
2732 + } while (more_work(cache));
2733 + }
2734 +
2735 +@@ -1998,6 +2021,9 @@ static int cache_create(struct cache_args *ca, struct cache **result)
2736 + atomic_set(&cache->nr_migrations, 0);
2737 + init_waitqueue_head(&cache->migration_wait);
2738 +
2739 ++ init_waitqueue_head(&cache->quiescing_wait);
2740 ++ atomic_set(&cache->quiescing_ack, 0);
2741 ++
2742 + r = -ENOMEM;
2743 + cache->nr_dirty = 0;
2744 + cache->dirty_bitset = alloc_bitset(from_cblock(cache->cache_size));
2745 +diff --git a/drivers/md/dm-mpath.c b/drivers/md/dm-mpath.c
2746 +index c5b7b3dd..eb7ddb20 100644
2747 +--- a/drivers/md/dm-mpath.c
2748 ++++ b/drivers/md/dm-mpath.c
2749 +@@ -86,6 +86,7 @@ struct multipath {
2750 + unsigned queue_if_no_path:1; /* Queue I/O if last path fails? */
2751 + unsigned saved_queue_if_no_path:1; /* Saved state during suspension */
2752 + unsigned retain_attached_hw_handler:1; /* If there's already a hw_handler present, don't change it. */
2753 ++ unsigned pg_init_disabled:1; /* pg_init is not currently allowed */
2754 +
2755 + unsigned pg_init_retries; /* Number of times to retry pg_init */
2756 + unsigned pg_init_count; /* Number of times pg_init called */
2757 +@@ -497,7 +498,8 @@ static void process_queued_ios(struct work_struct *work)
2758 + (!pgpath && !m->queue_if_no_path))
2759 + must_queue = 0;
2760 +
2761 +- if (m->pg_init_required && !m->pg_init_in_progress && pgpath)
2762 ++ if (m->pg_init_required && !m->pg_init_in_progress && pgpath &&
2763 ++ !m->pg_init_disabled)
2764 + __pg_init_all_paths(m);
2765 +
2766 + spin_unlock_irqrestore(&m->lock, flags);
2767 +@@ -942,10 +944,20 @@ static void multipath_wait_for_pg_init_completion(struct multipath *m)
2768 +
2769 + static void flush_multipath_work(struct multipath *m)
2770 + {
2771 ++ unsigned long flags;
2772 ++
2773 ++ spin_lock_irqsave(&m->lock, flags);
2774 ++ m->pg_init_disabled = 1;
2775 ++ spin_unlock_irqrestore(&m->lock, flags);
2776 ++
2777 + flush_workqueue(kmpath_handlerd);
2778 + multipath_wait_for_pg_init_completion(m);
2779 + flush_workqueue(kmultipathd);
2780 + flush_work(&m->trigger_event);
2781 ++
2782 ++ spin_lock_irqsave(&m->lock, flags);
2783 ++ m->pg_init_disabled = 0;
2784 ++ spin_unlock_irqrestore(&m->lock, flags);
2785 + }
2786 +
2787 + static void multipath_dtr(struct dm_target *ti)
2788 +@@ -1164,7 +1176,7 @@ static int pg_init_limit_reached(struct multipath *m, struct pgpath *pgpath)
2789 +
2790 + spin_lock_irqsave(&m->lock, flags);
2791 +
2792 +- if (m->pg_init_count <= m->pg_init_retries)
2793 ++ if (m->pg_init_count <= m->pg_init_retries && !m->pg_init_disabled)
2794 + m->pg_init_required = 1;
2795 + else
2796 + limit_reached = 1;
2797 +@@ -1699,7 +1711,7 @@ out:
2798 + *---------------------------------------------------------------*/
2799 + static struct target_type multipath_target = {
2800 + .name = "multipath",
2801 +- .version = {1, 5, 1},
2802 ++ .version = {1, 6, 0},
2803 + .module = THIS_MODULE,
2804 + .ctr = multipath_ctr,
2805 + .dtr = multipath_dtr,
2806 +diff --git a/drivers/md/dm-table.c b/drivers/md/dm-table.c
2807 +index 1ff252ab..9e3a045e 100644
2808 +--- a/drivers/md/dm-table.c
2809 ++++ b/drivers/md/dm-table.c
2810 +@@ -580,14 +580,28 @@ static int adjoin(struct dm_table *table, struct dm_target *ti)
2811 +
2812 + /*
2813 + * Used to dynamically allocate the arg array.
2814 ++ *
2815 ++ * We do first allocation with GFP_NOIO because dm-mpath and dm-thin must
2816 ++ * process messages even if some device is suspended. These messages have a
2817 ++ * small fixed number of arguments.
2818 ++ *
2819 ++ * On the other hand, dm-switch needs to process bulk data using messages and
2820 ++ * excessive use of GFP_NOIO could cause trouble.
2821 + */
2822 + static char **realloc_argv(unsigned *array_size, char **old_argv)
2823 + {
2824 + char **argv;
2825 + unsigned new_size;
2826 ++ gfp_t gfp;
2827 +
2828 +- new_size = *array_size ? *array_size * 2 : 64;
2829 +- argv = kmalloc(new_size * sizeof(*argv), GFP_KERNEL);
2830 ++ if (*array_size) {
2831 ++ new_size = *array_size * 2;
2832 ++ gfp = GFP_KERNEL;
2833 ++ } else {
2834 ++ new_size = 8;
2835 ++ gfp = GFP_NOIO;
2836 ++ }
2837 ++ argv = kmalloc(new_size * sizeof(*argv), gfp);
2838 + if (argv) {
2839 + memcpy(argv, old_argv, *array_size * sizeof(*argv));
2840 + *array_size = new_size;
2841 +diff --git a/drivers/md/md.c b/drivers/md/md.c
2842 +index d78f1fff..2290b950 100644
2843 +--- a/drivers/md/md.c
2844 ++++ b/drivers/md/md.c
2845 +@@ -3619,6 +3619,7 @@ level_store(struct mddev *mddev, const char *buf, size_t len)
2846 + mddev->in_sync = 1;
2847 + del_timer_sync(&mddev->safemode_timer);
2848 + }
2849 ++ blk_set_stacking_limits(&mddev->queue->limits);
2850 + pers->run(mddev);
2851 + set_bit(MD_CHANGE_DEVS, &mddev->flags);
2852 + mddev_resume(mddev);
2853 +diff --git a/drivers/md/persistent-data/dm-array.c b/drivers/md/persistent-data/dm-array.c
2854 +index 172147eb..af96e24e 100644
2855 +--- a/drivers/md/persistent-data/dm-array.c
2856 ++++ b/drivers/md/persistent-data/dm-array.c
2857 +@@ -509,15 +509,18 @@ static int grow_add_tail_block(struct resize *resize)
2858 + static int grow_needs_more_blocks(struct resize *resize)
2859 + {
2860 + int r;
2861 ++ unsigned old_nr_blocks = resize->old_nr_full_blocks;
2862 +
2863 + if (resize->old_nr_entries_in_last_block > 0) {
2864 ++ old_nr_blocks++;
2865 ++
2866 + r = grow_extend_tail_block(resize, resize->max_entries);
2867 + if (r)
2868 + return r;
2869 + }
2870 +
2871 + r = insert_full_ablocks(resize->info, resize->size_of_block,
2872 +- resize->old_nr_full_blocks,
2873 ++ old_nr_blocks,
2874 + resize->new_nr_full_blocks,
2875 + resize->max_entries, resize->value,
2876 + &resize->root);
2877 +diff --git a/drivers/media/dvb-frontends/af9013.c b/drivers/media/dvb-frontends/af9013.c
2878 +index a204f282..fb504f1e 100644
2879 +--- a/drivers/media/dvb-frontends/af9013.c
2880 ++++ b/drivers/media/dvb-frontends/af9013.c
2881 +@@ -24,6 +24,9 @@
2882 +
2883 + #include "af9013_priv.h"
2884 +
2885 ++/* Max transfer size done by I2C transfer functions */
2886 ++#define MAX_XFER_SIZE 64
2887 ++
2888 + struct af9013_state {
2889 + struct i2c_adapter *i2c;
2890 + struct dvb_frontend fe;
2891 +@@ -50,16 +53,23 @@ static int af9013_wr_regs_i2c(struct af9013_state *priv, u8 mbox, u16 reg,
2892 + const u8 *val, int len)
2893 + {
2894 + int ret;
2895 +- u8 buf[3+len];
2896 ++ u8 buf[MAX_XFER_SIZE];
2897 + struct i2c_msg msg[1] = {
2898 + {
2899 + .addr = priv->config.i2c_addr,
2900 + .flags = 0,
2901 +- .len = sizeof(buf),
2902 ++ .len = 3 + len,
2903 + .buf = buf,
2904 + }
2905 + };
2906 +
2907 ++ if (3 + len > sizeof(buf)) {
2908 ++ dev_warn(&priv->i2c->dev,
2909 ++ "%s: i2c wr reg=%04x: len=%d is too big!\n",
2910 ++ KBUILD_MODNAME, reg, len);
2911 ++ return -EINVAL;
2912 ++ }
2913 ++
2914 + buf[0] = (reg >> 8) & 0xff;
2915 + buf[1] = (reg >> 0) & 0xff;
2916 + buf[2] = mbox;
2917 +diff --git a/drivers/media/dvb-frontends/af9033.c b/drivers/media/dvb-frontends/af9033.c
2918 +index a777b4b9..30ee5905 100644
2919 +--- a/drivers/media/dvb-frontends/af9033.c
2920 ++++ b/drivers/media/dvb-frontends/af9033.c
2921 +@@ -21,6 +21,9 @@
2922 +
2923 + #include "af9033_priv.h"
2924 +
2925 ++/* Max transfer size done by I2C transfer functions */
2926 ++#define MAX_XFER_SIZE 64
2927 ++
2928 + struct af9033_state {
2929 + struct i2c_adapter *i2c;
2930 + struct dvb_frontend fe;
2931 +@@ -40,16 +43,23 @@ static int af9033_wr_regs(struct af9033_state *state, u32 reg, const u8 *val,
2932 + int len)
2933 + {
2934 + int ret;
2935 +- u8 buf[3 + len];
2936 ++ u8 buf[MAX_XFER_SIZE];
2937 + struct i2c_msg msg[1] = {
2938 + {
2939 + .addr = state->cfg.i2c_addr,
2940 + .flags = 0,
2941 +- .len = sizeof(buf),
2942 ++ .len = 3 + len,
2943 + .buf = buf,
2944 + }
2945 + };
2946 +
2947 ++ if (3 + len > sizeof(buf)) {
2948 ++ dev_warn(&state->i2c->dev,
2949 ++ "%s: i2c wr reg=%04x: len=%d is too big!\n",
2950 ++ KBUILD_MODNAME, reg, len);
2951 ++ return -EINVAL;
2952 ++ }
2953 ++
2954 + buf[0] = (reg >> 16) & 0xff;
2955 + buf[1] = (reg >> 8) & 0xff;
2956 + buf[2] = (reg >> 0) & 0xff;
2957 +@@ -161,7 +171,14 @@ static int af9033_wr_reg_val_tab(struct af9033_state *state,
2958 + const struct reg_val *tab, int tab_len)
2959 + {
2960 + int ret, i, j;
2961 +- u8 buf[tab_len];
2962 ++ u8 buf[MAX_XFER_SIZE];
2963 ++
2964 ++ if (tab_len > sizeof(buf)) {
2965 ++ dev_warn(&state->i2c->dev,
2966 ++ "%s: i2c wr len=%d is too big!\n",
2967 ++ KBUILD_MODNAME, tab_len);
2968 ++ return -EINVAL;
2969 ++ }
2970 +
2971 + dev_dbg(&state->i2c->dev, "%s: tab_len=%d\n", __func__, tab_len);
2972 +
2973 +diff --git a/drivers/media/dvb-frontends/bcm3510.c b/drivers/media/dvb-frontends/bcm3510.c
2974 +index 1b77909c..39a29dd2 100644
2975 +--- a/drivers/media/dvb-frontends/bcm3510.c
2976 ++++ b/drivers/media/dvb-frontends/bcm3510.c
2977 +@@ -44,6 +44,9 @@
2978 + #include "bcm3510.h"
2979 + #include "bcm3510_priv.h"
2980 +
2981 ++/* Max transfer size done by bcm3510_do_hab_cmd() function */
2982 ++#define MAX_XFER_SIZE 128
2983 ++
2984 + struct bcm3510_state {
2985 +
2986 + struct i2c_adapter* i2c;
2987 +@@ -201,9 +204,19 @@ static int bcm3510_hab_send_request(struct bcm3510_state *st, u8 *buf, int len)
2988 +
2989 + static int bcm3510_do_hab_cmd(struct bcm3510_state *st, u8 cmd, u8 msgid, u8 *obuf, u8 olen, u8 *ibuf, u8 ilen)
2990 + {
2991 +- u8 ob[olen+2],ib[ilen+2];
2992 ++ u8 ob[MAX_XFER_SIZE], ib[MAX_XFER_SIZE];
2993 + int ret = 0;
2994 +
2995 ++ if (ilen + 2 > sizeof(ib)) {
2996 ++ deb_hab("do_hab_cmd: ilen=%d is too big!\n", ilen);
2997 ++ return -EINVAL;
2998 ++ }
2999 ++
3000 ++ if (olen + 2 > sizeof(ob)) {
3001 ++ deb_hab("do_hab_cmd: olen=%d is too big!\n", olen);
3002 ++ return -EINVAL;
3003 ++ }
3004 ++
3005 + ob[0] = cmd;
3006 + ob[1] = msgid;
3007 + memcpy(&ob[2],obuf,olen);
3008 +diff --git a/drivers/media/dvb-frontends/cxd2820r_core.c b/drivers/media/dvb-frontends/cxd2820r_core.c
3009 +index 7ca5c69d..51447a04 100644
3010 +--- a/drivers/media/dvb-frontends/cxd2820r_core.c
3011 ++++ b/drivers/media/dvb-frontends/cxd2820r_core.c
3012 +@@ -21,12 +21,15 @@
3013 +
3014 + #include "cxd2820r_priv.h"
3015 +
3016 ++/* Max transfer size done by I2C transfer functions */
3017 ++#define MAX_XFER_SIZE 64
3018 ++
3019 + /* write multiple registers */
3020 + static int cxd2820r_wr_regs_i2c(struct cxd2820r_priv *priv, u8 i2c, u8 reg,
3021 + u8 *val, int len)
3022 + {
3023 + int ret;
3024 +- u8 buf[len+1];
3025 ++ u8 buf[MAX_XFER_SIZE];
3026 + struct i2c_msg msg[1] = {
3027 + {
3028 + .addr = i2c,
3029 +@@ -36,6 +39,13 @@ static int cxd2820r_wr_regs_i2c(struct cxd2820r_priv *priv, u8 i2c, u8 reg,
3030 + }
3031 + };
3032 +
3033 ++ if (1 + len > sizeof(buf)) {
3034 ++ dev_warn(&priv->i2c->dev,
3035 ++ "%s: i2c wr reg=%04x: len=%d is too big!\n",
3036 ++ KBUILD_MODNAME, reg, len);
3037 ++ return -EINVAL;
3038 ++ }
3039 ++
3040 + buf[0] = reg;
3041 + memcpy(&buf[1], val, len);
3042 +
3043 +@@ -55,7 +65,7 @@ static int cxd2820r_rd_regs_i2c(struct cxd2820r_priv *priv, u8 i2c, u8 reg,
3044 + u8 *val, int len)
3045 + {
3046 + int ret;
3047 +- u8 buf[len];
3048 ++ u8 buf[MAX_XFER_SIZE];
3049 + struct i2c_msg msg[2] = {
3050 + {
3051 + .addr = i2c,
3052 +@@ -70,6 +80,13 @@ static int cxd2820r_rd_regs_i2c(struct cxd2820r_priv *priv, u8 i2c, u8 reg,
3053 + }
3054 + };
3055 +
3056 ++ if (len > sizeof(buf)) {
3057 ++ dev_warn(&priv->i2c->dev,
3058 ++ "%s: i2c wr reg=%04x: len=%d is too big!\n",
3059 ++ KBUILD_MODNAME, reg, len);
3060 ++ return -EINVAL;
3061 ++ }
3062 ++
3063 + ret = i2c_transfer(priv->i2c, msg, 2);
3064 + if (ret == 2) {
3065 + memcpy(val, buf, len);
3066 +diff --git a/drivers/media/dvb-frontends/itd1000.c b/drivers/media/dvb-frontends/itd1000.c
3067 +index c1c3400b..cadcae4c 100644
3068 +--- a/drivers/media/dvb-frontends/itd1000.c
3069 ++++ b/drivers/media/dvb-frontends/itd1000.c
3070 +@@ -31,6 +31,9 @@
3071 + #include "itd1000.h"
3072 + #include "itd1000_priv.h"
3073 +
3074 ++/* Max transfer size done by I2C transfer functions */
3075 ++#define MAX_XFER_SIZE 64
3076 ++
3077 + static int debug;
3078 + module_param(debug, int, 0644);
3079 + MODULE_PARM_DESC(debug, "Turn on/off debugging (default:off).");
3080 +@@ -52,10 +55,18 @@ MODULE_PARM_DESC(debug, "Turn on/off debugging (default:off).");
3081 + /* don't write more than one byte with flexcop behind */
3082 + static int itd1000_write_regs(struct itd1000_state *state, u8 reg, u8 v[], u8 len)
3083 + {
3084 +- u8 buf[1+len];
3085 ++ u8 buf[MAX_XFER_SIZE];
3086 + struct i2c_msg msg = {
3087 + .addr = state->cfg->i2c_address, .flags = 0, .buf = buf, .len = len+1
3088 + };
3089 ++
3090 ++ if (1 + len > sizeof(buf)) {
3091 ++ printk(KERN_WARNING
3092 ++ "itd1000: i2c wr reg=%04x: len=%d is too big!\n",
3093 ++ reg, len);
3094 ++ return -EINVAL;
3095 ++ }
3096 ++
3097 + buf[0] = reg;
3098 + memcpy(&buf[1], v, len);
3099 +
3100 +diff --git a/drivers/media/dvb-frontends/mt312.c b/drivers/media/dvb-frontends/mt312.c
3101 +index ec388c1d..a74ac0dd 100644
3102 +--- a/drivers/media/dvb-frontends/mt312.c
3103 ++++ b/drivers/media/dvb-frontends/mt312.c
3104 +@@ -36,6 +36,8 @@
3105 + #include "mt312_priv.h"
3106 + #include "mt312.h"
3107 +
3108 ++/* Max transfer size done by I2C transfer functions */
3109 ++#define MAX_XFER_SIZE 64
3110 +
3111 + struct mt312_state {
3112 + struct i2c_adapter *i2c;
3113 +@@ -96,9 +98,15 @@ static int mt312_write(struct mt312_state *state, const enum mt312_reg_addr reg,
3114 + const u8 *src, const size_t count)
3115 + {
3116 + int ret;
3117 +- u8 buf[count + 1];
3118 ++ u8 buf[MAX_XFER_SIZE];
3119 + struct i2c_msg msg;
3120 +
3121 ++ if (1 + count > sizeof(buf)) {
3122 ++ printk(KERN_WARNING
3123 ++ "mt312: write: len=%zd is too big!\n", count);
3124 ++ return -EINVAL;
3125 ++ }
3126 ++
3127 + if (debug) {
3128 + int i;
3129 + dprintk("W(%d):", reg & 0x7f);
3130 +diff --git a/drivers/media/dvb-frontends/nxt200x.c b/drivers/media/dvb-frontends/nxt200x.c
3131 +index 8e288940..fbca9856 100644
3132 +--- a/drivers/media/dvb-frontends/nxt200x.c
3133 ++++ b/drivers/media/dvb-frontends/nxt200x.c
3134 +@@ -39,6 +39,9 @@
3135 + */
3136 + #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
3137 +
3138 ++/* Max transfer size done by I2C transfer functions */
3139 ++#define MAX_XFER_SIZE 64
3140 ++
3141 + #define NXT2002_DEFAULT_FIRMWARE "dvb-fe-nxt2002.fw"
3142 + #define NXT2004_DEFAULT_FIRMWARE "dvb-fe-nxt2004.fw"
3143 + #define CRC_CCIT_MASK 0x1021
3144 +@@ -95,10 +98,16 @@ static int i2c_readbytes(struct nxt200x_state *state, u8 addr, u8 *buf, u8 len)
3145 + static int nxt200x_writebytes (struct nxt200x_state* state, u8 reg,
3146 + const u8 *buf, u8 len)
3147 + {
3148 +- u8 buf2 [len+1];
3149 ++ u8 buf2[MAX_XFER_SIZE];
3150 + int err;
3151 + struct i2c_msg msg = { .addr = state->config->demod_address, .flags = 0, .buf = buf2, .len = len + 1 };
3152 +
3153 ++ if (1 + len > sizeof(buf2)) {
3154 ++ pr_warn("%s: i2c wr reg=%04x: len=%d is too big!\n",
3155 ++ __func__, reg, len);
3156 ++ return -EINVAL;
3157 ++ }
3158 ++
3159 + buf2[0] = reg;
3160 + memcpy(&buf2[1], buf, len);
3161 +
3162 +diff --git a/drivers/media/dvb-frontends/rtl2830.c b/drivers/media/dvb-frontends/rtl2830.c
3163 +index 362d26d1..7efb796c 100644
3164 +--- a/drivers/media/dvb-frontends/rtl2830.c
3165 ++++ b/drivers/media/dvb-frontends/rtl2830.c
3166 +@@ -27,20 +27,30 @@
3167 +
3168 + #include "rtl2830_priv.h"
3169 +
3170 ++/* Max transfer size done by I2C transfer functions */
3171 ++#define MAX_XFER_SIZE 64
3172 ++
3173 + /* write multiple hardware registers */
3174 + static int rtl2830_wr(struct rtl2830_priv *priv, u8 reg, const u8 *val, int len)
3175 + {
3176 + int ret;
3177 +- u8 buf[1+len];
3178 ++ u8 buf[MAX_XFER_SIZE];
3179 + struct i2c_msg msg[1] = {
3180 + {
3181 + .addr = priv->cfg.i2c_addr,
3182 + .flags = 0,
3183 +- .len = 1+len,
3184 ++ .len = 1 + len,
3185 + .buf = buf,
3186 + }
3187 + };
3188 +
3189 ++ if (1 + len > sizeof(buf)) {
3190 ++ dev_warn(&priv->i2c->dev,
3191 ++ "%s: i2c wr reg=%04x: len=%d is too big!\n",
3192 ++ KBUILD_MODNAME, reg, len);
3193 ++ return -EINVAL;
3194 ++ }
3195 ++
3196 + buf[0] = reg;
3197 + memcpy(&buf[1], val, len);
3198 +
3199 +diff --git a/drivers/media/dvb-frontends/rtl2832.c b/drivers/media/dvb-frontends/rtl2832.c
3200 +index facb8484..b8dd0a13 100644
3201 +--- a/drivers/media/dvb-frontends/rtl2832.c
3202 ++++ b/drivers/media/dvb-frontends/rtl2832.c
3203 +@@ -22,6 +22,9 @@
3204 + #include "dvb_math.h"
3205 + #include <linux/bitops.h>
3206 +
3207 ++/* Max transfer size done by I2C transfer functions */
3208 ++#define MAX_XFER_SIZE 64
3209 ++
3210 + int rtl2832_debug;
3211 + module_param_named(debug, rtl2832_debug, int, 0644);
3212 + MODULE_PARM_DESC(debug, "Turn on/off frontend debugging (default:off).");
3213 +@@ -162,16 +165,23 @@ static const struct rtl2832_reg_entry registers[] = {
3214 + static int rtl2832_wr(struct rtl2832_priv *priv, u8 reg, u8 *val, int len)
3215 + {
3216 + int ret;
3217 +- u8 buf[1+len];
3218 ++ u8 buf[MAX_XFER_SIZE];
3219 + struct i2c_msg msg[1] = {
3220 + {
3221 + .addr = priv->cfg.i2c_addr,
3222 + .flags = 0,
3223 +- .len = 1+len,
3224 ++ .len = 1 + len,
3225 + .buf = buf,
3226 + }
3227 + };
3228 +
3229 ++ if (1 + len > sizeof(buf)) {
3230 ++ dev_warn(&priv->i2c->dev,
3231 ++ "%s: i2c wr reg=%04x: len=%d is too big!\n",
3232 ++ KBUILD_MODNAME, reg, len);
3233 ++ return -EINVAL;
3234 ++ }
3235 ++
3236 + buf[0] = reg;
3237 + memcpy(&buf[1], val, len);
3238 +
3239 +diff --git a/drivers/media/dvb-frontends/s5h1420.c b/drivers/media/dvb-frontends/s5h1420.c
3240 +index e2fec9eb..93eeaf71 100644
3241 +--- a/drivers/media/dvb-frontends/s5h1420.c
3242 ++++ b/drivers/media/dvb-frontends/s5h1420.c
3243 +@@ -836,9 +836,16 @@ static u32 s5h1420_tuner_i2c_func(struct i2c_adapter *adapter)
3244 + static int s5h1420_tuner_i2c_tuner_xfer(struct i2c_adapter *i2c_adap, struct i2c_msg msg[], int num)
3245 + {
3246 + struct s5h1420_state *state = i2c_get_adapdata(i2c_adap);
3247 +- struct i2c_msg m[1 + num];
3248 ++ struct i2c_msg m[3];
3249 + u8 tx_open[2] = { CON_1, state->CON_1_val | 1 }; /* repeater stops once there was a stop condition */
3250 +
3251 ++ if (1 + num > ARRAY_SIZE(m)) {
3252 ++ printk(KERN_WARNING
3253 ++ "%s: i2c xfer: num=%d is too big!\n",
3254 ++ KBUILD_MODNAME, num);
3255 ++ return -EOPNOTSUPP;
3256 ++ }
3257 ++
3258 + memset(m, 0, sizeof(struct i2c_msg) * (1 + num));
3259 +
3260 + m[0].addr = state->config->demod_address;
3261 +@@ -847,7 +854,7 @@ static int s5h1420_tuner_i2c_tuner_xfer(struct i2c_adapter *i2c_adap, struct i2c
3262 +
3263 + memcpy(&m[1], msg, sizeof(struct i2c_msg) * num);
3264 +
3265 +- return i2c_transfer(state->i2c, m, 1+num) == 1 + num ? num : -EIO;
3266 ++ return i2c_transfer(state->i2c, m, 1 + num) == 1 + num ? num : -EIO;
3267 + }
3268 +
3269 + static struct i2c_algorithm s5h1420_tuner_i2c_algo = {
3270 +diff --git a/drivers/media/dvb-frontends/stb0899_drv.c b/drivers/media/dvb-frontends/stb0899_drv.c
3271 +index cc278b3d..2a979cfa 100644
3272 +--- a/drivers/media/dvb-frontends/stb0899_drv.c
3273 ++++ b/drivers/media/dvb-frontends/stb0899_drv.c
3274 +@@ -32,6 +32,9 @@
3275 + #include "stb0899_priv.h"
3276 + #include "stb0899_reg.h"
3277 +
3278 ++/* Max transfer size done by I2C transfer functions */
3279 ++#define MAX_XFER_SIZE 64
3280 ++
3281 + static unsigned int verbose = 0;//1;
3282 + module_param(verbose, int, 0644);
3283 +
3284 +@@ -499,7 +502,7 @@ err:
3285 + int stb0899_write_regs(struct stb0899_state *state, unsigned int reg, u8 *data, u32 count)
3286 + {
3287 + int ret;
3288 +- u8 buf[2 + count];
3289 ++ u8 buf[MAX_XFER_SIZE];
3290 + struct i2c_msg i2c_msg = {
3291 + .addr = state->config->demod_address,
3292 + .flags = 0,
3293 +@@ -507,6 +510,13 @@ int stb0899_write_regs(struct stb0899_state *state, unsigned int reg, u8 *data,
3294 + .len = 2 + count
3295 + };
3296 +
3297 ++ if (2 + count > sizeof(buf)) {
3298 ++ printk(KERN_WARNING
3299 ++ "%s: i2c wr reg=%04x: len=%d is too big!\n",
3300 ++ KBUILD_MODNAME, reg, count);
3301 ++ return -EINVAL;
3302 ++ }
3303 ++
3304 + buf[0] = reg >> 8;
3305 + buf[1] = reg & 0xff;
3306 + memcpy(&buf[2], data, count);
3307 +diff --git a/drivers/media/dvb-frontends/stb6100.c b/drivers/media/dvb-frontends/stb6100.c
3308 +index 45f9523f..cea175d1 100644
3309 +--- a/drivers/media/dvb-frontends/stb6100.c
3310 ++++ b/drivers/media/dvb-frontends/stb6100.c
3311 +@@ -31,6 +31,8 @@
3312 + static unsigned int verbose;
3313 + module_param(verbose, int, 0644);
3314 +
3315 ++/* Max transfer size done by I2C transfer functions */
3316 ++#define MAX_XFER_SIZE 64
3317 +
3318 + #define FE_ERROR 0
3319 + #define FE_NOTICE 1
3320 +@@ -183,7 +185,7 @@ static int stb6100_read_reg(struct stb6100_state *state, u8 reg)
3321 + static int stb6100_write_reg_range(struct stb6100_state *state, u8 buf[], int start, int len)
3322 + {
3323 + int rc;
3324 +- u8 cmdbuf[len + 1];
3325 ++ u8 cmdbuf[MAX_XFER_SIZE];
3326 + struct i2c_msg msg = {
3327 + .addr = state->config->tuner_address,
3328 + .flags = 0,
3329 +@@ -191,6 +193,13 @@ static int stb6100_write_reg_range(struct stb6100_state *state, u8 buf[], int st
3330 + .len = len + 1
3331 + };
3332 +
3333 ++ if (1 + len > sizeof(buf)) {
3334 ++ printk(KERN_WARNING
3335 ++ "%s: i2c wr: len=%d is too big!\n",
3336 ++ KBUILD_MODNAME, len);
3337 ++ return -EINVAL;
3338 ++ }
3339 ++
3340 + if (unlikely(start < 1 || start + len > STB6100_NUMREGS)) {
3341 + dprintk(verbose, FE_ERROR, 1, "Invalid register range %d:%d",
3342 + start, len);
3343 +diff --git a/drivers/media/dvb-frontends/stv0367.c b/drivers/media/dvb-frontends/stv0367.c
3344 +index 0c8e4594..f6c72779 100644
3345 +--- a/drivers/media/dvb-frontends/stv0367.c
3346 ++++ b/drivers/media/dvb-frontends/stv0367.c
3347 +@@ -33,6 +33,9 @@
3348 + #include "stv0367_regs.h"
3349 + #include "stv0367_priv.h"
3350 +
3351 ++/* Max transfer size done by I2C transfer functions */
3352 ++#define MAX_XFER_SIZE 64
3353 ++
3354 + static int stvdebug;
3355 + module_param_named(debug, stvdebug, int, 0644);
3356 +
3357 +@@ -767,7 +770,7 @@ static struct st_register def0367cab[STV0367CAB_NBREGS] = {
3358 + static
3359 + int stv0367_writeregs(struct stv0367_state *state, u16 reg, u8 *data, int len)
3360 + {
3361 +- u8 buf[len + 2];
3362 ++ u8 buf[MAX_XFER_SIZE];
3363 + struct i2c_msg msg = {
3364 + .addr = state->config->demod_address,
3365 + .flags = 0,
3366 +@@ -776,6 +779,14 @@ int stv0367_writeregs(struct stv0367_state *state, u16 reg, u8 *data, int len)
3367 + };
3368 + int ret;
3369 +
3370 ++ if (2 + len > sizeof(buf)) {
3371 ++ printk(KERN_WARNING
3372 ++ "%s: i2c wr reg=%04x: len=%d is too big!\n",
3373 ++ KBUILD_MODNAME, reg, len);
3374 ++ return -EINVAL;
3375 ++ }
3376 ++
3377 ++
3378 + buf[0] = MSB(reg);
3379 + buf[1] = LSB(reg);
3380 + memcpy(buf + 2, data, len);
3381 +diff --git a/drivers/media/dvb-frontends/stv090x.c b/drivers/media/dvb-frontends/stv090x.c
3382 +index 56d470ad..23e872f8 100644
3383 +--- a/drivers/media/dvb-frontends/stv090x.c
3384 ++++ b/drivers/media/dvb-frontends/stv090x.c
3385 +@@ -35,6 +35,9 @@
3386 + #include "stv090x.h"
3387 + #include "stv090x_priv.h"
3388 +
3389 ++/* Max transfer size done by I2C transfer functions */
3390 ++#define MAX_XFER_SIZE 64
3391 ++
3392 + static unsigned int verbose;
3393 + module_param(verbose, int, 0644);
3394 +
3395 +@@ -722,9 +725,16 @@ static int stv090x_write_regs(struct stv090x_state *state, unsigned int reg, u8
3396 + {
3397 + const struct stv090x_config *config = state->config;
3398 + int ret;
3399 +- u8 buf[2 + count];
3400 ++ u8 buf[MAX_XFER_SIZE];
3401 + struct i2c_msg i2c_msg = { .addr = config->address, .flags = 0, .buf = buf, .len = 2 + count };
3402 +
3403 ++ if (2 + count > sizeof(buf)) {
3404 ++ printk(KERN_WARNING
3405 ++ "%s: i2c wr reg=%04x: len=%d is too big!\n",
3406 ++ KBUILD_MODNAME, reg, count);
3407 ++ return -EINVAL;
3408 ++ }
3409 ++
3410 + buf[0] = reg >> 8;
3411 + buf[1] = reg & 0xff;
3412 + memcpy(&buf[2], data, count);
3413 +diff --git a/drivers/media/dvb-frontends/stv6110.c b/drivers/media/dvb-frontends/stv6110.c
3414 +index 20b5fa92..b1425830 100644
3415 +--- a/drivers/media/dvb-frontends/stv6110.c
3416 ++++ b/drivers/media/dvb-frontends/stv6110.c
3417 +@@ -30,6 +30,9 @@
3418 +
3419 + #include "stv6110.h"
3420 +
3421 ++/* Max transfer size done by I2C transfer functions */
3422 ++#define MAX_XFER_SIZE 64
3423 ++
3424 + static int debug;
3425 +
3426 + struct stv6110_priv {
3427 +@@ -68,7 +71,7 @@ static int stv6110_write_regs(struct dvb_frontend *fe, u8 buf[],
3428 + {
3429 + struct stv6110_priv *priv = fe->tuner_priv;
3430 + int rc;
3431 +- u8 cmdbuf[len + 1];
3432 ++ u8 cmdbuf[MAX_XFER_SIZE];
3433 + struct i2c_msg msg = {
3434 + .addr = priv->i2c_address,
3435 + .flags = 0,
3436 +@@ -78,6 +81,13 @@ static int stv6110_write_regs(struct dvb_frontend *fe, u8 buf[],
3437 +
3438 + dprintk("%s\n", __func__);
3439 +
3440 ++ if (1 + len > sizeof(cmdbuf)) {
3441 ++ printk(KERN_WARNING
3442 ++ "%s: i2c wr: len=%d is too big!\n",
3443 ++ KBUILD_MODNAME, len);
3444 ++ return -EINVAL;
3445 ++ }
3446 ++
3447 + if (start + len > 8)
3448 + return -EINVAL;
3449 +
3450 +diff --git a/drivers/media/dvb-frontends/stv6110x.c b/drivers/media/dvb-frontends/stv6110x.c
3451 +index f36cab12..e66154e5 100644
3452 +--- a/drivers/media/dvb-frontends/stv6110x.c
3453 ++++ b/drivers/media/dvb-frontends/stv6110x.c
3454 +@@ -32,6 +32,9 @@
3455 + #include "stv6110x.h"
3456 + #include "stv6110x_priv.h"
3457 +
3458 ++/* Max transfer size done by I2C transfer functions */
3459 ++#define MAX_XFER_SIZE 64
3460 ++
3461 + static unsigned int verbose;
3462 + module_param(verbose, int, 0644);
3463 + MODULE_PARM_DESC(verbose, "Set Verbosity level");
3464 +@@ -61,7 +64,8 @@ static int stv6110x_write_regs(struct stv6110x_state *stv6110x, int start, u8 da
3465 + {
3466 + int ret;
3467 + const struct stv6110x_config *config = stv6110x->config;
3468 +- u8 buf[len + 1];
3469 ++ u8 buf[MAX_XFER_SIZE];
3470 ++
3471 + struct i2c_msg msg = {
3472 + .addr = config->addr,
3473 + .flags = 0,
3474 +@@ -69,6 +73,13 @@ static int stv6110x_write_regs(struct stv6110x_state *stv6110x, int start, u8 da
3475 + .len = len + 1
3476 + };
3477 +
3478 ++ if (1 + len > sizeof(buf)) {
3479 ++ printk(KERN_WARNING
3480 ++ "%s: i2c wr: len=%d is too big!\n",
3481 ++ KBUILD_MODNAME, len);
3482 ++ return -EINVAL;
3483 ++ }
3484 ++
3485 + if (start + len > 8)
3486 + return -EINVAL;
3487 +
3488 +diff --git a/drivers/media/dvb-frontends/tda10071.c b/drivers/media/dvb-frontends/tda10071.c
3489 +index 2521f7e2..36eb27d3 100644
3490 +--- a/drivers/media/dvb-frontends/tda10071.c
3491 ++++ b/drivers/media/dvb-frontends/tda10071.c
3492 +@@ -20,6 +20,9 @@
3493 +
3494 + #include "tda10071_priv.h"
3495 +
3496 ++/* Max transfer size done by I2C transfer functions */
3497 ++#define MAX_XFER_SIZE 64
3498 ++
3499 + static struct dvb_frontend_ops tda10071_ops;
3500 +
3501 + /* write multiple registers */
3502 +@@ -27,16 +30,23 @@ static int tda10071_wr_regs(struct tda10071_priv *priv, u8 reg, u8 *val,
3503 + int len)
3504 + {
3505 + int ret;
3506 +- u8 buf[len+1];
3507 ++ u8 buf[MAX_XFER_SIZE];
3508 + struct i2c_msg msg[1] = {
3509 + {
3510 + .addr = priv->cfg.demod_i2c_addr,
3511 + .flags = 0,
3512 +- .len = sizeof(buf),
3513 ++ .len = 1 + len,
3514 + .buf = buf,
3515 + }
3516 + };
3517 +
3518 ++ if (1 + len > sizeof(buf)) {
3519 ++ dev_warn(&priv->i2c->dev,
3520 ++ "%s: i2c wr reg=%04x: len=%d is too big!\n",
3521 ++ KBUILD_MODNAME, reg, len);
3522 ++ return -EINVAL;
3523 ++ }
3524 ++
3525 + buf[0] = reg;
3526 + memcpy(&buf[1], val, len);
3527 +
3528 +@@ -56,7 +66,7 @@ static int tda10071_rd_regs(struct tda10071_priv *priv, u8 reg, u8 *val,
3529 + int len)
3530 + {
3531 + int ret;
3532 +- u8 buf[len];
3533 ++ u8 buf[MAX_XFER_SIZE];
3534 + struct i2c_msg msg[2] = {
3535 + {
3536 + .addr = priv->cfg.demod_i2c_addr,
3537 +@@ -66,11 +76,18 @@ static int tda10071_rd_regs(struct tda10071_priv *priv, u8 reg, u8 *val,
3538 + }, {
3539 + .addr = priv->cfg.demod_i2c_addr,
3540 + .flags = I2C_M_RD,
3541 +- .len = sizeof(buf),
3542 ++ .len = len,
3543 + .buf = buf,
3544 + }
3545 + };
3546 +
3547 ++ if (len > sizeof(buf)) {
3548 ++ dev_warn(&priv->i2c->dev,
3549 ++ "%s: i2c wr reg=%04x: len=%d is too big!\n",
3550 ++ KBUILD_MODNAME, reg, len);
3551 ++ return -EINVAL;
3552 ++ }
3553 ++
3554 + ret = i2c_transfer(priv->i2c, msg, 2);
3555 + if (ret == 2) {
3556 + memcpy(val, buf, len);
3557 +diff --git a/drivers/media/dvb-frontends/tda18271c2dd.c b/drivers/media/dvb-frontends/tda18271c2dd.c
3558 +index d281f77d..2c54586a 100644
3559 +--- a/drivers/media/dvb-frontends/tda18271c2dd.c
3560 ++++ b/drivers/media/dvb-frontends/tda18271c2dd.c
3561 +@@ -34,6 +34,9 @@
3562 + #include "dvb_frontend.h"
3563 + #include "tda18271c2dd.h"
3564 +
3565 ++/* Max transfer size done by I2C transfer functions */
3566 ++#define MAX_XFER_SIZE 64
3567 ++
3568 + struct SStandardParam {
3569 + s32 m_IFFrequency;
3570 + u32 m_BandWidth;
3571 +@@ -139,11 +142,18 @@ static int i2c_write(struct i2c_adapter *adap, u8 adr, u8 *data, int len)
3572 + static int WriteRegs(struct tda_state *state,
3573 + u8 SubAddr, u8 *Regs, u16 nRegs)
3574 + {
3575 +- u8 data[nRegs+1];
3576 ++ u8 data[MAX_XFER_SIZE];
3577 ++
3578 ++ if (1 + nRegs > sizeof(data)) {
3579 ++ printk(KERN_WARNING
3580 ++ "%s: i2c wr: len=%d is too big!\n",
3581 ++ KBUILD_MODNAME, nRegs);
3582 ++ return -EINVAL;
3583 ++ }
3584 +
3585 + data[0] = SubAddr;
3586 + memcpy(data + 1, Regs, nRegs);
3587 +- return i2c_write(state->i2c, state->adr, data, nRegs+1);
3588 ++ return i2c_write(state->i2c, state->adr, data, nRegs + 1);
3589 + }
3590 +
3591 + static int WriteReg(struct tda_state *state, u8 SubAddr, u8 Reg)
3592 +diff --git a/drivers/media/dvb-frontends/zl10039.c b/drivers/media/dvb-frontends/zl10039.c
3593 +index eff9c5fd..91b6b2e9 100644
3594 +--- a/drivers/media/dvb-frontends/zl10039.c
3595 ++++ b/drivers/media/dvb-frontends/zl10039.c
3596 +@@ -30,6 +30,9 @@
3597 +
3598 + static int debug;
3599 +
3600 ++/* Max transfer size done by I2C transfer functions */
3601 ++#define MAX_XFER_SIZE 64
3602 ++
3603 + #define dprintk(args...) \
3604 + do { \
3605 + if (debug) \
3606 +@@ -98,7 +101,7 @@ static int zl10039_write(struct zl10039_state *state,
3607 + const enum zl10039_reg_addr reg, const u8 *src,
3608 + const size_t count)
3609 + {
3610 +- u8 buf[count + 1];
3611 ++ u8 buf[MAX_XFER_SIZE];
3612 + struct i2c_msg msg = {
3613 + .addr = state->i2c_addr,
3614 + .flags = 0,
3615 +@@ -106,6 +109,13 @@ static int zl10039_write(struct zl10039_state *state,
3616 + .len = count + 1,
3617 + };
3618 +
3619 ++ if (1 + count > sizeof(buf)) {
3620 ++ printk(KERN_WARNING
3621 ++ "%s: i2c wr reg=%04x: len=%zd is too big!\n",
3622 ++ KBUILD_MODNAME, reg, count);
3623 ++ return -EINVAL;
3624 ++ }
3625 ++
3626 + dprintk("%s\n", __func__);
3627 + /* Write register address and data in one go */
3628 + buf[0] = reg;
3629 +diff --git a/drivers/media/pci/cx18/cx18-driver.c b/drivers/media/pci/cx18/cx18-driver.c
3630 +index 67b61cf3..13c9718a 100644
3631 +--- a/drivers/media/pci/cx18/cx18-driver.c
3632 ++++ b/drivers/media/pci/cx18/cx18-driver.c
3633 +@@ -324,23 +324,24 @@ static void cx18_eeprom_dump(struct cx18 *cx, unsigned char *eedata, int len)
3634 + /* Hauppauge card? get values from tveeprom */
3635 + void cx18_read_eeprom(struct cx18 *cx, struct tveeprom *tv)
3636 + {
3637 +- struct i2c_client c;
3638 ++ struct i2c_client *c;
3639 + u8 eedata[256];
3640 +
3641 +- memset(&c, 0, sizeof(c));
3642 +- strlcpy(c.name, "cx18 tveeprom tmp", sizeof(c.name));
3643 +- c.adapter = &cx->i2c_adap[0];
3644 +- c.addr = 0xA0 >> 1;
3645 ++ c = kzalloc(sizeof(*c), GFP_KERNEL);
3646 ++
3647 ++ strlcpy(c->name, "cx18 tveeprom tmp", sizeof(c->name));
3648 ++ c->adapter = &cx->i2c_adap[0];
3649 ++ c->addr = 0xa0 >> 1;
3650 +
3651 + memset(tv, 0, sizeof(*tv));
3652 +- if (tveeprom_read(&c, eedata, sizeof(eedata)))
3653 +- return;
3654 ++ if (tveeprom_read(c, eedata, sizeof(eedata)))
3655 ++ goto ret;
3656 +
3657 + switch (cx->card->type) {
3658 + case CX18_CARD_HVR_1600_ESMT:
3659 + case CX18_CARD_HVR_1600_SAMSUNG:
3660 + case CX18_CARD_HVR_1600_S5H1411:
3661 +- tveeprom_hauppauge_analog(&c, tv, eedata);
3662 ++ tveeprom_hauppauge_analog(c, tv, eedata);
3663 + break;
3664 + case CX18_CARD_YUAN_MPC718:
3665 + case CX18_CARD_GOTVIEW_PCI_DVD3:
3666 +@@ -354,6 +355,9 @@ void cx18_read_eeprom(struct cx18 *cx, struct tveeprom *tv)
3667 + cx18_eeprom_dump(cx, eedata, sizeof(eedata));
3668 + break;
3669 + }
3670 ++
3671 ++ret:
3672 ++ kfree(c);
3673 + }
3674 +
3675 + static void cx18_process_eeprom(struct cx18 *cx)
3676 +diff --git a/drivers/media/pci/cx23885/cimax2.c b/drivers/media/pci/cx23885/cimax2.c
3677 +index 73448491..16fa7ea4 100644
3678 +--- a/drivers/media/pci/cx23885/cimax2.c
3679 ++++ b/drivers/media/pci/cx23885/cimax2.c
3680 +@@ -26,6 +26,10 @@
3681 + #include "cx23885.h"
3682 + #include "cimax2.h"
3683 + #include "dvb_ca_en50221.h"
3684 ++
3685 ++/* Max transfer size done by I2C transfer functions */
3686 ++#define MAX_XFER_SIZE 64
3687 ++
3688 + /**** Bit definitions for MC417_RWD and MC417_OEN registers ***
3689 + bits 31-16
3690 + +-----------+
3691 +@@ -125,7 +129,7 @@ static int netup_write_i2c(struct i2c_adapter *i2c_adap, u8 addr, u8 reg,
3692 + u8 *buf, int len)
3693 + {
3694 + int ret;
3695 +- u8 buffer[len + 1];
3696 ++ u8 buffer[MAX_XFER_SIZE];
3697 +
3698 + struct i2c_msg msg = {
3699 + .addr = addr,
3700 +@@ -134,6 +138,13 @@ static int netup_write_i2c(struct i2c_adapter *i2c_adap, u8 addr, u8 reg,
3701 + .len = len + 1
3702 + };
3703 +
3704 ++ if (1 + len > sizeof(buffer)) {
3705 ++ printk(KERN_WARNING
3706 ++ "%s: i2c wr reg=%04x: len=%d is too big!\n",
3707 ++ KBUILD_MODNAME, reg, len);
3708 ++ return -EINVAL;
3709 ++ }
3710 ++
3711 + buffer[0] = reg;
3712 + memcpy(&buffer[1], buf, len);
3713 +
3714 +diff --git a/drivers/media/pci/cx23885/cx23885-dvb.c b/drivers/media/pci/cx23885/cx23885-dvb.c
3715 +index 9c5ed10b..bb291c66 100644
3716 +--- a/drivers/media/pci/cx23885/cx23885-dvb.c
3717 ++++ b/drivers/media/pci/cx23885/cx23885-dvb.c
3718 +@@ -1249,6 +1249,10 @@ static int dvb_register(struct cx23885_tsport *port)
3719 + fe0->dvb.frontend = dvb_attach(ds3000_attach,
3720 + &tevii_ds3000_config,
3721 + &i2c_bus->i2c_adap);
3722 ++ if (fe0->dvb.frontend != NULL) {
3723 ++ dvb_attach(ts2020_attach, fe0->dvb.frontend,
3724 ++ &tevii_ts2020_config, &i2c_bus->i2c_adap);
3725 ++ }
3726 + break;
3727 + case CX23885_BOARD_PROF_8000:
3728 + i2c_bus = &dev->i2c_bus[0];
3729 +diff --git a/drivers/media/pci/ttpci/av7110_hw.c b/drivers/media/pci/ttpci/av7110_hw.c
3730 +index f1cbfe52..6299d5da 100644
3731 +--- a/drivers/media/pci/ttpci/av7110_hw.c
3732 ++++ b/drivers/media/pci/ttpci/av7110_hw.c
3733 +@@ -22,7 +22,7 @@
3734 + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
3735 + * Or, point your browser to http://www.gnu.org/copyleft/gpl.html
3736 + *
3737 +- * the project's page is at http://www.linuxtv.org/
3738 ++ * the project's page is at http://www.linuxtv.org/
3739 + */
3740 +
3741 + /* for debugging ARM communication: */
3742 +@@ -40,6 +40,14 @@
3743 +
3744 + #define _NOHANDSHAKE
3745 +
3746 ++/*
3747 ++ * Max transfer size done by av7110_fw_cmd()
3748 ++ *
3749 ++ * The maximum size passed to this function is 6 bytes. The buffer also
3750 ++ * uses two additional ones for type and size. So, 8 bytes is enough.
3751 ++ */
3752 ++#define MAX_XFER_SIZE 8
3753 ++
3754 + /****************************************************************************
3755 + * DEBI functions
3756 + ****************************************************************************/
3757 +@@ -488,11 +496,18 @@ static int av7110_send_fw_cmd(struct av7110 *av7110, u16* buf, int length)
3758 + int av7110_fw_cmd(struct av7110 *av7110, int type, int com, int num, ...)
3759 + {
3760 + va_list args;
3761 +- u16 buf[num + 2];
3762 ++ u16 buf[MAX_XFER_SIZE];
3763 + int i, ret;
3764 +
3765 + // dprintk(4, "%p\n", av7110);
3766 +
3767 ++ if (2 + num > sizeof(buf)) {
3768 ++ printk(KERN_WARNING
3769 ++ "%s: %s len=%d is too big!\n",
3770 ++ KBUILD_MODNAME, __func__, num);
3771 ++ return -EINVAL;
3772 ++ }
3773 ++
3774 + buf[0] = ((type << 8) | com);
3775 + buf[1] = num;
3776 +
3777 +diff --git a/drivers/media/tuners/e4000.c b/drivers/media/tuners/e4000.c
3778 +index 1b33ed36..c4ce4500 100644
3779 +--- a/drivers/media/tuners/e4000.c
3780 ++++ b/drivers/media/tuners/e4000.c
3781 +@@ -20,20 +20,30 @@
3782 +
3783 + #include "e4000_priv.h"
3784 +
3785 ++/* Max transfer size done by I2C transfer functions */
3786 ++#define MAX_XFER_SIZE 64
3787 ++
3788 + /* write multiple registers */
3789 + static int e4000_wr_regs(struct e4000_priv *priv, u8 reg, u8 *val, int len)
3790 + {
3791 + int ret;
3792 +- u8 buf[1 + len];
3793 ++ u8 buf[MAX_XFER_SIZE];
3794 + struct i2c_msg msg[1] = {
3795 + {
3796 + .addr = priv->cfg->i2c_addr,
3797 + .flags = 0,
3798 +- .len = sizeof(buf),
3799 ++ .len = 1 + len,
3800 + .buf = buf,
3801 + }
3802 + };
3803 +
3804 ++ if (1 + len > sizeof(buf)) {
3805 ++ dev_warn(&priv->i2c->dev,
3806 ++ "%s: i2c wr reg=%04x: len=%d is too big!\n",
3807 ++ KBUILD_MODNAME, reg, len);
3808 ++ return -EINVAL;
3809 ++ }
3810 ++
3811 + buf[0] = reg;
3812 + memcpy(&buf[1], val, len);
3813 +
3814 +@@ -52,7 +62,7 @@ static int e4000_wr_regs(struct e4000_priv *priv, u8 reg, u8 *val, int len)
3815 + static int e4000_rd_regs(struct e4000_priv *priv, u8 reg, u8 *val, int len)
3816 + {
3817 + int ret;
3818 +- u8 buf[len];
3819 ++ u8 buf[MAX_XFER_SIZE];
3820 + struct i2c_msg msg[2] = {
3821 + {
3822 + .addr = priv->cfg->i2c_addr,
3823 +@@ -62,11 +72,18 @@ static int e4000_rd_regs(struct e4000_priv *priv, u8 reg, u8 *val, int len)
3824 + }, {
3825 + .addr = priv->cfg->i2c_addr,
3826 + .flags = I2C_M_RD,
3827 +- .len = sizeof(buf),
3828 ++ .len = len,
3829 + .buf = buf,
3830 + }
3831 + };
3832 +
3833 ++ if (len > sizeof(buf)) {
3834 ++ dev_warn(&priv->i2c->dev,
3835 ++ "%s: i2c rd reg=%04x: len=%d is too big!\n",
3836 ++ KBUILD_MODNAME, reg, len);
3837 ++ return -EINVAL;
3838 ++ }
3839 ++
3840 + ret = i2c_transfer(priv->i2c, msg, 2);
3841 + if (ret == 2) {
3842 + memcpy(val, buf, len);
3843 +diff --git a/drivers/media/tuners/fc2580.c b/drivers/media/tuners/fc2580.c
3844 +index 81f38aae..3aecaf46 100644
3845 +--- a/drivers/media/tuners/fc2580.c
3846 ++++ b/drivers/media/tuners/fc2580.c
3847 +@@ -20,6 +20,9 @@
3848 +
3849 + #include "fc2580_priv.h"
3850 +
3851 ++/* Max transfer size done by I2C transfer functions */
3852 ++#define MAX_XFER_SIZE 64
3853 ++
3854 + /*
3855 + * TODO:
3856 + * I2C write and read works only for one single register. Multiple registers
3857 +@@ -41,16 +44,23 @@
3858 + static int fc2580_wr_regs(struct fc2580_priv *priv, u8 reg, u8 *val, int len)
3859 + {
3860 + int ret;
3861 +- u8 buf[1 + len];
3862 ++ u8 buf[MAX_XFER_SIZE];
3863 + struct i2c_msg msg[1] = {
3864 + {
3865 + .addr = priv->cfg->i2c_addr,
3866 + .flags = 0,
3867 +- .len = sizeof(buf),
3868 ++ .len = 1 + len,
3869 + .buf = buf,
3870 + }
3871 + };
3872 +
3873 ++ if (1 + len > sizeof(buf)) {
3874 ++ dev_warn(&priv->i2c->dev,
3875 ++ "%s: i2c wr reg=%04x: len=%d is too big!\n",
3876 ++ KBUILD_MODNAME, reg, len);
3877 ++ return -EINVAL;
3878 ++ }
3879 ++
3880 + buf[0] = reg;
3881 + memcpy(&buf[1], val, len);
3882 +
3883 +@@ -69,7 +79,7 @@ static int fc2580_wr_regs(struct fc2580_priv *priv, u8 reg, u8 *val, int len)
3884 + static int fc2580_rd_regs(struct fc2580_priv *priv, u8 reg, u8 *val, int len)
3885 + {
3886 + int ret;
3887 +- u8 buf[len];
3888 ++ u8 buf[MAX_XFER_SIZE];
3889 + struct i2c_msg msg[2] = {
3890 + {
3891 + .addr = priv->cfg->i2c_addr,
3892 +@@ -79,11 +89,18 @@ static int fc2580_rd_regs(struct fc2580_priv *priv, u8 reg, u8 *val, int len)
3893 + }, {
3894 + .addr = priv->cfg->i2c_addr,
3895 + .flags = I2C_M_RD,
3896 +- .len = sizeof(buf),
3897 ++ .len = len,
3898 + .buf = buf,
3899 + }
3900 + };
3901 +
3902 ++ if (len > sizeof(buf)) {
3903 ++ dev_warn(&priv->i2c->dev,
3904 ++ "%s: i2c rd reg=%04x: len=%d is too big!\n",
3905 ++ KBUILD_MODNAME, reg, len);
3906 ++ return -EINVAL;
3907 ++ }
3908 ++
3909 + ret = i2c_transfer(priv->i2c, msg, 2);
3910 + if (ret == 2) {
3911 + memcpy(val, buf, len);
3912 +diff --git a/drivers/media/tuners/tda18212.c b/drivers/media/tuners/tda18212.c
3913 +index e4a84ee2..abe256e1 100644
3914 +--- a/drivers/media/tuners/tda18212.c
3915 ++++ b/drivers/media/tuners/tda18212.c
3916 +@@ -20,6 +20,9 @@
3917 +
3918 + #include "tda18212.h"
3919 +
3920 ++/* Max transfer size done by I2C transfer functions */
3921 ++#define MAX_XFER_SIZE 64
3922 ++
3923 + struct tda18212_priv {
3924 + struct tda18212_config *cfg;
3925 + struct i2c_adapter *i2c;
3926 +@@ -32,16 +35,23 @@ static int tda18212_wr_regs(struct tda18212_priv *priv, u8 reg, u8 *val,
3927 + int len)
3928 + {
3929 + int ret;
3930 +- u8 buf[len+1];
3931 ++ u8 buf[MAX_XFER_SIZE];
3932 + struct i2c_msg msg[1] = {
3933 + {
3934 + .addr = priv->cfg->i2c_address,
3935 + .flags = 0,
3936 +- .len = sizeof(buf),
3937 ++ .len = 1 + len,
3938 + .buf = buf,
3939 + }
3940 + };
3941 +
3942 ++ if (1 + len > sizeof(buf)) {
3943 ++ dev_warn(&priv->i2c->dev,
3944 ++ "%s: i2c wr reg=%04x: len=%d is too big!\n",
3945 ++ KBUILD_MODNAME, reg, len);
3946 ++ return -EINVAL;
3947 ++ }
3948 ++
3949 + buf[0] = reg;
3950 + memcpy(&buf[1], val, len);
3951 +
3952 +@@ -61,7 +71,7 @@ static int tda18212_rd_regs(struct tda18212_priv *priv, u8 reg, u8 *val,
3953 + int len)
3954 + {
3955 + int ret;
3956 +- u8 buf[len];
3957 ++ u8 buf[MAX_XFER_SIZE];
3958 + struct i2c_msg msg[2] = {
3959 + {
3960 + .addr = priv->cfg->i2c_address,
3961 +@@ -71,11 +81,18 @@ static int tda18212_rd_regs(struct tda18212_priv *priv, u8 reg, u8 *val,
3962 + }, {
3963 + .addr = priv->cfg->i2c_address,
3964 + .flags = I2C_M_RD,
3965 +- .len = sizeof(buf),
3966 ++ .len = len,
3967 + .buf = buf,
3968 + }
3969 + };
3970 +
3971 ++ if (len > sizeof(buf)) {
3972 ++ dev_warn(&priv->i2c->dev,
3973 ++ "%s: i2c rd reg=%04x: len=%d is too big!\n",
3974 ++ KBUILD_MODNAME, reg, len);
3975 ++ return -EINVAL;
3976 ++ }
3977 ++
3978 + ret = i2c_transfer(priv->i2c, msg, 2);
3979 + if (ret == 2) {
3980 + memcpy(val, buf, len);
3981 +diff --git a/drivers/media/tuners/tda18218.c b/drivers/media/tuners/tda18218.c
3982 +index 2d31aeb6..9300e936 100644
3983 +--- a/drivers/media/tuners/tda18218.c
3984 ++++ b/drivers/media/tuners/tda18218.c
3985 +@@ -20,11 +20,14 @@
3986 +
3987 + #include "tda18218_priv.h"
3988 +
3989 ++/* Max transfer size done by I2C transfer functions */
3990 ++#define MAX_XFER_SIZE 64
3991 ++
3992 + /* write multiple registers */
3993 + static int tda18218_wr_regs(struct tda18218_priv *priv, u8 reg, u8 *val, u8 len)
3994 + {
3995 + int ret = 0, len2, remaining;
3996 +- u8 buf[1 + len];
3997 ++ u8 buf[MAX_XFER_SIZE];
3998 + struct i2c_msg msg[1] = {
3999 + {
4000 + .addr = priv->cfg->i2c_address,
4001 +@@ -33,6 +36,13 @@ static int tda18218_wr_regs(struct tda18218_priv *priv, u8 reg, u8 *val, u8 len)
4002 + }
4003 + };
4004 +
4005 ++ if (1 + len > sizeof(buf)) {
4006 ++ dev_warn(&priv->i2c->dev,
4007 ++ "%s: i2c wr reg=%04x: len=%d is too big!\n",
4008 ++ KBUILD_MODNAME, reg, len);
4009 ++ return -EINVAL;
4010 ++ }
4011 ++
4012 + for (remaining = len; remaining > 0;
4013 + remaining -= (priv->cfg->i2c_wr_max - 1)) {
4014 + len2 = remaining;
4015 +@@ -63,7 +73,7 @@ static int tda18218_wr_regs(struct tda18218_priv *priv, u8 reg, u8 *val, u8 len)
4016 + static int tda18218_rd_regs(struct tda18218_priv *priv, u8 reg, u8 *val, u8 len)
4017 + {
4018 + int ret;
4019 +- u8 buf[reg+len]; /* we must start read always from reg 0x00 */
4020 ++ u8 buf[MAX_XFER_SIZE]; /* we must start read always from reg 0x00 */
4021 + struct i2c_msg msg[2] = {
4022 + {
4023 + .addr = priv->cfg->i2c_address,
4024 +@@ -73,11 +83,18 @@ static int tda18218_rd_regs(struct tda18218_priv *priv, u8 reg, u8 *val, u8 len)
4025 + }, {
4026 + .addr = priv->cfg->i2c_address,
4027 + .flags = I2C_M_RD,
4028 +- .len = sizeof(buf),
4029 ++ .len = reg + len,
4030 + .buf = buf,
4031 + }
4032 + };
4033 +
4034 ++ if (reg + len > sizeof(buf)) {
4035 ++ dev_warn(&priv->i2c->dev,
4036 ++ "%s: i2c wr reg=%04x: len=%d is too big!\n",
4037 ++ KBUILD_MODNAME, reg, len);
4038 ++ return -EINVAL;
4039 ++ }
4040 ++
4041 + ret = i2c_transfer(priv->i2c, msg, 2);
4042 + if (ret == 2) {
4043 + memcpy(val, &buf[reg], len);
4044 +diff --git a/drivers/media/tuners/tuner-xc2028.c b/drivers/media/tuners/tuner-xc2028.c
4045 +index 878d2c4d..9771cd83 100644
4046 +--- a/drivers/media/tuners/tuner-xc2028.c
4047 ++++ b/drivers/media/tuners/tuner-xc2028.c
4048 +@@ -24,6 +24,9 @@
4049 + #include <linux/dvb/frontend.h>
4050 + #include "dvb_frontend.h"
4051 +
4052 ++/* Max transfer size done by I2C transfer functions */
4053 ++#define MAX_XFER_SIZE 80
4054 ++
4055 + /* Registers (Write-only) */
4056 + #define XREG_INIT 0x00
4057 + #define XREG_RF_FREQ 0x02
4058 +@@ -547,7 +550,10 @@ static int load_firmware(struct dvb_frontend *fe, unsigned int type,
4059 + {
4060 + struct xc2028_data *priv = fe->tuner_priv;
4061 + int pos, rc;
4062 +- unsigned char *p, *endp, buf[priv->ctrl.max_len];
4063 ++ unsigned char *p, *endp, buf[MAX_XFER_SIZE];
4064 ++
4065 ++ if (priv->ctrl.max_len > sizeof(buf))
4066 ++ priv->ctrl.max_len = sizeof(buf);
4067 +
4068 + tuner_dbg("%s called\n", __func__);
4069 +
4070 +diff --git a/drivers/media/usb/dvb-usb-v2/af9015.c b/drivers/media/usb/dvb-usb-v2/af9015.c
4071 +index d556042c..da47d239 100644
4072 +--- a/drivers/media/usb/dvb-usb-v2/af9015.c
4073 ++++ b/drivers/media/usb/dvb-usb-v2/af9015.c
4074 +@@ -397,12 +397,13 @@ error:
4075 + return ret;
4076 + }
4077 +
4078 ++#define AF9015_EEPROM_SIZE 256
4079 ++
4080 + /* hash (and dump) eeprom */
4081 + static int af9015_eeprom_hash(struct dvb_usb_device *d)
4082 + {
4083 + struct af9015_state *state = d_to_priv(d);
4084 + int ret, i;
4085 +- static const unsigned int AF9015_EEPROM_SIZE = 256;
4086 + u8 buf[AF9015_EEPROM_SIZE];
4087 + struct req_t req = {READ_I2C, AF9015_I2C_EEPROM, 0, 0, 1, 1, NULL};
4088 +
4089 +diff --git a/drivers/media/usb/dvb-usb-v2/af9035.c b/drivers/media/usb/dvb-usb-v2/af9035.c
4090 +index b638fc1c..3968bff3 100644
4091 +--- a/drivers/media/usb/dvb-usb-v2/af9035.c
4092 ++++ b/drivers/media/usb/dvb-usb-v2/af9035.c
4093 +@@ -21,6 +21,9 @@
4094 +
4095 + #include "af9035.h"
4096 +
4097 ++/* Max transfer size done by I2C transfer functions */
4098 ++#define MAX_XFER_SIZE 64
4099 ++
4100 + DVB_DEFINE_MOD_OPT_ADAPTER_NR(adapter_nr);
4101 +
4102 + static u16 af9035_checksum(const u8 *buf, size_t len)
4103 +@@ -125,10 +128,16 @@ exit:
4104 + /* write multiple registers */
4105 + static int af9035_wr_regs(struct dvb_usb_device *d, u32 reg, u8 *val, int len)
4106 + {
4107 +- u8 wbuf[6 + len];
4108 ++ u8 wbuf[MAX_XFER_SIZE];
4109 + u8 mbox = (reg >> 16) & 0xff;
4110 + struct usb_req req = { CMD_MEM_WR, mbox, sizeof(wbuf), wbuf, 0, NULL };
4111 +
4112 ++ if (6 + len > sizeof(wbuf)) {
4113 ++ dev_warn(&d->udev->dev, "%s: i2c wr: len=%d is too big!\n",
4114 ++ KBUILD_MODNAME, len);
4115 ++ return -EOPNOTSUPP;
4116 ++ }
4117 ++
4118 + wbuf[0] = len;
4119 + wbuf[1] = 2;
4120 + wbuf[2] = 0;
4121 +@@ -227,9 +236,16 @@ static int af9035_i2c_master_xfer(struct i2c_adapter *adap,
4122 + msg[1].len);
4123 + } else {
4124 + /* I2C */
4125 +- u8 buf[5 + msg[0].len];
4126 ++ u8 buf[MAX_XFER_SIZE];
4127 + struct usb_req req = { CMD_I2C_RD, 0, sizeof(buf),
4128 + buf, msg[1].len, msg[1].buf };
4129 ++
4130 ++ if (5 + msg[0].len > sizeof(buf)) {
4131 ++ dev_warn(&d->udev->dev,
4132 ++ "%s: i2c xfer: len=%d is too big!\n",
4133 ++ KBUILD_MODNAME, msg[0].len);
4134 ++ return -EOPNOTSUPP;
4135 ++ }
4136 + req.mbox |= ((msg[0].addr & 0x80) >> 3);
4137 + buf[0] = msg[1].len;
4138 + buf[1] = msg[0].addr << 1;
4139 +@@ -256,9 +272,16 @@ static int af9035_i2c_master_xfer(struct i2c_adapter *adap,
4140 + msg[0].len - 3);
4141 + } else {
4142 + /* I2C */
4143 +- u8 buf[5 + msg[0].len];
4144 ++ u8 buf[MAX_XFER_SIZE];
4145 + struct usb_req req = { CMD_I2C_WR, 0, sizeof(buf), buf,
4146 + 0, NULL };
4147 ++
4148 ++ if (5 + msg[0].len > sizeof(buf)) {
4149 ++ dev_warn(&d->udev->dev,
4150 ++ "%s: i2c xfer: len=%d is too big!\n",
4151 ++ KBUILD_MODNAME, msg[0].len);
4152 ++ return -EOPNOTSUPP;
4153 ++ }
4154 + req.mbox |= ((msg[0].addr & 0x80) >> 3);
4155 + buf[0] = msg[0].len;
4156 + buf[1] = msg[0].addr << 1;
4157 +diff --git a/drivers/media/usb/dvb-usb-v2/mxl111sf.c b/drivers/media/usb/dvb-usb-v2/mxl111sf.c
4158 +index efdcb153..419a7c7e 100644
4159 +--- a/drivers/media/usb/dvb-usb-v2/mxl111sf.c
4160 ++++ b/drivers/media/usb/dvb-usb-v2/mxl111sf.c
4161 +@@ -23,6 +23,9 @@
4162 + #include "lgdt3305.h"
4163 + #include "lg2160.h"
4164 +
4165 ++/* Max transfer size done by I2C transfer functions */
4166 ++#define MAX_XFER_SIZE 64
4167 ++
4168 + int dvb_usb_mxl111sf_debug;
4169 + module_param_named(debug, dvb_usb_mxl111sf_debug, int, 0644);
4170 + MODULE_PARM_DESC(debug, "set debugging level "
4171 +@@ -63,7 +66,12 @@ int mxl111sf_ctrl_msg(struct dvb_usb_device *d,
4172 + {
4173 + int wo = (rbuf == NULL || rlen == 0); /* write-only */
4174 + int ret;
4175 +- u8 sndbuf[1+wlen];
4176 ++ u8 sndbuf[MAX_XFER_SIZE];
4177 ++
4178 ++ if (1 + wlen > sizeof(sndbuf)) {
4179 ++ pr_warn("%s: len=%d is too big!\n", __func__, wlen);
4180 ++ return -EOPNOTSUPP;
4181 ++ }
4182 +
4183 + deb_adv("%s(wlen = %d, rlen = %d)\n", __func__, wlen, rlen);
4184 +
4185 +diff --git a/drivers/media/usb/dvb-usb/cxusb.c b/drivers/media/usb/dvb-usb/cxusb.c
4186 +index 3940bb0f..20e345d9 100644
4187 +--- a/drivers/media/usb/dvb-usb/cxusb.c
4188 ++++ b/drivers/media/usb/dvb-usb/cxusb.c
4189 +@@ -43,6 +43,9 @@
4190 + #include "lgs8gxx.h"
4191 + #include "atbm8830.h"
4192 +
4193 ++/* Max transfer size done by I2C transfer functions */
4194 ++#define MAX_XFER_SIZE 64
4195 ++
4196 + /* debug */
4197 + static int dvb_usb_cxusb_debug;
4198 + module_param_named(debug, dvb_usb_cxusb_debug, int, 0644);
4199 +@@ -57,7 +60,14 @@ static int cxusb_ctrl_msg(struct dvb_usb_device *d,
4200 + u8 cmd, u8 *wbuf, int wlen, u8 *rbuf, int rlen)
4201 + {
4202 + int wo = (rbuf == NULL || rlen == 0); /* write-only */
4203 +- u8 sndbuf[1+wlen];
4204 ++ u8 sndbuf[MAX_XFER_SIZE];
4205 ++
4206 ++ if (1 + wlen > sizeof(sndbuf)) {
4207 ++ warn("i2c wr: len=%d is too big!\n",
4208 ++ wlen);
4209 ++ return -EOPNOTSUPP;
4210 ++ }
4211 ++
4212 + memset(sndbuf, 0, 1+wlen);
4213 +
4214 + sndbuf[0] = cmd;
4215 +@@ -158,7 +168,13 @@ static int cxusb_i2c_xfer(struct i2c_adapter *adap, struct i2c_msg msg[],
4216 +
4217 + if (msg[i].flags & I2C_M_RD) {
4218 + /* read only */
4219 +- u8 obuf[3], ibuf[1+msg[i].len];
4220 ++ u8 obuf[3], ibuf[MAX_XFER_SIZE];
4221 ++
4222 ++ if (1 + msg[i].len > sizeof(ibuf)) {
4223 ++ warn("i2c rd: len=%d is too big!\n",
4224 ++ msg[i].len);
4225 ++ return -EOPNOTSUPP;
4226 ++ }
4227 + obuf[0] = 0;
4228 + obuf[1] = msg[i].len;
4229 + obuf[2] = msg[i].addr;
4230 +@@ -172,7 +188,18 @@ static int cxusb_i2c_xfer(struct i2c_adapter *adap, struct i2c_msg msg[],
4231 + } else if (i+1 < num && (msg[i+1].flags & I2C_M_RD) &&
4232 + msg[i].addr == msg[i+1].addr) {
4233 + /* write to then read from same address */
4234 +- u8 obuf[3+msg[i].len], ibuf[1+msg[i+1].len];
4235 ++ u8 obuf[MAX_XFER_SIZE], ibuf[MAX_XFER_SIZE];
4236 ++
4237 ++ if (3 + msg[i].len > sizeof(obuf)) {
4238 ++ warn("i2c wr: len=%d is too big!\n",
4239 ++ msg[i].len);
4240 ++ return -EOPNOTSUPP;
4241 ++ }
4242 ++ if (1 + msg[i + 1].len > sizeof(ibuf)) {
4243 ++ warn("i2c rd: len=%d is too big!\n",
4244 ++ msg[i + 1].len);
4245 ++ return -EOPNOTSUPP;
4246 ++ }
4247 + obuf[0] = msg[i].len;
4248 + obuf[1] = msg[i+1].len;
4249 + obuf[2] = msg[i].addr;
4250 +@@ -191,7 +218,13 @@ static int cxusb_i2c_xfer(struct i2c_adapter *adap, struct i2c_msg msg[],
4251 + i++;
4252 + } else {
4253 + /* write only */
4254 +- u8 obuf[2+msg[i].len], ibuf;
4255 ++ u8 obuf[MAX_XFER_SIZE], ibuf;
4256 ++
4257 ++ if (2 + msg[i].len > sizeof(obuf)) {
4258 ++ warn("i2c wr: len=%d is too big!\n",
4259 ++ msg[i].len);
4260 ++ return -EOPNOTSUPP;
4261 ++ }
4262 + obuf[0] = msg[i].addr;
4263 + obuf[1] = msg[i].len;
4264 + memcpy(&obuf[2], msg[i].buf, msg[i].len);
4265 +diff --git a/drivers/media/usb/dvb-usb/dibusb-common.c b/drivers/media/usb/dvb-usb/dibusb-common.c
4266 +index c2dded92..6d68af0c 100644
4267 +--- a/drivers/media/usb/dvb-usb/dibusb-common.c
4268 ++++ b/drivers/media/usb/dvb-usb/dibusb-common.c
4269 +@@ -12,6 +12,9 @@
4270 + #include <linux/kconfig.h>
4271 + #include "dibusb.h"
4272 +
4273 ++/* Max transfer size done by I2C transfer functions */
4274 ++#define MAX_XFER_SIZE 64
4275 ++
4276 + static int debug;
4277 + module_param(debug, int, 0644);
4278 + MODULE_PARM_DESC(debug, "set debugging level (1=info (|-able))." DVB_USB_DEBUG_STATUS);
4279 +@@ -105,11 +108,16 @@ EXPORT_SYMBOL(dibusb2_0_power_ctrl);
4280 + static int dibusb_i2c_msg(struct dvb_usb_device *d, u8 addr,
4281 + u8 *wbuf, u16 wlen, u8 *rbuf, u16 rlen)
4282 + {
4283 +- u8 sndbuf[wlen+4]; /* lead(1) devaddr,direction(1) addr(2) data(wlen) (len(2) (when reading)) */
4284 ++ u8 sndbuf[MAX_XFER_SIZE]; /* lead(1) devaddr,direction(1) addr(2) data(wlen) (len(2) (when reading)) */
4285 + /* write only ? */
4286 + int wo = (rbuf == NULL || rlen == 0),
4287 + len = 2 + wlen + (wo ? 0 : 2);
4288 +
4289 ++ if (4 + wlen > sizeof(sndbuf)) {
4290 ++ warn("i2c wr: len=%d is too big!\n", wlen);
4291 ++ return -EOPNOTSUPP;
4292 ++ }
4293 ++
4294 + sndbuf[0] = wo ? DIBUSB_REQ_I2C_WRITE : DIBUSB_REQ_I2C_READ;
4295 + sndbuf[1] = (addr << 1) | (wo ? 0 : 1);
4296 +
4297 +diff --git a/drivers/media/usb/dvb-usb/dw2102.c b/drivers/media/usb/dvb-usb/dw2102.c
4298 +index 6e237b6d..71b22f5a 100644
4299 +--- a/drivers/media/usb/dvb-usb/dw2102.c
4300 ++++ b/drivers/media/usb/dvb-usb/dw2102.c
4301 +@@ -30,6 +30,9 @@
4302 + #include "stb6100_proc.h"
4303 + #include "m88rs2000.h"
4304 +
4305 ++/* Max transfer size done by I2C transfer functions */
4306 ++#define MAX_XFER_SIZE 64
4307 ++
4308 + #ifndef USB_PID_DW2102
4309 + #define USB_PID_DW2102 0x2102
4310 + #endif
4311 +@@ -308,7 +311,14 @@ static int dw2102_earda_i2c_transfer(struct i2c_adapter *adap, struct i2c_msg ms
4312 + case 2: {
4313 + /* read */
4314 + /* first write first register number */
4315 +- u8 ibuf[msg[1].len + 2], obuf[3];
4316 ++ u8 ibuf[MAX_XFER_SIZE], obuf[3];
4317 ++
4318 ++ if (2 + msg[1].len > sizeof(ibuf)) {
4319 ++ warn("i2c rd: len=%d is too big!\n",
4320 ++ msg[1].len);
4321 ++ return -EOPNOTSUPP;
4322 ++ }
4323 ++
4324 + obuf[0] = msg[0].addr << 1;
4325 + obuf[1] = msg[0].len;
4326 + obuf[2] = msg[0].buf[0];
4327 +@@ -325,7 +335,14 @@ static int dw2102_earda_i2c_transfer(struct i2c_adapter *adap, struct i2c_msg ms
4328 + switch (msg[0].addr) {
4329 + case 0x68: {
4330 + /* write to register */
4331 +- u8 obuf[msg[0].len + 2];
4332 ++ u8 obuf[MAX_XFER_SIZE];
4333 ++
4334 ++ if (2 + msg[0].len > sizeof(obuf)) {
4335 ++ warn("i2c wr: len=%d is too big!\n",
4336 ++ msg[1].len);
4337 ++ return -EOPNOTSUPP;
4338 ++ }
4339 ++
4340 + obuf[0] = msg[0].addr << 1;
4341 + obuf[1] = msg[0].len;
4342 + memcpy(obuf + 2, msg[0].buf, msg[0].len);
4343 +@@ -335,7 +352,14 @@ static int dw2102_earda_i2c_transfer(struct i2c_adapter *adap, struct i2c_msg ms
4344 + }
4345 + case 0x61: {
4346 + /* write to tuner */
4347 +- u8 obuf[msg[0].len + 2];
4348 ++ u8 obuf[MAX_XFER_SIZE];
4349 ++
4350 ++ if (2 + msg[0].len > sizeof(obuf)) {
4351 ++ warn("i2c wr: len=%d is too big!\n",
4352 ++ msg[1].len);
4353 ++ return -EOPNOTSUPP;
4354 ++ }
4355 ++
4356 + obuf[0] = msg[0].addr << 1;
4357 + obuf[1] = msg[0].len;
4358 + memcpy(obuf + 2, msg[0].buf, msg[0].len);
4359 +@@ -401,7 +425,14 @@ static int dw2104_i2c_transfer(struct i2c_adapter *adap, struct i2c_msg msg[], i
4360 + default: {
4361 + if (msg[j].flags == I2C_M_RD) {
4362 + /* read registers */
4363 +- u8 ibuf[msg[j].len + 2];
4364 ++ u8 ibuf[MAX_XFER_SIZE];
4365 ++
4366 ++ if (2 + msg[j].len > sizeof(ibuf)) {
4367 ++ warn("i2c rd: len=%d is too big!\n",
4368 ++ msg[j].len);
4369 ++ return -EOPNOTSUPP;
4370 ++ }
4371 ++
4372 + dw210x_op_rw(d->udev, 0xc3,
4373 + (msg[j].addr << 1) + 1, 0,
4374 + ibuf, msg[j].len + 2,
4375 +@@ -430,7 +461,14 @@ static int dw2104_i2c_transfer(struct i2c_adapter *adap, struct i2c_msg msg[], i
4376 + } while (len > 0);
4377 + } else {
4378 + /* write registers */
4379 +- u8 obuf[msg[j].len + 2];
4380 ++ u8 obuf[MAX_XFER_SIZE];
4381 ++
4382 ++ if (2 + msg[j].len > sizeof(obuf)) {
4383 ++ warn("i2c wr: len=%d is too big!\n",
4384 ++ msg[j].len);
4385 ++ return -EOPNOTSUPP;
4386 ++ }
4387 ++
4388 + obuf[0] = msg[j].addr << 1;
4389 + obuf[1] = msg[j].len;
4390 + memcpy(obuf + 2, msg[j].buf, msg[j].len);
4391 +@@ -463,7 +501,13 @@ static int dw3101_i2c_transfer(struct i2c_adapter *adap, struct i2c_msg msg[],
4392 + case 2: {
4393 + /* read */
4394 + /* first write first register number */
4395 +- u8 ibuf[msg[1].len + 2], obuf[3];
4396 ++ u8 ibuf[MAX_XFER_SIZE], obuf[3];
4397 ++
4398 ++ if (2 + msg[1].len > sizeof(ibuf)) {
4399 ++ warn("i2c rd: len=%d is too big!\n",
4400 ++ msg[1].len);
4401 ++ return -EOPNOTSUPP;
4402 ++ }
4403 + obuf[0] = msg[0].addr << 1;
4404 + obuf[1] = msg[0].len;
4405 + obuf[2] = msg[0].buf[0];
4406 +@@ -481,7 +525,13 @@ static int dw3101_i2c_transfer(struct i2c_adapter *adap, struct i2c_msg msg[],
4407 + case 0x60:
4408 + case 0x0c: {
4409 + /* write to register */
4410 +- u8 obuf[msg[0].len + 2];
4411 ++ u8 obuf[MAX_XFER_SIZE];
4412 ++
4413 ++ if (2 + msg[0].len > sizeof(obuf)) {
4414 ++ warn("i2c wr: len=%d is too big!\n",
4415 ++ msg[0].len);
4416 ++ return -EOPNOTSUPP;
4417 ++ }
4418 + obuf[0] = msg[0].addr << 1;
4419 + obuf[1] = msg[0].len;
4420 + memcpy(obuf + 2, msg[0].buf, msg[0].len);
4421 +@@ -563,7 +613,14 @@ static int s6x0_i2c_transfer(struct i2c_adapter *adap, struct i2c_msg msg[],
4422 + default: {
4423 + if (msg[j].flags == I2C_M_RD) {
4424 + /* read registers */
4425 +- u8 ibuf[msg[j].len];
4426 ++ u8 ibuf[MAX_XFER_SIZE];
4427 ++
4428 ++ if (msg[j].len > sizeof(ibuf)) {
4429 ++ warn("i2c rd: len=%d is too big!\n",
4430 ++ msg[j].len);
4431 ++ return -EOPNOTSUPP;
4432 ++ }
4433 ++
4434 + dw210x_op_rw(d->udev, 0x91, 0, 0,
4435 + ibuf, msg[j].len,
4436 + DW210X_READ_MSG);
4437 +@@ -590,7 +647,14 @@ static int s6x0_i2c_transfer(struct i2c_adapter *adap, struct i2c_msg msg[],
4438 + } while (len > 0);
4439 + } else if (j < (num - 1)) {
4440 + /* write register addr before read */
4441 +- u8 obuf[msg[j].len + 2];
4442 ++ u8 obuf[MAX_XFER_SIZE];
4443 ++
4444 ++ if (2 + msg[j].len > sizeof(obuf)) {
4445 ++ warn("i2c wr: len=%d is too big!\n",
4446 ++ msg[j].len);
4447 ++ return -EOPNOTSUPP;
4448 ++ }
4449 ++
4450 + obuf[0] = msg[j + 1].len;
4451 + obuf[1] = (msg[j].addr << 1);
4452 + memcpy(obuf + 2, msg[j].buf, msg[j].len);
4453 +@@ -602,7 +666,13 @@ static int s6x0_i2c_transfer(struct i2c_adapter *adap, struct i2c_msg msg[],
4454 + break;
4455 + } else {
4456 + /* write registers */
4457 +- u8 obuf[msg[j].len + 2];
4458 ++ u8 obuf[MAX_XFER_SIZE];
4459 ++
4460 ++ if (2 + msg[j].len > sizeof(obuf)) {
4461 ++ warn("i2c wr: len=%d is too big!\n",
4462 ++ msg[j].len);
4463 ++ return -EOPNOTSUPP;
4464 ++ }
4465 + obuf[0] = msg[j].len + 1;
4466 + obuf[1] = (msg[j].addr << 1);
4467 + memcpy(obuf + 2, msg[j].buf, msg[j].len);
4468 +diff --git a/drivers/mmc/host/atmel-mci.c b/drivers/mmc/host/atmel-mci.c
4469 +index aca59d93..b5c95043 100644
4470 +--- a/drivers/mmc/host/atmel-mci.c
4471 ++++ b/drivers/mmc/host/atmel-mci.c
4472 +@@ -584,6 +584,13 @@ static void atmci_timeout_timer(unsigned long data)
4473 + if (host->mrq->cmd->data) {
4474 + host->mrq->cmd->data->error = -ETIMEDOUT;
4475 + host->data = NULL;
4476 ++ /*
4477 ++ * With some SDIO modules, sometimes DMA transfer hangs. If
4478 ++ * stop_transfer() is not called then the DMA request is not
4479 ++ * removed, following ones are queued and never computed.
4480 ++ */
4481 ++ if (host->state == STATE_DATA_XFER)
4482 ++ host->stop_transfer(host);
4483 + } else {
4484 + host->mrq->cmd->error = -ETIMEDOUT;
4485 + host->cmd = NULL;
4486 +@@ -1787,12 +1794,14 @@ static void atmci_tasklet_func(unsigned long priv)
4487 + if (unlikely(status)) {
4488 + host->stop_transfer(host);
4489 + host->data = NULL;
4490 +- if (status & ATMCI_DTOE) {
4491 +- data->error = -ETIMEDOUT;
4492 +- } else if (status & ATMCI_DCRCE) {
4493 +- data->error = -EILSEQ;
4494 +- } else {
4495 +- data->error = -EIO;
4496 ++ if (data) {
4497 ++ if (status & ATMCI_DTOE) {
4498 ++ data->error = -ETIMEDOUT;
4499 ++ } else if (status & ATMCI_DCRCE) {
4500 ++ data->error = -EILSEQ;
4501 ++ } else {
4502 ++ data->error = -EIO;
4503 ++ }
4504 + }
4505 + }
4506 +
4507 +diff --git a/drivers/mtd/nand/gpmi-nand/gpmi-nand.c b/drivers/mtd/nand/gpmi-nand/gpmi-nand.c
4508 +index 25ecfa18..ab6581f1 100644
4509 +--- a/drivers/mtd/nand/gpmi-nand/gpmi-nand.c
4510 ++++ b/drivers/mtd/nand/gpmi-nand/gpmi-nand.c
4511 +@@ -264,8 +264,6 @@ static void dma_irq_callback(void *param)
4512 + struct gpmi_nand_data *this = param;
4513 + struct completion *dma_c = &this->dma_done;
4514 +
4515 +- complete(dma_c);
4516 +-
4517 + switch (this->dma_type) {
4518 + case DMA_FOR_COMMAND:
4519 + dma_unmap_sg(this->dev, &this->cmd_sgl, 1, DMA_TO_DEVICE);
4520 +@@ -290,6 +288,8 @@ static void dma_irq_callback(void *param)
4521 + default:
4522 + pr_err("in wrong DMA operation.\n");
4523 + }
4524 ++
4525 ++ complete(dma_c);
4526 + }
4527 +
4528 + int start_dma_without_bch_irq(struct gpmi_nand_data *this,
4529 +diff --git a/drivers/mtd/nand/nand_base.c b/drivers/mtd/nand/nand_base.c
4530 +index fb8c4dea..633db883 100644
4531 +--- a/drivers/mtd/nand/nand_base.c
4532 ++++ b/drivers/mtd/nand/nand_base.c
4533 +@@ -2904,10 +2904,21 @@ static int nand_flash_detect_onfi(struct mtd_info *mtd, struct nand_chip *chip,
4534 + sanitize_string(p->model, sizeof(p->model));
4535 + if (!mtd->name)
4536 + mtd->name = p->model;
4537 ++
4538 + mtd->writesize = le32_to_cpu(p->byte_per_page);
4539 +- mtd->erasesize = le32_to_cpu(p->pages_per_block) * mtd->writesize;
4540 ++
4541 ++ /*
4542 ++ * pages_per_block and blocks_per_lun may not be a power-of-2 size
4543 ++ * (don't ask me who thought of this...). MTD assumes that these
4544 ++ * dimensions will be power-of-2, so just truncate the remaining area.
4545 ++ */
4546 ++ mtd->erasesize = 1 << (fls(le32_to_cpu(p->pages_per_block)) - 1);
4547 ++ mtd->erasesize *= mtd->writesize;
4548 ++
4549 + mtd->oobsize = le16_to_cpu(p->spare_bytes_per_page);
4550 +- chip->chipsize = le32_to_cpu(p->blocks_per_lun);
4551 ++
4552 ++ /* See erasesize comment */
4553 ++ chip->chipsize = 1 << (fls(le32_to_cpu(p->blocks_per_lun)) - 1);
4554 + chip->chipsize *= (uint64_t)mtd->erasesize * p->lun_count;
4555 + *busw = 0;
4556 + if (le16_to_cpu(p->features) & 1)
4557 +diff --git a/drivers/net/can/flexcan.c b/drivers/net/can/flexcan.c
4558 +index a8f33a52..f63169d6 100644
4559 +--- a/drivers/net/can/flexcan.c
4560 ++++ b/drivers/net/can/flexcan.c
4561 +@@ -711,7 +711,6 @@ static int flexcan_chip_start(struct net_device *dev)
4562 + {
4563 + struct flexcan_priv *priv = netdev_priv(dev);
4564 + struct flexcan_regs __iomem *regs = priv->base;
4565 +- unsigned int i;
4566 + int err;
4567 + u32 reg_mcr, reg_ctrl;
4568 +
4569 +@@ -783,17 +782,6 @@ static int flexcan_chip_start(struct net_device *dev)
4570 + netdev_dbg(dev, "%s: writing ctrl=0x%08x", __func__, reg_ctrl);
4571 + flexcan_write(reg_ctrl, &regs->ctrl);
4572 +
4573 +- for (i = 0; i < ARRAY_SIZE(regs->cantxfg); i++) {
4574 +- flexcan_write(0, &regs->cantxfg[i].can_ctrl);
4575 +- flexcan_write(0, &regs->cantxfg[i].can_id);
4576 +- flexcan_write(0, &regs->cantxfg[i].data[0]);
4577 +- flexcan_write(0, &regs->cantxfg[i].data[1]);
4578 +-
4579 +- /* put MB into rx queue */
4580 +- flexcan_write(FLEXCAN_MB_CNT_CODE(0x4),
4581 +- &regs->cantxfg[i].can_ctrl);
4582 +- }
4583 +-
4584 + /* Abort any pending TX, mark Mailbox as INACTIVE */
4585 + flexcan_write(FLEXCAN_MB_CNT_CODE(0x4),
4586 + &regs->cantxfg[FLEXCAN_TX_BUF_ID].can_ctrl);
4587 +diff --git a/drivers/net/wireless/iwlegacy/3945.c b/drivers/net/wireless/iwlegacy/3945.c
4588 +index dc1e6da9..9a5f36e5 100644
4589 +--- a/drivers/net/wireless/iwlegacy/3945.c
4590 ++++ b/drivers/net/wireless/iwlegacy/3945.c
4591 +@@ -462,6 +462,8 @@ il3945_is_network_packet(struct il_priv *il, struct ieee80211_hdr *header)
4592 + }
4593 + }
4594 +
4595 ++#define SMALL_PACKET_SIZE 256
4596 ++
4597 + static void
4598 + il3945_pass_packet_to_mac80211(struct il_priv *il, struct il_rx_buf *rxb,
4599 + struct ieee80211_rx_status *stats)
4600 +@@ -470,14 +472,13 @@ il3945_pass_packet_to_mac80211(struct il_priv *il, struct il_rx_buf *rxb,
4601 + struct ieee80211_hdr *hdr = (struct ieee80211_hdr *)IL_RX_DATA(pkt);
4602 + struct il3945_rx_frame_hdr *rx_hdr = IL_RX_HDR(pkt);
4603 + struct il3945_rx_frame_end *rx_end = IL_RX_END(pkt);
4604 +- u16 len = le16_to_cpu(rx_hdr->len);
4605 ++ u32 len = le16_to_cpu(rx_hdr->len);
4606 + struct sk_buff *skb;
4607 + __le16 fc = hdr->frame_control;
4608 ++ u32 fraglen = PAGE_SIZE << il->hw_params.rx_page_order;
4609 +
4610 + /* We received data from the HW, so stop the watchdog */
4611 +- if (unlikely
4612 +- (len + IL39_RX_FRAME_SIZE >
4613 +- PAGE_SIZE << il->hw_params.rx_page_order)) {
4614 ++ if (unlikely(len + IL39_RX_FRAME_SIZE > fraglen)) {
4615 + D_DROP("Corruption detected!\n");
4616 + return;
4617 + }
4618 +@@ -488,26 +489,32 @@ il3945_pass_packet_to_mac80211(struct il_priv *il, struct il_rx_buf *rxb,
4619 + return;
4620 + }
4621 +
4622 +- skb = dev_alloc_skb(128);
4623 ++ skb = dev_alloc_skb(SMALL_PACKET_SIZE);
4624 + if (!skb) {
4625 + IL_ERR("dev_alloc_skb failed\n");
4626 + return;
4627 + }
4628 +
4629 + if (!il3945_mod_params.sw_crypto)
4630 +- il_set_decrypted_flag(il, (struct ieee80211_hdr *)rxb_addr(rxb),
4631 ++ il_set_decrypted_flag(il, (struct ieee80211_hdr *)pkt,
4632 + le32_to_cpu(rx_end->status), stats);
4633 +
4634 +- skb_add_rx_frag(skb, 0, rxb->page,
4635 +- (void *)rx_hdr->payload - (void *)pkt, len,
4636 +- len);
4637 +-
4638 ++ /* If frame is small enough to fit into skb->head, copy it
4639 ++ * and do not consume a full page
4640 ++ */
4641 ++ if (len <= SMALL_PACKET_SIZE) {
4642 ++ memcpy(skb_put(skb, len), rx_hdr->payload, len);
4643 ++ } else {
4644 ++ skb_add_rx_frag(skb, 0, rxb->page,
4645 ++ (void *)rx_hdr->payload - (void *)pkt, len,
4646 ++ fraglen);
4647 ++ il->alloc_rxb_page--;
4648 ++ rxb->page = NULL;
4649 ++ }
4650 + il_update_stats(il, false, fc, len);
4651 + memcpy(IEEE80211_SKB_RXCB(skb), stats, sizeof(*stats));
4652 +
4653 + ieee80211_rx(il->hw, skb);
4654 +- il->alloc_rxb_page--;
4655 +- rxb->page = NULL;
4656 + }
4657 +
4658 + #define IL_DELAY_NEXT_SCAN_AFTER_ASSOC (HZ*6)
4659 +diff --git a/drivers/net/wireless/iwlegacy/4965-mac.c b/drivers/net/wireless/iwlegacy/4965-mac.c
4660 +index a8eff95e..d2586f09 100644
4661 +--- a/drivers/net/wireless/iwlegacy/4965-mac.c
4662 ++++ b/drivers/net/wireless/iwlegacy/4965-mac.c
4663 +@@ -574,9 +574,11 @@ il4965_translate_rx_status(struct il_priv *il, u32 decrypt_in)
4664 + return decrypt_out;
4665 + }
4666 +
4667 ++#define SMALL_PACKET_SIZE 256
4668 ++
4669 + static void
4670 + il4965_pass_packet_to_mac80211(struct il_priv *il, struct ieee80211_hdr *hdr,
4671 +- u16 len, u32 ampdu_status, struct il_rx_buf *rxb,
4672 ++ u32 len, u32 ampdu_status, struct il_rx_buf *rxb,
4673 + struct ieee80211_rx_status *stats)
4674 + {
4675 + struct sk_buff *skb;
4676 +@@ -593,21 +595,25 @@ il4965_pass_packet_to_mac80211(struct il_priv *il, struct ieee80211_hdr *hdr,
4677 + il_set_decrypted_flag(il, hdr, ampdu_status, stats))
4678 + return;
4679 +
4680 +- skb = dev_alloc_skb(128);
4681 ++ skb = dev_alloc_skb(SMALL_PACKET_SIZE);
4682 + if (!skb) {
4683 + IL_ERR("dev_alloc_skb failed\n");
4684 + return;
4685 + }
4686 +
4687 +- skb_add_rx_frag(skb, 0, rxb->page, (void *)hdr - rxb_addr(rxb), len,
4688 +- len);
4689 ++ if (len <= SMALL_PACKET_SIZE) {
4690 ++ memcpy(skb_put(skb, len), hdr, len);
4691 ++ } else {
4692 ++ skb_add_rx_frag(skb, 0, rxb->page, (void *)hdr - rxb_addr(rxb),
4693 ++ len, PAGE_SIZE << il->hw_params.rx_page_order);
4694 ++ il->alloc_rxb_page--;
4695 ++ rxb->page = NULL;
4696 ++ }
4697 +
4698 + il_update_stats(il, false, fc, len);
4699 + memcpy(IEEE80211_SKB_RXCB(skb), stats, sizeof(*stats));
4700 +
4701 + ieee80211_rx(il->hw, skb);
4702 +- il->alloc_rxb_page--;
4703 +- rxb->page = NULL;
4704 + }
4705 +
4706 + /* Called for N_RX (legacy ABG frames), or
4707 +diff --git a/drivers/net/wireless/iwlwifi/iwl-trans.h b/drivers/net/wireless/iwlwifi/iwl-trans.h
4708 +index 7a13790b..72d2ecce 100644
4709 +--- a/drivers/net/wireless/iwlwifi/iwl-trans.h
4710 ++++ b/drivers/net/wireless/iwlwifi/iwl-trans.h
4711 +@@ -605,8 +605,10 @@ static inline int iwl_trans_send_cmd(struct iwl_trans *trans,
4712 + {
4713 + int ret;
4714 +
4715 +- WARN_ONCE(trans->state != IWL_TRANS_FW_ALIVE,
4716 +- "%s bad state = %d", __func__, trans->state);
4717 ++ if (trans->state != IWL_TRANS_FW_ALIVE) {
4718 ++ IWL_ERR(trans, "%s bad state = %d", __func__, trans->state);
4719 ++ return -EIO;
4720 ++ }
4721 +
4722 + if (!(cmd->flags & CMD_ASYNC))
4723 + lock_map_acquire_read(&trans->sync_cmd_lockdep_map);
4724 +diff --git a/drivers/net/wireless/mwifiex/sdio.c b/drivers/net/wireless/mwifiex/sdio.c
4725 +index 139c9581..047a6f34 100644
4726 +--- a/drivers/net/wireless/mwifiex/sdio.c
4727 ++++ b/drivers/net/wireless/mwifiex/sdio.c
4728 +@@ -930,7 +930,10 @@ static int mwifiex_decode_rx_packet(struct mwifiex_adapter *adapter,
4729 + struct sk_buff *skb, u32 upld_typ)
4730 + {
4731 + u8 *cmd_buf;
4732 ++ __le16 *curr_ptr = (__le16 *)skb->data;
4733 ++ u16 pkt_len = le16_to_cpu(*curr_ptr);
4734 +
4735 ++ skb_trim(skb, pkt_len);
4736 + skb_pull(skb, INTF_HEADER_LEN);
4737 +
4738 + switch (upld_typ) {
4739 +diff --git a/drivers/net/wireless/mwifiex/uap_txrx.c b/drivers/net/wireless/mwifiex/uap_txrx.c
4740 +index a018e42d..48e67247 100644
4741 +--- a/drivers/net/wireless/mwifiex/uap_txrx.c
4742 ++++ b/drivers/net/wireless/mwifiex/uap_txrx.c
4743 +@@ -34,6 +34,7 @@ static void mwifiex_uap_queue_bridged_pkt(struct mwifiex_private *priv,
4744 + struct mwifiex_txinfo *tx_info;
4745 + int hdr_chop;
4746 + struct timeval tv;
4747 ++ struct ethhdr *p_ethhdr;
4748 + u8 rfc1042_eth_hdr[ETH_ALEN] = { 0xaa, 0xaa, 0x03, 0x00, 0x00, 0x00 };
4749 +
4750 + uap_rx_pd = (struct uap_rxpd *)(skb->data);
4751 +@@ -48,14 +49,36 @@ static void mwifiex_uap_queue_bridged_pkt(struct mwifiex_private *priv,
4752 + }
4753 +
4754 + if (!memcmp(&rx_pkt_hdr->rfc1042_hdr,
4755 +- rfc1042_eth_hdr, sizeof(rfc1042_eth_hdr)))
4756 ++ rfc1042_eth_hdr, sizeof(rfc1042_eth_hdr))) {
4757 ++ /* Replace the 803 header and rfc1042 header (llc/snap) with
4758 ++ * an Ethernet II header, keep the src/dst and snap_type
4759 ++ * (ethertype).
4760 ++ *
4761 ++ * The firmware only passes up SNAP frames converting all RX
4762 ++ * data from 802.11 to 802.2/LLC/SNAP frames.
4763 ++ *
4764 ++ * To create the Ethernet II, just move the src, dst address
4765 ++ * right before the snap_type.
4766 ++ */
4767 ++ p_ethhdr = (struct ethhdr *)
4768 ++ ((u8 *)(&rx_pkt_hdr->eth803_hdr)
4769 ++ + sizeof(rx_pkt_hdr->eth803_hdr)
4770 ++ + sizeof(rx_pkt_hdr->rfc1042_hdr)
4771 ++ - sizeof(rx_pkt_hdr->eth803_hdr.h_dest)
4772 ++ - sizeof(rx_pkt_hdr->eth803_hdr.h_source)
4773 ++ - sizeof(rx_pkt_hdr->rfc1042_hdr.snap_type));
4774 ++ memcpy(p_ethhdr->h_source, rx_pkt_hdr->eth803_hdr.h_source,
4775 ++ sizeof(p_ethhdr->h_source));
4776 ++ memcpy(p_ethhdr->h_dest, rx_pkt_hdr->eth803_hdr.h_dest,
4777 ++ sizeof(p_ethhdr->h_dest));
4778 + /* Chop off the rxpd + the excess memory from
4779 + * 802.2/llc/snap header that was removed.
4780 + */
4781 +- hdr_chop = (u8 *)eth_hdr - (u8 *)uap_rx_pd;
4782 +- else
4783 ++ hdr_chop = (u8 *)p_ethhdr - (u8 *)uap_rx_pd;
4784 ++ } else {
4785 + /* Chop off the rxpd */
4786 + hdr_chop = (u8 *)&rx_pkt_hdr->eth803_hdr - (u8 *)uap_rx_pd;
4787 ++ }
4788 +
4789 + /* Chop off the leading header bytes so the it points
4790 + * to the start of either the reconstructed EthII frame
4791 +diff --git a/drivers/net/wireless/prism54/islpci_dev.c b/drivers/net/wireless/prism54/islpci_dev.c
4792 +index 5970ff6f..d498b02f 100644
4793 +--- a/drivers/net/wireless/prism54/islpci_dev.c
4794 ++++ b/drivers/net/wireless/prism54/islpci_dev.c
4795 +@@ -811,6 +811,10 @@ static const struct net_device_ops islpci_netdev_ops = {
4796 + .ndo_validate_addr = eth_validate_addr,
4797 + };
4798 +
4799 ++static struct device_type wlan_type = {
4800 ++ .name = "wlan",
4801 ++};
4802 ++
4803 + struct net_device *
4804 + islpci_setup(struct pci_dev *pdev)
4805 + {
4806 +@@ -821,9 +825,8 @@ islpci_setup(struct pci_dev *pdev)
4807 + return ndev;
4808 +
4809 + pci_set_drvdata(pdev, ndev);
4810 +-#if defined(SET_NETDEV_DEV)
4811 + SET_NETDEV_DEV(ndev, &pdev->dev);
4812 +-#endif
4813 ++ SET_NETDEV_DEVTYPE(ndev, &wlan_type);
4814 +
4815 + /* setup the structure members */
4816 + ndev->base_addr = pci_resource_start(pdev, 0);
4817 +diff --git a/drivers/net/wireless/rt2x00/rt2400pci.c b/drivers/net/wireless/rt2x00/rt2400pci.c
4818 +index f7143733..a3a2dcd2 100644
4819 +--- a/drivers/net/wireless/rt2x00/rt2400pci.c
4820 ++++ b/drivers/net/wireless/rt2x00/rt2400pci.c
4821 +@@ -1261,7 +1261,7 @@ static void rt2400pci_fill_rxdone(struct queue_entry *entry,
4822 + */
4823 + rxdesc->timestamp = ((u64)rx_high << 32) | rx_low;
4824 + rxdesc->signal = rt2x00_get_field32(word2, RXD_W2_SIGNAL) & ~0x08;
4825 +- rxdesc->rssi = rt2x00_get_field32(word2, RXD_W3_RSSI) -
4826 ++ rxdesc->rssi = rt2x00_get_field32(word3, RXD_W3_RSSI) -
4827 + entry->queue->rt2x00dev->rssi_offset;
4828 + rxdesc->size = rt2x00_get_field32(word0, RXD_W0_DATABYTE_COUNT);
4829 +
4830 +diff --git a/drivers/net/wireless/rtlwifi/base.c b/drivers/net/wireless/rtlwifi/base.c
4831 +index af59dd57..3698028c 100644
4832 +--- a/drivers/net/wireless/rtlwifi/base.c
4833 ++++ b/drivers/net/wireless/rtlwifi/base.c
4834 +@@ -37,6 +37,7 @@
4835 +
4836 + #include <linux/ip.h>
4837 + #include <linux/module.h>
4838 ++#include <linux/udp.h>
4839 +
4840 + /*
4841 + *NOTICE!!!: This file will be very big, we should
4842 +@@ -1066,64 +1067,52 @@ u8 rtl_is_special_data(struct ieee80211_hw *hw, struct sk_buff *skb, u8 is_tx)
4843 + if (!ieee80211_is_data(fc))
4844 + return false;
4845 +
4846 ++ ip = (const struct iphdr *)(skb->data + mac_hdr_len +
4847 ++ SNAP_SIZE + PROTOC_TYPE_SIZE);
4848 ++ ether_type = be16_to_cpup((__be16 *)
4849 ++ (skb->data + mac_hdr_len + SNAP_SIZE));
4850 +
4851 +- ip = (struct iphdr *)((u8 *) skb->data + mac_hdr_len +
4852 +- SNAP_SIZE + PROTOC_TYPE_SIZE);
4853 +- ether_type = *(u16 *) ((u8 *) skb->data + mac_hdr_len + SNAP_SIZE);
4854 +- /* ether_type = ntohs(ether_type); */
4855 +-
4856 +- if (ETH_P_IP == ether_type) {
4857 +- if (IPPROTO_UDP == ip->protocol) {
4858 +- struct udphdr *udp = (struct udphdr *)((u8 *) ip +
4859 +- (ip->ihl << 2));
4860 +- if (((((u8 *) udp)[1] == 68) &&
4861 +- (((u8 *) udp)[3] == 67)) ||
4862 +- ((((u8 *) udp)[1] == 67) &&
4863 +- (((u8 *) udp)[3] == 68))) {
4864 +- /*
4865 +- * 68 : UDP BOOTP client
4866 +- * 67 : UDP BOOTP server
4867 +- */
4868 +- RT_TRACE(rtlpriv, (COMP_SEND | COMP_RECV),
4869 +- DBG_DMESG, "dhcp %s !!\n",
4870 +- is_tx ? "Tx" : "Rx");
4871 +-
4872 +- if (is_tx) {
4873 +- rtlpriv->enter_ps = false;
4874 +- schedule_work(&rtlpriv->
4875 +- works.lps_change_work);
4876 +- ppsc->last_delaylps_stamp_jiffies =
4877 +- jiffies;
4878 +- }
4879 ++ switch (ether_type) {
4880 ++ case ETH_P_IP: {
4881 ++ struct udphdr *udp;
4882 ++ u16 src;
4883 ++ u16 dst;
4884 +
4885 +- return true;
4886 +- }
4887 +- }
4888 +- } else if (ETH_P_ARP == ether_type) {
4889 +- if (is_tx) {
4890 +- rtlpriv->enter_ps = false;
4891 +- schedule_work(&rtlpriv->works.lps_change_work);
4892 +- ppsc->last_delaylps_stamp_jiffies = jiffies;
4893 +- }
4894 ++ if (ip->protocol != IPPROTO_UDP)
4895 ++ return false;
4896 ++ udp = (struct udphdr *)((u8 *)ip + (ip->ihl << 2));
4897 ++ src = be16_to_cpu(udp->source);
4898 ++ dst = be16_to_cpu(udp->dest);
4899 +
4900 +- return true;
4901 +- } else if (ETH_P_PAE == ether_type) {
4902 ++ /* If this case involves port 68 (UDP BOOTP client) connecting
4903 ++ * with port 67 (UDP BOOTP server), then return true so that
4904 ++ * the lowest speed is used.
4905 ++ */
4906 ++ if (!((src == 68 && dst == 67) || (src == 67 && dst == 68)))
4907 ++ return false;
4908 ++
4909 ++ RT_TRACE(rtlpriv, (COMP_SEND | COMP_RECV), DBG_DMESG,
4910 ++ "dhcp %s !!\n", is_tx ? "Tx" : "Rx");
4911 ++ break;
4912 ++ }
4913 ++ case ETH_P_ARP:
4914 ++ break;
4915 ++ case ETH_P_PAE:
4916 + RT_TRACE(rtlpriv, (COMP_SEND | COMP_RECV), DBG_DMESG,
4917 + "802.1X %s EAPOL pkt!!\n", is_tx ? "Tx" : "Rx");
4918 +-
4919 +- if (is_tx) {
4920 +- rtlpriv->enter_ps = false;
4921 +- schedule_work(&rtlpriv->works.lps_change_work);
4922 +- ppsc->last_delaylps_stamp_jiffies = jiffies;
4923 +- }
4924 +-
4925 +- return true;
4926 +- } else if (ETH_P_IPV6 == ether_type) {
4927 +- /* IPv6 */
4928 +- return true;
4929 ++ break;
4930 ++ case ETH_P_IPV6:
4931 ++ /* TODO: Is this right? */
4932 ++ return false;
4933 ++ default:
4934 ++ return false;
4935 + }
4936 +-
4937 +- return false;
4938 ++ if (is_tx) {
4939 ++ rtlpriv->enter_ps = false;
4940 ++ schedule_work(&rtlpriv->works.lps_change_work);
4941 ++ ppsc->last_delaylps_stamp_jiffies = jiffies;
4942 ++ }
4943 ++ return true;
4944 + }
4945 +
4946 + /*********************************************************
4947 +diff --git a/drivers/net/wireless/rtlwifi/rtl8188ee/hw.c b/drivers/net/wireless/rtlwifi/rtl8188ee/hw.c
4948 +index b68cae30..e06971be 100644
4949 +--- a/drivers/net/wireless/rtlwifi/rtl8188ee/hw.c
4950 ++++ b/drivers/net/wireless/rtlwifi/rtl8188ee/hw.c
4951 +@@ -143,6 +143,7 @@ static void _rtl88ee_set_fw_clock_on(struct ieee80211_hw *hw,
4952 + } else {
4953 + rtlhal->fw_clk_change_in_progress = false;
4954 + spin_unlock_bh(&rtlpriv->locks.fw_ps_lock);
4955 ++ break;
4956 + }
4957 + }
4958 +
4959 +diff --git a/drivers/net/wireless/rtlwifi/rtl8192cu/mac.c b/drivers/net/wireless/rtlwifi/rtl8192cu/mac.c
4960 +index da4f5871..2c68c138 100644
4961 +--- a/drivers/net/wireless/rtlwifi/rtl8192cu/mac.c
4962 ++++ b/drivers/net/wireless/rtlwifi/rtl8192cu/mac.c
4963 +@@ -778,7 +778,7 @@ static long _rtl92c_signal_scale_mapping(struct ieee80211_hw *hw,
4964 +
4965 + static void _rtl92c_query_rxphystatus(struct ieee80211_hw *hw,
4966 + struct rtl_stats *pstats,
4967 +- struct rx_desc_92c *pdesc,
4968 ++ struct rx_desc_92c *p_desc,
4969 + struct rx_fwinfo_92c *p_drvinfo,
4970 + bool packet_match_bssid,
4971 + bool packet_toself,
4972 +@@ -793,11 +793,11 @@ static void _rtl92c_query_rxphystatus(struct ieee80211_hw *hw,
4973 + u32 rssi, total_rssi = 0;
4974 + bool in_powersavemode = false;
4975 + bool is_cck_rate;
4976 ++ u8 *pdesc = (u8 *)p_desc;
4977 +
4978 +- is_cck_rate = RX_HAL_IS_CCK_RATE(pdesc);
4979 ++ is_cck_rate = RX_HAL_IS_CCK_RATE(p_desc);
4980 + pstats->packet_matchbssid = packet_match_bssid;
4981 + pstats->packet_toself = packet_toself;
4982 +- pstats->is_cck = is_cck_rate;
4983 + pstats->packet_beacon = packet_beacon;
4984 + pstats->is_cck = is_cck_rate;
4985 + pstats->RX_SIGQ[0] = -1;
4986 +diff --git a/drivers/net/wireless/rtlwifi/rtl8192cu/trx.c b/drivers/net/wireless/rtlwifi/rtl8192cu/trx.c
4987 +index 5a060e53..5c52a8ac 100644
4988 +--- a/drivers/net/wireless/rtlwifi/rtl8192cu/trx.c
4989 ++++ b/drivers/net/wireless/rtlwifi/rtl8192cu/trx.c
4990 +@@ -303,10 +303,10 @@ out:
4991 + bool rtl92cu_rx_query_desc(struct ieee80211_hw *hw,
4992 + struct rtl_stats *stats,
4993 + struct ieee80211_rx_status *rx_status,
4994 +- u8 *p_desc, struct sk_buff *skb)
4995 ++ u8 *pdesc, struct sk_buff *skb)
4996 + {
4997 + struct rx_fwinfo_92c *p_drvinfo;
4998 +- struct rx_desc_92c *pdesc = (struct rx_desc_92c *)p_desc;
4999 ++ struct rx_desc_92c *p_desc = (struct rx_desc_92c *)pdesc;
5000 + u32 phystatus = GET_RX_DESC_PHY_STATUS(pdesc);
5001 +
5002 + stats->length = (u16) GET_RX_DESC_PKT_LEN(pdesc);
5003 +@@ -345,11 +345,11 @@ bool rtl92cu_rx_query_desc(struct ieee80211_hw *hw,
5004 + if (phystatus) {
5005 + p_drvinfo = (struct rx_fwinfo_92c *)(skb->data +
5006 + stats->rx_bufshift);
5007 +- rtl92c_translate_rx_signal_stuff(hw, skb, stats, pdesc,
5008 ++ rtl92c_translate_rx_signal_stuff(hw, skb, stats, p_desc,
5009 + p_drvinfo);
5010 + }
5011 + /*rx_status->qual = stats->signal; */
5012 +- rx_status->signal = stats->rssi + 10;
5013 ++ rx_status->signal = stats->recvsignalpower + 10;
5014 + /*rx_status->noise = -stats->noise; */
5015 + return true;
5016 + }
5017 +diff --git a/drivers/net/wireless/rtlwifi/rtl8192de/trx.c b/drivers/net/wireless/rtlwifi/rtl8192de/trx.c
5018 +index b8ec718a..542394c8 100644
5019 +--- a/drivers/net/wireless/rtlwifi/rtl8192de/trx.c
5020 ++++ b/drivers/net/wireless/rtlwifi/rtl8192de/trx.c
5021 +@@ -525,7 +525,7 @@ bool rtl92de_rx_query_desc(struct ieee80211_hw *hw, struct rtl_stats *stats,
5022 + p_drvinfo);
5023 + }
5024 + /*rx_status->qual = stats->signal; */
5025 +- rx_status->signal = stats->rssi + 10;
5026 ++ rx_status->signal = stats->recvsignalpower + 10;
5027 + /*rx_status->noise = -stats->noise; */
5028 + return true;
5029 + }
5030 +diff --git a/drivers/net/wireless/rtlwifi/rtl8192se/rf.c b/drivers/net/wireless/rtlwifi/rtl8192se/rf.c
5031 +index 5061f1db..92d38ab3 100644
5032 +--- a/drivers/net/wireless/rtlwifi/rtl8192se/rf.c
5033 ++++ b/drivers/net/wireless/rtlwifi/rtl8192se/rf.c
5034 +@@ -265,7 +265,7 @@ static void _rtl92s_get_txpower_writeval_byregulatory(struct ieee80211_hw *hw,
5035 + rtlefuse->pwrgroup_ht40
5036 + [RF90_PATH_A][chnl - 1]) {
5037 + pwrdiff_limit[i] =
5038 +- rtlefuse->pwrgroup_ht20
5039 ++ rtlefuse->pwrgroup_ht40
5040 + [RF90_PATH_A][chnl - 1];
5041 + }
5042 + } else {
5043 +diff --git a/drivers/net/wireless/rtlwifi/rtl8192se/trx.c b/drivers/net/wireless/rtlwifi/rtl8192se/trx.c
5044 +index c7095118..7d0f2e20 100644
5045 +--- a/drivers/net/wireless/rtlwifi/rtl8192se/trx.c
5046 ++++ b/drivers/net/wireless/rtlwifi/rtl8192se/trx.c
5047 +@@ -329,7 +329,7 @@ bool rtl92se_rx_query_desc(struct ieee80211_hw *hw, struct rtl_stats *stats,
5048 + }
5049 +
5050 + /*rx_status->qual = stats->signal; */
5051 +- rx_status->signal = stats->rssi + 10;
5052 ++ rx_status->signal = stats->recvsignalpower + 10;
5053 + /*rx_status->noise = -stats->noise; */
5054 +
5055 + return true;
5056 +diff --git a/drivers/net/wireless/rtlwifi/wifi.h b/drivers/net/wireless/rtlwifi/wifi.h
5057 +index 70325874..ad9c37a4 100644
5058 +--- a/drivers/net/wireless/rtlwifi/wifi.h
5059 ++++ b/drivers/net/wireless/rtlwifi/wifi.h
5060 +@@ -77,11 +77,7 @@
5061 + #define RTL_SLOT_TIME_9 9
5062 + #define RTL_SLOT_TIME_20 20
5063 +
5064 +-/*related with tcp/ip. */
5065 +-/*if_ehther.h*/
5066 +-#define ETH_P_PAE 0x888E /*Port Access Entity (IEEE 802.1X) */
5067 +-#define ETH_P_IP 0x0800 /*Internet Protocol packet */
5068 +-#define ETH_P_ARP 0x0806 /*Address Resolution packet */
5069 ++/*related to tcp/ip. */
5070 + #define SNAP_SIZE 6
5071 + #define PROTOC_TYPE_SIZE 2
5072 +
5073 +diff --git a/drivers/net/xen-netback/interface.c b/drivers/net/xen-netback/interface.c
5074 +index c4a2eb2c..540a7965 100644
5075 +--- a/drivers/net/xen-netback/interface.c
5076 ++++ b/drivers/net/xen-netback/interface.c
5077 +@@ -365,17 +365,19 @@ void xenvif_disconnect(struct xenvif *vif)
5078 + if (netif_carrier_ok(vif->dev))
5079 + xenvif_carrier_off(vif);
5080 +
5081 +- atomic_dec(&vif->refcnt);
5082 +- wait_event(vif->waiting_to_free, atomic_read(&vif->refcnt) == 0);
5083 +-
5084 +- if (vif->irq)
5085 ++ if (vif->irq) {
5086 + unbind_from_irqhandler(vif->irq, vif);
5087 ++ vif->irq = 0;
5088 ++ }
5089 +
5090 + xen_netbk_unmap_frontend_rings(vif);
5091 + }
5092 +
5093 + void xenvif_free(struct xenvif *vif)
5094 + {
5095 ++ atomic_dec(&vif->refcnt);
5096 ++ wait_event(vif->waiting_to_free, atomic_read(&vif->refcnt) == 0);
5097 ++
5098 + unregister_netdev(vif->dev);
5099 +
5100 + free_netdev(vif->dev);
5101 +diff --git a/drivers/pci/pcie/portdrv_pci.c b/drivers/pci/pcie/portdrv_pci.c
5102 +index 696caed5..ce8acc71 100644
5103 +--- a/drivers/pci/pcie/portdrv_pci.c
5104 ++++ b/drivers/pci/pcie/portdrv_pci.c
5105 +@@ -223,7 +223,6 @@ static int pcie_portdrv_probe(struct pci_dev *dev,
5106 + static void pcie_portdrv_remove(struct pci_dev *dev)
5107 + {
5108 + pcie_port_device_remove(dev);
5109 +- pci_disable_device(dev);
5110 + }
5111 +
5112 + static int error_detected_iter(struct device *device, void *data)
5113 +diff --git a/drivers/pinctrl/mvebu/pinctrl-dove.c b/drivers/pinctrl/mvebu/pinctrl-dove.c
5114 +index 428ea96a..e29e6d83 100644
5115 +--- a/drivers/pinctrl/mvebu/pinctrl-dove.c
5116 ++++ b/drivers/pinctrl/mvebu/pinctrl-dove.c
5117 +@@ -323,7 +323,7 @@ static int dove_twsi_ctrl_set(struct mvebu_mpp_ctrl *ctrl,
5118 + unsigned long gcfg2 = readl(DOVE_GLOBAL_CONFIG_2);
5119 +
5120 + gcfg1 &= ~DOVE_TWSI_ENABLE_OPTION1;
5121 +- gcfg2 &= ~(DOVE_TWSI_ENABLE_OPTION2 | DOVE_TWSI_ENABLE_OPTION2);
5122 ++ gcfg2 &= ~(DOVE_TWSI_ENABLE_OPTION2 | DOVE_TWSI_ENABLE_OPTION3);
5123 +
5124 + switch (config) {
5125 + case 1:
5126 +diff --git a/drivers/s390/net/qeth_core_main.c b/drivers/s390/net/qeth_core_main.c
5127 +index 6cd0fc1b..e06cb8f8 100644
5128 +--- a/drivers/s390/net/qeth_core_main.c
5129 ++++ b/drivers/s390/net/qeth_core_main.c
5130 +@@ -4448,7 +4448,7 @@ int qeth_snmp_command(struct qeth_card *card, char __user *udata)
5131 + struct qeth_cmd_buffer *iob;
5132 + struct qeth_ipa_cmd *cmd;
5133 + struct qeth_snmp_ureq *ureq;
5134 +- int req_len;
5135 ++ unsigned int req_len;
5136 + struct qeth_arp_query_info qinfo = {0, };
5137 + int rc = 0;
5138 +
5139 +@@ -4464,6 +4464,10 @@ int qeth_snmp_command(struct qeth_card *card, char __user *udata)
5140 + /* skip 4 bytes (data_len struct member) to get req_len */
5141 + if (copy_from_user(&req_len, udata + sizeof(int), sizeof(int)))
5142 + return -EFAULT;
5143 ++ if (req_len > (QETH_BUFSIZE - IPA_PDU_HEADER_SIZE -
5144 ++ sizeof(struct qeth_ipacmd_hdr) -
5145 ++ sizeof(struct qeth_ipacmd_setadpparms_hdr)))
5146 ++ return -EINVAL;
5147 + ureq = memdup_user(udata, req_len + sizeof(struct qeth_snmp_ureq_hdr));
5148 + if (IS_ERR(ureq)) {
5149 + QETH_CARD_TEXT(card, 2, "snmpnome");
5150 +diff --git a/drivers/staging/media/lirc/lirc_zilog.c b/drivers/staging/media/lirc/lirc_zilog.c
5151 +index 11d5338b..0feeaadf 100644
5152 +--- a/drivers/staging/media/lirc/lirc_zilog.c
5153 ++++ b/drivers/staging/media/lirc/lirc_zilog.c
5154 +@@ -61,6 +61,9 @@
5155 + #include <media/lirc_dev.h>
5156 + #include <media/lirc.h>
5157 +
5158 ++/* Max transfer size done by I2C transfer functions */
5159 ++#define MAX_XFER_SIZE 64
5160 ++
5161 + struct IR;
5162 +
5163 + struct IR_rx {
5164 +@@ -941,7 +944,14 @@ static ssize_t read(struct file *filep, char *outbuf, size_t n, loff_t *ppos)
5165 + schedule();
5166 + set_current_state(TASK_INTERRUPTIBLE);
5167 + } else {
5168 +- unsigned char buf[rbuf->chunk_size];
5169 ++ unsigned char buf[MAX_XFER_SIZE];
5170 ++
5171 ++ if (rbuf->chunk_size > sizeof(buf)) {
5172 ++ zilog_error("chunk_size is too big (%d)!\n",
5173 ++ rbuf->chunk_size);
5174 ++ ret = -EINVAL;
5175 ++ break;
5176 ++ }
5177 + m = lirc_buffer_read(rbuf, buf);
5178 + if (m == rbuf->chunk_size) {
5179 + ret = copy_to_user((void *)outbuf+written, buf,
5180 +diff --git a/drivers/staging/tidspbridge/Kconfig b/drivers/staging/tidspbridge/Kconfig
5181 +index 60848f19..f7deabcf 100644
5182 +--- a/drivers/staging/tidspbridge/Kconfig
5183 ++++ b/drivers/staging/tidspbridge/Kconfig
5184 +@@ -4,7 +4,7 @@
5185 +
5186 + menuconfig TIDSPBRIDGE
5187 + tristate "DSP Bridge driver"
5188 +- depends on ARCH_OMAP3 && !ARCH_MULTIPLATFORM
5189 ++ depends on ARCH_OMAP3 && !ARCH_MULTIPLATFORM && BROKEN
5190 + select OMAP_MBOX_FWK
5191 + help
5192 + DSP/BIOS Bridge is designed for platforms that contain a GPP and
5193 +diff --git a/drivers/staging/vt6656/baseband.c b/drivers/staging/vt6656/baseband.c
5194 +index 33fa7675..3ff1126c 100644
5195 +--- a/drivers/staging/vt6656/baseband.c
5196 ++++ b/drivers/staging/vt6656/baseband.c
5197 +@@ -941,6 +941,7 @@ int BBbVT3184Init(struct vnt_private *pDevice)
5198 + u8 * pbyAgc;
5199 + u16 wLengthAgc;
5200 + u8 abyArray[256];
5201 ++ u8 data;
5202 +
5203 + ntStatus = CONTROLnsRequestIn(pDevice,
5204 + MESSAGE_TYPE_READ,
5205 +@@ -1106,6 +1107,16 @@ else {
5206 + ControlvWriteByte(pDevice,MESSAGE_REQUEST_BBREG,0x0D,0x01);
5207 +
5208 + RFbRFTableDownload(pDevice);
5209 ++
5210 ++ /* Fix for TX USB resets from vendors driver */
5211 ++ CONTROLnsRequestIn(pDevice, MESSAGE_TYPE_READ, USB_REG4,
5212 ++ MESSAGE_REQUEST_MEM, sizeof(data), &data);
5213 ++
5214 ++ data |= 0x2;
5215 ++
5216 ++ CONTROLnsRequestOut(pDevice, MESSAGE_TYPE_WRITE, USB_REG4,
5217 ++ MESSAGE_REQUEST_MEM, sizeof(data), &data);
5218 ++
5219 + return true;//ntStatus;
5220 + }
5221 +
5222 +diff --git a/drivers/staging/vt6656/rndis.h b/drivers/staging/vt6656/rndis.h
5223 +index 5e073062..5cf5e732 100644
5224 +--- a/drivers/staging/vt6656/rndis.h
5225 ++++ b/drivers/staging/vt6656/rndis.h
5226 +@@ -66,6 +66,8 @@
5227 +
5228 + #define VIAUSB20_PACKET_HEADER 0x04
5229 +
5230 ++#define USB_REG4 0x604
5231 ++
5232 + typedef struct _CMD_MESSAGE
5233 + {
5234 + u8 byData[256];
5235 +diff --git a/drivers/staging/zsmalloc/zsmalloc-main.c b/drivers/staging/zsmalloc/zsmalloc-main.c
5236 +index f82f7e69..288f5825 100644
5237 +--- a/drivers/staging/zsmalloc/zsmalloc-main.c
5238 ++++ b/drivers/staging/zsmalloc/zsmalloc-main.c
5239 +@@ -430,7 +430,12 @@ static struct page *get_next_page(struct page *page)
5240 + return next;
5241 + }
5242 +
5243 +-/* Encode <page, obj_idx> as a single handle value */
5244 ++/*
5245 ++ * Encode <page, obj_idx> as a single handle value.
5246 ++ * On hardware platforms with physical memory starting at 0x0 the pfn
5247 ++ * could be 0 so we ensure that the handle will never be 0 by adjusting the
5248 ++ * encoded obj_idx value before encoding.
5249 ++ */
5250 + static void *obj_location_to_handle(struct page *page, unsigned long obj_idx)
5251 + {
5252 + unsigned long handle;
5253 +@@ -441,17 +446,21 @@ static void *obj_location_to_handle(struct page *page, unsigned long obj_idx)
5254 + }
5255 +
5256 + handle = page_to_pfn(page) << OBJ_INDEX_BITS;
5257 +- handle |= (obj_idx & OBJ_INDEX_MASK);
5258 ++ handle |= ((obj_idx + 1) & OBJ_INDEX_MASK);
5259 +
5260 + return (void *)handle;
5261 + }
5262 +
5263 +-/* Decode <page, obj_idx> pair from the given object handle */
5264 ++/*
5265 ++ * Decode <page, obj_idx> pair from the given object handle. We adjust the
5266 ++ * decoded obj_idx back to its original value since it was adjusted in
5267 ++ * obj_location_to_handle().
5268 ++ */
5269 + static void obj_handle_to_location(unsigned long handle, struct page **page,
5270 + unsigned long *obj_idx)
5271 + {
5272 + *page = pfn_to_page(handle >> OBJ_INDEX_BITS);
5273 +- *obj_idx = handle & OBJ_INDEX_MASK;
5274 ++ *obj_idx = (handle & OBJ_INDEX_MASK) - 1;
5275 + }
5276 +
5277 + static unsigned long obj_idx_to_offset(struct page *page,
5278 +diff --git a/drivers/target/iscsi/iscsi_target_auth.c b/drivers/target/iscsi/iscsi_target_auth.c
5279 +index cee17543..130a1e4f 100644
5280 +--- a/drivers/target/iscsi/iscsi_target_auth.c
5281 ++++ b/drivers/target/iscsi/iscsi_target_auth.c
5282 +@@ -148,6 +148,7 @@ static int chap_server_compute_md5(
5283 + unsigned char client_digest[MD5_SIGNATURE_SIZE];
5284 + unsigned char server_digest[MD5_SIGNATURE_SIZE];
5285 + unsigned char chap_n[MAX_CHAP_N_SIZE], chap_r[MAX_RESPONSE_LENGTH];
5286 ++ size_t compare_len;
5287 + struct iscsi_chap *chap = conn->auth_protocol;
5288 + struct crypto_hash *tfm;
5289 + struct hash_desc desc;
5290 +@@ -186,7 +187,9 @@ static int chap_server_compute_md5(
5291 + goto out;
5292 + }
5293 +
5294 +- if (memcmp(chap_n, auth->userid, strlen(auth->userid)) != 0) {
5295 ++ /* Include the terminating NULL in the compare */
5296 ++ compare_len = strlen(auth->userid) + 1;
5297 ++ if (strncmp(chap_n, auth->userid, compare_len) != 0) {
5298 + pr_err("CHAP_N values do not match!\n");
5299 + goto out;
5300 + }
5301 +diff --git a/drivers/target/iscsi/iscsi_target_configfs.c b/drivers/target/iscsi/iscsi_target_configfs.c
5302 +index 421344da..c45b3365 100644
5303 +--- a/drivers/target/iscsi/iscsi_target_configfs.c
5304 ++++ b/drivers/target/iscsi/iscsi_target_configfs.c
5305 +@@ -1650,6 +1650,11 @@ static int lio_queue_status(struct se_cmd *se_cmd)
5306 + struct iscsi_cmd *cmd = container_of(se_cmd, struct iscsi_cmd, se_cmd);
5307 +
5308 + cmd->i_state = ISTATE_SEND_STATUS;
5309 ++
5310 ++ if (cmd->se_cmd.scsi_status || cmd->sense_reason) {
5311 ++ iscsit_add_cmd_to_response_queue(cmd, cmd->conn, cmd->i_state);
5312 ++ return 0;
5313 ++ }
5314 + cmd->conn->conn_transport->iscsit_queue_status(cmd->conn, cmd);
5315 +
5316 + return 0;
5317 +diff --git a/drivers/target/iscsi/iscsi_target_device.c b/drivers/target/iscsi/iscsi_target_device.c
5318 +index 1b740335..4edcc47c 100644
5319 +--- a/drivers/target/iscsi/iscsi_target_device.c
5320 ++++ b/drivers/target/iscsi/iscsi_target_device.c
5321 +@@ -60,11 +60,7 @@ void iscsit_increment_maxcmdsn(struct iscsi_cmd *cmd, struct iscsi_session *sess
5322 +
5323 + cmd->maxcmdsn_inc = 1;
5324 +
5325 +- if (!mutex_trylock(&sess->cmdsn_mutex)) {
5326 +- sess->max_cmd_sn += 1;
5327 +- pr_debug("Updated MaxCmdSN to 0x%08x\n", sess->max_cmd_sn);
5328 +- return;
5329 +- }
5330 ++ mutex_lock(&sess->cmdsn_mutex);
5331 + sess->max_cmd_sn += 1;
5332 + pr_debug("Updated MaxCmdSN to 0x%08x\n", sess->max_cmd_sn);
5333 + mutex_unlock(&sess->cmdsn_mutex);
5334 +diff --git a/drivers/target/iscsi/iscsi_target_nego.c b/drivers/target/iscsi/iscsi_target_nego.c
5335 +index cd5018ff..72d9dec9 100644
5336 +--- a/drivers/target/iscsi/iscsi_target_nego.c
5337 ++++ b/drivers/target/iscsi/iscsi_target_nego.c
5338 +@@ -90,7 +90,7 @@ int extract_param(
5339 + if (len < 0)
5340 + return -1;
5341 +
5342 +- if (len > max_length) {
5343 ++ if (len >= max_length) {
5344 + pr_err("Length of input: %d exceeds max_length:"
5345 + " %d\n", len, max_length);
5346 + return -1;
5347 +diff --git a/drivers/video/backlight/atmel-pwm-bl.c b/drivers/video/backlight/atmel-pwm-bl.c
5348 +index 30e4ed52..27a14a05 100644
5349 +--- a/drivers/video/backlight/atmel-pwm-bl.c
5350 ++++ b/drivers/video/backlight/atmel-pwm-bl.c
5351 +@@ -70,7 +70,7 @@ static int atmel_pwm_bl_set_intensity(struct backlight_device *bd)
5352 + static int atmel_pwm_bl_get_intensity(struct backlight_device *bd)
5353 + {
5354 + struct atmel_pwm_bl *pwmbl = bl_get_data(bd);
5355 +- u8 intensity;
5356 ++ u32 intensity;
5357 +
5358 + if (pwmbl->pdata->pwm_active_low) {
5359 + intensity = pwm_channel_readl(&pwmbl->pwmc, PWM_CDTY) -
5360 +@@ -80,7 +80,7 @@ static int atmel_pwm_bl_get_intensity(struct backlight_device *bd)
5361 + pwm_channel_readl(&pwmbl->pwmc, PWM_CDTY);
5362 + }
5363 +
5364 +- return intensity;
5365 ++ return intensity & 0xffff;
5366 + }
5367 +
5368 + static int atmel_pwm_bl_init_pwm(struct atmel_pwm_bl *pwmbl)
5369 +@@ -207,8 +207,10 @@ static int atmel_pwm_bl_remove(struct platform_device *pdev)
5370 + {
5371 + struct atmel_pwm_bl *pwmbl = platform_get_drvdata(pdev);
5372 +
5373 +- if (pwmbl->gpio_on != -1)
5374 +- gpio_set_value(pwmbl->gpio_on, 0);
5375 ++ if (pwmbl->gpio_on != -1) {
5376 ++ gpio_set_value(pwmbl->gpio_on,
5377 ++ 0 ^ pwmbl->pdata->on_active_low);
5378 ++ }
5379 + pwm_channel_disable(&pwmbl->pwmc);
5380 + pwm_channel_free(&pwmbl->pwmc);
5381 + backlight_device_unregister(pwmbl->bldev);
5382 +diff --git a/drivers/video/console/sticore.c b/drivers/video/console/sticore.c
5383 +index 35687fd5..4ad24f2c 100644
5384 +--- a/drivers/video/console/sticore.c
5385 ++++ b/drivers/video/console/sticore.c
5386 +@@ -3,7 +3,7 @@
5387 + * core code for console driver using HP's STI firmware
5388 + *
5389 + * Copyright (C) 2000 Philipp Rumpf <prumpf@×××.org>
5390 +- * Copyright (C) 2001-2003 Helge Deller <deller@×××.de>
5391 ++ * Copyright (C) 2001-2013 Helge Deller <deller@×××.de>
5392 + * Copyright (C) 2001-2002 Thomas Bogendoerfer <tsbogend@×××××××××××××.de>
5393 + *
5394 + * TODO:
5395 +@@ -30,7 +30,7 @@
5396 +
5397 + #include "../sticore.h"
5398 +
5399 +-#define STI_DRIVERVERSION "Version 0.9a"
5400 ++#define STI_DRIVERVERSION "Version 0.9b"
5401 +
5402 + static struct sti_struct *default_sti __read_mostly;
5403 +
5404 +@@ -73,28 +73,34 @@ static const struct sti_init_flags default_init_flags = {
5405 +
5406 + static int sti_init_graph(struct sti_struct *sti)
5407 + {
5408 +- struct sti_init_inptr_ext inptr_ext = { 0, };
5409 +- struct sti_init_inptr inptr = {
5410 +- .text_planes = 3, /* # of text planes (max 3 for STI) */
5411 +- .ext_ptr = STI_PTR(&inptr_ext)
5412 +- };
5413 +- struct sti_init_outptr outptr = { 0, };
5414 ++ struct sti_init_inptr *inptr = &sti->sti_data->init_inptr;
5415 ++ struct sti_init_inptr_ext *inptr_ext = &sti->sti_data->init_inptr_ext;
5416 ++ struct sti_init_outptr *outptr = &sti->sti_data->init_outptr;
5417 + unsigned long flags;
5418 +- int ret;
5419 ++ int ret, err;
5420 +
5421 + spin_lock_irqsave(&sti->lock, flags);
5422 +
5423 +- ret = STI_CALL(sti->init_graph, &default_init_flags, &inptr,
5424 +- &outptr, sti->glob_cfg);
5425 ++ memset(inptr, 0, sizeof(*inptr));
5426 ++ inptr->text_planes = 3; /* # of text planes (max 3 for STI) */
5427 ++ memset(inptr_ext, 0, sizeof(*inptr_ext));
5428 ++ inptr->ext_ptr = STI_PTR(inptr_ext);
5429 ++ outptr->errno = 0;
5430 ++
5431 ++ ret = sti_call(sti, sti->init_graph, &default_init_flags, inptr,
5432 ++ outptr, sti->glob_cfg);
5433 ++
5434 ++ if (ret >= 0)
5435 ++ sti->text_planes = outptr->text_planes;
5436 ++ err = outptr->errno;
5437 +
5438 + spin_unlock_irqrestore(&sti->lock, flags);
5439 +
5440 + if (ret < 0) {
5441 +- printk(KERN_ERR "STI init_graph failed (ret %d, errno %d)\n",ret,outptr.errno);
5442 ++ pr_err("STI init_graph failed (ret %d, errno %d)\n", ret, err);
5443 + return -1;
5444 + }
5445 +
5446 +- sti->text_planes = outptr.text_planes;
5447 + return 0;
5448 + }
5449 +
5450 +@@ -104,16 +110,18 @@ static const struct sti_conf_flags default_conf_flags = {
5451 +
5452 + static void sti_inq_conf(struct sti_struct *sti)
5453 + {
5454 +- struct sti_conf_inptr inptr = { 0, };
5455 ++ struct sti_conf_inptr *inptr = &sti->sti_data->inq_inptr;
5456 ++ struct sti_conf_outptr *outptr = &sti->sti_data->inq_outptr;
5457 + unsigned long flags;
5458 + s32 ret;
5459 +
5460 +- sti->outptr.ext_ptr = STI_PTR(&sti->outptr_ext);
5461 ++ outptr->ext_ptr = STI_PTR(&sti->sti_data->inq_outptr_ext);
5462 +
5463 + do {
5464 + spin_lock_irqsave(&sti->lock, flags);
5465 +- ret = STI_CALL(sti->inq_conf, &default_conf_flags,
5466 +- &inptr, &sti->outptr, sti->glob_cfg);
5467 ++ memset(inptr, 0, sizeof(*inptr));
5468 ++ ret = sti_call(sti, sti->inq_conf, &default_conf_flags,
5469 ++ inptr, outptr, sti->glob_cfg);
5470 + spin_unlock_irqrestore(&sti->lock, flags);
5471 + } while (ret == 1);
5472 + }
5473 +@@ -126,7 +134,8 @@ static const struct sti_font_flags default_font_flags = {
5474 + void
5475 + sti_putc(struct sti_struct *sti, int c, int y, int x)
5476 + {
5477 +- struct sti_font_inptr inptr = {
5478 ++ struct sti_font_inptr *inptr = &sti->sti_data->font_inptr;
5479 ++ struct sti_font_inptr inptr_default = {
5480 + .font_start_addr= STI_PTR(sti->font->raw),
5481 + .index = c_index(sti, c),
5482 + .fg_color = c_fg(sti, c),
5483 +@@ -134,14 +143,15 @@ sti_putc(struct sti_struct *sti, int c, int y, int x)
5484 + .dest_x = x * sti->font_width,
5485 + .dest_y = y * sti->font_height,
5486 + };
5487 +- struct sti_font_outptr outptr = { 0, };
5488 ++ struct sti_font_outptr *outptr = &sti->sti_data->font_outptr;
5489 + s32 ret;
5490 + unsigned long flags;
5491 +
5492 + do {
5493 + spin_lock_irqsave(&sti->lock, flags);
5494 +- ret = STI_CALL(sti->font_unpmv, &default_font_flags,
5495 +- &inptr, &outptr, sti->glob_cfg);
5496 ++ *inptr = inptr_default;
5497 ++ ret = sti_call(sti, sti->font_unpmv, &default_font_flags,
5498 ++ inptr, outptr, sti->glob_cfg);
5499 + spin_unlock_irqrestore(&sti->lock, flags);
5500 + } while (ret == 1);
5501 + }
5502 +@@ -156,7 +166,8 @@ void
5503 + sti_set(struct sti_struct *sti, int src_y, int src_x,
5504 + int height, int width, u8 color)
5505 + {
5506 +- struct sti_blkmv_inptr inptr = {
5507 ++ struct sti_blkmv_inptr *inptr = &sti->sti_data->blkmv_inptr;
5508 ++ struct sti_blkmv_inptr inptr_default = {
5509 + .fg_color = color,
5510 + .bg_color = color,
5511 + .src_x = src_x,
5512 +@@ -166,14 +177,15 @@ sti_set(struct sti_struct *sti, int src_y, int src_x,
5513 + .width = width,
5514 + .height = height,
5515 + };
5516 +- struct sti_blkmv_outptr outptr = { 0, };
5517 ++ struct sti_blkmv_outptr *outptr = &sti->sti_data->blkmv_outptr;
5518 + s32 ret;
5519 + unsigned long flags;
5520 +
5521 + do {
5522 + spin_lock_irqsave(&sti->lock, flags);
5523 +- ret = STI_CALL(sti->block_move, &clear_blkmv_flags,
5524 +- &inptr, &outptr, sti->glob_cfg);
5525 ++ *inptr = inptr_default;
5526 ++ ret = sti_call(sti, sti->block_move, &clear_blkmv_flags,
5527 ++ inptr, outptr, sti->glob_cfg);
5528 + spin_unlock_irqrestore(&sti->lock, flags);
5529 + } while (ret == 1);
5530 + }
5531 +@@ -182,7 +194,8 @@ void
5532 + sti_clear(struct sti_struct *sti, int src_y, int src_x,
5533 + int height, int width, int c)
5534 + {
5535 +- struct sti_blkmv_inptr inptr = {
5536 ++ struct sti_blkmv_inptr *inptr = &sti->sti_data->blkmv_inptr;
5537 ++ struct sti_blkmv_inptr inptr_default = {
5538 + .fg_color = c_fg(sti, c),
5539 + .bg_color = c_bg(sti, c),
5540 + .src_x = src_x * sti->font_width,
5541 +@@ -192,14 +205,15 @@ sti_clear(struct sti_struct *sti, int src_y, int src_x,
5542 + .width = width * sti->font_width,
5543 + .height = height* sti->font_height,
5544 + };
5545 +- struct sti_blkmv_outptr outptr = { 0, };
5546 ++ struct sti_blkmv_outptr *outptr = &sti->sti_data->blkmv_outptr;
5547 + s32 ret;
5548 + unsigned long flags;
5549 +
5550 + do {
5551 + spin_lock_irqsave(&sti->lock, flags);
5552 +- ret = STI_CALL(sti->block_move, &clear_blkmv_flags,
5553 +- &inptr, &outptr, sti->glob_cfg);
5554 ++ *inptr = inptr_default;
5555 ++ ret = sti_call(sti, sti->block_move, &clear_blkmv_flags,
5556 ++ inptr, outptr, sti->glob_cfg);
5557 + spin_unlock_irqrestore(&sti->lock, flags);
5558 + } while (ret == 1);
5559 + }
5560 +@@ -212,7 +226,8 @@ void
5561 + sti_bmove(struct sti_struct *sti, int src_y, int src_x,
5562 + int dst_y, int dst_x, int height, int width)
5563 + {
5564 +- struct sti_blkmv_inptr inptr = {
5565 ++ struct sti_blkmv_inptr *inptr = &sti->sti_data->blkmv_inptr;
5566 ++ struct sti_blkmv_inptr inptr_default = {
5567 + .src_x = src_x * sti->font_width,
5568 + .src_y = src_y * sti->font_height,
5569 + .dest_x = dst_x * sti->font_width,
5570 +@@ -220,14 +235,15 @@ sti_bmove(struct sti_struct *sti, int src_y, int src_x,
5571 + .width = width * sti->font_width,
5572 + .height = height* sti->font_height,
5573 + };
5574 +- struct sti_blkmv_outptr outptr = { 0, };
5575 ++ struct sti_blkmv_outptr *outptr = &sti->sti_data->blkmv_outptr;
5576 + s32 ret;
5577 + unsigned long flags;
5578 +
5579 + do {
5580 + spin_lock_irqsave(&sti->lock, flags);
5581 +- ret = STI_CALL(sti->block_move, &default_blkmv_flags,
5582 +- &inptr, &outptr, sti->glob_cfg);
5583 ++ *inptr = inptr_default;
5584 ++ ret = sti_call(sti, sti->block_move, &default_blkmv_flags,
5585 ++ inptr, outptr, sti->glob_cfg);
5586 + spin_unlock_irqrestore(&sti->lock, flags);
5587 + } while (ret == 1);
5588 + }
5589 +@@ -284,7 +300,7 @@ __setup("sti=", sti_setup);
5590 +
5591 +
5592 +
5593 +-static char *font_name[MAX_STI_ROMS] = { "VGA8x16", };
5594 ++static char *font_name[MAX_STI_ROMS];
5595 + static int font_index[MAX_STI_ROMS],
5596 + font_height[MAX_STI_ROMS],
5597 + font_width[MAX_STI_ROMS];
5598 +@@ -389,10 +405,10 @@ static void sti_dump_outptr(struct sti_struct *sti)
5599 + "%d used bits\n"
5600 + "%d planes\n"
5601 + "attributes %08x\n",
5602 +- sti->outptr.bits_per_pixel,
5603 +- sti->outptr.bits_used,
5604 +- sti->outptr.planes,
5605 +- sti->outptr.attributes));
5606 ++ sti->sti_data->inq_outptr.bits_per_pixel,
5607 ++ sti->sti_data->inq_outptr.bits_used,
5608 ++ sti->sti_data->inq_outptr.planes,
5609 ++ sti->sti_data->inq_outptr.attributes));
5610 + }
5611 +
5612 + static int sti_init_glob_cfg(struct sti_struct *sti, unsigned long rom_address,
5613 +@@ -402,24 +418,21 @@ static int sti_init_glob_cfg(struct sti_struct *sti, unsigned long rom_address,
5614 + struct sti_glob_cfg_ext *glob_cfg_ext;
5615 + void *save_addr;
5616 + void *sti_mem_addr;
5617 +- const int save_addr_size = 1024; /* XXX */
5618 +- int i;
5619 ++ int i, size;
5620 +
5621 +- if (!sti->sti_mem_request)
5622 ++ if (sti->sti_mem_request < 256)
5623 + sti->sti_mem_request = 256; /* STI default */
5624 +
5625 +- glob_cfg = kzalloc(sizeof(*sti->glob_cfg), GFP_KERNEL);
5626 +- glob_cfg_ext = kzalloc(sizeof(*glob_cfg_ext), GFP_KERNEL);
5627 +- save_addr = kzalloc(save_addr_size, GFP_KERNEL);
5628 +- sti_mem_addr = kzalloc(sti->sti_mem_request, GFP_KERNEL);
5629 ++ size = sizeof(struct sti_all_data) + sti->sti_mem_request - 256;
5630 +
5631 +- if (!(glob_cfg && glob_cfg_ext && save_addr && sti_mem_addr)) {
5632 +- kfree(glob_cfg);
5633 +- kfree(glob_cfg_ext);
5634 +- kfree(save_addr);
5635 +- kfree(sti_mem_addr);
5636 ++ sti->sti_data = kzalloc(size, STI_LOWMEM);
5637 ++ if (!sti->sti_data)
5638 + return -ENOMEM;
5639 +- }
5640 ++
5641 ++ glob_cfg = &sti->sti_data->glob_cfg;
5642 ++ glob_cfg_ext = &sti->sti_data->glob_cfg_ext;
5643 ++ save_addr = &sti->sti_data->save_addr;
5644 ++ sti_mem_addr = &sti->sti_data->sti_mem_addr;
5645 +
5646 + glob_cfg->ext_ptr = STI_PTR(glob_cfg_ext);
5647 + glob_cfg->save_addr = STI_PTR(save_addr);
5648 +@@ -475,32 +488,31 @@ static int sti_init_glob_cfg(struct sti_struct *sti, unsigned long rom_address,
5649 + return 0;
5650 + }
5651 +
5652 +-#ifdef CONFIG_FB
5653 ++#ifdef CONFIG_FONTS
5654 + static struct sti_cooked_font *
5655 + sti_select_fbfont(struct sti_cooked_rom *cooked_rom, const char *fbfont_name)
5656 + {
5657 +- const struct font_desc *fbfont;
5658 ++ const struct font_desc *fbfont = NULL;
5659 + unsigned int size, bpc;
5660 + void *dest;
5661 + struct sti_rom_font *nf;
5662 + struct sti_cooked_font *cooked_font;
5663 +
5664 +- if (!fbfont_name || !strlen(fbfont_name))
5665 +- return NULL;
5666 +- fbfont = find_font(fbfont_name);
5667 ++ if (fbfont_name && strlen(fbfont_name))
5668 ++ fbfont = find_font(fbfont_name);
5669 + if (!fbfont)
5670 + fbfont = get_default_font(1024,768, ~(u32)0, ~(u32)0);
5671 + if (!fbfont)
5672 + return NULL;
5673 +
5674 +- DPRINTK((KERN_DEBUG "selected %dx%d fb-font %s\n",
5675 +- fbfont->width, fbfont->height, fbfont->name));
5676 ++ pr_info("STI selected %dx%d framebuffer font %s for sticon\n",
5677 ++ fbfont->width, fbfont->height, fbfont->name);
5678 +
5679 + bpc = ((fbfont->width+7)/8) * fbfont->height;
5680 + size = bpc * 256;
5681 + size += sizeof(struct sti_rom_font);
5682 +
5683 +- nf = kzalloc(size, GFP_KERNEL);
5684 ++ nf = kzalloc(size, STI_LOWMEM);
5685 + if (!nf)
5686 + return NULL;
5687 +
5688 +@@ -637,7 +649,7 @@ static void *sti_bmode_font_raw(struct sti_cooked_font *f)
5689 + unsigned char *n, *p, *q;
5690 + int size = f->raw->bytes_per_char*256+sizeof(struct sti_rom_font);
5691 +
5692 +- n = kzalloc (4*size, GFP_KERNEL);
5693 ++ n = kzalloc(4*size, STI_LOWMEM);
5694 + if (!n)
5695 + return NULL;
5696 + p = n + 3;
5697 +@@ -673,7 +685,7 @@ static struct sti_rom *sti_get_bmode_rom (unsigned long address)
5698 + sti_bmode_rom_copy(address + BMODE_LAST_ADDR_OFFS, sizeof(size), &size);
5699 +
5700 + size = (size+3) / 4;
5701 +- raw = kmalloc(size, GFP_KERNEL);
5702 ++ raw = kmalloc(size, STI_LOWMEM);
5703 + if (raw) {
5704 + sti_bmode_rom_copy(address, size, raw);
5705 + memmove (&raw->res004, &raw->type[0], 0x3c);
5706 +@@ -707,7 +719,7 @@ static struct sti_rom *sti_get_wmode_rom(unsigned long address)
5707 + /* read the ROM size directly from the struct in ROM */
5708 + size = gsc_readl(address + offsetof(struct sti_rom,last_addr));
5709 +
5710 +- raw = kmalloc(size, GFP_KERNEL);
5711 ++ raw = kmalloc(size, STI_LOWMEM);
5712 + if (raw)
5713 + sti_rom_copy(address, size, raw);
5714 +
5715 +@@ -743,6 +755,10 @@ static int sti_read_rom(int wordmode, struct sti_struct *sti,
5716 +
5717 + address = (unsigned long) STI_PTR(raw);
5718 +
5719 ++ pr_info("STI ROM supports 32 %sbit firmware functions.\n",
5720 ++ raw->alt_code_type == ALT_CODE_TYPE_PA_RISC_64
5721 ++ ? "and 64 " : "");
5722 ++
5723 + sti->font_unpmv = address + (raw->font_unpmv & 0x03ffffff);
5724 + sti->block_move = address + (raw->block_move & 0x03ffffff);
5725 + sti->init_graph = address + (raw->init_graph & 0x03ffffff);
5726 +@@ -901,7 +917,8 @@ test_rom:
5727 + sti_dump_globcfg(sti->glob_cfg, sti->sti_mem_request);
5728 + sti_dump_outptr(sti);
5729 +
5730 +- printk(KERN_INFO " graphics card name: %s\n", sti->outptr.dev_name );
5731 ++ pr_info(" graphics card name: %s\n",
5732 ++ sti->sti_data->inq_outptr.dev_name);
5733 +
5734 + sti_roms[num_sti_roms] = sti;
5735 + num_sti_roms++;
5736 +@@ -1073,6 +1090,29 @@ struct sti_struct * sti_get_rom(unsigned int index)
5737 + }
5738 + EXPORT_SYMBOL(sti_get_rom);
5739 +
5740 ++
5741 ++int sti_call(const struct sti_struct *sti, unsigned long func,
5742 ++ const void *flags, void *inptr, void *outptr,
5743 ++ struct sti_glob_cfg *glob_cfg)
5744 ++{
5745 ++ unsigned long _flags = STI_PTR(flags);
5746 ++ unsigned long _inptr = STI_PTR(inptr);
5747 ++ unsigned long _outptr = STI_PTR(outptr);
5748 ++ unsigned long _glob_cfg = STI_PTR(glob_cfg);
5749 ++ int ret;
5750 ++
5751 ++#ifdef CONFIG_64BIT
5752 ++ /* Check for overflow when using 32bit STI on 64bit kernel. */
5753 ++ if (WARN_ONCE(_flags>>32 || _inptr>>32 || _outptr>>32 || _glob_cfg>>32,
5754 ++ "Out of 32bit-range pointers!"))
5755 ++ return -1;
5756 ++#endif
5757 ++
5758 ++ ret = pdc_sti_call(func, _flags, _inptr, _outptr, _glob_cfg);
5759 ++
5760 ++ return ret;
5761 ++}
5762 ++
5763 + MODULE_AUTHOR("Philipp Rumpf, Helge Deller, Thomas Bogendoerfer");
5764 + MODULE_DESCRIPTION("Core STI driver for HP's NGLE series graphics cards in HP PARISC machines");
5765 + MODULE_LICENSE("GPL v2");
5766 +diff --git a/drivers/video/sticore.h b/drivers/video/sticore.h
5767 +index addf7b61..af161953 100644
5768 +--- a/drivers/video/sticore.h
5769 ++++ b/drivers/video/sticore.h
5770 +@@ -18,6 +18,9 @@
5771 + #define STI_FONT_HPROMAN8 1
5772 + #define STI_FONT_KANA8 2
5773 +
5774 ++#define ALT_CODE_TYPE_UNKNOWN 0x00 /* alt code type values */
5775 ++#define ALT_CODE_TYPE_PA_RISC_64 0x01
5776 ++
5777 + /* The latency of the STI functions cannot really be reduced by setting
5778 + * this to 0; STI doesn't seem to be designed to allow calling a different
5779 + * function (or the same function with different arguments) after a
5780 +@@ -40,14 +43,6 @@
5781 +
5782 + #define STI_PTR(p) ( virt_to_phys(p) )
5783 + #define PTR_STI(p) ( phys_to_virt((unsigned long)p) )
5784 +-#define STI_CALL(func, flags, inptr, outptr, glob_cfg) \
5785 +- ({ \
5786 +- pdc_sti_call( func, STI_PTR(flags), \
5787 +- STI_PTR(inptr), \
5788 +- STI_PTR(outptr), \
5789 +- STI_PTR(glob_cfg)); \
5790 +- })
5791 +-
5792 +
5793 + #define sti_onscreen_x(sti) (sti->glob_cfg->onscreen_x)
5794 + #define sti_onscreen_y(sti) (sti->glob_cfg->onscreen_y)
5795 +@@ -56,6 +51,12 @@
5796 + #define sti_font_x(sti) (PTR_STI(sti->font)->width)
5797 + #define sti_font_y(sti) (PTR_STI(sti->font)->height)
5798 +
5799 ++#ifdef CONFIG_64BIT
5800 ++#define STI_LOWMEM (GFP_KERNEL | GFP_DMA)
5801 ++#else
5802 ++#define STI_LOWMEM (GFP_KERNEL)
5803 ++#endif
5804 ++
5805 +
5806 + /* STI function configuration structs */
5807 +
5808 +@@ -306,6 +307,34 @@ struct sti_blkmv_outptr {
5809 + };
5810 +
5811 +
5812 ++/* sti_all_data is an internal struct which needs to be allocated in
5813 ++ * low memory (< 4GB) if STI is used with 32bit STI on a 64bit kernel */
5814 ++
5815 ++struct sti_all_data {
5816 ++ struct sti_glob_cfg glob_cfg;
5817 ++ struct sti_glob_cfg_ext glob_cfg_ext;
5818 ++
5819 ++ struct sti_conf_inptr inq_inptr;
5820 ++ struct sti_conf_outptr inq_outptr; /* configuration */
5821 ++ struct sti_conf_outptr_ext inq_outptr_ext;
5822 ++
5823 ++ struct sti_init_inptr_ext init_inptr_ext;
5824 ++ struct sti_init_inptr init_inptr;
5825 ++ struct sti_init_outptr init_outptr;
5826 ++
5827 ++ struct sti_blkmv_inptr blkmv_inptr;
5828 ++ struct sti_blkmv_outptr blkmv_outptr;
5829 ++
5830 ++ struct sti_font_inptr font_inptr;
5831 ++ struct sti_font_outptr font_outptr;
5832 ++
5833 ++ /* leave as last entries */
5834 ++ unsigned long save_addr[1024 / sizeof(unsigned long)];
5835 ++ /* min 256 bytes which is STI default, max sti->sti_mem_request */
5836 ++ unsigned long sti_mem_addr[256 / sizeof(unsigned long)];
5837 ++ /* do not add something below here ! */
5838 ++};
5839 ++
5840 + /* internal generic STI struct */
5841 +
5842 + struct sti_struct {
5843 +@@ -330,11 +359,9 @@ struct sti_struct {
5844 + region_t regions[STI_REGION_MAX];
5845 + unsigned long regions_phys[STI_REGION_MAX];
5846 +
5847 +- struct sti_glob_cfg *glob_cfg;
5848 +- struct sti_cooked_font *font; /* ptr to selected font (cooked) */
5849 ++ struct sti_glob_cfg *glob_cfg; /* points into sti_all_data */
5850 +
5851 +- struct sti_conf_outptr outptr; /* configuration */
5852 +- struct sti_conf_outptr_ext outptr_ext;
5853 ++ struct sti_cooked_font *font; /* ptr to selected font (cooked) */
5854 +
5855 + struct pci_dev *pd;
5856 +
5857 +@@ -343,6 +370,9 @@ struct sti_struct {
5858 +
5859 + /* pointer to the fb_info where this STI device is used */
5860 + struct fb_info *info;
5861 ++
5862 ++ /* pointer to all internal data */
5863 ++ struct sti_all_data *sti_data;
5864 + };
5865 +
5866 +
5867 +@@ -350,6 +380,14 @@ struct sti_struct {
5868 +
5869 + struct sti_struct *sti_get_rom(unsigned int index); /* 0: default sti */
5870 +
5871 ++
5872 ++/* sticore main function to call STI firmware */
5873 ++
5874 ++int sti_call(const struct sti_struct *sti, unsigned long func,
5875 ++ const void *flags, void *inptr, void *outptr,
5876 ++ struct sti_glob_cfg *glob_cfg);
5877 ++
5878 ++
5879 + /* functions to call the STI ROM directly */
5880 +
5881 + void sti_putc(struct sti_struct *sti, int c, int y, int x);
5882 +diff --git a/drivers/video/stifb.c b/drivers/video/stifb.c
5883 +index 876648e1..019a1fee 100644
5884 +--- a/drivers/video/stifb.c
5885 ++++ b/drivers/video/stifb.c
5886 +@@ -1101,6 +1101,7 @@ static int __init stifb_init_fb(struct sti_struct *sti, int bpp_pref)
5887 + var = &info->var;
5888 +
5889 + fb->sti = sti;
5890 ++ dev_name = sti->sti_data->inq_outptr.dev_name;
5891 + /* store upper 32bits of the graphics id */
5892 + fb->id = fb->sti->graphics_id[0];
5893 +
5894 +@@ -1114,11 +1115,11 @@ static int __init stifb_init_fb(struct sti_struct *sti, int bpp_pref)
5895 + Since this driver only supports standard mode, we check
5896 + if the device name contains the string "DX" and tell the
5897 + user how to reconfigure the card. */
5898 +- if (strstr(sti->outptr.dev_name, "DX")) {
5899 ++ if (strstr(dev_name, "DX")) {
5900 + printk(KERN_WARNING
5901 + "WARNING: stifb framebuffer driver does not support '%s' in double-buffer mode.\n"
5902 + "WARNING: Please disable the double-buffer mode in IPL menu (the PARISC-BIOS).\n",
5903 +- sti->outptr.dev_name);
5904 ++ dev_name);
5905 + goto out_err0;
5906 + }
5907 + /* fall though */
5908 +@@ -1130,7 +1131,7 @@ static int __init stifb_init_fb(struct sti_struct *sti, int bpp_pref)
5909 + break;
5910 + default:
5911 + printk(KERN_WARNING "stifb: '%s' (id: 0x%08x) not supported.\n",
5912 +- sti->outptr.dev_name, fb->id);
5913 ++ dev_name, fb->id);
5914 + goto out_err0;
5915 + }
5916 +
5917 +@@ -1154,7 +1155,6 @@ static int __init stifb_init_fb(struct sti_struct *sti, int bpp_pref)
5918 + fb->id = S9000_ID_A1659A;
5919 + break;
5920 + case S9000_ID_TIMBER: /* HP9000/710 Any (may be a grayscale device) */
5921 +- dev_name = fb->sti->outptr.dev_name;
5922 + if (strstr(dev_name, "GRAYSCALE") ||
5923 + strstr(dev_name, "Grayscale") ||
5924 + strstr(dev_name, "grayscale"))
5925 +@@ -1290,7 +1290,7 @@ static int __init stifb_init_fb(struct sti_struct *sti, int bpp_pref)
5926 + var->xres,
5927 + var->yres,
5928 + var->bits_per_pixel,
5929 +- sti->outptr.dev_name,
5930 ++ dev_name,
5931 + fb->id,
5932 + fix->mmio_start);
5933 +
5934 +diff --git a/fs/cifs/cifssmb.c b/fs/cifs/cifssmb.c
5935 +index a58dc77c..d17c5d72 100644
5936 +--- a/fs/cifs/cifssmb.c
5937 ++++ b/fs/cifs/cifssmb.c
5938 +@@ -3306,11 +3306,13 @@ static __u16 ACL_to_cifs_posix(char *parm_data, const char *pACL,
5939 + return 0;
5940 + }
5941 + cifs_acl->version = cpu_to_le16(1);
5942 +- if (acl_type == ACL_TYPE_ACCESS)
5943 ++ if (acl_type == ACL_TYPE_ACCESS) {
5944 + cifs_acl->access_entry_count = cpu_to_le16(count);
5945 +- else if (acl_type == ACL_TYPE_DEFAULT)
5946 ++ cifs_acl->default_entry_count = __constant_cpu_to_le16(0xFFFF);
5947 ++ } else if (acl_type == ACL_TYPE_DEFAULT) {
5948 + cifs_acl->default_entry_count = cpu_to_le16(count);
5949 +- else {
5950 ++ cifs_acl->access_entry_count = __constant_cpu_to_le16(0xFFFF);
5951 ++ } else {
5952 + cifs_dbg(FYI, "unknown ACL type %d\n", acl_type);
5953 + return 0;
5954 + }
5955 +diff --git a/fs/devpts/inode.c b/fs/devpts/inode.c
5956 +index 073d30b9..a726b9f2 100644
5957 +--- a/fs/devpts/inode.c
5958 ++++ b/fs/devpts/inode.c
5959 +@@ -498,6 +498,7 @@ static void devpts_kill_sb(struct super_block *sb)
5960 + {
5961 + struct pts_fs_info *fsi = DEVPTS_SB(sb);
5962 +
5963 ++ ida_destroy(&fsi->allocated_ptys);
5964 + kfree(fsi);
5965 + kill_litter_super(sb);
5966 + }
5967 +diff --git a/fs/ext4/xattr.c b/fs/ext4/xattr.c
5968 +index 03e9bebb..1423c481 100644
5969 +--- a/fs/ext4/xattr.c
5970 ++++ b/fs/ext4/xattr.c
5971 +@@ -1352,6 +1352,7 @@ retry:
5972 + new_extra_isize = s_min_extra_isize;
5973 + kfree(is); is = NULL;
5974 + kfree(bs); bs = NULL;
5975 ++ brelse(bh);
5976 + goto retry;
5977 + }
5978 + error = -1;
5979 +diff --git a/fs/namei.c b/fs/namei.c
5980 +index 9ed93612..cccaf77e 100644
5981 +--- a/fs/namei.c
5982 ++++ b/fs/namei.c
5983 +@@ -2263,6 +2263,7 @@ static int may_delete(struct inode *dir,struct dentry *victim,int isdir)
5984 + */
5985 + static inline int may_create(struct inode *dir, struct dentry *child)
5986 + {
5987 ++ audit_inode_child(dir, child, AUDIT_TYPE_CHILD_CREATE);
5988 + if (child->d_inode)
5989 + return -EEXIST;
5990 + if (IS_DEADDIR(dir))
5991 +diff --git a/include/acpi/acpi_bus.h b/include/acpi/acpi_bus.h
5992 +index f45b2a78..6b66efdc 100644
5993 +--- a/include/acpi/acpi_bus.h
5994 ++++ b/include/acpi/acpi_bus.h
5995 +@@ -97,6 +97,7 @@ enum acpi_hotplug_mode {
5996 + struct acpi_hotplug_profile {
5997 + struct kobject kobj;
5998 + bool enabled:1;
5999 ++ bool ignore:1;
6000 + enum acpi_hotplug_mode mode;
6001 + };
6002 +
6003 +diff --git a/include/linux/audit.h b/include/linux/audit.h
6004 +index b20b0385..729a4d16 100644
6005 +--- a/include/linux/audit.h
6006 ++++ b/include/linux/audit.h
6007 +@@ -103,8 +103,11 @@ extern void __audit_syscall_exit(int ret_success, long ret_value);
6008 + extern struct filename *__audit_reusename(const __user char *uptr);
6009 + extern void __audit_getname(struct filename *name);
6010 + extern void audit_putname(struct filename *name);
6011 ++
6012 ++#define AUDIT_INODE_PARENT 1 /* dentry represents the parent */
6013 ++#define AUDIT_INODE_HIDDEN 2 /* audit record should be hidden */
6014 + extern void __audit_inode(struct filename *name, const struct dentry *dentry,
6015 +- unsigned int parent);
6016 ++ unsigned int flags);
6017 + extern void __audit_inode_child(const struct inode *parent,
6018 + const struct dentry *dentry,
6019 + const unsigned char type);
6020 +@@ -148,10 +151,22 @@ static inline void audit_getname(struct filename *name)
6021 + if (unlikely(!audit_dummy_context()))
6022 + __audit_getname(name);
6023 + }
6024 +-static inline void audit_inode(struct filename *name, const struct dentry *dentry,
6025 ++static inline void audit_inode(struct filename *name,
6026 ++ const struct dentry *dentry,
6027 + unsigned int parent) {
6028 ++ if (unlikely(!audit_dummy_context())) {
6029 ++ unsigned int flags = 0;
6030 ++ if (parent)
6031 ++ flags |= AUDIT_INODE_PARENT;
6032 ++ __audit_inode(name, dentry, flags);
6033 ++ }
6034 ++}
6035 ++static inline void audit_inode_parent_hidden(struct filename *name,
6036 ++ const struct dentry *dentry)
6037 ++{
6038 + if (unlikely(!audit_dummy_context()))
6039 +- __audit_inode(name, dentry, parent);
6040 ++ __audit_inode(name, dentry,
6041 ++ AUDIT_INODE_PARENT | AUDIT_INODE_HIDDEN);
6042 + }
6043 + static inline void audit_inode_child(const struct inode *parent,
6044 + const struct dentry *dentry,
6045 +@@ -311,7 +326,7 @@ static inline void audit_putname(struct filename *name)
6046 + { }
6047 + static inline void __audit_inode(struct filename *name,
6048 + const struct dentry *dentry,
6049 +- unsigned int parent)
6050 ++ unsigned int flags)
6051 + { }
6052 + static inline void __audit_inode_child(const struct inode *parent,
6053 + const struct dentry *dentry,
6054 +@@ -321,6 +336,9 @@ static inline void audit_inode(struct filename *name,
6055 + const struct dentry *dentry,
6056 + unsigned int parent)
6057 + { }
6058 ++static inline void audit_inode_parent_hidden(struct filename *name,
6059 ++ const struct dentry *dentry)
6060 ++{ }
6061 + static inline void audit_inode_child(const struct inode *parent,
6062 + const struct dentry *dentry,
6063 + const unsigned char type)
6064 +diff --git a/include/linux/ipc_namespace.h b/include/linux/ipc_namespace.h
6065 +index 19c19a5e..f6c82de1 100644
6066 +--- a/include/linux/ipc_namespace.h
6067 ++++ b/include/linux/ipc_namespace.h
6068 +@@ -34,9 +34,9 @@ struct ipc_namespace {
6069 + int sem_ctls[4];
6070 + int used_sems;
6071 +
6072 +- int msg_ctlmax;
6073 +- int msg_ctlmnb;
6074 +- int msg_ctlmni;
6075 ++ unsigned int msg_ctlmax;
6076 ++ unsigned int msg_ctlmnb;
6077 ++ unsigned int msg_ctlmni;
6078 + atomic_t msg_bytes;
6079 + atomic_t msg_hdrs;
6080 + int auto_msgmni;
6081 +diff --git a/include/linux/msg.h b/include/linux/msg.h
6082 +index 391af8d1..e21f9d44 100644
6083 +--- a/include/linux/msg.h
6084 ++++ b/include/linux/msg.h
6085 +@@ -6,9 +6,9 @@
6086 +
6087 + /* one msg_msg structure for each message */
6088 + struct msg_msg {
6089 +- struct list_head m_list;
6090 +- long m_type;
6091 +- int m_ts; /* message text size */
6092 ++ struct list_head m_list;
6093 ++ long m_type;
6094 ++ size_t m_ts; /* message text size */
6095 + struct msg_msgseg* next;
6096 + void *security;
6097 + /* the actual message follows immediately */
6098 +diff --git a/include/linux/mtd/map.h b/include/linux/mtd/map.h
6099 +index 4b02512e..5f487d77 100644
6100 +--- a/include/linux/mtd/map.h
6101 ++++ b/include/linux/mtd/map.h
6102 +@@ -365,7 +365,7 @@ static inline map_word map_word_load_partial(struct map_info *map, map_word orig
6103 + bitpos = (map_bankwidth(map)-1-i)*8;
6104 + #endif
6105 + orig.x[0] &= ~(0xff << bitpos);
6106 +- orig.x[0] |= buf[i-start] << bitpos;
6107 ++ orig.x[0] |= (unsigned long)buf[i-start] << bitpos;
6108 + }
6109 + }
6110 + return orig;
6111 +@@ -384,7 +384,7 @@ static inline map_word map_word_ff(struct map_info *map)
6112 +
6113 + if (map_bankwidth(map) < MAP_FF_LIMIT) {
6114 + int bw = 8 * map_bankwidth(map);
6115 +- r.x[0] = (1 << bw) - 1;
6116 ++ r.x[0] = (1UL << bw) - 1;
6117 + } else {
6118 + for (i=0; i<map_words(map); i++)
6119 + r.x[i] = ~0UL;
6120 +diff --git a/include/net/netfilter/nf_conntrack_extend.h b/include/net/netfilter/nf_conntrack_extend.h
6121 +index 977bc8a4..33131085 100644
6122 +--- a/include/net/netfilter/nf_conntrack_extend.h
6123 ++++ b/include/net/netfilter/nf_conntrack_extend.h
6124 +@@ -80,7 +80,7 @@ static inline void nf_ct_ext_destroy(struct nf_conn *ct)
6125 + static inline void nf_ct_ext_free(struct nf_conn *ct)
6126 + {
6127 + if (ct->ext)
6128 +- kfree(ct->ext);
6129 ++ kfree_rcu(ct->ext, rcu);
6130 + }
6131 +
6132 + /* Add this type, returns pointer to data or NULL. */
6133 +diff --git a/include/trace/ftrace.h b/include/trace/ftrace.h
6134 +index 19edd7fa..66dba421 100644
6135 +--- a/include/trace/ftrace.h
6136 ++++ b/include/trace/ftrace.h
6137 +@@ -368,7 +368,8 @@ ftrace_define_fields_##call(struct ftrace_event_call *event_call) \
6138 + __data_size += (len) * sizeof(type);
6139 +
6140 + #undef __string
6141 +-#define __string(item, src) __dynamic_array(char, item, strlen(src) + 1)
6142 ++#define __string(item, src) __dynamic_array(char, item, \
6143 ++ strlen((src) ? (const char *)(src) : "(null)") + 1)
6144 +
6145 + #undef DECLARE_EVENT_CLASS
6146 + #define DECLARE_EVENT_CLASS(call, proto, args, tstruct, assign, print) \
6147 +@@ -498,7 +499,7 @@ static inline notrace int ftrace_get_offsets_##call( \
6148 +
6149 + #undef __assign_str
6150 + #define __assign_str(dst, src) \
6151 +- strcpy(__get_str(dst), src);
6152 ++ strcpy(__get_str(dst), (src) ? (const char *)(src) : "(null)");
6153 +
6154 + #undef TP_fast_assign
6155 + #define TP_fast_assign(args...) args
6156 +diff --git a/ipc/ipc_sysctl.c b/ipc/ipc_sysctl.c
6157 +index 130dfece..b0e99deb 100644
6158 +--- a/ipc/ipc_sysctl.c
6159 ++++ b/ipc/ipc_sysctl.c
6160 +@@ -62,7 +62,7 @@ static int proc_ipc_dointvec_minmax_orphans(ctl_table *table, int write,
6161 + return err;
6162 + }
6163 +
6164 +-static int proc_ipc_callback_dointvec(ctl_table *table, int write,
6165 ++static int proc_ipc_callback_dointvec_minmax(ctl_table *table, int write,
6166 + void __user *buffer, size_t *lenp, loff_t *ppos)
6167 + {
6168 + struct ctl_table ipc_table;
6169 +@@ -72,7 +72,7 @@ static int proc_ipc_callback_dointvec(ctl_table *table, int write,
6170 + memcpy(&ipc_table, table, sizeof(ipc_table));
6171 + ipc_table.data = get_ipc(table);
6172 +
6173 +- rc = proc_dointvec(&ipc_table, write, buffer, lenp, ppos);
6174 ++ rc = proc_dointvec_minmax(&ipc_table, write, buffer, lenp, ppos);
6175 +
6176 + if (write && !rc && lenp_bef == *lenp)
6177 + /*
6178 +@@ -152,15 +152,13 @@ static int proc_ipcauto_dointvec_minmax(ctl_table *table, int write,
6179 + #define proc_ipc_dointvec NULL
6180 + #define proc_ipc_dointvec_minmax NULL
6181 + #define proc_ipc_dointvec_minmax_orphans NULL
6182 +-#define proc_ipc_callback_dointvec NULL
6183 ++#define proc_ipc_callback_dointvec_minmax NULL
6184 + #define proc_ipcauto_dointvec_minmax NULL
6185 + #endif
6186 +
6187 + static int zero;
6188 + static int one = 1;
6189 +-#ifdef CONFIG_CHECKPOINT_RESTORE
6190 + static int int_max = INT_MAX;
6191 +-#endif
6192 +
6193 + static struct ctl_table ipc_kern_table[] = {
6194 + {
6195 +@@ -198,21 +196,27 @@ static struct ctl_table ipc_kern_table[] = {
6196 + .data = &init_ipc_ns.msg_ctlmax,
6197 + .maxlen = sizeof (init_ipc_ns.msg_ctlmax),
6198 + .mode = 0644,
6199 +- .proc_handler = proc_ipc_dointvec,
6200 ++ .proc_handler = proc_ipc_dointvec_minmax,
6201 ++ .extra1 = &zero,
6202 ++ .extra2 = &int_max,
6203 + },
6204 + {
6205 + .procname = "msgmni",
6206 + .data = &init_ipc_ns.msg_ctlmni,
6207 + .maxlen = sizeof (init_ipc_ns.msg_ctlmni),
6208 + .mode = 0644,
6209 +- .proc_handler = proc_ipc_callback_dointvec,
6210 ++ .proc_handler = proc_ipc_callback_dointvec_minmax,
6211 ++ .extra1 = &zero,
6212 ++ .extra2 = &int_max,
6213 + },
6214 + {
6215 + .procname = "msgmnb",
6216 + .data = &init_ipc_ns.msg_ctlmnb,
6217 + .maxlen = sizeof (init_ipc_ns.msg_ctlmnb),
6218 + .mode = 0644,
6219 +- .proc_handler = proc_ipc_dointvec,
6220 ++ .proc_handler = proc_ipc_dointvec_minmax,
6221 ++ .extra1 = &zero,
6222 ++ .extra2 = &int_max,
6223 + },
6224 + {
6225 + .procname = "sem",
6226 +diff --git a/ipc/mqueue.c b/ipc/mqueue.c
6227 +index e4e47f64..ae1996d3 100644
6228 +--- a/ipc/mqueue.c
6229 ++++ b/ipc/mqueue.c
6230 +@@ -823,6 +823,7 @@ SYSCALL_DEFINE4(mq_open, const char __user *, u_name, int, oflag, umode_t, mode,
6231 + error = ro;
6232 + goto out;
6233 + }
6234 ++ audit_inode_parent_hidden(name, root);
6235 + filp = do_create(ipc_ns, root->d_inode,
6236 + &path, oflag, mode,
6237 + u_attr ? &attr : NULL);
6238 +@@ -868,6 +869,7 @@ SYSCALL_DEFINE1(mq_unlink, const char __user *, u_name)
6239 + if (IS_ERR(name))
6240 + return PTR_ERR(name);
6241 +
6242 ++ audit_inode_parent_hidden(name, mnt->mnt_root);
6243 + err = mnt_want_write(mnt);
6244 + if (err)
6245 + goto out_name;
6246 +diff --git a/ipc/msgutil.c b/ipc/msgutil.c
6247 +index 491e71f2..7e709597 100644
6248 +--- a/ipc/msgutil.c
6249 ++++ b/ipc/msgutil.c
6250 +@@ -41,15 +41,15 @@ struct msg_msgseg {
6251 + /* the next part of the message follows immediately */
6252 + };
6253 +
6254 +-#define DATALEN_MSG (int)(PAGE_SIZE-sizeof(struct msg_msg))
6255 +-#define DATALEN_SEG (int)(PAGE_SIZE-sizeof(struct msg_msgseg))
6256 ++#define DATALEN_MSG ((size_t)PAGE_SIZE-sizeof(struct msg_msg))
6257 ++#define DATALEN_SEG ((size_t)PAGE_SIZE-sizeof(struct msg_msgseg))
6258 +
6259 +
6260 +-static struct msg_msg *alloc_msg(int len)
6261 ++static struct msg_msg *alloc_msg(size_t len)
6262 + {
6263 + struct msg_msg *msg;
6264 + struct msg_msgseg **pseg;
6265 +- int alen;
6266 ++ size_t alen;
6267 +
6268 + alen = min(len, DATALEN_MSG);
6269 + msg = kmalloc(sizeof(*msg) + alen, GFP_KERNEL);
6270 +@@ -80,12 +80,12 @@ out_err:
6271 + return NULL;
6272 + }
6273 +
6274 +-struct msg_msg *load_msg(const void __user *src, int len)
6275 ++struct msg_msg *load_msg(const void __user *src, size_t len)
6276 + {
6277 + struct msg_msg *msg;
6278 + struct msg_msgseg *seg;
6279 + int err = -EFAULT;
6280 +- int alen;
6281 ++ size_t alen;
6282 +
6283 + msg = alloc_msg(len);
6284 + if (msg == NULL)
6285 +@@ -117,8 +117,8 @@ out_err:
6286 + struct msg_msg *copy_msg(struct msg_msg *src, struct msg_msg *dst)
6287 + {
6288 + struct msg_msgseg *dst_pseg, *src_pseg;
6289 +- int len = src->m_ts;
6290 +- int alen;
6291 ++ size_t len = src->m_ts;
6292 ++ size_t alen;
6293 +
6294 + BUG_ON(dst == NULL);
6295 + if (src->m_ts > dst->m_ts)
6296 +@@ -147,9 +147,9 @@ struct msg_msg *copy_msg(struct msg_msg *src, struct msg_msg *dst)
6297 + return ERR_PTR(-ENOSYS);
6298 + }
6299 + #endif
6300 +-int store_msg(void __user *dest, struct msg_msg *msg, int len)
6301 ++int store_msg(void __user *dest, struct msg_msg *msg, size_t len)
6302 + {
6303 +- int alen;
6304 ++ size_t alen;
6305 + struct msg_msgseg *seg;
6306 +
6307 + alen = min(len, DATALEN_MSG);
6308 +diff --git a/ipc/sem.c b/ipc/sem.c
6309 +index 8c4f59b0..db9d241a 100644
6310 +--- a/ipc/sem.c
6311 ++++ b/ipc/sem.c
6312 +@@ -1282,6 +1282,12 @@ static int semctl_setval(struct ipc_namespace *ns, int semid, int semnum,
6313 +
6314 + sem_lock(sma, NULL, -1);
6315 +
6316 ++ if (sma->sem_perm.deleted) {
6317 ++ sem_unlock(sma, -1);
6318 ++ rcu_read_unlock();
6319 ++ return -EIDRM;
6320 ++ }
6321 ++
6322 + curr = &sma->sem_base[semnum];
6323 +
6324 + ipc_assert_locked_object(&sma->sem_perm);
6325 +@@ -1336,12 +1342,14 @@ static int semctl_main(struct ipc_namespace *ns, int semid, int semnum,
6326 + int i;
6327 +
6328 + sem_lock(sma, NULL, -1);
6329 ++ if (sma->sem_perm.deleted) {
6330 ++ err = -EIDRM;
6331 ++ goto out_unlock;
6332 ++ }
6333 + if(nsems > SEMMSL_FAST) {
6334 + if (!ipc_rcu_getref(sma)) {
6335 +- sem_unlock(sma, -1);
6336 +- rcu_read_unlock();
6337 + err = -EIDRM;
6338 +- goto out_free;
6339 ++ goto out_unlock;
6340 + }
6341 + sem_unlock(sma, -1);
6342 + rcu_read_unlock();
6343 +@@ -1354,10 +1362,8 @@ static int semctl_main(struct ipc_namespace *ns, int semid, int semnum,
6344 + rcu_read_lock();
6345 + sem_lock_and_putref(sma);
6346 + if (sma->sem_perm.deleted) {
6347 +- sem_unlock(sma, -1);
6348 +- rcu_read_unlock();
6349 + err = -EIDRM;
6350 +- goto out_free;
6351 ++ goto out_unlock;
6352 + }
6353 + }
6354 + for (i = 0; i < sma->sem_nsems; i++)
6355 +@@ -1375,8 +1381,8 @@ static int semctl_main(struct ipc_namespace *ns, int semid, int semnum,
6356 + struct sem_undo *un;
6357 +
6358 + if (!ipc_rcu_getref(sma)) {
6359 +- rcu_read_unlock();
6360 +- return -EIDRM;
6361 ++ err = -EIDRM;
6362 ++ goto out_rcu_wakeup;
6363 + }
6364 + rcu_read_unlock();
6365 +
6366 +@@ -1404,10 +1410,8 @@ static int semctl_main(struct ipc_namespace *ns, int semid, int semnum,
6367 + rcu_read_lock();
6368 + sem_lock_and_putref(sma);
6369 + if (sma->sem_perm.deleted) {
6370 +- sem_unlock(sma, -1);
6371 +- rcu_read_unlock();
6372 + err = -EIDRM;
6373 +- goto out_free;
6374 ++ goto out_unlock;
6375 + }
6376 +
6377 + for (i = 0; i < nsems; i++)
6378 +@@ -1431,6 +1435,10 @@ static int semctl_main(struct ipc_namespace *ns, int semid, int semnum,
6379 + goto out_rcu_wakeup;
6380 +
6381 + sem_lock(sma, NULL, -1);
6382 ++ if (sma->sem_perm.deleted) {
6383 ++ err = -EIDRM;
6384 ++ goto out_unlock;
6385 ++ }
6386 + curr = &sma->sem_base[semnum];
6387 +
6388 + switch (cmd) {
6389 +@@ -1836,6 +1844,10 @@ SYSCALL_DEFINE4(semtimedop, int, semid, struct sembuf __user *, tsops,
6390 + if (error)
6391 + goto out_rcu_wakeup;
6392 +
6393 ++ error = -EIDRM;
6394 ++ locknum = sem_lock(sma, sops, nsops);
6395 ++ if (sma->sem_perm.deleted)
6396 ++ goto out_unlock_free;
6397 + /*
6398 + * semid identifiers are not unique - find_alloc_undo may have
6399 + * allocated an undo structure, it was invalidated by an RMID
6400 +@@ -1843,8 +1855,6 @@ SYSCALL_DEFINE4(semtimedop, int, semid, struct sembuf __user *, tsops,
6401 + * This case can be detected checking un->semid. The existence of
6402 + * "un" itself is guaranteed by rcu.
6403 + */
6404 +- error = -EIDRM;
6405 +- locknum = sem_lock(sma, sops, nsops);
6406 + if (un && un->semid == -1)
6407 + goto out_unlock_free;
6408 +
6409 +@@ -2057,6 +2067,12 @@ void exit_sem(struct task_struct *tsk)
6410 + }
6411 +
6412 + sem_lock(sma, NULL, -1);
6413 ++ /* exit_sem raced with IPC_RMID, nothing to do */
6414 ++ if (sma->sem_perm.deleted) {
6415 ++ sem_unlock(sma, -1);
6416 ++ rcu_read_unlock();
6417 ++ continue;
6418 ++ }
6419 + un = __lookup_undo(ulp, semid);
6420 + if (un == NULL) {
6421 + /* exit_sem raced with IPC_RMID+semget() that created
6422 +diff --git a/ipc/util.c b/ipc/util.c
6423 +index fdb8ae74..7684f41b 100644
6424 +--- a/ipc/util.c
6425 ++++ b/ipc/util.c
6426 +@@ -17,12 +17,27 @@
6427 + * Pavel Emelianov <xemul@××××××.org>
6428 + *
6429 + * General sysv ipc locking scheme:
6430 +- * when doing ipc id lookups, take the ids->rwsem
6431 +- * rcu_read_lock()
6432 +- * obtain the ipc object (kern_ipc_perm)
6433 +- * perform security, capabilities, auditing and permission checks, etc.
6434 +- * acquire the ipc lock (kern_ipc_perm.lock) throught ipc_lock_object()
6435 +- * perform data updates (ie: SET, RMID, LOCK/UNLOCK commands)
6436 ++ * rcu_read_lock()
6437 ++ * obtain the ipc object (kern_ipc_perm) by looking up the id in an idr
6438 ++ * tree.
6439 ++ * - perform initial checks (capabilities, auditing and permission,
6440 ++ * etc).
6441 ++ * - perform read-only operations, such as STAT, INFO commands.
6442 ++ * acquire the ipc lock (kern_ipc_perm.lock) through
6443 ++ * ipc_lock_object()
6444 ++ * - perform data updates, such as SET, RMID commands and
6445 ++ * mechanism-specific operations (semop/semtimedop,
6446 ++ * msgsnd/msgrcv, shmat/shmdt).
6447 ++ * drop the ipc lock, through ipc_unlock_object().
6448 ++ * rcu_read_unlock()
6449 ++ *
6450 ++ * The ids->rwsem must be taken when:
6451 ++ * - creating, removing and iterating the existing entries in ipc
6452 ++ * identifier sets.
6453 ++ * - iterating through files under /proc/sysvipc/
6454 ++ *
6455 ++ * Note that sems have a special fast path that avoids kern_ipc_perm.lock -
6456 ++ * see sem_lock().
6457 + */
6458 +
6459 + #include <linux/mm.h>
6460 +diff --git a/ipc/util.h b/ipc/util.h
6461 +index f2f5036f..59d78aa9 100644
6462 +--- a/ipc/util.h
6463 ++++ b/ipc/util.h
6464 +@@ -148,9 +148,9 @@ int ipc_parse_version (int *cmd);
6465 + #endif
6466 +
6467 + extern void free_msg(struct msg_msg *msg);
6468 +-extern struct msg_msg *load_msg(const void __user *src, int len);
6469 ++extern struct msg_msg *load_msg(const void __user *src, size_t len);
6470 + extern struct msg_msg *copy_msg(struct msg_msg *src, struct msg_msg *dst);
6471 +-extern int store_msg(void __user *dest, struct msg_msg *msg, int len);
6472 ++extern int store_msg(void __user *dest, struct msg_msg *msg, size_t len);
6473 +
6474 + extern void recompute_msgmni(struct ipc_namespace *);
6475 +
6476 +diff --git a/kernel/audit.c b/kernel/audit.c
6477 +index 7b0e23a7..7ddfd8a0 100644
6478 +--- a/kernel/audit.c
6479 ++++ b/kernel/audit.c
6480 +@@ -613,7 +613,7 @@ static int audit_log_common_recv_msg(struct audit_buffer **ab, u16 msg_type)
6481 + int rc = 0;
6482 + uid_t uid = from_kuid(&init_user_ns, current_uid());
6483 +
6484 +- if (!audit_enabled) {
6485 ++ if (!audit_enabled && msg_type != AUDIT_USER_AVC) {
6486 + *ab = NULL;
6487 + return rc;
6488 + }
6489 +@@ -659,6 +659,7 @@ static int audit_receive_msg(struct sk_buff *skb, struct nlmsghdr *nlh)
6490 +
6491 + switch (msg_type) {
6492 + case AUDIT_GET:
6493 ++ status_set.mask = 0;
6494 + status_set.enabled = audit_enabled;
6495 + status_set.failure = audit_failure;
6496 + status_set.pid = audit_pid;
6497 +@@ -670,7 +671,7 @@ static int audit_receive_msg(struct sk_buff *skb, struct nlmsghdr *nlh)
6498 + &status_set, sizeof(status_set));
6499 + break;
6500 + case AUDIT_SET:
6501 +- if (nlh->nlmsg_len < sizeof(struct audit_status))
6502 ++ if (nlmsg_len(nlh) < sizeof(struct audit_status))
6503 + return -EINVAL;
6504 + status_get = (struct audit_status *)data;
6505 + if (status_get->mask & AUDIT_STATUS_ENABLED) {
6506 +@@ -832,7 +833,7 @@ static int audit_receive_msg(struct sk_buff *skb, struct nlmsghdr *nlh)
6507 +
6508 + memset(&s, 0, sizeof(s));
6509 + /* guard against past and future API changes */
6510 +- memcpy(&s, data, min(sizeof(s), (size_t)nlh->nlmsg_len));
6511 ++ memcpy(&s, data, min_t(size_t, sizeof(s), nlmsg_len(nlh)));
6512 + if ((s.enabled != 0 && s.enabled != 1) ||
6513 + (s.log_passwd != 0 && s.log_passwd != 1))
6514 + return -EINVAL;
6515 +@@ -1536,6 +1537,26 @@ void audit_log_name(struct audit_context *context, struct audit_names *n,
6516 + }
6517 + }
6518 +
6519 ++ /* log the audit_names record type */
6520 ++ audit_log_format(ab, " nametype=");
6521 ++ switch(n->type) {
6522 ++ case AUDIT_TYPE_NORMAL:
6523 ++ audit_log_format(ab, "NORMAL");
6524 ++ break;
6525 ++ case AUDIT_TYPE_PARENT:
6526 ++ audit_log_format(ab, "PARENT");
6527 ++ break;
6528 ++ case AUDIT_TYPE_CHILD_DELETE:
6529 ++ audit_log_format(ab, "DELETE");
6530 ++ break;
6531 ++ case AUDIT_TYPE_CHILD_CREATE:
6532 ++ audit_log_format(ab, "CREATE");
6533 ++ break;
6534 ++ default:
6535 ++ audit_log_format(ab, "UNKNOWN");
6536 ++ break;
6537 ++ }
6538 ++
6539 + audit_log_fcaps(ab, n);
6540 + audit_log_end(ab);
6541 + }
6542 +diff --git a/kernel/audit.h b/kernel/audit.h
6543 +index 1c95131e..123c9b7c 100644
6544 +--- a/kernel/audit.h
6545 ++++ b/kernel/audit.h
6546 +@@ -85,6 +85,7 @@ struct audit_names {
6547 +
6548 + struct filename *name;
6549 + int name_len; /* number of chars to log */
6550 ++ bool hidden; /* don't log this record */
6551 + bool name_put; /* call __putname()? */
6552 +
6553 + unsigned long ino;
6554 +diff --git a/kernel/auditsc.c b/kernel/auditsc.c
6555 +index 3c8a6013..9845cb32 100644
6556 +--- a/kernel/auditsc.c
6557 ++++ b/kernel/auditsc.c
6558 +@@ -1399,8 +1399,11 @@ static void audit_log_exit(struct audit_context *context, struct task_struct *ts
6559 + }
6560 +
6561 + i = 0;
6562 +- list_for_each_entry(n, &context->names_list, list)
6563 ++ list_for_each_entry(n, &context->names_list, list) {
6564 ++ if (n->hidden)
6565 ++ continue;
6566 + audit_log_name(context, n, NULL, i++, &call_panic);
6567 ++ }
6568 +
6569 + /* Send end of event record to help user space know we are finished */
6570 + ab = audit_log_start(context, GFP_KERNEL, AUDIT_EOE);
6571 +@@ -1769,14 +1772,15 @@ void audit_putname(struct filename *name)
6572 + * __audit_inode - store the inode and device from a lookup
6573 + * @name: name being audited
6574 + * @dentry: dentry being audited
6575 +- * @parent: does this dentry represent the parent?
6576 ++ * @flags: attributes for this particular entry
6577 + */
6578 + void __audit_inode(struct filename *name, const struct dentry *dentry,
6579 +- unsigned int parent)
6580 ++ unsigned int flags)
6581 + {
6582 + struct audit_context *context = current->audit_context;
6583 + const struct inode *inode = dentry->d_inode;
6584 + struct audit_names *n;
6585 ++ bool parent = flags & AUDIT_INODE_PARENT;
6586 +
6587 + if (!context->in_syscall)
6588 + return;
6589 +@@ -1831,6 +1835,8 @@ out:
6590 + if (parent) {
6591 + n->name_len = n->name ? parent_len(n->name->name) : AUDIT_NAME_FULL;
6592 + n->type = AUDIT_TYPE_PARENT;
6593 ++ if (flags & AUDIT_INODE_HIDDEN)
6594 ++ n->hidden = true;
6595 + } else {
6596 + n->name_len = AUDIT_NAME_FULL;
6597 + n->type = AUDIT_TYPE_NORMAL;
6598 +diff --git a/kernel/cgroup.c b/kernel/cgroup.c
6599 +index b6b26faf..d0def7fc 100644
6600 +--- a/kernel/cgroup.c
6601 ++++ b/kernel/cgroup.c
6602 +@@ -92,6 +92,14 @@ static DEFINE_MUTEX(cgroup_mutex);
6603 + static DEFINE_MUTEX(cgroup_root_mutex);
6604 +
6605 + /*
6606 ++ * cgroup destruction makes heavy use of work items and there can be a lot
6607 ++ * of concurrent destructions. Use a separate workqueue so that cgroup
6608 ++ * destruction work items don't end up filling up max_active of system_wq
6609 ++ * which may lead to deadlock.
6610 ++ */
6611 ++static struct workqueue_struct *cgroup_destroy_wq;
6612 ++
6613 ++/*
6614 + * Generate an array of cgroup subsystem pointers. At boot time, this is
6615 + * populated with the built in subsystems, and modular subsystems are
6616 + * registered after that. The mutable section of this array is protected by
6617 +@@ -873,7 +881,7 @@ static void cgroup_free_rcu(struct rcu_head *head)
6618 + {
6619 + struct cgroup *cgrp = container_of(head, struct cgroup, rcu_head);
6620 +
6621 +- schedule_work(&cgrp->free_work);
6622 ++ queue_work(cgroup_destroy_wq, &cgrp->free_work);
6623 + }
6624 +
6625 + static void cgroup_diput(struct dentry *dentry, struct inode *inode)
6626 +@@ -4686,6 +4694,22 @@ out:
6627 + return err;
6628 + }
6629 +
6630 ++static int __init cgroup_wq_init(void)
6631 ++{
6632 ++ /*
6633 ++ * There isn't much point in executing destruction path in
6634 ++ * parallel. Good chunk is serialized with cgroup_mutex anyway.
6635 ++ * Use 1 for @max_active.
6636 ++ *
6637 ++ * We would prefer to do this in cgroup_init() above, but that
6638 ++ * is called before init_workqueues(): so leave this until after.
6639 ++ */
6640 ++ cgroup_destroy_wq = alloc_workqueue("cgroup_destroy", 0, 1);
6641 ++ BUG_ON(!cgroup_destroy_wq);
6642 ++ return 0;
6643 ++}
6644 ++core_initcall(cgroup_wq_init);
6645 ++
6646 + /*
6647 + * proc_cgroup_show()
6648 + * - Print task's cgroup paths into seq_file, one line for each hierarchy
6649 +@@ -4996,7 +5020,7 @@ void __css_put(struct cgroup_subsys_state *css)
6650 +
6651 + v = css_unbias_refcnt(atomic_dec_return(&css->refcnt));
6652 + if (v == 0)
6653 +- schedule_work(&css->dput_work);
6654 ++ queue_work(cgroup_destroy_wq, &css->dput_work);
6655 + }
6656 + EXPORT_SYMBOL_GPL(__css_put);
6657 +
6658 +diff --git a/kernel/cpuset.c b/kernel/cpuset.c
6659 +index 6948e947..d313870d 100644
6660 +--- a/kernel/cpuset.c
6661 ++++ b/kernel/cpuset.c
6662 +@@ -984,8 +984,10 @@ static void cpuset_change_task_nodemask(struct task_struct *tsk,
6663 + need_loop = task_has_mempolicy(tsk) ||
6664 + !nodes_intersects(*newmems, tsk->mems_allowed);
6665 +
6666 +- if (need_loop)
6667 ++ if (need_loop) {
6668 ++ local_irq_disable();
6669 + write_seqcount_begin(&tsk->mems_allowed_seq);
6670 ++ }
6671 +
6672 + nodes_or(tsk->mems_allowed, tsk->mems_allowed, *newmems);
6673 + mpol_rebind_task(tsk, newmems, MPOL_REBIND_STEP1);
6674 +@@ -993,8 +995,10 @@ static void cpuset_change_task_nodemask(struct task_struct *tsk,
6675 + mpol_rebind_task(tsk, newmems, MPOL_REBIND_STEP2);
6676 + tsk->mems_allowed = *newmems;
6677 +
6678 +- if (need_loop)
6679 ++ if (need_loop) {
6680 + write_seqcount_end(&tsk->mems_allowed_seq);
6681 ++ local_irq_enable();
6682 ++ }
6683 +
6684 + task_unlock(tsk);
6685 + }
6686 +diff --git a/kernel/power/snapshot.c b/kernel/power/snapshot.c
6687 +index 0de28576..91c04f16 100644
6688 +--- a/kernel/power/snapshot.c
6689 ++++ b/kernel/power/snapshot.c
6690 +@@ -1398,7 +1398,11 @@ int hibernate_preallocate_memory(void)
6691 + * highmem and non-highmem zones separately.
6692 + */
6693 + pages_highmem = preallocate_image_highmem(highmem / 2);
6694 +- alloc = (count - max_size) - pages_highmem;
6695 ++ alloc = count - max_size;
6696 ++ if (alloc > pages_highmem)
6697 ++ alloc -= pages_highmem;
6698 ++ else
6699 ++ alloc = 0;
6700 + pages = preallocate_image_memory(alloc, avail_normal);
6701 + if (pages < alloc) {
6702 + /* We have exhausted non-highmem pages, try highmem. */
6703 +diff --git a/kernel/time/alarmtimer.c b/kernel/time/alarmtimer.c
6704 +index f11d83b1..a8f5084d 100644
6705 +--- a/kernel/time/alarmtimer.c
6706 ++++ b/kernel/time/alarmtimer.c
6707 +@@ -445,7 +445,7 @@ static int alarm_clock_getres(const clockid_t which_clock, struct timespec *tp)
6708 + clockid_t baseid = alarm_bases[clock2alarm(which_clock)].base_clockid;
6709 +
6710 + if (!alarmtimer_get_rtcdev())
6711 +- return -ENOTSUPP;
6712 ++ return -EINVAL;
6713 +
6714 + return hrtimer_get_res(baseid, tp);
6715 + }
6716 +@@ -462,7 +462,7 @@ static int alarm_clock_get(clockid_t which_clock, struct timespec *tp)
6717 + struct alarm_base *base = &alarm_bases[clock2alarm(which_clock)];
6718 +
6719 + if (!alarmtimer_get_rtcdev())
6720 +- return -ENOTSUPP;
6721 ++ return -EINVAL;
6722 +
6723 + *tp = ktime_to_timespec(base->gettime());
6724 + return 0;
6725 +diff --git a/kernel/trace/ftrace.c b/kernel/trace/ftrace.c
6726 +index f23449d0..331c1021 100644
6727 +--- a/kernel/trace/ftrace.c
6728 ++++ b/kernel/trace/ftrace.c
6729 +@@ -367,9 +367,6 @@ static int remove_ftrace_list_ops(struct ftrace_ops **list,
6730 +
6731 + static int __register_ftrace_function(struct ftrace_ops *ops)
6732 + {
6733 +- if (unlikely(ftrace_disabled))
6734 +- return -ENODEV;
6735 +-
6736 + if (FTRACE_WARN_ON(ops == &global_ops))
6737 + return -EINVAL;
6738 +
6739 +@@ -417,9 +414,6 @@ static int __unregister_ftrace_function(struct ftrace_ops *ops)
6740 + {
6741 + int ret;
6742 +
6743 +- if (ftrace_disabled)
6744 +- return -ENODEV;
6745 +-
6746 + if (WARN_ON(!(ops->flags & FTRACE_OPS_FL_ENABLED)))
6747 + return -EBUSY;
6748 +
6749 +@@ -2048,10 +2042,15 @@ static void ftrace_startup_enable(int command)
6750 + static int ftrace_startup(struct ftrace_ops *ops, int command)
6751 + {
6752 + bool hash_enable = true;
6753 ++ int ret;
6754 +
6755 + if (unlikely(ftrace_disabled))
6756 + return -ENODEV;
6757 +
6758 ++ ret = __register_ftrace_function(ops);
6759 ++ if (ret)
6760 ++ return ret;
6761 ++
6762 + ftrace_start_up++;
6763 + command |= FTRACE_UPDATE_CALLS;
6764 +
6765 +@@ -2073,12 +2072,17 @@ static int ftrace_startup(struct ftrace_ops *ops, int command)
6766 + return 0;
6767 + }
6768 +
6769 +-static void ftrace_shutdown(struct ftrace_ops *ops, int command)
6770 ++static int ftrace_shutdown(struct ftrace_ops *ops, int command)
6771 + {
6772 + bool hash_disable = true;
6773 ++ int ret;
6774 +
6775 + if (unlikely(ftrace_disabled))
6776 +- return;
6777 ++ return -ENODEV;
6778 ++
6779 ++ ret = __unregister_ftrace_function(ops);
6780 ++ if (ret)
6781 ++ return ret;
6782 +
6783 + ftrace_start_up--;
6784 + /*
6785 +@@ -2113,9 +2117,10 @@ static void ftrace_shutdown(struct ftrace_ops *ops, int command)
6786 + }
6787 +
6788 + if (!command || !ftrace_enabled)
6789 +- return;
6790 ++ return 0;
6791 +
6792 + ftrace_run_update_code(command);
6793 ++ return 0;
6794 + }
6795 +
6796 + static void ftrace_startup_sysctl(void)
6797 +@@ -3020,16 +3025,13 @@ static void __enable_ftrace_function_probe(void)
6798 + if (i == FTRACE_FUNC_HASHSIZE)
6799 + return;
6800 +
6801 +- ret = __register_ftrace_function(&trace_probe_ops);
6802 +- if (!ret)
6803 +- ret = ftrace_startup(&trace_probe_ops, 0);
6804 ++ ret = ftrace_startup(&trace_probe_ops, 0);
6805 +
6806 + ftrace_probe_registered = 1;
6807 + }
6808 +
6809 + static void __disable_ftrace_function_probe(void)
6810 + {
6811 +- int ret;
6812 + int i;
6813 +
6814 + if (!ftrace_probe_registered)
6815 +@@ -3042,9 +3044,7 @@ static void __disable_ftrace_function_probe(void)
6816 + }
6817 +
6818 + /* no more funcs left */
6819 +- ret = __unregister_ftrace_function(&trace_probe_ops);
6820 +- if (!ret)
6821 +- ftrace_shutdown(&trace_probe_ops, 0);
6822 ++ ftrace_shutdown(&trace_probe_ops, 0);
6823 +
6824 + ftrace_probe_registered = 0;
6825 + }
6826 +@@ -4241,12 +4241,15 @@ core_initcall(ftrace_nodyn_init);
6827 + static inline int ftrace_init_dyn_debugfs(struct dentry *d_tracer) { return 0; }
6828 + static inline void ftrace_startup_enable(int command) { }
6829 + /* Keep as macros so we do not need to define the commands */
6830 +-# define ftrace_startup(ops, command) \
6831 +- ({ \
6832 +- (ops)->flags |= FTRACE_OPS_FL_ENABLED; \
6833 +- 0; \
6834 ++# define ftrace_startup(ops, command) \
6835 ++ ({ \
6836 ++ int ___ret = __register_ftrace_function(ops); \
6837 ++ if (!___ret) \
6838 ++ (ops)->flags |= FTRACE_OPS_FL_ENABLED; \
6839 ++ ___ret; \
6840 + })
6841 +-# define ftrace_shutdown(ops, command) do { } while (0)
6842 ++# define ftrace_shutdown(ops, command) __unregister_ftrace_function(ops)
6843 ++
6844 + # define ftrace_startup_sysctl() do { } while (0)
6845 + # define ftrace_shutdown_sysctl() do { } while (0)
6846 +
6847 +@@ -4646,9 +4649,7 @@ int register_ftrace_function(struct ftrace_ops *ops)
6848 +
6849 + mutex_lock(&ftrace_lock);
6850 +
6851 +- ret = __register_ftrace_function(ops);
6852 +- if (!ret)
6853 +- ret = ftrace_startup(ops, 0);
6854 ++ ret = ftrace_startup(ops, 0);
6855 +
6856 + mutex_unlock(&ftrace_lock);
6857 +
6858 +@@ -4667,9 +4668,7 @@ int unregister_ftrace_function(struct ftrace_ops *ops)
6859 + int ret;
6860 +
6861 + mutex_lock(&ftrace_lock);
6862 +- ret = __unregister_ftrace_function(ops);
6863 +- if (!ret)
6864 +- ftrace_shutdown(ops, 0);
6865 ++ ret = ftrace_shutdown(ops, 0);
6866 + mutex_unlock(&ftrace_lock);
6867 +
6868 + return ret;
6869 +@@ -4863,6 +4862,13 @@ ftrace_suspend_notifier_call(struct notifier_block *bl, unsigned long state,
6870 + return NOTIFY_DONE;
6871 + }
6872 +
6873 ++/* Just a place holder for function graph */
6874 ++static struct ftrace_ops fgraph_ops __read_mostly = {
6875 ++ .func = ftrace_stub,
6876 ++ .flags = FTRACE_OPS_FL_STUB | FTRACE_OPS_FL_GLOBAL |
6877 ++ FTRACE_OPS_FL_RECURSION_SAFE,
6878 ++};
6879 ++
6880 + int register_ftrace_graph(trace_func_graph_ret_t retfunc,
6881 + trace_func_graph_ent_t entryfunc)
6882 + {
6883 +@@ -4889,7 +4895,7 @@ int register_ftrace_graph(trace_func_graph_ret_t retfunc,
6884 + ftrace_graph_return = retfunc;
6885 + ftrace_graph_entry = entryfunc;
6886 +
6887 +- ret = ftrace_startup(&global_ops, FTRACE_START_FUNC_RET);
6888 ++ ret = ftrace_startup(&fgraph_ops, FTRACE_START_FUNC_RET);
6889 +
6890 + out:
6891 + mutex_unlock(&ftrace_lock);
6892 +@@ -4906,7 +4912,7 @@ void unregister_ftrace_graph(void)
6893 + ftrace_graph_active--;
6894 + ftrace_graph_return = (trace_func_graph_ret_t)ftrace_stub;
6895 + ftrace_graph_entry = ftrace_graph_entry_stub;
6896 +- ftrace_shutdown(&global_ops, FTRACE_STOP_FUNC_RET);
6897 ++ ftrace_shutdown(&fgraph_ops, FTRACE_STOP_FUNC_RET);
6898 + unregister_pm_notifier(&ftrace_suspend_notifier);
6899 + unregister_trace_sched_switch(ftrace_graph_probe_sched_switch, NULL);
6900 +
6901 +diff --git a/kernel/workqueue.c b/kernel/workqueue.c
6902 +index e52d002d..68086a34 100644
6903 +--- a/kernel/workqueue.c
6904 ++++ b/kernel/workqueue.c
6905 +@@ -295,6 +295,9 @@ static DEFINE_HASHTABLE(unbound_pool_hash, UNBOUND_POOL_HASH_ORDER);
6906 + /* I: attributes used when instantiating standard unbound pools on demand */
6907 + static struct workqueue_attrs *unbound_std_wq_attrs[NR_STD_WORKER_POOLS];
6908 +
6909 ++/* I: attributes used when instantiating ordered pools on demand */
6910 ++static struct workqueue_attrs *ordered_wq_attrs[NR_STD_WORKER_POOLS];
6911 ++
6912 + struct workqueue_struct *system_wq __read_mostly;
6913 + EXPORT_SYMBOL(system_wq);
6914 + struct workqueue_struct *system_highpri_wq __read_mostly;
6915 +@@ -4059,7 +4062,7 @@ out_unlock:
6916 + static int alloc_and_link_pwqs(struct workqueue_struct *wq)
6917 + {
6918 + bool highpri = wq->flags & WQ_HIGHPRI;
6919 +- int cpu;
6920 ++ int cpu, ret;
6921 +
6922 + if (!(wq->flags & WQ_UNBOUND)) {
6923 + wq->cpu_pwqs = alloc_percpu(struct pool_workqueue);
6924 +@@ -4079,6 +4082,13 @@ static int alloc_and_link_pwqs(struct workqueue_struct *wq)
6925 + mutex_unlock(&wq->mutex);
6926 + }
6927 + return 0;
6928 ++ } else if (wq->flags & __WQ_ORDERED) {
6929 ++ ret = apply_workqueue_attrs(wq, ordered_wq_attrs[highpri]);
6930 ++ /* there should only be single pwq for ordering guarantee */
6931 ++ WARN(!ret && (wq->pwqs.next != &wq->dfl_pwq->pwqs_node ||
6932 ++ wq->pwqs.prev != &wq->dfl_pwq->pwqs_node),
6933 ++ "ordering guarantee broken for workqueue %s\n", wq->name);
6934 ++ return ret;
6935 + } else {
6936 + return apply_workqueue_attrs(wq, unbound_std_wq_attrs[highpri]);
6937 + }
6938 +@@ -4990,13 +5000,23 @@ static int __init init_workqueues(void)
6939 + }
6940 + }
6941 +
6942 +- /* create default unbound wq attrs */
6943 ++ /* create default unbound and ordered wq attrs */
6944 + for (i = 0; i < NR_STD_WORKER_POOLS; i++) {
6945 + struct workqueue_attrs *attrs;
6946 +
6947 + BUG_ON(!(attrs = alloc_workqueue_attrs(GFP_KERNEL)));
6948 + attrs->nice = std_nice[i];
6949 + unbound_std_wq_attrs[i] = attrs;
6950 ++
6951 ++ /*
6952 ++ * An ordered wq should have only one pwq as ordering is
6953 ++ * guaranteed by max_active which is enforced by pwqs.
6954 ++ * Turn off NUMA so that dfl_pwq is used for all nodes.
6955 ++ */
6956 ++ BUG_ON(!(attrs = alloc_workqueue_attrs(GFP_KERNEL)));
6957 ++ attrs->nice = std_nice[i];
6958 ++ attrs->no_numa = true;
6959 ++ ordered_wq_attrs[i] = attrs;
6960 + }
6961 +
6962 + system_wq = alloc_workqueue("events", 0, 0);
6963 +diff --git a/lib/vsprintf.c b/lib/vsprintf.c
6964 +index e149c641..620fae4c 100644
6965 +--- a/lib/vsprintf.c
6966 ++++ b/lib/vsprintf.c
6967 +@@ -26,6 +26,7 @@
6968 + #include <linux/math64.h>
6969 + #include <linux/uaccess.h>
6970 + #include <linux/ioport.h>
6971 ++#include <linux/cred.h>
6972 + #include <net/addrconf.h>
6973 +
6974 + #include <asm/page.h> /* for PAGE_SIZE */
6975 +@@ -1118,11 +1119,37 @@ char *pointer(const char *fmt, char *buf, char *end, void *ptr,
6976 + spec.field_width = default_width;
6977 + return string(buf, end, "pK-error", spec);
6978 + }
6979 +- if (!((kptr_restrict == 0) ||
6980 +- (kptr_restrict == 1 &&
6981 +- has_capability_noaudit(current, CAP_SYSLOG))))
6982 ++
6983 ++ switch (kptr_restrict) {
6984 ++ case 0:
6985 ++ /* Always print %pK values */
6986 ++ break;
6987 ++ case 1: {
6988 ++ /*
6989 ++ * Only print the real pointer value if the current
6990 ++ * process has CAP_SYSLOG and is running with the
6991 ++ * same credentials it started with. This is because
6992 ++ * access to files is checked at open() time, but %pK
6993 ++ * checks permission at read() time. We don't want to
6994 ++ * leak pointer values if a binary opens a file using
6995 ++ * %pK and then elevates privileges before reading it.
6996 ++ */
6997 ++ const struct cred *cred = current_cred();
6998 ++
6999 ++ if (!has_capability_noaudit(current, CAP_SYSLOG) ||
7000 ++ !uid_eq(cred->euid, cred->uid) ||
7001 ++ !gid_eq(cred->egid, cred->gid))
7002 ++ ptr = NULL;
7003 ++ break;
7004 ++ }
7005 ++ case 2:
7006 ++ default:
7007 ++ /* Always print 0's for %pK */
7008 + ptr = NULL;
7009 ++ break;
7010 ++ }
7011 + break;
7012 ++
7013 + case 'N':
7014 + switch (fmt[1]) {
7015 + case 'F':
7016 +diff --git a/mm/mmap.c b/mm/mmap.c
7017 +index 8d25fdc6..8f87b14c 100644
7018 +--- a/mm/mmap.c
7019 ++++ b/mm/mmap.c
7020 +@@ -1853,7 +1853,7 @@ arch_get_unmapped_area(struct file *filp, unsigned long addr,
7021 + struct vm_area_struct *vma;
7022 + struct vm_unmapped_area_info info;
7023 +
7024 +- if (len > TASK_SIZE)
7025 ++ if (len > TASK_SIZE - mmap_min_addr)
7026 + return -ENOMEM;
7027 +
7028 + if (flags & MAP_FIXED)
7029 +@@ -1862,7 +1862,7 @@ arch_get_unmapped_area(struct file *filp, unsigned long addr,
7030 + if (addr) {
7031 + addr = PAGE_ALIGN(addr);
7032 + vma = find_vma(mm, addr);
7033 +- if (TASK_SIZE - len >= addr &&
7034 ++ if (TASK_SIZE - len >= addr && addr >= mmap_min_addr &&
7035 + (!vma || addr + len <= vma->vm_start))
7036 + return addr;
7037 + }
7038 +@@ -1901,7 +1901,7 @@ arch_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
7039 + struct vm_unmapped_area_info info;
7040 +
7041 + /* requested length too big for entire address space */
7042 +- if (len > TASK_SIZE)
7043 ++ if (len > TASK_SIZE - mmap_min_addr)
7044 + return -ENOMEM;
7045 +
7046 + if (flags & MAP_FIXED)
7047 +@@ -1911,14 +1911,14 @@ arch_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
7048 + if (addr) {
7049 + addr = PAGE_ALIGN(addr);
7050 + vma = find_vma(mm, addr);
7051 +- if (TASK_SIZE - len >= addr &&
7052 ++ if (TASK_SIZE - len >= addr && addr >= mmap_min_addr &&
7053 + (!vma || addr + len <= vma->vm_start))
7054 + return addr;
7055 + }
7056 +
7057 + info.flags = VM_UNMAPPED_AREA_TOPDOWN;
7058 + info.length = len;
7059 +- info.low_limit = PAGE_SIZE;
7060 ++ info.low_limit = max(PAGE_SIZE, mmap_min_addr);
7061 + info.high_limit = mm->mmap_base;
7062 + info.align_mask = 0;
7063 + addr = vm_unmapped_area(&info);
7064 +diff --git a/net/9p/trans_virtio.c b/net/9p/trans_virtio.c
7065 +index e1c26b10..990afab2 100644
7066 +--- a/net/9p/trans_virtio.c
7067 ++++ b/net/9p/trans_virtio.c
7068 +@@ -577,6 +577,10 @@ static int p9_virtio_probe(struct virtio_device *vdev)
7069 + mutex_lock(&virtio_9p_lock);
7070 + list_add_tail(&chan->chan_list, &virtio_chan_list);
7071 + mutex_unlock(&virtio_9p_lock);
7072 ++
7073 ++ /* Let udev rules use the new mount_tag attribute. */
7074 ++ kobject_uevent(&(vdev->dev.kobj), KOBJ_CHANGE);
7075 ++
7076 + return 0;
7077 +
7078 + out_free_tag:
7079 +@@ -654,6 +658,7 @@ static void p9_virtio_remove(struct virtio_device *vdev)
7080 + list_del(&chan->chan_list);
7081 + mutex_unlock(&virtio_9p_lock);
7082 + sysfs_remove_file(&(vdev->dev.kobj), &dev_attr_mount_tag.attr);
7083 ++ kobject_uevent(&(vdev->dev.kobj), KOBJ_CHANGE);
7084 + kfree(chan->tag);
7085 + kfree(chan->vc_wq);
7086 + kfree(chan);
7087 +diff --git a/net/wireless/scan.c b/net/wireless/scan.c
7088 +index fd99ea49..81019ee3 100644
7089 +--- a/net/wireless/scan.c
7090 ++++ b/net/wireless/scan.c
7091 +@@ -253,10 +253,10 @@ void __cfg80211_sched_scan_results(struct work_struct *wk)
7092 + rdev = container_of(wk, struct cfg80211_registered_device,
7093 + sched_scan_results_wk);
7094 +
7095 +- request = rdev->sched_scan_req;
7096 +-
7097 + mutex_lock(&rdev->sched_scan_mtx);
7098 +
7099 ++ request = rdev->sched_scan_req;
7100 ++
7101 + /* we don't have sched_scan_req anymore if the scan is stopping */
7102 + if (request) {
7103 + if (request->flags & NL80211_SCAN_FLAG_FLUSH) {
7104 +diff --git a/security/selinux/netlabel.c b/security/selinux/netlabel.c
7105 +index da4b8b23..6235d052 100644
7106 +--- a/security/selinux/netlabel.c
7107 ++++ b/security/selinux/netlabel.c
7108 +@@ -442,8 +442,7 @@ int selinux_netlbl_socket_connect(struct sock *sk, struct sockaddr *addr)
7109 + sksec->nlbl_state != NLBL_CONNLABELED)
7110 + return 0;
7111 +
7112 +- local_bh_disable();
7113 +- bh_lock_sock_nested(sk);
7114 ++ lock_sock(sk);
7115 +
7116 + /* connected sockets are allowed to disconnect when the address family
7117 + * is set to AF_UNSPEC, if that is what is happening we want to reset
7118 +@@ -464,7 +463,6 @@ int selinux_netlbl_socket_connect(struct sock *sk, struct sockaddr *addr)
7119 + sksec->nlbl_state = NLBL_CONNLABELED;
7120 +
7121 + socket_connect_return:
7122 +- bh_unlock_sock(sk);
7123 +- local_bh_enable();
7124 ++ release_sock(sk);
7125 + return rc;
7126 + }
7127 +diff --git a/sound/pci/hda/hda_generic.c b/sound/pci/hda/hda_generic.c
7128 +index 26ed56f0..79750313 100644
7129 +--- a/sound/pci/hda/hda_generic.c
7130 ++++ b/sound/pci/hda/hda_generic.c
7131 +@@ -2445,12 +2445,8 @@ static int create_out_jack_modes(struct hda_codec *codec, int num_pins,
7132 +
7133 + for (i = 0; i < num_pins; i++) {
7134 + hda_nid_t pin = pins[i];
7135 +- if (pin == spec->hp_mic_pin) {
7136 +- int ret = create_hp_mic_jack_mode(codec, pin);
7137 +- if (ret < 0)
7138 +- return ret;
7139 ++ if (pin == spec->hp_mic_pin)
7140 + continue;
7141 +- }
7142 + if (get_out_jack_num_items(codec, pin) > 1) {
7143 + struct snd_kcontrol_new *knew;
7144 + char name[44];
7145 +@@ -2703,7 +2699,7 @@ static int hp_mic_jack_mode_put(struct snd_kcontrol *kcontrol,
7146 + val &= ~(AC_PINCTL_VREFEN | PIN_HP);
7147 + val |= get_vref_idx(vref_caps, idx) | PIN_IN;
7148 + } else
7149 +- val = snd_hda_get_default_vref(codec, nid);
7150 ++ val = snd_hda_get_default_vref(codec, nid) | PIN_IN;
7151 + }
7152 + snd_hda_set_pin_ctl_cache(codec, nid, val);
7153 + call_hp_automute(codec, NULL);
7154 +@@ -2723,9 +2719,6 @@ static int create_hp_mic_jack_mode(struct hda_codec *codec, hda_nid_t pin)
7155 + struct hda_gen_spec *spec = codec->spec;
7156 + struct snd_kcontrol_new *knew;
7157 +
7158 +- if (get_out_jack_num_items(codec, pin) <= 1 &&
7159 +- get_in_jack_num_items(codec, pin) <= 1)
7160 +- return 0; /* no need */
7161 + knew = snd_hda_gen_add_kctl(spec, "Headphone Mic Jack Mode",
7162 + &hp_mic_jack_mode_enum);
7163 + if (!knew)
7164 +@@ -2754,6 +2747,42 @@ static int add_loopback_list(struct hda_gen_spec *spec, hda_nid_t mix, int idx)
7165 + return 0;
7166 + }
7167 +
7168 ++/* return true if either a volume or a mute amp is found for the given
7169 ++ * aamix path; the amp has to be either in the mixer node or its direct leaf
7170 ++ */
7171 ++static bool look_for_mix_leaf_ctls(struct hda_codec *codec, hda_nid_t mix_nid,
7172 ++ hda_nid_t pin, unsigned int *mix_val,
7173 ++ unsigned int *mute_val)
7174 ++{
7175 ++ int idx, num_conns;
7176 ++ const hda_nid_t *list;
7177 ++ hda_nid_t nid;
7178 ++
7179 ++ idx = snd_hda_get_conn_index(codec, mix_nid, pin, true);
7180 ++ if (idx < 0)
7181 ++ return false;
7182 ++
7183 ++ *mix_val = *mute_val = 0;
7184 ++ if (nid_has_volume(codec, mix_nid, HDA_INPUT))
7185 ++ *mix_val = HDA_COMPOSE_AMP_VAL(mix_nid, 3, idx, HDA_INPUT);
7186 ++ if (nid_has_mute(codec, mix_nid, HDA_INPUT))
7187 ++ *mute_val = HDA_COMPOSE_AMP_VAL(mix_nid, 3, idx, HDA_INPUT);
7188 ++ if (*mix_val && *mute_val)
7189 ++ return true;
7190 ++
7191 ++ /* check leaf node */
7192 ++ num_conns = snd_hda_get_conn_list(codec, mix_nid, &list);
7193 ++ if (num_conns < idx)
7194 ++ return false;
7195 ++ nid = list[idx];
7196 ++ if (!*mix_val && nid_has_volume(codec, nid, HDA_OUTPUT))
7197 ++ *mix_val = HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT);
7198 ++ if (!*mute_val && nid_has_mute(codec, nid, HDA_OUTPUT))
7199 ++ *mute_val = HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT);
7200 ++
7201 ++ return *mix_val || *mute_val;
7202 ++}
7203 ++
7204 + /* create input playback/capture controls for the given pin */
7205 + static int new_analog_input(struct hda_codec *codec, int input_idx,
7206 + hda_nid_t pin, const char *ctlname, int ctlidx,
7207 +@@ -2761,12 +2790,11 @@ static int new_analog_input(struct hda_codec *codec, int input_idx,
7208 + {
7209 + struct hda_gen_spec *spec = codec->spec;
7210 + struct nid_path *path;
7211 +- unsigned int val;
7212 ++ unsigned int mix_val, mute_val;
7213 + int err, idx;
7214 +
7215 +- if (!nid_has_volume(codec, mix_nid, HDA_INPUT) &&
7216 +- !nid_has_mute(codec, mix_nid, HDA_INPUT))
7217 +- return 0; /* no need for analog loopback */
7218 ++ if (!look_for_mix_leaf_ctls(codec, mix_nid, pin, &mix_val, &mute_val))
7219 ++ return 0;
7220 +
7221 + path = snd_hda_add_new_path(codec, pin, mix_nid, 0);
7222 + if (!path)
7223 +@@ -2775,20 +2803,18 @@ static int new_analog_input(struct hda_codec *codec, int input_idx,
7224 + spec->loopback_paths[input_idx] = snd_hda_get_path_idx(codec, path);
7225 +
7226 + idx = path->idx[path->depth - 1];
7227 +- if (nid_has_volume(codec, mix_nid, HDA_INPUT)) {
7228 +- val = HDA_COMPOSE_AMP_VAL(mix_nid, 3, idx, HDA_INPUT);
7229 +- err = __add_pb_vol_ctrl(spec, HDA_CTL_WIDGET_VOL, ctlname, ctlidx, val);
7230 ++ if (mix_val) {
7231 ++ err = __add_pb_vol_ctrl(spec, HDA_CTL_WIDGET_VOL, ctlname, ctlidx, mix_val);
7232 + if (err < 0)
7233 + return err;
7234 +- path->ctls[NID_PATH_VOL_CTL] = val;
7235 ++ path->ctls[NID_PATH_VOL_CTL] = mix_val;
7236 + }
7237 +
7238 +- if (nid_has_mute(codec, mix_nid, HDA_INPUT)) {
7239 +- val = HDA_COMPOSE_AMP_VAL(mix_nid, 3, idx, HDA_INPUT);
7240 +- err = __add_pb_sw_ctrl(spec, HDA_CTL_WIDGET_MUTE, ctlname, ctlidx, val);
7241 ++ if (mute_val) {
7242 ++ err = __add_pb_sw_ctrl(spec, HDA_CTL_WIDGET_MUTE, ctlname, ctlidx, mute_val);
7243 + if (err < 0)
7244 + return err;
7245 +- path->ctls[NID_PATH_MUTE_CTL] = val;
7246 ++ path->ctls[NID_PATH_MUTE_CTL] = mute_val;
7247 + }
7248 +
7249 + path->active = true;
7250 +@@ -4287,6 +4313,17 @@ int snd_hda_gen_parse_auto_config(struct hda_codec *codec,
7251 + if (err < 0)
7252 + return err;
7253 +
7254 ++ /* create "Headphone Mic Jack Mode" if no input selection is
7255 ++ * available (or user specifies add_jack_modes hint)
7256 ++ */
7257 ++ if (spec->hp_mic_pin &&
7258 ++ (spec->auto_mic || spec->input_mux.num_items == 1 ||
7259 ++ spec->add_jack_modes)) {
7260 ++ err = create_hp_mic_jack_mode(codec, spec->hp_mic_pin);
7261 ++ if (err < 0)
7262 ++ return err;
7263 ++ }
7264 ++
7265 + if (spec->add_jack_modes) {
7266 + if (cfg->line_out_type != AUTO_PIN_SPEAKER_OUT) {
7267 + err = create_out_jack_modes(codec, cfg->line_outs,
7268 +diff --git a/sound/pci/hda/patch_realtek.c b/sound/pci/hda/patch_realtek.c
7269 +index 8bce0445..661afe7d 100644
7270 +--- a/sound/pci/hda/patch_realtek.c
7271 ++++ b/sound/pci/hda/patch_realtek.c
7272 +@@ -1765,6 +1765,7 @@ enum {
7273 + ALC889_FIXUP_IMAC91_VREF,
7274 + ALC882_FIXUP_INV_DMIC,
7275 + ALC882_FIXUP_NO_PRIMARY_HP,
7276 ++ ALC887_FIXUP_ASUS_BASS,
7277 + };
7278 +
7279 + static void alc889_fixup_coef(struct hda_codec *codec,
7280 +@@ -2086,6 +2087,13 @@ static const struct hda_fixup alc882_fixups[] = {
7281 + .type = HDA_FIXUP_FUNC,
7282 + .v.func = alc882_fixup_no_primary_hp,
7283 + },
7284 ++ [ALC887_FIXUP_ASUS_BASS] = {
7285 ++ .type = HDA_FIXUP_PINS,
7286 ++ .v.pins = (const struct hda_pintbl[]) {
7287 ++ {0x16, 0x99130130}, /* bass speaker */
7288 ++ {}
7289 ++ },
7290 ++ },
7291 + };
7292 +
7293 + static const struct snd_pci_quirk alc882_fixup_tbl[] = {
7294 +@@ -2119,6 +2127,7 @@ static const struct snd_pci_quirk alc882_fixup_tbl[] = {
7295 + SND_PCI_QUIRK(0x1043, 0x1873, "ASUS W90V", ALC882_FIXUP_ASUS_W90V),
7296 + SND_PCI_QUIRK(0x1043, 0x1971, "Asus W2JC", ALC882_FIXUP_ASUS_W2JC),
7297 + SND_PCI_QUIRK(0x1043, 0x835f, "Asus Eee 1601", ALC888_FIXUP_EEE1601),
7298 ++ SND_PCI_QUIRK(0x1043, 0x84bc, "ASUS ET2700", ALC887_FIXUP_ASUS_BASS),
7299 + SND_PCI_QUIRK(0x104d, 0x9047, "Sony Vaio TT", ALC889_FIXUP_VAIO_TT),
7300 + SND_PCI_QUIRK(0x104d, 0x905a, "Sony Vaio Z", ALC882_FIXUP_NO_PRIMARY_HP),
7301 + SND_PCI_QUIRK(0x104d, 0x9043, "Sony Vaio VGC-LN51JGB", ALC882_FIXUP_NO_PRIMARY_HP),
7302 +@@ -4494,6 +4503,7 @@ static int patch_alc662(struct hda_codec *codec)
7303 + case 0x10ec0272:
7304 + case 0x10ec0663:
7305 + case 0x10ec0665:
7306 ++ case 0x10ec0668:
7307 + set_beep_amp(spec, 0x0b, 0x04, HDA_INPUT);
7308 + break;
7309 + case 0x10ec0273:
7310 +@@ -4551,6 +4561,7 @@ static int patch_alc680(struct hda_codec *codec)
7311 + */
7312 + static const struct hda_codec_preset snd_hda_preset_realtek[] = {
7313 + { .id = 0x10ec0221, .name = "ALC221", .patch = patch_alc269 },
7314 ++ { .id = 0x10ec0231, .name = "ALC231", .patch = patch_alc269 },
7315 + { .id = 0x10ec0233, .name = "ALC233", .patch = patch_alc269 },
7316 + { .id = 0x10ec0255, .name = "ALC255", .patch = patch_alc269 },
7317 + { .id = 0x10ec0260, .name = "ALC260", .patch = patch_alc260 },
7318 +diff --git a/sound/soc/blackfin/bf5xx-i2s.c b/sound/soc/blackfin/bf5xx-i2s.c
7319 +index dd0c2a4f..e0869aaa 100644
7320 +--- a/sound/soc/blackfin/bf5xx-i2s.c
7321 ++++ b/sound/soc/blackfin/bf5xx-i2s.c
7322 +@@ -111,6 +111,7 @@ static int bf5xx_i2s_hw_params(struct snd_pcm_substream *substream,
7323 + bf5xx_i2s->tcr2 |= 7;
7324 + bf5xx_i2s->rcr2 |= 7;
7325 + sport_handle->wdsize = 1;
7326 ++ break;
7327 + case SNDRV_PCM_FORMAT_S16_LE:
7328 + bf5xx_i2s->tcr2 |= 15;
7329 + bf5xx_i2s->rcr2 |= 15;
7330 +diff --git a/sound/soc/codecs/ak4642.c b/sound/soc/codecs/ak4642.c
7331 +index 2d037870..687565d0 100644
7332 +--- a/sound/soc/codecs/ak4642.c
7333 ++++ b/sound/soc/codecs/ak4642.c
7334 +@@ -257,7 +257,7 @@ static int ak4642_dai_startup(struct snd_pcm_substream *substream,
7335 + * This operation came from example code of
7336 + * "ASAHI KASEI AK4642" (japanese) manual p94.
7337 + */
7338 +- snd_soc_write(codec, SG_SL1, PMMP | MGAIN0);
7339 ++ snd_soc_update_bits(codec, SG_SL1, PMMP | MGAIN0, PMMP | MGAIN0);
7340 + snd_soc_write(codec, TIMER, ZTM(0x3) | WTM(0x3));
7341 + snd_soc_write(codec, ALC_CTL1, ALC | LMTH0);
7342 + snd_soc_update_bits(codec, PW_MGMT1, PMADL, PMADL);
7343 +diff --git a/sound/soc/codecs/arizona.c b/sound/soc/codecs/arizona.c
7344 +index 389f2325..663a2a74 100644
7345 +--- a/sound/soc/codecs/arizona.c
7346 ++++ b/sound/soc/codecs/arizona.c
7347 +@@ -1455,6 +1455,8 @@ static void arizona_enable_fll(struct arizona_fll *fll,
7348 + try_wait_for_completion(&fll->ok);
7349 +
7350 + regmap_update_bits(arizona->regmap, fll->base + 1,
7351 ++ ARIZONA_FLL1_FREERUN, 0);
7352 ++ regmap_update_bits(arizona->regmap, fll->base + 1,
7353 + ARIZONA_FLL1_ENA, ARIZONA_FLL1_ENA);
7354 + if (fll->ref_src >= 0 && fll->sync_src >= 0 &&
7355 + fll->ref_src != fll->sync_src)
7356 +@@ -1473,6 +1475,8 @@ static void arizona_disable_fll(struct arizona_fll *fll)
7357 + struct arizona *arizona = fll->arizona;
7358 + bool change;
7359 +
7360 ++ regmap_update_bits(arizona->regmap, fll->base + 1,
7361 ++ ARIZONA_FLL1_FREERUN, ARIZONA_FLL1_FREERUN);
7362 + regmap_update_bits_check(arizona->regmap, fll->base + 1,
7363 + ARIZONA_FLL1_ENA, 0, &change);
7364 + regmap_update_bits(arizona->regmap, fll->base + 0x11,
7365 +diff --git a/sound/soc/codecs/cs42l52.h b/sound/soc/codecs/cs42l52.h
7366 +index 4277012c..a935d738 100644
7367 +--- a/sound/soc/codecs/cs42l52.h
7368 ++++ b/sound/soc/codecs/cs42l52.h
7369 +@@ -179,7 +179,7 @@
7370 + #define CS42L52_MICB_CTL 0x11
7371 + #define CS42L52_MIC_CTL_MIC_SEL_MASK 0xBF
7372 + #define CS42L52_MIC_CTL_MIC_SEL_SHIFT 6
7373 +-#define CS42L52_MIC_CTL_TYPE_MASK 0xDF
7374 ++#define CS42L52_MIC_CTL_TYPE_MASK 0x20
7375 + #define CS42L52_MIC_CTL_TYPE_SHIFT 5
7376 +
7377 +
7378 +diff --git a/sound/soc/codecs/wm5110.c b/sound/soc/codecs/wm5110.c
7379 +index 88ad7db5..cd6ed884 100644
7380 +--- a/sound/soc/codecs/wm5110.c
7381 ++++ b/sound/soc/codecs/wm5110.c
7382 +@@ -37,6 +37,47 @@ struct wm5110_priv {
7383 + struct arizona_fll fll[2];
7384 + };
7385 +
7386 ++static const struct reg_default wm5110_sysclk_revd_patch[] = {
7387 ++ { 0x3093, 0x1001 },
7388 ++ { 0x30E3, 0x1301 },
7389 ++ { 0x3133, 0x1201 },
7390 ++ { 0x3183, 0x1501 },
7391 ++ { 0x31D3, 0x1401 },
7392 ++};
7393 ++
7394 ++static int wm5110_sysclk_ev(struct snd_soc_dapm_widget *w,
7395 ++ struct snd_kcontrol *kcontrol, int event)
7396 ++{
7397 ++ struct snd_soc_codec *codec = w->codec;
7398 ++ struct arizona *arizona = dev_get_drvdata(codec->dev->parent);
7399 ++ struct regmap *regmap = codec->control_data;
7400 ++ const struct reg_default *patch = NULL;
7401 ++ int i, patch_size;
7402 ++
7403 ++ switch (arizona->rev) {
7404 ++ case 3:
7405 ++ patch = wm5110_sysclk_revd_patch;
7406 ++ patch_size = ARRAY_SIZE(wm5110_sysclk_revd_patch);
7407 ++ break;
7408 ++ default:
7409 ++ return 0;
7410 ++ }
7411 ++
7412 ++ switch (event) {
7413 ++ case SND_SOC_DAPM_POST_PMU:
7414 ++ if (patch)
7415 ++ for (i = 0; i < patch_size; i++)
7416 ++ regmap_write(regmap, patch[i].reg,
7417 ++ patch[i].def);
7418 ++ break;
7419 ++
7420 ++ default:
7421 ++ break;
7422 ++ }
7423 ++
7424 ++ return 0;
7425 ++}
7426 ++
7427 + static DECLARE_TLV_DB_SCALE(ana_tlv, 0, 100, 0);
7428 + static DECLARE_TLV_DB_SCALE(eq_tlv, -1200, 100, 0);
7429 + static DECLARE_TLV_DB_SCALE(digital_tlv, -6400, 50, 0);
7430 +@@ -386,7 +427,7 @@ static const struct snd_kcontrol_new wm5110_aec_loopback_mux =
7431 +
7432 + static const struct snd_soc_dapm_widget wm5110_dapm_widgets[] = {
7433 + SND_SOC_DAPM_SUPPLY("SYSCLK", ARIZONA_SYSTEM_CLOCK_1, ARIZONA_SYSCLK_ENA_SHIFT,
7434 +- 0, NULL, 0),
7435 ++ 0, wm5110_sysclk_ev, SND_SOC_DAPM_POST_PMU),
7436 + SND_SOC_DAPM_SUPPLY("ASYNCCLK", ARIZONA_ASYNC_CLOCK_1,
7437 + ARIZONA_ASYNC_CLK_ENA_SHIFT, 0, NULL, 0),
7438 + SND_SOC_DAPM_SUPPLY("OPCLK", ARIZONA_OUTPUT_SYSTEM_CLOCK,
7439 +diff --git a/sound/soc/codecs/wm8962.c b/sound/soc/codecs/wm8962.c
7440 +index 730dd0c0..e3cd8651 100644
7441 +--- a/sound/soc/codecs/wm8962.c
7442 ++++ b/sound/soc/codecs/wm8962.c
7443 +@@ -3686,6 +3686,8 @@ static int wm8962_i2c_probe(struct i2c_client *i2c,
7444 + if (ret < 0)
7445 + goto err_enable;
7446 +
7447 ++ regcache_cache_only(wm8962->regmap, true);
7448 ++
7449 + /* The drivers should power up as needed */
7450 + regulator_bulk_disable(ARRAY_SIZE(wm8962->supplies), wm8962->supplies);
7451 +
7452 +diff --git a/sound/soc/fsl/imx-pcm-fiq.c b/sound/soc/fsl/imx-pcm-fiq.c
7453 +index 670b96b0..dcfd0fae 100644
7454 +--- a/sound/soc/fsl/imx-pcm-fiq.c
7455 ++++ b/sound/soc/fsl/imx-pcm-fiq.c
7456 +@@ -42,7 +42,8 @@ struct imx_pcm_runtime_data {
7457 + struct hrtimer hrt;
7458 + int poll_time_ns;
7459 + struct snd_pcm_substream *substream;
7460 +- atomic_t running;
7461 ++ atomic_t playing;
7462 ++ atomic_t capturing;
7463 + };
7464 +
7465 + static enum hrtimer_restart snd_hrtimer_callback(struct hrtimer *hrt)
7466 +@@ -54,7 +55,7 @@ static enum hrtimer_restart snd_hrtimer_callback(struct hrtimer *hrt)
7467 + struct pt_regs regs;
7468 + unsigned long delta;
7469 +
7470 +- if (!atomic_read(&iprtd->running))
7471 ++ if (!atomic_read(&iprtd->playing) && !atomic_read(&iprtd->capturing))
7472 + return HRTIMER_NORESTART;
7473 +
7474 + get_fiq_regs(&regs);
7475 +@@ -122,7 +123,6 @@ static int snd_imx_pcm_prepare(struct snd_pcm_substream *substream)
7476 + return 0;
7477 + }
7478 +
7479 +-static int fiq_enable;
7480 + static int imx_pcm_fiq;
7481 +
7482 + static int snd_imx_pcm_trigger(struct snd_pcm_substream *substream, int cmd)
7483 +@@ -134,23 +134,27 @@ static int snd_imx_pcm_trigger(struct snd_pcm_substream *substream, int cmd)
7484 + case SNDRV_PCM_TRIGGER_START:
7485 + case SNDRV_PCM_TRIGGER_RESUME:
7486 + case SNDRV_PCM_TRIGGER_PAUSE_RELEASE:
7487 +- atomic_set(&iprtd->running, 1);
7488 ++ if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK)
7489 ++ atomic_set(&iprtd->playing, 1);
7490 ++ else
7491 ++ atomic_set(&iprtd->capturing, 1);
7492 + hrtimer_start(&iprtd->hrt, ns_to_ktime(iprtd->poll_time_ns),
7493 + HRTIMER_MODE_REL);
7494 +- if (++fiq_enable == 1)
7495 +- enable_fiq(imx_pcm_fiq);
7496 +-
7497 ++ enable_fiq(imx_pcm_fiq);
7498 + break;
7499 +
7500 + case SNDRV_PCM_TRIGGER_STOP:
7501 + case SNDRV_PCM_TRIGGER_SUSPEND:
7502 + case SNDRV_PCM_TRIGGER_PAUSE_PUSH:
7503 +- atomic_set(&iprtd->running, 0);
7504 +-
7505 +- if (--fiq_enable == 0)
7506 ++ if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK)
7507 ++ atomic_set(&iprtd->playing, 0);
7508 ++ else
7509 ++ atomic_set(&iprtd->capturing, 0);
7510 ++ if (!atomic_read(&iprtd->playing) &&
7511 ++ !atomic_read(&iprtd->capturing))
7512 + disable_fiq(imx_pcm_fiq);
7513 +-
7514 + break;
7515 ++
7516 + default:
7517 + return -EINVAL;
7518 + }
7519 +@@ -198,7 +202,8 @@ static int snd_imx_open(struct snd_pcm_substream *substream)
7520 +
7521 + iprtd->substream = substream;
7522 +
7523 +- atomic_set(&iprtd->running, 0);
7524 ++ atomic_set(&iprtd->playing, 0);
7525 ++ atomic_set(&iprtd->capturing, 0);
7526 + hrtimer_init(&iprtd->hrt, CLOCK_MONOTONIC, HRTIMER_MODE_REL);
7527 + iprtd->hrt.function = snd_hrtimer_callback;
7528 +
7529 +diff --git a/tools/perf/ui/hist.c b/tools/perf/ui/hist.c
7530 +index 4bf91b09..794bb1a1 100644
7531 +--- a/tools/perf/ui/hist.c
7532 ++++ b/tools/perf/ui/hist.c
7533 +@@ -113,7 +113,7 @@ static u64 he_get_##_field(struct hist_entry *he) \
7534 + static int hpp__color_##_type(struct perf_hpp *hpp, struct hist_entry *he) \
7535 + { \
7536 + return __hpp__fmt(hpp, he, he_get_##_field, " %6.2f%%", \
7537 +- (hpp_snprint_fn)percent_color_snprintf, true); \
7538 ++ percent_color_snprintf, true); \
7539 + }
7540 +
7541 + #define __HPP_ENTRY_PERCENT_FN(_type, _field) \
7542 +diff --git a/tools/perf/util/color.c b/tools/perf/util/color.c
7543 +index 11e46da1..66e44a50 100644
7544 +--- a/tools/perf/util/color.c
7545 ++++ b/tools/perf/util/color.c
7546 +@@ -318,8 +318,15 @@ int percent_color_fprintf(FILE *fp, const char *fmt, double percent)
7547 + return r;
7548 + }
7549 +
7550 +-int percent_color_snprintf(char *bf, size_t size, const char *fmt, double percent)
7551 ++int percent_color_snprintf(char *bf, size_t size, const char *fmt, ...)
7552 + {
7553 +- const char *color = get_percent_color(percent);
7554 ++ va_list args;
7555 ++ double percent;
7556 ++ const char *color;
7557 ++
7558 ++ va_start(args, fmt);
7559 ++ percent = va_arg(args, double);
7560 ++ va_end(args);
7561 ++ color = get_percent_color(percent);
7562 + return color_snprintf(bf, size, color, fmt, percent);
7563 + }
7564 +diff --git a/tools/perf/util/color.h b/tools/perf/util/color.h
7565 +index dea082b7..fced3840 100644
7566 +--- a/tools/perf/util/color.h
7567 ++++ b/tools/perf/util/color.h
7568 +@@ -39,7 +39,7 @@ int color_fprintf(FILE *fp, const char *color, const char *fmt, ...);
7569 + int color_snprintf(char *bf, size_t size, const char *color, const char *fmt, ...);
7570 + int color_fprintf_ln(FILE *fp, const char *color, const char *fmt, ...);
7571 + int color_fwrite_lines(FILE *fp, const char *color, size_t count, const char *buf);
7572 +-int percent_color_snprintf(char *bf, size_t size, const char *fmt, double percent);
7573 ++int percent_color_snprintf(char *bf, size_t size, const char *fmt, ...);
7574 + int percent_color_fprintf(FILE *fp, const char *fmt, double percent);
7575 + const char *get_percent_color(double percent);
7576 +