1 |
commit: e70e295836f04951c3eeaf0bdba524da86691c26 |
2 |
Author: Mike Pagano <mpagano <AT> gentoo <DOT> org> |
3 |
AuthorDate: Thu Oct 17 22:24:47 2019 +0000 |
4 |
Commit: Mike Pagano <mpagano <AT> gentoo <DOT> org> |
5 |
CommitDate: Thu Oct 17 22:25:20 2019 +0000 |
6 |
URL: https://gitweb.gentoo.org/proj/linux-patches.git/commit/?id=e70e2958 |
7 |
|
8 |
Linux patch 4.14.150 |
9 |
|
10 |
Signed-off-by: Mike Pagano <mpagano <AT> gentoo.org> |
11 |
|
12 |
0000_README | 4 + |
13 |
1149_linux-4.14.150.patch | 3404 +++++++++++++++++++++++++++++++++++++++++++++ |
14 |
2 files changed, 3408 insertions(+) |
15 |
|
16 |
diff --git a/0000_README b/0000_README |
17 |
index 3bfe86d..5e20a18 100644 |
18 |
--- a/0000_README |
19 |
+++ b/0000_README |
20 |
@@ -639,6 +639,10 @@ Patch: 1148_linux-4.14.149.patch |
21 |
From: https://www.kernel.org |
22 |
Desc: Linux 4.14.149 |
23 |
|
24 |
+Patch: 1149_linux-4.14.150.patch |
25 |
+From: https://www.kernel.org |
26 |
+Desc: Linux 4.14.150 |
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/1149_linux-4.14.150.patch b/1149_linux-4.14.150.patch |
33 |
new file mode 100644 |
34 |
index 0000000..58a7053 |
35 |
--- /dev/null |
36 |
+++ b/1149_linux-4.14.150.patch |
37 |
@@ -0,0 +1,3404 @@ |
38 |
+diff --git a/Documentation/usb/rio.txt b/Documentation/usb/rio.txt |
39 |
+deleted file mode 100644 |
40 |
+index aee715af7db7..000000000000 |
41 |
+--- a/Documentation/usb/rio.txt |
42 |
++++ /dev/null |
43 |
+@@ -1,138 +0,0 @@ |
44 |
+-Copyright (C) 1999, 2000 Bruce Tenison |
45 |
+-Portions Copyright (C) 1999, 2000 David Nelson |
46 |
+-Thanks to David Nelson for guidance and the usage of the scanner.txt |
47 |
+-and scanner.c files to model our driver and this informative file. |
48 |
+- |
49 |
+-Mar. 2, 2000 |
50 |
+- |
51 |
+-CHANGES |
52 |
+- |
53 |
+-- Initial Revision |
54 |
+- |
55 |
+- |
56 |
+-OVERVIEW |
57 |
+- |
58 |
+-This README will address issues regarding how to configure the kernel |
59 |
+-to access a RIO 500 mp3 player. |
60 |
+-Before I explain how to use this to access the Rio500 please be warned: |
61 |
+- |
62 |
+-W A R N I N G: |
63 |
+--------------- |
64 |
+- |
65 |
+-Please note that this software is still under development. The authors |
66 |
+-are in no way responsible for any damage that may occur, no matter how |
67 |
+-inconsequential. |
68 |
+- |
69 |
+-It seems that the Rio has a problem when sending .mp3 with low batteries. |
70 |
+-I suggest when the batteries are low and you want to transfer stuff that you |
71 |
+-replace it with a fresh one. In my case, what happened is I lost two 16kb |
72 |
+-blocks (they are no longer usable to store information to it). But I don't |
73 |
+-know if that's normal or not; it could simply be a problem with the flash |
74 |
+-memory. |
75 |
+- |
76 |
+-In an extreme case, I left my Rio playing overnight and the batteries wore |
77 |
+-down to nothing and appear to have corrupted the flash memory. My RIO |
78 |
+-needed to be replaced as a result. Diamond tech support is aware of the |
79 |
+-problem. Do NOT allow your batteries to wear down to nothing before |
80 |
+-changing them. It appears RIO 500 firmware does not handle low battery |
81 |
+-power well at all. |
82 |
+- |
83 |
+-On systems with OHCI controllers, the kernel OHCI code appears to have |
84 |
+-power on problems with some chipsets. If you are having problems |
85 |
+-connecting to your RIO 500, try turning it on first and then plugging it |
86 |
+-into the USB cable. |
87 |
+- |
88 |
+-Contact information: |
89 |
+--------------------- |
90 |
+- |
91 |
+- The main page for the project is hosted at sourceforge.net in the following |
92 |
+- URL: <http://rio500.sourceforge.net>. You can also go to the project's |
93 |
+- sourceforge home page at: <http://sourceforge.net/projects/rio500/>. |
94 |
+- There is also a mailing list: rio500-users@×××××××××××××××××.net |
95 |
+- |
96 |
+-Authors: |
97 |
+-------- |
98 |
+- |
99 |
+-Most of the code was written by Cesar Miquel <miquel@××××××.ar>. Keith |
100 |
+-Clayton <kclayton@×××.net> is incharge of the PPC port and making sure |
101 |
+-things work there. Bruce Tenison <btenison@×××××.net> is adding support |
102 |
+-for .fon files and also does testing. The program will mostly sure be |
103 |
+-re-written and Pete Ikusz along with the rest will re-design it. I would |
104 |
+-also like to thank Tri Nguyen <tmn_3022000@×××××××.com> who provided use |
105 |
+-with some important information regarding the communication with the Rio. |
106 |
+- |
107 |
+-ADDITIONAL INFORMATION and Userspace tools |
108 |
+- |
109 |
+-http://rio500.sourceforge.net/ |
110 |
+- |
111 |
+- |
112 |
+-REQUIREMENTS |
113 |
+- |
114 |
+-A host with a USB port. Ideally, either a UHCI (Intel) or OHCI |
115 |
+-(Compaq and others) hardware port should work. |
116 |
+- |
117 |
+-A Linux development kernel (2.3.x) with USB support enabled or a |
118 |
+-backported version to linux-2.2.x. See http://www.linux-usb.org for |
119 |
+-more information on accomplishing this. |
120 |
+- |
121 |
+-A Linux kernel with RIO 500 support enabled. |
122 |
+- |
123 |
+-'lspci' which is only needed to determine the type of USB hardware |
124 |
+-available in your machine. |
125 |
+- |
126 |
+-CONFIGURATION |
127 |
+- |
128 |
+-Using `lspci -v`, determine the type of USB hardware available. |
129 |
+- |
130 |
+- If you see something like: |
131 |
+- |
132 |
+- USB Controller: ...... |
133 |
+- Flags: ..... |
134 |
+- I/O ports at .... |
135 |
+- |
136 |
+- Then you have a UHCI based controller. |
137 |
+- |
138 |
+- If you see something like: |
139 |
+- |
140 |
+- USB Controller: ..... |
141 |
+- Flags: .... |
142 |
+- Memory at ..... |
143 |
+- |
144 |
+- Then you have a OHCI based controller. |
145 |
+- |
146 |
+-Using `make menuconfig` or your preferred method for configuring the |
147 |
+-kernel, select 'Support for USB', 'OHCI/UHCI' depending on your |
148 |
+-hardware (determined from the steps above), 'USB Diamond Rio500 support', and |
149 |
+-'Preliminary USB device filesystem'. Compile and install the modules |
150 |
+-(you may need to execute `depmod -a` to update the module |
151 |
+-dependencies). |
152 |
+- |
153 |
+-Add a device for the USB rio500: |
154 |
+- `mknod /dev/usb/rio500 c 180 64` |
155 |
+- |
156 |
+-Set appropriate permissions for /dev/usb/rio500 (don't forget about |
157 |
+-group and world permissions). Both read and write permissions are |
158 |
+-required for proper operation. |
159 |
+- |
160 |
+-Load the appropriate modules (if compiled as modules): |
161 |
+- |
162 |
+- OHCI: |
163 |
+- modprobe usbcore |
164 |
+- modprobe usb-ohci |
165 |
+- modprobe rio500 |
166 |
+- |
167 |
+- UHCI: |
168 |
+- modprobe usbcore |
169 |
+- modprobe usb-uhci (or uhci) |
170 |
+- modprobe rio500 |
171 |
+- |
172 |
+-That's it. The Rio500 Utils at: http://rio500.sourceforge.net should |
173 |
+-be able to access the rio500. |
174 |
+- |
175 |
+-BUGS |
176 |
+- |
177 |
+-If you encounter any problems feel free to drop me an email. |
178 |
+- |
179 |
+-Bruce Tenison |
180 |
+-btenison@×××××.net |
181 |
+- |
182 |
+diff --git a/MAINTAINERS b/MAINTAINERS |
183 |
+index 6cb70b853323..029f96c43250 100644 |
184 |
+--- a/MAINTAINERS |
185 |
++++ b/MAINTAINERS |
186 |
+@@ -13886,13 +13886,6 @@ W: http://www.linux-usb.org/usbnet |
187 |
+ S: Maintained |
188 |
+ F: drivers/net/usb/dm9601.c |
189 |
+ |
190 |
+-USB DIAMOND RIO500 DRIVER |
191 |
+-M: Cesar Miquel <miquel@××××××.ar> |
192 |
+-L: rio500-users@×××××××××××××××××.net |
193 |
+-W: http://rio500.sourceforge.net |
194 |
+-S: Maintained |
195 |
+-F: drivers/usb/misc/rio500* |
196 |
+- |
197 |
+ USB EHCI DRIVER |
198 |
+ M: Alan Stern <stern@×××××××××××××××.edu> |
199 |
+ L: linux-usb@×××××××××××.org |
200 |
+diff --git a/Makefile b/Makefile |
201 |
+index 93c3467eeb8c..3d96b277ffc9 100644 |
202 |
+--- a/Makefile |
203 |
++++ b/Makefile |
204 |
+@@ -1,7 +1,7 @@ |
205 |
+ # SPDX-License-Identifier: GPL-2.0 |
206 |
+ VERSION = 4 |
207 |
+ PATCHLEVEL = 14 |
208 |
+-SUBLEVEL = 149 |
209 |
++SUBLEVEL = 150 |
210 |
+ EXTRAVERSION = |
211 |
+ NAME = Petit Gorille |
212 |
+ |
213 |
+diff --git a/arch/arm/configs/badge4_defconfig b/arch/arm/configs/badge4_defconfig |
214 |
+index 5ae5b5228467..ef484c4cfd1a 100644 |
215 |
+--- a/arch/arm/configs/badge4_defconfig |
216 |
++++ b/arch/arm/configs/badge4_defconfig |
217 |
+@@ -91,7 +91,6 @@ CONFIG_USB_SERIAL_PL2303=m |
218 |
+ CONFIG_USB_SERIAL_CYBERJACK=m |
219 |
+ CONFIG_USB_SERIAL_XIRCOM=m |
220 |
+ CONFIG_USB_SERIAL_OMNINET=m |
221 |
+-CONFIG_USB_RIO500=m |
222 |
+ CONFIG_EXT2_FS=m |
223 |
+ CONFIG_EXT3_FS=m |
224 |
+ CONFIG_MSDOS_FS=y |
225 |
+diff --git a/arch/arm/configs/corgi_defconfig b/arch/arm/configs/corgi_defconfig |
226 |
+index 09e1672777c9..0ba8df0d48b9 100644 |
227 |
+--- a/arch/arm/configs/corgi_defconfig |
228 |
++++ b/arch/arm/configs/corgi_defconfig |
229 |
+@@ -197,7 +197,6 @@ CONFIG_USB_SERIAL_XIRCOM=m |
230 |
+ CONFIG_USB_SERIAL_OMNINET=m |
231 |
+ CONFIG_USB_EMI62=m |
232 |
+ CONFIG_USB_EMI26=m |
233 |
+-CONFIG_USB_RIO500=m |
234 |
+ CONFIG_USB_LEGOTOWER=m |
235 |
+ CONFIG_USB_LCD=m |
236 |
+ CONFIG_USB_CYTHERM=m |
237 |
+diff --git a/arch/arm/configs/pxa_defconfig b/arch/arm/configs/pxa_defconfig |
238 |
+index d5e1370ec303..38a5680c8236 100644 |
239 |
+--- a/arch/arm/configs/pxa_defconfig |
240 |
++++ b/arch/arm/configs/pxa_defconfig |
241 |
+@@ -588,7 +588,6 @@ CONFIG_USB_SERIAL_XIRCOM=m |
242 |
+ CONFIG_USB_SERIAL_OMNINET=m |
243 |
+ CONFIG_USB_EMI62=m |
244 |
+ CONFIG_USB_EMI26=m |
245 |
+-CONFIG_USB_RIO500=m |
246 |
+ CONFIG_USB_LEGOTOWER=m |
247 |
+ CONFIG_USB_LCD=m |
248 |
+ CONFIG_USB_CYTHERM=m |
249 |
+diff --git a/arch/arm/configs/s3c2410_defconfig b/arch/arm/configs/s3c2410_defconfig |
250 |
+index 2afb359f3168..bd71d5bf98c9 100644 |
251 |
+--- a/arch/arm/configs/s3c2410_defconfig |
252 |
++++ b/arch/arm/configs/s3c2410_defconfig |
253 |
+@@ -334,7 +334,6 @@ CONFIG_USB_EMI62=m |
254 |
+ CONFIG_USB_EMI26=m |
255 |
+ CONFIG_USB_ADUTUX=m |
256 |
+ CONFIG_USB_SEVSEG=m |
257 |
+-CONFIG_USB_RIO500=m |
258 |
+ CONFIG_USB_LEGOTOWER=m |
259 |
+ CONFIG_USB_LCD=m |
260 |
+ CONFIG_USB_CYPRESS_CY7C63=m |
261 |
+diff --git a/arch/arm/configs/spitz_defconfig b/arch/arm/configs/spitz_defconfig |
262 |
+index 9ea82c118661..3aff4ca2a94e 100644 |
263 |
+--- a/arch/arm/configs/spitz_defconfig |
264 |
++++ b/arch/arm/configs/spitz_defconfig |
265 |
+@@ -191,7 +191,6 @@ CONFIG_USB_SERIAL_XIRCOM=m |
266 |
+ CONFIG_USB_SERIAL_OMNINET=m |
267 |
+ CONFIG_USB_EMI62=m |
268 |
+ CONFIG_USB_EMI26=m |
269 |
+-CONFIG_USB_RIO500=m |
270 |
+ CONFIG_USB_LEGOTOWER=m |
271 |
+ CONFIG_USB_LCD=m |
272 |
+ CONFIG_USB_CYTHERM=m |
273 |
+diff --git a/arch/mips/configs/mtx1_defconfig b/arch/mips/configs/mtx1_defconfig |
274 |
+index c3d0d0a6e044..6895430b5b2c 100644 |
275 |
+--- a/arch/mips/configs/mtx1_defconfig |
276 |
++++ b/arch/mips/configs/mtx1_defconfig |
277 |
+@@ -623,7 +623,6 @@ CONFIG_USB_SERIAL_OMNINET=m |
278 |
+ CONFIG_USB_EMI62=m |
279 |
+ CONFIG_USB_EMI26=m |
280 |
+ CONFIG_USB_ADUTUX=m |
281 |
+-CONFIG_USB_RIO500=m |
282 |
+ CONFIG_USB_LEGOTOWER=m |
283 |
+ CONFIG_USB_LCD=m |
284 |
+ CONFIG_USB_CYPRESS_CY7C63=m |
285 |
+diff --git a/arch/mips/configs/rm200_defconfig b/arch/mips/configs/rm200_defconfig |
286 |
+index 99679e514042..d67a39219fff 100644 |
287 |
+--- a/arch/mips/configs/rm200_defconfig |
288 |
++++ b/arch/mips/configs/rm200_defconfig |
289 |
+@@ -344,7 +344,6 @@ CONFIG_USB_SERIAL_SAFE_PADDED=y |
290 |
+ CONFIG_USB_SERIAL_CYBERJACK=m |
291 |
+ CONFIG_USB_SERIAL_XIRCOM=m |
292 |
+ CONFIG_USB_SERIAL_OMNINET=m |
293 |
+-CONFIG_USB_RIO500=m |
294 |
+ CONFIG_USB_LEGOTOWER=m |
295 |
+ CONFIG_USB_LCD=m |
296 |
+ CONFIG_USB_CYTHERM=m |
297 |
+diff --git a/arch/mips/loongson64/Platform b/arch/mips/loongson64/Platform |
298 |
+index 0fce4608aa88..12abf14aed4a 100644 |
299 |
+--- a/arch/mips/loongson64/Platform |
300 |
++++ b/arch/mips/loongson64/Platform |
301 |
+@@ -43,6 +43,10 @@ else |
302 |
+ $(call cc-option,-march=mips64r2,-mips64r2 -U_MIPS_ISA -D_MIPS_ISA=_MIPS_ISA_MIPS64) |
303 |
+ endif |
304 |
+ |
305 |
++# Some -march= flags enable MMI instructions, and GCC complains about that |
306 |
++# support being enabled alongside -msoft-float. Thus explicitly disable MMI. |
307 |
++cflags-y += $(call cc-option,-mno-loongson-mmi) |
308 |
++ |
309 |
+ # |
310 |
+ # Loongson Machines' Support |
311 |
+ # |
312 |
+diff --git a/arch/mips/vdso/Makefile b/arch/mips/vdso/Makefile |
313 |
+index 0f455fdf822a..24f5f6baf2c0 100644 |
314 |
+--- a/arch/mips/vdso/Makefile |
315 |
++++ b/arch/mips/vdso/Makefile |
316 |
+@@ -9,6 +9,7 @@ ccflags-vdso := \ |
317 |
+ $(filter -mmicromips,$(KBUILD_CFLAGS)) \ |
318 |
+ $(filter -march=%,$(KBUILD_CFLAGS)) \ |
319 |
+ $(filter -m%-float,$(KBUILD_CFLAGS)) \ |
320 |
++ $(filter -mno-loongson-%,$(KBUILD_CFLAGS)) \ |
321 |
+ -D__VDSO__ |
322 |
+ cflags-vdso := $(ccflags-vdso) \ |
323 |
+ $(filter -W%,$(filter-out -Wa$(comma)%,$(KBUILD_CFLAGS))) \ |
324 |
+diff --git a/arch/x86/include/asm/mwait.h b/arch/x86/include/asm/mwait.h |
325 |
+index eb0f80ce8524..3aa82deeab5a 100644 |
326 |
+--- a/arch/x86/include/asm/mwait.h |
327 |
++++ b/arch/x86/include/asm/mwait.h |
328 |
+@@ -21,7 +21,7 @@ |
329 |
+ #define MWAIT_ECX_INTERRUPT_BREAK 0x1 |
330 |
+ #define MWAITX_ECX_TIMER_ENABLE BIT(1) |
331 |
+ #define MWAITX_MAX_LOOPS ((u32)-1) |
332 |
+-#define MWAITX_DISABLE_CSTATES 0xf |
333 |
++#define MWAITX_DISABLE_CSTATES 0xf0 |
334 |
+ |
335 |
+ static inline void __monitor(const void *eax, unsigned long ecx, |
336 |
+ unsigned long edx) |
337 |
+diff --git a/arch/x86/lib/delay.c b/arch/x86/lib/delay.c |
338 |
+index 4846eff7e4c8..17a0d0f5a1bf 100644 |
339 |
+--- a/arch/x86/lib/delay.c |
340 |
++++ b/arch/x86/lib/delay.c |
341 |
+@@ -113,8 +113,8 @@ static void delay_mwaitx(unsigned long __loops) |
342 |
+ __monitorx(raw_cpu_ptr(&cpu_tss_rw), 0, 0); |
343 |
+ |
344 |
+ /* |
345 |
+- * AMD, like Intel, supports the EAX hint and EAX=0xf |
346 |
+- * means, do not enter any deep C-state and we use it |
347 |
++ * AMD, like Intel's MWAIT version, supports the EAX hint and |
348 |
++ * EAX=0xf0 means, do not enter any deep C-state and we use it |
349 |
+ * here in delay() to minimize wakeup latency. |
350 |
+ */ |
351 |
+ __mwaitx(MWAITX_DISABLE_CSTATES, delay, MWAITX_ECX_TIMER_ENABLE); |
352 |
+diff --git a/drivers/firmware/efi/efi.c b/drivers/firmware/efi/efi.c |
353 |
+index c3eefa126e3b..f50072b51aef 100644 |
354 |
+--- a/drivers/firmware/efi/efi.c |
355 |
++++ b/drivers/firmware/efi/efi.c |
356 |
+@@ -266,6 +266,9 @@ static __init int efivar_ssdt_load(void) |
357 |
+ void *data; |
358 |
+ int ret; |
359 |
+ |
360 |
++ if (!efivar_ssdt[0]) |
361 |
++ return 0; |
362 |
++ |
363 |
+ ret = efivar_init(efivar_ssdt_iter, &entries, true, &entries); |
364 |
+ |
365 |
+ list_for_each_entry_safe(entry, aux, &entries, list) { |
366 |
+diff --git a/drivers/firmware/google/vpd_decode.c b/drivers/firmware/google/vpd_decode.c |
367 |
+index e75abe9fa122..6c7ab2ba85d2 100644 |
368 |
+--- a/drivers/firmware/google/vpd_decode.c |
369 |
++++ b/drivers/firmware/google/vpd_decode.c |
370 |
+@@ -62,7 +62,7 @@ static int vpd_decode_entry(const u32 max_len, const u8 *input_buf, |
371 |
+ if (max_len - consumed < *entry_len) |
372 |
+ return VPD_FAIL; |
373 |
+ |
374 |
+- consumed += decoded_len; |
375 |
++ consumed += *entry_len; |
376 |
+ *_consumed = consumed; |
377 |
+ return VPD_OK; |
378 |
+ } |
379 |
+diff --git a/drivers/gpio/gpiolib.c b/drivers/gpio/gpiolib.c |
380 |
+index f1809a54fcee..c7f5f0be2d74 100644 |
381 |
+--- a/drivers/gpio/gpiolib.c |
382 |
++++ b/drivers/gpio/gpiolib.c |
383 |
+@@ -2329,8 +2329,10 @@ static int _gpiod_direction_output_raw(struct gpio_desc *desc, int value) |
384 |
+ if (!ret) |
385 |
+ goto set_output_value; |
386 |
+ /* Emulate open drain by not actively driving the line high */ |
387 |
+- if (val) |
388 |
+- return gpiod_direction_input(desc); |
389 |
++ if (val) { |
390 |
++ ret = gpiod_direction_input(desc); |
391 |
++ goto set_output_flag; |
392 |
++ } |
393 |
+ } |
394 |
+ else if (test_bit(FLAG_OPEN_SOURCE, &desc->flags)) { |
395 |
+ ret = gpio_set_drive_single_ended(gc, gpio_chip_hwgpio(desc), |
396 |
+@@ -2338,8 +2340,10 @@ static int _gpiod_direction_output_raw(struct gpio_desc *desc, int value) |
397 |
+ if (!ret) |
398 |
+ goto set_output_value; |
399 |
+ /* Emulate open source by not actively driving the line low */ |
400 |
+- if (!val) |
401 |
+- return gpiod_direction_input(desc); |
402 |
++ if (!val) { |
403 |
++ ret = gpiod_direction_input(desc); |
404 |
++ goto set_output_flag; |
405 |
++ } |
406 |
+ } else { |
407 |
+ gpio_set_drive_single_ended(gc, gpio_chip_hwgpio(desc), |
408 |
+ PIN_CONFIG_DRIVE_PUSH_PULL); |
409 |
+@@ -2359,6 +2363,17 @@ set_output_value: |
410 |
+ trace_gpio_value(desc_to_gpio(desc), 0, val); |
411 |
+ trace_gpio_direction(desc_to_gpio(desc), 0, ret); |
412 |
+ return ret; |
413 |
++ |
414 |
++set_output_flag: |
415 |
++ /* |
416 |
++ * When emulating open-source or open-drain functionalities by not |
417 |
++ * actively driving the line (setting mode to input) we still need to |
418 |
++ * set the IS_OUT flag or otherwise we won't be able to set the line |
419 |
++ * value anymore. |
420 |
++ */ |
421 |
++ if (ret == 0) |
422 |
++ set_bit(FLAG_IS_OUT, &desc->flags); |
423 |
++ return ret; |
424 |
+ } |
425 |
+ |
426 |
+ /** |
427 |
+@@ -2540,8 +2555,6 @@ static void _gpio_set_open_drain_value(struct gpio_desc *desc, bool value) |
428 |
+ |
429 |
+ if (value) { |
430 |
+ err = chip->direction_input(chip, offset); |
431 |
+- if (!err) |
432 |
+- clear_bit(FLAG_IS_OUT, &desc->flags); |
433 |
+ } else { |
434 |
+ err = chip->direction_output(chip, offset, 0); |
435 |
+ if (!err) |
436 |
+@@ -2571,8 +2584,6 @@ static void _gpio_set_open_source_value(struct gpio_desc *desc, bool value) |
437 |
+ set_bit(FLAG_IS_OUT, &desc->flags); |
438 |
+ } else { |
439 |
+ err = chip->direction_input(chip, offset); |
440 |
+- if (!err) |
441 |
+- clear_bit(FLAG_IS_OUT, &desc->flags); |
442 |
+ } |
443 |
+ trace_gpio_direction(desc_to_gpio(desc), !value, err); |
444 |
+ if (err < 0) |
445 |
+diff --git a/drivers/iio/adc/ad799x.c b/drivers/iio/adc/ad799x.c |
446 |
+index 22426ae4af97..7d1895035af6 100644 |
447 |
+--- a/drivers/iio/adc/ad799x.c |
448 |
++++ b/drivers/iio/adc/ad799x.c |
449 |
+@@ -817,10 +817,10 @@ static int ad799x_probe(struct i2c_client *client, |
450 |
+ |
451 |
+ ret = ad799x_write_config(st, st->chip_config->default_config); |
452 |
+ if (ret < 0) |
453 |
+- goto error_disable_reg; |
454 |
++ goto error_disable_vref; |
455 |
+ ret = ad799x_read_config(st); |
456 |
+ if (ret < 0) |
457 |
+- goto error_disable_reg; |
458 |
++ goto error_disable_vref; |
459 |
+ st->config = ret; |
460 |
+ |
461 |
+ ret = iio_triggered_buffer_setup(indio_dev, NULL, |
462 |
+diff --git a/drivers/iio/adc/axp288_adc.c b/drivers/iio/adc/axp288_adc.c |
463 |
+index 0153df01e7b6..546bbe59c241 100644 |
464 |
+--- a/drivers/iio/adc/axp288_adc.c |
465 |
++++ b/drivers/iio/adc/axp288_adc.c |
466 |
+@@ -16,6 +16,7 @@ |
467 |
+ * |
468 |
+ */ |
469 |
+ |
470 |
++#include <linux/dmi.h> |
471 |
+ #include <linux/module.h> |
472 |
+ #include <linux/kernel.h> |
473 |
+ #include <linux/device.h> |
474 |
+@@ -34,6 +35,11 @@ |
475 |
+ #define AXP288_ADC_EN_MASK 0xF0 |
476 |
+ #define AXP288_ADC_TS_ENABLE 0x01 |
477 |
+ |
478 |
++#define AXP288_ADC_TS_BIAS_MASK GENMASK(5, 4) |
479 |
++#define AXP288_ADC_TS_BIAS_20UA (0 << 4) |
480 |
++#define AXP288_ADC_TS_BIAS_40UA (1 << 4) |
481 |
++#define AXP288_ADC_TS_BIAS_60UA (2 << 4) |
482 |
++#define AXP288_ADC_TS_BIAS_80UA (3 << 4) |
483 |
+ #define AXP288_ADC_TS_CURRENT_ON_OFF_MASK GENMASK(1, 0) |
484 |
+ #define AXP288_ADC_TS_CURRENT_OFF (0 << 0) |
485 |
+ #define AXP288_ADC_TS_CURRENT_ON_WHEN_CHARGING (1 << 0) |
486 |
+@@ -194,10 +200,36 @@ static int axp288_adc_read_raw(struct iio_dev *indio_dev, |
487 |
+ return ret; |
488 |
+ } |
489 |
+ |
490 |
++/* |
491 |
++ * We rely on the machine's firmware to correctly setup the TS pin bias current |
492 |
++ * at boot. This lists systems with broken fw where we need to set it ourselves. |
493 |
++ */ |
494 |
++static const struct dmi_system_id axp288_adc_ts_bias_override[] = { |
495 |
++ { |
496 |
++ /* Lenovo Ideapad 100S (11 inch) */ |
497 |
++ .matches = { |
498 |
++ DMI_MATCH(DMI_SYS_VENDOR, "LENOVO"), |
499 |
++ DMI_MATCH(DMI_PRODUCT_VERSION, "Lenovo ideapad 100S-11IBY"), |
500 |
++ }, |
501 |
++ .driver_data = (void *)(uintptr_t)AXP288_ADC_TS_BIAS_80UA, |
502 |
++ }, |
503 |
++ {} |
504 |
++}; |
505 |
++ |
506 |
+ static int axp288_adc_initialize(struct axp288_adc_info *info) |
507 |
+ { |
508 |
++ const struct dmi_system_id *bias_override; |
509 |
+ int ret, adc_enable_val; |
510 |
+ |
511 |
++ bias_override = dmi_first_match(axp288_adc_ts_bias_override); |
512 |
++ if (bias_override) { |
513 |
++ ret = regmap_update_bits(info->regmap, AXP288_ADC_TS_PIN_CTRL, |
514 |
++ AXP288_ADC_TS_BIAS_MASK, |
515 |
++ (uintptr_t)bias_override->driver_data); |
516 |
++ if (ret) |
517 |
++ return ret; |
518 |
++ } |
519 |
++ |
520 |
+ /* |
521 |
+ * Determine if the TS pin is enabled and set the TS current-source |
522 |
+ * accordingly. |
523 |
+diff --git a/drivers/iio/adc/hx711.c b/drivers/iio/adc/hx711.c |
524 |
+index 27005d84ed73..0dec733471d5 100644 |
525 |
+--- a/drivers/iio/adc/hx711.c |
526 |
++++ b/drivers/iio/adc/hx711.c |
527 |
+@@ -89,20 +89,35 @@ struct hx711_data { |
528 |
+ int gain_set; /* gain set on device */ |
529 |
+ int gain_chan_a; /* gain for channel A */ |
530 |
+ struct mutex lock; |
531 |
++ /* |
532 |
++ * delay after a rising edge on SCK until the data is ready DOUT |
533 |
++ * this is dependent on the hx711 where the datasheet tells a |
534 |
++ * maximum value of 100 ns |
535 |
++ * but also on potential parasitic capacities on the wiring |
536 |
++ */ |
537 |
++ u32 data_ready_delay_ns; |
538 |
++ u32 clock_frequency; |
539 |
+ }; |
540 |
+ |
541 |
+ static int hx711_cycle(struct hx711_data *hx711_data) |
542 |
+ { |
543 |
+- int val; |
544 |
++ unsigned long flags; |
545 |
+ |
546 |
+ /* |
547 |
+ * if preempted for more then 60us while PD_SCK is high: |
548 |
+ * hx711 is going in reset |
549 |
+ * ==> measuring is false |
550 |
+ */ |
551 |
+- preempt_disable(); |
552 |
++ local_irq_save(flags); |
553 |
+ gpiod_set_value(hx711_data->gpiod_pd_sck, 1); |
554 |
+- val = gpiod_get_value(hx711_data->gpiod_dout); |
555 |
++ |
556 |
++ /* |
557 |
++ * wait until DOUT is ready |
558 |
++ * it turned out that parasitic capacities are extending the time |
559 |
++ * until DOUT has reached it's value |
560 |
++ */ |
561 |
++ ndelay(hx711_data->data_ready_delay_ns); |
562 |
++ |
563 |
+ /* |
564 |
+ * here we are not waiting for 0.2 us as suggested by the datasheet, |
565 |
+ * because the oscilloscope showed in a test scenario |
566 |
+@@ -110,9 +125,16 @@ static int hx711_cycle(struct hx711_data *hx711_data) |
567 |
+ * and 0.56 us for PD_SCK low on TI Sitara with 800 MHz |
568 |
+ */ |
569 |
+ gpiod_set_value(hx711_data->gpiod_pd_sck, 0); |
570 |
+- preempt_enable(); |
571 |
++ local_irq_restore(flags); |
572 |
+ |
573 |
+- return val; |
574 |
++ /* |
575 |
++ * make it a square wave for addressing cases with capacitance on |
576 |
++ * PC_SCK |
577 |
++ */ |
578 |
++ ndelay(hx711_data->data_ready_delay_ns); |
579 |
++ |
580 |
++ /* sample as late as possible */ |
581 |
++ return gpiod_get_value(hx711_data->gpiod_dout); |
582 |
+ } |
583 |
+ |
584 |
+ static int hx711_read(struct hx711_data *hx711_data) |
585 |
+@@ -401,6 +423,7 @@ static const struct iio_chan_spec hx711_chan_spec[] = { |
586 |
+ static int hx711_probe(struct platform_device *pdev) |
587 |
+ { |
588 |
+ struct device *dev = &pdev->dev; |
589 |
++ struct device_node *np = dev->of_node; |
590 |
+ struct hx711_data *hx711_data; |
591 |
+ struct iio_dev *indio_dev; |
592 |
+ int ret; |
593 |
+@@ -474,6 +497,22 @@ static int hx711_probe(struct platform_device *pdev) |
594 |
+ hx711_data->gain_set = 128; |
595 |
+ hx711_data->gain_chan_a = 128; |
596 |
+ |
597 |
++ hx711_data->clock_frequency = 400000; |
598 |
++ ret = of_property_read_u32(np, "clock-frequency", |
599 |
++ &hx711_data->clock_frequency); |
600 |
++ |
601 |
++ /* |
602 |
++ * datasheet says the high level of PD_SCK has a maximum duration |
603 |
++ * of 50 microseconds |
604 |
++ */ |
605 |
++ if (hx711_data->clock_frequency < 20000) { |
606 |
++ dev_warn(dev, "clock-frequency too low - assuming 400 kHz\n"); |
607 |
++ hx711_data->clock_frequency = 400000; |
608 |
++ } |
609 |
++ |
610 |
++ hx711_data->data_ready_delay_ns = |
611 |
++ 1000000000 / hx711_data->clock_frequency; |
612 |
++ |
613 |
+ platform_set_drvdata(pdev, indio_dev); |
614 |
+ |
615 |
+ indio_dev->name = "hx711"; |
616 |
+diff --git a/drivers/iio/light/opt3001.c b/drivers/iio/light/opt3001.c |
617 |
+index b91ebc3483ce..743fd2cfdd54 100644 |
618 |
+--- a/drivers/iio/light/opt3001.c |
619 |
++++ b/drivers/iio/light/opt3001.c |
620 |
+@@ -695,6 +695,7 @@ static irqreturn_t opt3001_irq(int irq, void *_iio) |
621 |
+ struct iio_dev *iio = _iio; |
622 |
+ struct opt3001 *opt = iio_priv(iio); |
623 |
+ int ret; |
624 |
++ bool wake_result_ready_queue = false; |
625 |
+ |
626 |
+ if (!opt->ok_to_ignore_lock) |
627 |
+ mutex_lock(&opt->lock); |
628 |
+@@ -729,13 +730,16 @@ static irqreturn_t opt3001_irq(int irq, void *_iio) |
629 |
+ } |
630 |
+ opt->result = ret; |
631 |
+ opt->result_ready = true; |
632 |
+- wake_up(&opt->result_ready_queue); |
633 |
++ wake_result_ready_queue = true; |
634 |
+ } |
635 |
+ |
636 |
+ out: |
637 |
+ if (!opt->ok_to_ignore_lock) |
638 |
+ mutex_unlock(&opt->lock); |
639 |
+ |
640 |
++ if (wake_result_ready_queue) |
641 |
++ wake_up(&opt->result_ready_queue); |
642 |
++ |
643 |
+ return IRQ_HANDLED; |
644 |
+ } |
645 |
+ |
646 |
+diff --git a/drivers/media/usb/stkwebcam/stk-webcam.c b/drivers/media/usb/stkwebcam/stk-webcam.c |
647 |
+index c0bba773db25..a7da1356a36e 100644 |
648 |
+--- a/drivers/media/usb/stkwebcam/stk-webcam.c |
649 |
++++ b/drivers/media/usb/stkwebcam/stk-webcam.c |
650 |
+@@ -640,8 +640,7 @@ static int v4l_stk_release(struct file *fp) |
651 |
+ dev->owner = NULL; |
652 |
+ } |
653 |
+ |
654 |
+- if (is_present(dev)) |
655 |
+- usb_autopm_put_interface(dev->interface); |
656 |
++ usb_autopm_put_interface(dev->interface); |
657 |
+ mutex_unlock(&dev->lock); |
658 |
+ return v4l2_fh_release(fp); |
659 |
+ } |
660 |
+diff --git a/drivers/staging/fbtft/fbtft-core.c b/drivers/staging/fbtft/fbtft-core.c |
661 |
+index 6d0363deba61..0cbcbad8f074 100644 |
662 |
+--- a/drivers/staging/fbtft/fbtft-core.c |
663 |
++++ b/drivers/staging/fbtft/fbtft-core.c |
664 |
+@@ -828,7 +828,7 @@ struct fb_info *fbtft_framebuffer_alloc(struct fbtft_display *display, |
665 |
+ if (par->gamma.curves && gamma) { |
666 |
+ if (fbtft_gamma_parse_str(par, |
667 |
+ par->gamma.curves, gamma, strlen(gamma))) |
668 |
+- goto alloc_fail; |
669 |
++ goto release_framebuf; |
670 |
+ } |
671 |
+ |
672 |
+ /* Transmit buffer */ |
673 |
+@@ -845,7 +845,7 @@ struct fb_info *fbtft_framebuffer_alloc(struct fbtft_display *display, |
674 |
+ if (txbuflen > 0) { |
675 |
+ txbuf = devm_kzalloc(par->info->device, txbuflen, GFP_KERNEL); |
676 |
+ if (!txbuf) |
677 |
+- goto alloc_fail; |
678 |
++ goto release_framebuf; |
679 |
+ par->txbuf.buf = txbuf; |
680 |
+ par->txbuf.len = txbuflen; |
681 |
+ } |
682 |
+@@ -881,6 +881,9 @@ struct fb_info *fbtft_framebuffer_alloc(struct fbtft_display *display, |
683 |
+ |
684 |
+ return info; |
685 |
+ |
686 |
++release_framebuf: |
687 |
++ framebuffer_release(info); |
688 |
++ |
689 |
+ alloc_fail: |
690 |
+ vfree(vmem); |
691 |
+ |
692 |
+diff --git a/drivers/staging/vt6655/device_main.c b/drivers/staging/vt6655/device_main.c |
693 |
+index 84a915199e64..6edd87867ce0 100644 |
694 |
+--- a/drivers/staging/vt6655/device_main.c |
695 |
++++ b/drivers/staging/vt6655/device_main.c |
696 |
+@@ -1668,8 +1668,10 @@ vt6655_probe(struct pci_dev *pcid, const struct pci_device_id *ent) |
697 |
+ |
698 |
+ priv->hw->max_signal = 100; |
699 |
+ |
700 |
+- if (vnt_init(priv)) |
701 |
++ if (vnt_init(priv)) { |
702 |
++ device_free_info(priv); |
703 |
+ return -ENODEV; |
704 |
++ } |
705 |
+ |
706 |
+ device_print_info(priv); |
707 |
+ pci_set_drvdata(pcid, priv); |
708 |
+diff --git a/drivers/tty/serial/uartlite.c b/drivers/tty/serial/uartlite.c |
709 |
+index c9b8d702dadc..2e76eb4c604c 100644 |
710 |
+--- a/drivers/tty/serial/uartlite.c |
711 |
++++ b/drivers/tty/serial/uartlite.c |
712 |
+@@ -746,7 +746,8 @@ err_uart: |
713 |
+ static void __exit ulite_exit(void) |
714 |
+ { |
715 |
+ platform_driver_unregister(&ulite_platform_driver); |
716 |
+- uart_unregister_driver(&ulite_uart_driver); |
717 |
++ if (ulite_uart_driver.state) |
718 |
++ uart_unregister_driver(&ulite_uart_driver); |
719 |
+ } |
720 |
+ |
721 |
+ module_init(ulite_init); |
722 |
+diff --git a/drivers/usb/class/usblp.c b/drivers/usb/class/usblp.c |
723 |
+index fb87c17ed6fa..50836f79f908 100644 |
724 |
+--- a/drivers/usb/class/usblp.c |
725 |
++++ b/drivers/usb/class/usblp.c |
726 |
+@@ -474,10 +474,12 @@ static int usblp_release(struct inode *inode, struct file *file) |
727 |
+ |
728 |
+ mutex_lock(&usblp_mutex); |
729 |
+ usblp->used = 0; |
730 |
+- if (usblp->present) { |
731 |
++ if (usblp->present) |
732 |
+ usblp_unlink_urbs(usblp); |
733 |
+- usb_autopm_put_interface(usblp->intf); |
734 |
+- } else /* finish cleanup from disconnect */ |
735 |
++ |
736 |
++ usb_autopm_put_interface(usblp->intf); |
737 |
++ |
738 |
++ if (!usblp->present) /* finish cleanup from disconnect */ |
739 |
+ usblp_cleanup(usblp); |
740 |
+ mutex_unlock(&usblp_mutex); |
741 |
+ return 0; |
742 |
+diff --git a/drivers/usb/gadget/udc/dummy_hcd.c b/drivers/usb/gadget/udc/dummy_hcd.c |
743 |
+index f04e91ef9e7c..7e90f786d923 100644 |
744 |
+--- a/drivers/usb/gadget/udc/dummy_hcd.c |
745 |
++++ b/drivers/usb/gadget/udc/dummy_hcd.c |
746 |
+@@ -50,6 +50,7 @@ |
747 |
+ #define DRIVER_VERSION "02 May 2005" |
748 |
+ |
749 |
+ #define POWER_BUDGET 500 /* in mA; use 8 for low-power port testing */ |
750 |
++#define POWER_BUDGET_3 900 /* in mA */ |
751 |
+ |
752 |
+ static const char driver_name[] = "dummy_hcd"; |
753 |
+ static const char driver_desc[] = "USB Host+Gadget Emulator"; |
754 |
+@@ -2439,7 +2440,7 @@ static int dummy_start_ss(struct dummy_hcd *dum_hcd) |
755 |
+ dum_hcd->rh_state = DUMMY_RH_RUNNING; |
756 |
+ dum_hcd->stream_en_ep = 0; |
757 |
+ INIT_LIST_HEAD(&dum_hcd->urbp_list); |
758 |
+- dummy_hcd_to_hcd(dum_hcd)->power_budget = POWER_BUDGET; |
759 |
++ dummy_hcd_to_hcd(dum_hcd)->power_budget = POWER_BUDGET_3; |
760 |
+ dummy_hcd_to_hcd(dum_hcd)->state = HC_STATE_RUNNING; |
761 |
+ dummy_hcd_to_hcd(dum_hcd)->uses_new_polling = 1; |
762 |
+ #ifdef CONFIG_USB_OTG |
763 |
+diff --git a/drivers/usb/host/xhci-ring.c b/drivers/usb/host/xhci-ring.c |
764 |
+index 94a7669ccb80..009b6796f405 100644 |
765 |
+--- a/drivers/usb/host/xhci-ring.c |
766 |
++++ b/drivers/usb/host/xhci-ring.c |
767 |
+@@ -3223,10 +3223,10 @@ static int xhci_align_td(struct xhci_hcd *xhci, struct urb *urb, u32 enqd_len, |
768 |
+ if (usb_urb_dir_out(urb)) { |
769 |
+ len = sg_pcopy_to_buffer(urb->sg, urb->num_sgs, |
770 |
+ seg->bounce_buf, new_buff_len, enqd_len); |
771 |
+- if (len != seg->bounce_len) |
772 |
++ if (len != new_buff_len) |
773 |
+ xhci_warn(xhci, |
774 |
+ "WARN Wrong bounce buffer write length: %zu != %d\n", |
775 |
+- len, seg->bounce_len); |
776 |
++ len, new_buff_len); |
777 |
+ seg->bounce_dma = dma_map_single(dev, seg->bounce_buf, |
778 |
+ max_pkt, DMA_TO_DEVICE); |
779 |
+ } else { |
780 |
+diff --git a/drivers/usb/host/xhci.c b/drivers/usb/host/xhci.c |
781 |
+index 8893d1566765..465d7fd507ad 100644 |
782 |
+--- a/drivers/usb/host/xhci.c |
783 |
++++ b/drivers/usb/host/xhci.c |
784 |
+@@ -968,7 +968,7 @@ int xhci_suspend(struct xhci_hcd *xhci, bool do_wakeup) |
785 |
+ writel(command, &xhci->op_regs->command); |
786 |
+ xhci->broken_suspend = 0; |
787 |
+ if (xhci_handshake(&xhci->op_regs->status, |
788 |
+- STS_SAVE, 0, 10 * 1000)) { |
789 |
++ STS_SAVE, 0, 20 * 1000)) { |
790 |
+ /* |
791 |
+ * AMD SNPS xHC 3.0 occasionally does not clear the |
792 |
+ * SSS bit of USBSTS and when driver tries to poll |
793 |
+@@ -1044,6 +1044,18 @@ int xhci_resume(struct xhci_hcd *xhci, bool hibernated) |
794 |
+ hibernated = true; |
795 |
+ |
796 |
+ if (!hibernated) { |
797 |
++ /* |
798 |
++ * Some controllers might lose power during suspend, so wait |
799 |
++ * for controller not ready bit to clear, just as in xHC init. |
800 |
++ */ |
801 |
++ retval = xhci_handshake(&xhci->op_regs->status, |
802 |
++ STS_CNR, 0, 10 * 1000 * 1000); |
803 |
++ if (retval) { |
804 |
++ xhci_warn(xhci, "Controller not ready at resume %d\n", |
805 |
++ retval); |
806 |
++ spin_unlock_irq(&xhci->lock); |
807 |
++ return retval; |
808 |
++ } |
809 |
+ /* step 1: restore register */ |
810 |
+ xhci_restore_registers(xhci); |
811 |
+ /* step 2: initialize command ring buffer */ |
812 |
+@@ -4491,12 +4503,12 @@ static int xhci_update_timeout_for_endpoint(struct xhci_hcd *xhci, |
813 |
+ alt_timeout = xhci_call_host_update_timeout_for_endpoint(xhci, udev, |
814 |
+ desc, state, timeout); |
815 |
+ |
816 |
+- /* If we found we can't enable hub-initiated LPM, or |
817 |
++ /* If we found we can't enable hub-initiated LPM, and |
818 |
+ * the U1 or U2 exit latency was too high to allow |
819 |
+- * device-initiated LPM as well, just stop searching. |
820 |
++ * device-initiated LPM as well, then we will disable LPM |
821 |
++ * for this device, so stop searching any further. |
822 |
+ */ |
823 |
+- if (alt_timeout == USB3_LPM_DISABLED || |
824 |
+- alt_timeout == USB3_LPM_DEVICE_INITIATED) { |
825 |
++ if (alt_timeout == USB3_LPM_DISABLED) { |
826 |
+ *timeout = alt_timeout; |
827 |
+ return -E2BIG; |
828 |
+ } |
829 |
+@@ -4607,10 +4619,12 @@ static u16 xhci_calculate_lpm_timeout(struct usb_hcd *hcd, |
830 |
+ if (intf->dev.driver) { |
831 |
+ driver = to_usb_driver(intf->dev.driver); |
832 |
+ if (driver && driver->disable_hub_initiated_lpm) { |
833 |
+- dev_dbg(&udev->dev, "Hub-initiated %s disabled " |
834 |
+- "at request of driver %s\n", |
835 |
+- state_name, driver->name); |
836 |
+- return xhci_get_timeout_no_hub_lpm(udev, state); |
837 |
++ dev_dbg(&udev->dev, "Hub-initiated %s disabled at request of driver %s\n", |
838 |
++ state_name, driver->name); |
839 |
++ timeout = xhci_get_timeout_no_hub_lpm(udev, |
840 |
++ state); |
841 |
++ if (timeout == USB3_LPM_DISABLED) |
842 |
++ return timeout; |
843 |
+ } |
844 |
+ } |
845 |
+ |
846 |
+diff --git a/drivers/usb/image/microtek.c b/drivers/usb/image/microtek.c |
847 |
+index 0b21ba757bba..f5f68866b7fb 100644 |
848 |
+--- a/drivers/usb/image/microtek.c |
849 |
++++ b/drivers/usb/image/microtek.c |
850 |
+@@ -720,6 +720,10 @@ static int mts_usb_probe(struct usb_interface *intf, |
851 |
+ |
852 |
+ } |
853 |
+ |
854 |
++ if (ep_in_current != &ep_in_set[2]) { |
855 |
++ MTS_WARNING("couldn't find two input bulk endpoints. Bailing out.\n"); |
856 |
++ return -ENODEV; |
857 |
++ } |
858 |
+ |
859 |
+ if ( ep_out == -1 ) { |
860 |
+ MTS_WARNING( "couldn't find an output bulk endpoint. Bailing out.\n" ); |
861 |
+diff --git a/drivers/usb/misc/Kconfig b/drivers/usb/misc/Kconfig |
862 |
+index 0f9f25db9163..ad78de3cbfaa 100644 |
863 |
+--- a/drivers/usb/misc/Kconfig |
864 |
++++ b/drivers/usb/misc/Kconfig |
865 |
+@@ -46,16 +46,6 @@ config USB_SEVSEG |
866 |
+ To compile this driver as a module, choose M here: the |
867 |
+ module will be called usbsevseg. |
868 |
+ |
869 |
+-config USB_RIO500 |
870 |
+- tristate "USB Diamond Rio500 support" |
871 |
+- help |
872 |
+- Say Y here if you want to connect a USB Rio500 mp3 player to your |
873 |
+- computer's USB port. Please read <file:Documentation/usb/rio.txt> |
874 |
+- for more information. |
875 |
+- |
876 |
+- To compile this driver as a module, choose M here: the |
877 |
+- module will be called rio500. |
878 |
+- |
879 |
+ config USB_LEGOTOWER |
880 |
+ tristate "USB Lego Infrared Tower support" |
881 |
+ help |
882 |
+diff --git a/drivers/usb/misc/Makefile b/drivers/usb/misc/Makefile |
883 |
+index 109f54f5b9aa..0d416eb624bb 100644 |
884 |
+--- a/drivers/usb/misc/Makefile |
885 |
++++ b/drivers/usb/misc/Makefile |
886 |
+@@ -17,7 +17,6 @@ obj-$(CONFIG_USB_ISIGHTFW) += isight_firmware.o |
887 |
+ obj-$(CONFIG_USB_LCD) += usblcd.o |
888 |
+ obj-$(CONFIG_USB_LD) += ldusb.o |
889 |
+ obj-$(CONFIG_USB_LEGOTOWER) += legousbtower.o |
890 |
+-obj-$(CONFIG_USB_RIO500) += rio500.o |
891 |
+ obj-$(CONFIG_USB_TEST) += usbtest.o |
892 |
+ obj-$(CONFIG_USB_EHSET_TEST_FIXTURE) += ehset.o |
893 |
+ obj-$(CONFIG_USB_TRANCEVIBRATOR) += trancevibrator.o |
894 |
+diff --git a/drivers/usb/misc/adutux.c b/drivers/usb/misc/adutux.c |
895 |
+index 1c0ada75c35d..c8c8fa3f1f46 100644 |
896 |
+--- a/drivers/usb/misc/adutux.c |
897 |
++++ b/drivers/usb/misc/adutux.c |
898 |
+@@ -79,6 +79,7 @@ struct adu_device { |
899 |
+ char serial_number[8]; |
900 |
+ |
901 |
+ int open_count; /* number of times this port has been opened */ |
902 |
++ unsigned long disconnected:1; |
903 |
+ |
904 |
+ char *read_buffer_primary; |
905 |
+ int read_buffer_length; |
906 |
+@@ -120,7 +121,7 @@ static void adu_abort_transfers(struct adu_device *dev) |
907 |
+ { |
908 |
+ unsigned long flags; |
909 |
+ |
910 |
+- if (dev->udev == NULL) |
911 |
++ if (dev->disconnected) |
912 |
+ return; |
913 |
+ |
914 |
+ /* shutdown transfer */ |
915 |
+@@ -150,6 +151,7 @@ static void adu_delete(struct adu_device *dev) |
916 |
+ kfree(dev->read_buffer_secondary); |
917 |
+ kfree(dev->interrupt_in_buffer); |
918 |
+ kfree(dev->interrupt_out_buffer); |
919 |
++ usb_put_dev(dev->udev); |
920 |
+ kfree(dev); |
921 |
+ } |
922 |
+ |
923 |
+@@ -243,7 +245,7 @@ static int adu_open(struct inode *inode, struct file *file) |
924 |
+ } |
925 |
+ |
926 |
+ dev = usb_get_intfdata(interface); |
927 |
+- if (!dev || !dev->udev) { |
928 |
++ if (!dev) { |
929 |
+ retval = -ENODEV; |
930 |
+ goto exit_no_device; |
931 |
+ } |
932 |
+@@ -326,7 +328,7 @@ static int adu_release(struct inode *inode, struct file *file) |
933 |
+ } |
934 |
+ |
935 |
+ adu_release_internal(dev); |
936 |
+- if (dev->udev == NULL) { |
937 |
++ if (dev->disconnected) { |
938 |
+ /* the device was unplugged before the file was released */ |
939 |
+ if (!dev->open_count) /* ... and we're the last user */ |
940 |
+ adu_delete(dev); |
941 |
+@@ -355,7 +357,7 @@ static ssize_t adu_read(struct file *file, __user char *buffer, size_t count, |
942 |
+ return -ERESTARTSYS; |
943 |
+ |
944 |
+ /* verify that the device wasn't unplugged */ |
945 |
+- if (dev->udev == NULL) { |
946 |
++ if (dev->disconnected) { |
947 |
+ retval = -ENODEV; |
948 |
+ pr_err("No device or device unplugged %d\n", retval); |
949 |
+ goto exit; |
950 |
+@@ -520,7 +522,7 @@ static ssize_t adu_write(struct file *file, const __user char *buffer, |
951 |
+ goto exit_nolock; |
952 |
+ |
953 |
+ /* verify that the device wasn't unplugged */ |
954 |
+- if (dev->udev == NULL) { |
955 |
++ if (dev->disconnected) { |
956 |
+ retval = -ENODEV; |
957 |
+ pr_err("No device or device unplugged %d\n", retval); |
958 |
+ goto exit; |
959 |
+@@ -665,7 +667,7 @@ static int adu_probe(struct usb_interface *interface, |
960 |
+ |
961 |
+ mutex_init(&dev->mtx); |
962 |
+ spin_lock_init(&dev->buflock); |
963 |
+- dev->udev = udev; |
964 |
++ dev->udev = usb_get_dev(udev); |
965 |
+ init_waitqueue_head(&dev->read_wait); |
966 |
+ init_waitqueue_head(&dev->write_wait); |
967 |
+ |
968 |
+@@ -761,19 +763,21 @@ error: |
969 |
+ static void adu_disconnect(struct usb_interface *interface) |
970 |
+ { |
971 |
+ struct adu_device *dev; |
972 |
+- int minor; |
973 |
+ |
974 |
+ dev = usb_get_intfdata(interface); |
975 |
+ |
976 |
+- mutex_lock(&dev->mtx); /* not interruptible */ |
977 |
+- dev->udev = NULL; /* poison */ |
978 |
+- minor = dev->minor; |
979 |
+ usb_deregister_dev(interface, &adu_class); |
980 |
+- mutex_unlock(&dev->mtx); |
981 |
++ |
982 |
++ usb_poison_urb(dev->interrupt_in_urb); |
983 |
++ usb_poison_urb(dev->interrupt_out_urb); |
984 |
+ |
985 |
+ mutex_lock(&adutux_mutex); |
986 |
+ usb_set_intfdata(interface, NULL); |
987 |
+ |
988 |
++ mutex_lock(&dev->mtx); /* not interruptible */ |
989 |
++ dev->disconnected = 1; |
990 |
++ mutex_unlock(&dev->mtx); |
991 |
++ |
992 |
+ /* if the device is not opened, then we clean up right now */ |
993 |
+ if (!dev->open_count) |
994 |
+ adu_delete(dev); |
995 |
+diff --git a/drivers/usb/misc/chaoskey.c b/drivers/usb/misc/chaoskey.c |
996 |
+index abec6e604a62..eb0795c5ff7a 100644 |
997 |
+--- a/drivers/usb/misc/chaoskey.c |
998 |
++++ b/drivers/usb/misc/chaoskey.c |
999 |
+@@ -106,6 +106,7 @@ static void chaoskey_free(struct chaoskey *dev) |
1000 |
+ usb_free_urb(dev->urb); |
1001 |
+ kfree(dev->name); |
1002 |
+ kfree(dev->buf); |
1003 |
++ usb_put_intf(dev->interface); |
1004 |
+ kfree(dev); |
1005 |
+ } |
1006 |
+ } |
1007 |
+@@ -153,6 +154,8 @@ static int chaoskey_probe(struct usb_interface *interface, |
1008 |
+ if (dev == NULL) |
1009 |
+ goto out; |
1010 |
+ |
1011 |
++ dev->interface = usb_get_intf(interface); |
1012 |
++ |
1013 |
+ dev->buf = kmalloc(size, GFP_KERNEL); |
1014 |
+ |
1015 |
+ if (dev->buf == NULL) |
1016 |
+@@ -186,8 +189,6 @@ static int chaoskey_probe(struct usb_interface *interface, |
1017 |
+ strcat(dev->name, udev->serial); |
1018 |
+ } |
1019 |
+ |
1020 |
+- dev->interface = interface; |
1021 |
+- |
1022 |
+ dev->in_ep = in_ep; |
1023 |
+ |
1024 |
+ if (le16_to_cpu(udev->descriptor.idVendor) != ALEA_VENDOR_ID) |
1025 |
+diff --git a/drivers/usb/misc/iowarrior.c b/drivers/usb/misc/iowarrior.c |
1026 |
+index 43bee6dad5c9..7f226cc3ef8a 100644 |
1027 |
+--- a/drivers/usb/misc/iowarrior.c |
1028 |
++++ b/drivers/usb/misc/iowarrior.c |
1029 |
+@@ -87,6 +87,7 @@ struct iowarrior { |
1030 |
+ char chip_serial[9]; /* the serial number string of the chip connected */ |
1031 |
+ int report_size; /* number of bytes in a report */ |
1032 |
+ u16 product_id; |
1033 |
++ struct usb_anchor submitted; |
1034 |
+ }; |
1035 |
+ |
1036 |
+ /*--------------*/ |
1037 |
+@@ -246,6 +247,7 @@ static inline void iowarrior_delete(struct iowarrior *dev) |
1038 |
+ kfree(dev->int_in_buffer); |
1039 |
+ usb_free_urb(dev->int_in_urb); |
1040 |
+ kfree(dev->read_queue); |
1041 |
++ usb_put_intf(dev->interface); |
1042 |
+ kfree(dev); |
1043 |
+ } |
1044 |
+ |
1045 |
+@@ -427,11 +429,13 @@ static ssize_t iowarrior_write(struct file *file, |
1046 |
+ retval = -EFAULT; |
1047 |
+ goto error; |
1048 |
+ } |
1049 |
++ usb_anchor_urb(int_out_urb, &dev->submitted); |
1050 |
+ retval = usb_submit_urb(int_out_urb, GFP_KERNEL); |
1051 |
+ if (retval) { |
1052 |
+ dev_dbg(&dev->interface->dev, |
1053 |
+ "submit error %d for urb nr.%d\n", |
1054 |
+ retval, atomic_read(&dev->write_busy)); |
1055 |
++ usb_unanchor_urb(int_out_urb); |
1056 |
+ goto error; |
1057 |
+ } |
1058 |
+ /* submit was ok */ |
1059 |
+@@ -768,11 +772,13 @@ static int iowarrior_probe(struct usb_interface *interface, |
1060 |
+ init_waitqueue_head(&dev->write_wait); |
1061 |
+ |
1062 |
+ dev->udev = udev; |
1063 |
+- dev->interface = interface; |
1064 |
++ dev->interface = usb_get_intf(interface); |
1065 |
+ |
1066 |
+ iface_desc = interface->cur_altsetting; |
1067 |
+ dev->product_id = le16_to_cpu(udev->descriptor.idProduct); |
1068 |
+ |
1069 |
++ init_usb_anchor(&dev->submitted); |
1070 |
++ |
1071 |
+ res = usb_find_last_int_in_endpoint(iface_desc, &dev->int_in_endpoint); |
1072 |
+ if (res) { |
1073 |
+ dev_err(&interface->dev, "no interrupt-in endpoint found\n"); |
1074 |
+@@ -870,8 +876,6 @@ static void iowarrior_disconnect(struct usb_interface *interface) |
1075 |
+ dev = usb_get_intfdata(interface); |
1076 |
+ mutex_lock(&iowarrior_open_disc_lock); |
1077 |
+ usb_set_intfdata(interface, NULL); |
1078 |
+- /* prevent device read, write and ioctl */ |
1079 |
+- dev->present = 0; |
1080 |
+ |
1081 |
+ minor = dev->minor; |
1082 |
+ mutex_unlock(&iowarrior_open_disc_lock); |
1083 |
+@@ -882,8 +886,7 @@ static void iowarrior_disconnect(struct usb_interface *interface) |
1084 |
+ mutex_lock(&dev->mutex); |
1085 |
+ |
1086 |
+ /* prevent device read, write and ioctl */ |
1087 |
+- |
1088 |
+- mutex_unlock(&dev->mutex); |
1089 |
++ dev->present = 0; |
1090 |
+ |
1091 |
+ if (dev->opened) { |
1092 |
+ /* There is a process that holds a filedescriptor to the device , |
1093 |
+@@ -891,10 +894,13 @@ static void iowarrior_disconnect(struct usb_interface *interface) |
1094 |
+ Deleting the device is postponed until close() was called. |
1095 |
+ */ |
1096 |
+ usb_kill_urb(dev->int_in_urb); |
1097 |
++ usb_kill_anchored_urbs(&dev->submitted); |
1098 |
+ wake_up_interruptible(&dev->read_wait); |
1099 |
+ wake_up_interruptible(&dev->write_wait); |
1100 |
++ mutex_unlock(&dev->mutex); |
1101 |
+ } else { |
1102 |
+ /* no process is using the device, cleanup now */ |
1103 |
++ mutex_unlock(&dev->mutex); |
1104 |
+ iowarrior_delete(dev); |
1105 |
+ } |
1106 |
+ |
1107 |
+diff --git a/drivers/usb/misc/ldusb.c b/drivers/usb/misc/ldusb.c |
1108 |
+index 6635a3c990f6..fa5cf349ae19 100644 |
1109 |
+--- a/drivers/usb/misc/ldusb.c |
1110 |
++++ b/drivers/usb/misc/ldusb.c |
1111 |
+@@ -157,6 +157,7 @@ MODULE_PARM_DESC(min_interrupt_out_interval, "Minimum interrupt out interval in |
1112 |
+ struct ld_usb { |
1113 |
+ struct mutex mutex; /* locks this structure */ |
1114 |
+ struct usb_interface *intf; /* save off the usb interface pointer */ |
1115 |
++ unsigned long disconnected:1; |
1116 |
+ |
1117 |
+ int open_count; /* number of times this port has been opened */ |
1118 |
+ |
1119 |
+@@ -196,12 +197,10 @@ static void ld_usb_abort_transfers(struct ld_usb *dev) |
1120 |
+ /* shutdown transfer */ |
1121 |
+ if (dev->interrupt_in_running) { |
1122 |
+ dev->interrupt_in_running = 0; |
1123 |
+- if (dev->intf) |
1124 |
+- usb_kill_urb(dev->interrupt_in_urb); |
1125 |
++ usb_kill_urb(dev->interrupt_in_urb); |
1126 |
+ } |
1127 |
+ if (dev->interrupt_out_busy) |
1128 |
+- if (dev->intf) |
1129 |
+- usb_kill_urb(dev->interrupt_out_urb); |
1130 |
++ usb_kill_urb(dev->interrupt_out_urb); |
1131 |
+ } |
1132 |
+ |
1133 |
+ /** |
1134 |
+@@ -209,8 +208,6 @@ static void ld_usb_abort_transfers(struct ld_usb *dev) |
1135 |
+ */ |
1136 |
+ static void ld_usb_delete(struct ld_usb *dev) |
1137 |
+ { |
1138 |
+- ld_usb_abort_transfers(dev); |
1139 |
+- |
1140 |
+ /* free data structures */ |
1141 |
+ usb_free_urb(dev->interrupt_in_urb); |
1142 |
+ usb_free_urb(dev->interrupt_out_urb); |
1143 |
+@@ -266,7 +263,7 @@ static void ld_usb_interrupt_in_callback(struct urb *urb) |
1144 |
+ |
1145 |
+ resubmit: |
1146 |
+ /* resubmit if we're still running */ |
1147 |
+- if (dev->interrupt_in_running && !dev->buffer_overflow && dev->intf) { |
1148 |
++ if (dev->interrupt_in_running && !dev->buffer_overflow) { |
1149 |
+ retval = usb_submit_urb(dev->interrupt_in_urb, GFP_ATOMIC); |
1150 |
+ if (retval) { |
1151 |
+ dev_err(&dev->intf->dev, |
1152 |
+@@ -395,7 +392,7 @@ static int ld_usb_release(struct inode *inode, struct file *file) |
1153 |
+ retval = -ENODEV; |
1154 |
+ goto unlock_exit; |
1155 |
+ } |
1156 |
+- if (dev->intf == NULL) { |
1157 |
++ if (dev->disconnected) { |
1158 |
+ /* the device was unplugged before the file was released */ |
1159 |
+ mutex_unlock(&dev->mutex); |
1160 |
+ /* unlock here as ld_usb_delete frees dev */ |
1161 |
+@@ -426,7 +423,7 @@ static unsigned int ld_usb_poll(struct file *file, poll_table *wait) |
1162 |
+ |
1163 |
+ dev = file->private_data; |
1164 |
+ |
1165 |
+- if (!dev->intf) |
1166 |
++ if (dev->disconnected) |
1167 |
+ return POLLERR | POLLHUP; |
1168 |
+ |
1169 |
+ poll_wait(file, &dev->read_wait, wait); |
1170 |
+@@ -465,7 +462,7 @@ static ssize_t ld_usb_read(struct file *file, char __user *buffer, size_t count, |
1171 |
+ } |
1172 |
+ |
1173 |
+ /* verify that the device wasn't unplugged */ |
1174 |
+- if (dev->intf == NULL) { |
1175 |
++ if (dev->disconnected) { |
1176 |
+ retval = -ENODEV; |
1177 |
+ printk(KERN_ERR "ldusb: No device or device unplugged %d\n", retval); |
1178 |
+ goto unlock_exit; |
1179 |
+@@ -545,7 +542,7 @@ static ssize_t ld_usb_write(struct file *file, const char __user *buffer, |
1180 |
+ } |
1181 |
+ |
1182 |
+ /* verify that the device wasn't unplugged */ |
1183 |
+- if (dev->intf == NULL) { |
1184 |
++ if (dev->disconnected) { |
1185 |
+ retval = -ENODEV; |
1186 |
+ printk(KERN_ERR "ldusb: No device or device unplugged %d\n", retval); |
1187 |
+ goto unlock_exit; |
1188 |
+@@ -762,6 +759,9 @@ static void ld_usb_disconnect(struct usb_interface *intf) |
1189 |
+ /* give back our minor */ |
1190 |
+ usb_deregister_dev(intf, &ld_usb_class); |
1191 |
+ |
1192 |
++ usb_poison_urb(dev->interrupt_in_urb); |
1193 |
++ usb_poison_urb(dev->interrupt_out_urb); |
1194 |
++ |
1195 |
+ mutex_lock(&dev->mutex); |
1196 |
+ |
1197 |
+ /* if the device is not opened, then we clean up right now */ |
1198 |
+@@ -769,7 +769,7 @@ static void ld_usb_disconnect(struct usb_interface *intf) |
1199 |
+ mutex_unlock(&dev->mutex); |
1200 |
+ ld_usb_delete(dev); |
1201 |
+ } else { |
1202 |
+- dev->intf = NULL; |
1203 |
++ dev->disconnected = 1; |
1204 |
+ /* wake up pollers */ |
1205 |
+ wake_up_interruptible_all(&dev->read_wait); |
1206 |
+ wake_up_interruptible_all(&dev->write_wait); |
1207 |
+diff --git a/drivers/usb/misc/legousbtower.c b/drivers/usb/misc/legousbtower.c |
1208 |
+index 5628f678ab59..155615aadc9c 100644 |
1209 |
+--- a/drivers/usb/misc/legousbtower.c |
1210 |
++++ b/drivers/usb/misc/legousbtower.c |
1211 |
+@@ -183,7 +183,6 @@ static const struct usb_device_id tower_table[] = { |
1212 |
+ }; |
1213 |
+ |
1214 |
+ MODULE_DEVICE_TABLE (usb, tower_table); |
1215 |
+-static DEFINE_MUTEX(open_disc_mutex); |
1216 |
+ |
1217 |
+ #define LEGO_USB_TOWER_MINOR_BASE 160 |
1218 |
+ |
1219 |
+@@ -195,6 +194,7 @@ struct lego_usb_tower { |
1220 |
+ unsigned char minor; /* the starting minor number for this device */ |
1221 |
+ |
1222 |
+ int open_count; /* number of times this port has been opened */ |
1223 |
++ unsigned long disconnected:1; |
1224 |
+ |
1225 |
+ char* read_buffer; |
1226 |
+ size_t read_buffer_length; /* this much came in */ |
1227 |
+@@ -294,14 +294,13 @@ static inline void lego_usb_tower_debug_data(struct device *dev, |
1228 |
+ */ |
1229 |
+ static inline void tower_delete (struct lego_usb_tower *dev) |
1230 |
+ { |
1231 |
+- tower_abort_transfers (dev); |
1232 |
+- |
1233 |
+ /* free data structures */ |
1234 |
+ usb_free_urb(dev->interrupt_in_urb); |
1235 |
+ usb_free_urb(dev->interrupt_out_urb); |
1236 |
+ kfree (dev->read_buffer); |
1237 |
+ kfree (dev->interrupt_in_buffer); |
1238 |
+ kfree (dev->interrupt_out_buffer); |
1239 |
++ usb_put_dev(dev->udev); |
1240 |
+ kfree (dev); |
1241 |
+ } |
1242 |
+ |
1243 |
+@@ -336,18 +335,14 @@ static int tower_open (struct inode *inode, struct file *file) |
1244 |
+ goto exit; |
1245 |
+ } |
1246 |
+ |
1247 |
+- mutex_lock(&open_disc_mutex); |
1248 |
+ dev = usb_get_intfdata(interface); |
1249 |
+- |
1250 |
+ if (!dev) { |
1251 |
+- mutex_unlock(&open_disc_mutex); |
1252 |
+ retval = -ENODEV; |
1253 |
+ goto exit; |
1254 |
+ } |
1255 |
+ |
1256 |
+ /* lock this device */ |
1257 |
+ if (mutex_lock_interruptible(&dev->lock)) { |
1258 |
+- mutex_unlock(&open_disc_mutex); |
1259 |
+ retval = -ERESTARTSYS; |
1260 |
+ goto exit; |
1261 |
+ } |
1262 |
+@@ -355,12 +350,9 @@ static int tower_open (struct inode *inode, struct file *file) |
1263 |
+ |
1264 |
+ /* allow opening only once */ |
1265 |
+ if (dev->open_count) { |
1266 |
+- mutex_unlock(&open_disc_mutex); |
1267 |
+ retval = -EBUSY; |
1268 |
+ goto unlock_exit; |
1269 |
+ } |
1270 |
+- dev->open_count = 1; |
1271 |
+- mutex_unlock(&open_disc_mutex); |
1272 |
+ |
1273 |
+ /* reset the tower */ |
1274 |
+ result = usb_control_msg (dev->udev, |
1275 |
+@@ -400,13 +392,14 @@ static int tower_open (struct inode *inode, struct file *file) |
1276 |
+ dev_err(&dev->udev->dev, |
1277 |
+ "Couldn't submit interrupt_in_urb %d\n", retval); |
1278 |
+ dev->interrupt_in_running = 0; |
1279 |
+- dev->open_count = 0; |
1280 |
+ goto unlock_exit; |
1281 |
+ } |
1282 |
+ |
1283 |
+ /* save device in the file's private structure */ |
1284 |
+ file->private_data = dev; |
1285 |
+ |
1286 |
++ dev->open_count = 1; |
1287 |
++ |
1288 |
+ unlock_exit: |
1289 |
+ mutex_unlock(&dev->lock); |
1290 |
+ |
1291 |
+@@ -427,10 +420,9 @@ static int tower_release (struct inode *inode, struct file *file) |
1292 |
+ |
1293 |
+ if (dev == NULL) { |
1294 |
+ retval = -ENODEV; |
1295 |
+- goto exit_nolock; |
1296 |
++ goto exit; |
1297 |
+ } |
1298 |
+ |
1299 |
+- mutex_lock(&open_disc_mutex); |
1300 |
+ if (mutex_lock_interruptible(&dev->lock)) { |
1301 |
+ retval = -ERESTARTSYS; |
1302 |
+ goto exit; |
1303 |
+@@ -442,7 +434,8 @@ static int tower_release (struct inode *inode, struct file *file) |
1304 |
+ retval = -ENODEV; |
1305 |
+ goto unlock_exit; |
1306 |
+ } |
1307 |
+- if (dev->udev == NULL) { |
1308 |
++ |
1309 |
++ if (dev->disconnected) { |
1310 |
+ /* the device was unplugged before the file was released */ |
1311 |
+ |
1312 |
+ /* unlock here as tower_delete frees dev */ |
1313 |
+@@ -460,10 +453,7 @@ static int tower_release (struct inode *inode, struct file *file) |
1314 |
+ |
1315 |
+ unlock_exit: |
1316 |
+ mutex_unlock(&dev->lock); |
1317 |
+- |
1318 |
+ exit: |
1319 |
+- mutex_unlock(&open_disc_mutex); |
1320 |
+-exit_nolock: |
1321 |
+ return retval; |
1322 |
+ } |
1323 |
+ |
1324 |
+@@ -481,10 +471,9 @@ static void tower_abort_transfers (struct lego_usb_tower *dev) |
1325 |
+ if (dev->interrupt_in_running) { |
1326 |
+ dev->interrupt_in_running = 0; |
1327 |
+ mb(); |
1328 |
+- if (dev->udev) |
1329 |
+- usb_kill_urb (dev->interrupt_in_urb); |
1330 |
++ usb_kill_urb(dev->interrupt_in_urb); |
1331 |
+ } |
1332 |
+- if (dev->interrupt_out_busy && dev->udev) |
1333 |
++ if (dev->interrupt_out_busy) |
1334 |
+ usb_kill_urb(dev->interrupt_out_urb); |
1335 |
+ } |
1336 |
+ |
1337 |
+@@ -520,7 +509,7 @@ static unsigned int tower_poll (struct file *file, poll_table *wait) |
1338 |
+ |
1339 |
+ dev = file->private_data; |
1340 |
+ |
1341 |
+- if (!dev->udev) |
1342 |
++ if (dev->disconnected) |
1343 |
+ return POLLERR | POLLHUP; |
1344 |
+ |
1345 |
+ poll_wait(file, &dev->read_wait, wait); |
1346 |
+@@ -567,7 +556,7 @@ static ssize_t tower_read (struct file *file, char __user *buffer, size_t count, |
1347 |
+ } |
1348 |
+ |
1349 |
+ /* verify that the device wasn't unplugged */ |
1350 |
+- if (dev->udev == NULL) { |
1351 |
++ if (dev->disconnected) { |
1352 |
+ retval = -ENODEV; |
1353 |
+ pr_err("No device or device unplugged %d\n", retval); |
1354 |
+ goto unlock_exit; |
1355 |
+@@ -653,7 +642,7 @@ static ssize_t tower_write (struct file *file, const char __user *buffer, size_t |
1356 |
+ } |
1357 |
+ |
1358 |
+ /* verify that the device wasn't unplugged */ |
1359 |
+- if (dev->udev == NULL) { |
1360 |
++ if (dev->disconnected) { |
1361 |
+ retval = -ENODEV; |
1362 |
+ pr_err("No device or device unplugged %d\n", retval); |
1363 |
+ goto unlock_exit; |
1364 |
+@@ -762,7 +751,7 @@ static void tower_interrupt_in_callback (struct urb *urb) |
1365 |
+ |
1366 |
+ resubmit: |
1367 |
+ /* resubmit if we're still running */ |
1368 |
+- if (dev->interrupt_in_running && dev->udev) { |
1369 |
++ if (dev->interrupt_in_running) { |
1370 |
+ retval = usb_submit_urb (dev->interrupt_in_urb, GFP_ATOMIC); |
1371 |
+ if (retval) |
1372 |
+ dev_err(&dev->udev->dev, |
1373 |
+@@ -825,8 +814,9 @@ static int tower_probe (struct usb_interface *interface, const struct usb_device |
1374 |
+ |
1375 |
+ mutex_init(&dev->lock); |
1376 |
+ |
1377 |
+- dev->udev = udev; |
1378 |
++ dev->udev = usb_get_dev(udev); |
1379 |
+ dev->open_count = 0; |
1380 |
++ dev->disconnected = 0; |
1381 |
+ |
1382 |
+ dev->read_buffer = NULL; |
1383 |
+ dev->read_buffer_length = 0; |
1384 |
+@@ -894,8 +884,10 @@ static int tower_probe (struct usb_interface *interface, const struct usb_device |
1385 |
+ get_version_reply, |
1386 |
+ sizeof(*get_version_reply), |
1387 |
+ 1000); |
1388 |
+- if (result < 0) { |
1389 |
+- dev_err(idev, "LEGO USB Tower get version control request failed\n"); |
1390 |
++ if (result < sizeof(*get_version_reply)) { |
1391 |
++ if (result >= 0) |
1392 |
++ result = -EIO; |
1393 |
++ dev_err(idev, "get version request failed: %d\n", result); |
1394 |
+ retval = result; |
1395 |
+ goto error; |
1396 |
+ } |
1397 |
+@@ -913,7 +905,6 @@ static int tower_probe (struct usb_interface *interface, const struct usb_device |
1398 |
+ if (retval) { |
1399 |
+ /* something prevented us from registering this driver */ |
1400 |
+ dev_err(idev, "Not able to get a minor for this device.\n"); |
1401 |
+- usb_set_intfdata (interface, NULL); |
1402 |
+ goto error; |
1403 |
+ } |
1404 |
+ dev->minor = interface->minor; |
1405 |
+@@ -945,23 +936,24 @@ static void tower_disconnect (struct usb_interface *interface) |
1406 |
+ int minor; |
1407 |
+ |
1408 |
+ dev = usb_get_intfdata (interface); |
1409 |
+- mutex_lock(&open_disc_mutex); |
1410 |
+- usb_set_intfdata (interface, NULL); |
1411 |
+ |
1412 |
+ minor = dev->minor; |
1413 |
+ |
1414 |
+- /* give back our minor */ |
1415 |
++ /* give back our minor and prevent further open() */ |
1416 |
+ usb_deregister_dev (interface, &tower_class); |
1417 |
+ |
1418 |
++ /* stop I/O */ |
1419 |
++ usb_poison_urb(dev->interrupt_in_urb); |
1420 |
++ usb_poison_urb(dev->interrupt_out_urb); |
1421 |
++ |
1422 |
+ mutex_lock(&dev->lock); |
1423 |
+- mutex_unlock(&open_disc_mutex); |
1424 |
+ |
1425 |
+ /* if the device is not opened, then we clean up right now */ |
1426 |
+ if (!dev->open_count) { |
1427 |
+ mutex_unlock(&dev->lock); |
1428 |
+ tower_delete (dev); |
1429 |
+ } else { |
1430 |
+- dev->udev = NULL; |
1431 |
++ dev->disconnected = 1; |
1432 |
+ /* wake up pollers */ |
1433 |
+ wake_up_interruptible_all(&dev->read_wait); |
1434 |
+ wake_up_interruptible_all(&dev->write_wait); |
1435 |
+diff --git a/drivers/usb/misc/rio500.c b/drivers/usb/misc/rio500.c |
1436 |
+deleted file mode 100644 |
1437 |
+index c652a4fdc546..000000000000 |
1438 |
+--- a/drivers/usb/misc/rio500.c |
1439 |
++++ /dev/null |
1440 |
+@@ -1,574 +0,0 @@ |
1441 |
+-/* -*- linux-c -*- */ |
1442 |
+- |
1443 |
+-/* |
1444 |
+- * Driver for USB Rio 500 |
1445 |
+- * |
1446 |
+- * Cesar Miquel (miquel@××××××.ar) |
1447 |
+- * |
1448 |
+- * based on hp_scanner.c by David E. Nelson (dnelson@××××.net) |
1449 |
+- * |
1450 |
+- * This program is free software; you can redistribute it and/or |
1451 |
+- * modify it under the terms of the GNU General Public License as |
1452 |
+- * published by the Free Software Foundation; either version 2 of the |
1453 |
+- * License, or (at your option) any later version. |
1454 |
+- * |
1455 |
+- * This program is distributed in the hope that it will be useful, but |
1456 |
+- * WITHOUT ANY WARRANTY; without even the implied warranty of |
1457 |
+- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
1458 |
+- * General Public License for more details. |
1459 |
+- * |
1460 |
+- * You should have received a copy of the GNU General Public License |
1461 |
+- * along with this program; if not, write to the Free Software |
1462 |
+- * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. |
1463 |
+- * |
1464 |
+- * Based upon mouse.c (Brad Keryan) and printer.c (Michael Gee). |
1465 |
+- * |
1466 |
+- * Changelog: |
1467 |
+- * 30/05/2003 replaced lock/unlock kernel with up/down |
1468 |
+- * Daniele Bellucci bellucda@×××××××.it |
1469 |
+- * */ |
1470 |
+- |
1471 |
+-#include <linux/module.h> |
1472 |
+-#include <linux/kernel.h> |
1473 |
+-#include <linux/signal.h> |
1474 |
+-#include <linux/sched/signal.h> |
1475 |
+-#include <linux/mutex.h> |
1476 |
+-#include <linux/errno.h> |
1477 |
+-#include <linux/random.h> |
1478 |
+-#include <linux/poll.h> |
1479 |
+-#include <linux/slab.h> |
1480 |
+-#include <linux/spinlock.h> |
1481 |
+-#include <linux/usb.h> |
1482 |
+-#include <linux/wait.h> |
1483 |
+- |
1484 |
+-#include "rio500_usb.h" |
1485 |
+- |
1486 |
+-#define DRIVER_AUTHOR "Cesar Miquel <miquel@××××××.ar>" |
1487 |
+-#define DRIVER_DESC "USB Rio 500 driver" |
1488 |
+- |
1489 |
+-#define RIO_MINOR 64 |
1490 |
+- |
1491 |
+-/* stall/wait timeout for rio */ |
1492 |
+-#define NAK_TIMEOUT (HZ) |
1493 |
+- |
1494 |
+-#define IBUF_SIZE 0x1000 |
1495 |
+- |
1496 |
+-/* Size of the rio buffer */ |
1497 |
+-#define OBUF_SIZE 0x10000 |
1498 |
+- |
1499 |
+-struct rio_usb_data { |
1500 |
+- struct usb_device *rio_dev; /* init: probe_rio */ |
1501 |
+- unsigned int ifnum; /* Interface number of the USB device */ |
1502 |
+- int isopen; /* nz if open */ |
1503 |
+- int present; /* Device is present on the bus */ |
1504 |
+- char *obuf, *ibuf; /* transfer buffers */ |
1505 |
+- char bulk_in_ep, bulk_out_ep; /* Endpoint assignments */ |
1506 |
+- wait_queue_head_t wait_q; /* for timeouts */ |
1507 |
+- struct mutex lock; /* general race avoidance */ |
1508 |
+-}; |
1509 |
+- |
1510 |
+-static DEFINE_MUTEX(rio500_mutex); |
1511 |
+-static struct rio_usb_data rio_instance; |
1512 |
+- |
1513 |
+-static int open_rio(struct inode *inode, struct file *file) |
1514 |
+-{ |
1515 |
+- struct rio_usb_data *rio = &rio_instance; |
1516 |
+- |
1517 |
+- /* against disconnect() */ |
1518 |
+- mutex_lock(&rio500_mutex); |
1519 |
+- mutex_lock(&(rio->lock)); |
1520 |
+- |
1521 |
+- if (rio->isopen || !rio->present) { |
1522 |
+- mutex_unlock(&(rio->lock)); |
1523 |
+- mutex_unlock(&rio500_mutex); |
1524 |
+- return -EBUSY; |
1525 |
+- } |
1526 |
+- rio->isopen = 1; |
1527 |
+- |
1528 |
+- init_waitqueue_head(&rio->wait_q); |
1529 |
+- |
1530 |
+- mutex_unlock(&(rio->lock)); |
1531 |
+- |
1532 |
+- dev_info(&rio->rio_dev->dev, "Rio opened.\n"); |
1533 |
+- mutex_unlock(&rio500_mutex); |
1534 |
+- |
1535 |
+- return 0; |
1536 |
+-} |
1537 |
+- |
1538 |
+-static int close_rio(struct inode *inode, struct file *file) |
1539 |
+-{ |
1540 |
+- struct rio_usb_data *rio = &rio_instance; |
1541 |
+- |
1542 |
+- /* against disconnect() */ |
1543 |
+- mutex_lock(&rio500_mutex); |
1544 |
+- mutex_lock(&(rio->lock)); |
1545 |
+- |
1546 |
+- rio->isopen = 0; |
1547 |
+- if (!rio->present) { |
1548 |
+- /* cleanup has been delayed */ |
1549 |
+- kfree(rio->ibuf); |
1550 |
+- kfree(rio->obuf); |
1551 |
+- rio->ibuf = NULL; |
1552 |
+- rio->obuf = NULL; |
1553 |
+- } else { |
1554 |
+- dev_info(&rio->rio_dev->dev, "Rio closed.\n"); |
1555 |
+- } |
1556 |
+- mutex_unlock(&(rio->lock)); |
1557 |
+- mutex_unlock(&rio500_mutex); |
1558 |
+- return 0; |
1559 |
+-} |
1560 |
+- |
1561 |
+-static long ioctl_rio(struct file *file, unsigned int cmd, unsigned long arg) |
1562 |
+-{ |
1563 |
+- struct RioCommand rio_cmd; |
1564 |
+- struct rio_usb_data *rio = &rio_instance; |
1565 |
+- void __user *data; |
1566 |
+- unsigned char *buffer; |
1567 |
+- int result, requesttype; |
1568 |
+- int retries; |
1569 |
+- int retval=0; |
1570 |
+- |
1571 |
+- mutex_lock(&(rio->lock)); |
1572 |
+- /* Sanity check to make sure rio is connected, powered, etc */ |
1573 |
+- if (rio->present == 0 || rio->rio_dev == NULL) { |
1574 |
+- retval = -ENODEV; |
1575 |
+- goto err_out; |
1576 |
+- } |
1577 |
+- |
1578 |
+- switch (cmd) { |
1579 |
+- case RIO_RECV_COMMAND: |
1580 |
+- data = (void __user *) arg; |
1581 |
+- if (data == NULL) |
1582 |
+- break; |
1583 |
+- if (copy_from_user(&rio_cmd, data, sizeof(struct RioCommand))) { |
1584 |
+- retval = -EFAULT; |
1585 |
+- goto err_out; |
1586 |
+- } |
1587 |
+- if (rio_cmd.length < 0 || rio_cmd.length > PAGE_SIZE) { |
1588 |
+- retval = -EINVAL; |
1589 |
+- goto err_out; |
1590 |
+- } |
1591 |
+- buffer = (unsigned char *) __get_free_page(GFP_KERNEL); |
1592 |
+- if (buffer == NULL) { |
1593 |
+- retval = -ENOMEM; |
1594 |
+- goto err_out; |
1595 |
+- } |
1596 |
+- if (copy_from_user(buffer, rio_cmd.buffer, rio_cmd.length)) { |
1597 |
+- retval = -EFAULT; |
1598 |
+- free_page((unsigned long) buffer); |
1599 |
+- goto err_out; |
1600 |
+- } |
1601 |
+- |
1602 |
+- requesttype = rio_cmd.requesttype | USB_DIR_IN | |
1603 |
+- USB_TYPE_VENDOR | USB_RECIP_DEVICE; |
1604 |
+- dev_dbg(&rio->rio_dev->dev, |
1605 |
+- "sending command:reqtype=%0x req=%0x value=%0x index=%0x len=%0x\n", |
1606 |
+- requesttype, rio_cmd.request, rio_cmd.value, |
1607 |
+- rio_cmd.index, rio_cmd.length); |
1608 |
+- /* Send rio control message */ |
1609 |
+- retries = 3; |
1610 |
+- while (retries) { |
1611 |
+- result = usb_control_msg(rio->rio_dev, |
1612 |
+- usb_rcvctrlpipe(rio-> rio_dev, 0), |
1613 |
+- rio_cmd.request, |
1614 |
+- requesttype, |
1615 |
+- rio_cmd.value, |
1616 |
+- rio_cmd.index, buffer, |
1617 |
+- rio_cmd.length, |
1618 |
+- jiffies_to_msecs(rio_cmd.timeout)); |
1619 |
+- if (result == -ETIMEDOUT) |
1620 |
+- retries--; |
1621 |
+- else if (result < 0) { |
1622 |
+- dev_err(&rio->rio_dev->dev, |
1623 |
+- "Error executing ioctrl. code = %d\n", |
1624 |
+- result); |
1625 |
+- retries = 0; |
1626 |
+- } else { |
1627 |
+- dev_dbg(&rio->rio_dev->dev, |
1628 |
+- "Executed ioctl. Result = %d (data=%02x)\n", |
1629 |
+- result, buffer[0]); |
1630 |
+- if (copy_to_user(rio_cmd.buffer, buffer, |
1631 |
+- rio_cmd.length)) { |
1632 |
+- free_page((unsigned long) buffer); |
1633 |
+- retval = -EFAULT; |
1634 |
+- goto err_out; |
1635 |
+- } |
1636 |
+- retries = 0; |
1637 |
+- } |
1638 |
+- |
1639 |
+- /* rio_cmd.buffer contains a raw stream of single byte |
1640 |
+- data which has been returned from rio. Data is |
1641 |
+- interpreted at application level. For data that |
1642 |
+- will be cast to data types longer than 1 byte, data |
1643 |
+- will be little_endian and will potentially need to |
1644 |
+- be swapped at the app level */ |
1645 |
+- |
1646 |
+- } |
1647 |
+- free_page((unsigned long) buffer); |
1648 |
+- break; |
1649 |
+- |
1650 |
+- case RIO_SEND_COMMAND: |
1651 |
+- data = (void __user *) arg; |
1652 |
+- if (data == NULL) |
1653 |
+- break; |
1654 |
+- if (copy_from_user(&rio_cmd, data, sizeof(struct RioCommand))) { |
1655 |
+- retval = -EFAULT; |
1656 |
+- goto err_out; |
1657 |
+- } |
1658 |
+- if (rio_cmd.length < 0 || rio_cmd.length > PAGE_SIZE) { |
1659 |
+- retval = -EINVAL; |
1660 |
+- goto err_out; |
1661 |
+- } |
1662 |
+- buffer = (unsigned char *) __get_free_page(GFP_KERNEL); |
1663 |
+- if (buffer == NULL) { |
1664 |
+- retval = -ENOMEM; |
1665 |
+- goto err_out; |
1666 |
+- } |
1667 |
+- if (copy_from_user(buffer, rio_cmd.buffer, rio_cmd.length)) { |
1668 |
+- free_page((unsigned long)buffer); |
1669 |
+- retval = -EFAULT; |
1670 |
+- goto err_out; |
1671 |
+- } |
1672 |
+- |
1673 |
+- requesttype = rio_cmd.requesttype | USB_DIR_OUT | |
1674 |
+- USB_TYPE_VENDOR | USB_RECIP_DEVICE; |
1675 |
+- dev_dbg(&rio->rio_dev->dev, |
1676 |
+- "sending command: reqtype=%0x req=%0x value=%0x index=%0x len=%0x\n", |
1677 |
+- requesttype, rio_cmd.request, rio_cmd.value, |
1678 |
+- rio_cmd.index, rio_cmd.length); |
1679 |
+- /* Send rio control message */ |
1680 |
+- retries = 3; |
1681 |
+- while (retries) { |
1682 |
+- result = usb_control_msg(rio->rio_dev, |
1683 |
+- usb_sndctrlpipe(rio-> rio_dev, 0), |
1684 |
+- rio_cmd.request, |
1685 |
+- requesttype, |
1686 |
+- rio_cmd.value, |
1687 |
+- rio_cmd.index, buffer, |
1688 |
+- rio_cmd.length, |
1689 |
+- jiffies_to_msecs(rio_cmd.timeout)); |
1690 |
+- if (result == -ETIMEDOUT) |
1691 |
+- retries--; |
1692 |
+- else if (result < 0) { |
1693 |
+- dev_err(&rio->rio_dev->dev, |
1694 |
+- "Error executing ioctrl. code = %d\n", |
1695 |
+- result); |
1696 |
+- retries = 0; |
1697 |
+- } else { |
1698 |
+- dev_dbg(&rio->rio_dev->dev, |
1699 |
+- "Executed ioctl. Result = %d\n", result); |
1700 |
+- retries = 0; |
1701 |
+- |
1702 |
+- } |
1703 |
+- |
1704 |
+- } |
1705 |
+- free_page((unsigned long) buffer); |
1706 |
+- break; |
1707 |
+- |
1708 |
+- default: |
1709 |
+- retval = -ENOTTY; |
1710 |
+- break; |
1711 |
+- } |
1712 |
+- |
1713 |
+- |
1714 |
+-err_out: |
1715 |
+- mutex_unlock(&(rio->lock)); |
1716 |
+- return retval; |
1717 |
+-} |
1718 |
+- |
1719 |
+-static ssize_t |
1720 |
+-write_rio(struct file *file, const char __user *buffer, |
1721 |
+- size_t count, loff_t * ppos) |
1722 |
+-{ |
1723 |
+- DEFINE_WAIT(wait); |
1724 |
+- struct rio_usb_data *rio = &rio_instance; |
1725 |
+- |
1726 |
+- unsigned long copy_size; |
1727 |
+- unsigned long bytes_written = 0; |
1728 |
+- unsigned int partial; |
1729 |
+- |
1730 |
+- int result = 0; |
1731 |
+- int maxretry; |
1732 |
+- int errn = 0; |
1733 |
+- int intr; |
1734 |
+- |
1735 |
+- intr = mutex_lock_interruptible(&(rio->lock)); |
1736 |
+- if (intr) |
1737 |
+- return -EINTR; |
1738 |
+- /* Sanity check to make sure rio is connected, powered, etc */ |
1739 |
+- if (rio->present == 0 || rio->rio_dev == NULL) { |
1740 |
+- mutex_unlock(&(rio->lock)); |
1741 |
+- return -ENODEV; |
1742 |
+- } |
1743 |
+- |
1744 |
+- |
1745 |
+- |
1746 |
+- do { |
1747 |
+- unsigned long thistime; |
1748 |
+- char *obuf = rio->obuf; |
1749 |
+- |
1750 |
+- thistime = copy_size = |
1751 |
+- (count >= OBUF_SIZE) ? OBUF_SIZE : count; |
1752 |
+- if (copy_from_user(rio->obuf, buffer, copy_size)) { |
1753 |
+- errn = -EFAULT; |
1754 |
+- goto error; |
1755 |
+- } |
1756 |
+- maxretry = 5; |
1757 |
+- while (thistime) { |
1758 |
+- if (!rio->rio_dev) { |
1759 |
+- errn = -ENODEV; |
1760 |
+- goto error; |
1761 |
+- } |
1762 |
+- if (signal_pending(current)) { |
1763 |
+- mutex_unlock(&(rio->lock)); |
1764 |
+- return bytes_written ? bytes_written : -EINTR; |
1765 |
+- } |
1766 |
+- |
1767 |
+- result = usb_bulk_msg(rio->rio_dev, |
1768 |
+- usb_sndbulkpipe(rio->rio_dev, 2), |
1769 |
+- obuf, thistime, &partial, 5000); |
1770 |
+- |
1771 |
+- dev_dbg(&rio->rio_dev->dev, |
1772 |
+- "write stats: result:%d thistime:%lu partial:%u\n", |
1773 |
+- result, thistime, partial); |
1774 |
+- |
1775 |
+- if (result == -ETIMEDOUT) { /* NAK - so hold for a while */ |
1776 |
+- if (!maxretry--) { |
1777 |
+- errn = -ETIME; |
1778 |
+- goto error; |
1779 |
+- } |
1780 |
+- prepare_to_wait(&rio->wait_q, &wait, TASK_INTERRUPTIBLE); |
1781 |
+- schedule_timeout(NAK_TIMEOUT); |
1782 |
+- finish_wait(&rio->wait_q, &wait); |
1783 |
+- continue; |
1784 |
+- } else if (!result && partial) { |
1785 |
+- obuf += partial; |
1786 |
+- thistime -= partial; |
1787 |
+- } else |
1788 |
+- break; |
1789 |
+- } |
1790 |
+- if (result) { |
1791 |
+- dev_err(&rio->rio_dev->dev, "Write Whoops - %x\n", |
1792 |
+- result); |
1793 |
+- errn = -EIO; |
1794 |
+- goto error; |
1795 |
+- } |
1796 |
+- bytes_written += copy_size; |
1797 |
+- count -= copy_size; |
1798 |
+- buffer += copy_size; |
1799 |
+- } while (count > 0); |
1800 |
+- |
1801 |
+- mutex_unlock(&(rio->lock)); |
1802 |
+- |
1803 |
+- return bytes_written ? bytes_written : -EIO; |
1804 |
+- |
1805 |
+-error: |
1806 |
+- mutex_unlock(&(rio->lock)); |
1807 |
+- return errn; |
1808 |
+-} |
1809 |
+- |
1810 |
+-static ssize_t |
1811 |
+-read_rio(struct file *file, char __user *buffer, size_t count, loff_t * ppos) |
1812 |
+-{ |
1813 |
+- DEFINE_WAIT(wait); |
1814 |
+- struct rio_usb_data *rio = &rio_instance; |
1815 |
+- ssize_t read_count; |
1816 |
+- unsigned int partial; |
1817 |
+- int this_read; |
1818 |
+- int result; |
1819 |
+- int maxretry = 10; |
1820 |
+- char *ibuf; |
1821 |
+- int intr; |
1822 |
+- |
1823 |
+- intr = mutex_lock_interruptible(&(rio->lock)); |
1824 |
+- if (intr) |
1825 |
+- return -EINTR; |
1826 |
+- /* Sanity check to make sure rio is connected, powered, etc */ |
1827 |
+- if (rio->present == 0 || rio->rio_dev == NULL) { |
1828 |
+- mutex_unlock(&(rio->lock)); |
1829 |
+- return -ENODEV; |
1830 |
+- } |
1831 |
+- |
1832 |
+- ibuf = rio->ibuf; |
1833 |
+- |
1834 |
+- read_count = 0; |
1835 |
+- |
1836 |
+- |
1837 |
+- while (count > 0) { |
1838 |
+- if (signal_pending(current)) { |
1839 |
+- mutex_unlock(&(rio->lock)); |
1840 |
+- return read_count ? read_count : -EINTR; |
1841 |
+- } |
1842 |
+- if (!rio->rio_dev) { |
1843 |
+- mutex_unlock(&(rio->lock)); |
1844 |
+- return -ENODEV; |
1845 |
+- } |
1846 |
+- this_read = (count >= IBUF_SIZE) ? IBUF_SIZE : count; |
1847 |
+- |
1848 |
+- result = usb_bulk_msg(rio->rio_dev, |
1849 |
+- usb_rcvbulkpipe(rio->rio_dev, 1), |
1850 |
+- ibuf, this_read, &partial, |
1851 |
+- 8000); |
1852 |
+- |
1853 |
+- dev_dbg(&rio->rio_dev->dev, |
1854 |
+- "read stats: result:%d this_read:%u partial:%u\n", |
1855 |
+- result, this_read, partial); |
1856 |
+- |
1857 |
+- if (partial) { |
1858 |
+- count = this_read = partial; |
1859 |
+- } else if (result == -ETIMEDOUT || result == 15) { /* FIXME: 15 ??? */ |
1860 |
+- if (!maxretry--) { |
1861 |
+- mutex_unlock(&(rio->lock)); |
1862 |
+- dev_err(&rio->rio_dev->dev, |
1863 |
+- "read_rio: maxretry timeout\n"); |
1864 |
+- return -ETIME; |
1865 |
+- } |
1866 |
+- prepare_to_wait(&rio->wait_q, &wait, TASK_INTERRUPTIBLE); |
1867 |
+- schedule_timeout(NAK_TIMEOUT); |
1868 |
+- finish_wait(&rio->wait_q, &wait); |
1869 |
+- continue; |
1870 |
+- } else if (result != -EREMOTEIO) { |
1871 |
+- mutex_unlock(&(rio->lock)); |
1872 |
+- dev_err(&rio->rio_dev->dev, |
1873 |
+- "Read Whoops - result:%d partial:%u this_read:%u\n", |
1874 |
+- result, partial, this_read); |
1875 |
+- return -EIO; |
1876 |
+- } else { |
1877 |
+- mutex_unlock(&(rio->lock)); |
1878 |
+- return (0); |
1879 |
+- } |
1880 |
+- |
1881 |
+- if (this_read) { |
1882 |
+- if (copy_to_user(buffer, ibuf, this_read)) { |
1883 |
+- mutex_unlock(&(rio->lock)); |
1884 |
+- return -EFAULT; |
1885 |
+- } |
1886 |
+- count -= this_read; |
1887 |
+- read_count += this_read; |
1888 |
+- buffer += this_read; |
1889 |
+- } |
1890 |
+- } |
1891 |
+- mutex_unlock(&(rio->lock)); |
1892 |
+- return read_count; |
1893 |
+-} |
1894 |
+- |
1895 |
+-static const struct file_operations usb_rio_fops = { |
1896 |
+- .owner = THIS_MODULE, |
1897 |
+- .read = read_rio, |
1898 |
+- .write = write_rio, |
1899 |
+- .unlocked_ioctl = ioctl_rio, |
1900 |
+- .open = open_rio, |
1901 |
+- .release = close_rio, |
1902 |
+- .llseek = noop_llseek, |
1903 |
+-}; |
1904 |
+- |
1905 |
+-static struct usb_class_driver usb_rio_class = { |
1906 |
+- .name = "rio500%d", |
1907 |
+- .fops = &usb_rio_fops, |
1908 |
+- .minor_base = RIO_MINOR, |
1909 |
+-}; |
1910 |
+- |
1911 |
+-static int probe_rio(struct usb_interface *intf, |
1912 |
+- const struct usb_device_id *id) |
1913 |
+-{ |
1914 |
+- struct usb_device *dev = interface_to_usbdev(intf); |
1915 |
+- struct rio_usb_data *rio = &rio_instance; |
1916 |
+- int retval = 0; |
1917 |
+- |
1918 |
+- mutex_lock(&rio500_mutex); |
1919 |
+- if (rio->present) { |
1920 |
+- dev_info(&intf->dev, "Second USB Rio at address %d refused\n", dev->devnum); |
1921 |
+- retval = -EBUSY; |
1922 |
+- goto bail_out; |
1923 |
+- } else { |
1924 |
+- dev_info(&intf->dev, "USB Rio found at address %d\n", dev->devnum); |
1925 |
+- } |
1926 |
+- |
1927 |
+- retval = usb_register_dev(intf, &usb_rio_class); |
1928 |
+- if (retval) { |
1929 |
+- dev_err(&dev->dev, |
1930 |
+- "Not able to get a minor for this device.\n"); |
1931 |
+- retval = -ENOMEM; |
1932 |
+- goto bail_out; |
1933 |
+- } |
1934 |
+- |
1935 |
+- rio->rio_dev = dev; |
1936 |
+- |
1937 |
+- if (!(rio->obuf = kmalloc(OBUF_SIZE, GFP_KERNEL))) { |
1938 |
+- dev_err(&dev->dev, |
1939 |
+- "probe_rio: Not enough memory for the output buffer\n"); |
1940 |
+- usb_deregister_dev(intf, &usb_rio_class); |
1941 |
+- retval = -ENOMEM; |
1942 |
+- goto bail_out; |
1943 |
+- } |
1944 |
+- dev_dbg(&intf->dev, "obuf address:%p\n", rio->obuf); |
1945 |
+- |
1946 |
+- if (!(rio->ibuf = kmalloc(IBUF_SIZE, GFP_KERNEL))) { |
1947 |
+- dev_err(&dev->dev, |
1948 |
+- "probe_rio: Not enough memory for the input buffer\n"); |
1949 |
+- usb_deregister_dev(intf, &usb_rio_class); |
1950 |
+- kfree(rio->obuf); |
1951 |
+- retval = -ENOMEM; |
1952 |
+- goto bail_out; |
1953 |
+- } |
1954 |
+- dev_dbg(&intf->dev, "ibuf address:%p\n", rio->ibuf); |
1955 |
+- |
1956 |
+- mutex_init(&(rio->lock)); |
1957 |
+- |
1958 |
+- usb_set_intfdata (intf, rio); |
1959 |
+- rio->present = 1; |
1960 |
+-bail_out: |
1961 |
+- mutex_unlock(&rio500_mutex); |
1962 |
+- |
1963 |
+- return retval; |
1964 |
+-} |
1965 |
+- |
1966 |
+-static void disconnect_rio(struct usb_interface *intf) |
1967 |
+-{ |
1968 |
+- struct rio_usb_data *rio = usb_get_intfdata (intf); |
1969 |
+- |
1970 |
+- usb_set_intfdata (intf, NULL); |
1971 |
+- mutex_lock(&rio500_mutex); |
1972 |
+- if (rio) { |
1973 |
+- usb_deregister_dev(intf, &usb_rio_class); |
1974 |
+- |
1975 |
+- mutex_lock(&(rio->lock)); |
1976 |
+- if (rio->isopen) { |
1977 |
+- rio->isopen = 0; |
1978 |
+- /* better let it finish - the release will do whats needed */ |
1979 |
+- rio->rio_dev = NULL; |
1980 |
+- mutex_unlock(&(rio->lock)); |
1981 |
+- mutex_unlock(&rio500_mutex); |
1982 |
+- return; |
1983 |
+- } |
1984 |
+- kfree(rio->ibuf); |
1985 |
+- kfree(rio->obuf); |
1986 |
+- |
1987 |
+- dev_info(&intf->dev, "USB Rio disconnected.\n"); |
1988 |
+- |
1989 |
+- rio->present = 0; |
1990 |
+- mutex_unlock(&(rio->lock)); |
1991 |
+- } |
1992 |
+- mutex_unlock(&rio500_mutex); |
1993 |
+-} |
1994 |
+- |
1995 |
+-static const struct usb_device_id rio_table[] = { |
1996 |
+- { USB_DEVICE(0x0841, 1) }, /* Rio 500 */ |
1997 |
+- { } /* Terminating entry */ |
1998 |
+-}; |
1999 |
+- |
2000 |
+-MODULE_DEVICE_TABLE (usb, rio_table); |
2001 |
+- |
2002 |
+-static struct usb_driver rio_driver = { |
2003 |
+- .name = "rio500", |
2004 |
+- .probe = probe_rio, |
2005 |
+- .disconnect = disconnect_rio, |
2006 |
+- .id_table = rio_table, |
2007 |
+-}; |
2008 |
+- |
2009 |
+-module_usb_driver(rio_driver); |
2010 |
+- |
2011 |
+-MODULE_AUTHOR( DRIVER_AUTHOR ); |
2012 |
+-MODULE_DESCRIPTION( DRIVER_DESC ); |
2013 |
+-MODULE_LICENSE("GPL"); |
2014 |
+- |
2015 |
+diff --git a/drivers/usb/misc/rio500_usb.h b/drivers/usb/misc/rio500_usb.h |
2016 |
+deleted file mode 100644 |
2017 |
+index 359abc98e706..000000000000 |
2018 |
+--- a/drivers/usb/misc/rio500_usb.h |
2019 |
++++ /dev/null |
2020 |
+@@ -1,37 +0,0 @@ |
2021 |
+-/* ---------------------------------------------------------------------- |
2022 |
+- |
2023 |
+- Copyright (C) 2000 Cesar Miquel (miquel@××××××.ar) |
2024 |
+- |
2025 |
+- This program is free software; you can redistribute it and/or modify |
2026 |
+- it under the terms of the GNU General Public License as published by |
2027 |
+- the Free Software Foundation; either version 2 of the License, or |
2028 |
+- (at your option) any later version. |
2029 |
+- |
2030 |
+- This program is distributed in the hope that it will be useful, |
2031 |
+- but WITHOUT ANY WARRANTY; without even the implied warranty of |
2032 |
+- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
2033 |
+- GNU General Public License for more details. |
2034 |
+- |
2035 |
+- You should have received a copy of the GNU General Public License |
2036 |
+- along with this program; if not, write to the Free Software |
2037 |
+- Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. |
2038 |
+- |
2039 |
+- ---------------------------------------------------------------------- */ |
2040 |
+- |
2041 |
+- |
2042 |
+- |
2043 |
+-#define RIO_SEND_COMMAND 0x1 |
2044 |
+-#define RIO_RECV_COMMAND 0x2 |
2045 |
+- |
2046 |
+-#define RIO_DIR_OUT 0x0 |
2047 |
+-#define RIO_DIR_IN 0x1 |
2048 |
+- |
2049 |
+-struct RioCommand { |
2050 |
+- short length; |
2051 |
+- int request; |
2052 |
+- int requesttype; |
2053 |
+- int value; |
2054 |
+- int index; |
2055 |
+- void __user *buffer; |
2056 |
+- int timeout; |
2057 |
+-}; |
2058 |
+diff --git a/drivers/usb/misc/usblcd.c b/drivers/usb/misc/usblcd.c |
2059 |
+index 0f5ad896c7e3..6a50e22e0a72 100644 |
2060 |
+--- a/drivers/usb/misc/usblcd.c |
2061 |
++++ b/drivers/usb/misc/usblcd.c |
2062 |
+@@ -17,6 +17,7 @@ |
2063 |
+ #include <linux/slab.h> |
2064 |
+ #include <linux/errno.h> |
2065 |
+ #include <linux/mutex.h> |
2066 |
++#include <linux/rwsem.h> |
2067 |
+ #include <linux/uaccess.h> |
2068 |
+ #include <linux/usb.h> |
2069 |
+ |
2070 |
+@@ -56,6 +57,8 @@ struct usb_lcd { |
2071 |
+ using up all RAM */ |
2072 |
+ struct usb_anchor submitted; /* URBs to wait for |
2073 |
+ before suspend */ |
2074 |
++ struct rw_semaphore io_rwsem; |
2075 |
++ unsigned long disconnected:1; |
2076 |
+ }; |
2077 |
+ #define to_lcd_dev(d) container_of(d, struct usb_lcd, kref) |
2078 |
+ |
2079 |
+@@ -141,6 +144,13 @@ static ssize_t lcd_read(struct file *file, char __user * buffer, |
2080 |
+ |
2081 |
+ dev = file->private_data; |
2082 |
+ |
2083 |
++ down_read(&dev->io_rwsem); |
2084 |
++ |
2085 |
++ if (dev->disconnected) { |
2086 |
++ retval = -ENODEV; |
2087 |
++ goto out_up_io; |
2088 |
++ } |
2089 |
++ |
2090 |
+ /* do a blocking bulk read to get data from the device */ |
2091 |
+ retval = usb_bulk_msg(dev->udev, |
2092 |
+ usb_rcvbulkpipe(dev->udev, |
2093 |
+@@ -157,6 +167,9 @@ static ssize_t lcd_read(struct file *file, char __user * buffer, |
2094 |
+ retval = bytes_read; |
2095 |
+ } |
2096 |
+ |
2097 |
++out_up_io: |
2098 |
++ up_read(&dev->io_rwsem); |
2099 |
++ |
2100 |
+ return retval; |
2101 |
+ } |
2102 |
+ |
2103 |
+@@ -236,11 +249,18 @@ static ssize_t lcd_write(struct file *file, const char __user * user_buffer, |
2104 |
+ if (r < 0) |
2105 |
+ return -EINTR; |
2106 |
+ |
2107 |
++ down_read(&dev->io_rwsem); |
2108 |
++ |
2109 |
++ if (dev->disconnected) { |
2110 |
++ retval = -ENODEV; |
2111 |
++ goto err_up_io; |
2112 |
++ } |
2113 |
++ |
2114 |
+ /* create a urb, and a buffer for it, and copy the data to the urb */ |
2115 |
+ urb = usb_alloc_urb(0, GFP_KERNEL); |
2116 |
+ if (!urb) { |
2117 |
+ retval = -ENOMEM; |
2118 |
+- goto err_no_buf; |
2119 |
++ goto err_up_io; |
2120 |
+ } |
2121 |
+ |
2122 |
+ buf = usb_alloc_coherent(dev->udev, count, GFP_KERNEL, |
2123 |
+@@ -277,6 +297,7 @@ static ssize_t lcd_write(struct file *file, const char __user * user_buffer, |
2124 |
+ the USB core will eventually free it entirely */ |
2125 |
+ usb_free_urb(urb); |
2126 |
+ |
2127 |
++ up_read(&dev->io_rwsem); |
2128 |
+ exit: |
2129 |
+ return count; |
2130 |
+ error_unanchor: |
2131 |
+@@ -284,7 +305,8 @@ error_unanchor: |
2132 |
+ error: |
2133 |
+ usb_free_coherent(dev->udev, count, buf, urb->transfer_dma); |
2134 |
+ usb_free_urb(urb); |
2135 |
+-err_no_buf: |
2136 |
++err_up_io: |
2137 |
++ up_read(&dev->io_rwsem); |
2138 |
+ up(&dev->limit_sem); |
2139 |
+ return retval; |
2140 |
+ } |
2141 |
+@@ -324,6 +346,7 @@ static int lcd_probe(struct usb_interface *interface, |
2142 |
+ |
2143 |
+ kref_init(&dev->kref); |
2144 |
+ sema_init(&dev->limit_sem, USB_LCD_CONCURRENT_WRITES); |
2145 |
++ init_rwsem(&dev->io_rwsem); |
2146 |
+ init_usb_anchor(&dev->submitted); |
2147 |
+ |
2148 |
+ dev->udev = usb_get_dev(interface_to_usbdev(interface)); |
2149 |
+@@ -421,6 +444,12 @@ static void lcd_disconnect(struct usb_interface *interface) |
2150 |
+ /* give back our minor */ |
2151 |
+ usb_deregister_dev(interface, &lcd_class); |
2152 |
+ |
2153 |
++ down_write(&dev->io_rwsem); |
2154 |
++ dev->disconnected = 1; |
2155 |
++ up_write(&dev->io_rwsem); |
2156 |
++ |
2157 |
++ usb_kill_anchored_urbs(&dev->submitted); |
2158 |
++ |
2159 |
+ /* decrement our usage count */ |
2160 |
+ kref_put(&dev->kref, lcd_delete); |
2161 |
+ |
2162 |
+diff --git a/drivers/usb/misc/yurex.c b/drivers/usb/misc/yurex.c |
2163 |
+index 081570677f24..ec42f6b75564 100644 |
2164 |
+--- a/drivers/usb/misc/yurex.c |
2165 |
++++ b/drivers/usb/misc/yurex.c |
2166 |
+@@ -64,6 +64,7 @@ struct usb_yurex { |
2167 |
+ |
2168 |
+ struct kref kref; |
2169 |
+ struct mutex io_mutex; |
2170 |
++ unsigned long disconnected:1; |
2171 |
+ struct fasync_struct *async_queue; |
2172 |
+ wait_queue_head_t waitq; |
2173 |
+ |
2174 |
+@@ -111,6 +112,7 @@ static void yurex_delete(struct kref *kref) |
2175 |
+ dev->int_buffer, dev->urb->transfer_dma); |
2176 |
+ usb_free_urb(dev->urb); |
2177 |
+ } |
2178 |
++ usb_put_intf(dev->interface); |
2179 |
+ usb_put_dev(dev->udev); |
2180 |
+ kfree(dev); |
2181 |
+ } |
2182 |
+@@ -136,6 +138,7 @@ static void yurex_interrupt(struct urb *urb) |
2183 |
+ switch (status) { |
2184 |
+ case 0: /*success*/ |
2185 |
+ break; |
2186 |
++ /* The device is terminated or messed up, give up */ |
2187 |
+ case -EOVERFLOW: |
2188 |
+ dev_err(&dev->interface->dev, |
2189 |
+ "%s - overflow with length %d, actual length is %d\n", |
2190 |
+@@ -144,12 +147,13 @@ static void yurex_interrupt(struct urb *urb) |
2191 |
+ case -ENOENT: |
2192 |
+ case -ESHUTDOWN: |
2193 |
+ case -EILSEQ: |
2194 |
+- /* The device is terminated, clean up */ |
2195 |
++ case -EPROTO: |
2196 |
++ case -ETIME: |
2197 |
+ return; |
2198 |
+ default: |
2199 |
+ dev_err(&dev->interface->dev, |
2200 |
+ "%s - unknown status received: %d\n", __func__, status); |
2201 |
+- goto exit; |
2202 |
++ return; |
2203 |
+ } |
2204 |
+ |
2205 |
+ /* handle received message */ |
2206 |
+@@ -181,7 +185,6 @@ static void yurex_interrupt(struct urb *urb) |
2207 |
+ break; |
2208 |
+ } |
2209 |
+ |
2210 |
+-exit: |
2211 |
+ retval = usb_submit_urb(dev->urb, GFP_ATOMIC); |
2212 |
+ if (retval) { |
2213 |
+ dev_err(&dev->interface->dev, "%s - usb_submit_urb failed: %d\n", |
2214 |
+@@ -208,7 +211,7 @@ static int yurex_probe(struct usb_interface *interface, const struct usb_device_ |
2215 |
+ init_waitqueue_head(&dev->waitq); |
2216 |
+ |
2217 |
+ dev->udev = usb_get_dev(interface_to_usbdev(interface)); |
2218 |
+- dev->interface = interface; |
2219 |
++ dev->interface = usb_get_intf(interface); |
2220 |
+ |
2221 |
+ /* set up the endpoint information */ |
2222 |
+ iface_desc = interface->cur_altsetting; |
2223 |
+@@ -319,8 +322,9 @@ static void yurex_disconnect(struct usb_interface *interface) |
2224 |
+ |
2225 |
+ /* prevent more I/O from starting */ |
2226 |
+ usb_poison_urb(dev->urb); |
2227 |
++ usb_poison_urb(dev->cntl_urb); |
2228 |
+ mutex_lock(&dev->io_mutex); |
2229 |
+- dev->interface = NULL; |
2230 |
++ dev->disconnected = 1; |
2231 |
+ mutex_unlock(&dev->io_mutex); |
2232 |
+ |
2233 |
+ /* wakeup waiters */ |
2234 |
+@@ -408,7 +412,7 @@ static ssize_t yurex_read(struct file *file, char __user *buffer, size_t count, |
2235 |
+ dev = file->private_data; |
2236 |
+ |
2237 |
+ mutex_lock(&dev->io_mutex); |
2238 |
+- if (!dev->interface) { /* already disconnected */ |
2239 |
++ if (dev->disconnected) { /* already disconnected */ |
2240 |
+ mutex_unlock(&dev->io_mutex); |
2241 |
+ return -ENODEV; |
2242 |
+ } |
2243 |
+@@ -443,7 +447,7 @@ static ssize_t yurex_write(struct file *file, const char __user *user_buffer, |
2244 |
+ goto error; |
2245 |
+ |
2246 |
+ mutex_lock(&dev->io_mutex); |
2247 |
+- if (!dev->interface) { /* already disconnected */ |
2248 |
++ if (dev->disconnected) { /* already disconnected */ |
2249 |
+ mutex_unlock(&dev->io_mutex); |
2250 |
+ retval = -ENODEV; |
2251 |
+ goto error; |
2252 |
+diff --git a/drivers/usb/renesas_usbhs/common.h b/drivers/usb/renesas_usbhs/common.h |
2253 |
+index 8c5fc12ad778..b8620aa6b72e 100644 |
2254 |
+--- a/drivers/usb/renesas_usbhs/common.h |
2255 |
++++ b/drivers/usb/renesas_usbhs/common.h |
2256 |
+@@ -213,6 +213,7 @@ struct usbhs_priv; |
2257 |
+ /* DCPCTR */ |
2258 |
+ #define BSTS (1 << 15) /* Buffer Status */ |
2259 |
+ #define SUREQ (1 << 14) /* Sending SETUP Token */ |
2260 |
++#define INBUFM (1 << 14) /* (PIPEnCTR) Transfer Buffer Monitor */ |
2261 |
+ #define CSSTS (1 << 12) /* CSSTS Status */ |
2262 |
+ #define ACLRM (1 << 9) /* Buffer Auto-Clear Mode */ |
2263 |
+ #define SQCLR (1 << 8) /* Toggle Bit Clear */ |
2264 |
+diff --git a/drivers/usb/renesas_usbhs/fifo.c b/drivers/usb/renesas_usbhs/fifo.c |
2265 |
+index b6d9308d43ba..4a486fa5473e 100644 |
2266 |
+--- a/drivers/usb/renesas_usbhs/fifo.c |
2267 |
++++ b/drivers/usb/renesas_usbhs/fifo.c |
2268 |
+@@ -98,7 +98,7 @@ static void __usbhsf_pkt_del(struct usbhs_pkt *pkt) |
2269 |
+ list_del_init(&pkt->node); |
2270 |
+ } |
2271 |
+ |
2272 |
+-static struct usbhs_pkt *__usbhsf_pkt_get(struct usbhs_pipe *pipe) |
2273 |
++struct usbhs_pkt *__usbhsf_pkt_get(struct usbhs_pipe *pipe) |
2274 |
+ { |
2275 |
+ return list_first_entry_or_null(&pipe->list, struct usbhs_pkt, node); |
2276 |
+ } |
2277 |
+diff --git a/drivers/usb/renesas_usbhs/fifo.h b/drivers/usb/renesas_usbhs/fifo.h |
2278 |
+index 8b98507d7abc..c1fb39252b23 100644 |
2279 |
+--- a/drivers/usb/renesas_usbhs/fifo.h |
2280 |
++++ b/drivers/usb/renesas_usbhs/fifo.h |
2281 |
+@@ -106,5 +106,6 @@ void usbhs_pkt_push(struct usbhs_pipe *pipe, struct usbhs_pkt *pkt, |
2282 |
+ void *buf, int len, int zero, int sequence); |
2283 |
+ struct usbhs_pkt *usbhs_pkt_pop(struct usbhs_pipe *pipe, struct usbhs_pkt *pkt); |
2284 |
+ void usbhs_pkt_start(struct usbhs_pipe *pipe); |
2285 |
++struct usbhs_pkt *__usbhsf_pkt_get(struct usbhs_pipe *pipe); |
2286 |
+ |
2287 |
+ #endif /* RENESAS_USB_FIFO_H */ |
2288 |
+diff --git a/drivers/usb/renesas_usbhs/mod_gadget.c b/drivers/usb/renesas_usbhs/mod_gadget.c |
2289 |
+index c068b673420b..0dedb0d91dcc 100644 |
2290 |
+--- a/drivers/usb/renesas_usbhs/mod_gadget.c |
2291 |
++++ b/drivers/usb/renesas_usbhs/mod_gadget.c |
2292 |
+@@ -729,8 +729,7 @@ static int __usbhsg_ep_set_halt_wedge(struct usb_ep *ep, int halt, int wedge) |
2293 |
+ struct usbhs_priv *priv = usbhsg_gpriv_to_priv(gpriv); |
2294 |
+ struct device *dev = usbhsg_gpriv_to_dev(gpriv); |
2295 |
+ unsigned long flags; |
2296 |
+- |
2297 |
+- usbhsg_pipe_disable(uep); |
2298 |
++ int ret = 0; |
2299 |
+ |
2300 |
+ dev_dbg(dev, "set halt %d (pipe %d)\n", |
2301 |
+ halt, usbhs_pipe_number(pipe)); |
2302 |
+@@ -738,6 +737,18 @@ static int __usbhsg_ep_set_halt_wedge(struct usb_ep *ep, int halt, int wedge) |
2303 |
+ /******************** spin lock ********************/ |
2304 |
+ usbhs_lock(priv, flags); |
2305 |
+ |
2306 |
++ /* |
2307 |
++ * According to usb_ep_set_halt()'s description, this function should |
2308 |
++ * return -EAGAIN if the IN endpoint has any queue or data. Note |
2309 |
++ * that the usbhs_pipe_is_dir_in() returns false if the pipe is an |
2310 |
++ * IN endpoint in the gadget mode. |
2311 |
++ */ |
2312 |
++ if (!usbhs_pipe_is_dir_in(pipe) && (__usbhsf_pkt_get(pipe) || |
2313 |
++ usbhs_pipe_contains_transmittable_data(pipe))) { |
2314 |
++ ret = -EAGAIN; |
2315 |
++ goto out; |
2316 |
++ } |
2317 |
++ |
2318 |
+ if (halt) |
2319 |
+ usbhs_pipe_stall(pipe); |
2320 |
+ else |
2321 |
+@@ -748,10 +759,11 @@ static int __usbhsg_ep_set_halt_wedge(struct usb_ep *ep, int halt, int wedge) |
2322 |
+ else |
2323 |
+ usbhsg_status_clr(gpriv, USBHSG_STATUS_WEDGE); |
2324 |
+ |
2325 |
++out: |
2326 |
+ usbhs_unlock(priv, flags); |
2327 |
+ /******************** spin unlock ******************/ |
2328 |
+ |
2329 |
+- return 0; |
2330 |
++ return ret; |
2331 |
+ } |
2332 |
+ |
2333 |
+ static int usbhsg_ep_set_halt(struct usb_ep *ep, int value) |
2334 |
+diff --git a/drivers/usb/renesas_usbhs/pipe.c b/drivers/usb/renesas_usbhs/pipe.c |
2335 |
+index d811f0550c04..98ed6fcacd36 100644 |
2336 |
+--- a/drivers/usb/renesas_usbhs/pipe.c |
2337 |
++++ b/drivers/usb/renesas_usbhs/pipe.c |
2338 |
+@@ -286,6 +286,21 @@ int usbhs_pipe_is_accessible(struct usbhs_pipe *pipe) |
2339 |
+ return -EBUSY; |
2340 |
+ } |
2341 |
+ |
2342 |
++bool usbhs_pipe_contains_transmittable_data(struct usbhs_pipe *pipe) |
2343 |
++{ |
2344 |
++ u16 val; |
2345 |
++ |
2346 |
++ /* Do not support for DCP pipe */ |
2347 |
++ if (usbhs_pipe_is_dcp(pipe)) |
2348 |
++ return false; |
2349 |
++ |
2350 |
++ val = usbhsp_pipectrl_get(pipe); |
2351 |
++ if (val & INBUFM) |
2352 |
++ return true; |
2353 |
++ |
2354 |
++ return false; |
2355 |
++} |
2356 |
++ |
2357 |
+ /* |
2358 |
+ * PID ctrl |
2359 |
+ */ |
2360 |
+diff --git a/drivers/usb/renesas_usbhs/pipe.h b/drivers/usb/renesas_usbhs/pipe.h |
2361 |
+index 95185fdb29b1..e4144704ee02 100644 |
2362 |
+--- a/drivers/usb/renesas_usbhs/pipe.h |
2363 |
++++ b/drivers/usb/renesas_usbhs/pipe.h |
2364 |
+@@ -90,6 +90,7 @@ void usbhs_pipe_init(struct usbhs_priv *priv, |
2365 |
+ int usbhs_pipe_get_maxpacket(struct usbhs_pipe *pipe); |
2366 |
+ void usbhs_pipe_clear(struct usbhs_pipe *pipe); |
2367 |
+ int usbhs_pipe_is_accessible(struct usbhs_pipe *pipe); |
2368 |
++bool usbhs_pipe_contains_transmittable_data(struct usbhs_pipe *pipe); |
2369 |
+ void usbhs_pipe_enable(struct usbhs_pipe *pipe); |
2370 |
+ void usbhs_pipe_disable(struct usbhs_pipe *pipe); |
2371 |
+ void usbhs_pipe_stall(struct usbhs_pipe *pipe); |
2372 |
+diff --git a/drivers/usb/serial/ftdi_sio.c b/drivers/usb/serial/ftdi_sio.c |
2373 |
+index d2349c094767..8b5c99df0f2b 100644 |
2374 |
+--- a/drivers/usb/serial/ftdi_sio.c |
2375 |
++++ b/drivers/usb/serial/ftdi_sio.c |
2376 |
+@@ -1025,6 +1025,9 @@ static const struct usb_device_id id_table_combined[] = { |
2377 |
+ /* EZPrototypes devices */ |
2378 |
+ { USB_DEVICE(EZPROTOTYPES_VID, HJELMSLUND_USB485_ISO_PID) }, |
2379 |
+ { USB_DEVICE_INTERFACE_NUMBER(UNJO_VID, UNJO_ISODEBUG_V1_PID, 1) }, |
2380 |
++ /* Sienna devices */ |
2381 |
++ { USB_DEVICE(FTDI_VID, FTDI_SIENNA_PID) }, |
2382 |
++ { USB_DEVICE(ECHELON_VID, ECHELON_U20_PID) }, |
2383 |
+ { } /* Terminating entry */ |
2384 |
+ }; |
2385 |
+ |
2386 |
+diff --git a/drivers/usb/serial/ftdi_sio_ids.h b/drivers/usb/serial/ftdi_sio_ids.h |
2387 |
+index f12d806220b4..22d66217cb41 100644 |
2388 |
+--- a/drivers/usb/serial/ftdi_sio_ids.h |
2389 |
++++ b/drivers/usb/serial/ftdi_sio_ids.h |
2390 |
+@@ -39,6 +39,9 @@ |
2391 |
+ |
2392 |
+ #define FTDI_LUMEL_PD12_PID 0x6002 |
2393 |
+ |
2394 |
++/* Sienna Serial Interface by Secyourit GmbH */ |
2395 |
++#define FTDI_SIENNA_PID 0x8348 |
2396 |
++ |
2397 |
+ /* Cyber Cortex AV by Fabulous Silicon (http://fabuloussilicon.com) */ |
2398 |
+ #define CYBER_CORTEX_AV_PID 0x8698 |
2399 |
+ |
2400 |
+@@ -688,6 +691,12 @@ |
2401 |
+ #define BANDB_TTL3USB9M_PID 0xAC50 |
2402 |
+ #define BANDB_ZZ_PROG1_USB_PID 0xBA02 |
2403 |
+ |
2404 |
++/* |
2405 |
++ * Echelon USB Serial Interface |
2406 |
++ */ |
2407 |
++#define ECHELON_VID 0x0920 |
2408 |
++#define ECHELON_U20_PID 0x7500 |
2409 |
++ |
2410 |
+ /* |
2411 |
+ * Intrepid Control Systems (http://www.intrepidcs.com/) ValueCAN and NeoVI |
2412 |
+ */ |
2413 |
+diff --git a/drivers/usb/serial/keyspan.c b/drivers/usb/serial/keyspan.c |
2414 |
+index 5662d324edd2..2c5a53bdccd4 100644 |
2415 |
+--- a/drivers/usb/serial/keyspan.c |
2416 |
++++ b/drivers/usb/serial/keyspan.c |
2417 |
+@@ -1745,8 +1745,8 @@ static struct urb *keyspan_setup_urb(struct usb_serial *serial, int endpoint, |
2418 |
+ |
2419 |
+ ep_desc = find_ep(serial, endpoint); |
2420 |
+ if (!ep_desc) { |
2421 |
+- /* leak the urb, something's wrong and the callers don't care */ |
2422 |
+- return urb; |
2423 |
++ usb_free_urb(urb); |
2424 |
++ return NULL; |
2425 |
+ } |
2426 |
+ if (usb_endpoint_xfer_int(ep_desc)) { |
2427 |
+ ep_type_name = "INT"; |
2428 |
+diff --git a/drivers/usb/serial/option.c b/drivers/usb/serial/option.c |
2429 |
+index 959f462c6f72..b9fad046828d 100644 |
2430 |
+--- a/drivers/usb/serial/option.c |
2431 |
++++ b/drivers/usb/serial/option.c |
2432 |
+@@ -422,6 +422,7 @@ static void option_instat_callback(struct urb *urb); |
2433 |
+ #define CINTERION_PRODUCT_PH8_AUDIO 0x0083 |
2434 |
+ #define CINTERION_PRODUCT_AHXX_2RMNET 0x0084 |
2435 |
+ #define CINTERION_PRODUCT_AHXX_AUDIO 0x0085 |
2436 |
++#define CINTERION_PRODUCT_CLS8 0x00b0 |
2437 |
+ |
2438 |
+ /* Olivetti products */ |
2439 |
+ #define OLIVETTI_VENDOR_ID 0x0b3c |
2440 |
+@@ -1157,6 +1158,14 @@ static const struct usb_device_id option_ids[] = { |
2441 |
+ .driver_info = NCTRL(0) | RSVD(1) | RSVD(2) | RSVD(3) }, |
2442 |
+ { USB_DEVICE_INTERFACE_CLASS(TELIT_VENDOR_ID, TELIT_PRODUCT_LE922_USBCFG5, 0xff), |
2443 |
+ .driver_info = RSVD(0) | RSVD(1) | NCTRL(2) | RSVD(3) }, |
2444 |
++ { USB_DEVICE_INTERFACE_CLASS(TELIT_VENDOR_ID, 0x1050, 0xff), /* Telit FN980 (rmnet) */ |
2445 |
++ .driver_info = NCTRL(0) | RSVD(1) | RSVD(2) }, |
2446 |
++ { USB_DEVICE_INTERFACE_CLASS(TELIT_VENDOR_ID, 0x1051, 0xff), /* Telit FN980 (MBIM) */ |
2447 |
++ .driver_info = NCTRL(0) | RSVD(1) }, |
2448 |
++ { USB_DEVICE_INTERFACE_CLASS(TELIT_VENDOR_ID, 0x1052, 0xff), /* Telit FN980 (RNDIS) */ |
2449 |
++ .driver_info = NCTRL(2) | RSVD(3) }, |
2450 |
++ { USB_DEVICE_INTERFACE_CLASS(TELIT_VENDOR_ID, 0x1053, 0xff), /* Telit FN980 (ECM) */ |
2451 |
++ .driver_info = NCTRL(0) | RSVD(1) }, |
2452 |
+ { USB_DEVICE(TELIT_VENDOR_ID, TELIT_PRODUCT_ME910), |
2453 |
+ .driver_info = NCTRL(0) | RSVD(1) | RSVD(3) }, |
2454 |
+ { USB_DEVICE(TELIT_VENDOR_ID, TELIT_PRODUCT_ME910_DUAL_MODEM), |
2455 |
+@@ -1850,6 +1859,8 @@ static const struct usb_device_id option_ids[] = { |
2456 |
+ .driver_info = RSVD(4) }, |
2457 |
+ { USB_DEVICE_INTERFACE_CLASS(CINTERION_VENDOR_ID, CINTERION_PRODUCT_AHXX_2RMNET, 0xff) }, |
2458 |
+ { USB_DEVICE_INTERFACE_CLASS(CINTERION_VENDOR_ID, CINTERION_PRODUCT_AHXX_AUDIO, 0xff) }, |
2459 |
++ { USB_DEVICE_INTERFACE_CLASS(CINTERION_VENDOR_ID, CINTERION_PRODUCT_CLS8, 0xff), |
2460 |
++ .driver_info = RSVD(0) | RSVD(4) }, |
2461 |
+ { USB_DEVICE(CINTERION_VENDOR_ID, CINTERION_PRODUCT_HC28_MDM) }, |
2462 |
+ { USB_DEVICE(CINTERION_VENDOR_ID, CINTERION_PRODUCT_HC28_MDMNET) }, |
2463 |
+ { USB_DEVICE(SIEMENS_VENDOR_ID, CINTERION_PRODUCT_HC25_MDM) }, |
2464 |
+diff --git a/drivers/usb/serial/usb-serial.c b/drivers/usb/serial/usb-serial.c |
2465 |
+index bb34f9f7eaf4..8115b7cccf1a 100644 |
2466 |
+--- a/drivers/usb/serial/usb-serial.c |
2467 |
++++ b/drivers/usb/serial/usb-serial.c |
2468 |
+@@ -314,10 +314,7 @@ static void serial_cleanup(struct tty_struct *tty) |
2469 |
+ serial = port->serial; |
2470 |
+ owner = serial->type->driver.owner; |
2471 |
+ |
2472 |
+- mutex_lock(&serial->disc_mutex); |
2473 |
+- if (!serial->disconnected) |
2474 |
+- usb_autopm_put_interface(serial->interface); |
2475 |
+- mutex_unlock(&serial->disc_mutex); |
2476 |
++ usb_autopm_put_interface(serial->interface); |
2477 |
+ |
2478 |
+ usb_serial_put(serial); |
2479 |
+ module_put(owner); |
2480 |
+diff --git a/drivers/usb/usb-skeleton.c b/drivers/usb/usb-skeleton.c |
2481 |
+index bb0bd732e29a..7140d06ae04f 100644 |
2482 |
+--- a/drivers/usb/usb-skeleton.c |
2483 |
++++ b/drivers/usb/usb-skeleton.c |
2484 |
+@@ -63,6 +63,7 @@ struct usb_skel { |
2485 |
+ spinlock_t err_lock; /* lock for errors */ |
2486 |
+ struct kref kref; |
2487 |
+ struct mutex io_mutex; /* synchronize I/O with disconnect */ |
2488 |
++ unsigned long disconnected:1; |
2489 |
+ wait_queue_head_t bulk_in_wait; /* to wait for an ongoing read */ |
2490 |
+ }; |
2491 |
+ #define to_skel_dev(d) container_of(d, struct usb_skel, kref) |
2492 |
+@@ -75,6 +76,7 @@ static void skel_delete(struct kref *kref) |
2493 |
+ struct usb_skel *dev = to_skel_dev(kref); |
2494 |
+ |
2495 |
+ usb_free_urb(dev->bulk_in_urb); |
2496 |
++ usb_put_intf(dev->interface); |
2497 |
+ usb_put_dev(dev->udev); |
2498 |
+ kfree(dev->bulk_in_buffer); |
2499 |
+ kfree(dev); |
2500 |
+@@ -126,10 +128,7 @@ static int skel_release(struct inode *inode, struct file *file) |
2501 |
+ return -ENODEV; |
2502 |
+ |
2503 |
+ /* allow the device to be autosuspended */ |
2504 |
+- mutex_lock(&dev->io_mutex); |
2505 |
+- if (dev->interface) |
2506 |
+- usb_autopm_put_interface(dev->interface); |
2507 |
+- mutex_unlock(&dev->io_mutex); |
2508 |
++ usb_autopm_put_interface(dev->interface); |
2509 |
+ |
2510 |
+ /* decrement the count on our device */ |
2511 |
+ kref_put(&dev->kref, skel_delete); |
2512 |
+@@ -241,7 +240,7 @@ static ssize_t skel_read(struct file *file, char *buffer, size_t count, |
2513 |
+ if (rv < 0) |
2514 |
+ return rv; |
2515 |
+ |
2516 |
+- if (!dev->interface) { /* disconnect() was called */ |
2517 |
++ if (dev->disconnected) { /* disconnect() was called */ |
2518 |
+ rv = -ENODEV; |
2519 |
+ goto exit; |
2520 |
+ } |
2521 |
+@@ -422,7 +421,7 @@ static ssize_t skel_write(struct file *file, const char *user_buffer, |
2522 |
+ |
2523 |
+ /* this lock makes sure we don't submit URBs to gone devices */ |
2524 |
+ mutex_lock(&dev->io_mutex); |
2525 |
+- if (!dev->interface) { /* disconnect() was called */ |
2526 |
++ if (dev->disconnected) { /* disconnect() was called */ |
2527 |
+ mutex_unlock(&dev->io_mutex); |
2528 |
+ retval = -ENODEV; |
2529 |
+ goto error; |
2530 |
+@@ -507,7 +506,7 @@ static int skel_probe(struct usb_interface *interface, |
2531 |
+ init_waitqueue_head(&dev->bulk_in_wait); |
2532 |
+ |
2533 |
+ dev->udev = usb_get_dev(interface_to_usbdev(interface)); |
2534 |
+- dev->interface = interface; |
2535 |
++ dev->interface = usb_get_intf(interface); |
2536 |
+ |
2537 |
+ /* set up the endpoint information */ |
2538 |
+ /* use only the first bulk-in and bulk-out endpoints */ |
2539 |
+@@ -573,7 +572,7 @@ static void skel_disconnect(struct usb_interface *interface) |
2540 |
+ |
2541 |
+ /* prevent more I/O from starting */ |
2542 |
+ mutex_lock(&dev->io_mutex); |
2543 |
+- dev->interface = NULL; |
2544 |
++ dev->disconnected = 1; |
2545 |
+ mutex_unlock(&dev->io_mutex); |
2546 |
+ |
2547 |
+ usb_kill_anchored_urbs(&dev->submitted); |
2548 |
+diff --git a/fs/btrfs/tree-log.c b/fs/btrfs/tree-log.c |
2549 |
+index f8ef2e3fbf63..e35301e5fe8e 100644 |
2550 |
+--- a/fs/btrfs/tree-log.c |
2551 |
++++ b/fs/btrfs/tree-log.c |
2552 |
+@@ -2729,7 +2729,8 @@ out: |
2553 |
+ * in the tree of log roots |
2554 |
+ */ |
2555 |
+ static int update_log_root(struct btrfs_trans_handle *trans, |
2556 |
+- struct btrfs_root *log) |
2557 |
++ struct btrfs_root *log, |
2558 |
++ struct btrfs_root_item *root_item) |
2559 |
+ { |
2560 |
+ struct btrfs_fs_info *fs_info = log->fs_info; |
2561 |
+ int ret; |
2562 |
+@@ -2737,10 +2738,10 @@ static int update_log_root(struct btrfs_trans_handle *trans, |
2563 |
+ if (log->log_transid == 1) { |
2564 |
+ /* insert root item on the first sync */ |
2565 |
+ ret = btrfs_insert_root(trans, fs_info->log_root_tree, |
2566 |
+- &log->root_key, &log->root_item); |
2567 |
++ &log->root_key, root_item); |
2568 |
+ } else { |
2569 |
+ ret = btrfs_update_root(trans, fs_info->log_root_tree, |
2570 |
+- &log->root_key, &log->root_item); |
2571 |
++ &log->root_key, root_item); |
2572 |
+ } |
2573 |
+ return ret; |
2574 |
+ } |
2575 |
+@@ -2836,6 +2837,7 @@ int btrfs_sync_log(struct btrfs_trans_handle *trans, |
2576 |
+ struct btrfs_fs_info *fs_info = root->fs_info; |
2577 |
+ struct btrfs_root *log = root->log_root; |
2578 |
+ struct btrfs_root *log_root_tree = fs_info->log_root_tree; |
2579 |
++ struct btrfs_root_item new_root_item; |
2580 |
+ int log_transid = 0; |
2581 |
+ struct btrfs_log_ctx root_log_ctx; |
2582 |
+ struct blk_plug plug; |
2583 |
+@@ -2901,17 +2903,25 @@ int btrfs_sync_log(struct btrfs_trans_handle *trans, |
2584 |
+ goto out; |
2585 |
+ } |
2586 |
+ |
2587 |
++ /* |
2588 |
++ * We _must_ update under the root->log_mutex in order to make sure we |
2589 |
++ * have a consistent view of the log root we are trying to commit at |
2590 |
++ * this moment. |
2591 |
++ * |
2592 |
++ * We _must_ copy this into a local copy, because we are not holding the |
2593 |
++ * log_root_tree->log_mutex yet. This is important because when we |
2594 |
++ * commit the log_root_tree we must have a consistent view of the |
2595 |
++ * log_root_tree when we update the super block to point at the |
2596 |
++ * log_root_tree bytenr. If we update the log_root_tree here we'll race |
2597 |
++ * with the commit and possibly point at the new block which we may not |
2598 |
++ * have written out. |
2599 |
++ */ |
2600 |
+ btrfs_set_root_node(&log->root_item, log->node); |
2601 |
++ memcpy(&new_root_item, &log->root_item, sizeof(new_root_item)); |
2602 |
+ |
2603 |
+ root->log_transid++; |
2604 |
+ log->log_transid = root->log_transid; |
2605 |
+ root->log_start_pid = 0; |
2606 |
+- /* |
2607 |
+- * Update or create log root item under the root's log_mutex to prevent |
2608 |
+- * races with concurrent log syncs that can lead to failure to update |
2609 |
+- * log root item because it was not created yet. |
2610 |
+- */ |
2611 |
+- ret = update_log_root(trans, log); |
2612 |
+ /* |
2613 |
+ * IO has been started, blocks of the log tree have WRITTEN flag set |
2614 |
+ * in their headers. new modifications of the log will be written to |
2615 |
+@@ -2932,6 +2942,14 @@ int btrfs_sync_log(struct btrfs_trans_handle *trans, |
2616 |
+ mutex_unlock(&log_root_tree->log_mutex); |
2617 |
+ |
2618 |
+ mutex_lock(&log_root_tree->log_mutex); |
2619 |
++ |
2620 |
++ /* |
2621 |
++ * Now we are safe to update the log_root_tree because we're under the |
2622 |
++ * log_mutex, and we're a current writer so we're holding the commit |
2623 |
++ * open until we drop the log_mutex. |
2624 |
++ */ |
2625 |
++ ret = update_log_root(trans, log, &new_root_item); |
2626 |
++ |
2627 |
+ if (atomic_dec_and_test(&log_root_tree->log_writers)) { |
2628 |
+ /* |
2629 |
+ * Implicit memory barrier after atomic_dec_and_test |
2630 |
+diff --git a/fs/cifs/dir.c b/fs/cifs/dir.c |
2631 |
+index ca98afda3cdb..f00a7ce3eb6e 100644 |
2632 |
+--- a/fs/cifs/dir.c |
2633 |
++++ b/fs/cifs/dir.c |
2634 |
+@@ -841,10 +841,16 @@ lookup_out: |
2635 |
+ static int |
2636 |
+ cifs_d_revalidate(struct dentry *direntry, unsigned int flags) |
2637 |
+ { |
2638 |
++ struct inode *inode; |
2639 |
++ |
2640 |
+ if (flags & LOOKUP_RCU) |
2641 |
+ return -ECHILD; |
2642 |
+ |
2643 |
+ if (d_really_is_positive(direntry)) { |
2644 |
++ inode = d_inode(direntry); |
2645 |
++ if ((flags & LOOKUP_REVAL) && !CIFS_CACHE_READ(CIFS_I(inode))) |
2646 |
++ CIFS_I(inode)->time = 0; /* force reval */ |
2647 |
++ |
2648 |
+ if (cifs_revalidate_dentry(direntry)) |
2649 |
+ return 0; |
2650 |
+ else { |
2651 |
+@@ -855,7 +861,7 @@ cifs_d_revalidate(struct dentry *direntry, unsigned int flags) |
2652 |
+ * attributes will have been updated by |
2653 |
+ * cifs_revalidate_dentry(). |
2654 |
+ */ |
2655 |
+- if (IS_AUTOMOUNT(d_inode(direntry)) && |
2656 |
++ if (IS_AUTOMOUNT(inode) && |
2657 |
+ !(direntry->d_flags & DCACHE_NEED_AUTOMOUNT)) { |
2658 |
+ spin_lock(&direntry->d_lock); |
2659 |
+ direntry->d_flags |= DCACHE_NEED_AUTOMOUNT; |
2660 |
+diff --git a/fs/cifs/file.c b/fs/cifs/file.c |
2661 |
+index 6ee8f9270892..71a960da7cce 100644 |
2662 |
+--- a/fs/cifs/file.c |
2663 |
++++ b/fs/cifs/file.c |
2664 |
+@@ -252,6 +252,12 @@ cifs_nt_open(char *full_path, struct inode *inode, struct cifs_sb_info *cifs_sb, |
2665 |
+ rc = cifs_get_inode_info(&inode, full_path, buf, inode->i_sb, |
2666 |
+ xid, fid); |
2667 |
+ |
2668 |
++ if (rc) { |
2669 |
++ server->ops->close(xid, tcon, fid); |
2670 |
++ if (rc == -ESTALE) |
2671 |
++ rc = -EOPENSTALE; |
2672 |
++ } |
2673 |
++ |
2674 |
+ out: |
2675 |
+ kfree(buf); |
2676 |
+ return rc; |
2677 |
+diff --git a/fs/cifs/inode.c b/fs/cifs/inode.c |
2678 |
+index e7192ee7a89c..a35c14105906 100644 |
2679 |
+--- a/fs/cifs/inode.c |
2680 |
++++ b/fs/cifs/inode.c |
2681 |
+@@ -410,6 +410,7 @@ int cifs_get_inode_info_unix(struct inode **pinode, |
2682 |
+ /* if uniqueid is different, return error */ |
2683 |
+ if (unlikely(cifs_sb->mnt_cifs_flags & CIFS_MOUNT_SERVER_INUM && |
2684 |
+ CIFS_I(*pinode)->uniqueid != fattr.cf_uniqueid)) { |
2685 |
++ CIFS_I(*pinode)->time = 0; /* force reval */ |
2686 |
+ rc = -ESTALE; |
2687 |
+ goto cgiiu_exit; |
2688 |
+ } |
2689 |
+@@ -417,6 +418,7 @@ int cifs_get_inode_info_unix(struct inode **pinode, |
2690 |
+ /* if filetype is different, return error */ |
2691 |
+ if (unlikely(((*pinode)->i_mode & S_IFMT) != |
2692 |
+ (fattr.cf_mode & S_IFMT))) { |
2693 |
++ CIFS_I(*pinode)->time = 0; /* force reval */ |
2694 |
+ rc = -ESTALE; |
2695 |
+ goto cgiiu_exit; |
2696 |
+ } |
2697 |
+@@ -925,6 +927,7 @@ cifs_get_inode_info(struct inode **inode, const char *full_path, |
2698 |
+ /* if uniqueid is different, return error */ |
2699 |
+ if (unlikely(cifs_sb->mnt_cifs_flags & CIFS_MOUNT_SERVER_INUM && |
2700 |
+ CIFS_I(*inode)->uniqueid != fattr.cf_uniqueid)) { |
2701 |
++ CIFS_I(*inode)->time = 0; /* force reval */ |
2702 |
+ rc = -ESTALE; |
2703 |
+ goto cgii_exit; |
2704 |
+ } |
2705 |
+@@ -932,6 +935,7 @@ cifs_get_inode_info(struct inode **inode, const char *full_path, |
2706 |
+ /* if filetype is different, return error */ |
2707 |
+ if (unlikely(((*inode)->i_mode & S_IFMT) != |
2708 |
+ (fattr.cf_mode & S_IFMT))) { |
2709 |
++ CIFS_I(*inode)->time = 0; /* force reval */ |
2710 |
+ rc = -ESTALE; |
2711 |
+ goto cgii_exit; |
2712 |
+ } |
2713 |
+diff --git a/fs/f2fs/super.c b/fs/f2fs/super.c |
2714 |
+index 344aa861774b..e70975ca723b 100644 |
2715 |
+--- a/fs/f2fs/super.c |
2716 |
++++ b/fs/f2fs/super.c |
2717 |
+@@ -1814,11 +1814,11 @@ static int sanity_check_raw_super(struct f2fs_sb_info *sbi, |
2718 |
+ struct super_block *sb = sbi->sb; |
2719 |
+ unsigned int blocksize; |
2720 |
+ |
2721 |
+- if (F2FS_SUPER_MAGIC != le32_to_cpu(raw_super->magic)) { |
2722 |
++ if (le32_to_cpu(raw_super->magic) != F2FS_SUPER_MAGIC) { |
2723 |
+ f2fs_msg(sb, KERN_INFO, |
2724 |
+ "Magic Mismatch, valid(0x%x) - read(0x%x)", |
2725 |
+ F2FS_SUPER_MAGIC, le32_to_cpu(raw_super->magic)); |
2726 |
+- return 1; |
2727 |
++ return -EINVAL; |
2728 |
+ } |
2729 |
+ |
2730 |
+ /* Currently, support only 4KB page cache size */ |
2731 |
+@@ -1826,7 +1826,7 @@ static int sanity_check_raw_super(struct f2fs_sb_info *sbi, |
2732 |
+ f2fs_msg(sb, KERN_INFO, |
2733 |
+ "Invalid page_cache_size (%lu), supports only 4KB\n", |
2734 |
+ PAGE_SIZE); |
2735 |
+- return 1; |
2736 |
++ return -EFSCORRUPTED; |
2737 |
+ } |
2738 |
+ |
2739 |
+ /* Currently, support only 4KB block size */ |
2740 |
+@@ -1835,7 +1835,7 @@ static int sanity_check_raw_super(struct f2fs_sb_info *sbi, |
2741 |
+ f2fs_msg(sb, KERN_INFO, |
2742 |
+ "Invalid blocksize (%u), supports only 4KB\n", |
2743 |
+ blocksize); |
2744 |
+- return 1; |
2745 |
++ return -EFSCORRUPTED; |
2746 |
+ } |
2747 |
+ |
2748 |
+ /* check log blocks per segment */ |
2749 |
+@@ -1843,7 +1843,7 @@ static int sanity_check_raw_super(struct f2fs_sb_info *sbi, |
2750 |
+ f2fs_msg(sb, KERN_INFO, |
2751 |
+ "Invalid log blocks per segment (%u)\n", |
2752 |
+ le32_to_cpu(raw_super->log_blocks_per_seg)); |
2753 |
+- return 1; |
2754 |
++ return -EFSCORRUPTED; |
2755 |
+ } |
2756 |
+ |
2757 |
+ /* Currently, support 512/1024/2048/4096 bytes sector size */ |
2758 |
+@@ -1853,7 +1853,7 @@ static int sanity_check_raw_super(struct f2fs_sb_info *sbi, |
2759 |
+ F2FS_MIN_LOG_SECTOR_SIZE) { |
2760 |
+ f2fs_msg(sb, KERN_INFO, "Invalid log sectorsize (%u)", |
2761 |
+ le32_to_cpu(raw_super->log_sectorsize)); |
2762 |
+- return 1; |
2763 |
++ return -EFSCORRUPTED; |
2764 |
+ } |
2765 |
+ if (le32_to_cpu(raw_super->log_sectors_per_block) + |
2766 |
+ le32_to_cpu(raw_super->log_sectorsize) != |
2767 |
+@@ -1862,7 +1862,7 @@ static int sanity_check_raw_super(struct f2fs_sb_info *sbi, |
2768 |
+ "Invalid log sectors per block(%u) log sectorsize(%u)", |
2769 |
+ le32_to_cpu(raw_super->log_sectors_per_block), |
2770 |
+ le32_to_cpu(raw_super->log_sectorsize)); |
2771 |
+- return 1; |
2772 |
++ return -EFSCORRUPTED; |
2773 |
+ } |
2774 |
+ |
2775 |
+ segment_count = le32_to_cpu(raw_super->segment_count); |
2776 |
+@@ -1878,7 +1878,7 @@ static int sanity_check_raw_super(struct f2fs_sb_info *sbi, |
2777 |
+ f2fs_msg(sb, KERN_INFO, |
2778 |
+ "Invalid segment count (%u)", |
2779 |
+ segment_count); |
2780 |
+- return 1; |
2781 |
++ return -EFSCORRUPTED; |
2782 |
+ } |
2783 |
+ |
2784 |
+ if (total_sections > segment_count || |
2785 |
+@@ -1887,35 +1887,35 @@ static int sanity_check_raw_super(struct f2fs_sb_info *sbi, |
2786 |
+ f2fs_msg(sb, KERN_INFO, |
2787 |
+ "Invalid segment/section count (%u, %u x %u)", |
2788 |
+ segment_count, total_sections, segs_per_sec); |
2789 |
+- return 1; |
2790 |
++ return -EFSCORRUPTED; |
2791 |
+ } |
2792 |
+ |
2793 |
+ if ((segment_count / segs_per_sec) < total_sections) { |
2794 |
+ f2fs_msg(sb, KERN_INFO, |
2795 |
+ "Small segment_count (%u < %u * %u)", |
2796 |
+ segment_count, segs_per_sec, total_sections); |
2797 |
+- return 1; |
2798 |
++ return -EFSCORRUPTED; |
2799 |
+ } |
2800 |
+ |
2801 |
+ if (segment_count > (le64_to_cpu(raw_super->block_count) >> 9)) { |
2802 |
+ f2fs_msg(sb, KERN_INFO, |
2803 |
+ "Wrong segment_count / block_count (%u > %llu)", |
2804 |
+ segment_count, le64_to_cpu(raw_super->block_count)); |
2805 |
+- return 1; |
2806 |
++ return -EFSCORRUPTED; |
2807 |
+ } |
2808 |
+ |
2809 |
+ if (secs_per_zone > total_sections || !secs_per_zone) { |
2810 |
+ f2fs_msg(sb, KERN_INFO, |
2811 |
+ "Wrong secs_per_zone / total_sections (%u, %u)", |
2812 |
+ secs_per_zone, total_sections); |
2813 |
+- return 1; |
2814 |
++ return -EFSCORRUPTED; |
2815 |
+ } |
2816 |
+ if (le32_to_cpu(raw_super->extension_count) > F2FS_MAX_EXTENSION) { |
2817 |
+ f2fs_msg(sb, KERN_INFO, |
2818 |
+ "Corrupted extension count (%u > %u)", |
2819 |
+ le32_to_cpu(raw_super->extension_count), |
2820 |
+ F2FS_MAX_EXTENSION); |
2821 |
+- return 1; |
2822 |
++ return -EFSCORRUPTED; |
2823 |
+ } |
2824 |
+ |
2825 |
+ if (le32_to_cpu(raw_super->cp_payload) > |
2826 |
+@@ -1924,7 +1924,7 @@ static int sanity_check_raw_super(struct f2fs_sb_info *sbi, |
2827 |
+ "Insane cp_payload (%u > %u)", |
2828 |
+ le32_to_cpu(raw_super->cp_payload), |
2829 |
+ blocks_per_seg - F2FS_CP_PACKS); |
2830 |
+- return 1; |
2831 |
++ return -EFSCORRUPTED; |
2832 |
+ } |
2833 |
+ |
2834 |
+ /* check reserved ino info */ |
2835 |
+@@ -1936,12 +1936,12 @@ static int sanity_check_raw_super(struct f2fs_sb_info *sbi, |
2836 |
+ le32_to_cpu(raw_super->node_ino), |
2837 |
+ le32_to_cpu(raw_super->meta_ino), |
2838 |
+ le32_to_cpu(raw_super->root_ino)); |
2839 |
+- return 1; |
2840 |
++ return -EFSCORRUPTED; |
2841 |
+ } |
2842 |
+ |
2843 |
+ /* check CP/SIT/NAT/SSA/MAIN_AREA area boundary */ |
2844 |
+ if (sanity_check_area_boundary(sbi, bh)) |
2845 |
+- return 1; |
2846 |
++ return -EFSCORRUPTED; |
2847 |
+ |
2848 |
+ return 0; |
2849 |
+ } |
2850 |
+@@ -2216,11 +2216,11 @@ static int read_raw_super_block(struct f2fs_sb_info *sbi, |
2851 |
+ } |
2852 |
+ |
2853 |
+ /* sanity checking of raw super */ |
2854 |
+- if (sanity_check_raw_super(sbi, bh)) { |
2855 |
++ err = sanity_check_raw_super(sbi, bh); |
2856 |
++ if (err) { |
2857 |
+ f2fs_msg(sb, KERN_ERR, |
2858 |
+ "Can't find valid F2FS filesystem in %dth superblock", |
2859 |
+ block + 1); |
2860 |
+- err = -EFSCORRUPTED; |
2861 |
+ brelse(bh); |
2862 |
+ continue; |
2863 |
+ } |
2864 |
+diff --git a/fs/libfs.c b/fs/libfs.c |
2865 |
+index 3aabe553fc45..49623301e5f0 100644 |
2866 |
+--- a/fs/libfs.c |
2867 |
++++ b/fs/libfs.c |
2868 |
+@@ -86,58 +86,47 @@ int dcache_dir_close(struct inode *inode, struct file *file) |
2869 |
+ EXPORT_SYMBOL(dcache_dir_close); |
2870 |
+ |
2871 |
+ /* parent is locked at least shared */ |
2872 |
+-static struct dentry *next_positive(struct dentry *parent, |
2873 |
+- struct list_head *from, |
2874 |
+- int count) |
2875 |
++/* |
2876 |
++ * Returns an element of siblings' list. |
2877 |
++ * We are looking for <count>th positive after <p>; if |
2878 |
++ * found, dentry is grabbed and passed to caller via *<res>. |
2879 |
++ * If no such element exists, the anchor of list is returned |
2880 |
++ * and *<res> is set to NULL. |
2881 |
++ */ |
2882 |
++static struct list_head *scan_positives(struct dentry *cursor, |
2883 |
++ struct list_head *p, |
2884 |
++ loff_t count, |
2885 |
++ struct dentry **res) |
2886 |
+ { |
2887 |
+- unsigned *seq = &parent->d_inode->i_dir_seq, n; |
2888 |
+- struct dentry *res; |
2889 |
+- struct list_head *p; |
2890 |
+- bool skipped; |
2891 |
+- int i; |
2892 |
++ struct dentry *dentry = cursor->d_parent, *found = NULL; |
2893 |
+ |
2894 |
+-retry: |
2895 |
+- i = count; |
2896 |
+- skipped = false; |
2897 |
+- n = smp_load_acquire(seq) & ~1; |
2898 |
+- res = NULL; |
2899 |
+- rcu_read_lock(); |
2900 |
+- for (p = from->next; p != &parent->d_subdirs; p = p->next) { |
2901 |
++ spin_lock(&dentry->d_lock); |
2902 |
++ while ((p = p->next) != &dentry->d_subdirs) { |
2903 |
+ struct dentry *d = list_entry(p, struct dentry, d_child); |
2904 |
+- if (!simple_positive(d)) { |
2905 |
+- skipped = true; |
2906 |
+- } else if (!--i) { |
2907 |
+- res = d; |
2908 |
+- break; |
2909 |
++ // we must at least skip cursors, to avoid livelocks |
2910 |
++ if (d->d_flags & DCACHE_DENTRY_CURSOR) |
2911 |
++ continue; |
2912 |
++ if (simple_positive(d) && !--count) { |
2913 |
++ spin_lock_nested(&d->d_lock, DENTRY_D_LOCK_NESTED); |
2914 |
++ if (simple_positive(d)) |
2915 |
++ found = dget_dlock(d); |
2916 |
++ spin_unlock(&d->d_lock); |
2917 |
++ if (likely(found)) |
2918 |
++ break; |
2919 |
++ count = 1; |
2920 |
++ } |
2921 |
++ if (need_resched()) { |
2922 |
++ list_move(&cursor->d_child, p); |
2923 |
++ p = &cursor->d_child; |
2924 |
++ spin_unlock(&dentry->d_lock); |
2925 |
++ cond_resched(); |
2926 |
++ spin_lock(&dentry->d_lock); |
2927 |
+ } |
2928 |
+ } |
2929 |
+- rcu_read_unlock(); |
2930 |
+- if (skipped) { |
2931 |
+- smp_rmb(); |
2932 |
+- if (unlikely(*seq != n)) |
2933 |
+- goto retry; |
2934 |
+- } |
2935 |
+- return res; |
2936 |
+-} |
2937 |
+- |
2938 |
+-static void move_cursor(struct dentry *cursor, struct list_head *after) |
2939 |
+-{ |
2940 |
+- struct dentry *parent = cursor->d_parent; |
2941 |
+- unsigned n, *seq = &parent->d_inode->i_dir_seq; |
2942 |
+- spin_lock(&parent->d_lock); |
2943 |
+- for (;;) { |
2944 |
+- n = *seq; |
2945 |
+- if (!(n & 1) && cmpxchg(seq, n, n + 1) == n) |
2946 |
+- break; |
2947 |
+- cpu_relax(); |
2948 |
+- } |
2949 |
+- __list_del(cursor->d_child.prev, cursor->d_child.next); |
2950 |
+- if (after) |
2951 |
+- list_add(&cursor->d_child, after); |
2952 |
+- else |
2953 |
+- list_add_tail(&cursor->d_child, &parent->d_subdirs); |
2954 |
+- smp_store_release(seq, n + 2); |
2955 |
+- spin_unlock(&parent->d_lock); |
2956 |
++ spin_unlock(&dentry->d_lock); |
2957 |
++ dput(*res); |
2958 |
++ *res = found; |
2959 |
++ return p; |
2960 |
+ } |
2961 |
+ |
2962 |
+ loff_t dcache_dir_lseek(struct file *file, loff_t offset, int whence) |
2963 |
+@@ -153,17 +142,28 @@ loff_t dcache_dir_lseek(struct file *file, loff_t offset, int whence) |
2964 |
+ return -EINVAL; |
2965 |
+ } |
2966 |
+ if (offset != file->f_pos) { |
2967 |
++ struct dentry *cursor = file->private_data; |
2968 |
++ struct dentry *to = NULL; |
2969 |
++ struct list_head *p; |
2970 |
++ |
2971 |
+ file->f_pos = offset; |
2972 |
+- if (file->f_pos >= 2) { |
2973 |
+- struct dentry *cursor = file->private_data; |
2974 |
+- struct dentry *to; |
2975 |
+- loff_t n = file->f_pos - 2; |
2976 |
+- |
2977 |
+- inode_lock_shared(dentry->d_inode); |
2978 |
+- to = next_positive(dentry, &dentry->d_subdirs, n); |
2979 |
+- move_cursor(cursor, to ? &to->d_child : NULL); |
2980 |
+- inode_unlock_shared(dentry->d_inode); |
2981 |
++ inode_lock_shared(dentry->d_inode); |
2982 |
++ |
2983 |
++ if (file->f_pos > 2) { |
2984 |
++ p = scan_positives(cursor, &dentry->d_subdirs, |
2985 |
++ file->f_pos - 2, &to); |
2986 |
++ spin_lock(&dentry->d_lock); |
2987 |
++ list_move(&cursor->d_child, p); |
2988 |
++ spin_unlock(&dentry->d_lock); |
2989 |
++ } else { |
2990 |
++ spin_lock(&dentry->d_lock); |
2991 |
++ list_del_init(&cursor->d_child); |
2992 |
++ spin_unlock(&dentry->d_lock); |
2993 |
+ } |
2994 |
++ |
2995 |
++ dput(to); |
2996 |
++ |
2997 |
++ inode_unlock_shared(dentry->d_inode); |
2998 |
+ } |
2999 |
+ return offset; |
3000 |
+ } |
3001 |
+@@ -185,25 +185,29 @@ int dcache_readdir(struct file *file, struct dir_context *ctx) |
3002 |
+ { |
3003 |
+ struct dentry *dentry = file->f_path.dentry; |
3004 |
+ struct dentry *cursor = file->private_data; |
3005 |
+- struct list_head *p = &cursor->d_child; |
3006 |
+- struct dentry *next; |
3007 |
+- bool moved = false; |
3008 |
++ struct list_head *anchor = &dentry->d_subdirs; |
3009 |
++ struct dentry *next = NULL; |
3010 |
++ struct list_head *p; |
3011 |
+ |
3012 |
+ if (!dir_emit_dots(file, ctx)) |
3013 |
+ return 0; |
3014 |
+ |
3015 |
+ if (ctx->pos == 2) |
3016 |
+- p = &dentry->d_subdirs; |
3017 |
+- while ((next = next_positive(dentry, p, 1)) != NULL) { |
3018 |
++ p = anchor; |
3019 |
++ else |
3020 |
++ p = &cursor->d_child; |
3021 |
++ |
3022 |
++ while ((p = scan_positives(cursor, p, 1, &next)) != anchor) { |
3023 |
+ if (!dir_emit(ctx, next->d_name.name, next->d_name.len, |
3024 |
+ d_inode(next)->i_ino, dt_type(d_inode(next)))) |
3025 |
+ break; |
3026 |
+- moved = true; |
3027 |
+- p = &next->d_child; |
3028 |
+ ctx->pos++; |
3029 |
+ } |
3030 |
+- if (moved) |
3031 |
+- move_cursor(cursor, p); |
3032 |
++ spin_lock(&dentry->d_lock); |
3033 |
++ list_move_tail(&cursor->d_child, p); |
3034 |
++ spin_unlock(&dentry->d_lock); |
3035 |
++ dput(next); |
3036 |
++ |
3037 |
+ return 0; |
3038 |
+ } |
3039 |
+ EXPORT_SYMBOL(dcache_readdir); |
3040 |
+diff --git a/fs/nfs/direct.c b/fs/nfs/direct.c |
3041 |
+index 614ce1f8b4ac..9cdac9945483 100644 |
3042 |
+--- a/fs/nfs/direct.c |
3043 |
++++ b/fs/nfs/direct.c |
3044 |
+@@ -122,32 +122,49 @@ static inline int put_dreq(struct nfs_direct_req *dreq) |
3045 |
+ } |
3046 |
+ |
3047 |
+ static void |
3048 |
+-nfs_direct_good_bytes(struct nfs_direct_req *dreq, struct nfs_pgio_header *hdr) |
3049 |
++nfs_direct_handle_truncated(struct nfs_direct_req *dreq, |
3050 |
++ const struct nfs_pgio_header *hdr, |
3051 |
++ ssize_t dreq_len) |
3052 |
+ { |
3053 |
+- int i; |
3054 |
+- ssize_t count; |
3055 |
++ struct nfs_direct_mirror *mirror = &dreq->mirrors[hdr->pgio_mirror_idx]; |
3056 |
++ |
3057 |
++ if (!(test_bit(NFS_IOHDR_ERROR, &hdr->flags) || |
3058 |
++ test_bit(NFS_IOHDR_EOF, &hdr->flags))) |
3059 |
++ return; |
3060 |
++ if (dreq->max_count >= dreq_len) { |
3061 |
++ dreq->max_count = dreq_len; |
3062 |
++ if (dreq->count > dreq_len) |
3063 |
++ dreq->count = dreq_len; |
3064 |
++ |
3065 |
++ if (test_bit(NFS_IOHDR_ERROR, &hdr->flags)) |
3066 |
++ dreq->error = hdr->error; |
3067 |
++ else /* Clear outstanding error if this is EOF */ |
3068 |
++ dreq->error = 0; |
3069 |
++ } |
3070 |
++ if (mirror->count > dreq_len) |
3071 |
++ mirror->count = dreq_len; |
3072 |
++} |
3073 |
+ |
3074 |
+- WARN_ON_ONCE(dreq->count >= dreq->max_count); |
3075 |
++static void |
3076 |
++nfs_direct_count_bytes(struct nfs_direct_req *dreq, |
3077 |
++ const struct nfs_pgio_header *hdr) |
3078 |
++{ |
3079 |
++ struct nfs_direct_mirror *mirror = &dreq->mirrors[hdr->pgio_mirror_idx]; |
3080 |
++ loff_t hdr_end = hdr->io_start + hdr->good_bytes; |
3081 |
++ ssize_t dreq_len = 0; |
3082 |
+ |
3083 |
+- if (dreq->mirror_count == 1) { |
3084 |
+- dreq->mirrors[hdr->pgio_mirror_idx].count += hdr->good_bytes; |
3085 |
+- dreq->count += hdr->good_bytes; |
3086 |
+- } else { |
3087 |
+- /* mirrored writes */ |
3088 |
+- count = dreq->mirrors[hdr->pgio_mirror_idx].count; |
3089 |
+- if (count + dreq->io_start < hdr->io_start + hdr->good_bytes) { |
3090 |
+- count = hdr->io_start + hdr->good_bytes - dreq->io_start; |
3091 |
+- dreq->mirrors[hdr->pgio_mirror_idx].count = count; |
3092 |
+- } |
3093 |
+- /* update the dreq->count by finding the minimum agreed count from all |
3094 |
+- * mirrors */ |
3095 |
+- count = dreq->mirrors[0].count; |
3096 |
++ if (hdr_end > dreq->io_start) |
3097 |
++ dreq_len = hdr_end - dreq->io_start; |
3098 |
+ |
3099 |
+- for (i = 1; i < dreq->mirror_count; i++) |
3100 |
+- count = min(count, dreq->mirrors[i].count); |
3101 |
++ nfs_direct_handle_truncated(dreq, hdr, dreq_len); |
3102 |
+ |
3103 |
+- dreq->count = count; |
3104 |
+- } |
3105 |
++ if (dreq_len > dreq->max_count) |
3106 |
++ dreq_len = dreq->max_count; |
3107 |
++ |
3108 |
++ if (mirror->count < dreq_len) |
3109 |
++ mirror->count = dreq_len; |
3110 |
++ if (dreq->count < dreq_len) |
3111 |
++ dreq->count = dreq_len; |
3112 |
+ } |
3113 |
+ |
3114 |
+ /* |
3115 |
+@@ -401,20 +418,12 @@ static void nfs_direct_read_completion(struct nfs_pgio_header *hdr) |
3116 |
+ struct nfs_direct_req *dreq = hdr->dreq; |
3117 |
+ |
3118 |
+ spin_lock(&dreq->lock); |
3119 |
+- if (test_bit(NFS_IOHDR_ERROR, &hdr->flags)) |
3120 |
+- dreq->error = hdr->error; |
3121 |
+- |
3122 |
+ if (test_bit(NFS_IOHDR_REDO, &hdr->flags)) { |
3123 |
+ spin_unlock(&dreq->lock); |
3124 |
+ goto out_put; |
3125 |
+ } |
3126 |
+ |
3127 |
+- if (hdr->good_bytes != 0) |
3128 |
+- nfs_direct_good_bytes(dreq, hdr); |
3129 |
+- |
3130 |
+- if (test_bit(NFS_IOHDR_EOF, &hdr->flags)) |
3131 |
+- dreq->error = 0; |
3132 |
+- |
3133 |
++ nfs_direct_count_bytes(dreq, hdr); |
3134 |
+ spin_unlock(&dreq->lock); |
3135 |
+ |
3136 |
+ while (!list_empty(&hdr->pages)) { |
3137 |
+@@ -651,6 +660,9 @@ static void nfs_direct_write_reschedule(struct nfs_direct_req *dreq) |
3138 |
+ nfs_direct_write_scan_commit_list(dreq->inode, &reqs, &cinfo); |
3139 |
+ |
3140 |
+ dreq->count = 0; |
3141 |
++ dreq->max_count = 0; |
3142 |
++ list_for_each_entry(req, &reqs, wb_list) |
3143 |
++ dreq->max_count += req->wb_bytes; |
3144 |
+ dreq->verf.committed = NFS_INVALID_STABLE_HOW; |
3145 |
+ nfs_clear_pnfs_ds_commit_verifiers(&dreq->ds_cinfo); |
3146 |
+ for (i = 0; i < dreq->mirror_count; i++) |
3147 |
+@@ -783,17 +795,13 @@ static void nfs_direct_write_completion(struct nfs_pgio_header *hdr) |
3148 |
+ nfs_init_cinfo_from_dreq(&cinfo, dreq); |
3149 |
+ |
3150 |
+ spin_lock(&dreq->lock); |
3151 |
+- |
3152 |
+- if (test_bit(NFS_IOHDR_ERROR, &hdr->flags)) |
3153 |
+- dreq->error = hdr->error; |
3154 |
+- |
3155 |
+ if (test_bit(NFS_IOHDR_REDO, &hdr->flags)) { |
3156 |
+ spin_unlock(&dreq->lock); |
3157 |
+ goto out_put; |
3158 |
+ } |
3159 |
+ |
3160 |
++ nfs_direct_count_bytes(dreq, hdr); |
3161 |
+ if (hdr->good_bytes != 0) { |
3162 |
+- nfs_direct_good_bytes(dreq, hdr); |
3163 |
+ if (nfs_write_need_commit(hdr)) { |
3164 |
+ if (dreq->flags == NFS_ODIRECT_RESCHED_WRITES) |
3165 |
+ request_commit = true; |
3166 |
+diff --git a/fs/xfs/xfs_super.c b/fs/xfs/xfs_super.c |
3167 |
+index 0b0282d2f011..10151c9268e1 100644 |
3168 |
+--- a/fs/xfs/xfs_super.c |
3169 |
++++ b/fs/xfs/xfs_super.c |
3170 |
+@@ -1715,6 +1715,7 @@ xfs_fs_fill_super( |
3171 |
+ out_close_devices: |
3172 |
+ xfs_close_devices(mp); |
3173 |
+ out_free_fsname: |
3174 |
++ sb->s_fs_info = NULL; |
3175 |
+ xfs_free_fsname(mp); |
3176 |
+ kfree(mp); |
3177 |
+ out: |
3178 |
+@@ -1732,6 +1733,10 @@ xfs_fs_put_super( |
3179 |
+ { |
3180 |
+ struct xfs_mount *mp = XFS_M(sb); |
3181 |
+ |
3182 |
++ /* if ->fill_super failed, we have no mount to tear down */ |
3183 |
++ if (!sb->s_fs_info) |
3184 |
++ return; |
3185 |
++ |
3186 |
+ xfs_notice(mp, "Unmounting Filesystem"); |
3187 |
+ xfs_filestream_unmount(mp); |
3188 |
+ xfs_unmountfs(mp); |
3189 |
+@@ -1741,6 +1746,8 @@ xfs_fs_put_super( |
3190 |
+ xfs_destroy_percpu_counters(mp); |
3191 |
+ xfs_destroy_mount_workqueues(mp); |
3192 |
+ xfs_close_devices(mp); |
3193 |
++ |
3194 |
++ sb->s_fs_info = NULL; |
3195 |
+ xfs_free_fsname(mp); |
3196 |
+ kfree(mp); |
3197 |
+ } |
3198 |
+@@ -1760,6 +1767,9 @@ xfs_fs_nr_cached_objects( |
3199 |
+ struct super_block *sb, |
3200 |
+ struct shrink_control *sc) |
3201 |
+ { |
3202 |
++ /* Paranoia: catch incorrect calls during mount setup or teardown */ |
3203 |
++ if (WARN_ON_ONCE(!sb->s_fs_info)) |
3204 |
++ return 0; |
3205 |
+ return xfs_reclaim_inodes_count(XFS_M(sb)); |
3206 |
+ } |
3207 |
+ |
3208 |
+diff --git a/kernel/fork.c b/kernel/fork.c |
3209 |
+index 919e7cd5cd23..3352fdbd5e20 100644 |
3210 |
+--- a/kernel/fork.c |
3211 |
++++ b/kernel/fork.c |
3212 |
+@@ -2499,7 +2499,7 @@ int sysctl_max_threads(struct ctl_table *table, int write, |
3213 |
+ struct ctl_table t; |
3214 |
+ int ret; |
3215 |
+ int threads = max_threads; |
3216 |
+- int min = MIN_THREADS; |
3217 |
++ int min = 1; |
3218 |
+ int max = MAX_THREADS; |
3219 |
+ |
3220 |
+ t = *table; |
3221 |
+@@ -2511,7 +2511,7 @@ int sysctl_max_threads(struct ctl_table *table, int write, |
3222 |
+ if (ret || !write) |
3223 |
+ return ret; |
3224 |
+ |
3225 |
+- set_max_threads(threads); |
3226 |
++ max_threads = threads; |
3227 |
+ |
3228 |
+ return 0; |
3229 |
+ } |
3230 |
+diff --git a/kernel/panic.c b/kernel/panic.c |
3231 |
+index 32ff6fd30201..207ceac3a432 100644 |
3232 |
+--- a/kernel/panic.c |
3233 |
++++ b/kernel/panic.c |
3234 |
+@@ -146,6 +146,7 @@ void panic(const char *fmt, ...) |
3235 |
+ * after setting panic_cpu) from invoking panic() again. |
3236 |
+ */ |
3237 |
+ local_irq_disable(); |
3238 |
++ preempt_disable_notrace(); |
3239 |
+ |
3240 |
+ /* |
3241 |
+ * It's possible to come here directly from a panic-assertion and |
3242 |
+diff --git a/kernel/trace/ftrace.c b/kernel/trace/ftrace.c |
3243 |
+index 10b3e3b22af6..144d982905fc 100644 |
3244 |
+--- a/kernel/trace/ftrace.c |
3245 |
++++ b/kernel/trace/ftrace.c |
3246 |
+@@ -3629,21 +3629,22 @@ ftrace_regex_open(struct ftrace_ops *ops, int flag, |
3247 |
+ struct ftrace_hash *hash; |
3248 |
+ struct list_head *mod_head; |
3249 |
+ struct trace_array *tr = ops->private; |
3250 |
+- int ret = 0; |
3251 |
++ int ret = -ENOMEM; |
3252 |
+ |
3253 |
+ ftrace_ops_init(ops); |
3254 |
+ |
3255 |
+ if (unlikely(ftrace_disabled)) |
3256 |
+ return -ENODEV; |
3257 |
+ |
3258 |
++ if (tr && trace_array_get(tr) < 0) |
3259 |
++ return -ENODEV; |
3260 |
++ |
3261 |
+ iter = kzalloc(sizeof(*iter), GFP_KERNEL); |
3262 |
+ if (!iter) |
3263 |
+- return -ENOMEM; |
3264 |
++ goto out; |
3265 |
+ |
3266 |
+- if (trace_parser_get_init(&iter->parser, FTRACE_BUFF_MAX)) { |
3267 |
+- kfree(iter); |
3268 |
+- return -ENOMEM; |
3269 |
+- } |
3270 |
++ if (trace_parser_get_init(&iter->parser, FTRACE_BUFF_MAX)) |
3271 |
++ goto out; |
3272 |
+ |
3273 |
+ iter->ops = ops; |
3274 |
+ iter->flags = flag; |
3275 |
+@@ -3673,13 +3674,13 @@ ftrace_regex_open(struct ftrace_ops *ops, int flag, |
3276 |
+ |
3277 |
+ if (!iter->hash) { |
3278 |
+ trace_parser_put(&iter->parser); |
3279 |
+- kfree(iter); |
3280 |
+- ret = -ENOMEM; |
3281 |
+ goto out_unlock; |
3282 |
+ } |
3283 |
+ } else |
3284 |
+ iter->hash = hash; |
3285 |
+ |
3286 |
++ ret = 0; |
3287 |
++ |
3288 |
+ if (file->f_mode & FMODE_READ) { |
3289 |
+ iter->pg = ftrace_pages_start; |
3290 |
+ |
3291 |
+@@ -3691,7 +3692,6 @@ ftrace_regex_open(struct ftrace_ops *ops, int flag, |
3292 |
+ /* Failed */ |
3293 |
+ free_ftrace_hash(iter->hash); |
3294 |
+ trace_parser_put(&iter->parser); |
3295 |
+- kfree(iter); |
3296 |
+ } |
3297 |
+ } else |
3298 |
+ file->private_data = iter; |
3299 |
+@@ -3699,6 +3699,13 @@ ftrace_regex_open(struct ftrace_ops *ops, int flag, |
3300 |
+ out_unlock: |
3301 |
+ mutex_unlock(&ops->func_hash->regex_lock); |
3302 |
+ |
3303 |
++ out: |
3304 |
++ if (ret) { |
3305 |
++ kfree(iter); |
3306 |
++ if (tr) |
3307 |
++ trace_array_put(tr); |
3308 |
++ } |
3309 |
++ |
3310 |
+ return ret; |
3311 |
+ } |
3312 |
+ |
3313 |
+@@ -5098,6 +5105,8 @@ int ftrace_regex_release(struct inode *inode, struct file *file) |
3314 |
+ |
3315 |
+ mutex_unlock(&iter->ops->func_hash->regex_lock); |
3316 |
+ free_ftrace_hash(iter->hash); |
3317 |
++ if (iter->tr) |
3318 |
++ trace_array_put(iter->tr); |
3319 |
+ kfree(iter); |
3320 |
+ |
3321 |
+ return 0; |
3322 |
+diff --git a/kernel/trace/trace.c b/kernel/trace/trace.c |
3323 |
+index 91227e339ef6..bbe5a857c082 100644 |
3324 |
+--- a/kernel/trace/trace.c |
3325 |
++++ b/kernel/trace/trace.c |
3326 |
+@@ -4152,9 +4152,14 @@ static int show_traces_open(struct inode *inode, struct file *file) |
3327 |
+ if (tracing_disabled) |
3328 |
+ return -ENODEV; |
3329 |
+ |
3330 |
++ if (trace_array_get(tr) < 0) |
3331 |
++ return -ENODEV; |
3332 |
++ |
3333 |
+ ret = seq_open(file, &show_traces_seq_ops); |
3334 |
+- if (ret) |
3335 |
++ if (ret) { |
3336 |
++ trace_array_put(tr); |
3337 |
+ return ret; |
3338 |
++ } |
3339 |
+ |
3340 |
+ m = file->private_data; |
3341 |
+ m->private = tr; |
3342 |
+@@ -4162,6 +4167,14 @@ static int show_traces_open(struct inode *inode, struct file *file) |
3343 |
+ return 0; |
3344 |
+ } |
3345 |
+ |
3346 |
++static int show_traces_release(struct inode *inode, struct file *file) |
3347 |
++{ |
3348 |
++ struct trace_array *tr = inode->i_private; |
3349 |
++ |
3350 |
++ trace_array_put(tr); |
3351 |
++ return seq_release(inode, file); |
3352 |
++} |
3353 |
++ |
3354 |
+ static ssize_t |
3355 |
+ tracing_write_stub(struct file *filp, const char __user *ubuf, |
3356 |
+ size_t count, loff_t *ppos) |
3357 |
+@@ -4192,8 +4205,8 @@ static const struct file_operations tracing_fops = { |
3358 |
+ static const struct file_operations show_traces_fops = { |
3359 |
+ .open = show_traces_open, |
3360 |
+ .read = seq_read, |
3361 |
+- .release = seq_release, |
3362 |
+ .llseek = seq_lseek, |
3363 |
++ .release = show_traces_release, |
3364 |
+ }; |
3365 |
+ |
3366 |
+ static ssize_t |
3367 |
+diff --git a/kernel/trace/trace_hwlat.c b/kernel/trace/trace_hwlat.c |
3368 |
+index d7c8e4ec3d9d..bff6c033d70e 100644 |
3369 |
+--- a/kernel/trace/trace_hwlat.c |
3370 |
++++ b/kernel/trace/trace_hwlat.c |
3371 |
+@@ -152,7 +152,7 @@ void trace_hwlat_callback(bool enter) |
3372 |
+ if (enter) |
3373 |
+ nmi_ts_start = time_get(); |
3374 |
+ else |
3375 |
+- nmi_total_ts = time_get() - nmi_ts_start; |
3376 |
++ nmi_total_ts += time_get() - nmi_ts_start; |
3377 |
+ } |
3378 |
+ |
3379 |
+ if (enter) |
3380 |
+@@ -258,6 +258,8 @@ static int get_sample(void) |
3381 |
+ /* Keep a running maximum ever recorded hardware latency */ |
3382 |
+ if (sample > tr->max_latency) |
3383 |
+ tr->max_latency = sample; |
3384 |
++ if (outer_sample > tr->max_latency) |
3385 |
++ tr->max_latency = outer_sample; |
3386 |
+ } |
3387 |
+ |
3388 |
+ out: |
3389 |
+diff --git a/tools/perf/util/jitdump.c b/tools/perf/util/jitdump.c |
3390 |
+index 36483db032e8..3f02a5e284b2 100644 |
3391 |
+--- a/tools/perf/util/jitdump.c |
3392 |
++++ b/tools/perf/util/jitdump.c |
3393 |
+@@ -394,7 +394,7 @@ static int jit_repipe_code_load(struct jit_buf_desc *jd, union jr_entry *jr) |
3394 |
+ size_t size; |
3395 |
+ u16 idr_size; |
3396 |
+ const char *sym; |
3397 |
+- uint32_t count; |
3398 |
++ uint64_t count; |
3399 |
+ int ret, csize, usize; |
3400 |
+ pid_t pid, tid; |
3401 |
+ struct { |
3402 |
+@@ -417,7 +417,7 @@ static int jit_repipe_code_load(struct jit_buf_desc *jd, union jr_entry *jr) |
3403 |
+ return -1; |
3404 |
+ |
3405 |
+ filename = event->mmap2.filename; |
3406 |
+- size = snprintf(filename, PATH_MAX, "%s/jitted-%d-%u.so", |
3407 |
++ size = snprintf(filename, PATH_MAX, "%s/jitted-%d-%" PRIu64 ".so", |
3408 |
+ jd->dir, |
3409 |
+ pid, |
3410 |
+ count); |
3411 |
+@@ -530,7 +530,7 @@ static int jit_repipe_code_move(struct jit_buf_desc *jd, union jr_entry *jr) |
3412 |
+ return -1; |
3413 |
+ |
3414 |
+ filename = event->mmap2.filename; |
3415 |
+- size = snprintf(filename, PATH_MAX, "%s/jitted-%d-%"PRIu64, |
3416 |
++ size = snprintf(filename, PATH_MAX, "%s/jitted-%d-%" PRIu64 ".so", |
3417 |
+ jd->dir, |
3418 |
+ pid, |
3419 |
+ jr->move.code_index); |
3420 |
+diff --git a/tools/perf/util/llvm-utils.c b/tools/perf/util/llvm-utils.c |
3421 |
+index 2bdaac048a0a..da59a9e9543b 100644 |
3422 |
+--- a/tools/perf/util/llvm-utils.c |
3423 |
++++ b/tools/perf/util/llvm-utils.c |
3424 |
+@@ -225,14 +225,14 @@ static int detect_kbuild_dir(char **kbuild_dir) |
3425 |
+ const char *prefix_dir = ""; |
3426 |
+ const char *suffix_dir = ""; |
3427 |
+ |
3428 |
++ /* _UTSNAME_LENGTH is 65 */ |
3429 |
++ char release[128]; |
3430 |
++ |
3431 |
+ char *autoconf_path; |
3432 |
+ |
3433 |
+ int err; |
3434 |
+ |
3435 |
+ if (!test_dir) { |
3436 |
+- /* _UTSNAME_LENGTH is 65 */ |
3437 |
+- char release[128]; |
3438 |
+- |
3439 |
+ err = fetch_kernel_version(NULL, release, |
3440 |
+ sizeof(release)); |
3441 |
+ if (err) |