History

Merge tag 'usb-5.4-rc3' of git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/usb

Pull USB fixes from Greg KH: "Here are a lot of small USB driver fixes for 5.4-rc3. syzbot has stepped up its testing of the USB driver stack, now able to trigger fun race conditions between disconnect and probe functions. Because of that we have a lot of fixes in here from Johan and others fixing these reported issues that have been around since almost all time. We also are just deleting the rio500 driver, making all of the syzbot bugs found in it moot as it turns out no one has been using it for years as there is a userspace version that is being used instead. There are also a number of other small fixes in here, all resolving reported issues or regressions. All have been in linux-next without any reported issues" * tag 'usb-5.4-rc3' of git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/usb: (65 commits) USB: yurex: fix NULL-derefs on disconnect USB: iowarrior: use pr_err() USB: iowarrior: drop redundant iowarrior mutex USB: iowarrior: drop redundant disconnect mutex USB: iowarrior: fix use-after-free after driver unbind USB: iowarrior: fix use-after-free on release USB: iowarrior: fix use-after-free on disconnect USB: chaoskey: fix use-after-free on release USB: adutux: fix use-after-free on release USB: ldusb: fix NULL-derefs on driver unbind USB: legousbtower: fix use-after-free on release usb: cdns3: Fix for incorrect DMA mask. usb: cdns3: fix cdns3_core_init_role() usb: cdns3: gadget: Fix full-speed mode USB: usb-skeleton: drop redundant in-urb check USB: usb-skeleton: fix use-after-free after driver unbind USB: usb-skeleton: fix NULL-deref on disconnect usb:cdns3: Fix for CV CH9 running with g_zero driver. usb: dwc3: Remove dev_err() on platform_get_irq() failure usb: dwc3: Switch to platform_get_irq_byname_optional() ...

Linus Torvalds committed 7 years ago

Commit 6c90bbd2 parents 328fefa aafb00a74 files · +431 −961Browse files

Unified · Split

74 files
  1. Documentation/devicetree/bindings/usb/amlogic,dwc3.txt +2 −2
  2. Documentation/devicetree/bindings/usb/generic-ehci.yaml +6 −1
  3. Documentation/devicetree/bindings/usb/generic-ohci.yaml +6 −1
  4. Documentation/devicetree/bindings/usb/mediatek,mtk-xhci.txt +2 −2
  5. Documentation/devicetree/bindings/usb/mediatek,mtu3.txt +2 −2
  6. Documentation/devicetree/bindings/usb/usb-hcd.yaml +5 −0
  7. Documentation/devicetree/bindings/usb/usb-uhci.txt +1 −1
  8. Documentation/devicetree/bindings/usb/usb-xhci.txt +2 −2
  9. Documentation/usb/rio.rst +0 −109
  10. MAINTAINERS +0 −7
  11. arch/arm/boot/dts/sun4i-a10.dtsi +4 −0
  12. arch/arm/boot/dts/sun5i.dtsi +2 −0
  13. arch/arm/boot/dts/sun6i-a31.dtsi +4 −0
  14. arch/arm/boot/dts/sun7i-a20.dtsi +4 −0
  15. arch/arm/boot/dts/sun8i-a23-a33.dtsi +2 −0
  16. arch/arm/boot/dts/sun8i-a83t.dtsi +3 −0
  17. arch/arm/boot/dts/sun8i-r40.dtsi +4 −0
  18. arch/arm/boot/dts/sun9i-a80.dtsi +5 −0
  19. arch/arm/boot/dts/sunxi-h3-h5.dtsi +6 −0
  20. arch/arm/configs/badge4_defconfig +0 −1
  21. arch/arm/configs/corgi_defconfig +0 −1
  22. arch/arm/configs/pxa_defconfig +0 −1
  23. arch/arm/configs/s3c2410_defconfig +0 −1
  24. arch/arm/configs/spitz_defconfig +0 −1
  25. arch/arm64/boot/dts/allwinner/sun50i-a64-pinebook.dts +2 −0
  26. arch/arm64/boot/dts/allwinner/sun50i-a64.dtsi +2 −0
  27. arch/arm64/boot/dts/allwinner/sun50i-h6.dtsi +2 −0
  28. arch/mips/configs/mtx1_defconfig +0 −1
  29. arch/mips/configs/rm200_defconfig +0 −1
  30. drivers/base/platform.c +39 −7
  31. drivers/media/usb/stkwebcam/stk-webcam.c +1 −2
  32. drivers/usb/cdns3/cdns3-pci-wrap.c +2 −1
  33. drivers/usb/cdns3/core.c +19 −1
  34. drivers/usb/cdns3/ep0.c +9 −3
  35. drivers/usb/cdns3/gadget.c +8 −0
  36. drivers/usb/class/usblp.c +5 −3
  37. drivers/usb/dwc3/drd.c +2 −5
  38. drivers/usb/dwc3/gadget.c +2 −5
  39. drivers/usb/dwc3/host.c +2 −5
  40. drivers/usb/gadget/udc/Kconfig +1 −1
  41. drivers/usb/gadget/udc/dummy_hcd.c +2 −1
  42. drivers/usb/gadget/udc/lpc32xx_udc.c +2 −2
  43. drivers/usb/host/xhci-ext-caps.c +1 −0
  44. drivers/usb/host/xhci-ring.c +2 −2
  45. drivers/usb/host/xhci.c +63 −15
  46. drivers/usb/image/microtek.c +4 −0
  47. drivers/usb/misc/Kconfig +0 −10
  48. drivers/usb/misc/Makefile +0 −1
  49. drivers/usb/misc/adutux.c +15 −9
  50. drivers/usb/misc/chaoskey.c +3 −2
  51. drivers/usb/misc/iowarrior.c +15 −33
  52. drivers/usb/misc/ldusb.c +12 −12
  53. drivers/usb/misc/legousbtower.c +25 −33
  54. drivers/usb/misc/rio500.c +0 −554
  55. drivers/usb/misc/rio500_usb.h +0 −20
  56. drivers/usb/misc/usblcd.c +33 −27
  57. drivers/usb/misc/yurex.c +11 −7
  58. drivers/usb/renesas_usbhs/common.h +1 −0
  59. drivers/usb/renesas_usbhs/fifo.c +1 −1
  60. drivers/usb/renesas_usbhs/fifo.h +1 −0
  61. drivers/usb/renesas_usbhs/mod_gadget.c +15 −3
  62. drivers/usb/renesas_usbhs/pipe.c +15 −0
  63. drivers/usb/renesas_usbhs/pipe.h +1 −0
  64. drivers/usb/serial/ftdi_sio.c +3 −0
  65. drivers/usb/serial/ftdi_sio_ids.h +9 −0
  66. drivers/usb/serial/keyspan.c +2 −2
  67. drivers/usb/serial/option.c +11 −0
  68. drivers/usb/serial/usb-serial.c +1 −4
  69. drivers/usb/typec/tcpm/tcpm.c +8 −6
  70. drivers/usb/typec/ucsi/displayport.c +2 −0
  71. drivers/usb/typec/ucsi/ucsi_ccg.c +4 −38
  72. drivers/usb/usb-skeleton.c +9 −10
  73. drivers/usb/usbip/vhci_hcd.c +2 −2
  74. include/linux/platform_device.h +2 −0
