Magellan Linux

Annotation of /trunk/kernel-alx-legacy/patches-4.9/0311-4.9.212-all-fixes.patch

Parent Directory Parent Directory | Revision Log Revision Log


Revision 3608 - (hide annotations) (download)
Fri Aug 14 07:34:29 2020 UTC (3 years, 10 months ago) by niro
File size: 240853 byte(s)
-added kerenl-alx-legacy pkg
1 niro 3608 diff --git a/Documentation/kernel-parameters.txt b/Documentation/kernel-parameters.txt
2     index 1bc12619bedd..b2d2f4539a3f 100644
3     --- a/Documentation/kernel-parameters.txt
4     +++ b/Documentation/kernel-parameters.txt
5     @@ -1965,6 +1965,12 @@ bytes respectively. Such letter suffixes can also be entirely omitted.
6     kmemcheck=2 (one-shot mode)
7     Default: 2 (one-shot mode)
8    
9     + kpti= [ARM64] Control page table isolation of user
10     + and kernel address spaces.
11     + Default: enabled on cores which need mitigation.
12     + 0: force disabled
13     + 1: force enabled
14     +
15     kstack=N [X86] Print N words from the kernel stack
16     in oops dumps.
17    
18     diff --git a/Makefile b/Makefile
19     index 7fd68e080fe4..b6c05e99814e 100644
20     --- a/Makefile
21     +++ b/Makefile
22     @@ -1,6 +1,6 @@
23     VERSION = 4
24     PATCHLEVEL = 9
25     -SUBLEVEL = 211
26     +SUBLEVEL = 212
27     EXTRAVERSION =
28     NAME = Roaring Lionus
29    
30     diff --git a/arch/arm/boot/dts/lpc3250-phy3250.dts b/arch/arm/boot/dts/lpc3250-phy3250.dts
31     index b7bd3a110a8d..dd0bdf765599 100644
32     --- a/arch/arm/boot/dts/lpc3250-phy3250.dts
33     +++ b/arch/arm/boot/dts/lpc3250-phy3250.dts
34     @@ -49,8 +49,8 @@
35     sd_reg: regulator@2 {
36     compatible = "regulator-fixed";
37     regulator-name = "sd_reg";
38     - regulator-min-microvolt = <1800000>;
39     - regulator-max-microvolt = <1800000>;
40     + regulator-min-microvolt = <3300000>;
41     + regulator-max-microvolt = <3300000>;
42     gpio = <&gpio 5 5 0>;
43     enable-active-high;
44     };
45     diff --git a/arch/arm/boot/dts/lpc32xx.dtsi b/arch/arm/boot/dts/lpc32xx.dtsi
46     index 5fa3111731cb..2802c9565b6c 100644
47     --- a/arch/arm/boot/dts/lpc32xx.dtsi
48     +++ b/arch/arm/boot/dts/lpc32xx.dtsi
49     @@ -139,11 +139,11 @@
50     };
51    
52     clcd: clcd@31040000 {
53     - compatible = "arm,pl110", "arm,primecell";
54     + compatible = "arm,pl111", "arm,primecell";
55     reg = <0x31040000 0x1000>;
56     interrupts = <14 IRQ_TYPE_LEVEL_HIGH>;
57     - clocks = <&clk LPC32XX_CLK_LCD>;
58     - clock-names = "apb_pclk";
59     + clocks = <&clk LPC32XX_CLK_LCD>, <&clk LPC32XX_CLK_LCD>;
60     + clock-names = "clcdclk", "apb_pclk";
61     status = "disabled";
62     };
63    
64     @@ -462,7 +462,9 @@
65     key: key@40050000 {
66     compatible = "nxp,lpc3220-key";
67     reg = <0x40050000 0x1000>;
68     - interrupts = <54 IRQ_TYPE_LEVEL_HIGH>;
69     + clocks = <&clk LPC32XX_CLK_KEY>;
70     + interrupt-parent = <&sic1>;
71     + interrupts = <22 IRQ_TYPE_LEVEL_HIGH>;
72     status = "disabled";
73     };
74    
75     diff --git a/arch/arm/boot/dts/ls1021a-twr.dts b/arch/arm/boot/dts/ls1021a-twr.dts
76     index 44715c8ef756..72a3fc63d0ec 100644
77     --- a/arch/arm/boot/dts/ls1021a-twr.dts
78     +++ b/arch/arm/boot/dts/ls1021a-twr.dts
79     @@ -143,7 +143,7 @@
80     };
81    
82     &enet0 {
83     - tbi-handle = <&tbi1>;
84     + tbi-handle = <&tbi0>;
85     phy-handle = <&sgmii_phy2>;
86     phy-connection-type = "sgmii";
87     status = "okay";
88     @@ -222,6 +222,13 @@
89     sgmii_phy2: ethernet-phy@2 {
90     reg = <0x2>;
91     };
92     + tbi0: tbi-phy@1f {
93     + reg = <0x1f>;
94     + device_type = "tbi-phy";
95     + };
96     +};
97     +
98     +&mdio1 {
99     tbi1: tbi-phy@1f {
100     reg = <0x1f>;
101     device_type = "tbi-phy";
102     diff --git a/arch/arm/boot/dts/ls1021a.dtsi b/arch/arm/boot/dts/ls1021a.dtsi
103     index 825f6eae3d1c..27133c3a4b12 100644
104     --- a/arch/arm/boot/dts/ls1021a.dtsi
105     +++ b/arch/arm/boot/dts/ls1021a.dtsi
106     @@ -505,13 +505,22 @@
107     };
108    
109     mdio0: mdio@2d24000 {
110     - compatible = "gianfar";
111     + compatible = "fsl,etsec2-mdio";
112     device_type = "mdio";
113     #address-cells = <1>;
114     #size-cells = <0>;
115     reg = <0x0 0x2d24000 0x0 0x4000>;
116     };
117    
118     + mdio1: mdio@2d64000 {
119     + compatible = "fsl,etsec2-mdio";
120     + device_type = "mdio";
121     + #address-cells = <1>;
122     + #size-cells = <0>;
123     + reg = <0x0 0x2d64000 0x0 0x4000>,
124     + <0x0 0x2d50030 0x0 0x4>;
125     + };
126     +
127     ptp_clock@2d10e00 {
128     compatible = "fsl,etsec-ptp";
129     reg = <0x0 0x2d10e00 0x0 0xb0>;
130     diff --git a/arch/arm/common/mcpm_entry.c b/arch/arm/common/mcpm_entry.c
131     index a923524d1040..8617323eb273 100644
132     --- a/arch/arm/common/mcpm_entry.c
133     +++ b/arch/arm/common/mcpm_entry.c
134     @@ -379,7 +379,7 @@ static int __init nocache_trampoline(unsigned long _arg)
135     unsigned int cluster = MPIDR_AFFINITY_LEVEL(mpidr, 1);
136     phys_reset_t phys_reset;
137    
138     - mcpm_set_entry_vector(cpu, cluster, cpu_resume);
139     + mcpm_set_entry_vector(cpu, cluster, cpu_resume_no_hyp);
140     setup_mm_for_reboot();
141    
142     __mcpm_cpu_going_down(cpu, cluster);
143     diff --git a/arch/arm/include/asm/suspend.h b/arch/arm/include/asm/suspend.h
144     index 6c7182f32cef..e6c2f426f8c8 100644
145     --- a/arch/arm/include/asm/suspend.h
146     +++ b/arch/arm/include/asm/suspend.h
147     @@ -7,6 +7,7 @@ struct sleep_save_sp {
148     };
149    
150     extern void cpu_resume(void);
151     +extern void cpu_resume_no_hyp(void);
152     extern void cpu_resume_arm(void);
153     extern int cpu_suspend(unsigned long, int (*)(unsigned long));
154    
155     diff --git a/arch/arm/kernel/hyp-stub.S b/arch/arm/kernel/hyp-stub.S
156     index 15d073ae5da2..f5e5e3e19659 100644
157     --- a/arch/arm/kernel/hyp-stub.S
158     +++ b/arch/arm/kernel/hyp-stub.S
159     @@ -179,8 +179,8 @@ ARM_BE8(orr r7, r7, #(1 << 25)) @ HSCTLR.EE
160     @ Check whether GICv3 system registers are available
161     mrc p15, 0, r7, c0, c1, 1 @ ID_PFR1
162     ubfx r7, r7, #28, #4
163     - cmp r7, #1
164     - bne 2f
165     + teq r7, #0
166     + beq 2f
167    
168     @ Enable system register accesses
169     mrc p15, 4, r7, c12, c9, 5 @ ICC_HSRE
170     diff --git a/arch/arm/kernel/sleep.S b/arch/arm/kernel/sleep.S
171     index 0f6c1000582c..c8569390e7e7 100644
172     --- a/arch/arm/kernel/sleep.S
173     +++ b/arch/arm/kernel/sleep.S
174     @@ -119,6 +119,14 @@ ENDPROC(cpu_resume_after_mmu)
175     .text
176     .align
177    
178     +#ifdef CONFIG_MCPM
179     + .arm
180     +THUMB( .thumb )
181     +ENTRY(cpu_resume_no_hyp)
182     +ARM_BE8(setend be) @ ensure we are in BE mode
183     + b no_hyp
184     +#endif
185     +
186     #ifdef CONFIG_MMU
187     .arm
188     ENTRY(cpu_resume_arm)
189     @@ -134,6 +142,7 @@ ARM_BE8(setend be) @ ensure we are in BE mode
190     bl __hyp_stub_install_secondary
191     #endif
192     safe_svcmode_maskall r1
193     +no_hyp:
194     mov r1, #0
195     ALT_SMP(mrc p15, 0, r0, c0, c0, 5)
196     ALT_UP_B(1f)
197     @@ -162,6 +171,9 @@ ENDPROC(cpu_resume)
198    
199     #ifdef CONFIG_MMU
200     ENDPROC(cpu_resume_arm)
201     +#endif
202     +#ifdef CONFIG_MCPM
203     +ENDPROC(cpu_resume_no_hyp)
204     #endif
205    
206     .align 2
207     diff --git a/arch/arm/mach-omap2/omap_hwmod.c b/arch/arm/mach-omap2/omap_hwmod.c
208     index bfc74954540c..9421b78f869d 100644
209     --- a/arch/arm/mach-omap2/omap_hwmod.c
210     +++ b/arch/arm/mach-omap2/omap_hwmod.c
211     @@ -2588,7 +2588,7 @@ static void _setup_iclk_autoidle(struct omap_hwmod *oh)
212     */
213     static int _setup_reset(struct omap_hwmod *oh)
214     {
215     - int r;
216     + int r = 0;
217    
218     if (oh->_state != _HWMOD_STATE_INITIALIZED)
219     return -EINVAL;
220     diff --git a/arch/arm/mach-rpc/irq.c b/arch/arm/mach-rpc/irq.c
221     index 66502e6207fe..fce7fecbd8fa 100644
222     --- a/arch/arm/mach-rpc/irq.c
223     +++ b/arch/arm/mach-rpc/irq.c
224     @@ -117,7 +117,7 @@ extern unsigned char rpc_default_fiq_start, rpc_default_fiq_end;
225    
226     void __init rpc_init_irq(void)
227     {
228     - unsigned int irq, clr, set = 0;
229     + unsigned int irq, clr, set;
230    
231     iomd_writeb(0, IOMD_IRQMASKA);
232     iomd_writeb(0, IOMD_IRQMASKB);
233     @@ -129,6 +129,7 @@ void __init rpc_init_irq(void)
234    
235     for (irq = 0; irq < NR_IRQS; irq++) {
236     clr = IRQ_NOREQUEST;
237     + set = 0;
238    
239     if (irq <= 6 || (irq >= 9 && irq <= 15))
240     clr |= IRQ_NOPROBE;
241     diff --git a/arch/arm/plat-pxa/ssp.c b/arch/arm/plat-pxa/ssp.c
242     index b92673efffff..97bd43c16cd8 100644
243     --- a/arch/arm/plat-pxa/ssp.c
244     +++ b/arch/arm/plat-pxa/ssp.c
245     @@ -230,18 +230,12 @@ static int pxa_ssp_probe(struct platform_device *pdev)
246    
247     static int pxa_ssp_remove(struct platform_device *pdev)
248     {
249     - struct resource *res;
250     struct ssp_device *ssp;
251    
252     ssp = platform_get_drvdata(pdev);
253     if (ssp == NULL)
254     return -ENODEV;
255    
256     - res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
257     - release_mem_region(res->start, resource_size(res));
258     -
259     - clk_put(ssp->clk);
260     -
261     mutex_lock(&ssp_lock);
262     list_del(&ssp->node);
263     mutex_unlock(&ssp_lock);
264     diff --git a/arch/arm64/boot/dts/arm/juno-clocks.dtsi b/arch/arm64/boot/dts/arm/juno-clocks.dtsi
265     index 25352ed943e6..00bcbf7688c7 100644
266     --- a/arch/arm64/boot/dts/arm/juno-clocks.dtsi
267     +++ b/arch/arm64/boot/dts/arm/juno-clocks.dtsi
268     @@ -8,10 +8,10 @@
269     */
270    
271     /* SoC fixed clocks */
272     - soc_uartclk: refclk7273800hz {
273     + soc_uartclk: refclk7372800hz {
274     compatible = "fixed-clock";
275     #clock-cells = <0>;
276     - clock-frequency = <7273800>;
277     + clock-frequency = <7372800>;
278     clock-output-names = "juno:uartclk";
279     };
280    
281     diff --git a/arch/arm64/boot/dts/qcom/apq8016-sbc.dtsi b/arch/arm64/boot/dts/qcom/apq8016-sbc.dtsi
282     index 601be6127628..948efff7d830 100644
283     --- a/arch/arm64/boot/dts/qcom/apq8016-sbc.dtsi
284     +++ b/arch/arm64/boot/dts/qcom/apq8016-sbc.dtsi
285     @@ -355,6 +355,8 @@
286     l11 {
287     regulator-min-microvolt = <1750000>;
288     regulator-max-microvolt = <3337000>;
289     + regulator-allow-set-load;
290     + regulator-system-load = <200000>;
291     };
292    
293     l12 {
294     diff --git a/arch/arm64/kernel/cpufeature.c b/arch/arm64/kernel/cpufeature.c
295     index 9a8e45dc36bd..8cf001baee21 100644
296     --- a/arch/arm64/kernel/cpufeature.c
297     +++ b/arch/arm64/kernel/cpufeature.c
298     @@ -789,6 +789,11 @@ static bool unmap_kernel_at_el0(const struct arm64_cpu_capabilities *entry,
299     switch (read_cpuid_id() & MIDR_CPU_MODEL_MASK) {
300     case MIDR_CAVIUM_THUNDERX2:
301     case MIDR_BRCM_VULCAN:
302     + case MIDR_CORTEX_A53:
303     + case MIDR_CORTEX_A55:
304     + case MIDR_CORTEX_A57:
305     + case MIDR_CORTEX_A72:
306     + case MIDR_CORTEX_A73:
307     return false;
308     }
309    
310     diff --git a/arch/m68k/amiga/cia.c b/arch/m68k/amiga/cia.c
311     index 2081b8cd5591..b9aee983e6f4 100644
312     --- a/arch/m68k/amiga/cia.c
313     +++ b/arch/m68k/amiga/cia.c
314     @@ -88,10 +88,19 @@ static irqreturn_t cia_handler(int irq, void *dev_id)
315     struct ciabase *base = dev_id;
316     int mach_irq;
317     unsigned char ints;
318     + unsigned long flags;
319    
320     + /* Interrupts get disabled while the timer irq flag is cleared and
321     + * the timer interrupt serviced.
322     + */
323     mach_irq = base->cia_irq;
324     + local_irq_save(flags);
325     ints = cia_set_irq(base, CIA_ICR_ALL);
326     amiga_custom.intreq = base->int_mask;
327     + if (ints & 1)
328     + generic_handle_irq(mach_irq);
329     + local_irq_restore(flags);
330     + mach_irq++, ints >>= 1;
331     for (; ints; mach_irq++, ints >>= 1) {
332     if (ints & 1)
333     generic_handle_irq(mach_irq);
334     diff --git a/arch/m68k/atari/ataints.c b/arch/m68k/atari/ataints.c
335     index 3d2b63bedf05..56f02ea2c248 100644
336     --- a/arch/m68k/atari/ataints.c
337     +++ b/arch/m68k/atari/ataints.c
338     @@ -142,7 +142,7 @@ struct mfptimerbase {
339     .name = "MFP Timer D"
340     };
341    
342     -static irqreturn_t mfptimer_handler(int irq, void *dev_id)
343     +static irqreturn_t mfp_timer_d_handler(int irq, void *dev_id)
344     {
345     struct mfptimerbase *base = dev_id;
346     int mach_irq;
347     @@ -344,7 +344,7 @@ void __init atari_init_IRQ(void)
348     st_mfp.tim_ct_cd = (st_mfp.tim_ct_cd & 0xf0) | 0x6;
349    
350     /* request timer D dispatch handler */
351     - if (request_irq(IRQ_MFP_TIMD, mfptimer_handler, IRQF_SHARED,
352     + if (request_irq(IRQ_MFP_TIMD, mfp_timer_d_handler, IRQF_SHARED,
353     stmfp_base.name, &stmfp_base))
354     pr_err("Couldn't register %s interrupt\n", stmfp_base.name);
355    
356     diff --git a/arch/m68k/atari/time.c b/arch/m68k/atari/time.c
357     index c549b48174ec..972181c1fe4b 100644
358     --- a/arch/m68k/atari/time.c
359     +++ b/arch/m68k/atari/time.c
360     @@ -24,6 +24,18 @@
361     DEFINE_SPINLOCK(rtc_lock);
362     EXPORT_SYMBOL_GPL(rtc_lock);
363    
364     +static irqreturn_t mfp_timer_c_handler(int irq, void *dev_id)
365     +{
366     + irq_handler_t timer_routine = dev_id;
367     + unsigned long flags;
368     +
369     + local_irq_save(flags);
370     + timer_routine(0, NULL);
371     + local_irq_restore(flags);
372     +
373     + return IRQ_HANDLED;
374     +}
375     +
376     void __init
377     atari_sched_init(irq_handler_t timer_routine)
378     {
379     @@ -32,7 +44,8 @@ atari_sched_init(irq_handler_t timer_routine)
380     /* start timer C, div = 1:100 */
381     st_mfp.tim_ct_cd = (st_mfp.tim_ct_cd & 15) | 0x60;
382     /* install interrupt service routine for MFP Timer C */
383     - if (request_irq(IRQ_MFP_TIMC, timer_routine, 0, "timer", timer_routine))
384     + if (request_irq(IRQ_MFP_TIMC, mfp_timer_c_handler, 0, "timer",
385     + timer_routine))
386     pr_err("Couldn't register timer interrupt\n");
387     }
388    
389     diff --git a/arch/m68k/bvme6000/config.c b/arch/m68k/bvme6000/config.c
390     index 611d4d9ea2bd..3978d71d250b 100644
391     --- a/arch/m68k/bvme6000/config.c
392     +++ b/arch/m68k/bvme6000/config.c
393     @@ -45,11 +45,6 @@ extern int bvme6000_set_clock_mmss (unsigned long);
394     extern void bvme6000_reset (void);
395     void bvme6000_set_vectors (void);
396    
397     -/* Save tick handler routine pointer, will point to xtime_update() in
398     - * kernel/timer/timekeeping.c, called via bvme6000_process_int() */
399     -
400     -static irq_handler_t tick_handler;
401     -
402    
403     int __init bvme6000_parse_bootinfo(const struct bi_record *bi)
404     {
405     @@ -159,12 +154,18 @@ irqreturn_t bvme6000_abort_int (int irq, void *dev_id)
406    
407     static irqreturn_t bvme6000_timer_int (int irq, void *dev_id)
408     {
409     + irq_handler_t timer_routine = dev_id;
410     + unsigned long flags;
411     volatile RtcPtr_t rtc = (RtcPtr_t)BVME_RTC_BASE;
412     - unsigned char msr = rtc->msr & 0xc0;
413     + unsigned char msr;
414    
415     + local_irq_save(flags);
416     + msr = rtc->msr & 0xc0;
417     rtc->msr = msr | 0x20; /* Ack the interrupt */
418     + timer_routine(0, NULL);
419     + local_irq_restore(flags);
420    
421     - return tick_handler(irq, dev_id);
422     + return IRQ_HANDLED;
423     }
424    
425     /*
426     @@ -183,9 +184,8 @@ void bvme6000_sched_init (irq_handler_t timer_routine)
427    
428     rtc->msr = 0; /* Ensure timer registers accessible */
429    
430     - tick_handler = timer_routine;
431     - if (request_irq(BVME_IRQ_RTC, bvme6000_timer_int, 0,
432     - "timer", bvme6000_timer_int))
433     + if (request_irq(BVME_IRQ_RTC, bvme6000_timer_int, 0, "timer",
434     + timer_routine))
435     panic ("Couldn't register timer int");
436    
437     rtc->t1cr_omr = 0x04; /* Mode 2, ext clk */
438     diff --git a/arch/m68k/hp300/time.c b/arch/m68k/hp300/time.c
439     index 749543b425a4..03c83b8f9032 100644
440     --- a/arch/m68k/hp300/time.c
441     +++ b/arch/m68k/hp300/time.c
442     @@ -37,13 +37,19 @@
443    
444     static irqreturn_t hp300_tick(int irq, void *dev_id)
445     {
446     + irq_handler_t timer_routine = dev_id;
447     + unsigned long flags;
448     unsigned long tmp;
449     - irq_handler_t vector = dev_id;
450     +
451     + local_irq_save(flags);
452     in_8(CLOCKBASE + CLKSR);
453     asm volatile ("movpw %1@(5),%0" : "=d" (tmp) : "a" (CLOCKBASE));
454     + timer_routine(0, NULL);
455     + local_irq_restore(flags);
456     +
457     /* Turn off the network and SCSI leds */
458     blinken_leds(0, 0xe0);
459     - return vector(irq, NULL);
460     + return IRQ_HANDLED;
461     }
462    
463     u32 hp300_gettimeoffset(void)
464     diff --git a/arch/m68k/mac/via.c b/arch/m68k/mac/via.c
465     index 920ff63d4a81..a435aced6e43 100644
466     --- a/arch/m68k/mac/via.c
467     +++ b/arch/m68k/mac/via.c
468     @@ -53,16 +53,6 @@ static __u8 rbv_clear;
469    
470     static int gIER,gIFR,gBufA,gBufB;
471    
472     -/*
473     - * Timer defs.
474     - */
475     -
476     -#define TICK_SIZE 10000
477     -#define MAC_CLOCK_TICK (783300/HZ) /* ticks per HZ */
478     -#define MAC_CLOCK_LOW (MAC_CLOCK_TICK&0xFF)
479     -#define MAC_CLOCK_HIGH (MAC_CLOCK_TICK>>8)
480     -
481     -
482     /*
483     * On Macs with a genuine VIA chip there is no way to mask an individual slot
484     * interrupt. This limitation also seems to apply to VIA clone logic cores in
485     @@ -277,22 +267,6 @@ void __init via_init(void)
486     }
487     }
488    
489     -/*
490     - * Start the 100 Hz clock
491     - */
492     -
493     -void __init via_init_clock(irq_handler_t func)
494     -{
495     - via1[vACR] |= 0x40;
496     - via1[vT1LL] = MAC_CLOCK_LOW;
497     - via1[vT1LH] = MAC_CLOCK_HIGH;
498     - via1[vT1CL] = MAC_CLOCK_LOW;
499     - via1[vT1CH] = MAC_CLOCK_HIGH;
500     -
501     - if (request_irq(IRQ_MAC_TIMER_1, func, 0, "timer", func))
502     - pr_err("Couldn't register %s interrupt\n", "timer");
503     -}
504     -
505     /*
506     * Debugging dump, used in various places to see what's going on.
507     */
508     @@ -320,29 +294,6 @@ void via_debug_dump(void)
509     }
510     }
511    
512     -/*
513     - * This is always executed with interrupts disabled.
514     - *
515     - * TBI: get time offset between scheduling timer ticks
516     - */
517     -
518     -u32 mac_gettimeoffset(void)
519     -{
520     - unsigned long ticks, offset = 0;
521     -
522     - /* read VIA1 timer 2 current value */
523     - ticks = via1[vT1CL] | (via1[vT1CH] << 8);
524     - /* The probability of underflow is less than 2% */
525     - if (ticks > MAC_CLOCK_TICK - MAC_CLOCK_TICK / 50)
526     - /* Check for pending timer interrupt in VIA1 IFR */
527     - if (via1[vIFR] & 0x40) offset = TICK_SIZE;
528     -
529     - ticks = MAC_CLOCK_TICK - ticks;
530     - ticks = ticks * 10000L / MAC_CLOCK_TICK;
531     -
532     - return (ticks + offset) * 1000;
533     -}
534     -
535     /*
536     * Flush the L2 cache on Macs that have it by flipping
537     * the system into 24-bit mode for an instant.
538     @@ -446,6 +397,8 @@ void via_nubus_irq_shutdown(int irq)
539     * via6522.c :-), disable/pending masks added.
540     */
541    
542     +#define VIA_TIMER_1_INT BIT(6)
543     +
544     void via1_irq(struct irq_desc *desc)
545     {
546     int irq_num;
547     @@ -455,6 +408,21 @@ void via1_irq(struct irq_desc *desc)
548     if (!events)
549     return;
550    
551     + irq_num = IRQ_MAC_TIMER_1;
552     + irq_bit = VIA_TIMER_1_INT;
553     + if (events & irq_bit) {
554     + unsigned long flags;
555     +
556     + local_irq_save(flags);
557     + via1[vIFR] = irq_bit;
558     + generic_handle_irq(irq_num);
559     + local_irq_restore(flags);
560     +
561     + events &= ~irq_bit;
562     + if (!events)
563     + return;
564     + }
565     +
566     irq_num = VIA1_SOURCE_BASE;
567     irq_bit = 1;
568     do {
569     @@ -619,3 +587,56 @@ int via2_scsi_drq_pending(void)
570     return via2[gIFR] & (1 << IRQ_IDX(IRQ_MAC_SCSIDRQ));
571     }
572     EXPORT_SYMBOL(via2_scsi_drq_pending);
573     +
574     +/* timer and clock source */
575     +
576     +#define VIA_CLOCK_FREQ 783360 /* VIA "phase 2" clock in Hz */
577     +#define VIA_TIMER_INTERVAL (1000000 / HZ) /* microseconds per jiffy */
578     +#define VIA_TIMER_CYCLES (VIA_CLOCK_FREQ / HZ) /* clock cycles per jiffy */
579     +
580     +#define VIA_TC (VIA_TIMER_CYCLES - 2) /* including 0 and -1 */
581     +#define VIA_TC_LOW (VIA_TC & 0xFF)
582     +#define VIA_TC_HIGH (VIA_TC >> 8)
583     +
584     +void __init via_init_clock(irq_handler_t timer_routine)
585     +{
586     + if (request_irq(IRQ_MAC_TIMER_1, timer_routine, 0, "timer", NULL)) {
587     + pr_err("Couldn't register %s interrupt\n", "timer");
588     + return;
589     + }
590     +
591     + via1[vT1LL] = VIA_TC_LOW;
592     + via1[vT1LH] = VIA_TC_HIGH;
593     + via1[vT1CL] = VIA_TC_LOW;
594     + via1[vT1CH] = VIA_TC_HIGH;
595     + via1[vACR] |= 0x40;
596     +}
597     +
598     +u32 mac_gettimeoffset(void)
599     +{
600     + unsigned long flags;
601     + u8 count_high;
602     + u16 count, offset = 0;
603     +
604     + /*
605     + * Timer counter wrap-around is detected with the timer interrupt flag
606     + * but reading the counter low byte (vT1CL) would reset the flag.
607     + * Also, accessing both counter registers is essentially a data race.
608     + * These problems are avoided by ignoring the low byte. Clock accuracy
609     + * is 256 times worse (error can reach 0.327 ms) but CPU overhead is
610     + * reduced by avoiding slow VIA register accesses.
611     + */
612     +
613     + local_irq_save(flags);
614     + count_high = via1[vT1CH];
615     + if (count_high == 0xFF)
616     + count_high = 0;
617     + if (count_high > 0 && (via1[vIFR] & VIA_TIMER_1_INT))
618     + offset = VIA_TIMER_CYCLES;
619     + local_irq_restore(flags);
620     +
621     + count = count_high << 8;
622     + count = VIA_TIMER_CYCLES - count + offset;
623     +
624     + return ((count * VIA_TIMER_INTERVAL) / VIA_TIMER_CYCLES) * 1000;
625     +}
626     diff --git a/arch/m68k/mvme147/config.c b/arch/m68k/mvme147/config.c
627     index c11d38dfad08..1a095443790b 100644
628     --- a/arch/m68k/mvme147/config.c
629     +++ b/arch/m68k/mvme147/config.c
630     @@ -46,11 +46,6 @@ extern void mvme147_reset (void);
631    
632     static int bcd2int (unsigned char b);
633    
634     -/* Save tick handler routine pointer, will point to xtime_update() in
635     - * kernel/time/timekeeping.c, called via mvme147_process_int() */
636     -
637     -irq_handler_t tick_handler;
638     -
639    
640     int __init mvme147_parse_bootinfo(const struct bi_record *bi)
641     {
642     @@ -106,16 +101,23 @@ void __init config_mvme147(void)
643    
644     static irqreturn_t mvme147_timer_int (int irq, void *dev_id)
645     {
646     + irq_handler_t timer_routine = dev_id;
647     + unsigned long flags;
648     +
649     + local_irq_save(flags);
650     m147_pcc->t1_int_cntrl = PCC_TIMER_INT_CLR;
651     m147_pcc->t1_int_cntrl = PCC_INT_ENAB|PCC_LEVEL_TIMER1;
652     - return tick_handler(irq, dev_id);
653     + timer_routine(0, NULL);
654     + local_irq_restore(flags);
655     +
656     + return IRQ_HANDLED;
657     }
658    
659    
660     void mvme147_sched_init (irq_handler_t timer_routine)
661     {
662     - tick_handler = timer_routine;
663     - if (request_irq(PCC_IRQ_TIMER1, mvme147_timer_int, 0, "timer 1", NULL))
664     + if (request_irq(PCC_IRQ_TIMER1, mvme147_timer_int, 0, "timer 1",
665     + timer_routine))
666     pr_err("Couldn't register timer interrupt\n");
667    
668     /* Init the clock with a value */
669     diff --git a/arch/m68k/mvme16x/config.c b/arch/m68k/mvme16x/config.c
670     index 58e240939d26..ac49fa7ec46b 100644
671     --- a/arch/m68k/mvme16x/config.c
672     +++ b/arch/m68k/mvme16x/config.c
673     @@ -51,11 +51,6 @@ extern void mvme16x_reset (void);
674    
675     int bcd2int (unsigned char b);
676    
677     -/* Save tick handler routine pointer, will point to xtime_update() in
678     - * kernel/time/timekeeping.c, called via mvme16x_process_int() */
679     -
680     -static irq_handler_t tick_handler;
681     -
682    
683     unsigned short mvme16x_config;
684     EXPORT_SYMBOL(mvme16x_config);
685     @@ -354,8 +349,15 @@ static irqreturn_t mvme16x_abort_int (int irq, void *dev_id)
686    
687     static irqreturn_t mvme16x_timer_int (int irq, void *dev_id)
688     {
689     - *(volatile unsigned char *)0xfff4201b |= 8;
690     - return tick_handler(irq, dev_id);
691     + irq_handler_t timer_routine = dev_id;
692     + unsigned long flags;
693     +
694     + local_irq_save(flags);
695     + *(volatile unsigned char *)0xfff4201b |= 8;
696     + timer_routine(0, NULL);
697     + local_irq_restore(flags);
698     +
699     + return IRQ_HANDLED;
700     }
701    
702     void mvme16x_sched_init (irq_handler_t timer_routine)
703     @@ -363,14 +365,13 @@ void mvme16x_sched_init (irq_handler_t timer_routine)
704     uint16_t brdno = be16_to_cpu(mvme_bdid.brdno);
705     int irq;
706    
707     - tick_handler = timer_routine;
708     /* Using PCCchip2 or MC2 chip tick timer 1 */
709     *(volatile unsigned long *)0xfff42008 = 0;
710     *(volatile unsigned long *)0xfff42004 = 10000; /* 10ms */
711     *(volatile unsigned char *)0xfff42017 |= 3;
712     *(volatile unsigned char *)0xfff4201b = 0x16;
713     - if (request_irq(MVME16x_IRQ_TIMER, mvme16x_timer_int, 0,
714     - "timer", mvme16x_timer_int))
715     + if (request_irq(MVME16x_IRQ_TIMER, mvme16x_timer_int, 0, "timer",
716     + timer_routine))
717     panic ("Couldn't register timer int");
718    
719     if (brdno == 0x0162 || brdno == 0x172)
720     diff --git a/arch/m68k/q40/q40ints.c b/arch/m68k/q40/q40ints.c
721     index 513f9bb17b9c..60b51f5b9cfc 100644
722     --- a/arch/m68k/q40/q40ints.c
723     +++ b/arch/m68k/q40/q40ints.c
724     @@ -126,10 +126,10 @@ void q40_mksound(unsigned int hz, unsigned int ticks)
725     sound_ticks = ticks << 1;
726     }
727    
728     -static irq_handler_t q40_timer_routine;
729     -
730     -static irqreturn_t q40_timer_int (int irq, void * dev)
731     +static irqreturn_t q40_timer_int(int irq, void *dev_id)
732     {
733     + irq_handler_t timer_routine = dev_id;
734     +
735     ql_ticks = ql_ticks ? 0 : 1;
736     if (sound_ticks) {
737     unsigned char sval=(sound_ticks & 1) ? 128-SVOL : 128+SVOL;
738     @@ -138,8 +138,13 @@ static irqreturn_t q40_timer_int (int irq, void * dev)
739     *DAC_RIGHT=sval;
740     }
741    
742     - if (!ql_ticks)
743     - q40_timer_routine(irq, dev);
744     + if (!ql_ticks) {
745     + unsigned long flags;
746     +
747     + local_irq_save(flags);
748     + timer_routine(0, NULL);
749     + local_irq_restore(flags);
750     + }
751     return IRQ_HANDLED;
752     }
753    
754     @@ -147,11 +152,9 @@ void q40_sched_init (irq_handler_t timer_routine)
755     {
756     int timer_irq;
757    
758     - q40_timer_routine = timer_routine;
759     timer_irq = Q40_IRQ_FRAME;
760    
761     - if (request_irq(timer_irq, q40_timer_int, 0,
762     - "timer", q40_timer_int))
763     + if (request_irq(timer_irq, q40_timer_int, 0, "timer", timer_routine))
764     panic("Couldn't register timer int");
765    
766     master_outb(-1, FRAME_CLEAR_REG);
767     diff --git a/arch/m68k/sun3/sun3ints.c b/arch/m68k/sun3/sun3ints.c
768     index 6bbca30c9188..a5824abb4a39 100644
769     --- a/arch/m68k/sun3/sun3ints.c
770     +++ b/arch/m68k/sun3/sun3ints.c
771     @@ -61,8 +61,10 @@ static irqreturn_t sun3_int7(int irq, void *dev_id)
772    
773     static irqreturn_t sun3_int5(int irq, void *dev_id)
774     {
775     + unsigned long flags;
776     unsigned int cnt;
777    
778     + local_irq_save(flags);
779     #ifdef CONFIG_SUN3
780     intersil_clear();
781     #endif
782     @@ -76,6 +78,7 @@ static irqreturn_t sun3_int5(int irq, void *dev_id)
783     cnt = kstat_irqs_cpu(irq, 0);
784     if (!(cnt % 20))
785     sun3_leds(led_pattern[cnt % 160 / 20]);
786     + local_irq_restore(flags);
787     return IRQ_HANDLED;
788     }
789    
790     diff --git a/arch/m68k/sun3x/time.c b/arch/m68k/sun3x/time.c
791     index 431d3c4306dd..a4f6a44d3418 100644
792     --- a/arch/m68k/sun3x/time.c
793     +++ b/arch/m68k/sun3x/time.c
794     @@ -77,15 +77,19 @@ u32 sun3x_gettimeoffset(void)
795     }
796    
797     #if 0
798     -static void sun3x_timer_tick(int irq, void *dev_id, struct pt_regs *regs)
799     +static irqreturn_t sun3x_timer_tick(int irq, void *dev_id)
800     {
801     - void (*vector)(int, void *, struct pt_regs *) = dev_id;
802     + irq_handler_t timer_routine = dev_id;
803     + unsigned long flags;
804    
805     - /* Clear the pending interrupt - pulse the enable line low */
806     - disable_irq(5);
807     - enable_irq(5);
808     + local_irq_save(flags);
809     + /* Clear the pending interrupt - pulse the enable line low */
810     + disable_irq(5);
811     + enable_irq(5);
812     + timer_routine(0, NULL);
813     + local_irq_restore(flags);
814    
815     - vector(irq, NULL, regs);
816     + return IRQ_HANDLED;
817     }
818     #endif
819    
820     diff --git a/arch/mips/include/asm/io.h b/arch/mips/include/asm/io.h
821     index 06049b6b3ddd..5dfae80264b9 100644
822     --- a/arch/mips/include/asm/io.h
823     +++ b/arch/mips/include/asm/io.h
824     @@ -60,21 +60,11 @@
825     * instruction, so the lower 16 bits must be zero. Should be true on
826     * on any sane architecture; generic code does not use this assumption.
827     */
828     -extern const unsigned long mips_io_port_base;
829     +extern unsigned long mips_io_port_base;
830    
831     -/*
832     - * Gcc will generate code to load the value of mips_io_port_base after each
833     - * function call which may be fairly wasteful in some cases. So we don't
834     - * play quite by the book. We tell gcc mips_io_port_base is a long variable
835     - * which solves the code generation issue. Now we need to violate the
836     - * aliasing rules a little to make initialization possible and finally we
837     - * will need the barrier() to fight side effects of the aliasing chat.
838     - * This trickery will eventually collapse under gcc's optimizer. Oh well.
839     - */
840     static inline void set_io_port_base(unsigned long base)
841     {
842     - * (unsigned long *) &mips_io_port_base = base;
843     - barrier();
844     + mips_io_port_base = base;
845     }
846    
847     /*
848     diff --git a/arch/mips/kernel/setup.c b/arch/mips/kernel/setup.c
849     index 695950361d2a..7cc1d29334ee 100644
850     --- a/arch/mips/kernel/setup.c
851     +++ b/arch/mips/kernel/setup.c
852     @@ -74,7 +74,7 @@ static char __initdata builtin_cmdline[COMMAND_LINE_SIZE] = CONFIG_CMDLINE;
853     * mips_io_port_base is the begin of the address space to which x86 style
854     * I/O ports are mapped.
855     */
856     -const unsigned long mips_io_port_base = -1;
857     +unsigned long mips_io_port_base = -1;
858     EXPORT_SYMBOL(mips_io_port_base);
859    
860     static struct resource code_resource = { .name = "Kernel code", };
861     diff --git a/arch/nios2/kernel/nios2_ksyms.c b/arch/nios2/kernel/nios2_ksyms.c
862     index bf2f55d10a4d..4e704046a150 100644
863     --- a/arch/nios2/kernel/nios2_ksyms.c
864     +++ b/arch/nios2/kernel/nios2_ksyms.c
865     @@ -9,12 +9,20 @@
866     #include <linux/export.h>
867     #include <linux/string.h>
868    
869     +#include <asm/cacheflush.h>
870     +#include <asm/pgtable.h>
871     +
872     /* string functions */
873    
874     EXPORT_SYMBOL(memcpy);
875     EXPORT_SYMBOL(memset);
876     EXPORT_SYMBOL(memmove);
877    
878     +/* memory management */
879     +
880     +EXPORT_SYMBOL(empty_zero_page);
881     +EXPORT_SYMBOL(flush_icache_range);
882     +
883     /*
884     * libgcc functions - functions that are used internally by the
885     * compiler... (prototypes are not correct though, but that
886     @@ -31,3 +39,7 @@ DECLARE_EXPORT(__udivsi3);
887     DECLARE_EXPORT(__umoddi3);
888     DECLARE_EXPORT(__umodsi3);
889     DECLARE_EXPORT(__muldi3);
890     +DECLARE_EXPORT(__ucmpdi2);
891     +DECLARE_EXPORT(__lshrdi3);
892     +DECLARE_EXPORT(__ashldi3);
893     +DECLARE_EXPORT(__ashrdi3);
894     diff --git a/arch/powerpc/Makefile b/arch/powerpc/Makefile
895     index a60c9c6e5cc1..de29b88c0e70 100644
896     --- a/arch/powerpc/Makefile
897     +++ b/arch/powerpc/Makefile
898     @@ -373,7 +373,9 @@ vdso_install:
899     ifeq ($(CONFIG_PPC64),y)
900     $(Q)$(MAKE) $(build)=arch/$(ARCH)/kernel/vdso64 $@
901     endif
902     +ifdef CONFIG_VDSO32
903     $(Q)$(MAKE) $(build)=arch/$(ARCH)/kernel/vdso32 $@
904     +endif
905    
906     archclean:
907     $(Q)$(MAKE) $(clean)=$(boot)
908     diff --git a/arch/powerpc/include/asm/archrandom.h b/arch/powerpc/include/asm/archrandom.h
909     index 85e88f7a59c0..9ff848e3c4a6 100644
910     --- a/arch/powerpc/include/asm/archrandom.h
911     +++ b/arch/powerpc/include/asm/archrandom.h
912     @@ -27,7 +27,7 @@ static inline int arch_get_random_seed_int(unsigned int *v)
913     unsigned long val;
914     int rc;
915    
916     - rc = arch_get_random_long(&val);
917     + rc = arch_get_random_seed_long(&val);
918     if (rc)
919     *v = val;
920    
921     diff --git a/arch/powerpc/kernel/cacheinfo.c b/arch/powerpc/kernel/cacheinfo.c
922     index c641983bbdd6..3394a72b19f2 100644
923     --- a/arch/powerpc/kernel/cacheinfo.c
924     +++ b/arch/powerpc/kernel/cacheinfo.c
925     @@ -867,4 +867,21 @@ void cacheinfo_cpu_offline(unsigned int cpu_id)
926     if (cache)
927     cache_cpu_clear(cache, cpu_id);
928     }
929     +
930     +void cacheinfo_teardown(void)
931     +{
932     + unsigned int cpu;
933     +
934     + for_each_online_cpu(cpu)
935     + cacheinfo_cpu_offline(cpu);
936     +}
937     +
938     +void cacheinfo_rebuild(void)
939     +{
940     + unsigned int cpu;
941     +
942     + for_each_online_cpu(cpu)
943     + cacheinfo_cpu_online(cpu);
944     +}
945     +
946     #endif /* (CONFIG_PPC_PSERIES && CONFIG_SUSPEND) || CONFIG_HOTPLUG_CPU */
947     diff --git a/arch/powerpc/kernel/cacheinfo.h b/arch/powerpc/kernel/cacheinfo.h
948     index a7b74d36acd7..2cdee87a482c 100644
949     --- a/arch/powerpc/kernel/cacheinfo.h
950     +++ b/arch/powerpc/kernel/cacheinfo.h
951     @@ -5,4 +5,8 @@
952     extern void cacheinfo_cpu_online(unsigned int cpu_id);
953     extern void cacheinfo_cpu_offline(unsigned int cpu_id);
954    
955     +/* Allow migration/suspend to tear down and rebuild the hierarchy. */
956     +extern void cacheinfo_teardown(void);
957     +extern void cacheinfo_rebuild(void);
958     +
959     #endif /* _PPC_CACHEINFO_H */
960     diff --git a/arch/x86/Kconfig.debug b/arch/x86/Kconfig.debug
961     index 4386440fe463..f09a192260f8 100644
962     --- a/arch/x86/Kconfig.debug
963     +++ b/arch/x86/Kconfig.debug
964     @@ -192,7 +192,7 @@ config HAVE_MMIOTRACE_SUPPORT
965    
966     config X86_DECODER_SELFTEST
967     bool "x86 instruction decoder selftest"
968     - depends on DEBUG_KERNEL && KPROBES
969     + depends on DEBUG_KERNEL && INSTRUCTION_DECODER
970     depends on !COMPILE_TEST
971     ---help---
972     Perform x86 instruction decoder selftests at build time.
973     diff --git a/arch/x86/kernel/kgdb.c b/arch/x86/kernel/kgdb.c
974     index 8e36f249646e..904e18bb38c5 100644
975     --- a/arch/x86/kernel/kgdb.c
976     +++ b/arch/x86/kernel/kgdb.c
977     @@ -438,7 +438,7 @@ static void kgdb_disable_hw_debug(struct pt_regs *regs)
978     */
979     void kgdb_roundup_cpus(unsigned long flags)
980     {
981     - apic->send_IPI_allbutself(APIC_DM_NMI);
982     + apic->send_IPI_allbutself(NMI_VECTOR);
983     }
984     #endif
985    
986     diff --git a/block/blk-merge.c b/block/blk-merge.c
987     index 2642e5fc8b69..66795cca662a 100644
988     --- a/block/blk-merge.c
989     +++ b/block/blk-merge.c
990     @@ -305,13 +305,7 @@ void blk_recalc_rq_segments(struct request *rq)
991    
992     void blk_recount_segments(struct request_queue *q, struct bio *bio)
993     {
994     - unsigned short seg_cnt;
995     -
996     - /* estimate segment number by bi_vcnt for non-cloned bio */
997     - if (bio_flagged(bio, BIO_CLONED))
998     - seg_cnt = bio_segments(bio);
999     - else
1000     - seg_cnt = bio->bi_vcnt;
1001     + unsigned short seg_cnt = bio_segments(bio);
1002    
1003     if (test_bit(QUEUE_FLAG_NO_SG_MERGE, &q->queue_flags) &&
1004     (seg_cnt < queue_max_segments(q)))
1005     diff --git a/crypto/pcrypt.c b/crypto/pcrypt.c
1006     index f8ec3d4ba4a8..a5718c0a3dc4 100644
1007     --- a/crypto/pcrypt.c
1008     +++ b/crypto/pcrypt.c
1009     @@ -394,7 +394,7 @@ static int pcrypt_sysfs_add(struct padata_instance *pinst, const char *name)
1010     int ret;
1011    
1012     pinst->kobj.kset = pcrypt_kset;
1013     - ret = kobject_add(&pinst->kobj, NULL, name);
1014     + ret = kobject_add(&pinst->kobj, NULL, "%s", name);
1015     if (!ret)
1016     kobject_uevent(&pinst->kobj, KOBJ_ADD);
1017    
1018     diff --git a/crypto/tgr192.c b/crypto/tgr192.c
1019     index 321bc6ff2a9d..904c8444aa0a 100644
1020     --- a/crypto/tgr192.c
1021     +++ b/crypto/tgr192.c
1022     @@ -25,8 +25,9 @@
1023     #include <linux/init.h>
1024     #include <linux/module.h>
1025     #include <linux/mm.h>
1026     -#include <asm/byteorder.h>
1027     #include <linux/types.h>
1028     +#include <asm/byteorder.h>
1029     +#include <asm/unaligned.h>
1030    
1031     #define TGR192_DIGEST_SIZE 24
1032     #define TGR160_DIGEST_SIZE 20
1033     @@ -468,10 +469,9 @@ static void tgr192_transform(struct tgr192_ctx *tctx, const u8 * data)
1034     u64 a, b, c, aa, bb, cc;
1035     u64 x[8];
1036     int i;
1037     - const __le64 *ptr = (const __le64 *)data;
1038    
1039     for (i = 0; i < 8; i++)
1040     - x[i] = le64_to_cpu(ptr[i]);
1041     + x[i] = get_unaligned_le64(data + i * sizeof(__le64));
1042    
1043     /* save */
1044     a = aa = tctx->a;
1045     diff --git a/drivers/ata/libahci.c b/drivers/ata/libahci.c
1046     index f233ce60a678..1610fff19bb3 100644
1047     --- a/drivers/ata/libahci.c
1048     +++ b/drivers/ata/libahci.c
1049     @@ -190,7 +190,6 @@ struct ata_port_operations ahci_pmp_retry_srst_ops = {
1050     EXPORT_SYMBOL_GPL(ahci_pmp_retry_srst_ops);
1051    
1052     static bool ahci_em_messages __read_mostly = true;
1053     -EXPORT_SYMBOL_GPL(ahci_em_messages);
1054     module_param(ahci_em_messages, bool, 0444);
1055     /* add other LED protocol types when they become supported */
1056     MODULE_PARM_DESC(ahci_em_messages,
1057     diff --git a/drivers/atm/firestream.c b/drivers/atm/firestream.c
1058     index 85aaf2222587..82296fe2ba3b 100644
1059     --- a/drivers/atm/firestream.c
1060     +++ b/drivers/atm/firestream.c
1061     @@ -927,6 +927,7 @@ static int fs_open(struct atm_vcc *atm_vcc)
1062     }
1063     if (!to) {
1064     printk ("No more free channels for FS50..\n");
1065     + kfree(vcc);
1066     return -EBUSY;
1067     }
1068     vcc->channo = dev->channo;
1069     @@ -937,6 +938,7 @@ static int fs_open(struct atm_vcc *atm_vcc)
1070     if (((DO_DIRECTION(rxtp) && dev->atm_vccs[vcc->channo])) ||
1071     ( DO_DIRECTION(txtp) && test_bit (vcc->channo, dev->tx_inuse))) {
1072     printk ("Channel is in use for FS155.\n");
1073     + kfree(vcc);
1074     return -EBUSY;
1075     }
1076     }
1077     @@ -950,6 +952,7 @@ static int fs_open(struct atm_vcc *atm_vcc)
1078     tc, sizeof (struct fs_transmit_config));
1079     if (!tc) {
1080     fs_dprintk (FS_DEBUG_OPEN, "fs: can't alloc transmit_config.\n");
1081     + kfree(vcc);
1082     return -ENOMEM;
1083     }
1084    
1085     diff --git a/drivers/bcma/driver_pci.c b/drivers/bcma/driver_pci.c
1086     index f499a469e66d..12b2cc9a3fbe 100644
1087     --- a/drivers/bcma/driver_pci.c
1088     +++ b/drivers/bcma/driver_pci.c
1089     @@ -78,7 +78,7 @@ static u16 bcma_pcie_mdio_read(struct bcma_drv_pci *pc, u16 device, u8 address)
1090     v |= (address << BCMA_CORE_PCI_MDIODATA_REGADDR_SHF_OLD);
1091     }
1092    
1093     - v = BCMA_CORE_PCI_MDIODATA_START;
1094     + v |= BCMA_CORE_PCI_MDIODATA_START;
1095     v |= BCMA_CORE_PCI_MDIODATA_READ;
1096     v |= BCMA_CORE_PCI_MDIODATA_TA;
1097    
1098     @@ -121,7 +121,7 @@ static void bcma_pcie_mdio_write(struct bcma_drv_pci *pc, u16 device,
1099     v |= (address << BCMA_CORE_PCI_MDIODATA_REGADDR_SHF_OLD);
1100     }
1101    
1102     - v = BCMA_CORE_PCI_MDIODATA_START;
1103     + v |= BCMA_CORE_PCI_MDIODATA_START;
1104     v |= BCMA_CORE_PCI_MDIODATA_WRITE;
1105     v |= BCMA_CORE_PCI_MDIODATA_TA;
1106     v |= data;
1107     diff --git a/drivers/block/drbd/drbd_main.c b/drivers/block/drbd/drbd_main.c
1108     index f5c24459fc5c..daa9cef96ec6 100644
1109     --- a/drivers/block/drbd/drbd_main.c
1110     +++ b/drivers/block/drbd/drbd_main.c
1111     @@ -332,6 +332,8 @@ static int drbd_thread_setup(void *arg)
1112     thi->name[0],
1113     resource->name);
1114    
1115     + allow_kernel_signal(DRBD_SIGKILL);
1116     + allow_kernel_signal(SIGXCPU);
1117     restart:
1118     retval = thi->function(thi);
1119    
1120     diff --git a/drivers/clk/clk-highbank.c b/drivers/clk/clk-highbank.c
1121     index 727ed8e1bb72..8e4581004695 100644
1122     --- a/drivers/clk/clk-highbank.c
1123     +++ b/drivers/clk/clk-highbank.c
1124     @@ -293,6 +293,7 @@ static __init struct clk *hb_clk_init(struct device_node *node, const struct clk
1125     /* Map system registers */
1126     srnp = of_find_compatible_node(NULL, NULL, "calxeda,hb-sregs");
1127     hb_clk->reg = of_iomap(srnp, 0);
1128     + of_node_put(srnp);
1129     BUG_ON(!hb_clk->reg);
1130     hb_clk->reg += reg;
1131    
1132     diff --git a/drivers/clk/clk-qoriq.c b/drivers/clk/clk-qoriq.c
1133     index cdce49f6476a..65876ff6df41 100644
1134     --- a/drivers/clk/clk-qoriq.c
1135     +++ b/drivers/clk/clk-qoriq.c
1136     @@ -1245,6 +1245,7 @@ static void __init clockgen_init(struct device_node *np)
1137     pr_err("%s: Couldn't map %s regs\n", __func__,
1138     guts->full_name);
1139     }
1140     + of_node_put(guts);
1141     }
1142    
1143     }
1144     diff --git a/drivers/clk/imx/clk-imx6q.c b/drivers/clk/imx/clk-imx6q.c
1145     index 14682df5d312..d83f6221f1b0 100644
1146     --- a/drivers/clk/imx/clk-imx6q.c
1147     +++ b/drivers/clk/imx/clk-imx6q.c
1148     @@ -174,6 +174,7 @@ static void __init imx6q_clocks_init(struct device_node *ccm_node)
1149     np = of_find_compatible_node(NULL, NULL, "fsl,imx6q-anatop");
1150     base = of_iomap(np, 0);
1151     WARN_ON(!base);
1152     + of_node_put(np);
1153    
1154     /* Audio/video PLL post dividers do not work on i.MX6q revision 1.0 */
1155     if (clk_on_imx6q() && imx_get_soc_revision() == IMX_CHIP_REVISION_1_0) {
1156     diff --git a/drivers/clk/imx/clk-imx6sx.c b/drivers/clk/imx/clk-imx6sx.c
1157     index b5c96de41ccf..8bbc2542f2f7 100644
1158     --- a/drivers/clk/imx/clk-imx6sx.c
1159     +++ b/drivers/clk/imx/clk-imx6sx.c
1160     @@ -164,6 +164,7 @@ static void __init imx6sx_clocks_init(struct device_node *ccm_node)
1161     np = of_find_compatible_node(NULL, NULL, "fsl,imx6sx-anatop");
1162     base = of_iomap(np, 0);
1163     WARN_ON(!base);
1164     + of_node_put(np);
1165    
1166     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));
1167     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));
1168     diff --git a/drivers/clk/imx/clk-imx7d.c b/drivers/clk/imx/clk-imx7d.c
1169     index e7c7353a86fc..8c0c0d015132 100644
1170     --- a/drivers/clk/imx/clk-imx7d.c
1171     +++ b/drivers/clk/imx/clk-imx7d.c
1172     @@ -415,6 +415,7 @@ static void __init imx7d_clocks_init(struct device_node *ccm_node)
1173     np = of_find_compatible_node(NULL, NULL, "fsl,imx7d-anatop");
1174     base = of_iomap(np, 0);
1175     WARN_ON(!base);
1176     + of_node_put(np);
1177    
1178     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));
1179     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));
1180     diff --git a/drivers/clk/imx/clk-vf610.c b/drivers/clk/imx/clk-vf610.c
1181     index 0476353ab423..a19ab032d073 100644
1182     --- a/drivers/clk/imx/clk-vf610.c
1183     +++ b/drivers/clk/imx/clk-vf610.c
1184     @@ -203,6 +203,7 @@ static void __init vf610_clocks_init(struct device_node *ccm_node)
1185     np = of_find_compatible_node(NULL, NULL, "fsl,vf610-anatop");
1186     anatop_base = of_iomap(np, 0);
1187     BUG_ON(!anatop_base);
1188     + of_node_put(np);
1189    
1190     np = ccm_node;
1191     ccm_base = of_iomap(np, 0);
1192     diff --git a/drivers/clk/mvebu/armada-370.c b/drivers/clk/mvebu/armada-370.c
1193     index 2c7c1085f883..8fdfa97900cd 100644
1194     --- a/drivers/clk/mvebu/armada-370.c
1195     +++ b/drivers/clk/mvebu/armada-370.c
1196     @@ -177,8 +177,10 @@ static void __init a370_clk_init(struct device_node *np)
1197    
1198     mvebu_coreclk_setup(np, &a370_coreclks);
1199    
1200     - if (cgnp)
1201     + if (cgnp) {
1202     mvebu_clk_gating_setup(cgnp, a370_gating_desc);
1203     + of_node_put(cgnp);
1204     + }
1205     }
1206     CLK_OF_DECLARE(a370_clk, "marvell,armada-370-core-clock", a370_clk_init);
1207    
1208     diff --git a/drivers/clk/mvebu/armada-xp.c b/drivers/clk/mvebu/armada-xp.c
1209     index b3094315a3c0..2fa15a274719 100644
1210     --- a/drivers/clk/mvebu/armada-xp.c
1211     +++ b/drivers/clk/mvebu/armada-xp.c
1212     @@ -202,7 +202,9 @@ static void __init axp_clk_init(struct device_node *np)
1213    
1214     mvebu_coreclk_setup(np, &axp_coreclks);
1215    
1216     - if (cgnp)
1217     + if (cgnp) {
1218     mvebu_clk_gating_setup(cgnp, axp_gating_desc);
1219     + of_node_put(cgnp);
1220     + }
1221     }
1222     CLK_OF_DECLARE(axp_clk, "marvell,armada-xp-core-clock", axp_clk_init);
1223     diff --git a/drivers/clk/mvebu/dove.c b/drivers/clk/mvebu/dove.c
1224     index 59fad9546c84..5f258c9bb68b 100644
1225     --- a/drivers/clk/mvebu/dove.c
1226     +++ b/drivers/clk/mvebu/dove.c
1227     @@ -190,10 +190,14 @@ static void __init dove_clk_init(struct device_node *np)
1228    
1229     mvebu_coreclk_setup(np, &dove_coreclks);
1230    
1231     - if (ddnp)
1232     + if (ddnp) {
1233     dove_divider_clk_init(ddnp);
1234     + of_node_put(ddnp);
1235     + }
1236    
1237     - if (cgnp)
1238     + if (cgnp) {
1239     mvebu_clk_gating_setup(cgnp, dove_gating_desc);
1240     + of_node_put(cgnp);
1241     + }
1242     }
1243     CLK_OF_DECLARE(dove_clk, "marvell,dove-core-clock", dove_clk_init);
1244     diff --git a/drivers/clk/mvebu/kirkwood.c b/drivers/clk/mvebu/kirkwood.c
1245     index a2a8d614039d..890ebf623261 100644
1246     --- a/drivers/clk/mvebu/kirkwood.c
1247     +++ b/drivers/clk/mvebu/kirkwood.c
1248     @@ -333,6 +333,8 @@ static void __init kirkwood_clk_init(struct device_node *np)
1249     if (cgnp) {
1250     mvebu_clk_gating_setup(cgnp, kirkwood_gating_desc);
1251     kirkwood_clk_muxing_setup(cgnp, kirkwood_mux_desc);
1252     +
1253     + of_node_put(cgnp);
1254     }
1255     }
1256     CLK_OF_DECLARE(kirkwood_clk, "marvell,kirkwood-core-clock",
1257     diff --git a/drivers/clk/qcom/gcc-msm8996.c b/drivers/clk/qcom/gcc-msm8996.c
1258     index fe03e6fbc7df..ea6c227331fc 100644
1259     --- a/drivers/clk/qcom/gcc-msm8996.c
1260     +++ b/drivers/clk/qcom/gcc-msm8996.c
1261     @@ -140,22 +140,6 @@ static const char * const gcc_xo_gpll0_gpll4_gpll0_early_div[] = {
1262     "gpll0_early_div"
1263     };
1264    
1265     -static const struct parent_map gcc_xo_gpll0_gpll2_gpll3_gpll0_early_div_map[] = {
1266     - { P_XO, 0 },
1267     - { P_GPLL0, 1 },
1268     - { P_GPLL2, 2 },
1269     - { P_GPLL3, 3 },
1270     - { P_GPLL0_EARLY_DIV, 6 }
1271     -};
1272     -
1273     -static const char * const gcc_xo_gpll0_gpll2_gpll3_gpll0_early_div[] = {
1274     - "xo",
1275     - "gpll0",
1276     - "gpll2",
1277     - "gpll3",
1278     - "gpll0_early_div"
1279     -};
1280     -
1281     static const struct parent_map gcc_xo_gpll0_gpll1_early_div_gpll1_gpll4_gpll0_early_div_map[] = {
1282     { P_XO, 0 },
1283     { P_GPLL0, 1 },
1284     @@ -194,26 +178,6 @@ static const char * const gcc_xo_gpll0_gpll2_gpll3_gpll1_gpll2_early_gpll0_early
1285     "gpll0_early_div"
1286     };
1287    
1288     -static const struct parent_map gcc_xo_gpll0_gpll2_gpll3_gpll1_gpll4_gpll0_early_div_map[] = {
1289     - { P_XO, 0 },
1290     - { P_GPLL0, 1 },
1291     - { P_GPLL2, 2 },
1292     - { P_GPLL3, 3 },
1293     - { P_GPLL1, 4 },
1294     - { P_GPLL4, 5 },
1295     - { P_GPLL0_EARLY_DIV, 6 }
1296     -};
1297     -
1298     -static const char * const gcc_xo_gpll0_gpll2_gpll3_gpll1_gpll4_gpll0_early_div[] = {
1299     - "xo",
1300     - "gpll0",
1301     - "gpll2",
1302     - "gpll3",
1303     - "gpll1",
1304     - "gpll4",
1305     - "gpll0_early_div"
1306     -};
1307     -
1308     static struct clk_fixed_factor xo = {
1309     .mult = 1,
1310     .div = 1,
1311     diff --git a/drivers/clk/samsung/clk-exynos4.c b/drivers/clk/samsung/clk-exynos4.c
1312     index faab9b31baf5..91f9b79e3941 100644
1313     --- a/drivers/clk/samsung/clk-exynos4.c
1314     +++ b/drivers/clk/samsung/clk-exynos4.c
1315     @@ -1225,6 +1225,7 @@ static unsigned long __init exynos4_get_xom(void)
1316     xom = readl(chipid_base + 8);
1317    
1318     iounmap(chipid_base);
1319     + of_node_put(np);
1320     }
1321    
1322     return xom;
1323     diff --git a/drivers/clk/socfpga/clk-pll-a10.c b/drivers/clk/socfpga/clk-pll-a10.c
1324     index 35fabe1a32c3..269467e8e07e 100644
1325     --- a/drivers/clk/socfpga/clk-pll-a10.c
1326     +++ b/drivers/clk/socfpga/clk-pll-a10.c
1327     @@ -95,6 +95,7 @@ static struct clk * __init __socfpga_pll_init(struct device_node *node,
1328    
1329     clkmgr_np = of_find_compatible_node(NULL, NULL, "altr,clk-mgr");
1330     clk_mgr_a10_base_addr = of_iomap(clkmgr_np, 0);
1331     + of_node_put(clkmgr_np);
1332     BUG_ON(!clk_mgr_a10_base_addr);
1333     pll_clk->hw.reg = clk_mgr_a10_base_addr + reg;
1334    
1335     diff --git a/drivers/clk/socfpga/clk-pll.c b/drivers/clk/socfpga/clk-pll.c
1336     index c7f463172e4b..b4b44e9b5901 100644
1337     --- a/drivers/clk/socfpga/clk-pll.c
1338     +++ b/drivers/clk/socfpga/clk-pll.c
1339     @@ -100,6 +100,7 @@ static __init struct clk *__socfpga_pll_init(struct device_node *node,
1340    
1341     clkmgr_np = of_find_compatible_node(NULL, NULL, "altr,clk-mgr");
1342     clk_mgr_base_addr = of_iomap(clkmgr_np, 0);
1343     + of_node_put(clkmgr_np);
1344     BUG_ON(!clk_mgr_base_addr);
1345     pll_clk->hw.reg = clk_mgr_base_addr + reg;
1346    
1347     diff --git a/drivers/clk/sunxi-ng/ccu-sun8i-a23.c b/drivers/clk/sunxi-ng/ccu-sun8i-a23.c
1348     index 5c6d37bdf247..765c6977484e 100644
1349     --- a/drivers/clk/sunxi-ng/ccu-sun8i-a23.c
1350     +++ b/drivers/clk/sunxi-ng/ccu-sun8i-a23.c
1351     @@ -132,7 +132,7 @@ static SUNXI_CCU_NKM_WITH_GATE_LOCK(pll_mipi_clk, "pll-mipi",
1352     8, 4, /* N */
1353     4, 2, /* K */
1354     0, 4, /* M */
1355     - BIT(31), /* gate */
1356     + BIT(31) | BIT(23) | BIT(22), /* gate */
1357     BIT(28), /* lock */
1358     CLK_SET_RATE_UNGATE);
1359    
1360     diff --git a/drivers/clocksource/exynos_mct.c b/drivers/clocksource/exynos_mct.c
1361     index d32248e2ceab..ae3cbaeffd9c 100644
1362     --- a/drivers/clocksource/exynos_mct.c
1363     +++ b/drivers/clocksource/exynos_mct.c
1364     @@ -563,7 +563,19 @@ static int __init exynos4_timer_resources(struct device_node *np, void __iomem *
1365     return 0;
1366    
1367     out_irq:
1368     - free_percpu_irq(mct_irqs[MCT_L0_IRQ], &percpu_mct_tick);
1369     + if (mct_int_type == MCT_INT_PPI) {
1370     + free_percpu_irq(mct_irqs[MCT_L0_IRQ], &percpu_mct_tick);
1371     + } else {
1372     + for_each_possible_cpu(cpu) {
1373     + struct mct_clock_event_device *pcpu_mevt =
1374     + per_cpu_ptr(&percpu_mct_tick, cpu);
1375     +
1376     + if (pcpu_mevt->evt.irq != -1) {
1377     + free_irq(pcpu_mevt->evt.irq, pcpu_mevt);
1378     + pcpu_mevt->evt.irq = -1;
1379     + }
1380     + }
1381     + }
1382     return err;
1383     }
1384    
1385     diff --git a/drivers/clocksource/timer-sun5i.c b/drivers/clocksource/timer-sun5i.c
1386     index 4f87f3e76d83..c3e96de525a2 100644
1387     --- a/drivers/clocksource/timer-sun5i.c
1388     +++ b/drivers/clocksource/timer-sun5i.c
1389     @@ -201,6 +201,11 @@ static int __init sun5i_setup_clocksource(struct device_node *node,
1390     }
1391    
1392     rate = clk_get_rate(clk);
1393     + if (!rate) {
1394     + pr_err("Couldn't get parent clock rate\n");
1395     + ret = -EINVAL;
1396     + goto err_disable_clk;
1397     + }
1398    
1399     cs->timer.base = base;
1400     cs->timer.clk = clk;
1401     @@ -274,6 +279,11 @@ static int __init sun5i_setup_clockevent(struct device_node *node, void __iomem
1402     }
1403    
1404     rate = clk_get_rate(clk);
1405     + if (!rate) {
1406     + pr_err("Couldn't get parent clock rate\n");
1407     + ret = -EINVAL;
1408     + goto err_disable_clk;
1409     + }
1410    
1411     ce->timer.base = base;
1412     ce->timer.ticks_per_jiffy = DIV_ROUND_UP(rate, HZ);
1413     diff --git a/drivers/crypto/amcc/crypto4xx_trng.h b/drivers/crypto/amcc/crypto4xx_trng.h
1414     index 931d22531f51..7bbda51b7337 100644
1415     --- a/drivers/crypto/amcc/crypto4xx_trng.h
1416     +++ b/drivers/crypto/amcc/crypto4xx_trng.h
1417     @@ -26,9 +26,9 @@ void ppc4xx_trng_probe(struct crypto4xx_core_device *core_dev);
1418     void ppc4xx_trng_remove(struct crypto4xx_core_device *core_dev);
1419     #else
1420     static inline void ppc4xx_trng_probe(
1421     - struct crypto4xx_device *dev __maybe_unused) { }
1422     + struct crypto4xx_core_device *dev __maybe_unused) { }
1423     static inline void ppc4xx_trng_remove(
1424     - struct crypto4xx_device *dev __maybe_unused) { }
1425     + struct crypto4xx_core_device *dev __maybe_unused) { }
1426     #endif
1427    
1428     #endif
1429     diff --git a/drivers/crypto/caam/caamrng.c b/drivers/crypto/caam/caamrng.c
1430     index 9b92af2c7241..a77319bf221d 100644
1431     --- a/drivers/crypto/caam/caamrng.c
1432     +++ b/drivers/crypto/caam/caamrng.c
1433     @@ -361,7 +361,10 @@ static int __init caam_rng_init(void)
1434     goto free_rng_ctx;
1435    
1436     dev_info(dev, "registering rng-caam\n");
1437     - return hwrng_register(&caam_rng);
1438     +
1439     + err = hwrng_register(&caam_rng);
1440     + if (!err)
1441     + return err;
1442    
1443     free_rng_ctx:
1444     kfree(rng_ctx);
1445     diff --git a/drivers/crypto/ccp/ccp-crypto-aes.c b/drivers/crypto/ccp/ccp-crypto-aes.c
1446     index 89291c15015c..3f768699332b 100644
1447     --- a/drivers/crypto/ccp/ccp-crypto-aes.c
1448     +++ b/drivers/crypto/ccp/ccp-crypto-aes.c
1449     @@ -1,7 +1,8 @@
1450     +// SPDX-License-Identifier: GPL-2.0
1451     /*
1452     * AMD Cryptographic Coprocessor (CCP) AES crypto API support
1453     *
1454     - * Copyright (C) 2013,2016 Advanced Micro Devices, Inc.
1455     + * Copyright (C) 2013-2019 Advanced Micro Devices, Inc.
1456     *
1457     * Author: Tom Lendacky <thomas.lendacky@amd.com>
1458     *
1459     @@ -79,8 +80,7 @@ static int ccp_aes_crypt(struct ablkcipher_request *req, bool encrypt)
1460     return -EINVAL;
1461    
1462     if (((ctx->u.aes.mode == CCP_AES_MODE_ECB) ||
1463     - (ctx->u.aes.mode == CCP_AES_MODE_CBC) ||
1464     - (ctx->u.aes.mode == CCP_AES_MODE_CFB)) &&
1465     + (ctx->u.aes.mode == CCP_AES_MODE_CBC)) &&
1466     (req->nbytes & (AES_BLOCK_SIZE - 1)))
1467     return -EINVAL;
1468    
1469     @@ -291,7 +291,7 @@ static struct ccp_aes_def aes_algs[] = {
1470     .version = CCP_VERSION(3, 0),
1471     .name = "cfb(aes)",
1472     .driver_name = "cfb-aes-ccp",
1473     - .blocksize = AES_BLOCK_SIZE,
1474     + .blocksize = 1,
1475     .ivsize = AES_BLOCK_SIZE,
1476     .alg_defaults = &ccp_aes_defaults,
1477     },
1478     diff --git a/drivers/dma/dma-axi-dmac.c b/drivers/dma/dma-axi-dmac.c
1479     index 7f0b9aa15867..9887f2a14aa9 100644
1480     --- a/drivers/dma/dma-axi-dmac.c
1481     +++ b/drivers/dma/dma-axi-dmac.c
1482     @@ -451,7 +451,7 @@ static struct dma_async_tx_descriptor *axi_dmac_prep_interleaved(
1483    
1484     if (chan->hw_2d) {
1485     if (!axi_dmac_check_len(chan, xt->sgl[0].size) ||
1486     - !axi_dmac_check_len(chan, xt->numf))
1487     + xt->numf == 0)
1488     return NULL;
1489     if (xt->sgl[0].size + dst_icg > chan->max_length ||
1490     xt->sgl[0].size + src_icg > chan->max_length)
1491     diff --git a/drivers/dma/dw/platform.c b/drivers/dma/dw/platform.c
1492     index 5bda0eb9f393..7536fe80bc33 100644
1493     --- a/drivers/dma/dw/platform.c
1494     +++ b/drivers/dma/dw/platform.c
1495     @@ -87,13 +87,20 @@ static void dw_dma_acpi_controller_register(struct dw_dma *dw)
1496     dma_cap_set(DMA_SLAVE, info->dma_cap);
1497     info->filter_fn = dw_dma_acpi_filter;
1498    
1499     - ret = devm_acpi_dma_controller_register(dev, acpi_dma_simple_xlate,
1500     - info);
1501     + ret = acpi_dma_controller_register(dev, acpi_dma_simple_xlate, info);
1502     if (ret)
1503     dev_err(dev, "could not register acpi_dma_controller\n");
1504     }
1505     +
1506     +static void dw_dma_acpi_controller_free(struct dw_dma *dw)
1507     +{
1508     + struct device *dev = dw->dma.dev;
1509     +
1510     + acpi_dma_controller_free(dev);
1511     +}
1512     #else /* !CONFIG_ACPI */
1513     static inline void dw_dma_acpi_controller_register(struct dw_dma *dw) {}
1514     +static inline void dw_dma_acpi_controller_free(struct dw_dma *dw) {}
1515     #endif /* !CONFIG_ACPI */
1516    
1517     #ifdef CONFIG_OF
1518     @@ -226,6 +233,9 @@ static int dw_remove(struct platform_device *pdev)
1519     {
1520     struct dw_dma_chip *chip = platform_get_drvdata(pdev);
1521    
1522     + if (ACPI_HANDLE(&pdev->dev))
1523     + dw_dma_acpi_controller_free(chip->dw);
1524     +
1525     if (pdev->dev.of_node)
1526     of_dma_controller_free(pdev->dev.of_node);
1527    
1528     diff --git a/drivers/dma/edma.c b/drivers/dma/edma.c
1529     index 72f31e837b1d..56ec72468745 100644
1530     --- a/drivers/dma/edma.c
1531     +++ b/drivers/dma/edma.c
1532     @@ -2340,8 +2340,10 @@ static int edma_probe(struct platform_device *pdev)
1533    
1534     ecc->tc_list = devm_kcalloc(dev, ecc->num_tc,
1535     sizeof(*ecc->tc_list), GFP_KERNEL);
1536     - if (!ecc->tc_list)
1537     - return -ENOMEM;
1538     + if (!ecc->tc_list) {
1539     + ret = -ENOMEM;
1540     + goto err_reg1;
1541     + }
1542    
1543     for (i = 0;; i++) {
1544     ret = of_parse_phandle_with_fixed_args(node, "ti,tptcs",
1545     diff --git a/drivers/dma/hsu/hsu.c b/drivers/dma/hsu/hsu.c
1546     index 29d04ca71d52..15525a2b8ebd 100644
1547     --- a/drivers/dma/hsu/hsu.c
1548     +++ b/drivers/dma/hsu/hsu.c
1549     @@ -64,10 +64,10 @@ static void hsu_dma_chan_start(struct hsu_dma_chan *hsuc)
1550    
1551     if (hsuc->direction == DMA_MEM_TO_DEV) {
1552     bsr = config->dst_maxburst;
1553     - mtsr = config->src_addr_width;
1554     + mtsr = config->dst_addr_width;
1555     } else if (hsuc->direction == DMA_DEV_TO_MEM) {
1556     bsr = config->src_maxburst;
1557     - mtsr = config->dst_addr_width;
1558     + mtsr = config->src_addr_width;
1559     }
1560    
1561     hsu_chan_disable(hsuc);
1562     diff --git a/drivers/dma/imx-sdma.c b/drivers/dma/imx-sdma.c
1563     index 9f240b2d85a5..558d509b7d85 100644
1564     --- a/drivers/dma/imx-sdma.c
1565     +++ b/drivers/dma/imx-sdma.c
1566     @@ -1441,6 +1441,14 @@ static void sdma_add_scripts(struct sdma_engine *sdma,
1567     if (!sdma->script_number)
1568     sdma->script_number = SDMA_SCRIPT_ADDRS_ARRAY_SIZE_V1;
1569    
1570     + if (sdma->script_number > sizeof(struct sdma_script_start_addrs)
1571     + / sizeof(s32)) {
1572     + dev_err(sdma->dev,
1573     + "SDMA script number %d not match with firmware.\n",
1574     + sdma->script_number);
1575     + return;
1576     + }
1577     +
1578     for (i = 0; i < sdma->script_number; i++)
1579     if (addr_arr[i] > 0)
1580     saddr_arr[i] = addr_arr[i];
1581     diff --git a/drivers/dma/mv_xor.c b/drivers/dma/mv_xor.c
1582     index 23f75285a4d9..5d524f29c5f1 100644
1583     --- a/drivers/dma/mv_xor.c
1584     +++ b/drivers/dma/mv_xor.c
1585     @@ -1044,6 +1044,7 @@ mv_xor_channel_add(struct mv_xor_device *xordev,
1586     mv_chan->op_in_desc = XOR_MODE_IN_DESC;
1587    
1588     dma_dev = &mv_chan->dmadev;
1589     + dma_dev->dev = &pdev->dev;
1590     mv_chan->xordev = xordev;
1591    
1592     /*
1593     @@ -1076,7 +1077,6 @@ mv_xor_channel_add(struct mv_xor_device *xordev,
1594     dma_dev->device_free_chan_resources = mv_xor_free_chan_resources;
1595     dma_dev->device_tx_status = mv_xor_status;
1596     dma_dev->device_issue_pending = mv_xor_issue_pending;
1597     - dma_dev->dev = &pdev->dev;
1598    
1599     /* set prep routines based on capability */
1600     if (dma_has_cap(DMA_INTERRUPT, dma_dev->cap_mask))
1601     diff --git a/drivers/dma/tegra210-adma.c b/drivers/dma/tegra210-adma.c
1602     index e9e46a520745..2d4aeba579f7 100644
1603     --- a/drivers/dma/tegra210-adma.c
1604     +++ b/drivers/dma/tegra210-adma.c
1605     @@ -98,6 +98,7 @@ struct tegra_adma_chan_regs {
1606     unsigned int src_addr;
1607     unsigned int trg_addr;
1608     unsigned int fifo_ctrl;
1609     + unsigned int cmd;
1610     unsigned int tc;
1611     };
1612    
1613     @@ -127,6 +128,7 @@ struct tegra_adma_chan {
1614     enum dma_transfer_direction sreq_dir;
1615     unsigned int sreq_index;
1616     bool sreq_reserved;
1617     + struct tegra_adma_chan_regs ch_regs;
1618    
1619     /* Transfer count and position info */
1620     unsigned int tx_buf_count;
1621     @@ -635,8 +637,30 @@ static struct dma_chan *tegra_dma_of_xlate(struct of_phandle_args *dma_spec,
1622     static int tegra_adma_runtime_suspend(struct device *dev)
1623     {
1624     struct tegra_adma *tdma = dev_get_drvdata(dev);
1625     + struct tegra_adma_chan_regs *ch_reg;
1626     + struct tegra_adma_chan *tdc;
1627     + int i;
1628    
1629     tdma->global_cmd = tdma_read(tdma, ADMA_GLOBAL_CMD);
1630     + if (!tdma->global_cmd)
1631     + goto clk_disable;
1632     +
1633     + for (i = 0; i < tdma->nr_channels; i++) {
1634     + tdc = &tdma->channels[i];
1635     + ch_reg = &tdc->ch_regs;
1636     + ch_reg->cmd = tdma_ch_read(tdc, ADMA_CH_CMD);
1637     + /* skip if channel is not active */
1638     + if (!ch_reg->cmd)
1639     + continue;
1640     + ch_reg->tc = tdma_ch_read(tdc, ADMA_CH_TC);
1641     + ch_reg->src_addr = tdma_ch_read(tdc, ADMA_CH_LOWER_SRC_ADDR);
1642     + ch_reg->trg_addr = tdma_ch_read(tdc, ADMA_CH_LOWER_TRG_ADDR);
1643     + ch_reg->ctrl = tdma_ch_read(tdc, ADMA_CH_CTRL);
1644     + ch_reg->fifo_ctrl = tdma_ch_read(tdc, ADMA_CH_FIFO_CTRL);
1645     + ch_reg->config = tdma_ch_read(tdc, ADMA_CH_CONFIG);
1646     + }
1647     +
1648     +clk_disable:
1649     clk_disable_unprepare(tdma->ahub_clk);
1650    
1651     return 0;
1652     @@ -645,7 +669,9 @@ static int tegra_adma_runtime_suspend(struct device *dev)
1653     static int tegra_adma_runtime_resume(struct device *dev)
1654     {
1655     struct tegra_adma *tdma = dev_get_drvdata(dev);
1656     - int ret;
1657     + struct tegra_adma_chan_regs *ch_reg;
1658     + struct tegra_adma_chan *tdc;
1659     + int ret, i;
1660    
1661     ret = clk_prepare_enable(tdma->ahub_clk);
1662     if (ret) {
1663     @@ -654,6 +680,24 @@ static int tegra_adma_runtime_resume(struct device *dev)
1664     }
1665     tdma_write(tdma, ADMA_GLOBAL_CMD, tdma->global_cmd);
1666    
1667     + if (!tdma->global_cmd)
1668     + return 0;
1669     +
1670     + for (i = 0; i < tdma->nr_channels; i++) {
1671     + tdc = &tdma->channels[i];
1672     + ch_reg = &tdc->ch_regs;
1673     + /* skip if channel was not active earlier */
1674     + if (!ch_reg->cmd)
1675     + continue;
1676     + tdma_ch_write(tdc, ADMA_CH_TC, ch_reg->tc);
1677     + tdma_ch_write(tdc, ADMA_CH_LOWER_SRC_ADDR, ch_reg->src_addr);
1678     + tdma_ch_write(tdc, ADMA_CH_LOWER_TRG_ADDR, ch_reg->trg_addr);
1679     + tdma_ch_write(tdc, ADMA_CH_CTRL, ch_reg->ctrl);
1680     + tdma_ch_write(tdc, ADMA_CH_FIFO_CTRL, ch_reg->fifo_ctrl);
1681     + tdma_ch_write(tdc, ADMA_CH_CONFIG, ch_reg->config);
1682     + tdma_ch_write(tdc, ADMA_CH_CMD, ch_reg->cmd);
1683     + }
1684     +
1685     return 0;
1686     }
1687    
1688     @@ -700,16 +744,6 @@ static int tegra_adma_probe(struct platform_device *pdev)
1689     return PTR_ERR(tdma->ahub_clk);
1690     }
1691    
1692     - pm_runtime_enable(&pdev->dev);
1693     -
1694     - ret = pm_runtime_get_sync(&pdev->dev);
1695     - if (ret < 0)
1696     - goto rpm_disable;
1697     -
1698     - ret = tegra_adma_init(tdma);
1699     - if (ret)
1700     - goto rpm_put;
1701     -
1702     INIT_LIST_HEAD(&tdma->dma_dev.channels);
1703     for (i = 0; i < tdma->nr_channels; i++) {
1704     struct tegra_adma_chan *tdc = &tdma->channels[i];
1705     @@ -727,6 +761,16 @@ static int tegra_adma_probe(struct platform_device *pdev)
1706     tdc->tdma = tdma;
1707     }
1708    
1709     + pm_runtime_enable(&pdev->dev);
1710     +
1711     + ret = pm_runtime_get_sync(&pdev->dev);
1712     + if (ret < 0)
1713     + goto rpm_disable;
1714     +
1715     + ret = tegra_adma_init(tdma);
1716     + if (ret)
1717     + goto rpm_put;
1718     +
1719     dma_cap_set(DMA_SLAVE, tdma->dma_dev.cap_mask);
1720     dma_cap_set(DMA_PRIVATE, tdma->dma_dev.cap_mask);
1721     dma_cap_set(DMA_CYCLIC, tdma->dma_dev.cap_mask);
1722     @@ -768,13 +812,13 @@ static int tegra_adma_probe(struct platform_device *pdev)
1723    
1724     dma_remove:
1725     dma_async_device_unregister(&tdma->dma_dev);
1726     -irq_dispose:
1727     - while (--i >= 0)
1728     - irq_dispose_mapping(tdma->channels[i].irq);
1729     rpm_put:
1730     pm_runtime_put_sync(&pdev->dev);
1731     rpm_disable:
1732     pm_runtime_disable(&pdev->dev);
1733     +irq_dispose:
1734     + while (--i >= 0)
1735     + irq_dispose_mapping(tdma->channels[i].irq);
1736    
1737     return ret;
1738     }
1739     diff --git a/drivers/gpu/drm/drm_dp_mst_topology.c b/drivers/gpu/drm/drm_dp_mst_topology.c
1740     index e05dda92398c..17aedaaf364c 100644
1741     --- a/drivers/gpu/drm/drm_dp_mst_topology.c
1742     +++ b/drivers/gpu/drm/drm_dp_mst_topology.c
1743     @@ -980,9 +980,20 @@ static struct drm_dp_mst_port *drm_dp_mst_get_port_ref_locked(struct drm_dp_mst_
1744     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)
1745     {
1746     struct drm_dp_mst_port *rport = NULL;
1747     +
1748     mutex_lock(&mgr->lock);
1749     - if (mgr->mst_primary)
1750     - rport = drm_dp_mst_get_port_ref_locked(mgr->mst_primary, port);
1751     + /*
1752     + * Port may or may not be 'valid' but we don't care about that when
1753     + * destroying the port and we are guaranteed that the port pointer
1754     + * will be valid until we've finished
1755     + */
1756     + if (current_work() == &mgr->destroy_connector_work) {
1757     + kref_get(&port->kref);
1758     + rport = port;
1759     + } else if (mgr->mst_primary) {
1760     + rport = drm_dp_mst_get_port_ref_locked(mgr->mst_primary,
1761     + port);
1762     + }
1763     mutex_unlock(&mgr->lock);
1764     return rport;
1765     }
1766     diff --git a/drivers/gpu/drm/etnaviv/etnaviv_dump.c b/drivers/gpu/drm/etnaviv/etnaviv_dump.c
1767     index 2bef501d4a17..5af7c2594a79 100644
1768     --- a/drivers/gpu/drm/etnaviv/etnaviv_dump.c
1769     +++ b/drivers/gpu/drm/etnaviv/etnaviv_dump.c
1770     @@ -206,7 +206,7 @@ void etnaviv_core_dump(struct etnaviv_gpu *gpu)
1771     mutex_lock(&obj->lock);
1772     pages = etnaviv_gem_get_pages(obj);
1773     mutex_unlock(&obj->lock);
1774     - if (pages) {
1775     + if (!IS_ERR(pages)) {
1776     int j;
1777    
1778     iter.hdr->data[0] = bomap - bomap_start;
1779     diff --git a/drivers/gpu/drm/msm/adreno/a3xx_gpu.c b/drivers/gpu/drm/msm/adreno/a3xx_gpu.c
1780     index fd266ed963b6..25a0e7d13340 100644
1781     --- a/drivers/gpu/drm/msm/adreno/a3xx_gpu.c
1782     +++ b/drivers/gpu/drm/msm/adreno/a3xx_gpu.c
1783     @@ -383,19 +383,17 @@ static const unsigned int a3xx_registers[] = {
1784     0x2200, 0x2212, 0x2214, 0x2217, 0x221a, 0x221a, 0x2240, 0x227e,
1785     0x2280, 0x228b, 0x22c0, 0x22c0, 0x22c4, 0x22ce, 0x22d0, 0x22d8,
1786     0x22df, 0x22e6, 0x22e8, 0x22e9, 0x22ec, 0x22ec, 0x22f0, 0x22f7,
1787     - 0x22ff, 0x22ff, 0x2340, 0x2343, 0x2348, 0x2349, 0x2350, 0x2356,
1788     - 0x2360, 0x2360, 0x2440, 0x2440, 0x2444, 0x2444, 0x2448, 0x244d,
1789     - 0x2468, 0x2469, 0x246c, 0x246d, 0x2470, 0x2470, 0x2472, 0x2472,
1790     - 0x2474, 0x2475, 0x2479, 0x247a, 0x24c0, 0x24d3, 0x24e4, 0x24ef,
1791     - 0x2500, 0x2509, 0x250c, 0x250c, 0x250e, 0x250e, 0x2510, 0x2511,
1792     - 0x2514, 0x2515, 0x25e4, 0x25e4, 0x25ea, 0x25ea, 0x25ec, 0x25ed,
1793     - 0x25f0, 0x25f0, 0x2600, 0x2612, 0x2614, 0x2617, 0x261a, 0x261a,
1794     - 0x2640, 0x267e, 0x2680, 0x268b, 0x26c0, 0x26c0, 0x26c4, 0x26ce,
1795     - 0x26d0, 0x26d8, 0x26df, 0x26e6, 0x26e8, 0x26e9, 0x26ec, 0x26ec,
1796     - 0x26f0, 0x26f7, 0x26ff, 0x26ff, 0x2740, 0x2743, 0x2748, 0x2749,
1797     - 0x2750, 0x2756, 0x2760, 0x2760, 0x300c, 0x300e, 0x301c, 0x301d,
1798     - 0x302a, 0x302a, 0x302c, 0x302d, 0x3030, 0x3031, 0x3034, 0x3036,
1799     - 0x303c, 0x303c, 0x305e, 0x305f,
1800     + 0x22ff, 0x22ff, 0x2340, 0x2343, 0x2440, 0x2440, 0x2444, 0x2444,
1801     + 0x2448, 0x244d, 0x2468, 0x2469, 0x246c, 0x246d, 0x2470, 0x2470,
1802     + 0x2472, 0x2472, 0x2474, 0x2475, 0x2479, 0x247a, 0x24c0, 0x24d3,
1803     + 0x24e4, 0x24ef, 0x2500, 0x2509, 0x250c, 0x250c, 0x250e, 0x250e,
1804     + 0x2510, 0x2511, 0x2514, 0x2515, 0x25e4, 0x25e4, 0x25ea, 0x25ea,
1805     + 0x25ec, 0x25ed, 0x25f0, 0x25f0, 0x2600, 0x2612, 0x2614, 0x2617,
1806     + 0x261a, 0x261a, 0x2640, 0x267e, 0x2680, 0x268b, 0x26c0, 0x26c0,
1807     + 0x26c4, 0x26ce, 0x26d0, 0x26d8, 0x26df, 0x26e6, 0x26e8, 0x26e9,
1808     + 0x26ec, 0x26ec, 0x26f0, 0x26f7, 0x26ff, 0x26ff, 0x2740, 0x2743,
1809     + 0x300c, 0x300e, 0x301c, 0x301d, 0x302a, 0x302a, 0x302c, 0x302d,
1810     + 0x3030, 0x3031, 0x3034, 0x3036, 0x303c, 0x303c, 0x305e, 0x305f,
1811     ~0 /* sentinel */
1812     };
1813    
1814     diff --git a/drivers/gpu/drm/msm/dsi/dsi_host.c b/drivers/gpu/drm/msm/dsi/dsi_host.c
1815     index 6f240021705b..e49b414c012c 100644
1816     --- a/drivers/gpu/drm/msm/dsi/dsi_host.c
1817     +++ b/drivers/gpu/drm/msm/dsi/dsi_host.c
1818     @@ -33,6 +33,8 @@
1819     #include "sfpb.xml.h"
1820     #include "dsi_cfg.h"
1821    
1822     +#define DSI_RESET_TOGGLE_DELAY_MS 20
1823     +
1824     static int dsi_get_version(const void __iomem *base, u32 *major, u32 *minor)
1825     {
1826     u32 ver;
1827     @@ -909,7 +911,7 @@ static void dsi_sw_reset(struct msm_dsi_host *msm_host)
1828     wmb(); /* clocks need to be enabled before reset */
1829    
1830     dsi_write(msm_host, REG_DSI_RESET, 1);
1831     - wmb(); /* make sure reset happen */
1832     + msleep(DSI_RESET_TOGGLE_DELAY_MS); /* make sure reset happen */
1833     dsi_write(msm_host, REG_DSI_RESET, 0);
1834     }
1835    
1836     @@ -1288,7 +1290,7 @@ static void dsi_sw_reset_restore(struct msm_dsi_host *msm_host)
1837    
1838     /* dsi controller can only be reset while clocks are running */
1839     dsi_write(msm_host, REG_DSI_RESET, 1);
1840     - wmb(); /* make sure reset happen */
1841     + msleep(DSI_RESET_TOGGLE_DELAY_MS); /* make sure reset happen */
1842     dsi_write(msm_host, REG_DSI_RESET, 0);
1843     wmb(); /* controller out of reset */
1844     dsi_write(msm_host, REG_DSI_CTRL, data0);
1845     diff --git a/drivers/gpu/drm/msm/mdp/mdp5/mdp5_cfg.c b/drivers/gpu/drm/msm/mdp/mdp5/mdp5_cfg.c
1846     index 8b4e3004f451..86b0448d2ce5 100644
1847     --- a/drivers/gpu/drm/msm/mdp/mdp5/mdp5_cfg.c
1848     +++ b/drivers/gpu/drm/msm/mdp/mdp5/mdp5_cfg.c
1849     @@ -542,7 +542,7 @@ fail:
1850     if (cfg_handler)
1851     mdp5_cfg_destroy(cfg_handler);
1852    
1853     - return NULL;
1854     + return ERR_PTR(ret);
1855     }
1856    
1857     static struct mdp5_cfg_platform *mdp5_get_config(struct platform_device *dev)
1858     diff --git a/drivers/gpu/drm/nouveau/nvkm/subdev/fb/gddr3.c b/drivers/gpu/drm/nouveau/nvkm/subdev/fb/gddr3.c
1859     index 60ece0a8a2e1..1d2d6bae73cd 100644
1860     --- a/drivers/gpu/drm/nouveau/nvkm/subdev/fb/gddr3.c
1861     +++ b/drivers/gpu/drm/nouveau/nvkm/subdev/fb/gddr3.c
1862     @@ -87,7 +87,7 @@ nvkm_gddr3_calc(struct nvkm_ram *ram)
1863     WR = (ram->next->bios.timing[2] & 0x007f0000) >> 16;
1864     /* XXX: Get these values from the VBIOS instead */
1865     DLL = !(ram->mr[1] & 0x1);
1866     - RON = !(ram->mr[1] & 0x300) >> 8;
1867     + RON = !((ram->mr[1] & 0x300) >> 8);
1868     break;
1869     default:
1870     return -ENOSYS;
1871     diff --git a/drivers/gpu/drm/nouveau/nvkm/subdev/pmu/memx.c b/drivers/gpu/drm/nouveau/nvkm/subdev/pmu/memx.c
1872     index e6f74168238c..2ef9e942f43a 100644
1873     --- a/drivers/gpu/drm/nouveau/nvkm/subdev/pmu/memx.c
1874     +++ b/drivers/gpu/drm/nouveau/nvkm/subdev/pmu/memx.c
1875     @@ -87,10 +87,10 @@ nvkm_memx_fini(struct nvkm_memx **pmemx, bool exec)
1876     if (exec) {
1877     nvkm_pmu_send(pmu, reply, PROC_MEMX, MEMX_MSG_EXEC,
1878     memx->base, finish);
1879     + nvkm_debug(subdev, "Exec took %uns, PMU_IN %08x\n",
1880     + reply[0], reply[1]);
1881     }
1882    
1883     - nvkm_debug(subdev, "Exec took %uns, PMU_IN %08x\n",
1884     - reply[0], reply[1]);
1885     kfree(memx);
1886     return 0;
1887     }
1888     diff --git a/drivers/gpu/drm/radeon/cik.c b/drivers/gpu/drm/radeon/cik.c
1889     index b99f3e59011c..5fcb5869a489 100644
1890     --- a/drivers/gpu/drm/radeon/cik.c
1891     +++ b/drivers/gpu/drm/radeon/cik.c
1892     @@ -7026,8 +7026,8 @@ static int cik_irq_init(struct radeon_device *rdev)
1893     }
1894    
1895     /* setup interrupt control */
1896     - /* XXX this should actually be a bus address, not an MC address. same on older asics */
1897     - WREG32(INTERRUPT_CNTL2, rdev->ih.gpu_addr >> 8);
1898     + /* set dummy read address to dummy page address */
1899     + WREG32(INTERRUPT_CNTL2, rdev->dummy_page.addr >> 8);
1900     interrupt_cntl = RREG32(INTERRUPT_CNTL);
1901     /* IH_DUMMY_RD_OVERRIDE=0 - dummy read disabled with msi, enabled without msi
1902     * IH_DUMMY_RD_OVERRIDE=1 - dummy read controlled by IH_DUMMY_RD_EN
1903     diff --git a/drivers/gpu/drm/radeon/r600.c b/drivers/gpu/drm/radeon/r600.c
1904     index f2eac6b6c46a..9569c35f8766 100644
1905     --- a/drivers/gpu/drm/radeon/r600.c
1906     +++ b/drivers/gpu/drm/radeon/r600.c
1907     @@ -3697,8 +3697,8 @@ int r600_irq_init(struct radeon_device *rdev)
1908     }
1909    
1910     /* setup interrupt control */
1911     - /* set dummy read address to ring address */
1912     - WREG32(INTERRUPT_CNTL2, rdev->ih.gpu_addr >> 8);
1913     + /* set dummy read address to dummy page address */
1914     + WREG32(INTERRUPT_CNTL2, rdev->dummy_page.addr >> 8);
1915     interrupt_cntl = RREG32(INTERRUPT_CNTL);
1916     /* IH_DUMMY_RD_OVERRIDE=0 - dummy read disabled with msi, enabled without msi
1917     * IH_DUMMY_RD_OVERRIDE=1 - dummy read controlled by IH_DUMMY_RD_EN
1918     diff --git a/drivers/gpu/drm/radeon/si.c b/drivers/gpu/drm/radeon/si.c
1919     index b75d809c292e..919d389869ce 100644
1920     --- a/drivers/gpu/drm/radeon/si.c
1921     +++ b/drivers/gpu/drm/radeon/si.c
1922     @@ -6018,8 +6018,8 @@ static int si_irq_init(struct radeon_device *rdev)
1923     }
1924    
1925     /* setup interrupt control */
1926     - /* set dummy read address to ring address */
1927     - WREG32(INTERRUPT_CNTL2, rdev->ih.gpu_addr >> 8);
1928     + /* set dummy read address to dummy page address */
1929     + WREG32(INTERRUPT_CNTL2, rdev->dummy_page.addr >> 8);
1930     interrupt_cntl = RREG32(INTERRUPT_CNTL);
1931     /* IH_DUMMY_RD_OVERRIDE=0 - dummy read disabled with msi, enabled without msi
1932     * IH_DUMMY_RD_OVERRIDE=1 - dummy read controlled by IH_DUMMY_RD_EN
1933     diff --git a/drivers/gpu/drm/sti/sti_hda.c b/drivers/gpu/drm/sti/sti_hda.c
1934     index e7c243f70870..08808e3701de 100644
1935     --- a/drivers/gpu/drm/sti/sti_hda.c
1936     +++ b/drivers/gpu/drm/sti/sti_hda.c
1937     @@ -740,7 +740,6 @@ static int sti_hda_bind(struct device *dev, struct device *master, void *data)
1938     return 0;
1939    
1940     err_sysfs:
1941     - drm_bridge_remove(bridge);
1942     return -EINVAL;
1943     }
1944    
1945     diff --git a/drivers/gpu/drm/sti/sti_hdmi.c b/drivers/gpu/drm/sti/sti_hdmi.c
1946     index 376b0763c874..a5412a6fbeca 100644
1947     --- a/drivers/gpu/drm/sti/sti_hdmi.c
1948     +++ b/drivers/gpu/drm/sti/sti_hdmi.c
1949     @@ -1352,7 +1352,6 @@ static int sti_hdmi_bind(struct device *dev, struct device *master, void *data)
1950     return 0;
1951    
1952     err_sysfs:
1953     - drm_bridge_remove(bridge);
1954     hdmi->drm_connector = NULL;
1955     return -EINVAL;
1956     }
1957     diff --git a/drivers/gpu/drm/virtio/virtgpu_vq.c b/drivers/gpu/drm/virtio/virtgpu_vq.c
1958     index a1b3ea1ccb65..772a5a3b0ce1 100644
1959     --- a/drivers/gpu/drm/virtio/virtgpu_vq.c
1960     +++ b/drivers/gpu/drm/virtio/virtgpu_vq.c
1961     @@ -681,11 +681,11 @@ int virtio_gpu_cmd_get_capset(struct virtio_gpu_device *vgdev,
1962     {
1963     struct virtio_gpu_get_capset *cmd_p;
1964     struct virtio_gpu_vbuffer *vbuf;
1965     - int max_size = vgdev->capsets[idx].max_size;
1966     + int max_size;
1967     struct virtio_gpu_drv_cap_cache *cache_ent;
1968     void *resp_buf;
1969    
1970     - if (idx > vgdev->num_capsets)
1971     + if (idx >= vgdev->num_capsets)
1972     return -EINVAL;
1973    
1974     if (version > vgdev->capsets[idx].max_version)
1975     @@ -695,6 +695,7 @@ int virtio_gpu_cmd_get_capset(struct virtio_gpu_device *vgdev,
1976     if (!cache_ent)
1977     return -ENOMEM;
1978    
1979     + max_size = vgdev->capsets[idx].max_size;
1980     cache_ent->caps_cache = kmalloc(max_size, GFP_KERNEL);
1981     if (!cache_ent->caps_cache) {
1982     kfree(cache_ent);
1983     diff --git a/drivers/hwmon/adt7475.c b/drivers/hwmon/adt7475.c
1984     index 9c262d955331..d2583caa8087 100644
1985     --- a/drivers/hwmon/adt7475.c
1986     +++ b/drivers/hwmon/adt7475.c
1987     @@ -268,9 +268,10 @@ static inline u16 volt2reg(int channel, long volt, u8 bypass_attn)
1988     long reg;
1989    
1990     if (bypass_attn & (1 << channel))
1991     - reg = (volt * 1024) / 2250;
1992     + reg = DIV_ROUND_CLOSEST(volt * 1024, 2250);
1993     else
1994     - reg = (volt * r[1] * 1024) / ((r[0] + r[1]) * 2250);
1995     + reg = DIV_ROUND_CLOSEST(volt * r[1] * 1024,
1996     + (r[0] + r[1]) * 2250);
1997     return clamp_val(reg, 0, 1023) & (0xff << 2);
1998     }
1999    
2000     diff --git a/drivers/hwmon/hwmon.c b/drivers/hwmon/hwmon.c
2001     index a74c075a30ec..e0a1a118514f 100644
2002     --- a/drivers/hwmon/hwmon.c
2003     +++ b/drivers/hwmon/hwmon.c
2004     @@ -38,16 +38,20 @@ struct hwmon_device {
2005    
2006     #define to_hwmon_device(d) container_of(d, struct hwmon_device, dev)
2007    
2008     +#define MAX_SYSFS_ATTR_NAME_LENGTH 32
2009     +
2010     struct hwmon_device_attribute {
2011     struct device_attribute dev_attr;
2012     const struct hwmon_ops *ops;
2013     enum hwmon_sensor_types type;
2014     u32 attr;
2015     int index;
2016     + char name[MAX_SYSFS_ATTR_NAME_LENGTH];
2017     };
2018    
2019     #define to_hwmon_attr(d) \
2020     container_of(d, struct hwmon_device_attribute, dev_attr)
2021     +#define to_dev_attr(a) container_of(a, struct device_attribute, attr)
2022    
2023     /*
2024     * Thermal zone information
2025     @@ -55,7 +59,7 @@ struct hwmon_device_attribute {
2026     * also provides the sensor index.
2027     */
2028     struct hwmon_thermal_data {
2029     - struct hwmon_device *hwdev; /* Reference to hwmon device */
2030     + struct device *dev; /* Reference to hwmon device */
2031     int index; /* sensor index */
2032     };
2033    
2034     @@ -92,9 +96,27 @@ static const struct attribute_group *hwmon_dev_attr_groups[] = {
2035     NULL
2036     };
2037    
2038     +static void hwmon_free_attrs(struct attribute **attrs)
2039     +{
2040     + int i;
2041     +
2042     + for (i = 0; attrs[i]; i++) {
2043     + struct device_attribute *dattr = to_dev_attr(attrs[i]);
2044     + struct hwmon_device_attribute *hattr = to_hwmon_attr(dattr);
2045     +
2046     + kfree(hattr);
2047     + }
2048     + kfree(attrs);
2049     +}
2050     +
2051     static void hwmon_dev_release(struct device *dev)
2052     {
2053     - kfree(to_hwmon_device(dev));
2054     + struct hwmon_device *hwdev = to_hwmon_device(dev);
2055     +
2056     + if (hwdev->group.attrs)
2057     + hwmon_free_attrs(hwdev->group.attrs);
2058     + kfree(hwdev->groups);
2059     + kfree(hwdev);
2060     }
2061    
2062     static struct class hwmon_class = {
2063     @@ -118,11 +140,11 @@ static DEFINE_IDA(hwmon_ida);
2064     static int hwmon_thermal_get_temp(void *data, int *temp)
2065     {
2066     struct hwmon_thermal_data *tdata = data;
2067     - struct hwmon_device *hwdev = tdata->hwdev;
2068     + struct hwmon_device *hwdev = to_hwmon_device(tdata->dev);
2069     int ret;
2070     long t;
2071    
2072     - ret = hwdev->chip->ops->read(&hwdev->dev, hwmon_temp, hwmon_temp_input,
2073     + ret = hwdev->chip->ops->read(tdata->dev, hwmon_temp, hwmon_temp_input,
2074     tdata->index, &t);
2075     if (ret < 0)
2076     return ret;
2077     @@ -136,26 +158,31 @@ static struct thermal_zone_of_device_ops hwmon_thermal_ops = {
2078     .get_temp = hwmon_thermal_get_temp,
2079     };
2080    
2081     -static int hwmon_thermal_add_sensor(struct device *dev,
2082     - struct hwmon_device *hwdev, int index)
2083     +static int hwmon_thermal_add_sensor(struct device *dev, int index)
2084     {
2085     struct hwmon_thermal_data *tdata;
2086     + struct thermal_zone_device *tzd;
2087    
2088     tdata = devm_kzalloc(dev, sizeof(*tdata), GFP_KERNEL);
2089     if (!tdata)
2090     return -ENOMEM;
2091    
2092     - tdata->hwdev = hwdev;
2093     + tdata->dev = dev;
2094     tdata->index = index;
2095    
2096     - devm_thermal_zone_of_sensor_register(&hwdev->dev, index, tdata,
2097     - &hwmon_thermal_ops);
2098     + tzd = devm_thermal_zone_of_sensor_register(dev, index, tdata,
2099     + &hwmon_thermal_ops);
2100     + /*
2101     + * If CONFIG_THERMAL_OF is disabled, this returns -ENODEV,
2102     + * so ignore that error but forward any other error.
2103     + */
2104     + if (IS_ERR(tzd) && (PTR_ERR(tzd) != -ENODEV))
2105     + return PTR_ERR(tzd);
2106    
2107     return 0;
2108     }
2109     #else
2110     -static int hwmon_thermal_add_sensor(struct device *dev,
2111     - struct hwmon_device *hwdev, int index)
2112     +static int hwmon_thermal_add_sensor(struct device *dev, int index)
2113     {
2114     return 0;
2115     }
2116     @@ -205,8 +232,7 @@ static int hwmon_attr_base(enum hwmon_sensor_types type)
2117     return 1;
2118     }
2119    
2120     -static struct attribute *hwmon_genattr(struct device *dev,
2121     - const void *drvdata,
2122     +static struct attribute *hwmon_genattr(const void *drvdata,
2123     enum hwmon_sensor_types type,
2124     u32 attr,
2125     int index,
2126     @@ -232,20 +258,18 @@ static struct attribute *hwmon_genattr(struct device *dev,
2127     if ((mode & S_IWUGO) && !ops->write)
2128     return ERR_PTR(-EINVAL);
2129    
2130     + hattr = kzalloc(sizeof(*hattr), GFP_KERNEL);
2131     + if (!hattr)
2132     + return ERR_PTR(-ENOMEM);
2133     +
2134     if (type == hwmon_chip) {
2135     name = (char *)template;
2136     } else {
2137     - name = devm_kzalloc(dev, strlen(template) + 16, GFP_KERNEL);
2138     - if (!name)
2139     - return ERR_PTR(-ENOMEM);
2140     - scnprintf(name, strlen(template) + 16, template,
2141     + scnprintf(hattr->name, sizeof(hattr->name), template,
2142     index + hwmon_attr_base(type));
2143     + name = hattr->name;
2144     }
2145    
2146     - hattr = devm_kzalloc(dev, sizeof(*hattr), GFP_KERNEL);
2147     - if (!hattr)
2148     - return ERR_PTR(-ENOMEM);
2149     -
2150     hattr->type = type;
2151     hattr->attr = attr;
2152     hattr->index = index;
2153     @@ -433,8 +457,7 @@ static int hwmon_num_channel_attrs(const struct hwmon_channel_info *info)
2154     return n;
2155     }
2156    
2157     -static int hwmon_genattrs(struct device *dev,
2158     - const void *drvdata,
2159     +static int hwmon_genattrs(const void *drvdata,
2160     struct attribute **attrs,
2161     const struct hwmon_ops *ops,
2162     const struct hwmon_channel_info *info)
2163     @@ -460,7 +483,7 @@ static int hwmon_genattrs(struct device *dev,
2164     attr_mask &= ~BIT(attr);
2165     if (attr >= template_size)
2166     return -EINVAL;
2167     - a = hwmon_genattr(dev, drvdata, info->type, attr, i,
2168     + a = hwmon_genattr(drvdata, info->type, attr, i,
2169     templates[attr], ops);
2170     if (IS_ERR(a)) {
2171     if (PTR_ERR(a) != -ENOENT)
2172     @@ -474,8 +497,7 @@ static int hwmon_genattrs(struct device *dev,
2173     }
2174    
2175     static struct attribute **
2176     -__hwmon_create_attrs(struct device *dev, const void *drvdata,
2177     - const struct hwmon_chip_info *chip)
2178     +__hwmon_create_attrs(const void *drvdata, const struct hwmon_chip_info *chip)
2179     {
2180     int ret, i, aindex = 0, nattrs = 0;
2181     struct attribute **attrs;
2182     @@ -486,15 +508,17 @@ __hwmon_create_attrs(struct device *dev, const void *drvdata,
2183     if (nattrs == 0)
2184     return ERR_PTR(-EINVAL);
2185    
2186     - attrs = devm_kcalloc(dev, nattrs + 1, sizeof(*attrs), GFP_KERNEL);
2187     + attrs = kcalloc(nattrs + 1, sizeof(*attrs), GFP_KERNEL);
2188     if (!attrs)
2189     return ERR_PTR(-ENOMEM);
2190    
2191     for (i = 0; chip->info[i]; i++) {
2192     - ret = hwmon_genattrs(dev, drvdata, &attrs[aindex], chip->ops,
2193     + ret = hwmon_genattrs(drvdata, &attrs[aindex], chip->ops,
2194     chip->info[i]);
2195     - if (ret < 0)
2196     + if (ret < 0) {
2197     + hwmon_free_attrs(attrs);
2198     return ERR_PTR(ret);
2199     + }
2200     aindex += ret;
2201     }
2202    
2203     @@ -534,14 +558,13 @@ __hwmon_device_register(struct device *dev, const char *name, void *drvdata,
2204     for (i = 0; groups[i]; i++)
2205     ngroups++;
2206    
2207     - hwdev->groups = devm_kcalloc(dev, ngroups, sizeof(*groups),
2208     - GFP_KERNEL);
2209     + hwdev->groups = kcalloc(ngroups, sizeof(*groups), GFP_KERNEL);
2210     if (!hwdev->groups) {
2211     err = -ENOMEM;
2212     goto free_hwmon;
2213     }
2214    
2215     - attrs = __hwmon_create_attrs(dev, drvdata, chip);
2216     + attrs = __hwmon_create_attrs(drvdata, chip);
2217     if (IS_ERR(attrs)) {
2218     err = PTR_ERR(attrs);
2219     goto free_hwmon;
2220     @@ -585,8 +608,13 @@ __hwmon_device_register(struct device *dev, const char *name, void *drvdata,
2221     if (!chip->ops->is_visible(drvdata, hwmon_temp,
2222     hwmon_temp_input, j))
2223     continue;
2224     - if (info[i]->config[j] & HWMON_T_INPUT)
2225     - hwmon_thermal_add_sensor(dev, hwdev, j);
2226     + if (info[i]->config[j] & HWMON_T_INPUT) {
2227     + err = hwmon_thermal_add_sensor(hdev, j);
2228     + if (err) {
2229     + device_unregister(hdev);
2230     + goto ida_remove;
2231     + }
2232     + }
2233     }
2234     }
2235     }
2236     @@ -594,7 +622,7 @@ __hwmon_device_register(struct device *dev, const char *name, void *drvdata,
2237     return hdev;
2238    
2239     free_hwmon:
2240     - kfree(hwdev);
2241     + hwmon_dev_release(hdev);
2242     ida_remove:
2243     ida_simple_remove(&hwmon_ida, id);
2244     return ERR_PTR(err);
2245     diff --git a/drivers/hwmon/lm75.c b/drivers/hwmon/lm75.c
2246     index eff3b24d8473..fc31669a86ba 100644
2247     --- a/drivers/hwmon/lm75.c
2248     +++ b/drivers/hwmon/lm75.c
2249     @@ -164,7 +164,7 @@ static int lm75_write(struct device *dev, enum hwmon_sensor_types type,
2250     temp = DIV_ROUND_CLOSEST(temp << (resolution - 8),
2251     1000) << (16 - resolution);
2252    
2253     - return regmap_write(data->regmap, reg, temp);
2254     + return regmap_write(data->regmap, reg, (u16)temp);
2255     }
2256    
2257     static umode_t lm75_is_visible(const void *data, enum hwmon_sensor_types type,
2258     diff --git a/drivers/hwmon/nct7802.c b/drivers/hwmon/nct7802.c
2259     index 7f8738a83cb9..40addb213bdf 100644
2260     --- a/drivers/hwmon/nct7802.c
2261     +++ b/drivers/hwmon/nct7802.c
2262     @@ -32,8 +32,8 @@
2263     static const u8 REG_VOLTAGE[5] = { 0x09, 0x0a, 0x0c, 0x0d, 0x0e };
2264    
2265     static const u8 REG_VOLTAGE_LIMIT_LSB[2][5] = {
2266     - { 0x40, 0x00, 0x42, 0x44, 0x46 },
2267     - { 0x3f, 0x00, 0x41, 0x43, 0x45 },
2268     + { 0x46, 0x00, 0x40, 0x42, 0x44 },
2269     + { 0x45, 0x00, 0x3f, 0x41, 0x43 },
2270     };
2271    
2272     static const u8 REG_VOLTAGE_LIMIT_MSB[5] = { 0x48, 0x00, 0x47, 0x47, 0x48 };
2273     diff --git a/drivers/hwmon/shtc1.c b/drivers/hwmon/shtc1.c
2274     index decd7df995ab..2a18539591ea 100644
2275     --- a/drivers/hwmon/shtc1.c
2276     +++ b/drivers/hwmon/shtc1.c
2277     @@ -38,7 +38,7 @@ static const unsigned char shtc1_cmd_read_id_reg[] = { 0xef, 0xc8 };
2278    
2279     /* constants for reading the ID register */
2280     #define SHTC1_ID 0x07
2281     -#define SHTC1_ID_REG_MASK 0x1f
2282     +#define SHTC1_ID_REG_MASK 0x3f
2283    
2284     /* delays for non-blocking i2c commands, both in us */
2285     #define SHTC1_NONBLOCKING_WAIT_TIME_HPM 14400
2286     diff --git a/drivers/hwmon/w83627hf.c b/drivers/hwmon/w83627hf.c
2287     index 721295b9a051..43c0f89cefdf 100644
2288     --- a/drivers/hwmon/w83627hf.c
2289     +++ b/drivers/hwmon/w83627hf.c
2290     @@ -130,17 +130,23 @@ superio_select(struct w83627hf_sio_data *sio, int ld)
2291     outb(ld, sio->sioaddr + 1);
2292     }
2293    
2294     -static inline void
2295     +static inline int
2296     superio_enter(struct w83627hf_sio_data *sio)
2297     {
2298     + if (!request_muxed_region(sio->sioaddr, 2, DRVNAME))
2299     + return -EBUSY;
2300     +
2301     outb(0x87, sio->sioaddr);
2302     outb(0x87, sio->sioaddr);
2303     +
2304     + return 0;
2305     }
2306    
2307     static inline void
2308     superio_exit(struct w83627hf_sio_data *sio)
2309     {
2310     outb(0xAA, sio->sioaddr);
2311     + release_region(sio->sioaddr, 2);
2312     }
2313    
2314     #define W627_DEVID 0x52
2315     @@ -1275,7 +1281,7 @@ static DEVICE_ATTR(name, S_IRUGO, show_name, NULL);
2316     static int __init w83627hf_find(int sioaddr, unsigned short *addr,
2317     struct w83627hf_sio_data *sio_data)
2318     {
2319     - int err = -ENODEV;
2320     + int err;
2321     u16 val;
2322    
2323     static __initconst char *const names[] = {
2324     @@ -1287,7 +1293,11 @@ static int __init w83627hf_find(int sioaddr, unsigned short *addr,
2325     };
2326    
2327     sio_data->sioaddr = sioaddr;
2328     - superio_enter(sio_data);
2329     + err = superio_enter(sio_data);
2330     + if (err)
2331     + return err;
2332     +
2333     + err = -ENODEV;
2334     val = force_id ? force_id : superio_inb(sio_data, DEVID);
2335     switch (val) {
2336     case W627_DEVID:
2337     @@ -1641,9 +1651,21 @@ static int w83627thf_read_gpio5(struct platform_device *pdev)
2338     struct w83627hf_sio_data *sio_data = dev_get_platdata(&pdev->dev);
2339     int res = 0xff, sel;
2340    
2341     - superio_enter(sio_data);
2342     + if (superio_enter(sio_data)) {
2343     + /*
2344     + * Some other driver reserved the address space for itself.
2345     + * We don't want to fail driver instantiation because of that,
2346     + * so display a warning and keep going.
2347     + */
2348     + dev_warn(&pdev->dev,
2349     + "Can not read VID data: Failed to enable SuperIO access\n");
2350     + return res;
2351     + }
2352     +
2353     superio_select(sio_data, W83627HF_LD_GPIO5);
2354    
2355     + res = 0xff;
2356     +
2357     /* Make sure these GPIO pins are enabled */
2358     if (!(superio_inb(sio_data, W83627THF_GPIO5_EN) & (1<<3))) {
2359     dev_dbg(&pdev->dev, "GPIO5 disabled, no VID function\n");
2360     @@ -1674,7 +1696,17 @@ static int w83687thf_read_vid(struct platform_device *pdev)
2361     struct w83627hf_sio_data *sio_data = dev_get_platdata(&pdev->dev);
2362     int res = 0xff;
2363    
2364     - superio_enter(sio_data);
2365     + if (superio_enter(sio_data)) {
2366     + /*
2367     + * Some other driver reserved the address space for itself.
2368     + * We don't want to fail driver instantiation because of that,
2369     + * so display a warning and keep going.
2370     + */
2371     + dev_warn(&pdev->dev,
2372     + "Can not read VID data: Failed to enable SuperIO access\n");
2373     + return res;
2374     + }
2375     +
2376     superio_select(sio_data, W83627HF_LD_HWM);
2377    
2378     /* Make sure these GPIO pins are enabled */
2379     diff --git a/drivers/hwtracing/coresight/coresight-etb10.c b/drivers/hwtracing/coresight/coresight-etb10.c
2380     index ace55385b26f..ff10deed3fde 100644
2381     --- a/drivers/hwtracing/coresight/coresight-etb10.c
2382     +++ b/drivers/hwtracing/coresight/coresight-etb10.c
2383     @@ -279,9 +279,7 @@ static void *etb_alloc_buffer(struct coresight_device *csdev, int cpu,
2384     int node;
2385     struct cs_buffers *buf;
2386    
2387     - if (cpu == -1)
2388     - cpu = smp_processor_id();
2389     - node = cpu_to_node(cpu);
2390     + node = (cpu == -1) ? NUMA_NO_NODE : cpu_to_node(cpu);
2391    
2392     buf = kzalloc_node(sizeof(struct cs_buffers), GFP_KERNEL, node);
2393     if (!buf)
2394     diff --git a/drivers/hwtracing/coresight/coresight-tmc-etf.c b/drivers/hwtracing/coresight/coresight-tmc-etf.c
2395     index 14df4e34c21c..03ce12ad4317 100644
2396     --- a/drivers/hwtracing/coresight/coresight-tmc-etf.c
2397     +++ b/drivers/hwtracing/coresight/coresight-tmc-etf.c
2398     @@ -292,9 +292,7 @@ static void *tmc_alloc_etf_buffer(struct coresight_device *csdev, int cpu,
2399     int node;
2400     struct cs_buffers *buf;
2401    
2402     - if (cpu == -1)
2403     - cpu = smp_processor_id();
2404     - node = cpu_to_node(cpu);
2405     + node = (cpu == -1) ? NUMA_NO_NODE : cpu_to_node(cpu);
2406    
2407     /* Allocate memory structure for interaction with Perf */
2408     buf = kzalloc_node(sizeof(struct cs_buffers), GFP_KERNEL, node);
2409     diff --git a/drivers/iio/dac/ad5380.c b/drivers/iio/dac/ad5380.c
2410     index 97d2c5111f43..8bf7fc626a9d 100644
2411     --- a/drivers/iio/dac/ad5380.c
2412     +++ b/drivers/iio/dac/ad5380.c
2413     @@ -221,7 +221,7 @@ static int ad5380_read_raw(struct iio_dev *indio_dev,
2414     if (ret)
2415     return ret;
2416     *val >>= chan->scan_type.shift;
2417     - val -= (1 << chan->scan_type.realbits) / 2;
2418     + *val -= (1 << chan->scan_type.realbits) / 2;
2419     return IIO_VAL_INT;
2420     case IIO_CHAN_INFO_SCALE:
2421     *val = 2 * st->vref;
2422     diff --git a/drivers/infiniband/hw/cxgb4/cm.c b/drivers/infiniband/hw/cxgb4/cm.c
2423     index 605d50ad123c..a04a53acb24f 100644
2424     --- a/drivers/infiniband/hw/cxgb4/cm.c
2425     +++ b/drivers/infiniband/hw/cxgb4/cm.c
2426     @@ -2044,7 +2044,7 @@ static int import_ep(struct c4iw_ep *ep, int iptype, __u8 *peer_ip,
2427     } else {
2428     pdev = get_real_dev(n->dev);
2429     ep->l2t = cxgb4_l2t_get(cdev->rdev.lldi.l2t,
2430     - n, pdev, 0);
2431     + n, pdev, rt_tos2priority(tos));
2432     if (!ep->l2t)
2433     goto out;
2434     ep->mtu = dst_mtu(dst);
2435     @@ -2135,7 +2135,8 @@ static int c4iw_reconnect(struct c4iw_ep *ep)
2436     laddr6->sin6_addr.s6_addr,
2437     raddr6->sin6_addr.s6_addr,
2438     laddr6->sin6_port,
2439     - raddr6->sin6_port, 0,
2440     + raddr6->sin6_port,
2441     + ep->com.cm_id->tos,
2442     raddr6->sin6_scope_id);
2443     iptype = 6;
2444     ra = (__u8 *)&raddr6->sin6_addr;
2445     @@ -3278,7 +3279,7 @@ int c4iw_connect(struct iw_cm_id *cm_id, struct iw_cm_conn_param *conn_param)
2446     laddr6->sin6_addr.s6_addr,
2447     raddr6->sin6_addr.s6_addr,
2448     laddr6->sin6_port,
2449     - raddr6->sin6_port, 0,
2450     + raddr6->sin6_port, cm_id->tos,
2451     raddr6->sin6_scope_id);
2452     }
2453     if (!ep->dst) {
2454     diff --git a/drivers/infiniband/hw/hns/hns_roce_qp.c b/drivers/infiniband/hw/hns/hns_roce_qp.c
2455     index 33cf1035030b..6f3c0ea99dd0 100644
2456     --- a/drivers/infiniband/hw/hns/hns_roce_qp.c
2457     +++ b/drivers/infiniband/hw/hns/hns_roce_qp.c
2458     @@ -241,7 +241,6 @@ void hns_roce_qp_free(struct hns_roce_dev *hr_dev, struct hns_roce_qp *hr_qp)
2459    
2460     if ((hr_qp->ibqp.qp_type) != IB_QPT_GSI) {
2461     hns_roce_table_put(hr_dev, &qp_table->irrl_table, hr_qp->qpn);
2462     - hns_roce_table_put(hr_dev, &qp_table->qp_table, hr_qp->qpn);
2463     }
2464     }
2465    
2466     diff --git a/drivers/infiniband/hw/mlx5/qp.c b/drivers/infiniband/hw/mlx5/qp.c
2467     index a7bc89f5dae7..4d906a790481 100644
2468     --- a/drivers/infiniband/hw/mlx5/qp.c
2469     +++ b/drivers/infiniband/hw/mlx5/qp.c
2470     @@ -2324,6 +2324,11 @@ static enum mlx5_qp_optpar opt_mask[MLX5_QP_NUM_STATE][MLX5_QP_NUM_STATE][MLX5_Q
2471     [MLX5_QP_ST_UD] = MLX5_QP_OPTPAR_PKEY_INDEX |
2472     MLX5_QP_OPTPAR_Q_KEY |
2473     MLX5_QP_OPTPAR_PRI_PORT,
2474     + [MLX5_QP_ST_XRC] = MLX5_QP_OPTPAR_RRE |
2475     + MLX5_QP_OPTPAR_RAE |
2476     + MLX5_QP_OPTPAR_RWE |
2477     + MLX5_QP_OPTPAR_PKEY_INDEX |
2478     + MLX5_QP_OPTPAR_PRI_PORT,
2479     },
2480     [MLX5_QP_STATE_RTR] = {
2481     [MLX5_QP_ST_RC] = MLX5_QP_OPTPAR_ALT_ADDR_PATH |
2482     @@ -2357,6 +2362,12 @@ static enum mlx5_qp_optpar opt_mask[MLX5_QP_NUM_STATE][MLX5_QP_NUM_STATE][MLX5_Q
2483     MLX5_QP_OPTPAR_RWE |
2484     MLX5_QP_OPTPAR_PM_STATE,
2485     [MLX5_QP_ST_UD] = MLX5_QP_OPTPAR_Q_KEY,
2486     + [MLX5_QP_ST_XRC] = MLX5_QP_OPTPAR_ALT_ADDR_PATH |
2487     + MLX5_QP_OPTPAR_RRE |
2488     + MLX5_QP_OPTPAR_RAE |
2489     + MLX5_QP_OPTPAR_RWE |
2490     + MLX5_QP_OPTPAR_PM_STATE |
2491     + MLX5_QP_OPTPAR_RNR_TIMEOUT,
2492     },
2493     },
2494     [MLX5_QP_STATE_RTS] = {
2495     @@ -2373,6 +2384,12 @@ static enum mlx5_qp_optpar opt_mask[MLX5_QP_NUM_STATE][MLX5_QP_NUM_STATE][MLX5_Q
2496     [MLX5_QP_ST_UD] = MLX5_QP_OPTPAR_Q_KEY |
2497     MLX5_QP_OPTPAR_SRQN |
2498     MLX5_QP_OPTPAR_CQN_RCV,
2499     + [MLX5_QP_ST_XRC] = MLX5_QP_OPTPAR_RRE |
2500     + MLX5_QP_OPTPAR_RAE |
2501     + MLX5_QP_OPTPAR_RWE |
2502     + MLX5_QP_OPTPAR_RNR_TIMEOUT |
2503     + MLX5_QP_OPTPAR_PM_STATE |
2504     + MLX5_QP_OPTPAR_ALT_ADDR_PATH,
2505     },
2506     },
2507     [MLX5_QP_STATE_SQER] = {
2508     @@ -2384,6 +2401,10 @@ static enum mlx5_qp_optpar opt_mask[MLX5_QP_NUM_STATE][MLX5_QP_NUM_STATE][MLX5_Q
2509     MLX5_QP_OPTPAR_RWE |
2510     MLX5_QP_OPTPAR_RAE |
2511     MLX5_QP_OPTPAR_RRE,
2512     + [MLX5_QP_ST_XRC] = MLX5_QP_OPTPAR_RNR_TIMEOUT |
2513     + MLX5_QP_OPTPAR_RWE |
2514     + MLX5_QP_OPTPAR_RAE |
2515     + MLX5_QP_OPTPAR_RRE,
2516     },
2517     },
2518     };
2519     diff --git a/drivers/infiniband/hw/ocrdma/ocrdma_verbs.c b/drivers/infiniband/hw/ocrdma/ocrdma_verbs.c
2520     index 6af44f8db3d5..4d28bd8eff01 100644
2521     --- a/drivers/infiniband/hw/ocrdma/ocrdma_verbs.c
2522     +++ b/drivers/infiniband/hw/ocrdma/ocrdma_verbs.c
2523     @@ -55,7 +55,7 @@
2524    
2525     int ocrdma_query_pkey(struct ib_device *ibdev, u8 port, u16 index, u16 *pkey)
2526     {
2527     - if (index > 1)
2528     + if (index > 0)
2529     return -EINVAL;
2530    
2531     *pkey = 0xffff;
2532     diff --git a/drivers/infiniband/hw/qedr/verbs.c b/drivers/infiniband/hw/qedr/verbs.c
2533     index cd0408c2b376..7603a1641c7d 100644
2534     --- a/drivers/infiniband/hw/qedr/verbs.c
2535     +++ b/drivers/infiniband/hw/qedr/verbs.c
2536     @@ -54,7 +54,7 @@
2537    
2538     int qedr_query_pkey(struct ib_device *ibdev, u8 port, u16 index, u16 *pkey)
2539     {
2540     - if (index > QEDR_ROCE_PKEY_TABLE_LEN)
2541     + if (index >= QEDR_ROCE_PKEY_TABLE_LEN)
2542     return -EINVAL;
2543    
2544     *pkey = QEDR_ROCE_PKEY_DEFAULT;
2545     diff --git a/drivers/infiniband/hw/usnic/usnic_ib_verbs.c b/drivers/infiniband/hw/usnic/usnic_ib_verbs.c
2546     index a5bfbba6bbac..cacb720f44a0 100644
2547     --- a/drivers/infiniband/hw/usnic/usnic_ib_verbs.c
2548     +++ b/drivers/infiniband/hw/usnic/usnic_ib_verbs.c
2549     @@ -425,7 +425,7 @@ int usnic_ib_query_gid(struct ib_device *ibdev, u8 port, int index,
2550     int usnic_ib_query_pkey(struct ib_device *ibdev, u8 port, u16 index,
2551     u16 *pkey)
2552     {
2553     - if (index > 1)
2554     + if (index > 0)
2555     return -EINVAL;
2556    
2557     *pkey = 0xffff;
2558     diff --git a/drivers/infiniband/sw/rxe/rxe_cq.c b/drivers/infiniband/sw/rxe/rxe_cq.c
2559     index e5e6a5e7dee9..5ac88412f1ff 100644
2560     --- a/drivers/infiniband/sw/rxe/rxe_cq.c
2561     +++ b/drivers/infiniband/sw/rxe/rxe_cq.c
2562     @@ -30,7 +30,7 @@
2563     * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
2564     * SOFTWARE.
2565     */
2566     -
2567     +#include <linux/vmalloc.h>
2568     #include "rxe.h"
2569     #include "rxe_loc.h"
2570     #include "rxe_queue.h"
2571     @@ -89,7 +89,7 @@ int rxe_cq_from_init(struct rxe_dev *rxe, struct rxe_cq *cq, int cqe,
2572     err = do_mmap_info(rxe, udata, false, context, cq->queue->buf,
2573     cq->queue->buf_size, &cq->queue->ip);
2574     if (err) {
2575     - kvfree(cq->queue->buf);
2576     + vfree(cq->queue->buf);
2577     kfree(cq->queue);
2578     return err;
2579     }
2580     diff --git a/drivers/infiniband/sw/rxe/rxe_qp.c b/drivers/infiniband/sw/rxe/rxe_qp.c
2581     index 44b2108253bd..d6672127808b 100644
2582     --- a/drivers/infiniband/sw/rxe/rxe_qp.c
2583     +++ b/drivers/infiniband/sw/rxe/rxe_qp.c
2584     @@ -34,6 +34,7 @@
2585     #include <linux/skbuff.h>
2586     #include <linux/delay.h>
2587     #include <linux/sched.h>
2588     +#include <linux/vmalloc.h>
2589    
2590     #include "rxe.h"
2591     #include "rxe_loc.h"
2592     @@ -255,7 +256,7 @@ static int rxe_qp_init_req(struct rxe_dev *rxe, struct rxe_qp *qp,
2593     qp->sq.queue->buf_size, &qp->sq.queue->ip);
2594    
2595     if (err) {
2596     - kvfree(qp->sq.queue->buf);
2597     + vfree(qp->sq.queue->buf);
2598     kfree(qp->sq.queue);
2599     return err;
2600     }
2601     @@ -312,7 +313,7 @@ static int rxe_qp_init_resp(struct rxe_dev *rxe, struct rxe_qp *qp,
2602     qp->rq.queue->buf_size,
2603     &qp->rq.queue->ip);
2604     if (err) {
2605     - kvfree(qp->rq.queue->buf);
2606     + vfree(qp->rq.queue->buf);
2607     kfree(qp->rq.queue);
2608     return err;
2609     }
2610     diff --git a/drivers/infiniband/ulp/iser/iscsi_iser.h b/drivers/infiniband/ulp/iser/iscsi_iser.h
2611     index cb48e22afff7..a3614f7f0007 100644
2612     --- a/drivers/infiniband/ulp/iser/iscsi_iser.h
2613     +++ b/drivers/infiniband/ulp/iser/iscsi_iser.h
2614     @@ -197,7 +197,7 @@ struct iser_data_buf {
2615     struct scatterlist *sg;
2616     int size;
2617     unsigned long data_len;
2618     - unsigned int dma_nents;
2619     + int dma_nents;
2620     };
2621    
2622     /* fwd declarations */
2623     diff --git a/drivers/infiniband/ulp/iser/iser_memory.c b/drivers/infiniband/ulp/iser/iser_memory.c
2624     index 9c3e9ab53a41..759c2fe033e7 100644
2625     --- a/drivers/infiniband/ulp/iser/iser_memory.c
2626     +++ b/drivers/infiniband/ulp/iser/iser_memory.c
2627     @@ -240,8 +240,8 @@ int iser_fast_reg_fmr(struct iscsi_iser_task *iser_task,
2628     page_vec->npages = 0;
2629     page_vec->fake_mr.page_size = SIZE_4K;
2630     plen = ib_sg_to_pages(&page_vec->fake_mr, mem->sg,
2631     - mem->size, NULL, iser_set_page);
2632     - if (unlikely(plen < mem->size)) {
2633     + mem->dma_nents, NULL, iser_set_page);
2634     + if (unlikely(plen < mem->dma_nents)) {
2635     iser_err("page vec too short to hold this SG\n");
2636     iser_data_buf_dump(mem, device->ib_device);
2637     iser_dump_page_vec(page_vec);
2638     @@ -450,10 +450,10 @@ static int iser_fast_reg_mr(struct iscsi_iser_task *iser_task,
2639    
2640     ib_update_fast_reg_key(mr, ib_inc_rkey(mr->rkey));
2641    
2642     - n = ib_map_mr_sg(mr, mem->sg, mem->size, NULL, SIZE_4K);
2643     - if (unlikely(n != mem->size)) {
2644     + n = ib_map_mr_sg(mr, mem->sg, mem->dma_nents, NULL, SIZE_4K);
2645     + if (unlikely(n != mem->dma_nents)) {
2646     iser_err("failed to map sg (%d/%d)\n",
2647     - n, mem->size);
2648     + n, mem->dma_nents);
2649     return n < 0 ? n : -EINVAL;
2650     }
2651    
2652     diff --git a/drivers/infiniband/ulp/isert/ib_isert.c b/drivers/infiniband/ulp/isert/ib_isert.c
2653     index 02a5e2d7e574..0d2ab9a2cf44 100644
2654     --- a/drivers/infiniband/ulp/isert/ib_isert.c
2655     +++ b/drivers/infiniband/ulp/isert/ib_isert.c
2656     @@ -2555,17 +2555,6 @@ isert_wait4logout(struct isert_conn *isert_conn)
2657     }
2658     }
2659    
2660     -static void
2661     -isert_wait4cmds(struct iscsi_conn *conn)
2662     -{
2663     - isert_info("iscsi_conn %p\n", conn);
2664     -
2665     - if (conn->sess) {
2666     - target_sess_cmd_list_set_waiting(conn->sess->se_sess);
2667     - target_wait_for_sess_cmds(conn->sess->se_sess);
2668     - }
2669     -}
2670     -
2671     /**
2672     * isert_put_unsol_pending_cmds() - Drop commands waiting for
2673     * unsolicitate dataout
2674     @@ -2613,7 +2602,6 @@ static void isert_wait_conn(struct iscsi_conn *conn)
2675    
2676     ib_drain_qp(isert_conn->qp);
2677     isert_put_unsol_pending_cmds(conn);
2678     - isert_wait4cmds(conn);
2679     isert_wait4logout(isert_conn);
2680    
2681     queue_work(isert_release_wq, &isert_conn->release_work);
2682     diff --git a/drivers/input/keyboard/nomadik-ske-keypad.c b/drivers/input/keyboard/nomadik-ske-keypad.c
2683     index 8567ee47761e..ae3b04557074 100644
2684     --- a/drivers/input/keyboard/nomadik-ske-keypad.c
2685     +++ b/drivers/input/keyboard/nomadik-ske-keypad.c
2686     @@ -100,7 +100,7 @@ static int __init ske_keypad_chip_init(struct ske_keypad *keypad)
2687     while ((readl(keypad->reg_base + SKE_RIS) != 0x00000000) && timeout--)
2688     cpu_relax();
2689    
2690     - if (!timeout)
2691     + if (timeout == -1)
2692     return -EINVAL;
2693    
2694     /*
2695     diff --git a/drivers/input/misc/keyspan_remote.c b/drivers/input/misc/keyspan_remote.c
2696     index a3fe4a990cc9..c7b889d13edd 100644
2697     --- a/drivers/input/misc/keyspan_remote.c
2698     +++ b/drivers/input/misc/keyspan_remote.c
2699     @@ -344,7 +344,8 @@ static int keyspan_setup(struct usb_device* dev)
2700     int retval = 0;
2701    
2702     retval = usb_control_msg(dev, usb_sndctrlpipe(dev, 0),
2703     - 0x11, 0x40, 0x5601, 0x0, NULL, 0, 0);
2704     + 0x11, 0x40, 0x5601, 0x0, NULL, 0,
2705     + USB_CTRL_SET_TIMEOUT);
2706     if (retval) {
2707     dev_dbg(&dev->dev, "%s - failed to set bit rate due to error: %d\n",
2708     __func__, retval);
2709     @@ -352,7 +353,8 @@ static int keyspan_setup(struct usb_device* dev)
2710     }
2711    
2712     retval = usb_control_msg(dev, usb_sndctrlpipe(dev, 0),
2713     - 0x44, 0x40, 0x0, 0x0, NULL, 0, 0);
2714     + 0x44, 0x40, 0x0, 0x0, NULL, 0,
2715     + USB_CTRL_SET_TIMEOUT);
2716     if (retval) {
2717     dev_dbg(&dev->dev, "%s - failed to set resume sensitivity due to error: %d\n",
2718     __func__, retval);
2719     @@ -360,7 +362,8 @@ static int keyspan_setup(struct usb_device* dev)
2720     }
2721    
2722     retval = usb_control_msg(dev, usb_sndctrlpipe(dev, 0),
2723     - 0x22, 0x40, 0x0, 0x0, NULL, 0, 0);
2724     + 0x22, 0x40, 0x0, 0x0, NULL, 0,
2725     + USB_CTRL_SET_TIMEOUT);
2726     if (retval) {
2727     dev_dbg(&dev->dev, "%s - failed to turn receive on due to error: %d\n",
2728     __func__, retval);
2729     diff --git a/drivers/input/tablet/aiptek.c b/drivers/input/tablet/aiptek.c
2730     index 4613f0aefd08..5a7e5e073e52 100644
2731     --- a/drivers/input/tablet/aiptek.c
2732     +++ b/drivers/input/tablet/aiptek.c
2733     @@ -1822,14 +1822,14 @@ aiptek_probe(struct usb_interface *intf, const struct usb_device_id *id)
2734     input_set_abs_params(inputdev, ABS_WHEEL, AIPTEK_WHEEL_MIN, AIPTEK_WHEEL_MAX - 1, 0, 0);
2735    
2736     /* Verify that a device really has an endpoint */
2737     - if (intf->altsetting[0].desc.bNumEndpoints < 1) {
2738     + if (intf->cur_altsetting->desc.bNumEndpoints < 1) {
2739     dev_err(&intf->dev,
2740     "interface has %d endpoints, but must have minimum 1\n",
2741     - intf->altsetting[0].desc.bNumEndpoints);
2742     + intf->cur_altsetting->desc.bNumEndpoints);
2743     err = -EINVAL;
2744     goto fail3;
2745     }
2746     - endpoint = &intf->altsetting[0].endpoint[0].desc;
2747     + endpoint = &intf->cur_altsetting->endpoint[0].desc;
2748    
2749     /* Go set up our URB, which is called when the tablet receives
2750     * input.
2751     diff --git a/drivers/input/tablet/gtco.c b/drivers/input/tablet/gtco.c
2752     index 8af736dc4b18..dd8dc335daca 100644
2753     --- a/drivers/input/tablet/gtco.c
2754     +++ b/drivers/input/tablet/gtco.c
2755     @@ -875,18 +875,14 @@ static int gtco_probe(struct usb_interface *usbinterface,
2756     }
2757    
2758     /* Sanity check that a device has an endpoint */
2759     - if (usbinterface->altsetting[0].desc.bNumEndpoints < 1) {
2760     + if (usbinterface->cur_altsetting->desc.bNumEndpoints < 1) {
2761     dev_err(&usbinterface->dev,
2762     "Invalid number of endpoints\n");
2763     error = -EINVAL;
2764     goto err_free_urb;
2765     }
2766    
2767     - /*
2768     - * The endpoint is always altsetting 0, we know this since we know
2769     - * this device only has one interrupt endpoint
2770     - */
2771     - endpoint = &usbinterface->altsetting[0].endpoint[0].desc;
2772     + endpoint = &usbinterface->cur_altsetting->endpoint[0].desc;
2773    
2774     /* Some debug */
2775     dev_dbg(&usbinterface->dev, "gtco # interfaces: %d\n", usbinterface->num_altsetting);
2776     @@ -973,7 +969,7 @@ static int gtco_probe(struct usb_interface *usbinterface,
2777     input_dev->dev.parent = &usbinterface->dev;
2778    
2779     /* Setup the URB, it will be posted later on open of input device */
2780     - endpoint = &usbinterface->altsetting[0].endpoint[0].desc;
2781     + endpoint = &usbinterface->cur_altsetting->endpoint[0].desc;
2782    
2783     usb_fill_int_urb(gtco->urbinfo,
2784     udev,
2785     diff --git a/drivers/input/tablet/pegasus_notetaker.c b/drivers/input/tablet/pegasus_notetaker.c
2786     index 47de5a81172f..2319144802c9 100644
2787     --- a/drivers/input/tablet/pegasus_notetaker.c
2788     +++ b/drivers/input/tablet/pegasus_notetaker.c
2789     @@ -260,7 +260,7 @@ static int pegasus_probe(struct usb_interface *intf,
2790     return -ENODEV;
2791    
2792     /* Sanity check that the device has an endpoint */
2793     - if (intf->altsetting[0].desc.bNumEndpoints < 1) {
2794     + if (intf->cur_altsetting->desc.bNumEndpoints < 1) {
2795     dev_err(&intf->dev, "Invalid number of endpoints\n");
2796     return -EINVAL;
2797     }
2798     diff --git a/drivers/input/touchscreen/sun4i-ts.c b/drivers/input/touchscreen/sun4i-ts.c
2799     index d07dd29d4848..9a94d65bf483 100644
2800     --- a/drivers/input/touchscreen/sun4i-ts.c
2801     +++ b/drivers/input/touchscreen/sun4i-ts.c
2802     @@ -246,6 +246,7 @@ static int sun4i_ts_probe(struct platform_device *pdev)
2803     struct device *dev = &pdev->dev;
2804     struct device_node *np = dev->of_node;
2805     struct device *hwmon;
2806     + struct thermal_zone_device *thermal;
2807     int error;
2808     u32 reg;
2809     bool ts_attached;
2810     @@ -365,7 +366,10 @@ static int sun4i_ts_probe(struct platform_device *pdev)
2811     if (IS_ERR(hwmon))
2812     return PTR_ERR(hwmon);
2813    
2814     - devm_thermal_zone_of_sensor_register(ts->dev, 0, ts, &sun4i_ts_tz_ops);
2815     + thermal = devm_thermal_zone_of_sensor_register(ts->dev, 0, ts,
2816     + &sun4i_ts_tz_ops);
2817     + if (IS_ERR(thermal))
2818     + return PTR_ERR(thermal);
2819    
2820     writel(TEMP_IRQ_EN(1), ts->base + TP_INT_FIFOC);
2821    
2822     diff --git a/drivers/input/touchscreen/sur40.c b/drivers/input/touchscreen/sur40.c
2823     index 4c0eecae065c..2180fa8b695b 100644
2824     --- a/drivers/input/touchscreen/sur40.c
2825     +++ b/drivers/input/touchscreen/sur40.c
2826     @@ -523,7 +523,7 @@ static int sur40_probe(struct usb_interface *interface,
2827     int error;
2828    
2829     /* Check if we really have the right interface. */
2830     - iface_desc = &interface->altsetting[0];
2831     + iface_desc = interface->cur_altsetting;
2832     if (iface_desc->desc.bInterfaceClass != 0xFF)
2833     return -ENODEV;
2834    
2835     diff --git a/drivers/iommu/amd_iommu.c b/drivers/iommu/amd_iommu.c
2836     index c898c70472bb..bb0448c91f67 100644
2837     --- a/drivers/iommu/amd_iommu.c
2838     +++ b/drivers/iommu/amd_iommu.c
2839     @@ -2113,6 +2113,8 @@ skip_ats_check:
2840     */
2841     domain_flush_tlb_pde(domain);
2842    
2843     + domain_flush_complete(domain);
2844     +
2845     return ret;
2846     }
2847    
2848     diff --git a/drivers/iommu/amd_iommu_init.c b/drivers/iommu/amd_iommu_init.c
2849     index 9bb8d64b6f94..c113e46fdc3a 100644
2850     --- a/drivers/iommu/amd_iommu_init.c
2851     +++ b/drivers/iommu/amd_iommu_init.c
2852     @@ -383,6 +383,9 @@ static void iommu_enable(struct amd_iommu *iommu)
2853    
2854     static void iommu_disable(struct amd_iommu *iommu)
2855     {
2856     + if (!iommu->mmio_base)
2857     + return;
2858     +
2859     /* Disable command buffer */
2860     iommu_feature_disable(iommu, CONTROL_CMDBUF_EN);
2861    
2862     diff --git a/drivers/iommu/intel-iommu.c b/drivers/iommu/intel-iommu.c
2863     index 25cc6ae87039..5c6e0a9fd2f3 100644
2864     --- a/drivers/iommu/intel-iommu.c
2865     +++ b/drivers/iommu/intel-iommu.c
2866     @@ -3345,9 +3345,12 @@ static int __init init_dmars(void)
2867     iommu_identity_mapping |= IDENTMAP_ALL;
2868    
2869     #ifdef CONFIG_INTEL_IOMMU_BROKEN_GFX_WA
2870     - iommu_identity_mapping |= IDENTMAP_GFX;
2871     + dmar_map_gfx = 0;
2872     #endif
2873    
2874     + if (!dmar_map_gfx)
2875     + iommu_identity_mapping |= IDENTMAP_GFX;
2876     +
2877     check_tylersburg_isoch();
2878    
2879     if (iommu_identity_mapping) {
2880     diff --git a/drivers/iommu/iommu.c b/drivers/iommu/iommu.c
2881     index 71b89e47e952..dbcc13efaf3c 100644
2882     --- a/drivers/iommu/iommu.c
2883     +++ b/drivers/iommu/iommu.c
2884     @@ -1582,9 +1582,9 @@ int iommu_request_dm_for_dev(struct device *dev)
2885     int ret;
2886    
2887     /* Device must already be in a group before calling this function */
2888     - group = iommu_group_get_for_dev(dev);
2889     - if (IS_ERR(group))
2890     - return PTR_ERR(group);
2891     + group = iommu_group_get(dev);
2892     + if (!group)
2893     + return -EINVAL;
2894    
2895     mutex_lock(&group->mutex);
2896    
2897     diff --git a/drivers/md/bcache/super.c b/drivers/md/bcache/super.c
2898     index 080f9afcde8d..526e9d5a4fb1 100644
2899     --- a/drivers/md/bcache/super.c
2900     +++ b/drivers/md/bcache/super.c
2901     @@ -1398,9 +1398,6 @@ static void cache_set_flush(struct closure *cl)
2902     struct btree *b;
2903     unsigned i;
2904    
2905     - if (!c)
2906     - closure_return(cl);
2907     -
2908     bch_cache_accounting_destroy(&c->accounting);
2909    
2910     kobject_put(&c->internal);
2911     diff --git a/drivers/md/bitmap.c b/drivers/md/bitmap.c
2912     index f7ff408567ad..63bff4cc7098 100644
2913     --- a/drivers/md/bitmap.c
2914     +++ b/drivers/md/bitmap.c
2915     @@ -1699,7 +1699,7 @@ void bitmap_flush(struct mddev *mddev)
2916     /*
2917     * free memory that was allocated
2918     */
2919     -static void bitmap_free(struct bitmap *bitmap)
2920     +static void md_bitmap_free(struct bitmap *bitmap)
2921     {
2922     unsigned long k, pages;
2923     struct bitmap_page *bp;
2924     @@ -1749,7 +1749,7 @@ void bitmap_destroy(struct mddev *mddev)
2925     if (mddev->thread)
2926     mddev->thread->timeout = MAX_SCHEDULE_TIMEOUT;
2927    
2928     - bitmap_free(bitmap);
2929     + md_bitmap_free(bitmap);
2930     }
2931    
2932     /*
2933     @@ -1834,7 +1834,7 @@ struct bitmap *bitmap_create(struct mddev *mddev, int slot)
2934    
2935     return bitmap;
2936     error:
2937     - bitmap_free(bitmap);
2938     + md_bitmap_free(bitmap);
2939     return ERR_PTR(err);
2940     }
2941    
2942     @@ -1936,7 +1936,7 @@ int bitmap_copy_from_slot(struct mddev *mddev, int slot,
2943     *low = lo;
2944     *high = hi;
2945     err:
2946     - bitmap_free(bitmap);
2947     + md_bitmap_free(bitmap);
2948     return rv;
2949     }
2950     EXPORT_SYMBOL_GPL(bitmap_copy_from_slot);
2951     diff --git a/drivers/media/i2c/ov2659.c b/drivers/media/i2c/ov2659.c
2952     index ade3c48e2e0c..18546f950d79 100644
2953     --- a/drivers/media/i2c/ov2659.c
2954     +++ b/drivers/media/i2c/ov2659.c
2955     @@ -1137,7 +1137,7 @@ static int ov2659_set_fmt(struct v4l2_subdev *sd,
2956     mf = v4l2_subdev_get_try_format(sd, cfg, fmt->pad);
2957     *mf = fmt->format;
2958     #else
2959     - return -ENOTTY;
2960     + ret = -ENOTTY;
2961     #endif
2962     } else {
2963     s64 val;
2964     diff --git a/drivers/media/i2c/soc_camera/ov6650.c b/drivers/media/i2c/soc_camera/ov6650.c
2965     index 7a119466f973..3c959e48855c 100644
2966     --- a/drivers/media/i2c/soc_camera/ov6650.c
2967     +++ b/drivers/media/i2c/soc_camera/ov6650.c
2968     @@ -203,7 +203,6 @@ struct ov6650 {
2969     unsigned long pclk_max; /* from resolution and format */
2970     struct v4l2_fract tpf; /* as requested with s_parm */
2971     u32 code;
2972     - enum v4l2_colorspace colorspace;
2973     };
2974    
2975    
2976     @@ -216,6 +215,17 @@ static u32 ov6650_codes[] = {
2977     MEDIA_BUS_FMT_Y8_1X8,
2978     };
2979    
2980     +static const struct v4l2_mbus_framefmt ov6650_def_fmt = {
2981     + .width = W_CIF,
2982     + .height = H_CIF,
2983     + .code = MEDIA_BUS_FMT_SBGGR8_1X8,
2984     + .colorspace = V4L2_COLORSPACE_SRGB,
2985     + .field = V4L2_FIELD_NONE,
2986     + .ycbcr_enc = V4L2_YCBCR_ENC_DEFAULT,
2987     + .quantization = V4L2_QUANTIZATION_DEFAULT,
2988     + .xfer_func = V4L2_XFER_FUNC_DEFAULT,
2989     +};
2990     +
2991     /* read a register */
2992     static int ov6650_reg_read(struct i2c_client *client, u8 reg, u8 *val)
2993     {
2994     @@ -512,12 +522,20 @@ static int ov6650_get_fmt(struct v4l2_subdev *sd,
2995     if (format->pad)
2996     return -EINVAL;
2997    
2998     - mf->width = priv->rect.width >> priv->half_scale;
2999     - mf->height = priv->rect.height >> priv->half_scale;
3000     - mf->code = priv->code;
3001     - mf->colorspace = priv->colorspace;
3002     - mf->field = V4L2_FIELD_NONE;
3003     + /* initialize response with default media bus frame format */
3004     + *mf = ov6650_def_fmt;
3005    
3006     + /* update media bus format code and frame size */
3007     + if (format->which == V4L2_SUBDEV_FORMAT_TRY) {
3008     + mf->width = cfg->try_fmt.width;
3009     + mf->height = cfg->try_fmt.height;
3010     + mf->code = cfg->try_fmt.code;
3011     +
3012     + } else {
3013     + mf->width = priv->rect.width >> priv->half_scale;
3014     + mf->height = priv->rect.height >> priv->half_scale;
3015     + mf->code = priv->code;
3016     + }
3017     return 0;
3018     }
3019    
3020     @@ -624,11 +642,6 @@ static int ov6650_s_fmt(struct v4l2_subdev *sd, struct v4l2_mbus_framefmt *mf)
3021     priv->pclk_max = 8000000;
3022     }
3023    
3024     - if (code == MEDIA_BUS_FMT_SBGGR8_1X8)
3025     - priv->colorspace = V4L2_COLORSPACE_SRGB;
3026     - else if (code != 0)
3027     - priv->colorspace = V4L2_COLORSPACE_JPEG;
3028     -
3029     if (half_scale) {
3030     dev_dbg(&client->dev, "max resolution: QCIF\n");
3031     coma_set |= COMA_QCIF;
3032     @@ -684,11 +697,6 @@ static int ov6650_s_fmt(struct v4l2_subdev *sd, struct v4l2_mbus_framefmt *mf)
3033     if (!ret)
3034     priv->code = code;
3035    
3036     - if (!ret) {
3037     - mf->colorspace = priv->colorspace;
3038     - mf->width = priv->rect.width >> half_scale;
3039     - mf->height = priv->rect.height >> half_scale;
3040     - }
3041     return ret;
3042     }
3043    
3044     @@ -707,8 +715,6 @@ static int ov6650_set_fmt(struct v4l2_subdev *sd,
3045     v4l_bound_align_image(&mf->width, 2, W_CIF, 1,
3046     &mf->height, 2, H_CIF, 1, 0);
3047    
3048     - mf->field = V4L2_FIELD_NONE;
3049     -
3050     switch (mf->code) {
3051     case MEDIA_BUS_FMT_Y10_1X10:
3052     mf->code = MEDIA_BUS_FMT_Y8_1X8;
3053     @@ -717,19 +723,38 @@ static int ov6650_set_fmt(struct v4l2_subdev *sd,
3054     case MEDIA_BUS_FMT_YUYV8_2X8:
3055     case MEDIA_BUS_FMT_VYUY8_2X8:
3056     case MEDIA_BUS_FMT_UYVY8_2X8:
3057     - mf->colorspace = V4L2_COLORSPACE_JPEG;
3058     break;
3059     default:
3060     mf->code = MEDIA_BUS_FMT_SBGGR8_1X8;
3061     case MEDIA_BUS_FMT_SBGGR8_1X8:
3062     - mf->colorspace = V4L2_COLORSPACE_SRGB;
3063     break;
3064     }
3065    
3066     - if (format->which == V4L2_SUBDEV_FORMAT_ACTIVE)
3067     - return ov6650_s_fmt(sd, mf);
3068     - cfg->try_fmt = *mf;
3069     + if (format->which == V4L2_SUBDEV_FORMAT_TRY) {
3070     + /* store media bus format code and frame size in pad config */
3071     + cfg->try_fmt.width = mf->width;
3072     + cfg->try_fmt.height = mf->height;
3073     + cfg->try_fmt.code = mf->code;
3074    
3075     + /* return default mbus frame format updated with pad config */
3076     + *mf = ov6650_def_fmt;
3077     + mf->width = cfg->try_fmt.width;
3078     + mf->height = cfg->try_fmt.height;
3079     + mf->code = cfg->try_fmt.code;
3080     +
3081     + } else {
3082     + /* apply new media bus format code and frame size */
3083     + int ret = ov6650_s_fmt(sd, mf);
3084     +
3085     + if (ret)
3086     + return ret;
3087     +
3088     + /* return default format updated with active size and code */
3089     + *mf = ov6650_def_fmt;
3090     + mf->width = priv->rect.width >> priv->half_scale;
3091     + mf->height = priv->rect.height >> priv->half_scale;
3092     + mf->code = priv->code;
3093     + }
3094     return 0;
3095     }
3096    
3097     @@ -1048,7 +1073,6 @@ static int ov6650_probe(struct i2c_client *client,
3098     priv->rect.height = H_CIF;
3099     priv->half_scale = false;
3100     priv->code = MEDIA_BUS_FMT_YUYV8_2X8;
3101     - priv->colorspace = V4L2_COLORSPACE_JPEG;
3102    
3103     ret = ov6650_video_probe(client);
3104     if (ret)
3105     diff --git a/drivers/media/pci/cx18/cx18-fileops.c b/drivers/media/pci/cx18/cx18-fileops.c
3106     index df837408efd5..0171dc5b8809 100644
3107     --- a/drivers/media/pci/cx18/cx18-fileops.c
3108     +++ b/drivers/media/pci/cx18/cx18-fileops.c
3109     @@ -490,7 +490,7 @@ static ssize_t cx18_read_pos(struct cx18_stream *s, char __user *ubuf,
3110    
3111     CX18_DEBUG_HI_FILE("read %zd from %s, got %zd\n", count, s->name, rc);
3112     if (rc > 0)
3113     - pos += rc;
3114     + *pos += rc;
3115     return rc;
3116     }
3117    
3118     diff --git a/drivers/media/pci/cx23885/cx23885-dvb.c b/drivers/media/pci/cx23885/cx23885-dvb.c
3119     index 818f3c2fc98d..1d86e57f4d9f 100644
3120     --- a/drivers/media/pci/cx23885/cx23885-dvb.c
3121     +++ b/drivers/media/pci/cx23885/cx23885-dvb.c
3122     @@ -1471,8 +1471,9 @@ static int dvb_register(struct cx23885_tsport *port)
3123     if (fe0->dvb.frontend != NULL) {
3124     struct i2c_adapter *tun_i2c;
3125    
3126     - fe0->dvb.frontend->sec_priv = kmalloc(sizeof(dib7000p_ops), GFP_KERNEL);
3127     - memcpy(fe0->dvb.frontend->sec_priv, &dib7000p_ops, sizeof(dib7000p_ops));
3128     + fe0->dvb.frontend->sec_priv = kmemdup(&dib7000p_ops, sizeof(dib7000p_ops), GFP_KERNEL);
3129     + if (!fe0->dvb.frontend->sec_priv)
3130     + return -ENOMEM;
3131     tun_i2c = dib7000p_ops.get_i2c_master(fe0->dvb.frontend, DIBX000_I2C_INTERFACE_TUNER, 1);
3132     if (!dvb_attach(dib0070_attach, fe0->dvb.frontend, tun_i2c, &dib7070p_dib0070_config))
3133     return -ENODEV;
3134     diff --git a/drivers/media/pci/ivtv/ivtv-fileops.c b/drivers/media/pci/ivtv/ivtv-fileops.c
3135     index c9bd018e53de..e2b19c3eaa87 100644
3136     --- a/drivers/media/pci/ivtv/ivtv-fileops.c
3137     +++ b/drivers/media/pci/ivtv/ivtv-fileops.c
3138     @@ -420,7 +420,7 @@ static ssize_t ivtv_read_pos(struct ivtv_stream *s, char __user *ubuf, size_t co
3139    
3140     IVTV_DEBUG_HI_FILE("read %zd from %s, got %zd\n", count, s->name, rc);
3141     if (rc > 0)
3142     - pos += rc;
3143     + *pos += rc;
3144     return rc;
3145     }
3146    
3147     diff --git a/drivers/media/pci/tw5864/tw5864-video.c b/drivers/media/pci/tw5864/tw5864-video.c
3148     index 1ddf80f85c24..27ff6e0d9845 100644
3149     --- a/drivers/media/pci/tw5864/tw5864-video.c
3150     +++ b/drivers/media/pci/tw5864/tw5864-video.c
3151     @@ -1386,13 +1386,13 @@ static void tw5864_handle_frame(struct tw5864_h264_frame *frame)
3152     input->vb = NULL;
3153     spin_unlock_irqrestore(&input->slock, flags);
3154    
3155     - v4l2_buf = to_vb2_v4l2_buffer(&vb->vb.vb2_buf);
3156     -
3157     if (!vb) { /* Gone because of disabling */
3158     dev_dbg(&dev->pci->dev, "vb is empty, dropping frame\n");
3159     return;
3160     }
3161    
3162     + v4l2_buf = to_vb2_v4l2_buffer(&vb->vb.vb2_buf);
3163     +
3164     /*
3165     * Check for space.
3166     * Mind the overhead of startcode emulation prevention.
3167     diff --git a/drivers/media/platform/davinci/isif.c b/drivers/media/platform/davinci/isif.c
3168     index 78e37cf3470f..b51b875c5a61 100644
3169     --- a/drivers/media/platform/davinci/isif.c
3170     +++ b/drivers/media/platform/davinci/isif.c
3171     @@ -890,9 +890,7 @@ static int isif_set_hw_if_params(struct vpfe_hw_if_param *params)
3172     static int isif_config_ycbcr(void)
3173     {
3174     struct isif_ycbcr_config *params = &isif_cfg.ycbcr;
3175     - struct vpss_pg_frame_size frame_size;
3176     u32 modeset = 0, ccdcfg = 0;
3177     - struct vpss_sync_pol sync;
3178    
3179     dev_dbg(isif_cfg.dev, "\nStarting isif_config_ycbcr...");
3180    
3181     @@ -980,13 +978,6 @@ static int isif_config_ycbcr(void)
3182     /* two fields are interleaved in memory */
3183     regw(0x00000249, SDOFST);
3184    
3185     - /* Setup test pattern if enabled */
3186     - if (isif_cfg.bayer.config_params.test_pat_gen) {
3187     - sync.ccdpg_hdpol = params->hd_pol;
3188     - sync.ccdpg_vdpol = params->vd_pol;
3189     - dm365_vpss_set_sync_pol(sync);
3190     - dm365_vpss_set_pg_frame_size(frame_size);
3191     - }
3192     return 0;
3193     }
3194    
3195     diff --git a/drivers/media/platform/davinci/vpbe.c b/drivers/media/platform/davinci/vpbe.c
3196     index abce9c4a1a8e..59518c08528b 100644
3197     --- a/drivers/media/platform/davinci/vpbe.c
3198     +++ b/drivers/media/platform/davinci/vpbe.c
3199     @@ -130,7 +130,7 @@ static int vpbe_enum_outputs(struct vpbe_device *vpbe_dev,
3200     struct v4l2_output *output)
3201     {
3202     struct vpbe_config *cfg = vpbe_dev->cfg;
3203     - int temp_index = output->index;
3204     + unsigned int temp_index = output->index;
3205    
3206     if (temp_index >= cfg->num_outputs)
3207     return -EINVAL;
3208     diff --git a/drivers/media/platform/omap/omap_vout.c b/drivers/media/platform/omap/omap_vout.c
3209     index a31b95cb3b09..77ec70f5fef6 100644
3210     --- a/drivers/media/platform/omap/omap_vout.c
3211     +++ b/drivers/media/platform/omap/omap_vout.c
3212     @@ -1526,23 +1526,20 @@ static int vidioc_dqbuf(struct file *file, void *fh, struct v4l2_buffer *b)
3213     unsigned long size;
3214     struct videobuf_buffer *vb;
3215    
3216     - vb = q->bufs[b->index];
3217     -
3218     if (!vout->streaming)
3219     return -EINVAL;
3220    
3221     - if (file->f_flags & O_NONBLOCK)
3222     - /* Call videobuf_dqbuf for non blocking mode */
3223     - ret = videobuf_dqbuf(q, (struct v4l2_buffer *)b, 1);
3224     - else
3225     - /* Call videobuf_dqbuf for blocking mode */
3226     - ret = videobuf_dqbuf(q, (struct v4l2_buffer *)b, 0);
3227     + ret = videobuf_dqbuf(q, b, !!(file->f_flags & O_NONBLOCK));
3228     + if (ret)
3229     + return ret;
3230     +
3231     + vb = q->bufs[b->index];
3232    
3233     addr = (unsigned long) vout->buf_phy_addr[vb->i];
3234     size = (unsigned long) vb->size;
3235     dma_unmap_single(vout->vid_dev->v4l2_dev.dev, addr,
3236     size, DMA_TO_DEVICE);
3237     - return ret;
3238     + return 0;
3239     }
3240    
3241     static int vidioc_streamon(struct file *file, void *fh, enum v4l2_buf_type i)
3242     diff --git a/drivers/media/platform/s5p-jpeg/jpeg-core.c b/drivers/media/platform/s5p-jpeg/jpeg-core.c
3243     index c89922fb42ce..a63f4eec366e 100644
3244     --- a/drivers/media/platform/s5p-jpeg/jpeg-core.c
3245     +++ b/drivers/media/platform/s5p-jpeg/jpeg-core.c
3246     @@ -1963,7 +1963,7 @@ static int s5p_jpeg_controls_create(struct s5p_jpeg_ctx *ctx)
3247    
3248     v4l2_ctrl_new_std(&ctx->ctrl_handler, &s5p_jpeg_ctrl_ops,
3249     V4L2_CID_JPEG_RESTART_INTERVAL,
3250     - 0, 3, 0xffff, 0);
3251     + 0, 0xffff, 1, 0);
3252     if (ctx->jpeg->variant->version == SJPEG_S5P)
3253     mask = ~0x06; /* 422, 420 */
3254     }
3255     diff --git a/drivers/media/platform/vivid/vivid-osd.c b/drivers/media/platform/vivid/vivid-osd.c
3256     index bdc380b14e0c..a95b7c56569e 100644
3257     --- a/drivers/media/platform/vivid/vivid-osd.c
3258     +++ b/drivers/media/platform/vivid/vivid-osd.c
3259     @@ -167,7 +167,7 @@ static int _vivid_fb_check_var(struct fb_var_screeninfo *var, struct vivid_dev *
3260     var->nonstd = 0;
3261    
3262     var->vmode &= ~FB_VMODE_MASK;
3263     - var->vmode = FB_VMODE_NONINTERLACED;
3264     + var->vmode |= FB_VMODE_NONINTERLACED;
3265    
3266     /* Dummy values */
3267     var->hsync_len = 24;
3268     diff --git a/drivers/media/radio/wl128x/fmdrv_common.c b/drivers/media/radio/wl128x/fmdrv_common.c
3269     index c1457cf46698..db987dda356e 100644
3270     --- a/drivers/media/radio/wl128x/fmdrv_common.c
3271     +++ b/drivers/media/radio/wl128x/fmdrv_common.c
3272     @@ -1278,8 +1278,9 @@ static int fm_download_firmware(struct fmdev *fmdev, const u8 *fw_name)
3273    
3274     switch (action->type) {
3275     case ACTION_SEND_COMMAND: /* Send */
3276     - if (fmc_send_cmd(fmdev, 0, 0, action->data,
3277     - action->size, NULL, NULL))
3278     + ret = fmc_send_cmd(fmdev, 0, 0, action->data,
3279     + action->size, NULL, NULL);
3280     + if (ret)
3281     goto rel_fw;
3282    
3283     cmd_cnt++;
3284     diff --git a/drivers/mfd/intel-lpss.c b/drivers/mfd/intel-lpss.c
3285     index 22dd8c055048..71cecd7aeea0 100644
3286     --- a/drivers/mfd/intel-lpss.c
3287     +++ b/drivers/mfd/intel-lpss.c
3288     @@ -533,6 +533,7 @@ module_init(intel_lpss_init);
3289    
3290     static void __exit intel_lpss_exit(void)
3291     {
3292     + ida_destroy(&intel_lpss_devid_ida);
3293     debugfs_remove(intel_lpss_debugfs);
3294     }
3295     module_exit(intel_lpss_exit);
3296     diff --git a/drivers/misc/mic/card/mic_x100.c b/drivers/misc/mic/card/mic_x100.c
3297     index b9f0710ffa6b..4007adc666f3 100644
3298     --- a/drivers/misc/mic/card/mic_x100.c
3299     +++ b/drivers/misc/mic/card/mic_x100.c
3300     @@ -249,6 +249,9 @@ static int __init mic_probe(struct platform_device *pdev)
3301     mdrv->dev = &pdev->dev;
3302     snprintf(mdrv->name, sizeof(mic_driver_name), mic_driver_name);
3303    
3304     + /* FIXME: use dma_set_mask_and_coherent() and check result */
3305     + dma_coerce_mask_and_coherent(&pdev->dev, DMA_BIT_MASK(64));
3306     +
3307     mdev->mmio.pa = MIC_X100_MMIO_BASE;
3308     mdev->mmio.len = MIC_X100_MMIO_LEN;
3309     mdev->mmio.va = devm_ioremap(&pdev->dev, MIC_X100_MMIO_BASE,
3310     @@ -294,18 +297,6 @@ static void mic_platform_shutdown(struct platform_device *pdev)
3311     mic_remove(pdev);
3312     }
3313    
3314     -static u64 mic_dma_mask = DMA_BIT_MASK(64);
3315     -
3316     -static struct platform_device mic_platform_dev = {
3317     - .name = mic_driver_name,
3318     - .id = 0,
3319     - .num_resources = 0,
3320     - .dev = {
3321     - .dma_mask = &mic_dma_mask,
3322     - .coherent_dma_mask = DMA_BIT_MASK(64),
3323     - },
3324     -};
3325     -
3326     static struct platform_driver __refdata mic_platform_driver = {
3327     .probe = mic_probe,
3328     .remove = mic_remove,
3329     @@ -315,6 +306,8 @@ static struct platform_driver __refdata mic_platform_driver = {
3330     },
3331     };
3332    
3333     +static struct platform_device *mic_platform_dev;
3334     +
3335     static int __init mic_init(void)
3336     {
3337     int ret;
3338     @@ -328,9 +321,12 @@ static int __init mic_init(void)
3339    
3340     request_module("mic_x100_dma");
3341     mic_init_card_debugfs();
3342     - ret = platform_device_register(&mic_platform_dev);
3343     +
3344     + mic_platform_dev = platform_device_register_simple(mic_driver_name,
3345     + 0, NULL, 0);
3346     + ret = PTR_ERR_OR_ZERO(mic_platform_dev);
3347     if (ret) {
3348     - pr_err("platform_device_register ret %d\n", ret);
3349     + pr_err("platform_device_register_full ret %d\n", ret);
3350     goto cleanup_debugfs;
3351     }
3352     ret = platform_driver_register(&mic_platform_driver);
3353     @@ -341,7 +337,7 @@ static int __init mic_init(void)
3354     return ret;
3355    
3356     device_unregister:
3357     - platform_device_unregister(&mic_platform_dev);
3358     + platform_device_unregister(mic_platform_dev);
3359     cleanup_debugfs:
3360     mic_exit_card_debugfs();
3361     done:
3362     @@ -351,7 +347,7 @@ done:
3363     static void __exit mic_exit(void)
3364     {
3365     platform_driver_unregister(&mic_platform_driver);
3366     - platform_device_unregister(&mic_platform_dev);
3367     + platform_device_unregister(mic_platform_dev);
3368     mic_exit_card_debugfs();
3369     }
3370    
3371     diff --git a/drivers/misc/sgi-xp/xpc_partition.c b/drivers/misc/sgi-xp/xpc_partition.c
3372     index 6956f7e7d439..ca5f0102daef 100644
3373     --- a/drivers/misc/sgi-xp/xpc_partition.c
3374     +++ b/drivers/misc/sgi-xp/xpc_partition.c
3375     @@ -70,7 +70,7 @@ xpc_get_rsvd_page_pa(int nasid)
3376     unsigned long rp_pa = nasid; /* seed with nasid */
3377     size_t len = 0;
3378     size_t buf_len = 0;
3379     - void *buf = buf;
3380     + void *buf = NULL;
3381     void *buf_base = NULL;
3382     enum xp_retval (*get_partition_rsvd_page_pa)
3383     (void *, u64 *, unsigned long *, size_t *) =
3384     diff --git a/drivers/mmc/host/sdhci-brcmstb.c b/drivers/mmc/host/sdhci-brcmstb.c
3385     index 159f6f64c68e..ed6473731b45 100644
3386     --- a/drivers/mmc/host/sdhci-brcmstb.c
3387     +++ b/drivers/mmc/host/sdhci-brcmstb.c
3388     @@ -90,7 +90,9 @@ static int sdhci_brcmstb_probe(struct platform_device *pdev)
3389     host->mmc->caps2 |= MMC_CAP2_HC_ERASE_SZ;
3390    
3391     sdhci_get_of_property(pdev);
3392     - mmc_of_parse(host->mmc);
3393     + res = mmc_of_parse(host->mmc);
3394     + if (res)
3395     + goto err;
3396    
3397     /*
3398     * Supply the existing CAPS, but clear the UHS modes. This
3399     diff --git a/drivers/mmc/host/sdhci-tegra.c b/drivers/mmc/host/sdhci-tegra.c
3400     index 088a3ae0dff0..ec1949045295 100644
3401     --- a/drivers/mmc/host/sdhci-tegra.c
3402     +++ b/drivers/mmc/host/sdhci-tegra.c
3403     @@ -174,7 +174,7 @@ static void tegra_sdhci_reset(struct sdhci_host *host, u8 mask)
3404     misc_ctrl |= SDHCI_MISC_CTRL_ENABLE_DDR50;
3405     if (soc_data->nvquirks & NVQUIRK_ENABLE_SDR104)
3406     misc_ctrl |= SDHCI_MISC_CTRL_ENABLE_SDR104;
3407     - if (soc_data->nvquirks & SDHCI_MISC_CTRL_ENABLE_SDR50)
3408     + if (soc_data->nvquirks & NVQUIRK_ENABLE_SDR50)
3409     clk_ctrl |= SDHCI_CLOCK_CTRL_SDR50_TUNING_OVERRIDE;
3410     }
3411    
3412     diff --git a/drivers/mmc/host/sdhci.c b/drivers/mmc/host/sdhci.c
3413     index bd43dc7f4c63..68b736547d81 100644
3414     --- a/drivers/mmc/host/sdhci.c
3415     +++ b/drivers/mmc/host/sdhci.c
3416     @@ -3243,11 +3243,13 @@ int sdhci_setup_host(struct sdhci_host *host)
3417     if (host->ops->get_min_clock)
3418     mmc->f_min = host->ops->get_min_clock(host);
3419     else if (host->version >= SDHCI_SPEC_300) {
3420     - if (host->clk_mul) {
3421     - mmc->f_min = (host->max_clk * host->clk_mul) / 1024;
3422     + if (host->clk_mul)
3423     max_clk = host->max_clk * host->clk_mul;
3424     - } else
3425     - mmc->f_min = host->max_clk / SDHCI_MAX_DIV_SPEC_300;
3426     + /*
3427     + * Divided Clock Mode minimum clock rate is always less than
3428     + * Programmable Clock Mode minimum clock rate.
3429     + */
3430     + mmc->f_min = host->max_clk / SDHCI_MAX_DIV_SPEC_300;
3431     } else
3432     mmc->f_min = host->max_clk / SDHCI_MAX_DIV_SPEC_200;
3433    
3434     diff --git a/drivers/net/can/slcan.c b/drivers/net/can/slcan.c
3435     index 020437900fce..453a2ea7895b 100644
3436     --- a/drivers/net/can/slcan.c
3437     +++ b/drivers/net/can/slcan.c
3438     @@ -344,9 +344,16 @@ static void slcan_transmit(struct work_struct *work)
3439     */
3440     static void slcan_write_wakeup(struct tty_struct *tty)
3441     {
3442     - struct slcan *sl = tty->disc_data;
3443     + struct slcan *sl;
3444     +
3445     + rcu_read_lock();
3446     + sl = rcu_dereference(tty->disc_data);
3447     + if (!sl)
3448     + goto out;
3449    
3450     schedule_work(&sl->tx_work);
3451     +out:
3452     + rcu_read_unlock();
3453     }
3454    
3455     /* Send a can_frame to a TTY queue. */
3456     @@ -640,10 +647,11 @@ static void slcan_close(struct tty_struct *tty)
3457     return;
3458    
3459     spin_lock_bh(&sl->lock);
3460     - tty->disc_data = NULL;
3461     + rcu_assign_pointer(tty->disc_data, NULL);
3462     sl->tty = NULL;
3463     spin_unlock_bh(&sl->lock);
3464    
3465     + synchronize_rcu();
3466     flush_work(&sl->tx_work);
3467    
3468     /* Flush network side */
3469     diff --git a/drivers/net/dsa/qca8k.c b/drivers/net/dsa/qca8k.c
3470     index ebfbaf8597f4..3bbe85aae49b 100644
3471     --- a/drivers/net/dsa/qca8k.c
3472     +++ b/drivers/net/dsa/qca8k.c
3473     @@ -460,6 +460,18 @@ qca8k_set_pad_ctrl(struct qca8k_priv *priv, int port, int mode)
3474     qca8k_write(priv, QCA8K_REG_PORT5_PAD_CTRL,
3475     QCA8K_PORT_PAD_RGMII_RX_DELAY_EN);
3476     break;
3477     + case PHY_INTERFACE_MODE_RGMII_ID:
3478     + /* RGMII_ID needs internal delay. This is enabled through
3479     + * PORT5_PAD_CTRL for all ports, rather than individual port
3480     + * registers
3481     + */
3482     + qca8k_write(priv, reg,
3483     + QCA8K_PORT_PAD_RGMII_EN |
3484     + QCA8K_PORT_PAD_RGMII_TX_DELAY(QCA8K_MAX_DELAY) |
3485     + QCA8K_PORT_PAD_RGMII_RX_DELAY(QCA8K_MAX_DELAY));
3486     + qca8k_write(priv, QCA8K_REG_PORT5_PAD_CTRL,
3487     + QCA8K_PORT_PAD_RGMII_RX_DELAY_EN);
3488     + break;
3489     case PHY_INTERFACE_MODE_SGMII:
3490     qca8k_write(priv, reg, QCA8K_PORT_PAD_SGMII_EN);
3491     break;
3492     diff --git a/drivers/net/dsa/qca8k.h b/drivers/net/dsa/qca8k.h
3493     index 9c22bc3210cd..db95168ca111 100644
3494     --- a/drivers/net/dsa/qca8k.h
3495     +++ b/drivers/net/dsa/qca8k.h
3496     @@ -40,6 +40,7 @@
3497     ((0x8 + (x & 0x3)) << 22)
3498     #define QCA8K_PORT_PAD_RGMII_RX_DELAY(x) \
3499     ((0x10 + (x & 0x3)) << 20)
3500     +#define QCA8K_MAX_DELAY 3
3501     #define QCA8K_PORT_PAD_RGMII_RX_DELAY_EN BIT(24)
3502     #define QCA8K_PORT_PAD_SGMII_EN BIT(7)
3503     #define QCA8K_REG_MODULE_EN 0x030
3504     diff --git a/drivers/net/ethernet/amazon/ena/ena_com.c b/drivers/net/ethernet/amazon/ena/ena_com.c
3505     index bcd993140f84..912dc09bc7a7 100644
3506     --- a/drivers/net/ethernet/amazon/ena/ena_com.c
3507     +++ b/drivers/net/ethernet/amazon/ena/ena_com.c
3508     @@ -1967,7 +1967,7 @@ int ena_com_set_hash_function(struct ena_com_dev *ena_dev)
3509     if (unlikely(ret))
3510     return ret;
3511    
3512     - if (get_resp.u.flow_hash_func.supported_func & (1 << rss->hash_func)) {
3513     + if (!(get_resp.u.flow_hash_func.supported_func & BIT(rss->hash_func))) {
3514     pr_err("Func hash %d isn't supported by device, abort\n",
3515     rss->hash_func);
3516     return -EPERM;
3517     @@ -2052,6 +2052,7 @@ int ena_com_fill_hash_function(struct ena_com_dev *ena_dev,
3518     return -EINVAL;
3519     }
3520    
3521     + rss->hash_func = func;
3522     rc = ena_com_set_hash_function(ena_dev);
3523    
3524     /* Restore the old function */
3525     diff --git a/drivers/net/ethernet/amazon/ena/ena_ethtool.c b/drivers/net/ethernet/amazon/ena/ena_ethtool.c
3526     index 67b2338f8fb3..06fd061a20e9 100644
3527     --- a/drivers/net/ethernet/amazon/ena/ena_ethtool.c
3528     +++ b/drivers/net/ethernet/amazon/ena/ena_ethtool.c
3529     @@ -697,8 +697,8 @@ static int ena_set_rxfh(struct net_device *netdev, const u32 *indir,
3530     if (indir) {
3531     for (i = 0; i < ENA_RX_RSS_TABLE_SIZE; i++) {
3532     rc = ena_com_indirect_table_fill_entry(ena_dev,
3533     - ENA_IO_RXQ_IDX(indir[i]),
3534     - i);
3535     + i,
3536     + ENA_IO_RXQ_IDX(indir[i]));
3537     if (unlikely(rc)) {
3538     netif_err(adapter, drv, netdev,
3539     "Cannot fill indirect table (index is too large)\n");
3540     diff --git a/drivers/net/ethernet/amazon/ena/ena_netdev.c b/drivers/net/ethernet/amazon/ena/ena_netdev.c
3541     index 961f31c8356b..da21886609e3 100644
3542     --- a/drivers/net/ethernet/amazon/ena/ena_netdev.c
3543     +++ b/drivers/net/ethernet/amazon/ena/ena_netdev.c
3544     @@ -1702,6 +1702,7 @@ err_setup_rx:
3545     err_setup_tx:
3546     ena_free_io_irq(adapter);
3547     err_req_irq:
3548     + ena_del_napi(adapter);
3549    
3550     return rc;
3551     }
3552     diff --git a/drivers/net/ethernet/broadcom/bcmsysport.c b/drivers/net/ethernet/broadcom/bcmsysport.c
3553     index 95874c10c23b..e3b41af65d18 100644
3554     --- a/drivers/net/ethernet/broadcom/bcmsysport.c
3555     +++ b/drivers/net/ethernet/broadcom/bcmsysport.c
3556     @@ -1773,7 +1773,7 @@ static int bcm_sysport_probe(struct platform_device *pdev)
3557    
3558     priv->phy_interface = of_get_phy_mode(dn);
3559     /* Default to GMII interface mode */
3560     - if (priv->phy_interface < 0)
3561     + if ((int)priv->phy_interface < 0)
3562     priv->phy_interface = PHY_INTERFACE_MODE_GMII;
3563    
3564     /* In the case of a fixed PHY, the DT node associated
3565     diff --git a/drivers/net/ethernet/chelsio/cxgb3/cxgb3_main.c b/drivers/net/ethernet/chelsio/cxgb3/cxgb3_main.c
3566     index d1a2159e40d6..9627ed0b2f1c 100644
3567     --- a/drivers/net/ethernet/chelsio/cxgb3/cxgb3_main.c
3568     +++ b/drivers/net/ethernet/chelsio/cxgb3/cxgb3_main.c
3569     @@ -2440,6 +2440,8 @@ static int cxgb_extension_ioctl(struct net_device *dev, void __user *useraddr)
3570    
3571     if (!is_offload(adapter))
3572     return -EOPNOTSUPP;
3573     + if (!capable(CAP_NET_ADMIN))
3574     + return -EPERM;
3575     if (!(adapter->flags & FULL_INIT_DONE))
3576     return -EIO; /* need the memory controllers */
3577     if (copy_from_user(&t, useraddr, sizeof(t)))
3578     diff --git a/drivers/net/ethernet/hisilicon/hix5hd2_gmac.c b/drivers/net/ethernet/hisilicon/hix5hd2_gmac.c
3579     index e69a6bed31a9..dd24c352b200 100644
3580     --- a/drivers/net/ethernet/hisilicon/hix5hd2_gmac.c
3581     +++ b/drivers/net/ethernet/hisilicon/hix5hd2_gmac.c
3582     @@ -929,7 +929,7 @@ static int hix5hd2_dev_probe(struct platform_device *pdev)
3583     goto err_free_mdio;
3584    
3585     priv->phy_mode = of_get_phy_mode(node);
3586     - if (priv->phy_mode < 0) {
3587     + if ((int)priv->phy_mode < 0) {
3588     netdev_err(ndev, "not find phy-mode\n");
3589     ret = -EINVAL;
3590     goto err_mdiobus;
3591     diff --git a/drivers/net/ethernet/ibm/ehea/ehea_main.c b/drivers/net/ethernet/ibm/ehea/ehea_main.c
3592     index 2dd17e01e3a7..3692adb8902d 100644
3593     --- a/drivers/net/ethernet/ibm/ehea/ehea_main.c
3594     +++ b/drivers/net/ethernet/ibm/ehea/ehea_main.c
3595     @@ -1476,7 +1476,7 @@ static int ehea_init_port_res(struct ehea_port *port, struct ehea_port_res *pr,
3596    
3597     memset(pr, 0, sizeof(struct ehea_port_res));
3598    
3599     - pr->tx_bytes = rx_bytes;
3600     + pr->tx_bytes = tx_bytes;
3601     pr->tx_packets = tx_packets;
3602     pr->rx_bytes = rx_bytes;
3603     pr->rx_packets = rx_packets;
3604     diff --git a/drivers/net/ethernet/mellanox/mlxsw/reg.h b/drivers/net/ethernet/mellanox/mlxsw/reg.h
3605     index b2a745b579fd..fdc69218c8ca 100644
3606     --- a/drivers/net/ethernet/mellanox/mlxsw/reg.h
3607     +++ b/drivers/net/ethernet/mellanox/mlxsw/reg.h
3608     @@ -1873,7 +1873,7 @@ static inline void mlxsw_reg_qtct_pack(char *payload, u8 local_port,
3609     * Configures the ETS elements.
3610     */
3611     #define MLXSW_REG_QEEC_ID 0x400D
3612     -#define MLXSW_REG_QEEC_LEN 0x1C
3613     +#define MLXSW_REG_QEEC_LEN 0x20
3614    
3615     static const struct mlxsw_reg_info mlxsw_reg_qeec = {
3616     .id = MLXSW_REG_QEEC_ID,
3617     @@ -1918,6 +1918,15 @@ MLXSW_ITEM32(reg, qeec, element_index, 0x04, 0, 8);
3618     */
3619     MLXSW_ITEM32(reg, qeec, next_element_index, 0x08, 0, 8);
3620    
3621     +/* reg_qeec_mise
3622     + * Min shaper configuration enable. Enables configuration of the min
3623     + * shaper on this ETS element
3624     + * 0 - Disable
3625     + * 1 - Enable
3626     + * Access: RW
3627     + */
3628     +MLXSW_ITEM32(reg, qeec, mise, 0x0C, 31, 1);
3629     +
3630     enum {
3631     MLXSW_REG_QEEC_BYTES_MODE,
3632     MLXSW_REG_QEEC_PACKETS_MODE,
3633     @@ -1934,6 +1943,17 @@ enum {
3634     */
3635     MLXSW_ITEM32(reg, qeec, pb, 0x0C, 28, 1);
3636    
3637     +/* The smallest permitted min shaper rate. */
3638     +#define MLXSW_REG_QEEC_MIS_MIN 200000 /* Kbps */
3639     +
3640     +/* reg_qeec_min_shaper_rate
3641     + * Min shaper information rate.
3642     + * For CPU port, can only be configured for port hierarchy.
3643     + * When in bytes mode, value is specified in units of 1000bps.
3644     + * Access: RW
3645     + */
3646     +MLXSW_ITEM32(reg, qeec, min_shaper_rate, 0x0C, 0, 28);
3647     +
3648     /* reg_qeec_mase
3649     * Max shaper configuration enable. Enables configuration of the max
3650     * shaper on this ETS element.
3651     diff --git a/drivers/net/ethernet/natsemi/sonic.c b/drivers/net/ethernet/natsemi/sonic.c
3652     index 23821540ab07..a051dddcbd76 100644
3653     --- a/drivers/net/ethernet/natsemi/sonic.c
3654     +++ b/drivers/net/ethernet/natsemi/sonic.c
3655     @@ -221,9 +221,9 @@ static int sonic_send_packet(struct sk_buff *skb, struct net_device *dev)
3656    
3657     laddr = dma_map_single(lp->device, skb->data, length, DMA_TO_DEVICE);
3658     if (!laddr) {
3659     - printk(KERN_ERR "%s: failed to map tx DMA buffer.\n", dev->name);
3660     - dev_kfree_skb(skb);
3661     - return NETDEV_TX_BUSY;
3662     + pr_err_ratelimited("%s: failed to map tx DMA buffer.\n", dev->name);
3663     + dev_kfree_skb_any(skb);
3664     + return NETDEV_TX_OK;
3665     }
3666    
3667     sonic_tda_put(dev, entry, SONIC_TD_STATUS, 0); /* clear status */
3668     diff --git a/drivers/net/ethernet/pasemi/pasemi_mac.c b/drivers/net/ethernet/pasemi/pasemi_mac.c
3669     index 2f4a837f0d6a..dcd56ac68748 100644
3670     --- a/drivers/net/ethernet/pasemi/pasemi_mac.c
3671     +++ b/drivers/net/ethernet/pasemi/pasemi_mac.c
3672     @@ -1053,7 +1053,6 @@ static int pasemi_mac_phy_init(struct net_device *dev)
3673    
3674     dn = pci_device_to_OF_node(mac->pdev);
3675     phy_dn = of_parse_phandle(dn, "phy-handle", 0);
3676     - of_node_put(phy_dn);
3677    
3678     mac->link = 0;
3679     mac->speed = 0;
3680     @@ -1062,6 +1061,7 @@ static int pasemi_mac_phy_init(struct net_device *dev)
3681     phydev = of_phy_connect(dev, phy_dn, &pasemi_adjust_link, 0,
3682     PHY_INTERFACE_MODE_SGMII);
3683    
3684     + of_node_put(phy_dn);
3685     if (!phydev) {
3686     printk(KERN_ERR "%s: Could not attach to phy\n", dev->name);
3687     return -ENODEV;
3688     diff --git a/drivers/net/ethernet/qlogic/qed/qed_l2.c b/drivers/net/ethernet/qlogic/qed/qed_l2.c
3689     index 715776e2cfe5..2d198f6ee21d 100644
3690     --- a/drivers/net/ethernet/qlogic/qed/qed_l2.c
3691     +++ b/drivers/net/ethernet/qlogic/qed/qed_l2.c
3692     @@ -1328,10 +1328,9 @@ static void __qed_get_vport_pstats_addrlen(struct qed_hwfn *p_hwfn,
3693     }
3694     }
3695    
3696     -static void __qed_get_vport_pstats(struct qed_hwfn *p_hwfn,
3697     - struct qed_ptt *p_ptt,
3698     - struct qed_eth_stats *p_stats,
3699     - u16 statistics_bin)
3700     +static noinline_for_stack void
3701     +__qed_get_vport_pstats(struct qed_hwfn *p_hwfn, struct qed_ptt *p_ptt,
3702     + struct qed_eth_stats *p_stats, u16 statistics_bin)
3703     {
3704     struct eth_pstorm_per_queue_stat pstats;
3705     u32 pstats_addr = 0, pstats_len = 0;
3706     @@ -1351,10 +1350,9 @@ static void __qed_get_vport_pstats(struct qed_hwfn *p_hwfn,
3707     p_stats->tx_err_drop_pkts += HILO_64_REGPAIR(pstats.error_drop_pkts);
3708     }
3709    
3710     -static void __qed_get_vport_tstats(struct qed_hwfn *p_hwfn,
3711     - struct qed_ptt *p_ptt,
3712     - struct qed_eth_stats *p_stats,
3713     - u16 statistics_bin)
3714     +static noinline_for_stack void
3715     +__qed_get_vport_tstats(struct qed_hwfn *p_hwfn, struct qed_ptt *p_ptt,
3716     + struct qed_eth_stats *p_stats, u16 statistics_bin)
3717     {
3718     struct tstorm_per_port_stat tstats;
3719     u32 tstats_addr, tstats_len;
3720     @@ -1397,10 +1395,9 @@ static void __qed_get_vport_ustats_addrlen(struct qed_hwfn *p_hwfn,
3721     }
3722     }
3723    
3724     -static void __qed_get_vport_ustats(struct qed_hwfn *p_hwfn,
3725     - struct qed_ptt *p_ptt,
3726     - struct qed_eth_stats *p_stats,
3727     - u16 statistics_bin)
3728     +static noinline_for_stack
3729     +void __qed_get_vport_ustats(struct qed_hwfn *p_hwfn, struct qed_ptt *p_ptt,
3730     + struct qed_eth_stats *p_stats, u16 statistics_bin)
3731     {
3732     struct eth_ustorm_per_queue_stat ustats;
3733     u32 ustats_addr = 0, ustats_len = 0;
3734     @@ -1436,10 +1433,9 @@ static void __qed_get_vport_mstats_addrlen(struct qed_hwfn *p_hwfn,
3735     }
3736     }
3737    
3738     -static void __qed_get_vport_mstats(struct qed_hwfn *p_hwfn,
3739     - struct qed_ptt *p_ptt,
3740     - struct qed_eth_stats *p_stats,
3741     - u16 statistics_bin)
3742     +static noinline_for_stack void
3743     +__qed_get_vport_mstats(struct qed_hwfn *p_hwfn, struct qed_ptt *p_ptt,
3744     + struct qed_eth_stats *p_stats, u16 statistics_bin)
3745     {
3746     struct eth_mstorm_per_queue_stat mstats;
3747     u32 mstats_addr = 0, mstats_len = 0;
3748     @@ -1463,9 +1459,9 @@ static void __qed_get_vport_mstats(struct qed_hwfn *p_hwfn,
3749     HILO_64_REGPAIR(mstats.tpa_coalesced_bytes);
3750     }
3751    
3752     -static void __qed_get_vport_port_stats(struct qed_hwfn *p_hwfn,
3753     - struct qed_ptt *p_ptt,
3754     - struct qed_eth_stats *p_stats)
3755     +static noinline_for_stack void
3756     +__qed_get_vport_port_stats(struct qed_hwfn *p_hwfn, struct qed_ptt *p_ptt,
3757     + struct qed_eth_stats *p_stats)
3758     {
3759     struct port_stats port_stats;
3760     int j;
3761     diff --git a/drivers/net/ethernet/qualcomm/qca_spi.c b/drivers/net/ethernet/qualcomm/qca_spi.c
3762     index 21f546587e3d..31583d6f044f 100644
3763     --- a/drivers/net/ethernet/qualcomm/qca_spi.c
3764     +++ b/drivers/net/ethernet/qualcomm/qca_spi.c
3765     @@ -438,7 +438,6 @@ qcaspi_qca7k_sync(struct qcaspi *qca, int event)
3766     u16 signature = 0;
3767     u16 spi_config;
3768     u16 wrbuf_space = 0;
3769     - static u16 reset_count;
3770    
3771     if (event == QCASPI_EVENT_CPUON) {
3772     /* Read signature twice, if not valid
3773     @@ -491,13 +490,13 @@ qcaspi_qca7k_sync(struct qcaspi *qca, int event)
3774    
3775     qca->sync = QCASPI_SYNC_RESET;
3776     qca->stats.trig_reset++;
3777     - reset_count = 0;
3778     + qca->reset_count = 0;
3779     break;
3780     case QCASPI_SYNC_RESET:
3781     - reset_count++;
3782     + qca->reset_count++;
3783     netdev_dbg(qca->net_dev, "sync: waiting for CPU on, count %u.\n",
3784     - reset_count);
3785     - if (reset_count >= QCASPI_RESET_TIMEOUT) {
3786     + qca->reset_count);
3787     + if (qca->reset_count >= QCASPI_RESET_TIMEOUT) {
3788     /* reset did not seem to take place, try again */
3789     qca->sync = QCASPI_SYNC_UNKNOWN;
3790     qca->stats.reset_timeout++;
3791     diff --git a/drivers/net/ethernet/qualcomm/qca_spi.h b/drivers/net/ethernet/qualcomm/qca_spi.h
3792     index 6e31a0e744a4..c48c314ca4df 100644
3793     --- a/drivers/net/ethernet/qualcomm/qca_spi.h
3794     +++ b/drivers/net/ethernet/qualcomm/qca_spi.h
3795     @@ -97,6 +97,7 @@ struct qcaspi {
3796    
3797     unsigned int intr_req;
3798     unsigned int intr_svc;
3799     + u16 reset_count;
3800    
3801     #ifdef CONFIG_DEBUG_FS
3802     struct dentry *device_root;
3803     diff --git a/drivers/net/ethernet/renesas/sh_eth.c b/drivers/net/ethernet/renesas/sh_eth.c
3804     index 49300194d3f9..6f8d4810ce97 100644
3805     --- a/drivers/net/ethernet/renesas/sh_eth.c
3806     +++ b/drivers/net/ethernet/renesas/sh_eth.c
3807     @@ -2929,12 +2929,16 @@ static struct sh_eth_plat_data *sh_eth_parse_dt(struct device *dev)
3808     struct device_node *np = dev->of_node;
3809     struct sh_eth_plat_data *pdata;
3810     const char *mac_addr;
3811     + int ret;
3812    
3813     pdata = devm_kzalloc(dev, sizeof(*pdata), GFP_KERNEL);
3814     if (!pdata)
3815     return NULL;
3816    
3817     - pdata->phy_interface = of_get_phy_mode(np);
3818     + ret = of_get_phy_mode(np);
3819     + if (ret < 0)
3820     + return NULL;
3821     + pdata->phy_interface = ret;
3822    
3823     mac_addr = of_get_mac_address(np);
3824     if (mac_addr)
3825     diff --git a/drivers/net/ethernet/stmicro/stmmac/dwmac-ipq806x.c b/drivers/net/ethernet/stmicro/stmmac/dwmac-ipq806x.c
3826     index 866444b6c82f..11a4a81b0397 100644
3827     --- a/drivers/net/ethernet/stmicro/stmmac/dwmac-ipq806x.c
3828     +++ b/drivers/net/ethernet/stmicro/stmmac/dwmac-ipq806x.c
3829     @@ -203,7 +203,7 @@ static int ipq806x_gmac_of_parse(struct ipq806x_gmac *gmac)
3830     struct device *dev = &gmac->pdev->dev;
3831    
3832     gmac->phy_mode = of_get_phy_mode(dev->of_node);
3833     - if (gmac->phy_mode < 0) {
3834     + if ((int)gmac->phy_mode < 0) {
3835     dev_err(dev, "missing phy mode property\n");
3836     return -EINVAL;
3837     }
3838     diff --git a/drivers/net/ethernet/stmicro/stmmac/dwmac-meson8b.c b/drivers/net/ethernet/stmicro/stmmac/dwmac-meson8b.c
3839     index f356a44bcb81..6704d3e0392d 100644
3840     --- a/drivers/net/ethernet/stmicro/stmmac/dwmac-meson8b.c
3841     +++ b/drivers/net/ethernet/stmicro/stmmac/dwmac-meson8b.c
3842     @@ -280,7 +280,7 @@ static int meson8b_dwmac_probe(struct platform_device *pdev)
3843    
3844     dwmac->pdev = pdev;
3845     dwmac->phy_mode = of_get_phy_mode(pdev->dev.of_node);
3846     - if (dwmac->phy_mode < 0) {
3847     + if ((int)dwmac->phy_mode < 0) {
3848     dev_err(&pdev->dev, "missing phy-mode property\n");
3849     ret = -EINVAL;
3850     goto err_remove_config_dt;
3851     diff --git a/drivers/net/ethernet/stmicro/stmmac/dwmac4_core.c b/drivers/net/ethernet/stmicro/stmmac/dwmac4_core.c
3852     index f46f2bfc2cc0..4216c0a5eaf5 100644
3853     --- a/drivers/net/ethernet/stmicro/stmmac/dwmac4_core.c
3854     +++ b/drivers/net/ethernet/stmicro/stmmac/dwmac4_core.c
3855     @@ -168,7 +168,7 @@ static void dwmac4_set_filter(struct mac_device_info *hw,
3856     }
3857    
3858     /* Handle multiple unicast addresses */
3859     - if (netdev_uc_count(dev) > GMAC_MAX_PERFECT_ADDRESSES) {
3860     + if (netdev_uc_count(dev) > hw->unicast_filter_entries) {
3861     /* Switch to promiscuous mode if more than 128 addrs
3862     * are required
3863     */
3864     diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_ptp.c b/drivers/net/ethernet/stmicro/stmmac/stmmac_ptp.c
3865     index 3eb281d1db08..231330809037 100644
3866     --- a/drivers/net/ethernet/stmicro/stmmac/stmmac_ptp.c
3867     +++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_ptp.c
3868     @@ -158,7 +158,7 @@ static int stmmac_enable(struct ptp_clock_info *ptp,
3869     /* structure describing a PTP hardware clock */
3870     static struct ptp_clock_info stmmac_ptp_clock_ops = {
3871     .owner = THIS_MODULE,
3872     - .name = "stmmac_ptp_clock",
3873     + .name = "stmmac ptp",
3874     .max_adj = 62500000,
3875     .n_alarm = 0,
3876     .n_ext_ts = 0,
3877     diff --git a/drivers/net/gtp.c b/drivers/net/gtp.c
3878     index c2898718b593..5077c69eb652 100644
3879     --- a/drivers/net/gtp.c
3880     +++ b/drivers/net/gtp.c
3881     @@ -836,7 +836,9 @@ static int gtp_encap_enable(struct net_device *dev, struct gtp_dev *gtp,
3882     return -ENOENT;
3883     }
3884    
3885     - if (sock0->sk->sk_protocol != IPPROTO_UDP) {
3886     + if (sock0->sk->sk_protocol != IPPROTO_UDP ||
3887     + sock0->sk->sk_type != SOCK_DGRAM ||
3888     + (sock0->sk->sk_family != AF_INET && sock0->sk->sk_family != AF_INET6)) {
3889     netdev_dbg(dev, "socket fd=%d not UDP\n", fd_gtp0);
3890     err = -EINVAL;
3891     goto err1;
3892     diff --git a/drivers/net/phy/fixed_phy.c b/drivers/net/phy/fixed_phy.c
3893     index eb5167210681..3ab2eb677a59 100644
3894     --- a/drivers/net/phy/fixed_phy.c
3895     +++ b/drivers/net/phy/fixed_phy.c
3896     @@ -67,11 +67,11 @@ static int fixed_mdio_read(struct mii_bus *bus, int phy_addr, int reg_num)
3897     do {
3898     s = read_seqcount_begin(&fp->seqcount);
3899     /* Issue callback if user registered it. */
3900     - if (fp->link_update) {
3901     + if (fp->link_update)
3902     fp->link_update(fp->phydev->attached_dev,
3903     &fp->status);
3904     - fixed_phy_update(fp);
3905     - }
3906     + /* Check the GPIO for change in status */
3907     + fixed_phy_update(fp);
3908     state = fp->status;
3909     } while (read_seqcount_retry(&fp->seqcount, s));
3910    
3911     diff --git a/drivers/net/phy/phy.c b/drivers/net/phy/phy.c
3912     index 5fde8e335f13..82a4487bc66e 100644
3913     --- a/drivers/net/phy/phy.c
3914     +++ b/drivers/net/phy/phy.c
3915     @@ -463,7 +463,8 @@ int phy_ethtool_ksettings_get(struct phy_device *phydev,
3916     cmd->base.port = PORT_BNC;
3917     else
3918     cmd->base.port = PORT_MII;
3919     -
3920     + cmd->base.transceiver = phy_is_internal(phydev) ?
3921     + XCVR_INTERNAL : XCVR_EXTERNAL;
3922     cmd->base.phy_address = phydev->mdio.addr;
3923     cmd->base.autoneg = phydev->autoneg;
3924     cmd->base.eth_tp_mdix_ctrl = phydev->mdix;
3925     diff --git a/drivers/net/phy/phy_device.c b/drivers/net/phy/phy_device.c
3926     index 3289fd910c4a..487d0372a444 100644
3927     --- a/drivers/net/phy/phy_device.c
3928     +++ b/drivers/net/phy/phy_device.c
3929     @@ -80,7 +80,7 @@ static LIST_HEAD(phy_fixup_list);
3930     static DEFINE_MUTEX(phy_fixup_lock);
3931    
3932     #ifdef CONFIG_PM
3933     -static bool mdio_bus_phy_may_suspend(struct phy_device *phydev)
3934     +static bool mdio_bus_phy_may_suspend(struct phy_device *phydev, bool suspend)
3935     {
3936     struct device_driver *drv = phydev->mdio.dev.driver;
3937     struct phy_driver *phydrv = to_phy_driver(drv);
3938     @@ -92,10 +92,11 @@ static bool mdio_bus_phy_may_suspend(struct phy_device *phydev)
3939     /* PHY not attached? May suspend if the PHY has not already been
3940     * suspended as part of a prior call to phy_disconnect() ->
3941     * phy_detach() -> phy_suspend() because the parent netdev might be the
3942     - * MDIO bus driver and clock gated at this point.
3943     + * MDIO bus driver and clock gated at this point. Also may resume if
3944     + * PHY is not attached.
3945     */
3946     if (!netdev)
3947     - return !phydev->suspended;
3948     + return suspend ? !phydev->suspended : phydev->suspended;
3949    
3950     /* Don't suspend PHY if the attached netdev parent may wakeup.
3951     * The parent may point to a PCI device, as in tg3 driver.
3952     @@ -125,7 +126,7 @@ static int mdio_bus_phy_suspend(struct device *dev)
3953     if (phydev->attached_dev && phydev->adjust_link)
3954     phy_stop_machine(phydev);
3955    
3956     - if (!mdio_bus_phy_may_suspend(phydev))
3957     + if (!mdio_bus_phy_may_suspend(phydev, true))
3958     return 0;
3959    
3960     return phy_suspend(phydev);
3961     @@ -136,7 +137,7 @@ static int mdio_bus_phy_resume(struct device *dev)
3962     struct phy_device *phydev = to_phy_device(dev);
3963     int ret;
3964    
3965     - if (!mdio_bus_phy_may_suspend(phydev))
3966     + if (!mdio_bus_phy_may_suspend(phydev, false))
3967     goto no_resume;
3968    
3969     ret = phy_resume(phydev);
3970     diff --git a/drivers/net/slip/slip.c b/drivers/net/slip/slip.c
3971     index 7ec96c3e38a6..2af09c3851a5 100644
3972     --- a/drivers/net/slip/slip.c
3973     +++ b/drivers/net/slip/slip.c
3974     @@ -452,9 +452,16 @@ static void slip_transmit(struct work_struct *work)
3975     */
3976     static void slip_write_wakeup(struct tty_struct *tty)
3977     {
3978     - struct slip *sl = tty->disc_data;
3979     + struct slip *sl;
3980     +
3981     + rcu_read_lock();
3982     + sl = rcu_dereference(tty->disc_data);
3983     + if (!sl)
3984     + goto out;
3985    
3986     schedule_work(&sl->tx_work);
3987     +out:
3988     + rcu_read_unlock();
3989     }
3990    
3991     static void sl_tx_timeout(struct net_device *dev)
3992     @@ -887,10 +894,11 @@ static void slip_close(struct tty_struct *tty)
3993     return;
3994    
3995     spin_lock_bh(&sl->lock);
3996     - tty->disc_data = NULL;
3997     + rcu_assign_pointer(tty->disc_data, NULL);
3998     sl->tty = NULL;
3999     spin_unlock_bh(&sl->lock);
4000    
4001     + synchronize_rcu();
4002     flush_work(&sl->tx_work);
4003    
4004     /* VSV = very important to remove timers */
4005     diff --git a/drivers/net/usb/lan78xx.c b/drivers/net/usb/lan78xx.c
4006     index 473dd79e167b..65e94dffaabc 100644
4007     --- a/drivers/net/usb/lan78xx.c
4008     +++ b/drivers/net/usb/lan78xx.c
4009     @@ -30,6 +30,7 @@
4010     #include <linux/ipv6.h>
4011     #include <linux/mdio.h>
4012     #include <net/ip6_checksum.h>
4013     +#include <net/vxlan.h>
4014     #include <linux/microchipphy.h>
4015     #include <linux/of_net.h>
4016     #include "lan78xx.h"
4017     @@ -3291,6 +3292,19 @@ static void lan78xx_tx_timeout(struct net_device *net)
4018     tasklet_schedule(&dev->bh);
4019     }
4020    
4021     +static netdev_features_t lan78xx_features_check(struct sk_buff *skb,
4022     + struct net_device *netdev,
4023     + netdev_features_t features)
4024     +{
4025     + if (skb->len + TX_OVERHEAD > MAX_SINGLE_PACKET_SIZE)
4026     + features &= ~NETIF_F_GSO_MASK;
4027     +
4028     + features = vlan_features_check(skb, features);
4029     + features = vxlan_features_check(skb, features);
4030     +
4031     + return features;
4032     +}
4033     +
4034     static const struct net_device_ops lan78xx_netdev_ops = {
4035     .ndo_open = lan78xx_open,
4036     .ndo_stop = lan78xx_stop,
4037     @@ -3304,6 +3318,7 @@ static const struct net_device_ops lan78xx_netdev_ops = {
4038     .ndo_set_features = lan78xx_set_features,
4039     .ndo_vlan_rx_add_vid = lan78xx_vlan_rx_add_vid,
4040     .ndo_vlan_rx_kill_vid = lan78xx_vlan_rx_kill_vid,
4041     + .ndo_features_check = lan78xx_features_check,
4042     };
4043    
4044     static void lan78xx_stat_monitor(unsigned long param)
4045     diff --git a/drivers/net/wireless/ath/ath9k/dynack.c b/drivers/net/wireless/ath/ath9k/dynack.c
4046     index 6e236a485431..71b4888b30e7 100644
4047     --- a/drivers/net/wireless/ath/ath9k/dynack.c
4048     +++ b/drivers/net/wireless/ath/ath9k/dynack.c
4049     @@ -300,9 +300,9 @@ void ath_dynack_node_init(struct ath_hw *ah, struct ath_node *an)
4050    
4051     an->ackto = ackto;
4052    
4053     - spin_lock(&da->qlock);
4054     + spin_lock_bh(&da->qlock);
4055     list_add_tail(&an->list, &da->nodes);
4056     - spin_unlock(&da->qlock);
4057     + spin_unlock_bh(&da->qlock);
4058     }
4059     EXPORT_SYMBOL(ath_dynack_node_init);
4060    
4061     @@ -316,9 +316,9 @@ void ath_dynack_node_deinit(struct ath_hw *ah, struct ath_node *an)
4062     {
4063     struct ath_dynack *da = &ah->dynack;
4064    
4065     - spin_lock(&da->qlock);
4066     + spin_lock_bh(&da->qlock);
4067     list_del(&an->list);
4068     - spin_unlock(&da->qlock);
4069     + spin_unlock_bh(&da->qlock);
4070     }
4071     EXPORT_SYMBOL(ath_dynack_node_deinit);
4072    
4073     diff --git a/drivers/net/wireless/intel/iwlwifi/mvm/fw.c b/drivers/net/wireless/intel/iwlwifi/mvm/fw.c
4074     index 2ec3a91a0f6b..bba7ace1a744 100644
4075     --- a/drivers/net/wireless/intel/iwlwifi/mvm/fw.c
4076     +++ b/drivers/net/wireless/intel/iwlwifi/mvm/fw.c
4077     @@ -106,12 +106,12 @@ static int iwl_send_rss_cfg_cmd(struct iwl_mvm *mvm)
4078     int i;
4079     struct iwl_rss_config_cmd cmd = {
4080     .flags = cpu_to_le32(IWL_RSS_ENABLE),
4081     - .hash_mask = IWL_RSS_HASH_TYPE_IPV4_TCP |
4082     - IWL_RSS_HASH_TYPE_IPV4_UDP |
4083     - IWL_RSS_HASH_TYPE_IPV4_PAYLOAD |
4084     - IWL_RSS_HASH_TYPE_IPV6_TCP |
4085     - IWL_RSS_HASH_TYPE_IPV6_UDP |
4086     - IWL_RSS_HASH_TYPE_IPV6_PAYLOAD,
4087     + .hash_mask = BIT(IWL_RSS_HASH_TYPE_IPV4_TCP) |
4088     + BIT(IWL_RSS_HASH_TYPE_IPV4_UDP) |
4089     + BIT(IWL_RSS_HASH_TYPE_IPV4_PAYLOAD) |
4090     + BIT(IWL_RSS_HASH_TYPE_IPV6_TCP) |
4091     + BIT(IWL_RSS_HASH_TYPE_IPV6_UDP) |
4092     + BIT(IWL_RSS_HASH_TYPE_IPV6_PAYLOAD),
4093     };
4094    
4095     if (mvm->trans->num_rx_queues == 1)
4096     diff --git a/drivers/net/wireless/intel/iwlwifi/mvm/rxmq.c b/drivers/net/wireless/intel/iwlwifi/mvm/rxmq.c
4097     index c2bbc8c17beb..bc06d87a0106 100644
4098     --- a/drivers/net/wireless/intel/iwlwifi/mvm/rxmq.c
4099     +++ b/drivers/net/wireless/intel/iwlwifi/mvm/rxmq.c
4100     @@ -810,12 +810,12 @@ void iwl_mvm_rx_mpdu_mq(struct iwl_mvm *mvm, struct napi_struct *napi,
4101     bool toggle_bit = phy_info & IWL_RX_MPDU_PHY_AMPDU_TOGGLE;
4102    
4103     rx_status->flag |= RX_FLAG_AMPDU_DETAILS;
4104     - rx_status->ampdu_reference = mvm->ampdu_ref;
4105     /* toggle is switched whenever new aggregation starts */
4106     if (toggle_bit != mvm->ampdu_toggle) {
4107     mvm->ampdu_ref++;
4108     mvm->ampdu_toggle = toggle_bit;
4109     }
4110     + rx_status->ampdu_reference = mvm->ampdu_ref;
4111     }
4112    
4113     rcu_read_lock();
4114     diff --git a/drivers/net/wireless/marvell/libertas/cfg.c b/drivers/net/wireless/marvell/libertas/cfg.c
4115     index 7ff2efadceca..3eab802c7d3f 100644
4116     --- a/drivers/net/wireless/marvell/libertas/cfg.c
4117     +++ b/drivers/net/wireless/marvell/libertas/cfg.c
4118     @@ -272,6 +272,10 @@ add_ie_rates(u8 *tlv, const u8 *ie, int *nrates)
4119     int hw, ap, ap_max = ie[1];
4120     u8 hw_rate;
4121    
4122     + if (ap_max > MAX_RATES) {
4123     + lbs_deb_assoc("invalid rates\n");
4124     + return tlv;
4125     + }
4126     /* Advance past IE header */
4127     ie += 2;
4128    
4129     @@ -1789,6 +1793,9 @@ static int lbs_ibss_join_existing(struct lbs_private *priv,
4130     struct cmd_ds_802_11_ad_hoc_join cmd;
4131     u8 preamble = RADIO_PREAMBLE_SHORT;
4132     int ret = 0;
4133     + int hw, i;
4134     + u8 rates_max;
4135     + u8 *rates;
4136    
4137     lbs_deb_enter(LBS_DEB_CFG80211);
4138    
4139     @@ -1849,9 +1856,12 @@ static int lbs_ibss_join_existing(struct lbs_private *priv,
4140     if (!rates_eid) {
4141     lbs_add_rates(cmd.bss.rates);
4142     } else {
4143     - int hw, i;
4144     - u8 rates_max = rates_eid[1];
4145     - u8 *rates = cmd.bss.rates;
4146     + rates_max = rates_eid[1];
4147     + if (rates_max > MAX_RATES) {
4148     + lbs_deb_join("invalid rates");
4149     + goto out;
4150     + }
4151     + rates = cmd.bss.rates;
4152     for (hw = 0; hw < ARRAY_SIZE(lbs_rates); hw++) {
4153     u8 hw_rate = lbs_rates[hw].bitrate / 5;
4154     for (i = 0; i < rates_max; i++) {
4155     diff --git a/drivers/net/wireless/marvell/libertas_tf/cmd.c b/drivers/net/wireless/marvell/libertas_tf/cmd.c
4156     index 909ac3685010..2b193f1257a5 100644
4157     --- a/drivers/net/wireless/marvell/libertas_tf/cmd.c
4158     +++ b/drivers/net/wireless/marvell/libertas_tf/cmd.c
4159     @@ -69,7 +69,7 @@ static void lbtf_geo_init(struct lbtf_private *priv)
4160     break;
4161     }
4162    
4163     - for (ch = priv->range.start; ch < priv->range.end; ch++)
4164     + for (ch = range->start; ch < range->end; ch++)
4165     priv->channels[CHAN_TO_IDX(ch)].flags = 0;
4166     }
4167    
4168     diff --git a/drivers/net/wireless/mediatek/mt7601u/phy.c b/drivers/net/wireless/mediatek/mt7601u/phy.c
4169     index ca09a5d4305e..71a47459bf8a 100644
4170     --- a/drivers/net/wireless/mediatek/mt7601u/phy.c
4171     +++ b/drivers/net/wireless/mediatek/mt7601u/phy.c
4172     @@ -221,7 +221,7 @@ int mt7601u_wait_bbp_ready(struct mt7601u_dev *dev)
4173    
4174     do {
4175     val = mt7601u_bbp_rr(dev, MT_BBP_REG_VERSION);
4176     - if (val && ~val)
4177     + if (val && val != 0xff)
4178     break;
4179     } while (--i);
4180    
4181     diff --git a/drivers/nvme/host/pci.c b/drivers/nvme/host/pci.c
4182     index 1ac4cec5f4f7..e2bce9385eda 100644
4183     --- a/drivers/nvme/host/pci.c
4184     +++ b/drivers/nvme/host/pci.c
4185     @@ -1863,7 +1863,7 @@ static int nvme_pci_reg_write32(struct nvme_ctrl *ctrl, u32 off, u32 val)
4186    
4187     static int nvme_pci_reg_read64(struct nvme_ctrl *ctrl, u32 off, u64 *val)
4188     {
4189     - *val = readq(to_nvme_dev(ctrl)->bar + off);
4190     + *val = lo_hi_readq(to_nvme_dev(ctrl)->bar + off);
4191     return 0;
4192     }
4193    
4194     diff --git a/drivers/of/of_mdio.c b/drivers/of/of_mdio.c
4195     index 262281bd68fa..1e70851b1530 100644
4196     --- a/drivers/of/of_mdio.c
4197     +++ b/drivers/of/of_mdio.c
4198     @@ -353,7 +353,7 @@ struct phy_device *of_phy_get_and_connect(struct net_device *dev,
4199     struct phy_device *phy;
4200    
4201     iface = of_get_phy_mode(np);
4202     - if (iface < 0)
4203     + if ((int)iface < 0)
4204     return NULL;
4205    
4206     phy_np = of_parse_phandle(np, "phy-handle", 0);
4207     diff --git a/drivers/pinctrl/sh-pfc/pfc-emev2.c b/drivers/pinctrl/sh-pfc/pfc-emev2.c
4208     index 1cbbe04d7df6..eafd8edbcbe9 100644
4209     --- a/drivers/pinctrl/sh-pfc/pfc-emev2.c
4210     +++ b/drivers/pinctrl/sh-pfc/pfc-emev2.c
4211     @@ -1263,6 +1263,14 @@ static const char * const dtv_groups[] = {
4212     "dtv_b",
4213     };
4214    
4215     +static const char * const err_rst_reqb_groups[] = {
4216     + "err_rst_reqb",
4217     +};
4218     +
4219     +static const char * const ext_clki_groups[] = {
4220     + "ext_clki",
4221     +};
4222     +
4223     static const char * const iic0_groups[] = {
4224     "iic0",
4225     };
4226     @@ -1285,6 +1293,10 @@ static const char * const lcd_groups[] = {
4227     "yuv3",
4228     };
4229    
4230     +static const char * const lowpwr_groups[] = {
4231     + "lowpwr",
4232     +};
4233     +
4234     static const char * const ntsc_groups[] = {
4235     "ntsc_clk",
4236     "ntsc_data",
4237     @@ -1298,6 +1310,10 @@ static const char * const pwm1_groups[] = {
4238     "pwm1",
4239     };
4240    
4241     +static const char * const ref_clko_groups[] = {
4242     + "ref_clko",
4243     +};
4244     +
4245     static const char * const sd_groups[] = {
4246     "sd_cki",
4247     };
4248     @@ -1391,13 +1407,17 @@ static const struct sh_pfc_function pinmux_functions[] = {
4249     SH_PFC_FUNCTION(cam),
4250     SH_PFC_FUNCTION(cf),
4251     SH_PFC_FUNCTION(dtv),
4252     + SH_PFC_FUNCTION(err_rst_reqb),
4253     + SH_PFC_FUNCTION(ext_clki),
4254     SH_PFC_FUNCTION(iic0),
4255     SH_PFC_FUNCTION(iic1),
4256     SH_PFC_FUNCTION(jtag),
4257     SH_PFC_FUNCTION(lcd),
4258     + SH_PFC_FUNCTION(lowpwr),
4259     SH_PFC_FUNCTION(ntsc),
4260     SH_PFC_FUNCTION(pwm0),
4261     SH_PFC_FUNCTION(pwm1),
4262     + SH_PFC_FUNCTION(ref_clko),
4263     SH_PFC_FUNCTION(sd),
4264     SH_PFC_FUNCTION(sdi0),
4265     SH_PFC_FUNCTION(sdi1),
4266     diff --git a/drivers/pinctrl/sh-pfc/pfc-r8a7740.c b/drivers/pinctrl/sh-pfc/pfc-r8a7740.c
4267     index 35f436bcb849..e9739dbcb356 100644
4268     --- a/drivers/pinctrl/sh-pfc/pfc-r8a7740.c
4269     +++ b/drivers/pinctrl/sh-pfc/pfc-r8a7740.c
4270     @@ -1982,7 +1982,7 @@ static const unsigned int gether_gmii_pins[] = {
4271     */
4272     185, 186, 187, 188, 189, 190, 191, 192, 174, 161, 204,
4273     171, 170, 169, 168, 167, 166, 173, 172, 176, 184, 183, 203,
4274     - 205, 163, 206, 207,
4275     + 205, 163, 206, 207, 158,
4276     };
4277     static const unsigned int gether_gmii_mux[] = {
4278     ET_ERXD0_MARK, ET_ERXD1_MARK, ET_ERXD2_MARK, ET_ERXD3_MARK,
4279     @@ -2154,6 +2154,7 @@ static const unsigned int lcd0_data24_1_mux[] = {
4280     LCD0_D0_MARK, LCD0_D1_MARK, LCD0_D2_MARK, LCD0_D3_MARK,
4281     LCD0_D4_MARK, LCD0_D5_MARK, LCD0_D6_MARK, LCD0_D7_MARK,
4282     LCD0_D8_MARK, LCD0_D9_MARK, LCD0_D10_MARK, LCD0_D11_MARK,
4283     + LCD0_D12_MARK, LCD0_D13_MARK, LCD0_D14_MARK, LCD0_D15_MARK,
4284     LCD0_D16_MARK, LCD0_D17_MARK, LCD0_D18_PORT163_MARK,
4285     LCD0_D19_PORT162_MARK, LCD0_D20_PORT161_MARK, LCD0_D21_PORT158_MARK,
4286     LCD0_D22_PORT160_MARK, LCD0_D23_PORT159_MARK,
4287     diff --git a/drivers/pinctrl/sh-pfc/pfc-r8a7791.c b/drivers/pinctrl/sh-pfc/pfc-r8a7791.c
4288     index baa98d7fe947..dd350e296142 100644
4289     --- a/drivers/pinctrl/sh-pfc/pfc-r8a7791.c
4290     +++ b/drivers/pinctrl/sh-pfc/pfc-r8a7791.c
4291     @@ -3136,8 +3136,7 @@ static const unsigned int qspi_data4_b_pins[] = {
4292     RCAR_GP_PIN(6, 4),
4293     };
4294     static const unsigned int qspi_data4_b_mux[] = {
4295     - SPCLK_B_MARK, MOSI_IO0_B_MARK, MISO_IO1_B_MARK,
4296     - IO2_B_MARK, IO3_B_MARK, SSL_B_MARK,
4297     + MOSI_IO0_B_MARK, MISO_IO1_B_MARK, IO2_B_MARK, IO3_B_MARK,
4298     };
4299     /* - SCIF0 ------------------------------------------------------------------ */
4300     static const unsigned int scif0_data_pins[] = {
4301     @@ -4265,17 +4264,14 @@ static const unsigned int vin1_b_data18_pins[] = {
4302     };
4303     static const unsigned int vin1_b_data18_mux[] = {
4304     /* B */
4305     - VI1_DATA0_B_MARK, VI1_DATA1_B_MARK,
4306     VI1_DATA2_B_MARK, VI1_DATA3_B_MARK,
4307     VI1_DATA4_B_MARK, VI1_DATA5_B_MARK,
4308     VI1_DATA6_B_MARK, VI1_DATA7_B_MARK,
4309     /* G */
4310     - VI1_G0_B_MARK, VI1_G1_B_MARK,
4311     VI1_G2_B_MARK, VI1_G3_B_MARK,
4312     VI1_G4_B_MARK, VI1_G5_B_MARK,
4313     VI1_G6_B_MARK, VI1_G7_B_MARK,
4314     /* R */
4315     - VI1_R0_B_MARK, VI1_R1_B_MARK,
4316     VI1_R2_B_MARK, VI1_R3_B_MARK,
4317     VI1_R4_B_MARK, VI1_R5_B_MARK,
4318     VI1_R6_B_MARK, VI1_R7_B_MARK,
4319     @@ -5082,7 +5078,7 @@ static const char * const scifb2_groups[] = {
4320     "scifb2_data_b",
4321     "scifb2_clk_b",
4322     "scifb2_ctrl_b",
4323     - "scifb0_data_c",
4324     + "scifb2_data_c",
4325     "scifb2_clk_c",
4326     "scifb2_data_d",
4327     };
4328     diff --git a/drivers/pinctrl/sh-pfc/pfc-r8a7792.c b/drivers/pinctrl/sh-pfc/pfc-r8a7792.c
4329     index 21badb6166b9..97998929db93 100644
4330     --- a/drivers/pinctrl/sh-pfc/pfc-r8a7792.c
4331     +++ b/drivers/pinctrl/sh-pfc/pfc-r8a7792.c
4332     @@ -1863,6 +1863,7 @@ static const char * const vin1_groups[] = {
4333     "vin1_data8",
4334     "vin1_data24_b",
4335     "vin1_data20_b",
4336     + "vin1_data18_b",
4337     "vin1_data16_b",
4338     "vin1_sync",
4339     "vin1_field",
4340     diff --git a/drivers/pinctrl/sh-pfc/pfc-r8a7794.c b/drivers/pinctrl/sh-pfc/pfc-r8a7794.c
4341     index ef093ac0cf2f..fe8c9c24634d 100644
4342     --- a/drivers/pinctrl/sh-pfc/pfc-r8a7794.c
4343     +++ b/drivers/pinctrl/sh-pfc/pfc-r8a7794.c
4344     @@ -4826,7 +4826,7 @@ static const struct pinmux_cfg_reg pinmux_config_regs[] = {
4345     FN_AVB_MDC, FN_SSI_SDATA6_B, 0, 0, }
4346     },
4347     { PINMUX_CFG_REG_VAR("IPSR9", 0xE6060044, 32,
4348     - 1, 3, 3, 3, 3, 2, 2, 3, 3, 3, 3, 3, 3) {
4349     + 1, 3, 3, 3, 3, 2, 2, 3, 3, 3, 3, 3) {
4350     /* IP9_31 [1] */
4351     0, 0,
4352     /* IP9_30_28 [3] */
4353     diff --git a/drivers/pinctrl/sh-pfc/pfc-sh7269.c b/drivers/pinctrl/sh-pfc/pfc-sh7269.c
4354     index a50d22bef1f4..cfdb4fc177c3 100644
4355     --- a/drivers/pinctrl/sh-pfc/pfc-sh7269.c
4356     +++ b/drivers/pinctrl/sh-pfc/pfc-sh7269.c
4357     @@ -2119,7 +2119,7 @@ static const struct pinmux_cfg_reg pinmux_config_regs[] = {
4358     },
4359    
4360     { PINMUX_CFG_REG("PCIOR0", 0xfffe3852, 16, 1) {
4361     - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
4362     + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
4363     PC8_IN, PC8_OUT,
4364     PC7_IN, PC7_OUT,
4365     PC6_IN, PC6_OUT,
4366     diff --git a/drivers/pinctrl/sh-pfc/pfc-sh73a0.c b/drivers/pinctrl/sh-pfc/pfc-sh73a0.c
4367     index d25e6f674d0a..6dca760f9f28 100644
4368     --- a/drivers/pinctrl/sh-pfc/pfc-sh73a0.c
4369     +++ b/drivers/pinctrl/sh-pfc/pfc-sh73a0.c
4370     @@ -3086,6 +3086,7 @@ static const unsigned int tpu4_to2_mux[] = {
4371     };
4372     static const unsigned int tpu4_to3_pins[] = {
4373     /* TO */
4374     + PIN_NUMBER(6, 26),
4375     };
4376     static const unsigned int tpu4_to3_mux[] = {
4377     TPU4TO3_MARK,
4378     @@ -3366,7 +3367,8 @@ static const char * const fsic_groups[] = {
4379     "fsic_sclk_out",
4380     "fsic_data_in",
4381     "fsic_data_out",
4382     - "fsic_spdif",
4383     + "fsic_spdif_0",
4384     + "fsic_spdif_1",
4385     };
4386    
4387     static const char * const fsid_groups[] = {
4388     diff --git a/drivers/pinctrl/sh-pfc/pfc-sh7734.c b/drivers/pinctrl/sh-pfc/pfc-sh7734.c
4389     index 3eccc9b3ca84..c691e5e9d9de 100644
4390     --- a/drivers/pinctrl/sh-pfc/pfc-sh7734.c
4391     +++ b/drivers/pinctrl/sh-pfc/pfc-sh7734.c
4392     @@ -2231,13 +2231,13 @@ static const struct pinmux_cfg_reg pinmux_config_regs[] = {
4393     FN_LCD_CL1_B, 0, 0,
4394     /* IP10_5_3 [3] */
4395     FN_SSI_WS23, FN_VI1_5_B, FN_TX1_D, FN_HSCK0_C, FN_FALE_B,
4396     - FN_LCD_DON_B, 0, 0, 0,
4397     + FN_LCD_DON_B, 0, 0,
4398     /* IP10_2_0 [3] */
4399     FN_SSI_SCK23, FN_VI1_4_B, FN_RX1_D, FN_FCLE_B,
4400     FN_LCD_DATA15_B, 0, 0, 0 }
4401     },
4402     { PINMUX_CFG_REG_VAR("IPSR11", 0xFFFC0048, 32,
4403     - 3, 1, 2, 2, 2, 3, 3, 1, 2, 3, 3, 1, 1, 1, 1) {
4404     + 3, 1, 2, 3, 2, 2, 3, 3, 1, 2, 3, 3, 1, 1, 1, 1) {
4405     /* IP11_31_29 [3] */
4406     0, 0, 0, 0, 0, 0, 0, 0,
4407     /* IP11_28 [1] */
4408     diff --git a/drivers/platform/mips/cpu_hwmon.c b/drivers/platform/mips/cpu_hwmon.c
4409     index 4300a558d0f3..d02214a3f8e3 100644
4410     --- a/drivers/platform/mips/cpu_hwmon.c
4411     +++ b/drivers/platform/mips/cpu_hwmon.c
4412     @@ -155,7 +155,7 @@ static int __init loongson_hwmon_init(void)
4413    
4414     cpu_hwmon_dev = hwmon_device_register(NULL);
4415     if (IS_ERR(cpu_hwmon_dev)) {
4416     - ret = -ENOMEM;
4417     + ret = PTR_ERR(cpu_hwmon_dev);
4418     pr_err("hwmon_device_register fail!\n");
4419     goto fail_hwmon_device_register;
4420     }
4421     diff --git a/drivers/platform/x86/alienware-wmi.c b/drivers/platform/x86/alienware-wmi.c
4422     index fe419935041c..bee2115ecf10 100644
4423     --- a/drivers/platform/x86/alienware-wmi.c
4424     +++ b/drivers/platform/x86/alienware-wmi.c
4425     @@ -570,7 +570,7 @@ static ssize_t show_hdmi_source(struct device *dev,
4426     return scnprintf(buf, PAGE_SIZE,
4427     "input [gpu] unknown\n");
4428     }
4429     - pr_err("alienware-wmi: unknown HDMI source status: %d\n", out_data);
4430     + pr_err("alienware-wmi: unknown HDMI source status: %u\n", status);
4431     return scnprintf(buf, PAGE_SIZE, "input gpu [unknown]\n");
4432     }
4433    
4434     diff --git a/drivers/power/supply/power_supply_core.c b/drivers/power/supply/power_supply_core.c
4435     index 9e05ae0430a9..cb0b3d3d132f 100644
4436     --- a/drivers/power/supply/power_supply_core.c
4437     +++ b/drivers/power/supply/power_supply_core.c
4438     @@ -764,14 +764,14 @@ __power_supply_register(struct device *parent,
4439     }
4440    
4441     spin_lock_init(&psy->changed_lock);
4442     - rc = device_init_wakeup(dev, ws);
4443     - if (rc)
4444     - goto wakeup_init_failed;
4445     -
4446     rc = device_add(dev);
4447     if (rc)
4448     goto device_add_failed;
4449    
4450     + rc = device_init_wakeup(dev, ws);
4451     + if (rc)
4452     + goto wakeup_init_failed;
4453     +
4454     rc = psy_register_thermal(psy);
4455     if (rc)
4456     goto register_thermal_failed;
4457     @@ -808,8 +808,8 @@ register_cooler_failed:
4458     psy_unregister_thermal(psy);
4459     register_thermal_failed:
4460     device_del(dev);
4461     -device_add_failed:
4462     wakeup_init_failed:
4463     +device_add_failed:
4464     check_supplies_failed:
4465     dev_set_name_failed:
4466     put_device(dev);
4467     diff --git a/drivers/pwm/pwm-lpss.c b/drivers/pwm/pwm-lpss.c
4468     index 5208b3f80ad8..239003807c08 100644
4469     --- a/drivers/pwm/pwm-lpss.c
4470     +++ b/drivers/pwm/pwm-lpss.c
4471     @@ -205,6 +205,12 @@ EXPORT_SYMBOL_GPL(pwm_lpss_probe);
4472    
4473     int pwm_lpss_remove(struct pwm_lpss_chip *lpwm)
4474     {
4475     + int i;
4476     +
4477     + for (i = 0; i < lpwm->info->npwm; i++) {
4478     + if (pwm_is_enabled(&lpwm->chip.pwms[i]))
4479     + pm_runtime_put(lpwm->chip.dev);
4480     + }
4481     return pwmchip_remove(&lpwm->chip);
4482     }
4483     EXPORT_SYMBOL_GPL(pwm_lpss_remove);
4484     diff --git a/drivers/pwm/pwm-meson.c b/drivers/pwm/pwm-meson.c
4485     index f58a4867b519..a196439ee14c 100644
4486     --- a/drivers/pwm/pwm-meson.c
4487     +++ b/drivers/pwm/pwm-meson.c
4488     @@ -320,11 +320,6 @@ static int meson_pwm_apply(struct pwm_chip *chip, struct pwm_device *pwm,
4489     if (state->period != channel->state.period ||
4490     state->duty_cycle != channel->state.duty_cycle ||
4491     state->polarity != channel->state.polarity) {
4492     - if (channel->state.enabled) {
4493     - meson_pwm_disable(meson, pwm->hwpwm);
4494     - channel->state.enabled = false;
4495     - }
4496     -
4497     if (state->polarity != channel->state.polarity) {
4498     if (state->polarity == PWM_POLARITY_NORMAL)
4499     meson->inverter_mask |= BIT(pwm->hwpwm);
4500     diff --git a/drivers/rapidio/rio_cm.c b/drivers/rapidio/rio_cm.c
4501     index ef989a15aefc..b29fc258eeba 100644
4502     --- a/drivers/rapidio/rio_cm.c
4503     +++ b/drivers/rapidio/rio_cm.c
4504     @@ -1215,7 +1215,9 @@ static int riocm_ch_listen(u16 ch_id)
4505     riocm_debug(CHOP, "(ch_%d)", ch_id);
4506    
4507     ch = riocm_get_channel(ch_id);
4508     - if (!ch || !riocm_cmp_exch(ch, RIO_CM_CHAN_BOUND, RIO_CM_LISTEN))
4509     + if (!ch)
4510     + return -EINVAL;
4511     + if (!riocm_cmp_exch(ch, RIO_CM_CHAN_BOUND, RIO_CM_LISTEN))
4512     ret = -EINVAL;
4513     riocm_put_channel(ch);
4514     return ret;
4515     diff --git a/drivers/regulator/pv88060-regulator.c b/drivers/regulator/pv88060-regulator.c
4516     index 6c4afc73ecac..d229245d2b5e 100644
4517     --- a/drivers/regulator/pv88060-regulator.c
4518     +++ b/drivers/regulator/pv88060-regulator.c
4519     @@ -135,7 +135,7 @@ static int pv88060_set_current_limit(struct regulator_dev *rdev, int min,
4520     int i;
4521    
4522     /* search for closest to maximum */
4523     - for (i = info->n_current_limits; i >= 0; i--) {
4524     + for (i = info->n_current_limits - 1; i >= 0; i--) {
4525     if (min <= info->current_limits[i]
4526     && max >= info->current_limits[i]) {
4527     return regmap_update_bits(rdev->regmap,
4528     diff --git a/drivers/regulator/pv88080-regulator.c b/drivers/regulator/pv88080-regulator.c
4529     index 954a20eeb26f..a40ecfb77210 100644
4530     --- a/drivers/regulator/pv88080-regulator.c
4531     +++ b/drivers/regulator/pv88080-regulator.c
4532     @@ -279,7 +279,7 @@ static int pv88080_set_current_limit(struct regulator_dev *rdev, int min,
4533     int i;
4534    
4535     /* search for closest to maximum */
4536     - for (i = info->n_current_limits; i >= 0; i--) {
4537     + for (i = info->n_current_limits - 1; i >= 0; i--) {
4538     if (min <= info->current_limits[i]
4539     && max >= info->current_limits[i]) {
4540     return regmap_update_bits(rdev->regmap,
4541     diff --git a/drivers/regulator/pv88090-regulator.c b/drivers/regulator/pv88090-regulator.c
4542     index 421641175352..789652c9b014 100644
4543     --- a/drivers/regulator/pv88090-regulator.c
4544     +++ b/drivers/regulator/pv88090-regulator.c
4545     @@ -157,7 +157,7 @@ static int pv88090_set_current_limit(struct regulator_dev *rdev, int min,
4546     int i;
4547    
4548     /* search for closest to maximum */
4549     - for (i = info->n_current_limits; i >= 0; i--) {
4550     + for (i = info->n_current_limits - 1; i >= 0; i--) {
4551     if (min <= info->current_limits[i]
4552     && max >= info->current_limits[i]) {
4553     return regmap_update_bits(rdev->regmap,
4554     diff --git a/drivers/regulator/tps65086-regulator.c b/drivers/regulator/tps65086-regulator.c
4555     index 6dbf3cf3951e..12d26261394f 100644
4556     --- a/drivers/regulator/tps65086-regulator.c
4557     +++ b/drivers/regulator/tps65086-regulator.c
4558     @@ -89,8 +89,8 @@ static const struct regulator_linear_range tps65086_buck345_25mv_ranges[] = {
4559     static const struct regulator_linear_range tps65086_ldoa1_ranges[] = {
4560     REGULATOR_LINEAR_RANGE(1350000, 0x0, 0x0, 0),
4561     REGULATOR_LINEAR_RANGE(1500000, 0x1, 0x7, 100000),
4562     - REGULATOR_LINEAR_RANGE(2300000, 0x8, 0xA, 100000),
4563     - REGULATOR_LINEAR_RANGE(2700000, 0xB, 0xD, 150000),
4564     + REGULATOR_LINEAR_RANGE(2300000, 0x8, 0xB, 100000),
4565     + REGULATOR_LINEAR_RANGE(2850000, 0xC, 0xD, 150000),
4566     REGULATOR_LINEAR_RANGE(3300000, 0xE, 0xE, 0),
4567     };
4568    
4569     diff --git a/drivers/regulator/wm831x-dcdc.c b/drivers/regulator/wm831x-dcdc.c
4570     index 5a5bc4bb08d2..df591435d12a 100644
4571     --- a/drivers/regulator/wm831x-dcdc.c
4572     +++ b/drivers/regulator/wm831x-dcdc.c
4573     @@ -327,8 +327,8 @@ static int wm831x_buckv_get_voltage_sel(struct regulator_dev *rdev)
4574     }
4575    
4576     /* Current limit options */
4577     -static u16 wm831x_dcdc_ilim[] = {
4578     - 125, 250, 375, 500, 625, 750, 875, 1000
4579     +static const unsigned int wm831x_dcdc_ilim[] = {
4580     + 125000, 250000, 375000, 500000, 625000, 750000, 875000, 1000000
4581     };
4582    
4583     static int wm831x_buckv_set_current_limit(struct regulator_dev *rdev,
4584     diff --git a/drivers/rtc/rtc-88pm80x.c b/drivers/rtc/rtc-88pm80x.c
4585     index 466bf7f9a285..7da2a1fb50f8 100644
4586     --- a/drivers/rtc/rtc-88pm80x.c
4587     +++ b/drivers/rtc/rtc-88pm80x.c
4588     @@ -116,12 +116,14 @@ static int pm80x_rtc_read_time(struct device *dev, struct rtc_time *tm)
4589     unsigned char buf[4];
4590     unsigned long ticks, base, data;
4591     regmap_raw_read(info->map, PM800_RTC_EXPIRE2_1, buf, 4);
4592     - base = (buf[3] << 24) | (buf[2] << 16) | (buf[1] << 8) | buf[0];
4593     + base = ((unsigned long)buf[3] << 24) | (buf[2] << 16) |
4594     + (buf[1] << 8) | buf[0];
4595     dev_dbg(info->dev, "%x-%x-%x-%x\n", buf[0], buf[1], buf[2], buf[3]);
4596    
4597     /* load 32-bit read-only counter */
4598     regmap_raw_read(info->map, PM800_RTC_COUNTER1, buf, 4);
4599     - data = (buf[3] << 24) | (buf[2] << 16) | (buf[1] << 8) | buf[0];
4600     + data = ((unsigned long)buf[3] << 24) | (buf[2] << 16) |
4601     + (buf[1] << 8) | buf[0];
4602     ticks = base + data;
4603     dev_dbg(info->dev, "get base:0x%lx, RO count:0x%lx, ticks:0x%lx\n",
4604     base, data, ticks);
4605     @@ -144,7 +146,8 @@ static int pm80x_rtc_set_time(struct device *dev, struct rtc_time *tm)
4606    
4607     /* load 32-bit read-only counter */
4608     regmap_raw_read(info->map, PM800_RTC_COUNTER1, buf, 4);
4609     - data = (buf[3] << 24) | (buf[2] << 16) | (buf[1] << 8) | buf[0];
4610     + data = ((unsigned long)buf[3] << 24) | (buf[2] << 16) |
4611     + (buf[1] << 8) | buf[0];
4612     base = ticks - data;
4613     dev_dbg(info->dev, "set base:0x%lx, RO count:0x%lx, ticks:0x%lx\n",
4614     base, data, ticks);
4615     @@ -165,11 +168,13 @@ static int pm80x_rtc_read_alarm(struct device *dev, struct rtc_wkalrm *alrm)
4616     int ret;
4617    
4618     regmap_raw_read(info->map, PM800_RTC_EXPIRE2_1, buf, 4);
4619     - base = (buf[3] << 24) | (buf[2] << 16) | (buf[1] << 8) | buf[0];
4620     + base = ((unsigned long)buf[3] << 24) | (buf[2] << 16) |
4621     + (buf[1] << 8) | buf[0];
4622     dev_dbg(info->dev, "%x-%x-%x-%x\n", buf[0], buf[1], buf[2], buf[3]);
4623    
4624     regmap_raw_read(info->map, PM800_RTC_EXPIRE1_1, buf, 4);
4625     - data = (buf[3] << 24) | (buf[2] << 16) | (buf[1] << 8) | buf[0];
4626     + data = ((unsigned long)buf[3] << 24) | (buf[2] << 16) |
4627     + (buf[1] << 8) | buf[0];
4628     ticks = base + data;
4629     dev_dbg(info->dev, "get base:0x%lx, RO count:0x%lx, ticks:0x%lx\n",
4630     base, data, ticks);
4631     @@ -192,12 +197,14 @@ static int pm80x_rtc_set_alarm(struct device *dev, struct rtc_wkalrm *alrm)
4632     regmap_update_bits(info->map, PM800_RTC_CONTROL, PM800_ALARM1_EN, 0);
4633    
4634     regmap_raw_read(info->map, PM800_RTC_EXPIRE2_1, buf, 4);
4635     - base = (buf[3] << 24) | (buf[2] << 16) | (buf[1] << 8) | buf[0];
4636     + base = ((unsigned long)buf[3] << 24) | (buf[2] << 16) |
4637     + (buf[1] << 8) | buf[0];
4638     dev_dbg(info->dev, "%x-%x-%x-%x\n", buf[0], buf[1], buf[2], buf[3]);
4639    
4640     /* load 32-bit read-only counter */
4641     regmap_raw_read(info->map, PM800_RTC_COUNTER1, buf, 4);
4642     - data = (buf[3] << 24) | (buf[2] << 16) | (buf[1] << 8) | buf[0];
4643     + data = ((unsigned long)buf[3] << 24) | (buf[2] << 16) |
4644     + (buf[1] << 8) | buf[0];
4645     ticks = base + data;
4646     dev_dbg(info->dev, "get base:0x%lx, RO count:0x%lx, ticks:0x%lx\n",
4647     base, data, ticks);
4648     diff --git a/drivers/rtc/rtc-88pm860x.c b/drivers/rtc/rtc-88pm860x.c
4649     index 166faae3a59c..7d3e5168fcef 100644
4650     --- a/drivers/rtc/rtc-88pm860x.c
4651     +++ b/drivers/rtc/rtc-88pm860x.c
4652     @@ -115,11 +115,13 @@ static int pm860x_rtc_read_time(struct device *dev, struct rtc_time *tm)
4653     pm860x_page_bulk_read(info->i2c, REG0_ADDR, 8, buf);
4654     dev_dbg(info->dev, "%x-%x-%x-%x-%x-%x-%x-%x\n", buf[0], buf[1],
4655     buf[2], buf[3], buf[4], buf[5], buf[6], buf[7]);
4656     - base = (buf[1] << 24) | (buf[3] << 16) | (buf[5] << 8) | buf[7];
4657     + base = ((unsigned long)buf[1] << 24) | (buf[3] << 16) |
4658     + (buf[5] << 8) | buf[7];
4659    
4660     /* load 32-bit read-only counter */
4661     pm860x_bulk_read(info->i2c, PM8607_RTC_COUNTER1, 4, buf);
4662     - data = (buf[3] << 24) | (buf[2] << 16) | (buf[1] << 8) | buf[0];
4663     + data = ((unsigned long)buf[3] << 24) | (buf[2] << 16) |
4664     + (buf[1] << 8) | buf[0];
4665     ticks = base + data;
4666     dev_dbg(info->dev, "get base:0x%lx, RO count:0x%lx, ticks:0x%lx\n",
4667     base, data, ticks);
4668     @@ -145,7 +147,8 @@ static int pm860x_rtc_set_time(struct device *dev, struct rtc_time *tm)
4669    
4670     /* load 32-bit read-only counter */
4671     pm860x_bulk_read(info->i2c, PM8607_RTC_COUNTER1, 4, buf);
4672     - data = (buf[3] << 24) | (buf[2] << 16) | (buf[1] << 8) | buf[0];
4673     + data = ((unsigned long)buf[3] << 24) | (buf[2] << 16) |
4674     + (buf[1] << 8) | buf[0];
4675     base = ticks - data;
4676     dev_dbg(info->dev, "set base:0x%lx, RO count:0x%lx, ticks:0x%lx\n",
4677     base, data, ticks);
4678     @@ -170,10 +173,12 @@ static int pm860x_rtc_read_alarm(struct device *dev, struct rtc_wkalrm *alrm)
4679     pm860x_page_bulk_read(info->i2c, REG0_ADDR, 8, buf);
4680     dev_dbg(info->dev, "%x-%x-%x-%x-%x-%x-%x-%x\n", buf[0], buf[1],
4681     buf[2], buf[3], buf[4], buf[5], buf[6], buf[7]);
4682     - base = (buf[1] << 24) | (buf[3] << 16) | (buf[5] << 8) | buf[7];
4683     + base = ((unsigned long)buf[1] << 24) | (buf[3] << 16) |
4684     + (buf[5] << 8) | buf[7];
4685    
4686     pm860x_bulk_read(info->i2c, PM8607_RTC_EXPIRE1, 4, buf);
4687     - data = (buf[3] << 24) | (buf[2] << 16) | (buf[1] << 8) | buf[0];
4688     + data = ((unsigned long)buf[3] << 24) | (buf[2] << 16) |
4689     + (buf[1] << 8) | buf[0];
4690     ticks = base + data;
4691     dev_dbg(info->dev, "get base:0x%lx, RO count:0x%lx, ticks:0x%lx\n",
4692     base, data, ticks);
4693     @@ -198,11 +203,13 @@ static int pm860x_rtc_set_alarm(struct device *dev, struct rtc_wkalrm *alrm)
4694     pm860x_page_bulk_read(info->i2c, REG0_ADDR, 8, buf);
4695     dev_dbg(info->dev, "%x-%x-%x-%x-%x-%x-%x-%x\n", buf[0], buf[1],
4696     buf[2], buf[3], buf[4], buf[5], buf[6], buf[7]);
4697     - base = (buf[1] << 24) | (buf[3] << 16) | (buf[5] << 8) | buf[7];
4698     + base = ((unsigned long)buf[1] << 24) | (buf[3] << 16) |
4699     + (buf[5] << 8) | buf[7];
4700    
4701     /* load 32-bit read-only counter */
4702     pm860x_bulk_read(info->i2c, PM8607_RTC_COUNTER1, 4, buf);
4703     - data = (buf[3] << 24) | (buf[2] << 16) | (buf[1] << 8) | buf[0];
4704     + data = ((unsigned long)buf[3] << 24) | (buf[2] << 16) |
4705     + (buf[1] << 8) | buf[0];
4706     ticks = base + data;
4707     dev_dbg(info->dev, "get base:0x%lx, RO count:0x%lx, ticks:0x%lx\n",
4708     base, data, ticks);
4709     diff --git a/drivers/rtc/rtc-ds1672.c b/drivers/rtc/rtc-ds1672.c
4710     index 5c18ac7394c4..c911f2db0af5 100644
4711     --- a/drivers/rtc/rtc-ds1672.c
4712     +++ b/drivers/rtc/rtc-ds1672.c
4713     @@ -58,7 +58,8 @@ static int ds1672_get_datetime(struct i2c_client *client, struct rtc_time *tm)
4714     "%s: raw read data - counters=%02x,%02x,%02x,%02x\n",
4715     __func__, buf[0], buf[1], buf[2], buf[3]);
4716    
4717     - time = (buf[3] << 24) | (buf[2] << 16) | (buf[1] << 8) | buf[0];
4718     + time = ((unsigned long)buf[3] << 24) | (buf[2] << 16) |
4719     + (buf[1] << 8) | buf[0];
4720    
4721     rtc_time_to_tm(time, tm);
4722    
4723     diff --git a/drivers/rtc/rtc-mc146818-lib.c b/drivers/rtc/rtc-mc146818-lib.c
4724     index 2f1772a358ca..18a6f15e313d 100644
4725     --- a/drivers/rtc/rtc-mc146818-lib.c
4726     +++ b/drivers/rtc/rtc-mc146818-lib.c
4727     @@ -82,7 +82,7 @@ unsigned int mc146818_get_time(struct rtc_time *time)
4728     time->tm_year += real_year - 72;
4729     #endif
4730    
4731     - if (century)
4732     + if (century > 20)
4733     time->tm_year += (century - 19) * 100;
4734    
4735     /*
4736     diff --git a/drivers/rtc/rtc-pcf8563.c b/drivers/rtc/rtc-pcf8563.c
4737     index a4b8b603c807..533fb7027f0c 100644
4738     --- a/drivers/rtc/rtc-pcf8563.c
4739     +++ b/drivers/rtc/rtc-pcf8563.c
4740     @@ -563,7 +563,6 @@ static int pcf8563_probe(struct i2c_client *client,
4741     struct pcf8563 *pcf8563;
4742     int err;
4743     unsigned char buf;
4744     - unsigned char alm_pending;
4745    
4746     dev_dbg(&client->dev, "%s\n", __func__);
4747    
4748     @@ -587,13 +586,13 @@ static int pcf8563_probe(struct i2c_client *client,
4749     return err;
4750     }
4751    
4752     - err = pcf8563_get_alarm_mode(client, NULL, &alm_pending);
4753     - if (err) {
4754     - dev_err(&client->dev, "%s: read error\n", __func__);
4755     + /* Clear flags and disable interrupts */
4756     + buf = 0;
4757     + err = pcf8563_write_block_data(client, PCF8563_REG_ST2, 1, &buf);
4758     + if (err < 0) {
4759     + dev_err(&client->dev, "%s: write error\n", __func__);
4760     return err;
4761     }
4762     - if (alm_pending)
4763     - pcf8563_set_alarm_mode(client, 0);
4764    
4765     pcf8563->rtc = devm_rtc_device_register(&client->dev,
4766     pcf8563_driver.driver.name,
4767     diff --git a/drivers/rtc/rtc-pm8xxx.c b/drivers/rtc/rtc-pm8xxx.c
4768     index fac835530671..a1b4b0ed1f19 100644
4769     --- a/drivers/rtc/rtc-pm8xxx.c
4770     +++ b/drivers/rtc/rtc-pm8xxx.c
4771     @@ -186,7 +186,8 @@ static int pm8xxx_rtc_read_time(struct device *dev, struct rtc_time *tm)
4772     }
4773     }
4774    
4775     - secs = value[0] | (value[1] << 8) | (value[2] << 16) | (value[3] << 24);
4776     + secs = value[0] | (value[1] << 8) | (value[2] << 16) |
4777     + ((unsigned long)value[3] << 24);
4778    
4779     rtc_time_to_tm(secs, tm);
4780    
4781     @@ -267,7 +268,8 @@ static int pm8xxx_rtc_read_alarm(struct device *dev, struct rtc_wkalrm *alarm)
4782     return rc;
4783     }
4784    
4785     - secs = value[0] | (value[1] << 8) | (value[2] << 16) | (value[3] << 24);
4786     + secs = value[0] | (value[1] << 8) | (value[2] << 16) |
4787     + ((unsigned long)value[3] << 24);
4788    
4789     rtc_time_to_tm(secs, &alarm->time);
4790    
4791     diff --git a/drivers/scsi/libfc/fc_exch.c b/drivers/scsi/libfc/fc_exch.c
4792     index 16ca31ad5ec0..d0a86ef80652 100644
4793     --- a/drivers/scsi/libfc/fc_exch.c
4794     +++ b/drivers/scsi/libfc/fc_exch.c
4795     @@ -2506,7 +2506,7 @@ void fc_exch_recv(struct fc_lport *lport, struct fc_frame *fp)
4796    
4797     /* lport lock ? */
4798     if (!lport || lport->state == LPORT_ST_DISABLED) {
4799     - FC_LPORT_DBG(lport, "Receiving frames for an lport that "
4800     + FC_LIBFC_DBG("Receiving frames for an lport that "
4801     "has not been initialized correctly\n");
4802     fc_frame_free(fp);
4803     return;
4804     diff --git a/drivers/scsi/megaraid/megaraid_sas_base.c b/drivers/scsi/megaraid/megaraid_sas_base.c
4805     index c5cc002dfdd5..10ae624dd266 100644
4806     --- a/drivers/scsi/megaraid/megaraid_sas_base.c
4807     +++ b/drivers/scsi/megaraid/megaraid_sas_base.c
4808     @@ -3694,12 +3694,12 @@ megasas_transition_to_ready(struct megasas_instance *instance, int ocr)
4809     /*
4810     * The cur_state should not last for more than max_wait secs
4811     */
4812     - for (i = 0; i < max_wait; i++) {
4813     + for (i = 0; i < max_wait * 50; i++) {
4814     curr_abs_state = instance->instancet->
4815     read_fw_status_reg(instance->reg_set);
4816    
4817     if (abs_state == curr_abs_state) {
4818     - msleep(1000);
4819     + msleep(20);
4820     } else
4821     break;
4822     }
4823     diff --git a/drivers/scsi/qla2xxx/qla_os.c b/drivers/scsi/qla2xxx/qla_os.c
4824     index 3bae56b202f8..e730aabc26d0 100644
4825     --- a/drivers/scsi/qla2xxx/qla_os.c
4826     +++ b/drivers/scsi/qla2xxx/qla_os.c
4827     @@ -6055,8 +6055,7 @@ qla2x00_module_init(void)
4828     /* Initialize target kmem_cache and mem_pools */
4829     ret = qlt_init();
4830     if (ret < 0) {
4831     - kmem_cache_destroy(srb_cachep);
4832     - return ret;
4833     + goto destroy_cache;
4834     } else if (ret > 0) {
4835     /*
4836     * If initiator mode is explictly disabled by qlt_init(),
4837     @@ -6075,11 +6074,10 @@ qla2x00_module_init(void)
4838     qla2xxx_transport_template =
4839     fc_attach_transport(&qla2xxx_transport_functions);
4840     if (!qla2xxx_transport_template) {
4841     - kmem_cache_destroy(srb_cachep);
4842     ql_log(ql_log_fatal, NULL, 0x0002,
4843     "fc_attach_transport failed...Failing load!.\n");
4844     - qlt_exit();
4845     - return -ENODEV;
4846     + ret = -ENODEV;
4847     + goto qlt_exit;
4848     }
4849    
4850     apidev_major = register_chrdev(0, QLA2XXX_APIDEV, &apidev_fops);
4851     @@ -6091,27 +6089,37 @@ qla2x00_module_init(void)
4852     qla2xxx_transport_vport_template =
4853     fc_attach_transport(&qla2xxx_transport_vport_functions);
4854     if (!qla2xxx_transport_vport_template) {
4855     - kmem_cache_destroy(srb_cachep);
4856     - qlt_exit();
4857     - fc_release_transport(qla2xxx_transport_template);
4858     ql_log(ql_log_fatal, NULL, 0x0004,
4859     "fc_attach_transport vport failed...Failing load!.\n");
4860     - return -ENODEV;
4861     + ret = -ENODEV;
4862     + goto unreg_chrdev;
4863     }
4864     ql_log(ql_log_info, NULL, 0x0005,
4865     "QLogic Fibre Channel HBA Driver: %s.\n",
4866     qla2x00_version_str);
4867     ret = pci_register_driver(&qla2xxx_pci_driver);
4868     if (ret) {
4869     - kmem_cache_destroy(srb_cachep);
4870     - qlt_exit();
4871     - fc_release_transport(qla2xxx_transport_template);
4872     - fc_release_transport(qla2xxx_transport_vport_template);
4873     ql_log(ql_log_fatal, NULL, 0x0006,
4874     "pci_register_driver failed...ret=%d Failing load!.\n",
4875     ret);
4876     + goto release_vport_transport;
4877     }
4878     return ret;
4879     +
4880     +release_vport_transport:
4881     + fc_release_transport(qla2xxx_transport_vport_template);
4882     +
4883     +unreg_chrdev:
4884     + if (apidev_major >= 0)
4885     + unregister_chrdev(apidev_major, QLA2XXX_APIDEV);
4886     + fc_release_transport(qla2xxx_transport_template);
4887     +
4888     +qlt_exit:
4889     + qlt_exit();
4890     +
4891     +destroy_cache:
4892     + kmem_cache_destroy(srb_cachep);
4893     + return ret;
4894     }
4895    
4896     /**
4897     diff --git a/drivers/scsi/scsi_transport_iscsi.c b/drivers/scsi/scsi_transport_iscsi.c
4898     index c39551b32e94..ab7bc4e63425 100644
4899     --- a/drivers/scsi/scsi_transport_iscsi.c
4900     +++ b/drivers/scsi/scsi_transport_iscsi.c
4901     @@ -37,6 +37,8 @@
4902    
4903     #define ISCSI_TRANSPORT_VERSION "2.0-870"
4904    
4905     +#define ISCSI_SEND_MAX_ALLOWED 10
4906     +
4907     static int dbg_session;
4908     module_param_named(debug_session, dbg_session, int,
4909     S_IRUGO | S_IWUSR);
4910     @@ -3694,6 +3696,7 @@ iscsi_if_rx(struct sk_buff *skb)
4911     struct nlmsghdr *nlh;
4912     struct iscsi_uevent *ev;
4913     uint32_t group;
4914     + int retries = ISCSI_SEND_MAX_ALLOWED;
4915    
4916     nlh = nlmsg_hdr(skb);
4917     if (nlh->nlmsg_len < sizeof(*nlh) + sizeof(*ev) ||
4918     @@ -3724,6 +3727,10 @@ iscsi_if_rx(struct sk_buff *skb)
4919     break;
4920     err = iscsi_if_send_reply(group, nlh->nlmsg_seq,
4921     nlh->nlmsg_type, 0, 0, ev, sizeof(*ev));
4922     + if (err == -EAGAIN && --retries < 0) {
4923     + printk(KERN_WARNING "Send reply failed, error %d\n", err);
4924     + break;
4925     + }
4926     } while (err < 0 && err != -ECONNREFUSED && err != -ESRCH);
4927     skb_pull(skb, rlen);
4928     }
4929     diff --git a/drivers/soc/fsl/qe/gpio.c b/drivers/soc/fsl/qe/gpio.c
4930     index 0aaf429f31d5..b5a7107a9c0a 100644
4931     --- a/drivers/soc/fsl/qe/gpio.c
4932     +++ b/drivers/soc/fsl/qe/gpio.c
4933     @@ -152,8 +152,10 @@ struct qe_pin *qe_pin_request(struct device_node *np, int index)
4934     if (err < 0)
4935     goto err0;
4936     gc = gpio_to_chip(err);
4937     - if (WARN_ON(!gc))
4938     + if (WARN_ON(!gc)) {
4939     + err = -ENODEV;
4940     goto err0;
4941     + }
4942    
4943     if (!of_device_is_compatible(gc->of_node, "fsl,mpc8323-qe-pario-bank")) {
4944     pr_debug("%s: tried to get a non-qe pin\n", __func__);
4945     diff --git a/drivers/spi/spi-bcm2835aux.c b/drivers/spi/spi-bcm2835aux.c
4946     index 5c89bbb05441..e075712c501e 100644
4947     --- a/drivers/spi/spi-bcm2835aux.c
4948     +++ b/drivers/spi/spi-bcm2835aux.c
4949     @@ -416,7 +416,18 @@ static int bcm2835aux_spi_probe(struct platform_device *pdev)
4950     platform_set_drvdata(pdev, master);
4951     master->mode_bits = (SPI_CPOL | SPI_CS_HIGH | SPI_NO_CS);
4952     master->bits_per_word_mask = SPI_BPW_MASK(8);
4953     - master->num_chipselect = -1;
4954     + /* even though the driver never officially supported native CS
4955     + * allow a single native CS for legacy DT support purposes when
4956     + * no cs-gpio is configured.
4957     + * Known limitations for native cs are:
4958     + * * multiple chip-selects: cs0-cs2 are all simultaniously asserted
4959     + * whenever there is a transfer - this even includes SPI_NO_CS
4960     + * * SPI_CS_HIGH: is ignores - cs are always asserted low
4961     + * * cs_change: cs is deasserted after each spi_transfer
4962     + * * cs_delay_usec: cs is always deasserted one SCK cycle after
4963     + * a spi_transfer
4964     + */
4965     + master->num_chipselect = 1;
4966     master->transfer_one = bcm2835aux_spi_transfer_one;
4967     master->handle_err = bcm2835aux_spi_handle_err;
4968     master->prepare_message = bcm2835aux_spi_prepare_message;
4969     diff --git a/drivers/spi/spi-fsl-spi.c b/drivers/spi/spi-fsl-spi.c
4970     index 8b290d9d7935..5419de19859a 100644
4971     --- a/drivers/spi/spi-fsl-spi.c
4972     +++ b/drivers/spi/spi-fsl-spi.c
4973     @@ -408,7 +408,6 @@ static int fsl_spi_do_one_msg(struct spi_master *master,
4974     }
4975    
4976     m->status = status;
4977     - spi_finalize_current_message(master);
4978    
4979     if (status || !cs_change) {
4980     ndelay(nsecs);
4981     @@ -416,6 +415,7 @@ static int fsl_spi_do_one_msg(struct spi_master *master,
4982     }
4983    
4984     fsl_spi_setup_transfer(spi, NULL);
4985     + spi_finalize_current_message(master);
4986     return 0;
4987     }
4988    
4989     diff --git a/drivers/spi/spi-tegra114.c b/drivers/spi/spi-tegra114.c
4990     index 705f515863d4..e37712bed0b2 100644
4991     --- a/drivers/spi/spi-tegra114.c
4992     +++ b/drivers/spi/spi-tegra114.c
4993     @@ -307,10 +307,16 @@ static unsigned tegra_spi_fill_tx_fifo_from_client_txbuf(
4994     x |= (u32)(*tx_buf++) << (i * 8);
4995     tegra_spi_writel(tspi, x, SPI_TX_FIFO);
4996     }
4997     +
4998     + tspi->cur_tx_pos += written_words * tspi->bytes_per_word;
4999     } else {
5000     + unsigned int write_bytes;
5001     max_n_32bit = min(tspi->curr_dma_words, tx_empty_count);
5002     written_words = max_n_32bit;
5003     nbytes = written_words * tspi->bytes_per_word;
5004     + if (nbytes > t->len - tspi->cur_pos)
5005     + nbytes = t->len - tspi->cur_pos;
5006     + write_bytes = nbytes;
5007     for (count = 0; count < max_n_32bit; count++) {
5008     u32 x = 0;
5009    
5010     @@ -319,8 +325,10 @@ static unsigned tegra_spi_fill_tx_fifo_from_client_txbuf(
5011     x |= (u32)(*tx_buf++) << (i * 8);
5012     tegra_spi_writel(tspi, x, SPI_TX_FIFO);
5013     }
5014     +
5015     + tspi->cur_tx_pos += write_bytes;
5016     }
5017     - tspi->cur_tx_pos += written_words * tspi->bytes_per_word;
5018     +
5019     return written_words;
5020     }
5021    
5022     @@ -344,20 +352,27 @@ static unsigned int tegra_spi_read_rx_fifo_to_client_rxbuf(
5023     for (i = 0; len && (i < 4); i++, len--)
5024     *rx_buf++ = (x >> i*8) & 0xFF;
5025     }
5026     - tspi->cur_rx_pos += tspi->curr_dma_words * tspi->bytes_per_word;
5027     read_words += tspi->curr_dma_words;
5028     + tspi->cur_rx_pos += tspi->curr_dma_words * tspi->bytes_per_word;
5029     } else {
5030     u32 rx_mask = ((u32)1 << t->bits_per_word) - 1;
5031     + u8 bytes_per_word = tspi->bytes_per_word;
5032     + unsigned int read_bytes;
5033    
5034     + len = rx_full_count * bytes_per_word;
5035     + if (len > t->len - tspi->cur_pos)
5036     + len = t->len - tspi->cur_pos;
5037     + read_bytes = len;
5038     for (count = 0; count < rx_full_count; count++) {
5039     u32 x = tegra_spi_readl(tspi, SPI_RX_FIFO) & rx_mask;
5040    
5041     - for (i = 0; (i < tspi->bytes_per_word); i++)
5042     + for (i = 0; len && (i < bytes_per_word); i++, len--)
5043     *rx_buf++ = (x >> (i*8)) & 0xFF;
5044     }
5045     - tspi->cur_rx_pos += rx_full_count * tspi->bytes_per_word;
5046     read_words += rx_full_count;
5047     + tspi->cur_rx_pos += read_bytes;
5048     }
5049     +
5050     return read_words;
5051     }
5052    
5053     @@ -372,12 +387,17 @@ static void tegra_spi_copy_client_txbuf_to_spi_txbuf(
5054     unsigned len = tspi->curr_dma_words * tspi->bytes_per_word;
5055    
5056     memcpy(tspi->tx_dma_buf, t->tx_buf + tspi->cur_pos, len);
5057     + tspi->cur_tx_pos += tspi->curr_dma_words * tspi->bytes_per_word;
5058     } else {
5059     unsigned int i;
5060     unsigned int count;
5061     u8 *tx_buf = (u8 *)t->tx_buf + tspi->cur_tx_pos;
5062     unsigned consume = tspi->curr_dma_words * tspi->bytes_per_word;
5063     + unsigned int write_bytes;
5064    
5065     + if (consume > t->len - tspi->cur_pos)
5066     + consume = t->len - tspi->cur_pos;
5067     + write_bytes = consume;
5068     for (count = 0; count < tspi->curr_dma_words; count++) {
5069     u32 x = 0;
5070    
5071     @@ -386,8 +406,9 @@ static void tegra_spi_copy_client_txbuf_to_spi_txbuf(
5072     x |= (u32)(*tx_buf++) << (i * 8);
5073     tspi->tx_dma_buf[count] = x;
5074     }
5075     +
5076     + tspi->cur_tx_pos += write_bytes;
5077     }
5078     - tspi->cur_tx_pos += tspi->curr_dma_words * tspi->bytes_per_word;
5079    
5080     /* Make the dma buffer to read by dma */
5081     dma_sync_single_for_device(tspi->dev, tspi->tx_dma_phys,
5082     @@ -405,20 +426,28 @@ static void tegra_spi_copy_spi_rxbuf_to_client_rxbuf(
5083     unsigned len = tspi->curr_dma_words * tspi->bytes_per_word;
5084    
5085     memcpy(t->rx_buf + tspi->cur_rx_pos, tspi->rx_dma_buf, len);
5086     + tspi->cur_rx_pos += tspi->curr_dma_words * tspi->bytes_per_word;
5087     } else {
5088     unsigned int i;
5089     unsigned int count;
5090     unsigned char *rx_buf = t->rx_buf + tspi->cur_rx_pos;
5091     u32 rx_mask = ((u32)1 << t->bits_per_word) - 1;
5092     + unsigned consume = tspi->curr_dma_words * tspi->bytes_per_word;
5093     + unsigned int read_bytes;
5094    
5095     + if (consume > t->len - tspi->cur_pos)
5096     + consume = t->len - tspi->cur_pos;
5097     + read_bytes = consume;
5098     for (count = 0; count < tspi->curr_dma_words; count++) {
5099     u32 x = tspi->rx_dma_buf[count] & rx_mask;
5100    
5101     - for (i = 0; (i < tspi->bytes_per_word); i++)
5102     + for (i = 0; consume && (i < tspi->bytes_per_word);
5103     + i++, consume--)
5104     *rx_buf++ = (x >> (i*8)) & 0xFF;
5105     }
5106     +
5107     + tspi->cur_rx_pos += read_bytes;
5108     }
5109     - tspi->cur_rx_pos += tspi->curr_dma_words * tspi->bytes_per_word;
5110    
5111     /* Make the dma buffer to read by dma */
5112     dma_sync_single_for_device(tspi->dev, tspi->rx_dma_phys,
5113     @@ -730,6 +759,8 @@ static int tegra_spi_start_transfer_one(struct spi_device *spi,
5114    
5115     if (tspi->is_packed)
5116     command1 |= SPI_PACKED;
5117     + else
5118     + command1 &= ~SPI_PACKED;
5119    
5120     command1 &= ~(SPI_CS_SEL_MASK | SPI_TX_EN | SPI_RX_EN);
5121     tspi->cur_direction = 0;
5122     diff --git a/drivers/staging/comedi/drivers/ni_mio_common.c b/drivers/staging/comedi/drivers/ni_mio_common.c
5123     index fe03a41dc5cf..12056eb3cbe8 100644
5124     --- a/drivers/staging/comedi/drivers/ni_mio_common.c
5125     +++ b/drivers/staging/comedi/drivers/ni_mio_common.c
5126     @@ -4945,7 +4945,10 @@ static int ni_valid_rtsi_output_source(struct comedi_device *dev,
5127     case NI_RTSI_OUTPUT_G_SRC0:
5128     case NI_RTSI_OUTPUT_G_GATE0:
5129     case NI_RTSI_OUTPUT_RGOUT0:
5130     - case NI_RTSI_OUTPUT_RTSI_BRD_0:
5131     + case NI_RTSI_OUTPUT_RTSI_BRD(0):
5132     + case NI_RTSI_OUTPUT_RTSI_BRD(1):
5133     + case NI_RTSI_OUTPUT_RTSI_BRD(2):
5134     + case NI_RTSI_OUTPUT_RTSI_BRD(3):
5135     return 1;
5136     case NI_RTSI_OUTPUT_RTSI_OSC:
5137     return (devpriv->is_m_series) ? 1 : 0;
5138     @@ -4966,11 +4969,18 @@ static int ni_set_rtsi_routing(struct comedi_device *dev,
5139     devpriv->rtsi_trig_a_output_reg |= NISTC_RTSI_TRIG(chan, src);
5140     ni_stc_writew(dev, devpriv->rtsi_trig_a_output_reg,
5141     NISTC_RTSI_TRIGA_OUT_REG);
5142     - } else if (chan < 8) {
5143     + } else if (chan < NISTC_RTSI_TRIG_NUM_CHAN(devpriv->is_m_series)) {
5144     devpriv->rtsi_trig_b_output_reg &= ~NISTC_RTSI_TRIG_MASK(chan);
5145     devpriv->rtsi_trig_b_output_reg |= NISTC_RTSI_TRIG(chan, src);
5146     ni_stc_writew(dev, devpriv->rtsi_trig_b_output_reg,
5147     NISTC_RTSI_TRIGB_OUT_REG);
5148     + } else if (chan != NISTC_RTSI_TRIG_OLD_CLK_CHAN) {
5149     + /* probably should never reach this, since the
5150     + * ni_valid_rtsi_output_source above errors out if chan is too
5151     + * high
5152     + */
5153     + dev_err(dev->class_dev, "%s: unknown rtsi channel\n", __func__);
5154     + return -EINVAL;
5155     }
5156     return 2;
5157     }
5158     @@ -4986,12 +4996,12 @@ static unsigned int ni_get_rtsi_routing(struct comedi_device *dev,
5159     } else if (chan < NISTC_RTSI_TRIG_NUM_CHAN(devpriv->is_m_series)) {
5160     return NISTC_RTSI_TRIG_TO_SRC(chan,
5161     devpriv->rtsi_trig_b_output_reg);
5162     - } else {
5163     - if (chan == NISTC_RTSI_TRIG_OLD_CLK_CHAN)
5164     - return NI_RTSI_OUTPUT_RTSI_OSC;
5165     - dev_err(dev->class_dev, "bug! should never get here?\n");
5166     - return 0;
5167     + } else if (chan == NISTC_RTSI_TRIG_OLD_CLK_CHAN) {
5168     + return NI_RTSI_OUTPUT_RTSI_OSC;
5169     }
5170     +
5171     + dev_err(dev->class_dev, "%s: unknown rtsi channel\n", __func__);
5172     + return -EINVAL;
5173     }
5174    
5175     static int ni_rtsi_insn_config(struct comedi_device *dev,
5176     diff --git a/drivers/staging/greybus/light.c b/drivers/staging/greybus/light.c
5177     index 9f01427f35f9..1cb82cc28aa7 100644
5178     --- a/drivers/staging/greybus/light.c
5179     +++ b/drivers/staging/greybus/light.c
5180     @@ -1102,21 +1102,21 @@ static void gb_lights_channel_release(struct gb_channel *channel)
5181     static void gb_lights_light_release(struct gb_light *light)
5182     {
5183     int i;
5184     - int count;
5185    
5186     light->ready = false;
5187    
5188     - count = light->channels_count;
5189     -
5190     if (light->has_flash)
5191     gb_lights_light_v4l2_unregister(light);
5192     + light->has_flash = false;
5193    
5194     - for (i = 0; i < count; i++) {
5195     + for (i = 0; i < light->channels_count; i++)
5196     gb_lights_channel_release(&light->channels[i]);
5197     - light->channels_count--;
5198     - }
5199     + light->channels_count = 0;
5200     +
5201     kfree(light->channels);
5202     + light->channels = NULL;
5203     kfree(light->name);
5204     + light->name = NULL;
5205     }
5206    
5207     static void gb_lights_release(struct gb_lights *glights)
5208     diff --git a/drivers/staging/most/aim-cdev/cdev.c b/drivers/staging/most/aim-cdev/cdev.c
5209     index 7f51024dc5eb..e87b9ed4f37d 100644
5210     --- a/drivers/staging/most/aim-cdev/cdev.c
5211     +++ b/drivers/staging/most/aim-cdev/cdev.c
5212     @@ -451,7 +451,9 @@ static int aim_probe(struct most_interface *iface, int channel_id,
5213     c->devno = MKDEV(major, current_minor);
5214     cdev_init(&c->cdev, &channel_fops);
5215     c->cdev.owner = THIS_MODULE;
5216     - cdev_add(&c->cdev, c->devno, 1);
5217     + retval = cdev_add(&c->cdev, c->devno, 1);
5218     + if (retval < 0)
5219     + goto err_free_c;
5220     c->iface = iface;
5221     c->cfg = cfg;
5222     c->channel_id = channel_id;
5223     @@ -487,6 +489,7 @@ error_create_device:
5224     list_del(&c->list);
5225     error_alloc_kfifo:
5226     cdev_del(&c->cdev);
5227     +err_free_c:
5228     kfree(c);
5229     error_alloc_channel:
5230     ida_simple_remove(&minor_id, current_minor);
5231     diff --git a/drivers/target/iscsi/iscsi_target.c b/drivers/target/iscsi/iscsi_target.c
5232     index e5674e5857bf..9636d8744347 100644
5233     --- a/drivers/target/iscsi/iscsi_target.c
5234     +++ b/drivers/target/iscsi/iscsi_target.c
5235     @@ -4162,9 +4162,6 @@ int iscsit_close_connection(
5236     iscsit_stop_nopin_response_timer(conn);
5237     iscsit_stop_nopin_timer(conn);
5238    
5239     - if (conn->conn_transport->iscsit_wait_conn)
5240     - conn->conn_transport->iscsit_wait_conn(conn);
5241     -
5242     /*
5243     * During Connection recovery drop unacknowledged out of order
5244     * commands for this connection, and prepare the other commands
5245     @@ -4250,6 +4247,9 @@ int iscsit_close_connection(
5246     target_sess_cmd_list_set_waiting(sess->se_sess);
5247     target_wait_for_sess_cmds(sess->se_sess);
5248    
5249     + if (conn->conn_transport->iscsit_wait_conn)
5250     + conn->conn_transport->iscsit_wait_conn(conn);
5251     +
5252     ahash_request_free(conn->conn_tx_hash);
5253     if (conn->conn_rx_hash) {
5254     struct crypto_ahash *tfm;
5255     diff --git a/drivers/thermal/cpu_cooling.c b/drivers/thermal/cpu_cooling.c
5256     index f49d2989d000..984e5f514140 100644
5257     --- a/drivers/thermal/cpu_cooling.c
5258     +++ b/drivers/thermal/cpu_cooling.c
5259     @@ -607,7 +607,7 @@ static int cpufreq_get_requested_power(struct thermal_cooling_device *cdev,
5260     load = 0;
5261    
5262     total_load += load;
5263     - if (trace_thermal_power_cpu_limit_enabled() && load_cpu)
5264     + if (load_cpu)
5265     load_cpu[i] = load;
5266    
5267     i++;
5268     diff --git a/drivers/thermal/mtk_thermal.c b/drivers/thermal/mtk_thermal.c
5269     index 34169c32d495..ea9558679634 100644
5270     --- a/drivers/thermal/mtk_thermal.c
5271     +++ b/drivers/thermal/mtk_thermal.c
5272     @@ -348,7 +348,8 @@ static int mtk_thermal_bank_temperature(struct mtk_thermal_bank *bank)
5273     u32 raw;
5274    
5275     for (i = 0; i < conf->bank_data[bank->id].num_sensors; i++) {
5276     - raw = readl(mt->thermal_base + conf->msr[i]);
5277     + raw = readl(mt->thermal_base +
5278     + conf->msr[conf->bank_data[bank->id].sensors[i]]);
5279    
5280     temp = raw_to_mcelsius(mt,
5281     conf->bank_data[bank->id].sensors[i],
5282     @@ -485,7 +486,8 @@ static void mtk_thermal_init_bank(struct mtk_thermal *mt, int num,
5283    
5284     for (i = 0; i < conf->bank_data[num].num_sensors; i++)
5285     writel(conf->sensor_mux_values[conf->bank_data[num].sensors[i]],
5286     - mt->thermal_base + conf->adcpnp[i]);
5287     + mt->thermal_base +
5288     + conf->adcpnp[conf->bank_data[num].sensors[i]]);
5289    
5290     writel((1 << conf->bank_data[num].num_sensors) - 1,
5291     mt->thermal_base + TEMP_MONCTL0);
5292     diff --git a/drivers/tty/ipwireless/hardware.c b/drivers/tty/ipwireless/hardware.c
5293     index df0204b6148f..4417f7568422 100644
5294     --- a/drivers/tty/ipwireless/hardware.c
5295     +++ b/drivers/tty/ipwireless/hardware.c
5296     @@ -1515,6 +1515,8 @@ static void ipw_send_setup_packet(struct ipw_hardware *hw)
5297     sizeof(struct ipw_setup_get_version_query_packet),
5298     ADDR_SETUP_PROT, TL_PROTOCOLID_SETUP,
5299     TL_SETUP_SIGNO_GET_VERSION_QRY);
5300     + if (!ver_packet)
5301     + return;
5302     ver_packet->header.length = sizeof(struct tl_setup_get_version_qry);
5303    
5304     /*
5305     diff --git a/drivers/tty/serial/stm32-usart.c b/drivers/tty/serial/stm32-usart.c
5306     index 033856287ca2..ea8b591dd46f 100644
5307     --- a/drivers/tty/serial/stm32-usart.c
5308     +++ b/drivers/tty/serial/stm32-usart.c
5309     @@ -293,13 +293,8 @@ static void stm32_transmit_chars(struct uart_port *port)
5310     return;
5311     }
5312    
5313     - if (uart_tx_stopped(port)) {
5314     - stm32_stop_tx(port);
5315     - return;
5316     - }
5317     -
5318     - if (uart_circ_empty(xmit)) {
5319     - stm32_stop_tx(port);
5320     + if (uart_circ_empty(xmit) || uart_tx_stopped(port)) {
5321     + stm32_clr_bits(port, ofs->cr1, USART_CR1_TXEIE);
5322     return;
5323     }
5324    
5325     @@ -312,7 +307,7 @@ static void stm32_transmit_chars(struct uart_port *port)
5326     uart_write_wakeup(port);
5327    
5328     if (uart_circ_empty(xmit))
5329     - stm32_stop_tx(port);
5330     + stm32_clr_bits(port, ofs->cr1, USART_CR1_TXEIE);
5331     }
5332    
5333     static irqreturn_t stm32_interrupt(int irq, void *ptr)
5334     diff --git a/drivers/usb/class/cdc-wdm.c b/drivers/usb/class/cdc-wdm.c
5335     index 217a479165e0..09337a973335 100644
5336     --- a/drivers/usb/class/cdc-wdm.c
5337     +++ b/drivers/usb/class/cdc-wdm.c
5338     @@ -1098,7 +1098,7 @@ static int wdm_post_reset(struct usb_interface *intf)
5339     rv = recover_from_urb_loss(desc);
5340     mutex_unlock(&desc->wlock);
5341     mutex_unlock(&desc->rlock);
5342     - return 0;
5343     + return rv;
5344     }
5345    
5346     static struct usb_driver wdm_driver = {
5347     diff --git a/drivers/usb/host/xhci-hub.c b/drivers/usb/host/xhci-hub.c
5348     index 5cf5f3d9c1e5..04d36fa60734 100644
5349     --- a/drivers/usb/host/xhci-hub.c
5350     +++ b/drivers/usb/host/xhci-hub.c
5351     @@ -989,7 +989,7 @@ int xhci_hub_control(struct usb_hcd *hcd, u16 typeReq, u16 wValue,
5352     }
5353     port_li = readl(port_array[wIndex] + PORTLI);
5354     status = xhci_get_ext_port_status(temp, port_li);
5355     - put_unaligned_le32(cpu_to_le32(status), &buf[4]);
5356     + put_unaligned_le32(status, &buf[4]);
5357     }
5358     break;
5359     case SetPortFeature:
5360     diff --git a/drivers/usb/phy/Kconfig b/drivers/usb/phy/Kconfig
5361     index 19ce615455c1..de70e70d02be 100644
5362     --- a/drivers/usb/phy/Kconfig
5363     +++ b/drivers/usb/phy/Kconfig
5364     @@ -19,7 +19,7 @@ config AB8500_USB
5365     in host mode, low speed.
5366    
5367     config FSL_USB2_OTG
5368     - bool "Freescale USB OTG Transceiver Driver"
5369     + tristate "Freescale USB OTG Transceiver Driver"
5370     depends on USB_EHCI_FSL && USB_FSL_USB2 && USB_OTG_FSM=y && PM
5371     depends on USB_GADGET || !USB_GADGET # if USB_GADGET=m, this can't be 'y'
5372     select USB_PHY
5373     diff --git a/drivers/usb/phy/phy-twl6030-usb.c b/drivers/usb/phy/phy-twl6030-usb.c
5374     index a72e8d670adc..cf0b67433ac9 100644
5375     --- a/drivers/usb/phy/phy-twl6030-usb.c
5376     +++ b/drivers/usb/phy/phy-twl6030-usb.c
5377     @@ -422,7 +422,7 @@ static int twl6030_usb_remove(struct platform_device *pdev)
5378     {
5379     struct twl6030_usb *twl = platform_get_drvdata(pdev);
5380    
5381     - cancel_delayed_work(&twl->get_status_work);
5382     + cancel_delayed_work_sync(&twl->get_status_work);
5383     twl6030_interrupt_mask(TWL6030_USBOTG_INT_MASK,
5384     REG_INT_MSK_LINE_C);
5385     twl6030_interrupt_mask(TWL6030_USBOTG_INT_MASK,
5386     diff --git a/drivers/vfio/pci/vfio_pci.c b/drivers/vfio/pci/vfio_pci.c
5387     index da3f0ed18c76..c94167d87178 100644
5388     --- a/drivers/vfio/pci/vfio_pci.c
5389     +++ b/drivers/vfio/pci/vfio_pci.c
5390     @@ -729,6 +729,7 @@ static long vfio_pci_ioctl(void *device_data,
5391     {
5392     void __iomem *io;
5393     size_t size;
5394     + u16 orig_cmd;
5395    
5396     info.offset = VFIO_PCI_INDEX_TO_OFFSET(info.index);
5397     info.flags = 0;
5398     @@ -744,15 +745,23 @@ static long vfio_pci_ioctl(void *device_data,
5399     break;
5400     }
5401    
5402     - /* Is it really there? */
5403     + /*
5404     + * Is it really there? Enable memory decode for
5405     + * implicit access in pci_map_rom().
5406     + */
5407     + pci_read_config_word(pdev, PCI_COMMAND, &orig_cmd);
5408     + pci_write_config_word(pdev, PCI_COMMAND,
5409     + orig_cmd | PCI_COMMAND_MEMORY);
5410     +
5411     io = pci_map_rom(pdev, &size);
5412     - if (!io || !size) {
5413     + if (io) {
5414     + info.flags = VFIO_REGION_INFO_FLAG_READ;
5415     + pci_unmap_rom(pdev, io);
5416     + } else {
5417     info.size = 0;
5418     - break;
5419     }
5420     - pci_unmap_rom(pdev, io);
5421    
5422     - info.flags = VFIO_REGION_INFO_FLAG_READ;
5423     + pci_write_config_word(pdev, PCI_COMMAND, orig_cmd);
5424     break;
5425     }
5426     case VFIO_PCI_VGA_REGION_INDEX:
5427     diff --git a/drivers/video/backlight/lm3630a_bl.c b/drivers/video/backlight/lm3630a_bl.c
5428     index 60d6c2ac87aa..1771220b2437 100644
5429     --- a/drivers/video/backlight/lm3630a_bl.c
5430     +++ b/drivers/video/backlight/lm3630a_bl.c
5431     @@ -200,7 +200,7 @@ static int lm3630a_bank_a_update_status(struct backlight_device *bl)
5432     LM3630A_LEDA_ENABLE, LM3630A_LEDA_ENABLE);
5433     if (ret < 0)
5434     goto out_i2c_err;
5435     - return bl->props.brightness;
5436     + return 0;
5437    
5438     out_i2c_err:
5439     dev_err(pchip->dev, "i2c failed to access\n");
5440     @@ -277,7 +277,7 @@ static int lm3630a_bank_b_update_status(struct backlight_device *bl)
5441     LM3630A_LEDB_ENABLE, LM3630A_LEDB_ENABLE);
5442     if (ret < 0)
5443     goto out_i2c_err;
5444     - return bl->props.brightness;
5445     + return 0;
5446    
5447     out_i2c_err:
5448     dev_err(pchip->dev, "i2c failed to access REG_CTRL\n");
5449     diff --git a/drivers/video/fbdev/chipsfb.c b/drivers/video/fbdev/chipsfb.c
5450     index 59abdc6a97f6..314b7eceb81c 100644
5451     --- a/drivers/video/fbdev/chipsfb.c
5452     +++ b/drivers/video/fbdev/chipsfb.c
5453     @@ -350,7 +350,7 @@ static void init_chips(struct fb_info *p, unsigned long addr)
5454     static int chipsfb_pci_init(struct pci_dev *dp, const struct pci_device_id *ent)
5455     {
5456     struct fb_info *p;
5457     - unsigned long addr, size;
5458     + unsigned long addr;
5459     unsigned short cmd;
5460     int rc = -ENODEV;
5461    
5462     @@ -362,7 +362,6 @@ static int chipsfb_pci_init(struct pci_dev *dp, const struct pci_device_id *ent)
5463     if ((dp->resource[0].flags & IORESOURCE_MEM) == 0)
5464     goto err_disable;
5465     addr = pci_resource_start(dp, 0);
5466     - size = pci_resource_len(dp, 0);
5467     if (addr == 0)
5468     goto err_disable;
5469    
5470     diff --git a/drivers/xen/cpu_hotplug.c b/drivers/xen/cpu_hotplug.c
5471     index f4e59c445964..17054d695411 100644
5472     --- a/drivers/xen/cpu_hotplug.c
5473     +++ b/drivers/xen/cpu_hotplug.c
5474     @@ -53,7 +53,7 @@ static int vcpu_online(unsigned int cpu)
5475     }
5476     static void vcpu_hotplug(unsigned int cpu)
5477     {
5478     - if (!cpu_possible(cpu))
5479     + if (cpu >= nr_cpu_ids || !cpu_possible(cpu))
5480     return;
5481    
5482     switch (vcpu_online(cpu)) {
5483     diff --git a/fs/afs/super.c b/fs/afs/super.c
5484     index fbdb022b75a2..65389394e202 100644
5485     --- a/fs/afs/super.c
5486     +++ b/fs/afs/super.c
5487     @@ -317,6 +317,7 @@ static int afs_fill_super(struct super_block *sb,
5488     /* fill in the superblock */
5489     sb->s_blocksize = PAGE_SIZE;
5490     sb->s_blocksize_bits = PAGE_SHIFT;
5491     + sb->s_maxbytes = MAX_LFS_FILESIZE;
5492     sb->s_magic = AFS_FS_MAGIC;
5493     sb->s_op = &afs_super_ops;
5494     sb->s_bdi = &as->volume->bdi;
5495     diff --git a/fs/btrfs/inode-map.c b/fs/btrfs/inode-map.c
5496     index d27014b8bf72..075b59516c8c 100644
5497     --- a/fs/btrfs/inode-map.c
5498     +++ b/fs/btrfs/inode-map.c
5499     @@ -159,6 +159,7 @@ static void start_caching(struct btrfs_root *root)
5500     spin_lock(&root->ino_cache_lock);
5501     root->ino_cache_state = BTRFS_CACHE_FINISHED;
5502     spin_unlock(&root->ino_cache_lock);
5503     + wake_up(&root->ino_cache_wait);
5504     return;
5505     }
5506    
5507     diff --git a/fs/cifs/connect.c b/fs/cifs/connect.c
5508     index e43ba6db2bdd..751bdde6515d 100644
5509     --- a/fs/cifs/connect.c
5510     +++ b/fs/cifs/connect.c
5511     @@ -885,6 +885,7 @@ cifs_demultiplex_thread(void *p)
5512     mempool_resize(cifs_req_poolp, length + cifs_min_rcv);
5513    
5514     set_freezable();
5515     + allow_kernel_signal(SIGKILL);
5516     while (server->tcpStatus != CifsExiting) {
5517     if (try_to_freeze())
5518     continue;
5519     @@ -2221,7 +2222,7 @@ cifs_put_tcp_session(struct TCP_Server_Info *server, int from_reconnect)
5520    
5521     task = xchg(&server->tsk, NULL);
5522     if (task)
5523     - force_sig(SIGKILL, task);
5524     + send_sig(SIGKILL, task, 1);
5525     }
5526    
5527     static struct TCP_Server_Info *
5528     diff --git a/fs/exportfs/expfs.c b/fs/exportfs/expfs.c
5529     index 3706939e5dd5..1730122b10e0 100644
5530     --- a/fs/exportfs/expfs.c
5531     +++ b/fs/exportfs/expfs.c
5532     @@ -146,6 +146,7 @@ static struct dentry *reconnect_one(struct vfsmount *mnt,
5533     tmp = lookup_one_len_unlocked(nbuf, parent, strlen(nbuf));
5534     if (IS_ERR(tmp)) {
5535     dprintk("%s: lookup failed: %d\n", __func__, PTR_ERR(tmp));
5536     + err = PTR_ERR(tmp);
5537     goto out_err;
5538     }
5539     if (tmp != dentry) {
5540     diff --git a/fs/ext4/inline.c b/fs/ext4/inline.c
5541     index 9a13f86fed62..4df4d31057b3 100644
5542     --- a/fs/ext4/inline.c
5543     +++ b/fs/ext4/inline.c
5544     @@ -1417,7 +1417,7 @@ int htree_inlinedir_to_tree(struct file *dir_file,
5545     err = ext4_htree_store_dirent(dir_file, hinfo->hash,
5546     hinfo->minor_hash, de, &tmp_str);
5547     if (err) {
5548     - count = err;
5549     + ret = err;
5550     goto out;
5551     }
5552     count++;
5553     diff --git a/fs/jfs/jfs_txnmgr.c b/fs/jfs/jfs_txnmgr.c
5554     index 4d973524c887..224ef034004b 100644
5555     --- a/fs/jfs/jfs_txnmgr.c
5556     +++ b/fs/jfs/jfs_txnmgr.c
5557     @@ -1928,8 +1928,7 @@ static void xtLog(struct jfs_log * log, struct tblock * tblk, struct lrd * lrd,
5558     * header ?
5559     */
5560     if (tlck->type & tlckTRUNCATE) {
5561     - /* This odd declaration suppresses a bogus gcc warning */
5562     - pxd_t pxd = pxd; /* truncated extent of xad */
5563     + pxd_t pxd; /* truncated extent of xad */
5564     int twm;
5565    
5566     /*
5567     diff --git a/fs/namei.c b/fs/namei.c
5568     index eb4626bad88a..7150c4d0bd7b 100644
5569     --- a/fs/namei.c
5570     +++ b/fs/namei.c
5571     @@ -1011,7 +1011,8 @@ static int may_linkat(struct path *link)
5572     * may_create_in_sticky - Check whether an O_CREAT open in a sticky directory
5573     * should be allowed, or not, on files that already
5574     * exist.
5575     - * @dir: the sticky parent directory
5576     + * @dir_mode: mode bits of directory
5577     + * @dir_uid: owner of directory
5578     * @inode: the inode of the file to open
5579     *
5580     * Block an O_CREAT open of a FIFO (or a regular file) when:
5581     @@ -1027,18 +1028,18 @@ static int may_linkat(struct path *link)
5582     *
5583     * Returns 0 if the open is allowed, -ve on error.
5584     */
5585     -static int may_create_in_sticky(struct dentry * const dir,
5586     +static int may_create_in_sticky(umode_t dir_mode, kuid_t dir_uid,
5587     struct inode * const inode)
5588     {
5589     if ((!sysctl_protected_fifos && S_ISFIFO(inode->i_mode)) ||
5590     (!sysctl_protected_regular && S_ISREG(inode->i_mode)) ||
5591     - likely(!(dir->d_inode->i_mode & S_ISVTX)) ||
5592     - uid_eq(inode->i_uid, dir->d_inode->i_uid) ||
5593     + likely(!(dir_mode & S_ISVTX)) ||
5594     + uid_eq(inode->i_uid, dir_uid) ||
5595     uid_eq(current_fsuid(), inode->i_uid))
5596     return 0;
5597    
5598     - if (likely(dir->d_inode->i_mode & 0002) ||
5599     - (dir->d_inode->i_mode & 0020 &&
5600     + if (likely(dir_mode & 0002) ||
5601     + (dir_mode & 0020 &&
5602     ((sysctl_protected_fifos >= 2 && S_ISFIFO(inode->i_mode)) ||
5603     (sysctl_protected_regular >= 2 && S_ISREG(inode->i_mode))))) {
5604     return -EACCES;
5605     @@ -3259,6 +3260,8 @@ static int do_last(struct nameidata *nd,
5606     int *opened)
5607     {
5608     struct dentry *dir = nd->path.dentry;
5609     + kuid_t dir_uid = dir->d_inode->i_uid;
5610     + umode_t dir_mode = dir->d_inode->i_mode;
5611     int open_flag = op->open_flag;
5612     bool will_truncate = (open_flag & O_TRUNC) != 0;
5613     bool got_write = false;
5614     @@ -3401,7 +3404,7 @@ finish_open:
5615     error = -EISDIR;
5616     if (d_is_dir(nd->path.dentry))
5617     goto out;
5618     - error = may_create_in_sticky(dir,
5619     + error = may_create_in_sticky(dir_mode, dir_uid,
5620     d_backing_inode(nd->path.dentry));
5621     if (unlikely(error))
5622     goto out;
5623     diff --git a/fs/nfs/delegation.c b/fs/nfs/delegation.c
5624     index 9a8830a0f31f..014039618cff 100644
5625     --- a/fs/nfs/delegation.c
5626     +++ b/fs/nfs/delegation.c
5627     @@ -234,6 +234,8 @@ static struct inode *nfs_delegation_grab_inode(struct nfs_delegation *delegation
5628     spin_lock(&delegation->lock);
5629     if (delegation->inode != NULL)
5630     inode = igrab(delegation->inode);
5631     + if (!inode)
5632     + set_bit(NFS_DELEGATION_INODE_FREEING, &delegation->flags);
5633     spin_unlock(&delegation->lock);
5634     return inode;
5635     }
5636     @@ -867,10 +869,11 @@ restart:
5637     list_for_each_entry_rcu(server, &clp->cl_superblocks, client_link) {
5638     list_for_each_entry_rcu(delegation, &server->delegations,
5639     super_list) {
5640     - if (test_bit(NFS_DELEGATION_RETURNING,
5641     - &delegation->flags))
5642     - continue;
5643     - if (test_bit(NFS_DELEGATION_NEED_RECLAIM,
5644     + if (test_bit(NFS_DELEGATION_INODE_FREEING,
5645     + &delegation->flags) ||
5646     + test_bit(NFS_DELEGATION_RETURNING,
5647     + &delegation->flags) ||
5648     + test_bit(NFS_DELEGATION_NEED_RECLAIM,
5649     &delegation->flags) == 0)
5650     continue;
5651     if (!nfs_sb_active(server->super))
5652     @@ -975,10 +978,11 @@ restart:
5653     list_for_each_entry_rcu(server, &clp->cl_superblocks, client_link) {
5654     list_for_each_entry_rcu(delegation, &server->delegations,
5655     super_list) {
5656     - if (test_bit(NFS_DELEGATION_RETURNING,
5657     - &delegation->flags))
5658     - continue;
5659     - if (test_bit(NFS_DELEGATION_TEST_EXPIRED,
5660     + if (test_bit(NFS_DELEGATION_INODE_FREEING,
5661     + &delegation->flags) ||
5662     + test_bit(NFS_DELEGATION_RETURNING,
5663     + &delegation->flags) ||
5664     + test_bit(NFS_DELEGATION_TEST_EXPIRED,
5665     &delegation->flags) == 0)
5666     continue;
5667     if (!nfs_sb_active(server->super))
5668     diff --git a/fs/nfs/delegation.h b/fs/nfs/delegation.h
5669     index 2c6cb7fb7d5e..f72095bf9e10 100644
5670     --- a/fs/nfs/delegation.h
5671     +++ b/fs/nfs/delegation.h
5672     @@ -33,6 +33,7 @@ enum {
5673     NFS_DELEGATION_RETURNING,
5674     NFS_DELEGATION_REVOKED,
5675     NFS_DELEGATION_TEST_EXPIRED,
5676     + NFS_DELEGATION_INODE_FREEING,
5677     };
5678    
5679     int nfs_inode_set_delegation(struct inode *inode, struct rpc_cred *cred, struct nfs_openres *res);
5680     diff --git a/fs/nfs/super.c b/fs/nfs/super.c
5681     index 42c31587a936..4c21e572f2d9 100644
5682     --- a/fs/nfs/super.c
5683     +++ b/fs/nfs/super.c
5684     @@ -1928,7 +1928,7 @@ static int nfs_parse_devname(const char *dev_name,
5685     /* kill possible hostname list: not supported */
5686     comma = strchr(dev_name, ',');
5687     if (comma != NULL && comma < end)
5688     - *comma = 0;
5689     + len = comma - dev_name;
5690     }
5691    
5692     if (len > maxnamlen)
5693     diff --git a/fs/xfs/xfs_quotaops.c b/fs/xfs/xfs_quotaops.c
5694     index f82d79a8c694..a7c3da09b72f 100644
5695     --- a/fs/xfs/xfs_quotaops.c
5696     +++ b/fs/xfs/xfs_quotaops.c
5697     @@ -214,6 +214,9 @@ xfs_fs_rm_xquota(
5698     if (XFS_IS_QUOTA_ON(mp))
5699     return -EINVAL;
5700    
5701     + if (uflags & ~(FS_USER_QUOTA | FS_GROUP_QUOTA | FS_PROJ_QUOTA))
5702     + return -EINVAL;
5703     +
5704     if (uflags & FS_USER_QUOTA)
5705     flags |= XFS_DQ_USER;
5706     if (uflags & FS_GROUP_QUOTA)
5707     diff --git a/include/linux/bitmap.h b/include/linux/bitmap.h
5708     index dec03c0dbc21..26347cc717e8 100644
5709     --- a/include/linux/bitmap.h
5710     +++ b/include/linux/bitmap.h
5711     @@ -85,6 +85,14 @@
5712     * contain all bit positions from 0 to 'bits' - 1.
5713     */
5714    
5715     +/*
5716     + * Allocation and deallocation of bitmap.
5717     + * Provided in lib/bitmap.c to avoid circular dependency.
5718     + */
5719     +extern unsigned long *bitmap_alloc(unsigned int nbits, gfp_t flags);
5720     +extern unsigned long *bitmap_zalloc(unsigned int nbits, gfp_t flags);
5721     +extern void bitmap_free(const unsigned long *bitmap);
5722     +
5723     /*
5724     * lib/bitmap.c provides these functions:
5725     */
5726     diff --git a/include/linux/device.h b/include/linux/device.h
5727     index 8d732965fab7..eb865b461acc 100644
5728     --- a/include/linux/device.h
5729     +++ b/include/linux/device.h
5730     @@ -682,7 +682,8 @@ extern unsigned long devm_get_free_pages(struct device *dev,
5731     gfp_t gfp_mask, unsigned int order);
5732     extern void devm_free_pages(struct device *dev, unsigned long addr);
5733    
5734     -void __iomem *devm_ioremap_resource(struct device *dev, struct resource *res);
5735     +void __iomem *devm_ioremap_resource(struct device *dev,
5736     + const struct resource *res);
5737    
5738     /* allows to add/remove a custom action to devres stack */
5739     int devm_add_action(struct device *dev, void (*action)(void *), void *data);
5740     diff --git a/include/linux/mlx5/mlx5_ifc.h b/include/linux/mlx5/mlx5_ifc.h
5741     index 20ee90c47cd5..6dd276227217 100644
5742     --- a/include/linux/mlx5/mlx5_ifc.h
5743     +++ b/include/linux/mlx5/mlx5_ifc.h
5744     @@ -7909,8 +7909,6 @@ struct mlx5_ifc_query_lag_out_bits {
5745    
5746     u8 syndrome[0x20];
5747    
5748     - u8 reserved_at_40[0x40];
5749     -
5750     struct mlx5_ifc_lagc_bits ctx;
5751     };
5752    
5753     diff --git a/include/linux/netfilter/ipset/ip_set.h b/include/linux/netfilter/ipset/ip_set.h
5754     index 83b9a2e0d8d4..e3a91b24a31c 100644
5755     --- a/include/linux/netfilter/ipset/ip_set.h
5756     +++ b/include/linux/netfilter/ipset/ip_set.h
5757     @@ -537,13 +537,6 @@ ip6addrptr(const struct sk_buff *skb, bool src, struct in6_addr *addr)
5758     sizeof(*addr));
5759     }
5760    
5761     -/* Calculate the bytes required to store the inclusive range of a-b */
5762     -static inline int
5763     -bitmap_bytes(u32 a, u32 b)
5764     -{
5765     - return 4 * ((((b - a + 8) / 8) + 3) / 4);
5766     -}
5767     -
5768     #include <linux/netfilter/ipset/ip_set_timeout.h>
5769     #include <linux/netfilter/ipset/ip_set_comment.h>
5770    
5771     diff --git a/include/linux/platform_data/dma-imx-sdma.h b/include/linux/platform_data/dma-imx-sdma.h
5772     index 2d08816720f6..5bb0a119f39a 100644
5773     --- a/include/linux/platform_data/dma-imx-sdma.h
5774     +++ b/include/linux/platform_data/dma-imx-sdma.h
5775     @@ -50,7 +50,10 @@ struct sdma_script_start_addrs {
5776     /* End of v2 array */
5777     s32 zcanfd_2_mcu_addr;
5778     s32 zqspi_2_mcu_addr;
5779     + s32 mcu_2_ecspi_addr;
5780     /* End of v3 array */
5781     + s32 mcu_2_zqspi_addr;
5782     + /* End of v4 array */
5783     };
5784    
5785     /**
5786     diff --git a/include/linux/signal.h b/include/linux/signal.h
5787     index 5308304993be..ffa58ff53e22 100644
5788     --- a/include/linux/signal.h
5789     +++ b/include/linux/signal.h
5790     @@ -313,6 +313,9 @@ extern void signal_setup_done(int failed, struct ksignal *ksig, int stepping);
5791     extern void exit_signals(struct task_struct *tsk);
5792     extern void kernel_sigaction(int, __sighandler_t);
5793    
5794     +#define SIG_KTHREAD ((__force __sighandler_t)2)
5795     +#define SIG_KTHREAD_KERNEL ((__force __sighandler_t)3)
5796     +
5797     static inline void allow_signal(int sig)
5798     {
5799     /*
5800     @@ -320,7 +323,17 @@ static inline void allow_signal(int sig)
5801     * know it'll be handled, so that they don't get converted to
5802     * SIGKILL or just silently dropped.
5803     */
5804     - kernel_sigaction(sig, (__force __sighandler_t)2);
5805     + kernel_sigaction(sig, SIG_KTHREAD);
5806     +}
5807     +
5808     +static inline void allow_kernel_signal(int sig)
5809     +{
5810     + /*
5811     + * Kernel threads handle their own signals. Let the signal code
5812     + * know signals sent by the kernel will be handled, so that they
5813     + * don't get silently dropped.
5814     + */
5815     + kernel_sigaction(sig, SIG_KTHREAD_KERNEL);
5816     }
5817    
5818     static inline void disallow_signal(int sig)
5819     diff --git a/include/media/davinci/vpbe.h b/include/media/davinci/vpbe.h
5820     index 4376beeb28c2..5d8ceeddc797 100644
5821     --- a/include/media/davinci/vpbe.h
5822     +++ b/include/media/davinci/vpbe.h
5823     @@ -96,7 +96,7 @@ struct vpbe_config {
5824     struct encoder_config_info *ext_encoders;
5825     /* amplifier information goes here */
5826     struct amp_config_info *amp;
5827     - int num_outputs;
5828     + unsigned int num_outputs;
5829     /* Order is venc outputs followed by LCD and then external encoders */
5830     struct vpbe_output *outputs;
5831     };
5832     diff --git a/include/trace/events/xen.h b/include/trace/events/xen.h
5833     index d6be935caa50..ecd1a0f7bd3e 100644
5834     --- a/include/trace/events/xen.h
5835     +++ b/include/trace/events/xen.h
5836     @@ -63,7 +63,11 @@ TRACE_EVENT(xen_mc_callback,
5837     TP_PROTO(xen_mc_callback_fn_t fn, void *data),
5838     TP_ARGS(fn, data),
5839     TP_STRUCT__entry(
5840     - __field(xen_mc_callback_fn_t, fn)
5841     + /*
5842     + * Use field_struct to avoid is_signed_type()
5843     + * comparison of a function pointer.
5844     + */
5845     + __field_struct(xen_mc_callback_fn_t, fn)
5846     __field(void *, data)
5847     ),
5848     TP_fast_assign(
5849     diff --git a/include/uapi/linux/ethtool.h b/include/uapi/linux/ethtool.h
5850     index 8c5335bde212..5dd3332ebc66 100644
5851     --- a/include/uapi/linux/ethtool.h
5852     +++ b/include/uapi/linux/ethtool.h
5853     @@ -1687,6 +1687,8 @@ enum ethtool_reset_flags {
5854     * %ethtool_link_mode_bit_indices for the link modes, and other
5855     * link features that the link partner advertised through
5856     * autonegotiation; 0 if unknown or not applicable. Read-only.
5857     + * @transceiver: Used to distinguish different possible PHY types,
5858     + * reported consistently by PHYLIB. Read-only.
5859     *
5860     * If autonegotiation is disabled, the speed and @duplex represent the
5861     * fixed link mode and are writable if the driver supports multiple
5862     @@ -1738,7 +1740,9 @@ struct ethtool_link_settings {
5863     __u8 eth_tp_mdix;
5864     __u8 eth_tp_mdix_ctrl;
5865     __s8 link_mode_masks_nwords;
5866     - __u32 reserved[8];
5867     + __u8 transceiver;
5868     + __u8 reserved1[3];
5869     + __u32 reserved[7];
5870     __u32 link_mode_masks[0];
5871     /* layout of link_mode_masks fields:
5872     * __u32 map_supported[link_mode_masks_nwords];
5873     diff --git a/kernel/debug/kdb/kdb_main.c b/kernel/debug/kdb/kdb_main.c
5874     index 5a58421d7e2d..a52a6da8c3d0 100644
5875     --- a/kernel/debug/kdb/kdb_main.c
5876     +++ b/kernel/debug/kdb/kdb_main.c
5877     @@ -2632,7 +2632,7 @@ static int kdb_per_cpu(int argc, const char **argv)
5878     diag = kdbgetularg(argv[3], &whichcpu);
5879     if (diag)
5880     return diag;
5881     - if (!cpu_online(whichcpu)) {
5882     + if (whichcpu >= nr_cpu_ids || !cpu_online(whichcpu)) {
5883     kdb_printf("cpu %ld is not online\n", whichcpu);
5884     return KDB_BADCPUNUM;
5885     }
5886     diff --git a/kernel/events/core.c b/kernel/events/core.c
5887     index 5bbf7537a612..64ace5e9af2a 100644
5888     --- a/kernel/events/core.c
5889     +++ b/kernel/events/core.c
5890     @@ -4624,6 +4624,9 @@ static int perf_event_period(struct perf_event *event, u64 __user *arg)
5891     if (perf_event_check_period(event, value))
5892     return -EINVAL;
5893    
5894     + if (!event->attr.freq && (value & (1ULL << 63)))
5895     + return -EINVAL;
5896     +
5897     event_function_call(event, __perf_event_period, &value);
5898    
5899     return 0;
5900     diff --git a/kernel/signal.c b/kernel/signal.c
5901     index 30914b3c76b2..57fadbe69c2e 100644
5902     --- a/kernel/signal.c
5903     +++ b/kernel/signal.c
5904     @@ -79,6 +79,11 @@ static int sig_task_ignored(struct task_struct *t, int sig, bool force)
5905     handler == SIG_DFL && !(force && sig_kernel_only(sig)))
5906     return 1;
5907    
5908     + /* Only allow kernel generated signals to this kthread */
5909     + if (unlikely((t->flags & PF_KTHREAD) &&
5910     + (handler == SIG_KTHREAD_KERNEL) && !force))
5911     + return true;
5912     +
5913     return sig_handler_ignored(handler, sig);
5914     }
5915    
5916     diff --git a/lib/bitmap.c b/lib/bitmap.c
5917     index 0b66f0e5eb6b..a44b20a829dd 100644
5918     --- a/lib/bitmap.c
5919     +++ b/lib/bitmap.c
5920     @@ -13,6 +13,7 @@
5921     #include <linux/bitops.h>
5922     #include <linux/bug.h>
5923     #include <linux/kernel.h>
5924     +#include <linux/slab.h>
5925     #include <linux/string.h>
5926     #include <linux/uaccess.h>
5927    
5928     @@ -1212,3 +1213,22 @@ void bitmap_copy_le(unsigned long *dst, const unsigned long *src, unsigned int n
5929     }
5930     EXPORT_SYMBOL(bitmap_copy_le);
5931     #endif
5932     +
5933     +unsigned long *bitmap_alloc(unsigned int nbits, gfp_t flags)
5934     +{
5935     + return kmalloc_array(BITS_TO_LONGS(nbits), sizeof(unsigned long),
5936     + flags);
5937     +}
5938     +EXPORT_SYMBOL(bitmap_alloc);
5939     +
5940     +unsigned long *bitmap_zalloc(unsigned int nbits, gfp_t flags)
5941     +{
5942     + return bitmap_alloc(nbits, flags | __GFP_ZERO);
5943     +}
5944     +EXPORT_SYMBOL(bitmap_zalloc);
5945     +
5946     +void bitmap_free(const unsigned long *bitmap)
5947     +{
5948     + kfree(bitmap);
5949     +}
5950     +EXPORT_SYMBOL(bitmap_free);
5951     diff --git a/lib/devres.c b/lib/devres.c
5952     index cb1464c411a2..38912892053c 100644
5953     --- a/lib/devres.c
5954     +++ b/lib/devres.c
5955     @@ -131,7 +131,8 @@ EXPORT_SYMBOL(devm_iounmap);
5956     * if (IS_ERR(base))
5957     * return PTR_ERR(base);
5958     */
5959     -void __iomem *devm_ioremap_resource(struct device *dev, struct resource *res)
5960     +void __iomem *devm_ioremap_resource(struct device *dev,
5961     + const struct resource *res)
5962     {
5963     resource_size_t size;
5964     const char *name;
5965     diff --git a/lib/kfifo.c b/lib/kfifo.c
5966     index 90ba1eb1df06..a94227c55551 100644
5967     --- a/lib/kfifo.c
5968     +++ b/lib/kfifo.c
5969     @@ -82,7 +82,8 @@ int __kfifo_init(struct __kfifo *fifo, void *buffer,
5970     {
5971     size /= esize;
5972    
5973     - size = roundup_pow_of_two(size);
5974     + if (!is_power_of_2(size))
5975     + size = rounddown_pow_of_two(size);
5976    
5977     fifo->in = 0;
5978     fifo->out = 0;
5979     diff --git a/net/6lowpan/nhc.c b/net/6lowpan/nhc.c
5980     index 7008d53e455c..e61679bf0908 100644
5981     --- a/net/6lowpan/nhc.c
5982     +++ b/net/6lowpan/nhc.c
5983     @@ -18,7 +18,7 @@
5984     #include "nhc.h"
5985    
5986     static struct rb_root rb_root = RB_ROOT;
5987     -static struct lowpan_nhc *lowpan_nexthdr_nhcs[NEXTHDR_MAX];
5988     +static struct lowpan_nhc *lowpan_nexthdr_nhcs[NEXTHDR_MAX + 1];
5989     static DEFINE_SPINLOCK(lowpan_nhc_lock);
5990    
5991     static int lowpan_nhc_insert(struct lowpan_nhc *nhc)
5992     diff --git a/net/bridge/netfilter/ebtables.c b/net/bridge/netfilter/ebtables.c
5993     index 56b7197f0373..1d850edecd72 100644
5994     --- a/net/bridge/netfilter/ebtables.c
5995     +++ b/net/bridge/netfilter/ebtables.c
5996     @@ -2182,7 +2182,9 @@ static int compat_copy_entries(unsigned char *data, unsigned int size_user,
5997     if (ret < 0)
5998     return ret;
5999    
6000     - WARN_ON(size_remaining);
6001     + if (size_remaining)
6002     + return -EINVAL;
6003     +
6004     return state->buf_kern_offset;
6005     }
6006    
6007     diff --git a/net/core/ethtool.c b/net/core/ethtool.c
6008     index 476665f917a2..47d2d6e2b780 100644
6009     --- a/net/core/ethtool.c
6010     +++ b/net/core/ethtool.c
6011     @@ -514,6 +514,8 @@ convert_link_ksettings_to_legacy_settings(
6012     = link_ksettings->base.eth_tp_mdix;
6013     legacy_settings->eth_tp_mdix_ctrl
6014     = link_ksettings->base.eth_tp_mdix_ctrl;
6015     + legacy_settings->transceiver
6016     + = link_ksettings->base.transceiver;
6017     return retval;
6018     }
6019    
6020     diff --git a/net/core/neighbour.c b/net/core/neighbour.c
6021     index cd85cee14bd0..6578d1f8e6c4 100644
6022     --- a/net/core/neighbour.c
6023     +++ b/net/core/neighbour.c
6024     @@ -1834,8 +1834,8 @@ static int neightbl_fill_info(struct sk_buff *skb, struct neigh_table *tbl,
6025     goto nla_put_failure;
6026     {
6027     unsigned long now = jiffies;
6028     - unsigned int flush_delta = now - tbl->last_flush;
6029     - unsigned int rand_delta = now - tbl->last_rand;
6030     + long flush_delta = now - tbl->last_flush;
6031     + long rand_delta = now - tbl->last_rand;
6032     struct neigh_hash_table *nht;
6033     struct ndt_config ndc = {
6034     .ndtc_key_len = tbl->key_len,
6035     diff --git a/net/ieee802154/6lowpan/reassembly.c b/net/ieee802154/6lowpan/reassembly.c
6036     index c01df341b5f6..5936bfafb1c4 100644
6037     --- a/net/ieee802154/6lowpan/reassembly.c
6038     +++ b/net/ieee802154/6lowpan/reassembly.c
6039     @@ -633,7 +633,7 @@ err_sysctl:
6040    
6041     void lowpan_net_frag_exit(void)
6042     {
6043     - inet_frags_fini(&lowpan_frags);
6044     lowpan_frags_sysctl_unregister();
6045     unregister_pernet_subsys(&lowpan_frags_ops);
6046     + inet_frags_fini(&lowpan_frags);
6047     }
6048     diff --git a/net/ipv4/ip_tunnel.c b/net/ipv4/ip_tunnel.c
6049     index a4db2d79b913..65c47b1f0da4 100644
6050     --- a/net/ipv4/ip_tunnel.c
6051     +++ b/net/ipv4/ip_tunnel.c
6052     @@ -1184,10 +1184,8 @@ int ip_tunnel_init(struct net_device *dev)
6053     iph->version = 4;
6054     iph->ihl = 5;
6055    
6056     - if (tunnel->collect_md) {
6057     - dev->features |= NETIF_F_NETNS_LOCAL;
6058     + if (tunnel->collect_md)
6059     netif_keep_dst(dev);
6060     - }
6061     return 0;
6062     }
6063     EXPORT_SYMBOL_GPL(ip_tunnel_init);
6064     diff --git a/net/ipv4/tcp_bbr.c b/net/ipv4/tcp_bbr.c
6065     index 7e44d23b0328..3bfab2d41574 100644
6066     --- a/net/ipv4/tcp_bbr.c
6067     +++ b/net/ipv4/tcp_bbr.c
6068     @@ -649,8 +649,7 @@ static void bbr_update_bw(struct sock *sk, const struct rate_sample *rs)
6069     * bandwidth sample. Delivered is in packets and interval_us in uS and
6070     * ratio will be <<1 for most connections. So delivered is first scaled.
6071     */
6072     - bw = (u64)rs->delivered * BW_UNIT;
6073     - do_div(bw, rs->interval_us);
6074     + bw = div64_long((u64)rs->delivered * BW_UNIT, rs->interval_us);
6075    
6076     /* If this sample is application-limited, it is likely to have a very
6077     * low delivered count that represents application behavior rather than
6078     diff --git a/net/ipv6/ip6_tunnel.c b/net/ipv6/ip6_tunnel.c
6079     index cc28b8646986..ed795d50a8d2 100644
6080     --- a/net/ipv6/ip6_tunnel.c
6081     +++ b/net/ipv6/ip6_tunnel.c
6082     @@ -1861,10 +1861,8 @@ static int ip6_tnl_dev_init(struct net_device *dev)
6083     if (err)
6084     return err;
6085     ip6_tnl_link_config(t);
6086     - if (t->parms.collect_md) {
6087     - dev->features |= NETIF_F_NETNS_LOCAL;
6088     + if (t->parms.collect_md)
6089     netif_keep_dst(dev);
6090     - }
6091     return 0;
6092     }
6093    
6094     diff --git a/net/ipv6/reassembly.c b/net/ipv6/reassembly.c
6095     index 4aed9c45a91a..3f488555999e 100644
6096     --- a/net/ipv6/reassembly.c
6097     +++ b/net/ipv6/reassembly.c
6098     @@ -592,8 +592,8 @@ err_protocol:
6099    
6100     void ipv6_frag_exit(void)
6101     {
6102     - inet_frags_fini(&ip6_frags);
6103     ip6_frags_sysctl_unregister();
6104     unregister_pernet_subsys(&ip6_frags_ops);
6105     inet6_del_protocol(&frag_protocol, IPPROTO_FRAGMENT);
6106     + inet_frags_fini(&ip6_frags);
6107     }
6108     diff --git a/net/iucv/af_iucv.c b/net/iucv/af_iucv.c
6109     index c2dfc32eb9f2..02e10deef5b4 100644
6110     --- a/net/iucv/af_iucv.c
6111     +++ b/net/iucv/af_iucv.c
6112     @@ -2431,6 +2431,13 @@ out:
6113     return err;
6114     }
6115    
6116     +static void afiucv_iucv_exit(void)
6117     +{
6118     + device_unregister(af_iucv_dev);
6119     + driver_unregister(&af_iucv_driver);
6120     + pr_iucv->iucv_unregister(&af_iucv_handler, 0);
6121     +}
6122     +
6123     static int __init afiucv_init(void)
6124     {
6125     int err;
6126     @@ -2464,11 +2471,18 @@ static int __init afiucv_init(void)
6127     err = afiucv_iucv_init();
6128     if (err)
6129     goto out_sock;
6130     - } else
6131     - register_netdevice_notifier(&afiucv_netdev_notifier);
6132     + }
6133     +
6134     + err = register_netdevice_notifier(&afiucv_netdev_notifier);
6135     + if (err)
6136     + goto out_notifier;
6137     +
6138     dev_add_pack(&iucv_packet_type);
6139     return 0;
6140    
6141     +out_notifier:
6142     + if (pr_iucv)
6143     + afiucv_iucv_exit();
6144     out_sock:
6145     sock_unregister(PF_IUCV);
6146     out_proto:
6147     @@ -2482,12 +2496,11 @@ out:
6148     static void __exit afiucv_exit(void)
6149     {
6150     if (pr_iucv) {
6151     - device_unregister(af_iucv_dev);
6152     - driver_unregister(&af_iucv_driver);
6153     - pr_iucv->iucv_unregister(&af_iucv_handler, 0);
6154     + afiucv_iucv_exit();
6155     symbol_put(iucv_if);
6156     - } else
6157     - unregister_netdevice_notifier(&afiucv_netdev_notifier);
6158     + }
6159     +
6160     + unregister_netdevice_notifier(&afiucv_netdev_notifier);
6161     dev_remove_pack(&iucv_packet_type);
6162     sock_unregister(PF_IUCV);
6163     proto_unregister(&iucv_proto);
6164     diff --git a/net/l2tp/l2tp_core.c b/net/l2tp/l2tp_core.c
6165     index 4ae758bcb2cf..394a1ddb0782 100644
6166     --- a/net/l2tp/l2tp_core.c
6167     +++ b/net/l2tp/l2tp_core.c
6168     @@ -1947,7 +1947,8 @@ static __net_exit void l2tp_exit_net(struct net *net)
6169     }
6170     rcu_read_unlock_bh();
6171    
6172     - flush_workqueue(l2tp_wq);
6173     + if (l2tp_wq)
6174     + flush_workqueue(l2tp_wq);
6175     rcu_barrier();
6176     }
6177    
6178     diff --git a/net/llc/af_llc.c b/net/llc/af_llc.c
6179     index 789e66b0187a..2a859f967c8a 100644
6180     --- a/net/llc/af_llc.c
6181     +++ b/net/llc/af_llc.c
6182     @@ -111,22 +111,26 @@ static inline u8 llc_ui_header_len(struct sock *sk, struct sockaddr_llc *addr)
6183     *
6184     * Send data via reliable llc2 connection.
6185     * Returns 0 upon success, non-zero if action did not succeed.
6186     + *
6187     + * This function always consumes a reference to the skb.
6188     */
6189     static int llc_ui_send_data(struct sock* sk, struct sk_buff *skb, int noblock)
6190     {
6191     struct llc_sock* llc = llc_sk(sk);
6192     - int rc = 0;
6193    
6194     if (unlikely(llc_data_accept_state(llc->state) ||
6195     llc->remote_busy_flag ||
6196     llc->p_flag)) {
6197     long timeout = sock_sndtimeo(sk, noblock);
6198     + int rc;
6199    
6200     rc = llc_ui_wait_for_busy_core(sk, timeout);
6201     + if (rc) {
6202     + kfree_skb(skb);
6203     + return rc;
6204     + }
6205     }
6206     - if (unlikely(!rc))
6207     - rc = llc_build_and_send_pkt(sk, skb);
6208     - return rc;
6209     + return llc_build_and_send_pkt(sk, skb);
6210     }
6211    
6212     static void llc_ui_sk_init(struct socket *sock, struct sock *sk)
6213     @@ -896,7 +900,7 @@ static int llc_ui_sendmsg(struct socket *sock, struct msghdr *msg, size_t len)
6214     DECLARE_SOCKADDR(struct sockaddr_llc *, addr, msg->msg_name);
6215     int flags = msg->msg_flags;
6216     int noblock = flags & MSG_DONTWAIT;
6217     - struct sk_buff *skb;
6218     + struct sk_buff *skb = NULL;
6219     size_t size = 0;
6220     int rc = -EINVAL, copied = 0, hdrlen;
6221    
6222     @@ -905,10 +909,10 @@ static int llc_ui_sendmsg(struct socket *sock, struct msghdr *msg, size_t len)
6223     lock_sock(sk);
6224     if (addr) {
6225     if (msg->msg_namelen < sizeof(*addr))
6226     - goto release;
6227     + goto out;
6228     } else {
6229     if (llc_ui_addr_null(&llc->addr))
6230     - goto release;
6231     + goto out;
6232     addr = &llc->addr;
6233     }
6234     /* must bind connection to sap if user hasn't done it. */
6235     @@ -916,7 +920,7 @@ static int llc_ui_sendmsg(struct socket *sock, struct msghdr *msg, size_t len)
6236     /* bind to sap with null dev, exclusive. */
6237     rc = llc_ui_autobind(sock, addr);
6238     if (rc)
6239     - goto release;
6240     + goto out;
6241     }
6242     hdrlen = llc->dev->hard_header_len + llc_ui_header_len(sk, addr);
6243     size = hdrlen + len;
6244     @@ -925,12 +929,12 @@ static int llc_ui_sendmsg(struct socket *sock, struct msghdr *msg, size_t len)
6245     copied = size - hdrlen;
6246     rc = -EINVAL;
6247     if (copied < 0)
6248     - goto release;
6249     + goto out;
6250     release_sock(sk);
6251     skb = sock_alloc_send_skb(sk, size, noblock, &rc);
6252     lock_sock(sk);
6253     if (!skb)
6254     - goto release;
6255     + goto out;
6256     skb->dev = llc->dev;
6257     skb->protocol = llc_proto_type(addr->sllc_arphrd);
6258     skb_reserve(skb, hdrlen);
6259     @@ -940,29 +944,31 @@ static int llc_ui_sendmsg(struct socket *sock, struct msghdr *msg, size_t len)
6260     if (sk->sk_type == SOCK_DGRAM || addr->sllc_ua) {
6261     llc_build_and_send_ui_pkt(llc->sap, skb, addr->sllc_mac,
6262     addr->sllc_sap);
6263     + skb = NULL;
6264     goto out;
6265     }
6266     if (addr->sllc_test) {
6267     llc_build_and_send_test_pkt(llc->sap, skb, addr->sllc_mac,
6268     addr->sllc_sap);
6269     + skb = NULL;
6270     goto out;
6271     }
6272     if (addr->sllc_xid) {
6273     llc_build_and_send_xid_pkt(llc->sap, skb, addr->sllc_mac,
6274     addr->sllc_sap);
6275     + skb = NULL;
6276     goto out;
6277     }
6278     rc = -ENOPROTOOPT;
6279     if (!(sk->sk_type == SOCK_STREAM && !addr->sllc_ua))
6280     goto out;
6281     rc = llc_ui_send_data(sk, skb, noblock);
6282     + skb = NULL;
6283     out:
6284     - if (rc) {
6285     - kfree_skb(skb);
6286     -release:
6287     + kfree_skb(skb);
6288     + if (rc)
6289     dprintk("%s: failed sending from %02X to %02X: %d\n",
6290     __func__, llc->laddr.lsap, llc->daddr.lsap, rc);
6291     - }
6292     release_sock(sk);
6293     return rc ? : copied;
6294     }
6295     diff --git a/net/llc/llc_conn.c b/net/llc/llc_conn.c
6296     index 94c78cc49d3e..1bdbd134bd7a 100644
6297     --- a/net/llc/llc_conn.c
6298     +++ b/net/llc/llc_conn.c
6299     @@ -55,6 +55,8 @@ int sysctl_llc2_busy_timeout = LLC2_BUSY_TIME * HZ;
6300     * (executing it's actions and changing state), upper layer will be
6301     * indicated or confirmed, if needed. Returns 0 for success, 1 for
6302     * failure. The socket lock has to be held before calling this function.
6303     + *
6304     + * This function always consumes a reference to the skb.
6305     */
6306     int llc_conn_state_process(struct sock *sk, struct sk_buff *skb)
6307     {
6308     @@ -62,12 +64,6 @@ int llc_conn_state_process(struct sock *sk, struct sk_buff *skb)
6309     struct llc_sock *llc = llc_sk(skb->sk);
6310     struct llc_conn_state_ev *ev = llc_conn_ev(skb);
6311    
6312     - /*
6313     - * We have to hold the skb, because llc_conn_service will kfree it in
6314     - * the sending path and we need to look at the skb->cb, where we encode
6315     - * llc_conn_state_ev.
6316     - */
6317     - skb_get(skb);
6318     ev->ind_prim = ev->cfm_prim = 0;
6319     /*
6320     * Send event to state machine
6321     @@ -75,21 +71,12 @@ int llc_conn_state_process(struct sock *sk, struct sk_buff *skb)
6322     rc = llc_conn_service(skb->sk, skb);
6323     if (unlikely(rc != 0)) {
6324     printk(KERN_ERR "%s: llc_conn_service failed\n", __func__);
6325     - goto out_kfree_skb;
6326     - }
6327     -
6328     - if (unlikely(!ev->ind_prim && !ev->cfm_prim)) {
6329     - /* indicate or confirm not required */
6330     - if (!skb->next)
6331     - goto out_kfree_skb;
6332     goto out_skb_put;
6333     }
6334    
6335     - if (unlikely(ev->ind_prim && ev->cfm_prim)) /* Paranoia */
6336     - skb_get(skb);
6337     -
6338     switch (ev->ind_prim) {
6339     case LLC_DATA_PRIM:
6340     + skb_get(skb);
6341     llc_save_primitive(sk, skb, LLC_DATA_PRIM);
6342     if (unlikely(sock_queue_rcv_skb(sk, skb))) {
6343     /*
6344     @@ -106,6 +93,7 @@ int llc_conn_state_process(struct sock *sk, struct sk_buff *skb)
6345     * skb->sk pointing to the newly created struct sock in
6346     * llc_conn_handler. -acme
6347     */
6348     + skb_get(skb);
6349     skb_queue_tail(&sk->sk_receive_queue, skb);
6350     sk->sk_state_change(sk);
6351     break;
6352     @@ -121,7 +109,6 @@ int llc_conn_state_process(struct sock *sk, struct sk_buff *skb)
6353     sk->sk_state_change(sk);
6354     }
6355     }
6356     - kfree_skb(skb);
6357     sock_put(sk);
6358     break;
6359     case LLC_RESET_PRIM:
6360     @@ -130,14 +117,11 @@ int llc_conn_state_process(struct sock *sk, struct sk_buff *skb)
6361     * RESET is not being notified to upper layers for now
6362     */
6363     printk(KERN_INFO "%s: received a reset ind!\n", __func__);
6364     - kfree_skb(skb);
6365     break;
6366     default:
6367     - if (ev->ind_prim) {
6368     + if (ev->ind_prim)
6369     printk(KERN_INFO "%s: received unknown %d prim!\n",
6370     __func__, ev->ind_prim);
6371     - kfree_skb(skb);
6372     - }
6373     /* No indication */
6374     break;
6375     }
6376     @@ -179,15 +163,12 @@ int llc_conn_state_process(struct sock *sk, struct sk_buff *skb)
6377     printk(KERN_INFO "%s: received a reset conf!\n", __func__);
6378     break;
6379     default:
6380     - if (ev->cfm_prim) {
6381     + if (ev->cfm_prim)
6382     printk(KERN_INFO "%s: received unknown %d prim!\n",
6383     __func__, ev->cfm_prim);
6384     - break;
6385     - }
6386     - goto out_skb_put; /* No confirmation */
6387     + /* No confirmation */
6388     + break;
6389     }
6390     -out_kfree_skb:
6391     - kfree_skb(skb);
6392     out_skb_put:
6393     kfree_skb(skb);
6394     return rc;
6395     diff --git a/net/llc/llc_if.c b/net/llc/llc_if.c
6396     index 6daf391b3e84..fc4d2bd8816f 100644
6397     --- a/net/llc/llc_if.c
6398     +++ b/net/llc/llc_if.c
6399     @@ -38,6 +38,8 @@
6400     * closed and -EBUSY when sending data is not permitted in this state or
6401     * LLC has send an I pdu with p bit set to 1 and is waiting for it's
6402     * response.
6403     + *
6404     + * This function always consumes a reference to the skb.
6405     */
6406     int llc_build_and_send_pkt(struct sock *sk, struct sk_buff *skb)
6407     {
6408     @@ -46,20 +48,22 @@ int llc_build_and_send_pkt(struct sock *sk, struct sk_buff *skb)
6409     struct llc_sock *llc = llc_sk(sk);
6410    
6411     if (unlikely(llc->state == LLC_CONN_STATE_ADM))
6412     - goto out;
6413     + goto out_free;
6414     rc = -EBUSY;
6415     if (unlikely(llc_data_accept_state(llc->state) || /* data_conn_refuse */
6416     llc->p_flag)) {
6417     llc->failed_data_req = 1;
6418     - goto out;
6419     + goto out_free;
6420     }
6421     ev = llc_conn_ev(skb);
6422     ev->type = LLC_CONN_EV_TYPE_PRIM;
6423     ev->prim = LLC_DATA_PRIM;
6424     ev->prim_type = LLC_PRIM_TYPE_REQ;
6425     skb->dev = llc->dev;
6426     - rc = llc_conn_state_process(sk, skb);
6427     -out:
6428     + return llc_conn_state_process(sk, skb);
6429     +
6430     +out_free:
6431     + kfree_skb(skb);
6432     return rc;
6433     }
6434    
6435     diff --git a/net/mac80211/rc80211_minstrel_ht.c b/net/mac80211/rc80211_minstrel_ht.c
6436     index 593184d14b3e..e1b0e26c1f17 100644
6437     --- a/net/mac80211/rc80211_minstrel_ht.c
6438     +++ b/net/mac80211/rc80211_minstrel_ht.c
6439     @@ -547,7 +547,7 @@ minstrel_ht_update_stats(struct minstrel_priv *mp, struct minstrel_ht_sta *mi)
6440    
6441     /* (re)Initialize group rate indexes */
6442     for(j = 0; j < MAX_THR_RATES; j++)
6443     - tmp_group_tp_rate[j] = group;
6444     + tmp_group_tp_rate[j] = MCS_GROUP_RATES * group;
6445    
6446     for (i = 0; i < MCS_GROUP_RATES; i++) {
6447     if (!(mg->supported & BIT(i)))
6448     diff --git a/net/mac80211/rx.c b/net/mac80211/rx.c
6449     index 3b423c50ec8f..74652eb2f90f 100644
6450     --- a/net/mac80211/rx.c
6451     +++ b/net/mac80211/rx.c
6452     @@ -3205,9 +3205,18 @@ ieee80211_rx_h_mgmt(struct ieee80211_rx_data *rx)
6453     case cpu_to_le16(IEEE80211_STYPE_PROBE_RESP):
6454     /* process for all: mesh, mlme, ibss */
6455     break;
6456     + case cpu_to_le16(IEEE80211_STYPE_DEAUTH):
6457     + if (is_multicast_ether_addr(mgmt->da) &&
6458     + !is_broadcast_ether_addr(mgmt->da))
6459     + return RX_DROP_MONITOR;
6460     +
6461     + /* process only for station/IBSS */
6462     + if (sdata->vif.type != NL80211_IFTYPE_STATION &&
6463     + sdata->vif.type != NL80211_IFTYPE_ADHOC)
6464     + return RX_DROP_MONITOR;
6465     + break;
6466     case cpu_to_le16(IEEE80211_STYPE_ASSOC_RESP):
6467     case cpu_to_le16(IEEE80211_STYPE_REASSOC_RESP):
6468     - case cpu_to_le16(IEEE80211_STYPE_DEAUTH):
6469     case cpu_to_le16(IEEE80211_STYPE_DISASSOC):
6470     if (is_multicast_ether_addr(mgmt->da) &&
6471     !is_broadcast_ether_addr(mgmt->da))
6472     diff --git a/net/netfilter/ipset/ip_set_bitmap_gen.h b/net/netfilter/ipset/ip_set_bitmap_gen.h
6473     index 9b32059dee2d..7536cdd2da28 100644
6474     --- a/net/netfilter/ipset/ip_set_bitmap_gen.h
6475     +++ b/net/netfilter/ipset/ip_set_bitmap_gen.h
6476     @@ -81,7 +81,7 @@ mtype_flush(struct ip_set *set)
6477    
6478     if (set->extensions & IPSET_EXT_DESTROY)
6479     mtype_ext_cleanup(set);
6480     - memset(map->members, 0, map->memsize);
6481     + bitmap_zero(map->members, map->elements);
6482     }
6483    
6484     static int
6485     diff --git a/net/netfilter/ipset/ip_set_bitmap_ip.c b/net/netfilter/ipset/ip_set_bitmap_ip.c
6486     index 4783efff0bde..a4c104a4977f 100644
6487     --- a/net/netfilter/ipset/ip_set_bitmap_ip.c
6488     +++ b/net/netfilter/ipset/ip_set_bitmap_ip.c
6489     @@ -40,7 +40,7 @@ MODULE_ALIAS("ip_set_bitmap:ip");
6490    
6491     /* Type structure */
6492     struct bitmap_ip {
6493     - void *members; /* the set members */
6494     + unsigned long *members; /* the set members */
6495     u32 first_ip; /* host byte order, included in range */
6496     u32 last_ip; /* host byte order, included in range */
6497     u32 elements; /* number of max elements in the set */
6498     @@ -222,7 +222,7 @@ init_map_ip(struct ip_set *set, struct bitmap_ip *map,
6499     u32 first_ip, u32 last_ip,
6500     u32 elements, u32 hosts, u8 netmask)
6501     {
6502     - map->members = ip_set_alloc(map->memsize);
6503     + map->members = bitmap_zalloc(elements, GFP_KERNEL | __GFP_NOWARN);
6504     if (!map->members)
6505     return false;
6506     map->first_ip = first_ip;
6507     @@ -315,7 +315,7 @@ bitmap_ip_create(struct net *net, struct ip_set *set, struct nlattr *tb[],
6508     if (!map)
6509     return -ENOMEM;
6510    
6511     - map->memsize = bitmap_bytes(0, elements - 1);
6512     + map->memsize = BITS_TO_LONGS(elements) * sizeof(unsigned long);
6513     set->variant = &bitmap_ip;
6514     if (!init_map_ip(set, map, first_ip, last_ip,
6515     elements, hosts, netmask)) {
6516     diff --git a/net/netfilter/ipset/ip_set_bitmap_ipmac.c b/net/netfilter/ipset/ip_set_bitmap_ipmac.c
6517     index 9a065f672d3a..8e58e7e34981 100644
6518     --- a/net/netfilter/ipset/ip_set_bitmap_ipmac.c
6519     +++ b/net/netfilter/ipset/ip_set_bitmap_ipmac.c
6520     @@ -46,7 +46,7 @@ enum {
6521    
6522     /* Type structure */
6523     struct bitmap_ipmac {
6524     - void *members; /* the set members */
6525     + unsigned long *members; /* the set members */
6526     u32 first_ip; /* host byte order, included in range */
6527     u32 last_ip; /* host byte order, included in range */
6528     u32 elements; /* number of max elements in the set */
6529     @@ -299,7 +299,7 @@ static bool
6530     init_map_ipmac(struct ip_set *set, struct bitmap_ipmac *map,
6531     u32 first_ip, u32 last_ip, u32 elements)
6532     {
6533     - map->members = ip_set_alloc(map->memsize);
6534     + map->members = bitmap_zalloc(elements, GFP_KERNEL | __GFP_NOWARN);
6535     if (!map->members)
6536     return false;
6537     map->first_ip = first_ip;
6538     @@ -363,7 +363,7 @@ bitmap_ipmac_create(struct net *net, struct ip_set *set, struct nlattr *tb[],
6539     if (!map)
6540     return -ENOMEM;
6541    
6542     - map->memsize = bitmap_bytes(0, elements - 1);
6543     + map->memsize = BITS_TO_LONGS(elements) * sizeof(unsigned long);
6544     set->variant = &bitmap_ipmac;
6545     if (!init_map_ipmac(set, map, first_ip, last_ip, elements)) {
6546     kfree(map);
6547     diff --git a/net/netfilter/ipset/ip_set_bitmap_port.c b/net/netfilter/ipset/ip_set_bitmap_port.c
6548     index 7f0c733358a4..6771b362a123 100644
6549     --- a/net/netfilter/ipset/ip_set_bitmap_port.c
6550     +++ b/net/netfilter/ipset/ip_set_bitmap_port.c
6551     @@ -34,7 +34,7 @@ MODULE_ALIAS("ip_set_bitmap:port");
6552    
6553     /* Type structure */
6554     struct bitmap_port {
6555     - void *members; /* the set members */
6556     + unsigned long *members; /* the set members */
6557     u16 first_port; /* host byte order, included in range */
6558     u16 last_port; /* host byte order, included in range */
6559     u32 elements; /* number of max elements in the set */
6560     @@ -207,7 +207,7 @@ static bool
6561     init_map_port(struct ip_set *set, struct bitmap_port *map,
6562     u16 first_port, u16 last_port)
6563     {
6564     - map->members = ip_set_alloc(map->memsize);
6565     + map->members = bitmap_zalloc(map->elements, GFP_KERNEL | __GFP_NOWARN);
6566     if (!map->members)
6567     return false;
6568     map->first_port = first_port;
6569     @@ -250,7 +250,7 @@ bitmap_port_create(struct net *net, struct ip_set *set, struct nlattr *tb[],
6570     return -ENOMEM;
6571    
6572     map->elements = elements;
6573     - map->memsize = bitmap_bytes(0, map->elements);
6574     + map->memsize = BITS_TO_LONGS(elements) * sizeof(unsigned long);
6575     set->variant = &bitmap_port;
6576     if (!init_map_port(set, map, first_port, last_port)) {
6577     kfree(map);
6578     diff --git a/net/packet/af_packet.c b/net/packet/af_packet.c
6579     index 40cade140222..fb643945e424 100644
6580     --- a/net/packet/af_packet.c
6581     +++ b/net/packet/af_packet.c
6582     @@ -1332,15 +1332,21 @@ static void packet_sock_destruct(struct sock *sk)
6583    
6584     static bool fanout_flow_is_huge(struct packet_sock *po, struct sk_buff *skb)
6585     {
6586     - u32 rxhash;
6587     + u32 *history = po->rollover->history;
6588     + u32 victim, rxhash;
6589     int i, count = 0;
6590    
6591     rxhash = skb_get_hash(skb);
6592     for (i = 0; i < ROLLOVER_HLEN; i++)
6593     - if (po->rollover->history[i] == rxhash)
6594     + if (READ_ONCE(history[i]) == rxhash)
6595     count++;
6596    
6597     - po->rollover->history[prandom_u32() % ROLLOVER_HLEN] = rxhash;
6598     + victim = prandom_u32() % ROLLOVER_HLEN;
6599     +
6600     + /* Avoid dirtying the cache line if possible */
6601     + if (READ_ONCE(history[victim]) != rxhash)
6602     + WRITE_ONCE(history[victim], rxhash);
6603     +
6604     return count > (ROLLOVER_HLEN >> 1);
6605     }
6606    
6607     @@ -3404,20 +3410,29 @@ static int packet_recvmsg(struct socket *sock, struct msghdr *msg, size_t len,
6608     sock_recv_ts_and_drops(msg, sk, skb);
6609    
6610     if (msg->msg_name) {
6611     + int copy_len;
6612     +
6613     /* If the address length field is there to be filled
6614     * in, we fill it in now.
6615     */
6616     if (sock->type == SOCK_PACKET) {
6617     __sockaddr_check_size(sizeof(struct sockaddr_pkt));
6618     msg->msg_namelen = sizeof(struct sockaddr_pkt);
6619     + copy_len = msg->msg_namelen;
6620     } else {
6621     struct sockaddr_ll *sll = &PACKET_SKB_CB(skb)->sa.ll;
6622    
6623     msg->msg_namelen = sll->sll_halen +
6624     offsetof(struct sockaddr_ll, sll_addr);
6625     + copy_len = msg->msg_namelen;
6626     + if (msg->msg_namelen < sizeof(struct sockaddr_ll)) {
6627     + memset(msg->msg_name +
6628     + offsetof(struct sockaddr_ll, sll_addr),
6629     + 0, sizeof(sll->sll_addr));
6630     + msg->msg_namelen = sizeof(struct sockaddr_ll);
6631     + }
6632     }
6633     - memcpy(msg->msg_name, &PACKET_SKB_CB(skb)->sa,
6634     - msg->msg_namelen);
6635     + memcpy(msg->msg_name, &PACKET_SKB_CB(skb)->sa, copy_len);
6636     }
6637    
6638     if (pkt_sk(sk)->auxdata) {
6639     diff --git a/net/rds/ib_stats.c b/net/rds/ib_stats.c
6640     index 7e78dca1f252..aaf4b3d10203 100644
6641     --- a/net/rds/ib_stats.c
6642     +++ b/net/rds/ib_stats.c
6643     @@ -42,7 +42,7 @@ DEFINE_PER_CPU_SHARED_ALIGNED(struct rds_ib_statistics, rds_ib_stats);
6644     static const char *const rds_ib_stat_names[] = {
6645     "ib_connect_raced",
6646     "ib_listen_closed_stale",
6647     - "s_ib_evt_handler_call",
6648     + "ib_evt_handler_call",
6649     "ib_tasklet_call",
6650     "ib_tx_cq_event",
6651     "ib_tx_ring_full",
6652     diff --git a/net/rxrpc/output.c b/net/rxrpc/output.c
6653     index 59d328603312..64389f493bb2 100644
6654     --- a/net/rxrpc/output.c
6655     +++ b/net/rxrpc/output.c
6656     @@ -400,6 +400,9 @@ send_fragmentable:
6657     }
6658     break;
6659     #endif
6660     +
6661     + default:
6662     + BUG();
6663     }
6664    
6665     up_write(&conn->params.local->defrag_sem);
6666     diff --git a/net/sched/act_mirred.c b/net/sched/act_mirred.c
6667     index fc3650b06192..9b4c7c42c932 100644
6668     --- a/net/sched/act_mirred.c
6669     +++ b/net/sched/act_mirred.c
6670     @@ -332,7 +332,11 @@ static int __init mirred_init_module(void)
6671     return err;
6672    
6673     pr_info("Mirror/redirect action on\n");
6674     - return tcf_register_action(&act_mirred_ops, &mirred_net_ops);
6675     + err = tcf_register_action(&act_mirred_ops, &mirred_net_ops);
6676     + if (err)
6677     + unregister_netdevice_notifier(&mirred_device_notifier);
6678     +
6679     + return err;
6680     }
6681    
6682     static void __exit mirred_cleanup_module(void)
6683     diff --git a/net/sched/ematch.c b/net/sched/ematch.c
6684     index fbb7ebfc58c6..b0b04b3c0896 100644
6685     --- a/net/sched/ematch.c
6686     +++ b/net/sched/ematch.c
6687     @@ -267,12 +267,12 @@ static int tcf_em_validate(struct tcf_proto *tp,
6688     }
6689     em->data = (unsigned long) v;
6690     }
6691     + em->datalen = data_len;
6692     }
6693     }
6694    
6695     em->matchid = em_hdr->matchid;
6696     em->flags = em_hdr->flags;
6697     - em->datalen = data_len;
6698     em->net = net;
6699    
6700     err = 0;
6701     diff --git a/net/sched/sch_netem.c b/net/sched/sch_netem.c
6702     index 95002e56fa48..e06491314d59 100644
6703     --- a/net/sched/sch_netem.c
6704     +++ b/net/sched/sch_netem.c
6705     @@ -437,8 +437,7 @@ static int netem_enqueue(struct sk_buff *skb, struct Qdisc *sch,
6706     struct netem_skb_cb *cb;
6707     struct sk_buff *skb2;
6708     struct sk_buff *segs = NULL;
6709     - unsigned int len = 0, last_len, prev_len = qdisc_pkt_len(skb);
6710     - int nb = 0;
6711     + unsigned int prev_len = qdisc_pkt_len(skb);
6712     int count = 1;
6713     int rc = NET_XMIT_SUCCESS;
6714     int rc_drop = NET_XMIT_DROP;
6715     @@ -495,6 +494,7 @@ static int netem_enqueue(struct sk_buff *skb, struct Qdisc *sch,
6716     segs = netem_segment(skb, sch, to_free);
6717     if (!segs)
6718     return rc_drop;
6719     + qdisc_skb_cb(segs)->pkt_len = segs->len;
6720     } else {
6721     segs = skb;
6722     }
6723     @@ -510,6 +510,7 @@ static int netem_enqueue(struct sk_buff *skb, struct Qdisc *sch,
6724     if (skb->ip_summed == CHECKSUM_PARTIAL &&
6725     skb_checksum_help(skb)) {
6726     qdisc_drop(skb, sch, to_free);
6727     + skb = NULL;
6728     goto finish_segs;
6729     }
6730    
6731     @@ -585,6 +586,12 @@ static int netem_enqueue(struct sk_buff *skb, struct Qdisc *sch,
6732    
6733     finish_segs:
6734     if (segs) {
6735     + unsigned int len, last_len;
6736     + int nb;
6737     +
6738     + len = skb ? skb->len : 0;
6739     + nb = skb ? 1 : 0;
6740     +
6741     while (segs) {
6742     skb2 = segs->next;
6743     segs->next = NULL;
6744     @@ -600,9 +607,10 @@ finish_segs:
6745     }
6746     segs = skb2;
6747     }
6748     - sch->q.qlen += nb;
6749     - if (nb > 1)
6750     - qdisc_tree_reduce_backlog(sch, 1 - nb, prev_len - len);
6751     + /* Parent qdiscs accounted for 1 skb of size @prev_len */
6752     + qdisc_tree_reduce_backlog(sch, -(nb - 1), -(len - prev_len));
6753     + } else if (!skb) {
6754     + return NET_XMIT_DROP;
6755     }
6756     return NET_XMIT_SUCCESS;
6757     }
6758     diff --git a/net/tipc/node.c b/net/tipc/node.c
6759     index db8fbc076e1a..fe7b0ad1d6f3 100644
6760     --- a/net/tipc/node.c
6761     +++ b/net/tipc/node.c
6762     @@ -688,10 +688,10 @@ static void __tipc_node_link_down(struct tipc_node *n, int *bearer_id,
6763     static void tipc_node_link_down(struct tipc_node *n, int bearer_id, bool delete)
6764     {
6765     struct tipc_link_entry *le = &n->links[bearer_id];
6766     + struct tipc_media_addr *maddr = NULL;
6767     struct tipc_link *l = le->link;
6768     - struct tipc_media_addr *maddr;
6769     - struct sk_buff_head xmitq;
6770     int old_bearer_id = bearer_id;
6771     + struct sk_buff_head xmitq;
6772    
6773     if (!l)
6774     return;
6775     @@ -713,7 +713,8 @@ static void tipc_node_link_down(struct tipc_node *n, int bearer_id, bool delete)
6776     tipc_node_write_unlock(n);
6777     if (delete)
6778     tipc_mon_remove_peer(n->net, n->addr, old_bearer_id);
6779     - tipc_bearer_xmit(n->net, bearer_id, &xmitq, maddr);
6780     + if (!skb_queue_empty(&xmitq))
6781     + tipc_bearer_xmit(n->net, bearer_id, &xmitq, maddr);
6782     tipc_sk_rcv(n->net, &le->inputq);
6783     }
6784    
6785     diff --git a/net/tipc/sysctl.c b/net/tipc/sysctl.c
6786     index 1a779b1e8510..40f6d82083d7 100644
6787     --- a/net/tipc/sysctl.c
6788     +++ b/net/tipc/sysctl.c
6789     @@ -37,6 +37,8 @@
6790    
6791     #include <linux/sysctl.h>
6792    
6793     +static int zero;
6794     +static int one = 1;
6795     static struct ctl_table_header *tipc_ctl_hdr;
6796    
6797     static struct ctl_table tipc_table[] = {
6798     @@ -45,14 +47,16 @@ static struct ctl_table tipc_table[] = {
6799     .data = &sysctl_tipc_rmem,
6800     .maxlen = sizeof(sysctl_tipc_rmem),
6801     .mode = 0644,
6802     - .proc_handler = proc_dointvec,
6803     + .proc_handler = proc_dointvec_minmax,
6804     + .extra1 = &one,
6805     },
6806     {
6807     .procname = "named_timeout",
6808     .data = &sysctl_tipc_named_timeout,
6809     .maxlen = sizeof(sysctl_tipc_named_timeout),
6810     .mode = 0644,
6811     - .proc_handler = proc_dointvec,
6812     + .proc_handler = proc_dointvec_minmax,
6813     + .extra1 = &zero,
6814     },
6815     {}
6816     };
6817     diff --git a/net/x25/af_x25.c b/net/x25/af_x25.c
6818     index 6c2560f3f95b..a8ca79810dcc 100644
6819     --- a/net/x25/af_x25.c
6820     +++ b/net/x25/af_x25.c
6821     @@ -764,6 +764,10 @@ static int x25_connect(struct socket *sock, struct sockaddr *uaddr,
6822     if (sk->sk_state == TCP_ESTABLISHED)
6823     goto out;
6824    
6825     + rc = -EALREADY; /* Do nothing if call is already in progress */
6826     + if (sk->sk_state == TCP_SYN_SENT)
6827     + goto out;
6828     +
6829     sk->sk_state = TCP_CLOSE;
6830     sock->state = SS_UNCONNECTED;
6831    
6832     @@ -810,7 +814,7 @@ static int x25_connect(struct socket *sock, struct sockaddr *uaddr,
6833     /* Now the loop */
6834     rc = -EINPROGRESS;
6835     if (sk->sk_state != TCP_ESTABLISHED && (flags & O_NONBLOCK))
6836     - goto out_put_neigh;
6837     + goto out;
6838    
6839     rc = x25_wait_for_connection_establishment(sk);
6840     if (rc)
6841     diff --git a/scripts/recordmcount.c b/scripts/recordmcount.c
6842     index 5423a58d1b06..9972141f11aa 100644
6843     --- a/scripts/recordmcount.c
6844     +++ b/scripts/recordmcount.c
6845     @@ -53,6 +53,10 @@
6846     #define R_AARCH64_ABS64 257
6847     #endif
6848    
6849     +#define R_ARM_PC24 1
6850     +#define R_ARM_THM_CALL 10
6851     +#define R_ARM_CALL 28
6852     +
6853     static int fd_map; /* File descriptor for file being modified. */
6854     static int mmap_failed; /* Boolean flag. */
6855     static char gpfx; /* prefix for global symbol name (sometimes '_') */
6856     @@ -374,6 +378,18 @@ is_mcounted_section_name(char const *const txtname)
6857     #define RECORD_MCOUNT_64
6858     #include "recordmcount.h"
6859    
6860     +static int arm_is_fake_mcount(Elf32_Rel const *rp)
6861     +{
6862     + switch (ELF32_R_TYPE(w(rp->r_info))) {
6863     + case R_ARM_THM_CALL:
6864     + case R_ARM_CALL:
6865     + case R_ARM_PC24:
6866     + return 0;
6867     + }
6868     +
6869     + return 1;
6870     +}
6871     +
6872     /* 64-bit EM_MIPS has weird ELF64_Rela.r_info.
6873     * http://techpubs.sgi.com/library/manuals/4000/007-4658-001/pdf/007-4658-001.pdf
6874     * We interpret Table 29 Relocation Operation (Elf64_Rel, Elf64_Rela) [p.40]
6875     @@ -463,6 +479,7 @@ do_file(char const *const fname)
6876     break;
6877     case EM_ARM: reltype = R_ARM_ABS32;
6878     altmcount = "__gnu_mcount_nc";
6879     + is_fake_mcount32 = arm_is_fake_mcount;
6880     break;
6881     case EM_AARCH64:
6882     reltype = R_AARCH64_ABS64;
6883     diff --git a/security/keys/key.c b/security/keys/key.c
6884     index 7276d1a009d4..280b4feccdc0 100644
6885     --- a/security/keys/key.c
6886     +++ b/security/keys/key.c
6887     @@ -296,6 +296,7 @@ struct key *key_alloc(struct key_type *type, const char *desc,
6888     key->gid = gid;
6889     key->perm = perm;
6890     key->restrict_link = restrict_link;
6891     + key->last_used_at = ktime_get_real_seconds();
6892    
6893     if (!(flags & KEY_ALLOC_NOT_IN_QUOTA))
6894     key->flags |= 1 << KEY_FLAG_IN_QUOTA;
6895     diff --git a/sound/aoa/codecs/onyx.c b/sound/aoa/codecs/onyx.c
6896     index a04edff8b729..ae50d59fb810 100644
6897     --- a/sound/aoa/codecs/onyx.c
6898     +++ b/sound/aoa/codecs/onyx.c
6899     @@ -74,8 +74,10 @@ static int onyx_read_register(struct onyx *onyx, u8 reg, u8 *value)
6900     return 0;
6901     }
6902     v = i2c_smbus_read_byte_data(onyx->i2c, reg);
6903     - if (v < 0)
6904     + if (v < 0) {
6905     + *value = 0;
6906     return -1;
6907     + }
6908     *value = (u8)v;
6909     onyx->cache[ONYX_REG_CONTROL-FIRSTREGISTER] = *value;
6910     return 0;
6911     diff --git a/sound/pci/hda/hda_controller.h b/sound/pci/hda/hda_controller.h
6912     index b83feecf1e40..8f9386998270 100644
6913     --- a/sound/pci/hda/hda_controller.h
6914     +++ b/sound/pci/hda/hda_controller.h
6915     @@ -171,11 +171,10 @@ struct azx {
6916     #define azx_bus(chip) (&(chip)->bus.core)
6917     #define bus_to_azx(_bus) container_of(_bus, struct azx, bus.core)
6918    
6919     -#ifdef CONFIG_X86
6920     -#define azx_snoop(chip) ((chip)->snoop)
6921     -#else
6922     -#define azx_snoop(chip) true
6923     -#endif
6924     +static inline bool azx_snoop(struct azx *chip)
6925     +{
6926     + return !IS_ENABLED(CONFIG_X86) || chip->snoop;
6927     +}
6928    
6929     /*
6930     * macros for easy use
6931     diff --git a/sound/soc/codecs/cs4349.c b/sound/soc/codecs/cs4349.c
6932     index 231ca935cdf3..c232c42ccead 100644
6933     --- a/sound/soc/codecs/cs4349.c
6934     +++ b/sound/soc/codecs/cs4349.c
6935     @@ -380,6 +380,7 @@ static struct i2c_driver cs4349_i2c_driver = {
6936     .driver = {
6937     .name = "cs4349",
6938     .of_match_table = cs4349_of_match,
6939     + .pm = &cs4349_runtime_pm,
6940     },
6941     .id_table = cs4349_i2c_id,
6942     .probe = cs4349_i2c_probe,
6943     diff --git a/sound/soc/codecs/es8328.c b/sound/soc/codecs/es8328.c
6944     index 37722194b107..6b22700842e2 100644
6945     --- a/sound/soc/codecs/es8328.c
6946     +++ b/sound/soc/codecs/es8328.c
6947     @@ -234,7 +234,7 @@ static const struct soc_enum es8328_rline_enum =
6948     ARRAY_SIZE(es8328_line_texts),
6949     es8328_line_texts);
6950     static const struct snd_kcontrol_new es8328_right_line_controls =
6951     - SOC_DAPM_ENUM("Route", es8328_lline_enum);
6952     + SOC_DAPM_ENUM("Route", es8328_rline_enum);
6953    
6954     /* Left Mixer */
6955     static const struct snd_kcontrol_new es8328_left_mixer_controls[] = {
6956     diff --git a/sound/soc/codecs/wm8737.c b/sound/soc/codecs/wm8737.c
6957     index f0cb1c4afe3c..c5a8d758f58b 100644
6958     --- a/sound/soc/codecs/wm8737.c
6959     +++ b/sound/soc/codecs/wm8737.c
6960     @@ -170,7 +170,7 @@ SOC_DOUBLE("Polarity Invert Switch", WM8737_ADC_CONTROL, 5, 6, 1, 0),
6961     SOC_SINGLE("3D Switch", WM8737_3D_ENHANCE, 0, 1, 0),
6962     SOC_SINGLE("3D Depth", WM8737_3D_ENHANCE, 1, 15, 0),
6963     SOC_ENUM("3D Low Cut-off", low_3d),
6964     -SOC_ENUM("3D High Cut-off", low_3d),
6965     +SOC_ENUM("3D High Cut-off", high_3d),
6966     SOC_SINGLE_TLV("3D ADC Volume", WM8737_3D_ENHANCE, 7, 1, 1, adc_tlv),
6967    
6968     SOC_SINGLE("Noise Gate Switch", WM8737_NOISE_GATE, 0, 1, 0),
6969     diff --git a/sound/soc/davinci/davinci-mcasp.c b/sound/soc/davinci/davinci-mcasp.c
6970     index 624c209c9498..d1935c5c3602 100644
6971     --- a/sound/soc/davinci/davinci-mcasp.c
6972     +++ b/sound/soc/davinci/davinci-mcasp.c
6973     @@ -882,14 +882,13 @@ static int mcasp_i2s_hw_param(struct davinci_mcasp *mcasp, int stream,
6974     active_slots = hweight32(mcasp->tdm_mask[stream]);
6975     active_serializers = (channels + active_slots - 1) /
6976     active_slots;
6977     - if (active_serializers == 1) {
6978     + if (active_serializers == 1)
6979     active_slots = channels;
6980     - for (i = 0; i < total_slots; i++) {
6981     - if ((1 << i) & mcasp->tdm_mask[stream]) {
6982     - mask |= (1 << i);
6983     - if (--active_slots <= 0)
6984     - break;
6985     - }
6986     + for (i = 0; i < total_slots; i++) {
6987     + if ((1 << i) & mcasp->tdm_mask[stream]) {
6988     + mask |= (1 << i);
6989     + if (--active_slots <= 0)
6990     + break;
6991     }
6992     }
6993     } else {
6994     diff --git a/sound/soc/fsl/imx-sgtl5000.c b/sound/soc/fsl/imx-sgtl5000.c
6995     index 8e525f7ac08d..3d99a8579c99 100644
6996     --- a/sound/soc/fsl/imx-sgtl5000.c
6997     +++ b/sound/soc/fsl/imx-sgtl5000.c
6998     @@ -119,7 +119,8 @@ static int imx_sgtl5000_probe(struct platform_device *pdev)
6999     codec_dev = of_find_i2c_device_by_node(codec_np);
7000     if (!codec_dev) {
7001     dev_err(&pdev->dev, "failed to find codec platform device\n");
7002     - return -EPROBE_DEFER;
7003     + ret = -EPROBE_DEFER;
7004     + goto fail;
7005     }
7006    
7007     data = devm_kzalloc(&pdev->dev, sizeof(*data), GFP_KERNEL);
7008     diff --git a/sound/soc/qcom/apq8016_sbc.c b/sound/soc/qcom/apq8016_sbc.c
7009     index 07f91e918b23..754742018515 100644
7010     --- a/sound/soc/qcom/apq8016_sbc.c
7011     +++ b/sound/soc/qcom/apq8016_sbc.c
7012     @@ -114,13 +114,15 @@ static struct apq8016_sbc_data *apq8016_sbc_parse_of(struct snd_soc_card *card)
7013    
7014     if (!cpu || !codec) {
7015     dev_err(dev, "Can't find cpu/codec DT node\n");
7016     - return ERR_PTR(-EINVAL);
7017     + ret = -EINVAL;
7018     + goto error;
7019     }
7020    
7021     link->cpu_of_node = of_parse_phandle(cpu, "sound-dai", 0);
7022     if (!link->cpu_of_node) {
7023     dev_err(card->dev, "error getting cpu phandle\n");
7024     - return ERR_PTR(-EINVAL);
7025     + ret = -EINVAL;
7026     + goto error;
7027     }
7028    
7029     link->codec_of_node = of_parse_phandle(codec, "sound-dai", 0);
7030     @@ -132,28 +134,37 @@ static struct apq8016_sbc_data *apq8016_sbc_parse_of(struct snd_soc_card *card)
7031     ret = snd_soc_of_get_dai_name(cpu, &link->cpu_dai_name);
7032     if (ret) {
7033     dev_err(card->dev, "error getting cpu dai name\n");
7034     - return ERR_PTR(ret);
7035     + goto error;
7036     }
7037    
7038     ret = snd_soc_of_get_dai_name(codec, &link->codec_dai_name);
7039     if (ret) {
7040     dev_err(card->dev, "error getting codec dai name\n");
7041     - return ERR_PTR(ret);
7042     + goto error;
7043     }
7044    
7045     link->platform_of_node = link->cpu_of_node;
7046     ret = of_property_read_string(np, "link-name", &link->name);
7047     if (ret) {
7048     dev_err(card->dev, "error getting codec dai_link name\n");
7049     - return ERR_PTR(ret);
7050     + goto error;
7051     }
7052    
7053     link->stream_name = link->name;
7054     link->init = apq8016_sbc_dai_init;
7055     link++;
7056     +
7057     + of_node_put(cpu);
7058     + of_node_put(codec);
7059     }
7060    
7061     return data;
7062     +
7063     + error:
7064     + of_node_put(np);
7065     + of_node_put(cpu);
7066     + of_node_put(codec);
7067     + return ERR_PTR(ret);
7068     }
7069    
7070     static const struct snd_soc_dapm_widget apq8016_sbc_dapm_widgets[] = {
7071     diff --git a/sound/soc/soc-pcm.c b/sound/soc/soc-pcm.c
7072     index d69559e45872..635b22fa1101 100644
7073     --- a/sound/soc/soc-pcm.c
7074     +++ b/sound/soc/soc-pcm.c
7075     @@ -48,8 +48,8 @@ static bool snd_soc_dai_stream_valid(struct snd_soc_dai *dai, int stream)
7076     else
7077     codec_stream = &dai->driver->capture;
7078    
7079     - /* If the codec specifies any rate at all, it supports the stream. */
7080     - return codec_stream->rates;
7081     + /* If the codec specifies any channels at all, it supports the stream */
7082     + return codec_stream->channels_min;
7083     }
7084    
7085     /**
7086     diff --git a/sound/soc/sunxi/sun4i-i2s.c b/sound/soc/sunxi/sun4i-i2s.c
7087     index 15c92400cea4..02c373c65e19 100644
7088     --- a/sound/soc/sunxi/sun4i-i2s.c
7089     +++ b/sound/soc/sunxi/sun4i-i2s.c
7090     @@ -78,8 +78,8 @@
7091     #define SUN4I_I2S_CLK_DIV_MCLK_MASK GENMASK(3, 0)
7092     #define SUN4I_I2S_CLK_DIV_MCLK(mclk) ((mclk) << 0)
7093    
7094     -#define SUN4I_I2S_RX_CNT_REG 0x28
7095     -#define SUN4I_I2S_TX_CNT_REG 0x2c
7096     +#define SUN4I_I2S_TX_CNT_REG 0x28
7097     +#define SUN4I_I2S_RX_CNT_REG 0x2c
7098    
7099     #define SUN4I_I2S_TX_CHAN_SEL_REG 0x30
7100     #define SUN4I_I2S_TX_CHAN_SEL(num_chan) (((num_chan) - 1) << 0)
7101     diff --git a/sound/usb/mixer.c b/sound/usb/mixer.c
7102     index 64fa1bbf0acb..54011f8543a7 100644
7103     --- a/sound/usb/mixer.c
7104     +++ b/sound/usb/mixer.c
7105     @@ -2626,7 +2626,9 @@ int snd_usb_create_mixer(struct snd_usb_audio *chip, int ctrlif,
7106     (err = snd_usb_mixer_status_create(mixer)) < 0)
7107     goto _error;
7108    
7109     - snd_usb_mixer_apply_create_quirk(mixer);
7110     + err = snd_usb_mixer_apply_create_quirk(mixer);
7111     + if (err < 0)
7112     + goto _error;
7113    
7114     err = snd_device_new(chip->card, SNDRV_DEV_CODEC, mixer, &dev_ops);
7115     if (err < 0)
7116     diff --git a/sound/usb/quirks-table.h b/sound/usb/quirks-table.h
7117     index d32727c74a16..c892b4d1e733 100644
7118     --- a/sound/usb/quirks-table.h
7119     +++ b/sound/usb/quirks-table.h
7120     @@ -3293,19 +3293,14 @@ AU0828_DEVICE(0x2040, 0x7270, "Hauppauge", "HVR-950Q"),
7121     .ifnum = 0,
7122     .type = QUIRK_AUDIO_STANDARD_MIXER,
7123     },
7124     - /* Capture */
7125     - {
7126     - .ifnum = 1,
7127     - .type = QUIRK_IGNORE_INTERFACE,
7128     - },
7129     /* Playback */
7130     {
7131     - .ifnum = 2,
7132     + .ifnum = 1,
7133     .type = QUIRK_AUDIO_FIXED_ENDPOINT,
7134     .data = &(const struct audioformat) {
7135     .formats = SNDRV_PCM_FMTBIT_S16_LE,
7136     .channels = 2,
7137     - .iface = 2,
7138     + .iface = 1,
7139     .altsetting = 1,
7140     .altset_idx = 1,
7141     .attributes = UAC_EP_CS_ATTR_FILL_MAX |