diff options
author | Len Brown <len.brown@intel.com> | 2005-12-06 17:31:30 -0500 |
---|---|---|
committer | Len Brown <len.brown@intel.com> | 2005-12-06 17:31:30 -0500 |
commit | 3d5271f9883cba7b54762bc4fe027d4172f06db7 (patch) | |
tree | ab8a881a14478598a0c8bda0d26c62cdccfffd6d /drivers/usb | |
parent | 378b2556f4e09fa6f87ff0cb5c4395ff28257d02 (diff) | |
parent | 9115a6c787596e687df03010d97fccc5e0762506 (diff) |
Pull release into acpica branch
Diffstat (limited to 'drivers/usb')
186 files changed, 5969 insertions, 6071 deletions
diff --git a/drivers/usb/Makefile b/drivers/usb/Makefile index df014c2a7c54..a50c2bc506f2 100644 --- a/drivers/usb/Makefile +++ b/drivers/usb/Makefile | |||
@@ -8,6 +8,7 @@ obj-$(CONFIG_USB) += core/ | |||
8 | 8 | ||
9 | obj-$(CONFIG_USB_MON) += mon/ | 9 | obj-$(CONFIG_USB_MON) += mon/ |
10 | 10 | ||
11 | obj-$(CONFIG_PCI) += host/ | ||
11 | obj-$(CONFIG_USB_EHCI_HCD) += host/ | 12 | obj-$(CONFIG_USB_EHCI_HCD) += host/ |
12 | obj-$(CONFIG_USB_ISP116X_HCD) += host/ | 13 | obj-$(CONFIG_USB_ISP116X_HCD) += host/ |
13 | obj-$(CONFIG_USB_OHCI_HCD) += host/ | 14 | obj-$(CONFIG_USB_OHCI_HCD) += host/ |
@@ -17,7 +18,6 @@ obj-$(CONFIG_ETRAX_USB_HOST) += host/ | |||
17 | 18 | ||
18 | obj-$(CONFIG_USB_ACM) += class/ | 19 | obj-$(CONFIG_USB_ACM) += class/ |
19 | obj-$(CONFIG_USB_AUDIO) += class/ | 20 | obj-$(CONFIG_USB_AUDIO) += class/ |
20 | obj-$(CONFIG_USB_BLUETOOTH_TTY) += class/ | ||
21 | obj-$(CONFIG_USB_MIDI) += class/ | 21 | obj-$(CONFIG_USB_MIDI) += class/ |
22 | obj-$(CONFIG_USB_PRINTER) += class/ | 22 | obj-$(CONFIG_USB_PRINTER) += class/ |
23 | 23 | ||
diff --git a/drivers/usb/atm/Makefile b/drivers/usb/atm/Makefile index 751f297be2ef..85099718c683 100644 --- a/drivers/usb/atm/Makefile +++ b/drivers/usb/atm/Makefile | |||
@@ -6,3 +6,7 @@ obj-$(CONFIG_USB_CXACRU) += cxacru.o | |||
6 | obj-$(CONFIG_USB_SPEEDTOUCH) += speedtch.o | 6 | obj-$(CONFIG_USB_SPEEDTOUCH) += speedtch.o |
7 | obj-$(CONFIG_USB_ATM) += usbatm.o | 7 | obj-$(CONFIG_USB_ATM) += usbatm.o |
8 | obj-$(CONFIG_USB_XUSBATM) += xusbatm.o | 8 | obj-$(CONFIG_USB_XUSBATM) += xusbatm.o |
9 | |||
10 | ifeq ($(CONFIG_USB_DEBUG),y) | ||
11 | EXTRA_CFLAGS += -DDEBUG | ||
12 | endif | ||
diff --git a/drivers/usb/atm/cxacru.c b/drivers/usb/atm/cxacru.c index 79861ee12a29..9d59dc62e6d2 100644 --- a/drivers/usb/atm/cxacru.c +++ b/drivers/usb/atm/cxacru.c | |||
@@ -787,6 +787,9 @@ static const struct usb_device_id cxacru_usb_ids[] = { | |||
787 | { /* V = Conexant P = ADSL modem (Hasbani project) */ | 787 | { /* V = Conexant P = ADSL modem (Hasbani project) */ |
788 | USB_DEVICE(0x0572, 0xcb00), .driver_info = (unsigned long) &cxacru_cb00 | 788 | USB_DEVICE(0x0572, 0xcb00), .driver_info = (unsigned long) &cxacru_cb00 |
789 | }, | 789 | }, |
790 | { /* V = Conexant P = ADSL modem (Well PTI-800 */ | ||
791 | USB_DEVICE(0x0572, 0xcb02), .driver_info = (unsigned long) &cxacru_cb00 | ||
792 | }, | ||
790 | { /* V = Conexant P = ADSL modem */ | 793 | { /* V = Conexant P = ADSL modem */ |
791 | USB_DEVICE(0x0572, 0xcb01), .driver_info = (unsigned long) &cxacru_cb00 | 794 | USB_DEVICE(0x0572, 0xcb01), .driver_info = (unsigned long) &cxacru_cb00 |
792 | }, | 795 | }, |
diff --git a/drivers/usb/atm/usbatm.c b/drivers/usb/atm/usbatm.c index c466739428b2..2e6593e6c1bd 100644 --- a/drivers/usb/atm/usbatm.c +++ b/drivers/usb/atm/usbatm.c | |||
@@ -879,7 +879,7 @@ static int usbatm_atm_init(struct usbatm_data *instance) | |||
879 | 879 | ||
880 | fail: | 880 | fail: |
881 | instance->atm_dev = NULL; | 881 | instance->atm_dev = NULL; |
882 | shutdown_atm_dev(atm_dev); /* usbatm_atm_dev_close will eventually be called */ | 882 | atm_dev_deregister(atm_dev); /* usbatm_atm_dev_close will eventually be called */ |
883 | return ret; | 883 | return ret; |
884 | } | 884 | } |
885 | 885 | ||
@@ -1164,7 +1164,7 @@ void usbatm_usb_disconnect(struct usb_interface *intf) | |||
1164 | 1164 | ||
1165 | /* ATM finalize */ | 1165 | /* ATM finalize */ |
1166 | if (instance->atm_dev) | 1166 | if (instance->atm_dev) |
1167 | shutdown_atm_dev(instance->atm_dev); | 1167 | atm_dev_deregister(instance->atm_dev); |
1168 | 1168 | ||
1169 | usbatm_put_instance(instance); /* taken in usbatm_usb_probe */ | 1169 | usbatm_put_instance(instance); /* taken in usbatm_usb_probe */ |
1170 | } | 1170 | } |
diff --git a/drivers/usb/atm/usbatm.h b/drivers/usb/atm/usbatm.h index 936646457935..1adacd60d713 100644 --- a/drivers/usb/atm/usbatm.h +++ b/drivers/usb/atm/usbatm.h | |||
@@ -27,14 +27,9 @@ | |||
27 | #include <linux/config.h> | 27 | #include <linux/config.h> |
28 | 28 | ||
29 | /* | 29 | /* |
30 | #define DEBUG | ||
31 | #define VERBOSE_DEBUG | 30 | #define VERBOSE_DEBUG |
32 | */ | 31 | */ |
33 | 32 | ||
34 | #if !defined (DEBUG) && defined (CONFIG_USB_DEBUG) | ||
35 | # define DEBUG | ||
36 | #endif | ||
37 | |||
38 | #include <asm/semaphore.h> | 33 | #include <asm/semaphore.h> |
39 | #include <linux/atm.h> | 34 | #include <linux/atm.h> |
40 | #include <linux/atmdev.h> | 35 | #include <linux/atmdev.h> |
diff --git a/drivers/usb/class/Kconfig b/drivers/usb/class/Kconfig index 333e39bb105f..ef105a92a7bd 100644 --- a/drivers/usb/class/Kconfig +++ b/drivers/usb/class/Kconfig | |||
@@ -28,29 +28,6 @@ config USB_AUDIO | |||
28 | To compile this driver as a module, choose M here: the | 28 | To compile this driver as a module, choose M here: the |
29 | module will be called audio. | 29 | module will be called audio. |
30 | 30 | ||
31 | comment "USB Bluetooth TTY can only be used with disabled Bluetooth subsystem" | ||
32 | depends on USB && BT | ||
33 | |||
34 | config USB_BLUETOOTH_TTY | ||
35 | tristate "USB Bluetooth TTY support" | ||
36 | depends on USB && BT=n | ||
37 | ---help--- | ||
38 | This driver implements a nonstandard tty interface to a Bluetooth | ||
39 | device that can be used only by specialized Bluetooth HCI software. | ||
40 | |||
41 | Say Y here if you want to use OpenBT Bluetooth stack (available | ||
42 | at <http://developer.axis.com/software>), or other TTY based | ||
43 | Bluetooth stacks, and want to connect a USB Bluetooth device | ||
44 | to your computer's USB port. | ||
45 | |||
46 | Do *not* enable this driver if you want to use generic Linux | ||
47 | Bluetooth support. | ||
48 | |||
49 | If in doubt, say N here. | ||
50 | |||
51 | To compile this driver as a module, choose M here: the | ||
52 | module will be called bluetty. | ||
53 | |||
54 | config USB_MIDI | 31 | config USB_MIDI |
55 | tristate "USB MIDI support" | 32 | tristate "USB MIDI support" |
56 | depends on USB && SOUND && OBSOLETE_OSS_USB_DRIVER | 33 | depends on USB && SOUND && OBSOLETE_OSS_USB_DRIVER |
diff --git a/drivers/usb/class/Makefile b/drivers/usb/class/Makefile index 971e5497a3fd..229471247751 100644 --- a/drivers/usb/class/Makefile +++ b/drivers/usb/class/Makefile | |||
@@ -5,6 +5,5 @@ | |||
5 | 5 | ||
6 | obj-$(CONFIG_USB_ACM) += cdc-acm.o | 6 | obj-$(CONFIG_USB_ACM) += cdc-acm.o |
7 | obj-$(CONFIG_USB_AUDIO) += audio.o | 7 | obj-$(CONFIG_USB_AUDIO) += audio.o |
8 | obj-$(CONFIG_USB_BLUETOOTH_TTY) += bluetty.o | ||
9 | obj-$(CONFIG_USB_MIDI) += usb-midi.o | 8 | obj-$(CONFIG_USB_MIDI) += usb-midi.o |
10 | obj-$(CONFIG_USB_PRINTER) += usblp.o | 9 | obj-$(CONFIG_USB_PRINTER) += usblp.o |
diff --git a/drivers/usb/class/bluetty.c b/drivers/usb/class/bluetty.c deleted file mode 100644 index 524023327c49..000000000000 --- a/drivers/usb/class/bluetty.c +++ /dev/null | |||
@@ -1,1279 +0,0 @@ | |||
1 | /* | ||
2 | * bluetty.c Version 0.13 | ||
3 | * | ||
4 | * Copyright (C) 2000, 2001 Greg Kroah-Hartman <greg@kroah.com> | ||
5 | * Copyright (C) 2000 Mark Douglas Corner <mcorner@umich.edu> | ||
6 | * | ||
7 | * USB Bluetooth TTY driver, based on the Bluetooth Spec version 1.0B | ||
8 | * | ||
9 | * (2001/11/30) Version 0.13 gkh | ||
10 | * - added locking patch from Masoodur Rahman <rmasoodu@in.ibm.com> | ||
11 | * - removed active variable, as open_count will do. | ||
12 | * | ||
13 | * (2001/07/09) Version 0.12 gkh | ||
14 | * - removed in_interrupt() call, as it doesn't make sense to do | ||
15 | * that anymore. | ||
16 | * | ||
17 | * (2001/06/05) Version 0.11 gkh | ||
18 | * - Fixed problem with read urb status saying that we have shutdown, | ||
19 | * and that we shouldn't resubmit the urb. Patch from unknown. | ||
20 | * | ||
21 | * (2001/05/28) Version 0.10 gkh | ||
22 | * - Fixed problem with using data from userspace in the bluetooth_write | ||
23 | * function as found by the CHECKER project. | ||
24 | * - Added a buffer to the write_urb_pool which reduces the number of | ||
25 | * buffers being created and destroyed for ever write. Also cleans | ||
26 | * up the logic a bit. | ||
27 | * - Added a buffer to the control_urb_pool which fixes a memory leak | ||
28 | * when the device is removed from the system. | ||
29 | * | ||
30 | * (2001/05/28) Version 0.9 gkh | ||
31 | * Fixed problem with bluetooth==NULL for bluetooth_read_bulk_callback | ||
32 | * which was found by both the CHECKER project and Mikko Rahkonen. | ||
33 | * | ||
34 | * (08/04/2001) gb | ||
35 | * Identify version on module load. | ||
36 | * | ||
37 | * (2001/03/10) Version 0.8 gkh | ||
38 | * Fixed problem with not unlinking interrupt urb on device close | ||
39 | * and resubmitting the read urb on error with bluetooth struct. | ||
40 | * Thanks to Narayan Mohanram <narayan@RovingNetworks.com> for the | ||
41 | * fixes. | ||
42 | * | ||
43 | * (11/29/2000) Version 0.7 gkh | ||
44 | * Fixed problem with overrunning the tty flip buffer. | ||
45 | * Removed unneeded NULL pointer initialization. | ||
46 | * | ||
47 | * (10/05/2000) Version 0.6 gkh | ||
48 | * Fixed bug with urb->dev not being set properly, now that the usb | ||
49 | * core needs it. | ||
50 | * Got a real major id number and name. | ||
51 | * | ||
52 | * (08/06/2000) Version 0.5 gkh | ||
53 | * Fixed problem of not resubmitting the bulk read urb if there is | ||
54 | * an error in the callback. Ericsson devices seem to need this. | ||
55 | * | ||
56 | * (07/11/2000) Version 0.4 gkh | ||
57 | * Fixed bug in disconnect for when we call tty_hangup | ||
58 | * Fixed bug in bluetooth_ctrl_msg where the bluetooth struct was not | ||
59 | * getting attached to the control urb properly. | ||
60 | * Fixed bug in bluetooth_write where we pay attention to the result | ||
61 | * of bluetooth_ctrl_msg. | ||
62 | * | ||
63 | * (08/03/2000) Version 0.3 gkh mdc | ||
64 | * Merged in Mark's changes to make the driver play nice with the Axis | ||
65 | * stack. | ||
66 | * Made the write bulk use an urb pool to enable larger transfers with | ||
67 | * fewer calls to the driver. | ||
68 | * Fixed off by one bug in acl pkt receive | ||
69 | * Made packet counters specific to each bluetooth device | ||
70 | * Added checks for zero length callbacks | ||
71 | * Added buffers for int and bulk packets. Had to do this otherwise | ||
72 | * packet types could intermingle. | ||
73 | * Made a control urb pool for the control messages. | ||
74 | * | ||
75 | * (07/11/2000) Version 0.2 gkh | ||
76 | * Fixed a small bug found by Nils Faerber in the usb_bluetooth_probe | ||
77 | * function. | ||
78 | * | ||
79 | * (07/09/2000) Version 0.1 gkh | ||
80 | * Initial release. Has support for sending ACL data (which is really just | ||
81 | * a HCI frame.) Raw HCI commands and HCI events are not supported. | ||
82 | * A ioctl will probably be needed for the HCI commands and events in the | ||
83 | * future. All isoch endpoints are ignored at this time also. | ||
84 | * This driver should work for all currently shipping USB Bluetooth | ||
85 | * devices at this time :) | ||
86 | * | ||
87 | */ | ||
88 | |||
89 | /* | ||
90 | * This program is free software; you can redistribute it and/or modify | ||
91 | * it under the terms of the GNU General Public License as published by | ||
92 | * the Free Software Foundation; either version 2 of the License, or | ||
93 | * (at your option) any later version. | ||
94 | * | ||
95 | * This program is distributed in the hope that it will be useful, | ||
96 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
97 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
98 | * GNU General Public License for more details. | ||
99 | * | ||
100 | * You should have received a copy of the GNU General Public License | ||
101 | * along with this program; if not, write to the Free Software | ||
102 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | ||
103 | */ | ||
104 | |||
105 | |||
106 | #include <linux/kernel.h> | ||
107 | #include <linux/errno.h> | ||
108 | #include <linux/init.h> | ||
109 | #include <linux/slab.h> | ||
110 | #include <linux/tty.h> | ||
111 | #include <linux/tty_driver.h> | ||
112 | #include <linux/tty_flip.h> | ||
113 | #include <linux/module.h> | ||
114 | #include <asm/uaccess.h> | ||
115 | |||
116 | #define DEBUG | ||
117 | #include <linux/usb.h> | ||
118 | |||
119 | /* | ||
120 | * Version Information | ||
121 | */ | ||
122 | #define DRIVER_VERSION "v0.13" | ||
123 | #define DRIVER_AUTHOR "Greg Kroah-Hartman, Mark Douglas Corner" | ||
124 | #define DRIVER_DESC "USB Bluetooth tty driver" | ||
125 | |||
126 | /* define this if you have hardware that is not good */ | ||
127 | /*#define BTBUGGYHARDWARE */ | ||
128 | |||
129 | /* Class, SubClass, and Protocol codes that describe a Bluetooth device */ | ||
130 | #define WIRELESS_CLASS_CODE 0xe0 | ||
131 | #define RF_SUBCLASS_CODE 0x01 | ||
132 | #define BLUETOOTH_PROGRAMMING_PROTOCOL_CODE 0x01 | ||
133 | |||
134 | |||
135 | #define BLUETOOTH_TTY_MAJOR 216 /* real device node major id */ | ||
136 | #define BLUETOOTH_TTY_MINORS 256 /* whole lotta bluetooth devices */ | ||
137 | |||
138 | #define USB_BLUETOOTH_MAGIC 0x6d02 /* magic number for bluetooth struct */ | ||
139 | |||
140 | #define BLUETOOTH_CONTROL_REQUEST_TYPE 0x20 | ||
141 | |||
142 | /* Bluetooth packet types */ | ||
143 | #define CMD_PKT 0x01 | ||
144 | #define ACL_PKT 0x02 | ||
145 | #define SCO_PKT 0x03 | ||
146 | #define EVENT_PKT 0x04 | ||
147 | #define ERROR_PKT 0x05 | ||
148 | #define NEG_PKT 0x06 | ||
149 | |||
150 | /* Message sizes */ | ||
151 | #define MAX_EVENT_SIZE 0xFF | ||
152 | #define EVENT_HDR_SIZE 3 /* 2 for the header + 1 for the type indicator */ | ||
153 | #define EVENT_BUFFER_SIZE (MAX_EVENT_SIZE + EVENT_HDR_SIZE) | ||
154 | |||
155 | #define MAX_ACL_SIZE 0xFFFF | ||
156 | #define ACL_HDR_SIZE 5 /* 4 for the header + 1 for the type indicator */ | ||
157 | #define ACL_BUFFER_SIZE (MAX_ACL_SIZE + ACL_HDR_SIZE) | ||
158 | |||
159 | /* parity check flag */ | ||
160 | #define RELEVANT_IFLAG(iflag) (iflag & (IGNBRK|BRKINT|IGNPAR|PARMRK|INPCK)) | ||
161 | |||
162 | #define CHAR2INT16(c1,c0) (((u32)((c1) & 0xff) << 8) + (u32)((c0) & 0xff)) | ||
163 | |||
164 | #define NUM_BULK_URBS 24 | ||
165 | #define NUM_CONTROL_URBS 16 | ||
166 | |||
167 | struct usb_bluetooth { | ||
168 | int magic; | ||
169 | struct usb_device * dev; | ||
170 | struct tty_driver * tty_driver; /* the tty_driver for this device */ | ||
171 | struct tty_struct * tty; /* the corresponding tty for this port */ | ||
172 | |||
173 | unsigned char minor; /* the starting minor number for this device */ | ||
174 | int throttle; /* throttled by tty layer */ | ||
175 | int open_count; | ||
176 | |||
177 | __u8 control_out_bInterfaceNum; | ||
178 | struct urb * control_urb_pool[NUM_CONTROL_URBS]; | ||
179 | struct usb_ctrlrequest dr[NUM_CONTROL_URBS]; | ||
180 | |||
181 | unsigned char * interrupt_in_buffer; | ||
182 | struct urb * interrupt_in_urb; | ||
183 | __u8 interrupt_in_endpointAddress; | ||
184 | __u8 interrupt_in_interval; | ||
185 | int interrupt_in_buffer_size; | ||
186 | |||
187 | unsigned char * bulk_in_buffer; | ||
188 | struct urb * read_urb; | ||
189 | __u8 bulk_in_endpointAddress; | ||
190 | int bulk_in_buffer_size; | ||
191 | |||
192 | int bulk_out_buffer_size; | ||
193 | __u8 bulk_out_endpointAddress; | ||
194 | |||
195 | wait_queue_head_t write_wait; | ||
196 | |||
197 | struct work_struct work; /* work queue entry for line discipline waking up */ | ||
198 | |||
199 | unsigned int int_packet_pos; | ||
200 | unsigned char int_buffer[EVENT_BUFFER_SIZE]; | ||
201 | unsigned int bulk_packet_pos; | ||
202 | unsigned char bulk_buffer[ACL_BUFFER_SIZE]; /* 64k preallocated, fix? */ | ||
203 | struct semaphore lock; | ||
204 | }; | ||
205 | |||
206 | |||
207 | /* local function prototypes */ | ||
208 | static int bluetooth_open (struct tty_struct *tty, struct file *filp); | ||
209 | static void bluetooth_close (struct tty_struct *tty, struct file *filp); | ||
210 | static int bluetooth_write (struct tty_struct *tty, const unsigned char *buf, int count); | ||
211 | static int bluetooth_write_room (struct tty_struct *tty); | ||
212 | static int bluetooth_chars_in_buffer (struct tty_struct *tty); | ||
213 | static void bluetooth_throttle (struct tty_struct *tty); | ||
214 | static void bluetooth_unthrottle (struct tty_struct *tty); | ||
215 | static int bluetooth_ioctl (struct tty_struct *tty, struct file *file, unsigned int cmd, unsigned long arg); | ||
216 | static void bluetooth_set_termios (struct tty_struct *tty, struct termios *old); | ||
217 | |||
218 | static void bluetooth_int_callback (struct urb *urb, struct pt_regs *regs); | ||
219 | static void bluetooth_ctrl_callback (struct urb *urb, struct pt_regs *regs); | ||
220 | static void bluetooth_read_bulk_callback (struct urb *urb, struct pt_regs *regs); | ||
221 | static void bluetooth_write_bulk_callback (struct urb *urb, struct pt_regs *regs); | ||
222 | |||
223 | static int usb_bluetooth_probe (struct usb_interface *intf, | ||
224 | const struct usb_device_id *id); | ||
225 | static void usb_bluetooth_disconnect (struct usb_interface *intf); | ||
226 | |||
227 | |||
228 | static struct usb_device_id usb_bluetooth_ids [] = { | ||
229 | { USB_DEVICE_INFO(WIRELESS_CLASS_CODE, RF_SUBCLASS_CODE, BLUETOOTH_PROGRAMMING_PROTOCOL_CODE) }, | ||
230 | { } /* Terminating entry */ | ||
231 | }; | ||
232 | |||
233 | MODULE_DEVICE_TABLE (usb, usb_bluetooth_ids); | ||
234 | |||
235 | static struct usb_driver usb_bluetooth_driver = { | ||
236 | .owner = THIS_MODULE, | ||
237 | .name = "bluetty", | ||
238 | .probe = usb_bluetooth_probe, | ||
239 | .disconnect = usb_bluetooth_disconnect, | ||
240 | .id_table = usb_bluetooth_ids, | ||
241 | }; | ||
242 | |||
243 | static struct tty_driver *bluetooth_tty_driver; | ||
244 | static struct usb_bluetooth *bluetooth_table[BLUETOOTH_TTY_MINORS]; | ||
245 | |||
246 | |||
247 | static inline int bluetooth_paranoia_check (struct usb_bluetooth *bluetooth, const char *function) | ||
248 | { | ||
249 | if (!bluetooth) { | ||
250 | dbg("%s - bluetooth == NULL", function); | ||
251 | return -1; | ||
252 | } | ||
253 | if (bluetooth->magic != USB_BLUETOOTH_MAGIC) { | ||
254 | dbg("%s - bad magic number for bluetooth", function); | ||
255 | return -1; | ||
256 | } | ||
257 | |||
258 | return 0; | ||
259 | } | ||
260 | |||
261 | |||
262 | static inline struct usb_bluetooth* get_usb_bluetooth (struct usb_bluetooth *bluetooth, const char *function) | ||
263 | { | ||
264 | if (!bluetooth || | ||
265 | bluetooth_paranoia_check (bluetooth, function)) { | ||
266 | /* then say that we don't have a valid usb_bluetooth thing, which will | ||
267 | * end up generating -ENODEV return values */ | ||
268 | return NULL; | ||
269 | } | ||
270 | |||
271 | return bluetooth; | ||
272 | } | ||
273 | |||
274 | |||
275 | static inline struct usb_bluetooth *get_bluetooth_by_index (int index) | ||
276 | { | ||
277 | return bluetooth_table[index]; | ||
278 | } | ||
279 | |||
280 | |||
281 | static int bluetooth_ctrl_msg (struct usb_bluetooth *bluetooth, int request, int value, const unsigned char *buf, int len) | ||
282 | { | ||
283 | struct urb *urb = NULL; | ||
284 | struct usb_ctrlrequest *dr = NULL; | ||
285 | int i; | ||
286 | int status; | ||
287 | |||
288 | dbg ("%s", __FUNCTION__); | ||
289 | |||
290 | /* try to find a free urb in our list */ | ||
291 | for (i = 0; i < NUM_CONTROL_URBS; ++i) { | ||
292 | if (bluetooth->control_urb_pool[i]->status != -EINPROGRESS) { | ||
293 | urb = bluetooth->control_urb_pool[i]; | ||
294 | dr = &bluetooth->dr[i]; | ||
295 | break; | ||
296 | } | ||
297 | } | ||
298 | if (urb == NULL) { | ||
299 | dbg ("%s - no free urbs", __FUNCTION__); | ||
300 | return -ENOMEM; | ||
301 | } | ||
302 | |||
303 | /* keep increasing the urb transfer buffer to fit the size of the message */ | ||
304 | if (urb->transfer_buffer == NULL) { | ||
305 | urb->transfer_buffer = kmalloc (len, GFP_KERNEL); | ||
306 | if (urb->transfer_buffer == NULL) { | ||
307 | err ("%s - out of memory", __FUNCTION__); | ||
308 | return -ENOMEM; | ||
309 | } | ||
310 | } | ||
311 | if (urb->transfer_buffer_length < len) { | ||
312 | kfree(urb->transfer_buffer); | ||
313 | urb->transfer_buffer = kmalloc (len, GFP_KERNEL); | ||
314 | if (urb->transfer_buffer == NULL) { | ||
315 | err ("%s - out of memory", __FUNCTION__); | ||
316 | return -ENOMEM; | ||
317 | } | ||
318 | } | ||
319 | memcpy (urb->transfer_buffer, buf, len); | ||
320 | |||
321 | dr->bRequestType= BLUETOOTH_CONTROL_REQUEST_TYPE; | ||
322 | dr->bRequest = request; | ||
323 | dr->wValue = cpu_to_le16((u16) value); | ||
324 | dr->wIndex = cpu_to_le16((u16) bluetooth->control_out_bInterfaceNum); | ||
325 | dr->wLength = cpu_to_le16((u16) len); | ||
326 | |||
327 | usb_fill_control_urb (urb, bluetooth->dev, usb_sndctrlpipe(bluetooth->dev, 0), | ||
328 | (unsigned char*)dr, urb->transfer_buffer, len, bluetooth_ctrl_callback, bluetooth); | ||
329 | |||
330 | /* send it down the pipe */ | ||
331 | status = usb_submit_urb(urb, GFP_KERNEL); | ||
332 | if (status) | ||
333 | dbg("%s - usb_submit_urb(control) failed with status = %d", __FUNCTION__, status); | ||
334 | |||
335 | return status; | ||
336 | } | ||
337 | |||
338 | |||
339 | |||
340 | |||
341 | |||
342 | /***************************************************************************** | ||
343 | * Driver tty interface functions | ||
344 | *****************************************************************************/ | ||
345 | static int bluetooth_open (struct tty_struct *tty, struct file * filp) | ||
346 | { | ||
347 | struct usb_bluetooth *bluetooth; | ||
348 | int result; | ||
349 | |||
350 | dbg("%s", __FUNCTION__); | ||
351 | |||
352 | /* initialize the pointer incase something fails */ | ||
353 | tty->driver_data = NULL; | ||
354 | |||
355 | /* get the bluetooth object associated with this tty pointer */ | ||
356 | bluetooth = get_bluetooth_by_index (tty->index); | ||
357 | |||
358 | if (bluetooth_paranoia_check (bluetooth, __FUNCTION__)) { | ||
359 | return -ENODEV; | ||
360 | } | ||
361 | |||
362 | down (&bluetooth->lock); | ||
363 | |||
364 | ++bluetooth->open_count; | ||
365 | if (bluetooth->open_count == 1) { | ||
366 | /* set up our structure making the tty driver remember our object, and us it */ | ||
367 | tty->driver_data = bluetooth; | ||
368 | bluetooth->tty = tty; | ||
369 | |||
370 | /* force low_latency on so that our tty_push actually forces the data through, | ||
371 | * otherwise it is scheduled, and with high data rates (like with OHCI) data | ||
372 | * can get lost. */ | ||
373 | bluetooth->tty->low_latency = 1; | ||
374 | |||
375 | /* Reset the packet position counters */ | ||
376 | bluetooth->int_packet_pos = 0; | ||
377 | bluetooth->bulk_packet_pos = 0; | ||
378 | |||
379 | #ifndef BTBUGGYHARDWARE | ||
380 | /* Start reading from the device */ | ||
381 | usb_fill_bulk_urb (bluetooth->read_urb, bluetooth->dev, | ||
382 | usb_rcvbulkpipe(bluetooth->dev, bluetooth->bulk_in_endpointAddress), | ||
383 | bluetooth->bulk_in_buffer, | ||
384 | bluetooth->bulk_in_buffer_size, | ||
385 | bluetooth_read_bulk_callback, bluetooth); | ||
386 | result = usb_submit_urb(bluetooth->read_urb, GFP_KERNEL); | ||
387 | if (result) | ||
388 | dbg("%s - usb_submit_urb(read bulk) failed with status %d", __FUNCTION__, result); | ||
389 | #endif | ||
390 | usb_fill_int_urb (bluetooth->interrupt_in_urb, bluetooth->dev, | ||
391 | usb_rcvintpipe(bluetooth->dev, bluetooth->interrupt_in_endpointAddress), | ||
392 | bluetooth->interrupt_in_buffer, | ||
393 | bluetooth->interrupt_in_buffer_size, | ||
394 | bluetooth_int_callback, bluetooth, | ||
395 | bluetooth->interrupt_in_interval); | ||
396 | result = usb_submit_urb(bluetooth->interrupt_in_urb, GFP_KERNEL); | ||
397 | if (result) | ||
398 | dbg("%s - usb_submit_urb(interrupt in) failed with status %d", __FUNCTION__, result); | ||
399 | } | ||
400 | |||
401 | up(&bluetooth->lock); | ||
402 | |||
403 | return 0; | ||
404 | } | ||
405 | |||
406 | |||
407 | static void bluetooth_close (struct tty_struct *tty, struct file * filp) | ||
408 | { | ||
409 | struct usb_bluetooth *bluetooth = get_usb_bluetooth ((struct usb_bluetooth *)tty->driver_data, __FUNCTION__); | ||
410 | |||
411 | if (!bluetooth) { | ||
412 | return; | ||
413 | } | ||
414 | |||
415 | dbg("%s", __FUNCTION__); | ||
416 | |||
417 | if (!bluetooth->open_count) { | ||
418 | dbg ("%s - device not opened", __FUNCTION__); | ||
419 | return; | ||
420 | } | ||
421 | |||
422 | down (&bluetooth->lock); | ||
423 | |||
424 | --bluetooth->open_count; | ||
425 | if (bluetooth->open_count <= 0) { | ||
426 | bluetooth->open_count = 0; | ||
427 | |||
428 | /* shutdown any in-flight urbs that we know about */ | ||
429 | usb_kill_urb (bluetooth->read_urb); | ||
430 | usb_kill_urb (bluetooth->interrupt_in_urb); | ||
431 | } | ||
432 | up(&bluetooth->lock); | ||
433 | } | ||
434 | |||
435 | |||
436 | static int bluetooth_write (struct tty_struct * tty, const unsigned char *buf, int count) | ||
437 | { | ||
438 | struct usb_bluetooth *bluetooth = get_usb_bluetooth ((struct usb_bluetooth *)tty->driver_data, __FUNCTION__); | ||
439 | struct urb *urb = NULL; | ||
440 | unsigned char *temp_buffer = NULL; | ||
441 | const unsigned char *current_buffer; | ||
442 | unsigned char *urb_buffer; | ||
443 | int i; | ||
444 | int retval = 0; | ||
445 | |||
446 | if (!bluetooth) { | ||
447 | return -ENODEV; | ||
448 | } | ||
449 | |||
450 | dbg("%s - %d byte(s)", __FUNCTION__, count); | ||
451 | |||
452 | if (!bluetooth->open_count) { | ||
453 | dbg ("%s - device not opened", __FUNCTION__); | ||
454 | return -EINVAL; | ||
455 | } | ||
456 | |||
457 | if (count == 0) { | ||
458 | dbg("%s - write request of 0 bytes", __FUNCTION__); | ||
459 | return 0; | ||
460 | } | ||
461 | if (count == 1) { | ||
462 | dbg("%s - write request only included type %d", __FUNCTION__, buf[0]); | ||
463 | return 1; | ||
464 | } | ||
465 | |||
466 | #ifdef DEBUG | ||
467 | printk (KERN_DEBUG __FILE__ ": %s - length = %d, data = ", __FUNCTION__, count); | ||
468 | for (i = 0; i < count; ++i) { | ||
469 | printk ("%.2x ", buf[i]); | ||
470 | } | ||
471 | printk ("\n"); | ||
472 | #endif | ||
473 | |||
474 | current_buffer = buf; | ||
475 | |||
476 | switch (*current_buffer) { | ||
477 | /* First byte indicates the type of packet */ | ||
478 | case CMD_PKT: | ||
479 | /* dbg("%s- Send cmd_pkt len:%d", __FUNCTION__, count);*/ | ||
480 | |||
481 | retval = bluetooth_ctrl_msg (bluetooth, 0x00, 0x00, ¤t_buffer[1], count-1); | ||
482 | if (retval) { | ||
483 | goto exit; | ||
484 | } | ||
485 | retval = count; | ||
486 | break; | ||
487 | |||
488 | case ACL_PKT: | ||
489 | ++current_buffer; | ||
490 | --count; | ||
491 | |||
492 | urb_buffer = kmalloc (count, GFP_ATOMIC); | ||
493 | if (!urb_buffer) { | ||
494 | dev_err(&bluetooth->dev->dev, "out of memory\n"); | ||
495 | retval = -ENOMEM; | ||
496 | goto exit; | ||
497 | } | ||
498 | |||
499 | urb = usb_alloc_urb(0, GFP_ATOMIC); | ||
500 | if (!urb) { | ||
501 | dev_err(&bluetooth->dev->dev, "no more free urbs\n"); | ||
502 | kfree(urb_buffer); | ||
503 | retval = -ENOMEM; | ||
504 | goto exit; | ||
505 | } | ||
506 | memcpy (urb_buffer, current_buffer, count); | ||
507 | |||
508 | /* build up our urb */ | ||
509 | usb_fill_bulk_urb(urb, bluetooth->dev, | ||
510 | usb_sndbulkpipe(bluetooth->dev, | ||
511 | bluetooth->bulk_out_endpointAddress), | ||
512 | urb_buffer, | ||
513 | count, | ||
514 | bluetooth_write_bulk_callback, | ||
515 | bluetooth); | ||
516 | |||
517 | |||
518 | /* send it down the pipe */ | ||
519 | retval = usb_submit_urb(urb, GFP_KERNEL); | ||
520 | if (retval) { | ||
521 | dbg("%s - usb_submit_urb(write bulk) failed with error = %d", __FUNCTION__, retval); | ||
522 | goto exit; | ||
523 | } | ||
524 | |||
525 | /* we are done with this urb, so let the host driver | ||
526 | * really free it when it is finished with it */ | ||
527 | usb_free_urb (urb); | ||
528 | retval = count + 1; | ||
529 | break; | ||
530 | |||
531 | default : | ||
532 | dbg("%s - unsupported (at this time) write type", __FUNCTION__); | ||
533 | retval = -EINVAL; | ||
534 | break; | ||
535 | } | ||
536 | |||
537 | exit: | ||
538 | kfree(temp_buffer); | ||
539 | |||
540 | return retval; | ||
541 | } | ||
542 | |||
543 | |||
544 | static int bluetooth_write_room (struct tty_struct *tty) | ||
545 | { | ||
546 | dbg("%s", __FUNCTION__); | ||
547 | |||
548 | /* | ||
549 | * We really can take anything the user throws at us | ||
550 | * but let's pick a nice big number to tell the tty | ||
551 | * layer that we have lots of free space | ||
552 | */ | ||
553 | return 2048; | ||
554 | } | ||
555 | |||
556 | |||
557 | static int bluetooth_chars_in_buffer (struct tty_struct *tty) | ||
558 | { | ||
559 | dbg("%s", __FUNCTION__); | ||
560 | |||
561 | /* | ||
562 | * We can't really account for how much data we | ||
563 | * have sent out, but hasn't made it through to the | ||
564 | * device, so just tell the tty layer that everything | ||
565 | * is flushed. | ||
566 | */ | ||
567 | return 0; | ||
568 | } | ||
569 | |||
570 | |||
571 | static void bluetooth_throttle (struct tty_struct * tty) | ||
572 | { | ||
573 | struct usb_bluetooth *bluetooth = get_usb_bluetooth ((struct usb_bluetooth *)tty->driver_data, __FUNCTION__); | ||
574 | |||
575 | if (!bluetooth) { | ||
576 | return; | ||
577 | } | ||
578 | |||
579 | dbg("%s", __FUNCTION__); | ||
580 | |||
581 | if (!bluetooth->open_count) { | ||
582 | dbg ("%s - device not open", __FUNCTION__); | ||
583 | return; | ||
584 | } | ||
585 | |||
586 | dbg("%s unsupported (at this time)", __FUNCTION__); | ||
587 | |||
588 | return; | ||
589 | } | ||
590 | |||
591 | |||
592 | static void bluetooth_unthrottle (struct tty_struct * tty) | ||
593 | { | ||
594 | struct usb_bluetooth *bluetooth = get_usb_bluetooth ((struct usb_bluetooth *)tty->driver_data, __FUNCTION__); | ||
595 | |||
596 | if (!bluetooth) { | ||
597 | return; | ||
598 | } | ||
599 | |||
600 | dbg("%s", __FUNCTION__); | ||
601 | |||
602 | if (!bluetooth->open_count) { | ||
603 | dbg ("%s - device not open", __FUNCTION__); | ||
604 | return; | ||
605 | } | ||
606 | |||
607 | dbg("%s unsupported (at this time)", __FUNCTION__); | ||
608 | } | ||
609 | |||
610 | |||
611 | static int bluetooth_ioctl (struct tty_struct *tty, struct file * file, unsigned int cmd, unsigned long arg) | ||
612 | { | ||
613 | struct usb_bluetooth *bluetooth = get_usb_bluetooth ((struct usb_bluetooth *)tty->driver_data, __FUNCTION__); | ||
614 | |||
615 | if (!bluetooth) { | ||
616 | return -ENODEV; | ||
617 | } | ||
618 | |||
619 | dbg("%s - cmd 0x%.4x", __FUNCTION__, cmd); | ||
620 | |||
621 | if (!bluetooth->open_count) { | ||
622 | dbg ("%s - device not open", __FUNCTION__); | ||
623 | return -ENODEV; | ||
624 | } | ||
625 | |||
626 | /* FIXME!!! */ | ||
627 | return -ENOIOCTLCMD; | ||
628 | } | ||
629 | |||
630 | |||
631 | static void bluetooth_set_termios (struct tty_struct *tty, struct termios * old) | ||
632 | { | ||
633 | struct usb_bluetooth *bluetooth = get_usb_bluetooth ((struct usb_bluetooth *)tty->driver_data, __FUNCTION__); | ||
634 | |||
635 | if (!bluetooth) { | ||
636 | return; | ||
637 | } | ||
638 | |||
639 | dbg("%s", __FUNCTION__); | ||
640 | |||
641 | if (!bluetooth->open_count) { | ||
642 | dbg ("%s - device not open", __FUNCTION__); | ||
643 | return; | ||
644 | } | ||
645 | |||
646 | /* FIXME!!! */ | ||
647 | |||
648 | return; | ||
649 | } | ||
650 | |||
651 | |||
652 | #ifdef BTBUGGYHARDWARE | ||
653 | void btusb_enable_bulk_read(struct tty_struct *tty){ | ||
654 | struct usb_bluetooth *bluetooth = get_usb_bluetooth ((struct usb_bluetooth *)tty->driver_data, __FUNCTION__); | ||
655 | int result; | ||
656 | |||
657 | if (!bluetooth) { | ||
658 | return; | ||
659 | } | ||
660 | |||
661 | dbg("%s", __FUNCTION__); | ||
662 | |||
663 | if (!bluetooth->open_count) { | ||
664 | dbg ("%s - device not open", __FUNCTION__); | ||
665 | return; | ||
666 | } | ||
667 | |||
668 | if (bluetooth->read_urb) { | ||
669 | usb_fill_bulk_urb(bluetooth->read_urb, bluetooth->dev, | ||
670 | usb_rcvbulkpipe(bluetooth->dev, bluetooth->bulk_in_endpointAddress), | ||
671 | bluetooth->bulk_in_buffer, bluetooth->bulk_in_buffer_size, | ||
672 | bluetooth_read_bulk_callback, bluetooth); | ||
673 | result = usb_submit_urb(bluetooth->read_urb, GFP_KERNEL); | ||
674 | if (result) | ||
675 | err ("%s - failed submitting read urb, error %d", __FUNCTION__, result); | ||
676 | } | ||
677 | } | ||
678 | |||
679 | void btusb_disable_bulk_read(struct tty_struct *tty){ | ||
680 | struct usb_bluetooth *bluetooth = get_usb_bluetooth ((struct usb_bluetooth *)tty->driver_data, __FUNCTION__); | ||
681 | |||
682 | if (!bluetooth) { | ||
683 | return; | ||
684 | } | ||
685 | |||
686 | dbg("%s", __FUNCTION__); | ||
687 | |||
688 | if (!bluetooth->open_count) { | ||
689 | dbg ("%s - device not open", __FUNCTION__); | ||
690 | return; | ||
691 | } | ||
692 | |||
693 | if ((bluetooth->read_urb) && (bluetooth->read_urb->actual_length)) | ||
694 | usb_kill_urb(bluetooth->read_urb); | ||
695 | } | ||
696 | #endif | ||
697 | |||
698 | |||
699 | /***************************************************************************** | ||
700 | * urb callback functions | ||
701 | *****************************************************************************/ | ||
702 | |||
703 | |||
704 | static void bluetooth_int_callback (struct urb *urb, struct pt_regs *regs) | ||
705 | { | ||
706 | struct usb_bluetooth *bluetooth = get_usb_bluetooth ((struct usb_bluetooth *)urb->context, __FUNCTION__); | ||
707 | unsigned char *data = urb->transfer_buffer; | ||
708 | unsigned int i; | ||
709 | unsigned int count = urb->actual_length; | ||
710 | unsigned int packet_size; | ||
711 | int status; | ||
712 | |||
713 | dbg("%s", __FUNCTION__); | ||
714 | |||
715 | if (!bluetooth) { | ||
716 | dbg("%s - bad bluetooth pointer, exiting", __FUNCTION__); | ||
717 | return; | ||
718 | } | ||
719 | |||
720 | switch (urb->status) { | ||
721 | case 0: | ||
722 | /* success */ | ||
723 | break; | ||
724 | case -ECONNRESET: | ||
725 | case -ENOENT: | ||
726 | case -ESHUTDOWN: | ||
727 | /* this urb is terminated, clean up */ | ||
728 | dbg("%s - urb shutting down with status: %d", __FUNCTION__, urb->status); | ||
729 | return; | ||
730 | default: | ||
731 | dbg("%s - nonzero urb status received: %d", __FUNCTION__, urb->status); | ||
732 | goto exit; | ||
733 | } | ||
734 | |||
735 | if (!count) { | ||
736 | dbg("%s - zero length int", __FUNCTION__); | ||
737 | goto exit; | ||
738 | } | ||
739 | |||
740 | |||
741 | #ifdef DEBUG | ||
742 | if (count) { | ||
743 | printk (KERN_DEBUG __FILE__ ": %s- length = %d, data = ", __FUNCTION__, count); | ||
744 | for (i = 0; i < count; ++i) { | ||
745 | printk ("%.2x ", data[i]); | ||
746 | } | ||
747 | printk ("\n"); | ||
748 | } | ||
749 | #endif | ||
750 | |||
751 | #ifdef BTBUGGYHARDWARE | ||
752 | if ((count >= 2) && (data[0] == 0xFF) && (data[1] == 0x00)) { | ||
753 | data += 2; | ||
754 | count -= 2; | ||
755 | } | ||
756 | if (count == 0) { | ||
757 | urb->actual_length = 0; | ||
758 | goto exit; | ||
759 | } | ||
760 | #endif | ||
761 | /* We add a packet type identifier to the beginning of each | ||
762 | HCI frame. This makes the data in the tty look like a | ||
763 | serial USB devices. Each HCI frame can be broken across | ||
764 | multiple URBs so we buffer them until we have a full hci | ||
765 | packet */ | ||
766 | |||
767 | if (!bluetooth->int_packet_pos) { | ||
768 | bluetooth->int_buffer[0] = EVENT_PKT; | ||
769 | bluetooth->int_packet_pos++; | ||
770 | } | ||
771 | |||
772 | if (bluetooth->int_packet_pos + count > EVENT_BUFFER_SIZE) { | ||
773 | err("%s - exceeded EVENT_BUFFER_SIZE", __FUNCTION__); | ||
774 | bluetooth->int_packet_pos = 0; | ||
775 | goto exit; | ||
776 | } | ||
777 | |||
778 | memcpy (&bluetooth->int_buffer[bluetooth->int_packet_pos], | ||
779 | urb->transfer_buffer, count); | ||
780 | bluetooth->int_packet_pos += count; | ||
781 | urb->actual_length = 0; | ||
782 | |||
783 | if (bluetooth->int_packet_pos >= EVENT_HDR_SIZE) | ||
784 | packet_size = bluetooth->int_buffer[2]; | ||
785 | else | ||
786 | goto exit; | ||
787 | |||
788 | if (packet_size + EVENT_HDR_SIZE < bluetooth->int_packet_pos) { | ||
789 | err("%s - packet was too long", __FUNCTION__); | ||
790 | bluetooth->int_packet_pos = 0; | ||
791 | goto exit; | ||
792 | } | ||
793 | |||
794 | if (packet_size + EVENT_HDR_SIZE == bluetooth->int_packet_pos) { | ||
795 | for (i = 0; i < bluetooth->int_packet_pos; ++i) { | ||
796 | /* if we insert more than TTY_FLIPBUF_SIZE characters, we drop them */ | ||
797 | if (bluetooth->tty->flip.count >= TTY_FLIPBUF_SIZE) { | ||
798 | tty_flip_buffer_push(bluetooth->tty); | ||
799 | } | ||
800 | tty_insert_flip_char(bluetooth->tty, bluetooth->int_buffer[i], 0); | ||
801 | } | ||
802 | tty_flip_buffer_push(bluetooth->tty); | ||
803 | |||
804 | bluetooth->int_packet_pos = 0; | ||
805 | } | ||
806 | |||
807 | exit: | ||
808 | status = usb_submit_urb (urb, GFP_ATOMIC); | ||
809 | if (status) | ||
810 | err ("%s - usb_submit_urb failed with result %d", | ||
811 | __FUNCTION__, status); | ||
812 | } | ||
813 | |||
814 | |||
815 | static void bluetooth_ctrl_callback (struct urb *urb, struct pt_regs *regs) | ||
816 | { | ||
817 | struct usb_bluetooth *bluetooth = get_usb_bluetooth ((struct usb_bluetooth *)urb->context, __FUNCTION__); | ||
818 | |||
819 | dbg("%s", __FUNCTION__); | ||
820 | |||
821 | if (!bluetooth) { | ||
822 | dbg("%s - bad bluetooth pointer, exiting", __FUNCTION__); | ||
823 | return; | ||
824 | } | ||
825 | |||
826 | if (urb->status) { | ||
827 | dbg("%s - nonzero read bulk status received: %d", __FUNCTION__, urb->status); | ||
828 | return; | ||
829 | } | ||
830 | } | ||
831 | |||
832 | |||
833 | static void bluetooth_read_bulk_callback (struct urb *urb, struct pt_regs *regs) | ||
834 | { | ||
835 | struct usb_bluetooth *bluetooth = get_usb_bluetooth ((struct usb_bluetooth *)urb->context, __FUNCTION__); | ||
836 | unsigned char *data = urb->transfer_buffer; | ||
837 | unsigned int count = urb->actual_length; | ||
838 | unsigned int i; | ||
839 | unsigned int packet_size; | ||
840 | int result; | ||
841 | |||
842 | |||
843 | dbg("%s", __FUNCTION__); | ||
844 | |||
845 | if (!bluetooth) { | ||
846 | dbg("%s - bad bluetooth pointer, exiting", __FUNCTION__); | ||
847 | return; | ||
848 | } | ||
849 | |||
850 | if (urb->status) { | ||
851 | dbg("%s - nonzero read bulk status received: %d", __FUNCTION__, urb->status); | ||
852 | if (urb->status == -ENOENT) { | ||
853 | dbg("%s - URB canceled, won't reschedule", __FUNCTION__); | ||
854 | return; | ||
855 | } | ||
856 | goto exit; | ||
857 | } | ||
858 | |||
859 | if (!count) { | ||
860 | dbg("%s - zero length read bulk", __FUNCTION__); | ||
861 | goto exit; | ||
862 | } | ||
863 | |||
864 | #ifdef DEBUG | ||
865 | if (count) { | ||
866 | printk (KERN_DEBUG __FILE__ ": %s- length = %d, data = ", __FUNCTION__, count); | ||
867 | for (i = 0; i < count; ++i) { | ||
868 | printk ("%.2x ", data[i]); | ||
869 | } | ||
870 | printk ("\n"); | ||
871 | } | ||
872 | #endif | ||
873 | #ifdef BTBUGGYHARDWARE | ||
874 | if ((count == 4) && (data[0] == 0x00) && (data[1] == 0x00) | ||
875 | && (data[2] == 0x00) && (data[3] == 0x00)) { | ||
876 | urb->actual_length = 0; | ||
877 | usb_fill_bulk_urb(bluetooth->read_urb, bluetooth->dev, | ||
878 | usb_rcvbulkpipe(bluetooth->dev, bluetooth->bulk_in_endpointAddress), | ||
879 | bluetooth->bulk_in_buffer, bluetooth->bulk_in_buffer_size, | ||
880 | bluetooth_read_bulk_callback, bluetooth); | ||
881 | result = usb_submit_urb(bluetooth->read_urb, GFP_KERNEL); | ||
882 | if (result) | ||
883 | err ("%s - failed resubmitting read urb, error %d", __FUNCTION__, result); | ||
884 | |||
885 | return; | ||
886 | } | ||
887 | #endif | ||
888 | /* We add a packet type identifier to the beginning of each | ||
889 | HCI frame. This makes the data in the tty look like a | ||
890 | serial USB devices. Each HCI frame can be broken across | ||
891 | multiple URBs so we buffer them until we have a full hci | ||
892 | packet */ | ||
893 | |||
894 | if (!bluetooth->bulk_packet_pos) { | ||
895 | bluetooth->bulk_buffer[0] = ACL_PKT; | ||
896 | bluetooth->bulk_packet_pos++; | ||
897 | } | ||
898 | |||
899 | if (bluetooth->bulk_packet_pos + count > ACL_BUFFER_SIZE) { | ||
900 | err("%s - exceeded ACL_BUFFER_SIZE", __FUNCTION__); | ||
901 | bluetooth->bulk_packet_pos = 0; | ||
902 | goto exit; | ||
903 | } | ||
904 | |||
905 | memcpy (&bluetooth->bulk_buffer[bluetooth->bulk_packet_pos], | ||
906 | urb->transfer_buffer, count); | ||
907 | bluetooth->bulk_packet_pos += count; | ||
908 | urb->actual_length = 0; | ||
909 | |||
910 | if (bluetooth->bulk_packet_pos >= ACL_HDR_SIZE) { | ||
911 | packet_size = CHAR2INT16(bluetooth->bulk_buffer[4],bluetooth->bulk_buffer[3]); | ||
912 | } else { | ||
913 | goto exit; | ||
914 | } | ||
915 | |||
916 | if (packet_size + ACL_HDR_SIZE < bluetooth->bulk_packet_pos) { | ||
917 | err("%s - packet was too long", __FUNCTION__); | ||
918 | bluetooth->bulk_packet_pos = 0; | ||
919 | goto exit; | ||
920 | } | ||
921 | |||
922 | if (packet_size + ACL_HDR_SIZE == bluetooth->bulk_packet_pos) { | ||
923 | for (i = 0; i < bluetooth->bulk_packet_pos; ++i) { | ||
924 | /* if we insert more than TTY_FLIPBUF_SIZE characters, we drop them. */ | ||
925 | if (bluetooth->tty->flip.count >= TTY_FLIPBUF_SIZE) { | ||
926 | tty_flip_buffer_push(bluetooth->tty); | ||
927 | } | ||
928 | tty_insert_flip_char(bluetooth->tty, bluetooth->bulk_buffer[i], 0); | ||
929 | } | ||
930 | tty_flip_buffer_push(bluetooth->tty); | ||
931 | bluetooth->bulk_packet_pos = 0; | ||
932 | } | ||
933 | |||
934 | exit: | ||
935 | if (!bluetooth || !bluetooth->open_count) | ||
936 | return; | ||
937 | |||
938 | usb_fill_bulk_urb(bluetooth->read_urb, bluetooth->dev, | ||
939 | usb_rcvbulkpipe(bluetooth->dev, bluetooth->bulk_in_endpointAddress), | ||
940 | bluetooth->bulk_in_buffer, bluetooth->bulk_in_buffer_size, | ||
941 | bluetooth_read_bulk_callback, bluetooth); | ||
942 | result = usb_submit_urb(bluetooth->read_urb, GFP_KERNEL); | ||
943 | if (result) | ||
944 | err ("%s - failed resubmitting read urb, error %d", __FUNCTION__, result); | ||
945 | |||
946 | return; | ||
947 | } | ||
948 | |||
949 | |||
950 | static void bluetooth_write_bulk_callback (struct urb *urb, struct pt_regs *regs) | ||
951 | { | ||
952 | struct usb_bluetooth *bluetooth = get_usb_bluetooth ((struct usb_bluetooth *)urb->context, __FUNCTION__); | ||
953 | |||
954 | dbg("%s", __FUNCTION__); | ||
955 | |||
956 | /* free up the transfer buffer, as usb_free_urb() does not do this */ | ||
957 | kfree(urb->transfer_buffer); | ||
958 | |||
959 | if (!bluetooth) { | ||
960 | dbg("%s - bad bluetooth pointer, exiting", __FUNCTION__); | ||
961 | return; | ||
962 | } | ||
963 | |||
964 | if (urb->status) { | ||
965 | dbg("%s - nonzero write bulk status received: %d", __FUNCTION__, urb->status); | ||
966 | return; | ||
967 | } | ||
968 | |||
969 | /* wake up our little function to let the tty layer know that something happened */ | ||
970 | schedule_work(&bluetooth->work); | ||
971 | } | ||
972 | |||
973 | |||
974 | static void bluetooth_softint(void *private) | ||
975 | { | ||
976 | struct usb_bluetooth *bluetooth = get_usb_bluetooth ((struct usb_bluetooth *)private, __FUNCTION__); | ||
977 | |||
978 | dbg("%s", __FUNCTION__); | ||
979 | |||
980 | if (!bluetooth) | ||
981 | return; | ||
982 | |||
983 | tty_wakeup(bluetooth->tty); | ||
984 | } | ||
985 | |||
986 | |||
987 | static int usb_bluetooth_probe (struct usb_interface *intf, | ||
988 | const struct usb_device_id *id) | ||
989 | { | ||
990 | struct usb_device *dev = interface_to_usbdev (intf); | ||
991 | struct usb_bluetooth *bluetooth = NULL; | ||
992 | struct usb_host_interface *interface; | ||
993 | struct usb_endpoint_descriptor *endpoint; | ||
994 | struct usb_endpoint_descriptor *interrupt_in_endpoint[8]; | ||
995 | struct usb_endpoint_descriptor *bulk_in_endpoint[8]; | ||
996 | struct usb_endpoint_descriptor *bulk_out_endpoint[8]; | ||
997 | int control_out_endpoint; | ||
998 | |||
999 | int minor; | ||
1000 | int buffer_size; | ||
1001 | int i; | ||
1002 | int num_interrupt_in = 0; | ||
1003 | int num_bulk_in = 0; | ||
1004 | int num_bulk_out = 0; | ||
1005 | |||
1006 | interface = intf->cur_altsetting; | ||
1007 | control_out_endpoint = interface->desc.bInterfaceNumber; | ||
1008 | |||
1009 | /* find the endpoints that we need */ | ||
1010 | for (i = 0; i < interface->desc.bNumEndpoints; ++i) { | ||
1011 | endpoint = &interface->endpoint[i].desc; | ||
1012 | |||
1013 | if ((endpoint->bEndpointAddress & 0x80) && | ||
1014 | ((endpoint->bmAttributes & 3) == 0x02)) { | ||
1015 | /* we found a bulk in endpoint */ | ||
1016 | dbg("found bulk in"); | ||
1017 | bulk_in_endpoint[num_bulk_in] = endpoint; | ||
1018 | ++num_bulk_in; | ||
1019 | } | ||
1020 | |||
1021 | if (((endpoint->bEndpointAddress & 0x80) == 0x00) && | ||
1022 | ((endpoint->bmAttributes & 3) == 0x02)) { | ||
1023 | /* we found a bulk out endpoint */ | ||
1024 | dbg("found bulk out"); | ||
1025 | bulk_out_endpoint[num_bulk_out] = endpoint; | ||
1026 | ++num_bulk_out; | ||
1027 | } | ||
1028 | |||
1029 | if ((endpoint->bEndpointAddress & 0x80) && | ||
1030 | ((endpoint->bmAttributes & 3) == 0x03)) { | ||
1031 | /* we found a interrupt in endpoint */ | ||
1032 | dbg("found interrupt in"); | ||
1033 | interrupt_in_endpoint[num_interrupt_in] = endpoint; | ||
1034 | ++num_interrupt_in; | ||
1035 | } | ||
1036 | } | ||
1037 | |||
1038 | /* according to the spec, we can only have 1 bulk_in, 1 bulk_out, and 1 interrupt_in endpoints */ | ||
1039 | if ((num_bulk_in != 1) || | ||
1040 | (num_bulk_out != 1) || | ||
1041 | (num_interrupt_in != 1)) { | ||
1042 | dbg ("%s - improper number of endpoints. Bluetooth driver not bound.", __FUNCTION__); | ||
1043 | return -EIO; | ||
1044 | } | ||
1045 | |||
1046 | info("USB Bluetooth converter detected"); | ||
1047 | |||
1048 | for (minor = 0; minor < BLUETOOTH_TTY_MINORS && bluetooth_table[minor]; ++minor) | ||
1049 | ; | ||
1050 | if (bluetooth_table[minor]) { | ||
1051 | err("No more free Bluetooth devices"); | ||
1052 | return -ENODEV; | ||
1053 | } | ||
1054 | |||
1055 | if (!(bluetooth = kmalloc(sizeof(struct usb_bluetooth), GFP_KERNEL))) { | ||
1056 | err("Out of memory"); | ||
1057 | return -ENOMEM; | ||
1058 | } | ||
1059 | |||
1060 | memset(bluetooth, 0, sizeof(struct usb_bluetooth)); | ||
1061 | |||
1062 | bluetooth->magic = USB_BLUETOOTH_MAGIC; | ||
1063 | bluetooth->dev = dev; | ||
1064 | bluetooth->minor = minor; | ||
1065 | INIT_WORK(&bluetooth->work, bluetooth_softint, bluetooth); | ||
1066 | init_MUTEX(&bluetooth->lock); | ||
1067 | |||
1068 | /* record the interface number for the control out */ | ||
1069 | bluetooth->control_out_bInterfaceNum = control_out_endpoint; | ||
1070 | |||
1071 | /* create our control out urb pool */ | ||
1072 | for (i = 0; i < NUM_CONTROL_URBS; ++i) { | ||
1073 | struct urb *urb = usb_alloc_urb(0, GFP_KERNEL); | ||
1074 | if (urb == NULL) { | ||
1075 | err("No free urbs available"); | ||
1076 | goto probe_error; | ||
1077 | } | ||
1078 | urb->transfer_buffer = NULL; | ||
1079 | bluetooth->control_urb_pool[i] = urb; | ||
1080 | } | ||
1081 | |||
1082 | /* set up the endpoint information */ | ||
1083 | endpoint = bulk_in_endpoint[0]; | ||
1084 | bluetooth->read_urb = usb_alloc_urb (0, GFP_KERNEL); | ||
1085 | if (!bluetooth->read_urb) { | ||
1086 | err("No free urbs available"); | ||
1087 | goto probe_error; | ||
1088 | } | ||
1089 | bluetooth->bulk_in_buffer_size = buffer_size = le16_to_cpu(endpoint->wMaxPacketSize); | ||
1090 | bluetooth->bulk_in_endpointAddress = endpoint->bEndpointAddress; | ||
1091 | bluetooth->bulk_in_buffer = kmalloc (buffer_size, GFP_KERNEL); | ||
1092 | if (!bluetooth->bulk_in_buffer) { | ||
1093 | err("Couldn't allocate bulk_in_buffer"); | ||
1094 | goto probe_error; | ||
1095 | } | ||
1096 | usb_fill_bulk_urb(bluetooth->read_urb, dev, usb_rcvbulkpipe(dev, endpoint->bEndpointAddress), | ||
1097 | bluetooth->bulk_in_buffer, buffer_size, bluetooth_read_bulk_callback, bluetooth); | ||
1098 | |||
1099 | endpoint = bulk_out_endpoint[0]; | ||
1100 | bluetooth->bulk_out_endpointAddress = endpoint->bEndpointAddress; | ||
1101 | bluetooth->bulk_out_buffer_size = le16_to_cpu(endpoint->wMaxPacketSize) * 2; | ||
1102 | |||
1103 | endpoint = interrupt_in_endpoint[0]; | ||
1104 | bluetooth->interrupt_in_urb = usb_alloc_urb(0, GFP_KERNEL); | ||
1105 | if (!bluetooth->interrupt_in_urb) { | ||
1106 | err("No free urbs available"); | ||
1107 | goto probe_error; | ||
1108 | } | ||
1109 | bluetooth->interrupt_in_buffer_size = buffer_size = le16_to_cpu(endpoint->wMaxPacketSize); | ||
1110 | bluetooth->interrupt_in_endpointAddress = endpoint->bEndpointAddress; | ||
1111 | bluetooth->interrupt_in_interval = endpoint->bInterval; | ||
1112 | bluetooth->interrupt_in_buffer = kmalloc (buffer_size, GFP_KERNEL); | ||
1113 | if (!bluetooth->interrupt_in_buffer) { | ||
1114 | err("Couldn't allocate interrupt_in_buffer"); | ||
1115 | goto probe_error; | ||
1116 | } | ||
1117 | usb_fill_int_urb(bluetooth->interrupt_in_urb, dev, usb_rcvintpipe(dev, endpoint->bEndpointAddress), | ||
1118 | bluetooth->interrupt_in_buffer, buffer_size, bluetooth_int_callback, | ||
1119 | bluetooth, endpoint->bInterval); | ||
1120 | |||
1121 | /* initialize the devfs nodes for this device and let the user know what bluetooths we are bound to */ | ||
1122 | tty_register_device (bluetooth_tty_driver, minor, &intf->dev); | ||
1123 | info("Bluetooth converter now attached to ttyUB%d (or usb/ttub/%d for devfs)", minor, minor); | ||
1124 | |||
1125 | bluetooth_table[minor] = bluetooth; | ||
1126 | |||
1127 | /* success */ | ||
1128 | usb_set_intfdata (intf, bluetooth); | ||
1129 | return 0; | ||
1130 | |||
1131 | probe_error: | ||
1132 | if (bluetooth->read_urb) | ||
1133 | usb_free_urb (bluetooth->read_urb); | ||
1134 | if (bluetooth->bulk_in_buffer) | ||
1135 | kfree (bluetooth->bulk_in_buffer); | ||
1136 | if (bluetooth->interrupt_in_urb) | ||
1137 | usb_free_urb (bluetooth->interrupt_in_urb); | ||
1138 | if (bluetooth->interrupt_in_buffer) | ||
1139 | kfree (bluetooth->interrupt_in_buffer); | ||
1140 | for (i = 0; i < NUM_CONTROL_URBS; ++i) | ||
1141 | if (bluetooth->control_urb_pool[i]) { | ||
1142 | if (bluetooth->control_urb_pool[i]->transfer_buffer) | ||
1143 | kfree (bluetooth->control_urb_pool[i]->transfer_buffer); | ||
1144 | usb_free_urb (bluetooth->control_urb_pool[i]); | ||
1145 | } | ||
1146 | |||
1147 | bluetooth_table[minor] = NULL; | ||
1148 | |||
1149 | /* free up any memory that we allocated */ | ||
1150 | kfree (bluetooth); | ||
1151 | return -EIO; | ||
1152 | } | ||
1153 | |||
1154 | |||
1155 | static void usb_bluetooth_disconnect(struct usb_interface *intf) | ||
1156 | { | ||
1157 | struct usb_bluetooth *bluetooth = usb_get_intfdata (intf); | ||
1158 | int i; | ||
1159 | |||
1160 | usb_set_intfdata (intf, NULL); | ||
1161 | if (bluetooth) { | ||
1162 | if ((bluetooth->open_count) && (bluetooth->tty)) | ||
1163 | tty_hangup(bluetooth->tty); | ||
1164 | |||
1165 | bluetooth->open_count = 0; | ||
1166 | |||
1167 | if (bluetooth->read_urb) { | ||
1168 | usb_kill_urb (bluetooth->read_urb); | ||
1169 | usb_free_urb (bluetooth->read_urb); | ||
1170 | } | ||
1171 | if (bluetooth->bulk_in_buffer) | ||
1172 | kfree (bluetooth->bulk_in_buffer); | ||
1173 | |||
1174 | if (bluetooth->interrupt_in_urb) { | ||
1175 | usb_kill_urb (bluetooth->interrupt_in_urb); | ||
1176 | usb_free_urb (bluetooth->interrupt_in_urb); | ||
1177 | } | ||
1178 | if (bluetooth->interrupt_in_buffer) | ||
1179 | kfree (bluetooth->interrupt_in_buffer); | ||
1180 | |||
1181 | tty_unregister_device (bluetooth_tty_driver, bluetooth->minor); | ||
1182 | |||
1183 | for (i = 0; i < NUM_CONTROL_URBS; ++i) { | ||
1184 | if (bluetooth->control_urb_pool[i]) { | ||
1185 | usb_kill_urb (bluetooth->control_urb_pool[i]); | ||
1186 | if (bluetooth->control_urb_pool[i]->transfer_buffer) | ||
1187 | kfree (bluetooth->control_urb_pool[i]->transfer_buffer); | ||
1188 | usb_free_urb (bluetooth->control_urb_pool[i]); | ||
1189 | } | ||
1190 | } | ||
1191 | |||
1192 | info("Bluetooth converter now disconnected from ttyUB%d", bluetooth->minor); | ||
1193 | |||
1194 | bluetooth_table[bluetooth->minor] = NULL; | ||
1195 | |||
1196 | /* free up any memory that we allocated */ | ||
1197 | kfree (bluetooth); | ||
1198 | } else { | ||
1199 | info("device disconnected"); | ||
1200 | } | ||
1201 | } | ||
1202 | |||
1203 | static struct tty_operations bluetooth_ops = { | ||
1204 | .open = bluetooth_open, | ||
1205 | .close = bluetooth_close, | ||
1206 | .write = bluetooth_write, | ||
1207 | .write_room = bluetooth_write_room, | ||
1208 | .ioctl = bluetooth_ioctl, | ||
1209 | .set_termios = bluetooth_set_termios, | ||
1210 | .throttle = bluetooth_throttle, | ||
1211 | .unthrottle = bluetooth_unthrottle, | ||
1212 | .chars_in_buffer = bluetooth_chars_in_buffer, | ||
1213 | }; | ||
1214 | |||
1215 | static int usb_bluetooth_init(void) | ||
1216 | { | ||
1217 | int i; | ||
1218 | int result; | ||
1219 | |||
1220 | /* Initialize our global data */ | ||
1221 | for (i = 0; i < BLUETOOTH_TTY_MINORS; ++i) { | ||
1222 | bluetooth_table[i] = NULL; | ||
1223 | } | ||
1224 | |||
1225 | info ("USB Bluetooth support registered"); | ||
1226 | |||
1227 | bluetooth_tty_driver = alloc_tty_driver(BLUETOOTH_TTY_MINORS); | ||
1228 | if (!bluetooth_tty_driver) | ||
1229 | return -ENOMEM; | ||
1230 | |||
1231 | bluetooth_tty_driver->owner = THIS_MODULE; | ||
1232 | bluetooth_tty_driver->driver_name = "usb-bluetooth"; | ||
1233 | bluetooth_tty_driver->name = "ttyUB"; | ||
1234 | bluetooth_tty_driver->devfs_name = "usb/ttub/"; | ||
1235 | bluetooth_tty_driver->major = BLUETOOTH_TTY_MAJOR; | ||
1236 | bluetooth_tty_driver->minor_start = 0; | ||
1237 | bluetooth_tty_driver->type = TTY_DRIVER_TYPE_SERIAL; | ||
1238 | bluetooth_tty_driver->subtype = SERIAL_TYPE_NORMAL; | ||
1239 | bluetooth_tty_driver->flags = TTY_DRIVER_REAL_RAW | TTY_DRIVER_NO_DEVFS; | ||
1240 | bluetooth_tty_driver->init_termios = tty_std_termios; | ||
1241 | bluetooth_tty_driver->init_termios.c_cflag = B9600 | CS8 | CREAD | HUPCL | CLOCAL; | ||
1242 | tty_set_operations(bluetooth_tty_driver, &bluetooth_ops); | ||
1243 | if (tty_register_driver (bluetooth_tty_driver)) { | ||
1244 | err("%s - failed to register tty driver", __FUNCTION__); | ||
1245 | put_tty_driver(bluetooth_tty_driver); | ||
1246 | return -1; | ||
1247 | } | ||
1248 | |||
1249 | /* register the USB driver */ | ||
1250 | result = usb_register(&usb_bluetooth_driver); | ||
1251 | if (result < 0) { | ||
1252 | tty_unregister_driver(bluetooth_tty_driver); | ||
1253 | put_tty_driver(bluetooth_tty_driver); | ||
1254 | err("usb_register failed for the USB bluetooth driver. Error number %d", result); | ||
1255 | return -1; | ||
1256 | } | ||
1257 | |||
1258 | info(DRIVER_DESC " " DRIVER_VERSION); | ||
1259 | |||
1260 | return 0; | ||
1261 | } | ||
1262 | |||
1263 | |||
1264 | static void usb_bluetooth_exit(void) | ||
1265 | { | ||
1266 | usb_deregister(&usb_bluetooth_driver); | ||
1267 | tty_unregister_driver(bluetooth_tty_driver); | ||
1268 | put_tty_driver(bluetooth_tty_driver); | ||
1269 | } | ||
1270 | |||
1271 | |||
1272 | module_init(usb_bluetooth_init); | ||
1273 | module_exit(usb_bluetooth_exit); | ||
1274 | |||
1275 | /* Module information */ | ||
1276 | MODULE_AUTHOR( DRIVER_AUTHOR ); | ||
1277 | MODULE_DESCRIPTION( DRIVER_DESC ); | ||
1278 | MODULE_LICENSE("GPL"); | ||
1279 | |||
diff --git a/drivers/usb/class/cdc-acm.c b/drivers/usb/class/cdc-acm.c index 16ecad30e29c..1b4751412970 100644 --- a/drivers/usb/class/cdc-acm.c +++ b/drivers/usb/class/cdc-acm.c | |||
@@ -827,11 +827,10 @@ skip_normal_probe: | |||
827 | return -ENODEV; | 827 | return -ENODEV; |
828 | } | 828 | } |
829 | 829 | ||
830 | if (!(acm = kmalloc(sizeof(struct acm), GFP_KERNEL))) { | 830 | if (!(acm = kzalloc(sizeof(struct acm), GFP_KERNEL))) { |
831 | dev_dbg(&intf->dev, "out of memory (acm kmalloc)\n"); | 831 | dev_dbg(&intf->dev, "out of memory (acm kzalloc)\n"); |
832 | goto alloc_fail; | 832 | goto alloc_fail; |
833 | } | 833 | } |
834 | memset(acm, 0, sizeof(struct acm)); | ||
835 | 834 | ||
836 | ctrlsize = le16_to_cpu(epctrl->wMaxPacketSize); | 835 | ctrlsize = le16_to_cpu(epctrl->wMaxPacketSize); |
837 | readsize = le16_to_cpu(epread->wMaxPacketSize); | 836 | readsize = le16_to_cpu(epread->wMaxPacketSize); |
diff --git a/drivers/usb/class/usblp.c b/drivers/usb/class/usblp.c index e195709c9c7f..357e75335f17 100644 --- a/drivers/usb/class/usblp.c +++ b/drivers/usb/class/usblp.c | |||
@@ -844,9 +844,8 @@ static struct file_operations usblp_fops = { | |||
844 | }; | 844 | }; |
845 | 845 | ||
846 | static struct usb_class_driver usblp_class = { | 846 | static struct usb_class_driver usblp_class = { |
847 | .name = "usb/lp%d", | 847 | .name = "lp%d", |
848 | .fops = &usblp_fops, | 848 | .fops = &usblp_fops, |
849 | .mode = S_IFCHR | S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP, | ||
850 | .minor_base = USBLP_MINOR_BASE, | 849 | .minor_base = USBLP_MINOR_BASE, |
851 | }; | 850 | }; |
852 | 851 | ||
diff --git a/drivers/usb/core/Kconfig b/drivers/usb/core/Kconfig index 1a9ff6184943..ff03184da403 100644 --- a/drivers/usb/core/Kconfig +++ b/drivers/usb/core/Kconfig | |||
@@ -61,14 +61,17 @@ config USB_DYNAMIC_MINORS | |||
61 | If you are unsure about this, say N here. | 61 | If you are unsure about this, say N here. |
62 | 62 | ||
63 | config USB_SUSPEND | 63 | config USB_SUSPEND |
64 | bool "USB suspend/resume (EXPERIMENTAL)" | 64 | bool "USB selective suspend/resume and wakeup (EXPERIMENTAL)" |
65 | depends on USB && PM && EXPERIMENTAL | 65 | depends on USB && PM && EXPERIMENTAL |
66 | help | 66 | help |
67 | If you say Y here, you can use driver calls or the sysfs | 67 | If you say Y here, you can use driver calls or the sysfs |
68 | "power/state" file to suspend or resume individual USB | 68 | "power/state" file to suspend or resume individual USB |
69 | peripherals. There are many related features, such as | 69 | peripherals. |
70 | remote wakeup and driver-specific suspend processing, that | 70 | |
71 | may not yet work as expected. | 71 | Also, USB "remote wakeup" signaling is supported, whereby some |
72 | USB devices (like keyboards and network adapters) can wake up | ||
73 | their parent hub. That wakeup cascades up the USB tree, and | ||
74 | could wake the system from states like suspend-to-RAM. | ||
72 | 75 | ||
73 | If you are unsure about this, say N here. | 76 | If you are unsure about this, say N here. |
74 | 77 | ||
diff --git a/drivers/usb/core/Makefile b/drivers/usb/core/Makefile index d5503cf0bf74..86d5c380892d 100644 --- a/drivers/usb/core/Makefile +++ b/drivers/usb/core/Makefile | |||
@@ -3,7 +3,7 @@ | |||
3 | # | 3 | # |
4 | 4 | ||
5 | usbcore-objs := usb.o hub.o hcd.o urb.o message.o \ | 5 | usbcore-objs := usb.o hub.o hcd.o urb.o message.o \ |
6 | config.o file.o buffer.o sysfs.o devio.o | 6 | config.o file.o buffer.o sysfs.o devio.o notify.o |
7 | 7 | ||
8 | ifeq ($(CONFIG_PCI),y) | 8 | ifeq ($(CONFIG_PCI),y) |
9 | usbcore-objs += hcd-pci.o | 9 | usbcore-objs += hcd-pci.o |
@@ -14,3 +14,7 @@ ifeq ($(CONFIG_USB_DEVICEFS),y) | |||
14 | endif | 14 | endif |
15 | 15 | ||
16 | obj-$(CONFIG_USB) += usbcore.o | 16 | obj-$(CONFIG_USB) += usbcore.o |
17 | |||
18 | ifeq ($(CONFIG_USB_DEBUG),y) | ||
19 | EXTRA_CFLAGS += -DDEBUG | ||
20 | endif | ||
diff --git a/drivers/usb/core/buffer.c b/drivers/usb/core/buffer.c index fc15b4acc8af..419c9943a7cb 100644 --- a/drivers/usb/core/buffer.c +++ b/drivers/usb/core/buffer.c | |||
@@ -15,14 +15,6 @@ | |||
15 | #include <asm/scatterlist.h> | 15 | #include <asm/scatterlist.h> |
16 | #include <linux/dma-mapping.h> | 16 | #include <linux/dma-mapping.h> |
17 | #include <linux/dmapool.h> | 17 | #include <linux/dmapool.h> |
18 | |||
19 | |||
20 | #ifdef CONFIG_USB_DEBUG | ||
21 | #define DEBUG | ||
22 | #else | ||
23 | #undef DEBUG | ||
24 | #endif | ||
25 | |||
26 | #include <linux/usb.h> | 18 | #include <linux/usb.h> |
27 | #include "hcd.h" | 19 | #include "hcd.h" |
28 | 20 | ||
@@ -106,7 +98,7 @@ void hcd_buffer_destroy (struct usb_hcd *hcd) | |||
106 | void *hcd_buffer_alloc ( | 98 | void *hcd_buffer_alloc ( |
107 | struct usb_bus *bus, | 99 | struct usb_bus *bus, |
108 | size_t size, | 100 | size_t size, |
109 | unsigned mem_flags, | 101 | gfp_t mem_flags, |
110 | dma_addr_t *dma | 102 | dma_addr_t *dma |
111 | ) | 103 | ) |
112 | { | 104 | { |
diff --git a/drivers/usb/core/config.c b/drivers/usb/core/config.c index 99595e07b653..a9d89c78cc20 100644 --- a/drivers/usb/core/config.c +++ b/drivers/usb/core/config.c | |||
@@ -1,9 +1,4 @@ | |||
1 | #include <linux/config.h> | 1 | #include <linux/config.h> |
2 | |||
3 | #ifdef CONFIG_USB_DEBUG | ||
4 | #define DEBUG | ||
5 | #endif | ||
6 | |||
7 | #include <linux/usb.h> | 2 | #include <linux/usb.h> |
8 | #include <linux/module.h> | 3 | #include <linux/module.h> |
9 | #include <linux/init.h> | 4 | #include <linux/init.h> |
@@ -112,8 +107,12 @@ void usb_release_interface_cache(struct kref *ref) | |||
112 | struct usb_interface_cache *intfc = ref_to_usb_interface_cache(ref); | 107 | struct usb_interface_cache *intfc = ref_to_usb_interface_cache(ref); |
113 | int j; | 108 | int j; |
114 | 109 | ||
115 | for (j = 0; j < intfc->num_altsetting; j++) | 110 | for (j = 0; j < intfc->num_altsetting; j++) { |
116 | kfree(intfc->altsetting[j].endpoint); | 111 | struct usb_host_interface *alt = &intfc->altsetting[j]; |
112 | |||
113 | kfree(alt->endpoint); | ||
114 | kfree(alt->string); | ||
115 | } | ||
117 | kfree(intfc); | 116 | kfree(intfc); |
118 | } | 117 | } |
119 | 118 | ||
@@ -188,10 +187,9 @@ static int usb_parse_interface(struct device *ddev, int cfgno, | |||
188 | } | 187 | } |
189 | 188 | ||
190 | len = sizeof(struct usb_host_endpoint) * num_ep; | 189 | len = sizeof(struct usb_host_endpoint) * num_ep; |
191 | alt->endpoint = kmalloc(len, GFP_KERNEL); | 190 | alt->endpoint = kzalloc(len, GFP_KERNEL); |
192 | if (!alt->endpoint) | 191 | if (!alt->endpoint) |
193 | return -ENOMEM; | 192 | return -ENOMEM; |
194 | memset(alt->endpoint, 0, len); | ||
195 | 193 | ||
196 | /* Parse all the endpoint descriptors */ | 194 | /* Parse all the endpoint descriptors */ |
197 | n = 0; | 195 | n = 0; |
@@ -353,10 +351,9 @@ static int usb_parse_configuration(struct device *ddev, int cfgidx, | |||
353 | } | 351 | } |
354 | 352 | ||
355 | len = sizeof(*intfc) + sizeof(struct usb_host_interface) * j; | 353 | len = sizeof(*intfc) + sizeof(struct usb_host_interface) * j; |
356 | config->intf_cache[i] = intfc = kmalloc(len, GFP_KERNEL); | 354 | config->intf_cache[i] = intfc = kzalloc(len, GFP_KERNEL); |
357 | if (!intfc) | 355 | if (!intfc) |
358 | return -ENOMEM; | 356 | return -ENOMEM; |
359 | memset(intfc, 0, len); | ||
360 | kref_init(&intfc->ref); | 357 | kref_init(&intfc->ref); |
361 | } | 358 | } |
362 | 359 | ||
@@ -422,8 +419,6 @@ void usb_destroy_configuration(struct usb_device *dev) | |||
422 | struct usb_host_config *cf = &dev->config[c]; | 419 | struct usb_host_config *cf = &dev->config[c]; |
423 | 420 | ||
424 | kfree(cf->string); | 421 | kfree(cf->string); |
425 | cf->string = NULL; | ||
426 | |||
427 | for (i = 0; i < cf->desc.bNumInterfaces; i++) { | 422 | for (i = 0; i < cf->desc.bNumInterfaces; i++) { |
428 | if (cf->intf_cache[i]) | 423 | if (cf->intf_cache[i]) |
429 | kref_put(&cf->intf_cache[i]->ref, | 424 | kref_put(&cf->intf_cache[i]->ref, |
@@ -459,16 +454,14 @@ int usb_get_configuration(struct usb_device *dev) | |||
459 | } | 454 | } |
460 | 455 | ||
461 | length = ncfg * sizeof(struct usb_host_config); | 456 | length = ncfg * sizeof(struct usb_host_config); |
462 | dev->config = kmalloc(length, GFP_KERNEL); | 457 | dev->config = kzalloc(length, GFP_KERNEL); |
463 | if (!dev->config) | 458 | if (!dev->config) |
464 | goto err2; | 459 | goto err2; |
465 | memset(dev->config, 0, length); | ||
466 | 460 | ||
467 | length = ncfg * sizeof(char *); | 461 | length = ncfg * sizeof(char *); |
468 | dev->rawdescriptors = kmalloc(length, GFP_KERNEL); | 462 | dev->rawdescriptors = kzalloc(length, GFP_KERNEL); |
469 | if (!dev->rawdescriptors) | 463 | if (!dev->rawdescriptors) |
470 | goto err2; | 464 | goto err2; |
471 | memset(dev->rawdescriptors, 0, length); | ||
472 | 465 | ||
473 | buffer = kmalloc(USB_DT_CONFIG_SIZE, GFP_KERNEL); | 466 | buffer = kmalloc(USB_DT_CONFIG_SIZE, GFP_KERNEL); |
474 | if (!buffer) | 467 | if (!buffer) |
diff --git a/drivers/usb/core/devio.c b/drivers/usb/core/devio.c index b4265aa7d45e..b1d6e9af732d 100644 --- a/drivers/usb/core/devio.c +++ b/drivers/usb/core/devio.c | |||
@@ -30,6 +30,8 @@ | |||
30 | * Revision history | 30 | * Revision history |
31 | * 22.12.1999 0.1 Initial release (split from proc_usb.c) | 31 | * 22.12.1999 0.1 Initial release (split from proc_usb.c) |
32 | * 04.01.2000 0.2 Turned into its own filesystem | 32 | * 04.01.2000 0.2 Turned into its own filesystem |
33 | * 30.09.2005 0.3 Fix user-triggerable oops in async URB delivery | ||
34 | * (CAN-2005-3055) | ||
33 | */ | 35 | */ |
34 | 36 | ||
35 | /*****************************************************************************/ | 37 | /*****************************************************************************/ |
@@ -44,6 +46,7 @@ | |||
44 | #include <linux/usb.h> | 46 | #include <linux/usb.h> |
45 | #include <linux/usbdevice_fs.h> | 47 | #include <linux/usbdevice_fs.h> |
46 | #include <linux/cdev.h> | 48 | #include <linux/cdev.h> |
49 | #include <linux/notifier.h> | ||
47 | #include <asm/uaccess.h> | 50 | #include <asm/uaccess.h> |
48 | #include <asm/byteorder.h> | 51 | #include <asm/byteorder.h> |
49 | #include <linux/moduleparam.h> | 52 | #include <linux/moduleparam.h> |
@@ -58,7 +61,8 @@ static struct class *usb_device_class; | |||
58 | struct async { | 61 | struct async { |
59 | struct list_head asynclist; | 62 | struct list_head asynclist; |
60 | struct dev_state *ps; | 63 | struct dev_state *ps; |
61 | struct task_struct *task; | 64 | pid_t pid; |
65 | uid_t uid, euid; | ||
62 | unsigned int signr; | 66 | unsigned int signr; |
63 | unsigned int ifnum; | 67 | unsigned int ifnum; |
64 | void __user *userbuffer; | 68 | void __user *userbuffer; |
@@ -206,10 +210,10 @@ err: | |||
206 | static struct async *alloc_async(unsigned int numisoframes) | 210 | static struct async *alloc_async(unsigned int numisoframes) |
207 | { | 211 | { |
208 | unsigned int assize = sizeof(struct async) + numisoframes * sizeof(struct usb_iso_packet_descriptor); | 212 | unsigned int assize = sizeof(struct async) + numisoframes * sizeof(struct usb_iso_packet_descriptor); |
209 | struct async *as = kmalloc(assize, GFP_KERNEL); | 213 | struct async *as = kzalloc(assize, GFP_KERNEL); |
214 | |||
210 | if (!as) | 215 | if (!as) |
211 | return NULL; | 216 | return NULL; |
212 | memset(as, 0, assize); | ||
213 | as->urb = usb_alloc_urb(numisoframes, GFP_KERNEL); | 217 | as->urb = usb_alloc_urb(numisoframes, GFP_KERNEL); |
214 | if (!as->urb) { | 218 | if (!as->urb) { |
215 | kfree(as); | 219 | kfree(as); |
@@ -276,6 +280,28 @@ static inline struct async *async_getpending(struct dev_state *ps, void __user * | |||
276 | return NULL; | 280 | return NULL; |
277 | } | 281 | } |
278 | 282 | ||
283 | static void snoop_urb(struct urb *urb, void __user *userurb) | ||
284 | { | ||
285 | int j; | ||
286 | unsigned char *data = urb->transfer_buffer; | ||
287 | |||
288 | if (!usbfs_snoop) | ||
289 | return; | ||
290 | |||
291 | if (urb->pipe & USB_DIR_IN) | ||
292 | dev_info(&urb->dev->dev, "direction=IN\n"); | ||
293 | else | ||
294 | dev_info(&urb->dev->dev, "direction=OUT\n"); | ||
295 | dev_info(&urb->dev->dev, "userurb=%p\n", userurb); | ||
296 | dev_info(&urb->dev->dev, "transfer_buffer_length=%d\n", | ||
297 | urb->transfer_buffer_length); | ||
298 | dev_info(&urb->dev->dev, "actual_length=%d\n", urb->actual_length); | ||
299 | dev_info(&urb->dev->dev, "data: "); | ||
300 | for (j = 0; j < urb->transfer_buffer_length; ++j) | ||
301 | printk ("%02x ", data[j]); | ||
302 | printk("\n"); | ||
303 | } | ||
304 | |||
279 | static void async_completed(struct urb *urb, struct pt_regs *regs) | 305 | static void async_completed(struct urb *urb, struct pt_regs *regs) |
280 | { | 306 | { |
281 | struct async *as = (struct async *)urb->context; | 307 | struct async *as = (struct async *)urb->context; |
@@ -290,9 +316,12 @@ static void async_completed(struct urb *urb, struct pt_regs *regs) | |||
290 | sinfo.si_errno = as->urb->status; | 316 | sinfo.si_errno = as->urb->status; |
291 | sinfo.si_code = SI_ASYNCIO; | 317 | sinfo.si_code = SI_ASYNCIO; |
292 | sinfo.si_addr = as->userurb; | 318 | sinfo.si_addr = as->userurb; |
293 | send_sig_info(as->signr, &sinfo, as->task); | 319 | kill_proc_info_as_uid(as->signr, &sinfo, as->pid, as->uid, |
320 | as->euid); | ||
294 | } | 321 | } |
295 | wake_up(&ps->wait); | 322 | snoop(&urb->dev->dev, "urb complete\n"); |
323 | snoop_urb(urb, as->userurb); | ||
324 | wake_up(&ps->wait); | ||
296 | } | 325 | } |
297 | 326 | ||
298 | static void destroy_async (struct dev_state *ps, struct list_head *list) | 327 | static void destroy_async (struct dev_state *ps, struct list_head *list) |
@@ -489,6 +518,23 @@ static int check_ctrlrecip(struct dev_state *ps, unsigned int requesttype, unsig | |||
489 | return ret; | 518 | return ret; |
490 | } | 519 | } |
491 | 520 | ||
521 | static struct usb_device *usbdev_lookup_minor(int minor) | ||
522 | { | ||
523 | struct class_device *class_dev; | ||
524 | struct usb_device *dev = NULL; | ||
525 | |||
526 | down(&usb_device_class->sem); | ||
527 | list_for_each_entry(class_dev, &usb_device_class->children, node) { | ||
528 | if (class_dev->devt == MKDEV(USB_DEVICE_MAJOR, minor)) { | ||
529 | dev = class_dev->class_data; | ||
530 | break; | ||
531 | } | ||
532 | } | ||
533 | up(&usb_device_class->sem); | ||
534 | |||
535 | return dev; | ||
536 | }; | ||
537 | |||
492 | /* | 538 | /* |
493 | * file operations | 539 | * file operations |
494 | */ | 540 | */ |
@@ -526,7 +572,9 @@ static int usbdev_open(struct inode *inode, struct file *file) | |||
526 | INIT_LIST_HEAD(&ps->async_completed); | 572 | INIT_LIST_HEAD(&ps->async_completed); |
527 | init_waitqueue_head(&ps->wait); | 573 | init_waitqueue_head(&ps->wait); |
528 | ps->discsignr = 0; | 574 | ps->discsignr = 0; |
529 | ps->disctask = current; | 575 | ps->disc_pid = current->pid; |
576 | ps->disc_uid = current->uid; | ||
577 | ps->disc_euid = current->euid; | ||
530 | ps->disccontext = NULL; | 578 | ps->disccontext = NULL; |
531 | ps->ifclaimed = 0; | 579 | ps->ifclaimed = 0; |
532 | wmb(); | 580 | wmb(); |
@@ -595,7 +643,7 @@ static int proc_control(struct dev_state *ps, void __user *arg) | |||
595 | if (usbfs_snoop) { | 643 | if (usbfs_snoop) { |
596 | dev_info(&dev->dev, "control read: data "); | 644 | dev_info(&dev->dev, "control read: data "); |
597 | for (j = 0; j < i; ++j) | 645 | for (j = 0; j < i; ++j) |
598 | printk ("%02x ", (unsigned char)(tbuf)[j]); | 646 | printk("%02x ", (unsigned char)(tbuf)[j]); |
599 | printk("\n"); | 647 | printk("\n"); |
600 | } | 648 | } |
601 | if (copy_to_user(ctrl.data, tbuf, i)) { | 649 | if (copy_to_user(ctrl.data, tbuf, i)) { |
@@ -618,7 +666,7 @@ static int proc_control(struct dev_state *ps, void __user *arg) | |||
618 | if (usbfs_snoop) { | 666 | if (usbfs_snoop) { |
619 | dev_info(&dev->dev, "control write: data: "); | 667 | dev_info(&dev->dev, "control write: data: "); |
620 | for (j = 0; j < ctrl.wLength; ++j) | 668 | for (j = 0; j < ctrl.wLength; ++j) |
621 | printk ("%02x ", (unsigned char)(tbuf)[j]); | 669 | printk("%02x ", (unsigned char)(tbuf)[j]); |
622 | printk("\n"); | 670 | printk("\n"); |
623 | } | 671 | } |
624 | usb_unlock_device(dev); | 672 | usb_unlock_device(dev); |
@@ -643,7 +691,7 @@ static int proc_bulk(struct dev_state *ps, void __user *arg) | |||
643 | unsigned int tmo, len1, pipe; | 691 | unsigned int tmo, len1, pipe; |
644 | int len2; | 692 | int len2; |
645 | unsigned char *tbuf; | 693 | unsigned char *tbuf; |
646 | int i, ret; | 694 | int i, j, ret; |
647 | 695 | ||
648 | if (copy_from_user(&bulk, arg, sizeof(bulk))) | 696 | if (copy_from_user(&bulk, arg, sizeof(bulk))) |
649 | return -EFAULT; | 697 | return -EFAULT; |
@@ -668,10 +716,18 @@ static int proc_bulk(struct dev_state *ps, void __user *arg) | |||
668 | kfree(tbuf); | 716 | kfree(tbuf); |
669 | return -EINVAL; | 717 | return -EINVAL; |
670 | } | 718 | } |
719 | snoop(&dev->dev, "bulk read: len=0x%02x timeout=%04d\n", | ||
720 | bulk.len, bulk.timeout); | ||
671 | usb_unlock_device(dev); | 721 | usb_unlock_device(dev); |
672 | i = usb_bulk_msg(dev, pipe, tbuf, len1, &len2, tmo); | 722 | i = usb_bulk_msg(dev, pipe, tbuf, len1, &len2, tmo); |
673 | usb_lock_device(dev); | 723 | usb_lock_device(dev); |
674 | if (!i && len2) { | 724 | if (!i && len2) { |
725 | if (usbfs_snoop) { | ||
726 | dev_info(&dev->dev, "bulk read: data "); | ||
727 | for (j = 0; j < len2; ++j) | ||
728 | printk("%02x ", (unsigned char)(tbuf)[j]); | ||
729 | printk("\n"); | ||
730 | } | ||
675 | if (copy_to_user(bulk.data, tbuf, len2)) { | 731 | if (copy_to_user(bulk.data, tbuf, len2)) { |
676 | kfree(tbuf); | 732 | kfree(tbuf); |
677 | return -EFAULT; | 733 | return -EFAULT; |
@@ -684,6 +740,14 @@ static int proc_bulk(struct dev_state *ps, void __user *arg) | |||
684 | return -EFAULT; | 740 | return -EFAULT; |
685 | } | 741 | } |
686 | } | 742 | } |
743 | snoop(&dev->dev, "bulk write: len=0x%02x timeout=%04d\n", | ||
744 | bulk.len, bulk.timeout); | ||
745 | if (usbfs_snoop) { | ||
746 | dev_info(&dev->dev, "bulk write: data: "); | ||
747 | for (j = 0; j < len1; ++j) | ||
748 | printk("%02x ", (unsigned char)(tbuf)[j]); | ||
749 | printk("\n"); | ||
750 | } | ||
687 | usb_unlock_device(dev); | 751 | usb_unlock_device(dev); |
688 | i = usb_bulk_msg(dev, pipe, tbuf, len1, &len2, tmo); | 752 | i = usb_bulk_msg(dev, pipe, tbuf, len1, &len2, tmo); |
689 | usb_lock_device(dev); | 753 | usb_lock_device(dev); |
@@ -829,7 +893,6 @@ static int proc_setconfig(struct dev_state *ps, void __user *arg) | |||
829 | return status; | 893 | return status; |
830 | } | 894 | } |
831 | 895 | ||
832 | |||
833 | static int proc_do_submiturb(struct dev_state *ps, struct usbdevfs_urb *uurb, | 896 | static int proc_do_submiturb(struct dev_state *ps, struct usbdevfs_urb *uurb, |
834 | struct usbdevfs_iso_packet_desc __user *iso_frame_desc, | 897 | struct usbdevfs_iso_packet_desc __user *iso_frame_desc, |
835 | void __user *arg) | 898 | void __user *arg) |
@@ -890,6 +953,7 @@ static int proc_do_submiturb(struct dev_state *ps, struct usbdevfs_urb *uurb, | |||
890 | kfree(dr); | 953 | kfree(dr); |
891 | return -EFAULT; | 954 | return -EFAULT; |
892 | } | 955 | } |
956 | snoop(&ps->dev->dev, "control urb\n"); | ||
893 | break; | 957 | break; |
894 | 958 | ||
895 | case USBDEVFS_URB_TYPE_BULK: | 959 | case USBDEVFS_URB_TYPE_BULK: |
@@ -904,6 +968,7 @@ static int proc_do_submiturb(struct dev_state *ps, struct usbdevfs_urb *uurb, | |||
904 | return -EINVAL; | 968 | return -EINVAL; |
905 | if (!access_ok((uurb->endpoint & USB_DIR_IN) ? VERIFY_WRITE : VERIFY_READ, uurb->buffer, uurb->buffer_length)) | 969 | if (!access_ok((uurb->endpoint & USB_DIR_IN) ? VERIFY_WRITE : VERIFY_READ, uurb->buffer, uurb->buffer_length)) |
906 | return -EFAULT; | 970 | return -EFAULT; |
971 | snoop(&ps->dev->dev, "bulk urb\n"); | ||
907 | break; | 972 | break; |
908 | 973 | ||
909 | case USBDEVFS_URB_TYPE_ISO: | 974 | case USBDEVFS_URB_TYPE_ISO: |
@@ -933,6 +998,7 @@ static int proc_do_submiturb(struct dev_state *ps, struct usbdevfs_urb *uurb, | |||
933 | return -EINVAL; | 998 | return -EINVAL; |
934 | } | 999 | } |
935 | uurb->buffer_length = totlen; | 1000 | uurb->buffer_length = totlen; |
1001 | snoop(&ps->dev->dev, "iso urb\n"); | ||
936 | break; | 1002 | break; |
937 | 1003 | ||
938 | case USBDEVFS_URB_TYPE_INTERRUPT: | 1004 | case USBDEVFS_URB_TYPE_INTERRUPT: |
@@ -948,6 +1014,7 @@ static int proc_do_submiturb(struct dev_state *ps, struct usbdevfs_urb *uurb, | |||
948 | return -EINVAL; | 1014 | return -EINVAL; |
949 | if (!access_ok((uurb->endpoint & USB_DIR_IN) ? VERIFY_WRITE : VERIFY_READ, uurb->buffer, uurb->buffer_length)) | 1015 | if (!access_ok((uurb->endpoint & USB_DIR_IN) ? VERIFY_WRITE : VERIFY_READ, uurb->buffer, uurb->buffer_length)) |
950 | return -EFAULT; | 1016 | return -EFAULT; |
1017 | snoop(&ps->dev->dev, "interrupt urb\n"); | ||
951 | break; | 1018 | break; |
952 | 1019 | ||
953 | default: | 1020 | default: |
@@ -988,13 +1055,17 @@ static int proc_do_submiturb(struct dev_state *ps, struct usbdevfs_urb *uurb, | |||
988 | as->userbuffer = NULL; | 1055 | as->userbuffer = NULL; |
989 | as->signr = uurb->signr; | 1056 | as->signr = uurb->signr; |
990 | as->ifnum = ifnum; | 1057 | as->ifnum = ifnum; |
991 | as->task = current; | 1058 | as->pid = current->pid; |
1059 | as->uid = current->uid; | ||
1060 | as->euid = current->euid; | ||
992 | if (!(uurb->endpoint & USB_DIR_IN)) { | 1061 | if (!(uurb->endpoint & USB_DIR_IN)) { |
993 | if (copy_from_user(as->urb->transfer_buffer, uurb->buffer, as->urb->transfer_buffer_length)) { | 1062 | if (copy_from_user(as->urb->transfer_buffer, uurb->buffer, as->urb->transfer_buffer_length)) { |
994 | free_async(as); | 1063 | free_async(as); |
995 | return -EFAULT; | 1064 | return -EFAULT; |
996 | } | 1065 | } |
997 | } | 1066 | } |
1067 | snoop(&as->urb->dev->dev, "submit urb\n"); | ||
1068 | snoop_urb(as->urb, as->userurb); | ||
998 | async_newpending(as); | 1069 | async_newpending(as); |
999 | if ((ret = usb_submit_urb(as->urb, GFP_KERNEL))) { | 1070 | if ((ret = usb_submit_urb(as->urb, GFP_KERNEL))) { |
1000 | dev_printk(KERN_DEBUG, &ps->dev->dev, "usbfs: usb_submit_urb returned %d\n", ret); | 1071 | dev_printk(KERN_DEBUG, &ps->dev->dev, "usbfs: usb_submit_urb returned %d\n", ret); |
@@ -1230,23 +1301,20 @@ static int proc_releaseinterface(struct dev_state *ps, void __user *arg) | |||
1230 | return 0; | 1301 | return 0; |
1231 | } | 1302 | } |
1232 | 1303 | ||
1233 | static int proc_ioctl (struct dev_state *ps, void __user *arg) | 1304 | static int proc_ioctl(struct dev_state *ps, struct usbdevfs_ioctl *ctl) |
1234 | { | 1305 | { |
1235 | struct usbdevfs_ioctl ctrl; | ||
1236 | int size; | 1306 | int size; |
1237 | void *buf = NULL; | 1307 | void *buf = NULL; |
1238 | int retval = 0; | 1308 | int retval = 0; |
1239 | struct usb_interface *intf = NULL; | 1309 | struct usb_interface *intf = NULL; |
1240 | struct usb_driver *driver = NULL; | 1310 | struct usb_driver *driver = NULL; |
1241 | 1311 | ||
1242 | /* get input parameters and alloc buffer */ | 1312 | /* alloc buffer */ |
1243 | if (copy_from_user(&ctrl, arg, sizeof (ctrl))) | 1313 | if ((size = _IOC_SIZE (ctl->ioctl_code)) > 0) { |
1244 | return -EFAULT; | ||
1245 | if ((size = _IOC_SIZE (ctrl.ioctl_code)) > 0) { | ||
1246 | if ((buf = kmalloc (size, GFP_KERNEL)) == NULL) | 1314 | if ((buf = kmalloc (size, GFP_KERNEL)) == NULL) |
1247 | return -ENOMEM; | 1315 | return -ENOMEM; |
1248 | if ((_IOC_DIR(ctrl.ioctl_code) & _IOC_WRITE)) { | 1316 | if ((_IOC_DIR(ctl->ioctl_code) & _IOC_WRITE)) { |
1249 | if (copy_from_user (buf, ctrl.data, size)) { | 1317 | if (copy_from_user (buf, ctl->data, size)) { |
1250 | kfree(buf); | 1318 | kfree(buf); |
1251 | return -EFAULT; | 1319 | return -EFAULT; |
1252 | } | 1320 | } |
@@ -1262,9 +1330,9 @@ static int proc_ioctl (struct dev_state *ps, void __user *arg) | |||
1262 | 1330 | ||
1263 | if (ps->dev->state != USB_STATE_CONFIGURED) | 1331 | if (ps->dev->state != USB_STATE_CONFIGURED) |
1264 | retval = -EHOSTUNREACH; | 1332 | retval = -EHOSTUNREACH; |
1265 | else if (!(intf = usb_ifnum_to_if (ps->dev, ctrl.ifno))) | 1333 | else if (!(intf = usb_ifnum_to_if (ps->dev, ctl->ifno))) |
1266 | retval = -EINVAL; | 1334 | retval = -EINVAL; |
1267 | else switch (ctrl.ioctl_code) { | 1335 | else switch (ctl->ioctl_code) { |
1268 | 1336 | ||
1269 | /* disconnect kernel driver from interface */ | 1337 | /* disconnect kernel driver from interface */ |
1270 | case USBDEVFS_DISCONNECT: | 1338 | case USBDEVFS_DISCONNECT: |
@@ -1296,7 +1364,7 @@ static int proc_ioctl (struct dev_state *ps, void __user *arg) | |||
1296 | if (driver == NULL || driver->ioctl == NULL) { | 1364 | if (driver == NULL || driver->ioctl == NULL) { |
1297 | retval = -ENOTTY; | 1365 | retval = -ENOTTY; |
1298 | } else { | 1366 | } else { |
1299 | retval = driver->ioctl (intf, ctrl.ioctl_code, buf); | 1367 | retval = driver->ioctl (intf, ctl->ioctl_code, buf); |
1300 | if (retval == -ENOIOCTLCMD) | 1368 | if (retval == -ENOIOCTLCMD) |
1301 | retval = -ENOTTY; | 1369 | retval = -ENOTTY; |
1302 | } | 1370 | } |
@@ -1305,15 +1373,42 @@ static int proc_ioctl (struct dev_state *ps, void __user *arg) | |||
1305 | 1373 | ||
1306 | /* cleanup and return */ | 1374 | /* cleanup and return */ |
1307 | if (retval >= 0 | 1375 | if (retval >= 0 |
1308 | && (_IOC_DIR (ctrl.ioctl_code) & _IOC_READ) != 0 | 1376 | && (_IOC_DIR (ctl->ioctl_code) & _IOC_READ) != 0 |
1309 | && size > 0 | 1377 | && size > 0 |
1310 | && copy_to_user (ctrl.data, buf, size) != 0) | 1378 | && copy_to_user (ctl->data, buf, size) != 0) |
1311 | retval = -EFAULT; | 1379 | retval = -EFAULT; |
1312 | 1380 | ||
1313 | kfree(buf); | 1381 | kfree(buf); |
1314 | return retval; | 1382 | return retval; |
1315 | } | 1383 | } |
1316 | 1384 | ||
1385 | static int proc_ioctl_default(struct dev_state *ps, void __user *arg) | ||
1386 | { | ||
1387 | struct usbdevfs_ioctl ctrl; | ||
1388 | |||
1389 | if (copy_from_user(&ctrl, arg, sizeof (ctrl))) | ||
1390 | return -EFAULT; | ||
1391 | return proc_ioctl(ps, &ctrl); | ||
1392 | } | ||
1393 | |||
1394 | #ifdef CONFIG_COMPAT | ||
1395 | static int proc_ioctl_compat(struct dev_state *ps, compat_uptr_t arg) | ||
1396 | { | ||
1397 | struct usbdevfs_ioctl32 __user *uioc; | ||
1398 | struct usbdevfs_ioctl ctrl; | ||
1399 | u32 udata; | ||
1400 | |||
1401 | uioc = compat_ptr((long)arg); | ||
1402 | if (get_user(ctrl.ifno, &uioc->ifno) || | ||
1403 | get_user(ctrl.ioctl_code, &uioc->ioctl_code) || | ||
1404 | __get_user(udata, &uioc->data)) | ||
1405 | return -EFAULT; | ||
1406 | ctrl.data = compat_ptr(udata); | ||
1407 | |||
1408 | return proc_ioctl(ps, &ctrl); | ||
1409 | } | ||
1410 | #endif | ||
1411 | |||
1317 | /* | 1412 | /* |
1318 | * NOTE: All requests here that have interface numbers as parameters | 1413 | * NOTE: All requests here that have interface numbers as parameters |
1319 | * are assuming that somehow the configuration has been prevented from | 1414 | * are assuming that somehow the configuration has been prevented from |
@@ -1414,6 +1509,10 @@ static int usbdev_ioctl(struct inode *inode, struct file *file, unsigned int cmd | |||
1414 | ret = proc_reapurbnonblock_compat(ps, p); | 1509 | ret = proc_reapurbnonblock_compat(ps, p); |
1415 | break; | 1510 | break; |
1416 | 1511 | ||
1512 | case USBDEVFS_IOCTL32: | ||
1513 | snoop(&dev->dev, "%s: IOCTL\n", __FUNCTION__); | ||
1514 | ret = proc_ioctl_compat(ps, (compat_uptr_t)(long)p); | ||
1515 | break; | ||
1417 | #endif | 1516 | #endif |
1418 | 1517 | ||
1419 | case USBDEVFS_DISCARDURB: | 1518 | case USBDEVFS_DISCARDURB: |
@@ -1448,7 +1547,7 @@ static int usbdev_ioctl(struct inode *inode, struct file *file, unsigned int cmd | |||
1448 | 1547 | ||
1449 | case USBDEVFS_IOCTL: | 1548 | case USBDEVFS_IOCTL: |
1450 | snoop(&dev->dev, "%s: IOCTL\n", __FUNCTION__); | 1549 | snoop(&dev->dev, "%s: IOCTL\n", __FUNCTION__); |
1451 | ret = proc_ioctl(ps, p); | 1550 | ret = proc_ioctl_default(ps, p); |
1452 | break; | 1551 | break; |
1453 | } | 1552 | } |
1454 | usb_unlock_device(dev); | 1553 | usb_unlock_device(dev); |
@@ -1480,39 +1579,40 @@ struct file_operations usbfs_device_file_operations = { | |||
1480 | .release = usbdev_release, | 1579 | .release = usbdev_release, |
1481 | }; | 1580 | }; |
1482 | 1581 | ||
1483 | struct usb_device *usbdev_lookup_minor(int minor) | 1582 | static void usbdev_add(struct usb_device *dev) |
1484 | { | ||
1485 | struct class_device *class_dev; | ||
1486 | struct usb_device *dev = NULL; | ||
1487 | |||
1488 | down(&usb_device_class->sem); | ||
1489 | list_for_each_entry(class_dev, &usb_device_class->children, node) { | ||
1490 | if (class_dev->devt == MKDEV(USB_DEVICE_MAJOR, minor)) { | ||
1491 | dev = class_dev->class_data; | ||
1492 | break; | ||
1493 | } | ||
1494 | } | ||
1495 | up(&usb_device_class->sem); | ||
1496 | |||
1497 | return dev; | ||
1498 | }; | ||
1499 | |||
1500 | void usbdev_add(struct usb_device *dev) | ||
1501 | { | 1583 | { |
1502 | int minor = ((dev->bus->busnum-1) * 128) + (dev->devnum-1); | 1584 | int minor = ((dev->bus->busnum-1) * 128) + (dev->devnum-1); |
1503 | 1585 | ||
1504 | dev->class_dev = class_device_create(usb_device_class, | 1586 | dev->class_dev = class_device_create(usb_device_class, NULL, |
1505 | MKDEV(USB_DEVICE_MAJOR, minor), &dev->dev, | 1587 | MKDEV(USB_DEVICE_MAJOR, minor), &dev->dev, |
1506 | "usbdev%d.%d", dev->bus->busnum, dev->devnum); | 1588 | "usbdev%d.%d", dev->bus->busnum, dev->devnum); |
1507 | 1589 | ||
1508 | dev->class_dev->class_data = dev; | 1590 | dev->class_dev->class_data = dev; |
1509 | } | 1591 | } |
1510 | 1592 | ||
1511 | void usbdev_remove(struct usb_device *dev) | 1593 | static void usbdev_remove(struct usb_device *dev) |
1512 | { | 1594 | { |
1513 | class_device_unregister(dev->class_dev); | 1595 | class_device_unregister(dev->class_dev); |
1514 | } | 1596 | } |
1515 | 1597 | ||
1598 | static int usbdev_notify(struct notifier_block *self, unsigned long action, | ||
1599 | void *dev) | ||
1600 | { | ||
1601 | switch (action) { | ||
1602 | case USB_DEVICE_ADD: | ||
1603 | usbdev_add(dev); | ||
1604 | break; | ||
1605 | case USB_DEVICE_REMOVE: | ||
1606 | usbdev_remove(dev); | ||
1607 | break; | ||
1608 | } | ||
1609 | return NOTIFY_OK; | ||
1610 | } | ||
1611 | |||
1612 | static struct notifier_block usbdev_nb = { | ||
1613 | .notifier_call = usbdev_notify, | ||
1614 | }; | ||
1615 | |||
1516 | static struct cdev usb_device_cdev = { | 1616 | static struct cdev usb_device_cdev = { |
1517 | .kobj = {.name = "usb_device", }, | 1617 | .kobj = {.name = "usb_device", }, |
1518 | .owner = THIS_MODULE, | 1618 | .owner = THIS_MODULE, |
@@ -1532,24 +1632,32 @@ int __init usbdev_init(void) | |||
1532 | retval = cdev_add(&usb_device_cdev, USB_DEVICE_DEV, USB_DEVICE_MAX); | 1632 | retval = cdev_add(&usb_device_cdev, USB_DEVICE_DEV, USB_DEVICE_MAX); |
1533 | if (retval) { | 1633 | if (retval) { |
1534 | err("unable to get usb_device major %d", USB_DEVICE_MAJOR); | 1634 | err("unable to get usb_device major %d", USB_DEVICE_MAJOR); |
1535 | unregister_chrdev_region(USB_DEVICE_DEV, USB_DEVICE_MAX); | 1635 | goto error_cdev; |
1536 | goto out; | ||
1537 | } | 1636 | } |
1538 | usb_device_class = class_create(THIS_MODULE, "usb_device"); | 1637 | usb_device_class = class_create(THIS_MODULE, "usb_device"); |
1539 | if (IS_ERR(usb_device_class)) { | 1638 | if (IS_ERR(usb_device_class)) { |
1540 | err("unable to register usb_device class"); | 1639 | err("unable to register usb_device class"); |
1541 | retval = PTR_ERR(usb_device_class); | 1640 | retval = PTR_ERR(usb_device_class); |
1542 | usb_device_class = NULL; | 1641 | goto error_class; |
1543 | cdev_del(&usb_device_cdev); | ||
1544 | unregister_chrdev_region(USB_DEVICE_DEV, USB_DEVICE_MAX); | ||
1545 | } | 1642 | } |
1546 | 1643 | ||
1644 | usb_register_notify(&usbdev_nb); | ||
1645 | |||
1547 | out: | 1646 | out: |
1548 | return retval; | 1647 | return retval; |
1648 | |||
1649 | error_class: | ||
1650 | usb_device_class = NULL; | ||
1651 | cdev_del(&usb_device_cdev); | ||
1652 | |||
1653 | error_cdev: | ||
1654 | unregister_chrdev_region(USB_DEVICE_DEV, USB_DEVICE_MAX); | ||
1655 | goto out; | ||
1549 | } | 1656 | } |
1550 | 1657 | ||
1551 | void usbdev_cleanup(void) | 1658 | void usbdev_cleanup(void) |
1552 | { | 1659 | { |
1660 | usb_unregister_notify(&usbdev_nb); | ||
1553 | class_destroy(usb_device_class); | 1661 | class_destroy(usb_device_class); |
1554 | cdev_del(&usb_device_cdev); | 1662 | cdev_del(&usb_device_cdev); |
1555 | unregister_chrdev_region(USB_DEVICE_DEV, USB_DEVICE_MAX); | 1663 | unregister_chrdev_region(USB_DEVICE_DEV, USB_DEVICE_MAX); |
diff --git a/drivers/usb/core/file.c b/drivers/usb/core/file.c index 65ca131cc44c..37b13368c814 100644 --- a/drivers/usb/core/file.c +++ b/drivers/usb/core/file.c | |||
@@ -17,15 +17,8 @@ | |||
17 | 17 | ||
18 | #include <linux/config.h> | 18 | #include <linux/config.h> |
19 | #include <linux/module.h> | 19 | #include <linux/module.h> |
20 | #include <linux/devfs_fs_kernel.h> | ||
21 | #include <linux/spinlock.h> | 20 | #include <linux/spinlock.h> |
22 | #include <linux/errno.h> | 21 | #include <linux/errno.h> |
23 | |||
24 | #ifdef CONFIG_USB_DEBUG | ||
25 | #define DEBUG | ||
26 | #else | ||
27 | #undef DEBUG | ||
28 | #endif | ||
29 | #include <linux/usb.h> | 22 | #include <linux/usb.h> |
30 | 23 | ||
31 | #include "usb.h" | 24 | #include "usb.h" |
@@ -88,8 +81,6 @@ int usb_major_init(void) | |||
88 | goto out; | 81 | goto out; |
89 | } | 82 | } |
90 | 83 | ||
91 | devfs_mk_dir("usb"); | ||
92 | |||
93 | out: | 84 | out: |
94 | return error; | 85 | return error; |
95 | } | 86 | } |
@@ -97,7 +88,6 @@ out: | |||
97 | void usb_major_cleanup(void) | 88 | void usb_major_cleanup(void) |
98 | { | 89 | { |
99 | class_destroy(usb_class); | 90 | class_destroy(usb_class); |
100 | devfs_remove("usb"); | ||
101 | unregister_chrdev(USB_MAJOR, "usb"); | 91 | unregister_chrdev(USB_MAJOR, "usb"); |
102 | } | 92 | } |
103 | 93 | ||
@@ -112,8 +102,7 @@ void usb_major_cleanup(void) | |||
112 | * enabled, the minor number will be based on the next available free minor, | 102 | * enabled, the minor number will be based on the next available free minor, |
113 | * starting at the class_driver->minor_base. | 103 | * starting at the class_driver->minor_base. |
114 | * | 104 | * |
115 | * This function also creates the devfs file for the usb device, if devfs | 105 | * This function also creates a usb class device in the sysfs tree. |
116 | * is enabled, and creates a usb class device in the sysfs tree. | ||
117 | * | 106 | * |
118 | * usb_deregister_dev() must be called when the driver is done with | 107 | * usb_deregister_dev() must be called when the driver is done with |
119 | * the minor numbers given out by this function. | 108 | * the minor numbers given out by this function. |
@@ -162,22 +151,20 @@ int usb_register_dev(struct usb_interface *intf, | |||
162 | 151 | ||
163 | intf->minor = minor; | 152 | intf->minor = minor; |
164 | 153 | ||
165 | /* handle the devfs registration */ | ||
166 | snprintf(name, BUS_ID_SIZE, class_driver->name, minor - minor_base); | ||
167 | devfs_mk_cdev(MKDEV(USB_MAJOR, minor), class_driver->mode, name); | ||
168 | |||
169 | /* create a usb class device for this usb interface */ | 154 | /* create a usb class device for this usb interface */ |
155 | snprintf(name, BUS_ID_SIZE, class_driver->name, minor - minor_base); | ||
170 | temp = strrchr(name, '/'); | 156 | temp = strrchr(name, '/'); |
171 | if (temp && (temp[1] != 0x00)) | 157 | if (temp && (temp[1] != 0x00)) |
172 | ++temp; | 158 | ++temp; |
173 | else | 159 | else |
174 | temp = name; | 160 | temp = name; |
175 | intf->class_dev = class_device_create(usb_class, MKDEV(USB_MAJOR, minor), &intf->dev, "%s", temp); | 161 | intf->class_dev = class_device_create(usb_class, NULL, |
162 | MKDEV(USB_MAJOR, minor), | ||
163 | &intf->dev, "%s", temp); | ||
176 | if (IS_ERR(intf->class_dev)) { | 164 | if (IS_ERR(intf->class_dev)) { |
177 | spin_lock (&minor_lock); | 165 | spin_lock (&minor_lock); |
178 | usb_minors[intf->minor] = NULL; | 166 | usb_minors[intf->minor] = NULL; |
179 | spin_unlock (&minor_lock); | 167 | spin_unlock (&minor_lock); |
180 | devfs_remove (name); | ||
181 | retval = PTR_ERR(intf->class_dev); | 168 | retval = PTR_ERR(intf->class_dev); |
182 | } | 169 | } |
183 | exit: | 170 | exit: |
@@ -195,9 +182,8 @@ EXPORT_SYMBOL(usb_register_dev); | |||
195 | * call to usb_register_dev() (usually when the device is disconnected | 182 | * call to usb_register_dev() (usually when the device is disconnected |
196 | * from the system.) | 183 | * from the system.) |
197 | * | 184 | * |
198 | * This function also cleans up the devfs file for the usb device, if devfs | 185 | * This function also removes the usb class device from the sysfs tree. |
199 | * is enabled, and removes the usb class device from the sysfs tree. | 186 | * |
200 | * | ||
201 | * This should be called by all drivers that use the USB major number. | 187 | * This should be called by all drivers that use the USB major number. |
202 | */ | 188 | */ |
203 | void usb_deregister_dev(struct usb_interface *intf, | 189 | void usb_deregister_dev(struct usb_interface *intf, |
@@ -220,7 +206,6 @@ void usb_deregister_dev(struct usb_interface *intf, | |||
220 | spin_unlock (&minor_lock); | 206 | spin_unlock (&minor_lock); |
221 | 207 | ||
222 | snprintf(name, BUS_ID_SIZE, class_driver->name, intf->minor - minor_base); | 208 | snprintf(name, BUS_ID_SIZE, class_driver->name, intf->minor - minor_base); |
223 | devfs_remove (name); | ||
224 | class_device_destroy(usb_class, MKDEV(USB_MAJOR, intf->minor)); | 209 | class_device_destroy(usb_class, MKDEV(USB_MAJOR, intf->minor)); |
225 | intf->class_dev = NULL; | 210 | intf->class_dev = NULL; |
226 | intf->minor = -1; | 211 | intf->minor = -1; |
diff --git a/drivers/usb/core/hcd-pci.c b/drivers/usb/core/hcd-pci.c index cbb451d227d2..29b5b2a6e183 100644 --- a/drivers/usb/core/hcd-pci.c +++ b/drivers/usb/core/hcd-pci.c | |||
@@ -17,19 +17,22 @@ | |||
17 | */ | 17 | */ |
18 | 18 | ||
19 | #include <linux/config.h> | 19 | #include <linux/config.h> |
20 | |||
21 | #ifdef CONFIG_USB_DEBUG | ||
22 | #define DEBUG | ||
23 | #else | ||
24 | #undef DEBUG | ||
25 | #endif | ||
26 | |||
27 | #include <linux/kernel.h> | 20 | #include <linux/kernel.h> |
28 | #include <linux/module.h> | 21 | #include <linux/module.h> |
29 | #include <linux/pci.h> | 22 | #include <linux/pci.h> |
23 | #include <linux/usb.h> | ||
24 | |||
30 | #include <asm/io.h> | 25 | #include <asm/io.h> |
31 | #include <asm/irq.h> | 26 | #include <asm/irq.h> |
32 | #include <linux/usb.h> | 27 | |
28 | #ifdef CONFIG_PPC_PMAC | ||
29 | #include <asm/machdep.h> | ||
30 | #include <asm/pmac_feature.h> | ||
31 | #include <asm/pci-bridge.h> | ||
32 | #include <asm/prom.h> | ||
33 | #endif | ||
34 | |||
35 | #include "usb.h" | ||
33 | #include "hcd.h" | 36 | #include "hcd.h" |
34 | 37 | ||
35 | 38 | ||
@@ -197,6 +200,27 @@ int usb_hcd_pci_suspend (struct pci_dev *dev, pm_message_t message) | |||
197 | 200 | ||
198 | hcd = pci_get_drvdata(dev); | 201 | hcd = pci_get_drvdata(dev); |
199 | 202 | ||
203 | /* Root hub suspend should have stopped all downstream traffic, | ||
204 | * and all bus master traffic. And done so for both the interface | ||
205 | * and the stub usb_device (which we check here). But maybe it | ||
206 | * didn't; writing sysfs power/state files ignores such rules... | ||
207 | * | ||
208 | * We must ignore the FREEZE vs SUSPEND distinction here, because | ||
209 | * otherwise the swsusp will save (and restore) garbage state. | ||
210 | */ | ||
211 | if (hcd->self.root_hub->dev.power.power_state.event == PM_EVENT_ON) | ||
212 | return -EBUSY; | ||
213 | |||
214 | if (hcd->driver->suspend) { | ||
215 | retval = hcd->driver->suspend(hcd, message); | ||
216 | if (retval) { | ||
217 | dev_dbg (&dev->dev, "PCI pre-suspend fail, %d\n", | ||
218 | retval); | ||
219 | goto done; | ||
220 | } | ||
221 | } | ||
222 | synchronize_irq(dev->irq); | ||
223 | |||
200 | /* FIXME until the generic PM interfaces change a lot more, this | 224 | /* FIXME until the generic PM interfaces change a lot more, this |
201 | * can't use PCI D1 and D2 states. For example, the confusion | 225 | * can't use PCI D1 and D2 states. For example, the confusion |
202 | * between messages and states will need to vanish, and messages | 226 | * between messages and states will need to vanish, and messages |
@@ -215,41 +239,22 @@ int usb_hcd_pci_suspend (struct pci_dev *dev, pm_message_t message) | |||
215 | */ | 239 | */ |
216 | has_pci_pm = pci_find_capability(dev, PCI_CAP_ID_PM); | 240 | has_pci_pm = pci_find_capability(dev, PCI_CAP_ID_PM); |
217 | 241 | ||
218 | switch (hcd->state) { | 242 | /* Downstream ports from this root hub should already be quiesced, so |
219 | 243 | * there will be no DMA activity. Now we can shut down the upstream | |
220 | /* entry if root hub wasn't yet suspended ... from sysfs, | 244 | * link (except maybe for PME# resume signaling) and enter some PCI |
221 | * without autosuspend, or if USB_SUSPEND isn't configured. | 245 | * low power state, if the hardware allows. |
222 | */ | 246 | */ |
223 | case HC_STATE_RUNNING: | 247 | if (hcd->state == HC_STATE_SUSPENDED) { |
224 | hcd->state = HC_STATE_QUIESCING; | ||
225 | retval = hcd->driver->suspend (hcd, message); | ||
226 | if (retval) { | ||
227 | dev_dbg (hcd->self.controller, | ||
228 | "suspend fail, retval %d\n", | ||
229 | retval); | ||
230 | break; | ||
231 | } | ||
232 | hcd->state = HC_STATE_SUSPENDED; | ||
233 | /* FALLTHROUGH */ | ||
234 | 248 | ||
235 | /* entry with CONFIG_USB_SUSPEND, or hcds that autosuspend: the | ||
236 | * controller and/or root hub will already have been suspended, | ||
237 | * but it won't be ready for a PCI resume call. | ||
238 | * | ||
239 | * FIXME only CONFIG_USB_SUSPEND guarantees hub_suspend() will | ||
240 | * have been called, otherwise root hub timers still run ... | ||
241 | */ | ||
242 | case HC_STATE_SUSPENDED: | ||
243 | /* no DMA or IRQs except when HC is active */ | 249 | /* no DMA or IRQs except when HC is active */ |
244 | if (dev->current_state == PCI_D0) { | 250 | if (dev->current_state == PCI_D0) { |
245 | free_irq (hcd->irq, hcd); | ||
246 | pci_save_state (dev); | 251 | pci_save_state (dev); |
247 | pci_disable_device (dev); | 252 | pci_disable_device (dev); |
248 | } | 253 | } |
249 | 254 | ||
250 | if (!has_pci_pm) { | 255 | if (!has_pci_pm) { |
251 | dev_dbg (hcd->self.controller, "--> PCI D0/legacy\n"); | 256 | dev_dbg (hcd->self.controller, "--> PCI D0/legacy\n"); |
252 | break; | 257 | goto done; |
253 | } | 258 | } |
254 | 259 | ||
255 | /* NOTE: dev->current_state becomes nonzero only here, and | 260 | /* NOTE: dev->current_state becomes nonzero only here, and |
@@ -260,28 +265,43 @@ int usb_hcd_pci_suspend (struct pci_dev *dev, pm_message_t message) | |||
260 | retval = pci_set_power_state (dev, PCI_D3hot); | 265 | retval = pci_set_power_state (dev, PCI_D3hot); |
261 | if (retval == 0) { | 266 | if (retval == 0) { |
262 | dev_dbg (hcd->self.controller, "--> PCI D3\n"); | 267 | dev_dbg (hcd->self.controller, "--> PCI D3\n"); |
263 | retval = pci_enable_wake (dev, PCI_D3hot, hcd->remote_wakeup); | 268 | |
264 | if (retval) | 269 | /* Ignore these return values. We rely on pci code to |
265 | break; | 270 | * reject requests the hardware can't implement, rather |
266 | retval = pci_enable_wake (dev, PCI_D3cold, hcd->remote_wakeup); | 271 | * than coding the same thing. |
267 | } else if (retval < 0) { | 272 | */ |
273 | (void) pci_enable_wake (dev, PCI_D3hot, hcd->remote_wakeup); | ||
274 | (void) pci_enable_wake (dev, PCI_D3cold, hcd->remote_wakeup); | ||
275 | } else { | ||
268 | dev_dbg (&dev->dev, "PCI D3 suspend fail, %d\n", | 276 | dev_dbg (&dev->dev, "PCI D3 suspend fail, %d\n", |
269 | retval); | 277 | retval); |
270 | (void) usb_hcd_pci_resume (dev); | 278 | (void) usb_hcd_pci_resume (dev); |
271 | break; | ||
272 | } | 279 | } |
273 | break; | 280 | |
274 | default: | 281 | } else { |
275 | dev_dbg (hcd->self.controller, "hcd state %d; not suspended\n", | 282 | dev_dbg (hcd->self.controller, "hcd state %d; not suspended\n", |
276 | hcd->state); | 283 | hcd->state); |
277 | WARN_ON(1); | 284 | WARN_ON(1); |
278 | retval = -EINVAL; | 285 | retval = -EINVAL; |
279 | break; | ||
280 | } | 286 | } |
281 | 287 | ||
282 | /* update power_state **ONLY** to make sysfs happier */ | 288 | done: |
283 | if (retval == 0) | 289 | if (retval == 0) { |
284 | dev->dev.power.power_state = message; | 290 | dev->dev.power.power_state = PMSG_SUSPEND; |
291 | |||
292 | #ifdef CONFIG_PPC_PMAC | ||
293 | /* Disable ASIC clocks for USB */ | ||
294 | if (_machine == _MACH_Pmac) { | ||
295 | struct device_node *of_node; | ||
296 | |||
297 | of_node = pci_device_to_OF_node (dev); | ||
298 | if (of_node) | ||
299 | pmac_call_feature(PMAC_FTR_USB_ENABLE, | ||
300 | of_node, 0, 0); | ||
301 | } | ||
302 | #endif | ||
303 | } | ||
304 | |||
285 | return retval; | 305 | return retval; |
286 | } | 306 | } |
287 | EXPORT_SYMBOL (usb_hcd_pci_suspend); | 307 | EXPORT_SYMBOL (usb_hcd_pci_suspend); |
@@ -304,6 +324,18 @@ int usb_hcd_pci_resume (struct pci_dev *dev) | |||
304 | return 0; | 324 | return 0; |
305 | } | 325 | } |
306 | 326 | ||
327 | #ifdef CONFIG_PPC_PMAC | ||
328 | /* Reenable ASIC clocks for USB */ | ||
329 | if (_machine == _MACH_Pmac) { | ||
330 | struct device_node *of_node; | ||
331 | |||
332 | of_node = pci_device_to_OF_node (dev); | ||
333 | if (of_node) | ||
334 | pmac_call_feature (PMAC_FTR_USB_ENABLE, | ||
335 | of_node, 0, 1); | ||
336 | } | ||
337 | #endif | ||
338 | |||
307 | /* NOTE: chip docs cover clean "real suspend" cases (what Linux | 339 | /* NOTE: chip docs cover clean "real suspend" cases (what Linux |
308 | * calls "standby", "suspend to RAM", and so on). There are also | 340 | * calls "standby", "suspend to RAM", and so on). There are also |
309 | * dirty cases when swsusp fakes a suspend in "shutdown" mode. | 341 | * dirty cases when swsusp fakes a suspend in "shutdown" mode. |
@@ -337,20 +369,9 @@ int usb_hcd_pci_resume (struct pci_dev *dev) | |||
337 | dev->current_state); | 369 | dev->current_state); |
338 | } | 370 | } |
339 | #endif | 371 | #endif |
340 | retval = pci_enable_wake (dev, dev->current_state, 0); | 372 | /* yes, ignore these results too... */ |
341 | if (retval) { | 373 | (void) pci_enable_wake (dev, dev->current_state, 0); |
342 | dev_err(hcd->self.controller, | 374 | (void) pci_enable_wake (dev, PCI_D3cold, 0); |
343 | "can't enable_wake to %d, %d!\n", | ||
344 | dev->current_state, retval); | ||
345 | return retval; | ||
346 | } | ||
347 | retval = pci_enable_wake (dev, PCI_D3cold, 0); | ||
348 | if (retval) { | ||
349 | dev_err(hcd->self.controller, | ||
350 | "can't enable_wake to %d, %d!\n", | ||
351 | PCI_D3cold, retval); | ||
352 | return retval; | ||
353 | } | ||
354 | } else { | 375 | } else { |
355 | /* Same basic cases: clean (powered/not), dirty */ | 376 | /* Same basic cases: clean (powered/not), dirty */ |
356 | dev_dbg(hcd->self.controller, "PCI legacy resume\n"); | 377 | dev_dbg(hcd->self.controller, "PCI legacy resume\n"); |
@@ -372,25 +393,17 @@ int usb_hcd_pci_resume (struct pci_dev *dev) | |||
372 | 393 | ||
373 | dev->dev.power.power_state = PMSG_ON; | 394 | dev->dev.power.power_state = PMSG_ON; |
374 | 395 | ||
375 | hcd->state = HC_STATE_RESUMING; | 396 | clear_bit(HCD_FLAG_SAW_IRQ, &hcd->flags); |
376 | hcd->saw_irq = 0; | ||
377 | retval = request_irq (dev->irq, usb_hcd_irq, SA_SHIRQ, | ||
378 | hcd->irq_descr, hcd); | ||
379 | if (retval < 0) { | ||
380 | dev_err (hcd->self.controller, | ||
381 | "can't restore IRQ after resume!\n"); | ||
382 | usb_hc_died (hcd); | ||
383 | return retval; | ||
384 | } | ||
385 | 397 | ||
386 | retval = hcd->driver->resume (hcd); | 398 | if (hcd->driver->resume) { |
387 | if (!HC_IS_RUNNING (hcd->state)) { | 399 | retval = hcd->driver->resume(hcd); |
388 | dev_dbg (hcd->self.controller, | 400 | if (retval) { |
389 | "resume fail, retval %d\n", retval); | 401 | dev_err (hcd->self.controller, |
390 | usb_hc_died (hcd); | 402 | "PCI post-resume error %d!\n", retval); |
403 | usb_hc_died (hcd); | ||
404 | } | ||
391 | } | 405 | } |
392 | 406 | ||
393 | retval = pci_enable_device(dev); | ||
394 | return retval; | 407 | return retval; |
395 | } | 408 | } |
396 | EXPORT_SYMBOL (usb_hcd_pci_resume); | 409 | EXPORT_SYMBOL (usb_hcd_pci_resume); |
diff --git a/drivers/usb/core/hcd.c b/drivers/usb/core/hcd.c index 1017a97a418b..da24c31ee00d 100644 --- a/drivers/usb/core/hcd.c +++ b/drivers/usb/core/hcd.c | |||
@@ -23,11 +23,6 @@ | |||
23 | */ | 23 | */ |
24 | 24 | ||
25 | #include <linux/config.h> | 25 | #include <linux/config.h> |
26 | |||
27 | #ifdef CONFIG_USB_DEBUG | ||
28 | #define DEBUG | ||
29 | #endif | ||
30 | |||
31 | #include <linux/module.h> | 26 | #include <linux/module.h> |
32 | #include <linux/version.h> | 27 | #include <linux/version.h> |
33 | #include <linux/kernel.h> | 28 | #include <linux/kernel.h> |
@@ -130,7 +125,7 @@ static const u8 usb2_rh_dev_descriptor [18] = { | |||
130 | 0x09, /* __u8 bDeviceClass; HUB_CLASSCODE */ | 125 | 0x09, /* __u8 bDeviceClass; HUB_CLASSCODE */ |
131 | 0x00, /* __u8 bDeviceSubClass; */ | 126 | 0x00, /* __u8 bDeviceSubClass; */ |
132 | 0x01, /* __u8 bDeviceProtocol; [ usb 2.0 single TT ]*/ | 127 | 0x01, /* __u8 bDeviceProtocol; [ usb 2.0 single TT ]*/ |
133 | 0x08, /* __u8 bMaxPacketSize0; 8 Bytes */ | 128 | 0x40, /* __u8 bMaxPacketSize0; 64 Bytes */ |
134 | 129 | ||
135 | 0x00, 0x00, /* __le16 idVendor; */ | 130 | 0x00, 0x00, /* __le16 idVendor; */ |
136 | 0x00, 0x00, /* __le16 idProduct; */ | 131 | 0x00, 0x00, /* __le16 idProduct; */ |
@@ -153,7 +148,7 @@ static const u8 usb11_rh_dev_descriptor [18] = { | |||
153 | 0x09, /* __u8 bDeviceClass; HUB_CLASSCODE */ | 148 | 0x09, /* __u8 bDeviceClass; HUB_CLASSCODE */ |
154 | 0x00, /* __u8 bDeviceSubClass; */ | 149 | 0x00, /* __u8 bDeviceSubClass; */ |
155 | 0x00, /* __u8 bDeviceProtocol; [ low/full speeds only ] */ | 150 | 0x00, /* __u8 bDeviceProtocol; [ low/full speeds only ] */ |
156 | 0x08, /* __u8 bMaxPacketSize0; 8 Bytes */ | 151 | 0x40, /* __u8 bMaxPacketSize0; 64 Bytes */ |
157 | 152 | ||
158 | 0x00, 0x00, /* __le16 idVendor; */ | 153 | 0x00, 0x00, /* __le16 idVendor; */ |
159 | 0x00, 0x00, /* __le16 idProduct; */ | 154 | 0x00, 0x00, /* __le16 idProduct; */ |
@@ -458,22 +453,18 @@ static int rh_call_control (struct usb_hcd *hcd, struct urb *urb) | |||
458 | 453 | ||
459 | default: | 454 | default: |
460 | /* non-generic request */ | 455 | /* non-generic request */ |
461 | if (HC_IS_SUSPENDED (hcd->state)) | 456 | switch (typeReq) { |
462 | status = -EAGAIN; | 457 | case GetHubStatus: |
463 | else { | 458 | case GetPortStatus: |
464 | switch (typeReq) { | 459 | len = 4; |
465 | case GetHubStatus: | 460 | break; |
466 | case GetPortStatus: | 461 | case GetHubDescriptor: |
467 | len = 4; | 462 | len = sizeof (struct usb_hub_descriptor); |
468 | break; | 463 | break; |
469 | case GetHubDescriptor: | ||
470 | len = sizeof (struct usb_hub_descriptor); | ||
471 | break; | ||
472 | } | ||
473 | status = hcd->driver->hub_control (hcd, | ||
474 | typeReq, wValue, wIndex, | ||
475 | tbuf, wLength); | ||
476 | } | 464 | } |
465 | status = hcd->driver->hub_control (hcd, | ||
466 | typeReq, wValue, wIndex, | ||
467 | tbuf, wLength); | ||
477 | break; | 468 | break; |
478 | error: | 469 | error: |
479 | /* "protocol stall" on error */ | 470 | /* "protocol stall" on error */ |
@@ -487,7 +478,7 @@ error: | |||
487 | "CTRL: TypeReq=0x%x val=0x%x " | 478 | "CTRL: TypeReq=0x%x val=0x%x " |
488 | "idx=0x%x len=%d ==> %d\n", | 479 | "idx=0x%x len=%d ==> %d\n", |
489 | typeReq, wValue, wIndex, | 480 | typeReq, wValue, wIndex, |
490 | wLength, urb->status); | 481 | wLength, status); |
491 | } | 482 | } |
492 | } | 483 | } |
493 | if (len) { | 484 | if (len) { |
@@ -748,10 +739,9 @@ struct usb_bus *usb_alloc_bus (struct usb_operations *op) | |||
748 | { | 739 | { |
749 | struct usb_bus *bus; | 740 | struct usb_bus *bus; |
750 | 741 | ||
751 | bus = kmalloc (sizeof *bus, GFP_KERNEL); | 742 | bus = kzalloc (sizeof *bus, GFP_KERNEL); |
752 | if (!bus) | 743 | if (!bus) |
753 | return NULL; | 744 | return NULL; |
754 | memset(bus, 0, sizeof(struct usb_bus)); | ||
755 | usb_bus_init (bus); | 745 | usb_bus_init (bus); |
756 | bus->op = op; | 746 | bus->op = op; |
757 | return bus; | 747 | return bus; |
@@ -782,7 +772,8 @@ static int usb_register_bus(struct usb_bus *bus) | |||
782 | return -E2BIG; | 772 | return -E2BIG; |
783 | } | 773 | } |
784 | 774 | ||
785 | bus->class_dev = class_device_create(usb_host_class, MKDEV(0,0), bus->controller, "usb_host%d", busnum); | 775 | bus->class_dev = class_device_create(usb_host_class, NULL, MKDEV(0,0), |
776 | bus->controller, "usb_host%d", busnum); | ||
786 | if (IS_ERR(bus->class_dev)) { | 777 | if (IS_ERR(bus->class_dev)) { |
787 | clear_bit(busnum, busmap.busmap); | 778 | clear_bit(busnum, busmap.busmap); |
788 | up(&usb_bus_list_lock); | 779 | up(&usb_bus_list_lock); |
@@ -795,8 +786,7 @@ static int usb_register_bus(struct usb_bus *bus) | |||
795 | list_add (&bus->bus_list, &usb_bus_list); | 786 | list_add (&bus->bus_list, &usb_bus_list); |
796 | up (&usb_bus_list_lock); | 787 | up (&usb_bus_list_lock); |
797 | 788 | ||
798 | usbfs_add_bus (bus); | 789 | usb_notify_add_bus(bus); |
799 | usbmon_notify_bus_add (bus); | ||
800 | 790 | ||
801 | dev_info (bus->controller, "new USB bus registered, assigned bus number %d\n", bus->busnum); | 791 | dev_info (bus->controller, "new USB bus registered, assigned bus number %d\n", bus->busnum); |
802 | return 0; | 792 | return 0; |
@@ -823,8 +813,7 @@ static void usb_deregister_bus (struct usb_bus *bus) | |||
823 | list_del (&bus->bus_list); | 813 | list_del (&bus->bus_list); |
824 | up (&usb_bus_list_lock); | 814 | up (&usb_bus_list_lock); |
825 | 815 | ||
826 | usbmon_notify_bus_remove (bus); | 816 | usb_notify_remove_bus(bus); |
827 | usbfs_remove_bus (bus); | ||
828 | 817 | ||
829 | clear_bit (bus->busnum, busmap.busmap); | 818 | clear_bit (bus->busnum, busmap.busmap); |
830 | 819 | ||
@@ -1112,7 +1101,7 @@ static void urb_unlink (struct urb *urb) | |||
1112 | * expects usb_submit_urb() to have sanity checked and conditioned all | 1101 | * expects usb_submit_urb() to have sanity checked and conditioned all |
1113 | * inputs in the urb | 1102 | * inputs in the urb |
1114 | */ | 1103 | */ |
1115 | static int hcd_submit_urb (struct urb *urb, unsigned mem_flags) | 1104 | static int hcd_submit_urb (struct urb *urb, gfp_t mem_flags) |
1116 | { | 1105 | { |
1117 | int status; | 1106 | int status; |
1118 | struct usb_hcd *hcd = urb->dev->bus->hcpriv; | 1107 | struct usb_hcd *hcd = urb->dev->bus->hcpriv; |
@@ -1142,10 +1131,20 @@ static int hcd_submit_urb (struct urb *urb, unsigned mem_flags) | |||
1142 | else switch (hcd->state) { | 1131 | else switch (hcd->state) { |
1143 | case HC_STATE_RUNNING: | 1132 | case HC_STATE_RUNNING: |
1144 | case HC_STATE_RESUMING: | 1133 | case HC_STATE_RESUMING: |
1134 | doit: | ||
1145 | usb_get_dev (urb->dev); | 1135 | usb_get_dev (urb->dev); |
1146 | list_add_tail (&urb->urb_list, &ep->urb_list); | 1136 | list_add_tail (&urb->urb_list, &ep->urb_list); |
1147 | status = 0; | 1137 | status = 0; |
1148 | break; | 1138 | break; |
1139 | case HC_STATE_SUSPENDED: | ||
1140 | /* HC upstream links (register access, wakeup signaling) can work | ||
1141 | * even when the downstream links (and DMA etc) are quiesced; let | ||
1142 | * usbcore talk to the root hub. | ||
1143 | */ | ||
1144 | if (hcd->self.controller->power.power_state.event == PM_EVENT_ON | ||
1145 | && urb->dev->parent == NULL) | ||
1146 | goto doit; | ||
1147 | /* FALL THROUGH */ | ||
1149 | default: | 1148 | default: |
1150 | status = -ESHUTDOWN; | 1149 | status = -ESHUTDOWN; |
1151 | break; | 1150 | break; |
@@ -1293,12 +1292,6 @@ static int hcd_unlink_urb (struct urb *urb, int status) | |||
1293 | goto done; | 1292 | goto done; |
1294 | } | 1293 | } |
1295 | 1294 | ||
1296 | /* running ~= hc unlink handshake works (irq, timer, etc) | ||
1297 | * halted ~= no unlink handshake is needed | ||
1298 | * suspended, resuming == should never happen | ||
1299 | */ | ||
1300 | WARN_ON (!HC_IS_RUNNING (hcd->state) && hcd->state != HC_STATE_HALT); | ||
1301 | |||
1302 | /* insist the urb is still queued */ | 1295 | /* insist the urb is still queued */ |
1303 | list_for_each(tmp, &ep->urb_list) { | 1296 | list_for_each(tmp, &ep->urb_list) { |
1304 | if (tmp == &urb->urb_list) | 1297 | if (tmp == &urb->urb_list) |
@@ -1322,11 +1315,12 @@ static int hcd_unlink_urb (struct urb *urb, int status) | |||
1322 | * finish unlinking the initial failed usb_set_address() | 1315 | * finish unlinking the initial failed usb_set_address() |
1323 | * or device descriptor fetch. | 1316 | * or device descriptor fetch. |
1324 | */ | 1317 | */ |
1325 | if (!hcd->saw_irq && hcd->self.root_hub != urb->dev) { | 1318 | if (!test_bit(HCD_FLAG_SAW_IRQ, &hcd->flags) |
1319 | && hcd->self.root_hub != urb->dev) { | ||
1326 | dev_warn (hcd->self.controller, "Unlink after no-IRQ? " | 1320 | dev_warn (hcd->self.controller, "Unlink after no-IRQ? " |
1327 | "Controller is probably using the wrong IRQ." | 1321 | "Controller is probably using the wrong IRQ." |
1328 | "\n"); | 1322 | "\n"); |
1329 | hcd->saw_irq = 1; | 1323 | set_bit(HCD_FLAG_SAW_IRQ, &hcd->flags); |
1330 | } | 1324 | } |
1331 | 1325 | ||
1332 | urb->status = status; | 1326 | urb->status = status; |
@@ -1430,27 +1424,91 @@ rescan: | |||
1430 | 1424 | ||
1431 | /*-------------------------------------------------------------------------*/ | 1425 | /*-------------------------------------------------------------------------*/ |
1432 | 1426 | ||
1433 | #ifdef CONFIG_USB_SUSPEND | 1427 | #ifdef CONFIG_PM |
1434 | 1428 | ||
1435 | static int hcd_hub_suspend (struct usb_bus *bus) | 1429 | int hcd_bus_suspend (struct usb_bus *bus) |
1436 | { | 1430 | { |
1437 | struct usb_hcd *hcd; | 1431 | struct usb_hcd *hcd; |
1432 | int status; | ||
1438 | 1433 | ||
1439 | hcd = container_of (bus, struct usb_hcd, self); | 1434 | hcd = container_of (bus, struct usb_hcd, self); |
1440 | if (hcd->driver->hub_suspend) | 1435 | if (!hcd->driver->bus_suspend) |
1441 | return hcd->driver->hub_suspend (hcd); | 1436 | return -ENOENT; |
1442 | return 0; | 1437 | hcd->state = HC_STATE_QUIESCING; |
1438 | status = hcd->driver->bus_suspend (hcd); | ||
1439 | if (status == 0) | ||
1440 | hcd->state = HC_STATE_SUSPENDED; | ||
1441 | else | ||
1442 | dev_dbg(&bus->root_hub->dev, "%s fail, err %d\n", | ||
1443 | "suspend", status); | ||
1444 | return status; | ||
1443 | } | 1445 | } |
1444 | 1446 | ||
1445 | static int hcd_hub_resume (struct usb_bus *bus) | 1447 | int hcd_bus_resume (struct usb_bus *bus) |
1446 | { | 1448 | { |
1447 | struct usb_hcd *hcd; | 1449 | struct usb_hcd *hcd; |
1450 | int status; | ||
1448 | 1451 | ||
1449 | hcd = container_of (bus, struct usb_hcd, self); | 1452 | hcd = container_of (bus, struct usb_hcd, self); |
1450 | if (hcd->driver->hub_resume) | 1453 | if (!hcd->driver->bus_resume) |
1451 | return hcd->driver->hub_resume (hcd); | 1454 | return -ENOENT; |
1452 | return 0; | 1455 | if (hcd->state == HC_STATE_RUNNING) |
1456 | return 0; | ||
1457 | hcd->state = HC_STATE_RESUMING; | ||
1458 | status = hcd->driver->bus_resume (hcd); | ||
1459 | if (status == 0) | ||
1460 | hcd->state = HC_STATE_RUNNING; | ||
1461 | else { | ||
1462 | dev_dbg(&bus->root_hub->dev, "%s fail, err %d\n", | ||
1463 | "resume", status); | ||
1464 | usb_hc_died(hcd); | ||
1465 | } | ||
1466 | return status; | ||
1467 | } | ||
1468 | |||
1469 | /* | ||
1470 | * usb_hcd_suspend_root_hub - HCD autosuspends downstream ports | ||
1471 | * @hcd: host controller for this root hub | ||
1472 | * | ||
1473 | * This call arranges that usb_hcd_resume_root_hub() is safe to call later; | ||
1474 | * that the HCD's root hub polling is deactivated; and that the root's hub | ||
1475 | * driver is suspended. HCDs may call this to autosuspend when their root | ||
1476 | * hub's downstream ports are all inactive: unpowered, disconnected, | ||
1477 | * disabled, or suspended. | ||
1478 | * | ||
1479 | * The HCD will autoresume on device connect change detection (using SRP | ||
1480 | * or a D+/D- pullup). The HCD also autoresumes on remote wakeup signaling | ||
1481 | * from any ports that are suspended (if that is enabled). In most cases, | ||
1482 | * overcurrent signaling (on powered ports) will also start autoresume. | ||
1483 | * | ||
1484 | * Always called with IRQs blocked. | ||
1485 | */ | ||
1486 | void usb_hcd_suspend_root_hub (struct usb_hcd *hcd) | ||
1487 | { | ||
1488 | struct urb *urb; | ||
1489 | |||
1490 | spin_lock (&hcd_root_hub_lock); | ||
1491 | usb_suspend_root_hub (hcd->self.root_hub); | ||
1492 | |||
1493 | /* force status urb to complete/unlink while suspended */ | ||
1494 | if (hcd->status_urb) { | ||
1495 | urb = hcd->status_urb; | ||
1496 | urb->status = -ECONNRESET; | ||
1497 | urb->hcpriv = NULL; | ||
1498 | urb->actual_length = 0; | ||
1499 | |||
1500 | del_timer (&hcd->rh_timer); | ||
1501 | hcd->poll_pending = 0; | ||
1502 | hcd->status_urb = NULL; | ||
1503 | } else | ||
1504 | urb = NULL; | ||
1505 | spin_unlock (&hcd_root_hub_lock); | ||
1506 | hcd->state = HC_STATE_SUSPENDED; | ||
1507 | |||
1508 | if (urb) | ||
1509 | usb_hcd_giveback_urb (hcd, urb, NULL); | ||
1453 | } | 1510 | } |
1511 | EXPORT_SYMBOL_GPL(usb_hcd_suspend_root_hub); | ||
1454 | 1512 | ||
1455 | /** | 1513 | /** |
1456 | * usb_hcd_resume_root_hub - called by HCD to resume its root hub | 1514 | * usb_hcd_resume_root_hub - called by HCD to resume its root hub |
@@ -1459,7 +1517,7 @@ static int hcd_hub_resume (struct usb_bus *bus) | |||
1459 | * The USB host controller calls this function when its root hub is | 1517 | * The USB host controller calls this function when its root hub is |
1460 | * suspended (with the remote wakeup feature enabled) and a remote | 1518 | * suspended (with the remote wakeup feature enabled) and a remote |
1461 | * wakeup request is received. It queues a request for khubd to | 1519 | * wakeup request is received. It queues a request for khubd to |
1462 | * resume the root hub. | 1520 | * resume the root hub (that is, manage its downstream ports again). |
1463 | */ | 1521 | */ |
1464 | void usb_hcd_resume_root_hub (struct usb_hcd *hcd) | 1522 | void usb_hcd_resume_root_hub (struct usb_hcd *hcd) |
1465 | { | 1523 | { |
@@ -1470,13 +1528,9 @@ void usb_hcd_resume_root_hub (struct usb_hcd *hcd) | |||
1470 | usb_resume_root_hub (hcd->self.root_hub); | 1528 | usb_resume_root_hub (hcd->self.root_hub); |
1471 | spin_unlock_irqrestore (&hcd_root_hub_lock, flags); | 1529 | spin_unlock_irqrestore (&hcd_root_hub_lock, flags); |
1472 | } | 1530 | } |
1531 | EXPORT_SYMBOL_GPL(usb_hcd_resume_root_hub); | ||
1473 | 1532 | ||
1474 | #else | ||
1475 | void usb_hcd_resume_root_hub (struct usb_hcd *hcd) | ||
1476 | { | ||
1477 | } | ||
1478 | #endif | 1533 | #endif |
1479 | EXPORT_SYMBOL_GPL(usb_hcd_resume_root_hub); | ||
1480 | 1534 | ||
1481 | /*-------------------------------------------------------------------------*/ | 1535 | /*-------------------------------------------------------------------------*/ |
1482 | 1536 | ||
@@ -1529,10 +1583,6 @@ static struct usb_operations usb_hcd_operations = { | |||
1529 | .buffer_alloc = hcd_buffer_alloc, | 1583 | .buffer_alloc = hcd_buffer_alloc, |
1530 | .buffer_free = hcd_buffer_free, | 1584 | .buffer_free = hcd_buffer_free, |
1531 | .disable = hcd_endpoint_disable, | 1585 | .disable = hcd_endpoint_disable, |
1532 | #ifdef CONFIG_USB_SUSPEND | ||
1533 | .hub_suspend = hcd_hub_suspend, | ||
1534 | .hub_resume = hcd_hub_resume, | ||
1535 | #endif | ||
1536 | }; | 1586 | }; |
1537 | 1587 | ||
1538 | /*-------------------------------------------------------------------------*/ | 1588 | /*-------------------------------------------------------------------------*/ |
@@ -1600,13 +1650,15 @@ irqreturn_t usb_hcd_irq (int irq, void *__hcd, struct pt_regs * r) | |||
1600 | struct usb_hcd *hcd = __hcd; | 1650 | struct usb_hcd *hcd = __hcd; |
1601 | int start = hcd->state; | 1651 | int start = hcd->state; |
1602 | 1652 | ||
1603 | if (start == HC_STATE_HALT) | 1653 | if (unlikely(start == HC_STATE_HALT || |
1654 | !test_bit(HCD_FLAG_HW_ACCESSIBLE, &hcd->flags))) | ||
1604 | return IRQ_NONE; | 1655 | return IRQ_NONE; |
1605 | if (hcd->driver->irq (hcd, r) == IRQ_NONE) | 1656 | if (hcd->driver->irq (hcd, r) == IRQ_NONE) |
1606 | return IRQ_NONE; | 1657 | return IRQ_NONE; |
1607 | 1658 | ||
1608 | hcd->saw_irq = 1; | 1659 | set_bit(HCD_FLAG_SAW_IRQ, &hcd->flags); |
1609 | if (hcd->state == HC_STATE_HALT) | 1660 | |
1661 | if (unlikely(hcd->state == HC_STATE_HALT)) | ||
1610 | usb_hc_died (hcd); | 1662 | usb_hc_died (hcd); |
1611 | return IRQ_HANDLED; | 1663 | return IRQ_HANDLED; |
1612 | } | 1664 | } |
@@ -1719,6 +1771,8 @@ int usb_add_hcd(struct usb_hcd *hcd, | |||
1719 | 1771 | ||
1720 | dev_info(hcd->self.controller, "%s\n", hcd->product_desc); | 1772 | dev_info(hcd->self.controller, "%s\n", hcd->product_desc); |
1721 | 1773 | ||
1774 | set_bit(HCD_FLAG_HW_ACCESSIBLE, &hcd->flags); | ||
1775 | |||
1722 | /* till now HC has been in an indeterminate state ... */ | 1776 | /* till now HC has been in an indeterminate state ... */ |
1723 | if (hcd->driver->reset && (retval = hcd->driver->reset(hcd)) < 0) { | 1777 | if (hcd->driver->reset && (retval = hcd->driver->reset(hcd)) < 0) { |
1724 | dev_err(hcd->self.controller, "can't reset\n"); | 1778 | dev_err(hcd->self.controller, "can't reset\n"); |
diff --git a/drivers/usb/core/hcd.h b/drivers/usb/core/hcd.h index ac451fa7e4d2..c8a1b350e2cf 100644 --- a/drivers/usb/core/hcd.h +++ b/drivers/usb/core/hcd.h | |||
@@ -72,7 +72,12 @@ struct usb_hcd { /* usb_bus.hcpriv points to this */ | |||
72 | * hardware info/state | 72 | * hardware info/state |
73 | */ | 73 | */ |
74 | const struct hc_driver *driver; /* hw-specific hooks */ | 74 | const struct hc_driver *driver; /* hw-specific hooks */ |
75 | unsigned saw_irq : 1; | 75 | |
76 | /* Flags that need to be manipulated atomically */ | ||
77 | unsigned long flags; | ||
78 | #define HCD_FLAG_HW_ACCESSIBLE 0x00000001 | ||
79 | #define HCD_FLAG_SAW_IRQ 0x00000002 | ||
80 | |||
76 | unsigned can_wakeup:1; /* hw supports wakeup? */ | 81 | unsigned can_wakeup:1; /* hw supports wakeup? */ |
77 | unsigned remote_wakeup:1;/* sw should use wakeup? */ | 82 | unsigned remote_wakeup:1;/* sw should use wakeup? */ |
78 | unsigned rh_registered:1;/* is root hub registered? */ | 83 | unsigned rh_registered:1;/* is root hub registered? */ |
@@ -142,22 +147,18 @@ struct hcd_timeout { /* timeouts we allocate */ | |||
142 | 147 | ||
143 | struct usb_operations { | 148 | struct usb_operations { |
144 | int (*get_frame_number) (struct usb_device *usb_dev); | 149 | int (*get_frame_number) (struct usb_device *usb_dev); |
145 | int (*submit_urb) (struct urb *urb, unsigned mem_flags); | 150 | int (*submit_urb) (struct urb *urb, gfp_t mem_flags); |
146 | int (*unlink_urb) (struct urb *urb, int status); | 151 | int (*unlink_urb) (struct urb *urb, int status); |
147 | 152 | ||
148 | /* allocate dma-consistent buffer for URB_DMA_NOMAPPING */ | 153 | /* allocate dma-consistent buffer for URB_DMA_NOMAPPING */ |
149 | void *(*buffer_alloc)(struct usb_bus *bus, size_t size, | 154 | void *(*buffer_alloc)(struct usb_bus *bus, size_t size, |
150 | unsigned mem_flags, | 155 | gfp_t mem_flags, |
151 | dma_addr_t *dma); | 156 | dma_addr_t *dma); |
152 | void (*buffer_free)(struct usb_bus *bus, size_t size, | 157 | void (*buffer_free)(struct usb_bus *bus, size_t size, |
153 | void *addr, dma_addr_t dma); | 158 | void *addr, dma_addr_t dma); |
154 | 159 | ||
155 | void (*disable)(struct usb_device *udev, | 160 | void (*disable)(struct usb_device *udev, |
156 | struct usb_host_endpoint *ep); | 161 | struct usb_host_endpoint *ep); |
157 | |||
158 | /* global suspend/resume of bus */ | ||
159 | int (*hub_suspend)(struct usb_bus *); | ||
160 | int (*hub_resume)(struct usb_bus *); | ||
161 | }; | 162 | }; |
162 | 163 | ||
163 | /* each driver provides one of these, and hardware init support */ | 164 | /* each driver provides one of these, and hardware init support */ |
@@ -182,12 +183,12 @@ struct hc_driver { | |||
182 | int (*start) (struct usb_hcd *hcd); | 183 | int (*start) (struct usb_hcd *hcd); |
183 | 184 | ||
184 | /* NOTE: these suspend/resume calls relate to the HC as | 185 | /* NOTE: these suspend/resume calls relate to the HC as |
185 | * a whole, not just the root hub; they're for bus glue. | 186 | * a whole, not just the root hub; they're for PCI bus glue. |
186 | */ | 187 | */ |
187 | /* called after all devices were suspended */ | 188 | /* called after suspending the hub, before entering D3 etc */ |
188 | int (*suspend) (struct usb_hcd *hcd, pm_message_t message); | 189 | int (*suspend) (struct usb_hcd *hcd, pm_message_t message); |
189 | 190 | ||
190 | /* called before any devices get resumed */ | 191 | /* called after entering D0 (etc), before resuming the hub */ |
191 | int (*resume) (struct usb_hcd *hcd); | 192 | int (*resume) (struct usb_hcd *hcd); |
192 | 193 | ||
193 | /* cleanly make HCD stop writing memory and doing I/O */ | 194 | /* cleanly make HCD stop writing memory and doing I/O */ |
@@ -200,7 +201,7 @@ struct hc_driver { | |||
200 | int (*urb_enqueue) (struct usb_hcd *hcd, | 201 | int (*urb_enqueue) (struct usb_hcd *hcd, |
201 | struct usb_host_endpoint *ep, | 202 | struct usb_host_endpoint *ep, |
202 | struct urb *urb, | 203 | struct urb *urb, |
203 | unsigned mem_flags); | 204 | gfp_t mem_flags); |
204 | int (*urb_dequeue) (struct usb_hcd *hcd, struct urb *urb); | 205 | int (*urb_dequeue) (struct usb_hcd *hcd, struct urb *urb); |
205 | 206 | ||
206 | /* hw synch, freeing endpoint resources that urb_dequeue can't */ | 207 | /* hw synch, freeing endpoint resources that urb_dequeue can't */ |
@@ -212,8 +213,8 @@ struct hc_driver { | |||
212 | int (*hub_control) (struct usb_hcd *hcd, | 213 | int (*hub_control) (struct usb_hcd *hcd, |
213 | u16 typeReq, u16 wValue, u16 wIndex, | 214 | u16 typeReq, u16 wValue, u16 wIndex, |
214 | char *buf, u16 wLength); | 215 | char *buf, u16 wLength); |
215 | int (*hub_suspend)(struct usb_hcd *); | 216 | int (*bus_suspend)(struct usb_hcd *); |
216 | int (*hub_resume)(struct usb_hcd *); | 217 | int (*bus_resume)(struct usb_hcd *); |
217 | int (*start_port_reset)(struct usb_hcd *, unsigned port_num); | 218 | int (*start_port_reset)(struct usb_hcd *, unsigned port_num); |
218 | void (*hub_irq_enable)(struct usb_hcd *); | 219 | void (*hub_irq_enable)(struct usb_hcd *); |
219 | /* Needed only if port-change IRQs are level-triggered */ | 220 | /* Needed only if port-change IRQs are level-triggered */ |
@@ -247,7 +248,7 @@ int hcd_buffer_create (struct usb_hcd *hcd); | |||
247 | void hcd_buffer_destroy (struct usb_hcd *hcd); | 248 | void hcd_buffer_destroy (struct usb_hcd *hcd); |
248 | 249 | ||
249 | void *hcd_buffer_alloc (struct usb_bus *bus, size_t size, | 250 | void *hcd_buffer_alloc (struct usb_bus *bus, size_t size, |
250 | unsigned mem_flags, dma_addr_t *dma); | 251 | gfp_t mem_flags, dma_addr_t *dma); |
251 | void hcd_buffer_free (struct usb_bus *bus, size_t size, | 252 | void hcd_buffer_free (struct usb_bus *bus, size_t size, |
252 | void *addr, dma_addr_t dma); | 253 | void *addr, dma_addr_t dma); |
253 | 254 | ||
@@ -355,8 +356,6 @@ extern long usb_calc_bus_time (int speed, int is_input, | |||
355 | 356 | ||
356 | extern struct usb_bus *usb_alloc_bus (struct usb_operations *); | 357 | extern struct usb_bus *usb_alloc_bus (struct usb_operations *); |
357 | 358 | ||
358 | extern void usb_hcd_resume_root_hub (struct usb_hcd *hcd); | ||
359 | |||
360 | extern void usb_set_device_state(struct usb_device *udev, | 359 | extern void usb_set_device_state(struct usb_device *udev, |
361 | enum usb_device_state new_state); | 360 | enum usb_device_state new_state); |
362 | 361 | ||
@@ -378,6 +377,33 @@ extern int usb_find_interface_driver (struct usb_device *dev, | |||
378 | 377 | ||
379 | #define usb_endpoint_out(ep_dir) (!((ep_dir) & USB_DIR_IN)) | 378 | #define usb_endpoint_out(ep_dir) (!((ep_dir) & USB_DIR_IN)) |
380 | 379 | ||
380 | #ifdef CONFIG_PM | ||
381 | extern void usb_hcd_suspend_root_hub (struct usb_hcd *hcd); | ||
382 | extern void usb_hcd_resume_root_hub (struct usb_hcd *hcd); | ||
383 | extern int hcd_bus_suspend (struct usb_bus *bus); | ||
384 | extern int hcd_bus_resume (struct usb_bus *bus); | ||
385 | #else | ||
386 | static inline void usb_hcd_suspend_root_hub(struct usb_hcd *hcd) | ||
387 | { | ||
388 | return; | ||
389 | } | ||
390 | |||
391 | static inline void usb_hcd_resume_root_hub(struct usb_hcd *hcd) | ||
392 | { | ||
393 | return; | ||
394 | } | ||
395 | |||
396 | static inline int hcd_bus_suspend(struct usb_bus *bus) | ||
397 | { | ||
398 | return 0; | ||
399 | } | ||
400 | |||
401 | static inline int hcd_bus_resume (struct usb_bus *bus) | ||
402 | { | ||
403 | return 0; | ||
404 | } | ||
405 | #endif /* CONFIG_PM */ | ||
406 | |||
381 | /* | 407 | /* |
382 | * USB device fs stuff | 408 | * USB device fs stuff |
383 | */ | 409 | */ |
@@ -388,23 +414,13 @@ extern int usb_find_interface_driver (struct usb_device *dev, | |||
388 | * these are expected to be called from the USB core/hub thread | 414 | * these are expected to be called from the USB core/hub thread |
389 | * with the kernel lock held | 415 | * with the kernel lock held |
390 | */ | 416 | */ |
391 | extern void usbfs_add_bus(struct usb_bus *bus); | ||
392 | extern void usbfs_remove_bus(struct usb_bus *bus); | ||
393 | extern void usbfs_add_device(struct usb_device *dev); | ||
394 | extern void usbfs_remove_device(struct usb_device *dev); | ||
395 | extern void usbfs_update_special (void); | 417 | extern void usbfs_update_special (void); |
396 | |||
397 | extern int usbfs_init(void); | 418 | extern int usbfs_init(void); |
398 | extern void usbfs_cleanup(void); | 419 | extern void usbfs_cleanup(void); |
399 | 420 | ||
400 | #else /* CONFIG_USB_DEVICEFS */ | 421 | #else /* CONFIG_USB_DEVICEFS */ |
401 | 422 | ||
402 | static inline void usbfs_add_bus(struct usb_bus *bus) {} | ||
403 | static inline void usbfs_remove_bus(struct usb_bus *bus) {} | ||
404 | static inline void usbfs_add_device(struct usb_device *dev) {} | ||
405 | static inline void usbfs_remove_device(struct usb_device *dev) {} | ||
406 | static inline void usbfs_update_special (void) {} | 423 | static inline void usbfs_update_special (void) {} |
407 | |||
408 | static inline int usbfs_init(void) { return 0; } | 424 | static inline int usbfs_init(void) { return 0; } |
409 | static inline void usbfs_cleanup(void) { } | 425 | static inline void usbfs_cleanup(void) { } |
410 | 426 | ||
@@ -419,8 +435,6 @@ struct usb_mon_operations { | |||
419 | void (*urb_submit_error)(struct usb_bus *bus, struct urb *urb, int err); | 435 | void (*urb_submit_error)(struct usb_bus *bus, struct urb *urb, int err); |
420 | void (*urb_complete)(struct usb_bus *bus, struct urb *urb); | 436 | void (*urb_complete)(struct usb_bus *bus, struct urb *urb); |
421 | /* void (*urb_unlink)(struct usb_bus *bus, struct urb *urb); */ | 437 | /* void (*urb_unlink)(struct usb_bus *bus, struct urb *urb); */ |
422 | void (*bus_add)(struct usb_bus *bus); | ||
423 | void (*bus_remove)(struct usb_bus *bus); | ||
424 | }; | 438 | }; |
425 | 439 | ||
426 | extern struct usb_mon_operations *mon_ops; | 440 | extern struct usb_mon_operations *mon_ops; |
@@ -443,18 +457,6 @@ static inline void usbmon_urb_complete(struct usb_bus *bus, struct urb *urb) | |||
443 | if (bus->monitored) | 457 | if (bus->monitored) |
444 | (*mon_ops->urb_complete)(bus, urb); | 458 | (*mon_ops->urb_complete)(bus, urb); |
445 | } | 459 | } |
446 | |||
447 | static inline void usbmon_notify_bus_add(struct usb_bus *bus) | ||
448 | { | ||
449 | if (mon_ops) | ||
450 | (*mon_ops->bus_add)(bus); | ||
451 | } | ||
452 | |||
453 | static inline void usbmon_notify_bus_remove(struct usb_bus *bus) | ||
454 | { | ||
455 | if (mon_ops) | ||
456 | (*mon_ops->bus_remove)(bus); | ||
457 | } | ||
458 | 460 | ||
459 | int usb_mon_register(struct usb_mon_operations *ops); | 461 | int usb_mon_register(struct usb_mon_operations *ops); |
460 | void usb_mon_deregister(void); | 462 | void usb_mon_deregister(void); |
@@ -465,8 +467,6 @@ static inline void usbmon_urb_submit(struct usb_bus *bus, struct urb *urb) {} | |||
465 | static inline void usbmon_urb_submit_error(struct usb_bus *bus, struct urb *urb, | 467 | static inline void usbmon_urb_submit_error(struct usb_bus *bus, struct urb *urb, |
466 | int error) {} | 468 | int error) {} |
467 | static inline void usbmon_urb_complete(struct usb_bus *bus, struct urb *urb) {} | 469 | static inline void usbmon_urb_complete(struct usb_bus *bus, struct urb *urb) {} |
468 | static inline void usbmon_notify_bus_add(struct usb_bus *bus) {} | ||
469 | static inline void usbmon_notify_bus_remove(struct usb_bus *bus) {} | ||
470 | 470 | ||
471 | #endif /* CONFIG_USB_MON */ | 471 | #endif /* CONFIG_USB_MON */ |
472 | 472 | ||
diff --git a/drivers/usb/core/hub.c b/drivers/usb/core/hub.c index a12cab5314e9..f78bd124d290 100644 --- a/drivers/usb/core/hub.c +++ b/drivers/usb/core/hub.c | |||
@@ -9,11 +9,6 @@ | |||
9 | */ | 9 | */ |
10 | 10 | ||
11 | #include <linux/config.h> | 11 | #include <linux/config.h> |
12 | #ifdef CONFIG_USB_DEBUG | ||
13 | #define DEBUG | ||
14 | #else | ||
15 | #undef DEBUG | ||
16 | #endif | ||
17 | #include <linux/kernel.h> | 12 | #include <linux/kernel.h> |
18 | #include <linux/errno.h> | 13 | #include <linux/errno.h> |
19 | #include <linux/module.h> | 14 | #include <linux/module.h> |
@@ -436,9 +431,10 @@ static void hub_power_on(struct usb_hub *hub) | |||
436 | { | 431 | { |
437 | int port1; | 432 | int port1; |
438 | unsigned pgood_delay = hub->descriptor->bPwrOn2PwrGood * 2; | 433 | unsigned pgood_delay = hub->descriptor->bPwrOn2PwrGood * 2; |
434 | u16 wHubCharacteristics = le16_to_cpu(hub->descriptor->wHubCharacteristics); | ||
439 | 435 | ||
440 | /* if hub supports power switching, enable power on each port */ | 436 | /* if hub supports power switching, enable power on each port */ |
441 | if ((hub->descriptor->wHubCharacteristics & HUB_CHAR_LPSM) < 2) { | 437 | if ((wHubCharacteristics & HUB_CHAR_LPSM) < 2) { |
442 | dev_dbg(hub->intfdev, "enabling power on all ports\n"); | 438 | dev_dbg(hub->intfdev, "enabling power on all ports\n"); |
443 | for (port1 = 1; port1 <= hub->descriptor->bNbrPorts; port1++) | 439 | for (port1 = 1; port1 <= hub->descriptor->bNbrPorts; port1++) |
444 | set_port_feature(hub->hdev, port1, | 440 | set_port_feature(hub->hdev, port1, |
@@ -449,10 +445,18 @@ static void hub_power_on(struct usb_hub *hub) | |||
449 | msleep(max(pgood_delay, (unsigned) 100)); | 445 | msleep(max(pgood_delay, (unsigned) 100)); |
450 | } | 446 | } |
451 | 447 | ||
452 | static void hub_quiesce(struct usb_hub *hub) | 448 | static inline void __hub_quiesce(struct usb_hub *hub) |
453 | { | 449 | { |
454 | /* stop khubd and related activity */ | 450 | /* (nonblocking) khubd and related activity won't re-trigger */ |
455 | hub->quiescing = 1; | 451 | hub->quiescing = 1; |
452 | hub->activating = 0; | ||
453 | hub->resume_root_hub = 0; | ||
454 | } | ||
455 | |||
456 | static void hub_quiesce(struct usb_hub *hub) | ||
457 | { | ||
458 | /* (blocking) stop khubd and related activity */ | ||
459 | __hub_quiesce(hub); | ||
456 | usb_kill_urb(hub->urb); | 460 | usb_kill_urb(hub->urb); |
457 | if (hub->has_indicators) | 461 | if (hub->has_indicators) |
458 | cancel_delayed_work(&hub->leds); | 462 | cancel_delayed_work(&hub->leds); |
@@ -466,6 +470,7 @@ static void hub_activate(struct usb_hub *hub) | |||
466 | 470 | ||
467 | hub->quiescing = 0; | 471 | hub->quiescing = 0; |
468 | hub->activating = 1; | 472 | hub->activating = 1; |
473 | hub->resume_root_hub = 0; | ||
469 | status = usb_submit_urb(hub->urb, GFP_NOIO); | 474 | status = usb_submit_urb(hub->urb, GFP_NOIO); |
470 | if (status < 0) | 475 | if (status < 0) |
471 | dev_err(hub->intfdev, "activate --> %d\n", status); | 476 | dev_err(hub->intfdev, "activate --> %d\n", status); |
@@ -516,6 +521,7 @@ static int hub_configure(struct usb_hub *hub, | |||
516 | struct usb_device *hdev = hub->hdev; | 521 | struct usb_device *hdev = hub->hdev; |
517 | struct device *hub_dev = hub->intfdev; | 522 | struct device *hub_dev = hub->intfdev; |
518 | u16 hubstatus, hubchange; | 523 | u16 hubstatus, hubchange; |
524 | u16 wHubCharacteristics; | ||
519 | unsigned int pipe; | 525 | unsigned int pipe; |
520 | int maxp, ret; | 526 | int maxp, ret; |
521 | char *message; | 527 | char *message; |
@@ -561,9 +567,9 @@ static int hub_configure(struct usb_hub *hub, | |||
561 | dev_info (hub_dev, "%d port%s detected\n", hdev->maxchild, | 567 | dev_info (hub_dev, "%d port%s detected\n", hdev->maxchild, |
562 | (hdev->maxchild == 1) ? "" : "s"); | 568 | (hdev->maxchild == 1) ? "" : "s"); |
563 | 569 | ||
564 | le16_to_cpus(&hub->descriptor->wHubCharacteristics); | 570 | wHubCharacteristics = le16_to_cpu(hub->descriptor->wHubCharacteristics); |
565 | 571 | ||
566 | if (hub->descriptor->wHubCharacteristics & HUB_CHAR_COMPOUND) { | 572 | if (wHubCharacteristics & HUB_CHAR_COMPOUND) { |
567 | int i; | 573 | int i; |
568 | char portstr [USB_MAXCHILDREN + 1]; | 574 | char portstr [USB_MAXCHILDREN + 1]; |
569 | 575 | ||
@@ -576,7 +582,7 @@ static int hub_configure(struct usb_hub *hub, | |||
576 | } else | 582 | } else |
577 | dev_dbg(hub_dev, "standalone hub\n"); | 583 | dev_dbg(hub_dev, "standalone hub\n"); |
578 | 584 | ||
579 | switch (hub->descriptor->wHubCharacteristics & HUB_CHAR_LPSM) { | 585 | switch (wHubCharacteristics & HUB_CHAR_LPSM) { |
580 | case 0x00: | 586 | case 0x00: |
581 | dev_dbg(hub_dev, "ganged power switching\n"); | 587 | dev_dbg(hub_dev, "ganged power switching\n"); |
582 | break; | 588 | break; |
@@ -589,7 +595,7 @@ static int hub_configure(struct usb_hub *hub, | |||
589 | break; | 595 | break; |
590 | } | 596 | } |
591 | 597 | ||
592 | switch (hub->descriptor->wHubCharacteristics & HUB_CHAR_OCPM) { | 598 | switch (wHubCharacteristics & HUB_CHAR_OCPM) { |
593 | case 0x00: | 599 | case 0x00: |
594 | dev_dbg(hub_dev, "global over-current protection\n"); | 600 | dev_dbg(hub_dev, "global over-current protection\n"); |
595 | break; | 601 | break; |
@@ -629,7 +635,7 @@ static int hub_configure(struct usb_hub *hub, | |||
629 | } | 635 | } |
630 | 636 | ||
631 | /* Note 8 FS bit times == (8 bits / 12000000 bps) ~= 666ns */ | 637 | /* Note 8 FS bit times == (8 bits / 12000000 bps) ~= 666ns */ |
632 | switch (hub->descriptor->wHubCharacteristics & HUB_CHAR_TTTT) { | 638 | switch (wHubCharacteristics & HUB_CHAR_TTTT) { |
633 | case HUB_TTTT_8_BITS: | 639 | case HUB_TTTT_8_BITS: |
634 | if (hdev->descriptor.bDeviceProtocol != 0) { | 640 | if (hdev->descriptor.bDeviceProtocol != 0) { |
635 | hub->tt.think_time = 666; | 641 | hub->tt.think_time = 666; |
@@ -659,7 +665,7 @@ static int hub_configure(struct usb_hub *hub, | |||
659 | } | 665 | } |
660 | 666 | ||
661 | /* probe() zeroes hub->indicator[] */ | 667 | /* probe() zeroes hub->indicator[] */ |
662 | if (hub->descriptor->wHubCharacteristics & HUB_CHAR_PORTIND) { | 668 | if (wHubCharacteristics & HUB_CHAR_PORTIND) { |
663 | hub->has_indicators = 1; | 669 | hub->has_indicators = 1; |
664 | dev_dbg(hub_dev, "Port indicators are supported\n"); | 670 | dev_dbg(hub_dev, "Port indicators are supported\n"); |
665 | } | 671 | } |
@@ -704,7 +710,7 @@ static int hub_configure(struct usb_hub *hub, | |||
704 | (hubstatus & HUB_STATUS_LOCAL_POWER) | 710 | (hubstatus & HUB_STATUS_LOCAL_POWER) |
705 | ? "lost (inactive)" : "good"); | 711 | ? "lost (inactive)" : "good"); |
706 | 712 | ||
707 | if ((hub->descriptor->wHubCharacteristics & HUB_CHAR_OCPM) == 0) | 713 | if ((wHubCharacteristics & HUB_CHAR_OCPM) == 0) |
708 | dev_dbg(hub_dev, "%sover-current condition exists\n", | 714 | dev_dbg(hub_dev, "%sover-current condition exists\n", |
709 | (hubstatus & HUB_STATUS_OVERCURRENT) ? "" : "no "); | 715 | (hubstatus & HUB_STATUS_OVERCURRENT) ? "" : "no "); |
710 | 716 | ||
@@ -854,14 +860,12 @@ descriptor_error: | |||
854 | /* We found a hub */ | 860 | /* We found a hub */ |
855 | dev_info (&intf->dev, "USB hub found\n"); | 861 | dev_info (&intf->dev, "USB hub found\n"); |
856 | 862 | ||
857 | hub = kmalloc(sizeof(*hub), GFP_KERNEL); | 863 | hub = kzalloc(sizeof(*hub), GFP_KERNEL); |
858 | if (!hub) { | 864 | if (!hub) { |
859 | dev_dbg (&intf->dev, "couldn't kmalloc hub struct\n"); | 865 | dev_dbg (&intf->dev, "couldn't kmalloc hub struct\n"); |
860 | return -ENOMEM; | 866 | return -ENOMEM; |
861 | } | 867 | } |
862 | 868 | ||
863 | memset(hub, 0, sizeof(*hub)); | ||
864 | |||
865 | INIT_LIST_HEAD(&hub->event_list); | 869 | INIT_LIST_HEAD(&hub->event_list); |
866 | hub->intfdev = &intf->dev; | 870 | hub->intfdev = &intf->dev; |
867 | hub->hdev = hdev; | 871 | hub->hdev = hdev; |
@@ -1020,9 +1024,15 @@ void usb_set_device_state(struct usb_device *udev, | |||
1020 | spin_lock_irqsave(&device_state_lock, flags); | 1024 | spin_lock_irqsave(&device_state_lock, flags); |
1021 | if (udev->state == USB_STATE_NOTATTACHED) | 1025 | if (udev->state == USB_STATE_NOTATTACHED) |
1022 | ; /* do nothing */ | 1026 | ; /* do nothing */ |
1023 | else if (new_state != USB_STATE_NOTATTACHED) | 1027 | else if (new_state != USB_STATE_NOTATTACHED) { |
1024 | udev->state = new_state; | 1028 | udev->state = new_state; |
1025 | else | 1029 | if (new_state == USB_STATE_CONFIGURED) |
1030 | device_init_wakeup(&udev->dev, | ||
1031 | (udev->actconfig->desc.bmAttributes | ||
1032 | & USB_CONFIG_ATT_WAKEUP)); | ||
1033 | else if (new_state != USB_STATE_SUSPENDED) | ||
1034 | device_init_wakeup(&udev->dev, 0); | ||
1035 | } else | ||
1026 | recursively_mark_NOTATTACHED(udev); | 1036 | recursively_mark_NOTATTACHED(udev); |
1027 | spin_unlock_irqrestore(&device_state_lock, flags); | 1037 | spin_unlock_irqrestore(&device_state_lock, flags); |
1028 | } | 1038 | } |
@@ -1111,14 +1121,14 @@ void usb_disconnect(struct usb_device **pdev) | |||
1111 | */ | 1121 | */ |
1112 | usb_disable_device(udev, 0); | 1122 | usb_disable_device(udev, 0); |
1113 | 1123 | ||
1124 | usb_notify_remove_device(udev); | ||
1125 | |||
1114 | /* Free the device number, remove the /proc/bus/usb entry and | 1126 | /* Free the device number, remove the /proc/bus/usb entry and |
1115 | * the sysfs attributes, and delete the parent's children[] | 1127 | * the sysfs attributes, and delete the parent's children[] |
1116 | * (or root_hub) pointer. | 1128 | * (or root_hub) pointer. |
1117 | */ | 1129 | */ |
1118 | dev_dbg (&udev->dev, "unregistering device\n"); | 1130 | dev_dbg (&udev->dev, "unregistering device\n"); |
1119 | release_address(udev); | 1131 | release_address(udev); |
1120 | usbfs_remove_device(udev); | ||
1121 | usbdev_remove(udev); | ||
1122 | usb_remove_sysfs_dev_files(udev); | 1132 | usb_remove_sysfs_dev_files(udev); |
1123 | 1133 | ||
1124 | /* Avoid races with recursively_mark_NOTATTACHED() */ | 1134 | /* Avoid races with recursively_mark_NOTATTACHED() */ |
@@ -1189,21 +1199,6 @@ static inline void show_string(struct usb_device *udev, char *id, char *string) | |||
1189 | {} | 1199 | {} |
1190 | #endif | 1200 | #endif |
1191 | 1201 | ||
1192 | static void get_string(struct usb_device *udev, char **string, int index) | ||
1193 | { | ||
1194 | char *buf; | ||
1195 | |||
1196 | if (!index) | ||
1197 | return; | ||
1198 | buf = kmalloc(256, GFP_KERNEL); | ||
1199 | if (!buf) | ||
1200 | return; | ||
1201 | if (usb_string(udev, index, buf, 256) > 0) | ||
1202 | *string = buf; | ||
1203 | else | ||
1204 | kfree(buf); | ||
1205 | } | ||
1206 | |||
1207 | 1202 | ||
1208 | #ifdef CONFIG_USB_OTG | 1203 | #ifdef CONFIG_USB_OTG |
1209 | #include "otg_whitelist.h" | 1204 | #include "otg_whitelist.h" |
@@ -1242,9 +1237,10 @@ int usb_new_device(struct usb_device *udev) | |||
1242 | } | 1237 | } |
1243 | 1238 | ||
1244 | /* read the standard strings and cache them if present */ | 1239 | /* read the standard strings and cache them if present */ |
1245 | get_string(udev, &udev->product, udev->descriptor.iProduct); | 1240 | udev->product = usb_cache_string(udev, udev->descriptor.iProduct); |
1246 | get_string(udev, &udev->manufacturer, udev->descriptor.iManufacturer); | 1241 | udev->manufacturer = usb_cache_string(udev, |
1247 | get_string(udev, &udev->serial, udev->descriptor.iSerialNumber); | 1242 | udev->descriptor.iManufacturer); |
1243 | udev->serial = usb_cache_string(udev, udev->descriptor.iSerialNumber); | ||
1248 | 1244 | ||
1249 | /* Tell the world! */ | 1245 | /* Tell the world! */ |
1250 | dev_dbg(&udev->dev, "new device strings: Mfr=%d, Product=%d, " | 1246 | dev_dbg(&udev->dev, "new device strings: Mfr=%d, Product=%d, " |
@@ -1316,11 +1312,9 @@ int usb_new_device(struct usb_device *udev) | |||
1316 | * (Includes HNP test device.) | 1312 | * (Includes HNP test device.) |
1317 | */ | 1313 | */ |
1318 | if (udev->bus->b_hnp_enable || udev->bus->is_b_host) { | 1314 | if (udev->bus->b_hnp_enable || udev->bus->is_b_host) { |
1319 | static int __usb_suspend_device (struct usb_device *, | 1315 | static int __usb_suspend_device(struct usb_device *, |
1320 | int port1, pm_message_t state); | 1316 | int port1); |
1321 | err = __usb_suspend_device(udev, | 1317 | err = __usb_suspend_device(udev, udev->bus->otg_port); |
1322 | udev->bus->otg_port, | ||
1323 | PMSG_SUSPEND); | ||
1324 | if (err < 0) | 1318 | if (err < 0) |
1325 | dev_dbg(&udev->dev, "HNP fail, %d\n", err); | 1319 | dev_dbg(&udev->dev, "HNP fail, %d\n", err); |
1326 | } | 1320 | } |
@@ -1356,10 +1350,8 @@ int usb_new_device(struct usb_device *udev) | |||
1356 | } | 1350 | } |
1357 | 1351 | ||
1358 | /* USB device state == configured ... usable */ | 1352 | /* USB device state == configured ... usable */ |
1353 | usb_notify_add_device(udev); | ||
1359 | 1354 | ||
1360 | /* add a /proc/bus/usb entry */ | ||
1361 | usbdev_add(udev); | ||
1362 | usbfs_add_device(udev); | ||
1363 | return 0; | 1355 | return 0; |
1364 | 1356 | ||
1365 | fail: | 1357 | fail: |
@@ -1510,7 +1502,7 @@ static void hub_port_logical_disconnect(struct usb_hub *hub, int port1) | |||
1510 | /* FIXME let caller ask to power down the port: | 1502 | /* FIXME let caller ask to power down the port: |
1511 | * - some devices won't enumerate without a VBUS power cycle | 1503 | * - some devices won't enumerate without a VBUS power cycle |
1512 | * - SRP saves power that way | 1504 | * - SRP saves power that way |
1513 | * - usb_suspend_device(dev, PMSG_SUSPEND) | 1505 | * - ... new call, TBD ... |
1514 | * That's easy if this hub can switch power per-port, and | 1506 | * That's easy if this hub can switch power per-port, and |
1515 | * khubd reactivates the port later (timer, SRP, etc). | 1507 | * khubd reactivates the port later (timer, SRP, etc). |
1516 | * Powerdown must be optional, because of reset/DFU. | 1508 | * Powerdown must be optional, because of reset/DFU. |
@@ -1546,11 +1538,7 @@ static int hub_port_suspend(struct usb_hub *hub, int port1, | |||
1546 | * NOTE: OTG devices may issue remote wakeup (or SRP) even when | 1538 | * NOTE: OTG devices may issue remote wakeup (or SRP) even when |
1547 | * we don't explicitly enable it here. | 1539 | * we don't explicitly enable it here. |
1548 | */ | 1540 | */ |
1549 | if (udev->actconfig | 1541 | if (device_may_wakeup(&udev->dev)) { |
1550 | // && FIXME (remote wakeup enabled on this bus) | ||
1551 | // ... currently assuming it's always appropriate | ||
1552 | && (udev->actconfig->desc.bmAttributes | ||
1553 | & USB_CONFIG_ATT_WAKEUP) != 0) { | ||
1554 | status = usb_control_msg(udev, usb_sndctrlpipe(udev, 0), | 1542 | status = usb_control_msg(udev, usb_sndctrlpipe(udev, 0), |
1555 | USB_REQ_SET_FEATURE, USB_RECIP_DEVICE, | 1543 | USB_REQ_SET_FEATURE, USB_RECIP_DEVICE, |
1556 | USB_DEVICE_REMOTE_WAKEUP, 0, | 1544 | USB_DEVICE_REMOTE_WAKEUP, 0, |
@@ -1596,11 +1584,14 @@ static int hub_port_suspend(struct usb_hub *hub, int port1, | |||
1596 | * Other than re-initializing the hub (plug/unplug, except for root hubs), | 1584 | * Other than re-initializing the hub (plug/unplug, except for root hubs), |
1597 | * Linux (2.6) currently has NO mechanisms to initiate that: no khubd | 1585 | * Linux (2.6) currently has NO mechanisms to initiate that: no khubd |
1598 | * timer, no SRP, no requests through sysfs. | 1586 | * timer, no SRP, no requests through sysfs. |
1587 | * | ||
1588 | * If CONFIG_USB_SUSPEND isn't enabled, devices only really suspend when | ||
1589 | * the root hub for their bus goes into global suspend ... so we don't | ||
1590 | * (falsely) update the device power state to say it suspended. | ||
1599 | */ | 1591 | */ |
1600 | static int __usb_suspend_device (struct usb_device *udev, int port1, | 1592 | static int __usb_suspend_device (struct usb_device *udev, int port1) |
1601 | pm_message_t state) | ||
1602 | { | 1593 | { |
1603 | int status; | 1594 | int status = 0; |
1604 | 1595 | ||
1605 | /* caller owns the udev device lock */ | 1596 | /* caller owns the udev device lock */ |
1606 | if (port1 < 0) | 1597 | if (port1 < 0) |
@@ -1611,95 +1602,39 @@ static int __usb_suspend_device (struct usb_device *udev, int port1, | |||
1611 | return 0; | 1602 | return 0; |
1612 | } | 1603 | } |
1613 | 1604 | ||
1614 | /* suspend interface drivers; if this is a hub, it | 1605 | /* all interfaces must already be suspended */ |
1615 | * suspends the child devices | ||
1616 | */ | ||
1617 | if (udev->actconfig) { | 1606 | if (udev->actconfig) { |
1618 | int i; | 1607 | int i; |
1619 | 1608 | ||
1620 | for (i = 0; i < udev->actconfig->desc.bNumInterfaces; i++) { | 1609 | for (i = 0; i < udev->actconfig->desc.bNumInterfaces; i++) { |
1621 | struct usb_interface *intf; | 1610 | struct usb_interface *intf; |
1622 | struct usb_driver *driver; | ||
1623 | 1611 | ||
1624 | intf = udev->actconfig->interface[i]; | 1612 | intf = udev->actconfig->interface[i]; |
1625 | if (state.event <= intf->dev.power.power_state.event) | 1613 | if (is_active(intf)) { |
1626 | continue; | 1614 | dev_dbg(&intf->dev, "nyet suspended\n"); |
1627 | if (!intf->dev.driver) | 1615 | return -EBUSY; |
1628 | continue; | ||
1629 | driver = to_usb_driver(intf->dev.driver); | ||
1630 | |||
1631 | if (driver->suspend) { | ||
1632 | status = driver->suspend(intf, state); | ||
1633 | if (intf->dev.power.power_state.event != state.event | ||
1634 | || status) | ||
1635 | dev_err(&intf->dev, | ||
1636 | "suspend %d fail, code %d\n", | ||
1637 | state.event, status); | ||
1638 | } | ||
1639 | |||
1640 | /* only drivers with suspend() can ever resume(); | ||
1641 | * and after power loss, even they won't. | ||
1642 | * bus_rescan_devices() can rebind drivers later. | ||
1643 | * | ||
1644 | * FIXME the PM core self-deadlocks when unbinding | ||
1645 | * drivers during suspend/resume ... everything grabs | ||
1646 | * dpm_sem (not a spinlock, ugh). we want to unbind, | ||
1647 | * since we know every driver's probe/disconnect works | ||
1648 | * even for drivers that can't suspend. | ||
1649 | */ | ||
1650 | if (!driver->suspend || state.event > PM_EVENT_FREEZE) { | ||
1651 | #if 1 | ||
1652 | dev_warn(&intf->dev, "resume is unsafe!\n"); | ||
1653 | #else | ||
1654 | down_write(&usb_bus_type.rwsem); | ||
1655 | device_release_driver(&intf->dev); | ||
1656 | up_write(&usb_bus_type.rwsem); | ||
1657 | #endif | ||
1658 | } | 1616 | } |
1659 | } | 1617 | } |
1660 | } | 1618 | } |
1661 | 1619 | ||
1662 | /* | 1620 | /* we only change a device's upstream USB link. |
1663 | * FIXME this needs port power off call paths too, to help force | 1621 | * root hubs have no upstream USB link. |
1664 | * USB into the "generic" PM model. At least for devices on | ||
1665 | * ports that aren't using ganged switching (usually root hubs). | ||
1666 | * | ||
1667 | * NOTE: SRP-capable links should adopt more aggressive poweroff | ||
1668 | * policies (when HNP doesn't apply) once we have mechanisms to | ||
1669 | * turn power back on! (Likely not before 2.7...) | ||
1670 | */ | ||
1671 | if (state.event > PM_EVENT_FREEZE) { | ||
1672 | dev_warn(&udev->dev, "no poweroff yet, suspending instead\n"); | ||
1673 | } | ||
1674 | |||
1675 | /* "global suspend" of the HC-to-USB interface (root hub), or | ||
1676 | * "selective suspend" of just one hub-device link. | ||
1677 | */ | 1622 | */ |
1678 | if (!udev->parent) { | 1623 | if (udev->parent) |
1679 | struct usb_bus *bus = udev->bus; | ||
1680 | if (bus && bus->op->hub_suspend) { | ||
1681 | status = bus->op->hub_suspend (bus); | ||
1682 | if (status == 0) { | ||
1683 | dev_dbg(&udev->dev, "usb suspend\n"); | ||
1684 | usb_set_device_state(udev, | ||
1685 | USB_STATE_SUSPENDED); | ||
1686 | } | ||
1687 | } else | ||
1688 | status = -EOPNOTSUPP; | ||
1689 | } else | ||
1690 | status = hub_port_suspend(hdev_to_hub(udev->parent), port1, | 1624 | status = hub_port_suspend(hdev_to_hub(udev->parent), port1, |
1691 | udev); | 1625 | udev); |
1692 | 1626 | ||
1693 | if (status == 0) | 1627 | if (status == 0) |
1694 | udev->dev.power.power_state = state; | 1628 | udev->dev.power.power_state = PMSG_SUSPEND; |
1695 | return status; | 1629 | return status; |
1696 | } | 1630 | } |
1697 | 1631 | ||
1698 | /** | 1632 | #endif |
1633 | |||
1634 | /* | ||
1699 | * usb_suspend_device - suspend a usb device | 1635 | * usb_suspend_device - suspend a usb device |
1700 | * @udev: device that's no longer in active use | 1636 | * @udev: device that's no longer in active use |
1701 | * @state: PMSG_SUSPEND to suspend | 1637 | * Context: must be able to sleep; device not locked; pm locks held |
1702 | * Context: must be able to sleep; device not locked | ||
1703 | * | 1638 | * |
1704 | * Suspends a USB device that isn't in active use, conserving power. | 1639 | * Suspends a USB device that isn't in active use, conserving power. |
1705 | * Devices may wake out of a suspend, if anything important happens, | 1640 | * Devices may wake out of a suspend, if anything important happens, |
@@ -1707,37 +1642,49 @@ static int __usb_suspend_device (struct usb_device *udev, int port1, | |||
1707 | * suspend by the host, using usb_resume_device(). It's also routine | 1642 | * suspend by the host, using usb_resume_device(). It's also routine |
1708 | * to disconnect devices while they are suspended. | 1643 | * to disconnect devices while they are suspended. |
1709 | * | 1644 | * |
1645 | * This only affects the USB hardware for a device; its interfaces | ||
1646 | * (and, for hubs, child devices) must already have been suspended. | ||
1647 | * | ||
1710 | * Suspending OTG devices may trigger HNP, if that's been enabled | 1648 | * Suspending OTG devices may trigger HNP, if that's been enabled |
1711 | * between a pair of dual-role devices. That will change roles, such | 1649 | * between a pair of dual-role devices. That will change roles, such |
1712 | * as from A-Host to A-Peripheral or from B-Host back to B-Peripheral. | 1650 | * as from A-Host to A-Peripheral or from B-Host back to B-Peripheral. |
1713 | * | 1651 | * |
1714 | * Returns 0 on success, else negative errno. | 1652 | * Returns 0 on success, else negative errno. |
1715 | */ | 1653 | */ |
1716 | int usb_suspend_device(struct usb_device *udev, pm_message_t state) | 1654 | int usb_suspend_device(struct usb_device *udev) |
1717 | { | 1655 | { |
1656 | #ifdef CONFIG_USB_SUSPEND | ||
1718 | int port1, status; | 1657 | int port1, status; |
1719 | 1658 | ||
1720 | port1 = locktree(udev); | 1659 | port1 = locktree(udev); |
1721 | if (port1 < 0) | 1660 | if (port1 < 0) |
1722 | return port1; | 1661 | return port1; |
1723 | 1662 | ||
1724 | status = __usb_suspend_device(udev, port1, state); | 1663 | status = __usb_suspend_device(udev, port1); |
1725 | usb_unlock_device(udev); | 1664 | usb_unlock_device(udev); |
1726 | return status; | 1665 | return status; |
1666 | #else | ||
1667 | /* NOTE: udev->state unchanged, it's not lying ... */ | ||
1668 | udev->dev.power.power_state = PMSG_SUSPEND; | ||
1669 | return 0; | ||
1670 | #endif | ||
1727 | } | 1671 | } |
1728 | 1672 | ||
1729 | /* | 1673 | /* |
1674 | * If the USB "suspend" state is in use (rather than "global suspend"), | ||
1675 | * many devices will be individually taken out of suspend state using | ||
1676 | * special" resume" signaling. These routines kick in shortly after | ||
1730 | * hardware resume signaling is finished, either because of selective | 1677 | * hardware resume signaling is finished, either because of selective |
1731 | * resume (by host) or remote wakeup (by device) ... now see what changed | 1678 | * resume (by host) or remote wakeup (by device) ... now see what changed |
1732 | * in the tree that's rooted at this device. | 1679 | * in the tree that's rooted at this device. |
1733 | */ | 1680 | */ |
1734 | static int finish_port_resume(struct usb_device *udev) | 1681 | static int finish_device_resume(struct usb_device *udev) |
1735 | { | 1682 | { |
1736 | int status; | 1683 | int status; |
1737 | u16 devstatus; | 1684 | u16 devstatus; |
1738 | 1685 | ||
1739 | /* caller owns the udev device lock */ | 1686 | /* caller owns the udev device lock */ |
1740 | dev_dbg(&udev->dev, "usb resume\n"); | 1687 | dev_dbg(&udev->dev, "finish resume\n"); |
1741 | 1688 | ||
1742 | /* usb ch9 identifies four variants of SUSPENDED, based on what | 1689 | /* usb ch9 identifies four variants of SUSPENDED, based on what |
1743 | * state the device resumes to. Linux currently won't see the | 1690 | * state the device resumes to. Linux currently won't see the |
@@ -1747,7 +1694,6 @@ static int finish_port_resume(struct usb_device *udev) | |||
1747 | usb_set_device_state(udev, udev->actconfig | 1694 | usb_set_device_state(udev, udev->actconfig |
1748 | ? USB_STATE_CONFIGURED | 1695 | ? USB_STATE_CONFIGURED |
1749 | : USB_STATE_ADDRESS); | 1696 | : USB_STATE_ADDRESS); |
1750 | udev->dev.power.power_state = PMSG_ON; | ||
1751 | 1697 | ||
1752 | /* 10.5.4.5 says be sure devices in the tree are still there. | 1698 | /* 10.5.4.5 says be sure devices in the tree are still there. |
1753 | * For now let's assume the device didn't go crazy on resume, | 1699 | * For now let's assume the device didn't go crazy on resume, |
@@ -1760,9 +1706,11 @@ static int finish_port_resume(struct usb_device *udev) | |||
1760 | status); | 1706 | status); |
1761 | else if (udev->actconfig) { | 1707 | else if (udev->actconfig) { |
1762 | unsigned i; | 1708 | unsigned i; |
1709 | int (*resume)(struct device *); | ||
1763 | 1710 | ||
1764 | le16_to_cpus(&devstatus); | 1711 | le16_to_cpus(&devstatus); |
1765 | if (devstatus & (1 << USB_DEVICE_REMOTE_WAKEUP)) { | 1712 | if (devstatus & (1 << USB_DEVICE_REMOTE_WAKEUP) |
1713 | && udev->parent) { | ||
1766 | status = usb_control_msg(udev, | 1714 | status = usb_control_msg(udev, |
1767 | usb_sndctrlpipe(udev, 0), | 1715 | usb_sndctrlpipe(udev, 0), |
1768 | USB_REQ_CLEAR_FEATURE, | 1716 | USB_REQ_CLEAR_FEATURE, |
@@ -1778,33 +1726,11 @@ static int finish_port_resume(struct usb_device *udev) | |||
1778 | } | 1726 | } |
1779 | 1727 | ||
1780 | /* resume interface drivers; if this is a hub, it | 1728 | /* resume interface drivers; if this is a hub, it |
1781 | * resumes the child devices | 1729 | * may have a child resume event to deal with soon |
1782 | */ | 1730 | */ |
1783 | for (i = 0; i < udev->actconfig->desc.bNumInterfaces; i++) { | 1731 | resume = udev->dev.bus->resume; |
1784 | struct usb_interface *intf; | 1732 | for (i = 0; i < udev->actconfig->desc.bNumInterfaces; i++) |
1785 | struct usb_driver *driver; | 1733 | (void) resume(&udev->actconfig->interface[i]->dev); |
1786 | |||
1787 | intf = udev->actconfig->interface[i]; | ||
1788 | if (intf->dev.power.power_state.event == PM_EVENT_ON) | ||
1789 | continue; | ||
1790 | if (!intf->dev.driver) { | ||
1791 | /* FIXME maybe force to alt 0 */ | ||
1792 | continue; | ||
1793 | } | ||
1794 | driver = to_usb_driver(intf->dev.driver); | ||
1795 | |||
1796 | /* bus_rescan_devices() may rebind drivers */ | ||
1797 | if (!driver->resume) | ||
1798 | continue; | ||
1799 | |||
1800 | /* can we do better than just logging errors? */ | ||
1801 | status = driver->resume(intf); | ||
1802 | if (intf->dev.power.power_state.event != PM_EVENT_ON | ||
1803 | || status) | ||
1804 | dev_dbg(&intf->dev, | ||
1805 | "resume fail, state %d code %d\n", | ||
1806 | intf->dev.power.power_state.event, status); | ||
1807 | } | ||
1808 | status = 0; | 1734 | status = 0; |
1809 | 1735 | ||
1810 | } else if (udev->devnum <= 0) { | 1736 | } else if (udev->devnum <= 0) { |
@@ -1814,6 +1740,8 @@ static int finish_port_resume(struct usb_device *udev) | |||
1814 | return status; | 1740 | return status; |
1815 | } | 1741 | } |
1816 | 1742 | ||
1743 | #ifdef CONFIG_USB_SUSPEND | ||
1744 | |||
1817 | static int | 1745 | static int |
1818 | hub_port_resume(struct usb_hub *hub, int port1, struct usb_device *udev) | 1746 | hub_port_resume(struct usb_hub *hub, int port1, struct usb_device *udev) |
1819 | { | 1747 | { |
@@ -1859,7 +1787,7 @@ hub_port_resume(struct usb_hub *hub, int port1, struct usb_device *udev) | |||
1859 | /* TRSMRCY = 10 msec */ | 1787 | /* TRSMRCY = 10 msec */ |
1860 | msleep(10); | 1788 | msleep(10); |
1861 | if (udev) | 1789 | if (udev) |
1862 | status = finish_port_resume(udev); | 1790 | status = finish_device_resume(udev); |
1863 | } | 1791 | } |
1864 | } | 1792 | } |
1865 | if (status < 0) | 1793 | if (status < 0) |
@@ -1868,12 +1796,12 @@ hub_port_resume(struct usb_hub *hub, int port1, struct usb_device *udev) | |||
1868 | return status; | 1796 | return status; |
1869 | } | 1797 | } |
1870 | 1798 | ||
1871 | static int hub_resume (struct usb_interface *intf); | 1799 | #endif |
1872 | 1800 | ||
1873 | /** | 1801 | /* |
1874 | * usb_resume_device - re-activate a suspended usb device | 1802 | * usb_resume_device - re-activate a suspended usb device |
1875 | * @udev: device to re-activate | 1803 | * @udev: device to re-activate |
1876 | * Context: must be able to sleep; device not locked | 1804 | * Context: must be able to sleep; device not locked; pm locks held |
1877 | * | 1805 | * |
1878 | * This will re-activate the suspended device, increasing power usage | 1806 | * This will re-activate the suspended device, increasing power usage |
1879 | * while letting drivers communicate again with its endpoints. | 1807 | * while letting drivers communicate again with its endpoints. |
@@ -1891,35 +1819,22 @@ int usb_resume_device(struct usb_device *udev) | |||
1891 | if (port1 < 0) | 1819 | if (port1 < 0) |
1892 | return port1; | 1820 | return port1; |
1893 | 1821 | ||
1894 | /* "global resume" of the HC-to-USB interface (root hub), or | 1822 | #ifdef CONFIG_USB_SUSPEND |
1895 | * selective resume of one hub-to-device port | 1823 | /* selective resume of one downstream hub-to-device port */ |
1896 | */ | 1824 | if (udev->parent) { |
1897 | if (!udev->parent) { | 1825 | if (udev->state == USB_STATE_SUSPENDED) { |
1898 | struct usb_bus *bus = udev->bus; | 1826 | // NOTE swsusp may bork us, device state being wrong... |
1899 | if (bus && bus->op->hub_resume) { | 1827 | // NOTE this fails if parent is also suspended... |
1900 | status = bus->op->hub_resume (bus); | 1828 | status = hub_port_resume(hdev_to_hub(udev->parent), |
1829 | port1, udev); | ||
1901 | } else | 1830 | } else |
1902 | status = -EOPNOTSUPP; | 1831 | status = 0; |
1903 | if (status == 0) { | 1832 | } else |
1904 | dev_dbg(&udev->dev, "usb resume\n"); | 1833 | #endif |
1905 | /* TRSMRCY = 10 msec */ | 1834 | status = finish_device_resume(udev); |
1906 | msleep(10); | 1835 | if (status < 0) |
1907 | usb_set_device_state (udev, USB_STATE_CONFIGURED); | ||
1908 | udev->dev.power.power_state = PMSG_ON; | ||
1909 | status = hub_resume (udev | ||
1910 | ->actconfig->interface[0]); | ||
1911 | } | ||
1912 | } else if (udev->state == USB_STATE_SUSPENDED) { | ||
1913 | // NOTE this fails if parent is also suspended... | ||
1914 | status = hub_port_resume(hdev_to_hub(udev->parent), | ||
1915 | port1, udev); | ||
1916 | } else { | ||
1917 | status = 0; | ||
1918 | } | ||
1919 | if (status < 0) { | ||
1920 | dev_dbg(&udev->dev, "can't resume, status %d\n", | 1836 | dev_dbg(&udev->dev, "can't resume, status %d\n", |
1921 | status); | 1837 | status); |
1922 | } | ||
1923 | 1838 | ||
1924 | usb_unlock_device(udev); | 1839 | usb_unlock_device(udev); |
1925 | 1840 | ||
@@ -1936,6 +1851,8 @@ static int remote_wakeup(struct usb_device *udev) | |||
1936 | { | 1851 | { |
1937 | int status = 0; | 1852 | int status = 0; |
1938 | 1853 | ||
1854 | #ifdef CONFIG_USB_SUSPEND | ||
1855 | |||
1939 | /* don't repeat RESUME sequence if this device | 1856 | /* don't repeat RESUME sequence if this device |
1940 | * was already woken up by some other task | 1857 | * was already woken up by some other task |
1941 | */ | 1858 | */ |
@@ -1944,38 +1861,52 @@ static int remote_wakeup(struct usb_device *udev) | |||
1944 | dev_dbg(&udev->dev, "RESUME (wakeup)\n"); | 1861 | dev_dbg(&udev->dev, "RESUME (wakeup)\n"); |
1945 | /* TRSMRCY = 10 msec */ | 1862 | /* TRSMRCY = 10 msec */ |
1946 | msleep(10); | 1863 | msleep(10); |
1947 | status = finish_port_resume(udev); | 1864 | status = finish_device_resume(udev); |
1948 | } | 1865 | } |
1949 | up(&udev->serialize); | 1866 | up(&udev->serialize); |
1867 | #endif | ||
1950 | return status; | 1868 | return status; |
1951 | } | 1869 | } |
1952 | 1870 | ||
1953 | static int hub_suspend(struct usb_interface *intf, pm_message_t state) | 1871 | static int hub_suspend(struct usb_interface *intf, pm_message_t msg) |
1954 | { | 1872 | { |
1955 | struct usb_hub *hub = usb_get_intfdata (intf); | 1873 | struct usb_hub *hub = usb_get_intfdata (intf); |
1956 | struct usb_device *hdev = hub->hdev; | 1874 | struct usb_device *hdev = hub->hdev; |
1957 | unsigned port1; | 1875 | unsigned port1; |
1958 | int status; | ||
1959 | 1876 | ||
1960 | /* stop khubd and related activity */ | 1877 | /* fail if children aren't already suspended */ |
1961 | hub_quiesce(hub); | ||
1962 | |||
1963 | /* then suspend every port */ | ||
1964 | for (port1 = 1; port1 <= hdev->maxchild; port1++) { | 1878 | for (port1 = 1; port1 <= hdev->maxchild; port1++) { |
1965 | struct usb_device *udev; | 1879 | struct usb_device *udev; |
1966 | 1880 | ||
1967 | udev = hdev->children [port1-1]; | 1881 | udev = hdev->children [port1-1]; |
1968 | if (!udev) | 1882 | if (udev && (udev->dev.power.power_state.event |
1969 | continue; | 1883 | == PM_EVENT_ON |
1970 | down(&udev->serialize); | 1884 | #ifdef CONFIG_USB_SUSPEND |
1971 | status = __usb_suspend_device(udev, port1, state); | 1885 | || udev->state != USB_STATE_SUSPENDED |
1972 | up(&udev->serialize); | 1886 | #endif |
1973 | if (status < 0) | 1887 | )) { |
1974 | dev_dbg(&intf->dev, "suspend port %d --> %d\n", | 1888 | dev_dbg(&intf->dev, "port %d nyet suspended\n", port1); |
1975 | port1, status); | 1889 | return -EBUSY; |
1890 | } | ||
1976 | } | 1891 | } |
1977 | 1892 | ||
1978 | intf->dev.power.power_state = state; | 1893 | /* "global suspend" of the downstream HC-to-USB interface */ |
1894 | if (!hdev->parent) { | ||
1895 | struct usb_bus *bus = hdev->bus; | ||
1896 | if (bus) { | ||
1897 | int status = hcd_bus_suspend (bus); | ||
1898 | |||
1899 | if (status != 0) { | ||
1900 | dev_dbg(&hdev->dev, "'global' suspend %d\n", | ||
1901 | status); | ||
1902 | return status; | ||
1903 | } | ||
1904 | } else | ||
1905 | return -EOPNOTSUPP; | ||
1906 | } | ||
1907 | |||
1908 | /* stop khubd and related activity */ | ||
1909 | hub_quiesce(hub); | ||
1979 | return 0; | 1910 | return 0; |
1980 | } | 1911 | } |
1981 | 1912 | ||
@@ -1983,11 +1914,35 @@ static int hub_resume(struct usb_interface *intf) | |||
1983 | { | 1914 | { |
1984 | struct usb_device *hdev = interface_to_usbdev(intf); | 1915 | struct usb_device *hdev = interface_to_usbdev(intf); |
1985 | struct usb_hub *hub = usb_get_intfdata (intf); | 1916 | struct usb_hub *hub = usb_get_intfdata (intf); |
1986 | unsigned port1; | ||
1987 | int status; | 1917 | int status; |
1988 | 1918 | ||
1989 | if (intf->dev.power.power_state.event == PM_EVENT_ON) | 1919 | /* "global resume" of the downstream HC-to-USB interface */ |
1990 | return 0; | 1920 | if (!hdev->parent) { |
1921 | struct usb_bus *bus = hdev->bus; | ||
1922 | if (bus) { | ||
1923 | status = hcd_bus_resume (bus); | ||
1924 | if (status) { | ||
1925 | dev_dbg(&intf->dev, "'global' resume %d\n", | ||
1926 | status); | ||
1927 | return status; | ||
1928 | } | ||
1929 | } else | ||
1930 | return -EOPNOTSUPP; | ||
1931 | if (status == 0) { | ||
1932 | /* TRSMRCY = 10 msec */ | ||
1933 | msleep(10); | ||
1934 | } | ||
1935 | } | ||
1936 | |||
1937 | hub_activate(hub); | ||
1938 | |||
1939 | /* REVISIT: this recursion probably shouldn't exist. Remove | ||
1940 | * this code sometime, after retesting with different root and | ||
1941 | * external hubs. | ||
1942 | */ | ||
1943 | #ifdef CONFIG_USB_SUSPEND | ||
1944 | { | ||
1945 | unsigned port1; | ||
1991 | 1946 | ||
1992 | for (port1 = 1; port1 <= hdev->maxchild; port1++) { | 1947 | for (port1 = 1; port1 <= hdev->maxchild; port1++) { |
1993 | struct usb_device *udev; | 1948 | struct usb_device *udev; |
@@ -2013,7 +1968,7 @@ static int hub_resume(struct usb_interface *intf) | |||
2013 | if (portstat & USB_PORT_STAT_SUSPEND) | 1968 | if (portstat & USB_PORT_STAT_SUSPEND) |
2014 | status = hub_port_resume(hub, port1, udev); | 1969 | status = hub_port_resume(hub, port1, udev); |
2015 | else { | 1970 | else { |
2016 | status = finish_port_resume(udev); | 1971 | status = finish_device_resume(udev); |
2017 | if (status < 0) { | 1972 | if (status < 0) { |
2018 | dev_dbg(&intf->dev, "resume port %d --> %d\n", | 1973 | dev_dbg(&intf->dev, "resume port %d --> %d\n", |
2019 | port1, status); | 1974 | port1, status); |
@@ -2022,43 +1977,31 @@ static int hub_resume(struct usb_interface *intf) | |||
2022 | } | 1977 | } |
2023 | up(&udev->serialize); | 1978 | up(&udev->serialize); |
2024 | } | 1979 | } |
2025 | intf->dev.power.power_state = PMSG_ON; | 1980 | } |
2026 | 1981 | #endif | |
2027 | hub->resume_root_hub = 0; | ||
2028 | hub_activate(hub); | ||
2029 | return 0; | 1982 | return 0; |
2030 | } | 1983 | } |
2031 | 1984 | ||
2032 | void usb_resume_root_hub(struct usb_device *hdev) | 1985 | void usb_suspend_root_hub(struct usb_device *hdev) |
2033 | { | 1986 | { |
2034 | struct usb_hub *hub = hdev_to_hub(hdev); | 1987 | struct usb_hub *hub = hdev_to_hub(hdev); |
2035 | 1988 | ||
2036 | hub->resume_root_hub = 1; | 1989 | /* This also makes any led blinker stop retriggering. We're called |
2037 | kick_khubd(hub); | 1990 | * from irq, so the blinker might still be scheduled. Caller promises |
1991 | * that the root hub status URB will be canceled. | ||
1992 | */ | ||
1993 | __hub_quiesce(hub); | ||
1994 | mark_quiesced(to_usb_interface(hub->intfdev)); | ||
2038 | } | 1995 | } |
2039 | 1996 | ||
2040 | #else /* !CONFIG_USB_SUSPEND */ | 1997 | void usb_resume_root_hub(struct usb_device *hdev) |
2041 | |||
2042 | int usb_suspend_device(struct usb_device *udev, pm_message_t state) | ||
2043 | { | 1998 | { |
2044 | return 0; | 1999 | struct usb_hub *hub = hdev_to_hub(hdev); |
2045 | } | ||
2046 | 2000 | ||
2047 | int usb_resume_device(struct usb_device *udev) | 2001 | hub->resume_root_hub = 1; |
2048 | { | 2002 | kick_khubd(hub); |
2049 | return 0; | ||
2050 | } | 2003 | } |
2051 | 2004 | ||
2052 | #define hub_suspend NULL | ||
2053 | #define hub_resume NULL | ||
2054 | #define remote_wakeup(x) 0 | ||
2055 | |||
2056 | #endif /* CONFIG_USB_SUSPEND */ | ||
2057 | |||
2058 | EXPORT_SYMBOL(usb_suspend_device); | ||
2059 | EXPORT_SYMBOL(usb_resume_device); | ||
2060 | |||
2061 | |||
2062 | 2005 | ||
2063 | /* USB 2.0 spec, 7.1.7.3 / fig 7-29: | 2006 | /* USB 2.0 spec, 7.1.7.3 / fig 7-29: |
2064 | * | 2007 | * |
@@ -2467,6 +2410,7 @@ static void hub_port_connect_change(struct usb_hub *hub, int port1, | |||
2467 | { | 2410 | { |
2468 | struct usb_device *hdev = hub->hdev; | 2411 | struct usb_device *hdev = hub->hdev; |
2469 | struct device *hub_dev = hub->intfdev; | 2412 | struct device *hub_dev = hub->intfdev; |
2413 | u16 wHubCharacteristics = le16_to_cpu(hub->descriptor->wHubCharacteristics); | ||
2470 | int status, i; | 2414 | int status, i; |
2471 | 2415 | ||
2472 | dev_dbg (hub_dev, | 2416 | dev_dbg (hub_dev, |
@@ -2504,8 +2448,7 @@ static void hub_port_connect_change(struct usb_hub *hub, int port1, | |||
2504 | if (!(portstatus & USB_PORT_STAT_CONNECTION)) { | 2448 | if (!(portstatus & USB_PORT_STAT_CONNECTION)) { |
2505 | 2449 | ||
2506 | /* maybe switch power back on (e.g. root hub was reset) */ | 2450 | /* maybe switch power back on (e.g. root hub was reset) */ |
2507 | if ((hub->descriptor->wHubCharacteristics | 2451 | if ((wHubCharacteristics & HUB_CHAR_LPSM) < 2 |
2508 | & HUB_CHAR_LPSM) < 2 | ||
2509 | && !(portstatus & (1 << USB_PORT_FEAT_POWER))) | 2452 | && !(portstatus & (1 << USB_PORT_FEAT_POWER))) |
2510 | set_port_feature(hdev, port1, USB_PORT_FEAT_POWER); | 2453 | set_port_feature(hdev, port1, USB_PORT_FEAT_POWER); |
2511 | 2454 | ||
@@ -2684,21 +2627,28 @@ static void hub_events(void) | |||
2684 | intf = to_usb_interface(hub->intfdev); | 2627 | intf = to_usb_interface(hub->intfdev); |
2685 | hub_dev = &intf->dev; | 2628 | hub_dev = &intf->dev; |
2686 | 2629 | ||
2687 | dev_dbg(hub_dev, "state %d ports %d chg %04x evt %04x\n", | 2630 | i = hub->resume_root_hub; |
2631 | |||
2632 | dev_dbg(hub_dev, "state %d ports %d chg %04x evt %04x%s\n", | ||
2688 | hdev->state, hub->descriptor | 2633 | hdev->state, hub->descriptor |
2689 | ? hub->descriptor->bNbrPorts | 2634 | ? hub->descriptor->bNbrPorts |
2690 | : 0, | 2635 | : 0, |
2691 | /* NOTE: expects max 15 ports... */ | 2636 | /* NOTE: expects max 15 ports... */ |
2692 | (u16) hub->change_bits[0], | 2637 | (u16) hub->change_bits[0], |
2693 | (u16) hub->event_bits[0]); | 2638 | (u16) hub->event_bits[0], |
2639 | i ? ", resume root" : ""); | ||
2694 | 2640 | ||
2695 | usb_get_intf(intf); | 2641 | usb_get_intf(intf); |
2696 | i = hub->resume_root_hub; | ||
2697 | spin_unlock_irq(&hub_event_lock); | 2642 | spin_unlock_irq(&hub_event_lock); |
2698 | 2643 | ||
2699 | /* Is this is a root hub wanting to be resumed? */ | 2644 | /* Is this is a root hub wanting to reactivate the downstream |
2700 | if (i) | 2645 | * ports? If so, be sure the interface resumes even if its |
2701 | usb_resume_device(hdev); | 2646 | * stub "device" node was never suspended. |
2647 | */ | ||
2648 | if (i) { | ||
2649 | dpm_runtime_resume(&hdev->dev); | ||
2650 | dpm_runtime_resume(&intf->dev); | ||
2651 | } | ||
2702 | 2652 | ||
2703 | /* Lock the device, then check to see if we were | 2653 | /* Lock the device, then check to see if we were |
2704 | * disconnected while waiting for the lock to succeed. */ | 2654 | * disconnected while waiting for the lock to succeed. */ |
diff --git a/drivers/usb/core/hub.h b/drivers/usb/core/hub.h index e7fa9b5a521e..bf23f8978024 100644 --- a/drivers/usb/core/hub.h +++ b/drivers/usb/core/hub.h | |||
@@ -131,7 +131,7 @@ struct usb_hub_descriptor { | |||
131 | __u8 bDescLength; | 131 | __u8 bDescLength; |
132 | __u8 bDescriptorType; | 132 | __u8 bDescriptorType; |
133 | __u8 bNbrPorts; | 133 | __u8 bNbrPorts; |
134 | __u16 wHubCharacteristics; | 134 | __le16 wHubCharacteristics; |
135 | __u8 bPwrOn2PwrGood; | 135 | __u8 bPwrOn2PwrGood; |
136 | __u8 bHubContrCurrent; | 136 | __u8 bHubContrCurrent; |
137 | /* add 1 bit for hub status change; round to bytes */ | 137 | /* add 1 bit for hub status change; round to bytes */ |
diff --git a/drivers/usb/core/inode.c b/drivers/usb/core/inode.c index 640f41e47029..c44bbedec817 100644 --- a/drivers/usb/core/inode.c +++ b/drivers/usb/core/inode.c | |||
@@ -39,13 +39,13 @@ | |||
39 | #include <linux/usbdevice_fs.h> | 39 | #include <linux/usbdevice_fs.h> |
40 | #include <linux/smp_lock.h> | 40 | #include <linux/smp_lock.h> |
41 | #include <linux/parser.h> | 41 | #include <linux/parser.h> |
42 | #include <linux/notifier.h> | ||
42 | #include <asm/byteorder.h> | 43 | #include <asm/byteorder.h> |
43 | #include "usb.h" | 44 | #include "usb.h" |
44 | #include "hcd.h" | 45 | #include "hcd.h" |
45 | 46 | ||
46 | static struct super_operations usbfs_ops; | 47 | static struct super_operations usbfs_ops; |
47 | static struct file_operations default_file_operations; | 48 | static struct file_operations default_file_operations; |
48 | static struct inode_operations usbfs_dir_inode_operations; | ||
49 | static struct vfsmount *usbfs_mount; | 49 | static struct vfsmount *usbfs_mount; |
50 | static int usbfs_mount_count; /* = 0 */ | 50 | static int usbfs_mount_count; /* = 0 */ |
51 | static int ignore_mount = 0; | 51 | static int ignore_mount = 0; |
@@ -261,7 +261,7 @@ static struct inode *usbfs_get_inode (struct super_block *sb, int mode, dev_t de | |||
261 | inode->i_fop = &default_file_operations; | 261 | inode->i_fop = &default_file_operations; |
262 | break; | 262 | break; |
263 | case S_IFDIR: | 263 | case S_IFDIR: |
264 | inode->i_op = &usbfs_dir_inode_operations; | 264 | inode->i_op = &simple_dir_inode_operations; |
265 | inode->i_fop = &simple_dir_operations; | 265 | inode->i_fop = &simple_dir_operations; |
266 | 266 | ||
267 | /* directory inodes start off with i_nlink == 2 (for "." entry) */ | 267 | /* directory inodes start off with i_nlink == 2 (for "." entry) */ |
@@ -416,10 +416,6 @@ static struct file_operations default_file_operations = { | |||
416 | .llseek = default_file_lseek, | 416 | .llseek = default_file_lseek, |
417 | }; | 417 | }; |
418 | 418 | ||
419 | static struct inode_operations usbfs_dir_inode_operations = { | ||
420 | .lookup = simple_lookup, | ||
421 | }; | ||
422 | |||
423 | static struct super_operations usbfs_ops = { | 419 | static struct super_operations usbfs_ops = { |
424 | .statfs = simple_statfs, | 420 | .statfs = simple_statfs, |
425 | .drop_inode = generic_delete_inode, | 421 | .drop_inode = generic_delete_inode, |
@@ -619,7 +615,7 @@ void usbfs_update_special (void) | |||
619 | } | 615 | } |
620 | } | 616 | } |
621 | 617 | ||
622 | void usbfs_add_bus(struct usb_bus *bus) | 618 | static void usbfs_add_bus(struct usb_bus *bus) |
623 | { | 619 | { |
624 | struct dentry *parent; | 620 | struct dentry *parent; |
625 | char name[8]; | 621 | char name[8]; |
@@ -642,12 +638,9 @@ void usbfs_add_bus(struct usb_bus *bus) | |||
642 | err ("error creating usbfs bus entry"); | 638 | err ("error creating usbfs bus entry"); |
643 | return; | 639 | return; |
644 | } | 640 | } |
645 | |||
646 | usbfs_update_special(); | ||
647 | usbfs_conn_disc_event(); | ||
648 | } | 641 | } |
649 | 642 | ||
650 | void usbfs_remove_bus(struct usb_bus *bus) | 643 | static void usbfs_remove_bus(struct usb_bus *bus) |
651 | { | 644 | { |
652 | if (bus->usbfs_dentry) { | 645 | if (bus->usbfs_dentry) { |
653 | fs_remove_file (bus->usbfs_dentry); | 646 | fs_remove_file (bus->usbfs_dentry); |
@@ -659,12 +652,9 @@ void usbfs_remove_bus(struct usb_bus *bus) | |||
659 | remove_special_files(); | 652 | remove_special_files(); |
660 | num_buses = 0; | 653 | num_buses = 0; |
661 | } | 654 | } |
662 | |||
663 | usbfs_update_special(); | ||
664 | usbfs_conn_disc_event(); | ||
665 | } | 655 | } |
666 | 656 | ||
667 | void usbfs_add_device(struct usb_device *dev) | 657 | static void usbfs_add_device(struct usb_device *dev) |
668 | { | 658 | { |
669 | char name[8]; | 659 | char name[8]; |
670 | int i; | 660 | int i; |
@@ -690,12 +680,9 @@ void usbfs_add_device(struct usb_device *dev) | |||
690 | } | 680 | } |
691 | if (dev->usbfs_dentry->d_inode) | 681 | if (dev->usbfs_dentry->d_inode) |
692 | dev->usbfs_dentry->d_inode->i_size = i_size; | 682 | dev->usbfs_dentry->d_inode->i_size = i_size; |
693 | |||
694 | usbfs_update_special(); | ||
695 | usbfs_conn_disc_event(); | ||
696 | } | 683 | } |
697 | 684 | ||
698 | void usbfs_remove_device(struct usb_device *dev) | 685 | static void usbfs_remove_device(struct usb_device *dev) |
699 | { | 686 | { |
700 | struct dev_state *ds; | 687 | struct dev_state *ds; |
701 | struct siginfo sinfo; | 688 | struct siginfo sinfo; |
@@ -713,13 +700,36 @@ void usbfs_remove_device(struct usb_device *dev) | |||
713 | sinfo.si_errno = EPIPE; | 700 | sinfo.si_errno = EPIPE; |
714 | sinfo.si_code = SI_ASYNCIO; | 701 | sinfo.si_code = SI_ASYNCIO; |
715 | sinfo.si_addr = ds->disccontext; | 702 | sinfo.si_addr = ds->disccontext; |
716 | send_sig_info(ds->discsignr, &sinfo, ds->disctask); | 703 | kill_proc_info_as_uid(ds->discsignr, &sinfo, ds->disc_pid, ds->disc_uid, ds->disc_euid); |
717 | } | 704 | } |
718 | } | 705 | } |
706 | } | ||
707 | |||
708 | static int usbfs_notify(struct notifier_block *self, unsigned long action, void *dev) | ||
709 | { | ||
710 | switch (action) { | ||
711 | case USB_DEVICE_ADD: | ||
712 | usbfs_add_device(dev); | ||
713 | break; | ||
714 | case USB_DEVICE_REMOVE: | ||
715 | usbfs_remove_device(dev); | ||
716 | break; | ||
717 | case USB_BUS_ADD: | ||
718 | usbfs_add_bus(dev); | ||
719 | break; | ||
720 | case USB_BUS_REMOVE: | ||
721 | usbfs_remove_bus(dev); | ||
722 | } | ||
723 | |||
719 | usbfs_update_special(); | 724 | usbfs_update_special(); |
720 | usbfs_conn_disc_event(); | 725 | usbfs_conn_disc_event(); |
726 | return NOTIFY_OK; | ||
721 | } | 727 | } |
722 | 728 | ||
729 | static struct notifier_block usbfs_nb = { | ||
730 | .notifier_call = usbfs_notify, | ||
731 | }; | ||
732 | |||
723 | /* --------------------------------------------------------------------- */ | 733 | /* --------------------------------------------------------------------- */ |
724 | 734 | ||
725 | static struct proc_dir_entry *usbdir = NULL; | 735 | static struct proc_dir_entry *usbdir = NULL; |
@@ -732,6 +742,8 @@ int __init usbfs_init(void) | |||
732 | if (retval) | 742 | if (retval) |
733 | return retval; | 743 | return retval; |
734 | 744 | ||
745 | usb_register_notify(&usbfs_nb); | ||
746 | |||
735 | /* create mount point for usbfs */ | 747 | /* create mount point for usbfs */ |
736 | usbdir = proc_mkdir("usb", proc_bus); | 748 | usbdir = proc_mkdir("usb", proc_bus); |
737 | 749 | ||
@@ -740,6 +752,7 @@ int __init usbfs_init(void) | |||
740 | 752 | ||
741 | void usbfs_cleanup(void) | 753 | void usbfs_cleanup(void) |
742 | { | 754 | { |
755 | usb_unregister_notify(&usbfs_nb); | ||
743 | unregister_filesystem(&usb_fs_type); | 756 | unregister_filesystem(&usb_fs_type); |
744 | if (usbdir) | 757 | if (usbdir) |
745 | remove_proc_entry("usb", proc_bus); | 758 | remove_proc_entry("usb", proc_bus); |
diff --git a/drivers/usb/core/message.c b/drivers/usb/core/message.c index c47c8052b486..fe74f99ca5f4 100644 --- a/drivers/usb/core/message.c +++ b/drivers/usb/core/message.c | |||
@@ -3,13 +3,6 @@ | |||
3 | */ | 3 | */ |
4 | 4 | ||
5 | #include <linux/config.h> | 5 | #include <linux/config.h> |
6 | |||
7 | #ifdef CONFIG_USB_DEBUG | ||
8 | #define DEBUG | ||
9 | #else | ||
10 | #undef DEBUG | ||
11 | #endif | ||
12 | |||
13 | #include <linux/pci.h> /* for scatterlist macros */ | 6 | #include <linux/pci.h> /* for scatterlist macros */ |
14 | #include <linux/usb.h> | 7 | #include <linux/usb.h> |
15 | #include <linux/module.h> | 8 | #include <linux/module.h> |
@@ -187,21 +180,37 @@ int usb_control_msg(struct usb_device *dev, unsigned int pipe, __u8 request, __u | |||
187 | * If a thread in your driver uses this call, make sure your disconnect() | 180 | * If a thread in your driver uses this call, make sure your disconnect() |
188 | * method can wait for it to complete. Since you don't have a handle on | 181 | * method can wait for it to complete. Since you don't have a handle on |
189 | * the URB used, you can't cancel the request. | 182 | * the URB used, you can't cancel the request. |
183 | * | ||
184 | * Because there is no usb_interrupt_msg() and no USBDEVFS_INTERRUPT | ||
185 | * ioctl, users are forced to abuse this routine by using it to submit | ||
186 | * URBs for interrupt endpoints. We will take the liberty of creating | ||
187 | * an interrupt URB (with the default interval) if the target is an | ||
188 | * interrupt endpoint. | ||
190 | */ | 189 | */ |
191 | int usb_bulk_msg(struct usb_device *usb_dev, unsigned int pipe, | 190 | int usb_bulk_msg(struct usb_device *usb_dev, unsigned int pipe, |
192 | void *data, int len, int *actual_length, int timeout) | 191 | void *data, int len, int *actual_length, int timeout) |
193 | { | 192 | { |
194 | struct urb *urb; | 193 | struct urb *urb; |
194 | struct usb_host_endpoint *ep; | ||
195 | 195 | ||
196 | if (len < 0) | 196 | ep = (usb_pipein(pipe) ? usb_dev->ep_in : usb_dev->ep_out) |
197 | [usb_pipeendpoint(pipe)]; | ||
198 | if (!ep || len < 0) | ||
197 | return -EINVAL; | 199 | return -EINVAL; |
198 | 200 | ||
199 | urb=usb_alloc_urb(0, GFP_KERNEL); | 201 | urb = usb_alloc_urb(0, GFP_KERNEL); |
200 | if (!urb) | 202 | if (!urb) |
201 | return -ENOMEM; | 203 | return -ENOMEM; |
202 | 204 | ||
203 | usb_fill_bulk_urb(urb, usb_dev, pipe, data, len, | 205 | if ((ep->desc.bmAttributes & USB_ENDPOINT_XFERTYPE_MASK) == |
204 | usb_api_blocking_completion, NULL); | 206 | USB_ENDPOINT_XFER_INT) { |
207 | pipe = (pipe & ~(3 << 30)) | (PIPE_INTERRUPT << 30); | ||
208 | usb_fill_int_urb(urb, usb_dev, pipe, data, len, | ||
209 | usb_api_blocking_completion, NULL, | ||
210 | ep->desc.bInterval); | ||
211 | } else | ||
212 | usb_fill_bulk_urb(urb, usb_dev, pipe, data, len, | ||
213 | usb_api_blocking_completion, NULL); | ||
205 | 214 | ||
206 | return usb_start_wait_urb(urb, timeout, actual_length); | 215 | return usb_start_wait_urb(urb, timeout, actual_length); |
207 | } | 216 | } |
@@ -321,7 +330,7 @@ int usb_sg_init ( | |||
321 | struct scatterlist *sg, | 330 | struct scatterlist *sg, |
322 | int nents, | 331 | int nents, |
323 | size_t length, | 332 | size_t length, |
324 | unsigned mem_flags | 333 | gfp_t mem_flags |
325 | ) | 334 | ) |
326 | { | 335 | { |
327 | int i; | 336 | int i; |
@@ -771,6 +780,31 @@ int usb_string(struct usb_device *dev, int index, char *buf, size_t size) | |||
771 | return err; | 780 | return err; |
772 | } | 781 | } |
773 | 782 | ||
783 | /** | ||
784 | * usb_cache_string - read a string descriptor and cache it for later use | ||
785 | * @udev: the device whose string descriptor is being read | ||
786 | * @index: the descriptor index | ||
787 | * | ||
788 | * Returns a pointer to a kmalloc'ed buffer containing the descriptor string, | ||
789 | * or NULL if the index is 0 or the string could not be read. | ||
790 | */ | ||
791 | char *usb_cache_string(struct usb_device *udev, int index) | ||
792 | { | ||
793 | char *buf; | ||
794 | char *smallbuf = NULL; | ||
795 | int len; | ||
796 | |||
797 | if (index > 0 && (buf = kmalloc(256, GFP_KERNEL)) != NULL) { | ||
798 | if ((len = usb_string(udev, index, buf, 256)) > 0) { | ||
799 | if ((smallbuf = kmalloc(++len, GFP_KERNEL)) == NULL) | ||
800 | return buf; | ||
801 | memcpy(smallbuf, buf, len); | ||
802 | } | ||
803 | kfree(buf); | ||
804 | } | ||
805 | return smallbuf; | ||
806 | } | ||
807 | |||
774 | /* | 808 | /* |
775 | * usb_get_device_descriptor - (re)reads the device descriptor (usbcore) | 809 | * usb_get_device_descriptor - (re)reads the device descriptor (usbcore) |
776 | * @dev: the device whose device descriptor is being updated | 810 | * @dev: the device whose device descriptor is being updated |
@@ -987,13 +1021,11 @@ void usb_disable_device(struct usb_device *dev, int skip_ep0) | |||
987 | 1021 | ||
988 | /* remove this interface if it has been registered */ | 1022 | /* remove this interface if it has been registered */ |
989 | interface = dev->actconfig->interface[i]; | 1023 | interface = dev->actconfig->interface[i]; |
990 | if (!klist_node_attached(&interface->dev.knode_bus)) | 1024 | if (!device_is_registered(&interface->dev)) |
991 | continue; | 1025 | continue; |
992 | dev_dbg (&dev->dev, "unregistering interface %s\n", | 1026 | dev_dbg (&dev->dev, "unregistering interface %s\n", |
993 | interface->dev.bus_id); | 1027 | interface->dev.bus_id); |
994 | usb_remove_sysfs_intf_files(interface); | 1028 | usb_remove_sysfs_intf_files(interface); |
995 | kfree(interface->cur_altsetting->string); | ||
996 | interface->cur_altsetting->string = NULL; | ||
997 | device_del (&interface->dev); | 1029 | device_del (&interface->dev); |
998 | } | 1030 | } |
999 | 1031 | ||
@@ -1133,6 +1165,8 @@ int usb_set_interface(struct usb_device *dev, int interface, int alternate) | |||
1133 | */ | 1165 | */ |
1134 | 1166 | ||
1135 | /* prevent submissions using previous endpoint settings */ | 1167 | /* prevent submissions using previous endpoint settings */ |
1168 | if (device_is_registered(&iface->dev)) | ||
1169 | usb_remove_sysfs_intf_files(iface); | ||
1136 | usb_disable_interface(dev, iface); | 1170 | usb_disable_interface(dev, iface); |
1137 | 1171 | ||
1138 | iface->cur_altsetting = alt; | 1172 | iface->cur_altsetting = alt; |
@@ -1168,6 +1202,8 @@ int usb_set_interface(struct usb_device *dev, int interface, int alternate) | |||
1168 | * (Likewise, EP0 never "halts" on well designed devices.) | 1202 | * (Likewise, EP0 never "halts" on well designed devices.) |
1169 | */ | 1203 | */ |
1170 | usb_enable_interface(dev, iface); | 1204 | usb_enable_interface(dev, iface); |
1205 | if (device_is_registered(&iface->dev)) | ||
1206 | usb_create_sysfs_intf_files(iface); | ||
1171 | 1207 | ||
1172 | return 0; | 1208 | return 0; |
1173 | } | 1209 | } |
@@ -1217,10 +1253,8 @@ int usb_reset_configuration(struct usb_device *dev) | |||
1217 | USB_REQ_SET_CONFIGURATION, 0, | 1253 | USB_REQ_SET_CONFIGURATION, 0, |
1218 | config->desc.bConfigurationValue, 0, | 1254 | config->desc.bConfigurationValue, 0, |
1219 | NULL, 0, USB_CTRL_SET_TIMEOUT); | 1255 | NULL, 0, USB_CTRL_SET_TIMEOUT); |
1220 | if (retval < 0) { | 1256 | if (retval < 0) |
1221 | usb_set_device_state(dev, USB_STATE_ADDRESS); | ||
1222 | return retval; | 1257 | return retval; |
1223 | } | ||
1224 | 1258 | ||
1225 | dev->toggle[0] = dev->toggle[1] = 0; | 1259 | dev->toggle[0] = dev->toggle[1] = 0; |
1226 | 1260 | ||
@@ -1229,6 +1263,8 @@ int usb_reset_configuration(struct usb_device *dev) | |||
1229 | struct usb_interface *intf = config->interface[i]; | 1263 | struct usb_interface *intf = config->interface[i]; |
1230 | struct usb_host_interface *alt; | 1264 | struct usb_host_interface *alt; |
1231 | 1265 | ||
1266 | if (device_is_registered(&intf->dev)) | ||
1267 | usb_remove_sysfs_intf_files(intf); | ||
1232 | alt = usb_altnum_to_altsetting(intf, 0); | 1268 | alt = usb_altnum_to_altsetting(intf, 0); |
1233 | 1269 | ||
1234 | /* No altsetting 0? We'll assume the first altsetting. | 1270 | /* No altsetting 0? We'll assume the first altsetting. |
@@ -1241,6 +1277,8 @@ int usb_reset_configuration(struct usb_device *dev) | |||
1241 | 1277 | ||
1242 | intf->cur_altsetting = alt; | 1278 | intf->cur_altsetting = alt; |
1243 | usb_enable_interface(dev, intf); | 1279 | usb_enable_interface(dev, intf); |
1280 | if (device_is_registered(&intf->dev)) | ||
1281 | usb_create_sysfs_intf_files(intf); | ||
1244 | } | 1282 | } |
1245 | return 0; | 1283 | return 0; |
1246 | } | 1284 | } |
@@ -1328,7 +1366,7 @@ int usb_set_configuration(struct usb_device *dev, int configuration) | |||
1328 | } | 1366 | } |
1329 | 1367 | ||
1330 | for (; n < nintf; ++n) { | 1368 | for (; n < nintf; ++n) { |
1331 | new_interfaces[n] = kmalloc( | 1369 | new_interfaces[n] = kzalloc( |
1332 | sizeof(struct usb_interface), | 1370 | sizeof(struct usb_interface), |
1333 | GFP_KERNEL); | 1371 | GFP_KERNEL); |
1334 | if (!new_interfaces[n]) { | 1372 | if (!new_interfaces[n]) { |
@@ -1369,7 +1407,6 @@ free_interfaces: | |||
1369 | struct usb_host_interface *alt; | 1407 | struct usb_host_interface *alt; |
1370 | 1408 | ||
1371 | cp->interface[i] = intf = new_interfaces[i]; | 1409 | cp->interface[i] = intf = new_interfaces[i]; |
1372 | memset(intf, 0, sizeof(*intf)); | ||
1373 | intfc = cp->intf_cache[i]; | 1410 | intfc = cp->intf_cache[i]; |
1374 | intf->altsetting = intfc->altsetting; | 1411 | intf->altsetting = intfc->altsetting; |
1375 | intf->num_altsetting = intfc->num_altsetting; | 1412 | intf->num_altsetting = intfc->num_altsetting; |
@@ -1393,6 +1430,7 @@ free_interfaces: | |||
1393 | intf->dev.dma_mask = dev->dev.dma_mask; | 1430 | intf->dev.dma_mask = dev->dev.dma_mask; |
1394 | intf->dev.release = release_interface; | 1431 | intf->dev.release = release_interface; |
1395 | device_initialize (&intf->dev); | 1432 | device_initialize (&intf->dev); |
1433 | mark_quiesced(intf); | ||
1396 | sprintf (&intf->dev.bus_id[0], "%d-%s:%d.%d", | 1434 | sprintf (&intf->dev.bus_id[0], "%d-%s:%d.%d", |
1397 | dev->bus->busnum, dev->devpath, | 1435 | dev->bus->busnum, dev->devpath, |
1398 | configuration, | 1436 | configuration, |
@@ -1400,12 +1438,9 @@ free_interfaces: | |||
1400 | } | 1438 | } |
1401 | kfree(new_interfaces); | 1439 | kfree(new_interfaces); |
1402 | 1440 | ||
1403 | if ((cp->desc.iConfiguration) && | 1441 | if (cp->string == NULL) |
1404 | (cp->string == NULL)) { | 1442 | cp->string = usb_cache_string(dev, |
1405 | cp->string = kmalloc(256, GFP_KERNEL); | 1443 | cp->desc.iConfiguration); |
1406 | if (cp->string) | ||
1407 | usb_string(dev, cp->desc.iConfiguration, cp->string, 256); | ||
1408 | } | ||
1409 | 1444 | ||
1410 | /* Now that all the interfaces are set up, register them | 1445 | /* Now that all the interfaces are set up, register them |
1411 | * to trigger binding of drivers to interfaces. probe() | 1446 | * to trigger binding of drivers to interfaces. probe() |
@@ -1415,13 +1450,11 @@ free_interfaces: | |||
1415 | */ | 1450 | */ |
1416 | for (i = 0; i < nintf; ++i) { | 1451 | for (i = 0; i < nintf; ++i) { |
1417 | struct usb_interface *intf = cp->interface[i]; | 1452 | struct usb_interface *intf = cp->interface[i]; |
1418 | struct usb_interface_descriptor *desc; | ||
1419 | 1453 | ||
1420 | desc = &intf->altsetting [0].desc; | ||
1421 | dev_dbg (&dev->dev, | 1454 | dev_dbg (&dev->dev, |
1422 | "adding %s (config #%d, interface %d)\n", | 1455 | "adding %s (config #%d, interface %d)\n", |
1423 | intf->dev.bus_id, configuration, | 1456 | intf->dev.bus_id, configuration, |
1424 | desc->bInterfaceNumber); | 1457 | intf->cur_altsetting->desc.bInterfaceNumber); |
1425 | ret = device_add (&intf->dev); | 1458 | ret = device_add (&intf->dev); |
1426 | if (ret != 0) { | 1459 | if (ret != 0) { |
1427 | dev_err(&dev->dev, | 1460 | dev_err(&dev->dev, |
@@ -1430,13 +1463,6 @@ free_interfaces: | |||
1430 | ret); | 1463 | ret); |
1431 | continue; | 1464 | continue; |
1432 | } | 1465 | } |
1433 | if ((intf->cur_altsetting->desc.iInterface) && | ||
1434 | (intf->cur_altsetting->string == NULL)) { | ||
1435 | intf->cur_altsetting->string = kmalloc(256, GFP_KERNEL); | ||
1436 | if (intf->cur_altsetting->string) | ||
1437 | usb_string(dev, intf->cur_altsetting->desc.iInterface, | ||
1438 | intf->cur_altsetting->string, 256); | ||
1439 | } | ||
1440 | usb_create_sysfs_intf_files (intf); | 1466 | usb_create_sysfs_intf_files (intf); |
1441 | } | 1467 | } |
1442 | } | 1468 | } |
diff --git a/drivers/usb/core/notify.c b/drivers/usb/core/notify.c new file mode 100644 index 000000000000..fbbebab52fbd --- /dev/null +++ b/drivers/usb/core/notify.c | |||
@@ -0,0 +1,114 @@ | |||
1 | /* | ||
2 | * All the USB notify logic | ||
3 | * | ||
4 | * (C) Copyright 2005 Greg Kroah-Hartman <gregkh@suse.de> | ||
5 | * | ||
6 | * notifier functions originally based on those in kernel/sys.c | ||
7 | * but fixed up to not be so broken. | ||
8 | * | ||
9 | */ | ||
10 | |||
11 | |||
12 | #include <linux/config.h> | ||
13 | #include <linux/kernel.h> | ||
14 | #include <linux/notifier.h> | ||
15 | #include <linux/usb.h> | ||
16 | #include "usb.h" | ||
17 | |||
18 | |||
19 | static struct notifier_block *usb_notifier_list; | ||
20 | static DECLARE_MUTEX(usb_notifier_lock); | ||
21 | |||
22 | static void usb_notifier_chain_register(struct notifier_block **list, | ||
23 | struct notifier_block *n) | ||
24 | { | ||
25 | down(&usb_notifier_lock); | ||
26 | while (*list) { | ||
27 | if (n->priority > (*list)->priority) | ||
28 | break; | ||
29 | list = &((*list)->next); | ||
30 | } | ||
31 | n->next = *list; | ||
32 | *list = n; | ||
33 | up(&usb_notifier_lock); | ||
34 | } | ||
35 | |||
36 | static void usb_notifier_chain_unregister(struct notifier_block **nl, | ||
37 | struct notifier_block *n) | ||
38 | { | ||
39 | down(&usb_notifier_lock); | ||
40 | while ((*nl)!=NULL) { | ||
41 | if ((*nl)==n) { | ||
42 | *nl = n->next; | ||
43 | goto exit; | ||
44 | } | ||
45 | nl=&((*nl)->next); | ||
46 | } | ||
47 | exit: | ||
48 | up(&usb_notifier_lock); | ||
49 | } | ||
50 | |||
51 | static int usb_notifier_call_chain(struct notifier_block **n, | ||
52 | unsigned long val, void *v) | ||
53 | { | ||
54 | int ret=NOTIFY_DONE; | ||
55 | struct notifier_block *nb = *n; | ||
56 | |||
57 | down(&usb_notifier_lock); | ||
58 | while (nb) { | ||
59 | ret = nb->notifier_call(nb,val,v); | ||
60 | if (ret&NOTIFY_STOP_MASK) { | ||
61 | goto exit; | ||
62 | } | ||
63 | nb = nb->next; | ||
64 | } | ||
65 | exit: | ||
66 | up(&usb_notifier_lock); | ||
67 | return ret; | ||
68 | } | ||
69 | |||
70 | /** | ||
71 | * usb_register_notify - register a notifier callback whenever a usb change happens | ||
72 | * @nb: pointer to the notifier block for the callback events. | ||
73 | * | ||
74 | * These changes are either USB devices or busses being added or removed. | ||
75 | */ | ||
76 | void usb_register_notify(struct notifier_block *nb) | ||
77 | { | ||
78 | usb_notifier_chain_register(&usb_notifier_list, nb); | ||
79 | } | ||
80 | EXPORT_SYMBOL_GPL(usb_register_notify); | ||
81 | |||
82 | /** | ||
83 | * usb_unregister_notify - unregister a notifier callback | ||
84 | * @nb: pointer to the notifier block for the callback events. | ||
85 | * | ||
86 | * usb_register_notifier() must have been previously called for this function | ||
87 | * to work properly. | ||
88 | */ | ||
89 | void usb_unregister_notify(struct notifier_block *nb) | ||
90 | { | ||
91 | usb_notifier_chain_unregister(&usb_notifier_list, nb); | ||
92 | } | ||
93 | EXPORT_SYMBOL_GPL(usb_unregister_notify); | ||
94 | |||
95 | |||
96 | void usb_notify_add_device(struct usb_device *udev) | ||
97 | { | ||
98 | usb_notifier_call_chain(&usb_notifier_list, USB_DEVICE_ADD, udev); | ||
99 | } | ||
100 | |||
101 | void usb_notify_remove_device(struct usb_device *udev) | ||
102 | { | ||
103 | usb_notifier_call_chain(&usb_notifier_list, USB_DEVICE_REMOVE, udev); | ||
104 | } | ||
105 | |||
106 | void usb_notify_add_bus(struct usb_bus *ubus) | ||
107 | { | ||
108 | usb_notifier_call_chain(&usb_notifier_list, USB_BUS_ADD, ubus); | ||
109 | } | ||
110 | |||
111 | void usb_notify_remove_bus(struct usb_bus *ubus) | ||
112 | { | ||
113 | usb_notifier_call_chain(&usb_notifier_list, USB_BUS_REMOVE, ubus); | ||
114 | } | ||
diff --git a/drivers/usb/core/sysfs.c b/drivers/usb/core/sysfs.c index 00297f113849..71d881327e88 100644 --- a/drivers/usb/core/sysfs.c +++ b/drivers/usb/core/sysfs.c | |||
@@ -12,19 +12,210 @@ | |||
12 | 12 | ||
13 | #include <linux/config.h> | 13 | #include <linux/config.h> |
14 | #include <linux/kernel.h> | 14 | #include <linux/kernel.h> |
15 | |||
16 | #ifdef CONFIG_USB_DEBUG | ||
17 | #define DEBUG | ||
18 | #else | ||
19 | #undef DEBUG | ||
20 | #endif | ||
21 | #include <linux/usb.h> | 15 | #include <linux/usb.h> |
22 | |||
23 | #include "usb.h" | 16 | #include "usb.h" |
24 | 17 | ||
18 | /* endpoint stuff */ | ||
19 | struct ep_object { | ||
20 | struct usb_endpoint_descriptor *desc; | ||
21 | struct usb_device *udev; | ||
22 | struct kobject kobj; | ||
23 | }; | ||
24 | #define to_ep_object(_kobj) \ | ||
25 | container_of(_kobj, struct ep_object, kobj) | ||
26 | |||
27 | struct ep_attribute { | ||
28 | struct attribute attr; | ||
29 | ssize_t (*show)(struct usb_device *, | ||
30 | struct usb_endpoint_descriptor *, char *); | ||
31 | }; | ||
32 | #define to_ep_attribute(_attr) \ | ||
33 | container_of(_attr, struct ep_attribute, attr) | ||
34 | |||
35 | #define EP_ATTR(_name) \ | ||
36 | struct ep_attribute ep_##_name = { \ | ||
37 | .attr = {.name = #_name, .owner = THIS_MODULE, \ | ||
38 | .mode = S_IRUGO}, \ | ||
39 | .show = show_ep_##_name} | ||
40 | |||
41 | #define usb_ep_attr(field, format_string) \ | ||
42 | static ssize_t show_ep_##field(struct usb_device *udev, \ | ||
43 | struct usb_endpoint_descriptor *desc, \ | ||
44 | char *buf) \ | ||
45 | { \ | ||
46 | return sprintf(buf, format_string, desc->field); \ | ||
47 | } \ | ||
48 | static EP_ATTR(field); | ||
49 | |||
50 | usb_ep_attr(bLength, "%02x\n") | ||
51 | usb_ep_attr(bEndpointAddress, "%02x\n") | ||
52 | usb_ep_attr(bmAttributes, "%02x\n") | ||
53 | usb_ep_attr(bInterval, "%02x\n") | ||
54 | |||
55 | static ssize_t show_ep_wMaxPacketSize(struct usb_device *udev, | ||
56 | struct usb_endpoint_descriptor *desc, char *buf) | ||
57 | { | ||
58 | return sprintf(buf, "%04x\n", | ||
59 | le16_to_cpu(desc->wMaxPacketSize) & 0x07ff); | ||
60 | } | ||
61 | static EP_ATTR(wMaxPacketSize); | ||
62 | |||
63 | static ssize_t show_ep_type(struct usb_device *udev, | ||
64 | struct usb_endpoint_descriptor *desc, char *buf) | ||
65 | { | ||
66 | char *type = "unknown"; | ||
67 | |||
68 | switch (desc->bmAttributes & USB_ENDPOINT_XFERTYPE_MASK) { | ||
69 | case USB_ENDPOINT_XFER_CONTROL: | ||
70 | type = "Control"; | ||
71 | break; | ||
72 | case USB_ENDPOINT_XFER_ISOC: | ||
73 | type = "Isoc"; | ||
74 | break; | ||
75 | case USB_ENDPOINT_XFER_BULK: | ||
76 | type = "Bulk"; | ||
77 | break; | ||
78 | case USB_ENDPOINT_XFER_INT: | ||
79 | type = "Interrupt"; | ||
80 | break; | ||
81 | } | ||
82 | return sprintf(buf, "%s\n", type); | ||
83 | } | ||
84 | static EP_ATTR(type); | ||
85 | |||
86 | static ssize_t show_ep_interval(struct usb_device *udev, | ||
87 | struct usb_endpoint_descriptor *desc, char *buf) | ||
88 | { | ||
89 | char unit; | ||
90 | unsigned interval = 0; | ||
91 | unsigned in; | ||
92 | |||
93 | in = (desc->bEndpointAddress & USB_DIR_IN); | ||
94 | |||
95 | switch (desc->bmAttributes & USB_ENDPOINT_XFERTYPE_MASK) { | ||
96 | case USB_ENDPOINT_XFER_CONTROL: | ||
97 | if (udev->speed == USB_SPEED_HIGH) /* uframes per NAK */ | ||
98 | interval = desc->bInterval; | ||
99 | break; | ||
100 | case USB_ENDPOINT_XFER_ISOC: | ||
101 | interval = 1 << (desc->bInterval - 1); | ||
102 | break; | ||
103 | case USB_ENDPOINT_XFER_BULK: | ||
104 | if (udev->speed == USB_SPEED_HIGH && !in) /* uframes per NAK */ | ||
105 | interval = desc->bInterval; | ||
106 | break; | ||
107 | case USB_ENDPOINT_XFER_INT: | ||
108 | if (udev->speed == USB_SPEED_HIGH) | ||
109 | interval = 1 << (desc->bInterval - 1); | ||
110 | else | ||
111 | interval = desc->bInterval; | ||
112 | break; | ||
113 | } | ||
114 | interval *= (udev->speed == USB_SPEED_HIGH) ? 125 : 1000; | ||
115 | if (interval % 1000) | ||
116 | unit = 'u'; | ||
117 | else { | ||
118 | unit = 'm'; | ||
119 | interval /= 1000; | ||
120 | } | ||
121 | |||
122 | return sprintf(buf, "%d%cs\n", interval, unit); | ||
123 | } | ||
124 | static EP_ATTR(interval); | ||
125 | |||
126 | static ssize_t show_ep_direction(struct usb_device *udev, | ||
127 | struct usb_endpoint_descriptor *desc, char *buf) | ||
128 | { | ||
129 | char *direction; | ||
130 | |||
131 | if ((desc->bmAttributes & USB_ENDPOINT_XFERTYPE_MASK) == | ||
132 | USB_ENDPOINT_XFER_CONTROL) | ||
133 | direction = "both"; | ||
134 | else if (desc->bEndpointAddress & USB_DIR_IN) | ||
135 | direction = "in"; | ||
136 | else | ||
137 | direction = "out"; | ||
138 | return sprintf(buf, "%s\n", direction); | ||
139 | } | ||
140 | static EP_ATTR(direction); | ||
141 | |||
142 | static struct attribute *ep_attrs[] = { | ||
143 | &ep_bLength.attr, | ||
144 | &ep_bEndpointAddress.attr, | ||
145 | &ep_bmAttributes.attr, | ||
146 | &ep_bInterval.attr, | ||
147 | &ep_wMaxPacketSize.attr, | ||
148 | &ep_type.attr, | ||
149 | &ep_interval.attr, | ||
150 | &ep_direction.attr, | ||
151 | NULL, | ||
152 | }; | ||
153 | |||
154 | static void ep_object_release(struct kobject *kobj) | ||
155 | { | ||
156 | kfree(to_ep_object(kobj)); | ||
157 | } | ||
158 | |||
159 | static ssize_t ep_object_show(struct kobject *kobj, struct attribute *attr, | ||
160 | char *buf) | ||
161 | { | ||
162 | struct ep_object *ep_obj = to_ep_object(kobj); | ||
163 | struct ep_attribute *ep_attr = to_ep_attribute(attr); | ||
164 | |||
165 | return (ep_attr->show)(ep_obj->udev, ep_obj->desc, buf); | ||
166 | } | ||
167 | |||
168 | static struct sysfs_ops ep_object_sysfs_ops = { | ||
169 | .show = ep_object_show, | ||
170 | }; | ||
171 | |||
172 | static struct kobj_type ep_object_ktype = { | ||
173 | .release = ep_object_release, | ||
174 | .sysfs_ops = &ep_object_sysfs_ops, | ||
175 | .default_attrs = ep_attrs, | ||
176 | }; | ||
177 | |||
178 | static void usb_create_ep_files(struct kobject *parent, | ||
179 | struct usb_host_endpoint *endpoint, | ||
180 | struct usb_device *udev) | ||
181 | { | ||
182 | struct ep_object *ep_obj; | ||
183 | struct kobject *kobj; | ||
184 | |||
185 | ep_obj = kzalloc(sizeof(struct ep_object), GFP_KERNEL); | ||
186 | if (!ep_obj) | ||
187 | return; | ||
188 | |||
189 | ep_obj->desc = &endpoint->desc; | ||
190 | ep_obj->udev = udev; | ||
191 | |||
192 | kobj = &ep_obj->kobj; | ||
193 | kobject_set_name(kobj, "ep_%02x", endpoint->desc.bEndpointAddress); | ||
194 | kobj->parent = parent; | ||
195 | kobj->ktype = &ep_object_ktype; | ||
196 | |||
197 | /* Don't use kobject_register, because it generates a hotplug event */ | ||
198 | kobject_init(kobj); | ||
199 | if (kobject_add(kobj) == 0) | ||
200 | endpoint->kobj = kobj; | ||
201 | else | ||
202 | kobject_put(kobj); | ||
203 | } | ||
204 | |||
205 | static void usb_remove_ep_files(struct usb_host_endpoint *endpoint) | ||
206 | { | ||
207 | |||
208 | if (endpoint->kobj) { | ||
209 | kobject_del(endpoint->kobj); | ||
210 | kobject_put(endpoint->kobj); | ||
211 | endpoint->kobj = NULL; | ||
212 | } | ||
213 | } | ||
214 | |||
25 | /* Active configuration fields */ | 215 | /* Active configuration fields */ |
26 | #define usb_actconfig_show(field, multiplier, format_string) \ | 216 | #define usb_actconfig_show(field, multiplier, format_string) \ |
27 | static ssize_t show_##field (struct device *dev, struct device_attribute *attr, char *buf) \ | 217 | static ssize_t show_##field (struct device *dev, \ |
218 | struct device_attribute *attr, char *buf) \ | ||
28 | { \ | 219 | { \ |
29 | struct usb_device *udev; \ | 220 | struct usb_device *udev; \ |
30 | struct usb_host_config *actconfig; \ | 221 | struct usb_host_config *actconfig; \ |
@@ -46,22 +237,17 @@ usb_actconfig_attr (bNumInterfaces, 1, "%2d\n") | |||
46 | usb_actconfig_attr (bmAttributes, 1, "%2x\n") | 237 | usb_actconfig_attr (bmAttributes, 1, "%2x\n") |
47 | usb_actconfig_attr (bMaxPower, 2, "%3dmA\n") | 238 | usb_actconfig_attr (bMaxPower, 2, "%3dmA\n") |
48 | 239 | ||
49 | static ssize_t show_configuration_string(struct device *dev, struct device_attribute *attr, char *buf) | 240 | static ssize_t show_configuration_string(struct device *dev, |
241 | struct device_attribute *attr, char *buf) | ||
50 | { | 242 | { |
51 | struct usb_device *udev; | 243 | struct usb_device *udev; |
52 | struct usb_host_config *actconfig; | 244 | struct usb_host_config *actconfig; |
53 | int len; | ||
54 | 245 | ||
55 | udev = to_usb_device (dev); | 246 | udev = to_usb_device (dev); |
56 | actconfig = udev->actconfig; | 247 | actconfig = udev->actconfig; |
57 | if ((!actconfig) || (!actconfig->string)) | 248 | if ((!actconfig) || (!actconfig->string)) |
58 | return 0; | 249 | return 0; |
59 | len = sprintf(buf, actconfig->string, PAGE_SIZE); | 250 | return sprintf(buf, "%s\n", actconfig->string); |
60 | if (len < 0) | ||
61 | return 0; | ||
62 | buf[len] = '\n'; | ||
63 | buf[len+1] = 0; | ||
64 | return len+1; | ||
65 | } | 251 | } |
66 | static DEVICE_ATTR(configuration, S_IRUGO, show_configuration_string, NULL); | 252 | static DEVICE_ATTR(configuration, S_IRUGO, show_configuration_string, NULL); |
67 | 253 | ||
@@ -69,7 +255,8 @@ static DEVICE_ATTR(configuration, S_IRUGO, show_configuration_string, NULL); | |||
69 | usb_actconfig_show(bConfigurationValue, 1, "%u\n"); | 255 | usb_actconfig_show(bConfigurationValue, 1, "%u\n"); |
70 | 256 | ||
71 | static ssize_t | 257 | static ssize_t |
72 | set_bConfigurationValue (struct device *dev, struct device_attribute *attr, const char *buf, size_t count) | 258 | set_bConfigurationValue (struct device *dev, struct device_attribute *attr, |
259 | const char *buf, size_t count) | ||
73 | { | 260 | { |
74 | struct usb_device *udev = udev = to_usb_device (dev); | 261 | struct usb_device *udev = udev = to_usb_device (dev); |
75 | int config, value; | 262 | int config, value; |
@@ -87,18 +274,13 @@ static DEVICE_ATTR(bConfigurationValue, S_IRUGO | S_IWUSR, | |||
87 | 274 | ||
88 | /* String fields */ | 275 | /* String fields */ |
89 | #define usb_string_attr(name) \ | 276 | #define usb_string_attr(name) \ |
90 | static ssize_t show_##name(struct device *dev, struct device_attribute *attr, char *buf) \ | 277 | static ssize_t show_##name(struct device *dev, \ |
278 | struct device_attribute *attr, char *buf) \ | ||
91 | { \ | 279 | { \ |
92 | struct usb_device *udev; \ | 280 | struct usb_device *udev; \ |
93 | int len; \ | ||
94 | \ | 281 | \ |
95 | udev = to_usb_device (dev); \ | 282 | udev = to_usb_device (dev); \ |
96 | len = snprintf(buf, 256, "%s", udev->name); \ | 283 | return sprintf(buf, "%s\n", udev->name); \ |
97 | if (len < 0) \ | ||
98 | return 0; \ | ||
99 | buf[len] = '\n'; \ | ||
100 | buf[len+1] = 0; \ | ||
101 | return len+1; \ | ||
102 | } \ | 284 | } \ |
103 | static DEVICE_ATTR(name, S_IRUGO, show_##name, NULL); | 285 | static DEVICE_ATTR(name, S_IRUGO, show_##name, NULL); |
104 | 286 | ||
@@ -167,7 +349,8 @@ static DEVICE_ATTR(maxchild, S_IRUGO, show_maxchild, NULL); | |||
167 | /* Descriptor fields */ | 349 | /* Descriptor fields */ |
168 | #define usb_descriptor_attr_le16(field, format_string) \ | 350 | #define usb_descriptor_attr_le16(field, format_string) \ |
169 | static ssize_t \ | 351 | static ssize_t \ |
170 | show_##field (struct device *dev, struct device_attribute *attr, char *buf) \ | 352 | show_##field (struct device *dev, struct device_attribute *attr, \ |
353 | char *buf) \ | ||
171 | { \ | 354 | { \ |
172 | struct usb_device *udev; \ | 355 | struct usb_device *udev; \ |
173 | \ | 356 | \ |
@@ -183,7 +366,8 @@ usb_descriptor_attr_le16(bcdDevice, "%04x\n") | |||
183 | 366 | ||
184 | #define usb_descriptor_attr(field, format_string) \ | 367 | #define usb_descriptor_attr(field, format_string) \ |
185 | static ssize_t \ | 368 | static ssize_t \ |
186 | show_##field (struct device *dev, struct device_attribute *attr, char *buf) \ | 369 | show_##field (struct device *dev, struct device_attribute *attr, \ |
370 | char *buf) \ | ||
187 | { \ | 371 | { \ |
188 | struct usb_device *udev; \ | 372 | struct usb_device *udev; \ |
189 | \ | 373 | \ |
@@ -236,19 +420,21 @@ void usb_create_sysfs_dev_files (struct usb_device *udev) | |||
236 | if (udev->serial) | 420 | if (udev->serial) |
237 | device_create_file (dev, &dev_attr_serial); | 421 | device_create_file (dev, &dev_attr_serial); |
238 | device_create_file (dev, &dev_attr_configuration); | 422 | device_create_file (dev, &dev_attr_configuration); |
423 | usb_create_ep_files(&dev->kobj, &udev->ep0, udev); | ||
239 | } | 424 | } |
240 | 425 | ||
241 | void usb_remove_sysfs_dev_files (struct usb_device *udev) | 426 | void usb_remove_sysfs_dev_files (struct usb_device *udev) |
242 | { | 427 | { |
243 | struct device *dev = &udev->dev; | 428 | struct device *dev = &udev->dev; |
244 | 429 | ||
430 | usb_remove_ep_files(&udev->ep0); | ||
245 | sysfs_remove_group(&dev->kobj, &dev_attr_grp); | 431 | sysfs_remove_group(&dev->kobj, &dev_attr_grp); |
246 | 432 | ||
247 | if (udev->descriptor.iManufacturer) | 433 | if (udev->manufacturer) |
248 | device_remove_file(dev, &dev_attr_manufacturer); | 434 | device_remove_file(dev, &dev_attr_manufacturer); |
249 | if (udev->descriptor.iProduct) | 435 | if (udev->product) |
250 | device_remove_file(dev, &dev_attr_product); | 436 | device_remove_file(dev, &dev_attr_product); |
251 | if (udev->descriptor.iSerialNumber) | 437 | if (udev->serial) |
252 | device_remove_file(dev, &dev_attr_serial); | 438 | device_remove_file(dev, &dev_attr_serial); |
253 | device_remove_file (dev, &dev_attr_configuration); | 439 | device_remove_file (dev, &dev_attr_configuration); |
254 | } | 440 | } |
@@ -256,11 +442,13 @@ void usb_remove_sysfs_dev_files (struct usb_device *udev) | |||
256 | /* Interface fields */ | 442 | /* Interface fields */ |
257 | #define usb_intf_attr(field, format_string) \ | 443 | #define usb_intf_attr(field, format_string) \ |
258 | static ssize_t \ | 444 | static ssize_t \ |
259 | show_##field (struct device *dev, struct device_attribute *attr, char *buf) \ | 445 | show_##field (struct device *dev, struct device_attribute *attr, \ |
446 | char *buf) \ | ||
260 | { \ | 447 | { \ |
261 | struct usb_interface *intf = to_usb_interface (dev); \ | 448 | struct usb_interface *intf = to_usb_interface (dev); \ |
262 | \ | 449 | \ |
263 | return sprintf (buf, format_string, intf->cur_altsetting->desc.field); \ | 450 | return sprintf (buf, format_string, \ |
451 | intf->cur_altsetting->desc.field); \ | ||
264 | } \ | 452 | } \ |
265 | static DEVICE_ATTR(field, S_IRUGO, show_##field, NULL); | 453 | static DEVICE_ATTR(field, S_IRUGO, show_##field, NULL); |
266 | 454 | ||
@@ -271,7 +459,8 @@ usb_intf_attr (bInterfaceClass, "%02x\n") | |||
271 | usb_intf_attr (bInterfaceSubClass, "%02x\n") | 459 | usb_intf_attr (bInterfaceSubClass, "%02x\n") |
272 | usb_intf_attr (bInterfaceProtocol, "%02x\n") | 460 | usb_intf_attr (bInterfaceProtocol, "%02x\n") |
273 | 461 | ||
274 | static ssize_t show_interface_string(struct device *dev, struct device_attribute *attr, char *buf) | 462 | static ssize_t show_interface_string(struct device *dev, |
463 | struct device_attribute *attr, char *buf) | ||
275 | { | 464 | { |
276 | struct usb_interface *intf; | 465 | struct usb_interface *intf; |
277 | struct usb_device *udev; | 466 | struct usb_device *udev; |
@@ -288,34 +477,28 @@ static ssize_t show_interface_string(struct device *dev, struct device_attribute | |||
288 | } | 477 | } |
289 | static DEVICE_ATTR(interface, S_IRUGO, show_interface_string, NULL); | 478 | static DEVICE_ATTR(interface, S_IRUGO, show_interface_string, NULL); |
290 | 479 | ||
291 | static ssize_t show_modalias(struct device *dev, struct device_attribute *attr, char *buf) | 480 | static ssize_t show_modalias(struct device *dev, |
481 | struct device_attribute *attr, char *buf) | ||
292 | { | 482 | { |
293 | struct usb_interface *intf; | 483 | struct usb_interface *intf; |
294 | struct usb_device *udev; | 484 | struct usb_device *udev; |
295 | int len; | 485 | struct usb_host_interface *alt; |
296 | 486 | ||
297 | intf = to_usb_interface(dev); | 487 | intf = to_usb_interface(dev); |
298 | udev = interface_to_usbdev(intf); | 488 | udev = interface_to_usbdev(intf); |
299 | 489 | alt = intf->cur_altsetting; | |
300 | len = sprintf(buf, "usb:v%04Xp%04Xd%04Xdc%02Xdsc%02Xdp%02Xic", | 490 | |
301 | le16_to_cpu(udev->descriptor.idVendor), | 491 | return sprintf(buf, "usb:v%04Xp%04Xd%04Xdc%02Xdsc%02Xdp%02X" |
302 | le16_to_cpu(udev->descriptor.idProduct), | 492 | "ic%02Xisc%02Xip%02X\n", |
303 | le16_to_cpu(udev->descriptor.bcdDevice), | 493 | le16_to_cpu(udev->descriptor.idVendor), |
304 | udev->descriptor.bDeviceClass, | 494 | le16_to_cpu(udev->descriptor.idProduct), |
305 | udev->descriptor.bDeviceSubClass, | 495 | le16_to_cpu(udev->descriptor.bcdDevice), |
306 | udev->descriptor.bDeviceProtocol); | 496 | udev->descriptor.bDeviceClass, |
307 | buf += len; | 497 | udev->descriptor.bDeviceSubClass, |
308 | 498 | udev->descriptor.bDeviceProtocol, | |
309 | if (udev->descriptor.bDeviceClass == 0) { | 499 | alt->desc.bInterfaceClass, |
310 | struct usb_host_interface *alt = intf->cur_altsetting; | 500 | alt->desc.bInterfaceSubClass, |
311 | 501 | alt->desc.bInterfaceProtocol); | |
312 | return len + sprintf(buf, "%02Xisc%02Xip%02X\n", | ||
313 | alt->desc.bInterfaceClass, | ||
314 | alt->desc.bInterfaceSubClass, | ||
315 | alt->desc.bInterfaceProtocol); | ||
316 | } else { | ||
317 | return len + sprintf(buf, "*isc*ip*\n"); | ||
318 | } | ||
319 | } | 502 | } |
320 | static DEVICE_ATTR(modalias, S_IRUGO, show_modalias, NULL); | 503 | static DEVICE_ATTR(modalias, S_IRUGO, show_modalias, NULL); |
321 | 504 | ||
@@ -333,20 +516,47 @@ static struct attribute_group intf_attr_grp = { | |||
333 | .attrs = intf_attrs, | 516 | .attrs = intf_attrs, |
334 | }; | 517 | }; |
335 | 518 | ||
519 | static inline void usb_create_intf_ep_files(struct usb_interface *intf, | ||
520 | struct usb_device *udev) | ||
521 | { | ||
522 | struct usb_host_interface *iface_desc; | ||
523 | int i; | ||
524 | |||
525 | iface_desc = intf->cur_altsetting; | ||
526 | for (i = 0; i < iface_desc->desc.bNumEndpoints; ++i) | ||
527 | usb_create_ep_files(&intf->dev.kobj, &iface_desc->endpoint[i], | ||
528 | udev); | ||
529 | } | ||
530 | |||
531 | static inline void usb_remove_intf_ep_files(struct usb_interface *intf) | ||
532 | { | ||
533 | struct usb_host_interface *iface_desc; | ||
534 | int i; | ||
535 | |||
536 | iface_desc = intf->cur_altsetting; | ||
537 | for (i = 0; i < iface_desc->desc.bNumEndpoints; ++i) | ||
538 | usb_remove_ep_files(&iface_desc->endpoint[i]); | ||
539 | } | ||
540 | |||
336 | void usb_create_sysfs_intf_files (struct usb_interface *intf) | 541 | void usb_create_sysfs_intf_files (struct usb_interface *intf) |
337 | { | 542 | { |
543 | struct usb_device *udev = interface_to_usbdev(intf); | ||
544 | struct usb_host_interface *alt = intf->cur_altsetting; | ||
545 | |||
338 | sysfs_create_group(&intf->dev.kobj, &intf_attr_grp); | 546 | sysfs_create_group(&intf->dev.kobj, &intf_attr_grp); |
339 | 547 | ||
340 | if (intf->cur_altsetting->string) | 548 | if (alt->string == NULL) |
549 | alt->string = usb_cache_string(udev, alt->desc.iInterface); | ||
550 | if (alt->string) | ||
341 | device_create_file(&intf->dev, &dev_attr_interface); | 551 | device_create_file(&intf->dev, &dev_attr_interface); |
342 | 552 | usb_create_intf_ep_files(intf, udev); | |
343 | } | 553 | } |
344 | 554 | ||
345 | void usb_remove_sysfs_intf_files (struct usb_interface *intf) | 555 | void usb_remove_sysfs_intf_files (struct usb_interface *intf) |
346 | { | 556 | { |
557 | usb_remove_intf_ep_files(intf); | ||
347 | sysfs_remove_group(&intf->dev.kobj, &intf_attr_grp); | 558 | sysfs_remove_group(&intf->dev.kobj, &intf_attr_grp); |
348 | 559 | ||
349 | if (intf->cur_altsetting->string) | 560 | if (intf->cur_altsetting->string) |
350 | device_remove_file(&intf->dev, &dev_attr_interface); | 561 | device_remove_file(&intf->dev, &dev_attr_interface); |
351 | |||
352 | } | 562 | } |
diff --git a/drivers/usb/core/urb.c b/drivers/usb/core/urb.c index c846fefb7386..081796726b95 100644 --- a/drivers/usb/core/urb.c +++ b/drivers/usb/core/urb.c | |||
@@ -4,12 +4,6 @@ | |||
4 | #include <linux/bitops.h> | 4 | #include <linux/bitops.h> |
5 | #include <linux/slab.h> | 5 | #include <linux/slab.h> |
6 | #include <linux/init.h> | 6 | #include <linux/init.h> |
7 | |||
8 | #ifdef CONFIG_USB_DEBUG | ||
9 | #define DEBUG | ||
10 | #else | ||
11 | #undef DEBUG | ||
12 | #endif | ||
13 | #include <linux/usb.h> | 7 | #include <linux/usb.h> |
14 | #include "hcd.h" | 8 | #include "hcd.h" |
15 | 9 | ||
@@ -60,7 +54,7 @@ void usb_init_urb(struct urb *urb) | |||
60 | * | 54 | * |
61 | * The driver must call usb_free_urb() when it is finished with the urb. | 55 | * The driver must call usb_free_urb() when it is finished with the urb. |
62 | */ | 56 | */ |
63 | struct urb *usb_alloc_urb(int iso_packets, unsigned mem_flags) | 57 | struct urb *usb_alloc_urb(int iso_packets, gfp_t mem_flags) |
64 | { | 58 | { |
65 | struct urb *urb; | 59 | struct urb *urb; |
66 | 60 | ||
@@ -224,7 +218,7 @@ struct urb * usb_get_urb(struct urb *urb) | |||
224 | * GFP_NOIO, unless b) or c) apply | 218 | * GFP_NOIO, unless b) or c) apply |
225 | * | 219 | * |
226 | */ | 220 | */ |
227 | int usb_submit_urb(struct urb *urb, unsigned mem_flags) | 221 | int usb_submit_urb(struct urb *urb, gfp_t mem_flags) |
228 | { | 222 | { |
229 | int pipe, temp, max; | 223 | int pipe, temp, max; |
230 | struct usb_device *dev; | 224 | struct usb_device *dev; |
@@ -237,7 +231,8 @@ int usb_submit_urb(struct urb *urb, unsigned mem_flags) | |||
237 | (dev->state < USB_STATE_DEFAULT) || | 231 | (dev->state < USB_STATE_DEFAULT) || |
238 | (!dev->bus) || (dev->devnum <= 0)) | 232 | (!dev->bus) || (dev->devnum <= 0)) |
239 | return -ENODEV; | 233 | return -ENODEV; |
240 | if (dev->state == USB_STATE_SUSPENDED) | 234 | if (dev->bus->controller->power.power_state.event != PM_EVENT_ON |
235 | || dev->state == USB_STATE_SUSPENDED) | ||
241 | return -EHOSTUNREACH; | 236 | return -EHOSTUNREACH; |
242 | if (!(op = dev->bus->op) || !op->submit_urb) | 237 | if (!(op = dev->bus->op) || !op->submit_urb) |
243 | return -ENODEV; | 238 | return -ENODEV; |
diff --git a/drivers/usb/core/usb.c b/drivers/usb/core/usb.c index 087af73a59dd..e197ce9353de 100644 --- a/drivers/usb/core/usb.c +++ b/drivers/usb/core/usb.c | |||
@@ -22,13 +22,6 @@ | |||
22 | */ | 22 | */ |
23 | 23 | ||
24 | #include <linux/config.h> | 24 | #include <linux/config.h> |
25 | |||
26 | #ifdef CONFIG_USB_DEBUG | ||
27 | #define DEBUG | ||
28 | #else | ||
29 | #undef DEBUG | ||
30 | #endif | ||
31 | |||
32 | #include <linux/module.h> | 25 | #include <linux/module.h> |
33 | #include <linux/string.h> | 26 | #include <linux/string.h> |
34 | #include <linux/bitops.h> | 27 | #include <linux/bitops.h> |
@@ -107,10 +100,19 @@ static int usb_probe_interface(struct device *dev) | |||
107 | id = usb_match_id (intf, driver->id_table); | 100 | id = usb_match_id (intf, driver->id_table); |
108 | if (id) { | 101 | if (id) { |
109 | dev_dbg (dev, "%s - got id\n", __FUNCTION__); | 102 | dev_dbg (dev, "%s - got id\n", __FUNCTION__); |
103 | |||
104 | /* Interface "power state" doesn't correspond to any hardware | ||
105 | * state whatsoever. We use it to record when it's bound to | ||
106 | * a driver that may start I/0: it's not frozen/quiesced. | ||
107 | */ | ||
108 | mark_active(intf); | ||
110 | intf->condition = USB_INTERFACE_BINDING; | 109 | intf->condition = USB_INTERFACE_BINDING; |
111 | error = driver->probe (intf, id); | 110 | error = driver->probe (intf, id); |
112 | intf->condition = error ? USB_INTERFACE_UNBOUND : | 111 | if (error) { |
113 | USB_INTERFACE_BOUND; | 112 | mark_quiesced(intf); |
113 | intf->condition = USB_INTERFACE_UNBOUND; | ||
114 | } else | ||
115 | intf->condition = USB_INTERFACE_BOUND; | ||
114 | } | 116 | } |
115 | 117 | ||
116 | return error; | 118 | return error; |
@@ -136,6 +138,7 @@ static int usb_unbind_interface(struct device *dev) | |||
136 | 0); | 138 | 0); |
137 | usb_set_intfdata(intf, NULL); | 139 | usb_set_intfdata(intf, NULL); |
138 | intf->condition = USB_INTERFACE_UNBOUND; | 140 | intf->condition = USB_INTERFACE_UNBOUND; |
141 | mark_quiesced(intf); | ||
139 | 142 | ||
140 | return 0; | 143 | return 0; |
141 | } | 144 | } |
@@ -299,11 +302,12 @@ int usb_driver_claim_interface(struct usb_driver *driver, | |||
299 | dev->driver = &driver->driver; | 302 | dev->driver = &driver->driver; |
300 | usb_set_intfdata(iface, priv); | 303 | usb_set_intfdata(iface, priv); |
301 | iface->condition = USB_INTERFACE_BOUND; | 304 | iface->condition = USB_INTERFACE_BOUND; |
305 | mark_active(iface); | ||
302 | 306 | ||
303 | /* if interface was already added, bind now; else let | 307 | /* if interface was already added, bind now; else let |
304 | * the future device_add() bind it, bypassing probe() | 308 | * the future device_add() bind it, bypassing probe() |
305 | */ | 309 | */ |
306 | if (klist_node_attached(&dev->knode_bus)) | 310 | if (device_is_registered(dev)) |
307 | device_bind_driver(dev); | 311 | device_bind_driver(dev); |
308 | 312 | ||
309 | return 0; | 313 | return 0; |
@@ -336,8 +340,8 @@ void usb_driver_release_interface(struct usb_driver *driver, | |||
336 | if (iface->condition != USB_INTERFACE_BOUND) | 340 | if (iface->condition != USB_INTERFACE_BOUND) |
337 | return; | 341 | return; |
338 | 342 | ||
339 | /* release only after device_add() */ | 343 | /* don't release if the interface hasn't been added yet */ |
340 | if (klist_node_attached(&dev->knode_bus)) { | 344 | if (device_is_registered(dev)) { |
341 | iface->condition = USB_INTERFACE_UNBINDING; | 345 | iface->condition = USB_INTERFACE_UNBINDING; |
342 | device_release_driver(dev); | 346 | device_release_driver(dev); |
343 | } | 347 | } |
@@ -345,6 +349,7 @@ void usb_driver_release_interface(struct usb_driver *driver, | |||
345 | dev->driver = NULL; | 349 | dev->driver = NULL; |
346 | usb_set_intfdata(iface, NULL); | 350 | usb_set_intfdata(iface, NULL); |
347 | iface->condition = USB_INTERFACE_UNBOUND; | 351 | iface->condition = USB_INTERFACE_UNBOUND; |
352 | mark_quiesced(iface); | ||
348 | } | 353 | } |
349 | 354 | ||
350 | /** | 355 | /** |
@@ -557,6 +562,7 @@ static int usb_hotplug (struct device *dev, char **envp, int num_envp, | |||
557 | { | 562 | { |
558 | struct usb_interface *intf; | 563 | struct usb_interface *intf; |
559 | struct usb_device *usb_dev; | 564 | struct usb_device *usb_dev; |
565 | struct usb_host_interface *alt; | ||
560 | int i = 0; | 566 | int i = 0; |
561 | int length = 0; | 567 | int length = 0; |
562 | 568 | ||
@@ -573,7 +579,8 @@ static int usb_hotplug (struct device *dev, char **envp, int num_envp, | |||
573 | 579 | ||
574 | intf = to_usb_interface(dev); | 580 | intf = to_usb_interface(dev); |
575 | usb_dev = interface_to_usbdev (intf); | 581 | usb_dev = interface_to_usbdev (intf); |
576 | 582 | alt = intf->cur_altsetting; | |
583 | |||
577 | if (usb_dev->devnum < 0) { | 584 | if (usb_dev->devnum < 0) { |
578 | pr_debug ("usb %s: already deleted?\n", dev->bus_id); | 585 | pr_debug ("usb %s: already deleted?\n", dev->bus_id); |
579 | return -ENODEV; | 586 | return -ENODEV; |
@@ -615,46 +622,27 @@ static int usb_hotplug (struct device *dev, char **envp, int num_envp, | |||
615 | usb_dev->descriptor.bDeviceProtocol)) | 622 | usb_dev->descriptor.bDeviceProtocol)) |
616 | return -ENOMEM; | 623 | return -ENOMEM; |
617 | 624 | ||
618 | if (usb_dev->descriptor.bDeviceClass == 0) { | 625 | if (add_hotplug_env_var(envp, num_envp, &i, |
619 | struct usb_host_interface *alt = intf->cur_altsetting; | 626 | buffer, buffer_size, &length, |
627 | "INTERFACE=%d/%d/%d", | ||
628 | alt->desc.bInterfaceClass, | ||
629 | alt->desc.bInterfaceSubClass, | ||
630 | alt->desc.bInterfaceProtocol)) | ||
631 | return -ENOMEM; | ||
620 | 632 | ||
621 | /* 2.4 only exposed interface zero. in 2.5, hotplug | 633 | if (add_hotplug_env_var(envp, num_envp, &i, |
622 | * agents are called for all interfaces, and can use | 634 | buffer, buffer_size, &length, |
623 | * $DEVPATH/bInterfaceNumber if necessary. | 635 | "MODALIAS=usb:v%04Xp%04Xd%04Xdc%02Xdsc%02Xdp%02Xic%02Xisc%02Xip%02X", |
624 | */ | 636 | le16_to_cpu(usb_dev->descriptor.idVendor), |
625 | if (add_hotplug_env_var(envp, num_envp, &i, | 637 | le16_to_cpu(usb_dev->descriptor.idProduct), |
626 | buffer, buffer_size, &length, | 638 | le16_to_cpu(usb_dev->descriptor.bcdDevice), |
627 | "INTERFACE=%d/%d/%d", | 639 | usb_dev->descriptor.bDeviceClass, |
628 | alt->desc.bInterfaceClass, | 640 | usb_dev->descriptor.bDeviceSubClass, |
629 | alt->desc.bInterfaceSubClass, | 641 | usb_dev->descriptor.bDeviceProtocol, |
630 | alt->desc.bInterfaceProtocol)) | 642 | alt->desc.bInterfaceClass, |
631 | return -ENOMEM; | 643 | alt->desc.bInterfaceSubClass, |
632 | 644 | alt->desc.bInterfaceProtocol)) | |
633 | if (add_hotplug_env_var(envp, num_envp, &i, | 645 | return -ENOMEM; |
634 | buffer, buffer_size, &length, | ||
635 | "MODALIAS=usb:v%04Xp%04Xd%04Xdc%02Xdsc%02Xdp%02Xic%02Xisc%02Xip%02X", | ||
636 | le16_to_cpu(usb_dev->descriptor.idVendor), | ||
637 | le16_to_cpu(usb_dev->descriptor.idProduct), | ||
638 | le16_to_cpu(usb_dev->descriptor.bcdDevice), | ||
639 | usb_dev->descriptor.bDeviceClass, | ||
640 | usb_dev->descriptor.bDeviceSubClass, | ||
641 | usb_dev->descriptor.bDeviceProtocol, | ||
642 | alt->desc.bInterfaceClass, | ||
643 | alt->desc.bInterfaceSubClass, | ||
644 | alt->desc.bInterfaceProtocol)) | ||
645 | return -ENOMEM; | ||
646 | } else { | ||
647 | if (add_hotplug_env_var(envp, num_envp, &i, | ||
648 | buffer, buffer_size, &length, | ||
649 | "MODALIAS=usb:v%04Xp%04Xd%04Xdc%02Xdsc%02Xdp%02Xic*isc*ip*", | ||
650 | le16_to_cpu(usb_dev->descriptor.idVendor), | ||
651 | le16_to_cpu(usb_dev->descriptor.idProduct), | ||
652 | le16_to_cpu(usb_dev->descriptor.bcdDevice), | ||
653 | usb_dev->descriptor.bDeviceClass, | ||
654 | usb_dev->descriptor.bDeviceSubClass, | ||
655 | usb_dev->descriptor.bDeviceProtocol)) | ||
656 | return -ENOMEM; | ||
657 | } | ||
658 | 646 | ||
659 | envp[i] = NULL; | 647 | envp[i] = NULL; |
660 | 648 | ||
@@ -709,12 +697,10 @@ usb_alloc_dev(struct usb_device *parent, struct usb_bus *bus, unsigned port1) | |||
709 | { | 697 | { |
710 | struct usb_device *dev; | 698 | struct usb_device *dev; |
711 | 699 | ||
712 | dev = kmalloc(sizeof(*dev), GFP_KERNEL); | 700 | dev = kzalloc(sizeof(*dev), GFP_KERNEL); |
713 | if (!dev) | 701 | if (!dev) |
714 | return NULL; | 702 | return NULL; |
715 | 703 | ||
716 | memset(dev, 0, sizeof(*dev)); | ||
717 | |||
718 | bus = usb_bus_get(bus); | 704 | bus = usb_bus_get(bus); |
719 | if (!bus) { | 705 | if (!bus) { |
720 | kfree(dev); | 706 | kfree(dev); |
@@ -1147,7 +1133,7 @@ int __usb_get_extra_descriptor(char *buffer, unsigned size, | |||
1147 | void *usb_buffer_alloc ( | 1133 | void *usb_buffer_alloc ( |
1148 | struct usb_device *dev, | 1134 | struct usb_device *dev, |
1149 | size_t size, | 1135 | size_t size, |
1150 | unsigned mem_flags, | 1136 | gfp_t mem_flags, |
1151 | dma_addr_t *dma | 1137 | dma_addr_t *dma |
1152 | ) | 1138 | ) |
1153 | { | 1139 | { |
@@ -1402,13 +1388,30 @@ void usb_buffer_unmap_sg (struct usb_device *dev, unsigned pipe, | |||
1402 | usb_pipein (pipe) ? DMA_FROM_DEVICE : DMA_TO_DEVICE); | 1388 | usb_pipein (pipe) ? DMA_FROM_DEVICE : DMA_TO_DEVICE); |
1403 | } | 1389 | } |
1404 | 1390 | ||
1391 | static int verify_suspended(struct device *dev, void *unused) | ||
1392 | { | ||
1393 | return (dev->power.power_state.event == PM_EVENT_ON) ? -EBUSY : 0; | ||
1394 | } | ||
1395 | |||
1405 | static int usb_generic_suspend(struct device *dev, pm_message_t message) | 1396 | static int usb_generic_suspend(struct device *dev, pm_message_t message) |
1406 | { | 1397 | { |
1407 | struct usb_interface *intf; | 1398 | struct usb_interface *intf; |
1408 | struct usb_driver *driver; | 1399 | struct usb_driver *driver; |
1400 | int status; | ||
1409 | 1401 | ||
1410 | if (dev->driver == &usb_generic_driver) | 1402 | /* USB devices enter SUSPEND state through their hubs, but can be |
1411 | return usb_suspend_device (to_usb_device(dev), message); | 1403 | * marked for FREEZE as soon as their children are already idled. |
1404 | * But those semantics are useless, so we equate the two (sigh). | ||
1405 | */ | ||
1406 | if (dev->driver == &usb_generic_driver) { | ||
1407 | if (dev->power.power_state.event == message.event) | ||
1408 | return 0; | ||
1409 | /* we need to rule out bogus requests through sysfs */ | ||
1410 | status = device_for_each_child(dev, NULL, verify_suspended); | ||
1411 | if (status) | ||
1412 | return status; | ||
1413 | return usb_suspend_device (to_usb_device(dev)); | ||
1414 | } | ||
1412 | 1415 | ||
1413 | if ((dev->driver == NULL) || | 1416 | if ((dev->driver == NULL) || |
1414 | (dev->driver_data == &usb_generic_driver_data)) | 1417 | (dev->driver_data == &usb_generic_driver_data)) |
@@ -1417,23 +1420,44 @@ static int usb_generic_suspend(struct device *dev, pm_message_t message) | |||
1417 | intf = to_usb_interface(dev); | 1420 | intf = to_usb_interface(dev); |
1418 | driver = to_usb_driver(dev->driver); | 1421 | driver = to_usb_driver(dev->driver); |
1419 | 1422 | ||
1420 | /* there's only one USB suspend state */ | 1423 | /* with no hardware, USB interfaces only use FREEZE and ON states */ |
1421 | if (intf->dev.power.power_state.event) | 1424 | if (!is_active(intf)) |
1422 | return 0; | 1425 | return 0; |
1423 | 1426 | ||
1424 | if (driver->suspend) | 1427 | if (driver->suspend && driver->resume) { |
1425 | return driver->suspend(intf, message); | 1428 | status = driver->suspend(intf, message); |
1426 | return 0; | 1429 | if (status) |
1430 | dev_err(dev, "%s error %d\n", "suspend", status); | ||
1431 | else | ||
1432 | mark_quiesced(intf); | ||
1433 | } else { | ||
1434 | // FIXME else if there's no suspend method, disconnect... | ||
1435 | dev_warn(dev, "no %s?\n", "suspend"); | ||
1436 | status = 0; | ||
1437 | } | ||
1438 | return status; | ||
1427 | } | 1439 | } |
1428 | 1440 | ||
1429 | static int usb_generic_resume(struct device *dev) | 1441 | static int usb_generic_resume(struct device *dev) |
1430 | { | 1442 | { |
1431 | struct usb_interface *intf; | 1443 | struct usb_interface *intf; |
1432 | struct usb_driver *driver; | 1444 | struct usb_driver *driver; |
1445 | struct usb_device *udev; | ||
1446 | int status; | ||
1433 | 1447 | ||
1434 | /* devices resume through their hub */ | 1448 | if (dev->power.power_state.event == PM_EVENT_ON) |
1435 | if (dev->driver == &usb_generic_driver) | 1449 | return 0; |
1450 | |||
1451 | /* mark things as "on" immediately, no matter what errors crop up */ | ||
1452 | dev->power.power_state.event = PM_EVENT_ON; | ||
1453 | |||
1454 | /* devices resume through their hubs */ | ||
1455 | if (dev->driver == &usb_generic_driver) { | ||
1456 | udev = to_usb_device(dev); | ||
1457 | if (udev->state == USB_STATE_NOTATTACHED) | ||
1458 | return 0; | ||
1436 | return usb_resume_device (to_usb_device(dev)); | 1459 | return usb_resume_device (to_usb_device(dev)); |
1460 | } | ||
1437 | 1461 | ||
1438 | if ((dev->driver == NULL) || | 1462 | if ((dev->driver == NULL) || |
1439 | (dev->driver_data == &usb_generic_driver_data)) | 1463 | (dev->driver_data == &usb_generic_driver_data)) |
@@ -1442,8 +1466,22 @@ static int usb_generic_resume(struct device *dev) | |||
1442 | intf = to_usb_interface(dev); | 1466 | intf = to_usb_interface(dev); |
1443 | driver = to_usb_driver(dev->driver); | 1467 | driver = to_usb_driver(dev->driver); |
1444 | 1468 | ||
1445 | if (driver->resume) | 1469 | udev = interface_to_usbdev(intf); |
1446 | return driver->resume(intf); | 1470 | if (udev->state == USB_STATE_NOTATTACHED) |
1471 | return 0; | ||
1472 | |||
1473 | /* if driver was suspended, it has a resume method; | ||
1474 | * however, sysfs can wrongly mark things as suspended | ||
1475 | * (on the "no suspend method" FIXME path above) | ||
1476 | */ | ||
1477 | if (driver->resume) { | ||
1478 | status = driver->resume(intf); | ||
1479 | if (status) { | ||
1480 | dev_err(dev, "%s error %d\n", "resume", status); | ||
1481 | mark_quiesced(intf); | ||
1482 | } | ||
1483 | } else | ||
1484 | dev_warn(dev, "no %s?\n", "resume"); | ||
1447 | return 0; | 1485 | return 0; |
1448 | } | 1486 | } |
1449 | 1487 | ||
diff --git a/drivers/usb/core/usb.h b/drivers/usb/core/usb.h index 83d48c8133af..1c4a68499dce 100644 --- a/drivers/usb/core/usb.h +++ b/drivers/usb/core/usb.h | |||
@@ -13,12 +13,14 @@ extern void usb_disable_device (struct usb_device *dev, int skip_ep0); | |||
13 | 13 | ||
14 | extern int usb_get_device_descriptor(struct usb_device *dev, | 14 | extern int usb_get_device_descriptor(struct usb_device *dev, |
15 | unsigned int size); | 15 | unsigned int size); |
16 | extern char *usb_cache_string(struct usb_device *udev, int index); | ||
16 | extern int usb_set_configuration(struct usb_device *dev, int configuration); | 17 | extern int usb_set_configuration(struct usb_device *dev, int configuration); |
17 | 18 | ||
18 | extern void usb_lock_all_devices(void); | 19 | extern void usb_lock_all_devices(void); |
19 | extern void usb_unlock_all_devices(void); | 20 | extern void usb_unlock_all_devices(void); |
20 | 21 | ||
21 | extern void usb_kick_khubd(struct usb_device *dev); | 22 | extern void usb_kick_khubd(struct usb_device *dev); |
23 | extern void usb_suspend_root_hub(struct usb_device *hdev); | ||
22 | extern void usb_resume_root_hub(struct usb_device *dev); | 24 | extern void usb_resume_root_hub(struct usb_device *dev); |
23 | 25 | ||
24 | extern int usb_hub_init(void); | 26 | extern int usb_hub_init(void); |
@@ -28,6 +30,28 @@ extern void usb_major_cleanup(void); | |||
28 | extern int usb_host_init(void); | 30 | extern int usb_host_init(void); |
29 | extern void usb_host_cleanup(void); | 31 | extern void usb_host_cleanup(void); |
30 | 32 | ||
33 | extern int usb_suspend_device(struct usb_device *dev); | ||
34 | extern int usb_resume_device(struct usb_device *dev); | ||
35 | |||
36 | |||
37 | /* Interfaces and their "power state" are owned by usbcore */ | ||
38 | |||
39 | static inline void mark_active(struct usb_interface *f) | ||
40 | { | ||
41 | f->dev.power.power_state.event = PM_EVENT_ON; | ||
42 | } | ||
43 | |||
44 | static inline void mark_quiesced(struct usb_interface *f) | ||
45 | { | ||
46 | f->dev.power.power_state.event = PM_EVENT_FREEZE; | ||
47 | } | ||
48 | |||
49 | static inline int is_active(struct usb_interface *f) | ||
50 | { | ||
51 | return f->dev.power.power_state.event == PM_EVENT_ON; | ||
52 | } | ||
53 | |||
54 | |||
31 | /* for labeling diagnostics */ | 55 | /* for labeling diagnostics */ |
32 | extern const char *usbcore_name; | 56 | extern const char *usbcore_name; |
33 | 57 | ||
@@ -39,9 +63,6 @@ extern void usbfs_conn_disc_event(void); | |||
39 | 63 | ||
40 | extern int usbdev_init(void); | 64 | extern int usbdev_init(void); |
41 | extern void usbdev_cleanup(void); | 65 | extern void usbdev_cleanup(void); |
42 | extern void usbdev_add(struct usb_device *dev); | ||
43 | extern void usbdev_remove(struct usb_device *dev); | ||
44 | extern struct usb_device *usbdev_lookup_minor(int minor); | ||
45 | 66 | ||
46 | struct dev_state { | 67 | struct dev_state { |
47 | struct list_head list; /* state list */ | 68 | struct list_head list; /* state list */ |
@@ -52,8 +73,15 @@ struct dev_state { | |||
52 | struct list_head async_completed; | 73 | struct list_head async_completed; |
53 | wait_queue_head_t wait; /* wake up if a request completed */ | 74 | wait_queue_head_t wait; /* wake up if a request completed */ |
54 | unsigned int discsignr; | 75 | unsigned int discsignr; |
55 | struct task_struct *disctask; | 76 | pid_t disc_pid; |
77 | uid_t disc_uid, disc_euid; | ||
56 | void __user *disccontext; | 78 | void __user *disccontext; |
57 | unsigned long ifclaimed; | 79 | unsigned long ifclaimed; |
58 | }; | 80 | }; |
59 | 81 | ||
82 | /* internal notify stuff */ | ||
83 | extern void usb_notify_add_device(struct usb_device *udev); | ||
84 | extern void usb_notify_remove_device(struct usb_device *udev); | ||
85 | extern void usb_notify_add_bus(struct usb_bus *ubus); | ||
86 | extern void usb_notify_remove_bus(struct usb_bus *ubus); | ||
87 | |||
diff --git a/drivers/usb/gadget/dummy_hcd.c b/drivers/usb/gadget/dummy_hcd.c index 583db7c38cf1..c655d46c8aed 100644 --- a/drivers/usb/gadget/dummy_hcd.c +++ b/drivers/usb/gadget/dummy_hcd.c | |||
@@ -49,8 +49,7 @@ | |||
49 | #include <linux/timer.h> | 49 | #include <linux/timer.h> |
50 | #include <linux/list.h> | 50 | #include <linux/list.h> |
51 | #include <linux/interrupt.h> | 51 | #include <linux/interrupt.h> |
52 | #include <linux/version.h> | 52 | #include <linux/platform_device.h> |
53 | |||
54 | #include <linux/usb.h> | 53 | #include <linux/usb.h> |
55 | #include <linux/usb_gadget.h> | 54 | #include <linux/usb_gadget.h> |
56 | 55 | ||
@@ -470,7 +469,7 @@ static int dummy_disable (struct usb_ep *_ep) | |||
470 | } | 469 | } |
471 | 470 | ||
472 | static struct usb_request * | 471 | static struct usb_request * |
473 | dummy_alloc_request (struct usb_ep *_ep, unsigned mem_flags) | 472 | dummy_alloc_request (struct usb_ep *_ep, gfp_t mem_flags) |
474 | { | 473 | { |
475 | struct dummy_ep *ep; | 474 | struct dummy_ep *ep; |
476 | struct dummy_request *req; | 475 | struct dummy_request *req; |
@@ -507,7 +506,7 @@ dummy_alloc_buffer ( | |||
507 | struct usb_ep *_ep, | 506 | struct usb_ep *_ep, |
508 | unsigned bytes, | 507 | unsigned bytes, |
509 | dma_addr_t *dma, | 508 | dma_addr_t *dma, |
510 | unsigned mem_flags | 509 | gfp_t mem_flags |
511 | ) { | 510 | ) { |
512 | char *retval; | 511 | char *retval; |
513 | struct dummy_ep *ep; | 512 | struct dummy_ep *ep; |
@@ -541,7 +540,7 @@ fifo_complete (struct usb_ep *ep, struct usb_request *req) | |||
541 | 540 | ||
542 | static int | 541 | static int |
543 | dummy_queue (struct usb_ep *_ep, struct usb_request *_req, | 542 | dummy_queue (struct usb_ep *_ep, struct usb_request *_req, |
544 | unsigned mem_flags) | 543 | gfp_t mem_flags) |
545 | { | 544 | { |
546 | struct dummy_ep *ep; | 545 | struct dummy_ep *ep; |
547 | struct dummy_request *req; | 546 | struct dummy_request *req; |
@@ -897,7 +896,7 @@ dummy_gadget_release (struct device *dev) | |||
897 | #endif | 896 | #endif |
898 | } | 897 | } |
899 | 898 | ||
900 | static int dummy_udc_probe (struct device *dev) | 899 | static int dummy_udc_probe (struct platform_device *dev) |
901 | { | 900 | { |
902 | struct dummy *dum = the_controller; | 901 | struct dummy *dum = the_controller; |
903 | int rc; | 902 | int rc; |
@@ -910,7 +909,7 @@ static int dummy_udc_probe (struct device *dev) | |||
910 | dum->gadget.is_otg = (dummy_to_hcd(dum)->self.otg_port != 0); | 909 | dum->gadget.is_otg = (dummy_to_hcd(dum)->self.otg_port != 0); |
911 | 910 | ||
912 | strcpy (dum->gadget.dev.bus_id, "gadget"); | 911 | strcpy (dum->gadget.dev.bus_id, "gadget"); |
913 | dum->gadget.dev.parent = dev; | 912 | dum->gadget.dev.parent = &dev->dev; |
914 | dum->gadget.dev.release = dummy_gadget_release; | 913 | dum->gadget.dev.release = dummy_gadget_release; |
915 | rc = device_register (&dum->gadget.dev); | 914 | rc = device_register (&dum->gadget.dev); |
916 | if (rc < 0) | 915 | if (rc < 0) |
@@ -920,65 +919,60 @@ static int dummy_udc_probe (struct device *dev) | |||
920 | usb_bus_get (&dummy_to_hcd (dum)->self); | 919 | usb_bus_get (&dummy_to_hcd (dum)->self); |
921 | #endif | 920 | #endif |
922 | 921 | ||
923 | dev_set_drvdata (dev, dum); | 922 | platform_set_drvdata (dev, dum); |
924 | device_create_file (&dum->gadget.dev, &dev_attr_function); | 923 | device_create_file (&dum->gadget.dev, &dev_attr_function); |
925 | return rc; | 924 | return rc; |
926 | } | 925 | } |
927 | 926 | ||
928 | static int dummy_udc_remove (struct device *dev) | 927 | static int dummy_udc_remove (struct platform_device *dev) |
929 | { | 928 | { |
930 | struct dummy *dum = dev_get_drvdata (dev); | 929 | struct dummy *dum = platform_get_drvdata (dev); |
931 | 930 | ||
932 | dev_set_drvdata (dev, NULL); | 931 | platform_set_drvdata (dev, NULL); |
933 | device_remove_file (&dum->gadget.dev, &dev_attr_function); | 932 | device_remove_file (&dum->gadget.dev, &dev_attr_function); |
934 | device_unregister (&dum->gadget.dev); | 933 | device_unregister (&dum->gadget.dev); |
935 | return 0; | 934 | return 0; |
936 | } | 935 | } |
937 | 936 | ||
938 | static int dummy_udc_suspend (struct device *dev, pm_message_t state, | 937 | static int dummy_udc_suspend (struct platform_device *dev, pm_message_t state) |
939 | u32 level) | ||
940 | { | 938 | { |
941 | struct dummy *dum = dev_get_drvdata(dev); | 939 | struct dummy *dum = platform_get_drvdata(dev); |
942 | |||
943 | if (level != SUSPEND_DISABLE) | ||
944 | return 0; | ||
945 | 940 | ||
946 | dev_dbg (dev, "%s\n", __FUNCTION__); | 941 | dev_dbg (&dev->dev, "%s\n", __FUNCTION__); |
947 | spin_lock_irq (&dum->lock); | 942 | spin_lock_irq (&dum->lock); |
948 | dum->udc_suspended = 1; | 943 | dum->udc_suspended = 1; |
949 | set_link_state (dum); | 944 | set_link_state (dum); |
950 | spin_unlock_irq (&dum->lock); | 945 | spin_unlock_irq (&dum->lock); |
951 | 946 | ||
952 | dev->power.power_state = state; | 947 | dev->dev.power.power_state = state; |
953 | usb_hcd_poll_rh_status (dummy_to_hcd (dum)); | 948 | usb_hcd_poll_rh_status (dummy_to_hcd (dum)); |
954 | return 0; | 949 | return 0; |
955 | } | 950 | } |
956 | 951 | ||
957 | static int dummy_udc_resume (struct device *dev, u32 level) | 952 | static int dummy_udc_resume (struct platform_device *dev) |
958 | { | 953 | { |
959 | struct dummy *dum = dev_get_drvdata(dev); | 954 | struct dummy *dum = platform_get_drvdata(dev); |
960 | |||
961 | if (level != RESUME_ENABLE) | ||
962 | return 0; | ||
963 | 955 | ||
964 | dev_dbg (dev, "%s\n", __FUNCTION__); | 956 | dev_dbg (&dev->dev, "%s\n", __FUNCTION__); |
965 | spin_lock_irq (&dum->lock); | 957 | spin_lock_irq (&dum->lock); |
966 | dum->udc_suspended = 0; | 958 | dum->udc_suspended = 0; |
967 | set_link_state (dum); | 959 | set_link_state (dum); |
968 | spin_unlock_irq (&dum->lock); | 960 | spin_unlock_irq (&dum->lock); |
969 | 961 | ||
970 | dev->power.power_state = PMSG_ON; | 962 | dev->dev.power.power_state = PMSG_ON; |
971 | usb_hcd_poll_rh_status (dummy_to_hcd (dum)); | 963 | usb_hcd_poll_rh_status (dummy_to_hcd (dum)); |
972 | return 0; | 964 | return 0; |
973 | } | 965 | } |
974 | 966 | ||
975 | static struct device_driver dummy_udc_driver = { | 967 | static struct platform_driver dummy_udc_driver = { |
976 | .name = (char *) gadget_name, | ||
977 | .bus = &platform_bus_type, | ||
978 | .probe = dummy_udc_probe, | 968 | .probe = dummy_udc_probe, |
979 | .remove = dummy_udc_remove, | 969 | .remove = dummy_udc_remove, |
980 | .suspend = dummy_udc_suspend, | 970 | .suspend = dummy_udc_suspend, |
981 | .resume = dummy_udc_resume, | 971 | .resume = dummy_udc_resume, |
972 | .driver = { | ||
973 | .name = (char *) gadget_name, | ||
974 | .owner = THIS_MODULE, | ||
975 | }, | ||
982 | }; | 976 | }; |
983 | 977 | ||
984 | /*-------------------------------------------------------------------------*/ | 978 | /*-------------------------------------------------------------------------*/ |
@@ -999,7 +993,7 @@ static int dummy_urb_enqueue ( | |||
999 | struct usb_hcd *hcd, | 993 | struct usb_hcd *hcd, |
1000 | struct usb_host_endpoint *ep, | 994 | struct usb_host_endpoint *ep, |
1001 | struct urb *urb, | 995 | struct urb *urb, |
1002 | unsigned mem_flags | 996 | gfp_t mem_flags |
1003 | ) { | 997 | ) { |
1004 | struct dummy *dum; | 998 | struct dummy *dum; |
1005 | struct urbp *urbp; | 999 | struct urbp *urbp; |
@@ -1758,7 +1752,7 @@ static int dummy_hub_control ( | |||
1758 | return retval; | 1752 | return retval; |
1759 | } | 1753 | } |
1760 | 1754 | ||
1761 | static int dummy_hub_suspend (struct usb_hcd *hcd) | 1755 | static int dummy_bus_suspend (struct usb_hcd *hcd) |
1762 | { | 1756 | { |
1763 | struct dummy *dum = hcd_to_dummy (hcd); | 1757 | struct dummy *dum = hcd_to_dummy (hcd); |
1764 | 1758 | ||
@@ -1769,7 +1763,7 @@ static int dummy_hub_suspend (struct usb_hcd *hcd) | |||
1769 | return 0; | 1763 | return 0; |
1770 | } | 1764 | } |
1771 | 1765 | ||
1772 | static int dummy_hub_resume (struct usb_hcd *hcd) | 1766 | static int dummy_bus_resume (struct usb_hcd *hcd) |
1773 | { | 1767 | { |
1774 | struct dummy *dum = hcd_to_dummy (hcd); | 1768 | struct dummy *dum = hcd_to_dummy (hcd); |
1775 | 1769 | ||
@@ -1901,18 +1895,18 @@ static const struct hc_driver dummy_hcd = { | |||
1901 | 1895 | ||
1902 | .hub_status_data = dummy_hub_status, | 1896 | .hub_status_data = dummy_hub_status, |
1903 | .hub_control = dummy_hub_control, | 1897 | .hub_control = dummy_hub_control, |
1904 | .hub_suspend = dummy_hub_suspend, | 1898 | .bus_suspend = dummy_bus_suspend, |
1905 | .hub_resume = dummy_hub_resume, | 1899 | .bus_resume = dummy_bus_resume, |
1906 | }; | 1900 | }; |
1907 | 1901 | ||
1908 | static int dummy_hcd_probe (struct device *dev) | 1902 | static int dummy_hcd_probe (struct platform_device *dev) |
1909 | { | 1903 | { |
1910 | struct usb_hcd *hcd; | 1904 | struct usb_hcd *hcd; |
1911 | int retval; | 1905 | int retval; |
1912 | 1906 | ||
1913 | dev_info (dev, "%s, driver " DRIVER_VERSION "\n", driver_desc); | 1907 | dev_info(&dev->dev, "%s, driver " DRIVER_VERSION "\n", driver_desc); |
1914 | 1908 | ||
1915 | hcd = usb_create_hcd (&dummy_hcd, dev, dev->bus_id); | 1909 | hcd = usb_create_hcd (&dummy_hcd, &dev->dev, dev->dev.bus_id); |
1916 | if (!hcd) | 1910 | if (!hcd) |
1917 | return -ENOMEM; | 1911 | return -ENOMEM; |
1918 | the_controller = hcd_to_dummy (hcd); | 1912 | the_controller = hcd_to_dummy (hcd); |
@@ -1925,68 +1919,49 @@ static int dummy_hcd_probe (struct device *dev) | |||
1925 | return retval; | 1919 | return retval; |
1926 | } | 1920 | } |
1927 | 1921 | ||
1928 | static int dummy_hcd_remove (struct device *dev) | 1922 | static int dummy_hcd_remove (struct platform_device *dev) |
1929 | { | 1923 | { |
1930 | struct usb_hcd *hcd; | 1924 | struct usb_hcd *hcd; |
1931 | 1925 | ||
1932 | hcd = dev_get_drvdata (dev); | 1926 | hcd = platform_get_drvdata (dev); |
1933 | usb_remove_hcd (hcd); | 1927 | usb_remove_hcd (hcd); |
1934 | usb_put_hcd (hcd); | 1928 | usb_put_hcd (hcd); |
1935 | the_controller = NULL; | 1929 | the_controller = NULL; |
1936 | return 0; | 1930 | return 0; |
1937 | } | 1931 | } |
1938 | 1932 | ||
1939 | static int dummy_hcd_suspend (struct device *dev, pm_message_t state, | 1933 | static int dummy_hcd_suspend (struct platform_device *dev, pm_message_t state) |
1940 | u32 level) | ||
1941 | { | 1934 | { |
1942 | struct usb_hcd *hcd; | 1935 | struct usb_hcd *hcd; |
1943 | 1936 | ||
1944 | if (level != SUSPEND_DISABLE) | 1937 | dev_dbg (&dev->dev, "%s\n", __FUNCTION__); |
1945 | return 0; | 1938 | hcd = platform_get_drvdata (dev); |
1946 | |||
1947 | dev_dbg (dev, "%s\n", __FUNCTION__); | ||
1948 | hcd = dev_get_drvdata (dev); | ||
1949 | |||
1950 | #ifndef CONFIG_USB_SUSPEND | ||
1951 | /* Otherwise this would never happen */ | ||
1952 | usb_lock_device (hcd->self.root_hub); | ||
1953 | dummy_hub_suspend (hcd); | ||
1954 | usb_unlock_device (hcd->self.root_hub); | ||
1955 | #endif | ||
1956 | 1939 | ||
1957 | hcd->state = HC_STATE_SUSPENDED; | 1940 | hcd->state = HC_STATE_SUSPENDED; |
1958 | return 0; | 1941 | return 0; |
1959 | } | 1942 | } |
1960 | 1943 | ||
1961 | static int dummy_hcd_resume (struct device *dev, u32 level) | 1944 | static int dummy_hcd_resume (struct platform_device *dev) |
1962 | { | 1945 | { |
1963 | struct usb_hcd *hcd; | 1946 | struct usb_hcd *hcd; |
1964 | 1947 | ||
1965 | if (level != RESUME_ENABLE) | 1948 | dev_dbg (&dev->dev, "%s\n", __FUNCTION__); |
1966 | return 0; | 1949 | hcd = platform_get_drvdata (dev); |
1967 | |||
1968 | dev_dbg (dev, "%s\n", __FUNCTION__); | ||
1969 | hcd = dev_get_drvdata (dev); | ||
1970 | hcd->state = HC_STATE_RUNNING; | 1950 | hcd->state = HC_STATE_RUNNING; |
1971 | 1951 | ||
1972 | #ifndef CONFIG_USB_SUSPEND | ||
1973 | /* Otherwise this would never happen */ | ||
1974 | usb_lock_device (hcd->self.root_hub); | ||
1975 | dummy_hub_resume (hcd); | ||
1976 | usb_unlock_device (hcd->self.root_hub); | ||
1977 | #endif | ||
1978 | |||
1979 | usb_hcd_poll_rh_status (hcd); | 1952 | usb_hcd_poll_rh_status (hcd); |
1980 | return 0; | 1953 | return 0; |
1981 | } | 1954 | } |
1982 | 1955 | ||
1983 | static struct device_driver dummy_hcd_driver = { | 1956 | static struct platform_driver dummy_hcd_driver = { |
1984 | .name = (char *) driver_name, | ||
1985 | .bus = &platform_bus_type, | ||
1986 | .probe = dummy_hcd_probe, | 1957 | .probe = dummy_hcd_probe, |
1987 | .remove = dummy_hcd_remove, | 1958 | .remove = dummy_hcd_remove, |
1988 | .suspend = dummy_hcd_suspend, | 1959 | .suspend = dummy_hcd_suspend, |
1989 | .resume = dummy_hcd_resume, | 1960 | .resume = dummy_hcd_resume, |
1961 | .driver = { | ||
1962 | .name = (char *) driver_name, | ||
1963 | .owner = THIS_MODULE, | ||
1964 | }, | ||
1990 | }; | 1965 | }; |
1991 | 1966 | ||
1992 | /*-------------------------------------------------------------------------*/ | 1967 | /*-------------------------------------------------------------------------*/ |
@@ -2022,11 +1997,11 @@ static int __init init (void) | |||
2022 | if (usb_disabled ()) | 1997 | if (usb_disabled ()) |
2023 | return -ENODEV; | 1998 | return -ENODEV; |
2024 | 1999 | ||
2025 | retval = driver_register (&dummy_hcd_driver); | 2000 | retval = platform_driver_register (&dummy_hcd_driver); |
2026 | if (retval < 0) | 2001 | if (retval < 0) |
2027 | return retval; | 2002 | return retval; |
2028 | 2003 | ||
2029 | retval = driver_register (&dummy_udc_driver); | 2004 | retval = platform_driver_register (&dummy_udc_driver); |
2030 | if (retval < 0) | 2005 | if (retval < 0) |
2031 | goto err_register_udc_driver; | 2006 | goto err_register_udc_driver; |
2032 | 2007 | ||
@@ -2042,9 +2017,9 @@ static int __init init (void) | |||
2042 | err_register_udc: | 2017 | err_register_udc: |
2043 | platform_device_unregister (&the_hcd_pdev); | 2018 | platform_device_unregister (&the_hcd_pdev); |
2044 | err_register_hcd: | 2019 | err_register_hcd: |
2045 | driver_unregister (&dummy_udc_driver); | 2020 | platform_driver_unregister (&dummy_udc_driver); |
2046 | err_register_udc_driver: | 2021 | err_register_udc_driver: |
2047 | driver_unregister (&dummy_hcd_driver); | 2022 | platform_driver_unregister (&dummy_hcd_driver); |
2048 | return retval; | 2023 | return retval; |
2049 | } | 2024 | } |
2050 | module_init (init); | 2025 | module_init (init); |
@@ -2053,7 +2028,7 @@ static void __exit cleanup (void) | |||
2053 | { | 2028 | { |
2054 | platform_device_unregister (&the_udc_pdev); | 2029 | platform_device_unregister (&the_udc_pdev); |
2055 | platform_device_unregister (&the_hcd_pdev); | 2030 | platform_device_unregister (&the_hcd_pdev); |
2056 | driver_unregister (&dummy_udc_driver); | 2031 | platform_driver_unregister (&dummy_udc_driver); |
2057 | driver_unregister (&dummy_hcd_driver); | 2032 | platform_driver_unregister (&dummy_hcd_driver); |
2058 | } | 2033 | } |
2059 | module_exit (cleanup); | 2034 | module_exit (cleanup); |
diff --git a/drivers/usb/gadget/ether.c b/drivers/usb/gadget/ether.c index 49459e33e952..8f402f85e1ca 100644 --- a/drivers/usb/gadget/ether.c +++ b/drivers/usb/gadget/ether.c | |||
@@ -945,11 +945,11 @@ config_buf (enum usb_device_speed speed, | |||
945 | 945 | ||
946 | /*-------------------------------------------------------------------------*/ | 946 | /*-------------------------------------------------------------------------*/ |
947 | 947 | ||
948 | static void eth_start (struct eth_dev *dev, unsigned gfp_flags); | 948 | static void eth_start (struct eth_dev *dev, gfp_t gfp_flags); |
949 | static int alloc_requests (struct eth_dev *dev, unsigned n, unsigned gfp_flags); | 949 | static int alloc_requests (struct eth_dev *dev, unsigned n, gfp_t gfp_flags); |
950 | 950 | ||
951 | static int | 951 | static int |
952 | set_ether_config (struct eth_dev *dev, unsigned gfp_flags) | 952 | set_ether_config (struct eth_dev *dev, gfp_t gfp_flags) |
953 | { | 953 | { |
954 | int result = 0; | 954 | int result = 0; |
955 | struct usb_gadget *gadget = dev->gadget; | 955 | struct usb_gadget *gadget = dev->gadget; |
@@ -1081,7 +1081,7 @@ static void eth_reset_config (struct eth_dev *dev) | |||
1081 | * that returns config descriptors, and altsetting code. | 1081 | * that returns config descriptors, and altsetting code. |
1082 | */ | 1082 | */ |
1083 | static int | 1083 | static int |
1084 | eth_set_config (struct eth_dev *dev, unsigned number, unsigned gfp_flags) | 1084 | eth_set_config (struct eth_dev *dev, unsigned number, gfp_t gfp_flags) |
1085 | { | 1085 | { |
1086 | int result = 0; | 1086 | int result = 0; |
1087 | struct usb_gadget *gadget = dev->gadget; | 1087 | struct usb_gadget *gadget = dev->gadget; |
@@ -1598,7 +1598,7 @@ static void defer_kevent (struct eth_dev *dev, int flag) | |||
1598 | static void rx_complete (struct usb_ep *ep, struct usb_request *req); | 1598 | static void rx_complete (struct usb_ep *ep, struct usb_request *req); |
1599 | 1599 | ||
1600 | static int | 1600 | static int |
1601 | rx_submit (struct eth_dev *dev, struct usb_request *req, unsigned gfp_flags) | 1601 | rx_submit (struct eth_dev *dev, struct usb_request *req, gfp_t gfp_flags) |
1602 | { | 1602 | { |
1603 | struct sk_buff *skb; | 1603 | struct sk_buff *skb; |
1604 | int retval = -ENOMEM; | 1604 | int retval = -ENOMEM; |
@@ -1724,7 +1724,7 @@ clean: | |||
1724 | } | 1724 | } |
1725 | 1725 | ||
1726 | static int prealloc (struct list_head *list, struct usb_ep *ep, | 1726 | static int prealloc (struct list_head *list, struct usb_ep *ep, |
1727 | unsigned n, unsigned gfp_flags) | 1727 | unsigned n, gfp_t gfp_flags) |
1728 | { | 1728 | { |
1729 | unsigned i; | 1729 | unsigned i; |
1730 | struct usb_request *req; | 1730 | struct usb_request *req; |
@@ -1763,7 +1763,7 @@ extra: | |||
1763 | return 0; | 1763 | return 0; |
1764 | } | 1764 | } |
1765 | 1765 | ||
1766 | static int alloc_requests (struct eth_dev *dev, unsigned n, unsigned gfp_flags) | 1766 | static int alloc_requests (struct eth_dev *dev, unsigned n, gfp_t gfp_flags) |
1767 | { | 1767 | { |
1768 | int status; | 1768 | int status; |
1769 | 1769 | ||
@@ -1779,7 +1779,7 @@ fail: | |||
1779 | return status; | 1779 | return status; |
1780 | } | 1780 | } |
1781 | 1781 | ||
1782 | static void rx_fill (struct eth_dev *dev, unsigned gfp_flags) | 1782 | static void rx_fill (struct eth_dev *dev, gfp_t gfp_flags) |
1783 | { | 1783 | { |
1784 | struct usb_request *req; | 1784 | struct usb_request *req; |
1785 | unsigned long flags; | 1785 | unsigned long flags; |
@@ -1962,7 +1962,7 @@ drop: | |||
1962 | * normally just one notification will be queued. | 1962 | * normally just one notification will be queued. |
1963 | */ | 1963 | */ |
1964 | 1964 | ||
1965 | static struct usb_request *eth_req_alloc (struct usb_ep *, unsigned, unsigned); | 1965 | static struct usb_request *eth_req_alloc (struct usb_ep *, unsigned, gfp_t); |
1966 | static void eth_req_free (struct usb_ep *ep, struct usb_request *req); | 1966 | static void eth_req_free (struct usb_ep *ep, struct usb_request *req); |
1967 | 1967 | ||
1968 | static void | 1968 | static void |
@@ -2024,7 +2024,7 @@ static int rndis_control_ack (struct net_device *net) | |||
2024 | 2024 | ||
2025 | #endif /* RNDIS */ | 2025 | #endif /* RNDIS */ |
2026 | 2026 | ||
2027 | static void eth_start (struct eth_dev *dev, unsigned gfp_flags) | 2027 | static void eth_start (struct eth_dev *dev, gfp_t gfp_flags) |
2028 | { | 2028 | { |
2029 | DEBUG (dev, "%s\n", __FUNCTION__); | 2029 | DEBUG (dev, "%s\n", __FUNCTION__); |
2030 | 2030 | ||
@@ -2092,7 +2092,7 @@ static int eth_stop (struct net_device *net) | |||
2092 | /*-------------------------------------------------------------------------*/ | 2092 | /*-------------------------------------------------------------------------*/ |
2093 | 2093 | ||
2094 | static struct usb_request * | 2094 | static struct usb_request * |
2095 | eth_req_alloc (struct usb_ep *ep, unsigned size, unsigned gfp_flags) | 2095 | eth_req_alloc (struct usb_ep *ep, unsigned size, gfp_t gfp_flags) |
2096 | { | 2096 | { |
2097 | struct usb_request *req; | 2097 | struct usb_request *req; |
2098 | 2098 | ||
@@ -2533,6 +2533,7 @@ static struct usb_gadget_driver eth_driver = { | |||
2533 | 2533 | ||
2534 | .driver = { | 2534 | .driver = { |
2535 | .name = (char *) shortname, | 2535 | .name = (char *) shortname, |
2536 | .owner = THIS_MODULE, | ||
2536 | // .shutdown = ... | 2537 | // .shutdown = ... |
2537 | // .suspend = ... | 2538 | // .suspend = ... |
2538 | // .resume = ... | 2539 | // .resume = ... |
diff --git a/drivers/usb/gadget/file_storage.c b/drivers/usb/gadget/file_storage.c index a41d9d4baee3..ea09aaa3cab6 100644 --- a/drivers/usb/gadget/file_storage.c +++ b/drivers/usb/gadget/file_storage.c | |||
@@ -224,6 +224,7 @@ | |||
224 | #include <linux/fs.h> | 224 | #include <linux/fs.h> |
225 | #include <linux/init.h> | 225 | #include <linux/init.h> |
226 | #include <linux/kernel.h> | 226 | #include <linux/kernel.h> |
227 | #include <linux/kthread.h> | ||
227 | #include <linux/limits.h> | 228 | #include <linux/limits.h> |
228 | #include <linux/list.h> | 229 | #include <linux/list.h> |
229 | #include <linux/module.h> | 230 | #include <linux/module.h> |
@@ -669,7 +670,6 @@ struct fsg_dev { | |||
669 | wait_queue_head_t thread_wqh; | 670 | wait_queue_head_t thread_wqh; |
670 | int thread_wakeup_needed; | 671 | int thread_wakeup_needed; |
671 | struct completion thread_notifier; | 672 | struct completion thread_notifier; |
672 | int thread_pid; | ||
673 | struct task_struct *thread_task; | 673 | struct task_struct *thread_task; |
674 | sigset_t thread_signal_mask; | 674 | sigset_t thread_signal_mask; |
675 | 675 | ||
@@ -1084,7 +1084,6 @@ static void wakeup_thread(struct fsg_dev *fsg) | |||
1084 | static void raise_exception(struct fsg_dev *fsg, enum fsg_state new_state) | 1084 | static void raise_exception(struct fsg_dev *fsg, enum fsg_state new_state) |
1085 | { | 1085 | { |
1086 | unsigned long flags; | 1086 | unsigned long flags; |
1087 | struct task_struct *thread_task; | ||
1088 | 1087 | ||
1089 | /* Do nothing if a higher-priority exception is already in progress. | 1088 | /* Do nothing if a higher-priority exception is already in progress. |
1090 | * If a lower-or-equal priority exception is in progress, preempt it | 1089 | * If a lower-or-equal priority exception is in progress, preempt it |
@@ -1093,9 +1092,9 @@ static void raise_exception(struct fsg_dev *fsg, enum fsg_state new_state) | |||
1093 | if (fsg->state <= new_state) { | 1092 | if (fsg->state <= new_state) { |
1094 | fsg->exception_req_tag = fsg->ep0_req_tag; | 1093 | fsg->exception_req_tag = fsg->ep0_req_tag; |
1095 | fsg->state = new_state; | 1094 | fsg->state = new_state; |
1096 | thread_task = fsg->thread_task; | 1095 | if (fsg->thread_task) |
1097 | if (thread_task) | 1096 | send_sig_info(SIGUSR1, SEND_SIG_FORCED, |
1098 | send_sig_info(SIGUSR1, SEND_SIG_FORCED, thread_task); | 1097 | fsg->thread_task); |
1099 | } | 1098 | } |
1100 | spin_unlock_irqrestore(&fsg->lock, flags); | 1099 | spin_unlock_irqrestore(&fsg->lock, flags); |
1101 | } | 1100 | } |
@@ -3383,11 +3382,6 @@ static int fsg_main_thread(void *fsg_) | |||
3383 | { | 3382 | { |
3384 | struct fsg_dev *fsg = (struct fsg_dev *) fsg_; | 3383 | struct fsg_dev *fsg = (struct fsg_dev *) fsg_; |
3385 | 3384 | ||
3386 | fsg->thread_task = current; | ||
3387 | |||
3388 | /* Release all our userspace resources */ | ||
3389 | daemonize("file-storage-gadget"); | ||
3390 | |||
3391 | /* Allow the thread to be killed by a signal, but set the signal mask | 3385 | /* Allow the thread to be killed by a signal, but set the signal mask |
3392 | * to block everything but INT, TERM, KILL, and USR1. */ | 3386 | * to block everything but INT, TERM, KILL, and USR1. */ |
3393 | siginitsetinv(&fsg->thread_signal_mask, sigmask(SIGINT) | | 3387 | siginitsetinv(&fsg->thread_signal_mask, sigmask(SIGINT) | |
@@ -3400,9 +3394,6 @@ static int fsg_main_thread(void *fsg_) | |||
3400 | * that expects a __user pointer and it will work okay. */ | 3394 | * that expects a __user pointer and it will work okay. */ |
3401 | set_fs(get_ds()); | 3395 | set_fs(get_ds()); |
3402 | 3396 | ||
3403 | /* Wait for the gadget registration to finish up */ | ||
3404 | wait_for_completion(&fsg->thread_notifier); | ||
3405 | |||
3406 | /* The main loop */ | 3397 | /* The main loop */ |
3407 | while (fsg->state != FSG_STATE_TERMINATED) { | 3398 | while (fsg->state != FSG_STATE_TERMINATED) { |
3408 | if (exception_in_progress(fsg) || signal_pending(current)) { | 3399 | if (exception_in_progress(fsg) || signal_pending(current)) { |
@@ -3440,8 +3431,9 @@ static int fsg_main_thread(void *fsg_) | |||
3440 | spin_unlock_irq(&fsg->lock); | 3431 | spin_unlock_irq(&fsg->lock); |
3441 | } | 3432 | } |
3442 | 3433 | ||
3434 | spin_lock_irq(&fsg->lock); | ||
3443 | fsg->thread_task = NULL; | 3435 | fsg->thread_task = NULL; |
3444 | flush_signals(current); | 3436 | spin_unlock_irq(&fsg->lock); |
3445 | 3437 | ||
3446 | /* In case we are exiting because of a signal, unregister the | 3438 | /* In case we are exiting because of a signal, unregister the |
3447 | * gadget driver and close the backing file. */ | 3439 | * gadget driver and close the backing file. */ |
@@ -3831,12 +3823,11 @@ static int __init fsg_bind(struct usb_gadget *gadget) | |||
3831 | 3823 | ||
3832 | /* Create the LUNs, open their backing files, and register the | 3824 | /* Create the LUNs, open their backing files, and register the |
3833 | * LUN devices in sysfs. */ | 3825 | * LUN devices in sysfs. */ |
3834 | fsg->luns = kmalloc(i * sizeof(struct lun), GFP_KERNEL); | 3826 | fsg->luns = kzalloc(i * sizeof(struct lun), GFP_KERNEL); |
3835 | if (!fsg->luns) { | 3827 | if (!fsg->luns) { |
3836 | rc = -ENOMEM; | 3828 | rc = -ENOMEM; |
3837 | goto out; | 3829 | goto out; |
3838 | } | 3830 | } |
3839 | memset(fsg->luns, 0, i * sizeof(struct lun)); | ||
3840 | fsg->nluns = i; | 3831 | fsg->nluns = i; |
3841 | 3832 | ||
3842 | for (i = 0; i < fsg->nluns; ++i) { | 3833 | for (i = 0; i < fsg->nluns; ++i) { |
@@ -3959,10 +3950,12 @@ static int __init fsg_bind(struct usb_gadget *gadget) | |||
3959 | sprintf(&serial[i], "%02X", c); | 3950 | sprintf(&serial[i], "%02X", c); |
3960 | } | 3951 | } |
3961 | 3952 | ||
3962 | if ((rc = kernel_thread(fsg_main_thread, fsg, (CLONE_VM | CLONE_FS | | 3953 | fsg->thread_task = kthread_create(fsg_main_thread, fsg, |
3963 | CLONE_FILES))) < 0) | 3954 | "file-storage-gadget"); |
3955 | if (IS_ERR(fsg->thread_task)) { | ||
3956 | rc = PTR_ERR(fsg->thread_task); | ||
3964 | goto out; | 3957 | goto out; |
3965 | fsg->thread_pid = rc; | 3958 | } |
3966 | 3959 | ||
3967 | INFO(fsg, DRIVER_DESC ", version: " DRIVER_VERSION "\n"); | 3960 | INFO(fsg, DRIVER_DESC ", version: " DRIVER_VERSION "\n"); |
3968 | INFO(fsg, "Number of LUNs=%d\n", fsg->nluns); | 3961 | INFO(fsg, "Number of LUNs=%d\n", fsg->nluns); |
@@ -3994,7 +3987,12 @@ static int __init fsg_bind(struct usb_gadget *gadget) | |||
3994 | DBG(fsg, "removable=%d, stall=%d, buflen=%u\n", | 3987 | DBG(fsg, "removable=%d, stall=%d, buflen=%u\n", |
3995 | mod_data.removable, mod_data.can_stall, | 3988 | mod_data.removable, mod_data.can_stall, |
3996 | mod_data.buflen); | 3989 | mod_data.buflen); |
3997 | DBG(fsg, "I/O thread pid: %d\n", fsg->thread_pid); | 3990 | DBG(fsg, "I/O thread pid: %d\n", fsg->thread_task->pid); |
3991 | |||
3992 | set_bit(REGISTERED, &fsg->atomic_bitflags); | ||
3993 | |||
3994 | /* Tell the thread to start working */ | ||
3995 | wake_up_process(fsg->thread_task); | ||
3998 | return 0; | 3996 | return 0; |
3999 | 3997 | ||
4000 | autoconf_fail: | 3998 | autoconf_fail: |
@@ -4046,6 +4044,7 @@ static struct usb_gadget_driver fsg_driver = { | |||
4046 | 4044 | ||
4047 | .driver = { | 4045 | .driver = { |
4048 | .name = (char *) shortname, | 4046 | .name = (char *) shortname, |
4047 | .owner = THIS_MODULE, | ||
4049 | // .release = ... | 4048 | // .release = ... |
4050 | // .suspend = ... | 4049 | // .suspend = ... |
4051 | // .resume = ... | 4050 | // .resume = ... |
@@ -4057,10 +4056,9 @@ static int __init fsg_alloc(void) | |||
4057 | { | 4056 | { |
4058 | struct fsg_dev *fsg; | 4057 | struct fsg_dev *fsg; |
4059 | 4058 | ||
4060 | fsg = kmalloc(sizeof *fsg, GFP_KERNEL); | 4059 | fsg = kzalloc(sizeof *fsg, GFP_KERNEL); |
4061 | if (!fsg) | 4060 | if (!fsg) |
4062 | return -ENOMEM; | 4061 | return -ENOMEM; |
4063 | memset(fsg, 0, sizeof *fsg); | ||
4064 | spin_lock_init(&fsg->lock); | 4062 | spin_lock_init(&fsg->lock); |
4065 | init_rwsem(&fsg->filesem); | 4063 | init_rwsem(&fsg->filesem); |
4066 | init_waitqueue_head(&fsg->thread_wqh); | 4064 | init_waitqueue_head(&fsg->thread_wqh); |
@@ -4086,15 +4084,9 @@ static int __init fsg_init(void) | |||
4086 | if ((rc = fsg_alloc()) != 0) | 4084 | if ((rc = fsg_alloc()) != 0) |
4087 | return rc; | 4085 | return rc; |
4088 | fsg = the_fsg; | 4086 | fsg = the_fsg; |
4089 | if ((rc = usb_gadget_register_driver(&fsg_driver)) != 0) { | 4087 | if ((rc = usb_gadget_register_driver(&fsg_driver)) != 0) |
4090 | fsg_free(fsg); | 4088 | fsg_free(fsg); |
4091 | return rc; | 4089 | return rc; |
4092 | } | ||
4093 | set_bit(REGISTERED, &fsg->atomic_bitflags); | ||
4094 | |||
4095 | /* Tell the thread to start working */ | ||
4096 | complete(&fsg->thread_notifier); | ||
4097 | return 0; | ||
4098 | } | 4090 | } |
4099 | module_init(fsg_init); | 4091 | module_init(fsg_init); |
4100 | 4092 | ||
diff --git a/drivers/usb/gadget/goku_udc.c b/drivers/usb/gadget/goku_udc.c index eaab26f4ed37..b0f3cd63e3b9 100644 --- a/drivers/usb/gadget/goku_udc.c +++ b/drivers/usb/gadget/goku_udc.c | |||
@@ -269,7 +269,7 @@ static int goku_ep_disable(struct usb_ep *_ep) | |||
269 | /*-------------------------------------------------------------------------*/ | 269 | /*-------------------------------------------------------------------------*/ |
270 | 270 | ||
271 | static struct usb_request * | 271 | static struct usb_request * |
272 | goku_alloc_request(struct usb_ep *_ep, unsigned gfp_flags) | 272 | goku_alloc_request(struct usb_ep *_ep, gfp_t gfp_flags) |
273 | { | 273 | { |
274 | struct goku_request *req; | 274 | struct goku_request *req; |
275 | 275 | ||
@@ -327,7 +327,7 @@ goku_free_request(struct usb_ep *_ep, struct usb_request *_req) | |||
327 | */ | 327 | */ |
328 | static void * | 328 | static void * |
329 | goku_alloc_buffer(struct usb_ep *_ep, unsigned bytes, | 329 | goku_alloc_buffer(struct usb_ep *_ep, unsigned bytes, |
330 | dma_addr_t *dma, unsigned gfp_flags) | 330 | dma_addr_t *dma, gfp_t gfp_flags) |
331 | { | 331 | { |
332 | void *retval; | 332 | void *retval; |
333 | struct goku_ep *ep; | 333 | struct goku_ep *ep; |
@@ -789,7 +789,7 @@ finished: | |||
789 | /*-------------------------------------------------------------------------*/ | 789 | /*-------------------------------------------------------------------------*/ |
790 | 790 | ||
791 | static int | 791 | static int |
792 | goku_queue(struct usb_ep *_ep, struct usb_request *_req, unsigned gfp_flags) | 792 | goku_queue(struct usb_ep *_ep, struct usb_request *_req, gfp_t gfp_flags) |
793 | { | 793 | { |
794 | struct goku_request *req; | 794 | struct goku_request *req; |
795 | struct goku_ep *ep; | 795 | struct goku_ep *ep; |
diff --git a/drivers/usb/gadget/lh7a40x_udc.c b/drivers/usb/gadget/lh7a40x_udc.c index 4842577789c9..e02fea5a5433 100644 --- a/drivers/usb/gadget/lh7a40x_udc.c +++ b/drivers/usb/gadget/lh7a40x_udc.c | |||
@@ -21,6 +21,8 @@ | |||
21 | * | 21 | * |
22 | */ | 22 | */ |
23 | 23 | ||
24 | #include <linux/platform_device.h> | ||
25 | |||
24 | #include "lh7a40x_udc.h" | 26 | #include "lh7a40x_udc.h" |
25 | 27 | ||
26 | //#define DEBUG printk | 28 | //#define DEBUG printk |
@@ -71,13 +73,13 @@ static char *state_names[] = { | |||
71 | static int lh7a40x_ep_enable(struct usb_ep *ep, | 73 | static int lh7a40x_ep_enable(struct usb_ep *ep, |
72 | const struct usb_endpoint_descriptor *); | 74 | const struct usb_endpoint_descriptor *); |
73 | static int lh7a40x_ep_disable(struct usb_ep *ep); | 75 | static int lh7a40x_ep_disable(struct usb_ep *ep); |
74 | static struct usb_request *lh7a40x_alloc_request(struct usb_ep *ep, int); | 76 | static struct usb_request *lh7a40x_alloc_request(struct usb_ep *ep, gfp_t); |
75 | static void lh7a40x_free_request(struct usb_ep *ep, struct usb_request *); | 77 | static void lh7a40x_free_request(struct usb_ep *ep, struct usb_request *); |
76 | static void *lh7a40x_alloc_buffer(struct usb_ep *ep, unsigned, dma_addr_t *, | 78 | static void *lh7a40x_alloc_buffer(struct usb_ep *ep, unsigned, dma_addr_t *, |
77 | int); | 79 | gfp_t); |
78 | static void lh7a40x_free_buffer(struct usb_ep *ep, void *, dma_addr_t, | 80 | static void lh7a40x_free_buffer(struct usb_ep *ep, void *, dma_addr_t, |
79 | unsigned); | 81 | unsigned); |
80 | static int lh7a40x_queue(struct usb_ep *ep, struct usb_request *, int); | 82 | static int lh7a40x_queue(struct usb_ep *ep, struct usb_request *, gfp_t); |
81 | static int lh7a40x_dequeue(struct usb_ep *ep, struct usb_request *); | 83 | static int lh7a40x_dequeue(struct usb_ep *ep, struct usb_request *); |
82 | static int lh7a40x_set_halt(struct usb_ep *ep, int); | 84 | static int lh7a40x_set_halt(struct usb_ep *ep, int); |
83 | static int lh7a40x_fifo_status(struct usb_ep *ep); | 85 | static int lh7a40x_fifo_status(struct usb_ep *ep); |
@@ -1106,7 +1108,7 @@ static int lh7a40x_ep_disable(struct usb_ep *_ep) | |||
1106 | } | 1108 | } |
1107 | 1109 | ||
1108 | static struct usb_request *lh7a40x_alloc_request(struct usb_ep *ep, | 1110 | static struct usb_request *lh7a40x_alloc_request(struct usb_ep *ep, |
1109 | unsigned gfp_flags) | 1111 | gfp_t gfp_flags) |
1110 | { | 1112 | { |
1111 | struct lh7a40x_request *req; | 1113 | struct lh7a40x_request *req; |
1112 | 1114 | ||
@@ -1134,7 +1136,7 @@ static void lh7a40x_free_request(struct usb_ep *ep, struct usb_request *_req) | |||
1134 | } | 1136 | } |
1135 | 1137 | ||
1136 | static void *lh7a40x_alloc_buffer(struct usb_ep *ep, unsigned bytes, | 1138 | static void *lh7a40x_alloc_buffer(struct usb_ep *ep, unsigned bytes, |
1137 | dma_addr_t * dma, unsigned gfp_flags) | 1139 | dma_addr_t * dma, gfp_t gfp_flags) |
1138 | { | 1140 | { |
1139 | char *retval; | 1141 | char *retval; |
1140 | 1142 | ||
@@ -1158,7 +1160,7 @@ static void lh7a40x_free_buffer(struct usb_ep *ep, void *buf, dma_addr_t dma, | |||
1158 | * NOTE: Sets INDEX register | 1160 | * NOTE: Sets INDEX register |
1159 | */ | 1161 | */ |
1160 | static int lh7a40x_queue(struct usb_ep *_ep, struct usb_request *_req, | 1162 | static int lh7a40x_queue(struct usb_ep *_ep, struct usb_request *_req, |
1161 | unsigned gfp_flags) | 1163 | gfp_t gfp_flags) |
1162 | { | 1164 | { |
1163 | struct lh7a40x_request *req; | 1165 | struct lh7a40x_request *req; |
1164 | struct lh7a40x_ep *ep; | 1166 | struct lh7a40x_ep *ep; |
@@ -2083,21 +2085,21 @@ static struct lh7a40x_udc memory = { | |||
2083 | /* | 2085 | /* |
2084 | * probe - binds to the platform device | 2086 | * probe - binds to the platform device |
2085 | */ | 2087 | */ |
2086 | static int lh7a40x_udc_probe(struct device *_dev) | 2088 | static int lh7a40x_udc_probe(struct platform_device *pdev) |
2087 | { | 2089 | { |
2088 | struct lh7a40x_udc *dev = &memory; | 2090 | struct lh7a40x_udc *dev = &memory; |
2089 | int retval; | 2091 | int retval; |
2090 | 2092 | ||
2091 | DEBUG("%s: %p\n", __FUNCTION__, _dev); | 2093 | DEBUG("%s: %p\n", __FUNCTION__, pdev); |
2092 | 2094 | ||
2093 | spin_lock_init(&dev->lock); | 2095 | spin_lock_init(&dev->lock); |
2094 | dev->dev = _dev; | 2096 | dev->dev = &pdev->dev; |
2095 | 2097 | ||
2096 | device_initialize(&dev->gadget.dev); | 2098 | device_initialize(&dev->gadget.dev); |
2097 | dev->gadget.dev.parent = _dev; | 2099 | dev->gadget.dev.parent = &pdev->dev; |
2098 | 2100 | ||
2099 | the_controller = dev; | 2101 | the_controller = dev; |
2100 | dev_set_drvdata(_dev, dev); | 2102 | platform_set_drvdata(pdev, dev); |
2101 | 2103 | ||
2102 | udc_disable(dev); | 2104 | udc_disable(dev); |
2103 | udc_reinit(dev); | 2105 | udc_reinit(dev); |
@@ -2117,11 +2119,11 @@ static int lh7a40x_udc_probe(struct device *_dev) | |||
2117 | return retval; | 2119 | return retval; |
2118 | } | 2120 | } |
2119 | 2121 | ||
2120 | static int lh7a40x_udc_remove(struct device *_dev) | 2122 | static int lh7a40x_udc_remove(struct platform_device *pdev) |
2121 | { | 2123 | { |
2122 | struct lh7a40x_udc *dev = _dev->driver_data; | 2124 | struct lh7a40x_udc *dev = platform_get_drvdata(pdev); |
2123 | 2125 | ||
2124 | DEBUG("%s: %p\n", __FUNCTION__, dev); | 2126 | DEBUG("%s: %p\n", __FUNCTION__, pdev); |
2125 | 2127 | ||
2126 | udc_disable(dev); | 2128 | udc_disable(dev); |
2127 | remove_proc_files(); | 2129 | remove_proc_files(); |
@@ -2129,7 +2131,7 @@ static int lh7a40x_udc_remove(struct device *_dev) | |||
2129 | 2131 | ||
2130 | free_irq(IRQ_USBINTR, dev); | 2132 | free_irq(IRQ_USBINTR, dev); |
2131 | 2133 | ||
2132 | dev_set_drvdata(_dev, 0); | 2134 | platform_set_drvdata(pdev, 0); |
2133 | 2135 | ||
2134 | the_controller = 0; | 2136 | the_controller = 0; |
2135 | 2137 | ||
@@ -2138,25 +2140,27 @@ static int lh7a40x_udc_remove(struct device *_dev) | |||
2138 | 2140 | ||
2139 | /*-------------------------------------------------------------------------*/ | 2141 | /*-------------------------------------------------------------------------*/ |
2140 | 2142 | ||
2141 | static struct device_driver udc_driver = { | 2143 | static struct platform_driver udc_driver = { |
2142 | .name = (char *)driver_name, | ||
2143 | .bus = &platform_bus_type, | ||
2144 | .probe = lh7a40x_udc_probe, | 2144 | .probe = lh7a40x_udc_probe, |
2145 | .remove = lh7a40x_udc_remove | 2145 | .remove = lh7a40x_udc_remove |
2146 | /* FIXME power management support */ | 2146 | /* FIXME power management support */ |
2147 | /* .suspend = ... disable UDC */ | 2147 | /* .suspend = ... disable UDC */ |
2148 | /* .resume = ... re-enable UDC */ | 2148 | /* .resume = ... re-enable UDC */ |
2149 | .driver = { | ||
2150 | .name = (char *)driver_name, | ||
2151 | .owner = THIS_MODULE, | ||
2152 | }, | ||
2149 | }; | 2153 | }; |
2150 | 2154 | ||
2151 | static int __init udc_init(void) | 2155 | static int __init udc_init(void) |
2152 | { | 2156 | { |
2153 | DEBUG("%s: %s version %s\n", __FUNCTION__, driver_name, DRIVER_VERSION); | 2157 | DEBUG("%s: %s version %s\n", __FUNCTION__, driver_name, DRIVER_VERSION); |
2154 | return driver_register(&udc_driver); | 2158 | return platform_driver_register(&udc_driver); |
2155 | } | 2159 | } |
2156 | 2160 | ||
2157 | static void __exit udc_exit(void) | 2161 | static void __exit udc_exit(void) |
2158 | { | 2162 | { |
2159 | driver_unregister(&udc_driver); | 2163 | platform_driver_unregister(&udc_driver); |
2160 | } | 2164 | } |
2161 | 2165 | ||
2162 | module_init(udc_init); | 2166 | module_init(udc_init); |
diff --git a/drivers/usb/gadget/lh7a40x_udc.h b/drivers/usb/gadget/lh7a40x_udc.h index 1bb455c045a9..9b2e6f7cbb8b 100644 --- a/drivers/usb/gadget/lh7a40x_udc.h +++ b/drivers/usb/gadget/lh7a40x_udc.h | |||
@@ -29,7 +29,6 @@ | |||
29 | #include <linux/kernel.h> | 29 | #include <linux/kernel.h> |
30 | #include <linux/ioport.h> | 30 | #include <linux/ioport.h> |
31 | #include <linux/types.h> | 31 | #include <linux/types.h> |
32 | #include <linux/version.h> | ||
33 | #include <linux/errno.h> | 32 | #include <linux/errno.h> |
34 | #include <linux/delay.h> | 33 | #include <linux/delay.h> |
35 | #include <linux/sched.h> | 34 | #include <linux/sched.h> |
diff --git a/drivers/usb/gadget/net2280.c b/drivers/usb/gadget/net2280.c index 477fab2e74d1..c32e1f7476da 100644 --- a/drivers/usb/gadget/net2280.c +++ b/drivers/usb/gadget/net2280.c | |||
@@ -376,7 +376,7 @@ static int net2280_disable (struct usb_ep *_ep) | |||
376 | /*-------------------------------------------------------------------------*/ | 376 | /*-------------------------------------------------------------------------*/ |
377 | 377 | ||
378 | static struct usb_request * | 378 | static struct usb_request * |
379 | net2280_alloc_request (struct usb_ep *_ep, unsigned gfp_flags) | 379 | net2280_alloc_request (struct usb_ep *_ep, gfp_t gfp_flags) |
380 | { | 380 | { |
381 | struct net2280_ep *ep; | 381 | struct net2280_ep *ep; |
382 | struct net2280_request *req; | 382 | struct net2280_request *req; |
@@ -463,7 +463,7 @@ net2280_alloc_buffer ( | |||
463 | struct usb_ep *_ep, | 463 | struct usb_ep *_ep, |
464 | unsigned bytes, | 464 | unsigned bytes, |
465 | dma_addr_t *dma, | 465 | dma_addr_t *dma, |
466 | unsigned gfp_flags | 466 | gfp_t gfp_flags |
467 | ) | 467 | ) |
468 | { | 468 | { |
469 | void *retval; | 469 | void *retval; |
@@ -897,7 +897,7 @@ done (struct net2280_ep *ep, struct net2280_request *req, int status) | |||
897 | /*-------------------------------------------------------------------------*/ | 897 | /*-------------------------------------------------------------------------*/ |
898 | 898 | ||
899 | static int | 899 | static int |
900 | net2280_queue (struct usb_ep *_ep, struct usb_request *_req, unsigned gfp_flags) | 900 | net2280_queue (struct usb_ep *_ep, struct usb_request *_req, gfp_t gfp_flags) |
901 | { | 901 | { |
902 | struct net2280_request *req; | 902 | struct net2280_request *req; |
903 | struct net2280_ep *ep; | 903 | struct net2280_ep *ep; |
diff --git a/drivers/usb/gadget/omap_udc.c b/drivers/usb/gadget/omap_udc.c index ff5533e69560..a8972d7c97be 100644 --- a/drivers/usb/gadget/omap_udc.c +++ b/drivers/usb/gadget/omap_udc.c | |||
@@ -38,7 +38,7 @@ | |||
38 | #include <linux/proc_fs.h> | 38 | #include <linux/proc_fs.h> |
39 | #include <linux/mm.h> | 39 | #include <linux/mm.h> |
40 | #include <linux/moduleparam.h> | 40 | #include <linux/moduleparam.h> |
41 | #include <linux/device.h> | 41 | #include <linux/platform_device.h> |
42 | #include <linux/usb_ch9.h> | 42 | #include <linux/usb_ch9.h> |
43 | #include <linux/usb_gadget.h> | 43 | #include <linux/usb_gadget.h> |
44 | #include <linux/usb_otg.h> | 44 | #include <linux/usb_otg.h> |
@@ -269,7 +269,7 @@ static int omap_ep_disable(struct usb_ep *_ep) | |||
269 | /*-------------------------------------------------------------------------*/ | 269 | /*-------------------------------------------------------------------------*/ |
270 | 270 | ||
271 | static struct usb_request * | 271 | static struct usb_request * |
272 | omap_alloc_request(struct usb_ep *ep, unsigned gfp_flags) | 272 | omap_alloc_request(struct usb_ep *ep, gfp_t gfp_flags) |
273 | { | 273 | { |
274 | struct omap_req *req; | 274 | struct omap_req *req; |
275 | 275 | ||
@@ -298,7 +298,7 @@ omap_alloc_buffer( | |||
298 | struct usb_ep *_ep, | 298 | struct usb_ep *_ep, |
299 | unsigned bytes, | 299 | unsigned bytes, |
300 | dma_addr_t *dma, | 300 | dma_addr_t *dma, |
301 | unsigned gfp_flags | 301 | gfp_t gfp_flags |
302 | ) | 302 | ) |
303 | { | 303 | { |
304 | void *retval; | 304 | void *retval; |
@@ -691,7 +691,7 @@ static void next_out_dma(struct omap_ep *ep, struct omap_req *req) | |||
691 | } | 691 | } |
692 | 692 | ||
693 | static void | 693 | static void |
694 | finish_out_dma(struct omap_ep *ep, struct omap_req *req, int status) | 694 | finish_out_dma(struct omap_ep *ep, struct omap_req *req, int status, int one) |
695 | { | 695 | { |
696 | u16 count; | 696 | u16 count; |
697 | 697 | ||
@@ -699,6 +699,8 @@ finish_out_dma(struct omap_ep *ep, struct omap_req *req, int status) | |||
699 | ep->dma_counter = (u16) (req->req.dma + req->req.actual); | 699 | ep->dma_counter = (u16) (req->req.dma + req->req.actual); |
700 | count = dma_dest_len(ep, req->req.dma + req->req.actual); | 700 | count = dma_dest_len(ep, req->req.dma + req->req.actual); |
701 | count += req->req.actual; | 701 | count += req->req.actual; |
702 | if (one) | ||
703 | count--; | ||
702 | if (count <= req->req.length) | 704 | if (count <= req->req.length) |
703 | req->req.actual = count; | 705 | req->req.actual = count; |
704 | 706 | ||
@@ -747,7 +749,7 @@ static void dma_irq(struct omap_udc *udc, u16 irq_src) | |||
747 | if (!list_empty(&ep->queue)) { | 749 | if (!list_empty(&ep->queue)) { |
748 | req = container_of(ep->queue.next, | 750 | req = container_of(ep->queue.next, |
749 | struct omap_req, queue); | 751 | struct omap_req, queue); |
750 | finish_out_dma(ep, req, 0); | 752 | finish_out_dma(ep, req, 0, dman_stat & UDC_DMA_RX_SB); |
751 | } | 753 | } |
752 | UDC_IRQ_SRC_REG = UDC_RXN_EOT; | 754 | UDC_IRQ_SRC_REG = UDC_RXN_EOT; |
753 | 755 | ||
@@ -925,7 +927,7 @@ static void dma_channel_release(struct omap_ep *ep) | |||
925 | while (UDC_RXDMA_CFG_REG & mask) | 927 | while (UDC_RXDMA_CFG_REG & mask) |
926 | udelay(10); | 928 | udelay(10); |
927 | if (req) | 929 | if (req) |
928 | finish_out_dma(ep, req, -ECONNRESET); | 930 | finish_out_dma(ep, req, -ECONNRESET, 0); |
929 | } | 931 | } |
930 | omap_free_dma(ep->lch); | 932 | omap_free_dma(ep->lch); |
931 | ep->dma_channel = 0; | 933 | ep->dma_channel = 0; |
@@ -937,7 +939,7 @@ static void dma_channel_release(struct omap_ep *ep) | |||
937 | /*-------------------------------------------------------------------------*/ | 939 | /*-------------------------------------------------------------------------*/ |
938 | 940 | ||
939 | static int | 941 | static int |
940 | omap_ep_queue(struct usb_ep *_ep, struct usb_request *_req, unsigned gfp_flags) | 942 | omap_ep_queue(struct usb_ep *_ep, struct usb_request *_req, gfp_t gfp_flags) |
941 | { | 943 | { |
942 | struct omap_ep *ep = container_of(_ep, struct omap_ep, ep); | 944 | struct omap_ep *ep = container_of(_ep, struct omap_ep, ep); |
943 | struct omap_req *req = container_of(_req, struct omap_req, req); | 945 | struct omap_req *req = container_of(_req, struct omap_req, req); |
@@ -1786,8 +1788,12 @@ static void devstate_irq(struct omap_udc *udc, u16 irq_src) | |||
1786 | udc->driver->suspend(&udc->gadget); | 1788 | udc->driver->suspend(&udc->gadget); |
1787 | spin_lock(&udc->lock); | 1789 | spin_lock(&udc->lock); |
1788 | } | 1790 | } |
1791 | if (udc->transceiver) | ||
1792 | otg_set_suspend(udc->transceiver, 1); | ||
1789 | } else { | 1793 | } else { |
1790 | VDBG("resume\n"); | 1794 | VDBG("resume\n"); |
1795 | if (udc->transceiver) | ||
1796 | otg_set_suspend(udc->transceiver, 0); | ||
1791 | if (udc->gadget.speed == USB_SPEED_FULL | 1797 | if (udc->gadget.speed == USB_SPEED_FULL |
1792 | && udc->driver->resume) { | 1798 | && udc->driver->resume) { |
1793 | spin_unlock(&udc->lock); | 1799 | spin_unlock(&udc->lock); |
@@ -2701,18 +2707,17 @@ omap_udc_setup(struct platform_device *odev, struct otg_transceiver *xceiv) | |||
2701 | return 0; | 2707 | return 0; |
2702 | } | 2708 | } |
2703 | 2709 | ||
2704 | static int __init omap_udc_probe(struct device *dev) | 2710 | static int __init omap_udc_probe(struct platform_device *pdev) |
2705 | { | 2711 | { |
2706 | struct platform_device *odev = to_platform_device(dev); | ||
2707 | int status = -ENODEV; | 2712 | int status = -ENODEV; |
2708 | int hmc; | 2713 | int hmc; |
2709 | struct otg_transceiver *xceiv = NULL; | 2714 | struct otg_transceiver *xceiv = NULL; |
2710 | const char *type = NULL; | 2715 | const char *type = NULL; |
2711 | struct omap_usb_config *config = dev->platform_data; | 2716 | struct omap_usb_config *config = pdev->dev.platform_data; |
2712 | 2717 | ||
2713 | /* NOTE: "knows" the order of the resources! */ | 2718 | /* NOTE: "knows" the order of the resources! */ |
2714 | if (!request_mem_region(odev->resource[0].start, | 2719 | if (!request_mem_region(pdev->resource[0].start, |
2715 | odev->resource[0].end - odev->resource[0].start + 1, | 2720 | pdev->resource[0].end - pdev->resource[0].start + 1, |
2716 | driver_name)) { | 2721 | driver_name)) { |
2717 | DBG("request_mem_region failed\n"); | 2722 | DBG("request_mem_region failed\n"); |
2718 | return -EBUSY; | 2723 | return -EBUSY; |
@@ -2797,7 +2802,7 @@ bad_on_1710: | |||
2797 | INFO("hmc mode %d, %s transceiver\n", hmc, type); | 2802 | INFO("hmc mode %d, %s transceiver\n", hmc, type); |
2798 | 2803 | ||
2799 | /* a "gadget" abstracts/virtualizes the controller */ | 2804 | /* a "gadget" abstracts/virtualizes the controller */ |
2800 | status = omap_udc_setup(odev, xceiv); | 2805 | status = omap_udc_setup(pdev, xceiv); |
2801 | if (status) { | 2806 | if (status) { |
2802 | goto cleanup0; | 2807 | goto cleanup0; |
2803 | } | 2808 | } |
@@ -2815,28 +2820,28 @@ bad_on_1710: | |||
2815 | udc->clr_halt = UDC_RESET_EP; | 2820 | udc->clr_halt = UDC_RESET_EP; |
2816 | 2821 | ||
2817 | /* USB general purpose IRQ: ep0, state changes, dma, etc */ | 2822 | /* USB general purpose IRQ: ep0, state changes, dma, etc */ |
2818 | status = request_irq(odev->resource[1].start, omap_udc_irq, | 2823 | status = request_irq(pdev->resource[1].start, omap_udc_irq, |
2819 | SA_SAMPLE_RANDOM, driver_name, udc); | 2824 | SA_SAMPLE_RANDOM, driver_name, udc); |
2820 | if (status != 0) { | 2825 | if (status != 0) { |
2821 | ERR( "can't get irq %ld, err %d\n", | 2826 | ERR( "can't get irq %ld, err %d\n", |
2822 | odev->resource[1].start, status); | 2827 | pdev->resource[1].start, status); |
2823 | goto cleanup1; | 2828 | goto cleanup1; |
2824 | } | 2829 | } |
2825 | 2830 | ||
2826 | /* USB "non-iso" IRQ (PIO for all but ep0) */ | 2831 | /* USB "non-iso" IRQ (PIO for all but ep0) */ |
2827 | status = request_irq(odev->resource[2].start, omap_udc_pio_irq, | 2832 | status = request_irq(pdev->resource[2].start, omap_udc_pio_irq, |
2828 | SA_SAMPLE_RANDOM, "omap_udc pio", udc); | 2833 | SA_SAMPLE_RANDOM, "omap_udc pio", udc); |
2829 | if (status != 0) { | 2834 | if (status != 0) { |
2830 | ERR( "can't get irq %ld, err %d\n", | 2835 | ERR( "can't get irq %ld, err %d\n", |
2831 | odev->resource[2].start, status); | 2836 | pdev->resource[2].start, status); |
2832 | goto cleanup2; | 2837 | goto cleanup2; |
2833 | } | 2838 | } |
2834 | #ifdef USE_ISO | 2839 | #ifdef USE_ISO |
2835 | status = request_irq(odev->resource[3].start, omap_udc_iso_irq, | 2840 | status = request_irq(pdev->resource[3].start, omap_udc_iso_irq, |
2836 | SA_INTERRUPT, "omap_udc iso", udc); | 2841 | SA_INTERRUPT, "omap_udc iso", udc); |
2837 | if (status != 0) { | 2842 | if (status != 0) { |
2838 | ERR("can't get irq %ld, err %d\n", | 2843 | ERR("can't get irq %ld, err %d\n", |
2839 | odev->resource[3].start, status); | 2844 | pdev->resource[3].start, status); |
2840 | goto cleanup3; | 2845 | goto cleanup3; |
2841 | } | 2846 | } |
2842 | #endif | 2847 | #endif |
@@ -2847,11 +2852,11 @@ bad_on_1710: | |||
2847 | 2852 | ||
2848 | #ifdef USE_ISO | 2853 | #ifdef USE_ISO |
2849 | cleanup3: | 2854 | cleanup3: |
2850 | free_irq(odev->resource[2].start, udc); | 2855 | free_irq(pdev->resource[2].start, udc); |
2851 | #endif | 2856 | #endif |
2852 | 2857 | ||
2853 | cleanup2: | 2858 | cleanup2: |
2854 | free_irq(odev->resource[1].start, udc); | 2859 | free_irq(pdev->resource[1].start, udc); |
2855 | 2860 | ||
2856 | cleanup1: | 2861 | cleanup1: |
2857 | kfree (udc); | 2862 | kfree (udc); |
@@ -2860,14 +2865,13 @@ cleanup1: | |||
2860 | cleanup0: | 2865 | cleanup0: |
2861 | if (xceiv) | 2866 | if (xceiv) |
2862 | put_device(xceiv->dev); | 2867 | put_device(xceiv->dev); |
2863 | release_mem_region(odev->resource[0].start, | 2868 | release_mem_region(pdev->resource[0].start, |
2864 | odev->resource[0].end - odev->resource[0].start + 1); | 2869 | pdev->resource[0].end - pdev->resource[0].start + 1); |
2865 | return status; | 2870 | return status; |
2866 | } | 2871 | } |
2867 | 2872 | ||
2868 | static int __exit omap_udc_remove(struct device *dev) | 2873 | static int __exit omap_udc_remove(struct platform_device *pdev) |
2869 | { | 2874 | { |
2870 | struct platform_device *odev = to_platform_device(dev); | ||
2871 | DECLARE_COMPLETION(done); | 2875 | DECLARE_COMPLETION(done); |
2872 | 2876 | ||
2873 | if (!udc) | 2877 | if (!udc) |
@@ -2885,13 +2889,13 @@ static int __exit omap_udc_remove(struct device *dev) | |||
2885 | remove_proc_file(); | 2889 | remove_proc_file(); |
2886 | 2890 | ||
2887 | #ifdef USE_ISO | 2891 | #ifdef USE_ISO |
2888 | free_irq(odev->resource[3].start, udc); | 2892 | free_irq(pdev->resource[3].start, udc); |
2889 | #endif | 2893 | #endif |
2890 | free_irq(odev->resource[2].start, udc); | 2894 | free_irq(pdev->resource[2].start, udc); |
2891 | free_irq(odev->resource[1].start, udc); | 2895 | free_irq(pdev->resource[1].start, udc); |
2892 | 2896 | ||
2893 | release_mem_region(odev->resource[0].start, | 2897 | release_mem_region(pdev->resource[0].start, |
2894 | odev->resource[0].end - odev->resource[0].start + 1); | 2898 | pdev->resource[0].end - pdev->resource[0].start + 1); |
2895 | 2899 | ||
2896 | device_unregister(&udc->gadget.dev); | 2900 | device_unregister(&udc->gadget.dev); |
2897 | wait_for_completion(&done); | 2901 | wait_for_completion(&done); |
@@ -2909,12 +2913,10 @@ static int __exit omap_udc_remove(struct device *dev) | |||
2909 | * may involve talking to an external transceiver (e.g. isp1301). | 2913 | * may involve talking to an external transceiver (e.g. isp1301). |
2910 | */ | 2914 | */ |
2911 | 2915 | ||
2912 | static int omap_udc_suspend(struct device *dev, pm_message_t message, u32 level) | 2916 | static int omap_udc_suspend(struct platform_device *dev, pm_message_t message) |
2913 | { | 2917 | { |
2914 | u32 devstat; | 2918 | u32 devstat; |
2915 | 2919 | ||
2916 | if (level != SUSPEND_POWER_DOWN) | ||
2917 | return 0; | ||
2918 | devstat = UDC_DEVSTAT_REG; | 2920 | devstat = UDC_DEVSTAT_REG; |
2919 | 2921 | ||
2920 | /* we're requesting 48 MHz clock if the pullup is enabled | 2922 | /* we're requesting 48 MHz clock if the pullup is enabled |
@@ -2931,11 +2933,8 @@ static int omap_udc_suspend(struct device *dev, pm_message_t message, u32 level) | |||
2931 | return 0; | 2933 | return 0; |
2932 | } | 2934 | } |
2933 | 2935 | ||
2934 | static int omap_udc_resume(struct device *dev, u32 level) | 2936 | static int omap_udc_resume(struct platform_device *dev) |
2935 | { | 2937 | { |
2936 | if (level != RESUME_POWER_ON) | ||
2937 | return 0; | ||
2938 | |||
2939 | DBG("resume + wakeup/SRP\n"); | 2938 | DBG("resume + wakeup/SRP\n"); |
2940 | omap_pullup(&udc->gadget, 1); | 2939 | omap_pullup(&udc->gadget, 1); |
2941 | 2940 | ||
@@ -2946,13 +2945,15 @@ static int omap_udc_resume(struct device *dev, u32 level) | |||
2946 | 2945 | ||
2947 | /*-------------------------------------------------------------------------*/ | 2946 | /*-------------------------------------------------------------------------*/ |
2948 | 2947 | ||
2949 | static struct device_driver udc_driver = { | 2948 | static struct platform_driver udc_driver = { |
2950 | .name = (char *) driver_name, | ||
2951 | .bus = &platform_bus_type, | ||
2952 | .probe = omap_udc_probe, | 2949 | .probe = omap_udc_probe, |
2953 | .remove = __exit_p(omap_udc_remove), | 2950 | .remove = __exit_p(omap_udc_remove), |
2954 | .suspend = omap_udc_suspend, | 2951 | .suspend = omap_udc_suspend, |
2955 | .resume = omap_udc_resume, | 2952 | .resume = omap_udc_resume, |
2953 | .driver = { | ||
2954 | .owner = THIS_MODULE, | ||
2955 | .name = (char *) driver_name, | ||
2956 | }, | ||
2956 | }; | 2957 | }; |
2957 | 2958 | ||
2958 | static int __init udc_init(void) | 2959 | static int __init udc_init(void) |
@@ -2963,13 +2964,13 @@ static int __init udc_init(void) | |||
2963 | #endif | 2964 | #endif |
2964 | "%s\n", driver_desc, | 2965 | "%s\n", driver_desc, |
2965 | use_dma ? " (dma)" : ""); | 2966 | use_dma ? " (dma)" : ""); |
2966 | return driver_register(&udc_driver); | 2967 | return platform_driver_register(&udc_driver); |
2967 | } | 2968 | } |
2968 | module_init(udc_init); | 2969 | module_init(udc_init); |
2969 | 2970 | ||
2970 | static void __exit udc_exit(void) | 2971 | static void __exit udc_exit(void) |
2971 | { | 2972 | { |
2972 | driver_unregister(&udc_driver); | 2973 | platform_driver_unregister(&udc_driver); |
2973 | } | 2974 | } |
2974 | module_exit(udc_exit); | 2975 | module_exit(udc_exit); |
2975 | 2976 | ||
diff --git a/drivers/usb/gadget/pxa2xx_udc.c b/drivers/usb/gadget/pxa2xx_udc.c index 1507738337c4..bb028c5b8952 100644 --- a/drivers/usb/gadget/pxa2xx_udc.c +++ b/drivers/usb/gadget/pxa2xx_udc.c | |||
@@ -32,7 +32,6 @@ | |||
32 | #include <linux/kernel.h> | 32 | #include <linux/kernel.h> |
33 | #include <linux/ioport.h> | 33 | #include <linux/ioport.h> |
34 | #include <linux/types.h> | 34 | #include <linux/types.h> |
35 | #include <linux/version.h> | ||
36 | #include <linux/errno.h> | 35 | #include <linux/errno.h> |
37 | #include <linux/delay.h> | 36 | #include <linux/delay.h> |
38 | #include <linux/sched.h> | 37 | #include <linux/sched.h> |
@@ -43,7 +42,7 @@ | |||
43 | #include <linux/interrupt.h> | 42 | #include <linux/interrupt.h> |
44 | #include <linux/proc_fs.h> | 43 | #include <linux/proc_fs.h> |
45 | #include <linux/mm.h> | 44 | #include <linux/mm.h> |
46 | #include <linux/device.h> | 45 | #include <linux/platform_device.h> |
47 | #include <linux/dma-mapping.h> | 46 | #include <linux/dma-mapping.h> |
48 | 47 | ||
49 | #include <asm/byteorder.h> | 48 | #include <asm/byteorder.h> |
@@ -332,7 +331,7 @@ static int pxa2xx_ep_disable (struct usb_ep *_ep) | |||
332 | * pxa2xx_ep_alloc_request - allocate a request data structure | 331 | * pxa2xx_ep_alloc_request - allocate a request data structure |
333 | */ | 332 | */ |
334 | static struct usb_request * | 333 | static struct usb_request * |
335 | pxa2xx_ep_alloc_request (struct usb_ep *_ep, unsigned gfp_flags) | 334 | pxa2xx_ep_alloc_request (struct usb_ep *_ep, gfp_t gfp_flags) |
336 | { | 335 | { |
337 | struct pxa2xx_request *req; | 336 | struct pxa2xx_request *req; |
338 | 337 | ||
@@ -367,7 +366,7 @@ pxa2xx_ep_free_request (struct usb_ep *_ep, struct usb_request *_req) | |||
367 | */ | 366 | */ |
368 | static void * | 367 | static void * |
369 | pxa2xx_ep_alloc_buffer(struct usb_ep *_ep, unsigned bytes, | 368 | pxa2xx_ep_alloc_buffer(struct usb_ep *_ep, unsigned bytes, |
370 | dma_addr_t *dma, unsigned gfp_flags) | 369 | dma_addr_t *dma, gfp_t gfp_flags) |
371 | { | 370 | { |
372 | char *retval; | 371 | char *retval; |
373 | 372 | ||
@@ -874,7 +873,7 @@ done: | |||
874 | /*-------------------------------------------------------------------------*/ | 873 | /*-------------------------------------------------------------------------*/ |
875 | 874 | ||
876 | static int | 875 | static int |
877 | pxa2xx_ep_queue(struct usb_ep *_ep, struct usb_request *_req, unsigned gfp_flags) | 876 | pxa2xx_ep_queue(struct usb_ep *_ep, struct usb_request *_req, gfp_t gfp_flags) |
878 | { | 877 | { |
879 | struct pxa2xx_request *req; | 878 | struct pxa2xx_request *req; |
880 | struct pxa2xx_ep *ep; | 879 | struct pxa2xx_ep *ep; |
@@ -2433,7 +2432,7 @@ static struct pxa2xx_udc memory = { | |||
2433 | /* | 2432 | /* |
2434 | * probe - binds to the platform device | 2433 | * probe - binds to the platform device |
2435 | */ | 2434 | */ |
2436 | static int __init pxa2xx_udc_probe(struct device *_dev) | 2435 | static int __init pxa2xx_udc_probe(struct platform_device *pdev) |
2437 | { | 2436 | { |
2438 | struct pxa2xx_udc *dev = &memory; | 2437 | struct pxa2xx_udc *dev = &memory; |
2439 | int retval, out_dma = 1; | 2438 | int retval, out_dma = 1; |
@@ -2496,19 +2495,19 @@ static int __init pxa2xx_udc_probe(struct device *_dev) | |||
2496 | #endif | 2495 | #endif |
2497 | 2496 | ||
2498 | /* other non-static parts of init */ | 2497 | /* other non-static parts of init */ |
2499 | dev->dev = _dev; | 2498 | dev->dev = &pdev->dev; |
2500 | dev->mach = _dev->platform_data; | 2499 | dev->mach = pdev->dev.platform_data; |
2501 | 2500 | ||
2502 | init_timer(&dev->timer); | 2501 | init_timer(&dev->timer); |
2503 | dev->timer.function = udc_watchdog; | 2502 | dev->timer.function = udc_watchdog; |
2504 | dev->timer.data = (unsigned long) dev; | 2503 | dev->timer.data = (unsigned long) dev; |
2505 | 2504 | ||
2506 | device_initialize(&dev->gadget.dev); | 2505 | device_initialize(&dev->gadget.dev); |
2507 | dev->gadget.dev.parent = _dev; | 2506 | dev->gadget.dev.parent = &pdev->dev; |
2508 | dev->gadget.dev.dma_mask = _dev->dma_mask; | 2507 | dev->gadget.dev.dma_mask = pdev->dev.dma_mask; |
2509 | 2508 | ||
2510 | the_controller = dev; | 2509 | the_controller = dev; |
2511 | dev_set_drvdata(_dev, dev); | 2510 | platform_set_drvdata(pdev, dev); |
2512 | 2511 | ||
2513 | udc_disable(dev); | 2512 | udc_disable(dev); |
2514 | udc_reinit(dev); | 2513 | udc_reinit(dev); |
@@ -2560,14 +2559,14 @@ lubbock_fail0: | |||
2560 | return 0; | 2559 | return 0; |
2561 | } | 2560 | } |
2562 | 2561 | ||
2563 | static void pxa2xx_udc_shutdown(struct device *_dev) | 2562 | static void pxa2xx_udc_shutdown(struct platform_device *_dev) |
2564 | { | 2563 | { |
2565 | pullup_off(); | 2564 | pullup_off(); |
2566 | } | 2565 | } |
2567 | 2566 | ||
2568 | static int __exit pxa2xx_udc_remove(struct device *_dev) | 2567 | static int __exit pxa2xx_udc_remove(struct platform_device *pdev) |
2569 | { | 2568 | { |
2570 | struct pxa2xx_udc *dev = dev_get_drvdata(_dev); | 2569 | struct pxa2xx_udc *dev = platform_get_drvdata(pdev); |
2571 | 2570 | ||
2572 | udc_disable(dev); | 2571 | udc_disable(dev); |
2573 | remove_proc_files(); | 2572 | remove_proc_files(); |
@@ -2581,7 +2580,7 @@ static int __exit pxa2xx_udc_remove(struct device *_dev) | |||
2581 | free_irq(LUBBOCK_USB_DISC_IRQ, dev); | 2580 | free_irq(LUBBOCK_USB_DISC_IRQ, dev); |
2582 | free_irq(LUBBOCK_USB_IRQ, dev); | 2581 | free_irq(LUBBOCK_USB_IRQ, dev); |
2583 | } | 2582 | } |
2584 | dev_set_drvdata(_dev, NULL); | 2583 | platform_set_drvdata(pdev, NULL); |
2585 | the_controller = NULL; | 2584 | the_controller = NULL; |
2586 | return 0; | 2585 | return 0; |
2587 | } | 2586 | } |
@@ -2602,24 +2601,23 @@ static int __exit pxa2xx_udc_remove(struct device *_dev) | |||
2602 | * VBUS IRQs should probably be ignored so that the PXA device just acts | 2601 | * VBUS IRQs should probably be ignored so that the PXA device just acts |
2603 | * "dead" to USB hosts until system resume. | 2602 | * "dead" to USB hosts until system resume. |
2604 | */ | 2603 | */ |
2605 | static int pxa2xx_udc_suspend(struct device *dev, u32 state, u32 level) | 2604 | static int pxa2xx_udc_suspend(struct platform_device *dev, pm_message_t state) |
2606 | { | 2605 | { |
2607 | struct pxa2xx_udc *udc = dev_get_drvdata(dev); | 2606 | struct pxa2xx_udc *udc = platform_get_drvdata(dev); |
2607 | |||
2608 | if (!udc->mach->udc_command) | ||
2609 | WARN("USB host won't detect disconnect!\n"); | ||
2610 | pullup(udc, 0); | ||
2608 | 2611 | ||
2609 | if (level == SUSPEND_POWER_DOWN) { | ||
2610 | if (!udc->mach->udc_command) | ||
2611 | WARN("USB host won't detect disconnect!\n"); | ||
2612 | pullup(udc, 0); | ||
2613 | } | ||
2614 | return 0; | 2612 | return 0; |
2615 | } | 2613 | } |
2616 | 2614 | ||
2617 | static int pxa2xx_udc_resume(struct device *dev, u32 level) | 2615 | static int pxa2xx_udc_resume(struct platform_device *dev) |
2618 | { | 2616 | { |
2619 | struct pxa2xx_udc *udc = dev_get_drvdata(dev); | 2617 | struct pxa2xx_udc *udc = platform_get_drvdata(dev); |
2618 | |||
2619 | pullup(udc, 1); | ||
2620 | 2620 | ||
2621 | if (level == RESUME_POWER_ON) | ||
2622 | pullup(udc, 1); | ||
2623 | return 0; | 2621 | return 0; |
2624 | } | 2622 | } |
2625 | 2623 | ||
@@ -2630,26 +2628,28 @@ static int pxa2xx_udc_resume(struct device *dev, u32 level) | |||
2630 | 2628 | ||
2631 | /*-------------------------------------------------------------------------*/ | 2629 | /*-------------------------------------------------------------------------*/ |
2632 | 2630 | ||
2633 | static struct device_driver udc_driver = { | 2631 | static struct platform_driver udc_driver = { |
2634 | .name = "pxa2xx-udc", | ||
2635 | .bus = &platform_bus_type, | ||
2636 | .probe = pxa2xx_udc_probe, | 2632 | .probe = pxa2xx_udc_probe, |
2637 | .shutdown = pxa2xx_udc_shutdown, | 2633 | .shutdown = pxa2xx_udc_shutdown, |
2638 | .remove = __exit_p(pxa2xx_udc_remove), | 2634 | .remove = __exit_p(pxa2xx_udc_remove), |
2639 | .suspend = pxa2xx_udc_suspend, | 2635 | .suspend = pxa2xx_udc_suspend, |
2640 | .resume = pxa2xx_udc_resume, | 2636 | .resume = pxa2xx_udc_resume, |
2637 | .driver = { | ||
2638 | .owner = THIS_MODULE, | ||
2639 | .name = "pxa2xx-udc", | ||
2640 | }, | ||
2641 | }; | 2641 | }; |
2642 | 2642 | ||
2643 | static int __init udc_init(void) | 2643 | static int __init udc_init(void) |
2644 | { | 2644 | { |
2645 | printk(KERN_INFO "%s: version %s\n", driver_name, DRIVER_VERSION); | 2645 | printk(KERN_INFO "%s: version %s\n", driver_name, DRIVER_VERSION); |
2646 | return driver_register(&udc_driver); | 2646 | return platform_driver_register(&udc_driver); |
2647 | } | 2647 | } |
2648 | module_init(udc_init); | 2648 | module_init(udc_init); |
2649 | 2649 | ||
2650 | static void __exit udc_exit(void) | 2650 | static void __exit udc_exit(void) |
2651 | { | 2651 | { |
2652 | driver_unregister(&udc_driver); | 2652 | platform_driver_unregister(&udc_driver); |
2653 | } | 2653 | } |
2654 | module_exit(udc_exit); | 2654 | module_exit(udc_exit); |
2655 | 2655 | ||
diff --git a/drivers/usb/gadget/pxa2xx_udc.h b/drivers/usb/gadget/pxa2xx_udc.h index d0bc396a85d5..19a883f7d1b8 100644 --- a/drivers/usb/gadget/pxa2xx_udc.h +++ b/drivers/usb/gadget/pxa2xx_udc.h | |||
@@ -73,7 +73,7 @@ struct pxa2xx_ep { | |||
73 | volatile u32 *reg_ubcr; | 73 | volatile u32 *reg_ubcr; |
74 | volatile u32 *reg_uddr; | 74 | volatile u32 *reg_uddr; |
75 | #ifdef USE_DMA | 75 | #ifdef USE_DMA |
76 | volatile u32 *reg_drcmr; | 76 | volatile u32 *reg_drcmr; |
77 | #define drcmr(n) .reg_drcmr = & DRCMR ## n , | 77 | #define drcmr(n) .reg_drcmr = & DRCMR ## n , |
78 | #else | 78 | #else |
79 | #define drcmr(n) | 79 | #define drcmr(n) |
diff --git a/drivers/usb/gadget/rndis.c b/drivers/usb/gadget/rndis.c index 06b6eba925b5..9689efeb364c 100644 --- a/drivers/usb/gadget/rndis.c +++ b/drivers/usb/gadget/rndis.c | |||
@@ -28,7 +28,6 @@ | |||
28 | #include <linux/moduleparam.h> | 28 | #include <linux/moduleparam.h> |
29 | #include <linux/kernel.h> | 29 | #include <linux/kernel.h> |
30 | #include <linux/errno.h> | 30 | #include <linux/errno.h> |
31 | #include <linux/version.h> | ||
32 | #include <linux/init.h> | 31 | #include <linux/init.h> |
33 | #include <linux/list.h> | 32 | #include <linux/list.h> |
34 | #include <linux/proc_fs.h> | 33 | #include <linux/proc_fs.h> |
diff --git a/drivers/usb/gadget/serial.c b/drivers/usb/gadget/serial.c index c925d9222f53..b35ac6d334f8 100644 --- a/drivers/usb/gadget/serial.c +++ b/drivers/usb/gadget/serial.c | |||
@@ -300,18 +300,18 @@ static int gs_build_config_buf(u8 *buf, enum usb_device_speed speed, | |||
300 | u8 type, unsigned int index, int is_otg); | 300 | u8 type, unsigned int index, int is_otg); |
301 | 301 | ||
302 | static struct usb_request *gs_alloc_req(struct usb_ep *ep, unsigned int len, | 302 | static struct usb_request *gs_alloc_req(struct usb_ep *ep, unsigned int len, |
303 | unsigned kmalloc_flags); | 303 | gfp_t kmalloc_flags); |
304 | static void gs_free_req(struct usb_ep *ep, struct usb_request *req); | 304 | static void gs_free_req(struct usb_ep *ep, struct usb_request *req); |
305 | 305 | ||
306 | static struct gs_req_entry *gs_alloc_req_entry(struct usb_ep *ep, unsigned len, | 306 | static struct gs_req_entry *gs_alloc_req_entry(struct usb_ep *ep, unsigned len, |
307 | unsigned kmalloc_flags); | 307 | gfp_t kmalloc_flags); |
308 | static void gs_free_req_entry(struct usb_ep *ep, struct gs_req_entry *req); | 308 | static void gs_free_req_entry(struct usb_ep *ep, struct gs_req_entry *req); |
309 | 309 | ||
310 | static int gs_alloc_ports(struct gs_dev *dev, unsigned kmalloc_flags); | 310 | static int gs_alloc_ports(struct gs_dev *dev, gfp_t kmalloc_flags); |
311 | static void gs_free_ports(struct gs_dev *dev); | 311 | static void gs_free_ports(struct gs_dev *dev); |
312 | 312 | ||
313 | /* circular buffer */ | 313 | /* circular buffer */ |
314 | static struct gs_buf *gs_buf_alloc(unsigned int size, unsigned kmalloc_flags); | 314 | static struct gs_buf *gs_buf_alloc(unsigned int size, gfp_t kmalloc_flags); |
315 | static void gs_buf_free(struct gs_buf *gb); | 315 | static void gs_buf_free(struct gs_buf *gb); |
316 | static void gs_buf_clear(struct gs_buf *gb); | 316 | static void gs_buf_clear(struct gs_buf *gb); |
317 | static unsigned int gs_buf_data_avail(struct gs_buf *gb); | 317 | static unsigned int gs_buf_data_avail(struct gs_buf *gb); |
@@ -2091,7 +2091,7 @@ static int gs_build_config_buf(u8 *buf, enum usb_device_speed speed, | |||
2091 | * usb_request or NULL if there is an error. | 2091 | * usb_request or NULL if there is an error. |
2092 | */ | 2092 | */ |
2093 | static struct usb_request * | 2093 | static struct usb_request * |
2094 | gs_alloc_req(struct usb_ep *ep, unsigned int len, unsigned kmalloc_flags) | 2094 | gs_alloc_req(struct usb_ep *ep, unsigned int len, gfp_t kmalloc_flags) |
2095 | { | 2095 | { |
2096 | struct usb_request *req; | 2096 | struct usb_request *req; |
2097 | 2097 | ||
@@ -2132,7 +2132,7 @@ static void gs_free_req(struct usb_ep *ep, struct usb_request *req) | |||
2132 | * endpoint, buffer len, and kmalloc flags. | 2132 | * endpoint, buffer len, and kmalloc flags. |
2133 | */ | 2133 | */ |
2134 | static struct gs_req_entry * | 2134 | static struct gs_req_entry * |
2135 | gs_alloc_req_entry(struct usb_ep *ep, unsigned len, unsigned kmalloc_flags) | 2135 | gs_alloc_req_entry(struct usb_ep *ep, unsigned len, gfp_t kmalloc_flags) |
2136 | { | 2136 | { |
2137 | struct gs_req_entry *req; | 2137 | struct gs_req_entry *req; |
2138 | 2138 | ||
@@ -2173,7 +2173,7 @@ static void gs_free_req_entry(struct usb_ep *ep, struct gs_req_entry *req) | |||
2173 | * | 2173 | * |
2174 | * The device lock is normally held when calling this function. | 2174 | * The device lock is normally held when calling this function. |
2175 | */ | 2175 | */ |
2176 | static int gs_alloc_ports(struct gs_dev *dev, unsigned kmalloc_flags) | 2176 | static int gs_alloc_ports(struct gs_dev *dev, gfp_t kmalloc_flags) |
2177 | { | 2177 | { |
2178 | int i; | 2178 | int i; |
2179 | struct gs_port *port; | 2179 | struct gs_port *port; |
@@ -2255,7 +2255,7 @@ static void gs_free_ports(struct gs_dev *dev) | |||
2255 | * | 2255 | * |
2256 | * Allocate a circular buffer and all associated memory. | 2256 | * Allocate a circular buffer and all associated memory. |
2257 | */ | 2257 | */ |
2258 | static struct gs_buf *gs_buf_alloc(unsigned int size, unsigned kmalloc_flags) | 2258 | static struct gs_buf *gs_buf_alloc(unsigned int size, gfp_t kmalloc_flags) |
2259 | { | 2259 | { |
2260 | struct gs_buf *gb; | 2260 | struct gs_buf *gb; |
2261 | 2261 | ||
diff --git a/drivers/usb/gadget/zero.c b/drivers/usb/gadget/zero.c index 6890e773b2a2..6c58636e914b 100644 --- a/drivers/usb/gadget/zero.c +++ b/drivers/usb/gadget/zero.c | |||
@@ -612,7 +612,7 @@ static void source_sink_complete (struct usb_ep *ep, struct usb_request *req) | |||
612 | } | 612 | } |
613 | 613 | ||
614 | static struct usb_request * | 614 | static struct usb_request * |
615 | source_sink_start_ep (struct usb_ep *ep, unsigned gfp_flags) | 615 | source_sink_start_ep (struct usb_ep *ep, gfp_t gfp_flags) |
616 | { | 616 | { |
617 | struct usb_request *req; | 617 | struct usb_request *req; |
618 | int status; | 618 | int status; |
@@ -640,7 +640,7 @@ source_sink_start_ep (struct usb_ep *ep, unsigned gfp_flags) | |||
640 | } | 640 | } |
641 | 641 | ||
642 | static int | 642 | static int |
643 | set_source_sink_config (struct zero_dev *dev, unsigned gfp_flags) | 643 | set_source_sink_config (struct zero_dev *dev, gfp_t gfp_flags) |
644 | { | 644 | { |
645 | int result = 0; | 645 | int result = 0; |
646 | struct usb_ep *ep; | 646 | struct usb_ep *ep; |
@@ -744,7 +744,7 @@ static void loopback_complete (struct usb_ep *ep, struct usb_request *req) | |||
744 | } | 744 | } |
745 | 745 | ||
746 | static int | 746 | static int |
747 | set_loopback_config (struct zero_dev *dev, unsigned gfp_flags) | 747 | set_loopback_config (struct zero_dev *dev, gfp_t gfp_flags) |
748 | { | 748 | { |
749 | int result = 0; | 749 | int result = 0; |
750 | struct usb_ep *ep; | 750 | struct usb_ep *ep; |
@@ -845,7 +845,7 @@ static void zero_reset_config (struct zero_dev *dev) | |||
845 | * by limiting configuration choices (like the pxa2xx). | 845 | * by limiting configuration choices (like the pxa2xx). |
846 | */ | 846 | */ |
847 | static int | 847 | static int |
848 | zero_set_config (struct zero_dev *dev, unsigned number, unsigned gfp_flags) | 848 | zero_set_config (struct zero_dev *dev, unsigned number, gfp_t gfp_flags) |
849 | { | 849 | { |
850 | int result = 0; | 850 | int result = 0; |
851 | struct usb_gadget *gadget = dev->gadget; | 851 | struct usb_gadget *gadget = dev->gadget; |
@@ -1302,6 +1302,7 @@ static struct usb_gadget_driver zero_driver = { | |||
1302 | 1302 | ||
1303 | .driver = { | 1303 | .driver = { |
1304 | .name = (char *) shortname, | 1304 | .name = (char *) shortname, |
1305 | .owner = THIS_MODULE, | ||
1305 | // .shutdown = ... | 1306 | // .shutdown = ... |
1306 | // .suspend = ... | 1307 | // .suspend = ... |
1307 | // .resume = ... | 1308 | // .resume = ... |
diff --git a/drivers/usb/host/Makefile b/drivers/usb/host/Makefile index 350d14fc1cc9..58321d3f314c 100644 --- a/drivers/usb/host/Makefile +++ b/drivers/usb/host/Makefile | |||
@@ -1,8 +1,9 @@ | |||
1 | # | 1 | # |
2 | # Makefile for USB Host Controller Driver | 2 | # Makefile for USB Host Controller Drivers |
3 | # framework and drivers | ||
4 | # | 3 | # |
5 | 4 | ||
5 | obj-$(CONFIG_PCI) += pci-quirks.o | ||
6 | |||
6 | obj-$(CONFIG_USB_EHCI_HCD) += ehci-hcd.o | 7 | obj-$(CONFIG_USB_EHCI_HCD) += ehci-hcd.o |
7 | obj-$(CONFIG_USB_ISP116X_HCD) += isp116x-hcd.o | 8 | obj-$(CONFIG_USB_ISP116X_HCD) += isp116x-hcd.o |
8 | obj-$(CONFIG_USB_OHCI_HCD) += ohci-hcd.o | 9 | obj-$(CONFIG_USB_OHCI_HCD) += ohci-hcd.o |
diff --git a/drivers/usb/host/ehci-hcd.c b/drivers/usb/host/ehci-hcd.c index b948ffd94f45..29f52a44b928 100644 --- a/drivers/usb/host/ehci-hcd.c +++ b/drivers/usb/host/ehci-hcd.c | |||
@@ -182,6 +182,9 @@ static int ehci_halt (struct ehci_hcd *ehci) | |||
182 | { | 182 | { |
183 | u32 temp = readl (&ehci->regs->status); | 183 | u32 temp = readl (&ehci->regs->status); |
184 | 184 | ||
185 | /* disable any irqs left enabled by previous code */ | ||
186 | writel (0, &ehci->regs->intr_enable); | ||
187 | |||
185 | if ((temp & STS_HALT) != 0) | 188 | if ((temp & STS_HALT) != 0) |
186 | return 0; | 189 | return 0; |
187 | 190 | ||
@@ -297,50 +300,17 @@ static void ehci_watchdog (unsigned long param) | |||
297 | spin_unlock_irqrestore (&ehci->lock, flags); | 300 | spin_unlock_irqrestore (&ehci->lock, flags); |
298 | } | 301 | } |
299 | 302 | ||
300 | #ifdef CONFIG_PCI | 303 | /* Reboot notifiers kick in for silicon on any bus (not just pci, etc). |
301 | 304 | * This forcibly disables dma and IRQs, helping kexec and other cases | |
302 | /* EHCI 0.96 (and later) section 5.1 says how to kick BIOS/SMM/... | 305 | * where the next system software may expect clean state. |
303 | * off the controller (maybe it can boot from highspeed USB disks). | ||
304 | */ | 306 | */ |
305 | static int bios_handoff (struct ehci_hcd *ehci, int where, u32 cap) | ||
306 | { | ||
307 | struct pci_dev *pdev = to_pci_dev(ehci_to_hcd(ehci)->self.controller); | ||
308 | |||
309 | /* always say Linux will own the hardware */ | ||
310 | pci_write_config_byte(pdev, where + 3, 1); | ||
311 | |||
312 | /* maybe wait a while for BIOS to respond */ | ||
313 | if (cap & (1 << 16)) { | ||
314 | int msec = 5000; | ||
315 | |||
316 | do { | ||
317 | msleep(10); | ||
318 | msec -= 10; | ||
319 | pci_read_config_dword(pdev, where, &cap); | ||
320 | } while ((cap & (1 << 16)) && msec); | ||
321 | if (cap & (1 << 16)) { | ||
322 | ehci_err(ehci, "BIOS handoff failed (%d, %08x)\n", | ||
323 | where, cap); | ||
324 | // some BIOS versions seem buggy... | ||
325 | // return 1; | ||
326 | ehci_warn (ehci, "continuing after BIOS bug...\n"); | ||
327 | /* disable all SMIs, and clear "BIOS owns" flag */ | ||
328 | pci_write_config_dword(pdev, where + 4, 0); | ||
329 | pci_write_config_byte(pdev, where + 2, 0); | ||
330 | } else | ||
331 | ehci_dbg(ehci, "BIOS handoff succeeded\n"); | ||
332 | } | ||
333 | return 0; | ||
334 | } | ||
335 | |||
336 | #endif | ||
337 | |||
338 | static int | 307 | static int |
339 | ehci_reboot (struct notifier_block *self, unsigned long code, void *null) | 308 | ehci_reboot (struct notifier_block *self, unsigned long code, void *null) |
340 | { | 309 | { |
341 | struct ehci_hcd *ehci; | 310 | struct ehci_hcd *ehci; |
342 | 311 | ||
343 | ehci = container_of (self, struct ehci_hcd, reboot_notifier); | 312 | ehci = container_of (self, struct ehci_hcd, reboot_notifier); |
313 | (void) ehci_halt (ehci); | ||
344 | 314 | ||
345 | /* make BIOS/etc use companion controller during reboot */ | 315 | /* make BIOS/etc use companion controller during reboot */ |
346 | writel (0, &ehci->regs->configured_flag); | 316 | writel (0, &ehci->regs->configured_flag); |
@@ -363,215 +333,117 @@ static void ehci_port_power (struct ehci_hcd *ehci, int is_on) | |||
363 | msleep(20); | 333 | msleep(20); |
364 | } | 334 | } |
365 | 335 | ||
336 | /*-------------------------------------------------------------------------*/ | ||
337 | |||
338 | /* | ||
339 | * ehci_work is called from some interrupts, timers, and so on. | ||
340 | * it calls driver completion functions, after dropping ehci->lock. | ||
341 | */ | ||
342 | static void ehci_work (struct ehci_hcd *ehci, struct pt_regs *regs) | ||
343 | { | ||
344 | timer_action_done (ehci, TIMER_IO_WATCHDOG); | ||
345 | if (ehci->reclaim_ready) | ||
346 | end_unlink_async (ehci, regs); | ||
347 | |||
348 | /* another CPU may drop ehci->lock during a schedule scan while | ||
349 | * it reports urb completions. this flag guards against bogus | ||
350 | * attempts at re-entrant schedule scanning. | ||
351 | */ | ||
352 | if (ehci->scanning) | ||
353 | return; | ||
354 | ehci->scanning = 1; | ||
355 | scan_async (ehci, regs); | ||
356 | if (ehci->next_uframe != -1) | ||
357 | scan_periodic (ehci, regs); | ||
358 | ehci->scanning = 0; | ||
366 | 359 | ||
367 | /* called by khubd or root hub init threads */ | 360 | /* the IO watchdog guards against hardware or driver bugs that |
361 | * misplace IRQs, and should let us run completely without IRQs. | ||
362 | * such lossage has been observed on both VT6202 and VT8235. | ||
363 | */ | ||
364 | if (HC_IS_RUNNING (ehci_to_hcd(ehci)->state) && | ||
365 | (ehci->async->qh_next.ptr != NULL || | ||
366 | ehci->periodic_sched != 0)) | ||
367 | timer_action (ehci, TIMER_IO_WATCHDOG); | ||
368 | } | ||
368 | 369 | ||
369 | static int ehci_hc_reset (struct usb_hcd *hcd) | 370 | static void ehci_stop (struct usb_hcd *hcd) |
370 | { | 371 | { |
371 | struct ehci_hcd *ehci = hcd_to_ehci (hcd); | 372 | struct ehci_hcd *ehci = hcd_to_ehci (hcd); |
372 | u32 temp; | ||
373 | unsigned count = 256/4; | ||
374 | 373 | ||
375 | spin_lock_init (&ehci->lock); | 374 | ehci_dbg (ehci, "stop\n"); |
376 | 375 | ||
377 | ehci->caps = hcd->regs; | 376 | /* Turn off port power on all root hub ports. */ |
378 | ehci->regs = hcd->regs + HC_LENGTH (readl (&ehci->caps->hc_capbase)); | 377 | ehci_port_power (ehci, 0); |
379 | dbg_hcs_params (ehci, "reset"); | ||
380 | dbg_hcc_params (ehci, "reset"); | ||
381 | 378 | ||
382 | /* cache this readonly data; minimize chip reads */ | 379 | /* no more interrupts ... */ |
383 | ehci->hcs_params = readl (&ehci->caps->hcs_params); | 380 | del_timer_sync (&ehci->watchdog); |
384 | 381 | ||
385 | #ifdef CONFIG_PCI | 382 | spin_lock_irq(&ehci->lock); |
386 | if (hcd->self.controller->bus == &pci_bus_type) { | 383 | if (HC_IS_RUNNING (hcd->state)) |
387 | struct pci_dev *pdev = to_pci_dev(hcd->self.controller); | 384 | ehci_quiesce (ehci); |
388 | 385 | ||
389 | switch (pdev->vendor) { | 386 | ehci_reset (ehci); |
390 | case PCI_VENDOR_ID_TDI: | 387 | writel (0, &ehci->regs->intr_enable); |
391 | if (pdev->device == PCI_DEVICE_ID_TDI_EHCI) { | 388 | spin_unlock_irq(&ehci->lock); |
392 | ehci->is_tdi_rh_tt = 1; | ||
393 | tdi_reset (ehci); | ||
394 | } | ||
395 | break; | ||
396 | case PCI_VENDOR_ID_AMD: | ||
397 | /* AMD8111 EHCI doesn't work, according to AMD errata */ | ||
398 | if (pdev->device == 0x7463) { | ||
399 | ehci_info (ehci, "ignoring AMD8111 (errata)\n"); | ||
400 | return -EIO; | ||
401 | } | ||
402 | break; | ||
403 | case PCI_VENDOR_ID_NVIDIA: | ||
404 | /* NVidia reports that certain chips don't handle | ||
405 | * QH, ITD, or SITD addresses above 2GB. (But TD, | ||
406 | * data buffer, and periodic schedule are normal.) | ||
407 | */ | ||
408 | switch (pdev->device) { | ||
409 | case 0x003c: /* MCP04 */ | ||
410 | case 0x005b: /* CK804 */ | ||
411 | case 0x00d8: /* CK8 */ | ||
412 | case 0x00e8: /* CK8S */ | ||
413 | if (pci_set_consistent_dma_mask(pdev, | ||
414 | DMA_31BIT_MASK) < 0) | ||
415 | ehci_warn (ehci, "can't enable NVidia " | ||
416 | "workaround for >2GB RAM\n"); | ||
417 | break; | ||
418 | } | ||
419 | break; | ||
420 | } | ||
421 | 389 | ||
422 | /* optional debug port, normally in the first BAR */ | 390 | /* let companion controllers work when we aren't */ |
423 | temp = pci_find_capability (pdev, 0x0a); | 391 | writel (0, &ehci->regs->configured_flag); |
424 | if (temp) { | 392 | unregister_reboot_notifier (&ehci->reboot_notifier); |
425 | pci_read_config_dword(pdev, temp, &temp); | ||
426 | temp >>= 16; | ||
427 | if ((temp & (3 << 13)) == (1 << 13)) { | ||
428 | temp &= 0x1fff; | ||
429 | ehci->debug = hcd->regs + temp; | ||
430 | temp = readl (&ehci->debug->control); | ||
431 | ehci_info (ehci, "debug port %d%s\n", | ||
432 | HCS_DEBUG_PORT(ehci->hcs_params), | ||
433 | (temp & DBGP_ENABLED) | ||
434 | ? " IN USE" | ||
435 | : ""); | ||
436 | if (!(temp & DBGP_ENABLED)) | ||
437 | ehci->debug = NULL; | ||
438 | } | ||
439 | } | ||
440 | 393 | ||
441 | temp = HCC_EXT_CAPS (readl (&ehci->caps->hcc_params)); | 394 | remove_debug_files (ehci); |
442 | } else | ||
443 | temp = 0; | ||
444 | |||
445 | /* EHCI 0.96 and later may have "extended capabilities" */ | ||
446 | while (temp && count--) { | ||
447 | u32 cap; | ||
448 | |||
449 | pci_read_config_dword (to_pci_dev(hcd->self.controller), | ||
450 | temp, &cap); | ||
451 | ehci_dbg (ehci, "capability %04x at %02x\n", cap, temp); | ||
452 | switch (cap & 0xff) { | ||
453 | case 1: /* BIOS/SMM/... handoff */ | ||
454 | if (bios_handoff (ehci, temp, cap) != 0) | ||
455 | return -EOPNOTSUPP; | ||
456 | break; | ||
457 | case 0: /* illegal reserved capability */ | ||
458 | ehci_warn (ehci, "illegal capability!\n"); | ||
459 | cap = 0; | ||
460 | /* FALLTHROUGH */ | ||
461 | default: /* unknown */ | ||
462 | break; | ||
463 | } | ||
464 | temp = (cap >> 8) & 0xff; | ||
465 | } | ||
466 | if (!count) { | ||
467 | ehci_err (ehci, "bogus capabilities ... PCI problems!\n"); | ||
468 | return -EIO; | ||
469 | } | ||
470 | if (ehci_is_TDI(ehci)) | ||
471 | ehci_reset (ehci); | ||
472 | #endif | ||
473 | 395 | ||
474 | ehci_port_power (ehci, 0); | 396 | /* root hub is shut down separately (first, when possible) */ |
397 | spin_lock_irq (&ehci->lock); | ||
398 | if (ehci->async) | ||
399 | ehci_work (ehci, NULL); | ||
400 | spin_unlock_irq (&ehci->lock); | ||
401 | ehci_mem_cleanup (ehci); | ||
475 | 402 | ||
476 | /* at least the Genesys GL880S needs fixup here */ | 403 | #ifdef EHCI_STATS |
477 | temp = HCS_N_CC(ehci->hcs_params) * HCS_N_PCC(ehci->hcs_params); | 404 | ehci_dbg (ehci, "irq normal %ld err %ld reclaim %ld (lost %ld)\n", |
478 | temp &= 0x0f; | 405 | ehci->stats.normal, ehci->stats.error, ehci->stats.reclaim, |
479 | if (temp && HCS_N_PORTS(ehci->hcs_params) > temp) { | 406 | ehci->stats.lost_iaa); |
480 | ehci_dbg (ehci, "bogus port configuration: " | 407 | ehci_dbg (ehci, "complete %ld unlink %ld\n", |
481 | "cc=%d x pcc=%d < ports=%d\n", | 408 | ehci->stats.complete, ehci->stats.unlink); |
482 | HCS_N_CC(ehci->hcs_params), | ||
483 | HCS_N_PCC(ehci->hcs_params), | ||
484 | HCS_N_PORTS(ehci->hcs_params)); | ||
485 | |||
486 | #ifdef CONFIG_PCI | ||
487 | if (hcd->self.controller->bus == &pci_bus_type) { | ||
488 | struct pci_dev *pdev; | ||
489 | |||
490 | pdev = to_pci_dev(hcd->self.controller); | ||
491 | switch (pdev->vendor) { | ||
492 | case 0x17a0: /* GENESYS */ | ||
493 | /* GL880S: should be PORTS=2 */ | ||
494 | temp |= (ehci->hcs_params & ~0xf); | ||
495 | ehci->hcs_params = temp; | ||
496 | break; | ||
497 | case PCI_VENDOR_ID_NVIDIA: | ||
498 | /* NF4: should be PCC=10 */ | ||
499 | break; | ||
500 | } | ||
501 | } | ||
502 | #endif | 409 | #endif |
503 | } | ||
504 | 410 | ||
505 | /* force HC to halt state */ | 411 | dbg_status (ehci, "ehci_stop completed", readl (&ehci->regs->status)); |
506 | return ehci_halt (ehci); | ||
507 | } | 412 | } |
508 | 413 | ||
509 | static int ehci_start (struct usb_hcd *hcd) | 414 | /* one-time init, only for memory state */ |
415 | static int ehci_init(struct usb_hcd *hcd) | ||
510 | { | 416 | { |
511 | struct ehci_hcd *ehci = hcd_to_ehci (hcd); | 417 | struct ehci_hcd *ehci = hcd_to_ehci(hcd); |
512 | u32 temp; | 418 | u32 temp; |
513 | int retval; | 419 | int retval; |
514 | u32 hcc_params; | 420 | u32 hcc_params; |
515 | u8 sbrn = 0; | 421 | |
516 | int first; | 422 | spin_lock_init(&ehci->lock); |
517 | 423 | ||
518 | /* skip some things on restart paths */ | 424 | init_timer(&ehci->watchdog); |
519 | first = (ehci->watchdog.data == 0); | 425 | ehci->watchdog.function = ehci_watchdog; |
520 | if (first) { | 426 | ehci->watchdog.data = (unsigned long) ehci; |
521 | init_timer (&ehci->watchdog); | ||
522 | ehci->watchdog.function = ehci_watchdog; | ||
523 | ehci->watchdog.data = (unsigned long) ehci; | ||
524 | } | ||
525 | 427 | ||
526 | /* | 428 | /* |
527 | * hw default: 1K periodic list heads, one per frame. | 429 | * hw default: 1K periodic list heads, one per frame. |
528 | * periodic_size can shrink by USBCMD update if hcc_params allows. | 430 | * periodic_size can shrink by USBCMD update if hcc_params allows. |
529 | */ | 431 | */ |
530 | ehci->periodic_size = DEFAULT_I_TDPS; | 432 | ehci->periodic_size = DEFAULT_I_TDPS; |
531 | if (first && (retval = ehci_mem_init (ehci, GFP_KERNEL)) < 0) | 433 | if ((retval = ehci_mem_init(ehci, GFP_KERNEL)) < 0) |
532 | return retval; | 434 | return retval; |
533 | 435 | ||
534 | /* controllers may cache some of the periodic schedule ... */ | 436 | /* controllers may cache some of the periodic schedule ... */ |
535 | hcc_params = readl (&ehci->caps->hcc_params); | 437 | hcc_params = readl(&ehci->caps->hcc_params); |
536 | if (HCC_ISOC_CACHE (hcc_params)) // full frame cache | 438 | if (HCC_ISOC_CACHE(hcc_params)) // full frame cache |
537 | ehci->i_thresh = 8; | 439 | ehci->i_thresh = 8; |
538 | else // N microframes cached | 440 | else // N microframes cached |
539 | ehci->i_thresh = 2 + HCC_ISOC_THRES (hcc_params); | 441 | ehci->i_thresh = 2 + HCC_ISOC_THRES(hcc_params); |
540 | 442 | ||
541 | ehci->reclaim = NULL; | 443 | ehci->reclaim = NULL; |
542 | ehci->reclaim_ready = 0; | 444 | ehci->reclaim_ready = 0; |
543 | ehci->next_uframe = -1; | 445 | ehci->next_uframe = -1; |
544 | 446 | ||
545 | /* controller state: unknown --> reset */ | ||
546 | |||
547 | /* EHCI spec section 4.1 */ | ||
548 | if ((retval = ehci_reset (ehci)) != 0) { | ||
549 | ehci_mem_cleanup (ehci); | ||
550 | return retval; | ||
551 | } | ||
552 | writel (ehci->periodic_dma, &ehci->regs->frame_list); | ||
553 | |||
554 | #ifdef CONFIG_PCI | ||
555 | if (hcd->self.controller->bus == &pci_bus_type) { | ||
556 | struct pci_dev *pdev; | ||
557 | u16 port_wake; | ||
558 | |||
559 | pdev = to_pci_dev(hcd->self.controller); | ||
560 | |||
561 | /* Serial Bus Release Number is at PCI 0x60 offset */ | ||
562 | pci_read_config_byte(pdev, 0x60, &sbrn); | ||
563 | |||
564 | /* port wake capability, reported by boot firmware */ | ||
565 | pci_read_config_word(pdev, 0x62, &port_wake); | ||
566 | hcd->can_wakeup = (port_wake & 1) != 0; | ||
567 | |||
568 | /* help hc dma work well with cachelines */ | ||
569 | retval = pci_set_mwi(pdev); | ||
570 | if (retval) | ||
571 | ehci_dbg(ehci, "unable to enable MWI - not fatal.\n"); | ||
572 | } | ||
573 | #endif | ||
574 | |||
575 | /* | 447 | /* |
576 | * dedicate a qh for the async ring head, since we couldn't unlink | 448 | * dedicate a qh for the async ring head, since we couldn't unlink |
577 | * a 'real' qh without stopping the async schedule [4.8]. use it | 449 | * a 'real' qh without stopping the async schedule [4.8]. use it |
@@ -579,37 +451,13 @@ static int ehci_start (struct usb_hcd *hcd) | |||
579 | * its dummy is used in hw_alt_next of many tds, to prevent the qh | 451 | * its dummy is used in hw_alt_next of many tds, to prevent the qh |
580 | * from automatically advancing to the next td after short reads. | 452 | * from automatically advancing to the next td after short reads. |
581 | */ | 453 | */ |
582 | if (first) { | 454 | ehci->async->qh_next.qh = NULL; |
583 | ehci->async->qh_next.qh = NULL; | 455 | ehci->async->hw_next = QH_NEXT(ehci->async->qh_dma); |
584 | ehci->async->hw_next = QH_NEXT (ehci->async->qh_dma); | 456 | ehci->async->hw_info1 = cpu_to_le32(QH_HEAD); |
585 | ehci->async->hw_info1 = cpu_to_le32 (QH_HEAD); | 457 | ehci->async->hw_token = cpu_to_le32(QTD_STS_HALT); |
586 | ehci->async->hw_token = cpu_to_le32 (QTD_STS_HALT); | 458 | ehci->async->hw_qtd_next = EHCI_LIST_END; |
587 | ehci->async->hw_qtd_next = EHCI_LIST_END; | 459 | ehci->async->qh_state = QH_STATE_LINKED; |
588 | ehci->async->qh_state = QH_STATE_LINKED; | 460 | ehci->async->hw_alt_next = QTD_NEXT(ehci->async->dummy->qtd_dma); |
589 | ehci->async->hw_alt_next = QTD_NEXT (ehci->async->dummy->qtd_dma); | ||
590 | } | ||
591 | writel ((u32)ehci->async->qh_dma, &ehci->regs->async_next); | ||
592 | |||
593 | /* | ||
594 | * hcc_params controls whether ehci->regs->segment must (!!!) | ||
595 | * be used; it constrains QH/ITD/SITD and QTD locations. | ||
596 | * pci_pool consistent memory always uses segment zero. | ||
597 | * streaming mappings for I/O buffers, like pci_map_single(), | ||
598 | * can return segments above 4GB, if the device allows. | ||
599 | * | ||
600 | * NOTE: the dma mask is visible through dma_supported(), so | ||
601 | * drivers can pass this info along ... like NETIF_F_HIGHDMA, | ||
602 | * Scsi_Host.highmem_io, and so forth. It's readonly to all | ||
603 | * host side drivers though. | ||
604 | */ | ||
605 | if (HCC_64BIT_ADDR (hcc_params)) { | ||
606 | writel (0, &ehci->regs->segment); | ||
607 | #if 0 | ||
608 | // this is deeply broken on almost all architectures | ||
609 | if (!dma_set_mask (hcd->self.controller, DMA_64BIT_MASK)) | ||
610 | ehci_info (ehci, "enabled 64bit DMA\n"); | ||
611 | #endif | ||
612 | } | ||
613 | 461 | ||
614 | /* clear interrupt enables, set irq latency */ | 462 | /* clear interrupt enables, set irq latency */ |
615 | if (log2_irq_thresh < 0 || log2_irq_thresh > 6) | 463 | if (log2_irq_thresh < 0 || log2_irq_thresh > 6) |
@@ -624,13 +472,13 @@ static int ehci_start (struct usb_hcd *hcd) | |||
624 | * make problems: throughput reduction (!), data errors... | 472 | * make problems: throughput reduction (!), data errors... |
625 | */ | 473 | */ |
626 | if (park) { | 474 | if (park) { |
627 | park = min (park, (unsigned) 3); | 475 | park = min(park, (unsigned) 3); |
628 | temp |= CMD_PARK; | 476 | temp |= CMD_PARK; |
629 | temp |= park << 8; | 477 | temp |= park << 8; |
630 | } | 478 | } |
631 | ehci_info (ehci, "park %d\n", park); | 479 | ehci_dbg(ehci, "park %d\n", park); |
632 | } | 480 | } |
633 | if (HCC_PGM_FRAMELISTLEN (hcc_params)) { | 481 | if (HCC_PGM_FRAMELISTLEN(hcc_params)) { |
634 | /* periodic schedule size can be smaller than default */ | 482 | /* periodic schedule size can be smaller than default */ |
635 | temp &= ~(3 << 2); | 483 | temp &= ~(3 << 2); |
636 | temp |= (EHCI_TUNE_FLS << 2); | 484 | temp |= (EHCI_TUNE_FLS << 2); |
@@ -638,16 +486,63 @@ static int ehci_start (struct usb_hcd *hcd) | |||
638 | case 0: ehci->periodic_size = 1024; break; | 486 | case 0: ehci->periodic_size = 1024; break; |
639 | case 1: ehci->periodic_size = 512; break; | 487 | case 1: ehci->periodic_size = 512; break; |
640 | case 2: ehci->periodic_size = 256; break; | 488 | case 2: ehci->periodic_size = 256; break; |
641 | default: BUG (); | 489 | default: BUG(); |
642 | } | 490 | } |
643 | } | 491 | } |
492 | ehci->command = temp; | ||
493 | |||
494 | ehci->reboot_notifier.notifier_call = ehci_reboot; | ||
495 | register_reboot_notifier(&ehci->reboot_notifier); | ||
496 | |||
497 | return 0; | ||
498 | } | ||
499 | |||
500 | /* start HC running; it's halted, ehci_init() has been run (once) */ | ||
501 | static int ehci_run (struct usb_hcd *hcd) | ||
502 | { | ||
503 | struct ehci_hcd *ehci = hcd_to_ehci (hcd); | ||
504 | int retval; | ||
505 | u32 temp; | ||
506 | u32 hcc_params; | ||
507 | |||
508 | /* EHCI spec section 4.1 */ | ||
509 | if ((retval = ehci_reset(ehci)) != 0) { | ||
510 | unregister_reboot_notifier(&ehci->reboot_notifier); | ||
511 | ehci_mem_cleanup(ehci); | ||
512 | return retval; | ||
513 | } | ||
514 | writel(ehci->periodic_dma, &ehci->regs->frame_list); | ||
515 | writel((u32)ehci->async->qh_dma, &ehci->regs->async_next); | ||
516 | |||
517 | /* | ||
518 | * hcc_params controls whether ehci->regs->segment must (!!!) | ||
519 | * be used; it constrains QH/ITD/SITD and QTD locations. | ||
520 | * pci_pool consistent memory always uses segment zero. | ||
521 | * streaming mappings for I/O buffers, like pci_map_single(), | ||
522 | * can return segments above 4GB, if the device allows. | ||
523 | * | ||
524 | * NOTE: the dma mask is visible through dma_supported(), so | ||
525 | * drivers can pass this info along ... like NETIF_F_HIGHDMA, | ||
526 | * Scsi_Host.highmem_io, and so forth. It's readonly to all | ||
527 | * host side drivers though. | ||
528 | */ | ||
529 | hcc_params = readl(&ehci->caps->hcc_params); | ||
530 | if (HCC_64BIT_ADDR(hcc_params)) { | ||
531 | writel(0, &ehci->regs->segment); | ||
532 | #if 0 | ||
533 | // this is deeply broken on almost all architectures | ||
534 | if (!dma_set_mask(hcd->self.controller, DMA_64BIT_MASK)) | ||
535 | ehci_info(ehci, "enabled 64bit DMA\n"); | ||
536 | #endif | ||
537 | } | ||
538 | |||
539 | |||
644 | // Philips, Intel, and maybe others need CMD_RUN before the | 540 | // Philips, Intel, and maybe others need CMD_RUN before the |
645 | // root hub will detect new devices (why?); NEC doesn't | 541 | // root hub will detect new devices (why?); NEC doesn't |
646 | temp |= CMD_RUN; | 542 | ehci->command &= ~(CMD_LRESET|CMD_IAAD|CMD_PSE|CMD_ASE|CMD_RESET); |
647 | writel (temp, &ehci->regs->command); | 543 | ehci->command |= CMD_RUN; |
648 | dbg_cmd (ehci, "init", temp); | 544 | writel (ehci->command, &ehci->regs->command); |
649 | 545 | dbg_cmd (ehci, "init", ehci->command); | |
650 | /* set async sleep time = 10 us ... ? */ | ||
651 | 546 | ||
652 | /* | 547 | /* |
653 | * Start, enabling full USB 2.0 functionality ... usb 1.1 devices | 548 | * Start, enabling full USB 2.0 functionality ... usb 1.1 devices |
@@ -655,210 +550,25 @@ static int ehci_start (struct usb_hcd *hcd) | |||
655 | * involved with the root hub. (Except where one is integrated, | 550 | * involved with the root hub. (Except where one is integrated, |
656 | * and there's no companion controller unless maybe for USB OTG.) | 551 | * and there's no companion controller unless maybe for USB OTG.) |
657 | */ | 552 | */ |
658 | if (first) { | ||
659 | ehci->reboot_notifier.notifier_call = ehci_reboot; | ||
660 | register_reboot_notifier (&ehci->reboot_notifier); | ||
661 | } | ||
662 | |||
663 | hcd->state = HC_STATE_RUNNING; | 553 | hcd->state = HC_STATE_RUNNING; |
664 | writel (FLAG_CF, &ehci->regs->configured_flag); | 554 | writel (FLAG_CF, &ehci->regs->configured_flag); |
665 | readl (&ehci->regs->command); /* unblock posted write */ | 555 | readl (&ehci->regs->command); /* unblock posted writes */ |
666 | 556 | ||
667 | temp = HC_VERSION(readl (&ehci->caps->hc_capbase)); | 557 | temp = HC_VERSION(readl (&ehci->caps->hc_capbase)); |
668 | ehci_info (ehci, | 558 | ehci_info (ehci, |
669 | "USB %x.%x %s, EHCI %x.%02x, driver %s\n", | 559 | "USB %x.%x started, EHCI %x.%02x, driver %s\n", |
670 | ((sbrn & 0xf0)>>4), (sbrn & 0x0f), | 560 | ((ehci->sbrn & 0xf0)>>4), (ehci->sbrn & 0x0f), |
671 | first ? "initialized" : "restarted", | ||
672 | temp >> 8, temp & 0xff, DRIVER_VERSION); | 561 | temp >> 8, temp & 0xff, DRIVER_VERSION); |
673 | 562 | ||
674 | writel (INTR_MASK, &ehci->regs->intr_enable); /* Turn On Interrupts */ | 563 | writel (INTR_MASK, &ehci->regs->intr_enable); /* Turn On Interrupts */ |
675 | 564 | ||
676 | if (first) | 565 | /* GRR this is run-once init(), being done every time the HC starts. |
677 | create_debug_files (ehci); | 566 | * So long as they're part of class devices, we can't do it init() |
678 | 567 | * since the class device isn't created that early. | |
679 | return 0; | ||
680 | } | ||
681 | |||
682 | /* always called by thread; normally rmmod */ | ||
683 | |||
684 | static void ehci_stop (struct usb_hcd *hcd) | ||
685 | { | ||
686 | struct ehci_hcd *ehci = hcd_to_ehci (hcd); | ||
687 | |||
688 | ehci_dbg (ehci, "stop\n"); | ||
689 | |||
690 | /* Turn off port power on all root hub ports. */ | ||
691 | ehci_port_power (ehci, 0); | ||
692 | |||
693 | /* no more interrupts ... */ | ||
694 | del_timer_sync (&ehci->watchdog); | ||
695 | |||
696 | spin_lock_irq(&ehci->lock); | ||
697 | if (HC_IS_RUNNING (hcd->state)) | ||
698 | ehci_quiesce (ehci); | ||
699 | |||
700 | ehci_reset (ehci); | ||
701 | writel (0, &ehci->regs->intr_enable); | ||
702 | spin_unlock_irq(&ehci->lock); | ||
703 | |||
704 | /* let companion controllers work when we aren't */ | ||
705 | writel (0, &ehci->regs->configured_flag); | ||
706 | unregister_reboot_notifier (&ehci->reboot_notifier); | ||
707 | |||
708 | remove_debug_files (ehci); | ||
709 | |||
710 | /* root hub is shut down separately (first, when possible) */ | ||
711 | spin_lock_irq (&ehci->lock); | ||
712 | if (ehci->async) | ||
713 | ehci_work (ehci, NULL); | ||
714 | spin_unlock_irq (&ehci->lock); | ||
715 | ehci_mem_cleanup (ehci); | ||
716 | |||
717 | #ifdef EHCI_STATS | ||
718 | ehci_dbg (ehci, "irq normal %ld err %ld reclaim %ld (lost %ld)\n", | ||
719 | ehci->stats.normal, ehci->stats.error, ehci->stats.reclaim, | ||
720 | ehci->stats.lost_iaa); | ||
721 | ehci_dbg (ehci, "complete %ld unlink %ld\n", | ||
722 | ehci->stats.complete, ehci->stats.unlink); | ||
723 | #endif | ||
724 | |||
725 | dbg_status (ehci, "ehci_stop completed", readl (&ehci->regs->status)); | ||
726 | } | ||
727 | |||
728 | static int ehci_get_frame (struct usb_hcd *hcd) | ||
729 | { | ||
730 | struct ehci_hcd *ehci = hcd_to_ehci (hcd); | ||
731 | return (readl (&ehci->regs->frame_index) >> 3) % ehci->periodic_size; | ||
732 | } | ||
733 | |||
734 | /*-------------------------------------------------------------------------*/ | ||
735 | |||
736 | #ifdef CONFIG_PM | ||
737 | |||
738 | /* suspend/resume, section 4.3 */ | ||
739 | |||
740 | /* These routines rely on the bus (pci, platform, etc) | ||
741 | * to handle powerdown and wakeup, and currently also on | ||
742 | * transceivers that don't need any software attention to set up | ||
743 | * the right sort of wakeup. | ||
744 | */ | ||
745 | |||
746 | static int ehci_suspend (struct usb_hcd *hcd, pm_message_t message) | ||
747 | { | ||
748 | struct ehci_hcd *ehci = hcd_to_ehci (hcd); | ||
749 | |||
750 | if (time_before (jiffies, ehci->next_statechange)) | ||
751 | msleep (100); | ||
752 | |||
753 | #ifdef CONFIG_USB_SUSPEND | ||
754 | (void) usb_suspend_device (hcd->self.root_hub, message); | ||
755 | #else | ||
756 | usb_lock_device (hcd->self.root_hub); | ||
757 | (void) ehci_hub_suspend (hcd); | ||
758 | usb_unlock_device (hcd->self.root_hub); | ||
759 | #endif | ||
760 | |||
761 | // save (PCI) FLADJ in case of Vaux power loss | ||
762 | // ... we'd only use it to handle clock skew | ||
763 | |||
764 | return 0; | ||
765 | } | ||
766 | |||
767 | static int ehci_resume (struct usb_hcd *hcd) | ||
768 | { | ||
769 | struct ehci_hcd *ehci = hcd_to_ehci (hcd); | ||
770 | unsigned port; | ||
771 | struct usb_device *root = hcd->self.root_hub; | ||
772 | int retval = -EINVAL; | ||
773 | |||
774 | // maybe restore (PCI) FLADJ | ||
775 | |||
776 | if (time_before (jiffies, ehci->next_statechange)) | ||
777 | msleep (100); | ||
778 | |||
779 | /* If any port is suspended (or owned by the companion), | ||
780 | * we know we can/must resume the HC (and mustn't reset it). | ||
781 | */ | 568 | */ |
782 | for (port = HCS_N_PORTS (ehci->hcs_params); port > 0; ) { | 569 | create_debug_files(ehci); |
783 | u32 status; | ||
784 | port--; | ||
785 | status = readl (&ehci->regs->port_status [port]); | ||
786 | if (!(status & PORT_POWER)) | ||
787 | continue; | ||
788 | if (status & (PORT_SUSPEND | PORT_OWNER)) { | ||
789 | down (&hcd->self.root_hub->serialize); | ||
790 | retval = ehci_hub_resume (hcd); | ||
791 | up (&hcd->self.root_hub->serialize); | ||
792 | break; | ||
793 | } | ||
794 | if (!root->children [port]) | ||
795 | continue; | ||
796 | dbg_port (ehci, __FUNCTION__, port + 1, status); | ||
797 | usb_set_device_state (root->children[port], | ||
798 | USB_STATE_NOTATTACHED); | ||
799 | } | ||
800 | 570 | ||
801 | /* Else reset, to cope with power loss or flush-to-storage | 571 | return 0; |
802 | * style "resume" having activated BIOS during reboot. | ||
803 | */ | ||
804 | if (port == 0) { | ||
805 | (void) ehci_halt (ehci); | ||
806 | (void) ehci_reset (ehci); | ||
807 | (void) ehci_hc_reset (hcd); | ||
808 | |||
809 | /* emptying the schedule aborts any urbs */ | ||
810 | spin_lock_irq (&ehci->lock); | ||
811 | if (ehci->reclaim) | ||
812 | ehci->reclaim_ready = 1; | ||
813 | ehci_work (ehci, NULL); | ||
814 | spin_unlock_irq (&ehci->lock); | ||
815 | |||
816 | /* restart; khubd will disconnect devices */ | ||
817 | retval = ehci_start (hcd); | ||
818 | |||
819 | /* here we "know" root ports should always stay powered; | ||
820 | * but some controllers may lose all power. | ||
821 | */ | ||
822 | ehci_port_power (ehci, 1); | ||
823 | } | ||
824 | |||
825 | return retval; | ||
826 | } | ||
827 | |||
828 | #endif | ||
829 | |||
830 | /*-------------------------------------------------------------------------*/ | ||
831 | |||
832 | /* | ||
833 | * ehci_work is called from some interrupts, timers, and so on. | ||
834 | * it calls driver completion functions, after dropping ehci->lock. | ||
835 | */ | ||
836 | static void ehci_work (struct ehci_hcd *ehci, struct pt_regs *regs) | ||
837 | { | ||
838 | timer_action_done (ehci, TIMER_IO_WATCHDOG); | ||
839 | if (ehci->reclaim_ready) | ||
840 | end_unlink_async (ehci, regs); | ||
841 | |||
842 | /* another CPU may drop ehci->lock during a schedule scan while | ||
843 | * it reports urb completions. this flag guards against bogus | ||
844 | * attempts at re-entrant schedule scanning. | ||
845 | */ | ||
846 | if (ehci->scanning) | ||
847 | return; | ||
848 | ehci->scanning = 1; | ||
849 | scan_async (ehci, regs); | ||
850 | if (ehci->next_uframe != -1) | ||
851 | scan_periodic (ehci, regs); | ||
852 | ehci->scanning = 0; | ||
853 | |||
854 | /* the IO watchdog guards against hardware or driver bugs that | ||
855 | * misplace IRQs, and should let us run completely without IRQs. | ||
856 | * such lossage has been observed on both VT6202 and VT8235. | ||
857 | */ | ||
858 | if (HC_IS_RUNNING (ehci_to_hcd(ehci)->state) && | ||
859 | (ehci->async->qh_next.ptr != NULL || | ||
860 | ehci->periodic_sched != 0)) | ||
861 | timer_action (ehci, TIMER_IO_WATCHDOG); | ||
862 | } | 572 | } |
863 | 573 | ||
864 | /*-------------------------------------------------------------------------*/ | 574 | /*-------------------------------------------------------------------------*/ |
@@ -935,9 +645,8 @@ static irqreturn_t ehci_irq (struct usb_hcd *hcd, struct pt_regs *regs) | |||
935 | * stop that signaling. | 645 | * stop that signaling. |
936 | */ | 646 | */ |
937 | ehci->reset_done [i] = jiffies + msecs_to_jiffies (20); | 647 | ehci->reset_done [i] = jiffies + msecs_to_jiffies (20); |
938 | mod_timer (&hcd->rh_timer, | ||
939 | ehci->reset_done [i] + 1); | ||
940 | ehci_dbg (ehci, "port %d remote wakeup\n", i + 1); | 648 | ehci_dbg (ehci, "port %d remote wakeup\n", i + 1); |
649 | usb_hcd_resume_root_hub(hcd); | ||
941 | } | 650 | } |
942 | } | 651 | } |
943 | 652 | ||
@@ -983,7 +692,7 @@ static int ehci_urb_enqueue ( | |||
983 | struct usb_hcd *hcd, | 692 | struct usb_hcd *hcd, |
984 | struct usb_host_endpoint *ep, | 693 | struct usb_host_endpoint *ep, |
985 | struct urb *urb, | 694 | struct urb *urb, |
986 | unsigned mem_flags | 695 | gfp_t mem_flags |
987 | ) { | 696 | ) { |
988 | struct ehci_hcd *ehci = hcd_to_ehci (hcd); | 697 | struct ehci_hcd *ehci = hcd_to_ehci (hcd); |
989 | struct list_head qtd_list; | 698 | struct list_head qtd_list; |
@@ -1171,106 +880,24 @@ done: | |||
1171 | return; | 880 | return; |
1172 | } | 881 | } |
1173 | 882 | ||
1174 | /*-------------------------------------------------------------------------*/ | 883 | static int ehci_get_frame (struct usb_hcd *hcd) |
1175 | 884 | { | |
1176 | static const struct hc_driver ehci_driver = { | 885 | struct ehci_hcd *ehci = hcd_to_ehci (hcd); |
1177 | .description = hcd_name, | 886 | return (readl (&ehci->regs->frame_index) >> 3) % ehci->periodic_size; |
1178 | .product_desc = "EHCI Host Controller", | 887 | } |
1179 | .hcd_priv_size = sizeof(struct ehci_hcd), | ||
1180 | |||
1181 | /* | ||
1182 | * generic hardware linkage | ||
1183 | */ | ||
1184 | .irq = ehci_irq, | ||
1185 | .flags = HCD_MEMORY | HCD_USB2, | ||
1186 | |||
1187 | /* | ||
1188 | * basic lifecycle operations | ||
1189 | */ | ||
1190 | .reset = ehci_hc_reset, | ||
1191 | .start = ehci_start, | ||
1192 | #ifdef CONFIG_PM | ||
1193 | .suspend = ehci_suspend, | ||
1194 | .resume = ehci_resume, | ||
1195 | #endif | ||
1196 | .stop = ehci_stop, | ||
1197 | |||
1198 | /* | ||
1199 | * managing i/o requests and associated device resources | ||
1200 | */ | ||
1201 | .urb_enqueue = ehci_urb_enqueue, | ||
1202 | .urb_dequeue = ehci_urb_dequeue, | ||
1203 | .endpoint_disable = ehci_endpoint_disable, | ||
1204 | |||
1205 | /* | ||
1206 | * scheduling support | ||
1207 | */ | ||
1208 | .get_frame_number = ehci_get_frame, | ||
1209 | |||
1210 | /* | ||
1211 | * root hub support | ||
1212 | */ | ||
1213 | .hub_status_data = ehci_hub_status_data, | ||
1214 | .hub_control = ehci_hub_control, | ||
1215 | .hub_suspend = ehci_hub_suspend, | ||
1216 | .hub_resume = ehci_hub_resume, | ||
1217 | }; | ||
1218 | 888 | ||
1219 | /*-------------------------------------------------------------------------*/ | 889 | /*-------------------------------------------------------------------------*/ |
1220 | 890 | ||
1221 | /* EHCI 1.0 doesn't require PCI */ | ||
1222 | |||
1223 | #ifdef CONFIG_PCI | ||
1224 | |||
1225 | /* PCI driver selection metadata; PCI hotplugging uses this */ | ||
1226 | static const struct pci_device_id pci_ids [] = { { | ||
1227 | /* handle any USB 2.0 EHCI controller */ | ||
1228 | PCI_DEVICE_CLASS(((PCI_CLASS_SERIAL_USB << 8) | 0x20), ~0), | ||
1229 | .driver_data = (unsigned long) &ehci_driver, | ||
1230 | }, | ||
1231 | { /* end: all zeroes */ } | ||
1232 | }; | ||
1233 | MODULE_DEVICE_TABLE (pci, pci_ids); | ||
1234 | |||
1235 | /* pci driver glue; this is a "new style" PCI driver module */ | ||
1236 | static struct pci_driver ehci_pci_driver = { | ||
1237 | .name = (char *) hcd_name, | ||
1238 | .id_table = pci_ids, | ||
1239 | |||
1240 | .probe = usb_hcd_pci_probe, | ||
1241 | .remove = usb_hcd_pci_remove, | ||
1242 | |||
1243 | #ifdef CONFIG_PM | ||
1244 | .suspend = usb_hcd_pci_suspend, | ||
1245 | .resume = usb_hcd_pci_resume, | ||
1246 | #endif | ||
1247 | }; | ||
1248 | |||
1249 | #endif /* PCI */ | ||
1250 | |||
1251 | |||
1252 | #define DRIVER_INFO DRIVER_VERSION " " DRIVER_DESC | 891 | #define DRIVER_INFO DRIVER_VERSION " " DRIVER_DESC |
1253 | 892 | ||
1254 | MODULE_DESCRIPTION (DRIVER_INFO); | 893 | MODULE_DESCRIPTION (DRIVER_INFO); |
1255 | MODULE_AUTHOR (DRIVER_AUTHOR); | 894 | MODULE_AUTHOR (DRIVER_AUTHOR); |
1256 | MODULE_LICENSE ("GPL"); | 895 | MODULE_LICENSE ("GPL"); |
1257 | 896 | ||
1258 | static int __init init (void) | 897 | #ifdef CONFIG_PCI |
1259 | { | 898 | #include "ehci-pci.c" |
1260 | if (usb_disabled()) | 899 | #endif |
1261 | return -ENODEV; | ||
1262 | |||
1263 | pr_debug ("%s: block sizes: qh %Zd qtd %Zd itd %Zd sitd %Zd\n", | ||
1264 | hcd_name, | ||
1265 | sizeof (struct ehci_qh), sizeof (struct ehci_qtd), | ||
1266 | sizeof (struct ehci_itd), sizeof (struct ehci_sitd)); | ||
1267 | |||
1268 | return pci_register_driver (&ehci_pci_driver); | ||
1269 | } | ||
1270 | module_init (init); | ||
1271 | 900 | ||
1272 | static void __exit cleanup (void) | 901 | #if !defined(CONFIG_PCI) |
1273 | { | 902 | #error "missing bus glue for ehci-hcd" |
1274 | pci_unregister_driver (&ehci_pci_driver); | 903 | #endif |
1275 | } | ||
1276 | module_exit (cleanup); | ||
diff --git a/drivers/usb/host/ehci-hub.c b/drivers/usb/host/ehci-hub.c index 18d3f2270316..82caf336e9b6 100644 --- a/drivers/usb/host/ehci-hub.c +++ b/drivers/usb/host/ehci-hub.c | |||
@@ -30,7 +30,7 @@ | |||
30 | 30 | ||
31 | #ifdef CONFIG_PM | 31 | #ifdef CONFIG_PM |
32 | 32 | ||
33 | static int ehci_hub_suspend (struct usb_hcd *hcd) | 33 | static int ehci_bus_suspend (struct usb_hcd *hcd) |
34 | { | 34 | { |
35 | struct ehci_hcd *ehci = hcd_to_ehci (hcd); | 35 | struct ehci_hcd *ehci = hcd_to_ehci (hcd); |
36 | int port; | 36 | int port; |
@@ -83,7 +83,7 @@ static int ehci_hub_suspend (struct usb_hcd *hcd) | |||
83 | 83 | ||
84 | 84 | ||
85 | /* caller has locked the root hub, and should reset/reinit on error */ | 85 | /* caller has locked the root hub, and should reset/reinit on error */ |
86 | static int ehci_hub_resume (struct usb_hcd *hcd) | 86 | static int ehci_bus_resume (struct usb_hcd *hcd) |
87 | { | 87 | { |
88 | struct ehci_hcd *ehci = hcd_to_ehci (hcd); | 88 | struct ehci_hcd *ehci = hcd_to_ehci (hcd); |
89 | u32 temp; | 89 | u32 temp; |
@@ -94,6 +94,13 @@ static int ehci_hub_resume (struct usb_hcd *hcd) | |||
94 | msleep(5); | 94 | msleep(5); |
95 | spin_lock_irq (&ehci->lock); | 95 | spin_lock_irq (&ehci->lock); |
96 | 96 | ||
97 | /* Ideally and we've got a real resume here, and no port's power | ||
98 | * was lost. (For PCI, that means Vaux was maintained.) But we | ||
99 | * could instead be restoring a swsusp snapshot -- so that BIOS was | ||
100 | * the last user of the controller, not reset/pm hardware keeping | ||
101 | * state we gave to it. | ||
102 | */ | ||
103 | |||
97 | /* re-init operational registers in case we lost power */ | 104 | /* re-init operational registers in case we lost power */ |
98 | if (readl (&ehci->regs->intr_enable) == 0) { | 105 | if (readl (&ehci->regs->intr_enable) == 0) { |
99 | /* at least some APM implementations will try to deliver | 106 | /* at least some APM implementations will try to deliver |
@@ -159,8 +166,8 @@ static int ehci_hub_resume (struct usb_hcd *hcd) | |||
159 | 166 | ||
160 | #else | 167 | #else |
161 | 168 | ||
162 | #define ehci_hub_suspend NULL | 169 | #define ehci_bus_suspend NULL |
163 | #define ehci_hub_resume NULL | 170 | #define ehci_bus_resume NULL |
164 | 171 | ||
165 | #endif /* CONFIG_PM */ | 172 | #endif /* CONFIG_PM */ |
166 | 173 | ||
diff --git a/drivers/usb/host/ehci-mem.c b/drivers/usb/host/ehci-mem.c index 5c38ad869485..91c2ab43cbcc 100644 --- a/drivers/usb/host/ehci-mem.c +++ b/drivers/usb/host/ehci-mem.c | |||
@@ -45,7 +45,7 @@ static inline void ehci_qtd_init (struct ehci_qtd *qtd, dma_addr_t dma) | |||
45 | INIT_LIST_HEAD (&qtd->qtd_list); | 45 | INIT_LIST_HEAD (&qtd->qtd_list); |
46 | } | 46 | } |
47 | 47 | ||
48 | static struct ehci_qtd *ehci_qtd_alloc (struct ehci_hcd *ehci, int flags) | 48 | static struct ehci_qtd *ehci_qtd_alloc (struct ehci_hcd *ehci, gfp_t flags) |
49 | { | 49 | { |
50 | struct ehci_qtd *qtd; | 50 | struct ehci_qtd *qtd; |
51 | dma_addr_t dma; | 51 | dma_addr_t dma; |
@@ -79,7 +79,7 @@ static void qh_destroy (struct kref *kref) | |||
79 | dma_pool_free (ehci->qh_pool, qh, qh->qh_dma); | 79 | dma_pool_free (ehci->qh_pool, qh, qh->qh_dma); |
80 | } | 80 | } |
81 | 81 | ||
82 | static struct ehci_qh *ehci_qh_alloc (struct ehci_hcd *ehci, int flags) | 82 | static struct ehci_qh *ehci_qh_alloc (struct ehci_hcd *ehci, gfp_t flags) |
83 | { | 83 | { |
84 | struct ehci_qh *qh; | 84 | struct ehci_qh *qh; |
85 | dma_addr_t dma; | 85 | dma_addr_t dma; |
@@ -161,7 +161,7 @@ static void ehci_mem_cleanup (struct ehci_hcd *ehci) | |||
161 | } | 161 | } |
162 | 162 | ||
163 | /* remember to add cleanup code (above) if you add anything here */ | 163 | /* remember to add cleanup code (above) if you add anything here */ |
164 | static int ehci_mem_init (struct ehci_hcd *ehci, int flags) | 164 | static int ehci_mem_init (struct ehci_hcd *ehci, gfp_t flags) |
165 | { | 165 | { |
166 | int i; | 166 | int i; |
167 | 167 | ||
diff --git a/drivers/usb/host/ehci-pci.c b/drivers/usb/host/ehci-pci.c new file mode 100644 index 000000000000..13f73a836e45 --- /dev/null +++ b/drivers/usb/host/ehci-pci.c | |||
@@ -0,0 +1,425 @@ | |||
1 | /* | ||
2 | * EHCI HCD (Host Controller Driver) PCI Bus Glue. | ||
3 | * | ||
4 | * Copyright (c) 2000-2004 by David Brownell | ||
5 | * | ||
6 | * This program is free software; you can redistribute it and/or modify it | ||
7 | * under the terms of the GNU General Public License as published by the | ||
8 | * Free Software Foundation; either version 2 of the License, or (at your | ||
9 | * option) any later version. | ||
10 | * | ||
11 | * This program is distributed in the hope that it will be useful, but | ||
12 | * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY | ||
13 | * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License | ||
14 | * for more details. | ||
15 | * | ||
16 | * You should have received a copy of the GNU General Public License | ||
17 | * along with this program; if not, write to the Free Software Foundation, | ||
18 | * Inc., 675 Mass Ave, Cambridge, MA 02139, USA. | ||
19 | */ | ||
20 | |||
21 | #ifndef CONFIG_PCI | ||
22 | #error "This file is PCI bus glue. CONFIG_PCI must be defined." | ||
23 | #endif | ||
24 | |||
25 | /*-------------------------------------------------------------------------*/ | ||
26 | |||
27 | /* EHCI 0.96 (and later) section 5.1 says how to kick BIOS/SMM/... | ||
28 | * off the controller (maybe it can boot from highspeed USB disks). | ||
29 | */ | ||
30 | static int bios_handoff(struct ehci_hcd *ehci, int where, u32 cap) | ||
31 | { | ||
32 | struct pci_dev *pdev = to_pci_dev(ehci_to_hcd(ehci)->self.controller); | ||
33 | |||
34 | /* always say Linux will own the hardware */ | ||
35 | pci_write_config_byte(pdev, where + 3, 1); | ||
36 | |||
37 | /* maybe wait a while for BIOS to respond */ | ||
38 | if (cap & (1 << 16)) { | ||
39 | int msec = 5000; | ||
40 | |||
41 | do { | ||
42 | msleep(10); | ||
43 | msec -= 10; | ||
44 | pci_read_config_dword(pdev, where, &cap); | ||
45 | } while ((cap & (1 << 16)) && msec); | ||
46 | if (cap & (1 << 16)) { | ||
47 | ehci_err(ehci, "BIOS handoff failed (%d, %08x)\n", | ||
48 | where, cap); | ||
49 | // some BIOS versions seem buggy... | ||
50 | // return 1; | ||
51 | ehci_warn(ehci, "continuing after BIOS bug...\n"); | ||
52 | /* disable all SMIs, and clear "BIOS owns" flag */ | ||
53 | pci_write_config_dword(pdev, where + 4, 0); | ||
54 | pci_write_config_byte(pdev, where + 2, 0); | ||
55 | } else | ||
56 | ehci_dbg(ehci, "BIOS handoff succeeded\n"); | ||
57 | } | ||
58 | return 0; | ||
59 | } | ||
60 | |||
61 | /* called after powerup, by probe or system-pm "wakeup" */ | ||
62 | static int ehci_pci_reinit(struct ehci_hcd *ehci, struct pci_dev *pdev) | ||
63 | { | ||
64 | u32 temp; | ||
65 | int retval; | ||
66 | unsigned count = 256/4; | ||
67 | |||
68 | /* optional debug port, normally in the first BAR */ | ||
69 | temp = pci_find_capability(pdev, 0x0a); | ||
70 | if (temp) { | ||
71 | pci_read_config_dword(pdev, temp, &temp); | ||
72 | temp >>= 16; | ||
73 | if ((temp & (3 << 13)) == (1 << 13)) { | ||
74 | temp &= 0x1fff; | ||
75 | ehci->debug = ehci_to_hcd(ehci)->regs + temp; | ||
76 | temp = readl(&ehci->debug->control); | ||
77 | ehci_info(ehci, "debug port %d%s\n", | ||
78 | HCS_DEBUG_PORT(ehci->hcs_params), | ||
79 | (temp & DBGP_ENABLED) | ||
80 | ? " IN USE" | ||
81 | : ""); | ||
82 | if (!(temp & DBGP_ENABLED)) | ||
83 | ehci->debug = NULL; | ||
84 | } | ||
85 | } | ||
86 | |||
87 | temp = HCC_EXT_CAPS(readl(&ehci->caps->hcc_params)); | ||
88 | |||
89 | /* EHCI 0.96 and later may have "extended capabilities" */ | ||
90 | while (temp && count--) { | ||
91 | u32 cap; | ||
92 | |||
93 | pci_read_config_dword(pdev, temp, &cap); | ||
94 | ehci_dbg(ehci, "capability %04x at %02x\n", cap, temp); | ||
95 | switch (cap & 0xff) { | ||
96 | case 1: /* BIOS/SMM/... handoff */ | ||
97 | if (bios_handoff(ehci, temp, cap) != 0) | ||
98 | return -EOPNOTSUPP; | ||
99 | break; | ||
100 | case 0: /* illegal reserved capability */ | ||
101 | ehci_dbg(ehci, "illegal capability!\n"); | ||
102 | cap = 0; | ||
103 | /* FALLTHROUGH */ | ||
104 | default: /* unknown */ | ||
105 | break; | ||
106 | } | ||
107 | temp = (cap >> 8) & 0xff; | ||
108 | } | ||
109 | if (!count) { | ||
110 | ehci_err(ehci, "bogus capabilities ... PCI problems!\n"); | ||
111 | return -EIO; | ||
112 | } | ||
113 | |||
114 | /* PCI Memory-Write-Invalidate cycle support is optional (uncommon) */ | ||
115 | retval = pci_set_mwi(pdev); | ||
116 | if (!retval) | ||
117 | ehci_dbg(ehci, "MWI active\n"); | ||
118 | |||
119 | ehci_port_power(ehci, 0); | ||
120 | |||
121 | return 0; | ||
122 | } | ||
123 | |||
124 | /* called during probe() after chip reset completes */ | ||
125 | static int ehci_pci_setup(struct usb_hcd *hcd) | ||
126 | { | ||
127 | struct ehci_hcd *ehci = hcd_to_ehci(hcd); | ||
128 | struct pci_dev *pdev = to_pci_dev(hcd->self.controller); | ||
129 | u32 temp; | ||
130 | int retval; | ||
131 | |||
132 | ehci->caps = hcd->regs; | ||
133 | ehci->regs = hcd->regs + HC_LENGTH(readl(&ehci->caps->hc_capbase)); | ||
134 | dbg_hcs_params(ehci, "reset"); | ||
135 | dbg_hcc_params(ehci, "reset"); | ||
136 | |||
137 | /* cache this readonly data; minimize chip reads */ | ||
138 | ehci->hcs_params = readl(&ehci->caps->hcs_params); | ||
139 | |||
140 | retval = ehci_halt(ehci); | ||
141 | if (retval) | ||
142 | return retval; | ||
143 | |||
144 | /* data structure init */ | ||
145 | retval = ehci_init(hcd); | ||
146 | if (retval) | ||
147 | return retval; | ||
148 | |||
149 | /* NOTE: only the parts below this line are PCI-specific */ | ||
150 | |||
151 | switch (pdev->vendor) { | ||
152 | case PCI_VENDOR_ID_TDI: | ||
153 | if (pdev->device == PCI_DEVICE_ID_TDI_EHCI) { | ||
154 | ehci->is_tdi_rh_tt = 1; | ||
155 | tdi_reset(ehci); | ||
156 | } | ||
157 | break; | ||
158 | case PCI_VENDOR_ID_AMD: | ||
159 | /* AMD8111 EHCI doesn't work, according to AMD errata */ | ||
160 | if (pdev->device == 0x7463) { | ||
161 | ehci_info(ehci, "ignoring AMD8111 (errata)\n"); | ||
162 | retval = -EIO; | ||
163 | goto done; | ||
164 | } | ||
165 | break; | ||
166 | case PCI_VENDOR_ID_NVIDIA: | ||
167 | /* NVidia reports that certain chips don't handle | ||
168 | * QH, ITD, or SITD addresses above 2GB. (But TD, | ||
169 | * data buffer, and periodic schedule are normal.) | ||
170 | */ | ||
171 | switch (pdev->device) { | ||
172 | case 0x003c: /* MCP04 */ | ||
173 | case 0x005b: /* CK804 */ | ||
174 | case 0x00d8: /* CK8 */ | ||
175 | case 0x00e8: /* CK8S */ | ||
176 | if (pci_set_consistent_dma_mask(pdev, | ||
177 | DMA_31BIT_MASK) < 0) | ||
178 | ehci_warn(ehci, "can't enable NVidia " | ||
179 | "workaround for >2GB RAM\n"); | ||
180 | break; | ||
181 | } | ||
182 | break; | ||
183 | } | ||
184 | |||
185 | if (ehci_is_TDI(ehci)) | ||
186 | ehci_reset(ehci); | ||
187 | |||
188 | /* at least the Genesys GL880S needs fixup here */ | ||
189 | temp = HCS_N_CC(ehci->hcs_params) * HCS_N_PCC(ehci->hcs_params); | ||
190 | temp &= 0x0f; | ||
191 | if (temp && HCS_N_PORTS(ehci->hcs_params) > temp) { | ||
192 | ehci_dbg(ehci, "bogus port configuration: " | ||
193 | "cc=%d x pcc=%d < ports=%d\n", | ||
194 | HCS_N_CC(ehci->hcs_params), | ||
195 | HCS_N_PCC(ehci->hcs_params), | ||
196 | HCS_N_PORTS(ehci->hcs_params)); | ||
197 | |||
198 | switch (pdev->vendor) { | ||
199 | case 0x17a0: /* GENESYS */ | ||
200 | /* GL880S: should be PORTS=2 */ | ||
201 | temp |= (ehci->hcs_params & ~0xf); | ||
202 | ehci->hcs_params = temp; | ||
203 | break; | ||
204 | case PCI_VENDOR_ID_NVIDIA: | ||
205 | /* NF4: should be PCC=10 */ | ||
206 | break; | ||
207 | } | ||
208 | } | ||
209 | |||
210 | /* Serial Bus Release Number is at PCI 0x60 offset */ | ||
211 | pci_read_config_byte(pdev, 0x60, &ehci->sbrn); | ||
212 | |||
213 | /* REVISIT: per-port wake capability (PCI 0x62) currently unused */ | ||
214 | |||
215 | retval = ehci_pci_reinit(ehci, pdev); | ||
216 | done: | ||
217 | return retval; | ||
218 | } | ||
219 | |||
220 | /*-------------------------------------------------------------------------*/ | ||
221 | |||
222 | #ifdef CONFIG_PM | ||
223 | |||
224 | /* suspend/resume, section 4.3 */ | ||
225 | |||
226 | /* These routines rely on the PCI bus glue | ||
227 | * to handle powerdown and wakeup, and currently also on | ||
228 | * transceivers that don't need any software attention to set up | ||
229 | * the right sort of wakeup. | ||
230 | * Also they depend on separate root hub suspend/resume. | ||
231 | */ | ||
232 | |||
233 | static int ehci_pci_suspend(struct usb_hcd *hcd, pm_message_t message) | ||
234 | { | ||
235 | struct ehci_hcd *ehci = hcd_to_ehci(hcd); | ||
236 | unsigned long flags; | ||
237 | int rc = 0; | ||
238 | |||
239 | if (time_before(jiffies, ehci->next_statechange)) | ||
240 | msleep(10); | ||
241 | |||
242 | /* Root hub was already suspended. Disable irq emission and | ||
243 | * mark HW unaccessible, bail out if RH has been resumed. Use | ||
244 | * the spinlock to properly synchronize with possible pending | ||
245 | * RH suspend or resume activity. | ||
246 | * | ||
247 | * This is still racy as hcd->state is manipulated outside of | ||
248 | * any locks =P But that will be a different fix. | ||
249 | */ | ||
250 | spin_lock_irqsave (&ehci->lock, flags); | ||
251 | if (hcd->state != HC_STATE_SUSPENDED) { | ||
252 | rc = -EINVAL; | ||
253 | goto bail; | ||
254 | } | ||
255 | writel (0, &ehci->regs->intr_enable); | ||
256 | (void)readl(&ehci->regs->intr_enable); | ||
257 | |||
258 | clear_bit(HCD_FLAG_HW_ACCESSIBLE, &hcd->flags); | ||
259 | bail: | ||
260 | spin_unlock_irqrestore (&ehci->lock, flags); | ||
261 | |||
262 | // could save FLADJ in case of Vaux power loss | ||
263 | // ... we'd only use it to handle clock skew | ||
264 | |||
265 | return rc; | ||
266 | } | ||
267 | |||
268 | static int ehci_pci_resume(struct usb_hcd *hcd) | ||
269 | { | ||
270 | struct ehci_hcd *ehci = hcd_to_ehci(hcd); | ||
271 | unsigned port; | ||
272 | struct usb_device *root = hcd->self.root_hub; | ||
273 | struct pci_dev *pdev = to_pci_dev(hcd->self.controller); | ||
274 | int retval = -EINVAL; | ||
275 | |||
276 | // maybe restore FLADJ | ||
277 | |||
278 | if (time_before(jiffies, ehci->next_statechange)) | ||
279 | msleep(100); | ||
280 | |||
281 | /* Mark hardware accessible again as we are out of D3 state by now */ | ||
282 | set_bit(HCD_FLAG_HW_ACCESSIBLE, &hcd->flags); | ||
283 | |||
284 | /* If CF is clear, we lost PCI Vaux power and need to restart. */ | ||
285 | if (readl(&ehci->regs->configured_flag) != FLAG_CF) | ||
286 | goto restart; | ||
287 | |||
288 | /* If any port is suspended (or owned by the companion), | ||
289 | * we know we can/must resume the HC (and mustn't reset it). | ||
290 | * We just defer that to the root hub code. | ||
291 | */ | ||
292 | for (port = HCS_N_PORTS(ehci->hcs_params); port > 0; ) { | ||
293 | u32 status; | ||
294 | port--; | ||
295 | status = readl(&ehci->regs->port_status [port]); | ||
296 | if (!(status & PORT_POWER)) | ||
297 | continue; | ||
298 | if (status & (PORT_SUSPEND | PORT_RESUME | PORT_OWNER)) { | ||
299 | usb_hcd_resume_root_hub(hcd); | ||
300 | return 0; | ||
301 | } | ||
302 | } | ||
303 | |||
304 | restart: | ||
305 | ehci_dbg(ehci, "lost power, restarting\n"); | ||
306 | for (port = HCS_N_PORTS(ehci->hcs_params); port > 0; ) { | ||
307 | port--; | ||
308 | if (!root->children [port]) | ||
309 | continue; | ||
310 | usb_set_device_state(root->children[port], | ||
311 | USB_STATE_NOTATTACHED); | ||
312 | } | ||
313 | |||
314 | /* Else reset, to cope with power loss or flush-to-storage | ||
315 | * style "resume" having let BIOS kick in during reboot. | ||
316 | */ | ||
317 | (void) ehci_halt(ehci); | ||
318 | (void) ehci_reset(ehci); | ||
319 | (void) ehci_pci_reinit(ehci, pdev); | ||
320 | |||
321 | /* emptying the schedule aborts any urbs */ | ||
322 | spin_lock_irq(&ehci->lock); | ||
323 | if (ehci->reclaim) | ||
324 | ehci->reclaim_ready = 1; | ||
325 | ehci_work(ehci, NULL); | ||
326 | spin_unlock_irq(&ehci->lock); | ||
327 | |||
328 | /* restart; khubd will disconnect devices */ | ||
329 | retval = ehci_run(hcd); | ||
330 | |||
331 | /* here we "know" root ports should always stay powered */ | ||
332 | ehci_port_power(ehci, 1); | ||
333 | |||
334 | return retval; | ||
335 | } | ||
336 | #endif | ||
337 | |||
338 | static const struct hc_driver ehci_pci_hc_driver = { | ||
339 | .description = hcd_name, | ||
340 | .product_desc = "EHCI Host Controller", | ||
341 | .hcd_priv_size = sizeof(struct ehci_hcd), | ||
342 | |||
343 | /* | ||
344 | * generic hardware linkage | ||
345 | */ | ||
346 | .irq = ehci_irq, | ||
347 | .flags = HCD_MEMORY | HCD_USB2, | ||
348 | |||
349 | /* | ||
350 | * basic lifecycle operations | ||
351 | */ | ||
352 | .reset = ehci_pci_setup, | ||
353 | .start = ehci_run, | ||
354 | #ifdef CONFIG_PM | ||
355 | .suspend = ehci_pci_suspend, | ||
356 | .resume = ehci_pci_resume, | ||
357 | #endif | ||
358 | .stop = ehci_stop, | ||
359 | |||
360 | /* | ||
361 | * managing i/o requests and associated device resources | ||
362 | */ | ||
363 | .urb_enqueue = ehci_urb_enqueue, | ||
364 | .urb_dequeue = ehci_urb_dequeue, | ||
365 | .endpoint_disable = ehci_endpoint_disable, | ||
366 | |||
367 | /* | ||
368 | * scheduling support | ||
369 | */ | ||
370 | .get_frame_number = ehci_get_frame, | ||
371 | |||
372 | /* | ||
373 | * root hub support | ||
374 | */ | ||
375 | .hub_status_data = ehci_hub_status_data, | ||
376 | .hub_control = ehci_hub_control, | ||
377 | .bus_suspend = ehci_bus_suspend, | ||
378 | .bus_resume = ehci_bus_resume, | ||
379 | }; | ||
380 | |||
381 | /*-------------------------------------------------------------------------*/ | ||
382 | |||
383 | /* PCI driver selection metadata; PCI hotplugging uses this */ | ||
384 | static const struct pci_device_id pci_ids [] = { { | ||
385 | /* handle any USB 2.0 EHCI controller */ | ||
386 | PCI_DEVICE_CLASS(((PCI_CLASS_SERIAL_USB << 8) | 0x20), ~0), | ||
387 | .driver_data = (unsigned long) &ehci_pci_hc_driver, | ||
388 | }, | ||
389 | { /* end: all zeroes */ } | ||
390 | }; | ||
391 | MODULE_DEVICE_TABLE(pci, pci_ids); | ||
392 | |||
393 | /* pci driver glue; this is a "new style" PCI driver module */ | ||
394 | static struct pci_driver ehci_pci_driver = { | ||
395 | .name = (char *) hcd_name, | ||
396 | .id_table = pci_ids, | ||
397 | |||
398 | .probe = usb_hcd_pci_probe, | ||
399 | .remove = usb_hcd_pci_remove, | ||
400 | |||
401 | #ifdef CONFIG_PM | ||
402 | .suspend = usb_hcd_pci_suspend, | ||
403 | .resume = usb_hcd_pci_resume, | ||
404 | #endif | ||
405 | }; | ||
406 | |||
407 | static int __init ehci_hcd_pci_init(void) | ||
408 | { | ||
409 | if (usb_disabled()) | ||
410 | return -ENODEV; | ||
411 | |||
412 | pr_debug("%s: block sizes: qh %Zd qtd %Zd itd %Zd sitd %Zd\n", | ||
413 | hcd_name, | ||
414 | sizeof(struct ehci_qh), sizeof(struct ehci_qtd), | ||
415 | sizeof(struct ehci_itd), sizeof(struct ehci_sitd)); | ||
416 | |||
417 | return pci_register_driver(&ehci_pci_driver); | ||
418 | } | ||
419 | module_init(ehci_hcd_pci_init); | ||
420 | |||
421 | static void __exit ehci_hcd_pci_cleanup(void) | ||
422 | { | ||
423 | pci_unregister_driver(&ehci_pci_driver); | ||
424 | } | ||
425 | module_exit(ehci_hcd_pci_cleanup); | ||
diff --git a/drivers/usb/host/ehci-q.c b/drivers/usb/host/ehci-q.c index 940d38ca7d91..bf03ec0d8ee2 100644 --- a/drivers/usb/host/ehci-q.c +++ b/drivers/usb/host/ehci-q.c | |||
@@ -477,7 +477,7 @@ qh_urb_transaction ( | |||
477 | struct ehci_hcd *ehci, | 477 | struct ehci_hcd *ehci, |
478 | struct urb *urb, | 478 | struct urb *urb, |
479 | struct list_head *head, | 479 | struct list_head *head, |
480 | int flags | 480 | gfp_t flags |
481 | ) { | 481 | ) { |
482 | struct ehci_qtd *qtd, *qtd_prev; | 482 | struct ehci_qtd *qtd, *qtd_prev; |
483 | dma_addr_t buf; | 483 | dma_addr_t buf; |
@@ -629,7 +629,7 @@ static struct ehci_qh * | |||
629 | qh_make ( | 629 | qh_make ( |
630 | struct ehci_hcd *ehci, | 630 | struct ehci_hcd *ehci, |
631 | struct urb *urb, | 631 | struct urb *urb, |
632 | int flags | 632 | gfp_t flags |
633 | ) { | 633 | ) { |
634 | struct ehci_qh *qh = ehci_qh_alloc (ehci, flags); | 634 | struct ehci_qh *qh = ehci_qh_alloc (ehci, flags); |
635 | u32 info1 = 0, info2 = 0; | 635 | u32 info1 = 0, info2 = 0; |
@@ -906,12 +906,13 @@ submit_async ( | |||
906 | struct usb_host_endpoint *ep, | 906 | struct usb_host_endpoint *ep, |
907 | struct urb *urb, | 907 | struct urb *urb, |
908 | struct list_head *qtd_list, | 908 | struct list_head *qtd_list, |
909 | unsigned mem_flags | 909 | gfp_t mem_flags |
910 | ) { | 910 | ) { |
911 | struct ehci_qtd *qtd; | 911 | struct ehci_qtd *qtd; |
912 | int epnum; | 912 | int epnum; |
913 | unsigned long flags; | 913 | unsigned long flags; |
914 | struct ehci_qh *qh = NULL; | 914 | struct ehci_qh *qh = NULL; |
915 | int rc = 0; | ||
915 | 916 | ||
916 | qtd = list_entry (qtd_list->next, struct ehci_qtd, qtd_list); | 917 | qtd = list_entry (qtd_list->next, struct ehci_qtd, qtd_list); |
917 | epnum = ep->desc.bEndpointAddress; | 918 | epnum = ep->desc.bEndpointAddress; |
@@ -926,21 +927,28 @@ submit_async ( | |||
926 | #endif | 927 | #endif |
927 | 928 | ||
928 | spin_lock_irqsave (&ehci->lock, flags); | 929 | spin_lock_irqsave (&ehci->lock, flags); |
930 | if (unlikely(!test_bit(HCD_FLAG_HW_ACCESSIBLE, | ||
931 | &ehci_to_hcd(ehci)->flags))) { | ||
932 | rc = -ESHUTDOWN; | ||
933 | goto done; | ||
934 | } | ||
935 | |||
929 | qh = qh_append_tds (ehci, urb, qtd_list, epnum, &ep->hcpriv); | 936 | qh = qh_append_tds (ehci, urb, qtd_list, epnum, &ep->hcpriv); |
937 | if (unlikely(qh == NULL)) { | ||
938 | rc = -ENOMEM; | ||
939 | goto done; | ||
940 | } | ||
930 | 941 | ||
931 | /* Control/bulk operations through TTs don't need scheduling, | 942 | /* Control/bulk operations through TTs don't need scheduling, |
932 | * the HC and TT handle it when the TT has a buffer ready. | 943 | * the HC and TT handle it when the TT has a buffer ready. |
933 | */ | 944 | */ |
934 | if (likely (qh != NULL)) { | 945 | if (likely (qh->qh_state == QH_STATE_IDLE)) |
935 | if (likely (qh->qh_state == QH_STATE_IDLE)) | 946 | qh_link_async (ehci, qh_get (qh)); |
936 | qh_link_async (ehci, qh_get (qh)); | 947 | done: |
937 | } | ||
938 | spin_unlock_irqrestore (&ehci->lock, flags); | 948 | spin_unlock_irqrestore (&ehci->lock, flags); |
939 | if (unlikely (qh == NULL)) { | 949 | if (unlikely (qh == NULL)) |
940 | qtd_list_free (ehci, urb, qtd_list); | 950 | qtd_list_free (ehci, urb, qtd_list); |
941 | return -ENOMEM; | 951 | return rc; |
942 | } | ||
943 | return 0; | ||
944 | } | 952 | } |
945 | 953 | ||
946 | /*-------------------------------------------------------------------------*/ | 954 | /*-------------------------------------------------------------------------*/ |
diff --git a/drivers/usb/host/ehci-sched.c b/drivers/usb/host/ehci-sched.c index ccc7300baa6d..57e77374d228 100644 --- a/drivers/usb/host/ehci-sched.c +++ b/drivers/usb/host/ehci-sched.c | |||
@@ -589,7 +589,7 @@ static int intr_submit ( | |||
589 | struct usb_host_endpoint *ep, | 589 | struct usb_host_endpoint *ep, |
590 | struct urb *urb, | 590 | struct urb *urb, |
591 | struct list_head *qtd_list, | 591 | struct list_head *qtd_list, |
592 | unsigned mem_flags | 592 | gfp_t mem_flags |
593 | ) { | 593 | ) { |
594 | unsigned epnum; | 594 | unsigned epnum; |
595 | unsigned long flags; | 595 | unsigned long flags; |
@@ -602,6 +602,12 @@ static int intr_submit ( | |||
602 | 602 | ||
603 | spin_lock_irqsave (&ehci->lock, flags); | 603 | spin_lock_irqsave (&ehci->lock, flags); |
604 | 604 | ||
605 | if (unlikely(!test_bit(HCD_FLAG_HW_ACCESSIBLE, | ||
606 | &ehci_to_hcd(ehci)->flags))) { | ||
607 | status = -ESHUTDOWN; | ||
608 | goto done; | ||
609 | } | ||
610 | |||
605 | /* get qh and force any scheduling errors */ | 611 | /* get qh and force any scheduling errors */ |
606 | INIT_LIST_HEAD (&empty); | 612 | INIT_LIST_HEAD (&empty); |
607 | qh = qh_append_tds (ehci, urb, &empty, epnum, &ep->hcpriv); | 613 | qh = qh_append_tds (ehci, urb, &empty, epnum, &ep->hcpriv); |
@@ -634,7 +640,7 @@ done: | |||
634 | /* ehci_iso_stream ops work with both ITD and SITD */ | 640 | /* ehci_iso_stream ops work with both ITD and SITD */ |
635 | 641 | ||
636 | static struct ehci_iso_stream * | 642 | static struct ehci_iso_stream * |
637 | iso_stream_alloc (unsigned mem_flags) | 643 | iso_stream_alloc (gfp_t mem_flags) |
638 | { | 644 | { |
639 | struct ehci_iso_stream *stream; | 645 | struct ehci_iso_stream *stream; |
640 | 646 | ||
@@ -851,7 +857,7 @@ iso_stream_find (struct ehci_hcd *ehci, struct urb *urb) | |||
851 | /* ehci_iso_sched ops can be ITD-only or SITD-only */ | 857 | /* ehci_iso_sched ops can be ITD-only or SITD-only */ |
852 | 858 | ||
853 | static struct ehci_iso_sched * | 859 | static struct ehci_iso_sched * |
854 | iso_sched_alloc (unsigned packets, unsigned mem_flags) | 860 | iso_sched_alloc (unsigned packets, gfp_t mem_flags) |
855 | { | 861 | { |
856 | struct ehci_iso_sched *iso_sched; | 862 | struct ehci_iso_sched *iso_sched; |
857 | int size = sizeof *iso_sched; | 863 | int size = sizeof *iso_sched; |
@@ -924,7 +930,7 @@ itd_urb_transaction ( | |||
924 | struct ehci_iso_stream *stream, | 930 | struct ehci_iso_stream *stream, |
925 | struct ehci_hcd *ehci, | 931 | struct ehci_hcd *ehci, |
926 | struct urb *urb, | 932 | struct urb *urb, |
927 | unsigned mem_flags | 933 | gfp_t mem_flags |
928 | ) | 934 | ) |
929 | { | 935 | { |
930 | struct ehci_itd *itd; | 936 | struct ehci_itd *itd; |
@@ -1418,7 +1424,7 @@ itd_complete ( | |||
1418 | /*-------------------------------------------------------------------------*/ | 1424 | /*-------------------------------------------------------------------------*/ |
1419 | 1425 | ||
1420 | static int itd_submit (struct ehci_hcd *ehci, struct urb *urb, | 1426 | static int itd_submit (struct ehci_hcd *ehci, struct urb *urb, |
1421 | unsigned mem_flags) | 1427 | gfp_t mem_flags) |
1422 | { | 1428 | { |
1423 | int status = -EINVAL; | 1429 | int status = -EINVAL; |
1424 | unsigned long flags; | 1430 | unsigned long flags; |
@@ -1456,7 +1462,11 @@ static int itd_submit (struct ehci_hcd *ehci, struct urb *urb, | |||
1456 | 1462 | ||
1457 | /* schedule ... need to lock */ | 1463 | /* schedule ... need to lock */ |
1458 | spin_lock_irqsave (&ehci->lock, flags); | 1464 | spin_lock_irqsave (&ehci->lock, flags); |
1459 | status = iso_stream_schedule (ehci, urb, stream); | 1465 | if (unlikely(!test_bit(HCD_FLAG_HW_ACCESSIBLE, |
1466 | &ehci_to_hcd(ehci)->flags))) | ||
1467 | status = -ESHUTDOWN; | ||
1468 | else | ||
1469 | status = iso_stream_schedule (ehci, urb, stream); | ||
1460 | if (likely (status == 0)) | 1470 | if (likely (status == 0)) |
1461 | itd_link_urb (ehci, urb, ehci->periodic_size << 3, stream); | 1471 | itd_link_urb (ehci, urb, ehci->periodic_size << 3, stream); |
1462 | spin_unlock_irqrestore (&ehci->lock, flags); | 1472 | spin_unlock_irqrestore (&ehci->lock, flags); |
@@ -1529,7 +1539,7 @@ sitd_urb_transaction ( | |||
1529 | struct ehci_iso_stream *stream, | 1539 | struct ehci_iso_stream *stream, |
1530 | struct ehci_hcd *ehci, | 1540 | struct ehci_hcd *ehci, |
1531 | struct urb *urb, | 1541 | struct urb *urb, |
1532 | unsigned mem_flags | 1542 | gfp_t mem_flags |
1533 | ) | 1543 | ) |
1534 | { | 1544 | { |
1535 | struct ehci_sitd *sitd; | 1545 | struct ehci_sitd *sitd; |
@@ -1779,7 +1789,7 @@ sitd_complete ( | |||
1779 | 1789 | ||
1780 | 1790 | ||
1781 | static int sitd_submit (struct ehci_hcd *ehci, struct urb *urb, | 1791 | static int sitd_submit (struct ehci_hcd *ehci, struct urb *urb, |
1782 | unsigned mem_flags) | 1792 | gfp_t mem_flags) |
1783 | { | 1793 | { |
1784 | int status = -EINVAL; | 1794 | int status = -EINVAL; |
1785 | unsigned long flags; | 1795 | unsigned long flags; |
@@ -1815,7 +1825,11 @@ static int sitd_submit (struct ehci_hcd *ehci, struct urb *urb, | |||
1815 | 1825 | ||
1816 | /* schedule ... need to lock */ | 1826 | /* schedule ... need to lock */ |
1817 | spin_lock_irqsave (&ehci->lock, flags); | 1827 | spin_lock_irqsave (&ehci->lock, flags); |
1818 | status = iso_stream_schedule (ehci, urb, stream); | 1828 | if (unlikely(!test_bit(HCD_FLAG_HW_ACCESSIBLE, |
1829 | &ehci_to_hcd(ehci)->flags))) | ||
1830 | status = -ESHUTDOWN; | ||
1831 | else | ||
1832 | status = iso_stream_schedule (ehci, urb, stream); | ||
1819 | if (status == 0) | 1833 | if (status == 0) |
1820 | sitd_link_urb (ehci, urb, ehci->periodic_size << 3, stream); | 1834 | sitd_link_urb (ehci, urb, ehci->periodic_size << 3, stream); |
1821 | spin_unlock_irqrestore (&ehci->lock, flags); | 1835 | spin_unlock_irqrestore (&ehci->lock, flags); |
diff --git a/drivers/usb/host/ehci.h b/drivers/usb/host/ehci.h index f34a0516d35f..18e257c2bdb5 100644 --- a/drivers/usb/host/ehci.h +++ b/drivers/usb/host/ehci.h | |||
@@ -97,6 +97,7 @@ struct ehci_hcd { /* one per controller */ | |||
97 | #else | 97 | #else |
98 | # define COUNT(x) do {} while (0) | 98 | # define COUNT(x) do {} while (0) |
99 | #endif | 99 | #endif |
100 | u8 sbrn; /* packed release number */ | ||
100 | }; | 101 | }; |
101 | 102 | ||
102 | /* convert between an HCD pointer and the corresponding EHCI_HCD */ | 103 | /* convert between an HCD pointer and the corresponding EHCI_HCD */ |
diff --git a/drivers/usb/host/hc_crisv10.c b/drivers/usb/host/hc_crisv10.c index a8267cf17db4..0eaabeb37ac3 100644 --- a/drivers/usb/host/hc_crisv10.c +++ b/drivers/usb/host/hc_crisv10.c | |||
@@ -14,7 +14,6 @@ | |||
14 | #include <linux/unistd.h> | 14 | #include <linux/unistd.h> |
15 | #include <linux/interrupt.h> | 15 | #include <linux/interrupt.h> |
16 | #include <linux/init.h> | 16 | #include <linux/init.h> |
17 | #include <linux/version.h> | ||
18 | #include <linux/list.h> | 17 | #include <linux/list.h> |
19 | #include <linux/spinlock.h> | 18 | #include <linux/spinlock.h> |
20 | 19 | ||
diff --git a/drivers/usb/host/isp116x-hcd.c b/drivers/usb/host/isp116x-hcd.c index 41bbae83fc71..82f64986bc22 100644 --- a/drivers/usb/host/isp116x-hcd.c +++ b/drivers/usb/host/isp116x-hcd.c | |||
@@ -70,6 +70,7 @@ | |||
70 | #include <linux/interrupt.h> | 70 | #include <linux/interrupt.h> |
71 | #include <linux/usb.h> | 71 | #include <linux/usb.h> |
72 | #include <linux/usb_isp116x.h> | 72 | #include <linux/usb_isp116x.h> |
73 | #include <linux/platform_device.h> | ||
73 | 74 | ||
74 | #include <asm/io.h> | 75 | #include <asm/io.h> |
75 | #include <asm/irq.h> | 76 | #include <asm/irq.h> |
@@ -326,7 +327,8 @@ static void postproc_atl_queue(struct isp116x *isp116x) | |||
326 | usb_settoggle(udev, ep->epnum, | 327 | usb_settoggle(udev, ep->epnum, |
327 | ep->nextpid == | 328 | ep->nextpid == |
328 | USB_PID_OUT, | 329 | USB_PID_OUT, |
329 | PTD_GET_TOGGLE(ptd) ^ 1); | 330 | PTD_GET_TOGGLE(ptd)); |
331 | urb->actual_length += PTD_GET_COUNT(ptd); | ||
330 | urb->status = cc_to_error[TD_DATAUNDERRUN]; | 332 | urb->status = cc_to_error[TD_DATAUNDERRUN]; |
331 | spin_unlock(&urb->lock); | 333 | spin_unlock(&urb->lock); |
332 | continue; | 334 | continue; |
@@ -637,7 +639,7 @@ static irqreturn_t isp116x_irq(struct usb_hcd *hcd, struct pt_regs *regs) | |||
637 | + msecs_to_jiffies(20) + 1); | 639 | + msecs_to_jiffies(20) + 1); |
638 | if (intstat & HCINT_RD) { | 640 | if (intstat & HCINT_RD) { |
639 | DBG("---- remote wakeup\n"); | 641 | DBG("---- remote wakeup\n"); |
640 | schedule_work(&isp116x->rh_resume); | 642 | usb_hcd_resume_root_hub(hcd); |
641 | ret = IRQ_HANDLED; | 643 | ret = IRQ_HANDLED; |
642 | } | 644 | } |
643 | irqstat &= ~HCuPINT_OPR; | 645 | irqstat &= ~HCuPINT_OPR; |
@@ -693,7 +695,7 @@ static int balance(struct isp116x *isp116x, u16 period, u16 load) | |||
693 | 695 | ||
694 | static int isp116x_urb_enqueue(struct usb_hcd *hcd, | 696 | static int isp116x_urb_enqueue(struct usb_hcd *hcd, |
695 | struct usb_host_endpoint *hep, struct urb *urb, | 697 | struct usb_host_endpoint *hep, struct urb *urb, |
696 | unsigned mem_flags) | 698 | gfp_t mem_flags) |
697 | { | 699 | { |
698 | struct isp116x *isp116x = hcd_to_isp116x(hcd); | 700 | struct isp116x *isp116x = hcd_to_isp116x(hcd); |
699 | struct usb_device *udev = urb->dev; | 701 | struct usb_device *udev = urb->dev; |
@@ -1159,7 +1161,7 @@ static int isp116x_hub_control(struct usb_hcd *hcd, | |||
1159 | 1161 | ||
1160 | #ifdef CONFIG_PM | 1162 | #ifdef CONFIG_PM |
1161 | 1163 | ||
1162 | static int isp116x_hub_suspend(struct usb_hcd *hcd) | 1164 | static int isp116x_bus_suspend(struct usb_hcd *hcd) |
1163 | { | 1165 | { |
1164 | struct isp116x *isp116x = hcd_to_isp116x(hcd); | 1166 | struct isp116x *isp116x = hcd_to_isp116x(hcd); |
1165 | unsigned long flags; | 1167 | unsigned long flags; |
@@ -1199,7 +1201,7 @@ static int isp116x_hub_suspend(struct usb_hcd *hcd) | |||
1199 | return ret; | 1201 | return ret; |
1200 | } | 1202 | } |
1201 | 1203 | ||
1202 | static int isp116x_hub_resume(struct usb_hcd *hcd) | 1204 | static int isp116x_bus_resume(struct usb_hcd *hcd) |
1203 | { | 1205 | { |
1204 | struct isp116x *isp116x = hcd_to_isp116x(hcd); | 1206 | struct isp116x *isp116x = hcd_to_isp116x(hcd); |
1205 | u32 val; | 1207 | u32 val; |
@@ -1262,21 +1264,11 @@ static int isp116x_hub_resume(struct usb_hcd *hcd) | |||
1262 | return 0; | 1264 | return 0; |
1263 | } | 1265 | } |
1264 | 1266 | ||
1265 | static void isp116x_rh_resume(void *_hcd) | ||
1266 | { | ||
1267 | struct usb_hcd *hcd = _hcd; | ||
1268 | |||
1269 | usb_resume_device(hcd->self.root_hub); | ||
1270 | } | ||
1271 | 1267 | ||
1272 | #else | 1268 | #else |
1273 | 1269 | ||
1274 | #define isp116x_hub_suspend NULL | 1270 | #define isp116x_bus_suspend NULL |
1275 | #define isp116x_hub_resume NULL | 1271 | #define isp116x_bus_resume NULL |
1276 | |||
1277 | static void isp116x_rh_resume(void *_hcd) | ||
1278 | { | ||
1279 | } | ||
1280 | 1272 | ||
1281 | #endif | 1273 | #endif |
1282 | 1274 | ||
@@ -1635,23 +1627,21 @@ static struct hc_driver isp116x_hc_driver = { | |||
1635 | 1627 | ||
1636 | .hub_status_data = isp116x_hub_status_data, | 1628 | .hub_status_data = isp116x_hub_status_data, |
1637 | .hub_control = isp116x_hub_control, | 1629 | .hub_control = isp116x_hub_control, |
1638 | .hub_suspend = isp116x_hub_suspend, | 1630 | .bus_suspend = isp116x_bus_suspend, |
1639 | .hub_resume = isp116x_hub_resume, | 1631 | .bus_resume = isp116x_bus_resume, |
1640 | }; | 1632 | }; |
1641 | 1633 | ||
1642 | /*----------------------------------------------------------------*/ | 1634 | /*----------------------------------------------------------------*/ |
1643 | 1635 | ||
1644 | static int __init_or_module isp116x_remove(struct device *dev) | 1636 | static int __init_or_module isp116x_remove(struct platform_device *pdev) |
1645 | { | 1637 | { |
1646 | struct usb_hcd *hcd = dev_get_drvdata(dev); | 1638 | struct usb_hcd *hcd = platform_get_drvdata(pdev); |
1647 | struct isp116x *isp116x; | 1639 | struct isp116x *isp116x; |
1648 | struct platform_device *pdev; | ||
1649 | struct resource *res; | 1640 | struct resource *res; |
1650 | 1641 | ||
1651 | if (!hcd) | 1642 | if (!hcd) |
1652 | return 0; | 1643 | return 0; |
1653 | isp116x = hcd_to_isp116x(hcd); | 1644 | isp116x = hcd_to_isp116x(hcd); |
1654 | pdev = container_of(dev, struct platform_device, dev); | ||
1655 | remove_debug_file(isp116x); | 1645 | remove_debug_file(isp116x); |
1656 | usb_remove_hcd(hcd); | 1646 | usb_remove_hcd(hcd); |
1657 | 1647 | ||
@@ -1668,18 +1658,16 @@ static int __init_or_module isp116x_remove(struct device *dev) | |||
1668 | 1658 | ||
1669 | #define resource_len(r) (((r)->end - (r)->start) + 1) | 1659 | #define resource_len(r) (((r)->end - (r)->start) + 1) |
1670 | 1660 | ||
1671 | static int __init isp116x_probe(struct device *dev) | 1661 | static int __init isp116x_probe(struct platform_device *pdev) |
1672 | { | 1662 | { |
1673 | struct usb_hcd *hcd; | 1663 | struct usb_hcd *hcd; |
1674 | struct isp116x *isp116x; | 1664 | struct isp116x *isp116x; |
1675 | struct platform_device *pdev; | ||
1676 | struct resource *addr, *data; | 1665 | struct resource *addr, *data; |
1677 | void __iomem *addr_reg; | 1666 | void __iomem *addr_reg; |
1678 | void __iomem *data_reg; | 1667 | void __iomem *data_reg; |
1679 | int irq; | 1668 | int irq; |
1680 | int ret = 0; | 1669 | int ret = 0; |
1681 | 1670 | ||
1682 | pdev = container_of(dev, struct platform_device, dev); | ||
1683 | if (pdev->num_resources < 3) { | 1671 | if (pdev->num_resources < 3) { |
1684 | ret = -ENODEV; | 1672 | ret = -ENODEV; |
1685 | goto err1; | 1673 | goto err1; |
@@ -1693,7 +1681,7 @@ static int __init isp116x_probe(struct device *dev) | |||
1693 | goto err1; | 1681 | goto err1; |
1694 | } | 1682 | } |
1695 | 1683 | ||
1696 | if (dev->dma_mask) { | 1684 | if (pdev->dev.dma_mask) { |
1697 | DBG("DMA not supported\n"); | 1685 | DBG("DMA not supported\n"); |
1698 | ret = -EINVAL; | 1686 | ret = -EINVAL; |
1699 | goto err1; | 1687 | goto err1; |
@@ -1719,7 +1707,7 @@ static int __init isp116x_probe(struct device *dev) | |||
1719 | } | 1707 | } |
1720 | 1708 | ||
1721 | /* allocate and initialize hcd */ | 1709 | /* allocate and initialize hcd */ |
1722 | hcd = usb_create_hcd(&isp116x_hc_driver, dev, dev->bus_id); | 1710 | hcd = usb_create_hcd(&isp116x_hc_driver, &pdev->dev, pdev->dev.bus_id); |
1723 | if (!hcd) { | 1711 | if (!hcd) { |
1724 | ret = -ENOMEM; | 1712 | ret = -ENOMEM; |
1725 | goto err5; | 1713 | goto err5; |
@@ -1731,8 +1719,7 @@ static int __init isp116x_probe(struct device *dev) | |||
1731 | isp116x->addr_reg = addr_reg; | 1719 | isp116x->addr_reg = addr_reg; |
1732 | spin_lock_init(&isp116x->lock); | 1720 | spin_lock_init(&isp116x->lock); |
1733 | INIT_LIST_HEAD(&isp116x->async); | 1721 | INIT_LIST_HEAD(&isp116x->async); |
1734 | INIT_WORK(&isp116x->rh_resume, isp116x_rh_resume, hcd); | 1722 | isp116x->board = pdev->dev.platform_data; |
1735 | isp116x->board = dev->platform_data; | ||
1736 | 1723 | ||
1737 | if (!isp116x->board) { | 1724 | if (!isp116x->board) { |
1738 | ERR("Platform data structure not initialized\n"); | 1725 | ERR("Platform data structure not initialized\n"); |
@@ -1773,22 +1760,13 @@ static int __init isp116x_probe(struct device *dev) | |||
1773 | /* | 1760 | /* |
1774 | Suspend of platform device | 1761 | Suspend of platform device |
1775 | */ | 1762 | */ |
1776 | static int isp116x_suspend(struct device *dev, pm_message_t state, u32 phase) | 1763 | static int isp116x_suspend(struct platform_device *dev, pm_message_t state) |
1777 | { | 1764 | { |
1778 | int ret = 0; | 1765 | int ret = 0; |
1779 | struct usb_hcd *hcd = dev_get_drvdata(dev); | ||
1780 | 1766 | ||
1781 | VDBG("%s: state %x, phase %x\n", __func__, state, phase); | 1767 | VDBG("%s: state %x\n", __func__, state); |
1782 | 1768 | ||
1783 | if (phase != SUSPEND_DISABLE && phase != SUSPEND_POWER_DOWN) | 1769 | dev->dev.power.power_state = state; |
1784 | return 0; | ||
1785 | |||
1786 | ret = usb_suspend_device(hcd->self.root_hub, state); | ||
1787 | if (!ret) { | ||
1788 | dev->power.power_state = state; | ||
1789 | INFO("%s suspended\n", hcd_name); | ||
1790 | } else | ||
1791 | ERR("%s suspend failed\n", hcd_name); | ||
1792 | 1770 | ||
1793 | return ret; | 1771 | return ret; |
1794 | } | 1772 | } |
@@ -1796,21 +1774,14 @@ static int isp116x_suspend(struct device *dev, pm_message_t state, u32 phase) | |||
1796 | /* | 1774 | /* |
1797 | Resume platform device | 1775 | Resume platform device |
1798 | */ | 1776 | */ |
1799 | static int isp116x_resume(struct device *dev, u32 phase) | 1777 | static int isp116x_resume(struct platform_device *dev) |
1800 | { | 1778 | { |
1801 | int ret = 0; | 1779 | int ret = 0; |
1802 | struct usb_hcd *hcd = dev_get_drvdata(dev); | ||
1803 | 1780 | ||
1804 | VDBG("%s: state %x, phase %x\n", __func__, dev->power.power_state, | 1781 | VDBG("%s: state %x\n", __func__, dev->dev.power.power_state); |
1805 | phase); | 1782 | |
1806 | if (phase != RESUME_POWER_ON) | 1783 | dev->dev.power.power_state = PMSG_ON; |
1807 | return 0; | ||
1808 | 1784 | ||
1809 | ret = usb_resume_device(hcd->self.root_hub); | ||
1810 | if (!ret) { | ||
1811 | dev->power.power_state = PMSG_ON; | ||
1812 | VDBG("%s resumed\n", (char *)hcd_name); | ||
1813 | } | ||
1814 | return ret; | 1785 | return ret; |
1815 | } | 1786 | } |
1816 | 1787 | ||
@@ -1821,13 +1792,14 @@ static int isp116x_resume(struct device *dev, u32 phase) | |||
1821 | 1792 | ||
1822 | #endif | 1793 | #endif |
1823 | 1794 | ||
1824 | static struct device_driver isp116x_driver = { | 1795 | static struct platform_driver isp116x_driver = { |
1825 | .name = (char *)hcd_name, | ||
1826 | .bus = &platform_bus_type, | ||
1827 | .probe = isp116x_probe, | 1796 | .probe = isp116x_probe, |
1828 | .remove = isp116x_remove, | 1797 | .remove = isp116x_remove, |
1829 | .suspend = isp116x_suspend, | 1798 | .suspend = isp116x_suspend, |
1830 | .resume = isp116x_resume, | 1799 | .resume = isp116x_resume, |
1800 | .driver = { | ||
1801 | .name = (char *)hcd_name, | ||
1802 | }, | ||
1831 | }; | 1803 | }; |
1832 | 1804 | ||
1833 | /*-----------------------------------------------------------------*/ | 1805 | /*-----------------------------------------------------------------*/ |
@@ -1838,14 +1810,14 @@ static int __init isp116x_init(void) | |||
1838 | return -ENODEV; | 1810 | return -ENODEV; |
1839 | 1811 | ||
1840 | INFO("driver %s, %s\n", hcd_name, DRIVER_VERSION); | 1812 | INFO("driver %s, %s\n", hcd_name, DRIVER_VERSION); |
1841 | return driver_register(&isp116x_driver); | 1813 | return platform_driver_register(&isp116x_driver); |
1842 | } | 1814 | } |
1843 | 1815 | ||
1844 | module_init(isp116x_init); | 1816 | module_init(isp116x_init); |
1845 | 1817 | ||
1846 | static void __exit isp116x_cleanup(void) | 1818 | static void __exit isp116x_cleanup(void) |
1847 | { | 1819 | { |
1848 | driver_unregister(&isp116x_driver); | 1820 | platform_driver_unregister(&isp116x_driver); |
1849 | } | 1821 | } |
1850 | 1822 | ||
1851 | module_exit(isp116x_cleanup); | 1823 | module_exit(isp116x_cleanup); |
diff --git a/drivers/usb/host/isp116x.h b/drivers/usb/host/isp116x.h index 58873470dcf5..c6fec96785fe 100644 --- a/drivers/usb/host/isp116x.h +++ b/drivers/usb/host/isp116x.h | |||
@@ -253,7 +253,6 @@ static const int cc_to_error[16] = { | |||
253 | 253 | ||
254 | struct isp116x { | 254 | struct isp116x { |
255 | spinlock_t lock; | 255 | spinlock_t lock; |
256 | struct work_struct rh_resume; | ||
257 | 256 | ||
258 | void __iomem *addr_reg; | 257 | void __iomem *addr_reg; |
259 | void __iomem *data_reg; | 258 | void __iomem *data_reg; |
diff --git a/drivers/usb/host/ohci-au1xxx.c b/drivers/usb/host/ohci-au1xxx.c index 3981bf15c8c7..d9cf3b327d96 100644 --- a/drivers/usb/host/ohci-au1xxx.c +++ b/drivers/usb/host/ohci-au1xxx.c | |||
@@ -18,6 +18,8 @@ | |||
18 | * This file is licenced under the GPL. | 18 | * This file is licenced under the GPL. |
19 | */ | 19 | */ |
20 | 20 | ||
21 | #include <linux/platform_device.h> | ||
22 | |||
21 | #include <asm/mach-au1x00/au1000.h> | 23 | #include <asm/mach-au1x00/au1000.h> |
22 | 24 | ||
23 | #define USBH_ENABLE_BE (1<<0) | 25 | #define USBH_ENABLE_BE (1<<0) |
@@ -214,13 +216,17 @@ static const struct hc_driver ohci_au1xxx_hc_driver = { | |||
214 | */ | 216 | */ |
215 | .hub_status_data = ohci_hub_status_data, | 217 | .hub_status_data = ohci_hub_status_data, |
216 | .hub_control = ohci_hub_control, | 218 | .hub_control = ohci_hub_control, |
219 | #ifdef CONFIG_PM | ||
220 | .bus_suspend = ohci_bus_suspend, | ||
221 | .bus_resume = ohci_bus_resume, | ||
222 | #endif | ||
223 | .start_port_reset = ohci_start_port_reset, | ||
217 | }; | 224 | }; |
218 | 225 | ||
219 | /*-------------------------------------------------------------------------*/ | 226 | /*-------------------------------------------------------------------------*/ |
220 | 227 | ||
221 | static int ohci_hcd_au1xxx_drv_probe(struct device *dev) | 228 | static int ohci_hcd_au1xxx_drv_probe(struct platform_device *pdev) |
222 | { | 229 | { |
223 | struct platform_device *pdev = to_platform_device(dev); | ||
224 | int ret; | 230 | int ret; |
225 | 231 | ||
226 | pr_debug ("In ohci_hcd_au1xxx_drv_probe"); | 232 | pr_debug ("In ohci_hcd_au1xxx_drv_probe"); |
@@ -232,38 +238,37 @@ static int ohci_hcd_au1xxx_drv_probe(struct device *dev) | |||
232 | return ret; | 238 | return ret; |
233 | } | 239 | } |
234 | 240 | ||
235 | static int ohci_hcd_au1xxx_drv_remove(struct device *dev) | 241 | static int ohci_hcd_au1xxx_drv_remove(struct platform_device *pdev) |
236 | { | 242 | { |
237 | struct platform_device *pdev = to_platform_device(dev); | 243 | struct usb_hcd *hcd = platform_get_drvdata(pdev); |
238 | struct usb_hcd *hcd = dev_get_drvdata(dev); | ||
239 | 244 | ||
240 | usb_hcd_au1xxx_remove(hcd, pdev); | 245 | usb_hcd_au1xxx_remove(hcd, pdev); |
241 | return 0; | 246 | return 0; |
242 | } | 247 | } |
243 | /*TBD*/ | 248 | /*TBD*/ |
244 | /*static int ohci_hcd_au1xxx_drv_suspend(struct device *dev) | 249 | /*static int ohci_hcd_au1xxx_drv_suspend(struct platform_device *dev) |
245 | { | 250 | { |
246 | struct platform_device *pdev = to_platform_device(dev); | 251 | struct usb_hcd *hcd = platform_get_drvdata(dev); |
247 | struct usb_hcd *hcd = dev_get_drvdata(dev); | ||
248 | 252 | ||
249 | return 0; | 253 | return 0; |
250 | } | 254 | } |
251 | static int ohci_hcd_au1xxx_drv_resume(struct device *dev) | 255 | static int ohci_hcd_au1xxx_drv_resume(struct platform_device *dev) |
252 | { | 256 | { |
253 | struct platform_device *pdev = to_platform_device(dev); | 257 | struct usb_hcd *hcd = platform_get_drvdata(dev); |
254 | struct usb_hcd *hcd = dev_get_drvdata(dev); | ||
255 | 258 | ||
256 | return 0; | 259 | return 0; |
257 | } | 260 | } |
258 | */ | 261 | */ |
259 | 262 | ||
260 | static struct device_driver ohci_hcd_au1xxx_driver = { | 263 | static struct platform_driver ohci_hcd_au1xxx_driver = { |
261 | .name = "au1xxx-ohci", | ||
262 | .bus = &platform_bus_type, | ||
263 | .probe = ohci_hcd_au1xxx_drv_probe, | 264 | .probe = ohci_hcd_au1xxx_drv_probe, |
264 | .remove = ohci_hcd_au1xxx_drv_remove, | 265 | .remove = ohci_hcd_au1xxx_drv_remove, |
265 | /*.suspend = ohci_hcd_au1xxx_drv_suspend, */ | 266 | /*.suspend = ohci_hcd_au1xxx_drv_suspend, */ |
266 | /*.resume = ohci_hcd_au1xxx_drv_resume, */ | 267 | /*.resume = ohci_hcd_au1xxx_drv_resume, */ |
268 | .driver = { | ||
269 | .name = "au1xxx-ohci", | ||
270 | .owner = THIS_MODULE, | ||
271 | }, | ||
267 | }; | 272 | }; |
268 | 273 | ||
269 | static int __init ohci_hcd_au1xxx_init (void) | 274 | static int __init ohci_hcd_au1xxx_init (void) |
@@ -272,12 +277,12 @@ static int __init ohci_hcd_au1xxx_init (void) | |||
272 | pr_debug ("block sizes: ed %d td %d\n", | 277 | pr_debug ("block sizes: ed %d td %d\n", |
273 | sizeof (struct ed), sizeof (struct td)); | 278 | sizeof (struct ed), sizeof (struct td)); |
274 | 279 | ||
275 | return driver_register(&ohci_hcd_au1xxx_driver); | 280 | return platform_driver_register(&ohci_hcd_au1xxx_driver); |
276 | } | 281 | } |
277 | 282 | ||
278 | static void __exit ohci_hcd_au1xxx_cleanup (void) | 283 | static void __exit ohci_hcd_au1xxx_cleanup (void) |
279 | { | 284 | { |
280 | driver_unregister(&ohci_hcd_au1xxx_driver); | 285 | platform_driver_unregister(&ohci_hcd_au1xxx_driver); |
281 | } | 286 | } |
282 | 287 | ||
283 | module_init (ohci_hcd_au1xxx_init); | 288 | module_init (ohci_hcd_au1xxx_init); |
diff --git a/drivers/usb/host/ohci-dbg.c b/drivers/usb/host/ohci-dbg.c index 7924c74f958e..7bfffcbbd226 100644 --- a/drivers/usb/host/ohci-dbg.c +++ b/drivers/usb/host/ohci-dbg.c | |||
@@ -193,10 +193,6 @@ ohci_dump_status (struct ohci_hcd *controller, char **next, unsigned *size) | |||
193 | 193 | ||
194 | maybe_print_eds (controller, "donehead", | 194 | maybe_print_eds (controller, "donehead", |
195 | ohci_readl (controller, ®s->donehead), next, size); | 195 | ohci_readl (controller, ®s->donehead), next, size); |
196 | |||
197 | /* broken fminterval means traffic won't flow! */ | ||
198 | ohci_dbg (controller, "fminterval %08x\n", | ||
199 | ohci_readl (controller, ®s->fminterval)); | ||
200 | } | 196 | } |
201 | 197 | ||
202 | #define dbg_port_sw(hc,num,value,next,size) \ | 198 | #define dbg_port_sw(hc,num,value,next,size) \ |
diff --git a/drivers/usb/host/ohci-hcd.c b/drivers/usb/host/ohci-hcd.c index 67c1aa5eb1c1..bf1d9abc07ac 100644 --- a/drivers/usb/host/ohci-hcd.c +++ b/drivers/usb/host/ohci-hcd.c | |||
@@ -115,7 +115,7 @@ | |||
115 | 115 | ||
116 | /*-------------------------------------------------------------------------*/ | 116 | /*-------------------------------------------------------------------------*/ |
117 | 117 | ||
118 | // #define OHCI_VERBOSE_DEBUG /* not always helpful */ | 118 | #undef OHCI_VERBOSE_DEBUG /* not always helpful */ |
119 | 119 | ||
120 | /* For initializing controller (mask in an HCFS mode too) */ | 120 | /* For initializing controller (mask in an HCFS mode too) */ |
121 | #define OHCI_CONTROL_INIT OHCI_CTRL_CBSR | 121 | #define OHCI_CONTROL_INIT OHCI_CTRL_CBSR |
@@ -180,7 +180,7 @@ static int ohci_urb_enqueue ( | |||
180 | struct usb_hcd *hcd, | 180 | struct usb_hcd *hcd, |
181 | struct usb_host_endpoint *ep, | 181 | struct usb_host_endpoint *ep, |
182 | struct urb *urb, | 182 | struct urb *urb, |
183 | unsigned mem_flags | 183 | gfp_t mem_flags |
184 | ) { | 184 | ) { |
185 | struct ohci_hcd *ohci = hcd_to_ohci (hcd); | 185 | struct ohci_hcd *ohci = hcd_to_ohci (hcd); |
186 | struct ed *ed; | 186 | struct ed *ed; |
@@ -253,6 +253,10 @@ static int ohci_urb_enqueue ( | |||
253 | spin_lock_irqsave (&ohci->lock, flags); | 253 | spin_lock_irqsave (&ohci->lock, flags); |
254 | 254 | ||
255 | /* don't submit to a dead HC */ | 255 | /* don't submit to a dead HC */ |
256 | if (!test_bit(HCD_FLAG_HW_ACCESSIBLE, &hcd->flags)) { | ||
257 | retval = -ENODEV; | ||
258 | goto fail; | ||
259 | } | ||
256 | if (!HC_IS_RUNNING(hcd->state)) { | 260 | if (!HC_IS_RUNNING(hcd->state)) { |
257 | retval = -ENODEV; | 261 | retval = -ENODEV; |
258 | goto fail; | 262 | goto fail; |
@@ -723,7 +727,7 @@ static irqreturn_t ohci_irq (struct usb_hcd *hcd, struct pt_regs *ptregs) | |||
723 | ohci_vdbg (ohci, "resume detect\n"); | 727 | ohci_vdbg (ohci, "resume detect\n"); |
724 | ohci_writel (ohci, OHCI_INTR_RD, ®s->intrstatus); | 728 | ohci_writel (ohci, OHCI_INTR_RD, ®s->intrstatus); |
725 | if (hcd->state != HC_STATE_QUIESCING) | 729 | if (hcd->state != HC_STATE_QUIESCING) |
726 | schedule_work(&ohci->rh_resume); | 730 | usb_hcd_resume_root_hub(hcd); |
727 | } | 731 | } |
728 | 732 | ||
729 | if (ints & OHCI_INTR_WDH) { | 733 | if (ints & OHCI_INTR_WDH) { |
@@ -791,7 +795,7 @@ static void ohci_stop (struct usb_hcd *hcd) | |||
791 | 795 | ||
792 | /* must not be called from interrupt context */ | 796 | /* must not be called from interrupt context */ |
793 | 797 | ||
794 | #if defined(CONFIG_USB_SUSPEND) || defined(CONFIG_PM) | 798 | #ifdef CONFIG_PM |
795 | 799 | ||
796 | static int ohci_restart (struct ohci_hcd *ohci) | 800 | static int ohci_restart (struct ohci_hcd *ohci) |
797 | { | 801 | { |
diff --git a/drivers/usb/host/ohci-hub.c b/drivers/usb/host/ohci-hub.c index ce7b28da7a15..72e3b12a1926 100644 --- a/drivers/usb/host/ohci-hub.c +++ b/drivers/usb/host/ohci-hub.c | |||
@@ -36,7 +36,7 @@ | |||
36 | 36 | ||
37 | /*-------------------------------------------------------------------------*/ | 37 | /*-------------------------------------------------------------------------*/ |
38 | 38 | ||
39 | #if defined(CONFIG_USB_SUSPEND) || defined(CONFIG_PM) | 39 | #ifdef CONFIG_PM |
40 | 40 | ||
41 | #define OHCI_SCHED_ENABLES \ | 41 | #define OHCI_SCHED_ENABLES \ |
42 | (OHCI_CTRL_CLE|OHCI_CTRL_BLE|OHCI_CTRL_PLE|OHCI_CTRL_IE) | 42 | (OHCI_CTRL_CLE|OHCI_CTRL_BLE|OHCI_CTRL_PLE|OHCI_CTRL_IE) |
@@ -45,7 +45,7 @@ static void dl_done_list (struct ohci_hcd *, struct pt_regs *); | |||
45 | static void finish_unlinks (struct ohci_hcd *, u16 , struct pt_regs *); | 45 | static void finish_unlinks (struct ohci_hcd *, u16 , struct pt_regs *); |
46 | static int ohci_restart (struct ohci_hcd *ohci); | 46 | static int ohci_restart (struct ohci_hcd *ohci); |
47 | 47 | ||
48 | static int ohci_hub_suspend (struct usb_hcd *hcd) | 48 | static int ohci_bus_suspend (struct usb_hcd *hcd) |
49 | { | 49 | { |
50 | struct ohci_hcd *ohci = hcd_to_ohci (hcd); | 50 | struct ohci_hcd *ohci = hcd_to_ohci (hcd); |
51 | int status = 0; | 51 | int status = 0; |
@@ -53,6 +53,11 @@ static int ohci_hub_suspend (struct usb_hcd *hcd) | |||
53 | 53 | ||
54 | spin_lock_irqsave (&ohci->lock, flags); | 54 | spin_lock_irqsave (&ohci->lock, flags); |
55 | 55 | ||
56 | if (unlikely(!test_bit(HCD_FLAG_HW_ACCESSIBLE, &hcd->flags))) { | ||
57 | spin_unlock_irqrestore (&ohci->lock, flags); | ||
58 | return -ESHUTDOWN; | ||
59 | } | ||
60 | |||
56 | ohci->hc_control = ohci_readl (ohci, &ohci->regs->control); | 61 | ohci->hc_control = ohci_readl (ohci, &ohci->regs->control); |
57 | switch (ohci->hc_control & OHCI_CTRL_HCFS) { | 62 | switch (ohci->hc_control & OHCI_CTRL_HCFS) { |
58 | case OHCI_USB_RESUME: | 63 | case OHCI_USB_RESUME: |
@@ -73,7 +78,6 @@ static int ohci_hub_suspend (struct usb_hcd *hcd) | |||
73 | ohci_dbg (ohci, "suspend root hub\n"); | 78 | ohci_dbg (ohci, "suspend root hub\n"); |
74 | 79 | ||
75 | /* First stop any processing */ | 80 | /* First stop any processing */ |
76 | hcd->state = HC_STATE_QUIESCING; | ||
77 | if (ohci->hc_control & OHCI_SCHED_ENABLES) { | 81 | if (ohci->hc_control & OHCI_SCHED_ENABLES) { |
78 | int limit; | 82 | int limit; |
79 | 83 | ||
@@ -108,7 +112,9 @@ static int ohci_hub_suspend (struct usb_hcd *hcd) | |||
108 | else | 112 | else |
109 | ohci->hc_control &= ~OHCI_CTRL_RWE; | 113 | ohci->hc_control &= ~OHCI_CTRL_RWE; |
110 | 114 | ||
111 | /* Suspend hub */ | 115 | /* Suspend hub ... this is the "global (to this bus) suspend" mode, |
116 | * which doesn't imply ports will first be individually suspended. | ||
117 | */ | ||
112 | ohci->hc_control &= ~OHCI_CTRL_HCFS; | 118 | ohci->hc_control &= ~OHCI_CTRL_HCFS; |
113 | ohci->hc_control |= OHCI_USB_SUSPEND; | 119 | ohci->hc_control |= OHCI_USB_SUSPEND; |
114 | ohci_writel (ohci, ohci->hc_control, &ohci->regs->control); | 120 | ohci_writel (ohci, ohci->hc_control, &ohci->regs->control); |
@@ -118,8 +124,9 @@ static int ohci_hub_suspend (struct usb_hcd *hcd) | |||
118 | ohci->next_statechange = jiffies + msecs_to_jiffies (5); | 124 | ohci->next_statechange = jiffies + msecs_to_jiffies (5); |
119 | 125 | ||
120 | done: | 126 | done: |
127 | /* external suspend vs self autosuspend ... same effect */ | ||
121 | if (status == 0) | 128 | if (status == 0) |
122 | hcd->state = HC_STATE_SUSPENDED; | 129 | usb_hcd_suspend_root_hub(hcd); |
123 | spin_unlock_irqrestore (&ohci->lock, flags); | 130 | spin_unlock_irqrestore (&ohci->lock, flags); |
124 | return status; | 131 | return status; |
125 | } | 132 | } |
@@ -133,20 +140,28 @@ static inline struct ed *find_head (struct ed *ed) | |||
133 | } | 140 | } |
134 | 141 | ||
135 | /* caller has locked the root hub */ | 142 | /* caller has locked the root hub */ |
136 | static int ohci_hub_resume (struct usb_hcd *hcd) | 143 | static int ohci_bus_resume (struct usb_hcd *hcd) |
137 | { | 144 | { |
138 | struct ohci_hcd *ohci = hcd_to_ohci (hcd); | 145 | struct ohci_hcd *ohci = hcd_to_ohci (hcd); |
139 | u32 temp, enables; | 146 | u32 temp, enables; |
140 | int status = -EINPROGRESS; | 147 | int status = -EINPROGRESS; |
148 | unsigned long flags; | ||
141 | 149 | ||
142 | if (time_before (jiffies, ohci->next_statechange)) | 150 | if (time_before (jiffies, ohci->next_statechange)) |
143 | msleep(5); | 151 | msleep(5); |
144 | 152 | ||
145 | spin_lock_irq (&ohci->lock); | 153 | spin_lock_irqsave (&ohci->lock, flags); |
154 | |||
155 | if (unlikely(!test_bit(HCD_FLAG_HW_ACCESSIBLE, &hcd->flags))) { | ||
156 | spin_unlock_irqrestore (&ohci->lock, flags); | ||
157 | return -ESHUTDOWN; | ||
158 | } | ||
159 | |||
160 | |||
146 | ohci->hc_control = ohci_readl (ohci, &ohci->regs->control); | 161 | ohci->hc_control = ohci_readl (ohci, &ohci->regs->control); |
147 | 162 | ||
148 | if (ohci->hc_control & (OHCI_CTRL_IR | OHCI_SCHED_ENABLES)) { | 163 | if (ohci->hc_control & (OHCI_CTRL_IR | OHCI_SCHED_ENABLES)) { |
149 | /* this can happen after suspend-to-disk */ | 164 | /* this can happen after resuming a swsusp snapshot */ |
150 | if (hcd->state == HC_STATE_RESUMING) { | 165 | if (hcd->state == HC_STATE_RESUMING) { |
151 | ohci_dbg (ohci, "BIOS/SMM active, control %03x\n", | 166 | ohci_dbg (ohci, "BIOS/SMM active, control %03x\n", |
152 | ohci->hc_control); | 167 | ohci->hc_control); |
@@ -169,14 +184,15 @@ static int ohci_hub_resume (struct usb_hcd *hcd) | |||
169 | ohci_info (ohci, "wakeup\n"); | 184 | ohci_info (ohci, "wakeup\n"); |
170 | break; | 185 | break; |
171 | case OHCI_USB_OPER: | 186 | case OHCI_USB_OPER: |
172 | ohci_dbg (ohci, "already resumed\n"); | 187 | /* this can happen after resuming a swsusp snapshot */ |
173 | status = 0; | 188 | ohci_dbg (ohci, "snapshot resume? reinit\n"); |
189 | status = -EBUSY; | ||
174 | break; | 190 | break; |
175 | default: /* RESET, we lost power */ | 191 | default: /* RESET, we lost power */ |
176 | ohci_dbg (ohci, "root hub hardware reset\n"); | 192 | ohci_dbg (ohci, "lost power\n"); |
177 | status = -EBUSY; | 193 | status = -EBUSY; |
178 | } | 194 | } |
179 | spin_unlock_irq (&ohci->lock); | 195 | spin_unlock_irqrestore (&ohci->lock, flags); |
180 | if (status == -EBUSY) { | 196 | if (status == -EBUSY) { |
181 | (void) ohci_init (ohci); | 197 | (void) ohci_init (ohci); |
182 | return ohci_restart (ohci); | 198 | return ohci_restart (ohci); |
@@ -198,8 +214,7 @@ static int ohci_hub_resume (struct usb_hcd *hcd) | |||
198 | } | 214 | } |
199 | 215 | ||
200 | /* Some controllers (lucent erratum) need extra-long delays */ | 216 | /* Some controllers (lucent erratum) need extra-long delays */ |
201 | hcd->state = HC_STATE_RESUMING; | 217 | msleep (20 /* usb 11.5.1.10 */ + 12 /* 32 msec counter */ + 1); |
202 | mdelay (20 /* usb 11.5.1.10 */ + 15); | ||
203 | 218 | ||
204 | temp = ohci_readl (ohci, &ohci->regs->control); | 219 | temp = ohci_readl (ohci, &ohci->regs->control); |
205 | temp &= OHCI_CTRL_HCFS; | 220 | temp &= OHCI_CTRL_HCFS; |
@@ -273,28 +288,10 @@ static int ohci_hub_resume (struct usb_hcd *hcd) | |||
273 | (void) ohci_readl (ohci, &ohci->regs->control); | 288 | (void) ohci_readl (ohci, &ohci->regs->control); |
274 | } | 289 | } |
275 | 290 | ||
276 | hcd->state = HC_STATE_RUNNING; | ||
277 | return 0; | 291 | return 0; |
278 | } | 292 | } |
279 | 293 | ||
280 | static void ohci_rh_resume (void *_hcd) | 294 | #endif /* CONFIG_PM */ |
281 | { | ||
282 | struct usb_hcd *hcd = _hcd; | ||
283 | |||
284 | usb_lock_device (hcd->self.root_hub); | ||
285 | (void) ohci_hub_resume (hcd); | ||
286 | usb_unlock_device (hcd->self.root_hub); | ||
287 | } | ||
288 | |||
289 | #else | ||
290 | |||
291 | static void ohci_rh_resume (void *_hcd) | ||
292 | { | ||
293 | struct ohci_hcd *ohci = hcd_to_ohci (_hcd); | ||
294 | ohci_dbg(ohci, "rh_resume ??\n"); | ||
295 | } | ||
296 | |||
297 | #endif /* CONFIG_USB_SUSPEND || CONFIG_PM */ | ||
298 | 295 | ||
299 | /*-------------------------------------------------------------------------*/ | 296 | /*-------------------------------------------------------------------------*/ |
300 | 297 | ||
@@ -313,8 +310,8 @@ ohci_hub_status_data (struct usb_hcd *hcd, char *buf) | |||
313 | /* handle autosuspended root: finish resuming before | 310 | /* handle autosuspended root: finish resuming before |
314 | * letting khubd or root hub timer see state changes. | 311 | * letting khubd or root hub timer see state changes. |
315 | */ | 312 | */ |
316 | if ((ohci->hc_control & OHCI_CTRL_HCFS) != OHCI_USB_OPER | 313 | if (unlikely((ohci->hc_control & OHCI_CTRL_HCFS) != OHCI_USB_OPER |
317 | || !HC_IS_RUNNING(hcd->state)) { | 314 | || !HC_IS_RUNNING(hcd->state))) { |
318 | can_suspend = 0; | 315 | can_suspend = 0; |
319 | goto done; | 316 | goto done; |
320 | } | 317 | } |
@@ -367,7 +364,6 @@ done: | |||
367 | #ifdef CONFIG_PM | 364 | #ifdef CONFIG_PM |
368 | /* save power by suspending idle root hubs; | 365 | /* save power by suspending idle root hubs; |
369 | * INTR_RD wakes us when there's work | 366 | * INTR_RD wakes us when there's work |
370 | * NOTE: if we can do this, we don't need a root hub timer! | ||
371 | */ | 367 | */ |
372 | if (can_suspend | 368 | if (can_suspend |
373 | && !changed | 369 | && !changed |
@@ -379,8 +375,7 @@ done: | |||
379 | && usb_trylock_device (hcd->self.root_hub) | 375 | && usb_trylock_device (hcd->self.root_hub) |
380 | ) { | 376 | ) { |
381 | ohci_vdbg (ohci, "autosuspend\n"); | 377 | ohci_vdbg (ohci, "autosuspend\n"); |
382 | (void) ohci_hub_suspend (hcd); | 378 | (void) ohci_bus_suspend (hcd); |
383 | hcd->state = HC_STATE_RUNNING; | ||
384 | usb_unlock_device (hcd->self.root_hub); | 379 | usb_unlock_device (hcd->self.root_hub); |
385 | } | 380 | } |
386 | #endif | 381 | #endif |
@@ -526,6 +521,9 @@ static int ohci_hub_control ( | |||
526 | u32 temp; | 521 | u32 temp; |
527 | int retval = 0; | 522 | int retval = 0; |
528 | 523 | ||
524 | if (unlikely(!test_bit(HCD_FLAG_HW_ACCESSIBLE, &hcd->flags))) | ||
525 | return -ESHUTDOWN; | ||
526 | |||
529 | switch (typeReq) { | 527 | switch (typeReq) { |
530 | case ClearHubFeature: | 528 | case ClearHubFeature: |
531 | switch (wValue) { | 529 | switch (wValue) { |
@@ -554,7 +552,7 @@ static int ohci_hub_control ( | |||
554 | temp = RH_PS_POCI; | 552 | temp = RH_PS_POCI; |
555 | if ((ohci->hc_control & OHCI_CTRL_HCFS) | 553 | if ((ohci->hc_control & OHCI_CTRL_HCFS) |
556 | != OHCI_USB_OPER) | 554 | != OHCI_USB_OPER) |
557 | schedule_work (&ohci->rh_resume); | 555 | usb_hcd_resume_root_hub(hcd); |
558 | break; | 556 | break; |
559 | case USB_PORT_FEAT_C_SUSPEND: | 557 | case USB_PORT_FEAT_C_SUSPEND: |
560 | temp = RH_PS_PSSC; | 558 | temp = RH_PS_PSSC; |
diff --git a/drivers/usb/host/ohci-lh7a404.c b/drivers/usb/host/ohci-lh7a404.c index 817620d73841..3959ccc88332 100644 --- a/drivers/usb/host/ohci-lh7a404.c +++ b/drivers/usb/host/ohci-lh7a404.c | |||
@@ -16,9 +16,9 @@ | |||
16 | * This file is licenced under the GPL. | 16 | * This file is licenced under the GPL. |
17 | */ | 17 | */ |
18 | 18 | ||
19 | #include <linux/platform_device.h> | ||
20 | |||
19 | #include <asm/hardware.h> | 21 | #include <asm/hardware.h> |
20 | #include <asm/mach-types.h> | ||
21 | #include <asm/arch/hardware.h> | ||
22 | 22 | ||
23 | 23 | ||
24 | extern int usb_disabled(void); | 24 | extern int usb_disabled(void); |
@@ -195,13 +195,17 @@ static const struct hc_driver ohci_lh7a404_hc_driver = { | |||
195 | */ | 195 | */ |
196 | .hub_status_data = ohci_hub_status_data, | 196 | .hub_status_data = ohci_hub_status_data, |
197 | .hub_control = ohci_hub_control, | 197 | .hub_control = ohci_hub_control, |
198 | #ifdef CONFIG_PM | ||
199 | .bus_suspend = ohci_bus_suspend, | ||
200 | .bus_resume = ohci_bus_resume, | ||
201 | #endif | ||
202 | .start_port_reset = ohci_start_port_reset, | ||
198 | }; | 203 | }; |
199 | 204 | ||
200 | /*-------------------------------------------------------------------------*/ | 205 | /*-------------------------------------------------------------------------*/ |
201 | 206 | ||
202 | static int ohci_hcd_lh7a404_drv_probe(struct device *dev) | 207 | static int ohci_hcd_lh7a404_drv_probe(struct platform_device *pdev) |
203 | { | 208 | { |
204 | struct platform_device *pdev = to_platform_device(dev); | ||
205 | int ret; | 209 | int ret; |
206 | 210 | ||
207 | pr_debug ("In ohci_hcd_lh7a404_drv_probe"); | 211 | pr_debug ("In ohci_hcd_lh7a404_drv_probe"); |
@@ -213,39 +217,38 @@ static int ohci_hcd_lh7a404_drv_probe(struct device *dev) | |||
213 | return ret; | 217 | return ret; |
214 | } | 218 | } |
215 | 219 | ||
216 | static int ohci_hcd_lh7a404_drv_remove(struct device *dev) | 220 | static int ohci_hcd_lh7a404_drv_remove(struct platform_device *pdev) |
217 | { | 221 | { |
218 | struct platform_device *pdev = to_platform_device(dev); | 222 | struct usb_hcd *hcd = platform_get_drvdata(pdev); |
219 | struct usb_hcd *hcd = dev_get_drvdata(dev); | ||
220 | 223 | ||
221 | usb_hcd_lh7a404_remove(hcd, pdev); | 224 | usb_hcd_lh7a404_remove(hcd, pdev); |
222 | return 0; | 225 | return 0; |
223 | } | 226 | } |
224 | /*TBD*/ | 227 | /*TBD*/ |
225 | /*static int ohci_hcd_lh7a404_drv_suspend(struct device *dev) | 228 | /*static int ohci_hcd_lh7a404_drv_suspend(struct platform_device *dev) |
226 | { | 229 | { |
227 | struct platform_device *pdev = to_platform_device(dev); | 230 | struct usb_hcd *hcd = platform_get_drvdata(dev); |
228 | struct usb_hcd *hcd = dev_get_drvdata(dev); | ||
229 | 231 | ||
230 | return 0; | 232 | return 0; |
231 | } | 233 | } |
232 | static int ohci_hcd_lh7a404_drv_resume(struct device *dev) | 234 | static int ohci_hcd_lh7a404_drv_resume(struct platform_device *dev) |
233 | { | 235 | { |
234 | struct platform_device *pdev = to_platform_device(dev); | 236 | struct usb_hcd *hcd = platform_get_drvdata(dev); |
235 | struct usb_hcd *hcd = dev_get_drvdata(dev); | ||
236 | 237 | ||
237 | 238 | ||
238 | return 0; | 239 | return 0; |
239 | } | 240 | } |
240 | */ | 241 | */ |
241 | 242 | ||
242 | static struct device_driver ohci_hcd_lh7a404_driver = { | 243 | static struct platform_driver ohci_hcd_lh7a404_driver = { |
243 | .name = "lh7a404-ohci", | ||
244 | .bus = &platform_bus_type, | ||
245 | .probe = ohci_hcd_lh7a404_drv_probe, | 244 | .probe = ohci_hcd_lh7a404_drv_probe, |
246 | .remove = ohci_hcd_lh7a404_drv_remove, | 245 | .remove = ohci_hcd_lh7a404_drv_remove, |
247 | /*.suspend = ohci_hcd_lh7a404_drv_suspend, */ | 246 | /*.suspend = ohci_hcd_lh7a404_drv_suspend, */ |
248 | /*.resume = ohci_hcd_lh7a404_drv_resume, */ | 247 | /*.resume = ohci_hcd_lh7a404_drv_resume, */ |
248 | .driver = { | ||
249 | .name = "lh7a404-ohci", | ||
250 | .owner = THIS_MODULE, | ||
251 | }, | ||
249 | }; | 252 | }; |
250 | 253 | ||
251 | static int __init ohci_hcd_lh7a404_init (void) | 254 | static int __init ohci_hcd_lh7a404_init (void) |
@@ -254,12 +257,12 @@ static int __init ohci_hcd_lh7a404_init (void) | |||
254 | pr_debug ("block sizes: ed %d td %d\n", | 257 | pr_debug ("block sizes: ed %d td %d\n", |
255 | sizeof (struct ed), sizeof (struct td)); | 258 | sizeof (struct ed), sizeof (struct td)); |
256 | 259 | ||
257 | return driver_register(&ohci_hcd_lh7a404_driver); | 260 | return platform_driver_register(&ohci_hcd_lh7a404_driver); |
258 | } | 261 | } |
259 | 262 | ||
260 | static void __exit ohci_hcd_lh7a404_cleanup (void) | 263 | static void __exit ohci_hcd_lh7a404_cleanup (void) |
261 | { | 264 | { |
262 | driver_unregister(&ohci_hcd_lh7a404_driver); | 265 | platform_driver_unregister(&ohci_hcd_lh7a404_driver); |
263 | } | 266 | } |
264 | 267 | ||
265 | module_init (ohci_hcd_lh7a404_init); | 268 | module_init (ohci_hcd_lh7a404_init); |
diff --git a/drivers/usb/host/ohci-mem.c b/drivers/usb/host/ohci-mem.c index fd3c4d3714bd..bfbe328a4788 100644 --- a/drivers/usb/host/ohci-mem.c +++ b/drivers/usb/host/ohci-mem.c | |||
@@ -28,7 +28,6 @@ static void ohci_hcd_init (struct ohci_hcd *ohci) | |||
28 | ohci->next_statechange = jiffies; | 28 | ohci->next_statechange = jiffies; |
29 | spin_lock_init (&ohci->lock); | 29 | spin_lock_init (&ohci->lock); |
30 | INIT_LIST_HEAD (&ohci->pending); | 30 | INIT_LIST_HEAD (&ohci->pending); |
31 | INIT_WORK (&ohci->rh_resume, ohci_rh_resume, ohci_to_hcd(ohci)); | ||
32 | ohci->reboot_notifier.notifier_call = ohci_reboot; | 31 | ohci->reboot_notifier.notifier_call = ohci_reboot; |
33 | } | 32 | } |
34 | 33 | ||
@@ -84,7 +83,7 @@ dma_to_td (struct ohci_hcd *hc, dma_addr_t td_dma) | |||
84 | 83 | ||
85 | /* TDs ... */ | 84 | /* TDs ... */ |
86 | static struct td * | 85 | static struct td * |
87 | td_alloc (struct ohci_hcd *hc, unsigned mem_flags) | 86 | td_alloc (struct ohci_hcd *hc, gfp_t mem_flags) |
88 | { | 87 | { |
89 | dma_addr_t dma; | 88 | dma_addr_t dma; |
90 | struct td *td; | 89 | struct td *td; |
@@ -118,7 +117,7 @@ td_free (struct ohci_hcd *hc, struct td *td) | |||
118 | 117 | ||
119 | /* EDs ... */ | 118 | /* EDs ... */ |
120 | static struct ed * | 119 | static struct ed * |
121 | ed_alloc (struct ohci_hcd *hc, unsigned mem_flags) | 120 | ed_alloc (struct ohci_hcd *hc, gfp_t mem_flags) |
122 | { | 121 | { |
123 | dma_addr_t dma; | 122 | dma_addr_t dma; |
124 | struct ed *ed; | 123 | struct ed *ed; |
diff --git a/drivers/usb/host/ohci-omap.c b/drivers/usb/host/ohci-omap.c index 5cde76faab93..c9e29d808711 100644 --- a/drivers/usb/host/ohci-omap.c +++ b/drivers/usb/host/ohci-omap.c | |||
@@ -14,11 +14,14 @@ | |||
14 | * This file is licenced under the GPL. | 14 | * This file is licenced under the GPL. |
15 | */ | 15 | */ |
16 | 16 | ||
17 | #include <linux/signal.h> /* SA_INTERRUPT */ | ||
18 | #include <linux/jiffies.h> | ||
19 | #include <linux/platform_device.h> | ||
20 | |||
17 | #include <asm/hardware.h> | 21 | #include <asm/hardware.h> |
18 | #include <asm/io.h> | 22 | #include <asm/io.h> |
19 | #include <asm/mach-types.h> | 23 | #include <asm/mach-types.h> |
20 | 24 | ||
21 | #include <asm/arch/hardware.h> | ||
22 | #include <asm/arch/mux.h> | 25 | #include <asm/arch/mux.h> |
23 | #include <asm/arch/irqs.h> | 26 | #include <asm/arch/irqs.h> |
24 | #include <asm/arch/gpio.h> | 27 | #include <asm/arch/gpio.h> |
@@ -421,33 +424,31 @@ static const struct hc_driver ohci_omap_hc_driver = { | |||
421 | */ | 424 | */ |
422 | .hub_status_data = ohci_hub_status_data, | 425 | .hub_status_data = ohci_hub_status_data, |
423 | .hub_control = ohci_hub_control, | 426 | .hub_control = ohci_hub_control, |
424 | #ifdef CONFIG_USB_SUSPEND | 427 | #ifdef CONFIG_PM |
425 | .hub_suspend = ohci_hub_suspend, | 428 | .bus_suspend = ohci_bus_suspend, |
426 | .hub_resume = ohci_hub_resume, | 429 | .bus_resume = ohci_bus_resume, |
427 | #endif | 430 | #endif |
428 | .start_port_reset = ohci_start_port_reset, | 431 | .start_port_reset = ohci_start_port_reset, |
429 | }; | 432 | }; |
430 | 433 | ||
431 | /*-------------------------------------------------------------------------*/ | 434 | /*-------------------------------------------------------------------------*/ |
432 | 435 | ||
433 | static int ohci_hcd_omap_drv_probe(struct device *dev) | 436 | static int ohci_hcd_omap_drv_probe(struct platform_device *dev) |
434 | { | 437 | { |
435 | return usb_hcd_omap_probe(&ohci_omap_hc_driver, | 438 | return usb_hcd_omap_probe(&ohci_omap_hc_driver, dev); |
436 | to_platform_device(dev)); | ||
437 | } | 439 | } |
438 | 440 | ||
439 | static int ohci_hcd_omap_drv_remove(struct device *dev) | 441 | static int ohci_hcd_omap_drv_remove(struct platform_device *dev) |
440 | { | 442 | { |
441 | struct platform_device *pdev = to_platform_device(dev); | 443 | struct usb_hcd *hcd = platform_get_drvdata(dev); |
442 | struct usb_hcd *hcd = dev_get_drvdata(dev); | ||
443 | struct ohci_hcd *ohci = hcd_to_ohci (hcd); | 444 | struct ohci_hcd *ohci = hcd_to_ohci (hcd); |
444 | 445 | ||
445 | usb_hcd_omap_remove(hcd, pdev); | 446 | usb_hcd_omap_remove(hcd, dev); |
446 | if (ohci->transceiver) { | 447 | if (ohci->transceiver) { |
447 | (void) otg_set_host(ohci->transceiver, 0); | 448 | (void) otg_set_host(ohci->transceiver, 0); |
448 | put_device(ohci->transceiver->dev); | 449 | put_device(ohci->transceiver->dev); |
449 | } | 450 | } |
450 | dev_set_drvdata(dev, NULL); | 451 | platform_set_drvdata(dev, NULL); |
451 | 452 | ||
452 | return 0; | 453 | return 0; |
453 | } | 454 | } |
@@ -456,50 +457,32 @@ static int ohci_hcd_omap_drv_remove(struct device *dev) | |||
456 | 457 | ||
457 | #ifdef CONFIG_PM | 458 | #ifdef CONFIG_PM |
458 | 459 | ||
459 | static int ohci_omap_suspend(struct device *dev, pm_message_t message, u32 level) | 460 | static int ohci_omap_suspend(struct platform_device *dev, pm_message_t message) |
460 | { | 461 | { |
461 | struct ohci_hcd *ohci = hcd_to_ohci(dev_get_drvdata(dev)); | 462 | struct ohci_hcd *ohci = hcd_to_ohci(platform_get_drvdata(dev)); |
462 | int status = -EINVAL; | 463 | |
463 | 464 | if (time_before(jiffies, ohci->next_statechange)) | |
464 | if (level != SUSPEND_POWER_DOWN) | 465 | msleep(5); |
465 | return 0; | 466 | ohci->next_statechange = jiffies; |
466 | 467 | ||
467 | down(&ohci_to_hcd(ohci)->self.root_hub->serialize); | 468 | omap_ohci_clock_power(0); |
468 | status = ohci_hub_suspend(ohci_to_hcd(ohci)); | 469 | ohci_to_hcd(ohci)->state = HC_STATE_SUSPENDED; |
469 | if (status == 0) { | 470 | dev->power.power_state = PMSG_SUSPEND; |
470 | omap_ohci_clock_power(0); | 471 | return 0; |
471 | ohci_to_hcd(ohci)->self.root_hub->state = | ||
472 | USB_STATE_SUSPENDED; | ||
473 | ohci_to_hcd(ohci)->state = HC_STATE_SUSPENDED; | ||
474 | dev->power.power_state = PMSG_SUSPEND; | ||
475 | } | ||
476 | up(&ohci_to_hcd(ohci)->self.root_hub->serialize); | ||
477 | return status; | ||
478 | } | 472 | } |
479 | 473 | ||
480 | static int ohci_omap_resume(struct device *dev, u32 level) | 474 | static int ohci_omap_resume(struct platform_device *dev) |
481 | { | 475 | { |
482 | struct ohci_hcd *ohci = hcd_to_ohci(dev_get_drvdata(dev)); | 476 | struct ohci_hcd *ohci = hcd_to_ohci(platform_get_drvdata(dev)); |
483 | int status = 0; | ||
484 | |||
485 | if (level != RESUME_POWER_ON) | ||
486 | return 0; | ||
487 | 477 | ||
488 | if (time_before(jiffies, ohci->next_statechange)) | 478 | if (time_before(jiffies, ohci->next_statechange)) |
489 | msleep(5); | 479 | msleep(5); |
490 | ohci->next_statechange = jiffies; | 480 | ohci->next_statechange = jiffies; |
481 | |||
491 | omap_ohci_clock_power(1); | 482 | omap_ohci_clock_power(1); |
492 | #ifdef CONFIG_USB_SUSPEND | 483 | dev->power.power_state = PMSG_ON; |
493 | /* get extra cleanup even if remote wakeup isn't in use */ | 484 | usb_hcd_resume_root_hub(dev_get_drvdata(dev)); |
494 | status = usb_resume_device(ohci_to_hcd(ohci)->self.root_hub); | 485 | return 0; |
495 | #else | ||
496 | down(&ohci_to_hcd(ohci)->self.root_hub->serialize); | ||
497 | status = ohci_hub_resume(ohci_to_hcd(ohci)); | ||
498 | up(&ohci_to_hcd(ohci)->self.root_hub->serialize); | ||
499 | #endif | ||
500 | if (status == 0) | ||
501 | dev->power.power_state = PMSG_ON; | ||
502 | return status; | ||
503 | } | 486 | } |
504 | 487 | ||
505 | #endif | 488 | #endif |
@@ -509,15 +492,17 @@ static int ohci_omap_resume(struct device *dev, u32 level) | |||
509 | /* | 492 | /* |
510 | * Driver definition to register with the OMAP bus | 493 | * Driver definition to register with the OMAP bus |
511 | */ | 494 | */ |
512 | static struct device_driver ohci_hcd_omap_driver = { | 495 | static struct platform_driver ohci_hcd_omap_driver = { |
513 | .name = "ohci", | ||
514 | .bus = &platform_bus_type, | ||
515 | .probe = ohci_hcd_omap_drv_probe, | 496 | .probe = ohci_hcd_omap_drv_probe, |
516 | .remove = ohci_hcd_omap_drv_remove, | 497 | .remove = ohci_hcd_omap_drv_remove, |
517 | #ifdef CONFIG_PM | 498 | #ifdef CONFIG_PM |
518 | .suspend = ohci_omap_suspend, | 499 | .suspend = ohci_omap_suspend, |
519 | .resume = ohci_omap_resume, | 500 | .resume = ohci_omap_resume, |
520 | #endif | 501 | #endif |
502 | .driver = { | ||
503 | .owner = THIS_MODULE, | ||
504 | .name = "ohci", | ||
505 | }, | ||
521 | }; | 506 | }; |
522 | 507 | ||
523 | static int __init ohci_hcd_omap_init (void) | 508 | static int __init ohci_hcd_omap_init (void) |
@@ -529,12 +514,12 @@ static int __init ohci_hcd_omap_init (void) | |||
529 | pr_debug("%s: block sizes: ed %Zd td %Zd\n", hcd_name, | 514 | pr_debug("%s: block sizes: ed %Zd td %Zd\n", hcd_name, |
530 | sizeof (struct ed), sizeof (struct td)); | 515 | sizeof (struct ed), sizeof (struct td)); |
531 | 516 | ||
532 | return driver_register(&ohci_hcd_omap_driver); | 517 | return platform_driver_register(&ohci_hcd_omap_driver); |
533 | } | 518 | } |
534 | 519 | ||
535 | static void __exit ohci_hcd_omap_cleanup (void) | 520 | static void __exit ohci_hcd_omap_cleanup (void) |
536 | { | 521 | { |
537 | driver_unregister(&ohci_hcd_omap_driver); | 522 | platform_driver_unregister(&ohci_hcd_omap_driver); |
538 | } | 523 | } |
539 | 524 | ||
540 | module_init (ohci_hcd_omap_init); | 525 | module_init (ohci_hcd_omap_init); |
diff --git a/drivers/usb/host/ohci-pci.c b/drivers/usb/host/ohci-pci.c index eede6be098d2..1b09dde068e1 100644 --- a/drivers/usb/host/ohci-pci.c +++ b/drivers/usb/host/ohci-pci.c | |||
@@ -14,13 +14,6 @@ | |||
14 | * This file is licenced under the GPL. | 14 | * This file is licenced under the GPL. |
15 | */ | 15 | */ |
16 | 16 | ||
17 | #ifdef CONFIG_PPC_PMAC | ||
18 | #include <asm/machdep.h> | ||
19 | #include <asm/pmac_feature.h> | ||
20 | #include <asm/pci-bridge.h> | ||
21 | #include <asm/prom.h> | ||
22 | #endif | ||
23 | |||
24 | #ifndef CONFIG_PCI | 17 | #ifndef CONFIG_PCI |
25 | #error "This file is PCI bus glue. CONFIG_PCI must be defined." | 18 | #error "This file is PCI bus glue. CONFIG_PCI must be defined." |
26 | #endif | 19 | #endif |
@@ -112,66 +105,38 @@ ohci_pci_start (struct usb_hcd *hcd) | |||
112 | 105 | ||
113 | static int ohci_pci_suspend (struct usb_hcd *hcd, pm_message_t message) | 106 | static int ohci_pci_suspend (struct usb_hcd *hcd, pm_message_t message) |
114 | { | 107 | { |
115 | struct ohci_hcd *ohci = hcd_to_ohci (hcd); | 108 | struct ohci_hcd *ohci = hcd_to_ohci (hcd); |
116 | 109 | unsigned long flags; | |
117 | /* suspend root hub, hoping it keeps power during suspend */ | 110 | int rc = 0; |
118 | if (time_before (jiffies, ohci->next_statechange)) | 111 | |
119 | msleep (100); | 112 | /* Root hub was already suspended. Disable irq emission and |
120 | 113 | * mark HW unaccessible, bail out if RH has been resumed. Use | |
121 | #ifdef CONFIG_USB_SUSPEND | 114 | * the spinlock to properly synchronize with possible pending |
122 | (void) usb_suspend_device (hcd->self.root_hub, message); | 115 | * RH suspend or resume activity. |
123 | #else | 116 | * |
124 | usb_lock_device (hcd->self.root_hub); | 117 | * This is still racy as hcd->state is manipulated outside of |
125 | (void) ohci_hub_suspend (hcd); | 118 | * any locks =P But that will be a different fix. |
126 | usb_unlock_device (hcd->self.root_hub); | 119 | */ |
127 | #endif | 120 | spin_lock_irqsave (&ohci->lock, flags); |
128 | 121 | if (hcd->state != HC_STATE_SUSPENDED) { | |
129 | /* let things settle down a bit */ | 122 | rc = -EINVAL; |
130 | msleep (100); | 123 | goto bail; |
131 | |||
132 | #ifdef CONFIG_PPC_PMAC | ||
133 | if (_machine == _MACH_Pmac) { | ||
134 | struct device_node *of_node; | ||
135 | |||
136 | /* Disable USB PAD & cell clock */ | ||
137 | of_node = pci_device_to_OF_node (to_pci_dev(hcd->self.controller)); | ||
138 | if (of_node) | ||
139 | pmac_call_feature(PMAC_FTR_USB_ENABLE, of_node, 0, 0); | ||
140 | } | 124 | } |
141 | #endif /* CONFIG_PPC_PMAC */ | 125 | ohci_writel(ohci, OHCI_INTR_MIE, &ohci->regs->intrdisable); |
142 | return 0; | 126 | (void)ohci_readl(ohci, &ohci->regs->intrdisable); |
127 | clear_bit(HCD_FLAG_HW_ACCESSIBLE, &hcd->flags); | ||
128 | bail: | ||
129 | spin_unlock_irqrestore (&ohci->lock, flags); | ||
130 | |||
131 | return rc; | ||
143 | } | 132 | } |
144 | 133 | ||
145 | 134 | ||
146 | static int ohci_pci_resume (struct usb_hcd *hcd) | 135 | static int ohci_pci_resume (struct usb_hcd *hcd) |
147 | { | 136 | { |
148 | struct ohci_hcd *ohci = hcd_to_ohci (hcd); | 137 | set_bit(HCD_FLAG_HW_ACCESSIBLE, &hcd->flags); |
149 | int retval = 0; | 138 | usb_hcd_resume_root_hub(hcd); |
150 | 139 | return 0; | |
151 | #ifdef CONFIG_PPC_PMAC | ||
152 | if (_machine == _MACH_Pmac) { | ||
153 | struct device_node *of_node; | ||
154 | |||
155 | /* Re-enable USB PAD & cell clock */ | ||
156 | of_node = pci_device_to_OF_node (to_pci_dev(hcd->self.controller)); | ||
157 | if (of_node) | ||
158 | pmac_call_feature (PMAC_FTR_USB_ENABLE, of_node, 0, 1); | ||
159 | } | ||
160 | #endif /* CONFIG_PPC_PMAC */ | ||
161 | |||
162 | /* resume root hub */ | ||
163 | if (time_before (jiffies, ohci->next_statechange)) | ||
164 | msleep (100); | ||
165 | #ifdef CONFIG_USB_SUSPEND | ||
166 | /* get extra cleanup even if remote wakeup isn't in use */ | ||
167 | retval = usb_resume_device (hcd->self.root_hub); | ||
168 | #else | ||
169 | usb_lock_device (hcd->self.root_hub); | ||
170 | retval = ohci_hub_resume (hcd); | ||
171 | usb_unlock_device (hcd->self.root_hub); | ||
172 | #endif | ||
173 | |||
174 | return retval; | ||
175 | } | 140 | } |
176 | 141 | ||
177 | #endif /* CONFIG_PM */ | 142 | #endif /* CONFIG_PM */ |
@@ -218,9 +183,9 @@ static const struct hc_driver ohci_pci_hc_driver = { | |||
218 | */ | 183 | */ |
219 | .hub_status_data = ohci_hub_status_data, | 184 | .hub_status_data = ohci_hub_status_data, |
220 | .hub_control = ohci_hub_control, | 185 | .hub_control = ohci_hub_control, |
221 | #ifdef CONFIG_USB_SUSPEND | 186 | #ifdef CONFIG_PM |
222 | .hub_suspend = ohci_hub_suspend, | 187 | .bus_suspend = ohci_bus_suspend, |
223 | .hub_resume = ohci_hub_resume, | 188 | .bus_resume = ohci_bus_resume, |
224 | #endif | 189 | #endif |
225 | .start_port_reset = ohci_start_port_reset, | 190 | .start_port_reset = ohci_start_port_reset, |
226 | }; | 191 | }; |
diff --git a/drivers/usb/host/ohci-ppc-soc.c b/drivers/usb/host/ohci-ppc-soc.c index 251533363028..2ec6a78bd65e 100644 --- a/drivers/usb/host/ohci-ppc-soc.c +++ b/drivers/usb/host/ohci-ppc-soc.c | |||
@@ -14,6 +14,8 @@ | |||
14 | * This file is licenced under the GPL. | 14 | * This file is licenced under the GPL. |
15 | */ | 15 | */ |
16 | 16 | ||
17 | #include <linux/platform_device.h> | ||
18 | |||
17 | /* configure so an HC device and id are always provided */ | 19 | /* configure so an HC device and id are always provided */ |
18 | /* always called with process context; sleeping is OK */ | 20 | /* always called with process context; sleeping is OK */ |
19 | 21 | ||
@@ -163,16 +165,15 @@ static const struct hc_driver ohci_ppc_soc_hc_driver = { | |||
163 | */ | 165 | */ |
164 | .hub_status_data = ohci_hub_status_data, | 166 | .hub_status_data = ohci_hub_status_data, |
165 | .hub_control = ohci_hub_control, | 167 | .hub_control = ohci_hub_control, |
166 | #ifdef CONFIG_USB_SUSPEND | 168 | #ifdef CONFIG_PM |
167 | .hub_suspend = ohci_hub_suspend, | 169 | .bus_suspend = ohci_bus_suspend, |
168 | .hub_resume = ohci_hub_resume, | 170 | .bus_resume = ohci_bus_resume, |
169 | #endif | 171 | #endif |
170 | .start_port_reset = ohci_start_port_reset, | 172 | .start_port_reset = ohci_start_port_reset, |
171 | }; | 173 | }; |
172 | 174 | ||
173 | static int ohci_hcd_ppc_soc_drv_probe(struct device *dev) | 175 | static int ohci_hcd_ppc_soc_drv_probe(struct platform_device *pdev) |
174 | { | 176 | { |
175 | struct platform_device *pdev = to_platform_device(dev); | ||
176 | int ret; | 177 | int ret; |
177 | 178 | ||
178 | if (usb_disabled()) | 179 | if (usb_disabled()) |
@@ -182,24 +183,25 @@ static int ohci_hcd_ppc_soc_drv_probe(struct device *dev) | |||
182 | return ret; | 183 | return ret; |
183 | } | 184 | } |
184 | 185 | ||
185 | static int ohci_hcd_ppc_soc_drv_remove(struct device *dev) | 186 | static int ohci_hcd_ppc_soc_drv_remove(struct platform_device *pdev) |
186 | { | 187 | { |
187 | struct platform_device *pdev = to_platform_device(dev); | 188 | struct usb_hcd *hcd = platform_get_drvdata(pdev); |
188 | struct usb_hcd *hcd = dev_get_drvdata(dev); | ||
189 | 189 | ||
190 | usb_hcd_ppc_soc_remove(hcd, pdev); | 190 | usb_hcd_ppc_soc_remove(hcd, pdev); |
191 | return 0; | 191 | return 0; |
192 | } | 192 | } |
193 | 193 | ||
194 | static struct device_driver ohci_hcd_ppc_soc_driver = { | 194 | static struct platform_driver ohci_hcd_ppc_soc_driver = { |
195 | .name = "ppc-soc-ohci", | ||
196 | .bus = &platform_bus_type, | ||
197 | .probe = ohci_hcd_ppc_soc_drv_probe, | 195 | .probe = ohci_hcd_ppc_soc_drv_probe, |
198 | .remove = ohci_hcd_ppc_soc_drv_remove, | 196 | .remove = ohci_hcd_ppc_soc_drv_remove, |
199 | #if defined(CONFIG_USB_SUSPEND) || defined(CONFIG_PM) | 197 | #ifdef CONFIG_PM |
200 | /*.suspend = ohci_hcd_ppc_soc_drv_suspend,*/ | 198 | /*.suspend = ohci_hcd_ppc_soc_drv_suspend,*/ |
201 | /*.resume = ohci_hcd_ppc_soc_drv_resume,*/ | 199 | /*.resume = ohci_hcd_ppc_soc_drv_resume,*/ |
202 | #endif | 200 | #endif |
201 | .driver = { | ||
202 | .name = "ppc-soc-ohci", | ||
203 | .owner = THIS_MODULE, | ||
204 | }, | ||
203 | }; | 205 | }; |
204 | 206 | ||
205 | static int __init ohci_hcd_ppc_soc_init(void) | 207 | static int __init ohci_hcd_ppc_soc_init(void) |
@@ -208,12 +210,12 @@ static int __init ohci_hcd_ppc_soc_init(void) | |||
208 | pr_debug("block sizes: ed %d td %d\n", sizeof(struct ed), | 210 | pr_debug("block sizes: ed %d td %d\n", sizeof(struct ed), |
209 | sizeof(struct td)); | 211 | sizeof(struct td)); |
210 | 212 | ||
211 | return driver_register(&ohci_hcd_ppc_soc_driver); | 213 | return platform_driver_register(&ohci_hcd_ppc_soc_driver); |
212 | } | 214 | } |
213 | 215 | ||
214 | static void __exit ohci_hcd_ppc_soc_cleanup(void) | 216 | static void __exit ohci_hcd_ppc_soc_cleanup(void) |
215 | { | 217 | { |
216 | driver_unregister(&ohci_hcd_ppc_soc_driver); | 218 | platform_driver_unregister(&ohci_hcd_ppc_soc_driver); |
217 | } | 219 | } |
218 | 220 | ||
219 | module_init(ohci_hcd_ppc_soc_init); | 221 | module_init(ohci_hcd_ppc_soc_init); |
diff --git a/drivers/usb/host/ohci-pxa27x.c b/drivers/usb/host/ohci-pxa27x.c index 2fdb262d4726..9d65ec307990 100644 --- a/drivers/usb/host/ohci-pxa27x.c +++ b/drivers/usb/host/ohci-pxa27x.c | |||
@@ -20,6 +20,9 @@ | |||
20 | */ | 20 | */ |
21 | 21 | ||
22 | #include <linux/device.h> | 22 | #include <linux/device.h> |
23 | #include <linux/signal.h> | ||
24 | #include <linux/platform_device.h> | ||
25 | |||
23 | #include <asm/mach-types.h> | 26 | #include <asm/mach-types.h> |
24 | #include <asm/hardware.h> | 27 | #include <asm/hardware.h> |
25 | #include <asm/arch/pxa-regs.h> | 28 | #include <asm/arch/pxa-regs.h> |
@@ -278,17 +281,17 @@ static const struct hc_driver ohci_pxa27x_hc_driver = { | |||
278 | */ | 281 | */ |
279 | .hub_status_data = ohci_hub_status_data, | 282 | .hub_status_data = ohci_hub_status_data, |
280 | .hub_control = ohci_hub_control, | 283 | .hub_control = ohci_hub_control, |
281 | #ifdef CONFIG_USB_SUSPEND | 284 | #ifdef CONFIG_PM |
282 | .hub_suspend = ohci_hub_suspend, | 285 | .bus_suspend = ohci_bus_suspend, |
283 | .hub_resume = ohci_hub_resume, | 286 | .bus_resume = ohci_bus_resume, |
284 | #endif | 287 | #endif |
288 | .start_port_reset = ohci_start_port_reset, | ||
285 | }; | 289 | }; |
286 | 290 | ||
287 | /*-------------------------------------------------------------------------*/ | 291 | /*-------------------------------------------------------------------------*/ |
288 | 292 | ||
289 | static int ohci_hcd_pxa27x_drv_probe(struct device *dev) | 293 | static int ohci_hcd_pxa27x_drv_probe(struct platform_device *pdev) |
290 | { | 294 | { |
291 | struct platform_device *pdev = to_platform_device(dev); | ||
292 | int ret; | 295 | int ret; |
293 | 296 | ||
294 | pr_debug ("In ohci_hcd_pxa27x_drv_probe"); | 297 | pr_debug ("In ohci_hcd_pxa27x_drv_probe"); |
@@ -300,41 +303,39 @@ static int ohci_hcd_pxa27x_drv_probe(struct device *dev) | |||
300 | return ret; | 303 | return ret; |
301 | } | 304 | } |
302 | 305 | ||
303 | static int ohci_hcd_pxa27x_drv_remove(struct device *dev) | 306 | static int ohci_hcd_pxa27x_drv_remove(struct platform_device *pdev) |
304 | { | 307 | { |
305 | struct platform_device *pdev = to_platform_device(dev); | 308 | struct usb_hcd *hcd = platform_get_drvdata(pdev); |
306 | struct usb_hcd *hcd = dev_get_drvdata(dev); | ||
307 | 309 | ||
308 | usb_hcd_pxa27x_remove(hcd, pdev); | 310 | usb_hcd_pxa27x_remove(hcd, pdev); |
309 | return 0; | 311 | return 0; |
310 | } | 312 | } |
311 | 313 | ||
312 | static int ohci_hcd_pxa27x_drv_suspend(struct device *dev, pm_message_t state, u32 level) | 314 | static int ohci_hcd_pxa27x_drv_suspend(struct platform_device *dev, pm_message_t state) |
313 | { | 315 | { |
314 | // struct platform_device *pdev = to_platform_device(dev); | 316 | // struct usb_hcd *hcd = platform_get_drvdata(dev); |
315 | // struct usb_hcd *hcd = dev_get_drvdata(dev); | ||
316 | printk("%s: not implemented yet\n", __FUNCTION__); | 317 | printk("%s: not implemented yet\n", __FUNCTION__); |
317 | 318 | ||
318 | return 0; | 319 | return 0; |
319 | } | 320 | } |
320 | 321 | ||
321 | static int ohci_hcd_pxa27x_drv_resume(struct device *dev, u32 level) | 322 | static int ohci_hcd_pxa27x_drv_resume(struct platform_device *dev) |
322 | { | 323 | { |
323 | // struct platform_device *pdev = to_platform_device(dev); | 324 | // struct usb_hcd *hcd = platform_get_drvdata(dev); |
324 | // struct usb_hcd *hcd = dev_get_drvdata(dev); | ||
325 | printk("%s: not implemented yet\n", __FUNCTION__); | 325 | printk("%s: not implemented yet\n", __FUNCTION__); |
326 | 326 | ||
327 | return 0; | 327 | return 0; |
328 | } | 328 | } |
329 | 329 | ||
330 | 330 | ||
331 | static struct device_driver ohci_hcd_pxa27x_driver = { | 331 | static struct platform_driver ohci_hcd_pxa27x_driver = { |
332 | .name = "pxa27x-ohci", | ||
333 | .bus = &platform_bus_type, | ||
334 | .probe = ohci_hcd_pxa27x_drv_probe, | 332 | .probe = ohci_hcd_pxa27x_drv_probe, |
335 | .remove = ohci_hcd_pxa27x_drv_remove, | 333 | .remove = ohci_hcd_pxa27x_drv_remove, |
336 | .suspend = ohci_hcd_pxa27x_drv_suspend, | 334 | .suspend = ohci_hcd_pxa27x_drv_suspend, |
337 | .resume = ohci_hcd_pxa27x_drv_resume, | 335 | .resume = ohci_hcd_pxa27x_drv_resume, |
336 | .driver = { | ||
337 | .name = "pxa27x-ohci", | ||
338 | }, | ||
338 | }; | 339 | }; |
339 | 340 | ||
340 | static int __init ohci_hcd_pxa27x_init (void) | 341 | static int __init ohci_hcd_pxa27x_init (void) |
@@ -343,12 +344,12 @@ static int __init ohci_hcd_pxa27x_init (void) | |||
343 | pr_debug ("block sizes: ed %d td %d\n", | 344 | pr_debug ("block sizes: ed %d td %d\n", |
344 | sizeof (struct ed), sizeof (struct td)); | 345 | sizeof (struct ed), sizeof (struct td)); |
345 | 346 | ||
346 | return driver_register(&ohci_hcd_pxa27x_driver); | 347 | return platform_driver_register(&ohci_hcd_pxa27x_driver); |
347 | } | 348 | } |
348 | 349 | ||
349 | static void __exit ohci_hcd_pxa27x_cleanup (void) | 350 | static void __exit ohci_hcd_pxa27x_cleanup (void) |
350 | { | 351 | { |
351 | driver_unregister(&ohci_hcd_pxa27x_driver); | 352 | platform_driver_unregister(&ohci_hcd_pxa27x_driver); |
352 | } | 353 | } |
353 | 354 | ||
354 | module_init (ohci_hcd_pxa27x_init); | 355 | module_init (ohci_hcd_pxa27x_init); |
diff --git a/drivers/usb/host/ohci-s3c2410.c b/drivers/usb/host/ohci-s3c2410.c index 3d9bcf78a9a4..35cc9402adc0 100644 --- a/drivers/usb/host/ohci-s3c2410.c +++ b/drivers/usb/host/ohci-s3c2410.c | |||
@@ -19,8 +19,9 @@ | |||
19 | * This file is licenced under the GPL. | 19 | * This file is licenced under the GPL. |
20 | */ | 20 | */ |
21 | 21 | ||
22 | #include <linux/platform_device.h> | ||
23 | |||
22 | #include <asm/hardware.h> | 24 | #include <asm/hardware.h> |
23 | #include <asm/mach-types.h> | ||
24 | #include <asm/hardware/clock.h> | 25 | #include <asm/hardware/clock.h> |
25 | #include <asm/arch/usb-control.h> | 26 | #include <asm/arch/usb-control.h> |
26 | 27 | ||
@@ -449,47 +450,47 @@ static const struct hc_driver ohci_s3c2410_hc_driver = { | |||
449 | */ | 450 | */ |
450 | .hub_status_data = ohci_s3c2410_hub_status_data, | 451 | .hub_status_data = ohci_s3c2410_hub_status_data, |
451 | .hub_control = ohci_s3c2410_hub_control, | 452 | .hub_control = ohci_s3c2410_hub_control, |
452 | 453 | #ifdef CONFIG_PM | |
453 | #if defined(CONFIG_USB_SUSPEND) && 0 | 454 | .bus_suspend = ohci_bus_suspend, |
454 | .hub_suspend = ohci_hub_suspend, | 455 | .bus_resume = ohci_bus_resume, |
455 | .hub_resume = ohci_hub_resume, | ||
456 | #endif | 456 | #endif |
457 | .start_port_reset = ohci_start_port_reset, | ||
457 | }; | 458 | }; |
458 | 459 | ||
459 | /* device driver */ | 460 | /* device driver */ |
460 | 461 | ||
461 | static int ohci_hcd_s3c2410_drv_probe(struct device *dev) | 462 | static int ohci_hcd_s3c2410_drv_probe(struct platform_device *pdev) |
462 | { | 463 | { |
463 | struct platform_device *pdev = to_platform_device(dev); | ||
464 | return usb_hcd_s3c2410_probe(&ohci_s3c2410_hc_driver, pdev); | 464 | return usb_hcd_s3c2410_probe(&ohci_s3c2410_hc_driver, pdev); |
465 | } | 465 | } |
466 | 466 | ||
467 | static int ohci_hcd_s3c2410_drv_remove(struct device *dev) | 467 | static int ohci_hcd_s3c2410_drv_remove(struct platform_device *pdev) |
468 | { | 468 | { |
469 | struct platform_device *pdev = to_platform_device(dev); | 469 | struct usb_hcd *hcd = platform_get_drvdata(pdev); |
470 | struct usb_hcd *hcd = dev_get_drvdata(dev); | ||
471 | 470 | ||
472 | usb_hcd_s3c2410_remove(hcd, pdev); | 471 | usb_hcd_s3c2410_remove(hcd, pdev); |
473 | return 0; | 472 | return 0; |
474 | } | 473 | } |
475 | 474 | ||
476 | static struct device_driver ohci_hcd_s3c2410_driver = { | 475 | static struct platform_driver ohci_hcd_s3c2410_driver = { |
477 | .name = "s3c2410-ohci", | ||
478 | .bus = &platform_bus_type, | ||
479 | .probe = ohci_hcd_s3c2410_drv_probe, | 476 | .probe = ohci_hcd_s3c2410_drv_probe, |
480 | .remove = ohci_hcd_s3c2410_drv_remove, | 477 | .remove = ohci_hcd_s3c2410_drv_remove, |
481 | /*.suspend = ohci_hcd_s3c2410_drv_suspend, */ | 478 | /*.suspend = ohci_hcd_s3c2410_drv_suspend, */ |
482 | /*.resume = ohci_hcd_s3c2410_drv_resume, */ | 479 | /*.resume = ohci_hcd_s3c2410_drv_resume, */ |
480 | .driver = { | ||
481 | .owner = THIS_MODULE, | ||
482 | .name = "s3c2410-ohci", | ||
483 | }, | ||
483 | }; | 484 | }; |
484 | 485 | ||
485 | static int __init ohci_hcd_s3c2410_init (void) | 486 | static int __init ohci_hcd_s3c2410_init (void) |
486 | { | 487 | { |
487 | return driver_register(&ohci_hcd_s3c2410_driver); | 488 | return platform_driver_register(&ohci_hcd_s3c2410_driver); |
488 | } | 489 | } |
489 | 490 | ||
490 | static void __exit ohci_hcd_s3c2410_cleanup (void) | 491 | static void __exit ohci_hcd_s3c2410_cleanup (void) |
491 | { | 492 | { |
492 | driver_unregister(&ohci_hcd_s3c2410_driver); | 493 | platform_driver_unregister(&ohci_hcd_s3c2410_driver); |
493 | } | 494 | } |
494 | 495 | ||
495 | module_init (ohci_hcd_s3c2410_init); | 496 | module_init (ohci_hcd_s3c2410_init); |
diff --git a/drivers/usb/host/ohci-sa1111.c b/drivers/usb/host/ohci-sa1111.c index 814d2be4ee7b..fb3221ebbb29 100644 --- a/drivers/usb/host/ohci-sa1111.c +++ b/drivers/usb/host/ohci-sa1111.c | |||
@@ -235,10 +235,11 @@ static const struct hc_driver ohci_sa1111_hc_driver = { | |||
235 | */ | 235 | */ |
236 | .hub_status_data = ohci_hub_status_data, | 236 | .hub_status_data = ohci_hub_status_data, |
237 | .hub_control = ohci_hub_control, | 237 | .hub_control = ohci_hub_control, |
238 | #ifdef CONFIG_USB_SUSPEND | 238 | #ifdef CONFIG_PM |
239 | .hub_suspend = ohci_hub_suspend, | 239 | .bus_suspend = ohci_bus_suspend, |
240 | .hub_resume = ohci_hub_resume, | 240 | .bus_resume = ohci_bus_resume, |
241 | #endif | 241 | #endif |
242 | .start_port_reset = ohci_start_port_reset, | ||
242 | }; | 243 | }; |
243 | 244 | ||
244 | /*-------------------------------------------------------------------------*/ | 245 | /*-------------------------------------------------------------------------*/ |
diff --git a/drivers/usb/host/ohci.h b/drivers/usb/host/ohci.h index 8a9b9d9209e9..caacf14371f5 100644 --- a/drivers/usb/host/ohci.h +++ b/drivers/usb/host/ohci.h | |||
@@ -389,7 +389,6 @@ struct ohci_hcd { | |||
389 | unsigned long next_statechange; /* suspend/resume */ | 389 | unsigned long next_statechange; /* suspend/resume */ |
390 | u32 fminterval; /* saved register */ | 390 | u32 fminterval; /* saved register */ |
391 | 391 | ||
392 | struct work_struct rh_resume; | ||
393 | struct notifier_block reboot_notifier; | 392 | struct notifier_block reboot_notifier; |
394 | 393 | ||
395 | unsigned long flags; /* for HC bugs */ | 394 | unsigned long flags; /* for HC bugs */ |
diff --git a/drivers/usb/host/pci-quirks.c b/drivers/usb/host/pci-quirks.c new file mode 100644 index 000000000000..e46528c825bf --- /dev/null +++ b/drivers/usb/host/pci-quirks.c | |||
@@ -0,0 +1,319 @@ | |||
1 | /* | ||
2 | * This file contains code to reset and initialize USB host controllers. | ||
3 | * Some of it includes work-arounds for PCI hardware and BIOS quirks. | ||
4 | * It may need to run early during booting -- before USB would normally | ||
5 | * initialize -- to ensure that Linux doesn't use any legacy modes. | ||
6 | * | ||
7 | * Copyright (c) 1999 Martin Mares <mj@ucw.cz> | ||
8 | * (and others) | ||
9 | */ | ||
10 | |||
11 | #include <linux/config.h> | ||
12 | #ifdef CONFIG_USB_DEBUG | ||
13 | #define DEBUG | ||
14 | #else | ||
15 | #undef DEBUG | ||
16 | #endif | ||
17 | |||
18 | #include <linux/types.h> | ||
19 | #include <linux/kernel.h> | ||
20 | #include <linux/pci.h> | ||
21 | #include <linux/init.h> | ||
22 | #include <linux/delay.h> | ||
23 | #include <linux/acpi.h> | ||
24 | |||
25 | |||
26 | #define UHCI_USBLEGSUP 0xc0 /* legacy support */ | ||
27 | #define UHCI_USBCMD 0 /* command register */ | ||
28 | #define UHCI_USBINTR 4 /* interrupt register */ | ||
29 | #define UHCI_USBLEGSUP_RWC 0x8f00 /* the R/WC bits */ | ||
30 | #define UHCI_USBLEGSUP_RO 0x5040 /* R/O and reserved bits */ | ||
31 | #define UHCI_USBCMD_RUN 0x0001 /* RUN/STOP bit */ | ||
32 | #define UHCI_USBCMD_HCRESET 0x0002 /* Host Controller reset */ | ||
33 | #define UHCI_USBCMD_EGSM 0x0008 /* Global Suspend Mode */ | ||
34 | #define UHCI_USBCMD_CONFIGURE 0x0040 /* Config Flag */ | ||
35 | #define UHCI_USBINTR_RESUME 0x0002 /* Resume interrupt enable */ | ||
36 | |||
37 | #define OHCI_CONTROL 0x04 | ||
38 | #define OHCI_CMDSTATUS 0x08 | ||
39 | #define OHCI_INTRSTATUS 0x0c | ||
40 | #define OHCI_INTRENABLE 0x10 | ||
41 | #define OHCI_INTRDISABLE 0x14 | ||
42 | #define OHCI_OCR (1 << 3) /* ownership change request */ | ||
43 | #define OHCI_CTRL_RWC (1 << 9) /* remote wakeup connected */ | ||
44 | #define OHCI_CTRL_IR (1 << 8) /* interrupt routing */ | ||
45 | #define OHCI_INTR_OC (1 << 30) /* ownership change */ | ||
46 | |||
47 | #define EHCI_HCC_PARAMS 0x08 /* extended capabilities */ | ||
48 | #define EHCI_USBCMD 0 /* command register */ | ||
49 | #define EHCI_USBCMD_RUN (1 << 0) /* RUN/STOP bit */ | ||
50 | #define EHCI_USBSTS 4 /* status register */ | ||
51 | #define EHCI_USBSTS_HALTED (1 << 12) /* HCHalted bit */ | ||
52 | #define EHCI_USBINTR 8 /* interrupt register */ | ||
53 | #define EHCI_USBLEGSUP 0 /* legacy support register */ | ||
54 | #define EHCI_USBLEGSUP_BIOS (1 << 16) /* BIOS semaphore */ | ||
55 | #define EHCI_USBLEGSUP_OS (1 << 24) /* OS semaphore */ | ||
56 | #define EHCI_USBLEGCTLSTS 4 /* legacy control/status */ | ||
57 | #define EHCI_USBLEGCTLSTS_SOOE (1 << 13) /* SMI on ownership change */ | ||
58 | |||
59 | |||
60 | /* | ||
61 | * Make sure the controller is completely inactive, unable to | ||
62 | * generate interrupts or do DMA. | ||
63 | */ | ||
64 | void uhci_reset_hc(struct pci_dev *pdev, unsigned long base) | ||
65 | { | ||
66 | /* Turn off PIRQ enable and SMI enable. (This also turns off the | ||
67 | * BIOS's USB Legacy Support.) Turn off all the R/WC bits too. | ||
68 | */ | ||
69 | pci_write_config_word(pdev, UHCI_USBLEGSUP, UHCI_USBLEGSUP_RWC); | ||
70 | |||
71 | /* Reset the HC - this will force us to get a | ||
72 | * new notification of any already connected | ||
73 | * ports due to the virtual disconnect that it | ||
74 | * implies. | ||
75 | */ | ||
76 | outw(UHCI_USBCMD_HCRESET, base + UHCI_USBCMD); | ||
77 | mb(); | ||
78 | udelay(5); | ||
79 | if (inw(base + UHCI_USBCMD) & UHCI_USBCMD_HCRESET) | ||
80 | dev_warn(&pdev->dev, "HCRESET not completed yet!\n"); | ||
81 | |||
82 | /* Just to be safe, disable interrupt requests and | ||
83 | * make sure the controller is stopped. | ||
84 | */ | ||
85 | outw(0, base + UHCI_USBINTR); | ||
86 | outw(0, base + UHCI_USBCMD); | ||
87 | } | ||
88 | EXPORT_SYMBOL_GPL(uhci_reset_hc); | ||
89 | |||
90 | /* | ||
91 | * Initialize a controller that was newly discovered or has just been | ||
92 | * resumed. In either case we can't be sure of its previous state. | ||
93 | * | ||
94 | * Returns: 1 if the controller was reset, 0 otherwise. | ||
95 | */ | ||
96 | int uhci_check_and_reset_hc(struct pci_dev *pdev, unsigned long base) | ||
97 | { | ||
98 | u16 legsup; | ||
99 | unsigned int cmd, intr; | ||
100 | |||
101 | /* | ||
102 | * When restarting a suspended controller, we expect all the | ||
103 | * settings to be the same as we left them: | ||
104 | * | ||
105 | * PIRQ and SMI disabled, no R/W bits set in USBLEGSUP; | ||
106 | * Controller is stopped and configured with EGSM set; | ||
107 | * No interrupts enabled except possibly Resume Detect. | ||
108 | * | ||
109 | * If any of these conditions are violated we do a complete reset. | ||
110 | */ | ||
111 | pci_read_config_word(pdev, UHCI_USBLEGSUP, &legsup); | ||
112 | if (legsup & ~(UHCI_USBLEGSUP_RO | UHCI_USBLEGSUP_RWC)) { | ||
113 | dev_dbg(&pdev->dev, "%s: legsup = 0x%04x\n", | ||
114 | __FUNCTION__, legsup); | ||
115 | goto reset_needed; | ||
116 | } | ||
117 | |||
118 | cmd = inw(base + UHCI_USBCMD); | ||
119 | if ((cmd & UHCI_USBCMD_RUN) || !(cmd & UHCI_USBCMD_CONFIGURE) || | ||
120 | !(cmd & UHCI_USBCMD_EGSM)) { | ||
121 | dev_dbg(&pdev->dev, "%s: cmd = 0x%04x\n", | ||
122 | __FUNCTION__, cmd); | ||
123 | goto reset_needed; | ||
124 | } | ||
125 | |||
126 | intr = inw(base + UHCI_USBINTR); | ||
127 | if (intr & (~UHCI_USBINTR_RESUME)) { | ||
128 | dev_dbg(&pdev->dev, "%s: intr = 0x%04x\n", | ||
129 | __FUNCTION__, intr); | ||
130 | goto reset_needed; | ||
131 | } | ||
132 | return 0; | ||
133 | |||
134 | reset_needed: | ||
135 | dev_dbg(&pdev->dev, "Performing full reset\n"); | ||
136 | uhci_reset_hc(pdev, base); | ||
137 | return 1; | ||
138 | } | ||
139 | EXPORT_SYMBOL_GPL(uhci_check_and_reset_hc); | ||
140 | |||
141 | static inline int io_type_enabled(struct pci_dev *pdev, unsigned int mask) | ||
142 | { | ||
143 | u16 cmd; | ||
144 | return !pci_read_config_word(pdev, PCI_COMMAND, &cmd) && (cmd & mask); | ||
145 | } | ||
146 | |||
147 | #define pio_enabled(dev) io_type_enabled(dev, PCI_COMMAND_IO) | ||
148 | #define mmio_enabled(dev) io_type_enabled(dev, PCI_COMMAND_MEMORY) | ||
149 | |||
150 | static void __devinit quirk_usb_handoff_uhci(struct pci_dev *pdev) | ||
151 | { | ||
152 | unsigned long base = 0; | ||
153 | int i; | ||
154 | |||
155 | if (!pio_enabled(pdev)) | ||
156 | return; | ||
157 | |||
158 | for (i = 0; i < PCI_ROM_RESOURCE; i++) | ||
159 | if ((pci_resource_flags(pdev, i) & IORESOURCE_IO)) { | ||
160 | base = pci_resource_start(pdev, i); | ||
161 | break; | ||
162 | } | ||
163 | |||
164 | if (base) | ||
165 | uhci_check_and_reset_hc(pdev, base); | ||
166 | } | ||
167 | |||
168 | static int __devinit mmio_resource_enabled(struct pci_dev *pdev, int idx) | ||
169 | { | ||
170 | return pci_resource_start(pdev, idx) && mmio_enabled(pdev); | ||
171 | } | ||
172 | |||
173 | static void __devinit quirk_usb_handoff_ohci(struct pci_dev *pdev) | ||
174 | { | ||
175 | void __iomem *base; | ||
176 | int wait_time; | ||
177 | u32 control; | ||
178 | |||
179 | if (!mmio_resource_enabled(pdev, 0)) | ||
180 | return; | ||
181 | |||
182 | base = ioremap_nocache(pci_resource_start(pdev, 0), | ||
183 | pci_resource_len(pdev, 0)); | ||
184 | if (base == NULL) return; | ||
185 | |||
186 | /* On PA-RISC, PDC can leave IR set incorrectly; ignore it there. */ | ||
187 | #ifndef __hppa__ | ||
188 | control = readl(base + OHCI_CONTROL); | ||
189 | if (control & OHCI_CTRL_IR) { | ||
190 | wait_time = 500; /* arbitrary; 5 seconds */ | ||
191 | writel(OHCI_INTR_OC, base + OHCI_INTRENABLE); | ||
192 | writel(OHCI_OCR, base + OHCI_CMDSTATUS); | ||
193 | while (wait_time > 0 && | ||
194 | readl(base + OHCI_CONTROL) & OHCI_CTRL_IR) { | ||
195 | wait_time -= 10; | ||
196 | msleep(10); | ||
197 | } | ||
198 | if (wait_time <= 0) | ||
199 | printk(KERN_WARNING "%s %s: early BIOS handoff " | ||
200 | "failed (BIOS bug ?)\n", | ||
201 | pdev->dev.bus_id, "OHCI"); | ||
202 | |||
203 | /* reset controller, preserving RWC */ | ||
204 | writel(control & OHCI_CTRL_RWC, base + OHCI_CONTROL); | ||
205 | } | ||
206 | #endif | ||
207 | |||
208 | /* | ||
209 | * disable interrupts | ||
210 | */ | ||
211 | writel(~(u32)0, base + OHCI_INTRDISABLE); | ||
212 | writel(~(u32)0, base + OHCI_INTRSTATUS); | ||
213 | |||
214 | iounmap(base); | ||
215 | } | ||
216 | |||
217 | static void __devinit quirk_usb_disable_ehci(struct pci_dev *pdev) | ||
218 | { | ||
219 | int wait_time, delta; | ||
220 | void __iomem *base, *op_reg_base; | ||
221 | u32 hcc_params, val, temp; | ||
222 | u8 cap_length; | ||
223 | |||
224 | if (!mmio_resource_enabled(pdev, 0)) | ||
225 | return; | ||
226 | |||
227 | base = ioremap_nocache(pci_resource_start(pdev, 0), | ||
228 | pci_resource_len(pdev, 0)); | ||
229 | if (base == NULL) return; | ||
230 | |||
231 | cap_length = readb(base); | ||
232 | op_reg_base = base + cap_length; | ||
233 | hcc_params = readl(base + EHCI_HCC_PARAMS); | ||
234 | hcc_params = (hcc_params >> 8) & 0xff; | ||
235 | if (hcc_params) { | ||
236 | pci_read_config_dword(pdev, | ||
237 | hcc_params + EHCI_USBLEGSUP, | ||
238 | &val); | ||
239 | if (((val & 0xff) == 1) && (val & EHCI_USBLEGSUP_BIOS)) { | ||
240 | /* | ||
241 | * Ok, BIOS is in smm mode, try to hand off... | ||
242 | */ | ||
243 | pci_read_config_dword(pdev, | ||
244 | hcc_params + EHCI_USBLEGCTLSTS, | ||
245 | &temp); | ||
246 | pci_write_config_dword(pdev, | ||
247 | hcc_params + EHCI_USBLEGCTLSTS, | ||
248 | temp | EHCI_USBLEGCTLSTS_SOOE); | ||
249 | val |= EHCI_USBLEGSUP_OS; | ||
250 | pci_write_config_dword(pdev, | ||
251 | hcc_params + EHCI_USBLEGSUP, | ||
252 | val); | ||
253 | |||
254 | wait_time = 500; | ||
255 | do { | ||
256 | msleep(10); | ||
257 | wait_time -= 10; | ||
258 | pci_read_config_dword(pdev, | ||
259 | hcc_params + EHCI_USBLEGSUP, | ||
260 | &val); | ||
261 | } while (wait_time && (val & EHCI_USBLEGSUP_BIOS)); | ||
262 | if (!wait_time) { | ||
263 | /* | ||
264 | * well, possibly buggy BIOS... | ||
265 | */ | ||
266 | printk(KERN_WARNING "%s %s: early BIOS handoff " | ||
267 | "failed (BIOS bug ?)\n", | ||
268 | pdev->dev.bus_id, "EHCI"); | ||
269 | pci_write_config_dword(pdev, | ||
270 | hcc_params + EHCI_USBLEGSUP, | ||
271 | EHCI_USBLEGSUP_OS); | ||
272 | pci_write_config_dword(pdev, | ||
273 | hcc_params + EHCI_USBLEGCTLSTS, | ||
274 | 0); | ||
275 | } | ||
276 | } | ||
277 | } | ||
278 | |||
279 | /* | ||
280 | * halt EHCI & disable its interrupts in any case | ||
281 | */ | ||
282 | val = readl(op_reg_base + EHCI_USBSTS); | ||
283 | if ((val & EHCI_USBSTS_HALTED) == 0) { | ||
284 | val = readl(op_reg_base + EHCI_USBCMD); | ||
285 | val &= ~EHCI_USBCMD_RUN; | ||
286 | writel(val, op_reg_base + EHCI_USBCMD); | ||
287 | |||
288 | wait_time = 2000; | ||
289 | delta = 100; | ||
290 | do { | ||
291 | writel(0x3f, op_reg_base + EHCI_USBSTS); | ||
292 | udelay(delta); | ||
293 | wait_time -= delta; | ||
294 | val = readl(op_reg_base + EHCI_USBSTS); | ||
295 | if ((val == ~(u32)0) || (val & EHCI_USBSTS_HALTED)) { | ||
296 | break; | ||
297 | } | ||
298 | } while (wait_time > 0); | ||
299 | } | ||
300 | writel(0, op_reg_base + EHCI_USBINTR); | ||
301 | writel(0x3f, op_reg_base + EHCI_USBSTS); | ||
302 | |||
303 | iounmap(base); | ||
304 | |||
305 | return; | ||
306 | } | ||
307 | |||
308 | |||
309 | |||
310 | static void __devinit quirk_usb_early_handoff(struct pci_dev *pdev) | ||
311 | { | ||
312 | if (pdev->class == PCI_CLASS_SERIAL_USB_UHCI) | ||
313 | quirk_usb_handoff_uhci(pdev); | ||
314 | else if (pdev->class == PCI_CLASS_SERIAL_USB_OHCI) | ||
315 | quirk_usb_handoff_ohci(pdev); | ||
316 | else if (pdev->class == PCI_CLASS_SERIAL_USB_EHCI) | ||
317 | quirk_usb_disable_ehci(pdev); | ||
318 | } | ||
319 | DECLARE_PCI_FIXUP_FINAL(PCI_ANY_ID, PCI_ANY_ID, quirk_usb_early_handoff); | ||
diff --git a/drivers/usb/host/sl811-hcd.c b/drivers/usb/host/sl811-hcd.c index d2a1fd40dfcb..a7722a6a5a5b 100644 --- a/drivers/usb/host/sl811-hcd.c +++ b/drivers/usb/host/sl811-hcd.c | |||
@@ -54,6 +54,7 @@ | |||
54 | #include <linux/interrupt.h> | 54 | #include <linux/interrupt.h> |
55 | #include <linux/usb.h> | 55 | #include <linux/usb.h> |
56 | #include <linux/usb_sl811.h> | 56 | #include <linux/usb_sl811.h> |
57 | #include <linux/platform_device.h> | ||
57 | 58 | ||
58 | #include <asm/io.h> | 59 | #include <asm/io.h> |
59 | #include <asm/irq.h> | 60 | #include <asm/irq.h> |
@@ -782,6 +783,9 @@ retry: | |||
782 | /* usb 1.1 says max 90% of a frame is available for periodic transfers. | 783 | /* usb 1.1 says max 90% of a frame is available for periodic transfers. |
783 | * this driver doesn't promise that much since it's got to handle an | 784 | * this driver doesn't promise that much since it's got to handle an |
784 | * IRQ per packet; irq handling latencies also use up that time. | 785 | * IRQ per packet; irq handling latencies also use up that time. |
786 | * | ||
787 | * NOTE: the periodic schedule is a sparse tree, with the load for | ||
788 | * each branch minimized. see fig 3.5 in the OHCI spec for example. | ||
785 | */ | 789 | */ |
786 | #define MAX_PERIODIC_LOAD 500 /* out of 1000 usec */ | 790 | #define MAX_PERIODIC_LOAD 500 /* out of 1000 usec */ |
787 | 791 | ||
@@ -815,7 +819,7 @@ static int sl811h_urb_enqueue( | |||
815 | struct usb_hcd *hcd, | 819 | struct usb_hcd *hcd, |
816 | struct usb_host_endpoint *hep, | 820 | struct usb_host_endpoint *hep, |
817 | struct urb *urb, | 821 | struct urb *urb, |
818 | unsigned mem_flags | 822 | gfp_t mem_flags |
819 | ) { | 823 | ) { |
820 | struct sl811 *sl811 = hcd_to_sl811(hcd); | 824 | struct sl811 *sl811 = hcd_to_sl811(hcd); |
821 | struct usb_device *udev = urb->dev; | 825 | struct usb_device *udev = urb->dev; |
@@ -843,6 +847,7 @@ static int sl811h_urb_enqueue( | |||
843 | if (!(sl811->port1 & (1 << USB_PORT_FEAT_ENABLE)) | 847 | if (!(sl811->port1 & (1 << USB_PORT_FEAT_ENABLE)) |
844 | || !HC_IS_RUNNING(hcd->state)) { | 848 | || !HC_IS_RUNNING(hcd->state)) { |
845 | retval = -ENODEV; | 849 | retval = -ENODEV; |
850 | kfree(ep); | ||
846 | goto fail; | 851 | goto fail; |
847 | } | 852 | } |
848 | 853 | ||
@@ -911,8 +916,16 @@ static int sl811h_urb_enqueue( | |||
911 | case PIPE_ISOCHRONOUS: | 916 | case PIPE_ISOCHRONOUS: |
912 | case PIPE_INTERRUPT: | 917 | case PIPE_INTERRUPT: |
913 | urb->interval = ep->period; | 918 | urb->interval = ep->period; |
914 | if (ep->branch < PERIODIC_SIZE) | 919 | if (ep->branch < PERIODIC_SIZE) { |
920 | /* NOTE: the phase is correct here, but the value | ||
921 | * needs offsetting by the transfer queue depth. | ||
922 | * All current drivers ignore start_frame, so this | ||
923 | * is unlikely to ever matter... | ||
924 | */ | ||
925 | urb->start_frame = (sl811->frame & (PERIODIC_SIZE - 1)) | ||
926 | + ep->branch; | ||
915 | break; | 927 | break; |
928 | } | ||
916 | 929 | ||
917 | retval = balance(sl811, ep->period, ep->load); | 930 | retval = balance(sl811, ep->period, ep->load); |
918 | if (retval < 0) | 931 | if (retval < 0) |
@@ -1122,7 +1135,7 @@ sl811h_hub_descriptor ( | |||
1122 | desc->wHubCharacteristics = (__force __u16)cpu_to_le16(temp); | 1135 | desc->wHubCharacteristics = (__force __u16)cpu_to_le16(temp); |
1123 | 1136 | ||
1124 | /* two bitmaps: ports removable, and legacy PortPwrCtrlMask */ | 1137 | /* two bitmaps: ports removable, and legacy PortPwrCtrlMask */ |
1125 | desc->bitmap[0] = 1 << 1; | 1138 | desc->bitmap[0] = 0 << 1; |
1126 | desc->bitmap[1] = ~0; | 1139 | desc->bitmap[1] = ~0; |
1127 | } | 1140 | } |
1128 | 1141 | ||
@@ -1351,7 +1364,7 @@ error: | |||
1351 | #ifdef CONFIG_PM | 1364 | #ifdef CONFIG_PM |
1352 | 1365 | ||
1353 | static int | 1366 | static int |
1354 | sl811h_hub_suspend(struct usb_hcd *hcd) | 1367 | sl811h_bus_suspend(struct usb_hcd *hcd) |
1355 | { | 1368 | { |
1356 | // SOFs off | 1369 | // SOFs off |
1357 | DBG("%s\n", __FUNCTION__); | 1370 | DBG("%s\n", __FUNCTION__); |
@@ -1359,7 +1372,7 @@ sl811h_hub_suspend(struct usb_hcd *hcd) | |||
1359 | } | 1372 | } |
1360 | 1373 | ||
1361 | static int | 1374 | static int |
1362 | sl811h_hub_resume(struct usb_hcd *hcd) | 1375 | sl811h_bus_resume(struct usb_hcd *hcd) |
1363 | { | 1376 | { |
1364 | // SOFs on | 1377 | // SOFs on |
1365 | DBG("%s\n", __FUNCTION__); | 1378 | DBG("%s\n", __FUNCTION__); |
@@ -1368,8 +1381,8 @@ sl811h_hub_resume(struct usb_hcd *hcd) | |||
1368 | 1381 | ||
1369 | #else | 1382 | #else |
1370 | 1383 | ||
1371 | #define sl811h_hub_suspend NULL | 1384 | #define sl811h_bus_suspend NULL |
1372 | #define sl811h_hub_resume NULL | 1385 | #define sl811h_bus_resume NULL |
1373 | 1386 | ||
1374 | #endif | 1387 | #endif |
1375 | 1388 | ||
@@ -1611,31 +1624,28 @@ static struct hc_driver sl811h_hc_driver = { | |||
1611 | */ | 1624 | */ |
1612 | .hub_status_data = sl811h_hub_status_data, | 1625 | .hub_status_data = sl811h_hub_status_data, |
1613 | .hub_control = sl811h_hub_control, | 1626 | .hub_control = sl811h_hub_control, |
1614 | .hub_suspend = sl811h_hub_suspend, | 1627 | .bus_suspend = sl811h_bus_suspend, |
1615 | .hub_resume = sl811h_hub_resume, | 1628 | .bus_resume = sl811h_bus_resume, |
1616 | }; | 1629 | }; |
1617 | 1630 | ||
1618 | /*-------------------------------------------------------------------------*/ | 1631 | /*-------------------------------------------------------------------------*/ |
1619 | 1632 | ||
1620 | static int __devexit | 1633 | static int __devexit |
1621 | sl811h_remove(struct device *dev) | 1634 | sl811h_remove(struct platform_device *dev) |
1622 | { | 1635 | { |
1623 | struct usb_hcd *hcd = dev_get_drvdata(dev); | 1636 | struct usb_hcd *hcd = platform_get_drvdata(dev); |
1624 | struct sl811 *sl811 = hcd_to_sl811(hcd); | 1637 | struct sl811 *sl811 = hcd_to_sl811(hcd); |
1625 | struct platform_device *pdev; | ||
1626 | struct resource *res; | 1638 | struct resource *res; |
1627 | 1639 | ||
1628 | pdev = container_of(dev, struct platform_device, dev); | ||
1629 | |||
1630 | remove_debug_file(sl811); | 1640 | remove_debug_file(sl811); |
1631 | usb_remove_hcd(hcd); | 1641 | usb_remove_hcd(hcd); |
1632 | 1642 | ||
1633 | /* some platforms may use IORESOURCE_IO */ | 1643 | /* some platforms may use IORESOURCE_IO */ |
1634 | res = platform_get_resource(pdev, IORESOURCE_MEM, 1); | 1644 | res = platform_get_resource(dev, IORESOURCE_MEM, 1); |
1635 | if (res) | 1645 | if (res) |
1636 | iounmap(sl811->data_reg); | 1646 | iounmap(sl811->data_reg); |
1637 | 1647 | ||
1638 | res = platform_get_resource(pdev, IORESOURCE_MEM, 0); | 1648 | res = platform_get_resource(dev, IORESOURCE_MEM, 0); |
1639 | if (res) | 1649 | if (res) |
1640 | iounmap(sl811->addr_reg); | 1650 | iounmap(sl811->addr_reg); |
1641 | 1651 | ||
@@ -1644,11 +1654,10 @@ sl811h_remove(struct device *dev) | |||
1644 | } | 1654 | } |
1645 | 1655 | ||
1646 | static int __devinit | 1656 | static int __devinit |
1647 | sl811h_probe(struct device *dev) | 1657 | sl811h_probe(struct platform_device *dev) |
1648 | { | 1658 | { |
1649 | struct usb_hcd *hcd; | 1659 | struct usb_hcd *hcd; |
1650 | struct sl811 *sl811; | 1660 | struct sl811 *sl811; |
1651 | struct platform_device *pdev; | ||
1652 | struct resource *addr, *data; | 1661 | struct resource *addr, *data; |
1653 | int irq; | 1662 | int irq; |
1654 | void __iomem *addr_reg; | 1663 | void __iomem *addr_reg; |
@@ -1661,24 +1670,23 @@ sl811h_probe(struct device *dev) | |||
1661 | * specific platform_data. we don't probe for IRQs, and do only | 1670 | * specific platform_data. we don't probe for IRQs, and do only |
1662 | * minimal sanity checking. | 1671 | * minimal sanity checking. |
1663 | */ | 1672 | */ |
1664 | pdev = container_of(dev, struct platform_device, dev); | 1673 | irq = platform_get_irq(dev, 0); |
1665 | irq = platform_get_irq(pdev, 0); | 1674 | if (dev->num_resources < 3 || irq < 0) |
1666 | if (pdev->num_resources < 3 || irq < 0) | ||
1667 | return -ENODEV; | 1675 | return -ENODEV; |
1668 | 1676 | ||
1669 | /* refuse to confuse usbcore */ | 1677 | /* refuse to confuse usbcore */ |
1670 | if (dev->dma_mask) { | 1678 | if (dev->dev.dma_mask) { |
1671 | DBG("no we won't dma\n"); | 1679 | DBG("no we won't dma\n"); |
1672 | return -EINVAL; | 1680 | return -EINVAL; |
1673 | } | 1681 | } |
1674 | 1682 | ||
1675 | /* the chip may be wired for either kind of addressing */ | 1683 | /* the chip may be wired for either kind of addressing */ |
1676 | addr = platform_get_resource(pdev, IORESOURCE_MEM, 0); | 1684 | addr = platform_get_resource(dev, IORESOURCE_MEM, 0); |
1677 | data = platform_get_resource(pdev, IORESOURCE_MEM, 1); | 1685 | data = platform_get_resource(dev, IORESOURCE_MEM, 1); |
1678 | retval = -EBUSY; | 1686 | retval = -EBUSY; |
1679 | if (!addr || !data) { | 1687 | if (!addr || !data) { |
1680 | addr = platform_get_resource(pdev, IORESOURCE_IO, 0); | 1688 | addr = platform_get_resource(dev, IORESOURCE_IO, 0); |
1681 | data = platform_get_resource(pdev, IORESOURCE_IO, 1); | 1689 | data = platform_get_resource(dev, IORESOURCE_IO, 1); |
1682 | if (!addr || !data) | 1690 | if (!addr || !data) |
1683 | return -ENODEV; | 1691 | return -ENODEV; |
1684 | ioaddr = 1; | 1692 | ioaddr = 1; |
@@ -1700,7 +1708,7 @@ sl811h_probe(struct device *dev) | |||
1700 | } | 1708 | } |
1701 | 1709 | ||
1702 | /* allocate and initialize hcd */ | 1710 | /* allocate and initialize hcd */ |
1703 | hcd = usb_create_hcd(&sl811h_hc_driver, dev, dev->bus_id); | 1711 | hcd = usb_create_hcd(&sl811h_hc_driver, &dev->dev, dev->dev.bus_id); |
1704 | if (!hcd) { | 1712 | if (!hcd) { |
1705 | retval = -ENOMEM; | 1713 | retval = -ENOMEM; |
1706 | goto err5; | 1714 | goto err5; |
@@ -1710,7 +1718,7 @@ sl811h_probe(struct device *dev) | |||
1710 | 1718 | ||
1711 | spin_lock_init(&sl811->lock); | 1719 | spin_lock_init(&sl811->lock); |
1712 | INIT_LIST_HEAD(&sl811->async); | 1720 | INIT_LIST_HEAD(&sl811->async); |
1713 | sl811->board = dev->platform_data; | 1721 | sl811->board = dev->dev.platform_data; |
1714 | init_timer(&sl811->timer); | 1722 | init_timer(&sl811->timer); |
1715 | sl811->timer.function = sl811h_timer; | 1723 | sl811->timer.function = sl811h_timer; |
1716 | sl811->timer.data = (unsigned long) sl811; | 1724 | sl811->timer.data = (unsigned long) sl811; |
@@ -1772,45 +1780,39 @@ sl811h_probe(struct device *dev) | |||
1772 | */ | 1780 | */ |
1773 | 1781 | ||
1774 | static int | 1782 | static int |
1775 | sl811h_suspend(struct device *dev, pm_message_t state, u32 phase) | 1783 | sl811h_suspend(struct platform_device *dev, pm_message_t state) |
1776 | { | 1784 | { |
1777 | struct usb_hcd *hcd = dev_get_drvdata(dev); | 1785 | struct usb_hcd *hcd = platform_get_drvdata(dev); |
1778 | struct sl811 *sl811 = hcd_to_sl811(hcd); | 1786 | struct sl811 *sl811 = hcd_to_sl811(hcd); |
1779 | int retval = 0; | 1787 | int retval = 0; |
1780 | 1788 | ||
1781 | if (phase != SUSPEND_POWER_DOWN) | ||
1782 | return retval; | ||
1783 | |||
1784 | if (state.event == PM_EVENT_FREEZE) | 1789 | if (state.event == PM_EVENT_FREEZE) |
1785 | retval = sl811h_hub_suspend(hcd); | 1790 | retval = sl811h_bus_suspend(hcd); |
1786 | else if (state.event == PM_EVENT_SUSPEND) | 1791 | else if (state.event == PM_EVENT_SUSPEND) |
1787 | port_power(sl811, 0); | 1792 | port_power(sl811, 0); |
1788 | if (retval == 0) | 1793 | if (retval == 0) |
1789 | dev->power.power_state = state; | 1794 | dev->dev.power.power_state = state; |
1790 | return retval; | 1795 | return retval; |
1791 | } | 1796 | } |
1792 | 1797 | ||
1793 | static int | 1798 | static int |
1794 | sl811h_resume(struct device *dev, u32 phase) | 1799 | sl811h_resume(struct platform_device *dev) |
1795 | { | 1800 | { |
1796 | struct usb_hcd *hcd = dev_get_drvdata(dev); | 1801 | struct usb_hcd *hcd = platform_get_drvdata(dev); |
1797 | struct sl811 *sl811 = hcd_to_sl811(hcd); | 1802 | struct sl811 *sl811 = hcd_to_sl811(hcd); |
1798 | 1803 | ||
1799 | if (phase != RESUME_POWER_ON) | ||
1800 | return 0; | ||
1801 | |||
1802 | /* with no "check to see if VBUS is still powered" board hook, | 1804 | /* with no "check to see if VBUS is still powered" board hook, |
1803 | * let's assume it'd only be powered to enable remote wakeup. | 1805 | * let's assume it'd only be powered to enable remote wakeup. |
1804 | */ | 1806 | */ |
1805 | if (dev->power.power_state.event == PM_EVENT_SUSPEND | 1807 | if (dev->dev.power.power_state.event == PM_EVENT_SUSPEND |
1806 | || !hcd->can_wakeup) { | 1808 | || !hcd->can_wakeup) { |
1807 | sl811->port1 = 0; | 1809 | sl811->port1 = 0; |
1808 | port_power(sl811, 1); | 1810 | port_power(sl811, 1); |
1809 | return 0; | 1811 | return 0; |
1810 | } | 1812 | } |
1811 | 1813 | ||
1812 | dev->power.power_state = PMSG_ON; | 1814 | dev->dev.power.power_state = PMSG_ON; |
1813 | return sl811h_hub_resume(hcd); | 1815 | return sl811h_bus_resume(hcd); |
1814 | } | 1816 | } |
1815 | 1817 | ||
1816 | #else | 1818 | #else |
@@ -1822,15 +1824,16 @@ sl811h_resume(struct device *dev, u32 phase) | |||
1822 | 1824 | ||
1823 | 1825 | ||
1824 | /* this driver is exported so sl811_cs can depend on it */ | 1826 | /* this driver is exported so sl811_cs can depend on it */ |
1825 | struct device_driver sl811h_driver = { | 1827 | struct platform_driver sl811h_driver = { |
1826 | .name = (char *) hcd_name, | ||
1827 | .bus = &platform_bus_type, | ||
1828 | |||
1829 | .probe = sl811h_probe, | 1828 | .probe = sl811h_probe, |
1830 | .remove = __devexit_p(sl811h_remove), | 1829 | .remove = __devexit_p(sl811h_remove), |
1831 | 1830 | ||
1832 | .suspend = sl811h_suspend, | 1831 | .suspend = sl811h_suspend, |
1833 | .resume = sl811h_resume, | 1832 | .resume = sl811h_resume, |
1833 | .driver = { | ||
1834 | .name = (char *) hcd_name, | ||
1835 | .owner = THIS_MODULE, | ||
1836 | }, | ||
1834 | }; | 1837 | }; |
1835 | EXPORT_SYMBOL(sl811h_driver); | 1838 | EXPORT_SYMBOL(sl811h_driver); |
1836 | 1839 | ||
@@ -1842,12 +1845,12 @@ static int __init sl811h_init(void) | |||
1842 | return -ENODEV; | 1845 | return -ENODEV; |
1843 | 1846 | ||
1844 | INFO("driver %s, %s\n", hcd_name, DRIVER_VERSION); | 1847 | INFO("driver %s, %s\n", hcd_name, DRIVER_VERSION); |
1845 | return driver_register(&sl811h_driver); | 1848 | return platform_driver_register(&sl811h_driver); |
1846 | } | 1849 | } |
1847 | module_init(sl811h_init); | 1850 | module_init(sl811h_init); |
1848 | 1851 | ||
1849 | static void __exit sl811h_cleanup(void) | 1852 | static void __exit sl811h_cleanup(void) |
1850 | { | 1853 | { |
1851 | driver_unregister(&sl811h_driver); | 1854 | platform_driver_unregister(&sl811h_driver); |
1852 | } | 1855 | } |
1853 | module_exit(sl811h_cleanup); | 1856 | module_exit(sl811h_cleanup); |
diff --git a/drivers/usb/host/sl811_cs.c b/drivers/usb/host/sl811_cs.c index 38aebe361ca1..e73faf831b24 100644 --- a/drivers/usb/host/sl811_cs.c +++ b/drivers/usb/host/sl811_cs.c | |||
@@ -19,6 +19,7 @@ | |||
19 | #include <linux/string.h> | 19 | #include <linux/string.h> |
20 | #include <linux/timer.h> | 20 | #include <linux/timer.h> |
21 | #include <linux/ioport.h> | 21 | #include <linux/ioport.h> |
22 | #include <linux/platform_device.h> | ||
22 | 23 | ||
23 | #include <pcmcia/cs_types.h> | 24 | #include <pcmcia/cs_types.h> |
24 | #include <pcmcia/cs.h> | 25 | #include <pcmcia/cs.h> |
diff --git a/drivers/usb/host/uhci-debug.c b/drivers/usb/host/uhci-debug.c index 4538a98b6f9d..151154df37fa 100644 --- a/drivers/usb/host/uhci-debug.c +++ b/drivers/usb/host/uhci-debug.c | |||
@@ -348,7 +348,6 @@ static int uhci_show_urbp(struct uhci_hcd *uhci, struct urb_priv *urbp, char *bu | |||
348 | 348 | ||
349 | if (urbp->urb->status != -EINPROGRESS) | 349 | if (urbp->urb->status != -EINPROGRESS) |
350 | out += sprintf(out, "Status=%d ", urbp->urb->status); | 350 | out += sprintf(out, "Status=%d ", urbp->urb->status); |
351 | //out += sprintf(out, "Inserttime=%lx ",urbp->inserttime); | ||
352 | //out += sprintf(out, "FSBRtime=%lx ",urbp->fsbrtime); | 351 | //out += sprintf(out, "FSBRtime=%lx ",urbp->fsbrtime); |
353 | 352 | ||
354 | count = 0; | 353 | count = 0; |
@@ -446,11 +445,11 @@ static int uhci_sprint_schedule(struct uhci_hcd *uhci, char *buf, int len) | |||
446 | out += sprintf(out, "Frame List\n"); | 445 | out += sprintf(out, "Frame List\n"); |
447 | for (i = 0; i < UHCI_NUMFRAMES; ++i) { | 446 | for (i = 0; i < UHCI_NUMFRAMES; ++i) { |
448 | int shown = 0; | 447 | int shown = 0; |
449 | td = uhci->fl->frame_cpu[i]; | 448 | td = uhci->frame_cpu[i]; |
450 | if (!td) | 449 | if (!td) |
451 | continue; | 450 | continue; |
452 | 451 | ||
453 | if (td->dma_handle != (dma_addr_t)uhci->fl->frame[i]) { | 452 | if (td->dma_handle != (dma_addr_t)uhci->frame[i]) { |
454 | show_frame_num(); | 453 | show_frame_num(); |
455 | out += sprintf(out, " frame list does not match td->dma_handle!\n"); | 454 | out += sprintf(out, " frame list does not match td->dma_handle!\n"); |
456 | } | 455 | } |
diff --git a/drivers/usb/host/uhci-hcd.c b/drivers/usb/host/uhci-hcd.c index 0c024898cbea..ed550132db0b 100644 --- a/drivers/usb/host/uhci-hcd.c +++ b/drivers/usb/host/uhci-hcd.c | |||
@@ -101,37 +101,16 @@ static void uhci_get_current_frame_number(struct uhci_hcd *uhci); | |||
101 | #include "uhci-q.c" | 101 | #include "uhci-q.c" |
102 | #include "uhci-hub.c" | 102 | #include "uhci-hub.c" |
103 | 103 | ||
104 | extern void uhci_reset_hc(struct pci_dev *pdev, unsigned long base); | ||
105 | extern int uhci_check_and_reset_hc(struct pci_dev *pdev, unsigned long base); | ||
106 | |||
104 | /* | 107 | /* |
105 | * Make sure the controller is completely inactive, unable to | 108 | * Finish up a host controller reset and update the recorded state. |
106 | * generate interrupts or do DMA. | ||
107 | */ | 109 | */ |
108 | static void reset_hc(struct uhci_hcd *uhci) | 110 | static void finish_reset(struct uhci_hcd *uhci) |
109 | { | 111 | { |
110 | int port; | 112 | int port; |
111 | 113 | ||
112 | /* Turn off PIRQ enable and SMI enable. (This also turns off the | ||
113 | * BIOS's USB Legacy Support.) Turn off all the R/WC bits too. | ||
114 | */ | ||
115 | pci_write_config_word(to_pci_dev(uhci_dev(uhci)), USBLEGSUP, | ||
116 | USBLEGSUP_RWC); | ||
117 | |||
118 | /* Reset the HC - this will force us to get a | ||
119 | * new notification of any already connected | ||
120 | * ports due to the virtual disconnect that it | ||
121 | * implies. | ||
122 | */ | ||
123 | outw(USBCMD_HCRESET, uhci->io_addr + USBCMD); | ||
124 | mb(); | ||
125 | udelay(5); | ||
126 | if (inw(uhci->io_addr + USBCMD) & USBCMD_HCRESET) | ||
127 | dev_warn(uhci_dev(uhci), "HCRESET not completed yet!\n"); | ||
128 | |||
129 | /* Just to be safe, disable interrupt requests and | ||
130 | * make sure the controller is stopped. | ||
131 | */ | ||
132 | outw(0, uhci->io_addr + USBINTR); | ||
133 | outw(0, uhci->io_addr + USBCMD); | ||
134 | |||
135 | /* HCRESET doesn't affect the Suspend, Reset, and Resume Detect | 114 | /* HCRESET doesn't affect the Suspend, Reset, and Resume Detect |
136 | * bits in the port status and control registers. | 115 | * bits in the port status and control registers. |
137 | * We have to clear them by hand. | 116 | * We have to clear them by hand. |
@@ -153,7 +132,8 @@ static void reset_hc(struct uhci_hcd *uhci) | |||
153 | */ | 132 | */ |
154 | static void hc_died(struct uhci_hcd *uhci) | 133 | static void hc_died(struct uhci_hcd *uhci) |
155 | { | 134 | { |
156 | reset_hc(uhci); | 135 | uhci_reset_hc(to_pci_dev(uhci_dev(uhci)), uhci->io_addr); |
136 | finish_reset(uhci); | ||
157 | uhci->hc_inaccessible = 1; | 137 | uhci->hc_inaccessible = 1; |
158 | } | 138 | } |
159 | 139 | ||
@@ -163,44 +143,8 @@ static void hc_died(struct uhci_hcd *uhci) | |||
163 | */ | 143 | */ |
164 | static void check_and_reset_hc(struct uhci_hcd *uhci) | 144 | static void check_and_reset_hc(struct uhci_hcd *uhci) |
165 | { | 145 | { |
166 | u16 legsup; | 146 | if (uhci_check_and_reset_hc(to_pci_dev(uhci_dev(uhci)), uhci->io_addr)) |
167 | unsigned int cmd, intr; | 147 | finish_reset(uhci); |
168 | |||
169 | /* | ||
170 | * When restarting a suspended controller, we expect all the | ||
171 | * settings to be the same as we left them: | ||
172 | * | ||
173 | * PIRQ and SMI disabled, no R/W bits set in USBLEGSUP; | ||
174 | * Controller is stopped and configured with EGSM set; | ||
175 | * No interrupts enabled except possibly Resume Detect. | ||
176 | * | ||
177 | * If any of these conditions are violated we do a complete reset. | ||
178 | */ | ||
179 | pci_read_config_word(to_pci_dev(uhci_dev(uhci)), USBLEGSUP, &legsup); | ||
180 | if (legsup & ~(USBLEGSUP_RO | USBLEGSUP_RWC)) { | ||
181 | dev_dbg(uhci_dev(uhci), "%s: legsup = 0x%04x\n", | ||
182 | __FUNCTION__, legsup); | ||
183 | goto reset_needed; | ||
184 | } | ||
185 | |||
186 | cmd = inw(uhci->io_addr + USBCMD); | ||
187 | if ((cmd & USBCMD_RS) || !(cmd & USBCMD_CF) || !(cmd & USBCMD_EGSM)) { | ||
188 | dev_dbg(uhci_dev(uhci), "%s: cmd = 0x%04x\n", | ||
189 | __FUNCTION__, cmd); | ||
190 | goto reset_needed; | ||
191 | } | ||
192 | |||
193 | intr = inw(uhci->io_addr + USBINTR); | ||
194 | if (intr & (~USBINTR_RESUME)) { | ||
195 | dev_dbg(uhci_dev(uhci), "%s: intr = 0x%04x\n", | ||
196 | __FUNCTION__, intr); | ||
197 | goto reset_needed; | ||
198 | } | ||
199 | return; | ||
200 | |||
201 | reset_needed: | ||
202 | dev_dbg(uhci_dev(uhci), "Performing full reset\n"); | ||
203 | reset_hc(uhci); | ||
204 | } | 148 | } |
205 | 149 | ||
206 | /* | 150 | /* |
@@ -212,13 +156,13 @@ static void configure_hc(struct uhci_hcd *uhci) | |||
212 | outb(USBSOF_DEFAULT, uhci->io_addr + USBSOF); | 156 | outb(USBSOF_DEFAULT, uhci->io_addr + USBSOF); |
213 | 157 | ||
214 | /* Store the frame list base address */ | 158 | /* Store the frame list base address */ |
215 | outl(uhci->fl->dma_handle, uhci->io_addr + USBFLBASEADD); | 159 | outl(uhci->frame_dma_handle, uhci->io_addr + USBFLBASEADD); |
216 | 160 | ||
217 | /* Set the current frame number */ | 161 | /* Set the current frame number */ |
218 | outw(uhci->frame_number, uhci->io_addr + USBFRNUM); | 162 | outw(uhci->frame_number, uhci->io_addr + USBFRNUM); |
219 | 163 | ||
220 | /* Mark controller as running before we enable interrupts */ | 164 | /* Mark controller as not halted before we enable interrupts */ |
221 | uhci_to_hcd(uhci)->state = HC_STATE_RUNNING; | 165 | uhci_to_hcd(uhci)->state = HC_STATE_SUSPENDED; |
222 | mb(); | 166 | mb(); |
223 | 167 | ||
224 | /* Enable PIRQ */ | 168 | /* Enable PIRQ */ |
@@ -319,6 +263,7 @@ __acquires(uhci->lock) | |||
319 | 263 | ||
320 | static void start_rh(struct uhci_hcd *uhci) | 264 | static void start_rh(struct uhci_hcd *uhci) |
321 | { | 265 | { |
266 | uhci_to_hcd(uhci)->state = HC_STATE_RUNNING; | ||
322 | uhci->is_stopped = 0; | 267 | uhci->is_stopped = 0; |
323 | smp_wmb(); | 268 | smp_wmb(); |
324 | 269 | ||
@@ -437,36 +382,21 @@ static void release_uhci(struct uhci_hcd *uhci) | |||
437 | int i; | 382 | int i; |
438 | 383 | ||
439 | for (i = 0; i < UHCI_NUM_SKELQH; i++) | 384 | for (i = 0; i < UHCI_NUM_SKELQH; i++) |
440 | if (uhci->skelqh[i]) { | 385 | uhci_free_qh(uhci, uhci->skelqh[i]); |
441 | uhci_free_qh(uhci, uhci->skelqh[i]); | ||
442 | uhci->skelqh[i] = NULL; | ||
443 | } | ||
444 | 386 | ||
445 | if (uhci->term_td) { | 387 | uhci_free_td(uhci, uhci->term_td); |
446 | uhci_free_td(uhci, uhci->term_td); | ||
447 | uhci->term_td = NULL; | ||
448 | } | ||
449 | 388 | ||
450 | if (uhci->qh_pool) { | 389 | dma_pool_destroy(uhci->qh_pool); |
451 | dma_pool_destroy(uhci->qh_pool); | ||
452 | uhci->qh_pool = NULL; | ||
453 | } | ||
454 | 390 | ||
455 | if (uhci->td_pool) { | 391 | dma_pool_destroy(uhci->td_pool); |
456 | dma_pool_destroy(uhci->td_pool); | ||
457 | uhci->td_pool = NULL; | ||
458 | } | ||
459 | 392 | ||
460 | if (uhci->fl) { | 393 | kfree(uhci->frame_cpu); |
461 | dma_free_coherent(uhci_dev(uhci), sizeof(*uhci->fl), | ||
462 | uhci->fl, uhci->fl->dma_handle); | ||
463 | uhci->fl = NULL; | ||
464 | } | ||
465 | 394 | ||
466 | if (uhci->dentry) { | 395 | dma_free_coherent(uhci_dev(uhci), |
467 | debugfs_remove(uhci->dentry); | 396 | UHCI_NUMFRAMES * sizeof(*uhci->frame), |
468 | uhci->dentry = NULL; | 397 | uhci->frame, uhci->frame_dma_handle); |
469 | } | 398 | |
399 | debugfs_remove(uhci->dentry); | ||
470 | } | 400 | } |
471 | 401 | ||
472 | static int uhci_reset(struct usb_hcd *hcd) | 402 | static int uhci_reset(struct usb_hcd *hcd) |
@@ -545,7 +475,6 @@ static int uhci_start(struct usb_hcd *hcd) | |||
545 | struct uhci_hcd *uhci = hcd_to_uhci(hcd); | 475 | struct uhci_hcd *uhci = hcd_to_uhci(hcd); |
546 | int retval = -EBUSY; | 476 | int retval = -EBUSY; |
547 | int i; | 477 | int i; |
548 | dma_addr_t dma_handle; | ||
549 | struct dentry *dentry; | 478 | struct dentry *dentry; |
550 | 479 | ||
551 | hcd->uses_new_polling = 1; | 480 | hcd->uses_new_polling = 1; |
@@ -579,17 +508,23 @@ static int uhci_start(struct usb_hcd *hcd) | |||
579 | 508 | ||
580 | init_waitqueue_head(&uhci->waitqh); | 509 | init_waitqueue_head(&uhci->waitqh); |
581 | 510 | ||
582 | uhci->fl = dma_alloc_coherent(uhci_dev(uhci), sizeof(*uhci->fl), | 511 | uhci->frame = dma_alloc_coherent(uhci_dev(uhci), |
583 | &dma_handle, 0); | 512 | UHCI_NUMFRAMES * sizeof(*uhci->frame), |
584 | if (!uhci->fl) { | 513 | &uhci->frame_dma_handle, 0); |
514 | if (!uhci->frame) { | ||
585 | dev_err(uhci_dev(uhci), "unable to allocate " | 515 | dev_err(uhci_dev(uhci), "unable to allocate " |
586 | "consistent memory for frame list\n"); | 516 | "consistent memory for frame list\n"); |
587 | goto err_alloc_fl; | 517 | goto err_alloc_frame; |
588 | } | 518 | } |
519 | memset(uhci->frame, 0, UHCI_NUMFRAMES * sizeof(*uhci->frame)); | ||
589 | 520 | ||
590 | memset((void *)uhci->fl, 0, sizeof(*uhci->fl)); | 521 | uhci->frame_cpu = kcalloc(UHCI_NUMFRAMES, sizeof(*uhci->frame_cpu), |
591 | 522 | GFP_KERNEL); | |
592 | uhci->fl->dma_handle = dma_handle; | 523 | if (!uhci->frame_cpu) { |
524 | dev_err(uhci_dev(uhci), "unable to allocate " | ||
525 | "memory for frame pointers\n"); | ||
526 | goto err_alloc_frame_cpu; | ||
527 | } | ||
593 | 528 | ||
594 | uhci->td_pool = dma_pool_create("uhci_td", uhci_dev(uhci), | 529 | uhci->td_pool = dma_pool_create("uhci_td", uhci_dev(uhci), |
595 | sizeof(struct uhci_td), 16, 0); | 530 | sizeof(struct uhci_td), 16, 0); |
@@ -672,7 +607,7 @@ static int uhci_start(struct usb_hcd *hcd) | |||
672 | irq = 7; | 607 | irq = 7; |
673 | 608 | ||
674 | /* Only place we don't use the frame list routines */ | 609 | /* Only place we don't use the frame list routines */ |
675 | uhci->fl->frame[i] = UHCI_PTR_QH | | 610 | uhci->frame[i] = UHCI_PTR_QH | |
676 | cpu_to_le32(uhci->skelqh[irq]->dma_handle); | 611 | cpu_to_le32(uhci->skelqh[irq]->dma_handle); |
677 | } | 612 | } |
678 | 613 | ||
@@ -690,31 +625,29 @@ static int uhci_start(struct usb_hcd *hcd) | |||
690 | * error exits: | 625 | * error exits: |
691 | */ | 626 | */ |
692 | err_alloc_skelqh: | 627 | err_alloc_skelqh: |
693 | for (i = 0; i < UHCI_NUM_SKELQH; i++) | 628 | for (i = 0; i < UHCI_NUM_SKELQH; i++) { |
694 | if (uhci->skelqh[i]) { | 629 | if (uhci->skelqh[i]) |
695 | uhci_free_qh(uhci, uhci->skelqh[i]); | 630 | uhci_free_qh(uhci, uhci->skelqh[i]); |
696 | uhci->skelqh[i] = NULL; | 631 | } |
697 | } | ||
698 | 632 | ||
699 | uhci_free_td(uhci, uhci->term_td); | 633 | uhci_free_td(uhci, uhci->term_td); |
700 | uhci->term_td = NULL; | ||
701 | 634 | ||
702 | err_alloc_term_td: | 635 | err_alloc_term_td: |
703 | dma_pool_destroy(uhci->qh_pool); | 636 | dma_pool_destroy(uhci->qh_pool); |
704 | uhci->qh_pool = NULL; | ||
705 | 637 | ||
706 | err_create_qh_pool: | 638 | err_create_qh_pool: |
707 | dma_pool_destroy(uhci->td_pool); | 639 | dma_pool_destroy(uhci->td_pool); |
708 | uhci->td_pool = NULL; | ||
709 | 640 | ||
710 | err_create_td_pool: | 641 | err_create_td_pool: |
711 | dma_free_coherent(uhci_dev(uhci), sizeof(*uhci->fl), | 642 | kfree(uhci->frame_cpu); |
712 | uhci->fl, uhci->fl->dma_handle); | ||
713 | uhci->fl = NULL; | ||
714 | 643 | ||
715 | err_alloc_fl: | 644 | err_alloc_frame_cpu: |
645 | dma_free_coherent(uhci_dev(uhci), | ||
646 | UHCI_NUMFRAMES * sizeof(*uhci->frame), | ||
647 | uhci->frame, uhci->frame_dma_handle); | ||
648 | |||
649 | err_alloc_frame: | ||
716 | debugfs_remove(uhci->dentry); | 650 | debugfs_remove(uhci->dentry); |
717 | uhci->dentry = NULL; | ||
718 | 651 | ||
719 | err_create_debug_entry: | 652 | err_create_debug_entry: |
720 | return retval; | 653 | return retval; |
@@ -726,7 +659,7 @@ static void uhci_stop(struct usb_hcd *hcd) | |||
726 | 659 | ||
727 | spin_lock_irq(&uhci->lock); | 660 | spin_lock_irq(&uhci->lock); |
728 | if (!uhci->hc_inaccessible) | 661 | if (!uhci->hc_inaccessible) |
729 | reset_hc(uhci); | 662 | hc_died(uhci); |
730 | uhci_scan_schedule(uhci, NULL); | 663 | uhci_scan_schedule(uhci, NULL); |
731 | spin_unlock_irq(&uhci->lock); | 664 | spin_unlock_irq(&uhci->lock); |
732 | 665 | ||
@@ -774,14 +707,8 @@ static int uhci_suspend(struct usb_hcd *hcd, pm_message_t message) | |||
774 | if (uhci->hc_inaccessible) /* Dead or already suspended */ | 707 | if (uhci->hc_inaccessible) /* Dead or already suspended */ |
775 | goto done; | 708 | goto done; |
776 | 709 | ||
777 | #ifndef CONFIG_USB_SUSPEND | ||
778 | /* Otherwise this would never happen */ | ||
779 | suspend_rh(uhci, UHCI_RH_SUSPENDED); | ||
780 | #endif | ||
781 | |||
782 | if (uhci->rh_state > UHCI_RH_SUSPENDED) { | 710 | if (uhci->rh_state > UHCI_RH_SUSPENDED) { |
783 | dev_warn(uhci_dev(uhci), "Root hub isn't suspended!\n"); | 711 | dev_warn(uhci_dev(uhci), "Root hub isn't suspended!\n"); |
784 | hcd->state = HC_STATE_RUNNING; | ||
785 | rc = -EBUSY; | 712 | rc = -EBUSY; |
786 | goto done; | 713 | goto done; |
787 | }; | 714 | }; |
@@ -790,6 +717,7 @@ static int uhci_suspend(struct usb_hcd *hcd, pm_message_t message) | |||
790 | * at the source, so we must turn off PIRQ. | 717 | * at the source, so we must turn off PIRQ. |
791 | */ | 718 | */ |
792 | pci_write_config_word(to_pci_dev(uhci_dev(uhci)), USBLEGSUP, 0); | 719 | pci_write_config_word(to_pci_dev(uhci_dev(uhci)), USBLEGSUP, 0); |
720 | clear_bit(HCD_FLAG_HW_ACCESSIBLE, &hcd->flags); | ||
793 | uhci->hc_inaccessible = 1; | 721 | uhci->hc_inaccessible = 1; |
794 | hcd->poll_rh = 0; | 722 | hcd->poll_rh = 0; |
795 | 723 | ||
@@ -806,6 +734,11 @@ static int uhci_resume(struct usb_hcd *hcd) | |||
806 | 734 | ||
807 | dev_dbg(uhci_dev(uhci), "%s\n", __FUNCTION__); | 735 | dev_dbg(uhci_dev(uhci), "%s\n", __FUNCTION__); |
808 | 736 | ||
737 | /* We aren't in D3 state anymore, we do that even if dead as I | ||
738 | * really don't want to keep a stale HCD_FLAG_HW_ACCESSIBLE=0 | ||
739 | */ | ||
740 | set_bit(HCD_FLAG_HW_ACCESSIBLE, &hcd->flags); | ||
741 | |||
809 | if (uhci->rh_state == UHCI_RH_RESET) /* Dead */ | 742 | if (uhci->rh_state == UHCI_RH_RESET) /* Dead */ |
810 | return 0; | 743 | return 0; |
811 | spin_lock_irq(&uhci->lock); | 744 | spin_lock_irq(&uhci->lock); |
@@ -820,10 +753,6 @@ static int uhci_resume(struct usb_hcd *hcd) | |||
820 | check_and_reset_hc(uhci); | 753 | check_and_reset_hc(uhci); |
821 | configure_hc(uhci); | 754 | configure_hc(uhci); |
822 | 755 | ||
823 | #ifndef CONFIG_USB_SUSPEND | ||
824 | /* Otherwise this would never happen */ | ||
825 | wakeup_rh(uhci); | ||
826 | #endif | ||
827 | if (uhci->rh_state == UHCI_RH_RESET) | 756 | if (uhci->rh_state == UHCI_RH_RESET) |
828 | suspend_rh(uhci, UHCI_RH_SUSPENDED); | 757 | suspend_rh(uhci, UHCI_RH_SUSPENDED); |
829 | 758 | ||
@@ -881,8 +810,8 @@ static const struct hc_driver uhci_driver = { | |||
881 | #ifdef CONFIG_PM | 810 | #ifdef CONFIG_PM |
882 | .suspend = uhci_suspend, | 811 | .suspend = uhci_suspend, |
883 | .resume = uhci_resume, | 812 | .resume = uhci_resume, |
884 | .hub_suspend = uhci_rh_suspend, | 813 | .bus_suspend = uhci_rh_suspend, |
885 | .hub_resume = uhci_rh_resume, | 814 | .bus_resume = uhci_rh_resume, |
886 | #endif | 815 | #endif |
887 | .stop = uhci_stop, | 816 | .stop = uhci_stop, |
888 | 817 | ||
diff --git a/drivers/usb/host/uhci-hcd.h b/drivers/usb/host/uhci-hcd.h index 282f40b75881..e576db57a926 100644 --- a/drivers/usb/host/uhci-hcd.h +++ b/drivers/usb/host/uhci-hcd.h | |||
@@ -7,6 +7,7 @@ | |||
7 | #define usb_packetid(pipe) (usb_pipein(pipe) ? USB_PID_IN : USB_PID_OUT) | 7 | #define usb_packetid(pipe) (usb_pipein(pipe) ? USB_PID_IN : USB_PID_OUT) |
8 | #define PIPE_DEVEP_MASK 0x0007ff00 | 8 | #define PIPE_DEVEP_MASK 0x0007ff00 |
9 | 9 | ||
10 | |||
10 | /* | 11 | /* |
11 | * Universal Host Controller Interface data structures and defines | 12 | * Universal Host Controller Interface data structures and defines |
12 | */ | 13 | */ |
@@ -82,15 +83,10 @@ | |||
82 | #define UHCI_MAX_SOF_NUMBER 2047 /* in an SOF packet */ | 83 | #define UHCI_MAX_SOF_NUMBER 2047 /* in an SOF packet */ |
83 | #define CAN_SCHEDULE_FRAMES 1000 /* how far future frames can be scheduled */ | 84 | #define CAN_SCHEDULE_FRAMES 1000 /* how far future frames can be scheduled */ |
84 | 85 | ||
85 | struct uhci_frame_list { | ||
86 | __le32 frame[UHCI_NUMFRAMES]; | ||
87 | |||
88 | void *frame_cpu[UHCI_NUMFRAMES]; | ||
89 | |||
90 | dma_addr_t dma_handle; | ||
91 | }; | ||
92 | 86 | ||
93 | struct urb_priv; | 87 | /* |
88 | * Queue Headers | ||
89 | */ | ||
94 | 90 | ||
95 | /* | 91 | /* |
96 | * One role of a QH is to hold a queue of TDs for some endpoint. Each QH is | 92 | * One role of a QH is to hold a queue of TDs for some endpoint. Each QH is |
@@ -116,13 +112,13 @@ struct uhci_qh { | |||
116 | 112 | ||
117 | struct urb_priv *urbp; | 113 | struct urb_priv *urbp; |
118 | 114 | ||
119 | struct list_head list; /* P: uhci->frame_list_lock */ | 115 | struct list_head list; |
120 | struct list_head remove_list; /* P: uhci->remove_list_lock */ | 116 | struct list_head remove_list; |
121 | } __attribute__((aligned(16))); | 117 | } __attribute__((aligned(16))); |
122 | 118 | ||
123 | /* | 119 | /* |
124 | * We need a special accessor for the element pointer because it is | 120 | * We need a special accessor for the element pointer because it is |
125 | * subject to asynchronous updates by the controller | 121 | * subject to asynchronous updates by the controller. |
126 | */ | 122 | */ |
127 | static __le32 inline qh_element(struct uhci_qh *qh) { | 123 | static __le32 inline qh_element(struct uhci_qh *qh) { |
128 | __le32 element = qh->element; | 124 | __le32 element = qh->element; |
@@ -131,6 +127,11 @@ static __le32 inline qh_element(struct uhci_qh *qh) { | |||
131 | return element; | 127 | return element; |
132 | } | 128 | } |
133 | 129 | ||
130 | |||
131 | /* | ||
132 | * Transfer Descriptors | ||
133 | */ | ||
134 | |||
134 | /* | 135 | /* |
135 | * for TD <status>: | 136 | * for TD <status>: |
136 | */ | 137 | */ |
@@ -183,17 +184,10 @@ static __le32 inline qh_element(struct uhci_qh *qh) { | |||
183 | * | 184 | * |
184 | * That's silly, the hardware doesn't care. The hardware only cares that | 185 | * That's silly, the hardware doesn't care. The hardware only cares that |
185 | * the hardware words are 16-byte aligned, and we can have any amount of | 186 | * the hardware words are 16-byte aligned, and we can have any amount of |
186 | * sw space after the TD entry as far as I can tell. | 187 | * sw space after the TD entry. |
187 | * | ||
188 | * But let's just go with the documentation, at least for 32-bit machines. | ||
189 | * On 64-bit machines we probably want to take advantage of the fact that | ||
190 | * hw doesn't really care about the size of the sw-only area. | ||
191 | * | ||
192 | * Alas, not anymore, we have more than 4 words for software, woops. | ||
193 | * Everything still works tho, surprise! -jerdfelt | ||
194 | * | 188 | * |
195 | * td->link points to either another TD (not necessarily for the same urb or | 189 | * td->link points to either another TD (not necessarily for the same urb or |
196 | * even the same endpoint), or nothing (PTR_TERM), or a QH (for queued urbs) | 190 | * even the same endpoint), or nothing (PTR_TERM), or a QH (for queued urbs). |
197 | */ | 191 | */ |
198 | struct uhci_td { | 192 | struct uhci_td { |
199 | /* Hardware fields */ | 193 | /* Hardware fields */ |
@@ -205,18 +199,16 @@ struct uhci_td { | |||
205 | /* Software fields */ | 199 | /* Software fields */ |
206 | dma_addr_t dma_handle; | 200 | dma_addr_t dma_handle; |
207 | 201 | ||
208 | struct urb *urb; | 202 | struct list_head list; |
209 | 203 | struct list_head remove_list; | |
210 | struct list_head list; /* P: urb->lock */ | ||
211 | struct list_head remove_list; /* P: uhci->td_remove_list_lock */ | ||
212 | 204 | ||
213 | int frame; /* for iso: what frame? */ | 205 | int frame; /* for iso: what frame? */ |
214 | struct list_head fl_list; /* P: uhci->frame_list_lock */ | 206 | struct list_head fl_list; |
215 | } __attribute__((aligned(16))); | 207 | } __attribute__((aligned(16))); |
216 | 208 | ||
217 | /* | 209 | /* |
218 | * We need a special accessor for the control/status word because it is | 210 | * We need a special accessor for the control/status word because it is |
219 | * subject to asynchronous updates by the controller | 211 | * subject to asynchronous updates by the controller. |
220 | */ | 212 | */ |
221 | static u32 inline td_status(struct uhci_td *td) { | 213 | static u32 inline td_status(struct uhci_td *td) { |
222 | __le32 status = td->status; | 214 | __le32 status = td->status; |
@@ -227,6 +219,10 @@ static u32 inline td_status(struct uhci_td *td) { | |||
227 | 219 | ||
228 | 220 | ||
229 | /* | 221 | /* |
222 | * Skeleton Queue Headers | ||
223 | */ | ||
224 | |||
225 | /* | ||
230 | * The UHCI driver places Interrupt, Control and Bulk into QH's both | 226 | * The UHCI driver places Interrupt, Control and Bulk into QH's both |
231 | * to group together TD's for one transfer, and also to faciliate queuing | 227 | * to group together TD's for one transfer, and also to faciliate queuing |
232 | * of URB's. To make it easy to insert entries into the schedule, we have | 228 | * of URB's. To make it easy to insert entries into the schedule, we have |
@@ -256,15 +252,15 @@ static u32 inline td_status(struct uhci_td *td) { | |||
256 | * | 252 | * |
257 | * The terminating QH is used for 2 reasons: | 253 | * The terminating QH is used for 2 reasons: |
258 | * - To place a terminating TD which is used to workaround a PIIX bug | 254 | * - To place a terminating TD which is used to workaround a PIIX bug |
259 | * (see Intel errata for explanation) | 255 | * (see Intel errata for explanation), and |
260 | * - To loop back to the full-speed control queue for full-speed bandwidth | 256 | * - To loop back to the full-speed control queue for full-speed bandwidth |
261 | * reclamation | 257 | * reclamation. |
262 | * | 258 | * |
263 | * Isochronous transfers are stored before the start of the skeleton | 259 | * Isochronous transfers are stored before the start of the skeleton |
264 | * schedule and don't use QH's. While the UHCI spec doesn't forbid the | 260 | * schedule and don't use QH's. While the UHCI spec doesn't forbid the |
265 | * use of QH's for Isochronous, it doesn't use them either. Since we don't | 261 | * use of QH's for Isochronous, it doesn't use them either. And the spec |
266 | * need to use them either, we follow the spec diagrams in hope that it'll | 262 | * says that queues never advance on an error completion status, which |
267 | * be more compatible with future UHCI implementations. | 263 | * makes them totally unsuitable for Isochronous transfers. |
268 | */ | 264 | */ |
269 | 265 | ||
270 | #define UHCI_NUM_SKELQH 12 | 266 | #define UHCI_NUM_SKELQH 12 |
@@ -314,8 +310,13 @@ static inline int __interval_to_skel(int interval) | |||
314 | return 0; /* int128 for 128-255 ms (Max.) */ | 310 | return 0; /* int128 for 128-255 ms (Max.) */ |
315 | } | 311 | } |
316 | 312 | ||
313 | |||
314 | /* | ||
315 | * The UHCI controller and root hub | ||
316 | */ | ||
317 | |||
317 | /* | 318 | /* |
318 | * States for the root hub. | 319 | * States for the root hub: |
319 | * | 320 | * |
320 | * To prevent "bouncing" in the presence of electrical noise, | 321 | * To prevent "bouncing" in the presence of electrical noise, |
321 | * when there are no devices attached we delay for 1 second in the | 322 | * when there are no devices attached we delay for 1 second in the |
@@ -326,7 +327,7 @@ static inline int __interval_to_skel(int interval) | |||
326 | */ | 327 | */ |
327 | enum uhci_rh_state { | 328 | enum uhci_rh_state { |
328 | /* In the following states the HC must be halted. | 329 | /* In the following states the HC must be halted. |
329 | * These two must come first */ | 330 | * These two must come first. */ |
330 | UHCI_RH_RESET, | 331 | UHCI_RH_RESET, |
331 | UHCI_RH_SUSPENDED, | 332 | UHCI_RH_SUSPENDED, |
332 | 333 | ||
@@ -338,13 +339,13 @@ enum uhci_rh_state { | |||
338 | UHCI_RH_SUSPENDING, | 339 | UHCI_RH_SUSPENDING, |
339 | 340 | ||
340 | /* In the following states it's an error if the HC is halted. | 341 | /* In the following states it's an error if the HC is halted. |
341 | * These two must come last */ | 342 | * These two must come last. */ |
342 | UHCI_RH_RUNNING, /* The normal state */ | 343 | UHCI_RH_RUNNING, /* The normal state */ |
343 | UHCI_RH_RUNNING_NODEVS, /* Running with no devices attached */ | 344 | UHCI_RH_RUNNING_NODEVS, /* Running with no devices attached */ |
344 | }; | 345 | }; |
345 | 346 | ||
346 | /* | 347 | /* |
347 | * This describes the full uhci information. | 348 | * The full UHCI controller information: |
348 | */ | 349 | */ |
349 | struct uhci_hcd { | 350 | struct uhci_hcd { |
350 | 351 | ||
@@ -361,7 +362,11 @@ struct uhci_hcd { | |||
361 | struct uhci_qh *skelqh[UHCI_NUM_SKELQH]; /* Skeleton QH's */ | 362 | struct uhci_qh *skelqh[UHCI_NUM_SKELQH]; /* Skeleton QH's */ |
362 | 363 | ||
363 | spinlock_t lock; | 364 | spinlock_t lock; |
364 | struct uhci_frame_list *fl; /* P: uhci->lock */ | 365 | |
366 | dma_addr_t frame_dma_handle; /* Hardware frame list */ | ||
367 | __le32 *frame; | ||
368 | void **frame_cpu; /* CPU's frame list */ | ||
369 | |||
365 | int fsbr; /* Full-speed bandwidth reclamation */ | 370 | int fsbr; /* Full-speed bandwidth reclamation */ |
366 | unsigned long fsbrtimeout; /* FSBR delay */ | 371 | unsigned long fsbrtimeout; /* FSBR delay */ |
367 | 372 | ||
@@ -385,22 +390,22 @@ struct uhci_hcd { | |||
385 | unsigned long ports_timeout; /* Time to stop signalling */ | 390 | unsigned long ports_timeout; /* Time to stop signalling */ |
386 | 391 | ||
387 | /* Main list of URB's currently controlled by this HC */ | 392 | /* Main list of URB's currently controlled by this HC */ |
388 | struct list_head urb_list; /* P: uhci->lock */ | 393 | struct list_head urb_list; |
389 | 394 | ||
390 | /* List of QH's that are done, but waiting to be unlinked (race) */ | 395 | /* List of QH's that are done, but waiting to be unlinked (race) */ |
391 | struct list_head qh_remove_list; /* P: uhci->lock */ | 396 | struct list_head qh_remove_list; |
392 | unsigned int qh_remove_age; /* Age in frames */ | 397 | unsigned int qh_remove_age; /* Age in frames */ |
393 | 398 | ||
394 | /* List of TD's that are done, but waiting to be freed (race) */ | 399 | /* List of TD's that are done, but waiting to be freed (race) */ |
395 | struct list_head td_remove_list; /* P: uhci->lock */ | 400 | struct list_head td_remove_list; |
396 | unsigned int td_remove_age; /* Age in frames */ | 401 | unsigned int td_remove_age; /* Age in frames */ |
397 | 402 | ||
398 | /* List of asynchronously unlinked URB's */ | 403 | /* List of asynchronously unlinked URB's */ |
399 | struct list_head urb_remove_list; /* P: uhci->lock */ | 404 | struct list_head urb_remove_list; |
400 | unsigned int urb_remove_age; /* Age in frames */ | 405 | unsigned int urb_remove_age; /* Age in frames */ |
401 | 406 | ||
402 | /* List of URB's awaiting completion callback */ | 407 | /* List of URB's awaiting completion callback */ |
403 | struct list_head complete_list; /* P: uhci->lock */ | 408 | struct list_head complete_list; |
404 | 409 | ||
405 | int rh_numports; /* Number of root-hub ports */ | 410 | int rh_numports; /* Number of root-hub ports */ |
406 | 411 | ||
@@ -419,13 +424,17 @@ static inline struct usb_hcd *uhci_to_hcd(struct uhci_hcd *uhci) | |||
419 | 424 | ||
420 | #define uhci_dev(u) (uhci_to_hcd(u)->self.controller) | 425 | #define uhci_dev(u) (uhci_to_hcd(u)->self.controller) |
421 | 426 | ||
427 | |||
428 | /* | ||
429 | * Private per-URB data | ||
430 | */ | ||
422 | struct urb_priv { | 431 | struct urb_priv { |
423 | struct list_head urb_list; | 432 | struct list_head urb_list; |
424 | 433 | ||
425 | struct urb *urb; | 434 | struct urb *urb; |
426 | 435 | ||
427 | struct uhci_qh *qh; /* QH for this URB */ | 436 | struct uhci_qh *qh; /* QH for this URB */ |
428 | struct list_head td_list; /* P: urb->lock */ | 437 | struct list_head td_list; |
429 | 438 | ||
430 | unsigned fsbr : 1; /* URB turned on FSBR */ | 439 | unsigned fsbr : 1; /* URB turned on FSBR */ |
431 | unsigned fsbr_timeout : 1; /* URB timed out on FSBR */ | 440 | unsigned fsbr_timeout : 1; /* URB timed out on FSBR */ |
@@ -434,12 +443,12 @@ struct urb_priv { | |||
434 | /* a control transfer, retrigger */ | 443 | /* a control transfer, retrigger */ |
435 | /* the status phase */ | 444 | /* the status phase */ |
436 | 445 | ||
437 | unsigned long inserttime; /* In jiffies */ | ||
438 | unsigned long fsbrtime; /* In jiffies */ | 446 | unsigned long fsbrtime; /* In jiffies */ |
439 | 447 | ||
440 | struct list_head queue_list; /* P: uhci->frame_list_lock */ | 448 | struct list_head queue_list; |
441 | }; | 449 | }; |
442 | 450 | ||
451 | |||
443 | /* | 452 | /* |
444 | * Locking in uhci.c | 453 | * Locking in uhci.c |
445 | * | 454 | * |
@@ -459,6 +468,5 @@ struct urb_priv { | |||
459 | 468 | ||
460 | #define PCI_VENDOR_ID_GENESYS 0x17a0 | 469 | #define PCI_VENDOR_ID_GENESYS 0x17a0 |
461 | #define PCI_DEVICE_ID_GL880S_UHCI 0x8083 | 470 | #define PCI_DEVICE_ID_GL880S_UHCI 0x8083 |
462 | #define PCI_DEVICE_ID_GL880S_EHCI 0x8084 | ||
463 | 471 | ||
464 | #endif | 472 | #endif |
diff --git a/drivers/usb/host/uhci-q.c b/drivers/usb/host/uhci-q.c index ea0d168a8c67..7e46887d9e12 100644 --- a/drivers/usb/host/uhci-q.c +++ b/drivers/usb/host/uhci-q.c | |||
@@ -89,10 +89,10 @@ static void uhci_insert_td_frame_list(struct uhci_hcd *uhci, struct uhci_td *td, | |||
89 | td->frame = framenum; | 89 | td->frame = framenum; |
90 | 90 | ||
91 | /* Is there a TD already mapped there? */ | 91 | /* Is there a TD already mapped there? */ |
92 | if (uhci->fl->frame_cpu[framenum]) { | 92 | if (uhci->frame_cpu[framenum]) { |
93 | struct uhci_td *ftd, *ltd; | 93 | struct uhci_td *ftd, *ltd; |
94 | 94 | ||
95 | ftd = uhci->fl->frame_cpu[framenum]; | 95 | ftd = uhci->frame_cpu[framenum]; |
96 | ltd = list_entry(ftd->fl_list.prev, struct uhci_td, fl_list); | 96 | ltd = list_entry(ftd->fl_list.prev, struct uhci_td, fl_list); |
97 | 97 | ||
98 | list_add_tail(&td->fl_list, &ftd->fl_list); | 98 | list_add_tail(&td->fl_list, &ftd->fl_list); |
@@ -101,29 +101,32 @@ static void uhci_insert_td_frame_list(struct uhci_hcd *uhci, struct uhci_td *td, | |||
101 | wmb(); | 101 | wmb(); |
102 | ltd->link = cpu_to_le32(td->dma_handle); | 102 | ltd->link = cpu_to_le32(td->dma_handle); |
103 | } else { | 103 | } else { |
104 | td->link = uhci->fl->frame[framenum]; | 104 | td->link = uhci->frame[framenum]; |
105 | wmb(); | 105 | wmb(); |
106 | uhci->fl->frame[framenum] = cpu_to_le32(td->dma_handle); | 106 | uhci->frame[framenum] = cpu_to_le32(td->dma_handle); |
107 | uhci->fl->frame_cpu[framenum] = td; | 107 | uhci->frame_cpu[framenum] = td; |
108 | } | 108 | } |
109 | } | 109 | } |
110 | 110 | ||
111 | static void uhci_remove_td(struct uhci_hcd *uhci, struct uhci_td *td) | 111 | static inline void uhci_remove_td_frame_list(struct uhci_hcd *uhci, |
112 | struct uhci_td *td) | ||
112 | { | 113 | { |
113 | /* If it's not inserted, don't remove it */ | 114 | /* If it's not inserted, don't remove it */ |
114 | if (td->frame == -1 && list_empty(&td->fl_list)) | 115 | if (td->frame == -1) { |
116 | WARN_ON(!list_empty(&td->fl_list)); | ||
115 | return; | 117 | return; |
118 | } | ||
116 | 119 | ||
117 | if (td->frame != -1 && uhci->fl->frame_cpu[td->frame] == td) { | 120 | if (uhci->frame_cpu[td->frame] == td) { |
118 | if (list_empty(&td->fl_list)) { | 121 | if (list_empty(&td->fl_list)) { |
119 | uhci->fl->frame[td->frame] = td->link; | 122 | uhci->frame[td->frame] = td->link; |
120 | uhci->fl->frame_cpu[td->frame] = NULL; | 123 | uhci->frame_cpu[td->frame] = NULL; |
121 | } else { | 124 | } else { |
122 | struct uhci_td *ntd; | 125 | struct uhci_td *ntd; |
123 | 126 | ||
124 | ntd = list_entry(td->fl_list.next, struct uhci_td, fl_list); | 127 | ntd = list_entry(td->fl_list.next, struct uhci_td, fl_list); |
125 | uhci->fl->frame[td->frame] = cpu_to_le32(ntd->dma_handle); | 128 | uhci->frame[td->frame] = cpu_to_le32(ntd->dma_handle); |
126 | uhci->fl->frame_cpu[td->frame] = ntd; | 129 | uhci->frame_cpu[td->frame] = ntd; |
127 | } | 130 | } |
128 | } else { | 131 | } else { |
129 | struct uhci_td *ptd; | 132 | struct uhci_td *ptd; |
@@ -132,13 +135,20 @@ static void uhci_remove_td(struct uhci_hcd *uhci, struct uhci_td *td) | |||
132 | ptd->link = td->link; | 135 | ptd->link = td->link; |
133 | } | 136 | } |
134 | 137 | ||
135 | wmb(); | ||
136 | td->link = UHCI_PTR_TERM; | ||
137 | |||
138 | list_del_init(&td->fl_list); | 138 | list_del_init(&td->fl_list); |
139 | td->frame = -1; | 139 | td->frame = -1; |
140 | } | 140 | } |
141 | 141 | ||
142 | static void unlink_isochronous_tds(struct uhci_hcd *uhci, struct urb *urb) | ||
143 | { | ||
144 | struct urb_priv *urbp = (struct urb_priv *) urb->hcpriv; | ||
145 | struct uhci_td *td; | ||
146 | |||
147 | list_for_each_entry(td, &urbp->td_list, list) | ||
148 | uhci_remove_td_frame_list(uhci, td); | ||
149 | wmb(); | ||
150 | } | ||
151 | |||
142 | /* | 152 | /* |
143 | * Inserts a td list into qh. | 153 | * Inserts a td list into qh. |
144 | */ | 154 | */ |
@@ -443,7 +453,6 @@ static struct urb_priv *uhci_alloc_urb_priv(struct uhci_hcd *uhci, struct urb *u | |||
443 | 453 | ||
444 | memset((void *)urbp, 0, sizeof(*urbp)); | 454 | memset((void *)urbp, 0, sizeof(*urbp)); |
445 | 455 | ||
446 | urbp->inserttime = jiffies; | ||
447 | urbp->fsbrtime = jiffies; | 456 | urbp->fsbrtime = jiffies; |
448 | urbp->urb = urb; | 457 | urbp->urb = urb; |
449 | 458 | ||
@@ -462,8 +471,6 @@ static void uhci_add_td_to_urb(struct urb *urb, struct uhci_td *td) | |||
462 | { | 471 | { |
463 | struct urb_priv *urbp = (struct urb_priv *)urb->hcpriv; | 472 | struct urb_priv *urbp = (struct urb_priv *)urb->hcpriv; |
464 | 473 | ||
465 | td->urb = urb; | ||
466 | |||
467 | list_add_tail(&td->list, &urbp->td_list); | 474 | list_add_tail(&td->list, &urbp->td_list); |
468 | } | 475 | } |
469 | 476 | ||
@@ -473,8 +480,6 @@ static void uhci_remove_td_from_urb(struct uhci_td *td) | |||
473 | return; | 480 | return; |
474 | 481 | ||
475 | list_del_init(&td->list); | 482 | list_del_init(&td->list); |
476 | |||
477 | td->urb = NULL; | ||
478 | } | 483 | } |
479 | 484 | ||
480 | static void uhci_destroy_urb_priv(struct uhci_hcd *uhci, struct urb *urb) | 485 | static void uhci_destroy_urb_priv(struct uhci_hcd *uhci, struct urb *urb) |
@@ -503,7 +508,6 @@ static void uhci_destroy_urb_priv(struct uhci_hcd *uhci, struct urb *urb) | |||
503 | 508 | ||
504 | list_for_each_entry_safe(td, tmp, &urbp->td_list, list) { | 509 | list_for_each_entry_safe(td, tmp, &urbp->td_list, list) { |
505 | uhci_remove_td_from_urb(td); | 510 | uhci_remove_td_from_urb(td); |
506 | uhci_remove_td(uhci, td); | ||
507 | list_add(&td->remove_list, &uhci->td_remove_list); | 511 | list_add(&td->remove_list, &uhci->td_remove_list); |
508 | } | 512 | } |
509 | 513 | ||
@@ -1073,6 +1077,7 @@ static int uhci_submit_isochronous(struct uhci_hcd *uhci, struct urb *urb) | |||
1073 | struct uhci_td *td; | 1077 | struct uhci_td *td; |
1074 | int i, ret, frame; | 1078 | int i, ret, frame; |
1075 | int status, destination; | 1079 | int status, destination; |
1080 | struct urb_priv *urbp = (struct urb_priv *) urb->hcpriv; | ||
1076 | 1081 | ||
1077 | status = TD_CTRL_ACTIVE | TD_CTRL_IOS; | 1082 | status = TD_CTRL_ACTIVE | TD_CTRL_IOS; |
1078 | destination = (urb->pipe & PIPE_DEVEP_MASK) | usb_packetid(urb->pipe); | 1083 | destination = (urb->pipe & PIPE_DEVEP_MASK) | usb_packetid(urb->pipe); |
@@ -1081,11 +1086,7 @@ static int uhci_submit_isochronous(struct uhci_hcd *uhci, struct urb *urb) | |||
1081 | if (ret) | 1086 | if (ret) |
1082 | return ret; | 1087 | return ret; |
1083 | 1088 | ||
1084 | frame = urb->start_frame; | 1089 | for (i = 0; i < urb->number_of_packets; i++) { |
1085 | for (i = 0; i < urb->number_of_packets; i++, frame += urb->interval) { | ||
1086 | if (!urb->iso_frame_desc[i].length) | ||
1087 | continue; | ||
1088 | |||
1089 | td = uhci_alloc_td(uhci); | 1090 | td = uhci_alloc_td(uhci); |
1090 | if (!td) | 1091 | if (!td) |
1091 | return -ENOMEM; | 1092 | return -ENOMEM; |
@@ -1096,8 +1097,12 @@ static int uhci_submit_isochronous(struct uhci_hcd *uhci, struct urb *urb) | |||
1096 | 1097 | ||
1097 | if (i + 1 >= urb->number_of_packets) | 1098 | if (i + 1 >= urb->number_of_packets) |
1098 | td->status |= cpu_to_le32(TD_CTRL_IOC); | 1099 | td->status |= cpu_to_le32(TD_CTRL_IOC); |
1100 | } | ||
1099 | 1101 | ||
1102 | frame = urb->start_frame; | ||
1103 | list_for_each_entry(td, &urbp->td_list, list) { | ||
1100 | uhci_insert_td_frame_list(uhci, td, frame); | 1104 | uhci_insert_td_frame_list(uhci, td, frame); |
1105 | frame += urb->interval; | ||
1101 | } | 1106 | } |
1102 | 1107 | ||
1103 | return -EINPROGRESS; | 1108 | return -EINPROGRESS; |
@@ -1110,7 +1115,7 @@ static int uhci_result_isochronous(struct uhci_hcd *uhci, struct urb *urb) | |||
1110 | int status; | 1115 | int status; |
1111 | int i, ret = 0; | 1116 | int i, ret = 0; |
1112 | 1117 | ||
1113 | urb->actual_length = 0; | 1118 | urb->actual_length = urb->error_count = 0; |
1114 | 1119 | ||
1115 | i = 0; | 1120 | i = 0; |
1116 | list_for_each_entry(td, &urbp->td_list, list) { | 1121 | list_for_each_entry(td, &urbp->td_list, list) { |
@@ -1134,6 +1139,7 @@ static int uhci_result_isochronous(struct uhci_hcd *uhci, struct urb *urb) | |||
1134 | 1139 | ||
1135 | i++; | 1140 | i++; |
1136 | } | 1141 | } |
1142 | unlink_isochronous_tds(uhci, urb); | ||
1137 | 1143 | ||
1138 | return ret; | 1144 | return ret; |
1139 | } | 1145 | } |
@@ -1164,7 +1170,7 @@ static struct urb *uhci_find_urb_ep(struct uhci_hcd *uhci, struct urb *urb) | |||
1164 | 1170 | ||
1165 | static int uhci_urb_enqueue(struct usb_hcd *hcd, | 1171 | static int uhci_urb_enqueue(struct usb_hcd *hcd, |
1166 | struct usb_host_endpoint *ep, | 1172 | struct usb_host_endpoint *ep, |
1167 | struct urb *urb, unsigned mem_flags) | 1173 | struct urb *urb, gfp_t mem_flags) |
1168 | { | 1174 | { |
1169 | int ret; | 1175 | int ret; |
1170 | struct uhci_hcd *uhci = hcd_to_uhci(hcd); | 1176 | struct uhci_hcd *uhci = hcd_to_uhci(hcd); |
@@ -1366,6 +1372,8 @@ static int uhci_urb_dequeue(struct usb_hcd *hcd, struct urb *urb) | |||
1366 | goto done; | 1372 | goto done; |
1367 | list_del_init(&urbp->urb_list); | 1373 | list_del_init(&urbp->urb_list); |
1368 | 1374 | ||
1375 | if (usb_pipetype(urb->pipe) == PIPE_ISOCHRONOUS) | ||
1376 | unlink_isochronous_tds(uhci, urb); | ||
1369 | uhci_unlink_generic(uhci, urb); | 1377 | uhci_unlink_generic(uhci, urb); |
1370 | 1378 | ||
1371 | uhci_get_current_frame_number(uhci); | 1379 | uhci_get_current_frame_number(uhci); |
diff --git a/drivers/usb/image/mdc800.c b/drivers/usb/image/mdc800.c index a330a4b50e16..1d973bcf56aa 100644 --- a/drivers/usb/image/mdc800.c +++ b/drivers/usb/image/mdc800.c | |||
@@ -425,9 +425,8 @@ static void mdc800_usb_download_notify (struct urb *urb, struct pt_regs *res) | |||
425 | static struct usb_driver mdc800_usb_driver; | 425 | static struct usb_driver mdc800_usb_driver; |
426 | static struct file_operations mdc800_device_ops; | 426 | static struct file_operations mdc800_device_ops; |
427 | static struct usb_class_driver mdc800_class = { | 427 | static struct usb_class_driver mdc800_class = { |
428 | .name = "usb/mdc800%d", | 428 | .name = "mdc800%d", |
429 | .fops = &mdc800_device_ops, | 429 | .fops = &mdc800_device_ops, |
430 | .mode = S_IFCHR | S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP, | ||
431 | .minor_base = MDC800_DEVICE_MINOR_BASE, | 430 | .minor_base = MDC800_DEVICE_MINOR_BASE, |
432 | }; | 431 | }; |
433 | 432 | ||
@@ -976,13 +975,13 @@ static struct usb_driver mdc800_usb_driver = | |||
976 | Init and Cleanup this driver (Main Functions) | 975 | Init and Cleanup this driver (Main Functions) |
977 | *************************************************************************/ | 976 | *************************************************************************/ |
978 | 977 | ||
979 | #define try(A) if (!(A)) goto cleanup_on_fail; | ||
980 | |||
981 | static int __init usb_mdc800_init (void) | 978 | static int __init usb_mdc800_init (void) |
982 | { | 979 | { |
983 | int retval = -ENODEV; | 980 | int retval = -ENODEV; |
984 | /* Allocate Memory */ | 981 | /* Allocate Memory */ |
985 | try (mdc800=kmalloc (sizeof (struct mdc800_data), GFP_KERNEL)); | 982 | mdc800=kmalloc (sizeof (struct mdc800_data), GFP_KERNEL); |
983 | if (!mdc800) | ||
984 | goto cleanup_on_fail; | ||
986 | 985 | ||
987 | memset(mdc800, 0, sizeof(struct mdc800_data)); | 986 | memset(mdc800, 0, sizeof(struct mdc800_data)); |
988 | mdc800->dev = NULL; | 987 | mdc800->dev = NULL; |
@@ -998,13 +997,25 @@ static int __init usb_mdc800_init (void) | |||
998 | mdc800->downloaded = 0; | 997 | mdc800->downloaded = 0; |
999 | mdc800->written = 0; | 998 | mdc800->written = 0; |
1000 | 999 | ||
1001 | try (mdc800->irq_urb_buffer=kmalloc (8, GFP_KERNEL)); | 1000 | mdc800->irq_urb_buffer=kmalloc (8, GFP_KERNEL); |
1002 | try (mdc800->write_urb_buffer=kmalloc (8, GFP_KERNEL)); | 1001 | if (!mdc800->irq_urb_buffer) |
1003 | try (mdc800->download_urb_buffer=kmalloc (64, GFP_KERNEL)); | 1002 | goto cleanup_on_fail; |
1003 | mdc800->write_urb_buffer=kmalloc (8, GFP_KERNEL); | ||
1004 | if (!mdc800->write_urb_buffer) | ||
1005 | goto cleanup_on_fail; | ||
1006 | mdc800->download_urb_buffer=kmalloc (64, GFP_KERNEL); | ||
1007 | if (!mdc800->download_urb_buffer) | ||
1008 | goto cleanup_on_fail; | ||
1004 | 1009 | ||
1005 | try (mdc800->irq_urb=usb_alloc_urb (0, GFP_KERNEL)); | 1010 | mdc800->irq_urb=usb_alloc_urb (0, GFP_KERNEL); |
1006 | try (mdc800->download_urb=usb_alloc_urb (0, GFP_KERNEL)); | 1011 | if (!mdc800->irq_urb) |
1007 | try (mdc800->write_urb=usb_alloc_urb (0, GFP_KERNEL)); | 1012 | goto cleanup_on_fail; |
1013 | mdc800->download_urb=usb_alloc_urb (0, GFP_KERNEL); | ||
1014 | if (!mdc800->download_urb) | ||
1015 | goto cleanup_on_fail; | ||
1016 | mdc800->write_urb=usb_alloc_urb (0, GFP_KERNEL); | ||
1017 | if (!mdc800->write_urb) | ||
1018 | goto cleanup_on_fail; | ||
1008 | 1019 | ||
1009 | /* Register the driver */ | 1020 | /* Register the driver */ |
1010 | retval = usb_register(&mdc800_usb_driver); | 1021 | retval = usb_register(&mdc800_usb_driver); |
diff --git a/drivers/usb/image/microtek.c b/drivers/usb/image/microtek.c index c84e1486054f..950543aa5ac7 100644 --- a/drivers/usb/image/microtek.c +++ b/drivers/usb/image/microtek.c | |||
@@ -327,6 +327,18 @@ static inline void mts_urb_abort(struct mts_desc* desc) { | |||
327 | usb_kill_urb( desc->urb ); | 327 | usb_kill_urb( desc->urb ); |
328 | } | 328 | } |
329 | 329 | ||
330 | static int mts_slave_alloc (struct scsi_device *s) | ||
331 | { | ||
332 | s->inquiry_len = 0x24; | ||
333 | return 0; | ||
334 | } | ||
335 | |||
336 | static int mts_slave_configure (struct scsi_device *s) | ||
337 | { | ||
338 | blk_queue_dma_alignment(s->request_queue, (512 - 1)); | ||
339 | return 0; | ||
340 | } | ||
341 | |||
330 | static int mts_scsi_abort (Scsi_Cmnd *srb) | 342 | static int mts_scsi_abort (Scsi_Cmnd *srb) |
331 | { | 343 | { |
332 | struct mts_desc* desc = (struct mts_desc*)(srb->device->host->hostdata[0]); | 344 | struct mts_desc* desc = (struct mts_desc*)(srb->device->host->hostdata[0]); |
@@ -411,7 +423,7 @@ static void mts_transfer_done( struct urb *transfer, struct pt_regs *regs ) | |||
411 | MTS_INT_INIT(); | 423 | MTS_INT_INIT(); |
412 | 424 | ||
413 | context->srb->result &= MTS_SCSI_ERR_MASK; | 425 | context->srb->result &= MTS_SCSI_ERR_MASK; |
414 | context->srb->result |= (unsigned)context->status<<1; | 426 | context->srb->result |= (unsigned)(*context->scsi_status)<<1; |
415 | 427 | ||
416 | mts_transfer_cleanup(transfer); | 428 | mts_transfer_cleanup(transfer); |
417 | 429 | ||
@@ -427,7 +439,7 @@ static void mts_get_status( struct urb *transfer ) | |||
427 | mts_int_submit_urb(transfer, | 439 | mts_int_submit_urb(transfer, |
428 | usb_rcvbulkpipe(context->instance->usb_dev, | 440 | usb_rcvbulkpipe(context->instance->usb_dev, |
429 | context->instance->ep_response), | 441 | context->instance->ep_response), |
430 | &context->status, | 442 | context->scsi_status, |
431 | 1, | 443 | 1, |
432 | mts_transfer_done ); | 444 | mts_transfer_done ); |
433 | } | 445 | } |
@@ -481,7 +493,7 @@ static void mts_command_done( struct urb *transfer, struct pt_regs *regs ) | |||
481 | context->data_pipe, | 493 | context->data_pipe, |
482 | context->data, | 494 | context->data, |
483 | context->data_length, | 495 | context->data_length, |
484 | context->srb->use_sg ? mts_do_sg : mts_data_done); | 496 | context->srb->use_sg > 1 ? mts_do_sg : mts_data_done); |
485 | } else { | 497 | } else { |
486 | mts_get_status(transfer); | 498 | mts_get_status(transfer); |
487 | } | 499 | } |
@@ -627,12 +639,11 @@ int mts_scsi_queuecommand( Scsi_Cmnd *srb, mts_scsi_cmnd_callback callback ) | |||
627 | callback(srb); | 639 | callback(srb); |
628 | 640 | ||
629 | } | 641 | } |
630 | |||
631 | out: | 642 | out: |
632 | return err; | 643 | return err; |
633 | } | 644 | } |
634 | 645 | ||
635 | static Scsi_Host_Template mts_scsi_host_template = { | 646 | static struct scsi_host_template mts_scsi_host_template = { |
636 | .module = THIS_MODULE, | 647 | .module = THIS_MODULE, |
637 | .name = "microtekX6", | 648 | .name = "microtekX6", |
638 | .proc_name = "microtekX6", | 649 | .proc_name = "microtekX6", |
@@ -645,6 +656,9 @@ static Scsi_Host_Template mts_scsi_host_template = { | |||
645 | .cmd_per_lun = 1, | 656 | .cmd_per_lun = 1, |
646 | .use_clustering = 1, | 657 | .use_clustering = 1, |
647 | .emulated = 1, | 658 | .emulated = 1, |
659 | .slave_alloc = mts_slave_alloc, | ||
660 | .slave_configure = mts_slave_configure, | ||
661 | .max_sectors= 256, /* 128 K */ | ||
648 | }; | 662 | }; |
649 | 663 | ||
650 | struct vendor_product | 664 | struct vendor_product |
@@ -771,17 +785,20 @@ static int mts_usb_probe(struct usb_interface *intf, | |||
771 | MTS_WARNING( "couldn't find an output bulk endpoint. Bailing out.\n" ); | 785 | MTS_WARNING( "couldn't find an output bulk endpoint. Bailing out.\n" ); |
772 | return -ENODEV; | 786 | return -ENODEV; |
773 | } | 787 | } |
774 | 788 | ||
775 | 789 | ||
776 | new_desc = kmalloc(sizeof(struct mts_desc), GFP_KERNEL); | 790 | new_desc = kzalloc(sizeof(struct mts_desc), GFP_KERNEL); |
777 | if (!new_desc) | 791 | if (!new_desc) |
778 | goto out; | 792 | goto out; |
779 | 793 | ||
780 | memset(new_desc, 0, sizeof(*new_desc)); | ||
781 | new_desc->urb = usb_alloc_urb(0, GFP_KERNEL); | 794 | new_desc->urb = usb_alloc_urb(0, GFP_KERNEL); |
782 | if (!new_desc->urb) | 795 | if (!new_desc->urb) |
783 | goto out_kfree; | 796 | goto out_kfree; |
784 | 797 | ||
798 | new_desc->context.scsi_status = kmalloc(1, GFP_KERNEL); | ||
799 | if (!new_desc->context.scsi_status) | ||
800 | goto out_kfree2; | ||
801 | |||
785 | new_desc->usb_dev = dev; | 802 | new_desc->usb_dev = dev; |
786 | new_desc->usb_intf = intf; | 803 | new_desc->usb_intf = intf; |
787 | init_MUTEX(&new_desc->lock); | 804 | init_MUTEX(&new_desc->lock); |
@@ -818,6 +835,8 @@ static int mts_usb_probe(struct usb_interface *intf, | |||
818 | usb_set_intfdata(intf, new_desc); | 835 | usb_set_intfdata(intf, new_desc); |
819 | return 0; | 836 | return 0; |
820 | 837 | ||
838 | out_kfree2: | ||
839 | kfree(new_desc->context.scsi_status); | ||
821 | out_free_urb: | 840 | out_free_urb: |
822 | usb_free_urb(new_desc->urb); | 841 | usb_free_urb(new_desc->urb); |
823 | out_kfree: | 842 | out_kfree: |
@@ -837,6 +856,7 @@ static void mts_usb_disconnect (struct usb_interface *intf) | |||
837 | 856 | ||
838 | scsi_host_put(desc->host); | 857 | scsi_host_put(desc->host); |
839 | usb_free_urb(desc->urb); | 858 | usb_free_urb(desc->urb); |
859 | kfree(desc->context.scsi_status); | ||
840 | kfree(desc); | 860 | kfree(desc); |
841 | } | 861 | } |
842 | 862 | ||
@@ -857,5 +877,3 @@ module_exit(microtek_drv_exit); | |||
857 | MODULE_AUTHOR( DRIVER_AUTHOR ); | 877 | MODULE_AUTHOR( DRIVER_AUTHOR ); |
858 | MODULE_DESCRIPTION( DRIVER_DESC ); | 878 | MODULE_DESCRIPTION( DRIVER_DESC ); |
859 | MODULE_LICENSE("GPL"); | 879 | MODULE_LICENSE("GPL"); |
860 | |||
861 | |||
diff --git a/drivers/usb/image/microtek.h b/drivers/usb/image/microtek.h index 3271deb8c001..926d4bdc6746 100644 --- a/drivers/usb/image/microtek.h +++ b/drivers/usb/image/microtek.h | |||
@@ -22,7 +22,7 @@ struct mts_transfer_context | |||
22 | int data_pipe; | 22 | int data_pipe; |
23 | int fragment; | 23 | int fragment; |
24 | 24 | ||
25 | u8 status; /* status returned from ep_response after command completion */ | 25 | u8 *scsi_status; /* status returned from ep_response after command completion */ |
26 | }; | 26 | }; |
27 | 27 | ||
28 | 28 | ||
diff --git a/drivers/usb/input/Makefile b/drivers/usb/input/Makefile index 5e03b93f29f6..07cb17db42fc 100644 --- a/drivers/usb/input/Makefile +++ b/drivers/usb/input/Makefile | |||
@@ -42,3 +42,7 @@ obj-$(CONFIG_USB_ACECAD) += acecad.o | |||
42 | obj-$(CONFIG_USB_YEALINK) += yealink.o | 42 | obj-$(CONFIG_USB_YEALINK) += yealink.o |
43 | obj-$(CONFIG_USB_XPAD) += xpad.o | 43 | obj-$(CONFIG_USB_XPAD) += xpad.o |
44 | obj-$(CONFIG_USB_APPLETOUCH) += appletouch.o | 44 | obj-$(CONFIG_USB_APPLETOUCH) += appletouch.o |
45 | |||
46 | ifeq ($(CONFIG_USB_DEBUG),y) | ||
47 | EXTRA_CFLAGS += -DDEBUG | ||
48 | endif | ||
diff --git a/drivers/usb/input/acecad.c b/drivers/usb/input/acecad.c index 74f8760d7c07..a32558b4048e 100644 --- a/drivers/usb/input/acecad.c +++ b/drivers/usb/input/acecad.c | |||
@@ -53,7 +53,7 @@ struct usb_acecad { | |||
53 | char name[128]; | 53 | char name[128]; |
54 | char phys[64]; | 54 | char phys[64]; |
55 | struct usb_device *usbdev; | 55 | struct usb_device *usbdev; |
56 | struct input_dev dev; | 56 | struct input_dev *input; |
57 | struct urb *irq; | 57 | struct urb *irq; |
58 | 58 | ||
59 | signed char *data; | 59 | signed char *data; |
@@ -64,7 +64,7 @@ static void usb_acecad_irq(struct urb *urb, struct pt_regs *regs) | |||
64 | { | 64 | { |
65 | struct usb_acecad *acecad = urb->context; | 65 | struct usb_acecad *acecad = urb->context; |
66 | unsigned char *data = acecad->data; | 66 | unsigned char *data = acecad->data; |
67 | struct input_dev *dev = &acecad->dev; | 67 | struct input_dev *dev = acecad->input; |
68 | int prox, status; | 68 | int prox, status; |
69 | 69 | ||
70 | switch (urb->status) { | 70 | switch (urb->status) { |
@@ -135,8 +135,8 @@ static int usb_acecad_probe(struct usb_interface *intf, const struct usb_device_ | |||
135 | struct usb_host_interface *interface = intf->cur_altsetting; | 135 | struct usb_host_interface *interface = intf->cur_altsetting; |
136 | struct usb_endpoint_descriptor *endpoint; | 136 | struct usb_endpoint_descriptor *endpoint; |
137 | struct usb_acecad *acecad; | 137 | struct usb_acecad *acecad; |
138 | struct input_dev *input_dev; | ||
138 | int pipe, maxp; | 139 | int pipe, maxp; |
139 | char path[64]; | ||
140 | 140 | ||
141 | if (interface->desc.bNumEndpoints != 1) | 141 | if (interface->desc.bNumEndpoints != 1) |
142 | return -ENODEV; | 142 | return -ENODEV; |
@@ -153,8 +153,9 @@ static int usb_acecad_probe(struct usb_interface *intf, const struct usb_device_ | |||
153 | maxp = usb_maxpacket(dev, pipe, usb_pipeout(pipe)); | 153 | maxp = usb_maxpacket(dev, pipe, usb_pipeout(pipe)); |
154 | 154 | ||
155 | acecad = kzalloc(sizeof(struct usb_acecad), GFP_KERNEL); | 155 | acecad = kzalloc(sizeof(struct usb_acecad), GFP_KERNEL); |
156 | if (!acecad) | 156 | input_dev = input_allocate_device(); |
157 | return -ENOMEM; | 157 | if (!acecad || !input_dev) |
158 | goto fail1; | ||
158 | 159 | ||
159 | acecad->data = usb_buffer_alloc(dev, 8, SLAB_KERNEL, &acecad->data_dma); | 160 | acecad->data = usb_buffer_alloc(dev, 8, SLAB_KERNEL, &acecad->data_dma); |
160 | if (!acecad->data) | 161 | if (!acecad->data) |
@@ -164,6 +165,9 @@ static int usb_acecad_probe(struct usb_interface *intf, const struct usb_device_ | |||
164 | if (!acecad->irq) | 165 | if (!acecad->irq) |
165 | goto fail2; | 166 | goto fail2; |
166 | 167 | ||
168 | acecad->usbdev = dev; | ||
169 | acecad->input = input_dev; | ||
170 | |||
167 | if (dev->manufacturer) | 171 | if (dev->manufacturer) |
168 | strlcpy(acecad->name, dev->manufacturer, sizeof(acecad->name)); | 172 | strlcpy(acecad->name, dev->manufacturer, sizeof(acecad->name)); |
169 | 173 | ||
@@ -173,48 +177,48 @@ static int usb_acecad_probe(struct usb_interface *intf, const struct usb_device_ | |||
173 | strlcat(acecad->name, dev->product, sizeof(acecad->name)); | 177 | strlcat(acecad->name, dev->product, sizeof(acecad->name)); |
174 | } | 178 | } |
175 | 179 | ||
176 | usb_make_path(dev, path, sizeof(path)); | 180 | usb_make_path(dev, acecad->phys, sizeof(acecad->phys)); |
177 | snprintf(acecad->phys, sizeof(acecad->phys), "%s/input0", path); | 181 | strlcat(acecad->phys, "/input0", sizeof(acecad->phys)); |
178 | 182 | ||
179 | acecad->usbdev = dev; | 183 | input_dev->name = acecad->name; |
184 | input_dev->phys = acecad->phys; | ||
185 | usb_to_input_id(dev, &input_dev->id); | ||
186 | input_dev->cdev.dev = &intf->dev; | ||
187 | input_dev->private = acecad; | ||
180 | 188 | ||
181 | acecad->dev.evbit[0] = BIT(EV_KEY) | BIT(EV_ABS); | 189 | input_dev->open = usb_acecad_open; |
182 | acecad->dev.absbit[0] = BIT(ABS_X) | BIT(ABS_Y) | BIT(ABS_PRESSURE); | 190 | input_dev->close = usb_acecad_close; |
183 | acecad->dev.keybit[LONG(BTN_LEFT)] = BIT(BTN_LEFT) | BIT(BTN_RIGHT) | BIT(BTN_MIDDLE); | 191 | |
184 | acecad->dev.keybit[LONG(BTN_DIGI)] = BIT(BTN_TOOL_PEN) |BIT(BTN_TOUCH) | BIT(BTN_STYLUS) | BIT(BTN_STYLUS2); | 192 | input_dev->evbit[0] = BIT(EV_KEY) | BIT(EV_ABS); |
193 | input_dev->absbit[0] = BIT(ABS_X) | BIT(ABS_Y) | BIT(ABS_PRESSURE); | ||
194 | input_dev->keybit[LONG(BTN_LEFT)] = BIT(BTN_LEFT) | BIT(BTN_RIGHT) | BIT(BTN_MIDDLE); | ||
195 | input_dev->keybit[LONG(BTN_DIGI)] = BIT(BTN_TOOL_PEN) |BIT(BTN_TOUCH) | BIT(BTN_STYLUS) | BIT(BTN_STYLUS2); | ||
185 | 196 | ||
186 | switch (id->driver_info) { | 197 | switch (id->driver_info) { |
187 | case 0: | 198 | case 0: |
188 | acecad->dev.absmax[ABS_X] = 5000; | 199 | input_dev->absmax[ABS_X] = 5000; |
189 | acecad->dev.absmax[ABS_Y] = 3750; | 200 | input_dev->absmax[ABS_Y] = 3750; |
190 | acecad->dev.absmax[ABS_PRESSURE] = 512; | 201 | input_dev->absmax[ABS_PRESSURE] = 512; |
191 | if (!strlen(acecad->name)) | 202 | if (!strlen(acecad->name)) |
192 | snprintf(acecad->name, sizeof(acecad->name), | 203 | snprintf(acecad->name, sizeof(acecad->name), |
193 | "USB Acecad Flair Tablet %04x:%04x", | 204 | "USB Acecad Flair Tablet %04x:%04x", |
194 | dev->descriptor.idVendor, dev->descriptor.idProduct); | 205 | le16_to_cpu(dev->descriptor.idVendor), |
206 | le16_to_cpu(dev->descriptor.idProduct)); | ||
195 | break; | 207 | break; |
196 | case 1: | 208 | case 1: |
197 | acecad->dev.absmax[ABS_X] = 3000; | 209 | input_dev->absmax[ABS_X] = 3000; |
198 | acecad->dev.absmax[ABS_Y] = 2250; | 210 | input_dev->absmax[ABS_Y] = 2250; |
199 | acecad->dev.absmax[ABS_PRESSURE] = 1024; | 211 | input_dev->absmax[ABS_PRESSURE] = 1024; |
200 | if (!strlen(acecad->name)) | 212 | if (!strlen(acecad->name)) |
201 | snprintf(acecad->name, sizeof(acecad->name), | 213 | snprintf(acecad->name, sizeof(acecad->name), |
202 | "USB Acecad 302 Tablet %04x:%04x", | 214 | "USB Acecad 302 Tablet %04x:%04x", |
203 | dev->descriptor.idVendor, dev->descriptor.idProduct); | 215 | le16_to_cpu(dev->descriptor.idVendor), |
216 | le16_to_cpu(dev->descriptor.idProduct)); | ||
204 | break; | 217 | break; |
205 | } | 218 | } |
206 | 219 | ||
207 | acecad->dev.absfuzz[ABS_X] = 4; | 220 | input_dev->absfuzz[ABS_X] = 4; |
208 | acecad->dev.absfuzz[ABS_Y] = 4; | 221 | input_dev->absfuzz[ABS_Y] = 4; |
209 | |||
210 | acecad->dev.private = acecad; | ||
211 | acecad->dev.open = usb_acecad_open; | ||
212 | acecad->dev.close = usb_acecad_close; | ||
213 | |||
214 | acecad->dev.name = acecad->name; | ||
215 | acecad->dev.phys = acecad->phys; | ||
216 | usb_to_input_id(dev, &acecad->dev.id); | ||
217 | acecad->dev.dev = &intf->dev; | ||
218 | 222 | ||
219 | usb_fill_int_urb(acecad->irq, dev, pipe, | 223 | usb_fill_int_urb(acecad->irq, dev, pipe, |
220 | acecad->data, maxp > 8 ? 8 : maxp, | 224 | acecad->data, maxp > 8 ? 8 : maxp, |
@@ -222,17 +226,15 @@ static int usb_acecad_probe(struct usb_interface *intf, const struct usb_device_ | |||
222 | acecad->irq->transfer_dma = acecad->data_dma; | 226 | acecad->irq->transfer_dma = acecad->data_dma; |
223 | acecad->irq->transfer_flags |= URB_NO_TRANSFER_DMA_MAP; | 227 | acecad->irq->transfer_flags |= URB_NO_TRANSFER_DMA_MAP; |
224 | 228 | ||
225 | input_register_device(&acecad->dev); | 229 | input_register_device(acecad->input); |
226 | |||
227 | printk(KERN_INFO "input: %s with packet size %d on %s\n", | ||
228 | acecad->name, maxp, path); | ||
229 | 230 | ||
230 | usb_set_intfdata(intf, acecad); | 231 | usb_set_intfdata(intf, acecad); |
231 | 232 | ||
232 | return 0; | 233 | return 0; |
233 | 234 | ||
234 | fail2: usb_buffer_free(dev, 8, acecad->data, acecad->data_dma); | 235 | fail2: usb_buffer_free(dev, 8, acecad->data, acecad->data_dma); |
235 | fail1: kfree(acecad); | 236 | fail1: input_free_device(input_dev); |
237 | kfree(acecad); | ||
236 | return -ENOMEM; | 238 | return -ENOMEM; |
237 | } | 239 | } |
238 | 240 | ||
@@ -243,7 +245,7 @@ static void usb_acecad_disconnect(struct usb_interface *intf) | |||
243 | usb_set_intfdata(intf, NULL); | 245 | usb_set_intfdata(intf, NULL); |
244 | if (acecad) { | 246 | if (acecad) { |
245 | usb_kill_urb(acecad->irq); | 247 | usb_kill_urb(acecad->irq); |
246 | input_unregister_device(&acecad->dev); | 248 | input_unregister_device(acecad->input); |
247 | usb_free_urb(acecad->irq); | 249 | usb_free_urb(acecad->irq); |
248 | usb_buffer_free(interface_to_usbdev(intf), 10, acecad->data, acecad->data_dma); | 250 | usb_buffer_free(interface_to_usbdev(intf), 10, acecad->data, acecad->data_dma); |
249 | kfree(acecad); | 251 | kfree(acecad); |
diff --git a/drivers/usb/input/aiptek.c b/drivers/usb/input/aiptek.c index cd0cbfe20723..1c3b472a3bca 100644 --- a/drivers/usb/input/aiptek.c +++ b/drivers/usb/input/aiptek.c | |||
@@ -317,7 +317,7 @@ struct aiptek_settings { | |||
317 | }; | 317 | }; |
318 | 318 | ||
319 | struct aiptek { | 319 | struct aiptek { |
320 | struct input_dev inputdev; /* input device struct */ | 320 | struct input_dev *inputdev; /* input device struct */ |
321 | struct usb_device *usbdev; /* usb device struct */ | 321 | struct usb_device *usbdev; /* usb device struct */ |
322 | struct urb *urb; /* urb for incoming reports */ | 322 | struct urb *urb; /* urb for incoming reports */ |
323 | dma_addr_t data_dma; /* our dma stuffage */ | 323 | dma_addr_t data_dma; /* our dma stuffage */ |
@@ -402,7 +402,7 @@ static void aiptek_irq(struct urb *urb, struct pt_regs *regs) | |||
402 | { | 402 | { |
403 | struct aiptek *aiptek = urb->context; | 403 | struct aiptek *aiptek = urb->context; |
404 | unsigned char *data = aiptek->data; | 404 | unsigned char *data = aiptek->data; |
405 | struct input_dev *inputdev = &aiptek->inputdev; | 405 | struct input_dev *inputdev = aiptek->inputdev; |
406 | int jitterable = 0; | 406 | int jitterable = 0; |
407 | int retval, macro, x, y, z, left, right, middle, p, dv, tip, bs, pck; | 407 | int retval, macro, x, y, z, left, right, middle, p, dv, tip, bs, pck; |
408 | 408 | ||
@@ -955,20 +955,20 @@ static int aiptek_program_tablet(struct aiptek *aiptek) | |||
955 | /* Query getXextension */ | 955 | /* Query getXextension */ |
956 | if ((ret = aiptek_query(aiptek, 0x01, 0x00)) < 0) | 956 | if ((ret = aiptek_query(aiptek, 0x01, 0x00)) < 0) |
957 | return ret; | 957 | return ret; |
958 | aiptek->inputdev.absmin[ABS_X] = 0; | 958 | aiptek->inputdev->absmin[ABS_X] = 0; |
959 | aiptek->inputdev.absmax[ABS_X] = ret - 1; | 959 | aiptek->inputdev->absmax[ABS_X] = ret - 1; |
960 | 960 | ||
961 | /* Query getYextension */ | 961 | /* Query getYextension */ |
962 | if ((ret = aiptek_query(aiptek, 0x01, 0x01)) < 0) | 962 | if ((ret = aiptek_query(aiptek, 0x01, 0x01)) < 0) |
963 | return ret; | 963 | return ret; |
964 | aiptek->inputdev.absmin[ABS_Y] = 0; | 964 | aiptek->inputdev->absmin[ABS_Y] = 0; |
965 | aiptek->inputdev.absmax[ABS_Y] = ret - 1; | 965 | aiptek->inputdev->absmax[ABS_Y] = ret - 1; |
966 | 966 | ||
967 | /* Query getPressureLevels */ | 967 | /* Query getPressureLevels */ |
968 | if ((ret = aiptek_query(aiptek, 0x08, 0x00)) < 0) | 968 | if ((ret = aiptek_query(aiptek, 0x08, 0x00)) < 0) |
969 | return ret; | 969 | return ret; |
970 | aiptek->inputdev.absmin[ABS_PRESSURE] = 0; | 970 | aiptek->inputdev->absmin[ABS_PRESSURE] = 0; |
971 | aiptek->inputdev.absmax[ABS_PRESSURE] = ret - 1; | 971 | aiptek->inputdev->absmax[ABS_PRESSURE] = ret - 1; |
972 | 972 | ||
973 | /* Depending on whether we are in absolute or relative mode, we will | 973 | /* Depending on whether we are in absolute or relative mode, we will |
974 | * do a switchToTablet(absolute) or switchToMouse(relative) command. | 974 | * do a switchToTablet(absolute) or switchToMouse(relative) command. |
@@ -1025,8 +1025,8 @@ static ssize_t show_tabletSize(struct device *dev, struct device_attribute *attr | |||
1025 | return 0; | 1025 | return 0; |
1026 | 1026 | ||
1027 | return snprintf(buf, PAGE_SIZE, "%dx%d\n", | 1027 | return snprintf(buf, PAGE_SIZE, "%dx%d\n", |
1028 | aiptek->inputdev.absmax[ABS_X] + 1, | 1028 | aiptek->inputdev->absmax[ABS_X] + 1, |
1029 | aiptek->inputdev.absmax[ABS_Y] + 1); | 1029 | aiptek->inputdev->absmax[ABS_Y] + 1); |
1030 | } | 1030 | } |
1031 | 1031 | ||
1032 | /* These structs define the sysfs files, param #1 is the name of the | 1032 | /* These structs define the sysfs files, param #1 is the name of the |
@@ -1048,7 +1048,7 @@ static ssize_t show_tabletProductId(struct device *dev, struct device_attribute | |||
1048 | return 0; | 1048 | return 0; |
1049 | 1049 | ||
1050 | return snprintf(buf, PAGE_SIZE, "0x%04x\n", | 1050 | return snprintf(buf, PAGE_SIZE, "0x%04x\n", |
1051 | aiptek->inputdev.id.product); | 1051 | aiptek->inputdev->id.product); |
1052 | } | 1052 | } |
1053 | 1053 | ||
1054 | static DEVICE_ATTR(product_id, S_IRUGO, show_tabletProductId, NULL); | 1054 | static DEVICE_ATTR(product_id, S_IRUGO, show_tabletProductId, NULL); |
@@ -1063,7 +1063,7 @@ static ssize_t show_tabletVendorId(struct device *dev, struct device_attribute * | |||
1063 | if (aiptek == NULL) | 1063 | if (aiptek == NULL) |
1064 | return 0; | 1064 | return 0; |
1065 | 1065 | ||
1066 | return snprintf(buf, PAGE_SIZE, "0x%04x\n", aiptek->inputdev.id.vendor); | 1066 | return snprintf(buf, PAGE_SIZE, "0x%04x\n", aiptek->inputdev->id.vendor); |
1067 | } | 1067 | } |
1068 | 1068 | ||
1069 | static DEVICE_ATTR(vendor_id, S_IRUGO, show_tabletVendorId, NULL); | 1069 | static DEVICE_ATTR(vendor_id, S_IRUGO, show_tabletVendorId, NULL); |
@@ -1977,7 +1977,6 @@ aiptek_probe(struct usb_interface *intf, const struct usb_device_id *id) | |||
1977 | struct input_dev *inputdev; | 1977 | struct input_dev *inputdev; |
1978 | struct input_handle *inputhandle; | 1978 | struct input_handle *inputhandle; |
1979 | struct list_head *node, *next; | 1979 | struct list_head *node, *next; |
1980 | char path[64 + 1]; | ||
1981 | int i; | 1980 | int i; |
1982 | int speeds[] = { 0, | 1981 | int speeds[] = { 0, |
1983 | AIPTEK_PROGRAMMABLE_DELAY_50, | 1982 | AIPTEK_PROGRAMMABLE_DELAY_50, |
@@ -1996,24 +1995,26 @@ aiptek_probe(struct usb_interface *intf, const struct usb_device_id *id) | |||
1996 | */ | 1995 | */ |
1997 | speeds[0] = programmableDelay; | 1996 | speeds[0] = programmableDelay; |
1998 | 1997 | ||
1999 | if ((aiptek = kmalloc(sizeof(struct aiptek), GFP_KERNEL)) == NULL) | 1998 | aiptek = kzalloc(sizeof(struct aiptek), GFP_KERNEL); |
2000 | return -ENOMEM; | 1999 | inputdev = input_allocate_device(); |
2001 | memset(aiptek, 0, sizeof(struct aiptek)); | 2000 | if (!aiptek || !inputdev) |
2001 | goto fail1; | ||
2002 | 2002 | ||
2003 | aiptek->data = usb_buffer_alloc(usbdev, AIPTEK_PACKET_LENGTH, | 2003 | aiptek->data = usb_buffer_alloc(usbdev, AIPTEK_PACKET_LENGTH, |
2004 | SLAB_ATOMIC, &aiptek->data_dma); | 2004 | SLAB_ATOMIC, &aiptek->data_dma); |
2005 | if (aiptek->data == NULL) { | 2005 | if (!aiptek->data) |
2006 | kfree(aiptek); | 2006 | goto fail1; |
2007 | return -ENOMEM; | ||
2008 | } | ||
2009 | 2007 | ||
2010 | aiptek->urb = usb_alloc_urb(0, GFP_KERNEL); | 2008 | aiptek->urb = usb_alloc_urb(0, GFP_KERNEL); |
2011 | if (aiptek->urb == NULL) { | 2009 | if (!aiptek->urb) |
2012 | usb_buffer_free(usbdev, AIPTEK_PACKET_LENGTH, aiptek->data, | 2010 | goto fail2; |
2013 | aiptek->data_dma); | 2011 | |
2014 | kfree(aiptek); | 2012 | aiptek->inputdev = inputdev; |
2015 | return -ENOMEM; | 2013 | aiptek->usbdev = usbdev; |
2016 | } | 2014 | aiptek->ifnum = intf->altsetting[0].desc.bInterfaceNumber; |
2015 | aiptek->inDelay = 0; | ||
2016 | aiptek->endDelay = 0; | ||
2017 | aiptek->previousJitterable = 0; | ||
2017 | 2018 | ||
2018 | /* Set up the curSettings struct. Said struct contains the current | 2019 | /* Set up the curSettings struct. Said struct contains the current |
2019 | * programmable parameters. The newSetting struct contains changes | 2020 | * programmable parameters. The newSetting struct contains changes |
@@ -2036,31 +2037,48 @@ aiptek_probe(struct usb_interface *intf, const struct usb_device_id *id) | |||
2036 | 2037 | ||
2037 | /* Both structs should have equivalent settings | 2038 | /* Both structs should have equivalent settings |
2038 | */ | 2039 | */ |
2039 | memcpy(&aiptek->newSetting, &aiptek->curSetting, | 2040 | aiptek->newSetting = aiptek->curSetting; |
2040 | sizeof(struct aiptek_settings)); | 2041 | |
2042 | /* Determine the usb devices' physical path. | ||
2043 | * Asketh not why we always pretend we're using "../input0", | ||
2044 | * but I suspect this will have to be refactored one | ||
2045 | * day if a single USB device can be a keyboard & a mouse | ||
2046 | * & a tablet, and the inputX number actually will tell | ||
2047 | * us something... | ||
2048 | */ | ||
2049 | usb_make_path(usbdev, aiptek->features.usbPath, | ||
2050 | sizeof(aiptek->features.usbPath)); | ||
2051 | strlcat(aiptek->features.usbPath, "/input0", | ||
2052 | sizeof(aiptek->features.usbPath)); | ||
2053 | |||
2054 | /* Set up client data, pointers to open and close routines | ||
2055 | * for the input device. | ||
2056 | */ | ||
2057 | inputdev->name = "Aiptek"; | ||
2058 | inputdev->phys = aiptek->features.usbPath; | ||
2059 | usb_to_input_id(usbdev, &inputdev->id); | ||
2060 | inputdev->cdev.dev = &intf->dev; | ||
2061 | inputdev->private = aiptek; | ||
2062 | inputdev->open = aiptek_open; | ||
2063 | inputdev->close = aiptek_close; | ||
2041 | 2064 | ||
2042 | /* Now program the capacities of the tablet, in terms of being | 2065 | /* Now program the capacities of the tablet, in terms of being |
2043 | * an input device. | 2066 | * an input device. |
2044 | */ | 2067 | */ |
2045 | aiptek->inputdev.evbit[0] |= BIT(EV_KEY) | 2068 | inputdev->evbit[0] |= BIT(EV_KEY) |
2046 | | BIT(EV_ABS) | 2069 | | BIT(EV_ABS) |
2047 | | BIT(EV_REL) | 2070 | | BIT(EV_REL) |
2048 | | BIT(EV_MSC); | 2071 | | BIT(EV_MSC); |
2049 | 2072 | ||
2050 | aiptek->inputdev.absbit[0] |= | 2073 | inputdev->absbit[0] |= BIT(ABS_MISC); |
2051 | (BIT(ABS_X) | | ||
2052 | BIT(ABS_Y) | | ||
2053 | BIT(ABS_PRESSURE) | | ||
2054 | BIT(ABS_TILT_X) | | ||
2055 | BIT(ABS_TILT_Y) | BIT(ABS_WHEEL) | BIT(ABS_MISC)); | ||
2056 | 2074 | ||
2057 | aiptek->inputdev.relbit[0] |= | 2075 | inputdev->relbit[0] |= |
2058 | (BIT(REL_X) | BIT(REL_Y) | BIT(REL_WHEEL) | BIT(REL_MISC)); | 2076 | (BIT(REL_X) | BIT(REL_Y) | BIT(REL_WHEEL) | BIT(REL_MISC)); |
2059 | 2077 | ||
2060 | aiptek->inputdev.keybit[LONG(BTN_LEFT)] |= | 2078 | inputdev->keybit[LONG(BTN_LEFT)] |= |
2061 | (BIT(BTN_LEFT) | BIT(BTN_RIGHT) | BIT(BTN_MIDDLE)); | 2079 | (BIT(BTN_LEFT) | BIT(BTN_RIGHT) | BIT(BTN_MIDDLE)); |
2062 | 2080 | ||
2063 | aiptek->inputdev.keybit[LONG(BTN_DIGI)] |= | 2081 | inputdev->keybit[LONG(BTN_DIGI)] |= |
2064 | (BIT(BTN_TOOL_PEN) | | 2082 | (BIT(BTN_TOOL_PEN) | |
2065 | BIT(BTN_TOOL_RUBBER) | | 2083 | BIT(BTN_TOOL_RUBBER) | |
2066 | BIT(BTN_TOOL_PENCIL) | | 2084 | BIT(BTN_TOOL_PENCIL) | |
@@ -2070,70 +2088,26 @@ aiptek_probe(struct usb_interface *intf, const struct usb_device_id *id) | |||
2070 | BIT(BTN_TOOL_LENS) | | 2088 | BIT(BTN_TOOL_LENS) | |
2071 | BIT(BTN_TOUCH) | BIT(BTN_STYLUS) | BIT(BTN_STYLUS2)); | 2089 | BIT(BTN_TOUCH) | BIT(BTN_STYLUS) | BIT(BTN_STYLUS2)); |
2072 | 2090 | ||
2073 | aiptek->inputdev.mscbit[0] = BIT(MSC_SERIAL); | 2091 | inputdev->mscbit[0] = BIT(MSC_SERIAL); |
2074 | 2092 | ||
2075 | /* Programming the tablet macro keys needs to be done with a for loop | 2093 | /* Programming the tablet macro keys needs to be done with a for loop |
2076 | * as the keycodes are discontiguous. | 2094 | * as the keycodes are discontiguous. |
2077 | */ | 2095 | */ |
2078 | for (i = 0; i < sizeof(macroKeyEvents) / sizeof(macroKeyEvents[0]); ++i) | 2096 | for (i = 0; i < sizeof(macroKeyEvents) / sizeof(macroKeyEvents[0]); ++i) |
2079 | set_bit(macroKeyEvents[i], aiptek->inputdev.keybit); | 2097 | set_bit(macroKeyEvents[i], inputdev->keybit); |
2080 | |||
2081 | /* Set up client data, pointers to open and close routines | ||
2082 | * for the input device. | ||
2083 | */ | ||
2084 | aiptek->inputdev.private = aiptek; | ||
2085 | aiptek->inputdev.open = aiptek_open; | ||
2086 | aiptek->inputdev.close = aiptek_close; | ||
2087 | 2098 | ||
2088 | /* Determine the usb devices' physical path. | 2099 | /* |
2089 | * Asketh not why we always pretend we're using "../input0", | 2100 | * Program the input device coordinate capacities. We do not yet |
2090 | * but I suspect this will have to be refactored one | ||
2091 | * day if a single USB device can be a keyboard & a mouse | ||
2092 | * & a tablet, and the inputX number actually will tell | ||
2093 | * us something... | ||
2094 | */ | ||
2095 | if (usb_make_path(usbdev, path, 64) > 0) | ||
2096 | sprintf(aiptek->features.usbPath, "%s/input0", path); | ||
2097 | |||
2098 | /* Program the input device coordinate capacities. We do not yet | ||
2099 | * know what maximum X, Y, and Z values are, so we're putting fake | 2101 | * know what maximum X, Y, and Z values are, so we're putting fake |
2100 | * values in. Later, we'll ask the tablet to put in the correct | 2102 | * values in. Later, we'll ask the tablet to put in the correct |
2101 | * values. | 2103 | * values. |
2102 | */ | 2104 | */ |
2103 | aiptek->inputdev.absmin[ABS_X] = 0; | 2105 | input_set_abs_params(inputdev, ABS_X, 0, 2999, 0, 0); |
2104 | aiptek->inputdev.absmax[ABS_X] = 2999; | 2106 | input_set_abs_params(inputdev, ABS_X, 0, 2249, 0, 0); |
2105 | aiptek->inputdev.absmin[ABS_Y] = 0; | 2107 | input_set_abs_params(inputdev, ABS_PRESSURE, 0, 511, 0, 0); |
2106 | aiptek->inputdev.absmax[ABS_Y] = 2249; | 2108 | input_set_abs_params(inputdev, ABS_TILT_X, AIPTEK_TILT_MIN, AIPTEK_TILT_MAX, 0, 0); |
2107 | aiptek->inputdev.absmin[ABS_PRESSURE] = 0; | 2109 | input_set_abs_params(inputdev, ABS_TILT_Y, AIPTEK_TILT_MIN, AIPTEK_TILT_MAX, 0, 0); |
2108 | aiptek->inputdev.absmax[ABS_PRESSURE] = 511; | 2110 | input_set_abs_params(inputdev, ABS_WHEEL, AIPTEK_WHEEL_MIN, AIPTEK_WHEEL_MAX - 1, 0, 0); |
2109 | aiptek->inputdev.absmin[ABS_TILT_X] = AIPTEK_TILT_MIN; | ||
2110 | aiptek->inputdev.absmax[ABS_TILT_X] = AIPTEK_TILT_MAX; | ||
2111 | aiptek->inputdev.absmin[ABS_TILT_Y] = AIPTEK_TILT_MIN; | ||
2112 | aiptek->inputdev.absmax[ABS_TILT_Y] = AIPTEK_TILT_MAX; | ||
2113 | aiptek->inputdev.absmin[ABS_WHEEL] = AIPTEK_WHEEL_MIN; | ||
2114 | aiptek->inputdev.absmax[ABS_WHEEL] = AIPTEK_WHEEL_MAX - 1; | ||
2115 | aiptek->inputdev.absfuzz[ABS_X] = 0; | ||
2116 | aiptek->inputdev.absfuzz[ABS_Y] = 0; | ||
2117 | aiptek->inputdev.absfuzz[ABS_PRESSURE] = 0; | ||
2118 | aiptek->inputdev.absfuzz[ABS_TILT_X] = 0; | ||
2119 | aiptek->inputdev.absfuzz[ABS_TILT_Y] = 0; | ||
2120 | aiptek->inputdev.absfuzz[ABS_WHEEL] = 0; | ||
2121 | aiptek->inputdev.absflat[ABS_X] = 0; | ||
2122 | aiptek->inputdev.absflat[ABS_Y] = 0; | ||
2123 | aiptek->inputdev.absflat[ABS_PRESSURE] = 0; | ||
2124 | aiptek->inputdev.absflat[ABS_TILT_X] = 0; | ||
2125 | aiptek->inputdev.absflat[ABS_TILT_Y] = 0; | ||
2126 | aiptek->inputdev.absflat[ABS_WHEEL] = 0; | ||
2127 | aiptek->inputdev.name = "Aiptek"; | ||
2128 | aiptek->inputdev.phys = aiptek->features.usbPath; | ||
2129 | usb_to_input_id(usbdev, &aiptek->inputdev.id); | ||
2130 | aiptek->inputdev.dev = &intf->dev; | ||
2131 | |||
2132 | aiptek->usbdev = usbdev; | ||
2133 | aiptek->ifnum = intf->altsetting[0].desc.bInterfaceNumber; | ||
2134 | aiptek->inDelay = 0; | ||
2135 | aiptek->endDelay = 0; | ||
2136 | aiptek->previousJitterable = 0; | ||
2137 | 2111 | ||
2138 | endpoint = &intf->altsetting[0].endpoint[0].desc; | 2112 | endpoint = &intf->altsetting[0].endpoint[0].desc; |
2139 | 2113 | ||
@@ -2150,28 +2124,6 @@ aiptek_probe(struct usb_interface *intf, const struct usb_device_id *id) | |||
2150 | aiptek->urb->transfer_dma = aiptek->data_dma; | 2124 | aiptek->urb->transfer_dma = aiptek->data_dma; |
2151 | aiptek->urb->transfer_flags |= URB_NO_TRANSFER_DMA_MAP; | 2125 | aiptek->urb->transfer_flags |= URB_NO_TRANSFER_DMA_MAP; |
2152 | 2126 | ||
2153 | /* Register the tablet as an Input Device | ||
2154 | */ | ||
2155 | input_register_device(&aiptek->inputdev); | ||
2156 | |||
2157 | /* We now will look for the evdev device which is mapped to | ||
2158 | * the tablet. The partial name is kept in the link list of | ||
2159 | * input_handles associated with this input device. | ||
2160 | * What identifies an evdev input_handler is that it begins | ||
2161 | * with 'event', continues with a digit, and that in turn | ||
2162 | * is mapped to /{devfs}/input/eventN. | ||
2163 | */ | ||
2164 | inputdev = &aiptek->inputdev; | ||
2165 | list_for_each_safe(node, next, &inputdev->h_list) { | ||
2166 | inputhandle = to_handle(node); | ||
2167 | if (strncmp(inputhandle->name, "event", 5) == 0) { | ||
2168 | strcpy(aiptek->features.inputPath, inputhandle->name); | ||
2169 | break; | ||
2170 | } | ||
2171 | } | ||
2172 | |||
2173 | info("input: Aiptek on %s (%s)\n", path, aiptek->features.inputPath); | ||
2174 | |||
2175 | /* Program the tablet. This sets the tablet up in the mode | 2127 | /* Program the tablet. This sets the tablet up in the mode |
2176 | * specified in newSetting, and also queries the tablet's | 2128 | * specified in newSetting, and also queries the tablet's |
2177 | * physical capacities. | 2129 | * physical capacities. |
@@ -2186,13 +2138,32 @@ aiptek_probe(struct usb_interface *intf, const struct usb_device_id *id) | |||
2186 | for (i = 0; i < sizeof(speeds) / sizeof(speeds[0]); ++i) { | 2138 | for (i = 0; i < sizeof(speeds) / sizeof(speeds[0]); ++i) { |
2187 | aiptek->curSetting.programmableDelay = speeds[i]; | 2139 | aiptek->curSetting.programmableDelay = speeds[i]; |
2188 | (void)aiptek_program_tablet(aiptek); | 2140 | (void)aiptek_program_tablet(aiptek); |
2189 | if (aiptek->inputdev.absmax[ABS_X] > 0) { | 2141 | if (aiptek->inputdev->absmax[ABS_X] > 0) { |
2190 | info("input: Aiptek using %d ms programming speed\n", | 2142 | info("input: Aiptek using %d ms programming speed\n", |
2191 | aiptek->curSetting.programmableDelay); | 2143 | aiptek->curSetting.programmableDelay); |
2192 | break; | 2144 | break; |
2193 | } | 2145 | } |
2194 | } | 2146 | } |
2195 | 2147 | ||
2148 | /* Register the tablet as an Input Device | ||
2149 | */ | ||
2150 | input_register_device(aiptek->inputdev); | ||
2151 | |||
2152 | /* We now will look for the evdev device which is mapped to | ||
2153 | * the tablet. The partial name is kept in the link list of | ||
2154 | * input_handles associated with this input device. | ||
2155 | * What identifies an evdev input_handler is that it begins | ||
2156 | * with 'event', continues with a digit, and that in turn | ||
2157 | * is mapped to input/eventN. | ||
2158 | */ | ||
2159 | list_for_each_safe(node, next, &inputdev->h_list) { | ||
2160 | inputhandle = to_handle(node); | ||
2161 | if (strncmp(inputhandle->name, "event", 5) == 0) { | ||
2162 | strcpy(aiptek->features.inputPath, inputhandle->name); | ||
2163 | break; | ||
2164 | } | ||
2165 | } | ||
2166 | |||
2196 | /* Associate this driver's struct with the usb interface. | 2167 | /* Associate this driver's struct with the usb interface. |
2197 | */ | 2168 | */ |
2198 | usb_set_intfdata(intf, aiptek); | 2169 | usb_set_intfdata(intf, aiptek); |
@@ -2207,6 +2178,12 @@ aiptek_probe(struct usb_interface *intf, const struct usb_device_id *id) | |||
2207 | info("aiptek: error loading 'evdev' module"); | 2178 | info("aiptek: error loading 'evdev' module"); |
2208 | 2179 | ||
2209 | return 0; | 2180 | return 0; |
2181 | |||
2182 | fail2: usb_buffer_free(usbdev, AIPTEK_PACKET_LENGTH, aiptek->data, | ||
2183 | aiptek->data_dma); | ||
2184 | fail1: input_free_device(inputdev); | ||
2185 | kfree(aiptek); | ||
2186 | return -ENOMEM; | ||
2210 | } | 2187 | } |
2211 | 2188 | ||
2212 | /* Forward declaration */ | 2189 | /* Forward declaration */ |
@@ -2234,7 +2211,7 @@ static void aiptek_disconnect(struct usb_interface *intf) | |||
2234 | /* Free & unhook everything from the system. | 2211 | /* Free & unhook everything from the system. |
2235 | */ | 2212 | */ |
2236 | usb_kill_urb(aiptek->urb); | 2213 | usb_kill_urb(aiptek->urb); |
2237 | input_unregister_device(&aiptek->inputdev); | 2214 | input_unregister_device(aiptek->inputdev); |
2238 | aiptek_delete_files(&intf->dev); | 2215 | aiptek_delete_files(&intf->dev); |
2239 | usb_free_urb(aiptek->urb); | 2216 | usb_free_urb(aiptek->urb); |
2240 | usb_buffer_free(interface_to_usbdev(intf), | 2217 | usb_buffer_free(interface_to_usbdev(intf), |
diff --git a/drivers/usb/input/appletouch.c b/drivers/usb/input/appletouch.c index e03c1c567a14..15840db092a5 100644 --- a/drivers/usb/input/appletouch.c +++ b/drivers/usb/input/appletouch.c | |||
@@ -39,7 +39,7 @@ | |||
39 | #define APPLE_VENDOR_ID 0x05AC | 39 | #define APPLE_VENDOR_ID 0x05AC |
40 | 40 | ||
41 | #define ATP_DEVICE(prod) \ | 41 | #define ATP_DEVICE(prod) \ |
42 | .match_flags = USB_DEVICE_ID_MATCH_DEVICE | \ | 42 | .match_flags = USB_DEVICE_ID_MATCH_DEVICE | \ |
43 | USB_DEVICE_ID_MATCH_INT_CLASS | \ | 43 | USB_DEVICE_ID_MATCH_INT_CLASS | \ |
44 | USB_DEVICE_ID_MATCH_INT_PROTOCOL, \ | 44 | USB_DEVICE_ID_MATCH_INT_PROTOCOL, \ |
45 | .idVendor = APPLE_VENDOR_ID, \ | 45 | .idVendor = APPLE_VENDOR_ID, \ |
@@ -78,9 +78,9 @@ MODULE_DEVICE_TABLE (usb, atp_table); | |||
78 | * We try to keep the touchpad aspect ratio while still doing only simple | 78 | * We try to keep the touchpad aspect ratio while still doing only simple |
79 | * arithmetics. | 79 | * arithmetics. |
80 | * The factors below give coordinates like: | 80 | * The factors below give coordinates like: |
81 | * 0 <= x < 960 on 12" and 15" Powerbooks | 81 | * 0 <= x < 960 on 12" and 15" Powerbooks |
82 | * 0 <= x < 1600 on 17" Powerbooks | 82 | * 0 <= x < 1600 on 17" Powerbooks |
83 | * 0 <= y < 646 | 83 | * 0 <= y < 646 |
84 | */ | 84 | */ |
85 | #define ATP_XFACT 64 | 85 | #define ATP_XFACT 64 |
86 | #define ATP_YFACT 43 | 86 | #define ATP_YFACT 43 |
@@ -93,11 +93,12 @@ MODULE_DEVICE_TABLE (usb, atp_table); | |||
93 | 93 | ||
94 | /* Structure to hold all of our device specific stuff */ | 94 | /* Structure to hold all of our device specific stuff */ |
95 | struct atp { | 95 | struct atp { |
96 | char phys[64]; | ||
96 | struct usb_device * udev; /* usb device */ | 97 | struct usb_device * udev; /* usb device */ |
97 | struct urb * urb; /* usb request block */ | 98 | struct urb * urb; /* usb request block */ |
98 | signed char * data; /* transferred data */ | 99 | signed char * data; /* transferred data */ |
99 | int open; /* non-zero if opened */ | 100 | int open; /* non-zero if opened */ |
100 | struct input_dev input; /* input dev */ | 101 | struct input_dev *input; /* input dev */ |
101 | int valid; /* are the sensors valid ? */ | 102 | int valid; /* are the sensors valid ? */ |
102 | int x_old; /* last reported x/y, */ | 103 | int x_old; /* last reported x/y, */ |
103 | int y_old; /* used for smoothing */ | 104 | int y_old; /* used for smoothing */ |
@@ -114,11 +115,11 @@ struct atp { | |||
114 | int i; \ | 115 | int i; \ |
115 | printk("appletouch: %s %lld", msg, (long long)jiffies); \ | 116 | printk("appletouch: %s %lld", msg, (long long)jiffies); \ |
116 | for (i = 0; i < ATP_XSENSORS + ATP_YSENSORS; i++) \ | 117 | for (i = 0; i < ATP_XSENSORS + ATP_YSENSORS; i++) \ |
117 | printk(" %02x", tab[i]); \ | 118 | printk(" %02x", tab[i]); \ |
118 | printk("\n"); \ | 119 | printk("\n"); \ |
119 | } | 120 | } |
120 | 121 | ||
121 | #define dprintk(format, a...) \ | 122 | #define dprintk(format, a...) \ |
122 | do { \ | 123 | do { \ |
123 | if (debug) printk(format, ##a); \ | 124 | if (debug) printk(format, ##a); \ |
124 | } while (0) | 125 | } while (0) |
@@ -219,8 +220,8 @@ static void atp_complete(struct urb* urb, struct pt_regs* regs) | |||
219 | for (i = 16; i < ATP_XSENSORS; i++) | 220 | for (i = 16; i < ATP_XSENSORS; i++) |
220 | if (dev->xy_cur[i]) { | 221 | if (dev->xy_cur[i]) { |
221 | printk("appletouch: 17\" model detected.\n"); | 222 | printk("appletouch: 17\" model detected.\n"); |
222 | input_set_abs_params(&dev->input, ABS_X, 0, | 223 | input_set_abs_params(dev->input, ABS_X, 0, |
223 | (ATP_XSENSORS - 1) * | 224 | (ATP_XSENSORS - 1) * |
224 | ATP_XFACT - 1, | 225 | ATP_XFACT - 1, |
225 | ATP_FUZZ, 0); | 226 | ATP_FUZZ, 0); |
226 | break; | 227 | break; |
@@ -260,12 +261,12 @@ static void atp_complete(struct urb* urb, struct pt_regs* regs) | |||
260 | "Xz: %3d Yz: %3d\n", | 261 | "Xz: %3d Yz: %3d\n", |
261 | x, y, x_z, y_z); | 262 | x, y, x_z, y_z); |
262 | 263 | ||
263 | input_report_key(&dev->input, BTN_TOUCH, 1); | 264 | input_report_key(dev->input, BTN_TOUCH, 1); |
264 | input_report_abs(&dev->input, ABS_X, x); | 265 | input_report_abs(dev->input, ABS_X, x); |
265 | input_report_abs(&dev->input, ABS_Y, y); | 266 | input_report_abs(dev->input, ABS_Y, y); |
266 | input_report_abs(&dev->input, ABS_PRESSURE, | 267 | input_report_abs(dev->input, ABS_PRESSURE, |
267 | min(ATP_PRESSURE, x_z + y_z)); | 268 | min(ATP_PRESSURE, x_z + y_z)); |
268 | atp_report_fingers(&dev->input, max(x_f, y_f)); | 269 | atp_report_fingers(dev->input, max(x_f, y_f)); |
269 | } | 270 | } |
270 | dev->x_old = x; | 271 | dev->x_old = x; |
271 | dev->y_old = y; | 272 | dev->y_old = y; |
@@ -273,17 +274,17 @@ static void atp_complete(struct urb* urb, struct pt_regs* regs) | |||
273 | else if (!x && !y) { | 274 | else if (!x && !y) { |
274 | 275 | ||
275 | dev->x_old = dev->y_old = -1; | 276 | dev->x_old = dev->y_old = -1; |
276 | input_report_key(&dev->input, BTN_TOUCH, 0); | 277 | input_report_key(dev->input, BTN_TOUCH, 0); |
277 | input_report_abs(&dev->input, ABS_PRESSURE, 0); | 278 | input_report_abs(dev->input, ABS_PRESSURE, 0); |
278 | atp_report_fingers(&dev->input, 0); | 279 | atp_report_fingers(dev->input, 0); |
279 | 280 | ||
280 | /* reset the accumulator on release */ | 281 | /* reset the accumulator on release */ |
281 | memset(dev->xy_acc, 0, sizeof(dev->xy_acc)); | 282 | memset(dev->xy_acc, 0, sizeof(dev->xy_acc)); |
282 | } | 283 | } |
283 | 284 | ||
284 | input_report_key(&dev->input, BTN_LEFT, !!dev->data[80]); | 285 | input_report_key(dev->input, BTN_LEFT, !!dev->data[80]); |
285 | 286 | ||
286 | input_sync(&dev->input); | 287 | input_sync(dev->input); |
287 | 288 | ||
288 | exit: | 289 | exit: |
289 | retval = usb_submit_urb(dev->urb, GFP_ATOMIC); | 290 | retval = usb_submit_urb(dev->urb, GFP_ATOMIC); |
@@ -314,21 +315,14 @@ static void atp_close(struct input_dev *input) | |||
314 | 315 | ||
315 | static int atp_probe(struct usb_interface *iface, const struct usb_device_id *id) | 316 | static int atp_probe(struct usb_interface *iface, const struct usb_device_id *id) |
316 | { | 317 | { |
317 | struct atp *dev = NULL; | 318 | struct atp *dev; |
319 | struct input_dev *input_dev; | ||
320 | struct usb_device *udev = interface_to_usbdev(iface); | ||
318 | struct usb_host_interface *iface_desc; | 321 | struct usb_host_interface *iface_desc; |
319 | struct usb_endpoint_descriptor *endpoint; | 322 | struct usb_endpoint_descriptor *endpoint; |
320 | int int_in_endpointAddr = 0; | 323 | int int_in_endpointAddr = 0; |
321 | int i, retval = -ENOMEM; | 324 | int i, retval = -ENOMEM; |
322 | 325 | ||
323 | /* allocate memory for our device state and initialize it */ | ||
324 | dev = kmalloc(sizeof(struct atp), GFP_KERNEL); | ||
325 | if (dev == NULL) { | ||
326 | err("Out of memory"); | ||
327 | goto err_kmalloc; | ||
328 | } | ||
329 | memset(dev, 0, sizeof(struct atp)); | ||
330 | |||
331 | dev->udev = interface_to_usbdev(iface); | ||
332 | 326 | ||
333 | /* set up the endpoint information */ | 327 | /* set up the endpoint information */ |
334 | /* use only the first interrupt-in endpoint */ | 328 | /* use only the first interrupt-in endpoint */ |
@@ -345,70 +339,82 @@ static int atp_probe(struct usb_interface *iface, const struct usb_device_id *id | |||
345 | } | 339 | } |
346 | } | 340 | } |
347 | if (!int_in_endpointAddr) { | 341 | if (!int_in_endpointAddr) { |
348 | retval = -EIO; | ||
349 | err("Could not find int-in endpoint"); | 342 | err("Could not find int-in endpoint"); |
350 | goto err_endpoint; | 343 | return -EIO; |
351 | } | 344 | } |
352 | 345 | ||
353 | /* save our data pointer in this interface device */ | 346 | /* allocate memory for our device state and initialize it */ |
354 | usb_set_intfdata(iface, dev); | 347 | dev = kzalloc(sizeof(struct atp), GFP_KERNEL); |
348 | input_dev = input_allocate_device(); | ||
349 | if (!dev || !input_dev) { | ||
350 | err("Out of memory"); | ||
351 | goto err_free_devs; | ||
352 | } | ||
353 | |||
354 | dev->udev = udev; | ||
355 | dev->input = input_dev; | ||
355 | 356 | ||
356 | dev->urb = usb_alloc_urb(0, GFP_KERNEL); | 357 | dev->urb = usb_alloc_urb(0, GFP_KERNEL); |
357 | if (!dev->urb) { | 358 | if (!dev->urb) { |
358 | retval = -ENOMEM; | 359 | retval = -ENOMEM; |
359 | goto err_usballoc; | 360 | goto err_free_devs; |
360 | } | 361 | } |
362 | |||
361 | dev->data = usb_buffer_alloc(dev->udev, ATP_DATASIZE, GFP_KERNEL, | 363 | dev->data = usb_buffer_alloc(dev->udev, ATP_DATASIZE, GFP_KERNEL, |
362 | &dev->urb->transfer_dma); | 364 | &dev->urb->transfer_dma); |
363 | if (!dev->data) { | 365 | if (!dev->data) { |
364 | retval = -ENOMEM; | 366 | retval = -ENOMEM; |
365 | goto err_usbbufalloc; | 367 | goto err_free_urb; |
366 | } | 368 | } |
367 | usb_fill_int_urb(dev->urb, dev->udev, | 369 | |
368 | usb_rcvintpipe(dev->udev, int_in_endpointAddr), | 370 | usb_fill_int_urb(dev->urb, udev, |
371 | usb_rcvintpipe(udev, int_in_endpointAddr), | ||
369 | dev->data, ATP_DATASIZE, atp_complete, dev, 1); | 372 | dev->data, ATP_DATASIZE, atp_complete, dev, 1); |
370 | 373 | ||
371 | init_input_dev(&dev->input); | 374 | usb_make_path(udev, dev->phys, sizeof(dev->phys)); |
372 | dev->input.name = "appletouch"; | 375 | strlcat(dev->phys, "/input0", sizeof(dev->phys)); |
373 | dev->input.dev = &iface->dev; | 376 | |
374 | dev->input.private = dev; | 377 | input_dev->name = "appletouch"; |
375 | dev->input.open = atp_open; | 378 | input_dev->phys = dev->phys; |
376 | dev->input.close = atp_close; | 379 | usb_to_input_id(dev->udev, &input_dev->id); |
380 | input_dev->cdev.dev = &iface->dev; | ||
377 | 381 | ||
378 | usb_to_input_id(dev->udev, &dev->input.id); | 382 | input_dev->private = dev; |
383 | input_dev->open = atp_open; | ||
384 | input_dev->close = atp_close; | ||
379 | 385 | ||
380 | set_bit(EV_ABS, dev->input.evbit); | 386 | set_bit(EV_ABS, input_dev->evbit); |
381 | 387 | ||
382 | /* | 388 | /* |
383 | * 12" and 15" Powerbooks only have 16 x sensors, | 389 | * 12" and 15" Powerbooks only have 16 x sensors, |
384 | * 17" models are detected later. | 390 | * 17" models are detected later. |
385 | */ | 391 | */ |
386 | input_set_abs_params(&dev->input, ABS_X, 0, | 392 | input_set_abs_params(input_dev, ABS_X, 0, |
387 | (16 - 1) * ATP_XFACT - 1, ATP_FUZZ, 0); | 393 | (16 - 1) * ATP_XFACT - 1, ATP_FUZZ, 0); |
388 | input_set_abs_params(&dev->input, ABS_Y, 0, | 394 | input_set_abs_params(input_dev, ABS_Y, 0, |
389 | (ATP_YSENSORS - 1) * ATP_YFACT - 1, ATP_FUZZ, 0); | 395 | (ATP_YSENSORS - 1) * ATP_YFACT - 1, ATP_FUZZ, 0); |
390 | input_set_abs_params(&dev->input, ABS_PRESSURE, 0, ATP_PRESSURE, 0, 0); | 396 | input_set_abs_params(input_dev, ABS_PRESSURE, 0, ATP_PRESSURE, 0, 0); |
391 | 397 | ||
392 | set_bit(EV_KEY, dev->input.evbit); | 398 | set_bit(EV_KEY, input_dev->evbit); |
393 | set_bit(BTN_TOUCH, dev->input.keybit); | 399 | set_bit(BTN_TOUCH, input_dev->keybit); |
394 | set_bit(BTN_TOOL_FINGER, dev->input.keybit); | 400 | set_bit(BTN_TOOL_FINGER, input_dev->keybit); |
395 | set_bit(BTN_TOOL_DOUBLETAP, dev->input.keybit); | 401 | set_bit(BTN_TOOL_DOUBLETAP, input_dev->keybit); |
396 | set_bit(BTN_TOOL_TRIPLETAP, dev->input.keybit); | 402 | set_bit(BTN_TOOL_TRIPLETAP, input_dev->keybit); |
397 | set_bit(BTN_LEFT, dev->input.keybit); | 403 | set_bit(BTN_LEFT, input_dev->keybit); |
398 | 404 | ||
399 | input_register_device(&dev->input); | 405 | input_register_device(dev->input); |
400 | 406 | ||
401 | printk(KERN_INFO "input: appletouch connected\n"); | 407 | /* save our data pointer in this interface device */ |
408 | usb_set_intfdata(iface, dev); | ||
402 | 409 | ||
403 | return 0; | 410 | return 0; |
404 | 411 | ||
405 | err_usbbufalloc: | 412 | err_free_urb: |
406 | usb_free_urb(dev->urb); | 413 | usb_free_urb(dev->urb); |
407 | err_usballoc: | 414 | err_free_devs: |
408 | usb_set_intfdata(iface, NULL); | 415 | usb_set_intfdata(iface, NULL); |
409 | err_endpoint: | ||
410 | kfree(dev); | 416 | kfree(dev); |
411 | err_kmalloc: | 417 | input_free_device(input_dev); |
412 | return retval; | 418 | return retval; |
413 | } | 419 | } |
414 | 420 | ||
@@ -419,7 +425,7 @@ static void atp_disconnect(struct usb_interface *iface) | |||
419 | usb_set_intfdata(iface, NULL); | 425 | usb_set_intfdata(iface, NULL); |
420 | if (dev) { | 426 | if (dev) { |
421 | usb_kill_urb(dev->urb); | 427 | usb_kill_urb(dev->urb); |
422 | input_unregister_device(&dev->input); | 428 | input_unregister_device(dev->input); |
423 | usb_free_urb(dev->urb); | 429 | usb_free_urb(dev->urb); |
424 | usb_buffer_free(dev->udev, ATP_DATASIZE, | 430 | usb_buffer_free(dev->udev, ATP_DATASIZE, |
425 | dev->data, dev->urb->transfer_dma); | 431 | dev->data, dev->urb->transfer_dma); |
diff --git a/drivers/usb/input/ati_remote.c b/drivers/usb/input/ati_remote.c index fd99681ee483..9a2a47db9494 100644 --- a/drivers/usb/input/ati_remote.c +++ b/drivers/usb/input/ati_remote.c | |||
@@ -112,7 +112,6 @@ | |||
112 | 112 | ||
113 | #define NAME_BUFSIZE 80 /* size of product name, path buffers */ | 113 | #define NAME_BUFSIZE 80 /* size of product name, path buffers */ |
114 | #define DATA_BUFSIZE 63 /* size of URB data buffers */ | 114 | #define DATA_BUFSIZE 63 /* size of URB data buffers */ |
115 | #define ATI_INPUTNUM 1 /* Which input device to register as */ | ||
116 | 115 | ||
117 | static unsigned long channel_mask; | 116 | static unsigned long channel_mask; |
118 | module_param(channel_mask, ulong, 0444); | 117 | module_param(channel_mask, ulong, 0444); |
@@ -162,7 +161,7 @@ static char accel[] = { 1, 2, 4, 6, 9, 13, 20 }; | |||
162 | static DECLARE_MUTEX(disconnect_sem); | 161 | static DECLARE_MUTEX(disconnect_sem); |
163 | 162 | ||
164 | struct ati_remote { | 163 | struct ati_remote { |
165 | struct input_dev idev; | 164 | struct input_dev *idev; |
166 | struct usb_device *udev; | 165 | struct usb_device *udev; |
167 | struct usb_interface *interface; | 166 | struct usb_interface *interface; |
168 | 167 | ||
@@ -198,15 +197,13 @@ struct ati_remote { | |||
198 | #define KIND_ACCEL 7 /* Directional keypad - left, right, up, down.*/ | 197 | #define KIND_ACCEL 7 /* Directional keypad - left, right, up, down.*/ |
199 | 198 | ||
200 | /* Translation table from hardware messages to input events. */ | 199 | /* Translation table from hardware messages to input events. */ |
201 | static struct | 200 | static struct { |
202 | { | ||
203 | short kind; | 201 | short kind; |
204 | unsigned char data1, data2; | 202 | unsigned char data1, data2; |
205 | int type; | 203 | int type; |
206 | unsigned int code; | 204 | unsigned int code; |
207 | int value; | 205 | int value; |
208 | } ati_remote_tbl[] = | 206 | } ati_remote_tbl[] = { |
209 | { | ||
210 | /* Directional control pad axes */ | 207 | /* Directional control pad axes */ |
211 | {KIND_ACCEL, 0x35, 0x70, EV_REL, REL_X, -1}, /* left */ | 208 | {KIND_ACCEL, 0x35, 0x70, EV_REL, REL_X, -1}, /* left */ |
212 | {KIND_ACCEL, 0x36, 0x71, EV_REL, REL_X, 1}, /* right */ | 209 | {KIND_ACCEL, 0x36, 0x71, EV_REL, REL_X, 1}, /* right */ |
@@ -286,7 +283,6 @@ static struct | |||
286 | 283 | ||
287 | /* Local function prototypes */ | 284 | /* Local function prototypes */ |
288 | static void ati_remote_dump (unsigned char *data, unsigned int actual_length); | 285 | static void ati_remote_dump (unsigned char *data, unsigned int actual_length); |
289 | static void ati_remote_delete (struct ati_remote *dev); | ||
290 | static int ati_remote_open (struct input_dev *inputdev); | 286 | static int ati_remote_open (struct input_dev *inputdev); |
291 | static void ati_remote_close (struct input_dev *inputdev); | 287 | static void ati_remote_close (struct input_dev *inputdev); |
292 | static int ati_remote_sendpacket (struct ati_remote *ati_remote, u16 cmd, unsigned char *data); | 288 | static int ati_remote_sendpacket (struct ati_remote *ati_remote, u16 cmd, unsigned char *data); |
@@ -428,7 +424,7 @@ static void ati_remote_input_report(struct urb *urb, struct pt_regs *regs) | |||
428 | { | 424 | { |
429 | struct ati_remote *ati_remote = urb->context; | 425 | struct ati_remote *ati_remote = urb->context; |
430 | unsigned char *data= ati_remote->inbuf; | 426 | unsigned char *data= ati_remote->inbuf; |
431 | struct input_dev *dev = &ati_remote->idev; | 427 | struct input_dev *dev = ati_remote->idev; |
432 | int index, acc; | 428 | int index, acc; |
433 | int remote_num; | 429 | int remote_num; |
434 | 430 | ||
@@ -587,38 +583,55 @@ static void ati_remote_irq_in(struct urb *urb, struct pt_regs *regs) | |||
587 | } | 583 | } |
588 | 584 | ||
589 | /* | 585 | /* |
590 | * ati_remote_delete | 586 | * ati_remote_alloc_buffers |
591 | */ | 587 | */ |
592 | static void ati_remote_delete(struct ati_remote *ati_remote) | 588 | static int ati_remote_alloc_buffers(struct usb_device *udev, |
589 | struct ati_remote *ati_remote) | ||
593 | { | 590 | { |
594 | if (ati_remote->irq_urb) | 591 | ati_remote->inbuf = usb_buffer_alloc(udev, DATA_BUFSIZE, SLAB_ATOMIC, |
595 | usb_kill_urb(ati_remote->irq_urb); | 592 | &ati_remote->inbuf_dma); |
593 | if (!ati_remote->inbuf) | ||
594 | return -1; | ||
596 | 595 | ||
597 | if (ati_remote->out_urb) | 596 | ati_remote->outbuf = usb_buffer_alloc(udev, DATA_BUFSIZE, SLAB_ATOMIC, |
598 | usb_kill_urb(ati_remote->out_urb); | 597 | &ati_remote->outbuf_dma); |
598 | if (!ati_remote->outbuf) | ||
599 | return -1; | ||
599 | 600 | ||
600 | input_unregister_device(&ati_remote->idev); | 601 | ati_remote->irq_urb = usb_alloc_urb(0, GFP_KERNEL); |
602 | if (!ati_remote->irq_urb) | ||
603 | return -1; | ||
601 | 604 | ||
602 | if (ati_remote->inbuf) | 605 | ati_remote->out_urb = usb_alloc_urb(0, GFP_KERNEL); |
603 | usb_buffer_free(ati_remote->udev, DATA_BUFSIZE, | 606 | if (!ati_remote->out_urb) |
604 | ati_remote->inbuf, ati_remote->inbuf_dma); | 607 | return -1; |
605 | 608 | ||
606 | if (ati_remote->outbuf) | 609 | return 0; |
607 | usb_buffer_free(ati_remote->udev, DATA_BUFSIZE, | 610 | } |
608 | ati_remote->outbuf, ati_remote->outbuf_dma); | ||
609 | 611 | ||
612 | /* | ||
613 | * ati_remote_free_buffers | ||
614 | */ | ||
615 | static void ati_remote_free_buffers(struct ati_remote *ati_remote) | ||
616 | { | ||
610 | if (ati_remote->irq_urb) | 617 | if (ati_remote->irq_urb) |
611 | usb_free_urb(ati_remote->irq_urb); | 618 | usb_free_urb(ati_remote->irq_urb); |
612 | 619 | ||
613 | if (ati_remote->out_urb) | 620 | if (ati_remote->out_urb) |
614 | usb_free_urb(ati_remote->out_urb); | 621 | usb_free_urb(ati_remote->out_urb); |
615 | 622 | ||
616 | kfree(ati_remote); | 623 | if (ati_remote->inbuf) |
624 | usb_buffer_free(ati_remote->udev, DATA_BUFSIZE, | ||
625 | ati_remote->inbuf, ati_remote->inbuf_dma); | ||
626 | |||
627 | if (ati_remote->outbuf) | ||
628 | usb_buffer_free(ati_remote->udev, DATA_BUFSIZE, | ||
629 | ati_remote->inbuf, ati_remote->outbuf_dma); | ||
617 | } | 630 | } |
618 | 631 | ||
619 | static void ati_remote_input_init(struct ati_remote *ati_remote) | 632 | static void ati_remote_input_init(struct ati_remote *ati_remote) |
620 | { | 633 | { |
621 | struct input_dev *idev = &(ati_remote->idev); | 634 | struct input_dev *idev = ati_remote->idev; |
622 | int i; | 635 | int i; |
623 | 636 | ||
624 | idev->evbit[0] = BIT(EV_KEY) | BIT(EV_REL); | 637 | idev->evbit[0] = BIT(EV_KEY) | BIT(EV_REL); |
@@ -637,7 +650,7 @@ static void ati_remote_input_init(struct ati_remote *ati_remote) | |||
637 | idev->phys = ati_remote->phys; | 650 | idev->phys = ati_remote->phys; |
638 | 651 | ||
639 | usb_to_input_id(ati_remote->udev, &idev->id); | 652 | usb_to_input_id(ati_remote->udev, &idev->id); |
640 | idev->dev = &ati_remote->udev->dev; | 653 | idev->cdev.dev = &ati_remote->udev->dev; |
641 | } | 654 | } |
642 | 655 | ||
643 | static int ati_remote_initialize(struct ati_remote *ati_remote) | 656 | static int ati_remote_initialize(struct ati_remote *ati_remote) |
@@ -674,7 +687,7 @@ static int ati_remote_initialize(struct ati_remote *ati_remote) | |||
674 | (ati_remote_sendpacket(ati_remote, 0x8007, init2))) { | 687 | (ati_remote_sendpacket(ati_remote, 0x8007, init2))) { |
675 | dev_err(&ati_remote->interface->dev, | 688 | dev_err(&ati_remote->interface->dev, |
676 | "Initializing ati_remote hardware failed.\n"); | 689 | "Initializing ati_remote hardware failed.\n"); |
677 | return 1; | 690 | return -EIO; |
678 | } | 691 | } |
679 | 692 | ||
680 | return 0; | 693 | return 0; |
@@ -686,95 +699,83 @@ static int ati_remote_initialize(struct ati_remote *ati_remote) | |||
686 | static int ati_remote_probe(struct usb_interface *interface, const struct usb_device_id *id) | 699 | static int ati_remote_probe(struct usb_interface *interface, const struct usb_device_id *id) |
687 | { | 700 | { |
688 | struct usb_device *udev = interface_to_usbdev(interface); | 701 | struct usb_device *udev = interface_to_usbdev(interface); |
689 | struct ati_remote *ati_remote = NULL; | 702 | struct usb_host_interface *iface_host = interface->cur_altsetting; |
690 | struct usb_host_interface *iface_host; | 703 | struct usb_endpoint_descriptor *endpoint_in, *endpoint_out; |
691 | int retval = -ENOMEM; | 704 | struct ati_remote *ati_remote; |
692 | char path[64]; | 705 | struct input_dev *input_dev; |
693 | 706 | int err = -ENOMEM; | |
694 | /* Allocate and clear an ati_remote struct */ | ||
695 | if (!(ati_remote = kmalloc(sizeof (struct ati_remote), GFP_KERNEL))) | ||
696 | return -ENOMEM; | ||
697 | memset(ati_remote, 0x00, sizeof (struct ati_remote)); | ||
698 | 707 | ||
699 | iface_host = interface->cur_altsetting; | ||
700 | if (iface_host->desc.bNumEndpoints != 2) { | 708 | if (iface_host->desc.bNumEndpoints != 2) { |
701 | err("%s: Unexpected desc.bNumEndpoints\n", __FUNCTION__); | 709 | err("%s: Unexpected desc.bNumEndpoints\n", __FUNCTION__); |
702 | retval = -ENODEV; | 710 | return -ENODEV; |
703 | goto error; | ||
704 | } | 711 | } |
705 | 712 | ||
706 | ati_remote->endpoint_in = &(iface_host->endpoint[0].desc); | 713 | endpoint_in = &iface_host->endpoint[0].desc; |
707 | ati_remote->endpoint_out = &(iface_host->endpoint[1].desc); | 714 | endpoint_out = &iface_host->endpoint[1].desc; |
708 | ati_remote->udev = udev; | ||
709 | ati_remote->interface = interface; | ||
710 | 715 | ||
711 | if (!(ati_remote->endpoint_in->bEndpointAddress & 0x80)) { | 716 | if (!(endpoint_in->bEndpointAddress & USB_DIR_IN)) { |
712 | err("%s: Unexpected endpoint_in->bEndpointAddress\n", __FUNCTION__); | 717 | err("%s: Unexpected endpoint_in->bEndpointAddress\n", __FUNCTION__); |
713 | retval = -ENODEV; | 718 | return -ENODEV; |
714 | goto error; | ||
715 | } | 719 | } |
716 | if ((ati_remote->endpoint_in->bmAttributes & 3) != 3) { | 720 | if ((endpoint_in->bmAttributes & USB_ENDPOINT_XFERTYPE_MASK) != USB_ENDPOINT_XFER_INT) { |
717 | err("%s: Unexpected endpoint_in->bmAttributes\n", __FUNCTION__); | 721 | err("%s: Unexpected endpoint_in->bmAttributes\n", __FUNCTION__); |
718 | retval = -ENODEV; | 722 | return -ENODEV; |
719 | goto error; | ||
720 | } | 723 | } |
721 | if (le16_to_cpu(ati_remote->endpoint_in->wMaxPacketSize) == 0) { | 724 | if (le16_to_cpu(endpoint_in->wMaxPacketSize) == 0) { |
722 | err("%s: endpoint_in message size==0? \n", __FUNCTION__); | 725 | err("%s: endpoint_in message size==0? \n", __FUNCTION__); |
723 | retval = -ENODEV; | 726 | return -ENODEV; |
724 | goto error; | ||
725 | } | 727 | } |
726 | 728 | ||
727 | /* Allocate URB buffers, URBs */ | 729 | ati_remote = kzalloc(sizeof (struct ati_remote), GFP_KERNEL); |
728 | ati_remote->inbuf = usb_buffer_alloc(udev, DATA_BUFSIZE, SLAB_ATOMIC, | 730 | input_dev = input_allocate_device(); |
729 | &ati_remote->inbuf_dma); | 731 | if (!ati_remote || !input_dev) |
730 | if (!ati_remote->inbuf) | 732 | goto fail1; |
731 | goto error; | ||
732 | 733 | ||
733 | ati_remote->outbuf = usb_buffer_alloc(udev, DATA_BUFSIZE, SLAB_ATOMIC, | 734 | /* Allocate URB buffers, URBs */ |
734 | &ati_remote->outbuf_dma); | 735 | if (ati_remote_alloc_buffers(udev, ati_remote)) |
735 | if (!ati_remote->outbuf) | 736 | goto fail2; |
736 | goto error; | ||
737 | 737 | ||
738 | ati_remote->irq_urb = usb_alloc_urb(0, GFP_KERNEL); | 738 | ati_remote->endpoint_in = endpoint_in; |
739 | if (!ati_remote->irq_urb) | 739 | ati_remote->endpoint_out = endpoint_out; |
740 | goto error; | 740 | ati_remote->udev = udev; |
741 | ati_remote->idev = input_dev; | ||
742 | ati_remote->interface = interface; | ||
741 | 743 | ||
742 | ati_remote->out_urb = usb_alloc_urb(0, GFP_KERNEL); | 744 | usb_make_path(udev, ati_remote->phys, sizeof(ati_remote->phys)); |
743 | if (!ati_remote->out_urb) | 745 | strlcpy(ati_remote->phys, "/input0", sizeof(ati_remote->phys)); |
744 | goto error; | ||
745 | 746 | ||
746 | usb_make_path(udev, path, NAME_BUFSIZE); | ||
747 | sprintf(ati_remote->phys, "%s/input%d", path, ATI_INPUTNUM); | ||
748 | if (udev->manufacturer) | 747 | if (udev->manufacturer) |
749 | strcat(ati_remote->name, udev->manufacturer); | 748 | strlcpy(ati_remote->name, udev->manufacturer, sizeof(ati_remote->name)); |
750 | 749 | ||
751 | if (udev->product) | 750 | if (udev->product) |
752 | sprintf(ati_remote->name, "%s %s", ati_remote->name, udev->product); | 751 | snprintf(ati_remote->name, sizeof(ati_remote->name), |
752 | "%s %s", ati_remote->name, udev->product); | ||
753 | 753 | ||
754 | if (!strlen(ati_remote->name)) | 754 | if (!strlen(ati_remote->name)) |
755 | sprintf(ati_remote->name, DRIVER_DESC "(%04x,%04x)", | 755 | snprintf(ati_remote->name, sizeof(ati_remote->name), |
756 | DRIVER_DESC "(%04x,%04x)", | ||
756 | le16_to_cpu(ati_remote->udev->descriptor.idVendor), | 757 | le16_to_cpu(ati_remote->udev->descriptor.idVendor), |
757 | le16_to_cpu(ati_remote->udev->descriptor.idProduct)); | 758 | le16_to_cpu(ati_remote->udev->descriptor.idProduct)); |
758 | 759 | ||
760 | ati_remote_input_init(ati_remote); | ||
761 | |||
759 | /* Device Hardware Initialization - fills in ati_remote->idev from udev. */ | 762 | /* Device Hardware Initialization - fills in ati_remote->idev from udev. */ |
760 | retval = ati_remote_initialize(ati_remote); | 763 | err = ati_remote_initialize(ati_remote); |
761 | if (retval) | 764 | if (err) |
762 | goto error; | 765 | goto fail3; |
763 | 766 | ||
764 | /* Set up and register input device */ | 767 | /* Set up and register input device */ |
765 | ati_remote_input_init(ati_remote); | 768 | input_register_device(ati_remote->idev); |
766 | input_register_device(&ati_remote->idev); | ||
767 | |||
768 | dev_info(&ati_remote->interface->dev, "Input registered: %s on %s\n", | ||
769 | ati_remote->name, path); | ||
770 | 769 | ||
771 | usb_set_intfdata(interface, ati_remote); | 770 | usb_set_intfdata(interface, ati_remote); |
771 | return 0; | ||
772 | 772 | ||
773 | error: | 773 | fail3: usb_kill_urb(ati_remote->irq_urb); |
774 | if (retval) | 774 | usb_kill_urb(ati_remote->out_urb); |
775 | ati_remote_delete(ati_remote); | 775 | fail2: ati_remote_free_buffers(ati_remote); |
776 | 776 | fail1: input_free_device(input_dev); | |
777 | return retval; | 777 | kfree(ati_remote); |
778 | return err; | ||
778 | } | 779 | } |
779 | 780 | ||
780 | /* | 781 | /* |
@@ -791,7 +792,11 @@ static void ati_remote_disconnect(struct usb_interface *interface) | |||
791 | return; | 792 | return; |
792 | } | 793 | } |
793 | 794 | ||
794 | ati_remote_delete(ati_remote); | 795 | usb_kill_urb(ati_remote->irq_urb); |
796 | usb_kill_urb(ati_remote->out_urb); | ||
797 | input_unregister_device(ati_remote->idev); | ||
798 | ati_remote_free_buffers(ati_remote); | ||
799 | kfree(ati_remote); | ||
795 | } | 800 | } |
796 | 801 | ||
797 | /* | 802 | /* |
diff --git a/drivers/usb/input/hid-core.c b/drivers/usb/input/hid-core.c index a99865c689c5..45f3130fadea 100644 --- a/drivers/usb/input/hid-core.c +++ b/drivers/usb/input/hid-core.c | |||
@@ -1318,6 +1318,7 @@ void hid_init_reports(struct hid_device *hid) | |||
1318 | #define USB_DEVICE_ID_WACOM_PTU 0x0003 | 1318 | #define USB_DEVICE_ID_WACOM_PTU 0x0003 |
1319 | #define USB_DEVICE_ID_WACOM_INTUOS3 0x00B0 | 1319 | #define USB_DEVICE_ID_WACOM_INTUOS3 0x00B0 |
1320 | #define USB_DEVICE_ID_WACOM_CINTIQ 0x003F | 1320 | #define USB_DEVICE_ID_WACOM_CINTIQ 0x003F |
1321 | #define USB_DEVICE_ID_WACOM_DTF 0x00C0 | ||
1321 | 1322 | ||
1322 | #define USB_VENDOR_ID_ACECAD 0x0460 | 1323 | #define USB_VENDOR_ID_ACECAD 0x0460 |
1323 | #define USB_DEVICE_ID_ACECAD_FLAIR 0x0004 | 1324 | #define USB_DEVICE_ID_ACECAD_FLAIR 0x0004 |
@@ -1524,6 +1525,9 @@ static struct hid_blacklist { | |||
1524 | { USB_VENDOR_ID_WACOM, USB_DEVICE_ID_WACOM_PL + 3, HID_QUIRK_IGNORE }, | 1525 | { USB_VENDOR_ID_WACOM, USB_DEVICE_ID_WACOM_PL + 3, HID_QUIRK_IGNORE }, |
1525 | { USB_VENDOR_ID_WACOM, USB_DEVICE_ID_WACOM_PL + 4, HID_QUIRK_IGNORE }, | 1526 | { USB_VENDOR_ID_WACOM, USB_DEVICE_ID_WACOM_PL + 4, HID_QUIRK_IGNORE }, |
1526 | { USB_VENDOR_ID_WACOM, USB_DEVICE_ID_WACOM_PL + 5, HID_QUIRK_IGNORE }, | 1527 | { USB_VENDOR_ID_WACOM, USB_DEVICE_ID_WACOM_PL + 5, HID_QUIRK_IGNORE }, |
1528 | { USB_VENDOR_ID_WACOM, USB_DEVICE_ID_WACOM_PL + 7, HID_QUIRK_IGNORE }, | ||
1529 | { USB_VENDOR_ID_WACOM, USB_DEVICE_ID_WACOM_PL + 8, HID_QUIRK_IGNORE }, | ||
1530 | { USB_VENDOR_ID_WACOM, USB_DEVICE_ID_WACOM_PL + 9, HID_QUIRK_IGNORE }, | ||
1527 | { USB_VENDOR_ID_WACOM, USB_DEVICE_ID_WACOM_INTUOS2 + 1, HID_QUIRK_IGNORE }, | 1531 | { USB_VENDOR_ID_WACOM, USB_DEVICE_ID_WACOM_INTUOS2 + 1, HID_QUIRK_IGNORE }, |
1528 | { USB_VENDOR_ID_WACOM, USB_DEVICE_ID_WACOM_INTUOS2 + 2, HID_QUIRK_IGNORE }, | 1532 | { USB_VENDOR_ID_WACOM, USB_DEVICE_ID_WACOM_INTUOS2 + 2, HID_QUIRK_IGNORE }, |
1529 | { USB_VENDOR_ID_WACOM, USB_DEVICE_ID_WACOM_INTUOS2 + 3, HID_QUIRK_IGNORE }, | 1533 | { USB_VENDOR_ID_WACOM, USB_DEVICE_ID_WACOM_INTUOS2 + 3, HID_QUIRK_IGNORE }, |
@@ -1531,11 +1535,19 @@ static struct hid_blacklist { | |||
1531 | { USB_VENDOR_ID_WACOM, USB_DEVICE_ID_WACOM_INTUOS2 + 5, HID_QUIRK_IGNORE }, | 1535 | { USB_VENDOR_ID_WACOM, USB_DEVICE_ID_WACOM_INTUOS2 + 5, HID_QUIRK_IGNORE }, |
1532 | { USB_VENDOR_ID_WACOM, USB_DEVICE_ID_WACOM_INTUOS2 + 7, HID_QUIRK_IGNORE }, | 1536 | { USB_VENDOR_ID_WACOM, USB_DEVICE_ID_WACOM_INTUOS2 + 7, HID_QUIRK_IGNORE }, |
1533 | { USB_VENDOR_ID_WACOM, USB_DEVICE_ID_WACOM_VOLITO, HID_QUIRK_IGNORE }, | 1537 | { USB_VENDOR_ID_WACOM, USB_DEVICE_ID_WACOM_VOLITO, HID_QUIRK_IGNORE }, |
1538 | { USB_VENDOR_ID_WACOM, USB_DEVICE_ID_WACOM_VOLITO + 1, HID_QUIRK_IGNORE }, | ||
1539 | { USB_VENDOR_ID_WACOM, USB_DEVICE_ID_WACOM_VOLITO + 2, HID_QUIRK_IGNORE }, | ||
1540 | { USB_VENDOR_ID_WACOM, USB_DEVICE_ID_WACOM_VOLITO + 3, HID_QUIRK_IGNORE }, | ||
1541 | { USB_VENDOR_ID_WACOM, USB_DEVICE_ID_WACOM_VOLITO + 4, HID_QUIRK_IGNORE }, | ||
1542 | { USB_VENDOR_ID_WACOM, USB_DEVICE_ID_WACOM_GRAPHIRE + 5, HID_QUIRK_IGNORE }, | ||
1543 | { USB_VENDOR_ID_WACOM, USB_DEVICE_ID_WACOM_GRAPHIRE + 6, HID_QUIRK_IGNORE }, | ||
1534 | { USB_VENDOR_ID_WACOM, USB_DEVICE_ID_WACOM_PTU, HID_QUIRK_IGNORE }, | 1544 | { USB_VENDOR_ID_WACOM, USB_DEVICE_ID_WACOM_PTU, HID_QUIRK_IGNORE }, |
1535 | { USB_VENDOR_ID_WACOM, USB_DEVICE_ID_WACOM_INTUOS3, HID_QUIRK_IGNORE }, | 1545 | { USB_VENDOR_ID_WACOM, USB_DEVICE_ID_WACOM_INTUOS3, HID_QUIRK_IGNORE }, |
1536 | { USB_VENDOR_ID_WACOM, USB_DEVICE_ID_WACOM_INTUOS3 + 1, HID_QUIRK_IGNORE }, | 1546 | { USB_VENDOR_ID_WACOM, USB_DEVICE_ID_WACOM_INTUOS3 + 1, HID_QUIRK_IGNORE }, |
1537 | { USB_VENDOR_ID_WACOM, USB_DEVICE_ID_WACOM_INTUOS3 + 2, HID_QUIRK_IGNORE }, | 1547 | { USB_VENDOR_ID_WACOM, USB_DEVICE_ID_WACOM_INTUOS3 + 2, HID_QUIRK_IGNORE }, |
1548 | { USB_VENDOR_ID_WACOM, USB_DEVICE_ID_WACOM_INTUOS3 + 5, HID_QUIRK_IGNORE }, | ||
1538 | { USB_VENDOR_ID_WACOM, USB_DEVICE_ID_WACOM_CINTIQ, HID_QUIRK_IGNORE }, | 1549 | { USB_VENDOR_ID_WACOM, USB_DEVICE_ID_WACOM_CINTIQ, HID_QUIRK_IGNORE }, |
1550 | { USB_VENDOR_ID_WACOM, USB_DEVICE_ID_WACOM_DTF, HID_QUIRK_IGNORE }, | ||
1539 | { USB_VENDOR_ID_WISEGROUP, USB_DEVICE_ID_4_PHIDGETSERVO_20, HID_QUIRK_IGNORE }, | 1551 | { USB_VENDOR_ID_WISEGROUP, USB_DEVICE_ID_4_PHIDGETSERVO_20, HID_QUIRK_IGNORE }, |
1540 | { USB_VENDOR_ID_WISEGROUP, USB_DEVICE_ID_1_PHIDGETSERVO_20, HID_QUIRK_IGNORE }, | 1552 | { USB_VENDOR_ID_WISEGROUP, USB_DEVICE_ID_1_PHIDGETSERVO_20, HID_QUIRK_IGNORE }, |
1541 | 1553 | ||
@@ -1619,8 +1631,8 @@ static struct hid_device *usb_hid_configure(struct usb_interface *intf) | |||
1619 | struct hid_descriptor *hdesc; | 1631 | struct hid_descriptor *hdesc; |
1620 | struct hid_device *hid; | 1632 | struct hid_device *hid; |
1621 | unsigned quirks = 0, rsize = 0; | 1633 | unsigned quirks = 0, rsize = 0; |
1622 | char *buf, *rdesc; | 1634 | char *rdesc; |
1623 | int n, insize = 0; | 1635 | int n, len, insize = 0; |
1624 | 1636 | ||
1625 | for (n = 0; hid_blacklist[n].idVendor; n++) | 1637 | for (n = 0; hid_blacklist[n].idVendor; n++) |
1626 | if ((hid_blacklist[n].idVendor == le16_to_cpu(dev->descriptor.idVendor)) && | 1638 | if ((hid_blacklist[n].idVendor == le16_to_cpu(dev->descriptor.idVendor)) && |
@@ -1630,10 +1642,11 @@ static struct hid_device *usb_hid_configure(struct usb_interface *intf) | |||
1630 | if (quirks & HID_QUIRK_IGNORE) | 1642 | if (quirks & HID_QUIRK_IGNORE) |
1631 | return NULL; | 1643 | return NULL; |
1632 | 1644 | ||
1633 | if (usb_get_extra_descriptor(interface, HID_DT_HID, &hdesc) && ((!interface->desc.bNumEndpoints) || | 1645 | if (usb_get_extra_descriptor(interface, HID_DT_HID, &hdesc) && |
1634 | usb_get_extra_descriptor(&interface->endpoint[0], HID_DT_HID, &hdesc))) { | 1646 | (!interface->desc.bNumEndpoints || |
1635 | dbg("class descriptor not present\n"); | 1647 | usb_get_extra_descriptor(&interface->endpoint[0], HID_DT_HID, &hdesc))) { |
1636 | return NULL; | 1648 | dbg("class descriptor not present\n"); |
1649 | return NULL; | ||
1637 | } | 1650 | } |
1638 | 1651 | ||
1639 | for (n = 0; n < hdesc->bNumDescriptors; n++) | 1652 | for (n = 0; n < hdesc->bNumDescriptors; n++) |
@@ -1702,10 +1715,7 @@ static struct hid_device *usb_hid_configure(struct usb_interface *intf) | |||
1702 | if ((endpoint->bmAttributes & 3) != 3) /* Not an interrupt endpoint */ | 1715 | if ((endpoint->bmAttributes & 3) != 3) /* Not an interrupt endpoint */ |
1703 | continue; | 1716 | continue; |
1704 | 1717 | ||
1705 | /* handle potential highspeed HID correctly */ | ||
1706 | interval = endpoint->bInterval; | 1718 | interval = endpoint->bInterval; |
1707 | if (dev->speed == USB_SPEED_HIGH) | ||
1708 | interval = 1 << (interval - 1); | ||
1709 | 1719 | ||
1710 | /* Change the polling interval of mice. */ | 1720 | /* Change the polling interval of mice. */ |
1711 | if (hid->collection->usage == HID_GD_MOUSE && hid_mousepoll_interval > 0) | 1721 | if (hid->collection->usage == HID_GD_MOUSE && hid_mousepoll_interval > 0) |
@@ -1752,38 +1762,43 @@ static struct hid_device *usb_hid_configure(struct usb_interface *intf) | |||
1752 | 1762 | ||
1753 | hid->name[0] = 0; | 1763 | hid->name[0] = 0; |
1754 | 1764 | ||
1755 | if (!(buf = kmalloc(64, GFP_KERNEL))) | 1765 | if (dev->manufacturer) |
1756 | goto fail; | 1766 | strlcpy(hid->name, dev->manufacturer, sizeof(hid->name)); |
1767 | |||
1768 | if (dev->product) { | ||
1769 | if (dev->manufacturer) | ||
1770 | strlcat(hid->name, " ", sizeof(hid->name)); | ||
1771 | strlcat(hid->name, dev->product, sizeof(hid->name)); | ||
1772 | } | ||
1757 | 1773 | ||
1758 | if (dev->manufacturer) { | 1774 | if (!strlen(hid->name)) |
1759 | strcat(hid->name, dev->manufacturer); | 1775 | snprintf(hid->name, sizeof(hid->name), "HID %04x:%04x", |
1760 | if (dev->product) | 1776 | le16_to_cpu(dev->descriptor.idVendor), |
1761 | snprintf(hid->name, 64, "%s %s", hid->name, dev->product); | 1777 | le16_to_cpu(dev->descriptor.idProduct)); |
1762 | } else if (dev->product) { | 1778 | |
1763 | snprintf(hid->name, 128, "%s", dev->product); | 1779 | usb_make_path(dev, hid->phys, sizeof(hid->phys)); |
1764 | } else | 1780 | strlcat(hid->phys, "/input", sizeof(hid->phys)); |
1765 | snprintf(hid->name, 128, "%04x:%04x", | 1781 | len = strlen(hid->phys); |
1766 | le16_to_cpu(dev->descriptor.idVendor), | 1782 | if (len < sizeof(hid->phys) - 1) |
1767 | le16_to_cpu(dev->descriptor.idProduct)); | 1783 | snprintf(hid->phys + len, sizeof(hid->phys) - len, |
1768 | 1784 | "%d", intf->altsetting[0].desc.bInterfaceNumber); | |
1769 | usb_make_path(dev, buf, 64); | ||
1770 | snprintf(hid->phys, 64, "%s/input%d", buf, | ||
1771 | intf->altsetting[0].desc.bInterfaceNumber); | ||
1772 | 1785 | ||
1773 | if (usb_string(dev, dev->descriptor.iSerialNumber, hid->uniq, 64) <= 0) | 1786 | if (usb_string(dev, dev->descriptor.iSerialNumber, hid->uniq, 64) <= 0) |
1774 | hid->uniq[0] = 0; | 1787 | hid->uniq[0] = 0; |
1775 | 1788 | ||
1776 | kfree(buf); | ||
1777 | |||
1778 | hid->urbctrl = usb_alloc_urb(0, GFP_KERNEL); | 1789 | hid->urbctrl = usb_alloc_urb(0, GFP_KERNEL); |
1779 | if (!hid->urbctrl) | 1790 | if (!hid->urbctrl) |
1780 | goto fail; | 1791 | goto fail; |
1792 | |||
1781 | usb_fill_control_urb(hid->urbctrl, dev, 0, (void *) hid->cr, | 1793 | usb_fill_control_urb(hid->urbctrl, dev, 0, (void *) hid->cr, |
1782 | hid->ctrlbuf, 1, hid_ctrl, hid); | 1794 | hid->ctrlbuf, 1, hid_ctrl, hid); |
1783 | hid->urbctrl->setup_dma = hid->cr_dma; | 1795 | hid->urbctrl->setup_dma = hid->cr_dma; |
1784 | hid->urbctrl->transfer_dma = hid->ctrlbuf_dma; | 1796 | hid->urbctrl->transfer_dma = hid->ctrlbuf_dma; |
1785 | hid->urbctrl->transfer_flags |= (URB_NO_TRANSFER_DMA_MAP | URB_NO_SETUP_DMA_MAP); | 1797 | hid->urbctrl->transfer_flags |= (URB_NO_TRANSFER_DMA_MAP | URB_NO_SETUP_DMA_MAP); |
1786 | 1798 | ||
1799 | /* May be needed for some devices */ | ||
1800 | usb_clear_halt(hid->dev, hid->urbin->pipe); | ||
1801 | |||
1787 | return hid; | 1802 | return hid; |
1788 | 1803 | ||
1789 | fail: | 1804 | fail: |
@@ -1887,7 +1902,6 @@ static int hid_suspend(struct usb_interface *intf, pm_message_t message) | |||
1887 | struct hid_device *hid = usb_get_intfdata (intf); | 1902 | struct hid_device *hid = usb_get_intfdata (intf); |
1888 | 1903 | ||
1889 | usb_kill_urb(hid->urbin); | 1904 | usb_kill_urb(hid->urbin); |
1890 | intf->dev.power.power_state = PMSG_SUSPEND; | ||
1891 | dev_dbg(&intf->dev, "suspend\n"); | 1905 | dev_dbg(&intf->dev, "suspend\n"); |
1892 | return 0; | 1906 | return 0; |
1893 | } | 1907 | } |
@@ -1897,7 +1911,6 @@ static int hid_resume(struct usb_interface *intf) | |||
1897 | struct hid_device *hid = usb_get_intfdata (intf); | 1911 | struct hid_device *hid = usb_get_intfdata (intf); |
1898 | int status; | 1912 | int status; |
1899 | 1913 | ||
1900 | intf->dev.power.power_state = PMSG_ON; | ||
1901 | if (hid->open) | 1914 | if (hid->open) |
1902 | status = usb_submit_urb(hid->urbin, GFP_NOIO); | 1915 | status = usb_submit_urb(hid->urbin, GFP_NOIO); |
1903 | else | 1916 | else |
diff --git a/drivers/usb/input/hid-input.c b/drivers/usb/input/hid-input.c index 0b6452248a39..9ff25eb520a6 100644 --- a/drivers/usb/input/hid-input.c +++ b/drivers/usb/input/hid-input.c | |||
@@ -76,8 +76,8 @@ static struct { | |||
76 | static void hidinput_configure_usage(struct hid_input *hidinput, struct hid_field *field, | 76 | static void hidinput_configure_usage(struct hid_input *hidinput, struct hid_field *field, |
77 | struct hid_usage *usage) | 77 | struct hid_usage *usage) |
78 | { | 78 | { |
79 | struct input_dev *input = &hidinput->input; | 79 | struct input_dev *input = hidinput->input; |
80 | struct hid_device *device = hidinput->input.private; | 80 | struct hid_device *device = input->private; |
81 | int max = 0, code; | 81 | int max = 0, code; |
82 | unsigned long *bit = NULL; | 82 | unsigned long *bit = NULL; |
83 | 83 | ||
@@ -461,7 +461,8 @@ void hidinput_hid_event(struct hid_device *hid, struct hid_field *field, struct | |||
461 | 461 | ||
462 | if (!field->hidinput) | 462 | if (!field->hidinput) |
463 | return; | 463 | return; |
464 | input = &field->hidinput->input; | 464 | |
465 | input = field->hidinput->input; | ||
465 | 466 | ||
466 | input_regs(input, regs); | 467 | input_regs(input, regs); |
467 | 468 | ||
@@ -533,13 +534,10 @@ void hidinput_hid_event(struct hid_device *hid, struct hid_field *field, struct | |||
533 | 534 | ||
534 | void hidinput_report_event(struct hid_device *hid, struct hid_report *report) | 535 | void hidinput_report_event(struct hid_device *hid, struct hid_report *report) |
535 | { | 536 | { |
536 | struct list_head *lh; | ||
537 | struct hid_input *hidinput; | 537 | struct hid_input *hidinput; |
538 | 538 | ||
539 | list_for_each (lh, &hid->inputs) { | 539 | list_for_each_entry(hidinput, &hid->inputs, list) |
540 | hidinput = list_entry(lh, struct hid_input, list); | 540 | input_sync(hidinput->input); |
541 | input_sync(&hidinput->input); | ||
542 | } | ||
543 | } | 541 | } |
544 | 542 | ||
545 | static int hidinput_find_field(struct hid_device *hid, unsigned int type, unsigned int code, struct hid_field **field) | 543 | static int hidinput_find_field(struct hid_device *hid, unsigned int type, unsigned int code, struct hid_field **field) |
@@ -604,6 +602,7 @@ int hidinput_connect(struct hid_device *hid) | |||
604 | struct usb_device *dev = hid->dev; | 602 | struct usb_device *dev = hid->dev; |
605 | struct hid_report *report; | 603 | struct hid_report *report; |
606 | struct hid_input *hidinput = NULL; | 604 | struct hid_input *hidinput = NULL; |
605 | struct input_dev *input_dev; | ||
607 | int i, j, k; | 606 | int i, j, k; |
608 | 607 | ||
609 | INIT_LIST_HEAD(&hid->inputs); | 608 | INIT_LIST_HEAD(&hid->inputs); |
@@ -624,25 +623,28 @@ int hidinput_connect(struct hid_device *hid) | |||
624 | continue; | 623 | continue; |
625 | 624 | ||
626 | if (!hidinput) { | 625 | if (!hidinput) { |
627 | hidinput = kmalloc(sizeof(*hidinput), GFP_KERNEL); | 626 | hidinput = kzalloc(sizeof(*hidinput), GFP_KERNEL); |
628 | if (!hidinput) { | 627 | input_dev = input_allocate_device(); |
628 | if (!hidinput || !input_dev) { | ||
629 | kfree(hidinput); | ||
630 | input_free_device(input_dev); | ||
629 | err("Out of memory during hid input probe"); | 631 | err("Out of memory during hid input probe"); |
630 | return -1; | 632 | return -1; |
631 | } | 633 | } |
632 | memset(hidinput, 0, sizeof(*hidinput)); | ||
633 | 634 | ||
634 | list_add_tail(&hidinput->list, &hid->inputs); | 635 | input_dev->private = hid; |
636 | input_dev->event = hidinput_input_event; | ||
637 | input_dev->open = hidinput_open; | ||
638 | input_dev->close = hidinput_close; | ||
635 | 639 | ||
636 | hidinput->input.private = hid; | 640 | input_dev->name = hid->name; |
637 | hidinput->input.event = hidinput_input_event; | 641 | input_dev->phys = hid->phys; |
638 | hidinput->input.open = hidinput_open; | 642 | input_dev->uniq = hid->uniq; |
639 | hidinput->input.close = hidinput_close; | 643 | usb_to_input_id(dev, &input_dev->id); |
644 | input_dev->cdev.dev = &hid->intf->dev; | ||
640 | 645 | ||
641 | hidinput->input.name = hid->name; | 646 | hidinput->input = input_dev; |
642 | hidinput->input.phys = hid->phys; | 647 | list_add_tail(&hidinput->list, &hid->inputs); |
643 | hidinput->input.uniq = hid->uniq; | ||
644 | usb_to_input_id(dev, &hidinput->input.id); | ||
645 | hidinput->input.dev = &hid->intf->dev; | ||
646 | } | 648 | } |
647 | 649 | ||
648 | for (i = 0; i < report->maxfield; i++) | 650 | for (i = 0; i < report->maxfield; i++) |
@@ -657,7 +659,7 @@ int hidinput_connect(struct hid_device *hid) | |||
657 | * UGCI) cram a lot of unrelated inputs into the | 659 | * UGCI) cram a lot of unrelated inputs into the |
658 | * same interface. */ | 660 | * same interface. */ |
659 | hidinput->report = report; | 661 | hidinput->report = report; |
660 | input_register_device(&hidinput->input); | 662 | input_register_device(hidinput->input); |
661 | hidinput = NULL; | 663 | hidinput = NULL; |
662 | } | 664 | } |
663 | } | 665 | } |
@@ -667,7 +669,7 @@ int hidinput_connect(struct hid_device *hid) | |||
667 | * only useful in this case, and not for multi-input quirks. */ | 669 | * only useful in this case, and not for multi-input quirks. */ |
668 | if (hidinput) { | 670 | if (hidinput) { |
669 | hid_ff_init(hid); | 671 | hid_ff_init(hid); |
670 | input_register_device(&hidinput->input); | 672 | input_register_device(hidinput->input); |
671 | } | 673 | } |
672 | 674 | ||
673 | return 0; | 675 | return 0; |
@@ -675,13 +677,11 @@ int hidinput_connect(struct hid_device *hid) | |||
675 | 677 | ||
676 | void hidinput_disconnect(struct hid_device *hid) | 678 | void hidinput_disconnect(struct hid_device *hid) |
677 | { | 679 | { |
678 | struct list_head *lh, *next; | 680 | struct hid_input *hidinput, *next; |
679 | struct hid_input *hidinput; | ||
680 | 681 | ||
681 | list_for_each_safe(lh, next, &hid->inputs) { | 682 | list_for_each_entry_safe(hidinput, next, &hid->inputs, list) { |
682 | hidinput = list_entry(lh, struct hid_input, list); | ||
683 | input_unregister_device(&hidinput->input); | ||
684 | list_del(&hidinput->list); | 683 | list_del(&hidinput->list); |
684 | input_unregister_device(hidinput->input); | ||
685 | kfree(hidinput); | 685 | kfree(hidinput); |
686 | } | 686 | } |
687 | } | 687 | } |
diff --git a/drivers/usb/input/hid-lgff.c b/drivers/usb/input/hid-lgff.c index 0c4c77aa31ea..f82c9c9e5d51 100644 --- a/drivers/usb/input/hid-lgff.c +++ b/drivers/usb/input/hid-lgff.c | |||
@@ -255,22 +255,19 @@ static void hid_lgff_input_init(struct hid_device* hid) | |||
255 | u16 idVendor = le16_to_cpu(hid->dev->descriptor.idVendor); | 255 | u16 idVendor = le16_to_cpu(hid->dev->descriptor.idVendor); |
256 | u16 idProduct = le16_to_cpu(hid->dev->descriptor.idProduct); | 256 | u16 idProduct = le16_to_cpu(hid->dev->descriptor.idProduct); |
257 | struct hid_input *hidinput = list_entry(hid->inputs.next, struct hid_input, list); | 257 | struct hid_input *hidinput = list_entry(hid->inputs.next, struct hid_input, list); |
258 | struct input_dev *input_dev = hidinput->input; | ||
258 | 259 | ||
259 | while (dev->idVendor && (idVendor != dev->idVendor || idProduct != dev->idProduct)) | 260 | while (dev->idVendor && (idVendor != dev->idVendor || idProduct != dev->idProduct)) |
260 | dev++; | 261 | dev++; |
261 | 262 | ||
262 | ff = dev->ff; | 263 | for (ff = dev->ff; *ff >= 0; ff++) |
264 | set_bit(*ff, input_dev->ffbit); | ||
263 | 265 | ||
264 | while (*ff >= 0) { | 266 | input_dev->upload_effect = hid_lgff_upload_effect; |
265 | set_bit(*ff, hidinput->input.ffbit); | 267 | input_dev->flush = hid_lgff_flush; |
266 | ++ff; | ||
267 | } | ||
268 | |||
269 | hidinput->input.upload_effect = hid_lgff_upload_effect; | ||
270 | hidinput->input.flush = hid_lgff_flush; | ||
271 | 268 | ||
272 | set_bit(EV_FF, hidinput->input.evbit); | 269 | set_bit(EV_FF, input_dev->evbit); |
273 | hidinput->input.ff_effects_max = LGFF_EFFECTS; | 270 | input_dev->ff_effects_max = LGFF_EFFECTS; |
274 | } | 271 | } |
275 | 272 | ||
276 | static void hid_lgff_exit(struct hid_device* hid) | 273 | static void hid_lgff_exit(struct hid_device* hid) |
diff --git a/drivers/usb/input/hid-tmff.c b/drivers/usb/input/hid-tmff.c index 8f6a0a6f94a9..023fd5ac31c8 100644 --- a/drivers/usb/input/hid-tmff.c +++ b/drivers/usb/input/hid-tmff.c | |||
@@ -111,6 +111,7 @@ int hid_tmff_init(struct hid_device *hid) | |||
111 | struct tmff_device *private; | 111 | struct tmff_device *private; |
112 | struct list_head *pos; | 112 | struct list_head *pos; |
113 | struct hid_input *hidinput = list_entry(hid->inputs.next, struct hid_input, list); | 113 | struct hid_input *hidinput = list_entry(hid->inputs.next, struct hid_input, list); |
114 | struct input_dev *input_dev = hidinput->input; | ||
114 | 115 | ||
115 | private = kmalloc(sizeof(struct tmff_device), GFP_KERNEL); | 116 | private = kmalloc(sizeof(struct tmff_device), GFP_KERNEL); |
116 | if (!private) | 117 | if (!private) |
@@ -155,7 +156,7 @@ int hid_tmff_init(struct hid_device *hid) | |||
155 | private->report = report; | 156 | private->report = report; |
156 | private->rumble = field; | 157 | private->rumble = field; |
157 | 158 | ||
158 | set_bit(FF_RUMBLE, hidinput->input.ffbit); | 159 | set_bit(FF_RUMBLE, input_dev->ffbit); |
159 | break; | 160 | break; |
160 | 161 | ||
161 | default: | 162 | default: |
@@ -164,11 +165,11 @@ int hid_tmff_init(struct hid_device *hid) | |||
164 | } | 165 | } |
165 | 166 | ||
166 | /* Fallthrough to here only when a valid usage is found */ | 167 | /* Fallthrough to here only when a valid usage is found */ |
167 | hidinput->input.upload_effect = hid_tmff_upload_effect; | 168 | input_dev->upload_effect = hid_tmff_upload_effect; |
168 | hidinput->input.flush = hid_tmff_flush; | 169 | input_dev->flush = hid_tmff_flush; |
169 | 170 | ||
170 | set_bit(EV_FF, hidinput->input.evbit); | 171 | set_bit(EV_FF, input_dev->evbit); |
171 | hidinput->input.ff_effects_max = TMFF_EFFECTS; | 172 | input_dev->ff_effects_max = TMFF_EFFECTS; |
172 | } | 173 | } |
173 | } | 174 | } |
174 | 175 | ||
diff --git a/drivers/usb/input/hid.h b/drivers/usb/input/hid.h index ec2412c42f1e..ee48a2276104 100644 --- a/drivers/usb/input/hid.h +++ b/drivers/usb/input/hid.h | |||
@@ -371,7 +371,7 @@ struct hid_control_fifo { | |||
371 | struct hid_input { | 371 | struct hid_input { |
372 | struct list_head list; | 372 | struct list_head list; |
373 | struct hid_report *report; | 373 | struct hid_report *report; |
374 | struct input_dev input; | 374 | struct input_dev *input; |
375 | }; | 375 | }; |
376 | 376 | ||
377 | struct hid_device { /* device report descriptor */ | 377 | struct hid_device { /* device report descriptor */ |
diff --git a/drivers/usb/input/hiddev.c b/drivers/usb/input/hiddev.c index d32427818af7..440377c7a0da 100644 --- a/drivers/usb/input/hiddev.c +++ b/drivers/usb/input/hiddev.c | |||
@@ -732,9 +732,8 @@ static struct file_operations hiddev_fops = { | |||
732 | }; | 732 | }; |
733 | 733 | ||
734 | static struct usb_class_driver hiddev_class = { | 734 | static struct usb_class_driver hiddev_class = { |
735 | .name = "usb/hid/hiddev%d", | 735 | .name = "hiddev%d", |
736 | .fops = &hiddev_fops, | 736 | .fops = &hiddev_fops, |
737 | .mode = S_IFCHR | S_IRUGO | S_IWUSR, | ||
738 | .minor_base = HIDDEV_MINOR_BASE, | 737 | .minor_base = HIDDEV_MINOR_BASE, |
739 | }; | 738 | }; |
740 | 739 | ||
diff --git a/drivers/usb/input/itmtouch.c b/drivers/usb/input/itmtouch.c index becb87efb869..4a50acb39d29 100644 --- a/drivers/usb/input/itmtouch.c +++ b/drivers/usb/input/itmtouch.c | |||
@@ -40,13 +40,6 @@ | |||
40 | *****************************************************************************/ | 40 | *****************************************************************************/ |
41 | 41 | ||
42 | #include <linux/config.h> | 42 | #include <linux/config.h> |
43 | |||
44 | #ifdef CONFIG_USB_DEBUG | ||
45 | #define DEBUG | ||
46 | #else | ||
47 | #undef DEBUG | ||
48 | #endif | ||
49 | |||
50 | #include <linux/kernel.h> | 43 | #include <linux/kernel.h> |
51 | #include <linux/slab.h> | 44 | #include <linux/slab.h> |
52 | #include <linux/input.h> | 45 | #include <linux/input.h> |
@@ -73,7 +66,7 @@ MODULE_LICENSE( DRIVER_LICENSE ); | |||
73 | 66 | ||
74 | struct itmtouch_dev { | 67 | struct itmtouch_dev { |
75 | struct usb_device *usbdev; /* usb device */ | 68 | struct usb_device *usbdev; /* usb device */ |
76 | struct input_dev inputdev; /* input device */ | 69 | struct input_dev *inputdev; /* input device */ |
77 | struct urb *readurb; /* urb */ | 70 | struct urb *readurb; /* urb */ |
78 | char rbuf[ITM_BUFSIZE]; /* data */ | 71 | char rbuf[ITM_BUFSIZE]; /* data */ |
79 | int users; | 72 | int users; |
@@ -88,9 +81,9 @@ static struct usb_device_id itmtouch_ids [] = { | |||
88 | 81 | ||
89 | static void itmtouch_irq(struct urb *urb, struct pt_regs *regs) | 82 | static void itmtouch_irq(struct urb *urb, struct pt_regs *regs) |
90 | { | 83 | { |
91 | struct itmtouch_dev * itmtouch = urb->context; | 84 | struct itmtouch_dev *itmtouch = urb->context; |
92 | unsigned char *data = urb->transfer_buffer; | 85 | unsigned char *data = urb->transfer_buffer; |
93 | struct input_dev *dev = &itmtouch->inputdev; | 86 | struct input_dev *dev = itmtouch->inputdev; |
94 | int retval; | 87 | int retval; |
95 | 88 | ||
96 | switch (urb->status) { | 89 | switch (urb->status) { |
@@ -156,49 +149,62 @@ static void itmtouch_close(struct input_dev *input) | |||
156 | static int itmtouch_probe(struct usb_interface *intf, const struct usb_device_id *id) | 149 | static int itmtouch_probe(struct usb_interface *intf, const struct usb_device_id *id) |
157 | { | 150 | { |
158 | struct itmtouch_dev *itmtouch; | 151 | struct itmtouch_dev *itmtouch; |
152 | struct input_dev *input_dev; | ||
159 | struct usb_host_interface *interface; | 153 | struct usb_host_interface *interface; |
160 | struct usb_endpoint_descriptor *endpoint; | 154 | struct usb_endpoint_descriptor *endpoint; |
161 | struct usb_device *udev = interface_to_usbdev(intf); | 155 | struct usb_device *udev = interface_to_usbdev(intf); |
162 | unsigned int pipe; | 156 | unsigned int pipe; |
163 | unsigned int maxp; | 157 | unsigned int maxp; |
164 | char path[PATH_SIZE]; | ||
165 | 158 | ||
166 | interface = intf->cur_altsetting; | 159 | interface = intf->cur_altsetting; |
167 | endpoint = &interface->endpoint[0].desc; | 160 | endpoint = &interface->endpoint[0].desc; |
168 | 161 | ||
169 | if (!(itmtouch = kzalloc(sizeof(struct itmtouch_dev), GFP_KERNEL))) { | 162 | itmtouch = kzalloc(sizeof(struct itmtouch_dev), GFP_KERNEL); |
163 | input_dev = input_allocate_device(); | ||
164 | if (!itmtouch || !input_dev) { | ||
170 | err("%s - Out of memory.", __FUNCTION__); | 165 | err("%s - Out of memory.", __FUNCTION__); |
171 | return -ENOMEM; | 166 | goto fail; |
172 | } | 167 | } |
173 | 168 | ||
174 | itmtouch->usbdev = udev; | 169 | itmtouch->usbdev = udev; |
170 | itmtouch->inputdev = input_dev; | ||
175 | 171 | ||
176 | itmtouch->inputdev.private = itmtouch; | 172 | if (udev->manufacturer) |
177 | itmtouch->inputdev.open = itmtouch_open; | 173 | strlcpy(itmtouch->name, udev->manufacturer, sizeof(itmtouch->name)); |
178 | itmtouch->inputdev.close = itmtouch_close; | ||
179 | |||
180 | usb_make_path(udev, path, PATH_SIZE); | ||
181 | 174 | ||
182 | itmtouch->inputdev.evbit[0] = BIT(EV_KEY) | BIT(EV_ABS); | 175 | if (udev->product) { |
183 | itmtouch->inputdev.absbit[0] = BIT(ABS_X) | BIT(ABS_Y) | BIT(ABS_PRESSURE); | 176 | if (udev->manufacturer) |
184 | itmtouch->inputdev.keybit[LONG(BTN_TOUCH)] = BIT(BTN_TOUCH); | 177 | strlcat(itmtouch->name, " ", sizeof(itmtouch->name)); |
185 | 178 | strlcat(itmtouch->name, udev->product, sizeof(itmtouch->name)); | |
186 | itmtouch->inputdev.name = itmtouch->name; | 179 | } |
187 | itmtouch->inputdev.phys = itmtouch->phys; | ||
188 | usb_to_input_id(udev, &itmtouch->inputdev.id); | ||
189 | itmtouch->inputdev.dev = &intf->dev; | ||
190 | 180 | ||
191 | if (!strlen(itmtouch->name)) | 181 | if (!strlen(itmtouch->name)) |
192 | sprintf(itmtouch->name, "USB ITM touchscreen"); | 182 | sprintf(itmtouch->name, "USB ITM touchscreen"); |
193 | 183 | ||
184 | usb_make_path(udev, itmtouch->phys, sizeof(itmtouch->phys)); | ||
185 | strlcpy(itmtouch->phys, "/input0", sizeof(itmtouch->phys)); | ||
186 | |||
187 | input_dev->name = itmtouch->name; | ||
188 | input_dev->phys = itmtouch->phys; | ||
189 | usb_to_input_id(udev, &input_dev->id); | ||
190 | input_dev->cdev.dev = &intf->dev; | ||
191 | input_dev->private = itmtouch; | ||
192 | |||
193 | input_dev->open = itmtouch_open; | ||
194 | input_dev->close = itmtouch_close; | ||
195 | |||
196 | input_dev->evbit[0] = BIT(EV_KEY) | BIT(EV_ABS); | ||
197 | input_dev->absbit[0] = BIT(ABS_X) | BIT(ABS_Y) | BIT(ABS_PRESSURE); | ||
198 | input_dev->keybit[LONG(BTN_TOUCH)] = BIT(BTN_TOUCH); | ||
199 | |||
194 | /* device limits */ | 200 | /* device limits */ |
195 | /* as specified by the ITM datasheet, X and Y are 12bit, | 201 | /* as specified by the ITM datasheet, X and Y are 12bit, |
196 | * Z (pressure) is 8 bit. However, the fields are defined up | 202 | * Z (pressure) is 8 bit. However, the fields are defined up |
197 | * to 14 bits for future possible expansion. | 203 | * to 14 bits for future possible expansion. |
198 | */ | 204 | */ |
199 | input_set_abs_params(&itmtouch->inputdev, ABS_X, 0, 0x0FFF, 2, 0); | 205 | input_set_abs_params(input_dev, ABS_X, 0, 0x0FFF, 2, 0); |
200 | input_set_abs_params(&itmtouch->inputdev, ABS_Y, 0, 0x0FFF, 2, 0); | 206 | input_set_abs_params(input_dev, ABS_Y, 0, 0x0FFF, 2, 0); |
201 | input_set_abs_params(&itmtouch->inputdev, ABS_PRESSURE, 0, 0xFF, 2, 0); | 207 | input_set_abs_params(input_dev, ABS_PRESSURE, 0, 0xFF, 2, 0); |
202 | 208 | ||
203 | /* initialise the URB so we can read from the transport stream */ | 209 | /* initialise the URB so we can read from the transport stream */ |
204 | pipe = usb_rcvintpipe(itmtouch->usbdev, endpoint->bEndpointAddress); | 210 | pipe = usb_rcvintpipe(itmtouch->usbdev, endpoint->bEndpointAddress); |
@@ -208,22 +214,23 @@ static int itmtouch_probe(struct usb_interface *intf, const struct usb_device_id | |||
208 | maxp = ITM_BUFSIZE; | 214 | maxp = ITM_BUFSIZE; |
209 | 215 | ||
210 | itmtouch->readurb = usb_alloc_urb(0, GFP_KERNEL); | 216 | itmtouch->readurb = usb_alloc_urb(0, GFP_KERNEL); |
211 | |||
212 | if (!itmtouch->readurb) { | 217 | if (!itmtouch->readurb) { |
213 | dbg("%s - usb_alloc_urb failed: itmtouch->readurb", __FUNCTION__); | 218 | dbg("%s - usb_alloc_urb failed: itmtouch->readurb", __FUNCTION__); |
214 | kfree(itmtouch); | 219 | goto fail; |
215 | return -ENOMEM; | ||
216 | } | 220 | } |
217 | 221 | ||
218 | usb_fill_int_urb(itmtouch->readurb, itmtouch->usbdev, pipe, itmtouch->rbuf, | 222 | usb_fill_int_urb(itmtouch->readurb, itmtouch->usbdev, pipe, itmtouch->rbuf, |
219 | maxp, itmtouch_irq, itmtouch, endpoint->bInterval); | 223 | maxp, itmtouch_irq, itmtouch, endpoint->bInterval); |
220 | 224 | ||
221 | input_register_device(&itmtouch->inputdev); | 225 | input_register_device(itmtouch->inputdev); |
222 | 226 | ||
223 | printk(KERN_INFO "itmtouch: %s registered on %s\n", itmtouch->name, path); | ||
224 | usb_set_intfdata(intf, itmtouch); | 227 | usb_set_intfdata(intf, itmtouch); |
225 | 228 | ||
226 | return 0; | 229 | return 0; |
230 | |||
231 | fail: input_free_device(input_dev); | ||
232 | kfree(itmtouch); | ||
233 | return -ENOMEM; | ||
227 | } | 234 | } |
228 | 235 | ||
229 | static void itmtouch_disconnect(struct usb_interface *intf) | 236 | static void itmtouch_disconnect(struct usb_interface *intf) |
@@ -233,7 +240,7 @@ static void itmtouch_disconnect(struct usb_interface *intf) | |||
233 | usb_set_intfdata(intf, NULL); | 240 | usb_set_intfdata(intf, NULL); |
234 | 241 | ||
235 | if (itmtouch) { | 242 | if (itmtouch) { |
236 | input_unregister_device(&itmtouch->inputdev); | 243 | input_unregister_device(itmtouch->inputdev); |
237 | usb_kill_urb(itmtouch->readurb); | 244 | usb_kill_urb(itmtouch->readurb); |
238 | usb_free_urb(itmtouch->readurb); | 245 | usb_free_urb(itmtouch->readurb); |
239 | kfree(itmtouch); | 246 | kfree(itmtouch); |
diff --git a/drivers/usb/input/kbtab.c b/drivers/usb/input/kbtab.c index b6f6ac8d9c2f..a248664b5d1d 100644 --- a/drivers/usb/input/kbtab.c +++ b/drivers/usb/input/kbtab.c | |||
@@ -34,7 +34,7 @@ MODULE_PARM_DESC(kb_pressure_click, "pressure threshold for clicks"); | |||
34 | struct kbtab { | 34 | struct kbtab { |
35 | signed char *data; | 35 | signed char *data; |
36 | dma_addr_t data_dma; | 36 | dma_addr_t data_dma; |
37 | struct input_dev dev; | 37 | struct input_dev *dev; |
38 | struct usb_device *usbdev; | 38 | struct usb_device *usbdev; |
39 | struct urb *irq; | 39 | struct urb *irq; |
40 | int x, y; | 40 | int x, y; |
@@ -48,7 +48,7 @@ static void kbtab_irq(struct urb *urb, struct pt_regs *regs) | |||
48 | { | 48 | { |
49 | struct kbtab *kbtab = urb->context; | 49 | struct kbtab *kbtab = urb->context; |
50 | unsigned char *data = kbtab->data; | 50 | unsigned char *data = kbtab->data; |
51 | struct input_dev *dev = &kbtab->dev; | 51 | struct input_dev *dev = kbtab->dev; |
52 | int retval; | 52 | int retval; |
53 | 53 | ||
54 | switch (urb->status) { | 54 | switch (urb->status) { |
@@ -124,53 +124,43 @@ static int kbtab_probe(struct usb_interface *intf, const struct usb_device_id *i | |||
124 | struct usb_device *dev = interface_to_usbdev(intf); | 124 | struct usb_device *dev = interface_to_usbdev(intf); |
125 | struct usb_endpoint_descriptor *endpoint; | 125 | struct usb_endpoint_descriptor *endpoint; |
126 | struct kbtab *kbtab; | 126 | struct kbtab *kbtab; |
127 | char path[64]; | 127 | struct input_dev *input_dev; |
128 | 128 | ||
129 | if (!(kbtab = kmalloc(sizeof(struct kbtab), GFP_KERNEL))) | 129 | kbtab = kzalloc(sizeof(struct kbtab), GFP_KERNEL); |
130 | return -ENOMEM; | 130 | input_dev = input_allocate_device(); |
131 | memset(kbtab, 0, sizeof(struct kbtab)); | 131 | if (!kbtab || !input_dev) |
132 | goto fail1; | ||
132 | 133 | ||
133 | kbtab->data = usb_buffer_alloc(dev, 8, GFP_KERNEL, &kbtab->data_dma); | 134 | kbtab->data = usb_buffer_alloc(dev, 8, GFP_KERNEL, &kbtab->data_dma); |
134 | if (!kbtab->data) { | 135 | if (!kbtab->data) |
135 | kfree(kbtab); | 136 | goto fail1; |
136 | return -ENOMEM; | ||
137 | } | ||
138 | 137 | ||
139 | kbtab->irq = usb_alloc_urb(0, GFP_KERNEL); | 138 | kbtab->irq = usb_alloc_urb(0, GFP_KERNEL); |
140 | if (!kbtab->irq) { | 139 | if (!kbtab->irq) |
141 | usb_buffer_free(dev, 10, kbtab->data, kbtab->data_dma); | 140 | goto fail2; |
142 | kfree(kbtab); | ||
143 | return -ENOMEM; | ||
144 | } | ||
145 | |||
146 | kbtab->dev.evbit[0] |= BIT(EV_KEY) | BIT(EV_ABS) | BIT(EV_MSC); | ||
147 | kbtab->dev.absbit[0] |= BIT(ABS_X) | BIT(ABS_Y) | BIT(ABS_PRESSURE); | ||
148 | |||
149 | kbtab->dev.keybit[LONG(BTN_LEFT)] |= BIT(BTN_LEFT) | BIT(BTN_RIGHT) | BIT(BTN_MIDDLE); | ||
150 | |||
151 | kbtab->dev.keybit[LONG(BTN_DIGI)] |= BIT(BTN_TOOL_PEN) | BIT(BTN_TOUCH); | ||
152 | 141 | ||
153 | kbtab->dev.mscbit[0] |= BIT(MSC_SERIAL); | 142 | kbtab->usbdev = dev; |
154 | 143 | kbtab->dev = input_dev; | |
155 | kbtab->dev.absmax[ABS_X] = 0x2000; | ||
156 | kbtab->dev.absmax[ABS_Y] = 0x1750; | ||
157 | kbtab->dev.absmax[ABS_PRESSURE] = 0xff; | ||
158 | 144 | ||
159 | kbtab->dev.absfuzz[ABS_X] = 4; | 145 | usb_make_path(dev, kbtab->phys, sizeof(kbtab->phys)); |
160 | kbtab->dev.absfuzz[ABS_Y] = 4; | 146 | strlcat(kbtab->phys, "/input0", sizeof(kbtab->phys)); |
161 | 147 | ||
162 | kbtab->dev.private = kbtab; | 148 | input_dev->name = "KB Gear Tablet"; |
163 | kbtab->dev.open = kbtab_open; | 149 | input_dev->phys = kbtab->phys; |
164 | kbtab->dev.close = kbtab_close; | 150 | usb_to_input_id(dev, &input_dev->id); |
151 | input_dev->cdev.dev = &intf->dev; | ||
152 | input_dev->private = kbtab; | ||
165 | 153 | ||
166 | usb_make_path(dev, path, 64); | 154 | input_dev->open = kbtab_open; |
167 | sprintf(kbtab->phys, "%s/input0", path); | 155 | input_dev->close = kbtab_close; |
168 | 156 | ||
169 | kbtab->dev.name = "KB Gear Tablet"; | 157 | input_dev->evbit[0] |= BIT(EV_KEY) | BIT(EV_ABS) | BIT(EV_MSC); |
170 | kbtab->dev.phys = kbtab->phys; | 158 | input_dev->keybit[LONG(BTN_LEFT)] |= BIT(BTN_LEFT) | BIT(BTN_RIGHT) | BIT(BTN_MIDDLE); |
171 | usb_to_input_id(dev, &kbtab->dev.id); | 159 | input_dev->keybit[LONG(BTN_DIGI)] |= BIT(BTN_TOOL_PEN) | BIT(BTN_TOUCH); |
172 | kbtab->dev.dev = &intf->dev; | 160 | input_dev->mscbit[0] |= BIT(MSC_SERIAL); |
173 | kbtab->usbdev = dev; | 161 | input_set_abs_params(input_dev, ABS_X, 0, 0x2000, 4, 0); |
162 | input_set_abs_params(input_dev, ABS_X, 0, 0x1750, 4, 0); | ||
163 | input_set_abs_params(input_dev, ABS_PRESSURE, 0, 0xff, 0, 0); | ||
174 | 164 | ||
175 | endpoint = &intf->cur_altsetting->endpoint[0].desc; | 165 | endpoint = &intf->cur_altsetting->endpoint[0].desc; |
176 | 166 | ||
@@ -181,23 +171,25 @@ static int kbtab_probe(struct usb_interface *intf, const struct usb_device_id *i | |||
181 | kbtab->irq->transfer_dma = kbtab->data_dma; | 171 | kbtab->irq->transfer_dma = kbtab->data_dma; |
182 | kbtab->irq->transfer_flags |= URB_NO_TRANSFER_DMA_MAP; | 172 | kbtab->irq->transfer_flags |= URB_NO_TRANSFER_DMA_MAP; |
183 | 173 | ||
184 | input_register_device(&kbtab->dev); | 174 | input_register_device(kbtab->dev); |
185 | |||
186 | printk(KERN_INFO "input: KB Gear Tablet on %s\n", path); | ||
187 | 175 | ||
188 | usb_set_intfdata(intf, kbtab); | 176 | usb_set_intfdata(intf, kbtab); |
189 | |||
190 | return 0; | 177 | return 0; |
178 | |||
179 | fail2: usb_buffer_free(dev, 10, kbtab->data, kbtab->data_dma); | ||
180 | fail1: input_free_device(input_dev); | ||
181 | kfree(kbtab); | ||
182 | return -ENOMEM; | ||
191 | } | 183 | } |
192 | 184 | ||
193 | static void kbtab_disconnect(struct usb_interface *intf) | 185 | static void kbtab_disconnect(struct usb_interface *intf) |
194 | { | 186 | { |
195 | struct kbtab *kbtab = usb_get_intfdata (intf); | 187 | struct kbtab *kbtab = usb_get_intfdata(intf); |
196 | 188 | ||
197 | usb_set_intfdata(intf, NULL); | 189 | usb_set_intfdata(intf, NULL); |
198 | if (kbtab) { | 190 | if (kbtab) { |
199 | usb_kill_urb(kbtab->irq); | 191 | usb_kill_urb(kbtab->irq); |
200 | input_unregister_device(&kbtab->dev); | 192 | input_unregister_device(kbtab->dev); |
201 | usb_free_urb(kbtab->irq); | 193 | usb_free_urb(kbtab->irq); |
202 | usb_buffer_free(interface_to_usbdev(intf), 10, kbtab->data, kbtab->data_dma); | 194 | usb_buffer_free(interface_to_usbdev(intf), 10, kbtab->data, kbtab->data_dma); |
203 | kfree(kbtab); | 195 | kfree(kbtab); |
diff --git a/drivers/usb/input/keyspan_remote.c b/drivers/usb/input/keyspan_remote.c index 99de1b33c07d..a32cfe51b77d 100644 --- a/drivers/usb/input/keyspan_remote.c +++ b/drivers/usb/input/keyspan_remote.c | |||
@@ -20,6 +20,7 @@ | |||
20 | #include <linux/moduleparam.h> | 20 | #include <linux/moduleparam.h> |
21 | #include <linux/input.h> | 21 | #include <linux/input.h> |
22 | #include <linux/usb.h> | 22 | #include <linux/usb.h> |
23 | #include <linux/usb_input.h> | ||
23 | 24 | ||
24 | #define DRIVER_VERSION "v0.1" | 25 | #define DRIVER_VERSION "v0.1" |
25 | #define DRIVER_AUTHOR "Michael Downey <downey@zymeta.com>" | 26 | #define DRIVER_AUTHOR "Michael Downey <downey@zymeta.com>" |
@@ -75,7 +76,7 @@ struct usb_keyspan { | |||
75 | char name[128]; | 76 | char name[128]; |
76 | char phys[64]; | 77 | char phys[64]; |
77 | struct usb_device* udev; | 78 | struct usb_device* udev; |
78 | struct input_dev input; | 79 | struct input_dev *input; |
79 | struct usb_interface* interface; | 80 | struct usb_interface* interface; |
80 | struct usb_endpoint_descriptor* in_endpoint; | 81 | struct usb_endpoint_descriptor* in_endpoint; |
81 | struct urb* irq_urb; | 82 | struct urb* irq_urb; |
@@ -136,12 +137,11 @@ static struct usb_driver keyspan_driver; | |||
136 | */ | 137 | */ |
137 | static void keyspan_print(struct usb_keyspan* dev) /*unsigned char* data)*/ | 138 | static void keyspan_print(struct usb_keyspan* dev) /*unsigned char* data)*/ |
138 | { | 139 | { |
139 | char codes[4*RECV_SIZE]; | 140 | char codes[4 * RECV_SIZE]; |
140 | int i; | 141 | int i; |
141 | 142 | ||
142 | for (i = 0; i < RECV_SIZE; i++) { | 143 | for (i = 0; i < RECV_SIZE; i++) |
143 | snprintf(codes+i*3, 4, "%02x ", dev->in_buffer[i]); | 144 | snprintf(codes + i * 3, 4, "%02x ", dev->in_buffer[i]); |
144 | } | ||
145 | 145 | ||
146 | dev_info(&dev->udev->dev, "%s\n", codes); | 146 | dev_info(&dev->udev->dev, "%s\n", codes); |
147 | } | 147 | } |
@@ -153,16 +153,17 @@ static void keyspan_print(struct usb_keyspan* dev) /*unsigned char* data)*/ | |||
153 | static int keyspan_load_tester(struct usb_keyspan* dev, int bits_needed) | 153 | static int keyspan_load_tester(struct usb_keyspan* dev, int bits_needed) |
154 | { | 154 | { |
155 | if (dev->data.bits_left >= bits_needed) | 155 | if (dev->data.bits_left >= bits_needed) |
156 | return(0); | 156 | return 0; |
157 | 157 | ||
158 | /* | 158 | /* |
159 | * Somehow we've missed the last message. The message will be repeated | 159 | * Somehow we've missed the last message. The message will be repeated |
160 | * though so it's not too big a deal | 160 | * though so it's not too big a deal |
161 | */ | 161 | */ |
162 | if (dev->data.pos >= dev->data.len) { | 162 | if (dev->data.pos >= dev->data.len) { |
163 | dev_dbg(&dev->udev, "%s - Error ran out of data. pos: %d, len: %d\n", | 163 | dev_dbg(&dev->udev->dev, |
164 | "%s - Error ran out of data. pos: %d, len: %d\n", | ||
164 | __FUNCTION__, dev->data.pos, dev->data.len); | 165 | __FUNCTION__, dev->data.pos, dev->data.len); |
165 | return(-1); | 166 | return -1; |
166 | } | 167 | } |
167 | 168 | ||
168 | /* Load as much as we can into the tester. */ | 169 | /* Load as much as we can into the tester. */ |
@@ -172,7 +173,7 @@ static int keyspan_load_tester(struct usb_keyspan* dev, int bits_needed) | |||
172 | dev->data.bits_left += 8; | 173 | dev->data.bits_left += 8; |
173 | } | 174 | } |
174 | 175 | ||
175 | return(0); | 176 | return 0; |
176 | } | 177 | } |
177 | 178 | ||
178 | /* | 179 | /* |
@@ -306,15 +307,15 @@ static void keyspan_check_data(struct usb_keyspan *remote, struct pt_regs *regs) | |||
306 | err("Bad message recieved, no stop bit found.\n"); | 307 | err("Bad message recieved, no stop bit found.\n"); |
307 | } | 308 | } |
308 | 309 | ||
309 | dev_dbg(&remote->udev, | 310 | dev_dbg(&remote->udev->dev, |
310 | "%s found valid message: system: %d, button: %d, toggle: %d\n", | 311 | "%s found valid message: system: %d, button: %d, toggle: %d\n", |
311 | __FUNCTION__, message.system, message.button, message.toggle); | 312 | __FUNCTION__, message.system, message.button, message.toggle); |
312 | 313 | ||
313 | if (message.toggle != remote->toggle) { | 314 | if (message.toggle != remote->toggle) { |
314 | input_regs(&remote->input, regs); | 315 | input_regs(remote->input, regs); |
315 | input_report_key(&remote->input, keyspan_key_table[message.button], 1); | 316 | input_report_key(remote->input, keyspan_key_table[message.button], 1); |
316 | input_report_key(&remote->input, keyspan_key_table[message.button], 0); | 317 | input_report_key(remote->input, keyspan_key_table[message.button], 0); |
317 | input_sync(&remote->input); | 318 | input_sync(remote->input); |
318 | remote->toggle = message.toggle; | 319 | remote->toggle = message.toggle; |
319 | } | 320 | } |
320 | 321 | ||
@@ -397,14 +398,9 @@ static int keyspan_open(struct input_dev *dev) | |||
397 | { | 398 | { |
398 | struct usb_keyspan *remote = dev->private; | 399 | struct usb_keyspan *remote = dev->private; |
399 | 400 | ||
400 | if (remote->open++) | ||
401 | return 0; | ||
402 | |||
403 | remote->irq_urb->dev = remote->udev; | 401 | remote->irq_urb->dev = remote->udev; |
404 | if (usb_submit_urb(remote->irq_urb, GFP_KERNEL)) { | 402 | if (usb_submit_urb(remote->irq_urb, GFP_KERNEL)) |
405 | remote->open--; | ||
406 | return -EIO; | 403 | return -EIO; |
407 | } | ||
408 | 404 | ||
409 | return 0; | 405 | return 0; |
410 | } | 406 | } |
@@ -413,8 +409,26 @@ static void keyspan_close(struct input_dev *dev) | |||
413 | { | 409 | { |
414 | struct usb_keyspan *remote = dev->private; | 410 | struct usb_keyspan *remote = dev->private; |
415 | 411 | ||
416 | if (!--remote->open) | 412 | usb_kill_urb(remote->irq_urb); |
417 | usb_kill_urb(remote->irq_urb); | 413 | } |
414 | |||
415 | static struct usb_endpoint_descriptor *keyspan_get_in_endpoint(struct usb_host_interface *iface) | ||
416 | { | ||
417 | |||
418 | struct usb_endpoint_descriptor *endpoint; | ||
419 | int i; | ||
420 | |||
421 | for (i = 0; i < iface->desc.bNumEndpoints; ++i) { | ||
422 | endpoint = &iface->endpoint[i].desc; | ||
423 | |||
424 | if ((endpoint->bEndpointAddress & USB_DIR_IN) && | ||
425 | ((endpoint->bmAttributes & USB_ENDPOINT_XFERTYPE_MASK) == USB_ENDPOINT_XFER_INT)) { | ||
426 | /* we found our interrupt in endpoint */ | ||
427 | return endpoint; | ||
428 | } | ||
429 | } | ||
430 | |||
431 | return NULL; | ||
418 | } | 432 | } |
419 | 433 | ||
420 | /* | 434 | /* |
@@ -422,110 +436,78 @@ static void keyspan_close(struct input_dev *dev) | |||
422 | */ | 436 | */ |
423 | static int keyspan_probe(struct usb_interface *interface, const struct usb_device_id *id) | 437 | static int keyspan_probe(struct usb_interface *interface, const struct usb_device_id *id) |
424 | { | 438 | { |
425 | int i; | 439 | struct usb_device *udev = interface_to_usbdev(interface); |
426 | int retval = -ENOMEM; | ||
427 | char path[64]; | ||
428 | char *buf; | ||
429 | struct usb_keyspan *remote = NULL; | ||
430 | struct usb_host_interface *iface_desc; | ||
431 | struct usb_endpoint_descriptor *endpoint; | 440 | struct usb_endpoint_descriptor *endpoint; |
432 | struct usb_device *udev = usb_get_dev(interface_to_usbdev(interface)); | 441 | struct usb_keyspan *remote; |
442 | struct input_dev *input_dev; | ||
443 | int i, retval; | ||
433 | 444 | ||
434 | /* allocate memory for our device state and initialize it */ | 445 | endpoint = keyspan_get_in_endpoint(interface->cur_altsetting); |
435 | remote = kmalloc(sizeof(*remote), GFP_KERNEL); | 446 | if (!endpoint) |
436 | if (remote == NULL) { | 447 | return -ENODEV; |
437 | err("Out of memory\n"); | 448 | |
438 | goto error; | 449 | remote = kzalloc(sizeof(*remote), GFP_KERNEL); |
450 | input_dev = input_allocate_device(); | ||
451 | if (!remote || !input_dev) { | ||
452 | retval = -ENOMEM; | ||
453 | goto fail1; | ||
439 | } | 454 | } |
440 | memset(remote, 0x00, sizeof(*remote)); | ||
441 | 455 | ||
442 | remote->udev = udev; | 456 | remote->udev = udev; |
457 | remote->input = input_dev; | ||
443 | remote->interface = interface; | 458 | remote->interface = interface; |
459 | remote->in_endpoint = endpoint; | ||
444 | remote->toggle = -1; /* Set to -1 so we will always not match the toggle from the first remote message. */ | 460 | remote->toggle = -1; /* Set to -1 so we will always not match the toggle from the first remote message. */ |
445 | 461 | ||
446 | /* set up the endpoint information */ | 462 | remote->in_buffer = usb_buffer_alloc(udev, RECV_SIZE, SLAB_ATOMIC, &remote->in_dma); |
447 | /* use only the first in interrupt endpoint */ | 463 | if (!remote->in_buffer) { |
448 | iface_desc = interface->cur_altsetting; | 464 | retval = -ENOMEM; |
449 | for (i = 0; i < iface_desc->desc.bNumEndpoints; ++i) { | 465 | goto fail1; |
450 | endpoint = &iface_desc->endpoint[i].desc; | ||
451 | |||
452 | if (!remote->in_endpoint && | ||
453 | (endpoint->bEndpointAddress & USB_DIR_IN) && | ||
454 | ((endpoint->bmAttributes & USB_ENDPOINT_XFERTYPE_MASK) == USB_ENDPOINT_XFER_INT)) { | ||
455 | /* we found our interrupt in endpoint */ | ||
456 | remote->in_endpoint = endpoint; | ||
457 | |||
458 | remote->in_buffer = usb_buffer_alloc(remote->udev, RECV_SIZE, SLAB_ATOMIC, &remote->in_dma); | ||
459 | if (!remote->in_buffer) { | ||
460 | retval = -ENOMEM; | ||
461 | goto error; | ||
462 | } | ||
463 | } | ||
464 | } | ||
465 | |||
466 | if (!remote->in_endpoint) { | ||
467 | err("Could not find interrupt input endpoint.\n"); | ||
468 | retval = -ENODEV; | ||
469 | goto error; | ||
470 | } | 466 | } |
471 | 467 | ||
472 | remote->irq_urb = usb_alloc_urb(0, GFP_KERNEL); | 468 | remote->irq_urb = usb_alloc_urb(0, GFP_KERNEL); |
473 | if (!remote->irq_urb) { | 469 | if (!remote->irq_urb) { |
474 | err("Failed to allocate urb.\n"); | ||
475 | retval = -ENOMEM; | 470 | retval = -ENOMEM; |
476 | goto error; | 471 | goto fail2; |
477 | } | 472 | } |
478 | 473 | ||
479 | retval = keyspan_setup(remote->udev); | 474 | retval = keyspan_setup(udev); |
480 | if (retval) { | 475 | if (retval) { |
481 | err("Failed to setup device.\n"); | ||
482 | retval = -ENODEV; | 476 | retval = -ENODEV; |
483 | goto error; | 477 | goto fail3; |
484 | } | ||
485 | |||
486 | /* | ||
487 | * Setup the input system with the bits we are going to be reporting | ||
488 | */ | ||
489 | remote->input.evbit[0] = BIT(EV_KEY); /* We will only report KEY events. */ | ||
490 | for (i = 0; i < 32; ++i) { | ||
491 | if (keyspan_key_table[i] != KEY_RESERVED) { | ||
492 | set_bit(keyspan_key_table[i], remote->input.keybit); | ||
493 | } | ||
494 | } | 478 | } |
495 | 479 | ||
496 | remote->input.private = remote; | 480 | if (udev->manufacturer) |
497 | remote->input.open = keyspan_open; | 481 | strlcpy(remote->name, udev->manufacturer, sizeof(remote->name)); |
498 | remote->input.close = keyspan_close; | ||
499 | |||
500 | usb_make_path(remote->udev, path, 64); | ||
501 | sprintf(remote->phys, "%s/input0", path); | ||
502 | 482 | ||
503 | remote->input.name = remote->name; | 483 | if (udev->product) { |
504 | remote->input.phys = remote->phys; | 484 | if (udev->manufacturer) |
505 | remote->input.id.bustype = BUS_USB; | 485 | strlcat(remote->name, " ", sizeof(remote->name)); |
506 | remote->input.id.vendor = le16_to_cpu(remote->udev->descriptor.idVendor); | 486 | strlcat(remote->name, udev->product, sizeof(remote->name)); |
507 | remote->input.id.product = le16_to_cpu(remote->udev->descriptor.idProduct); | ||
508 | remote->input.id.version = le16_to_cpu(remote->udev->descriptor.bcdDevice); | ||
509 | |||
510 | if (!(buf = kmalloc(63, GFP_KERNEL))) { | ||
511 | usb_buffer_free(remote->udev, RECV_SIZE, remote->in_buffer, remote->in_dma); | ||
512 | kfree(remote); | ||
513 | return -ENOMEM; | ||
514 | } | 487 | } |
515 | 488 | ||
516 | if (remote->udev->descriptor.iManufacturer && | 489 | if (!strlen(remote->name)) |
517 | usb_string(remote->udev, remote->udev->descriptor.iManufacturer, buf, 63) > 0) | 490 | snprintf(remote->name, sizeof(remote->name), |
518 | strcat(remote->name, buf); | 491 | "USB Keyspan Remote %04x:%04x", |
492 | le16_to_cpu(udev->descriptor.idVendor), | ||
493 | le16_to_cpu(udev->descriptor.idProduct)); | ||
519 | 494 | ||
520 | if (remote->udev->descriptor.iProduct && | 495 | usb_make_path(udev, remote->phys, sizeof(remote->phys)); |
521 | usb_string(remote->udev, remote->udev->descriptor.iProduct, buf, 63) > 0) | 496 | strlcat(remote->phys, "/input0", sizeof(remote->phys)); |
522 | sprintf(remote->name, "%s %s", remote->name, buf); | ||
523 | 497 | ||
524 | if (!strlen(remote->name)) | 498 | input_dev->name = remote->name; |
525 | sprintf(remote->name, "USB Keyspan Remote %04x:%04x", | 499 | input_dev->phys = remote->phys; |
526 | remote->input.id.vendor, remote->input.id.product); | 500 | usb_to_input_id(udev, &input_dev->id); |
501 | input_dev->cdev.dev = &interface->dev; | ||
527 | 502 | ||
528 | kfree(buf); | 503 | input_dev->evbit[0] = BIT(EV_KEY); /* We will only report KEY events. */ |
504 | for (i = 0; i < ARRAY_SIZE(keyspan_key_table); i++) | ||
505 | if (keyspan_key_table[i] != KEY_RESERVED) | ||
506 | set_bit(keyspan_key_table[i], input_dev->keybit); | ||
507 | |||
508 | input_dev->private = remote; | ||
509 | input_dev->open = keyspan_open; | ||
510 | input_dev->close = keyspan_close; | ||
529 | 511 | ||
530 | /* | 512 | /* |
531 | * Initialize the URB to access the device. The urb gets sent to the device in keyspan_open() | 513 | * Initialize the URB to access the device. The urb gets sent to the device in keyspan_open() |
@@ -538,27 +520,17 @@ static int keyspan_probe(struct usb_interface *interface, const struct usb_devic | |||
538 | remote->irq_urb->transfer_flags |= URB_NO_TRANSFER_DMA_MAP; | 520 | remote->irq_urb->transfer_flags |= URB_NO_TRANSFER_DMA_MAP; |
539 | 521 | ||
540 | /* we can register the device now, as it is ready */ | 522 | /* we can register the device now, as it is ready */ |
541 | input_register_device(&remote->input); | 523 | input_register_device(remote->input); |
542 | 524 | ||
543 | /* save our data pointer in this interface device */ | 525 | /* save our data pointer in this interface device */ |
544 | usb_set_intfdata(interface, remote); | 526 | usb_set_intfdata(interface, remote); |
545 | 527 | ||
546 | /* let the user know what node this device is now attached to */ | ||
547 | info("connected: %s on %s", remote->name, path); | ||
548 | return 0; | 528 | return 0; |
549 | 529 | ||
550 | error: | 530 | fail3: usb_free_urb(remote->irq_urb); |
551 | /* | 531 | fail2: usb_buffer_free(udev, RECV_SIZE, remote->in_buffer, remote->in_dma); |
552 | * In case of error we need to clean up any allocated buffers | 532 | fail1: kfree(remote); |
553 | */ | 533 | input_free_device(input_dev); |
554 | if (remote->irq_urb) | ||
555 | usb_free_urb(remote->irq_urb); | ||
556 | |||
557 | if (remote->in_buffer) | ||
558 | usb_buffer_free(remote->udev, RECV_SIZE, remote->in_buffer, remote->in_dma); | ||
559 | |||
560 | if (remote) | ||
561 | kfree(remote); | ||
562 | 534 | ||
563 | return retval; | 535 | return retval; |
564 | } | 536 | } |
@@ -570,23 +542,16 @@ static void keyspan_disconnect(struct usb_interface *interface) | |||
570 | { | 542 | { |
571 | struct usb_keyspan *remote; | 543 | struct usb_keyspan *remote; |
572 | 544 | ||
573 | /* prevent keyspan_open() from racing keyspan_disconnect() */ | ||
574 | lock_kernel(); | ||
575 | |||
576 | remote = usb_get_intfdata(interface); | 545 | remote = usb_get_intfdata(interface); |
577 | usb_set_intfdata(interface, NULL); | 546 | usb_set_intfdata(interface, NULL); |
578 | 547 | ||
579 | if (remote) { /* We have a valid driver structure so clean up everything we allocated. */ | 548 | if (remote) { /* We have a valid driver structure so clean up everything we allocated. */ |
580 | input_unregister_device(&remote->input); | 549 | input_unregister_device(remote->input); |
581 | usb_kill_urb(remote->irq_urb); | 550 | usb_kill_urb(remote->irq_urb); |
582 | usb_free_urb(remote->irq_urb); | 551 | usb_free_urb(remote->irq_urb); |
583 | usb_buffer_free(interface_to_usbdev(interface), RECV_SIZE, remote->in_buffer, remote->in_dma); | 552 | usb_buffer_free(remote->udev, RECV_SIZE, remote->in_buffer, remote->in_dma); |
584 | kfree(remote); | 553 | kfree(remote); |
585 | } | 554 | } |
586 | |||
587 | unlock_kernel(); | ||
588 | |||
589 | info("USB Keyspan now disconnected"); | ||
590 | } | 555 | } |
591 | 556 | ||
592 | /* | 557 | /* |
diff --git a/drivers/usb/input/map_to_7segment.h b/drivers/usb/input/map_to_7segment.h index 52ff27f15127..a424094d9fe2 100644 --- a/drivers/usb/input/map_to_7segment.h +++ b/drivers/usb/input/map_to_7segment.h | |||
@@ -79,7 +79,7 @@ struct seg7_conversion_map { | |||
79 | 79 | ||
80 | static inline int map_to_seg7(struct seg7_conversion_map *map, int c) | 80 | static inline int map_to_seg7(struct seg7_conversion_map *map, int c) |
81 | { | 81 | { |
82 | return c & 0x7f ? map->table[c] : -EINVAL; | 82 | return c >= 0 && c < sizeof(map->table) ? map->table[c] : -EINVAL; |
83 | } | 83 | } |
84 | 84 | ||
85 | #define SEG7_CONVERSION_MAP(_name, _map) \ | 85 | #define SEG7_CONVERSION_MAP(_name, _map) \ |
diff --git a/drivers/usb/input/mtouchusb.c b/drivers/usb/input/mtouchusb.c index ff9275057a18..52cc18cd247d 100644 --- a/drivers/usb/input/mtouchusb.c +++ b/drivers/usb/input/mtouchusb.c | |||
@@ -40,13 +40,6 @@ | |||
40 | *****************************************************************************/ | 40 | *****************************************************************************/ |
41 | 41 | ||
42 | #include <linux/config.h> | 42 | #include <linux/config.h> |
43 | |||
44 | #ifdef CONFIG_USB_DEBUG | ||
45 | #define DEBUG | ||
46 | #else | ||
47 | #undef DEBUG | ||
48 | #endif | ||
49 | |||
50 | #include <linux/kernel.h> | 43 | #include <linux/kernel.h> |
51 | #include <linux/slab.h> | 44 | #include <linux/slab.h> |
52 | #include <linux/input.h> | 45 | #include <linux/input.h> |
@@ -98,7 +91,7 @@ struct mtouch_usb { | |||
98 | dma_addr_t data_dma; | 91 | dma_addr_t data_dma; |
99 | struct urb *irq; | 92 | struct urb *irq; |
100 | struct usb_device *udev; | 93 | struct usb_device *udev; |
101 | struct input_dev input; | 94 | struct input_dev *input; |
102 | char name[128]; | 95 | char name[128]; |
103 | char phys[64]; | 96 | char phys[64]; |
104 | }; | 97 | }; |
@@ -135,14 +128,14 @@ static void mtouchusb_irq(struct urb *urb, struct pt_regs *regs) | |||
135 | goto exit; | 128 | goto exit; |
136 | } | 129 | } |
137 | 130 | ||
138 | input_regs(&mtouch->input, regs); | 131 | input_regs(mtouch->input, regs); |
139 | input_report_key(&mtouch->input, BTN_TOUCH, | 132 | input_report_key(mtouch->input, BTN_TOUCH, |
140 | MTOUCHUSB_GET_TOUCHED(mtouch->data)); | 133 | MTOUCHUSB_GET_TOUCHED(mtouch->data)); |
141 | input_report_abs(&mtouch->input, ABS_X, MTOUCHUSB_GET_XC(mtouch->data)); | 134 | input_report_abs(mtouch->input, ABS_X, MTOUCHUSB_GET_XC(mtouch->data)); |
142 | input_report_abs(&mtouch->input, ABS_Y, | 135 | input_report_abs(mtouch->input, ABS_Y, |
143 | (raw_coordinates ? MTOUCHUSB_MAX_RAW_YC : MTOUCHUSB_MAX_CALIB_YC) | 136 | (raw_coordinates ? MTOUCHUSB_MAX_RAW_YC : MTOUCHUSB_MAX_CALIB_YC) |
144 | - MTOUCHUSB_GET_YC(mtouch->data)); | 137 | - MTOUCHUSB_GET_YC(mtouch->data)); |
145 | input_sync(&mtouch->input); | 138 | input_sync(mtouch->input); |
146 | 139 | ||
147 | exit: | 140 | exit: |
148 | retval = usb_submit_urb(urb, GFP_ATOMIC); | 141 | retval = usb_submit_urb(urb, GFP_ATOMIC); |
@@ -195,10 +188,10 @@ static void mtouchusb_free_buffers(struct usb_device *udev, struct mtouch_usb *m | |||
195 | static int mtouchusb_probe(struct usb_interface *intf, const struct usb_device_id *id) | 188 | static int mtouchusb_probe(struct usb_interface *intf, const struct usb_device_id *id) |
196 | { | 189 | { |
197 | struct mtouch_usb *mtouch; | 190 | struct mtouch_usb *mtouch; |
191 | struct input_dev *input_dev; | ||
198 | struct usb_host_interface *interface; | 192 | struct usb_host_interface *interface; |
199 | struct usb_endpoint_descriptor *endpoint; | 193 | struct usb_endpoint_descriptor *endpoint; |
200 | struct usb_device *udev = interface_to_usbdev(intf); | 194 | struct usb_device *udev = interface_to_usbdev(intf); |
201 | char path[64]; | ||
202 | int nRet; | 195 | int nRet; |
203 | 196 | ||
204 | dbg("%s - called", __FUNCTION__); | 197 | dbg("%s - called", __FUNCTION__); |
@@ -209,57 +202,55 @@ static int mtouchusb_probe(struct usb_interface *intf, const struct usb_device_i | |||
209 | dbg("%s - setting endpoint", __FUNCTION__); | 202 | dbg("%s - setting endpoint", __FUNCTION__); |
210 | endpoint = &interface->endpoint[0].desc; | 203 | endpoint = &interface->endpoint[0].desc; |
211 | 204 | ||
212 | if (!(mtouch = kmalloc(sizeof(struct mtouch_usb), GFP_KERNEL))) { | 205 | mtouch = kzalloc(sizeof(struct mtouch_usb), GFP_KERNEL); |
206 | input_dev = input_allocate_device(); | ||
207 | if (!mtouch || !input_dev) { | ||
213 | err("%s - Out of memory.", __FUNCTION__); | 208 | err("%s - Out of memory.", __FUNCTION__); |
214 | return -ENOMEM; | 209 | goto fail1; |
215 | } | 210 | } |
216 | 211 | ||
217 | memset(mtouch, 0, sizeof(struct mtouch_usb)); | ||
218 | mtouch->udev = udev; | ||
219 | |||
220 | dbg("%s - allocating buffers", __FUNCTION__); | 212 | dbg("%s - allocating buffers", __FUNCTION__); |
221 | if (mtouchusb_alloc_buffers(udev, mtouch)) { | 213 | if (mtouchusb_alloc_buffers(udev, mtouch)) |
222 | mtouchusb_free_buffers(udev, mtouch); | 214 | goto fail2; |
223 | kfree(mtouch); | ||
224 | return -ENOMEM; | ||
225 | } | ||
226 | 215 | ||
227 | mtouch->input.private = mtouch; | 216 | mtouch->udev = udev; |
228 | mtouch->input.open = mtouchusb_open; | 217 | mtouch->input = input_dev; |
229 | mtouch->input.close = mtouchusb_close; | ||
230 | |||
231 | usb_make_path(udev, path, 64); | ||
232 | sprintf(mtouch->phys, "%s/input0", path); | ||
233 | |||
234 | mtouch->input.name = mtouch->name; | ||
235 | mtouch->input.phys = mtouch->phys; | ||
236 | usb_to_input_id(udev, &mtouch->input.id); | ||
237 | mtouch->input.dev = &intf->dev; | ||
238 | |||
239 | mtouch->input.evbit[0] = BIT(EV_KEY) | BIT(EV_ABS); | ||
240 | mtouch->input.absbit[0] = BIT(ABS_X) | BIT(ABS_Y); | ||
241 | mtouch->input.keybit[LONG(BTN_TOUCH)] = BIT(BTN_TOUCH); | ||
242 | |||
243 | /* Used to Scale Compensated Data and Flip Y */ | ||
244 | mtouch->input.absmin[ABS_X] = MTOUCHUSB_MIN_XC; | ||
245 | mtouch->input.absmax[ABS_X] = raw_coordinates ? | ||
246 | MTOUCHUSB_MAX_RAW_XC : MTOUCHUSB_MAX_CALIB_XC; | ||
247 | mtouch->input.absfuzz[ABS_X] = MTOUCHUSB_XC_FUZZ; | ||
248 | mtouch->input.absflat[ABS_X] = MTOUCHUSB_XC_FLAT; | ||
249 | mtouch->input.absmin[ABS_Y] = MTOUCHUSB_MIN_YC; | ||
250 | mtouch->input.absmax[ABS_Y] = raw_coordinates ? | ||
251 | MTOUCHUSB_MAX_RAW_YC : MTOUCHUSB_MAX_CALIB_YC; | ||
252 | mtouch->input.absfuzz[ABS_Y] = MTOUCHUSB_YC_FUZZ; | ||
253 | mtouch->input.absflat[ABS_Y] = MTOUCHUSB_YC_FLAT; | ||
254 | 218 | ||
255 | if (udev->manufacturer) | 219 | if (udev->manufacturer) |
256 | strcat(mtouch->name, udev->manufacturer); | 220 | strlcpy(mtouch->name, udev->manufacturer, sizeof(mtouch->name)); |
257 | if (udev->product) | 221 | |
258 | sprintf(mtouch->name, "%s %s", mtouch->name, udev->product); | 222 | if (udev->product) { |
223 | if (udev->manufacturer) | ||
224 | strlcat(mtouch->name, " ", sizeof(mtouch->name)); | ||
225 | strlcat(mtouch->name, udev->product, sizeof(mtouch->name)); | ||
226 | } | ||
259 | 227 | ||
260 | if (!strlen(mtouch->name)) | 228 | if (!strlen(mtouch->name)) |
261 | sprintf(mtouch->name, "USB Touchscreen %04x:%04x", | 229 | snprintf(mtouch->name, sizeof(mtouch->name), |
262 | mtouch->input.id.vendor, mtouch->input.id.product); | 230 | "USB Touchscreen %04x:%04x", |
231 | le16_to_cpu(udev->descriptor.idVendor), | ||
232 | le16_to_cpu(udev->descriptor.idProduct)); | ||
233 | |||
234 | usb_make_path(udev, mtouch->phys, sizeof(mtouch->phys)); | ||
235 | strlcpy(mtouch->phys, "/input0", sizeof(mtouch->phys)); | ||
236 | |||
237 | input_dev->name = mtouch->name; | ||
238 | input_dev->phys = mtouch->phys; | ||
239 | usb_to_input_id(udev, &input_dev->id); | ||
240 | input_dev->cdev.dev = &intf->dev; | ||
241 | input_dev->private = mtouch; | ||
242 | |||
243 | input_dev->open = mtouchusb_open; | ||
244 | input_dev->close = mtouchusb_close; | ||
245 | |||
246 | input_dev->evbit[0] = BIT(EV_KEY) | BIT(EV_ABS); | ||
247 | input_dev->keybit[LONG(BTN_TOUCH)] = BIT(BTN_TOUCH); | ||
248 | input_set_abs_params(input_dev, ABS_X, MTOUCHUSB_MIN_XC, | ||
249 | raw_coordinates ? MTOUCHUSB_MAX_RAW_XC : MTOUCHUSB_MAX_CALIB_XC, | ||
250 | MTOUCHUSB_XC_FUZZ, MTOUCHUSB_XC_FLAT); | ||
251 | input_set_abs_params(input_dev, ABS_Y, MTOUCHUSB_MIN_YC, | ||
252 | raw_coordinates ? MTOUCHUSB_MAX_RAW_YC : MTOUCHUSB_MAX_CALIB_YC, | ||
253 | MTOUCHUSB_YC_FUZZ, MTOUCHUSB_YC_FLAT); | ||
263 | 254 | ||
264 | nRet = usb_control_msg(mtouch->udev, usb_rcvctrlpipe(udev, 0), | 255 | nRet = usb_control_msg(mtouch->udev, usb_rcvctrlpipe(udev, 0), |
265 | MTOUCHUSB_RESET, | 256 | MTOUCHUSB_RESET, |
@@ -272,9 +263,7 @@ static int mtouchusb_probe(struct usb_interface *intf, const struct usb_device_i | |||
272 | mtouch->irq = usb_alloc_urb(0, GFP_KERNEL); | 263 | mtouch->irq = usb_alloc_urb(0, GFP_KERNEL); |
273 | if (!mtouch->irq) { | 264 | if (!mtouch->irq) { |
274 | dbg("%s - usb_alloc_urb failed: mtouch->irq", __FUNCTION__); | 265 | dbg("%s - usb_alloc_urb failed: mtouch->irq", __FUNCTION__); |
275 | mtouchusb_free_buffers(udev, mtouch); | 266 | goto fail2; |
276 | kfree(mtouch); | ||
277 | return -ENOMEM; | ||
278 | } | 267 | } |
279 | 268 | ||
280 | dbg("%s - usb_fill_int_urb", __FUNCTION__); | 269 | dbg("%s - usb_fill_int_urb", __FUNCTION__); |
@@ -284,7 +273,7 @@ static int mtouchusb_probe(struct usb_interface *intf, const struct usb_device_i | |||
284 | mtouchusb_irq, mtouch, endpoint->bInterval); | 273 | mtouchusb_irq, mtouch, endpoint->bInterval); |
285 | 274 | ||
286 | dbg("%s - input_register_device", __FUNCTION__); | 275 | dbg("%s - input_register_device", __FUNCTION__); |
287 | input_register_device(&mtouch->input); | 276 | input_register_device(mtouch->input); |
288 | 277 | ||
289 | nRet = usb_control_msg(mtouch->udev, usb_rcvctrlpipe(udev, 0), | 278 | nRet = usb_control_msg(mtouch->udev, usb_rcvctrlpipe(udev, 0), |
290 | MTOUCHUSB_ASYNC_REPORT, | 279 | MTOUCHUSB_ASYNC_REPORT, |
@@ -293,10 +282,13 @@ static int mtouchusb_probe(struct usb_interface *intf, const struct usb_device_i | |||
293 | dbg("%s - usb_control_msg - MTOUCHUSB_ASYNC_REPORT - bytes|err: %d", | 282 | dbg("%s - usb_control_msg - MTOUCHUSB_ASYNC_REPORT - bytes|err: %d", |
294 | __FUNCTION__, nRet); | 283 | __FUNCTION__, nRet); |
295 | 284 | ||
296 | printk(KERN_INFO "input: %s on %s\n", mtouch->name, path); | ||
297 | usb_set_intfdata(intf, mtouch); | 285 | usb_set_intfdata(intf, mtouch); |
298 | |||
299 | return 0; | 286 | return 0; |
287 | |||
288 | fail2: mtouchusb_free_buffers(udev, mtouch); | ||
289 | fail1: input_free_device(input_dev); | ||
290 | kfree(mtouch); | ||
291 | return -ENOMEM; | ||
300 | } | 292 | } |
301 | 293 | ||
302 | static void mtouchusb_disconnect(struct usb_interface *intf) | 294 | static void mtouchusb_disconnect(struct usb_interface *intf) |
@@ -308,7 +300,7 @@ static void mtouchusb_disconnect(struct usb_interface *intf) | |||
308 | if (mtouch) { | 300 | if (mtouch) { |
309 | dbg("%s - mtouch is initialized, cleaning up", __FUNCTION__); | 301 | dbg("%s - mtouch is initialized, cleaning up", __FUNCTION__); |
310 | usb_kill_urb(mtouch->irq); | 302 | usb_kill_urb(mtouch->irq); |
311 | input_unregister_device(&mtouch->input); | 303 | input_unregister_device(mtouch->input); |
312 | usb_free_urb(mtouch->irq); | 304 | usb_free_urb(mtouch->irq); |
313 | mtouchusb_free_buffers(interface_to_usbdev(intf), mtouch); | 305 | mtouchusb_free_buffers(interface_to_usbdev(intf), mtouch); |
314 | kfree(mtouch); | 306 | kfree(mtouch); |
diff --git a/drivers/usb/input/pid.c b/drivers/usb/input/pid.c index acc71ec560e9..19e015d171aa 100644 --- a/drivers/usb/input/pid.c +++ b/drivers/usb/input/pid.c | |||
@@ -37,8 +37,6 @@ | |||
37 | #include "hid.h" | 37 | #include "hid.h" |
38 | #include "pid.h" | 38 | #include "pid.h" |
39 | 39 | ||
40 | #define DEBUG | ||
41 | |||
42 | #define CHECK_OWNERSHIP(i, hid_pid) \ | 40 | #define CHECK_OWNERSHIP(i, hid_pid) \ |
43 | ((i) < FF_EFFECTS_MAX && i >= 0 && \ | 41 | ((i) < FF_EFFECTS_MAX && i >= 0 && \ |
44 | test_bit(FF_PID_FLAGS_USED, &hid_pid->effects[(i)].flags) && \ | 42 | test_bit(FF_PID_FLAGS_USED, &hid_pid->effects[(i)].flags) && \ |
@@ -198,7 +196,7 @@ static int hid_pid_upload_effect(struct input_dev *dev, | |||
198 | } | 196 | } |
199 | 197 | ||
200 | effect->id = id; | 198 | effect->id = id; |
201 | dev_dbg(&pid_private->hid->dev->dev, "effect ID is %d\n.", id); | 199 | dev_dbg(&pid_private->hid->dev->dev, "effect ID is %d.\n", id); |
202 | pid_private->effects[id].owner = current->pid; | 200 | pid_private->effects[id].owner = current->pid; |
203 | pid_private->effects[id].flags = (1 << FF_PID_FLAGS_USED); | 201 | pid_private->effects[id].flags = (1 << FF_PID_FLAGS_USED); |
204 | spin_unlock_irqrestore(&pid_private->lock, flags); | 202 | spin_unlock_irqrestore(&pid_private->lock, flags); |
@@ -262,6 +260,7 @@ int hid_pid_init(struct hid_device *hid) | |||
262 | { | 260 | { |
263 | struct hid_ff_pid *private; | 261 | struct hid_ff_pid *private; |
264 | struct hid_input *hidinput = list_entry(&hid->inputs, struct hid_input, list); | 262 | struct hid_input *hidinput = list_entry(&hid->inputs, struct hid_input, list); |
263 | struct input_dev *input_dev = hidinput->input; | ||
265 | 264 | ||
266 | private = hid->ff_private = kzalloc(sizeof(struct hid_ff_pid), GFP_KERNEL); | 265 | private = hid->ff_private = kzalloc(sizeof(struct hid_ff_pid), GFP_KERNEL); |
267 | if (!private) | 266 | if (!private) |
@@ -281,11 +280,12 @@ int hid_pid_init(struct hid_device *hid) | |||
281 | usb_fill_control_urb(private->urbffout, hid->dev, 0, | 280 | usb_fill_control_urb(private->urbffout, hid->dev, 0, |
282 | (void *)&private->ffcr, private->ctrl_buffer, 8, | 281 | (void *)&private->ffcr, private->ctrl_buffer, 8, |
283 | hid_pid_ctrl_out, hid); | 282 | hid_pid_ctrl_out, hid); |
284 | hidinput->input.upload_effect = hid_pid_upload_effect; | 283 | |
285 | hidinput->input.flush = hid_pid_flush; | 284 | input_dev->upload_effect = hid_pid_upload_effect; |
286 | hidinput->input.ff_effects_max = 8; // A random default | 285 | input_dev->flush = hid_pid_flush; |
287 | set_bit(EV_FF, hidinput->input.evbit); | 286 | input_dev->ff_effects_max = 8; // A random default |
288 | set_bit(EV_FF_STATUS, hidinput->input.evbit); | 287 | set_bit(EV_FF, input_dev->evbit); |
288 | set_bit(EV_FF_STATUS, input_dev->evbit); | ||
289 | 289 | ||
290 | spin_lock_init(&private->lock); | 290 | spin_lock_init(&private->lock); |
291 | 291 | ||
diff --git a/drivers/usb/input/powermate.c b/drivers/usb/input/powermate.c index ad4afe7e5897..b7476233ef5d 100644 --- a/drivers/usb/input/powermate.c +++ b/drivers/usb/input/powermate.c | |||
@@ -68,7 +68,7 @@ struct powermate_device { | |||
68 | struct usb_ctrlrequest *configcr; | 68 | struct usb_ctrlrequest *configcr; |
69 | dma_addr_t configcr_dma; | 69 | dma_addr_t configcr_dma; |
70 | struct usb_device *udev; | 70 | struct usb_device *udev; |
71 | struct input_dev input; | 71 | struct input_dev *input; |
72 | spinlock_t lock; | 72 | spinlock_t lock; |
73 | int static_brightness; | 73 | int static_brightness; |
74 | int pulse_speed; | 74 | int pulse_speed; |
@@ -106,10 +106,10 @@ static void powermate_irq(struct urb *urb, struct pt_regs *regs) | |||
106 | } | 106 | } |
107 | 107 | ||
108 | /* handle updates to device state */ | 108 | /* handle updates to device state */ |
109 | input_regs(&pm->input, regs); | 109 | input_regs(pm->input, regs); |
110 | input_report_key(&pm->input, BTN_0, pm->data[0] & 0x01); | 110 | input_report_key(pm->input, BTN_0, pm->data[0] & 0x01); |
111 | input_report_rel(&pm->input, REL_DIAL, pm->data[1]); | 111 | input_report_rel(pm->input, REL_DIAL, pm->data[1]); |
112 | input_sync(&pm->input); | 112 | input_sync(pm->input); |
113 | 113 | ||
114 | exit: | 114 | exit: |
115 | retval = usb_submit_urb (urb, GFP_ATOMIC); | 115 | retval = usb_submit_urb (urb, GFP_ATOMIC); |
@@ -153,10 +153,10 @@ static void powermate_sync_state(struct powermate_device *pm) | |||
153 | 153 | ||
154 | Only values of 'arg' quite close to 255 are particularly useful/spectacular. | 154 | Only values of 'arg' quite close to 255 are particularly useful/spectacular. |
155 | */ | 155 | */ |
156 | if (pm->pulse_speed < 255){ | 156 | if (pm->pulse_speed < 255) { |
157 | op = 0; // divide | 157 | op = 0; // divide |
158 | arg = 255 - pm->pulse_speed; | 158 | arg = 255 - pm->pulse_speed; |
159 | } else if (pm->pulse_speed > 255){ | 159 | } else if (pm->pulse_speed > 255) { |
160 | op = 2; // multiply | 160 | op = 2; // multiply |
161 | arg = pm->pulse_speed - 255; | 161 | arg = pm->pulse_speed - 255; |
162 | } else { | 162 | } else { |
@@ -166,11 +166,11 @@ static void powermate_sync_state(struct powermate_device *pm) | |||
166 | pm->configcr->wValue = cpu_to_le16( (pm->pulse_table << 8) | SET_PULSE_MODE ); | 166 | pm->configcr->wValue = cpu_to_le16( (pm->pulse_table << 8) | SET_PULSE_MODE ); |
167 | pm->configcr->wIndex = cpu_to_le16( (arg << 8) | op ); | 167 | pm->configcr->wIndex = cpu_to_le16( (arg << 8) | op ); |
168 | pm->requires_update &= ~UPDATE_PULSE_MODE; | 168 | pm->requires_update &= ~UPDATE_PULSE_MODE; |
169 | }else if (pm->requires_update & UPDATE_STATIC_BRIGHTNESS){ | 169 | } else if (pm->requires_update & UPDATE_STATIC_BRIGHTNESS) { |
170 | pm->configcr->wValue = cpu_to_le16( SET_STATIC_BRIGHTNESS ); | 170 | pm->configcr->wValue = cpu_to_le16( SET_STATIC_BRIGHTNESS ); |
171 | pm->configcr->wIndex = cpu_to_le16( pm->static_brightness ); | 171 | pm->configcr->wIndex = cpu_to_le16( pm->static_brightness ); |
172 | pm->requires_update &= ~UPDATE_STATIC_BRIGHTNESS; | 172 | pm->requires_update &= ~UPDATE_STATIC_BRIGHTNESS; |
173 | }else{ | 173 | } else { |
174 | printk(KERN_ERR "powermate: unknown update required"); | 174 | printk(KERN_ERR "powermate: unknown update required"); |
175 | pm->requires_update = 0; /* fudge the bug */ | 175 | pm->requires_update = 0; /* fudge the bug */ |
176 | return; | 176 | return; |
@@ -228,19 +228,19 @@ static void powermate_pulse_led(struct powermate_device *pm, int static_brightne | |||
228 | spin_lock_irqsave(&pm->lock, flags); | 228 | spin_lock_irqsave(&pm->lock, flags); |
229 | 229 | ||
230 | /* mark state updates which are required */ | 230 | /* mark state updates which are required */ |
231 | if (static_brightness != pm->static_brightness){ | 231 | if (static_brightness != pm->static_brightness) { |
232 | pm->static_brightness = static_brightness; | 232 | pm->static_brightness = static_brightness; |
233 | pm->requires_update |= UPDATE_STATIC_BRIGHTNESS; | 233 | pm->requires_update |= UPDATE_STATIC_BRIGHTNESS; |
234 | } | 234 | } |
235 | if (pulse_asleep != pm->pulse_asleep){ | 235 | if (pulse_asleep != pm->pulse_asleep) { |
236 | pm->pulse_asleep = pulse_asleep; | 236 | pm->pulse_asleep = pulse_asleep; |
237 | pm->requires_update |= (UPDATE_PULSE_ASLEEP | UPDATE_STATIC_BRIGHTNESS); | 237 | pm->requires_update |= (UPDATE_PULSE_ASLEEP | UPDATE_STATIC_BRIGHTNESS); |
238 | } | 238 | } |
239 | if (pulse_awake != pm->pulse_awake){ | 239 | if (pulse_awake != pm->pulse_awake) { |
240 | pm->pulse_awake = pulse_awake; | 240 | pm->pulse_awake = pulse_awake; |
241 | pm->requires_update |= (UPDATE_PULSE_AWAKE | UPDATE_STATIC_BRIGHTNESS); | 241 | pm->requires_update |= (UPDATE_PULSE_AWAKE | UPDATE_STATIC_BRIGHTNESS); |
242 | } | 242 | } |
243 | if (pulse_speed != pm->pulse_speed || pulse_table != pm->pulse_table){ | 243 | if (pulse_speed != pm->pulse_speed || pulse_table != pm->pulse_table) { |
244 | pm->pulse_speed = pulse_speed; | 244 | pm->pulse_speed = pulse_speed; |
245 | pm->pulse_table = pulse_table; | 245 | pm->pulse_table = pulse_table; |
246 | pm->requires_update |= UPDATE_PULSE_MODE; | 246 | pm->requires_update |= UPDATE_PULSE_MODE; |
@@ -283,6 +283,7 @@ static int powermate_alloc_buffers(struct usb_device *udev, struct powermate_dev | |||
283 | SLAB_ATOMIC, &pm->data_dma); | 283 | SLAB_ATOMIC, &pm->data_dma); |
284 | if (!pm->data) | 284 | if (!pm->data) |
285 | return -1; | 285 | return -1; |
286 | |||
286 | pm->configcr = usb_buffer_alloc(udev, sizeof(*(pm->configcr)), | 287 | pm->configcr = usb_buffer_alloc(udev, sizeof(*(pm->configcr)), |
287 | SLAB_ATOMIC, &pm->configcr_dma); | 288 | SLAB_ATOMIC, &pm->configcr_dma); |
288 | if (!pm->configcr) | 289 | if (!pm->configcr) |
@@ -308,8 +309,9 @@ static int powermate_probe(struct usb_interface *intf, const struct usb_device_i | |||
308 | struct usb_host_interface *interface; | 309 | struct usb_host_interface *interface; |
309 | struct usb_endpoint_descriptor *endpoint; | 310 | struct usb_endpoint_descriptor *endpoint; |
310 | struct powermate_device *pm; | 311 | struct powermate_device *pm; |
312 | struct input_dev *input_dev; | ||
311 | int pipe, maxp; | 313 | int pipe, maxp; |
312 | char path[64]; | 314 | int err = -ENOMEM; |
313 | 315 | ||
314 | interface = intf->cur_altsetting; | 316 | interface = intf->cur_altsetting; |
315 | endpoint = &interface->endpoint[0].desc; | 317 | endpoint = &interface->endpoint[0].desc; |
@@ -323,42 +325,61 @@ static int powermate_probe(struct usb_interface *intf, const struct usb_device_i | |||
323 | 0, interface->desc.bInterfaceNumber, NULL, 0, | 325 | 0, interface->desc.bInterfaceNumber, NULL, 0, |
324 | USB_CTRL_SET_TIMEOUT); | 326 | USB_CTRL_SET_TIMEOUT); |
325 | 327 | ||
326 | if (!(pm = kmalloc(sizeof(struct powermate_device), GFP_KERNEL))) | 328 | pm = kzalloc(sizeof(struct powermate_device), GFP_KERNEL); |
327 | return -ENOMEM; | 329 | input_dev = input_allocate_device(); |
328 | 330 | if (!pm || !input_dev) | |
329 | memset(pm, 0, sizeof(struct powermate_device)); | 331 | goto fail1; |
330 | pm->udev = udev; | ||
331 | 332 | ||
332 | if (powermate_alloc_buffers(udev, pm)) { | 333 | if (powermate_alloc_buffers(udev, pm)) |
333 | powermate_free_buffers(udev, pm); | 334 | goto fail2; |
334 | kfree(pm); | ||
335 | return -ENOMEM; | ||
336 | } | ||
337 | 335 | ||
338 | pm->irq = usb_alloc_urb(0, GFP_KERNEL); | 336 | pm->irq = usb_alloc_urb(0, GFP_KERNEL); |
339 | if (!pm->irq) { | 337 | if (!pm->irq) |
340 | powermate_free_buffers(udev, pm); | 338 | goto fail2; |
341 | kfree(pm); | ||
342 | return -ENOMEM; | ||
343 | } | ||
344 | 339 | ||
345 | pm->config = usb_alloc_urb(0, GFP_KERNEL); | 340 | pm->config = usb_alloc_urb(0, GFP_KERNEL); |
346 | if (!pm->config) { | 341 | if (!pm->config) |
347 | usb_free_urb(pm->irq); | 342 | goto fail3; |
348 | powermate_free_buffers(udev, pm); | 343 | |
349 | kfree(pm); | 344 | pm->udev = udev; |
350 | return -ENOMEM; | 345 | pm->input = input_dev; |
351 | } | 346 | |
347 | usb_make_path(udev, pm->phys, sizeof(pm->phys)); | ||
348 | strlcpy(pm->phys, "/input0", sizeof(pm->phys)); | ||
352 | 349 | ||
353 | spin_lock_init(&pm->lock); | 350 | spin_lock_init(&pm->lock); |
354 | init_input_dev(&pm->input); | 351 | |
352 | switch (le16_to_cpu(udev->descriptor.idProduct)) { | ||
353 | case POWERMATE_PRODUCT_NEW: | ||
354 | input_dev->name = pm_name_powermate; | ||
355 | break; | ||
356 | case POWERMATE_PRODUCT_OLD: | ||
357 | input_dev->name = pm_name_soundknob; | ||
358 | break; | ||
359 | default: | ||
360 | input_dev->name = pm_name_soundknob; | ||
361 | printk(KERN_WARNING "powermate: unknown product id %04x\n", | ||
362 | le16_to_cpu(udev->descriptor.idProduct)); | ||
363 | } | ||
364 | |||
365 | input_dev->phys = pm->phys; | ||
366 | usb_to_input_id(udev, &input_dev->id); | ||
367 | input_dev->cdev.dev = &intf->dev; | ||
368 | input_dev->private = pm; | ||
369 | |||
370 | input_dev->event = powermate_input_event; | ||
371 | |||
372 | input_dev->evbit[0] = BIT(EV_KEY) | BIT(EV_REL) | BIT(EV_MSC); | ||
373 | input_dev->keybit[LONG(BTN_0)] = BIT(BTN_0); | ||
374 | input_dev->relbit[LONG(REL_DIAL)] = BIT(REL_DIAL); | ||
375 | input_dev->mscbit[LONG(MSC_PULSELED)] = BIT(MSC_PULSELED); | ||
355 | 376 | ||
356 | /* get a handle to the interrupt data pipe */ | 377 | /* get a handle to the interrupt data pipe */ |
357 | pipe = usb_rcvintpipe(udev, endpoint->bEndpointAddress); | 378 | pipe = usb_rcvintpipe(udev, endpoint->bEndpointAddress); |
358 | maxp = usb_maxpacket(udev, pipe, usb_pipeout(pipe)); | 379 | maxp = usb_maxpacket(udev, pipe, usb_pipeout(pipe)); |
359 | 380 | ||
360 | if(maxp < POWERMATE_PAYLOAD_SIZE_MIN || maxp > POWERMATE_PAYLOAD_SIZE_MAX){ | 381 | if (maxp < POWERMATE_PAYLOAD_SIZE_MIN || maxp > POWERMATE_PAYLOAD_SIZE_MAX) { |
361 | printk("powermate: Expected payload of %d--%d bytes, found %d bytes!\n", | 382 | printk(KERN_WARNING "powermate: Expected payload of %d--%d bytes, found %d bytes!\n", |
362 | POWERMATE_PAYLOAD_SIZE_MIN, POWERMATE_PAYLOAD_SIZE_MAX, maxp); | 383 | POWERMATE_PAYLOAD_SIZE_MIN, POWERMATE_PAYLOAD_SIZE_MAX, maxp); |
363 | maxp = POWERMATE_PAYLOAD_SIZE_MAX; | 384 | maxp = POWERMATE_PAYLOAD_SIZE_MAX; |
364 | } | 385 | } |
@@ -371,35 +392,11 @@ static int powermate_probe(struct usb_interface *intf, const struct usb_device_i | |||
371 | 392 | ||
372 | /* register our interrupt URB with the USB system */ | 393 | /* register our interrupt URB with the USB system */ |
373 | if (usb_submit_urb(pm->irq, GFP_KERNEL)) { | 394 | if (usb_submit_urb(pm->irq, GFP_KERNEL)) { |
374 | powermate_free_buffers(udev, pm); | 395 | err = -EIO; |
375 | kfree(pm); | 396 | goto fail4; |
376 | return -EIO; /* failure */ | ||
377 | } | 397 | } |
378 | 398 | ||
379 | switch (le16_to_cpu(udev->descriptor.idProduct)) { | 399 | input_register_device(pm->input); |
380 | case POWERMATE_PRODUCT_NEW: pm->input.name = pm_name_powermate; break; | ||
381 | case POWERMATE_PRODUCT_OLD: pm->input.name = pm_name_soundknob; break; | ||
382 | default: | ||
383 | pm->input.name = pm_name_soundknob; | ||
384 | printk(KERN_WARNING "powermate: unknown product id %04x\n", | ||
385 | le16_to_cpu(udev->descriptor.idProduct)); | ||
386 | } | ||
387 | |||
388 | pm->input.private = pm; | ||
389 | pm->input.evbit[0] = BIT(EV_KEY) | BIT(EV_REL) | BIT(EV_MSC); | ||
390 | pm->input.keybit[LONG(BTN_0)] = BIT(BTN_0); | ||
391 | pm->input.relbit[LONG(REL_DIAL)] = BIT(REL_DIAL); | ||
392 | pm->input.mscbit[LONG(MSC_PULSELED)] = BIT(MSC_PULSELED); | ||
393 | usb_to_input_id(udev, &pm->input.id); | ||
394 | pm->input.event = powermate_input_event; | ||
395 | pm->input.dev = &intf->dev; | ||
396 | pm->input.phys = pm->phys; | ||
397 | |||
398 | input_register_device(&pm->input); | ||
399 | |||
400 | usb_make_path(udev, path, 64); | ||
401 | snprintf(pm->phys, 64, "%s/input0", path); | ||
402 | printk(KERN_INFO "input: %s on %s\n", pm->input.name, pm->input.phys); | ||
403 | 400 | ||
404 | /* force an update of everything */ | 401 | /* force an update of everything */ |
405 | pm->requires_update = UPDATE_PULSE_ASLEEP | UPDATE_PULSE_AWAKE | UPDATE_PULSE_MODE | UPDATE_STATIC_BRIGHTNESS; | 402 | pm->requires_update = UPDATE_PULSE_ASLEEP | UPDATE_PULSE_AWAKE | UPDATE_PULSE_MODE | UPDATE_STATIC_BRIGHTNESS; |
@@ -407,6 +404,13 @@ static int powermate_probe(struct usb_interface *intf, const struct usb_device_i | |||
407 | 404 | ||
408 | usb_set_intfdata(intf, pm); | 405 | usb_set_intfdata(intf, pm); |
409 | return 0; | 406 | return 0; |
407 | |||
408 | fail4: usb_free_urb(pm->config); | ||
409 | fail3: usb_free_urb(pm->irq); | ||
410 | fail2: powermate_free_buffers(udev, pm); | ||
411 | fail1: input_free_device(input_dev); | ||
412 | kfree(pm); | ||
413 | return err; | ||
410 | } | 414 | } |
411 | 415 | ||
412 | /* Called when a USB device we've accepted ownership of is removed */ | 416 | /* Called when a USB device we've accepted ownership of is removed */ |
@@ -418,7 +422,7 @@ static void powermate_disconnect(struct usb_interface *intf) | |||
418 | if (pm) { | 422 | if (pm) { |
419 | pm->requires_update = 0; | 423 | pm->requires_update = 0; |
420 | usb_kill_urb(pm->irq); | 424 | usb_kill_urb(pm->irq); |
421 | input_unregister_device(&pm->input); | 425 | input_unregister_device(pm->input); |
422 | usb_free_urb(pm->irq); | 426 | usb_free_urb(pm->irq); |
423 | usb_free_urb(pm->config); | 427 | usb_free_urb(pm->config); |
424 | powermate_free_buffers(interface_to_usbdev(intf), pm); | 428 | powermate_free_buffers(interface_to_usbdev(intf), pm); |
diff --git a/drivers/usb/input/touchkitusb.c b/drivers/usb/input/touchkitusb.c index 4276c24a5080..7420c6b84284 100644 --- a/drivers/usb/input/touchkitusb.c +++ b/drivers/usb/input/touchkitusb.c | |||
@@ -30,10 +30,6 @@ | |||
30 | #include <linux/input.h> | 30 | #include <linux/input.h> |
31 | #include <linux/module.h> | 31 | #include <linux/module.h> |
32 | #include <linux/init.h> | 32 | #include <linux/init.h> |
33 | |||
34 | #if !defined(DEBUG) && defined(CONFIG_USB_DEBUG) | ||
35 | #define DEBUG | ||
36 | #endif | ||
37 | #include <linux/usb.h> | 33 | #include <linux/usb.h> |
38 | #include <linux/usb_input.h> | 34 | #include <linux/usb_input.h> |
39 | 35 | ||
@@ -68,14 +64,16 @@ struct touchkit_usb { | |||
68 | dma_addr_t data_dma; | 64 | dma_addr_t data_dma; |
69 | struct urb *irq; | 65 | struct urb *irq; |
70 | struct usb_device *udev; | 66 | struct usb_device *udev; |
71 | struct input_dev input; | 67 | struct input_dev *input; |
72 | char name[128]; | 68 | char name[128]; |
73 | char phys[64]; | 69 | char phys[64]; |
74 | }; | 70 | }; |
75 | 71 | ||
76 | static struct usb_device_id touchkit_devices[] = { | 72 | static struct usb_device_id touchkit_devices[] = { |
77 | {USB_DEVICE(0x3823, 0x0001)}, | 73 | {USB_DEVICE(0x3823, 0x0001)}, |
74 | {USB_DEVICE(0x0123, 0x0001)}, | ||
78 | {USB_DEVICE(0x0eef, 0x0001)}, | 75 | {USB_DEVICE(0x0eef, 0x0001)}, |
76 | {USB_DEVICE(0x0eef, 0x0002)}, | ||
79 | {} | 77 | {} |
80 | }; | 78 | }; |
81 | 79 | ||
@@ -115,12 +113,12 @@ static void touchkit_irq(struct urb *urb, struct pt_regs *regs) | |||
115 | y = TOUCHKIT_GET_Y(touchkit->data); | 113 | y = TOUCHKIT_GET_Y(touchkit->data); |
116 | } | 114 | } |
117 | 115 | ||
118 | input_regs(&touchkit->input, regs); | 116 | input_regs(touchkit->input, regs); |
119 | input_report_key(&touchkit->input, BTN_TOUCH, | 117 | input_report_key(touchkit->input, BTN_TOUCH, |
120 | TOUCHKIT_GET_TOUCHED(touchkit->data)); | 118 | TOUCHKIT_GET_TOUCHED(touchkit->data)); |
121 | input_report_abs(&touchkit->input, ABS_X, x); | 119 | input_report_abs(touchkit->input, ABS_X, x); |
122 | input_report_abs(&touchkit->input, ABS_Y, y); | 120 | input_report_abs(touchkit->input, ABS_Y, y); |
123 | input_sync(&touchkit->input); | 121 | input_sync(touchkit->input); |
124 | 122 | ||
125 | exit: | 123 | exit: |
126 | retval = usb_submit_urb(urb, GFP_ATOMIC); | 124 | retval = usb_submit_urb(urb, GFP_ATOMIC); |
@@ -171,87 +169,81 @@ static void touchkit_free_buffers(struct usb_device *udev, | |||
171 | static int touchkit_probe(struct usb_interface *intf, | 169 | static int touchkit_probe(struct usb_interface *intf, |
172 | const struct usb_device_id *id) | 170 | const struct usb_device_id *id) |
173 | { | 171 | { |
174 | int ret; | ||
175 | struct touchkit_usb *touchkit; | 172 | struct touchkit_usb *touchkit; |
173 | struct input_dev *input_dev; | ||
176 | struct usb_host_interface *interface; | 174 | struct usb_host_interface *interface; |
177 | struct usb_endpoint_descriptor *endpoint; | 175 | struct usb_endpoint_descriptor *endpoint; |
178 | struct usb_device *udev = interface_to_usbdev(intf); | 176 | struct usb_device *udev = interface_to_usbdev(intf); |
179 | char path[64]; | ||
180 | 177 | ||
181 | interface = intf->cur_altsetting; | 178 | interface = intf->cur_altsetting; |
182 | endpoint = &interface->endpoint[0].desc; | 179 | endpoint = &interface->endpoint[0].desc; |
183 | 180 | ||
184 | touchkit = kmalloc(sizeof(struct touchkit_usb), GFP_KERNEL); | 181 | touchkit = kzalloc(sizeof(struct touchkit_usb), GFP_KERNEL); |
185 | if (!touchkit) | 182 | input_dev = input_allocate_device(); |
186 | return -ENOMEM; | 183 | if (!touchkit || !input_dev) |
187 | |||
188 | memset(touchkit, 0, sizeof(struct touchkit_usb)); | ||
189 | touchkit->udev = udev; | ||
190 | |||
191 | if (touchkit_alloc_buffers(udev, touchkit)) { | ||
192 | ret = -ENOMEM; | ||
193 | goto out_free; | 184 | goto out_free; |
194 | } | ||
195 | |||
196 | touchkit->input.private = touchkit; | ||
197 | touchkit->input.open = touchkit_open; | ||
198 | touchkit->input.close = touchkit_close; | ||
199 | |||
200 | usb_make_path(udev, path, 64); | ||
201 | sprintf(touchkit->phys, "%s/input0", path); | ||
202 | |||
203 | touchkit->input.name = touchkit->name; | ||
204 | touchkit->input.phys = touchkit->phys; | ||
205 | usb_to_input_id(udev, &touchkit->input.id); | ||
206 | touchkit->input.dev = &intf->dev; | ||
207 | |||
208 | touchkit->input.evbit[0] = BIT(EV_KEY) | BIT(EV_ABS); | ||
209 | touchkit->input.absbit[0] = BIT(ABS_X) | BIT(ABS_Y); | ||
210 | touchkit->input.keybit[LONG(BTN_TOUCH)] = BIT(BTN_TOUCH); | ||
211 | |||
212 | /* Used to Scale Compensated Data */ | ||
213 | touchkit->input.absmin[ABS_X] = TOUCHKIT_MIN_XC; | ||
214 | touchkit->input.absmax[ABS_X] = TOUCHKIT_MAX_XC; | ||
215 | touchkit->input.absfuzz[ABS_X] = TOUCHKIT_XC_FUZZ; | ||
216 | touchkit->input.absflat[ABS_X] = TOUCHKIT_XC_FLAT; | ||
217 | touchkit->input.absmin[ABS_Y] = TOUCHKIT_MIN_YC; | ||
218 | touchkit->input.absmax[ABS_Y] = TOUCHKIT_MAX_YC; | ||
219 | touchkit->input.absfuzz[ABS_Y] = TOUCHKIT_YC_FUZZ; | ||
220 | touchkit->input.absflat[ABS_Y] = TOUCHKIT_YC_FLAT; | ||
221 | |||
222 | if (udev->manufacturer) | ||
223 | strcat(touchkit->name, udev->manufacturer); | ||
224 | if (udev->product) | ||
225 | sprintf(touchkit->name, "%s %s", touchkit->name, udev->product); | ||
226 | 185 | ||
227 | if (!strlen(touchkit->name)) | 186 | if (touchkit_alloc_buffers(udev, touchkit)) |
228 | sprintf(touchkit->name, "USB Touchscreen %04x:%04x", | 187 | goto out_free; |
229 | touchkit->input.id.vendor, touchkit->input.id.product); | ||
230 | 188 | ||
231 | touchkit->irq = usb_alloc_urb(0, GFP_KERNEL); | 189 | touchkit->irq = usb_alloc_urb(0, GFP_KERNEL); |
232 | if (!touchkit->irq) { | 190 | if (!touchkit->irq) { |
233 | dbg("%s - usb_alloc_urb failed: touchkit->irq", __FUNCTION__); | 191 | dbg("%s - usb_alloc_urb failed: touchkit->irq", __FUNCTION__); |
234 | ret = -ENOMEM; | ||
235 | goto out_free_buffers; | 192 | goto out_free_buffers; |
236 | } | 193 | } |
237 | 194 | ||
195 | touchkit->udev = udev; | ||
196 | touchkit->input = input_dev; | ||
197 | |||
198 | if (udev->manufacturer) | ||
199 | strlcpy(touchkit->name, udev->manufacturer, sizeof(touchkit->name)); | ||
200 | |||
201 | if (udev->product) { | ||
202 | if (udev->manufacturer) | ||
203 | strlcat(touchkit->name, " ", sizeof(touchkit->name)); | ||
204 | strlcat(touchkit->name, udev->product, sizeof(touchkit->name)); | ||
205 | } | ||
206 | |||
207 | if (!strlen(touchkit->name)) | ||
208 | snprintf(touchkit->name, sizeof(touchkit->name), | ||
209 | "USB Touchscreen %04x:%04x", | ||
210 | le16_to_cpu(udev->descriptor.idVendor), | ||
211 | le16_to_cpu(udev->descriptor.idProduct)); | ||
212 | |||
213 | usb_make_path(udev, touchkit->phys, sizeof(touchkit->phys)); | ||
214 | strlcpy(touchkit->phys, "/input0", sizeof(touchkit->phys)); | ||
215 | |||
216 | input_dev->name = touchkit->name; | ||
217 | input_dev->phys = touchkit->phys; | ||
218 | usb_to_input_id(udev, &input_dev->id); | ||
219 | input_dev->cdev.dev = &intf->dev; | ||
220 | input_dev->private = touchkit; | ||
221 | input_dev->open = touchkit_open; | ||
222 | input_dev->close = touchkit_close; | ||
223 | |||
224 | input_dev->evbit[0] = BIT(EV_KEY) | BIT(EV_ABS); | ||
225 | input_dev->keybit[LONG(BTN_TOUCH)] = BIT(BTN_TOUCH); | ||
226 | input_set_abs_params(input_dev, ABS_X, TOUCHKIT_MIN_XC, TOUCHKIT_MAX_XC, | ||
227 | TOUCHKIT_XC_FUZZ, TOUCHKIT_XC_FLAT); | ||
228 | input_set_abs_params(input_dev, ABS_Y, TOUCHKIT_MIN_YC, TOUCHKIT_MAX_YC, | ||
229 | TOUCHKIT_YC_FUZZ, TOUCHKIT_YC_FLAT); | ||
230 | |||
238 | usb_fill_int_urb(touchkit->irq, touchkit->udev, | 231 | usb_fill_int_urb(touchkit->irq, touchkit->udev, |
239 | usb_rcvintpipe(touchkit->udev, 0x81), | 232 | usb_rcvintpipe(touchkit->udev, 0x81), |
240 | touchkit->data, TOUCHKIT_REPORT_DATA_SIZE, | 233 | touchkit->data, TOUCHKIT_REPORT_DATA_SIZE, |
241 | touchkit_irq, touchkit, endpoint->bInterval); | 234 | touchkit_irq, touchkit, endpoint->bInterval); |
242 | 235 | ||
243 | input_register_device(&touchkit->input); | 236 | input_register_device(touchkit->input); |
244 | 237 | ||
245 | printk(KERN_INFO "input: %s on %s\n", touchkit->name, path); | ||
246 | usb_set_intfdata(intf, touchkit); | 238 | usb_set_intfdata(intf, touchkit); |
247 | |||
248 | return 0; | 239 | return 0; |
249 | 240 | ||
250 | out_free_buffers: | 241 | out_free_buffers: |
251 | touchkit_free_buffers(udev, touchkit); | 242 | touchkit_free_buffers(udev, touchkit); |
252 | out_free: | 243 | out_free: |
244 | input_free_device(input_dev); | ||
253 | kfree(touchkit); | 245 | kfree(touchkit); |
254 | return ret; | 246 | return -ENOMEM; |
255 | } | 247 | } |
256 | 248 | ||
257 | static void touchkit_disconnect(struct usb_interface *intf) | 249 | static void touchkit_disconnect(struct usb_interface *intf) |
@@ -265,8 +257,8 @@ static void touchkit_disconnect(struct usb_interface *intf) | |||
265 | 257 | ||
266 | dbg("%s - touchkit is initialized, cleaning up", __FUNCTION__); | 258 | dbg("%s - touchkit is initialized, cleaning up", __FUNCTION__); |
267 | usb_set_intfdata(intf, NULL); | 259 | usb_set_intfdata(intf, NULL); |
268 | input_unregister_device(&touchkit->input); | ||
269 | usb_kill_urb(touchkit->irq); | 260 | usb_kill_urb(touchkit->irq); |
261 | input_unregister_device(touchkit->input); | ||
270 | usb_free_urb(touchkit->irq); | 262 | usb_free_urb(touchkit->irq); |
271 | touchkit_free_buffers(interface_to_usbdev(intf), touchkit); | 263 | touchkit_free_buffers(interface_to_usbdev(intf), touchkit); |
272 | kfree(touchkit); | 264 | kfree(touchkit); |
diff --git a/drivers/usb/input/usbkbd.c b/drivers/usb/input/usbkbd.c index 28987f15eeee..226b6f90a907 100644 --- a/drivers/usb/input/usbkbd.c +++ b/drivers/usb/input/usbkbd.c | |||
@@ -66,7 +66,7 @@ static unsigned char usb_kbd_keycode[256] = { | |||
66 | }; | 66 | }; |
67 | 67 | ||
68 | struct usb_kbd { | 68 | struct usb_kbd { |
69 | struct input_dev dev; | 69 | struct input_dev *dev; |
70 | struct usb_device *usbdev; | 70 | struct usb_device *usbdev; |
71 | unsigned char old[8]; | 71 | unsigned char old[8]; |
72 | struct urb *irq, *led; | 72 | struct urb *irq, *led; |
@@ -99,29 +99,29 @@ static void usb_kbd_irq(struct urb *urb, struct pt_regs *regs) | |||
99 | goto resubmit; | 99 | goto resubmit; |
100 | } | 100 | } |
101 | 101 | ||
102 | input_regs(&kbd->dev, regs); | 102 | input_regs(kbd->dev, regs); |
103 | 103 | ||
104 | for (i = 0; i < 8; i++) | 104 | for (i = 0; i < 8; i++) |
105 | input_report_key(&kbd->dev, usb_kbd_keycode[i + 224], (kbd->new[0] >> i) & 1); | 105 | input_report_key(kbd->dev, usb_kbd_keycode[i + 224], (kbd->new[0] >> i) & 1); |
106 | 106 | ||
107 | for (i = 2; i < 8; i++) { | 107 | for (i = 2; i < 8; i++) { |
108 | 108 | ||
109 | if (kbd->old[i] > 3 && memscan(kbd->new + 2, kbd->old[i], 6) == kbd->new + 8) { | 109 | if (kbd->old[i] > 3 && memscan(kbd->new + 2, kbd->old[i], 6) == kbd->new + 8) { |
110 | if (usb_kbd_keycode[kbd->old[i]]) | 110 | if (usb_kbd_keycode[kbd->old[i]]) |
111 | input_report_key(&kbd->dev, usb_kbd_keycode[kbd->old[i]], 0); | 111 | input_report_key(kbd->dev, usb_kbd_keycode[kbd->old[i]], 0); |
112 | else | 112 | else |
113 | info("Unknown key (scancode %#x) released.", kbd->old[i]); | 113 | info("Unknown key (scancode %#x) released.", kbd->old[i]); |
114 | } | 114 | } |
115 | 115 | ||
116 | if (kbd->new[i] > 3 && memscan(kbd->old + 2, kbd->new[i], 6) == kbd->old + 8) { | 116 | if (kbd->new[i] > 3 && memscan(kbd->old + 2, kbd->new[i], 6) == kbd->old + 8) { |
117 | if (usb_kbd_keycode[kbd->new[i]]) | 117 | if (usb_kbd_keycode[kbd->new[i]]) |
118 | input_report_key(&kbd->dev, usb_kbd_keycode[kbd->new[i]], 1); | 118 | input_report_key(kbd->dev, usb_kbd_keycode[kbd->new[i]], 1); |
119 | else | 119 | else |
120 | info("Unknown key (scancode %#x) pressed.", kbd->new[i]); | 120 | info("Unknown key (scancode %#x) pressed.", kbd->new[i]); |
121 | } | 121 | } |
122 | } | 122 | } |
123 | 123 | ||
124 | input_sync(&kbd->dev); | 124 | input_sync(kbd->dev); |
125 | 125 | ||
126 | memcpy(kbd->old, kbd->new, 8); | 126 | memcpy(kbd->old, kbd->new, 8); |
127 | 127 | ||
@@ -227,12 +227,12 @@ static void usb_kbd_free_mem(struct usb_device *dev, struct usb_kbd *kbd) | |||
227 | static int usb_kbd_probe(struct usb_interface *iface, | 227 | static int usb_kbd_probe(struct usb_interface *iface, |
228 | const struct usb_device_id *id) | 228 | const struct usb_device_id *id) |
229 | { | 229 | { |
230 | struct usb_device * dev = interface_to_usbdev(iface); | 230 | struct usb_device *dev = interface_to_usbdev(iface); |
231 | struct usb_host_interface *interface; | 231 | struct usb_host_interface *interface; |
232 | struct usb_endpoint_descriptor *endpoint; | 232 | struct usb_endpoint_descriptor *endpoint; |
233 | struct usb_kbd *kbd; | 233 | struct usb_kbd *kbd; |
234 | struct input_dev *input_dev; | ||
234 | int i, pipe, maxp; | 235 | int i, pipe, maxp; |
235 | char path[64]; | ||
236 | 236 | ||
237 | interface = iface->cur_altsetting; | 237 | interface = iface->cur_altsetting; |
238 | 238 | ||
@@ -240,37 +240,59 @@ static int usb_kbd_probe(struct usb_interface *iface, | |||
240 | return -ENODEV; | 240 | return -ENODEV; |
241 | 241 | ||
242 | endpoint = &interface->endpoint[0].desc; | 242 | endpoint = &interface->endpoint[0].desc; |
243 | if (!(endpoint->bEndpointAddress & 0x80)) | 243 | if (!(endpoint->bEndpointAddress & USB_DIR_IN)) |
244 | return -ENODEV; | 244 | return -ENODEV; |
245 | if ((endpoint->bmAttributes & 3) != 3) | 245 | if ((endpoint->bmAttributes & USB_ENDPOINT_XFERTYPE_MASK) != USB_ENDPOINT_XFER_INT) |
246 | return -ENODEV; | 246 | return -ENODEV; |
247 | 247 | ||
248 | pipe = usb_rcvintpipe(dev, endpoint->bEndpointAddress); | 248 | pipe = usb_rcvintpipe(dev, endpoint->bEndpointAddress); |
249 | maxp = usb_maxpacket(dev, pipe, usb_pipeout(pipe)); | 249 | maxp = usb_maxpacket(dev, pipe, usb_pipeout(pipe)); |
250 | 250 | ||
251 | if (!(kbd = kmalloc(sizeof(struct usb_kbd), GFP_KERNEL))) | 251 | kbd = kzalloc(sizeof(struct usb_kbd), GFP_KERNEL); |
252 | return -ENOMEM; | 252 | input_dev = input_allocate_device(); |
253 | memset(kbd, 0, sizeof(struct usb_kbd)); | 253 | if (!kbd || !input_dev) |
254 | goto fail1; | ||
254 | 255 | ||
255 | if (usb_kbd_alloc_mem(dev, kbd)) { | 256 | if (usb_kbd_alloc_mem(dev, kbd)) |
256 | usb_kbd_free_mem(dev, kbd); | 257 | goto fail2; |
257 | kfree(kbd); | ||
258 | return -ENOMEM; | ||
259 | } | ||
260 | 258 | ||
261 | kbd->usbdev = dev; | 259 | kbd->usbdev = dev; |
260 | kbd->dev = input_dev; | ||
261 | |||
262 | if (dev->manufacturer) | ||
263 | strlcpy(kbd->name, dev->manufacturer, sizeof(kbd->name)); | ||
264 | |||
265 | if (dev->product) { | ||
266 | if (dev->manufacturer) | ||
267 | strlcat(kbd->name, " ", sizeof(kbd->name)); | ||
268 | strlcat(kbd->name, dev->product, sizeof(kbd->name)); | ||
269 | } | ||
270 | |||
271 | if (!strlen(kbd->name)) | ||
272 | snprintf(kbd->name, sizeof(kbd->name), | ||
273 | "USB HIDBP Keyboard %04x:%04x", | ||
274 | le16_to_cpu(dev->descriptor.idVendor), | ||
275 | le16_to_cpu(dev->descriptor.idProduct)); | ||
276 | |||
277 | usb_make_path(dev, kbd->phys, sizeof(kbd->phys)); | ||
278 | strlcpy(kbd->phys, "/input0", sizeof(kbd->phys)); | ||
262 | 279 | ||
263 | kbd->dev.evbit[0] = BIT(EV_KEY) | BIT(EV_LED) | BIT(EV_REP); | 280 | input_dev->name = kbd->name; |
264 | kbd->dev.ledbit[0] = BIT(LED_NUML) | BIT(LED_CAPSL) | BIT(LED_SCROLLL) | BIT(LED_COMPOSE) | BIT(LED_KANA); | 281 | input_dev->phys = kbd->phys; |
282 | usb_to_input_id(dev, &input_dev->id); | ||
283 | input_dev->cdev.dev = &iface->dev; | ||
284 | input_dev->private = kbd; | ||
285 | |||
286 | input_dev->evbit[0] = BIT(EV_KEY) | BIT(EV_LED) | BIT(EV_REP); | ||
287 | input_dev->ledbit[0] = BIT(LED_NUML) | BIT(LED_CAPSL) | BIT(LED_SCROLLL) | BIT(LED_COMPOSE) | BIT(LED_KANA); | ||
265 | 288 | ||
266 | for (i = 0; i < 255; i++) | 289 | for (i = 0; i < 255; i++) |
267 | set_bit(usb_kbd_keycode[i], kbd->dev.keybit); | 290 | set_bit(usb_kbd_keycode[i], input_dev->keybit); |
268 | clear_bit(0, kbd->dev.keybit); | 291 | clear_bit(0, input_dev->keybit); |
269 | 292 | ||
270 | kbd->dev.private = kbd; | 293 | input_dev->event = usb_kbd_event; |
271 | kbd->dev.event = usb_kbd_event; | 294 | input_dev->open = usb_kbd_open; |
272 | kbd->dev.open = usb_kbd_open; | 295 | input_dev->close = usb_kbd_close; |
273 | kbd->dev.close = usb_kbd_close; | ||
274 | 296 | ||
275 | usb_fill_int_urb(kbd->irq, dev, pipe, | 297 | usb_fill_int_urb(kbd->irq, dev, pipe, |
276 | kbd->new, (maxp > 8 ? 8 : maxp), | 298 | kbd->new, (maxp > 8 ? 8 : maxp), |
@@ -284,37 +306,22 @@ static int usb_kbd_probe(struct usb_interface *iface, | |||
284 | kbd->cr->wIndex = cpu_to_le16(interface->desc.bInterfaceNumber); | 306 | kbd->cr->wIndex = cpu_to_le16(interface->desc.bInterfaceNumber); |
285 | kbd->cr->wLength = cpu_to_le16(1); | 307 | kbd->cr->wLength = cpu_to_le16(1); |
286 | 308 | ||
287 | usb_make_path(dev, path, 64); | ||
288 | sprintf(kbd->phys, "%s/input0", path); | ||
289 | |||
290 | kbd->dev.name = kbd->name; | ||
291 | kbd->dev.phys = kbd->phys; | ||
292 | usb_to_input_id(dev, &kbd->dev.id); | ||
293 | kbd->dev.dev = &iface->dev; | ||
294 | |||
295 | if (dev->manufacturer) | ||
296 | strcat(kbd->name, dev->manufacturer); | ||
297 | if (dev->product) | ||
298 | sprintf(kbd->name, "%s %s", kbd->name, dev->product); | ||
299 | |||
300 | if (!strlen(kbd->name)) | ||
301 | sprintf(kbd->name, "USB HIDBP Keyboard %04x:%04x", | ||
302 | kbd->dev.id.vendor, kbd->dev.id.product); | ||
303 | |||
304 | usb_fill_control_urb(kbd->led, dev, usb_sndctrlpipe(dev, 0), | 309 | usb_fill_control_urb(kbd->led, dev, usb_sndctrlpipe(dev, 0), |
305 | (void *) kbd->cr, kbd->leds, 1, | 310 | (void *) kbd->cr, kbd->leds, 1, |
306 | usb_kbd_led, kbd); | 311 | usb_kbd_led, kbd); |
307 | kbd->led->setup_dma = kbd->cr_dma; | 312 | kbd->led->setup_dma = kbd->cr_dma; |
308 | kbd->led->transfer_dma = kbd->leds_dma; | 313 | kbd->led->transfer_dma = kbd->leds_dma; |
309 | kbd->led->transfer_flags |= (URB_NO_TRANSFER_DMA_MAP | 314 | kbd->led->transfer_flags |= (URB_NO_TRANSFER_DMA_MAP | URB_NO_SETUP_DMA_MAP); |
310 | | URB_NO_SETUP_DMA_MAP); | ||
311 | 315 | ||
312 | input_register_device(&kbd->dev); | 316 | input_register_device(kbd->dev); |
313 | |||
314 | printk(KERN_INFO "input: %s on %s\n", kbd->name, path); | ||
315 | 317 | ||
316 | usb_set_intfdata(iface, kbd); | 318 | usb_set_intfdata(iface, kbd); |
317 | return 0; | 319 | return 0; |
320 | |||
321 | fail2: usb_kbd_free_mem(dev, kbd); | ||
322 | fail1: input_free_device(input_dev); | ||
323 | kfree(kbd); | ||
324 | return -ENOMEM; | ||
318 | } | 325 | } |
319 | 326 | ||
320 | static void usb_kbd_disconnect(struct usb_interface *intf) | 327 | static void usb_kbd_disconnect(struct usb_interface *intf) |
@@ -324,7 +331,7 @@ static void usb_kbd_disconnect(struct usb_interface *intf) | |||
324 | usb_set_intfdata(intf, NULL); | 331 | usb_set_intfdata(intf, NULL); |
325 | if (kbd) { | 332 | if (kbd) { |
326 | usb_kill_urb(kbd->irq); | 333 | usb_kill_urb(kbd->irq); |
327 | input_unregister_device(&kbd->dev); | 334 | input_unregister_device(kbd->dev); |
328 | usb_kbd_free_mem(interface_to_usbdev(intf), kbd); | 335 | usb_kbd_free_mem(interface_to_usbdev(intf), kbd); |
329 | kfree(kbd); | 336 | kfree(kbd); |
330 | } | 337 | } |
diff --git a/drivers/usb/input/usbmouse.c b/drivers/usb/input/usbmouse.c index 4104dec847fb..230f6b1b314a 100644 --- a/drivers/usb/input/usbmouse.c +++ b/drivers/usb/input/usbmouse.c | |||
@@ -50,7 +50,7 @@ struct usb_mouse { | |||
50 | char name[128]; | 50 | char name[128]; |
51 | char phys[64]; | 51 | char phys[64]; |
52 | struct usb_device *usbdev; | 52 | struct usb_device *usbdev; |
53 | struct input_dev dev; | 53 | struct input_dev *dev; |
54 | struct urb *irq; | 54 | struct urb *irq; |
55 | 55 | ||
56 | signed char *data; | 56 | signed char *data; |
@@ -61,7 +61,7 @@ static void usb_mouse_irq(struct urb *urb, struct pt_regs *regs) | |||
61 | { | 61 | { |
62 | struct usb_mouse *mouse = urb->context; | 62 | struct usb_mouse *mouse = urb->context; |
63 | signed char *data = mouse->data; | 63 | signed char *data = mouse->data; |
64 | struct input_dev *dev = &mouse->dev; | 64 | struct input_dev *dev = mouse->dev; |
65 | int status; | 65 | int status; |
66 | 66 | ||
67 | switch (urb->status) { | 67 | switch (urb->status) { |
@@ -115,14 +115,14 @@ static void usb_mouse_close(struct input_dev *dev) | |||
115 | usb_kill_urb(mouse->irq); | 115 | usb_kill_urb(mouse->irq); |
116 | } | 116 | } |
117 | 117 | ||
118 | static int usb_mouse_probe(struct usb_interface * intf, const struct usb_device_id * id) | 118 | static int usb_mouse_probe(struct usb_interface *intf, const struct usb_device_id *id) |
119 | { | 119 | { |
120 | struct usb_device * dev = interface_to_usbdev(intf); | 120 | struct usb_device *dev = interface_to_usbdev(intf); |
121 | struct usb_host_interface *interface; | 121 | struct usb_host_interface *interface; |
122 | struct usb_endpoint_descriptor *endpoint; | 122 | struct usb_endpoint_descriptor *endpoint; |
123 | struct usb_mouse *mouse; | 123 | struct usb_mouse *mouse; |
124 | struct input_dev *input_dev; | ||
124 | int pipe, maxp; | 125 | int pipe, maxp; |
125 | char path[64]; | ||
126 | 126 | ||
127 | interface = intf->cur_altsetting; | 127 | interface = intf->cur_altsetting; |
128 | 128 | ||
@@ -130,59 +130,62 @@ static int usb_mouse_probe(struct usb_interface * intf, const struct usb_device_ | |||
130 | return -ENODEV; | 130 | return -ENODEV; |
131 | 131 | ||
132 | endpoint = &interface->endpoint[0].desc; | 132 | endpoint = &interface->endpoint[0].desc; |
133 | if (!(endpoint->bEndpointAddress & 0x80)) | 133 | if (!(endpoint->bEndpointAddress & USB_DIR_IN)) |
134 | return -ENODEV; | 134 | return -ENODEV; |
135 | if ((endpoint->bmAttributes & 3) != 3) | 135 | if ((endpoint->bmAttributes & USB_ENDPOINT_XFERTYPE_MASK) != USB_ENDPOINT_XFER_INT) |
136 | return -ENODEV; | 136 | return -ENODEV; |
137 | 137 | ||
138 | pipe = usb_rcvintpipe(dev, endpoint->bEndpointAddress); | 138 | pipe = usb_rcvintpipe(dev, endpoint->bEndpointAddress); |
139 | maxp = usb_maxpacket(dev, pipe, usb_pipeout(pipe)); | 139 | maxp = usb_maxpacket(dev, pipe, usb_pipeout(pipe)); |
140 | 140 | ||
141 | if (!(mouse = kmalloc(sizeof(struct usb_mouse), GFP_KERNEL))) | 141 | mouse = kzalloc(sizeof(struct usb_mouse), GFP_KERNEL); |
142 | return -ENOMEM; | 142 | input_dev = input_allocate_device(); |
143 | memset(mouse, 0, sizeof(struct usb_mouse)); | 143 | if (!mouse || !input_dev) |
144 | goto fail1; | ||
144 | 145 | ||
145 | mouse->data = usb_buffer_alloc(dev, 8, SLAB_ATOMIC, &mouse->data_dma); | 146 | mouse->data = usb_buffer_alloc(dev, 8, SLAB_ATOMIC, &mouse->data_dma); |
146 | if (!mouse->data) { | 147 | if (!mouse->data) |
147 | kfree(mouse); | 148 | goto fail1; |
148 | return -ENOMEM; | ||
149 | } | ||
150 | 149 | ||
151 | mouse->irq = usb_alloc_urb(0, GFP_KERNEL); | 150 | mouse->irq = usb_alloc_urb(0, GFP_KERNEL); |
152 | if (!mouse->irq) { | 151 | if (!mouse->irq) |
153 | usb_buffer_free(dev, 8, mouse->data, mouse->data_dma); | 152 | goto fail2; |
154 | kfree(mouse); | ||
155 | return -ENODEV; | ||
156 | } | ||
157 | 153 | ||
158 | mouse->usbdev = dev; | 154 | mouse->usbdev = dev; |
155 | mouse->dev = input_dev; | ||
156 | |||
157 | if (dev->manufacturer) | ||
158 | strlcpy(mouse->name, dev->manufacturer, sizeof(mouse->name)); | ||
159 | 159 | ||
160 | mouse->dev.evbit[0] = BIT(EV_KEY) | BIT(EV_REL); | 160 | if (dev->product) { |
161 | mouse->dev.keybit[LONG(BTN_MOUSE)] = BIT(BTN_LEFT) | BIT(BTN_RIGHT) | BIT(BTN_MIDDLE); | 161 | if (dev->manufacturer) |
162 | mouse->dev.relbit[0] = BIT(REL_X) | BIT(REL_Y); | 162 | strlcat(mouse->name, " ", sizeof(mouse->name)); |
163 | mouse->dev.keybit[LONG(BTN_MOUSE)] |= BIT(BTN_SIDE) | BIT(BTN_EXTRA); | 163 | strlcat(mouse->name, dev->product, sizeof(mouse->name)); |
164 | mouse->dev.relbit[0] |= BIT(REL_WHEEL); | 164 | } |
165 | 165 | ||
166 | mouse->dev.private = mouse; | 166 | if (!strlen(mouse->name)) |
167 | mouse->dev.open = usb_mouse_open; | 167 | snprintf(mouse->name, sizeof(mouse->name), |
168 | mouse->dev.close = usb_mouse_close; | 168 | "USB HIDBP Mouse %04x:%04x", |
169 | le16_to_cpu(dev->descriptor.idVendor), | ||
170 | le16_to_cpu(dev->descriptor.idProduct)); | ||
169 | 171 | ||
170 | usb_make_path(dev, path, 64); | 172 | usb_make_path(dev, mouse->phys, sizeof(mouse->phys)); |
171 | sprintf(mouse->phys, "%s/input0", path); | 173 | strlcat(mouse->phys, "/input0", sizeof(mouse->phys)); |
172 | 174 | ||
173 | mouse->dev.name = mouse->name; | 175 | input_dev->name = mouse->name; |
174 | mouse->dev.phys = mouse->phys; | 176 | input_dev->phys = mouse->phys; |
175 | usb_to_input_id(dev, &mouse->dev.id); | 177 | usb_to_input_id(dev, &input_dev->id); |
176 | mouse->dev.dev = &intf->dev; | 178 | input_dev->cdev.dev = &intf->dev; |
177 | 179 | ||
178 | if (dev->manufacturer) | 180 | input_dev->evbit[0] = BIT(EV_KEY) | BIT(EV_REL); |
179 | strcat(mouse->name, dev->manufacturer); | 181 | input_dev->keybit[LONG(BTN_MOUSE)] = BIT(BTN_LEFT) | BIT(BTN_RIGHT) | BIT(BTN_MIDDLE); |
180 | if (dev->product) | 182 | input_dev->relbit[0] = BIT(REL_X) | BIT(REL_Y); |
181 | sprintf(mouse->name, "%s %s", mouse->name, dev->product); | 183 | input_dev->keybit[LONG(BTN_MOUSE)] |= BIT(BTN_SIDE) | BIT(BTN_EXTRA); |
184 | input_dev->relbit[0] |= BIT(REL_WHEEL); | ||
182 | 185 | ||
183 | if (!strlen(mouse->name)) | 186 | input_dev->private = mouse; |
184 | sprintf(mouse->name, "USB HIDBP Mouse %04x:%04x", | 187 | input_dev->open = usb_mouse_open; |
185 | mouse->dev.id.vendor, mouse->dev.id.product); | 188 | input_dev->close = usb_mouse_close; |
186 | 189 | ||
187 | usb_fill_int_urb(mouse->irq, dev, pipe, mouse->data, | 190 | usb_fill_int_urb(mouse->irq, dev, pipe, mouse->data, |
188 | (maxp > 8 ? 8 : maxp), | 191 | (maxp > 8 ? 8 : maxp), |
@@ -190,11 +193,15 @@ static int usb_mouse_probe(struct usb_interface * intf, const struct usb_device_ | |||
190 | mouse->irq->transfer_dma = mouse->data_dma; | 193 | mouse->irq->transfer_dma = mouse->data_dma; |
191 | mouse->irq->transfer_flags |= URB_NO_TRANSFER_DMA_MAP; | 194 | mouse->irq->transfer_flags |= URB_NO_TRANSFER_DMA_MAP; |
192 | 195 | ||
193 | input_register_device(&mouse->dev); | 196 | input_register_device(mouse->dev); |
194 | printk(KERN_INFO "input: %s on %s\n", mouse->name, path); | ||
195 | 197 | ||
196 | usb_set_intfdata(intf, mouse); | 198 | usb_set_intfdata(intf, mouse); |
197 | return 0; | 199 | return 0; |
200 | |||
201 | fail2: usb_buffer_free(dev, 8, mouse->data, mouse->data_dma); | ||
202 | fail1: input_free_device(input_dev); | ||
203 | kfree(mouse); | ||
204 | return -ENOMEM; | ||
198 | } | 205 | } |
199 | 206 | ||
200 | static void usb_mouse_disconnect(struct usb_interface *intf) | 207 | static void usb_mouse_disconnect(struct usb_interface *intf) |
@@ -204,7 +211,7 @@ static void usb_mouse_disconnect(struct usb_interface *intf) | |||
204 | usb_set_intfdata(intf, NULL); | 211 | usb_set_intfdata(intf, NULL); |
205 | if (mouse) { | 212 | if (mouse) { |
206 | usb_kill_urb(mouse->irq); | 213 | usb_kill_urb(mouse->irq); |
207 | input_unregister_device(&mouse->dev); | 214 | input_unregister_device(mouse->dev); |
208 | usb_free_urb(mouse->irq); | 215 | usb_free_urb(mouse->irq); |
209 | usb_buffer_free(interface_to_usbdev(intf), 8, mouse->data, mouse->data_dma); | 216 | usb_buffer_free(interface_to_usbdev(intf), 8, mouse->data, mouse->data_dma); |
210 | kfree(mouse); | 217 | kfree(mouse); |
diff --git a/drivers/usb/input/wacom.c b/drivers/usb/input/wacom.c index 3b266af3048a..aea1cfae34cc 100644 --- a/drivers/usb/input/wacom.c +++ b/drivers/usb/input/wacom.c | |||
@@ -52,8 +52,10 @@ | |||
52 | * v1.30.1 (pi) - Added Graphire3 support | 52 | * v1.30.1 (pi) - Added Graphire3 support |
53 | * v1.40 (pc) - Add support for several new devices, fix eraser reporting, ... | 53 | * v1.40 (pc) - Add support for several new devices, fix eraser reporting, ... |
54 | * v1.43 (pc) - Added support for Cintiq 21UX | 54 | * v1.43 (pc) - Added support for Cintiq 21UX |
55 | - Fixed a Graphire bug | 55 | * - Fixed a Graphire bug |
56 | - Merged wacom_intuos3_irq into wacom_intuos_irq | 56 | * - Merged wacom_intuos3_irq into wacom_intuos_irq |
57 | * v1.44 (pc) - Added support for Graphire4, Cintiq 710, Intuos3 6x11, etc. | ||
58 | * - Report Device IDs | ||
57 | */ | 59 | */ |
58 | 60 | ||
59 | /* | 61 | /* |
@@ -76,7 +78,7 @@ | |||
76 | /* | 78 | /* |
77 | * Version Information | 79 | * Version Information |
78 | */ | 80 | */ |
79 | #define DRIVER_VERSION "v1.43" | 81 | #define DRIVER_VERSION "v1.44" |
80 | #define DRIVER_AUTHOR "Vojtech Pavlik <vojtech@ucw.cz>" | 82 | #define DRIVER_AUTHOR "Vojtech Pavlik <vojtech@ucw.cz>" |
81 | #define DRIVER_DESC "USB Wacom Graphire and Wacom Intuos tablet driver" | 83 | #define DRIVER_DESC "USB Wacom Graphire and Wacom Intuos tablet driver" |
82 | #define DRIVER_LICENSE "GPL" | 84 | #define DRIVER_LICENSE "GPL" |
@@ -86,10 +88,14 @@ MODULE_DESCRIPTION(DRIVER_DESC); | |||
86 | MODULE_LICENSE(DRIVER_LICENSE); | 88 | MODULE_LICENSE(DRIVER_LICENSE); |
87 | 89 | ||
88 | #define USB_VENDOR_ID_WACOM 0x056a | 90 | #define USB_VENDOR_ID_WACOM 0x056a |
91 | #define STYLUS_DEVICE_ID 0x02 | ||
92 | #define CURSOR_DEVICE_ID 0x06 | ||
93 | #define ERASER_DEVICE_ID 0x0A | ||
89 | 94 | ||
90 | enum { | 95 | enum { |
91 | PENPARTNER = 0, | 96 | PENPARTNER = 0, |
92 | GRAPHIRE, | 97 | GRAPHIRE, |
98 | G4, | ||
93 | PL, | 99 | PL, |
94 | INTUOS, | 100 | INTUOS, |
95 | INTUOS3, | 101 | INTUOS3, |
@@ -111,11 +117,12 @@ struct wacom_features { | |||
111 | struct wacom { | 117 | struct wacom { |
112 | signed char *data; | 118 | signed char *data; |
113 | dma_addr_t data_dma; | 119 | dma_addr_t data_dma; |
114 | struct input_dev dev; | 120 | struct input_dev *dev; |
115 | struct usb_device *usbdev; | 121 | struct usb_device *usbdev; |
116 | struct urb *irq; | 122 | struct urb *irq; |
117 | struct wacom_features *features; | 123 | struct wacom_features *features; |
118 | int tool[2]; | 124 | int tool[2]; |
125 | int id[2]; | ||
119 | __u32 serial[2]; | 126 | __u32 serial[2]; |
120 | char phys[32]; | 127 | char phys[32]; |
121 | }; | 128 | }; |
@@ -135,8 +142,8 @@ static void wacom_pl_irq(struct urb *urb, struct pt_regs *regs) | |||
135 | { | 142 | { |
136 | struct wacom *wacom = urb->context; | 143 | struct wacom *wacom = urb->context; |
137 | unsigned char *data = wacom->data; | 144 | unsigned char *data = wacom->data; |
138 | struct input_dev *dev = &wacom->dev; | 145 | struct input_dev *dev = wacom->dev; |
139 | int prox, pressure; | 146 | int prox, pressure, id; |
140 | int retval; | 147 | int retval; |
141 | 148 | ||
142 | switch (urb->status) { | 149 | switch (urb->status) { |
@@ -163,6 +170,7 @@ static void wacom_pl_irq(struct urb *urb, struct pt_regs *regs) | |||
163 | 170 | ||
164 | input_regs(dev, regs); | 171 | input_regs(dev, regs); |
165 | 172 | ||
173 | id = ERASER_DEVICE_ID; | ||
166 | if (prox) { | 174 | if (prox) { |
167 | 175 | ||
168 | pressure = (signed char)((data[7] << 1) | ((data[4] >> 2) & 1)); | 176 | pressure = (signed char)((data[7] << 1) | ((data[4] >> 2) & 1)); |
@@ -177,11 +185,15 @@ static void wacom_pl_irq(struct urb *urb, struct pt_regs *regs) | |||
177 | * an out of proximity for previous tool then a in for new tool. | 185 | * an out of proximity for previous tool then a in for new tool. |
178 | */ | 186 | */ |
179 | if (!wacom->tool[0]) { | 187 | if (!wacom->tool[0]) { |
180 | /* Going into proximity select tool */ | 188 | /* Eraser bit set for DTF */ |
181 | wacom->tool[1] = (data[4] & 0x20)? BTN_TOOL_RUBBER : BTN_TOOL_PEN; | 189 | if (data[1] & 0x10) |
190 | wacom->tool[1] = BTN_TOOL_RUBBER; | ||
191 | else | ||
192 | /* Going into proximity select tool */ | ||
193 | wacom->tool[1] = (data[4] & 0x20) ? BTN_TOOL_RUBBER : BTN_TOOL_PEN; | ||
182 | } else { | 194 | } else { |
183 | /* was entered with stylus2 pressed */ | 195 | /* was entered with stylus2 pressed */ |
184 | if (wacom->tool[1] == BTN_TOOL_RUBBER && !(data[4] & 0x20) ) { | 196 | if (wacom->tool[1] == BTN_TOOL_RUBBER && !(data[4] & 0x20)) { |
185 | /* report out proximity for previous tool */ | 197 | /* report out proximity for previous tool */ |
186 | input_report_key(dev, wacom->tool[1], 0); | 198 | input_report_key(dev, wacom->tool[1], 0); |
187 | input_sync(dev); | 199 | input_sync(dev); |
@@ -192,8 +204,9 @@ static void wacom_pl_irq(struct urb *urb, struct pt_regs *regs) | |||
192 | if (wacom->tool[1] != BTN_TOOL_RUBBER) { | 204 | if (wacom->tool[1] != BTN_TOOL_RUBBER) { |
193 | /* Unknown tool selected default to pen tool */ | 205 | /* Unknown tool selected default to pen tool */ |
194 | wacom->tool[1] = BTN_TOOL_PEN; | 206 | wacom->tool[1] = BTN_TOOL_PEN; |
207 | id = STYLUS_DEVICE_ID; | ||
195 | } | 208 | } |
196 | input_report_key(dev, wacom->tool[1], prox); /* report in proximity for tool */ | 209 | input_report_key(dev, wacom->tool[1], id); /* report in proximity for tool */ |
197 | input_report_abs(dev, ABS_X, data[3] | (data[2] << 7) | ((data[1] & 0x03) << 14)); | 210 | input_report_abs(dev, ABS_X, data[3] | (data[2] << 7) | ((data[1] & 0x03) << 14)); |
198 | input_report_abs(dev, ABS_Y, data[6] | (data[5] << 7) | ((data[4] & 0x03) << 14)); | 211 | input_report_abs(dev, ABS_Y, data[6] | (data[5] << 7) | ((data[4] & 0x03) << 14)); |
199 | input_report_abs(dev, ABS_PRESSURE, pressure); | 212 | input_report_abs(dev, ABS_PRESSURE, pressure); |
@@ -225,7 +238,7 @@ static void wacom_ptu_irq(struct urb *urb, struct pt_regs *regs) | |||
225 | { | 238 | { |
226 | struct wacom *wacom = urb->context; | 239 | struct wacom *wacom = urb->context; |
227 | unsigned char *data = wacom->data; | 240 | unsigned char *data = wacom->data; |
228 | struct input_dev *dev = &wacom->dev; | 241 | struct input_dev *dev = wacom->dev; |
229 | int retval; | 242 | int retval; |
230 | 243 | ||
231 | switch (urb->status) { | 244 | switch (urb->status) { |
@@ -250,10 +263,10 @@ static void wacom_ptu_irq(struct urb *urb, struct pt_regs *regs) | |||
250 | 263 | ||
251 | input_regs(dev, regs); | 264 | input_regs(dev, regs); |
252 | if (data[1] & 0x04) { | 265 | if (data[1] & 0x04) { |
253 | input_report_key(dev, BTN_TOOL_RUBBER, data[1] & 0x20); | 266 | input_report_key(dev, BTN_TOOL_RUBBER, (data[1] & 0x20) ? ERASER_DEVICE_ID : 0); |
254 | input_report_key(dev, BTN_TOUCH, data[1] & 0x08); | 267 | input_report_key(dev, BTN_TOUCH, data[1] & 0x08); |
255 | } else { | 268 | } else { |
256 | input_report_key(dev, BTN_TOOL_PEN, data[1] & 0x20); | 269 | input_report_key(dev, BTN_TOOL_PEN, (data[1] & 0x20) ? STYLUS_DEVICE_ID : 0); |
257 | input_report_key(dev, BTN_TOUCH, data[1] & 0x01); | 270 | input_report_key(dev, BTN_TOUCH, data[1] & 0x01); |
258 | } | 271 | } |
259 | input_report_abs(dev, ABS_X, le16_to_cpu(*(__le16 *) &data[2])); | 272 | input_report_abs(dev, ABS_X, le16_to_cpu(*(__le16 *) &data[2])); |
@@ -275,7 +288,7 @@ static void wacom_penpartner_irq(struct urb *urb, struct pt_regs *regs) | |||
275 | { | 288 | { |
276 | struct wacom *wacom = urb->context; | 289 | struct wacom *wacom = urb->context; |
277 | unsigned char *data = wacom->data; | 290 | unsigned char *data = wacom->data; |
278 | struct input_dev *dev = &wacom->dev; | 291 | struct input_dev *dev = wacom->dev; |
279 | int retval; | 292 | int retval; |
280 | 293 | ||
281 | switch (urb->status) { | 294 | switch (urb->status) { |
@@ -299,7 +312,7 @@ static void wacom_penpartner_irq(struct urb *urb, struct pt_regs *regs) | |||
299 | } | 312 | } |
300 | 313 | ||
301 | input_regs(dev, regs); | 314 | input_regs(dev, regs); |
302 | input_report_key(dev, BTN_TOOL_PEN, 1); | 315 | input_report_key(dev, BTN_TOOL_PEN, STYLUS_DEVICE_ID); |
303 | input_report_abs(dev, ABS_X, le16_to_cpu(*(__le16 *) &data[1])); | 316 | input_report_abs(dev, ABS_X, le16_to_cpu(*(__le16 *) &data[1])); |
304 | input_report_abs(dev, ABS_Y, le16_to_cpu(*(__le16 *) &data[3])); | 317 | input_report_abs(dev, ABS_Y, le16_to_cpu(*(__le16 *) &data[3])); |
305 | input_report_abs(dev, ABS_PRESSURE, (signed char)data[6] + 127); | 318 | input_report_abs(dev, ABS_PRESSURE, (signed char)data[6] + 127); |
@@ -318,8 +331,8 @@ static void wacom_graphire_irq(struct urb *urb, struct pt_regs *regs) | |||
318 | { | 331 | { |
319 | struct wacom *wacom = urb->context; | 332 | struct wacom *wacom = urb->context; |
320 | unsigned char *data = wacom->data; | 333 | unsigned char *data = wacom->data; |
321 | struct input_dev *dev = &wacom->dev; | 334 | struct input_dev *dev = wacom->dev; |
322 | int x, y; | 335 | int x, y, id, rw; |
323 | int retval; | 336 | int retval; |
324 | 337 | ||
325 | switch (urb->status) { | 338 | switch (urb->status) { |
@@ -344,6 +357,7 @@ static void wacom_graphire_irq(struct urb *urb, struct pt_regs *regs) | |||
344 | 357 | ||
345 | input_regs(dev, regs); | 358 | input_regs(dev, regs); |
346 | 359 | ||
360 | id = STYLUS_DEVICE_ID; | ||
347 | if (data[1] & 0x10) { /* in prox */ | 361 | if (data[1] & 0x10) { /* in prox */ |
348 | 362 | ||
349 | switch ((data[1] >> 5) & 3) { | 363 | switch ((data[1] >> 5) & 3) { |
@@ -354,18 +368,27 @@ static void wacom_graphire_irq(struct urb *urb, struct pt_regs *regs) | |||
354 | 368 | ||
355 | case 1: /* Rubber */ | 369 | case 1: /* Rubber */ |
356 | wacom->tool[0] = BTN_TOOL_RUBBER; | 370 | wacom->tool[0] = BTN_TOOL_RUBBER; |
371 | id = ERASER_DEVICE_ID; | ||
357 | break; | 372 | break; |
358 | 373 | ||
359 | case 2: /* Mouse with wheel */ | 374 | case 2: /* Mouse with wheel */ |
360 | input_report_key(dev, BTN_MIDDLE, data[1] & 0x04); | 375 | input_report_key(dev, BTN_MIDDLE, data[1] & 0x04); |
361 | input_report_rel(dev, REL_WHEEL, (signed char) data[6]); | 376 | if (wacom->features->type == G4) { |
377 | rw = data[7] & 0x04 ? -(data[7] & 0x03) : (data[7] & 0x03); | ||
378 | input_report_rel(dev, REL_WHEEL, rw); | ||
379 | } else | ||
380 | input_report_rel(dev, REL_WHEEL, (signed char) data[6]); | ||
362 | /* fall through */ | 381 | /* fall through */ |
363 | 382 | ||
364 | case 3: /* Mouse without wheel */ | 383 | case 3: /* Mouse without wheel */ |
365 | wacom->tool[0] = BTN_TOOL_MOUSE; | 384 | wacom->tool[0] = BTN_TOOL_MOUSE; |
385 | id = CURSOR_DEVICE_ID; | ||
366 | input_report_key(dev, BTN_LEFT, data[1] & 0x01); | 386 | input_report_key(dev, BTN_LEFT, data[1] & 0x01); |
367 | input_report_key(dev, BTN_RIGHT, data[1] & 0x02); | 387 | input_report_key(dev, BTN_RIGHT, data[1] & 0x02); |
368 | input_report_abs(dev, ABS_DISTANCE, data[7]); | 388 | if (wacom->features->type == G4) |
389 | input_report_abs(dev, ABS_DISTANCE, data[6]); | ||
390 | else | ||
391 | input_report_abs(dev, ABS_DISTANCE, data[7]); | ||
369 | break; | 392 | break; |
370 | } | 393 | } |
371 | } | 394 | } |
@@ -376,16 +399,50 @@ static void wacom_graphire_irq(struct urb *urb, struct pt_regs *regs) | |||
376 | input_report_abs(dev, ABS_X, x); | 399 | input_report_abs(dev, ABS_X, x); |
377 | input_report_abs(dev, ABS_Y, y); | 400 | input_report_abs(dev, ABS_Y, y); |
378 | if (wacom->tool[0] != BTN_TOOL_MOUSE) { | 401 | if (wacom->tool[0] != BTN_TOOL_MOUSE) { |
379 | input_report_abs(dev, ABS_PRESSURE, le16_to_cpu(*(__le16 *) &data[6])); | 402 | input_report_abs(dev, ABS_PRESSURE, data[6] | ((data[7] & 0x01) << 8)); |
380 | input_report_key(dev, BTN_TOUCH, data[1] & 0x01); | 403 | input_report_key(dev, BTN_TOUCH, data[1] & 0x01); |
381 | input_report_key(dev, BTN_STYLUS, data[1] & 0x02); | 404 | input_report_key(dev, BTN_STYLUS, data[1] & 0x02); |
382 | input_report_key(dev, BTN_STYLUS2, data[1] & 0x04); | 405 | input_report_key(dev, BTN_STYLUS2, data[1] & 0x04); |
383 | } | 406 | } |
384 | } | 407 | } |
385 | 408 | ||
386 | input_report_key(dev, wacom->tool[0], data[1] & 0x10); | 409 | input_report_key(dev, wacom->tool[0], (data[1] & 0x10) ? id : 0); |
387 | input_sync(dev); | 410 | input_sync(dev); |
388 | 411 | ||
412 | /* send pad data */ | ||
413 | if (wacom->features->type == G4) { | ||
414 | /* fist time sending pad data */ | ||
415 | if (wacom->tool[1] != BTN_TOOL_FINGER) { | ||
416 | wacom->id[1] = 0; | ||
417 | wacom->serial[1] = (data[7] & 0x38) >> 2; | ||
418 | } | ||
419 | if (data[7] & 0xf8) { | ||
420 | input_report_key(dev, BTN_0, (data[7] & 0x40)); | ||
421 | input_report_key(dev, BTN_4, (data[7] & 0x80)); | ||
422 | if (((data[7] & 0x38) >> 2) == (wacom->serial[1] & 0x0e)) | ||
423 | /* alter REL_WHEEL value so X apps can get it */ | ||
424 | wacom->serial[1] += (wacom->serial[1] & 0x01) ? -1 : 1; | ||
425 | else | ||
426 | wacom->serial[1] = (data[7] & 0x38 ) >> 2; | ||
427 | |||
428 | /* don't alter the value when there is no wheel event */ | ||
429 | if (wacom->serial[1] == 1) | ||
430 | wacom->serial[1] = 0; | ||
431 | rw = wacom->serial[1]; | ||
432 | rw = (rw & 0x08) ? -(rw & 0x07) : (rw & 0x07); | ||
433 | input_report_rel(dev, REL_WHEEL, rw); | ||
434 | wacom->tool[1] = BTN_TOOL_FINGER; | ||
435 | wacom->id[1] = data[7] & 0xf8; | ||
436 | input_report_key(dev, wacom->tool[1], 0xf0); | ||
437 | input_event(dev, EV_MSC, MSC_SERIAL, 0xf0); | ||
438 | } else if (wacom->id[1]) { | ||
439 | wacom->id[1] = 0; | ||
440 | wacom->serial[1] = 0; | ||
441 | input_report_key(dev, wacom->tool[1], 0); | ||
442 | input_event(dev, EV_MSC, MSC_SERIAL, 0xf0); | ||
443 | } | ||
444 | input_sync(dev); | ||
445 | } | ||
389 | exit: | 446 | exit: |
390 | retval = usb_submit_urb (urb, GFP_ATOMIC); | 447 | retval = usb_submit_urb (urb, GFP_ATOMIC); |
391 | if (retval) | 448 | if (retval) |
@@ -397,7 +454,7 @@ static int wacom_intuos_inout(struct urb *urb) | |||
397 | { | 454 | { |
398 | struct wacom *wacom = urb->context; | 455 | struct wacom *wacom = urb->context; |
399 | unsigned char *data = wacom->data; | 456 | unsigned char *data = wacom->data; |
400 | struct input_dev *dev = &wacom->dev; | 457 | struct input_dev *dev = wacom->dev; |
401 | int idx; | 458 | int idx; |
402 | 459 | ||
403 | /* tool number */ | 460 | /* tool number */ |
@@ -410,7 +467,8 @@ static int wacom_intuos_inout(struct urb *urb) | |||
410 | (data[4] << 20) + (data[5] << 12) + | 467 | (data[4] << 20) + (data[5] << 12) + |
411 | (data[6] << 4) + (data[7] >> 4); | 468 | (data[6] << 4) + (data[7] >> 4); |
412 | 469 | ||
413 | switch ((data[2] << 4) | (data[3] >> 4)) { | 470 | wacom->id[idx] = (data[2] << 4) | (data[3] >> 4); |
471 | switch (wacom->id[idx]) { | ||
414 | case 0x812: /* Inking pen */ | 472 | case 0x812: /* Inking pen */ |
415 | case 0x801: /* Intuos3 Inking pen */ | 473 | case 0x801: /* Intuos3 Inking pen */ |
416 | case 0x012: | 474 | case 0x012: |
@@ -458,7 +516,7 @@ static int wacom_intuos_inout(struct urb *urb) | |||
458 | default: /* Unknown tool */ | 516 | default: /* Unknown tool */ |
459 | wacom->tool[idx] = BTN_TOOL_PEN; | 517 | wacom->tool[idx] = BTN_TOOL_PEN; |
460 | } | 518 | } |
461 | input_report_key(dev, wacom->tool[idx], 1); | 519 | input_report_key(dev, wacom->tool[idx], wacom->id[idx]); |
462 | input_event(dev, EV_MSC, MSC_SERIAL, wacom->serial[idx]); | 520 | input_event(dev, EV_MSC, MSC_SERIAL, wacom->serial[idx]); |
463 | input_sync(dev); | 521 | input_sync(dev); |
464 | return 1; | 522 | return 1; |
@@ -479,7 +537,7 @@ static void wacom_intuos_general(struct urb *urb) | |||
479 | { | 537 | { |
480 | struct wacom *wacom = urb->context; | 538 | struct wacom *wacom = urb->context; |
481 | unsigned char *data = wacom->data; | 539 | unsigned char *data = wacom->data; |
482 | struct input_dev *dev = &wacom->dev; | 540 | struct input_dev *dev = wacom->dev; |
483 | unsigned int t; | 541 | unsigned int t; |
484 | 542 | ||
485 | /* general pen packet */ | 543 | /* general pen packet */ |
@@ -509,7 +567,7 @@ static void wacom_intuos_irq(struct urb *urb, struct pt_regs *regs) | |||
509 | { | 567 | { |
510 | struct wacom *wacom = urb->context; | 568 | struct wacom *wacom = urb->context; |
511 | unsigned char *data = wacom->data; | 569 | unsigned char *data = wacom->data; |
512 | struct input_dev *dev = &wacom->dev; | 570 | struct input_dev *dev = wacom->dev; |
513 | unsigned int t; | 571 | unsigned int t; |
514 | int idx; | 572 | int idx; |
515 | int retval; | 573 | int retval; |
@@ -637,7 +695,7 @@ static void wacom_intuos_irq(struct urb *urb, struct pt_regs *regs) | |||
637 | } | 695 | } |
638 | } | 696 | } |
639 | 697 | ||
640 | input_report_key(dev, wacom->tool[idx], 1); | 698 | input_report_key(dev, wacom->tool[idx], wacom->id[idx]); |
641 | input_event(dev, EV_MSC, MSC_SERIAL, wacom->serial[idx]); | 699 | input_event(dev, EV_MSC, MSC_SERIAL, wacom->serial[idx]); |
642 | input_sync(dev); | 700 | input_sync(dev); |
643 | 701 | ||
@@ -655,6 +713,13 @@ static struct wacom_features wacom_features[] = { | |||
655 | { "Wacom Graphire2 5x7", 8, 13918, 10206, 511, 32, GRAPHIRE, wacom_graphire_irq }, | 713 | { "Wacom Graphire2 5x7", 8, 13918, 10206, 511, 32, GRAPHIRE, wacom_graphire_irq }, |
656 | { "Wacom Graphire3", 8, 10208, 7424, 511, 32, GRAPHIRE, wacom_graphire_irq }, | 714 | { "Wacom Graphire3", 8, 10208, 7424, 511, 32, GRAPHIRE, wacom_graphire_irq }, |
657 | { "Wacom Graphire3 6x8", 8, 16704, 12064, 511, 32, GRAPHIRE, wacom_graphire_irq }, | 715 | { "Wacom Graphire3 6x8", 8, 16704, 12064, 511, 32, GRAPHIRE, wacom_graphire_irq }, |
716 | { "Wacom Graphire4 4x5", 8, 10208, 7424, 511, 32, G4, wacom_graphire_irq }, | ||
717 | { "Wacom Graphire4 6x8", 8, 16704, 12064, 511, 32, G4, wacom_graphire_irq }, | ||
718 | { "Wacom Volito", 8, 5104, 3712, 511, 32, GRAPHIRE, wacom_graphire_irq }, | ||
719 | { "Wacom PenStation2", 8, 3250, 2320, 255, 32, GRAPHIRE, wacom_graphire_irq }, | ||
720 | { "Wacom Volito2 4x5", 8, 5104, 3712, 511, 32, GRAPHIRE, wacom_graphire_irq }, | ||
721 | { "Wacom Volito2 2x3", 8, 3248, 2320, 511, 32, GRAPHIRE, wacom_graphire_irq }, | ||
722 | { "Wacom PenPartner2", 8, 3250, 2320, 255, 32, GRAPHIRE, wacom_graphire_irq }, | ||
658 | { "Wacom Intuos 4x5", 10, 12700, 10600, 1023, 15, INTUOS, wacom_intuos_irq }, | 723 | { "Wacom Intuos 4x5", 10, 12700, 10600, 1023, 15, INTUOS, wacom_intuos_irq }, |
659 | { "Wacom Intuos 6x8", 10, 20320, 16240, 1023, 15, INTUOS, wacom_intuos_irq }, | 724 | { "Wacom Intuos 6x8", 10, 20320, 16240, 1023, 15, INTUOS, wacom_intuos_irq }, |
660 | { "Wacom Intuos 9x12", 10, 30480, 24060, 1023, 15, INTUOS, wacom_intuos_irq }, | 725 | { "Wacom Intuos 9x12", 10, 30480, 24060, 1023, 15, INTUOS, wacom_intuos_irq }, |
@@ -666,16 +731,20 @@ static struct wacom_features wacom_features[] = { | |||
666 | { "Wacom PL600SX", 8, 6260, 5016, 255, 32, PL, wacom_pl_irq }, | 731 | { "Wacom PL600SX", 8, 6260, 5016, 255, 32, PL, wacom_pl_irq }, |
667 | { "Wacom PL550", 8, 6144, 4608, 511, 32, PL, wacom_pl_irq }, | 732 | { "Wacom PL550", 8, 6144, 4608, 511, 32, PL, wacom_pl_irq }, |
668 | { "Wacom PL800", 8, 7220, 5780, 511, 32, PL, wacom_pl_irq }, | 733 | { "Wacom PL800", 8, 7220, 5780, 511, 32, PL, wacom_pl_irq }, |
734 | { "Wacom PL700", 8, 6758, 5406, 511, 32, PL, wacom_pl_irq }, | ||
735 | { "Wacom PL510", 8, 6282, 4762, 511, 32, PL, wacom_pl_irq }, | ||
736 | { "Wacom PL710", 8, 34080, 27660, 511, 32, PL, wacom_pl_irq }, | ||
737 | { "Wacom DTF720", 8, 6858, 5506, 511, 32, PL, wacom_pl_irq }, | ||
738 | { "Wacom Cintiq Partner",8, 20480, 15360, 511, 32, PL, wacom_ptu_irq }, | ||
669 | { "Wacom Intuos2 4x5", 10, 12700, 10600, 1023, 15, INTUOS, wacom_intuos_irq }, | 739 | { "Wacom Intuos2 4x5", 10, 12700, 10600, 1023, 15, INTUOS, wacom_intuos_irq }, |
670 | { "Wacom Intuos2 6x8", 10, 20320, 16240, 1023, 15, INTUOS, wacom_intuos_irq }, | 740 | { "Wacom Intuos2 6x8", 10, 20320, 16240, 1023, 15, INTUOS, wacom_intuos_irq }, |
671 | { "Wacom Intuos2 9x12", 10, 30480, 24060, 1023, 15, INTUOS, wacom_intuos_irq }, | 741 | { "Wacom Intuos2 9x12", 10, 30480, 24060, 1023, 15, INTUOS, wacom_intuos_irq }, |
672 | { "Wacom Intuos2 12x12", 10, 30480, 31680, 1023, 15, INTUOS, wacom_intuos_irq }, | 742 | { "Wacom Intuos2 12x12", 10, 30480, 31680, 1023, 15, INTUOS, wacom_intuos_irq }, |
673 | { "Wacom Intuos2 12x18", 10, 45720, 31680, 1023, 15, INTUOS, wacom_intuos_irq }, | 743 | { "Wacom Intuos2 12x18", 10, 45720, 31680, 1023, 15, INTUOS, wacom_intuos_irq }, |
674 | { "Wacom Volito", 8, 5104, 3712, 511, 32, GRAPHIRE, wacom_graphire_irq }, | ||
675 | { "Wacom Cintiq Partner",8, 20480, 15360, 511, 32, PL, wacom_ptu_irq }, | ||
676 | { "Wacom Intuos3 4x5", 10, 25400, 20320, 1023, 15, INTUOS3, wacom_intuos_irq }, | 744 | { "Wacom Intuos3 4x5", 10, 25400, 20320, 1023, 15, INTUOS3, wacom_intuos_irq }, |
677 | { "Wacom Intuos3 6x8", 10, 40640, 30480, 1023, 15, INTUOS3, wacom_intuos_irq }, | 745 | { "Wacom Intuos3 6x8", 10, 40640, 30480, 1023, 15, INTUOS3, wacom_intuos_irq }, |
678 | { "Wacom Intuos3 9x12", 10, 60960, 45720, 1023, 15, INTUOS3, wacom_intuos_irq }, | 746 | { "Wacom Intuos3 9x12", 10, 60960, 45720, 1023, 15, INTUOS3, wacom_intuos_irq }, |
747 | { "Wacom Intuos3 6x11", 10, 54204, 31750, 1023, 15, INTUOS3, wacom_intuos_irq }, | ||
679 | { "Wacom Cintiq 21UX", 10, 87200, 65600, 1023, 15, CINTIQ, wacom_intuos_irq }, | 748 | { "Wacom Cintiq 21UX", 10, 87200, 65600, 1023, 15, CINTIQ, wacom_intuos_irq }, |
680 | { "Wacom Intuos2 6x8", 10, 20320, 16240, 1023, 15, INTUOS, wacom_intuos_irq }, | 749 | { "Wacom Intuos2 6x8", 10, 20320, 16240, 1023, 15, INTUOS, wacom_intuos_irq }, |
681 | { } | 750 | { } |
@@ -688,6 +757,13 @@ static struct usb_device_id wacom_ids[] = { | |||
688 | { USB_DEVICE(USB_VENDOR_ID_WACOM, 0x12) }, | 757 | { USB_DEVICE(USB_VENDOR_ID_WACOM, 0x12) }, |
689 | { USB_DEVICE(USB_VENDOR_ID_WACOM, 0x13) }, | 758 | { USB_DEVICE(USB_VENDOR_ID_WACOM, 0x13) }, |
690 | { USB_DEVICE(USB_VENDOR_ID_WACOM, 0x14) }, | 759 | { USB_DEVICE(USB_VENDOR_ID_WACOM, 0x14) }, |
760 | { USB_DEVICE(USB_VENDOR_ID_WACOM, 0x15) }, | ||
761 | { USB_DEVICE(USB_VENDOR_ID_WACOM, 0x16) }, | ||
762 | { USB_DEVICE(USB_VENDOR_ID_WACOM, 0x60) }, | ||
763 | { USB_DEVICE(USB_VENDOR_ID_WACOM, 0x61) }, | ||
764 | { USB_DEVICE(USB_VENDOR_ID_WACOM, 0x62) }, | ||
765 | { USB_DEVICE(USB_VENDOR_ID_WACOM, 0x63) }, | ||
766 | { USB_DEVICE(USB_VENDOR_ID_WACOM, 0x64) }, | ||
691 | { USB_DEVICE(USB_VENDOR_ID_WACOM, 0x20) }, | 767 | { USB_DEVICE(USB_VENDOR_ID_WACOM, 0x20) }, |
692 | { USB_DEVICE(USB_VENDOR_ID_WACOM, 0x21) }, | 768 | { USB_DEVICE(USB_VENDOR_ID_WACOM, 0x21) }, |
693 | { USB_DEVICE(USB_VENDOR_ID_WACOM, 0x22) }, | 769 | { USB_DEVICE(USB_VENDOR_ID_WACOM, 0x22) }, |
@@ -699,16 +775,20 @@ static struct usb_device_id wacom_ids[] = { | |||
699 | { USB_DEVICE(USB_VENDOR_ID_WACOM, 0x33) }, | 775 | { USB_DEVICE(USB_VENDOR_ID_WACOM, 0x33) }, |
700 | { USB_DEVICE(USB_VENDOR_ID_WACOM, 0x34) }, | 776 | { USB_DEVICE(USB_VENDOR_ID_WACOM, 0x34) }, |
701 | { USB_DEVICE(USB_VENDOR_ID_WACOM, 0x35) }, | 777 | { USB_DEVICE(USB_VENDOR_ID_WACOM, 0x35) }, |
778 | { USB_DEVICE(USB_VENDOR_ID_WACOM, 0x37) }, | ||
779 | { USB_DEVICE(USB_VENDOR_ID_WACOM, 0x38) }, | ||
780 | { USB_DEVICE(USB_VENDOR_ID_WACOM, 0x39) }, | ||
781 | { USB_DEVICE(USB_VENDOR_ID_WACOM, 0xC0) }, | ||
782 | { USB_DEVICE(USB_VENDOR_ID_WACOM, 0x03) }, | ||
702 | { USB_DEVICE(USB_VENDOR_ID_WACOM, 0x41) }, | 783 | { USB_DEVICE(USB_VENDOR_ID_WACOM, 0x41) }, |
703 | { USB_DEVICE(USB_VENDOR_ID_WACOM, 0x42) }, | 784 | { USB_DEVICE(USB_VENDOR_ID_WACOM, 0x42) }, |
704 | { USB_DEVICE(USB_VENDOR_ID_WACOM, 0x43) }, | 785 | { USB_DEVICE(USB_VENDOR_ID_WACOM, 0x43) }, |
705 | { USB_DEVICE(USB_VENDOR_ID_WACOM, 0x44) }, | 786 | { USB_DEVICE(USB_VENDOR_ID_WACOM, 0x44) }, |
706 | { USB_DEVICE(USB_VENDOR_ID_WACOM, 0x45) }, | 787 | { USB_DEVICE(USB_VENDOR_ID_WACOM, 0x45) }, |
707 | { USB_DEVICE(USB_VENDOR_ID_WACOM, 0x60) }, | ||
708 | { USB_DEVICE(USB_VENDOR_ID_WACOM, 0x03) }, | ||
709 | { USB_DEVICE(USB_VENDOR_ID_WACOM, 0xB0) }, | 788 | { USB_DEVICE(USB_VENDOR_ID_WACOM, 0xB0) }, |
710 | { USB_DEVICE(USB_VENDOR_ID_WACOM, 0xB1) }, | 789 | { USB_DEVICE(USB_VENDOR_ID_WACOM, 0xB1) }, |
711 | { USB_DEVICE(USB_VENDOR_ID_WACOM, 0xB2) }, | 790 | { USB_DEVICE(USB_VENDOR_ID_WACOM, 0xB2) }, |
791 | { USB_DEVICE(USB_VENDOR_ID_WACOM, 0xB5) }, | ||
712 | { USB_DEVICE(USB_VENDOR_ID_WACOM, 0x3F) }, | 792 | { USB_DEVICE(USB_VENDOR_ID_WACOM, 0x3F) }, |
713 | { USB_DEVICE(USB_VENDOR_ID_WACOM, 0x47) }, | 793 | { USB_DEVICE(USB_VENDOR_ID_WACOM, 0x47) }, |
714 | { } | 794 | { } |
@@ -738,95 +818,90 @@ static int wacom_probe(struct usb_interface *intf, const struct usb_device_id *i | |||
738 | { | 818 | { |
739 | struct usb_device *dev = interface_to_usbdev(intf); | 819 | struct usb_device *dev = interface_to_usbdev(intf); |
740 | struct usb_endpoint_descriptor *endpoint; | 820 | struct usb_endpoint_descriptor *endpoint; |
741 | char rep_data[2] = {0x02, 0x02}; | ||
742 | struct wacom *wacom; | 821 | struct wacom *wacom; |
743 | char path[64]; | 822 | struct input_dev *input_dev; |
823 | char rep_data[2] = {0x02, 0x02}; | ||
744 | 824 | ||
745 | if (!(wacom = kmalloc(sizeof(struct wacom), GFP_KERNEL))) | 825 | wacom = kzalloc(sizeof(struct wacom), GFP_KERNEL); |
746 | return -ENOMEM; | 826 | input_dev = input_allocate_device(); |
747 | memset(wacom, 0, sizeof(struct wacom)); | 827 | if (!wacom || !input_dev) |
828 | goto fail1; | ||
748 | 829 | ||
749 | wacom->data = usb_buffer_alloc(dev, 10, GFP_KERNEL, &wacom->data_dma); | 830 | wacom->data = usb_buffer_alloc(dev, 10, GFP_KERNEL, &wacom->data_dma); |
750 | if (!wacom->data) { | 831 | if (!wacom->data) |
751 | kfree(wacom); | 832 | goto fail1; |
752 | return -ENOMEM; | ||
753 | } | ||
754 | 833 | ||
755 | wacom->irq = usb_alloc_urb(0, GFP_KERNEL); | 834 | wacom->irq = usb_alloc_urb(0, GFP_KERNEL); |
756 | if (!wacom->irq) { | 835 | if (!wacom->irq) |
757 | usb_buffer_free(dev, 10, wacom->data, wacom->data_dma); | 836 | goto fail2; |
758 | kfree(wacom); | 837 | |
759 | return -ENOMEM; | 838 | wacom->usbdev = dev; |
760 | } | 839 | wacom->dev = input_dev; |
840 | usb_make_path(dev, wacom->phys, sizeof(wacom->phys)); | ||
841 | strlcat(wacom->phys, "/input0", sizeof(wacom->phys)); | ||
761 | 842 | ||
762 | wacom->features = wacom_features + (id - wacom_ids); | 843 | wacom->features = wacom_features + (id - wacom_ids); |
844 | if (wacom->features->pktlen > 10) | ||
845 | BUG(); | ||
846 | |||
847 | input_dev->name = wacom->features->name; | ||
848 | usb_to_input_id(dev, &input_dev->id); | ||
763 | 849 | ||
764 | wacom->dev.evbit[0] |= BIT(EV_KEY) | BIT(EV_ABS); | 850 | input_dev->cdev.dev = &intf->dev; |
765 | wacom->dev.absbit[0] |= BIT(ABS_X) | BIT(ABS_Y) | BIT(ABS_PRESSURE); | 851 | input_dev->private = wacom; |
766 | wacom->dev.keybit[LONG(BTN_DIGI)] |= BIT(BTN_TOOL_PEN) | BIT(BTN_TOUCH) | BIT(BTN_STYLUS); | 852 | input_dev->open = wacom_open; |
853 | input_dev->close = wacom_close; | ||
854 | |||
855 | input_dev->evbit[0] |= BIT(EV_KEY) | BIT(EV_ABS); | ||
856 | input_dev->keybit[LONG(BTN_DIGI)] |= BIT(BTN_TOOL_PEN) | BIT(BTN_TOUCH) | BIT(BTN_STYLUS); | ||
857 | input_set_abs_params(input_dev, ABS_X, 0, wacom->features->y_max, 4, 0); | ||
858 | input_set_abs_params(input_dev, ABS_Y, 0, wacom->features->y_max, 4, 0); | ||
859 | input_set_abs_params(input_dev, ABS_PRESSURE, 0, wacom->features->pressure_max, 0, 0); | ||
767 | 860 | ||
768 | switch (wacom->features->type) { | 861 | switch (wacom->features->type) { |
862 | case G4: | ||
863 | input_dev->evbit[0] |= BIT(EV_MSC); | ||
864 | input_dev->mscbit[0] |= BIT(MSC_SERIAL); | ||
865 | input_dev->keybit[LONG(BTN_DIGI)] |= BIT(BTN_TOOL_FINGER); | ||
866 | input_dev->keybit[LONG(BTN_LEFT)] |= BIT(BTN_0) | BIT(BTN_1) | BIT(BTN_2) | BIT(BTN_3) | BIT(BTN_4) | BIT(BTN_5) | BIT(BTN_6) | BIT(BTN_7); | ||
867 | /* fall through */ | ||
868 | |||
769 | case GRAPHIRE: | 869 | case GRAPHIRE: |
770 | wacom->dev.evbit[0] |= BIT(EV_REL); | 870 | input_dev->evbit[0] |= BIT(EV_REL); |
771 | wacom->dev.relbit[0] |= BIT(REL_WHEEL); | 871 | input_dev->relbit[0] |= BIT(REL_WHEEL); |
772 | wacom->dev.absbit[0] |= BIT(ABS_DISTANCE); | 872 | input_dev->keybit[LONG(BTN_LEFT)] |= BIT(BTN_LEFT) | BIT(BTN_RIGHT) | BIT(BTN_MIDDLE); |
773 | wacom->dev.keybit[LONG(BTN_LEFT)] |= BIT(BTN_LEFT) | BIT(BTN_RIGHT) | BIT(BTN_MIDDLE); | 873 | input_dev->keybit[LONG(BTN_DIGI)] |= BIT(BTN_TOOL_RUBBER) | BIT(BTN_TOOL_MOUSE) | BIT(BTN_STYLUS2); |
774 | wacom->dev.keybit[LONG(BTN_DIGI)] |= BIT(BTN_TOOL_RUBBER) | BIT(BTN_TOOL_MOUSE) | BIT(BTN_STYLUS2); | 874 | input_set_abs_params(input_dev, ABS_DISTANCE, 0, wacom->features->distance_max, 0, 0); |
775 | break; | 875 | break; |
776 | 876 | ||
777 | case INTUOS3: | 877 | case INTUOS3: |
778 | case CINTIQ: | 878 | case CINTIQ: |
779 | wacom->dev.keybit[LONG(BTN_DIGI)] |= BIT(BTN_TOOL_FINGER); | 879 | input_dev->keybit[LONG(BTN_DIGI)] |= BIT(BTN_TOOL_FINGER); |
780 | wacom->dev.keybit[LONG(BTN_LEFT)] |= BIT(BTN_0) | BIT(BTN_1) | BIT(BTN_2) | BIT(BTN_3) | BIT(BTN_4) | BIT(BTN_5) | BIT(BTN_6) | BIT(BTN_7); | 880 | input_dev->keybit[LONG(BTN_LEFT)] |= BIT(BTN_0) | BIT(BTN_1) | BIT(BTN_2) | BIT(BTN_3) | BIT(BTN_4) | BIT(BTN_5) | BIT(BTN_6) | BIT(BTN_7); |
781 | wacom->dev.absbit[0] |= BIT(ABS_RX) | BIT(ABS_RY); | 881 | input_set_abs_params(input_dev, ABS_RX, 0, 4097, 0, 0); |
882 | input_set_abs_params(input_dev, ABS_RY, 0, 4097, 0, 0); | ||
782 | /* fall through */ | 883 | /* fall through */ |
783 | 884 | ||
784 | case INTUOS: | 885 | case INTUOS: |
785 | wacom->dev.evbit[0] |= BIT(EV_MSC) | BIT(EV_REL); | 886 | input_dev->evbit[0] |= BIT(EV_MSC) | BIT(EV_REL); |
786 | wacom->dev.mscbit[0] |= BIT(MSC_SERIAL); | 887 | input_dev->mscbit[0] |= BIT(MSC_SERIAL); |
787 | wacom->dev.relbit[0] |= BIT(REL_WHEEL); | 888 | input_dev->relbit[0] |= BIT(REL_WHEEL); |
788 | wacom->dev.keybit[LONG(BTN_LEFT)] |= BIT(BTN_LEFT) | BIT(BTN_RIGHT) | BIT(BTN_MIDDLE) | BIT(BTN_SIDE) | BIT(BTN_EXTRA); | 889 | input_dev->keybit[LONG(BTN_LEFT)] |= BIT(BTN_LEFT) | BIT(BTN_RIGHT) | BIT(BTN_MIDDLE) | BIT(BTN_SIDE) | BIT(BTN_EXTRA); |
789 | wacom->dev.keybit[LONG(BTN_DIGI)] |= BIT(BTN_TOOL_RUBBER) | BIT(BTN_TOOL_MOUSE) | BIT(BTN_TOOL_BRUSH) | 890 | input_dev->keybit[LONG(BTN_DIGI)] |= BIT(BTN_TOOL_RUBBER) | BIT(BTN_TOOL_MOUSE) | BIT(BTN_TOOL_BRUSH) |
790 | | BIT(BTN_TOOL_PENCIL) | BIT(BTN_TOOL_AIRBRUSH) | BIT(BTN_TOOL_LENS) | BIT(BTN_STYLUS2); | 891 | | BIT(BTN_TOOL_PENCIL) | BIT(BTN_TOOL_AIRBRUSH) | BIT(BTN_TOOL_LENS) | BIT(BTN_STYLUS2); |
791 | wacom->dev.absbit[0] |= BIT(ABS_DISTANCE) | BIT(ABS_WHEEL) | BIT(ABS_TILT_X) | BIT(ABS_TILT_Y) | BIT(ABS_RZ) | BIT(ABS_THROTTLE); | 892 | input_set_abs_params(input_dev, ABS_DISTANCE, 0, wacom->features->distance_max, 0, 0); |
893 | input_set_abs_params(input_dev, ABS_WHEEL, 0, 1023, 0, 0); | ||
894 | input_set_abs_params(input_dev, ABS_TILT_X, 0, 127, 0, 0); | ||
895 | input_set_abs_params(input_dev, ABS_TILT_Y, 0, 127, 0, 0); | ||
896 | input_set_abs_params(input_dev, ABS_RZ, -900, 899, 0, 0); | ||
897 | input_set_abs_params(input_dev, ABS_THROTTLE, -1023, 1023, 0, 0); | ||
792 | break; | 898 | break; |
793 | 899 | ||
794 | case PL: | 900 | case PL: |
795 | wacom->dev.keybit[LONG(BTN_DIGI)] |= BIT(BTN_STYLUS2) | BIT(BTN_TOOL_RUBBER); | 901 | input_dev->keybit[LONG(BTN_DIGI)] |= BIT(BTN_STYLUS2) | BIT(BTN_TOOL_RUBBER); |
796 | break; | 902 | break; |
797 | } | 903 | } |
798 | 904 | ||
799 | wacom->dev.absmax[ABS_X] = wacom->features->x_max; | ||
800 | wacom->dev.absmax[ABS_Y] = wacom->features->y_max; | ||
801 | wacom->dev.absmax[ABS_PRESSURE] = wacom->features->pressure_max; | ||
802 | wacom->dev.absmax[ABS_DISTANCE] = wacom->features->distance_max; | ||
803 | wacom->dev.absmax[ABS_TILT_X] = 127; | ||
804 | wacom->dev.absmax[ABS_TILT_Y] = 127; | ||
805 | wacom->dev.absmax[ABS_WHEEL] = 1023; | ||
806 | |||
807 | wacom->dev.absmax[ABS_RX] = 4097; | ||
808 | wacom->dev.absmax[ABS_RY] = 4097; | ||
809 | wacom->dev.absmin[ABS_RZ] = -900; | ||
810 | wacom->dev.absmax[ABS_RZ] = 899; | ||
811 | wacom->dev.absmin[ABS_THROTTLE] = -1023; | ||
812 | wacom->dev.absmax[ABS_THROTTLE] = 1023; | ||
813 | |||
814 | wacom->dev.absfuzz[ABS_X] = 4; | ||
815 | wacom->dev.absfuzz[ABS_Y] = 4; | ||
816 | |||
817 | wacom->dev.private = wacom; | ||
818 | wacom->dev.open = wacom_open; | ||
819 | wacom->dev.close = wacom_close; | ||
820 | |||
821 | usb_make_path(dev, path, 64); | ||
822 | sprintf(wacom->phys, "%s/input0", path); | ||
823 | |||
824 | wacom->dev.name = wacom->features->name; | ||
825 | wacom->dev.phys = wacom->phys; | ||
826 | usb_to_input_id(dev, &wacom->dev.id); | ||
827 | wacom->dev.dev = &intf->dev; | ||
828 | wacom->usbdev = dev; | ||
829 | |||
830 | endpoint = &intf->cur_altsetting->endpoint[0].desc; | 905 | endpoint = &intf->cur_altsetting->endpoint[0].desc; |
831 | 906 | ||
832 | if (wacom->features->pktlen > 10) | 907 | if (wacom->features->pktlen > 10) |
@@ -839,18 +914,20 @@ static int wacom_probe(struct usb_interface *intf, const struct usb_device_id *i | |||
839 | wacom->irq->transfer_dma = wacom->data_dma; | 914 | wacom->irq->transfer_dma = wacom->data_dma; |
840 | wacom->irq->transfer_flags |= URB_NO_TRANSFER_DMA_MAP; | 915 | wacom->irq->transfer_flags |= URB_NO_TRANSFER_DMA_MAP; |
841 | 916 | ||
842 | input_register_device(&wacom->dev); | 917 | input_register_device(wacom->dev); |
843 | 918 | ||
844 | /* ask the tablet to report tablet data */ | 919 | /* ask the tablet to report tablet data */ |
845 | usb_set_report(intf, 3, 2, rep_data, 2); | 920 | usb_set_report(intf, 3, 2, rep_data, 2); |
846 | /* repeat once (not sure why the first call often fails) */ | 921 | /* repeat once (not sure why the first call often fails) */ |
847 | usb_set_report(intf, 3, 2, rep_data, 2); | 922 | usb_set_report(intf, 3, 2, rep_data, 2); |
848 | 923 | ||
849 | printk(KERN_INFO "input: %s on %s\n", wacom->features->name, path); | ||
850 | |||
851 | usb_set_intfdata(intf, wacom); | 924 | usb_set_intfdata(intf, wacom); |
852 | |||
853 | return 0; | 925 | return 0; |
926 | |||
927 | fail2: usb_buffer_free(dev, 10, wacom->data, wacom->data_dma); | ||
928 | fail1: input_free_device(input_dev); | ||
929 | kfree(wacom); | ||
930 | return -ENOMEM; | ||
854 | } | 931 | } |
855 | 932 | ||
856 | static void wacom_disconnect(struct usb_interface *intf) | 933 | static void wacom_disconnect(struct usb_interface *intf) |
@@ -860,7 +937,7 @@ static void wacom_disconnect(struct usb_interface *intf) | |||
860 | usb_set_intfdata(intf, NULL); | 937 | usb_set_intfdata(intf, NULL); |
861 | if (wacom) { | 938 | if (wacom) { |
862 | usb_kill_urb(wacom->irq); | 939 | usb_kill_urb(wacom->irq); |
863 | input_unregister_device(&wacom->dev); | 940 | input_unregister_device(wacom->dev); |
864 | usb_free_urb(wacom->irq); | 941 | usb_free_urb(wacom->irq); |
865 | usb_buffer_free(interface_to_usbdev(intf), 10, wacom->data, wacom->data_dma); | 942 | usb_buffer_free(interface_to_usbdev(intf), 10, wacom->data, wacom->data_dma); |
866 | kfree(wacom); | 943 | kfree(wacom); |
diff --git a/drivers/usb/input/xpad.c b/drivers/usb/input/xpad.c index 18125e0bffa2..43112f040b6d 100644 --- a/drivers/usb/input/xpad.c +++ b/drivers/usb/input/xpad.c | |||
@@ -103,7 +103,7 @@ static struct usb_device_id xpad_table [] = { | |||
103 | MODULE_DEVICE_TABLE (usb, xpad_table); | 103 | MODULE_DEVICE_TABLE (usb, xpad_table); |
104 | 104 | ||
105 | struct usb_xpad { | 105 | struct usb_xpad { |
106 | struct input_dev dev; /* input device interface */ | 106 | struct input_dev *dev; /* input device interface */ |
107 | struct usb_device *udev; /* usb device */ | 107 | struct usb_device *udev; /* usb device */ |
108 | 108 | ||
109 | struct urb *irq_in; /* urb for interrupt in report */ | 109 | struct urb *irq_in; /* urb for interrupt in report */ |
@@ -125,7 +125,7 @@ struct usb_xpad { | |||
125 | 125 | ||
126 | static void xpad_process_packet(struct usb_xpad *xpad, u16 cmd, unsigned char *data, struct pt_regs *regs) | 126 | static void xpad_process_packet(struct usb_xpad *xpad, u16 cmd, unsigned char *data, struct pt_regs *regs) |
127 | { | 127 | { |
128 | struct input_dev *dev = &xpad->dev; | 128 | struct input_dev *dev = xpad->dev; |
129 | 129 | ||
130 | input_regs(dev, regs); | 130 | input_regs(dev, regs); |
131 | 131 | ||
@@ -214,9 +214,9 @@ static void xpad_close (struct input_dev *dev) | |||
214 | static int xpad_probe(struct usb_interface *intf, const struct usb_device_id *id) | 214 | static int xpad_probe(struct usb_interface *intf, const struct usb_device_id *id) |
215 | { | 215 | { |
216 | struct usb_device *udev = interface_to_usbdev (intf); | 216 | struct usb_device *udev = interface_to_usbdev (intf); |
217 | struct usb_xpad *xpad = NULL; | 217 | struct usb_xpad *xpad; |
218 | struct input_dev *input_dev; | ||
218 | struct usb_endpoint_descriptor *ep_irq_in; | 219 | struct usb_endpoint_descriptor *ep_irq_in; |
219 | char path[64]; | ||
220 | int i; | 220 | int i; |
221 | 221 | ||
222 | for (i = 0; xpad_device[i].idVendor; i++) { | 222 | for (i = 0; xpad_device[i].idVendor; i++) { |
@@ -225,89 +225,80 @@ static int xpad_probe(struct usb_interface *intf, const struct usb_device_id *id | |||
225 | break; | 225 | break; |
226 | } | 226 | } |
227 | 227 | ||
228 | if ((xpad = kmalloc (sizeof(struct usb_xpad), GFP_KERNEL)) == NULL) { | 228 | xpad = kzalloc(sizeof(struct usb_xpad), GFP_KERNEL); |
229 | err("cannot allocate memory for new pad"); | 229 | input_dev = input_allocate_device(); |
230 | return -ENOMEM; | 230 | if (!xpad || !input_dev) |
231 | } | 231 | goto fail1; |
232 | memset(xpad, 0, sizeof(struct usb_xpad)); | ||
233 | 232 | ||
234 | xpad->idata = usb_buffer_alloc(udev, XPAD_PKT_LEN, | 233 | xpad->idata = usb_buffer_alloc(udev, XPAD_PKT_LEN, |
235 | SLAB_ATOMIC, &xpad->idata_dma); | 234 | SLAB_ATOMIC, &xpad->idata_dma); |
236 | if (!xpad->idata) { | 235 | if (!xpad->idata) |
237 | kfree(xpad); | 236 | goto fail1; |
238 | return -ENOMEM; | ||
239 | } | ||
240 | 237 | ||
241 | xpad->irq_in = usb_alloc_urb(0, GFP_KERNEL); | 238 | xpad->irq_in = usb_alloc_urb(0, GFP_KERNEL); |
242 | if (!xpad->irq_in) { | 239 | if (!xpad->irq_in) |
243 | err("cannot allocate memory for new pad irq urb"); | 240 | goto fail2; |
244 | usb_buffer_free(udev, XPAD_PKT_LEN, xpad->idata, xpad->idata_dma); | ||
245 | kfree(xpad); | ||
246 | return -ENOMEM; | ||
247 | } | ||
248 | |||
249 | ep_irq_in = &intf->cur_altsetting->endpoint[0].desc; | ||
250 | |||
251 | usb_fill_int_urb(xpad->irq_in, udev, | ||
252 | usb_rcvintpipe(udev, ep_irq_in->bEndpointAddress), | ||
253 | xpad->idata, XPAD_PKT_LEN, xpad_irq_in, | ||
254 | xpad, ep_irq_in->bInterval); | ||
255 | xpad->irq_in->transfer_dma = xpad->idata_dma; | ||
256 | xpad->irq_in->transfer_flags |= URB_NO_TRANSFER_DMA_MAP; | ||
257 | 241 | ||
258 | xpad->udev = udev; | 242 | xpad->udev = udev; |
243 | xpad->dev = input_dev; | ||
244 | usb_make_path(udev, xpad->phys, sizeof(xpad->phys)); | ||
245 | strlcat(xpad->phys, "/input0", sizeof(xpad->phys)); | ||
259 | 246 | ||
260 | usb_to_input_id(udev, &xpad->dev.id); | 247 | input_dev->name = xpad_device[i].name; |
261 | xpad->dev.dev = &intf->dev; | 248 | input_dev->phys = xpad->phys; |
262 | xpad->dev.private = xpad; | 249 | usb_to_input_id(udev, &input_dev->id); |
263 | xpad->dev.name = xpad_device[i].name; | 250 | input_dev->cdev.dev = &intf->dev; |
264 | xpad->dev.phys = xpad->phys; | 251 | input_dev->private = xpad; |
265 | xpad->dev.open = xpad_open; | 252 | input_dev->open = xpad_open; |
266 | xpad->dev.close = xpad_close; | 253 | input_dev->close = xpad_close; |
267 | |||
268 | usb_make_path(udev, path, 64); | ||
269 | snprintf(xpad->phys, 64, "%s/input0", path); | ||
270 | 254 | ||
271 | xpad->dev.evbit[0] = BIT(EV_KEY) | BIT(EV_ABS); | 255 | input_dev->evbit[0] = BIT(EV_KEY) | BIT(EV_ABS); |
272 | 256 | ||
273 | for (i = 0; xpad_btn[i] >= 0; i++) | 257 | for (i = 0; xpad_btn[i] >= 0; i++) |
274 | set_bit(xpad_btn[i], xpad->dev.keybit); | 258 | set_bit(xpad_btn[i], input_dev->keybit); |
275 | 259 | ||
276 | for (i = 0; xpad_abs[i] >= 0; i++) { | 260 | for (i = 0; xpad_abs[i] >= 0; i++) { |
277 | 261 | ||
278 | signed short t = xpad_abs[i]; | 262 | signed short t = xpad_abs[i]; |
279 | 263 | ||
280 | set_bit(t, xpad->dev.absbit); | 264 | set_bit(t, input_dev->absbit); |
281 | 265 | ||
282 | switch (t) { | 266 | switch (t) { |
283 | case ABS_X: | 267 | case ABS_X: |
284 | case ABS_Y: | 268 | case ABS_Y: |
285 | case ABS_RX: | 269 | case ABS_RX: |
286 | case ABS_RY: /* the two sticks */ | 270 | case ABS_RY: /* the two sticks */ |
287 | xpad->dev.absmax[t] = 32767; | 271 | input_set_abs_params(input_dev, t, -32768, 32767, 16, 128); |
288 | xpad->dev.absmin[t] = -32768; | ||
289 | xpad->dev.absflat[t] = 128; | ||
290 | xpad->dev.absfuzz[t] = 16; | ||
291 | break; | 272 | break; |
292 | case ABS_Z: | 273 | case ABS_Z: |
293 | case ABS_RZ: /* the triggers */ | 274 | case ABS_RZ: /* the triggers */ |
294 | xpad->dev.absmax[t] = 255; | 275 | input_set_abs_params(input_dev, t, 0, 255, 0, 0); |
295 | xpad->dev.absmin[t] = 0; | ||
296 | break; | 276 | break; |
297 | case ABS_HAT0X: | 277 | case ABS_HAT0X: |
298 | case ABS_HAT0Y: /* the d-pad */ | 278 | case ABS_HAT0Y: /* the d-pad */ |
299 | xpad->dev.absmax[t] = 1; | 279 | input_set_abs_params(input_dev, t, -1, 1, 0, 0); |
300 | xpad->dev.absmin[t] = -1; | ||
301 | break; | 280 | break; |
302 | } | 281 | } |
303 | } | 282 | } |
304 | 283 | ||
305 | input_register_device(&xpad->dev); | 284 | ep_irq_in = &intf->cur_altsetting->endpoint[0].desc; |
285 | usb_fill_int_urb(xpad->irq_in, udev, | ||
286 | usb_rcvintpipe(udev, ep_irq_in->bEndpointAddress), | ||
287 | xpad->idata, XPAD_PKT_LEN, xpad_irq_in, | ||
288 | xpad, ep_irq_in->bInterval); | ||
289 | xpad->irq_in->transfer_dma = xpad->idata_dma; | ||
290 | xpad->irq_in->transfer_flags |= URB_NO_TRANSFER_DMA_MAP; | ||
306 | 291 | ||
307 | printk(KERN_INFO "input: %s on %s", xpad->dev.name, path); | 292 | input_register_device(xpad->dev); |
308 | 293 | ||
309 | usb_set_intfdata(intf, xpad); | 294 | usb_set_intfdata(intf, xpad); |
310 | return 0; | 295 | return 0; |
296 | |||
297 | fail2: usb_buffer_free(udev, XPAD_PKT_LEN, xpad->idata, xpad->idata_dma); | ||
298 | fail1: input_free_device(input_dev); | ||
299 | kfree(xpad); | ||
300 | return -ENOMEM; | ||
301 | |||
311 | } | 302 | } |
312 | 303 | ||
313 | static void xpad_disconnect(struct usb_interface *intf) | 304 | static void xpad_disconnect(struct usb_interface *intf) |
@@ -317,7 +308,7 @@ static void xpad_disconnect(struct usb_interface *intf) | |||
317 | usb_set_intfdata(intf, NULL); | 308 | usb_set_intfdata(intf, NULL); |
318 | if (xpad) { | 309 | if (xpad) { |
319 | usb_kill_urb(xpad->irq_in); | 310 | usb_kill_urb(xpad->irq_in); |
320 | input_unregister_device(&xpad->dev); | 311 | input_unregister_device(xpad->dev); |
321 | usb_free_urb(xpad->irq_in); | 312 | usb_free_urb(xpad->irq_in); |
322 | usb_buffer_free(interface_to_usbdev(intf), XPAD_PKT_LEN, xpad->idata, xpad->idata_dma); | 313 | usb_buffer_free(interface_to_usbdev(intf), XPAD_PKT_LEN, xpad->idata, xpad->idata_dma); |
323 | kfree(xpad); | 314 | kfree(xpad); |
diff --git a/drivers/usb/input/yealink.c b/drivers/usb/input/yealink.c index 58a176ef96a5..f526aebea502 100644 --- a/drivers/usb/input/yealink.c +++ b/drivers/usb/input/yealink.c | |||
@@ -54,6 +54,7 @@ | |||
54 | #include <linux/module.h> | 54 | #include <linux/module.h> |
55 | #include <linux/rwsem.h> | 55 | #include <linux/rwsem.h> |
56 | #include <linux/usb.h> | 56 | #include <linux/usb.h> |
57 | #include <linux/usb_input.h> | ||
57 | 58 | ||
58 | #include "map_to_7segment.h" | 59 | #include "map_to_7segment.h" |
59 | #include "yealink.h" | 60 | #include "yealink.h" |
@@ -101,12 +102,12 @@ static const struct lcd_segment_map { | |||
101 | }; | 102 | }; |
102 | 103 | ||
103 | struct yealink_dev { | 104 | struct yealink_dev { |
104 | struct input_dev idev; /* input device */ | 105 | struct input_dev *idev; /* input device */ |
105 | struct usb_device *udev; /* usb device */ | 106 | struct usb_device *udev; /* usb device */ |
106 | 107 | ||
107 | /* irq input channel */ | 108 | /* irq input channel */ |
108 | struct yld_ctl_packet *irq_data; | 109 | struct yld_ctl_packet *irq_data; |
109 | dma_addr_t irq_dma; | 110 | dma_addr_t irq_dma; |
110 | struct urb *urb_irq; | 111 | struct urb *urb_irq; |
111 | 112 | ||
112 | /* control output channel */ | 113 | /* control output channel */ |
@@ -237,7 +238,7 @@ static int map_p1k_to_key(int scancode) | |||
237 | */ | 238 | */ |
238 | static void report_key(struct yealink_dev *yld, int key, struct pt_regs *regs) | 239 | static void report_key(struct yealink_dev *yld, int key, struct pt_regs *regs) |
239 | { | 240 | { |
240 | struct input_dev *idev = &yld->idev; | 241 | struct input_dev *idev = yld->idev; |
241 | 242 | ||
242 | input_regs(idev, regs); | 243 | input_regs(idev, regs); |
243 | if (yld->key_code >= 0) { | 244 | if (yld->key_code >= 0) { |
@@ -809,8 +810,12 @@ static int usb_cleanup(struct yealink_dev *yld, int err) | |||
809 | } | 810 | } |
810 | if (yld->urb_ctl) | 811 | if (yld->urb_ctl) |
811 | usb_free_urb(yld->urb_ctl); | 812 | usb_free_urb(yld->urb_ctl); |
812 | if (yld->idev.dev) | 813 | if (yld->idev) { |
813 | input_unregister_device(&yld->idev); | 814 | if (err) |
815 | input_free_device(yld->idev); | ||
816 | else | ||
817 | input_unregister_device(yld->idev); | ||
818 | } | ||
814 | if (yld->ctl_req) | 819 | if (yld->ctl_req) |
815 | usb_buffer_free(yld->udev, sizeof(*(yld->ctl_req)), | 820 | usb_buffer_free(yld->udev, sizeof(*(yld->ctl_req)), |
816 | yld->ctl_req, yld->ctl_req_dma); | 821 | yld->ctl_req, yld->ctl_req_dma); |
@@ -857,7 +862,7 @@ static int usb_probe(struct usb_interface *intf, const struct usb_device_id *id) | |||
857 | struct usb_host_interface *interface; | 862 | struct usb_host_interface *interface; |
858 | struct usb_endpoint_descriptor *endpoint; | 863 | struct usb_endpoint_descriptor *endpoint; |
859 | struct yealink_dev *yld; | 864 | struct yealink_dev *yld; |
860 | char path[64]; | 865 | struct input_dev *input_dev; |
861 | int ret, pipe, i; | 866 | int ret, pipe, i; |
862 | 867 | ||
863 | i = usb_match(udev); | 868 | i = usb_match(udev); |
@@ -866,17 +871,21 @@ static int usb_probe(struct usb_interface *intf, const struct usb_device_id *id) | |||
866 | 871 | ||
867 | interface = intf->cur_altsetting; | 872 | interface = intf->cur_altsetting; |
868 | endpoint = &interface->endpoint[0].desc; | 873 | endpoint = &interface->endpoint[0].desc; |
869 | if (!(endpoint->bEndpointAddress & 0x80)) | 874 | if (!(endpoint->bEndpointAddress & USB_DIR_IN)) |
870 | return -EIO; | 875 | return -EIO; |
871 | if ((endpoint->bmAttributes & 3) != 3) | 876 | if ((endpoint->bmAttributes & USB_ENDPOINT_XFERTYPE_MASK) != USB_ENDPOINT_XFER_INT) |
872 | return -EIO; | 877 | return -EIO; |
873 | 878 | ||
874 | if ((yld = kmalloc(sizeof(struct yealink_dev), GFP_KERNEL)) == NULL) | 879 | yld = kzalloc(sizeof(struct yealink_dev), GFP_KERNEL); |
880 | if (!yld) | ||
875 | return -ENOMEM; | 881 | return -ENOMEM; |
876 | 882 | ||
877 | memset(yld, 0, sizeof(*yld)); | ||
878 | yld->udev = udev; | 883 | yld->udev = udev; |
879 | 884 | ||
885 | yld->idev = input_dev = input_allocate_device(); | ||
886 | if (!input_dev) | ||
887 | return usb_cleanup(yld, -ENOMEM); | ||
888 | |||
880 | /* allocate usb buffers */ | 889 | /* allocate usb buffers */ |
881 | yld->irq_data = usb_buffer_alloc(udev, USB_PKT_LEN, | 890 | yld->irq_data = usb_buffer_alloc(udev, USB_PKT_LEN, |
882 | SLAB_ATOMIC, &yld->irq_dma); | 891 | SLAB_ATOMIC, &yld->irq_dma); |
@@ -935,42 +944,37 @@ static int usb_probe(struct usb_interface *intf, const struct usb_device_id *id) | |||
935 | yld->urb_ctl->dev = udev; | 944 | yld->urb_ctl->dev = udev; |
936 | 945 | ||
937 | /* find out the physical bus location */ | 946 | /* find out the physical bus location */ |
938 | if (usb_make_path(udev, path, sizeof(path)) > 0) | 947 | usb_make_path(udev, yld->phys, sizeof(yld->phys)); |
939 | snprintf(yld->phys, sizeof(yld->phys)-1, "%s/input0", path); | 948 | strlcat(yld->phys, "/input0", sizeof(yld->phys)); |
940 | 949 | ||
941 | /* register settings for the input device */ | 950 | /* register settings for the input device */ |
942 | init_input_dev(&yld->idev); | 951 | input_dev->name = yld_device[i].name; |
943 | yld->idev.private = yld; | 952 | input_dev->phys = yld->phys; |
944 | yld->idev.id.bustype = BUS_USB; | 953 | usb_to_input_id(udev, &input_dev->id); |
945 | yld->idev.id.vendor = le16_to_cpu(udev->descriptor.idVendor); | 954 | input_dev->cdev.dev = &intf->dev; |
946 | yld->idev.id.product = le16_to_cpu(udev->descriptor.idProduct); | 955 | |
947 | yld->idev.id.version = le16_to_cpu(udev->descriptor.bcdDevice); | 956 | input_dev->private = yld; |
948 | yld->idev.dev = &intf->dev; | 957 | input_dev->open = input_open; |
949 | yld->idev.name = yld_device[i].name; | 958 | input_dev->close = input_close; |
950 | yld->idev.phys = yld->phys; | 959 | /* input_dev->event = input_ev; TODO */ |
951 | /* yld->idev.event = input_ev; TODO */ | ||
952 | yld->idev.open = input_open; | ||
953 | yld->idev.close = input_close; | ||
954 | 960 | ||
955 | /* register available key events */ | 961 | /* register available key events */ |
956 | yld->idev.evbit[0] = BIT(EV_KEY); | 962 | input_dev->evbit[0] = BIT(EV_KEY); |
957 | for (i = 0; i < 256; i++) { | 963 | for (i = 0; i < 256; i++) { |
958 | int k = map_p1k_to_key(i); | 964 | int k = map_p1k_to_key(i); |
959 | if (k >= 0) { | 965 | if (k >= 0) { |
960 | set_bit(k & 0xff, yld->idev.keybit); | 966 | set_bit(k & 0xff, input_dev->keybit); |
961 | if (k >> 8) | 967 | if (k >> 8) |
962 | set_bit(k >> 8, yld->idev.keybit); | 968 | set_bit(k >> 8, input_dev->keybit); |
963 | } | 969 | } |
964 | } | 970 | } |
965 | 971 | ||
966 | printk(KERN_INFO "input: %s on %s\n", yld->idev.name, path); | 972 | input_register_device(yld->idev); |
967 | |||
968 | input_register_device(&yld->idev); | ||
969 | 973 | ||
970 | usb_set_intfdata(intf, yld); | 974 | usb_set_intfdata(intf, yld); |
971 | 975 | ||
972 | /* clear visible elements */ | 976 | /* clear visible elements */ |
973 | for (i=0; i<ARRAY_SIZE(lcdMap); i++) | 977 | for (i = 0; i < ARRAY_SIZE(lcdMap); i++) |
974 | setChar(yld, i, ' '); | 978 | setChar(yld, i, ' '); |
975 | 979 | ||
976 | /* display driver version on LCD line 3 */ | 980 | /* display driver version on LCD line 3 */ |
diff --git a/drivers/usb/media/dabusb.c b/drivers/usb/media/dabusb.c index 6ca2fae99d2d..27b23c55bbc7 100644 --- a/drivers/usb/media/dabusb.c +++ b/drivers/usb/media/dabusb.c | |||
@@ -707,9 +707,8 @@ static struct file_operations dabusb_fops = | |||
707 | }; | 707 | }; |
708 | 708 | ||
709 | static struct usb_class_driver dabusb_class = { | 709 | static struct usb_class_driver dabusb_class = { |
710 | .name = "usb/dabusb%d", | 710 | .name = "dabusb%d", |
711 | .fops = &dabusb_fops, | 711 | .fops = &dabusb_fops, |
712 | .mode = S_IFCHR | S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP, | ||
713 | .minor_base = DABUSB_MINOR, | 712 | .minor_base = DABUSB_MINOR, |
714 | }; | 713 | }; |
715 | 714 | ||
diff --git a/drivers/usb/media/konicawc.c b/drivers/usb/media/konicawc.c index 20ac9e1069d4..9fe2c2710d13 100644 --- a/drivers/usb/media/konicawc.c +++ b/drivers/usb/media/konicawc.c | |||
@@ -119,7 +119,7 @@ struct konicawc { | |||
119 | int yplanesz; /* Number of bytes in the Y plane */ | 119 | int yplanesz; /* Number of bytes in the Y plane */ |
120 | unsigned int buttonsts:1; | 120 | unsigned int buttonsts:1; |
121 | #ifdef CONFIG_INPUT | 121 | #ifdef CONFIG_INPUT |
122 | struct input_dev input; | 122 | struct input_dev *input; |
123 | char input_physname[64]; | 123 | char input_physname[64]; |
124 | #endif | 124 | #endif |
125 | }; | 125 | }; |
@@ -218,6 +218,57 @@ static void konicawc_adjust_picture(struct uvd *uvd) | |||
218 | konicawc_camera_on(uvd); | 218 | konicawc_camera_on(uvd); |
219 | } | 219 | } |
220 | 220 | ||
221 | #ifdef CONFIG_INPUT | ||
222 | |||
223 | static void konicawc_register_input(struct konicawc *cam, struct usb_device *dev) | ||
224 | { | ||
225 | struct input_dev *input_dev; | ||
226 | |||
227 | usb_make_path(dev, cam->input_physname, sizeof(cam->input_physname)); | ||
228 | strncat(cam->input_physname, "/input0", sizeof(cam->input_physname)); | ||
229 | |||
230 | cam->input = input_dev = input_allocate_device(); | ||
231 | if (!input_dev) { | ||
232 | warn("Not enough memory for camera's input device\n"); | ||
233 | return; | ||
234 | } | ||
235 | |||
236 | input_dev->name = "Konicawc snapshot button"; | ||
237 | input_dev->phys = cam->input_physname; | ||
238 | usb_to_input_id(dev, &input_dev->id); | ||
239 | input_dev->cdev.dev = &dev->dev; | ||
240 | |||
241 | input_dev->evbit[0] = BIT(EV_KEY); | ||
242 | input_dev->keybit[LONG(BTN_0)] = BIT(BTN_0); | ||
243 | |||
244 | input_dev->private = cam; | ||
245 | |||
246 | input_register_device(cam->input); | ||
247 | } | ||
248 | |||
249 | static void konicawc_unregister_input(struct konicawc *cam) | ||
250 | { | ||
251 | if (cam->input) { | ||
252 | input_unregister_device(cam->input); | ||
253 | cam->input = NULL; | ||
254 | } | ||
255 | } | ||
256 | |||
257 | static void konicawc_report_buttonstat(struct konicawc *cam) | ||
258 | { | ||
259 | if (cam->input) { | ||
260 | input_report_key(cam->input, BTN_0, cam->buttonsts); | ||
261 | input_sync(cam->input); | ||
262 | } | ||
263 | } | ||
264 | |||
265 | #else | ||
266 | |||
267 | static inline void konicawc_register_input(struct konicawc *cam, struct usb_device *dev) { } | ||
268 | static inline void konicawc_unregister_input(struct konicawc *cam) { } | ||
269 | static inline void konicawc_report_buttonstat(struct konicawc *cam) { } | ||
270 | |||
271 | #endif /* CONFIG_INPUT */ | ||
221 | 272 | ||
222 | static int konicawc_compress_iso(struct uvd *uvd, struct urb *dataurb, struct urb *stsurb) | 273 | static int konicawc_compress_iso(struct uvd *uvd, struct urb *dataurb, struct urb *stsurb) |
223 | { | 274 | { |
@@ -273,10 +324,7 @@ static int konicawc_compress_iso(struct uvd *uvd, struct urb *dataurb, struct ur | |||
273 | if(button != cam->buttonsts) { | 324 | if(button != cam->buttonsts) { |
274 | DEBUG(2, "button: %sclicked", button ? "" : "un"); | 325 | DEBUG(2, "button: %sclicked", button ? "" : "un"); |
275 | cam->buttonsts = button; | 326 | cam->buttonsts = button; |
276 | #ifdef CONFIG_INPUT | 327 | konicawc_report_buttonstat(cam); |
277 | input_report_key(&cam->input, BTN_0, cam->buttonsts); | ||
278 | input_sync(&cam->input); | ||
279 | #endif | ||
280 | } | 328 | } |
281 | 329 | ||
282 | if(sts == 0x01) { /* drop frame */ | 330 | if(sts == 0x01) { /* drop frame */ |
@@ -645,9 +693,9 @@ static int konicawc_set_video_mode(struct uvd *uvd, struct video_window *vw) | |||
645 | RingQueue_Flush(&uvd->dp); | 693 | RingQueue_Flush(&uvd->dp); |
646 | cam->lastframe = -2; | 694 | cam->lastframe = -2; |
647 | if(uvd->curframe != -1) { | 695 | if(uvd->curframe != -1) { |
648 | uvd->frame[uvd->curframe].curline = 0; | 696 | uvd->frame[uvd->curframe].curline = 0; |
649 | uvd->frame[uvd->curframe].seqRead_Length = 0; | 697 | uvd->frame[uvd->curframe].seqRead_Length = 0; |
650 | uvd->frame[uvd->curframe].seqRead_Index = 0; | 698 | uvd->frame[uvd->curframe].seqRead_Index = 0; |
651 | } | 699 | } |
652 | 700 | ||
653 | konicawc_start_data(uvd); | 701 | konicawc_start_data(uvd); |
@@ -718,7 +766,6 @@ static void konicawc_configure_video(struct uvd *uvd) | |||
718 | DEBUG(1, "setting initial values"); | 766 | DEBUG(1, "setting initial values"); |
719 | } | 767 | } |
720 | 768 | ||
721 | |||
722 | static int konicawc_probe(struct usb_interface *intf, const struct usb_device_id *devid) | 769 | static int konicawc_probe(struct usb_interface *intf, const struct usb_device_id *devid) |
723 | { | 770 | { |
724 | struct usb_device *dev = interface_to_usbdev(intf); | 771 | struct usb_device *dev = interface_to_usbdev(intf); |
@@ -839,21 +886,8 @@ static int konicawc_probe(struct usb_interface *intf, const struct usb_device_id | |||
839 | err("usbvideo_RegisterVideoDevice() failed."); | 886 | err("usbvideo_RegisterVideoDevice() failed."); |
840 | uvd = NULL; | 887 | uvd = NULL; |
841 | } | 888 | } |
842 | #ifdef CONFIG_INPUT | 889 | |
843 | /* Register input device for button */ | 890 | konicawc_register_input(cam, dev); |
844 | memset(&cam->input, 0, sizeof(struct input_dev)); | ||
845 | cam->input.name = "Konicawc snapshot button"; | ||
846 | cam->input.private = cam; | ||
847 | cam->input.evbit[0] = BIT(EV_KEY); | ||
848 | cam->input.keybit[LONG(BTN_0)] = BIT(BTN_0); | ||
849 | usb_to_input_id(dev, &cam->input.id); | ||
850 | input_register_device(&cam->input); | ||
851 | |||
852 | usb_make_path(dev, cam->input_physname, 56); | ||
853 | strcat(cam->input_physname, "/input0"); | ||
854 | cam->input.phys = cam->input_physname; | ||
855 | info("konicawc: %s on %s\n", cam->input.name, cam->input.phys); | ||
856 | #endif | ||
857 | } | 891 | } |
858 | 892 | ||
859 | if (uvd) { | 893 | if (uvd) { |
@@ -869,10 +903,9 @@ static void konicawc_free_uvd(struct uvd *uvd) | |||
869 | int i; | 903 | int i; |
870 | struct konicawc *cam = (struct konicawc *)uvd->user_data; | 904 | struct konicawc *cam = (struct konicawc *)uvd->user_data; |
871 | 905 | ||
872 | #ifdef CONFIG_INPUT | 906 | konicawc_unregister_input(cam); |
873 | input_unregister_device(&cam->input); | 907 | |
874 | #endif | 908 | for (i = 0; i < USBVIDEO_NUMSBUF; i++) { |
875 | for (i=0; i < USBVIDEO_NUMSBUF; i++) { | ||
876 | usb_free_urb(cam->sts_urb[i]); | 909 | usb_free_urb(cam->sts_urb[i]); |
877 | cam->sts_urb[i] = NULL; | 910 | cam->sts_urb[i] = NULL; |
878 | } | 911 | } |
diff --git a/drivers/usb/media/pwc/pwc-if.c b/drivers/usb/media/pwc/pwc-if.c index b77e65c03659..5524fd70210b 100644 --- a/drivers/usb/media/pwc/pwc-if.c +++ b/drivers/usb/media/pwc/pwc-if.c | |||
@@ -62,6 +62,7 @@ | |||
62 | #include <linux/poll.h> | 62 | #include <linux/poll.h> |
63 | #include <linux/slab.h> | 63 | #include <linux/slab.h> |
64 | #include <linux/vmalloc.h> | 64 | #include <linux/vmalloc.h> |
65 | #include <linux/version.h> | ||
65 | #include <asm/io.h> | 66 | #include <asm/io.h> |
66 | 67 | ||
67 | #include "pwc.h" | 68 | #include "pwc.h" |
diff --git a/drivers/usb/media/pwc/pwc.h b/drivers/usb/media/pwc/pwc.h index 267869dab185..6dd76bb3dff1 100644 --- a/drivers/usb/media/pwc/pwc.h +++ b/drivers/usb/media/pwc/pwc.h | |||
@@ -25,8 +25,6 @@ | |||
25 | #ifndef PWC_H | 25 | #ifndef PWC_H |
26 | #define PWC_H | 26 | #define PWC_H |
27 | 27 | ||
28 | #include <linux/version.h> | ||
29 | |||
30 | #include <linux/config.h> | 28 | #include <linux/config.h> |
31 | #include <linux/module.h> | 29 | #include <linux/module.h> |
32 | #include <linux/usb.h> | 30 | #include <linux/usb.h> |
diff --git a/drivers/usb/media/sn9c102_core.c b/drivers/usb/media/sn9c102_core.c index cf8cfbabefde..b2e66e3b90aa 100644 --- a/drivers/usb/media/sn9c102_core.c +++ b/drivers/usb/media/sn9c102_core.c | |||
@@ -199,7 +199,7 @@ static void sn9c102_release_buffers(struct sn9c102_device* cam) | |||
199 | { | 199 | { |
200 | if (cam->nbuffers) { | 200 | if (cam->nbuffers) { |
201 | rvfree(cam->frame[0].bufmem, | 201 | rvfree(cam->frame[0].bufmem, |
202 | cam->nbuffers * cam->frame[0].buf.length); | 202 | cam->nbuffers * PAGE_ALIGN(cam->frame[0].buf.length)); |
203 | cam->nbuffers = 0; | 203 | cam->nbuffers = 0; |
204 | } | 204 | } |
205 | } | 205 | } |
diff --git a/drivers/usb/media/vicam.c b/drivers/usb/media/vicam.c index 4a5857c53f11..0bc0b1247a6b 100644 --- a/drivers/usb/media/vicam.c +++ b/drivers/usb/media/vicam.c | |||
@@ -1148,7 +1148,7 @@ vicam_write_proc_gain(struct file *file, const char *buffer, | |||
1148 | static void | 1148 | static void |
1149 | vicam_create_proc_root(void) | 1149 | vicam_create_proc_root(void) |
1150 | { | 1150 | { |
1151 | vicam_proc_root = create_proc_entry("video/vicam", S_IFDIR, 0); | 1151 | vicam_proc_root = proc_mkdir("video/vicam", NULL); |
1152 | 1152 | ||
1153 | if (vicam_proc_root) | 1153 | if (vicam_proc_root) |
1154 | vicam_proc_root->owner = THIS_MODULE; | 1154 | vicam_proc_root->owner = THIS_MODULE; |
@@ -1181,7 +1181,7 @@ vicam_create_proc_entry(struct vicam_camera *cam) | |||
1181 | 1181 | ||
1182 | sprintf(name, "video%d", cam->vdev.minor); | 1182 | sprintf(name, "video%d", cam->vdev.minor); |
1183 | 1183 | ||
1184 | cam->proc_dir = create_proc_entry(name, S_IFDIR, vicam_proc_root); | 1184 | cam->proc_dir = proc_mkdir(name, vicam_proc_root); |
1185 | 1185 | ||
1186 | if ( !cam->proc_dir ) | 1186 | if ( !cam->proc_dir ) |
1187 | return; // FIXME: We should probably return an error here | 1187 | return; // FIXME: We should probably return an error here |
diff --git a/drivers/usb/media/w9968cf.c b/drivers/usb/media/w9968cf.c index f36c0b6c6e36..67612c81cb9f 100644 --- a/drivers/usb/media/w9968cf.c +++ b/drivers/usb/media/w9968cf.c | |||
@@ -25,7 +25,6 @@ | |||
25 | * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. * | 25 | * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. * |
26 | ***************************************************************************/ | 26 | ***************************************************************************/ |
27 | 27 | ||
28 | #include <linux/version.h> | ||
29 | #include <linux/module.h> | 28 | #include <linux/module.h> |
30 | #include <linux/kernel.h> | 29 | #include <linux/kernel.h> |
31 | #include <linux/kmod.h> | 30 | #include <linux/kmod.h> |
diff --git a/drivers/usb/misc/Makefile b/drivers/usb/misc/Makefile index 862e40a83689..6c693bc68e2e 100644 --- a/drivers/usb/misc/Makefile +++ b/drivers/usb/misc/Makefile | |||
@@ -18,4 +18,8 @@ obj-$(CONFIG_USB_RIO500) += rio500.o | |||
18 | obj-$(CONFIG_USB_TEST) += usbtest.o | 18 | obj-$(CONFIG_USB_TEST) += usbtest.o |
19 | obj-$(CONFIG_USB_USS720) += uss720.o | 19 | obj-$(CONFIG_USB_USS720) += uss720.o |
20 | 20 | ||
21 | obj-$(CONFIG_USB_SISUSBVGA) += sisusbvga/ \ No newline at end of file | 21 | obj-$(CONFIG_USB_SISUSBVGA) += sisusbvga/ |
22 | |||
23 | ifeq ($(CONFIG_USB_DEBUG),y) | ||
24 | EXTRA_CFLAGS += -DDEBUG | ||
25 | endif | ||
diff --git a/drivers/usb/misc/auerswald.c b/drivers/usb/misc/auerswald.c index ae4681f9f0ea..2a28ceeaa66a 100644 --- a/drivers/usb/misc/auerswald.c +++ b/drivers/usb/misc/auerswald.c | |||
@@ -30,7 +30,6 @@ | |||
30 | #include <linux/module.h> | 30 | #include <linux/module.h> |
31 | #include <linux/init.h> | 31 | #include <linux/init.h> |
32 | #include <linux/wait.h> | 32 | #include <linux/wait.h> |
33 | #undef DEBUG /* include debug macros until it's done */ | ||
34 | #include <linux/usb.h> | 33 | #include <linux/usb.h> |
35 | 34 | ||
36 | /*-------------------------------------------------------------------*/ | 35 | /*-------------------------------------------------------------------*/ |
@@ -1873,9 +1872,8 @@ static struct file_operations auerswald_fops = | |||
1873 | }; | 1872 | }; |
1874 | 1873 | ||
1875 | static struct usb_class_driver auerswald_class = { | 1874 | static struct usb_class_driver auerswald_class = { |
1876 | .name = "usb/auer%d", | 1875 | .name = "auer%d", |
1877 | .fops = &auerswald_fops, | 1876 | .fops = &auerswald_fops, |
1878 | .mode = S_IFCHR | S_IRUGO | S_IWUGO, | ||
1879 | .minor_base = AUER_MINOR_BASE, | 1877 | .minor_base = AUER_MINOR_BASE, |
1880 | }; | 1878 | }; |
1881 | 1879 | ||
diff --git a/drivers/usb/misc/idmouse.c b/drivers/usb/misc/idmouse.c index 733acc213726..1dc3e0f73014 100644 --- a/drivers/usb/misc/idmouse.c +++ b/drivers/usb/misc/idmouse.c | |||
@@ -105,11 +105,10 @@ static struct file_operations idmouse_fops = { | |||
105 | .release = idmouse_release, | 105 | .release = idmouse_release, |
106 | }; | 106 | }; |
107 | 107 | ||
108 | /* class driver information for devfs */ | 108 | /* class driver information */ |
109 | static struct usb_class_driver idmouse_class = { | 109 | static struct usb_class_driver idmouse_class = { |
110 | .name = "usb/idmouse%d", | 110 | .name = "idmouse%d", |
111 | .fops = &idmouse_fops, | 111 | .fops = &idmouse_fops, |
112 | .mode = S_IFCHR | S_IRUSR | S_IRGRP | S_IROTH, /* filemode (char, 444) */ | ||
113 | .minor_base = USB_IDMOUSE_MINOR_BASE, | 112 | .minor_base = USB_IDMOUSE_MINOR_BASE, |
114 | }; | 113 | }; |
115 | 114 | ||
@@ -320,20 +319,8 @@ static ssize_t idmouse_read(struct file *file, char __user *buffer, size_t count | |||
320 | return -ENODEV; | 319 | return -ENODEV; |
321 | } | 320 | } |
322 | 321 | ||
323 | if (*ppos >= IMGSIZE) { | 322 | result = simple_read_from_buffer(buffer, count, ppos, |
324 | up (&dev->sem); | 323 | dev->bulk_in_buffer, IMGSIZE); |
325 | return 0; | ||
326 | } | ||
327 | |||
328 | count = min ((loff_t)count, IMGSIZE - (*ppos)); | ||
329 | |||
330 | if (copy_to_user (buffer, dev->bulk_in_buffer + *ppos, count)) { | ||
331 | result = -EFAULT; | ||
332 | } else { | ||
333 | result = count; | ||
334 | *ppos += count; | ||
335 | } | ||
336 | |||
337 | /* unlock the device */ | 324 | /* unlock the device */ |
338 | up(&dev->sem); | 325 | up(&dev->sem); |
339 | return result; | 326 | return result; |
diff --git a/drivers/usb/misc/legousbtower.c b/drivers/usb/misc/legousbtower.c index 7d06105763d4..2703e205bc8f 100644 --- a/drivers/usb/misc/legousbtower.c +++ b/drivers/usb/misc/legousbtower.c | |||
@@ -271,12 +271,11 @@ static struct file_operations tower_fops = { | |||
271 | 271 | ||
272 | /* | 272 | /* |
273 | * usb class driver info in order to get a minor number from the usb core, | 273 | * usb class driver info in order to get a minor number from the usb core, |
274 | * and to have the device registered with devfs and the driver core | 274 | * and to have the device registered with the driver core |
275 | */ | 275 | */ |
276 | static struct usb_class_driver tower_class = { | 276 | static struct usb_class_driver tower_class = { |
277 | .name = "usb/legousbtower%d", | 277 | .name = "legousbtower%d", |
278 | .fops = &tower_fops, | 278 | .fops = &tower_fops, |
279 | .mode = S_IFCHR | S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP | S_IROTH, | ||
280 | .minor_base = LEGO_USB_TOWER_MINOR_BASE, | 279 | .minor_base = LEGO_USB_TOWER_MINOR_BASE, |
281 | }; | 280 | }; |
282 | 281 | ||
diff --git a/drivers/usb/misc/phidgetservo.c b/drivers/usb/misc/phidgetservo.c index b84eda631ab5..a30d4a6ee824 100644 --- a/drivers/usb/misc/phidgetservo.c +++ b/drivers/usb/misc/phidgetservo.c | |||
@@ -26,9 +26,6 @@ | |||
26 | */ | 26 | */ |
27 | 27 | ||
28 | #include <linux/config.h> | 28 | #include <linux/config.h> |
29 | #ifdef CONFIG_USB_DEBUG | ||
30 | #define DEBUG 1 | ||
31 | #endif | ||
32 | #include <linux/kernel.h> | 29 | #include <linux/kernel.h> |
33 | #include <linux/errno.h> | 30 | #include <linux/errno.h> |
34 | #include <linux/init.h> | 31 | #include <linux/init.h> |
diff --git a/drivers/usb/misc/rio500.c b/drivers/usb/misc/rio500.c index 26f77e29c7a6..9590dbac5d9a 100644 --- a/drivers/usb/misc/rio500.c +++ b/drivers/usb/misc/rio500.c | |||
@@ -393,7 +393,7 @@ read_rio(struct file *file, char __user *buffer, size_t count, loff_t * ppos) | |||
393 | ibuf, this_read, &partial, | 393 | ibuf, this_read, &partial, |
394 | 8000); | 394 | 8000); |
395 | 395 | ||
396 | dbg(KERN_DEBUG "read stats: result:%d this_read:%u partial:%u", | 396 | dbg("read stats: result:%d this_read:%u partial:%u", |
397 | result, this_read, partial); | 397 | result, this_read, partial); |
398 | 398 | ||
399 | if (partial) { | 399 | if (partial) { |
@@ -443,9 +443,8 @@ file_operations usb_rio_fops = { | |||
443 | }; | 443 | }; |
444 | 444 | ||
445 | static struct usb_class_driver usb_rio_class = { | 445 | static struct usb_class_driver usb_rio_class = { |
446 | .name = "usb/rio500%d", | 446 | .name = "rio500%d", |
447 | .fops = &usb_rio_fops, | 447 | .fops = &usb_rio_fops, |
448 | .mode = S_IFCHR | S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP, | ||
449 | .minor_base = RIO_MINOR, | 448 | .minor_base = RIO_MINOR, |
450 | }; | 449 | }; |
451 | 450 | ||
diff --git a/drivers/usb/misc/sisusbvga/sisusb.c b/drivers/usb/misc/sisusbvga/sisusb.c index 39db3155723a..41ef2b606751 100644 --- a/drivers/usb/misc/sisusbvga/sisusb.c +++ b/drivers/usb/misc/sisusbvga/sisusb.c | |||
@@ -37,7 +37,6 @@ | |||
37 | */ | 37 | */ |
38 | 38 | ||
39 | #include <linux/config.h> | 39 | #include <linux/config.h> |
40 | #include <linux/version.h> | ||
41 | #include <linux/module.h> | 40 | #include <linux/module.h> |
42 | #include <linux/kernel.h> | 41 | #include <linux/kernel.h> |
43 | #include <linux/signal.h> | 42 | #include <linux/signal.h> |
@@ -2440,7 +2439,7 @@ int | |||
2440 | sisusb_reset_text_mode(struct sisusb_usb_data *sisusb, int init) | 2439 | sisusb_reset_text_mode(struct sisusb_usb_data *sisusb, int init) |
2441 | { | 2440 | { |
2442 | int ret = 0, slot = sisusb->font_slot, i; | 2441 | int ret = 0, slot = sisusb->font_slot, i; |
2443 | struct font_desc *myfont; | 2442 | const struct font_desc *myfont; |
2444 | u8 *tempbuf; | 2443 | u8 *tempbuf; |
2445 | u16 *tempbufb; | 2444 | u16 *tempbufb; |
2446 | size_t written; | 2445 | size_t written; |
@@ -3239,12 +3238,7 @@ static struct file_operations usb_sisusb_fops = { | |||
3239 | }; | 3238 | }; |
3240 | 3239 | ||
3241 | static struct usb_class_driver usb_sisusb_class = { | 3240 | static struct usb_class_driver usb_sisusb_class = { |
3242 | #if LINUX_VERSION_CODE <= KERNEL_VERSION(2,6,13) | ||
3243 | .name = "usb/sisusbvga%d", | ||
3244 | .mode = S_IFCHR | S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP, | ||
3245 | #else | ||
3246 | .name = "sisusbvga%d", | 3241 | .name = "sisusbvga%d", |
3247 | #endif | ||
3248 | .fops = &usb_sisusb_fops, | 3242 | .fops = &usb_sisusb_fops, |
3249 | .minor_base = SISUSB_MINOR | 3243 | .minor_base = SISUSB_MINOR |
3250 | }; | 3244 | }; |
diff --git a/drivers/usb/misc/sisusbvga/sisusb.h b/drivers/usb/misc/sisusbvga/sisusb.h index 401ff21d7881..1d7a77cc7c4a 100644 --- a/drivers/usb/misc/sisusbvga/sisusb.h +++ b/drivers/usb/misc/sisusbvga/sisusb.h | |||
@@ -37,6 +37,7 @@ | |||
37 | #ifndef _SISUSB_H_ | 37 | #ifndef _SISUSB_H_ |
38 | #define _SISUSB_H_ | 38 | #define _SISUSB_H_ |
39 | 39 | ||
40 | #include <linux/version.h> | ||
40 | #ifdef CONFIG_COMPAT | 41 | #ifdef CONFIG_COMPAT |
41 | #if LINUX_VERSION_CODE <= KERNEL_VERSION(2,6,10) | 42 | #if LINUX_VERSION_CODE <= KERNEL_VERSION(2,6,10) |
42 | #include <linux/ioctl32.h> | 43 | #include <linux/ioctl32.h> |
diff --git a/drivers/usb/misc/sisusbvga/sisusb_con.c b/drivers/usb/misc/sisusbvga/sisusb_con.c index 24584463553d..be5c1a25ae21 100644 --- a/drivers/usb/misc/sisusbvga/sisusb_con.c +++ b/drivers/usb/misc/sisusbvga/sisusb_con.c | |||
@@ -48,7 +48,6 @@ | |||
48 | */ | 48 | */ |
49 | 49 | ||
50 | #include <linux/config.h> | 50 | #include <linux/config.h> |
51 | #include <linux/version.h> | ||
52 | #include <linux/module.h> | 51 | #include <linux/module.h> |
53 | #include <linux/kernel.h> | 52 | #include <linux/kernel.h> |
54 | #include <linux/signal.h> | 53 | #include <linux/signal.h> |
diff --git a/drivers/usb/misc/sisusbvga/sisusb_init.c b/drivers/usb/misc/sisusbvga/sisusb_init.c index f28bc240f9b6..044fa4482f9f 100644 --- a/drivers/usb/misc/sisusbvga/sisusb_init.c +++ b/drivers/usb/misc/sisusbvga/sisusb_init.c | |||
@@ -37,7 +37,6 @@ | |||
37 | */ | 37 | */ |
38 | 38 | ||
39 | #include <linux/config.h> | 39 | #include <linux/config.h> |
40 | #include <linux/version.h> | ||
41 | #include <linux/module.h> | 40 | #include <linux/module.h> |
42 | #include <linux/kernel.h> | 41 | #include <linux/kernel.h> |
43 | #include <linux/errno.h> | 42 | #include <linux/errno.h> |
diff --git a/drivers/usb/misc/usblcd.c b/drivers/usb/misc/usblcd.c index 096ab3029676..85f3725334b0 100644 --- a/drivers/usb/misc/usblcd.c +++ b/drivers/usb/misc/usblcd.c | |||
@@ -251,13 +251,12 @@ static struct file_operations lcd_fops = { | |||
251 | }; | 251 | }; |
252 | 252 | ||
253 | /* | 253 | /* |
254 | * * usb class driver info in order to get a minor number from the usb core, | 254 | * usb class driver info in order to get a minor number from the usb core, |
255 | * * and to have the device registered with devfs and the driver core | 255 | * and to have the device registered with the driver core |
256 | * */ | 256 | */ |
257 | static struct usb_class_driver lcd_class = { | 257 | static struct usb_class_driver lcd_class = { |
258 | .name = "usb/lcd%d", | 258 | .name = "lcd%d", |
259 | .fops = &lcd_fops, | 259 | .fops = &lcd_fops, |
260 | .mode = S_IFCHR | S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP | S_IROTH, | ||
261 | .minor_base = USBLCD_MINOR, | 260 | .minor_base = USBLCD_MINOR, |
262 | }; | 261 | }; |
263 | 262 | ||
diff --git a/drivers/usb/misc/usbled.c b/drivers/usb/misc/usbled.c index f6ba4c788dbc..3c93921cb6b3 100644 --- a/drivers/usb/misc/usbled.c +++ b/drivers/usb/misc/usbled.c | |||
@@ -10,9 +10,6 @@ | |||
10 | */ | 10 | */ |
11 | 11 | ||
12 | #include <linux/config.h> | 12 | #include <linux/config.h> |
13 | #ifdef CONFIG_USB_DEBUG | ||
14 | #define DEBUG 1 | ||
15 | #endif | ||
16 | #include <linux/kernel.h> | 13 | #include <linux/kernel.h> |
17 | #include <linux/errno.h> | 14 | #include <linux/errno.h> |
18 | #include <linux/init.h> | 15 | #include <linux/init.h> |
diff --git a/drivers/usb/misc/usbtest.c b/drivers/usb/misc/usbtest.c index 54799eb0bc60..605a2afe34ed 100644 --- a/drivers/usb/misc/usbtest.c +++ b/drivers/usb/misc/usbtest.c | |||
@@ -1,7 +1,4 @@ | |||
1 | #include <linux/config.h> | 1 | #include <linux/config.h> |
2 | #if !defined (DEBUG) && defined (CONFIG_USB_DEBUG) | ||
3 | # define DEBUG | ||
4 | #endif | ||
5 | #include <linux/kernel.h> | 2 | #include <linux/kernel.h> |
6 | #include <linux/errno.h> | 3 | #include <linux/errno.h> |
7 | #include <linux/init.h> | 4 | #include <linux/init.h> |
@@ -9,7 +6,7 @@ | |||
9 | #include <linux/mm.h> | 6 | #include <linux/mm.h> |
10 | #include <linux/module.h> | 7 | #include <linux/module.h> |
11 | #include <linux/moduleparam.h> | 8 | #include <linux/moduleparam.h> |
12 | #include <asm/scatterlist.h> | 9 | #include <linux/scatterlist.h> |
13 | 10 | ||
14 | #include <linux/usb.h> | 11 | #include <linux/usb.h> |
15 | 12 | ||
@@ -381,7 +378,6 @@ alloc_sglist (int nents, int max, int vary) | |||
381 | sg = kmalloc (nents * sizeof *sg, SLAB_KERNEL); | 378 | sg = kmalloc (nents * sizeof *sg, SLAB_KERNEL); |
382 | if (!sg) | 379 | if (!sg) |
383 | return NULL; | 380 | return NULL; |
384 | memset (sg, 0, nents * sizeof *sg); | ||
385 | 381 | ||
386 | for (i = 0; i < nents; i++) { | 382 | for (i = 0; i < nents; i++) { |
387 | char *buf; | 383 | char *buf; |
@@ -394,9 +390,7 @@ alloc_sglist (int nents, int max, int vary) | |||
394 | memset (buf, 0, size); | 390 | memset (buf, 0, size); |
395 | 391 | ||
396 | /* kmalloc pages are always physically contiguous! */ | 392 | /* kmalloc pages are always physically contiguous! */ |
397 | sg [i].page = virt_to_page (buf); | 393 | sg_init_one(&sg[i], buf, size); |
398 | sg [i].offset = offset_in_page (buf); | ||
399 | sg [i].length = size; | ||
400 | 394 | ||
401 | if (vary) { | 395 | if (vary) { |
402 | size += vary; | 396 | size += vary; |
@@ -983,6 +977,7 @@ test_ctrl_queue (struct usbtest_dev *dev, struct usbtest_param *param) | |||
983 | reqp->number = i % NUM_SUBCASES; | 977 | reqp->number = i % NUM_SUBCASES; |
984 | reqp->expected = expected; | 978 | reqp->expected = expected; |
985 | u->setup_packet = (char *) &reqp->setup; | 979 | u->setup_packet = (char *) &reqp->setup; |
980 | u->transfer_flags |= URB_NO_SETUP_DMA_MAP; | ||
986 | 981 | ||
987 | u->context = &context; | 982 | u->context = &context; |
988 | u->complete = ctrl_complete; | 983 | u->complete = ctrl_complete; |
@@ -1948,21 +1943,11 @@ usbtest_probe (struct usb_interface *intf, const struct usb_device_id *id) | |||
1948 | 1943 | ||
1949 | static int usbtest_suspend (struct usb_interface *intf, pm_message_t message) | 1944 | static int usbtest_suspend (struct usb_interface *intf, pm_message_t message) |
1950 | { | 1945 | { |
1951 | struct usbtest_dev *dev = usb_get_intfdata (intf); | ||
1952 | |||
1953 | down (&dev->sem); | ||
1954 | intf->dev.power.power_state = PMSG_SUSPEND; | ||
1955 | up (&dev->sem); | ||
1956 | return 0; | 1946 | return 0; |
1957 | } | 1947 | } |
1958 | 1948 | ||
1959 | static int usbtest_resume (struct usb_interface *intf) | 1949 | static int usbtest_resume (struct usb_interface *intf) |
1960 | { | 1950 | { |
1961 | struct usbtest_dev *dev = usb_get_intfdata (intf); | ||
1962 | |||
1963 | down (&dev->sem); | ||
1964 | intf->dev.power.power_state = PMSG_ON; | ||
1965 | up (&dev->sem); | ||
1966 | return 0; | 1951 | return 0; |
1967 | } | 1952 | } |
1968 | 1953 | ||
diff --git a/drivers/usb/misc/uss720.c b/drivers/usb/misc/uss720.c index 03fb70ef2eb3..1cabe7ed91f5 100644 --- a/drivers/usb/misc/uss720.c +++ b/drivers/usb/misc/uss720.c | |||
@@ -41,8 +41,6 @@ | |||
41 | 41 | ||
42 | /*****************************************************************************/ | 42 | /*****************************************************************************/ |
43 | 43 | ||
44 | #define DEBUG | ||
45 | |||
46 | #include <linux/module.h> | 44 | #include <linux/module.h> |
47 | #include <linux/socket.h> | 45 | #include <linux/socket.h> |
48 | #include <linux/parport.h> | 46 | #include <linux/parport.h> |
@@ -137,7 +135,7 @@ static void async_complete(struct urb *urb, struct pt_regs *ptregs) | |||
137 | 135 | ||
138 | static struct uss720_async_request *submit_async_request(struct parport_uss720_private *priv, | 136 | static struct uss720_async_request *submit_async_request(struct parport_uss720_private *priv, |
139 | __u8 request, __u8 requesttype, __u16 value, __u16 index, | 137 | __u8 request, __u8 requesttype, __u16 value, __u16 index, |
140 | unsigned int mem_flags) | 138 | gfp_t mem_flags) |
141 | { | 139 | { |
142 | struct usb_device *usbdev; | 140 | struct usb_device *usbdev; |
143 | struct uss720_async_request *rq; | 141 | struct uss720_async_request *rq; |
@@ -204,7 +202,7 @@ static unsigned int kill_all_async_requests_priv(struct parport_uss720_private * | |||
204 | 202 | ||
205 | /* --------------------------------------------------------------------- */ | 203 | /* --------------------------------------------------------------------- */ |
206 | 204 | ||
207 | static int get_1284_register(struct parport *pp, unsigned char reg, unsigned char *val, unsigned int mem_flags) | 205 | static int get_1284_register(struct parport *pp, unsigned char reg, unsigned char *val, gfp_t mem_flags) |
208 | { | 206 | { |
209 | struct parport_uss720_private *priv; | 207 | struct parport_uss720_private *priv; |
210 | struct uss720_async_request *rq; | 208 | struct uss720_async_request *rq; |
@@ -238,7 +236,7 @@ static int get_1284_register(struct parport *pp, unsigned char reg, unsigned cha | |||
238 | return -EIO; | 236 | return -EIO; |
239 | } | 237 | } |
240 | 238 | ||
241 | static int set_1284_register(struct parport *pp, unsigned char reg, unsigned char val, unsigned int mem_flags) | 239 | static int set_1284_register(struct parport *pp, unsigned char reg, unsigned char val, gfp_t mem_flags) |
242 | { | 240 | { |
243 | struct parport_uss720_private *priv; | 241 | struct parport_uss720_private *priv; |
244 | struct uss720_async_request *rq; | 242 | struct uss720_async_request *rq; |
diff --git a/drivers/usb/mon/mon_main.c b/drivers/usb/mon/mon_main.c index 508a21028db4..c34944c75047 100644 --- a/drivers/usb/mon/mon_main.c +++ b/drivers/usb/mon/mon_main.c | |||
@@ -11,6 +11,7 @@ | |||
11 | #include <linux/usb.h> | 11 | #include <linux/usb.h> |
12 | #include <linux/debugfs.h> | 12 | #include <linux/debugfs.h> |
13 | #include <linux/smp_lock.h> | 13 | #include <linux/smp_lock.h> |
14 | #include <linux/notifier.h> | ||
14 | 15 | ||
15 | #include "usb_mon.h" | 16 | #include "usb_mon.h" |
16 | #include "../core/hcd.h" | 17 | #include "../core/hcd.h" |
@@ -205,6 +206,23 @@ static void mon_bus_remove(struct usb_bus *ubus) | |||
205 | up(&mon_lock); | 206 | up(&mon_lock); |
206 | } | 207 | } |
207 | 208 | ||
209 | static int mon_notify(struct notifier_block *self, unsigned long action, | ||
210 | void *dev) | ||
211 | { | ||
212 | switch (action) { | ||
213 | case USB_BUS_ADD: | ||
214 | mon_bus_add(dev); | ||
215 | break; | ||
216 | case USB_BUS_REMOVE: | ||
217 | mon_bus_remove(dev); | ||
218 | } | ||
219 | return NOTIFY_OK; | ||
220 | } | ||
221 | |||
222 | static struct notifier_block mon_nb = { | ||
223 | .notifier_call = mon_notify, | ||
224 | }; | ||
225 | |||
208 | /* | 226 | /* |
209 | * Ops | 227 | * Ops |
210 | */ | 228 | */ |
@@ -212,8 +230,6 @@ static struct usb_mon_operations mon_ops_0 = { | |||
212 | .urb_submit = mon_submit, | 230 | .urb_submit = mon_submit, |
213 | .urb_submit_error = mon_submit_error, | 231 | .urb_submit_error = mon_submit_error, |
214 | .urb_complete = mon_complete, | 232 | .urb_complete = mon_complete, |
215 | .bus_add = mon_bus_add, | ||
216 | .bus_remove = mon_bus_remove, | ||
217 | }; | 233 | }; |
218 | 234 | ||
219 | /* | 235 | /* |
@@ -329,6 +345,8 @@ static int __init mon_init(void) | |||
329 | } | 345 | } |
330 | // MOD_INC_USE_COUNT(which_module?); | 346 | // MOD_INC_USE_COUNT(which_module?); |
331 | 347 | ||
348 | usb_register_notify(&mon_nb); | ||
349 | |||
332 | down(&usb_bus_list_lock); | 350 | down(&usb_bus_list_lock); |
333 | list_for_each_entry (ubus, &usb_bus_list, bus_list) { | 351 | list_for_each_entry (ubus, &usb_bus_list, bus_list) { |
334 | mon_bus_init(mondir, ubus); | 352 | mon_bus_init(mondir, ubus); |
@@ -342,6 +360,7 @@ static void __exit mon_exit(void) | |||
342 | struct mon_bus *mbus; | 360 | struct mon_bus *mbus; |
343 | struct list_head *p; | 361 | struct list_head *p; |
344 | 362 | ||
363 | usb_unregister_notify(&mon_nb); | ||
345 | usb_mon_deregister(); | 364 | usb_mon_deregister(); |
346 | 365 | ||
347 | down(&mon_lock); | 366 | down(&mon_lock); |
diff --git a/drivers/usb/net/Kconfig b/drivers/usb/net/Kconfig index 8c010bb44eb8..efd6ca7e4ac5 100644 --- a/drivers/usb/net/Kconfig +++ b/drivers/usb/net/Kconfig | |||
@@ -294,7 +294,7 @@ config USB_NET_ZAURUS | |||
294 | This also supports some related device firmware, as used in some | 294 | This also supports some related device firmware, as used in some |
295 | PDAs from Olympus and some cell phones from Motorola. | 295 | PDAs from Olympus and some cell phones from Motorola. |
296 | 296 | ||
297 | If you install an alternate ROM image, such as the Linux 2.6 based | 297 | If you install an alternate image, such as the Linux 2.6 based |
298 | versions of OpenZaurus, you should no longer need to support this | 298 | versions of OpenZaurus, you should no longer need to support this |
299 | protocol. Only the "eth-fd" or "net_fd" drivers in these devices | 299 | protocol. Only the "eth-fd" or "net_fd" drivers in these devices |
300 | really need this non-conformant variant of CDC Ethernet (or in | 300 | really need this non-conformant variant of CDC Ethernet (or in |
diff --git a/drivers/usb/net/Makefile b/drivers/usb/net/Makefile index 222c0495f791..a21e6eaabaf6 100644 --- a/drivers/usb/net/Makefile +++ b/drivers/usb/net/Makefile | |||
@@ -16,3 +16,7 @@ obj-$(CONFIG_USB_NET_CDC_SUBSET) += cdc_subset.o | |||
16 | obj-$(CONFIG_USB_NET_ZAURUS) += zaurus.o | 16 | obj-$(CONFIG_USB_NET_ZAURUS) += zaurus.o |
17 | obj-$(CONFIG_USB_USBNET) += usbnet.o | 17 | obj-$(CONFIG_USB_USBNET) += usbnet.o |
18 | obj-$(CONFIG_USB_ZD1201) += zd1201.o | 18 | obj-$(CONFIG_USB_ZD1201) += zd1201.o |
19 | |||
20 | ifeq ($(CONFIG_USB_DEBUG),y) | ||
21 | EXTRA_CFLAGS += -DDEBUG | ||
22 | endif | ||
diff --git a/drivers/usb/net/asix.c b/drivers/usb/net/asix.c index 861f00a43750..542120ef1fd2 100644 --- a/drivers/usb/net/asix.c +++ b/drivers/usb/net/asix.c | |||
@@ -23,9 +23,6 @@ | |||
23 | // #define VERBOSE // more; success messages | 23 | // #define VERBOSE // more; success messages |
24 | 24 | ||
25 | #include <linux/config.h> | 25 | #include <linux/config.h> |
26 | #ifdef CONFIG_USB_DEBUG | ||
27 | # define DEBUG | ||
28 | #endif | ||
29 | #include <linux/module.h> | 26 | #include <linux/module.h> |
30 | #include <linux/kmod.h> | 27 | #include <linux/kmod.h> |
31 | #include <linux/sched.h> | 28 | #include <linux/sched.h> |
@@ -753,7 +750,7 @@ static int ax88772_rx_fixup(struct usbnet *dev, struct sk_buff *skb) | |||
753 | } | 750 | } |
754 | 751 | ||
755 | static struct sk_buff *ax88772_tx_fixup(struct usbnet *dev, struct sk_buff *skb, | 752 | static struct sk_buff *ax88772_tx_fixup(struct usbnet *dev, struct sk_buff *skb, |
756 | unsigned flags) | 753 | gfp_t flags) |
757 | { | 754 | { |
758 | int padlen; | 755 | int padlen; |
759 | int headroom = skb_headroom(skb); | 756 | int headroom = skb_headroom(skb); |
diff --git a/drivers/usb/net/cdc_ether.c b/drivers/usb/net/cdc_ether.c index 652b04bbf6af..c008c981862b 100644 --- a/drivers/usb/net/cdc_ether.c +++ b/drivers/usb/net/cdc_ether.c | |||
@@ -21,9 +21,6 @@ | |||
21 | // #define VERBOSE // more; success messages | 21 | // #define VERBOSE // more; success messages |
22 | 22 | ||
23 | #include <linux/config.h> | 23 | #include <linux/config.h> |
24 | #ifdef CONFIG_USB_DEBUG | ||
25 | # define DEBUG | ||
26 | #endif | ||
27 | #include <linux/module.h> | 24 | #include <linux/module.h> |
28 | #include <linux/sched.h> | 25 | #include <linux/sched.h> |
29 | #include <linux/init.h> | 26 | #include <linux/init.h> |
diff --git a/drivers/usb/net/cdc_subset.c b/drivers/usb/net/cdc_subset.c index f1730b685fd2..f05cfb83c82d 100644 --- a/drivers/usb/net/cdc_subset.c +++ b/drivers/usb/net/cdc_subset.c | |||
@@ -18,9 +18,6 @@ | |||
18 | */ | 18 | */ |
19 | 19 | ||
20 | #include <linux/config.h> | 20 | #include <linux/config.h> |
21 | #ifdef CONFIG_USB_DEBUG | ||
22 | # define DEBUG | ||
23 | #endif | ||
24 | #include <linux/module.h> | 21 | #include <linux/module.h> |
25 | #include <linux/kmod.h> | 22 | #include <linux/kmod.h> |
26 | #include <linux/sched.h> | 23 | #include <linux/sched.h> |
diff --git a/drivers/usb/net/gl620a.c b/drivers/usb/net/gl620a.c index c8763ae33c73..2455e9a85674 100644 --- a/drivers/usb/net/gl620a.c +++ b/drivers/usb/net/gl620a.c | |||
@@ -22,9 +22,6 @@ | |||
22 | // #define VERBOSE // more; success messages | 22 | // #define VERBOSE // more; success messages |
23 | 23 | ||
24 | #include <linux/config.h> | 24 | #include <linux/config.h> |
25 | #ifdef CONFIG_USB_DEBUG | ||
26 | # define DEBUG | ||
27 | #endif | ||
28 | #include <linux/module.h> | 25 | #include <linux/module.h> |
29 | #include <linux/sched.h> | 26 | #include <linux/sched.h> |
30 | #include <linux/init.h> | 27 | #include <linux/init.h> |
@@ -301,7 +298,7 @@ static int genelink_rx_fixup(struct usbnet *dev, struct sk_buff *skb) | |||
301 | } | 298 | } |
302 | 299 | ||
303 | static struct sk_buff * | 300 | static struct sk_buff * |
304 | genelink_tx_fixup(struct usbnet *dev, struct sk_buff *skb, unsigned flags) | 301 | genelink_tx_fixup(struct usbnet *dev, struct sk_buff *skb, gfp_t flags) |
305 | { | 302 | { |
306 | int padlen; | 303 | int padlen; |
307 | int length = skb->len; | 304 | int length = skb->len; |
diff --git a/drivers/usb/net/kaweth.c b/drivers/usb/net/kaweth.c index e04b0ce3611a..b5776518020f 100644 --- a/drivers/usb/net/kaweth.c +++ b/drivers/usb/net/kaweth.c | |||
@@ -219,7 +219,6 @@ struct kaweth_device | |||
219 | 219 | ||
220 | __u32 status; | 220 | __u32 status; |
221 | int end; | 221 | int end; |
222 | int removed; | ||
223 | int suspend_lowmem_rx; | 222 | int suspend_lowmem_rx; |
224 | int suspend_lowmem_ctrl; | 223 | int suspend_lowmem_ctrl; |
225 | int linkstate; | 224 | int linkstate; |
@@ -469,7 +468,7 @@ static int kaweth_reset(struct kaweth_device *kaweth) | |||
469 | 0, | 468 | 0, |
470 | KAWETH_CONTROL_TIMEOUT); | 469 | KAWETH_CONTROL_TIMEOUT); |
471 | 470 | ||
472 | udelay(10000); | 471 | mdelay(10); |
473 | 472 | ||
474 | kaweth_dbg("kaweth_reset() returns %d.",result); | 473 | kaweth_dbg("kaweth_reset() returns %d.",result); |
475 | 474 | ||
@@ -477,13 +476,13 @@ static int kaweth_reset(struct kaweth_device *kaweth) | |||
477 | } | 476 | } |
478 | 477 | ||
479 | static void kaweth_usb_receive(struct urb *, struct pt_regs *regs); | 478 | static void kaweth_usb_receive(struct urb *, struct pt_regs *regs); |
480 | static int kaweth_resubmit_rx_urb(struct kaweth_device *, unsigned); | 479 | static int kaweth_resubmit_rx_urb(struct kaweth_device *, gfp_t); |
481 | 480 | ||
482 | /**************************************************************** | 481 | /**************************************************************** |
483 | int_callback | 482 | int_callback |
484 | *****************************************************************/ | 483 | *****************************************************************/ |
485 | 484 | ||
486 | static void kaweth_resubmit_int_urb(struct kaweth_device *kaweth, int mf) | 485 | static void kaweth_resubmit_int_urb(struct kaweth_device *kaweth, gfp_t mf) |
487 | { | 486 | { |
488 | int status; | 487 | int status; |
489 | 488 | ||
@@ -550,7 +549,7 @@ static void kaweth_resubmit_tl(void *d) | |||
550 | * kaweth_resubmit_rx_urb | 549 | * kaweth_resubmit_rx_urb |
551 | ****************************************************************/ | 550 | ****************************************************************/ |
552 | static int kaweth_resubmit_rx_urb(struct kaweth_device *kaweth, | 551 | static int kaweth_resubmit_rx_urb(struct kaweth_device *kaweth, |
553 | unsigned mem_flags) | 552 | gfp_t mem_flags) |
554 | { | 553 | { |
555 | int result; | 554 | int result; |
556 | 555 | ||
@@ -699,6 +698,7 @@ static int kaweth_close(struct net_device *net) | |||
699 | 698 | ||
700 | usb_kill_urb(kaweth->irq_urb); | 699 | usb_kill_urb(kaweth->irq_urb); |
701 | usb_kill_urb(kaweth->rx_urb); | 700 | usb_kill_urb(kaweth->rx_urb); |
701 | usb_kill_urb(kaweth->tx_urb); | ||
702 | 702 | ||
703 | flush_scheduled_work(); | 703 | flush_scheduled_work(); |
704 | 704 | ||
@@ -750,13 +750,6 @@ static int kaweth_start_xmit(struct sk_buff *skb, struct net_device *net) | |||
750 | 750 | ||
751 | spin_lock(&kaweth->device_lock); | 751 | spin_lock(&kaweth->device_lock); |
752 | 752 | ||
753 | if (kaweth->removed) { | ||
754 | /* our device is undergoing disconnection - we bail out */ | ||
755 | spin_unlock(&kaweth->device_lock); | ||
756 | dev_kfree_skb_irq(skb); | ||
757 | return 0; | ||
758 | } | ||
759 | |||
760 | kaweth_async_set_rx_mode(kaweth); | 753 | kaweth_async_set_rx_mode(kaweth); |
761 | netif_stop_queue(net); | 754 | netif_stop_queue(net); |
762 | 755 | ||
@@ -1136,10 +1129,6 @@ static void kaweth_disconnect(struct usb_interface *intf) | |||
1136 | return; | 1129 | return; |
1137 | } | 1130 | } |
1138 | netdev = kaweth->net; | 1131 | netdev = kaweth->net; |
1139 | kaweth->removed = 1; | ||
1140 | usb_kill_urb(kaweth->irq_urb); | ||
1141 | usb_kill_urb(kaweth->rx_urb); | ||
1142 | usb_kill_urb(kaweth->tx_urb); | ||
1143 | 1132 | ||
1144 | kaweth_dbg("Unregistering net device"); | 1133 | kaweth_dbg("Unregistering net device"); |
1145 | unregister_netdev(netdev); | 1134 | unregister_netdev(netdev); |
diff --git a/drivers/usb/net/net1080.c b/drivers/usb/net/net1080.c index a4309c4a491b..b3799b1a2b0d 100644 --- a/drivers/usb/net/net1080.c +++ b/drivers/usb/net/net1080.c | |||
@@ -21,9 +21,6 @@ | |||
21 | // #define VERBOSE // more; success messages | 21 | // #define VERBOSE // more; success messages |
22 | 22 | ||
23 | #include <linux/config.h> | 23 | #include <linux/config.h> |
24 | #ifdef CONFIG_USB_DEBUG | ||
25 | # define DEBUG | ||
26 | #endif | ||
27 | #include <linux/module.h> | 24 | #include <linux/module.h> |
28 | #include <linux/sched.h> | 25 | #include <linux/sched.h> |
29 | #include <linux/init.h> | 26 | #include <linux/init.h> |
@@ -500,7 +497,7 @@ static int net1080_rx_fixup(struct usbnet *dev, struct sk_buff *skb) | |||
500 | } | 497 | } |
501 | 498 | ||
502 | static struct sk_buff * | 499 | static struct sk_buff * |
503 | net1080_tx_fixup(struct usbnet *dev, struct sk_buff *skb, unsigned flags) | 500 | net1080_tx_fixup(struct usbnet *dev, struct sk_buff *skb, gfp_t flags) |
504 | { | 501 | { |
505 | int padlen; | 502 | int padlen; |
506 | struct sk_buff *skb2; | 503 | struct sk_buff *skb2; |
diff --git a/drivers/usb/net/pegasus.c b/drivers/usb/net/pegasus.c index 7484d34780fc..683e3df5d607 100644 --- a/drivers/usb/net/pegasus.c +++ b/drivers/usb/net/pegasus.c | |||
@@ -28,8 +28,6 @@ | |||
28 | * is out of the interrupt routine. | 28 | * is out of the interrupt routine. |
29 | */ | 29 | */ |
30 | 30 | ||
31 | #undef DEBUG | ||
32 | |||
33 | #include <linux/sched.h> | 31 | #include <linux/sched.h> |
34 | #include <linux/slab.h> | 32 | #include <linux/slab.h> |
35 | #include <linux/init.h> | 33 | #include <linux/init.h> |
@@ -648,6 +646,13 @@ static void read_bulk_callback(struct urb *urb, struct pt_regs *regs) | |||
648 | } | 646 | } |
649 | 647 | ||
650 | /* | 648 | /* |
649 | * If the packet is unreasonably long, quietly drop it rather than | ||
650 | * kernel panicing by calling skb_put. | ||
651 | */ | ||
652 | if (pkt_len > PEGASUS_MTU) | ||
653 | goto goon; | ||
654 | |||
655 | /* | ||
651 | * at this point we are sure pegasus->rx_skb != NULL | 656 | * at this point we are sure pegasus->rx_skb != NULL |
652 | * so we go ahead and pass up the packet. | 657 | * so we go ahead and pass up the packet. |
653 | */ | 658 | */ |
@@ -886,15 +891,17 @@ static inline void get_interrupt_interval(pegasus_t * pegasus) | |||
886 | __u8 data[2]; | 891 | __u8 data[2]; |
887 | 892 | ||
888 | read_eprom_word(pegasus, 4, (__u16 *) data); | 893 | read_eprom_word(pegasus, 4, (__u16 *) data); |
889 | if (data[1] < 0x80) { | 894 | if (pegasus->usb->speed != USB_SPEED_HIGH) { |
890 | if (netif_msg_timer(pegasus)) | 895 | if (data[1] < 0x80) { |
891 | dev_info(&pegasus->intf->dev, | 896 | if (netif_msg_timer(pegasus)) |
892 | "intr interval changed from %ums to %ums\n", | 897 | dev_info(&pegasus->intf->dev, "intr interval " |
893 | data[1], 0x80); | 898 | "changed from %ums to %ums\n", |
894 | data[1] = 0x80; | 899 | data[1], 0x80); |
895 | #ifdef PEGASUS_WRITE_EEPROM | 900 | data[1] = 0x80; |
896 | write_eprom_word(pegasus, 4, *(__u16 *) data); | 901 | #ifdef PEGASUS_WRITE_EEPROM |
902 | write_eprom_word(pegasus, 4, *(__u16 *) data); | ||
897 | #endif | 903 | #endif |
904 | } | ||
898 | } | 905 | } |
899 | pegasus->intr_interval = data[1]; | 906 | pegasus->intr_interval = data[1]; |
900 | } | 907 | } |
@@ -904,8 +911,9 @@ static void set_carrier(struct net_device *net) | |||
904 | pegasus_t *pegasus = netdev_priv(net); | 911 | pegasus_t *pegasus = netdev_priv(net); |
905 | u16 tmp; | 912 | u16 tmp; |
906 | 913 | ||
907 | if (read_mii_word(pegasus, pegasus->phy, MII_BMSR, &tmp)) | 914 | if (!read_mii_word(pegasus, pegasus->phy, MII_BMSR, &tmp)) |
908 | return; | 915 | return; |
916 | |||
909 | if (tmp & BMSR_LSTATUS) | 917 | if (tmp & BMSR_LSTATUS) |
910 | netif_carrier_on(net); | 918 | netif_carrier_on(net); |
911 | else | 919 | else |
@@ -1355,6 +1363,7 @@ static void pegasus_disconnect(struct usb_interface *intf) | |||
1355 | cancel_delayed_work(&pegasus->carrier_check); | 1363 | cancel_delayed_work(&pegasus->carrier_check); |
1356 | unregister_netdev(pegasus->net); | 1364 | unregister_netdev(pegasus->net); |
1357 | usb_put_dev(interface_to_usbdev(intf)); | 1365 | usb_put_dev(interface_to_usbdev(intf)); |
1366 | unlink_all_urbs(pegasus); | ||
1358 | free_all_urbs(pegasus); | 1367 | free_all_urbs(pegasus); |
1359 | free_skb_pool(pegasus); | 1368 | free_skb_pool(pegasus); |
1360 | if (pegasus->rx_skb) | 1369 | if (pegasus->rx_skb) |
@@ -1373,7 +1382,6 @@ static int pegasus_suspend (struct usb_interface *intf, pm_message_t message) | |||
1373 | usb_kill_urb(pegasus->rx_urb); | 1382 | usb_kill_urb(pegasus->rx_urb); |
1374 | usb_kill_urb(pegasus->intr_urb); | 1383 | usb_kill_urb(pegasus->intr_urb); |
1375 | } | 1384 | } |
1376 | intf->dev.power.power_state = PMSG_SUSPEND; | ||
1377 | return 0; | 1385 | return 0; |
1378 | } | 1386 | } |
1379 | 1387 | ||
@@ -1381,7 +1389,6 @@ static int pegasus_resume (struct usb_interface *intf) | |||
1381 | { | 1389 | { |
1382 | struct pegasus *pegasus = usb_get_intfdata(intf); | 1390 | struct pegasus *pegasus = usb_get_intfdata(intf); |
1383 | 1391 | ||
1384 | intf->dev.power.power_state = PMSG_ON; | ||
1385 | netif_device_attach (pegasus->net); | 1392 | netif_device_attach (pegasus->net); |
1386 | if (netif_running(pegasus->net)) { | 1393 | if (netif_running(pegasus->net)) { |
1387 | pegasus->rx_urb->status = 0; | 1394 | pegasus->rx_urb->status = 0; |
diff --git a/drivers/usb/net/pegasus.h b/drivers/usb/net/pegasus.h index b98f2a833442..9fbd59b55cb6 100644 --- a/drivers/usb/net/pegasus.h +++ b/drivers/usb/net/pegasus.h | |||
@@ -181,6 +181,8 @@ PEGASUS_DEV( "Accton USB 10/100 Ethernet Adapter", VENDOR_ACCTON, 0x1046, | |||
181 | DEFAULT_GPIO_RESET ) | 181 | DEFAULT_GPIO_RESET ) |
182 | PEGASUS_DEV( "SpeedStream USB 10/100 Ethernet", VENDOR_ACCTON, 0x5046, | 182 | PEGASUS_DEV( "SpeedStream USB 10/100 Ethernet", VENDOR_ACCTON, 0x5046, |
183 | DEFAULT_GPIO_RESET | PEGASUS_II ) | 183 | DEFAULT_GPIO_RESET | PEGASUS_II ) |
184 | PEGASUS_DEV( "Philips USB 10/100 Ethernet", VENDOR_ACCTON, 0xb004, | ||
185 | DEFAULT_GPIO_RESET | PEGASUS_II ) | ||
184 | PEGASUS_DEV( "ADMtek ADM8511 \"Pegasus II\" USB Ethernet", | 186 | PEGASUS_DEV( "ADMtek ADM8511 \"Pegasus II\" USB Ethernet", |
185 | VENDOR_ADMTEK, 0x8511, | 187 | VENDOR_ADMTEK, 0x8511, |
186 | DEFAULT_GPIO_RESET | PEGASUS_II | HAS_HOME_PNA ) | 188 | DEFAULT_GPIO_RESET | PEGASUS_II | HAS_HOME_PNA ) |
diff --git a/drivers/usb/net/plusb.c b/drivers/usb/net/plusb.c index 74c2b3581c76..89856aa0e3b8 100644 --- a/drivers/usb/net/plusb.c +++ b/drivers/usb/net/plusb.c | |||
@@ -21,9 +21,6 @@ | |||
21 | // #define VERBOSE // more; success messages | 21 | // #define VERBOSE // more; success messages |
22 | 22 | ||
23 | #include <linux/config.h> | 23 | #include <linux/config.h> |
24 | #ifdef CONFIG_USB_DEBUG | ||
25 | # define DEBUG | ||
26 | #endif | ||
27 | #include <linux/module.h> | 24 | #include <linux/module.h> |
28 | #include <linux/sched.h> | 25 | #include <linux/sched.h> |
29 | #include <linux/init.h> | 26 | #include <linux/init.h> |
diff --git a/drivers/usb/net/rndis_host.c b/drivers/usb/net/rndis_host.c index 2ed2e5fb7778..c0ecbab6f6ba 100644 --- a/drivers/usb/net/rndis_host.c +++ b/drivers/usb/net/rndis_host.c | |||
@@ -21,9 +21,6 @@ | |||
21 | // #define VERBOSE // more; success messages | 21 | // #define VERBOSE // more; success messages |
22 | 22 | ||
23 | #include <linux/config.h> | 23 | #include <linux/config.h> |
24 | #ifdef CONFIG_USB_DEBUG | ||
25 | # define DEBUG | ||
26 | #endif | ||
27 | #include <linux/module.h> | 24 | #include <linux/module.h> |
28 | #include <linux/sched.h> | 25 | #include <linux/sched.h> |
29 | #include <linux/init.h> | 26 | #include <linux/init.h> |
@@ -517,7 +514,7 @@ static int rndis_rx_fixup(struct usbnet *dev, struct sk_buff *skb) | |||
517 | } | 514 | } |
518 | 515 | ||
519 | static struct sk_buff * | 516 | static struct sk_buff * |
520 | rndis_tx_fixup(struct usbnet *dev, struct sk_buff *skb, unsigned flags) | 517 | rndis_tx_fixup(struct usbnet *dev, struct sk_buff *skb, gfp_t flags) |
521 | { | 518 | { |
522 | struct rndis_data_hdr *hdr; | 519 | struct rndis_data_hdr *hdr; |
523 | struct sk_buff *skb2; | 520 | struct sk_buff *skb2; |
diff --git a/drivers/usb/net/rtl8150.c b/drivers/usb/net/rtl8150.c index c3d4e3589e30..787dd3591d6a 100644 --- a/drivers/usb/net/rtl8150.c +++ b/drivers/usb/net/rtl8150.c | |||
@@ -909,6 +909,7 @@ static void rtl8150_disconnect(struct usb_interface *intf) | |||
909 | usb_set_intfdata(intf, NULL); | 909 | usb_set_intfdata(intf, NULL); |
910 | if (dev) { | 910 | if (dev) { |
911 | set_bit(RTL8150_UNPLUG, &dev->flags); | 911 | set_bit(RTL8150_UNPLUG, &dev->flags); |
912 | tasklet_disable(&dev->tl); | ||
912 | unregister_netdev(dev->netdev); | 913 | unregister_netdev(dev->netdev); |
913 | unlink_all_urbs(dev); | 914 | unlink_all_urbs(dev); |
914 | free_all_urbs(dev); | 915 | free_all_urbs(dev); |
diff --git a/drivers/usb/net/usbnet.c b/drivers/usb/net/usbnet.c index 6c460918d54f..362d6907c9bb 100644 --- a/drivers/usb/net/usbnet.c +++ b/drivers/usb/net/usbnet.c | |||
@@ -34,9 +34,6 @@ | |||
34 | // #define VERBOSE // more; success messages | 34 | // #define VERBOSE // more; success messages |
35 | 35 | ||
36 | #include <linux/config.h> | 36 | #include <linux/config.h> |
37 | #ifdef CONFIG_USB_DEBUG | ||
38 | # define DEBUG | ||
39 | #endif | ||
40 | #include <linux/module.h> | 37 | #include <linux/module.h> |
41 | #include <linux/sched.h> | 38 | #include <linux/sched.h> |
42 | #include <linux/init.h> | 39 | #include <linux/init.h> |
@@ -288,7 +285,7 @@ EXPORT_SYMBOL_GPL(usbnet_defer_kevent); | |||
288 | 285 | ||
289 | static void rx_complete (struct urb *urb, struct pt_regs *regs); | 286 | static void rx_complete (struct urb *urb, struct pt_regs *regs); |
290 | 287 | ||
291 | static void rx_submit (struct usbnet *dev, struct urb *urb, unsigned flags) | 288 | static void rx_submit (struct usbnet *dev, struct urb *urb, gfp_t flags) |
292 | { | 289 | { |
293 | struct sk_buff *skb; | 290 | struct sk_buff *skb; |
294 | struct skb_data *entry; | 291 | struct skb_data *entry; |
@@ -1185,7 +1182,6 @@ int usbnet_suspend (struct usb_interface *intf, pm_message_t message) | |||
1185 | netif_device_detach (dev->net); | 1182 | netif_device_detach (dev->net); |
1186 | (void) unlink_urbs (dev, &dev->rxq); | 1183 | (void) unlink_urbs (dev, &dev->rxq); |
1187 | (void) unlink_urbs (dev, &dev->txq); | 1184 | (void) unlink_urbs (dev, &dev->txq); |
1188 | intf->dev.power.power_state = PMSG_SUSPEND; | ||
1189 | return 0; | 1185 | return 0; |
1190 | } | 1186 | } |
1191 | EXPORT_SYMBOL_GPL(usbnet_suspend); | 1187 | EXPORT_SYMBOL_GPL(usbnet_suspend); |
@@ -1194,7 +1190,6 @@ int usbnet_resume (struct usb_interface *intf) | |||
1194 | { | 1190 | { |
1195 | struct usbnet *dev = usb_get_intfdata(intf); | 1191 | struct usbnet *dev = usb_get_intfdata(intf); |
1196 | 1192 | ||
1197 | intf->dev.power.power_state = PMSG_ON; | ||
1198 | netif_device_attach (dev->net); | 1193 | netif_device_attach (dev->net); |
1199 | tasklet_schedule (&dev->bh); | 1194 | tasklet_schedule (&dev->bh); |
1200 | return 0; | 1195 | return 0; |
diff --git a/drivers/usb/net/usbnet.h b/drivers/usb/net/usbnet.h index 7aa0abd1a9bd..89fc4958eecf 100644 --- a/drivers/usb/net/usbnet.h +++ b/drivers/usb/net/usbnet.h | |||
@@ -107,7 +107,7 @@ struct driver_info { | |||
107 | 107 | ||
108 | /* fixup tx packet (add framing) */ | 108 | /* fixup tx packet (add framing) */ |
109 | struct sk_buff *(*tx_fixup)(struct usbnet *dev, | 109 | struct sk_buff *(*tx_fixup)(struct usbnet *dev, |
110 | struct sk_buff *skb, unsigned flags); | 110 | struct sk_buff *skb, gfp_t flags); |
111 | 111 | ||
112 | /* for new devices, use the descriptor-reading code instead */ | 112 | /* for new devices, use the descriptor-reading code instead */ |
113 | int in; /* rx endpoint */ | 113 | int in; /* rx endpoint */ |
diff --git a/drivers/usb/net/zaurus.c b/drivers/usb/net/zaurus.c index ee3b892aeabc..680d13957af4 100644 --- a/drivers/usb/net/zaurus.c +++ b/drivers/usb/net/zaurus.c | |||
@@ -21,9 +21,6 @@ | |||
21 | // #define VERBOSE // more; success messages | 21 | // #define VERBOSE // more; success messages |
22 | 22 | ||
23 | #include <linux/config.h> | 23 | #include <linux/config.h> |
24 | #ifdef CONFIG_USB_DEBUG | ||
25 | # define DEBUG | ||
26 | #endif | ||
27 | #include <linux/module.h> | 24 | #include <linux/module.h> |
28 | #include <linux/sched.h> | 25 | #include <linux/sched.h> |
29 | #include <linux/init.h> | 26 | #include <linux/init.h> |
@@ -62,7 +59,7 @@ | |||
62 | */ | 59 | */ |
63 | 60 | ||
64 | static struct sk_buff * | 61 | static struct sk_buff * |
65 | zaurus_tx_fixup(struct usbnet *dev, struct sk_buff *skb, unsigned flags) | 62 | zaurus_tx_fixup(struct usbnet *dev, struct sk_buff *skb, gfp_t flags) |
66 | { | 63 | { |
67 | int padlen; | 64 | int padlen; |
68 | struct sk_buff *skb2; | 65 | struct sk_buff *skb2; |
diff --git a/drivers/usb/net/zd1201.c b/drivers/usb/net/zd1201.c index c4e479ee926a..2f52261c7cc1 100644 --- a/drivers/usb/net/zd1201.c +++ b/drivers/usb/net/zd1201.c | |||
@@ -521,7 +521,7 @@ static int zd1201_setconfig(struct zd1201 *zd, int rid, void *buf, int len, int | |||
521 | int reqlen; | 521 | int reqlen; |
522 | char seq=0; | 522 | char seq=0; |
523 | struct urb *urb; | 523 | struct urb *urb; |
524 | unsigned int gfp_mask = wait ? GFP_NOIO : GFP_ATOMIC; | 524 | gfp_t gfp_mask = wait ? GFP_NOIO : GFP_ATOMIC; |
525 | 525 | ||
526 | len += 4; /* first 4 are for header */ | 526 | len += 4; /* first 4 are for header */ |
527 | 527 | ||
diff --git a/drivers/usb/serial/ChangeLog.history b/drivers/usb/serial/ChangeLog.history new file mode 100644 index 000000000000..52c4f7bd7a80 --- /dev/null +++ b/drivers/usb/serial/ChangeLog.history | |||
@@ -0,0 +1,730 @@ | |||
1 | This is the contents of some of the drivers/usb/serial/ files that had old | ||
2 | changelog comments. They were quite old, and out of date, and we don't keep | ||
3 | them anymore, so I've put them here, away from the source files, in case | ||
4 | people still care to see them. | ||
5 | |||
6 | - Greg Kroah-Hartman <greg@kroah.com> October 20, 2005 | ||
7 | |||
8 | ----------------------------------------------------------------------- | ||
9 | usb-serial.h Change Log comments: | ||
10 | |||
11 | (03/26/2002) gkh | ||
12 | removed the port->tty check from port_paranoia_check() due to serial | ||
13 | consoles not having a tty device assigned to them. | ||
14 | |||
15 | (12/03/2001) gkh | ||
16 | removed active from the port structure. | ||
17 | added documentation to the usb_serial_device_type structure | ||
18 | |||
19 | (10/10/2001) gkh | ||
20 | added vendor and product to serial structure. Needed to determine device | ||
21 | owner when the device is disconnected. | ||
22 | |||
23 | (05/30/2001) gkh | ||
24 | added sem to port structure and removed port_lock | ||
25 | |||
26 | (10/05/2000) gkh | ||
27 | Added interrupt_in_endpointAddress and bulk_in_endpointAddress to help | ||
28 | fix bug with urb->dev not being set properly, now that the usb core | ||
29 | needs it. | ||
30 | |||
31 | (09/11/2000) gkh | ||
32 | Added usb_serial_debug_data function to help get rid of #DEBUG in the | ||
33 | drivers. | ||
34 | |||
35 | (08/28/2000) gkh | ||
36 | Added port_lock to port structure. | ||
37 | |||
38 | (08/08/2000) gkh | ||
39 | Added open_count to port structure. | ||
40 | |||
41 | (07/23/2000) gkh | ||
42 | Added bulk_out_endpointAddress to port structure. | ||
43 | |||
44 | (07/19/2000) gkh, pberger, and borchers | ||
45 | Modifications to allow usb-serial drivers to be modules. | ||
46 | |||
47 | ----------------------------------------------------------------------- | ||
48 | usb-serial.c Change Log comments: | ||
49 | |||
50 | (12/10/2002) gkh | ||
51 | Split the ports off into their own struct device, and added a | ||
52 | usb-serial bus driver. | ||
53 | |||
54 | (11/19/2002) gkh | ||
55 | removed a few #ifdefs for the generic code and cleaned up the failure | ||
56 | logic in initialization. | ||
57 | |||
58 | (10/02/2002) gkh | ||
59 | moved the console code to console.c and out of this file. | ||
60 | |||
61 | (06/05/2002) gkh | ||
62 | moved location of startup() call in serial_probe() until after all | ||
63 | of the port information and endpoints are initialized. This makes | ||
64 | things easier for some drivers. | ||
65 | |||
66 | (04/10/2002) gkh | ||
67 | added serial_read_proc function which creates a | ||
68 | /proc/tty/driver/usb-serial file. | ||
69 | |||
70 | (03/27/2002) gkh | ||
71 | Got USB serial console code working properly and merged into the main | ||
72 | version of the tree. Thanks to Randy Dunlap for the initial version | ||
73 | of this code, and for pushing me to finish it up. | ||
74 | The USB serial console works with any usb serial driver device. | ||
75 | |||
76 | (03/21/2002) gkh | ||
77 | Moved all manipulation of port->open_count into the core. Now the | ||
78 | individual driver's open and close functions are called only when the | ||
79 | first open() and last close() is called. Making the drivers a bit | ||
80 | smaller and simpler. | ||
81 | Fixed a bug if a driver didn't have the owner field set. | ||
82 | |||
83 | (02/26/2002) gkh | ||
84 | Moved all locking into the main serial_* functions, instead of having | ||
85 | the individual drivers have to grab the port semaphore. This should | ||
86 | reduce races. | ||
87 | Reworked the MOD_INC logic a bit to always increment and decrement, even | ||
88 | if the generic driver is being used. | ||
89 | |||
90 | (10/10/2001) gkh | ||
91 | usb_serial_disconnect() now sets the serial->dev pointer is to NULL to | ||
92 | help prevent child drivers from accessing the device since it is now | ||
93 | gone. | ||
94 | |||
95 | (09/13/2001) gkh | ||
96 | Moved generic driver initialize after we have registered with the USB | ||
97 | core. Thanks to Randy Dunlap for pointing this problem out. | ||
98 | |||
99 | (07/03/2001) gkh | ||
100 | Fixed module paramater size. Thanks to John Brockmeyer for the pointer. | ||
101 | Fixed vendor and product getting defined through the MODULE_PARM macro | ||
102 | if the Generic driver wasn't compiled in. | ||
103 | Fixed problem with generic_shutdown() not being called for drivers that | ||
104 | don't have a shutdown() function. | ||
105 | |||
106 | (06/06/2001) gkh | ||
107 | added evil hack that is needed for the prolific pl2303 device due to the | ||
108 | crazy way its endpoints are set up. | ||
109 | |||
110 | (05/30/2001) gkh | ||
111 | switched from using spinlock to a semaphore, which fixes lots of problems. | ||
112 | |||
113 | (04/08/2001) gb | ||
114 | Identify version on module load. | ||
115 | |||
116 | 2001_02_05 gkh | ||
117 | Fixed buffer overflows bug with the generic serial driver. Thanks to | ||
118 | Todd Squires <squirest@ct0.com> for fixing this. | ||
119 | |||
120 | (01/10/2001) gkh | ||
121 | Fixed bug where the generic serial adaptor grabbed _any_ device that was | ||
122 | offered to it. | ||
123 | |||
124 | (12/12/2000) gkh | ||
125 | Removed MOD_INC and MOD_DEC from poll and disconnect functions, and | ||
126 | moved them to the serial_open and serial_close functions. | ||
127 | Also fixed bug with there not being a MOD_DEC for the generic driver | ||
128 | (thanks to Gary Brubaker for finding this.) | ||
129 | |||
130 | (11/29/2000) gkh | ||
131 | Small NULL pointer initialization cleanup which saves a bit of disk image | ||
132 | |||
133 | (11/01/2000) Adam J. Richter | ||
134 | instead of using idVendor/idProduct pairs, usb serial drivers | ||
135 | now identify their hardware interest with usb_device_id tables, | ||
136 | which they usually have anyhow for use with MODULE_DEVICE_TABLE. | ||
137 | |||
138 | (10/05/2000) gkh | ||
139 | Fixed bug with urb->dev not being set properly, now that the usb | ||
140 | core needs it. | ||
141 | |||
142 | (09/11/2000) gkh | ||
143 | Removed DEBUG #ifdefs with call to usb_serial_debug_data | ||
144 | |||
145 | (08/28/2000) gkh | ||
146 | Added port_lock to port structure. | ||
147 | Added locks for SMP safeness to generic driver | ||
148 | Fixed the ability to open a generic device's port more than once. | ||
149 | |||
150 | (07/23/2000) gkh | ||
151 | Added bulk_out_endpointAddress to port structure. | ||
152 | |||
153 | (07/19/2000) gkh, pberger, and borchers | ||
154 | Modifications to allow usb-serial drivers to be modules. | ||
155 | |||
156 | (07/03/2000) gkh | ||
157 | Added more debugging to serial_ioctl call | ||
158 | |||
159 | (06/25/2000) gkh | ||
160 | Changed generic_write_bulk_callback to not call wake_up_interruptible | ||
161 | directly, but to have port_softint do it at a safer time. | ||
162 | |||
163 | (06/23/2000) gkh | ||
164 | Cleaned up debugging statements in a quest to find UHCI timeout bug. | ||
165 | |||
166 | (05/22/2000) gkh | ||
167 | Changed the makefile, enabling the big CONFIG_USB_SERIAL_SOMTHING to be | ||
168 | removed from the individual device source files. | ||
169 | |||
170 | (05/03/2000) gkh | ||
171 | Added the Digi Acceleport driver from Al Borchers and Peter Berger. | ||
172 | |||
173 | (05/02/2000) gkh | ||
174 | Changed devfs and tty register code to work properly now. This was based on | ||
175 | the ACM driver changes by Vojtech Pavlik. | ||
176 | |||
177 | (04/27/2000) Ryan VanderBijl | ||
178 | Put calls to *_paranoia_checks into one function. | ||
179 | |||
180 | (04/23/2000) gkh | ||
181 | Fixed bug that Randy Dunlap found for Generic devices with no bulk out ports. | ||
182 | Moved when the startup code printed out the devices that are supported. | ||
183 | |||
184 | (04/19/2000) gkh | ||
185 | Added driver for ZyXEL omni.net lcd plus ISDN TA | ||
186 | Made startup info message specify which drivers were compiled in. | ||
187 | |||
188 | (04/03/2000) gkh | ||
189 | Changed the probe process to remove the module unload races. | ||
190 | Changed where the tty layer gets initialized to have devfs work nicer. | ||
191 | Added initial devfs support. | ||
192 | |||
193 | (03/26/2000) gkh | ||
194 | Split driver up into device specific pieces. | ||
195 | |||
196 | (03/19/2000) gkh | ||
197 | Fixed oops that could happen when device was removed while a program | ||
198 | was talking to the device. | ||
199 | Removed the static urbs and now all urbs are created and destroyed | ||
200 | dynamically. | ||
201 | Reworked the internal interface. Now everything is based on the | ||
202 | usb_serial_port structure instead of the larger usb_serial structure. | ||
203 | This fixes the bug that a multiport device could not have more than | ||
204 | one port open at one time. | ||
205 | |||
206 | (03/17/2000) gkh | ||
207 | Added config option for debugging messages. | ||
208 | Added patch for keyspan pda from Brian Warner. | ||
209 | |||
210 | (03/06/2000) gkh | ||
211 | Added the keyspan pda code from Brian Warner <warner@lothar.com> | ||
212 | Moved a bunch of the port specific stuff into its own structure. This | ||
213 | is in anticipation of the true multiport devices (there's a bug if you | ||
214 | try to access more than one port of any multiport device right now) | ||
215 | |||
216 | (02/21/2000) gkh | ||
217 | Made it so that any serial devices only have to specify which functions | ||
218 | they want to overload from the generic function calls (great, | ||
219 | inheritance in C, in a driver, just what I wanted...) | ||
220 | Added support for set_termios and ioctl function calls. No drivers take | ||
221 | advantage of this yet. | ||
222 | Removed the #ifdef MODULE, now there is no module specific code. | ||
223 | Cleaned up a few comments in usb-serial.h that were wrong (thanks again | ||
224 | to Miles Lott). | ||
225 | Small fix to get_free_serial. | ||
226 | |||
227 | (02/14/2000) gkh | ||
228 | Removed the Belkin and Peracom functionality from the driver due to | ||
229 | the lack of support from the vendor, and me not wanting people to | ||
230 | accidenatly buy the device, expecting it to work with Linux. | ||
231 | Added read_bulk_callback and write_bulk_callback to the type structure | ||
232 | for the needs of the FTDI and WhiteHEAT driver. | ||
233 | Changed all reverences to FTDI to FTDI_SIO at the request of Bill | ||
234 | Ryder. | ||
235 | Changed the output urb size back to the max endpoint size to make | ||
236 | the ftdi_sio driver have it easier, and due to the fact that it didn't | ||
237 | really increase the speed any. | ||
238 | |||
239 | (02/11/2000) gkh | ||
240 | Added VISOR_FUNCTION_CONSOLE to the visor startup function. This was a | ||
241 | patch from Miles Lott (milos@insync.net). | ||
242 | Fixed bug with not restoring the minor range that a device grabs, if | ||
243 | the startup function fails (thanks Miles for finding this). | ||
244 | |||
245 | (02/05/2000) gkh | ||
246 | Added initial framework for the Keyspan PDA serial converter so that | ||
247 | Brian Warner has a place to put his code. | ||
248 | Made the ezusb specific functions generic enough that different | ||
249 | devices can use them (whiteheat and keyspan_pda both need them). | ||
250 | Split out a whole bunch of structure and other stuff to a separate | ||
251 | usb-serial.h file. | ||
252 | Made the Visor connection messages a little more understandable, now | ||
253 | that Miles Lott (milos@insync.net) has gotten the Generic channel to | ||
254 | work. Also made them always show up in the log file. | ||
255 | |||
256 | (01/25/2000) gkh | ||
257 | Added initial framework for FTDI serial converter so that Bill Ryder | ||
258 | has a place to put his code. | ||
259 | Added the vendor specific info from Handspring. Now we can print out | ||
260 | informational debug messages as well as understand what is happening. | ||
261 | |||
262 | (01/23/2000) gkh | ||
263 | Fixed problem of crash when trying to open a port that didn't have a | ||
264 | device assigned to it. Made the minor node finding a little smarter, | ||
265 | now it looks to find a continuous space for the new device. | ||
266 | |||
267 | (01/21/2000) gkh | ||
268 | Fixed bug in visor_startup with patch from Miles Lott (milos@insync.net) | ||
269 | Fixed get_serial_by_minor which was all messed up for multi port | ||
270 | devices. Fixed multi port problem for generic devices. Now the number | ||
271 | of ports is determined by the number of bulk out endpoints for the | ||
272 | generic device. | ||
273 | |||
274 | (01/19/2000) gkh | ||
275 | Removed lots of cruft that was around from the old (pre urb) driver | ||
276 | interface. | ||
277 | Made the serial_table dynamic. This should save lots of memory when | ||
278 | the number of minor nodes goes up to 256. | ||
279 | Added initial support for devices that have more than one port. | ||
280 | Added more debugging comments for the Visor, and added a needed | ||
281 | set_configuration call. | ||
282 | |||
283 | (01/17/2000) gkh | ||
284 | Fixed the WhiteHEAT firmware (my processing tool had a bug) | ||
285 | and added new debug loader firmware for it. | ||
286 | Removed the put_char function as it isn't really needed. | ||
287 | Added visor startup commands as found by the Win98 dump. | ||
288 | |||
289 | (01/13/2000) gkh | ||
290 | Fixed the vendor id for the generic driver to the one I meant it to be. | ||
291 | |||
292 | (01/12/2000) gkh | ||
293 | Forget the version numbering...that's pretty useless... | ||
294 | Made the driver able to be compiled so that the user can select which | ||
295 | converter they want to use. This allows people who only want the Visor | ||
296 | support to not pay the memory size price of the WhiteHEAT. | ||
297 | Fixed bug where the generic driver (idVendor=0000 and idProduct=0000) | ||
298 | grabbed the root hub. Not good. | ||
299 | |||
300 | version 0.4.0 (01/10/2000) gkh | ||
301 | Added whiteheat.h containing the firmware for the ConnectTech WhiteHEAT | ||
302 | device. Added startup function to allow firmware to be downloaded to | ||
303 | a device if it needs to be. | ||
304 | Added firmware download logic to the WhiteHEAT device. | ||
305 | Started to add #defines to split up the different drivers for potential | ||
306 | configuration option. | ||
307 | |||
308 | version 0.3.1 (12/30/99) gkh | ||
309 | Fixed problems with urb for bulk out. | ||
310 | Added initial support for multiple sets of endpoints. This enables | ||
311 | the Handspring Visor to be attached successfully. Only the first | ||
312 | bulk in / bulk out endpoint pair is being used right now. | ||
313 | |||
314 | version 0.3.0 (12/27/99) gkh | ||
315 | Added initial support for the Handspring Visor based on a patch from | ||
316 | Miles Lott (milos@sneety.insync.net) | ||
317 | Cleaned up the code a bunch and converted over to using urbs only. | ||
318 | |||
319 | version 0.2.3 (12/21/99) gkh | ||
320 | Added initial support for the Connect Tech WhiteHEAT converter. | ||
321 | Incremented the number of ports in expectation of getting the | ||
322 | WhiteHEAT to work properly (4 ports per connection). | ||
323 | Added notification on insertion and removal of what port the | ||
324 | device is/was connected to (and what kind of device it was). | ||
325 | |||
326 | version 0.2.2 (12/16/99) gkh | ||
327 | Changed major number to the new allocated number. We're legal now! | ||
328 | |||
329 | version 0.2.1 (12/14/99) gkh | ||
330 | Fixed bug that happens when device node is opened when there isn't a | ||
331 | device attached to it. Thanks to marek@webdesign.no for noticing this. | ||
332 | |||
333 | version 0.2.0 (11/10/99) gkh | ||
334 | Split up internals to make it easier to add different types of serial | ||
335 | converters to the code. | ||
336 | Added a "generic" driver that gets it's vendor and product id | ||
337 | from when the module is loaded. Thanks to David E. Nelson (dnelson@jump.net) | ||
338 | for the idea and sample code (from the usb scanner driver.) | ||
339 | Cleared up any licensing questions by releasing it under the GNU GPL. | ||
340 | |||
341 | version 0.1.2 (10/25/99) gkh | ||
342 | Fixed bug in detecting device. | ||
343 | |||
344 | version 0.1.1 (10/05/99) gkh | ||
345 | Changed the major number to not conflict with anything else. | ||
346 | |||
347 | version 0.1 (09/28/99) gkh | ||
348 | Can recognize the two different devices and start up a read from | ||
349 | device when asked to. Writes also work. No control signals yet, this | ||
350 | all is vendor specific data (i.e. no spec), also no control for | ||
351 | different baud rates or other bit settings. | ||
352 | Currently we are using the same devid as the acm driver. This needs | ||
353 | to change. | ||
354 | |||
355 | ----------------------------------------------------------------------- | ||
356 | visor.c Change Log comments: | ||
357 | |||
358 | (06/03/2003) Judd Montgomery <judd at jpilot.org> | ||
359 | Added support for module parameter options for untested/unknown | ||
360 | devices. | ||
361 | |||
362 | (03/09/2003) gkh | ||
363 | Added support for the Sony Clie NZ90V device. Thanks to Martin Brachtl | ||
364 | <brachtl@redgrep.cz> for the information. | ||
365 | |||
366 | (03/05/2003) gkh | ||
367 | Think Treo support is now working. | ||
368 | |||
369 | (04/03/2002) gkh | ||
370 | Added support for the Sony OS 4.1 devices. Thanks to Hiroyuki ARAKI | ||
371 | <hiro@zob.ne.jp> for the information. | ||
372 | |||
373 | (03/27/2002) gkh | ||
374 | Removed assumptions that port->tty was always valid (is not true | ||
375 | for usb serial console devices.) | ||
376 | |||
377 | (03/23/2002) gkh | ||
378 | Added support for the Palm i705 device, thanks to Thomas Riemer | ||
379 | <tom@netmech.com> for the information. | ||
380 | |||
381 | (03/21/2002) gkh | ||
382 | Added support for the Palm m130 device, thanks to Udo Eisenbarth | ||
383 | <udo.eisenbarth@web.de> for the information. | ||
384 | |||
385 | (02/27/2002) gkh | ||
386 | Reworked the urb handling logic. We have no more pool, but dynamically | ||
387 | allocate the urb and the transfer buffer on the fly. In testing this | ||
388 | does not incure any measurable overhead. This also relies on the fact | ||
389 | that we have proper reference counting logic for urbs. | ||
390 | |||
391 | (02/21/2002) SilaS | ||
392 | Added initial support for the Palm m515 devices. | ||
393 | |||
394 | (02/14/2002) gkh | ||
395 | Added support for the Clie S-360 device. | ||
396 | |||
397 | (12/18/2001) gkh | ||
398 | Added better Clie support for 3.5 devices. Thanks to Geoffrey Levand | ||
399 | for the patch. | ||
400 | |||
401 | (11/11/2001) gkh | ||
402 | Added support for the m125 devices, and added check to prevent oopses | ||
403 | for Clié devices that lie about the number of ports they have. | ||
404 | |||
405 | (08/30/2001) gkh | ||
406 | Added support for the Clie devices, both the 3.5 and 4.0 os versions. | ||
407 | Many thanks to Daniel Burke, and Bryan Payne for helping with this. | ||
408 | |||
409 | (08/23/2001) gkh | ||
410 | fixed a few potential bugs pointed out by Oliver Neukum. | ||
411 | |||
412 | (05/30/2001) gkh | ||
413 | switched from using spinlock to a semaphore, which fixes lots of problems. | ||
414 | |||
415 | (05/28/2000) gkh | ||
416 | Added initial support for the Palm m500 and Palm m505 devices. | ||
417 | |||
418 | (04/08/2001) gb | ||
419 | Identify version on module load. | ||
420 | |||
421 | (01/21/2000) gkh | ||
422 | Added write_room and chars_in_buffer, as they were previously using the | ||
423 | generic driver versions which is all wrong now that we are using an urb | ||
424 | pool. Thanks to Wolfgang Grandegger for pointing this out to me. | ||
425 | Removed count assignment in the write function, which was not needed anymore | ||
426 | either. Thanks to Al Borchers for pointing this out. | ||
427 | |||
428 | (12/12/2000) gkh | ||
429 | Moved MOD_DEC to end of visor_close to be nicer, as the final write | ||
430 | message can sleep. | ||
431 | |||
432 | (11/12/2000) gkh | ||
433 | Fixed bug with data being dropped on the floor by forcing tty->low_latency | ||
434 | to be on. Hopefully this fixes the OHCI issue! | ||
435 | |||
436 | (11/01/2000) Adam J. Richter | ||
437 | usb_device_id table support | ||
438 | |||
439 | (10/05/2000) gkh | ||
440 | Fixed bug with urb->dev not being set properly, now that the usb | ||
441 | core needs it. | ||
442 | |||
443 | (09/11/2000) gkh | ||
444 | Got rid of always calling kmalloc for every urb we wrote out to the | ||
445 | device. | ||
446 | Added visor_read_callback so we can keep track of bytes in and out for | ||
447 | those people who like to know the speed of their device. | ||
448 | Removed DEBUG #ifdefs with call to usb_serial_debug_data | ||
449 | |||
450 | (09/06/2000) gkh | ||
451 | Fixed oops in visor_exit. Need to uncomment usb_unlink_urb call _after_ | ||
452 | the host controller drivers set urb->dev = NULL when the urb is finished. | ||
453 | |||
454 | (08/28/2000) gkh | ||
455 | Added locks for SMP safeness. | ||
456 | |||
457 | (08/08/2000) gkh | ||
458 | Fixed endian problem in visor_startup. | ||
459 | Fixed MOD_INC and MOD_DEC logic and the ability to open a port more | ||
460 | than once. | ||
461 | |||
462 | (07/23/2000) gkh | ||
463 | Added pool of write urbs to speed up transfers to the visor. | ||
464 | |||
465 | (07/19/2000) gkh | ||
466 | Added module_init and module_exit functions to handle the fact that this | ||
467 | driver is a loadable module now. | ||
468 | |||
469 | (07/03/2000) gkh | ||
470 | Added visor_set_ioctl and visor_set_termios functions (they don't do much | ||
471 | of anything, but are good for debugging.) | ||
472 | |||
473 | (06/25/2000) gkh | ||
474 | Fixed bug in visor_unthrottle that should help with the disconnect in PPP | ||
475 | bug that people have been reporting. | ||
476 | |||
477 | (06/23/2000) gkh | ||
478 | Cleaned up debugging statements in a quest to find UHCI timeout bug. | ||
479 | |||
480 | (04/27/2000) Ryan VanderBijl | ||
481 | Fixed memory leak in visor_close | ||
482 | |||
483 | (03/26/2000) gkh | ||
484 | Split driver up into device specific pieces. | ||
485 | |||
486 | ----------------------------------------------------------------------- | ||
487 | pl2303.c Change Log comments: | ||
488 | |||
489 | 2002_Mar_26 gkh | ||
490 | allowed driver to work properly if there is no tty assigned to a port | ||
491 | (this happens for serial console devices.) | ||
492 | |||
493 | 2001_Oct_06 gkh | ||
494 | Added RTS and DTR line control. Thanks to joe@bndlg.de for parts of it. | ||
495 | |||
496 | 2001_Sep_19 gkh | ||
497 | Added break support. | ||
498 | |||
499 | 2001_Aug_30 gkh | ||
500 | fixed oops in write_bulk_callback. | ||
501 | |||
502 | 2001_Aug_28 gkh | ||
503 | reworked buffer logic to be like other usb-serial drivers. Hopefully | ||
504 | removing some reported problems. | ||
505 | |||
506 | 2001_Jun_06 gkh | ||
507 | finished porting to 2.4 format. | ||
508 | |||
509 | |||
510 | ----------------------------------------------------------------------- | ||
511 | io_edgeport.c Change Log comments: | ||
512 | |||
513 | 2003_04_03 al borchers | ||
514 | - fixed a bug (that shows up with dosemu) where the tty struct is | ||
515 | used in a callback after it has been freed | ||
516 | |||
517 | 2.3 2002_03_08 greg kroah-hartman | ||
518 | - fixed bug when multiple devices were attached at the same time. | ||
519 | |||
520 | 2.2 2001_11_14 greg kroah-hartman | ||
521 | - fixed bug in edge_close that kept the port from being used more | ||
522 | than once. | ||
523 | - fixed memory leak on device removal. | ||
524 | - fixed potential double free of memory when command urb submitting | ||
525 | failed. | ||
526 | - other small cleanups when the device is removed | ||
527 | |||
528 | 2.1 2001_07_09 greg kroah-hartman | ||
529 | - added support for TIOCMBIS and TIOCMBIC. | ||
530 | |||
531 | (04/08/2001) gb | ||
532 | - Identify version on module load. | ||
533 | |||
534 | 2.0 2001_03_05 greg kroah-hartman | ||
535 | - reworked entire driver to fit properly in with the other usb-serial | ||
536 | drivers. Occasional oopses still happen, but it's a good start. | ||
537 | |||
538 | 1.2.3 (02/23/2001) greg kroah-hartman | ||
539 | - changed device table to work properly for 2.4.x final format. | ||
540 | - fixed problem with dropping data at high data rates. | ||
541 | |||
542 | 1.2.2 (11/27/2000) greg kroah-hartman | ||
543 | - cleaned up more NTisms. | ||
544 | - Added device table for 2.4.0-test11 | ||
545 | |||
546 | 1.2.1 (11/08/2000) greg kroah-hartman | ||
547 | - Started to clean up NTisms. | ||
548 | - Fixed problem with dev field of urb for kernels >= 2.4.0-test9 | ||
549 | |||
550 | 1.2 (10/17/2000) David Iacovelli | ||
551 | Remove all EPIC code and GPL source | ||
552 | Fix RELEVANT_IFLAG macro to include flow control | ||
553 | changes port configuration changes. | ||
554 | Fix redefinition of SERIAL_MAGIC | ||
555 | Change all timeout values to 5 seconds | ||
556 | Tried to fix the UHCI multiple urb submission, but failed miserably. | ||
557 | it seems to work fine with OHCI. | ||
558 | ( Greg take a look at the #if 0 at end of WriteCmdUsb() we must | ||
559 | find a way to work arount this UHCI bug ) | ||
560 | |||
561 | 1.1 (10/11/2000) David Iacovelli | ||
562 | Fix XON/XOFF flow control to support both IXON and IXOFF | ||
563 | |||
564 | 0.9.27 (06/30/2000) David Iacovelli | ||
565 | Added transmit queue and now allocate urb for command writes. | ||
566 | |||
567 | 0.9.26 (06/29/2000) David Iacovelli | ||
568 | Add support for 80251 based edgeport | ||
569 | |||
570 | 0.9.25 (06/27/2000) David Iacovelli | ||
571 | Do not close the port if it has multiple opens. | ||
572 | |||
573 | 0.9.24 (05/26/2000) David Iacovelli | ||
574 | Add IOCTLs to support RXTX and JAVA POS | ||
575 | and first cut at running BlackBox Demo | ||
576 | |||
577 | 0.9.23 (05/24/2000) David Iacovelli | ||
578 | Add IOCTLs to support RXTX and JAVA POS | ||
579 | |||
580 | 0.9.22 (05/23/2000) David Iacovelli | ||
581 | fixed bug in enumeration. If epconfig turns on mapping by | ||
582 | path after a device is already plugged in, we now update | ||
583 | the mapping correctly | ||
584 | |||
585 | 0.9.21 (05/16/2000) David Iacovelli | ||
586 | Added BlockUntilChaseResp() to also wait for txcredits | ||
587 | Updated the way we allocate and handle write URBs | ||
588 | Add debug code to dump buffers | ||
589 | |||
590 | 0.9.20 (05/01/2000) David Iacovelli | ||
591 | change driver to use usb/tts/ | ||
592 | |||
593 | 0.9.19 (05/01/2000) David Iacovelli | ||
594 | Update code to compile if DEBUG is off | ||
595 | |||
596 | 0.9.18 (04/28/2000) David Iacovelli | ||
597 | cleanup and test tty_register with devfs | ||
598 | |||
599 | 0.9.17 (04/27/2000) greg kroah-hartman | ||
600 | changed tty_register around to be like the way it | ||
601 | was before, but now it works properly with devfs. | ||
602 | |||
603 | 0.9.16 (04/26/2000) david iacovelli | ||
604 | Fixed bug in GetProductInfo() | ||
605 | |||
606 | 0.9.15 (04/25/2000) david iacovelli | ||
607 | Updated enumeration | ||
608 | |||
609 | 0.9.14 (04/24/2000) david iacovelli | ||
610 | Removed all config/status IOCTLS and | ||
611 | converted to using /proc/edgeport | ||
612 | still playing with devfs | ||
613 | |||
614 | 0.9.13 (04/24/2000) david iacovelli | ||
615 | Removed configuration based on ttyUSB0 | ||
616 | Added support for configuration using /prod/edgeport | ||
617 | first attempt at using devfs (not working yet!) | ||
618 | Added IOCTL to GetProductInfo() | ||
619 | Added support for custom baud rates | ||
620 | Add support for random port numbers | ||
621 | |||
622 | 0.9.12 (04/18/2000) david iacovelli | ||
623 | added additional configuration IOCTLs | ||
624 | use ttyUSB0 for configuration | ||
625 | |||
626 | 0.9.11 (04/17/2000) greg kroah-hartman | ||
627 | fixed module initialization race conditions. | ||
628 | made all urbs dynamically allocated. | ||
629 | made driver devfs compatible. now it only registers the tty device | ||
630 | when the device is actually plugged in. | ||
631 | |||
632 | 0.9.10 (04/13/2000) greg kroah-hartman | ||
633 | added proc interface framework. | ||
634 | |||
635 | 0.9.9 (04/13/2000) david iacovelli | ||
636 | added enumeration code and ioctls to configure the device | ||
637 | |||
638 | 0.9.8 (04/12/2000) david iacovelli | ||
639 | Change interrupt read start when device is plugged in | ||
640 | and stop when device is removed | ||
641 | process interrupt reads when all ports are closed | ||
642 | (keep value of rxBytesAvail consistent with the edgeport) | ||
643 | set the USB_BULK_QUEUE flag so that we can shove a bunch | ||
644 | of urbs at once down the pipe | ||
645 | |||
646 | 0.9.7 (04/10/2000) david iacovelli | ||
647 | start to add enumeration code. | ||
648 | generate serial number for epic devices | ||
649 | add support for kdb | ||
650 | |||
651 | 0.9.6 (03/30/2000) david iacovelli | ||
652 | add IOCTL to get string, manufacture, and boot descriptors | ||
653 | |||
654 | 0.9.5 (03/14/2000) greg kroah-hartman | ||
655 | more error checking added to SerialOpen to try to fix UHCI open problem | ||
656 | |||
657 | 0.9.4 (03/09/2000) greg kroah-hartman | ||
658 | added more error checking to handle oops when data is hanging | ||
659 | around and tty is abruptly closed. | ||
660 | |||
661 | 0.9.3 (03/09/2000) david iacovelli | ||
662 | Add epic support for xon/xoff chars | ||
663 | play with performance | ||
664 | |||
665 | 0.9.2 (03/08/2000) greg kroah-hartman | ||
666 | changed most "info" calls to "dbg" | ||
667 | implemented flow control properly in the termios call | ||
668 | |||
669 | 0.9.1 (03/08/2000) david iacovelli | ||
670 | added EPIC support | ||
671 | enabled bootloader update | ||
672 | |||
673 | 0.9 (03/08/2000) greg kroah-hartman | ||
674 | Release to IO networks. | ||
675 | Integrated changes that David made | ||
676 | made getting urbs for writing SMP safe | ||
677 | |||
678 | 0.8 (03/07/2000) greg kroah-hartman | ||
679 | Release to IO networks. | ||
680 | Fixed problems that were seen in code by David. | ||
681 | Now both Edgeport/4 and Edgeport/2 works properly. | ||
682 | Changed most of the functions to use port instead of serial. | ||
683 | |||
684 | 0.7 (02/27/2000) greg kroah-hartman | ||
685 | Milestone 3 release. | ||
686 | Release to IO Networks | ||
687 | ioctl for waiting on line change implemented. | ||
688 | ioctl for getting statistics implemented. | ||
689 | multiport support working. | ||
690 | lsr and msr registers are now handled properly. | ||
691 | change break now hooked up and working. | ||
692 | support for all known Edgeport devices. | ||
693 | |||
694 | 0.6 (02/22/2000) greg kroah-hartman | ||
695 | Release to IO networks. | ||
696 | CHASE is implemented correctly when port is closed. | ||
697 | SerialOpen now blocks correctly until port is fully opened. | ||
698 | |||
699 | 0.5 (02/20/2000) greg kroah-hartman | ||
700 | Release to IO networks. | ||
701 | Known problems: | ||
702 | modem status register changes are not sent on to the user | ||
703 | CHASE is not implemented when the port is closed. | ||
704 | |||
705 | 0.4 (02/16/2000) greg kroah-hartman | ||
706 | Second cut at the CeBit demo. | ||
707 | Doesn't leak memory on every write to the port | ||
708 | Still small leaks on startup. | ||
709 | Added support for Edgeport/2 and Edgeport/8 | ||
710 | |||
711 | 0.3 (02/15/2000) greg kroah-hartman | ||
712 | CeBit demo release. | ||
713 | Force the line settings to 4800, 8, 1, e for the demo. | ||
714 | Warning! This version leaks memory like crazy! | ||
715 | |||
716 | 0.2 (01/30/2000) greg kroah-hartman | ||
717 | Milestone 1 release. | ||
718 | Device is found by USB subsystem, enumerated, fimware is downloaded | ||
719 | and the descriptors are printed to the debug log, config is set, and | ||
720 | green light starts to blink. Open port works, and data can be sent | ||
721 | and received at the default settings of the UART. Loopback connector | ||
722 | and debug log confirms this. | ||
723 | |||
724 | 0.1 (01/23/2000) greg kroah-hartman | ||
725 | Initial release to help IO Networks try to set up their test system. | ||
726 | Edgeport4 is recognized, firmware is downloaded, config is set so | ||
727 | device blinks green light every 3 sec. Port is bound, but opening, | ||
728 | closing, and sending data do not work properly. | ||
729 | |||
730 | |||
diff --git a/drivers/usb/serial/Kconfig b/drivers/usb/serial/Kconfig index 9438909e87a5..14f55fd26a64 100644 --- a/drivers/usb/serial/Kconfig +++ b/drivers/usb/serial/Kconfig | |||
@@ -62,6 +62,15 @@ config USB_SERIAL_AIRPRIME | |||
62 | To compile this driver as a module, choose M here: the | 62 | To compile this driver as a module, choose M here: the |
63 | module will be called airprime. | 63 | module will be called airprime. |
64 | 64 | ||
65 | config USB_SERIAL_ANYDATA | ||
66 | tristate "USB AnyData CDMA Wireless Driver" | ||
67 | depends on USB_SERIAL | ||
68 | help | ||
69 | Say Y here if you want to use a AnyData CDMA device. | ||
70 | |||
71 | To compile this driver as a module, choose M here: the | ||
72 | module will be called anydata. | ||
73 | |||
65 | config USB_SERIAL_BELKIN | 74 | config USB_SERIAL_BELKIN |
66 | tristate "USB Belkin and Peracom Single Port Serial Driver" | 75 | tristate "USB Belkin and Peracom Single Port Serial Driver" |
67 | depends on USB_SERIAL | 76 | depends on USB_SERIAL |
diff --git a/drivers/usb/serial/Makefile b/drivers/usb/serial/Makefile index 6c7cdcc99a9e..f0b04420cea1 100644 --- a/drivers/usb/serial/Makefile +++ b/drivers/usb/serial/Makefile | |||
@@ -12,6 +12,7 @@ usbserial-obj-$(CONFIG_USB_EZUSB) += ezusb.o | |||
12 | usbserial-objs := usb-serial.o generic.o bus.o $(usbserial-obj-y) | 12 | usbserial-objs := usb-serial.o generic.o bus.o $(usbserial-obj-y) |
13 | 13 | ||
14 | obj-$(CONFIG_USB_SERIAL_AIRPRIME) += airprime.o | 14 | obj-$(CONFIG_USB_SERIAL_AIRPRIME) += airprime.o |
15 | obj-$(CONFIG_USB_SERIAL_ANYDATA) += anydata.o | ||
15 | obj-$(CONFIG_USB_SERIAL_BELKIN) += belkin_sa.o | 16 | obj-$(CONFIG_USB_SERIAL_BELKIN) += belkin_sa.o |
16 | obj-$(CONFIG_USB_SERIAL_CP2101) += cp2101.o | 17 | obj-$(CONFIG_USB_SERIAL_CP2101) += cp2101.o |
17 | obj-$(CONFIG_USB_SERIAL_CYBERJACK) += cyberjack.o | 18 | obj-$(CONFIG_USB_SERIAL_CYBERJACK) += cyberjack.o |
diff --git a/drivers/usb/serial/airprime.c b/drivers/usb/serial/airprime.c index a4ce0008d69b..1f29d8837327 100644 --- a/drivers/usb/serial/airprime.c +++ b/drivers/usb/serial/airprime.c | |||
@@ -16,7 +16,8 @@ | |||
16 | #include "usb-serial.h" | 16 | #include "usb-serial.h" |
17 | 17 | ||
18 | static struct usb_device_id id_table [] = { | 18 | static struct usb_device_id id_table [] = { |
19 | { USB_DEVICE(0xf3d, 0x0112) }, | 19 | { USB_DEVICE(0xf3d, 0x0112) }, /* AirPrime CDMA Wireless PC Card */ |
20 | { USB_DEVICE(0x1410, 0x1110) }, /* Novatel Wireless Merlin CDMA */ | ||
20 | { }, | 21 | { }, |
21 | }; | 22 | }; |
22 | MODULE_DEVICE_TABLE(usb, id_table); | 23 | MODULE_DEVICE_TABLE(usb, id_table); |
@@ -29,9 +30,11 @@ static struct usb_driver airprime_driver = { | |||
29 | .id_table = id_table, | 30 | .id_table = id_table, |
30 | }; | 31 | }; |
31 | 32 | ||
32 | static struct usb_serial_device_type airprime_device = { | 33 | static struct usb_serial_driver airprime_device = { |
33 | .owner = THIS_MODULE, | 34 | .driver = { |
34 | .name = "airprime", | 35 | .owner = THIS_MODULE, |
36 | .name = "airprime", | ||
37 | }, | ||
35 | .id_table = id_table, | 38 | .id_table = id_table, |
36 | .num_interrupt_in = NUM_DONT_CARE, | 39 | .num_interrupt_in = NUM_DONT_CARE, |
37 | .num_bulk_in = NUM_DONT_CARE, | 40 | .num_bulk_in = NUM_DONT_CARE, |
diff --git a/drivers/usb/serial/anydata.c b/drivers/usb/serial/anydata.c new file mode 100644 index 000000000000..18022a74a3dc --- /dev/null +++ b/drivers/usb/serial/anydata.c | |||
@@ -0,0 +1,123 @@ | |||
1 | /* | ||
2 | * AnyData CDMA Serial USB driver | ||
3 | * | ||
4 | * Copyright (C) 2005 Greg Kroah-Hartman <gregkh@suse.de> | ||
5 | * | ||
6 | * This program is free software; you can redistribute it and/or | ||
7 | * modify it under the terms of the GNU General Public License version | ||
8 | * 2 as published by the Free Software Foundation. | ||
9 | */ | ||
10 | |||
11 | #include <linux/kernel.h> | ||
12 | #include <linux/init.h> | ||
13 | #include <linux/tty.h> | ||
14 | #include <linux/module.h> | ||
15 | #include <linux/usb.h> | ||
16 | #include "usb-serial.h" | ||
17 | |||
18 | static struct usb_device_id id_table [] = { | ||
19 | { USB_DEVICE(0x16d5, 0x6501) }, /* AirData CDMA device */ | ||
20 | { }, | ||
21 | }; | ||
22 | MODULE_DEVICE_TABLE(usb, id_table); | ||
23 | |||
24 | /* if overridden by the user, then use their value for the size of the | ||
25 | * read and write urbs */ | ||
26 | static int buffer_size; | ||
27 | static int debug; | ||
28 | |||
29 | static struct usb_driver anydata_driver = { | ||
30 | .owner = THIS_MODULE, | ||
31 | .name = "anydata", | ||
32 | .probe = usb_serial_probe, | ||
33 | .disconnect = usb_serial_disconnect, | ||
34 | .id_table = id_table, | ||
35 | }; | ||
36 | |||
37 | static int anydata_open(struct usb_serial_port *port, struct file *filp) | ||
38 | { | ||
39 | char *buffer; | ||
40 | int result = 0; | ||
41 | |||
42 | dbg("%s - port %d", __FUNCTION__, port->number); | ||
43 | |||
44 | if (buffer_size) { | ||
45 | /* override the default buffer sizes */ | ||
46 | buffer = kmalloc(buffer_size, GFP_KERNEL); | ||
47 | if (!buffer) { | ||
48 | dev_err(&port->dev, "%s - out of memory.\n", | ||
49 | __FUNCTION__); | ||
50 | return -ENOMEM; | ||
51 | } | ||
52 | kfree (port->read_urb->transfer_buffer); | ||
53 | port->read_urb->transfer_buffer = buffer; | ||
54 | port->read_urb->transfer_buffer_length = buffer_size; | ||
55 | |||
56 | buffer = kmalloc(buffer_size, GFP_KERNEL); | ||
57 | if (!buffer) { | ||
58 | dev_err(&port->dev, "%s - out of memory.\n", | ||
59 | __FUNCTION__); | ||
60 | return -ENOMEM; | ||
61 | } | ||
62 | kfree (port->write_urb->transfer_buffer); | ||
63 | port->write_urb->transfer_buffer = buffer; | ||
64 | port->write_urb->transfer_buffer_length = buffer_size; | ||
65 | port->bulk_out_size = buffer_size; | ||
66 | } | ||
67 | |||
68 | /* Start reading from the device */ | ||
69 | usb_fill_bulk_urb(port->read_urb, port->serial->dev, | ||
70 | usb_rcvbulkpipe(port->serial->dev, | ||
71 | port->bulk_in_endpointAddress), | ||
72 | port->read_urb->transfer_buffer, | ||
73 | port->read_urb->transfer_buffer_length, | ||
74 | usb_serial_generic_write_bulk_callback, port); | ||
75 | result = usb_submit_urb(port->read_urb, GFP_KERNEL); | ||
76 | if (result) | ||
77 | dev_err(&port->dev, | ||
78 | "%s - failed submitting read urb, error %d\n", | ||
79 | __FUNCTION__, result); | ||
80 | |||
81 | return result; | ||
82 | } | ||
83 | |||
84 | static struct usb_serial_driver anydata_device = { | ||
85 | .driver = { | ||
86 | .owner = THIS_MODULE, | ||
87 | .name = "anydata", | ||
88 | }, | ||
89 | .id_table = id_table, | ||
90 | .num_interrupt_in = NUM_DONT_CARE, | ||
91 | .num_bulk_in = NUM_DONT_CARE, | ||
92 | .num_bulk_out = NUM_DONT_CARE, | ||
93 | .num_ports = 1, | ||
94 | .open = anydata_open, | ||
95 | }; | ||
96 | |||
97 | static int __init anydata_init(void) | ||
98 | { | ||
99 | int retval; | ||
100 | |||
101 | retval = usb_serial_register(&anydata_device); | ||
102 | if (retval) | ||
103 | return retval; | ||
104 | retval = usb_register(&anydata_driver); | ||
105 | if (retval) | ||
106 | usb_serial_deregister(&anydata_device); | ||
107 | return retval; | ||
108 | } | ||
109 | |||
110 | static void __exit anydata_exit(void) | ||
111 | { | ||
112 | usb_deregister(&anydata_driver); | ||
113 | usb_serial_deregister(&anydata_device); | ||
114 | } | ||
115 | |||
116 | module_init(anydata_init); | ||
117 | module_exit(anydata_exit); | ||
118 | MODULE_LICENSE("GPL"); | ||
119 | |||
120 | module_param(debug, bool, S_IRUGO | S_IWUSR); | ||
121 | MODULE_PARM_DESC(debug, "Debug enabled or not"); | ||
122 | module_param(buffer_size, int, 0); | ||
123 | MODULE_PARM_DESC(buffer_size, "Size of the transfer buffers"); | ||
diff --git a/drivers/usb/serial/belkin_sa.c b/drivers/usb/serial/belkin_sa.c index abb1b2c543bb..84bc0ee4f061 100644 --- a/drivers/usb/serial/belkin_sa.c +++ b/drivers/usb/serial/belkin_sa.c | |||
@@ -121,10 +121,12 @@ static struct usb_driver belkin_driver = { | |||
121 | }; | 121 | }; |
122 | 122 | ||
123 | /* All of the device info needed for the serial converters */ | 123 | /* All of the device info needed for the serial converters */ |
124 | static struct usb_serial_device_type belkin_device = { | 124 | static struct usb_serial_driver belkin_device = { |
125 | .owner = THIS_MODULE, | 125 | .driver = { |
126 | .name = "Belkin / Peracom / GoHubs USB Serial Adapter", | 126 | .owner = THIS_MODULE, |
127 | .short_name = "belkin", | 127 | .name = "belkin", |
128 | }, | ||
129 | .description = "Belkin / Peracom / GoHubs USB Serial Adapter", | ||
128 | .id_table = id_table_combined, | 130 | .id_table = id_table_combined, |
129 | .num_interrupt_in = 1, | 131 | .num_interrupt_in = 1, |
130 | .num_bulk_in = 1, | 132 | .num_bulk_in = 1, |
diff --git a/drivers/usb/serial/bus.c b/drivers/usb/serial/bus.c index 2f612c2d894b..664139afcfa9 100644 --- a/drivers/usb/serial/bus.c +++ b/drivers/usb/serial/bus.c | |||
@@ -18,7 +18,7 @@ | |||
18 | 18 | ||
19 | static int usb_serial_device_match (struct device *dev, struct device_driver *drv) | 19 | static int usb_serial_device_match (struct device *dev, struct device_driver *drv) |
20 | { | 20 | { |
21 | struct usb_serial_device_type *driver; | 21 | struct usb_serial_driver *driver; |
22 | const struct usb_serial_port *port; | 22 | const struct usb_serial_port *port; |
23 | 23 | ||
24 | /* | 24 | /* |
@@ -44,7 +44,7 @@ struct bus_type usb_serial_bus_type = { | |||
44 | 44 | ||
45 | static int usb_serial_device_probe (struct device *dev) | 45 | static int usb_serial_device_probe (struct device *dev) |
46 | { | 46 | { |
47 | struct usb_serial_device_type *driver; | 47 | struct usb_serial_driver *driver; |
48 | struct usb_serial_port *port; | 48 | struct usb_serial_port *port; |
49 | int retval = 0; | 49 | int retval = 0; |
50 | int minor; | 50 | int minor; |
@@ -57,13 +57,13 @@ static int usb_serial_device_probe (struct device *dev) | |||
57 | 57 | ||
58 | driver = port->serial->type; | 58 | driver = port->serial->type; |
59 | if (driver->port_probe) { | 59 | if (driver->port_probe) { |
60 | if (!try_module_get(driver->owner)) { | 60 | if (!try_module_get(driver->driver.owner)) { |
61 | dev_err(dev, "module get failed, exiting\n"); | 61 | dev_err(dev, "module get failed, exiting\n"); |
62 | retval = -EIO; | 62 | retval = -EIO; |
63 | goto exit; | 63 | goto exit; |
64 | } | 64 | } |
65 | retval = driver->port_probe (port); | 65 | retval = driver->port_probe (port); |
66 | module_put(driver->owner); | 66 | module_put(driver->driver.owner); |
67 | if (retval) | 67 | if (retval) |
68 | goto exit; | 68 | goto exit; |
69 | } | 69 | } |
@@ -72,7 +72,7 @@ static int usb_serial_device_probe (struct device *dev) | |||
72 | tty_register_device (usb_serial_tty_driver, minor, dev); | 72 | tty_register_device (usb_serial_tty_driver, minor, dev); |
73 | dev_info(&port->serial->dev->dev, | 73 | dev_info(&port->serial->dev->dev, |
74 | "%s converter now attached to ttyUSB%d\n", | 74 | "%s converter now attached to ttyUSB%d\n", |
75 | driver->name, minor); | 75 | driver->description, minor); |
76 | 76 | ||
77 | exit: | 77 | exit: |
78 | return retval; | 78 | return retval; |
@@ -80,7 +80,7 @@ exit: | |||
80 | 80 | ||
81 | static int usb_serial_device_remove (struct device *dev) | 81 | static int usb_serial_device_remove (struct device *dev) |
82 | { | 82 | { |
83 | struct usb_serial_device_type *driver; | 83 | struct usb_serial_driver *driver; |
84 | struct usb_serial_port *port; | 84 | struct usb_serial_port *port; |
85 | int retval = 0; | 85 | int retval = 0; |
86 | int minor; | 86 | int minor; |
@@ -92,43 +92,38 @@ static int usb_serial_device_remove (struct device *dev) | |||
92 | 92 | ||
93 | driver = port->serial->type; | 93 | driver = port->serial->type; |
94 | if (driver->port_remove) { | 94 | if (driver->port_remove) { |
95 | if (!try_module_get(driver->owner)) { | 95 | if (!try_module_get(driver->driver.owner)) { |
96 | dev_err(dev, "module get failed, exiting\n"); | 96 | dev_err(dev, "module get failed, exiting\n"); |
97 | retval = -EIO; | 97 | retval = -EIO; |
98 | goto exit; | 98 | goto exit; |
99 | } | 99 | } |
100 | retval = driver->port_remove (port); | 100 | retval = driver->port_remove (port); |
101 | module_put(driver->owner); | 101 | module_put(driver->driver.owner); |
102 | } | 102 | } |
103 | exit: | 103 | exit: |
104 | minor = port->number; | 104 | minor = port->number; |
105 | tty_unregister_device (usb_serial_tty_driver, minor); | 105 | tty_unregister_device (usb_serial_tty_driver, minor); |
106 | dev_info(dev, "%s converter now disconnected from ttyUSB%d\n", | 106 | dev_info(dev, "%s converter now disconnected from ttyUSB%d\n", |
107 | driver->name, minor); | 107 | driver->description, minor); |
108 | 108 | ||
109 | return retval; | 109 | return retval; |
110 | } | 110 | } |
111 | 111 | ||
112 | int usb_serial_bus_register(struct usb_serial_device_type *device) | 112 | int usb_serial_bus_register(struct usb_serial_driver *driver) |
113 | { | 113 | { |
114 | int retval; | 114 | int retval; |
115 | 115 | ||
116 | if (device->short_name) | 116 | driver->driver.bus = &usb_serial_bus_type; |
117 | device->driver.name = (char *)device->short_name; | 117 | driver->driver.probe = usb_serial_device_probe; |
118 | else | 118 | driver->driver.remove = usb_serial_device_remove; |
119 | device->driver.name = (char *)device->name; | ||
120 | device->driver.bus = &usb_serial_bus_type; | ||
121 | device->driver.probe = usb_serial_device_probe; | ||
122 | device->driver.remove = usb_serial_device_remove; | ||
123 | device->driver.owner = device->owner; | ||
124 | 119 | ||
125 | retval = driver_register(&device->driver); | 120 | retval = driver_register(&driver->driver); |
126 | 121 | ||
127 | return retval; | 122 | return retval; |
128 | } | 123 | } |
129 | 124 | ||
130 | void usb_serial_bus_deregister(struct usb_serial_device_type *device) | 125 | void usb_serial_bus_deregister(struct usb_serial_driver *driver) |
131 | { | 126 | { |
132 | driver_unregister (&device->driver); | 127 | driver_unregister(&driver->driver); |
133 | } | 128 | } |
134 | 129 | ||
diff --git a/drivers/usb/serial/cp2101.c b/drivers/usb/serial/cp2101.c index 97c78c21e8d1..c9787001cf2a 100644 --- a/drivers/usb/serial/cp2101.c +++ b/drivers/usb/serial/cp2101.c | |||
@@ -60,6 +60,7 @@ static struct usb_device_id id_table [] = { | |||
60 | { USB_DEVICE(0x10C4, 0x80F6) }, /* Suunto sports instrument */ | 60 | { USB_DEVICE(0x10C4, 0x80F6) }, /* Suunto sports instrument */ |
61 | { USB_DEVICE(0x10A6, 0xAA26) }, /* Knock-off DCU-11 cable */ | 61 | { USB_DEVICE(0x10A6, 0xAA26) }, /* Knock-off DCU-11 cable */ |
62 | { USB_DEVICE(0x10AB, 0x10C5) }, /* Siemens MC60 Cable */ | 62 | { USB_DEVICE(0x10AB, 0x10C5) }, /* Siemens MC60 Cable */ |
63 | { USB_DEVICE(0x16D6, 0x0001) }, /* Jablotron serial interface */ | ||
63 | { } /* Terminating Entry */ | 64 | { } /* Terminating Entry */ |
64 | }; | 65 | }; |
65 | 66 | ||
@@ -67,15 +68,17 @@ MODULE_DEVICE_TABLE (usb, id_table); | |||
67 | 68 | ||
68 | static struct usb_driver cp2101_driver = { | 69 | static struct usb_driver cp2101_driver = { |
69 | .owner = THIS_MODULE, | 70 | .owner = THIS_MODULE, |
70 | .name = "CP2101", | 71 | .name = "cp2101", |
71 | .probe = usb_serial_probe, | 72 | .probe = usb_serial_probe, |
72 | .disconnect = usb_serial_disconnect, | 73 | .disconnect = usb_serial_disconnect, |
73 | .id_table = id_table, | 74 | .id_table = id_table, |
74 | }; | 75 | }; |
75 | 76 | ||
76 | static struct usb_serial_device_type cp2101_device = { | 77 | static struct usb_serial_driver cp2101_device = { |
77 | .owner = THIS_MODULE, | 78 | .driver = { |
78 | .name = "CP2101", | 79 | .owner = THIS_MODULE, |
80 | .name = "cp2101", | ||
81 | }, | ||
79 | .id_table = id_table, | 82 | .id_table = id_table, |
80 | .num_interrupt_in = 0, | 83 | .num_interrupt_in = 0, |
81 | .num_bulk_in = 0, | 84 | .num_bulk_in = 0, |
diff --git a/drivers/usb/serial/cyberjack.c b/drivers/usb/serial/cyberjack.c index b5b431067b08..e581e4ae8483 100644 --- a/drivers/usb/serial/cyberjack.c +++ b/drivers/usb/serial/cyberjack.c | |||
@@ -83,10 +83,12 @@ static struct usb_driver cyberjack_driver = { | |||
83 | .id_table = id_table, | 83 | .id_table = id_table, |
84 | }; | 84 | }; |
85 | 85 | ||
86 | static struct usb_serial_device_type cyberjack_device = { | 86 | static struct usb_serial_driver cyberjack_device = { |
87 | .owner = THIS_MODULE, | 87 | .driver = { |
88 | .name = "Reiner SCT Cyberjack USB card reader", | 88 | .owner = THIS_MODULE, |
89 | .short_name = "cyberjack", | 89 | .name = "cyberjack", |
90 | }, | ||
91 | .description = "Reiner SCT Cyberjack USB card reader", | ||
90 | .id_table = id_table, | 92 | .id_table = id_table, |
91 | .num_interrupt_in = 1, | 93 | .num_interrupt_in = 1, |
92 | .num_bulk_in = 1, | 94 | .num_bulk_in = 1, |
diff --git a/drivers/usb/serial/cypress_m8.c b/drivers/usb/serial/cypress_m8.c index 9ee1aaff2fcd..af9290ed257b 100644 --- a/drivers/usb/serial/cypress_m8.c +++ b/drivers/usb/serial/cypress_m8.c | |||
@@ -176,10 +176,12 @@ static unsigned int cypress_buf_put(struct cypress_buf *cb, const char *buf, u | |||
176 | static unsigned int cypress_buf_get(struct cypress_buf *cb, char *buf, unsigned int count); | 176 | static unsigned int cypress_buf_get(struct cypress_buf *cb, char *buf, unsigned int count); |
177 | 177 | ||
178 | 178 | ||
179 | static struct usb_serial_device_type cypress_earthmate_device = { | 179 | static struct usb_serial_driver cypress_earthmate_device = { |
180 | .owner = THIS_MODULE, | 180 | .driver = { |
181 | .name = "DeLorme Earthmate USB", | 181 | .owner = THIS_MODULE, |
182 | .short_name = "earthmate", | 182 | .name = "earthmate", |
183 | }, | ||
184 | .description = "DeLorme Earthmate USB", | ||
183 | .id_table = id_table_earthmate, | 185 | .id_table = id_table_earthmate, |
184 | .num_interrupt_in = 1, | 186 | .num_interrupt_in = 1, |
185 | .num_interrupt_out = 1, | 187 | .num_interrupt_out = 1, |
@@ -203,10 +205,12 @@ static struct usb_serial_device_type cypress_earthmate_device = { | |||
203 | .write_int_callback = cypress_write_int_callback, | 205 | .write_int_callback = cypress_write_int_callback, |
204 | }; | 206 | }; |
205 | 207 | ||
206 | static struct usb_serial_device_type cypress_hidcom_device = { | 208 | static struct usb_serial_driver cypress_hidcom_device = { |
207 | .owner = THIS_MODULE, | 209 | .driver = { |
208 | .name = "HID->COM RS232 Adapter", | 210 | .owner = THIS_MODULE, |
209 | .short_name = "cyphidcom", | 211 | .name = "cyphidcom", |
212 | }, | ||
213 | .description = "HID->COM RS232 Adapter", | ||
210 | .id_table = id_table_cyphidcomrs232, | 214 | .id_table = id_table_cyphidcomrs232, |
211 | .num_interrupt_in = 1, | 215 | .num_interrupt_in = 1, |
212 | .num_interrupt_out = 1, | 216 | .num_interrupt_out = 1, |
diff --git a/drivers/usb/serial/digi_acceleport.c b/drivers/usb/serial/digi_acceleport.c index a19a47f6cf12..dc74644a603d 100644 --- a/drivers/usb/serial/digi_acceleport.c +++ b/drivers/usb/serial/digi_acceleport.c | |||
@@ -503,10 +503,12 @@ static struct usb_driver digi_driver = { | |||
503 | 503 | ||
504 | /* device info needed for the Digi serial converter */ | 504 | /* device info needed for the Digi serial converter */ |
505 | 505 | ||
506 | static struct usb_serial_device_type digi_acceleport_2_device = { | 506 | static struct usb_serial_driver digi_acceleport_2_device = { |
507 | .owner = THIS_MODULE, | 507 | .driver = { |
508 | .name = "Digi 2 port USB adapter", | 508 | .owner = THIS_MODULE, |
509 | .short_name = "digi_2", | 509 | .name = "digi_2", |
510 | }, | ||
511 | .description = "Digi 2 port USB adapter", | ||
510 | .id_table = id_table_2, | 512 | .id_table = id_table_2, |
511 | .num_interrupt_in = 0, | 513 | .num_interrupt_in = 0, |
512 | .num_bulk_in = 4, | 514 | .num_bulk_in = 4, |
@@ -530,10 +532,12 @@ static struct usb_serial_device_type digi_acceleport_2_device = { | |||
530 | .shutdown = digi_shutdown, | 532 | .shutdown = digi_shutdown, |
531 | }; | 533 | }; |
532 | 534 | ||
533 | static struct usb_serial_device_type digi_acceleport_4_device = { | 535 | static struct usb_serial_driver digi_acceleport_4_device = { |
534 | .owner = THIS_MODULE, | 536 | .driver = { |
535 | .name = "Digi 4 port USB adapter", | 537 | .owner = THIS_MODULE, |
536 | .short_name = "digi_4", | 538 | .name = "digi_4", |
539 | }, | ||
540 | .description = "Digi 4 port USB adapter", | ||
537 | .id_table = id_table_4, | 541 | .id_table = id_table_4, |
538 | .num_interrupt_in = 0, | 542 | .num_interrupt_in = 0, |
539 | .num_bulk_in = 5, | 543 | .num_bulk_in = 5, |
diff --git a/drivers/usb/serial/empeg.c b/drivers/usb/serial/empeg.c index 8d562ab454a8..0b0546dcc7b9 100644 --- a/drivers/usb/serial/empeg.c +++ b/drivers/usb/serial/empeg.c | |||
@@ -112,9 +112,11 @@ static struct usb_driver empeg_driver = { | |||
112 | .id_table = id_table, | 112 | .id_table = id_table, |
113 | }; | 113 | }; |
114 | 114 | ||
115 | static struct usb_serial_device_type empeg_device = { | 115 | static struct usb_serial_driver empeg_device = { |
116 | .owner = THIS_MODULE, | 116 | .driver = { |
117 | .name = "Empeg", | 117 | .owner = THIS_MODULE, |
118 | .name = "empeg", | ||
119 | }, | ||
118 | .id_table = id_table, | 120 | .id_table = id_table, |
119 | .num_interrupt_in = 0, | 121 | .num_interrupt_in = 0, |
120 | .num_bulk_in = 1, | 122 | .num_bulk_in = 1, |
diff --git a/drivers/usb/serial/ftdi_sio.c b/drivers/usb/serial/ftdi_sio.c index 4e434cb10bb1..06e04b442ff1 100644 --- a/drivers/usb/serial/ftdi_sio.c +++ b/drivers/usb/serial/ftdi_sio.c | |||
@@ -411,6 +411,8 @@ static struct usb_device_id id_table_combined [] = { | |||
411 | { USB_DEVICE(FTDI_VID, FTDI_ELV_UM100_PID) }, | 411 | { USB_DEVICE(FTDI_VID, FTDI_ELV_UM100_PID) }, |
412 | { USB_DEVICE(FTDI_VID, FTDI_ELV_UR100_PID) }, | 412 | { USB_DEVICE(FTDI_VID, FTDI_ELV_UR100_PID) }, |
413 | { USB_DEVICE(FTDI_VID, FTDI_ELV_ALC8500_PID) }, | 413 | { USB_DEVICE(FTDI_VID, FTDI_ELV_ALC8500_PID) }, |
414 | { USB_DEVICE(FTDI_VID, FTDI_PYRAMID_PID) }, | ||
415 | { USB_DEVICE(FTDI_VID, FTDI_ELV_FHZ1000PC_PID) }, | ||
414 | /* | 416 | /* |
415 | * These will probably use user-space drivers. Uncomment them if | 417 | * These will probably use user-space drivers. Uncomment them if |
416 | * you need them or use the user-specified vendor/product module | 418 | * you need them or use the user-specified vendor/product module |
@@ -428,7 +430,6 @@ static struct usb_device_id id_table_combined [] = { | |||
428 | /* { USB_DEVICE(FTDI_VID, FTDI_ELV_T1100_PID) }, */ | 430 | /* { USB_DEVICE(FTDI_VID, FTDI_ELV_T1100_PID) }, */ |
429 | /* { USB_DEVICE(FTDI_VID, FTDI_ELV_PCD200_PID) }, */ | 431 | /* { USB_DEVICE(FTDI_VID, FTDI_ELV_PCD200_PID) }, */ |
430 | /* { USB_DEVICE(FTDI_VID, FTDI_ELV_ULA200_PID) }, */ | 432 | /* { USB_DEVICE(FTDI_VID, FTDI_ELV_ULA200_PID) }, */ |
431 | /* { USB_DEVICE(FTDI_VID, FTDI_ELV_FHZ1000PC_PID) }, */ | ||
432 | /* { USB_DEVICE(FTDI_VID, FTDI_ELV_CSI8_PID) }, */ | 433 | /* { USB_DEVICE(FTDI_VID, FTDI_ELV_CSI8_PID) }, */ |
433 | /* { USB_DEVICE(FTDI_VID, FTDI_ELV_EM1000DL_PID) }, */ | 434 | /* { USB_DEVICE(FTDI_VID, FTDI_ELV_EM1000DL_PID) }, */ |
434 | /* { USB_DEVICE(FTDI_VID, FTDI_ELV_PCK100_PID) }, */ | 435 | /* { USB_DEVICE(FTDI_VID, FTDI_ELV_PCK100_PID) }, */ |
@@ -471,6 +472,11 @@ static struct usb_device_id id_table_combined [] = { | |||
471 | { USB_DEVICE(FTDI_VID, FTDI_MHAM_Y6_PID) }, | 472 | { USB_DEVICE(FTDI_VID, FTDI_MHAM_Y6_PID) }, |
472 | { USB_DEVICE(FTDI_VID, FTDI_MHAM_Y8_PID) }, | 473 | { USB_DEVICE(FTDI_VID, FTDI_MHAM_Y8_PID) }, |
473 | { USB_DEVICE(EVOLUTION_VID, EVOLUTION_ER1_PID) }, | 474 | { USB_DEVICE(EVOLUTION_VID, EVOLUTION_ER1_PID) }, |
475 | { USB_DEVICE(FTDI_VID, FTDI_ARTEMIS_PID) }, | ||
476 | { USB_DEVICE(FTDI_VID, FTDI_ATIK_ATK16_PID) }, | ||
477 | { USB_DEVICE(FTDI_VID, FTDI_ATIK_ATK16HR_PID) }, | ||
478 | { USB_DEVICE(KOBIL_VID, KOBIL_CONV_B1_PID) }, | ||
479 | { USB_DEVICE(KOBIL_VID, KOBIL_CONV_KAAN_PID) }, | ||
474 | { }, /* Optional parameter entry */ | 480 | { }, /* Optional parameter entry */ |
475 | { } /* Terminating entry */ | 481 | { } /* Terminating entry */ |
476 | }; | 482 | }; |
@@ -558,10 +564,12 @@ static unsigned short int ftdi_232am_baud_to_divisor (int baud); | |||
558 | static __u32 ftdi_232bm_baud_base_to_divisor (int baud, int base); | 564 | static __u32 ftdi_232bm_baud_base_to_divisor (int baud, int base); |
559 | static __u32 ftdi_232bm_baud_to_divisor (int baud); | 565 | static __u32 ftdi_232bm_baud_to_divisor (int baud); |
560 | 566 | ||
561 | static struct usb_serial_device_type ftdi_sio_device = { | 567 | static struct usb_serial_driver ftdi_sio_device = { |
562 | .owner = THIS_MODULE, | 568 | .driver = { |
563 | .name = "FTDI USB Serial Device", | 569 | .owner = THIS_MODULE, |
564 | .short_name = "ftdi_sio", | 570 | .name = "ftdi_sio", |
571 | }, | ||
572 | .description = "FTDI USB Serial Device", | ||
565 | .id_table = id_table_combined, | 573 | .id_table = id_table_combined, |
566 | .num_interrupt_in = 0, | 574 | .num_interrupt_in = 0, |
567 | .num_bulk_in = 1, | 575 | .num_bulk_in = 1, |
@@ -1846,10 +1854,12 @@ static void ftdi_set_termios (struct usb_serial_port *port, struct termios *old_ | |||
1846 | } else { | 1854 | } else { |
1847 | /* set the baudrate determined before */ | 1855 | /* set the baudrate determined before */ |
1848 | if (change_speed(port)) { | 1856 | if (change_speed(port)) { |
1849 | err("%s urb failed to set baurdrate", __FUNCTION__); | 1857 | err("%s urb failed to set baudrate", __FUNCTION__); |
1858 | } | ||
1859 | /* Ensure RTS and DTR are raised when baudrate changed from 0 */ | ||
1860 | if ((old_termios->c_cflag & CBAUD) == B0) { | ||
1861 | set_mctrl(port, TIOCM_DTR | TIOCM_RTS); | ||
1850 | } | 1862 | } |
1851 | /* Ensure RTS and DTR are raised */ | ||
1852 | set_mctrl(port, TIOCM_DTR | TIOCM_RTS); | ||
1853 | } | 1863 | } |
1854 | 1864 | ||
1855 | /* Set flow control */ | 1865 | /* Set flow control */ |
diff --git a/drivers/usb/serial/ftdi_sio.h b/drivers/usb/serial/ftdi_sio.h index 2c35d74cc6d6..773ea3eca086 100644 --- a/drivers/usb/serial/ftdi_sio.h +++ b/drivers/usb/serial/ftdi_sio.h | |||
@@ -128,6 +128,13 @@ | |||
128 | #define SEALEVEL_2803_8_PID 0X2883 /* SeaLINK+8 (2803) Port 8 */ | 128 | #define SEALEVEL_2803_8_PID 0X2883 /* SeaLINK+8 (2803) Port 8 */ |
129 | 129 | ||
130 | /* | 130 | /* |
131 | * The following are the values for two KOBIL chipcard terminals. | ||
132 | */ | ||
133 | #define KOBIL_VID 0x0d46 /* KOBIL Vendor ID */ | ||
134 | #define KOBIL_CONV_B1_PID 0x2020 /* KOBIL Konverter for B1 */ | ||
135 | #define KOBIL_CONV_KAAN_PID 0x2021 /* KOBIL_Konverter for KAAN */ | ||
136 | |||
137 | /* | ||
131 | * DSS-20 Sync Station for Sony Ericsson P800 | 138 | * DSS-20 Sync Station for Sony Ericsson P800 |
132 | */ | 139 | */ |
133 | 140 | ||
@@ -199,6 +206,19 @@ | |||
199 | #define FTDI_PIEGROUP_PID 0xF208 /* Product Id */ | 206 | #define FTDI_PIEGROUP_PID 0xF208 /* Product Id */ |
200 | 207 | ||
201 | /* | 208 | /* |
209 | * Definitions for Artemis astronomical USB based cameras | ||
210 | * Check it at http://www.artemisccd.co.uk/ | ||
211 | */ | ||
212 | #define FTDI_ARTEMIS_PID 0xDF28 /* All Artemis Cameras */ | ||
213 | |||
214 | /* | ||
215 | * Definitions for ATIK Instruments astronomical USB based cameras | ||
216 | * Check it at http://www.atik-instruments.com/ | ||
217 | */ | ||
218 | #define FTDI_ATIK_ATK16_PID 0xDF30 /* ATIK ATK-16 Camera */ | ||
219 | #define FTDI_ATIK_ATK16HR_PID 0xDF31 /* ATIK ATK-16HR Camera */ | ||
220 | |||
221 | /* | ||
202 | * Protego product ids | 222 | * Protego product ids |
203 | */ | 223 | */ |
204 | #define PROTEGO_SPECIAL_1 0xFC70 /* special/unknown device */ | 224 | #define PROTEGO_SPECIAL_1 0xFC70 /* special/unknown device */ |
@@ -329,6 +349,9 @@ | |||
329 | #define EVOLUTION_VID 0xDEEE /* Vendor ID */ | 349 | #define EVOLUTION_VID 0xDEEE /* Vendor ID */ |
330 | #define EVOLUTION_ER1_PID 0x0300 /* ER1 Control Module */ | 350 | #define EVOLUTION_ER1_PID 0x0300 /* ER1 Control Module */ |
331 | 351 | ||
352 | /* Pyramid Computer GmbH */ | ||
353 | #define FTDI_PYRAMID_PID 0xE6C8 /* Pyramid Appliance Display */ | ||
354 | |||
332 | /* Commands */ | 355 | /* Commands */ |
333 | #define FTDI_SIO_RESET 0 /* Reset the port */ | 356 | #define FTDI_SIO_RESET 0 /* Reset the port */ |
334 | #define FTDI_SIO_MODEM_CTRL 1 /* Set the modem control register */ | 357 | #define FTDI_SIO_MODEM_CTRL 1 /* Set the modem control register */ |
diff --git a/drivers/usb/serial/garmin_gps.c b/drivers/usb/serial/garmin_gps.c index 2ef614d5c8f2..35820bda7ae1 100644 --- a/drivers/usb/serial/garmin_gps.c +++ b/drivers/usb/serial/garmin_gps.c | |||
@@ -1468,16 +1468,13 @@ static void garmin_shutdown (struct usb_serial *serial) | |||
1468 | } | 1468 | } |
1469 | 1469 | ||
1470 | 1470 | ||
1471 | |||
1472 | |||
1473 | |||
1474 | |||
1475 | |||
1476 | /* All of the device info needed */ | 1471 | /* All of the device info needed */ |
1477 | static struct usb_serial_device_type garmin_device = { | 1472 | static struct usb_serial_driver garmin_device = { |
1478 | .owner = THIS_MODULE, | 1473 | .driver = { |
1479 | .name = "Garmin GPS usb/tty", | 1474 | .owner = THIS_MODULE, |
1480 | .short_name = "garmin_gps", | 1475 | .name = "garmin_gps", |
1476 | }, | ||
1477 | .description = "Garmin GPS usb/tty", | ||
1481 | .id_table = id_table, | 1478 | .id_table = id_table, |
1482 | .num_interrupt_in = 1, | 1479 | .num_interrupt_in = 1, |
1483 | .num_bulk_in = 1, | 1480 | .num_bulk_in = 1, |
diff --git a/drivers/usb/serial/generic.c b/drivers/usb/serial/generic.c index ddde5fb13f6b..53a47c31cd0e 100644 --- a/drivers/usb/serial/generic.c +++ b/drivers/usb/serial/generic.c | |||
@@ -36,10 +36,11 @@ MODULE_PARM_DESC(product, "User specified USB idProduct"); | |||
36 | static struct usb_device_id generic_device_ids[2]; /* Initially all zeroes. */ | 36 | static struct usb_device_id generic_device_ids[2]; /* Initially all zeroes. */ |
37 | 37 | ||
38 | /* All of the device info needed for the Generic Serial Converter */ | 38 | /* All of the device info needed for the Generic Serial Converter */ |
39 | struct usb_serial_device_type usb_serial_generic_device = { | 39 | struct usb_serial_driver usb_serial_generic_device = { |
40 | .owner = THIS_MODULE, | 40 | .driver = { |
41 | .name = "Generic", | 41 | .owner = THIS_MODULE, |
42 | .short_name = "generic", | 42 | .name = "generic", |
43 | }, | ||
43 | .id_table = generic_device_ids, | 44 | .id_table = generic_device_ids, |
44 | .num_interrupt_in = NUM_DONT_CARE, | 45 | .num_interrupt_in = NUM_DONT_CARE, |
45 | .num_bulk_in = NUM_DONT_CARE, | 46 | .num_bulk_in = NUM_DONT_CARE, |
@@ -223,7 +224,7 @@ int usb_serial_generic_write_room (struct usb_serial_port *port) | |||
223 | dbg("%s - port %d", __FUNCTION__, port->number); | 224 | dbg("%s - port %d", __FUNCTION__, port->number); |
224 | 225 | ||
225 | if (serial->num_bulk_out) { | 226 | if (serial->num_bulk_out) { |
226 | if (port->write_urb_busy) | 227 | if (!(port->write_urb_busy)) |
227 | room = port->bulk_out_size; | 228 | room = port->bulk_out_size; |
228 | } | 229 | } |
229 | 230 | ||
@@ -308,6 +309,7 @@ void usb_serial_generic_write_bulk_callback (struct urb *urb, struct pt_regs *re | |||
308 | 309 | ||
309 | schedule_work(&port->work); | 310 | schedule_work(&port->work); |
310 | } | 311 | } |
312 | EXPORT_SYMBOL_GPL(usb_serial_generic_write_bulk_callback); | ||
311 | 313 | ||
312 | void usb_serial_generic_shutdown (struct usb_serial *serial) | 314 | void usb_serial_generic_shutdown (struct usb_serial *serial) |
313 | { | 315 | { |
diff --git a/drivers/usb/serial/hp4x.c b/drivers/usb/serial/hp4x.c index 64d55fbd206e..8eadfb705601 100644 --- a/drivers/usb/serial/hp4x.c +++ b/drivers/usb/serial/hp4x.c | |||
@@ -38,15 +38,17 @@ MODULE_DEVICE_TABLE(usb, id_table); | |||
38 | 38 | ||
39 | static struct usb_driver hp49gp_driver = { | 39 | static struct usb_driver hp49gp_driver = { |
40 | .owner = THIS_MODULE, | 40 | .owner = THIS_MODULE, |
41 | .name = "HP4X", | 41 | .name = "hp4X", |
42 | .probe = usb_serial_probe, | 42 | .probe = usb_serial_probe, |
43 | .disconnect = usb_serial_disconnect, | 43 | .disconnect = usb_serial_disconnect, |
44 | .id_table = id_table, | 44 | .id_table = id_table, |
45 | }; | 45 | }; |
46 | 46 | ||
47 | static struct usb_serial_device_type hp49gp_device = { | 47 | static struct usb_serial_driver hp49gp_device = { |
48 | .owner = THIS_MODULE, | 48 | .driver = { |
49 | .name = "HP4X", | 49 | .owner = THIS_MODULE, |
50 | .name = "hp4X", | ||
51 | }, | ||
50 | .id_table = id_table, | 52 | .id_table = id_table, |
51 | .num_interrupt_in = NUM_DONT_CARE, | 53 | .num_interrupt_in = NUM_DONT_CARE, |
52 | .num_bulk_in = NUM_DONT_CARE, | 54 | .num_bulk_in = NUM_DONT_CARE, |
diff --git a/drivers/usb/serial/io_edgeport.c b/drivers/usb/serial/io_edgeport.c index 04bfe279d763..dc4c498bd1ed 100644 --- a/drivers/usb/serial/io_edgeport.c +++ b/drivers/usb/serial/io_edgeport.c | |||
@@ -27,225 +27,6 @@ | |||
27 | * Networks technical support, or Peter Berger <pberger@brimson.com>, | 27 | * Networks technical support, or Peter Berger <pberger@brimson.com>, |
28 | * or Al Borchers <alborchers@steinerpoint.com>. | 28 | * or Al Borchers <alborchers@steinerpoint.com>. |
29 | * | 29 | * |
30 | * Version history: | ||
31 | * | ||
32 | * 2003_04_03 al borchers | ||
33 | * - fixed a bug (that shows up with dosemu) where the tty struct is | ||
34 | * used in a callback after it has been freed | ||
35 | * | ||
36 | * 2.3 2002_03_08 greg kroah-hartman | ||
37 | * - fixed bug when multiple devices were attached at the same time. | ||
38 | * | ||
39 | * 2.2 2001_11_14 greg kroah-hartman | ||
40 | * - fixed bug in edge_close that kept the port from being used more | ||
41 | * than once. | ||
42 | * - fixed memory leak on device removal. | ||
43 | * - fixed potential double free of memory when command urb submitting | ||
44 | * failed. | ||
45 | * - other small cleanups when the device is removed | ||
46 | * | ||
47 | * 2.1 2001_07_09 greg kroah-hartman | ||
48 | * - added support for TIOCMBIS and TIOCMBIC. | ||
49 | * | ||
50 | * (04/08/2001) gb | ||
51 | * - Identify version on module load. | ||
52 | * | ||
53 | * 2.0 2001_03_05 greg kroah-hartman | ||
54 | * - reworked entire driver to fit properly in with the other usb-serial | ||
55 | * drivers. Occasional oopses still happen, but it's a good start. | ||
56 | * | ||
57 | * 1.2.3 (02/23/2001) greg kroah-hartman | ||
58 | * - changed device table to work properly for 2.4.x final format. | ||
59 | * - fixed problem with dropping data at high data rates. | ||
60 | * | ||
61 | * 1.2.2 (11/27/2000) greg kroah-hartman | ||
62 | * - cleaned up more NTisms. | ||
63 | * - Added device table for 2.4.0-test11 | ||
64 | * | ||
65 | * 1.2.1 (11/08/2000) greg kroah-hartman | ||
66 | * - Started to clean up NTisms. | ||
67 | * - Fixed problem with dev field of urb for kernels >= 2.4.0-test9 | ||
68 | * | ||
69 | * 1.2 (10/17/2000) David Iacovelli | ||
70 | * Remove all EPIC code and GPL source | ||
71 | * Fix RELEVANT_IFLAG macro to include flow control | ||
72 | * changes port configuration changes. | ||
73 | * Fix redefinition of SERIAL_MAGIC | ||
74 | * Change all timeout values to 5 seconds | ||
75 | * Tried to fix the UHCI multiple urb submission, but failed miserably. | ||
76 | * it seems to work fine with OHCI. | ||
77 | * ( Greg take a look at the #if 0 at end of WriteCmdUsb() we must | ||
78 | * find a way to work arount this UHCI bug ) | ||
79 | * | ||
80 | * 1.1 (10/11/2000) David Iacovelli | ||
81 | * Fix XON/XOFF flow control to support both IXON and IXOFF | ||
82 | * | ||
83 | * 0.9.27 (06/30/2000) David Iacovelli | ||
84 | * Added transmit queue and now allocate urb for command writes. | ||
85 | * | ||
86 | * 0.9.26 (06/29/2000) David Iacovelli | ||
87 | * Add support for 80251 based edgeport | ||
88 | * | ||
89 | * 0.9.25 (06/27/2000) David Iacovelli | ||
90 | * Do not close the port if it has multiple opens. | ||
91 | * | ||
92 | * 0.9.24 (05/26/2000) David Iacovelli | ||
93 | * Add IOCTLs to support RXTX and JAVA POS | ||
94 | * and first cut at running BlackBox Demo | ||
95 | * | ||
96 | * 0.9.23 (05/24/2000) David Iacovelli | ||
97 | * Add IOCTLs to support RXTX and JAVA POS | ||
98 | * | ||
99 | * 0.9.22 (05/23/2000) David Iacovelli | ||
100 | * fixed bug in enumeration. If epconfig turns on mapping by | ||
101 | * path after a device is already plugged in, we now update | ||
102 | * the mapping correctly | ||
103 | * | ||
104 | * 0.9.21 (05/16/2000) David Iacovelli | ||
105 | * Added BlockUntilChaseResp() to also wait for txcredits | ||
106 | * Updated the way we allocate and handle write URBs | ||
107 | * Add debug code to dump buffers | ||
108 | * | ||
109 | * 0.9.20 (05/01/2000) David Iacovelli | ||
110 | * change driver to use usb/tts/ | ||
111 | * | ||
112 | * 0.9.19 (05/01/2000) David Iacovelli | ||
113 | * Update code to compile if DEBUG is off | ||
114 | * | ||
115 | * 0.9.18 (04/28/2000) David Iacovelli | ||
116 | * cleanup and test tty_register with devfs | ||
117 | * | ||
118 | * 0.9.17 (04/27/2000) greg kroah-hartman | ||
119 | * changed tty_register around to be like the way it | ||
120 | * was before, but now it works properly with devfs. | ||
121 | * | ||
122 | * 0.9.16 (04/26/2000) david iacovelli | ||
123 | * Fixed bug in GetProductInfo() | ||
124 | * | ||
125 | * 0.9.15 (04/25/2000) david iacovelli | ||
126 | * Updated enumeration | ||
127 | * | ||
128 | * 0.9.14 (04/24/2000) david iacovelli | ||
129 | * Removed all config/status IOCTLS and | ||
130 | * converted to using /proc/edgeport | ||
131 | * still playing with devfs | ||
132 | * | ||
133 | * 0.9.13 (04/24/2000) david iacovelli | ||
134 | * Removed configuration based on ttyUSB0 | ||
135 | * Added support for configuration using /prod/edgeport | ||
136 | * first attempt at using devfs (not working yet!) | ||
137 | * Added IOCTL to GetProductInfo() | ||
138 | * Added support for custom baud rates | ||
139 | * Add support for random port numbers | ||
140 | * | ||
141 | * 0.9.12 (04/18/2000) david iacovelli | ||
142 | * added additional configuration IOCTLs | ||
143 | * use ttyUSB0 for configuration | ||
144 | * | ||
145 | * 0.9.11 (04/17/2000) greg kroah-hartman | ||
146 | * fixed module initialization race conditions. | ||
147 | * made all urbs dynamically allocated. | ||
148 | * made driver devfs compatible. now it only registers the tty device | ||
149 | * when the device is actually plugged in. | ||
150 | * | ||
151 | * 0.9.10 (04/13/2000) greg kroah-hartman | ||
152 | * added proc interface framework. | ||
153 | * | ||
154 | * 0.9.9 (04/13/2000) david iacovelli | ||
155 | * added enumeration code and ioctls to configure the device | ||
156 | * | ||
157 | * 0.9.8 (04/12/2000) david iacovelli | ||
158 | * Change interrupt read start when device is plugged in | ||
159 | * and stop when device is removed | ||
160 | * process interrupt reads when all ports are closed | ||
161 | * (keep value of rxBytesAvail consistent with the edgeport) | ||
162 | * set the USB_BULK_QUEUE flag so that we can shove a bunch | ||
163 | * of urbs at once down the pipe | ||
164 | * | ||
165 | * 0.9.7 (04/10/2000) david iacovelli | ||
166 | * start to add enumeration code. | ||
167 | * generate serial number for epic devices | ||
168 | * add support for kdb | ||
169 | * | ||
170 | * 0.9.6 (03/30/2000) david iacovelli | ||
171 | * add IOCTL to get string, manufacture, and boot descriptors | ||
172 | * | ||
173 | * 0.9.5 (03/14/2000) greg kroah-hartman | ||
174 | * more error checking added to SerialOpen to try to fix UHCI open problem | ||
175 | * | ||
176 | * 0.9.4 (03/09/2000) greg kroah-hartman | ||
177 | * added more error checking to handle oops when data is hanging | ||
178 | * around and tty is abruptly closed. | ||
179 | * | ||
180 | * 0.9.3 (03/09/2000) david iacovelli | ||
181 | * Add epic support for xon/xoff chars | ||
182 | * play with performance | ||
183 | * | ||
184 | * 0.9.2 (03/08/2000) greg kroah-hartman | ||
185 | * changed most "info" calls to "dbg" | ||
186 | * implemented flow control properly in the termios call | ||
187 | * | ||
188 | * 0.9.1 (03/08/2000) david iacovelli | ||
189 | * added EPIC support | ||
190 | * enabled bootloader update | ||
191 | * | ||
192 | * 0.9 (03/08/2000) greg kroah-hartman | ||
193 | * Release to IO networks. | ||
194 | * Integrated changes that David made | ||
195 | * made getting urbs for writing SMP safe | ||
196 | * | ||
197 | * 0.8 (03/07/2000) greg kroah-hartman | ||
198 | * Release to IO networks. | ||
199 | * Fixed problems that were seen in code by David. | ||
200 | * Now both Edgeport/4 and Edgeport/2 works properly. | ||
201 | * Changed most of the functions to use port instead of serial. | ||
202 | * | ||
203 | * 0.7 (02/27/2000) greg kroah-hartman | ||
204 | * Milestone 3 release. | ||
205 | * Release to IO Networks | ||
206 | * ioctl for waiting on line change implemented. | ||
207 | * ioctl for getting statistics implemented. | ||
208 | * multiport support working. | ||
209 | * lsr and msr registers are now handled properly. | ||
210 | * change break now hooked up and working. | ||
211 | * support for all known Edgeport devices. | ||
212 | * | ||
213 | * 0.6 (02/22/2000) greg kroah-hartman | ||
214 | * Release to IO networks. | ||
215 | * CHASE is implemented correctly when port is closed. | ||
216 | * SerialOpen now blocks correctly until port is fully opened. | ||
217 | * | ||
218 | * 0.5 (02/20/2000) greg kroah-hartman | ||
219 | * Release to IO networks. | ||
220 | * Known problems: | ||
221 | * modem status register changes are not sent on to the user | ||
222 | * CHASE is not implemented when the port is closed. | ||
223 | * | ||
224 | * 0.4 (02/16/2000) greg kroah-hartman | ||
225 | * Second cut at the CeBit demo. | ||
226 | * Doesn't leak memory on every write to the port | ||
227 | * Still small leaks on startup. | ||
228 | * Added support for Edgeport/2 and Edgeport/8 | ||
229 | * | ||
230 | * 0.3 (02/15/2000) greg kroah-hartman | ||
231 | * CeBit demo release. | ||
232 | * Force the line settings to 4800, 8, 1, e for the demo. | ||
233 | * Warning! This version leaks memory like crazy! | ||
234 | * | ||
235 | * 0.2 (01/30/2000) greg kroah-hartman | ||
236 | * Milestone 1 release. | ||
237 | * Device is found by USB subsystem, enumerated, fimware is downloaded | ||
238 | * and the descriptors are printed to the debug log, config is set, and | ||
239 | * green light starts to blink. Open port works, and data can be sent | ||
240 | * and received at the default settings of the UART. Loopback connector | ||
241 | * and debug log confirms this. | ||
242 | * | ||
243 | * 0.1 (01/23/2000) greg kroah-hartman | ||
244 | * Initial release to help IO Networks try to set up their test system. | ||
245 | * Edgeport4 is recognized, firmware is downloaded, config is set so | ||
246 | * device blinks green light every 3 sec. Port is bound, but opening, | ||
247 | * closing, and sending data do not work properly. | ||
248 | * | ||
249 | */ | 30 | */ |
250 | 31 | ||
251 | #include <linux/config.h> | 32 | #include <linux/config.h> |
diff --git a/drivers/usb/serial/io_tables.h b/drivers/usb/serial/io_tables.h index e7ffe02408bd..fad561c04c76 100644 --- a/drivers/usb/serial/io_tables.h +++ b/drivers/usb/serial/io_tables.h | |||
@@ -75,10 +75,12 @@ static struct usb_device_id id_table_combined [] = { | |||
75 | 75 | ||
76 | MODULE_DEVICE_TABLE (usb, id_table_combined); | 76 | MODULE_DEVICE_TABLE (usb, id_table_combined); |
77 | 77 | ||
78 | static struct usb_serial_device_type edgeport_2port_device = { | 78 | static struct usb_serial_driver edgeport_2port_device = { |
79 | .owner = THIS_MODULE, | 79 | .driver = { |
80 | .name = "Edgeport 2 port adapter", | 80 | .owner = THIS_MODULE, |
81 | .short_name = "edgeport_2", | 81 | .name = "edgeport_2", |
82 | }, | ||
83 | .description = "Edgeport 2 port adapter", | ||
82 | .id_table = edgeport_2port_id_table, | 84 | .id_table = edgeport_2port_id_table, |
83 | .num_interrupt_in = 1, | 85 | .num_interrupt_in = 1, |
84 | .num_bulk_in = 1, | 86 | .num_bulk_in = 1, |
@@ -103,10 +105,12 @@ static struct usb_serial_device_type edgeport_2port_device = { | |||
103 | .write_bulk_callback = edge_bulk_out_data_callback, | 105 | .write_bulk_callback = edge_bulk_out_data_callback, |
104 | }; | 106 | }; |
105 | 107 | ||
106 | static struct usb_serial_device_type edgeport_4port_device = { | 108 | static struct usb_serial_driver edgeport_4port_device = { |
107 | .owner = THIS_MODULE, | 109 | .driver = { |
108 | .name = "Edgeport 4 port adapter", | 110 | .owner = THIS_MODULE, |
109 | .short_name = "edgeport_4", | 111 | .name = "edgeport_4", |
112 | }, | ||
113 | .description = "Edgeport 4 port adapter", | ||
110 | .id_table = edgeport_4port_id_table, | 114 | .id_table = edgeport_4port_id_table, |
111 | .num_interrupt_in = 1, | 115 | .num_interrupt_in = 1, |
112 | .num_bulk_in = 1, | 116 | .num_bulk_in = 1, |
@@ -131,10 +135,12 @@ static struct usb_serial_device_type edgeport_4port_device = { | |||
131 | .write_bulk_callback = edge_bulk_out_data_callback, | 135 | .write_bulk_callback = edge_bulk_out_data_callback, |
132 | }; | 136 | }; |
133 | 137 | ||
134 | static struct usb_serial_device_type edgeport_8port_device = { | 138 | static struct usb_serial_driver edgeport_8port_device = { |
135 | .owner = THIS_MODULE, | 139 | .driver = { |
136 | .name = "Edgeport 8 port adapter", | 140 | .owner = THIS_MODULE, |
137 | .short_name = "edgeport_8", | 141 | .name = "edgeport_8", |
142 | }, | ||
143 | .description = "Edgeport 8 port adapter", | ||
138 | .id_table = edgeport_8port_id_table, | 144 | .id_table = edgeport_8port_id_table, |
139 | .num_interrupt_in = 1, | 145 | .num_interrupt_in = 1, |
140 | .num_bulk_in = 1, | 146 | .num_bulk_in = 1, |
diff --git a/drivers/usb/serial/io_ti.c b/drivers/usb/serial/io_ti.c index ebf9967f7c86..832b6d6734c0 100644 --- a/drivers/usb/serial/io_ti.c +++ b/drivers/usb/serial/io_ti.c | |||
@@ -2982,10 +2982,12 @@ static unsigned int edge_buf_get(struct edge_buf *eb, char *buf, | |||
2982 | } | 2982 | } |
2983 | 2983 | ||
2984 | 2984 | ||
2985 | static struct usb_serial_device_type edgeport_1port_device = { | 2985 | static struct usb_serial_driver edgeport_1port_device = { |
2986 | .owner = THIS_MODULE, | 2986 | .driver = { |
2987 | .name = "Edgeport TI 1 port adapter", | 2987 | .owner = THIS_MODULE, |
2988 | .short_name = "edgeport_ti_1", | 2988 | .name = "edgeport_ti_1", |
2989 | }, | ||
2990 | .description = "Edgeport TI 1 port adapter", | ||
2989 | .id_table = edgeport_1port_id_table, | 2991 | .id_table = edgeport_1port_id_table, |
2990 | .num_interrupt_in = 1, | 2992 | .num_interrupt_in = 1, |
2991 | .num_bulk_in = 1, | 2993 | .num_bulk_in = 1, |
@@ -3010,10 +3012,12 @@ static struct usb_serial_device_type edgeport_1port_device = { | |||
3010 | .write_bulk_callback = edge_bulk_out_callback, | 3012 | .write_bulk_callback = edge_bulk_out_callback, |
3011 | }; | 3013 | }; |
3012 | 3014 | ||
3013 | static struct usb_serial_device_type edgeport_2port_device = { | 3015 | static struct usb_serial_driver edgeport_2port_device = { |
3014 | .owner = THIS_MODULE, | 3016 | .driver = { |
3015 | .name = "Edgeport TI 2 port adapter", | 3017 | .owner = THIS_MODULE, |
3016 | .short_name = "edgeport_ti_2", | 3018 | .name = "edgeport_ti_2", |
3019 | }, | ||
3020 | .description = "Edgeport TI 2 port adapter", | ||
3017 | .id_table = edgeport_2port_id_table, | 3021 | .id_table = edgeport_2port_id_table, |
3018 | .num_interrupt_in = 1, | 3022 | .num_interrupt_in = 1, |
3019 | .num_bulk_in = 2, | 3023 | .num_bulk_in = 2, |
diff --git a/drivers/usb/serial/ipaq.c b/drivers/usb/serial/ipaq.c index c05c2a2a0f31..d5d066488100 100644 --- a/drivers/usb/serial/ipaq.c +++ b/drivers/usb/serial/ipaq.c | |||
@@ -92,24 +92,7 @@ static void ipaq_destroy_lists(struct usb_serial_port *port); | |||
92 | static struct usb_device_id ipaq_id_table [] = { | 92 | static struct usb_device_id ipaq_id_table [] = { |
93 | /* The first entry is a placeholder for the insmod-specified device */ | 93 | /* The first entry is a placeholder for the insmod-specified device */ |
94 | { USB_DEVICE(0x049F, 0x0003) }, | 94 | { USB_DEVICE(0x049F, 0x0003) }, |
95 | { USB_DEVICE(0x1690, 0x0601) }, /* Askey USB Sync */ | 95 | { USB_DEVICE(0x0104, 0x00BE) }, /* Socket USB Sync */ |
96 | { USB_DEVICE(0x0960, 0x0065) }, /* BCOM USB Sync 0065 */ | ||
97 | { USB_DEVICE(0x0960, 0x0066) }, /* BCOM USB Sync 0066 */ | ||
98 | { USB_DEVICE(0x0960, 0x0067) }, /* BCOM USB Sync 0067 */ | ||
99 | { USB_DEVICE(0x07CF, 0x2001) }, /* CASIO USB Sync 2001 */ | ||
100 | { USB_DEVICE(0x07CF, 0x2002) }, /* CASIO USB Sync 2002 */ | ||
101 | { USB_DEVICE(0x07CF, 0x2003) }, /* CASIO USB Sync 2003 */ | ||
102 | { USB_DEVICE(0x049F, 0x0003) }, /* Compaq iPAQ USB Sync */ | ||
103 | { USB_DEVICE(0x049F, 0x0032) }, /* Compaq iPAQ USB Sync */ | ||
104 | { USB_DEVICE(0x413C, 0x4001) }, /* Dell Axim USB Sync */ | ||
105 | { USB_DEVICE(0x413C, 0x4002) }, /* Dell Axim USB Sync */ | ||
106 | { USB_DEVICE(0x413C, 0x4003) }, /* Dell Axim USB Sync */ | ||
107 | { USB_DEVICE(0x413C, 0x4004) }, /* Dell Axim USB Sync */ | ||
108 | { USB_DEVICE(0x413C, 0x4005) }, /* Dell Axim USB Sync */ | ||
109 | { USB_DEVICE(0x413C, 0x4006) }, /* Dell Axim USB Sync */ | ||
110 | { USB_DEVICE(0x413C, 0x4007) }, /* Dell Axim USB Sync */ | ||
111 | { USB_DEVICE(0x413C, 0x4008) }, /* Dell Axim USB Sync */ | ||
112 | { USB_DEVICE(0x413C, 0x4009) }, /* Dell Axim USB Sync */ | ||
113 | { USB_DEVICE(0x03F0, 0x1016) }, /* HP USB Sync */ | 96 | { USB_DEVICE(0x03F0, 0x1016) }, /* HP USB Sync */ |
114 | { USB_DEVICE(0x03F0, 0x1116) }, /* HP USB Sync 1611 */ | 97 | { USB_DEVICE(0x03F0, 0x1116) }, /* HP USB Sync 1611 */ |
115 | { USB_DEVICE(0x03F0, 0x1216) }, /* HP USB Sync 1612 */ | 98 | { USB_DEVICE(0x03F0, 0x1216) }, /* HP USB Sync 1612 */ |
@@ -125,7 +108,13 @@ static struct usb_device_id ipaq_id_table [] = { | |||
125 | { USB_DEVICE(0x03F0, 0x5016) }, /* HP USB Sync 1650 */ | 108 | { USB_DEVICE(0x03F0, 0x5016) }, /* HP USB Sync 1650 */ |
126 | { USB_DEVICE(0x03F0, 0x5116) }, /* HP USB Sync 1651 */ | 109 | { USB_DEVICE(0x03F0, 0x5116) }, /* HP USB Sync 1651 */ |
127 | { USB_DEVICE(0x03F0, 0x5216) }, /* HP USB Sync 1652 */ | 110 | { USB_DEVICE(0x03F0, 0x5216) }, /* HP USB Sync 1652 */ |
128 | { USB_DEVICE(0x094B, 0x0001) }, /* Linkup Systems USB Sync */ | 111 | { USB_DEVICE(0x0409, 0x00D5) }, /* NEC USB Sync */ |
112 | { USB_DEVICE(0x0409, 0x00D6) }, /* NEC USB Sync */ | ||
113 | { USB_DEVICE(0x0409, 0x00D7) }, /* NEC USB Sync */ | ||
114 | { USB_DEVICE(0x0409, 0x8024) }, /* NEC USB Sync */ | ||
115 | { USB_DEVICE(0x0409, 0x8025) }, /* NEC USB Sync */ | ||
116 | { USB_DEVICE(0x043E, 0x9C01) }, /* LGE USB Sync */ | ||
117 | { USB_DEVICE(0x045E, 0x00CE) }, /* Microsoft USB Sync */ | ||
129 | { USB_DEVICE(0x045E, 0x0400) }, /* Windows Powered Pocket PC 2002 */ | 118 | { USB_DEVICE(0x045E, 0x0400) }, /* Windows Powered Pocket PC 2002 */ |
130 | { USB_DEVICE(0x045E, 0x0401) }, /* Windows Powered Pocket PC 2002 */ | 119 | { USB_DEVICE(0x045E, 0x0401) }, /* Windows Powered Pocket PC 2002 */ |
131 | { USB_DEVICE(0x045E, 0x0402) }, /* Windows Powered Pocket PC 2002 */ | 120 | { USB_DEVICE(0x045E, 0x0402) }, /* Windows Powered Pocket PC 2002 */ |
@@ -251,17 +240,81 @@ static struct usb_device_id ipaq_id_table [] = { | |||
251 | { USB_DEVICE(0x045E, 0x04E8) }, /* Windows Powered Smartphone 2003 */ | 240 | { USB_DEVICE(0x045E, 0x04E8) }, /* Windows Powered Smartphone 2003 */ |
252 | { USB_DEVICE(0x045E, 0x04E9) }, /* Windows Powered Smartphone 2003 */ | 241 | { USB_DEVICE(0x045E, 0x04E9) }, /* Windows Powered Smartphone 2003 */ |
253 | { USB_DEVICE(0x045E, 0x04EA) }, /* Windows Powered Smartphone 2003 */ | 242 | { USB_DEVICE(0x045E, 0x04EA) }, /* Windows Powered Smartphone 2003 */ |
254 | { USB_DEVICE(0x0961, 0x0010) }, /* Portatec USB Sync */ | 243 | { USB_DEVICE(0x049F, 0x0003) }, /* Compaq iPAQ USB Sync */ |
255 | { USB_DEVICE(0x5E04, 0xCE00) }, /* SAGEM Wireless Assistant */ | 244 | { USB_DEVICE(0x049F, 0x0032) }, /* Compaq iPAQ USB Sync */ |
256 | { USB_DEVICE(0x0104, 0x00BE) }, /* Socket USB Sync */ | 245 | { USB_DEVICE(0x04A4, 0x0014) }, /* Hitachi USB Sync */ |
246 | { USB_DEVICE(0x04AD, 0x0301) }, /* USB Sync 0301 */ | ||
247 | { USB_DEVICE(0x04AD, 0x0302) }, /* USB Sync 0302 */ | ||
248 | { USB_DEVICE(0x04AD, 0x0303) }, /* USB Sync 0303 */ | ||
249 | { USB_DEVICE(0x04C5, 0x1058) }, /* FUJITSU USB Sync */ | ||
250 | { USB_DEVICE(0x04C5, 0x1079) }, /* FUJITSU USB Sync */ | ||
251 | { USB_DEVICE(0x04DA, 0x2500) }, /* Panasonic USB Sync */ | ||
252 | { USB_DEVICE(0x04E8, 0x5F00) }, /* Samsung NEXiO USB Sync */ | ||
253 | { USB_DEVICE(0x04E8, 0x5F01) }, /* Samsung NEXiO USB Sync */ | ||
254 | { USB_DEVICE(0x04E8, 0x5F02) }, /* Samsung NEXiO USB Sync */ | ||
255 | { USB_DEVICE(0x04E8, 0x5F03) }, /* Samsung NEXiO USB Sync */ | ||
256 | { USB_DEVICE(0x04E8, 0x5F04) }, /* Samsung NEXiO USB Sync */ | ||
257 | { USB_DEVICE(0x04E8, 0x6611) }, /* Samsung MITs USB Sync */ | ||
258 | { USB_DEVICE(0x04E8, 0x6613) }, /* Samsung MITs USB Sync */ | ||
259 | { USB_DEVICE(0x04E8, 0x6615) }, /* Samsung MITs USB Sync */ | ||
260 | { USB_DEVICE(0x04E8, 0x6617) }, /* Samsung MITs USB Sync */ | ||
261 | { USB_DEVICE(0x04E8, 0x6619) }, /* Samsung MITs USB Sync */ | ||
262 | { USB_DEVICE(0x04E8, 0x661B) }, /* Samsung MITs USB Sync */ | ||
263 | { USB_DEVICE(0x04E8, 0x662E) }, /* Samsung MITs USB Sync */ | ||
264 | { USB_DEVICE(0x04E8, 0x6630) }, /* Samsung MITs USB Sync */ | ||
265 | { USB_DEVICE(0x04E8, 0x6632) }, /* Samsung MITs USB Sync */ | ||
266 | { USB_DEVICE(0x04f1, 0x3011) }, /* JVC USB Sync */ | ||
267 | { USB_DEVICE(0x04F1, 0x3012) }, /* JVC USB Sync */ | ||
268 | { USB_DEVICE(0x0502, 0x1631) }, /* c10 Series */ | ||
269 | { USB_DEVICE(0x0502, 0x1632) }, /* c20 Series */ | ||
270 | { USB_DEVICE(0x0502, 0x16E1) }, /* Acer n10 Handheld USB Sync */ | ||
271 | { USB_DEVICE(0x0502, 0x16E2) }, /* Acer n20 Handheld USB Sync */ | ||
272 | { USB_DEVICE(0x0502, 0x16E3) }, /* Acer n30 Handheld USB Sync */ | ||
273 | { USB_DEVICE(0x0536, 0x01A0) }, /* HHP PDT */ | ||
274 | { USB_DEVICE(0x0543, 0x0ED9) }, /* ViewSonic Color Pocket PC V35 */ | ||
275 | { USB_DEVICE(0x0543, 0x1527) }, /* ViewSonic Color Pocket PC V36 */ | ||
276 | { USB_DEVICE(0x0543, 0x1529) }, /* ViewSonic Color Pocket PC V37 */ | ||
277 | { USB_DEVICE(0x0543, 0x152B) }, /* ViewSonic Color Pocket PC V38 */ | ||
278 | { USB_DEVICE(0x0543, 0x152E) }, /* ViewSonic Pocket PC */ | ||
279 | { USB_DEVICE(0x0543, 0x1921) }, /* ViewSonic Communicator Pocket PC */ | ||
280 | { USB_DEVICE(0x0543, 0x1922) }, /* ViewSonic Smartphone */ | ||
281 | { USB_DEVICE(0x0543, 0x1923) }, /* ViewSonic Pocket PC V30 */ | ||
282 | { USB_DEVICE(0x05E0, 0x2000) }, /* Symbol USB Sync */ | ||
283 | { USB_DEVICE(0x05E0, 0x2001) }, /* Symbol USB Sync 0x2001 */ | ||
284 | { USB_DEVICE(0x05E0, 0x2002) }, /* Symbol USB Sync 0x2002 */ | ||
285 | { USB_DEVICE(0x05E0, 0x2003) }, /* Symbol USB Sync 0x2003 */ | ||
286 | { USB_DEVICE(0x05E0, 0x2004) }, /* Symbol USB Sync 0x2004 */ | ||
287 | { USB_DEVICE(0x05E0, 0x2005) }, /* Symbol USB Sync 0x2005 */ | ||
288 | { USB_DEVICE(0x05E0, 0x2006) }, /* Symbol USB Sync 0x2006 */ | ||
289 | { USB_DEVICE(0x05E0, 0x2007) }, /* Symbol USB Sync 0x2007 */ | ||
290 | { USB_DEVICE(0x05E0, 0x2008) }, /* Symbol USB Sync 0x2008 */ | ||
291 | { USB_DEVICE(0x05E0, 0x2009) }, /* Symbol USB Sync 0x2009 */ | ||
292 | { USB_DEVICE(0x05E0, 0x200A) }, /* Symbol USB Sync 0x200A */ | ||
293 | { USB_DEVICE(0x067E, 0x1001) }, /* Intermec Mobile Computer */ | ||
294 | { USB_DEVICE(0x07CF, 0x2001) }, /* CASIO USB Sync 2001 */ | ||
295 | { USB_DEVICE(0x07CF, 0x2002) }, /* CASIO USB Sync 2002 */ | ||
296 | { USB_DEVICE(0x07CF, 0x2003) }, /* CASIO USB Sync 2003 */ | ||
257 | { USB_DEVICE(0x0930, 0x0700) }, /* TOSHIBA USB Sync 0700 */ | 297 | { USB_DEVICE(0x0930, 0x0700) }, /* TOSHIBA USB Sync 0700 */ |
258 | { USB_DEVICE(0x0930, 0x0705) }, /* TOSHIBA Pocket PC e310 */ | 298 | { USB_DEVICE(0x0930, 0x0705) }, /* TOSHIBA Pocket PC e310 */ |
299 | { USB_DEVICE(0x0930, 0x0706) }, /* TOSHIBA Pocket PC e740 */ | ||
259 | { USB_DEVICE(0x0930, 0x0707) }, /* TOSHIBA Pocket PC e330 Series */ | 300 | { USB_DEVICE(0x0930, 0x0707) }, /* TOSHIBA Pocket PC e330 Series */ |
260 | { USB_DEVICE(0x0930, 0x0708) }, /* TOSHIBA Pocket PC e350 Series */ | 301 | { USB_DEVICE(0x0930, 0x0708) }, /* TOSHIBA Pocket PC e350 Series */ |
261 | { USB_DEVICE(0x0930, 0x0706) }, /* TOSHIBA Pocket PC e740 */ | ||
262 | { USB_DEVICE(0x0930, 0x0709) }, /* TOSHIBA Pocket PC e750 Series */ | 302 | { USB_DEVICE(0x0930, 0x0709) }, /* TOSHIBA Pocket PC e750 Series */ |
263 | { USB_DEVICE(0x0930, 0x070A) }, /* TOSHIBA Pocket PC e400 Series */ | 303 | { USB_DEVICE(0x0930, 0x070A) }, /* TOSHIBA Pocket PC e400 Series */ |
264 | { USB_DEVICE(0x0930, 0x070B) }, /* TOSHIBA Pocket PC e800 Series */ | 304 | { USB_DEVICE(0x0930, 0x070B) }, /* TOSHIBA Pocket PC e800 Series */ |
305 | { USB_DEVICE(0x094B, 0x0001) }, /* Linkup Systems USB Sync */ | ||
306 | { USB_DEVICE(0x0960, 0x0065) }, /* BCOM USB Sync 0065 */ | ||
307 | { USB_DEVICE(0x0960, 0x0066) }, /* BCOM USB Sync 0066 */ | ||
308 | { USB_DEVICE(0x0960, 0x0067) }, /* BCOM USB Sync 0067 */ | ||
309 | { USB_DEVICE(0x0961, 0x0010) }, /* Portatec USB Sync */ | ||
310 | { USB_DEVICE(0x099E, 0x0052) }, /* Trimble GeoExplorer */ | ||
311 | { USB_DEVICE(0x099E, 0x4000) }, /* TDS Data Collector */ | ||
312 | { USB_DEVICE(0x0B05, 0x4200) }, /* ASUS USB Sync */ | ||
313 | { USB_DEVICE(0x0B05, 0x4201) }, /* ASUS USB Sync */ | ||
314 | { USB_DEVICE(0x0B05, 0x4202) }, /* ASUS USB Sync */ | ||
315 | { USB_DEVICE(0x0B05, 0x420F) }, /* ASUS USB Sync */ | ||
316 | { USB_DEVICE(0x0B05, 0x9200) }, /* ASUS USB Sync */ | ||
317 | { USB_DEVICE(0x0B05, 0x9202) }, /* ASUS USB Sync */ | ||
265 | { USB_DEVICE(0x0BB4, 0x00CE) }, /* HTC USB Sync */ | 318 | { USB_DEVICE(0x0BB4, 0x00CE) }, /* HTC USB Sync */ |
266 | { USB_DEVICE(0x0BB4, 0x0A01) }, /* PocketPC USB Sync */ | 319 | { USB_DEVICE(0x0BB4, 0x0A01) }, /* PocketPC USB Sync */ |
267 | { USB_DEVICE(0x0BB4, 0x0A02) }, /* PocketPC USB Sync */ | 320 | { USB_DEVICE(0x0BB4, 0x0A02) }, /* PocketPC USB Sync */ |
@@ -422,116 +475,67 @@ static struct usb_device_id ipaq_id_table [] = { | |||
422 | { USB_DEVICE(0x0BB4, 0x0A9D) }, /* SmartPhone USB Sync */ | 475 | { USB_DEVICE(0x0BB4, 0x0A9D) }, /* SmartPhone USB Sync */ |
423 | { USB_DEVICE(0x0BB4, 0x0A9E) }, /* SmartPhone USB Sync */ | 476 | { USB_DEVICE(0x0BB4, 0x0A9E) }, /* SmartPhone USB Sync */ |
424 | { USB_DEVICE(0x0BB4, 0x0A9F) }, /* SmartPhone USB Sync */ | 477 | { USB_DEVICE(0x0BB4, 0x0A9F) }, /* SmartPhone USB Sync */ |
425 | { USB_DEVICE(0x0409, 0x00D5) }, /* NEC USB Sync */ | ||
426 | { USB_DEVICE(0x0409, 0x00D6) }, /* NEC USB Sync */ | ||
427 | { USB_DEVICE(0x0409, 0x00D7) }, /* NEC USB Sync */ | ||
428 | { USB_DEVICE(0x0409, 0x8024) }, /* NEC USB Sync */ | ||
429 | { USB_DEVICE(0x0409, 0x8025) }, /* NEC USB Sync */ | ||
430 | { USB_DEVICE(0x04A4, 0x0014) }, /* Hitachi USB Sync */ | ||
431 | { USB_DEVICE(0x0BF8, 0x1001) }, /* Fujitsu Siemens Computers USB Sync */ | 478 | { USB_DEVICE(0x0BF8, 0x1001) }, /* Fujitsu Siemens Computers USB Sync */ |
432 | { USB_DEVICE(0x0F98, 0x0201) }, /* Cyberbank USB Sync */ | 479 | { USB_DEVICE(0x0C44, 0x03A2) }, /* Motorola iDEN Smartphone */ |
433 | { USB_DEVICE(0x0502, 0x16E1) }, /* Acer n10 Handheld USB Sync */ | ||
434 | { USB_DEVICE(0x0502, 0x16E3) }, /* Acer n30 Handheld USB Sync */ | ||
435 | { USB_DEVICE(0x0502, 0x16E2) }, /* Acer n20 Handheld USB Sync */ | ||
436 | { USB_DEVICE(0x0502, 0x1631) }, /* c10 Series */ | ||
437 | { USB_DEVICE(0x0502, 0x1632) }, /* c20 Series */ | ||
438 | { USB_DEVICE(0x0B05, 0x9202) }, /* ASUS USB Sync */ | ||
439 | { USB_DEVICE(0x0B05, 0x420F) }, /* ASUS USB Sync */ | ||
440 | { USB_DEVICE(0x0B05, 0x4200) }, /* ASUS USB Sync */ | ||
441 | { USB_DEVICE(0x0B05, 0x4201) }, /* ASUS USB Sync */ | ||
442 | { USB_DEVICE(0x0B05, 0x4202) }, /* ASUS USB Sync */ | ||
443 | { USB_DEVICE(0x0B05, 0x9200) }, /* ASUS USB Sync */ | ||
444 | { USB_DEVICE(0x0C8E, 0x6000) }, /* Cesscom Luxian Series */ | 480 | { USB_DEVICE(0x0C8E, 0x6000) }, /* Cesscom Luxian Series */ |
445 | { USB_DEVICE(0x04AD, 0x0301) }, /* USB Sync 0301 */ | 481 | { USB_DEVICE(0x0CAD, 0x9001) }, /* Motorola PowerPad Pocket PC Device */ |
446 | { USB_DEVICE(0x04AD, 0x0302) }, /* USB Sync 0302 */ | 482 | { USB_DEVICE(0x0F4E, 0x0200) }, /* Freedom Scientific USB Sync */ |
447 | { USB_DEVICE(0x04AD, 0x0303) }, /* USB Sync 0303 */ | 483 | { USB_DEVICE(0x0F98, 0x0201) }, /* Cyberbank USB Sync */ |
484 | { USB_DEVICE(0x0FB8, 0x3001) }, /* Wistron USB Sync */ | ||
485 | { USB_DEVICE(0x0FB8, 0x3002) }, /* Wistron USB Sync */ | ||
486 | { USB_DEVICE(0x0FB8, 0x3003) }, /* Wistron USB Sync */ | ||
487 | { USB_DEVICE(0x0FB8, 0x4001) }, /* Wistron USB Sync */ | ||
488 | { USB_DEVICE(0x1066, 0x00CE) }, /* E-TEN USB Sync */ | ||
448 | { USB_DEVICE(0x1066, 0x0300) }, /* E-TEN P3XX Pocket PC */ | 489 | { USB_DEVICE(0x1066, 0x0300) }, /* E-TEN P3XX Pocket PC */ |
449 | { USB_DEVICE(0x1066, 0x0500) }, /* E-TEN P5XX Pocket PC */ | 490 | { USB_DEVICE(0x1066, 0x0500) }, /* E-TEN P5XX Pocket PC */ |
450 | { USB_DEVICE(0x1066, 0x0600) }, /* E-TEN P6XX Pocket PC */ | 491 | { USB_DEVICE(0x1066, 0x0600) }, /* E-TEN P6XX Pocket PC */ |
451 | { USB_DEVICE(0x1066, 0x0700) }, /* E-TEN P7XX Pocket PC */ | 492 | { USB_DEVICE(0x1066, 0x0700) }, /* E-TEN P7XX Pocket PC */ |
452 | { USB_DEVICE(0x1066, 0x00CE) }, /* E-TEN USB Sync */ | 493 | { USB_DEVICE(0x1114, 0x0001) }, /* Psion Teklogix Sync 753x */ |
453 | { USB_DEVICE(0x0F4E, 0x0200) }, /* Freedom Scientific USB Sync */ | 494 | { USB_DEVICE(0x1114, 0x0004) }, /* Psion Teklogix Sync netBookPro */ |
454 | { USB_DEVICE(0x04C5, 0x1058) }, /* FUJITSU USB Sync */ | 495 | { USB_DEVICE(0x1114, 0x0006) }, /* Psion Teklogix Sync 7525 */ |
455 | { USB_DEVICE(0x04C5, 0x1079) }, /* FUJITSU USB Sync */ | 496 | { USB_DEVICE(0x1182, 0x1388) }, /* VES USB Sync */ |
456 | { USB_DEVICE(0x067E, 0x1001) }, /* Intermec Mobile Computer */ | 497 | { USB_DEVICE(0x11D9, 0x1002) }, /* Rugged Pocket PC 2003 */ |
457 | { USB_DEVICE(0x04f1, 0x3011) }, /* JVC USB Sync */ | 498 | { USB_DEVICE(0x11D9, 0x1003) }, /* Rugged Pocket PC 2003 */ |
458 | { USB_DEVICE(0x04F1, 0x3012) }, /* JVC USB Sync */ | 499 | { USB_DEVICE(0x1231, 0xCE01) }, /* USB Sync 03 */ |
459 | { USB_DEVICE(0x3708, 0x20CE) }, /* Legend USB Sync */ | 500 | { USB_DEVICE(0x1231, 0xCE02) }, /* USB Sync 03 */ |
460 | { USB_DEVICE(0x3708, 0x21CE) }, /* Lenovo USB Sync */ | 501 | { USB_DEVICE(0x1690, 0x0601) }, /* Askey USB Sync */ |
461 | { USB_DEVICE(0x043E, 0x9C01) }, /* LGE USB Sync */ | 502 | { USB_DEVICE(0x22B8, 0x4204) }, /* Motorola MPx200 Smartphone */ |
462 | { USB_DEVICE(0x04DA, 0x2500) }, /* Panasonic USB Sync */ | 503 | { USB_DEVICE(0x22B8, 0x4214) }, /* Motorola MPc GSM */ |
463 | { USB_DEVICE(0x3340, 0x0B1C) }, /* Generic PPC StrongARM */ | 504 | { USB_DEVICE(0x22B8, 0x4224) }, /* Motorola MPx220 Smartphone */ |
464 | { USB_DEVICE(0x3340, 0x0E3A) }, /* Generic PPC USB Sync */ | 505 | { USB_DEVICE(0x22B8, 0x4234) }, /* Motorola MPc CDMA */ |
465 | { USB_DEVICE(0x3340, 0x0F3A) }, /* Generic SmartPhone USB Sync */ | 506 | { USB_DEVICE(0x22B8, 0x4244) }, /* Motorola MPx100 Smartphone */ |
466 | { USB_DEVICE(0x3340, 0x0F1C) }, /* Itautec USB Sync */ | 507 | { USB_DEVICE(0x3340, 0x011C) }, /* Mio DigiWalker PPC StrongARM */ |
467 | { USB_DEVICE(0x3340, 0x1326) }, /* Itautec USB Sync */ | ||
468 | { USB_DEVICE(0x3340, 0x3326) }, /* MEDION Winodws Moble USB Sync */ | ||
469 | { USB_DEVICE(0x3340, 0x0326) }, /* Mio DigiWalker 338 */ | 508 | { USB_DEVICE(0x3340, 0x0326) }, /* Mio DigiWalker 338 */ |
470 | { USB_DEVICE(0x3340, 0x0426) }, /* Mio DigiWalker 338 */ | 509 | { USB_DEVICE(0x3340, 0x0426) }, /* Mio DigiWalker 338 */ |
471 | { USB_DEVICE(0x3340, 0x011C) }, /* Mio DigiWalker PPC StrongARM */ | ||
472 | { USB_DEVICE(0x3340, 0x053A) }, /* Mio DigiWalker SmartPhone USB Sync */ | ||
473 | { USB_DEVICE(0x3340, 0x043A) }, /* Mio DigiWalker USB Sync */ | 510 | { USB_DEVICE(0x3340, 0x043A) }, /* Mio DigiWalker USB Sync */ |
474 | { USB_DEVICE(0x3340, 0x071C) }, /* MiTAC USB Sync */ | ||
475 | { USB_DEVICE(0x3340, 0x051C) }, /* MiTAC USB Sync 528 */ | 511 | { USB_DEVICE(0x3340, 0x051C) }, /* MiTAC USB Sync 528 */ |
476 | { USB_DEVICE(0x3340, 0x2326) }, /* Vobis USB Sync */ | 512 | { USB_DEVICE(0x3340, 0x053A) }, /* Mio DigiWalker SmartPhone USB Sync */ |
513 | { USB_DEVICE(0x3340, 0x071C) }, /* MiTAC USB Sync */ | ||
514 | { USB_DEVICE(0x3340, 0x0B1C) }, /* Generic PPC StrongARM */ | ||
515 | { USB_DEVICE(0x3340, 0x0E3A) }, /* Generic PPC USB Sync */ | ||
516 | { USB_DEVICE(0x3340, 0x0F1C) }, /* Itautec USB Sync */ | ||
517 | { USB_DEVICE(0x3340, 0x0F3A) }, /* Generic SmartPhone USB Sync */ | ||
518 | { USB_DEVICE(0x3340, 0x1326) }, /* Itautec USB Sync */ | ||
477 | { USB_DEVICE(0x3340, 0x191C) }, /* YAKUMO USB Sync */ | 519 | { USB_DEVICE(0x3340, 0x191C) }, /* YAKUMO USB Sync */ |
520 | { USB_DEVICE(0x3340, 0x2326) }, /* Vobis USB Sync */ | ||
521 | { USB_DEVICE(0x3340, 0x3326) }, /* MEDION Winodws Moble USB Sync */ | ||
522 | { USB_DEVICE(0x3708, 0x20CE) }, /* Legend USB Sync */ | ||
523 | { USB_DEVICE(0x3708, 0x21CE) }, /* Lenovo USB Sync */ | ||
478 | { USB_DEVICE(0x4113, 0x0210) }, /* Mobile Media Technology USB Sync */ | 524 | { USB_DEVICE(0x4113, 0x0210) }, /* Mobile Media Technology USB Sync */ |
479 | { USB_DEVICE(0x4113, 0x0211) }, /* Mobile Media Technology USB Sync */ | 525 | { USB_DEVICE(0x4113, 0x0211) }, /* Mobile Media Technology USB Sync */ |
480 | { USB_DEVICE(0x4113, 0x0400) }, /* Mobile Media Technology USB Sync */ | 526 | { USB_DEVICE(0x4113, 0x0400) }, /* Mobile Media Technology USB Sync */ |
481 | { USB_DEVICE(0x4113, 0x0410) }, /* Mobile Media Technology USB Sync */ | 527 | { USB_DEVICE(0x4113, 0x0410) }, /* Mobile Media Technology USB Sync */ |
482 | { USB_DEVICE(0x0CAD, 0x9001) }, /* Motorola PowerPad Pocket PC Device */ | 528 | { USB_DEVICE(0x413C, 0x4001) }, /* Dell Axim USB Sync */ |
483 | { USB_DEVICE(0x0C44, 0x03A2) }, /* Motorola iDEN Smartphone */ | 529 | { USB_DEVICE(0x413C, 0x4002) }, /* Dell Axim USB Sync */ |
484 | { USB_DEVICE(0x04E8, 0x6611) }, /* Samsung MITs USB Sync */ | 530 | { USB_DEVICE(0x413C, 0x4003) }, /* Dell Axim USB Sync */ |
485 | { USB_DEVICE(0x04E8, 0x6613) }, /* Samsung MITs USB Sync */ | 531 | { USB_DEVICE(0x413C, 0x4004) }, /* Dell Axim USB Sync */ |
486 | { USB_DEVICE(0x04E8, 0x6615) }, /* Samsung MITs USB Sync */ | 532 | { USB_DEVICE(0x413C, 0x4005) }, /* Dell Axim USB Sync */ |
487 | { USB_DEVICE(0x04E8, 0x6617) }, /* Samsung MITs USB Sync */ | 533 | { USB_DEVICE(0x413C, 0x4006) }, /* Dell Axim USB Sync */ |
488 | { USB_DEVICE(0x04E8, 0x6619) }, /* Samsung MITs USB Sync */ | 534 | { USB_DEVICE(0x413C, 0x4007) }, /* Dell Axim USB Sync */ |
489 | { USB_DEVICE(0x04E8, 0x661B) }, /* Samsung MITs USB Sync */ | 535 | { USB_DEVICE(0x413C, 0x4008) }, /* Dell Axim USB Sync */ |
490 | { USB_DEVICE(0x04E8, 0x5F00) }, /* Samsung NEXiO USB Sync */ | 536 | { USB_DEVICE(0x413C, 0x4009) }, /* Dell Axim USB Sync */ |
491 | { USB_DEVICE(0x04E8, 0x5F01) }, /* Samsung NEXiO USB Sync */ | ||
492 | { USB_DEVICE(0x04E8, 0x5F02) }, /* Samsung NEXiO USB Sync */ | ||
493 | { USB_DEVICE(0x04E8, 0x5F03) }, /* Samsung NEXiO USB Sync */ | ||
494 | { USB_DEVICE(0x04E8, 0x5F04) }, /* Samsung NEXiO USB Sync */ | ||
495 | { USB_DEVICE(0x04E8, 0x662E) }, /* Samsung MITs USB Sync */ | ||
496 | { USB_DEVICE(0x04E8, 0x6630) }, /* Samsung MITs USB Sync */ | ||
497 | { USB_DEVICE(0x04E8, 0x6632) }, /* Samsung MITs USB Sync */ | ||
498 | { USB_DEVICE(0x4505, 0x0010) }, /* Smartphone */ | 537 | { USB_DEVICE(0x4505, 0x0010) }, /* Smartphone */ |
499 | { USB_DEVICE(0x05E0, 0x2000) }, /* Symbol USB Sync */ | 538 | { USB_DEVICE(0x5E04, 0xCE00) }, /* SAGEM Wireless Assistant */ |
500 | { USB_DEVICE(0x05E0, 0x2001) }, /* Symbol USB Sync 0x2001 */ | ||
501 | { USB_DEVICE(0x05E0, 0x2002) }, /* Symbol USB Sync 0x2002 */ | ||
502 | { USB_DEVICE(0x05E0, 0x2003) }, /* Symbol USB Sync 0x2003 */ | ||
503 | { USB_DEVICE(0x05E0, 0x2004) }, /* Symbol USB Sync 0x2004 */ | ||
504 | { USB_DEVICE(0x05E0, 0x2005) }, /* Symbol USB Sync 0x2005 */ | ||
505 | { USB_DEVICE(0x05E0, 0x2006) }, /* Symbol USB Sync 0x2006 */ | ||
506 | { USB_DEVICE(0x05E0, 0x2007) }, /* Symbol USB Sync 0x2007 */ | ||
507 | { USB_DEVICE(0x05E0, 0x2008) }, /* Symbol USB Sync 0x2008 */ | ||
508 | { USB_DEVICE(0x05E0, 0x2009) }, /* Symbol USB Sync 0x2009 */ | ||
509 | { USB_DEVICE(0x05E0, 0x200A) }, /* Symbol USB Sync 0x200A */ | ||
510 | { USB_DEVICE(0x1182, 0x1388) }, /* VES USB Sync */ | ||
511 | { USB_DEVICE(0x0543, 0x0ED9) }, /* ViewSonic Color Pocket PC V35 */ | ||
512 | { USB_DEVICE(0x0543, 0x1527) }, /* ViewSonic Color Pocket PC V36 */ | ||
513 | { USB_DEVICE(0x0543, 0x1529) }, /* ViewSonic Color Pocket PC V37 */ | ||
514 | { USB_DEVICE(0x0543, 0x152B) }, /* ViewSonic Color Pocket PC V38 */ | ||
515 | { USB_DEVICE(0x0543, 0x152E) }, /* ViewSonic Pocket PC */ | ||
516 | { USB_DEVICE(0x0543, 0x1921) }, /* ViewSonic Communicator Pocket PC */ | ||
517 | { USB_DEVICE(0x0543, 0x1922) }, /* ViewSonic Smartphone */ | ||
518 | { USB_DEVICE(0x0543, 0x1923) }, /* ViewSonic Pocket PC V30 */ | ||
519 | { USB_DEVICE(0x0536, 0x01A0) }, /* HHP PDT */ | ||
520 | { USB_DEVICE(0x099E, 0x0052) }, /* Trimble GeoExplorer */ | ||
521 | { USB_DEVICE(0x099E, 0x4000) }, /* TDS Data Collector */ | ||
522 | { USB_DEVICE(0x0FB8, 0x3001) }, /* Wistron USB Sync */ | ||
523 | { USB_DEVICE(0x0FB8, 0x3002) }, /* Wistron USB Sync */ | ||
524 | { USB_DEVICE(0x0FB8, 0x3003) }, /* Wistron USB Sync */ | ||
525 | { USB_DEVICE(0x0FB8, 0x4001) }, /* Wistron USB Sync */ | ||
526 | { USB_DEVICE(0x11D9, 0x1003) }, /* Rugged Pocket PC 2003 */ | ||
527 | { USB_DEVICE(0x11D9, 0x1002) }, /* Rugged Pocket PC 2003 */ | ||
528 | { USB_DEVICE(0x22B8, 0x4204) }, /* Motorola MPx200 Smartphone */ | ||
529 | { USB_DEVICE(0x22B8, 0x4214) }, /* Motorola MPc GSM */ | ||
530 | { USB_DEVICE(0x22B8, 0x4224) }, /* Motorola MPx220 Smartphone */ | ||
531 | { USB_DEVICE(0x22B8, 0x4234) }, /* Motorola MPc CDMA */ | ||
532 | { USB_DEVICE(0x22B8, 0x4244) }, /* Motorola MPx100 Smartphone */ | ||
533 | { USB_DEVICE(0x1231, 0xCE01) }, /* USB Sync 03 */ | ||
534 | { USB_DEVICE(0x1231, 0xCE02) }, /* USB Sync 03 */ | ||
535 | { } /* Terminating entry */ | 539 | { } /* Terminating entry */ |
536 | }; | 540 | }; |
537 | 541 | ||
@@ -547,9 +551,12 @@ static struct usb_driver ipaq_driver = { | |||
547 | 551 | ||
548 | 552 | ||
549 | /* All of the device info needed for the Compaq iPAQ */ | 553 | /* All of the device info needed for the Compaq iPAQ */ |
550 | static struct usb_serial_device_type ipaq_device = { | 554 | static struct usb_serial_driver ipaq_device = { |
551 | .owner = THIS_MODULE, | 555 | .driver = { |
552 | .name = "PocketPC PDA", | 556 | .owner = THIS_MODULE, |
557 | .name = "ipaq", | ||
558 | }, | ||
559 | .description = "PocketPC PDA", | ||
553 | .id_table = ipaq_id_table, | 560 | .id_table = ipaq_id_table, |
554 | .num_interrupt_in = NUM_DONT_CARE, | 561 | .num_interrupt_in = NUM_DONT_CARE, |
555 | .num_bulk_in = 1, | 562 | .num_bulk_in = 1, |
diff --git a/drivers/usb/serial/ipw.c b/drivers/usb/serial/ipw.c index 85e242459c27..7744b8148bc5 100644 --- a/drivers/usb/serial/ipw.c +++ b/drivers/usb/serial/ipw.c | |||
@@ -46,7 +46,6 @@ | |||
46 | #include <linux/module.h> | 46 | #include <linux/module.h> |
47 | #include <linux/spinlock.h> | 47 | #include <linux/spinlock.h> |
48 | #include <linux/usb.h> | 48 | #include <linux/usb.h> |
49 | #include <linux/usb.h> | ||
50 | #include <asm/uaccess.h> | 49 | #include <asm/uaccess.h> |
51 | #include "usb-serial.h" | 50 | #include "usb-serial.h" |
52 | 51 | ||
@@ -443,10 +442,12 @@ static int ipw_disconnect(struct usb_serial_port *port) | |||
443 | return 0; | 442 | return 0; |
444 | } | 443 | } |
445 | 444 | ||
446 | static struct usb_serial_device_type ipw_device = { | 445 | static struct usb_serial_driver ipw_device = { |
447 | .owner = THIS_MODULE, | 446 | .driver = { |
448 | .name = "IPWireless converter", | 447 | .owner = THIS_MODULE, |
449 | .short_name = "ipw", | 448 | .name = "ipw", |
449 | }, | ||
450 | .description = "IPWireless converter", | ||
450 | .id_table = usb_ipw_ids, | 451 | .id_table = usb_ipw_ids, |
451 | .num_interrupt_in = NUM_DONT_CARE, | 452 | .num_interrupt_in = NUM_DONT_CARE, |
452 | .num_bulk_in = 1, | 453 | .num_bulk_in = 1, |
diff --git a/drivers/usb/serial/ir-usb.c b/drivers/usb/serial/ir-usb.c index 937b2fdd7171..19f329e9bdcf 100644 --- a/drivers/usb/serial/ir-usb.c +++ b/drivers/usb/serial/ir-usb.c | |||
@@ -133,9 +133,12 @@ static struct usb_driver ir_driver = { | |||
133 | }; | 133 | }; |
134 | 134 | ||
135 | 135 | ||
136 | static struct usb_serial_device_type ir_device = { | 136 | static struct usb_serial_driver ir_device = { |
137 | .owner = THIS_MODULE, | 137 | .driver = { |
138 | .name = "IR Dongle", | 138 | .owner = THIS_MODULE, |
139 | .name = "ir-usb", | ||
140 | }, | ||
141 | .description = "IR Dongle", | ||
139 | .id_table = id_table, | 142 | .id_table = id_table, |
140 | .num_interrupt_in = 1, | 143 | .num_interrupt_in = 1, |
141 | .num_bulk_in = 1, | 144 | .num_bulk_in = 1, |
diff --git a/drivers/usb/serial/keyspan.h b/drivers/usb/serial/keyspan.h index e9b45b768aca..5cfc13b5e56f 100644 --- a/drivers/usb/serial/keyspan.h +++ b/drivers/usb/serial/keyspan.h | |||
@@ -570,10 +570,12 @@ static struct usb_device_id keyspan_4port_ids[] = { | |||
570 | }; | 570 | }; |
571 | 571 | ||
572 | /* Structs for the devices, pre and post renumeration. */ | 572 | /* Structs for the devices, pre and post renumeration. */ |
573 | static struct usb_serial_device_type keyspan_pre_device = { | 573 | static struct usb_serial_driver keyspan_pre_device = { |
574 | .owner = THIS_MODULE, | 574 | .driver = { |
575 | .name = "Keyspan - (without firmware)", | 575 | .owner = THIS_MODULE, |
576 | .short_name = "keyspan_no_firm", | 576 | .name = "keyspan_no_firm", |
577 | }, | ||
578 | .description = "Keyspan - (without firmware)", | ||
577 | .id_table = keyspan_pre_ids, | 579 | .id_table = keyspan_pre_ids, |
578 | .num_interrupt_in = NUM_DONT_CARE, | 580 | .num_interrupt_in = NUM_DONT_CARE, |
579 | .num_bulk_in = NUM_DONT_CARE, | 581 | .num_bulk_in = NUM_DONT_CARE, |
@@ -582,10 +584,12 @@ static struct usb_serial_device_type keyspan_pre_device = { | |||
582 | .attach = keyspan_fake_startup, | 584 | .attach = keyspan_fake_startup, |
583 | }; | 585 | }; |
584 | 586 | ||
585 | static struct usb_serial_device_type keyspan_1port_device = { | 587 | static struct usb_serial_driver keyspan_1port_device = { |
586 | .owner = THIS_MODULE, | 588 | .driver = { |
587 | .name = "Keyspan 1 port adapter", | 589 | .owner = THIS_MODULE, |
588 | .short_name = "keyspan_1", | 590 | .name = "keyspan_1", |
591 | }, | ||
592 | .description = "Keyspan 1 port adapter", | ||
589 | .id_table = keyspan_1port_ids, | 593 | .id_table = keyspan_1port_ids, |
590 | .num_interrupt_in = NUM_DONT_CARE, | 594 | .num_interrupt_in = NUM_DONT_CARE, |
591 | .num_bulk_in = NUM_DONT_CARE, | 595 | .num_bulk_in = NUM_DONT_CARE, |
@@ -607,10 +611,12 @@ static struct usb_serial_device_type keyspan_1port_device = { | |||
607 | .shutdown = keyspan_shutdown, | 611 | .shutdown = keyspan_shutdown, |
608 | }; | 612 | }; |
609 | 613 | ||
610 | static struct usb_serial_device_type keyspan_2port_device = { | 614 | static struct usb_serial_driver keyspan_2port_device = { |
611 | .owner = THIS_MODULE, | 615 | .driver = { |
612 | .name = "Keyspan 2 port adapter", | 616 | .owner = THIS_MODULE, |
613 | .short_name = "keyspan_2", | 617 | .name = "keyspan_2", |
618 | }, | ||
619 | .description = "Keyspan 2 port adapter", | ||
614 | .id_table = keyspan_2port_ids, | 620 | .id_table = keyspan_2port_ids, |
615 | .num_interrupt_in = NUM_DONT_CARE, | 621 | .num_interrupt_in = NUM_DONT_CARE, |
616 | .num_bulk_in = NUM_DONT_CARE, | 622 | .num_bulk_in = NUM_DONT_CARE, |
@@ -632,10 +638,12 @@ static struct usb_serial_device_type keyspan_2port_device = { | |||
632 | .shutdown = keyspan_shutdown, | 638 | .shutdown = keyspan_shutdown, |
633 | }; | 639 | }; |
634 | 640 | ||
635 | static struct usb_serial_device_type keyspan_4port_device = { | 641 | static struct usb_serial_driver keyspan_4port_device = { |
636 | .owner = THIS_MODULE, | 642 | .driver = { |
637 | .name = "Keyspan 4 port adapter", | 643 | .owner = THIS_MODULE, |
638 | .short_name = "keyspan_4", | 644 | .name = "keyspan_4", |
645 | }, | ||
646 | .description = "Keyspan 4 port adapter", | ||
639 | .id_table = keyspan_4port_ids, | 647 | .id_table = keyspan_4port_ids, |
640 | .num_interrupt_in = NUM_DONT_CARE, | 648 | .num_interrupt_in = NUM_DONT_CARE, |
641 | .num_bulk_in = 5, | 649 | .num_bulk_in = 5, |
diff --git a/drivers/usb/serial/keyspan_pda.c b/drivers/usb/serial/keyspan_pda.c index 635c384cb15a..cd4f48bd83b6 100644 --- a/drivers/usb/serial/keyspan_pda.c +++ b/drivers/usb/serial/keyspan_pda.c | |||
@@ -783,10 +783,12 @@ static void keyspan_pda_shutdown (struct usb_serial *serial) | |||
783 | } | 783 | } |
784 | 784 | ||
785 | #ifdef KEYSPAN | 785 | #ifdef KEYSPAN |
786 | static struct usb_serial_device_type keyspan_pda_fake_device = { | 786 | static struct usb_serial_driver keyspan_pda_fake_device = { |
787 | .owner = THIS_MODULE, | 787 | .driver = { |
788 | .name = "Keyspan PDA - (prerenumeration)", | 788 | .owner = THIS_MODULE, |
789 | .short_name = "keyspan_pda_pre", | 789 | .name = "keyspan_pda_pre", |
790 | }, | ||
791 | .description = "Keyspan PDA - (prerenumeration)", | ||
790 | .id_table = id_table_fake, | 792 | .id_table = id_table_fake, |
791 | .num_interrupt_in = NUM_DONT_CARE, | 793 | .num_interrupt_in = NUM_DONT_CARE, |
792 | .num_bulk_in = NUM_DONT_CARE, | 794 | .num_bulk_in = NUM_DONT_CARE, |
@@ -797,10 +799,12 @@ static struct usb_serial_device_type keyspan_pda_fake_device = { | |||
797 | #endif | 799 | #endif |
798 | 800 | ||
799 | #ifdef XIRCOM | 801 | #ifdef XIRCOM |
800 | static struct usb_serial_device_type xircom_pgs_fake_device = { | 802 | static struct usb_serial_driver xircom_pgs_fake_device = { |
801 | .owner = THIS_MODULE, | 803 | .driver = { |
802 | .name = "Xircom / Entregra PGS - (prerenumeration)", | 804 | .owner = THIS_MODULE, |
803 | .short_name = "xircom_no_firm", | 805 | .name = "xircom_no_firm", |
806 | }, | ||
807 | .description = "Xircom / Entregra PGS - (prerenumeration)", | ||
804 | .id_table = id_table_fake_xircom, | 808 | .id_table = id_table_fake_xircom, |
805 | .num_interrupt_in = NUM_DONT_CARE, | 809 | .num_interrupt_in = NUM_DONT_CARE, |
806 | .num_bulk_in = NUM_DONT_CARE, | 810 | .num_bulk_in = NUM_DONT_CARE, |
@@ -810,10 +814,12 @@ static struct usb_serial_device_type xircom_pgs_fake_device = { | |||
810 | }; | 814 | }; |
811 | #endif | 815 | #endif |
812 | 816 | ||
813 | static struct usb_serial_device_type keyspan_pda_device = { | 817 | static struct usb_serial_driver keyspan_pda_device = { |
814 | .owner = THIS_MODULE, | 818 | .driver = { |
815 | .name = "Keyspan PDA", | 819 | .owner = THIS_MODULE, |
816 | .short_name = "keyspan_pda", | 820 | .name = "keyspan_pda", |
821 | }, | ||
822 | .description = "Keyspan PDA", | ||
817 | .id_table = id_table_std, | 823 | .id_table = id_table_std, |
818 | .num_interrupt_in = 1, | 824 | .num_interrupt_in = 1, |
819 | .num_bulk_in = 0, | 825 | .num_bulk_in = 0, |
diff --git a/drivers/usb/serial/kl5kusb105.c b/drivers/usb/serial/kl5kusb105.c index a11e829e38c8..a8951c0fd020 100644 --- a/drivers/usb/serial/kl5kusb105.c +++ b/drivers/usb/serial/kl5kusb105.c | |||
@@ -123,10 +123,12 @@ static struct usb_driver kl5kusb105d_driver = { | |||
123 | .id_table = id_table, | 123 | .id_table = id_table, |
124 | }; | 124 | }; |
125 | 125 | ||
126 | static struct usb_serial_device_type kl5kusb105d_device = { | 126 | static struct usb_serial_driver kl5kusb105d_device = { |
127 | .owner = THIS_MODULE, | 127 | .driver = { |
128 | .name = "KL5KUSB105D / PalmConnect", | 128 | .owner = THIS_MODULE, |
129 | .short_name = "kl5kusb105d", | 129 | .name = "kl5kusb105d", |
130 | }, | ||
131 | .description = "KL5KUSB105D / PalmConnect", | ||
130 | .id_table = id_table, | 132 | .id_table = id_table, |
131 | .num_interrupt_in = 1, | 133 | .num_interrupt_in = 1, |
132 | .num_bulk_in = 1, | 134 | .num_bulk_in = 1, |
diff --git a/drivers/usb/serial/kobil_sct.c b/drivers/usb/serial/kobil_sct.c index fe4c98a75171..9456dd9dd136 100644 --- a/drivers/usb/serial/kobil_sct.c +++ b/drivers/usb/serial/kobil_sct.c | |||
@@ -105,9 +105,12 @@ static struct usb_driver kobil_driver = { | |||
105 | }; | 105 | }; |
106 | 106 | ||
107 | 107 | ||
108 | static struct usb_serial_device_type kobil_device = { | 108 | static struct usb_serial_driver kobil_device = { |
109 | .owner = THIS_MODULE, | 109 | .driver = { |
110 | .name = "KOBIL USB smart card terminal", | 110 | .owner = THIS_MODULE, |
111 | .name = "kobil", | ||
112 | }, | ||
113 | .description = "KOBIL USB smart card terminal", | ||
111 | .id_table = id_table, | 114 | .id_table = id_table, |
112 | .num_interrupt_in = NUM_DONT_CARE, | 115 | .num_interrupt_in = NUM_DONT_CARE, |
113 | .num_bulk_in = 0, | 116 | .num_bulk_in = 0, |
diff --git a/drivers/usb/serial/mct_u232.c b/drivers/usb/serial/mct_u232.c index 50b6369647d2..ca5dbadb9b7e 100644 --- a/drivers/usb/serial/mct_u232.c +++ b/drivers/usb/serial/mct_u232.c | |||
@@ -132,10 +132,12 @@ static struct usb_driver mct_u232_driver = { | |||
132 | .id_table = id_table_combined, | 132 | .id_table = id_table_combined, |
133 | }; | 133 | }; |
134 | 134 | ||
135 | static struct usb_serial_device_type mct_u232_device = { | 135 | static struct usb_serial_driver mct_u232_device = { |
136 | .owner = THIS_MODULE, | 136 | .driver = { |
137 | .name = "MCT U232", | 137 | .owner = THIS_MODULE, |
138 | .short_name = "mct_u232", | 138 | .name = "mct_u232", |
139 | }, | ||
140 | .description = "MCT U232", | ||
139 | .id_table = id_table_combined, | 141 | .id_table = id_table_combined, |
140 | .num_interrupt_in = 2, | 142 | .num_interrupt_in = 2, |
141 | .num_bulk_in = 0, | 143 | .num_bulk_in = 0, |
diff --git a/drivers/usb/serial/omninet.c b/drivers/usb/serial/omninet.c index 6a99ae192df1..3caf97072ac0 100644 --- a/drivers/usb/serial/omninet.c +++ b/drivers/usb/serial/omninet.c | |||
@@ -88,10 +88,12 @@ static struct usb_driver omninet_driver = { | |||
88 | }; | 88 | }; |
89 | 89 | ||
90 | 90 | ||
91 | static struct usb_serial_device_type zyxel_omninet_device = { | 91 | static struct usb_serial_driver zyxel_omninet_device = { |
92 | .owner = THIS_MODULE, | 92 | .driver = { |
93 | .name = "ZyXEL - omni.net lcd plus usb", | 93 | .owner = THIS_MODULE, |
94 | .short_name = "omninet", | 94 | .name = "omninet", |
95 | }, | ||
96 | .description = "ZyXEL - omni.net lcd plus usb", | ||
95 | .id_table = id_table, | 97 | .id_table = id_table, |
96 | .num_interrupt_in = 1, | 98 | .num_interrupt_in = 1, |
97 | .num_bulk_in = 1, | 99 | .num_bulk_in = 1, |
diff --git a/drivers/usb/serial/option.c b/drivers/usb/serial/option.c index 92d0f925d053..7716000045b7 100644 --- a/drivers/usb/serial/option.c +++ b/drivers/usb/serial/option.c | |||
@@ -25,6 +25,9 @@ | |||
25 | 2005-06-20 v0.4.1 add missing braces :-/ | 25 | 2005-06-20 v0.4.1 add missing braces :-/ |
26 | killed end-of-line whitespace | 26 | killed end-of-line whitespace |
27 | 2005-07-15 v0.4.2 rename WLAN product to FUSION, add FUSION2 | 27 | 2005-07-15 v0.4.2 rename WLAN product to FUSION, add FUSION2 |
28 | 2005-09-10 v0.4.3 added HUAWEI E600 card and Audiovox AirCard | ||
29 | 2005-09-20 v0.4.4 increased recv buffer size: the card sometimes | ||
30 | wants to send >2000 bytes. | ||
28 | 31 | ||
29 | Work sponsored by: Sigos GmbH, Germany <info@sigos.de> | 32 | Work sponsored by: Sigos GmbH, Germany <info@sigos.de> |
30 | 33 | ||
@@ -71,15 +74,21 @@ static int option_send_setup(struct usb_serial_port *port); | |||
71 | 74 | ||
72 | /* Vendor and product IDs */ | 75 | /* Vendor and product IDs */ |
73 | #define OPTION_VENDOR_ID 0x0AF0 | 76 | #define OPTION_VENDOR_ID 0x0AF0 |
77 | #define HUAWEI_VENDOR_ID 0x12D1 | ||
78 | #define AUDIOVOX_VENDOR_ID 0x0F3D | ||
74 | 79 | ||
75 | #define OPTION_PRODUCT_OLD 0x5000 | 80 | #define OPTION_PRODUCT_OLD 0x5000 |
76 | #define OPTION_PRODUCT_FUSION 0x6000 | 81 | #define OPTION_PRODUCT_FUSION 0x6000 |
77 | #define OPTION_PRODUCT_FUSION2 0x6300 | 82 | #define OPTION_PRODUCT_FUSION2 0x6300 |
83 | #define HUAWEI_PRODUCT_E600 0x1001 | ||
84 | #define AUDIOVOX_PRODUCT_AIRCARD 0x0112 | ||
78 | 85 | ||
79 | static struct usb_device_id option_ids[] = { | 86 | static struct usb_device_id option_ids[] = { |
80 | { USB_DEVICE(OPTION_VENDOR_ID, OPTION_PRODUCT_OLD) }, | 87 | { USB_DEVICE(OPTION_VENDOR_ID, OPTION_PRODUCT_OLD) }, |
81 | { USB_DEVICE(OPTION_VENDOR_ID, OPTION_PRODUCT_FUSION) }, | 88 | { USB_DEVICE(OPTION_VENDOR_ID, OPTION_PRODUCT_FUSION) }, |
82 | { USB_DEVICE(OPTION_VENDOR_ID, OPTION_PRODUCT_FUSION2) }, | 89 | { USB_DEVICE(OPTION_VENDOR_ID, OPTION_PRODUCT_FUSION2) }, |
90 | { USB_DEVICE(HUAWEI_VENDOR_ID, HUAWEI_PRODUCT_E600) }, | ||
91 | { USB_DEVICE(AUDIOVOX_VENDOR_ID, AUDIOVOX_PRODUCT_AIRCARD) }, | ||
83 | { } /* Terminating entry */ | 92 | { } /* Terminating entry */ |
84 | }; | 93 | }; |
85 | 94 | ||
@@ -96,10 +105,12 @@ static struct usb_driver option_driver = { | |||
96 | /* The card has three separate interfaces, wich the serial driver | 105 | /* The card has three separate interfaces, wich the serial driver |
97 | * recognizes separately, thus num_port=1. | 106 | * recognizes separately, thus num_port=1. |
98 | */ | 107 | */ |
99 | static struct usb_serial_device_type option_3port_device = { | 108 | static struct usb_serial_driver option_3port_device = { |
100 | .owner = THIS_MODULE, | 109 | .driver = { |
101 | .name = "Option 3G data card", | 110 | .owner = THIS_MODULE, |
102 | .short_name = "option", | 111 | .name = "option", |
112 | }, | ||
113 | .description = "Option 3G data card", | ||
103 | .id_table = option_ids, | 114 | .id_table = option_ids, |
104 | .num_interrupt_in = NUM_DONT_CARE, | 115 | .num_interrupt_in = NUM_DONT_CARE, |
105 | .num_bulk_in = NUM_DONT_CARE, | 116 | .num_bulk_in = NUM_DONT_CARE, |
@@ -132,7 +143,7 @@ static int debug; | |||
132 | 143 | ||
133 | #define N_IN_URB 4 | 144 | #define N_IN_URB 4 |
134 | #define N_OUT_URB 1 | 145 | #define N_OUT_URB 1 |
135 | #define IN_BUFLEN 1024 | 146 | #define IN_BUFLEN 4096 |
136 | #define OUT_BUFLEN 128 | 147 | #define OUT_BUFLEN 128 |
137 | 148 | ||
138 | struct option_port_private { | 149 | struct option_port_private { |
diff --git a/drivers/usb/serial/pl2303.c b/drivers/usb/serial/pl2303.c index 3cf245bdda54..41a45a5025b2 100644 --- a/drivers/usb/serial/pl2303.c +++ b/drivers/usb/serial/pl2303.c | |||
@@ -8,31 +8,10 @@ | |||
8 | * | 8 | * |
9 | * This program is free software; you can redistribute it and/or modify | 9 | * This program is free software; you can redistribute it and/or modify |
10 | * it under the terms of the GNU General Public License as published by | 10 | * it under the terms of the GNU General Public License as published by |
11 | * the Free Software Foundation; either version 2 of the License, or | 11 | * the Free Software Foundation; either version 2 of the License. |
12 | * (at your option) any later version. | ||
13 | * | 12 | * |
14 | * See Documentation/usb/usb-serial.txt for more information on using this driver | 13 | * See Documentation/usb/usb-serial.txt for more information on using this driver |
15 | * | 14 | * |
16 | * 2002_Mar_26 gkh | ||
17 | * allowed driver to work properly if there is no tty assigned to a port | ||
18 | * (this happens for serial console devices.) | ||
19 | * | ||
20 | * 2001_Oct_06 gkh | ||
21 | * Added RTS and DTR line control. Thanks to joe@bndlg.de for parts of it. | ||
22 | * | ||
23 | * 2001_Sep_19 gkh | ||
24 | * Added break support. | ||
25 | * | ||
26 | * 2001_Aug_30 gkh | ||
27 | * fixed oops in write_bulk_callback. | ||
28 | * | ||
29 | * 2001_Aug_28 gkh | ||
30 | * reworked buffer logic to be like other usb-serial drivers. Hopefully | ||
31 | * removing some reported problems. | ||
32 | * | ||
33 | * 2001_Jun_06 gkh | ||
34 | * finished porting to 2.4 format. | ||
35 | * | ||
36 | */ | 15 | */ |
37 | 16 | ||
38 | #include <linux/config.h> | 17 | #include <linux/config.h> |
@@ -55,7 +34,6 @@ | |||
55 | /* | 34 | /* |
56 | * Version Information | 35 | * Version Information |
57 | */ | 36 | */ |
58 | #define DRIVER_VERSION "v0.12" | ||
59 | #define DRIVER_DESC "Prolific PL2303 USB to serial adaptor driver" | 37 | #define DRIVER_DESC "Prolific PL2303 USB to serial adaptor driver" |
60 | 38 | ||
61 | static int debug; | 39 | static int debug; |
@@ -93,7 +71,9 @@ static struct usb_device_id id_table [] = { | |||
93 | { USB_DEVICE(SITECOM_VENDOR_ID, SITECOM_PRODUCT_ID) }, | 71 | { USB_DEVICE(SITECOM_VENDOR_ID, SITECOM_PRODUCT_ID) }, |
94 | { USB_DEVICE(ALCATEL_VENDOR_ID, ALCATEL_PRODUCT_ID) }, | 72 | { USB_DEVICE(ALCATEL_VENDOR_ID, ALCATEL_PRODUCT_ID) }, |
95 | { USB_DEVICE(SAMSUNG_VENDOR_ID, SAMSUNG_PRODUCT_ID) }, | 73 | { USB_DEVICE(SAMSUNG_VENDOR_ID, SAMSUNG_PRODUCT_ID) }, |
74 | { USB_DEVICE(SIEMENS_VENDOR_ID, SIEMENS_PRODUCT_ID_SX1) }, | ||
96 | { USB_DEVICE(SIEMENS_VENDOR_ID, SIEMENS_PRODUCT_ID_X65) }, | 75 | { USB_DEVICE(SIEMENS_VENDOR_ID, SIEMENS_PRODUCT_ID_X65) }, |
76 | { USB_DEVICE(SIEMENS_VENDOR_ID, SIEMENS_PRODUCT_ID_X75) }, | ||
97 | { USB_DEVICE(SYNTECH_VENDOR_ID, SYNTECH_PRODUCT_ID) }, | 77 | { USB_DEVICE(SYNTECH_VENDOR_ID, SYNTECH_PRODUCT_ID) }, |
98 | { USB_DEVICE( NOKIA_CA42_VENDOR_ID, NOKIA_CA42_PRODUCT_ID ) }, | 78 | { USB_DEVICE( NOKIA_CA42_VENDOR_ID, NOKIA_CA42_PRODUCT_ID ) }, |
99 | { } /* Terminating entry */ | 79 | { } /* Terminating entry */ |
@@ -175,9 +155,11 @@ static unsigned int pl2303_buf_get(struct pl2303_buf *pb, char *buf, | |||
175 | 155 | ||
176 | 156 | ||
177 | /* All of the device info needed for the PL2303 SIO serial converter */ | 157 | /* All of the device info needed for the PL2303 SIO serial converter */ |
178 | static struct usb_serial_device_type pl2303_device = { | 158 | static struct usb_serial_driver pl2303_device = { |
179 | .owner = THIS_MODULE, | 159 | .driver = { |
180 | .name = "PL-2303", | 160 | .owner = THIS_MODULE, |
161 | .name = "pl2303", | ||
162 | }, | ||
181 | .id_table = id_table, | 163 | .id_table = id_table, |
182 | .num_interrupt_in = NUM_DONT_CARE, | 164 | .num_interrupt_in = NUM_DONT_CARE, |
183 | .num_bulk_in = 1, | 165 | .num_bulk_in = 1, |
@@ -831,7 +813,9 @@ static void pl2303_update_line_status(struct usb_serial_port *port, | |||
831 | u8 length = UART_STATE; | 813 | u8 length = UART_STATE; |
832 | 814 | ||
833 | if ((le16_to_cpu(port->serial->dev->descriptor.idVendor) == SIEMENS_VENDOR_ID) && | 815 | if ((le16_to_cpu(port->serial->dev->descriptor.idVendor) == SIEMENS_VENDOR_ID) && |
834 | (le16_to_cpu(port->serial->dev->descriptor.idProduct) == SIEMENS_PRODUCT_ID_X65)) { | 816 | (le16_to_cpu(port->serial->dev->descriptor.idProduct) == SIEMENS_PRODUCT_ID_X65 || |
817 | le16_to_cpu(port->serial->dev->descriptor.idProduct) == SIEMENS_PRODUCT_ID_SX1 || | ||
818 | le16_to_cpu(port->serial->dev->descriptor.idProduct) == SIEMENS_PRODUCT_ID_X75)) { | ||
835 | length = 1; | 819 | length = 1; |
836 | status_idx = 0; | 820 | status_idx = 0; |
837 | } | 821 | } |
@@ -1195,7 +1179,7 @@ static int __init pl2303_init (void) | |||
1195 | retval = usb_register(&pl2303_driver); | 1179 | retval = usb_register(&pl2303_driver); |
1196 | if (retval) | 1180 | if (retval) |
1197 | goto failed_usb_register; | 1181 | goto failed_usb_register; |
1198 | info(DRIVER_DESC " " DRIVER_VERSION); | 1182 | info(DRIVER_DESC); |
1199 | return 0; | 1183 | return 0; |
1200 | failed_usb_register: | 1184 | failed_usb_register: |
1201 | usb_serial_deregister(&pl2303_device); | 1185 | usb_serial_deregister(&pl2303_device); |
@@ -1215,7 +1199,6 @@ module_init(pl2303_init); | |||
1215 | module_exit(pl2303_exit); | 1199 | module_exit(pl2303_exit); |
1216 | 1200 | ||
1217 | MODULE_DESCRIPTION(DRIVER_DESC); | 1201 | MODULE_DESCRIPTION(DRIVER_DESC); |
1218 | MODULE_VERSION(DRIVER_VERSION); | ||
1219 | MODULE_LICENSE("GPL"); | 1202 | MODULE_LICENSE("GPL"); |
1220 | 1203 | ||
1221 | module_param(debug, bool, S_IRUGO | S_IWUSR); | 1204 | module_param(debug, bool, S_IRUGO | S_IWUSR); |
diff --git a/drivers/usb/serial/pl2303.h b/drivers/usb/serial/pl2303.h index 7be9644f5a03..21d434d81813 100644 --- a/drivers/usb/serial/pl2303.h +++ b/drivers/usb/serial/pl2303.h | |||
@@ -54,7 +54,9 @@ | |||
54 | #define SAMSUNG_PRODUCT_ID 0x8001 | 54 | #define SAMSUNG_PRODUCT_ID 0x8001 |
55 | 55 | ||
56 | #define SIEMENS_VENDOR_ID 0x11f5 | 56 | #define SIEMENS_VENDOR_ID 0x11f5 |
57 | #define SIEMENS_PRODUCT_ID_SX1 0x0001 | ||
57 | #define SIEMENS_PRODUCT_ID_X65 0x0003 | 58 | #define SIEMENS_PRODUCT_ID_X65 0x0003 |
59 | #define SIEMENS_PRODUCT_ID_X75 0x0004 | ||
58 | 60 | ||
59 | #define SYNTECH_VENDOR_ID 0x0745 | 61 | #define SYNTECH_VENDOR_ID 0x0745 |
60 | #define SYNTECH_PRODUCT_ID 0x0001 | 62 | #define SYNTECH_PRODUCT_ID 0x0001 |
diff --git a/drivers/usb/serial/safe_serial.c b/drivers/usb/serial/safe_serial.c index 96a17568cbf1..c22bdc0c4dfd 100644 --- a/drivers/usb/serial/safe_serial.c +++ b/drivers/usb/serial/safe_serial.c | |||
@@ -92,7 +92,7 @@ MODULE_DESCRIPTION (DRIVER_DESC); | |||
92 | MODULE_LICENSE("GPL"); | 92 | MODULE_LICENSE("GPL"); |
93 | 93 | ||
94 | #if defined(CONFIG_USBD_SAFE_SERIAL_VENDOR) && !defined(CONFIG_USBD_SAFE_SERIAL_PRODUCT) | 94 | #if defined(CONFIG_USBD_SAFE_SERIAL_VENDOR) && !defined(CONFIG_USBD_SAFE_SERIAL_PRODUCT) |
95 | #abort "SAFE_SERIAL_VENDOR defined without SAFE_SERIAL_PRODUCT" | 95 | #error "SAFE_SERIAL_VENDOR defined without SAFE_SERIAL_PRODUCT" |
96 | #endif | 96 | #endif |
97 | 97 | ||
98 | #if ! defined(CONFIG_USBD_SAFE_SERIAL_VENDOR) | 98 | #if ! defined(CONFIG_USBD_SAFE_SERIAL_VENDOR) |
@@ -397,9 +397,11 @@ static int safe_startup (struct usb_serial *serial) | |||
397 | return 0; | 397 | return 0; |
398 | } | 398 | } |
399 | 399 | ||
400 | static struct usb_serial_device_type safe_device = { | 400 | static struct usb_serial_driver safe_device = { |
401 | .owner = THIS_MODULE, | 401 | .driver = { |
402 | .name = "Safe", | 402 | .owner = THIS_MODULE, |
403 | .name = "safe_serial", | ||
404 | }, | ||
403 | .id_table = id_table, | 405 | .id_table = id_table, |
404 | .num_interrupt_in = NUM_DONT_CARE, | 406 | .num_interrupt_in = NUM_DONT_CARE, |
405 | .num_bulk_in = NUM_DONT_CARE, | 407 | .num_bulk_in = NUM_DONT_CARE, |
diff --git a/drivers/usb/serial/ti_usb_3410_5052.c b/drivers/usb/serial/ti_usb_3410_5052.c index 59c88de3e7ae..205dbf7201da 100644 --- a/drivers/usb/serial/ti_usb_3410_5052.c +++ b/drivers/usb/serial/ti_usb_3410_5052.c | |||
@@ -255,9 +255,12 @@ static struct usb_driver ti_usb_driver = { | |||
255 | .id_table = ti_id_table_combined, | 255 | .id_table = ti_id_table_combined, |
256 | }; | 256 | }; |
257 | 257 | ||
258 | static struct usb_serial_device_type ti_1port_device = { | 258 | static struct usb_serial_driver ti_1port_device = { |
259 | .owner = THIS_MODULE, | 259 | .driver = { |
260 | .name = "TI USB 3410 1 port adapter", | 260 | .owner = THIS_MODULE, |
261 | .name = "ti_usb_3410_5052_1", | ||
262 | }, | ||
263 | .description = "TI USB 3410 1 port adapter", | ||
261 | .id_table = ti_id_table_3410, | 264 | .id_table = ti_id_table_3410, |
262 | .num_interrupt_in = 1, | 265 | .num_interrupt_in = 1, |
263 | .num_bulk_in = 1, | 266 | .num_bulk_in = 1, |
@@ -282,9 +285,12 @@ static struct usb_serial_device_type ti_1port_device = { | |||
282 | .write_bulk_callback = ti_bulk_out_callback, | 285 | .write_bulk_callback = ti_bulk_out_callback, |
283 | }; | 286 | }; |
284 | 287 | ||
285 | static struct usb_serial_device_type ti_2port_device = { | 288 | static struct usb_serial_driver ti_2port_device = { |
286 | .owner = THIS_MODULE, | 289 | .driver = { |
287 | .name = "TI USB 5052 2 port adapter", | 290 | .owner = THIS_MODULE, |
291 | .name = "ti_usb_3410_5052_2", | ||
292 | }, | ||
293 | .description = "TI USB 5052 2 port adapter", | ||
288 | .id_table = ti_id_table_5052, | 294 | .id_table = ti_id_table_5052, |
289 | .num_interrupt_in = 1, | 295 | .num_interrupt_in = 1, |
290 | .num_bulk_in = 2, | 296 | .num_bulk_in = 2, |
diff --git a/drivers/usb/serial/usb-serial.c b/drivers/usb/serial/usb-serial.c index e77fbdfc782d..0c4881d18cd5 100644 --- a/drivers/usb/serial/usb-serial.c +++ b/drivers/usb/serial/usb-serial.c | |||
@@ -1,7 +1,7 @@ | |||
1 | /* | 1 | /* |
2 | * USB Serial Converter driver | 2 | * USB Serial Converter driver |
3 | * | 3 | * |
4 | * Copyright (C) 1999 - 2004 Greg Kroah-Hartman (greg@kroah.com) | 4 | * Copyright (C) 1999 - 2005 Greg Kroah-Hartman (greg@kroah.com) |
5 | * Copyright (C) 2000 Peter Berger (pberger@brimson.com) | 5 | * Copyright (C) 2000 Peter Berger (pberger@brimson.com) |
6 | * Copyright (C) 2000 Al Borchers (borchers@steinerpoint.com) | 6 | * Copyright (C) 2000 Al Borchers (borchers@steinerpoint.com) |
7 | * | 7 | * |
@@ -9,316 +9,11 @@ | |||
9 | * modify it under the terms of the GNU General Public License version | 9 | * modify it under the terms of the GNU General Public License version |
10 | * 2 as published by the Free Software Foundation. | 10 | * 2 as published by the Free Software Foundation. |
11 | * | 11 | * |
12 | * This driver was originally based on the ACM driver by Armin Fuerst (which was | 12 | * This driver was originally based on the ACM driver by Armin Fuerst (which was |
13 | * based on a driver by Brad Keryan) | 13 | * based on a driver by Brad Keryan) |
14 | * | 14 | * |
15 | * See Documentation/usb/usb-serial.txt for more information on using this driver | 15 | * See Documentation/usb/usb-serial.txt for more information on using this driver |
16 | * | 16 | * |
17 | * (12/10/2002) gkh | ||
18 | * Split the ports off into their own struct device, and added a | ||
19 | * usb-serial bus driver. | ||
20 | * | ||
21 | * (11/19/2002) gkh | ||
22 | * removed a few #ifdefs for the generic code and cleaned up the failure | ||
23 | * logic in initialization. | ||
24 | * | ||
25 | * (10/02/2002) gkh | ||
26 | * moved the console code to console.c and out of this file. | ||
27 | * | ||
28 | * (06/05/2002) gkh | ||
29 | * moved location of startup() call in serial_probe() until after all | ||
30 | * of the port information and endpoints are initialized. This makes | ||
31 | * things easier for some drivers. | ||
32 | * | ||
33 | * (04/10/2002) gkh | ||
34 | * added serial_read_proc function which creates a | ||
35 | * /proc/tty/driver/usb-serial file. | ||
36 | * | ||
37 | * (03/27/2002) gkh | ||
38 | * Got USB serial console code working properly and merged into the main | ||
39 | * version of the tree. Thanks to Randy Dunlap for the initial version | ||
40 | * of this code, and for pushing me to finish it up. | ||
41 | * The USB serial console works with any usb serial driver device. | ||
42 | * | ||
43 | * (03/21/2002) gkh | ||
44 | * Moved all manipulation of port->open_count into the core. Now the | ||
45 | * individual driver's open and close functions are called only when the | ||
46 | * first open() and last close() is called. Making the drivers a bit | ||
47 | * smaller and simpler. | ||
48 | * Fixed a bug if a driver didn't have the owner field set. | ||
49 | * | ||
50 | * (02/26/2002) gkh | ||
51 | * Moved all locking into the main serial_* functions, instead of having | ||
52 | * the individual drivers have to grab the port semaphore. This should | ||
53 | * reduce races. | ||
54 | * Reworked the MOD_INC logic a bit to always increment and decrement, even | ||
55 | * if the generic driver is being used. | ||
56 | * | ||
57 | * (10/10/2001) gkh | ||
58 | * usb_serial_disconnect() now sets the serial->dev pointer is to NULL to | ||
59 | * help prevent child drivers from accessing the device since it is now | ||
60 | * gone. | ||
61 | * | ||
62 | * (09/13/2001) gkh | ||
63 | * Moved generic driver initialize after we have registered with the USB | ||
64 | * core. Thanks to Randy Dunlap for pointing this problem out. | ||
65 | * | ||
66 | * (07/03/2001) gkh | ||
67 | * Fixed module paramater size. Thanks to John Brockmeyer for the pointer. | ||
68 | * Fixed vendor and product getting defined through the MODULE_PARM macro | ||
69 | * if the Generic driver wasn't compiled in. | ||
70 | * Fixed problem with generic_shutdown() not being called for drivers that | ||
71 | * don't have a shutdown() function. | ||
72 | * | ||
73 | * (06/06/2001) gkh | ||
74 | * added evil hack that is needed for the prolific pl2303 device due to the | ||
75 | * crazy way its endpoints are set up. | ||
76 | * | ||
77 | * (05/30/2001) gkh | ||
78 | * switched from using spinlock to a semaphore, which fixes lots of problems. | ||
79 | * | ||
80 | * (04/08/2001) gb | ||
81 | * Identify version on module load. | ||
82 | * | ||
83 | * 2001_02_05 gkh | ||
84 | * Fixed buffer overflows bug with the generic serial driver. Thanks to | ||
85 | * Todd Squires <squirest@ct0.com> for fixing this. | ||
86 | * | ||
87 | * (01/10/2001) gkh | ||
88 | * Fixed bug where the generic serial adaptor grabbed _any_ device that was | ||
89 | * offered to it. | ||
90 | * | ||
91 | * (12/12/2000) gkh | ||
92 | * Removed MOD_INC and MOD_DEC from poll and disconnect functions, and | ||
93 | * moved them to the serial_open and serial_close functions. | ||
94 | * Also fixed bug with there not being a MOD_DEC for the generic driver | ||
95 | * (thanks to Gary Brubaker for finding this.) | ||
96 | * | ||
97 | * (11/29/2000) gkh | ||
98 | * Small NULL pointer initialization cleanup which saves a bit of disk image | ||
99 | * | ||
100 | * (11/01/2000) Adam J. Richter | ||
101 | * instead of using idVendor/idProduct pairs, usb serial drivers | ||
102 | * now identify their hardware interest with usb_device_id tables, | ||
103 | * which they usually have anyhow for use with MODULE_DEVICE_TABLE. | ||
104 | * | ||
105 | * (10/05/2000) gkh | ||
106 | * Fixed bug with urb->dev not being set properly, now that the usb | ||
107 | * core needs it. | ||
108 | * | ||
109 | * (09/11/2000) gkh | ||
110 | * Removed DEBUG #ifdefs with call to usb_serial_debug_data | ||
111 | * | ||
112 | * (08/28/2000) gkh | ||
113 | * Added port_lock to port structure. | ||
114 | * Added locks for SMP safeness to generic driver | ||
115 | * Fixed the ability to open a generic device's port more than once. | ||
116 | * | ||
117 | * (07/23/2000) gkh | ||
118 | * Added bulk_out_endpointAddress to port structure. | ||
119 | * | ||
120 | * (07/19/2000) gkh, pberger, and borchers | ||
121 | * Modifications to allow usb-serial drivers to be modules. | ||
122 | * | ||
123 | * (07/03/2000) gkh | ||
124 | * Added more debugging to serial_ioctl call | ||
125 | * | ||
126 | * (06/25/2000) gkh | ||
127 | * Changed generic_write_bulk_callback to not call wake_up_interruptible | ||
128 | * directly, but to have port_softint do it at a safer time. | ||
129 | * | ||
130 | * (06/23/2000) gkh | ||
131 | * Cleaned up debugging statements in a quest to find UHCI timeout bug. | ||
132 | * | ||
133 | * (05/22/2000) gkh | ||
134 | * Changed the makefile, enabling the big CONFIG_USB_SERIAL_SOMTHING to be | ||
135 | * removed from the individual device source files. | ||
136 | * | ||
137 | * (05/03/2000) gkh | ||
138 | * Added the Digi Acceleport driver from Al Borchers and Peter Berger. | ||
139 | * | ||
140 | * (05/02/2000) gkh | ||
141 | * Changed devfs and tty register code to work properly now. This was based on | ||
142 | * the ACM driver changes by Vojtech Pavlik. | ||
143 | * | ||
144 | * (04/27/2000) Ryan VanderBijl | ||
145 | * Put calls to *_paranoia_checks into one function. | ||
146 | * | ||
147 | * (04/23/2000) gkh | ||
148 | * Fixed bug that Randy Dunlap found for Generic devices with no bulk out ports. | ||
149 | * Moved when the startup code printed out the devices that are supported. | ||
150 | * | ||
151 | * (04/19/2000) gkh | ||
152 | * Added driver for ZyXEL omni.net lcd plus ISDN TA | ||
153 | * Made startup info message specify which drivers were compiled in. | ||
154 | * | ||
155 | * (04/03/2000) gkh | ||
156 | * Changed the probe process to remove the module unload races. | ||
157 | * Changed where the tty layer gets initialized to have devfs work nicer. | ||
158 | * Added initial devfs support. | ||
159 | * | ||
160 | * (03/26/2000) gkh | ||
161 | * Split driver up into device specific pieces. | ||
162 | * | ||
163 | * (03/19/2000) gkh | ||
164 | * Fixed oops that could happen when device was removed while a program | ||
165 | * was talking to the device. | ||
166 | * Removed the static urbs and now all urbs are created and destroyed | ||
167 | * dynamically. | ||
168 | * Reworked the internal interface. Now everything is based on the | ||
169 | * usb_serial_port structure instead of the larger usb_serial structure. | ||
170 | * This fixes the bug that a multiport device could not have more than | ||
171 | * one port open at one time. | ||
172 | * | ||
173 | * (03/17/2000) gkh | ||
174 | * Added config option for debugging messages. | ||
175 | * Added patch for keyspan pda from Brian Warner. | ||
176 | * | ||
177 | * (03/06/2000) gkh | ||
178 | * Added the keyspan pda code from Brian Warner <warner@lothar.com> | ||
179 | * Moved a bunch of the port specific stuff into its own structure. This | ||
180 | * is in anticipation of the true multiport devices (there's a bug if you | ||
181 | * try to access more than one port of any multiport device right now) | ||
182 | * | ||
183 | * (02/21/2000) gkh | ||
184 | * Made it so that any serial devices only have to specify which functions | ||
185 | * they want to overload from the generic function calls (great, | ||
186 | * inheritance in C, in a driver, just what I wanted...) | ||
187 | * Added support for set_termios and ioctl function calls. No drivers take | ||
188 | * advantage of this yet. | ||
189 | * Removed the #ifdef MODULE, now there is no module specific code. | ||
190 | * Cleaned up a few comments in usb-serial.h that were wrong (thanks again | ||
191 | * to Miles Lott). | ||
192 | * Small fix to get_free_serial. | ||
193 | * | ||
194 | * (02/14/2000) gkh | ||
195 | * Removed the Belkin and Peracom functionality from the driver due to | ||
196 | * the lack of support from the vendor, and me not wanting people to | ||
197 | * accidenatly buy the device, expecting it to work with Linux. | ||
198 | * Added read_bulk_callback and write_bulk_callback to the type structure | ||
199 | * for the needs of the FTDI and WhiteHEAT driver. | ||
200 | * Changed all reverences to FTDI to FTDI_SIO at the request of Bill | ||
201 | * Ryder. | ||
202 | * Changed the output urb size back to the max endpoint size to make | ||
203 | * the ftdi_sio driver have it easier, and due to the fact that it didn't | ||
204 | * really increase the speed any. | ||
205 | * | ||
206 | * (02/11/2000) gkh | ||
207 | * Added VISOR_FUNCTION_CONSOLE to the visor startup function. This was a | ||
208 | * patch from Miles Lott (milos@insync.net). | ||
209 | * Fixed bug with not restoring the minor range that a device grabs, if | ||
210 | * the startup function fails (thanks Miles for finding this). | ||
211 | * | ||
212 | * (02/05/2000) gkh | ||
213 | * Added initial framework for the Keyspan PDA serial converter so that | ||
214 | * Brian Warner has a place to put his code. | ||
215 | * Made the ezusb specific functions generic enough that different | ||
216 | * devices can use them (whiteheat and keyspan_pda both need them). | ||
217 | * Split out a whole bunch of structure and other stuff to a separate | ||
218 | * usb-serial.h file. | ||
219 | * Made the Visor connection messages a little more understandable, now | ||
220 | * that Miles Lott (milos@insync.net) has gotten the Generic channel to | ||
221 | * work. Also made them always show up in the log file. | ||
222 | * | ||
223 | * (01/25/2000) gkh | ||
224 | * Added initial framework for FTDI serial converter so that Bill Ryder | ||
225 | * has a place to put his code. | ||
226 | * Added the vendor specific info from Handspring. Now we can print out | ||
227 | * informational debug messages as well as understand what is happening. | ||
228 | * | ||
229 | * (01/23/2000) gkh | ||
230 | * Fixed problem of crash when trying to open a port that didn't have a | ||
231 | * device assigned to it. Made the minor node finding a little smarter, | ||
232 | * now it looks to find a continuous space for the new device. | ||
233 | * | ||
234 | * (01/21/2000) gkh | ||
235 | * Fixed bug in visor_startup with patch from Miles Lott (milos@insync.net) | ||
236 | * Fixed get_serial_by_minor which was all messed up for multi port | ||
237 | * devices. Fixed multi port problem for generic devices. Now the number | ||
238 | * of ports is determined by the number of bulk out endpoints for the | ||
239 | * generic device. | ||
240 | * | ||
241 | * (01/19/2000) gkh | ||
242 | * Removed lots of cruft that was around from the old (pre urb) driver | ||
243 | * interface. | ||
244 | * Made the serial_table dynamic. This should save lots of memory when | ||
245 | * the number of minor nodes goes up to 256. | ||
246 | * Added initial support for devices that have more than one port. | ||
247 | * Added more debugging comments for the Visor, and added a needed | ||
248 | * set_configuration call. | ||
249 | * | ||
250 | * (01/17/2000) gkh | ||
251 | * Fixed the WhiteHEAT firmware (my processing tool had a bug) | ||
252 | * and added new debug loader firmware for it. | ||
253 | * Removed the put_char function as it isn't really needed. | ||
254 | * Added visor startup commands as found by the Win98 dump. | ||
255 | * | ||
256 | * (01/13/2000) gkh | ||
257 | * Fixed the vendor id for the generic driver to the one I meant it to be. | ||
258 | * | ||
259 | * (01/12/2000) gkh | ||
260 | * Forget the version numbering...that's pretty useless... | ||
261 | * Made the driver able to be compiled so that the user can select which | ||
262 | * converter they want to use. This allows people who only want the Visor | ||
263 | * support to not pay the memory size price of the WhiteHEAT. | ||
264 | * Fixed bug where the generic driver (idVendor=0000 and idProduct=0000) | ||
265 | * grabbed the root hub. Not good. | ||
266 | * | ||
267 | * version 0.4.0 (01/10/2000) gkh | ||
268 | * Added whiteheat.h containing the firmware for the ConnectTech WhiteHEAT | ||
269 | * device. Added startup function to allow firmware to be downloaded to | ||
270 | * a device if it needs to be. | ||
271 | * Added firmware download logic to the WhiteHEAT device. | ||
272 | * Started to add #defines to split up the different drivers for potential | ||
273 | * configuration option. | ||
274 | * | ||
275 | * version 0.3.1 (12/30/99) gkh | ||
276 | * Fixed problems with urb for bulk out. | ||
277 | * Added initial support for multiple sets of endpoints. This enables | ||
278 | * the Handspring Visor to be attached successfully. Only the first | ||
279 | * bulk in / bulk out endpoint pair is being used right now. | ||
280 | * | ||
281 | * version 0.3.0 (12/27/99) gkh | ||
282 | * Added initial support for the Handspring Visor based on a patch from | ||
283 | * Miles Lott (milos@sneety.insync.net) | ||
284 | * Cleaned up the code a bunch and converted over to using urbs only. | ||
285 | * | ||
286 | * version 0.2.3 (12/21/99) gkh | ||
287 | * Added initial support for the Connect Tech WhiteHEAT converter. | ||
288 | * Incremented the number of ports in expectation of getting the | ||
289 | * WhiteHEAT to work properly (4 ports per connection). | ||
290 | * Added notification on insertion and removal of what port the | ||
291 | * device is/was connected to (and what kind of device it was). | ||
292 | * | ||
293 | * version 0.2.2 (12/16/99) gkh | ||
294 | * Changed major number to the new allocated number. We're legal now! | ||
295 | * | ||
296 | * version 0.2.1 (12/14/99) gkh | ||
297 | * Fixed bug that happens when device node is opened when there isn't a | ||
298 | * device attached to it. Thanks to marek@webdesign.no for noticing this. | ||
299 | * | ||
300 | * version 0.2.0 (11/10/99) gkh | ||
301 | * Split up internals to make it easier to add different types of serial | ||
302 | * converters to the code. | ||
303 | * Added a "generic" driver that gets it's vendor and product id | ||
304 | * from when the module is loaded. Thanks to David E. Nelson (dnelson@jump.net) | ||
305 | * for the idea and sample code (from the usb scanner driver.) | ||
306 | * Cleared up any licensing questions by releasing it under the GNU GPL. | ||
307 | * | ||
308 | * version 0.1.2 (10/25/99) gkh | ||
309 | * Fixed bug in detecting device. | ||
310 | * | ||
311 | * version 0.1.1 (10/05/99) gkh | ||
312 | * Changed the major number to not conflict with anything else. | ||
313 | * | ||
314 | * version 0.1 (09/28/99) gkh | ||
315 | * Can recognize the two different devices and start up a read from | ||
316 | * device when asked to. Writes also work. No control signals yet, this | ||
317 | * all is vendor specific data (i.e. no spec), also no control for | ||
318 | * different baud rates or other bit settings. | ||
319 | * Currently we are using the same devid as the acm driver. This needs | ||
320 | * to change. | ||
321 | * | ||
322 | */ | 17 | */ |
323 | 18 | ||
324 | #include <linux/config.h> | 19 | #include <linux/config.h> |
@@ -342,7 +37,6 @@ | |||
342 | /* | 37 | /* |
343 | * Version Information | 38 | * Version Information |
344 | */ | 39 | */ |
345 | #define DRIVER_VERSION "v2.0" | ||
346 | #define DRIVER_AUTHOR "Greg Kroah-Hartman, greg@kroah.com, http://www.kroah.com/linux/" | 40 | #define DRIVER_AUTHOR "Greg Kroah-Hartman, greg@kroah.com, http://www.kroah.com/linux/" |
347 | #define DRIVER_DESC "USB Serial Driver core" | 41 | #define DRIVER_DESC "USB Serial Driver core" |
348 | 42 | ||
@@ -427,7 +121,7 @@ static void destroy_serial(struct kref *kref) | |||
427 | 121 | ||
428 | serial = to_usb_serial(kref); | 122 | serial = to_usb_serial(kref); |
429 | 123 | ||
430 | dbg ("%s - %s", __FUNCTION__, serial->type->name); | 124 | dbg("%s - %s", __FUNCTION__, serial->type->description); |
431 | 125 | ||
432 | serial->type->shutdown(serial); | 126 | serial->type->shutdown(serial); |
433 | 127 | ||
@@ -507,7 +201,7 @@ static int serial_open (struct tty_struct *tty, struct file * filp) | |||
507 | /* lock this module before we call it | 201 | /* lock this module before we call it |
508 | * this may fail, which means we must bail out, | 202 | * this may fail, which means we must bail out, |
509 | * safe because we are called with BKL held */ | 203 | * safe because we are called with BKL held */ |
510 | if (!try_module_get(serial->type->owner)) { | 204 | if (!try_module_get(serial->type->driver.owner)) { |
511 | retval = -ENODEV; | 205 | retval = -ENODEV; |
512 | goto bailout_kref_put; | 206 | goto bailout_kref_put; |
513 | } | 207 | } |
@@ -522,7 +216,7 @@ static int serial_open (struct tty_struct *tty, struct file * filp) | |||
522 | return 0; | 216 | return 0; |
523 | 217 | ||
524 | bailout_module_put: | 218 | bailout_module_put: |
525 | module_put(serial->type->owner); | 219 | module_put(serial->type->driver.owner); |
526 | bailout_kref_put: | 220 | bailout_kref_put: |
527 | kref_put(&serial->kref, destroy_serial); | 221 | kref_put(&serial->kref, destroy_serial); |
528 | port->open_count = 0; | 222 | port->open_count = 0; |
@@ -553,7 +247,7 @@ static void serial_close(struct tty_struct *tty, struct file * filp) | |||
553 | port->tty = NULL; | 247 | port->tty = NULL; |
554 | } | 248 | } |
555 | 249 | ||
556 | module_put(port->serial->type->owner); | 250 | module_put(port->serial->type->driver.owner); |
557 | } | 251 | } |
558 | 252 | ||
559 | kref_put(&port->serial->kref, destroy_serial); | 253 | kref_put(&port->serial->kref, destroy_serial); |
@@ -711,16 +405,16 @@ static int serial_read_proc (char *page, char **start, off_t off, int count, int | |||
711 | char tmp[40]; | 405 | char tmp[40]; |
712 | 406 | ||
713 | dbg("%s", __FUNCTION__); | 407 | dbg("%s", __FUNCTION__); |
714 | length += sprintf (page, "usbserinfo:1.0 driver:%s\n", DRIVER_VERSION); | 408 | length += sprintf (page, "usbserinfo:1.0 driver:2.0\n"); |
715 | for (i = 0; i < SERIAL_TTY_MINORS && length < PAGE_SIZE; ++i) { | 409 | for (i = 0; i < SERIAL_TTY_MINORS && length < PAGE_SIZE; ++i) { |
716 | serial = usb_serial_get_by_index(i); | 410 | serial = usb_serial_get_by_index(i); |
717 | if (serial == NULL) | 411 | if (serial == NULL) |
718 | continue; | 412 | continue; |
719 | 413 | ||
720 | length += sprintf (page+length, "%d:", i); | 414 | length += sprintf (page+length, "%d:", i); |
721 | if (serial->type->owner) | 415 | if (serial->type->driver.owner) |
722 | length += sprintf (page+length, " module:%s", module_name(serial->type->owner)); | 416 | length += sprintf (page+length, " module:%s", module_name(serial->type->driver.owner)); |
723 | length += sprintf (page+length, " name:\"%s\"", serial->type->name); | 417 | length += sprintf (page+length, " name:\"%s\"", serial->type->description); |
724 | length += sprintf (page+length, " vendor:%04x product:%04x", | 418 | length += sprintf (page+length, " vendor:%04x product:%04x", |
725 | le16_to_cpu(serial->dev->descriptor.idVendor), | 419 | le16_to_cpu(serial->dev->descriptor.idVendor), |
726 | le16_to_cpu(serial->dev->descriptor.idProduct)); | 420 | le16_to_cpu(serial->dev->descriptor.idProduct)); |
@@ -823,7 +517,7 @@ static void port_release(struct device *dev) | |||
823 | 517 | ||
824 | static struct usb_serial * create_serial (struct usb_device *dev, | 518 | static struct usb_serial * create_serial (struct usb_device *dev, |
825 | struct usb_interface *interface, | 519 | struct usb_interface *interface, |
826 | struct usb_serial_device_type *type) | 520 | struct usb_serial_driver *driver) |
827 | { | 521 | { |
828 | struct usb_serial *serial; | 522 | struct usb_serial *serial; |
829 | 523 | ||
@@ -834,22 +528,22 @@ static struct usb_serial * create_serial (struct usb_device *dev, | |||
834 | } | 528 | } |
835 | memset (serial, 0, sizeof(*serial)); | 529 | memset (serial, 0, sizeof(*serial)); |
836 | serial->dev = usb_get_dev(dev); | 530 | serial->dev = usb_get_dev(dev); |
837 | serial->type = type; | 531 | serial->type = driver; |
838 | serial->interface = interface; | 532 | serial->interface = interface; |
839 | kref_init(&serial->kref); | 533 | kref_init(&serial->kref); |
840 | 534 | ||
841 | return serial; | 535 | return serial; |
842 | } | 536 | } |
843 | 537 | ||
844 | static struct usb_serial_device_type *search_serial_device(struct usb_interface *iface) | 538 | static struct usb_serial_driver *search_serial_device(struct usb_interface *iface) |
845 | { | 539 | { |
846 | struct list_head *p; | 540 | struct list_head *p; |
847 | const struct usb_device_id *id; | 541 | const struct usb_device_id *id; |
848 | struct usb_serial_device_type *t; | 542 | struct usb_serial_driver *t; |
849 | 543 | ||
850 | /* List trough know devices and see if the usb id matches */ | 544 | /* List trough know devices and see if the usb id matches */ |
851 | list_for_each(p, &usb_serial_driver_list) { | 545 | list_for_each(p, &usb_serial_driver_list) { |
852 | t = list_entry(p, struct usb_serial_device_type, driver_list); | 546 | t = list_entry(p, struct usb_serial_driver, driver_list); |
853 | id = usb_match_id(iface, t->id_table); | 547 | id = usb_match_id(iface, t->id_table); |
854 | if (id != NULL) { | 548 | if (id != NULL) { |
855 | dbg("descriptor matches"); | 549 | dbg("descriptor matches"); |
@@ -872,7 +566,7 @@ int usb_serial_probe(struct usb_interface *interface, | |||
872 | struct usb_endpoint_descriptor *interrupt_out_endpoint[MAX_NUM_PORTS]; | 566 | struct usb_endpoint_descriptor *interrupt_out_endpoint[MAX_NUM_PORTS]; |
873 | struct usb_endpoint_descriptor *bulk_in_endpoint[MAX_NUM_PORTS]; | 567 | struct usb_endpoint_descriptor *bulk_in_endpoint[MAX_NUM_PORTS]; |
874 | struct usb_endpoint_descriptor *bulk_out_endpoint[MAX_NUM_PORTS]; | 568 | struct usb_endpoint_descriptor *bulk_out_endpoint[MAX_NUM_PORTS]; |
875 | struct usb_serial_device_type *type = NULL; | 569 | struct usb_serial_driver *type = NULL; |
876 | int retval; | 570 | int retval; |
877 | int minor; | 571 | int minor; |
878 | int buffer_size; | 572 | int buffer_size; |
@@ -900,7 +594,7 @@ int usb_serial_probe(struct usb_interface *interface, | |||
900 | if (type->probe) { | 594 | if (type->probe) { |
901 | const struct usb_device_id *id; | 595 | const struct usb_device_id *id; |
902 | 596 | ||
903 | if (!try_module_get(type->owner)) { | 597 | if (!try_module_get(type->driver.owner)) { |
904 | dev_err(&interface->dev, "module get failed, exiting\n"); | 598 | dev_err(&interface->dev, "module get failed, exiting\n"); |
905 | kfree (serial); | 599 | kfree (serial); |
906 | return -EIO; | 600 | return -EIO; |
@@ -908,7 +602,7 @@ int usb_serial_probe(struct usb_interface *interface, | |||
908 | 602 | ||
909 | id = usb_match_id(interface, type->id_table); | 603 | id = usb_match_id(interface, type->id_table); |
910 | retval = type->probe(serial, id); | 604 | retval = type->probe(serial, id); |
911 | module_put(type->owner); | 605 | module_put(type->driver.owner); |
912 | 606 | ||
913 | if (retval) { | 607 | if (retval) { |
914 | dbg ("sub driver rejected device"); | 608 | dbg ("sub driver rejected device"); |
@@ -992,7 +686,7 @@ int usb_serial_probe(struct usb_interface *interface, | |||
992 | #endif | 686 | #endif |
993 | 687 | ||
994 | /* found all that we need */ | 688 | /* found all that we need */ |
995 | dev_info(&interface->dev, "%s converter detected\n", type->name); | 689 | dev_info(&interface->dev, "%s converter detected\n", type->description); |
996 | 690 | ||
997 | #ifdef CONFIG_USB_SERIAL_GENERIC | 691 | #ifdef CONFIG_USB_SERIAL_GENERIC |
998 | if (type == &usb_serial_generic_device) { | 692 | if (type == &usb_serial_generic_device) { |
@@ -1007,13 +701,13 @@ int usb_serial_probe(struct usb_interface *interface, | |||
1007 | if (!num_ports) { | 701 | if (!num_ports) { |
1008 | /* if this device type has a calc_num_ports function, call it */ | 702 | /* if this device type has a calc_num_ports function, call it */ |
1009 | if (type->calc_num_ports) { | 703 | if (type->calc_num_ports) { |
1010 | if (!try_module_get(type->owner)) { | 704 | if (!try_module_get(type->driver.owner)) { |
1011 | dev_err(&interface->dev, "module get failed, exiting\n"); | 705 | dev_err(&interface->dev, "module get failed, exiting\n"); |
1012 | kfree (serial); | 706 | kfree (serial); |
1013 | return -EIO; | 707 | return -EIO; |
1014 | } | 708 | } |
1015 | num_ports = type->calc_num_ports (serial); | 709 | num_ports = type->calc_num_ports (serial); |
1016 | module_put(type->owner); | 710 | module_put(type->driver.owner); |
1017 | } | 711 | } |
1018 | if (!num_ports) | 712 | if (!num_ports) |
1019 | num_ports = type->num_ports; | 713 | num_ports = type->num_ports; |
@@ -1158,12 +852,12 @@ int usb_serial_probe(struct usb_interface *interface, | |||
1158 | 852 | ||
1159 | /* if this device type has an attach function, call it */ | 853 | /* if this device type has an attach function, call it */ |
1160 | if (type->attach) { | 854 | if (type->attach) { |
1161 | if (!try_module_get(type->owner)) { | 855 | if (!try_module_get(type->driver.owner)) { |
1162 | dev_err(&interface->dev, "module get failed, exiting\n"); | 856 | dev_err(&interface->dev, "module get failed, exiting\n"); |
1163 | goto probe_error; | 857 | goto probe_error; |
1164 | } | 858 | } |
1165 | retval = type->attach (serial); | 859 | retval = type->attach (serial); |
1166 | module_put(type->owner); | 860 | module_put(type->driver.owner); |
1167 | if (retval < 0) | 861 | if (retval < 0) |
1168 | goto probe_error; | 862 | goto probe_error; |
1169 | if (retval > 0) { | 863 | if (retval > 0) { |
@@ -1330,7 +1024,7 @@ static int __init usb_serial_init(void) | |||
1330 | goto exit_generic; | 1024 | goto exit_generic; |
1331 | } | 1025 | } |
1332 | 1026 | ||
1333 | info(DRIVER_DESC " " DRIVER_VERSION); | 1027 | info(DRIVER_DESC); |
1334 | 1028 | ||
1335 | return result; | 1029 | return result; |
1336 | 1030 | ||
@@ -1375,7 +1069,7 @@ module_exit(usb_serial_exit); | |||
1375 | } \ | 1069 | } \ |
1376 | } while (0) | 1070 | } while (0) |
1377 | 1071 | ||
1378 | static void fixup_generic(struct usb_serial_device_type *device) | 1072 | static void fixup_generic(struct usb_serial_driver *device) |
1379 | { | 1073 | { |
1380 | set_to_generic_if_null(device, open); | 1074 | set_to_generic_if_null(device, open); |
1381 | set_to_generic_if_null(device, write); | 1075 | set_to_generic_if_null(device, write); |
@@ -1387,30 +1081,33 @@ static void fixup_generic(struct usb_serial_device_type *device) | |||
1387 | set_to_generic_if_null(device, shutdown); | 1081 | set_to_generic_if_null(device, shutdown); |
1388 | } | 1082 | } |
1389 | 1083 | ||
1390 | int usb_serial_register(struct usb_serial_device_type *new_device) | 1084 | int usb_serial_register(struct usb_serial_driver *driver) |
1391 | { | 1085 | { |
1392 | int retval; | 1086 | int retval; |
1393 | 1087 | ||
1394 | fixup_generic(new_device); | 1088 | fixup_generic(driver); |
1089 | |||
1090 | if (!driver->description) | ||
1091 | driver->description = driver->driver.name; | ||
1395 | 1092 | ||
1396 | /* Add this device to our list of devices */ | 1093 | /* Add this device to our list of devices */ |
1397 | list_add(&new_device->driver_list, &usb_serial_driver_list); | 1094 | list_add(&driver->driver_list, &usb_serial_driver_list); |
1398 | 1095 | ||
1399 | retval = usb_serial_bus_register(new_device); | 1096 | retval = usb_serial_bus_register(driver); |
1400 | if (retval) { | 1097 | if (retval) { |
1401 | err("problem %d when registering driver %s", retval, new_device->name); | 1098 | err("problem %d when registering driver %s", retval, driver->description); |
1402 | list_del(&new_device->driver_list); | 1099 | list_del(&driver->driver_list); |
1403 | } | 1100 | } |
1404 | else | 1101 | else |
1405 | info("USB Serial support registered for %s", new_device->name); | 1102 | info("USB Serial support registered for %s", driver->description); |
1406 | 1103 | ||
1407 | return retval; | 1104 | return retval; |
1408 | } | 1105 | } |
1409 | 1106 | ||
1410 | 1107 | ||
1411 | void usb_serial_deregister(struct usb_serial_device_type *device) | 1108 | void usb_serial_deregister(struct usb_serial_driver *device) |
1412 | { | 1109 | { |
1413 | info("USB Serial deregistering driver %s", device->name); | 1110 | info("USB Serial deregistering driver %s", device->description); |
1414 | list_del(&device->driver_list); | 1111 | list_del(&device->driver_list); |
1415 | usb_serial_bus_deregister(device); | 1112 | usb_serial_bus_deregister(device); |
1416 | } | 1113 | } |
@@ -1429,7 +1126,6 @@ EXPORT_SYMBOL_GPL(usb_serial_port_softint); | |||
1429 | /* Module information */ | 1126 | /* Module information */ |
1430 | MODULE_AUTHOR( DRIVER_AUTHOR ); | 1127 | MODULE_AUTHOR( DRIVER_AUTHOR ); |
1431 | MODULE_DESCRIPTION( DRIVER_DESC ); | 1128 | MODULE_DESCRIPTION( DRIVER_DESC ); |
1432 | MODULE_VERSION( DRIVER_VERSION ); | ||
1433 | MODULE_LICENSE("GPL"); | 1129 | MODULE_LICENSE("GPL"); |
1434 | 1130 | ||
1435 | module_param(debug, bool, S_IRUGO | S_IWUSR); | 1131 | module_param(debug, bool, S_IRUGO | S_IWUSR); |
diff --git a/drivers/usb/serial/usb-serial.h b/drivers/usb/serial/usb-serial.h index 57f92f054c75..238a5a871ed6 100644 --- a/drivers/usb/serial/usb-serial.h +++ b/drivers/usb/serial/usb-serial.h | |||
@@ -1,53 +1,13 @@ | |||
1 | /* | 1 | /* |
2 | * USB Serial Converter driver | 2 | * USB Serial Converter driver |
3 | * | 3 | * |
4 | * Copyright (C) 1999 - 2004 | 4 | * Copyright (C) 1999 - 2005 |
5 | * Greg Kroah-Hartman (greg@kroah.com) | 5 | * Greg Kroah-Hartman (greg@kroah.com) |
6 | * | 6 | * |
7 | * This program is free software; you can redistribute it and/or modify | 7 | * This program is free software; you can redistribute it and/or modify |
8 | * it under the terms of the GNU General Public License as published by | 8 | * it under the terms of the GNU General Public License as published by |
9 | * the Free Software Foundation; either version 2 of the License, or | 9 | * the Free Software Foundation; either version 2 of the License. |
10 | * (at your option) any later version. | ||
11 | * | 10 | * |
12 | * See Documentation/usb/usb-serial.txt for more information on using this driver | ||
13 | * | ||
14 | * (03/26/2002) gkh | ||
15 | * removed the port->tty check from port_paranoia_check() due to serial | ||
16 | * consoles not having a tty device assigned to them. | ||
17 | * | ||
18 | * (12/03/2001) gkh | ||
19 | * removed active from the port structure. | ||
20 | * added documentation to the usb_serial_device_type structure | ||
21 | * | ||
22 | * (10/10/2001) gkh | ||
23 | * added vendor and product to serial structure. Needed to determine device | ||
24 | * owner when the device is disconnected. | ||
25 | * | ||
26 | * (05/30/2001) gkh | ||
27 | * added sem to port structure and removed port_lock | ||
28 | * | ||
29 | * (10/05/2000) gkh | ||
30 | * Added interrupt_in_endpointAddress and bulk_in_endpointAddress to help | ||
31 | * fix bug with urb->dev not being set properly, now that the usb core | ||
32 | * needs it. | ||
33 | * | ||
34 | * (09/11/2000) gkh | ||
35 | * Added usb_serial_debug_data function to help get rid of #DEBUG in the | ||
36 | * drivers. | ||
37 | * | ||
38 | * (08/28/2000) gkh | ||
39 | * Added port_lock to port structure. | ||
40 | * | ||
41 | * (08/08/2000) gkh | ||
42 | * Added open_count to port structure. | ||
43 | * | ||
44 | * (07/23/2000) gkh | ||
45 | * Added bulk_out_endpointAddress to port structure. | ||
46 | * | ||
47 | * (07/19/2000) gkh, pberger, and borchers | ||
48 | * Modifications to allow usb-serial drivers to be modules. | ||
49 | * | ||
50 | * | ||
51 | */ | 11 | */ |
52 | 12 | ||
53 | 13 | ||
@@ -143,7 +103,7 @@ static inline void usb_set_serial_port_data (struct usb_serial_port *port, void | |||
143 | /** | 103 | /** |
144 | * usb_serial - structure used by the usb-serial core for a device | 104 | * usb_serial - structure used by the usb-serial core for a device |
145 | * @dev: pointer to the struct usb_device for this device | 105 | * @dev: pointer to the struct usb_device for this device |
146 | * @type: pointer to the struct usb_serial_device_type for this device | 106 | * @type: pointer to the struct usb_serial_driver for this device |
147 | * @interface: pointer to the struct usb_interface for this device | 107 | * @interface: pointer to the struct usb_interface for this device |
148 | * @minor: the starting minor number for this device | 108 | * @minor: the starting minor number for this device |
149 | * @num_ports: the number of ports this device has | 109 | * @num_ports: the number of ports this device has |
@@ -159,7 +119,7 @@ static inline void usb_set_serial_port_data (struct usb_serial_port *port, void | |||
159 | */ | 119 | */ |
160 | struct usb_serial { | 120 | struct usb_serial { |
161 | struct usb_device * dev; | 121 | struct usb_device * dev; |
162 | struct usb_serial_device_type * type; | 122 | struct usb_serial_driver * type; |
163 | struct usb_interface * interface; | 123 | struct usb_interface * interface; |
164 | unsigned char minor; | 124 | unsigned char minor; |
165 | unsigned char num_ports; | 125 | unsigned char num_ports; |
@@ -188,13 +148,9 @@ static inline void usb_set_serial_data (struct usb_serial *serial, void *data) | |||
188 | } | 148 | } |
189 | 149 | ||
190 | /** | 150 | /** |
191 | * usb_serial_device_type - a structure that defines a usb serial device | 151 | * usb_serial_driver - describes a usb serial driver |
192 | * @owner: pointer to the module that owns this device. | 152 | * @description: pointer to a string that describes this driver. This string used |
193 | * @name: pointer to a string that describes this device. This string used | ||
194 | * in the syslog messages when a device is inserted or removed. | 153 | * in the syslog messages when a device is inserted or removed. |
195 | * @short_name: a pointer to a string that describes this device in | ||
196 | * KOBJ_NAME_LEN characters or less. This is used for the sysfs interface | ||
197 | * to describe the driver. | ||
198 | * @id_table: pointer to a list of usb_device_id structures that define all | 154 | * @id_table: pointer to a list of usb_device_id structures that define all |
199 | * of the devices this structure can support. | 155 | * of the devices this structure can support. |
200 | * @num_interrupt_in: the number of interrupt in endpoints this device will | 156 | * @num_interrupt_in: the number of interrupt in endpoints this device will |
@@ -221,16 +177,19 @@ static inline void usb_set_serial_data (struct usb_serial *serial, void *data) | |||
221 | * @shutdown: pointer to the driver's shutdown function. This will be | 177 | * @shutdown: pointer to the driver's shutdown function. This will be |
222 | * called when the device is removed from the system. | 178 | * called when the device is removed from the system. |
223 | * | 179 | * |
224 | * This structure is defines a USB Serial device. It provides all of | 180 | * This structure is defines a USB Serial driver. It provides all of |
225 | * the information that the USB serial core code needs. If the function | 181 | * the information that the USB serial core code needs. If the function |
226 | * pointers are defined, then the USB serial core code will call them when | 182 | * pointers are defined, then the USB serial core code will call them when |
227 | * the corresponding tty port functions are called. If they are not | 183 | * the corresponding tty port functions are called. If they are not |
228 | * called, the generic serial function will be used instead. | 184 | * called, the generic serial function will be used instead. |
185 | * | ||
186 | * The driver.owner field should be set to the module owner of this driver. | ||
187 | * The driver.name field should be set to the name of this driver (remember | ||
188 | * it will show up in sysfs, so it needs to be short and to the point. | ||
189 | * Useing the module name is a good idea.) | ||
229 | */ | 190 | */ |
230 | struct usb_serial_device_type { | 191 | struct usb_serial_driver { |
231 | struct module *owner; | 192 | const char *description; |
232 | char *name; | ||
233 | char *short_name; | ||
234 | const struct usb_device_id *id_table; | 193 | const struct usb_device_id *id_table; |
235 | char num_interrupt_in; | 194 | char num_interrupt_in; |
236 | char num_interrupt_out; | 195 | char num_interrupt_out; |
@@ -269,10 +228,10 @@ struct usb_serial_device_type { | |||
269 | void (*read_bulk_callback)(struct urb *urb, struct pt_regs *regs); | 228 | void (*read_bulk_callback)(struct urb *urb, struct pt_regs *regs); |
270 | void (*write_bulk_callback)(struct urb *urb, struct pt_regs *regs); | 229 | void (*write_bulk_callback)(struct urb *urb, struct pt_regs *regs); |
271 | }; | 230 | }; |
272 | #define to_usb_serial_driver(d) container_of(d, struct usb_serial_device_type, driver) | 231 | #define to_usb_serial_driver(d) container_of(d, struct usb_serial_driver, driver) |
273 | 232 | ||
274 | extern int usb_serial_register(struct usb_serial_device_type *new_device); | 233 | extern int usb_serial_register(struct usb_serial_driver *driver); |
275 | extern void usb_serial_deregister(struct usb_serial_device_type *device); | 234 | extern void usb_serial_deregister(struct usb_serial_driver *driver); |
276 | extern void usb_serial_port_softint(void *private); | 235 | extern void usb_serial_port_softint(void *private); |
277 | 236 | ||
278 | extern int usb_serial_probe(struct usb_interface *iface, const struct usb_device_id *id); | 237 | extern int usb_serial_probe(struct usb_interface *iface, const struct usb_device_id *id); |
@@ -303,10 +262,10 @@ extern void usb_serial_generic_shutdown (struct usb_serial *serial); | |||
303 | extern int usb_serial_generic_register (int debug); | 262 | extern int usb_serial_generic_register (int debug); |
304 | extern void usb_serial_generic_deregister (void); | 263 | extern void usb_serial_generic_deregister (void); |
305 | 264 | ||
306 | extern int usb_serial_bus_register (struct usb_serial_device_type *device); | 265 | extern int usb_serial_bus_register (struct usb_serial_driver *device); |
307 | extern void usb_serial_bus_deregister (struct usb_serial_device_type *device); | 266 | extern void usb_serial_bus_deregister (struct usb_serial_driver *device); |
308 | 267 | ||
309 | extern struct usb_serial_device_type usb_serial_generic_device; | 268 | extern struct usb_serial_driver usb_serial_generic_device; |
310 | extern struct bus_type usb_serial_bus_type; | 269 | extern struct bus_type usb_serial_bus_type; |
311 | extern struct tty_driver *usb_serial_tty_driver; | 270 | extern struct tty_driver *usb_serial_tty_driver; |
312 | 271 | ||
diff --git a/drivers/usb/serial/visor.c b/drivers/usb/serial/visor.c index 31c57adcb623..a473c1c34559 100644 --- a/drivers/usb/serial/visor.c +++ b/drivers/usb/serial/visor.c | |||
@@ -7,139 +7,10 @@ | |||
7 | * | 7 | * |
8 | * This program is free software; you can redistribute it and/or modify | 8 | * This program is free software; you can redistribute it and/or modify |
9 | * it under the terms of the GNU General Public License as published by | 9 | * it under the terms of the GNU General Public License as published by |
10 | * the Free Software Foundation; either version 2 of the License, or | 10 | * the Free Software Foundation; either version 2 of the License. |
11 | * (at your option) any later version. | ||
12 | * | 11 | * |
13 | * See Documentation/usb/usb-serial.txt for more information on using this driver | 12 | * See Documentation/usb/usb-serial.txt for more information on using this driver |
14 | * | 13 | * |
15 | * (06/03/2003) Judd Montgomery <judd at jpilot.org> | ||
16 | * Added support for module parameter options for untested/unknown | ||
17 | * devices. | ||
18 | * | ||
19 | * (03/09/2003) gkh | ||
20 | * Added support for the Sony Clie NZ90V device. Thanks to Martin Brachtl | ||
21 | * <brachtl@redgrep.cz> for the information. | ||
22 | * | ||
23 | * (03/05/2003) gkh | ||
24 | * Think Treo support is now working. | ||
25 | * | ||
26 | * (04/03/2002) gkh | ||
27 | * Added support for the Sony OS 4.1 devices. Thanks to Hiroyuki ARAKI | ||
28 | * <hiro@zob.ne.jp> for the information. | ||
29 | * | ||
30 | * (03/27/2002) gkh | ||
31 | * Removed assumptions that port->tty was always valid (is not true | ||
32 | * for usb serial console devices.) | ||
33 | * | ||
34 | * (03/23/2002) gkh | ||
35 | * Added support for the Palm i705 device, thanks to Thomas Riemer | ||
36 | * <tom@netmech.com> for the information. | ||
37 | * | ||
38 | * (03/21/2002) gkh | ||
39 | * Added support for the Palm m130 device, thanks to Udo Eisenbarth | ||
40 | * <udo.eisenbarth@web.de> for the information. | ||
41 | * | ||
42 | * (02/27/2002) gkh | ||
43 | * Reworked the urb handling logic. We have no more pool, but dynamically | ||
44 | * allocate the urb and the transfer buffer on the fly. In testing this | ||
45 | * does not incure any measurable overhead. This also relies on the fact | ||
46 | * that we have proper reference counting logic for urbs. | ||
47 | * | ||
48 | * (02/21/2002) SilaS | ||
49 | * Added initial support for the Palm m515 devices. | ||
50 | * | ||
51 | * (02/14/2002) gkh | ||
52 | * Added support for the Clie S-360 device. | ||
53 | * | ||
54 | * (12/18/2001) gkh | ||
55 | * Added better Clie support for 3.5 devices. Thanks to Geoffrey Levand | ||
56 | * for the patch. | ||
57 | * | ||
58 | * (11/11/2001) gkh | ||
59 | * Added support for the m125 devices, and added check to prevent oopses | ||
60 | * for Clié devices that lie about the number of ports they have. | ||
61 | * | ||
62 | * (08/30/2001) gkh | ||
63 | * Added support for the Clie devices, both the 3.5 and 4.0 os versions. | ||
64 | * Many thanks to Daniel Burke, and Bryan Payne for helping with this. | ||
65 | * | ||
66 | * (08/23/2001) gkh | ||
67 | * fixed a few potential bugs pointed out by Oliver Neukum. | ||
68 | * | ||
69 | * (05/30/2001) gkh | ||
70 | * switched from using spinlock to a semaphore, which fixes lots of problems. | ||
71 | * | ||
72 | * (05/28/2000) gkh | ||
73 | * Added initial support for the Palm m500 and Palm m505 devices. | ||
74 | * | ||
75 | * (04/08/2001) gb | ||
76 | * Identify version on module load. | ||
77 | * | ||
78 | * (01/21/2000) gkh | ||
79 | * Added write_room and chars_in_buffer, as they were previously using the | ||
80 | * generic driver versions which is all wrong now that we are using an urb | ||
81 | * pool. Thanks to Wolfgang Grandegger for pointing this out to me. | ||
82 | * Removed count assignment in the write function, which was not needed anymore | ||
83 | * either. Thanks to Al Borchers for pointing this out. | ||
84 | * | ||
85 | * (12/12/2000) gkh | ||
86 | * Moved MOD_DEC to end of visor_close to be nicer, as the final write | ||
87 | * message can sleep. | ||
88 | * | ||
89 | * (11/12/2000) gkh | ||
90 | * Fixed bug with data being dropped on the floor by forcing tty->low_latency | ||
91 | * to be on. Hopefully this fixes the OHCI issue! | ||
92 | * | ||
93 | * (11/01/2000) Adam J. Richter | ||
94 | * usb_device_id table support | ||
95 | * | ||
96 | * (10/05/2000) gkh | ||
97 | * Fixed bug with urb->dev not being set properly, now that the usb | ||
98 | * core needs it. | ||
99 | * | ||
100 | * (09/11/2000) gkh | ||
101 | * Got rid of always calling kmalloc for every urb we wrote out to the | ||
102 | * device. | ||
103 | * Added visor_read_callback so we can keep track of bytes in and out for | ||
104 | * those people who like to know the speed of their device. | ||
105 | * Removed DEBUG #ifdefs with call to usb_serial_debug_data | ||
106 | * | ||
107 | * (09/06/2000) gkh | ||
108 | * Fixed oops in visor_exit. Need to uncomment usb_unlink_urb call _after_ | ||
109 | * the host controller drivers set urb->dev = NULL when the urb is finished. | ||
110 | * | ||
111 | * (08/28/2000) gkh | ||
112 | * Added locks for SMP safeness. | ||
113 | * | ||
114 | * (08/08/2000) gkh | ||
115 | * Fixed endian problem in visor_startup. | ||
116 | * Fixed MOD_INC and MOD_DEC logic and the ability to open a port more | ||
117 | * than once. | ||
118 | * | ||
119 | * (07/23/2000) gkh | ||
120 | * Added pool of write urbs to speed up transfers to the visor. | ||
121 | * | ||
122 | * (07/19/2000) gkh | ||
123 | * Added module_init and module_exit functions to handle the fact that this | ||
124 | * driver is a loadable module now. | ||
125 | * | ||
126 | * (07/03/2000) gkh | ||
127 | * Added visor_set_ioctl and visor_set_termios functions (they don't do much | ||
128 | * of anything, but are good for debugging.) | ||
129 | * | ||
130 | * (06/25/2000) gkh | ||
131 | * Fixed bug in visor_unthrottle that should help with the disconnect in PPP | ||
132 | * bug that people have been reporting. | ||
133 | * | ||
134 | * (06/23/2000) gkh | ||
135 | * Cleaned up debugging statements in a quest to find UHCI timeout bug. | ||
136 | * | ||
137 | * (04/27/2000) Ryan VanderBijl | ||
138 | * Fixed memory leak in visor_close | ||
139 | * | ||
140 | * (03/26/2000) gkh | ||
141 | * Split driver up into device specific pieces. | ||
142 | * | ||
143 | */ | 14 | */ |
144 | 15 | ||
145 | #include <linux/config.h> | 16 | #include <linux/config.h> |
@@ -161,7 +32,6 @@ | |||
161 | /* | 32 | /* |
162 | * Version Information | 33 | * Version Information |
163 | */ | 34 | */ |
164 | #define DRIVER_VERSION "v2.1" | ||
165 | #define DRIVER_AUTHOR "Greg Kroah-Hartman <greg@kroah.com>" | 35 | #define DRIVER_AUTHOR "Greg Kroah-Hartman <greg@kroah.com>" |
166 | #define DRIVER_DESC "USB HandSpring Visor / Palm OS driver" | 36 | #define DRIVER_DESC "USB HandSpring Visor / Palm OS driver" |
167 | 37 | ||
@@ -311,10 +181,12 @@ static struct usb_driver visor_driver = { | |||
311 | }; | 181 | }; |
312 | 182 | ||
313 | /* All of the device info needed for the Handspring Visor, and Palm 4.0 devices */ | 183 | /* All of the device info needed for the Handspring Visor, and Palm 4.0 devices */ |
314 | static struct usb_serial_device_type handspring_device = { | 184 | static struct usb_serial_driver handspring_device = { |
315 | .owner = THIS_MODULE, | 185 | .driver = { |
316 | .name = "Handspring Visor / Palm OS", | 186 | .owner = THIS_MODULE, |
317 | .short_name = "visor", | 187 | .name = "visor", |
188 | }, | ||
189 | .description = "Handspring Visor / Palm OS", | ||
318 | .id_table = id_table, | 190 | .id_table = id_table, |
319 | .num_interrupt_in = NUM_DONT_CARE, | 191 | .num_interrupt_in = NUM_DONT_CARE, |
320 | .num_bulk_in = 2, | 192 | .num_bulk_in = 2, |
@@ -339,10 +211,12 @@ static struct usb_serial_device_type handspring_device = { | |||
339 | }; | 211 | }; |
340 | 212 | ||
341 | /* All of the device info needed for the Clie UX50, TH55 Palm 5.0 devices */ | 213 | /* All of the device info needed for the Clie UX50, TH55 Palm 5.0 devices */ |
342 | static struct usb_serial_device_type clie_5_device = { | 214 | static struct usb_serial_driver clie_5_device = { |
343 | .owner = THIS_MODULE, | 215 | .driver = { |
344 | .name = "Sony Clie 5.0", | 216 | .owner = THIS_MODULE, |
345 | .short_name = "clie_5", | 217 | .name = "clie_5", |
218 | }, | ||
219 | .description = "Sony Clie 5.0", | ||
346 | .id_table = clie_id_5_table, | 220 | .id_table = clie_id_5_table, |
347 | .num_interrupt_in = NUM_DONT_CARE, | 221 | .num_interrupt_in = NUM_DONT_CARE, |
348 | .num_bulk_in = 2, | 222 | .num_bulk_in = 2, |
@@ -367,10 +241,12 @@ static struct usb_serial_device_type clie_5_device = { | |||
367 | }; | 241 | }; |
368 | 242 | ||
369 | /* device info for the Sony Clie OS version 3.5 */ | 243 | /* device info for the Sony Clie OS version 3.5 */ |
370 | static struct usb_serial_device_type clie_3_5_device = { | 244 | static struct usb_serial_driver clie_3_5_device = { |
371 | .owner = THIS_MODULE, | 245 | .driver = { |
372 | .name = "Sony Clie 3.5", | 246 | .owner = THIS_MODULE, |
373 | .short_name = "clie_3.5", | 247 | .name = "clie_3.5", |
248 | }, | ||
249 | .description = "Sony Clie 3.5", | ||
374 | .id_table = clie_id_3_5_table, | 250 | .id_table = clie_id_3_5_table, |
375 | .num_interrupt_in = 0, | 251 | .num_interrupt_in = 0, |
376 | .num_bulk_in = 1, | 252 | .num_bulk_in = 1, |
@@ -782,7 +658,7 @@ static int palm_os_3_probe (struct usb_serial *serial, const struct usb_device_i | |||
782 | break; | 658 | break; |
783 | } | 659 | } |
784 | dev_info(dev, "%s: port %d, is for %s use\n", | 660 | dev_info(dev, "%s: port %d, is for %s use\n", |
785 | serial->type->name, | 661 | serial->type->description, |
786 | connection_info->connections[i].port, string); | 662 | connection_info->connections[i].port, string); |
787 | } | 663 | } |
788 | } | 664 | } |
@@ -791,11 +667,11 @@ static int palm_os_3_probe (struct usb_serial *serial, const struct usb_device_i | |||
791 | */ | 667 | */ |
792 | if (num_ports == 0 || num_ports > 2) { | 668 | if (num_ports == 0 || num_ports > 2) { |
793 | dev_warn (dev, "%s: No valid connect info available\n", | 669 | dev_warn (dev, "%s: No valid connect info available\n", |
794 | serial->type->name); | 670 | serial->type->description); |
795 | num_ports = 2; | 671 | num_ports = 2; |
796 | } | 672 | } |
797 | 673 | ||
798 | dev_info(dev, "%s: Number of ports: %d\n", serial->type->name, | 674 | dev_info(dev, "%s: Number of ports: %d\n", serial->type->description, |
799 | num_ports); | 675 | num_ports); |
800 | 676 | ||
801 | /* | 677 | /* |
@@ -1125,7 +1001,7 @@ static int __init visor_init (void) | |||
1125 | retval = usb_register(&visor_driver); | 1001 | retval = usb_register(&visor_driver); |
1126 | if (retval) | 1002 | if (retval) |
1127 | goto failed_usb_register; | 1003 | goto failed_usb_register; |
1128 | info(DRIVER_DESC " " DRIVER_VERSION); | 1004 | info(DRIVER_DESC); |
1129 | 1005 | ||
1130 | return 0; | 1006 | return 0; |
1131 | failed_usb_register: | 1007 | failed_usb_register: |
diff --git a/drivers/usb/serial/whiteheat.c b/drivers/usb/serial/whiteheat.c index cf3bc30675a1..18c3183be769 100644 --- a/drivers/usb/serial/whiteheat.c +++ b/drivers/usb/serial/whiteheat.c | |||
@@ -156,10 +156,12 @@ static void whiteheat_unthrottle (struct usb_serial_port *port); | |||
156 | static void whiteheat_read_callback (struct urb *urb, struct pt_regs *regs); | 156 | static void whiteheat_read_callback (struct urb *urb, struct pt_regs *regs); |
157 | static void whiteheat_write_callback (struct urb *urb, struct pt_regs *regs); | 157 | static void whiteheat_write_callback (struct urb *urb, struct pt_regs *regs); |
158 | 158 | ||
159 | static struct usb_serial_device_type whiteheat_fake_device = { | 159 | static struct usb_serial_driver whiteheat_fake_device = { |
160 | .owner = THIS_MODULE, | 160 | .driver = { |
161 | .name = "Connect Tech - WhiteHEAT - (prerenumeration)", | 161 | .owner = THIS_MODULE, |
162 | .short_name = "whiteheatnofirm", | 162 | .name = "whiteheatnofirm", |
163 | }, | ||
164 | .description = "Connect Tech - WhiteHEAT - (prerenumeration)", | ||
163 | .id_table = id_table_prerenumeration, | 165 | .id_table = id_table_prerenumeration, |
164 | .num_interrupt_in = NUM_DONT_CARE, | 166 | .num_interrupt_in = NUM_DONT_CARE, |
165 | .num_bulk_in = NUM_DONT_CARE, | 167 | .num_bulk_in = NUM_DONT_CARE, |
@@ -169,10 +171,12 @@ static struct usb_serial_device_type whiteheat_fake_device = { | |||
169 | .attach = whiteheat_firmware_attach, | 171 | .attach = whiteheat_firmware_attach, |
170 | }; | 172 | }; |
171 | 173 | ||
172 | static struct usb_serial_device_type whiteheat_device = { | 174 | static struct usb_serial_driver whiteheat_device = { |
173 | .owner = THIS_MODULE, | 175 | .driver = { |
174 | .name = "Connect Tech - WhiteHEAT", | 176 | .owner = THIS_MODULE, |
175 | .short_name = "whiteheat", | 177 | .name = "whiteheat", |
178 | }, | ||
179 | .description = "Connect Tech - WhiteHEAT", | ||
176 | .id_table = id_table_std, | 180 | .id_table = id_table_std, |
177 | .num_interrupt_in = NUM_DONT_CARE, | 181 | .num_interrupt_in = NUM_DONT_CARE, |
178 | .num_bulk_in = NUM_DONT_CARE, | 182 | .num_bulk_in = NUM_DONT_CARE, |
@@ -382,10 +386,10 @@ static int whiteheat_attach (struct usb_serial *serial) | |||
382 | usb_clear_halt(serial->dev, pipe); | 386 | usb_clear_halt(serial->dev, pipe); |
383 | ret = usb_bulk_msg (serial->dev, pipe, command, 2, &alen, COMMAND_TIMEOUT_MS); | 387 | ret = usb_bulk_msg (serial->dev, pipe, command, 2, &alen, COMMAND_TIMEOUT_MS); |
384 | if (ret) { | 388 | if (ret) { |
385 | err("%s: Couldn't send command [%d]", serial->type->name, ret); | 389 | err("%s: Couldn't send command [%d]", serial->type->description, ret); |
386 | goto no_firmware; | 390 | goto no_firmware; |
387 | } else if (alen != sizeof(command)) { | 391 | } else if (alen != sizeof(command)) { |
388 | err("%s: Send command incomplete [%d]", serial->type->name, alen); | 392 | err("%s: Send command incomplete [%d]", serial->type->description, alen); |
389 | goto no_firmware; | 393 | goto no_firmware; |
390 | } | 394 | } |
391 | 395 | ||
@@ -394,19 +398,19 @@ static int whiteheat_attach (struct usb_serial *serial) | |||
394 | usb_clear_halt(serial->dev, pipe); | 398 | usb_clear_halt(serial->dev, pipe); |
395 | ret = usb_bulk_msg (serial->dev, pipe, result, sizeof(*hw_info) + 1, &alen, COMMAND_TIMEOUT_MS); | 399 | ret = usb_bulk_msg (serial->dev, pipe, result, sizeof(*hw_info) + 1, &alen, COMMAND_TIMEOUT_MS); |
396 | if (ret) { | 400 | if (ret) { |
397 | err("%s: Couldn't get results [%d]", serial->type->name, ret); | 401 | err("%s: Couldn't get results [%d]", serial->type->description, ret); |
398 | goto no_firmware; | 402 | goto no_firmware; |
399 | } else if (alen != sizeof(result)) { | 403 | } else if (alen != sizeof(result)) { |
400 | err("%s: Get results incomplete [%d]", serial->type->name, alen); | 404 | err("%s: Get results incomplete [%d]", serial->type->description, alen); |
401 | goto no_firmware; | 405 | goto no_firmware; |
402 | } else if (result[0] != command[0]) { | 406 | } else if (result[0] != command[0]) { |
403 | err("%s: Command failed [%d]", serial->type->name, result[0]); | 407 | err("%s: Command failed [%d]", serial->type->description, result[0]); |
404 | goto no_firmware; | 408 | goto no_firmware; |
405 | } | 409 | } |
406 | 410 | ||
407 | hw_info = (struct whiteheat_hw_info *)&result[1]; | 411 | hw_info = (struct whiteheat_hw_info *)&result[1]; |
408 | 412 | ||
409 | info("%s: Driver %s: Firmware v%d.%02d", serial->type->name, | 413 | info("%s: Driver %s: Firmware v%d.%02d", serial->type->description, |
410 | DRIVER_VERSION, hw_info->sw_major_rev, hw_info->sw_minor_rev); | 414 | DRIVER_VERSION, hw_info->sw_major_rev, hw_info->sw_minor_rev); |
411 | 415 | ||
412 | for (i = 0; i < serial->num_ports; i++) { | 416 | for (i = 0; i < serial->num_ports; i++) { |
@@ -414,7 +418,7 @@ static int whiteheat_attach (struct usb_serial *serial) | |||
414 | 418 | ||
415 | info = (struct whiteheat_private *)kmalloc(sizeof(struct whiteheat_private), GFP_KERNEL); | 419 | info = (struct whiteheat_private *)kmalloc(sizeof(struct whiteheat_private), GFP_KERNEL); |
416 | if (info == NULL) { | 420 | if (info == NULL) { |
417 | err("%s: Out of memory for port structures\n", serial->type->name); | 421 | err("%s: Out of memory for port structures\n", serial->type->description); |
418 | goto no_private; | 422 | goto no_private; |
419 | } | 423 | } |
420 | 424 | ||
@@ -484,7 +488,7 @@ static int whiteheat_attach (struct usb_serial *serial) | |||
484 | 488 | ||
485 | command_info = (struct whiteheat_command_private *)kmalloc(sizeof(struct whiteheat_command_private), GFP_KERNEL); | 489 | command_info = (struct whiteheat_command_private *)kmalloc(sizeof(struct whiteheat_command_private), GFP_KERNEL); |
486 | if (command_info == NULL) { | 490 | if (command_info == NULL) { |
487 | err("%s: Out of memory for port structures\n", serial->type->name); | 491 | err("%s: Out of memory for port structures\n", serial->type->description); |
488 | goto no_command_private; | 492 | goto no_command_private; |
489 | } | 493 | } |
490 | 494 | ||
@@ -501,9 +505,9 @@ static int whiteheat_attach (struct usb_serial *serial) | |||
501 | 505 | ||
502 | no_firmware: | 506 | no_firmware: |
503 | /* Firmware likely not running */ | 507 | /* Firmware likely not running */ |
504 | err("%s: Unable to retrieve firmware version, try replugging\n", serial->type->name); | 508 | err("%s: Unable to retrieve firmware version, try replugging\n", serial->type->description); |
505 | err("%s: If the firmware is not running (status led not blinking)\n", serial->type->name); | 509 | err("%s: If the firmware is not running (status led not blinking)\n", serial->type->description); |
506 | err("%s: please contact support@connecttech.com\n", serial->type->name); | 510 | err("%s: please contact support@connecttech.com\n", serial->type->description); |
507 | return -ENODEV; | 511 | return -ENODEV; |
508 | 512 | ||
509 | no_command_private: | 513 | no_command_private: |
diff --git a/drivers/usb/storage/Kconfig b/drivers/usb/storage/Kconfig index bb9819cc8826..c41d64dbb0f0 100644 --- a/drivers/usb/storage/Kconfig +++ b/drivers/usb/storage/Kconfig | |||
@@ -2,7 +2,8 @@ | |||
2 | # USB Storage driver configuration | 2 | # USB Storage driver configuration |
3 | # | 3 | # |
4 | 4 | ||
5 | comment "NOTE: USB_STORAGE enables SCSI, and 'SCSI disk support' may also be needed; see USB_STORAGE Help for more information" | 5 | comment "NOTE: USB_STORAGE enables SCSI, and 'SCSI disk support'" |
6 | comment "may also be needed; see USB_STORAGE Help for more information" | ||
6 | depends on USB | 7 | depends on USB |
7 | 8 | ||
8 | config USB_STORAGE | 9 | config USB_STORAGE |
@@ -114,7 +115,7 @@ config USB_STORAGE_JUMPSHOT | |||
114 | 115 | ||
115 | config USB_STORAGE_ONETOUCH | 116 | config USB_STORAGE_ONETOUCH |
116 | bool "Support OneTouch Button on Maxtor Hard Drives (EXPERIMENTAL)" | 117 | bool "Support OneTouch Button on Maxtor Hard Drives (EXPERIMENTAL)" |
117 | depends on USB_STORAGE && INPUT_EVDEV && EXPERIMENTAL | 118 | depends on USB_STORAGE && INPUT_EVDEV && EXPERIMENTAL && !PM |
118 | help | 119 | help |
119 | Say Y here to include additional code to support the Maxtor OneTouch | 120 | Say Y here to include additional code to support the Maxtor OneTouch |
120 | USB hard drive's onetouch button. | 121 | USB hard drive's onetouch button. |
diff --git a/drivers/usb/storage/onetouch.c b/drivers/usb/storage/onetouch.c index 2c9402dc702b..89401a59f952 100644 --- a/drivers/usb/storage/onetouch.c +++ b/drivers/usb/storage/onetouch.c | |||
@@ -5,7 +5,7 @@ | |||
5 | * Copyright (c) 2005 Nick Sillik <n.sillik@temple.edu> | 5 | * Copyright (c) 2005 Nick Sillik <n.sillik@temple.edu> |
6 | * | 6 | * |
7 | * Initial work by: | 7 | * Initial work by: |
8 | * Copyright (c) 2003 Erik Thyren <erth7411@student.uu.se> | 8 | * Copyright (c) 2003 Erik Thyren <erth7411@student.uu.se> |
9 | * | 9 | * |
10 | * Based on usbmouse.c (Vojtech Pavlik) and xpad.c (Marko Friedemann) | 10 | * Based on usbmouse.c (Vojtech Pavlik) and xpad.c (Marko Friedemann) |
11 | * | 11 | * |
@@ -46,7 +46,7 @@ void onetouch_release_input(void *onetouch_); | |||
46 | struct usb_onetouch { | 46 | struct usb_onetouch { |
47 | char name[128]; | 47 | char name[128]; |
48 | char phys[64]; | 48 | char phys[64]; |
49 | struct input_dev dev; /* input device interface */ | 49 | struct input_dev *dev; /* input device interface */ |
50 | struct usb_device *udev; /* usb device */ | 50 | struct usb_device *udev; /* usb device */ |
51 | 51 | ||
52 | struct urb *irq; /* urb for interrupt in report */ | 52 | struct urb *irq; /* urb for interrupt in report */ |
@@ -58,7 +58,7 @@ static void usb_onetouch_irq(struct urb *urb, struct pt_regs *regs) | |||
58 | { | 58 | { |
59 | struct usb_onetouch *onetouch = urb->context; | 59 | struct usb_onetouch *onetouch = urb->context; |
60 | signed char *data = onetouch->data; | 60 | signed char *data = onetouch->data; |
61 | struct input_dev *dev = &onetouch->dev; | 61 | struct input_dev *dev = onetouch->dev; |
62 | int status; | 62 | int status; |
63 | 63 | ||
64 | switch (urb->status) { | 64 | switch (urb->status) { |
@@ -74,11 +74,9 @@ static void usb_onetouch_irq(struct urb *urb, struct pt_regs *regs) | |||
74 | } | 74 | } |
75 | 75 | ||
76 | input_regs(dev, regs); | 76 | input_regs(dev, regs); |
77 | 77 | input_report_key(dev, ONETOUCH_BUTTON, data[0] & 0x02); | |
78 | input_report_key(&onetouch->dev, ONETOUCH_BUTTON, | ||
79 | data[0] & 0x02); | ||
80 | |||
81 | input_sync(dev); | 78 | input_sync(dev); |
79 | |||
82 | resubmit: | 80 | resubmit: |
83 | status = usb_submit_urb (urb, SLAB_ATOMIC); | 81 | status = usb_submit_urb (urb, SLAB_ATOMIC); |
84 | if (status) | 82 | if (status) |
@@ -113,8 +111,8 @@ int onetouch_connect_input(struct us_data *ss) | |||
113 | struct usb_host_interface *interface; | 111 | struct usb_host_interface *interface; |
114 | struct usb_endpoint_descriptor *endpoint; | 112 | struct usb_endpoint_descriptor *endpoint; |
115 | struct usb_onetouch *onetouch; | 113 | struct usb_onetouch *onetouch; |
114 | struct input_dev *input_dev; | ||
116 | int pipe, maxp; | 115 | int pipe, maxp; |
117 | char path[64]; | ||
118 | 116 | ||
119 | interface = ss->pusb_intf->cur_altsetting; | 117 | interface = ss->pusb_intf->cur_altsetting; |
120 | 118 | ||
@@ -122,62 +120,62 @@ int onetouch_connect_input(struct us_data *ss) | |||
122 | return -ENODEV; | 120 | return -ENODEV; |
123 | 121 | ||
124 | endpoint = &interface->endpoint[2].desc; | 122 | endpoint = &interface->endpoint[2].desc; |
125 | if(!(endpoint->bEndpointAddress & USB_DIR_IN)) | 123 | if (!(endpoint->bEndpointAddress & USB_DIR_IN)) |
126 | return -ENODEV; | 124 | return -ENODEV; |
127 | if((endpoint->bmAttributes & USB_ENDPOINT_XFERTYPE_MASK) | 125 | if ((endpoint->bmAttributes & USB_ENDPOINT_XFERTYPE_MASK) |
128 | != USB_ENDPOINT_XFER_INT) | 126 | != USB_ENDPOINT_XFER_INT) |
129 | return -ENODEV; | 127 | return -ENODEV; |
130 | 128 | ||
131 | pipe = usb_rcvintpipe(udev, endpoint->bEndpointAddress); | 129 | pipe = usb_rcvintpipe(udev, endpoint->bEndpointAddress); |
132 | maxp = usb_maxpacket(udev, pipe, usb_pipeout(pipe)); | 130 | maxp = usb_maxpacket(udev, pipe, usb_pipeout(pipe)); |
133 | 131 | ||
134 | if (!(onetouch = kcalloc(1, sizeof(struct usb_onetouch), GFP_KERNEL))) | 132 | onetouch = kzalloc(sizeof(struct usb_onetouch), GFP_KERNEL); |
135 | return -ENOMEM; | 133 | input_dev = input_allocate_device(); |
134 | if (!onetouch || !input_dev) | ||
135 | goto fail1; | ||
136 | 136 | ||
137 | onetouch->data = usb_buffer_alloc(udev, ONETOUCH_PKT_LEN, | 137 | onetouch->data = usb_buffer_alloc(udev, ONETOUCH_PKT_LEN, |
138 | SLAB_ATOMIC, &onetouch->data_dma); | 138 | SLAB_ATOMIC, &onetouch->data_dma); |
139 | if (!onetouch->data){ | 139 | if (!onetouch->data) |
140 | kfree(onetouch); | 140 | goto fail1; |
141 | return -ENOMEM; | ||
142 | } | ||
143 | 141 | ||
144 | onetouch->irq = usb_alloc_urb(0, GFP_KERNEL); | 142 | onetouch->irq = usb_alloc_urb(0, GFP_KERNEL); |
145 | if (!onetouch->irq){ | 143 | if (!onetouch->irq) |
146 | kfree(onetouch); | 144 | goto fail2; |
147 | usb_buffer_free(udev, ONETOUCH_PKT_LEN, | ||
148 | onetouch->data, onetouch->data_dma); | ||
149 | return -ENODEV; | ||
150 | } | ||
151 | |||
152 | 145 | ||
153 | onetouch->udev = udev; | 146 | onetouch->udev = udev; |
147 | onetouch->dev = input_dev; | ||
154 | 148 | ||
155 | set_bit(EV_KEY, onetouch->dev.evbit); | 149 | if (udev->manufacturer) |
156 | set_bit(ONETOUCH_BUTTON, onetouch->dev.keybit); | 150 | strlcpy(onetouch->name, udev->manufacturer, |
157 | clear_bit(0, onetouch->dev.keybit); | 151 | sizeof(onetouch->name)); |
152 | if (udev->product) { | ||
153 | if (udev->manufacturer) | ||
154 | strlcat(onetouch->name, " ", sizeof(onetouch->name)); | ||
155 | strlcat(onetouch->name, udev->product, sizeof(onetouch->name)); | ||
156 | } | ||
158 | 157 | ||
159 | onetouch->dev.private = onetouch; | 158 | if (!strlen(onetouch->name)) |
160 | onetouch->dev.open = usb_onetouch_open; | 159 | snprintf(onetouch->name, sizeof(onetouch->name), |
161 | onetouch->dev.close = usb_onetouch_close; | 160 | "Maxtor Onetouch %04x:%04x", |
161 | le16_to_cpu(udev->descriptor.idVendor), | ||
162 | le16_to_cpu(udev->descriptor.idProduct)); | ||
162 | 163 | ||
163 | usb_make_path(udev, path, sizeof(path)); | 164 | usb_make_path(udev, onetouch->phys, sizeof(onetouch->phys)); |
164 | sprintf(onetouch->phys, "%s/input0", path); | 165 | strlcat(onetouch->phys, "/input0", sizeof(onetouch->phys)); |
165 | 166 | ||
166 | onetouch->dev.name = onetouch->name; | 167 | input_dev->name = onetouch->name; |
167 | onetouch->dev.phys = onetouch->phys; | 168 | input_dev->phys = onetouch->phys; |
169 | usb_to_input_id(udev, &input_dev->id); | ||
170 | input_dev->cdev.dev = &udev->dev; | ||
168 | 171 | ||
169 | usb_to_input_id(udev, &onetouch->dev.id); | 172 | set_bit(EV_KEY, input_dev->evbit); |
173 | set_bit(ONETOUCH_BUTTON, input_dev->keybit); | ||
174 | clear_bit(0, input_dev->keybit); | ||
170 | 175 | ||
171 | onetouch->dev.dev = &udev->dev; | 176 | input_dev->private = onetouch; |
172 | 177 | input_dev->open = usb_onetouch_open; | |
173 | if (udev->manufacturer) | 178 | input_dev->close = usb_onetouch_close; |
174 | strcat(onetouch->name, udev->manufacturer); | ||
175 | if (udev->product) | ||
176 | sprintf(onetouch->name, "%s %s", onetouch->name, | ||
177 | udev->product); | ||
178 | if (!strlen(onetouch->name)) | ||
179 | sprintf(onetouch->name, "Maxtor Onetouch %04x:%04x", | ||
180 | onetouch->dev.id.vendor, onetouch->dev.id.product); | ||
181 | 179 | ||
182 | usb_fill_int_urb(onetouch->irq, udev, pipe, onetouch->data, | 180 | usb_fill_int_urb(onetouch->irq, udev, pipe, onetouch->data, |
183 | (maxp > 8 ? 8 : maxp), | 181 | (maxp > 8 ? 8 : maxp), |
@@ -188,10 +186,15 @@ int onetouch_connect_input(struct us_data *ss) | |||
188 | ss->extra_destructor = onetouch_release_input; | 186 | ss->extra_destructor = onetouch_release_input; |
189 | ss->extra = onetouch; | 187 | ss->extra = onetouch; |
190 | 188 | ||
191 | input_register_device(&onetouch->dev); | 189 | input_register_device(onetouch->dev); |
192 | printk(KERN_INFO "usb-input: %s on %s\n", onetouch->dev.name, path); | ||
193 | 190 | ||
194 | return 0; | 191 | return 0; |
192 | |||
193 | fail2: usb_buffer_free(udev, ONETOUCH_PKT_LEN, | ||
194 | onetouch->data, onetouch->data_dma); | ||
195 | fail1: kfree(onetouch); | ||
196 | input_free_device(input_dev); | ||
197 | return -ENOMEM; | ||
195 | } | 198 | } |
196 | 199 | ||
197 | void onetouch_release_input(void *onetouch_) | 200 | void onetouch_release_input(void *onetouch_) |
@@ -200,11 +203,9 @@ void onetouch_release_input(void *onetouch_) | |||
200 | 203 | ||
201 | if (onetouch) { | 204 | if (onetouch) { |
202 | usb_kill_urb(onetouch->irq); | 205 | usb_kill_urb(onetouch->irq); |
203 | input_unregister_device(&onetouch->dev); | 206 | input_unregister_device(onetouch->dev); |
204 | usb_free_urb(onetouch->irq); | 207 | usb_free_urb(onetouch->irq); |
205 | usb_buffer_free(onetouch->udev, ONETOUCH_PKT_LEN, | 208 | usb_buffer_free(onetouch->udev, ONETOUCH_PKT_LEN, |
206 | onetouch->data, onetouch->data_dma); | 209 | onetouch->data, onetouch->data_dma); |
207 | printk(KERN_INFO "usb-input: deregistering %s\n", | ||
208 | onetouch->dev.name); | ||
209 | } | 210 | } |
210 | } | 211 | } |
diff --git a/drivers/usb/storage/shuttle_usbat.c b/drivers/usb/storage/shuttle_usbat.c index 356342c6e7a2..fea176d7e79a 100644 --- a/drivers/usb/storage/shuttle_usbat.c +++ b/drivers/usb/storage/shuttle_usbat.c | |||
@@ -1,4 +1,4 @@ | |||
1 | /* Driver for SCM Microsystems USB-ATAPI cable | 1 | /* Driver for SCM Microsystems (a.k.a. Shuttle) USB-ATAPI cable |
2 | * | 2 | * |
3 | * $Id: shuttle_usbat.c,v 1.17 2002/04/22 03:39:43 mdharm Exp $ | 3 | * $Id: shuttle_usbat.c,v 1.17 2002/04/22 03:39:43 mdharm Exp $ |
4 | * | 4 | * |
@@ -67,10 +67,10 @@ static int usbat_flash_transport(struct scsi_cmnd * srb, struct us_data *us); | |||
67 | static int usbat_hp8200e_transport(struct scsi_cmnd *srb, struct us_data *us); | 67 | static int usbat_hp8200e_transport(struct scsi_cmnd *srb, struct us_data *us); |
68 | 68 | ||
69 | /* | 69 | /* |
70 | * Convenience function to produce an ATAPI read/write sectors command | 70 | * Convenience function to produce an ATA read/write sectors command |
71 | * Use cmd=0x20 for read, cmd=0x30 for write | 71 | * Use cmd=0x20 for read, cmd=0x30 for write |
72 | */ | 72 | */ |
73 | static void usbat_pack_atapi_sector_cmd(unsigned char *buf, | 73 | static void usbat_pack_ata_sector_cmd(unsigned char *buf, |
74 | unsigned char thistime, | 74 | unsigned char thistime, |
75 | u32 sector, unsigned char cmd) | 75 | u32 sector, unsigned char cmd) |
76 | { | 76 | { |
@@ -196,10 +196,12 @@ static int usbat_check_status(struct us_data *us) | |||
196 | if (rc != USB_STOR_XFER_GOOD) | 196 | if (rc != USB_STOR_XFER_GOOD) |
197 | return USB_STOR_TRANSPORT_FAILED; | 197 | return USB_STOR_TRANSPORT_FAILED; |
198 | 198 | ||
199 | if (*reply & 0x01 && *reply != 0x51) // error/check condition (0x51 is ok) | 199 | /* error/check condition (0x51 is ok) */ |
200 | if (*reply & 0x01 && *reply != 0x51) | ||
200 | return USB_STOR_TRANSPORT_FAILED; | 201 | return USB_STOR_TRANSPORT_FAILED; |
201 | 202 | ||
202 | if (*reply & 0x20) // device fault | 203 | /* device fault */ |
204 | if (*reply & 0x20) | ||
203 | return USB_STOR_TRANSPORT_FAILED; | 205 | return USB_STOR_TRANSPORT_FAILED; |
204 | 206 | ||
205 | return USB_STOR_TRANSPORT_GOOD; | 207 | return USB_STOR_TRANSPORT_GOOD; |
@@ -222,29 +224,39 @@ static int usbat_set_shuttle_features(struct us_data *us, | |||
222 | command[0] = 0x40; | 224 | command[0] = 0x40; |
223 | command[1] = USBAT_CMD_SET_FEAT; | 225 | command[1] = USBAT_CMD_SET_FEAT; |
224 | 226 | ||
225 | // The only bit relevant to ATA access is bit 6 | 227 | /* |
226 | // which defines 8 bit data access (set) or 16 bit (unset) | 228 | * The only bit relevant to ATA access is bit 6 |
229 | * which defines 8 bit data access (set) or 16 bit (unset) | ||
230 | */ | ||
227 | command[2] = epp_control; | 231 | command[2] = epp_control; |
228 | 232 | ||
229 | // If FCQ is set in the qualifier (defined in R/W cmd), then bits U0, U1, | 233 | /* |
230 | // ET1 and ET2 define an external event to be checked for on event of a | 234 | * If FCQ is set in the qualifier (defined in R/W cmd), then bits U0, U1, |
231 | // _read_blocks or _write_blocks operation. The read/write will not take | 235 | * ET1 and ET2 define an external event to be checked for on event of a |
232 | // place unless the defined trigger signal is active. | 236 | * _read_blocks or _write_blocks operation. The read/write will not take |
237 | * place unless the defined trigger signal is active. | ||
238 | */ | ||
233 | command[3] = external_trigger; | 239 | command[3] = external_trigger; |
234 | 240 | ||
235 | // The resultant byte of the mask operation (see mask_byte) is compared for | 241 | /* |
236 | // equivalence with this test pattern. If equal, the read/write will take | 242 | * The resultant byte of the mask operation (see mask_byte) is compared for |
237 | // place. | 243 | * equivalence with this test pattern. If equal, the read/write will take |
244 | * place. | ||
245 | */ | ||
238 | command[4] = test_pattern; | 246 | command[4] = test_pattern; |
239 | 247 | ||
240 | // This value is logically ANDed with the status register field specified | 248 | /* |
241 | // in the read/write command. | 249 | * This value is logically ANDed with the status register field specified |
250 | * in the read/write command. | ||
251 | */ | ||
242 | command[5] = mask_byte; | 252 | command[5] = mask_byte; |
243 | 253 | ||
244 | // If ALQ is set in the qualifier, this field contains the address of the | 254 | /* |
245 | // registers where the byte count should be read for transferring the data. | 255 | * If ALQ is set in the qualifier, this field contains the address of the |
246 | // If ALQ is not set, then this field contains the number of bytes to be | 256 | * registers where the byte count should be read for transferring the data. |
247 | // transferred. | 257 | * If ALQ is not set, then this field contains the number of bytes to be |
258 | * transferred. | ||
259 | */ | ||
248 | command[6] = subcountL; | 260 | command[6] = subcountL; |
249 | command[7] = subcountH; | 261 | command[7] = subcountH; |
250 | 262 | ||
@@ -273,26 +285,26 @@ static int usbat_wait_not_busy(struct us_data *us, int minutes) | |||
273 | 285 | ||
274 | if (result!=USB_STOR_XFER_GOOD) | 286 | if (result!=USB_STOR_XFER_GOOD) |
275 | return USB_STOR_TRANSPORT_ERROR; | 287 | return USB_STOR_TRANSPORT_ERROR; |
276 | if (*status & 0x01) { // check condition | 288 | if (*status & 0x01) { /* check condition */ |
277 | result = usbat_read(us, USBAT_ATA, 0x10, status); | 289 | result = usbat_read(us, USBAT_ATA, 0x10, status); |
278 | return USB_STOR_TRANSPORT_FAILED; | 290 | return USB_STOR_TRANSPORT_FAILED; |
279 | } | 291 | } |
280 | if (*status & 0x20) // device fault | 292 | if (*status & 0x20) /* device fault */ |
281 | return USB_STOR_TRANSPORT_FAILED; | 293 | return USB_STOR_TRANSPORT_FAILED; |
282 | 294 | ||
283 | if ((*status & 0x80)==0x00) { // not busy | 295 | if ((*status & 0x80)==0x00) { /* not busy */ |
284 | US_DEBUGP("Waited not busy for %d steps\n", i); | 296 | US_DEBUGP("Waited not busy for %d steps\n", i); |
285 | return USB_STOR_TRANSPORT_GOOD; | 297 | return USB_STOR_TRANSPORT_GOOD; |
286 | } | 298 | } |
287 | 299 | ||
288 | if (i<500) | 300 | if (i<500) |
289 | msleep(10); // 5 seconds | 301 | msleep(10); /* 5 seconds */ |
290 | else if (i<700) | 302 | else if (i<700) |
291 | msleep(50); // 10 seconds | 303 | msleep(50); /* 10 seconds */ |
292 | else if (i<1200) | 304 | else if (i<1200) |
293 | msleep(100); // 50 seconds | 305 | msleep(100); /* 50 seconds */ |
294 | else | 306 | else |
295 | msleep(1000); // X minutes | 307 | msleep(1000); /* X minutes */ |
296 | } | 308 | } |
297 | 309 | ||
298 | US_DEBUGP("Waited not busy for %d minutes, timing out.\n", | 310 | US_DEBUGP("Waited not busy for %d minutes, timing out.\n", |
@@ -412,9 +424,12 @@ static int usbat_hp8200e_rw_block_test(struct us_data *us, | |||
412 | 424 | ||
413 | if (i==0) { | 425 | if (i==0) { |
414 | cmdlen = 16; | 426 | cmdlen = 16; |
415 | // Write to multiple registers | 427 | /* |
416 | // Not really sure the 0x07, 0x17, 0xfc, 0xe7 is necessary here, | 428 | * Write to multiple registers |
417 | // but that's what came out of the trace every single time. | 429 | * Not really sure the 0x07, 0x17, 0xfc, 0xe7 is |
430 | * necessary here, but that's what came out of the | ||
431 | * trace every single time. | ||
432 | */ | ||
418 | command[0] = 0x40; | 433 | command[0] = 0x40; |
419 | command[1] = access | USBAT_CMD_WRITE_REGS; | 434 | command[1] = access | USBAT_CMD_WRITE_REGS; |
420 | command[2] = 0x07; | 435 | command[2] = 0x07; |
@@ -426,7 +441,7 @@ static int usbat_hp8200e_rw_block_test(struct us_data *us, | |||
426 | } else | 441 | } else |
427 | cmdlen = 8; | 442 | cmdlen = 8; |
428 | 443 | ||
429 | // Conditionally read or write blocks | 444 | /* Conditionally read or write blocks */ |
430 | command[cmdlen-8] = (direction==DMA_TO_DEVICE ? 0x40 : 0xC0); | 445 | command[cmdlen-8] = (direction==DMA_TO_DEVICE ? 0x40 : 0xC0); |
431 | command[cmdlen-7] = access | | 446 | command[cmdlen-7] = access | |
432 | (direction==DMA_TO_DEVICE ? | 447 | (direction==DMA_TO_DEVICE ? |
@@ -456,11 +471,6 @@ static int usbat_hp8200e_rw_block_test(struct us_data *us, | |||
456 | 471 | ||
457 | } | 472 | } |
458 | 473 | ||
459 | |||
460 | //US_DEBUGP("Transfer %s %d bytes, sg buffers %d\n", | ||
461 | // direction == DMA_TO_DEVICE ? "out" : "in", | ||
462 | // len, use_sg); | ||
463 | |||
464 | result = usb_stor_bulk_transfer_sg(us, | 474 | result = usb_stor_bulk_transfer_sg(us, |
465 | pipe, content, len, use_sg, NULL); | 475 | pipe, content, len, use_sg, NULL); |
466 | 476 | ||
@@ -508,9 +518,9 @@ static int usbat_hp8200e_rw_block_test(struct us_data *us, | |||
508 | 518 | ||
509 | if (result!=USB_STOR_XFER_GOOD) | 519 | if (result!=USB_STOR_XFER_GOOD) |
510 | return USB_STOR_TRANSPORT_ERROR; | 520 | return USB_STOR_TRANSPORT_ERROR; |
511 | if (*status & 0x01) // check condition | 521 | if (*status & 0x01) /* check condition */ |
512 | return USB_STOR_TRANSPORT_FAILED; | 522 | return USB_STOR_TRANSPORT_FAILED; |
513 | if (*status & 0x20) // device fault | 523 | if (*status & 0x20) /* device fault */ |
514 | return USB_STOR_TRANSPORT_FAILED; | 524 | return USB_STOR_TRANSPORT_FAILED; |
515 | 525 | ||
516 | US_DEBUGP("Redoing %s\n", | 526 | US_DEBUGP("Redoing %s\n", |
@@ -547,32 +557,32 @@ static int usbat_multiple_write(struct us_data *us, | |||
547 | 557 | ||
548 | BUG_ON(num_registers > US_IOBUF_SIZE/2); | 558 | BUG_ON(num_registers > US_IOBUF_SIZE/2); |
549 | 559 | ||
550 | // Write to multiple registers, ATA access | 560 | /* Write to multiple registers, ATA access */ |
551 | command[0] = 0x40; | 561 | command[0] = 0x40; |
552 | command[1] = USBAT_ATA | USBAT_CMD_WRITE_REGS; | 562 | command[1] = USBAT_ATA | USBAT_CMD_WRITE_REGS; |
553 | 563 | ||
554 | // No relevance | 564 | /* No relevance */ |
555 | command[2] = 0; | 565 | command[2] = 0; |
556 | command[3] = 0; | 566 | command[3] = 0; |
557 | command[4] = 0; | 567 | command[4] = 0; |
558 | command[5] = 0; | 568 | command[5] = 0; |
559 | 569 | ||
560 | // Number of bytes to be transferred (incl. addresses and data) | 570 | /* Number of bytes to be transferred (incl. addresses and data) */ |
561 | command[6] = LSB_of(num_registers*2); | 571 | command[6] = LSB_of(num_registers*2); |
562 | command[7] = MSB_of(num_registers*2); | 572 | command[7] = MSB_of(num_registers*2); |
563 | 573 | ||
564 | // The setup command | 574 | /* The setup command */ |
565 | result = usbat_execute_command(us, command, 8); | 575 | result = usbat_execute_command(us, command, 8); |
566 | if (result != USB_STOR_XFER_GOOD) | 576 | if (result != USB_STOR_XFER_GOOD) |
567 | return USB_STOR_TRANSPORT_ERROR; | 577 | return USB_STOR_TRANSPORT_ERROR; |
568 | 578 | ||
569 | // Create the reg/data, reg/data sequence | 579 | /* Create the reg/data, reg/data sequence */ |
570 | for (i=0; i<num_registers; i++) { | 580 | for (i=0; i<num_registers; i++) { |
571 | data[i<<1] = registers[i]; | 581 | data[i<<1] = registers[i]; |
572 | data[1+(i<<1)] = data_out[i]; | 582 | data[1+(i<<1)] = data_out[i]; |
573 | } | 583 | } |
574 | 584 | ||
575 | // Send the data | 585 | /* Send the data */ |
576 | result = usbat_bulk_write(us, data, num_registers*2); | 586 | result = usbat_bulk_write(us, data, num_registers*2); |
577 | if (result != USB_STOR_XFER_GOOD) | 587 | if (result != USB_STOR_XFER_GOOD) |
578 | return USB_STOR_TRANSPORT_ERROR; | 588 | return USB_STOR_TRANSPORT_ERROR; |
@@ -606,17 +616,17 @@ static int usbat_read_blocks(struct us_data *us, | |||
606 | command[1] = USBAT_ATA | USBAT_CMD_COND_READ_BLOCK; | 616 | command[1] = USBAT_ATA | USBAT_CMD_COND_READ_BLOCK; |
607 | command[2] = USBAT_ATA_DATA; | 617 | command[2] = USBAT_ATA_DATA; |
608 | command[3] = USBAT_ATA_STATUS; | 618 | command[3] = USBAT_ATA_STATUS; |
609 | command[4] = 0xFD; // Timeout (ms); | 619 | command[4] = 0xFD; /* Timeout (ms); */ |
610 | command[5] = USBAT_QUAL_FCQ; | 620 | command[5] = USBAT_QUAL_FCQ; |
611 | command[6] = LSB_of(len); | 621 | command[6] = LSB_of(len); |
612 | command[7] = MSB_of(len); | 622 | command[7] = MSB_of(len); |
613 | 623 | ||
614 | // Multiple block read setup command | 624 | /* Multiple block read setup command */ |
615 | result = usbat_execute_command(us, command, 8); | 625 | result = usbat_execute_command(us, command, 8); |
616 | if (result != USB_STOR_XFER_GOOD) | 626 | if (result != USB_STOR_XFER_GOOD) |
617 | return USB_STOR_TRANSPORT_FAILED; | 627 | return USB_STOR_TRANSPORT_FAILED; |
618 | 628 | ||
619 | // Read the blocks we just asked for | 629 | /* Read the blocks we just asked for */ |
620 | result = usbat_bulk_read(us, buffer, len); | 630 | result = usbat_bulk_read(us, buffer, len); |
621 | if (result != USB_STOR_XFER_GOOD) | 631 | if (result != USB_STOR_XFER_GOOD) |
622 | return USB_STOR_TRANSPORT_FAILED; | 632 | return USB_STOR_TRANSPORT_FAILED; |
@@ -647,17 +657,17 @@ static int usbat_write_blocks(struct us_data *us, | |||
647 | command[1] = USBAT_ATA | USBAT_CMD_COND_WRITE_BLOCK; | 657 | command[1] = USBAT_ATA | USBAT_CMD_COND_WRITE_BLOCK; |
648 | command[2] = USBAT_ATA_DATA; | 658 | command[2] = USBAT_ATA_DATA; |
649 | command[3] = USBAT_ATA_STATUS; | 659 | command[3] = USBAT_ATA_STATUS; |
650 | command[4] = 0xFD; // Timeout (ms) | 660 | command[4] = 0xFD; /* Timeout (ms) */ |
651 | command[5] = USBAT_QUAL_FCQ; | 661 | command[5] = USBAT_QUAL_FCQ; |
652 | command[6] = LSB_of(len); | 662 | command[6] = LSB_of(len); |
653 | command[7] = MSB_of(len); | 663 | command[7] = MSB_of(len); |
654 | 664 | ||
655 | // Multiple block write setup command | 665 | /* Multiple block write setup command */ |
656 | result = usbat_execute_command(us, command, 8); | 666 | result = usbat_execute_command(us, command, 8); |
657 | if (result != USB_STOR_XFER_GOOD) | 667 | if (result != USB_STOR_XFER_GOOD) |
658 | return USB_STOR_TRANSPORT_FAILED; | 668 | return USB_STOR_TRANSPORT_FAILED; |
659 | 669 | ||
660 | // Write the data | 670 | /* Write the data */ |
661 | result = usbat_bulk_write(us, buffer, len); | 671 | result = usbat_bulk_write(us, buffer, len); |
662 | if (result != USB_STOR_XFER_GOOD) | 672 | if (result != USB_STOR_XFER_GOOD) |
663 | return USB_STOR_TRANSPORT_FAILED; | 673 | return USB_STOR_TRANSPORT_FAILED; |
@@ -711,16 +721,20 @@ static int usbat_device_reset(struct us_data *us) | |||
711 | { | 721 | { |
712 | int rc; | 722 | int rc; |
713 | 723 | ||
714 | // Reset peripheral, enable peripheral control signals | 724 | /* |
715 | // (bring reset signal up) | 725 | * Reset peripheral, enable peripheral control signals |
726 | * (bring reset signal up) | ||
727 | */ | ||
716 | rc = usbat_write_user_io(us, | 728 | rc = usbat_write_user_io(us, |
717 | USBAT_UIO_DRVRST | USBAT_UIO_OE1 | USBAT_UIO_OE0, | 729 | USBAT_UIO_DRVRST | USBAT_UIO_OE1 | USBAT_UIO_OE0, |
718 | USBAT_UIO_EPAD | USBAT_UIO_1); | 730 | USBAT_UIO_EPAD | USBAT_UIO_1); |
719 | if (rc != USB_STOR_XFER_GOOD) | 731 | if (rc != USB_STOR_XFER_GOOD) |
720 | return USB_STOR_TRANSPORT_ERROR; | 732 | return USB_STOR_TRANSPORT_ERROR; |
721 | 733 | ||
722 | // Enable peripheral control signals | 734 | /* |
723 | // (bring reset signal down) | 735 | * Enable peripheral control signals |
736 | * (bring reset signal down) | ||
737 | */ | ||
724 | rc = usbat_write_user_io(us, | 738 | rc = usbat_write_user_io(us, |
725 | USBAT_UIO_OE1 | USBAT_UIO_OE0, | 739 | USBAT_UIO_OE1 | USBAT_UIO_OE0, |
726 | USBAT_UIO_EPAD | USBAT_UIO_1); | 740 | USBAT_UIO_EPAD | USBAT_UIO_1); |
@@ -737,7 +751,7 @@ static int usbat_device_enable_cdt(struct us_data *us) | |||
737 | { | 751 | { |
738 | int rc; | 752 | int rc; |
739 | 753 | ||
740 | // Enable peripheral control signals and card detect | 754 | /* Enable peripheral control signals and card detect */ |
741 | rc = usbat_write_user_io(us, | 755 | rc = usbat_write_user_io(us, |
742 | USBAT_UIO_ACKD | USBAT_UIO_OE1 | USBAT_UIO_OE0, | 756 | USBAT_UIO_ACKD | USBAT_UIO_OE1 | USBAT_UIO_OE0, |
743 | USBAT_UIO_EPAD | USBAT_UIO_1); | 757 | USBAT_UIO_EPAD | USBAT_UIO_1); |
@@ -786,7 +800,7 @@ static int usbat_flash_check_media(struct us_data *us, | |||
786 | if (rc != USB_STOR_XFER_GOOD) | 800 | if (rc != USB_STOR_XFER_GOOD) |
787 | return USB_STOR_TRANSPORT_ERROR; | 801 | return USB_STOR_TRANSPORT_ERROR; |
788 | 802 | ||
789 | // Check for media existence | 803 | /* Check for media existence */ |
790 | rc = usbat_flash_check_media_present(uio); | 804 | rc = usbat_flash_check_media_present(uio); |
791 | if (rc == USBAT_FLASH_MEDIA_NONE) { | 805 | if (rc == USBAT_FLASH_MEDIA_NONE) { |
792 | info->sense_key = 0x02; | 806 | info->sense_key = 0x02; |
@@ -795,11 +809,11 @@ static int usbat_flash_check_media(struct us_data *us, | |||
795 | return USB_STOR_TRANSPORT_FAILED; | 809 | return USB_STOR_TRANSPORT_FAILED; |
796 | } | 810 | } |
797 | 811 | ||
798 | // Check for media change | 812 | /* Check for media change */ |
799 | rc = usbat_flash_check_media_changed(uio); | 813 | rc = usbat_flash_check_media_changed(uio); |
800 | if (rc == USBAT_FLASH_MEDIA_CHANGED) { | 814 | if (rc == USBAT_FLASH_MEDIA_CHANGED) { |
801 | 815 | ||
802 | // Reset and re-enable card detect | 816 | /* Reset and re-enable card detect */ |
803 | rc = usbat_device_reset(us); | 817 | rc = usbat_device_reset(us); |
804 | if (rc != USB_STOR_TRANSPORT_GOOD) | 818 | if (rc != USB_STOR_TRANSPORT_GOOD) |
805 | return rc; | 819 | return rc; |
@@ -839,7 +853,7 @@ static int usbat_identify_device(struct us_data *us, | |||
839 | rc = usbat_device_reset(us); | 853 | rc = usbat_device_reset(us); |
840 | if (rc != USB_STOR_TRANSPORT_GOOD) | 854 | if (rc != USB_STOR_TRANSPORT_GOOD) |
841 | return rc; | 855 | return rc; |
842 | msleep(25); | 856 | msleep(500); |
843 | 857 | ||
844 | /* | 858 | /* |
845 | * In attempt to distinguish between HP CDRW's and Flash readers, we now | 859 | * In attempt to distinguish between HP CDRW's and Flash readers, we now |
@@ -855,15 +869,15 @@ static int usbat_identify_device(struct us_data *us, | |||
855 | if (rc != USB_STOR_XFER_GOOD) | 869 | if (rc != USB_STOR_XFER_GOOD) |
856 | return USB_STOR_TRANSPORT_ERROR; | 870 | return USB_STOR_TRANSPORT_ERROR; |
857 | 871 | ||
858 | // Check for error bit | 872 | /* Check for error bit, or if the command 'fell through' */ |
859 | if (status & 0x01) { | 873 | if (status == 0xA1 || !(status & 0x01)) { |
860 | // Device is a CompactFlash reader/writer | 874 | /* Device is HP 8200 */ |
861 | US_DEBUGP("usbat_identify_device: Detected Flash reader/writer\n"); | ||
862 | info->devicetype = USBAT_DEV_FLASH; | ||
863 | } else { | ||
864 | // Device is HP 8200 | ||
865 | US_DEBUGP("usbat_identify_device: Detected HP8200 CDRW\n"); | 875 | US_DEBUGP("usbat_identify_device: Detected HP8200 CDRW\n"); |
866 | info->devicetype = USBAT_DEV_HP8200; | 876 | info->devicetype = USBAT_DEV_HP8200; |
877 | } else { | ||
878 | /* Device is a CompactFlash reader/writer */ | ||
879 | US_DEBUGP("usbat_identify_device: Detected Flash reader/writer\n"); | ||
880 | info->devicetype = USBAT_DEV_FLASH; | ||
867 | } | 881 | } |
868 | 882 | ||
869 | return USB_STOR_TRANSPORT_GOOD; | 883 | return USB_STOR_TRANSPORT_GOOD; |
@@ -916,7 +930,7 @@ static int usbat_flash_get_sector_count(struct us_data *us, | |||
916 | if (!reply) | 930 | if (!reply) |
917 | return USB_STOR_TRANSPORT_ERROR; | 931 | return USB_STOR_TRANSPORT_ERROR; |
918 | 932 | ||
919 | // ATAPI command : IDENTIFY DEVICE | 933 | /* ATA command : IDENTIFY DEVICE */ |
920 | rc = usbat_multiple_write(us, registers, command, 3); | 934 | rc = usbat_multiple_write(us, registers, command, 3); |
921 | if (rc != USB_STOR_XFER_GOOD) { | 935 | if (rc != USB_STOR_XFER_GOOD) { |
922 | US_DEBUGP("usbat_flash_get_sector_count: Gah! identify_device failed\n"); | 936 | US_DEBUGP("usbat_flash_get_sector_count: Gah! identify_device failed\n"); |
@@ -924,7 +938,7 @@ static int usbat_flash_get_sector_count(struct us_data *us, | |||
924 | goto leave; | 938 | goto leave; |
925 | } | 939 | } |
926 | 940 | ||
927 | // Read device status | 941 | /* Read device status */ |
928 | if (usbat_get_status(us, &status) != USB_STOR_XFER_GOOD) { | 942 | if (usbat_get_status(us, &status) != USB_STOR_XFER_GOOD) { |
929 | rc = USB_STOR_TRANSPORT_ERROR; | 943 | rc = USB_STOR_TRANSPORT_ERROR; |
930 | goto leave; | 944 | goto leave; |
@@ -932,7 +946,7 @@ static int usbat_flash_get_sector_count(struct us_data *us, | |||
932 | 946 | ||
933 | msleep(100); | 947 | msleep(100); |
934 | 948 | ||
935 | // Read the device identification data | 949 | /* Read the device identification data */ |
936 | rc = usbat_read_block(us, reply, 512); | 950 | rc = usbat_read_block(us, reply, 512); |
937 | if (rc != USB_STOR_TRANSPORT_GOOD) | 951 | if (rc != USB_STOR_TRANSPORT_GOOD) |
938 | goto leave; | 952 | goto leave; |
@@ -977,19 +991,23 @@ static int usbat_flash_read_data(struct us_data *us, | |||
977 | if (result != USB_STOR_TRANSPORT_GOOD) | 991 | if (result != USB_STOR_TRANSPORT_GOOD) |
978 | return result; | 992 | return result; |
979 | 993 | ||
980 | // we're working in LBA mode. according to the ATA spec, | 994 | /* |
981 | // we can support up to 28-bit addressing. I don't know if Jumpshot | 995 | * we're working in LBA mode. according to the ATA spec, |
982 | // supports beyond 24-bit addressing. It's kind of hard to test | 996 | * we can support up to 28-bit addressing. I don't know if Jumpshot |
983 | // since it requires > 8GB CF card. | 997 | * supports beyond 24-bit addressing. It's kind of hard to test |
998 | * since it requires > 8GB CF card. | ||
999 | */ | ||
984 | 1000 | ||
985 | if (sector > 0x0FFFFFFF) | 1001 | if (sector > 0x0FFFFFFF) |
986 | return USB_STOR_TRANSPORT_ERROR; | 1002 | return USB_STOR_TRANSPORT_ERROR; |
987 | 1003 | ||
988 | totallen = sectors * info->ssize; | 1004 | totallen = sectors * info->ssize; |
989 | 1005 | ||
990 | // Since we don't read more than 64 KB at a time, we have to create | 1006 | /* |
991 | // a bounce buffer and move the data a piece at a time between the | 1007 | * Since we don't read more than 64 KB at a time, we have to create |
992 | // bounce buffer and the actual transfer buffer. | 1008 | * a bounce buffer and move the data a piece at a time between the |
1009 | * bounce buffer and the actual transfer buffer. | ||
1010 | */ | ||
993 | 1011 | ||
994 | alloclen = min(totallen, 65536u); | 1012 | alloclen = min(totallen, 65536u); |
995 | buffer = kmalloc(alloclen, GFP_NOIO); | 1013 | buffer = kmalloc(alloclen, GFP_NOIO); |
@@ -997,27 +1015,29 @@ static int usbat_flash_read_data(struct us_data *us, | |||
997 | return USB_STOR_TRANSPORT_ERROR; | 1015 | return USB_STOR_TRANSPORT_ERROR; |
998 | 1016 | ||
999 | do { | 1017 | do { |
1000 | // loop, never allocate or transfer more than 64k at once | 1018 | /* |
1001 | // (min(128k, 255*info->ssize) is the real limit) | 1019 | * loop, never allocate or transfer more than 64k at once |
1020 | * (min(128k, 255*info->ssize) is the real limit) | ||
1021 | */ | ||
1002 | len = min(totallen, alloclen); | 1022 | len = min(totallen, alloclen); |
1003 | thistime = (len / info->ssize) & 0xff; | 1023 | thistime = (len / info->ssize) & 0xff; |
1004 | 1024 | ||
1005 | // ATAPI command 0x20 (READ SECTORS) | 1025 | /* ATA command 0x20 (READ SECTORS) */ |
1006 | usbat_pack_atapi_sector_cmd(command, thistime, sector, 0x20); | 1026 | usbat_pack_ata_sector_cmd(command, thistime, sector, 0x20); |
1007 | 1027 | ||
1008 | // Write/execute ATAPI read command | 1028 | /* Write/execute ATA read command */ |
1009 | result = usbat_multiple_write(us, registers, command, 7); | 1029 | result = usbat_multiple_write(us, registers, command, 7); |
1010 | if (result != USB_STOR_TRANSPORT_GOOD) | 1030 | if (result != USB_STOR_TRANSPORT_GOOD) |
1011 | goto leave; | 1031 | goto leave; |
1012 | 1032 | ||
1013 | // Read the data we just requested | 1033 | /* Read the data we just requested */ |
1014 | result = usbat_read_blocks(us, buffer, len); | 1034 | result = usbat_read_blocks(us, buffer, len); |
1015 | if (result != USB_STOR_TRANSPORT_GOOD) | 1035 | if (result != USB_STOR_TRANSPORT_GOOD) |
1016 | goto leave; | 1036 | goto leave; |
1017 | 1037 | ||
1018 | US_DEBUGP("usbat_flash_read_data: %d bytes\n", len); | 1038 | US_DEBUGP("usbat_flash_read_data: %d bytes\n", len); |
1019 | 1039 | ||
1020 | // Store the data in the transfer buffer | 1040 | /* Store the data in the transfer buffer */ |
1021 | usb_stor_access_xfer_buf(buffer, len, us->srb, | 1041 | usb_stor_access_xfer_buf(buffer, len, us->srb, |
1022 | &sg_idx, &sg_offset, TO_XFER_BUF); | 1042 | &sg_idx, &sg_offset, TO_XFER_BUF); |
1023 | 1043 | ||
@@ -1061,19 +1081,23 @@ static int usbat_flash_write_data(struct us_data *us, | |||
1061 | if (result != USB_STOR_TRANSPORT_GOOD) | 1081 | if (result != USB_STOR_TRANSPORT_GOOD) |
1062 | return result; | 1082 | return result; |
1063 | 1083 | ||
1064 | // we're working in LBA mode. according to the ATA spec, | 1084 | /* |
1065 | // we can support up to 28-bit addressing. I don't know if Jumpshot | 1085 | * we're working in LBA mode. according to the ATA spec, |
1066 | // supports beyond 24-bit addressing. It's kind of hard to test | 1086 | * we can support up to 28-bit addressing. I don't know if the device |
1067 | // since it requires > 8GB CF card. | 1087 | * supports beyond 24-bit addressing. It's kind of hard to test |
1088 | * since it requires > 8GB media. | ||
1089 | */ | ||
1068 | 1090 | ||
1069 | if (sector > 0x0FFFFFFF) | 1091 | if (sector > 0x0FFFFFFF) |
1070 | return USB_STOR_TRANSPORT_ERROR; | 1092 | return USB_STOR_TRANSPORT_ERROR; |
1071 | 1093 | ||
1072 | totallen = sectors * info->ssize; | 1094 | totallen = sectors * info->ssize; |
1073 | 1095 | ||
1074 | // Since we don't write more than 64 KB at a time, we have to create | 1096 | /* |
1075 | // a bounce buffer and move the data a piece at a time between the | 1097 | * Since we don't write more than 64 KB at a time, we have to create |
1076 | // bounce buffer and the actual transfer buffer. | 1098 | * a bounce buffer and move the data a piece at a time between the |
1099 | * bounce buffer and the actual transfer buffer. | ||
1100 | */ | ||
1077 | 1101 | ||
1078 | alloclen = min(totallen, 65536u); | 1102 | alloclen = min(totallen, 65536u); |
1079 | buffer = kmalloc(alloclen, GFP_NOIO); | 1103 | buffer = kmalloc(alloclen, GFP_NOIO); |
@@ -1081,24 +1105,26 @@ static int usbat_flash_write_data(struct us_data *us, | |||
1081 | return USB_STOR_TRANSPORT_ERROR; | 1105 | return USB_STOR_TRANSPORT_ERROR; |
1082 | 1106 | ||
1083 | do { | 1107 | do { |
1084 | // loop, never allocate or transfer more than 64k at once | 1108 | /* |
1085 | // (min(128k, 255*info->ssize) is the real limit) | 1109 | * loop, never allocate or transfer more than 64k at once |
1110 | * (min(128k, 255*info->ssize) is the real limit) | ||
1111 | */ | ||
1086 | len = min(totallen, alloclen); | 1112 | len = min(totallen, alloclen); |
1087 | thistime = (len / info->ssize) & 0xff; | 1113 | thistime = (len / info->ssize) & 0xff; |
1088 | 1114 | ||
1089 | // Get the data from the transfer buffer | 1115 | /* Get the data from the transfer buffer */ |
1090 | usb_stor_access_xfer_buf(buffer, len, us->srb, | 1116 | usb_stor_access_xfer_buf(buffer, len, us->srb, |
1091 | &sg_idx, &sg_offset, FROM_XFER_BUF); | 1117 | &sg_idx, &sg_offset, FROM_XFER_BUF); |
1092 | 1118 | ||
1093 | // ATAPI command 0x30 (WRITE SECTORS) | 1119 | /* ATA command 0x30 (WRITE SECTORS) */ |
1094 | usbat_pack_atapi_sector_cmd(command, thistime, sector, 0x30); | 1120 | usbat_pack_ata_sector_cmd(command, thistime, sector, 0x30); |
1095 | 1121 | ||
1096 | // Write/execute ATAPI write command | 1122 | /* Write/execute ATA write command */ |
1097 | result = usbat_multiple_write(us, registers, command, 7); | 1123 | result = usbat_multiple_write(us, registers, command, 7); |
1098 | if (result != USB_STOR_TRANSPORT_GOOD) | 1124 | if (result != USB_STOR_TRANSPORT_GOOD) |
1099 | goto leave; | 1125 | goto leave; |
1100 | 1126 | ||
1101 | // Write the data | 1127 | /* Write the data */ |
1102 | result = usbat_write_blocks(us, buffer, len); | 1128 | result = usbat_write_blocks(us, buffer, len); |
1103 | if (result != USB_STOR_TRANSPORT_GOOD) | 1129 | if (result != USB_STOR_TRANSPORT_GOOD) |
1104 | goto leave; | 1130 | goto leave; |
@@ -1169,42 +1195,44 @@ static int usbat_hp8200e_handle_read10(struct us_data *us, | |||
1169 | srb->transfersize); | 1195 | srb->transfersize); |
1170 | } | 1196 | } |
1171 | 1197 | ||
1172 | // Since we only read in one block at a time, we have to create | 1198 | /* |
1173 | // a bounce buffer and move the data a piece at a time between the | 1199 | * Since we only read in one block at a time, we have to create |
1174 | // bounce buffer and the actual transfer buffer. | 1200 | * a bounce buffer and move the data a piece at a time between the |
1201 | * bounce buffer and the actual transfer buffer. | ||
1202 | */ | ||
1175 | 1203 | ||
1176 | len = (65535/srb->transfersize) * srb->transfersize; | 1204 | len = (65535/srb->transfersize) * srb->transfersize; |
1177 | US_DEBUGP("Max read is %d bytes\n", len); | 1205 | US_DEBUGP("Max read is %d bytes\n", len); |
1178 | len = min(len, srb->request_bufflen); | 1206 | len = min(len, srb->request_bufflen); |
1179 | buffer = kmalloc(len, GFP_NOIO); | 1207 | buffer = kmalloc(len, GFP_NOIO); |
1180 | if (buffer == NULL) // bloody hell! | 1208 | if (buffer == NULL) /* bloody hell! */ |
1181 | return USB_STOR_TRANSPORT_FAILED; | 1209 | return USB_STOR_TRANSPORT_FAILED; |
1182 | sector = short_pack(data[7+3], data[7+2]); | 1210 | sector = short_pack(data[7+3], data[7+2]); |
1183 | sector <<= 16; | 1211 | sector <<= 16; |
1184 | sector |= short_pack(data[7+5], data[7+4]); | 1212 | sector |= short_pack(data[7+5], data[7+4]); |
1185 | transferred = 0; | 1213 | transferred = 0; |
1186 | 1214 | ||
1187 | sg_segment = 0; // for keeping track of where we are in | 1215 | sg_segment = 0; /* for keeping track of where we are in */ |
1188 | sg_offset = 0; // the scatter/gather list | 1216 | sg_offset = 0; /* the scatter/gather list */ |
1189 | 1217 | ||
1190 | while (transferred != srb->request_bufflen) { | 1218 | while (transferred != srb->request_bufflen) { |
1191 | 1219 | ||
1192 | if (len > srb->request_bufflen - transferred) | 1220 | if (len > srb->request_bufflen - transferred) |
1193 | len = srb->request_bufflen - transferred; | 1221 | len = srb->request_bufflen - transferred; |
1194 | 1222 | ||
1195 | data[3] = len&0xFF; // (cylL) = expected length (L) | 1223 | data[3] = len&0xFF; /* (cylL) = expected length (L) */ |
1196 | data[4] = (len>>8)&0xFF; // (cylH) = expected length (H) | 1224 | data[4] = (len>>8)&0xFF; /* (cylH) = expected length (H) */ |
1197 | 1225 | ||
1198 | // Fix up the SCSI command sector and num sectors | 1226 | /* Fix up the SCSI command sector and num sectors */ |
1199 | 1227 | ||
1200 | data[7+2] = MSB_of(sector>>16); // SCSI command sector | 1228 | data[7+2] = MSB_of(sector>>16); /* SCSI command sector */ |
1201 | data[7+3] = LSB_of(sector>>16); | 1229 | data[7+3] = LSB_of(sector>>16); |
1202 | data[7+4] = MSB_of(sector&0xFFFF); | 1230 | data[7+4] = MSB_of(sector&0xFFFF); |
1203 | data[7+5] = LSB_of(sector&0xFFFF); | 1231 | data[7+5] = LSB_of(sector&0xFFFF); |
1204 | if (data[7+0] == GPCMD_READ_CD) | 1232 | if (data[7+0] == GPCMD_READ_CD) |
1205 | data[7+6] = 0; | 1233 | data[7+6] = 0; |
1206 | data[7+7] = MSB_of(len / srb->transfersize); // SCSI command | 1234 | data[7+7] = MSB_of(len / srb->transfersize); /* SCSI command */ |
1207 | data[7+8] = LSB_of(len / srb->transfersize); // num sectors | 1235 | data[7+8] = LSB_of(len / srb->transfersize); /* num sectors */ |
1208 | 1236 | ||
1209 | result = usbat_hp8200e_rw_block_test(us, USBAT_ATA, | 1237 | result = usbat_hp8200e_rw_block_test(us, USBAT_ATA, |
1210 | registers, data, 19, | 1238 | registers, data, 19, |
@@ -1217,16 +1245,16 @@ static int usbat_hp8200e_handle_read10(struct us_data *us, | |||
1217 | if (result != USB_STOR_TRANSPORT_GOOD) | 1245 | if (result != USB_STOR_TRANSPORT_GOOD) |
1218 | break; | 1246 | break; |
1219 | 1247 | ||
1220 | // Store the data in the transfer buffer | 1248 | /* Store the data in the transfer buffer */ |
1221 | usb_stor_access_xfer_buf(buffer, len, srb, | 1249 | usb_stor_access_xfer_buf(buffer, len, srb, |
1222 | &sg_segment, &sg_offset, TO_XFER_BUF); | 1250 | &sg_segment, &sg_offset, TO_XFER_BUF); |
1223 | 1251 | ||
1224 | // Update the amount transferred and the sector number | 1252 | /* Update the amount transferred and the sector number */ |
1225 | 1253 | ||
1226 | transferred += len; | 1254 | transferred += len; |
1227 | sector += len / srb->transfersize; | 1255 | sector += len / srb->transfersize; |
1228 | 1256 | ||
1229 | } // while transferred != srb->request_bufflen | 1257 | } /* while transferred != srb->request_bufflen */ |
1230 | 1258 | ||
1231 | kfree(buffer); | 1259 | kfree(buffer); |
1232 | return result; | 1260 | return result; |
@@ -1237,7 +1265,7 @@ static int usbat_select_and_test_registers(struct us_data *us) | |||
1237 | int selector; | 1265 | int selector; |
1238 | unsigned char *status = us->iobuf; | 1266 | unsigned char *status = us->iobuf; |
1239 | 1267 | ||
1240 | // try device = master, then device = slave. | 1268 | /* try device = master, then device = slave. */ |
1241 | for (selector = 0xA0; selector <= 0xB0; selector += 0x10) { | 1269 | for (selector = 0xA0; selector <= 0xB0; selector += 0x10) { |
1242 | if (usbat_write(us, USBAT_ATA, USBAT_ATA_DEVICE, selector) != | 1270 | if (usbat_write(us, USBAT_ATA, USBAT_ATA_DEVICE, selector) != |
1243 | USB_STOR_XFER_GOOD) | 1271 | USB_STOR_XFER_GOOD) |
@@ -1298,7 +1326,7 @@ int init_usbat(struct us_data *us) | |||
1298 | memset(us->extra, 0, sizeof(struct usbat_info)); | 1326 | memset(us->extra, 0, sizeof(struct usbat_info)); |
1299 | info = (struct usbat_info *) (us->extra); | 1327 | info = (struct usbat_info *) (us->extra); |
1300 | 1328 | ||
1301 | // Enable peripheral control signals | 1329 | /* Enable peripheral control signals */ |
1302 | rc = usbat_write_user_io(us, | 1330 | rc = usbat_write_user_io(us, |
1303 | USBAT_UIO_OE1 | USBAT_UIO_OE0, | 1331 | USBAT_UIO_OE1 | USBAT_UIO_OE0, |
1304 | USBAT_UIO_EPAD | USBAT_UIO_1); | 1332 | USBAT_UIO_EPAD | USBAT_UIO_1); |
@@ -1337,7 +1365,7 @@ int init_usbat(struct us_data *us) | |||
1337 | 1365 | ||
1338 | US_DEBUGP("INIT 5\n"); | 1366 | US_DEBUGP("INIT 5\n"); |
1339 | 1367 | ||
1340 | // Enable peripheral control signals and card detect | 1368 | /* Enable peripheral control signals and card detect */ |
1341 | rc = usbat_device_enable_cdt(us); | 1369 | rc = usbat_device_enable_cdt(us); |
1342 | if (rc != USB_STOR_TRANSPORT_GOOD) | 1370 | if (rc != USB_STOR_TRANSPORT_GOOD) |
1343 | return rc; | 1371 | return rc; |
@@ -1364,7 +1392,7 @@ int init_usbat(struct us_data *us) | |||
1364 | 1392 | ||
1365 | US_DEBUGP("INIT 9\n"); | 1393 | US_DEBUGP("INIT 9\n"); |
1366 | 1394 | ||
1367 | // At this point, we need to detect which device we are using | 1395 | /* At this point, we need to detect which device we are using */ |
1368 | if (usbat_set_transport(us, info)) | 1396 | if (usbat_set_transport(us, info)) |
1369 | return USB_STOR_TRANSPORT_ERROR; | 1397 | return USB_STOR_TRANSPORT_ERROR; |
1370 | 1398 | ||
@@ -1414,10 +1442,10 @@ static int usbat_hp8200e_transport(struct scsi_cmnd *srb, struct us_data *us) | |||
1414 | data[0] = 0x00; | 1442 | data[0] = 0x00; |
1415 | data[1] = 0x00; | 1443 | data[1] = 0x00; |
1416 | data[2] = 0x00; | 1444 | data[2] = 0x00; |
1417 | data[3] = len&0xFF; // (cylL) = expected length (L) | 1445 | data[3] = len&0xFF; /* (cylL) = expected length (L) */ |
1418 | data[4] = (len>>8)&0xFF; // (cylH) = expected length (H) | 1446 | data[4] = (len>>8)&0xFF; /* (cylH) = expected length (H) */ |
1419 | data[5] = 0xB0; // (device sel) = slave | 1447 | data[5] = 0xB0; /* (device sel) = slave */ |
1420 | data[6] = 0xA0; // (command) = ATA PACKET COMMAND | 1448 | data[6] = 0xA0; /* (command) = ATA PACKET COMMAND */ |
1421 | 1449 | ||
1422 | for (i=7; i<19; i++) { | 1450 | for (i=7; i<19; i++) { |
1423 | registers[i] = 0x10; | 1451 | registers[i] = 0x10; |
@@ -1466,13 +1494,15 @@ static int usbat_hp8200e_transport(struct scsi_cmnd *srb, struct us_data *us) | |||
1466 | return result; | 1494 | return result; |
1467 | } | 1495 | } |
1468 | 1496 | ||
1469 | // Write the 12-byte command header. | 1497 | /* |
1470 | 1498 | * Write the 12-byte command header. | |
1471 | // If the command is BLANK then set the timer for 75 minutes. | 1499 | * |
1472 | // Otherwise set it for 10 minutes. | 1500 | * If the command is BLANK then set the timer for 75 minutes. |
1473 | 1501 | * Otherwise set it for 10 minutes. | |
1474 | // NOTE: THE 8200 DOCUMENTATION STATES THAT BLANKING A CDRW | 1502 | * |
1475 | // AT SPEED 4 IS UNRELIABLE!!! | 1503 | * NOTE: THE 8200 DOCUMENTATION STATES THAT BLANKING A CDRW |
1504 | * AT SPEED 4 IS UNRELIABLE!!! | ||
1505 | */ | ||
1476 | 1506 | ||
1477 | if ( (result = usbat_write_block(us, | 1507 | if ( (result = usbat_write_block(us, |
1478 | USBAT_ATA, srb->cmnd, 12, | 1508 | USBAT_ATA, srb->cmnd, 12, |
@@ -1481,19 +1511,18 @@ static int usbat_hp8200e_transport(struct scsi_cmnd *srb, struct us_data *us) | |||
1481 | return result; | 1511 | return result; |
1482 | } | 1512 | } |
1483 | 1513 | ||
1484 | // If there is response data to be read in | 1514 | /* If there is response data to be read in then do it here. */ |
1485 | // then do it here. | ||
1486 | 1515 | ||
1487 | if (len != 0 && (srb->sc_data_direction == DMA_FROM_DEVICE)) { | 1516 | if (len != 0 && (srb->sc_data_direction == DMA_FROM_DEVICE)) { |
1488 | 1517 | ||
1489 | // How many bytes to read in? Check cylL register | 1518 | /* How many bytes to read in? Check cylL register */ |
1490 | 1519 | ||
1491 | if (usbat_read(us, USBAT_ATA, USBAT_ATA_LBA_ME, status) != | 1520 | if (usbat_read(us, USBAT_ATA, USBAT_ATA_LBA_ME, status) != |
1492 | USB_STOR_XFER_GOOD) { | 1521 | USB_STOR_XFER_GOOD) { |
1493 | return USB_STOR_TRANSPORT_ERROR; | 1522 | return USB_STOR_TRANSPORT_ERROR; |
1494 | } | 1523 | } |
1495 | 1524 | ||
1496 | if (len > 0xFF) { // need to read cylH also | 1525 | if (len > 0xFF) { /* need to read cylH also */ |
1497 | len = *status; | 1526 | len = *status; |
1498 | if (usbat_read(us, USBAT_ATA, USBAT_ATA_LBA_HI, status) != | 1527 | if (usbat_read(us, USBAT_ATA, USBAT_ATA_LBA_HI, status) != |
1499 | USB_STOR_XFER_GOOD) { | 1528 | USB_STOR_XFER_GOOD) { |
@@ -1556,13 +1585,16 @@ static int usbat_flash_transport(struct scsi_cmnd * srb, struct us_data *us) | |||
1556 | if (rc != USB_STOR_TRANSPORT_GOOD) | 1585 | if (rc != USB_STOR_TRANSPORT_GOOD) |
1557 | return rc; | 1586 | return rc; |
1558 | 1587 | ||
1559 | info->ssize = 0x200; // hard coded 512 byte sectors as per ATA spec | 1588 | /* hard coded 512 byte sectors as per ATA spec */ |
1589 | info->ssize = 0x200; | ||
1560 | US_DEBUGP("usbat_flash_transport: READ_CAPACITY: %ld sectors, %ld bytes per sector\n", | 1590 | US_DEBUGP("usbat_flash_transport: READ_CAPACITY: %ld sectors, %ld bytes per sector\n", |
1561 | info->sectors, info->ssize); | 1591 | info->sectors, info->ssize); |
1562 | 1592 | ||
1563 | // build the reply | 1593 | /* |
1564 | // note: must return the sector number of the last sector, | 1594 | * build the reply |
1565 | // *not* the total number of sectors | 1595 | * note: must return the sector number of the last sector, |
1596 | * *not* the total number of sectors | ||
1597 | */ | ||
1566 | ((__be32 *) ptr)[0] = cpu_to_be32(info->sectors - 1); | 1598 | ((__be32 *) ptr)[0] = cpu_to_be32(info->sectors - 1); |
1567 | ((__be32 *) ptr)[1] = cpu_to_be32(info->ssize); | 1599 | ((__be32 *) ptr)[1] = cpu_to_be32(info->ssize); |
1568 | usb_stor_set_xfer_buf(ptr, 8, srb); | 1600 | usb_stor_set_xfer_buf(ptr, 8, srb); |
@@ -1586,7 +1618,9 @@ static int usbat_flash_transport(struct scsi_cmnd * srb, struct us_data *us) | |||
1586 | } | 1618 | } |
1587 | 1619 | ||
1588 | if (srb->cmnd[0] == READ_12) { | 1620 | if (srb->cmnd[0] == READ_12) { |
1589 | // I don't think we'll ever see a READ_12 but support it anyway... | 1621 | /* |
1622 | * I don't think we'll ever see a READ_12 but support it anyway | ||
1623 | */ | ||
1590 | block = ((u32)(srb->cmnd[2]) << 24) | ((u32)(srb->cmnd[3]) << 16) | | 1624 | block = ((u32)(srb->cmnd[2]) << 24) | ((u32)(srb->cmnd[3]) << 16) | |
1591 | ((u32)(srb->cmnd[4]) << 8) | ((u32)(srb->cmnd[5])); | 1625 | ((u32)(srb->cmnd[4]) << 8) | ((u32)(srb->cmnd[5])); |
1592 | 1626 | ||
@@ -1608,7 +1642,9 @@ static int usbat_flash_transport(struct scsi_cmnd * srb, struct us_data *us) | |||
1608 | } | 1642 | } |
1609 | 1643 | ||
1610 | if (srb->cmnd[0] == WRITE_12) { | 1644 | if (srb->cmnd[0] == WRITE_12) { |
1611 | // I don't think we'll ever see a WRITE_12 but support it anyway... | 1645 | /* |
1646 | * I don't think we'll ever see a WRITE_12 but support it anyway | ||
1647 | */ | ||
1612 | block = ((u32)(srb->cmnd[2]) << 24) | ((u32)(srb->cmnd[3]) << 16) | | 1648 | block = ((u32)(srb->cmnd[2]) << 24) | ((u32)(srb->cmnd[3]) << 16) | |
1613 | ((u32)(srb->cmnd[4]) << 8) | ((u32)(srb->cmnd[5])); | 1649 | ((u32)(srb->cmnd[4]) << 8) | ((u32)(srb->cmnd[5])); |
1614 | 1650 | ||
@@ -1645,8 +1681,10 @@ static int usbat_flash_transport(struct scsi_cmnd * srb, struct us_data *us) | |||
1645 | } | 1681 | } |
1646 | 1682 | ||
1647 | if (srb->cmnd[0] == ALLOW_MEDIUM_REMOVAL) { | 1683 | if (srb->cmnd[0] == ALLOW_MEDIUM_REMOVAL) { |
1648 | // sure. whatever. not like we can stop the user from popping | 1684 | /* |
1649 | // the media out of the device (no locking doors, etc) | 1685 | * sure. whatever. not like we can stop the user from popping |
1686 | * the media out of the device (no locking doors, etc) | ||
1687 | */ | ||
1650 | return USB_STOR_TRANSPORT_GOOD; | 1688 | return USB_STOR_TRANSPORT_GOOD; |
1651 | } | 1689 | } |
1652 | 1690 | ||
diff --git a/drivers/usb/storage/shuttle_usbat.h b/drivers/usb/storage/shuttle_usbat.h index 5b8e867e2ae5..25e7d8b340b8 100644 --- a/drivers/usb/storage/shuttle_usbat.h +++ b/drivers/usb/storage/shuttle_usbat.h | |||
@@ -55,8 +55,8 @@ | |||
55 | #define USBAT_UIO_WRITE 0 | 55 | #define USBAT_UIO_WRITE 0 |
56 | 56 | ||
57 | /* Qualifier bits */ | 57 | /* Qualifier bits */ |
58 | #define USBAT_QUAL_FCQ 0x20 // full compare | 58 | #define USBAT_QUAL_FCQ 0x20 /* full compare */ |
59 | #define USBAT_QUAL_ALQ 0x10 // auto load subcount | 59 | #define USBAT_QUAL_ALQ 0x10 /* auto load subcount */ |
60 | 60 | ||
61 | /* USBAT Flash Media status types */ | 61 | /* USBAT Flash Media status types */ |
62 | #define USBAT_FLASH_MEDIA_NONE 0 | 62 | #define USBAT_FLASH_MEDIA_NONE 0 |
@@ -67,39 +67,39 @@ | |||
67 | #define USBAT_FLASH_MEDIA_CHANGED 1 | 67 | #define USBAT_FLASH_MEDIA_CHANGED 1 |
68 | 68 | ||
69 | /* USBAT ATA registers */ | 69 | /* USBAT ATA registers */ |
70 | #define USBAT_ATA_DATA 0x10 // read/write data (R/W) | 70 | #define USBAT_ATA_DATA 0x10 /* read/write data (R/W) */ |
71 | #define USBAT_ATA_FEATURES 0x11 // set features (W) | 71 | #define USBAT_ATA_FEATURES 0x11 /* set features (W) */ |
72 | #define USBAT_ATA_ERROR 0x11 // error (R) | 72 | #define USBAT_ATA_ERROR 0x11 /* error (R) */ |
73 | #define USBAT_ATA_SECCNT 0x12 // sector count (R/W) | 73 | #define USBAT_ATA_SECCNT 0x12 /* sector count (R/W) */ |
74 | #define USBAT_ATA_SECNUM 0x13 // sector number (R/W) | 74 | #define USBAT_ATA_SECNUM 0x13 /* sector number (R/W) */ |
75 | #define USBAT_ATA_LBA_ME 0x14 // cylinder low (R/W) | 75 | #define USBAT_ATA_LBA_ME 0x14 /* cylinder low (R/W) */ |
76 | #define USBAT_ATA_LBA_HI 0x15 // cylinder high (R/W) | 76 | #define USBAT_ATA_LBA_HI 0x15 /* cylinder high (R/W) */ |
77 | #define USBAT_ATA_DEVICE 0x16 // head/device selection (R/W) | 77 | #define USBAT_ATA_DEVICE 0x16 /* head/device selection (R/W) */ |
78 | #define USBAT_ATA_STATUS 0x17 // device status (R) | 78 | #define USBAT_ATA_STATUS 0x17 /* device status (R) */ |
79 | #define USBAT_ATA_CMD 0x17 // device command (W) | 79 | #define USBAT_ATA_CMD 0x17 /* device command (W) */ |
80 | #define USBAT_ATA_ALTSTATUS 0x0E // status (no clear IRQ) (R) | 80 | #define USBAT_ATA_ALTSTATUS 0x0E /* status (no clear IRQ) (R) */ |
81 | 81 | ||
82 | /* USBAT User I/O Data registers */ | 82 | /* USBAT User I/O Data registers */ |
83 | #define USBAT_UIO_EPAD 0x80 // Enable Peripheral Control Signals | 83 | #define USBAT_UIO_EPAD 0x80 /* Enable Peripheral Control Signals */ |
84 | #define USBAT_UIO_CDT 0x40 // Card Detect (Read Only) | 84 | #define USBAT_UIO_CDT 0x40 /* Card Detect (Read Only) */ |
85 | // CDT = ACKD & !UI1 & !UI0 | 85 | /* CDT = ACKD & !UI1 & !UI0 */ |
86 | #define USBAT_UIO_1 0x20 // I/O 1 | 86 | #define USBAT_UIO_1 0x20 /* I/O 1 */ |
87 | #define USBAT_UIO_0 0x10 // I/O 0 | 87 | #define USBAT_UIO_0 0x10 /* I/O 0 */ |
88 | #define USBAT_UIO_EPP_ATA 0x08 // 1=EPP mode, 0=ATA mode | 88 | #define USBAT_UIO_EPP_ATA 0x08 /* 1=EPP mode, 0=ATA mode */ |
89 | #define USBAT_UIO_UI1 0x04 // Input 1 | 89 | #define USBAT_UIO_UI1 0x04 /* Input 1 */ |
90 | #define USBAT_UIO_UI0 0x02 // Input 0 | 90 | #define USBAT_UIO_UI0 0x02 /* Input 0 */ |
91 | #define USBAT_UIO_INTR_ACK 0x01 // Interrupt (ATA & ISA)/Acknowledge (EPP) | 91 | #define USBAT_UIO_INTR_ACK 0x01 /* Interrupt (ATA/ISA)/Acknowledge (EPP) */ |
92 | 92 | ||
93 | /* USBAT User I/O Enable registers */ | 93 | /* USBAT User I/O Enable registers */ |
94 | #define USBAT_UIO_DRVRST 0x80 // Reset Peripheral | 94 | #define USBAT_UIO_DRVRST 0x80 /* Reset Peripheral */ |
95 | #define USBAT_UIO_ACKD 0x40 // Enable Card Detect | 95 | #define USBAT_UIO_ACKD 0x40 /* Enable Card Detect */ |
96 | #define USBAT_UIO_OE1 0x20 // I/O 1 set=output/clr=input | 96 | #define USBAT_UIO_OE1 0x20 /* I/O 1 set=output/clr=input */ |
97 | // If ACKD=1, set OE1 to 1 also. | 97 | /* If ACKD=1, set OE1 to 1 also. */ |
98 | #define USBAT_UIO_OE0 0x10 // I/O 0 set=output/clr=input | 98 | #define USBAT_UIO_OE0 0x10 /* I/O 0 set=output/clr=input */ |
99 | #define USBAT_UIO_ADPRST 0x01 // Reset SCM chip | 99 | #define USBAT_UIO_ADPRST 0x01 /* Reset SCM chip */ |
100 | 100 | ||
101 | /* USBAT Features */ | 101 | /* USBAT Features */ |
102 | #define USBAT_FEAT_ETEN 0x80 // External trigger enable | 102 | #define USBAT_FEAT_ETEN 0x80 /* External trigger enable */ |
103 | #define USBAT_FEAT_U1 0x08 | 103 | #define USBAT_FEAT_U1 0x08 |
104 | #define USBAT_FEAT_U0 0x04 | 104 | #define USBAT_FEAT_U0 0x04 |
105 | #define USBAT_FEAT_ET1 0x02 | 105 | #define USBAT_FEAT_ET1 0x02 |
@@ -112,12 +112,12 @@ struct usbat_info { | |||
112 | int devicetype; | 112 | int devicetype; |
113 | 113 | ||
114 | /* Used for Flash readers only */ | 114 | /* Used for Flash readers only */ |
115 | unsigned long sectors; // total sector count | 115 | unsigned long sectors; /* total sector count */ |
116 | unsigned long ssize; // sector size in bytes | 116 | unsigned long ssize; /* sector size in bytes */ |
117 | 117 | ||
118 | unsigned char sense_key; | 118 | unsigned char sense_key; |
119 | unsigned long sense_asc; // additional sense code | 119 | unsigned long sense_asc; /* additional sense code */ |
120 | unsigned long sense_ascq; // additional sense code qualifier | 120 | unsigned long sense_ascq; /* additional sense code qualifier */ |
121 | }; | 121 | }; |
122 | 122 | ||
123 | #endif | 123 | #endif |
diff --git a/drivers/usb/storage/transport.c b/drivers/usb/storage/transport.c index c1ba5301ebfc..7ca896a342e3 100644 --- a/drivers/usb/storage/transport.c +++ b/drivers/usb/storage/transport.c | |||
@@ -636,11 +636,11 @@ void usb_stor_invoke_transport(struct scsi_cmnd *srb, struct us_data *us) | |||
636 | 636 | ||
637 | /* use the new buffer we have */ | 637 | /* use the new buffer we have */ |
638 | old_request_buffer = srb->request_buffer; | 638 | old_request_buffer = srb->request_buffer; |
639 | srb->request_buffer = srb->sense_buffer; | 639 | srb->request_buffer = us->sensebuf; |
640 | 640 | ||
641 | /* set the buffer length for transfer */ | 641 | /* set the buffer length for transfer */ |
642 | old_request_bufflen = srb->request_bufflen; | 642 | old_request_bufflen = srb->request_bufflen; |
643 | srb->request_bufflen = 18; | 643 | srb->request_bufflen = US_SENSE_SIZE; |
644 | 644 | ||
645 | /* set up for no scatter-gather use */ | 645 | /* set up for no scatter-gather use */ |
646 | old_sg = srb->use_sg; | 646 | old_sg = srb->use_sg; |
@@ -652,6 +652,7 @@ void usb_stor_invoke_transport(struct scsi_cmnd *srb, struct us_data *us) | |||
652 | temp_result = us->transport(us->srb, us); | 652 | temp_result = us->transport(us->srb, us); |
653 | 653 | ||
654 | /* let's clean up right away */ | 654 | /* let's clean up right away */ |
655 | memcpy(srb->sense_buffer, us->sensebuf, US_SENSE_SIZE); | ||
655 | srb->resid = old_resid; | 656 | srb->resid = old_resid; |
656 | srb->request_buffer = old_request_buffer; | 657 | srb->request_buffer = old_request_buffer; |
657 | srb->request_bufflen = old_request_bufflen; | 658 | srb->request_bufflen = old_request_bufflen; |
@@ -923,6 +924,7 @@ int usb_stor_Bulk_max_lun(struct us_data *us) | |||
923 | int result; | 924 | int result; |
924 | 925 | ||
925 | /* issue the command */ | 926 | /* issue the command */ |
927 | us->iobuf[0] = 0; | ||
926 | result = usb_stor_control_msg(us, us->recv_ctrl_pipe, | 928 | result = usb_stor_control_msg(us, us->recv_ctrl_pipe, |
927 | US_BULK_GET_MAX_LUN, | 929 | US_BULK_GET_MAX_LUN, |
928 | USB_DIR_IN | USB_TYPE_CLASS | | 930 | USB_DIR_IN | USB_TYPE_CLASS | |
diff --git a/drivers/usb/storage/transport.h b/drivers/usb/storage/transport.h index 8d9e0663f8fe..0a362cc781ad 100644 --- a/drivers/usb/storage/transport.h +++ b/drivers/usb/storage/transport.h | |||
@@ -50,7 +50,7 @@ | |||
50 | #define US_PR_CB 0x01 /* Control/Bulk w/o interrupt */ | 50 | #define US_PR_CB 0x01 /* Control/Bulk w/o interrupt */ |
51 | #define US_PR_BULK 0x50 /* bulk only */ | 51 | #define US_PR_BULK 0x50 /* bulk only */ |
52 | #ifdef CONFIG_USB_STORAGE_USBAT | 52 | #ifdef CONFIG_USB_STORAGE_USBAT |
53 | #define US_PR_SCM_ATAPI 0x80 /* SCM-ATAPI bridge */ | 53 | #define US_PR_USBAT 0x80 /* SCM-ATAPI bridge */ |
54 | #endif | 54 | #endif |
55 | #ifdef CONFIG_USB_STORAGE_SDDR09 | 55 | #ifdef CONFIG_USB_STORAGE_SDDR09 |
56 | #define US_PR_EUSB_SDDR09 0x81 /* SCM-SCSI bridge for SDDR-09 */ | 56 | #define US_PR_EUSB_SDDR09 0x81 /* SCM-SCSI bridge for SDDR-09 */ |
diff --git a/drivers/usb/storage/unusual_devs.h b/drivers/usb/storage/unusual_devs.h index b79dad1b598c..f5f47a34b168 100644 --- a/drivers/usb/storage/unusual_devs.h +++ b/drivers/usb/storage/unusual_devs.h | |||
@@ -71,12 +71,12 @@ UNUSUAL_DEV( 0x03f0, 0x0107, 0x0200, 0x0200, | |||
71 | UNUSUAL_DEV( 0x03f0, 0x0207, 0x0001, 0x0001, | 71 | UNUSUAL_DEV( 0x03f0, 0x0207, 0x0001, 0x0001, |
72 | "HP", | 72 | "HP", |
73 | "CD-Writer+ 8200e", | 73 | "CD-Writer+ 8200e", |
74 | US_SC_8070, US_PR_SCM_ATAPI, init_usbat, 0), | 74 | US_SC_8070, US_PR_USBAT, init_usbat, 0), |
75 | 75 | ||
76 | UNUSUAL_DEV( 0x03f0, 0x0307, 0x0001, 0x0001, | 76 | UNUSUAL_DEV( 0x03f0, 0x0307, 0x0001, 0x0001, |
77 | "HP", | 77 | "HP", |
78 | "CD-Writer+ CD-4e", | 78 | "CD-Writer+ CD-4e", |
79 | US_SC_8070, US_PR_SCM_ATAPI, init_usbat, 0), | 79 | US_SC_8070, US_PR_USBAT, init_usbat, 0), |
80 | #endif | 80 | #endif |
81 | 81 | ||
82 | /* Patch submitted by Mihnea-Costin Grigore <mihnea@zulu.ro> */ | 82 | /* Patch submitted by Mihnea-Costin Grigore <mihnea@zulu.ro> */ |
@@ -106,6 +106,13 @@ UNUSUAL_DEV( 0x0411, 0x001c, 0x0113, 0x0113, | |||
106 | US_SC_DEVICE, US_PR_DEVICE, NULL, | 106 | US_SC_DEVICE, US_PR_DEVICE, NULL, |
107 | US_FL_FIX_INQUIRY ), | 107 | US_FL_FIX_INQUIRY ), |
108 | 108 | ||
109 | /* Reported by Stefan Werner <dustbln@gmx.de> */ | ||
110 | UNUSUAL_DEV( 0x0419, 0xaaf6, 0x0100, 0x0100, | ||
111 | "TrekStor", | ||
112 | "i.Beat Joy 2.0", | ||
113 | US_SC_DEVICE, US_PR_DEVICE, NULL, | ||
114 | US_FL_IGNORE_RESIDUE ), | ||
115 | |||
109 | /* Reported by Olaf Hering <olh@suse.de> from novell bug #105878 */ | 116 | /* Reported by Olaf Hering <olh@suse.de> from novell bug #105878 */ |
110 | UNUSUAL_DEV( 0x0424, 0x0fdc, 0x0210, 0x0210, | 117 | UNUSUAL_DEV( 0x0424, 0x0fdc, 0x0210, 0x0210, |
111 | "SMSC", | 118 | "SMSC", |
@@ -244,6 +251,13 @@ UNUSUAL_DEV( 0x04da, 0x2372, 0x0000, 0x9999, | |||
244 | US_SC_DEVICE, US_PR_DEVICE, NULL, | 251 | US_SC_DEVICE, US_PR_DEVICE, NULL, |
245 | US_FL_FIX_CAPACITY | US_FL_NOT_LOCKABLE ), | 252 | US_FL_FIX_CAPACITY | US_FL_NOT_LOCKABLE ), |
246 | 253 | ||
254 | /* Reported by Simeon Simeonov <simeonov_2000@yahoo.com> */ | ||
255 | UNUSUAL_DEV( 0x04da, 0x2373, 0x0000, 0x9999, | ||
256 | "LEICA", | ||
257 | "D-LUX Camera", | ||
258 | US_SC_DEVICE, US_PR_DEVICE, NULL, | ||
259 | US_FL_FIX_CAPACITY | US_FL_NOT_LOCKABLE ), | ||
260 | |||
247 | /* Most of the following entries were developed with the help of | 261 | /* Most of the following entries were developed with the help of |
248 | * Shuttle/SCM directly. | 262 | * Shuttle/SCM directly. |
249 | */ | 263 | */ |
@@ -333,9 +347,9 @@ UNUSUAL_DEV( 0x04fc, 0x80c2, 0x0100, 0x0100, | |||
333 | 347 | ||
334 | #ifdef CONFIG_USB_STORAGE_USBAT | 348 | #ifdef CONFIG_USB_STORAGE_USBAT |
335 | UNUSUAL_DEV( 0x04e6, 0x1010, 0x0000, 0x9999, | 349 | UNUSUAL_DEV( 0x04e6, 0x1010, 0x0000, 0x9999, |
336 | "SCM", | 350 | "Shuttle/SCM", |
337 | "SCM USBAT-02", | 351 | "USBAT-02", |
338 | US_SC_SCSI, US_PR_SCM_ATAPI, init_usbat, | 352 | US_SC_SCSI, US_PR_USBAT, init_usbat, |
339 | US_FL_SINGLE_LUN), | 353 | US_FL_SINGLE_LUN), |
340 | #endif | 354 | #endif |
341 | 355 | ||
@@ -598,6 +612,16 @@ UNUSUAL_DEV( 0x05ac, 0x1205, 0x0000, 0x9999, | |||
598 | US_SC_DEVICE, US_PR_DEVICE, NULL, | 612 | US_SC_DEVICE, US_PR_DEVICE, NULL, |
599 | US_FL_FIX_CAPACITY ), | 613 | US_FL_FIX_CAPACITY ), |
600 | 614 | ||
615 | /* | ||
616 | * Reported by Tyson Vinson <lornoss@gmail.com> | ||
617 | * This particular productId is the iPod Nano | ||
618 | */ | ||
619 | UNUSUAL_DEV( 0x05ac, 0x120a, 0x0000, 0x9999, | ||
620 | "Apple", | ||
621 | "iPod", | ||
622 | US_SC_DEVICE, US_PR_DEVICE, NULL, | ||
623 | US_FL_FIX_CAPACITY ), | ||
624 | |||
601 | #ifdef CONFIG_USB_STORAGE_JUMPSHOT | 625 | #ifdef CONFIG_USB_STORAGE_JUMPSHOT |
602 | UNUSUAL_DEV( 0x05dc, 0x0001, 0x0000, 0x0001, | 626 | UNUSUAL_DEV( 0x05dc, 0x0001, 0x0000, 0x0001, |
603 | "Lexar", | 627 | "Lexar", |
@@ -686,11 +710,6 @@ UNUSUAL_DEV( 0x0686, 0x4017, 0x0001, 0x0001, | |||
686 | "DIMAGE E223", | 710 | "DIMAGE E223", |
687 | US_SC_SCSI, US_PR_DEVICE, NULL, 0 ), | 711 | US_SC_SCSI, US_PR_DEVICE, NULL, 0 ), |
688 | 712 | ||
689 | UNUSUAL_DEV( 0x0693, 0x0002, 0x0100, 0x0100, | ||
690 | "Hagiwara", | ||
691 | "FlashGate SmartMedia", | ||
692 | US_SC_SCSI, US_PR_BULK, NULL, 0 ), | ||
693 | |||
694 | UNUSUAL_DEV( 0x0693, 0x0005, 0x0100, 0x0100, | 713 | UNUSUAL_DEV( 0x0693, 0x0005, 0x0100, 0x0100, |
695 | "Hagiwara", | 714 | "Hagiwara", |
696 | "Flashgate", | 715 | "Flashgate", |
@@ -702,6 +721,14 @@ UNUSUAL_DEV( 0x0781, 0x0001, 0x0200, 0x0200, | |||
702 | US_SC_SCSI, US_PR_CB, NULL, | 721 | US_SC_SCSI, US_PR_CB, NULL, |
703 | US_FL_SINGLE_LUN ), | 722 | US_FL_SINGLE_LUN ), |
704 | 723 | ||
724 | #ifdef CONFIG_USB_STORAGE_USBAT | ||
725 | UNUSUAL_DEV( 0x0781, 0x0005, 0x0005, 0x0005, | ||
726 | "Sandisk", | ||
727 | "ImageMate SDDR-05b", | ||
728 | US_SC_SCSI, US_PR_USBAT, init_usbat, | ||
729 | US_FL_SINGLE_LUN ), | ||
730 | #endif | ||
731 | |||
705 | UNUSUAL_DEV( 0x0781, 0x0100, 0x0100, 0x0100, | 732 | UNUSUAL_DEV( 0x0781, 0x0100, 0x0100, 0x0100, |
706 | "Sandisk", | 733 | "Sandisk", |
707 | "ImageMate SDDR-12", | 734 | "ImageMate SDDR-12", |
@@ -724,7 +751,7 @@ UNUSUAL_DEV( 0x07ab, 0xfc01, 0x0000, 0x9999, | |||
724 | #endif | 751 | #endif |
725 | 752 | ||
726 | /* Reported by Eero Volotinen <eero@ping-viini.org> */ | 753 | /* Reported by Eero Volotinen <eero@ping-viini.org> */ |
727 | UNUSUAL_DEV( 0x07ab, 0xfccd, 0x0406, 0x0406, | 754 | UNUSUAL_DEV( 0x07ab, 0xfccd, 0x0000, 0x9999, |
728 | "Freecom Technologies", | 755 | "Freecom Technologies", |
729 | "FHD-Classic", | 756 | "FHD-Classic", |
730 | US_SC_DEVICE, US_PR_DEVICE, NULL, | 757 | US_SC_DEVICE, US_PR_DEVICE, NULL, |
@@ -976,6 +1003,11 @@ UNUSUAL_DEV( 0x0c0b, 0xa109, 0x0000, 0xffff, | |||
976 | * | 1003 | * |
977 | */ | 1004 | */ |
978 | #ifdef CONFIG_USB_STORAGE_ONETOUCH | 1005 | #ifdef CONFIG_USB_STORAGE_ONETOUCH |
1006 | UNUSUAL_DEV( 0x0d49, 0x7000, 0x0000, 0x9999, | ||
1007 | "Maxtor", | ||
1008 | "OneTouch External Harddrive", | ||
1009 | US_SC_DEVICE, US_PR_DEVICE, onetouch_connect_input, | ||
1010 | 0), | ||
979 | UNUSUAL_DEV( 0x0d49, 0x7010, 0x0000, 0x9999, | 1011 | UNUSUAL_DEV( 0x0d49, 0x7010, 0x0000, 0x9999, |
980 | "Maxtor", | 1012 | "Maxtor", |
981 | "OneTouch External Harddrive", | 1013 | "OneTouch External Harddrive", |
@@ -1086,6 +1118,15 @@ UNUSUAL_DEV( 0x2735, 0x100b, 0x0000, 0x9999, | |||
1086 | US_SC_DEVICE, US_PR_DEVICE, NULL, | 1118 | US_SC_DEVICE, US_PR_DEVICE, NULL, |
1087 | US_FL_GO_SLOW ), | 1119 | US_FL_GO_SLOW ), |
1088 | 1120 | ||
1121 | /* | ||
1122 | * David Härdeman <david@2gen.com> | ||
1123 | * The key makes the SCSI stack print confusing (but harmless) messages | ||
1124 | */ | ||
1125 | UNUSUAL_DEV( 0x4146, 0xba01, 0x0100, 0x0100, | ||
1126 | "Iomega", | ||
1127 | "Micro Mini 1GB", | ||
1128 | US_SC_DEVICE, US_PR_DEVICE, NULL, US_FL_NOT_LOCKABLE ), | ||
1129 | |||
1089 | #ifdef CONFIG_USB_STORAGE_SDDR55 | 1130 | #ifdef CONFIG_USB_STORAGE_SDDR55 |
1090 | UNUSUAL_DEV( 0x55aa, 0xa103, 0x0000, 0x9999, | 1131 | UNUSUAL_DEV( 0x55aa, 0xa103, 0x0000, 0x9999, |
1091 | "Sandisk", | 1132 | "Sandisk", |
diff --git a/drivers/usb/storage/usb.c b/drivers/usb/storage/usb.c index f9a9bfa1aef5..3847ebed2aa4 100644 --- a/drivers/usb/storage/usb.c +++ b/drivers/usb/storage/usb.c | |||
@@ -54,6 +54,7 @@ | |||
54 | #include <linux/module.h> | 54 | #include <linux/module.h> |
55 | #include <linux/init.h> | 55 | #include <linux/init.h> |
56 | #include <linux/slab.h> | 56 | #include <linux/slab.h> |
57 | #include <linux/kthread.h> | ||
57 | 58 | ||
58 | #include <scsi/scsi.h> | 59 | #include <scsi/scsi.h> |
59 | #include <scsi/scsi_cmnd.h> | 60 | #include <scsi/scsi_cmnd.h> |
@@ -111,11 +112,6 @@ static atomic_t total_threads = ATOMIC_INIT(0); | |||
111 | static DECLARE_COMPLETION(threads_gone); | 112 | static DECLARE_COMPLETION(threads_gone); |
112 | 113 | ||
113 | 114 | ||
114 | static int storage_probe(struct usb_interface *iface, | ||
115 | const struct usb_device_id *id); | ||
116 | |||
117 | static void storage_disconnect(struct usb_interface *iface); | ||
118 | |||
119 | /* The entries in this table, except for final ones here | 115 | /* The entries in this table, except for final ones here |
120 | * (USB_MASS_STORAGE_CLASS and the empty entry), correspond, | 116 | * (USB_MASS_STORAGE_CLASS and the empty entry), correspond, |
121 | * line for line with the entries of us_unsuaul_dev_list[]. | 117 | * line for line with the entries of us_unsuaul_dev_list[]. |
@@ -233,13 +229,40 @@ static struct us_unusual_dev us_unusual_dev_list[] = { | |||
233 | { NULL } | 229 | { NULL } |
234 | }; | 230 | }; |
235 | 231 | ||
236 | static struct usb_driver usb_storage_driver = { | 232 | |
237 | .owner = THIS_MODULE, | 233 | #ifdef CONFIG_PM /* Minimal support for suspend and resume */ |
238 | .name = "usb-storage", | 234 | |
239 | .probe = storage_probe, | 235 | static int storage_suspend(struct usb_interface *iface, pm_message_t message) |
240 | .disconnect = storage_disconnect, | 236 | { |
241 | .id_table = storage_usb_ids, | 237 | struct us_data *us = usb_get_intfdata(iface); |
242 | }; | 238 | |
239 | /* Wait until no command is running */ | ||
240 | down(&us->dev_semaphore); | ||
241 | |||
242 | US_DEBUGP("%s\n", __FUNCTION__); | ||
243 | iface->dev.power.power_state.event = message.event; | ||
244 | |||
245 | /* When runtime PM is working, we'll set a flag to indicate | ||
246 | * whether we should autoresume when a SCSI request arrives. */ | ||
247 | |||
248 | up(&us->dev_semaphore); | ||
249 | return 0; | ||
250 | } | ||
251 | |||
252 | static int storage_resume(struct usb_interface *iface) | ||
253 | { | ||
254 | struct us_data *us = usb_get_intfdata(iface); | ||
255 | |||
256 | down(&us->dev_semaphore); | ||
257 | |||
258 | US_DEBUGP("%s\n", __FUNCTION__); | ||
259 | iface->dev.power.power_state.event = PM_EVENT_ON; | ||
260 | |||
261 | up(&us->dev_semaphore); | ||
262 | return 0; | ||
263 | } | ||
264 | |||
265 | #endif /* CONFIG_PM */ | ||
243 | 266 | ||
244 | /* | 267 | /* |
245 | * fill_inquiry_response takes an unsigned char array (which must | 268 | * fill_inquiry_response takes an unsigned char array (which must |
@@ -288,22 +311,7 @@ static int usb_stor_control_thread(void * __us) | |||
288 | struct us_data *us = (struct us_data *)__us; | 311 | struct us_data *us = (struct us_data *)__us; |
289 | struct Scsi_Host *host = us_to_host(us); | 312 | struct Scsi_Host *host = us_to_host(us); |
290 | 313 | ||
291 | lock_kernel(); | ||
292 | |||
293 | /* | ||
294 | * This thread doesn't need any user-level access, | ||
295 | * so get rid of all our resources. | ||
296 | */ | ||
297 | daemonize("usb-storage"); | ||
298 | current->flags |= PF_NOFREEZE; | 314 | current->flags |= PF_NOFREEZE; |
299 | unlock_kernel(); | ||
300 | |||
301 | /* acquire a reference to the host, so it won't be deallocated | ||
302 | * until we're ready to exit */ | ||
303 | scsi_host_get(host); | ||
304 | |||
305 | /* signal that we've started the thread */ | ||
306 | complete(&(us->notify)); | ||
307 | 315 | ||
308 | for(;;) { | 316 | for(;;) { |
309 | US_DEBUGP("*** thread sleeping.\n"); | 317 | US_DEBUGP("*** thread sleeping.\n"); |
@@ -467,6 +475,12 @@ static int associate_dev(struct us_data *us, struct usb_interface *intf) | |||
467 | US_DEBUGP("I/O buffer allocation failed\n"); | 475 | US_DEBUGP("I/O buffer allocation failed\n"); |
468 | return -ENOMEM; | 476 | return -ENOMEM; |
469 | } | 477 | } |
478 | |||
479 | us->sensebuf = kmalloc(US_SENSE_SIZE, GFP_KERNEL); | ||
480 | if (!us->sensebuf) { | ||
481 | US_DEBUGP("Sense buffer allocation failed\n"); | ||
482 | return -ENOMEM; | ||
483 | } | ||
470 | return 0; | 484 | return 0; |
471 | } | 485 | } |
472 | 486 | ||
@@ -555,8 +569,8 @@ static int get_transport(struct us_data *us) | |||
555 | break; | 569 | break; |
556 | 570 | ||
557 | #ifdef CONFIG_USB_STORAGE_USBAT | 571 | #ifdef CONFIG_USB_STORAGE_USBAT |
558 | case US_PR_SCM_ATAPI: | 572 | case US_PR_USBAT: |
559 | us->transport_name = "SCM/ATAPI"; | 573 | us->transport_name = "Shuttle USBAT"; |
560 | us->transport = usbat_transport; | 574 | us->transport = usbat_transport; |
561 | us->transport_reset = usb_stor_CB_reset; | 575 | us->transport_reset = usb_stor_CB_reset; |
562 | us->max_lun = 1; | 576 | us->max_lun = 1; |
@@ -740,6 +754,7 @@ static int get_pipes(struct us_data *us) | |||
740 | static int usb_stor_acquire_resources(struct us_data *us) | 754 | static int usb_stor_acquire_resources(struct us_data *us) |
741 | { | 755 | { |
742 | int p; | 756 | int p; |
757 | struct task_struct *th; | ||
743 | 758 | ||
744 | us->current_urb = usb_alloc_urb(0, GFP_KERNEL); | 759 | us->current_urb = usb_alloc_urb(0, GFP_KERNEL); |
745 | if (!us->current_urb) { | 760 | if (!us->current_urb) { |
@@ -747,38 +762,28 @@ static int usb_stor_acquire_resources(struct us_data *us) | |||
747 | return -ENOMEM; | 762 | return -ENOMEM; |
748 | } | 763 | } |
749 | 764 | ||
750 | /* Lock the device while we carry out the next two operations */ | ||
751 | down(&us->dev_semaphore); | ||
752 | |||
753 | /* For bulk-only devices, determine the max LUN value */ | ||
754 | if (us->protocol == US_PR_BULK) { | ||
755 | p = usb_stor_Bulk_max_lun(us); | ||
756 | if (p < 0) { | ||
757 | up(&us->dev_semaphore); | ||
758 | return p; | ||
759 | } | ||
760 | us->max_lun = p; | ||
761 | } | ||
762 | |||
763 | /* Just before we start our control thread, initialize | 765 | /* Just before we start our control thread, initialize |
764 | * the device if it needs initialization */ | 766 | * the device if it needs initialization */ |
765 | if (us->unusual_dev->initFunction) | 767 | if (us->unusual_dev->initFunction) { |
766 | us->unusual_dev->initFunction(us); | 768 | p = us->unusual_dev->initFunction(us); |
767 | 769 | if (p) | |
768 | up(&us->dev_semaphore); | 770 | return p; |
771 | } | ||
769 | 772 | ||
770 | /* Start up our control thread */ | 773 | /* Start up our control thread */ |
771 | p = kernel_thread(usb_stor_control_thread, us, CLONE_VM); | 774 | th = kthread_create(usb_stor_control_thread, us, "usb-storage"); |
772 | if (p < 0) { | 775 | if (IS_ERR(th)) { |
773 | printk(KERN_WARNING USB_STORAGE | 776 | printk(KERN_WARNING USB_STORAGE |
774 | "Unable to start control thread\n"); | 777 | "Unable to start control thread\n"); |
775 | return p; | 778 | return PTR_ERR(th); |
776 | } | 779 | } |
777 | us->pid = p; | ||
778 | atomic_inc(&total_threads); | ||
779 | 780 | ||
780 | /* Wait for the thread to start */ | 781 | /* Take a reference to the host for the control thread and |
781 | wait_for_completion(&(us->notify)); | 782 | * count it among all the threads we have launched. Then |
783 | * start it up. */ | ||
784 | scsi_host_get(us_to_host(us)); | ||
785 | atomic_inc(&total_threads); | ||
786 | wake_up_process(th); | ||
782 | 787 | ||
783 | return 0; | 788 | return 0; |
784 | } | 789 | } |
@@ -812,6 +817,8 @@ static void dissociate_dev(struct us_data *us) | |||
812 | { | 817 | { |
813 | US_DEBUGP("-- %s\n", __FUNCTION__); | 818 | US_DEBUGP("-- %s\n", __FUNCTION__); |
814 | 819 | ||
820 | kfree(us->sensebuf); | ||
821 | |||
815 | /* Free the device-related DMA-mapped buffers */ | 822 | /* Free the device-related DMA-mapped buffers */ |
816 | if (us->cr) | 823 | if (us->cr) |
817 | usb_buffer_free(us->pusb_dev, sizeof(*us->cr), us->cr, | 824 | usb_buffer_free(us->pusb_dev, sizeof(*us->cr), us->cr, |
@@ -872,21 +879,6 @@ static int usb_stor_scan_thread(void * __us) | |||
872 | { | 879 | { |
873 | struct us_data *us = (struct us_data *)__us; | 880 | struct us_data *us = (struct us_data *)__us; |
874 | 881 | ||
875 | /* | ||
876 | * This thread doesn't need any user-level access, | ||
877 | * so get rid of all our resources. | ||
878 | */ | ||
879 | lock_kernel(); | ||
880 | daemonize("usb-stor-scan"); | ||
881 | unlock_kernel(); | ||
882 | |||
883 | /* Acquire a reference to the host, so it won't be deallocated | ||
884 | * until we're ready to exit */ | ||
885 | scsi_host_get(us_to_host(us)); | ||
886 | |||
887 | /* Signal that we've started the thread */ | ||
888 | complete(&(us->notify)); | ||
889 | |||
890 | printk(KERN_DEBUG | 882 | printk(KERN_DEBUG |
891 | "usb-storage: device found at %d\n", us->pusb_dev->devnum); | 883 | "usb-storage: device found at %d\n", us->pusb_dev->devnum); |
892 | 884 | ||
@@ -904,6 +896,14 @@ retry: | |||
904 | 896 | ||
905 | /* If the device is still connected, perform the scanning */ | 897 | /* If the device is still connected, perform the scanning */ |
906 | if (!test_bit(US_FLIDX_DISCONNECTING, &us->flags)) { | 898 | if (!test_bit(US_FLIDX_DISCONNECTING, &us->flags)) { |
899 | |||
900 | /* For bulk-only devices, determine the max LUN value */ | ||
901 | if (us->protocol == US_PR_BULK && | ||
902 | !(us->flags & US_FL_SINGLE_LUN)) { | ||
903 | down(&us->dev_semaphore); | ||
904 | us->max_lun = usb_stor_Bulk_max_lun(us); | ||
905 | up(&us->dev_semaphore); | ||
906 | } | ||
907 | scsi_scan_host(us_to_host(us)); | 907 | scsi_scan_host(us_to_host(us)); |
908 | printk(KERN_DEBUG "usb-storage: device scan complete\n"); | 908 | printk(KERN_DEBUG "usb-storage: device scan complete\n"); |
909 | 909 | ||
@@ -923,6 +923,7 @@ static int storage_probe(struct usb_interface *intf, | |||
923 | struct us_data *us; | 923 | struct us_data *us; |
924 | const int id_index = id - storage_usb_ids; | 924 | const int id_index = id - storage_usb_ids; |
925 | int result; | 925 | int result; |
926 | struct task_struct *th; | ||
926 | 927 | ||
927 | US_DEBUGP("USB Mass Storage device detected\n"); | 928 | US_DEBUGP("USB Mass Storage device detected\n"); |
928 | 929 | ||
@@ -1003,17 +1004,21 @@ static int storage_probe(struct usb_interface *intf, | |||
1003 | } | 1004 | } |
1004 | 1005 | ||
1005 | /* Start up the thread for delayed SCSI-device scanning */ | 1006 | /* Start up the thread for delayed SCSI-device scanning */ |
1006 | result = kernel_thread(usb_stor_scan_thread, us, CLONE_VM); | 1007 | th = kthread_create(usb_stor_scan_thread, us, "usb-stor-scan"); |
1007 | if (result < 0) { | 1008 | if (IS_ERR(th)) { |
1008 | printk(KERN_WARNING USB_STORAGE | 1009 | printk(KERN_WARNING USB_STORAGE |
1009 | "Unable to start the device-scanning thread\n"); | 1010 | "Unable to start the device-scanning thread\n"); |
1010 | quiesce_and_remove_host(us); | 1011 | quiesce_and_remove_host(us); |
1012 | result = PTR_ERR(th); | ||
1011 | goto BadDevice; | 1013 | goto BadDevice; |
1012 | } | 1014 | } |
1013 | atomic_inc(&total_threads); | ||
1014 | 1015 | ||
1015 | /* Wait for the thread to start */ | 1016 | /* Take a reference to the host for the scanning thread and |
1016 | wait_for_completion(&(us->notify)); | 1017 | * count it among all the threads we have launched. Then |
1018 | * start it up. */ | ||
1019 | scsi_host_get(us_to_host(us)); | ||
1020 | atomic_inc(&total_threads); | ||
1021 | wake_up_process(th); | ||
1017 | 1022 | ||
1018 | return 0; | 1023 | return 0; |
1019 | 1024 | ||
@@ -1038,6 +1043,18 @@ static void storage_disconnect(struct usb_interface *intf) | |||
1038 | * Initialization and registration | 1043 | * Initialization and registration |
1039 | ***********************************************************************/ | 1044 | ***********************************************************************/ |
1040 | 1045 | ||
1046 | static struct usb_driver usb_storage_driver = { | ||
1047 | .owner = THIS_MODULE, | ||
1048 | .name = "usb-storage", | ||
1049 | .probe = storage_probe, | ||
1050 | .disconnect = storage_disconnect, | ||
1051 | #ifdef CONFIG_PM | ||
1052 | .suspend = storage_suspend, | ||
1053 | .resume = storage_resume, | ||
1054 | #endif | ||
1055 | .id_table = storage_usb_ids, | ||
1056 | }; | ||
1057 | |||
1041 | static int __init usb_stor_init(void) | 1058 | static int __init usb_stor_init(void) |
1042 | { | 1059 | { |
1043 | int retval; | 1060 | int retval; |
diff --git a/drivers/usb/storage/usb.h b/drivers/usb/storage/usb.h index a195adae57b6..98b09711a739 100644 --- a/drivers/usb/storage/usb.h +++ b/drivers/usb/storage/usb.h | |||
@@ -117,6 +117,7 @@ enum { US_DO_ALL_FLAGS }; | |||
117 | */ | 117 | */ |
118 | 118 | ||
119 | #define US_IOBUF_SIZE 64 /* Size of the DMA-mapped I/O buffer */ | 119 | #define US_IOBUF_SIZE 64 /* Size of the DMA-mapped I/O buffer */ |
120 | #define US_SENSE_SIZE 18 /* Size of the autosense data buffer */ | ||
120 | 121 | ||
121 | typedef int (*trans_cmnd)(struct scsi_cmnd *, struct us_data*); | 122 | typedef int (*trans_cmnd)(struct scsi_cmnd *, struct us_data*); |
122 | typedef int (*trans_reset)(struct us_data*); | 123 | typedef int (*trans_reset)(struct us_data*); |
@@ -160,14 +161,12 @@ struct us_data { | |||
160 | struct scsi_cmnd *srb; /* current srb */ | 161 | struct scsi_cmnd *srb; /* current srb */ |
161 | unsigned int tag; /* current dCBWTag */ | 162 | unsigned int tag; /* current dCBWTag */ |
162 | 163 | ||
163 | /* thread information */ | ||
164 | int pid; /* control thread */ | ||
165 | |||
166 | /* control and bulk communications data */ | 164 | /* control and bulk communications data */ |
167 | struct urb *current_urb; /* USB requests */ | 165 | struct urb *current_urb; /* USB requests */ |
168 | struct usb_ctrlrequest *cr; /* control requests */ | 166 | struct usb_ctrlrequest *cr; /* control requests */ |
169 | struct usb_sg_request current_sg; /* scatter-gather req. */ | 167 | struct usb_sg_request current_sg; /* scatter-gather req. */ |
170 | unsigned char *iobuf; /* I/O buffer */ | 168 | unsigned char *iobuf; /* I/O buffer */ |
169 | unsigned char *sensebuf; /* sense data buffer */ | ||
171 | dma_addr_t cr_dma; /* buffer DMA addresses */ | 170 | dma_addr_t cr_dma; /* buffer DMA addresses */ |
172 | dma_addr_t iobuf_dma; | 171 | dma_addr_t iobuf_dma; |
173 | 172 | ||
diff --git a/drivers/usb/usb-skeleton.c b/drivers/usb/usb-skeleton.c index 353f24d45bc1..6c3a53f8f26c 100644 --- a/drivers/usb/usb-skeleton.c +++ b/drivers/usb/usb-skeleton.c | |||
@@ -223,9 +223,8 @@ static struct file_operations skel_fops = { | |||
223 | * and to have the device registered with devfs and the driver core | 223 | * and to have the device registered with devfs and the driver core |
224 | */ | 224 | */ |
225 | static struct usb_class_driver skel_class = { | 225 | static struct usb_class_driver skel_class = { |
226 | .name = "usb/skel%d", | 226 | .name = "skel%d", |
227 | .fops = &skel_fops, | 227 | .fops = &skel_fops, |
228 | .mode = S_IFCHR | S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP | S_IROTH, | ||
229 | .minor_base = USB_SKEL_MINOR_BASE, | 228 | .minor_base = USB_SKEL_MINOR_BASE, |
230 | }; | 229 | }; |
231 | 230 | ||