Gentoo Archives: gentoo-commits

From: Mike Pagano <mpagano@g.o>
To: gentoo-commits@l.g.o
Subject: [gentoo-commits] proj/linux-patches:4.4 commit in: /
Date: Wed, 29 Jan 2020 12:36:14
Message-Id: 1580301344.a96d7847b6078a1647ccdb098d313511cef950de.mpagano@gentoo
1 commit: a96d7847b6078a1647ccdb098d313511cef950de
2 Author: Mike Pagano <mpagano <AT> gentoo <DOT> org>
3 AuthorDate: Wed Jan 29 12:35:44 2020 +0000
4 Commit: Mike Pagano <mpagano <AT> gentoo <DOT> org>
5 CommitDate: Wed Jan 29 12:35:44 2020 +0000
6 URL: https://gitweb.gentoo.org/proj/linux-patches.git/commit/?id=a96d7847
7
8 Linux patch 4.4.212
9
10 Signed-off-by: Mike Pagano <mpagano <AT> gentoo.org>
11
12 0000_README | 4 +
13 1211_linux-4.4.212.patch | 5145 ++++++++++++++++++++++++++++++++++++++++++++++
14 2 files changed, 5149 insertions(+)
15
16 diff --git a/0000_README b/0000_README
17 index 8e923ff..17859bd 100644
18 --- a/0000_README
19 +++ b/0000_README
20 @@ -887,6 +887,10 @@ Patch: 1210_linux-4.4.211.patch
21 From: http://www.kernel.org
22 Desc: Linux 4.4.211
23
24 +Patch: 1211_linux-4.4.212.patch
25 +From: http://www.kernel.org
26 +Desc: Linux 4.4.212
27 +
28 Patch: 1500_XATTR_USER_PREFIX.patch
29 From: https://bugs.gentoo.org/show_bug.cgi?id=470644
30 Desc: Support for namespace user.pax.* on tmpfs.
31
32 diff --git a/1211_linux-4.4.212.patch b/1211_linux-4.4.212.patch
33 new file mode 100644
34 index 0000000..150526f
35 --- /dev/null
36 +++ b/1211_linux-4.4.212.patch
37 @@ -0,0 +1,5145 @@
38 +diff --git a/Makefile b/Makefile
39 +index 9f03733dac69..379f2a525c02 100644
40 +--- a/Makefile
41 ++++ b/Makefile
42 +@@ -1,6 +1,6 @@
43 + VERSION = 4
44 + PATCHLEVEL = 4
45 +-SUBLEVEL = 211
46 ++SUBLEVEL = 212
47 + EXTRAVERSION =
48 + NAME = Blurry Fish Butt
49 +
50 +diff --git a/arch/arm/common/mcpm_entry.c b/arch/arm/common/mcpm_entry.c
51 +index a923524d1040..8617323eb273 100644
52 +--- a/arch/arm/common/mcpm_entry.c
53 ++++ b/arch/arm/common/mcpm_entry.c
54 +@@ -379,7 +379,7 @@ static int __init nocache_trampoline(unsigned long _arg)
55 + unsigned int cluster = MPIDR_AFFINITY_LEVEL(mpidr, 1);
56 + phys_reset_t phys_reset;
57 +
58 +- mcpm_set_entry_vector(cpu, cluster, cpu_resume);
59 ++ mcpm_set_entry_vector(cpu, cluster, cpu_resume_no_hyp);
60 + setup_mm_for_reboot();
61 +
62 + __mcpm_cpu_going_down(cpu, cluster);
63 +diff --git a/arch/arm/include/asm/suspend.h b/arch/arm/include/asm/suspend.h
64 +index 6c7182f32cef..e6c2f426f8c8 100644
65 +--- a/arch/arm/include/asm/suspend.h
66 ++++ b/arch/arm/include/asm/suspend.h
67 +@@ -7,6 +7,7 @@ struct sleep_save_sp {
68 + };
69 +
70 + extern void cpu_resume(void);
71 ++extern void cpu_resume_no_hyp(void);
72 + extern void cpu_resume_arm(void);
73 + extern int cpu_suspend(unsigned long, int (*)(unsigned long));
74 +
75 +diff --git a/arch/arm/kernel/sleep.S b/arch/arm/kernel/sleep.S
76 +index 0f6c1000582c..c8569390e7e7 100644
77 +--- a/arch/arm/kernel/sleep.S
78 ++++ b/arch/arm/kernel/sleep.S
79 +@@ -119,6 +119,14 @@ ENDPROC(cpu_resume_after_mmu)
80 + .text
81 + .align
82 +
83 ++#ifdef CONFIG_MCPM
84 ++ .arm
85 ++THUMB( .thumb )
86 ++ENTRY(cpu_resume_no_hyp)
87 ++ARM_BE8(setend be) @ ensure we are in BE mode
88 ++ b no_hyp
89 ++#endif
90 ++
91 + #ifdef CONFIG_MMU
92 + .arm
93 + ENTRY(cpu_resume_arm)
94 +@@ -134,6 +142,7 @@ ARM_BE8(setend be) @ ensure we are in BE mode
95 + bl __hyp_stub_install_secondary
96 + #endif
97 + safe_svcmode_maskall r1
98 ++no_hyp:
99 + mov r1, #0
100 + ALT_SMP(mrc p15, 0, r0, c0, c0, 5)
101 + ALT_UP_B(1f)
102 +@@ -162,6 +171,9 @@ ENDPROC(cpu_resume)
103 +
104 + #ifdef CONFIG_MMU
105 + ENDPROC(cpu_resume_arm)
106 ++#endif
107 ++#ifdef CONFIG_MCPM
108 ++ENDPROC(cpu_resume_no_hyp)
109 + #endif
110 +
111 + .align 2
112 +diff --git a/arch/arm/mach-omap2/omap_hwmod.c b/arch/arm/mach-omap2/omap_hwmod.c
113 +index 36706d32d656..1bc87c29467b 100644
114 +--- a/arch/arm/mach-omap2/omap_hwmod.c
115 ++++ b/arch/arm/mach-omap2/omap_hwmod.c
116 +@@ -2563,7 +2563,7 @@ static void _setup_iclk_autoidle(struct omap_hwmod *oh)
117 + */
118 + static int _setup_reset(struct omap_hwmod *oh)
119 + {
120 +- int r;
121 ++ int r = 0;
122 +
123 + if (oh->_state != _HWMOD_STATE_INITIALIZED)
124 + return -EINVAL;
125 +diff --git a/arch/arm/mach-rpc/irq.c b/arch/arm/mach-rpc/irq.c
126 +index 66502e6207fe..fce7fecbd8fa 100644
127 +--- a/arch/arm/mach-rpc/irq.c
128 ++++ b/arch/arm/mach-rpc/irq.c
129 +@@ -117,7 +117,7 @@ extern unsigned char rpc_default_fiq_start, rpc_default_fiq_end;
130 +
131 + void __init rpc_init_irq(void)
132 + {
133 +- unsigned int irq, clr, set = 0;
134 ++ unsigned int irq, clr, set;
135 +
136 + iomd_writeb(0, IOMD_IRQMASKA);
137 + iomd_writeb(0, IOMD_IRQMASKB);
138 +@@ -129,6 +129,7 @@ void __init rpc_init_irq(void)
139 +
140 + for (irq = 0; irq < NR_IRQS; irq++) {
141 + clr = IRQ_NOREQUEST;
142 ++ set = 0;
143 +
144 + if (irq <= 6 || (irq >= 9 && irq <= 15))
145 + clr |= IRQ_NOPROBE;
146 +diff --git a/arch/arm/plat-pxa/ssp.c b/arch/arm/plat-pxa/ssp.c
147 +index 6748827c2ec8..b6b0979e3cf9 100644
148 +--- a/arch/arm/plat-pxa/ssp.c
149 ++++ b/arch/arm/plat-pxa/ssp.c
150 +@@ -231,18 +231,12 @@ static int pxa_ssp_probe(struct platform_device *pdev)
151 +
152 + static int pxa_ssp_remove(struct platform_device *pdev)
153 + {
154 +- struct resource *res;
155 + struct ssp_device *ssp;
156 +
157 + ssp = platform_get_drvdata(pdev);
158 + if (ssp == NULL)
159 + return -ENODEV;
160 +
161 +- res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
162 +- release_mem_region(res->start, resource_size(res));
163 +-
164 +- clk_put(ssp->clk);
165 +-
166 + mutex_lock(&ssp_lock);
167 + list_del(&ssp->node);
168 + mutex_unlock(&ssp_lock);
169 +diff --git a/arch/arm64/boot/dts/arm/juno-clocks.dtsi b/arch/arm64/boot/dts/arm/juno-clocks.dtsi
170 +index 25352ed943e6..00bcbf7688c7 100644
171 +--- a/arch/arm64/boot/dts/arm/juno-clocks.dtsi
172 ++++ b/arch/arm64/boot/dts/arm/juno-clocks.dtsi
173 +@@ -8,10 +8,10 @@
174 + */
175 +
176 + /* SoC fixed clocks */
177 +- soc_uartclk: refclk7273800hz {
178 ++ soc_uartclk: refclk7372800hz {
179 + compatible = "fixed-clock";
180 + #clock-cells = <0>;
181 +- clock-frequency = <7273800>;
182 ++ clock-frequency = <7372800>;
183 + clock-output-names = "juno:uartclk";
184 + };
185 +
186 +diff --git a/arch/m68k/amiga/cia.c b/arch/m68k/amiga/cia.c
187 +index 2081b8cd5591..b9aee983e6f4 100644
188 +--- a/arch/m68k/amiga/cia.c
189 ++++ b/arch/m68k/amiga/cia.c
190 +@@ -88,10 +88,19 @@ static irqreturn_t cia_handler(int irq, void *dev_id)
191 + struct ciabase *base = dev_id;
192 + int mach_irq;
193 + unsigned char ints;
194 ++ unsigned long flags;
195 +
196 ++ /* Interrupts get disabled while the timer irq flag is cleared and
197 ++ * the timer interrupt serviced.
198 ++ */
199 + mach_irq = base->cia_irq;
200 ++ local_irq_save(flags);
201 + ints = cia_set_irq(base, CIA_ICR_ALL);
202 + amiga_custom.intreq = base->int_mask;
203 ++ if (ints & 1)
204 ++ generic_handle_irq(mach_irq);
205 ++ local_irq_restore(flags);
206 ++ mach_irq++, ints >>= 1;
207 + for (; ints; mach_irq++, ints >>= 1) {
208 + if (ints & 1)
209 + generic_handle_irq(mach_irq);
210 +diff --git a/arch/m68k/atari/ataints.c b/arch/m68k/atari/ataints.c
211 +index 3d2b63bedf05..56f02ea2c248 100644
212 +--- a/arch/m68k/atari/ataints.c
213 ++++ b/arch/m68k/atari/ataints.c
214 +@@ -142,7 +142,7 @@ struct mfptimerbase {
215 + .name = "MFP Timer D"
216 + };
217 +
218 +-static irqreturn_t mfptimer_handler(int irq, void *dev_id)
219 ++static irqreturn_t mfp_timer_d_handler(int irq, void *dev_id)
220 + {
221 + struct mfptimerbase *base = dev_id;
222 + int mach_irq;
223 +@@ -344,7 +344,7 @@ void __init atari_init_IRQ(void)
224 + st_mfp.tim_ct_cd = (st_mfp.tim_ct_cd & 0xf0) | 0x6;
225 +
226 + /* request timer D dispatch handler */
227 +- if (request_irq(IRQ_MFP_TIMD, mfptimer_handler, IRQF_SHARED,
228 ++ if (request_irq(IRQ_MFP_TIMD, mfp_timer_d_handler, IRQF_SHARED,
229 + stmfp_base.name, &stmfp_base))
230 + pr_err("Couldn't register %s interrupt\n", stmfp_base.name);
231 +
232 +diff --git a/arch/m68k/atari/time.c b/arch/m68k/atari/time.c
233 +index c549b48174ec..972181c1fe4b 100644
234 +--- a/arch/m68k/atari/time.c
235 ++++ b/arch/m68k/atari/time.c
236 +@@ -24,6 +24,18 @@
237 + DEFINE_SPINLOCK(rtc_lock);
238 + EXPORT_SYMBOL_GPL(rtc_lock);
239 +
240 ++static irqreturn_t mfp_timer_c_handler(int irq, void *dev_id)
241 ++{
242 ++ irq_handler_t timer_routine = dev_id;
243 ++ unsigned long flags;
244 ++
245 ++ local_irq_save(flags);
246 ++ timer_routine(0, NULL);
247 ++ local_irq_restore(flags);
248 ++
249 ++ return IRQ_HANDLED;
250 ++}
251 ++
252 + void __init
253 + atari_sched_init(irq_handler_t timer_routine)
254 + {
255 +@@ -32,7 +44,8 @@ atari_sched_init(irq_handler_t timer_routine)
256 + /* start timer C, div = 1:100 */
257 + st_mfp.tim_ct_cd = (st_mfp.tim_ct_cd & 15) | 0x60;
258 + /* install interrupt service routine for MFP Timer C */
259 +- if (request_irq(IRQ_MFP_TIMC, timer_routine, 0, "timer", timer_routine))
260 ++ if (request_irq(IRQ_MFP_TIMC, mfp_timer_c_handler, 0, "timer",
261 ++ timer_routine))
262 + pr_err("Couldn't register timer interrupt\n");
263 + }
264 +
265 +diff --git a/arch/m68k/bvme6000/config.c b/arch/m68k/bvme6000/config.c
266 +index 478623dbb209..62054c01ecb4 100644
267 +--- a/arch/m68k/bvme6000/config.c
268 ++++ b/arch/m68k/bvme6000/config.c
269 +@@ -46,11 +46,6 @@ extern int bvme6000_set_clock_mmss (unsigned long);
270 + extern void bvme6000_reset (void);
271 + void bvme6000_set_vectors (void);
272 +
273 +-/* Save tick handler routine pointer, will point to xtime_update() in
274 +- * kernel/timer/timekeeping.c, called via bvme6000_process_int() */
275 +-
276 +-static irq_handler_t tick_handler;
277 +-
278 +
279 + int __init bvme6000_parse_bootinfo(const struct bi_record *bi)
280 + {
281 +@@ -160,12 +155,18 @@ irqreturn_t bvme6000_abort_int (int irq, void *dev_id)
282 +
283 + static irqreturn_t bvme6000_timer_int (int irq, void *dev_id)
284 + {
285 ++ irq_handler_t timer_routine = dev_id;
286 ++ unsigned long flags;
287 + volatile RtcPtr_t rtc = (RtcPtr_t)BVME_RTC_BASE;
288 +- unsigned char msr = rtc->msr & 0xc0;
289 ++ unsigned char msr;
290 +
291 ++ local_irq_save(flags);
292 ++ msr = rtc->msr & 0xc0;
293 + rtc->msr = msr | 0x20; /* Ack the interrupt */
294 ++ timer_routine(0, NULL);
295 ++ local_irq_restore(flags);
296 +
297 +- return tick_handler(irq, dev_id);
298 ++ return IRQ_HANDLED;
299 + }
300 +
301 + /*
302 +@@ -184,9 +185,8 @@ void bvme6000_sched_init (irq_handler_t timer_routine)
303 +
304 + rtc->msr = 0; /* Ensure timer registers accessible */
305 +
306 +- tick_handler = timer_routine;
307 +- if (request_irq(BVME_IRQ_RTC, bvme6000_timer_int, 0,
308 +- "timer", bvme6000_timer_int))
309 ++ if (request_irq(BVME_IRQ_RTC, bvme6000_timer_int, 0, "timer",
310 ++ timer_routine))
311 + panic ("Couldn't register timer int");
312 +
313 + rtc->t1cr_omr = 0x04; /* Mode 2, ext clk */
314 +diff --git a/arch/m68k/hp300/time.c b/arch/m68k/hp300/time.c
315 +index 749543b425a4..03c83b8f9032 100644
316 +--- a/arch/m68k/hp300/time.c
317 ++++ b/arch/m68k/hp300/time.c
318 +@@ -37,13 +37,19 @@
319 +
320 + static irqreturn_t hp300_tick(int irq, void *dev_id)
321 + {
322 ++ irq_handler_t timer_routine = dev_id;
323 ++ unsigned long flags;
324 + unsigned long tmp;
325 +- irq_handler_t vector = dev_id;
326 ++
327 ++ local_irq_save(flags);
328 + in_8(CLOCKBASE + CLKSR);
329 + asm volatile ("movpw %1@(5),%0" : "=d" (tmp) : "a" (CLOCKBASE));
330 ++ timer_routine(0, NULL);
331 ++ local_irq_restore(flags);
332 ++
333 + /* Turn off the network and SCSI leds */
334 + blinken_leds(0, 0xe0);
335 +- return vector(irq, NULL);
336 ++ return IRQ_HANDLED;
337 + }
338 +
339 + u32 hp300_gettimeoffset(void)
340 +diff --git a/arch/m68k/mac/via.c b/arch/m68k/mac/via.c
341 +index ce56e04386e7..49f9fa4529a8 100644
342 +--- a/arch/m68k/mac/via.c
343 ++++ b/arch/m68k/mac/via.c
344 +@@ -53,16 +53,6 @@ static __u8 rbv_clear;
345 +
346 + static int gIER,gIFR,gBufA,gBufB;
347 +
348 +-/*
349 +- * Timer defs.
350 +- */
351 +-
352 +-#define TICK_SIZE 10000
353 +-#define MAC_CLOCK_TICK (783300/HZ) /* ticks per HZ */
354 +-#define MAC_CLOCK_LOW (MAC_CLOCK_TICK&0xFF)
355 +-#define MAC_CLOCK_HIGH (MAC_CLOCK_TICK>>8)
356 +-
357 +-
358 + /*
359 + * On Macs with a genuine VIA chip there is no way to mask an individual slot
360 + * interrupt. This limitation also seems to apply to VIA clone logic cores in
361 +@@ -277,22 +267,6 @@ void __init via_init(void)
362 + }
363 + }
364 +
365 +-/*
366 +- * Start the 100 Hz clock
367 +- */
368 +-
369 +-void __init via_init_clock(irq_handler_t func)
370 +-{
371 +- via1[vACR] |= 0x40;
372 +- via1[vT1LL] = MAC_CLOCK_LOW;
373 +- via1[vT1LH] = MAC_CLOCK_HIGH;
374 +- via1[vT1CL] = MAC_CLOCK_LOW;
375 +- via1[vT1CH] = MAC_CLOCK_HIGH;
376 +-
377 +- if (request_irq(IRQ_MAC_TIMER_1, func, 0, "timer", func))
378 +- pr_err("Couldn't register %s interrupt\n", "timer");
379 +-}
380 +-
381 + /*
382 + * Debugging dump, used in various places to see what's going on.
383 + */
384 +@@ -320,29 +294,6 @@ void via_debug_dump(void)
385 + }
386 + }
387 +
388 +-/*
389 +- * This is always executed with interrupts disabled.
390 +- *
391 +- * TBI: get time offset between scheduling timer ticks
392 +- */
393 +-
394 +-u32 mac_gettimeoffset(void)
395 +-{
396 +- unsigned long ticks, offset = 0;
397 +-
398 +- /* read VIA1 timer 2 current value */
399 +- ticks = via1[vT1CL] | (via1[vT1CH] << 8);
400 +- /* The probability of underflow is less than 2% */
401 +- if (ticks > MAC_CLOCK_TICK - MAC_CLOCK_TICK / 50)
402 +- /* Check for pending timer interrupt in VIA1 IFR */
403 +- if (via1[vIFR] & 0x40) offset = TICK_SIZE;
404 +-
405 +- ticks = MAC_CLOCK_TICK - ticks;
406 +- ticks = ticks * 10000L / MAC_CLOCK_TICK;
407 +-
408 +- return (ticks + offset) * 1000;
409 +-}
410 +-
411 + /*
412 + * Flush the L2 cache on Macs that have it by flipping
413 + * the system into 24-bit mode for an instant.
414 +@@ -446,6 +397,8 @@ void via_nubus_irq_shutdown(int irq)
415 + * via6522.c :-), disable/pending masks added.
416 + */
417 +
418 ++#define VIA_TIMER_1_INT BIT(6)
419 ++
420 + void via1_irq(struct irq_desc *desc)
421 + {
422 + int irq_num;
423 +@@ -455,6 +408,21 @@ void via1_irq(struct irq_desc *desc)
424 + if (!events)
425 + return;
426 +
427 ++ irq_num = IRQ_MAC_TIMER_1;
428 ++ irq_bit = VIA_TIMER_1_INT;
429 ++ if (events & irq_bit) {
430 ++ unsigned long flags;
431 ++
432 ++ local_irq_save(flags);
433 ++ via1[vIFR] = irq_bit;
434 ++ generic_handle_irq(irq_num);
435 ++ local_irq_restore(flags);
436 ++
437 ++ events &= ~irq_bit;
438 ++ if (!events)
439 ++ return;
440 ++ }
441 ++
442 + irq_num = VIA1_SOURCE_BASE;
443 + irq_bit = 1;
444 + do {
445 +@@ -619,3 +587,56 @@ int via2_scsi_drq_pending(void)
446 + return via2[gIFR] & (1 << IRQ_IDX(IRQ_MAC_SCSIDRQ));
447 + }
448 + EXPORT_SYMBOL(via2_scsi_drq_pending);
449 ++
450 ++/* timer and clock source */
451 ++
452 ++#define VIA_CLOCK_FREQ 783360 /* VIA "phase 2" clock in Hz */
453 ++#define VIA_TIMER_INTERVAL (1000000 / HZ) /* microseconds per jiffy */
454 ++#define VIA_TIMER_CYCLES (VIA_CLOCK_FREQ / HZ) /* clock cycles per jiffy */
455 ++
456 ++#define VIA_TC (VIA_TIMER_CYCLES - 2) /* including 0 and -1 */
457 ++#define VIA_TC_LOW (VIA_TC & 0xFF)
458 ++#define VIA_TC_HIGH (VIA_TC >> 8)
459 ++
460 ++void __init via_init_clock(irq_handler_t timer_routine)
461 ++{
462 ++ if (request_irq(IRQ_MAC_TIMER_1, timer_routine, 0, "timer", NULL)) {
463 ++ pr_err("Couldn't register %s interrupt\n", "timer");
464 ++ return;
465 ++ }
466 ++
467 ++ via1[vT1LL] = VIA_TC_LOW;
468 ++ via1[vT1LH] = VIA_TC_HIGH;
469 ++ via1[vT1CL] = VIA_TC_LOW;
470 ++ via1[vT1CH] = VIA_TC_HIGH;
471 ++ via1[vACR] |= 0x40;
472 ++}
473 ++
474 ++u32 mac_gettimeoffset(void)
475 ++{
476 ++ unsigned long flags;
477 ++ u8 count_high;
478 ++ u16 count, offset = 0;
479 ++
480 ++ /*
481 ++ * Timer counter wrap-around is detected with the timer interrupt flag
482 ++ * but reading the counter low byte (vT1CL) would reset the flag.
483 ++ * Also, accessing both counter registers is essentially a data race.
484 ++ * These problems are avoided by ignoring the low byte. Clock accuracy
485 ++ * is 256 times worse (error can reach 0.327 ms) but CPU overhead is
486 ++ * reduced by avoiding slow VIA register accesses.
487 ++ */
488 ++
489 ++ local_irq_save(flags);
490 ++ count_high = via1[vT1CH];
491 ++ if (count_high == 0xFF)
492 ++ count_high = 0;
493 ++ if (count_high > 0 && (via1[vIFR] & VIA_TIMER_1_INT))
494 ++ offset = VIA_TIMER_CYCLES;
495 ++ local_irq_restore(flags);
496 ++
497 ++ count = count_high << 8;
498 ++ count = VIA_TIMER_CYCLES - count + offset;
499 ++
500 ++ return ((count * VIA_TIMER_INTERVAL) / VIA_TIMER_CYCLES) * 1000;
501 ++}
502 +diff --git a/arch/m68k/mvme147/config.c b/arch/m68k/mvme147/config.c
503 +index e6a3b56c6481..152fbde23424 100644
504 +--- a/arch/m68k/mvme147/config.c
505 ++++ b/arch/m68k/mvme147/config.c
506 +@@ -47,11 +47,6 @@ extern void mvme147_reset (void);
507 +
508 + static int bcd2int (unsigned char b);
509 +
510 +-/* Save tick handler routine pointer, will point to xtime_update() in
511 +- * kernel/time/timekeeping.c, called via mvme147_process_int() */
512 +-
513 +-irq_handler_t tick_handler;
514 +-
515 +
516 + int __init mvme147_parse_bootinfo(const struct bi_record *bi)
517 + {
518 +@@ -107,16 +102,23 @@ void __init config_mvme147(void)
519 +
520 + static irqreturn_t mvme147_timer_int (int irq, void *dev_id)
521 + {
522 ++ irq_handler_t timer_routine = dev_id;
523 ++ unsigned long flags;
524 ++
525 ++ local_irq_save(flags);
526 + m147_pcc->t1_int_cntrl = PCC_TIMER_INT_CLR;
527 + m147_pcc->t1_int_cntrl = PCC_INT_ENAB|PCC_LEVEL_TIMER1;
528 +- return tick_handler(irq, dev_id);
529 ++ timer_routine(0, NULL);
530 ++ local_irq_restore(flags);
531 ++
532 ++ return IRQ_HANDLED;
533 + }
534 +
535 +
536 + void mvme147_sched_init (irq_handler_t timer_routine)
537 + {
538 +- tick_handler = timer_routine;
539 +- if (request_irq(PCC_IRQ_TIMER1, mvme147_timer_int, 0, "timer 1", NULL))
540 ++ if (request_irq(PCC_IRQ_TIMER1, mvme147_timer_int, 0, "timer 1",
541 ++ timer_routine))
542 + pr_err("Couldn't register timer interrupt\n");
543 +
544 + /* Init the clock with a value */
545 +diff --git a/arch/m68k/mvme16x/config.c b/arch/m68k/mvme16x/config.c
546 +index a53803cc66cd..0d43bfb3324d 100644
547 +--- a/arch/m68k/mvme16x/config.c
548 ++++ b/arch/m68k/mvme16x/config.c
549 +@@ -52,11 +52,6 @@ extern void mvme16x_reset (void);
550 +
551 + int bcd2int (unsigned char b);
552 +
553 +-/* Save tick handler routine pointer, will point to xtime_update() in
554 +- * kernel/time/timekeeping.c, called via mvme16x_process_int() */
555 +-
556 +-static irq_handler_t tick_handler;
557 +-
558 +
559 + unsigned short mvme16x_config;
560 + EXPORT_SYMBOL(mvme16x_config);
561 +@@ -355,8 +350,15 @@ static irqreturn_t mvme16x_abort_int (int irq, void *dev_id)
562 +
563 + static irqreturn_t mvme16x_timer_int (int irq, void *dev_id)
564 + {
565 +- *(volatile unsigned char *)0xfff4201b |= 8;
566 +- return tick_handler(irq, dev_id);
567 ++ irq_handler_t timer_routine = dev_id;
568 ++ unsigned long flags;
569 ++
570 ++ local_irq_save(flags);
571 ++ *(volatile unsigned char *)0xfff4201b |= 8;
572 ++ timer_routine(0, NULL);
573 ++ local_irq_restore(flags);
574 ++
575 ++ return IRQ_HANDLED;
576 + }
577 +
578 + void mvme16x_sched_init (irq_handler_t timer_routine)
579 +@@ -364,14 +366,13 @@ void mvme16x_sched_init (irq_handler_t timer_routine)
580 + uint16_t brdno = be16_to_cpu(mvme_bdid.brdno);
581 + int irq;
582 +
583 +- tick_handler = timer_routine;
584 + /* Using PCCchip2 or MC2 chip tick timer 1 */
585 + *(volatile unsigned long *)0xfff42008 = 0;
586 + *(volatile unsigned long *)0xfff42004 = 10000; /* 10ms */
587 + *(volatile unsigned char *)0xfff42017 |= 3;
588 + *(volatile unsigned char *)0xfff4201b = 0x16;
589 +- if (request_irq(MVME16x_IRQ_TIMER, mvme16x_timer_int, 0,
590 +- "timer", mvme16x_timer_int))
591 ++ if (request_irq(MVME16x_IRQ_TIMER, mvme16x_timer_int, 0, "timer",
592 ++ timer_routine))
593 + panic ("Couldn't register timer int");
594 +
595 + if (brdno == 0x0162 || brdno == 0x172)
596 +diff --git a/arch/m68k/q40/q40ints.c b/arch/m68k/q40/q40ints.c
597 +index 513f9bb17b9c..60b51f5b9cfc 100644
598 +--- a/arch/m68k/q40/q40ints.c
599 ++++ b/arch/m68k/q40/q40ints.c
600 +@@ -126,10 +126,10 @@ void q40_mksound(unsigned int hz, unsigned int ticks)
601 + sound_ticks = ticks << 1;
602 + }
603 +
604 +-static irq_handler_t q40_timer_routine;
605 +-
606 +-static irqreturn_t q40_timer_int (int irq, void * dev)
607 ++static irqreturn_t q40_timer_int(int irq, void *dev_id)
608 + {
609 ++ irq_handler_t timer_routine = dev_id;
610 ++
611 + ql_ticks = ql_ticks ? 0 : 1;
612 + if (sound_ticks) {
613 + unsigned char sval=(sound_ticks & 1) ? 128-SVOL : 128+SVOL;
614 +@@ -138,8 +138,13 @@ static irqreturn_t q40_timer_int (int irq, void * dev)
615 + *DAC_RIGHT=sval;
616 + }
617 +
618 +- if (!ql_ticks)
619 +- q40_timer_routine(irq, dev);
620 ++ if (!ql_ticks) {
621 ++ unsigned long flags;
622 ++
623 ++ local_irq_save(flags);
624 ++ timer_routine(0, NULL);
625 ++ local_irq_restore(flags);
626 ++ }
627 + return IRQ_HANDLED;
628 + }
629 +
630 +@@ -147,11 +152,9 @@ void q40_sched_init (irq_handler_t timer_routine)
631 + {
632 + int timer_irq;
633 +
634 +- q40_timer_routine = timer_routine;
635 + timer_irq = Q40_IRQ_FRAME;
636 +
637 +- if (request_irq(timer_irq, q40_timer_int, 0,
638 +- "timer", q40_timer_int))
639 ++ if (request_irq(timer_irq, q40_timer_int, 0, "timer", timer_routine))
640 + panic("Couldn't register timer int");
641 +
642 + master_outb(-1, FRAME_CLEAR_REG);
643 +diff --git a/arch/m68k/sun3/sun3ints.c b/arch/m68k/sun3/sun3ints.c
644 +index 6bbca30c9188..a5824abb4a39 100644
645 +--- a/arch/m68k/sun3/sun3ints.c
646 ++++ b/arch/m68k/sun3/sun3ints.c
647 +@@ -61,8 +61,10 @@ static irqreturn_t sun3_int7(int irq, void *dev_id)
648 +
649 + static irqreturn_t sun3_int5(int irq, void *dev_id)
650 + {
651 ++ unsigned long flags;
652 + unsigned int cnt;
653 +
654 ++ local_irq_save(flags);
655 + #ifdef CONFIG_SUN3
656 + intersil_clear();
657 + #endif
658 +@@ -76,6 +78,7 @@ static irqreturn_t sun3_int5(int irq, void *dev_id)
659 + cnt = kstat_irqs_cpu(irq, 0);
660 + if (!(cnt % 20))
661 + sun3_leds(led_pattern[cnt % 160 / 20]);
662 ++ local_irq_restore(flags);
663 + return IRQ_HANDLED;
664 + }
665 +
666 +diff --git a/arch/m68k/sun3x/time.c b/arch/m68k/sun3x/time.c
667 +index c8eb08add6b0..7a195313ff4f 100644
668 +--- a/arch/m68k/sun3x/time.c
669 ++++ b/arch/m68k/sun3x/time.c
670 +@@ -77,15 +77,19 @@ u32 sun3x_gettimeoffset(void)
671 + }
672 +
673 + #if 0
674 +-static void sun3x_timer_tick(int irq, void *dev_id, struct pt_regs *regs)
675 ++static irqreturn_t sun3x_timer_tick(int irq, void *dev_id)
676 + {
677 +- void (*vector)(int, void *, struct pt_regs *) = dev_id;
678 ++ irq_handler_t timer_routine = dev_id;
679 ++ unsigned long flags;
680 +
681 +- /* Clear the pending interrupt - pulse the enable line low */
682 +- disable_irq(5);
683 +- enable_irq(5);
684 ++ local_irq_save(flags);
685 ++ /* Clear the pending interrupt - pulse the enable line low */
686 ++ disable_irq(5);
687 ++ enable_irq(5);
688 ++ timer_routine(0, NULL);
689 ++ local_irq_restore(flags);
690 +
691 +- vector(irq, NULL, regs);
692 ++ return IRQ_HANDLED;
693 + }
694 + #endif
695 +
696 +diff --git a/arch/mips/include/asm/io.h b/arch/mips/include/asm/io.h
697 +index ab1df19b0957..60604b26fa72 100644
698 +--- a/arch/mips/include/asm/io.h
699 ++++ b/arch/mips/include/asm/io.h
700 +@@ -60,21 +60,11 @@
701 + * instruction, so the lower 16 bits must be zero. Should be true on
702 + * on any sane architecture; generic code does not use this assumption.
703 + */
704 +-extern const unsigned long mips_io_port_base;
705 ++extern unsigned long mips_io_port_base;
706 +
707 +-/*
708 +- * Gcc will generate code to load the value of mips_io_port_base after each
709 +- * function call which may be fairly wasteful in some cases. So we don't
710 +- * play quite by the book. We tell gcc mips_io_port_base is a long variable
711 +- * which solves the code generation issue. Now we need to violate the
712 +- * aliasing rules a little to make initialization possible and finally we
713 +- * will need the barrier() to fight side effects of the aliasing chat.
714 +- * This trickery will eventually collapse under gcc's optimizer. Oh well.
715 +- */
716 + static inline void set_io_port_base(unsigned long base)
717 + {
718 +- * (unsigned long *) &mips_io_port_base = base;
719 +- barrier();
720 ++ mips_io_port_base = base;
721 + }
722 +
723 + /*
724 +diff --git a/arch/mips/kernel/setup.c b/arch/mips/kernel/setup.c
725 +index 4f9f1ae49213..fadc946b306d 100644
726 +--- a/arch/mips/kernel/setup.c
727 ++++ b/arch/mips/kernel/setup.c
728 +@@ -80,7 +80,7 @@ static char __initdata builtin_cmdline[COMMAND_LINE_SIZE] = CONFIG_CMDLINE;
729 + * mips_io_port_base is the begin of the address space to which x86 style
730 + * I/O ports are mapped.
731 + */
732 +-const unsigned long mips_io_port_base = -1;
733 ++unsigned long mips_io_port_base = -1;
734 + EXPORT_SYMBOL(mips_io_port_base);
735 +
736 + static struct resource code_resource = { .name = "Kernel code", };
737 +diff --git a/arch/nios2/kernel/nios2_ksyms.c b/arch/nios2/kernel/nios2_ksyms.c
738 +index bf2f55d10a4d..4e704046a150 100644
739 +--- a/arch/nios2/kernel/nios2_ksyms.c
740 ++++ b/arch/nios2/kernel/nios2_ksyms.c
741 +@@ -9,12 +9,20 @@
742 + #include <linux/export.h>
743 + #include <linux/string.h>
744 +
745 ++#include <asm/cacheflush.h>
746 ++#include <asm/pgtable.h>
747 ++
748 + /* string functions */
749 +
750 + EXPORT_SYMBOL(memcpy);
751 + EXPORT_SYMBOL(memset);
752 + EXPORT_SYMBOL(memmove);
753 +
754 ++/* memory management */
755 ++
756 ++EXPORT_SYMBOL(empty_zero_page);
757 ++EXPORT_SYMBOL(flush_icache_range);
758 ++
759 + /*
760 + * libgcc functions - functions that are used internally by the
761 + * compiler... (prototypes are not correct though, but that
762 +@@ -31,3 +39,7 @@ DECLARE_EXPORT(__udivsi3);
763 + DECLARE_EXPORT(__umoddi3);
764 + DECLARE_EXPORT(__umodsi3);
765 + DECLARE_EXPORT(__muldi3);
766 ++DECLARE_EXPORT(__ucmpdi2);
767 ++DECLARE_EXPORT(__lshrdi3);
768 ++DECLARE_EXPORT(__ashldi3);
769 ++DECLARE_EXPORT(__ashrdi3);
770 +diff --git a/arch/powerpc/Makefile b/arch/powerpc/Makefile
771 +index d7eb035a9c96..65cb22541c66 100644
772 +--- a/arch/powerpc/Makefile
773 ++++ b/arch/powerpc/Makefile
774 +@@ -350,7 +350,9 @@ vdso_install:
775 + ifeq ($(CONFIG_PPC64),y)
776 + $(Q)$(MAKE) $(build)=arch/$(ARCH)/kernel/vdso64 $@
777 + endif
778 ++ifdef CONFIG_VDSO32
779 + $(Q)$(MAKE) $(build)=arch/$(ARCH)/kernel/vdso32 $@
780 ++endif
781 +
782 + archclean:
783 + $(Q)$(MAKE) $(clean)=$(boot)
784 +diff --git a/arch/powerpc/include/asm/archrandom.h b/arch/powerpc/include/asm/archrandom.h
785 +index 85e88f7a59c0..9ff848e3c4a6 100644
786 +--- a/arch/powerpc/include/asm/archrandom.h
787 ++++ b/arch/powerpc/include/asm/archrandom.h
788 +@@ -27,7 +27,7 @@ static inline int arch_get_random_seed_int(unsigned int *v)
789 + unsigned long val;
790 + int rc;
791 +
792 +- rc = arch_get_random_long(&val);
793 ++ rc = arch_get_random_seed_long(&val);
794 + if (rc)
795 + *v = val;
796 +
797 +diff --git a/arch/powerpc/kernel/cacheinfo.c b/arch/powerpc/kernel/cacheinfo.c
798 +index c641983bbdd6..3394a72b19f2 100644
799 +--- a/arch/powerpc/kernel/cacheinfo.c
800 ++++ b/arch/powerpc/kernel/cacheinfo.c
801 +@@ -867,4 +867,21 @@ void cacheinfo_cpu_offline(unsigned int cpu_id)
802 + if (cache)
803 + cache_cpu_clear(cache, cpu_id);
804 + }
805 ++
806 ++void cacheinfo_teardown(void)
807 ++{
808 ++ unsigned int cpu;
809 ++
810 ++ for_each_online_cpu(cpu)
811 ++ cacheinfo_cpu_offline(cpu);
812 ++}
813 ++
814 ++void cacheinfo_rebuild(void)
815 ++{
816 ++ unsigned int cpu;
817 ++
818 ++ for_each_online_cpu(cpu)
819 ++ cacheinfo_cpu_online(cpu);
820 ++}
821 ++
822 + #endif /* (CONFIG_PPC_PSERIES && CONFIG_SUSPEND) || CONFIG_HOTPLUG_CPU */
823 +diff --git a/arch/powerpc/kernel/cacheinfo.h b/arch/powerpc/kernel/cacheinfo.h
824 +index a7b74d36acd7..2cdee87a482c 100644
825 +--- a/arch/powerpc/kernel/cacheinfo.h
826 ++++ b/arch/powerpc/kernel/cacheinfo.h
827 +@@ -5,4 +5,8 @@
828 + extern void cacheinfo_cpu_online(unsigned int cpu_id);
829 + extern void cacheinfo_cpu_offline(unsigned int cpu_id);
830 +
831 ++/* Allow migration/suspend to tear down and rebuild the hierarchy. */
832 ++extern void cacheinfo_teardown(void);
833 ++extern void cacheinfo_rebuild(void);
834 ++
835 + #endif /* _PPC_CACHEINFO_H */
836 +diff --git a/arch/powerpc/sysdev/qe_lib/gpio.c b/arch/powerpc/sysdev/qe_lib/gpio.c
837 +index 521e67a49dc4..4052e3d7edbd 100644
838 +--- a/arch/powerpc/sysdev/qe_lib/gpio.c
839 ++++ b/arch/powerpc/sysdev/qe_lib/gpio.c
840 +@@ -155,8 +155,10 @@ struct qe_pin *qe_pin_request(struct device_node *np, int index)
841 + if (err < 0)
842 + goto err0;
843 + gc = gpio_to_chip(err);
844 +- if (WARN_ON(!gc))
845 ++ if (WARN_ON(!gc)) {
846 ++ err = -ENODEV;
847 + goto err0;
848 ++ }
849 +
850 + if (!of_device_is_compatible(gc->of_node, "fsl,mpc8323-qe-pario-bank")) {
851 + pr_debug("%s: tried to get a non-qe pin\n", __func__);
852 +diff --git a/arch/x86/Kconfig.debug b/arch/x86/Kconfig.debug
853 +index 2aa212fb0faf..31c191a08bb1 100644
854 +--- a/arch/x86/Kconfig.debug
855 ++++ b/arch/x86/Kconfig.debug
856 +@@ -221,7 +221,7 @@ config HAVE_MMIOTRACE_SUPPORT
857 +
858 + config X86_DECODER_SELFTEST
859 + bool "x86 instruction decoder selftest"
860 +- depends on DEBUG_KERNEL && KPROBES
861 ++ depends on DEBUG_KERNEL && INSTRUCTION_DECODER
862 + depends on !COMPILE_TEST
863 + ---help---
864 + Perform x86 instruction decoder selftests at build time.
865 +diff --git a/arch/x86/kernel/kgdb.c b/arch/x86/kernel/kgdb.c
866 +index 44256a62702b..4a08fda2b06f 100644
867 +--- a/arch/x86/kernel/kgdb.c
868 ++++ b/arch/x86/kernel/kgdb.c
869 +@@ -437,7 +437,7 @@ static void kgdb_disable_hw_debug(struct pt_regs *regs)
870 + */
871 + void kgdb_roundup_cpus(unsigned long flags)
872 + {
873 +- apic->send_IPI_allbutself(APIC_DM_NMI);
874 ++ apic->send_IPI_allbutself(NMI_VECTOR);
875 + }
876 + #endif
877 +
878 +diff --git a/block/blk-merge.c b/block/blk-merge.c
879 +index 7225511cf0b4..b8f1eaeeaac2 100644
880 +--- a/block/blk-merge.c
881 ++++ b/block/blk-merge.c
882 +@@ -296,13 +296,7 @@ void blk_recalc_rq_segments(struct request *rq)
883 +
884 + void blk_recount_segments(struct request_queue *q, struct bio *bio)
885 + {
886 +- unsigned short seg_cnt;
887 +-
888 +- /* estimate segment number by bi_vcnt for non-cloned bio */
889 +- if (bio_flagged(bio, BIO_CLONED))
890 +- seg_cnt = bio_segments(bio);
891 +- else
892 +- seg_cnt = bio->bi_vcnt;
893 ++ unsigned short seg_cnt = bio_segments(bio);
894 +
895 + if (test_bit(QUEUE_FLAG_NO_SG_MERGE, &q->queue_flags) &&
896 + (seg_cnt < queue_max_segments(q)))
897 +diff --git a/crypto/pcrypt.c b/crypto/pcrypt.c
898 +index f8ec3d4ba4a8..a5718c0a3dc4 100644
899 +--- a/crypto/pcrypt.c
900 ++++ b/crypto/pcrypt.c
901 +@@ -394,7 +394,7 @@ static int pcrypt_sysfs_add(struct padata_instance *pinst, const char *name)
902 + int ret;
903 +
904 + pinst->kobj.kset = pcrypt_kset;
905 +- ret = kobject_add(&pinst->kobj, NULL, name);
906 ++ ret = kobject_add(&pinst->kobj, NULL, "%s", name);
907 + if (!ret)
908 + kobject_uevent(&pinst->kobj, KOBJ_ADD);
909 +
910 +diff --git a/crypto/tgr192.c b/crypto/tgr192.c
911 +index 321bc6ff2a9d..904c8444aa0a 100644
912 +--- a/crypto/tgr192.c
913 ++++ b/crypto/tgr192.c
914 +@@ -25,8 +25,9 @@
915 + #include <linux/init.h>
916 + #include <linux/module.h>
917 + #include <linux/mm.h>
918 +-#include <asm/byteorder.h>
919 + #include <linux/types.h>
920 ++#include <asm/byteorder.h>
921 ++#include <asm/unaligned.h>
922 +
923 + #define TGR192_DIGEST_SIZE 24
924 + #define TGR160_DIGEST_SIZE 20
925 +@@ -468,10 +469,9 @@ static void tgr192_transform(struct tgr192_ctx *tctx, const u8 * data)
926 + u64 a, b, c, aa, bb, cc;
927 + u64 x[8];
928 + int i;
929 +- const __le64 *ptr = (const __le64 *)data;
930 +
931 + for (i = 0; i < 8; i++)
932 +- x[i] = le64_to_cpu(ptr[i]);
933 ++ x[i] = get_unaligned_le64(data + i * sizeof(__le64));
934 +
935 + /* save */
936 + a = aa = tctx->a;
937 +diff --git a/drivers/ata/libahci.c b/drivers/ata/libahci.c
938 +index 8116cb2fef2d..1241cecfcfca 100644
939 +--- a/drivers/ata/libahci.c
940 ++++ b/drivers/ata/libahci.c
941 +@@ -187,7 +187,6 @@ struct ata_port_operations ahci_pmp_retry_srst_ops = {
942 + EXPORT_SYMBOL_GPL(ahci_pmp_retry_srst_ops);
943 +
944 + static bool ahci_em_messages __read_mostly = true;
945 +-EXPORT_SYMBOL_GPL(ahci_em_messages);
946 + module_param(ahci_em_messages, bool, 0444);
947 + /* add other LED protocol types when they become supported */
948 + MODULE_PARM_DESC(ahci_em_messages,
949 +diff --git a/drivers/atm/firestream.c b/drivers/atm/firestream.c
950 +index 82f2ae0d7cc4..04b39d0da868 100644
951 +--- a/drivers/atm/firestream.c
952 ++++ b/drivers/atm/firestream.c
953 +@@ -923,6 +923,7 @@ static int fs_open(struct atm_vcc *atm_vcc)
954 + }
955 + if (!to) {
956 + printk ("No more free channels for FS50..\n");
957 ++ kfree(vcc);
958 + return -EBUSY;
959 + }
960 + vcc->channo = dev->channo;
961 +@@ -933,6 +934,7 @@ static int fs_open(struct atm_vcc *atm_vcc)
962 + if (((DO_DIRECTION(rxtp) && dev->atm_vccs[vcc->channo])) ||
963 + ( DO_DIRECTION(txtp) && test_bit (vcc->channo, dev->tx_inuse))) {
964 + printk ("Channel is in use for FS155.\n");
965 ++ kfree(vcc);
966 + return -EBUSY;
967 + }
968 + }
969 +@@ -946,6 +948,7 @@ static int fs_open(struct atm_vcc *atm_vcc)
970 + tc, sizeof (struct fs_transmit_config));
971 + if (!tc) {
972 + fs_dprintk (FS_DEBUG_OPEN, "fs: can't alloc transmit_config.\n");
973 ++ kfree(vcc);
974 + return -ENOMEM;
975 + }
976 +
977 +diff --git a/drivers/bcma/driver_pci.c b/drivers/bcma/driver_pci.c
978 +index f499a469e66d..12b2cc9a3fbe 100644
979 +--- a/drivers/bcma/driver_pci.c
980 ++++ b/drivers/bcma/driver_pci.c
981 +@@ -78,7 +78,7 @@ static u16 bcma_pcie_mdio_read(struct bcma_drv_pci *pc, u16 device, u8 address)
982 + v |= (address << BCMA_CORE_PCI_MDIODATA_REGADDR_SHF_OLD);
983 + }
984 +
985 +- v = BCMA_CORE_PCI_MDIODATA_START;
986 ++ v |= BCMA_CORE_PCI_MDIODATA_START;
987 + v |= BCMA_CORE_PCI_MDIODATA_READ;
988 + v |= BCMA_CORE_PCI_MDIODATA_TA;
989 +
990 +@@ -121,7 +121,7 @@ static void bcma_pcie_mdio_write(struct bcma_drv_pci *pc, u16 device,
991 + v |= (address << BCMA_CORE_PCI_MDIODATA_REGADDR_SHF_OLD);
992 + }
993 +
994 +- v = BCMA_CORE_PCI_MDIODATA_START;
995 ++ v |= BCMA_CORE_PCI_MDIODATA_START;
996 + v |= BCMA_CORE_PCI_MDIODATA_WRITE;
997 + v |= BCMA_CORE_PCI_MDIODATA_TA;
998 + v |= data;
999 +diff --git a/drivers/block/drbd/drbd_main.c b/drivers/block/drbd/drbd_main.c
1000 +index 385ec4ae3394..456350bd24b3 100644
1001 +--- a/drivers/block/drbd/drbd_main.c
1002 ++++ b/drivers/block/drbd/drbd_main.c
1003 +@@ -331,6 +331,8 @@ static int drbd_thread_setup(void *arg)
1004 + thi->name[0],
1005 + resource->name);
1006 +
1007 ++ allow_kernel_signal(DRBD_SIGKILL);
1008 ++ allow_kernel_signal(SIGXCPU);
1009 + restart:
1010 + retval = thi->function(thi);
1011 +
1012 +diff --git a/drivers/clk/clk-highbank.c b/drivers/clk/clk-highbank.c
1013 +index be3a21abb185..4105066b428c 100644
1014 +--- a/drivers/clk/clk-highbank.c
1015 ++++ b/drivers/clk/clk-highbank.c
1016 +@@ -294,6 +294,7 @@ static __init struct clk *hb_clk_init(struct device_node *node, const struct clk
1017 + /* Map system registers */
1018 + srnp = of_find_compatible_node(NULL, NULL, "calxeda,hb-sregs");
1019 + hb_clk->reg = of_iomap(srnp, 0);
1020 ++ of_node_put(srnp);
1021 + BUG_ON(!hb_clk->reg);
1022 + hb_clk->reg += reg;
1023 +
1024 +diff --git a/drivers/clk/clk-qoriq.c b/drivers/clk/clk-qoriq.c
1025 +index 7244a621c61b..efc9e1973295 100644
1026 +--- a/drivers/clk/clk-qoriq.c
1027 ++++ b/drivers/clk/clk-qoriq.c
1028 +@@ -1244,6 +1244,7 @@ static void __init clockgen_init(struct device_node *np)
1029 + pr_err("%s: Couldn't map %s regs\n", __func__,
1030 + guts->full_name);
1031 + }
1032 ++ of_node_put(guts);
1033 + }
1034 +
1035 + }
1036 +diff --git a/drivers/clk/imx/clk-imx6q.c b/drivers/clk/imx/clk-imx6q.c
1037 +index 46c05c9a9354..39ea50102d52 100644
1038 +--- a/drivers/clk/imx/clk-imx6q.c
1039 ++++ b/drivers/clk/imx/clk-imx6q.c
1040 +@@ -155,6 +155,7 @@ static void __init imx6q_clocks_init(struct device_node *ccm_node)
1041 + np = of_find_compatible_node(NULL, NULL, "fsl,imx6q-anatop");
1042 + base = of_iomap(np, 0);
1043 + WARN_ON(!base);
1044 ++ of_node_put(np);
1045 +
1046 + /* Audio/video PLL post dividers do not work on i.MX6q revision 1.0 */
1047 + if (clk_on_imx6q() && imx_get_soc_revision() == IMX_CHIP_REVISION_1_0) {
1048 +diff --git a/drivers/clk/imx/clk-imx6sx.c b/drivers/clk/imx/clk-imx6sx.c
1049 +index fea125eb4330..8f2958ac04e8 100644
1050 +--- a/drivers/clk/imx/clk-imx6sx.c
1051 ++++ b/drivers/clk/imx/clk-imx6sx.c
1052 +@@ -162,6 +162,7 @@ static void __init imx6sx_clocks_init(struct device_node *ccm_node)
1053 + np = of_find_compatible_node(NULL, NULL, "fsl,imx6sx-anatop");
1054 + base = of_iomap(np, 0);
1055 + WARN_ON(!base);
1056 ++ of_node_put(np);
1057 +
1058 + clks[IMX6SX_PLL1_BYPASS_SRC] = imx_clk_mux("pll1_bypass_src", base + 0x00, 14, 1, pll_bypass_src_sels, ARRAY_SIZE(pll_bypass_src_sels));
1059 + clks[IMX6SX_PLL2_BYPASS_SRC] = imx_clk_mux("pll2_bypass_src", base + 0x30, 14, 1, pll_bypass_src_sels, ARRAY_SIZE(pll_bypass_src_sels));
1060 +diff --git a/drivers/clk/imx/clk-imx7d.c b/drivers/clk/imx/clk-imx7d.c
1061 +index 448ef321948b..863163b239a3 100644
1062 +--- a/drivers/clk/imx/clk-imx7d.c
1063 ++++ b/drivers/clk/imx/clk-imx7d.c
1064 +@@ -386,6 +386,7 @@ static void __init imx7d_clocks_init(struct device_node *ccm_node)
1065 + np = of_find_compatible_node(NULL, NULL, "fsl,imx7d-anatop");
1066 + base = of_iomap(np, 0);
1067 + WARN_ON(!base);
1068 ++ of_node_put(np);
1069 +
1070 + clks[IMX7D_PLL_ARM_MAIN_SRC] = imx_clk_mux("pll_arm_main_src", base + 0x60, 14, 2, pll_bypass_src_sel, ARRAY_SIZE(pll_bypass_src_sel));
1071 + clks[IMX7D_PLL_DRAM_MAIN_SRC] = imx_clk_mux("pll_dram_main_src", base + 0x70, 14, 2, pll_bypass_src_sel, ARRAY_SIZE(pll_bypass_src_sel));
1072 +diff --git a/drivers/clk/imx/clk-vf610.c b/drivers/clk/imx/clk-vf610.c
1073 +index 0a94d9661d91..2c92a2706fdd 100644
1074 +--- a/drivers/clk/imx/clk-vf610.c
1075 ++++ b/drivers/clk/imx/clk-vf610.c
1076 +@@ -155,6 +155,7 @@ static void __init vf610_clocks_init(struct device_node *ccm_node)
1077 + np = of_find_compatible_node(NULL, NULL, "fsl,vf610-anatop");
1078 + anatop_base = of_iomap(np, 0);
1079 + BUG_ON(!anatop_base);
1080 ++ of_node_put(np);
1081 +
1082 + np = ccm_node;
1083 + ccm_base = of_iomap(np, 0);
1084 +diff --git a/drivers/clk/mvebu/armada-370.c b/drivers/clk/mvebu/armada-370.c
1085 +index 2c7c1085f883..8fdfa97900cd 100644
1086 +--- a/drivers/clk/mvebu/armada-370.c
1087 ++++ b/drivers/clk/mvebu/armada-370.c
1088 +@@ -177,8 +177,10 @@ static void __init a370_clk_init(struct device_node *np)
1089 +
1090 + mvebu_coreclk_setup(np, &a370_coreclks);
1091 +
1092 +- if (cgnp)
1093 ++ if (cgnp) {
1094 + mvebu_clk_gating_setup(cgnp, a370_gating_desc);
1095 ++ of_node_put(cgnp);
1096 ++ }
1097 + }
1098 + CLK_OF_DECLARE(a370_clk, "marvell,armada-370-core-clock", a370_clk_init);
1099 +
1100 +diff --git a/drivers/clk/mvebu/armada-xp.c b/drivers/clk/mvebu/armada-xp.c
1101 +index b3094315a3c0..2fa15a274719 100644
1102 +--- a/drivers/clk/mvebu/armada-xp.c
1103 ++++ b/drivers/clk/mvebu/armada-xp.c
1104 +@@ -202,7 +202,9 @@ static void __init axp_clk_init(struct device_node *np)
1105 +
1106 + mvebu_coreclk_setup(np, &axp_coreclks);
1107 +
1108 +- if (cgnp)
1109 ++ if (cgnp) {
1110 + mvebu_clk_gating_setup(cgnp, axp_gating_desc);
1111 ++ of_node_put(cgnp);
1112 ++ }
1113 + }
1114 + CLK_OF_DECLARE(axp_clk, "marvell,armada-xp-core-clock", axp_clk_init);
1115 +diff --git a/drivers/clk/mvebu/kirkwood.c b/drivers/clk/mvebu/kirkwood.c
1116 +index 99550f25975e..1d2b9a1a9609 100644
1117 +--- a/drivers/clk/mvebu/kirkwood.c
1118 ++++ b/drivers/clk/mvebu/kirkwood.c
1119 +@@ -335,6 +335,8 @@ static void __init kirkwood_clk_init(struct device_node *np)
1120 + if (cgnp) {
1121 + mvebu_clk_gating_setup(cgnp, kirkwood_gating_desc);
1122 + kirkwood_clk_muxing_setup(cgnp, kirkwood_mux_desc);
1123 ++
1124 ++ of_node_put(cgnp);
1125 + }
1126 + }
1127 + CLK_OF_DECLARE(kirkwood_clk, "marvell,kirkwood-core-clock",
1128 +diff --git a/drivers/clk/samsung/clk-exynos4.c b/drivers/clk/samsung/clk-exynos4.c
1129 +index 7f370d3e0983..6c8e45e007c8 100644
1130 +--- a/drivers/clk/samsung/clk-exynos4.c
1131 ++++ b/drivers/clk/samsung/clk-exynos4.c
1132 +@@ -1224,6 +1224,7 @@ static unsigned long exynos4_get_xom(void)
1133 + xom = readl(chipid_base + 8);
1134 +
1135 + iounmap(chipid_base);
1136 ++ of_node_put(np);
1137 + }
1138 +
1139 + return xom;
1140 +diff --git a/drivers/clk/socfpga/clk-pll-a10.c b/drivers/clk/socfpga/clk-pll-a10.c
1141 +index 402d630bd531..623d5b77fb43 100644
1142 +--- a/drivers/clk/socfpga/clk-pll-a10.c
1143 ++++ b/drivers/clk/socfpga/clk-pll-a10.c
1144 +@@ -95,6 +95,7 @@ static struct __init clk * __socfpga_pll_init(struct device_node *node,
1145 +
1146 + clkmgr_np = of_find_compatible_node(NULL, NULL, "altr,clk-mgr");
1147 + clk_mgr_a10_base_addr = of_iomap(clkmgr_np, 0);
1148 ++ of_node_put(clkmgr_np);
1149 + BUG_ON(!clk_mgr_a10_base_addr);
1150 + pll_clk->hw.reg = clk_mgr_a10_base_addr + reg;
1151 +
1152 +diff --git a/drivers/clk/socfpga/clk-pll.c b/drivers/clk/socfpga/clk-pll.c
1153 +index c7f463172e4b..b4b44e9b5901 100644
1154 +--- a/drivers/clk/socfpga/clk-pll.c
1155 ++++ b/drivers/clk/socfpga/clk-pll.c
1156 +@@ -100,6 +100,7 @@ static __init struct clk *__socfpga_pll_init(struct device_node *node,
1157 +
1158 + clkmgr_np = of_find_compatible_node(NULL, NULL, "altr,clk-mgr");
1159 + clk_mgr_base_addr = of_iomap(clkmgr_np, 0);
1160 ++ of_node_put(clkmgr_np);
1161 + BUG_ON(!clk_mgr_base_addr);
1162 + pll_clk->hw.reg = clk_mgr_base_addr + reg;
1163 +
1164 +diff --git a/drivers/clocksource/timer-sun5i.c b/drivers/clocksource/timer-sun5i.c
1165 +index bca9573e036a..32b2dab69fd7 100644
1166 +--- a/drivers/clocksource/timer-sun5i.c
1167 ++++ b/drivers/clocksource/timer-sun5i.c
1168 +@@ -201,6 +201,11 @@ static int __init sun5i_setup_clocksource(struct device_node *node,
1169 + }
1170 +
1171 + rate = clk_get_rate(clk);
1172 ++ if (!rate) {
1173 ++ pr_err("Couldn't get parent clock rate\n");
1174 ++ ret = -EINVAL;
1175 ++ goto err_disable_clk;
1176 ++ }
1177 +
1178 + cs->timer.base = base;
1179 + cs->timer.clk = clk;
1180 +@@ -274,6 +279,11 @@ static int __init sun5i_setup_clockevent(struct device_node *node, void __iomem
1181 + }
1182 +
1183 + rate = clk_get_rate(clk);
1184 ++ if (!rate) {
1185 ++ pr_err("Couldn't get parent clock rate\n");
1186 ++ ret = -EINVAL;
1187 ++ goto err_disable_clk;
1188 ++ }
1189 +
1190 + ce->timer.base = base;
1191 + ce->timer.ticks_per_jiffy = DIV_ROUND_UP(rate, HZ);
1192 +diff --git a/drivers/crypto/caam/caamrng.c b/drivers/crypto/caam/caamrng.c
1193 +index 9b92af2c7241..a77319bf221d 100644
1194 +--- a/drivers/crypto/caam/caamrng.c
1195 ++++ b/drivers/crypto/caam/caamrng.c
1196 +@@ -361,7 +361,10 @@ static int __init caam_rng_init(void)
1197 + goto free_rng_ctx;
1198 +
1199 + dev_info(dev, "registering rng-caam\n");
1200 +- return hwrng_register(&caam_rng);
1201 ++
1202 ++ err = hwrng_register(&caam_rng);
1203 ++ if (!err)
1204 ++ return err;
1205 +
1206 + free_rng_ctx:
1207 + kfree(rng_ctx);
1208 +diff --git a/drivers/dma/dma-axi-dmac.c b/drivers/dma/dma-axi-dmac.c
1209 +index 5b2395e7e04d..6de3d2142c7d 100644
1210 +--- a/drivers/dma/dma-axi-dmac.c
1211 ++++ b/drivers/dma/dma-axi-dmac.c
1212 +@@ -441,7 +441,7 @@ static struct dma_async_tx_descriptor *axi_dmac_prep_interleaved(
1213 +
1214 + if (chan->hw_2d) {
1215 + if (!axi_dmac_check_len(chan, xt->sgl[0].size) ||
1216 +- !axi_dmac_check_len(chan, xt->numf))
1217 ++ xt->numf == 0)
1218 + return NULL;
1219 + if (xt->sgl[0].size + dst_icg > chan->max_length ||
1220 + xt->sgl[0].size + src_icg > chan->max_length)
1221 +diff --git a/drivers/dma/dw/platform.c b/drivers/dma/dw/platform.c
1222 +index 68a4815750b5..22d0cc1855b5 100644
1223 +--- a/drivers/dma/dw/platform.c
1224 ++++ b/drivers/dma/dw/platform.c
1225 +@@ -87,13 +87,20 @@ static void dw_dma_acpi_controller_register(struct dw_dma *dw)
1226 + dma_cap_set(DMA_SLAVE, info->dma_cap);
1227 + info->filter_fn = dw_dma_acpi_filter;
1228 +
1229 +- ret = devm_acpi_dma_controller_register(dev, acpi_dma_simple_xlate,
1230 +- info);
1231 ++ ret = acpi_dma_controller_register(dev, acpi_dma_simple_xlate, info);
1232 + if (ret)
1233 + dev_err(dev, "could not register acpi_dma_controller\n");
1234 + }
1235 ++
1236 ++static void dw_dma_acpi_controller_free(struct dw_dma *dw)
1237 ++{
1238 ++ struct device *dev = dw->dma.dev;
1239 ++
1240 ++ acpi_dma_controller_free(dev);
1241 ++}
1242 + #else /* !CONFIG_ACPI */
1243 + static inline void dw_dma_acpi_controller_register(struct dw_dma *dw) {}
1244 ++static inline void dw_dma_acpi_controller_free(struct dw_dma *dw) {}
1245 + #endif /* !CONFIG_ACPI */
1246 +
1247 + #ifdef CONFIG_OF
1248 +@@ -225,6 +232,9 @@ static int dw_remove(struct platform_device *pdev)
1249 + {
1250 + struct dw_dma_chip *chip = platform_get_drvdata(pdev);
1251 +
1252 ++ if (ACPI_HANDLE(&pdev->dev))
1253 ++ dw_dma_acpi_controller_free(chip->dw);
1254 ++
1255 + if (pdev->dev.of_node)
1256 + of_dma_controller_free(pdev->dev.of_node);
1257 +
1258 +diff --git a/drivers/dma/edma.c b/drivers/dma/edma.c
1259 +index e508c8c5f3fd..17521fcf226f 100644
1260 +--- a/drivers/dma/edma.c
1261 ++++ b/drivers/dma/edma.c
1262 +@@ -2288,8 +2288,10 @@ static int edma_probe(struct platform_device *pdev)
1263 +
1264 + ecc->tc_list = devm_kcalloc(dev, ecc->num_tc,
1265 + sizeof(*ecc->tc_list), GFP_KERNEL);
1266 +- if (!ecc->tc_list)
1267 +- return -ENOMEM;
1268 ++ if (!ecc->tc_list) {
1269 ++ ret = -ENOMEM;
1270 ++ goto err_reg1;
1271 ++ }
1272 +
1273 + for (i = 0;; i++) {
1274 + ret = of_parse_phandle_with_fixed_args(node, "ti,tptcs",
1275 +diff --git a/drivers/dma/imx-sdma.c b/drivers/dma/imx-sdma.c
1276 +index dd97dbf6618c..1dc06e0e890f 100644
1277 +--- a/drivers/dma/imx-sdma.c
1278 ++++ b/drivers/dma/imx-sdma.c
1279 +@@ -1411,6 +1411,14 @@ static void sdma_add_scripts(struct sdma_engine *sdma,
1280 + if (!sdma->script_number)
1281 + sdma->script_number = SDMA_SCRIPT_ADDRS_ARRAY_SIZE_V1;
1282 +
1283 ++ if (sdma->script_number > sizeof(struct sdma_script_start_addrs)
1284 ++ / sizeof(s32)) {
1285 ++ dev_err(sdma->dev,
1286 ++ "SDMA script number %d not match with firmware.\n",
1287 ++ sdma->script_number);
1288 ++ return;
1289 ++ }
1290 ++
1291 + for (i = 0; i < sdma->script_number; i++)
1292 + if (addr_arr[i] > 0)
1293 + saddr_arr[i] = addr_arr[i];
1294 +diff --git a/drivers/gpu/drm/drm_dp_mst_topology.c b/drivers/gpu/drm/drm_dp_mst_topology.c
1295 +index 2cb924ffd5a3..4d0f77f0edad 100644
1296 +--- a/drivers/gpu/drm/drm_dp_mst_topology.c
1297 ++++ b/drivers/gpu/drm/drm_dp_mst_topology.c
1298 +@@ -975,9 +975,20 @@ static struct drm_dp_mst_port *drm_dp_mst_get_port_ref_locked(struct drm_dp_mst_
1299 + static struct drm_dp_mst_port *drm_dp_get_validated_port_ref(struct drm_dp_mst_topology_mgr *mgr, struct drm_dp_mst_port *port)
1300 + {
1301 + struct drm_dp_mst_port *rport = NULL;
1302 ++
1303 + mutex_lock(&mgr->lock);
1304 +- if (mgr->mst_primary)
1305 +- rport = drm_dp_mst_get_port_ref_locked(mgr->mst_primary, port);
1306 ++ /*
1307 ++ * Port may or may not be 'valid' but we don't care about that when
1308 ++ * destroying the port and we are guaranteed that the port pointer
1309 ++ * will be valid until we've finished
1310 ++ */
1311 ++ if (current_work() == &mgr->destroy_connector_work) {
1312 ++ kref_get(&port->kref);
1313 ++ rport = port;
1314 ++ } else if (mgr->mst_primary) {
1315 ++ rport = drm_dp_mst_get_port_ref_locked(mgr->mst_primary,
1316 ++ port);
1317 ++ }
1318 + mutex_unlock(&mgr->lock);
1319 + return rport;
1320 + }
1321 +diff --git a/drivers/gpu/drm/msm/adreno/a3xx_gpu.c b/drivers/gpu/drm/msm/adreno/a3xx_gpu.c
1322 +index fd266ed963b6..25a0e7d13340 100644
1323 +--- a/drivers/gpu/drm/msm/adreno/a3xx_gpu.c
1324 ++++ b/drivers/gpu/drm/msm/adreno/a3xx_gpu.c
1325 +@@ -383,19 +383,17 @@ static const unsigned int a3xx_registers[] = {
1326 + 0x2200, 0x2212, 0x2214, 0x2217, 0x221a, 0x221a, 0x2240, 0x227e,
1327 + 0x2280, 0x228b, 0x22c0, 0x22c0, 0x22c4, 0x22ce, 0x22d0, 0x22d8,
1328 + 0x22df, 0x22e6, 0x22e8, 0x22e9, 0x22ec, 0x22ec, 0x22f0, 0x22f7,
1329 +- 0x22ff, 0x22ff, 0x2340, 0x2343, 0x2348, 0x2349, 0x2350, 0x2356,
1330 +- 0x2360, 0x2360, 0x2440, 0x2440, 0x2444, 0x2444, 0x2448, 0x244d,
1331 +- 0x2468, 0x2469, 0x246c, 0x246d, 0x2470, 0x2470, 0x2472, 0x2472,
1332 +- 0x2474, 0x2475, 0x2479, 0x247a, 0x24c0, 0x24d3, 0x24e4, 0x24ef,
1333 +- 0x2500, 0x2509, 0x250c, 0x250c, 0x250e, 0x250e, 0x2510, 0x2511,
1334 +- 0x2514, 0x2515, 0x25e4, 0x25e4, 0x25ea, 0x25ea, 0x25ec, 0x25ed,
1335 +- 0x25f0, 0x25f0, 0x2600, 0x2612, 0x2614, 0x2617, 0x261a, 0x261a,
1336 +- 0x2640, 0x267e, 0x2680, 0x268b, 0x26c0, 0x26c0, 0x26c4, 0x26ce,
1337 +- 0x26d0, 0x26d8, 0x26df, 0x26e6, 0x26e8, 0x26e9, 0x26ec, 0x26ec,
1338 +- 0x26f0, 0x26f7, 0x26ff, 0x26ff, 0x2740, 0x2743, 0x2748, 0x2749,
1339 +- 0x2750, 0x2756, 0x2760, 0x2760, 0x300c, 0x300e, 0x301c, 0x301d,
1340 +- 0x302a, 0x302a, 0x302c, 0x302d, 0x3030, 0x3031, 0x3034, 0x3036,
1341 +- 0x303c, 0x303c, 0x305e, 0x305f,
1342 ++ 0x22ff, 0x22ff, 0x2340, 0x2343, 0x2440, 0x2440, 0x2444, 0x2444,
1343 ++ 0x2448, 0x244d, 0x2468, 0x2469, 0x246c, 0x246d, 0x2470, 0x2470,
1344 ++ 0x2472, 0x2472, 0x2474, 0x2475, 0x2479, 0x247a, 0x24c0, 0x24d3,
1345 ++ 0x24e4, 0x24ef, 0x2500, 0x2509, 0x250c, 0x250c, 0x250e, 0x250e,
1346 ++ 0x2510, 0x2511, 0x2514, 0x2515, 0x25e4, 0x25e4, 0x25ea, 0x25ea,
1347 ++ 0x25ec, 0x25ed, 0x25f0, 0x25f0, 0x2600, 0x2612, 0x2614, 0x2617,
1348 ++ 0x261a, 0x261a, 0x2640, 0x267e, 0x2680, 0x268b, 0x26c0, 0x26c0,
1349 ++ 0x26c4, 0x26ce, 0x26d0, 0x26d8, 0x26df, 0x26e6, 0x26e8, 0x26e9,
1350 ++ 0x26ec, 0x26ec, 0x26f0, 0x26f7, 0x26ff, 0x26ff, 0x2740, 0x2743,
1351 ++ 0x300c, 0x300e, 0x301c, 0x301d, 0x302a, 0x302a, 0x302c, 0x302d,
1352 ++ 0x3030, 0x3031, 0x3034, 0x3036, 0x303c, 0x303c, 0x305e, 0x305f,
1353 + ~0 /* sentinel */
1354 + };
1355 +
1356 +diff --git a/drivers/gpu/drm/msm/dsi/dsi_host.c b/drivers/gpu/drm/msm/dsi/dsi_host.c
1357 +index 4c49868efcda..12ddbbb53107 100644
1358 +--- a/drivers/gpu/drm/msm/dsi/dsi_host.c
1359 ++++ b/drivers/gpu/drm/msm/dsi/dsi_host.c
1360 +@@ -30,6 +30,8 @@
1361 + #include "dsi.xml.h"
1362 + #include "dsi_cfg.h"
1363 +
1364 ++#define DSI_RESET_TOGGLE_DELAY_MS 20
1365 ++
1366 + static int dsi_get_version(const void __iomem *base, u32 *major, u32 *minor)
1367 + {
1368 + u32 ver;
1369 +@@ -764,7 +766,7 @@ static void dsi_sw_reset(struct msm_dsi_host *msm_host)
1370 + wmb(); /* clocks need to be enabled before reset */
1371 +
1372 + dsi_write(msm_host, REG_DSI_RESET, 1);
1373 +- wmb(); /* make sure reset happen */
1374 ++ msleep(DSI_RESET_TOGGLE_DELAY_MS); /* make sure reset happen */
1375 + dsi_write(msm_host, REG_DSI_RESET, 0);
1376 + }
1377 +
1378 +@@ -1111,7 +1113,7 @@ static void dsi_sw_reset_restore(struct msm_dsi_host *msm_host)
1379 +
1380 + /* dsi controller can only be reset while clocks are running */
1381 + dsi_write(msm_host, REG_DSI_RESET, 1);
1382 +- wmb(); /* make sure reset happen */
1383 ++ msleep(DSI_RESET_TOGGLE_DELAY_MS); /* make sure reset happen */
1384 + dsi_write(msm_host, REG_DSI_RESET, 0);
1385 + wmb(); /* controller out of reset */
1386 + dsi_write(msm_host, REG_DSI_CTRL, data0);
1387 +diff --git a/drivers/gpu/drm/msm/mdp/mdp5/mdp5_cfg.c b/drivers/gpu/drm/msm/mdp/mdp5/mdp5_cfg.c
1388 +index bb1225aa2f75..89305ad3cde2 100644
1389 +--- a/drivers/gpu/drm/msm/mdp/mdp5/mdp5_cfg.c
1390 ++++ b/drivers/gpu/drm/msm/mdp/mdp5/mdp5_cfg.c
1391 +@@ -547,7 +547,7 @@ fail:
1392 + if (cfg_handler)
1393 + mdp5_cfg_destroy(cfg_handler);
1394 +
1395 +- return NULL;
1396 ++ return ERR_PTR(ret);
1397 + }
1398 +
1399 + static struct mdp5_cfg_platform *mdp5_get_config(struct platform_device *dev)
1400 +diff --git a/drivers/gpu/drm/nouveau/nvkm/subdev/fb/gddr3.c b/drivers/gpu/drm/nouveau/nvkm/subdev/fb/gddr3.c
1401 +index 60ece0a8a2e1..1d2d6bae73cd 100644
1402 +--- a/drivers/gpu/drm/nouveau/nvkm/subdev/fb/gddr3.c
1403 ++++ b/drivers/gpu/drm/nouveau/nvkm/subdev/fb/gddr3.c
1404 +@@ -87,7 +87,7 @@ nvkm_gddr3_calc(struct nvkm_ram *ram)
1405 + WR = (ram->next->bios.timing[2] & 0x007f0000) >> 16;
1406 + /* XXX: Get these values from the VBIOS instead */
1407 + DLL = !(ram->mr[1] & 0x1);
1408 +- RON = !(ram->mr[1] & 0x300) >> 8;
1409 ++ RON = !((ram->mr[1] & 0x300) >> 8);
1410 + break;
1411 + default:
1412 + return -ENOSYS;
1413 +diff --git a/drivers/gpu/drm/nouveau/nvkm/subdev/pmu/memx.c b/drivers/gpu/drm/nouveau/nvkm/subdev/pmu/memx.c
1414 +index e6f74168238c..2ef9e942f43a 100644
1415 +--- a/drivers/gpu/drm/nouveau/nvkm/subdev/pmu/memx.c
1416 ++++ b/drivers/gpu/drm/nouveau/nvkm/subdev/pmu/memx.c
1417 +@@ -87,10 +87,10 @@ nvkm_memx_fini(struct nvkm_memx **pmemx, bool exec)
1418 + if (exec) {
1419 + nvkm_pmu_send(pmu, reply, PROC_MEMX, MEMX_MSG_EXEC,
1420 + memx->base, finish);
1421 ++ nvkm_debug(subdev, "Exec took %uns, PMU_IN %08x\n",
1422 ++ reply[0], reply[1]);
1423 + }
1424 +
1425 +- nvkm_debug(subdev, "Exec took %uns, PMU_IN %08x\n",
1426 +- reply[0], reply[1]);
1427 + kfree(memx);
1428 + return 0;
1429 + }
1430 +diff --git a/drivers/gpu/drm/radeon/cik.c b/drivers/gpu/drm/radeon/cik.c
1431 +index 80b6d6e4721a..7acde09c8e8f 100644
1432 +--- a/drivers/gpu/drm/radeon/cik.c
1433 ++++ b/drivers/gpu/drm/radeon/cik.c
1434 +@@ -7372,8 +7372,8 @@ static int cik_irq_init(struct radeon_device *rdev)
1435 + }
1436 +
1437 + /* setup interrupt control */
1438 +- /* XXX this should actually be a bus address, not an MC address. same on older asics */
1439 +- WREG32(INTERRUPT_CNTL2, rdev->ih.gpu_addr >> 8);
1440 ++ /* set dummy read address to dummy page address */
1441 ++ WREG32(INTERRUPT_CNTL2, rdev->dummy_page.addr >> 8);
1442 + interrupt_cntl = RREG32(INTERRUPT_CNTL);
1443 + /* IH_DUMMY_RD_OVERRIDE=0 - dummy read disabled with msi, enabled without msi
1444 + * IH_DUMMY_RD_OVERRIDE=1 - dummy read controlled by IH_DUMMY_RD_EN
1445 +diff --git a/drivers/gpu/drm/radeon/r600.c b/drivers/gpu/drm/radeon/r600.c
1446 +index 0e20c08f8977..2056224d0b3c 100644
1447 +--- a/drivers/gpu/drm/radeon/r600.c
1448 ++++ b/drivers/gpu/drm/radeon/r600.c
1449 +@@ -3647,8 +3647,8 @@ int r600_irq_init(struct radeon_device *rdev)
1450 + }
1451 +
1452 + /* setup interrupt control */
1453 +- /* set dummy read address to ring address */
1454 +- WREG32(INTERRUPT_CNTL2, rdev->ih.gpu_addr >> 8);
1455 ++ /* set dummy read address to dummy page address */
1456 ++ WREG32(INTERRUPT_CNTL2, rdev->dummy_page.addr >> 8);
1457 + interrupt_cntl = RREG32(INTERRUPT_CNTL);
1458 + /* IH_DUMMY_RD_OVERRIDE=0 - dummy read disabled with msi, enabled without msi
1459 + * IH_DUMMY_RD_OVERRIDE=1 - dummy read controlled by IH_DUMMY_RD_EN
1460 +diff --git a/drivers/gpu/drm/radeon/si.c b/drivers/gpu/drm/radeon/si.c
1461 +index 5cf3a2cbc07e..4128c98d9054 100644
1462 +--- a/drivers/gpu/drm/radeon/si.c
1463 ++++ b/drivers/gpu/drm/radeon/si.c
1464 +@@ -6013,8 +6013,8 @@ static int si_irq_init(struct radeon_device *rdev)
1465 + }
1466 +
1467 + /* setup interrupt control */
1468 +- /* set dummy read address to ring address */
1469 +- WREG32(INTERRUPT_CNTL2, rdev->ih.gpu_addr >> 8);
1470 ++ /* set dummy read address to dummy page address */
1471 ++ WREG32(INTERRUPT_CNTL2, rdev->dummy_page.addr >> 8);
1472 + interrupt_cntl = RREG32(INTERRUPT_CNTL);
1473 + /* IH_DUMMY_RD_OVERRIDE=0 - dummy read disabled with msi, enabled without msi
1474 + * IH_DUMMY_RD_OVERRIDE=1 - dummy read controlled by IH_DUMMY_RD_EN
1475 +diff --git a/drivers/gpu/drm/virtio/virtgpu_vq.c b/drivers/gpu/drm/virtio/virtgpu_vq.c
1476 +index a1b3ea1ccb65..772a5a3b0ce1 100644
1477 +--- a/drivers/gpu/drm/virtio/virtgpu_vq.c
1478 ++++ b/drivers/gpu/drm/virtio/virtgpu_vq.c
1479 +@@ -681,11 +681,11 @@ int virtio_gpu_cmd_get_capset(struct virtio_gpu_device *vgdev,
1480 + {
1481 + struct virtio_gpu_get_capset *cmd_p;
1482 + struct virtio_gpu_vbuffer *vbuf;
1483 +- int max_size = vgdev->capsets[idx].max_size;
1484 ++ int max_size;
1485 + struct virtio_gpu_drv_cap_cache *cache_ent;
1486 + void *resp_buf;
1487 +
1488 +- if (idx > vgdev->num_capsets)
1489 ++ if (idx >= vgdev->num_capsets)
1490 + return -EINVAL;
1491 +
1492 + if (version > vgdev->capsets[idx].max_version)
1493 +@@ -695,6 +695,7 @@ int virtio_gpu_cmd_get_capset(struct virtio_gpu_device *vgdev,
1494 + if (!cache_ent)
1495 + return -ENOMEM;
1496 +
1497 ++ max_size = vgdev->capsets[idx].max_size;
1498 + cache_ent->caps_cache = kmalloc(max_size, GFP_KERNEL);
1499 + if (!cache_ent->caps_cache) {
1500 + kfree(cache_ent);
1501 +diff --git a/drivers/hwmon/adt7475.c b/drivers/hwmon/adt7475.c
1502 +index 9c262d955331..d2583caa8087 100644
1503 +--- a/drivers/hwmon/adt7475.c
1504 ++++ b/drivers/hwmon/adt7475.c
1505 +@@ -268,9 +268,10 @@ static inline u16 volt2reg(int channel, long volt, u8 bypass_attn)
1506 + long reg;
1507 +
1508 + if (bypass_attn & (1 << channel))
1509 +- reg = (volt * 1024) / 2250;
1510 ++ reg = DIV_ROUND_CLOSEST(volt * 1024, 2250);
1511 + else
1512 +- reg = (volt * r[1] * 1024) / ((r[0] + r[1]) * 2250);
1513 ++ reg = DIV_ROUND_CLOSEST(volt * r[1] * 1024,
1514 ++ (r[0] + r[1]) * 2250);
1515 + return clamp_val(reg, 0, 1023) & (0xff << 2);
1516 + }
1517 +
1518 +diff --git a/drivers/hwmon/nct7802.c b/drivers/hwmon/nct7802.c
1519 +index 7f8738a83cb9..40addb213bdf 100644
1520 +--- a/drivers/hwmon/nct7802.c
1521 ++++ b/drivers/hwmon/nct7802.c
1522 +@@ -32,8 +32,8 @@
1523 + static const u8 REG_VOLTAGE[5] = { 0x09, 0x0a, 0x0c, 0x0d, 0x0e };
1524 +
1525 + static const u8 REG_VOLTAGE_LIMIT_LSB[2][5] = {
1526 +- { 0x40, 0x00, 0x42, 0x44, 0x46 },
1527 +- { 0x3f, 0x00, 0x41, 0x43, 0x45 },
1528 ++ { 0x46, 0x00, 0x40, 0x42, 0x44 },
1529 ++ { 0x45, 0x00, 0x3f, 0x41, 0x43 },
1530 + };
1531 +
1532 + static const u8 REG_VOLTAGE_LIMIT_MSB[5] = { 0x48, 0x00, 0x47, 0x47, 0x48 };
1533 +diff --git a/drivers/hwmon/shtc1.c b/drivers/hwmon/shtc1.c
1534 +index decd7df995ab..2a18539591ea 100644
1535 +--- a/drivers/hwmon/shtc1.c
1536 ++++ b/drivers/hwmon/shtc1.c
1537 +@@ -38,7 +38,7 @@ static const unsigned char shtc1_cmd_read_id_reg[] = { 0xef, 0xc8 };
1538 +
1539 + /* constants for reading the ID register */
1540 + #define SHTC1_ID 0x07
1541 +-#define SHTC1_ID_REG_MASK 0x1f
1542 ++#define SHTC1_ID_REG_MASK 0x3f
1543 +
1544 + /* delays for non-blocking i2c commands, both in us */
1545 + #define SHTC1_NONBLOCKING_WAIT_TIME_HPM 14400
1546 +diff --git a/drivers/hwmon/w83627hf.c b/drivers/hwmon/w83627hf.c
1547 +index 721295b9a051..43c0f89cefdf 100644
1548 +--- a/drivers/hwmon/w83627hf.c
1549 ++++ b/drivers/hwmon/w83627hf.c
1550 +@@ -130,17 +130,23 @@ superio_select(struct w83627hf_sio_data *sio, int ld)
1551 + outb(ld, sio->sioaddr + 1);
1552 + }
1553 +
1554 +-static inline void
1555 ++static inline int
1556 + superio_enter(struct w83627hf_sio_data *sio)
1557 + {
1558 ++ if (!request_muxed_region(sio->sioaddr, 2, DRVNAME))
1559 ++ return -EBUSY;
1560 ++
1561 + outb(0x87, sio->sioaddr);
1562 + outb(0x87, sio->sioaddr);
1563 ++
1564 ++ return 0;
1565 + }
1566 +
1567 + static inline void
1568 + superio_exit(struct w83627hf_sio_data *sio)
1569 + {
1570 + outb(0xAA, sio->sioaddr);
1571 ++ release_region(sio->sioaddr, 2);
1572 + }
1573 +
1574 + #define W627_DEVID 0x52
1575 +@@ -1275,7 +1281,7 @@ static DEVICE_ATTR(name, S_IRUGO, show_name, NULL);
1576 + static int __init w83627hf_find(int sioaddr, unsigned short *addr,
1577 + struct w83627hf_sio_data *sio_data)
1578 + {
1579 +- int err = -ENODEV;
1580 ++ int err;
1581 + u16 val;
1582 +
1583 + static __initconst char *const names[] = {
1584 +@@ -1287,7 +1293,11 @@ static int __init w83627hf_find(int sioaddr, unsigned short *addr,
1585 + };
1586 +
1587 + sio_data->sioaddr = sioaddr;
1588 +- superio_enter(sio_data);
1589 ++ err = superio_enter(sio_data);
1590 ++ if (err)
1591 ++ return err;
1592 ++
1593 ++ err = -ENODEV;
1594 + val = force_id ? force_id : superio_inb(sio_data, DEVID);
1595 + switch (val) {
1596 + case W627_DEVID:
1597 +@@ -1641,9 +1651,21 @@ static int w83627thf_read_gpio5(struct platform_device *pdev)
1598 + struct w83627hf_sio_data *sio_data = dev_get_platdata(&pdev->dev);
1599 + int res = 0xff, sel;
1600 +
1601 +- superio_enter(sio_data);
1602 ++ if (superio_enter(sio_data)) {
1603 ++ /*
1604 ++ * Some other driver reserved the address space for itself.
1605 ++ * We don't want to fail driver instantiation because of that,
1606 ++ * so display a warning and keep going.
1607 ++ */
1608 ++ dev_warn(&pdev->dev,
1609 ++ "Can not read VID data: Failed to enable SuperIO access\n");
1610 ++ return res;
1611 ++ }
1612 ++
1613 + superio_select(sio_data, W83627HF_LD_GPIO5);
1614 +
1615 ++ res = 0xff;
1616 ++
1617 + /* Make sure these GPIO pins are enabled */
1618 + if (!(superio_inb(sio_data, W83627THF_GPIO5_EN) & (1<<3))) {
1619 + dev_dbg(&pdev->dev, "GPIO5 disabled, no VID function\n");
1620 +@@ -1674,7 +1696,17 @@ static int w83687thf_read_vid(struct platform_device *pdev)
1621 + struct w83627hf_sio_data *sio_data = dev_get_platdata(&pdev->dev);
1622 + int res = 0xff;
1623 +
1624 +- superio_enter(sio_data);
1625 ++ if (superio_enter(sio_data)) {
1626 ++ /*
1627 ++ * Some other driver reserved the address space for itself.
1628 ++ * We don't want to fail driver instantiation because of that,
1629 ++ * so display a warning and keep going.
1630 ++ */
1631 ++ dev_warn(&pdev->dev,
1632 ++ "Can not read VID data: Failed to enable SuperIO access\n");
1633 ++ return res;
1634 ++ }
1635 ++
1636 + superio_select(sio_data, W83627HF_LD_HWM);
1637 +
1638 + /* Make sure these GPIO pins are enabled */
1639 +diff --git a/drivers/iio/dac/ad5380.c b/drivers/iio/dac/ad5380.c
1640 +index 97d2c5111f43..8bf7fc626a9d 100644
1641 +--- a/drivers/iio/dac/ad5380.c
1642 ++++ b/drivers/iio/dac/ad5380.c
1643 +@@ -221,7 +221,7 @@ static int ad5380_read_raw(struct iio_dev *indio_dev,
1644 + if (ret)
1645 + return ret;
1646 + *val >>= chan->scan_type.shift;
1647 +- val -= (1 << chan->scan_type.realbits) / 2;
1648 ++ *val -= (1 << chan->scan_type.realbits) / 2;
1649 + return IIO_VAL_INT;
1650 + case IIO_CHAN_INFO_SCALE:
1651 + *val = 2 * st->vref;
1652 +diff --git a/drivers/iio/industrialio-buffer.c b/drivers/iio/industrialio-buffer.c
1653 +index 961afb5588be..864a61b05665 100644
1654 +--- a/drivers/iio/industrialio-buffer.c
1655 ++++ b/drivers/iio/industrialio-buffer.c
1656 +@@ -527,7 +527,7 @@ static int iio_compute_scan_bytes(struct iio_dev *indio_dev,
1657 + {
1658 + const struct iio_chan_spec *ch;
1659 + unsigned bytes = 0;
1660 +- int length, i;
1661 ++ int length, i, largest = 0;
1662 +
1663 + /* How much space will the demuxed element take? */
1664 + for_each_set_bit(i, mask,
1665 +@@ -540,6 +540,7 @@ static int iio_compute_scan_bytes(struct iio_dev *indio_dev,
1666 + length = ch->scan_type.storagebits / 8;
1667 + bytes = ALIGN(bytes, length);
1668 + bytes += length;
1669 ++ largest = max(largest, length);
1670 + }
1671 + if (timestamp) {
1672 + ch = iio_find_channel_from_si(indio_dev,
1673 +@@ -551,7 +552,10 @@ static int iio_compute_scan_bytes(struct iio_dev *indio_dev,
1674 + length = ch->scan_type.storagebits / 8;
1675 + bytes = ALIGN(bytes, length);
1676 + bytes += length;
1677 ++ largest = max(largest, length);
1678 + }
1679 ++
1680 ++ bytes = ALIGN(bytes, largest);
1681 + return bytes;
1682 + }
1683 +
1684 +diff --git a/drivers/infiniband/hw/mlx5/qp.c b/drivers/infiniband/hw/mlx5/qp.c
1685 +index 43d277a931c2..eac5f5eff8d2 100644
1686 +--- a/drivers/infiniband/hw/mlx5/qp.c
1687 ++++ b/drivers/infiniband/hw/mlx5/qp.c
1688 +@@ -1426,6 +1426,11 @@ static enum mlx5_qp_optpar opt_mask[MLX5_QP_NUM_STATE][MLX5_QP_NUM_STATE][MLX5_Q
1689 + [MLX5_QP_ST_UD] = MLX5_QP_OPTPAR_PKEY_INDEX |
1690 + MLX5_QP_OPTPAR_Q_KEY |
1691 + MLX5_QP_OPTPAR_PRI_PORT,
1692 ++ [MLX5_QP_ST_XRC] = MLX5_QP_OPTPAR_RRE |
1693 ++ MLX5_QP_OPTPAR_RAE |
1694 ++ MLX5_QP_OPTPAR_RWE |
1695 ++ MLX5_QP_OPTPAR_PKEY_INDEX |
1696 ++ MLX5_QP_OPTPAR_PRI_PORT,
1697 + },
1698 + [MLX5_QP_STATE_RTR] = {
1699 + [MLX5_QP_ST_RC] = MLX5_QP_OPTPAR_ALT_ADDR_PATH |
1700 +@@ -1459,6 +1464,12 @@ static enum mlx5_qp_optpar opt_mask[MLX5_QP_NUM_STATE][MLX5_QP_NUM_STATE][MLX5_Q
1701 + MLX5_QP_OPTPAR_RWE |
1702 + MLX5_QP_OPTPAR_PM_STATE,
1703 + [MLX5_QP_ST_UD] = MLX5_QP_OPTPAR_Q_KEY,
1704 ++ [MLX5_QP_ST_XRC] = MLX5_QP_OPTPAR_ALT_ADDR_PATH |
1705 ++ MLX5_QP_OPTPAR_RRE |
1706 ++ MLX5_QP_OPTPAR_RAE |
1707 ++ MLX5_QP_OPTPAR_RWE |
1708 ++ MLX5_QP_OPTPAR_PM_STATE |
1709 ++ MLX5_QP_OPTPAR_RNR_TIMEOUT,
1710 + },
1711 + },
1712 + [MLX5_QP_STATE_RTS] = {
1713 +@@ -1475,6 +1486,12 @@ static enum mlx5_qp_optpar opt_mask[MLX5_QP_NUM_STATE][MLX5_QP_NUM_STATE][MLX5_Q
1714 + [MLX5_QP_ST_UD] = MLX5_QP_OPTPAR_Q_KEY |
1715 + MLX5_QP_OPTPAR_SRQN |
1716 + MLX5_QP_OPTPAR_CQN_RCV,
1717 ++ [MLX5_QP_ST_XRC] = MLX5_QP_OPTPAR_RRE |
1718 ++ MLX5_QP_OPTPAR_RAE |
1719 ++ MLX5_QP_OPTPAR_RWE |
1720 ++ MLX5_QP_OPTPAR_RNR_TIMEOUT |
1721 ++ MLX5_QP_OPTPAR_PM_STATE |
1722 ++ MLX5_QP_OPTPAR_ALT_ADDR_PATH,
1723 + },
1724 + },
1725 + [MLX5_QP_STATE_SQER] = {
1726 +@@ -1486,6 +1503,10 @@ static enum mlx5_qp_optpar opt_mask[MLX5_QP_NUM_STATE][MLX5_QP_NUM_STATE][MLX5_Q
1727 + MLX5_QP_OPTPAR_RWE |
1728 + MLX5_QP_OPTPAR_RAE |
1729 + MLX5_QP_OPTPAR_RRE,
1730 ++ [MLX5_QP_ST_XRC] = MLX5_QP_OPTPAR_RNR_TIMEOUT |
1731 ++ MLX5_QP_OPTPAR_RWE |
1732 ++ MLX5_QP_OPTPAR_RAE |
1733 ++ MLX5_QP_OPTPAR_RRE,
1734 + },
1735 + },
1736 + };
1737 +diff --git a/drivers/infiniband/hw/ocrdma/ocrdma_verbs.c b/drivers/infiniband/hw/ocrdma/ocrdma_verbs.c
1738 +index 76e96f97b3f6..6385448b22c5 100644
1739 +--- a/drivers/infiniband/hw/ocrdma/ocrdma_verbs.c
1740 ++++ b/drivers/infiniband/hw/ocrdma/ocrdma_verbs.c
1741 +@@ -55,7 +55,7 @@
1742 +
1743 + int ocrdma_query_pkey(struct ib_device *ibdev, u8 port, u16 index, u16 *pkey)
1744 + {
1745 +- if (index > 1)
1746 ++ if (index > 0)
1747 + return -EINVAL;
1748 +
1749 + *pkey = 0xffff;
1750 +diff --git a/drivers/infiniband/hw/usnic/usnic_ib_verbs.c b/drivers/infiniband/hw/usnic/usnic_ib_verbs.c
1751 +index f8e3211689a3..8e18bfca5516 100644
1752 +--- a/drivers/infiniband/hw/usnic/usnic_ib_verbs.c
1753 ++++ b/drivers/infiniband/hw/usnic/usnic_ib_verbs.c
1754 +@@ -427,7 +427,7 @@ int usnic_ib_query_gid(struct ib_device *ibdev, u8 port, int index,
1755 + int usnic_ib_query_pkey(struct ib_device *ibdev, u8 port, u16 index,
1756 + u16 *pkey)
1757 + {
1758 +- if (index > 1)
1759 ++ if (index > 0)
1760 + return -EINVAL;
1761 +
1762 + *pkey = 0xffff;
1763 +diff --git a/drivers/infiniband/ulp/isert/ib_isert.c b/drivers/infiniband/ulp/isert/ib_isert.c
1764 +index 0b7f5a701c60..32ef17e1aef8 100644
1765 +--- a/drivers/infiniband/ulp/isert/ib_isert.c
1766 ++++ b/drivers/infiniband/ulp/isert/ib_isert.c
1767 +@@ -3277,17 +3277,6 @@ isert_wait4logout(struct isert_conn *isert_conn)
1768 + }
1769 + }
1770 +
1771 +-static void
1772 +-isert_wait4cmds(struct iscsi_conn *conn)
1773 +-{
1774 +- isert_info("iscsi_conn %p\n", conn);
1775 +-
1776 +- if (conn->sess) {
1777 +- target_sess_cmd_list_set_waiting(conn->sess->se_sess);
1778 +- target_wait_for_sess_cmds(conn->sess->se_sess);
1779 +- }
1780 +-}
1781 +-
1782 + static void
1783 + isert_wait4flush(struct isert_conn *isert_conn)
1784 + {
1785 +@@ -3361,7 +3350,6 @@ static void isert_wait_conn(struct iscsi_conn *conn)
1786 +
1787 + isert_wait4flush(isert_conn);
1788 + isert_put_unsol_pending_cmds(conn);
1789 +- isert_wait4cmds(conn);
1790 + isert_wait4logout(isert_conn);
1791 +
1792 + queue_work(isert_release_wq, &isert_conn->release_work);
1793 +diff --git a/drivers/input/keyboard/nomadik-ske-keypad.c b/drivers/input/keyboard/nomadik-ske-keypad.c
1794 +index 8567ee47761e..ae3b04557074 100644
1795 +--- a/drivers/input/keyboard/nomadik-ske-keypad.c
1796 ++++ b/drivers/input/keyboard/nomadik-ske-keypad.c
1797 +@@ -100,7 +100,7 @@ static int __init ske_keypad_chip_init(struct ske_keypad *keypad)
1798 + while ((readl(keypad->reg_base + SKE_RIS) != 0x00000000) && timeout--)
1799 + cpu_relax();
1800 +
1801 +- if (!timeout)
1802 ++ if (timeout == -1)
1803 + return -EINVAL;
1804 +
1805 + /*
1806 +diff --git a/drivers/input/misc/keyspan_remote.c b/drivers/input/misc/keyspan_remote.c
1807 +index a3fe4a990cc9..c7b889d13edd 100644
1808 +--- a/drivers/input/misc/keyspan_remote.c
1809 ++++ b/drivers/input/misc/keyspan_remote.c
1810 +@@ -344,7 +344,8 @@ static int keyspan_setup(struct usb_device* dev)
1811 + int retval = 0;
1812 +
1813 + retval = usb_control_msg(dev, usb_sndctrlpipe(dev, 0),
1814 +- 0x11, 0x40, 0x5601, 0x0, NULL, 0, 0);
1815 ++ 0x11, 0x40, 0x5601, 0x0, NULL, 0,
1816 ++ USB_CTRL_SET_TIMEOUT);
1817 + if (retval) {
1818 + dev_dbg(&dev->dev, "%s - failed to set bit rate due to error: %d\n",
1819 + __func__, retval);
1820 +@@ -352,7 +353,8 @@ static int keyspan_setup(struct usb_device* dev)
1821 + }
1822 +
1823 + retval = usb_control_msg(dev, usb_sndctrlpipe(dev, 0),
1824 +- 0x44, 0x40, 0x0, 0x0, NULL, 0, 0);
1825 ++ 0x44, 0x40, 0x0, 0x0, NULL, 0,
1826 ++ USB_CTRL_SET_TIMEOUT);
1827 + if (retval) {
1828 + dev_dbg(&dev->dev, "%s - failed to set resume sensitivity due to error: %d\n",
1829 + __func__, retval);
1830 +@@ -360,7 +362,8 @@ static int keyspan_setup(struct usb_device* dev)
1831 + }
1832 +
1833 + retval = usb_control_msg(dev, usb_sndctrlpipe(dev, 0),
1834 +- 0x22, 0x40, 0x0, 0x0, NULL, 0, 0);
1835 ++ 0x22, 0x40, 0x0, 0x0, NULL, 0,
1836 ++ USB_CTRL_SET_TIMEOUT);
1837 + if (retval) {
1838 + dev_dbg(&dev->dev, "%s - failed to turn receive on due to error: %d\n",
1839 + __func__, retval);
1840 +diff --git a/drivers/input/tablet/aiptek.c b/drivers/input/tablet/aiptek.c
1841 +index 78ca44840d60..40a166773c1b 100644
1842 +--- a/drivers/input/tablet/aiptek.c
1843 ++++ b/drivers/input/tablet/aiptek.c
1844 +@@ -1820,14 +1820,14 @@ aiptek_probe(struct usb_interface *intf, const struct usb_device_id *id)
1845 + input_set_abs_params(inputdev, ABS_WHEEL, AIPTEK_WHEEL_MIN, AIPTEK_WHEEL_MAX - 1, 0, 0);
1846 +
1847 + /* Verify that a device really has an endpoint */
1848 +- if (intf->altsetting[0].desc.bNumEndpoints < 1) {
1849 ++ if (intf->cur_altsetting->desc.bNumEndpoints < 1) {
1850 + dev_err(&intf->dev,
1851 + "interface has %d endpoints, but must have minimum 1\n",
1852 +- intf->altsetting[0].desc.bNumEndpoints);
1853 ++ intf->cur_altsetting->desc.bNumEndpoints);
1854 + err = -EINVAL;
1855 + goto fail3;
1856 + }
1857 +- endpoint = &intf->altsetting[0].endpoint[0].desc;
1858 ++ endpoint = &intf->cur_altsetting->endpoint[0].desc;
1859 +
1860 + /* Go set up our URB, which is called when the tablet receives
1861 + * input.
1862 +diff --git a/drivers/input/tablet/gtco.c b/drivers/input/tablet/gtco.c
1863 +index 5a0e4cd86353..67dc17c8bba9 100644
1864 +--- a/drivers/input/tablet/gtco.c
1865 ++++ b/drivers/input/tablet/gtco.c
1866 +@@ -876,18 +876,14 @@ static int gtco_probe(struct usb_interface *usbinterface,
1867 + }
1868 +
1869 + /* Sanity check that a device has an endpoint */
1870 +- if (usbinterface->altsetting[0].desc.bNumEndpoints < 1) {
1871 ++ if (usbinterface->cur_altsetting->desc.bNumEndpoints < 1) {
1872 + dev_err(&usbinterface->dev,
1873 + "Invalid number of endpoints\n");
1874 + error = -EINVAL;
1875 + goto err_free_urb;
1876 + }
1877 +
1878 +- /*
1879 +- * The endpoint is always altsetting 0, we know this since we know
1880 +- * this device only has one interrupt endpoint
1881 +- */
1882 +- endpoint = &usbinterface->altsetting[0].endpoint[0].desc;
1883 ++ endpoint = &usbinterface->cur_altsetting->endpoint[0].desc;
1884 +
1885 + /* Some debug */
1886 + dev_dbg(&usbinterface->dev, "gtco # interfaces: %d\n", usbinterface->num_altsetting);
1887 +@@ -974,7 +970,7 @@ static int gtco_probe(struct usb_interface *usbinterface,
1888 + input_dev->dev.parent = &usbinterface->dev;
1889 +
1890 + /* Setup the URB, it will be posted later on open of input device */
1891 +- endpoint = &usbinterface->altsetting[0].endpoint[0].desc;
1892 ++ endpoint = &usbinterface->cur_altsetting->endpoint[0].desc;
1893 +
1894 + usb_fill_int_urb(gtco->urbinfo,
1895 + gtco->usbdev,
1896 +diff --git a/drivers/input/touchscreen/sur40.c b/drivers/input/touchscreen/sur40.c
1897 +index 0146e2c74649..6178e28baaba 100644
1898 +--- a/drivers/input/touchscreen/sur40.c
1899 ++++ b/drivers/input/touchscreen/sur40.c
1900 +@@ -496,7 +496,7 @@ static int sur40_probe(struct usb_interface *interface,
1901 + int error;
1902 +
1903 + /* Check if we really have the right interface. */
1904 +- iface_desc = &interface->altsetting[0];
1905 ++ iface_desc = interface->cur_altsetting;
1906 + if (iface_desc->desc.bInterfaceClass != 0xFF)
1907 + return -ENODEV;
1908 +
1909 +diff --git a/drivers/iommu/amd_iommu.c b/drivers/iommu/amd_iommu.c
1910 +index 0ad8b7c78a43..66a406e87e11 100644
1911 +--- a/drivers/iommu/amd_iommu.c
1912 ++++ b/drivers/iommu/amd_iommu.c
1913 +@@ -2184,6 +2184,8 @@ static int attach_device(struct device *dev,
1914 + */
1915 + domain_flush_tlb_pde(domain);
1916 +
1917 ++ domain_flush_complete(domain);
1918 ++
1919 + return ret;
1920 + }
1921 +
1922 +diff --git a/drivers/iommu/amd_iommu_init.c b/drivers/iommu/amd_iommu_init.c
1923 +index 6a69b5bb231f..036fb186a3be 100644
1924 +--- a/drivers/iommu/amd_iommu_init.c
1925 ++++ b/drivers/iommu/amd_iommu_init.c
1926 +@@ -360,6 +360,9 @@ static void iommu_enable(struct amd_iommu *iommu)
1927 +
1928 + static void iommu_disable(struct amd_iommu *iommu)
1929 + {
1930 ++ if (!iommu->mmio_base)
1931 ++ return;
1932 ++
1933 + /* Disable command buffer */
1934 + iommu_feature_disable(iommu, CONTROL_CMDBUF_EN);
1935 +
1936 +diff --git a/drivers/iommu/intel-iommu.c b/drivers/iommu/intel-iommu.c
1937 +index b965561a4162..a2005b82ec8f 100644
1938 +--- a/drivers/iommu/intel-iommu.c
1939 ++++ b/drivers/iommu/intel-iommu.c
1940 +@@ -3259,9 +3259,12 @@ static int __init init_dmars(void)
1941 + iommu_identity_mapping |= IDENTMAP_ALL;
1942 +
1943 + #ifdef CONFIG_INTEL_IOMMU_BROKEN_GFX_WA
1944 +- iommu_identity_mapping |= IDENTMAP_GFX;
1945 ++ dmar_map_gfx = 0;
1946 + #endif
1947 +
1948 ++ if (!dmar_map_gfx)
1949 ++ iommu_identity_mapping |= IDENTMAP_GFX;
1950 ++
1951 + check_tylersburg_isoch();
1952 +
1953 + if (iommu_identity_mapping) {
1954 +diff --git a/drivers/iommu/iommu.c b/drivers/iommu/iommu.c
1955 +index 5d5066cf3bbd..589207176ffa 100644
1956 +--- a/drivers/iommu/iommu.c
1957 ++++ b/drivers/iommu/iommu.c
1958 +@@ -1594,9 +1594,9 @@ int iommu_request_dm_for_dev(struct device *dev)
1959 + int ret;
1960 +
1961 + /* Device must already be in a group before calling this function */
1962 +- group = iommu_group_get_for_dev(dev);
1963 +- if (IS_ERR(group))
1964 +- return PTR_ERR(group);
1965 ++ group = iommu_group_get(dev);
1966 ++ if (!group)
1967 ++ return -EINVAL;
1968 +
1969 + mutex_lock(&group->mutex);
1970 +
1971 +diff --git a/drivers/md/bitmap.c b/drivers/md/bitmap.c
1972 +index 7a50728b9389..391090c455ce 100644
1973 +--- a/drivers/md/bitmap.c
1974 ++++ b/drivers/md/bitmap.c
1975 +@@ -1671,7 +1671,7 @@ void bitmap_flush(struct mddev *mddev)
1976 + /*
1977 + * free memory that was allocated
1978 + */
1979 +-static void bitmap_free(struct bitmap *bitmap)
1980 ++static void md_bitmap_free(struct bitmap *bitmap)
1981 + {
1982 + unsigned long k, pages;
1983 + struct bitmap_page *bp;
1984 +@@ -1721,7 +1721,7 @@ void bitmap_destroy(struct mddev *mddev)
1985 + if (bitmap->sysfs_can_clear)
1986 + sysfs_put(bitmap->sysfs_can_clear);
1987 +
1988 +- bitmap_free(bitmap);
1989 ++ md_bitmap_free(bitmap);
1990 + }
1991 +
1992 + /*
1993 +@@ -1805,7 +1805,7 @@ struct bitmap *bitmap_create(struct mddev *mddev, int slot)
1994 +
1995 + return bitmap;
1996 + error:
1997 +- bitmap_free(bitmap);
1998 ++ md_bitmap_free(bitmap);
1999 + return ERR_PTR(err);
2000 + }
2001 +
2002 +@@ -1904,7 +1904,7 @@ int bitmap_copy_from_slot(struct mddev *mddev, int slot,
2003 + *low = lo;
2004 + *high = hi;
2005 + err:
2006 +- bitmap_free(bitmap);
2007 ++ md_bitmap_free(bitmap);
2008 + return rv;
2009 + }
2010 + EXPORT_SYMBOL_GPL(bitmap_copy_from_slot);
2011 +diff --git a/drivers/media/i2c/ov2659.c b/drivers/media/i2c/ov2659.c
2012 +index 6eefb8bbb5b5..20e3c56991cf 100644
2013 +--- a/drivers/media/i2c/ov2659.c
2014 ++++ b/drivers/media/i2c/ov2659.c
2015 +@@ -1137,7 +1137,7 @@ static int ov2659_set_fmt(struct v4l2_subdev *sd,
2016 + mf = v4l2_subdev_get_try_format(sd, cfg, fmt->pad);
2017 + *mf = fmt->format;
2018 + #else
2019 +- return -ENOTTY;
2020 ++ ret = -ENOTTY;
2021 + #endif
2022 + } else {
2023 + s64 val;
2024 +diff --git a/drivers/media/i2c/soc_camera/ov6650.c b/drivers/media/i2c/soc_camera/ov6650.c
2025 +index bb55ddfbf733..7928ea8528e1 100644
2026 +--- a/drivers/media/i2c/soc_camera/ov6650.c
2027 ++++ b/drivers/media/i2c/soc_camera/ov6650.c
2028 +@@ -203,7 +203,6 @@ struct ov6650 {
2029 + unsigned long pclk_max; /* from resolution and format */
2030 + struct v4l2_fract tpf; /* as requested with s_parm */
2031 + u32 code;
2032 +- enum v4l2_colorspace colorspace;
2033 + };
2034 +
2035 +
2036 +@@ -216,6 +215,17 @@ static u32 ov6650_codes[] = {
2037 + MEDIA_BUS_FMT_Y8_1X8,
2038 + };
2039 +
2040 ++static const struct v4l2_mbus_framefmt ov6650_def_fmt = {
2041 ++ .width = W_CIF,
2042 ++ .height = H_CIF,
2043 ++ .code = MEDIA_BUS_FMT_SBGGR8_1X8,
2044 ++ .colorspace = V4L2_COLORSPACE_SRGB,
2045 ++ .field = V4L2_FIELD_NONE,
2046 ++ .ycbcr_enc = V4L2_YCBCR_ENC_DEFAULT,
2047 ++ .quantization = V4L2_QUANTIZATION_DEFAULT,
2048 ++ .xfer_func = V4L2_XFER_FUNC_DEFAULT,
2049 ++};
2050 ++
2051 + /* read a register */
2052 + static int ov6650_reg_read(struct i2c_client *client, u8 reg, u8 *val)
2053 + {
2054 +@@ -510,12 +520,20 @@ static int ov6650_get_fmt(struct v4l2_subdev *sd,
2055 + if (format->pad)
2056 + return -EINVAL;
2057 +
2058 +- mf->width = priv->rect.width >> priv->half_scale;
2059 +- mf->height = priv->rect.height >> priv->half_scale;
2060 +- mf->code = priv->code;
2061 +- mf->colorspace = priv->colorspace;
2062 +- mf->field = V4L2_FIELD_NONE;
2063 ++ /* initialize response with default media bus frame format */
2064 ++ *mf = ov6650_def_fmt;
2065 +
2066 ++ /* update media bus format code and frame size */
2067 ++ if (format->which == V4L2_SUBDEV_FORMAT_TRY) {
2068 ++ mf->width = cfg->try_fmt.width;
2069 ++ mf->height = cfg->try_fmt.height;
2070 ++ mf->code = cfg->try_fmt.code;
2071 ++
2072 ++ } else {
2073 ++ mf->width = priv->rect.width >> priv->half_scale;
2074 ++ mf->height = priv->rect.height >> priv->half_scale;
2075 ++ mf->code = priv->code;
2076 ++ }
2077 + return 0;
2078 + }
2079 +
2080 +@@ -623,11 +641,6 @@ static int ov6650_s_fmt(struct v4l2_subdev *sd, struct v4l2_mbus_framefmt *mf)
2081 + priv->pclk_max = 8000000;
2082 + }
2083 +
2084 +- if (code == MEDIA_BUS_FMT_SBGGR8_1X8)
2085 +- priv->colorspace = V4L2_COLORSPACE_SRGB;
2086 +- else if (code != 0)
2087 +- priv->colorspace = V4L2_COLORSPACE_JPEG;
2088 +-
2089 + if (half_scale) {
2090 + dev_dbg(&client->dev, "max resolution: QCIF\n");
2091 + coma_set |= COMA_QCIF;
2092 +@@ -683,11 +696,6 @@ static int ov6650_s_fmt(struct v4l2_subdev *sd, struct v4l2_mbus_framefmt *mf)
2093 + if (!ret)
2094 + priv->code = code;
2095 +
2096 +- if (!ret) {
2097 +- mf->colorspace = priv->colorspace;
2098 +- mf->width = priv->rect.width >> half_scale;
2099 +- mf->height = priv->rect.height >> half_scale;
2100 +- }
2101 + return ret;
2102 + }
2103 +
2104 +@@ -706,8 +714,6 @@ static int ov6650_set_fmt(struct v4l2_subdev *sd,
2105 + v4l_bound_align_image(&mf->width, 2, W_CIF, 1,
2106 + &mf->height, 2, H_CIF, 1, 0);
2107 +
2108 +- mf->field = V4L2_FIELD_NONE;
2109 +-
2110 + switch (mf->code) {
2111 + case MEDIA_BUS_FMT_Y10_1X10:
2112 + mf->code = MEDIA_BUS_FMT_Y8_1X8;
2113 +@@ -716,19 +722,38 @@ static int ov6650_set_fmt(struct v4l2_subdev *sd,
2114 + case MEDIA_BUS_FMT_YUYV8_2X8:
2115 + case MEDIA_BUS_FMT_VYUY8_2X8:
2116 + case MEDIA_BUS_FMT_UYVY8_2X8:
2117 +- mf->colorspace = V4L2_COLORSPACE_JPEG;
2118 + break;
2119 + default:
2120 + mf->code = MEDIA_BUS_FMT_SBGGR8_1X8;
2121 + case MEDIA_BUS_FMT_SBGGR8_1X8:
2122 +- mf->colorspace = V4L2_COLORSPACE_SRGB;
2123 + break;
2124 + }
2125 +
2126 +- if (format->which == V4L2_SUBDEV_FORMAT_ACTIVE)
2127 +- return ov6650_s_fmt(sd, mf);
2128 +- cfg->try_fmt = *mf;
2129 ++ if (format->which == V4L2_SUBDEV_FORMAT_TRY) {
2130 ++ /* store media bus format code and frame size in pad config */
2131 ++ cfg->try_fmt.width = mf->width;
2132 ++ cfg->try_fmt.height = mf->height;
2133 ++ cfg->try_fmt.code = mf->code;
2134 +
2135 ++ /* return default mbus frame format updated with pad config */
2136 ++ *mf = ov6650_def_fmt;
2137 ++ mf->width = cfg->try_fmt.width;
2138 ++ mf->height = cfg->try_fmt.height;
2139 ++ mf->code = cfg->try_fmt.code;
2140 ++
2141 ++ } else {
2142 ++ /* apply new media bus format code and frame size */
2143 ++ int ret = ov6650_s_fmt(sd, mf);
2144 ++
2145 ++ if (ret)
2146 ++ return ret;
2147 ++
2148 ++ /* return default format updated with active size and code */
2149 ++ *mf = ov6650_def_fmt;
2150 ++ mf->width = priv->rect.width >> priv->half_scale;
2151 ++ mf->height = priv->rect.height >> priv->half_scale;
2152 ++ mf->code = priv->code;
2153 ++ }
2154 + return 0;
2155 + }
2156 +
2157 +@@ -1048,7 +1073,6 @@ static int ov6650_probe(struct i2c_client *client,
2158 + priv->rect.height = H_CIF;
2159 + priv->half_scale = false;
2160 + priv->code = MEDIA_BUS_FMT_YUYV8_2X8;
2161 +- priv->colorspace = V4L2_COLORSPACE_JPEG;
2162 +
2163 + ret = ov6650_video_probe(client);
2164 + if (ret)
2165 +diff --git a/drivers/media/pci/cx18/cx18-fileops.c b/drivers/media/pci/cx18/cx18-fileops.c
2166 +index df837408efd5..0171dc5b8809 100644
2167 +--- a/drivers/media/pci/cx18/cx18-fileops.c
2168 ++++ b/drivers/media/pci/cx18/cx18-fileops.c
2169 +@@ -490,7 +490,7 @@ static ssize_t cx18_read_pos(struct cx18_stream *s, char __user *ubuf,
2170 +
2171 + CX18_DEBUG_HI_FILE("read %zd from %s, got %zd\n", count, s->name, rc);
2172 + if (rc > 0)
2173 +- pos += rc;
2174 ++ *pos += rc;
2175 + return rc;
2176 + }
2177 +
2178 +diff --git a/drivers/media/pci/cx23885/cx23885-dvb.c b/drivers/media/pci/cx23885/cx23885-dvb.c
2179 +index e543cbbf2ec4..8fe78b8b1c25 100644
2180 +--- a/drivers/media/pci/cx23885/cx23885-dvb.c
2181 ++++ b/drivers/media/pci/cx23885/cx23885-dvb.c
2182 +@@ -1452,8 +1452,9 @@ static int dvb_register(struct cx23885_tsport *port)
2183 + if (fe0->dvb.frontend != NULL) {
2184 + struct i2c_adapter *tun_i2c;
2185 +
2186 +- fe0->dvb.frontend->sec_priv = kmalloc(sizeof(dib7000p_ops), GFP_KERNEL);
2187 +- memcpy(fe0->dvb.frontend->sec_priv, &dib7000p_ops, sizeof(dib7000p_ops));
2188 ++ fe0->dvb.frontend->sec_priv = kmemdup(&dib7000p_ops, sizeof(dib7000p_ops), GFP_KERNEL);
2189 ++ if (!fe0->dvb.frontend->sec_priv)
2190 ++ return -ENOMEM;
2191 + tun_i2c = dib7000p_ops.get_i2c_master(fe0->dvb.frontend, DIBX000_I2C_INTERFACE_TUNER, 1);
2192 + if (!dvb_attach(dib0070_attach, fe0->dvb.frontend, tun_i2c, &dib7070p_dib0070_config))
2193 + return -ENODEV;
2194 +diff --git a/drivers/media/pci/ivtv/ivtv-fileops.c b/drivers/media/pci/ivtv/ivtv-fileops.c
2195 +index 605d280d8a5f..cb65fe6c49e0 100644
2196 +--- a/drivers/media/pci/ivtv/ivtv-fileops.c
2197 ++++ b/drivers/media/pci/ivtv/ivtv-fileops.c
2198 +@@ -420,7 +420,7 @@ static ssize_t ivtv_read_pos(struct ivtv_stream *s, char __user *ubuf, size_t co
2199 +
2200 + IVTV_DEBUG_HI_FILE("read %zd from %s, got %zd\n", count, s->name, rc);
2201 + if (rc > 0)
2202 +- pos += rc;
2203 ++ *pos += rc;
2204 + return rc;
2205 + }
2206 +
2207 +diff --git a/drivers/media/platform/davinci/isif.c b/drivers/media/platform/davinci/isif.c
2208 +index 78e37cf3470f..b51b875c5a61 100644
2209 +--- a/drivers/media/platform/davinci/isif.c
2210 ++++ b/drivers/media/platform/davinci/isif.c
2211 +@@ -890,9 +890,7 @@ static int isif_set_hw_if_params(struct vpfe_hw_if_param *params)
2212 + static int isif_config_ycbcr(void)
2213 + {
2214 + struct isif_ycbcr_config *params = &isif_cfg.ycbcr;
2215 +- struct vpss_pg_frame_size frame_size;
2216 + u32 modeset = 0, ccdcfg = 0;
2217 +- struct vpss_sync_pol sync;
2218 +
2219 + dev_dbg(isif_cfg.dev, "\nStarting isif_config_ycbcr...");
2220 +
2221 +@@ -980,13 +978,6 @@ static int isif_config_ycbcr(void)
2222 + /* two fields are interleaved in memory */
2223 + regw(0x00000249, SDOFST);
2224 +
2225 +- /* Setup test pattern if enabled */
2226 +- if (isif_cfg.bayer.config_params.test_pat_gen) {
2227 +- sync.ccdpg_hdpol = params->hd_pol;
2228 +- sync.ccdpg_vdpol = params->vd_pol;
2229 +- dm365_vpss_set_sync_pol(sync);
2230 +- dm365_vpss_set_pg_frame_size(frame_size);
2231 +- }
2232 + return 0;
2233 + }
2234 +
2235 +diff --git a/drivers/media/platform/davinci/vpbe.c b/drivers/media/platform/davinci/vpbe.c
2236 +index abce9c4a1a8e..59518c08528b 100644
2237 +--- a/drivers/media/platform/davinci/vpbe.c
2238 ++++ b/drivers/media/platform/davinci/vpbe.c
2239 +@@ -130,7 +130,7 @@ static int vpbe_enum_outputs(struct vpbe_device *vpbe_dev,
2240 + struct v4l2_output *output)
2241 + {
2242 + struct vpbe_config *cfg = vpbe_dev->cfg;
2243 +- int temp_index = output->index;
2244 ++ unsigned int temp_index = output->index;
2245 +
2246 + if (temp_index >= cfg->num_outputs)
2247 + return -EINVAL;
2248 +diff --git a/drivers/media/platform/omap/omap_vout.c b/drivers/media/platform/omap/omap_vout.c
2249 +index 596359576109..cf015bfc559b 100644
2250 +--- a/drivers/media/platform/omap/omap_vout.c
2251 ++++ b/drivers/media/platform/omap/omap_vout.c
2252 +@@ -1580,23 +1580,20 @@ static int vidioc_dqbuf(struct file *file, void *fh, struct v4l2_buffer *b)
2253 + unsigned long size;
2254 + struct videobuf_buffer *vb;
2255 +
2256 +- vb = q->bufs[b->index];
2257 +-
2258 + if (!vout->streaming)
2259 + return -EINVAL;
2260 +
2261 +- if (file->f_flags & O_NONBLOCK)
2262 +- /* Call videobuf_dqbuf for non blocking mode */
2263 +- ret = videobuf_dqbuf(q, (struct v4l2_buffer *)b, 1);
2264 +- else
2265 +- /* Call videobuf_dqbuf for blocking mode */
2266 +- ret = videobuf_dqbuf(q, (struct v4l2_buffer *)b, 0);
2267 ++ ret = videobuf_dqbuf(q, b, !!(file->f_flags & O_NONBLOCK));
2268 ++ if (ret)
2269 ++ return ret;
2270 ++
2271 ++ vb = q->bufs[b->index];
2272 +
2273 + addr = (unsigned long) vout->buf_phy_addr[vb->i];
2274 + size = (unsigned long) vb->size;
2275 + dma_unmap_single(vout->vid_dev->v4l2_dev.dev, addr,
2276 + size, DMA_TO_DEVICE);
2277 +- return ret;
2278 ++ return 0;
2279 + }
2280 +
2281 + static int vidioc_streamon(struct file *file, void *fh, enum v4l2_buf_type i)
2282 +diff --git a/drivers/media/platform/s5p-jpeg/jpeg-core.c b/drivers/media/platform/s5p-jpeg/jpeg-core.c
2283 +index 0d981bbf38bc..255f70999ee8 100644
2284 +--- a/drivers/media/platform/s5p-jpeg/jpeg-core.c
2285 ++++ b/drivers/media/platform/s5p-jpeg/jpeg-core.c
2286 +@@ -1952,7 +1952,7 @@ static int s5p_jpeg_controls_create(struct s5p_jpeg_ctx *ctx)
2287 +
2288 + v4l2_ctrl_new_std(&ctx->ctrl_handler, &s5p_jpeg_ctrl_ops,
2289 + V4L2_CID_JPEG_RESTART_INTERVAL,
2290 +- 0, 3, 0xffff, 0);
2291 ++ 0, 0xffff, 1, 0);
2292 + if (ctx->jpeg->variant->version == SJPEG_S5P)
2293 + mask = ~0x06; /* 422, 420 */
2294 + }
2295 +diff --git a/drivers/media/platform/vivid/vivid-osd.c b/drivers/media/platform/vivid/vivid-osd.c
2296 +index e15eef6a94e5..f3afc74f98ed 100644
2297 +--- a/drivers/media/platform/vivid/vivid-osd.c
2298 ++++ b/drivers/media/platform/vivid/vivid-osd.c
2299 +@@ -167,7 +167,7 @@ static int _vivid_fb_check_var(struct fb_var_screeninfo *var, struct vivid_dev *
2300 + var->nonstd = 0;
2301 +
2302 + var->vmode &= ~FB_VMODE_MASK;
2303 +- var->vmode = FB_VMODE_NONINTERLACED;
2304 ++ var->vmode |= FB_VMODE_NONINTERLACED;
2305 +
2306 + /* Dummy values */
2307 + var->hsync_len = 24;
2308 +diff --git a/drivers/media/radio/wl128x/fmdrv_common.c b/drivers/media/radio/wl128x/fmdrv_common.c
2309 +index 51639a3f7abe..0cee10cca0e5 100644
2310 +--- a/drivers/media/radio/wl128x/fmdrv_common.c
2311 ++++ b/drivers/media/radio/wl128x/fmdrv_common.c
2312 +@@ -1278,8 +1278,9 @@ static int fm_download_firmware(struct fmdev *fmdev, const u8 *fw_name)
2313 +
2314 + switch (action->type) {
2315 + case ACTION_SEND_COMMAND: /* Send */
2316 +- if (fmc_send_cmd(fmdev, 0, 0, action->data,
2317 +- action->size, NULL, NULL))
2318 ++ ret = fmc_send_cmd(fmdev, 0, 0, action->data,
2319 ++ action->size, NULL, NULL);
2320 ++ if (ret)
2321 + goto rel_fw;
2322 +
2323 + cmd_cnt++;
2324 +diff --git a/drivers/mfd/intel-lpss.c b/drivers/mfd/intel-lpss.c
2325 +index 498875193386..adbb23b6595f 100644
2326 +--- a/drivers/mfd/intel-lpss.c
2327 ++++ b/drivers/mfd/intel-lpss.c
2328 +@@ -525,6 +525,7 @@ module_init(intel_lpss_init);
2329 +
2330 + static void __exit intel_lpss_exit(void)
2331 + {
2332 ++ ida_destroy(&intel_lpss_devid_ida);
2333 + debugfs_remove(intel_lpss_debugfs);
2334 + }
2335 + module_exit(intel_lpss_exit);
2336 +diff --git a/drivers/misc/mic/card/mic_x100.c b/drivers/misc/mic/card/mic_x100.c
2337 +index b2958ce2368c..cd778e2b4f3e 100644
2338 +--- a/drivers/misc/mic/card/mic_x100.c
2339 ++++ b/drivers/misc/mic/card/mic_x100.c
2340 +@@ -249,6 +249,9 @@ static int __init mic_probe(struct platform_device *pdev)
2341 + mdrv->dev = &pdev->dev;
2342 + snprintf(mdrv->name, sizeof(mic_driver_name), mic_driver_name);
2343 +
2344 ++ /* FIXME: use dma_set_mask_and_coherent() and check result */
2345 ++ dma_coerce_mask_and_coherent(&pdev->dev, DMA_BIT_MASK(64));
2346 ++
2347 + mdev->mmio.pa = MIC_X100_MMIO_BASE;
2348 + mdev->mmio.len = MIC_X100_MMIO_LEN;
2349 + mdev->mmio.va = devm_ioremap(&pdev->dev, MIC_X100_MMIO_BASE,
2350 +@@ -294,18 +297,6 @@ static void mic_platform_shutdown(struct platform_device *pdev)
2351 + mic_remove(pdev);
2352 + }
2353 +
2354 +-static u64 mic_dma_mask = DMA_BIT_MASK(64);
2355 +-
2356 +-static struct platform_device mic_platform_dev = {
2357 +- .name = mic_driver_name,
2358 +- .id = 0,
2359 +- .num_resources = 0,
2360 +- .dev = {
2361 +- .dma_mask = &mic_dma_mask,
2362 +- .coherent_dma_mask = DMA_BIT_MASK(64),
2363 +- },
2364 +-};
2365 +-
2366 + static struct platform_driver __refdata mic_platform_driver = {
2367 + .probe = mic_probe,
2368 + .remove = mic_remove,
2369 +@@ -315,6 +306,8 @@ static struct platform_driver __refdata mic_platform_driver = {
2370 + },
2371 + };
2372 +
2373 ++static struct platform_device *mic_platform_dev;
2374 ++
2375 + static int __init mic_init(void)
2376 + {
2377 + int ret;
2378 +@@ -327,9 +320,12 @@ static int __init mic_init(void)
2379 + }
2380 +
2381 + mic_init_card_debugfs();
2382 +- ret = platform_device_register(&mic_platform_dev);
2383 ++
2384 ++ mic_platform_dev = platform_device_register_simple(mic_driver_name,
2385 ++ 0, NULL, 0);
2386 ++ ret = PTR_ERR_OR_ZERO(mic_platform_dev);
2387 + if (ret) {
2388 +- pr_err("platform_device_register ret %d\n", ret);
2389 ++ pr_err("platform_device_register_full ret %d\n", ret);
2390 + goto cleanup_debugfs;
2391 + }
2392 + ret = platform_driver_register(&mic_platform_driver);
2393 +@@ -340,7 +336,7 @@ static int __init mic_init(void)
2394 + return ret;
2395 +
2396 + device_unregister:
2397 +- platform_device_unregister(&mic_platform_dev);
2398 ++ platform_device_unregister(mic_platform_dev);
2399 + cleanup_debugfs:
2400 + mic_exit_card_debugfs();
2401 + done:
2402 +@@ -350,7 +346,7 @@ done:
2403 + static void __exit mic_exit(void)
2404 + {
2405 + platform_driver_unregister(&mic_platform_driver);
2406 +- platform_device_unregister(&mic_platform_dev);
2407 ++ platform_device_unregister(mic_platform_dev);
2408 + mic_exit_card_debugfs();
2409 + }
2410 +
2411 +diff --git a/drivers/misc/sgi-xp/xpc_partition.c b/drivers/misc/sgi-xp/xpc_partition.c
2412 +index 6956f7e7d439..ca5f0102daef 100644
2413 +--- a/drivers/misc/sgi-xp/xpc_partition.c
2414 ++++ b/drivers/misc/sgi-xp/xpc_partition.c
2415 +@@ -70,7 +70,7 @@ xpc_get_rsvd_page_pa(int nasid)
2416 + unsigned long rp_pa = nasid; /* seed with nasid */
2417 + size_t len = 0;
2418 + size_t buf_len = 0;
2419 +- void *buf = buf;
2420 ++ void *buf = NULL;
2421 + void *buf_base = NULL;
2422 + enum xp_retval (*get_partition_rsvd_page_pa)
2423 + (void *, u64 *, unsigned long *, size_t *) =
2424 +diff --git a/drivers/mmc/host/sdhci.c b/drivers/mmc/host/sdhci.c
2425 +index 2bae0214528b..bf309a8a66a1 100644
2426 +--- a/drivers/mmc/host/sdhci.c
2427 ++++ b/drivers/mmc/host/sdhci.c
2428 +@@ -3096,11 +3096,13 @@ int sdhci_add_host(struct sdhci_host *host)
2429 + if (host->ops->get_min_clock)
2430 + mmc->f_min = host->ops->get_min_clock(host);
2431 + else if (host->version >= SDHCI_SPEC_300) {
2432 +- if (host->clk_mul) {
2433 +- mmc->f_min = (host->max_clk * host->clk_mul) / 1024;
2434 ++ if (host->clk_mul)
2435 + max_clk = host->max_clk * host->clk_mul;
2436 +- } else
2437 +- mmc->f_min = host->max_clk / SDHCI_MAX_DIV_SPEC_300;
2438 ++ /*
2439 ++ * Divided Clock Mode minimum clock rate is always less than
2440 ++ * Programmable Clock Mode minimum clock rate.
2441 ++ */
2442 ++ mmc->f_min = host->max_clk / SDHCI_MAX_DIV_SPEC_300;
2443 + } else
2444 + mmc->f_min = host->max_clk / SDHCI_MAX_DIV_SPEC_200;
2445 +
2446 +diff --git a/drivers/net/can/slcan.c b/drivers/net/can/slcan.c
2447 +index 8a226cc05c10..cc4a0c48f090 100644
2448 +--- a/drivers/net/can/slcan.c
2449 ++++ b/drivers/net/can/slcan.c
2450 +@@ -344,9 +344,16 @@ static void slcan_transmit(struct work_struct *work)
2451 + */
2452 + static void slcan_write_wakeup(struct tty_struct *tty)
2453 + {
2454 +- struct slcan *sl = tty->disc_data;
2455 ++ struct slcan *sl;
2456 ++
2457 ++ rcu_read_lock();
2458 ++ sl = rcu_dereference(tty->disc_data);
2459 ++ if (!sl)
2460 ++ goto out;
2461 +
2462 + schedule_work(&sl->tx_work);
2463 ++out:
2464 ++ rcu_read_unlock();
2465 + }
2466 +
2467 + /* Send a can_frame to a TTY queue. */
2468 +@@ -640,10 +647,11 @@ static void slcan_close(struct tty_struct *tty)
2469 + return;
2470 +
2471 + spin_lock_bh(&sl->lock);
2472 +- tty->disc_data = NULL;
2473 ++ rcu_assign_pointer(tty->disc_data, NULL);
2474 + sl->tty = NULL;
2475 + spin_unlock_bh(&sl->lock);
2476 +
2477 ++ synchronize_rcu();
2478 + flush_work(&sl->tx_work);
2479 +
2480 + /* Flush network side */
2481 +diff --git a/drivers/net/ethernet/broadcom/bcmsysport.c b/drivers/net/ethernet/broadcom/bcmsysport.c
2482 +index 53b3c1a5851c..9530ee12726f 100644
2483 +--- a/drivers/net/ethernet/broadcom/bcmsysport.c
2484 ++++ b/drivers/net/ethernet/broadcom/bcmsysport.c
2485 +@@ -1794,7 +1794,7 @@ static int bcm_sysport_probe(struct platform_device *pdev)
2486 +
2487 + priv->phy_interface = of_get_phy_mode(dn);
2488 + /* Default to GMII interface mode */
2489 +- if (priv->phy_interface < 0)
2490 ++ if ((int)priv->phy_interface < 0)
2491 + priv->phy_interface = PHY_INTERFACE_MODE_GMII;
2492 +
2493 + /* In the case of a fixed PHY, the DT node associated
2494 +diff --git a/drivers/net/ethernet/chelsio/cxgb3/cxgb3_main.c b/drivers/net/ethernet/chelsio/cxgb3/cxgb3_main.c
2495 +index bee615cddbdd..f40eefd1b378 100644
2496 +--- a/drivers/net/ethernet/chelsio/cxgb3/cxgb3_main.c
2497 ++++ b/drivers/net/ethernet/chelsio/cxgb3/cxgb3_main.c
2498 +@@ -2437,6 +2437,8 @@ static int cxgb_extension_ioctl(struct net_device *dev, void __user *useraddr)
2499 +
2500 + if (!is_offload(adapter))
2501 + return -EOPNOTSUPP;
2502 ++ if (!capable(CAP_NET_ADMIN))
2503 ++ return -EPERM;
2504 + if (!(adapter->flags & FULL_INIT_DONE))
2505 + return -EIO; /* need the memory controllers */
2506 + if (copy_from_user(&t, useraddr, sizeof(t)))
2507 +diff --git a/drivers/net/ethernet/hisilicon/hix5hd2_gmac.c b/drivers/net/ethernet/hisilicon/hix5hd2_gmac.c
2508 +index e51892d518ff..761c80eb8a68 100644
2509 +--- a/drivers/net/ethernet/hisilicon/hix5hd2_gmac.c
2510 ++++ b/drivers/net/ethernet/hisilicon/hix5hd2_gmac.c
2511 +@@ -951,7 +951,7 @@ static int hix5hd2_dev_probe(struct platform_device *pdev)
2512 + goto err_free_mdio;
2513 +
2514 + priv->phy_mode = of_get_phy_mode(node);
2515 +- if (priv->phy_mode < 0) {
2516 ++ if ((int)priv->phy_mode < 0) {
2517 + netdev_err(ndev, "not find phy-mode\n");
2518 + ret = -EINVAL;
2519 + goto err_mdiobus;
2520 +diff --git a/drivers/net/ethernet/ibm/ehea/ehea_main.c b/drivers/net/ethernet/ibm/ehea/ehea_main.c
2521 +index 1a56de06b014..fdbba588c6db 100644
2522 +--- a/drivers/net/ethernet/ibm/ehea/ehea_main.c
2523 ++++ b/drivers/net/ethernet/ibm/ehea/ehea_main.c
2524 +@@ -1477,7 +1477,7 @@ static int ehea_init_port_res(struct ehea_port *port, struct ehea_port_res *pr,
2525 +
2526 + memset(pr, 0, sizeof(struct ehea_port_res));
2527 +
2528 +- pr->tx_bytes = rx_bytes;
2529 ++ pr->tx_bytes = tx_bytes;
2530 + pr->tx_packets = tx_packets;
2531 + pr->rx_bytes = rx_bytes;
2532 + pr->rx_packets = rx_packets;
2533 +diff --git a/drivers/net/ethernet/natsemi/sonic.c b/drivers/net/ethernet/natsemi/sonic.c
2534 +index 0798b4adb039..667900578249 100644
2535 +--- a/drivers/net/ethernet/natsemi/sonic.c
2536 ++++ b/drivers/net/ethernet/natsemi/sonic.c
2537 +@@ -221,9 +221,9 @@ static int sonic_send_packet(struct sk_buff *skb, struct net_device *dev)
2538 +
2539 + laddr = dma_map_single(lp->device, skb->data, length, DMA_TO_DEVICE);
2540 + if (!laddr) {
2541 +- printk(KERN_ERR "%s: failed to map tx DMA buffer.\n", dev->name);
2542 +- dev_kfree_skb(skb);
2543 +- return NETDEV_TX_BUSY;
2544 ++ pr_err_ratelimited("%s: failed to map tx DMA buffer.\n", dev->name);
2545 ++ dev_kfree_skb_any(skb);
2546 ++ return NETDEV_TX_OK;
2547 + }
2548 +
2549 + sonic_tda_put(dev, entry, SONIC_TD_STATUS, 0); /* clear status */
2550 +diff --git a/drivers/net/ethernet/pasemi/pasemi_mac.c b/drivers/net/ethernet/pasemi/pasemi_mac.c
2551 +index 57a6e6cd74fc..48106953cf64 100644
2552 +--- a/drivers/net/ethernet/pasemi/pasemi_mac.c
2553 ++++ b/drivers/net/ethernet/pasemi/pasemi_mac.c
2554 +@@ -1091,7 +1091,6 @@ static int pasemi_mac_phy_init(struct net_device *dev)