Gentoo Archives: gentoo-commits

From: Mike Pagano <mpagano@g.o>
To: gentoo-commits@l.g.o
Subject: [gentoo-commits] proj/linux-patches:4.9 commit in: /
Date: Wed, 01 Jul 2020 12:10:52
Message-Id: 1593605436.371bb07b0e2c28329a10c91f7dd7e85653d8454c.mpagano@gentoo
1 commit: 371bb07b0e2c28329a10c91f7dd7e85653d8454c
2 Author: Mike Pagano <mpagano <AT> gentoo <DOT> org>
3 AuthorDate: Wed Jul 1 12:10:36 2020 +0000
4 Commit: Mike Pagano <mpagano <AT> gentoo <DOT> org>
5 CommitDate: Wed Jul 1 12:10:36 2020 +0000
6 URL: https://gitweb.gentoo.org/proj/linux-patches.git/commit/?id=371bb07b
7
8 Linux patch 4.9.229
9
10 Signed-off-by: Mike Pagano <mpagano <AT> gentoo.org>
11
12 0000_README | 4 +
13 1228_linux-4.9.229.patch | 7171 ++++++++++++++++++++++++++++++++++++++++++++++
14 2 files changed, 7175 insertions(+)
15
16 diff --git a/0000_README b/0000_README
17 index f7c5f42..0a85d73 100644
18 --- a/0000_README
19 +++ b/0000_README
20 @@ -955,6 +955,10 @@ Patch: 1227_linux-4.9.228.patch
21 From: http://www.kernel.org
22 Desc: Linux 4.9.228
23
24 +Patch: 1228_linux-4.9.229.patch
25 +From: http://www.kernel.org
26 +Desc: Linux 4.9.229
27 +
28 Patch: 1500_XATTR_USER_PREFIX.patch
29 From: https://bugs.gentoo.org/show_bug.cgi?id=470644
30 Desc: Support for namespace user.pax.* on tmpfs.
31
32 diff --git a/1228_linux-4.9.229.patch b/1228_linux-4.9.229.patch
33 new file mode 100644
34 index 0000000..53a13fb
35 --- /dev/null
36 +++ b/1228_linux-4.9.229.patch
37 @@ -0,0 +1,7171 @@
38 +diff --git a/Documentation/media/uapi/dvb/fe-get-property.rst b/Documentation/media/uapi/dvb/fe-get-property.rst
39 +index 015d4db597b5..c80c5fc6e916 100644
40 +--- a/Documentation/media/uapi/dvb/fe-get-property.rst
41 ++++ b/Documentation/media/uapi/dvb/fe-get-property.rst
42 +@@ -48,8 +48,11 @@ depends on the delivery system and on the device:
43 +
44 + - This call requires read/write access to the device.
45 +
46 +- - At return, the values are updated to reflect the actual parameters
47 +- used.
48 ++.. note::
49 ++
50 ++ At return, the values aren't updated to reflect the actual
51 ++ parameters used. If the actual parameters are needed, an explicit
52 ++ call to ``FE_GET_PROPERTY`` is needed.
53 +
54 + - ``FE_GET_PROPERTY:``
55 +
56 +diff --git a/Makefile b/Makefile
57 +index af23d7b67442..a8a9704a6e2e 100644
58 +--- a/Makefile
59 ++++ b/Makefile
60 +@@ -1,6 +1,6 @@
61 + VERSION = 4
62 + PATCHLEVEL = 9
63 +-SUBLEVEL = 228
64 ++SUBLEVEL = 229
65 + EXTRAVERSION =
66 + NAME = Roaring Lionus
67 +
68 +diff --git a/arch/arm/mach-imx/pm-imx5.c b/arch/arm/mach-imx/pm-imx5.c
69 +index 868781fd460c..14c630c899c5 100644
70 +--- a/arch/arm/mach-imx/pm-imx5.c
71 ++++ b/arch/arm/mach-imx/pm-imx5.c
72 +@@ -301,14 +301,14 @@ static int __init imx_suspend_alloc_ocram(
73 + if (!ocram_pool) {
74 + pr_warn("%s: ocram pool unavailable!\n", __func__);
75 + ret = -ENODEV;
76 +- goto put_node;
77 ++ goto put_device;
78 + }
79 +
80 + ocram_base = gen_pool_alloc(ocram_pool, size);
81 + if (!ocram_base) {
82 + pr_warn("%s: unable to alloc ocram!\n", __func__);
83 + ret = -ENOMEM;
84 +- goto put_node;
85 ++ goto put_device;
86 + }
87 +
88 + phys = gen_pool_virt_to_phys(ocram_pool, ocram_base);
89 +@@ -318,6 +318,8 @@ static int __init imx_suspend_alloc_ocram(
90 + if (virt_out)
91 + *virt_out = virt;
92 +
93 ++put_device:
94 ++ put_device(&pdev->dev);
95 + put_node:
96 + of_node_put(node);
97 +
98 +diff --git a/arch/arm/mach-integrator/Kconfig b/arch/arm/mach-integrator/Kconfig
99 +index cefe44f6889b..ba124f8704fa 100644
100 +--- a/arch/arm/mach-integrator/Kconfig
101 ++++ b/arch/arm/mach-integrator/Kconfig
102 +@@ -3,6 +3,8 @@ menuconfig ARCH_INTEGRATOR
103 + depends on ARCH_MULTI_V4T || ARCH_MULTI_V5 || ARCH_MULTI_V6
104 + select ARM_AMBA
105 + select COMMON_CLK_VERSATILE
106 ++ select CMA
107 ++ select DMA_CMA
108 + select HAVE_TCM
109 + select ICST
110 + select MFD_SYSCON
111 +@@ -34,14 +36,13 @@ config INTEGRATOR_IMPD1
112 + select ARM_VIC
113 + select GPIO_PL061
114 + select GPIOLIB
115 ++ select REGULATOR
116 ++ select REGULATOR_FIXED_VOLTAGE
117 + help
118 + The IM-PD1 is an add-on logic module for the Integrator which
119 + allows ARM(R) Ltd PrimeCells to be developed and evaluated.
120 + The IM-PD1 can be found on the Integrator/PP2 platform.
121 +
122 +- To compile this driver as a module, choose M here: the
123 +- module will be called impd1.
124 +-
125 + config INTEGRATOR_CM7TDMI
126 + bool "Integrator/CM7TDMI core module"
127 + depends on ARCH_INTEGRATOR_AP
128 +diff --git a/arch/arm64/kernel/perf_regs.c b/arch/arm64/kernel/perf_regs.c
129 +index 3f62b35fb6f1..815c395a1076 100644
130 +--- a/arch/arm64/kernel/perf_regs.c
131 ++++ b/arch/arm64/kernel/perf_regs.c
132 +@@ -13,15 +13,34 @@ u64 perf_reg_value(struct pt_regs *regs, int idx)
133 + return 0;
134 +
135 + /*
136 +- * Compat (i.e. 32 bit) mode:
137 +- * - PC has been set in the pt_regs struct in kernel_entry,
138 +- * - Handle SP and LR here.
139 ++ * Our handling of compat tasks (PERF_SAMPLE_REGS_ABI_32) is weird, but
140 ++ * we're stuck with it for ABI compatability reasons.
141 ++ *
142 ++ * For a 32-bit consumer inspecting a 32-bit task, then it will look at
143 ++ * the first 16 registers (see arch/arm/include/uapi/asm/perf_regs.h).
144 ++ * These correspond directly to a prefix of the registers saved in our
145 ++ * 'struct pt_regs', with the exception of the PC, so we copy that down
146 ++ * (x15 corresponds to SP_hyp in the architecture).
147 ++ *
148 ++ * So far, so good.
149 ++ *
150 ++ * The oddity arises when a 64-bit consumer looks at a 32-bit task and
151 ++ * asks for registers beyond PERF_REG_ARM_MAX. In this case, we return
152 ++ * SP_usr, LR_usr and PC in the positions where the AArch64 SP, LR and
153 ++ * PC registers would normally live. The initial idea was to allow a
154 ++ * 64-bit unwinder to unwind a 32-bit task and, although it's not clear
155 ++ * how well that works in practice, somebody might be relying on it.
156 ++ *
157 ++ * At the time we make a sample, we don't know whether the consumer is
158 ++ * 32-bit or 64-bit, so we have to cater for both possibilities.
159 + */
160 + if (compat_user_mode(regs)) {
161 + if ((u32)idx == PERF_REG_ARM64_SP)
162 + return regs->compat_sp;
163 + if ((u32)idx == PERF_REG_ARM64_LR)
164 + return regs->compat_lr;
165 ++ if (idx == 15)
166 ++ return regs->pc;
167 + }
168 +
169 + if ((u32)idx == PERF_REG_ARM64_SP)
170 +diff --git a/arch/openrisc/kernel/entry.S b/arch/openrisc/kernel/entry.S
171 +index c17e8451d997..3fbe420f49c4 100644
172 +--- a/arch/openrisc/kernel/entry.S
173 ++++ b/arch/openrisc/kernel/entry.S
174 +@@ -1092,13 +1092,13 @@ ENTRY(__sys_clone)
175 + l.movhi r29,hi(sys_clone)
176 + l.ori r29,r29,lo(sys_clone)
177 + l.j _fork_save_extra_regs_and_call
178 +- l.addi r7,r1,0
179 ++ l.nop
180 +
181 + ENTRY(__sys_fork)
182 + l.movhi r29,hi(sys_fork)
183 + l.ori r29,r29,lo(sys_fork)
184 + l.j _fork_save_extra_regs_and_call
185 +- l.addi r3,r1,0
186 ++ l.nop
187 +
188 + ENTRY(sys_rt_sigreturn)
189 + l.j _sys_rt_sigreturn
190 +diff --git a/arch/powerpc/include/asm/book3s/64/pgtable.h b/arch/powerpc/include/asm/book3s/64/pgtable.h
191 +index 9fd77f8794a0..315758c84187 100644
192 +--- a/arch/powerpc/include/asm/book3s/64/pgtable.h
193 ++++ b/arch/powerpc/include/asm/book3s/64/pgtable.h
194 +@@ -754,10 +754,25 @@ extern struct page *pgd_page(pgd_t pgd);
195 + #define pud_page_vaddr(pud) __va(pud_val(pud) & ~PUD_MASKED_BITS)
196 + #define pgd_page_vaddr(pgd) __va(pgd_val(pgd) & ~PGD_MASKED_BITS)
197 +
198 +-#define pgd_index(address) (((address) >> (PGDIR_SHIFT)) & (PTRS_PER_PGD - 1))
199 +-#define pud_index(address) (((address) >> (PUD_SHIFT)) & (PTRS_PER_PUD - 1))
200 +-#define pmd_index(address) (((address) >> (PMD_SHIFT)) & (PTRS_PER_PMD - 1))
201 +-#define pte_index(address) (((address) >> (PAGE_SHIFT)) & (PTRS_PER_PTE - 1))
202 ++static inline unsigned long pgd_index(unsigned long address)
203 ++{
204 ++ return (address >> PGDIR_SHIFT) & (PTRS_PER_PGD - 1);
205 ++}
206 ++
207 ++static inline unsigned long pud_index(unsigned long address)
208 ++{
209 ++ return (address >> PUD_SHIFT) & (PTRS_PER_PUD - 1);
210 ++}
211 ++
212 ++static inline unsigned long pmd_index(unsigned long address)
213 ++{
214 ++ return (address >> PMD_SHIFT) & (PTRS_PER_PMD - 1);
215 ++}
216 ++
217 ++static inline unsigned long pte_index(unsigned long address)
218 ++{
219 ++ return (address >> PAGE_SHIFT) & (PTRS_PER_PTE - 1);
220 ++}
221 +
222 + /*
223 + * Find an entry in a page-table-directory. We combine the address region
224 +diff --git a/arch/powerpc/include/asm/kprobes.h b/arch/powerpc/include/asm/kprobes.h
225 +index 2c9759bdb63b..063d64c1c9e8 100644
226 +--- a/arch/powerpc/include/asm/kprobes.h
227 ++++ b/arch/powerpc/include/asm/kprobes.h
228 +@@ -29,6 +29,7 @@
229 + #include <linux/types.h>
230 + #include <linux/ptrace.h>
231 + #include <linux/percpu.h>
232 ++#include <linux/module.h>
233 + #include <asm/probes.h>
234 + #include <asm/code-patching.h>
235 +
236 +@@ -60,7 +61,7 @@ typedef ppc_opcode_t kprobe_opcode_t;
237 + #define kprobe_lookup_name(name, addr) \
238 + { \
239 + char dot_name[MODULE_NAME_LEN + 1 + KSYM_NAME_LEN]; \
240 +- char *modsym; \
241 ++ const char *modsym; \
242 + bool dot_appended = false; \
243 + if ((modsym = strchr(name, ':')) != NULL) { \
244 + modsym++; \
245 +diff --git a/arch/powerpc/kernel/machine_kexec.c b/arch/powerpc/kernel/machine_kexec.c
246 +index 9dafd7af39b8..cb4d6cd949fc 100644
247 +--- a/arch/powerpc/kernel/machine_kexec.c
248 ++++ b/arch/powerpc/kernel/machine_kexec.c
249 +@@ -113,11 +113,12 @@ void machine_kexec(struct kimage *image)
250 +
251 + void __init reserve_crashkernel(void)
252 + {
253 +- unsigned long long crash_size, crash_base;
254 ++ unsigned long long crash_size, crash_base, total_mem_sz;
255 + int ret;
256 +
257 ++ total_mem_sz = memory_limit ? memory_limit : memblock_phys_mem_size();
258 + /* use common parsing */
259 +- ret = parse_crashkernel(boot_command_line, memblock_phys_mem_size(),
260 ++ ret = parse_crashkernel(boot_command_line, total_mem_sz,
261 + &crash_size, &crash_base);
262 + if (ret == 0 && crash_size > 0) {
263 + crashk_res.start = crash_base;
264 +@@ -176,6 +177,7 @@ void __init reserve_crashkernel(void)
265 + /* Crash kernel trumps memory limit */
266 + if (memory_limit && memory_limit <= crashk_res.end) {
267 + memory_limit = crashk_res.end + 1;
268 ++ total_mem_sz = memory_limit;
269 + printk("Adjusted memory limit for crashkernel, now 0x%llx\n",
270 + memory_limit);
271 + }
272 +@@ -184,7 +186,7 @@ void __init reserve_crashkernel(void)
273 + "for crashkernel (System RAM: %ldMB)\n",
274 + (unsigned long)(crash_size >> 20),
275 + (unsigned long)(crashk_res.start >> 20),
276 +- (unsigned long)(memblock_phys_mem_size() >> 20));
277 ++ (unsigned long)(total_mem_sz >> 20));
278 +
279 + if (!memblock_is_region_memory(crashk_res.start, crash_size) ||
280 + memblock_reserve(crashk_res.start, crash_size)) {
281 +diff --git a/arch/powerpc/perf/hv-24x7.c b/arch/powerpc/perf/hv-24x7.c
282 +index 991c6a517ddc..2456522583c2 100644
283 +--- a/arch/powerpc/perf/hv-24x7.c
284 ++++ b/arch/powerpc/perf/hv-24x7.c
285 +@@ -1306,16 +1306,6 @@ static void h_24x7_event_read(struct perf_event *event)
286 + h24x7hw = &get_cpu_var(hv_24x7_hw);
287 + h24x7hw->events[i] = event;
288 + put_cpu_var(h24x7hw);
289 +- /*
290 +- * Clear the event count so we can compute the _change_
291 +- * in the 24x7 raw counter value at the end of the txn.
292 +- *
293 +- * Note that we could alternatively read the 24x7 value
294 +- * now and save its value in event->hw.prev_count. But
295 +- * that would require issuing a hcall, which would then
296 +- * defeat the purpose of using the txn interface.
297 +- */
298 +- local64_set(&event->count, 0);
299 + }
300 +
301 + put_cpu_var(hv_24x7_reqb);
302 +diff --git a/arch/powerpc/platforms/ps3/mm.c b/arch/powerpc/platforms/ps3/mm.c
303 +index b0f34663b1ae..19bae78b1f25 100644
304 +--- a/arch/powerpc/platforms/ps3/mm.c
305 ++++ b/arch/powerpc/platforms/ps3/mm.c
306 +@@ -212,13 +212,14 @@ void ps3_mm_vas_destroy(void)
307 + {
308 + int result;
309 +
310 +- DBG("%s:%d: map.vas_id = %llu\n", __func__, __LINE__, map.vas_id);
311 +-
312 + if (map.vas_id) {
313 + result = lv1_select_virtual_address_space(0);
314 +- BUG_ON(result);
315 +- result = lv1_destruct_virtual_address_space(map.vas_id);
316 +- BUG_ON(result);
317 ++ result += lv1_destruct_virtual_address_space(map.vas_id);
318 ++
319 ++ if (result) {
320 ++ lv1_panic(0);
321 ++ }
322 ++
323 + map.vas_id = 0;
324 + }
325 + }
326 +@@ -316,19 +317,20 @@ static void ps3_mm_region_destroy(struct mem_region *r)
327 + int result;
328 +
329 + if (!r->destroy) {
330 +- pr_info("%s:%d: Not destroying high region: %llxh %llxh\n",
331 +- __func__, __LINE__, r->base, r->size);
332 + return;
333 + }
334 +
335 +- DBG("%s:%d: r->base = %llxh\n", __func__, __LINE__, r->base);
336 +-
337 + if (r->base) {
338 + result = lv1_release_memory(r->base);
339 +- BUG_ON(result);
340 ++
341 ++ if (result) {
342 ++ lv1_panic(0);
343 ++ }
344 ++
345 + r->size = r->base = r->offset = 0;
346 + map.total = map.rm.size;
347 + }
348 ++
349 + ps3_mm_set_repository_highmem(NULL);
350 + }
351 +
352 +diff --git a/arch/powerpc/platforms/pseries/ras.c b/arch/powerpc/platforms/pseries/ras.c
353 +index 8799d8a83d56..0af19aa1df57 100644
354 +--- a/arch/powerpc/platforms/pseries/ras.c
355 ++++ b/arch/powerpc/platforms/pseries/ras.c
356 +@@ -311,10 +311,11 @@ static irqreturn_t ras_error_interrupt(int irq, void *dev_id)
357 + /*
358 + * Some versions of FWNMI place the buffer inside the 4kB page starting at
359 + * 0x7000. Other versions place it inside the rtas buffer. We check both.
360 ++ * Minimum size of the buffer is 16 bytes.
361 + */
362 + #define VALID_FWNMI_BUFFER(A) \
363 +- ((((A) >= 0x7000) && ((A) < 0x7ff0)) || \
364 +- (((A) >= rtas.base) && ((A) < (rtas.base + rtas.size - 16))))
365 ++ ((((A) >= 0x7000) && ((A) <= 0x8000 - 16)) || \
366 ++ (((A) >= rtas.base) && ((A) <= (rtas.base + rtas.size - 16))))
367 +
368 + /*
369 + * Get the error information for errors coming through the
370 +diff --git a/arch/s390/include/asm/syscall.h b/arch/s390/include/asm/syscall.h
371 +index 6bc941be6921..166fbd74e316 100644
372 +--- a/arch/s390/include/asm/syscall.h
373 ++++ b/arch/s390/include/asm/syscall.h
374 +@@ -41,7 +41,17 @@ static inline void syscall_rollback(struct task_struct *task,
375 + static inline long syscall_get_error(struct task_struct *task,
376 + struct pt_regs *regs)
377 + {
378 +- return IS_ERR_VALUE(regs->gprs[2]) ? regs->gprs[2] : 0;
379 ++ unsigned long error = regs->gprs[2];
380 ++#ifdef CONFIG_COMPAT
381 ++ if (test_tsk_thread_flag(task, TIF_31BIT)) {
382 ++ /*
383 ++ * Sign-extend the value so (int)-EFOO becomes (long)-EFOO
384 ++ * and will match correctly in comparisons.
385 ++ */
386 ++ error = (long)(int)error;
387 ++ }
388 ++#endif
389 ++ return IS_ERR_VALUE(error) ? error : 0;
390 + }
391 +
392 + static inline long syscall_get_return_value(struct task_struct *task,
393 +diff --git a/arch/s390/kernel/ptrace.c b/arch/s390/kernel/ptrace.c
394 +index fc2974b929c3..ee757d6f585e 100644
395 +--- a/arch/s390/kernel/ptrace.c
396 ++++ b/arch/s390/kernel/ptrace.c
397 +@@ -308,6 +308,25 @@ static inline void __poke_user_per(struct task_struct *child,
398 + child->thread.per_user.end = data;
399 + }
400 +
401 ++static void fixup_int_code(struct task_struct *child, addr_t data)
402 ++{
403 ++ struct pt_regs *regs = task_pt_regs(child);
404 ++ int ilc = regs->int_code >> 16;
405 ++ u16 insn;
406 ++
407 ++ if (ilc > 6)
408 ++ return;
409 ++
410 ++ if (ptrace_access_vm(child, regs->psw.addr - (regs->int_code >> 16),
411 ++ &insn, sizeof(insn), FOLL_FORCE) != sizeof(insn))
412 ++ return;
413 ++
414 ++ /* double check that tracee stopped on svc instruction */
415 ++ if ((insn >> 8) != 0xa)
416 ++ return;
417 ++
418 ++ regs->int_code = 0x20000 | (data & 0xffff);
419 ++}
420 + /*
421 + * Write a word to the user area of a process at location addr. This
422 + * operation does have an additional problem compared to peek_user.
423 +@@ -319,7 +338,9 @@ static int __poke_user(struct task_struct *child, addr_t addr, addr_t data)
424 + struct user *dummy = NULL;
425 + addr_t offset;
426 +
427 ++
428 + if (addr < (addr_t) &dummy->regs.acrs) {
429 ++ struct pt_regs *regs = task_pt_regs(child);
430 + /*
431 + * psw and gprs are stored on the stack
432 + */
433 +@@ -337,7 +358,11 @@ static int __poke_user(struct task_struct *child, addr_t addr, addr_t data)
434 + /* Invalid addressing mode bits */
435 + return -EINVAL;
436 + }
437 +- *(addr_t *)((addr_t) &task_pt_regs(child)->psw + addr) = data;
438 ++
439 ++ if (test_pt_regs_flag(regs, PIF_SYSCALL) &&
440 ++ addr == offsetof(struct user, regs.gprs[2]))
441 ++ fixup_int_code(child, data);
442 ++ *(addr_t *)((addr_t) &regs->psw + addr) = data;
443 +
444 + } else if (addr < (addr_t) (&dummy->regs.orig_gpr2)) {
445 + /*
446 +@@ -703,6 +728,10 @@ static int __poke_user_compat(struct task_struct *child,
447 + regs->psw.mask = (regs->psw.mask & ~PSW_MASK_BA) |
448 + (__u64)(tmp & PSW32_ADDR_AMODE);
449 + } else {
450 ++
451 ++ if (test_pt_regs_flag(regs, PIF_SYSCALL) &&
452 ++ addr == offsetof(struct compat_user, regs.gprs[2]))
453 ++ fixup_int_code(child, data);
454 + /* gpr 0-15 */
455 + *(__u32*)((addr_t) &regs->psw + addr*2 + 4) = tmp;
456 + }
457 +diff --git a/arch/sparc/kernel/ptrace_32.c b/arch/sparc/kernel/ptrace_32.c
458 +index 396dbdea0cfa..2f4316c14266 100644
459 +--- a/arch/sparc/kernel/ptrace_32.c
460 ++++ b/arch/sparc/kernel/ptrace_32.c
461 +@@ -167,12 +167,17 @@ static int genregs32_set(struct task_struct *target,
462 + if (ret || !count)
463 + return ret;
464 + ret = user_regset_copyin(&pos, &count, &kbuf, &ubuf,
465 +- &regs->y,
466 ++ &regs->npc,
467 + 34 * sizeof(u32), 35 * sizeof(u32));
468 + if (ret || !count)
469 + return ret;
470 ++ ret = user_regset_copyin(&pos, &count, &kbuf, &ubuf,
471 ++ &regs->y,
472 ++ 35 * sizeof(u32), 36 * sizeof(u32));
473 ++ if (ret || !count)
474 ++ return ret;
475 + return user_regset_copyin_ignore(&pos, &count, &kbuf, &ubuf,
476 +- 35 * sizeof(u32), 38 * sizeof(u32));
477 ++ 36 * sizeof(u32), 38 * sizeof(u32));
478 + }
479 +
480 + static int fpregs32_get(struct task_struct *target,
481 +diff --git a/arch/x86/boot/Makefile b/arch/x86/boot/Makefile
482 +index 3b16935b22bc..d1df7d2e31b1 100644
483 +--- a/arch/x86/boot/Makefile
484 ++++ b/arch/x86/boot/Makefile
485 +@@ -87,7 +87,7 @@ $(obj)/vmlinux.bin: $(obj)/compressed/vmlinux FORCE
486 +
487 + SETUP_OBJS = $(addprefix $(obj)/,$(setup-y))
488 +
489 +-sed-zoffset := -e 's/^\([0-9a-fA-F]*\) [ABCDGRSTVW] \(startup_32\|startup_64\|efi32_stub_entry\|efi64_stub_entry\|efi_pe_entry\|input_data\|_end\|_ehead\|_text\|z_.*\)$$/\#define ZO_\2 0x\1/p'
490 ++sed-zoffset := -e 's/^\([0-9a-fA-F]*\) [a-zA-Z] \(startup_32\|startup_64\|efi32_stub_entry\|efi64_stub_entry\|efi_pe_entry\|input_data\|_end\|_ehead\|_text\|z_.*\)$$/\#define ZO_\2 0x\1/p'
491 +
492 + quiet_cmd_zoffset = ZOFFSET $@
493 + cmd_zoffset = $(NM) $< | sed -n $(sed-zoffset) > $@
494 +diff --git a/arch/x86/kernel/kprobes/core.c b/arch/x86/kernel/kprobes/core.c
495 +index dcd6df5943d6..86aec286e4f2 100644
496 +--- a/arch/x86/kernel/kprobes/core.c
497 ++++ b/arch/x86/kernel/kprobes/core.c
498 +@@ -754,6 +754,13 @@ __visible __used void *trampoline_handler(struct pt_regs *regs)
499 + void *frame_pointer;
500 + bool skipped = false;
501 +
502 ++ /*
503 ++ * Set a dummy kprobe for avoiding kretprobe recursion.
504 ++ * Since kretprobe never run in kprobe handler, kprobe must not
505 ++ * be running at this point.
506 ++ */
507 ++ kprobe_busy_begin();
508 ++
509 + INIT_HLIST_HEAD(&empty_rp);
510 + kretprobe_hash_lock(current, &head, &flags);
511 + /* fixup registers */
512 +@@ -829,10 +836,9 @@ __visible __used void *trampoline_handler(struct pt_regs *regs)
513 + orig_ret_address = (unsigned long)ri->ret_addr;
514 + if (ri->rp && ri->rp->handler) {
515 + __this_cpu_write(current_kprobe, &ri->rp->kp);
516 +- get_kprobe_ctlblk()->kprobe_status = KPROBE_HIT_ACTIVE;
517 + ri->ret_addr = correct_ret_addr;
518 + ri->rp->handler(ri, regs);
519 +- __this_cpu_write(current_kprobe, NULL);
520 ++ __this_cpu_write(current_kprobe, &kprobe_busy);
521 + }
522 +
523 + recycle_rp_inst(ri, &empty_rp);
524 +@@ -848,6 +854,8 @@ __visible __used void *trampoline_handler(struct pt_regs *regs)
525 +
526 + kretprobe_hash_unlock(current, &flags);
527 +
528 ++ kprobe_busy_end();
529 ++
530 + hlist_for_each_entry_safe(ri, tmp, &empty_rp, hlist) {
531 + hlist_del(&ri->hlist);
532 + kfree(ri);
533 +diff --git a/arch/x86/kvm/x86.c b/arch/x86/kvm/x86.c
534 +index 0f66f7dd8938..6b7faa14c27b 100644
535 +--- a/arch/x86/kvm/x86.c
536 ++++ b/arch/x86/kvm/x86.c
537 +@@ -2304,7 +2304,7 @@ int kvm_set_msr_common(struct kvm_vcpu *vcpu, struct msr_data *msr_info)
538 + return kvm_mtrr_set_msr(vcpu, msr, data);
539 + case MSR_IA32_APICBASE:
540 + return kvm_set_apic_base(vcpu, msr_info);
541 +- case APIC_BASE_MSR ... APIC_BASE_MSR + 0x3ff:
542 ++ case APIC_BASE_MSR ... APIC_BASE_MSR + 0xff:
543 + return kvm_x2apic_msr_write(vcpu, msr, data);
544 + case MSR_IA32_TSCDEADLINE:
545 + kvm_set_lapic_tscdeadline_msr(vcpu, data);
546 +@@ -2576,7 +2576,7 @@ int kvm_get_msr_common(struct kvm_vcpu *vcpu, struct msr_data *msr_info)
547 + case MSR_IA32_APICBASE:
548 + msr_info->data = kvm_get_apic_base(vcpu);
549 + break;
550 +- case APIC_BASE_MSR ... APIC_BASE_MSR + 0x3ff:
551 ++ case APIC_BASE_MSR ... APIC_BASE_MSR + 0xff:
552 + return kvm_x2apic_msr_read(vcpu, msr_info->index, &msr_info->data);
553 + break;
554 + case MSR_IA32_TSCDEADLINE:
555 +diff --git a/crypto/algboss.c b/crypto/algboss.c
556 +index 6e39d9c05b98..5cbc588555ca 100644
557 +--- a/crypto/algboss.c
558 ++++ b/crypto/algboss.c
559 +@@ -194,8 +194,6 @@ static int cryptomgr_schedule_probe(struct crypto_larval *larval)
560 + if (IS_ERR(thread))
561 + goto err_put_larval;
562 +
563 +- wait_for_completion_interruptible(&larval->completion);
564 +-
565 + return NOTIFY_STOP;
566 +
567 + err_put_larval:
568 +diff --git a/drivers/acpi/sysfs.c b/drivers/acpi/sysfs.c
569 +index 7502441b1400..764786cfb0d9 100644
570 +--- a/drivers/acpi/sysfs.c
571 ++++ b/drivers/acpi/sysfs.c
572 +@@ -843,13 +843,13 @@ static void __exit interrupt_stats_exit(void)
573 + }
574 +
575 + static ssize_t
576 +-acpi_show_profile(struct device *dev, struct device_attribute *attr,
577 ++acpi_show_profile(struct kobject *kobj, struct kobj_attribute *attr,
578 + char *buf)
579 + {
580 + return sprintf(buf, "%d\n", acpi_gbl_FADT.preferred_profile);
581 + }
582 +
583 +-static const struct device_attribute pm_profile_attr =
584 ++static const struct kobj_attribute pm_profile_attr =
585 + __ATTR(pm_profile, S_IRUGO, acpi_show_profile, NULL);
586 +
587 + static ssize_t hotplug_enabled_show(struct kobject *kobj,
588 +diff --git a/drivers/ata/libata-core.c b/drivers/ata/libata-core.c
589 +index ba0cffbd0bb6..46bf7e9d00ab 100644
590 +--- a/drivers/ata/libata-core.c
591 ++++ b/drivers/ata/libata-core.c
592 +@@ -57,7 +57,6 @@
593 + #include <linux/workqueue.h>
594 + #include <linux/scatterlist.h>
595 + #include <linux/io.h>
596 +-#include <linux/async.h>
597 + #include <linux/log2.h>
598 + #include <linux/slab.h>
599 + #include <linux/glob.h>
600 +@@ -6410,7 +6409,7 @@ int ata_host_register(struct ata_host *host, struct scsi_host_template *sht)
601 + /* perform each probe asynchronously */
602 + for (i = 0; i < host->n_ports; i++) {
603 + struct ata_port *ap = host->ports[i];
604 +- async_schedule(async_port_probe, ap);
605 ++ ap->cookie = async_schedule(async_port_probe, ap);
606 + }
607 +
608 + return 0;
609 +@@ -6550,11 +6549,11 @@ void ata_host_detach(struct ata_host *host)
610 + {
611 + int i;
612 +
613 +- /* Ensure ata_port probe has completed */
614 +- async_synchronize_full();
615 +-
616 +- for (i = 0; i < host->n_ports; i++)
617 ++ for (i = 0; i < host->n_ports; i++) {
618 ++ /* Ensure ata_port probe has completed */
619 ++ async_synchronize_cookie(host->ports[i]->cookie + 1);
620 + ata_port_detach(host->ports[i]);
621 ++ }
622 +
623 + /* the host is dead now, dissociate ACPI */
624 + ata_acpi_dissociate(host);
625 +diff --git a/drivers/ata/libata-scsi.c b/drivers/ata/libata-scsi.c
626 +index c4f2b563c9f0..f4b38adb9d8a 100644
627 +--- a/drivers/ata/libata-scsi.c
628 ++++ b/drivers/ata/libata-scsi.c
629 +@@ -3967,12 +3967,13 @@ static unsigned int ata_scsi_mode_select_xlat(struct ata_queued_cmd *qc)
630 + {
631 + struct scsi_cmnd *scmd = qc->scsicmd;
632 + const u8 *cdb = scmd->cmnd;
633 +- const u8 *p;
634 + u8 pg, spg;
635 + unsigned six_byte, pg_len, hdr_len, bd_len;
636 + int len;
637 + u16 fp = (u16)-1;
638 + u8 bp = 0xff;
639 ++ u8 buffer[64];
640 ++ const u8 *p = buffer;
641 +
642 + VPRINTK("ENTER\n");
643 +
644 +@@ -4006,12 +4007,14 @@ static unsigned int ata_scsi_mode_select_xlat(struct ata_queued_cmd *qc)
645 + if (!scsi_sg_count(scmd) || scsi_sglist(scmd)->length < len)
646 + goto invalid_param_len;
647 +
648 +- p = page_address(sg_page(scsi_sglist(scmd)));
649 +-
650 + /* Move past header and block descriptors. */
651 + if (len < hdr_len)
652 + goto invalid_param_len;
653 +
654 ++ if (!sg_copy_to_buffer(scsi_sglist(scmd), scsi_sg_count(scmd),
655 ++ buffer, sizeof(buffer)))
656 ++ goto invalid_param_len;
657 ++
658 + if (six_byte)
659 + bd_len = p[3];
660 + else
661 +diff --git a/drivers/base/platform.c b/drivers/base/platform.c
662 +index bef299ef6227..ec2e4b6bc56f 100644
663 +--- a/drivers/base/platform.c
664 ++++ b/drivers/base/platform.c
665 +@@ -692,6 +692,8 @@ int __init_or_module __platform_driver_probe(struct platform_driver *drv,
666 + /* temporary section violation during probe() */
667 + drv->probe = probe;
668 + retval = code = __platform_driver_register(drv, module);
669 ++ if (retval)
670 ++ return retval;
671 +
672 + /*
673 + * Fixup that section violation, being paranoid about code scanning
674 +diff --git a/drivers/block/ps3disk.c b/drivers/block/ps3disk.c
675 +index 76f33c84ce3d..7ec5e8f0cbe5 100644
676 +--- a/drivers/block/ps3disk.c
677 ++++ b/drivers/block/ps3disk.c
678 +@@ -464,7 +464,6 @@ static int ps3disk_probe(struct ps3_system_bus_device *_dev)
679 + blk_queue_bounce_limit(queue, BLK_BOUNCE_HIGH);
680 +
681 + blk_queue_max_hw_sectors(queue, dev->bounce_size >> 9);
682 +- blk_queue_segment_boundary(queue, -1UL);
683 + blk_queue_dma_alignment(queue, dev->blk_size-1);
684 + blk_queue_logical_block_size(queue, dev->blk_size);
685 +
686 +diff --git a/drivers/clk/bcm/clk-bcm2835.c b/drivers/clk/bcm/clk-bcm2835.c
687 +index 73aab6e984cd..2b5075298cdc 100644
688 +--- a/drivers/clk/bcm/clk-bcm2835.c
689 ++++ b/drivers/clk/bcm/clk-bcm2835.c
690 +@@ -1295,13 +1295,13 @@ static struct clk_hw *bcm2835_register_clock(struct bcm2835_cprman *cprman,
691 + return &clock->hw;
692 + }
693 +
694 +-static struct clk *bcm2835_register_gate(struct bcm2835_cprman *cprman,
695 ++static struct clk_hw *bcm2835_register_gate(struct bcm2835_cprman *cprman,
696 + const struct bcm2835_gate_data *data)
697 + {
698 +- return clk_register_gate(cprman->dev, data->name, data->parent,
699 +- CLK_IGNORE_UNUSED | CLK_SET_RATE_GATE,
700 +- cprman->regs + data->ctl_reg,
701 +- CM_GATE_BIT, 0, &cprman->regs_lock);
702 ++ return clk_hw_register_gate(cprman->dev, data->name, data->parent,
703 ++ CLK_IGNORE_UNUSED | CLK_SET_RATE_GATE,
704 ++ cprman->regs + data->ctl_reg,
705 ++ CM_GATE_BIT, 0, &cprman->regs_lock);
706 + }
707 +
708 + typedef struct clk_hw *(*bcm2835_clk_register)(struct bcm2835_cprman *cprman,
709 +diff --git a/drivers/clk/qcom/gcc-msm8916.c b/drivers/clk/qcom/gcc-msm8916.c
710 +index 8dd71345b5d0..55430c8f1bc2 100644
711 +--- a/drivers/clk/qcom/gcc-msm8916.c
712 ++++ b/drivers/clk/qcom/gcc-msm8916.c
713 +@@ -270,7 +270,7 @@ static struct clk_pll gpll0 = {
714 + .l_reg = 0x21004,
715 + .m_reg = 0x21008,
716 + .n_reg = 0x2100c,
717 +- .config_reg = 0x21014,
718 ++ .config_reg = 0x21010,
719 + .mode_reg = 0x21000,
720 + .status_reg = 0x2101c,
721 + .status_bit = 17,
722 +@@ -297,7 +297,7 @@ static struct clk_pll gpll1 = {
723 + .l_reg = 0x20004,
724 + .m_reg = 0x20008,
725 + .n_reg = 0x2000c,
726 +- .config_reg = 0x20014,
727 ++ .config_reg = 0x20010,
728 + .mode_reg = 0x20000,
729 + .status_reg = 0x2001c,
730 + .status_bit = 17,
731 +@@ -324,7 +324,7 @@ static struct clk_pll gpll2 = {
732 + .l_reg = 0x4a004,
733 + .m_reg = 0x4a008,
734 + .n_reg = 0x4a00c,
735 +- .config_reg = 0x4a014,
736 ++ .config_reg = 0x4a010,
737 + .mode_reg = 0x4a000,
738 + .status_reg = 0x4a01c,
739 + .status_bit = 17,
740 +@@ -351,7 +351,7 @@ static struct clk_pll bimc_pll = {
741 + .l_reg = 0x23004,
742 + .m_reg = 0x23008,
743 + .n_reg = 0x2300c,
744 +- .config_reg = 0x23014,
745 ++ .config_reg = 0x23010,
746 + .mode_reg = 0x23000,
747 + .status_reg = 0x2301c,
748 + .status_bit = 17,
749 +diff --git a/drivers/clk/samsung/clk-exynos5433.c b/drivers/clk/samsung/clk-exynos5433.c
750 +index 09cdd35dc434..a082b026791a 100644
751 +--- a/drivers/clk/samsung/clk-exynos5433.c
752 ++++ b/drivers/clk/samsung/clk-exynos5433.c
753 +@@ -1672,7 +1672,8 @@ static const struct samsung_gate_clock peric_gate_clks[] __initconst = {
754 + GATE(CLK_SCLK_PCM1, "sclk_pcm1", "sclk_pcm1_peric",
755 + ENABLE_SCLK_PERIC, 7, CLK_SET_RATE_PARENT, 0),
756 + GATE(CLK_SCLK_I2S1, "sclk_i2s1", "sclk_i2s1_peric",
757 +- ENABLE_SCLK_PERIC, 6, CLK_SET_RATE_PARENT, 0),
758 ++ ENABLE_SCLK_PERIC, 6,
759 ++ CLK_SET_RATE_PARENT | CLK_IGNORE_UNUSED, 0),
760 + GATE(CLK_SCLK_SPI2, "sclk_spi2", "sclk_spi2_peric", ENABLE_SCLK_PERIC,
761 + 5, CLK_SET_RATE_PARENT, 0),
762 + GATE(CLK_SCLK_SPI1, "sclk_spi1", "sclk_spi1_peric", ENABLE_SCLK_PERIC,
763 +diff --git a/drivers/clk/st/clk-flexgen.c b/drivers/clk/st/clk-flexgen.c
764 +index a485f3b284b9..033e6062599d 100644
765 +--- a/drivers/clk/st/clk-flexgen.c
766 ++++ b/drivers/clk/st/clk-flexgen.c
767 +@@ -371,6 +371,7 @@ static void __init st_of_flexgen_setup(struct device_node *np)
768 + break;
769 + }
770 +
771 ++ flex_flags &= ~CLK_IS_CRITICAL;
772 + of_clk_detect_critical(np, i, &flex_flags);
773 +
774 + /*
775 +diff --git a/drivers/clk/sunxi/clk-sunxi.c b/drivers/clk/sunxi/clk-sunxi.c
776 +index f2c9274b8bd5..369164f0bd0e 100644
777 +--- a/drivers/clk/sunxi/clk-sunxi.c
778 ++++ b/drivers/clk/sunxi/clk-sunxi.c
779 +@@ -98,7 +98,7 @@ static void sun6i_a31_get_pll1_factors(struct factors_request *req)
780 + * Round down the frequency to the closest multiple of either
781 + * 6 or 16
782 + */
783 +- u32 round_freq_6 = round_down(freq_mhz, 6);
784 ++ u32 round_freq_6 = rounddown(freq_mhz, 6);
785 + u32 round_freq_16 = round_down(freq_mhz, 16);
786 +
787 + if (round_freq_6 > round_freq_16)
788 +diff --git a/drivers/clk/ti/composite.c b/drivers/clk/ti/composite.c
789 +index 1cf70f452e1e..3725b2e0c788 100644
790 +--- a/drivers/clk/ti/composite.c
791 ++++ b/drivers/clk/ti/composite.c
792 +@@ -226,6 +226,7 @@ cleanup:
793 + if (!cclk->comp_clks[i])
794 + continue;
795 + list_del(&cclk->comp_clks[i]->link);
796 ++ kfree(cclk->comp_clks[i]->parent_names);
797 + kfree(cclk->comp_clks[i]);
798 + }
799 +
800 +diff --git a/drivers/crypto/omap-sham.c b/drivers/crypto/omap-sham.c
801 +index ff6ac4e824b5..e7ca922a45e1 100644
802 +--- a/drivers/crypto/omap-sham.c
803 ++++ b/drivers/crypto/omap-sham.c
804 +@@ -167,8 +167,6 @@ struct omap_sham_hmac_ctx {
805 + };
806 +
807 + struct omap_sham_ctx {
808 +- struct omap_sham_dev *dd;
809 +-
810 + unsigned long flags;
811 +
812 + /* fallback stuff */
813 +@@ -915,27 +913,35 @@ static int omap_sham_update_dma_stop(struct omap_sham_dev *dd)
814 + return 0;
815 + }
816 +
817 ++struct omap_sham_dev *omap_sham_find_dev(struct omap_sham_reqctx *ctx)
818 ++{
819 ++ struct omap_sham_dev *dd;
820 ++
821 ++ if (ctx->dd)
822 ++ return ctx->dd;
823 ++
824 ++ spin_lock_bh(&sham.lock);
825 ++ dd = list_first_entry(&sham.dev_list, struct omap_sham_dev, list);
826 ++ list_move_tail(&dd->list, &sham.dev_list);
827 ++ ctx->dd = dd;
828 ++ spin_unlock_bh(&sham.lock);
829 ++
830 ++ return dd;
831 ++}
832 ++
833 + static int omap_sham_init(struct ahash_request *req)
834 + {
835 + struct crypto_ahash *tfm = crypto_ahash_reqtfm(req);
836 + struct omap_sham_ctx *tctx = crypto_ahash_ctx(tfm);
837 + struct omap_sham_reqctx *ctx = ahash_request_ctx(req);
838 +- struct omap_sham_dev *dd = NULL, *tmp;
839 ++ struct omap_sham_dev *dd;
840 + int bs = 0;
841 +
842 +- spin_lock_bh(&sham.lock);
843 +- if (!tctx->dd) {
844 +- list_for_each_entry(tmp, &sham.dev_list, list) {
845 +- dd = tmp;
846 +- break;
847 +- }
848 +- tctx->dd = dd;
849 +- } else {
850 +- dd = tctx->dd;
851 +- }
852 +- spin_unlock_bh(&sham.lock);
853 ++ ctx->dd = NULL;
854 +
855 +- ctx->dd = dd;
856 ++ dd = omap_sham_find_dev(ctx);
857 ++ if (!dd)
858 ++ return -ENODEV;
859 +
860 + ctx->flags = 0;
861 +
862 +@@ -1185,8 +1191,7 @@ err1:
863 + static int omap_sham_enqueue(struct ahash_request *req, unsigned int op)
864 + {
865 + struct omap_sham_reqctx *ctx = ahash_request_ctx(req);
866 +- struct omap_sham_ctx *tctx = crypto_tfm_ctx(req->base.tfm);
867 +- struct omap_sham_dev *dd = tctx->dd;
868 ++ struct omap_sham_dev *dd = ctx->dd;
869 +
870 + ctx->op = op;
871 +
872 +@@ -1196,7 +1201,7 @@ static int omap_sham_enqueue(struct ahash_request *req, unsigned int op)
873 + static int omap_sham_update(struct ahash_request *req)
874 + {
875 + struct omap_sham_reqctx *ctx = ahash_request_ctx(req);
876 +- struct omap_sham_dev *dd = ctx->dd;
877 ++ struct omap_sham_dev *dd = omap_sham_find_dev(ctx);
878 +
879 + if (!req->nbytes)
880 + return 0;
881 +@@ -1301,21 +1306,8 @@ static int omap_sham_setkey(struct crypto_ahash *tfm, const u8 *key,
882 + struct omap_sham_hmac_ctx *bctx = tctx->base;
883 + int bs = crypto_shash_blocksize(bctx->shash);
884 + int ds = crypto_shash_digestsize(bctx->shash);
885 +- struct omap_sham_dev *dd = NULL, *tmp;
886 + int err, i;
887 +
888 +- spin_lock_bh(&sham.lock);
889 +- if (!tctx->dd) {
890 +- list_for_each_entry(tmp, &sham.dev_list, list) {
891 +- dd = tmp;
892 +- break;
893 +- }
894 +- tctx->dd = dd;
895 +- } else {
896 +- dd = tctx->dd;
897 +- }
898 +- spin_unlock_bh(&sham.lock);
899 +-
900 + err = crypto_shash_setkey(tctx->fallback, key, keylen);
901 + if (err)
902 + return err;
903 +@@ -1333,7 +1325,7 @@ static int omap_sham_setkey(struct crypto_ahash *tfm, const u8 *key,
904 +
905 + memset(bctx->ipad + keylen, 0, bs - keylen);
906 +
907 +- if (!test_bit(FLAGS_AUTO_XOR, &dd->flags)) {
908 ++ if (!test_bit(FLAGS_AUTO_XOR, &sham.flags)) {
909 + memcpy(bctx->opad, bctx->ipad, bs);
910 +
911 + for (i = 0; i < bs; i++) {
912 +@@ -2072,6 +2064,7 @@ static int omap_sham_probe(struct platform_device *pdev)
913 + }
914 +
915 + dd->flags |= dd->pdata->flags;
916 ++ sham.flags |= dd->pdata->flags;
917 +
918 + pm_runtime_use_autosuspend(dev);
919 + pm_runtime_set_autosuspend_delay(dev, DEFAULT_AUTOSUSPEND_DELAY);
920 +@@ -2097,6 +2090,9 @@ static int omap_sham_probe(struct platform_device *pdev)
921 + spin_unlock(&sham.lock);
922 +
923 + for (i = 0; i < dd->pdata->algs_info_size; i++) {
924 ++ if (dd->pdata->algs_info[i].registered)
925 ++ break;
926 ++
927 + for (j = 0; j < dd->pdata->algs_info[i].size; j++) {
928 + struct ahash_alg *alg;
929 +
930 +@@ -2142,9 +2138,11 @@ static int omap_sham_remove(struct platform_device *pdev)
931 + list_del(&dd->list);
932 + spin_unlock(&sham.lock);
933 + for (i = dd->pdata->algs_info_size - 1; i >= 0; i--)
934 +- for (j = dd->pdata->algs_info[i].registered - 1; j >= 0; j--)
935 ++ for (j = dd->pdata->algs_info[i].registered - 1; j >= 0; j--) {
936 + crypto_unregister_ahash(
937 + &dd->pdata->algs_info[i].algs_list[j]);
938 ++ dd->pdata->algs_info[i].registered--;
939 ++ }
940 + tasklet_kill(&dd->done_task);
941 + pm_runtime_disable(&pdev->dev);
942 +
943 +diff --git a/drivers/extcon/extcon-adc-jack.c b/drivers/extcon/extcon-adc-jack.c
944 +index bc538708c753..cdee6d6d5453 100644
945 +--- a/drivers/extcon/extcon-adc-jack.c
946 ++++ b/drivers/extcon/extcon-adc-jack.c
947 +@@ -128,7 +128,7 @@ static int adc_jack_probe(struct platform_device *pdev)
948 + for (i = 0; data->adc_conditions[i].id != EXTCON_NONE; i++);
949 + data->num_conditions = i;
950 +
951 +- data->chan = iio_channel_get(&pdev->dev, pdata->consumer_channel);
952 ++ data->chan = devm_iio_channel_get(&pdev->dev, pdata->consumer_channel);
953 + if (IS_ERR(data->chan))
954 + return PTR_ERR(data->chan);
955 +
956 +@@ -170,7 +170,6 @@ static int adc_jack_remove(struct platform_device *pdev)
957 +
958 + free_irq(data->irq, data);
959 + cancel_work_sync(&data->handler.work);
960 +- iio_channel_release(data->chan);
961 +
962 + return 0;
963 + }
964 +diff --git a/drivers/firmware/efi/esrt.c b/drivers/firmware/efi/esrt.c
965 +index 241dd7c63d2c..481b2f0a190b 100644
966 +--- a/drivers/firmware/efi/esrt.c
967 ++++ b/drivers/firmware/efi/esrt.c
968 +@@ -180,7 +180,7 @@ static int esre_create_sysfs_entry(void *esre, int entry_num)
969 + rc = kobject_init_and_add(&entry->kobj, &esre1_ktype, NULL,
970 + "entry%d", entry_num);
971 + if (rc) {
972 +- kfree(entry);
973 ++ kobject_put(&entry->kobj);
974 + return rc;
975 + }
976 + }
977 +diff --git a/drivers/gpu/drm/drm_dp_mst_topology.c b/drivers/gpu/drm/drm_dp_mst_topology.c
978 +index 41e67e983a7f..bb70c5272fe8 100644
979 +--- a/drivers/gpu/drm/drm_dp_mst_topology.c
980 ++++ b/drivers/gpu/drm/drm_dp_mst_topology.c
981 +@@ -29,6 +29,7 @@
982 + #include <linux/i2c.h>
983 + #include <drm/drm_dp_mst_helper.h>
984 + #include <drm/drmP.h>
985 ++#include <linux/iopoll.h>
986 +
987 + #include <drm/drm_fixed.h>
988 +
989 +@@ -2673,6 +2674,17 @@ fail:
990 + return ret;
991 + }
992 +
993 ++static int do_get_act_status(struct drm_dp_aux *aux)
994 ++{
995 ++ int ret;
996 ++ u8 status;
997 ++
998 ++ ret = drm_dp_dpcd_readb(aux, DP_PAYLOAD_TABLE_UPDATE_STATUS, &status);
999 ++ if (ret < 0)
1000 ++ return ret;
1001 ++
1002 ++ return status;
1003 ++}
1004 +
1005 + /**
1006 + * drm_dp_check_act_status() - Check ACT handled status.
1007 +@@ -2682,33 +2694,29 @@ fail:
1008 + */
1009 + int drm_dp_check_act_status(struct drm_dp_mst_topology_mgr *mgr)
1010 + {
1011 +- u8 status;
1012 +- int ret;
1013 +- int count = 0;
1014 +-
1015 +- do {
1016 +- ret = drm_dp_dpcd_readb(mgr->aux, DP_PAYLOAD_TABLE_UPDATE_STATUS, &status);
1017 +-
1018 +- if (ret < 0) {
1019 +- DRM_DEBUG_KMS("failed to read payload table status %d\n", ret);
1020 +- goto fail;
1021 +- }
1022 +-
1023 +- if (status & DP_PAYLOAD_ACT_HANDLED)
1024 +- break;
1025 +- count++;
1026 +- udelay(100);
1027 +-
1028 +- } while (count < 30);
1029 +-
1030 +- if (!(status & DP_PAYLOAD_ACT_HANDLED)) {
1031 +- DRM_DEBUG_KMS("failed to get ACT bit %d after %d retries\n", status, count);
1032 +- ret = -EINVAL;
1033 +- goto fail;
1034 ++ /*
1035 ++ * There doesn't seem to be any recommended retry count or timeout in
1036 ++ * the MST specification. Since some hubs have been observed to take
1037 ++ * over 1 second to update their payload allocations under certain
1038 ++ * conditions, we use a rather large timeout value.
1039 ++ */
1040 ++ const int timeout_ms = 3000;
1041 ++ int ret, status;
1042 ++
1043 ++ ret = readx_poll_timeout(do_get_act_status, mgr->aux, status,
1044 ++ status & DP_PAYLOAD_ACT_HANDLED || status < 0,
1045 ++ 200, timeout_ms * USEC_PER_MSEC);
1046 ++ if (ret < 0 && status >= 0) {
1047 ++ DRM_DEBUG_KMS("Failed to get ACT after %dms, last status: %02x\n",
1048 ++ timeout_ms, status);
1049 ++ return -EINVAL;
1050 ++ } else if (status < 0) {
1051 ++ DRM_DEBUG_KMS("Failed to read payload table status: %d\n",
1052 ++ status);
1053 ++ return status;
1054 + }
1055 ++
1056 + return 0;
1057 +-fail:
1058 +- return ret;
1059 + }
1060 + EXPORT_SYMBOL(drm_dp_check_act_status);
1061 +
1062 +diff --git a/drivers/gpu/drm/drm_encoder_slave.c b/drivers/gpu/drm/drm_encoder_slave.c
1063 +index 4484785cd9ac..95d5a5949753 100644
1064 +--- a/drivers/gpu/drm/drm_encoder_slave.c
1065 ++++ b/drivers/gpu/drm/drm_encoder_slave.c
1066 +@@ -84,7 +84,7 @@ int drm_i2c_encoder_init(struct drm_device *dev,
1067 +
1068 + err = encoder_drv->encoder_init(client, dev, encoder);
1069 + if (err)
1070 +- goto fail_unregister;
1071 ++ goto fail_module_put;
1072 +
1073 + if (info->platform_data)
1074 + encoder->slave_funcs->set_config(&encoder->base,
1075 +@@ -92,9 +92,10 @@ int drm_i2c_encoder_init(struct drm_device *dev,
1076 +
1077 + return 0;
1078 +
1079 ++fail_module_put:
1080 ++ module_put(module);
1081 + fail_unregister:
1082 + i2c_unregister_device(client);
1083 +- module_put(module);
1084 + fail:
1085 + return err;
1086 + }
1087 +diff --git a/drivers/gpu/drm/i915/i915_cmd_parser.c b/drivers/gpu/drm/i915/i915_cmd_parser.c
1088 +index 1e104518192d..8a98442d494b 100644
1089 +--- a/drivers/gpu/drm/i915/i915_cmd_parser.c
1090 ++++ b/drivers/gpu/drm/i915/i915_cmd_parser.c
1091 +@@ -570,6 +570,9 @@ struct drm_i915_reg_descriptor {
1092 + #define REG32(_reg, ...) \
1093 + { .addr = (_reg), __VA_ARGS__ }
1094 +
1095 ++#define REG32_IDX(_reg, idx) \
1096 ++ { .addr = _reg(idx) }
1097 ++
1098 + /*
1099 + * Convenience macro for adding 64-bit registers.
1100 + *
1101 +@@ -667,6 +670,7 @@ static const struct drm_i915_reg_descriptor gen9_blt_regs[] = {
1102 + REG64_IDX(RING_TIMESTAMP, BSD_RING_BASE),
1103 + REG32(BCS_SWCTRL),
1104 + REG64_IDX(RING_TIMESTAMP, BLT_RING_BASE),
1105 ++ REG32_IDX(RING_CTX_TIMESTAMP, BLT_RING_BASE),
1106 + REG64_IDX(BCS_GPR, 0),
1107 + REG64_IDX(BCS_GPR, 1),
1108 + REG64_IDX(BCS_GPR, 2),
1109 +diff --git a/drivers/gpu/drm/msm/mdp/mdp5/mdp5_kms.c b/drivers/gpu/drm/msm/mdp/mdp5/mdp5_kms.c
1110 +index ed7143d35b25..6224aca7cd29 100644
1111 +--- a/drivers/gpu/drm/msm/mdp/mdp5/mdp5_kms.c
1112 ++++ b/drivers/gpu/drm/msm/mdp/mdp5/mdp5_kms.c
1113 +@@ -769,7 +769,8 @@ static int mdp5_init(struct platform_device *pdev, struct drm_device *dev)
1114 +
1115 + return 0;
1116 + fail:
1117 +- mdp5_destroy(pdev);
1118 ++ if (mdp5_kms)
1119 ++ mdp5_destroy(pdev);
1120 + return ret;
1121 + }
1122 +
1123 +diff --git a/drivers/gpu/drm/qxl/qxl_kms.c b/drivers/gpu/drm/qxl/qxl_kms.c
1124 +index e642242728c0..a886652ed895 100644
1125 +--- a/drivers/gpu/drm/qxl/qxl_kms.c
1126 ++++ b/drivers/gpu/drm/qxl/qxl_kms.c
1127 +@@ -199,7 +199,7 @@ static int qxl_device_init(struct qxl_device *qdev,
1128 + &(qdev->ram_header->cursor_ring_hdr),
1129 + sizeof(struct qxl_command),
1130 + QXL_CURSOR_RING_SIZE,
1131 +- qdev->io_base + QXL_IO_NOTIFY_CMD,
1132 ++ qdev->io_base + QXL_IO_NOTIFY_CURSOR,
1133 + false,
1134 + &qdev->cursor_event);
1135 +
1136 +diff --git a/drivers/gpu/drm/radeon/ni_dpm.c b/drivers/gpu/drm/radeon/ni_dpm.c
1137 +index 4a601f990562..a32cf6dbd3ee 100644
1138 +--- a/drivers/gpu/drm/radeon/ni_dpm.c
1139 ++++ b/drivers/gpu/drm/radeon/ni_dpm.c
1140 +@@ -2126,7 +2126,7 @@ static int ni_init_smc_spll_table(struct radeon_device *rdev)
1141 + if (clk_s & ~(SMC_NISLANDS_SPLL_DIV_TABLE_CLKS_MASK >> SMC_NISLANDS_SPLL_DIV_TABLE_CLKS_SHIFT))
1142 + ret = -EINVAL;
1143 +
1144 +- if (clk_s & ~(SMC_NISLANDS_SPLL_DIV_TABLE_CLKS_MASK >> SMC_NISLANDS_SPLL_DIV_TABLE_CLKS_SHIFT))
1145 ++ if (fb_div & ~(SMC_NISLANDS_SPLL_DIV_TABLE_FBDIV_MASK >> SMC_NISLANDS_SPLL_DIV_TABLE_FBDIV_SHIFT))
1146 + ret = -EINVAL;
1147 +
1148 + if (clk_v & ~(SMC_NISLANDS_SPLL_DIV_TABLE_CLKV_MASK >> SMC_NISLANDS_SPLL_DIV_TABLE_CLKV_SHIFT))
1149 +diff --git a/drivers/i2c/busses/i2c-piix4.c b/drivers/i2c/busses/i2c-piix4.c
1150 +index 62785aa76b3f..8324d2729088 100644
1151 +--- a/drivers/i2c/busses/i2c-piix4.c
1152 ++++ b/drivers/i2c/busses/i2c-piix4.c
1153 +@@ -840,7 +840,8 @@ static int piix4_probe(struct pci_dev *dev, const struct pci_device_id *id)
1154 + }
1155 +
1156 + if (dev->vendor == PCI_VENDOR_ID_AMD &&
1157 +- dev->device == PCI_DEVICE_ID_AMD_HUDSON2_SMBUS) {
1158 ++ (dev->device == PCI_DEVICE_ID_AMD_HUDSON2_SMBUS ||
1159 ++ dev->device == PCI_DEVICE_ID_AMD_KERNCZ_SMBUS)) {
1160 + retval = piix4_setup_sb800(dev, id, 1);
1161 + }
1162 +
1163 +diff --git a/drivers/i2c/busses/i2c-pxa.c b/drivers/i2c/busses/i2c-pxa.c
1164 +index e28b825b0433..fb191ad8fc3a 100644
1165 +--- a/drivers/i2c/busses/i2c-pxa.c
1166 ++++ b/drivers/i2c/busses/i2c-pxa.c
1167 +@@ -297,11 +297,10 @@ static void i2c_pxa_scream_blue_murder(struct pxa_i2c *i2c, const char *why)
1168 + dev_err(dev, "IBMR: %08x IDBR: %08x ICR: %08x ISR: %08x\n",
1169 + readl(_IBMR(i2c)), readl(_IDBR(i2c)), readl(_ICR(i2c)),
1170 + readl(_ISR(i2c)));
1171 +- dev_dbg(dev, "log: ");
1172 ++ dev_err(dev, "log:");
1173 + for (i = 0; i < i2c->irqlogidx; i++)
1174 +- pr_debug("[%08x:%08x] ", i2c->isrlog[i], i2c->icrlog[i]);
1175 +-
1176 +- pr_debug("\n");
1177 ++ pr_cont(" [%03x:%05x]", i2c->isrlog[i], i2c->icrlog[i]);
1178 ++ pr_cont("\n");
1179 + }
1180 +
1181 + #else /* ifdef DEBUG */
1182 +@@ -691,11 +690,9 @@ static inline void i2c_pxa_stop_message(struct pxa_i2c *i2c)
1183 + {
1184 + u32 icr;
1185 +
1186 +- /*
1187 +- * Clear the STOP and ACK flags
1188 +- */
1189 ++ /* Clear the START, STOP, ACK, TB and MA flags */
1190 + icr = readl(_ICR(i2c));
1191 +- icr &= ~(ICR_STOP | ICR_ACKNAK);
1192 ++ icr &= ~(ICR_START | ICR_STOP | ICR_ACKNAK | ICR_TB | ICR_MA);
1193 + writel(icr, _ICR(i2c));
1194 + }
1195 +
1196 +diff --git a/drivers/iio/pressure/bmp280-core.c b/drivers/iio/pressure/bmp280-core.c
1197 +index c9263acc190b..85b90b5939db 100644
1198 +--- a/drivers/iio/pressure/bmp280-core.c
1199 ++++ b/drivers/iio/pressure/bmp280-core.c
1200 +@@ -182,6 +182,8 @@ static u32 bmp280_compensate_humidity(struct bmp280_data *data,
1201 + + (s32)2097152) * H2 + 8192) >> 14);
1202 + var -= ((((var >> 15) * (var >> 15)) >> 7) * (s32)H1) >> 4;
1203 +
1204 ++ var = clamp_val(var, 0, 419430400);
1205 ++
1206 + return var >> 12;
1207 + };
1208 +
1209 +@@ -630,7 +632,7 @@ static int bmp180_measure(struct bmp280_data *data, u8 ctrl_meas)
1210 + unsigned int ctrl;
1211 +
1212 + if (data->use_eoc)
1213 +- init_completion(&data->done);
1214 ++ reinit_completion(&data->done);
1215 +
1216 + ret = regmap_write(data->regmap, BMP280_REG_CTRL_MEAS, ctrl_meas);
1217 + if (ret)
1218 +@@ -886,6 +888,9 @@ static int bmp085_fetch_eoc_irq(struct device *dev,
1219 + "trying to enforce it\n");
1220 + irq_trig = IRQF_TRIGGER_RISING;
1221 + }
1222 ++
1223 ++ init_completion(&data->done);
1224 ++
1225 + ret = devm_request_threaded_irq(dev,
1226 + irq,
1227 + bmp085_eoc_irq,
1228 +diff --git a/drivers/infiniband/core/cma_configfs.c b/drivers/infiniband/core/cma_configfs.c
1229 +index 41573df1d9fc..692fc42255c9 100644
1230 +--- a/drivers/infiniband/core/cma_configfs.c
1231 ++++ b/drivers/infiniband/core/cma_configfs.c
1232 +@@ -277,8 +277,21 @@ fail:
1233 + return ERR_PTR(err);
1234 + }
1235 +
1236 ++static void drop_cma_dev(struct config_group *cgroup, struct config_item *item)
1237 ++{
1238 ++ struct config_group *group =
1239 ++ container_of(item, struct config_group, cg_item);
1240 ++ struct cma_dev_group *cma_dev_group =
1241 ++ container_of(group, struct cma_dev_group, device_group);
1242 ++
1243 ++ configfs_remove_default_groups(&cma_dev_group->ports_group);
1244 ++ configfs_remove_default_groups(&cma_dev_group->device_group);
1245 ++ config_item_put(item);
1246 ++}
1247 ++
1248 + static struct configfs_group_operations cma_subsys_group_ops = {
1249 + .make_group = make_cma_dev,
1250 ++ .drop_item = drop_cma_dev,
1251 + };
1252 +
1253 + static struct config_item_type cma_subsys_type = {
1254 +diff --git a/drivers/infiniband/core/mad.c b/drivers/infiniband/core/mad.c
1255 +index a1f059a9c751..f03e10517acc 100644
1256 +--- a/drivers/infiniband/core/mad.c
1257 ++++ b/drivers/infiniband/core/mad.c
1258 +@@ -2885,6 +2885,7 @@ static int ib_mad_post_receive_mads(struct ib_mad_qp_info *qp_info,
1259 + DMA_FROM_DEVICE);
1260 + if (unlikely(ib_dma_mapping_error(qp_info->port_priv->device,
1261 + sg_list.addr))) {
1262 ++ kfree(mad_priv);
1263 + ret = -ENOMEM;
1264 + break;
1265 + }
1266 +diff --git a/drivers/md/bcache/btree.c b/drivers/md/bcache/btree.c
1267 +index c8c5e3368b8b..12849829077d 100644
1268 +--- a/drivers/md/bcache/btree.c
1269 ++++ b/drivers/md/bcache/btree.c
1270 +@@ -1370,7 +1370,7 @@ static int btree_gc_coalesce(struct btree *b, struct btree_op *op,
1271 + if (__set_blocks(n1, n1->keys + n2->keys,
1272 + block_bytes(b->c)) >
1273 + btree_blocks(new_nodes[i]))
1274 +- goto out_nocoalesce;
1275 ++ goto out_unlock_nocoalesce;
1276 +
1277 + keys = n2->keys;
1278 + /* Take the key of the node we're getting rid of */
1279 +@@ -1399,7 +1399,7 @@ static int btree_gc_coalesce(struct btree *b, struct btree_op *op,
1280 +
1281 + if (__bch_keylist_realloc(&keylist,
1282 + bkey_u64s(&new_nodes[i]->key)))
1283 +- goto out_nocoalesce;
1284 ++ goto out_unlock_nocoalesce;
1285 +
1286 + bch_btree_node_write(new_nodes[i], &cl);
1287 + bch_keylist_add(&keylist, &new_nodes[i]->key);
1288 +@@ -1445,6 +1445,10 @@ static int btree_gc_coalesce(struct btree *b, struct btree_op *op,
1289 + /* Invalidated our iterator */
1290 + return -EINTR;
1291 +
1292 ++out_unlock_nocoalesce:
1293 ++ for (i = 0; i < nodes; i++)
1294 ++ mutex_unlock(&new_nodes[i]->write_lock);
1295 ++
1296 + out_nocoalesce:
1297 + closure_sync(&cl);
1298 + bch_keylist_free(&keylist);
1299 +diff --git a/drivers/media/dvb-core/dvb_frontend.c b/drivers/media/dvb-core/dvb_frontend.c
1300 +index 372057cabea4..cd45b3894661 100644
1301 +--- a/drivers/media/dvb-core/dvb_frontend.c
1302 ++++ b/drivers/media/dvb-core/dvb_frontend.c
1303 +@@ -41,6 +41,7 @@
1304 + #include <linux/jiffies.h>
1305 + #include <linux/kthread.h>
1306 + #include <linux/ktime.h>
1307 ++#include <linux/compat.h>
1308 + #include <asm/processor.h>
1309 +
1310 + #include "dvb_frontend.h"
1311 +@@ -458,7 +459,7 @@ static int dvb_frontend_swzigzag_autotune(struct dvb_frontend *fe, int check_wra
1312 +
1313 + static void dvb_frontend_swzigzag(struct dvb_frontend *fe)
1314 + {
1315 +- enum fe_status s = 0;
1316 ++ enum fe_status s = FE_NONE;
1317 + int retval = 0;
1318 + struct dvb_frontend_private *fepriv = fe->frontend_priv;
1319 + struct dtv_frontend_properties *c = &fe->dtv_property_cache, tmp;
1320 +@@ -932,8 +933,6 @@ static int dvb_frontend_clear_cache(struct dvb_frontend *fe)
1321 + memset(c, 0, offsetof(struct dtv_frontend_properties, strength));
1322 + c->delivery_system = delsys;
1323 +
1324 +- c->state = DTV_CLEAR;
1325 +-
1326 + dev_dbg(fe->dvb->device, "%s: Clearing cache for delivery system %d\n",
1327 + __func__, c->delivery_system);
1328 +
1329 +@@ -998,6 +997,17 @@ static int dvb_frontend_clear_cache(struct dvb_frontend *fe)
1330 + .buffer = b \
1331 + }
1332 +
1333 ++struct dtv_cmds_h {
1334 ++ char *name; /* A display name for debugging purposes */
1335 ++
1336 ++ __u32 cmd; /* A unique ID */
1337 ++
1338 ++ /* Flags */
1339 ++ __u32 set:1; /* Either a set or get property */
1340 ++ __u32 buffer:1; /* Does this property use the buffer? */
1341 ++ __u32 reserved:30; /* Align */
1342 ++};
1343 ++
1344 + static struct dtv_cmds_h dtv_cmds[DTV_MAX_COMMAND + 1] = {
1345 + _DTV_CMD(DTV_TUNE, 1, 0),
1346 + _DTV_CMD(DTV_CLEAR, 1, 0),
1347 +@@ -1079,22 +1089,19 @@ static struct dtv_cmds_h dtv_cmds[DTV_MAX_COMMAND + 1] = {
1348 + _DTV_CMD(DTV_STAT_TOTAL_BLOCK_COUNT, 0, 0),
1349 + };
1350 +
1351 +-static void dtv_property_dump(struct dvb_frontend *fe,
1352 +- bool is_set,
1353 ++static void dtv_get_property_dump(struct dvb_frontend *fe,
1354 + struct dtv_property *tvp)
1355 + {
1356 + int i;
1357 +
1358 + if (tvp->cmd <= 0 || tvp->cmd > DTV_MAX_COMMAND) {
1359 +- dev_warn(fe->dvb->device, "%s: %s tvp.cmd = 0x%08x undefined\n",
1360 +- __func__,
1361 +- is_set ? "SET" : "GET",
1362 ++ dev_warn(fe->dvb->device, "%s: GET tvp.cmd = 0x%08x undefined\n"
1363 ++ , __func__,
1364 + tvp->cmd);
1365 + return;
1366 + }
1367 +
1368 +- dev_dbg(fe->dvb->device, "%s: %s tvp.cmd = 0x%08x (%s)\n", __func__,
1369 +- is_set ? "SET" : "GET",
1370 ++ dev_dbg(fe->dvb->device, "%s: GET tvp.cmd = 0x%08x (%s)\n", __func__,
1371 + tvp->cmd,
1372 + dtv_cmds[tvp->cmd].name);
1373 +
1374 +@@ -1285,17 +1292,15 @@ static int dtv_get_frontend(struct dvb_frontend *fe,
1375 + return 0;
1376 + }
1377 +
1378 +-static int dvb_frontend_ioctl_legacy(struct file *file,
1379 +- unsigned int cmd, void *parg);
1380 +-static int dvb_frontend_ioctl_properties(struct file *file,
1381 +- unsigned int cmd, void *parg);
1382 ++static int dvb_frontend_handle_ioctl(struct file *file,
1383 ++ unsigned int cmd, void *parg);
1384 +
1385 + static int dtv_property_process_get(struct dvb_frontend *fe,
1386 + const struct dtv_frontend_properties *c,
1387 + struct dtv_property *tvp,
1388 + struct file *file)
1389 + {
1390 +- int r, ncaps;
1391 ++ int ncaps;
1392 +
1393 + switch(tvp->cmd) {
1394 + case DTV_ENUM_DELSYS:
1395 +@@ -1506,14 +1511,7 @@ static int dtv_property_process_get(struct dvb_frontend *fe,
1396 + return -EINVAL;
1397 + }
1398 +
1399 +- /* Allow the frontend to override outgoing properties */
1400 +- if (fe->ops.get_property) {
1401 +- r = fe->ops.get_property(fe, tvp);
1402 +- if (r < 0)
1403 +- return r;
1404 +- }
1405 +-
1406 +- dtv_property_dump(fe, false, tvp);
1407 ++ dtv_get_property_dump(fe, tvp);
1408 +
1409 + return 0;
1410 + }
1411 +@@ -1740,23 +1738,36 @@ static int dvbv3_set_delivery_system(struct dvb_frontend *fe)
1412 + return emulate_delivery_system(fe, delsys);
1413 + }
1414 +
1415 ++/**
1416 ++ * dtv_property_process_set - Sets a single DTV property
1417 ++ * @fe: Pointer to &struct dvb_frontend
1418 ++ * @file: Pointer to &struct file
1419 ++ * @cmd: Digital TV command
1420 ++ * @data: An unsigned 32-bits number
1421 ++ *
1422 ++ * This routine assigns the property
1423 ++ * value to the corresponding member of
1424 ++ * &struct dtv_frontend_properties
1425 ++ *
1426 ++ * Returns:
1427 ++ * Zero on success, negative errno on failure.
1428 ++ */
1429 + static int dtv_property_process_set(struct dvb_frontend *fe,
1430 +- struct dtv_property *tvp,
1431 +- struct file *file)
1432 ++ struct file *file,
1433 ++ u32 cmd, u32 data)
1434 + {
1435 + int r = 0;
1436 + struct dtv_frontend_properties *c = &fe->dtv_property_cache;
1437 +
1438 +- /* Allow the frontend to validate incoming properties */
1439 +- if (fe->ops.set_property) {
1440 +- r = fe->ops.set_property(fe, tvp);
1441 +- if (r < 0)
1442 +- return r;
1443 +- }
1444 +-
1445 +- dtv_property_dump(fe, true, tvp);
1446 +-
1447 +- switch(tvp->cmd) {
1448 ++ /** Dump DTV command name and value*/
1449 ++ if (!cmd || cmd > DTV_MAX_COMMAND)
1450 ++ dev_warn(fe->dvb->device, "%s: SET cmd 0x%08x undefined\n",
1451 ++ __func__, cmd);
1452 ++ else
1453 ++ dev_dbg(fe->dvb->device,
1454 ++ "%s: SET cmd 0x%08x (%s) to 0x%08x\n",
1455 ++ __func__, cmd, dtv_cmds[cmd].name, data);
1456 ++ switch (cmd) {
1457 + case DTV_CLEAR:
1458 + /*
1459 + * Reset a cache of data specific to the frontend here. This does
1460 +@@ -1765,144 +1776,144 @@ static int dtv_property_process_set(struct dvb_frontend *fe,
1461 + dvb_frontend_clear_cache(fe);
1462 + break;
1463 + case DTV_TUNE:
1464 +- /* interpret the cache of data, build either a traditional frontend
1465 +- * tunerequest so we can pass validation in the FE_SET_FRONTEND
1466 +- * ioctl.
1467 ++ /*
1468 ++ * Use the cached Digital TV properties to tune the
1469 ++ * frontend
1470 + */
1471 +- c->state = tvp->cmd;
1472 +- dev_dbg(fe->dvb->device, "%s: Finalised property cache\n",
1473 +- __func__);
1474 ++ dev_dbg(fe->dvb->device,
1475 ++ "%s: Setting the frontend from property cache\n",
1476 ++ __func__);
1477 +
1478 + r = dtv_set_frontend(fe);
1479 + break;
1480 + case DTV_FREQUENCY:
1481 +- c->frequency = tvp->u.data;
1482 ++ c->frequency = data;
1483 + break;
1484 + case DTV_MODULATION:
1485 +- c->modulation = tvp->u.data;
1486 ++ c->modulation = data;
1487 + break;
1488 + case DTV_BANDWIDTH_HZ:
1489 +- c->bandwidth_hz = tvp->u.data;
1490 ++ c->bandwidth_hz = data;
1491 + break;
1492 + case DTV_INVERSION:
1493 +- c->inversion = tvp->u.data;
1494 ++ c->inversion = data;
1495 + break;
1496 + case DTV_SYMBOL_RATE:
1497 +- c->symbol_rate = tvp->u.data;
1498 ++ c->symbol_rate = data;
1499 + break;
1500 + case DTV_INNER_FEC:
1501 +- c->fec_inner = tvp->u.data;
1502 ++ c->fec_inner = data;
1503 + break;
1504 + case DTV_PILOT:
1505 +- c->pilot = tvp->u.data;
1506 ++ c->pilot = data;
1507 + break;
1508 + case DTV_ROLLOFF:
1509 +- c->rolloff = tvp->u.data;
1510 ++ c->rolloff = data;
1511 + break;
1512 + case DTV_DELIVERY_SYSTEM:
1513 +- r = dvbv5_set_delivery_system(fe, tvp->u.data);
1514 ++ r = dvbv5_set_delivery_system(fe, data);
1515 + break;
1516 + case DTV_VOLTAGE:
1517 +- c->voltage = tvp->u.data;
1518 +- r = dvb_frontend_ioctl_legacy(file, FE_SET_VOLTAGE,
1519 ++ c->voltage = data;
1520 ++ r = dvb_frontend_handle_ioctl(file, FE_SET_VOLTAGE,
1521 + (void *)c->voltage);
1522 + break;
1523 + case DTV_TONE:
1524 +- c->sectone = tvp->u.data;
1525 +- r = dvb_frontend_ioctl_legacy(file, FE_SET_TONE,
1526 ++ c->sectone = data;
1527 ++ r = dvb_frontend_handle_ioctl(file, FE_SET_TONE,
1528 + (void *)c->sectone);
1529 + break;
1530 + case DTV_CODE_RATE_HP:
1531 +- c->code_rate_HP = tvp->u.data;
1532 ++ c->code_rate_HP = data;
1533 + break;
1534 + case DTV_CODE_RATE_LP:
1535 +- c->code_rate_LP = tvp->u.data;
1536 ++ c->code_rate_LP = data;
1537 + break;
1538 + case DTV_GUARD_INTERVAL:
1539 +- c->guard_interval = tvp->u.data;
1540 ++ c->guard_interval = data;
1541 + break;
1542 + case DTV_TRANSMISSION_MODE:
1543 +- c->transmission_mode = tvp->u.data;
1544 ++ c->transmission_mode = data;
1545 + break;
1546 + case DTV_HIERARCHY:
1547 +- c->hierarchy = tvp->u.data;
1548 ++ c->hierarchy = data;
1549 + break;
1550 + case DTV_INTERLEAVING:
1551 +- c->interleaving = tvp->u.data;
1552 ++ c->interleaving = data;
1553 + break;
1554 +
1555 + /* ISDB-T Support here */
1556 + case DTV_ISDBT_PARTIAL_RECEPTION:
1557 +- c->isdbt_partial_reception = tvp->u.data;
1558 ++ c->isdbt_partial_reception = data;
1559 + break;
1560 + case DTV_ISDBT_SOUND_BROADCASTING:
1561 +- c->isdbt_sb_mode = tvp->u.data;
1562 ++ c->isdbt_sb_mode = data;
1563 + break;
1564 + case DTV_ISDBT_SB_SUBCHANNEL_ID:
1565 +- c->isdbt_sb_subchannel = tvp->u.data;
1566 ++ c->isdbt_sb_subchannel = data;
1567 + break;
1568 + case DTV_ISDBT_SB_SEGMENT_IDX:
1569 +- c->isdbt_sb_segment_idx = tvp->u.data;
1570 ++ c->isdbt_sb_segment_idx = data;
1571 + break;
1572 + case DTV_ISDBT_SB_SEGMENT_COUNT:
1573 +- c->isdbt_sb_segment_count = tvp->u.data;
1574 ++ c->isdbt_sb_segment_count = data;
1575 + break;
1576 + case DTV_ISDBT_LAYER_ENABLED:
1577 +- c->isdbt_layer_enabled = tvp->u.data;
1578 ++ c->isdbt_layer_enabled = data;
1579 + break;
1580 + case DTV_ISDBT_LAYERA_FEC:
1581 +- c->layer[0].fec = tvp->u.data;
1582 ++ c->layer[0].fec = data;
1583 + break;
1584 + case DTV_ISDBT_LAYERA_MODULATION:
1585 +- c->layer[0].modulation = tvp->u.data;
1586 ++ c->layer[0].modulation = data;
1587 + break;
1588 + case DTV_ISDBT_LAYERA_SEGMENT_COUNT:
1589 +- c->layer[0].segment_count = tvp->u.data;
1590 ++ c->layer[0].segment_count = data;
1591 + break;
1592 + case DTV_ISDBT_LAYERA_TIME_INTERLEAVING:
1593 +- c->layer[0].interleaving = tvp->u.data;
1594 ++ c->layer[0].interleaving = data;
1595 + break;
1596 + case DTV_ISDBT_LAYERB_FEC:
1597 +- c->layer[1].fec = tvp->u.data;
1598 ++ c->layer[1].fec = data;
1599 + break;
1600 + case DTV_ISDBT_LAYERB_MODULATION:
1601 +- c->layer[1].modulation = tvp->u.data;
1602 ++ c->layer[1].modulation = data;
1603 + break;
1604 + case DTV_ISDBT_LAYERB_SEGMENT_COUNT:
1605 +- c->layer[1].segment_count = tvp->u.data;
1606 ++ c->layer[1].segment_count = data;
1607 + break;
1608 + case DTV_ISDBT_LAYERB_TIME_INTERLEAVING:
1609 +- c->layer[1].interleaving = tvp->u.data;
1610 ++ c->layer[1].interleaving = data;
1611 + break;
1612 + case DTV_ISDBT_LAYERC_FEC:
1613 +- c->layer[2].fec = tvp->u.data;
1614 ++ c->layer[2].fec = data;
1615 + break;
1616 + case DTV_ISDBT_LAYERC_MODULATION:
1617 +- c->layer[2].modulation = tvp->u.data;
1618 ++ c->layer[2].modulation = data;
1619 + break;
1620 + case DTV_ISDBT_LAYERC_SEGMENT_COUNT:
1621 +- c->layer[2].segment_count = tvp->u.data;
1622 ++ c->layer[2].segment_count = data;
1623 + break;
1624 + case DTV_ISDBT_LAYERC_TIME_INTERLEAVING:
1625 +- c->layer[2].interleaving = tvp->u.data;
1626 ++ c->layer[2].interleaving = data;
1627 + break;
1628 +
1629 + /* Multistream support */
1630 + case DTV_STREAM_ID:
1631 + case DTV_DVBT2_PLP_ID_LEGACY:
1632 +- c->stream_id = tvp->u.data;
1633 ++ c->stream_id = data;
1634 + break;
1635 +
1636 + /* ATSC-MH */
1637 + case DTV_ATSCMH_PARADE_ID:
1638 +- fe->dtv_property_cache.atscmh_parade_id = tvp->u.data;
1639 ++ fe->dtv_property_cache.atscmh_parade_id = data;
1640 + break;
1641 + case DTV_ATSCMH_RS_FRAME_ENSEMBLE:
1642 +- fe->dtv_property_cache.atscmh_rs_frame_ensemble = tvp->u.data;
1643 ++ fe->dtv_property_cache.atscmh_rs_frame_ensemble = data;
1644 + break;
1645 +
1646 + case DTV_LNA:
1647 +- c->lna = tvp->u.data;
1648 ++ c->lna = data;
1649 + if (fe->ops.set_lna)
1650 + r = fe->ops.set_lna(fe);
1651 + if (r < 0)
1652 +@@ -1916,14 +1927,13 @@ static int dtv_property_process_set(struct dvb_frontend *fe,
1653 + return r;
1654 + }
1655 +
1656 +-static int dvb_frontend_ioctl(struct file *file,
1657 +- unsigned int cmd, void *parg)
1658 ++static int dvb_frontend_do_ioctl(struct file *file, unsigned int cmd,
1659 ++ void *parg)
1660 + {
1661 + struct dvb_device *dvbdev = file->private_data;
1662 + struct dvb_frontend *fe = dvbdev->priv;
1663 +- struct dtv_frontend_properties *c = &fe->dtv_property_cache;
1664 + struct dvb_frontend_private *fepriv = fe->frontend_priv;
1665 +- int err = -EOPNOTSUPP;
1666 ++ int err;
1667 +
1668 + dev_dbg(fe->dvb->device, "%s: (%d)\n", __func__, _IOC_NR(cmd));
1669 + if (down_interruptible(&fepriv->sem))
1670 +@@ -1934,74 +1944,125 @@ static int dvb_frontend_ioctl(struct file *file,
1671 + return -ENODEV;
1672 + }
1673 +
1674 +- if ((file->f_flags & O_ACCMODE) == O_RDONLY &&
1675 +- (_IOC_DIR(cmd) != _IOC_READ || cmd == FE_GET_EVENT ||
1676 +- cmd == FE_DISEQC_RECV_SLAVE_REPLY)) {
1677 ++ /*
1678 ++ * If the frontend is opened in read-only mode, only the ioctls
1679 ++ * that don't interfere with the tune logic should be accepted.
1680 ++ * That allows an external application to monitor the DVB QoS and
1681 ++ * statistics parameters.
1682 ++ *
1683 ++ * That matches all _IOR() ioctls, except for two special cases:
1684 ++ * - FE_GET_EVENT is part of the tuning logic on a DVB application;
1685 ++ * - FE_DISEQC_RECV_SLAVE_REPLY is part of DiSEqC 2.0
1686 ++ * setup
1687 ++ * So, those two ioctls should also return -EPERM, as otherwise
1688 ++ * reading from them would interfere with a DVB tune application
1689 ++ */
1690 ++ if ((file->f_flags & O_ACCMODE) == O_RDONLY
1691 ++ && (_IOC_DIR(cmd) != _IOC_READ
1692 ++ || cmd == FE_GET_EVENT
1693 ++ || cmd == FE_DISEQC_RECV_SLAVE_REPLY)) {
1694 + up(&fepriv->sem);
1695 + return -EPERM;
1696 + }
1697 +
1698 +- if ((cmd == FE_SET_PROPERTY) || (cmd == FE_GET_PROPERTY))
1699 +- err = dvb_frontend_ioctl_properties(file, cmd, parg);
1700 +- else {
1701 +- c->state = DTV_UNDEFINED;
1702 +- err = dvb_frontend_ioctl_legacy(file, cmd, parg);
1703 +- }
1704 ++ err = dvb_frontend_handle_ioctl(file, cmd, parg);
1705 +
1706 + up(&fepriv->sem);
1707 + return err;
1708 + }
1709 +
1710 +-static int dvb_frontend_ioctl_properties(struct file *file,
1711 +- unsigned int cmd, void *parg)
1712 ++static long dvb_frontend_ioctl(struct file *file, unsigned int cmd,
1713 ++ unsigned long arg)
1714 ++{
1715 ++ struct dvb_device *dvbdev = file->private_data;
1716 ++
1717 ++ if (!dvbdev)
1718 ++ return -ENODEV;
1719 ++
1720 ++ return dvb_usercopy(file, cmd, arg, dvb_frontend_do_ioctl);
1721 ++}
1722 ++
1723 ++#ifdef CONFIG_COMPAT
1724 ++struct compat_dtv_property {
1725 ++ __u32 cmd;
1726 ++ __u32 reserved[3];
1727 ++ union {
1728 ++ __u32 data;
1729 ++ struct dtv_fe_stats st;
1730 ++ struct {
1731 ++ __u8 data[32];
1732 ++ __u32 len;
1733 ++ __u32 reserved1[3];
1734 ++ compat_uptr_t reserved2;
1735 ++ } buffer;
1736 ++ } u;
1737 ++ int result;
1738 ++} __attribute__ ((packed));
1739 ++
1740 ++struct compat_dtv_properties {
1741 ++ __u32 num;
1742 ++ compat_uptr_t props;
1743 ++};
1744 ++
1745 ++#define COMPAT_FE_SET_PROPERTY _IOW('o', 82, struct compat_dtv_properties)
1746 ++#define COMPAT_FE_GET_PROPERTY _IOR('o', 83, struct compat_dtv_properties)
1747 ++
1748 ++static int dvb_frontend_handle_compat_ioctl(struct file *file, unsigned int cmd,
1749 ++ unsigned long arg)
1750 + {
1751 + struct dvb_device *dvbdev = file->private_data;
1752 + struct dvb_frontend *fe = dvbdev->priv;
1753 + struct dvb_frontend_private *fepriv = fe->frontend_priv;
1754 +- struct dtv_frontend_properties *c = &fe->dtv_property_cache;
1755 +- int err = 0;
1756 ++ int i, err = 0;
1757 +
1758 +- struct dtv_properties *tvps = parg;
1759 +- struct dtv_property *tvp = NULL;
1760 +- int i;
1761 ++ if (cmd == COMPAT_FE_SET_PROPERTY) {
1762 ++ struct compat_dtv_properties prop, *tvps = NULL;
1763 ++ struct compat_dtv_property *tvp = NULL;
1764 +
1765 +- dev_dbg(fe->dvb->device, "%s:\n", __func__);
1766 ++ if (copy_from_user(&prop, compat_ptr(arg), sizeof(prop)))
1767 ++ return -EFAULT;
1768 +
1769 +- if (cmd == FE_SET_PROPERTY) {
1770 +- dev_dbg(fe->dvb->device, "%s: properties.num = %d\n", __func__, tvps->num);
1771 +- dev_dbg(fe->dvb->device, "%s: properties.props = %p\n", __func__, tvps->props);
1772 ++ tvps = &prop;
1773 +
1774 +- /* Put an arbitrary limit on the number of messages that can
1775 +- * be sent at once */
1776 +- if ((tvps->num == 0) || (tvps->num > DTV_IOCTL_MAX_MSGS))
1777 ++ /*
1778 ++ * Put an arbitrary limit on the number of messages that can
1779 ++ * be sent at once
1780 ++ */
1781 ++ if (!tvps->num || (tvps->num > DTV_IOCTL_MAX_MSGS))
1782 + return -EINVAL;
1783 +
1784 +- tvp = memdup_user(tvps->props, tvps->num * sizeof(*tvp));
1785 ++ tvp = memdup_user(compat_ptr(tvps->props), tvps->num * sizeof(*tvp));
1786 + if (IS_ERR(tvp))
1787 + return PTR_ERR(tvp);
1788 +
1789 + for (i = 0; i < tvps->num; i++) {
1790 +- err = dtv_property_process_set(fe, tvp + i, file);
1791 +- if (err < 0)
1792 +- goto out;
1793 +- (tvp + i)->result = err;
1794 ++ err = dtv_property_process_set(fe, file,
1795 ++ (tvp + i)->cmd,
1796 ++ (tvp + i)->u.data);
1797 ++ if (err < 0) {
1798 ++ kfree(tvp);
1799 ++ return err;
1800 ++ }
1801 + }
1802 +-
1803 +- if (c->state == DTV_TUNE)
1804 +- dev_dbg(fe->dvb->device, "%s: Property cache is full, tuning\n", __func__);
1805 +-
1806 +- } else if (cmd == FE_GET_PROPERTY) {
1807 ++ kfree(tvp);
1808 ++ } else if (cmd == COMPAT_FE_GET_PROPERTY) {
1809 ++ struct compat_dtv_properties prop, *tvps = NULL;
1810 ++ struct compat_dtv_property *tvp = NULL;
1811 + struct dtv_frontend_properties getp = fe->dtv_property_cache;
1812 +
1813 +- dev_dbg(fe->dvb->device, "%s: properties.num = %d\n", __func__, tvps->num);
1814 +- dev_dbg(fe->dvb->device, "%s: properties.props = %p\n", __func__, tvps->props);
1815 ++ if (copy_from_user(&prop, compat_ptr(arg), sizeof(prop)))
1816 ++ return -EFAULT;
1817 +
1818 +- /* Put an arbitrary limit on the number of messages that can
1819 +- * be sent at once */
1820 +- if ((tvps->num == 0) || (tvps->num > DTV_IOCTL_MAX_MSGS))
1821 ++ tvps = &prop;
1822 ++
1823 ++ /*
1824 ++ * Put an arbitrary limit on the number of messages that can
1825 ++ * be sent at once
1826 ++ */
1827 ++ if (!tvps->num || (tvps->num > DTV_IOCTL_MAX_MSGS))
1828 + return -EINVAL;
1829 +
1830 +- tvp = memdup_user(tvps->props, tvps->num * sizeof(*tvp));
1831 ++ tvp = memdup_user(compat_ptr(tvps->props), tvps->num * sizeof(*tvp));
1832 + if (IS_ERR(tvp))
1833 + return PTR_ERR(tvp);
1834 +
1835 +@@ -2013,30 +2074,53 @@ static int dvb_frontend_ioctl_properties(struct file *file,
1836 + */
1837 + if (fepriv->state != FESTATE_IDLE) {
1838 + err = dtv_get_frontend(fe, &getp, NULL);
1839 +- if (err < 0)
1840 +- goto out;
1841 ++ if (err < 0) {
1842 ++ kfree(tvp);
1843 ++ return err;
1844 ++ }
1845 + }
1846 + for (i = 0; i < tvps->num; i++) {
1847 +- err = dtv_property_process_get(fe, &getp, tvp + i, file);
1848 +- if (err < 0)
1849 +- goto out;
1850 +- (tvp + i)->result = err;
1851 ++ err = dtv_property_process_get(
1852 ++ fe, &getp, (struct dtv_property *)(tvp + i), file);
1853 ++ if (err < 0) {
1854 ++ kfree(tvp);
1855 ++ return err;
1856 ++ }
1857 + }
1858 +
1859 +- if (copy_to_user((void __user *)tvps->props, tvp,
1860 +- tvps->num * sizeof(struct dtv_property))) {
1861 +- err = -EFAULT;
1862 +- goto out;
1863 ++ if (copy_to_user((void __user *)compat_ptr(tvps->props), tvp,
1864 ++ tvps->num * sizeof(struct compat_dtv_property))) {
1865 ++ kfree(tvp);
1866 ++ return -EFAULT;
1867 + }
1868 ++ kfree(tvp);
1869 ++ }
1870 +
1871 +- } else
1872 +- err = -EOPNOTSUPP;
1873 +-
1874 +-out:
1875 +- kfree(tvp);
1876 + return err;
1877 + }
1878 +
1879 ++static long dvb_frontend_compat_ioctl(struct file *file, unsigned int cmd,
1880 ++ unsigned long arg)
1881 ++{
1882 ++ struct dvb_device *dvbdev = file->private_data;
1883 ++ struct dvb_frontend *fe = dvbdev->priv;
1884 ++ struct dvb_frontend_private *fepriv = fe->frontend_priv;
1885 ++ int err;
1886 ++
1887 ++ if (cmd == COMPAT_FE_SET_PROPERTY || cmd == COMPAT_FE_GET_PROPERTY) {
1888 ++ if (down_interruptible(&fepriv->sem))
1889 ++ return -ERESTARTSYS;
1890 ++
1891 ++ err = dvb_frontend_handle_compat_ioctl(file, cmd, arg);
1892 ++
1893 ++ up(&fepriv->sem);
1894 ++ return err;
1895 ++ }
1896 ++
1897 ++ return dvb_frontend_ioctl(file, cmd, (unsigned long)compat_ptr(arg));
1898 ++}
1899 ++#endif
1900 ++
1901 + static int dtv_set_frontend(struct dvb_frontend *fe)
1902 + {
1903 + struct dvb_frontend_private *fepriv = fe->frontend_priv;
1904 +@@ -2174,16 +2258,103 @@ static int dtv_set_frontend(struct dvb_frontend *fe)
1905 + }
1906 +
1907 +
1908 +-static int dvb_frontend_ioctl_legacy(struct file *file,
1909 +- unsigned int cmd, void *parg)
1910 ++static int dvb_frontend_handle_ioctl(struct file *file,
1911 ++ unsigned int cmd, void *parg)
1912 + {
1913 + struct dvb_device *dvbdev = file->private_data;
1914 + struct dvb_frontend *fe = dvbdev->priv;
1915 + struct dvb_frontend_private *fepriv = fe->frontend_priv;
1916 + struct dtv_frontend_properties *c = &fe->dtv_property_cache;
1917 +- int err = -EOPNOTSUPP;
1918 ++ int i, err = -ENOTSUPP;
1919 ++
1920 ++ dev_dbg(fe->dvb->device, "%s:\n", __func__);
1921 ++
1922 ++ switch(cmd) {
1923 ++ case FE_SET_PROPERTY: {
1924 ++ struct dtv_properties *tvps = parg;
1925 ++ struct dtv_property *tvp = NULL;
1926 ++
1927 ++ dev_dbg(fe->dvb->device, "%s: properties.num = %d\n",
1928 ++ __func__, tvps->num);
1929 ++ dev_dbg(fe->dvb->device, "%s: properties.props = %p\n",
1930 ++ __func__, tvps->props);
1931 ++
1932 ++ /*
1933 ++ * Put an arbitrary limit on the number of messages that can
1934 ++ * be sent at once
1935 ++ */
1936 ++ if (!tvps->num || (tvps->num > DTV_IOCTL_MAX_MSGS))
1937 ++ return -EINVAL;
1938 ++
1939 ++ tvp = memdup_user(tvps->props, tvps->num * sizeof(*tvp));
1940 ++ if (IS_ERR(tvp))
1941 ++ return PTR_ERR(tvp);
1942 ++
1943 ++ for (i = 0; i < tvps->num; i++) {
1944 ++ err = dtv_property_process_set(fe, file,
1945 ++ (tvp + i)->cmd,
1946 ++ (tvp + i)->u.data);
1947 ++ if (err < 0) {
1948 ++ kfree(tvp);
1949 ++ return err;
1950 ++ }
1951 ++ }
1952 ++ kfree(tvp);
1953 ++ err = 0;
1954 ++ break;
1955 ++ }
1956 ++ case FE_GET_PROPERTY: {
1957 ++ struct dtv_properties *tvps = parg;
1958 ++ struct dtv_property *tvp = NULL;
1959 ++ struct dtv_frontend_properties getp = fe->dtv_property_cache;
1960 ++
1961 ++ dev_dbg(fe->dvb->device, "%s: properties.num = %d\n",
1962 ++ __func__, tvps->num);
1963 ++ dev_dbg(fe->dvb->device, "%s: properties.props = %p\n",
1964 ++ __func__, tvps->props);
1965 ++
1966 ++ /*
1967 ++ * Put an arbitrary limit on the number of messages that can
1968 ++ * be sent at once
1969 ++ */
1970 ++ if (!tvps->num || (tvps->num > DTV_IOCTL_MAX_MSGS))
1971 ++ return -EINVAL;
1972 ++
1973 ++ tvp = memdup_user(tvps->props, tvps->num * sizeof(*tvp));
1974 ++ if (IS_ERR(tvp))
1975 ++ return PTR_ERR(tvp);
1976 ++
1977 ++ /*
1978 ++ * Let's use our own copy of property cache, in order to
1979 ++ * avoid mangling with DTV zigzag logic, as drivers might
1980 ++ * return crap, if they don't check if the data is available
1981 ++ * before updating the properties cache.
1982 ++ */
1983 ++ if (fepriv->state != FESTATE_IDLE) {
1984 ++ err = dtv_get_frontend(fe, &getp, NULL);
1985 ++ if (err < 0) {
1986 ++ kfree(tvp);
1987 ++ return err;
1988 ++ }
1989 ++ }
1990 ++ for (i = 0; i < tvps->num; i++) {
1991 ++ err = dtv_property_process_get(fe, &getp, tvp + i, file);
1992 ++ if (err < 0) {
1993 ++ kfree(tvp);
1994 ++ return err;
1995 ++ }
1996 ++ }
1997 ++
1998 ++ if (copy_to_user((void __user *)tvps->props, tvp,
1999 ++ tvps->num * sizeof(struct dtv_property))) {
2000 ++ kfree(tvp);
2001 ++ return -EFAULT;
2002 ++ }
2003 ++ kfree(tvp);
2004 ++ err = 0;
2005 ++ break;
2006 ++ }
2007 +
2008 +- switch (cmd) {
2009 + case FE_GET_INFO: {
2010 + struct dvb_frontend_info* info = parg;
2011 +
2012 +@@ -2247,42 +2418,6 @@ static int dvb_frontend_ioctl_legacy(struct file *file,
2013 + break;
2014 + }
2015 +
2016 +- case FE_READ_BER:
2017 +- if (fe->ops.read_ber) {
2018 +- if (fepriv->thread)
2019 +- err = fe->ops.read_ber(fe, (__u32 *) parg);
2020 +- else
2021 +- err = -EAGAIN;
2022 +- }
2023 +- break;
2024 +-
2025 +- case FE_READ_SIGNAL_STRENGTH:
2026 +- if (fe->ops.read_signal_strength) {
2027 +- if (fepriv->thread)
2028 +- err = fe->ops.read_signal_strength(fe, (__u16 *) parg);
2029 +- else
2030 +- err = -EAGAIN;
2031 +- }
2032 +- break;
2033 +-
2034 +- case FE_READ_SNR:
2035 +- if (fe->ops.read_snr) {
2036 +- if (fepriv->thread)
2037 +- err = fe->ops.read_snr(fe, (__u16 *) parg);
2038 +- else
2039 +- err = -EAGAIN;
2040 +- }
2041 +- break;
2042 +-
2043 +- case FE_READ_UNCORRECTED_BLOCKS:
2044 +- if (fe->ops.read_ucblocks) {
2045 +- if (fepriv->thread)
2046 +- err = fe->ops.read_ucblocks(fe, (__u32 *) parg);
2047 +- else
2048 +- err = -EAGAIN;
2049 +- }
2050 +- break;
2051 +-
2052 + case FE_DISEQC_RESET_OVERLOAD:
2053 + if (fe->ops.diseqc_reset_overload) {
2054 + err = fe->ops.diseqc_reset_overload(fe);
2055 +@@ -2334,6 +2469,23 @@ static int dvb_frontend_ioctl_legacy(struct file *file,
2056 + }
2057 + break;
2058 +
2059 ++ case FE_DISEQC_RECV_SLAVE_REPLY:
2060 ++ if (fe->ops.diseqc_recv_slave_reply)
2061 ++ err = fe->ops.diseqc_recv_slave_reply(fe, (struct dvb_diseqc_slave_reply*) parg);
2062 ++ break;
2063 ++
2064 ++ case FE_ENABLE_HIGH_LNB_VOLTAGE:
2065 ++ if (fe->ops.enable_high_lnb_voltage)
2066 ++ err = fe->ops.enable_high_lnb_voltage(fe, (long) parg);
2067 ++ break;
2068 ++
2069 ++ case FE_SET_FRONTEND_TUNE_MODE:
2070 ++ fepriv->tune_mode_flags = (unsigned long) parg;
2071 ++ err = 0;
2072 ++ break;
2073 ++
2074 ++ /* DEPRECATED dish control ioctls */
2075 ++
2076 + case FE_DISHNETWORK_SEND_LEGACY_CMD:
2077 + if (fe->ops.dishnetwork_send_legacy_command) {
2078 + err = fe->ops.dishnetwork_send_legacy_command(fe,
2079 +@@ -2398,16 +2550,46 @@ static int dvb_frontend_ioctl_legacy(struct file *file,
2080 + }
2081 + break;
2082 +
2083 +- case FE_DISEQC_RECV_SLAVE_REPLY:
2084 +- if (fe->ops.diseqc_recv_slave_reply)
2085 +- err = fe->ops.diseqc_recv_slave_reply(fe, (struct dvb_diseqc_slave_reply*) parg);
2086 ++ /* DEPRECATED statistics ioctls */
2087 ++
2088 ++ case FE_READ_BER:
2089 ++ if (fe->ops.read_ber) {
2090 ++ if (fepriv->thread)
2091 ++ err = fe->ops.read_ber(fe, (__u32 *) parg);
2092 ++ else
2093 ++ err = -EAGAIN;
2094 ++ }
2095 + break;
2096 +
2097 +- case FE_ENABLE_HIGH_LNB_VOLTAGE:
2098 +- if (fe->ops.enable_high_lnb_voltage)
2099 +- err = fe->ops.enable_high_lnb_voltage(fe, (long) parg);
2100 ++ case FE_READ_SIGNAL_STRENGTH:
2101 ++ if (fe->ops.read_signal_strength) {
2102 ++ if (fepriv->thread)
2103 ++ err = fe->ops.read_signal_strength(fe, (__u16 *) parg);
2104 ++ else
2105 ++ err = -EAGAIN;
2106 ++ }
2107 ++ break;
2108 ++
2109 ++ case FE_READ_SNR:
2110 ++ if (fe->ops.read_snr) {
2111 ++ if (fepriv->thread)
2112 ++ err = fe->ops.read_snr(fe, (__u16 *) parg);
2113 ++ else
2114 ++ err = -EAGAIN;
2115 ++ }
2116 ++ break;
2117 ++
2118 ++ case FE_READ_UNCORRECTED_BLOCKS:
2119 ++ if (fe->ops.read_ucblocks) {
2120 ++ if (fepriv->thread)
2121 ++ err = fe->ops.read_ucblocks(fe, (__u32 *) parg);
2122 ++ else
2123 ++ err = -EAGAIN;
2124 ++ }
2125 + break;
2126 +
2127 ++ /* DEPRECATED DVBv3 ioctls */
2128 ++
2129 + case FE_SET_FRONTEND:
2130 + err = dvbv3_set_delivery_system(fe);
2131 + if (err)
2132 +@@ -2434,11 +2616,10 @@ static int dvb_frontend_ioctl_legacy(struct file *file,
2133 + err = dtv_get_frontend(fe, &getp, parg);
2134 + break;
2135 + }
2136 +- case FE_SET_FRONTEND_TUNE_MODE:
2137 +- fepriv->tune_mode_flags = (unsigned long) parg;
2138 +- err = 0;
2139 +- break;
2140 +- }
2141 ++
2142 ++ default:
2143 ++ return -ENOTSUPP;
2144 ++ } /* switch */
2145 +
2146 + return err;
2147 + }
2148 +@@ -2609,7 +2790,10 @@ static int dvb_frontend_release(struct inode *inode, struct file *file)
2149 +
2150 + static const struct file_operations dvb_frontend_fops = {
2151 + .owner = THIS_MODULE,
2152 +- .unlocked_ioctl = dvb_generic_ioctl,
2153 ++ .unlocked_ioctl = dvb_frontend_ioctl,
2154 ++#ifdef CONFIG_COMPAT
2155 ++ .compat_ioctl = dvb_frontend_compat_ioctl,
2156 ++#endif
2157 + .poll = dvb_frontend_poll,
2158 + .open = dvb_frontend_open,
2159 + .release = dvb_frontend_release,
2160 +@@ -2677,7 +2861,6 @@ int dvb_register_frontend(struct dvb_adapter* dvb,
2161 + #if defined(CONFIG_MEDIA_CONTROLLER_DVB)
2162 + .name = fe->ops.info.name,
2163 + #endif
2164 +- .kernel_ioctl = dvb_frontend_ioctl
2165 + };
2166 +
2167 + dev_dbg(dvb->device, "%s:\n", __func__);
2168 +diff --git a/drivers/media/dvb-core/dvb_frontend.h b/drivers/media/dvb-core/dvb_frontend.h
2169 +index fb6e84811504..8a6267ad56d6 100644
2170 +--- a/drivers/media/dvb-core/dvb_frontend.h
2171 ++++ b/drivers/media/dvb-core/dvb_frontend.h
2172 +@@ -397,13 +397,8 @@ struct dtv_frontend_properties;
2173 + * @search: callback function used on some custom algo search algos.
2174 + * @tuner_ops: pointer to struct dvb_tuner_ops
2175 + * @analog_ops: pointer to struct analog_demod_ops
2176 +- * @set_property: callback function to allow the frontend to validade
2177 +- * incoming properties. Should not be used on new drivers.
2178 +- * @get_property: callback function to allow the frontend to override
2179 +- * outcoming properties. Should not be used on new drivers.
2180 + */
2181 + struct dvb_frontend_ops {
2182 +-
2183 + struct dvb_frontend_info info;
2184 +
2185 + u8 delsys[MAX_DELSYS];
2186 +@@ -461,9 +456,6 @@ struct dvb_frontend_ops {
2187 +
2188 + struct dvb_tuner_ops tuner_ops;
2189 + struct analog_demod_ops analog_ops;
2190 +-
2191 +- int (*set_property)(struct dvb_frontend* fe, struct dtv_property* tvp);
2192 +- int (*get_property)(struct dvb_frontend* fe, struct dtv_property* tvp);
2193 + };
2194 +
2195 + #ifdef __DVB_CORE__
2196 +@@ -623,11 +615,6 @@ struct dtv_frontend_properties {
2197 + struct dtv_fe_stats post_bit_count;
2198 + struct dtv_fe_stats block_error;
2199 + struct dtv_fe_stats block_count;
2200 +-
2201 +- /* private: */
2202 +- /* Cache State */
2203 +- u32 state;
2204 +-
2205 + };
2206 +
2207 + #define DVB_FE_NO_EXIT 0
2208 +diff --git a/drivers/media/dvb-frontends/lg2160.c b/drivers/media/dvb-frontends/lg2160.c
2209 +index f51a3a0b3949..1b640651531d 100644
2210 +--- a/drivers/media/dvb-frontends/lg2160.c
2211 ++++ b/drivers/media/dvb-frontends/lg2160.c
2212 +@@ -1052,16 +1052,6 @@ fail:
2213 + return ret;
2214 + }
2215 +
2216 +-static int lg216x_get_property(struct dvb_frontend *fe,
2217 +- struct dtv_property *tvp)
2218 +-{
2219 +- struct dtv_frontend_properties *c = &fe->dtv_property_cache;
2220 +-
2221 +- return (DTV_ATSCMH_FIC_VER == tvp->cmd) ?
2222 +- lg216x_get_frontend(fe, c) : 0;
2223 +-}
2224 +-
2225 +-
2226 + static int lg2160_set_frontend(struct dvb_frontend *fe)
2227 + {
2228 + struct lg216x_state *state = fe->demodulator_priv;
2229 +@@ -1372,8 +1362,6 @@ static struct dvb_frontend_ops lg2160_ops = {
2230 + .init = lg216x_init,
2231 + .sleep = lg216x_sleep,
2232 + #endif
2233 +- .get_property = lg216x_get_property,
2234 +-
2235 + .set_frontend = lg2160_set_frontend,
2236 + .get_frontend = lg216x_get_frontend,
2237 + .get_tune_settings = lg216x_get_tune_settings,
2238 +@@ -1400,8 +1388,6 @@ static struct dvb_frontend_ops lg2161_ops = {
2239 + .init = lg216x_init,
2240 + .sleep = lg216x_sleep,
2241 + #endif
2242 +- .get_property = lg216x_get_property,
2243 +-
2244 + .set_frontend = lg2160_set_frontend,
2245 + .get_frontend = lg216x_get_frontend,
2246 + .get_tune_settings = lg216x_get_tune_settings,
2247 +diff --git a/drivers/media/dvb-frontends/stv0288.c b/drivers/media/dvb-frontends/stv0288.c
2248 +index c93d9a45f7f7..2b8c75f28d2e 100644
2249 +--- a/drivers/media/dvb-frontends/stv0288.c
2250 ++++ b/drivers/media/dvb-frontends/stv0288.c
2251 +@@ -447,12 +447,6 @@ static int stv0288_read_ucblocks(struct dvb_frontend *fe, u32 *ucblocks)
2252 + return 0;
2253 + }
2254 +
2255 +-static int stv0288_set_property(struct dvb_frontend *fe, struct dtv_property *p)
2256 +-{
2257 +- dprintk("%s(..)\n", __func__);
2258 +- return 0;
2259 +-}
2260 +-
2261 + static int stv0288_set_frontend(struct dvb_frontend *fe)
2262 + {
2263 + struct stv0288_state *state = fe->demodulator_priv;
2264 +@@ -568,7 +562,6 @@ static struct dvb_frontend_ops stv0288_ops = {
2265 + .set_tone = stv0288_set_tone,
2266 + .set_voltage = stv0288_set_voltage,
2267 +
2268 +- .set_property = stv0288_set_property,
2269 + .set_frontend = stv0288_set_frontend,
2270 + };
2271 +
2272 +diff --git a/drivers/media/dvb-frontends/stv6110.c b/drivers/media/dvb-frontends/stv6110.c
2273 +index 66a5a7f2295c..93262b13c644 100644
2274 +--- a/drivers/media/dvb-frontends/stv6110.c
2275 ++++ b/drivers/media/dvb-frontends/stv6110.c
2276 +@@ -263,11 +263,9 @@ static int stv6110_get_frequency(struct dvb_frontend *fe, u32 *frequency)
2277 + static int stv6110_set_frequency(struct dvb_frontend *fe, u32 frequency)
2278 + {
2279 + struct stv6110_priv *priv = fe->tuner_priv;
2280 +- struct dtv_frontend_properties *c = &fe->dtv_property_cache;
2281 + u8 ret = 0x04;
2282 + u32 divider, ref, p, presc, i, result_freq, vco_freq;
2283 + s32 p_calc, p_calc_opt = 1000, r_div, r_div_opt = 0, p_val;
2284 +- s32 srate;
2285 +
2286 + dprintk("%s, freq=%d kHz, mclk=%d Hz\n", __func__,
2287 + frequency, priv->mclk);
2288 +@@ -278,13 +276,6 @@ static int stv6110_set_frequency(struct dvb_frontend *fe, u32 frequency)
2289 + ((((priv->mclk / 1000000) - 16) & 0x1f) << 3);
2290 +
2291 + /* BB_GAIN = db/2 */
2292 +- if (fe->ops.set_property && fe->ops.get_property) {
2293 +- srate = c->symbol_rate;
2294 +- dprintk("%s: Get Frontend parameters: srate=%d\n",
2295 +- __func__, srate);
2296 +- } else
2297 +- srate = 15000000;
2298 +-
2299 + priv->regs[RSTV6110_CTRL2] &= ~0x0f;
2300 + priv->regs[RSTV6110_CTRL2] |= (priv->gain & 0x0f);
2301 +
2302 +diff --git a/drivers/media/usb/dvb-usb/friio-fe.c b/drivers/media/usb/dvb-usb/friio-fe.c
2303 +index 979f05b4b87c..237f12f9a7f2 100644
2304 +--- a/drivers/media/usb/dvb-usb/friio-fe.c
2305 ++++ b/drivers/media/usb/dvb-usb/friio-fe.c
2306 +@@ -261,28 +261,6 @@ static int jdvbt90502_read_signal_strength(struct dvb_frontend *fe,
2307 + return 0;
2308 + }
2309 +
2310 +-
2311 +-/* filter out un-supported properties to notify users */
2312 +-static int jdvbt90502_set_property(struct dvb_frontend *fe,
2313 +- struct dtv_property *tvp)
2314 +-{
2315 +- int r = 0;
2316 +-
2317 +- switch (tvp->cmd) {
2318 +- case DTV_DELIVERY_SYSTEM:
2319 +- if (tvp->u.data != SYS_ISDBT)
2320 +- r = -EINVAL;
2321 +- break;
2322 +- case DTV_CLEAR:
2323 +- case DTV_TUNE:
2324 +- case DTV_FREQUENCY:
2325 +- break;
2326 +- default:
2327 +- r = -EINVAL;
2328 +- }
2329 +- return r;
2330 +-}
2331 +-
2332 + static int jdvbt90502_set_frontend(struct dvb_frontend *fe)
2333 + {
2334 + struct dtv_frontend_properties *p = &fe->dtv_property_cache;
2335 +@@ -457,8 +435,6 @@ static struct dvb_frontend_ops jdvbt90502_ops = {
2336 + .init = jdvbt90502_init,
2337 + .write = _jdvbt90502_write,
2338 +
2339 +- .set_property = jdvbt90502_set_property,
2340 +-
2341 + .set_frontend = jdvbt90502_set_frontend,
2342 +
2343 + .read_status = jdvbt90502_read_status,
2344 +diff --git a/drivers/mfd/wm8994-core.c b/drivers/mfd/wm8994-core.c
2345 +index 8588dbad3301..925c1828ec28 100644
2346 +--- a/drivers/mfd/wm8994-core.c
2347 ++++ b/drivers/mfd/wm8994-core.c
2348 +@@ -698,3 +698,4 @@ module_i2c_driver(wm8994_i2c_driver);
2349 + MODULE_DESCRIPTION("Core support for the WM8994 audio CODEC");
2350 + MODULE_LICENSE("GPL");
2351 + MODULE_AUTHOR("Mark Brown <broonie@×××××××××××××××××××××××.com>");
2352 ++MODULE_SOFTDEP("pre: wm8994_regulator");
2353 +diff --git a/drivers/mtd/nand/ams-delta.c b/drivers/mtd/nand/ams-delta.c
2354 +index 78e12cc8bac2..02ec2d183607 100644
2355 +--- a/drivers/mtd/nand/ams-delta.c
2356 ++++ b/drivers/mtd/nand/ams-delta.c
2357 +@@ -264,7 +264,7 @@ static int ams_delta_cleanup(struct platform_device *pdev)
2358 + void __iomem *io_base = platform_get_drvdata(pdev);
2359 +
2360 + /* Release resources, unregister device */
2361 +- nand_release(ams_delta_mtd);
2362 ++ nand_release(mtd_to_nand(ams_delta_mtd));
2363 +
2364 + gpio_free_array(_mandatory_gpio, ARRAY_SIZE(_mandatory_gpio));
2365 + gpio_free(AMS_DELTA_GPIO_PIN_NAND_RB);
2366 +diff --git a/drivers/mtd/nand/atmel_nand.c b/drivers/mtd/nand/atmel_nand.c
2367 +index 68b9160108c9..45495bc1a70e 100644
2368 +--- a/drivers/mtd/nand/atmel_nand.c
2369 ++++ b/drivers/mtd/nand/atmel_nand.c
2370 +@@ -2336,7 +2336,7 @@ static int atmel_nand_remove(struct platform_device *pdev)
2371 + struct atmel_nand_host *host = platform_get_drvdata(pdev);
2372 + struct mtd_info *mtd = nand_to_mtd(&host->nand_chip);
2373 +
2374 +- nand_release(mtd);
2375 ++ nand_release(&host->nand_chip);
2376 +
2377 + atmel_nand_disable(host);
2378 +
2379 +diff --git a/drivers/mtd/nand/au1550nd.c b/drivers/mtd/nand/au1550nd.c
2380 +index 9bf6d9915694..a0e7789131df 100644
2381 +--- a/drivers/mtd/nand/au1550nd.c
2382 ++++ b/drivers/mtd/nand/au1550nd.c
2383 +@@ -496,7 +496,7 @@ static int au1550nd_remove(struct platform_device *pdev)
2384 + struct au1550nd_ctx *ctx = platform_get_drvdata(pdev);
2385 + struct resource *r = platform_get_resource(pdev, IORESOURCE_MEM, 0);
2386 +
2387 +- nand_release(nand_to_mtd(&ctx->chip));
2388 ++ nand_release(&ctx->chip);
2389 + iounmap(ctx->base);
2390 + release_mem_region(r->start, 0x1000);
2391 + kfree(ctx);
2392 +diff --git a/drivers/mtd/nand/bcm47xxnflash/main.c b/drivers/mtd/nand/bcm47xxnflash/main.c
2393 +index fb31429b70a9..d79694160845 100644
2394 +--- a/drivers/mtd/nand/bcm47xxnflash/main.c
2395 ++++ b/drivers/mtd/nand/bcm47xxnflash/main.c
2396 +@@ -65,7 +65,7 @@ static int bcm47xxnflash_remove(struct platform_device *pdev)
2397 + {
2398 + struct bcm47xxnflash *nflash = platform_get_drvdata(pdev);
2399 +
2400 +- nand_release(nand_to_mtd(&nflash->nand_chip));
2401 ++ nand_release(&nflash->nand_chip);
2402 +
2403 + return 0;
2404 + }
2405 +diff --git a/drivers/mtd/nand/bf5xx_nand.c b/drivers/mtd/nand/bf5xx_nand.c
2406 +index 3962f55bd034..020bb350a2db 100644
2407 +--- a/drivers/mtd/nand/bf5xx_nand.c
2408 ++++ b/drivers/mtd/nand/bf5xx_nand.c
2409 +@@ -688,7 +688,7 @@ static int bf5xx_nand_remove(struct platform_device *pdev)
2410 + * and their partitions, then go through freeing the
2411 + * resources used
2412 + */
2413 +- nand_release(nand_to_mtd(&info->chip));
2414 ++ nand_release(&info->chip);
2415 +
2416 + peripheral_free_list(bfin_nfc_pin_req);
2417 + bf5xx_nand_dma_remove(info);
2418 +diff --git a/drivers/mtd/nand/brcmnand/brcmnand.c b/drivers/mtd/nand/brcmnand/brcmnand.c
2419 +index 1291492a1cef..fbee81909d38 100644
2420 +--- a/drivers/mtd/nand/brcmnand/brcmnand.c
2421 ++++ b/drivers/mtd/nand/brcmnand/brcmnand.c
2422 +@@ -2595,7 +2595,7 @@ int brcmnand_remove(struct platform_device *pdev)
2423 + struct brcmnand_host *host;
2424 +
2425 + list_for_each_entry(host, &ctrl->host_list, node)
2426 +- nand_release(nand_to_mtd(&host->chip));
2427 ++ nand_release(&host->chip);
2428 +
2429 + clk_disable_unprepare(ctrl->clk);
2430 +
2431 +diff --git a/drivers/mtd/nand/cafe_nand.c b/drivers/mtd/nand/cafe_nand.c
2432 +index 0b0c93702abb..c16e740c01c3 100644
2433 +--- a/drivers/mtd/nand/cafe_nand.c
2434 ++++ b/drivers/mtd/nand/cafe_nand.c
2435 +@@ -825,7 +825,7 @@ static void cafe_nand_remove(struct pci_dev *pdev)
2436 + /* Disable NAND IRQ in global IRQ mask register */
2437 + cafe_writel(cafe, ~1 & cafe_readl(cafe, GLOBAL_IRQ_MASK), GLOBAL_IRQ_MASK);
2438 + free_irq(pdev->irq, mtd);
2439 +- nand_release(mtd);
2440 ++ nand_release(chip);
2441 + free_rs(cafe->rs);
2442 + pci_iounmap(pdev, cafe->mmio);
2443 + dma_free_coherent(&cafe->pdev->dev,
2444 +diff --git a/drivers/mtd/nand/cmx270_nand.c b/drivers/mtd/nand/cmx270_nand.c
2445 +index 49133783ca53..b9667204e711 100644
2446 +--- a/drivers/mtd/nand/cmx270_nand.c
2447 ++++ b/drivers/mtd/nand/cmx270_nand.c
2448 +@@ -230,7 +230,7 @@ module_init(cmx270_init);
2449 + static void __exit cmx270_cleanup(void)
2450 + {
2451 + /* Release resources, unregister device */
2452 +- nand_release(cmx270_nand_mtd);
2453 ++ nand_release(mtd_to_nand(cmx270_nand_mtd));
2454 +
2455 + gpio_free(GPIO_NAND_RB);
2456 + gpio_free(GPIO_NAND_CS);
2457 +diff --git a/drivers/mtd/nand/cs553x_nand.c b/drivers/mtd/nand/cs553x_nand.c
2458 +index a65e4e0f57a1..4779dfec3576 100644
2459 +--- a/drivers/mtd/nand/cs553x_nand.c
2460 ++++ b/drivers/mtd/nand/cs553x_nand.c
2461 +@@ -339,7 +339,7 @@ static void __exit cs553x_cleanup(void)
2462 + mmio_base = this->IO_ADDR_R;
2463 +
2464 + /* Release resources, unregister device */
2465 +- nand_release(mtd);
2466 ++ nand_release(this);
2467 + kfree(mtd->name);
2468 + cs553x_mtd[i] = NULL;
2469 +
2470 +diff --git a/drivers/mtd/nand/davinci_nand.c b/drivers/mtd/nand/davinci_nand.c
2471 +index 27fa8b87cd5f..c7f535676e49 100644
2472 +--- a/drivers/mtd/nand/davinci_nand.c
2473 ++++ b/drivers/mtd/nand/davinci_nand.c
2474 +@@ -840,7 +840,7 @@ static int nand_davinci_remove(struct platform_device *pdev)
2475 + ecc4_busy = false;
2476 + spin_unlock_irq(&davinci_nand_lock);
2477 +
2478 +- nand_release(nand_to_mtd(&info->chip));
2479 ++ nand_release(&info->chip);
2480 +
2481 + clk_disable_unprepare(info->clk);
2482 +
2483 +diff --git a/drivers/mtd/nand/denali.c b/drivers/mtd/nand/denali.c
2484 +index 0476ae8776d9..982cbc7f412f 100644
2485 +--- a/drivers/mtd/nand/denali.c
2486 ++++ b/drivers/mtd/nand/denali.c
2487 +@@ -1655,7 +1655,7 @@ void denali_remove(struct denali_nand_info *denali)
2488 + */
2489 + int bufsize = mtd->writesize + mtd->oobsize;
2490 +
2491 +- nand_release(mtd);
2492 ++ nand_release(&denali->nand);
2493 + denali_irq_cleanup(denali->irq, denali);
2494 + dma_unmap_single(denali->dev, denali->buf.dma_buf, bufsize,
2495 + DMA_BIDIRECTIONAL);
2496 +diff --git a/drivers/mtd/nand/diskonchip.c b/drivers/mtd/nand/diskonchip.c
2497 +index a023ab9e9cbf..374b7a10ba51 100644
2498 +--- a/drivers/mtd/nand/diskonchip.c
2499 ++++ b/drivers/mtd/nand/diskonchip.c
2500 +@@ -1605,13 +1605,10 @@ static int __init doc_probe(unsigned long physadr)
2501 + numchips = doc2001_init(mtd);
2502 +
2503 + if ((ret = nand_scan(mtd, numchips)) || (ret = doc->late_init(mtd))) {
2504 +- /* DBB note: i believe nand_release is necessary here, as
2505 ++ /* DBB note: i believe nand_cleanup is necessary here, as
2506 + buffers may have been allocated in nand_base. Check with
2507 + Thomas. FIX ME! */
2508 +- /* nand_release will call mtd_device_unregister, but we
2509 +- haven't yet added it. This is handled without incident by
2510 +- mtd_device_unregister, as far as I can tell. */
2511 +- nand_release(mtd);
2512 ++ nand_cleanup(nand);
2513 + kfree(nand);
2514 + goto fail;
2515 + }
2516 +@@ -1644,7 +1641,7 @@ static void release_nanddoc(void)
2517 + doc = nand_get_controller_data(nand);
2518 +
2519 + nextmtd = doc->nextdoc;
2520 +- nand_release(mtd);
2521 ++ nand_release(nand);
2522 + iounmap(doc->virtadr);
2523 + release_mem_region(doc->physadr, DOC_IOREMAP_LEN);
2524 + kfree(nand);
2525 +diff --git a/drivers/mtd/nand/docg4.c b/drivers/mtd/nand/docg4.c
2526 +index 7af2a3cd949e..5798cd87f340 100644
2527 +--- a/drivers/mtd/nand/docg4.c
2528 ++++ b/drivers/mtd/nand/docg4.c
2529 +@@ -1374,7 +1374,7 @@ static int __init probe_docg4(struct platform_device *pdev)
2530 + return 0;
2531 +
2532 + fail:
2533 +- nand_release(mtd); /* deletes partitions and mtd devices */
2534 ++ nand_release(nand); /* deletes partitions and mtd devices */
2535 + free_bch(doc->bch);
2536 + kfree(nand);
2537 +
2538 +@@ -1387,7 +1387,7 @@ fail_unmap:
2539 + static int __exit cleanup_docg4(struct platform_device *pdev)
2540 + {
2541 + struct docg4_priv *doc = platform_get_drvdata(pdev);
2542 +- nand_release(doc->mtd);
2543 ++ nand_release(mtd_to_nand(doc->mtd));
2544 + free_bch(doc->bch);
2545 + kfree(mtd_to_nand(doc->mtd));
2546 + iounmap(doc->virtadr);
2547 +diff --git a/drivers/mtd/nand/fsl_elbc_nand.c b/drivers/mtd/nand/fsl_elbc_nand.c
2548 +index 113f76e59937..2fc4f2ab89ff 100644
2549 +--- a/drivers/mtd/nand/fsl_elbc_nand.c
2550 ++++ b/drivers/mtd/nand/fsl_elbc_nand.c
2551 +@@ -811,7 +811,7 @@ static int fsl_elbc_chip_remove(struct fsl_elbc_mtd *priv)
2552 + struct fsl_elbc_fcm_ctrl *elbc_fcm_ctrl = priv->ctrl->nand;
2553 + struct mtd_info *mtd = nand_to_mtd(&priv->chip);
2554 +
2555 +- nand_release(mtd);
2556 ++ nand_release(&priv->chip);
2557 +
2558 + kfree(mtd->name);
2559 +
2560 +diff --git a/drivers/mtd/nand/fsl_ifc_nand.c b/drivers/mtd/nand/fsl_ifc_nand.c
2561 +index 4c3b986dd74d..cf0fccb5908e 100644
2562 +--- a/drivers/mtd/nand/fsl_ifc_nand.c
2563 ++++ b/drivers/mtd/nand/fsl_ifc_nand.c
2564 +@@ -918,7 +918,7 @@ static int fsl_ifc_chip_remove(struct fsl_ifc_mtd *priv)
2565 + {
2566 + struct mtd_info *mtd = nand_to_mtd(&priv->chip);
2567 +
2568 +- nand_release(mtd);
2569 ++ nand_release(&priv->chip);
2570 +
2571 + kfree(mtd->name);
2572 +
2573 +diff --git a/drivers/mtd/nand/fsl_upm.c b/drivers/mtd/nand/fsl_upm.c
2574 +index d85fa2555b68..0b4d2489cc71 100644
2575 +--- a/drivers/mtd/nand/fsl_upm.c
2576 ++++ b/drivers/mtd/nand/fsl_upm.c
2577 +@@ -326,7 +326,7 @@ static int fun_remove(struct platform_device *ofdev)
2578 + struct mtd_info *mtd = nand_to_mtd(&fun->chip);
2579 + int i;
2580 +
2581 +- nand_release(mtd);
2582 ++ nand_release(&fun->chip);
2583 + kfree(mtd->name);
2584 +
2585 + for (i = 0; i < fun->mchip_count; i++) {
2586 +diff --git a/drivers/mtd/nand/fsmc_nand.c b/drivers/mtd/nand/fsmc_nand.c
2587 +index d4f454a4b35e..92737deb7845 100644
2588 +--- a/drivers/mtd/nand/fsmc_nand.c
2589 ++++ b/drivers/mtd/nand/fsmc_nand.c
2590 +@@ -1038,7 +1038,7 @@ static int fsmc_nand_remove(struct platform_device *pdev)
2591 + struct fsmc_nand_data *host = platform_get_drvdata(pdev);
2592 +
2593 + if (host) {
2594 +- nand_release(nand_to_mtd(&host->nand));
2595 ++ nand_release(&host->nand);
2596 +
2597 + if (host->mode == USE_DMA_ACCESS) {
2598 + dma_release_channel(host->write_dma_chan);
2599 +diff --git a/drivers/mtd/nand/gpio.c b/drivers/mtd/nand/gpio.c
2600 +index 6317f6836022..c7461ca1c1a6 100644
2601 +--- a/drivers/mtd/nand/gpio.c
2602 ++++ b/drivers/mtd/nand/gpio.c
2603 +@@ -197,7 +197,7 @@ static int gpio_nand_remove(struct platform_device *pdev)
2604 + {
2605 + struct gpiomtd *gpiomtd = platform_get_drvdata(pdev);
2606 +
2607 +- nand_release(nand_to_mtd(&gpiomtd->nand_chip));
2608 ++ nand_release(&gpiomtd->nand_chip);
2609 +
2610 + if (gpio_is_valid(gpiomtd->plat.gpio_nwp))
2611 + gpio_set_value(gpiomtd->plat.gpio_nwp, 0);
2612 +diff --git a/drivers/mtd/nand/gpmi-nand/gpmi-nand.c b/drivers/mtd/nand/gpmi-nand/gpmi-nand.c
2613 +index d9dab4275859..f4a99e91c250 100644
2614 +--- a/drivers/mtd/nand/gpmi-nand/gpmi-nand.c
2615 ++++ b/drivers/mtd/nand/gpmi-nand/gpmi-nand.c
2616 +@@ -1930,7 +1930,7 @@ static int gpmi_set_geometry(struct gpmi_nand_data *this)
2617 +
2618 + static void gpmi_nand_exit(struct gpmi_nand_data *this)
2619 + {
2620 +- nand_release(nand_to_mtd(&this->nand));
2621 ++ nand_release(&this->nand);
2622 + gpmi_free_dma_buffer(this);
2623 + }
2624 +
2625 +diff --git a/drivers/mtd/nand/hisi504_nand.c b/drivers/mtd/nand/hisi504_nand.c
2626 +index 9432546f4cd4..6c96d9d29a31 100644
2627 +--- a/drivers/mtd/nand/hisi504_nand.c
2628 ++++ b/drivers/mtd/nand/hisi504_nand.c
2629 +@@ -823,7 +823,7 @@ static int hisi_nfc_probe(struct platform_device *pdev)
2630 + return 0;
2631 +
2632 + err_mtd:
2633 +- nand_release(mtd);
2634 ++ nand_release(chip);
2635 + err_res:
2636 + return ret;
2637 + }
2638 +@@ -831,9 +831,8 @@ err_res:
2639 + static int hisi_nfc_remove(struct platform_device *pdev)
2640 + {
2641 + struct hinfc_host *host = platform_get_drvdata(pdev);
2642 +- struct mtd_info *mtd = nand_to_mtd(&host->chip);
2643 +
2644 +- nand_release(mtd);
2645 ++ nand_release(&host->chip);
2646 +
2647 + return 0;
2648 + }
2649 +diff --git a/drivers/mtd/nand/jz4740_nand.c b/drivers/mtd/nand/jz4740_nand.c
2650 +index 5551c36adbdf..6f323858d51a 100644
2651 +--- a/drivers/mtd/nand/jz4740_nand.c
2652 ++++ b/drivers/mtd/nand/jz4740_nand.c
2653 +@@ -499,7 +499,7 @@ static int jz_nand_probe(struct platform_device *pdev)
2654 + return 0;
2655 +
2656 + err_nand_release:
2657 +- nand_release(mtd);
2658 ++ nand_release(chip);
2659 + err_unclaim_banks:
2660 + while (chipnr--) {
2661 + unsigned char bank = nand->banks[chipnr];
2662 +@@ -520,7 +520,7 @@ static int jz_nand_remove(struct platform_device *pdev)
2663 + struct jz_nand *nand = platform_get_drvdata(pdev);
2664 + size_t i;
2665 +
2666 +- nand_release(nand_to_mtd(&nand->chip));
2667 ++ nand_release(&nand->chip);
2668 +
2669 + /* Deassert and disable all chips */
2670 + writel(0, nand->base + JZ_REG_NAND_CTRL);
2671 +diff --git a/drivers/mtd/nand/jz4780_nand.c b/drivers/mtd/nand/jz4780_nand.c
2672 +index a39bb70175ee..e8aaf2543946 100644
2673 +--- a/drivers/mtd/nand/jz4780_nand.c
2674 ++++ b/drivers/mtd/nand/jz4780_nand.c
2675 +@@ -293,7 +293,7 @@ static int jz4780_nand_init_chip(struct platform_device *pdev,
2676 +
2677 + ret = mtd_device_register(mtd, NULL, 0);
2678 + if (ret) {
2679 +- nand_release(mtd);
2680 ++ nand_release(chip);
2681 + return ret;
2682 + }
2683 +
2684 +@@ -308,7 +308,7 @@ static void jz4780_nand_cleanup_chips(struct jz4780_nand_controller *nfc)
2685 +
2686 + while (!list_empty(&nfc->chips)) {
2687 + chip = list_first_entry(&nfc->chips, struct jz4780_nand_chip, chip_list);
2688 +- nand_release(nand_to_mtd(&chip->chip));
2689 ++ nand_release(&chip->chip);
2690 + list_del(&chip->chip_list);
2691 + }
2692 + }
2693 +diff --git a/drivers/mtd/nand/lpc32xx_mlc.c b/drivers/mtd/nand/lpc32xx_mlc.c
2694 +index bc6e49af063a..839f8f4ace9e 100644
2695 +--- a/drivers/mtd/nand/lpc32xx_mlc.c
2696 ++++ b/drivers/mtd/nand/lpc32xx_mlc.c
2697 +@@ -805,7 +805,7 @@ static int lpc32xx_nand_probe(struct platform_device *pdev)
2698 + if (!res)
2699 + return res;
2700 +
2701 +- nand_release(mtd);
2702 ++ nand_release(nand_chip);
2703 +
2704 + err_exit4:
2705 + free_irq(host->irq, host);
2706 +@@ -828,9 +828,8 @@ err_exit1:
2707 + static int lpc32xx_nand_remove(struct platform_device *pdev)
2708 + {
2709 + struct lpc32xx_nand_host *host = platform_get_drvdata(pdev);
2710 +- struct mtd_info *mtd = nand_to_mtd(&host->nand_chip);
2711 +
2712 +- nand_release(mtd);
2713 ++ nand_release(&host->nand_chip);
2714 + free_irq(host->irq, host);
2715 + if (use_dma)
2716 + dma_release_channel(host->dma_chan);
2717 +diff --git a/drivers/mtd/nand/lpc32xx_slc.c b/drivers/mtd/nand/lpc32xx_slc.c
2718 +index 8d3edc34958e..0b5fa254ea60 100644
2719 +--- a/drivers/mtd/nand/lpc32xx_slc.c
2720 ++++ b/drivers/mtd/nand/lpc32xx_slc.c
2721 +@@ -940,7 +940,7 @@ static int lpc32xx_nand_probe(struct platform_device *pdev)
2722 + if (!res)
2723 + return res;
2724 +
2725 +- nand_release(mtd);
2726 ++ nand_release(chip);
2727 +
2728 + err_exit3:
2729 + dma_release_channel(host->dma_chan);
2730 +@@ -959,9 +959,8 @@ static int lpc32xx_nand_remove(struct platform_device *pdev)
2731 + {
2732 + uint32_t tmp;
2733 + struct lpc32xx_nand_host *host = platform_get_drvdata(pdev);
2734 +- struct mtd_info *mtd = nand_to_mtd(&host->nand_chip);
2735 +
2736 +- nand_release(mtd);
2737 ++ nand_release(&host->nand_chip);
2738 + dma_release_channel(host->dma_chan);
2739 +
2740 + /* Force CE high */
2741 +diff --git a/drivers/mtd/nand/mpc5121_nfc.c b/drivers/mtd/nand/mpc5121_nfc.c
2742 +index 7eacb2f545f5..9662f8fe4713 100644
2743 +--- a/drivers/mtd/nand/mpc5121_nfc.c
2744 ++++ b/drivers/mtd/nand/mpc5121_nfc.c
2745 +@@ -827,7 +827,7 @@ static int mpc5121_nfc_remove(struct platform_device *op)
2746 + struct device *dev = &op->dev;
2747 + struct mtd_info *mtd = dev_get_drvdata(dev);
2748 +
2749 +- nand_release(mtd);
2750 ++ nand_release(mtd_to_nand(mtd));
2751 + mpc5121_nfc_free(dev, mtd);
2752 +
2753 + return 0;
2754 +diff --git a/drivers/mtd/nand/mtk_nand.c b/drivers/mtd/nand/mtk_nand.c
2755 +index ca95ae00215e..2375dce766ef 100644
2756 +--- a/drivers/mtd/nand/mtk_nand.c
2757 ++++ b/drivers/mtd/nand/mtk_nand.c
2758 +@@ -1327,7 +1327,7 @@ static int mtk_nfc_nand_chip_init(struct device *dev, struct mtk_nfc *nfc,
2759 + ret = mtd_device_parse_register(mtd, NULL, NULL, NULL, 0);
2760 + if (ret) {
2761 + dev_err(dev, "mtd parse partition error\n");
2762 +- nand_release(mtd);
2763 ++ nand_cleanup(nand);
2764 + return ret;
2765 + }
2766 +
2767 +@@ -1450,7 +1450,7 @@ static int mtk_nfc_remove(struct platform_device *pdev)
2768 + while (!list_empty(&nfc->chips)) {
2769 + chip = list_first_entry(&nfc->chips, struct mtk_nfc_nand_chip,
2770 + node);
2771 +- nand_release(nand_to_mtd(&chip->nand));
2772 ++ nand_release(&chip->nand);
2773 + list_del(&chip->node);
2774 + }
2775 +
2776 +diff --git a/drivers/mtd/nand/mxc_nand.c b/drivers/mtd/nand/mxc_nand.c
2777 +index 5c44eb57885b..deb3cbadbc51 100644
2778 +--- a/drivers/mtd/nand/mxc_nand.c
2779 ++++ b/drivers/mtd/nand/mxc_nand.c
2780 +@@ -1838,7 +1838,7 @@ static int mxcnd_remove(struct platform_device *pdev)
2781 + {
2782 + struct mxc_nand_host *host = platform_get_drvdata(pdev);
2783 +
2784 +- nand_release(nand_to_mtd(&host->nand));
2785 ++ nand_release(&host->nand);
2786 + if (host->clk_act)
2787 + clk_disable_unprepare(host->clk);
2788 +
2789 +diff --git a/drivers/mtd/nand/nand_base.c b/drivers/mtd/nand/nand_base.c
2790 +index 5fb45161789c..bdf40c090acd 100644
2791 +--- a/drivers/mtd/nand/nand_base.c
2792 ++++ b/drivers/mtd/nand/nand_base.c
2793 +@@ -4941,12 +4941,12 @@ EXPORT_SYMBOL_GPL(nand_cleanup);
2794 + /**
2795 + * nand_release - [NAND Interface] Unregister the MTD device and free resources
2796 + * held by the NAND device
2797 +- * @mtd: MTD device structure
2798 ++ * @chip: NAND chip object
2799 + */
2800 +-void nand_release(struct mtd_info *mtd)
2801 ++void nand_release(struct nand_chip *chip)
2802 + {
2803 +- mtd_device_unregister(mtd);
2804 +- nand_cleanup(mtd_to_nand(mtd));
2805 ++ mtd_device_unregister(nand_to_mtd(chip));
2806 ++ nand_cleanup(chip);
2807 + }
2808 + EXPORT_SYMBOL_GPL(nand_release);
2809 +
2810 +diff --git a/drivers/mtd/nand/nandsim.c b/drivers/mtd/nand/nandsim.c
2811 +index 1eb934414eb5..fe593f2f1ec7 100644
2812 +--- a/drivers/mtd/nand/nandsim.c
2813 ++++ b/drivers/mtd/nand/nandsim.c
2814 +@@ -2394,7 +2394,7 @@ static int __init ns_init_module(void)
2815 +
2816 + err_exit:
2817 + free_nandsim(nand);
2818 +- nand_release(nsmtd);
2819 ++ nand_release(chip);
2820 + for (i = 0;i < ARRAY_SIZE(nand->partitions); ++i)
2821 + kfree(nand->partitions[i].name);
2822 + error:
2823 +@@ -2417,7 +2417,7 @@ static void __exit ns_cleanup_module(void)
2824 +
2825 + nandsim_debugfs_remove(ns);
2826 + free_nandsim(ns); /* Free nandsim private resources */
2827 +- nand_release(nsmtd); /* Unregister driver */
2828 ++ nand_release(chip); /* Unregister driver */
2829 + for (i = 0;i < ARRAY_SIZE(ns->partitions); ++i)
2830 + kfree(ns->partitions[i].name);
2831 + kfree(mtd_to_nand(nsmtd)); /* Free other structures */
2832 +diff --git a/drivers/mtd/nand/ndfc.c b/drivers/mtd/nand/ndfc.c
2833 +index 28e6118362f7..d03b47d2664b 100644
2834 +--- a/drivers/mtd/nand/ndfc.c
2835 ++++ b/drivers/mtd/nand/ndfc.c
2836 +@@ -258,7 +258,7 @@ static int ndfc_remove(struct platform_device *ofdev)
2837 + struct ndfc_controller *ndfc = dev_get_drvdata(&ofdev->dev);
2838 + struct mtd_info *mtd = nand_to_mtd(&ndfc->chip);
2839 +
2840 +- nand_release(mtd);
2841 ++ nand_release(&ndfc->chip);
2842 + kfree(mtd->name);
2843 +
2844 + return 0;
2845 +diff --git a/drivers/mtd/nand/nuc900_nand.c b/drivers/mtd/nand/nuc900_nand.c
2846 +index 8f64011d32ef..f7f54b46f246 100644
2847 +--- a/drivers/mtd/nand/nuc900_nand.c
2848 ++++ b/drivers/mtd/nand/nuc900_nand.c
2849 +@@ -284,7 +284,7 @@ static int nuc900_nand_remove(struct platform_device *pdev)
2850 + {
2851 + struct nuc900_nand *nuc900_nand = platform_get_drvdata(pdev);
2852 +
2853 +- nand_release(nand_to_mtd(&nuc900_nand->chip));
2854 ++ nand_release(&nuc900_nand->chip);
2855 + clk_disable(nuc900_nand->clk);
2856 +
2857 + return 0;
2858 +diff --git a/drivers/mtd/nand/omap2.c b/drivers/mtd/nand/omap2.c
2859 +index f3a516b3f108..62c0ca437c91 100644
2860 +--- a/drivers/mtd/nand/omap2.c
2861 ++++ b/drivers/mtd/nand/omap2.c
2862 +@@ -2307,7 +2307,7 @@ static int omap_nand_remove(struct platform_device *pdev)
2863 + }
2864 + if (info->dma)
2865 + dma_release_channel(info->dma);
2866 +- nand_release(mtd);
2867 ++ nand_release(nand_chip);
2868 + return 0;
2869 + }
2870 +
2871 +diff --git a/drivers/mtd/nand/orion_nand.c b/drivers/mtd/nand/orion_nand.c
2872 +index af2f09135fb0..0acfc0a7d8e0 100644
2873 +--- a/drivers/mtd/nand/orion_nand.c
2874 ++++ b/drivers/mtd/nand/orion_nand.c
2875 +@@ -167,7 +167,7 @@ static int __init orion_nand_probe(struct platform_device *pdev)
2876 + mtd->name = "orion_nand";
2877 + ret = mtd_device_register(mtd, board->parts, board->nr_parts);
2878 + if (ret) {
2879 +- nand_release(mtd);
2880 ++ nand_cleanup(nc);
2881 + goto no_dev;
2882 + }
2883 +
2884 +@@ -184,9 +184,8 @@ static int orion_nand_remove(struct platform_device *pdev)
2885 + {
2886 + struct orion_nand_info *info = platform_get_drvdata(pdev);
2887 + struct nand_chip *chip = &info->chip;
2888 +- struct mtd_info *mtd = nand_to_mtd(chip);
2889 +
2890 +- nand_release(mtd);
2891 ++ nand_release(chip);
2892 +
2893 + if (!IS_ERR(info->clk))
2894 + clk_disable_unprepare(info->clk);
2895 +diff --git a/drivers/mtd/nand/pasemi_nand.c b/drivers/mtd/nand/pasemi_nand.c
2896 +index 80c98eef44d9..3300e43e2cb9 100644
2897 +--- a/drivers/mtd/nand/pasemi_nand.c
2898 ++++ b/drivers/mtd/nand/pasemi_nand.c
2899 +@@ -194,7 +194,7 @@ static int pasemi_nand_remove(struct platform_device *ofdev)
2900 + chip = mtd_to_nand(pasemi_nand_mtd);
2901 +
2902 + /* Release resources, unregister device */
2903 +- nand_release(pasemi_nand_mtd);
2904 ++ nand_release(chip);
2905 +
2906 + release_region(lpcctl, 4);
2907 +
2908 +diff --git a/drivers/mtd/nand/plat_nand.c b/drivers/mtd/nand/plat_nand.c
2909 +index 415a53a0deeb..ae2b3c0804ce 100644
2910 +--- a/drivers/mtd/nand/plat_nand.c
2911 ++++ b/drivers/mtd/nand/plat_nand.c
2912 +@@ -100,7 +100,7 @@ static int plat_nand_probe(struct platform_device *pdev)
2913 + if (!err)
2914 + return err;
2915 +
2916 +- nand_release(mtd);
2917 ++ nand_cleanup(&data->chip);
2918 + out:
2919 + if (pdata->ctrl.remove)
2920 + pdata->ctrl.remove(pdev);
2921 +@@ -115,7 +115,7 @@ static int plat_nand_remove(struct platform_device *pdev)
2922 + struct plat_nand_data *data = platform_get_drvdata(pdev);
2923 + struct platform_nand_data *pdata = dev_get_platdata(&pdev->dev);
2924 +
2925 +- nand_release(nand_to_mtd(&data->chip));
2926 ++ nand_release(&data->chip);
2927 + if (pdata->ctrl.remove)
2928 + pdata->ctrl.remove(pdev);
2929 +
2930 +diff --git a/drivers/mtd/nand/pxa3xx_nand.c b/drivers/mtd/nand/pxa3xx_nand.c
2931 +index 3b8911cd3a19..46f13f7e54da 100644
2932 +--- a/drivers/mtd/nand/pxa3xx_nand.c
2933 ++++ b/drivers/mtd/nand/pxa3xx_nand.c
2934 +@@ -1907,7 +1907,7 @@ static int pxa3xx_nand_remove(struct platform_device *pdev)
2935 + clk_disable_unprepare(info->clk);
2936 +
2937 + for (cs = 0; cs < pdata->num_cs; cs++)
2938 +- nand_release(nand_to_mtd(&info->host[cs]->chip));
2939 ++ nand_release(&info->host[cs]->chip);
2940 + return 0;
2941 + }
2942 +
2943 +diff --git a/drivers/mtd/nand/qcom_nandc.c b/drivers/mtd/nand/qcom_nandc.c
2944 +index 9f6c9a34b9eb..1594770987fd 100644
2945 +--- a/drivers/mtd/nand/qcom_nandc.c
2946 ++++ b/drivers/mtd/nand/qcom_nandc.c
2947 +@@ -2163,7 +2163,7 @@ static int qcom_nandc_probe(struct platform_device *pdev)
2948 +
2949 + err_cs_init:
2950 + list_for_each_entry(host, &nandc->host_list, node)
2951 +- nand_release(nand_to_mtd(&host->chip));
2952 ++ nand_release(&host->chip);
2953 + err_setup:
2954 + clk_disable_unprepare(nandc->aon_clk);
2955 + err_aon_clk:
2956 +@@ -2180,7 +2180,7 @@ static int qcom_nandc_remove(struct platform_device *pdev)
2957 + struct qcom_nand_host *host;
2958 +
2959 + list_for_each_entry(host, &nandc->host_list, node)
2960 +- nand_release(nand_to_mtd(&host->chip));
2961 ++ nand_release(&host->chip);
2962 +
2963 + qcom_nandc_unalloc(nandc);
2964 +
2965 +diff --git a/drivers/mtd/nand/r852.c b/drivers/mtd/nand/r852.c
2966 +index fc9287af4614..2cfa54941395 100644
2967 +--- a/drivers/mtd/nand/r852.c
2968 ++++ b/drivers/mtd/nand/r852.c
2969 +@@ -656,7 +656,7 @@ static int r852_register_nand_device(struct r852_device *dev)
2970 + dev->card_registred = 1;
2971 + return 0;
2972 + error3:
2973 +- nand_release(mtd);
2974 ++ nand_release(dev->chip);
2975 + error1:
2976 + /* Force card redetect */
2977 + dev->card_detected = 0;
2978 +@@ -675,7 +675,7 @@ static void r852_unregister_nand_device(struct r852_device *dev)
2979 + return;
2980 +
2981 + device_remove_file(&mtd->dev, &dev_attr_media_type);
2982 +- nand_release(mtd);
2983 ++ nand_release(dev->chip);
2984 + r852_engine_disable(dev);
2985 + dev->card_registred = 0;
2986 + }
2987 +diff --git a/drivers/mtd/nand/s3c2410.c b/drivers/mtd/nand/s3c2410.c
2988 +index d459c19d78de..be9c145b743c 100644
2989 +--- a/drivers/mtd/nand/s3c2410.c
2990 ++++ b/drivers/mtd/nand/s3c2410.c
2991 +@@ -768,7 +768,7 @@ static int s3c24xx_nand_remove(struct platform_device *pdev)
2992 +
2993 + for (mtdno = 0; mtdno < info->mtd_count; mtdno++, ptr++) {
2994 + pr_debug("releasing mtd %d (%p)\n", mtdno, ptr);
2995 +- nand_release(nand_to_mtd(&ptr->chip));
2996 ++ nand_release(&ptr->chip);
2997 + }
2998 + }
2999 +
3000 +diff --git a/drivers/mtd/nand/sh_flctl.c b/drivers/mtd/nand/sh_flctl.c
3001 +index d6c013f93b8c..31f98acdba07 100644
3002 +--- a/drivers/mtd/nand/sh_flctl.c
3003 ++++ b/drivers/mtd/nand/sh_flctl.c
3004 +@@ -1229,7 +1229,7 @@ static int flctl_remove(struct platform_device *pdev)
3005 + struct sh_flctl *flctl = platform_get_drvdata(pdev);
3006 +
3007 + flctl_release_dma(flctl);
3008 +- nand_release(nand_to_mtd(&flctl->chip));
3009 ++ nand_release(&flctl->chip);
3010 + pm_runtime_disable(&pdev->dev);
3011 +
3012 + return 0;
3013 +diff --git a/drivers/mtd/nand/sharpsl.c b/drivers/mtd/nand/sharpsl.c
3014 +index 064ca1757589..661b4928e0fc 100644
3015 +--- a/drivers/mtd/nand/sharpsl.c
3016 ++++ b/drivers/mtd/nand/sharpsl.c
3017 +@@ -192,7 +192,7 @@ static int sharpsl_nand_probe(struct platform_device *pdev)
3018 + return 0;
3019 +
3020 + err_add:
3021 +- nand_release(mtd);
3022 ++ nand_cleanup(this);
3023 +
3024 + err_scan:
3025 + iounmap(sharpsl->io);
3026 +@@ -210,7 +210,7 @@ static int sharpsl_nand_remove(struct platform_device *pdev)
3027 + struct sharpsl_nand *sharpsl = platform_get_drvdata(pdev);
3028 +
3029 + /* Release resources, unregister device */
3030 +- nand_release(nand_to_mtd(&sharpsl->chip));
3031 ++ nand_release(&sharpsl->chip);
3032 +
3033 + iounmap(sharpsl->io);
3034 +
3035 +diff --git a/drivers/mtd/nand/socrates_nand.c b/drivers/mtd/nand/socrates_nand.c
3036 +index 888fd314c62a..957d9597c484 100644
3037 +--- a/drivers/mtd/nand/socrates_nand.c
3038 ++++ b/drivers/mtd/nand/socrates_nand.c
3039 +@@ -203,7 +203,7 @@ static int socrates_nand_probe(struct platform_device *ofdev)
3040 + if (!res)
3041 + return res;
3042 +
3043 +- nand_release(mtd);
3044 ++ nand_cleanup(nand_chip);
3045 +
3046 + out:
3047 + iounmap(host->io_base);
3048 +@@ -216,9 +216,8 @@ out:
3049 + static int socrates_nand_remove(struct platform_device *ofdev)
3050 + {
3051 + struct socrates_nand_host *host = dev_get_drvdata(&ofdev->dev);
3052 +- struct mtd_info *mtd = nand_to_mtd(&host->nand_chip);
3053 +
3054 +- nand_release(mtd);
3055 ++ nand_release(&host->nand_chip);
3056 +
3057 + iounmap(host->io_base);
3058 +
3059 +diff --git a/drivers/mtd/nand/sunxi_nand.c b/drivers/mtd/nand/sunxi_nand.c
3060 +index 886355bfa761..ddf3e24cc289 100644
3061 +--- a/drivers/mtd/nand/sunxi_nand.c
3062 ++++ b/drivers/mtd/nand/sunxi_nand.c
3063 +@@ -2108,7 +2108,7 @@ static int sunxi_nand_chip_init(struct device *dev, struct sunxi_nfc *nfc,
3064 + ret = mtd_device_register(mtd, NULL, 0);
3065 + if (ret) {
3066 + dev_err(dev, "failed to register mtd device: %d\n", ret);
3067 +- nand_release(mtd);
3068 ++ nand_release(nand);
3069 + return ret;
3070 + }
3071 +
3072 +@@ -2147,7 +2147,7 @@ static void sunxi_nand_chips_cleanup(struct sunxi_nfc *nfc)
3073 + while (!list_empty(&nfc->chips)) {
3074 + chip = list_first_entry(&nfc->chips, struct sunxi_nand_chip,
3075 + node);
3076 +- nand_release(nand_to_mtd(&chip->nand));
3077 ++ nand_release(&chip->nand);
3078 + sunxi_nand_ecc_cleanup(&chip->nand.ecc);
3079 + list_del(&chip->node);
3080 + }
3081 +diff --git a/drivers/mtd/nand/tmio_nand.c b/drivers/mtd/nand/tmio_nand.c
3082 +index 08b30549ec0a..d07c729f5b9b 100644
3083 +--- a/drivers/mtd/nand/tmio_nand.c
3084 ++++ b/drivers/mtd/nand/tmio_nand.c
3085 +@@ -446,7 +446,7 @@ static int tmio_probe(struct platform_device *dev)
3086 + if (!retval)
3087 + return retval;
3088 +
3089 +- nand_release(mtd);
3090 ++ nand_cleanup(nand_chip);
3091 +
3092 + err_irq:
3093 + tmio_hw_stop(dev, tmio);
3094 +@@ -457,7 +457,7 @@ static int tmio_remove(struct platform_device *dev)
3095 + {
3096 + struct tmio_nand *tmio = platform_get_drvdata(dev);
3097 +
3098 +- nand_release(nand_to_mtd(&tmio->chip));
3099 ++ nand_release(&tmio->chip);
3100 + tmio_hw_stop(dev, tmio);
3101 + return 0;
3102 + }
3103 +diff --git a/drivers/mtd/nand/txx9ndfmc.c b/drivers/mtd/nand/txx9ndfmc.c
3104 +index 0a14fda2e41b..f2ba55b0a1e9 100644
3105 +--- a/drivers/mtd/nand/txx9ndfmc.c
3106 ++++ b/drivers/mtd/nand/txx9ndfmc.c
3107 +@@ -390,7 +390,7 @@ static int __exit txx9ndfmc_remove(struct platform_device *dev)
3108 + chip = mtd_to_nand(mtd);
3109 + txx9_priv = nand_get_controller_data(chip);
3110 +
3111 +- nand_release(mtd);
3112 ++ nand_release(chip);
3113 + kfree(txx9_priv->mtdname);
3114 + kfree(txx9_priv);
3115 + }
3116 +diff --git a/drivers/mtd/nand/vf610_nfc.c b/drivers/mtd/nand/vf610_nfc.c
3117 +index ddc629e3f63a..ec004e0a94a3 100644
3118 +--- a/drivers/mtd/nand/vf610_nfc.c
3119 ++++ b/drivers/mtd/nand/vf610_nfc.c
3120 +@@ -795,7 +795,7 @@ static int vf610_nfc_remove(struct platform_device *pdev)
3121 + struct mtd_info *mtd = platform_get_drvdata(pdev);
3122 + struct vf610_nfc *nfc = mtd_to_nfc(mtd);
3123 +
3124 +- nand_release(mtd);
3125 ++ nand_release(mtd_to_nand(mtd));
3126 + clk_disable_unprepare(nfc->clk);
3127 + return 0;
3128 + }
3129 +diff --git a/drivers/mtd/nand/xway_nand.c b/drivers/mtd/nand/xway_nand.c
3130 +index 895101a5e686..3d51b8fc5aaf 100644
3131 +--- a/drivers/mtd/nand/xway_nand.c
3132 ++++ b/drivers/mtd/nand/xway_nand.c
3133 +@@ -211,7 +211,7 @@ static int xway_nand_probe(struct platform_device *pdev)
3134 +
3135 + err = mtd_device_register(mtd, NULL, 0);
3136 + if (err)
3137 +- nand_release(mtd);
3138 ++ nand_cleanup(&data->chip);
3139 +
3140 + return err;
3141 + }
3142 +@@ -223,7 +223,7 @@ static int xway_nand_remove(struct platform_device *pdev)
3143 + {
3144 + struct xway_nand_data *data = platform_get_drvdata(pdev);
3145 +
3146 +- nand_release(nand_to_mtd(&data->chip));
3147 ++ nand_release(&data->chip);
3148 +
3149 + return 0;
3150 + }
3151 +diff --git a/drivers/net/ethernet/atheros/alx/main.c b/drivers/net/ethernet/atheros/alx/main.c
3152 +index c0f84b73574d..2a5bb1012385 100644
3153 +--- a/drivers/net/ethernet/atheros/alx/main.c
3154 ++++ b/drivers/net/ethernet/atheros/alx/main.c
3155 +@@ -1056,8 +1056,12 @@ out_disable_adv_intr:
3156 +
3157 + static void __alx_stop(struct alx_priv *alx)
3158 + {
3159 +- alx_halt(alx);
3160 + alx_free_irq(alx);
3161 ++
3162 ++ cancel_work_sync(&alx->link_check_wk);
3163 ++ cancel_work_sync(&alx->reset_wk);
3164 ++
3165 ++ alx_halt(alx);
3166 + alx_free_rings(alx);
3167 + }
3168 +
3169 +@@ -1659,9 +1663,6 @@ static void alx_remove(struct pci_dev *pdev)
3170 + struct alx_priv *alx = pci_get_drvdata(pdev);
3171 + struct alx_hw *hw = &alx->hw;
3172 +
3173 +- cancel_work_sync(&alx->link_check_wk);
3174 +- cancel_work_sync(&alx->reset_wk);
3175 +-
3176 + /* restore permanent mac address */
3177 + alx_set_macaddr(hw, hw->perm_addr);
3178 +
3179 +diff --git a/drivers/net/ethernet/broadcom/tg3.c b/drivers/net/ethernet/broadcom/tg3.c
3180 +index c069a04a6e7e..5790b35064a8 100644
3181 +--- a/drivers/net/ethernet/broadcom/tg3.c
3182 ++++ b/drivers/net/ethernet/broadcom/tg3.c
3183 +@@ -18174,8 +18174,8 @@ static pci_ers_result_t tg3_io_error_detected(struct pci_dev *pdev,
3184 +
3185 + rtnl_lock();
3186 +
3187 +- /* We probably don't have netdev yet */
3188 +- if (!netdev || !netif_running(netdev))
3189 ++ /* Could be second call or maybe we don't have netdev yet */
3190 ++ if (!netdev || tp->pcierr_recovery || !netif_running(netdev))
3191 + goto done;
3192 +
3193 + /* We needn't recover from permanent error */
3194 +diff --git a/drivers/net/ethernet/intel/e1000e/netdev.c b/drivers/net/ethernet/intel/e1000e/netdev.c
3195 +index be324b4761eb..3c01bc43889a 100644
3196 +--- a/drivers/net/ethernet/intel/e1000e/netdev.c
3197 ++++ b/drivers/net/ethernet/intel/e1000e/netdev.c
3198 +@@ -6315,11 +6315,17 @@ static int __e1000_shutdown(struct pci_dev *pdev, bool runtime)
3199 + struct net_device *netdev = pci_get_drvdata(pdev);
3200 + struct e1000_adapter *adapter = netdev_priv(netdev);
3201 + struct e1000_hw *hw = &adapter->hw;
3202 +- u32 ctrl, ctrl_ext, rctl, status;
3203 +- /* Runtime suspend should only enable wakeup for link changes */
3204 +- u32 wufc = runtime ? E1000_WUFC_LNKC : adapter->wol;
3205 ++ u32 ctrl, ctrl_ext, rctl, status, wufc;
3206 + int retval = 0;
3207 +
3208 ++ /* Runtime suspend should only enable wakeup for link changes */
3209 ++ if (runtime)
3210 ++ wufc = E1000_WUFC_LNKC;
3211 ++ else if (device_may_wakeup(&pdev->dev))
3212 ++ wufc = adapter->wol;
3213 ++ else
3214 ++ wufc = 0;
3215 ++
3216 + status = er32(STATUS);
3217 + if (status & E1000_STATUS_LU)
3218 + wufc &= ~E1000_WUFC_LNKC;
3219 +@@ -6377,7 +6383,7 @@ static int __e1000_shutdown(struct pci_dev *pdev, bool runtime)
3220 + e1000e_igp3_phy_powerdown_workaround_ich8lan(&adapter->hw);
3221 + } else if ((hw->mac.type == e1000_pch_lpt) ||
3222 + (hw->mac.type == e1000_pch_spt)) {
3223 +- if (!(wufc & (E1000_WUFC_EX | E1000_WUFC_MC | E1000_WUFC_BC)))
3224 ++ if (wufc && !(wufc & (E1000_WUFC_EX | E1000_WUFC_MC | E1000_WUFC_BC)))
3225 + /* ULP does not support wake from unicast, multicast
3226 + * or broadcast.
3227 + */
3228 +diff --git a/drivers/net/ethernet/qlogic/qed/qed_cxt.c b/drivers/net/ethernet/qlogic/qed/qed_cxt.c
3229 +index f1956c4d02a0..d026da36e47e 100644
3230 +--- a/drivers/net/ethernet/qlogic/qed/qed_cxt.c
3231 ++++ b/drivers/net/ethernet/qlogic/qed/qed_cxt.c
3232 +@@ -339,7 +339,7 @@ static void qed_cxt_qm_iids(struct qed_hwfn *p_hwfn,
3233 + vf_tids += segs[NUM_TASK_PF_SEGMENTS].count;
3234 + }
3235 +
3236 +- iids->vf_cids += vf_cids * p_mngr->vf_count;
3237 ++ iids->vf_cids = vf_cids;
3238 + iids->tids += vf_tids * p_mngr->vf_count;
3239 +
3240 + DP_VERBOSE(p_hwfn, QED_MSG_ILT,
3241 +diff --git a/drivers/net/ethernet/qlogic/qed/qed_vf.c b/drivers/net/ethernet/qlogic/qed/qed_vf.c
3242 +index cf34908ec8e1..170243d3276b 100644
3243 +--- a/drivers/net/ethernet/qlogic/qed/qed_vf.c
3244 ++++ b/drivers/net/ethernet/qlogic/qed/qed_vf.c
3245 +@@ -57,12 +57,17 @@ static void qed_vf_pf_req_end(struct qed_hwfn *p_hwfn, int req_status)
3246 + mutex_unlock(&(p_hwfn->vf_iov_info->mutex));
3247 + }
3248 +
3249 ++#define QED_VF_CHANNEL_USLEEP_ITERATIONS 90
3250 ++#define QED_VF_CHANNEL_USLEEP_DELAY 100
3251 ++#define QED_VF_CHANNEL_MSLEEP_ITERATIONS 10
3252 ++#define QED_VF_CHANNEL_MSLEEP_DELAY 25
3253 ++
3254 + static int qed_send_msg2pf(struct qed_hwfn *p_hwfn, u8 *done, u32 resp_size)
3255 + {
3256 + union vfpf_tlvs *p_req = p_hwfn->vf_iov_info->vf2pf_request;
3257 + struct ustorm_trigger_vf_zone trigger;
3258 + struct ustorm_vf_zone *zone_data;
3259 +- int rc = 0, time = 100;
3260 ++ int iter, rc = 0;
3261 +
3262 + zone_data = (struct ustorm_vf_zone *)PXP_VF_BAR0_START_USDM_ZONE_B;
3263 +
3264 +@@ -102,11 +107,19 @@ static int qed_send_msg2pf(struct qed_hwfn *p_hwfn, u8 *done, u32 resp_size)
3265 + REG_WR(p_hwfn, (uintptr_t)&zone_data->trigger, *((u32 *)&trigger));
3266 +
3267 + /* When PF would be done with the response, it would write back to the
3268 +- * `done' address. Poll until then.
3269 ++ * `done' address from a coherent DMA zone. Poll until then.
3270 + */
3271 +- while ((!*done) && time) {
3272 +- msleep(25);
3273 +- time--;
3274 ++
3275 ++ iter = QED_VF_CHANNEL_USLEEP_ITERATIONS;
3276 ++ while (!*done && iter--) {
3277 ++ udelay(QED_VF_CHANNEL_USLEEP_DELAY);
3278 ++ dma_rmb();
3279 ++ }
3280 ++
3281 ++ iter = QED_VF_CHANNEL_MSLEEP_ITERATIONS;
3282 ++ while (!*done && iter--) {
3283 ++ msleep(QED_VF_CHANNEL_MSLEEP_DELAY);
3284 ++ dma_rmb();
3285 + }
3286 +
3287 + if (!*done) {
3288 +diff --git a/drivers/net/ethernet/rocker/rocker_main.c b/drivers/net/ethernet/rocker/rocker_main.c
3289 +index 24b746406bc7..4640e6c4aecf 100644
3290 +--- a/drivers/net/ethernet/rocker/rocker_main.c
3291 ++++ b/drivers/net/ethernet/rocker/rocker_main.c
3292 +@@ -648,10 +648,10 @@ static int rocker_dma_rings_init(struct rocker *rocker)
3293 + err_dma_event_ring_bufs_alloc:
3294 + rocker_dma_ring_destroy(rocker, &rocker->event_ring);
3295 + err_dma_event_ring_create:
3296 ++ rocker_dma_cmd_ring_waits_free(rocker);
3297 ++err_dma_cmd_ring_waits_alloc:
3298 + rocker_dma_ring_bufs_free(rocker, &rocker->cmd_ring,
3299 + PCI_DMA_BIDIRECTIONAL);
3300 +-err_dma_cmd_ring_waits_alloc:
3301 +- rocker_dma_cmd_ring_waits_free(rocker);
3302 + err_dma_cmd_ring_bufs_alloc:
3303 + rocker_dma_ring_destroy(rocker, &rocker->cmd_ring);
3304 + return err;
3305 +diff --git a/drivers/net/hamradio/yam.c b/drivers/net/hamradio/yam.c
3306 +index aaff07c10058..a453b82d1077 100644
3307 +--- a/drivers/net/hamradio/yam.c
3308 ++++ b/drivers/net/hamradio/yam.c
3309 +@@ -1160,6 +1160,7 @@ static int __init yam_init_driver(void)
3310 + err = register_netdev(dev);
3311 + if (err) {
3312 + printk(KERN_WARNING "yam: cannot register net device %s\n", dev->name);
3313 ++ free_netdev(dev);
3314 + goto error;
3315 + }
3316 + yam_devs[i] = dev;
3317 +diff --git a/drivers/net/usb/ax88179_178a.c b/drivers/net/usb/ax88179_178a.c
3318 +index 559af8e6ad90..0434ecf67712 100644
3319 +--- a/drivers/net/usb/ax88179_178a.c
3320 ++++ b/drivers/net/usb/ax88179_178a.c
3321 +@@ -1396,10 +1396,10 @@ static int ax88179_rx_fixup(struct usbnet *dev, struct sk_buff *skb)
3322 + }
3323 +
3324 + if (pkt_cnt == 0) {
3325 +- /* Skip IP alignment psudo header */
3326 +- skb_pull(skb, 2);
3327 + skb->len = pkt_len;
3328 +- skb_set_tail_pointer(skb, pkt_len);
3329 ++ /* Skip IP alignment pseudo header */
3330 ++ skb_pull(skb, 2);
3331 ++ skb_set_tail_pointer(skb, skb->len);
3332 + skb->truesize = pkt_len + sizeof(struct sk_buff);
3333 + ax88179_rx_checksum(skb, pkt_hdr);
3334 + return 1;
3335 +@@ -1408,8 +1408,9 @@ static int ax88179_rx_fixup(struct usbnet *dev, struct sk_buff *skb)
3336 + ax_skb = skb_clone(skb, GFP_ATOMIC);
3337 + if (ax_skb) {
3338 + ax_skb->len = pkt_len;
3339 +- ax_skb->data = skb->data + 2;
3340 +- skb_set_tail_pointer(ax_skb, pkt_len);
3341 ++ /* Skip IP alignment pseudo header */
3342 ++ skb_pull(ax_skb, 2);
3343 ++ skb_set_tail_pointer(ax_skb, ax_skb->len);
3344 + ax_skb->truesize = pkt_len + sizeof(struct sk_buff);
3345 + ax88179_rx_checksum(ax_skb, pkt_hdr);
3346 + usbnet_skb_return(dev, ax_skb);
3347 +diff --git a/drivers/pci/host/pci-aardvark.c b/drivers/pci/host/pci-aardvark.c
3348 +index 1dbd09c91a7c..736d9f58438e 100644
3349 +--- a/drivers/pci/host/pci-aardvark.c
3350 ++++ b/drivers/pci/host/pci-aardvark.c
3351 +@@ -363,10 +363,6 @@ static void advk_pcie_setup_hw(struct advk_pcie *pcie)
3352 +
3353 + advk_pcie_wait_for_link(pcie);
3354 +
3355 +- reg = PCIE_CORE_LINK_L0S_ENTRY |
3356 +- (1 << PCIE_CORE_LINK_WIDTH_SHIFT);
3357 +- advk_writel(pcie, reg, PCIE_CORE_LINK_CTRL_STAT_REG);
3358 +-
3359 + reg = advk_readl(pcie, PCIE_CORE_CMD_STATUS_REG);
3360 + reg |= PCIE_CORE_CMD_MEM_ACCESS_EN |
3361 + PCIE_CORE_CMD_IO_ACCESS_EN |
3362 +diff --git a/drivers/pci/host/pcie-rcar.c b/drivers/pci/host/pcie-rcar.c
3363 +index 7f6b454bca65..3ff423220df6 100644
3364 +--- a/drivers/pci/host/pcie-rcar.c
3365 ++++ b/drivers/pci/host/pcie-rcar.c
3366 +@@ -328,11 +328,12 @@ static struct pci_ops rcar_pcie_ops = {
3367 + };
3368 +
3369 + static void rcar_pcie_setup_window(int win, struct rcar_pcie *pcie,
3370 +- struct resource *res)
3371 ++ struct resource_entry *window)
3372 + {
3373 + /* Setup PCIe address space mappings for each resource */
3374 + resource_size_t size;
3375 + resource_size_t res_start;
3376 ++ struct resource *res = window->res;
3377 + u32 mask;
3378 +
3379 + rcar_pci_write_reg(pcie, 0x00000000, PCIEPTCTLR(win));
3380 +@@ -346,9 +347,9 @@ static void rcar_pcie_setup_window(int win, struct rcar_pcie *pcie,
3381 + rcar_pci_write_reg(pcie, mask << 7, PCIEPAMR(win));
3382 +
3383 + if (res->flags & IORESOURCE_IO)
3384 +- res_start = pci_pio_to_address(res->start);
3385 ++ res_start = pci_pio_to_address(res->start) - window->offset;
3386 + else
3387 +- res_start = res->start;
3388 ++ res_start = res->start - window->offset;
3389 +
3390 + rcar_pci_write_reg(pcie, upper_32_bits(res_start), PCIEPAUR(win));
3391 + rcar_pci_write_reg(pcie, lower_32_bits(res_start) & ~0x7F,
3392 +@@ -377,7 +378,7 @@ static int rcar_pcie_setup(struct list_head *resource, struct rcar_pcie *pci)
3393 + switch (resource_type(res)) {
3394 + case IORESOURCE_IO:
3395 + case IORESOURCE_MEM:
3396 +- rcar_pcie_setup_window(i, pci, res);
3397 ++ rcar_pcie_setup_window(i, pci, win);
3398 + i++;
3399 + break;
3400 + case IORESOURCE_BUS:
3401 +diff --git a/drivers/pci/pcie/aspm.c b/drivers/pci/pcie/aspm.c
3402 +index 4a5fde58974a..75551a781e88 100644
3403 +--- a/drivers/pci/pcie/aspm.c
3404 ++++ b/drivers/pci/pcie/aspm.c
3405 +@@ -410,16 +410,6 @@ static void pcie_aspm_cap_init(struct pcie_link_state *link, int blacklist)
3406 +
3407 + /* Setup initial capable state. Will be updated later */
3408 + link->aspm_capable = link->aspm_support;
3409 +- /*
3410 +- * If the downstream component has pci bridge function, don't
3411 +- * do ASPM for now.
3412 +- */
3413 +- list_for_each_entry(child, &linkbus->devices, bus_list) {
3414 +- if (pci_pcie_type(child) == PCI_EXP_TYPE_PCI_BRIDGE) {
3415 +- link->aspm_disable = ASPM_STATE_ALL;
3416 +- break;
3417 +- }
3418 +- }
3419 +
3420 + /* Get and check endpoint acceptable latencies */
3421 + list_for_each_entry(child, &linkbus->devices, bus_list) {
3422 +diff --git a/drivers/pci/pcie/ptm.c b/drivers/pci/pcie/ptm.c
3423 +index 3008bba360f3..ec6f6213960b 100644
3424 +--- a/drivers/pci/pcie/ptm.c
3425 ++++ b/drivers/pci/pcie/ptm.c
3426 +@@ -47,10 +47,6 @@ void pci_ptm_init(struct pci_dev *dev)
3427 + if (!pci_is_pcie(dev))
3428 + return;
3429 +
3430 +- pos = pci_find_ext_capability(dev, PCI_EXT_CAP_ID_PTM);
3431 +- if (!pos)
3432 +- return;
3433 +-
3434 + /*
3435 + * Enable PTM only on interior devices (root ports, switch ports,
3436 + * etc.) on the assumption that it causes no link traffic until an
3437 +@@ -60,6 +56,23 @@ void pci_ptm_init(struct pci_dev *dev)
3438 + pci_pcie_type(dev) == PCI_EXP_TYPE_RC_END))
3439 + return;
3440 +
3441 ++ /*
3442 ++ * Switch Downstream Ports are not permitted to have a PTM
3443 ++ * capability; their PTM behavior is controlled by the Upstream
3444 ++ * Port (PCIe r5.0, sec 7.9.16).
3445 ++ */
3446 ++ ups = pci_upstream_bridge(dev);
3447 ++ if (pci_pcie_type(dev) == PCI_EXP_TYPE_DOWNSTREAM &&
3448 ++ ups && ups->ptm_enabled) {
3449 ++ dev->ptm_granularity = ups->ptm_granularity;
3450 ++ dev->ptm_enabled = 1;
3451 ++ return;
3452 ++ }
3453 ++
3454 ++ pos = pci_find_ext_capability(dev, PCI_EXT_CAP_ID_PTM);
3455 ++ if (!pos)
3456 ++ return;
3457 ++
3458 + pci_read_config_dword(dev, pos + PCI_PTM_CAP, &cap);
3459 + local_clock = (cap & PCI_PTM_GRANULARITY_MASK) >> 8;
3460 +
3461 +@@ -69,7 +82,6 @@ void pci_ptm_init(struct pci_dev *dev)
3462 + * the spec recommendation (PCIe r3.1, sec 7.32.3), select the
3463 + * furthest upstream Time Source as the PTM Root.
3464 + */
3465 +- ups = pci_upstream_bridge(dev);
3466 + if (ups && ups->ptm_enabled) {
3467 + ctrl = PCI_PTM_CTRL_ENABLE;
3468 + if (ups->ptm_granularity == 0)
3469 +diff --git a/drivers/pinctrl/freescale/pinctrl-imx1-core.c b/drivers/pinctrl/freescale/pinctrl-imx1-core.c
3470 +index e2cca91fd266..68108c4c3969 100644
3471 +--- a/drivers/pinctrl/freescale/pinctrl-imx1-core.c
3472 ++++ b/drivers/pinctrl/freescale/pinctrl-imx1-core.c
3473 +@@ -642,7 +642,6 @@ int imx1_pinctrl_core_probe(struct platform_device *pdev,
3474 +
3475 + ret = of_platform_populate(pdev->dev.of_node, NULL, NULL, &pdev->dev);
3476 + if (ret) {
3477 +- pinctrl_unregister(ipctl->pctl);
3478 + dev_err(&pdev->dev, "Failed to populate subdevices\n");
3479 + return ret;
3480 + }
3481 +diff --git a/drivers/power/supply/Kconfig b/drivers/power/supply/Kconfig
3482 +index 76806a0be820..0de9a958b29a 100644
3483 +--- a/drivers/power/supply/Kconfig
3484 ++++ b/drivers/power/supply/Kconfig
3485 +@@ -424,7 +424,7 @@ config CHARGER_BQ24257
3486 + tristate "TI BQ24250/24251/24257 battery charger driver"
3487 + depends on I2C
3488 + depends on GPIOLIB || COMPILE_TEST
3489 +- depends on REGMAP_I2C
3490 ++ select REGMAP_I2C
3491 + help
3492 + Say Y to enable support for the TI BQ24250, BQ24251, and BQ24257 battery
3493 + chargers.
3494 +diff --git a/drivers/power/supply/lp8788-charger.c b/drivers/power/supply/lp8788-charger.c
3495 +index cd614fe69d14..c3075ea011b6 100644
3496 +--- a/drivers/power/supply/lp8788-charger.c
3497 ++++ b/drivers/power/supply/lp8788-charger.c
3498 +@@ -603,27 +603,14 @@ static void lp8788_setup_adc_channel(struct device *dev,
3499 + return;
3500 +
3501 + /* ADC channel for battery voltage */
3502 +- chan = iio_channel_get(dev, pdata->adc_vbatt);
3503 ++ chan = devm_iio_channel_get(dev, pdata->adc_vbatt);
3504 + pchg->chan[LP8788_VBATT] = IS_ERR(chan) ? NULL : chan;
3505 +
3506 + /* ADC channel for battery temperature */
3507 +- chan = iio_channel_get(dev, pdata->adc_batt_temp);
3508 ++ chan = devm_iio_channel_get(dev, pdata->adc_batt_temp);
3509 + pchg->chan[LP8788_BATT_TEMP] = IS_ERR(chan) ? NULL : chan;
3510 + }
3511 +
3512 +-static void lp8788_release_adc_channel(struct lp8788_charger *pchg)
3513 +-{
3514 +- int i;
3515 +-
3516 +- for (i = 0; i < LP8788_NUM_CHG_ADC; i++) {
3517 +- if (!pchg->chan[i])
3518 +- continue;
3519 +-
3520 +- iio_channel_release(pchg->chan[i]);
3521 +- pchg->chan[i] = NULL;
3522 +- }
3523 +-}
3524 +-
3525 + static ssize_t lp8788_show_charger_status(struct device *dev,
3526 + struct device_attribute *attr, char *buf)
3527 + {
3528 +@@ -744,7 +731,6 @@ static int lp8788_charger_remove(struct platform_device *pdev)
3529 + lp8788_irq_unregister(pdev, pchg);
3530 + sysfs_remove_group(&pdev->dev.kobj, &lp8788_attr_group);
3531 + lp8788_psy_unregister(pchg);
3532 +- lp8788_release_adc_channel(pchg);
3533 +
3534 + return 0;
3535 + }
3536 +diff --git a/drivers/power/supply/smb347-charger.c b/drivers/power/supply/smb347-charger.c
3537 +index 072c5189bd6d..0655dbdc7000 100644
3538 +--- a/drivers/power/supply/smb347-charger.c
3539 ++++ b/drivers/power/supply/smb347-charger.c
3540 +@@ -1141,6 +1141,7 @@ static bool smb347_volatile_reg(struct device *dev, unsigned int reg)
3541 + switch (reg) {
3542 + case IRQSTAT_A:
3543 + case IRQSTAT_C:
3544 ++ case IRQSTAT_D:
3545 + case IRQSTAT_E:
3546 + case IRQSTAT_F:
3547 + case STAT_A:
3548 +diff --git a/drivers/s390/cio/qdio.h b/drivers/s390/cio/qdio.h
3549 +index 7e70f9298cc1..11f6ebd04545 100644
3550 +--- a/drivers/s390/cio/qdio.h
3551 ++++ b/drivers/s390/cio/qdio.h
3552 +@@ -376,7 +376,6 @@ static inline int multicast_outbound(struct qdio_q *q)
3553 + extern u64 last_ai_time;
3554 +
3555 + /* prototypes for thin interrupt */
3556 +-void qdio_setup_thinint(struct qdio_irq *irq_ptr);
3557 + int qdio_establish_thinint(struct qdio_irq *irq_ptr);
3558 + void qdio_shutdown_thinint(struct qdio_irq *irq_ptr);
3559 + void tiqdio_add_input_queues(struct qdio_irq *irq_ptr);
3560 +diff --git a/drivers/s390/cio/qdio_setup.c b/drivers/s390/cio/qdio_setup.c
3561 +index d0090c5c88e7..a64615a10352 100644
3562 +--- a/drivers/s390/cio/qdio_setup.c
3563 ++++ b/drivers/s390/cio/qdio_setup.c
3564 +@@ -479,7 +479,6 @@ int qdio_setup_irq(struct qdio_initialize *init_data)
3565 + setup_queues(irq_ptr, init_data);
3566 +
3567 + setup_qib(irq_ptr, init_data);
3568 +- qdio_setup_thinint(irq_ptr);
3569 + set_impl_params(irq_ptr, init_data->qib_param_field_format,
3570 + init_data->qib_param_field,
3571 + init_data->input_slib_elements,
3572 +diff --git a/drivers/s390/cio/qdio_thinint.c b/drivers/s390/cio/qdio_thinint.c
3573 +index debe69adfc70..aecb6445a567 100644
3574 +--- a/drivers/s390/cio/qdio_thinint.c
3575 ++++ b/drivers/s390/cio/qdio_thinint.c
3576 +@@ -268,17 +268,19 @@ int __init tiqdio_register_thinints(void)
3577 +
3578 + int qdio_establish_thinint(struct qdio_irq *irq_ptr)
3579 + {
3580 ++ int rc;
3581 ++
3582 + if (!is_thinint_irq(irq_ptr))
3583 + return 0;
3584 +- return set_subchannel_ind(irq_ptr, 0);
3585 +-}
3586 +
3587 +-void qdio_setup_thinint(struct qdio_irq *irq_ptr)
3588 +-{
3589 +- if (!is_thinint_irq(irq_ptr))
3590 +- return;
3591 + irq_ptr->dsci = get_indicator();
3592 + DBF_HEX(&irq_ptr->dsci, sizeof(void *));
3593 ++
3594 ++ rc = set_subchannel_ind(irq_ptr, 0);
3595 ++ if (rc)
3596 ++ put_indicator(irq_ptr->dsci);
3597 ++
3598 ++ return rc;
3599 + }
3600 +
3601 + void qdio_shutdown_thinint(struct qdio_irq *irq_ptr)
3602 +diff --git a/drivers/scsi/arm/acornscsi.c b/drivers/scsi/arm/acornscsi.c
3603 +index 12b88294d667..76ad20e49126 100644
3604 +--- a/drivers/scsi/arm/acornscsi.c
3605 ++++ b/drivers/scsi/arm/acornscsi.c
3606 +@@ -2913,8 +2913,10 @@ static int acornscsi_probe(struct expansion_card *ec, const struct ecard_id *id)
3607 +
3608 + ashost->base = ecardm_iomap(ec, ECARD_RES_MEMC, 0, 0);
3609 + ashost->fast = ecardm_iomap(ec, ECARD_RES_IOCFAST, 0, 0);
3610 +- if (!ashost->base || !ashost->fast)
3611 ++ if (!ashost->base || !ashost->fast) {
3612 ++ ret = -ENOMEM;
3613 + goto out_put;
3614 ++ }
3615 +
3616 + host->irq = ec->irq;
3617 + ashost->host = host;
3618 +diff --git a/drivers/scsi/ibmvscsi/ibmvscsi.c b/drivers/scsi/ibmvscsi/ibmvscsi.c
3619 +index e1730227b448..f299839698a3 100644
3620 +--- a/drivers/scsi/ibmvscsi/ibmvscsi.c
3621 ++++ b/drivers/scsi/ibmvscsi/ibmvscsi.c
3622 +@@ -425,6 +425,8 @@ static int ibmvscsi_reenable_crq_queue(struct crq_queue *queue,
3623 + int rc = 0;
3624 + struct vio_dev *vdev = to_vio_dev(hostdata->dev);
3625 +
3626 ++ set_adapter_info(hostdata);
3627 ++
3628 + /* Re-enable the CRQ */
3629 + do {
3630 + if (rc)
3631 +diff --git a/drivers/scsi/iscsi_boot_sysfs.c b/drivers/scsi/iscsi_boot_sysfs.c
3632 +index d453667612f8..15d64f96e623 100644
3633 +--- a/drivers/scsi/iscsi_boot_sysfs.c
3634 ++++ b/drivers/scsi/iscsi_boot_sysfs.c
3635 +@@ -360,7 +360,7 @@ iscsi_boot_create_kobj(struct iscsi_boot_kset *boot_kset,
3636 + boot_kobj->kobj.kset = boot_kset->kset;
3637 + if (kobject_init_and_add(&boot_kobj->kobj, &iscsi_boot_ktype,
3638 + NULL, name, index)) {
3639 +- kfree(boot_kobj);
3640 ++ kobject_put(&boot_kobj->kobj);
3641 + return NULL;
3642 + }
3643 + boot_kobj->data = data;
3644 +diff --git a/drivers/scsi/lpfc/lpfc_els.c b/drivers/scsi/lpfc/lpfc_els.c
3645 +index 4901bf24916b..09dbf3021bb0 100644
3646 +--- a/drivers/scsi/lpfc/lpfc_els.c
3647 ++++ b/drivers/scsi/lpfc/lpfc_els.c
3648 +@@ -7606,6 +7606,8 @@ lpfc_els_unsol_buffer(struct lpfc_hba *phba, struct lpfc_sli_ring *pring,
3649 + spin_lock_irq(shost->host_lock);
3650 + if (ndlp->nlp_flag & NLP_IN_DEV_LOSS) {
3651 + spin_unlock_irq(shost->host_lock);
3652 ++ if (newnode)
3653 ++ lpfc_nlp_put(ndlp);
3654 + goto dropit;
3655 + }
3656 + spin_unlock_irq(shost->host_lock);
3657 +diff --git a/drivers/scsi/mpt3sas/mpt3sas_base.c b/drivers/scsi/mpt3sas/mpt3sas_base.c
3658 +index 6ccde2b41517..601a93953307 100644
3659 +--- a/drivers/scsi/mpt3sas/mpt3sas_base.c
3660 ++++ b/drivers/scsi/mpt3sas/mpt3sas_base.c
3661 +@@ -3166,7 +3166,9 @@ _base_release_memory_pools(struct MPT3SAS_ADAPTER *ioc)
3662 + ioc->scsi_lookup = NULL;
3663 + }
3664 + kfree(ioc->hpr_lookup);
3665 ++ ioc->hpr_lookup = NULL;
3666 + kfree(ioc->internal_lookup);
3667 ++ ioc->internal_lookup = NULL;
3668 + if (ioc->chain_lookup) {
3669 + for (i = 0; i < ioc->chain_depth; i++) {
3670 + if (ioc->chain_lookup[i].chain_buffer)
3671 +diff --git a/drivers/scsi/qla2xxx/tcm_qla2xxx.c b/drivers/scsi/qla2xxx/tcm_qla2xxx.c
3672 +index abdd6f93c8fe..324cddd4656e 100644
3673 +--- a/drivers/scsi/qla2xxx/tcm_qla2xxx.c
3674 ++++ b/drivers/scsi/qla2xxx/tcm_qla2xxx.c
3675 +@@ -855,6 +855,7 @@ static ssize_t tcm_qla2xxx_tpg_enable_store(struct config_item *item,
3676 +
3677 + atomic_set(&tpg->lport_tpg_enabled, 0);
3678 + qlt_stop_phase1(vha->vha_tgt.qla_tgt);
3679 ++ qlt_stop_phase2(vha->vha_tgt.qla_tgt);
3680 + }
3681 +
3682 + return count;
3683 +@@ -1019,6 +1020,7 @@ static ssize_t tcm_qla2xxx_npiv_tpg_enable_store(struct config_item *item,
3684 +
3685 + atomic_set(&tpg->lport_tpg_enabled, 0);
3686 + qlt_stop_phase1(vha->vha_tgt.qla_tgt);
3687 ++ qlt_stop_phase2(vha->vha_tgt.qla_tgt);
3688 + }
3689 +
3690 + return count;
3691 +diff --git a/drivers/scsi/scsi_devinfo.c b/drivers/scsi/scsi_devinfo.c
3692 +index d596b76eea64..aad9195b356a 100644
3693 +--- a/drivers/scsi/scsi_devinfo.c
3694 ++++ b/drivers/scsi/scsi_devinfo.c
3695 +@@ -451,7 +451,8 @@ static struct scsi_dev_info_list *scsi_dev_info_list_find(const char *vendor,
3696 + /*
3697 + * vendor strings must be an exact match
3698 + */
3699 +- if (vmax != strlen(devinfo->vendor) ||
3700 ++ if (vmax != strnlen(devinfo->vendor,
3701 ++ sizeof(devinfo->vendor)) ||
3702 + memcmp(devinfo->vendor, vskip, vmax))
3703 + continue;
3704 +
3705 +@@ -459,7 +460,7 @@ static struct scsi_dev_info_list *scsi_dev_info_list_find(const char *vendor,
3706 + * @model specifies the full string, and
3707 + * must be larger or equal to devinfo->model
3708 + */
3709 +- mlen = strlen(devinfo->model);
3710 ++ mlen = strnlen(devinfo->model, sizeof(devinfo->model));
3711 + if (mmax < mlen || memcmp(devinfo->model, mskip, mlen))
3712 + continue;
3713 + return devinfo;
3714 +diff --git a/drivers/scsi/sr.c b/drivers/scsi/sr.c
3715 +index cc484cb287d2..67a73ea0a615 100644
3716 +--- a/drivers/scsi/sr.c
3717 ++++ b/drivers/scsi/sr.c
3718 +@@ -745,7 +745,7 @@ static int sr_probe(struct device *dev)
3719 + cd->cdi.disk = disk;
3720 +
3721 + if (register_cdrom(&cd->cdi))
3722 +- goto fail_put;
3723 ++ goto fail_minor;
3724 +
3725 + /*
3726 + * Initialize block layer runtime PM stuffs before the
3727 +@@ -763,6 +763,10 @@ static int sr_probe(struct device *dev)
3728 +
3729 + return 0;
3730 +
3731 ++fail_minor:
3732 ++ spin_lock(&sr_index_lock);
3733 ++ clear_bit(minor, sr_index_bits);
3734 ++ spin_unlock(&sr_index_lock);
3735 + fail_put:
3736 + put_disk(disk);
3737 + fail_free:
3738 +diff --git a/drivers/staging/sm750fb/sm750.c b/drivers/staging/sm750fb/sm750.c
3739 +index 86ace1449309..ee54711cf8e8 100644
3740 +--- a/drivers/staging/sm750fb/sm750.c
3741 ++++ b/drivers/staging/sm750fb/sm750.c
3742 +@@ -897,6 +897,7 @@ static int lynxfb_set_fbinfo(struct fb_info *info, int index)
3743 + fix->visual = FB_VISUAL_PSEUDOCOLOR;
3744 + break;
3745 + case 16:
3746 ++ case 24:
3747 + case 32:
3748 + fix->visual = FB_VISUAL_TRUECOLOR;
3749 + break;
3750 +diff --git a/drivers/tty/n_gsm.c b/drivers/tty/n_gsm.c
3751 +index 9e9016e67843..1ab9bd433542 100644
3752 +--- a/drivers/tty/n_gsm.c
3753 ++++ b/drivers/tty/n_gsm.c
3754 +@@ -681,11 +681,10 @@ static struct gsm_msg *gsm_data_alloc(struct gsm_mux *gsm, u8 addr, int len,
3755 + * FIXME: lock against link layer control transmissions
3756 + */
3757 +
3758 +-static void gsm_data_kick(struct gsm_mux *gsm)
3759 ++static void gsm_data_kick(struct gsm_mux *gsm, struct gsm_dlci *dlci)
3760 + {
3761 + struct gsm_msg *msg, *nmsg;
3762 + int len;
3763 +- int skip_sof = 0;
3764 +
3765 + list_for_each_entry_safe(msg, nmsg, &gsm->tx_list, list) {
3766 + if (gsm->constipated && msg->addr)
3767 +@@ -707,18 +706,23 @@ static void gsm_data_kick(struct gsm_mux *gsm)
3768 + print_hex_dump_bytes("gsm_data_kick: ",
3769 + DUMP_PREFIX_OFFSET,
3770 + gsm->txframe, len);
3771 +-
3772 +- if (gsm->output(gsm, gsm->txframe + skip_sof,
3773 +- len - skip_sof) < 0)
3774 ++ if (gsm->output(gsm, gsm->txframe, len) < 0)
3775 + break;
3776 + /* FIXME: Can eliminate one SOF in many more cases */
3777 + gsm->tx_bytes -= msg->len;
3778 +- /* For a burst of frames skip the extra SOF within the
3779 +- burst */
3780 +- skip_sof = 1;
3781 +
3782 + list_del(&msg->list);
3783 + kfree(msg);
3784 ++
3785 ++ if (dlci) {
3786 ++ tty_port_tty_wakeup(&dlci->port);
3787 ++ } else {
3788 ++ int i = 0;
3789 ++
3790 ++ for (i = 0; i < NUM_DLCI; i++)
3791 ++ if (gsm->dlci[i])
3792 ++ tty_port_tty_wakeup(&gsm->dlci[i]->port);
3793 ++ }
3794 + }
3795 + }
3796 +
3797 +@@ -770,7 +774,7 @@ static void __gsm_data_queue(struct gsm_dlci *dlci, struct gsm_msg *msg)
3798 + /* Add to the actual output queue */
3799 + list_add_tail(&msg->list, &gsm->tx_list);
3800 + gsm->tx_bytes += msg->len;
3801 +- gsm_data_kick(gsm);
3802 ++ gsm_data_kick(gsm, dlci);
3803 + }
3804 +
3805 + /**
3806 +@@ -1231,7 +1235,7 @@ static void gsm_control_message(struct gsm_mux *gsm, unsigned int command,
3807 + gsm_control_reply(gsm, CMD_FCON, NULL, 0);
3808 + /* Kick the link in case it is idling */
3809 + spin_lock_irqsave(&gsm->tx_lock, flags);
3810 +- gsm_data_kick(gsm);
3811 ++ gsm_data_kick(gsm, NULL);
3812 + spin_unlock_irqrestore(&gsm->tx_lock, flags);
3813 + break;
3814 + case CMD_FCOFF:
3815 +@@ -2414,7 +2418,7 @@ static void gsmld_write_wakeup(struct tty_struct *tty)
3816 + /* Queue poll */
3817 + clear_bit(TTY_DO_WRITE_WAKEUP, &tty->flags);
3818 + spin_lock_irqsave(&gsm->tx_lock, flags);
3819 +- gsm_data_kick(gsm);
3820 ++ gsm_data_kick(gsm, NULL);
3821 + if (gsm->tx_bytes < TX_THRESH_LO) {
3822 + gsm_dlci_data_sweep(gsm);
3823 + }
3824 +diff --git a/drivers/tty/serial/amba-pl011.c b/drivers/tty/serial/amba-pl011.c
3825 +index f6586a8681b9..b3b9b3d2cddf 100644
3826 +--- a/drivers/tty/serial/amba-pl011.c
3827 ++++ b/drivers/tty/serial/amba-pl011.c
3828 +@@ -2524,6 +2524,7 @@ static int pl011_setup_port(struct device *dev, struct uart_amba_port *uap,
3829 + uap->port.fifosize = uap->fifosize;
3830 + uap->port.flags = UPF_BOOT_AUTOCONF;
3831 + uap->port.line = index;
3832 ++ spin_lock_init(&uap->port.lock);
3833 +
3834 + amba_ports[index] = uap;
3835 +
3836 +diff --git a/drivers/usb/class/cdc-acm.c b/drivers/usb/class/cdc-acm.c
3837 +index 5b0bffba4aac..2dc563b61b88 100644
3838 +--- a/drivers/usb/class/cdc-acm.c
3839 ++++ b/drivers/usb/class/cdc-acm.c
3840 +@@ -1627,6 +1627,8 @@ static int acm_reset_resume(struct usb_interface *intf)
3841 +
3842 + static const struct usb_device_id acm_ids[] = {
3843 + /* quirky and broken devices */
3844 ++ { USB_DEVICE(0x0424, 0x274e), /* Microchip Technology, Inc. (formerly SMSC) */
3845 ++ .driver_info = DISABLE_ECHO, }, /* DISABLE ECHO in termios flag */
3846 + { USB_DEVICE(0x076d, 0x0006), /* Denso Cradle CU-321 */
3847 + .driver_info = NO_UNION_NORMAL, },/* has no union descriptor */
3848 + { USB_DEVICE(0x17ef, 0x7000), /* Lenovo USB modem */
3849 +diff --git a/drivers/usb/class/usblp.c b/drivers/usb/class/usblp.c
3850 +index 07c3c3449147..c578d64edc15 100644
3851 +--- a/drivers/usb/class/usblp.c
3852 ++++ b/drivers/usb/class/usblp.c
3853 +@@ -481,7 +481,8 @@ static int usblp_release(struct inode *inode, struct file *file)
3854 + usb_autopm_put_interface(usblp->intf);
3855 +
3856 + if (!usblp->present) /* finish cleanup from disconnect */
3857 +- usblp_cleanup(usblp);
3858 ++ usblp_cleanup(usblp); /* any URBs must be dead */
3859 ++
3860 + mutex_unlock(&usblp_mutex);
3861 + return 0;
3862 + }
3863 +@@ -1397,9 +1398,11 @@ static void usblp_disconnect(struct usb_interface *intf)
3864 +
3865 + usblp_unlink_urbs(usblp);
3866 + mutex_unlock(&usblp->mut);
3867 ++ usb_poison_anchored_urbs(&usblp->urbs);
3868 +
3869 + if (!usblp->used)
3870 + usblp_cleanup(usblp);
3871 ++
3872 + mutex_unlock(&usblp_mutex);
3873 + }
3874 +
3875 +diff --git a/drivers/usb/core/quirks.c b/drivers/usb/core/quirks.c
3876 +index 27d05f0134de..e6e0f786547b 100644
3877 +--- a/drivers/usb/core/quirks.c
3878 ++++ b/drivers/usb/core/quirks.c
3879 +@@ -73,11 +73,12 @@ static const struct usb_device_id usb_quirk_list[] = {
3880 + /* Logitech HD Webcam C270 */
3881 + { USB_DEVICE(0x046d, 0x0825), .driver_info = USB_QUIRK_RESET_RESUME },
3882 +
3883 +- /* Logitech HD Pro Webcams C920, C920-C, C925e and C930e */
3884 ++ /* Logitech HD Pro Webcams C920, C920-C, C922, C925e and C930e */
3885 + { USB_DEVICE(0x046d, 0x082d), .driver_info = USB_QUIRK_DELAY_INIT },
3886 + { USB_DEVICE(0x046d, 0x0841), .driver_info = USB_QUIRK_DELAY_INIT },
3887 + { USB_DEVICE(0x046d, 0x0843), .driver_info = USB_QUIRK_DELAY_INIT },
3888 + { USB_DEVICE(0x046d, 0x085b), .driver_info = USB_QUIRK_DELAY_INIT },
3889 ++ { USB_DEVICE(0x046d, 0x085c), .driver_info = USB_QUIRK_DELAY_INIT },
3890 +
3891 + /* Logitech ConferenceCam CC3000e */
3892 + { USB_DEVICE(0x046d, 0x0847), .driver_info = USB_QUIRK_DELAY_INIT },
3893 +diff --git a/drivers/usb/dwc2/core_intr.c b/drivers/usb/dwc2/core_intr.c
3894 +index d85c5c9f96c1..f046703f63f2 100644
3895 +--- a/drivers/usb/dwc2/core_intr.c
3896 ++++ b/drivers/usb/dwc2/core_intr.c
3897 +@@ -365,10 +365,13 @@ static void dwc2_handle_wakeup_detected_intr(struct dwc2_hsotg *hsotg)
3898 + if (ret && (ret != -ENOTSUPP))
3899 + dev_err(hsotg->dev, "exit hibernation failed\n");
3900 +
3901 ++ /* Change to L0 state */
3902 ++ hsotg->lx_state = DWC2_L0;
3903 + call_gadget(hsotg, resume);
3904 ++ } else {
3905 ++ /* Change to L0 state */
3906 ++ hsotg->lx_state = DWC2_L0;
3907 + }
3908 +- /* Change to L0 state */
3909 +- hsotg->lx_state = DWC2_L0;
3910 + } else {
3911 + if (hsotg->core_params->hibernation)
3912 + return;
3913 +diff --git a/drivers/usb/dwc2/gadget.c b/drivers/usb/dwc2/gadget.c
3914 +index 3ae27b6ed07c..9381a108a985 100644
3915 +--- a/drivers/usb/dwc2/gadget.c
3916 ++++ b/drivers/usb/dwc2/gadget.c
3917 +@@ -3947,12 +3947,6 @@ int dwc2_gadget_init(struct dwc2_hsotg *hsotg, int irq)
3918 + epnum, 0);
3919 + }
3920 +
3921 +- ret = usb_add_gadget_udc(dev, &hsotg->gadget);
3922 +- if (ret) {
3923 +- dwc2_hsotg_ep_free_request(&hsotg->eps_out[0]->ep,
3924 +- hsotg->ctrl_req);
3925 +- return ret;
3926 +- }
3927 + dwc2_hsotg_dump(hsotg);
3928 +
3929 + return 0;
3930 +diff --git a/drivers/usb/dwc2/platform.c b/drivers/usb/dwc2/platform.c
3931 +index 8e1728b39a49..63178ed7f650 100644
3932 +--- a/drivers/usb/dwc2/platform.c
3933 ++++ b/drivers/usb/dwc2/platform.c
3934 +@@ -661,6 +661,17 @@ static int dwc2_driver_probe(struct platform_device *dev)
3935 + if (hsotg->dr_mode == USB_DR_MODE_PERIPHERAL)
3936 + dwc2_lowlevel_hw_disable(hsotg);
3937 +
3938 ++#if IS_ENABLED(CONFIG_USB_DWC2_PERIPHERAL) || \
3939 ++ IS_ENABLED(CONFIG_USB_DWC2_DUAL_ROLE)
3940 ++ /* Postponed adding a new gadget to the udc class driver list */
3941 ++ if (hsotg->gadget_enabled) {
3942 ++ retval = usb_add_gadget_udc(hsotg->dev, &hsotg->gadget);
3943 ++ if (retval) {
3944 ++ dwc2_hsotg_remove(hsotg);
3945 ++ goto error;
3946 ++ }
3947 ++ }
3948 ++#endif /* CONFIG_USB_DWC2_PERIPHERAL || CONFIG_USB_DWC2_DUAL_ROLE */
3949 + return 0;
3950 +
3951 + error:
3952 +diff --git a/drivers/usb/gadget/composite.c b/drivers/usb/gadget/composite.c
3953 +index 2e545d025030..5a1723d99fe5 100644
3954 +--- a/drivers/usb/gadget/composite.c
3955 ++++ b/drivers/usb/gadget/composite.c
3956 +@@ -100,40 +100,43 @@ function_descriptors(struct usb_function *f,
3957 + }
3958 +
3959 + /**
3960 +- * next_ep_desc() - advance to the next EP descriptor
3961 ++ * next_desc() - advance to the next desc_type descriptor
3962 + * @t: currect pointer within descriptor array
3963 ++ * @desc_type: descriptor type
3964 + *
3965 +- * Return: next EP descriptor or NULL
3966 ++ * Return: next desc_type descriptor or NULL
3967 + *
3968 +- * Iterate over @t until either EP descriptor found or
3969 ++ * Iterate over @t until either desc_type descriptor found or
3970 + * NULL (that indicates end of list) encountered
3971 + */
3972 + static struct usb_descriptor_header**
3973 +-next_ep_desc(struct usb_descriptor_header **t)
3974 ++next_desc(struct usb_descriptor_header **t, u8 desc_type)
3975 + {
3976 + for (; *t; t++) {
3977 +- if ((*t)->bDescriptorType == USB_DT_ENDPOINT)
3978 ++ if ((*t)->bDescriptorType == desc_type)
3979 + return t;
3980 + }
3981 + return NULL;
3982 + }
3983 +
3984 + /*
3985 +- * for_each_ep_desc()- iterate over endpoint descriptors in the
3986 +- * descriptors list
3987 +- * @start: pointer within descriptor array.
3988 +- * @ep_desc: endpoint descriptor to use as the loop cursor
3989 ++ * for_each_desc() - iterate over desc_type descriptors in the
3990 ++ * descriptors list
3991 ++ * @start: pointer within descriptor array.
3992 ++ * @iter_desc: desc_type descriptor to use as the loop cursor
3993 ++ * @desc_type: wanted descriptr type
3994 + */
3995 +-#define for_each_ep_desc(start, ep_desc) \
3996 +- for (ep_desc = next_ep_desc(start); \
3997 +- ep_desc; ep_desc = next_ep_desc(ep_desc+1))
3998 ++#define for_each_desc(start, iter_desc, desc_type) \
3999 ++ for (iter_desc = next_desc(start, desc_type); \
4000 ++ iter_desc; iter_desc = next_desc(iter_desc + 1, desc_type))
4001 +
4002 + /**
4003 +- * config_ep_by_speed() - configures the given endpoint
4004 ++ * config_ep_by_speed_and_alt() - configures the given endpoint
4005 + * according to gadget speed.
4006 + * @g: pointer to the gadget
4007 + * @f: usb function
4008 + * @_ep: the endpoint to configure
4009 ++ * @alt: alternate setting number
4010 + *
4011 + * Return: error code, 0 on success
4012 + *
4013 +@@ -146,11 +149,13 @@ next_ep_desc(struct usb_descriptor_header **t)
4014 + * Note: the supplied function should hold all the descriptors
4015 + * for supported speeds
4016 + */
4017 +-int config_ep_by_speed(struct usb_gadget *g,
4018 +- struct usb_function *f,
4019 +- struct usb_ep *_ep)
4020 ++int config_ep_by_speed_and_alt(struct usb_gadget *g,
4021 ++ struct usb_function *f,
4022 ++ struct usb_ep *_ep,
4023 ++ u8 alt)
4024 + {
4025 + struct usb_endpoint_descriptor *chosen_desc = NULL;
4026 ++ struct usb_interface_descriptor *int_desc = NULL;
4027 + struct usb_descriptor_header **speed_desc = NULL;
4028 +
4029 + struct usb_ss_ep_comp_descriptor *comp_desc = NULL;
4030 +@@ -186,8 +191,21 @@ int config_ep_by_speed(struct usb_gadget *g,
4031 + default:
4032 + speed_desc = f->fs_descriptors;
4033 + }
4034 ++
4035 ++ /* find correct alternate setting descriptor */
4036 ++ for_each_desc(speed_desc, d_spd, USB_DT_INTERFACE) {
4037 ++ int_desc = (struct usb_interface_descriptor *)*d_spd;
4038 ++
4039 ++ if (int_desc->bAlternateSetting == alt) {
4040 ++ speed_desc = d_spd;
4041 ++ goto intf_found;
4042 ++ }
4043 ++ }
4044 ++ return -EIO;
4045 ++
4046 ++intf_found:
4047 + /* find descriptors */
4048 +- for_each_ep_desc(speed_desc, d_spd) {
4049 ++ for_each_desc(speed_desc, d_spd, USB_DT_ENDPOINT) {
4050 + chosen_desc = (struct usb_endpoint_descriptor *)*d_spd;
4051 + if (chosen_desc->bEndpointAddress == _ep->address)
4052 + goto ep_found;
4053 +@@ -240,6 +258,32 @@ ep_found:
4054 + }
4055 + return 0;
4056 + }
4057 ++EXPORT_SYMBOL_GPL(config_ep_by_speed_and_alt);
4058 ++
4059 ++/**
4060 ++ * config_ep_by_speed() - configures the given endpoint
4061 ++ * according to gadget speed.
4062 ++ * @g: pointer to the gadget
4063 ++ * @f: usb function
4064 ++ * @_ep: the endpoint to configure
4065 ++ *
4066 ++ * Return: error code, 0 on success
4067 ++ *
4068 ++ * This function chooses the right descriptors for a given
4069 ++ * endpoint according to gadget speed and saves it in the
4070 ++ * endpoint desc field. If the endpoint already has a descriptor
4071 ++ * assigned to it - overwrites it with currently corresponding
4072 ++ * descriptor. The endpoint maxpacket field is updated according
4073 ++ * to the chosen descriptor.
4074 ++ * Note: the supplied function should hold all the descriptors
4075 ++ * for supported speeds
4076 ++ */
4077 ++int config_ep_by_speed(struct usb_gadget *g,
4078 ++ struct usb_function *f,
4079 ++ struct usb_ep *_ep)
4080 ++{
4081 ++ return config_ep_by_speed_and_alt(g, f, _ep, 0);
4082 ++}
4083 + EXPORT_SYMBOL_GPL(config_ep_by_speed);
4084 +
4085 + /**
4086 +diff --git a/drivers/usb/gadget/udc/lpc32xx_udc.c b/drivers/usb/gadget/udc/lpc32xx_udc.c
4087 +index ac2aa04ca657..710793161795 100644
4088 +--- a/drivers/usb/gadget/udc/lpc32xx_udc.c
4089 ++++ b/drivers/usb/gadget/udc/lpc32xx_udc.c
4090 +@@ -1615,17 +1615,17 @@ static int lpc32xx_ep_enable(struct usb_ep *_ep,
4091 + const struct usb_endpoint_descriptor *desc)
4092 + {
4093 + struct lpc32xx_ep *ep = container_of(_ep, struct lpc32xx_ep, ep);
4094 +- struct lpc32xx_udc *udc = ep->udc;
4095 ++ struct lpc32xx_udc *udc;
4096 + u16 maxpacket;
4097 + u32 tmp;
4098 + unsigned long flags;
4099 +
4100 + /* Verify EP data */
4101 + if ((!_ep) || (!ep) || (!desc) ||
4102 +- (desc->bDescriptorType != USB_DT_ENDPOINT)) {
4103 +- dev_dbg(udc->dev, "bad ep or descriptor\n");
4104 ++ (desc->bDescriptorType != USB_DT_ENDPOINT))
4105 + return -EINVAL;
4106 +- }
4107 ++
4108 ++ udc = ep->udc;
4109 + maxpacket = usb_endpoint_maxp(desc);
4110 + if ((maxpacket == 0) || (maxpacket > ep->maxpacket)) {
4111 + dev_dbg(udc->dev, "bad ep descriptor's packet size\n");
4112 +@@ -1873,7 +1873,7 @@ static int lpc32xx_ep_dequeue(struct usb_ep *_ep, struct usb_request *_req)
4113 + static int lpc32xx_ep_set_halt(struct usb_ep *_ep, int value)
4114 + {
4115 + struct lpc32xx_ep *ep = container_of(_ep, struct lpc32xx_ep, ep);
4116 +- struct lpc32xx_udc *udc = ep->udc;
4117 ++ struct lpc32xx_udc *udc;
4118 + unsigned long flags;
4119 +
4120 + if ((!ep) || (ep->hwep_num <= 1))
4121 +@@ -1883,6 +1883,7 @@ static int lpc32xx_ep_set_halt(struct usb_ep *_ep, int value)
4122 + if (ep->is_in)
4123 + return -EAGAIN;
4124 +
4125 ++ udc = ep->udc;
4126 + spin_lock_irqsave(&udc->lock, flags);
4127 +
4128 + if (value == 1) {
4129 +diff --git a/drivers/usb/gadget/udc/m66592-udc.c b/drivers/usb/gadget/udc/m66592-udc.c
4130 +index 6e977dc22570..1be409644a48 100644
4131 +--- a/drivers/usb/gadget/udc/m66592-udc.c
4132 ++++ b/drivers/usb/gadget/udc/m66592-udc.c
4133 +@@ -1672,7 +1672,7 @@ static int m66592_probe(struct platform_device *pdev)
4134 +
4135 + err_add_udc:
4136 + m66592_free_request(&m66592->ep[0].ep, m66592->ep0_req);
4137 +-
4138 ++ m66592->ep0_req = NULL;
4139 + clean_up3:
4140 + if (m66592->pdata->on_chip) {
4141 + clk_disable(m66592->clk);
4142 +diff --git a/drivers/usb/gadget/udc/mv_udc_core.c b/drivers/usb/gadget/udc/mv_udc_core.c
4143 +index ce73b3552269..8700db903382 100644
4144 +--- a/drivers/usb/gadget/udc/mv_udc_core.c
4145 ++++ b/drivers/usb/gadget/udc/mv_udc_core.c
4146 +@@ -2317,7 +2317,8 @@ static int mv_udc_probe(struct platform_device *pdev)
4147 + return 0;
4148 +
4149 + err_create_workqueue:
4150 +- destroy_workqueue(udc->qwork);
4151 ++ if (udc->qwork)
4152 ++ destroy_workqueue(udc->qwork);
4153 + err_destroy_dma:
4154 + dma_pool_destroy(udc->dtd_pool);
4155 + err_free_dma:
4156 +diff --git a/drivers/usb/gadget/udc/s3c2410_udc.c b/drivers/usb/gadget/udc/s3c2410_udc.c
4157 +index eb3571ee59e3..08153a48704b 100644
4158 +--- a/drivers/usb/gadget/udc/s3c2410_udc.c
4159 ++++ b/drivers/usb/gadget/udc/s3c2410_udc.c
4160 +@@ -269,10 +269,6 @@ static void s3c2410_udc_done(struct s3c2410_ep *ep,
4161 + static void s3c2410_udc_nuke(struct s3c2410_udc *udc,
4162 + struct s3c2410_ep *ep, int status)
4163 + {
4164 +- /* Sanity check */
4165 +- if (&ep->queue == NULL)
4166 +- return;
4167 +-
4168 + while (!list_empty(&ep->queue)) {
4169 + struct s3c2410_request *req;
4170 + req = list_entry(ep->queue.next, struct s3c2410_request,
4171 +diff --git a/drivers/usb/host/ehci-exynos.c b/drivers/usb/host/ehci-exynos.c
4172 +index 7a603f66a9bc..44b7c3e780f6 100644
4173 +--- a/drivers/usb/host/ehci-exynos.c
4174 ++++ b/drivers/usb/host/ehci-exynos.c
4175 +@@ -199,9 +199,8 @@ skip_phy:
4176 + hcd->rsrc_len = resource_size(res);
4177 +
4178 + irq = platform_get_irq(pdev, 0);
4179 +- if (!irq) {
4180 +- dev_err(&pdev->dev, "Failed to get IRQ\n");
4181 +- err = -ENODEV;
4182 ++ if (irq < 0) {
4183 ++ err = irq;
4184 + goto fail_io;
4185 + }
4186 +
4187 +diff --git a/drivers/usb/host/ehci-mxc.c b/drivers/usb/host/ehci-mxc.c
4188 +index c7a9b31eeaef..637079a35003 100644
4189 +--- a/drivers/usb/host/ehci-mxc.c
4190 ++++ b/drivers/usb/host/ehci-mxc.c
4191 +@@ -63,6 +63,8 @@ static int ehci_mxc_drv_probe(struct platform_device *pdev)
4192 + }
4193 +
4194 + irq = platform_get_irq(pdev, 0);
4195 ++ if (irq < 0)
4196 ++ return irq;
4197 +
4198 + hcd = usb_create_hcd(&ehci_mxc_hc_driver, dev, dev_name(dev));
4199 + if (!hcd)
4200 +diff --git a/drivers/usb/host/ehci-pci.c b/drivers/usb/host/ehci-pci.c
4201 +index 3b3649d88c5f..08b3f8c80601 100644
4202 +--- a/drivers/usb/host/ehci-pci.c
4203 ++++ b/drivers/usb/host/ehci-pci.c
4204 +@@ -229,6 +229,13 @@ static int ehci_pci_setup(struct usb_hcd *hcd)
4205 + ehci_info(ehci, "applying MosChip frame-index workaround\n");
4206 + ehci->frame_index_bug = 1;
4207 + break;
4208 ++ case PCI_VENDOR_ID_HUAWEI:
4209 ++ /* Synopsys HC bug */
4210 ++ if (pdev->device == 0xa239) {
4211 ++ ehci_info(ehci, "applying Synopsys HC workaround\n");
4212 ++ ehci->has_synopsys_hc_bug = 1;
4213 ++ }
4214 ++ break;
4215 + }
4216 +
4217 + /* optional debug port, normally in the first BAR */
4218 +diff --git a/drivers/usb/host/ehci-platform.c b/drivers/usb/host/ehci-platform.c
4219 +index a268d9e8d6cf..1b141e9299f9 100644
4220 +--- a/drivers/usb/host/ehci-platform.c
4221 ++++ b/drivers/usb/host/ehci-platform.c
4222 +@@ -378,6 +378,11 @@ static int ehci_platform_resume(struct device *dev)
4223 + }
4224 +
4225 + ehci_resume(hcd, priv->reset_on_resume);
4226 ++
4227 ++ pm_runtime_disable(dev);
4228 ++ pm_runtime_set_active(dev);
4229 ++ pm_runtime_enable(dev);
4230 ++
4231 + return 0;
4232 + }
4233 + #endif /* CONFIG_PM_SLEEP */
4234 +diff --git a/drivers/usb/host/ohci-platform.c b/drivers/usb/host/ohci-platform.c
4235 +index 898b74086c12..9e3fdb1421f7 100644
4236 +--- a/drivers/usb/host/ohci-platform.c
4237 ++++ b/drivers/usb/host/ohci-platform.c
4238 +@@ -340,6 +340,11 @@ static int ohci_platform_resume(struct device *dev)
4239 + }
4240 +
4241 + ohci_resume(hcd, false);
4242 ++
4243 ++ pm_runtime_disable(dev);
4244 ++ pm_runtime_set_active(dev);
4245 ++ pm_runtime_enable(dev);
4246 ++
4247 + return 0;
4248 + }
4249 + #endif /* CONFIG_PM_SLEEP */
4250 +diff --git a/drivers/usb/host/ohci-sm501.c b/drivers/usb/host/ohci-sm501.c
4251 +index a8b8d8b8d9f3..a960d2bb8dd1 100644
4252 +--- a/drivers/usb/host/ohci-sm501.c
4253 ++++ b/drivers/usb/host/ohci-sm501.c
4254 +@@ -196,6 +196,7 @@ static int ohci_hcd_sm501_drv_remove(struct platform_device *pdev)
4255 + struct resource *mem;
4256 +
4257 + usb_remove_hcd(hcd);
4258 ++ iounmap(hcd->regs);
4259 + release_mem_region(hcd->rsrc_start, hcd->rsrc_len);
4260 + usb_put_hcd(hcd);
4261 + dma_release_declared_memory(&pdev->dev);
4262 +diff --git a/drivers/usb/host/xhci-plat.c b/drivers/usb/host/xhci-plat.c
4263 +index 781283a5138e..169d7b2feb1f 100644
4264 +--- a/drivers/usb/host/xhci-plat.c
4265 ++++ b/drivers/usb/host/xhci-plat.c
4266 +@@ -313,8 +313,17 @@ static int xhci_plat_resume(struct device *dev)
4267 + {
4268 + struct usb_hcd *hcd = dev_get_drvdata(dev);
4269 + struct xhci_hcd *xhci = hcd_to_xhci(hcd);
4270 ++ int ret;
4271 ++
4272 ++ ret = xhci_resume(xhci, 0);
4273 ++ if (ret)
4274 ++ return ret;
4275 ++
4276 ++ pm_runtime_disable(dev);
4277 ++ pm_runtime_set_active(dev);
4278 ++ pm_runtime_enable(dev);
4279 +
4280 +- return xhci_resume(xhci, 0);
4281 ++ return 0;
4282 + }
4283 +
4284 + static const struct dev_pm_ops xhci_plat_pm_ops = {
4285 +diff --git a/drivers/usb/host/xhci.c b/drivers/usb/host/xhci.c
4286 +index baacc442ec6a..b27987431079 100644
4287 +--- a/drivers/usb/host/xhci.c
4288 ++++ b/drivers/usb/host/xhci.c
4289 +@@ -1347,6 +1347,7 @@ static int xhci_check_maxpacket(struct xhci_hcd *xhci, unsigned int slot_id,
4290 + xhci->devs[slot_id]->out_ctx, ep_index);
4291 +
4292 + ep_ctx = xhci_get_ep_ctx(xhci, command->in_ctx, ep_index);
4293 ++ ep_ctx->ep_info &= cpu_to_le32(~EP_STATE_MASK);/* must clear */
4294 + ep_ctx->ep_info2 &= cpu_to_le32(~MAX_PACKET_MASK);
4295 + ep_ctx->ep_info2 |= cpu_to_le32(MAX_PACKET(max_packet_size));
4296 +
4297 +@@ -4244,6 +4245,9 @@ int xhci_set_usb2_hardware_lpm(struct usb_hcd *hcd,
4298 + mutex_lock(hcd->bandwidth_mutex);
4299 + xhci_change_max_exit_latency(xhci, udev, 0);
4300 + mutex_unlock(hcd->bandwidth_mutex);
4301 ++ readl_poll_timeout(port_array[port_num], pm_val,
4302 ++ (pm_val & PORT_PLS_MASK) == XDEV_U0,
4303 ++ 100, 10000);
4304 + return 0;
4305 + }
4306 + }
4307 +diff --git a/drivers/usb/host/xhci.h b/drivers/usb/host/xhci.h
4308 +index 2b603ef5c10c..2b8df83dad38 100644
4309 +--- a/drivers/usb/host/xhci.h
4310 ++++ b/drivers/usb/host/xhci.h
4311 +@@ -709,7 +709,7 @@ struct xhci_ep_ctx {
4312 + * 4 - TRB error
4313 + * 5-7 - reserved
4314 + */
4315 +-#define EP_STATE_MASK (0xf)
4316 ++#define EP_STATE_MASK (0x7)
4317 + #define EP_STATE_DISABLED 0
4318 + #define EP_STATE_RUNNING 1
4319 + #define EP_STATE_HALTED 2
4320 +diff --git a/drivers/vfio/pci/vfio_pci_config.c b/drivers/vfio/pci/vfio_pci_config.c
4321 +index 84905d074c4f..ef45b8f5bf51 100644
4322 +--- a/drivers/vfio/pci/vfio_pci_config.c
4323 ++++ b/drivers/vfio/pci/vfio_pci_config.c
4324 +@@ -1461,7 +1461,12 @@ static int vfio_cap_init(struct vfio_pci_device *vdev)
4325 + if (ret)
4326 + return ret;
4327 +
4328 +- if (cap <= PCI_CAP_ID_MAX) {
4329 ++ /*
4330 ++ * ID 0 is a NULL capability, conflicting with our fake
4331 ++ * PCI_CAP_ID_BASIC. As it has no content, consider it
4332 ++ * hidden for now.
4333 ++ */
4334 ++ if (cap && cap <= PCI_CAP_ID_MAX) {
4335 + len = pci_cap_length[cap];
4336 + if (len == 0xFF) { /* Variable length */
4337 + len = vfio_cap_len(vdev, cap, pos);
4338 +@@ -1729,8 +1734,11 @@ void vfio_config_free(struct vfio_pci_device *vdev)
4339 + vdev->vconfig = NULL;
4340 + kfree(vdev->pci_config_map);
4341 + vdev->pci_config_map = NULL;
4342 +- kfree(vdev->msi_perm);
4343 +- vdev->msi_perm = NULL;
4344 ++ if (vdev->msi_perm) {
4345 ++ free_perm_bits(vdev->msi_perm);
4346 ++ kfree(vdev->msi_perm);
4347 ++ vdev->msi_perm = NULL;
4348 ++ }
4349 + }
4350 +
4351 + /*
4352 +diff --git a/drivers/video/backlight/lp855x_bl.c b/drivers/video/backlight/lp855x_bl.c
4353 +index 939f057836e1..4cdc7a3f6dc5 100644
4354 +--- a/drivers/video/backlight/lp855x_bl.c
4355 ++++ b/drivers/video/backlight/lp855x_bl.c
4356 +@@ -460,7 +460,7 @@ static int lp855x_probe(struct i2c_client *cl, const struct i2c_device_id *id)
4357 + ret = regulator_enable(lp->enable);
4358 + if (ret < 0) {
4359 + dev_err(lp->dev, "failed to enable vddio: %d\n", ret);
4360 +- return ret;
4361 ++ goto disable_supply;
4362 + }
4363 +
4364 + /*
4365 +@@ -475,24 +475,34 @@ static int lp855x_probe(struct i2c_client *cl, const struct i2c_device_id *id)
4366 + ret = lp855x_configure(lp);
4367 + if (ret) {
4368 + dev_err(lp->dev, "device config err: %d", ret);
4369 +- return ret;
4370 ++ goto disable_vddio;
4371 + }
4372 +
4373 + ret = lp855x_backlight_register(lp);
4374 + if (ret) {
4375 + dev_err(lp->dev,
4376 + "failed to register backlight. err: %d\n", ret);
4377 +- return ret;
4378 ++ goto disable_vddio;
4379 + }
4380 +
4381 + ret = sysfs_create_group(&lp->dev->kobj, &lp855x_attr_group);
4382 + if (ret) {
4383 + dev_err(lp->dev, "failed to register sysfs. err: %d\n", ret);
4384 +- return ret;
4385 ++ goto disable_vddio;
4386 + }
4387 +
4388 + backlight_update_status(lp->bl);
4389 ++
4390 + return 0;
4391 ++
4392 ++disable_vddio:
4393 ++ if (lp->enable)
4394 ++ regulator_disable(lp->enable);
4395 ++disable_supply:
4396 ++ if (lp->supply)
4397 ++ regulator_disable(lp->supply);
4398 ++
4399 ++ return ret;
4400 + }
4401 +
4402 + static int lp855x_remove(struct i2c_client *cl)
4403 +@@ -501,6 +511,8 @@ static int lp855x_remove(struct i2c_client *cl)
4404 +
4405 + lp->bl->props.brightness = 0;
4406 + backlight_update_status(lp->bl);
4407 ++ if (lp->enable)
4408 ++ regulator_disable(lp->enable);
4409 + if (lp->supply)
4410 + regulator_disable(lp->supply);
4411 + sysfs_remove_group(&lp->dev->kobj, &lp855x_attr_group);
4412 +diff --git a/drivers/watchdog/da9062_wdt.c b/drivers/watchdog/da9062_wdt.c
4413 +index daeb645fcea8..519419136ce8 100644
4414 +--- a/drivers/watchdog/da9062_wdt.c
4415 ++++ b/drivers/watchdog/da9062_wdt.c
4416 +@@ -94,11 +94,6 @@ static int da9062_wdt_update_timeout_register(struct da9062_watchdog *wdt,
4417 + unsigned int regval)
4418 + {
4419 + struct da9062 *chip = wdt->hw;
4420 +- int ret;
4421 +-
4422 +- ret = da9062_reset_watchdog_timer(wdt);
4423 +- if (ret)
4424 +- return ret;
4425 +
4426 + return regmap_update_bits(chip->regmap,
4427 + DA9062AA_CONTROL_D,
4428 +diff --git a/fs/block_dev.c b/fs/block_dev.c
4429 +index 8a894cd4875b..06f7cbe20132 100644
4430 +--- a/fs/block_dev.c
4431 ++++ b/fs/block_dev.c
4432 +@@ -1255,10 +1255,8 @@ static int __blkdev_get(struct block_device *bdev, fmode_t mode, int for_part)
4433 + */
4434 + if (!for_part) {
4435 + ret = devcgroup_inode_permission(bdev->bd_inode, perm);
4436 +- if (ret != 0) {
4437 +- bdput(bdev);
4438 ++ if (ret != 0)
4439 + return ret;
4440 +- }
4441 + }
4442 +
4443 + restart:
4444 +@@ -1330,8 +1328,10 @@ static int __blkdev_get(struct block_device *bdev, fmode_t mode, int for_part)
4445 + goto out_clear;
4446 + BUG_ON(for_part);
4447 + ret = __blkdev_get(whole, mode, 1);
4448 +- if (ret)
4449 ++ if (ret) {
4450 ++ bdput(whole);
4451 + goto out_clear;
4452 ++ }
4453 + bdev->bd_contains = whole;
4454 + bdev->bd_part = disk_get_part(disk, partno);
4455 + if (!(disk->flags & GENHD_FL_UP) ||
4456 +@@ -1382,7 +1382,6 @@ static int __blkdev_get(struct block_device *bdev, fmode_t mode, int for_part)
4457 + put_disk(disk);
4458 + module_put(owner);
4459 + out:
4460 +- bdput(bdev);
4461 +
4462 + return ret;
4463 + }
4464 +@@ -1468,6 +1467,9 @@ int blkdev_get(struct block_device *bdev, fmode_t mode, void *holder)
4465 + bdput(whole);
4466 + }
4467 +
4468 ++ if (res)
4469 ++ bdput(bdev);
4470 ++
4471 + return res;
4472 + }
4473 + EXPORT_SYMBOL(blkdev_get);
4474 +diff --git a/fs/cifs/smb2ops.c b/fs/cifs/smb2ops.c
4475 +index 67d9b7a277a3..edd4c7292be0 100644
4476 +--- a/fs/cifs/smb2ops.c
4477 ++++ b/fs/cifs/smb2ops.c
4478 +@@ -1220,6 +1220,12 @@ static long smb3_zero_range(struct file *file, struct cifs_tcon *tcon,
4479 + inode = d_inode(cfile->dentry);
4480 + cifsi = CIFS_I(inode);
4481 +
4482 ++ /*
4483 ++ * We zero the range through ioctl, so we need remove the page caches
4484 ++ * first, otherwise the data may be inconsistent with the server.
4485 ++ */
4486 ++ truncate_pagecache_range(inode, offset, offset + len - 1);
4487 ++
4488 + /* if file not oplocked can't be sure whether asking to extend size */
4489 + if (!CIFS_CACHE_READ(cifsi))
4490 + if (keep_size == false)
4491 +@@ -1276,6 +1282,12 @@ static long smb3_punch_hole(struct file *file, struct cifs_tcon *tcon,
4492 + if (!smb2_set_sparse(xid, tcon, cfile, inode, set_sparse))
4493 + return -EOPNOTSUPP;
4494 +
4495 ++ /*
4496 ++ * We implement the punch hole through ioctl, so we need remove the page
4497 ++ * caches first, otherwise the data may be inconsistent with the server.
4498 ++ */
4499 ++ truncate_pagecache_range(inode, offset, offset + len - 1);
4500 ++
4501 + cifs_dbg(FYI, "offset %lld len %lld", offset, len);
4502 +
4503 + fsctl_buf.FileOffset = cpu_to_le64(offset);
4504 +diff --git a/fs/compat_ioctl.c b/fs/compat_ioctl.c
4505 +index 02ac9067a354..9fa3285425fe 100644
4506 +--- a/fs/compat_ioctl.c
4507 ++++ b/fs/compat_ioctl.c
4508 +@@ -1340,23 +1340,6 @@ COMPATIBLE_IOCTL(DMX_GET_PES_PIDS)
4509 + COMPATIBLE_IOCTL(DMX_GET_CAPS)
4510 + COMPATIBLE_IOCTL(DMX_SET_SOURCE)
4511 + COMPATIBLE_IOCTL(DMX_GET_STC)
4512 +-COMPATIBLE_IOCTL(FE_GET_INFO)
4513 +-COMPATIBLE_IOCTL(FE_DISEQC_RESET_OVERLOAD)
4514 +-COMPATIBLE_IOCTL(FE_DISEQC_SEND_MASTER_CMD)
4515 +-COMPATIBLE_IOCTL(FE_DISEQC_RECV_SLAVE_REPLY)
4516 +-COMPATIBLE_IOCTL(FE_DISEQC_SEND_BURST)
4517 +-COMPATIBLE_IOCTL(FE_SET_TONE)
4518 +-COMPATIBLE_IOCTL(FE_SET_VOLTAGE)
4519 +-COMPATIBLE_IOCTL(FE_ENABLE_HIGH_LNB_VOLTAGE)
4520 +-COMPATIBLE_IOCTL(FE_READ_STATUS)
4521 +-COMPATIBLE_IOCTL(FE_READ_BER)
4522 +-COMPATIBLE_IOCTL(FE_READ_SIGNAL_STRENGTH)
4523 +-COMPATIBLE_IOCTL(FE_READ_SNR)
4524 +-COMPATIBLE_IOCTL(FE_READ_UNCORRECTED_BLOCKS)
4525 +-COMPATIBLE_IOCTL(FE_SET_FRONTEND)
4526 +-COMPATIBLE_IOCTL(FE_GET_FRONTEND)
4527 +-COMPATIBLE_IOCTL(FE_GET_EVENT)
4528 +-COMPATIBLE_IOCTL(FE_DISHNETWORK_SEND_LEGACY_CMD)
4529 + COMPATIBLE_IOCTL(VIDEO_STOP)
4530 + COMPATIBLE_IOCTL(VIDEO_PLAY)
4531 + COMPATIBLE_IOCTL(VIDEO_FREEZE)
4532 +diff --git a/fs/dlm/dlm_internal.h b/fs/dlm/dlm_internal.h
4533 +index 216b61604ef9..c211156aabe2 100644
4534 +--- a/fs/dlm/dlm_internal.h
4535 ++++ b/fs/dlm/dlm_internal.h
4536 +@@ -100,7 +100,6 @@ do { \
4537 + __LINE__, __FILE__, #x, jiffies); \
4538 + {do} \
4539 + printk("\n"); \
4540 +- BUG(); \
4541 + panic("DLM: Record message above and reboot.\n"); \
4542 + } \
4543 + }
4544 +diff --git a/fs/ext4/extents.c b/fs/ext4/extents.c
4545 +index 51c2713a615a..ab19f61bd04b 100644
4546 +--- a/fs/ext4/extents.c
4547 ++++ b/fs/ext4/extents.c
4548 +@@ -2916,7 +2916,7 @@ again:
4549 + * in use to avoid freeing it when removing blocks.
4550 + */
4551 + if (sbi->s_cluster_ratio > 1) {
4552 +- pblk = ext4_ext_pblock(ex) + end - ee_block + 2;
4553 ++ pblk = ext4_ext_pblock(ex) + end - ee_block + 1;
4554 + partial_cluster =
4555 + -(long long) EXT4_B2C(sbi, pblk);
4556 + }
4557 +diff --git a/fs/gfs2/ops_fstype.c b/fs/gfs2/ops_fstype.c
4558 +index 84e5ac061b17..bb5ddaabc218 100644
4559 +--- a/fs/gfs2/ops_fstype.c
4560 ++++ b/fs/gfs2/ops_fstype.c
4561 +@@ -920,7 +920,7 @@ fail:
4562 + }
4563 +
4564 + static const match_table_t nolock_tokens = {
4565 +- { Opt_jid, "jid=%d\n", },
4566 ++ { Opt_jid, "jid=%d", },
4567 + { Opt_err, NULL },
4568 + };
4569 +
4570 +diff --git a/fs/nfs/direct.c b/fs/nfs/direct.c
4571 +index de135d2591ff..1affdec23729 100644
4572 +--- a/fs/nfs/direct.c
4573 ++++ b/fs/nfs/direct.c
4574 +@@ -379,8 +379,6 @@ static void nfs_direct_complete(struct nfs_direct_req *dreq)
4575 + {
4576 + struct inode *inode = dreq->inode;
4577 +
4578 +- inode_dio_end(inode);
4579 +-
4580 + if (dreq->iocb) {
4581 + long res = (long) dreq->error;
4582 + if (dreq->count != 0) {
4583 +@@ -392,7 +390,10 @@ static void nfs_direct_complete(struct nfs_direct_req *dreq)
4584 +
4585 + complete(&dreq->completion);
4586 +
4587 ++ igrab(inode);
4588 + nfs_direct_req_release(dreq);
4589 ++ inode_dio_end(inode);
4590 ++ iput(inode);
4591 + }
4592 +
4593 + static void nfs_direct_readpage_release(struct nfs_page *req)
4594 +@@ -534,8 +535,10 @@ static ssize_t nfs_direct_read_schedule_iovec(struct nfs_direct_req *dreq,
4595 + * generic layer handle the completion.
4596 + */
4597 + if (requested_bytes == 0) {
4598 +- inode_dio_end(inode);
4599 ++ igrab(inode);
4600 + nfs_direct_req_release(dreq);
4601 ++ inode_dio_end(inode);
4602 ++ iput(inode);
4603 + return result < 0 ? result : -EIO;
4604 + }
4605 +
4606 +@@ -953,8 +956,10 @@ static ssize_t nfs_direct_write_schedule_iovec(struct nfs_direct_req *dreq,
4607 + * generic layer handle the completion.
4608 + */
4609 + if (requested_bytes == 0) {
4610 +- inode_dio_end(inode);
4611 ++ igrab(inode);
4612 + nfs_direct_req_release(dreq);
4613 ++ inode_dio_end(inode);
4614 ++ iput(inode);
4615 + return result < 0 ? result : -EIO;
4616 + }
4617 +
4618 +diff --git a/fs/nfs/file.c b/fs/nfs/file.c
4619 +index 1eec947c562d..a89d2f793c1b 100644
4620 +--- a/fs/nfs/file.c
4621 ++++ b/fs/nfs/file.c
4622 +@@ -82,6 +82,7 @@ nfs_file_release(struct inode *inode, struct file *filp)
4623 + dprintk("NFS: release(%pD2)\n", filp);
4624 +
4625 + nfs_inc_stats(inode, NFSIOS_VFSRELEASE);
4626 ++ inode_dio_wait(inode);
4627 + nfs_file_clear_open_context(filp);
4628 + return 0;
4629 + }
4630 +diff --git a/fs/nfs/flexfilelayout/flexfilelayout.c b/fs/nfs/flexfilelayout/flexfilelayout.c
4631 +index 4539008502ce..83149cbae093 100644
4632 +--- a/fs/nfs/flexfilelayout/flexfilelayout.c
4633 ++++ b/fs/nfs/flexfilelayout/flexfilelayout.c
4634 +@@ -939,9 +939,8 @@ retry:
4635 + goto out_mds;
4636 +
4637 + /* Use a direct mapping of ds_idx to pgio mirror_idx */
4638 +- if (WARN_ON_ONCE(pgio->pg_mirror_count !=
4639 +- FF_LAYOUT_MIRROR_COUNT(pgio->pg_lseg)))
4640 +- goto out_mds;
4641 ++ if (pgio->pg_mirror_count != FF_LAYOUT_MIRROR_COUNT(pgio->pg_lseg))
4642 ++ goto out_eagain;
4643 +
4644 + for (i = 0; i < pgio->pg_mirror_count; i++) {
4645 + ds = nfs4_ff_layout_prepare_ds(pgio->pg_lseg, i, true);
4646 +@@ -960,11 +959,15 @@ retry:
4647 + }
4648 +
4649 + return;
4650 +-
4651 ++out_eagain:
4652 ++ pnfs_generic_pg_cleanup(pgio);
4653 ++ pgio->pg_error = -EAGAIN;
4654 ++ return;
4655 + out_mds:
4656 + pnfs_put_lseg(pgio->pg_lseg);
4657 + pgio->pg_lseg = NULL;
4658 + nfs_pageio_reset_write_mds(pgio);
4659 ++ pgio->pg_error = -EAGAIN;
4660 + }
4661 +
4662 + static unsigned int
4663 +diff --git a/fs/nfs/nfs4proc.c b/fs/nfs/nfs4proc.c
4664 +index 632d3c3f8dfb..c189722bf9c7 100644
4665 +--- a/fs/nfs/nfs4proc.c
4666 ++++ b/fs/nfs/nfs4proc.c
4667 +@@ -7151,7 +7151,7 @@ nfs4_bind_one_conn_to_session_done(struct rpc_task *task, void *calldata)
4668 + }
4669 +
4670 + static const struct rpc_call_ops nfs4_bind_one_conn_to_session_ops = {
4671 +- .rpc_call_done = &nfs4_bind_one_conn_to_session_done,
4672 ++ .rpc_call_done = nfs4_bind_one_conn_to_session_done,
4673 + };
4674 +
4675 + /*
4676 +diff --git a/fs/nfsd/nfs4callback.c b/fs/nfsd/nfs4callback.c
4677 +index 8d842282111b..172f697864ab 100644
4678 +--- a/fs/nfsd/nfs4callback.c
4679 ++++ b/fs/nfsd/nfs4callback.c
4680 +@@ -1156,6 +1156,8 @@ static void nfsd4_process_cb_update(struct nfsd4_callback *cb)
4681 + err = setup_callback_client(clp, &conn, ses);
4682 + if (err) {
4683 + nfsd4_mark_cb_down(clp, err);
4684 ++ if (c)
4685 ++ svc_xprt_put(c->cn_xprt);
4686 + return;
4687 + }
4688 + }
4689 +diff --git a/fs/ocfs2/ocfs2_fs.h b/fs/ocfs2/ocfs2_fs.h
4690 +index 44d178b8d1aa..c3697cf60500 100644
4691 +--- a/fs/ocfs2/ocfs2_fs.h
4692 ++++ b/fs/ocfs2/ocfs2_fs.h
4693 +@@ -304,7 +304,7 @@
4694 + #define OCFS2_MAX_SLOTS 255
4695 +
4696 + /* Slot map indicator for an empty slot */
4697 +-#define OCFS2_INVALID_SLOT -1
4698 ++#define OCFS2_INVALID_SLOT ((u16)-1)
4699 +
4700 + #define OCFS2_VOL_UUID_LEN 16
4701 + #define OCFS2_MAX_VOL_LABEL_LEN 64
4702 +@@ -340,8 +340,8 @@ struct ocfs2_system_inode_info {
4703 + enum {
4704 + BAD_BLOCK_SYSTEM_INODE = 0,
4705 + GLOBAL_INODE_ALLOC_SYSTEM_INODE,
4706 ++#define OCFS2_FIRST_ONLINE_SYSTEM_INODE GLOBAL_INODE_ALLOC_SYSTEM_INODE
4707 + SLOT_MAP_SYSTEM_INODE,
4708 +-#define OCFS2_FIRST_ONLINE_SYSTEM_INODE SLOT_MAP_SYSTEM_INODE
4709 + HEARTBEAT_SYSTEM_INODE,
4710 + GLOBAL_BITMAP_SYSTEM_INODE,
4711 + USER_QUOTA_SYSTEM_INODE,
4712 +diff --git a/fs/ocfs2/suballoc.c b/fs/ocfs2/suballoc.c
4713 +index 6ad3533940ba..00558bc59052 100644
4714 +--- a/fs/ocfs2/suballoc.c
4715 ++++ b/fs/ocfs2/suballoc.c
4716 +@@ -2891,9 +2891,12 @@ int ocfs2_test_inode_bit(struct ocfs2_super *osb, u64 blkno, int *res)
4717 + goto bail;
4718 + }
4719 +
4720 +- inode_alloc_inode =
4721 +- ocfs2_get_system_file_inode(osb, INODE_ALLOC_SYSTEM_INODE,
4722 +- suballoc_slot);
4723 ++ if (suballoc_slot == (u16)OCFS2_INVALID_SLOT)
4724 ++ inode_alloc_inode = ocfs2_get_system_file_inode(osb,
4725 ++ GLOBAL_INODE_ALLOC_SYSTEM_INODE, suballoc_slot);
4726 ++ else
4727 ++ inode_alloc_inode = ocfs2_get_system_file_inode(osb,
4728 ++ INODE_ALLOC_SYSTEM_INODE, suballoc_slot);
4729 + if (!inode_alloc_inode) {
4730 + /* the error code could be inaccurate, but we are not able to
4731 + * get the correct one. */
4732 +diff --git a/fs/xfs/libxfs/xfs_alloc.c b/fs/xfs/libxfs/xfs_alloc.c
4733 +index e567551402a6..b904d4634355 100644
4734 +--- a/fs/xfs/libxfs/xfs_alloc.c
4735 ++++ b/fs/xfs/libxfs/xfs_alloc.c
4736 +@@ -2507,6 +2507,13 @@ xfs_agf_verify(
4737 + be32_to_cpu(agf->agf_flcount) <= XFS_AGFL_SIZE(mp)))
4738 + return false;
4739 +
4740 ++ if (be32_to_cpu(agf->agf_length) > mp->m_sb.sb_dblocks)
4741 ++ return false;
4742 ++
4743 ++ if (be32_to_cpu(agf->agf_freeblks) < be32_to_cpu(agf->agf_longest) ||
4744 ++ be32_to_cpu(agf->agf_freeblks) > be32_to_cpu(agf->agf_length))
4745 ++ return false;
4746 ++
4747 + if (be32_to_cpu(agf->agf_levels[XFS_BTNUM_BNO]) < 1 ||
4748 + be32_to_cpu(agf->agf_levels[XFS_BTNUM_CNT]) < 1 ||
4749 + be32_to_cpu(agf->agf_levels[XFS_BTNUM_BNO]) > XFS_BTREE_MAXLEVELS ||
4750 +@@ -2518,6 +2525,10 @@ xfs_agf_verify(
4751 + be32_to_cpu(agf->agf_levels[XFS_BTNUM_RMAP]) > XFS_BTREE_MAXLEVELS))
4752 + return false;
4753 +
4754 ++ if (xfs_sb_version_hasrmapbt(&mp->m_sb) &&
4755 ++ be32_to_cpu(agf->agf_rmap_blocks) > be32_to_cpu(agf->agf_length))
4756 ++ return false;
4757 ++
4758 + /*
4759 + * during growfs operations, the perag is not fully initialised,
4760 + * so we can't use it for any useful checking. growfs ensures we can't
4761 +@@ -2531,6 +2542,11 @@ xfs_agf_verify(
4762 + be32_to_cpu(agf->agf_btreeblks) > be32_to_cpu(agf->agf_length))
4763 + return false;
4764 +
4765 ++ if (xfs_sb_version_hasreflink(&mp->m_sb) &&
4766 ++ be32_to_cpu(agf->agf_refcount_blocks) >
4767 ++ be32_to_cpu(agf->agf_length))
4768 ++ return false;
4769 ++
4770 + if (xfs_sb_version_hasreflink(&mp->m_sb) &&
4771 + (be32_to_cpu(agf->agf_refcount_level) < 1 ||
4772 + be32_to_cpu(agf->agf_refcount_level) > XFS_BTREE_MAXLEVELS))
4773 +diff --git a/include/linux/bitops.h b/include/linux/bitops.h
4774 +index cee74a52b9eb..e1dee6c91ff5 100644
4775 +--- a/include/linux/bitops.h
4776 ++++ b/include/linux/bitops.h
4777 +@@ -49,7 +49,7 @@ static inline int get_bitmask_order(unsigned int count)
4778 +
4779 + static __always_inline unsigned long hweight_long(unsigned long w)
4780 + {
4781 +- return sizeof(w) == 4 ? hweight32(w) : hweight64(w);
4782 ++ return sizeof(w) == 4 ? hweight32(w) : hweight64((__u64)w);
4783 + }
4784 +
4785 + /**
4786 +diff --git a/include/linux/elfnote.h b/include/linux/elfnote.h
4787 +index 278e3ef05336..56c6d9031663 100644
4788 +--- a/include/linux/elfnote.h
4789 ++++ b/include/linux/elfnote.h
4790 +@@ -53,7 +53,7 @@
4791 + .popsection ;
4792 +
4793 + #define ELFNOTE(name, type, desc) \
4794 +- ELFNOTE_START(name, type, "") \
4795 ++ ELFNOTE_START(name, type, "a") \
4796 + desc ; \
4797 + ELFNOTE_END
4798 +
4799 +diff --git a/include/linux/genhd.h b/include/linux/genhd.h
4800 +index 3c99fb6727ca..12a2f5ac51c9 100644
4801 +--- a/include/linux/genhd.h
4802 ++++ b/include/linux/genhd.h
4803 +@@ -716,9 +716,11 @@ static inline sector_t part_nr_sects_read(struct hd_struct *part)
4804 + static inline void part_nr_sects_write(struct hd_struct *part, sector_t size)
4805 + {
4806 + #if BITS_PER_LONG==32 && defined(CONFIG_LBDAF) && defined(CONFIG_SMP)
4807 ++ preempt_disable();
4808 + write_seqcount_begin(&part->nr_sects_seq);
4809 + part->nr_sects = size;
4810 + write_seqcount_end(&part->nr_sects_seq);
4811 ++ preempt_enable();
4812 + #elif BITS_PER_LONG==32 && defined(CONFIG_LBDAF) && defined(CONFIG_PREEMPT)
4813 + preempt_disable();
4814 + part->nr_sects = size;
4815 +diff --git a/include/linux/kprobes.h b/include/linux/kprobes.h
4816 +index cb527c78de9f..4db62045f01a 100644
4817 +--- a/include/linux/kprobes.h
4818 ++++ b/include/linux/kprobes.h
4819 +@@ -366,6 +366,10 @@ static inline struct kprobe_ctlblk *get_kprobe_ctlblk(void)
4820 + return this_cpu_ptr(&kprobe_ctlblk);
4821 + }
4822 +
4823 ++extern struct kprobe kprobe_busy;
4824 ++void kprobe_busy_begin(void);
4825 ++void kprobe_busy_end(void);
4826 ++
4827 + int register_kprobe(struct kprobe *p);
4828 + void unregister_kprobe(struct kprobe *p);
4829 + int register_kprobes(struct kprobe **kps, int num);
4830 +diff --git a/include/linux/libata.h b/include/linux/libata.h
4831 +index cdfb67b22317..780ccde2c312 100644
4832 +--- a/include/linux/libata.h
4833 ++++ b/include/linux/libata.h
4834 +@@ -38,6 +38,7 @@
4835 + #include <linux/acpi.h>
4836 + #include <linux/cdrom.h>
4837 + #include <linux/sched.h>
4838 ++#include <linux/async.h>
4839 +
4840 + /*
4841 + * Define if arch has non-standard setup. This is a _PCI_ standard
4842 +@@ -878,6 +879,8 @@ struct ata_port {
4843 + struct timer_list fastdrain_timer;
4844 + unsigned long fastdrain_cnt;
4845 +
4846 ++ async_cookie_t cookie;
4847 ++
4848 + int em_message_type;
4849 + void *private_data;
4850 +
4851 +diff --git a/include/linux/mtd/nand.h b/include/linux/mtd/nand.h
4852 +index d8905a229f34..573e744223a2 100644
4853 +--- a/include/linux/mtd/nand.h
4854 ++++ b/include/linux/mtd/nand.h
4855 +@@ -24,6 +24,7 @@
4856 + #include <linux/mtd/flashchip.h>
4857 + #include <linux/mtd/bbm.h>
4858 +
4859 ++struct nand_chip;
4860 + struct mtd_info;
4861 + struct nand_flash_dev;
4862 + struct device_node;
4863 +@@ -39,7 +40,7 @@ int nand_scan_ident(struct mtd_info *mtd, int max_chips,
4864 + int nand_scan_tail(struct mtd_info *mtd);
4865 +
4866 + /* Unregister the MTD device and free resources held by the NAND device */
4867 +-void nand_release(struct mtd_info *mtd);
4868 ++void nand_release(struct nand_chip *chip);
4869 +
4870 + /* Internal helper for board drivers which need to override command function */
4871 + void nand_wait_ready(struct mtd_info *mtd);
4872 +@@ -219,9 +220,6 @@ enum nand_ecc_algo {
4873 + #define NAND_CI_CELLTYPE_MSK 0x0C
4874 + #define NAND_CI_CELLTYPE_SHIFT 2
4875 +
4876 +-/* Keep gcc happy */
4877 +-struct nand_chip;
4878 +-
4879 + /* ONFI features */
4880 + #define ONFI_FEATURE_16_BIT_BUS (1 << 0)
4881 + #define ONFI_FEATURE_EXT_PARAM_PAGE (1 << 7)
4882 +diff --git a/include/linux/netdevice.h b/include/linux/netdevice.h
4883 +index 81c85ba6e2b8..4d1b1056ac97 100644
4884 +--- a/include/linux/netdevice.h
4885 ++++ b/include/linux/netdevice.h
4886 +@@ -2480,7 +2480,7 @@ void synchronize_net(void);
4887 + int init_dummy_netdev(struct net_device *dev);
4888 +
4889 + DECLARE_PER_CPU(int, xmit_recursion);
4890 +-#define XMIT_RECURSION_LIMIT 10
4891 ++#define XMIT_RECURSION_LIMIT 8
4892 +
4893 + static inline int dev_recursion_level(void)
4894 + {
4895 +diff --git a/include/linux/qed/qed_chain.h b/include/linux/qed/qed_chain.h
4896 +index 72d88cf3ca25..5a215da57b55 100644
4897 +--- a/include/linux/qed/qed_chain.h
4898 ++++ b/include/linux/qed/qed_chain.h
4899 +@@ -155,28 +155,34 @@ static inline u32 qed_chain_get_cons_idx_u32(struct qed_chain *p_chain)
4900 +
4901 + static inline u16 qed_chain_get_elem_left(struct qed_chain *p_chain)
4902 + {
4903 ++ u16 elem_per_page = p_chain->elem_per_page;
4904 ++ u32 prod = p_chain->u.chain16.prod_idx;
4905 ++ u32 cons = p_chain->u.chain16.cons_idx;
4906 + u16 used;
4907 +
4908 +- used = (u16) (((u32)0x10000 +
4909 +- (u32)p_chain->u.chain16.prod_idx) -
4910 +- (u32)p_chain->u.chain16.cons_idx);
4911 ++ if (prod < cons)
4912 ++ prod += (u32)U16_MAX + 1;
4913 ++
4914 ++ used = (u16)(prod - cons);
4915 + if (p_chain->mode == QED_CHAIN_MODE_NEXT_PTR)
4916 +- used -= p_chain->u.chain16.prod_idx / p_chain->elem_per_page -
4917 +- p_chain->u.chain16.cons_idx / p_chain->elem_per_page;
4918 ++ used -= prod / elem_per_page - cons / elem_per_page;
4919 +
4920 + return (u16)(p_chain->capacity - used);
4921 + }
4922 +
4923 + static inline u32 qed_chain_get_elem_left_u32(struct qed_chain *p_chain)
4924 + {
4925 ++ u16 elem_per_page = p_chain->elem_per_page;
4926 ++ u64 prod = p_chain->u.chain32.prod_idx;
4927 ++ u64 cons = p_chain->u.chain32.cons_idx;
4928 + u32 used;
4929 +
4930 +- used = (u32) (((u64)0x100000000ULL +
4931 +- (u64)p_chain->u.chain32.prod_idx) -
4932 +- (u64)p_chain->u.chain32.cons_idx);
4933 ++ if (prod < cons)
4934 ++ prod += (u64)U32_MAX + 1;
4935 ++
4936 ++ used = (u32)(prod - cons);
4937 + if (p_chain->mode == QED_CHAIN_MODE_NEXT_PTR)
4938 +- used -= p_chain->u.chain32.prod_idx / p_chain->elem_per_page -
4939 +- p_chain->u.chain32.cons_idx / p_chain->elem_per_page;
4940 ++ used -= (u32)(prod / elem_per_page - cons / elem_per_page);
4941 +
4942 + return p_chain->capacity - used;
4943 + }
4944 +diff --git a/include/linux/usb/composite.h b/include/linux/usb/composite.h
4945 +index 667d20454a21..0ec7185e5ddf 100644
4946 +--- a/include/linux/usb/composite.h
4947 ++++ b/include/linux/usb/composite.h
4948 +@@ -248,6 +248,9 @@ int usb_function_activate(struct usb_function *);
4949 +
4950 + int usb_interface_id(struct usb_configuration *, struct usb_function *);
4951 +
4952 ++int config_ep_by_speed_and_alt(struct usb_gadget *g, struct usb_function *f,
4953 ++ struct usb_ep *_ep, u8 alt);
4954 ++
4955 + int config_ep_by_speed(struct usb_gadget *g, struct usb_function *f,
4956 + struct usb_ep *_ep);
4957 +
4958 +diff --git a/include/net/sctp/constants.h b/include/net/sctp/constants.h
4959 +index 5b847e49f7e9..8890fd66021d 100644
4960 +--- a/include/net/sctp/constants.h
4961 ++++ b/include/net/sctp/constants.h
4962 +@@ -357,11 +357,13 @@ typedef enum {
4963 + ipv4_is_anycast_6to4(a))
4964 +
4965 + /* Flags used for the bind address copy functions. */
4966 +-#define SCTP_ADDR6_ALLOWED 0x00000001 /* IPv6 address is allowed by
4967 ++#define SCTP_ADDR4_ALLOWED 0x00000001 /* IPv4 address is allowed by
4968 + local sock family */
4969 +-#define SCTP_ADDR4_PEERSUPP 0x00000002 /* IPv4 address is supported by
4970 ++#define SCTP_ADDR6_ALLOWED 0x00000002 /* IPv6 address is allowed by
4971 ++ local sock family */
4972 ++#define SCTP_ADDR4_PEERSUPP 0x00000004 /* IPv4 address is supported by
4973 + peer */
4974 +-#define SCTP_ADDR6_PEERSUPP 0x00000004 /* IPv6 address is supported by
4975 ++#define SCTP_ADDR6_PEERSUPP 0x00000008 /* IPv6 address is supported by
4976 + peer */
4977 +
4978 + /* Reasons to retransmit. */
4979 +diff --git a/include/net/sock.h b/include/net/sock.h
4980 +index d6bce19ca261..db68c72126d5 100644
4981 +--- a/include/net/sock.h
4982 ++++ b/include/net/sock.h
4983 +@@ -1631,7 +1631,6 @@ static inline int sk_tx_queue_get(const struct sock *sk)
4984 +
4985 + static inline void sk_set_socket(struct sock *sk, struct socket *sock)
4986 + {
4987 +- sk_tx_queue_clear(sk);
4988 + sk->sk_socket = sock;
4989 + }
4990 +
4991 +diff --git a/include/uapi/linux/dvb/frontend.h b/include/uapi/linux/dvb/frontend.h
4992 +index afc3972b0879..b653754ee9cf 100644
4993 +--- a/include/uapi/linux/dvb/frontend.h
4994 ++++ b/include/uapi/linux/dvb/frontend.h
4995 +@@ -28,13 +28,46 @@
4996 +
4997 + #include <linux/types.h>
4998 +
4999 +-enum fe_type {
5000 +- FE_QPSK,
5001 +- FE_QAM,
5002 +- FE_OFDM,
5003 +- FE_ATSC
5004 +-};
5005 +-
5006 ++/**
5007 ++ * enum fe_caps - Frontend capabilities
5008 ++ *
5009 ++ * @FE_IS_STUPID: There's something wrong at the
5010 ++ * frontend, and it can't report its
5011 ++ * capabilities.
5012 ++ * @FE_CAN_INVERSION_AUTO: Can auto-detect frequency spectral
5013 ++ * band inversion
5014 ++ * @FE_CAN_FEC_1_2: Supports FEC 1/2
5015 ++ * @FE_CAN_FEC_2_3: Supports FEC 2/3
5016 ++ * @FE_CAN_FEC_3_4: Supports FEC 3/4
5017 ++ * @FE_CAN_FEC_4_5: Supports FEC 4/5
5018 ++ * @FE_CAN_FEC_5_6: Supports FEC 5/6
5019 ++ * @FE_CAN_FEC_6_7: Supports FEC 6/7
5020 ++ * @FE_CAN_FEC_7_8: Supports FEC 7/8
5021 ++ * @FE_CAN_FEC_8_9: Supports FEC 8/9
5022 ++ * @FE_CAN_FEC_AUTO: Can auto-detect FEC
5023 ++ * @FE_CAN_QPSK: Supports QPSK modulation
5024 ++ * @FE_CAN_QAM_16: Supports 16-QAM modulation
5025 ++ * @FE_CAN_QAM_32: Supports 32-QAM modulation
5026 ++ * @FE_CAN_QAM_64: Supports 64-QAM modulation
5027 ++ * @FE_CAN_QAM_128: Supports 128-QAM modulation
5028 ++ * @FE_CAN_QAM_256: Supports 256-QAM modulation
5029 ++ * @FE_CAN_QAM_AUTO: Can auto-detect QAM modulation
5030 ++ * @FE_CAN_TRANSMISSION_MODE_AUTO: Can auto-detect transmission mode
5031 ++ * @FE_CAN_BANDWIDTH_AUTO: Can auto-detect bandwidth
5032 ++ * @FE_CAN_GUARD_INTERVAL_AUTO: Can auto-detect guard interval
5033 ++ * @FE_CAN_HIERARCHY_AUTO: Can auto-detect hierarchy
5034 ++ * @FE_CAN_8VSB: Supports 8-VSB modulation
5035 ++ * @FE_CAN_16VSB: Supporta 16-VSB modulation
5036 ++ * @FE_HAS_EXTENDED_CAPS: Unused
5037 ++ * @FE_CAN_MULTISTREAM: Supports multistream filtering
5038 ++ * @FE_CAN_TURBO_FEC: Supports "turbo FEC" modulation
5039 ++ * @FE_CAN_2G_MODULATION: Supports "2nd generation" modulation,
5040 ++ * e. g. DVB-S2, DVB-T2, DVB-C2
5041 ++ * @FE_NEEDS_BENDING: Unused
5042 ++ * @FE_CAN_RECOVER: Can recover from a cable unplug
5043 ++ * automatically
5044 ++ * @FE_CAN_MUTE_TS: Can stop spurious TS data output
5045 ++ */
5046 + enum fe_caps {
5047 + FE_IS_STUPID = 0,
5048 + FE_CAN_INVERSION_AUTO = 0x1,
5049 +@@ -60,15 +93,55 @@ enum fe_caps {
5050 + FE_CAN_HIERARCHY_AUTO = 0x100000,
5051 + FE_CAN_8VSB = 0x200000,
5052 + FE_CAN_16VSB = 0x400000,
5053 +- FE_HAS_EXTENDED_CAPS = 0x800000, /* We need more bitspace for newer APIs, indicate this. */
5054 +- FE_CAN_MULTISTREAM = 0x4000000, /* frontend supports multistream filtering */
5055 +- FE_CAN_TURBO_FEC = 0x8000000, /* frontend supports "turbo fec modulation" */
5056 +- FE_CAN_2G_MODULATION = 0x10000000, /* frontend supports "2nd generation modulation" (DVB-S2) */
5057 +- FE_NEEDS_BENDING = 0x20000000, /* not supported anymore, don't use (frontend requires frequency bending) */
5058 +- FE_CAN_RECOVER = 0x40000000, /* frontend can recover from a cable unplug automatically */
5059 +- FE_CAN_MUTE_TS = 0x80000000 /* frontend can stop spurious TS data output */
5060 ++ FE_HAS_EXTENDED_CAPS = 0x800000,
5061 ++ FE_CAN_MULTISTREAM = 0x4000000,
5062 ++ FE_CAN_TURBO_FEC = 0x8000000,
5063 ++ FE_CAN_2G_MODULATION = 0x10000000,
5064 ++ FE_NEEDS_BENDING = 0x20000000,
5065 ++ FE_CAN_RECOVER = 0x40000000,
5066 ++ FE_CAN_MUTE_TS = 0x80000000
5067 ++};
5068 ++
5069 ++/*
5070 ++ * DEPRECATED: Should be kept just due to backward compatibility.
5071 ++ */
5072 ++enum fe_type {
5073 ++ FE_QPSK,
5074 ++ FE_QAM,
5075 ++ FE_OFDM,
5076 ++ FE_ATSC
5077 + };
5078 +
5079 ++/**
5080 ++ * struct dvb_frontend_info - Frontend properties and capabilities
5081 ++ *
5082 ++ * @name: Name of the frontend
5083 ++ * @type: **DEPRECATED**.
5084 ++ * Should not be used on modern programs,
5085 ++ * as a frontend may have more than one type.
5086 ++ * In order to get the support types of a given
5087 ++ * frontend, use :c:type:`DTV_ENUM_DELSYS`
5088 ++ * instead.
5089 ++ * @frequency_min: Minimal frequency supported by the frontend.
5090 ++ * @frequency_max: Minimal frequency supported by the frontend.
5091 ++ * @frequency_stepsize: All frequencies are multiple of this value.
5092 ++ * @frequency_tolerance: Frequency tolerance.
5093 ++ * @symbol_rate_min: Minimal symbol rate, in bauds
5094 ++ * (for Cable/Satellite systems).
5095 ++ * @symbol_rate_max: Maximal symbol rate, in bauds
5096 ++ * (for Cable/Satellite systems).
5097 ++ * @symbol_rate_tolerance: Maximal symbol rate tolerance, in ppm
5098 ++ * (for Cable/Satellite systems).
5099 ++ * @notifier_delay: **DEPRECATED**. Not used by any driver.
5100 ++ * @caps: Capabilities supported by the frontend,
5101 ++ * as specified in &enum fe_caps.
5102 ++ *
5103 ++ * .. note:
5104 ++ *
5105 ++ * #. The frequencies are specified in Hz for Terrestrial and Cable
5106 ++ * systems.
5107 ++ * #. The frequencies are specified in kHz for Satellite systems.
5108 ++ */
5109 + struct dvb_frontend_info {
5110 + char name[128];
5111 + enum fe_type type; /* DEPRECATED. Use DTV_ENUM_DELSYS instead */
5112 +@@ -78,53 +151,102 @@ struct dvb_frontend_info {
5113 + __u32 frequency_tolerance;
5114 + __u32 symbol_rate_min;
5115 + __u32 symbol_rate_max;
5116 +- __u32 symbol_rate_tolerance; /* ppm */
5117 ++ __u32 symbol_rate_tolerance;
5118 + __u32 notifier_delay; /* DEPRECATED */
5119 + enum fe_caps caps;
5120 + };
5121 +
5122 +-
5123 + /**
5124 +- * Check out the DiSEqC bus spec available on http://www.eutelsat.org/ for
5125 +- * the meaning of this struct...
5126 ++ * struct dvb_diseqc_master_cmd - DiSEqC master command
5127 ++ *
5128 ++ * @msg:
5129 ++ * DiSEqC message to be sent. It contains a 3 bytes header with:
5130 ++ * framing + address + command, and an optional argument
5131 ++ * of up to 3 bytes of data.
5132 ++ * @msg_len:
5133 ++ * Length of the DiSEqC message. Valid values are 3 to 6.
5134 ++ *
5135 ++ * Check out the DiSEqC bus spec available on http://www.eutelsat.org/ for
5136 ++ * the possible messages that can be used.
5137 + */
5138 + struct dvb_diseqc_master_cmd {
5139 +- __u8 msg [6]; /* { framing, address, command, data [3] } */
5140 +- __u8 msg_len; /* valid values are 3...6 */
5141 ++ __u8 msg[6];
5142 ++ __u8 msg_len;
5143 + };
5144 +
5145 ++/**
5146 ++ * struct dvb_diseqc_slave_reply - DiSEqC received data
5147 ++ *
5148 ++ * @msg:
5149 ++ * DiSEqC message buffer to store a message received via DiSEqC.
5150 ++ * It contains one byte header with: framing and
5151 ++ * an optional argument of up to 3 bytes of data.
5152 ++ * @msg_len:
5153 ++ * Length of the DiSEqC message. Valid values are 0 to 4,
5154 ++ * where 0 means no message.
5155 ++ * @timeout:
5156 ++ * Return from ioctl after timeout ms with errorcode when
5157 ++ * no message was received.
5158 ++ *
5159 ++ * Check out the DiSEqC bus spec available on http://www.eutelsat.org/ for
5160 ++ * the possible messages that can be used.
5161 ++ */
5162 + struct dvb_diseqc_slave_reply {
5163 +- __u8 msg [4]; /* { framing, data [3] } */
5164 +- __u8 msg_len; /* valid values are 0...4, 0 means no msg */
5165 +- int timeout; /* return from ioctl after timeout ms with */
5166 +-}; /* errorcode when no message was received */
5167 ++ __u8 msg[4];
5168 ++ __u8 msg_len;
5169 ++ int timeout;
5170 ++};
5171 +
5172 ++/**
5173 ++ * enum fe_sec_voltage - DC Voltage used to feed the LNBf
5174 ++ *
5175 ++ * @SEC_VOLTAGE_13: Output 13V to the LNBf
5176 ++ * @SEC_VOLTAGE_18: Output 18V to the LNBf
5177 ++ * @SEC_VOLTAGE_OFF: Don't feed the LNBf with a DC voltage
5178 ++ */
5179 + enum fe_sec_voltage {
5180 + SEC_VOLTAGE_13,
5181 + SEC_VOLTAGE_18,
5182 + SEC_VOLTAGE_OFF
5183 + };
5184 +
5185 ++/**
5186 ++ * enum fe_sec_tone_mode - Type of tone to be send to the LNBf.
5187 ++ * @SEC_TONE_ON: Sends a 22kHz tone burst to the antenna.
5188 ++ * @SEC_TONE_OFF: Don't send a 22kHz tone to the antenna (except
5189 ++ * if the ``FE_DISEQC_*`` ioctls are called).
5190 ++ */
5191 + enum fe_sec_tone_mode {
5192 + SEC_TONE_ON,
5193 + SEC_TONE_OFF
5194 + };
5195 +
5196 ++/**
5197 ++ * enum fe_sec_mini_cmd - Type of mini burst to be sent
5198 ++ *
5199 ++ * @SEC_MINI_A: Sends a mini-DiSEqC 22kHz '0' Tone Burst to select
5200 ++ * satellite-A
5201 ++ * @SEC_MINI_B: Sends a mini-DiSEqC 22kHz '1' Data Burst to select
5202 ++ * satellite-B
5203 ++ */
5204 + enum fe_sec_mini_cmd {
5205 + SEC_MINI_A,
5206 + SEC_MINI_B
5207 + };
5208 +
5209 + /**
5210 +- * enum fe_status - enumerates the possible frontend status
5211 +- * @FE_HAS_SIGNAL: found something above the noise level
5212 +- * @FE_HAS_CARRIER: found a DVB signal
5213 +- * @FE_HAS_VITERBI: FEC is stable
5214 +- * @FE_HAS_SYNC: found sync bytes
5215 +- * @FE_HAS_LOCK: everything's working
5216 +- * @FE_TIMEDOUT: no lock within the last ~2 seconds
5217 +- * @FE_REINIT: frontend was reinitialized, application is recommended
5218 +- * to reset DiSEqC, tone and parameters
5219 ++ * enum fe_status - Enumerates the possible frontend status.
5220 ++ * @FE_NONE: The frontend doesn't have any kind of lock.
5221 ++ * That's the initial frontend status
5222 ++ * @FE_HAS_SIGNAL: Has found something above the noise level.
5223 ++ * @FE_HAS_CARRIER: Has found a DVB signal.
5224 ++ * @FE_HAS_VITERBI: FEC inner coding (Viterbi, LDPC or other inner code).
5225 ++ * is stable.
5226 ++ * @FE_HAS_SYNC: Synchronization bytes was found.
5227 ++ * @FE_HAS_LOCK: DVB were locked and everything is working.
5228 ++ * @FE_TIMEDOUT: Fo lock within the last about 2 seconds.
5229 ++ * @FE_REINIT: Frontend was reinitialized, application is recommended
5230 ++ * to reset DiSEqC, tone and parameters.
5231 + */
5232 + enum fe_status {
5233 + FE_NONE = 0x00,
5234 +@@ -137,12 +259,45 @@ enum fe_status {
5235 + FE_REINIT = 0x40,
5236 + };
5237 +
5238 ++/**
5239 ++ * enum fe_spectral_inversion - Type of inversion band
5240 ++ *
5241 ++ * @INVERSION_OFF: Don't do spectral band inversion.
5242 ++ * @INVERSION_ON: Do spectral band inversion.
5243 ++ * @INVERSION_AUTO: Autodetect spectral band inversion.
5244 ++ *
5245 ++ * This parameter indicates if spectral inversion should be presumed or
5246 ++ * not. In the automatic setting (``INVERSION_AUTO``) the hardware will try
5247 ++ * to figure out the correct setting by itself. If the hardware doesn't
5248 ++ * support, the DVB core will try to lock at the carrier first with
5249 ++ * inversion off. If it fails, it will try to enable inversion.
5250 ++ */
5251 + enum fe_spectral_inversion {
5252 + INVERSION_OFF,
5253 + INVERSION_ON,
5254 + INVERSION_AUTO
5255 + };
5256 +
5257 ++/**
5258 ++ * enum fe_code_rate - Type of Forward Error Correction (FEC)
5259 ++ *
5260 ++ *
5261 ++ * @FEC_NONE: No Forward Error Correction Code
5262 ++ * @FEC_1_2: Forward Error Correction Code 1/2
5263 ++ * @FEC_2_3: Forward Error Correction Code 2/3
5264 ++ * @FEC_3_4: Forward Error Correction Code 3/4
5265 ++ * @FEC_4_5: Forward Error Correction Code 4/5
5266 ++ * @FEC_5_6: Forward Error Correction Code 5/6
5267 ++ * @FEC_6_7: Forward Error Correction Code 6/7
5268 ++ * @FEC_7_8: Forward Error Correction Code 7/8
5269 ++ * @FEC_8_9: Forward Error Correction Code 8/9
5270 ++ * @FEC_AUTO: Autodetect Error Correction Code
5271 ++ * @FEC_3_5: Forward Error Correction Code 3/5
5272 ++ * @FEC_9_10: Forward Error Correction Code 9/10
5273 ++ * @FEC_2_5: Forward Error Correction Code 2/5
5274 ++ *
5275 ++ * Please note that not all FEC types are supported by a given standard.
5276 ++ */
5277 + enum fe_code_rate {
5278 + FEC_NONE = 0,
5279 + FEC_1_2,
5280 +@@ -159,6 +314,26 @@ enum fe_code_rate {
5281 + FEC_2_5,
5282 + };
5283 +
5284 ++/**
5285 ++ * enum fe_modulation - Type of modulation/constellation
5286 ++ * @QPSK: QPSK modulation
5287 ++ * @QAM_16: 16-QAM modulation
5288 ++ * @QAM_32: 32-QAM modulation
5289 ++ * @QAM_64: 64-QAM modulation
5290 ++ * @QAM_128: 128-QAM modulation
5291 ++ * @QAM_256: 256-QAM modulation
5292 ++ * @QAM_AUTO: Autodetect QAM modulation
5293 ++ * @VSB_8: 8-VSB modulation
5294 ++ * @VSB_16: 16-VSB modulation
5295 ++ * @PSK_8: 8-PSK modulation
5296 ++ * @APSK_16: 16-APSK modulation
5297 ++ * @APSK_32: 32-APSK modulation
5298 ++ * @DQPSK: DQPSK modulation
5299 ++ * @QAM_4_NR: 4-QAM-NR modulation
5300 ++ *
5301 ++ * Please note that not all modulations are supported by a given standard.
5302 ++ *
5303 ++ */
5304 + enum fe_modulation {
5305 + QPSK,
5306 + QAM_16,
5307 +@@ -176,6 +351,32 @@ enum fe_modulation {
5308 + QAM_4_NR,
5309 + };
5310 +
5311 ++/**
5312 ++ * enum fe_transmit_mode - Transmission mode
5313 ++ *
5314 ++ * @TRANSMISSION_MODE_AUTO:
5315 ++ * Autodetect transmission mode. The hardware will try to find the
5316 ++ * correct FFT-size (if capable) to fill in the missing parameters.
5317 ++ * @TRANSMISSION_MODE_1K:
5318 ++ * Transmission mode 1K
5319 ++ * @TRANSMISSION_MODE_2K:
5320 ++ * Transmission mode 2K
5321 ++ * @TRANSMISSION_MODE_8K:
5322 ++ * Transmission mode 8K
5323 ++ * @TRANSMISSION_MODE_4K:
5324 ++ * Transmission mode 4K
5325 ++ * @TRANSMISSION_MODE_16K:
5326 ++ * Transmission mode 16K
5327 ++ * @TRANSMISSION_MODE_32K:
5328 ++ * Transmission mode 32K
5329 ++ * @TRANSMISSION_MODE_C1:
5330 ++ * Single Carrier (C=1) transmission mode (DTMB only)
5331 ++ * @TRANSMISSION_MODE_C3780:
5332 ++ * Multi Carrier (C=3780) transmission mode (DTMB only)
5333 ++ *
5334 ++ * Please note that not all transmission modes are supported by a given
5335 ++ * standard.
5336 ++ */
5337 + enum fe_transmit_mode {
5338 + TRANSMISSION_MODE_2K,
5339 + TRANSMISSION_MODE_8K,
5340 +@@ -188,6 +389,23 @@ enum fe_transmit_mode {
5341 + TRANSMISSION_MODE_C3780,
5342 + };
5343 +
5344 ++/**
5345 ++ * enum fe_guard_interval - Guard interval
5346 ++ *
5347 ++ * @GUARD_INTERVAL_AUTO: Autodetect the guard interval
5348 ++ * @GUARD_INTERVAL_1_128: Guard interval 1/128
5349 ++ * @GUARD_INTERVAL_1_32: Guard interval 1/32
5350 ++ * @GUARD_INTERVAL_1_16: Guard interval 1/16
5351 ++ * @GUARD_INTERVAL_1_8: Guard interval 1/8
5352 ++ * @GUARD_INTERVAL_1_4: Guard interval 1/4
5353 ++ * @GUARD_INTERVAL_19_128: Guard interval 19/128
5354 ++ * @GUARD_INTERVAL_19_256: Guard interval 19/256
5355 ++ * @GUARD_INTERVAL_PN420: PN length 420 (1/4)
5356 ++ * @GUARD_INTERVAL_PN595: PN length 595 (1/6)
5357 ++ * @GUARD_INTERVAL_PN945: PN length 945 (1/9)
5358 ++ *
5359 ++ * Please note that not all guard intervals are supported by a given standard.
5360 ++ */
5361 + enum fe_guard_interval {
5362 + GUARD_INTERVAL_1_32,
5363 + GUARD_INTERVAL_1_16,
5364 +@@ -202,6 +420,16 @@ enum fe_guard_interval {
5365 + GUARD_INTERVAL_PN945,
5366 + };
5367 +
5368 ++/**
5369 ++ * enum fe_hierarchy - Hierarchy
5370 ++ * @HIERARCHY_NONE: No hierarchy
5371 ++ * @HIERARCHY_AUTO: Autodetect hierarchy (if supported)
5372 ++ * @HIERARCHY_1: Hierarchy 1
5373 ++ * @HIERARCHY_2: Hierarchy 2
5374 ++ * @HIERARCHY_4: Hierarchy 4
5375 ++ *
5376 ++ * Please note that not all hierarchy types are supported by a given standard.
5377 ++ */
5378 + enum fe_hierarchy {
5379 + HIERARCHY_NONE,
5380 + HIERARCHY_1,
5381 +@@ -210,6 +438,15 @@ enum fe_hierarchy {
5382 + HIERARCHY_AUTO
5383 + };
5384 +
5385 ++/**
5386 ++ * enum fe_interleaving - Interleaving
5387 ++ * @INTERLEAVING_NONE: No interleaving.
5388 ++ * @INTERLEAVING_AUTO: Auto-detect interleaving.
5389 ++ * @INTERLEAVING_240: Interleaving of 240 symbols.
5390 ++ * @INTERLEAVING_720: Interleaving of 720 symbols.
5391 ++ *
5392 ++ * Please note that, currently, only DTMB uses it.
5393 ++ */
5394 + enum fe_interleaving {
5395 + INTERLEAVING_NONE,
5396 + INTERLEAVING_AUTO,
5397 +@@ -217,7 +454,8 @@ enum fe_interleaving {
5398 + INTERLEAVING_720,
5399 + };
5400 +
5401 +-/* S2API Commands */
5402 ++/* DVBv5 property Commands */
5403 ++
5404 + #define DTV_UNDEFINED 0
5405 + #define DTV_TUNE 1
5406 + #define DTV_CLEAR 2
5407 +@@ -310,19 +548,79 @@ enum fe_interleaving {
5408 +
5409 + #define DTV_MAX_COMMAND DTV_STAT_TOTAL_BLOCK_COUNT
5410 +
5411 ++/**
5412 ++ * enum fe_pilot - Type of pilot tone
5413 ++ *
5414 ++ * @PILOT_ON: Pilot tones enabled
5415 ++ * @PILOT_OFF: Pilot tones disabled
5416 ++ * @PILOT_AUTO: Autodetect pilot tones
5417 ++ */
5418 + enum fe_pilot {
5419 + PILOT_ON,
5420 + PILOT_OFF,
5421 + PILOT_AUTO,
5422 + };
5423 +
5424 ++/**
5425 ++ * enum fe_rolloff - Rolloff factor (also known as alpha)
5426 ++ * @ROLLOFF_35: Roloff factor: 35%
5427 ++ * @ROLLOFF_20: Roloff factor: 20%
5428 ++ * @ROLLOFF_25: Roloff factor: 25%
5429 ++ * @ROLLOFF_AUTO: Auto-detect the roloff factor.
5430 ++ *
5431 ++ * .. note:
5432 ++ *
5433 ++ * Roloff factor of 35% is implied on DVB-S. On DVB-S2, it is default.
5434 ++ */
5435 + enum fe_rolloff {
5436 +- ROLLOFF_35, /* Implied value in DVB-S, default for DVB-S2 */
5437 ++ ROLLOFF_35,
5438 + ROLLOFF_20,
5439 + ROLLOFF_25,
5440 + ROLLOFF_AUTO,
5441 + };
5442 +
5443 ++/**
5444 ++ * enum fe_delivery_system - Type of the delivery system
5445 ++ *
5446 ++ * @SYS_UNDEFINED:
5447 ++ * Undefined standard. Generally, indicates an error
5448 ++ * @SYS_DVBC_ANNEX_A:
5449 ++ * Cable TV: DVB-C following ITU-T J.83 Annex A spec
5450 ++ * @SYS_DVBC_ANNEX_B:
5451 ++ * Cable TV: DVB-C following ITU-T J.83 Annex B spec (ClearQAM)
5452 ++ * @SYS_DVBC_ANNEX_C:
5453 ++ * Cable TV: DVB-C following ITU-T J.83 Annex C spec
5454 ++ * @SYS_ISDBC:
5455 ++ * Cable TV: ISDB-C (no drivers yet)
5456 ++ * @SYS_DVBT:
5457 ++ * Terrestrial TV: DVB-T
5458 ++ * @SYS_DVBT2:
5459 ++ * Terrestrial TV: DVB-T2
5460 ++ * @SYS_ISDBT:
5461 ++ * Terrestrial TV: ISDB-T
5462 ++ * @SYS_ATSC:
5463 ++ * Terrestrial TV: ATSC
5464 ++ * @SYS_ATSCMH:
5465 ++ * Terrestrial TV (mobile): ATSC-M/H
5466 ++ * @SYS_DTMB:
5467 ++ * Terrestrial TV: DTMB
5468 ++ * @SYS_DVBS:
5469 ++ * Satellite TV: DVB-S
5470 ++ * @SYS_DVBS2:
5471 ++ * Satellite TV: DVB-S2
5472 ++ * @SYS_TURBO:
5473 ++ * Satellite TV: DVB-S Turbo
5474 ++ * @SYS_ISDBS:
5475 ++ * Satellite TV: ISDB-S
5476 ++ * @SYS_DAB:
5477 ++ * Digital audio: DAB (not fully supported)
5478 ++ * @SYS_DSS:
5479 ++ * Satellite TV: DSS (not fully supported)
5480 ++ * @SYS_CMMB:
5481 ++ * Terrestrial TV (mobile): CMMB (not fully supported)
5482 ++ * @SYS_DVBH:
5483 ++ * Terrestrial TV (mobile): DVB-H (standard deprecated)
5484 ++ */
5485 + enum fe_delivery_system {
5486 + SYS_UNDEFINED,
5487 + SYS_DVBC_ANNEX_A,
5488 +@@ -345,35 +643,85 @@ enum fe_delivery_system {
5489 + SYS_DVBC_ANNEX_C,
5490 + };
5491 +
5492 +-/* backward compatibility */
5493 ++/* backward compatibility definitions for delivery systems */
5494 + #define SYS_DVBC_ANNEX_AC SYS_DVBC_ANNEX_A
5495 +-#define SYS_DMBTH SYS_DTMB /* DMB-TH is legacy name, use DTMB instead */
5496 ++#define SYS_DMBTH SYS_DTMB /* DMB-TH is legacy name, use DTMB */
5497 +
5498 +-/* ATSC-MH */
5499 ++/* ATSC-MH specific parameters */
5500 +
5501 ++/**
5502 ++ * enum atscmh_sccc_block_mode - Type of Series Concatenated Convolutional
5503 ++ * Code Block Mode.
5504 ++ *
5505 ++ * @ATSCMH_SCCC_BLK_SEP:
5506 ++ * Separate SCCC: the SCCC outer code mode shall be set independently
5507 ++ * for each Group Region (A, B, C, D)
5508 ++ * @ATSCMH_SCCC_BLK_COMB:
5509 ++ * Combined SCCC: all four Regions shall have the same SCCC outer
5510 ++ * code mode.
5511 ++ * @ATSCMH_SCCC_BLK_RES:
5512 ++ * Reserved. Shouldn't be used.
5513 ++ */
5514 + enum atscmh_sccc_block_mode {
5515 + ATSCMH_SCCC_BLK_SEP = 0,
5516 + ATSCMH_SCCC_BLK_COMB = 1,
5517 + ATSCMH_SCCC_BLK_RES = 2,
5518 + };
5519 +
5520 ++/**
5521 ++ * enum atscmh_sccc_code_mode - Type of Series Concatenated Convolutional
5522 ++ * Code Rate.
5523 ++ *
5524 ++ * @ATSCMH_SCCC_CODE_HLF:
5525 ++ * The outer code rate of a SCCC Block is 1/2 rate.
5526 ++ * @ATSCMH_SCCC_CODE_QTR:
5527 ++ * The outer code rate of a SCCC Block is 1/4 rate.
5528 ++ * @ATSCMH_SCCC_CODE_RES:
5529 ++ * Reserved. Should not be used.
5530 ++ */
5531 + enum atscmh_sccc_code_mode {
5532 + ATSCMH_SCCC_CODE_HLF = 0,
5533 + ATSCMH_SCCC_CODE_QTR = 1,
5534 + ATSCMH_SCCC_CODE_RES = 2,
5535 + };
5536 +
5537 ++/**
5538 ++ * enum atscmh_rs_frame_ensemble - Reed Solomon(RS) frame ensemble.
5539 ++ *
5540 ++ * @ATSCMH_RSFRAME_ENS_PRI: Primary Ensemble.
5541 ++ * @ATSCMH_RSFRAME_ENS_SEC: Secondary Ensemble.
5542 ++ */
5543 + enum atscmh_rs_frame_ensemble {
5544 + ATSCMH_RSFRAME_ENS_PRI = 0,
5545 + ATSCMH_RSFRAME_ENS_SEC = 1,
5546 + };
5547 +
5548 ++/**
5549 ++ * enum atscmh_rs_frame_mode - Reed Solomon (RS) frame mode.
5550 ++ *
5551 ++ * @ATSCMH_RSFRAME_PRI_ONLY:
5552 ++ * Single Frame: There is only a primary RS Frame for all Group
5553 ++ * Regions.
5554 ++ * @ATSCMH_RSFRAME_PRI_SEC:
5555 ++ * Dual Frame: There are two separate RS Frames: Primary RS Frame for
5556 ++ * Group Region A and B and Secondary RS Frame for Group Region C and
5557 ++ * D.
5558 ++ * @ATSCMH_RSFRAME_RES:
5559 ++ * Reserved. Shouldn't be used.
5560 ++ */
5561 + enum atscmh_rs_frame_mode {
5562 + ATSCMH_RSFRAME_PRI_ONLY = 0,
5563 + ATSCMH_RSFRAME_PRI_SEC = 1,
5564 + ATSCMH_RSFRAME_RES = 2,
5565 + };
5566 +
5567 ++/**
5568 ++ * enum atscmh_rs_code_mode
5569 ++ * @ATSCMH_RSCODE_211_187: Reed Solomon code (211,187).
5570 ++ * @ATSCMH_RSCODE_223_187: Reed Solomon code (223,187).
5571 ++ * @ATSCMH_RSCODE_235_187: Reed Solomon code (235,187).
5572 ++ * @ATSCMH_RSCODE_RES: Reserved. Shouldn't be used.
5573 ++ */
5574 + enum atscmh_rs_code_mode {
5575 + ATSCMH_RSCODE_211_187 = 0,
5576 + ATSCMH_RSCODE_223_187 = 1,
5577 +@@ -384,28 +732,18 @@ enum atscmh_rs_code_mode {
5578 + #define NO_STREAM_ID_FILTER (~0U)
5579 + #define LNA_AUTO (~0U)
5580 +
5581 +-struct dtv_cmds_h {
5582 +- char *name; /* A display name for debugging purposes */
5583 +-
5584 +- __u32 cmd; /* A unique ID */
5585 +-
5586 +- /* Flags */
5587 +- __u32 set:1; /* Either a set or get property */
5588 +- __u32 buffer:1; /* Does this property use the buffer? */
5589 +- __u32 reserved:30; /* Align */
5590 +-};
5591 +-
5592 + /**
5593 +- * Scale types for the quality parameters.
5594 ++ * enum fecap_scale_params - scale types for the quality parameters.
5595 ++ *
5596 + * @FE_SCALE_NOT_AVAILABLE: That QoS measure is not available. That
5597 + * could indicate a temporary or a permanent
5598 + * condition.
5599 + * @FE_SCALE_DECIBEL: The scale is measured in 0.001 dB steps, typically
5600 +- * used on signal measures.
5601 ++ * used on signal measures.
5602 + * @FE_SCALE_RELATIVE: The scale is a relative percentual measure,
5603 +- * ranging from 0 (0%) to 0xffff (100%).
5604 ++ * ranging from 0 (0%) to 0xffff (100%).
5605 + * @FE_SCALE_COUNTER: The scale counts the occurrence of an event, like
5606 +- * bit error, block error, lapsed time.
5607 ++ * bit error, block error, lapsed time.
5608 + */
5609 + enum fecap_scale_params {
5610 + FE_SCALE_NOT_AVAILABLE = 0,
5611 +@@ -417,24 +755,38 @@ enum fecap_scale_params {
5612 + /**
5613 + * struct dtv_stats - Used for reading a DTV status property
5614 + *
5615 +- * @value: value of the measure. Should range from 0 to 0xffff;
5616 + * @scale: Filled with enum fecap_scale_params - the scale
5617 + * in usage for that parameter
5618 + *
5619 ++ * The ``{unnamed_union}`` may have either one of the values below:
5620 ++ *
5621 ++ * %svalue
5622 ++ * integer value of the measure, for %FE_SCALE_DECIBEL,
5623 ++ * used for dB measures. The unit is 0.001 dB.
5624 ++ *
5625 ++ * %uvalue
5626 ++ * unsigned integer value of the measure, used when @scale is
5627 ++ * either %FE_SCALE_RELATIVE or %FE_SCALE_COUNTER.
5628 ++ *
5629 + * For most delivery systems, this will return a single value for each
5630 + * parameter.
5631 ++ *
5632 + * It should be noticed, however, that new OFDM delivery systems like
5633 + * ISDB can use different modulation types for each group of carriers.
5634 + * On such standards, up to 8 groups of statistics can be provided, one
5635 + * for each carrier group (called "layer" on ISDB).
5636 ++ *
5637 + * In order to be consistent with other delivery systems, the first
5638 + * value refers to the entire set of carriers ("global").
5639 +- * dtv_status:scale should use the value FE_SCALE_NOT_AVAILABLE when
5640 ++ *
5641 ++ * @scale should use the value %FE_SCALE_NOT_AVAILABLE when
5642 + * the value for the entire group of carriers or from one specific layer
5643 + * is not provided by the hardware.
5644 +- * st.len should be filled with the latest filled status + 1.
5645 + *
5646 +- * In other words, for ISDB, those values should be filled like:
5647 ++ * @len should be filled with the latest filled status + 1.
5648 ++ *
5649 ++ * In other words, for ISDB, those values should be filled like::
5650 ++ *
5651 + * u.st.stat.svalue[0] = global statistics;
5652 + * u.st.stat.scale[0] = FE_SCALE_DECIBEL;
5653 + * u.st.stat.value[1] = layer A statistics;
5654 +@@ -456,11 +808,39 @@ struct dtv_stats {
5655 +
5656 + #define MAX_DTV_STATS 4
5657 +
5658 ++/**
5659 ++ * struct dtv_fe_stats - store Digital TV frontend statistics
5660 ++ *
5661 ++ * @len: length of the statistics - if zero, stats is disabled.
5662 ++ * @stat: array with digital TV statistics.
5663 ++ *
5664 ++ * On most standards, @len can either be 0 or 1. However, for ISDB, each
5665 ++ * layer is modulated in separate. So, each layer may have its own set
5666 ++ * of statistics. If so, stat[0] carries on a global value for the property.
5667 ++ * Indexes 1 to 3 means layer A to B.
5668 ++ */
5669 + struct dtv_fe_stats {
5670 + __u8 len;
5671 + struct dtv_stats stat[MAX_DTV_STATS];
5672 + } __attribute__ ((packed));
5673 +
5674 ++/**
5675 ++ * struct dtv_property - store one of frontend command and its value
5676 ++ *
5677 ++ * @cmd: Digital TV command.
5678 ++ * @reserved: Not used.
5679 ++ * @u: Union with the values for the command.
5680 ++ * @result: Unused
5681 ++ *
5682 ++ * The @u union may have either one of the values below:
5683 ++ *
5684 ++ * %data
5685 ++ * an unsigned 32-bits number.
5686 ++ * %st
5687 ++ * a &struct dtv_fe_stats array of statistics.
5688 ++ * %buffer
5689 ++ * a buffer of up to 32 characters (currently unused).
5690 ++ */
5691 + struct dtv_property {
5692 + __u32 cmd;
5693 + __u32 reserved[3];
5694 +@@ -480,17 +860,70 @@ struct dtv_property {
5695 + /* num of properties cannot exceed DTV_IOCTL_MAX_MSGS per ioctl */
5696 + #define DTV_IOCTL_MAX_MSGS 64
5697 +
5698 ++/**
5699 ++ * struct dtv_properties - a set of command/value pairs.
5700 ++ *
5701 ++ * @num: amount of commands stored at the struct.
5702 ++ * @props: a pointer to &struct dtv_property.
5703 ++ */
5704 + struct dtv_properties {
5705 + __u32 num;
5706 + struct dtv_property *props;
5707 + };
5708 +
5709 ++/*
5710 ++ * When set, this flag will disable any zigzagging or other "normal" tuning
5711 ++ * behavior. Additionally, there will be no automatic monitoring of the lock
5712 ++ * status, and hence no frontend events will be generated. If a frontend device
5713 ++ * is closed, this flag will be automatically turned off when the device is
5714 ++ * reopened read-write.
5715 ++ */
5716 ++#define FE_TUNE_MODE_ONESHOT 0x01
5717 ++
5718 ++/* Digital TV Frontend API calls */
5719 ++
5720 ++#define FE_GET_INFO _IOR('o', 61, struct dvb_frontend_info)
5721 ++
5722 ++#define FE_DISEQC_RESET_OVERLOAD _IO('o', 62)
5723 ++#define FE_DISEQC_SEND_MASTER_CMD _IOW('o', 63, struct dvb_diseqc_master_cmd)
5724 ++#define FE_DISEQC_RECV_SLAVE_REPLY _IOR('o', 64, struct dvb_diseqc_slave_reply)
5725 ++#define FE_DISEQC_SEND_BURST _IO('o', 65) /* fe_sec_mini_cmd_t */
5726 ++
5727 ++#define FE_SET_TONE _IO('o', 66) /* fe_sec_tone_mode_t */
5728 ++#define FE_SET_VOLTAGE _IO('o', 67) /* fe_sec_voltage_t */
5729 ++#define FE_ENABLE_HIGH_LNB_VOLTAGE _IO('o', 68) /* int */
5730 ++
5731 ++#define FE_READ_STATUS _IOR('o', 69, fe_status_t)
5732 ++#define FE_READ_BER _IOR('o', 70, __u32)
5733 ++#define FE_READ_SIGNAL_STRENGTH _IOR('o', 71, __u16)
5734 ++#define FE_READ_SNR _IOR('o', 72, __u16)
5735 ++#define FE_READ_UNCORRECTED_BLOCKS _IOR('o', 73, __u32)
5736 ++
5737 ++#define FE_SET_FRONTEND_TUNE_MODE _IO('o', 81) /* unsigned int */
5738 ++#define FE_GET_EVENT _IOR('o', 78, struct dvb_frontend_event)
5739 ++
5740 ++#define FE_DISHNETWORK_SEND_LEGACY_CMD _IO('o', 80) /* unsigned int */
5741 ++
5742 ++#define FE_SET_PROPERTY _IOW('o', 82, struct dtv_properties)
5743 ++#define FE_GET_PROPERTY _IOR('o', 83, struct dtv_properties)
5744 ++
5745 + #if defined(__DVB_CORE__) || !defined (__KERNEL__)
5746 +
5747 + /*
5748 +- * DEPRECATED: The DVBv3 ioctls, structs and enums should not be used on
5749 +- * newer programs, as it doesn't support the second generation of digital
5750 +- * TV standards, nor supports newer delivery systems.
5751 ++ * DEPRECATED: Everything below is deprecated in favor of DVBv5 API
5752 ++ *
5753 ++ * The DVBv3 only ioctls, structs and enums should not be used on
5754 ++ * newer programs, as it doesn't support the second generation of
5755 ++ * digital TV standards, nor supports newer delivery systems.
5756 ++ * They also don't support modern frontends with usually support multiple
5757 ++ * delivery systems.
5758 ++ *
5759 ++ * Drivers shouldn't use them.
5760 ++ *
5761 ++ * New applications should use DVBv5 delivery system instead
5762 ++ */
5763 ++
5764 ++/*
5765 + */
5766 +
5767 + enum fe_bandwidth {
5768 +@@ -503,7 +936,7 @@ enum fe_bandwidth {
5769 + BANDWIDTH_1_712_MHZ,
5770 + };
5771 +
5772 +-/* This is needed for legacy userspace support */
5773 ++/* This is kept for legacy userspace support */
5774 + typedef enum fe_sec_voltage fe_sec_voltage_t;
5775 + typedef enum fe_caps fe_caps_t;
5776 + typedef enum fe_type fe_type_t;
5777 +@@ -521,6 +954,8 @@ typedef enum fe_pilot fe_pilot_t;
5778 + typedef enum fe_rolloff fe_rolloff_t;
5779 + typedef enum fe_delivery_system fe_delivery_system_t;
5780 +
5781 ++/* DVBv3 structs */
5782 ++
5783 + struct dvb_qpsk_parameters {
5784 + __u32 symbol_rate; /* symbol rate in Symbols per second */
5785 + fe_code_rate_t fec_inner; /* forward error correction (see above) */
5786 +@@ -562,42 +997,12 @@ struct dvb_frontend_event {
5787 + fe_status_t status;
5788 + struct dvb_frontend_parameters parameters;
5789 + };
5790 +-#endif
5791 +
5792 +-#define FE_SET_PROPERTY _IOW('o', 82, struct dtv_properties)
5793 +-#define FE_GET_PROPERTY _IOR('o', 83, struct dtv_properties)
5794 +-
5795 +-/**
5796 +- * When set, this flag will disable any zigzagging or other "normal" tuning
5797 +- * behaviour. Additionally, there will be no automatic monitoring of the lock
5798 +- * status, and hence no frontend events will be generated. If a frontend device
5799 +- * is closed, this flag will be automatically turned off when the device is
5800 +- * reopened read-write.
5801 +- */
5802 +-#define FE_TUNE_MODE_ONESHOT 0x01
5803 +-
5804 +-#define FE_GET_INFO _IOR('o', 61, struct dvb_frontend_info)
5805 +-
5806 +-#define FE_DISEQC_RESET_OVERLOAD _IO('o', 62)
5807 +-#define FE_DISEQC_SEND_MASTER_CMD _IOW('o', 63, struct dvb_diseqc_master_cmd)
5808 +-#define FE_DISEQC_RECV_SLAVE_REPLY _IOR('o', 64, struct dvb_diseqc_slave_reply)
5809 +-#define FE_DISEQC_SEND_BURST _IO('o', 65) /* fe_sec_mini_cmd_t */
5810 +-
5811 +-#define FE_SET_TONE _IO('o', 66) /* fe_sec_tone_mode_t */
5812 +-#define FE_SET_VOLTAGE _IO('o', 67) /* fe_sec_voltage_t */
5813 +-#define FE_ENABLE_HIGH_LNB_VOLTAGE _IO('o', 68) /* int */
5814 +-
5815 +-#define FE_READ_STATUS _IOR('o', 69, fe_status_t)
5816 +-#define FE_READ_BER _IOR('o', 70, __u32)
5817 +-#define FE_READ_SIGNAL_STRENGTH _IOR('o', 71, __u16)
5818 +-#define FE_READ_SNR _IOR('o', 72, __u16)
5819 +-#define FE_READ_UNCORRECTED_BLOCKS _IOR('o', 73, __u32)
5820 ++/* DVBv3 API calls */
5821 +
5822 + #define FE_SET_FRONTEND _IOW('o', 76, struct dvb_frontend_parameters)
5823 + #define FE_GET_FRONTEND _IOR('o', 77, struct dvb_frontend_parameters)
5824 +-#define FE_SET_FRONTEND_TUNE_MODE _IO('o', 81) /* unsigned int */
5825 +-#define FE_GET_EVENT _IOR('o', 78, struct dvb_frontend_event)
5826 +
5827 +-#define FE_DISHNETWORK_SEND_LEGACY_CMD _IO('o', 80) /* unsigned int */
5828 ++#endif
5829 +
5830 + #endif /*_DVBFRONTEND_H_*/
5831 +diff --git a/kernel/kprobes.c b/kernel/kprobes.c
5832 +index 1b75fb8c7735..a864e94ecb6b 100644
5833 +--- a/kernel/kprobes.c
5834 ++++ b/kernel/kprobes.c
5835 +@@ -561,11 +561,12 @@ static void kprobe_optimizer(struct work_struct *work)
5836 + do_free_cleaned_kprobes();
5837 +
5838 + mutex_unlock(&module_mutex);
5839 +- mutex_unlock(&kprobe_mutex);
5840 +
5841 + /* Step 5: Kick optimizer again if needed */
5842 + if (!list_empty(&optimizing_list) || !list_empty(&unoptimizing_list))
5843 + kick_kprobe_optimizer();
5844 ++
5845 ++ mutex_unlock(&kprobe_mutex);
5846 + }
5847 +
5848 + /* Wait for completing optimization and unoptimization */
5849 +@@ -1149,6 +1150,26 @@ __releases(hlist_lock)
5850 + }
5851 + NOKPROBE_SYMBOL(kretprobe_table_unlock);
5852 +
5853 ++struct kprobe kprobe_busy = {
5854 ++ .addr = (void *) get_kprobe,
5855 ++};
5856 ++
5857 ++void kprobe_busy_begin(void)
5858 ++{
5859 ++ struct kprobe_ctlblk *kcb;
5860 ++
5861 ++ preempt_disable();
5862 ++ __this_cpu_write(current_kprobe, &kprobe_busy);
5863 ++ kcb = get_kprobe_ctlblk();
5864 ++ kcb->kprobe_status = KPROBE_HIT_ACTIVE;
5865 ++}
5866 ++
5867 ++void kprobe_busy_end(void)
5868 ++{
5869 ++ __this_cpu_write(current_kprobe, NULL);
5870 ++ preempt_enable();
5871 ++}
5872 ++
5873 + /*
5874 + * This function is called from finish_task_switch when task tk becomes dead,
5875 + * so that we can recycle any function-return probe instances associated
5876 +@@ -1166,6 +1187,8 @@ void kprobe_flush_task(struct task_struct *tk)
5877 + /* Early boot. kretprobe_table_locks not yet initialized. */
5878 + return;
5879 +
5880 ++ kprobe_busy_begin();
5881 ++
5882 + INIT_HLIST_HEAD(&empty_rp);
5883 + hash = hash_ptr(tk, KPROBE_HASH_BITS);
5884 + head = &kretprobe_inst_table[hash];
5885 +@@ -1179,6 +1202,8 @@ void kprobe_flush_task(struct task_struct *tk)
5886 + hlist_del(&ri->hlist);
5887 + kfree(ri);
5888 + }
5889 ++
5890 ++ kprobe_busy_end();
5891 + }
5892 + NOKPROBE_SYMBOL(kprobe_flush_task);
5893 +
5894 +diff --git a/kernel/sched/core.c b/kernel/sched/core.c
5895 +index 82cec9a666e7..870d802c46f9 100644
5896 +--- a/kernel/sched/core.c
5897 ++++ b/kernel/sched/core.c
5898 +@@ -3697,7 +3697,8 @@ void rt_mutex_setprio(struct task_struct *p, int prio)
5899 + if (dl_prio(prio)) {
5900 + struct task_struct *pi_task = rt_mutex_get_top_task(p);
5901 + if (!dl_prio(p->normal_prio) ||
5902 +- (pi_task && dl_entity_preempt(&pi_task->dl, &p->dl))) {
5903 ++ (pi_task && dl_prio(pi_task->prio) &&
5904 ++ dl_entity_preempt(&pi_task->dl, &p->dl))) {
5905 + p->dl.dl_boosted = 1;
5906 + queue_flag |= ENQUEUE_REPLENISH;
5907 + } else
5908 +diff --git a/kernel/trace/blktrace.c b/kernel/trace/blktrace.c
5909 +index 6d3b432a748a..88eb9261c7b5 100644
5910 +--- a/kernel/trace/blktrace.c
5911 ++++ b/kernel/trace/blktrace.c
5912 +@@ -15,6 +15,9 @@
5913 + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
5914 + *
5915 + */
5916 ++
5917 ++#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
5918 ++
5919 + #include <linux/kernel.h>
5920 + #include <linux/blkdev.h>
5921 + #include <linux/blktrace_api.h>
5922 +@@ -481,6 +484,16 @@ int do_blk_trace_setup(struct request_queue *q, char *name, dev_t dev,
5923 + */
5924 + strreplace(buts->name, '/', '_');
5925 +
5926 ++ /*
5927 ++ * bdev can be NULL, as with scsi-generic, this is a helpful as
5928 ++ * we can be.
5929 ++ */
5930 ++ if (q->blk_trace) {
5931 ++ pr_warn("Concurrent blktraces are not allowed on %s\n",
5932 ++ buts->name);
5933 ++ return -EBUSY;
5934 ++ }
5935 ++
5936 + bt = kzalloc(sizeof(*bt), GFP_KERNEL);
5937 + if (!bt)
5938 + return -ENOMEM;
5939 +diff --git a/kernel/trace/trace_events_trigger.c b/kernel/trace/trace_events_trigger.c
5940 +index c9ca2ed50c0e..a371c7def875 100644
5941 +--- a/kernel/trace/trace_events_trigger.c
5942 ++++ b/kernel/trace/trace_events_trigger.c
5943 +@@ -222,11 +222,17 @@ static int event_trigger_regex_open(struct inode *inode, struct file *file)
5944 +
5945 + static int trigger_process_regex(struct trace_event_file *file, char *buff)
5946 + {
5947 +- char *command, *next = buff;
5948 ++ char *command, *next;
5949 + struct event_command *p;
5950 + int ret = -EINVAL;
5951 +
5952 ++ next = buff = skip_spaces(buff);
5953 + command = strsep(&next, ": \t");
5954 ++ if (next) {
5955 ++ next = skip_spaces(next);
5956 ++ if (!*next)
5957 ++ next = NULL;
5958 ++ }
5959 + command = (command[0] != '!') ? command : command + 1;
5960 +
5961 + mutex_lock(&trigger_cmd_mutex);
5962 +@@ -629,8 +635,14 @@ event_trigger_callback(struct event_command *cmd_ops,
5963 + int ret;
5964 +
5965 + /* separate the trigger from the filter (t:n [if filter]) */
5966 +- if (param && isdigit(param[0]))
5967 ++ if (param && isdigit(param[0])) {
5968 + trigger = strsep(&param, " \t");
5969 ++ if (param) {
5970 ++ param = skip_spaces(param);
5971 ++ if (!*param)
5972 ++ param = NULL;
5973 ++ }
5974 ++ }
5975 +
5976 + trigger_ops = cmd_ops->get_trigger_ops(cmd, trigger);
5977 +
5978 +@@ -1335,6 +1347,11 @@ int event_enable_trigger_func(struct event_command *cmd_ops,
5979 + trigger = strsep(&param, " \t");
5980 + if (!trigger)
5981 + return -EINVAL;
5982 ++ if (param) {
5983 ++ param = skip_spaces(param);
5984 ++ if (!*param)
5985 ++ param = NULL;
5986 ++ }
5987 +
5988 + system = strsep(&trigger, ":");
5989 + if (!trigger)
5990 +diff --git a/lib/zlib_inflate/inffast.c b/lib/zlib_inflate/inffast.c
5991 +index 2c13ecc5bb2c..ed1f3df27260 100644
5992 +--- a/lib/zlib_inflate/inffast.c
5993 ++++ b/lib/zlib_inflate/inffast.c
5994 +@@ -10,17 +10,6 @@
5995 +
5996 + #ifndef ASMINF
5997 +
5998 +-/* Allow machine dependent optimization for post-increment or pre-increment.
5999 +- Based on testing to date,
6000 +- Pre-increment preferred for:
6001 +- - PowerPC G3 (Adler)
6002 +- - MIPS R5000 (Randers-Pehrson)
6003 +- Post-increment preferred for:
6004 +- - none
6005 +- No measurable difference:
6006 +- - Pentium III (Anderson)
6007 +- - M68060 (Nikl)
6008 +- */
6009 + union uu {
6010 + unsigned short us;
6011 + unsigned char b[2];
6012 +@@ -38,16 +27,6 @@ get_unaligned16(const unsigned short *p)
6013 + return mm.us;
6014 + }
6015 +
6016 +-#ifdef POSTINC
6017 +-# define OFF 0
6018 +-# define PUP(a) *(a)++
6019 +-# define UP_UNALIGNED(a) get_unaligned16((a)++)
6020 +-#else
6021 +-# define OFF 1
6022 +-# define PUP(a) *++(a)
6023 +-# define UP_UNALIGNED(a) get_unaligned16(++(a))
6024 +-#endif
6025 +-
6026 + /*
6027 + Decode literal, length, and distance codes and write out the resulting
6028 + literal and match bytes until either not enough input or output is
6029 +@@ -115,9 +94,9 @@ void inflate_fast(z_streamp strm, unsigned start)
6030 +
6031 + /* copy state to local variables */
6032 + state = (struct inflate_state *)strm->state;
6033 +- in = strm->next_in - OFF;
6034 ++ in = strm->next_in;
6035 + last = in + (strm->avail_in - 5);
6036 +- out = strm->next_out - OFF;
6037 ++ out = strm->next_out;
6038 + beg = out - (start - strm->avail_out);
6039 + end = out + (strm->avail_out - 257);
6040 + #ifdef INFLATE_STRICT
6041 +@@ -138,9 +117,9 @@ void inflate_fast(z_streamp strm, unsigned start)
6042 + input data or output space */
6043 + do {
6044 + if (bits < 15) {
6045 +- hold += (unsigned long)(PUP(in)) << bits;
6046 ++ hold += (unsigned long)(*in++) << bits;
6047 + bits += 8;
6048 +- hold += (unsigned long)(PUP(in)) << bits;
6049 ++ hold += (unsigned long)(*in++) << bits;
6050 + bits += 8;
6051 + }
6052 + this = lcode[hold & lmask];
6053 +@@ -150,14 +129,14 @@ void inflate_fast(z_streamp strm, unsigned start)
6054 + bits -= op;
6055 + op = (unsigned)(this.op);
6056 + if (op == 0) { /* literal */
6057 +- PUP(out) = (unsigned char)(this.val);
6058 ++ *out++ = (unsigned char)(this.val);
6059 + }
6060 + else if (op & 16) { /* length base */
6061 + len = (unsigned)(this.val);
6062 + op &= 15; /* number of extra bits */
6063 + if (op) {
6064 + if (bits < op) {
6065 +- hold += (unsigned long)(PUP(in)) << bits;
6066 ++ hold += (unsigned long)(*in++) << bits;
6067 + bits += 8;
6068 + }
6069 + len += (unsigned)hold & ((1U << op) - 1);
6070 +@@ -165,9 +144,9 @@ void inflate_fast(z_streamp strm, unsigned start)
6071 + bits -= op;
6072 + }
6073 + if (bits < 15) {
6074 +- hold += (unsigned long)(PUP(in)) << bits;
6075 ++ hold += (unsigned long)(*in++) << bits;
6076 + bits += 8;
6077 +- hold += (unsigned long)(PUP(in)) << bits;
6078 ++ hold += (unsigned long)(*in++) << bits;
6079 + bits += 8;
6080 + }
6081 + this = dcode[hold & dmask];
6082 +@@ -180,10 +159,10 @@ void inflate_fast(z_streamp strm, unsigned start)
6083 + dist = (unsigned)(this.val);
6084 + op &= 15; /* number of extra bits */
6085 + if (bits < op) {
6086 +- hold += (unsigned long)(PUP(in)) << bits;
6087 ++ hold += (unsigned long)(*in++) << bits;
6088 + bits += 8;
6089 + if (bits < op) {
6090 +- hold += (unsigned long)(PUP(in)) << bits;
6091 ++ hold += (unsigned long)(*in++) << bits;
6092 + bits += 8;
6093 + }
6094 + }
6095 +@@ -205,13 +184,13 @@ void inflate_fast(z_streamp strm, unsigned start)
6096 + state->mode = BAD;
6097 + break;
6098 + }
6099 +- from = window - OFF;
6100 ++ from = window;
6101 + if (write == 0) { /* very common case */
6102 + from += wsize - op;
6103 + if (op < len) { /* some from window */
6104 + len -= op;
6105 + do {
6106 +- PUP(out) = PUP(from);
6107 ++ *out++ = *from++;
6108 + } while (--op);
6109 + from = out - dist; /* rest from output */
6110 + }
6111 +@@ -222,14 +201,14 @@ void inflate_fast(z_streamp strm, unsigned start)
6112 + if (op < len) { /* some from end of window */
6113 + len -= op;
6114 + do {
6115 +- PUP(out) = PUP(from);
6116 ++ *out++ = *from++;
6117 + } while (--op);
6118 +- from = window - OFF;
6119 ++ from = window;
6120 + if (write < len) { /* some from start of window */
6121 + op = write;
6122 + len -= op;
6123 + do {
6124 +- PUP(out) = PUP(from);
6125 ++ *out++ = *from++;
6126 + } while (--op);
6127 + from = out - dist; /* rest from output */
6128 + }
6129 +@@ -240,21 +219,21 @@ void inflate_fast(z_streamp strm, unsigned start)
6130 + if (op < len) { /* some from window */
6131 + len -= op;
6132 + do {
6133 +- PUP(out) = PUP(from);
6134 ++ *out++ = *from++;
6135 + } while (--op);
6136 + from = out - dist; /* rest from output */
6137 + }
6138 + }
6139 + while (len > 2) {
6140 +- PUP(out) = PUP(from);
6141 +- PUP(out) = PUP(from);
6142 +- PUP(out) = PUP(from);
6143 ++ *out++ = *from++;
6144 ++ *out++ = *from++;
6145 ++ *out++ = *from++;
6146 + len -= 3;
6147 + }
6148 + if (len) {
6149 +- PUP(out) = PUP(from);
6150 ++ *out++ = *from++;
6151 + if (len > 1)
6152 +- PUP(out) = PUP(from);
6153 ++ *out++ = *from++;
6154 + }
6155 + }
6156 + else {
6157 +@@ -264,29 +243,29 @@ void inflate_fast(z_streamp strm, unsigned start)
6158 + from = out - dist; /* copy direct from output */
6159 + /* minimum length is three */
6160 + /* Align out addr */
6161 +- if (!((long)(out - 1 + OFF) & 1)) {
6162 +- PUP(out) = PUP(from);
6163 ++ if (!((long)(out - 1) & 1)) {
6164 ++ *out++ = *from++;
6165 + len--;
6166 + }
6167 +- sout = (unsigned short *)(out - OFF);
6168 ++ sout = (unsigned short *)(out);
6169 + if (dist > 2) {
6170 + unsigned short *sfrom;
6171 +
6172 +- sfrom = (unsigned short *)(from - OFF);
6173 ++ sfrom = (unsigned short *)(from);
6174 + loops = len >> 1;
6175 + do
6176 + #ifdef CONFIG_HAVE_EFFICIENT_UNALIGNED_ACCESS
6177 +- PUP(sout) = PUP(sfrom);
6178 ++ *sout++ = *sfrom++;
6179 + #else
6180 +- PUP(sout) = UP_UNALIGNED(sfrom);
6181 ++ *sout++ = get_unaligned16(sfrom++);
6182 + #endif
6183 + while (--loops);
6184 +- out = (unsigned char *)sout + OFF;
6185 +- from = (unsigned char *)sfrom + OFF;
6186 ++ out = (unsigned char *)sout;
6187 ++ from = (unsigned char *)sfrom;
6188 + } else { /* dist == 1 or dist == 2 */
6189 + unsigned short pat16;
6190 +
6191 +- pat16 = *(sout-1+OFF);
6192 ++ pat16 = *(sout-1);
6193 + if (dist == 1) {
6194 + union uu mm;
6195 + /* copy one char pattern to both bytes */
6196 +@@ -296,12 +275,12 @@ void inflate_fast(z_streamp strm, unsigned start)
6197 + }
6198 + loops = len >> 1;
6199 + do
6200 +- PUP(sout) = pat16;
6201 ++ *sout++ = pat16;
6202 + while (--loops);
6203 +- out = (unsigned char *)sout + OFF;
6204 ++ out = (unsigned char *)sout;
6205 + }
6206 + if (len & 1)
6207 +- PUP(out) = PUP(from);
6208 ++ *out++ = *from++;
6209 + }
6210 + }
6211 + else if ((op & 64) == 0) { /* 2nd level distance code */
6212 +@@ -336,8 +315,8 @@ void inflate_fast(z_streamp strm, unsigned start)
6213 + hold &= (1U << bits) - 1;
6214 +
6215 + /* update state and return */
6216 +- strm->next_in = in + OFF;
6217 +- strm->next_out = out + OFF;
6218 ++ strm->next_in = in;
6219 ++ strm->next_out = out;
6220 + strm->avail_in = (unsigned)(in < last ? 5 + (last - in) : 5 - (in - last));
6221 + strm->avail_out = (unsigned)(out < end ?
6222 + 257 + (end - out) : 257 - (out - end));
6223 +diff --git a/mm/slab_common.c b/mm/slab_common.c
6224 +index 13f1926f8fcd..26c4d4722927 100644
6225 +--- a/mm/slab_common.c
6226 ++++ b/mm/slab_common.c
6227 +@@ -1345,7 +1345,7 @@ void kzfree(const void *p)
6228 + if (unlikely(ZERO_OR_NULL_PTR(mem)))
6229 + return;
6230 + ks = ksize(mem);
6231 +- memset(mem, 0, ks);
6232 ++ memzero_explicit(mem, ks);
6233 + kfree(mem);
6234 + }
6235 + EXPORT_SYMBOL(kzfree);
6236 +diff --git a/net/core/dev.c b/net/core/dev.c
6237 +index 1041523aaa76..267b648a0645 100644
6238 +--- a/net/core/dev.c
6239 ++++ b/net/core/dev.c
6240 +@@ -82,6 +82,7 @@
6241 + #include <linux/slab.h>
6242 + #include <linux/sched.h>
6243 + #include <linux/mutex.h>
6244 ++#include <linux/rwsem.h>
6245 + #include <linux/string.h>
6246 + #include <linux/mm.h>
6247 + #include <linux/socket.h>
6248 +@@ -189,7 +190,7 @@ static DEFINE_SPINLOCK(napi_hash_lock);
6249 + static unsigned int napi_gen_id = NR_CPUS;
6250 + static DEFINE_READ_MOSTLY_HASHTABLE(napi_hash, 8);
6251 +
6252 +-static seqcount_t devnet_rename_seq;
6253 ++static DECLARE_RWSEM(devnet_rename_sem);
6254 +
6255 + static inline void dev_base_seq_inc(struct net *net)
6256 + {
6257 +@@ -866,33 +867,28 @@ EXPORT_SYMBOL(dev_get_by_index);
6258 + * @net: network namespace
6259 + * @name: a pointer to the buffer where the name will be stored.
6260 + * @ifindex: the ifindex of the interface to get the name from.
6261 +- *
6262 +- * The use of raw_seqcount_begin() and cond_resched() before
6263 +- * retrying is required as we want to give the writers a chance
6264 +- * to complete when CONFIG_PREEMPT is not set.
6265 + */
6266 + int netdev_get_name(struct net *net, char *name, int ifindex)
6267 + {
6268 + struct net_device *dev;
6269 +- unsigned int seq;
6270 ++ int ret;
6271 +
6272 +-retry:
6273 +- seq = raw_seqcount_begin(&devnet_rename_seq);
6274 ++ down_read(&devnet_rename_sem);
6275 + rcu_read_lock();
6276 ++
6277 + dev = dev_get_by_index_rcu(net, ifindex);
6278 + if (!dev) {
6279 +- rcu_read_unlock();
6280 +- return -ENODEV;
6281 ++ ret = -ENODEV;
6282 ++ goto out;
6283 + }
6284 +
6285 + strcpy(name, dev->name);
6286 +- rcu_read_unlock();
6287 +- if (read_seqcount_retry(&devnet_rename_seq, seq)) {
6288 +- cond_resched();
6289 +- goto retry;
6290 +- }
6291 +
6292 +- return 0;
6293 ++ ret = 0;
6294 ++out:
6295 ++ rcu_read_unlock();
6296 ++ up_read(&devnet_rename_sem);
6297 ++ return ret;
6298 + }
6299 +
6300 + /**
6301 +@@ -1157,10 +1153,10 @@ int dev_change_name(struct net_device *dev, const char *newname)
6302 + if (dev->flags & IFF_UP)
6303 + return -EBUSY;
6304 +
6305 +- write_seqcount_begin(&devnet_rename_seq);
6306 ++ down_write(&devnet_rename_sem);
6307 +
6308 + if (strncmp(newname, dev->name, IFNAMSIZ) == 0) {
6309 +- write_seqcount_end(&devnet_rename_seq);
6310 ++ up_write(&devnet_rename_sem);
6311 + return 0;
6312 + }
6313 +
6314 +@@ -1168,7 +1164,7 @@ int dev_change_name(struct net_device *dev, const char *newname)
6315 +
6316 + err = dev_get_valid_name(net, dev, newname);
6317 + if (err < 0) {
6318 +- write_seqcount_end(&devnet_rename_seq);
6319 ++ up_write(&devnet_rename_sem);
6320 + return err;
6321 + }
6322 +
6323 +@@ -1183,11 +1179,11 @@ rollback:
6324 + if (ret) {
6325 + memcpy(dev->name, oldname, IFNAMSIZ);
6326 + dev->name_assign_type = old_assign_type;
6327 +- write_seqcount_end(&devnet_rename_seq);
6328 ++ up_write(&devnet_rename_sem);
6329 + return ret;
6330 + }
6331 +
6332 +- write_seqcount_end(&devnet_rename_seq);
6333 ++ up_write(&devnet_rename_sem);
6334 +
6335 + netdev_adjacent_rename_links(dev, oldname);
6336 +
6337 +@@ -1208,7 +1204,7 @@ rollback:
6338 + /* err >= 0 after dev_alloc_name() or stores the first errno */
6339 + if (err >= 0) {
6340 + err = ret;
6341 +- write_seqcount_begin(&devnet_rename_seq);
6342 ++ down_write(&devnet_rename_sem);
6343 + memcpy(dev->name, oldname, IFNAMSIZ);
6344 + memcpy(oldname, newname, IFNAMSIZ);
6345 + dev->name_assign_type = old_assign_type;
6346 +@@ -7359,6 +7355,13 @@ int register_netdevice(struct net_device *dev)
6347 + rcu_barrier();
6348 +
6349 + dev->reg_state = NETREG_UNREGISTERED;
6350 ++ /* We should put the kobject that hold in
6351 ++ * netdev_unregister_kobject(), otherwise
6352 ++ * the net device cannot be freed when
6353 ++ * driver calls free_netdev(), because the
6354 ++ * kobject is being hold.
6355 ++ */
6356 ++ kobject_put(&dev->dev.kobj);
6357 + }
6358 + /*
6359 + * Prevent userspace races by waiting until the network
6360 +diff --git a/net/core/sock.c b/net/core/sock.c
6361 +index 41794a698da6..dac9365151df 100644
6362 +--- a/net/core/sock.c
6363 ++++ b/net/core/sock.c
6364 +@@ -1403,6 +1403,7 @@ struct sock *sk_alloc(struct net *net, int family, gfp_t priority,
6365 + cgroup_sk_alloc(&sk->sk_cgrp_data);
6366 + sock_update_classid(&sk->sk_cgrp_data);
6367 + sock_update_netprioidx(&sk->sk_cgrp_data);
6368 ++ sk_tx_queue_clear(sk);
6369 + }
6370 +
6371 + return sk;
6372 +@@ -1587,6 +1588,7 @@ struct sock *sk_clone_lock(const struct sock *sk, const gfp_t priority)
6373 + */
6374 + sk_refcnt_debug_inc(newsk);
6375 + sk_set_socket(newsk, NULL);
6376 ++ sk_tx_queue_clear(newsk);
6377 + newsk->sk_wq = NULL;
6378 +
6379 + if (newsk->sk_prot->sockets_allocated)
6380 +diff --git a/net/ipv4/fib_semantics.c b/net/ipv4/fib_semantics.c
6381 +index 6aec95e1fc13..305104d116d6 100644
6382 +--- a/net/ipv4/fib_semantics.c
6383 ++++ b/net/ipv4/fib_semantics.c
6384 +@@ -776,7 +776,7 @@ static int fib_check_nh(struct fib_config *cfg, struct fib_info *fi,
6385 + if (fl4.flowi4_scope < RT_SCOPE_LINK)
6386 + fl4.flowi4_scope = RT_SCOPE_LINK;
6387 +
6388 +- if (cfg->fc_table)
6389 ++ if (cfg->fc_table && cfg->fc_table != RT_TABLE_MAIN)
6390 + tbl = fib_get_table(net, cfg->fc_table);
6391 +
6392 + if (tbl)
6393 +diff --git a/net/ipv4/ip_tunnel.c b/net/ipv4/ip_tunnel.c
6394 +index dd5db4cc7d06..5f2e3334ccce 100644
6395 +--- a/net/ipv4/ip_tunnel.c
6396 ++++ b/net/ipv4/ip_tunnel.c
6397 +@@ -98,9 +98,10 @@ struct ip_tunnel *ip_tunnel_lookup(struct ip_tunnel_net *itn,
6398 + __be32 remote, __be32 local,
6399 + __be32 key)
6400 + {
6401 +- unsigned int hash;
6402 + struct ip_tunnel *t, *cand = NULL;
6403 + struct hlist_head *head;
6404 ++ struct net_device *ndev;
6405 ++ unsigned int hash;
6406 +
6407 + hash = ip_tunnel_hash(key, remote);
6408 + head = &itn->tunnels[hash];
6409 +@@ -175,8 +176,9 @@ struct ip_tunnel *ip_tunnel_lookup(struct ip_tunnel_net *itn,
6410 + if (t)
6411 + return t;
6412 +
6413 +- if (itn->fb_tunnel_dev && itn->fb_tunnel_dev->flags & IFF_UP)
6414 +- return netdev_priv(itn->fb_tunnel_dev);
6415 ++ ndev = READ_ONCE(itn->fb_tunnel_dev);
6416 ++ if (ndev && ndev->flags & IFF_UP)
6417 ++ return netdev_priv(ndev);
6418 +
6419 + return NULL;
6420 + }
6421 +@@ -1193,9 +1195,9 @@ void ip_tunnel_uninit(struct net_device *dev)
6422 + struct ip_tunnel_net *itn;
6423 +
6424 + itn = net_generic(net, tunnel->ip_tnl_net_id);
6425 +- /* fb_tunnel_dev will be unregisted in net-exit call. */
6426 +- if (itn->fb_tunnel_dev != dev)
6427 +- ip_tunnel_del(itn, netdev_priv(dev));
6428 ++ ip_tunnel_del(itn, netdev_priv(dev));
6429 ++ if (itn->fb_tunnel_dev == dev)
6430 ++ WRITE_ONCE(itn->fb_tunnel_dev, NULL);
6431 +
6432 + dst_cache_reset(&tunnel->dst_cache);
6433 + }
6434 +diff --git a/net/ipv4/tcp_cubic.c b/net/ipv4/tcp_cubic.c
6435 +index c99230efcd52..00397c6add20 100644
6436 +--- a/net/ipv4/tcp_cubic.c
6437 ++++ b/net/ipv4/tcp_cubic.c
6438 +@@ -414,6 +414,8 @@ static void hystart_update(struct sock *sk, u32 delay)
6439 +
6440 + if (hystart_detect & HYSTART_DELAY) {
6441 + /* obtain the minimum delay of more than sampling packets */
6442 ++ if (ca->curr_rtt > delay)
6443 ++ ca->curr_rtt = delay;
6444 + if (ca->sample_cnt < HYSTART_MIN_SAMPLES) {
6445 + if (ca->curr_rtt == 0 || ca->curr_rtt > delay)
6446 + ca->curr_rtt = delay;
6447 +diff --git a/net/ipv4/tcp_input.c b/net/ipv4/tcp_input.c
6448 +index 52014c5312b9..b3953f789891 100644
6449 +--- a/net/ipv4/tcp_input.c
6450 ++++ b/net/ipv4/tcp_input.c
6451 +@@ -4537,7 +4537,11 @@ static void tcp_data_queue_ofo(struct sock *sk, struct sk_buff *skb)
6452 + if (tcp_ooo_try_coalesce(sk, tp->ooo_last_skb,
6453 + skb, &fragstolen)) {
6454 + coalesce_done:
6455 +- tcp_grow_window(sk, skb);
6456 ++ /* For non sack flows, do not grow window to force DUPACK
6457 ++ * and trigger fast retransmit.
6458 ++ */
6459 ++ if (tcp_is_sack(tp))
6460 ++ tcp_grow_window(sk, skb);
6461 + kfree_skb_partial(skb, fragstolen);
6462 + skb = NULL;
6463 + goto add_sack;
6464 +@@ -4621,7 +4625,11 @@ add_sack:
6465 + tcp_sack_new_ofo_skb(sk, seq, end_seq);
6466 + end:
6467 + if (skb) {
6468 +- tcp_grow_window(sk, skb);
6469 ++ /* For non sack flows, do not grow window to force DUPACK
6470 ++ * and trigger fast retransmit.
6471 ++ */
6472 ++ if (tcp_is_sack(tp))
6473 ++ tcp_grow_window(sk, skb);
6474 + skb_set_owner_r(skb, sk);
6475 + }
6476 + }
6477 +diff --git a/net/ipv6/ip6_gre.c b/net/ipv6/ip6_gre.c
6478 +index caee5530ae2c..ca001ecb7197 100644
6479 +--- a/net/ipv6/ip6_gre.c
6480 ++++ b/net/ipv6/ip6_gre.c
6481 +@@ -124,6 +124,7 @@ static struct ip6_tnl *ip6gre_tunnel_lookup(struct net_device *dev,
6482 + int dev_type = (gre_proto == htons(ETH_P_TEB)) ?
6483 + ARPHRD_ETHER : ARPHRD_IP6GRE;
6484 + int score, cand_score = 4;
6485 ++ struct net_device *ndev;
6486 +
6487 + for_each_ip_tunnel_rcu(t, ign->tunnels_r_l[h0 ^ h1]) {
6488 + if (!ipv6_addr_equal(local, &t->parms.laddr) ||
6489 +@@ -226,9 +227,9 @@ static struct ip6_tnl *ip6gre_tunnel_lookup(struct net_device *dev,
6490 + if (cand)
6491 + return cand;
6492 +
6493 +- dev = ign->fb_tunnel_dev;
6494 +- if (dev->flags & IFF_UP)
6495 +- return netdev_priv(dev);
6496 ++ ndev = READ_ONCE(ign->fb_tunnel_dev);
6497 ++ if (ndev && ndev->flags & IFF_UP)
6498 ++ return netdev_priv(ndev);
6499 +
6500 + return NULL;
6501 + }
6502 +@@ -364,6 +365,8 @@ static void ip6gre_tunnel_uninit(struct net_device *dev)
6503 + struct ip6gre_net *ign = net_generic(t->net, ip6gre_net_id);
6504 +
6505 + ip6gre_tunnel_unlink(ign, t);
6506 ++ if (ign->fb_tunnel_dev == dev)
6507 ++ WRITE_ONCE(ign->fb_tunnel_dev, NULL);
6508 + dst_cache_reset(&t->dst_cache);
6509 + dev_put(dev);
6510 + }
6511 +diff --git a/net/ipv6/mcast.c b/net/ipv6/mcast.c
6512 +index e065d48b31b9..f904b9b24027 100644
6513 +--- a/net/ipv6/mcast.c
6514 ++++ b/net/ipv6/mcast.c
6515 +@@ -2601,6 +2601,7 @@ void ipv6_mc_destroy_dev(struct inet6_dev *idev)
6516 + idev->mc_list = i->next;
6517 +
6518 + write_unlock_bh(&idev->lock);
6519 ++ ip6_mc_clear_src(i);
6520 + ma_put(i);
6521 + write_lock_bh(&idev->lock);
6522 + }
6523 +diff --git a/net/l2tp/l2tp_core.c b/net/l2tp/l2tp_core.c
6524 +index fdc1de1cb4fa..c191ea65a6c7 100644
6525 +--- a/net/l2tp/l2tp_core.c
6526 ++++ b/net/l2tp/l2tp_core.c
6527 +@@ -351,8 +351,13 @@ int l2tp_session_register(struct l2tp_session *session,
6528 +
6529 + spin_lock_bh(&pn->l2tp_session_hlist_lock);
6530 +
6531 ++ /* IP encap expects session IDs to be globally unique, while
6532 ++ * UDP encap doesn't.
6533 ++ */
6534 + hlist_for_each_entry(session_walk, g_head, global_hlist)
6535 +- if (session_walk->session_id == session->session_id) {
6536 ++ if (session_walk->session_id == session->session_id &&
6537 ++ (session_walk->tunnel->encap == L2TP_ENCAPTYPE_IP ||
6538 ++ tunnel->encap == L2TP_ENCAPTYPE_IP)) {
6539 + err = -EEXIST;
6540 + goto err_tlock_pnlock;
6541 + }
6542 +diff --git a/net/netfilter/ipset/ip_set_core.c b/net/netfilter/ipset/ip_set_core.c
6543 +index f64660e9ff87..511496278262 100644
6544 +--- a/net/netfilter/ipset/ip_set_core.c
6545 ++++ b/net/netfilter/ipset/ip_set_core.c
6546 +@@ -379,6 +379,8 @@ ip_set_elem_len(struct ip_set *set, struct nlattr *tb[], size_t len,
6547 + for (id = 0; id < IPSET_EXT_ID_MAX; id++) {
6548 + if (!add_extension(id, cadt_flags, tb))
6549 + continue;
6550 ++ if (align < ip_set_extensions[id].align)
6551 ++ align = ip_set_extensions[id].align;
6552 + len = ALIGN(len, ip_set_extensions[id].align);
6553 + set->offset[id] = len;
6554 + set->extensions |= ip_set_extensions[id].type;
6555 +diff --git a/net/rxrpc/call_accept.c b/net/rxrpc/call_accept.c
6556 +index 832d854c2d5c..01ad588144e3 100644
6557 +--- a/net/rxrpc/call_accept.c
6558 ++++ b/net/rxrpc/call_accept.c
6559 +@@ -26,6 +26,11 @@
6560 + #include <net/ip.h>
6561 + #include "ar-internal.h"
6562 +
6563 ++static void rxrpc_dummy_notify(struct sock *sk, struct rxrpc_call *call,
6564 ++ unsigned long user_call_ID)
6565 ++{
6566 ++}
6567 ++
6568 + /*
6569 + * Preallocate a single service call, connection and peer and, if possible,
6570 + * give them a user ID and attach the user's side of the ID to them.
6571 +@@ -224,6 +229,8 @@ void rxrpc_discard_prealloc(struct rxrpc_sock *rx)
6572 + if (rx->discard_new_call) {
6573 + _debug("discard %lx", call->user_call_ID);
6574 + rx->discard_new_call(call, call->user_call_ID);
6575 ++ if (call->notify_rx)
6576 ++ call->notify_rx = rxrpc_dummy_notify;
6577 + rxrpc_put_call(call, rxrpc_call_put_kernel);
6578 + }
6579 + rxrpc_call_completed(call);
6580 +diff --git a/net/sched/sch_generic.c b/net/sched/sch_generic.c
6581 +index 88ce8edf1261..04ca08f85220 100644
6582 +--- a/net/sched/sch_generic.c
6583 ++++ b/net/sched/sch_generic.c
6584 +@@ -337,6 +337,7 @@ void __netdev_watchdog_up(struct net_device *dev)
6585 + dev_hold(dev);
6586 + }
6587 + }
6588 ++EXPORT_SYMBOL_GPL(__netdev_watchdog_up);
6589 +
6590 + static void dev_watchdog_up(struct net_device *dev)
6591 + {
6592 +diff --git a/net/sctp/associola.c b/net/sctp/associola.c
6593 +index 16e120b84118..8c5597d07240 100644
6594 +--- a/net/sctp/associola.c
6595 ++++ b/net/sctp/associola.c
6596 +@@ -1583,12 +1583,15 @@ void sctp_assoc_rwnd_decrease(struct sctp_association *asoc, unsigned int len)
6597 + int sctp_assoc_set_bind_addr_from_ep(struct sctp_association *asoc,
6598 + sctp_scope_t scope, gfp_t gfp)
6599 + {
6600 ++ struct sock *sk = asoc->base.sk;
6601 + int flags;
6602 +
6603 + /* Use scoping rules to determine the subset of addresses from
6604 + * the endpoint.
6605 + */
6606 +- flags = (PF_INET6 == asoc->base.sk->sk_family) ? SCTP_ADDR6_ALLOWED : 0;
6607 ++ flags = (PF_INET6 == sk->sk_family) ? SCTP_ADDR6_ALLOWED : 0;
6608 ++ if (!inet_v6_ipv6only(sk))
6609 ++ flags |= SCTP_ADDR4_ALLOWED;
6610 + if (asoc->peer.ipv4_address)
6611 + flags |= SCTP_ADDR4_PEERSUPP;
6612 + if (asoc->peer.ipv6_address)
6613 +diff --git a/net/sctp/bind_addr.c b/net/sctp/bind_addr.c
6614 +index 401c60750b20..dc4335d817d8 100644
6615 +--- a/net/sctp/bind_addr.c
6616 ++++ b/net/sctp/bind_addr.c
6617 +@@ -451,6 +451,7 @@ static int sctp_copy_one_addr(struct net *net, struct sctp_bind_addr *dest,
6618 + * well as the remote peer.
6619 + */
6620 + if ((((AF_INET == addr->sa.sa_family) &&
6621 ++ (flags & SCTP_ADDR4_ALLOWED) &&
6622 + (flags & SCTP_ADDR4_PEERSUPP))) ||
6623 + (((AF_INET6 == addr->sa.sa_family) &&
6624 + (flags & SCTP_ADDR6_ALLOWED) &&
6625 +diff --git a/net/sctp/protocol.c b/net/sctp/protocol.c
6626 +index c5a2a538279b..b2c242facf1b 100644
6627 +--- a/net/sctp/protocol.c
6628 ++++ b/net/sctp/protocol.c
6629 +@@ -210,6 +210,7 @@ int sctp_copy_local_addr_list(struct net *net, struct sctp_bind_addr *bp,
6630 + * sock as well as the remote peer.
6631 + */
6632 + if ((((AF_INET == addr->a.sa.sa_family) &&
6633 ++ (copy_flags & SCTP_ADDR4_ALLOWED) &&
6634 + (copy_flags & SCTP_ADDR4_PEERSUPP))) ||
6635 + (((AF_INET6 == addr->a.sa.sa_family) &&
6636 + (copy_flags & SCTP_ADDR6_ALLOWED) &&
6637 +diff --git a/net/sunrpc/addr.c b/net/sunrpc/addr.c
6638 +index 2e0a6f92e563..8391c2785550 100644
6639 +--- a/net/sunrpc/addr.c
6640 ++++ b/net/sunrpc/addr.c
6641 +@@ -81,11 +81,11 @@ static size_t rpc_ntop6(const struct sockaddr *sap,
6642 +
6643 + rc = snprintf(scopebuf, sizeof(scopebuf), "%c%u",
6644 + IPV6_SCOPE_DELIMITER, sin6->sin6_scope_id);
6645 +- if (unlikely((size_t)rc > sizeof(scopebuf)))
6646 ++ if (unlikely((size_t)rc >= sizeof(scopebuf)))
6647 + return 0;
6648 +
6649 + len += rc;
6650 +- if (unlikely(len > buflen))
6651 ++ if (unlikely(len >= buflen))
6652 + return 0;
6653 +
6654 + strcat(buf, scopebuf);
6655 +diff --git a/net/sunrpc/rpc_pipe.c b/net/sunrpc/rpc_pipe.c
6656 +index 34f94052c519..137f92bfafac 100644
6657 +--- a/net/sunrpc/rpc_pipe.c
6658 ++++ b/net/sunrpc/rpc_pipe.c
6659 +@@ -1347,6 +1347,7 @@ rpc_gssd_dummy_populate(struct dentry *root, struct rpc_pipe *pipe_data)
6660 + q.len = strlen(gssd_dummy_clnt_dir[0].name);
6661 + clnt_dentry = d_hash_and_lookup(gssd_dentry, &q);
6662 + if (!clnt_dentry) {
6663 ++ __rpc_depopulate(gssd_dentry, gssd_dummy_clnt_dir, 0, 1);
6664 + pipe_dentry = ERR_PTR(-ENOENT);
6665 + goto out;
6666 + }
6667 +diff --git a/net/sunrpc/xdr.c b/net/sunrpc/xdr.c
6668 +index 69846c6574ef..dd547edee59f 100644
6669 +--- a/net/sunrpc/xdr.c
6670 ++++ b/net/sunrpc/xdr.c
6671 +@@ -1036,6 +1036,7 @@ xdr_buf_subsegment(struct xdr_buf *buf, struct xdr_buf *subbuf,
6672 + base = 0;
6673 + } else {
6674 + base -= buf->head[0].iov_len;
6675 ++ subbuf->head[0].iov_base = buf->head[0].iov_base;
6676 + subbuf->head[0].iov_len = 0;
6677 + }
6678 +
6679 +@@ -1048,6 +1049,8 @@ xdr_buf_subsegment(struct xdr_buf *buf, struct xdr_buf *subbuf,
6680 + base = 0;
6681 + } else {
6682 + base -= buf->page_len;
6683 ++ subbuf->pages = buf->pages;
6684 ++ subbuf->page_base = 0;
6685 + subbuf->page_len = 0;
6686 + }
6687 +
6688 +@@ -1059,6 +1062,7 @@ xdr_buf_subsegment(struct xdr_buf *buf, struct xdr_buf *subbuf,
6689 + base = 0;
6690 + } else {
6691 + base -= buf->tail[0].iov_len;
6692 ++ subbuf->tail[0].iov_base = buf->tail[0].iov_base;
6693 + subbuf->tail[0].iov_len = 0;
6694 + }
6695 +
6696 +diff --git a/scripts/Kbuild.include b/scripts/Kbuild.include
6697 +index 558dea61db11..1920b9e2d251 100644
6698 +--- a/scripts/Kbuild.include
6699 ++++ b/scripts/Kbuild.include
6700 +@@ -82,20 +82,21 @@ cc-cross-prefix = \
6701 + fi)))
6702 +
6703 + # output directory for tests below
6704 +-TMPOUT := $(if $(KBUILD_EXTMOD),$(firstword $(KBUILD_EXTMOD))/)
6705 ++TMPOUT = $(if $(KBUILD_EXTMOD),$(firstword $(KBUILD_EXTMOD))/).tmp_$$$$
6706 +
6707 + # try-run
6708 + # Usage: option = $(call try-run, $(CC)...-o "$$TMP",option-ok,otherwise)
6709 + # Exit code chooses option. "$$TMP" is can be used as temporary file and
6710 + # is automatically cleaned up.
6711 + try-run = $(shell set -e; \
6712 +- TMP="$(TMPOUT).$$$$.tmp"; \
6713 +- TMPO="$(TMPOUT).$$$$.o"; \
6714 ++ TMP=$(TMPOUT)/tmp; \
6715 ++ TMPO=$(TMPOUT)/tmp.o; \
6716 ++ mkdir -p $(TMPOUT); \
6717 ++ trap "rm -rf $(TMPOUT)" EXIT; \
6718 + if ($(1)) >/dev/null 2>&1; \
6719 + then echo "$(2)"; \
6720 + else echo "$(3)"; \
6721 +- fi; \
6722 +- rm -f "$$TMP" "$$TMPO")
6723 ++ fi)
6724 +
6725 + # as-option
6726 + # Usage: cflags-y += $(call as-option,-Wa$(comma)-isa=foo,)
6727 +diff --git a/scripts/mksysmap b/scripts/mksysmap
6728 +index a35acc0d0b82..9aa23d15862a 100755
6729 +--- a/scripts/mksysmap
6730 ++++ b/scripts/mksysmap
6731 +@@ -41,4 +41,4 @@
6732 + # so we just ignore them to let readprofile continue to work.
6733 + # (At least sparc64 has __crc_ in the middle).
6734 +
6735 +-$NM -n $1 | grep -v '\( [aNUw] \)\|\(__crc_\)\|\( \$[adt]\)\|\( .L\)' > $2
6736 ++$NM -n $1 | grep -v '\( [aNUw] \)\|\(__crc_\)\|\( \$[adt]\)\|\( \.L\)' > $2
6737 +diff --git a/security/selinux/ss/services.c b/security/selinux/ss/services.c
6738 +index bfc4ffa1fa1a..6ca297821d45 100644
6739 +--- a/security/selinux/ss/services.c
6740 ++++ b/security/selinux/ss/services.c
6741 +@@ -2616,8 +2616,12 @@ err:
6742 + if (*names) {
6743 + for (i = 0; i < *len; i++)
6744 + kfree((*names)[i]);
6745 ++ kfree(*names);
6746 + }
6747 + kfree(*values);
6748 ++ *len = 0;
6749 ++ *names = NULL;
6750 ++ *values = NULL;
6751 + goto out;
6752 + }
6753 +
6754 +diff --git a/sound/isa/wavefront/wavefront_synth.c b/sound/isa/wavefront/wavefront_synth.c
6755 +index 718d5e3b7806..6c06d0645779 100644
6756 +--- a/sound/isa/wavefront/wavefront_synth.c
6757 ++++ b/sound/isa/wavefront/wavefront_synth.c
6758 +@@ -1174,7 +1174,10 @@ wavefront_send_alias (snd_wavefront_t *dev, wavefront_patch_info *header)
6759 + "alias for %d\n",
6760 + header->number,
6761 + header->hdr.a.OriginalSample);
6762 +-
6763 ++
6764 ++ if (header->number >= WF_MAX_SAMPLE)
6765 ++ return -EINVAL;
6766 ++
6767 + munge_int32 (header->number, &alias_hdr[0], 2);
6768 + munge_int32 (header->hdr.a.OriginalSample, &alias_hdr[2], 2);
6769 + munge_int32 (*((unsigned int *)&header->hdr.a.sampleStartOffset),
6770 +@@ -1205,6 +1208,9 @@ wavefront_send_multisample (snd_wavefront_t *dev, wavefront_patch_info *header)
6771 + int num_samples;
6772 + unsigned char *msample_hdr;
6773 +
6774 ++ if (header->number >= WF_MAX_SAMPLE)
6775 ++ return -EINVAL;
6776 ++
6777 + msample_hdr = kmalloc(WF_MSAMPLE_BYTES, GFP_KERNEL);
6778 + if (! msample_hdr)
6779 + return -ENOMEM;
6780 +diff --git a/sound/pci/hda/patch_hdmi.c b/sound/pci/hda/patch_hdmi.c
6781 +index a866a20349c3..2def4ad579cc 100644
6782 +--- a/sound/pci/hda/patch_hdmi.c
6783 ++++ b/sound/pci/hda/patch_hdmi.c
6784 +@@ -3687,6 +3687,11 @@ HDA_CODEC_ENTRY(0x10de0095, "GPU 95 HDMI/DP", patch_nvhdmi),
6785 + HDA_CODEC_ENTRY(0x10de0097, "GPU 97 HDMI/DP", patch_nvhdmi),
6786 + HDA_CODEC_ENTRY(0x10de0098, "GPU 98 HDMI/DP", patch_nvhdmi),
6787 + HDA_CODEC_ENTRY(0x10de0099, "GPU 99 HDMI/DP", patch_nvhdmi),
6788 ++HDA_CODEC_ENTRY(0x10de009a, "GPU 9a HDMI/DP", patch_nvhdmi),
6789 ++HDA_CODEC_ENTRY(0x10de009d, "GPU 9d HDMI/DP", patch_nvhdmi),
6790 ++HDA_CODEC_ENTRY(0x10de009e, "GPU 9e HDMI/DP", patch_nvhdmi),
6791 ++HDA_CODEC_ENTRY(0x10de009f, "GPU 9f HDMI/DP", patch_nvhdmi),
6792 ++HDA_CODEC_ENTRY(0x10de00a0, "GPU a0 HDMI/DP", patch_nvhdmi),
6793 + HDA_CODEC_ENTRY(0x10de8001, "MCP73 HDMI", patch_nvhdmi_2ch),
6794 + HDA_CODEC_ENTRY(0x10de8067, "MCP67/68 HDMI", patch_nvhdmi_2ch),
6795 + HDA_CODEC_ENTRY(0x11069f80, "VX900 HDMI/DP", patch_via_hdmi),
6796 +diff --git a/sound/soc/fsl/fsl_asrc_dma.c b/sound/soc/fsl/fsl_asrc_dma.c
6797 +index dc30d780f874..3fcf174b99d3 100644
6798 +--- a/sound/soc/fsl/fsl_asrc_dma.c
6799 ++++ b/sound/soc/fsl/fsl_asrc_dma.c
6800 +@@ -243,6 +243,7 @@ static int fsl_asrc_dma_hw_params(struct snd_pcm_substream *substream,
6801 + ret = dmaengine_slave_config(pair->dma_chan[dir], &config_be);
6802 + if (ret) {
6803 + dev_err(dev, "failed to config DMA channel for Back-End\n");
6804 ++ dma_release_channel(pair->dma_chan[dir]);
6805 + return ret;
6806 + }
6807 +
6808 +diff --git a/sound/usb/card.h b/sound/usb/card.h
6809 +index 111b0f009afa..c4599cf0ddc9 100644
6810 +--- a/sound/usb/card.h
6811 ++++ b/sound/usb/card.h
6812 +@@ -80,6 +80,10 @@ struct snd_usb_endpoint {
6813 + dma_addr_t sync_dma; /* DMA address of syncbuf */
6814 +
6815 + unsigned int pipe; /* the data i/o pipe */
6816 ++ unsigned int framesize[2]; /* small/large frame sizes in samples */
6817 ++ unsigned int sample_rem; /* remainder from division fs/fps */
6818 ++ unsigned int sample_accum; /* sample accumulator */
6819 ++ unsigned int fps; /* frames per second */
6820 + unsigned int freqn; /* nominal sampling rate in fs/fps in Q16.16 format */
6821 + unsigned int freqm; /* momentary sampling rate in fs/fps in Q16.16 format */
6822 + int freqshift; /* how much to shift the feedback value to get Q16.16 */
6823 +diff --git a/sound/usb/endpoint.c b/sound/usb/endpoint.c
6824 +index 30aa5f2df6da..b5207e71ed72 100644
6825 +--- a/sound/usb/endpoint.c
6826 ++++ b/sound/usb/endpoint.c
6827 +@@ -137,12 +137,12 @@ int snd_usb_endpoint_implicit_feedback_sink(struct snd_usb_endpoint *ep)
6828 +
6829 + /*
6830 + * For streaming based on information derived from sync endpoints,
6831 +- * prepare_outbound_urb_sizes() will call next_packet_size() to
6832 ++ * prepare_outbound_urb_sizes() will call slave_next_packet_size() to
6833 + * determine the number of samples to be sent in the next packet.
6834 + *
6835 +- * For implicit feedback, next_packet_size() is unused.
6836 ++ * For implicit feedback, slave_next_packet_size() is unused.
6837 + */
6838 +-int snd_usb_endpoint_next_packet_size(struct snd_usb_endpoint *ep)
6839 ++int snd_usb_endpoint_slave_next_packet_size(struct snd_usb_endpoint *ep)
6840 + {
6841 + unsigned long flags;
6842 + int ret;
6843 +@@ -159,6 +159,29 @@ int snd_usb_endpoint_next_packet_size(struct snd_usb_endpoint *ep)
6844 + return ret;
6845 + }
6846 +
6847 ++/*
6848 ++ * For adaptive and synchronous endpoints, prepare_outbound_urb_sizes()
6849 ++ * will call next_packet_size() to determine the number of samples to be
6850 ++ * sent in the next packet.
6851 ++ */
6852 ++int snd_usb_endpoint_next_packet_size(struct snd_usb_endpoint *ep)
6853 ++{
6854 ++ int ret;
6855 ++
6856 ++ if (ep->fill_max)
6857 ++ return ep->maxframesize;
6858 ++
6859 ++ ep->sample_accum += ep->sample_rem;
6860 ++ if (ep->sample_accum >= ep->fps) {
6861 ++ ep->sample_accum -= ep->fps;
6862 ++ ret = ep->framesize[1];
6863 ++ } else {
6864 ++ ret = ep->framesize[0];
6865 ++ }
6866 ++
6867 ++ return ret;
6868 ++}
6869 ++
6870 + static void retire_outbound_urb(struct snd_usb_endpoint *ep,
6871 + struct snd_urb_ctx *urb_ctx)
6872 + {
6873 +@@ -203,6 +226,8 @@ static void prepare_silent_urb(struct snd_usb_endpoint *ep,
6874 +
6875 + if (ctx->packet_size[i])
6876 + counts = ctx->packet_size[i];
6877 ++ else if (ep->sync_master)
6878 ++ counts = snd_usb_endpoint_slave_next_packet_size(ep);
6879 + else
6880 + counts = snd_usb_endpoint_next_packet_size(ep);
6881 +
6882 +@@ -875,10 +900,17 @@ int snd_usb_endpoint_set_params(struct snd_usb_endpoint *ep,
6883 + ep->maxpacksize = fmt->maxpacksize;
6884 + ep->fill_max = !!(fmt->attributes & UAC_EP_CS_ATTR_FILL_MAX);
6885 +
6886 +- if (snd_usb_get_speed(ep->chip->dev) == USB_SPEED_FULL)
6887 ++ if (snd_usb_get_speed(ep->chip->dev) == USB_SPEED_FULL) {
6888 + ep->freqn = get_usb_full_speed_rate(rate);
6889 +- else
6890 ++ ep->fps = 1000;
6891 ++ } else {
6892 + ep->freqn = get_usb_high_speed_rate(rate);
6893 ++ ep->fps = 8000;
6894 ++ }
6895 ++
6896 ++ ep->sample_rem = rate % ep->fps;
6897 ++ ep->framesize[0] = rate / ep->fps;
6898 ++ ep->framesize[1] = (rate + (ep->fps - 1)) / ep->fps;
6899 +
6900 + /* calculate the frequency in 16.16 format */
6901 + ep->freqm = ep->freqn;
6902 +@@ -937,6 +969,7 @@ int snd_usb_endpoint_start(struct snd_usb_endpoint *ep)
6903 + ep->active_mask = 0;
6904 + ep->unlink_mask = 0;
6905 + ep->phase = 0;
6906 ++ ep->sample_accum = 0;
6907 +
6908 + snd_usb_endpoint_start_quirk(ep);
6909 +
6910 +diff --git a/sound/usb/endpoint.h b/sound/usb/endpoint.h
6911 +index 584f295d7c77..4aad49cbeb5f 100644
6912 +--- a/sound/usb/endpoint.h
6913 ++++ b/sound/usb/endpoint.h
6914 +@@ -27,6 +27,7 @@ void snd_usb_endpoint_release(struct snd_usb_endpoint *ep);
6915 + void snd_usb_endpoint_free(struct snd_usb_endpoint *ep);
6916 +
6917 + int snd_usb_endpoint_implicit_feedback_sink(struct snd_usb_endpoint *ep);
6918 ++int snd_usb_endpoint_slave_next_packet_size(struct snd_usb_endpoint *ep);
6919 + int snd_usb_endpoint_next_packet_size(struct snd_usb_endpoint *ep);
6920 +
6921 + void snd_usb_handle_sync_urb(struct snd_usb_endpoint *ep,
6922 +diff --git a/sound/usb/mixer.c b/sound/usb/mixer.c
6923 +index 024864ce3f76..6913ea27e978 100644
6924 +--- a/sound/usb/mixer.c
6925 ++++ b/sound/usb/mixer.c
6926 +@@ -585,8 +585,9 @@ static int check_matrix_bitmap(unsigned char *bmap,
6927 + * if failed, give up and free the control instance.
6928 + */
6929 +
6930 +-int snd_usb_mixer_add_control(struct usb_mixer_elem_list *list,
6931 +- struct snd_kcontrol *kctl)
6932 ++int snd_usb_mixer_add_list(struct usb_mixer_elem_list *list,
6933 ++ struct snd_kcontrol *kctl,
6934 ++ bool is_std_info)
6935 + {
6936 + struct usb_mixer_interface *mixer = list->mixer;
6937 + int err;
6938 +@@ -599,6 +600,7 @@ int snd_usb_mixer_add_control(struct usb_mixer_elem_list *list,
6939 + return err;
6940 + }
6941 + list->kctl = kctl;
6942 ++ list->is_std_info = is_std_info;
6943 + list->next_id_elem = mixer->id_elems[list->id];
6944 + mixer->id_elems[list->id] = list;
6945 + return 0;
6946 +@@ -2397,15 +2399,23 @@ void snd_usb_mixer_notify_id(struct usb_mixer_interface *mixer, int unitid)
6947 + {
6948 + struct usb_mixer_elem_list *list;
6949 +
6950 +- for (list = mixer->id_elems[unitid]; list; list = list->next_id_elem)
6951 ++ for_each_mixer_elem(list, mixer, unitid) {
6952 ++ struct usb_mixer_elem_info *info;
6953 ++
6954 ++ if (!list->is_std_info)
6955 ++ continue;
6956 ++ info = mixer_elem_list_to_info(list);
6957 ++ /* invalidate cache, so the value is read from the device */
6958 ++ info->cached = 0;
6959 + snd_ctl_notify(mixer->chip->card, SNDRV_CTL_EVENT_MASK_VALUE,
6960 + &list->kctl->id);
6961 ++ }
6962 + }
6963 +
6964 + static void snd_usb_mixer_dump_cval(struct snd_info_buffer *buffer,
6965 + struct usb_mixer_elem_list *list)
6966 + {
6967 +- struct usb_mixer_elem_info *cval = (struct usb_mixer_elem_info *)list;
6968 ++ struct usb_mixer_elem_info *cval = mixer_elem_list_to_info(list);
6969 + static char *val_types[] = {"BOOLEAN", "INV_BOOLEAN",
6970 + "S8", "U8", "S16", "U16"};
6971 + snd_iprintf(buffer, " Info: id=%i, control=%i, cmask=0x%x, "
6972 +@@ -2431,8 +2441,7 @@ static void snd_usb_mixer_proc_read(struct snd_info_entry *entry,
6973 + mixer->ignore_ctl_error);
6974 + snd_iprintf(buffer, "Card: %s\n", chip->card->longname);
6975 + for (unitid = 0; unitid < MAX_ID_ELEMS; unitid++) {
6976 +- for (list = mixer->id_elems[unitid]; list;
6977 +- list = list->next_id_elem) {
6978 ++ for_each_mixer_elem(list, mixer, unitid) {
6979 + snd_iprintf(buffer, " Unit: %i\n", list->id);
6980 + if (list->kctl)
6981 + snd_iprintf(buffer,
6982 +@@ -2462,19 +2471,21 @@ static void snd_usb_mixer_interrupt_v2(struct usb_mixer_interface *mixer,
6983 + return;
6984 + }
6985 +
6986 +- for (list = mixer->id_elems[unitid]; list; list = list->next_id_elem)
6987 ++ for_each_mixer_elem(list, mixer, unitid)
6988 + count++;
6989 +
6990 + if (count == 0)
6991 + return;
6992 +
6993 +- for (list = mixer->id_elems[unitid]; list; list = list->next_id_elem) {
6994 ++ for_each_mixer_elem(list, mixer, unitid) {
6995 + struct usb_mixer_elem_info *info;
6996 +
6997 + if (!list->kctl)
6998 + continue;
6999 ++ if (!list->is_std_info)
7000 ++ continue;
7001 +
7002 +- info = (struct usb_mixer_elem_info *)list;
7003 ++ info = mixer_elem_list_to_info(list);
7004 + if (count > 1 && info->control != control)
7005 + continue;
7006 +
7007 +@@ -2694,7 +2705,7 @@ int snd_usb_mixer_suspend(struct usb_mixer_interface *mixer)
7008 +
7009 + static int restore_mixer_value(struct usb_mixer_elem_list *list)
7010 + {
7011 +- struct usb_mixer_elem_info *cval = (struct usb_mixer_elem_info *)list;
7012 ++ struct usb_mixer_elem_info *cval = mixer_elem_list_to_info(list);
7013 + int c, err, idx;
7014 +
7015 + if (cval->cmask) {
7016 +@@ -2730,8 +2741,7 @@ int snd_usb_mixer_resume(struct usb_mixer_interface *mixer, bool reset_resume)
7017 + if (reset_resume) {
7018 + /* restore cached mixer values */
7019 + for (id = 0; id < MAX_ID_ELEMS; id++) {
7020 +- for (list = mixer->id_elems[id]; list;
7021 +- list = list->next_id_elem) {
7022 ++ for_each_mixer_elem(list, mixer, id) {
7023 + if (list->resume) {
7024 + err = list->resume(list);
7025 + if (err < 0)
7026 +diff --git a/sound/usb/mixer.h b/sound/usb/mixer.h
7027 +index 545d99b09706..7d16a9221070 100644
7028 +--- a/sound/usb/mixer.h
7029 ++++ b/sound/usb/mixer.h
7030 +@@ -48,10 +48,17 @@ struct usb_mixer_elem_list {
7031 + struct usb_mixer_elem_list *next_id_elem; /* list of controls with same id */
7032 + struct snd_kcontrol *kctl;
7033 + unsigned int id;
7034 ++ bool is_std_info;
7035 + usb_mixer_elem_dump_func_t dump;
7036 + usb_mixer_elem_resume_func_t resume;
7037 + };
7038 +
7039 ++/* iterate over mixer element list of the given unit id */
7040 ++#define for_each_mixer_elem(list, mixer, id) \
7041 ++ for ((list) = (mixer)->id_elems[id]; (list); (list) = (list)->next_id_elem)
7042 ++#define mixer_elem_list_to_info(list) \
7043 ++ container_of(list, struct usb_mixer_elem_info, head)
7044 ++
7045 + struct usb_mixer_elem_info {
7046 + struct usb_mixer_elem_list head;
7047 + unsigned int control; /* CS or ICN (high byte) */
7048 +@@ -79,8 +86,12 @@ void snd_usb_mixer_notify_id(struct usb_mixer_interface *mixer, int unitid);
7049 + int snd_usb_mixer_set_ctl_value(struct usb_mixer_elem_info *cval,
7050 + int request, int validx, int value_set);
7051 +
7052 +-int snd_usb_mixer_add_control(struct usb_mixer_elem_list *list,
7053 +- struct snd_kcontrol *kctl);
7054 ++int snd_usb_mixer_add_list(struct usb_mixer_elem_list *list,
7055 ++ struct snd_kcontrol *kctl,
7056 ++ bool is_std_info);
7057 ++
7058 ++#define snd_usb_mixer_add_control(list, kctl) \
7059 ++ snd_usb_mixer_add_list(list, kctl, true)
7060 +
7061 + void snd_usb_mixer_elem_init_std(struct usb_mixer_elem_list *list,
7062 + struct usb_mixer_interface *mixer,
7063 +diff --git a/sound/usb/mixer_quirks.c b/sound/usb/mixer_quirks.c
7064 +index 723b535ca2ec..198515f86fcc 100644
7065 +--- a/sound/usb/mixer_quirks.c
7066 ++++ b/sound/usb/mixer_quirks.c
7067 +@@ -168,7 +168,8 @@ static int add_single_ctl_with_resume(struct usb_mixer_interface *mixer,
7068 + return -ENOMEM;
7069 + }
7070 + kctl->private_free = snd_usb_mixer_elem_free;
7071 +- return snd_usb_mixer_add_control(list, kctl);
7072 ++ /* don't use snd_usb_mixer_add_control() here, this is a special list element */
7073 ++ return snd_usb_mixer_add_list(list, kctl, false);
7074 + }
7075 +
7076 + /*
7077 +@@ -1170,7 +1171,7 @@ void snd_emuusb_set_samplerate(struct snd_usb_audio *chip,
7078 + int unitid = 12; /* SamleRate ExtensionUnit ID */
7079 +
7080 + list_for_each_entry(mixer, &chip->mixer_list, list) {
7081 +- cval = (struct usb_mixer_elem_info *)mixer->id_elems[unitid];
7082 ++ cval = mixer_elem_list_to_info(mixer->id_elems[unitid]);
7083 + if (cval) {
7084 + snd_usb_mixer_set_ctl_value(cval, UAC_SET_CUR,
7085 + cval->control << 8,
7086 +diff --git a/sound/usb/mixer_scarlett.c b/sound/usb/mixer_scarlett.c
7087 +index 7438e7c4a842..2876cd9b35b3 100644
7088 +--- a/sound/usb/mixer_scarlett.c
7089 ++++ b/sound/usb/mixer_scarlett.c
7090 +@@ -287,8 +287,7 @@ static int scarlett_ctl_switch_put(struct snd_kcontrol *kctl,
7091 +
7092 + static int scarlett_ctl_resume(struct usb_mixer_elem_list *list)
7093 + {
7094 +- struct usb_mixer_elem_info *elem =
7095 +- container_of(list, struct usb_mixer_elem_info, head);
7096 ++ struct usb_mixer_elem_info *elem = mixer_elem_list_to_info(list);
7097 + int i;
7098 +
7099 + for (i = 0; i < elem->channels; i++)
7100 +@@ -447,8 +446,7 @@ static int scarlett_ctl_enum_put(struct snd_kcontrol *kctl,
7101 +
7102 + static int scarlett_ctl_enum_resume(struct usb_mixer_elem_list *list)
7103 + {
7104 +- struct usb_mixer_elem_info *elem =
7105 +- container_of(list, struct usb_mixer_elem_info, head);
7106 ++ struct usb_mixer_elem_info *elem = mixer_elem_list_to_info(list);
7107 +
7108 + if (elem->cached)
7109 + snd_usb_set_cur_mix_value(elem, 0, 0, *elem->cache_val);
7110 +diff --git a/sound/usb/pcm.c b/sound/usb/pcm.c
7111 +index 9bc995f9b4e1..615213aeda33 100644
7112 +--- a/sound/usb/pcm.c
7113 ++++ b/sound/usb/pcm.c
7114 +@@ -1483,6 +1483,8 @@ static void prepare_playback_urb(struct snd_usb_substream *subs,
7115 + for (i = 0; i < ctx->packets; i++) {
7116 + if (ctx->packet_size[i])
7117 + counts = ctx->packet_size[i];
7118 ++ else if (ep->sync_master)
7119 ++ counts = snd_usb_endpoint_slave_next_packet_size(ep);
7120 + else
7121 + counts = snd_usb_endpoint_next_packet_size(ep);
7122 +
7123 +diff --git a/sound/usb/quirks.c b/sound/usb/quirks.c
7124 +index 0484a8d8a5bb..486d27129ac3 100644
7125 +--- a/sound/usb/quirks.c
7126 ++++ b/sound/usb/quirks.c
7127 +@@ -1162,6 +1162,7 @@ bool snd_usb_get_sample_rate_quirk(struct snd_usb_audio *chip)
7128 + static bool is_itf_usb_dsd_2alts_dac(unsigned int id)
7129 + {
7130 + switch (id) {
7131 ++ case USB_ID(0x154e, 0x1002): /* Denon DCD-1500RE */
7132 + case USB_ID(0x154e, 0x1003): /* Denon DA-300USB */
7133 + case USB_ID(0x154e, 0x3005): /* Marantz HD-DAC1 */
7134 + case USB_ID(0x154e, 0x3006): /* Marantz SA-14S1 */
7135 +diff --git a/tools/perf/builtin-report.c b/tools/perf/builtin-report.c
7136 +index 0abca8783bb3..78485edb9467 100644
7137 +--- a/tools/perf/builtin-report.c
7138 ++++ b/tools/perf/builtin-report.c
7139 +@@ -341,8 +341,7 @@ static size_t hists__fprintf_nr_sample_events(struct hists *hists, struct report
7140 + if (evname != NULL)
7141 + ret += fprintf(fp, " of event '%s'", evname);
7142 +
7143 +- if (symbol_conf.show_ref_callgraph &&
7144 +- strstr(evname, "call-graph=no")) {
7145 ++ if (symbol_conf.show_ref_callgraph && evname && strstr(evname, "call-graph=no")) {
7146 + ret += fprintf(fp, ", show reference callgraph");
7147 + }
7148 +
7149 +diff --git a/tools/testing/selftests/networking/timestamping/timestamping.c b/tools/testing/selftests/networking/timestamping/timestamping.c
7150 +index 5cdfd743447b..900ed4b47899 100644
7151 +--- a/tools/testing/selftests/networking/timestamping/timestamping.c
7152 ++++ b/tools/testing/selftests/networking/timestamping/timestamping.c
7153 +@@ -332,10 +332,16 @@ int main(int argc, char **argv)
7154 + int val;
7155 + socklen_t len;
7156 + struct timeval next;
7157 ++ size_t if_len;
7158 +
7159 + if (argc < 2)
7160 + usage(0);
7161 + interface = argv[1];
7162 ++ if_len = strlen(interface);
7163 ++ if (if_len >= IFNAMSIZ) {
7164 ++ printf("interface name exceeds IFNAMSIZ\n");
7165 ++ exit(1);
7166 ++ }
7167 +
7168 + for (i = 2; i < argc; i++) {
7169 + if (!strcasecmp(argv[i], "SO_TIMESTAMP"))
7170 +@@ -369,12 +375,12 @@ int main(int argc, char **argv)
7171 + bail("socket");
7172 +
7173 + memset(&device, 0, sizeof(device));
7174 +- strncpy(device.ifr_name, interface, sizeof(device.ifr_name));
7175 ++ memcpy(device.ifr_name, interface, if_len + 1);
7176 + if (ioctl(sock, SIOCGIFADDR, &device) < 0)
7177 + bail("getting interface IP address");
7178 +
7179 + memset(&hwtstamp, 0, sizeof(hwtstamp));
7180 +- strncpy(hwtstamp.ifr_name, interface, sizeof(hwtstamp.ifr_name));
7181 ++ memcpy(hwtstamp.ifr_name, interface, if_len + 1);
7182 + hwtstamp.ifr_data = (void *)&hwconfig;
7183 + memset(&hwconfig, 0, sizeof(hwconfig));
7184 + hwconfig.tx_type =
7185 +diff --git a/tools/testing/selftests/x86/protection_keys.c b/tools/testing/selftests/x86/protection_keys.c
7186 +index 874972ccfc95..5338e668b5e6 100644
7187 +--- a/tools/testing/selftests/x86/protection_keys.c
7188 ++++ b/tools/testing/selftests/x86/protection_keys.c
7189 +@@ -23,6 +23,7 @@
7190 + #define _GNU_SOURCE
7191 + #include <errno.h>
7192 + #include <linux/futex.h>
7193 ++#include <time.h>
7194 + #include <sys/time.h>
7195 + #include <sys/syscall.h>
7196 + #include <string.h>
7197 +@@ -608,10 +609,10 @@ int alloc_random_pkey(void)
7198 + int nr_alloced = 0;
7199 + int random_index;
7200 + memset(alloced_pkeys, 0, sizeof(alloced_pkeys));
7201 ++ srand((unsigned int)time(NULL));
7202 +
7203 + /* allocate every possible key and make a note of which ones we got */
7204 + max_nr_pkey_allocs = NR_PKEYS;
7205 +- max_nr_pkey_allocs = 1;
7206 + for (i = 0; i < max_nr_pkey_allocs; i++) {
7207 + int new_pkey = alloc_pkey();
7208 + if (new_pkey < 0)