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
85the node is not important. The content of the node is defined in dwc2.txt.85the node is not important. The content of the node is defined in dwc2.txt.
86 86
87PHY documentation is provided in the following places:87PHY documentation is provided in the following places:
88- Documentation/devicetree/bindings/phy/meson-g12a-usb2-phy.txt88- Documentation/devicetree/bindings/phy/amlogic,meson-g12a-usb2-phy.yaml
89- Documentation/devicetree/bindings/phy/meson-g12a-usb3-pcie-phy.txt89- Documentation/devicetree/bindings/phy/amlogic,meson-g12a-usb3-pcie-phy.yaml
90 90
91Example device nodes:91Example device nodes:
92 usb: usb@ffe09000 {92 usb: usb@ffe09000 {
Documentation/devicetree/bindings/usb/generic-ehci.yaml+6−1
@@ -63,7 +63,11 @@ properties: · 62 unmodified lines
63 description:63 description:
64 Set this flag to force EHCI reset after resume.64 Set this flag to force EHCI reset after resume.
65 65
66 phys: true66 phys:
67 description: PHY specifier for the USB PHY
68
69 phy-names:
70 const: usb
67 71
68required:72required:
69 - compatible73 - compatible
@@ -89,6 +93,7 @@ examples: · 19 unmodified lines
89 interrupts = <39>;93 interrupts = <39>;
90 clocks = <&ahb_gates 1>;94 clocks = <&ahb_gates 1>;
91 phys = <&usbphy 1>;95 phys = <&usbphy 1>;
96 phy-names = "usb";
92 };97 };
93 98
94...99...
Documentation/devicetree/bindings/usb/generic-ohci.yaml+6−1
@@ -67,7 +67,11 @@ properties: · 66 unmodified lines
67 description:67 description:
68 Overrides the detected port count68 Overrides the detected port count
69 69
70 phys: true70 phys:
71 description: PHY specifier for the USB PHY
72
73 phy-names:
74 const: usb
71 75
72required:76required:
73 - compatible77 - compatible
@@ -84,6 +88,7 @@ examples: · 10 unmodified lines
84 interrupts = <64>;88 interrupts = <64>;
85 clocks = <&usb_clk 6>, <&ahb_gates 2>;89 clocks = <&usb_clk 6>, <&ahb_gates 2>;
86 phys = <&usbphy 1>;90 phys = <&usbphy 1>;
91 phy-names = "usb";
87 };92 };
88 93
89...94...
Documentation/devicetree/bindings/usb/mediatek,mtk-xhci.txt+2−2
@@ -33,7 +33,7 @@ Required properties: · 32 unmodified lines
33 "dma_ck": dma_bus clock for data transfer by DMA,33 "dma_ck": dma_bus clock for data transfer by DMA,
34 "xhci_ck": controller clock34 "xhci_ck": controller clock
35 35
36 - phys : see usb-hcd.txt in the current directory36 - phys : see usb-hcd.yaml in the current directory
37 37
38Optional properties:38Optional properties:
39 - wakeup-source : enable USB remote wakeup;39 - wakeup-source : enable USB remote wakeup;
@@ -53,7 +53,7 @@ Optional properties: · 13 unmodified lines
53 See: Documentation/devicetree/bindings/pinctrl/pinctrl-bindings.txt53 See: Documentation/devicetree/bindings/pinctrl/pinctrl-bindings.txt
54 - imod-interval-ns: default interrupt moderation interval is 5000ns54 - imod-interval-ns: default interrupt moderation interval is 5000ns
55 55
56additionally the properties from usb-hcd.txt (in the current directory) are56additionally the properties from usb-hcd.yaml (in the current directory) are
57supported.57supported.
58 58
59Example:59Example:
Documentation/devicetree/bindings/usb/mediatek,mtu3.txt+2−2
@@ -17,7 +17,7 @@ Required properties: · 16 unmodified lines
17 - clock-names : must contain "sys_ck" for clock of controller,17 - clock-names : must contain "sys_ck" for clock of controller,
18 the following clocks are optional:18 the following clocks are optional:
19 "ref_ck", "mcu_ck" and "dma_ck";19 "ref_ck", "mcu_ck" and "dma_ck";
20 - phys : see usb-hcd.txt in the current directory20 - phys : see usb-hcd.yaml in the current directory
21 - dr_mode : should be one of "host", "peripheral" or "otg",21 - dr_mode : should be one of "host", "peripheral" or "otg",
22 refer to usb/generic.txt22 refer to usb/generic.txt
23 23
@@ -60,7 +60,7 @@ Optional properties: · 36 unmodified lines
60 - mediatek,u3p-dis-msk : mask to disable u3ports, bit0 for u3port0,60 - mediatek,u3p-dis-msk : mask to disable u3ports, bit0 for u3port0,
61 bit1 for u3port1, ... etc;61 bit1 for u3port1, ... etc;
62 62
63additionally the properties from usb-hcd.txt (in the current directory) are63additionally the properties from usb-hcd.yaml (in the current directory) are
64supported.64supported.
65 65
66Sub-nodes:66Sub-nodes:
Documentation/devicetree/bindings/usb/usb-hcd.yaml+5−0
@@ -18,8 +18,13 @@ properties: · 17 unmodified lines
18 description:18 description:
19 List of all the USB PHYs on this HCD19 List of all the USB PHYs on this HCD
20 20
21 phy-names:
22 description:
23 Name specifier for the USB PHY
24
21examples:25examples:
22 - |26 - |
23 usb {27 usb {
24 phys = <&usb2_phy1>, <&usb3_phy1>;28 phys = <&usb2_phy1>, <&usb3_phy1>;
29 phy-names = "usb";
25 };30 };
Documentation/devicetree/bindings/usb/usb-uhci.txt+1−1
@@ -6,7 +6,7 @@ Required properties: · 5 unmodified lines
6- reg : Should contain 1 register ranges(address and length)6- reg : Should contain 1 register ranges(address and length)
7- interrupts : UHCI controller interrupt7- interrupts : UHCI controller interrupt
8 8
9additionally the properties from usb-hcd.txt (in the current directory) are9additionally the properties from usb-hcd.yaml (in the current directory) are
10supported.10supported.
11 11
12Example:12Example:
Documentation/devicetree/bindings/usb/usb-xhci.txt+2−2
@@ -41,9 +41,9 @@ Optional properties: · 40 unmodified lines
41 - usb3-lpm-capable: determines if platform is USB3 LPM capable41 - usb3-lpm-capable: determines if platform is USB3 LPM capable
42 - quirk-broken-port-ped: set if the controller has broken port disable mechanism42 - quirk-broken-port-ped: set if the controller has broken port disable mechanism
43 - imod-interval-ns: default interrupt moderation interval is 5000ns43 - imod-interval-ns: default interrupt moderation interval is 5000ns
44 - phys : see usb-hcd.txt in the current directory44 - phys : see usb-hcd.yaml in the current directory
45 45
46additionally the properties from usb-hcd.txt (in the current directory) are46additionally the properties from usb-hcd.yaml (in the current directory) are
47supported.47supported.
48 48
49 49
Documentation/usb/rio.rst+0−109
@@ -1,109 +0,0 @@
1============
2Diamonds Rio
3============
4
5Copyright (C) 1999, 2000 Bruce Tenison
6
7Portions Copyright (C) 1999, 2000 David Nelson
8
9Thanks to David Nelson for guidance and the usage of the scanner.txt
10and scanner.c files to model our driver and this informative file.
11
12Mar. 2, 2000
13
14Changes
15=======
16
17- Initial Revision
18
19
20Overview
21========
22
23This README will address issues regarding how to configure the kernel
24to access a RIO 500 mp3 player.
25Before 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
33It seems that the Rio has a problem when sending .mp3 with low batteries.
34I suggest when the batteries are low and you want to transfer stuff that you
35replace it with a fresh one. In my case, what happened is I lost two 16kb
36blocks (they are no longer usable to store information to it). But I don't
37know if that's normal or not; it could simply be a problem with the flash
38memory.
39
40In an extreme case, I left my Rio playing overnight and the batteries wore
41down to nothing and appear to have corrupted the flash memory. My RIO
42needed to be replaced as a result. Diamond tech support is aware of the
43problem. Do NOT allow your batteries to wear down to nothing before
44changing them. It appears RIO 500 firmware does not handle low battery
45power well at all.
46
47On systems with OHCI controllers, the kernel OHCI code appears to have
48power on problems with some chipsets. If you are having problems
49connecting to your RIO 500, try turning it on first and then plugging it
50into the USB cable.
51
52Contact 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
60Authors
61-------
62
63Most of the code was written by Cesar Miquel <miquel@df.uba.ar>. Keith
64Clayton <kclayton@jps.net> is incharge of the PPC port and making sure
65things work there. Bruce Tenison <btenison@dibbs.net> is adding support
66for .fon files and also does testing. The program will mostly sure be
67re-written and Pete Ikusz along with the rest will re-design it. I would
68also like to thank Tri Nguyen <tmn_3022000@hotmail.com> who provided use
69with some important information regarding the communication with the Rio.
70
71Additional Information and userspace tools
72
73 http://rio500.sourceforge.net/
74
75
76Requirements
77============
78
79A host with a USB port running a Linux kernel with RIO 500 support enabled.
80
81The driver is a module called rio500, which should be automatically loaded
82as you plug in your device. If that fails you can manually load it with
83
84 modprobe rio500
85
86Udev should automatically create a device node as soon as plug in your device.
87If that fails, you can manually add a device for the USB rio500::
88
89 mknod /dev/usb/rio500 c 180 64
90
91In that case, set appropriate permissions for /dev/usb/rio500 (don't forget
92about group and world permissions). Both read and write permissions are
93required for proper operation.
94
95That's it. The Rio500 Utils at: http://rio500.sourceforge.net should
96be able to access the rio500.
97
98Limits
99======
100
101You can use only a single rio500 device at a time with your computer.
102
103Bugs
104====
105
106If you encounter any problems feel free to drop me an email.
107
108Bruce Tenison
109btenison@dibbs.net
MAINTAINERS+0−7
@@ -16764,13 +16764,6 @@ W: http://www.linux-usb.org/usbnet · 16763 unmodified lines
16764S: Maintained16764S: Maintained
16765F: drivers/net/usb/dm9601.c16765F: drivers/net/usb/dm9601.c
16766 16766
16767USB DIAMOND RIO500 DRIVER
16768M: Cesar Miquel <miquel@df.uba.ar>
16769L: rio500-users@lists.sourceforge.net
16770W: http://rio500.sourceforge.net
16771S: Maintained
16772F: drivers/usb/misc/rio500*
16773
16774USB EHCI DRIVER16767USB EHCI DRIVER
16775M: Alan Stern <stern@rowland.harvard.edu>16768M: Alan Stern <stern@rowland.harvard.edu>
16776L: linux-usb@vger.kernel.org16769L: linux-usb@vger.kernel.org
arch/arm/boot/dts/sun4i-a10.dtsi+4−0
@@ -520,6 +520,7 @@ · 519 unmodified lines
520 interrupts = <39>;520 interrupts = <39>;
521 clocks = <&ccu CLK_AHB_EHCI0>;521 clocks = <&ccu CLK_AHB_EHCI0>;
522 phys = <&usbphy 1>;522 phys = <&usbphy 1>;
523 phy-names = "usb";
523 status = "disabled";524 status = "disabled";
524 };525 };
525 526
@@ -529,6 +530,7 @@ · 3 unmodified lines
529 interrupts = <64>;530 interrupts = <64>;
530 clocks = <&ccu CLK_USB_OHCI0>, <&ccu CLK_AHB_OHCI0>;531 clocks = <&ccu CLK_USB_OHCI0>, <&ccu CLK_AHB_OHCI0>;
531 phys = <&usbphy 1>;532 phys = <&usbphy 1>;
533 phy-names = "usb";
532 status = "disabled";534 status = "disabled";
533 };535 };
534 536
@@ -608,6 +610,7 @@ · 73 unmodified lines
608 interrupts = <40>;610 interrupts = <40>;
609 clocks = <&ccu CLK_AHB_EHCI1>;611 clocks = <&ccu CLK_AHB_EHCI1>;
610 phys = <&usbphy 2>;612 phys = <&usbphy 2>;
613 phy-names = "usb";
611 status = "disabled";614 status = "disabled";
612 };615 };
613 616
@@ -617,6 +620,7 @@ · 3 unmodified lines
617 interrupts = <65>;620 interrupts = <65>;
618 clocks = <&ccu CLK_USB_OHCI1>, <&ccu CLK_AHB_OHCI1>;621 clocks = <&ccu CLK_USB_OHCI1>, <&ccu CLK_AHB_OHCI1>;
619 phys = <&usbphy 2>;622 phys = <&usbphy 2>;
623 phy-names = "usb";
620 status = "disabled";624 status = "disabled";
621 };625 };
622 626
arch/arm/boot/dts/sun5i.dtsi+2−0
@@ -391,6 +391,7 @@ · 390 unmodified lines
391 interrupts = <39>;391 interrupts = <39>;
392 clocks = <&ccu CLK_AHB_EHCI>;392 clocks = <&ccu CLK_AHB_EHCI>;
393 phys = <&usbphy 1>;393 phys = <&usbphy 1>;
394 phy-names = "usb";
394 status = "disabled";395 status = "disabled";
395 };396 };
396 397
@@ -400,6 +401,7 @@ · 3 unmodified lines
400 interrupts = <40>;401 interrupts = <40>;
401 clocks = <&ccu CLK_USB_OHCI>, <&ccu CLK_AHB_OHCI>;402 clocks = <&ccu CLK_USB_OHCI>, <&ccu CLK_AHB_OHCI>;
402 phys = <&usbphy 1>;403 phys = <&usbphy 1>;
404 phy-names = "usb";
403 status = "disabled";405 status = "disabled";
404 };406 };
405 407
arch/arm/boot/dts/sun6i-a31.dtsi+4−0
@@ -545,6 +545,7 @@ · 544 unmodified lines
545 clocks = <&ccu CLK_AHB1_EHCI0>;545 clocks = <&ccu CLK_AHB1_EHCI0>;
546 resets = <&ccu RST_AHB1_EHCI0>;546 resets = <&ccu RST_AHB1_EHCI0>;
547 phys = <&usbphy 1>;547 phys = <&usbphy 1>;
548 phy-names = "usb";
548 status = "disabled";549 status = "disabled";
549 };550 };
550 551
@@ -555,6 +556,7 @@ · 4 unmodified lines
555 clocks = <&ccu CLK_AHB1_OHCI0>, <&ccu CLK_USB_OHCI0>;556 clocks = <&ccu CLK_AHB1_OHCI0>, <&ccu CLK_USB_OHCI0>;
556 resets = <&ccu RST_AHB1_OHCI0>;557 resets = <&ccu RST_AHB1_OHCI0>;
557 phys = <&usbphy 1>;558 phys = <&usbphy 1>;
559 phy-names = "usb";
558 status = "disabled";560 status = "disabled";
559 };561 };
560 562
@@ -565,6 +567,7 @@ · 4 unmodified lines
565 clocks = <&ccu CLK_AHB1_EHCI1>;567 clocks = <&ccu CLK_AHB1_EHCI1>;
566 resets = <&ccu RST_AHB1_EHCI1>;568 resets = <&ccu RST_AHB1_EHCI1>;
567 phys = <&usbphy 2>;569 phys = <&usbphy 2>;
570 phy-names = "usb";
568 status = "disabled";571 status = "disabled";
569 };572 };
570 573
@@ -575,6 +578,7 @@ · 4 unmodified lines
575 clocks = <&ccu CLK_AHB1_OHCI1>, <&ccu CLK_USB_OHCI1>;578 clocks = <&ccu CLK_AHB1_OHCI1>, <&ccu CLK_USB_OHCI1>;
576 resets = <&ccu RST_AHB1_OHCI1>;579 resets = <&ccu RST_AHB1_OHCI1>;
577 phys = <&usbphy 2>;580 phys = <&usbphy 2>;
581 phy-names = "usb";
578 status = "disabled";582 status = "disabled";
579 };583 };
580 584
arch/arm/boot/dts/sun7i-a20.dtsi+4−0
@@ -623,6 +623,7 @@ · 622 unmodified lines
623 interrupts = <GIC_SPI 39 IRQ_TYPE_LEVEL_HIGH>;623 interrupts = <GIC_SPI 39 IRQ_TYPE_LEVEL_HIGH>;
624 clocks = <&ccu CLK_AHB_EHCI0>;624 clocks = <&ccu CLK_AHB_EHCI0>;
625 phys = <&usbphy 1>;625 phys = <&usbphy 1>;
626 phy-names = "usb";
626 status = "disabled";627 status = "disabled";
627 };628 };
628 629
@@ -632,6 +633,7 @@ · 3 unmodified lines
632 interrupts = <GIC_SPI 64 IRQ_TYPE_LEVEL_HIGH>;633 interrupts = <GIC_SPI 64 IRQ_TYPE_LEVEL_HIGH>;
633 clocks = <&ccu CLK_USB_OHCI0>, <&ccu CLK_AHB_OHCI0>;634 clocks = <&ccu CLK_USB_OHCI0>, <&ccu CLK_AHB_OHCI0>;
634 phys = <&usbphy 1>;635 phys = <&usbphy 1>;
636 phy-names = "usb";
635 status = "disabled";637 status = "disabled";
636 };638 };
637 639
@@ -714,6 +716,7 @@ · 76 unmodified lines
714 interrupts = <GIC_SPI 40 IRQ_TYPE_LEVEL_HIGH>;716 interrupts = <GIC_SPI 40 IRQ_TYPE_LEVEL_HIGH>;
715 clocks = <&ccu CLK_AHB_EHCI1>;717 clocks = <&ccu CLK_AHB_EHCI1>;
716 phys = <&usbphy 2>;718 phys = <&usbphy 2>;
719 phy-names = "usb";
717 status = "disabled";720 status = "disabled";
718 };721 };
719 722
@@ -723,6 +726,7 @@ · 3 unmodified lines
723 interrupts = <GIC_SPI 65 IRQ_TYPE_LEVEL_HIGH>;726 interrupts = <GIC_SPI 65 IRQ_TYPE_LEVEL_HIGH>;
724 clocks = <&ccu CLK_USB_OHCI1>, <&ccu CLK_AHB_OHCI1>;727 clocks = <&ccu CLK_USB_OHCI1>, <&ccu CLK_AHB_OHCI1>;
725 phys = <&usbphy 2>;728 phys = <&usbphy 2>;
729 phy-names = "usb";
726 status = "disabled";730 status = "disabled";
727 };731 };
728 732
arch/arm/boot/dts/sun8i-a23-a33.dtsi+2−0
@@ -307,6 +307,7 @@ · 306 unmodified lines
307 clocks = <&ccu CLK_BUS_EHCI>;307 clocks = <&ccu CLK_BUS_EHCI>;
308 resets = <&ccu RST_BUS_EHCI>;308 resets = <&ccu RST_BUS_EHCI>;
309 phys = <&usbphy 1>;309 phys = <&usbphy 1>;
310 phy-names = "usb";
310 status = "disabled";311 status = "disabled";
311 };312 };
312 313
@@ -317,6 +318,7 @@ · 4 unmodified lines
317 clocks = <&ccu CLK_BUS_OHCI>, <&ccu CLK_USB_OHCI>;318 clocks = <&ccu CLK_BUS_OHCI>, <&ccu CLK_USB_OHCI>;
318 resets = <&ccu RST_BUS_OHCI>;319 resets = <&ccu RST_BUS_OHCI>;
319 phys = <&usbphy 1>;320 phys = <&usbphy 1>;
321 phy-names = "usb";
320 status = "disabled";322 status = "disabled";
321 };323 };
322 324
arch/arm/boot/dts/sun8i-a83t.dtsi+3−0
@@ -632,6 +632,7 @@ · 631 unmodified lines
632 clocks = <&ccu CLK_BUS_EHCI0>;632 clocks = <&ccu CLK_BUS_EHCI0>;
633 resets = <&ccu RST_BUS_EHCI0>;633 resets = <&ccu RST_BUS_EHCI0>;
634 phys = <&usbphy 1>;634 phys = <&usbphy 1>;
635 phy-names = "usb";
635 status = "disabled";636 status = "disabled";
636 };637 };
637 638
@@ -643,6 +644,7 @@ · 5 unmodified lines
643 clocks = <&ccu CLK_BUS_OHCI0>, <&ccu CLK_USB_OHCI0>;644 clocks = <&ccu CLK_BUS_OHCI0>, <&ccu CLK_USB_OHCI0>;
644 resets = <&ccu RST_BUS_OHCI0>;645 resets = <&ccu RST_BUS_OHCI0>;
645 phys = <&usbphy 1>;646 phys = <&usbphy 1>;
647 phy-names = "usb";
646 status = "disabled";648 status = "disabled";
647 };649 };
648 650
@@ -654,6 +656,7 @@ · 5 unmodified lines
654 clocks = <&ccu CLK_BUS_EHCI1>;656 clocks = <&ccu CLK_BUS_EHCI1>;
655 resets = <&ccu RST_BUS_EHCI1>;657 resets = <&ccu RST_BUS_EHCI1>;
656 phys = <&usbphy 2>;658 phys = <&usbphy 2>;
659 phy-names = "usb";
657 status = "disabled";660 status = "disabled";
658 };661 };
659 662
arch/arm/boot/dts/sun8i-r40.dtsi+4−0
@@ -273,6 +273,7 @@ · 272 unmodified lines
273 clocks = <&ccu CLK_BUS_EHCI1>;273 clocks = <&ccu CLK_BUS_EHCI1>;
274 resets = <&ccu RST_BUS_EHCI1>;274 resets = <&ccu RST_BUS_EHCI1>;
275 phys = <&usbphy 1>;275 phys = <&usbphy 1>;
276 phy-names = "usb";
276 status = "disabled";277 status = "disabled";
277 };278 };
278 279
@@ -284,6 +285,7 @@ · 5 unmodified lines
284 <&ccu CLK_USB_OHCI1>;285 <&ccu CLK_USB_OHCI1>;
285 resets = <&ccu RST_BUS_OHCI1>;286 resets = <&ccu RST_BUS_OHCI1>;
286 phys = <&usbphy 1>;287 phys = <&usbphy 1>;
288 phy-names = "usb";
287 status = "disabled";289 status = "disabled";
288 };290 };
289 291
@@ -294,6 +296,7 @@ · 4 unmodified lines
294 clocks = <&ccu CLK_BUS_EHCI2>;296 clocks = <&ccu CLK_BUS_EHCI2>;
295 resets = <&ccu RST_BUS_EHCI2>;297 resets = <&ccu RST_BUS_EHCI2>;
296 phys = <&usbphy 2>;298 phys = <&usbphy 2>;
299 phy-names = "usb";
297 status = "disabled";300 status = "disabled";
298 };301 };
299 302
@@ -305,6 +308,7 @@ · 5 unmodified lines
305 <&ccu CLK_USB_OHCI2>;308 <&ccu CLK_USB_OHCI2>;
306 resets = <&ccu RST_BUS_OHCI2>;309 resets = <&ccu RST_BUS_OHCI2>;
307 phys = <&usbphy 2>;310 phys = <&usbphy 2>;
311 phy-names = "usb";
308 status = "disabled";312 status = "disabled";
309 };313 };
310 314
arch/arm/boot/dts/sun9i-a80.dtsi+5−0
@@ -346,6 +346,7 @@ · 345 unmodified lines
346 clocks = <&usb_clocks CLK_BUS_HCI0>;346 clocks = <&usb_clocks CLK_BUS_HCI0>;
347 resets = <&usb_clocks RST_USB0_HCI>;347 resets = <&usb_clocks RST_USB0_HCI>;
348 phys = <&usbphy1>;348 phys = <&usbphy1>;
349 phy-names = "usb";
349 status = "disabled";350 status = "disabled";
350 };351 };
351 352
@@ -357,6 +358,7 @@ · 5 unmodified lines
357 <&usb_clocks CLK_USB_OHCI0>;358 <&usb_clocks CLK_USB_OHCI0>;
358 resets = <&usb_clocks RST_USB0_HCI>;359 resets = <&usb_clocks RST_USB0_HCI>;
359 phys = <&usbphy1>;360 phys = <&usbphy1>;
361 phy-names = "usb";
360 status = "disabled";362 status = "disabled";
361 };363 };
362 364
@@ -378,6 +380,7 @@ · 15 unmodified lines
378 clocks = <&usb_clocks CLK_BUS_HCI1>;380 clocks = <&usb_clocks CLK_BUS_HCI1>;
379 resets = <&usb_clocks RST_USB1_HCI>;381 resets = <&usb_clocks RST_USB1_HCI>;
380 phys = <&usbphy2>;382 phys = <&usbphy2>;
383 phy-names = "usb";
381 status = "disabled";384 status = "disabled";
382 };385 };
383 386
@@ -407,6 +410,7 @@ · 23 unmodified lines
407 clocks = <&usb_clocks CLK_BUS_HCI2>;410 clocks = <&usb_clocks CLK_BUS_HCI2>;
408 resets = <&usb_clocks RST_USB2_HCI>;411 resets = <&usb_clocks RST_USB2_HCI>;
409 phys = <&usbphy3>;412 phys = <&usbphy3>;
413 phy-names = "usb";
410 status = "disabled";414 status = "disabled";
411 };415 };
412 416
@@ -418,6 +422,7 @@ · 5 unmodified lines
418 <&usb_clocks CLK_USB_OHCI2>;422 <&usb_clocks CLK_USB_OHCI2>;
419 resets = <&usb_clocks RST_USB2_HCI>;423 resets = <&usb_clocks RST_USB2_HCI>;
420 phys = <&usbphy3>;424 phys = <&usbphy3>;
425 phy-names = "usb";
421 status = "disabled";426 status = "disabled";
422 };427 };
423 428
arch/arm/boot/dts/sunxi-h3-h5.dtsi+6−0
@@ -304,6 +304,7 @@ · 303 unmodified lines
304 clocks = <&ccu CLK_BUS_EHCI1>, <&ccu CLK_BUS_OHCI1>;304 clocks = <&ccu CLK_BUS_EHCI1>, <&ccu CLK_BUS_OHCI1>;
305 resets = <&ccu RST_BUS_EHCI1>, <&ccu RST_BUS_OHCI1>;305 resets = <&ccu RST_BUS_EHCI1>, <&ccu RST_BUS_OHCI1>;
306 phys = <&usbphy 1>;306 phys = <&usbphy 1>;
307 phy-names = "usb";
307 status = "disabled";308 status = "disabled";
308 };309 };
309 310
@@ -315,6 +316,7 @@ · 5 unmodified lines
315 <&ccu CLK_USB_OHCI1>;316 <&ccu CLK_USB_OHCI1>;
316 resets = <&ccu RST_BUS_EHCI1>, <&ccu RST_BUS_OHCI1>;317 resets = <&ccu RST_BUS_EHCI1>, <&ccu RST_BUS_OHCI1>;
317 phys = <&usbphy 1>;318 phys = <&usbphy 1>;
319 phy-names = "usb";
318 status = "disabled";320 status = "disabled";
319 };321 };
320 322
@@ -325,6 +327,7 @@ · 4 unmodified lines
325 clocks = <&ccu CLK_BUS_EHCI2>, <&ccu CLK_BUS_OHCI2>;327 clocks = <&ccu CLK_BUS_EHCI2>, <&ccu CLK_BUS_OHCI2>;
326 resets = <&ccu RST_BUS_EHCI2>, <&ccu RST_BUS_OHCI2>;328 resets = <&ccu RST_BUS_EHCI2>, <&ccu RST_BUS_OHCI2>;
327 phys = <&usbphy 2>;329 phys = <&usbphy 2>;
330 phy-names = "usb";
328 status = "disabled";331 status = "disabled";
329 };332 };
330 333
@@ -336,6 +339,7 @@ · 5 unmodified lines
336 <&ccu CLK_USB_OHCI2>;339 <&ccu CLK_USB_OHCI2>;
337 resets = <&ccu RST_BUS_EHCI2>, <&ccu RST_BUS_OHCI2>;340 resets = <&ccu RST_BUS_EHCI2>, <&ccu RST_BUS_OHCI2>;
338 phys = <&usbphy 2>;341 phys = <&usbphy 2>;
342 phy-names = "usb";
339 status = "disabled";343 status = "disabled";
340 };344 };
341 345
@@ -346,6 +350,7 @@ · 4 unmodified lines
346 clocks = <&ccu CLK_BUS_EHCI3>, <&ccu CLK_BUS_OHCI3>;350 clocks = <&ccu CLK_BUS_EHCI3>, <&ccu CLK_BUS_OHCI3>;
347 resets = <&ccu RST_BUS_EHCI3>, <&ccu RST_BUS_OHCI3>;351 resets = <&ccu RST_BUS_EHCI3>, <&ccu RST_BUS_OHCI3>;
348 phys = <&usbphy 3>;352 phys = <&usbphy 3>;
353 phy-names = "usb";
349 status = "disabled";354 status = "disabled";
350 };355 };
351 356
@@ -357,6 +362,7 @@ · 5 unmodified lines
357 <&ccu CLK_USB_OHCI3>;362 <&ccu CLK_USB_OHCI3>;
358 resets = <&ccu RST_BUS_EHCI3>, <&ccu RST_BUS_OHCI3>;363 resets = <&ccu RST_BUS_EHCI3>, <&ccu RST_BUS_OHCI3>;
359 phys = <&usbphy 3>;364 phys = <&usbphy 3>;
365 phy-names = "usb";
360 status = "disabled";366 status = "disabled";
361 };367 };
362 368
arch/arm/configs/badge4_defconfig+0−1
@@ -91,7 +91,6 @@ CONFIG_USB_SERIAL_PL2303=m · 90 unmodified lines
91CONFIG_USB_SERIAL_CYBERJACK=m91CONFIG_USB_SERIAL_CYBERJACK=m
92CONFIG_USB_SERIAL_XIRCOM=m92CONFIG_USB_SERIAL_XIRCOM=m
93CONFIG_USB_SERIAL_OMNINET=m93CONFIG_USB_SERIAL_OMNINET=m
94CONFIG_USB_RIO500=m
95CONFIG_EXT2_FS=m94CONFIG_EXT2_FS=m
96CONFIG_EXT3_FS=m95CONFIG_EXT3_FS=m
97CONFIG_MSDOS_FS=y96CONFIG_MSDOS_FS=y
arch/arm/configs/corgi_defconfig+0−1
@@ -195,7 +195,6 @@ CONFIG_USB_SERIAL_XIRCOM=m · 194 unmodified lines
195CONFIG_USB_SERIAL_OMNINET=m195CONFIG_USB_SERIAL_OMNINET=m
196CONFIG_USB_EMI62=m196CONFIG_USB_EMI62=m
197CONFIG_USB_EMI26=m197CONFIG_USB_EMI26=m
198CONFIG_USB_RIO500=m
199CONFIG_USB_LEGOTOWER=m198CONFIG_USB_LEGOTOWER=m
200CONFIG_USB_LCD=m199CONFIG_USB_LCD=m
201CONFIG_USB_CYTHERM=m200CONFIG_USB_CYTHERM=m
arch/arm/configs/pxa_defconfig+0−1
@@ -581,7 +581,6 @@ CONFIG_USB_SERIAL_XIRCOM=m · 580 unmodified lines
581CONFIG_USB_SERIAL_OMNINET=m581CONFIG_USB_SERIAL_OMNINET=m
582CONFIG_USB_EMI62=m582CONFIG_USB_EMI62=m
583CONFIG_USB_EMI26=m583CONFIG_USB_EMI26=m
584CONFIG_USB_RIO500=m
585CONFIG_USB_LEGOTOWER=m584CONFIG_USB_LEGOTOWER=m
586CONFIG_USB_LCD=m585CONFIG_USB_LCD=m
587CONFIG_USB_CYTHERM=m586CONFIG_USB_CYTHERM=m
arch/arm/configs/s3c2410_defconfig+0−1
@@ -327,7 +327,6 @@ CONFIG_USB_EMI62=m · 326 unmodified lines
327CONFIG_USB_EMI26=m327CONFIG_USB_EMI26=m
328CONFIG_USB_ADUTUX=m328CONFIG_USB_ADUTUX=m
329CONFIG_USB_SEVSEG=m329CONFIG_USB_SEVSEG=m
330CONFIG_USB_RIO500=m
331CONFIG_USB_LEGOTOWER=m330CONFIG_USB_LEGOTOWER=m
332CONFIG_USB_LCD=m331CONFIG_USB_LCD=m
333CONFIG_USB_CYPRESS_CY7C63=m332CONFIG_USB_CYPRESS_CY7C63=m
arch/arm/configs/spitz_defconfig+0−1
@@ -189,7 +189,6 @@ CONFIG_USB_SERIAL_XIRCOM=m · 188 unmodified lines
189CONFIG_USB_SERIAL_OMNINET=m189CONFIG_USB_SERIAL_OMNINET=m
190CONFIG_USB_EMI62=m190CONFIG_USB_EMI62=m
191CONFIG_USB_EMI26=m191CONFIG_USB_EMI26=m
192CONFIG_USB_RIO500=m
193CONFIG_USB_LEGOTOWER=m192CONFIG_USB_LEGOTOWER=m
194CONFIG_USB_LCD=m193CONFIG_USB_LCD=m
195CONFIG_USB_CYTHERM=m194CONFIG_USB_CYTHERM=m
arch/arm64/boot/dts/allwinner/sun50i-a64-pinebook.dts+2−0
@@ -104,6 +104,7 @@ · 103 unmodified lines
104 104
105&ehci0 {105&ehci0 {
106 phys = <&usbphy 0>;106 phys = <&usbphy 0>;
107 phy-names = "usb";
107 status = "okay";108 status = "okay";
108};109};
109 110
@@ -150,6 +151,7 @@ · 40 unmodified lines
150 151
151&ohci0 {152&ohci0 {
152 phys = <&usbphy 0>;153 phys = <&usbphy 0>;
154 phy-names = "usb";
153 status = "okay";155 status = "okay";
154};156};
155 157
arch/arm64/boot/dts/allwinner/sun50i-a64.dtsi+2−0
@@ -553,6 +553,7 @@ · 552 unmodified lines
553 resets = <&ccu RST_BUS_OHCI1>,553 resets = <&ccu RST_BUS_OHCI1>,
554 <&ccu RST_BUS_EHCI1>;554 <&ccu RST_BUS_EHCI1>;
555 phys = <&usbphy 1>;555 phys = <&usbphy 1>;
556 phy-names = "usb";
556 status = "disabled";557 status = "disabled";
557 };558 };
558 559
@@ -564,6 +565,7 @@ · 5 unmodified lines
564 <&ccu CLK_USB_OHCI1>;565 <&ccu CLK_USB_OHCI1>;
565 resets = <&ccu RST_BUS_OHCI1>;566 resets = <&ccu RST_BUS_OHCI1>;
566 phys = <&usbphy 1>;567 phys = <&usbphy 1>;
568 phy-names = "usb";
567 status = "disabled";569 status = "disabled";
568 };570 };
569 571
arch/arm64/boot/dts/allwinner/sun50i-h6.dtsi+2−0
@@ -547,6 +547,7 @@ · 546 unmodified lines
547 resets = <&ccu RST_BUS_OHCI3>,547 resets = <&ccu RST_BUS_OHCI3>,
548 <&ccu RST_BUS_EHCI3>;548 <&ccu RST_BUS_EHCI3>;
549 phys = <&usb2phy 3>;549 phys = <&usb2phy 3>;
550 phy-names = "usb";
550 status = "disabled";551 status = "disabled";
551 };552 };
552 553
@@ -558,6 +559,7 @@ · 5 unmodified lines
558 <&ccu CLK_USB_OHCI3>;559 <&ccu CLK_USB_OHCI3>;
559 resets = <&ccu RST_BUS_OHCI3>;560 resets = <&ccu RST_BUS_OHCI3>;
560 phys = <&usb2phy 3>;561 phys = <&usb2phy 3>;
562 phy-names = "usb";
561 status = "disabled";563 status = "disabled";
562 };564 };
563 565
arch/mips/configs/mtx1_defconfig+0−1
@@ -571,7 +571,6 @@ CONFIG_USB_SERIAL_OMNINET=m · 570 unmodified lines
571CONFIG_USB_EMI62=m571CONFIG_USB_EMI62=m
572CONFIG_USB_EMI26=m572CONFIG_USB_EMI26=m
573CONFIG_USB_ADUTUX=m573CONFIG_USB_ADUTUX=m
574CONFIG_USB_RIO500=m
575CONFIG_USB_LEGOTOWER=m574CONFIG_USB_LEGOTOWER=m
576CONFIG_USB_LCD=m575CONFIG_USB_LCD=m
577CONFIG_USB_CYPRESS_CY7C63=m576CONFIG_USB_CYPRESS_CY7C63=m
arch/mips/configs/rm200_defconfig+0−1
@@ -314,7 +314,6 @@ CONFIG_USB_SERIAL_SAFE_PADDED=y · 313 unmodified lines
314CONFIG_USB_SERIAL_CYBERJACK=m314CONFIG_USB_SERIAL_CYBERJACK=m
315CONFIG_USB_SERIAL_XIRCOM=m315CONFIG_USB_SERIAL_XIRCOM=m
316CONFIG_USB_SERIAL_OMNINET=m316CONFIG_USB_SERIAL_OMNINET=m
317CONFIG_USB_RIO500=m
318CONFIG_USB_LEGOTOWER=m317CONFIG_USB_LEGOTOWER=m
319CONFIG_USB_LCD=m318CONFIG_USB_LCD=m
320CONFIG_USB_CYTHERM=m319CONFIG_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
241}241}
242EXPORT_SYMBOL_GPL(platform_get_resource_byname);242EXPORT_SYMBOL_GPL(platform_get_resource_byname);
243 243
244/**244static int __platform_get_irq_byname(struct platform_device *dev,
245 * platform_get_irq_byname - get an IRQ for a device by name245 const char *name)
246 * @dev: platform device
247 * @name: IRQ name
248 */
249int platform_get_irq_byname(struct platform_device *dev, const char *name)
250{246{
251 struct resource *r;247 struct resource *r;
252 248
@@ -262,11 +258,47 @@ int platform_get_irq_byname(struct platform_device *dev, const char *name) · 9 unmodified lines
262 if (r)258 if (r)
263 return r->start;259 return r->start;
264 260
265 dev_err(&dev->dev, "IRQ %s not found\n", name);
266 return -ENXIO;261 return -ENXIO;
267}262}
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 */
273int 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}
268EXPORT_SYMBOL_GPL(platform_get_irq_byname);283EXPORT_SYMBOL_GPL(platform_get_irq_byname);
269 284
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 */
295int platform_get_irq_byname_optional(struct platform_device *dev,
296 const char *name)
297{
298 return __platform_get_irq_byname(dev, name);
299}
300EXPORT_SYMBOL_GPL(platform_get_irq_byname_optional);
301
270/**302/**
271 * platform_add_devices - add a numbers of platform devices303 * platform_add_devices - add a numbers of platform devices
272 * @devs: array of platform devices to add304 * @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
643 dev->owner = NULL;643 dev->owner = NULL;
644 }644 }
645 645
646 if (is_present(dev))646 usb_autopm_put_interface(dev->interface);
647 usb_autopm_put_interface(dev->interface);
648 mutex_unlock(&dev->lock);647 mutex_unlock(&dev->lock);
649 return v4l2_fh_release(fp);648 return v4l2_fh_release(fp);
650}649}
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
159 wrap->plat_dev = platform_device_register_full(&plat_info);159 wrap->plat_dev = platform_device_register_full(&plat_info);
160 if (IS_ERR(wrap->plat_dev)) {160 if (IS_ERR(wrap->plat_dev)) {
161 pci_disable_device(pdev);161 pci_disable_device(pdev);
162 err = PTR_ERR(wrap->plat_dev);
162 kfree(wrap);163 kfree(wrap);
163 return PTR_ERR(wrap->plat_dev);164 return err;
164 }165 }
165 }166 }
166 167
drivers/usb/cdns3/core.c+19−1
@@ -160,10 +160,28 @@ static int cdns3_core_init_role(struct cdns3 *cdns) · 159 unmodified lines
160 if (ret)160 if (ret)
161 goto err;161 goto err;
162 162
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:
164 ret = cdns3_hw_role_switch(cdns);171 ret = cdns3_hw_role_switch(cdns);
165 if (ret)172 if (ret)
166 goto err;173 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;
167 }185 }
168 186
169 return ret;187 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
234static int cdns3_req_ep0_get_status(struct cdns3_device *priv_dev,234static int cdns3_req_ep0_get_status(struct cdns3_device *priv_dev,
235 struct usb_ctrlrequest *ctrl)235 struct usb_ctrlrequest *ctrl)
236{236{
237 struct cdns3_endpoint *priv_ep;
237 __le16 *response_pkt;238 __le16 *response_pkt;
238 u16 usb_status = 0;239 u16 usb_status = 0;
239 u32 recip;240 u32 recip;
241 u8 index;
240 242
241 recip = ctrl->bRequestType & USB_RECIP_MASK;243 recip = ctrl->bRequestType & USB_RECIP_MASK;
242 244
@@ -262,9 +264,13 @@ static int cdns3_req_ep0_get_status(struct cdns3_device *priv_dev, · 19 unmodified lines
262 case USB_RECIP_INTERFACE:264 case USB_RECIP_INTERFACE:
263 return cdns3_ep0_delegate_req(priv_dev, ctrl);265 return cdns3_ep0_delegate_req(priv_dev, ctrl);
264 case USB_RECIP_ENDPOINT:266 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 */
266 cdns3_select_ep(priv_dev, ctrl->wIndex);271 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))
268 usb_status = BIT(USB_ENDPOINT_HALT);274 usb_status = BIT(USB_ENDPOINT_HALT);
269 break;275 break;
270 default:276 default:
@@ -332,7 +338,7 @@ static int cdns3_ep0_feature_handle_device(struct cdns3_device *priv_dev, · 61 unmodified lines
332 * for sending status stage.338 * for sending status stage.
333 * This time should be less then 3ms.339 * This time should be less then 3ms.
334 */340 */
335 usleep_range(1000, 2000);341 mdelay(1);
336 cdns3_set_register_bit(&priv_dev->regs->usb_cmd,342 cdns3_set_register_bit(&priv_dev->regs->usb_cmd,
337 USB_CMD_STMODE |343 USB_CMD_STMODE |
338 USB_STS_TMODE_SEL(tmode - 1));344 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
2571 switch (max_speed) {2571 switch (max_speed) {
2572 case USB_SPEED_FULL:2572 case USB_SPEED_FULL:
2573 writel(USB_CONF_SFORCE_FS, &priv_dev->regs->usb_conf);2573 writel(USB_CONF_SFORCE_FS, &priv_dev->regs->usb_conf);
2574 writel(USB_CONF_USB3DIS, &priv_dev->regs->usb_conf);
2574 break;2575 break;
2575 case USB_SPEED_HIGH:2576 case USB_SPEED_HIGH:
2576 writel(USB_CONF_USB3DIS, &priv_dev->regs->usb_conf);2577 writel(USB_CONF_USB3DIS, &priv_dev->regs->usb_conf);
@@ -2662,6 +2663,13 @@ static int __cdns3_gadget_init(struct cdns3 *cdns) · 85 unmodified lines
2662{2663{
2663 int ret = 0;2664 int ret = 0;
2664 2665
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
2665 cdns3_drd_switch_gadget(cdns, 1);2673 cdns3_drd_switch_gadget(cdns, 1);
2666 pm_runtime_get_sync(cdns->dev);2674 pm_runtime_get_sync(cdns->dev);
2667 2675
drivers/usb/class/usblp.c+5−3
@@ -461,10 +461,12 @@ static int usblp_release(struct inode *inode, struct file *file) · 460 unmodified lines
461 461
462 mutex_lock(&usblp_mutex);462 mutex_lock(&usblp_mutex);
463 usblp->used = 0;463 usblp->used = 0;
464 if (usblp->present) {464 if (usblp->present)
465 usblp_unlink_urbs(usblp);465 usblp_unlink_urbs(usblp);
466 usb_autopm_put_interface(usblp->intf);466
467 } else /* finish cleanup from disconnect */467 usb_autopm_put_interface(usblp->intf);
468
469 if (!usblp->present) /* finish cleanup from disconnect */
468 usblp_cleanup(usblp);470 usblp_cleanup(usblp);
469 mutex_unlock(&usblp_mutex);471 mutex_unlock(&usblp_mutex);
470 return 0;472 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
139 struct platform_device *dwc3_pdev = to_platform_device(dwc->dev);139 struct platform_device *dwc3_pdev = to_platform_device(dwc->dev);
140 int irq;140 int irq;
141 141
142 irq = platform_get_irq_byname(dwc3_pdev, "otg");142 irq = platform_get_irq_byname_optional(dwc3_pdev, "otg");
143 if (irq > 0)143 if (irq > 0)
144 goto out;144 goto out;
145 145
146 if (irq == -EPROBE_DEFER)146 if (irq == -EPROBE_DEFER)
147 goto out;147 goto out;
148 148
149 irq = platform_get_irq_byname(dwc3_pdev, "dwc_usb3");149 irq = platform_get_irq_byname_optional(dwc3_pdev, "dwc_usb3");
150 if (irq > 0)150 if (irq > 0)
151 goto out;151 goto out;
152 152
@@ -157,9 +157,6 @@ static int dwc3_otg_get_irq(struct dwc3 *dwc) · 4 unmodified lines
157 if (irq > 0)157 if (irq > 0)
158 goto out;158 goto out;
159 159
160 if (irq != -EPROBE_DEFER)
161 dev_err(dwc->dev, "missing OTG IRQ\n");
162
163 if (!irq)160 if (!irq)
164 irq = -EINVAL;161 irq = -EINVAL;
165 162
drivers/usb/dwc3/gadget.c+2−5
@@ -3264,14 +3264,14 @@ static int dwc3_gadget_get_irq(struct dwc3 *dwc) · 3263 unmodified lines
3264 struct platform_device *dwc3_pdev = to_platform_device(dwc->dev);3264 struct platform_device *dwc3_pdev = to_platform_device(dwc->dev);
3265 int irq;3265 int irq;
3266 3266
3267 irq = platform_get_irq_byname(dwc3_pdev, "peripheral");3267 irq = platform_get_irq_byname_optional(dwc3_pdev, "peripheral");
3268 if (irq > 0)3268 if (irq > 0)
3269 goto out;3269 goto out;
3270 3270
3271 if (irq == -EPROBE_DEFER)3271 if (irq == -EPROBE_DEFER)
3272 goto out;3272 goto out;
3273 3273
3274 irq = platform_get_irq_byname(dwc3_pdev, "dwc_usb3");3274 irq = platform_get_irq_byname_optional(dwc3_pdev, "dwc_usb3");
3275 if (irq > 0)3275 if (irq > 0)
3276 goto out;3276 goto out;
3277 3277
@@ -3282,9 +3282,6 @@ static int dwc3_gadget_get_irq(struct dwc3 *dwc) · 4 unmodified lines
3282 if (irq > 0)3282 if (irq > 0)
3283 goto out;3283 goto out;
3284 3284
3285 if (irq != -EPROBE_DEFER)
3286 dev_err(dwc->dev, "missing peripheral IRQ\n");
3287
3288 if (!irq)3285 if (!irq)
3289 irq = -EINVAL;3286 irq = -EINVAL;
3290 3287
drivers/usb/dwc3/host.c+2−5
@@ -16,14 +16,14 @@ static int dwc3_host_get_irq(struct dwc3 *dwc) · 15 unmodified lines
16 struct platform_device *dwc3_pdev = to_platform_device(dwc->dev);16 struct platform_device *dwc3_pdev = to_platform_device(dwc->dev);
17 int irq;17 int irq;
18 18
19 irq = platform_get_irq_byname(dwc3_pdev, "host");19 irq = platform_get_irq_byname_optional(dwc3_pdev, "host");
20 if (irq > 0)20 if (irq > 0)
21 goto out;21 goto out;
22 22
23 if (irq == -EPROBE_DEFER)23 if (irq == -EPROBE_DEFER)
24 goto out;24 goto out;
25 25
26 irq = platform_get_irq_byname(dwc3_pdev, "dwc_usb3");26 irq = platform_get_irq_byname_optional(dwc3_pdev, "dwc_usb3");
27 if (irq > 0)27 if (irq > 0)
28 goto out;28 goto out;
29 29
@@ -34,9 +34,6 @@ static int dwc3_host_get_irq(struct dwc3 *dwc) · 4 unmodified lines
34 if (irq > 0)34 if (irq > 0)
35 goto out;35 goto out;
36 36
37 if (irq != -EPROBE_DEFER)
38 dev_err(dwc->dev, "missing host IRQ\n");
39
40 if (!irq)37 if (!irq)
41 irq = -EINVAL;38 irq = -EINVAL;
42 39
drivers/usb/gadget/udc/Kconfig+1−1
@@ -45,7 +45,7 @@ config USB_AT91 · 44 unmodified lines
45 45
46config USB_LPC32XX46config USB_LPC32XX
47 tristate "LPC32XX USB Peripheral Controller"47 tristate "LPC32XX USB Peripheral Controller"
48 depends on ARCH_LPC32XX48 depends on ARCH_LPC32XX || COMPILE_TEST
49 depends on I2C49 depends on I2C
50 select USB_ISP130150 select USB_ISP1301
51 help51 help
drivers/usb/gadget/udc/dummy_hcd.c+2−1
@@ -48,6 +48,7 @@ · 47 unmodified lines
48#define DRIVER_VERSION "02 May 2005"48#define DRIVER_VERSION "02 May 2005"
49 49
50#define POWER_BUDGET 500 /* in mA; use 8 for low-power port testing */50#define POWER_BUDGET 500 /* in mA; use 8 for low-power port testing */
51#define POWER_BUDGET_3 900 /* in mA */
51 52
52static const char driver_name[] = "dummy_hcd";53static const char driver_name[] = "dummy_hcd";
53static const char driver_desc[] = "USB Host+Gadget Emulator";54static 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
2432 dum_hcd->rh_state = DUMMY_RH_RUNNING;2433 dum_hcd->rh_state = DUMMY_RH_RUNNING;
2433 dum_hcd->stream_en_ep = 0;2434 dum_hcd->stream_en_ep = 0;
2434 INIT_LIST_HEAD(&dum_hcd->urbp_list);2435 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;
2436 dummy_hcd_to_hcd(dum_hcd)->state = HC_STATE_RUNNING;2437 dummy_hcd_to_hcd(dum_hcd)->state = HC_STATE_RUNNING;
2437 dummy_hcd_to_hcd(dum_hcd)->uses_new_polling = 1;2438 dummy_hcd_to_hcd(dum_hcd)->uses_new_polling = 1;
2438#ifdef CONFIG_USB_OTG2439#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
1151 u32 *p32, tmp, cbytes;1151 u32 *p32, tmp, cbytes;
1152 1152
1153 /* Use optimal data transfer method based on source address and size */1153 /* Use optimal data transfer method based on source address and size */
1154 switch (((u32) data) & 0x3) {1154 switch (((uintptr_t) data) & 0x3) {
1155 case 0: /* 32-bit aligned */1155 case 0: /* 32-bit aligned */
1156 p32 = (u32 *) data;1156 p32 = (u32 *) data;
1157 cbytes = (bytes & ~0x3);1157 cbytes = (bytes & ~0x3);
@@ -1252,7 +1252,7 @@ static void udc_stuff_fifo(struct lpc32xx_udc *udc, u8 *data, u32 bytes) · 94 unmodified lines
1252 u32 *p32, tmp, cbytes;1252 u32 *p32, tmp, cbytes;
1253 1253
1254 /* Use optimal data transfer method based on source address and size */1254 /* Use optimal data transfer method based on source address and size */
1255 switch (((u32) data) & 0x3) {1255 switch (((uintptr_t) data) & 0x3) {
1256 case 0: /* 32-bit aligned */1256 case 0: /* 32-bit aligned */
1257 p32 = (u32 *) data;1257 p32 = (u32 *) data;
1258 cbytes = (bytes & ~0x3);1258 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
57 ret = platform_device_add_properties(pdev, role_switch_props);57 ret = platform_device_add_properties(pdev, role_switch_props);
58 if (ret) {58 if (ret) {
59 dev_err(dev, "failed to register device properties\n");59 dev_err(dev, "failed to register device properties\n");
60 platform_device_put(pdev);
60 return ret;61 return ret;
61 }62 }
62 }63 }
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
3202 if (usb_urb_dir_out(urb)) {3202 if (usb_urb_dir_out(urb)) {
3203 len = sg_pcopy_to_buffer(urb->sg, urb->num_sgs,3203 len = sg_pcopy_to_buffer(urb->sg, urb->num_sgs,
3204 seg->bounce_buf, new_buff_len, enqd_len);3204 seg->bounce_buf, new_buff_len, enqd_len);
3205 if (len != seg->bounce_len)3205 if (len != new_buff_len)
3206 xhci_warn(xhci,3206 xhci_warn(xhci,
3207 "WARN Wrong bounce buffer write length: %zu != %d\n",3207 "WARN Wrong bounce buffer write length: %zu != %d\n",
3208 len, seg->bounce_len);3208 len, new_buff_len);
3209 seg->bounce_dma = dma_map_single(dev, seg->bounce_buf,3209 seg->bounce_dma = dma_map_single(dev, seg->bounce_buf,
3210 max_pkt, DMA_TO_DEVICE);3210 max_pkt, DMA_TO_DEVICE);
3211 } else {3211 } 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
1032 writel(command, &xhci->op_regs->command);1032 writel(command, &xhci->op_regs->command);
1033 xhci->broken_suspend = 0;1033 xhci->broken_suspend = 0;
1034 if (xhci_handshake(&xhci->op_regs->status,1034 if (xhci_handshake(&xhci->op_regs->status,
1035 STS_SAVE, 0, 10 * 1000)) {1035 STS_SAVE, 0, 20 * 1000)) {
1036 /*1036 /*
1037 * AMD SNPS xHC 3.0 occasionally does not clear the1037 * AMD SNPS xHC 3.0 occasionally does not clear the
1038 * SSS bit of USBSTS and when driver tries to poll1038 * 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
1108 hibernated = true;1108 hibernated = true;
1109 1109
1110 if (!hibernated) {1110 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 }
1111 /* step 1: restore register */1123 /* step 1: restore register */
1112 xhci_restore_registers(xhci);1124 xhci_restore_registers(xhci);
1113 /* step 2: initialize command ring buffer */1125 /* step 2: initialize command ring buffer */
@@ -3083,6 +3095,7 @@ static void xhci_endpoint_reset(struct usb_hcd *hcd, · 1969 unmodified lines
3083 unsigned int ep_index;3095 unsigned int ep_index;
3084 unsigned long flags;3096 unsigned long flags;
3085 u32 ep_flag;3097 u32 ep_flag;
3098 int err;
3086 3099
3087 xhci = hcd_to_xhci(hcd);3100 xhci = hcd_to_xhci(hcd);
3088 if (!host_ep->hcpriv)3101 if (!host_ep->hcpriv)
@@ -3142,7 +3155,17 @@ static void xhci_endpoint_reset(struct usb_hcd *hcd, · 53 unmodified lines
3142 xhci_free_command(xhci, cfg_cmd);3155 xhci_free_command(xhci, cfg_cmd);
3143 goto cleanup;3156 goto cleanup;
3144 }3157 }
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
3146 xhci_ring_cmd_db(xhci);3169 xhci_ring_cmd_db(xhci);
3147 spin_unlock_irqrestore(&xhci->lock, flags);3170 spin_unlock_irqrestore(&xhci->lock, flags);
3148 3171
@@ -3156,8 +3179,16 @@ static void xhci_endpoint_reset(struct usb_hcd *hcd, · 7 unmodified lines
3156 ctrl_ctx, ep_flag, ep_flag);3179 ctrl_ctx, ep_flag, ep_flag);
3157 xhci_endpoint_copy(xhci, cfg_cmd->in_ctx, vdev->out_ctx, ep_index);3180 xhci_endpoint_copy(xhci, cfg_cmd->in_ctx, vdev->out_ctx, ep_index);
3158 3181
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,
3160 udev->slot_id, false);3183 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
3161 xhci_ring_cmd_db(xhci);3192 xhci_ring_cmd_db(xhci);
3162 spin_unlock_irqrestore(&xhci->lock, flags);3193 spin_unlock_irqrestore(&xhci->lock, flags);
3163 3194
@@ -4674,12 +4705,12 @@ static int xhci_update_timeout_for_endpoint(struct xhci_hcd *xhci, · 1510 unmodified lines
4674 alt_timeout = xhci_call_host_update_timeout_for_endpoint(xhci, udev,4705 alt_timeout = xhci_call_host_update_timeout_for_endpoint(xhci, udev,
4675 desc, state, timeout);4706 desc, state, timeout);
4676 4707
4677 /* If we found we can't enable hub-initiated LPM, or4708 /* If we found we can't enable hub-initiated LPM, and
4678 * the U1 or U2 exit latency was too high to allow4709 * 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.
4680 */4712 */
4681 if (alt_timeout == USB3_LPM_DISABLED ||4713 if (alt_timeout == USB3_LPM_DISABLED) {
4682 alt_timeout == USB3_LPM_DEVICE_INITIATED) {
4683 *timeout = alt_timeout;4714 *timeout = alt_timeout;
4684 return -E2BIG;4715 return -E2BIG;
4685 }4716 }
@@ -4790,10 +4821,12 @@ static u16 xhci_calculate_lpm_timeout(struct usb_hcd *hcd, · 104 unmodified lines
4790 if (intf->dev.driver) {4821 if (intf->dev.driver) {
4791 driver = to_usb_driver(intf->dev.driver);4822 driver = to_usb_driver(intf->dev.driver);
4792 if (driver && driver->disable_hub_initiated_lpm) {4823 if (driver && driver->disable_hub_initiated_lpm) {
4793 dev_dbg(&udev->dev, "Hub-initiated %s disabled "4824 dev_dbg(&udev->dev, "Hub-initiated %s disabled at request of driver %s\n",
4794 "at request of driver %s\n",4825 state_name, driver->name);
4795 state_name, driver->name);4826 timeout = xhci_get_timeout_no_hub_lpm(udev,
4796 return xhci_get_timeout_no_hub_lpm(udev, state);4827 state);
4828 if (timeout == USB3_LPM_DISABLED)
4829 return timeout;
4797 }4830 }
4798 }4831 }
4799 4832
@@ -5077,11 +5110,18 @@ int xhci_gen_setup(struct usb_hcd *hcd, xhci_get_quirks_t get_quirks) · 277 unmodified lines
5077 hcd->has_tt = 1;5110 hcd->has_tt = 1;
5078 } else {5111 } else {
5079 /*5112 /*
5080 * Some 3.1 hosts return sbrn 0x30, use xhci supported protocol5113 * Early xHCI 1.1 spec did not mention USB 3.1 capable hosts
5081 * minor revision instead of sbrn. Minor revision is a two digit5114 * should return 0x31 for sbrn, or that the minor revision
5082 * BCD containing minor and sub-minor numbers, only show minor.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.
5083 */5120 */
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;
5085 5125
5086 switch (minor_rev) {5126 switch (minor_rev) {
5087 case 2:5127 case 2:
@@ -5198,8 +5238,16 @@ static void xhci_clear_tt_buffer_complete(struct usb_hcd *hcd, · 110 unmodified lines
5198 unsigned int ep_index;5238 unsigned int ep_index;
5199 unsigned long flags;5239 unsigned long flags;
5200 5240
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
5201 xhci = hcd_to_xhci(hcd);5247 xhci = hcd_to_xhci(hcd);
5202 udev = (struct usb_device *)ep->hcpriv;5248 udev = (struct usb_device *)ep->hcpriv;
5249 if (!udev)
5250 return;
5203 slot_id = udev->slot_id;5251 slot_id = udev->slot_id;
5204 ep_index = xhci_get_endpoint_index(&ep->desc);5252 ep_index = xhci_get_endpoint_index(&ep->desc);
5205 5253
drivers/usb/image/microtek.c+4−0
@@ -716,6 +716,10 @@ static int mts_usb_probe(struct usb_interface *intf, · 715 unmodified lines
716 716
717 }717 }
718 718
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 }
719 723
720 if ( ep_out == -1 ) {724 if ( ep_out == -1 ) {
721 MTS_WARNING( "couldn't find an output bulk endpoint. Bailing out.\n" );725 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
47 To compile this driver as a module, choose M here: the47 To compile this driver as a module, choose M here: the
48 module will be called usbsevseg.48 module will be called usbsevseg.
49 49
50config 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
60config USB_LEGOTOWER50config USB_LEGOTOWER
61 tristate "USB Lego Infrared Tower support"51 tristate "USB Lego Infrared Tower support"
62 help52 help
drivers/usb/misc/Makefile+0−1
@@ -17,7 +17,6 @@ obj-$(CONFIG_USB_ISIGHTFW) += isight_firmware.o · 16 unmodified lines
17obj-$(CONFIG_USB_LCD) += usblcd.o17obj-$(CONFIG_USB_LCD) += usblcd.o
18obj-$(CONFIG_USB_LD) += ldusb.o18obj-$(CONFIG_USB_LD) += ldusb.o
19obj-$(CONFIG_USB_LEGOTOWER) += legousbtower.o19obj-$(CONFIG_USB_LEGOTOWER) += legousbtower.o
20obj-$(CONFIG_USB_RIO500) += rio500.o
21obj-$(CONFIG_USB_TEST) += usbtest.o20obj-$(CONFIG_USB_TEST) += usbtest.o
22obj-$(CONFIG_USB_EHSET_TEST_FIXTURE) += ehset.o21obj-$(CONFIG_USB_EHSET_TEST_FIXTURE) += ehset.o
23obj-$(CONFIG_USB_TRANCEVIBRATOR) += trancevibrator.o22obj-$(CONFIG_USB_TRANCEVIBRATOR) += trancevibrator.o
drivers/usb/misc/adutux.c+15−9
@@ -75,6 +75,7 @@ struct adu_device { · 74 unmodified lines
75 char serial_number[8];75 char serial_number[8];
76 76
77 int open_count; /* number of times this port has been opened */77 int open_count; /* number of times this port has been opened */
78 unsigned long disconnected:1;
78 79
79 char *read_buffer_primary;80 char *read_buffer_primary;
80 int read_buffer_length;81 int read_buffer_length;
@@ -116,7 +117,7 @@ static void adu_abort_transfers(struct adu_device *dev) · 35 unmodified lines
116{117{
117 unsigned long flags;118 unsigned long flags;
118 119
119 if (dev->udev == NULL)120 if (dev->disconnected)
120 return;121 return;
121 122
122 /* shutdown transfer */123 /* shutdown transfer */
@@ -148,6 +149,7 @@ static void adu_delete(struct adu_device *dev) · 25 unmodified lines
148 kfree(dev->read_buffer_secondary);149 kfree(dev->read_buffer_secondary);
149 kfree(dev->interrupt_in_buffer);150 kfree(dev->interrupt_in_buffer);
150 kfree(dev->interrupt_out_buffer);151 kfree(dev->interrupt_out_buffer);
152 usb_put_dev(dev->udev);
151 kfree(dev);153 kfree(dev);
152}154}
153 155
@@ -243,7 +245,7 @@ static int adu_open(struct inode *inode, struct file *file) · 89 unmodified lines
243 }245 }
244 246
245 dev = usb_get_intfdata(interface);247 dev = usb_get_intfdata(interface);
246 if (!dev || !dev->udev) {248 if (!dev) {
247 retval = -ENODEV;249 retval = -ENODEV;
248 goto exit_no_device;250 goto exit_no_device;
249 }251 }
@@ -326,7 +328,7 @@ static int adu_release(struct inode *inode, struct file *file) · 76 unmodified lines
326 }328 }
327 329
328 adu_release_internal(dev);330 adu_release_internal(dev);
329 if (dev->udev == NULL) {331 if (dev->disconnected) {
330 /* the device was unplugged before the file was released */332 /* the device was unplugged before the file was released */
331 if (!dev->open_count) /* ... and we're the last user */333 if (!dev->open_count) /* ... and we're the last user */
332 adu_delete(dev);334 adu_delete(dev);
@@ -354,7 +356,7 @@ static ssize_t adu_read(struct file *file, __user char *buffer, size_t count, · 21 unmodified lines
354 return -ERESTARTSYS;356 return -ERESTARTSYS;
355 357
356 /* verify that the device wasn't unplugged */358 /* verify that the device wasn't unplugged */
357 if (dev->udev == NULL) {359 if (dev->disconnected) {
358 retval = -ENODEV;360 retval = -ENODEV;
359 pr_err("No device or device unplugged %d\n", retval);361 pr_err("No device or device unplugged %d\n", retval);
360 goto exit;362 goto exit;
@@ -518,7 +520,7 @@ static ssize_t adu_write(struct file *file, const __user char *buffer, · 157 unmodified lines
518 goto exit_nolock;520 goto exit_nolock;
519 521
520 /* verify that the device wasn't unplugged */522 /* verify that the device wasn't unplugged */
521 if (dev->udev == NULL) {523 if (dev->disconnected) {
522 retval = -ENODEV;524 retval = -ENODEV;
523 pr_err("No device or device unplugged %d\n", retval);525 pr_err("No device or device unplugged %d\n", retval);
524 goto exit;526 goto exit;
@@ -663,7 +665,7 @@ static int adu_probe(struct usb_interface *interface, · 138 unmodified lines
663 665
664 mutex_init(&dev->mtx);666 mutex_init(&dev->mtx);
665 spin_lock_init(&dev->buflock);667 spin_lock_init(&dev->buflock);
666 dev->udev = udev;668 dev->udev = usb_get_dev(udev);
667 init_waitqueue_head(&dev->read_wait);669 init_waitqueue_head(&dev->read_wait);
668 init_waitqueue_head(&dev->write_wait);670 init_waitqueue_head(&dev->write_wait);
669 671
@@ -762,14 +764,18 @@ static void adu_disconnect(struct usb_interface *interface) · 92 unmodified lines
762 764
763 dev = usb_get_intfdata(interface);765 dev = usb_get_intfdata(interface);
764 766
765 mutex_lock(&dev->mtx); /* not interruptible */
766 dev->udev = NULL; /* poison */
767 usb_deregister_dev(interface, &adu_class);767 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);
769 771
770 mutex_lock(&adutux_mutex);772 mutex_lock(&adutux_mutex);
771 usb_set_intfdata(interface, NULL);773 usb_set_intfdata(interface, NULL);
772 774
775 mutex_lock(&dev->mtx); /* not interruptible */
776 dev->disconnected = 1;
777 mutex_unlock(&dev->mtx);
778
773 /* if the device is not opened, then we clean up right now */779 /* if the device is not opened, then we clean up right now */
774 if (!dev->open_count)780 if (!dev->open_count)
775 adu_delete(dev);781 adu_delete(dev);
drivers/usb/misc/chaoskey.c+3−2
@@ -98,6 +98,7 @@ static void chaoskey_free(struct chaoskey *dev) · 97 unmodified lines
98 usb_free_urb(dev->urb);98 usb_free_urb(dev->urb);
99 kfree(dev->name);99 kfree(dev->name);
100 kfree(dev->buf);100 kfree(dev->buf);
101 usb_put_intf(dev->interface);
101 kfree(dev);102 kfree(dev);
102 }103 }
103}104}
@@ -145,6 +146,8 @@ static int chaoskey_probe(struct usb_interface *interface, · 41 unmodified lines
145 if (dev == NULL)146 if (dev == NULL)
146 goto out;147 goto out;
147 148
149 dev->interface = usb_get_intf(interface);
150
148 dev->buf = kmalloc(size, GFP_KERNEL);151 dev->buf = kmalloc(size, GFP_KERNEL);
149 152
150 if (dev->buf == NULL)153 if (dev->buf == NULL)
@@ -174,8 +177,6 @@ static int chaoskey_probe(struct usb_interface *interface, · 23 unmodified lines
174 goto out;177 goto out;
175 }178 }
176 179
177 dev->interface = interface;
178
179 dev->in_ep = in_ep;180 dev->in_ep = in_ep;
180 181
181 if (le16_to_cpu(udev->descriptor.idVendor) != ALEA_VENDOR_ID)182 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
54MODULE_DESCRIPTION(DRIVER_DESC);54MODULE_DESCRIPTION(DRIVER_DESC);
55MODULE_LICENSE("GPL");55MODULE_LICENSE("GPL");
56 56
57/* Module parameters */
58static DEFINE_MUTEX(iowarrior_mutex);
59
60static struct usb_driver iowarrior_driver;57static struct usb_driver iowarrior_driver;
61static DEFINE_MUTEX(iowarrior_open_disc_lock);
62 58
63/*--------------*/59/*--------------*/
64/* data */60/* data */
@@ -87,6 +83,7 @@ struct iowarrior { · 22 unmodified lines
87 char chip_serial[9]; /* the serial number string of the chip connected */83 char chip_serial[9]; /* the serial number string of the chip connected */
88 int report_size; /* number of bytes in a report */84 int report_size; /* number of bytes in a report */
89 u16 product_id;85 u16 product_id;
86 struct usb_anchor submitted;
90};87};
91 88
92/*--------------*/89/*--------------*/
@@ -243,6 +240,7 @@ static inline void iowarrior_delete(struct iowarrior *dev) · 150 unmodified lines
243 kfree(dev->int_in_buffer);240 kfree(dev->int_in_buffer);
244 usb_free_urb(dev->int_in_urb);241 usb_free_urb(dev->int_in_urb);
245 kfree(dev->read_queue);242 kfree(dev->read_queue);
243 usb_put_intf(dev->interface);
246 kfree(dev);244 kfree(dev);
247}245}
248 246
@@ -424,11 +422,13 @@ static ssize_t iowarrior_write(struct file *file, · 175 unmodified lines
424 retval = -EFAULT;422 retval = -EFAULT;
425 goto error;423 goto error;
426 }424 }
425 usb_anchor_urb(int_out_urb, &dev->submitted);
427 retval = usb_submit_urb(int_out_urb, GFP_KERNEL);426 retval = usb_submit_urb(int_out_urb, GFP_KERNEL);
428 if (retval) {427 if (retval) {
429 dev_dbg(&dev->interface->dev,428 dev_dbg(&dev->interface->dev,
430 "submit error %d for urb nr.%d\n",429 "submit error %d for urb nr.%d\n",
431 retval, atomic_read(&dev->write_busy));430 retval, atomic_read(&dev->write_busy));
431 usb_unanchor_urb(int_out_urb);
432 goto error;432 goto error;
433 }433 }
434 /* submit was ok */434 /* submit was ok */
@@ -477,8 +477,6 @@ static long iowarrior_ioctl(struct file *file, unsigned int cmd, · 42 unmodified lines
477 if (!buffer)477 if (!buffer)
478 return -ENOMEM;478 return -ENOMEM;
479 479
480 /* lock this object */
481 mutex_lock(&iowarrior_mutex);
482 mutex_lock(&dev->mutex);480 mutex_lock(&dev->mutex);
483 481
484 /* verify that the device wasn't unplugged */482 /* verify that the device wasn't unplugged */
@@ -571,7 +569,6 @@ static long iowarrior_ioctl(struct file *file, unsigned int cmd, · 86 unmodified lines
571error_out:569error_out:
572 /* unlock the device */570 /* unlock the device */
573 mutex_unlock(&dev->mutex);571 mutex_unlock(&dev->mutex);
574 mutex_unlock(&iowarrior_mutex);
575 kfree(buffer);572 kfree(buffer);
576 return retval;573 return retval;
577}574}
@@ -586,27 +583,20 @@ static int iowarrior_open(struct inode *inode, struct file *file) · 8 unmodified lines
586 int subminor;583 int subminor;
587 int retval = 0;584 int retval = 0;
588 585
589 mutex_lock(&iowarrior_mutex);
590 subminor = iminor(inode);586 subminor = iminor(inode);
591 587
592 interface = usb_find_interface(&iowarrior_driver, subminor);588 interface = usb_find_interface(&iowarrior_driver, subminor);
593 if (!interface) {589 if (!interface) {
594 mutex_unlock(&iowarrior_mutex);590 pr_err("%s - error, can't find device for minor %d\n",
595 printk(KERN_ERR "%s - error, can't find device for minor %d\n",
596 __func__, subminor);591 __func__, subminor);
597 return -ENODEV;592 return -ENODEV;
598 }593 }
599 594
600 mutex_lock(&iowarrior_open_disc_lock);
601 dev = usb_get_intfdata(interface);595 dev = usb_get_intfdata(interface);
602 if (!dev) {596 if (!dev)
603 mutex_unlock(&iowarrior_open_disc_lock);
604 mutex_unlock(&iowarrior_mutex);
605 return -ENODEV;597 return -ENODEV;
606 }
607 598
608 mutex_lock(&dev->mutex);599 mutex_lock(&dev->mutex);
609 mutex_unlock(&iowarrior_open_disc_lock);
610 600
611 /* Only one process can open each device, no sharing. */601 /* Only one process can open each device, no sharing. */
612 if (dev->opened) {602 if (dev->opened) {
@@ -628,7 +618,6 @@ static int iowarrior_open(struct inode *inode, struct file *file) · 15 unmodified lines
628 618
629out:619out:
630 mutex_unlock(&dev->mutex);620 mutex_unlock(&dev->mutex);
631 mutex_unlock(&iowarrior_mutex);
632 return retval;621 return retval;
633}622}
634 623
@@ -764,11 +753,13 @@ static int iowarrior_probe(struct usb_interface *interface, · 129 unmodified lines
764 init_waitqueue_head(&dev->write_wait);753 init_waitqueue_head(&dev->write_wait);
765 754
766 dev->udev = udev;755 dev->udev = udev;
767 dev->interface = interface;756 dev->interface = usb_get_intf(interface);
768 757
769 iface_desc = interface->cur_altsetting;758 iface_desc = interface->cur_altsetting;
770 dev->product_id = le16_to_cpu(udev->descriptor.idProduct);759 dev->product_id = le16_to_cpu(udev->descriptor.idProduct);
771 760
761 init_usb_anchor(&dev->submitted);
762
772 res = usb_find_last_int_in_endpoint(iface_desc, &dev->int_in_endpoint);763 res = usb_find_last_int_in_endpoint(iface_desc, &dev->int_in_endpoint);
773 if (res) {764 if (res) {
774 dev_err(&interface->dev, "no interrupt-in endpoint found\n");765 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
836 if (retval) {827 if (retval) {
837 /* something prevented us from registering this driver */828 /* something prevented us from registering this driver */
838 dev_err(&interface->dev, "Not able to get a minor for this device.\n");829 dev_err(&interface->dev, "Not able to get a minor for this device.\n");
839 usb_set_intfdata(interface, NULL);
840 goto error;830 goto error;
841 }831 }
842 832
@@ -860,26 +850,15 @@ error: · 17 unmodified lines
860 */850 */
861static void iowarrior_disconnect(struct usb_interface *interface)851static void iowarrior_disconnect(struct usb_interface *interface)
862{852{
863 struct iowarrior *dev;853 struct iowarrior *dev = usb_get_intfdata(interface);
864 int minor;854 int minor = dev->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*/
875 855
876 usb_deregister_dev(interface, &iowarrior_class);856 usb_deregister_dev(interface, &iowarrior_class);
877 857
878 mutex_lock(&dev->mutex);858 mutex_lock(&dev->mutex);
879 859
880 /* prevent device read, write and ioctl */860 /* prevent device read, write and ioctl */
881 861 dev->present = 0;
882 mutex_unlock(&dev->mutex);
883 862
884 if (dev->opened) {863 if (dev->opened) {
885 /* There is a process that holds a filedescriptor to the device ,864 /* 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
887 Deleting the device is postponed until close() was called.866 Deleting the device is postponed until close() was called.
888 */867 */
889 usb_kill_urb(dev->int_in_urb);868 usb_kill_urb(dev->int_in_urb);
869 usb_kill_anchored_urbs(&dev->submitted);
890 wake_up_interruptible(&dev->read_wait);870 wake_up_interruptible(&dev->read_wait);
891 wake_up_interruptible(&dev->write_wait);871 wake_up_interruptible(&dev->write_wait);
872 mutex_unlock(&dev->mutex);
892 } else {873 } else {
893 /* no process is using the device, cleanup now */874 /* no process is using the device, cleanup now */
875 mutex_unlock(&dev->mutex);
894 iowarrior_delete(dev);876 iowarrior_delete(dev);
895 }877 }
896 878
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
153struct ld_usb {153struct ld_usb {
154 struct mutex mutex; /* locks this structure */154 struct mutex mutex; /* locks this structure */
155 struct usb_interface *intf; /* save off the usb interface pointer */155 struct usb_interface *intf; /* save off the usb interface pointer */
156 unsigned long disconnected:1;
156 157
157 int open_count; /* number of times this port has been opened */158 int open_count; /* number of times this port has been opened */
158 159
@@ -192,12 +193,10 @@ static void ld_usb_abort_transfers(struct ld_usb *dev) · 33 unmodified lines
192 /* shutdown transfer */193 /* shutdown transfer */
193 if (dev->interrupt_in_running) {194 if (dev->interrupt_in_running) {
194 dev->interrupt_in_running = 0;195 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);
197 }197 }
198 if (dev->interrupt_out_busy)198 if (dev->interrupt_out_busy)
199 if (dev->intf)199 usb_kill_urb(dev->interrupt_out_urb);
200 usb_kill_urb(dev->interrupt_out_urb);
201}200}
202 201
203/**202/**
@@ -205,8 +204,6 @@ static void ld_usb_abort_transfers(struct ld_usb *dev) · 1 unmodified line
205 */204 */
206static void ld_usb_delete(struct ld_usb *dev)205static void ld_usb_delete(struct ld_usb *dev)
207{206{
208 ld_usb_abort_transfers(dev);
209
210 /* free data structures */207 /* free data structures */
211 usb_free_urb(dev->interrupt_in_urb);208 usb_free_urb(dev->interrupt_in_urb);
212 usb_free_urb(dev->interrupt_out_urb);209 usb_free_urb(dev->interrupt_out_urb);
@@ -263,7 +260,7 @@ static void ld_usb_interrupt_in_callback(struct urb *urb) · 50 unmodified lines
263 260
264resubmit:261resubmit:
265 /* resubmit if we're still running */262 /* 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) {
267 retval = usb_submit_urb(dev->interrupt_in_urb, GFP_ATOMIC);264 retval = usb_submit_urb(dev->interrupt_in_urb, GFP_ATOMIC);
268 if (retval) {265 if (retval) {
269 dev_err(&dev->intf->dev,266 dev_err(&dev->intf->dev,
@@ -392,7 +389,7 @@ static int ld_usb_release(struct inode *inode, struct file *file) · 122 unmodified lines
392 retval = -ENODEV;389 retval = -ENODEV;
393 goto unlock_exit;390 goto unlock_exit;
394 }391 }
395 if (dev->intf == NULL) {392 if (dev->disconnected) {
396 /* the device was unplugged before the file was released */393 /* the device was unplugged before the file was released */
397 mutex_unlock(&dev->mutex);394 mutex_unlock(&dev->mutex);
398 /* unlock here as ld_usb_delete frees dev */395 /* 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
423 420
424 dev = file->private_data;421 dev = file->private_data;
425 422
426 if (!dev->intf)423 if (dev->disconnected)
427 return EPOLLERR | EPOLLHUP;424 return EPOLLERR | EPOLLHUP;
428 425
429 poll_wait(file, &dev->read_wait, wait);426 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
462 }459 }
463 460
464 /* verify that the device wasn't unplugged */461 /* verify that the device wasn't unplugged */
465 if (dev->intf == NULL) {462 if (dev->disconnected) {
466 retval = -ENODEV;463 retval = -ENODEV;
467 printk(KERN_ERR "ldusb: No device or device unplugged %d\n", retval);464 printk(KERN_ERR "ldusb: No device or device unplugged %d\n", retval);
468 goto unlock_exit;465 goto unlock_exit;
@@ -542,7 +539,7 @@ static ssize_t ld_usb_write(struct file *file, const char __user *buffer, · 73 unmodified lines
542 }539 }
543 540
544 /* verify that the device wasn't unplugged */541 /* verify that the device wasn't unplugged */
545 if (dev->intf == NULL) {542 if (dev->disconnected) {
546 retval = -ENODEV;543 retval = -ENODEV;
547 printk(KERN_ERR "ldusb: No device or device unplugged %d\n", retval);544 printk(KERN_ERR "ldusb: No device or device unplugged %d\n", retval);
548 goto unlock_exit;545 goto unlock_exit;
@@ -764,6 +761,9 @@ static void ld_usb_disconnect(struct usb_interface *intf) · 215 unmodified lines
764 /* give back our minor */761 /* give back our minor */
765 usb_deregister_dev(intf, &ld_usb_class);762 usb_deregister_dev(intf, &ld_usb_class);
766 763
764 usb_poison_urb(dev->interrupt_in_urb);
765 usb_poison_urb(dev->interrupt_out_urb);
766
767 mutex_lock(&dev->mutex);767 mutex_lock(&dev->mutex);
768 768
769 /* if the device is not opened, then we clean up right now */769 /* 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
771 mutex_unlock(&dev->mutex);771 mutex_unlock(&dev->mutex);
772 ld_usb_delete(dev);772 ld_usb_delete(dev);
773 } else {773 } else {
774 dev->intf = NULL;774 dev->disconnected = 1;
775 /* wake up pollers */775 /* wake up pollers */
776 wake_up_interruptible_all(&dev->read_wait);776 wake_up_interruptible_all(&dev->read_wait);
777 wake_up_interruptible_all(&dev->write_wait);777 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
179};179};
180 180
181MODULE_DEVICE_TABLE (usb, tower_table);181MODULE_DEVICE_TABLE (usb, tower_table);
182static DEFINE_MUTEX(open_disc_mutex);
183 182
184#define LEGO_USB_TOWER_MINOR_BASE 160183#define LEGO_USB_TOWER_MINOR_BASE 160
185 184
@@ -191,6 +190,7 @@ struct lego_usb_tower { · 5 unmodified lines
191 unsigned char minor; /* the starting minor number for this device */190 unsigned char minor; /* the starting minor number for this device */
192 191
193 int open_count; /* number of times this port has been opened */192 int open_count; /* number of times this port has been opened */
193 unsigned long disconnected:1;
194 194
195 char* read_buffer;195 char* read_buffer;
196 size_t read_buffer_length; /* this much came in */196 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
290 */290 */
291static inline void tower_delete (struct lego_usb_tower *dev)291static inline void tower_delete (struct lego_usb_tower *dev)
292{292{
293 tower_abort_transfers (dev);
294
295 /* free data structures */293 /* free data structures */
296 usb_free_urb(dev->interrupt_in_urb);294 usb_free_urb(dev->interrupt_in_urb);
297 usb_free_urb(dev->interrupt_out_urb);295 usb_free_urb(dev->interrupt_out_urb);
298 kfree (dev->read_buffer);296 kfree (dev->read_buffer);
299 kfree (dev->interrupt_in_buffer);297 kfree (dev->interrupt_in_buffer);
300 kfree (dev->interrupt_out_buffer);298 kfree (dev->interrupt_out_buffer);
299 usb_put_dev(dev->udev);
301 kfree (dev);300 kfree (dev);
302}301}
303 302
@@ -332,18 +331,14 @@ static int tower_open (struct inode *inode, struct file *file) · 28 unmodified lines
332 goto exit;331 goto exit;
333 }332 }
334 333
335 mutex_lock(&open_disc_mutex);
336 dev = usb_get_intfdata(interface);334 dev = usb_get_intfdata(interface);
337
338 if (!dev) {335 if (!dev) {
339 mutex_unlock(&open_disc_mutex);
340 retval = -ENODEV;336 retval = -ENODEV;
341 goto exit;337 goto exit;
342 }338 }
343 339
344 /* lock this device */340 /* lock this device */
345 if (mutex_lock_interruptible(&dev->lock)) {341 if (mutex_lock_interruptible(&dev->lock)) {
346 mutex_unlock(&open_disc_mutex);
347 retval = -ERESTARTSYS;342 retval = -ERESTARTSYS;
348 goto exit;343 goto exit;
349 }344 }
@@ -351,12 +346,9 @@ static int tower_open (struct inode *inode, struct file *file) · 1 unmodified line
351 346
352 /* allow opening only once */347 /* allow opening only once */
353 if (dev->open_count) {348 if (dev->open_count) {
354 mutex_unlock(&open_disc_mutex);
355 retval = -EBUSY;349 retval = -EBUSY;
356 goto unlock_exit;350 goto unlock_exit;
357 }351 }
358 dev->open_count = 1;
359 mutex_unlock(&open_disc_mutex);
360 352
361 /* reset the tower */353 /* reset the tower */
362 result = usb_control_msg (dev->udev,354 result = usb_control_msg (dev->udev,
@@ -396,13 +388,14 @@ static int tower_open (struct inode *inode, struct file *file) · 33 unmodified lines
396 dev_err(&dev->udev->dev,388 dev_err(&dev->udev->dev,
397 "Couldn't submit interrupt_in_urb %d\n", retval);389 "Couldn't submit interrupt_in_urb %d\n", retval);
398 dev->interrupt_in_running = 0;390 dev->interrupt_in_running = 0;
399 dev->open_count = 0;
400 goto unlock_exit;391 goto unlock_exit;
401 }392 }
402 393
403 /* save device in the file's private structure */394 /* save device in the file's private structure */
404 file->private_data = dev;395 file->private_data = dev;
405 396
397 dev->open_count = 1;
398
406unlock_exit:399unlock_exit:
407 mutex_unlock(&dev->lock);400 mutex_unlock(&dev->lock);
408 401
@@ -423,10 +416,9 @@ static int tower_release (struct inode *inode, struct file *file) · 14 unmodified lines
423 416
424 if (dev == NULL) {417 if (dev == NULL) {
425 retval = -ENODEV;418 retval = -ENODEV;
426 goto exit_nolock;419 goto exit;
427 }420 }
428 421
429 mutex_lock(&open_disc_mutex);
430 if (mutex_lock_interruptible(&dev->lock)) {422 if (mutex_lock_interruptible(&dev->lock)) {
431 retval = -ERESTARTSYS;423 retval = -ERESTARTSYS;
432 goto exit;424 goto exit;
@@ -438,7 +430,8 @@ static int tower_release (struct inode *inode, struct file *file) · 5 unmodified lines
438 retval = -ENODEV;430 retval = -ENODEV;
439 goto unlock_exit;431 goto unlock_exit;
440 }432 }
441 if (dev->udev == NULL) {433
434 if (dev->disconnected) {
442 /* the device was unplugged before the file was released */435 /* the device was unplugged before the file was released */
443 436
444 /* unlock here as tower_delete frees dev */437 /* unlock here as tower_delete frees dev */
@@ -456,10 +449,7 @@ static int tower_release (struct inode *inode, struct file *file) · 11 unmodified lines
456 449
457unlock_exit:450unlock_exit:
458 mutex_unlock(&dev->lock);451 mutex_unlock(&dev->lock);
459
460exit:452exit:
461 mutex_unlock(&open_disc_mutex);
462exit_nolock:
463 return retval;453 return retval;
464}454}
465 455
@@ -477,10 +467,9 @@ static void tower_abort_transfers (struct lego_usb_tower *dev) · 11 unmodified lines
477 if (dev->interrupt_in_running) {467 if (dev->interrupt_in_running) {
478 dev->interrupt_in_running = 0;468 dev->interrupt_in_running = 0;
479 mb();469 mb();
480 if (dev->udev)470 usb_kill_urb(dev->interrupt_in_urb);
481 usb_kill_urb (dev->interrupt_in_urb);
482 }471 }
483 if (dev->interrupt_out_busy && dev->udev)472 if (dev->interrupt_out_busy)
484 usb_kill_urb(dev->interrupt_out_urb);473 usb_kill_urb(dev->interrupt_out_urb);
485}474}
486 475
@@ -516,7 +505,7 @@ static __poll_t tower_poll (struct file *file, poll_table *wait) · 29 unmodified lines
516 505
517 dev = file->private_data;506 dev = file->private_data;
518 507
519 if (!dev->udev)508 if (dev->disconnected)
520 return EPOLLERR | EPOLLHUP;509 return EPOLLERR | EPOLLHUP;
521 510
522 poll_wait(file, &dev->read_wait, wait);511 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
563 }552 }
564 553
565 /* verify that the device wasn't unplugged */554 /* verify that the device wasn't unplugged */
566 if (dev->udev == NULL) {555 if (dev->disconnected) {
567 retval = -ENODEV;556 retval = -ENODEV;
568 pr_err("No device or device unplugged %d\n", retval);557 pr_err("No device or device unplugged %d\n", retval);
569 goto unlock_exit;558 goto unlock_exit;
@@ -649,7 +638,7 @@ static ssize_t tower_write (struct file *file, const char __user *buffer, size_t · 79 unmodified lines
649 }638 }
650 639
651 /* verify that the device wasn't unplugged */640 /* verify that the device wasn't unplugged */
652 if (dev->udev == NULL) {641 if (dev->disconnected) {
653 retval = -ENODEV;642 retval = -ENODEV;
654 pr_err("No device or device unplugged %d\n", retval);643 pr_err("No device or device unplugged %d\n", retval);
655 goto unlock_exit;644 goto unlock_exit;
@@ -759,7 +748,7 @@ static void tower_interrupt_in_callback (struct urb *urb) · 103 unmodified lines
759 748
760resubmit:749resubmit:
761 /* resubmit if we're still running */750 /* resubmit if we're still running */
762 if (dev->interrupt_in_running && dev->udev) {751 if (dev->interrupt_in_running) {
763 retval = usb_submit_urb (dev->interrupt_in_urb, GFP_ATOMIC);752 retval = usb_submit_urb (dev->interrupt_in_urb, GFP_ATOMIC);
764 if (retval)753 if (retval)
765 dev_err(&dev->udev->dev,754 dev_err(&dev->udev->dev,
@@ -822,8 +811,9 @@ static int tower_probe (struct usb_interface *interface, const struct usb_device · 56 unmodified lines
822 811
823 mutex_init(&dev->lock);812 mutex_init(&dev->lock);
824 813
825 dev->udev = udev;814 dev->udev = usb_get_dev(udev);
826 dev->open_count = 0;815 dev->open_count = 0;
816 dev->disconnected = 0;
827 817
828 dev->read_buffer = NULL;818 dev->read_buffer = NULL;
829 dev->read_buffer_length = 0;819 dev->read_buffer_length = 0;
@@ -891,8 +881,10 @@ static int tower_probe (struct usb_interface *interface, const struct usb_device · 61 unmodified lines
891 get_version_reply,881 get_version_reply,
892 sizeof(*get_version_reply),882 sizeof(*get_version_reply),
893 1000);883 1000);
894 if (result < 0) {884 if (result < sizeof(*get_version_reply)) {
895 dev_err(idev, "LEGO USB Tower get version control request failed\n");885 if (result >= 0)
886 result = -EIO;
887 dev_err(idev, "get version request failed: %d\n", result);
896 retval = result;888 retval = result;
897 goto error;889 goto error;
898 }890 }
@@ -910,7 +902,6 @@ static int tower_probe (struct usb_interface *interface, const struct usb_device · 11 unmodified lines
910 if (retval) {902 if (retval) {
911 /* something prevented us from registering this driver */903 /* something prevented us from registering this driver */
912 dev_err(idev, "Not able to get a minor for this device.\n");904 dev_err(idev, "Not able to get a minor for this device.\n");
913 usb_set_intfdata (interface, NULL);
914 goto error;905 goto error;
915 }906 }
916 dev->minor = interface->minor;907 dev->minor = interface->minor;
@@ -942,23 +933,24 @@ static void tower_disconnect (struct usb_interface *interface) · 25 unmodified lines
942 int minor;933 int minor;
943 934
944 dev = usb_get_intfdata (interface);935 dev = usb_get_intfdata (interface);
945 mutex_lock(&open_disc_mutex);
946 usb_set_intfdata (interface, NULL);
947 936
948 minor = dev->minor;937 minor = dev->minor;
949 938
950 /* give back our minor */939 /* give back our minor and prevent further open() */
951 usb_deregister_dev (interface, &tower_class);940 usb_deregister_dev (interface, &tower_class);
952 941
942 /* stop I/O */
943 usb_poison_urb(dev->interrupt_in_urb);
944 usb_poison_urb(dev->interrupt_out_urb);
945
953 mutex_lock(&dev->lock);946 mutex_lock(&dev->lock);
954 mutex_unlock(&open_disc_mutex);
955 947
956 /* if the device is not opened, then we clean up right now */948 /* if the device is not opened, then we clean up right now */
957 if (!dev->open_count) {949 if (!dev->open_count) {
958 mutex_unlock(&dev->lock);950 mutex_unlock(&dev->lock);
959 tower_delete (dev);951 tower_delete (dev);
960 } else {952 } else {
961 dev->udev = NULL;953 dev->disconnected = 1;
962 /* wake up pollers */954 /* wake up pollers */
963 wake_up_interruptible_all(&dev->read_wait);955 wake_up_interruptible_all(&dev->read_wait);
964 wake_up_interruptible_all(&dev->write_wait);956 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
46struct 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
56static DEFINE_MUTEX(rio500_mutex);
57static struct rio_usb_data rio_instance;
58
59static 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
81static 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
102static 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
255err_out:
256 mutex_unlock(&rio500_mutex);
257 return retval;
258}
259
260static ssize_t
261write_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
346error:
347 mutex_unlock(&rio500_mutex);
348 return errn;
349}
350
351static ssize_t
352read_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
436static 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
446static struct usb_class_driver usb_rio_class = {
447 .name = "rio500%d",
448 .fops = &usb_rio_fops,
449 .minor_base = RIO_MINOR,
450};
451
452static 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
509static 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
535static const struct usb_device_id rio_table[] = {
536 { USB_DEVICE(0x0841, 1) }, /* Rio 500 */
537 { } /* Terminating entry */
538};
539
540MODULE_DEVICE_TABLE (usb, rio_table);
541
542static struct usb_driver rio_driver = {
543 .name = "rio500",
544 .probe = probe_rio,
545 .disconnect = disconnect_rio,
546 .id_table = rio_table,
547};
548
549module_usb_driver(rio_driver);
550
551MODULE_AUTHOR( DRIVER_AUTHOR );
552MODULE_DESCRIPTION( DRIVER_DESC );
553MODULE_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
12struct 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
18#include <linux/slab.h>18#include <linux/slab.h>
19#include <linux/errno.h>19#include <linux/errno.h>
20#include <linux/mutex.h>20#include <linux/mutex.h>
21#include <linux/rwsem.h>
21#include <linux/uaccess.h>22#include <linux/uaccess.h>
22#include <linux/usb.h>23#include <linux/usb.h>
23 24
@@ -29,16 +30,12 @@ · 5 unmodified lines
29#define IOCTL_GET_DRV_VERSION 230#define IOCTL_GET_DRV_VERSION 2
30 31
31 32
32static DEFINE_MUTEX(lcd_mutex);
33static const struct usb_device_id id_table[] = {33static const struct usb_device_id id_table[] = {
34 { .idVendor = 0x10D2, .match_flags = USB_DEVICE_ID_MATCH_VENDOR, },34 { .idVendor = 0x10D2, .match_flags = USB_DEVICE_ID_MATCH_VENDOR, },
35 { },35 { },
36};36};
37MODULE_DEVICE_TABLE(usb, id_table);37MODULE_DEVICE_TABLE(usb, id_table);
38 38
39static DEFINE_MUTEX(open_disc_mutex);
40
41
42struct usb_lcd {39struct usb_lcd {
43 struct usb_device *udev; /* init: probe_lcd */40 struct usb_device *udev; /* init: probe_lcd */
44 struct usb_interface *interface; /* the interface for41 struct usb_interface *interface; /* the interface for
@@ -57,6 +54,8 @@ struct usb_lcd { · 12 unmodified lines
57 using up all RAM */54 using up all RAM */
58 struct usb_anchor submitted; /* URBs to wait for55 struct usb_anchor submitted; /* URBs to wait for
59 before suspend */56 before suspend */
57 struct rw_semaphore io_rwsem;
58 unsigned long disconnected:1;
60};59};
61#define to_lcd_dev(d) container_of(d, struct usb_lcd, kref)60#define to_lcd_dev(d) container_of(d, struct usb_lcd, kref)
62 61
@@ -81,40 +80,29 @@ static int lcd_open(struct inode *inode, struct file *file) · 18 unmodified lines
81 struct usb_interface *interface;80 struct usb_interface *interface;
82 int subminor, r;81 int subminor, r;
83 82
84 mutex_lock(&lcd_mutex);
85 subminor = iminor(inode);83 subminor = iminor(inode);
86 84
87 interface = usb_find_interface(&lcd_driver, subminor);85 interface = usb_find_interface(&lcd_driver, subminor);
88 if (!interface) {86 if (!interface) {
89 mutex_unlock(&lcd_mutex);87 pr_err("USBLCD: %s - error, can't find device for minor %d\n",
90 printk(KERN_ERR "USBLCD: %s - error, can't find device for minor %d\n",
91 __func__, subminor);88 __func__, subminor);
92 return -ENODEV;89 return -ENODEV;
93 }90 }
94 91
95 mutex_lock(&open_disc_mutex);
96 dev = usb_get_intfdata(interface);92 dev = usb_get_intfdata(interface);
97 if (!dev) {
98 mutex_unlock(&open_disc_mutex);
99 mutex_unlock(&lcd_mutex);
100 return -ENODEV;
101 }
102 93
103 /* increment our usage count for the device */94 /* increment our usage count for the device */
104 kref_get(&dev->kref);95 kref_get(&dev->kref);
105 mutex_unlock(&open_disc_mutex);
106 96
107 /* grab a power reference */97 /* grab a power reference */
108 r = usb_autopm_get_interface(interface);98 r = usb_autopm_get_interface(interface);
109 if (r < 0) {99 if (r < 0) {
110 kref_put(&dev->kref, lcd_delete);100 kref_put(&dev->kref, lcd_delete);
111 mutex_unlock(&lcd_mutex);
112 return r;101 return r;
113 }102 }
114 103
115 /* save our object in the file's private structure */104 /* save our object in the file's private structure */
116 file->private_data = dev;105 file->private_data = dev;
117 mutex_unlock(&lcd_mutex);
118 106
119 return 0;107 return 0;
120}108}
@@ -142,6 +130,13 @@ static ssize_t lcd_read(struct file *file, char __user * buffer, · 21 unmodified lines
142 130
143 dev = file->private_data;131 dev = file->private_data;
144 132
133 down_read(&dev->io_rwsem);
134
135 if (dev->disconnected) {
136 retval = -ENODEV;
137 goto out_up_io;
138 }
139
145 /* do a blocking bulk read to get data from the device */140 /* do a blocking bulk read to get data from the device */
146 retval = usb_bulk_msg(dev->udev,141 retval = usb_bulk_msg(dev->udev,
147 usb_rcvbulkpipe(dev->udev,142 usb_rcvbulkpipe(dev->udev,
@@ -158,6 +153,9 @@ static ssize_t lcd_read(struct file *file, char __user * buffer, · 10 unmodified lines
158 retval = bytes_read;153 retval = bytes_read;
159 }154 }
160 155
156out_up_io:
157 up_read(&dev->io_rwsem);
158
161 return retval;159 return retval;
162}160}
163 161
@@ -173,14 +171,12 @@ static long lcd_ioctl(struct file *file, unsigned int cmd, unsigned long arg) · 9 unmodified lines
173 171
174 switch (cmd) {172 switch (cmd) {
175 case IOCTL_GET_HARD_VERSION:173 case IOCTL_GET_HARD_VERSION:
176 mutex_lock(&lcd_mutex);
177 bcdDevice = le16_to_cpu((dev->udev)->descriptor.bcdDevice);174 bcdDevice = le16_to_cpu((dev->udev)->descriptor.bcdDevice);
178 sprintf(buf, "%1d%1d.%1d%1d",175 sprintf(buf, "%1d%1d.%1d%1d",
179 (bcdDevice & 0xF000)>>12,176 (bcdDevice & 0xF000)>>12,
180 (bcdDevice & 0xF00)>>8,177 (bcdDevice & 0xF00)>>8,
181 (bcdDevice & 0xF0)>>4,178 (bcdDevice & 0xF0)>>4,
182 (bcdDevice & 0xF));179 (bcdDevice & 0xF));
183 mutex_unlock(&lcd_mutex);
184 if (copy_to_user((void __user *)arg, buf, strlen(buf)) != 0)180 if (copy_to_user((void __user *)arg, buf, strlen(buf)) != 0)
185 return -EFAULT;181 return -EFAULT;
186 break;182 break;
@@ -237,11 +233,18 @@ static ssize_t lcd_write(struct file *file, const char __user * user_buffer, · 50 unmodified lines
237 if (r < 0)233 if (r < 0)
238 return -EINTR;234 return -EINTR;
239 235
236 down_read(&dev->io_rwsem);
237
238 if (dev->disconnected) {
239 retval = -ENODEV;
240 goto err_up_io;
241 }
242
240 /* create a urb, and a buffer for it, and copy the data to the urb */243 /* create a urb, and a buffer for it, and copy the data to the urb */
241 urb = usb_alloc_urb(0, GFP_KERNEL);244 urb = usb_alloc_urb(0, GFP_KERNEL);
242 if (!urb) {245 if (!urb) {
243 retval = -ENOMEM;246 retval = -ENOMEM;
244 goto err_no_buf;247 goto err_up_io;
245 }248 }
246 249
247 buf = usb_alloc_coherent(dev->udev, count, GFP_KERNEL,250 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
278 the USB core will eventually free it entirely */281 the USB core will eventually free it entirely */
279 usb_free_urb(urb);282 usb_free_urb(urb);
280 283
284 up_read(&dev->io_rwsem);
281exit:285exit:
282 return count;286 return count;
283error_unanchor:287error_unanchor:
@@ -285,7 +289,8 @@ error_unanchor: · 1 unmodified line
285error:289error:
286 usb_free_coherent(dev->udev, count, buf, urb->transfer_dma);290 usb_free_coherent(dev->udev, count, buf, urb->transfer_dma);
287 usb_free_urb(urb);291 usb_free_urb(urb);
288err_no_buf:292err_up_io:
293 up_read(&dev->io_rwsem);
289 up(&dev->limit_sem);294 up(&dev->limit_sem);
290 return retval;295 return retval;
291}296}
@@ -325,6 +330,7 @@ static int lcd_probe(struct usb_interface *interface, · 33 unmodified lines
325 330
326 kref_init(&dev->kref);331 kref_init(&dev->kref);
327 sema_init(&dev->limit_sem, USB_LCD_CONCURRENT_WRITES);332 sema_init(&dev->limit_sem, USB_LCD_CONCURRENT_WRITES);
333 init_rwsem(&dev->io_rwsem);
328 init_usb_anchor(&dev->submitted);334 init_usb_anchor(&dev->submitted);
329 335
330 dev->udev = usb_get_dev(interface_to_usbdev(interface));336 dev->udev = usb_get_dev(interface_to_usbdev(interface));
@@ -365,7 +371,6 @@ static int lcd_probe(struct usb_interface *interface, · 34 unmodified lines
365 /* something prevented us from registering this driver */371 /* something prevented us from registering this driver */
366 dev_err(&interface->dev,372 dev_err(&interface->dev,
367 "Not able to get a minor for this device.\n");373 "Not able to get a minor for this device.\n");
368 usb_set_intfdata(interface, NULL);
369 goto error;374 goto error;
370 }375 }
371 376
@@ -411,17 +416,18 @@ static int lcd_resume(struct usb_interface *intf) · 39 unmodified lines
411 416
412static void lcd_disconnect(struct usb_interface *interface)417static void lcd_disconnect(struct usb_interface *interface)
413{418{
414 struct usb_lcd *dev;419 struct usb_lcd *dev = usb_get_intfdata(interface);
415 int minor = interface->minor;420 int minor = interface->minor;
416 421
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
422 /* give back our minor */422 /* give back our minor */
423 usb_deregister_dev(interface, &lcd_class);423 usb_deregister_dev(interface, &lcd_class);
424 424
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
425 /* decrement our usage count */431 /* decrement our usage count */
426 kref_put(&dev->kref, lcd_delete);432 kref_put(&dev->kref, lcd_delete);
427 433
drivers/usb/misc/yurex.c+11−7
@@ -60,6 +60,7 @@ struct usb_yurex { · 59 unmodified lines
60 60
61 struct kref kref;61 struct kref kref;
62 struct mutex io_mutex;62 struct mutex io_mutex;
63 unsigned long disconnected:1;
63 struct fasync_struct *async_queue;64 struct fasync_struct *async_queue;
64 wait_queue_head_t waitq;65 wait_queue_head_t waitq;
65 66
@@ -107,6 +108,7 @@ static void yurex_delete(struct kref *kref) · 41 unmodified lines
107 dev->int_buffer, dev->urb->transfer_dma);108 dev->int_buffer, dev->urb->transfer_dma);
108 usb_free_urb(dev->urb);109 usb_free_urb(dev->urb);
109 }110 }
111 usb_put_intf(dev->interface);
110 usb_put_dev(dev->udev);112 usb_put_dev(dev->udev);
111 kfree(dev);113 kfree(dev);
112}114}
@@ -132,6 +134,7 @@ static void yurex_interrupt(struct urb *urb) · 19 unmodified lines
132 switch (status) {134 switch (status) {
133 case 0: /*success*/135 case 0: /*success*/
134 break;136 break;
137 /* The device is terminated or messed up, give up */
135 case -EOVERFLOW:138 case -EOVERFLOW:
136 dev_err(&dev->interface->dev,139 dev_err(&dev->interface->dev,
137 "%s - overflow with length %d, actual length is %d\n",140 "%s - overflow with length %d, actual length is %d\n",
@@ -140,12 +143,13 @@ static void yurex_interrupt(struct urb *urb) · 2 unmodified lines
140 case -ENOENT:143 case -ENOENT:
141 case -ESHUTDOWN:144 case -ESHUTDOWN:
142 case -EILSEQ:145 case -EILSEQ:
143 /* The device is terminated, clean up */146 case -EPROTO:
147 case -ETIME:
144 return;148 return;
145 default:149 default:
146 dev_err(&dev->interface->dev,150 dev_err(&dev->interface->dev,
147 "%s - unknown status received: %d\n", __func__, status);151 "%s - unknown status received: %d\n", __func__, status);
148 goto exit;152 return;
149 }153 }
150 154
151 /* handle received message */155 /* handle received message */
@@ -177,7 +181,6 @@ static void yurex_interrupt(struct urb *urb) · 25 unmodified lines
177 break;181 break;
178 }182 }
179 183
180exit:
181 retval = usb_submit_urb(dev->urb, GFP_ATOMIC);184 retval = usb_submit_urb(dev->urb, GFP_ATOMIC);
182 if (retval) {185 if (retval) {
183 dev_err(&dev->interface->dev, "%s - usb_submit_urb failed: %d\n",186 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
204 init_waitqueue_head(&dev->waitq);207 init_waitqueue_head(&dev->waitq);
205 208
206 dev->udev = usb_get_dev(interface_to_usbdev(interface));209 dev->udev = usb_get_dev(interface_to_usbdev(interface));
207 dev->interface = interface;210 dev->interface = usb_get_intf(interface);
208 211
209 /* set up the endpoint information */212 /* set up the endpoint information */
210 iface_desc = interface->cur_altsetting;213 iface_desc = interface->cur_altsetting;
@@ -315,8 +318,9 @@ static void yurex_disconnect(struct usb_interface *interface) · 104 unmodified lines
315 318
316 /* prevent more I/O from starting */319 /* prevent more I/O from starting */
317 usb_poison_urb(dev->urb);320 usb_poison_urb(dev->urb);
321 usb_poison_urb(dev->cntl_urb);
318 mutex_lock(&dev->io_mutex);322 mutex_lock(&dev->io_mutex);
319 dev->interface = NULL;323 dev->disconnected = 1;
320 mutex_unlock(&dev->io_mutex);324 mutex_unlock(&dev->io_mutex);
321 325
322 /* wakeup waiters */326 /* wakeup waiters */
@@ -404,7 +408,7 @@ static ssize_t yurex_read(struct file *file, char __user *buffer, size_t count, · 81 unmodified lines
404 dev = file->private_data;408 dev = file->private_data;
405 409
406 mutex_lock(&dev->io_mutex);410 mutex_lock(&dev->io_mutex);
407 if (!dev->interface) { /* already disconnected */411 if (dev->disconnected) { /* already disconnected */
408 mutex_unlock(&dev->io_mutex);412 mutex_unlock(&dev->io_mutex);
409 return -ENODEV;413 return -ENODEV;
410 }414 }
@@ -439,7 +443,7 @@ static ssize_t yurex_write(struct file *file, const char __user *user_buffer, · 28 unmodified lines
439 goto error;443 goto error;
440 444
441 mutex_lock(&dev->io_mutex);445 mutex_lock(&dev->io_mutex);
442 if (!dev->interface) { /* already disconnected */446 if (dev->disconnected) { /* already disconnected */
443 mutex_unlock(&dev->io_mutex);447 mutex_unlock(&dev->io_mutex);
444 retval = -ENODEV;448 retval = -ENODEV;
445 goto error;449 goto error;
drivers/usb/renesas_usbhs/common.h+1−0
@@ -211,6 +211,7 @@ struct usbhs_priv; · 210 unmodified lines
211/* DCPCTR */211/* DCPCTR */
212#define BSTS (1 << 15) /* Buffer Status */212#define BSTS (1 << 15) /* Buffer Status */
213#define SUREQ (1 << 14) /* Sending SETUP Token */213#define SUREQ (1 << 14) /* Sending SETUP Token */
214#define INBUFM (1 << 14) /* (PIPEnCTR) Transfer Buffer Monitor */
214#define CSSTS (1 << 12) /* CSSTS Status */215#define CSSTS (1 << 12) /* CSSTS Status */
215#define ACLRM (1 << 9) /* Buffer Auto-Clear Mode */216#define ACLRM (1 << 9) /* Buffer Auto-Clear Mode */
216#define SQCLR (1 << 8) /* Toggle Bit Clear */217#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
89 list_del_init(&pkt->node);89 list_del_init(&pkt->node);
90}90}
91 91
92static struct usbhs_pkt *__usbhsf_pkt_get(struct usbhs_pipe *pipe)92struct usbhs_pkt *__usbhsf_pkt_get(struct usbhs_pipe *pipe)
93{93{
94 return list_first_entry_or_null(&pipe->list, struct usbhs_pkt, node);94 return list_first_entry_or_null(&pipe->list, struct usbhs_pkt, node);
95}95}
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
97 void *buf, int len, int zero, int sequence);97 void *buf, int len, int zero, int sequence);
98struct usbhs_pkt *usbhs_pkt_pop(struct usbhs_pipe *pipe, struct usbhs_pkt *pkt);98struct usbhs_pkt *usbhs_pkt_pop(struct usbhs_pipe *pipe, struct usbhs_pkt *pkt);
99void usbhs_pkt_start(struct usbhs_pipe *pipe);99void usbhs_pkt_start(struct usbhs_pipe *pipe);
100struct usbhs_pkt *__usbhsf_pkt_get(struct usbhs_pipe *pipe);
100 101
101#endif /* RENESAS_USB_FIFO_H */102#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
722 struct usbhs_priv *priv = usbhsg_gpriv_to_priv(gpriv);722 struct usbhs_priv *priv = usbhsg_gpriv_to_priv(gpriv);
723 struct device *dev = usbhsg_gpriv_to_dev(gpriv);723 struct device *dev = usbhsg_gpriv_to_dev(gpriv);
724 unsigned long flags;724 unsigned long flags;
725 725 int ret = 0;
726 usbhsg_pipe_disable(uep);
727 726
728 dev_dbg(dev, "set halt %d (pipe %d)\n",727 dev_dbg(dev, "set halt %d (pipe %d)\n",
729 halt, usbhs_pipe_number(pipe));728 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
731 /******************** spin lock ********************/730 /******************** spin lock ********************/
732 usbhs_lock(priv, flags);731 usbhs_lock(priv, flags);
733 732
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
734 if (halt)745 if (halt)
735 usbhs_pipe_stall(pipe);746 usbhs_pipe_stall(pipe);
736 else747 else
@@ -741,10 +752,11 @@ static int __usbhsg_ep_set_halt_wedge(struct usb_ep *ep, int halt, int wedge) · 4 unmodified lines
741 else752 else
742 usbhsg_status_clr(gpriv, USBHSG_STATUS_WEDGE);753 usbhsg_status_clr(gpriv, USBHSG_STATUS_WEDGE);
743 754
755out:
744 usbhs_unlock(priv, flags);756 usbhs_unlock(priv, flags);
745 /******************** spin unlock ******************/757 /******************** spin unlock ******************/
746 758
747 return 0;759 return ret;
748}760}
749 761
750static int usbhsg_ep_set_halt(struct usb_ep *ep, int value)762static 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
277 return -EBUSY;277 return -EBUSY;
278}278}
279 279
280bool 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
280/*295/*
281 * PID ctrl296 * PID ctrl
282 */297 */
drivers/usb/renesas_usbhs/pipe.h+1−0
@@ -83,6 +83,7 @@ void usbhs_pipe_clear(struct usbhs_pipe *pipe); · 82 unmodified lines
83void usbhs_pipe_clear_without_sequence(struct usbhs_pipe *pipe,83void usbhs_pipe_clear_without_sequence(struct usbhs_pipe *pipe,
84 int needs_bfre, int bfre_enable);84 int needs_bfre, int bfre_enable);
85int usbhs_pipe_is_accessible(struct usbhs_pipe *pipe);85int usbhs_pipe_is_accessible(struct usbhs_pipe *pipe);
86bool usbhs_pipe_contains_transmittable_data(struct usbhs_pipe *pipe);
86void usbhs_pipe_enable(struct usbhs_pipe *pipe);87void usbhs_pipe_enable(struct usbhs_pipe *pipe);
87void usbhs_pipe_disable(struct usbhs_pipe *pipe);88void usbhs_pipe_disable(struct usbhs_pipe *pipe);
88void usbhs_pipe_stall(struct usbhs_pipe *pipe);89void 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
1030 /* EZPrototypes devices */1030 /* EZPrototypes devices */
1031 { USB_DEVICE(EZPROTOTYPES_VID, HJELMSLUND_USB485_ISO_PID) },1031 { USB_DEVICE(EZPROTOTYPES_VID, HJELMSLUND_USB485_ISO_PID) },
1032 { USB_DEVICE_INTERFACE_NUMBER(UNJO_VID, UNJO_ISODEBUG_V1_PID, 1) },1032 { 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) },
1033 { } /* Terminating entry */1036 { } /* Terminating entry */
1034};1037};
1035 1038
drivers/usb/serial/ftdi_sio_ids.h+9−0
@@ -39,6 +39,9 @@ · 38 unmodified lines
39 39
40#define FTDI_LUMEL_PD12_PID 0x600240#define FTDI_LUMEL_PD12_PID 0x6002
41 41
42/* Sienna Serial Interface by Secyourit GmbH */
43#define FTDI_SIENNA_PID 0x8348
44
42/* Cyber Cortex AV by Fabulous Silicon (http://fabuloussilicon.com) */45/* Cyber Cortex AV by Fabulous Silicon (http://fabuloussilicon.com) */
43#define CYBER_CORTEX_AV_PID 0x869846#define CYBER_CORTEX_AV_PID 0x8698
44 47
@@ -688,6 +691,12 @@ · 643 unmodified lines
688#define BANDB_TTL3USB9M_PID 0xAC50691#define BANDB_TTL3USB9M_PID 0xAC50
689#define BANDB_ZZ_PROG1_USB_PID 0xBA02692#define BANDB_ZZ_PROG1_USB_PID 0xBA02
690 693
694/*
695 * Echelon USB Serial Interface
696 */
697#define ECHELON_VID 0x0920
698#define ECHELON_U20_PID 0x7500
699
691/*700/*
692 * Intrepid Control Systems (http://www.intrepidcs.com/) ValueCAN and NeoVI701 * Intrepid Control Systems (http://www.intrepidcs.com/) ValueCAN and NeoVI
693 */702 */
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
1741 1741
1742 ep_desc = find_ep(serial, endpoint);1742 ep_desc = find_ep(serial, endpoint);
1743 if (!ep_desc) {1743 if (!ep_desc) {
1744 /* leak the urb, something's wrong and the callers don't care */1744 usb_free_urb(urb);
1745 return urb;1745 return NULL;
1746 }1746 }
1747 if (usb_endpoint_xfer_int(ep_desc)) {1747 if (usb_endpoint_xfer_int(ep_desc)) {
1748 ep_type_name = "INT";1748 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
419#define CINTERION_PRODUCT_PH8_AUDIO 0x0083419#define CINTERION_PRODUCT_PH8_AUDIO 0x0083
420#define CINTERION_PRODUCT_AHXX_2RMNET 0x0084420#define CINTERION_PRODUCT_AHXX_2RMNET 0x0084
421#define CINTERION_PRODUCT_AHXX_AUDIO 0x0085421#define CINTERION_PRODUCT_AHXX_AUDIO 0x0085
422#define CINTERION_PRODUCT_CLS8 0x00b0
422 423
423/* Olivetti products */424/* Olivetti products */
424#define OLIVETTI_VENDOR_ID 0x0b3c425#define OLIVETTI_VENDOR_ID 0x0b3c
@@ -1154,6 +1155,14 @@ static const struct usb_device_id option_ids[] = { · 729 unmodified lines
1154 .driver_info = NCTRL(0) | RSVD(1) | RSVD(2) | RSVD(3) },1155 .driver_info = NCTRL(0) | RSVD(1) | RSVD(2) | RSVD(3) },
1155 { USB_DEVICE_INTERFACE_CLASS(TELIT_VENDOR_ID, TELIT_PRODUCT_LE922_USBCFG5, 0xff),1156 { USB_DEVICE_INTERFACE_CLASS(TELIT_VENDOR_ID, TELIT_PRODUCT_LE922_USBCFG5, 0xff),
1156 .driver_info = RSVD(0) | RSVD(1) | NCTRL(2) | RSVD(3) },1157 .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) },
1157 { USB_DEVICE(TELIT_VENDOR_ID, TELIT_PRODUCT_ME910),1166 { USB_DEVICE(TELIT_VENDOR_ID, TELIT_PRODUCT_ME910),
1158 .driver_info = NCTRL(0) | RSVD(1) | RSVD(3) },1167 .driver_info = NCTRL(0) | RSVD(1) | RSVD(3) },
1159 { USB_DEVICE(TELIT_VENDOR_ID, TELIT_PRODUCT_ME910_DUAL_MODEM),1168 { 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
1847 .driver_info = RSVD(4) },1856 .driver_info = RSVD(4) },
1848 { USB_DEVICE_INTERFACE_CLASS(CINTERION_VENDOR_ID, CINTERION_PRODUCT_AHXX_2RMNET, 0xff) },1857 { USB_DEVICE_INTERFACE_CLASS(CINTERION_VENDOR_ID, CINTERION_PRODUCT_AHXX_2RMNET, 0xff) },
1849 { USB_DEVICE_INTERFACE_CLASS(CINTERION_VENDOR_ID, CINTERION_PRODUCT_AHXX_AUDIO, 0xff) },1858 { 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) },
1850 { USB_DEVICE(CINTERION_VENDOR_ID, CINTERION_PRODUCT_HC28_MDM) },1861 { USB_DEVICE(CINTERION_VENDOR_ID, CINTERION_PRODUCT_HC28_MDM) },
1851 { USB_DEVICE(CINTERION_VENDOR_ID, CINTERION_PRODUCT_HC28_MDMNET) },1862 { USB_DEVICE(CINTERION_VENDOR_ID, CINTERION_PRODUCT_HC28_MDMNET) },
1852 { USB_DEVICE(SIEMENS_VENDOR_ID, CINTERION_PRODUCT_HC25_MDM) },1863 { 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
314 serial = port->serial;314 serial = port->serial;
315 owner = serial->type->driver.owner;315 owner = serial->type->driver.owner;
316 316
317 mutex_lock(&serial->disc_mutex);317 usb_autopm_put_interface(serial->interface);
318 if (!serial->disconnected)
319 usb_autopm_put_interface(serial->interface);
320 mutex_unlock(&serial->disc_mutex);
321 318
322 usb_serial_put(serial);319 usb_serial_put(serial);
323 module_put(owner);320 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
4409 /* USB data support is optional */4409 /* USB data support is optional */
4410 ret = fwnode_property_read_string(fwnode, "data-role", &cap_str);4410 ret = fwnode_property_read_string(fwnode, "data-role", &cap_str);
4411 if (ret == 0) {4411 if (ret == 0) {
4412 port->typec_caps.data = typec_find_port_data_role(cap_str);4412 ret = typec_find_port_data_role(cap_str);
4413 if (port->typec_caps.data < 0)4413 if (ret < 0)
4414 return -EINVAL;4414 return ret;
4415 port->typec_caps.data = ret;
4415 }4416 }
4416 4417
4417 ret = fwnode_property_read_string(fwnode, "power-role", &cap_str);4418 ret = fwnode_property_read_string(fwnode, "power-role", &cap_str);
4418 if (ret < 0)4419 if (ret < 0)
4419 return ret;4420 return ret;
4420 4421
4421 port->typec_caps.type = typec_find_port_power_role(cap_str);4422 ret = typec_find_port_power_role(cap_str);
4422 if (port->typec_caps.type < 0)4423 if (ret < 0)
4423 return -EINVAL;4424 return ret;
4425 port->typec_caps.type = ret;
4424 port->port_type = port->typec_caps.type;4426 port->port_type = port->typec_caps.type;
4425 4427
4426 if (port->port_type == TYPEC_PORT_SNK)4428 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
75 75
76 if (cur != 0xff) {76 if (cur != 0xff) {
77 mutex_unlock(&dp->con->lock);77 mutex_unlock(&dp->con->lock);
78 if (dp->con->port_altmode[cur] == alt)
79 return 0;
78 return -EBUSY;80 return -EBUSY;
79 }81 }
80 82
drivers/usb/typec/ucsi/ucsi_ccg.c+4−38
@@ -195,7 +195,6 @@ struct ucsi_ccg { · 194 unmodified lines
195 195
196 /* fw build with vendor information */196 /* fw build with vendor information */
197 u16 fw_build;197 u16 fw_build;
198 bool run_isr; /* flag to call ISR routine during resume */
199 struct work_struct pm_work;198 struct work_struct pm_work;
200};199};
201 200
@@ -224,18 +223,6 @@ static int ccg_read(struct ucsi_ccg *uc, u16 rab, u8 *data, u32 len) · 22 unmodified lines
224 if (quirks && quirks->max_read_len)223 if (quirks && quirks->max_read_len)
225 max_read_len = quirks->max_read_len;224 max_read_len = quirks->max_read_len;
226 225
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
239 pm_runtime_get_sync(uc->dev);226 pm_runtime_get_sync(uc->dev);
240 while (rem_len > 0) {227 while (rem_len > 0) {
241 msgs[1].buf = &data[len - rem_len];228 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
278 msgs[0].len = len + sizeof(rab);265 msgs[0].len = len + sizeof(rab);
279 msgs[0].buf = buf;266 msgs[0].buf = buf;
280 267
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
293 pm_runtime_get_sync(uc->dev);268 pm_runtime_get_sync(uc->dev);
294 status = i2c_transfer(client->adapter, msgs, ARRAY_SIZE(msgs));269 status = i2c_transfer(client->adapter, msgs, ARRAY_SIZE(msgs));
295 if (status < 0) {270 if (status < 0) {
@@ -1130,7 +1105,6 @@ static int ucsi_ccg_probe(struct i2c_client *client, · 834 unmodified lines
1130 uc->ppm.sync = ucsi_ccg_sync;1105 uc->ppm.sync = ucsi_ccg_sync;
1131 uc->dev = dev;1106 uc->dev = dev;
1132 uc->client = client;1107 uc->client = client;
1133 uc->run_isr = true;
1134 mutex_init(&uc->lock);1108 mutex_init(&uc->lock);
1135 INIT_WORK(&uc->work, ccg_update_firmware);1109 INIT_WORK(&uc->work, ccg_update_firmware);
1136 INIT_WORK(&uc->pm_work, ccg_pm_workaround_work);1110 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
1188 1162
1189 pm_runtime_set_active(uc->dev);1163 pm_runtime_set_active(uc->dev);
1190 pm_runtime_enable(uc->dev);1164 pm_runtime_enable(uc->dev);
1165 pm_runtime_use_autosuspend(uc->dev);
1166 pm_runtime_set_autosuspend_delay(uc->dev, 5000);
1191 pm_runtime_idle(uc->dev);1167 pm_runtime_idle(uc->dev);
1192 1168
1193 return 0;1169 return 0;
@@ -1229,7 +1205,6 @@ static int ucsi_ccg_runtime_resume(struct device *dev) · 35 unmodified lines
1229{1205{
1230 struct i2c_client *client = to_i2c_client(dev);1206 struct i2c_client *client = to_i2c_client(dev);
1231 struct ucsi_ccg *uc = i2c_get_clientdata(client);1207 struct ucsi_ccg *uc = i2c_get_clientdata(client);
1232 bool schedule = true;
1233 1208
1234 /*1209 /*
1235 * Firmware version 3.1.10 or earlier, built for NVIDIA has known issue1210 * 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
1237 * Schedule a work to call ISR as a workaround.1212 * Schedule a work to call ISR as a workaround.
1238 */1213 */
1239 if (uc->fw_build == CCG_FW_BUILD_NVIDIA &&1214 if (uc->fw_build == CCG_FW_BUILD_NVIDIA &&
1240 uc->fw_version <= CCG_OLD_FW_VERSION) {1215 uc->fw_version <= CCG_OLD_FW_VERSION)
1241 mutex_lock(&uc->lock);1216 schedule_work(&uc->pm_work);
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 }
1251 1217
1252 return 0;1218 return 0;
1253}1219}
drivers/usb/usb-skeleton.c+9−10
@@ -61,6 +61,7 @@ struct usb_skel { · 60 unmodified lines
61 spinlock_t err_lock; /* lock for errors */61 spinlock_t err_lock; /* lock for errors */
62 struct kref kref;62 struct kref kref;
63 struct mutex io_mutex; /* synchronize I/O with disconnect */63 struct mutex io_mutex; /* synchronize I/O with disconnect */
64 unsigned long disconnected:1;
64 wait_queue_head_t bulk_in_wait; /* to wait for an ongoing read */65 wait_queue_head_t bulk_in_wait; /* to wait for an ongoing read */
65};66};
66#define to_skel_dev(d) container_of(d, struct usb_skel, kref)67#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
73 struct usb_skel *dev = to_skel_dev(kref);74 struct usb_skel *dev = to_skel_dev(kref);
74 75
75 usb_free_urb(dev->bulk_in_urb);76 usb_free_urb(dev->bulk_in_urb);
77 usb_put_intf(dev->interface);
76 usb_put_dev(dev->udev);78 usb_put_dev(dev->udev);
77 kfree(dev->bulk_in_buffer);79 kfree(dev->bulk_in_buffer);
78 kfree(dev);80 kfree(dev);
@@ -124,10 +126,7 @@ static int skel_release(struct inode *inode, struct file *file) · 45 unmodified lines
124 return -ENODEV;126 return -ENODEV;
125 127
126 /* allow the device to be autosuspended */128 /* allow the device to be autosuspended */
127 mutex_lock(&dev->io_mutex);129 usb_autopm_put_interface(dev->interface);
128 if (dev->interface)
129 usb_autopm_put_interface(dev->interface);
130 mutex_unlock(&dev->io_mutex);
131 130
132 /* decrement the count on our device */131 /* decrement the count on our device */
133 kref_put(&dev->kref, skel_delete);132 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
231 230
232 dev = file->private_data;231 dev = file->private_data;
233 232
234 /* if we cannot read at all, return EOF */233 if (!count)
235 if (!dev->bulk_in_urb || !count)
236 return 0;234 return 0;
237 235
238 /* no concurrent readers */236 /* no concurrent readers */
@@ -240,7 +238,7 @@ static ssize_t skel_read(struct file *file, char *buffer, size_t count, · 1 unmodified line
240 if (rv < 0)238 if (rv < 0)
241 return rv;239 return rv;
242 240
243 if (!dev->interface) { /* disconnect() was called */241 if (dev->disconnected) { /* disconnect() was called */
244 rv = -ENODEV;242 rv = -ENODEV;
245 goto exit;243 goto exit;
246 }244 }
@@ -422,7 +420,7 @@ static ssize_t skel_write(struct file *file, const char *user_buffer, · 175 unmodified lines
422 420
423 /* this lock makes sure we don't submit URBs to gone devices */421 /* this lock makes sure we don't submit URBs to gone devices */
424 mutex_lock(&dev->io_mutex);422 mutex_lock(&dev->io_mutex);
425 if (!dev->interface) { /* disconnect() was called */423 if (dev->disconnected) { /* disconnect() was called */
426 mutex_unlock(&dev->io_mutex);424 mutex_unlock(&dev->io_mutex);
427 retval = -ENODEV;425 retval = -ENODEV;
428 goto error;426 goto error;
@@ -507,7 +505,7 @@ static int skel_probe(struct usb_interface *interface, · 78 unmodified lines
507 init_waitqueue_head(&dev->bulk_in_wait);505 init_waitqueue_head(&dev->bulk_in_wait);
508 506
509 dev->udev = usb_get_dev(interface_to_usbdev(interface));507 dev->udev = usb_get_dev(interface_to_usbdev(interface));
510 dev->interface = interface;508 dev->interface = usb_get_intf(interface);
511 509
512 /* set up the endpoint information */510 /* set up the endpoint information */
513 /* use only the first bulk-in and bulk-out endpoints */511 /* 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
573 571
574 /* prevent more I/O from starting */572 /* prevent more I/O from starting */
575 mutex_lock(&dev->io_mutex);573 mutex_lock(&dev->io_mutex);
576 dev->interface = NULL;574 dev->disconnected = 1;
577 mutex_unlock(&dev->io_mutex);575 mutex_unlock(&dev->io_mutex);
578 576
577 usb_kill_urb(dev->bulk_in_urb);
579 usb_kill_anchored_urbs(&dev->submitted);578 usb_kill_anchored_urbs(&dev->submitted);
580 579
581 /* decrement our usage count */580 /* 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
1195 if (id == 0 && usb_hcd_is_primary_hcd(hcd)) {1195 if (id == 0 && usb_hcd_is_primary_hcd(hcd)) {
1196 err = vhci_init_attr_group();1196 err = vhci_init_attr_group();
1197 if (err) {1197 if (err) {
1198 pr_err("init attr group\n");1198 dev_err(hcd_dev(hcd), "init attr group failed, err = %d\n", err);
1199 return err;1199 return err;
1200 }1200 }
1201 err = sysfs_create_group(&hcd_dev(hcd)->kobj, &vhci_attr_group);1201 err = sysfs_create_group(&hcd_dev(hcd)->kobj, &vhci_attr_group);
1202 if (err) {1202 if (err) {
1203 pr_err("create sysfs files\n");1203 dev_err(hcd_dev(hcd), "create sysfs files failed, err = %d\n", err);
1204 vhci_finish_attr_group();1204 vhci_finish_attr_group();
1205 return err;1205 return err;
1206 }1206 }
include/linux/platform_device.h+2−0
@@ -64,6 +64,8 @@ extern struct resource *platform_get_resource_byname(struct platform_device *, · 63 unmodified lines
64 unsigned int,64 unsigned int,
65 const char *);65 const char *);
66extern int platform_get_irq_byname(struct platform_device *, const char *);66extern int platform_get_irq_byname(struct platform_device *, const char *);
67extern int platform_get_irq_byname_optional(struct platform_device *dev,
68 const char *name);
67extern int platform_add_devices(struct platform_device **, int);69extern int platform_add_devices(struct platform_device **, int);
68 70
69struct platform_device_info {71struct platform_device_info {