diff options
author | Bastien Nocera <hadess@hadess.net> | 2019-09-23 12:18:43 -0400 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@linuxfoundation.org> | 2019-10-04 04:53:36 -0400 |
commit | 015664d15270a112c2371d812f03f7c579b35a73 (patch) | |
tree | b0eb88204ba848ac7a0e6b37443be03f77746668 | |
parent | 54ecb8f7028c5eb3d740bb82b0f1d90f2df63c5c (diff) |
USB: rio500: Remove Rio 500 kernel driver
The Rio500 kernel driver has not been used by Rio500 owners since 2001
not long after the rio500 project added support for a user-space USB stack
through the very first versions of usbdevfs and then libusb.
Support for the kernel driver was removed from the upstream utilities
in 2008:
https://gitlab.freedesktop.org/hadess/rio500/commit/943f624ab721eb8281c287650fcc9e2026f6f5db
Cc: Cesar Miquel <miquel@df.uba.ar>
Signed-off-by: Bastien Nocera <hadess@hadess.net>
Cc: stable <stable@vger.kernel.org>
Link: https://lore.kernel.org/r/6251c17584d220472ce882a3d9c199c401a51a71.camel@hadess.net
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
-rw-r--r-- | Documentation/usb/rio.rst | 109 | ||||
-rw-r--r-- | MAINTAINERS | 7 | ||||
-rw-r--r-- | arch/arm/configs/badge4_defconfig | 1 | ||||
-rw-r--r-- | arch/arm/configs/corgi_defconfig | 1 | ||||
-rw-r--r-- | arch/arm/configs/pxa_defconfig | 1 | ||||
-rw-r--r-- | arch/arm/configs/s3c2410_defconfig | 1 | ||||
-rw-r--r-- | arch/arm/configs/spitz_defconfig | 1 | ||||
-rw-r--r-- | arch/mips/configs/mtx1_defconfig | 1 | ||||
-rw-r--r-- | arch/mips/configs/rm200_defconfig | 1 | ||||
-rw-r--r-- | drivers/usb/misc/Kconfig | 10 | ||||
-rw-r--r-- | drivers/usb/misc/Makefile | 1 | ||||
-rw-r--r-- | drivers/usb/misc/rio500.c | 554 | ||||
-rw-r--r-- | drivers/usb/misc/rio500_usb.h | 20 |
13 files changed, 0 insertions, 708 deletions
diff --git a/Documentation/usb/rio.rst b/Documentation/usb/rio.rst deleted file mode 100644 index ea73475471db..000000000000 --- a/Documentation/usb/rio.rst +++ /dev/null | |||
@@ -1,109 +0,0 @@ | |||
1 | ============ | ||
2 | Diamonds Rio | ||
3 | ============ | ||
4 | |||
5 | Copyright (C) 1999, 2000 Bruce Tenison | ||
6 | |||
7 | Portions Copyright (C) 1999, 2000 David Nelson | ||
8 | |||
9 | Thanks to David Nelson for guidance and the usage of the scanner.txt | ||
10 | and scanner.c files to model our driver and this informative file. | ||
11 | |||
12 | Mar. 2, 2000 | ||
13 | |||
14 | Changes | ||
15 | ======= | ||
16 | |||
17 | - Initial Revision | ||
18 | |||
19 | |||
20 | Overview | ||
21 | ======== | ||
22 | |||
23 | This README will address issues regarding how to configure the kernel | ||
24 | to access a RIO 500 mp3 player. | ||
25 | Before I explain how to use this to access the Rio500 please be warned: | ||
26 | |||
27 | .. warning:: | ||
28 | |||
29 | Please note that this software is still under development. The authors | ||
30 | are in no way responsible for any damage that may occur, no matter how | ||
31 | inconsequential. | ||
32 | |||
33 | It seems that the Rio has a problem when sending .mp3 with low batteries. | ||
34 | I suggest when the batteries are low and you want to transfer stuff that you | ||
35 | replace it with a fresh one. In my case, what happened is I lost two 16kb | ||
36 | blocks (they are no longer usable to store information to it). But I don't | ||
37 | know if that's normal or not; it could simply be a problem with the flash | ||
38 | memory. | ||
39 | |||
40 | In an extreme case, I left my Rio playing overnight and the batteries wore | ||
41 | down to nothing and appear to have corrupted the flash memory. My RIO | ||
42 | needed to be replaced as a result. Diamond tech support is aware of the | ||
43 | problem. Do NOT allow your batteries to wear down to nothing before | ||
44 | changing them. It appears RIO 500 firmware does not handle low battery | ||
45 | power well at all. | ||
46 | |||
47 | On systems with OHCI controllers, the kernel OHCI code appears to have | ||
48 | power on problems with some chipsets. If you are having problems | ||
49 | connecting to your RIO 500, try turning it on first and then plugging it | ||
50 | into the USB cable. | ||
51 | |||
52 | Contact Information | ||
53 | ------------------- | ||
54 | |||
55 | The main page for the project is hosted at sourceforge.net in the following | ||
56 | URL: <http://rio500.sourceforge.net>. You can also go to the project's | ||
57 | sourceforge home page at: <http://sourceforge.net/projects/rio500/>. | ||
58 | There is also a mailing list: rio500-users@lists.sourceforge.net | ||
59 | |||
60 | Authors | ||
61 | ------- | ||
62 | |||
63 | Most of the code was written by Cesar Miquel <miquel@df.uba.ar>. Keith | ||
64 | Clayton <kclayton@jps.net> is incharge of the PPC port and making sure | ||
65 | things work there. Bruce Tenison <btenison@dibbs.net> is adding support | ||
66 | for .fon files and also does testing. The program will mostly sure be | ||
67 | re-written and Pete Ikusz along with the rest will re-design it. I would | ||
68 | also like to thank Tri Nguyen <tmn_3022000@hotmail.com> who provided use | ||
69 | with some important information regarding the communication with the Rio. | ||
70 | |||
71 | Additional Information and userspace tools | ||
72 | |||
73 | http://rio500.sourceforge.net/ | ||
74 | |||
75 | |||
76 | Requirements | ||
77 | ============ | ||
78 | |||
79 | A host with a USB port running a Linux kernel with RIO 500 support enabled. | ||
80 | |||
81 | The driver is a module called rio500, which should be automatically loaded | ||
82 | as you plug in your device. If that fails you can manually load it with | ||
83 | |||
84 | modprobe rio500 | ||
85 | |||
86 | Udev should automatically create a device node as soon as plug in your device. | ||
87 | If that fails, you can manually add a device for the USB rio500:: | ||
88 | |||
89 | mknod /dev/usb/rio500 c 180 64 | ||
90 | |||
91 | In that case, set appropriate permissions for /dev/usb/rio500 (don't forget | ||
92 | about group and world permissions). Both read and write permissions are | ||
93 | required for proper operation. | ||
94 | |||
95 | That's it. The Rio500 Utils at: http://rio500.sourceforge.net should | ||
96 | be able to access the rio500. | ||
97 | |||
98 | Limits | ||
99 | ====== | ||
100 | |||
101 | You can use only a single rio500 device at a time with your computer. | ||
102 | |||
103 | Bugs | ||
104 | ==== | ||
105 | |||
106 | If you encounter any problems feel free to drop me an email. | ||
107 | |||
108 | Bruce Tenison | ||
109 | btenison@dibbs.net | ||
diff --git a/MAINTAINERS b/MAINTAINERS index 296de2b51c83..3bcf493f3f8c 100644 --- a/MAINTAINERS +++ b/MAINTAINERS | |||
@@ -16762,13 +16762,6 @@ W: http://www.linux-usb.org/usbnet | |||
16762 | S: Maintained | 16762 | S: Maintained |
16763 | F: drivers/net/usb/dm9601.c | 16763 | F: drivers/net/usb/dm9601.c |
16764 | 16764 | ||
16765 | USB DIAMOND RIO500 DRIVER | ||
16766 | M: Cesar Miquel <miquel@df.uba.ar> | ||
16767 | L: rio500-users@lists.sourceforge.net | ||
16768 | W: http://rio500.sourceforge.net | ||
16769 | S: Maintained | ||
16770 | F: drivers/usb/misc/rio500* | ||
16771 | |||
16772 | USB EHCI DRIVER | 16765 | USB EHCI DRIVER |
16773 | M: Alan Stern <stern@rowland.harvard.edu> | 16766 | M: Alan Stern <stern@rowland.harvard.edu> |
16774 | L: linux-usb@vger.kernel.org | 16767 | L: linux-usb@vger.kernel.org |
diff --git a/arch/arm/configs/badge4_defconfig b/arch/arm/configs/badge4_defconfig index 5ae5b5228467..ef484c4cfd1a 100644 --- a/arch/arm/configs/badge4_defconfig +++ b/arch/arm/configs/badge4_defconfig | |||
@@ -91,7 +91,6 @@ CONFIG_USB_SERIAL_PL2303=m | |||
91 | CONFIG_USB_SERIAL_CYBERJACK=m | 91 | CONFIG_USB_SERIAL_CYBERJACK=m |
92 | CONFIG_USB_SERIAL_XIRCOM=m | 92 | CONFIG_USB_SERIAL_XIRCOM=m |
93 | CONFIG_USB_SERIAL_OMNINET=m | 93 | CONFIG_USB_SERIAL_OMNINET=m |
94 | CONFIG_USB_RIO500=m | ||
95 | CONFIG_EXT2_FS=m | 94 | CONFIG_EXT2_FS=m |
96 | CONFIG_EXT3_FS=m | 95 | CONFIG_EXT3_FS=m |
97 | CONFIG_MSDOS_FS=y | 96 | CONFIG_MSDOS_FS=y |
diff --git a/arch/arm/configs/corgi_defconfig b/arch/arm/configs/corgi_defconfig index e4f6442588e7..4fec2ec379ad 100644 --- a/arch/arm/configs/corgi_defconfig +++ b/arch/arm/configs/corgi_defconfig | |||
@@ -195,7 +195,6 @@ CONFIG_USB_SERIAL_XIRCOM=m | |||
195 | CONFIG_USB_SERIAL_OMNINET=m | 195 | CONFIG_USB_SERIAL_OMNINET=m |
196 | CONFIG_USB_EMI62=m | 196 | CONFIG_USB_EMI62=m |
197 | CONFIG_USB_EMI26=m | 197 | CONFIG_USB_EMI26=m |
198 | CONFIG_USB_RIO500=m | ||
199 | CONFIG_USB_LEGOTOWER=m | 198 | CONFIG_USB_LEGOTOWER=m |
200 | CONFIG_USB_LCD=m | 199 | CONFIG_USB_LCD=m |
201 | CONFIG_USB_CYTHERM=m | 200 | CONFIG_USB_CYTHERM=m |
diff --git a/arch/arm/configs/pxa_defconfig b/arch/arm/configs/pxa_defconfig index 787c3f9be414..b817c57f05f1 100644 --- a/arch/arm/configs/pxa_defconfig +++ b/arch/arm/configs/pxa_defconfig | |||
@@ -581,7 +581,6 @@ CONFIG_USB_SERIAL_XIRCOM=m | |||
581 | CONFIG_USB_SERIAL_OMNINET=m | 581 | CONFIG_USB_SERIAL_OMNINET=m |
582 | CONFIG_USB_EMI62=m | 582 | CONFIG_USB_EMI62=m |
583 | CONFIG_USB_EMI26=m | 583 | CONFIG_USB_EMI26=m |
584 | CONFIG_USB_RIO500=m | ||
585 | CONFIG_USB_LEGOTOWER=m | 584 | CONFIG_USB_LEGOTOWER=m |
586 | CONFIG_USB_LCD=m | 585 | CONFIG_USB_LCD=m |
587 | CONFIG_USB_CYTHERM=m | 586 | CONFIG_USB_CYTHERM=m |
diff --git a/arch/arm/configs/s3c2410_defconfig b/arch/arm/configs/s3c2410_defconfig index 95b5a4ffddea..73ed73a8785a 100644 --- a/arch/arm/configs/s3c2410_defconfig +++ b/arch/arm/configs/s3c2410_defconfig | |||
@@ -327,7 +327,6 @@ CONFIG_USB_EMI62=m | |||
327 | CONFIG_USB_EMI26=m | 327 | CONFIG_USB_EMI26=m |
328 | CONFIG_USB_ADUTUX=m | 328 | CONFIG_USB_ADUTUX=m |
329 | CONFIG_USB_SEVSEG=m | 329 | CONFIG_USB_SEVSEG=m |
330 | CONFIG_USB_RIO500=m | ||
331 | CONFIG_USB_LEGOTOWER=m | 330 | CONFIG_USB_LEGOTOWER=m |
332 | CONFIG_USB_LCD=m | 331 | CONFIG_USB_LCD=m |
333 | CONFIG_USB_CYPRESS_CY7C63=m | 332 | CONFIG_USB_CYPRESS_CY7C63=m |
diff --git a/arch/arm/configs/spitz_defconfig b/arch/arm/configs/spitz_defconfig index 4fb51d665abb..a1cdbfa064c5 100644 --- a/arch/arm/configs/spitz_defconfig +++ b/arch/arm/configs/spitz_defconfig | |||
@@ -189,7 +189,6 @@ CONFIG_USB_SERIAL_XIRCOM=m | |||
189 | CONFIG_USB_SERIAL_OMNINET=m | 189 | CONFIG_USB_SERIAL_OMNINET=m |
190 | CONFIG_USB_EMI62=m | 190 | CONFIG_USB_EMI62=m |
191 | CONFIG_USB_EMI26=m | 191 | CONFIG_USB_EMI26=m |
192 | CONFIG_USB_RIO500=m | ||
193 | CONFIG_USB_LEGOTOWER=m | 192 | CONFIG_USB_LEGOTOWER=m |
194 | CONFIG_USB_LCD=m | 193 | CONFIG_USB_LCD=m |
195 | CONFIG_USB_CYTHERM=m | 194 | CONFIG_USB_CYTHERM=m |
diff --git a/arch/mips/configs/mtx1_defconfig b/arch/mips/configs/mtx1_defconfig index 16bef819fe98..914af125a7fa 100644 --- a/arch/mips/configs/mtx1_defconfig +++ b/arch/mips/configs/mtx1_defconfig | |||
@@ -571,7 +571,6 @@ CONFIG_USB_SERIAL_OMNINET=m | |||
571 | CONFIG_USB_EMI62=m | 571 | CONFIG_USB_EMI62=m |
572 | CONFIG_USB_EMI26=m | 572 | CONFIG_USB_EMI26=m |
573 | CONFIG_USB_ADUTUX=m | 573 | CONFIG_USB_ADUTUX=m |
574 | CONFIG_USB_RIO500=m | ||
575 | CONFIG_USB_LEGOTOWER=m | 574 | CONFIG_USB_LEGOTOWER=m |
576 | CONFIG_USB_LCD=m | 575 | CONFIG_USB_LCD=m |
577 | CONFIG_USB_CYPRESS_CY7C63=m | 576 | CONFIG_USB_CYPRESS_CY7C63=m |
diff --git a/arch/mips/configs/rm200_defconfig b/arch/mips/configs/rm200_defconfig index 8762e75f5d5f..2c7adea7638f 100644 --- a/arch/mips/configs/rm200_defconfig +++ b/arch/mips/configs/rm200_defconfig | |||
@@ -314,7 +314,6 @@ CONFIG_USB_SERIAL_SAFE_PADDED=y | |||
314 | CONFIG_USB_SERIAL_CYBERJACK=m | 314 | CONFIG_USB_SERIAL_CYBERJACK=m |
315 | CONFIG_USB_SERIAL_XIRCOM=m | 315 | CONFIG_USB_SERIAL_XIRCOM=m |
316 | CONFIG_USB_SERIAL_OMNINET=m | 316 | CONFIG_USB_SERIAL_OMNINET=m |
317 | CONFIG_USB_RIO500=m | ||
318 | CONFIG_USB_LEGOTOWER=m | 317 | CONFIG_USB_LEGOTOWER=m |
319 | CONFIG_USB_LCD=m | 318 | CONFIG_USB_LCD=m |
320 | CONFIG_USB_CYTHERM=m | 319 | CONFIG_USB_CYTHERM=m |
diff --git a/drivers/usb/misc/Kconfig b/drivers/usb/misc/Kconfig index bdae62b2ffe0..9bce583aada3 100644 --- a/drivers/usb/misc/Kconfig +++ b/drivers/usb/misc/Kconfig | |||
@@ -47,16 +47,6 @@ config USB_SEVSEG | |||
47 | To compile this driver as a module, choose M here: the | 47 | 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 | ||
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 | config USB_LEGOTOWER | 50 | config USB_LEGOTOWER |
61 | tristate "USB Lego Infrared Tower support" | 51 | tristate "USB Lego Infrared Tower support" |
62 | help | 52 | help |
diff --git a/drivers/usb/misc/Makefile b/drivers/usb/misc/Makefile index 109f54f5b9aa..0d416eb624bb 100644 --- a/drivers/usb/misc/Makefile +++ b/drivers/usb/misc/Makefile | |||
@@ -17,7 +17,6 @@ obj-$(CONFIG_USB_ISIGHTFW) += isight_firmware.o | |||
17 | obj-$(CONFIG_USB_LCD) += usblcd.o | 17 | obj-$(CONFIG_USB_LCD) += usblcd.o |
18 | obj-$(CONFIG_USB_LD) += ldusb.o | 18 | obj-$(CONFIG_USB_LD) += ldusb.o |
19 | obj-$(CONFIG_USB_LEGOTOWER) += legousbtower.o | 19 | obj-$(CONFIG_USB_LEGOTOWER) += legousbtower.o |
20 | obj-$(CONFIG_USB_RIO500) += rio500.o | ||
21 | obj-$(CONFIG_USB_TEST) += usbtest.o | 20 | obj-$(CONFIG_USB_TEST) += usbtest.o |
22 | obj-$(CONFIG_USB_EHSET_TEST_FIXTURE) += ehset.o | 21 | obj-$(CONFIG_USB_EHSET_TEST_FIXTURE) += ehset.o |
23 | obj-$(CONFIG_USB_TRANCEVIBRATOR) += trancevibrator.o | 22 | obj-$(CONFIG_USB_TRANCEVIBRATOR) += trancevibrator.o |
diff --git a/drivers/usb/misc/rio500.c b/drivers/usb/misc/rio500.c deleted file mode 100644 index 30cae5e1954d..000000000000 --- a/drivers/usb/misc/rio500.c +++ /dev/null | |||
@@ -1,554 +0,0 @@ | |||
1 | // SPDX-License-Identifier: GPL-2.0+ | ||
2 | /* -*- linux-c -*- */ | ||
3 | |||
4 | /* | ||
5 | * Driver for USB Rio 500 | ||
6 | * | ||
7 | * Cesar Miquel (miquel@df.uba.ar) | ||
8 | * | ||
9 | * based on hp_scanner.c by David E. Nelson (dnelson@jump.net) | ||
10 | * | ||
11 | * Based upon mouse.c (Brad Keryan) and printer.c (Michael Gee). | ||
12 | * | ||
13 | * Changelog: | ||
14 | * 30/05/2003 replaced lock/unlock kernel with up/down | ||
15 | * Daniele Bellucci bellucda@tiscali.it | ||
16 | * */ | ||
17 | |||
18 | #include <linux/module.h> | ||
19 | #include <linux/kernel.h> | ||
20 | #include <linux/signal.h> | ||
21 | #include <linux/sched/signal.h> | ||
22 | #include <linux/mutex.h> | ||
23 | #include <linux/errno.h> | ||
24 | #include <linux/random.h> | ||
25 | #include <linux/poll.h> | ||
26 | #include <linux/slab.h> | ||
27 | #include <linux/spinlock.h> | ||
28 | #include <linux/usb.h> | ||
29 | #include <linux/wait.h> | ||
30 | |||
31 | #include "rio500_usb.h" | ||
32 | |||
33 | #define DRIVER_AUTHOR "Cesar Miquel <miquel@df.uba.ar>" | ||
34 | #define DRIVER_DESC "USB Rio 500 driver" | ||
35 | |||
36 | #define RIO_MINOR 64 | ||
37 | |||
38 | /* stall/wait timeout for rio */ | ||
39 | #define NAK_TIMEOUT (HZ) | ||
40 | |||
41 | #define IBUF_SIZE 0x1000 | ||
42 | |||
43 | /* Size of the rio buffer */ | ||
44 | #define OBUF_SIZE 0x10000 | ||
45 | |||
46 | struct rio_usb_data { | ||
47 | struct usb_device *rio_dev; /* init: probe_rio */ | ||
48 | unsigned int ifnum; /* Interface number of the USB device */ | ||
49 | int isopen; /* nz if open */ | ||
50 | int present; /* Device is present on the bus */ | ||
51 | char *obuf, *ibuf; /* transfer buffers */ | ||
52 | char bulk_in_ep, bulk_out_ep; /* Endpoint assignments */ | ||
53 | wait_queue_head_t wait_q; /* for timeouts */ | ||
54 | }; | ||
55 | |||
56 | static DEFINE_MUTEX(rio500_mutex); | ||
57 | static struct rio_usb_data rio_instance; | ||
58 | |||
59 | static int open_rio(struct inode *inode, struct file *file) | ||
60 | { | ||
61 | struct rio_usb_data *rio = &rio_instance; | ||
62 | |||
63 | /* against disconnect() */ | ||
64 | mutex_lock(&rio500_mutex); | ||
65 | |||
66 | if (rio->isopen || !rio->present) { | ||
67 | mutex_unlock(&rio500_mutex); | ||
68 | return -EBUSY; | ||
69 | } | ||
70 | rio->isopen = 1; | ||
71 | |||
72 | init_waitqueue_head(&rio->wait_q); | ||
73 | |||
74 | |||
75 | dev_info(&rio->rio_dev->dev, "Rio opened.\n"); | ||
76 | mutex_unlock(&rio500_mutex); | ||
77 | |||
78 | return 0; | ||
79 | } | ||
80 | |||
81 | static int close_rio(struct inode *inode, struct file *file) | ||
82 | { | ||
83 | struct rio_usb_data *rio = &rio_instance; | ||
84 | |||
85 | /* against disconnect() */ | ||
86 | mutex_lock(&rio500_mutex); | ||
87 | |||
88 | rio->isopen = 0; | ||
89 | if (!rio->present) { | ||
90 | /* cleanup has been delayed */ | ||
91 | kfree(rio->ibuf); | ||
92 | kfree(rio->obuf); | ||
93 | rio->ibuf = NULL; | ||
94 | rio->obuf = NULL; | ||
95 | } else { | ||
96 | dev_info(&rio->rio_dev->dev, "Rio closed.\n"); | ||
97 | } | ||
98 | mutex_unlock(&rio500_mutex); | ||
99 | return 0; | ||
100 | } | ||
101 | |||
102 | static long ioctl_rio(struct file *file, unsigned int cmd, unsigned long arg) | ||
103 | { | ||
104 | struct RioCommand rio_cmd; | ||
105 | struct rio_usb_data *rio = &rio_instance; | ||
106 | void __user *data; | ||
107 | unsigned char *buffer; | ||
108 | int result, requesttype; | ||
109 | int retries; | ||
110 | int retval=0; | ||
111 | |||
112 | mutex_lock(&rio500_mutex); | ||
113 | /* Sanity check to make sure rio is connected, powered, etc */ | ||
114 | if (rio->present == 0 || rio->rio_dev == NULL) { | ||
115 | retval = -ENODEV; | ||
116 | goto err_out; | ||
117 | } | ||
118 | |||
119 | switch (cmd) { | ||
120 | case RIO_RECV_COMMAND: | ||
121 | data = (void __user *) arg; | ||
122 | if (data == NULL) | ||
123 | break; | ||
124 | if (copy_from_user(&rio_cmd, data, sizeof(struct RioCommand))) { | ||
125 | retval = -EFAULT; | ||
126 | goto err_out; | ||
127 | } | ||
128 | if (rio_cmd.length < 0 || rio_cmd.length > PAGE_SIZE) { | ||
129 | retval = -EINVAL; | ||
130 | goto err_out; | ||
131 | } | ||
132 | buffer = (unsigned char *) __get_free_page(GFP_KERNEL); | ||
133 | if (buffer == NULL) { | ||
134 | retval = -ENOMEM; | ||
135 | goto err_out; | ||
136 | } | ||
137 | if (copy_from_user(buffer, rio_cmd.buffer, rio_cmd.length)) { | ||
138 | retval = -EFAULT; | ||
139 | free_page((unsigned long) buffer); | ||
140 | goto err_out; | ||
141 | } | ||
142 | |||
143 | requesttype = rio_cmd.requesttype | USB_DIR_IN | | ||
144 | USB_TYPE_VENDOR | USB_RECIP_DEVICE; | ||
145 | dev_dbg(&rio->rio_dev->dev, | ||
146 | "sending command:reqtype=%0x req=%0x value=%0x index=%0x len=%0x\n", | ||
147 | requesttype, rio_cmd.request, rio_cmd.value, | ||
148 | rio_cmd.index, rio_cmd.length); | ||
149 | /* Send rio control message */ | ||
150 | retries = 3; | ||
151 | while (retries) { | ||
152 | result = usb_control_msg(rio->rio_dev, | ||
153 | usb_rcvctrlpipe(rio-> rio_dev, 0), | ||
154 | rio_cmd.request, | ||
155 | requesttype, | ||
156 | rio_cmd.value, | ||
157 | rio_cmd.index, buffer, | ||
158 | rio_cmd.length, | ||
159 | jiffies_to_msecs(rio_cmd.timeout)); | ||
160 | if (result == -ETIMEDOUT) | ||
161 | retries--; | ||
162 | else if (result < 0) { | ||
163 | dev_err(&rio->rio_dev->dev, | ||
164 | "Error executing ioctrl. code = %d\n", | ||
165 | result); | ||
166 | retries = 0; | ||
167 | } else { | ||
168 | dev_dbg(&rio->rio_dev->dev, | ||
169 | "Executed ioctl. Result = %d (data=%02x)\n", | ||
170 | result, buffer[0]); | ||
171 | if (copy_to_user(rio_cmd.buffer, buffer, | ||
172 | rio_cmd.length)) { | ||
173 | free_page((unsigned long) buffer); | ||
174 | retval = -EFAULT; | ||
175 | goto err_out; | ||
176 | } | ||
177 | retries = 0; | ||
178 | } | ||
179 | |||
180 | /* rio_cmd.buffer contains a raw stream of single byte | ||
181 | data which has been returned from rio. Data is | ||
182 | interpreted at application level. For data that | ||
183 | will be cast to data types longer than 1 byte, data | ||
184 | will be little_endian and will potentially need to | ||
185 | be swapped at the app level */ | ||
186 | |||
187 | } | ||
188 | free_page((unsigned long) buffer); | ||
189 | break; | ||
190 | |||
191 | case RIO_SEND_COMMAND: | ||
192 | data = (void __user *) arg; | ||
193 | if (data == NULL) | ||
194 | break; | ||
195 | if (copy_from_user(&rio_cmd, data, sizeof(struct RioCommand))) { | ||
196 | retval = -EFAULT; | ||
197 | goto err_out; | ||
198 | } | ||
199 | if (rio_cmd.length < 0 || rio_cmd.length > PAGE_SIZE) { | ||
200 | retval = -EINVAL; | ||
201 | goto err_out; | ||
202 | } | ||
203 | buffer = (unsigned char *) __get_free_page(GFP_KERNEL); | ||
204 | if (buffer == NULL) { | ||
205 | retval = -ENOMEM; | ||
206 | goto err_out; | ||
207 | } | ||
208 | if (copy_from_user(buffer, rio_cmd.buffer, rio_cmd.length)) { | ||
209 | free_page((unsigned long)buffer); | ||
210 | retval = -EFAULT; | ||
211 | goto err_out; | ||
212 | } | ||
213 | |||
214 | requesttype = rio_cmd.requesttype | USB_DIR_OUT | | ||
215 | USB_TYPE_VENDOR | USB_RECIP_DEVICE; | ||
216 | dev_dbg(&rio->rio_dev->dev, | ||
217 | "sending command: reqtype=%0x req=%0x value=%0x index=%0x len=%0x\n", | ||
218 | requesttype, rio_cmd.request, rio_cmd.value, | ||
219 | rio_cmd.index, rio_cmd.length); | ||
220 | /* Send rio control message */ | ||
221 | retries = 3; | ||
222 | while (retries) { | ||
223 | result = usb_control_msg(rio->rio_dev, | ||
224 | usb_sndctrlpipe(rio-> rio_dev, 0), | ||
225 | rio_cmd.request, | ||
226 | requesttype, | ||
227 | rio_cmd.value, | ||
228 | rio_cmd.index, buffer, | ||
229 | rio_cmd.length, | ||
230 | jiffies_to_msecs(rio_cmd.timeout)); | ||
231 | if (result == -ETIMEDOUT) | ||
232 | retries--; | ||
233 | else if (result < 0) { | ||
234 | dev_err(&rio->rio_dev->dev, | ||
235 | "Error executing ioctrl. code = %d\n", | ||
236 | result); | ||
237 | retries = 0; | ||
238 | } else { | ||
239 | dev_dbg(&rio->rio_dev->dev, | ||
240 | "Executed ioctl. Result = %d\n", result); | ||
241 | retries = 0; | ||
242 | |||
243 | } | ||
244 | |||
245 | } | ||
246 | free_page((unsigned long) buffer); | ||
247 | break; | ||
248 | |||
249 | default: | ||
250 | retval = -ENOTTY; | ||
251 | break; | ||
252 | } | ||
253 | |||
254 | |||
255 | err_out: | ||
256 | mutex_unlock(&rio500_mutex); | ||
257 | return retval; | ||
258 | } | ||
259 | |||
260 | static ssize_t | ||
261 | write_rio(struct file *file, const char __user *buffer, | ||
262 | size_t count, loff_t * ppos) | ||
263 | { | ||
264 | DEFINE_WAIT(wait); | ||
265 | struct rio_usb_data *rio = &rio_instance; | ||
266 | |||
267 | unsigned long copy_size; | ||
268 | unsigned long bytes_written = 0; | ||
269 | unsigned int partial; | ||
270 | |||
271 | int result = 0; | ||
272 | int maxretry; | ||
273 | int errn = 0; | ||
274 | int intr; | ||
275 | |||
276 | intr = mutex_lock_interruptible(&rio500_mutex); | ||
277 | if (intr) | ||
278 | return -EINTR; | ||
279 | /* Sanity check to make sure rio is connected, powered, etc */ | ||
280 | if (rio->present == 0 || rio->rio_dev == NULL) { | ||
281 | mutex_unlock(&rio500_mutex); | ||
282 | return -ENODEV; | ||
283 | } | ||
284 | |||
285 | |||
286 | |||
287 | do { | ||
288 | unsigned long thistime; | ||
289 | char *obuf = rio->obuf; | ||
290 | |||
291 | thistime = copy_size = | ||
292 | (count >= OBUF_SIZE) ? OBUF_SIZE : count; | ||
293 | if (copy_from_user(rio->obuf, buffer, copy_size)) { | ||
294 | errn = -EFAULT; | ||
295 | goto error; | ||
296 | } | ||
297 | maxretry = 5; | ||
298 | while (thistime) { | ||
299 | if (!rio->rio_dev) { | ||
300 | errn = -ENODEV; | ||
301 | goto error; | ||
302 | } | ||
303 | if (signal_pending(current)) { | ||
304 | mutex_unlock(&rio500_mutex); | ||
305 | return bytes_written ? bytes_written : -EINTR; | ||
306 | } | ||
307 | |||
308 | result = usb_bulk_msg(rio->rio_dev, | ||
309 | usb_sndbulkpipe(rio->rio_dev, 2), | ||
310 | obuf, thistime, &partial, 5000); | ||
311 | |||
312 | dev_dbg(&rio->rio_dev->dev, | ||
313 | "write stats: result:%d thistime:%lu partial:%u\n", | ||
314 | result, thistime, partial); | ||
315 | |||
316 | if (result == -ETIMEDOUT) { /* NAK - so hold for a while */ | ||
317 | if (!maxretry--) { | ||
318 | errn = -ETIME; | ||
319 | goto error; | ||
320 | } | ||
321 | prepare_to_wait(&rio->wait_q, &wait, TASK_INTERRUPTIBLE); | ||
322 | schedule_timeout(NAK_TIMEOUT); | ||
323 | finish_wait(&rio->wait_q, &wait); | ||
324 | continue; | ||
325 | } else if (!result && partial) { | ||
326 | obuf += partial; | ||
327 | thistime -= partial; | ||
328 | } else | ||
329 | break; | ||
330 | } | ||
331 | if (result) { | ||
332 | dev_err(&rio->rio_dev->dev, "Write Whoops - %x\n", | ||
333 | result); | ||
334 | errn = -EIO; | ||
335 | goto error; | ||
336 | } | ||
337 | bytes_written += copy_size; | ||
338 | count -= copy_size; | ||
339 | buffer += copy_size; | ||
340 | } while (count > 0); | ||
341 | |||
342 | mutex_unlock(&rio500_mutex); | ||
343 | |||
344 | return bytes_written ? bytes_written : -EIO; | ||
345 | |||
346 | error: | ||
347 | mutex_unlock(&rio500_mutex); | ||
348 | return errn; | ||
349 | } | ||
350 | |||
351 | static ssize_t | ||
352 | read_rio(struct file *file, char __user *buffer, size_t count, loff_t * ppos) | ||
353 | { | ||
354 | DEFINE_WAIT(wait); | ||
355 | struct rio_usb_data *rio = &rio_instance; | ||
356 | ssize_t read_count; | ||
357 | unsigned int partial; | ||
358 | int this_read; | ||
359 | int result; | ||
360 | int maxretry = 10; | ||
361 | char *ibuf; | ||
362 | int intr; | ||
363 | |||
364 | intr = mutex_lock_interruptible(&rio500_mutex); | ||
365 | if (intr) | ||
366 | return -EINTR; | ||
367 | /* Sanity check to make sure rio is connected, powered, etc */ | ||
368 | if (rio->present == 0 || rio->rio_dev == NULL) { | ||
369 | mutex_unlock(&rio500_mutex); | ||
370 | return -ENODEV; | ||
371 | } | ||
372 | |||
373 | ibuf = rio->ibuf; | ||
374 | |||
375 | read_count = 0; | ||
376 | |||
377 | |||
378 | while (count > 0) { | ||
379 | if (signal_pending(current)) { | ||
380 | mutex_unlock(&rio500_mutex); | ||
381 | return read_count ? read_count : -EINTR; | ||
382 | } | ||
383 | if (!rio->rio_dev) { | ||
384 | mutex_unlock(&rio500_mutex); | ||
385 | return -ENODEV; | ||
386 | } | ||
387 | this_read = (count >= IBUF_SIZE) ? IBUF_SIZE : count; | ||
388 | |||
389 | result = usb_bulk_msg(rio->rio_dev, | ||
390 | usb_rcvbulkpipe(rio->rio_dev, 1), | ||
391 | ibuf, this_read, &partial, | ||
392 | 8000); | ||
393 | |||
394 | dev_dbg(&rio->rio_dev->dev, | ||
395 | "read stats: result:%d this_read:%u partial:%u\n", | ||
396 | result, this_read, partial); | ||
397 | |||
398 | if (partial) { | ||
399 | count = this_read = partial; | ||
400 | } else if (result == -ETIMEDOUT || result == 15) { /* FIXME: 15 ??? */ | ||
401 | if (!maxretry--) { | ||
402 | mutex_unlock(&rio500_mutex); | ||
403 | dev_err(&rio->rio_dev->dev, | ||
404 | "read_rio: maxretry timeout\n"); | ||
405 | return -ETIME; | ||
406 | } | ||
407 | prepare_to_wait(&rio->wait_q, &wait, TASK_INTERRUPTIBLE); | ||
408 | schedule_timeout(NAK_TIMEOUT); | ||
409 | finish_wait(&rio->wait_q, &wait); | ||
410 | continue; | ||
411 | } else if (result != -EREMOTEIO) { | ||
412 | mutex_unlock(&rio500_mutex); | ||
413 | dev_err(&rio->rio_dev->dev, | ||
414 | "Read Whoops - result:%d partial:%u this_read:%u\n", | ||
415 | result, partial, this_read); | ||
416 | return -EIO; | ||
417 | } else { | ||
418 | mutex_unlock(&rio500_mutex); | ||
419 | return (0); | ||
420 | } | ||
421 | |||
422 | if (this_read) { | ||
423 | if (copy_to_user(buffer, ibuf, this_read)) { | ||
424 | mutex_unlock(&rio500_mutex); | ||
425 | return -EFAULT; | ||
426 | } | ||
427 | count -= this_read; | ||
428 | read_count += this_read; | ||
429 | buffer += this_read; | ||
430 | } | ||
431 | } | ||
432 | mutex_unlock(&rio500_mutex); | ||
433 | return read_count; | ||
434 | } | ||
435 | |||
436 | static const struct file_operations usb_rio_fops = { | ||
437 | .owner = THIS_MODULE, | ||
438 | .read = read_rio, | ||
439 | .write = write_rio, | ||
440 | .unlocked_ioctl = ioctl_rio, | ||
441 | .open = open_rio, | ||
442 | .release = close_rio, | ||
443 | .llseek = noop_llseek, | ||
444 | }; | ||
445 | |||
446 | static struct usb_class_driver usb_rio_class = { | ||
447 | .name = "rio500%d", | ||
448 | .fops = &usb_rio_fops, | ||
449 | .minor_base = RIO_MINOR, | ||
450 | }; | ||
451 | |||
452 | static int probe_rio(struct usb_interface *intf, | ||
453 | const struct usb_device_id *id) | ||
454 | { | ||
455 | struct usb_device *dev = interface_to_usbdev(intf); | ||
456 | struct rio_usb_data *rio = &rio_instance; | ||
457 | int retval = -ENOMEM; | ||
458 | char *ibuf, *obuf; | ||
459 | |||
460 | if (rio->present) { | ||
461 | dev_info(&intf->dev, "Second USB Rio at address %d refused\n", dev->devnum); | ||
462 | return -EBUSY; | ||
463 | } | ||
464 | dev_info(&intf->dev, "USB Rio found at address %d\n", dev->devnum); | ||
465 | |||
466 | obuf = kmalloc(OBUF_SIZE, GFP_KERNEL); | ||
467 | if (!obuf) { | ||
468 | dev_err(&dev->dev, | ||
469 | "probe_rio: Not enough memory for the output buffer\n"); | ||
470 | goto err_obuf; | ||
471 | } | ||
472 | dev_dbg(&intf->dev, "obuf address: %p\n", obuf); | ||
473 | |||
474 | ibuf = kmalloc(IBUF_SIZE, GFP_KERNEL); | ||
475 | if (!ibuf) { | ||
476 | dev_err(&dev->dev, | ||
477 | "probe_rio: Not enough memory for the input buffer\n"); | ||
478 | goto err_ibuf; | ||
479 | } | ||
480 | dev_dbg(&intf->dev, "ibuf address: %p\n", ibuf); | ||
481 | |||
482 | mutex_lock(&rio500_mutex); | ||
483 | rio->rio_dev = dev; | ||
484 | rio->ibuf = ibuf; | ||
485 | rio->obuf = obuf; | ||
486 | rio->present = 1; | ||
487 | mutex_unlock(&rio500_mutex); | ||
488 | |||
489 | retval = usb_register_dev(intf, &usb_rio_class); | ||
490 | if (retval) { | ||
491 | dev_err(&dev->dev, | ||
492 | "Not able to get a minor for this device.\n"); | ||
493 | goto err_register; | ||
494 | } | ||
495 | |||
496 | usb_set_intfdata(intf, rio); | ||
497 | return retval; | ||
498 | |||
499 | err_register: | ||
500 | mutex_lock(&rio500_mutex); | ||
501 | rio->present = 0; | ||
502 | mutex_unlock(&rio500_mutex); | ||
503 | err_ibuf: | ||
504 | kfree(obuf); | ||
505 | err_obuf: | ||
506 | return retval; | ||
507 | } | ||
508 | |||
509 | static void disconnect_rio(struct usb_interface *intf) | ||
510 | { | ||
511 | struct rio_usb_data *rio = usb_get_intfdata (intf); | ||
512 | |||
513 | usb_set_intfdata (intf, NULL); | ||
514 | if (rio) { | ||
515 | usb_deregister_dev(intf, &usb_rio_class); | ||
516 | |||
517 | mutex_lock(&rio500_mutex); | ||
518 | if (rio->isopen) { | ||
519 | rio->isopen = 0; | ||
520 | /* better let it finish - the release will do whats needed */ | ||
521 | rio->rio_dev = NULL; | ||
522 | mutex_unlock(&rio500_mutex); | ||
523 | return; | ||
524 | } | ||
525 | kfree(rio->ibuf); | ||
526 | kfree(rio->obuf); | ||
527 | |||
528 | dev_info(&intf->dev, "USB Rio disconnected.\n"); | ||
529 | |||
530 | rio->present = 0; | ||
531 | mutex_unlock(&rio500_mutex); | ||
532 | } | ||
533 | } | ||
534 | |||
535 | static const struct usb_device_id rio_table[] = { | ||
536 | { USB_DEVICE(0x0841, 1) }, /* Rio 500 */ | ||
537 | { } /* Terminating entry */ | ||
538 | }; | ||
539 | |||
540 | MODULE_DEVICE_TABLE (usb, rio_table); | ||
541 | |||
542 | static struct usb_driver rio_driver = { | ||
543 | .name = "rio500", | ||
544 | .probe = probe_rio, | ||
545 | .disconnect = disconnect_rio, | ||
546 | .id_table = rio_table, | ||
547 | }; | ||
548 | |||
549 | module_usb_driver(rio_driver); | ||
550 | |||
551 | MODULE_AUTHOR( DRIVER_AUTHOR ); | ||
552 | MODULE_DESCRIPTION( DRIVER_DESC ); | ||
553 | MODULE_LICENSE("GPL"); | ||
554 | |||
diff --git a/drivers/usb/misc/rio500_usb.h b/drivers/usb/misc/rio500_usb.h deleted file mode 100644 index 6db7a5863496..000000000000 --- a/drivers/usb/misc/rio500_usb.h +++ /dev/null | |||
@@ -1,20 +0,0 @@ | |||
1 | // SPDX-License-Identifier: GPL-2.0+ | ||
2 | /* ---------------------------------------------------------------------- | ||
3 | Copyright (C) 2000 Cesar Miquel (miquel@df.uba.ar) | ||
4 | ---------------------------------------------------------------------- */ | ||
5 | |||
6 | #define RIO_SEND_COMMAND 0x1 | ||
7 | #define RIO_RECV_COMMAND 0x2 | ||
8 | |||
9 | #define RIO_DIR_OUT 0x0 | ||
10 | #define RIO_DIR_IN 0x1 | ||
11 | |||
12 | struct RioCommand { | ||
13 | short length; | ||
14 | int request; | ||
15 | int requesttype; | ||
16 | int value; | ||
17 | int index; | ||
18 | void __user *buffer; | ||
19 | int timeout; | ||
20 | }; | ||