Documentation/devicetree/bindings/usb/amlogic,dwc3.txt+2−2
@@ -85,8 +85,8 @@ A child node must exist to represent the core DWC2 IP block. The name of · 84 unmodified lines
8585 the node is not important. The content of the node is defined in dwc2.txt.
8686
8787 PHY documentation is provided in the following places:
88−- Documentation/devicetree/bindings/phy/meson-g12a-usb2-phy.txt
89−- Documentation/devicetree/bindings/phy/meson-g12a-usb3-pcie-phy.txt
88+- Documentation/devicetree/bindings/phy/amlogic,meson-g12a-usb2-phy.yaml
89+- Documentation/devicetree/bindings/phy/amlogic,meson-g12a-usb3-pcie-phy.yaml
9090
9191 Example device nodes:
9292 usb: usb@ffe09000 {
Documentation/devicetree/bindings/usb/generic-ehci.yaml+6−1
@@ -63,7 +63,11 @@ properties: · 62 unmodified lines
6363 description:
6464 Set this flag to force EHCI reset after resume.
6565
66− phys: true
66+ phys:
67+ description: PHY specifier for the USB PHY
68+
69+ phy-names:
70+ const: usb
6771
6872 required:
6973 - compatible
@@ -89,6 +93,7 @@ examples: · 19 unmodified lines
8993 interrupts = <39>;
9094 clocks = <&ahb_gates 1>;
9195 phys = <&usbphy 1>;
96+ phy-names = "usb";
9297 };
9398
9499 ...
Documentation/devicetree/bindings/usb/generic-ohci.yaml+6−1
@@ -67,7 +67,11 @@ properties: · 66 unmodified lines
6767 description:
6868 Overrides the detected port count
6969
70− phys: true
70+ phys:
71+ description: PHY specifier for the USB PHY
72+
73+ phy-names:
74+ const: usb
7175
7276 required:
7377 - compatible
@@ -84,6 +88,7 @@ examples: · 10 unmodified lines
8488 interrupts = <64>;
8589 clocks = <&usb_clk 6>, <&ahb_gates 2>;
8690 phys = <&usbphy 1>;
91+ phy-names = "usb";
8792 };
8893
8994 ...
Documentation/devicetree/bindings/usb/mediatek,mtk-xhci.txt+2−2
@@ -33,7 +33,7 @@ Required properties: · 32 unmodified lines
3333 "dma_ck": dma_bus clock for data transfer by DMA,
3434 "xhci_ck": controller clock
3535
36− - phys : see usb-hcd.txt in the current directory
36+ - phys : see usb-hcd.yaml in the current directory
3737
3838 Optional properties:
3939 - wakeup-source : enable USB remote wakeup;
@@ -53,7 +53,7 @@ Optional properties: · 13 unmodified lines
5353 See: Documentation/devicetree/bindings/pinctrl/pinctrl-bindings.txt
5454 - imod-interval-ns: default interrupt moderation interval is 5000ns
5555
56−additionally the properties from usb-hcd.txt (in the current directory) are
56+additionally the properties from usb-hcd.yaml (in the current directory) are
5757 supported.
5858
5959 Example:
Documentation/devicetree/bindings/usb/mediatek,mtu3.txt+2−2
@@ -17,7 +17,7 @@ Required properties: · 16 unmodified lines
1717 - clock-names : must contain "sys_ck" for clock of controller,
1818 the following clocks are optional:
1919 "ref_ck", "mcu_ck" and "dma_ck";
20− - phys : see usb-hcd.txt in the current directory
20+ - phys : see usb-hcd.yaml in the current directory
2121 - dr_mode : should be one of "host", "peripheral" or "otg",
2222 refer to usb/generic.txt
2323
@@ -60,7 +60,7 @@ Optional properties: · 36 unmodified lines
6060 - mediatek,u3p-dis-msk : mask to disable u3ports, bit0 for u3port0,
6161 bit1 for u3port1, ... etc;
6262
63−additionally the properties from usb-hcd.txt (in the current directory) are
63+additionally the properties from usb-hcd.yaml (in the current directory) are
6464 supported.
6565
6666 Sub-nodes:
Documentation/devicetree/bindings/usb/usb-hcd.yaml+5−0
@@ -18,8 +18,13 @@ properties: · 17 unmodified lines
1818 description:
1919 List of all the USB PHYs on this HCD
2020
21+ phy-names:
22+ description:
23+ Name specifier for the USB PHY
24+
2125 examples:
2226 - |
2327 usb {
2428 phys = <&usb2_phy1>, <&usb3_phy1>;
29+ phy-names = "usb";
2530 };
Documentation/devicetree/bindings/usb/usb-uhci.txt+1−1
@@ -6,7 +6,7 @@ Required properties: · 5 unmodified lines
66 - reg : Should contain 1 register ranges(address and length)
77 - interrupts : UHCI controller interrupt
88
9−additionally the properties from usb-hcd.txt (in the current directory) are
9+additionally the properties from usb-hcd.yaml (in the current directory) are
1010 supported.
1111
1212 Example:
Documentation/devicetree/bindings/usb/usb-xhci.txt+2−2
@@ -41,9 +41,9 @@ Optional properties: · 40 unmodified lines
4141 - usb3-lpm-capable: determines if platform is USB3 LPM capable
4242 - quirk-broken-port-ped: set if the controller has broken port disable mechanism
4343 - imod-interval-ns: default interrupt moderation interval is 5000ns
44− - phys : see usb-hcd.txt in the current directory
44+ - phys : see usb-hcd.yaml in the current directory
4545
46−additionally the properties from usb-hcd.txt (in the current directory) are
46+additionally the properties from usb-hcd.yaml (in the current directory) are
4747 supported.
4848
4949
Documentation/usb/rio.rst+0−109
@@ -1,109 +0,0 @@
1−============
2−Diamonds Rio
3−============
4−
5−Copyright (C) 1999, 2000 Bruce Tenison
6−
7−Portions Copyright (C) 1999, 2000 David Nelson
8−
9−Thanks to David Nelson for guidance and the usage of the scanner.txt
10−and scanner.c files to model our driver and this informative file.
11−
12−Mar. 2, 2000
13−
14−Changes
15−=======
16−
17−- Initial Revision
18−
19−
20−Overview
21−========
22−
23−This README will address issues regarding how to configure the kernel
24−to access a RIO 500 mp3 player.
25−Before I explain how to use this to access the Rio500 please be warned:
26−
27−.. warning::
28−
29− Please note that this software is still under development. The authors
30− are in no way responsible for any damage that may occur, no matter how
31− inconsequential.
32−
33−It seems that the Rio has a problem when sending .mp3 with low batteries.
34−I suggest when the batteries are low and you want to transfer stuff that you
35−replace it with a fresh one. In my case, what happened is I lost two 16kb
36−blocks (they are no longer usable to store information to it). But I don't
37−know if that's normal or not; it could simply be a problem with the flash
38−memory.
39−
40−In an extreme case, I left my Rio playing overnight and the batteries wore
41−down to nothing and appear to have corrupted the flash memory. My RIO
42−needed to be replaced as a result. Diamond tech support is aware of the
43−problem. Do NOT allow your batteries to wear down to nothing before
44−changing them. It appears RIO 500 firmware does not handle low battery
45−power well at all.
46−
47−On systems with OHCI controllers, the kernel OHCI code appears to have
48−power on problems with some chipsets. If you are having problems
49−connecting to your RIO 500, try turning it on first and then plugging it
50−into the USB cable.
51−
52−Contact Information
53−-------------------
54−
55− The main page for the project is hosted at sourceforge.net in the following
56− URL: <http://rio500.sourceforge.net>. You can also go to the project's
57− sourceforge home page at: <http://sourceforge.net/projects/rio500/>.
58− There is also a mailing list: rio500-users@lists.sourceforge.net
59−
60−Authors
61−-------
62−
63−Most of the code was written by Cesar Miquel <miquel@df.uba.ar>. Keith
64−Clayton <kclayton@jps.net> is incharge of the PPC port and making sure
65−things work there. Bruce Tenison <btenison@dibbs.net> is adding support
66−for .fon files and also does testing. The program will mostly sure be
67−re-written and Pete Ikusz along with the rest will re-design it. I would
68−also like to thank Tri Nguyen <tmn_3022000@hotmail.com> who provided use
69−with some important information regarding the communication with the Rio.
70−
71−Additional Information and userspace tools
72−
73− http://rio500.sourceforge.net/
74−
75−
76−Requirements
77−============
78−
79−A host with a USB port running a Linux kernel with RIO 500 support enabled.
80−
81−The driver is a module called rio500, which should be automatically loaded
82−as you plug in your device. If that fails you can manually load it with
83−
84− modprobe rio500
85−
86−Udev should automatically create a device node as soon as plug in your device.
87−If that fails, you can manually add a device for the USB rio500::
88−
89− mknod /dev/usb/rio500 c 180 64
90−
91−In that case, set appropriate permissions for /dev/usb/rio500 (don't forget
92−about group and world permissions). Both read and write permissions are
93−required for proper operation.
94−
95−That's it. The Rio500 Utils at: http://rio500.sourceforge.net should
96−be able to access the rio500.
97−
98−Limits
99−======
100−
101−You can use only a single rio500 device at a time with your computer.
102−
103−Bugs
104−====
105−
106−If you encounter any problems feel free to drop me an email.
107−
108−Bruce Tenison
109−btenison@dibbs.net
MAINTAINERS+0−7
@@ -16764,13 +16764,6 @@ W: http://www.linux-usb.org/usbnet · 16763 unmodified lines
1676416764 S: Maintained
1676516765 F: drivers/net/usb/dm9601.c
1676616766
16767−USB DIAMOND RIO500 DRIVER
16768−M: Cesar Miquel <miquel@df.uba.ar>
16769−L: rio500-users@lists.sourceforge.net
16770−W: http://rio500.sourceforge.net
16771−S: Maintained
16772−F: drivers/usb/misc/rio500*
16773−
1677416767 USB EHCI DRIVER
1677516768 M: Alan Stern <stern@rowland.harvard.edu>
1677616769 L: linux-usb@vger.kernel.org
arch/arm/boot/dts/sun4i-a10.dtsi+4−0
@@ -520,6 +520,7 @@ · 519 unmodified lines
520520 interrupts = <39>;
521521 clocks = <&ccu CLK_AHB_EHCI0>;
522522 phys = <&usbphy 1>;
523+ phy-names = "usb";
523524 status = "disabled";
524525 };
525526
@@ -529,6 +530,7 @@ · 3 unmodified lines
529530 interrupts = <64>;
530531 clocks = <&ccu CLK_USB_OHCI0>, <&ccu CLK_AHB_OHCI0>;
531532 phys = <&usbphy 1>;
533+ phy-names = "usb";
532534 status = "disabled";
533535 };
534536
@@ -608,6 +610,7 @@ · 73 unmodified lines
608610 interrupts = <40>;
609611 clocks = <&ccu CLK_AHB_EHCI1>;
610612 phys = <&usbphy 2>;
613+ phy-names = "usb";
611614 status = "disabled";
612615 };
613616
@@ -617,6 +620,7 @@ · 3 unmodified lines
617620 interrupts = <65>;
618621 clocks = <&ccu CLK_USB_OHCI1>, <&ccu CLK_AHB_OHCI1>;
619622 phys = <&usbphy 2>;
623+ phy-names = "usb";
620624 status = "disabled";
621625 };
622626
arch/arm/boot/dts/sun5i.dtsi+2−0
@@ -391,6 +391,7 @@ · 390 unmodified lines
391391 interrupts = <39>;
392392 clocks = <&ccu CLK_AHB_EHCI>;
393393 phys = <&usbphy 1>;
394+ phy-names = "usb";
394395 status = "disabled";
395396 };
396397
@@ -400,6 +401,7 @@ · 3 unmodified lines
400401 interrupts = <40>;
401402 clocks = <&ccu CLK_USB_OHCI>, <&ccu CLK_AHB_OHCI>;
402403 phys = <&usbphy 1>;
404+ phy-names = "usb";
403405 status = "disabled";
404406 };
405407
arch/arm/boot/dts/sun6i-a31.dtsi+4−0
@@ -545,6 +545,7 @@ · 544 unmodified lines
545545 clocks = <&ccu CLK_AHB1_EHCI0>;
546546 resets = <&ccu RST_AHB1_EHCI0>;
547547 phys = <&usbphy 1>;
548+ phy-names = "usb";
548549 status = "disabled";
549550 };
550551
@@ -555,6 +556,7 @@ · 4 unmodified lines
555556 clocks = <&ccu CLK_AHB1_OHCI0>, <&ccu CLK_USB_OHCI0>;
556557 resets = <&ccu RST_AHB1_OHCI0>;
557558 phys = <&usbphy 1>;
559+ phy-names = "usb";
558560 status = "disabled";
559561 };
560562
@@ -565,6 +567,7 @@ · 4 unmodified lines
565567 clocks = <&ccu CLK_AHB1_EHCI1>;
566568 resets = <&ccu RST_AHB1_EHCI1>;
567569 phys = <&usbphy 2>;
570+ phy-names = "usb";
568571 status = "disabled";
569572 };
570573
@@ -575,6 +578,7 @@ · 4 unmodified lines
575578 clocks = <&ccu CLK_AHB1_OHCI1>, <&ccu CLK_USB_OHCI1>;
576579 resets = <&ccu RST_AHB1_OHCI1>;
577580 phys = <&usbphy 2>;
581+ phy-names = "usb";
578582 status = "disabled";
579583 };
580584
arch/arm/boot/dts/sun7i-a20.dtsi+4−0
@@ -623,6 +623,7 @@ · 622 unmodified lines
623623 interrupts = <GIC_SPI 39 IRQ_TYPE_LEVEL_HIGH>;
624624 clocks = <&ccu CLK_AHB_EHCI0>;
625625 phys = <&usbphy 1>;
626+ phy-names = "usb";
626627 status = "disabled";
627628 };
628629
@@ -632,6 +633,7 @@ · 3 unmodified lines
632633 interrupts = <GIC_SPI 64 IRQ_TYPE_LEVEL_HIGH>;
633634 clocks = <&ccu CLK_USB_OHCI0>, <&ccu CLK_AHB_OHCI0>;
634635 phys = <&usbphy 1>;
636+ phy-names = "usb";
635637 status = "disabled";
636638 };
637639
@@ -714,6 +716,7 @@ · 76 unmodified lines
714716 interrupts = <GIC_SPI 40 IRQ_TYPE_LEVEL_HIGH>;
715717 clocks = <&ccu CLK_AHB_EHCI1>;
716718 phys = <&usbphy 2>;
719+ phy-names = "usb";
717720 status = "disabled";
718721 };
719722
@@ -723,6 +726,7 @@ · 3 unmodified lines
723726 interrupts = <GIC_SPI 65 IRQ_TYPE_LEVEL_HIGH>;
724727 clocks = <&ccu CLK_USB_OHCI1>, <&ccu CLK_AHB_OHCI1>;
725728 phys = <&usbphy 2>;
729+ phy-names = "usb";
726730 status = "disabled";
727731 };
728732
arch/arm/boot/dts/sun8i-a23-a33.dtsi+2−0
@@ -307,6 +307,7 @@ · 306 unmodified lines
307307 clocks = <&ccu CLK_BUS_EHCI>;
308308 resets = <&ccu RST_BUS_EHCI>;
309309 phys = <&usbphy 1>;
310+ phy-names = "usb";
310311 status = "disabled";
311312 };
312313
@@ -317,6 +318,7 @@ · 4 unmodified lines
317318 clocks = <&ccu CLK_BUS_OHCI>, <&ccu CLK_USB_OHCI>;
318319 resets = <&ccu RST_BUS_OHCI>;
319320 phys = <&usbphy 1>;
321+ phy-names = "usb";
320322 status = "disabled";
321323 };
322324
arch/arm/boot/dts/sun8i-a83t.dtsi+3−0
@@ -632,6 +632,7 @@ · 631 unmodified lines
632632 clocks = <&ccu CLK_BUS_EHCI0>;
633633 resets = <&ccu RST_BUS_EHCI0>;
634634 phys = <&usbphy 1>;
635+ phy-names = "usb";
635636 status = "disabled";
636637 };
637638
@@ -643,6 +644,7 @@ · 5 unmodified lines
643644 clocks = <&ccu CLK_BUS_OHCI0>, <&ccu CLK_USB_OHCI0>;
644645 resets = <&ccu RST_BUS_OHCI0>;
645646 phys = <&usbphy 1>;
647+ phy-names = "usb";
646648 status = "disabled";
647649 };
648650
@@ -654,6 +656,7 @@ · 5 unmodified lines
654656 clocks = <&ccu CLK_BUS_EHCI1>;
655657 resets = <&ccu RST_BUS_EHCI1>;
656658 phys = <&usbphy 2>;
659+ phy-names = "usb";
657660 status = "disabled";
658661 };
659662
arch/arm/boot/dts/sun8i-r40.dtsi+4−0
@@ -273,6 +273,7 @@ · 272 unmodified lines
273273 clocks = <&ccu CLK_BUS_EHCI1>;
274274 resets = <&ccu RST_BUS_EHCI1>;
275275 phys = <&usbphy 1>;
276+ phy-names = "usb";
276277 status = "disabled";
277278 };
278279
@@ -284,6 +285,7 @@ · 5 unmodified lines
284285 <&ccu CLK_USB_OHCI1>;
285286 resets = <&ccu RST_BUS_OHCI1>;
286287 phys = <&usbphy 1>;
288+ phy-names = "usb";
287289 status = "disabled";
288290 };
289291
@@ -294,6 +296,7 @@ · 4 unmodified lines
294296 clocks = <&ccu CLK_BUS_EHCI2>;
295297 resets = <&ccu RST_BUS_EHCI2>;
296298 phys = <&usbphy 2>;
299+ phy-names = "usb";
297300 status = "disabled";
298301 };
299302
@@ -305,6 +308,7 @@ · 5 unmodified lines
305308 <&ccu CLK_USB_OHCI2>;
306309 resets = <&ccu RST_BUS_OHCI2>;
307310 phys = <&usbphy 2>;
311+ phy-names = "usb";
308312 status = "disabled";
309313 };
310314
arch/arm/boot/dts/sun9i-a80.dtsi+5−0
@@ -346,6 +346,7 @@ · 345 unmodified lines
346346 clocks = <&usb_clocks CLK_BUS_HCI0>;
347347 resets = <&usb_clocks RST_USB0_HCI>;
348348 phys = <&usbphy1>;
349+ phy-names = "usb";
349350 status = "disabled";
350351 };
351352
@@ -357,6 +358,7 @@ · 5 unmodified lines
357358 <&usb_clocks CLK_USB_OHCI0>;
358359 resets = <&usb_clocks RST_USB0_HCI>;
359360 phys = <&usbphy1>;
361+ phy-names = "usb";
360362 status = "disabled";
361363 };
362364
@@ -378,6 +380,7 @@ · 15 unmodified lines
378380 clocks = <&usb_clocks CLK_BUS_HCI1>;
379381 resets = <&usb_clocks RST_USB1_HCI>;
380382 phys = <&usbphy2>;
383+ phy-names = "usb";
381384 status = "disabled";
382385 };
383386
@@ -407,6 +410,7 @@ · 23 unmodified lines
407410 clocks = <&usb_clocks CLK_BUS_HCI2>;
408411 resets = <&usb_clocks RST_USB2_HCI>;
409412 phys = <&usbphy3>;
413+ phy-names = "usb";
410414 status = "disabled";
411415 };
412416
@@ -418,6 +422,7 @@ · 5 unmodified lines
418422 <&usb_clocks CLK_USB_OHCI2>;
419423 resets = <&usb_clocks RST_USB2_HCI>;
420424 phys = <&usbphy3>;
425+ phy-names = "usb";
421426 status = "disabled";
422427 };
423428
arch/arm/boot/dts/sunxi-h3-h5.dtsi+6−0
@@ -304,6 +304,7 @@ · 303 unmodified lines
304304 clocks = <&ccu CLK_BUS_EHCI1>, <&ccu CLK_BUS_OHCI1>;
305305 resets = <&ccu RST_BUS_EHCI1>, <&ccu RST_BUS_OHCI1>;
306306 phys = <&usbphy 1>;
307+ phy-names = "usb";
307308 status = "disabled";
308309 };
309310
@@ -315,6 +316,7 @@ · 5 unmodified lines
315316 <&ccu CLK_USB_OHCI1>;
316317 resets = <&ccu RST_BUS_EHCI1>, <&ccu RST_BUS_OHCI1>;
317318 phys = <&usbphy 1>;
319+ phy-names = "usb";
318320 status = "disabled";
319321 };
320322
@@ -325,6 +327,7 @@ · 4 unmodified lines
325327 clocks = <&ccu CLK_BUS_EHCI2>, <&ccu CLK_BUS_OHCI2>;
326328 resets = <&ccu RST_BUS_EHCI2>, <&ccu RST_BUS_OHCI2>;
327329 phys = <&usbphy 2>;
330+ phy-names = "usb";
328331 status = "disabled";
329332 };
330333
@@ -336,6 +339,7 @@ · 5 unmodified lines
336339 <&ccu CLK_USB_OHCI2>;
337340 resets = <&ccu RST_BUS_EHCI2>, <&ccu RST_BUS_OHCI2>;
338341 phys = <&usbphy 2>;
342+ phy-names = "usb";
339343 status = "disabled";
340344 };
341345
@@ -346,6 +350,7 @@ · 4 unmodified lines
346350 clocks = <&ccu CLK_BUS_EHCI3>, <&ccu CLK_BUS_OHCI3>;
347351 resets = <&ccu RST_BUS_EHCI3>, <&ccu RST_BUS_OHCI3>;
348352 phys = <&usbphy 3>;
353+ phy-names = "usb";
349354 status = "disabled";
350355 };
351356
@@ -357,6 +362,7 @@ · 5 unmodified lines
357362 <&ccu CLK_USB_OHCI3>;
358363 resets = <&ccu RST_BUS_EHCI3>, <&ccu RST_BUS_OHCI3>;
359364 phys = <&usbphy 3>;
365+ phy-names = "usb";
360366 status = "disabled";
361367 };
362368
arch/arm/configs/badge4_defconfig+0−1
@@ -91,7 +91,6 @@ CONFIG_USB_SERIAL_PL2303=m · 90 unmodified lines
9191 CONFIG_USB_SERIAL_CYBERJACK=m
9292 CONFIG_USB_SERIAL_XIRCOM=m
9393 CONFIG_USB_SERIAL_OMNINET=m
94−CONFIG_USB_RIO500=m
9594 CONFIG_EXT2_FS=m
9695 CONFIG_EXT3_FS=m
9796 CONFIG_MSDOS_FS=y
arch/arm/configs/corgi_defconfig+0−1
@@ -195,7 +195,6 @@ CONFIG_USB_SERIAL_XIRCOM=m · 194 unmodified lines
195195 CONFIG_USB_SERIAL_OMNINET=m
196196 CONFIG_USB_EMI62=m
197197 CONFIG_USB_EMI26=m
198−CONFIG_USB_RIO500=m
199198 CONFIG_USB_LEGOTOWER=m
200199 CONFIG_USB_LCD=m
201200 CONFIG_USB_CYTHERM=m
arch/arm/configs/pxa_defconfig+0−1
@@ -581,7 +581,6 @@ CONFIG_USB_SERIAL_XIRCOM=m · 580 unmodified lines
581581 CONFIG_USB_SERIAL_OMNINET=m
582582 CONFIG_USB_EMI62=m
583583 CONFIG_USB_EMI26=m
584−CONFIG_USB_RIO500=m
585584 CONFIG_USB_LEGOTOWER=m
586585 CONFIG_USB_LCD=m
587586 CONFIG_USB_CYTHERM=m
arch/arm/configs/s3c2410_defconfig+0−1
@@ -327,7 +327,6 @@ CONFIG_USB_EMI62=m · 326 unmodified lines
327327 CONFIG_USB_EMI26=m
328328 CONFIG_USB_ADUTUX=m
329329 CONFIG_USB_SEVSEG=m
330−CONFIG_USB_RIO500=m
331330 CONFIG_USB_LEGOTOWER=m
332331 CONFIG_USB_LCD=m
333332 CONFIG_USB_CYPRESS_CY7C63=m
arch/arm/configs/spitz_defconfig+0−1
@@ -189,7 +189,6 @@ CONFIG_USB_SERIAL_XIRCOM=m · 188 unmodified lines
189189 CONFIG_USB_SERIAL_OMNINET=m
190190 CONFIG_USB_EMI62=m
191191 CONFIG_USB_EMI26=m
192−CONFIG_USB_RIO500=m
193192 CONFIG_USB_LEGOTOWER=m
194193 CONFIG_USB_LCD=m
195194 CONFIG_USB_CYTHERM=m
arch/arm64/boot/dts/allwinner/sun50i-a64-pinebook.dts+2−0
@@ -104,6 +104,7 @@ · 103 unmodified lines
104104
105105 &ehci0 {
106106 phys = <&usbphy 0>;
107+ phy-names = "usb";
107108 status = "okay";
108109 };
109110
@@ -150,6 +151,7 @@ · 40 unmodified lines
150151
151152 &ohci0 {
152153 phys = <&usbphy 0>;
154+ phy-names = "usb";
153155 status = "okay";
154156 };
155157
arch/arm64/boot/dts/allwinner/sun50i-a64.dtsi+2−0
@@ -553,6 +553,7 @@ · 552 unmodified lines
553553 resets = <&ccu RST_BUS_OHCI1>,
554554 <&ccu RST_BUS_EHCI1>;
555555 phys = <&usbphy 1>;
556+ phy-names = "usb";
556557 status = "disabled";
557558 };
558559
@@ -564,6 +565,7 @@ · 5 unmodified lines
564565 <&ccu CLK_USB_OHCI1>;
565566 resets = <&ccu RST_BUS_OHCI1>;
566567 phys = <&usbphy 1>;
568+ phy-names = "usb";
567569 status = "disabled";
568570 };
569571
arch/arm64/boot/dts/allwinner/sun50i-h6.dtsi+2−0
@@ -547,6 +547,7 @@ · 546 unmodified lines
547547 resets = <&ccu RST_BUS_OHCI3>,
548548 <&ccu RST_BUS_EHCI3>;
549549 phys = <&usb2phy 3>;
550+ phy-names = "usb";
550551 status = "disabled";
551552 };
552553
@@ -558,6 +559,7 @@ · 5 unmodified lines
558559 <&ccu CLK_USB_OHCI3>;
559560 resets = <&ccu RST_BUS_OHCI3>;
560561 phys = <&usb2phy 3>;
562+ phy-names = "usb";
561563 status = "disabled";
562564 };
563565
arch/mips/configs/mtx1_defconfig+0−1
@@ -571,7 +571,6 @@ CONFIG_USB_SERIAL_OMNINET=m · 570 unmodified lines
571571 CONFIG_USB_EMI62=m
572572 CONFIG_USB_EMI26=m
573573 CONFIG_USB_ADUTUX=m
574−CONFIG_USB_RIO500=m
575574 CONFIG_USB_LEGOTOWER=m
576575 CONFIG_USB_LCD=m
577576 CONFIG_USB_CYPRESS_CY7C63=m
arch/mips/configs/rm200_defconfig+0−1
@@ -314,7 +314,6 @@ CONFIG_USB_SERIAL_SAFE_PADDED=y · 313 unmodified lines
314314 CONFIG_USB_SERIAL_CYBERJACK=m
315315 CONFIG_USB_SERIAL_XIRCOM=m
316316 CONFIG_USB_SERIAL_OMNINET=m
317−CONFIG_USB_RIO500=m
318317 CONFIG_USB_LEGOTOWER=m
319318 CONFIG_USB_LCD=m
320319 CONFIG_USB_CYTHERM=m
drivers/base/platform.c+39−7
@@ -241,12 +241,8 @@ struct resource *platform_get_resource_byname(struct platform_device *dev, · 240 unmodified lines
241241 }
242242 EXPORT_SYMBOL_GPL(platform_get_resource_byname);
243243
244−/**
245− * platform_get_irq_byname - get an IRQ for a device by name
246− * @dev: platform device
247− * @name: IRQ name
248− */
249−int platform_get_irq_byname(struct platform_device *dev, const char *name)
244+static int __platform_get_irq_byname(struct platform_device *dev,
245+ const char *name)
250246 {
251247 struct resource *r;
252248
@@ -262,11 +258,47 @@ int platform_get_irq_byname(struct platform_device *dev, const char *name) · 9 unmodified lines
262258 if (r)
263259 return r->start;
264260
265− dev_err(&dev->dev, "IRQ %s not found\n", name);
266261 return -ENXIO;
267262 }
263+
264+/**
265+ * platform_get_irq_byname - get an IRQ for a device by name
266+ * @dev: platform device
267+ * @name: IRQ name
268+ *
269+ * Get an IRQ like platform_get_irq(), but then by name rather then by index.
270+ *
271+ * Return: IRQ number on success, negative error number on failure.
272+ */
273+int platform_get_irq_byname(struct platform_device *dev, const char *name)
274+{
275+ int ret;
276+
277+ ret = __platform_get_irq_byname(dev, name);
278+ if (ret < 0 && ret != -EPROBE_DEFER)
279+ dev_err(&dev->dev, "IRQ %s not found\n", name);
280+
281+ return ret;
282+}
268283 EXPORT_SYMBOL_GPL(platform_get_irq_byname);
269284
285+/**
286+ * platform_get_irq_byname_optional - get an optional IRQ for a device by name
287+ * @dev: platform device
288+ * @name: IRQ name
289+ *
290+ * Get an optional IRQ by name like platform_get_irq_byname(). Except that it
291+ * does not print an error message if an IRQ can not be obtained.
292+ *
293+ * Return: IRQ number on success, negative error number on failure.
294+ */
295+int platform_get_irq_byname_optional(struct platform_device *dev,
296+ const char *name)
297+{
298+ return __platform_get_irq_byname(dev, name);
299+}
300+EXPORT_SYMBOL_GPL(platform_get_irq_byname_optional);
301+
270302 /**
271303 * platform_add_devices - add a numbers of platform devices
272304 * @devs: array of platform devices to add
drivers/media/usb/stkwebcam/stk-webcam.c+1−2
@@ -643,8 +643,7 @@ static int v4l_stk_release(struct file *fp) · 642 unmodified lines
643643 dev->owner = NULL;
644644 }
645645
646− if (is_present(dev))
647− usb_autopm_put_interface(dev->interface);
646+ usb_autopm_put_interface(dev->interface);
648647 mutex_unlock(&dev->lock);
649648 return v4l2_fh_release(fp);
650649 }
drivers/usb/cdns3/cdns3-pci-wrap.c+2−1
@@ -159,8 +159,9 @@ static int cdns3_pci_probe(struct pci_dev *pdev, · 158 unmodified lines
159159 wrap->plat_dev = platform_device_register_full(&plat_info);
160160 if (IS_ERR(wrap->plat_dev)) {
161161 pci_disable_device(pdev);
162+ err = PTR_ERR(wrap->plat_dev);
162163 kfree(wrap);
163− return PTR_ERR(wrap->plat_dev);
164+ return err;
164165 }
165166 }
166167
drivers/usb/cdns3/core.c+19−1
@@ -160,10 +160,28 @@ static int cdns3_core_init_role(struct cdns3 *cdns) · 159 unmodified lines
160160 if (ret)
161161 goto err;
162162
163− if (cdns->dr_mode != USB_DR_MODE_OTG) {
163+ /* Initialize idle role to start with */
164+ ret = cdns3_role_start(cdns, USB_ROLE_NONE);
165+ if (ret)
166+ goto err;
167+
168+ switch (cdns->dr_mode) {
169+ case USB_DR_MODE_UNKNOWN:
170+ case USB_DR_MODE_OTG:
164171 ret = cdns3_hw_role_switch(cdns);
165172 if (ret)
166173 goto err;
174+ break;
175+ case USB_DR_MODE_PERIPHERAL:
176+ ret = cdns3_role_start(cdns, USB_ROLE_DEVICE);
177+ if (ret)
178+ goto err;
179+ break;
180+ case USB_DR_MODE_HOST:
181+ ret = cdns3_role_start(cdns, USB_ROLE_HOST);
182+ if (ret)
183+ goto err;
184+ break;
167185 }
168186
169187 return ret;
drivers/usb/cdns3/ep0.c+9−3
@@ -234,9 +234,11 @@ static int cdns3_req_ep0_set_address(struct cdns3_device *priv_dev, · 233 unmodified lines
234234 static int cdns3_req_ep0_get_status(struct cdns3_device *priv_dev,
235235 struct usb_ctrlrequest *ctrl)
236236 {
237+ struct cdns3_endpoint *priv_ep;
237238 __le16 *response_pkt;
238239 u16 usb_status = 0;
239240 u32 recip;
241+ u8 index;
240242
241243 recip = ctrl->bRequestType & USB_RECIP_MASK;
242244
@@ -262,9 +264,13 @@ static int cdns3_req_ep0_get_status(struct cdns3_device *priv_dev, · 19 unmodified lines
262264 case USB_RECIP_INTERFACE:
263265 return cdns3_ep0_delegate_req(priv_dev, ctrl);
264266 case USB_RECIP_ENDPOINT:
265− /* check if endpoint is stalled */
267+ index = cdns3_ep_addr_to_index(ctrl->wIndex);
268+ priv_ep = priv_dev->eps[index];
269+
270+ /* check if endpoint is stalled or stall is pending */
266271 cdns3_select_ep(priv_dev, ctrl->wIndex);
267− if (EP_STS_STALL(readl(&priv_dev->regs->ep_sts)))
272+ if (EP_STS_STALL(readl(&priv_dev->regs->ep_sts)) ||
273+ (priv_ep->flags & EP_STALL_PENDING))
268274 usb_status = BIT(USB_ENDPOINT_HALT);
269275 break;
270276 default:
@@ -332,7 +338,7 @@ static int cdns3_ep0_feature_handle_device(struct cdns3_device *priv_dev, · 61 unmodified lines
332338 * for sending status stage.
333339 * This time should be less then 3ms.
334340 */
335− usleep_range(1000, 2000);
341+ mdelay(1);
336342 cdns3_set_register_bit(&priv_dev->regs->usb_cmd,
337343 USB_CMD_STMODE |
338344 USB_STS_TMODE_SEL(tmode - 1));
drivers/usb/cdns3/gadget.c+8−0
@@ -2571,6 +2571,7 @@ static int cdns3_gadget_start(struct cdns3 *cdns) · 2570 unmodified lines
25712571 switch (max_speed) {
25722572 case USB_SPEED_FULL:
25732573 writel(USB_CONF_SFORCE_FS, &priv_dev->regs->usb_conf);
2574+ writel(USB_CONF_USB3DIS, &priv_dev->regs->usb_conf);
25742575 break;
25752576 case USB_SPEED_HIGH:
25762577 writel(USB_CONF_USB3DIS, &priv_dev->regs->usb_conf);
@@ -2662,6 +2663,13 @@ static int __cdns3_gadget_init(struct cdns3 *cdns) · 85 unmodified lines
26622663 {
26632664 int ret = 0;
26642665
2666+ /* Ensure 32-bit DMA Mask in case we switched back from Host mode */
2667+ ret = dma_set_mask_and_coherent(cdns->dev, DMA_BIT_MASK(32));
2668+ if (ret) {
2669+ dev_err(cdns->dev, "Failed to set dma mask: %d\n", ret);
2670+ return ret;
2671+ }
2672+
26652673 cdns3_drd_switch_gadget(cdns, 1);
26662674 pm_runtime_get_sync(cdns->dev);
26672675
drivers/usb/class/usblp.c+5−3
@@ -461,10 +461,12 @@ static int usblp_release(struct inode *inode, struct file *file) · 460 unmodified lines
461461
462462 mutex_lock(&usblp_mutex);
463463 usblp->used = 0;
464− if (usblp->present) {
464+ if (usblp->present)
465465 usblp_unlink_urbs(usblp);
466− usb_autopm_put_interface(usblp->intf);
467− } else /* finish cleanup from disconnect */
466+
467+ usb_autopm_put_interface(usblp->intf);
468+
469+ if (!usblp->present) /* finish cleanup from disconnect */
468470 usblp_cleanup(usblp);
469471 mutex_unlock(&usblp_mutex);
470472 return 0;
drivers/usb/dwc3/drd.c+2−5
@@ -139,14 +139,14 @@ static int dwc3_otg_get_irq(struct dwc3 *dwc) · 138 unmodified lines
139139 struct platform_device *dwc3_pdev = to_platform_device(dwc->dev);
140140 int irq;
141141
142− irq = platform_get_irq_byname(dwc3_pdev, "otg");
142+ irq = platform_get_irq_byname_optional(dwc3_pdev, "otg");
143143 if (irq > 0)
144144 goto out;
145145
146146 if (irq == -EPROBE_DEFER)
147147 goto out;
148148
149− irq = platform_get_irq_byname(dwc3_pdev, "dwc_usb3");
149+ irq = platform_get_irq_byname_optional(dwc3_pdev, "dwc_usb3");
150150 if (irq > 0)
151151 goto out;
152152
@@ -157,9 +157,6 @@ static int dwc3_otg_get_irq(struct dwc3 *dwc) · 4 unmodified lines
157157 if (irq > 0)
158158 goto out;
159159
160− if (irq != -EPROBE_DEFER)
161− dev_err(dwc->dev, "missing OTG IRQ\n");
162−
163160 if (!irq)
164161 irq = -EINVAL;
165162
drivers/usb/dwc3/gadget.c+2−5
@@ -3264,14 +3264,14 @@ static int dwc3_gadget_get_irq(struct dwc3 *dwc) · 3263 unmodified lines
32643264 struct platform_device *dwc3_pdev = to_platform_device(dwc->dev);
32653265 int irq;
32663266
3267− irq = platform_get_irq_byname(dwc3_pdev, "peripheral");
3267+ irq = platform_get_irq_byname_optional(dwc3_pdev, "peripheral");
32683268 if (irq > 0)
32693269 goto out;
32703270
32713271 if (irq == -EPROBE_DEFER)
32723272 goto out;
32733273
3274− irq = platform_get_irq_byname(dwc3_pdev, "dwc_usb3");
3274+ irq = platform_get_irq_byname_optional(dwc3_pdev, "dwc_usb3");
32753275 if (irq > 0)
32763276 goto out;
32773277
@@ -3282,9 +3282,6 @@ static int dwc3_gadget_get_irq(struct dwc3 *dwc) · 4 unmodified lines
32823282 if (irq > 0)
32833283 goto out;
32843284
3285− if (irq != -EPROBE_DEFER)
3286− dev_err(dwc->dev, "missing peripheral IRQ\n");
3287−
32883285 if (!irq)
32893286 irq = -EINVAL;
32903287
drivers/usb/dwc3/host.c+2−5
@@ -16,14 +16,14 @@ static int dwc3_host_get_irq(struct dwc3 *dwc) · 15 unmodified lines
1616 struct platform_device *dwc3_pdev = to_platform_device(dwc->dev);
1717 int irq;
1818
19− irq = platform_get_irq_byname(dwc3_pdev, "host");
19+ irq = platform_get_irq_byname_optional(dwc3_pdev, "host");
2020 if (irq > 0)
2121 goto out;
2222
2323 if (irq == -EPROBE_DEFER)
2424 goto out;
2525
26− irq = platform_get_irq_byname(dwc3_pdev, "dwc_usb3");
26+ irq = platform_get_irq_byname_optional(dwc3_pdev, "dwc_usb3");
2727 if (irq > 0)
2828 goto out;
2929
@@ -34,9 +34,6 @@ static int dwc3_host_get_irq(struct dwc3 *dwc) · 4 unmodified lines
3434 if (irq > 0)
3535 goto out;
3636
37− if (irq != -EPROBE_DEFER)
38− dev_err(dwc->dev, "missing host IRQ\n");
39−
4037 if (!irq)
4138 irq = -EINVAL;
4239
drivers/usb/gadget/udc/Kconfig+1−1
@@ -45,7 +45,7 @@ config USB_AT91 · 44 unmodified lines
4545
4646 config USB_LPC32XX
4747 tristate "LPC32XX USB Peripheral Controller"
48− depends on ARCH_LPC32XX
48+ depends on ARCH_LPC32XX || COMPILE_TEST
4949 depends on I2C
5050 select USB_ISP1301
5151 help
drivers/usb/gadget/udc/dummy_hcd.c+2−1
@@ -48,6 +48,7 @@ · 47 unmodified lines
4848 #define DRIVER_VERSION "02 May 2005"
4949
5050 #define POWER_BUDGET 500 /* in mA; use 8 for low-power port testing */
51+#define POWER_BUDGET_3 900 /* in mA */
5152
5253 static const char driver_name[] = "dummy_hcd";
5354 static const char driver_desc[] = "USB Host+Gadget Emulator";
@@ -2432,7 +2433,7 @@ static int dummy_start_ss(struct dummy_hcd *dum_hcd) · 2378 unmodified lines
24322433 dum_hcd->rh_state = DUMMY_RH_RUNNING;
24332434 dum_hcd->stream_en_ep = 0;
24342435 INIT_LIST_HEAD(&dum_hcd->urbp_list);
2435− dummy_hcd_to_hcd(dum_hcd)->power_budget = POWER_BUDGET;
2436+ dummy_hcd_to_hcd(dum_hcd)->power_budget = POWER_BUDGET_3;
24362437 dummy_hcd_to_hcd(dum_hcd)->state = HC_STATE_RUNNING;
24372438 dummy_hcd_to_hcd(dum_hcd)->uses_new_polling = 1;
24382439 #ifdef CONFIG_USB_OTG
drivers/usb/gadget/udc/lpc32xx_udc.c+2−2
@@ -1151,7 +1151,7 @@ static void udc_pop_fifo(struct lpc32xx_udc *udc, u8 *data, u32 bytes) · 1150 unmodified lines
11511151 u32 *p32, tmp, cbytes;
11521152
11531153 /* Use optimal data transfer method based on source address and size */
1154− switch (((u32) data) & 0x3) {
1154+ switch (((uintptr_t) data) & 0x3) {
11551155 case 0: /* 32-bit aligned */
11561156 p32 = (u32 *) data;
11571157 cbytes = (bytes & ~0x3);
@@ -1252,7 +1252,7 @@ static void udc_stuff_fifo(struct lpc32xx_udc *udc, u8 *data, u32 bytes) · 94 unmodified lines
12521252 u32 *p32, tmp, cbytes;
12531253
12541254 /* Use optimal data transfer method based on source address and size */
1255− switch (((u32) data) & 0x3) {
1255+ switch (((uintptr_t) data) & 0x3) {
12561256 case 0: /* 32-bit aligned */
12571257 p32 = (u32 *) data;
12581258 cbytes = (bytes & ~0x3);
drivers/usb/host/xhci-ext-caps.c+1−0
@@ -57,6 +57,7 @@ static int xhci_create_intel_xhci_sw_pdev(struct xhci_hcd *xhci, u32 cap_offset) · 56 unmodified lines
5757 ret = platform_device_add_properties(pdev, role_switch_props);
5858 if (ret) {
5959 dev_err(dev, "failed to register device properties\n");
60+ platform_device_put(pdev);
6061 return ret;
6162 }
6263 }
drivers/usb/host/xhci-ring.c+2−2
@@ -3202,10 +3202,10 @@ static int xhci_align_td(struct xhci_hcd *xhci, struct urb *urb, u32 enqd_len, · 3201 unmodified lines
32023202 if (usb_urb_dir_out(urb)) {
32033203 len = sg_pcopy_to_buffer(urb->sg, urb->num_sgs,
32043204 seg->bounce_buf, new_buff_len, enqd_len);
3205− if (len != seg->bounce_len)
3205+ if (len != new_buff_len)
32063206 xhci_warn(xhci,
32073207 "WARN Wrong bounce buffer write length: %zu != %d\n",
3208− len, seg->bounce_len);
3208+ len, new_buff_len);
32093209 seg->bounce_dma = dma_map_single(dev, seg->bounce_buf,
32103210 max_pkt, DMA_TO_DEVICE);
32113211 } else {
drivers/usb/host/xhci.c+63−15
@@ -1032,7 +1032,7 @@ int xhci_suspend(struct xhci_hcd *xhci, bool do_wakeup) · 1031 unmodified lines
10321032 writel(command, &xhci->op_regs->command);
10331033 xhci->broken_suspend = 0;
10341034 if (xhci_handshake(&xhci->op_regs->status,
1035− STS_SAVE, 0, 10 * 1000)) {
1035+ STS_SAVE, 0, 20 * 1000)) {
10361036 /*
10371037 * AMD SNPS xHC 3.0 occasionally does not clear the
10381038 * SSS bit of USBSTS and when driver tries to poll
@@ -1108,6 +1108,18 @@ int xhci_resume(struct xhci_hcd *xhci, bool hibernated) · 69 unmodified lines
11081108 hibernated = true;
11091109
11101110 if (!hibernated) {
1111+ /*
1112+ * Some controllers might lose power during suspend, so wait
1113+ * for controller not ready bit to clear, just as in xHC init.
1114+ */
1115+ retval = xhci_handshake(&xhci->op_regs->status,
1116+ STS_CNR, 0, 10 * 1000 * 1000);
1117+ if (retval) {
1118+ xhci_warn(xhci, "Controller not ready at resume %d\n",
1119+ retval);
1120+ spin_unlock_irq(&xhci->lock);
1121+ return retval;
1122+ }
11111123 /* step 1: restore register */
11121124 xhci_restore_registers(xhci);
11131125 /* step 2: initialize command ring buffer */
@@ -3083,6 +3095,7 @@ static void xhci_endpoint_reset(struct usb_hcd *hcd, · 1969 unmodified lines
30833095 unsigned int ep_index;
30843096 unsigned long flags;
30853097 u32 ep_flag;
3098+ int err;
30863099
30873100 xhci = hcd_to_xhci(hcd);
30883101 if (!host_ep->hcpriv)
@@ -3142,7 +3155,17 @@ static void xhci_endpoint_reset(struct usb_hcd *hcd, · 53 unmodified lines
31423155 xhci_free_command(xhci, cfg_cmd);
31433156 goto cleanup;
31443157 }
3145− xhci_queue_stop_endpoint(xhci, stop_cmd, udev->slot_id, ep_index, 0);
3158+
3159+ err = xhci_queue_stop_endpoint(xhci, stop_cmd, udev->slot_id,
3160+ ep_index, 0);
3161+ if (err < 0) {
3162+ spin_unlock_irqrestore(&xhci->lock, flags);
3163+ xhci_free_command(xhci, cfg_cmd);
3164+ xhci_dbg(xhci, "%s: Failed to queue stop ep command, %d ",
3165+ __func__, err);
3166+ goto cleanup;
3167+ }
3168+
31463169 xhci_ring_cmd_db(xhci);
31473170 spin_unlock_irqrestore(&xhci->lock, flags);
31483171
@@ -3156,8 +3179,16 @@ static void xhci_endpoint_reset(struct usb_hcd *hcd, · 7 unmodified lines
31563179 ctrl_ctx, ep_flag, ep_flag);
31573180 xhci_endpoint_copy(xhci, cfg_cmd->in_ctx, vdev->out_ctx, ep_index);
31583181
3159− xhci_queue_configure_endpoint(xhci, cfg_cmd, cfg_cmd->in_ctx->dma,
3182+ err = xhci_queue_configure_endpoint(xhci, cfg_cmd, cfg_cmd->in_ctx->dma,
31603183 udev->slot_id, false);
3184+ if (err < 0) {
3185+ spin_unlock_irqrestore(&xhci->lock, flags);
3186+ xhci_free_command(xhci, cfg_cmd);
3187+ xhci_dbg(xhci, "%s: Failed to queue config ep command, %d ",
3188+ __func__, err);
3189+ goto cleanup;
3190+ }
3191+
31613192 xhci_ring_cmd_db(xhci);
31623193 spin_unlock_irqrestore(&xhci->lock, flags);
31633194
@@ -4674,12 +4705,12 @@ static int xhci_update_timeout_for_endpoint(struct xhci_hcd *xhci, · 1510 unmodified lines
46744705 alt_timeout = xhci_call_host_update_timeout_for_endpoint(xhci, udev,
46754706 desc, state, timeout);
46764707
4677− /* If we found we can't enable hub-initiated LPM, or
4708+ /* If we found we can't enable hub-initiated LPM, and
46784709 * the U1 or U2 exit latency was too high to allow
4679− * device-initiated LPM as well, just stop searching.
4710+ * device-initiated LPM as well, then we will disable LPM
4711+ * for this device, so stop searching any further.
46804712 */
4681− if (alt_timeout == USB3_LPM_DISABLED ||
4682− alt_timeout == USB3_LPM_DEVICE_INITIATED) {
4713+ if (alt_timeout == USB3_LPM_DISABLED) {
46834714 *timeout = alt_timeout;
46844715 return -E2BIG;
46854716 }
@@ -4790,10 +4821,12 @@ static u16 xhci_calculate_lpm_timeout(struct usb_hcd *hcd, · 104 unmodified lines
47904821 if (intf->dev.driver) {
47914822 driver = to_usb_driver(intf->dev.driver);
47924823 if (driver && driver->disable_hub_initiated_lpm) {
4793− dev_dbg(&udev->dev, "Hub-initiated %s disabled "
4794− "at request of driver %s\n",
4795− state_name, driver->name);
4796− return xhci_get_timeout_no_hub_lpm(udev, state);
4824+ dev_dbg(&udev->dev, "Hub-initiated %s disabled at request of driver %s\n",
4825+ state_name, driver->name);
4826+ timeout = xhci_get_timeout_no_hub_lpm(udev,
4827+ state);
4828+ if (timeout == USB3_LPM_DISABLED)
4829+ return timeout;
47974830 }
47984831 }
47994832
@@ -5077,11 +5110,18 @@ int xhci_gen_setup(struct usb_hcd *hcd, xhci_get_quirks_t get_quirks) · 277 unmodified lines
50775110 hcd->has_tt = 1;
50785111 } else {
50795112 /*
5080− * Some 3.1 hosts return sbrn 0x30, use xhci supported protocol
5081− * minor revision instead of sbrn. Minor revision is a two digit
5082− * BCD containing minor and sub-minor numbers, only show minor.
5113+ * Early xHCI 1.1 spec did not mention USB 3.1 capable hosts
5114+ * should return 0x31 for sbrn, or that the minor revision
5115+ * is a two digit BCD containig minor and sub-minor numbers.
5116+ * This was later clarified in xHCI 1.2.
5117+ *
5118+ * Some USB 3.1 capable hosts therefore have sbrn 0x30, and
5119+ * minor revision set to 0x1 instead of 0x10.
50835120 */
5084− minor_rev = xhci->usb3_rhub.min_rev / 0x10;
5121+ if (xhci->usb3_rhub.min_rev == 0x1)
5122+ minor_rev = 1;
5123+ else
5124+ minor_rev = xhci->usb3_rhub.min_rev / 0x10;
50855125
50865126 switch (minor_rev) {
50875127 case 2:
@@ -5198,8 +5238,16 @@ static void xhci_clear_tt_buffer_complete(struct usb_hcd *hcd, · 110 unmodified lines
51985238 unsigned int ep_index;
51995239 unsigned long flags;
52005240
5241+ /*
5242+ * udev might be NULL if tt buffer is cleared during a failed device
5243+ * enumeration due to a halted control endpoint. Usb core might
5244+ * have allocated a new udev for the next enumeration attempt.
5245+ */
5246+
52015247 xhci = hcd_to_xhci(hcd);
52025248 udev = (struct usb_device *)ep->hcpriv;
5249+ if (!udev)
5250+ return;
52035251 slot_id = udev->slot_id;
52045252 ep_index = xhci_get_endpoint_index(&ep->desc);
52055253
drivers/usb/image/microtek.c+4−0
@@ -716,6 +716,10 @@ static int mts_usb_probe(struct usb_interface *intf, · 715 unmodified lines
716716
717717 }
718718
719+ if (ep_in_current != &ep_in_set[2]) {
720+ MTS_WARNING("couldn't find two input bulk endpoints. Bailing out.\n");
721+ return -ENODEV;
722+ }
719723
720724 if ( ep_out == -1 ) {
721725 MTS_WARNING( "couldn't find an output bulk endpoint. Bailing out.\n" );
drivers/usb/misc/Kconfig+0−10
@@ -47,16 +47,6 @@ config USB_SEVSEG · 46 unmodified lines
4747 To compile this driver as a module, choose M here: the
4848 module will be called usbsevseg.
4949
50−config USB_RIO500
51− tristate "USB Diamond Rio500 support"
52− help
53− Say Y here if you want to connect a USB Rio500 mp3 player to your
54− computer's USB port. Please read <file:Documentation/usb/rio.rst>
55− for more information.
56−
57− To compile this driver as a module, choose M here: the
58− module will be called rio500.
59−
6050 config USB_LEGOTOWER
6151 tristate "USB Lego Infrared Tower support"
6252 help
drivers/usb/misc/Makefile+0−1
@@ -17,7 +17,6 @@ obj-$(CONFIG_USB_ISIGHTFW) += isight_firmware.o · 16 unmodified lines
1717 obj-$(CONFIG_USB_LCD) += usblcd.o
1818 obj-$(CONFIG_USB_LD) += ldusb.o
1919 obj-$(CONFIG_USB_LEGOTOWER) += legousbtower.o
20−obj-$(CONFIG_USB_RIO500) += rio500.o
2120 obj-$(CONFIG_USB_TEST) += usbtest.o
2221 obj-$(CONFIG_USB_EHSET_TEST_FIXTURE) += ehset.o
2322 obj-$(CONFIG_USB_TRANCEVIBRATOR) += trancevibrator.o
drivers/usb/misc/adutux.c+15−9
@@ -75,6 +75,7 @@ struct adu_device { · 74 unmodified lines
7575 char serial_number[8];
7676
7777 int open_count; /* number of times this port has been opened */
78+ unsigned long disconnected:1;
7879
7980 char *read_buffer_primary;
8081 int read_buffer_length;
@@ -116,7 +117,7 @@ static void adu_abort_transfers(struct adu_device *dev) · 35 unmodified lines
116117 {
117118 unsigned long flags;
118119
119− if (dev->udev == NULL)
120+ if (dev->disconnected)
120121 return;
121122
122123 /* shutdown transfer */
@@ -148,6 +149,7 @@ static void adu_delete(struct adu_device *dev) · 25 unmodified lines
148149 kfree(dev->read_buffer_secondary);
149150 kfree(dev->interrupt_in_buffer);
150151 kfree(dev->interrupt_out_buffer);
152+ usb_put_dev(dev->udev);
151153 kfree(dev);
152154 }
153155
@@ -243,7 +245,7 @@ static int adu_open(struct inode *inode, struct file *file) · 89 unmodified lines
243245 }
244246
245247 dev = usb_get_intfdata(interface);
246− if (!dev || !dev->udev) {
248+ if (!dev) {
247249 retval = -ENODEV;
248250 goto exit_no_device;
249251 }
@@ -326,7 +328,7 @@ static int adu_release(struct inode *inode, struct file *file) · 76 unmodified lines
326328 }
327329
328330 adu_release_internal(dev);
329− if (dev->udev == NULL) {
331+ if (dev->disconnected) {
330332 /* the device was unplugged before the file was released */
331333 if (!dev->open_count) /* ... and we're the last user */
332334 adu_delete(dev);
@@ -354,7 +356,7 @@ static ssize_t adu_read(struct file *file, __user char *buffer, size_t count, · 21 unmodified lines
354356 return -ERESTARTSYS;
355357
356358 /* verify that the device wasn't unplugged */
357− if (dev->udev == NULL) {
359+ if (dev->disconnected) {
358360 retval = -ENODEV;
359361 pr_err("No device or device unplugged %d\n", retval);
360362 goto exit;
@@ -518,7 +520,7 @@ static ssize_t adu_write(struct file *file, const __user char *buffer, · 157 unmodified lines
518520 goto exit_nolock;
519521
520522 /* verify that the device wasn't unplugged */
521− if (dev->udev == NULL) {
523+ if (dev->disconnected) {
522524 retval = -ENODEV;
523525 pr_err("No device or device unplugged %d\n", retval);
524526 goto exit;
@@ -663,7 +665,7 @@ static int adu_probe(struct usb_interface *interface, · 138 unmodified lines
663665
664666 mutex_init(&dev->mtx);
665667 spin_lock_init(&dev->buflock);
666− dev->udev = udev;
668+ dev->udev = usb_get_dev(udev);
667669 init_waitqueue_head(&dev->read_wait);
668670 init_waitqueue_head(&dev->write_wait);
669671
@@ -762,14 +764,18 @@ static void adu_disconnect(struct usb_interface *interface) · 92 unmodified lines
762764
763765 dev = usb_get_intfdata(interface);
764766
765− mutex_lock(&dev->mtx); /* not interruptible */
766− dev->udev = NULL; /* poison */
767767 usb_deregister_dev(interface, &adu_class);
768− mutex_unlock(&dev->mtx);
768+
769+ usb_poison_urb(dev->interrupt_in_urb);
770+ usb_poison_urb(dev->interrupt_out_urb);
769771
770772 mutex_lock(&adutux_mutex);
771773 usb_set_intfdata(interface, NULL);
772774
775+ mutex_lock(&dev->mtx); /* not interruptible */
776+ dev->disconnected = 1;
777+ mutex_unlock(&dev->mtx);
778+
773779 /* if the device is not opened, then we clean up right now */
774780 if (!dev->open_count)
775781 adu_delete(dev);
drivers/usb/misc/chaoskey.c+3−2
@@ -98,6 +98,7 @@ static void chaoskey_free(struct chaoskey *dev) · 97 unmodified lines
9898 usb_free_urb(dev->urb);
9999 kfree(dev->name);
100100 kfree(dev->buf);
101+ usb_put_intf(dev->interface);
101102 kfree(dev);
102103 }
103104 }
@@ -145,6 +146,8 @@ static int chaoskey_probe(struct usb_interface *interface, · 41 unmodified lines
145146 if (dev == NULL)
146147 goto out;
147148
149+ dev->interface = usb_get_intf(interface);
150+
148151 dev->buf = kmalloc(size, GFP_KERNEL);
149152
150153 if (dev->buf == NULL)
@@ -174,8 +177,6 @@ static int chaoskey_probe(struct usb_interface *interface, · 23 unmodified lines
174177 goto out;
175178 }
176179
177− dev->interface = interface;
178−
179180 dev->in_ep = in_ep;
180181
181182 if (le16_to_cpu(udev->descriptor.idVendor) != ALEA_VENDOR_ID)
drivers/usb/misc/iowarrior.c+15−33
@@ -54,11 +54,7 @@ MODULE_AUTHOR(DRIVER_AUTHOR); · 53 unmodified lines
5454 MODULE_DESCRIPTION(DRIVER_DESC);
5555 MODULE_LICENSE("GPL");
5656
57−/* Module parameters */
58−static DEFINE_MUTEX(iowarrior_mutex);
59−
6057 static struct usb_driver iowarrior_driver;
61−static DEFINE_MUTEX(iowarrior_open_disc_lock);
6258
6359 /*--------------*/
6460 /* data */
@@ -87,6 +83,7 @@ struct iowarrior { · 22 unmodified lines
8783 char chip_serial[9]; /* the serial number string of the chip connected */
8884 int report_size; /* number of bytes in a report */
8985 u16 product_id;
86+ struct usb_anchor submitted;
9087 };
9188
9289 /*--------------*/
@@ -243,6 +240,7 @@ static inline void iowarrior_delete(struct iowarrior *dev) · 150 unmodified lines
243240 kfree(dev->int_in_buffer);
244241 usb_free_urb(dev->int_in_urb);
245242 kfree(dev->read_queue);
243+ usb_put_intf(dev->interface);
246244 kfree(dev);
247245 }
248246
@@ -424,11 +422,13 @@ static ssize_t iowarrior_write(struct file *file, · 175 unmodified lines
424422 retval = -EFAULT;
425423 goto error;
426424 }
425+ usb_anchor_urb(int_out_urb, &dev->submitted);
427426 retval = usb_submit_urb(int_out_urb, GFP_KERNEL);
428427 if (retval) {
429428 dev_dbg(&dev->interface->dev,
430429 "submit error %d for urb nr.%d\n",
431430 retval, atomic_read(&dev->write_busy));
431+ usb_unanchor_urb(int_out_urb);
432432 goto error;
433433 }
434434 /* submit was ok */
@@ -477,8 +477,6 @@ static long iowarrior_ioctl(struct file *file, unsigned int cmd, · 42 unmodified lines
477477 if (!buffer)
478478 return -ENOMEM;
479479
480− /* lock this object */
481− mutex_lock(&iowarrior_mutex);
482480 mutex_lock(&dev->mutex);
483481
484482 /* verify that the device wasn't unplugged */
@@ -571,7 +569,6 @@ static long iowarrior_ioctl(struct file *file, unsigned int cmd, · 86 unmodified lines
571569 error_out:
572570 /* unlock the device */
573571 mutex_unlock(&dev->mutex);
574− mutex_unlock(&iowarrior_mutex);
575572 kfree(buffer);
576573 return retval;
577574 }
@@ -586,27 +583,20 @@ static int iowarrior_open(struct inode *inode, struct file *file) · 8 unmodified lines
586583 int subminor;
587584 int retval = 0;
588585
589− mutex_lock(&iowarrior_mutex);
590586 subminor = iminor(inode);
591587
592588 interface = usb_find_interface(&iowarrior_driver, subminor);
593589 if (!interface) {
594− mutex_unlock(&iowarrior_mutex);
595− printk(KERN_ERR "%s - error, can't find device for minor %d\n",
590+ pr_err("%s - error, can't find device for minor %d\n",
596591 __func__, subminor);
597592 return -ENODEV;
598593 }
599594
600− mutex_lock(&iowarrior_open_disc_lock);
601595 dev = usb_get_intfdata(interface);
602− if (!dev) {
603− mutex_unlock(&iowarrior_open_disc_lock);
604− mutex_unlock(&iowarrior_mutex);
596+ if (!dev)
605597 return -ENODEV;
606− }
607598
608599 mutex_lock(&dev->mutex);
609− mutex_unlock(&iowarrior_open_disc_lock);
610600
611601 /* Only one process can open each device, no sharing. */
612602 if (dev->opened) {
@@ -628,7 +618,6 @@ static int iowarrior_open(struct inode *inode, struct file *file) · 15 unmodified lines
628618
629619 out:
630620 mutex_unlock(&dev->mutex);
631− mutex_unlock(&iowarrior_mutex);
632621 return retval;
633622 }
634623
@@ -764,11 +753,13 @@ static int iowarrior_probe(struct usb_interface *interface, · 129 unmodified lines
764753 init_waitqueue_head(&dev->write_wait);
765754
766755 dev->udev = udev;
767− dev->interface = interface;
756+ dev->interface = usb_get_intf(interface);
768757
769758 iface_desc = interface->cur_altsetting;
770759 dev->product_id = le16_to_cpu(udev->descriptor.idProduct);
771760
761+ init_usb_anchor(&dev->submitted);
762+
772763 res = usb_find_last_int_in_endpoint(iface_desc, &dev->int_in_endpoint);
773764 if (res) {
774765 dev_err(&interface->dev, "no interrupt-in endpoint found\n");
@@ -836,7 +827,6 @@ static int iowarrior_probe(struct usb_interface *interface, · 61 unmodified lines
836827 if (retval) {
837828 /* something prevented us from registering this driver */
838829 dev_err(&interface->dev, "Not able to get a minor for this device.\n");
839− usb_set_intfdata(interface, NULL);
840830 goto error;
841831 }
842832
@@ -860,26 +850,15 @@ error: · 17 unmodified lines
860850 */
861851 static void iowarrior_disconnect(struct usb_interface *interface)
862852 {
863− struct iowarrior *dev;
864− int minor;
865−
866− dev = usb_get_intfdata(interface);
867− mutex_lock(&iowarrior_open_disc_lock);
868− usb_set_intfdata(interface, NULL);
869− /* prevent device read, write and ioctl */
870− dev->present = 0;
871−
872− minor = dev->minor;
873− mutex_unlock(&iowarrior_open_disc_lock);
874− /* give back our minor - this will call close() locks need to be dropped at this point*/
853+ struct iowarrior *dev = usb_get_intfdata(interface);
854+ int minor = dev->minor;
875855
876856 usb_deregister_dev(interface, &iowarrior_class);
877857
878858 mutex_lock(&dev->mutex);
879859
880860 /* prevent device read, write and ioctl */
881−
882− mutex_unlock(&dev->mutex);
861+ dev->present = 0;
883862
884863 if (dev->opened) {
885864 /* There is a process that holds a filedescriptor to the device ,
@@ -887,10 +866,13 @@ static void iowarrior_disconnect(struct usb_interface *interface) · 1 unmodified line
887866 Deleting the device is postponed until close() was called.
888867 */
889868 usb_kill_urb(dev->int_in_urb);
869+ usb_kill_anchored_urbs(&dev->submitted);
890870 wake_up_interruptible(&dev->read_wait);
891871 wake_up_interruptible(&dev->write_wait);
872+ mutex_unlock(&dev->mutex);
892873 } else {
893874 /* no process is using the device, cleanup now */
875+ mutex_unlock(&dev->mutex);
894876 iowarrior_delete(dev);
895877 }
896878
drivers/usb/misc/ldusb.c+12−12
@@ -153,6 +153,7 @@ MODULE_PARM_DESC(min_interrupt_out_interval, "Minimum interrupt out interval in · 152 unmodified lines
153153 struct ld_usb {
154154 struct mutex mutex; /* locks this structure */
155155 struct usb_interface *intf; /* save off the usb interface pointer */
156+ unsigned long disconnected:1;
156157
157158 int open_count; /* number of times this port has been opened */
158159
@@ -192,12 +193,10 @@ static void ld_usb_abort_transfers(struct ld_usb *dev) · 33 unmodified lines
192193 /* shutdown transfer */
193194 if (dev->interrupt_in_running) {
194195 dev->interrupt_in_running = 0;
195− if (dev->intf)
196− usb_kill_urb(dev->interrupt_in_urb);
196+ usb_kill_urb(dev->interrupt_in_urb);
197197 }
198198 if (dev->interrupt_out_busy)
199− if (dev->intf)
200− usb_kill_urb(dev->interrupt_out_urb);
199+ usb_kill_urb(dev->interrupt_out_urb);
201200 }
202201
203202 /**
@@ -205,8 +204,6 @@ static void ld_usb_abort_transfers(struct ld_usb *dev) · 1 unmodified line
205204 */
206205 static void ld_usb_delete(struct ld_usb *dev)
207206 {
208− ld_usb_abort_transfers(dev);
209−
210207 /* free data structures */
211208 usb_free_urb(dev->interrupt_in_urb);
212209 usb_free_urb(dev->interrupt_out_urb);
@@ -263,7 +260,7 @@ static void ld_usb_interrupt_in_callback(struct urb *urb) · 50 unmodified lines
263260
264261 resubmit:
265262 /* resubmit if we're still running */
266− if (dev->interrupt_in_running && !dev->buffer_overflow && dev->intf) {
263+ if (dev->interrupt_in_running && !dev->buffer_overflow) {
267264 retval = usb_submit_urb(dev->interrupt_in_urb, GFP_ATOMIC);
268265 if (retval) {
269266 dev_err(&dev->intf->dev,
@@ -392,7 +389,7 @@ static int ld_usb_release(struct inode *inode, struct file *file) · 122 unmodified lines
392389 retval = -ENODEV;
393390 goto unlock_exit;
394391 }
395− if (dev->intf == NULL) {
392+ if (dev->disconnected) {
396393 /* the device was unplugged before the file was released */
397394 mutex_unlock(&dev->mutex);
398395 /* unlock here as ld_usb_delete frees dev */
@@ -423,7 +420,7 @@ static __poll_t ld_usb_poll(struct file *file, poll_table *wait) · 24 unmodified lines
423420
424421 dev = file->private_data;
425422
426− if (!dev->intf)
423+ if (dev->disconnected)
427424 return EPOLLERR | EPOLLHUP;
428425
429426 poll_wait(file, &dev->read_wait, wait);
@@ -462,7 +459,7 @@ static ssize_t ld_usb_read(struct file *file, char __user *buffer, size_t count, · 32 unmodified lines
462459 }
463460
464461 /* verify that the device wasn't unplugged */
465− if (dev->intf == NULL) {
462+ if (dev->disconnected) {
466463 retval = -ENODEV;
467464 printk(KERN_ERR "ldusb: No device or device unplugged %d\n", retval);
468465 goto unlock_exit;
@@ -542,7 +539,7 @@ static ssize_t ld_usb_write(struct file *file, const char __user *buffer, · 73 unmodified lines
542539 }
543540
544541 /* verify that the device wasn't unplugged */
545− if (dev->intf == NULL) {
542+ if (dev->disconnected) {
546543 retval = -ENODEV;
547544 printk(KERN_ERR "ldusb: No device or device unplugged %d\n", retval);
548545 goto unlock_exit;
@@ -764,6 +761,9 @@ static void ld_usb_disconnect(struct usb_interface *intf) · 215 unmodified lines
764761 /* give back our minor */
765762 usb_deregister_dev(intf, &ld_usb_class);
766763
764+ usb_poison_urb(dev->interrupt_in_urb);
765+ usb_poison_urb(dev->interrupt_out_urb);
766+
767767 mutex_lock(&dev->mutex);
768768
769769 /* if the device is not opened, then we clean up right now */
@@ -771,7 +771,7 @@ static void ld_usb_disconnect(struct usb_interface *intf) · 1 unmodified line
771771 mutex_unlock(&dev->mutex);
772772 ld_usb_delete(dev);
773773 } else {
774− dev->intf = NULL;
774+ dev->disconnected = 1;
775775 /* wake up pollers */
776776 wake_up_interruptible_all(&dev->read_wait);
777777 wake_up_interruptible_all(&dev->write_wait);
drivers/usb/misc/legousbtower.c+25−33
@@ -179,7 +179,6 @@ static const struct usb_device_id tower_table[] = { · 178 unmodified lines
179179 };
180180
181181 MODULE_DEVICE_TABLE (usb, tower_table);
182−static DEFINE_MUTEX(open_disc_mutex);
183182
184183 #define LEGO_USB_TOWER_MINOR_BASE 160
185184
@@ -191,6 +190,7 @@ struct lego_usb_tower { · 5 unmodified lines
191190 unsigned char minor; /* the starting minor number for this device */
192191
193192 int open_count; /* number of times this port has been opened */
193+ unsigned long disconnected:1;
194194
195195 char* read_buffer;
196196 size_t read_buffer_length; /* this much came in */
@@ -290,14 +290,13 @@ static inline void lego_usb_tower_debug_data(struct device *dev, · 93 unmodified lines
290290 */
291291 static inline void tower_delete (struct lego_usb_tower *dev)
292292 {
293− tower_abort_transfers (dev);
294−
295293 /* free data structures */
296294 usb_free_urb(dev->interrupt_in_urb);
297295 usb_free_urb(dev->interrupt_out_urb);
298296 kfree (dev->read_buffer);
299297 kfree (dev->interrupt_in_buffer);
300298 kfree (dev->interrupt_out_buffer);
299+ usb_put_dev(dev->udev);
301300 kfree (dev);
302301 }
303302
@@ -332,18 +331,14 @@ static int tower_open (struct inode *inode, struct file *file) · 28 unmodified lines
332331 goto exit;
333332 }
334333
335− mutex_lock(&open_disc_mutex);
336334 dev = usb_get_intfdata(interface);
337−
338335 if (!dev) {
339− mutex_unlock(&open_disc_mutex);
340336 retval = -ENODEV;
341337 goto exit;
342338 }
343339
344340 /* lock this device */
345341 if (mutex_lock_interruptible(&dev->lock)) {
346− mutex_unlock(&open_disc_mutex);
347342 retval = -ERESTARTSYS;
348343 goto exit;
349344 }
@@ -351,12 +346,9 @@ static int tower_open (struct inode *inode, struct file *file) · 1 unmodified line
351346
352347 /* allow opening only once */
353348 if (dev->open_count) {
354− mutex_unlock(&open_disc_mutex);
355349 retval = -EBUSY;
356350 goto unlock_exit;
357351 }
358− dev->open_count = 1;
359− mutex_unlock(&open_disc_mutex);
360352
361353 /* reset the tower */
362354 result = usb_control_msg (dev->udev,
@@ -396,13 +388,14 @@ static int tower_open (struct inode *inode, struct file *file) · 33 unmodified lines
396388 dev_err(&dev->udev->dev,
397389 "Couldn't submit interrupt_in_urb %d\n", retval);
398390 dev->interrupt_in_running = 0;
399− dev->open_count = 0;
400391 goto unlock_exit;
401392 }
402393
403394 /* save device in the file's private structure */
404395 file->private_data = dev;
405396
397+ dev->open_count = 1;
398+
406399 unlock_exit:
407400 mutex_unlock(&dev->lock);
408401
@@ -423,10 +416,9 @@ static int tower_release (struct inode *inode, struct file *file) · 14 unmodified lines
423416
424417 if (dev == NULL) {
425418 retval = -ENODEV;
426− goto exit_nolock;
419+ goto exit;
427420 }
428421
429− mutex_lock(&open_disc_mutex);
430422 if (mutex_lock_interruptible(&dev->lock)) {
431423 retval = -ERESTARTSYS;
432424 goto exit;
@@ -438,7 +430,8 @@ static int tower_release (struct inode *inode, struct file *file) · 5 unmodified lines
438430 retval = -ENODEV;
439431 goto unlock_exit;
440432 }
441− if (dev->udev == NULL) {
433+
434+ if (dev->disconnected) {
442435 /* the device was unplugged before the file was released */
443436
444437 /* unlock here as tower_delete frees dev */
@@ -456,10 +449,7 @@ static int tower_release (struct inode *inode, struct file *file) · 11 unmodified lines
456449
457450 unlock_exit:
458451 mutex_unlock(&dev->lock);
459−
460452 exit:
461− mutex_unlock(&open_disc_mutex);
462−exit_nolock:
463453 return retval;
464454 }
465455
@@ -477,10 +467,9 @@ static void tower_abort_transfers (struct lego_usb_tower *dev) · 11 unmodified lines
477467 if (dev->interrupt_in_running) {
478468 dev->interrupt_in_running = 0;
479469 mb();
480− if (dev->udev)
481− usb_kill_urb (dev->interrupt_in_urb);
470+ usb_kill_urb(dev->interrupt_in_urb);
482471 }
483− if (dev->interrupt_out_busy && dev->udev)
472+ if (dev->interrupt_out_busy)
484473 usb_kill_urb(dev->interrupt_out_urb);
485474 }
486475
@@ -516,7 +505,7 @@ static __poll_t tower_poll (struct file *file, poll_table *wait) · 29 unmodified lines
516505
517506 dev = file->private_data;
518507
519− if (!dev->udev)
508+ if (dev->disconnected)
520509 return EPOLLERR | EPOLLHUP;
521510
522511 poll_wait(file, &dev->read_wait, wait);
@@ -563,7 +552,7 @@ static ssize_t tower_read (struct file *file, char __user *buffer, size_t count, · 40 unmodified lines
563552 }
564553
565554 /* verify that the device wasn't unplugged */
566− if (dev->udev == NULL) {
555+ if (dev->disconnected) {
567556 retval = -ENODEV;
568557 pr_err("No device or device unplugged %d\n", retval);
569558 goto unlock_exit;
@@ -649,7 +638,7 @@ static ssize_t tower_write (struct file *file, const char __user *buffer, size_t · 79 unmodified lines
649638 }
650639
651640 /* verify that the device wasn't unplugged */
652− if (dev->udev == NULL) {
641+ if (dev->disconnected) {
653642 retval = -ENODEV;
654643 pr_err("No device or device unplugged %d\n", retval);
655644 goto unlock_exit;
@@ -759,7 +748,7 @@ static void tower_interrupt_in_callback (struct urb *urb) · 103 unmodified lines
759748
760749 resubmit:
761750 /* resubmit if we're still running */
762− if (dev->interrupt_in_running && dev->udev) {
751+ if (dev->interrupt_in_running) {
763752 retval = usb_submit_urb (dev->interrupt_in_urb, GFP_ATOMIC);
764753 if (retval)
765754 dev_err(&dev->udev->dev,
@@ -822,8 +811,9 @@ static int tower_probe (struct usb_interface *interface, const struct usb_device · 56 unmodified lines
822811
823812 mutex_init(&dev->lock);
824813
825− dev->udev = udev;
814+ dev->udev = usb_get_dev(udev);
826815 dev->open_count = 0;
816+ dev->disconnected = 0;
827817
828818 dev->read_buffer = NULL;
829819 dev->read_buffer_length = 0;
@@ -891,8 +881,10 @@ static int tower_probe (struct usb_interface *interface, const struct usb_device · 61 unmodified lines
891881 get_version_reply,
892882 sizeof(*get_version_reply),
893883 1000);
894− if (result < 0) {
895− dev_err(idev, "LEGO USB Tower get version control request failed\n");
884+ if (result < sizeof(*get_version_reply)) {
885+ if (result >= 0)
886+ result = -EIO;
887+ dev_err(idev, "get version request failed: %d\n", result);
896888 retval = result;
897889 goto error;
898890 }
@@ -910,7 +902,6 @@ static int tower_probe (struct usb_interface *interface, const struct usb_device · 11 unmodified lines
910902 if (retval) {
911903 /* something prevented us from registering this driver */
912904 dev_err(idev, "Not able to get a minor for this device.\n");
913− usb_set_intfdata (interface, NULL);
914905 goto error;
915906 }
916907 dev->minor = interface->minor;
@@ -942,23 +933,24 @@ static void tower_disconnect (struct usb_interface *interface) · 25 unmodified lines
942933 int minor;
943934
944935 dev = usb_get_intfdata (interface);
945− mutex_lock(&open_disc_mutex);
946− usb_set_intfdata (interface, NULL);
947936
948937 minor = dev->minor;
949938
950− /* give back our minor */
939+ /* give back our minor and prevent further open() */
951940 usb_deregister_dev (interface, &tower_class);
952941
942+ /* stop I/O */
943+ usb_poison_urb(dev->interrupt_in_urb);
944+ usb_poison_urb(dev->interrupt_out_urb);
945+
953946 mutex_lock(&dev->lock);
954− mutex_unlock(&open_disc_mutex);
955947
956948 /* if the device is not opened, then we clean up right now */
957949 if (!dev->open_count) {
958950 mutex_unlock(&dev->lock);
959951 tower_delete (dev);
960952 } else {
961− dev->udev = NULL;
953+ dev->disconnected = 1;
962954 /* wake up pollers */
963955 wake_up_interruptible_all(&dev->read_wait);
964956 wake_up_interruptible_all(&dev->write_wait);
drivers/usb/misc/rio500.c+0−554
@@ -1,554 +0,0 @@
1−// SPDX-License-Identifier: GPL-2.0+
2−/* -*- linux-c -*- */
3−
4−/*
5− * Driver for USB Rio 500
6− *
7− * Cesar Miquel (miquel@df.uba.ar)
8− *
9− * based on hp_scanner.c by David E. Nelson (dnelson@jump.net)
10− *
11− * Based upon mouse.c (Brad Keryan) and printer.c (Michael Gee).
12− *
13− * Changelog:
14− * 30/05/2003 replaced lock/unlock kernel with up/down
15− * Daniele Bellucci bellucda@tiscali.it
16− * */
17−
18−#include <linux/module.h>
19−#include <linux/kernel.h>
20−#include <linux/signal.h>
21−#include <linux/sched/signal.h>
22−#include <linux/mutex.h>
23−#include <linux/errno.h>
24−#include <linux/random.h>
25−#include <linux/poll.h>
26−#include <linux/slab.h>
27−#include <linux/spinlock.h>
28−#include <linux/usb.h>
29−#include <linux/wait.h>
30−
31−#include "rio500_usb.h"
32−
33−#define DRIVER_AUTHOR "Cesar Miquel <miquel@df.uba.ar>"
34−#define DRIVER_DESC "USB Rio 500 driver"
35−
36−#define RIO_MINOR 64
37−
38−/* stall/wait timeout for rio */
39−#define NAK_TIMEOUT (HZ)
40−
41−#define IBUF_SIZE 0x1000
42−
43−/* Size of the rio buffer */
44−#define OBUF_SIZE 0x10000
45−
46−struct rio_usb_data {
47− struct usb_device *rio_dev; /* init: probe_rio */
48− unsigned int ifnum; /* Interface number of the USB device */
49− int isopen; /* nz if open */
50− int present; /* Device is present on the bus */
51− char *obuf, *ibuf; /* transfer buffers */
52− char bulk_in_ep, bulk_out_ep; /* Endpoint assignments */
53− wait_queue_head_t wait_q; /* for timeouts */
54−};
55−
56−static DEFINE_MUTEX(rio500_mutex);
57−static struct rio_usb_data rio_instance;
58−
59−static int open_rio(struct inode *inode, struct file *file)
60−{
61− struct rio_usb_data *rio = &rio_instance;
62−
63− /* against disconnect() */
64− mutex_lock(&rio500_mutex);
65−
66− if (rio->isopen || !rio->present) {
67− mutex_unlock(&rio500_mutex);
68− return -EBUSY;
69− }
70− rio->isopen = 1;
71−
72− init_waitqueue_head(&rio->wait_q);
73−
74−
75− dev_info(&rio->rio_dev->dev, "Rio opened.\n");
76− mutex_unlock(&rio500_mutex);
77−
78− return 0;
79−}
80−
81−static int close_rio(struct inode *inode, struct file *file)
82−{
83− struct rio_usb_data *rio = &rio_instance;
84−
85− /* against disconnect() */
86− mutex_lock(&rio500_mutex);
87−
88− rio->isopen = 0;
89− if (!rio->present) {
90− /* cleanup has been delayed */
91− kfree(rio->ibuf);
92− kfree(rio->obuf);
93− rio->ibuf = NULL;
94− rio->obuf = NULL;
95− } else {
96− dev_info(&rio->rio_dev->dev, "Rio closed.\n");
97− }
98− mutex_unlock(&rio500_mutex);
99− return 0;
100−}
101−
102−static long ioctl_rio(struct file *file, unsigned int cmd, unsigned long arg)
103−{
104− struct RioCommand rio_cmd;
105− struct rio_usb_data *rio = &rio_instance;
106− void __user *data;
107− unsigned char *buffer;
108− int result, requesttype;
109− int retries;
110− int retval=0;
111−
112− mutex_lock(&rio500_mutex);
113− /* Sanity check to make sure rio is connected, powered, etc */
114− if (rio->present == 0 || rio->rio_dev == NULL) {
115− retval = -ENODEV;
116− goto err_out;
117− }
118−
119− switch (cmd) {
120− case RIO_RECV_COMMAND:
121− data = (void __user *) arg;
122− if (data == NULL)
123− break;
124− if (copy_from_user(&rio_cmd, data, sizeof(struct RioCommand))) {
125− retval = -EFAULT;
126− goto err_out;
127− }
128− if (rio_cmd.length < 0 || rio_cmd.length > PAGE_SIZE) {
129− retval = -EINVAL;
130− goto err_out;
131− }
132− buffer = (unsigned char *) __get_free_page(GFP_KERNEL);
133− if (buffer == NULL) {
134− retval = -ENOMEM;
135− goto err_out;
136− }
137− if (copy_from_user(buffer, rio_cmd.buffer, rio_cmd.length)) {
138− retval = -EFAULT;
139− free_page((unsigned long) buffer);
140− goto err_out;
141− }
142−
143− requesttype = rio_cmd.requesttype | USB_DIR_IN |
144− USB_TYPE_VENDOR | USB_RECIP_DEVICE;
145− dev_dbg(&rio->rio_dev->dev,
146− "sending command:reqtype=%0x req=%0x value=%0x index=%0x len=%0x\n",
147− requesttype, rio_cmd.request, rio_cmd.value,
148− rio_cmd.index, rio_cmd.length);
149− /* Send rio control message */
150− retries = 3;
151− while (retries) {
152− result = usb_control_msg(rio->rio_dev,
153− usb_rcvctrlpipe(rio-> rio_dev, 0),
154− rio_cmd.request,
155− requesttype,
156− rio_cmd.value,
157− rio_cmd.index, buffer,
158− rio_cmd.length,
159− jiffies_to_msecs(rio_cmd.timeout));
160− if (result == -ETIMEDOUT)
161− retries--;
162− else if (result < 0) {
163− dev_err(&rio->rio_dev->dev,
164− "Error executing ioctrl. code = %d\n",
165− result);
166− retries = 0;
167− } else {
168− dev_dbg(&rio->rio_dev->dev,
169− "Executed ioctl. Result = %d (data=%02x)\n",
170− result, buffer[0]);
171− if (copy_to_user(rio_cmd.buffer, buffer,
172− rio_cmd.length)) {
173− free_page((unsigned long) buffer);
174− retval = -EFAULT;
175− goto err_out;
176− }
177− retries = 0;
178− }
179−
180− /* rio_cmd.buffer contains a raw stream of single byte
181− data which has been returned from rio. Data is
182− interpreted at application level. For data that
183− will be cast to data types longer than 1 byte, data
184− will be little_endian and will potentially need to
185− be swapped at the app level */
186−
187− }
188− free_page((unsigned long) buffer);
189− break;
190−
191− case RIO_SEND_COMMAND:
192− data = (void __user *) arg;
193− if (data == NULL)
194− break;
195− if (copy_from_user(&rio_cmd, data, sizeof(struct RioCommand))) {
196− retval = -EFAULT;
197− goto err_out;
198− }
199− if (rio_cmd.length < 0 || rio_cmd.length > PAGE_SIZE) {
200− retval = -EINVAL;
201− goto err_out;
202− }
203− buffer = (unsigned char *) __get_free_page(GFP_KERNEL);
204− if (buffer == NULL) {
205− retval = -ENOMEM;
206− goto err_out;
207− }
208− if (copy_from_user(buffer, rio_cmd.buffer, rio_cmd.length)) {
209− free_page((unsigned long)buffer);
210− retval = -EFAULT;
211− goto err_out;
212− }
213−
214− requesttype = rio_cmd.requesttype | USB_DIR_OUT |
215− USB_TYPE_VENDOR | USB_RECIP_DEVICE;
216− dev_dbg(&rio->rio_dev->dev,
217− "sending command: reqtype=%0x req=%0x value=%0x index=%0x len=%0x\n",
218− requesttype, rio_cmd.request, rio_cmd.value,
219− rio_cmd.index, rio_cmd.length);
220− /* Send rio control message */
221− retries = 3;
222− while (retries) {
223− result = usb_control_msg(rio->rio_dev,
224− usb_sndctrlpipe(rio-> rio_dev, 0),
225− rio_cmd.request,
226− requesttype,
227− rio_cmd.value,
228− rio_cmd.index, buffer,
229− rio_cmd.length,
230− jiffies_to_msecs(rio_cmd.timeout));
231− if (result == -ETIMEDOUT)
232− retries--;
233− else if (result < 0) {
234− dev_err(&rio->rio_dev->dev,
235− "Error executing ioctrl. code = %d\n",
236− result);
237− retries = 0;
238− } else {
239− dev_dbg(&rio->rio_dev->dev,
240− "Executed ioctl. Result = %d\n", result);
241− retries = 0;
242−
243− }
244−
245− }
246− free_page((unsigned long) buffer);
247− break;
248−
249− default:
250− retval = -ENOTTY;
251− break;
252− }
253−
254−
255−err_out:
256− mutex_unlock(&rio500_mutex);
257− return retval;
258−}
259−
260−static ssize_t
261−write_rio(struct file *file, const char __user *buffer,
262− size_t count, loff_t * ppos)
263−{
264− DEFINE_WAIT(wait);
265− struct rio_usb_data *rio = &rio_instance;
266−
267− unsigned long copy_size;
268− unsigned long bytes_written = 0;
269− unsigned int partial;
270−
271− int result = 0;
272− int maxretry;
273− int errn = 0;
274− int intr;
275−
276− intr = mutex_lock_interruptible(&rio500_mutex);
277− if (intr)
278− return -EINTR;
279− /* Sanity check to make sure rio is connected, powered, etc */
280− if (rio->present == 0 || rio->rio_dev == NULL) {
281− mutex_unlock(&rio500_mutex);
282− return -ENODEV;
283− }
284−
285−
286−
287− do {
288− unsigned long thistime;
289− char *obuf = rio->obuf;
290−
291− thistime = copy_size =
292− (count >= OBUF_SIZE) ? OBUF_SIZE : count;
293− if (copy_from_user(rio->obuf, buffer, copy_size)) {
294− errn = -EFAULT;
295− goto error;
296− }
297− maxretry = 5;
298− while (thistime) {
299− if (!rio->rio_dev) {
300− errn = -ENODEV;
301− goto error;
302− }
303− if (signal_pending(current)) {
304− mutex_unlock(&rio500_mutex);
305− return bytes_written ? bytes_written : -EINTR;
306− }
307−
308− result = usb_bulk_msg(rio->rio_dev,
309− usb_sndbulkpipe(rio->rio_dev, 2),
310− obuf, thistime, &partial, 5000);
311−
312− dev_dbg(&rio->rio_dev->dev,
313− "write stats: result:%d thistime:%lu partial:%u\n",
314− result, thistime, partial);
315−
316− if (result == -ETIMEDOUT) { /* NAK - so hold for a while */
317− if (!maxretry--) {
318− errn = -ETIME;
319− goto error;
320− }
321− prepare_to_wait(&rio->wait_q, &wait, TASK_INTERRUPTIBLE);
322− schedule_timeout(NAK_TIMEOUT);
323− finish_wait(&rio->wait_q, &wait);
324− continue;
325− } else if (!result && partial) {
326− obuf += partial;
327− thistime -= partial;
328− } else
329− break;
330− }
331− if (result) {
332− dev_err(&rio->rio_dev->dev, "Write Whoops - %x\n",
333− result);
334− errn = -EIO;
335− goto error;
336− }
337− bytes_written += copy_size;
338− count -= copy_size;
339− buffer += copy_size;
340− } while (count > 0);
341−
342− mutex_unlock(&rio500_mutex);
343−
344− return bytes_written ? bytes_written : -EIO;
345−
346−error:
347− mutex_unlock(&rio500_mutex);
348− return errn;
349−}
350−
351−static ssize_t
352−read_rio(struct file *file, char __user *buffer, size_t count, loff_t * ppos)
353−{
354− DEFINE_WAIT(wait);
355− struct rio_usb_data *rio = &rio_instance;
356− ssize_t read_count;
357− unsigned int partial;
358− int this_read;
359− int result;
360− int maxretry = 10;
361− char *ibuf;
362− int intr;
363−
364− intr = mutex_lock_interruptible(&rio500_mutex);
365− if (intr)
366− return -EINTR;
367− /* Sanity check to make sure rio is connected, powered, etc */
368− if (rio->present == 0 || rio->rio_dev == NULL) {
369− mutex_unlock(&rio500_mutex);
370− return -ENODEV;
371− }
372−
373− ibuf = rio->ibuf;
374−
375− read_count = 0;
376−
377−
378− while (count > 0) {
379− if (signal_pending(current)) {
380− mutex_unlock(&rio500_mutex);
381− return read_count ? read_count : -EINTR;
382− }
383− if (!rio->rio_dev) {
384− mutex_unlock(&rio500_mutex);
385− return -ENODEV;
386− }
387− this_read = (count >= IBUF_SIZE) ? IBUF_SIZE : count;
388−
389− result = usb_bulk_msg(rio->rio_dev,
390− usb_rcvbulkpipe(rio->rio_dev, 1),
391− ibuf, this_read, &partial,
392− 8000);
393−
394− dev_dbg(&rio->rio_dev->dev,
395− "read stats: result:%d this_read:%u partial:%u\n",
396− result, this_read, partial);
397−
398− if (partial) {
399− count = this_read = partial;
400− } else if (result == -ETIMEDOUT || result == 15) { /* FIXME: 15 ??? */
401− if (!maxretry--) {
402− mutex_unlock(&rio500_mutex);
403− dev_err(&rio->rio_dev->dev,
404− "read_rio: maxretry timeout\n");
405− return -ETIME;
406− }
407− prepare_to_wait(&rio->wait_q, &wait, TASK_INTERRUPTIBLE);
408− schedule_timeout(NAK_TIMEOUT);
409− finish_wait(&rio->wait_q, &wait);
410− continue;
411− } else if (result != -EREMOTEIO) {
412− mutex_unlock(&rio500_mutex);
413− dev_err(&rio->rio_dev->dev,
414− "Read Whoops - result:%d partial:%u this_read:%u\n",
415− result, partial, this_read);
416− return -EIO;
417− } else {
418− mutex_unlock(&rio500_mutex);
419− return (0);
420− }
421−
422− if (this_read) {
423− if (copy_to_user(buffer, ibuf, this_read)) {
424− mutex_unlock(&rio500_mutex);
425− return -EFAULT;
426− }
427− count -= this_read;
428− read_count += this_read;
429− buffer += this_read;
430− }
431− }
432− mutex_unlock(&rio500_mutex);
433− return read_count;
434−}
435−
436−static const struct file_operations usb_rio_fops = {
437− .owner = THIS_MODULE,
438− .read = read_rio,
439− .write = write_rio,
440− .unlocked_ioctl = ioctl_rio,
441− .open = open_rio,
442− .release = close_rio,
443− .llseek = noop_llseek,
444−};
445−
446−static struct usb_class_driver usb_rio_class = {
447− .name = "rio500%d",
448− .fops = &usb_rio_fops,
449− .minor_base = RIO_MINOR,
450−};
451−
452−static int probe_rio(struct usb_interface *intf,
453− const struct usb_device_id *id)
454−{
455− struct usb_device *dev = interface_to_usbdev(intf);
456− struct rio_usb_data *rio = &rio_instance;
457− int retval = -ENOMEM;
458− char *ibuf, *obuf;
459−
460− if (rio->present) {
461− dev_info(&intf->dev, "Second USB Rio at address %d refused\n", dev->devnum);
462− return -EBUSY;
463− }
464− dev_info(&intf->dev, "USB Rio found at address %d\n", dev->devnum);
465−
466− obuf = kmalloc(OBUF_SIZE, GFP_KERNEL);
467− if (!obuf) {
468− dev_err(&dev->dev,
469− "probe_rio: Not enough memory for the output buffer\n");
470− goto err_obuf;
471− }
472− dev_dbg(&intf->dev, "obuf address: %p\n", obuf);
473−
474− ibuf = kmalloc(IBUF_SIZE, GFP_KERNEL);
475− if (!ibuf) {
476− dev_err(&dev->dev,
477− "probe_rio: Not enough memory for the input buffer\n");
478− goto err_ibuf;
479− }
480− dev_dbg(&intf->dev, "ibuf address: %p\n", ibuf);
481−
482− mutex_lock(&rio500_mutex);
483− rio->rio_dev = dev;
484− rio->ibuf = ibuf;
485− rio->obuf = obuf;
486− rio->present = 1;
487− mutex_unlock(&rio500_mutex);
488−
489− retval = usb_register_dev(intf, &usb_rio_class);
490− if (retval) {
491− dev_err(&dev->dev,
492− "Not able to get a minor for this device.\n");
493− goto err_register;
494− }
495−
496− usb_set_intfdata(intf, rio);
497− return retval;
498−
499− err_register:
500− mutex_lock(&rio500_mutex);
501− rio->present = 0;
502− mutex_unlock(&rio500_mutex);
503− err_ibuf:
504− kfree(obuf);
505− err_obuf:
506− return retval;
507−}
508−
509−static void disconnect_rio(struct usb_interface *intf)
510−{
511− struct rio_usb_data *rio = usb_get_intfdata (intf);
512−
513− usb_set_intfdata (intf, NULL);
514− if (rio) {
515− usb_deregister_dev(intf, &usb_rio_class);
516−
517− mutex_lock(&rio500_mutex);
518− if (rio->isopen) {
519− rio->isopen = 0;
520− /* better let it finish - the release will do whats needed */
521− rio->rio_dev = NULL;
522− mutex_unlock(&rio500_mutex);
523− return;
524− }
525− kfree(rio->ibuf);
526− kfree(rio->obuf);
527−
528− dev_info(&intf->dev, "USB Rio disconnected.\n");
529−
530− rio->present = 0;
531− mutex_unlock(&rio500_mutex);
532− }
533−}
534−
535−static const struct usb_device_id rio_table[] = {
536− { USB_DEVICE(0x0841, 1) }, /* Rio 500 */
537− { } /* Terminating entry */
538−};
539−
540−MODULE_DEVICE_TABLE (usb, rio_table);
541−
542−static struct usb_driver rio_driver = {
543− .name = "rio500",
544− .probe = probe_rio,
545− .disconnect = disconnect_rio,
546− .id_table = rio_table,
547−};
548−
549−module_usb_driver(rio_driver);
550−
551−MODULE_AUTHOR( DRIVER_AUTHOR );
552−MODULE_DESCRIPTION( DRIVER_DESC );
553−MODULE_LICENSE("GPL");
554−
drivers/usb/misc/rio500_usb.h+0−20
@@ -1,20 +0,0 @@
1−// SPDX-License-Identifier: GPL-2.0+
2−/* ----------------------------------------------------------------------
3− Copyright (C) 2000 Cesar Miquel (miquel@df.uba.ar)
4− ---------------------------------------------------------------------- */
5−
6−#define RIO_SEND_COMMAND 0x1
7−#define RIO_RECV_COMMAND 0x2
8−
9−#define RIO_DIR_OUT 0x0
10−#define RIO_DIR_IN 0x1
11−
12−struct RioCommand {
13− short length;
14− int request;
15− int requesttype;
16− int value;
17− int index;
18− void __user *buffer;
19− int timeout;
20−};
drivers/usb/misc/usblcd.c+33−27
@@ -18,6 +18,7 @@ · 17 unmodified lines
1818 #include <linux/slab.h>
1919 #include <linux/errno.h>
2020 #include <linux/mutex.h>
21+#include <linux/rwsem.h>
2122 #include <linux/uaccess.h>
2223 #include <linux/usb.h>
2324
@@ -29,16 +30,12 @@ · 5 unmodified lines
2930 #define IOCTL_GET_DRV_VERSION 2
3031
3132
32−static DEFINE_MUTEX(lcd_mutex);
3333 static const struct usb_device_id id_table[] = {
3434 { .idVendor = 0x10D2, .match_flags = USB_DEVICE_ID_MATCH_VENDOR, },
3535 { },
3636 };
3737 MODULE_DEVICE_TABLE(usb, id_table);
3838
39−static DEFINE_MUTEX(open_disc_mutex);
40−
41−
4239 struct usb_lcd {
4340 struct usb_device *udev; /* init: probe_lcd */
4441 struct usb_interface *interface; /* the interface for
@@ -57,6 +54,8 @@ struct usb_lcd { · 12 unmodified lines
5754 using up all RAM */
5855 struct usb_anchor submitted; /* URBs to wait for
5956 before suspend */
57+ struct rw_semaphore io_rwsem;
58+ unsigned long disconnected:1;
6059 };
6160 #define to_lcd_dev(d) container_of(d, struct usb_lcd, kref)
6261
@@ -81,40 +80,29 @@ static int lcd_open(struct inode *inode, struct file *file) · 18 unmodified lines
8180 struct usb_interface *interface;
8281 int subminor, r;
8382
84− mutex_lock(&lcd_mutex);
8583 subminor = iminor(inode);
8684
8785 interface = usb_find_interface(&lcd_driver, subminor);
8886 if (!interface) {
89− mutex_unlock(&lcd_mutex);
90− printk(KERN_ERR "USBLCD: %s - error, can't find device for minor %d\n",
87+ pr_err("USBLCD: %s - error, can't find device for minor %d\n",
9188 __func__, subminor);
9289 return -ENODEV;
9390 }
9491
95− mutex_lock(&open_disc_mutex);
9692 dev = usb_get_intfdata(interface);
97− if (!dev) {
98− mutex_unlock(&open_disc_mutex);
99− mutex_unlock(&lcd_mutex);
100− return -ENODEV;
101− }
10293
10394 /* increment our usage count for the device */
10495 kref_get(&dev->kref);
105− mutex_unlock(&open_disc_mutex);
10696
10797 /* grab a power reference */
10898 r = usb_autopm_get_interface(interface);
10999 if (r < 0) {
110100 kref_put(&dev->kref, lcd_delete);
111− mutex_unlock(&lcd_mutex);
112101 return r;
113102 }
114103
115104 /* save our object in the file's private structure */
116105 file->private_data = dev;
117− mutex_unlock(&lcd_mutex);
118106
119107 return 0;
120108 }
@@ -142,6 +130,13 @@ static ssize_t lcd_read(struct file *file, char __user * buffer, · 21 unmodified lines
142130
143131 dev = file->private_data;
144132
133+ down_read(&dev->io_rwsem);
134+
135+ if (dev->disconnected) {
136+ retval = -ENODEV;
137+ goto out_up_io;
138+ }
139+
145140 /* do a blocking bulk read to get data from the device */
146141 retval = usb_bulk_msg(dev->udev,
147142 usb_rcvbulkpipe(dev->udev,
@@ -158,6 +153,9 @@ static ssize_t lcd_read(struct file *file, char __user * buffer, · 10 unmodified lines
158153 retval = bytes_read;
159154 }
160155
156+out_up_io:
157+ up_read(&dev->io_rwsem);
158+
161159 return retval;
162160 }
163161
@@ -173,14 +171,12 @@ static long lcd_ioctl(struct file *file, unsigned int cmd, unsigned long arg) · 9 unmodified lines
173171
174172 switch (cmd) {
175173 case IOCTL_GET_HARD_VERSION:
176− mutex_lock(&lcd_mutex);
177174 bcdDevice = le16_to_cpu((dev->udev)->descriptor.bcdDevice);
178175 sprintf(buf, "%1d%1d.%1d%1d",
179176 (bcdDevice & 0xF000)>>12,
180177 (bcdDevice & 0xF00)>>8,
181178 (bcdDevice & 0xF0)>>4,
182179 (bcdDevice & 0xF));
183− mutex_unlock(&lcd_mutex);
184180 if (copy_to_user((void __user *)arg, buf, strlen(buf)) != 0)
185181 return -EFAULT;
186182 break;
@@ -237,11 +233,18 @@ static ssize_t lcd_write(struct file *file, const char __user * user_buffer, · 50 unmodified lines
237233 if (r < 0)
238234 return -EINTR;
239235
236+ down_read(&dev->io_rwsem);
237+
238+ if (dev->disconnected) {
239+ retval = -ENODEV;
240+ goto err_up_io;
241+ }
242+
240243 /* create a urb, and a buffer for it, and copy the data to the urb */
241244 urb = usb_alloc_urb(0, GFP_KERNEL);
242245 if (!urb) {
243246 retval = -ENOMEM;
244− goto err_no_buf;
247+ goto err_up_io;
245248 }
246249
247250 buf = usb_alloc_coherent(dev->udev, count, GFP_KERNEL,
@@ -278,6 +281,7 @@ static ssize_t lcd_write(struct file *file, const char __user * user_buffer, · 30 unmodified lines
278281 the USB core will eventually free it entirely */
279282 usb_free_urb(urb);
280283
284+ up_read(&dev->io_rwsem);
281285 exit:
282286 return count;
283287 error_unanchor:
@@ -285,7 +289,8 @@ error_unanchor: · 1 unmodified line
285289 error:
286290 usb_free_coherent(dev->udev, count, buf, urb->transfer_dma);
287291 usb_free_urb(urb);
288−err_no_buf:
292+err_up_io:
293+ up_read(&dev->io_rwsem);
289294 up(&dev->limit_sem);
290295 return retval;
291296 }
@@ -325,6 +330,7 @@ static int lcd_probe(struct usb_interface *interface, · 33 unmodified lines
325330
326331 kref_init(&dev->kref);
327332 sema_init(&dev->limit_sem, USB_LCD_CONCURRENT_WRITES);
333+ init_rwsem(&dev->io_rwsem);
328334 init_usb_anchor(&dev->submitted);
329335
330336 dev->udev = usb_get_dev(interface_to_usbdev(interface));
@@ -365,7 +371,6 @@ static int lcd_probe(struct usb_interface *interface, · 34 unmodified lines
365371 /* something prevented us from registering this driver */
366372 dev_err(&interface->dev,
367373 "Not able to get a minor for this device.\n");
368− usb_set_intfdata(interface, NULL);
369374 goto error;
370375 }
371376
@@ -411,17 +416,18 @@ static int lcd_resume(struct usb_interface *intf) · 39 unmodified lines
411416
412417 static void lcd_disconnect(struct usb_interface *interface)
413418 {
414− struct usb_lcd *dev;
419+ struct usb_lcd *dev = usb_get_intfdata(interface);
415420 int minor = interface->minor;
416421
417− mutex_lock(&open_disc_mutex);
418− dev = usb_get_intfdata(interface);
419− usb_set_intfdata(interface, NULL);
420− mutex_unlock(&open_disc_mutex);
421−
422422 /* give back our minor */
423423 usb_deregister_dev(interface, &lcd_class);
424424
425+ down_write(&dev->io_rwsem);
426+ dev->disconnected = 1;
427+ up_write(&dev->io_rwsem);
428+
429+ usb_kill_anchored_urbs(&dev->submitted);
430+
425431 /* decrement our usage count */
426432 kref_put(&dev->kref, lcd_delete);
427433
drivers/usb/misc/yurex.c+11−7
@@ -60,6 +60,7 @@ struct usb_yurex { · 59 unmodified lines
6060
6161 struct kref kref;
6262 struct mutex io_mutex;
63+ unsigned long disconnected:1;
6364 struct fasync_struct *async_queue;
6465 wait_queue_head_t waitq;
6566
@@ -107,6 +108,7 @@ static void yurex_delete(struct kref *kref) · 41 unmodified lines
107108 dev->int_buffer, dev->urb->transfer_dma);
108109 usb_free_urb(dev->urb);
109110 }
111+ usb_put_intf(dev->interface);
110112 usb_put_dev(dev->udev);
111113 kfree(dev);
112114 }
@@ -132,6 +134,7 @@ static void yurex_interrupt(struct urb *urb) · 19 unmodified lines
132134 switch (status) {
133135 case 0: /*success*/
134136 break;
137+ /* The device is terminated or messed up, give up */
135138 case -EOVERFLOW:
136139 dev_err(&dev->interface->dev,
137140 "%s - overflow with length %d, actual length is %d\n",
@@ -140,12 +143,13 @@ static void yurex_interrupt(struct urb *urb) · 2 unmodified lines
140143 case -ENOENT:
141144 case -ESHUTDOWN:
142145 case -EILSEQ:
143− /* The device is terminated, clean up */
146+ case -EPROTO:
147+ case -ETIME:
144148 return;
145149 default:
146150 dev_err(&dev->interface->dev,
147151 "%s - unknown status received: %d\n", __func__, status);
148− goto exit;
152+ return;
149153 }
150154
151155 /* handle received message */
@@ -177,7 +181,6 @@ static void yurex_interrupt(struct urb *urb) · 25 unmodified lines
177181 break;
178182 }
179183
180−exit:
181184 retval = usb_submit_urb(dev->urb, GFP_ATOMIC);
182185 if (retval) {
183186 dev_err(&dev->interface->dev, "%s - usb_submit_urb failed: %d\n",
@@ -204,7 +207,7 @@ static int yurex_probe(struct usb_interface *interface, const struct usb_device_ · 20 unmodified lines
204207 init_waitqueue_head(&dev->waitq);
205208
206209 dev->udev = usb_get_dev(interface_to_usbdev(interface));
207− dev->interface = interface;
210+ dev->interface = usb_get_intf(interface);
208211
209212 /* set up the endpoint information */
210213 iface_desc = interface->cur_altsetting;
@@ -315,8 +318,9 @@ static void yurex_disconnect(struct usb_interface *interface) · 104 unmodified lines
315318
316319 /* prevent more I/O from starting */
317320 usb_poison_urb(dev->urb);
321+ usb_poison_urb(dev->cntl_urb);
318322 mutex_lock(&dev->io_mutex);
319− dev->interface = NULL;
323+ dev->disconnected = 1;
320324 mutex_unlock(&dev->io_mutex);
321325
322326 /* wakeup waiters */
@@ -404,7 +408,7 @@ static ssize_t yurex_read(struct file *file, char __user *buffer, size_t count, · 81 unmodified lines
404408 dev = file->private_data;
405409
406410 mutex_lock(&dev->io_mutex);
407− if (!dev->interface) { /* already disconnected */
411+ if (dev->disconnected) { /* already disconnected */
408412 mutex_unlock(&dev->io_mutex);
409413 return -ENODEV;
410414 }
@@ -439,7 +443,7 @@ static ssize_t yurex_write(struct file *file, const char __user *user_buffer, · 28 unmodified lines
439443 goto error;
440444
441445 mutex_lock(&dev->io_mutex);
442− if (!dev->interface) { /* already disconnected */
446+ if (dev->disconnected) { /* already disconnected */
443447 mutex_unlock(&dev->io_mutex);
444448 retval = -ENODEV;
445449 goto error;
drivers/usb/renesas_usbhs/common.h+1−0
@@ -211,6 +211,7 @@ struct usbhs_priv; · 210 unmodified lines
211211 /* DCPCTR */
212212 #define BSTS (1 << 15) /* Buffer Status */
213213 #define SUREQ (1 << 14) /* Sending SETUP Token */
214+#define INBUFM (1 << 14) /* (PIPEnCTR) Transfer Buffer Monitor */
214215 #define CSSTS (1 << 12) /* CSSTS Status */
215216 #define ACLRM (1 << 9) /* Buffer Auto-Clear Mode */
216217 #define SQCLR (1 << 8) /* Toggle Bit Clear */
drivers/usb/renesas_usbhs/fifo.c+1−1
@@ -89,7 +89,7 @@ static void __usbhsf_pkt_del(struct usbhs_pkt *pkt) · 88 unmodified lines
8989 list_del_init(&pkt->node);
9090 }
9191
92−static struct usbhs_pkt *__usbhsf_pkt_get(struct usbhs_pipe *pipe)
92+struct usbhs_pkt *__usbhsf_pkt_get(struct usbhs_pipe *pipe)
9393 {
9494 return list_first_entry_or_null(&pipe->list, struct usbhs_pkt, node);
9595 }
drivers/usb/renesas_usbhs/fifo.h+1−0
@@ -97,5 +97,6 @@ void usbhs_pkt_push(struct usbhs_pipe *pipe, struct usbhs_pkt *pkt, · 96 unmodified lines
9797 void *buf, int len, int zero, int sequence);
9898 struct usbhs_pkt *usbhs_pkt_pop(struct usbhs_pipe *pipe, struct usbhs_pkt *pkt);
9999 void usbhs_pkt_start(struct usbhs_pipe *pipe);
100+struct usbhs_pkt *__usbhsf_pkt_get(struct usbhs_pipe *pipe);
100101
101102 #endif /* RENESAS_USB_FIFO_H */
drivers/usb/renesas_usbhs/mod_gadget.c+15−3
@@ -722,8 +722,7 @@ static int __usbhsg_ep_set_halt_wedge(struct usb_ep *ep, int halt, int wedge) · 721 unmodified lines
722722 struct usbhs_priv *priv = usbhsg_gpriv_to_priv(gpriv);
723723 struct device *dev = usbhsg_gpriv_to_dev(gpriv);
724724 unsigned long flags;
725−
726− usbhsg_pipe_disable(uep);
725+ int ret = 0;
727726
728727 dev_dbg(dev, "set halt %d (pipe %d)\n",
729728 halt, usbhs_pipe_number(pipe));
@@ -731,6 +730,18 @@ static int __usbhsg_ep_set_halt_wedge(struct usb_ep *ep, int halt, int wedge) · 1 unmodified line
731730 /******************** spin lock ********************/
732731 usbhs_lock(priv, flags);
733732
733+ /*
734+ * According to usb_ep_set_halt()'s description, this function should
735+ * return -EAGAIN if the IN endpoint has any queue or data. Note
736+ * that the usbhs_pipe_is_dir_in() returns false if the pipe is an
737+ * IN endpoint in the gadget mode.
738+ */
739+ if (!usbhs_pipe_is_dir_in(pipe) && (__usbhsf_pkt_get(pipe) ||
740+ usbhs_pipe_contains_transmittable_data(pipe))) {
741+ ret = -EAGAIN;
742+ goto out;
743+ }
744+
734745 if (halt)
735746 usbhs_pipe_stall(pipe);
736747 else
@@ -741,10 +752,11 @@ static int __usbhsg_ep_set_halt_wedge(struct usb_ep *ep, int halt, int wedge) · 4 unmodified lines
741752 else
742753 usbhsg_status_clr(gpriv, USBHSG_STATUS_WEDGE);
743754
755+out:
744756 usbhs_unlock(priv, flags);
745757 /******************** spin unlock ******************/
746758
747− return 0;
759+ return ret;
748760 }
749761
750762 static int usbhsg_ep_set_halt(struct usb_ep *ep, int value)
drivers/usb/renesas_usbhs/pipe.c+15−0
@@ -277,6 +277,21 @@ int usbhs_pipe_is_accessible(struct usbhs_pipe *pipe) · 276 unmodified lines
277277 return -EBUSY;
278278 }
279279
280+bool usbhs_pipe_contains_transmittable_data(struct usbhs_pipe *pipe)
281+{
282+ u16 val;
283+
284+ /* Do not support for DCP pipe */
285+ if (usbhs_pipe_is_dcp(pipe))
286+ return false;
287+
288+ val = usbhsp_pipectrl_get(pipe);
289+ if (val & INBUFM)
290+ return true;
291+
292+ return false;
293+}
294+
280295 /*
281296 * PID ctrl
282297 */
drivers/usb/renesas_usbhs/pipe.h+1−0
@@ -83,6 +83,7 @@ void usbhs_pipe_clear(struct usbhs_pipe *pipe); · 82 unmodified lines
8383 void usbhs_pipe_clear_without_sequence(struct usbhs_pipe *pipe,
8484 int needs_bfre, int bfre_enable);
8585 int usbhs_pipe_is_accessible(struct usbhs_pipe *pipe);
86+bool usbhs_pipe_contains_transmittable_data(struct usbhs_pipe *pipe);
8687 void usbhs_pipe_enable(struct usbhs_pipe *pipe);
8788 void usbhs_pipe_disable(struct usbhs_pipe *pipe);
8889 void usbhs_pipe_stall(struct usbhs_pipe *pipe);
drivers/usb/serial/ftdi_sio.c+3−0
@@ -1030,6 +1030,9 @@ static const struct usb_device_id id_table_combined[] = { · 1029 unmodified lines
10301030 /* EZPrototypes devices */
10311031 { USB_DEVICE(EZPROTOTYPES_VID, HJELMSLUND_USB485_ISO_PID) },
10321032 { USB_DEVICE_INTERFACE_NUMBER(UNJO_VID, UNJO_ISODEBUG_V1_PID, 1) },
1033+ /* Sienna devices */
1034+ { USB_DEVICE(FTDI_VID, FTDI_SIENNA_PID) },
1035+ { USB_DEVICE(ECHELON_VID, ECHELON_U20_PID) },
10331036 { } /* Terminating entry */
10341037 };
10351038
drivers/usb/serial/ftdi_sio_ids.h+9−0
@@ -39,6 +39,9 @@ · 38 unmodified lines
3939
4040 #define FTDI_LUMEL_PD12_PID 0x6002
4141
42+/* Sienna Serial Interface by Secyourit GmbH */
43+#define FTDI_SIENNA_PID 0x8348
44+
4245 /* Cyber Cortex AV by Fabulous Silicon (http://fabuloussilicon.com) */
4346 #define CYBER_CORTEX_AV_PID 0x8698
4447
@@ -688,6 +691,12 @@ · 643 unmodified lines
688691 #define BANDB_TTL3USB9M_PID 0xAC50
689692 #define BANDB_ZZ_PROG1_USB_PID 0xBA02
690693
694+/*
695+ * Echelon USB Serial Interface
696+ */
697+#define ECHELON_VID 0x0920
698+#define ECHELON_U20_PID 0x7500
699+
691700 /*
692701 * Intrepid Control Systems (http://www.intrepidcs.com/) ValueCAN and NeoVI
693702 */
drivers/usb/serial/keyspan.c+2−2
@@ -1741,8 +1741,8 @@ static struct urb *keyspan_setup_urb(struct usb_serial *serial, int endpoint, · 1740 unmodified lines
17411741
17421742 ep_desc = find_ep(serial, endpoint);
17431743 if (!ep_desc) {
1744− /* leak the urb, something's wrong and the callers don't care */
1745− return urb;
1744+ usb_free_urb(urb);
1745+ return NULL;
17461746 }
17471747 if (usb_endpoint_xfer_int(ep_desc)) {
17481748 ep_type_name = "INT";
drivers/usb/serial/option.c+11−0
@@ -419,6 +419,7 @@ static void option_instat_callback(struct urb *urb); · 418 unmodified lines
419419 #define CINTERION_PRODUCT_PH8_AUDIO 0x0083
420420 #define CINTERION_PRODUCT_AHXX_2RMNET 0x0084
421421 #define CINTERION_PRODUCT_AHXX_AUDIO 0x0085
422+#define CINTERION_PRODUCT_CLS8 0x00b0
422423
423424 /* Olivetti products */
424425 #define OLIVETTI_VENDOR_ID 0x0b3c
@@ -1154,6 +1155,14 @@ static const struct usb_device_id option_ids[] = { · 729 unmodified lines
11541155 .driver_info = NCTRL(0) | RSVD(1) | RSVD(2) | RSVD(3) },
11551156 { USB_DEVICE_INTERFACE_CLASS(TELIT_VENDOR_ID, TELIT_PRODUCT_LE922_USBCFG5, 0xff),
11561157 .driver_info = RSVD(0) | RSVD(1) | NCTRL(2) | RSVD(3) },
1158+ { USB_DEVICE_INTERFACE_CLASS(TELIT_VENDOR_ID, 0x1050, 0xff), /* Telit FN980 (rmnet) */
1159+ .driver_info = NCTRL(0) | RSVD(1) | RSVD(2) },
1160+ { USB_DEVICE_INTERFACE_CLASS(TELIT_VENDOR_ID, 0x1051, 0xff), /* Telit FN980 (MBIM) */
1161+ .driver_info = NCTRL(0) | RSVD(1) },
1162+ { USB_DEVICE_INTERFACE_CLASS(TELIT_VENDOR_ID, 0x1052, 0xff), /* Telit FN980 (RNDIS) */
1163+ .driver_info = NCTRL(2) | RSVD(3) },
1164+ { USB_DEVICE_INTERFACE_CLASS(TELIT_VENDOR_ID, 0x1053, 0xff), /* Telit FN980 (ECM) */
1165+ .driver_info = NCTRL(0) | RSVD(1) },
11571166 { USB_DEVICE(TELIT_VENDOR_ID, TELIT_PRODUCT_ME910),
11581167 .driver_info = NCTRL(0) | RSVD(1) | RSVD(3) },
11591168 { USB_DEVICE(TELIT_VENDOR_ID, TELIT_PRODUCT_ME910_DUAL_MODEM),
@@ -1847,6 +1856,8 @@ static const struct usb_device_id option_ids[] = { · 687 unmodified lines
18471856 .driver_info = RSVD(4) },
18481857 { USB_DEVICE_INTERFACE_CLASS(CINTERION_VENDOR_ID, CINTERION_PRODUCT_AHXX_2RMNET, 0xff) },
18491858 { USB_DEVICE_INTERFACE_CLASS(CINTERION_VENDOR_ID, CINTERION_PRODUCT_AHXX_AUDIO, 0xff) },
1859+ { USB_DEVICE_INTERFACE_CLASS(CINTERION_VENDOR_ID, CINTERION_PRODUCT_CLS8, 0xff),
1860+ .driver_info = RSVD(0) | RSVD(4) },
18501861 { USB_DEVICE(CINTERION_VENDOR_ID, CINTERION_PRODUCT_HC28_MDM) },
18511862 { USB_DEVICE(CINTERION_VENDOR_ID, CINTERION_PRODUCT_HC28_MDMNET) },
18521863 { USB_DEVICE(SIEMENS_VENDOR_ID, CINTERION_PRODUCT_HC25_MDM) },
drivers/usb/serial/usb-serial.c+1−4
@@ -314,10 +314,7 @@ static void serial_cleanup(struct tty_struct *tty) · 313 unmodified lines
314314 serial = port->serial;
315315 owner = serial->type->driver.owner;
316316
317− mutex_lock(&serial->disc_mutex);
318− if (!serial->disconnected)
319− usb_autopm_put_interface(serial->interface);
320− mutex_unlock(&serial->disc_mutex);
317+ usb_autopm_put_interface(serial->interface);
321318
322319 usb_serial_put(serial);
323320 module_put(owner);
drivers/usb/typec/tcpm/tcpm.c+8−6
@@ -4409,18 +4409,20 @@ static int tcpm_fw_get_caps(struct tcpm_port *port, · 4408 unmodified lines
44094409 /* USB data support is optional */
44104410 ret = fwnode_property_read_string(fwnode, "data-role", &cap_str);
44114411 if (ret == 0) {
4412− port->typec_caps.data = typec_find_port_data_role(cap_str);
4413− if (port->typec_caps.data < 0)
4414− return -EINVAL;
4412+ ret = typec_find_port_data_role(cap_str);
4413+ if (ret < 0)
4414+ return ret;
4415+ port->typec_caps.data = ret;
44154416 }
44164417
44174418 ret = fwnode_property_read_string(fwnode, "power-role", &cap_str);
44184419 if (ret < 0)
44194420 return ret;
44204421
4421− port->typec_caps.type = typec_find_port_power_role(cap_str);
4422− if (port->typec_caps.type < 0)
4423− return -EINVAL;
4422+ ret = typec_find_port_power_role(cap_str);
4423+ if (ret < 0)
4424+ return ret;
4425+ port->typec_caps.type = ret;
44244426 port->port_type = port->typec_caps.type;
44254427
44264428 if (port->port_type == TYPEC_PORT_SNK)
drivers/usb/typec/ucsi/displayport.c+2−0
@@ -75,6 +75,8 @@ static int ucsi_displayport_enter(struct typec_altmode *alt) · 74 unmodified lines
7575
7676 if (cur != 0xff) {
7777 mutex_unlock(&dp->con->lock);
78+ if (dp->con->port_altmode[cur] == alt)
79+ return 0;
7880 return -EBUSY;
7981 }
8082
drivers/usb/typec/ucsi/ucsi_ccg.c+4−38
@@ -195,7 +195,6 @@ struct ucsi_ccg { · 194 unmodified lines
195195
196196 /* fw build with vendor information */
197197 u16 fw_build;
198− bool run_isr; /* flag to call ISR routine during resume */
199198 struct work_struct pm_work;
200199 };
201200
@@ -224,18 +223,6 @@ static int ccg_read(struct ucsi_ccg *uc, u16 rab, u8 *data, u32 len) · 22 unmodified lines
224223 if (quirks && quirks->max_read_len)
225224 max_read_len = quirks->max_read_len;
226225
227− if (uc->fw_build == CCG_FW_BUILD_NVIDIA &&
228− uc->fw_version <= CCG_OLD_FW_VERSION) {
229− mutex_lock(&uc->lock);
230− /*
231− * Do not schedule pm_work to run ISR in
232− * ucsi_ccg_runtime_resume() after pm_runtime_get_sync()
233− * since we are already in ISR path.
234− */
235− uc->run_isr = false;
236− mutex_unlock(&uc->lock);
237− }
238−
239226 pm_runtime_get_sync(uc->dev);
240227 while (rem_len > 0) {
241228 msgs[1].buf = &data[len - rem_len];
@@ -278,18 +265,6 @@ static int ccg_write(struct ucsi_ccg *uc, u16 rab, u8 *data, u32 len) · 36 unmodified lines
278265 msgs[0].len = len + sizeof(rab);
279266 msgs[0].buf = buf;
280267
281− if (uc->fw_build == CCG_FW_BUILD_NVIDIA &&
282− uc->fw_version <= CCG_OLD_FW_VERSION) {
283− mutex_lock(&uc->lock);
284− /*
285− * Do not schedule pm_work to run ISR in
286− * ucsi_ccg_runtime_resume() after pm_runtime_get_sync()
287− * since we are already in ISR path.
288− */
289− uc->run_isr = false;
290− mutex_unlock(&uc->lock);
291− }
292−
293268 pm_runtime_get_sync(uc->dev);
294269 status = i2c_transfer(client->adapter, msgs, ARRAY_SIZE(msgs));
295270 if (status < 0) {
@@ -1130,7 +1105,6 @@ static int ucsi_ccg_probe(struct i2c_client *client, · 834 unmodified lines
11301105 uc->ppm.sync = ucsi_ccg_sync;
11311106 uc->dev = dev;
11321107 uc->client = client;
1133− uc->run_isr = true;
11341108 mutex_init(&uc->lock);
11351109 INIT_WORK(&uc->work, ccg_update_firmware);
11361110 INIT_WORK(&uc->pm_work, ccg_pm_workaround_work);
@@ -1188,6 +1162,8 @@ static int ucsi_ccg_probe(struct i2c_client *client, · 51 unmodified lines
11881162
11891163 pm_runtime_set_active(uc->dev);
11901164 pm_runtime_enable(uc->dev);
1165+ pm_runtime_use_autosuspend(uc->dev);
1166+ pm_runtime_set_autosuspend_delay(uc->dev, 5000);
11911167 pm_runtime_idle(uc->dev);
11921168
11931169 return 0;
@@ -1229,7 +1205,6 @@ static int ucsi_ccg_runtime_resume(struct device *dev) · 35 unmodified lines
12291205 {
12301206 struct i2c_client *client = to_i2c_client(dev);
12311207 struct ucsi_ccg *uc = i2c_get_clientdata(client);
1232− bool schedule = true;
12331208
12341209 /*
12351210 * Firmware version 3.1.10 or earlier, built for NVIDIA has known issue
@@ -1237,17 +1212,8 @@ static int ucsi_ccg_runtime_resume(struct device *dev) · 1 unmodified line
12371212 * Schedule a work to call ISR as a workaround.
12381213 */
12391214 if (uc->fw_build == CCG_FW_BUILD_NVIDIA &&
1240− uc->fw_version <= CCG_OLD_FW_VERSION) {
1241− mutex_lock(&uc->lock);
1242− if (!uc->run_isr) {
1243− uc->run_isr = true;
1244− schedule = false;
1245− }
1246− mutex_unlock(&uc->lock);
1247−
1248− if (schedule)
1249− schedule_work(&uc->pm_work);
1250− }
1215+ uc->fw_version <= CCG_OLD_FW_VERSION)
1216+ schedule_work(&uc->pm_work);
12511217
12521218 return 0;
12531219 }
drivers/usb/usb-skeleton.c+9−10
@@ -61,6 +61,7 @@ struct usb_skel { · 60 unmodified lines
6161 spinlock_t err_lock; /* lock for errors */
6262 struct kref kref;
6363 struct mutex io_mutex; /* synchronize I/O with disconnect */
64+ unsigned long disconnected:1;
6465 wait_queue_head_t bulk_in_wait; /* to wait for an ongoing read */
6566 };
6667 #define to_skel_dev(d) container_of(d, struct usb_skel, kref)
@@ -73,6 +74,7 @@ static void skel_delete(struct kref *kref) · 6 unmodified lines
7374 struct usb_skel *dev = to_skel_dev(kref);
7475
7576 usb_free_urb(dev->bulk_in_urb);
77+ usb_put_intf(dev->interface);
7678 usb_put_dev(dev->udev);
7779 kfree(dev->bulk_in_buffer);
7880 kfree(dev);
@@ -124,10 +126,7 @@ static int skel_release(struct inode *inode, struct file *file) · 45 unmodified lines
124126 return -ENODEV;
125127
126128 /* allow the device to be autosuspended */
127− mutex_lock(&dev->io_mutex);
128− if (dev->interface)
129− usb_autopm_put_interface(dev->interface);
130− mutex_unlock(&dev->io_mutex);
129+ usb_autopm_put_interface(dev->interface);
131130
132131 /* decrement the count on our device */
133132 kref_put(&dev->kref, skel_delete);
@@ -231,8 +230,7 @@ static ssize_t skel_read(struct file *file, char *buffer, size_t count, · 97 unmodified lines
231230
232231 dev = file->private_data;
233232
234− /* if we cannot read at all, return EOF */
235− if (!dev->bulk_in_urb || !count)
233+ if (!count)
236234 return 0;
237235
238236 /* no concurrent readers */
@@ -240,7 +238,7 @@ static ssize_t skel_read(struct file *file, char *buffer, size_t count, · 1 unmodified line
240238 if (rv < 0)
241239 return rv;
242240
243− if (!dev->interface) { /* disconnect() was called */
241+ if (dev->disconnected) { /* disconnect() was called */
244242 rv = -ENODEV;
245243 goto exit;
246244 }
@@ -422,7 +420,7 @@ static ssize_t skel_write(struct file *file, const char *user_buffer, · 175 unmodified lines
422420
423421 /* this lock makes sure we don't submit URBs to gone devices */
424422 mutex_lock(&dev->io_mutex);
425− if (!dev->interface) { /* disconnect() was called */
423+ if (dev->disconnected) { /* disconnect() was called */
426424 mutex_unlock(&dev->io_mutex);
427425 retval = -ENODEV;
428426 goto error;
@@ -507,7 +505,7 @@ static int skel_probe(struct usb_interface *interface, · 78 unmodified lines
507505 init_waitqueue_head(&dev->bulk_in_wait);
508506
509507 dev->udev = usb_get_dev(interface_to_usbdev(interface));
510− dev->interface = interface;
508+ dev->interface = usb_get_intf(interface);
511509
512510 /* set up the endpoint information */
513511 /* use only the first bulk-in and bulk-out endpoints */
@@ -573,9 +571,10 @@ static void skel_disconnect(struct usb_interface *interface) · 59 unmodified lines
573571
574572 /* prevent more I/O from starting */
575573 mutex_lock(&dev->io_mutex);
576− dev->interface = NULL;
574+ dev->disconnected = 1;
577575 mutex_unlock(&dev->io_mutex);
578576
577+ usb_kill_urb(dev->bulk_in_urb);
579578 usb_kill_anchored_urbs(&dev->submitted);
580579
581580 /* decrement our usage count */
drivers/usb/usbip/vhci_hcd.c+2−2
@@ -1195,12 +1195,12 @@ static int vhci_start(struct usb_hcd *hcd) · 1194 unmodified lines
11951195 if (id == 0 && usb_hcd_is_primary_hcd(hcd)) {
11961196 err = vhci_init_attr_group();
11971197 if (err) {
1198− pr_err("init attr group\n");
1198+ dev_err(hcd_dev(hcd), "init attr group failed, err = %d\n", err);
11991199 return err;
12001200 }
12011201 err = sysfs_create_group(&hcd_dev(hcd)->kobj, &vhci_attr_group);
12021202 if (err) {
1203− pr_err("create sysfs files\n");
1203+ dev_err(hcd_dev(hcd), "create sysfs files failed, err = %d\n", err);
12041204 vhci_finish_attr_group();
12051205 return err;
12061206 }
include/linux/platform_device.h+2−0
@@ -64,6 +64,8 @@ extern struct resource *platform_get_resource_byname(struct platform_device *, · 63 unmodified lines
6464 unsigned int,
6565 const char *);
6666 extern int platform_get_irq_byname(struct platform_device *, const char *);
67+extern int platform_get_irq_byname_optional(struct platform_device *dev,
68+ const char *name);
6769 extern int platform_add_devices(struct platform_device **, int);
6870
6971 struct platform_device_info {