Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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()
...

+431 -961
+2 -2
Documentation/devicetree/bindings/usb/amlogic,dwc3.txt
··· 85 85 the node is not important. The content of the node is defined in dwc2.txt. 86 86 87 87 PHY documentation is provided in the following places: 88 - - Documentation/devicetree/bindings/phy/meson-g12a-usb2-phy.txt 89 - - Documentation/devicetree/bindings/phy/meson-g12a-usb3-pcie-phy.txt 88 + - Documentation/devicetree/bindings/phy/amlogic,meson-g12a-usb2-phy.yaml 89 + - Documentation/devicetree/bindings/phy/amlogic,meson-g12a-usb3-pcie-phy.yaml 90 90 91 91 Example device nodes: 92 92 usb: usb@ffe09000 {
+6 -1
Documentation/devicetree/bindings/usb/generic-ehci.yaml
··· 63 63 description: 64 64 Set this flag to force EHCI reset after resume. 65 65 66 - phys: true 66 + phys: 67 + description: PHY specifier for the USB PHY 68 + 69 + phy-names: 70 + const: usb 67 71 68 72 required: 69 73 - compatible ··· 93 89 interrupts = <39>; 94 90 clocks = <&ahb_gates 1>; 95 91 phys = <&usbphy 1>; 92 + phy-names = "usb"; 96 93 }; 97 94 98 95 ...
+6 -1
Documentation/devicetree/bindings/usb/generic-ohci.yaml
··· 67 67 description: 68 68 Overrides the detected port count 69 69 70 - phys: true 70 + phys: 71 + description: PHY specifier for the USB PHY 72 + 73 + phy-names: 74 + const: usb 71 75 72 76 required: 73 77 - compatible ··· 88 84 interrupts = <64>; 89 85 clocks = <&usb_clk 6>, <&ahb_gates 2>; 90 86 phys = <&usbphy 1>; 87 + phy-names = "usb"; 91 88 }; 92 89 93 90 ...
+2 -2
Documentation/devicetree/bindings/usb/mediatek,mtk-xhci.txt
··· 33 33 "dma_ck": dma_bus clock for data transfer by DMA, 34 34 "xhci_ck": controller clock 35 35 36 - - phys : see usb-hcd.txt in the current directory 36 + - phys : see usb-hcd.yaml in the current directory 37 37 38 38 Optional properties: 39 39 - wakeup-source : enable USB remote wakeup; ··· 53 53 See: Documentation/devicetree/bindings/pinctrl/pinctrl-bindings.txt 54 54 - imod-interval-ns: default interrupt moderation interval is 5000ns 55 55 56 - additionally the properties from usb-hcd.txt (in the current directory) are 56 + additionally the properties from usb-hcd.yaml (in the current directory) are 57 57 supported. 58 58 59 59 Example:
+2 -2
Documentation/devicetree/bindings/usb/mediatek,mtu3.txt
··· 17 17 - clock-names : must contain "sys_ck" for clock of controller, 18 18 the following clocks are optional: 19 19 "ref_ck", "mcu_ck" and "dma_ck"; 20 - - phys : see usb-hcd.txt in the current directory 20 + - phys : see usb-hcd.yaml in the current directory 21 21 - dr_mode : should be one of "host", "peripheral" or "otg", 22 22 refer to usb/generic.txt 23 23 ··· 60 60 - mediatek,u3p-dis-msk : mask to disable u3ports, bit0 for u3port0, 61 61 bit1 for u3port1, ... etc; 62 62 63 - additionally the properties from usb-hcd.txt (in the current directory) are 63 + additionally the properties from usb-hcd.yaml (in the current directory) are 64 64 supported. 65 65 66 66 Sub-nodes:
+5
Documentation/devicetree/bindings/usb/usb-hcd.yaml
··· 18 18 description: 19 19 List of all the USB PHYs on this HCD 20 20 21 + phy-names: 22 + description: 23 + Name specifier for the USB PHY 24 + 21 25 examples: 22 26 - | 23 27 usb { 24 28 phys = <&usb2_phy1>, <&usb3_phy1>; 29 + phy-names = "usb"; 25 30 };
+1 -1
Documentation/devicetree/bindings/usb/usb-uhci.txt
··· 6 6 - reg : Should contain 1 register ranges(address and length) 7 7 - interrupts : UHCI controller interrupt 8 8 9 - additionally the properties from usb-hcd.txt (in the current directory) are 9 + additionally the properties from usb-hcd.yaml (in the current directory) are 10 10 supported. 11 11 12 12 Example:
+2 -2
Documentation/devicetree/bindings/usb/usb-xhci.txt
··· 41 41 - usb3-lpm-capable: determines if platform is USB3 LPM capable 42 42 - quirk-broken-port-ped: set if the controller has broken port disable mechanism 43 43 - imod-interval-ns: default interrupt moderation interval is 5000ns 44 - - phys : see usb-hcd.txt in the current directory 44 + - phys : see usb-hcd.yaml in the current directory 45 45 46 - additionally the properties from usb-hcd.txt (in the current directory) are 46 + additionally the properties from usb-hcd.yaml (in the current directory) are 47 47 supported. 48 48 49 49
-109
Documentation/usb/rio.rst
··· 1 - ============ 2 - Diamonds Rio 3 - ============ 4 - 5 - Copyright (C) 1999, 2000 Bruce Tenison 6 - 7 - Portions Copyright (C) 1999, 2000 David Nelson 8 - 9 - Thanks to David Nelson for guidance and the usage of the scanner.txt 10 - and scanner.c files to model our driver and this informative file. 11 - 12 - Mar. 2, 2000 13 - 14 - Changes 15 - ======= 16 - 17 - - Initial Revision 18 - 19 - 20 - Overview 21 - ======== 22 - 23 - This README will address issues regarding how to configure the kernel 24 - to access a RIO 500 mp3 player. 25 - Before I explain how to use this to access the Rio500 please be warned: 26 - 27 - .. warning:: 28 - 29 - Please note that this software is still under development. The authors 30 - are in no way responsible for any damage that may occur, no matter how 31 - inconsequential. 32 - 33 - It seems that the Rio has a problem when sending .mp3 with low batteries. 34 - I suggest when the batteries are low and you want to transfer stuff that you 35 - replace it with a fresh one. In my case, what happened is I lost two 16kb 36 - blocks (they are no longer usable to store information to it). But I don't 37 - know if that's normal or not; it could simply be a problem with the flash 38 - memory. 39 - 40 - In an extreme case, I left my Rio playing overnight and the batteries wore 41 - down to nothing and appear to have corrupted the flash memory. My RIO 42 - needed to be replaced as a result. Diamond tech support is aware of the 43 - problem. Do NOT allow your batteries to wear down to nothing before 44 - changing them. It appears RIO 500 firmware does not handle low battery 45 - power well at all. 46 - 47 - On systems with OHCI controllers, the kernel OHCI code appears to have 48 - power on problems with some chipsets. If you are having problems 49 - connecting to your RIO 500, try turning it on first and then plugging it 50 - into the USB cable. 51 - 52 - Contact Information 53 - ------------------- 54 - 55 - The main page for the project is hosted at sourceforge.net in the following 56 - URL: <http://rio500.sourceforge.net>. You can also go to the project's 57 - sourceforge home page at: <http://sourceforge.net/projects/rio500/>. 58 - There is also a mailing list: rio500-users@lists.sourceforge.net 59 - 60 - Authors 61 - ------- 62 - 63 - Most of the code was written by Cesar Miquel <miquel@df.uba.ar>. Keith 64 - Clayton <kclayton@jps.net> is incharge of the PPC port and making sure 65 - things work there. Bruce Tenison <btenison@dibbs.net> is adding support 66 - for .fon files and also does testing. The program will mostly sure be 67 - re-written and Pete Ikusz along with the rest will re-design it. I would 68 - also like to thank Tri Nguyen <tmn_3022000@hotmail.com> who provided use 69 - with some important information regarding the communication with the Rio. 70 - 71 - Additional Information and userspace tools 72 - 73 - http://rio500.sourceforge.net/ 74 - 75 - 76 - Requirements 77 - ============ 78 - 79 - A host with a USB port running a Linux kernel with RIO 500 support enabled. 80 - 81 - The driver is a module called rio500, which should be automatically loaded 82 - as you plug in your device. If that fails you can manually load it with 83 - 84 - modprobe rio500 85 - 86 - Udev should automatically create a device node as soon as plug in your device. 87 - If that fails, you can manually add a device for the USB rio500:: 88 - 89 - mknod /dev/usb/rio500 c 180 64 90 - 91 - In that case, set appropriate permissions for /dev/usb/rio500 (don't forget 92 - about group and world permissions). Both read and write permissions are 93 - required for proper operation. 94 - 95 - That's it. The Rio500 Utils at: http://rio500.sourceforge.net should 96 - be able to access the rio500. 97 - 98 - Limits 99 - ====== 100 - 101 - You can use only a single rio500 device at a time with your computer. 102 - 103 - Bugs 104 - ==== 105 - 106 - If you encounter any problems feel free to drop me an email. 107 - 108 - Bruce Tenison 109 - btenison@dibbs.net
-7
MAINTAINERS
··· 16764 16764 S: Maintained 16765 16765 F: drivers/net/usb/dm9601.c 16766 16766 16767 - USB DIAMOND RIO500 DRIVER 16768 - M: Cesar Miquel <miquel@df.uba.ar> 16769 - L: rio500-users@lists.sourceforge.net 16770 - W: http://rio500.sourceforge.net 16771 - S: Maintained 16772 - F: drivers/usb/misc/rio500* 16773 - 16774 16767 USB EHCI DRIVER 16775 16768 M: Alan Stern <stern@rowland.harvard.edu> 16776 16769 L: linux-usb@vger.kernel.org
+4
arch/arm/boot/dts/sun4i-a10.dtsi
··· 520 520 interrupts = <39>; 521 521 clocks = <&ccu CLK_AHB_EHCI0>; 522 522 phys = <&usbphy 1>; 523 + phy-names = "usb"; 523 524 status = "disabled"; 524 525 }; 525 526 ··· 530 529 interrupts = <64>; 531 530 clocks = <&ccu CLK_USB_OHCI0>, <&ccu CLK_AHB_OHCI0>; 532 531 phys = <&usbphy 1>; 532 + phy-names = "usb"; 533 533 status = "disabled"; 534 534 }; 535 535 ··· 610 608 interrupts = <40>; 611 609 clocks = <&ccu CLK_AHB_EHCI1>; 612 610 phys = <&usbphy 2>; 611 + phy-names = "usb"; 613 612 status = "disabled"; 614 613 }; 615 614 ··· 620 617 interrupts = <65>; 621 618 clocks = <&ccu CLK_USB_OHCI1>, <&ccu CLK_AHB_OHCI1>; 622 619 phys = <&usbphy 2>; 620 + phy-names = "usb"; 623 621 status = "disabled"; 624 622 }; 625 623
+2
arch/arm/boot/dts/sun5i.dtsi
··· 391 391 interrupts = <39>; 392 392 clocks = <&ccu CLK_AHB_EHCI>; 393 393 phys = <&usbphy 1>; 394 + phy-names = "usb"; 394 395 status = "disabled"; 395 396 }; 396 397 ··· 401 400 interrupts = <40>; 402 401 clocks = <&ccu CLK_USB_OHCI>, <&ccu CLK_AHB_OHCI>; 403 402 phys = <&usbphy 1>; 403 + phy-names = "usb"; 404 404 status = "disabled"; 405 405 }; 406 406
+4
arch/arm/boot/dts/sun6i-a31.dtsi
··· 545 545 clocks = <&ccu CLK_AHB1_EHCI0>; 546 546 resets = <&ccu RST_AHB1_EHCI0>; 547 547 phys = <&usbphy 1>; 548 + phy-names = "usb"; 548 549 status = "disabled"; 549 550 }; 550 551 ··· 556 555 clocks = <&ccu CLK_AHB1_OHCI0>, <&ccu CLK_USB_OHCI0>; 557 556 resets = <&ccu RST_AHB1_OHCI0>; 558 557 phys = <&usbphy 1>; 558 + phy-names = "usb"; 559 559 status = "disabled"; 560 560 }; 561 561 ··· 567 565 clocks = <&ccu CLK_AHB1_EHCI1>; 568 566 resets = <&ccu RST_AHB1_EHCI1>; 569 567 phys = <&usbphy 2>; 568 + phy-names = "usb"; 570 569 status = "disabled"; 571 570 }; 572 571 ··· 578 575 clocks = <&ccu CLK_AHB1_OHCI1>, <&ccu CLK_USB_OHCI1>; 579 576 resets = <&ccu RST_AHB1_OHCI1>; 580 577 phys = <&usbphy 2>; 578 + phy-names = "usb"; 581 579 status = "disabled"; 582 580 }; 583 581
+4
arch/arm/boot/dts/sun7i-a20.dtsi
··· 623 623 interrupts = <GIC_SPI 39 IRQ_TYPE_LEVEL_HIGH>; 624 624 clocks = <&ccu CLK_AHB_EHCI0>; 625 625 phys = <&usbphy 1>; 626 + phy-names = "usb"; 626 627 status = "disabled"; 627 628 }; 628 629 ··· 633 632 interrupts = <GIC_SPI 64 IRQ_TYPE_LEVEL_HIGH>; 634 633 clocks = <&ccu CLK_USB_OHCI0>, <&ccu CLK_AHB_OHCI0>; 635 634 phys = <&usbphy 1>; 635 + phy-names = "usb"; 636 636 status = "disabled"; 637 637 }; 638 638 ··· 716 714 interrupts = <GIC_SPI 40 IRQ_TYPE_LEVEL_HIGH>; 717 715 clocks = <&ccu CLK_AHB_EHCI1>; 718 716 phys = <&usbphy 2>; 717 + phy-names = "usb"; 719 718 status = "disabled"; 720 719 }; 721 720 ··· 726 723 interrupts = <GIC_SPI 65 IRQ_TYPE_LEVEL_HIGH>; 727 724 clocks = <&ccu CLK_USB_OHCI1>, <&ccu CLK_AHB_OHCI1>; 728 725 phys = <&usbphy 2>; 726 + phy-names = "usb"; 729 727 status = "disabled"; 730 728 }; 731 729
+2
arch/arm/boot/dts/sun8i-a23-a33.dtsi
··· 307 307 clocks = <&ccu CLK_BUS_EHCI>; 308 308 resets = <&ccu RST_BUS_EHCI>; 309 309 phys = <&usbphy 1>; 310 + phy-names = "usb"; 310 311 status = "disabled"; 311 312 }; 312 313 ··· 318 317 clocks = <&ccu CLK_BUS_OHCI>, <&ccu CLK_USB_OHCI>; 319 318 resets = <&ccu RST_BUS_OHCI>; 320 319 phys = <&usbphy 1>; 320 + phy-names = "usb"; 321 321 status = "disabled"; 322 322 }; 323 323
+3
arch/arm/boot/dts/sun8i-a83t.dtsi
··· 632 632 clocks = <&ccu CLK_BUS_EHCI0>; 633 633 resets = <&ccu RST_BUS_EHCI0>; 634 634 phys = <&usbphy 1>; 635 + phy-names = "usb"; 635 636 status = "disabled"; 636 637 }; 637 638 ··· 644 643 clocks = <&ccu CLK_BUS_OHCI0>, <&ccu CLK_USB_OHCI0>; 645 644 resets = <&ccu RST_BUS_OHCI0>; 646 645 phys = <&usbphy 1>; 646 + phy-names = "usb"; 647 647 status = "disabled"; 648 648 }; 649 649 ··· 656 654 clocks = <&ccu CLK_BUS_EHCI1>; 657 655 resets = <&ccu RST_BUS_EHCI1>; 658 656 phys = <&usbphy 2>; 657 + phy-names = "usb"; 659 658 status = "disabled"; 660 659 }; 661 660
+4
arch/arm/boot/dts/sun8i-r40.dtsi
··· 273 273 clocks = <&ccu CLK_BUS_EHCI1>; 274 274 resets = <&ccu RST_BUS_EHCI1>; 275 275 phys = <&usbphy 1>; 276 + phy-names = "usb"; 276 277 status = "disabled"; 277 278 }; 278 279 ··· 285 284 <&ccu CLK_USB_OHCI1>; 286 285 resets = <&ccu RST_BUS_OHCI1>; 287 286 phys = <&usbphy 1>; 287 + phy-names = "usb"; 288 288 status = "disabled"; 289 289 }; 290 290 ··· 296 294 clocks = <&ccu CLK_BUS_EHCI2>; 297 295 resets = <&ccu RST_BUS_EHCI2>; 298 296 phys = <&usbphy 2>; 297 + phy-names = "usb"; 299 298 status = "disabled"; 300 299 }; 301 300 ··· 308 305 <&ccu CLK_USB_OHCI2>; 309 306 resets = <&ccu RST_BUS_OHCI2>; 310 307 phys = <&usbphy 2>; 308 + phy-names = "usb"; 311 309 status = "disabled"; 312 310 }; 313 311
+5
arch/arm/boot/dts/sun9i-a80.dtsi
··· 346 346 clocks = <&usb_clocks CLK_BUS_HCI0>; 347 347 resets = <&usb_clocks RST_USB0_HCI>; 348 348 phys = <&usbphy1>; 349 + phy-names = "usb"; 349 350 status = "disabled"; 350 351 }; 351 352 ··· 358 357 <&usb_clocks CLK_USB_OHCI0>; 359 358 resets = <&usb_clocks RST_USB0_HCI>; 360 359 phys = <&usbphy1>; 360 + phy-names = "usb"; 361 361 status = "disabled"; 362 362 }; 363 363 ··· 380 378 clocks = <&usb_clocks CLK_BUS_HCI1>; 381 379 resets = <&usb_clocks RST_USB1_HCI>; 382 380 phys = <&usbphy2>; 381 + phy-names = "usb"; 383 382 status = "disabled"; 384 383 }; 385 384 ··· 410 407 clocks = <&usb_clocks CLK_BUS_HCI2>; 411 408 resets = <&usb_clocks RST_USB2_HCI>; 412 409 phys = <&usbphy3>; 410 + phy-names = "usb"; 413 411 status = "disabled"; 414 412 }; 415 413 ··· 422 418 <&usb_clocks CLK_USB_OHCI2>; 423 419 resets = <&usb_clocks RST_USB2_HCI>; 424 420 phys = <&usbphy3>; 421 + phy-names = "usb"; 425 422 status = "disabled"; 426 423 }; 427 424
+6
arch/arm/boot/dts/sunxi-h3-h5.dtsi
··· 304 304 clocks = <&ccu CLK_BUS_EHCI1>, <&ccu CLK_BUS_OHCI1>; 305 305 resets = <&ccu RST_BUS_EHCI1>, <&ccu RST_BUS_OHCI1>; 306 306 phys = <&usbphy 1>; 307 + phy-names = "usb"; 307 308 status = "disabled"; 308 309 }; 309 310 ··· 316 315 <&ccu CLK_USB_OHCI1>; 317 316 resets = <&ccu RST_BUS_EHCI1>, <&ccu RST_BUS_OHCI1>; 318 317 phys = <&usbphy 1>; 318 + phy-names = "usb"; 319 319 status = "disabled"; 320 320 }; 321 321 ··· 327 325 clocks = <&ccu CLK_BUS_EHCI2>, <&ccu CLK_BUS_OHCI2>; 328 326 resets = <&ccu RST_BUS_EHCI2>, <&ccu RST_BUS_OHCI2>; 329 327 phys = <&usbphy 2>; 328 + phy-names = "usb"; 330 329 status = "disabled"; 331 330 }; 332 331 ··· 339 336 <&ccu CLK_USB_OHCI2>; 340 337 resets = <&ccu RST_BUS_EHCI2>, <&ccu RST_BUS_OHCI2>; 341 338 phys = <&usbphy 2>; 339 + phy-names = "usb"; 342 340 status = "disabled"; 343 341 }; 344 342 ··· 350 346 clocks = <&ccu CLK_BUS_EHCI3>, <&ccu CLK_BUS_OHCI3>; 351 347 resets = <&ccu RST_BUS_EHCI3>, <&ccu RST_BUS_OHCI3>; 352 348 phys = <&usbphy 3>; 349 + phy-names = "usb"; 353 350 status = "disabled"; 354 351 }; 355 352 ··· 362 357 <&ccu CLK_USB_OHCI3>; 363 358 resets = <&ccu RST_BUS_EHCI3>, <&ccu RST_BUS_OHCI3>; 364 359 phys = <&usbphy 3>; 360 + phy-names = "usb"; 365 361 status = "disabled"; 366 362 }; 367 363
-1
arch/arm/configs/badge4_defconfig
··· 91 91 CONFIG_USB_SERIAL_CYBERJACK=m 92 92 CONFIG_USB_SERIAL_XIRCOM=m 93 93 CONFIG_USB_SERIAL_OMNINET=m 94 - CONFIG_USB_RIO500=m 95 94 CONFIG_EXT2_FS=m 96 95 CONFIG_EXT3_FS=m 97 96 CONFIG_MSDOS_FS=y
-1
arch/arm/configs/corgi_defconfig
··· 195 195 CONFIG_USB_SERIAL_OMNINET=m 196 196 CONFIG_USB_EMI62=m 197 197 CONFIG_USB_EMI26=m 198 - CONFIG_USB_RIO500=m 199 198 CONFIG_USB_LEGOTOWER=m 200 199 CONFIG_USB_LCD=m 201 200 CONFIG_USB_CYTHERM=m
-1
arch/arm/configs/pxa_defconfig
··· 581 581 CONFIG_USB_SERIAL_OMNINET=m 582 582 CONFIG_USB_EMI62=m 583 583 CONFIG_USB_EMI26=m 584 - CONFIG_USB_RIO500=m 585 584 CONFIG_USB_LEGOTOWER=m 586 585 CONFIG_USB_LCD=m 587 586 CONFIG_USB_CYTHERM=m
-1
arch/arm/configs/s3c2410_defconfig
··· 327 327 CONFIG_USB_EMI26=m 328 328 CONFIG_USB_ADUTUX=m 329 329 CONFIG_USB_SEVSEG=m 330 - CONFIG_USB_RIO500=m 331 330 CONFIG_USB_LEGOTOWER=m 332 331 CONFIG_USB_LCD=m 333 332 CONFIG_USB_CYPRESS_CY7C63=m
-1
arch/arm/configs/spitz_defconfig
··· 189 189 CONFIG_USB_SERIAL_OMNINET=m 190 190 CONFIG_USB_EMI62=m 191 191 CONFIG_USB_EMI26=m 192 - CONFIG_USB_RIO500=m 193 192 CONFIG_USB_LEGOTOWER=m 194 193 CONFIG_USB_LCD=m 195 194 CONFIG_USB_CYTHERM=m
+2
arch/arm64/boot/dts/allwinner/sun50i-a64-pinebook.dts
··· 104 104 105 105 &ehci0 { 106 106 phys = <&usbphy 0>; 107 + phy-names = "usb"; 107 108 status = "okay"; 108 109 }; 109 110 ··· 151 150 152 151 &ohci0 { 153 152 phys = <&usbphy 0>; 153 + phy-names = "usb"; 154 154 status = "okay"; 155 155 }; 156 156
+2
arch/arm64/boot/dts/allwinner/sun50i-a64.dtsi
··· 553 553 resets = <&ccu RST_BUS_OHCI1>, 554 554 <&ccu RST_BUS_EHCI1>; 555 555 phys = <&usbphy 1>; 556 + phy-names = "usb"; 556 557 status = "disabled"; 557 558 }; 558 559 ··· 565 564 <&ccu CLK_USB_OHCI1>; 566 565 resets = <&ccu RST_BUS_OHCI1>; 567 566 phys = <&usbphy 1>; 567 + phy-names = "usb"; 568 568 status = "disabled"; 569 569 }; 570 570
+2
arch/arm64/boot/dts/allwinner/sun50i-h6.dtsi
··· 547 547 resets = <&ccu RST_BUS_OHCI3>, 548 548 <&ccu RST_BUS_EHCI3>; 549 549 phys = <&usb2phy 3>; 550 + phy-names = "usb"; 550 551 status = "disabled"; 551 552 }; 552 553 ··· 559 558 <&ccu CLK_USB_OHCI3>; 560 559 resets = <&ccu RST_BUS_OHCI3>; 561 560 phys = <&usb2phy 3>; 561 + phy-names = "usb"; 562 562 status = "disabled"; 563 563 }; 564 564
-1
arch/mips/configs/mtx1_defconfig
··· 571 571 CONFIG_USB_EMI62=m 572 572 CONFIG_USB_EMI26=m 573 573 CONFIG_USB_ADUTUX=m 574 - CONFIG_USB_RIO500=m 575 574 CONFIG_USB_LEGOTOWER=m 576 575 CONFIG_USB_LCD=m 577 576 CONFIG_USB_CYPRESS_CY7C63=m
-1
arch/mips/configs/rm200_defconfig
··· 314 314 CONFIG_USB_SERIAL_CYBERJACK=m 315 315 CONFIG_USB_SERIAL_XIRCOM=m 316 316 CONFIG_USB_SERIAL_OMNINET=m 317 - CONFIG_USB_RIO500=m 318 317 CONFIG_USB_LEGOTOWER=m 319 318 CONFIG_USB_LCD=m 320 319 CONFIG_USB_CYTHERM=m
+39 -7
drivers/base/platform.c
··· 241 241 } 242 242 EXPORT_SYMBOL_GPL(platform_get_resource_byname); 243 243 244 - /** 245 - * platform_get_irq_byname - get an IRQ for a device by name 246 - * @dev: platform device 247 - * @name: IRQ name 248 - */ 249 - int platform_get_irq_byname(struct platform_device *dev, const char *name) 244 + static int __platform_get_irq_byname(struct platform_device *dev, 245 + const char *name) 250 246 { 251 247 struct resource *r; 252 248 ··· 258 262 if (r) 259 263 return r->start; 260 264 261 - dev_err(&dev->dev, "IRQ %s not found\n", name); 262 265 return -ENXIO; 263 266 } 267 + 268 + /** 269 + * platform_get_irq_byname - get an IRQ for a device by name 270 + * @dev: platform device 271 + * @name: IRQ name 272 + * 273 + * Get an IRQ like platform_get_irq(), but then by name rather then by index. 274 + * 275 + * Return: IRQ number on success, negative error number on failure. 276 + */ 277 + int platform_get_irq_byname(struct platform_device *dev, const char *name) 278 + { 279 + int ret; 280 + 281 + ret = __platform_get_irq_byname(dev, name); 282 + if (ret < 0 && ret != -EPROBE_DEFER) 283 + dev_err(&dev->dev, "IRQ %s not found\n", name); 284 + 285 + return ret; 286 + } 264 287 EXPORT_SYMBOL_GPL(platform_get_irq_byname); 288 + 289 + /** 290 + * platform_get_irq_byname_optional - get an optional IRQ for a device by name 291 + * @dev: platform device 292 + * @name: IRQ name 293 + * 294 + * Get an optional IRQ by name like platform_get_irq_byname(). Except that it 295 + * does not print an error message if an IRQ can not be obtained. 296 + * 297 + * Return: IRQ number on success, negative error number on failure. 298 + */ 299 + int platform_get_irq_byname_optional(struct platform_device *dev, 300 + const char *name) 301 + { 302 + return __platform_get_irq_byname(dev, name); 303 + } 304 + EXPORT_SYMBOL_GPL(platform_get_irq_byname_optional); 265 305 266 306 /** 267 307 * platform_add_devices - add a numbers of platform devices
+1 -2
drivers/media/usb/stkwebcam/stk-webcam.c
··· 643 643 dev->owner = NULL; 644 644 } 645 645 646 - if (is_present(dev)) 647 - usb_autopm_put_interface(dev->interface); 646 + usb_autopm_put_interface(dev->interface); 648 647 mutex_unlock(&dev->lock); 649 648 return v4l2_fh_release(fp); 650 649 }
+2 -1
drivers/usb/cdns3/cdns3-pci-wrap.c
··· 159 159 wrap->plat_dev = platform_device_register_full(&plat_info); 160 160 if (IS_ERR(wrap->plat_dev)) { 161 161 pci_disable_device(pdev); 162 + err = PTR_ERR(wrap->plat_dev); 162 163 kfree(wrap); 163 - return PTR_ERR(wrap->plat_dev); 164 + return err; 164 165 } 165 166 } 166 167
+19 -1
drivers/usb/cdns3/core.c
··· 160 160 if (ret) 161 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 171 ret = cdns3_hw_role_switch(cdns); 165 172 if (ret) 166 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 187 return ret;
+9 -3
drivers/usb/cdns3/ep0.c
··· 234 234 static int cdns3_req_ep0_get_status(struct cdns3_device *priv_dev, 235 235 struct usb_ctrlrequest *ctrl) 236 236 { 237 + struct cdns3_endpoint *priv_ep; 237 238 __le16 *response_pkt; 238 239 u16 usb_status = 0; 239 240 u32 recip; 241 + u8 index; 240 242 241 243 recip = ctrl->bRequestType & USB_RECIP_MASK; 242 244 ··· 264 262 case USB_RECIP_INTERFACE: 265 263 return cdns3_ep0_delegate_req(priv_dev, ctrl); 266 264 case USB_RECIP_ENDPOINT: 267 - /* check if endpoint is stalled */ 265 + index = cdns3_ep_addr_to_index(ctrl->wIndex); 266 + priv_ep = priv_dev->eps[index]; 267 + 268 + /* check if endpoint is stalled or stall is pending */ 268 269 cdns3_select_ep(priv_dev, ctrl->wIndex); 269 - if (EP_STS_STALL(readl(&priv_dev->regs->ep_sts))) 270 + if (EP_STS_STALL(readl(&priv_dev->regs->ep_sts)) || 271 + (priv_ep->flags & EP_STALL_PENDING)) 270 272 usb_status = BIT(USB_ENDPOINT_HALT); 271 273 break; 272 274 default: ··· 338 332 * for sending status stage. 339 333 * This time should be less then 3ms. 340 334 */ 341 - usleep_range(1000, 2000); 335 + mdelay(1); 342 336 cdns3_set_register_bit(&priv_dev->regs->usb_cmd, 343 337 USB_CMD_STMODE | 344 338 USB_STS_TMODE_SEL(tmode - 1));
+8
drivers/usb/cdns3/gadget.c
··· 2571 2571 switch (max_speed) { 2572 2572 case USB_SPEED_FULL: 2573 2573 writel(USB_CONF_SFORCE_FS, &priv_dev->regs->usb_conf); 2574 + writel(USB_CONF_USB3DIS, &priv_dev->regs->usb_conf); 2574 2575 break; 2575 2576 case USB_SPEED_HIGH: 2576 2577 writel(USB_CONF_USB3DIS, &priv_dev->regs->usb_conf); ··· 2662 2661 static int __cdns3_gadget_init(struct cdns3 *cdns) 2663 2662 { 2664 2663 int ret = 0; 2664 + 2665 + /* Ensure 32-bit DMA Mask in case we switched back from Host mode */ 2666 + ret = dma_set_mask_and_coherent(cdns->dev, DMA_BIT_MASK(32)); 2667 + if (ret) { 2668 + dev_err(cdns->dev, "Failed to set dma mask: %d\n", ret); 2669 + return ret; 2670 + } 2665 2671 2666 2672 cdns3_drd_switch_gadget(cdns, 1); 2667 2673 pm_runtime_get_sync(cdns->dev);
+5 -3
drivers/usb/class/usblp.c
··· 461 461 462 462 mutex_lock(&usblp_mutex); 463 463 usblp->used = 0; 464 - if (usblp->present) { 464 + if (usblp->present) 465 465 usblp_unlink_urbs(usblp); 466 - usb_autopm_put_interface(usblp->intf); 467 - } else /* finish cleanup from disconnect */ 466 + 467 + usb_autopm_put_interface(usblp->intf); 468 + 469 + if (!usblp->present) /* finish cleanup from disconnect */ 468 470 usblp_cleanup(usblp); 469 471 mutex_unlock(&usblp_mutex); 470 472 return 0;
+2 -5
drivers/usb/dwc3/drd.c
··· 139 139 struct platform_device *dwc3_pdev = to_platform_device(dwc->dev); 140 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 143 if (irq > 0) 144 144 goto out; 145 145 146 146 if (irq == -EPROBE_DEFER) 147 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 150 if (irq > 0) 151 151 goto out; 152 152 ··· 156 156 irq = platform_get_irq(dwc3_pdev, 0); 157 157 if (irq > 0) 158 158 goto out; 159 - 160 - if (irq != -EPROBE_DEFER) 161 - dev_err(dwc->dev, "missing OTG IRQ\n"); 162 159 163 160 if (!irq) 164 161 irq = -EINVAL;
+2 -5
drivers/usb/dwc3/gadget.c
··· 3264 3264 struct platform_device *dwc3_pdev = to_platform_device(dwc->dev); 3265 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 3268 if (irq > 0) 3269 3269 goto out; 3270 3270 3271 3271 if (irq == -EPROBE_DEFER) 3272 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 3275 if (irq > 0) 3276 3276 goto out; 3277 3277 ··· 3281 3281 irq = platform_get_irq(dwc3_pdev, 0); 3282 3282 if (irq > 0) 3283 3283 goto out; 3284 - 3285 - if (irq != -EPROBE_DEFER) 3286 - dev_err(dwc->dev, "missing peripheral IRQ\n"); 3287 3284 3288 3285 if (!irq) 3289 3286 irq = -EINVAL;
+2 -5
drivers/usb/dwc3/host.c
··· 16 16 struct platform_device *dwc3_pdev = to_platform_device(dwc->dev); 17 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 20 if (irq > 0) 21 21 goto out; 22 22 23 23 if (irq == -EPROBE_DEFER) 24 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 27 if (irq > 0) 28 28 goto out; 29 29 ··· 33 33 irq = platform_get_irq(dwc3_pdev, 0); 34 34 if (irq > 0) 35 35 goto out; 36 - 37 - if (irq != -EPROBE_DEFER) 38 - dev_err(dwc->dev, "missing host IRQ\n"); 39 36 40 37 if (!irq) 41 38 irq = -EINVAL;
+1 -1
drivers/usb/gadget/udc/Kconfig
··· 45 45 46 46 config USB_LPC32XX 47 47 tristate "LPC32XX USB Peripheral Controller" 48 - depends on ARCH_LPC32XX 48 + depends on ARCH_LPC32XX || COMPILE_TEST 49 49 depends on I2C 50 50 select USB_ISP1301 51 51 help
+2 -1
drivers/usb/gadget/udc/dummy_hcd.c
··· 48 48 #define DRIVER_VERSION "02 May 2005" 49 49 50 50 #define POWER_BUDGET 500 /* in mA; use 8 for low-power port testing */ 51 + #define POWER_BUDGET_3 900 /* in mA */ 51 52 52 53 static const char driver_name[] = "dummy_hcd"; 53 54 static const char driver_desc[] = "USB Host+Gadget Emulator"; ··· 2433 2432 dum_hcd->rh_state = DUMMY_RH_RUNNING; 2434 2433 dum_hcd->stream_en_ep = 0; 2435 2434 INIT_LIST_HEAD(&dum_hcd->urbp_list); 2436 - dummy_hcd_to_hcd(dum_hcd)->power_budget = POWER_BUDGET; 2435 + dummy_hcd_to_hcd(dum_hcd)->power_budget = POWER_BUDGET_3; 2437 2436 dummy_hcd_to_hcd(dum_hcd)->state = HC_STATE_RUNNING; 2438 2437 dummy_hcd_to_hcd(dum_hcd)->uses_new_polling = 1; 2439 2438 #ifdef CONFIG_USB_OTG
+2 -2
drivers/usb/gadget/udc/lpc32xx_udc.c
··· 1151 1151 u32 *p32, tmp, cbytes; 1152 1152 1153 1153 /* Use optimal data transfer method based on source address and size */ 1154 - switch (((u32) data) & 0x3) { 1154 + switch (((uintptr_t) data) & 0x3) { 1155 1155 case 0: /* 32-bit aligned */ 1156 1156 p32 = (u32 *) data; 1157 1157 cbytes = (bytes & ~0x3); ··· 1252 1252 u32 *p32, tmp, cbytes; 1253 1253 1254 1254 /* Use optimal data transfer method based on source address and size */ 1255 - switch (((u32) data) & 0x3) { 1255 + switch (((uintptr_t) data) & 0x3) { 1256 1256 case 0: /* 32-bit aligned */ 1257 1257 p32 = (u32 *) data; 1258 1258 cbytes = (bytes & ~0x3);
+1
drivers/usb/host/xhci-ext-caps.c
··· 57 57 ret = platform_device_add_properties(pdev, role_switch_props); 58 58 if (ret) { 59 59 dev_err(dev, "failed to register device properties\n"); 60 + platform_device_put(pdev); 60 61 return ret; 61 62 } 62 63 }
+2 -2
drivers/usb/host/xhci-ring.c
··· 3202 3202 if (usb_urb_dir_out(urb)) { 3203 3203 len = sg_pcopy_to_buffer(urb->sg, urb->num_sgs, 3204 3204 seg->bounce_buf, new_buff_len, enqd_len); 3205 - if (len != seg->bounce_len) 3205 + if (len != new_buff_len) 3206 3206 xhci_warn(xhci, 3207 3207 "WARN Wrong bounce buffer write length: %zu != %d\n", 3208 - len, seg->bounce_len); 3208 + len, new_buff_len); 3209 3209 seg->bounce_dma = dma_map_single(dev, seg->bounce_buf, 3210 3210 max_pkt, DMA_TO_DEVICE); 3211 3211 } else {
+63 -15
drivers/usb/host/xhci.c
··· 1032 1032 writel(command, &xhci->op_regs->command); 1033 1033 xhci->broken_suspend = 0; 1034 1034 if (xhci_handshake(&xhci->op_regs->status, 1035 - STS_SAVE, 0, 10 * 1000)) { 1035 + STS_SAVE, 0, 20 * 1000)) { 1036 1036 /* 1037 1037 * AMD SNPS xHC 3.0 occasionally does not clear the 1038 1038 * SSS bit of USBSTS and when driver tries to poll ··· 1108 1108 hibernated = true; 1109 1109 1110 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 1123 /* step 1: restore register */ 1112 1124 xhci_restore_registers(xhci); 1113 1125 /* step 2: initialize command ring buffer */ ··· 3095 3083 unsigned int ep_index; 3096 3084 unsigned long flags; 3097 3085 u32 ep_flag; 3086 + int err; 3098 3087 3099 3088 xhci = hcd_to_xhci(hcd); 3100 3089 if (!host_ep->hcpriv) ··· 3155 3142 xhci_free_command(xhci, cfg_cmd); 3156 3143 goto cleanup; 3157 3144 } 3158 - xhci_queue_stop_endpoint(xhci, stop_cmd, udev->slot_id, ep_index, 0); 3145 + 3146 + err = xhci_queue_stop_endpoint(xhci, stop_cmd, udev->slot_id, 3147 + ep_index, 0); 3148 + if (err < 0) { 3149 + spin_unlock_irqrestore(&xhci->lock, flags); 3150 + xhci_free_command(xhci, cfg_cmd); 3151 + xhci_dbg(xhci, "%s: Failed to queue stop ep command, %d ", 3152 + __func__, err); 3153 + goto cleanup; 3154 + } 3155 + 3159 3156 xhci_ring_cmd_db(xhci); 3160 3157 spin_unlock_irqrestore(&xhci->lock, flags); 3161 3158 ··· 3179 3156 ctrl_ctx, ep_flag, ep_flag); 3180 3157 xhci_endpoint_copy(xhci, cfg_cmd->in_ctx, vdev->out_ctx, ep_index); 3181 3158 3182 - xhci_queue_configure_endpoint(xhci, cfg_cmd, cfg_cmd->in_ctx->dma, 3159 + err = xhci_queue_configure_endpoint(xhci, cfg_cmd, cfg_cmd->in_ctx->dma, 3183 3160 udev->slot_id, false); 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 config ep command, %d ", 3165 + __func__, err); 3166 + goto cleanup; 3167 + } 3168 + 3184 3169 xhci_ring_cmd_db(xhci); 3185 3170 spin_unlock_irqrestore(&xhci->lock, flags); 3186 3171 ··· 4705 4674 alt_timeout = xhci_call_host_update_timeout_for_endpoint(xhci, udev, 4706 4675 desc, state, timeout); 4707 4676 4708 - /* If we found we can't enable hub-initiated LPM, or 4677 + /* If we found we can't enable hub-initiated LPM, and 4709 4678 * the U1 or U2 exit latency was too high to allow 4710 - * device-initiated LPM as well, just stop searching. 4679 + * device-initiated LPM as well, then we will disable LPM 4680 + * for this device, so stop searching any further. 4711 4681 */ 4712 - if (alt_timeout == USB3_LPM_DISABLED || 4713 - alt_timeout == USB3_LPM_DEVICE_INITIATED) { 4682 + if (alt_timeout == USB3_LPM_DISABLED) { 4714 4683 *timeout = alt_timeout; 4715 4684 return -E2BIG; 4716 4685 } ··· 4821 4790 if (intf->dev.driver) { 4822 4791 driver = to_usb_driver(intf->dev.driver); 4823 4792 if (driver && driver->disable_hub_initiated_lpm) { 4824 - dev_dbg(&udev->dev, "Hub-initiated %s disabled " 4825 - "at request of driver %s\n", 4826 - state_name, driver->name); 4827 - return xhci_get_timeout_no_hub_lpm(udev, state); 4793 + dev_dbg(&udev->dev, "Hub-initiated %s disabled at request of driver %s\n", 4794 + state_name, driver->name); 4795 + timeout = xhci_get_timeout_no_hub_lpm(udev, 4796 + state); 4797 + if (timeout == USB3_LPM_DISABLED) 4798 + return timeout; 4828 4799 } 4829 4800 } 4830 4801 ··· 5110 5077 hcd->has_tt = 1; 5111 5078 } else { 5112 5079 /* 5113 - * Some 3.1 hosts return sbrn 0x30, use xhci supported protocol 5114 - * minor revision instead of sbrn. Minor revision is a two digit 5115 - * BCD containing minor and sub-minor numbers, only show minor. 5080 + * Early xHCI 1.1 spec did not mention USB 3.1 capable hosts 5081 + * should return 0x31 for sbrn, or that the minor revision 5082 + * is a two digit BCD containig minor and sub-minor numbers. 5083 + * This was later clarified in xHCI 1.2. 5084 + * 5085 + * Some USB 3.1 capable hosts therefore have sbrn 0x30, and 5086 + * minor revision set to 0x1 instead of 0x10. 5116 5087 */ 5117 - minor_rev = xhci->usb3_rhub.min_rev / 0x10; 5088 + if (xhci->usb3_rhub.min_rev == 0x1) 5089 + minor_rev = 1; 5090 + else 5091 + minor_rev = xhci->usb3_rhub.min_rev / 0x10; 5118 5092 5119 5093 switch (minor_rev) { 5120 5094 case 2: ··· 5238 5198 unsigned int ep_index; 5239 5199 unsigned long flags; 5240 5200 5201 + /* 5202 + * udev might be NULL if tt buffer is cleared during a failed device 5203 + * enumeration due to a halted control endpoint. Usb core might 5204 + * have allocated a new udev for the next enumeration attempt. 5205 + */ 5206 + 5241 5207 xhci = hcd_to_xhci(hcd); 5242 5208 udev = (struct usb_device *)ep->hcpriv; 5209 + if (!udev) 5210 + return; 5243 5211 slot_id = udev->slot_id; 5244 5212 ep_index = xhci_get_endpoint_index(&ep->desc); 5245 5213
+4
drivers/usb/image/microtek.c
··· 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 724 if ( ep_out == -1 ) { 721 725 MTS_WARNING( "couldn't find an output bulk endpoint. Bailing out.\n" );
-10
drivers/usb/misc/Kconfig
··· 47 47 To compile this driver as a module, choose M here: the 48 48 module will be called usbsevseg. 49 49 50 - config USB_RIO500 51 - tristate "USB Diamond Rio500 support" 52 - help 53 - Say Y here if you want to connect a USB Rio500 mp3 player to your 54 - computer's USB port. Please read <file:Documentation/usb/rio.rst> 55 - for more information. 56 - 57 - To compile this driver as a module, choose M here: the 58 - module will be called rio500. 59 - 60 50 config USB_LEGOTOWER 61 51 tristate "USB Lego Infrared Tower support" 62 52 help
-1
drivers/usb/misc/Makefile
··· 17 17 obj-$(CONFIG_USB_LCD) += usblcd.o 18 18 obj-$(CONFIG_USB_LD) += ldusb.o 19 19 obj-$(CONFIG_USB_LEGOTOWER) += legousbtower.o 20 - obj-$(CONFIG_USB_RIO500) += rio500.o 21 20 obj-$(CONFIG_USB_TEST) += usbtest.o 22 21 obj-$(CONFIG_USB_EHSET_TEST_FIXTURE) += ehset.o 23 22 obj-$(CONFIG_USB_TRANCEVIBRATOR) += trancevibrator.o
+15 -9
drivers/usb/misc/adutux.c
··· 75 75 char serial_number[8]; 76 76 77 77 int open_count; /* number of times this port has been opened */ 78 + unsigned long disconnected:1; 78 79 79 80 char *read_buffer_primary; 80 81 int read_buffer_length; ··· 117 116 { 118 117 unsigned long flags; 119 118 120 - if (dev->udev == NULL) 119 + if (dev->disconnected) 121 120 return; 122 121 123 122 /* shutdown transfer */ ··· 149 148 kfree(dev->read_buffer_secondary); 150 149 kfree(dev->interrupt_in_buffer); 151 150 kfree(dev->interrupt_out_buffer); 151 + usb_put_dev(dev->udev); 152 152 kfree(dev); 153 153 } 154 154 ··· 245 243 } 246 244 247 245 dev = usb_get_intfdata(interface); 248 - if (!dev || !dev->udev) { 246 + if (!dev) { 249 247 retval = -ENODEV; 250 248 goto exit_no_device; 251 249 } ··· 328 326 } 329 327 330 328 adu_release_internal(dev); 331 - if (dev->udev == NULL) { 329 + if (dev->disconnected) { 332 330 /* the device was unplugged before the file was released */ 333 331 if (!dev->open_count) /* ... and we're the last user */ 334 332 adu_delete(dev); ··· 356 354 return -ERESTARTSYS; 357 355 358 356 /* verify that the device wasn't unplugged */ 359 - if (dev->udev == NULL) { 357 + if (dev->disconnected) { 360 358 retval = -ENODEV; 361 359 pr_err("No device or device unplugged %d\n", retval); 362 360 goto exit; ··· 520 518 goto exit_nolock; 521 519 522 520 /* verify that the device wasn't unplugged */ 523 - if (dev->udev == NULL) { 521 + if (dev->disconnected) { 524 522 retval = -ENODEV; 525 523 pr_err("No device or device unplugged %d\n", retval); 526 524 goto exit; ··· 665 663 666 664 mutex_init(&dev->mtx); 667 665 spin_lock_init(&dev->buflock); 668 - dev->udev = udev; 666 + dev->udev = usb_get_dev(udev); 669 667 init_waitqueue_head(&dev->read_wait); 670 668 init_waitqueue_head(&dev->write_wait); 671 669 ··· 764 762 765 763 dev = usb_get_intfdata(interface); 766 764 767 - mutex_lock(&dev->mtx); /* not interruptible */ 768 - dev->udev = NULL; /* poison */ 769 765 usb_deregister_dev(interface, &adu_class); 770 - mutex_unlock(&dev->mtx); 766 + 767 + usb_poison_urb(dev->interrupt_in_urb); 768 + usb_poison_urb(dev->interrupt_out_urb); 771 769 772 770 mutex_lock(&adutux_mutex); 773 771 usb_set_intfdata(interface, NULL); 772 + 773 + mutex_lock(&dev->mtx); /* not interruptible */ 774 + dev->disconnected = 1; 775 + mutex_unlock(&dev->mtx); 774 776 775 777 /* if the device is not opened, then we clean up right now */ 776 778 if (!dev->open_count)
+3 -2
drivers/usb/misc/chaoskey.c
··· 98 98 usb_free_urb(dev->urb); 99 99 kfree(dev->name); 100 100 kfree(dev->buf); 101 + usb_put_intf(dev->interface); 101 102 kfree(dev); 102 103 } 103 104 } ··· 146 145 if (dev == NULL) 147 146 goto out; 148 147 148 + dev->interface = usb_get_intf(interface); 149 + 149 150 dev->buf = kmalloc(size, GFP_KERNEL); 150 151 151 152 if (dev->buf == NULL) ··· 176 173 if (dev->name == NULL) 177 174 goto out; 178 175 } 179 - 180 - dev->interface = interface; 181 176 182 177 dev->in_ep = in_ep; 183 178
+15 -33
drivers/usb/misc/iowarrior.c
··· 54 54 MODULE_DESCRIPTION(DRIVER_DESC); 55 55 MODULE_LICENSE("GPL"); 56 56 57 - /* Module parameters */ 58 - static DEFINE_MUTEX(iowarrior_mutex); 59 - 60 57 static struct usb_driver iowarrior_driver; 61 - static DEFINE_MUTEX(iowarrior_open_disc_lock); 62 58 63 59 /*--------------*/ 64 60 /* data */ ··· 83 87 char chip_serial[9]; /* the serial number string of the chip connected */ 84 88 int report_size; /* number of bytes in a report */ 85 89 u16 product_id; 90 + struct usb_anchor submitted; 86 91 }; 87 92 88 93 /*--------------*/ ··· 240 243 kfree(dev->int_in_buffer); 241 244 usb_free_urb(dev->int_in_urb); 242 245 kfree(dev->read_queue); 246 + usb_put_intf(dev->interface); 243 247 kfree(dev); 244 248 } 245 249 ··· 422 424 retval = -EFAULT; 423 425 goto error; 424 426 } 427 + usb_anchor_urb(int_out_urb, &dev->submitted); 425 428 retval = usb_submit_urb(int_out_urb, GFP_KERNEL); 426 429 if (retval) { 427 430 dev_dbg(&dev->interface->dev, 428 431 "submit error %d for urb nr.%d\n", 429 432 retval, atomic_read(&dev->write_busy)); 433 + usb_unanchor_urb(int_out_urb); 430 434 goto error; 431 435 } 432 436 /* submit was ok */ ··· 477 477 if (!buffer) 478 478 return -ENOMEM; 479 479 480 - /* lock this object */ 481 - mutex_lock(&iowarrior_mutex); 482 480 mutex_lock(&dev->mutex); 483 481 484 482 /* verify that the device wasn't unplugged */ ··· 569 571 error_out: 570 572 /* unlock the device */ 571 573 mutex_unlock(&dev->mutex); 572 - mutex_unlock(&iowarrior_mutex); 573 574 kfree(buffer); 574 575 return retval; 575 576 } ··· 583 586 int subminor; 584 587 int retval = 0; 585 588 586 - mutex_lock(&iowarrior_mutex); 587 589 subminor = iminor(inode); 588 590 589 591 interface = usb_find_interface(&iowarrior_driver, subminor); 590 592 if (!interface) { 591 - mutex_unlock(&iowarrior_mutex); 592 - printk(KERN_ERR "%s - error, can't find device for minor %d\n", 593 + pr_err("%s - error, can't find device for minor %d\n", 593 594 __func__, subminor); 594 595 return -ENODEV; 595 596 } 596 597 597 - mutex_lock(&iowarrior_open_disc_lock); 598 598 dev = usb_get_intfdata(interface); 599 - if (!dev) { 600 - mutex_unlock(&iowarrior_open_disc_lock); 601 - mutex_unlock(&iowarrior_mutex); 599 + if (!dev) 602 600 return -ENODEV; 603 - } 604 601 605 602 mutex_lock(&dev->mutex); 606 - mutex_unlock(&iowarrior_open_disc_lock); 607 603 608 604 /* Only one process can open each device, no sharing. */ 609 605 if (dev->opened) { ··· 618 628 619 629 out: 620 630 mutex_unlock(&dev->mutex); 621 - mutex_unlock(&iowarrior_mutex); 622 631 return retval; 623 632 } 624 633 ··· 753 764 init_waitqueue_head(&dev->write_wait); 754 765 755 766 dev->udev = udev; 756 - dev->interface = interface; 767 + dev->interface = usb_get_intf(interface); 757 768 758 769 iface_desc = interface->cur_altsetting; 759 770 dev->product_id = le16_to_cpu(udev->descriptor.idProduct); 771 + 772 + init_usb_anchor(&dev->submitted); 760 773 761 774 res = usb_find_last_int_in_endpoint(iface_desc, &dev->int_in_endpoint); 762 775 if (res) { ··· 827 836 if (retval) { 828 837 /* something prevented us from registering this driver */ 829 838 dev_err(&interface->dev, "Not able to get a minor for this device.\n"); 830 - usb_set_intfdata(interface, NULL); 831 839 goto error; 832 840 } 833 841 ··· 850 860 */ 851 861 static void iowarrior_disconnect(struct usb_interface *interface) 852 862 { 853 - struct iowarrior *dev; 854 - int minor; 855 - 856 - dev = usb_get_intfdata(interface); 857 - mutex_lock(&iowarrior_open_disc_lock); 858 - usb_set_intfdata(interface, NULL); 859 - /* prevent device read, write and ioctl */ 860 - dev->present = 0; 861 - 862 - minor = dev->minor; 863 - mutex_unlock(&iowarrior_open_disc_lock); 864 - /* give back our minor - this will call close() locks need to be dropped at this point*/ 863 + struct iowarrior *dev = usb_get_intfdata(interface); 864 + int minor = dev->minor; 865 865 866 866 usb_deregister_dev(interface, &iowarrior_class); 867 867 868 868 mutex_lock(&dev->mutex); 869 869 870 870 /* prevent device read, write and ioctl */ 871 - 872 - mutex_unlock(&dev->mutex); 871 + dev->present = 0; 873 872 874 873 if (dev->opened) { 875 874 /* There is a process that holds a filedescriptor to the device , ··· 866 887 Deleting the device is postponed until close() was called. 867 888 */ 868 889 usb_kill_urb(dev->int_in_urb); 890 + usb_kill_anchored_urbs(&dev->submitted); 869 891 wake_up_interruptible(&dev->read_wait); 870 892 wake_up_interruptible(&dev->write_wait); 893 + mutex_unlock(&dev->mutex); 871 894 } else { 872 895 /* no process is using the device, cleanup now */ 896 + mutex_unlock(&dev->mutex); 873 897 iowarrior_delete(dev); 874 898 } 875 899
+12 -12
drivers/usb/misc/ldusb.c
··· 153 153 struct ld_usb { 154 154 struct mutex mutex; /* locks this structure */ 155 155 struct usb_interface *intf; /* save off the usb interface pointer */ 156 + unsigned long disconnected:1; 156 157 157 158 int open_count; /* number of times this port has been opened */ 158 159 ··· 193 192 /* shutdown transfer */ 194 193 if (dev->interrupt_in_running) { 195 194 dev->interrupt_in_running = 0; 196 - if (dev->intf) 197 - usb_kill_urb(dev->interrupt_in_urb); 195 + usb_kill_urb(dev->interrupt_in_urb); 198 196 } 199 197 if (dev->interrupt_out_busy) 200 - if (dev->intf) 201 - usb_kill_urb(dev->interrupt_out_urb); 198 + usb_kill_urb(dev->interrupt_out_urb); 202 199 } 203 200 204 201 /** ··· 204 205 */ 205 206 static void ld_usb_delete(struct ld_usb *dev) 206 207 { 207 - ld_usb_abort_transfers(dev); 208 - 209 208 /* free data structures */ 210 209 usb_free_urb(dev->interrupt_in_urb); 211 210 usb_free_urb(dev->interrupt_out_urb); ··· 260 263 261 264 resubmit: 262 265 /* resubmit if we're still running */ 263 - if (dev->interrupt_in_running && !dev->buffer_overflow && dev->intf) { 266 + if (dev->interrupt_in_running && !dev->buffer_overflow) { 264 267 retval = usb_submit_urb(dev->interrupt_in_urb, GFP_ATOMIC); 265 268 if (retval) { 266 269 dev_err(&dev->intf->dev, ··· 389 392 retval = -ENODEV; 390 393 goto unlock_exit; 391 394 } 392 - if (dev->intf == NULL) { 395 + if (dev->disconnected) { 393 396 /* the device was unplugged before the file was released */ 394 397 mutex_unlock(&dev->mutex); 395 398 /* unlock here as ld_usb_delete frees dev */ ··· 420 423 421 424 dev = file->private_data; 422 425 423 - if (!dev->intf) 426 + if (dev->disconnected) 424 427 return EPOLLERR | EPOLLHUP; 425 428 426 429 poll_wait(file, &dev->read_wait, wait); ··· 459 462 } 460 463 461 464 /* verify that the device wasn't unplugged */ 462 - if (dev->intf == NULL) { 465 + if (dev->disconnected) { 463 466 retval = -ENODEV; 464 467 printk(KERN_ERR "ldusb: No device or device unplugged %d\n", retval); 465 468 goto unlock_exit; ··· 539 542 } 540 543 541 544 /* verify that the device wasn't unplugged */ 542 - if (dev->intf == NULL) { 545 + if (dev->disconnected) { 543 546 retval = -ENODEV; 544 547 printk(KERN_ERR "ldusb: No device or device unplugged %d\n", retval); 545 548 goto unlock_exit; ··· 761 764 /* give back our minor */ 762 765 usb_deregister_dev(intf, &ld_usb_class); 763 766 767 + usb_poison_urb(dev->interrupt_in_urb); 768 + usb_poison_urb(dev->interrupt_out_urb); 769 + 764 770 mutex_lock(&dev->mutex); 765 771 766 772 /* if the device is not opened, then we clean up right now */ ··· 771 771 mutex_unlock(&dev->mutex); 772 772 ld_usb_delete(dev); 773 773 } else { 774 - dev->intf = NULL; 774 + dev->disconnected = 1; 775 775 /* wake up pollers */ 776 776 wake_up_interruptible_all(&dev->read_wait); 777 777 wake_up_interruptible_all(&dev->write_wait);
+25 -33
drivers/usb/misc/legousbtower.c
··· 179 179 }; 180 180 181 181 MODULE_DEVICE_TABLE (usb, tower_table); 182 - static DEFINE_MUTEX(open_disc_mutex); 183 182 184 183 #define LEGO_USB_TOWER_MINOR_BASE 160 185 184 ··· 190 191 unsigned char minor; /* the starting minor number for this device */ 191 192 192 193 int open_count; /* number of times this port has been opened */ 194 + unsigned long disconnected:1; 193 195 194 196 char* read_buffer; 195 197 size_t read_buffer_length; /* this much came in */ ··· 290 290 */ 291 291 static inline void tower_delete (struct lego_usb_tower *dev) 292 292 { 293 - tower_abort_transfers (dev); 294 - 295 293 /* free data structures */ 296 294 usb_free_urb(dev->interrupt_in_urb); 297 295 usb_free_urb(dev->interrupt_out_urb); 298 296 kfree (dev->read_buffer); 299 297 kfree (dev->interrupt_in_buffer); 300 298 kfree (dev->interrupt_out_buffer); 299 + usb_put_dev(dev->udev); 301 300 kfree (dev); 302 301 } 303 302 ··· 331 332 goto exit; 332 333 } 333 334 334 - mutex_lock(&open_disc_mutex); 335 335 dev = usb_get_intfdata(interface); 336 - 337 336 if (!dev) { 338 - mutex_unlock(&open_disc_mutex); 339 337 retval = -ENODEV; 340 338 goto exit; 341 339 } 342 340 343 341 /* lock this device */ 344 342 if (mutex_lock_interruptible(&dev->lock)) { 345 - mutex_unlock(&open_disc_mutex); 346 343 retval = -ERESTARTSYS; 347 344 goto exit; 348 345 } ··· 346 351 347 352 /* allow opening only once */ 348 353 if (dev->open_count) { 349 - mutex_unlock(&open_disc_mutex); 350 354 retval = -EBUSY; 351 355 goto unlock_exit; 352 356 } 353 - dev->open_count = 1; 354 - mutex_unlock(&open_disc_mutex); 355 357 356 358 /* reset the tower */ 357 359 result = usb_control_msg (dev->udev, ··· 388 396 dev_err(&dev->udev->dev, 389 397 "Couldn't submit interrupt_in_urb %d\n", retval); 390 398 dev->interrupt_in_running = 0; 391 - dev->open_count = 0; 392 399 goto unlock_exit; 393 400 } 394 401 395 402 /* save device in the file's private structure */ 396 403 file->private_data = dev; 404 + 405 + dev->open_count = 1; 397 406 398 407 unlock_exit: 399 408 mutex_unlock(&dev->lock); ··· 416 423 417 424 if (dev == NULL) { 418 425 retval = -ENODEV; 419 - goto exit_nolock; 426 + goto exit; 420 427 } 421 428 422 - mutex_lock(&open_disc_mutex); 423 429 if (mutex_lock_interruptible(&dev->lock)) { 424 430 retval = -ERESTARTSYS; 425 431 goto exit; ··· 430 438 retval = -ENODEV; 431 439 goto unlock_exit; 432 440 } 433 - if (dev->udev == NULL) { 441 + 442 + if (dev->disconnected) { 434 443 /* the device was unplugged before the file was released */ 435 444 436 445 /* unlock here as tower_delete frees dev */ ··· 449 456 450 457 unlock_exit: 451 458 mutex_unlock(&dev->lock); 452 - 453 459 exit: 454 - mutex_unlock(&open_disc_mutex); 455 - exit_nolock: 456 460 return retval; 457 461 } 458 462 ··· 467 477 if (dev->interrupt_in_running) { 468 478 dev->interrupt_in_running = 0; 469 479 mb(); 470 - if (dev->udev) 471 - usb_kill_urb (dev->interrupt_in_urb); 480 + usb_kill_urb(dev->interrupt_in_urb); 472 481 } 473 - if (dev->interrupt_out_busy && dev->udev) 482 + if (dev->interrupt_out_busy) 474 483 usb_kill_urb(dev->interrupt_out_urb); 475 484 } 476 485 ··· 505 516 506 517 dev = file->private_data; 507 518 508 - if (!dev->udev) 519 + if (dev->disconnected) 509 520 return EPOLLERR | EPOLLHUP; 510 521 511 522 poll_wait(file, &dev->read_wait, wait); ··· 552 563 } 553 564 554 565 /* verify that the device wasn't unplugged */ 555 - if (dev->udev == NULL) { 566 + if (dev->disconnected) { 556 567 retval = -ENODEV; 557 568 pr_err("No device or device unplugged %d\n", retval); 558 569 goto unlock_exit; ··· 638 649 } 639 650 640 651 /* verify that the device wasn't unplugged */ 641 - if (dev->udev == NULL) { 652 + if (dev->disconnected) { 642 653 retval = -ENODEV; 643 654 pr_err("No device or device unplugged %d\n", retval); 644 655 goto unlock_exit; ··· 748 759 749 760 resubmit: 750 761 /* resubmit if we're still running */ 751 - if (dev->interrupt_in_running && dev->udev) { 762 + if (dev->interrupt_in_running) { 752 763 retval = usb_submit_urb (dev->interrupt_in_urb, GFP_ATOMIC); 753 764 if (retval) 754 765 dev_err(&dev->udev->dev, ··· 811 822 812 823 mutex_init(&dev->lock); 813 824 814 - dev->udev = udev; 825 + dev->udev = usb_get_dev(udev); 815 826 dev->open_count = 0; 827 + dev->disconnected = 0; 816 828 817 829 dev->read_buffer = NULL; 818 830 dev->read_buffer_length = 0; ··· 881 891 get_version_reply, 882 892 sizeof(*get_version_reply), 883 893 1000); 884 - if (result < 0) { 885 - dev_err(idev, "LEGO USB Tower get version control request failed\n"); 894 + if (result < sizeof(*get_version_reply)) { 895 + if (result >= 0) 896 + result = -EIO; 897 + dev_err(idev, "get version request failed: %d\n", result); 886 898 retval = result; 887 899 goto error; 888 900 } ··· 902 910 if (retval) { 903 911 /* something prevented us from registering this driver */ 904 912 dev_err(idev, "Not able to get a minor for this device.\n"); 905 - usb_set_intfdata (interface, NULL); 906 913 goto error; 907 914 } 908 915 dev->minor = interface->minor; ··· 933 942 int minor; 934 943 935 944 dev = usb_get_intfdata (interface); 936 - mutex_lock(&open_disc_mutex); 937 - usb_set_intfdata (interface, NULL); 938 945 939 946 minor = dev->minor; 940 947 941 - /* give back our minor */ 948 + /* give back our minor and prevent further open() */ 942 949 usb_deregister_dev (interface, &tower_class); 943 950 951 + /* stop I/O */ 952 + usb_poison_urb(dev->interrupt_in_urb); 953 + usb_poison_urb(dev->interrupt_out_urb); 954 + 944 955 mutex_lock(&dev->lock); 945 - mutex_unlock(&open_disc_mutex); 946 956 947 957 /* if the device is not opened, then we clean up right now */ 948 958 if (!dev->open_count) { 949 959 mutex_unlock(&dev->lock); 950 960 tower_delete (dev); 951 961 } else { 952 - dev->udev = NULL; 962 + dev->disconnected = 1; 953 963 /* wake up pollers */ 954 964 wake_up_interruptible_all(&dev->read_wait); 955 965 wake_up_interruptible_all(&dev->write_wait);
-554
drivers/usb/misc/rio500.c
··· 1 - // SPDX-License-Identifier: GPL-2.0+ 2 - /* -*- linux-c -*- */ 3 - 4 - /* 5 - * Driver for USB Rio 500 6 - * 7 - * Cesar Miquel (miquel@df.uba.ar) 8 - * 9 - * based on hp_scanner.c by David E. Nelson (dnelson@jump.net) 10 - * 11 - * Based upon mouse.c (Brad Keryan) and printer.c (Michael Gee). 12 - * 13 - * Changelog: 14 - * 30/05/2003 replaced lock/unlock kernel with up/down 15 - * Daniele Bellucci bellucda@tiscali.it 16 - * */ 17 - 18 - #include <linux/module.h> 19 - #include <linux/kernel.h> 20 - #include <linux/signal.h> 21 - #include <linux/sched/signal.h> 22 - #include <linux/mutex.h> 23 - #include <linux/errno.h> 24 - #include <linux/random.h> 25 - #include <linux/poll.h> 26 - #include <linux/slab.h> 27 - #include <linux/spinlock.h> 28 - #include <linux/usb.h> 29 - #include <linux/wait.h> 30 - 31 - #include "rio500_usb.h" 32 - 33 - #define DRIVER_AUTHOR "Cesar Miquel <miquel@df.uba.ar>" 34 - #define DRIVER_DESC "USB Rio 500 driver" 35 - 36 - #define RIO_MINOR 64 37 - 38 - /* stall/wait timeout for rio */ 39 - #define NAK_TIMEOUT (HZ) 40 - 41 - #define IBUF_SIZE 0x1000 42 - 43 - /* Size of the rio buffer */ 44 - #define OBUF_SIZE 0x10000 45 - 46 - struct rio_usb_data { 47 - struct usb_device *rio_dev; /* init: probe_rio */ 48 - unsigned int ifnum; /* Interface number of the USB device */ 49 - int isopen; /* nz if open */ 50 - int present; /* Device is present on the bus */ 51 - char *obuf, *ibuf; /* transfer buffers */ 52 - char bulk_in_ep, bulk_out_ep; /* Endpoint assignments */ 53 - wait_queue_head_t wait_q; /* for timeouts */ 54 - }; 55 - 56 - static DEFINE_MUTEX(rio500_mutex); 57 - static struct rio_usb_data rio_instance; 58 - 59 - static int open_rio(struct inode *inode, struct file *file) 60 - { 61 - struct rio_usb_data *rio = &rio_instance; 62 - 63 - /* against disconnect() */ 64 - mutex_lock(&rio500_mutex); 65 - 66 - if (rio->isopen || !rio->present) { 67 - mutex_unlock(&rio500_mutex); 68 - return -EBUSY; 69 - } 70 - rio->isopen = 1; 71 - 72 - init_waitqueue_head(&rio->wait_q); 73 - 74 - 75 - dev_info(&rio->rio_dev->dev, "Rio opened.\n"); 76 - mutex_unlock(&rio500_mutex); 77 - 78 - return 0; 79 - } 80 - 81 - static int close_rio(struct inode *inode, struct file *file) 82 - { 83 - struct rio_usb_data *rio = &rio_instance; 84 - 85 - /* against disconnect() */ 86 - mutex_lock(&rio500_mutex); 87 - 88 - rio->isopen = 0; 89 - if (!rio->present) { 90 - /* cleanup has been delayed */ 91 - kfree(rio->ibuf); 92 - kfree(rio->obuf); 93 - rio->ibuf = NULL; 94 - rio->obuf = NULL; 95 - } else { 96 - dev_info(&rio->rio_dev->dev, "Rio closed.\n"); 97 - } 98 - mutex_unlock(&rio500_mutex); 99 - return 0; 100 - } 101 - 102 - static long ioctl_rio(struct file *file, unsigned int cmd, unsigned long arg) 103 - { 104 - struct RioCommand rio_cmd; 105 - struct rio_usb_data *rio = &rio_instance; 106 - void __user *data; 107 - unsigned char *buffer; 108 - int result, requesttype; 109 - int retries; 110 - int retval=0; 111 - 112 - mutex_lock(&rio500_mutex); 113 - /* Sanity check to make sure rio is connected, powered, etc */ 114 - if (rio->present == 0 || rio->rio_dev == NULL) { 115 - retval = -ENODEV; 116 - goto err_out; 117 - } 118 - 119 - switch (cmd) { 120 - case RIO_RECV_COMMAND: 121 - data = (void __user *) arg; 122 - if (data == NULL) 123 - break; 124 - if (copy_from_user(&rio_cmd, data, sizeof(struct RioCommand))) { 125 - retval = -EFAULT; 126 - goto err_out; 127 - } 128 - if (rio_cmd.length < 0 || rio_cmd.length > PAGE_SIZE) { 129 - retval = -EINVAL; 130 - goto err_out; 131 - } 132 - buffer = (unsigned char *) __get_free_page(GFP_KERNEL); 133 - if (buffer == NULL) { 134 - retval = -ENOMEM; 135 - goto err_out; 136 - } 137 - if (copy_from_user(buffer, rio_cmd.buffer, rio_cmd.length)) { 138 - retval = -EFAULT; 139 - free_page((unsigned long) buffer); 140 - goto err_out; 141 - } 142 - 143 - requesttype = rio_cmd.requesttype | USB_DIR_IN | 144 - USB_TYPE_VENDOR | USB_RECIP_DEVICE; 145 - dev_dbg(&rio->rio_dev->dev, 146 - "sending command:reqtype=%0x req=%0x value=%0x index=%0x len=%0x\n", 147 - requesttype, rio_cmd.request, rio_cmd.value, 148 - rio_cmd.index, rio_cmd.length); 149 - /* Send rio control message */ 150 - retries = 3; 151 - while (retries) { 152 - result = usb_control_msg(rio->rio_dev, 153 - usb_rcvctrlpipe(rio-> rio_dev, 0), 154 - rio_cmd.request, 155 - requesttype, 156 - rio_cmd.value, 157 - rio_cmd.index, buffer, 158 - rio_cmd.length, 159 - jiffies_to_msecs(rio_cmd.timeout)); 160 - if (result == -ETIMEDOUT) 161 - retries--; 162 - else if (result < 0) { 163 - dev_err(&rio->rio_dev->dev, 164 - "Error executing ioctrl. code = %d\n", 165 - result); 166 - retries = 0; 167 - } else { 168 - dev_dbg(&rio->rio_dev->dev, 169 - "Executed ioctl. Result = %d (data=%02x)\n", 170 - result, buffer[0]); 171 - if (copy_to_user(rio_cmd.buffer, buffer, 172 - rio_cmd.length)) { 173 - free_page((unsigned long) buffer); 174 - retval = -EFAULT; 175 - goto err_out; 176 - } 177 - retries = 0; 178 - } 179 - 180 - /* rio_cmd.buffer contains a raw stream of single byte 181 - data which has been returned from rio. Data is 182 - interpreted at application level. For data that 183 - will be cast to data types longer than 1 byte, data 184 - will be little_endian and will potentially need to 185 - be swapped at the app level */ 186 - 187 - } 188 - free_page((unsigned long) buffer); 189 - break; 190 - 191 - case RIO_SEND_COMMAND: 192 - data = (void __user *) arg; 193 - if (data == NULL) 194 - break; 195 - if (copy_from_user(&rio_cmd, data, sizeof(struct RioCommand))) { 196 - retval = -EFAULT; 197 - goto err_out; 198 - } 199 - if (rio_cmd.length < 0 || rio_cmd.length > PAGE_SIZE) { 200 - retval = -EINVAL; 201 - goto err_out; 202 - } 203 - buffer = (unsigned char *) __get_free_page(GFP_KERNEL); 204 - if (buffer == NULL) { 205 - retval = -ENOMEM; 206 - goto err_out; 207 - } 208 - if (copy_from_user(buffer, rio_cmd.buffer, rio_cmd.length)) { 209 - free_page((unsigned long)buffer); 210 - retval = -EFAULT; 211 - goto err_out; 212 - } 213 - 214 - requesttype = rio_cmd.requesttype | USB_DIR_OUT | 215 - USB_TYPE_VENDOR | USB_RECIP_DEVICE; 216 - dev_dbg(&rio->rio_dev->dev, 217 - "sending command: reqtype=%0x req=%0x value=%0x index=%0x len=%0x\n", 218 - requesttype, rio_cmd.request, rio_cmd.value, 219 - rio_cmd.index, rio_cmd.length); 220 - /* Send rio control message */ 221 - retries = 3; 222 - while (retries) { 223 - result = usb_control_msg(rio->rio_dev, 224 - usb_sndctrlpipe(rio-> rio_dev, 0), 225 - rio_cmd.request, 226 - requesttype, 227 - rio_cmd.value, 228 - rio_cmd.index, buffer, 229 - rio_cmd.length, 230 - jiffies_to_msecs(rio_cmd.timeout)); 231 - if (result == -ETIMEDOUT) 232 - retries--; 233 - else if (result < 0) { 234 - dev_err(&rio->rio_dev->dev, 235 - "Error executing ioctrl. code = %d\n", 236 - result); 237 - retries = 0; 238 - } else { 239 - dev_dbg(&rio->rio_dev->dev, 240 - "Executed ioctl. Result = %d\n", result); 241 - retries = 0; 242 - 243 - } 244 - 245 - } 246 - free_page((unsigned long) buffer); 247 - break; 248 - 249 - default: 250 - retval = -ENOTTY; 251 - break; 252 - } 253 - 254 - 255 - err_out: 256 - mutex_unlock(&rio500_mutex); 257 - return retval; 258 - } 259 - 260 - static ssize_t 261 - write_rio(struct file *file, const char __user *buffer, 262 - size_t count, loff_t * ppos) 263 - { 264 - DEFINE_WAIT(wait); 265 - struct rio_usb_data *rio = &rio_instance; 266 - 267 - unsigned long copy_size; 268 - unsigned long bytes_written = 0; 269 - unsigned int partial; 270 - 271 - int result = 0; 272 - int maxretry; 273 - int errn = 0; 274 - int intr; 275 - 276 - intr = mutex_lock_interruptible(&rio500_mutex); 277 - if (intr) 278 - return -EINTR; 279 - /* Sanity check to make sure rio is connected, powered, etc */ 280 - if (rio->present == 0 || rio->rio_dev == NULL) { 281 - mutex_unlock(&rio500_mutex); 282 - return -ENODEV; 283 - } 284 - 285 - 286 - 287 - do { 288 - unsigned long thistime; 289 - char *obuf = rio->obuf; 290 - 291 - thistime = copy_size = 292 - (count >= OBUF_SIZE) ? OBUF_SIZE : count; 293 - if (copy_from_user(rio->obuf, buffer, copy_size)) { 294 - errn = -EFAULT; 295 - goto error; 296 - } 297 - maxretry = 5; 298 - while (thistime) { 299 - if (!rio->rio_dev) { 300 - errn = -ENODEV; 301 - goto error; 302 - } 303 - if (signal_pending(current)) { 304 - mutex_unlock(&rio500_mutex); 305 - return bytes_written ? bytes_written : -EINTR; 306 - } 307 - 308 - result = usb_bulk_msg(rio->rio_dev, 309 - usb_sndbulkpipe(rio->rio_dev, 2), 310 - obuf, thistime, &partial, 5000); 311 - 312 - dev_dbg(&rio->rio_dev->dev, 313 - "write stats: result:%d thistime:%lu partial:%u\n", 314 - result, thistime, partial); 315 - 316 - if (result == -ETIMEDOUT) { /* NAK - so hold for a while */ 317 - if (!maxretry--) { 318 - errn = -ETIME; 319 - goto error; 320 - } 321 - prepare_to_wait(&rio->wait_q, &wait, TASK_INTERRUPTIBLE); 322 - schedule_timeout(NAK_TIMEOUT); 323 - finish_wait(&rio->wait_q, &wait); 324 - continue; 325 - } else if (!result && partial) { 326 - obuf += partial; 327 - thistime -= partial; 328 - } else 329 - break; 330 - } 331 - if (result) { 332 - dev_err(&rio->rio_dev->dev, "Write Whoops - %x\n", 333 - result); 334 - errn = -EIO; 335 - goto error; 336 - } 337 - bytes_written += copy_size; 338 - count -= copy_size; 339 - buffer += copy_size; 340 - } while (count > 0); 341 - 342 - mutex_unlock(&rio500_mutex); 343 - 344 - return bytes_written ? bytes_written : -EIO; 345 - 346 - error: 347 - mutex_unlock(&rio500_mutex); 348 - return errn; 349 - } 350 - 351 - static ssize_t 352 - read_rio(struct file *file, char __user *buffer, size_t count, loff_t * ppos) 353 - { 354 - DEFINE_WAIT(wait); 355 - struct rio_usb_data *rio = &rio_instance; 356 - ssize_t read_count; 357 - unsigned int partial; 358 - int this_read; 359 - int result; 360 - int maxretry = 10; 361 - char *ibuf; 362 - int intr; 363 - 364 - intr = mutex_lock_interruptible(&rio500_mutex); 365 - if (intr) 366 - return -EINTR; 367 - /* Sanity check to make sure rio is connected, powered, etc */ 368 - if (rio->present == 0 || rio->rio_dev == NULL) { 369 - mutex_unlock(&rio500_mutex); 370 - return -ENODEV; 371 - } 372 - 373 - ibuf = rio->ibuf; 374 - 375 - read_count = 0; 376 - 377 - 378 - while (count > 0) { 379 - if (signal_pending(current)) { 380 - mutex_unlock(&rio500_mutex); 381 - return read_count ? read_count : -EINTR; 382 - } 383 - if (!rio->rio_dev) { 384 - mutex_unlock(&rio500_mutex); 385 - return -ENODEV; 386 - } 387 - this_read = (count >= IBUF_SIZE) ? IBUF_SIZE : count; 388 - 389 - result = usb_bulk_msg(rio->rio_dev, 390 - usb_rcvbulkpipe(rio->rio_dev, 1), 391 - ibuf, this_read, &partial, 392 - 8000); 393 - 394 - dev_dbg(&rio->rio_dev->dev, 395 - "read stats: result:%d this_read:%u partial:%u\n", 396 - result, this_read, partial); 397 - 398 - if (partial) { 399 - count = this_read = partial; 400 - } else if (result == -ETIMEDOUT || result == 15) { /* FIXME: 15 ??? */ 401 - if (!maxretry--) { 402 - mutex_unlock(&rio500_mutex); 403 - dev_err(&rio->rio_dev->dev, 404 - "read_rio: maxretry timeout\n"); 405 - return -ETIME; 406 - } 407 - prepare_to_wait(&rio->wait_q, &wait, TASK_INTERRUPTIBLE); 408 - schedule_timeout(NAK_TIMEOUT); 409 - finish_wait(&rio->wait_q, &wait); 410 - continue; 411 - } else if (result != -EREMOTEIO) { 412 - mutex_unlock(&rio500_mutex); 413 - dev_err(&rio->rio_dev->dev, 414 - "Read Whoops - result:%d partial:%u this_read:%u\n", 415 - result, partial, this_read); 416 - return -EIO; 417 - } else { 418 - mutex_unlock(&rio500_mutex); 419 - return (0); 420 - } 421 - 422 - if (this_read) { 423 - if (copy_to_user(buffer, ibuf, this_read)) { 424 - mutex_unlock(&rio500_mutex); 425 - return -EFAULT; 426 - } 427 - count -= this_read; 428 - read_count += this_read; 429 - buffer += this_read; 430 - } 431 - } 432 - mutex_unlock(&rio500_mutex); 433 - return read_count; 434 - } 435 - 436 - static const struct file_operations usb_rio_fops = { 437 - .owner = THIS_MODULE, 438 - .read = read_rio, 439 - .write = write_rio, 440 - .unlocked_ioctl = ioctl_rio, 441 - .open = open_rio, 442 - .release = close_rio, 443 - .llseek = noop_llseek, 444 - }; 445 - 446 - static struct usb_class_driver usb_rio_class = { 447 - .name = "rio500%d", 448 - .fops = &usb_rio_fops, 449 - .minor_base = RIO_MINOR, 450 - }; 451 - 452 - static int probe_rio(struct usb_interface *intf, 453 - const struct usb_device_id *id) 454 - { 455 - struct usb_device *dev = interface_to_usbdev(intf); 456 - struct rio_usb_data *rio = &rio_instance; 457 - int retval = -ENOMEM; 458 - char *ibuf, *obuf; 459 - 460 - if (rio->present) { 461 - dev_info(&intf->dev, "Second USB Rio at address %d refused\n", dev->devnum); 462 - return -EBUSY; 463 - } 464 - dev_info(&intf->dev, "USB Rio found at address %d\n", dev->devnum); 465 - 466 - obuf = kmalloc(OBUF_SIZE, GFP_KERNEL); 467 - if (!obuf) { 468 - dev_err(&dev->dev, 469 - "probe_rio: Not enough memory for the output buffer\n"); 470 - goto err_obuf; 471 - } 472 - dev_dbg(&intf->dev, "obuf address: %p\n", obuf); 473 - 474 - ibuf = kmalloc(IBUF_SIZE, GFP_KERNEL); 475 - if (!ibuf) { 476 - dev_err(&dev->dev, 477 - "probe_rio: Not enough memory for the input buffer\n"); 478 - goto err_ibuf; 479 - } 480 - dev_dbg(&intf->dev, "ibuf address: %p\n", ibuf); 481 - 482 - mutex_lock(&rio500_mutex); 483 - rio->rio_dev = dev; 484 - rio->ibuf = ibuf; 485 - rio->obuf = obuf; 486 - rio->present = 1; 487 - mutex_unlock(&rio500_mutex); 488 - 489 - retval = usb_register_dev(intf, &usb_rio_class); 490 - if (retval) { 491 - dev_err(&dev->dev, 492 - "Not able to get a minor for this device.\n"); 493 - goto err_register; 494 - } 495 - 496 - usb_set_intfdata(intf, rio); 497 - return retval; 498 - 499 - err_register: 500 - mutex_lock(&rio500_mutex); 501 - rio->present = 0; 502 - mutex_unlock(&rio500_mutex); 503 - err_ibuf: 504 - kfree(obuf); 505 - err_obuf: 506 - return retval; 507 - } 508 - 509 - static void disconnect_rio(struct usb_interface *intf) 510 - { 511 - struct rio_usb_data *rio = usb_get_intfdata (intf); 512 - 513 - usb_set_intfdata (intf, NULL); 514 - if (rio) { 515 - usb_deregister_dev(intf, &usb_rio_class); 516 - 517 - mutex_lock(&rio500_mutex); 518 - if (rio->isopen) { 519 - rio->isopen = 0; 520 - /* better let it finish - the release will do whats needed */ 521 - rio->rio_dev = NULL; 522 - mutex_unlock(&rio500_mutex); 523 - return; 524 - } 525 - kfree(rio->ibuf); 526 - kfree(rio->obuf); 527 - 528 - dev_info(&intf->dev, "USB Rio disconnected.\n"); 529 - 530 - rio->present = 0; 531 - mutex_unlock(&rio500_mutex); 532 - } 533 - } 534 - 535 - static const struct usb_device_id rio_table[] = { 536 - { USB_DEVICE(0x0841, 1) }, /* Rio 500 */ 537 - { } /* Terminating entry */ 538 - }; 539 - 540 - MODULE_DEVICE_TABLE (usb, rio_table); 541 - 542 - static struct usb_driver rio_driver = { 543 - .name = "rio500", 544 - .probe = probe_rio, 545 - .disconnect = disconnect_rio, 546 - .id_table = rio_table, 547 - }; 548 - 549 - module_usb_driver(rio_driver); 550 - 551 - MODULE_AUTHOR( DRIVER_AUTHOR ); 552 - MODULE_DESCRIPTION( DRIVER_DESC ); 553 - MODULE_LICENSE("GPL"); 554 -
-20
drivers/usb/misc/rio500_usb.h
··· 1 - // SPDX-License-Identifier: GPL-2.0+ 2 - /* ---------------------------------------------------------------------- 3 - Copyright (C) 2000 Cesar Miquel (miquel@df.uba.ar) 4 - ---------------------------------------------------------------------- */ 5 - 6 - #define RIO_SEND_COMMAND 0x1 7 - #define RIO_RECV_COMMAND 0x2 8 - 9 - #define RIO_DIR_OUT 0x0 10 - #define RIO_DIR_IN 0x1 11 - 12 - struct RioCommand { 13 - short length; 14 - int request; 15 - int requesttype; 16 - int value; 17 - int index; 18 - void __user *buffer; 19 - int timeout; 20 - };
+33 -27
drivers/usb/misc/usblcd.c
··· 18 18 #include <linux/slab.h> 19 19 #include <linux/errno.h> 20 20 #include <linux/mutex.h> 21 + #include <linux/rwsem.h> 21 22 #include <linux/uaccess.h> 22 23 #include <linux/usb.h> 23 24 ··· 30 29 #define IOCTL_GET_DRV_VERSION 2 31 30 32 31 33 - static DEFINE_MUTEX(lcd_mutex); 34 32 static const struct usb_device_id id_table[] = { 35 33 { .idVendor = 0x10D2, .match_flags = USB_DEVICE_ID_MATCH_VENDOR, }, 36 34 { }, 37 35 }; 38 36 MODULE_DEVICE_TABLE(usb, id_table); 39 - 40 - static DEFINE_MUTEX(open_disc_mutex); 41 - 42 37 43 38 struct usb_lcd { 44 39 struct usb_device *udev; /* init: probe_lcd */ ··· 54 57 using up all RAM */ 55 58 struct usb_anchor submitted; /* URBs to wait for 56 59 before suspend */ 60 + struct rw_semaphore io_rwsem; 61 + unsigned long disconnected:1; 57 62 }; 58 63 #define to_lcd_dev(d) container_of(d, struct usb_lcd, kref) 59 64 ··· 80 81 struct usb_interface *interface; 81 82 int subminor, r; 82 83 83 - mutex_lock(&lcd_mutex); 84 84 subminor = iminor(inode); 85 85 86 86 interface = usb_find_interface(&lcd_driver, subminor); 87 87 if (!interface) { 88 - mutex_unlock(&lcd_mutex); 89 - printk(KERN_ERR "USBLCD: %s - error, can't find device for minor %d\n", 88 + pr_err("USBLCD: %s - error, can't find device for minor %d\n", 90 89 __func__, subminor); 91 90 return -ENODEV; 92 91 } 93 92 94 - mutex_lock(&open_disc_mutex); 95 93 dev = usb_get_intfdata(interface); 96 - if (!dev) { 97 - mutex_unlock(&open_disc_mutex); 98 - mutex_unlock(&lcd_mutex); 99 - return -ENODEV; 100 - } 101 94 102 95 /* increment our usage count for the device */ 103 96 kref_get(&dev->kref); 104 - mutex_unlock(&open_disc_mutex); 105 97 106 98 /* grab a power reference */ 107 99 r = usb_autopm_get_interface(interface); 108 100 if (r < 0) { 109 101 kref_put(&dev->kref, lcd_delete); 110 - mutex_unlock(&lcd_mutex); 111 102 return r; 112 103 } 113 104 114 105 /* save our object in the file's private structure */ 115 106 file->private_data = dev; 116 - mutex_unlock(&lcd_mutex); 117 107 118 108 return 0; 119 109 } ··· 130 142 131 143 dev = file->private_data; 132 144 145 + down_read(&dev->io_rwsem); 146 + 147 + if (dev->disconnected) { 148 + retval = -ENODEV; 149 + goto out_up_io; 150 + } 151 + 133 152 /* do a blocking bulk read to get data from the device */ 134 153 retval = usb_bulk_msg(dev->udev, 135 154 usb_rcvbulkpipe(dev->udev, ··· 153 158 retval = bytes_read; 154 159 } 155 160 161 + out_up_io: 162 + up_read(&dev->io_rwsem); 163 + 156 164 return retval; 157 165 } 158 166 ··· 171 173 172 174 switch (cmd) { 173 175 case IOCTL_GET_HARD_VERSION: 174 - mutex_lock(&lcd_mutex); 175 176 bcdDevice = le16_to_cpu((dev->udev)->descriptor.bcdDevice); 176 177 sprintf(buf, "%1d%1d.%1d%1d", 177 178 (bcdDevice & 0xF000)>>12, 178 179 (bcdDevice & 0xF00)>>8, 179 180 (bcdDevice & 0xF0)>>4, 180 181 (bcdDevice & 0xF)); 181 - mutex_unlock(&lcd_mutex); 182 182 if (copy_to_user((void __user *)arg, buf, strlen(buf)) != 0) 183 183 return -EFAULT; 184 184 break; ··· 233 237 if (r < 0) 234 238 return -EINTR; 235 239 240 + down_read(&dev->io_rwsem); 241 + 242 + if (dev->disconnected) { 243 + retval = -ENODEV; 244 + goto err_up_io; 245 + } 246 + 236 247 /* create a urb, and a buffer for it, and copy the data to the urb */ 237 248 urb = usb_alloc_urb(0, GFP_KERNEL); 238 249 if (!urb) { 239 250 retval = -ENOMEM; 240 - goto err_no_buf; 251 + goto err_up_io; 241 252 } 242 253 243 254 buf = usb_alloc_coherent(dev->udev, count, GFP_KERNEL, ··· 281 278 the USB core will eventually free it entirely */ 282 279 usb_free_urb(urb); 283 280 281 + up_read(&dev->io_rwsem); 284 282 exit: 285 283 return count; 286 284 error_unanchor: ··· 289 285 error: 290 286 usb_free_coherent(dev->udev, count, buf, urb->transfer_dma); 291 287 usb_free_urb(urb); 292 - err_no_buf: 288 + err_up_io: 289 + up_read(&dev->io_rwsem); 293 290 up(&dev->limit_sem); 294 291 return retval; 295 292 } ··· 330 325 331 326 kref_init(&dev->kref); 332 327 sema_init(&dev->limit_sem, USB_LCD_CONCURRENT_WRITES); 328 + init_rwsem(&dev->io_rwsem); 333 329 init_usb_anchor(&dev->submitted); 334 330 335 331 dev->udev = usb_get_dev(interface_to_usbdev(interface)); ··· 371 365 /* something prevented us from registering this driver */ 372 366 dev_err(&interface->dev, 373 367 "Not able to get a minor for this device.\n"); 374 - usb_set_intfdata(interface, NULL); 375 368 goto error; 376 369 } 377 370 ··· 416 411 417 412 static void lcd_disconnect(struct usb_interface *interface) 418 413 { 419 - struct usb_lcd *dev; 414 + struct usb_lcd *dev = usb_get_intfdata(interface); 420 415 int minor = interface->minor; 421 - 422 - mutex_lock(&open_disc_mutex); 423 - dev = usb_get_intfdata(interface); 424 - usb_set_intfdata(interface, NULL); 425 - mutex_unlock(&open_disc_mutex); 426 416 427 417 /* give back our minor */ 428 418 usb_deregister_dev(interface, &lcd_class); 419 + 420 + down_write(&dev->io_rwsem); 421 + dev->disconnected = 1; 422 + up_write(&dev->io_rwsem); 423 + 424 + usb_kill_anchored_urbs(&dev->submitted); 429 425 430 426 /* decrement our usage count */ 431 427 kref_put(&dev->kref, lcd_delete);
+11 -7
drivers/usb/misc/yurex.c
··· 60 60 61 61 struct kref kref; 62 62 struct mutex io_mutex; 63 + unsigned long disconnected:1; 63 64 struct fasync_struct *async_queue; 64 65 wait_queue_head_t waitq; 65 66 ··· 108 107 dev->int_buffer, dev->urb->transfer_dma); 109 108 usb_free_urb(dev->urb); 110 109 } 110 + usb_put_intf(dev->interface); 111 111 usb_put_dev(dev->udev); 112 112 kfree(dev); 113 113 } ··· 134 132 switch (status) { 135 133 case 0: /*success*/ 136 134 break; 135 + /* The device is terminated or messed up, give up */ 137 136 case -EOVERFLOW: 138 137 dev_err(&dev->interface->dev, 139 138 "%s - overflow with length %d, actual length is %d\n", ··· 143 140 case -ENOENT: 144 141 case -ESHUTDOWN: 145 142 case -EILSEQ: 146 - /* The device is terminated, clean up */ 143 + case -EPROTO: 144 + case -ETIME: 147 145 return; 148 146 default: 149 147 dev_err(&dev->interface->dev, 150 148 "%s - unknown status received: %d\n", __func__, status); 151 - goto exit; 149 + return; 152 150 } 153 151 154 152 /* handle received message */ ··· 181 177 break; 182 178 } 183 179 184 - exit: 185 180 retval = usb_submit_urb(dev->urb, GFP_ATOMIC); 186 181 if (retval) { 187 182 dev_err(&dev->interface->dev, "%s - usb_submit_urb failed: %d\n", ··· 207 204 init_waitqueue_head(&dev->waitq); 208 205 209 206 dev->udev = usb_get_dev(interface_to_usbdev(interface)); 210 - dev->interface = interface; 207 + dev->interface = usb_get_intf(interface); 211 208 212 209 /* set up the endpoint information */ 213 210 iface_desc = interface->cur_altsetting; ··· 318 315 319 316 /* prevent more I/O from starting */ 320 317 usb_poison_urb(dev->urb); 318 + usb_poison_urb(dev->cntl_urb); 321 319 mutex_lock(&dev->io_mutex); 322 - dev->interface = NULL; 320 + dev->disconnected = 1; 323 321 mutex_unlock(&dev->io_mutex); 324 322 325 323 /* wakeup waiters */ ··· 408 404 dev = file->private_data; 409 405 410 406 mutex_lock(&dev->io_mutex); 411 - if (!dev->interface) { /* already disconnected */ 407 + if (dev->disconnected) { /* already disconnected */ 412 408 mutex_unlock(&dev->io_mutex); 413 409 return -ENODEV; 414 410 } ··· 443 439 goto error; 444 440 445 441 mutex_lock(&dev->io_mutex); 446 - if (!dev->interface) { /* already disconnected */ 442 + if (dev->disconnected) { /* already disconnected */ 447 443 mutex_unlock(&dev->io_mutex); 448 444 retval = -ENODEV; 449 445 goto error;
+1
drivers/usb/renesas_usbhs/common.h
··· 211 211 /* DCPCTR */ 212 212 #define BSTS (1 << 15) /* Buffer Status */ 213 213 #define SUREQ (1 << 14) /* Sending SETUP Token */ 214 + #define INBUFM (1 << 14) /* (PIPEnCTR) Transfer Buffer Monitor */ 214 215 #define CSSTS (1 << 12) /* CSSTS Status */ 215 216 #define ACLRM (1 << 9) /* Buffer Auto-Clear Mode */ 216 217 #define SQCLR (1 << 8) /* Toggle Bit Clear */
+1 -1
drivers/usb/renesas_usbhs/fifo.c
··· 89 89 list_del_init(&pkt->node); 90 90 } 91 91 92 - static struct usbhs_pkt *__usbhsf_pkt_get(struct usbhs_pipe *pipe) 92 + struct usbhs_pkt *__usbhsf_pkt_get(struct usbhs_pipe *pipe) 93 93 { 94 94 return list_first_entry_or_null(&pipe->list, struct usbhs_pkt, node); 95 95 }
+1
drivers/usb/renesas_usbhs/fifo.h
··· 97 97 void *buf, int len, int zero, int sequence); 98 98 struct usbhs_pkt *usbhs_pkt_pop(struct usbhs_pipe *pipe, struct usbhs_pkt *pkt); 99 99 void usbhs_pkt_start(struct usbhs_pipe *pipe); 100 + struct usbhs_pkt *__usbhsf_pkt_get(struct usbhs_pipe *pipe); 100 101 101 102 #endif /* RENESAS_USB_FIFO_H */
+15 -3
drivers/usb/renesas_usbhs/mod_gadget.c
··· 722 722 struct usbhs_priv *priv = usbhsg_gpriv_to_priv(gpriv); 723 723 struct device *dev = usbhsg_gpriv_to_dev(gpriv); 724 724 unsigned long flags; 725 - 726 - usbhsg_pipe_disable(uep); 725 + int ret = 0; 727 726 728 727 dev_dbg(dev, "set halt %d (pipe %d)\n", 729 728 halt, usbhs_pipe_number(pipe)); 730 729 731 730 /******************** spin lock ********************/ 732 731 usbhs_lock(priv, flags); 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 + } 733 744 734 745 if (halt) 735 746 usbhs_pipe_stall(pipe); ··· 752 741 else 753 742 usbhsg_status_clr(gpriv, USBHSG_STATUS_WEDGE); 754 743 744 + out: 755 745 usbhs_unlock(priv, flags); 756 746 /******************** spin unlock ******************/ 757 747 758 - return 0; 748 + return ret; 759 749 } 760 750 761 751 static int usbhsg_ep_set_halt(struct usb_ep *ep, int value)
+15
drivers/usb/renesas_usbhs/pipe.c
··· 277 277 return -EBUSY; 278 278 } 279 279 280 + bool usbhs_pipe_contains_transmittable_data(struct usbhs_pipe *pipe) 281 + { 282 + u16 val; 283 + 284 + /* Do not support for DCP pipe */ 285 + if (usbhs_pipe_is_dcp(pipe)) 286 + return false; 287 + 288 + val = usbhsp_pipectrl_get(pipe); 289 + if (val & INBUFM) 290 + return true; 291 + 292 + return false; 293 + } 294 + 280 295 /* 281 296 * PID ctrl 282 297 */
+1
drivers/usb/renesas_usbhs/pipe.h
··· 83 83 void usbhs_pipe_clear_without_sequence(struct usbhs_pipe *pipe, 84 84 int needs_bfre, int bfre_enable); 85 85 int usbhs_pipe_is_accessible(struct usbhs_pipe *pipe); 86 + bool usbhs_pipe_contains_transmittable_data(struct usbhs_pipe *pipe); 86 87 void usbhs_pipe_enable(struct usbhs_pipe *pipe); 87 88 void usbhs_pipe_disable(struct usbhs_pipe *pipe); 88 89 void usbhs_pipe_stall(struct usbhs_pipe *pipe);
+3
drivers/usb/serial/ftdi_sio.c
··· 1030 1030 /* EZPrototypes devices */ 1031 1031 { USB_DEVICE(EZPROTOTYPES_VID, HJELMSLUND_USB485_ISO_PID) }, 1032 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 1036 { } /* Terminating entry */ 1034 1037 }; 1035 1038
+9
drivers/usb/serial/ftdi_sio_ids.h
··· 39 39 40 40 #define FTDI_LUMEL_PD12_PID 0x6002 41 41 42 + /* Sienna Serial Interface by Secyourit GmbH */ 43 + #define FTDI_SIENNA_PID 0x8348 44 + 42 45 /* Cyber Cortex AV by Fabulous Silicon (http://fabuloussilicon.com) */ 43 46 #define CYBER_CORTEX_AV_PID 0x8698 44 47 ··· 690 687 #define BANDB_TTL5USB9M_PID 0xAC49 691 688 #define BANDB_TTL3USB9M_PID 0xAC50 692 689 #define BANDB_ZZ_PROG1_USB_PID 0xBA02 690 + 691 + /* 692 + * Echelon USB Serial Interface 693 + */ 694 + #define ECHELON_VID 0x0920 695 + #define ECHELON_U20_PID 0x7500 693 696 694 697 /* 695 698 * Intrepid Control Systems (http://www.intrepidcs.com/) ValueCAN and NeoVI
+2 -2
drivers/usb/serial/keyspan.c
··· 1741 1741 1742 1742 ep_desc = find_ep(serial, endpoint); 1743 1743 if (!ep_desc) { 1744 - /* leak the urb, something's wrong and the callers don't care */ 1745 - return urb; 1744 + usb_free_urb(urb); 1745 + return NULL; 1746 1746 } 1747 1747 if (usb_endpoint_xfer_int(ep_desc)) { 1748 1748 ep_type_name = "INT";
+11
drivers/usb/serial/option.c
··· 419 419 #define CINTERION_PRODUCT_PH8_AUDIO 0x0083 420 420 #define CINTERION_PRODUCT_AHXX_2RMNET 0x0084 421 421 #define CINTERION_PRODUCT_AHXX_AUDIO 0x0085 422 + #define CINTERION_PRODUCT_CLS8 0x00b0 422 423 423 424 /* Olivetti products */ 424 425 #define OLIVETTI_VENDOR_ID 0x0b3c ··· 1155 1154 .driver_info = NCTRL(0) | RSVD(1) | RSVD(2) | RSVD(3) }, 1156 1155 { USB_DEVICE_INTERFACE_CLASS(TELIT_VENDOR_ID, TELIT_PRODUCT_LE922_USBCFG5, 0xff), 1157 1156 .driver_info = RSVD(0) | RSVD(1) | NCTRL(2) | RSVD(3) }, 1157 + { USB_DEVICE_INTERFACE_CLASS(TELIT_VENDOR_ID, 0x1050, 0xff), /* Telit FN980 (rmnet) */ 1158 + .driver_info = NCTRL(0) | RSVD(1) | RSVD(2) }, 1159 + { USB_DEVICE_INTERFACE_CLASS(TELIT_VENDOR_ID, 0x1051, 0xff), /* Telit FN980 (MBIM) */ 1160 + .driver_info = NCTRL(0) | RSVD(1) }, 1161 + { USB_DEVICE_INTERFACE_CLASS(TELIT_VENDOR_ID, 0x1052, 0xff), /* Telit FN980 (RNDIS) */ 1162 + .driver_info = NCTRL(2) | RSVD(3) }, 1163 + { USB_DEVICE_INTERFACE_CLASS(TELIT_VENDOR_ID, 0x1053, 0xff), /* Telit FN980 (ECM) */ 1164 + .driver_info = NCTRL(0) | RSVD(1) }, 1158 1165 { USB_DEVICE(TELIT_VENDOR_ID, TELIT_PRODUCT_ME910), 1159 1166 .driver_info = NCTRL(0) | RSVD(1) | RSVD(3) }, 1160 1167 { USB_DEVICE(TELIT_VENDOR_ID, TELIT_PRODUCT_ME910_DUAL_MODEM), ··· 1856 1847 .driver_info = RSVD(4) }, 1857 1848 { USB_DEVICE_INTERFACE_CLASS(CINTERION_VENDOR_ID, CINTERION_PRODUCT_AHXX_2RMNET, 0xff) }, 1858 1849 { USB_DEVICE_INTERFACE_CLASS(CINTERION_VENDOR_ID, CINTERION_PRODUCT_AHXX_AUDIO, 0xff) }, 1850 + { USB_DEVICE_INTERFACE_CLASS(CINTERION_VENDOR_ID, CINTERION_PRODUCT_CLS8, 0xff), 1851 + .driver_info = RSVD(0) | RSVD(4) }, 1859 1852 { USB_DEVICE(CINTERION_VENDOR_ID, CINTERION_PRODUCT_HC28_MDM) }, 1860 1853 { USB_DEVICE(CINTERION_VENDOR_ID, CINTERION_PRODUCT_HC28_MDMNET) }, 1861 1854 { USB_DEVICE(SIEMENS_VENDOR_ID, CINTERION_PRODUCT_HC25_MDM) },
+1 -4
drivers/usb/serial/usb-serial.c
··· 314 314 serial = port->serial; 315 315 owner = serial->type->driver.owner; 316 316 317 - mutex_lock(&serial->disc_mutex); 318 - if (!serial->disconnected) 319 - usb_autopm_put_interface(serial->interface); 320 - mutex_unlock(&serial->disc_mutex); 317 + usb_autopm_put_interface(serial->interface); 321 318 322 319 usb_serial_put(serial); 323 320 module_put(owner);
+8 -6
drivers/usb/typec/tcpm/tcpm.c
··· 4409 4409 /* USB data support is optional */ 4410 4410 ret = fwnode_property_read_string(fwnode, "data-role", &cap_str); 4411 4411 if (ret == 0) { 4412 - port->typec_caps.data = typec_find_port_data_role(cap_str); 4413 - if (port->typec_caps.data < 0) 4414 - return -EINVAL; 4412 + ret = typec_find_port_data_role(cap_str); 4413 + if (ret < 0) 4414 + return ret; 4415 + port->typec_caps.data = ret; 4415 4416 } 4416 4417 4417 4418 ret = fwnode_property_read_string(fwnode, "power-role", &cap_str); 4418 4419 if (ret < 0) 4419 4420 return ret; 4420 4421 4421 - port->typec_caps.type = typec_find_port_power_role(cap_str); 4422 - if (port->typec_caps.type < 0) 4423 - return -EINVAL; 4422 + ret = typec_find_port_power_role(cap_str); 4423 + if (ret < 0) 4424 + return ret; 4425 + port->typec_caps.type = ret; 4424 4426 port->port_type = port->typec_caps.type; 4425 4427 4426 4428 if (port->port_type == TYPEC_PORT_SNK)
+2
drivers/usb/typec/ucsi/displayport.c
··· 75 75 76 76 if (cur != 0xff) { 77 77 mutex_unlock(&dp->con->lock); 78 + if (dp->con->port_altmode[cur] == alt) 79 + return 0; 78 80 return -EBUSY; 79 81 } 80 82
+4 -38
drivers/usb/typec/ucsi/ucsi_ccg.c
··· 195 195 196 196 /* fw build with vendor information */ 197 197 u16 fw_build; 198 - bool run_isr; /* flag to call ISR routine during resume */ 199 198 struct work_struct pm_work; 200 199 }; 201 200 ··· 222 223 /* check any max_read_len limitation on i2c adapter */ 223 224 if (quirks && quirks->max_read_len) 224 225 max_read_len = quirks->max_read_len; 225 - 226 - if (uc->fw_build == CCG_FW_BUILD_NVIDIA && 227 - uc->fw_version <= CCG_OLD_FW_VERSION) { 228 - mutex_lock(&uc->lock); 229 - /* 230 - * Do not schedule pm_work to run ISR in 231 - * ucsi_ccg_runtime_resume() after pm_runtime_get_sync() 232 - * since we are already in ISR path. 233 - */ 234 - uc->run_isr = false; 235 - mutex_unlock(&uc->lock); 236 - } 237 226 238 227 pm_runtime_get_sync(uc->dev); 239 228 while (rem_len > 0) { ··· 264 277 265 278 msgs[0].len = len + sizeof(rab); 266 279 msgs[0].buf = buf; 267 - 268 - if (uc->fw_build == CCG_FW_BUILD_NVIDIA && 269 - uc->fw_version <= CCG_OLD_FW_VERSION) { 270 - mutex_lock(&uc->lock); 271 - /* 272 - * Do not schedule pm_work to run ISR in 273 - * ucsi_ccg_runtime_resume() after pm_runtime_get_sync() 274 - * since we are already in ISR path. 275 - */ 276 - uc->run_isr = false; 277 - mutex_unlock(&uc->lock); 278 - } 279 280 280 281 pm_runtime_get_sync(uc->dev); 281 282 status = i2c_transfer(client->adapter, msgs, ARRAY_SIZE(msgs)); ··· 1105 1130 uc->ppm.sync = ucsi_ccg_sync; 1106 1131 uc->dev = dev; 1107 1132 uc->client = client; 1108 - uc->run_isr = true; 1109 1133 mutex_init(&uc->lock); 1110 1134 INIT_WORK(&uc->work, ccg_update_firmware); 1111 1135 INIT_WORK(&uc->pm_work, ccg_pm_workaround_work); ··· 1162 1188 1163 1189 pm_runtime_set_active(uc->dev); 1164 1190 pm_runtime_enable(uc->dev); 1191 + pm_runtime_use_autosuspend(uc->dev); 1192 + pm_runtime_set_autosuspend_delay(uc->dev, 5000); 1165 1193 pm_runtime_idle(uc->dev); 1166 1194 1167 1195 return 0; ··· 1205 1229 { 1206 1230 struct i2c_client *client = to_i2c_client(dev); 1207 1231 struct ucsi_ccg *uc = i2c_get_clientdata(client); 1208 - bool schedule = true; 1209 1232 1210 1233 /* 1211 1234 * Firmware version 3.1.10 or earlier, built for NVIDIA has known issue ··· 1212 1237 * Schedule a work to call ISR as a workaround. 1213 1238 */ 1214 1239 if (uc->fw_build == CCG_FW_BUILD_NVIDIA && 1215 - uc->fw_version <= CCG_OLD_FW_VERSION) { 1216 - mutex_lock(&uc->lock); 1217 - if (!uc->run_isr) { 1218 - uc->run_isr = true; 1219 - schedule = false; 1220 - } 1221 - mutex_unlock(&uc->lock); 1222 - 1223 - if (schedule) 1224 - schedule_work(&uc->pm_work); 1225 - } 1240 + uc->fw_version <= CCG_OLD_FW_VERSION) 1241 + schedule_work(&uc->pm_work); 1226 1242 1227 1243 return 0; 1228 1244 }
+9 -10
drivers/usb/usb-skeleton.c
··· 61 61 spinlock_t err_lock; /* lock for errors */ 62 62 struct kref kref; 63 63 struct mutex io_mutex; /* synchronize I/O with disconnect */ 64 + unsigned long disconnected:1; 64 65 wait_queue_head_t bulk_in_wait; /* to wait for an ongoing read */ 65 66 }; 66 67 #define to_skel_dev(d) container_of(d, struct usb_skel, kref) ··· 74 73 struct usb_skel *dev = to_skel_dev(kref); 75 74 76 75 usb_free_urb(dev->bulk_in_urb); 76 + usb_put_intf(dev->interface); 77 77 usb_put_dev(dev->udev); 78 78 kfree(dev->bulk_in_buffer); 79 79 kfree(dev); ··· 126 124 return -ENODEV; 127 125 128 126 /* allow the device to be autosuspended */ 129 - mutex_lock(&dev->io_mutex); 130 - if (dev->interface) 131 - usb_autopm_put_interface(dev->interface); 132 - mutex_unlock(&dev->io_mutex); 127 + usb_autopm_put_interface(dev->interface); 133 128 134 129 /* decrement the count on our device */ 135 130 kref_put(&dev->kref, skel_delete); ··· 230 231 231 232 dev = file->private_data; 232 233 233 - /* if we cannot read at all, return EOF */ 234 - if (!dev->bulk_in_urb || !count) 234 + if (!count) 235 235 return 0; 236 236 237 237 /* no concurrent readers */ ··· 238 240 if (rv < 0) 239 241 return rv; 240 242 241 - if (!dev->interface) { /* disconnect() was called */ 243 + if (dev->disconnected) { /* disconnect() was called */ 242 244 rv = -ENODEV; 243 245 goto exit; 244 246 } ··· 420 422 421 423 /* this lock makes sure we don't submit URBs to gone devices */ 422 424 mutex_lock(&dev->io_mutex); 423 - if (!dev->interface) { /* disconnect() was called */ 425 + if (dev->disconnected) { /* disconnect() was called */ 424 426 mutex_unlock(&dev->io_mutex); 425 427 retval = -ENODEV; 426 428 goto error; ··· 505 507 init_waitqueue_head(&dev->bulk_in_wait); 506 508 507 509 dev->udev = usb_get_dev(interface_to_usbdev(interface)); 508 - dev->interface = interface; 510 + dev->interface = usb_get_intf(interface); 509 511 510 512 /* set up the endpoint information */ 511 513 /* use only the first bulk-in and bulk-out endpoints */ ··· 571 573 572 574 /* prevent more I/O from starting */ 573 575 mutex_lock(&dev->io_mutex); 574 - dev->interface = NULL; 576 + dev->disconnected = 1; 575 577 mutex_unlock(&dev->io_mutex); 576 578 579 + usb_kill_urb(dev->bulk_in_urb); 577 580 usb_kill_anchored_urbs(&dev->submitted); 578 581 579 582 /* decrement our usage count */
+2 -2
drivers/usb/usbip/vhci_hcd.c
··· 1195 1195 if (id == 0 && usb_hcd_is_primary_hcd(hcd)) { 1196 1196 err = vhci_init_attr_group(); 1197 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 1199 return err; 1200 1200 } 1201 1201 err = sysfs_create_group(&hcd_dev(hcd)->kobj, &vhci_attr_group); 1202 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 1204 vhci_finish_attr_group(); 1205 1205 return err; 1206 1206 }
+2
include/linux/platform_device.h
··· 64 64 unsigned int, 65 65 const char *); 66 66 extern int platform_get_irq_byname(struct platform_device *, const char *); 67 + extern int platform_get_irq_byname_optional(struct platform_device *dev, 68 + const char *name); 67 69 extern int platform_add_devices(struct platform_device **, int); 68 70 69 71 struct platform_device_info {