aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/usb
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/usb')
-rw-r--r--drivers/usb/Makefile2
-rw-r--r--drivers/usb/atm/cxacru.c5
-rw-r--r--drivers/usb/atm/speedtch.c95
-rw-r--r--drivers/usb/atm/ueagle-atm.c85
-rw-r--r--drivers/usb/atm/usbatm.c7
-rw-r--r--drivers/usb/class/cdc-acm.c35
-rw-r--r--drivers/usb/class/usblp.c82
-rw-r--r--drivers/usb/core/devio.c16
-rw-r--r--drivers/usb/core/endpoint.c22
-rw-r--r--drivers/usb/core/hcd.c15
-rw-r--r--drivers/usb/core/hcd.h9
-rw-r--r--drivers/usb/core/hub.c5
-rw-r--r--drivers/usb/core/message.c9
-rw-r--r--drivers/usb/gadget/at91_udc.c4
-rw-r--r--drivers/usb/gadget/dummy_hcd.c2
-rw-r--r--drivers/usb/gadget/goku_udc.c2
-rw-r--r--drivers/usb/gadget/lh7a40x_udc.c2
-rw-r--r--drivers/usb/gadget/net2280.c26
-rw-r--r--drivers/usb/gadget/omap_udc.c9
-rw-r--r--drivers/usb/gadget/pxa2xx_udc.c13
-rw-r--r--drivers/usb/host/ehci-dbg.c4
-rw-r--r--drivers/usb/host/ehci-hcd.c88
-rw-r--r--drivers/usb/host/ehci-hub.c4
-rw-r--r--drivers/usb/host/ehci-pci.c4
-rw-r--r--drivers/usb/host/ehci-q.c27
-rw-r--r--drivers/usb/host/ehci-sched.c21
-rw-r--r--drivers/usb/host/ehci.h22
-rw-r--r--drivers/usb/host/hc_crisv10.c12
-rw-r--r--drivers/usb/host/isp116x-hcd.c16
-rw-r--r--drivers/usb/host/ohci-hcd.c39
-rw-r--r--drivers/usb/host/ohci-hub.c14
-rw-r--r--drivers/usb/host/ohci-pnx4008.c9
-rw-r--r--drivers/usb/host/ohci-q.c16
-rw-r--r--drivers/usb/host/sl811-hcd.c21
-rw-r--r--drivers/usb/host/u132-hcd.c8
-rw-r--r--drivers/usb/host/uhci-hcd.c52
-rw-r--r--drivers/usb/host/uhci-hub.c2
-rw-r--r--drivers/usb/host/uhci-q.c15
-rw-r--r--drivers/usb/image/mdc800.c6
-rw-r--r--drivers/usb/image/microtek.c10
-rw-r--r--drivers/usb/input/Kconfig10
-rw-r--r--drivers/usb/input/Makefile3
-rw-r--r--drivers/usb/input/acecad.c2
-rw-r--r--drivers/usb/input/aiptek.c13
-rw-r--r--drivers/usb/input/appletouch.c2
-rw-r--r--drivers/usb/input/ati_remote.c27
-rw-r--r--drivers/usb/input/ati_remote2.c14
-rw-r--r--drivers/usb/input/hid-core.c101
-rw-r--r--drivers/usb/input/hid-input.c21
-rw-r--r--drivers/usb/input/hid.h5
-rw-r--r--drivers/usb/input/hiddev.c2
-rw-r--r--drivers/usb/input/itmtouch.c14
-rw-r--r--drivers/usb/input/kbtab.c2
-rw-r--r--drivers/usb/input/keyspan_remote.c7
-rw-r--r--drivers/usb/input/mtouchusb.c3
-rw-r--r--drivers/usb/input/powermate.c7
-rw-r--r--drivers/usb/input/touchkitusb.c15
-rw-r--r--drivers/usb/input/usbkbd.c6
-rw-r--r--drivers/usb/input/usbmouse.c4
-rw-r--r--drivers/usb/input/usbtouchscreen.c21
-rw-r--r--drivers/usb/input/wacom.h6
-rw-r--r--drivers/usb/input/wacom_sys.c29
-rw-r--r--drivers/usb/input/wacom_wac.c130
-rw-r--r--drivers/usb/input/wacom_wac.h2
-rw-r--r--drivers/usb/input/xpad.c186
-rw-r--r--drivers/usb/input/yealink.c9
-rw-r--r--drivers/usb/misc/Kconfig10
-rw-r--r--drivers/usb/misc/Makefile1
-rw-r--r--drivers/usb/misc/adutux.c7
-rw-r--r--drivers/usb/misc/appledisplay.c2
-rw-r--r--drivers/usb/misc/auerswald.c32
-rw-r--r--drivers/usb/misc/ftdi-elan.c38
-rw-r--r--drivers/usb/misc/ldusb.c4
-rw-r--r--drivers/usb/misc/legousbtower.c8
-rw-r--r--drivers/usb/misc/phidgetkit.c2
-rw-r--r--drivers/usb/misc/phidgetmotorcontrol.c2
-rw-r--r--drivers/usb/misc/sisusbvga/sisusb.c4
-rw-r--r--drivers/usb/misc/trancevibrator.c (renamed from drivers/usb/input/trancevibrator.c)0
-rw-r--r--drivers/usb/misc/usblcd.c2
-rw-r--r--drivers/usb/misc/usbtest.c8
-rw-r--r--drivers/usb/misc/uss720.c4
-rw-r--r--drivers/usb/net/Kconfig16
-rw-r--r--drivers/usb/net/Makefile1
-rw-r--r--drivers/usb/net/asix.c50
-rw-r--r--drivers/usb/net/catc.c8
-rw-r--r--drivers/usb/net/cdc_ether.c2
-rw-r--r--drivers/usb/net/gl620a.c2
-rw-r--r--drivers/usb/net/kaweth.c214
-rw-r--r--drivers/usb/net/mcs7830.c534
-rw-r--r--drivers/usb/net/net1080.c2
-rw-r--r--drivers/usb/net/pegasus.c14
-rw-r--r--drivers/usb/net/rtl8150.c12
-rw-r--r--drivers/usb/net/usbnet.c91
-rw-r--r--drivers/usb/net/usbnet.h5
-rw-r--r--drivers/usb/serial/Kconfig17
-rw-r--r--drivers/usb/serial/Makefile1
-rw-r--r--drivers/usb/serial/aircable.c4
-rw-r--r--drivers/usb/serial/airprime.c11
-rw-r--r--drivers/usb/serial/belkin_sa.c4
-rw-r--r--drivers/usb/serial/cp2101.c4
-rw-r--r--drivers/usb/serial/cyberjack.c12
-rw-r--r--drivers/usb/serial/cypress_m8.c8
-rw-r--r--drivers/usb/serial/digi_acceleport.c8
-rw-r--r--drivers/usb/serial/empeg.c8
-rw-r--r--drivers/usb/serial/ftdi_sio.c264
-rw-r--r--drivers/usb/serial/ftdi_sio.h11
-rw-r--r--drivers/usb/serial/garmin_gps.c6
-rw-r--r--drivers/usb/serial/generic.c4
-rw-r--r--drivers/usb/serial/io_edgeport.c16
-rw-r--r--drivers/usb/serial/io_ti.c6
-rw-r--r--drivers/usb/serial/ipaq.c9
-rw-r--r--drivers/usb/serial/ipw.c4
-rw-r--r--drivers/usb/serial/ir-usb.c8
-rw-r--r--drivers/usb/serial/keyspan.c52
-rw-r--r--drivers/usb/serial/keyspan_pda.c4
-rw-r--r--drivers/usb/serial/kl5kusb105.c8
-rw-r--r--drivers/usb/serial/kobil_sct.c8
-rw-r--r--drivers/usb/serial/mct_u232.c4
-rw-r--r--drivers/usb/serial/mos7720.c1683
-rw-r--r--drivers/usb/serial/mos7840.c58
-rw-r--r--drivers/usb/serial/navman.c2
-rw-r--r--drivers/usb/serial/omninet.c8
-rw-r--r--drivers/usb/serial/option.c10
-rw-r--r--drivers/usb/serial/pl2303.c6
-rw-r--r--drivers/usb/serial/safe_serial.c2
-rw-r--r--drivers/usb/serial/sierra.c700
-rw-r--r--drivers/usb/serial/ti_usb_3410_5052.c12
-rw-r--r--drivers/usb/serial/visor.c12
-rw-r--r--drivers/usb/serial/whiteheat.c16
-rw-r--r--drivers/usb/storage/onetouch.c3
-rw-r--r--drivers/usb/storage/transport.c2
-rw-r--r--drivers/usb/storage/unusual_devs.h23
-rw-r--r--drivers/usb/usb-skeleton.c2
133 files changed, 4399 insertions, 1172 deletions
diff --git a/drivers/usb/Makefile b/drivers/usb/Makefile
index 97d57cfc343b..825bf884537a 100644
--- a/drivers/usb/Makefile
+++ b/drivers/usb/Makefile
@@ -33,7 +33,6 @@ obj-$(CONFIG_USB_KBTAB) += input/
33obj-$(CONFIG_USB_MOUSE) += input/ 33obj-$(CONFIG_USB_MOUSE) += input/
34obj-$(CONFIG_USB_MTOUCH) += input/ 34obj-$(CONFIG_USB_MTOUCH) += input/
35obj-$(CONFIG_USB_POWERMATE) += input/ 35obj-$(CONFIG_USB_POWERMATE) += input/
36obj-$(CONFIG_USB_TRANCEVIBRATOR)+= input/
37obj-$(CONFIG_USB_WACOM) += input/ 36obj-$(CONFIG_USB_WACOM) += input/
38obj-$(CONFIG_USB_XPAD) += input/ 37obj-$(CONFIG_USB_XPAD) += input/
39 38
@@ -66,6 +65,7 @@ obj-$(CONFIG_USB_PHIDGETSERVO) += misc/
66obj-$(CONFIG_USB_RIO500) += misc/ 65obj-$(CONFIG_USB_RIO500) += misc/
67obj-$(CONFIG_USB_SISUSBVGA) += misc/ 66obj-$(CONFIG_USB_SISUSBVGA) += misc/
68obj-$(CONFIG_USB_TEST) += misc/ 67obj-$(CONFIG_USB_TEST) += misc/
68obj-$(CONFIG_USB_TRANCEVIBRATOR)+= misc/
69obj-$(CONFIG_USB_USS720) += misc/ 69obj-$(CONFIG_USB_USS720) += misc/
70 70
71obj-$(CONFIG_USB_ATM) += atm/ 71obj-$(CONFIG_USB_ATM) += atm/
diff --git a/drivers/usb/atm/cxacru.c b/drivers/usb/atm/cxacru.c
index 04631dcbabbc..e6565633ba0f 100644
--- a/drivers/usb/atm/cxacru.c
+++ b/drivers/usb/atm/cxacru.c
@@ -171,7 +171,7 @@ struct cxacru_data {
171}; 171};
172 172
173/* the following three functions are stolen from drivers/usb/core/message.c */ 173/* the following three functions are stolen from drivers/usb/core/message.c */
174static void cxacru_blocking_completion(struct urb *urb, struct pt_regs *regs) 174static void cxacru_blocking_completion(struct urb *urb)
175{ 175{
176 complete((struct completion *)urb->context); 176 complete((struct completion *)urb->context);
177} 177}
@@ -793,6 +793,9 @@ static const struct usb_device_id cxacru_usb_ids[] = {
793 { /* V = Conexant P = ADSL modem */ 793 { /* V = Conexant P = ADSL modem */
794 USB_DEVICE(0x0572, 0xcb06), .driver_info = (unsigned long) &cxacru_cb00 794 USB_DEVICE(0x0572, 0xcb06), .driver_info = (unsigned long) &cxacru_cb00
795 }, 795 },
796 { /* V = Conexant P = ADSL modem (ZTE ZXDSL 852) */
797 USB_DEVICE(0x0572, 0xcb07), .driver_info = (unsigned long) &cxacru_cb00
798 },
796 { /* V = Olitec P = ADSL modem version 2 */ 799 { /* V = Olitec P = ADSL modem version 2 */
797 USB_DEVICE(0x08e3, 0x0100), .driver_info = (unsigned long) &cxacru_cafe 800 USB_DEVICE(0x08e3, 0x0100), .driver_info = (unsigned long) &cxacru_cafe
798 }, 801 },
diff --git a/drivers/usb/atm/speedtch.c b/drivers/usb/atm/speedtch.c
index 956b7a1e8af9..c870c804470f 100644
--- a/drivers/usb/atm/speedtch.c
+++ b/drivers/usb/atm/speedtch.c
@@ -55,7 +55,6 @@ static const char speedtch_driver_name[] = "speedtch";
55#define OFFSET_d 9 /* size 4 */ 55#define OFFSET_d 9 /* size 4 */
56#define OFFSET_e 13 /* size 1 */ 56#define OFFSET_e 13 /* size 1 */
57#define OFFSET_f 14 /* size 1 */ 57#define OFFSET_f 14 /* size 1 */
58#define TOTAL 15
59 58
60#define SIZE_7 1 59#define SIZE_7 1
61#define SIZE_b 8 60#define SIZE_b 8
@@ -79,6 +78,18 @@ static int dl_512_first = DEFAULT_DL_512_FIRST;
79static int enable_isoc = DEFAULT_ENABLE_ISOC; 78static int enable_isoc = DEFAULT_ENABLE_ISOC;
80static int sw_buffering = DEFAULT_SW_BUFFERING; 79static int sw_buffering = DEFAULT_SW_BUFFERING;
81 80
81#define DEFAULT_B_MAX_DSL 8128
82#define DEFAULT_MODEM_MODE 11
83#define MODEM_OPTION_LENGTH 16
84static const unsigned char DEFAULT_MODEM_OPTION[MODEM_OPTION_LENGTH] = {
85 0x10, 0x00, 0x00, 0x00, 0x20, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
86};
87
88static unsigned int BMaxDSL = DEFAULT_B_MAX_DSL;
89static unsigned char ModemMode = DEFAULT_MODEM_MODE;
90static unsigned char ModemOption[MODEM_OPTION_LENGTH];
91static int num_ModemOption;
92
82module_param(altsetting, uint, S_IRUGO | S_IWUSR); 93module_param(altsetting, uint, S_IRUGO | S_IWUSR);
83MODULE_PARM_DESC(altsetting, 94MODULE_PARM_DESC(altsetting,
84 "Alternative setting for data interface (bulk_default: " 95 "Alternative setting for data interface (bulk_default: "
@@ -100,6 +111,17 @@ MODULE_PARM_DESC(sw_buffering,
100 "Enable software buffering (default: " 111 "Enable software buffering (default: "
101 __MODULE_STRING(DEFAULT_SW_BUFFERING) ")"); 112 __MODULE_STRING(DEFAULT_SW_BUFFERING) ")");
102 113
114module_param(BMaxDSL, uint, S_IRUGO | S_IWUSR);
115MODULE_PARM_DESC(BMaxDSL,
116 "default: " __MODULE_STRING(DEFAULT_B_MAX_DSL));
117
118module_param(ModemMode, byte, S_IRUGO | S_IWUSR);
119MODULE_PARM_DESC(ModemMode,
120 "default: " __MODULE_STRING(DEFAULT_MODEM_MODE));
121
122module_param_array(ModemOption, byte, &num_ModemOption, S_IRUGO);
123MODULE_PARM_DESC(ModemOption, "default: 0x10,0x00,0x00,0x00,0x20");
124
103#define INTERFACE_DATA 1 125#define INTERFACE_DATA 1
104#define ENDPOINT_INT 0x81 126#define ENDPOINT_INT 0x81
105#define ENDPOINT_BULK_DATA 0x07 127#define ENDPOINT_BULK_DATA 0x07
@@ -108,10 +130,17 @@ MODULE_PARM_DESC(sw_buffering,
108 130
109#define hex2int(c) ( (c >= '0') && (c <= '9') ? (c - '0') : ((c & 0xf) + 9) ) 131#define hex2int(c) ( (c >= '0') && (c <= '9') ? (c - '0') : ((c & 0xf) + 9) )
110 132
133struct speedtch_params {
134 unsigned int altsetting;
135 unsigned int BMaxDSL;
136 unsigned char ModemMode;
137 unsigned char ModemOption[MODEM_OPTION_LENGTH];
138};
139
111struct speedtch_instance_data { 140struct speedtch_instance_data {
112 struct usbatm_data *usbatm; 141 struct usbatm_data *usbatm;
113 142
114 unsigned int altsetting; 143 struct speedtch_params params; /* set in probe, constant afterwards */
115 144
116 struct work_struct status_checker; 145 struct work_struct status_checker;
117 146
@@ -123,7 +152,7 @@ struct speedtch_instance_data {
123 struct urb *int_urb; 152 struct urb *int_urb;
124 unsigned char int_data[16]; 153 unsigned char int_data[16];
125 154
126 unsigned char scratch_buffer[TOTAL]; 155 unsigned char scratch_buffer[16];
127}; 156};
128 157
129/*************** 158/***************
@@ -186,6 +215,34 @@ static void speedtch_test_sequence(struct speedtch_instance_data *instance)
186 0x01, 0x40, 0x04, 0x00, buf, 3, CTRL_TIMEOUT); 215 0x01, 0x40, 0x04, 0x00, buf, 3, CTRL_TIMEOUT);
187 if (ret < 0) 216 if (ret < 0)
188 usb_warn(usbatm, "%s failed on URB150: %d\n", __func__, ret); 217 usb_warn(usbatm, "%s failed on URB150: %d\n", __func__, ret);
218
219 /* Extra initialisation in recent drivers - gives higher speeds */
220
221 /* URBext1 */
222 buf[0] = instance->params.ModemMode;
223 ret = usb_control_msg(usb_dev, usb_sndctrlpipe(usb_dev, 0),
224 0x01, 0x40, 0x11, 0x00, buf, 1, CTRL_TIMEOUT);
225 if (ret < 0)
226 usb_warn(usbatm, "%s failed on URBext1: %d\n", __func__, ret);
227
228 /* URBext2 */
229 /* This seems to be the one which actually triggers the higher sync
230 rate -- it does require the new firmware too, although it works OK
231 with older firmware */
232 ret = usb_control_msg(usb_dev, usb_sndctrlpipe(usb_dev, 0),
233 0x01, 0x40, 0x14, 0x00,
234 instance->params.ModemOption,
235 MODEM_OPTION_LENGTH, CTRL_TIMEOUT);
236 if (ret < 0)
237 usb_warn(usbatm, "%s failed on URBext2: %d\n", __func__, ret);
238
239 /* URBext3 */
240 buf[0] = instance->params.BMaxDSL & 0xff;
241 buf[1] = instance->params.BMaxDSL >> 8;
242 ret = usb_control_msg(usb_dev, usb_sndctrlpipe(usb_dev, 0),
243 0x01, 0x40, 0x12, 0x00, buf, 2, CTRL_TIMEOUT);
244 if (ret < 0)
245 usb_warn(usbatm, "%s failed on URBext3: %d\n", __func__, ret);
189} 246}
190 247
191static int speedtch_upload_firmware(struct speedtch_instance_data *instance, 248static int speedtch_upload_firmware(struct speedtch_instance_data *instance,
@@ -285,8 +342,8 @@ static int speedtch_upload_firmware(struct speedtch_instance_data *instance,
285 because we're in our own kernel thread anyway. */ 342 because we're in our own kernel thread anyway. */
286 msleep_interruptible(1000); 343 msleep_interruptible(1000);
287 344
288 if ((ret = usb_set_interface(usb_dev, INTERFACE_DATA, instance->altsetting)) < 0) { 345 if ((ret = usb_set_interface(usb_dev, INTERFACE_DATA, instance->params.altsetting)) < 0) {
289 usb_err(usbatm, "%s: setting interface to %d failed (%d)!\n", __func__, instance->altsetting, ret); 346 usb_err(usbatm, "%s: setting interface to %d failed (%d)!\n", __func__, instance->params.altsetting, ret);
290 goto out_free; 347 goto out_free;
291 } 348 }
292 349
@@ -372,7 +429,7 @@ static int speedtch_read_status(struct speedtch_instance_data *instance)
372 unsigned char *buf = instance->scratch_buffer; 429 unsigned char *buf = instance->scratch_buffer;
373 int ret; 430 int ret;
374 431
375 memset(buf, 0, TOTAL); 432 memset(buf, 0, 16);
376 433
377 ret = usb_control_msg(usb_dev, usb_rcvctrlpipe(usb_dev, 0), 434 ret = usb_control_msg(usb_dev, usb_rcvctrlpipe(usb_dev, 0),
378 0x12, 0xc0, 0x07, 0x00, buf + OFFSET_7, SIZE_7, 435 0x12, 0xc0, 0x07, 0x00, buf + OFFSET_7, SIZE_7,
@@ -547,7 +604,7 @@ static void speedtch_resubmit_int(unsigned long data)
547 } 604 }
548} 605}
549 606
550static void speedtch_handle_int(struct urb *int_urb, struct pt_regs *regs) 607static void speedtch_handle_int(struct urb *int_urb)
551{ 608{
552 struct speedtch_instance_data *instance = int_urb->context; 609 struct speedtch_instance_data *instance = int_urb->context;
553 struct usbatm_data *usbatm = instance->usbatm; 610 struct usbatm_data *usbatm = instance->usbatm;
@@ -746,17 +803,21 @@ static int speedtch_bind(struct usbatm_data *usbatm,
746 803
747 instance->usbatm = usbatm; 804 instance->usbatm = usbatm;
748 805
749 /* altsetting and enable_isoc may change at any moment, so take a snapshot */ 806 /* module parameters may change at any moment, so take a snapshot */
750 instance->altsetting = altsetting; 807 instance->params.altsetting = altsetting;
808 instance->params.BMaxDSL = BMaxDSL;
809 instance->params.ModemMode = ModemMode;
810 memcpy(instance->params.ModemOption, DEFAULT_MODEM_OPTION, MODEM_OPTION_LENGTH);
811 memcpy(instance->params.ModemOption, ModemOption, num_ModemOption);
751 use_isoc = enable_isoc; 812 use_isoc = enable_isoc;
752 813
753 if (instance->altsetting) 814 if (instance->params.altsetting)
754 if ((ret = usb_set_interface(usb_dev, INTERFACE_DATA, instance->altsetting)) < 0) { 815 if ((ret = usb_set_interface(usb_dev, INTERFACE_DATA, instance->params.altsetting)) < 0) {
755 usb_err(usbatm, "%s: setting interface to %2d failed (%d)!\n", __func__, instance->altsetting, ret); 816 usb_err(usbatm, "%s: setting interface to %2d failed (%d)!\n", __func__, instance->params.altsetting, ret);
756 instance->altsetting = 0; /* fall back to default */ 817 instance->params.altsetting = 0; /* fall back to default */
757 } 818 }
758 819
759 if (!instance->altsetting && use_isoc) 820 if (!instance->params.altsetting && use_isoc)
760 if ((ret = usb_set_interface(usb_dev, INTERFACE_DATA, DEFAULT_ISOC_ALTSETTING)) < 0) { 821 if ((ret = usb_set_interface(usb_dev, INTERFACE_DATA, DEFAULT_ISOC_ALTSETTING)) < 0) {
761 usb_dbg(usbatm, "%s: setting interface to %2d failed (%d)!\n", __func__, DEFAULT_ISOC_ALTSETTING, ret); 822 usb_dbg(usbatm, "%s: setting interface to %2d failed (%d)!\n", __func__, DEFAULT_ISOC_ALTSETTING, ret);
762 use_isoc = 0; /* fall back to bulk */ 823 use_isoc = 0; /* fall back to bulk */
@@ -783,14 +844,14 @@ static int speedtch_bind(struct usbatm_data *usbatm,
783 usb_info(usbatm, "isochronous transfer not supported - using bulk\n"); 844 usb_info(usbatm, "isochronous transfer not supported - using bulk\n");
784 } 845 }
785 846
786 if (!use_isoc && !instance->altsetting) 847 if (!use_isoc && !instance->params.altsetting)
787 if ((ret = usb_set_interface(usb_dev, INTERFACE_DATA, DEFAULT_BULK_ALTSETTING)) < 0) { 848 if ((ret = usb_set_interface(usb_dev, INTERFACE_DATA, DEFAULT_BULK_ALTSETTING)) < 0) {
788 usb_err(usbatm, "%s: setting interface to %2d failed (%d)!\n", __func__, DEFAULT_BULK_ALTSETTING, ret); 849 usb_err(usbatm, "%s: setting interface to %2d failed (%d)!\n", __func__, DEFAULT_BULK_ALTSETTING, ret);
789 goto fail_free; 850 goto fail_free;
790 } 851 }
791 852
792 if (!instance->altsetting) 853 if (!instance->params.altsetting)
793 instance->altsetting = use_isoc ? DEFAULT_ISOC_ALTSETTING : DEFAULT_BULK_ALTSETTING; 854 instance->params.altsetting = use_isoc ? DEFAULT_ISOC_ALTSETTING : DEFAULT_BULK_ALTSETTING;
794 855
795 usbatm->flags |= (use_isoc ? UDSL_USE_ISOC : 0); 856 usbatm->flags |= (use_isoc ? UDSL_USE_ISOC : 0);
796 857
diff --git a/drivers/usb/atm/ueagle-atm.c b/drivers/usb/atm/ueagle-atm.c
index 465961a26e4a..f6b9f7e1f716 100644
--- a/drivers/usb/atm/ueagle-atm.c
+++ b/drivers/usb/atm/ueagle-atm.c
@@ -68,7 +68,7 @@
68 68
69#include "usbatm.h" 69#include "usbatm.h"
70 70
71#define EAGLEUSBVERSION "ueagle 1.3" 71#define EAGLEUSBVERSION "ueagle 1.4"
72 72
73 73
74/* 74/*
@@ -80,14 +80,14 @@
80 dev_dbg(&(usb_dev)->dev, \ 80 dev_dbg(&(usb_dev)->dev, \
81 "[ueagle-atm dbg] %s: " format, \ 81 "[ueagle-atm dbg] %s: " format, \
82 __FUNCTION__, ##args); \ 82 __FUNCTION__, ##args); \
83 } while (0) 83 } while (0)
84 84
85#define uea_vdbg(usb_dev, format, args...) \ 85#define uea_vdbg(usb_dev, format, args...) \
86 do { \ 86 do { \
87 if (debug >= 2) \ 87 if (debug >= 2) \
88 dev_dbg(&(usb_dev)->dev, \ 88 dev_dbg(&(usb_dev)->dev, \
89 "[ueagle-atm vdbg] " format, ##args); \ 89 "[ueagle-atm vdbg] " format, ##args); \
90 } while (0) 90 } while (0)
91 91
92#define uea_enters(usb_dev) \ 92#define uea_enters(usb_dev) \
93 uea_vdbg(usb_dev, "entering %s\n", __FUNCTION__) 93 uea_vdbg(usb_dev, "entering %s\n", __FUNCTION__)
@@ -218,8 +218,8 @@ enum {
218#define UEA_CHIP_VERSION(x) \ 218#define UEA_CHIP_VERSION(x) \
219 ((x)->driver_info & 0xf) 219 ((x)->driver_info & 0xf)
220 220
221#define IS_ISDN(sc) \ 221#define IS_ISDN(usb_dev) \
222 (le16_to_cpu(sc->usb_dev->descriptor.bcdDevice) & 0x80) 222 (le16_to_cpu((usb_dev)->descriptor.bcdDevice) & 0x80)
223 223
224#define INS_TO_USBDEV(ins) ins->usb_dev 224#define INS_TO_USBDEV(ins) ins->usb_dev
225 225
@@ -625,12 +625,12 @@ static int request_dsp(struct uea_softc *sc)
625 char *dsp_name; 625 char *dsp_name;
626 626
627 if (UEA_CHIP_VERSION(sc) == ADI930) { 627 if (UEA_CHIP_VERSION(sc) == ADI930) {
628 if (IS_ISDN(sc)) 628 if (IS_ISDN(sc->usb_dev))
629 dsp_name = FW_DIR "DSP9i.bin"; 629 dsp_name = FW_DIR "DSP9i.bin";
630 else 630 else
631 dsp_name = FW_DIR "DSP9p.bin"; 631 dsp_name = FW_DIR "DSP9p.bin";
632 } else { 632 } else {
633 if (IS_ISDN(sc)) 633 if (IS_ISDN(sc->usb_dev))
634 dsp_name = FW_DIR "DSPei.bin"; 634 dsp_name = FW_DIR "DSPei.bin";
635 else 635 else
636 dsp_name = FW_DIR "DSPep.bin"; 636 dsp_name = FW_DIR "DSPep.bin";
@@ -744,7 +744,7 @@ static inline void wake_up_cmv_ack(struct uea_softc *sc)
744 744
745static inline int wait_cmv_ack(struct uea_softc *sc) 745static inline int wait_cmv_ack(struct uea_softc *sc)
746{ 746{
747 int ret = wait_event_timeout(sc->cmv_ack_wait, 747 int ret = wait_event_interruptible_timeout(sc->cmv_ack_wait,
748 sc->cmv_ack, ACK_TIMEOUT); 748 sc->cmv_ack, ACK_TIMEOUT);
749 sc->cmv_ack = 0; 749 sc->cmv_ack = 0;
750 750
@@ -885,7 +885,8 @@ static int uea_stat(struct uea_softc *sc)
885 break; 885 break;
886 886
887 case 3: /* fail ... */ 887 case 3: /* fail ... */
888 uea_info(INS_TO_USBDEV(sc), "modem synchronization failed\n"); 888 uea_info(INS_TO_USBDEV(sc), "modem synchronization failed"
889 " (may be try other cmv/dsp)\n");
889 return -EAGAIN; 890 return -EAGAIN;
890 891
891 case 4 ... 6: /* test state */ 892 case 4 ... 6: /* test state */
@@ -913,12 +914,6 @@ static int uea_stat(struct uea_softc *sc)
913 release_firmware(sc->dsp_firm); 914 release_firmware(sc->dsp_firm);
914 sc->dsp_firm = NULL; 915 sc->dsp_firm = NULL;
915 } 916 }
916
917 ret = uea_read_cmv(sc, SA_INFO, 10, &sc->stats.phy.firmid);
918 if (ret < 0)
919 return ret;
920 uea_info(INS_TO_USBDEV(sc), "ATU-R firmware version : %x\n",
921 sc->stats.phy.firmid);
922 } 917 }
923 918
924 /* always update it as atm layer could not be init when we switch to 919 /* always update it as atm layer could not be init when we switch to
@@ -1033,9 +1028,9 @@ static int request_cmvs(struct uea_softc *sc,
1033 1028
1034 if (cmv_file[sc->modem_index] == NULL) { 1029 if (cmv_file[sc->modem_index] == NULL) {
1035 if (UEA_CHIP_VERSION(sc) == ADI930) 1030 if (UEA_CHIP_VERSION(sc) == ADI930)
1036 file = (IS_ISDN(sc)) ? "CMV9i.bin" : "CMV9p.bin"; 1031 file = (IS_ISDN(sc->usb_dev)) ? "CMV9i.bin" : "CMV9p.bin";
1037 else 1032 else
1038 file = (IS_ISDN(sc)) ? "CMVei.bin" : "CMVep.bin"; 1033 file = (IS_ISDN(sc->usb_dev)) ? "CMVei.bin" : "CMVep.bin";
1039 } else 1034 } else
1040 file = cmv_file[sc->modem_index]; 1035 file = cmv_file[sc->modem_index];
1041 1036
@@ -1131,6 +1126,13 @@ static int uea_start_reset(struct uea_softc *sc)
1131 if (ret < 0) 1126 if (ret < 0)
1132 return ret; 1127 return ret;
1133 1128
1129 /* Dump firmware version */
1130 ret = uea_read_cmv(sc, SA_INFO, 10, &sc->stats.phy.firmid);
1131 if (ret < 0)
1132 return ret;
1133 uea_info(INS_TO_USBDEV(sc), "ATU-R firmware version : %x\n",
1134 sc->stats.phy.firmid);
1135
1134 /* get options */ 1136 /* get options */
1135 ret = len = request_cmvs(sc, &cmvs, &cmvs_fw); 1137 ret = len = request_cmvs(sc, &cmvs, &cmvs_fw);
1136 if (ret < 0) 1138 if (ret < 0)
@@ -1147,6 +1149,8 @@ static int uea_start_reset(struct uea_softc *sc)
1147 /* Enter in R-ACT-REQ */ 1149 /* Enter in R-ACT-REQ */
1148 ret = uea_write_cmv(sc, SA_CNTL, 0, 2); 1150 ret = uea_write_cmv(sc, SA_CNTL, 0, 2);
1149 uea_vdbg(INS_TO_USBDEV(sc), "Entering in R-ACT-REQ state\n"); 1151 uea_vdbg(INS_TO_USBDEV(sc), "Entering in R-ACT-REQ state\n");
1152 uea_info(INS_TO_USBDEV(sc), "Modem started, "
1153 "waiting synchronization\n");
1150out: 1154out:
1151 release_firmware(cmvs_fw); 1155 release_firmware(cmvs_fw);
1152 sc->reset = 0; 1156 sc->reset = 0;
@@ -1172,7 +1176,10 @@ static int uea_kthread(void *data)
1172 if (!ret) 1176 if (!ret)
1173 ret = uea_stat(sc); 1177 ret = uea_stat(sc);
1174 if (ret != -EAGAIN) 1178 if (ret != -EAGAIN)
1175 msleep(1000); 1179 msleep_interruptible(1000);
1180 if (try_to_freeze())
1181 uea_err(INS_TO_USBDEV(sc), "suspend/resume not supported, "
1182 "please unplug/replug your modem\n");
1176 } 1183 }
1177 uea_leaves(INS_TO_USBDEV(sc)); 1184 uea_leaves(INS_TO_USBDEV(sc));
1178 return ret; 1185 return ret;
@@ -1297,7 +1304,7 @@ bad1:
1297/* 1304/*
1298 * interrupt handler 1305 * interrupt handler
1299 */ 1306 */
1300static void uea_intr(struct urb *urb, struct pt_regs *regs) 1307static void uea_intr(struct urb *urb)
1301{ 1308{
1302 struct uea_softc *sc = urb->context; 1309 struct uea_softc *sc = urb->context;
1303 struct intr_pkt *intr = urb->transfer_buffer; 1310 struct intr_pkt *intr = urb->transfer_buffer;
@@ -1566,6 +1573,7 @@ UEA_ATTR(uscorr, 0);
1566UEA_ATTR(dscorr, 0); 1573UEA_ATTR(dscorr, 0);
1567UEA_ATTR(usunc, 0); 1574UEA_ATTR(usunc, 0);
1568UEA_ATTR(dsunc, 0); 1575UEA_ATTR(dsunc, 0);
1576UEA_ATTR(firmid, 0);
1569 1577
1570/* Retrieve the device End System Identifier (MAC) */ 1578/* Retrieve the device End System Identifier (MAC) */
1571 1579
@@ -1597,7 +1605,7 @@ static int uea_heavy(struct usbatm_data *usbatm, struct usb_interface *intf)
1597{ 1605{
1598 struct uea_softc *sc = usbatm->driver_data; 1606 struct uea_softc *sc = usbatm->driver_data;
1599 1607
1600 wait_event(sc->sync_q, IS_OPERATIONAL(sc)); 1608 wait_event_interruptible(sc->sync_q, IS_OPERATIONAL(sc));
1601 1609
1602 return 0; 1610 return 0;
1603 1611
@@ -1639,16 +1647,13 @@ static struct attribute *attrs[] = {
1639 &dev_attr_stat_dscorr.attr, 1647 &dev_attr_stat_dscorr.attr,
1640 &dev_attr_stat_usunc.attr, 1648 &dev_attr_stat_usunc.attr,
1641 &dev_attr_stat_dsunc.attr, 1649 &dev_attr_stat_dsunc.attr,
1650 &dev_attr_stat_firmid.attr,
1651 NULL,
1642}; 1652};
1643static struct attribute_group attr_grp = { 1653static struct attribute_group attr_grp = {
1644 .attrs = attrs, 1654 .attrs = attrs,
1645}; 1655};
1646 1656
1647static int create_fs_entries(struct usb_interface *intf)
1648{
1649 return sysfs_create_group(&intf->dev.kobj, &attr_grp);
1650}
1651
1652static int uea_bind(struct usbatm_data *usbatm, struct usb_interface *intf, 1657static int uea_bind(struct usbatm_data *usbatm, struct usb_interface *intf,
1653 const struct usb_device_id *id) 1658 const struct usb_device_id *id)
1654{ 1659{
@@ -1708,31 +1713,25 @@ static int uea_bind(struct usbatm_data *usbatm, struct usb_interface *intf,
1708 } 1713 }
1709 } 1714 }
1710 1715
1716 ret = sysfs_create_group(&intf->dev.kobj, &attr_grp);
1717 if (ret < 0)
1718 goto error;
1719
1711 ret = uea_boot(sc); 1720 ret = uea_boot(sc);
1712 if (ret < 0) { 1721 if (ret < 0)
1713 kfree(sc); 1722 goto error;
1714 return ret;
1715 }
1716 1723
1717 ret = create_fs_entries(intf);
1718 if (ret) {
1719 uea_stop(sc);
1720 kfree(sc);
1721 return ret;
1722 }
1723 return 0; 1724 return 0;
1724} 1725error:
1725 1726 kfree(sc);
1726static void destroy_fs_entries(struct usb_interface *intf) 1727 return ret;
1727{
1728 sysfs_remove_group(&intf->dev.kobj, &attr_grp);
1729} 1728}
1730 1729
1731static void uea_unbind(struct usbatm_data *usbatm, struct usb_interface *intf) 1730static void uea_unbind(struct usbatm_data *usbatm, struct usb_interface *intf)
1732{ 1731{
1733 struct uea_softc *sc = usbatm->driver_data; 1732 struct uea_softc *sc = usbatm->driver_data;
1734 1733
1735 destroy_fs_entries(intf); 1734 sysfs_remove_group(&intf->dev.kobj, &attr_grp);
1736 uea_stop(sc); 1735 uea_stop(sc);
1737 kfree(sc); 1736 kfree(sc);
1738} 1737}
@@ -1753,10 +1752,10 @@ static int uea_probe(struct usb_interface *intf, const struct usb_device_id *id)
1753 struct usb_device *usb = interface_to_usbdev(intf); 1752 struct usb_device *usb = interface_to_usbdev(intf);
1754 1753
1755 uea_enters(usb); 1754 uea_enters(usb);
1756 uea_info(usb, "ADSL device founded vid (%#X) pid (%#X) : %s\n", 1755 uea_info(usb, "ADSL device founded vid (%#X) pid (%#X) : %s %s\n",
1757 le16_to_cpu(usb->descriptor.idVendor), 1756 le16_to_cpu(usb->descriptor.idVendor),
1758 le16_to_cpu(usb->descriptor.idProduct), 1757 le16_to_cpu(usb->descriptor.idProduct),
1759 chip_name[UEA_CHIP_VERSION(id)]); 1758 chip_name[UEA_CHIP_VERSION(id)], IS_ISDN(usb)?"isdn":"pots");
1760 1759
1761 usb_reset_device(usb); 1760 usb_reset_device(usb);
1762 1761
diff --git a/drivers/usb/atm/usbatm.c b/drivers/usb/atm/usbatm.c
index a38701c742c3..ec63b0ee0743 100644
--- a/drivers/usb/atm/usbatm.c
+++ b/drivers/usb/atm/usbatm.c
@@ -254,7 +254,7 @@ static int usbatm_submit_urb(struct urb *urb)
254 return ret; 254 return ret;
255} 255}
256 256
257static void usbatm_complete(struct urb *urb, struct pt_regs *regs) 257static void usbatm_complete(struct urb *urb)
258{ 258{
259 struct usbatm_channel *channel = urb->context; 259 struct usbatm_channel *channel = urb->context;
260 unsigned long flags; 260 unsigned long flags;
@@ -1001,6 +1001,7 @@ static int usbatm_do_heavy_init(void *arg)
1001 1001
1002 daemonize(instance->driver->driver_name); 1002 daemonize(instance->driver->driver_name);
1003 allow_signal(SIGTERM); 1003 allow_signal(SIGTERM);
1004 instance->thread_pid = current->pid;
1004 1005
1005 complete(&instance->thread_started); 1006 complete(&instance->thread_started);
1006 1007
@@ -1025,10 +1026,6 @@ static int usbatm_heavy_init(struct usbatm_data *instance)
1025 return ret; 1026 return ret;
1026 } 1027 }
1027 1028
1028 mutex_lock(&instance->serialize);
1029 instance->thread_pid = ret;
1030 mutex_unlock(&instance->serialize);
1031
1032 wait_for_completion(&instance->thread_started); 1029 wait_for_completion(&instance->thread_started);
1033 1030
1034 return 0; 1031 return 0;
diff --git a/drivers/usb/class/cdc-acm.c b/drivers/usb/class/cdc-acm.c
index 71288295df2f..9a9012fd284b 100644
--- a/drivers/usb/class/cdc-acm.c
+++ b/drivers/usb/class/cdc-acm.c
@@ -218,7 +218,7 @@ static int acm_write_start(struct acm *acm)
218 */ 218 */
219 219
220/* control interface reports status changes with "interrupt" transfers */ 220/* control interface reports status changes with "interrupt" transfers */
221static void acm_ctrl_irq(struct urb *urb, struct pt_regs *regs) 221static void acm_ctrl_irq(struct urb *urb)
222{ 222{
223 struct acm *acm = urb->context; 223 struct acm *acm = urb->context;
224 struct usb_cdc_notification *dr = urb->transfer_buffer; 224 struct usb_cdc_notification *dr = urb->transfer_buffer;
@@ -285,7 +285,7 @@ exit:
285} 285}
286 286
287/* data interface returns incoming bytes, or we got unthrottled */ 287/* data interface returns incoming bytes, or we got unthrottled */
288static void acm_read_bulk(struct urb *urb, struct pt_regs *regs) 288static void acm_read_bulk(struct urb *urb)
289{ 289{
290 struct acm_rb *buf; 290 struct acm_rb *buf;
291 struct acm_ru *rcv = urb->context; 291 struct acm_ru *rcv = urb->context;
@@ -325,7 +325,7 @@ static void acm_rx_tasklet(unsigned long _acm)
325 struct acm_rb *buf; 325 struct acm_rb *buf;
326 struct tty_struct *tty = acm->tty; 326 struct tty_struct *tty = acm->tty;
327 struct acm_ru *rcv; 327 struct acm_ru *rcv;
328 //unsigned long flags; 328 unsigned long flags;
329 int i = 0; 329 int i = 0;
330 dbg("Entering acm_rx_tasklet"); 330 dbg("Entering acm_rx_tasklet");
331 331
@@ -333,15 +333,15 @@ static void acm_rx_tasklet(unsigned long _acm)
333 return; 333 return;
334 334
335next_buffer: 335next_buffer:
336 spin_lock(&acm->read_lock); 336 spin_lock_irqsave(&acm->read_lock, flags);
337 if (list_empty(&acm->filled_read_bufs)) { 337 if (list_empty(&acm->filled_read_bufs)) {
338 spin_unlock(&acm->read_lock); 338 spin_unlock_irqrestore(&acm->read_lock, flags);
339 goto urbs; 339 goto urbs;
340 } 340 }
341 buf = list_entry(acm->filled_read_bufs.next, 341 buf = list_entry(acm->filled_read_bufs.next,
342 struct acm_rb, list); 342 struct acm_rb, list);
343 list_del(&buf->list); 343 list_del(&buf->list);
344 spin_unlock(&acm->read_lock); 344 spin_unlock_irqrestore(&acm->read_lock, flags);
345 345
346 dbg("acm_rx_tasklet: procesing buf 0x%p, size = %d", buf, buf->size); 346 dbg("acm_rx_tasklet: procesing buf 0x%p, size = %d", buf, buf->size);
347 347
@@ -356,29 +356,29 @@ next_buffer:
356 memmove(buf->base, buf->base + i, buf->size - i); 356 memmove(buf->base, buf->base + i, buf->size - i);
357 buf->size -= i; 357 buf->size -= i;
358 spin_unlock(&acm->throttle_lock); 358 spin_unlock(&acm->throttle_lock);
359 spin_lock(&acm->read_lock); 359 spin_lock_irqsave(&acm->read_lock, flags);
360 list_add(&buf->list, &acm->filled_read_bufs); 360 list_add(&buf->list, &acm->filled_read_bufs);
361 spin_unlock(&acm->read_lock); 361 spin_unlock_irqrestore(&acm->read_lock, flags);
362 return; 362 return;
363 } 363 }
364 spin_unlock(&acm->throttle_lock); 364 spin_unlock(&acm->throttle_lock);
365 365
366 spin_lock(&acm->read_lock); 366 spin_lock_irqsave(&acm->read_lock, flags);
367 list_add(&buf->list, &acm->spare_read_bufs); 367 list_add(&buf->list, &acm->spare_read_bufs);
368 spin_unlock(&acm->read_lock); 368 spin_unlock_irqrestore(&acm->read_lock, flags);
369 goto next_buffer; 369 goto next_buffer;
370 370
371urbs: 371urbs:
372 while (!list_empty(&acm->spare_read_bufs)) { 372 while (!list_empty(&acm->spare_read_bufs)) {
373 spin_lock(&acm->read_lock); 373 spin_lock_irqsave(&acm->read_lock, flags);
374 if (list_empty(&acm->spare_read_urbs)) { 374 if (list_empty(&acm->spare_read_urbs)) {
375 spin_unlock(&acm->read_lock); 375 spin_unlock_irqrestore(&acm->read_lock, flags);
376 return; 376 return;
377 } 377 }
378 rcv = list_entry(acm->spare_read_urbs.next, 378 rcv = list_entry(acm->spare_read_urbs.next,
379 struct acm_ru, list); 379 struct acm_ru, list);
380 list_del(&rcv->list); 380 list_del(&rcv->list);
381 spin_unlock(&acm->read_lock); 381 spin_unlock_irqrestore(&acm->read_lock, flags);
382 382
383 buf = list_entry(acm->spare_read_bufs.next, 383 buf = list_entry(acm->spare_read_bufs.next,
384 struct acm_rb, list); 384 struct acm_rb, list);
@@ -400,16 +400,16 @@ urbs:
400 free-urbs-pool and resubmited ASAP */ 400 free-urbs-pool and resubmited ASAP */
401 if (usb_submit_urb(rcv->urb, GFP_ATOMIC) < 0) { 401 if (usb_submit_urb(rcv->urb, GFP_ATOMIC) < 0) {
402 list_add(&buf->list, &acm->spare_read_bufs); 402 list_add(&buf->list, &acm->spare_read_bufs);
403 spin_lock(&acm->read_lock); 403 spin_lock_irqsave(&acm->read_lock, flags);
404 list_add(&rcv->list, &acm->spare_read_urbs); 404 list_add(&rcv->list, &acm->spare_read_urbs);
405 spin_unlock(&acm->read_lock); 405 spin_unlock_irqrestore(&acm->read_lock, flags);
406 return; 406 return;
407 } 407 }
408 } 408 }
409} 409}
410 410
411/* data interface wrote those outgoing bytes */ 411/* data interface wrote those outgoing bytes */
412static void acm_write_bulk(struct urb *urb, struct pt_regs *regs) 412static void acm_write_bulk(struct urb *urb)
413{ 413{
414 struct acm *acm = (struct acm *)urb->context; 414 struct acm *acm = (struct acm *)urb->context;
415 415
@@ -1083,6 +1083,9 @@ static struct usb_device_id acm_ids[] = {
1083 { USB_DEVICE(0x0482, 0x0203), /* KYOCERA AH-K3001V */ 1083 { USB_DEVICE(0x0482, 0x0203), /* KYOCERA AH-K3001V */
1084 .driver_info = NO_UNION_NORMAL, /* has no union descriptor */ 1084 .driver_info = NO_UNION_NORMAL, /* has no union descriptor */
1085 }, 1085 },
1086 { USB_DEVICE(0x079b, 0x000f), /* BT On-Air USB MODEM */
1087 .driver_info = NO_UNION_NORMAL, /* has no union descriptor */
1088 },
1086 { USB_DEVICE(0x0ace, 0x1608), /* ZyDAS 56K USB MODEM */ 1089 { USB_DEVICE(0x0ace, 0x1608), /* ZyDAS 56K USB MODEM */
1087 .driver_info = SINGLE_RX_URB, /* firmware bug */ 1090 .driver_info = SINGLE_RX_URB, /* firmware bug */
1088 }, 1091 },
diff --git a/drivers/usb/class/usblp.c b/drivers/usb/class/usblp.c
index 9cac11ca1bb7..6303970e93c1 100644
--- a/drivers/usb/class/usblp.c
+++ b/drivers/usb/class/usblp.c
@@ -154,6 +154,7 @@ struct usblp {
154 unsigned char used; /* True if open */ 154 unsigned char used; /* True if open */
155 unsigned char present; /* True if not disconnected */ 155 unsigned char present; /* True if not disconnected */
156 unsigned char bidir; /* interface is bidirectional */ 156 unsigned char bidir; /* interface is bidirectional */
157 unsigned char sleeping; /* interface is suspended */
157 unsigned char *device_id_string; /* IEEE 1284 DEVICE ID string (ptr) */ 158 unsigned char *device_id_string; /* IEEE 1284 DEVICE ID string (ptr) */
158 /* first 2 bytes are (big-endian) length */ 159 /* first 2 bytes are (big-endian) length */
159}; 160};
@@ -183,6 +184,7 @@ static void usblp_dump(struct usblp *usblp) {
183 dbg("quirks=%d", usblp->quirks); 184 dbg("quirks=%d", usblp->quirks);
184 dbg("used=%d", usblp->used); 185 dbg("used=%d", usblp->used);
185 dbg("bidir=%d", usblp->bidir); 186 dbg("bidir=%d", usblp->bidir);
187 dbg("sleeping=%d", usblp->sleeping);
186 dbg("device_id_string=\"%s\"", 188 dbg("device_id_string=\"%s\"",
187 usblp->device_id_string ? 189 usblp->device_id_string ?
188 usblp->device_id_string + 2 : 190 usblp->device_id_string + 2 :
@@ -271,7 +273,7 @@ static int proto_bias = -1;
271 * URB callback. 273 * URB callback.
272 */ 274 */
273 275
274static void usblp_bulk_read(struct urb *urb, struct pt_regs *regs) 276static void usblp_bulk_read(struct urb *urb)
275{ 277{
276 struct usblp *usblp = urb->context; 278 struct usblp *usblp = urb->context;
277 279
@@ -288,7 +290,7 @@ unplug:
288 wake_up_interruptible(&usblp->wait); 290 wake_up_interruptible(&usblp->wait);
289} 291}
290 292
291static void usblp_bulk_write(struct urb *urb, struct pt_regs *regs) 293static void usblp_bulk_write(struct urb *urb)
292{ 294{
293 struct usblp *usblp = urb->context; 295 struct usblp *usblp = urb->context;
294 296
@@ -338,6 +340,20 @@ static int usblp_check_status(struct usblp *usblp, int err)
338 return newerr; 340 return newerr;
339} 341}
340 342
343static int handle_bidir (struct usblp *usblp)
344{
345 if (usblp->bidir && usblp->used && !usblp->sleeping) {
346 usblp->readcount = 0;
347 usblp->readurb->dev = usblp->dev;
348 if (usb_submit_urb(usblp->readurb, GFP_KERNEL) < 0) {
349 usblp->used = 0;
350 return -EIO;
351 }
352 }
353
354 return 0;
355}
356
341/* 357/*
342 * File op functions. 358 * File op functions.
343 */ 359 */
@@ -390,14 +406,9 @@ static int usblp_open(struct inode *inode, struct file *file)
390 usblp->writeurb->status = 0; 406 usblp->writeurb->status = 0;
391 usblp->readurb->status = 0; 407 usblp->readurb->status = 0;
392 408
393 if (usblp->bidir) { 409 if (handle_bidir(usblp) < 0) {
394 usblp->readcount = 0; 410 file->private_data = NULL;
395 usblp->readurb->dev = usblp->dev; 411 retval = -EIO;
396 if (usb_submit_urb(usblp->readurb, GFP_KERNEL) < 0) {
397 retval = -EIO;
398 usblp->used = 0;
399 file->private_data = NULL;
400 }
401 } 412 }
402out: 413out:
403 mutex_unlock (&usblp_mutex); 414 mutex_unlock (&usblp_mutex);
@@ -460,6 +471,11 @@ static long usblp_ioctl(struct file *file, unsigned int cmd, unsigned long arg)
460 goto done; 471 goto done;
461 } 472 }
462 473
474 if (usblp->sleeping) {
475 retval = -ENODEV;
476 goto done;
477 }
478
463 dbg("usblp_ioctl: cmd=0x%x (%c nr=%d len=%d dir=%d)", cmd, _IOC_TYPE(cmd), 479 dbg("usblp_ioctl: cmd=0x%x (%c nr=%d len=%d dir=%d)", cmd, _IOC_TYPE(cmd),
464 _IOC_NR(cmd), _IOC_SIZE(cmd), _IOC_DIR(cmd) ); 480 _IOC_NR(cmd), _IOC_SIZE(cmd), _IOC_DIR(cmd) );
465 481
@@ -658,6 +674,11 @@ static ssize_t usblp_write(struct file *file, const char __user *buffer, size_t
658 return -ENODEV; 674 return -ENODEV;
659 } 675 }
660 676
677 if (usblp->sleeping) {
678 up (&usblp->sem);
679 return writecount ? writecount : -ENODEV;
680 }
681
661 if (usblp->writeurb->status != 0) { 682 if (usblp->writeurb->status != 0) {
662 if (usblp->quirks & USBLP_QUIRK_BIDIR) { 683 if (usblp->quirks & USBLP_QUIRK_BIDIR) {
663 if (!usblp->wcomplete) 684 if (!usblp->wcomplete)
@@ -701,6 +722,7 @@ static ssize_t usblp_write(struct file *file, const char __user *buffer, size_t
701 usblp->wcomplete = 0; 722 usblp->wcomplete = 0;
702 err = usb_submit_urb(usblp->writeurb, GFP_KERNEL); 723 err = usb_submit_urb(usblp->writeurb, GFP_KERNEL);
703 if (err) { 724 if (err) {
725 usblp->wcomplete = 1;
704 if (err != -ENOMEM) 726 if (err != -ENOMEM)
705 count = -EIO; 727 count = -EIO;
706 else 728 else
@@ -749,6 +771,11 @@ static ssize_t usblp_read(struct file *file, char __user *buffer, size_t count,
749 goto done; 771 goto done;
750 } 772 }
751 773
774 if (usblp->sleeping) {
775 count = -ENODEV;
776 goto done;
777 }
778
752 if (usblp->readurb->status) { 779 if (usblp->readurb->status) {
753 err("usblp%d: error %d reading from printer", 780 err("usblp%d: error %d reading from printer",
754 usblp->minor, usblp->readurb->status); 781 usblp->minor, usblp->readurb->status);
@@ -1167,6 +1194,39 @@ static void usblp_disconnect(struct usb_interface *intf)
1167 mutex_unlock (&usblp_mutex); 1194 mutex_unlock (&usblp_mutex);
1168} 1195}
1169 1196
1197static int usblp_suspend (struct usb_interface *intf, pm_message_t message)
1198{
1199 struct usblp *usblp = usb_get_intfdata (intf);
1200
1201 /* this races against normal access and open */
1202 mutex_lock (&usblp_mutex);
1203 down (&usblp->sem);
1204 /* we take no more IO */
1205 usblp->sleeping = 1;
1206 usblp_unlink_urbs(usblp);
1207 up (&usblp->sem);
1208 mutex_unlock (&usblp_mutex);
1209
1210 return 0;
1211}
1212
1213static int usblp_resume (struct usb_interface *intf)
1214{
1215 struct usblp *usblp = usb_get_intfdata (intf);
1216 int r;
1217
1218 mutex_lock (&usblp_mutex);
1219 down (&usblp->sem);
1220
1221 usblp->sleeping = 0;
1222 r = handle_bidir (usblp);
1223
1224 up (&usblp->sem);
1225 mutex_unlock (&usblp_mutex);
1226
1227 return r;
1228}
1229
1170static struct usb_device_id usblp_ids [] = { 1230static struct usb_device_id usblp_ids [] = {
1171 { USB_DEVICE_INFO(7, 1, 1) }, 1231 { USB_DEVICE_INFO(7, 1, 1) },
1172 { USB_DEVICE_INFO(7, 1, 2) }, 1232 { USB_DEVICE_INFO(7, 1, 2) },
@@ -1183,6 +1243,8 @@ static struct usb_driver usblp_driver = {
1183 .name = "usblp", 1243 .name = "usblp",
1184 .probe = usblp_probe, 1244 .probe = usblp_probe,
1185 .disconnect = usblp_disconnect, 1245 .disconnect = usblp_disconnect,
1246 .suspend = usblp_suspend,
1247 .resume = usblp_resume,
1186 .id_table = usblp_ids, 1248 .id_table = usblp_ids,
1187}; 1249};
1188 1250
diff --git a/drivers/usb/core/devio.c b/drivers/usb/core/devio.c
index 3f509beb88e4..fed92be63b5e 100644
--- a/drivers/usb/core/devio.c
+++ b/drivers/usb/core/devio.c
@@ -304,7 +304,7 @@ static void snoop_urb(struct urb *urb, void __user *userurb)
304 printk("\n"); 304 printk("\n");
305} 305}
306 306
307static void async_completed(struct urb *urb, struct pt_regs *regs) 307static void async_completed(struct urb *urb)
308{ 308{
309 struct async *as = urb->context; 309 struct async *as = urb->context;
310 struct dev_state *ps = as->ps; 310 struct dev_state *ps = as->ps;
@@ -1216,7 +1216,7 @@ static int proc_submiturb_compat(struct dev_state *ps, void __user *arg)
1216{ 1216{
1217 struct usbdevfs_urb uurb; 1217 struct usbdevfs_urb uurb;
1218 1218
1219 if (get_urb32(&uurb,(struct usbdevfs_urb32 *)arg)) 1219 if (get_urb32(&uurb,(struct usbdevfs_urb32 __user *)arg))
1220 return -EFAULT; 1220 return -EFAULT;
1221 1221
1222 return proc_do_submiturb(ps, &uurb, ((struct usbdevfs_urb32 __user *)arg)->iso_frame_desc, arg); 1222 return proc_do_submiturb(ps, &uurb, ((struct usbdevfs_urb32 __user *)arg)->iso_frame_desc, arg);
@@ -1251,7 +1251,7 @@ static int processcompl_compat(struct async *as, void __user * __user *arg)
1251 } 1251 }
1252 1252
1253 free_async(as); 1253 free_async(as);
1254 if (put_user((u32)(u64)addr, (u32 __user *)arg)) 1254 if (put_user(ptr_to_compat(addr), (u32 __user *)arg))
1255 return -EFAULT; 1255 return -EFAULT;
1256 return 0; 1256 return 0;
1257} 1257}
@@ -1520,7 +1520,7 @@ static int usbdev_ioctl(struct inode *inode, struct file *file, unsigned int cmd
1520 1520
1521 case USBDEVFS_IOCTL32: 1521 case USBDEVFS_IOCTL32:
1522 snoop(&dev->dev, "%s: IOCTL\n", __FUNCTION__); 1522 snoop(&dev->dev, "%s: IOCTL\n", __FUNCTION__);
1523 ret = proc_ioctl_compat(ps, (compat_uptr_t)(long)p); 1523 ret = proc_ioctl_compat(ps, ptr_to_compat(p));
1524 break; 1524 break;
1525#endif 1525#endif
1526 1526
@@ -1588,15 +1588,18 @@ const struct file_operations usbfs_device_file_operations = {
1588 .release = usbdev_release, 1588 .release = usbdev_release,
1589}; 1589};
1590 1590
1591static void usbdev_add(struct usb_device *dev) 1591static int usbdev_add(struct usb_device *dev)
1592{ 1592{
1593 int minor = ((dev->bus->busnum-1) * 128) + (dev->devnum-1); 1593 int minor = ((dev->bus->busnum-1) * 128) + (dev->devnum-1);
1594 1594
1595 dev->class_dev = class_device_create(usb_device_class, NULL, 1595 dev->class_dev = class_device_create(usb_device_class, NULL,
1596 MKDEV(USB_DEVICE_MAJOR, minor), &dev->dev, 1596 MKDEV(USB_DEVICE_MAJOR, minor), &dev->dev,
1597 "usbdev%d.%d", dev->bus->busnum, dev->devnum); 1597 "usbdev%d.%d", dev->bus->busnum, dev->devnum);
1598 if (IS_ERR(dev->class_dev))
1599 return PTR_ERR(dev->class_dev);
1598 1600
1599 dev->class_dev->class_data = dev; 1601 dev->class_dev->class_data = dev;
1602 return 0;
1600} 1603}
1601 1604
1602static void usbdev_remove(struct usb_device *dev) 1605static void usbdev_remove(struct usb_device *dev)
@@ -1609,7 +1612,8 @@ static int usbdev_notify(struct notifier_block *self, unsigned long action,
1609{ 1612{
1610 switch (action) { 1613 switch (action) {
1611 case USB_DEVICE_ADD: 1614 case USB_DEVICE_ADD:
1612 usbdev_add(dev); 1615 if (usbdev_add(dev))
1616 return NOTIFY_BAD;
1613 break; 1617 break;
1614 case USB_DEVICE_REMOVE: 1618 case USB_DEVICE_REMOVE:
1615 usbdev_remove(dev); 1619 usbdev_remove(dev);
diff --git a/drivers/usb/core/endpoint.c b/drivers/usb/core/endpoint.c
index 3ebb90149e93..3b2d137912be 100644
--- a/drivers/usb/core/endpoint.c
+++ b/drivers/usb/core/endpoint.c
@@ -223,7 +223,7 @@ int usb_create_ep_files(struct device *parent,
223 ep_dev = kzalloc(sizeof(*ep_dev), GFP_KERNEL); 223 ep_dev = kzalloc(sizeof(*ep_dev), GFP_KERNEL);
224 if (!ep_dev) { 224 if (!ep_dev) {
225 retval = -ENOMEM; 225 retval = -ENOMEM;
226 goto exit; 226 goto error_alloc;
227 } 227 }
228 228
229 /* fun calculation to determine the minor of this endpoint */ 229 /* fun calculation to determine the minor of this endpoint */
@@ -241,33 +241,31 @@ int usb_create_ep_files(struct device *parent,
241 241
242 retval = device_register(&ep_dev->dev); 242 retval = device_register(&ep_dev->dev);
243 if (retval) 243 if (retval)
244 goto error; 244 goto error_register;
245 retval = sysfs_create_group(&ep_dev->dev.kobj, &ep_dev_attr_grp); 245 retval = sysfs_create_group(&ep_dev->dev.kobj, &ep_dev_attr_grp);
246 if (retval) 246 if (retval)
247 goto error_group; 247 goto error_group;
248 248
249 endpoint->ep_dev = ep_dev;
250
251 /* create the symlink to the old-style "ep_XX" directory */ 249 /* create the symlink to the old-style "ep_XX" directory */
252 sprintf(name, "ep_%02x", endpoint->desc.bEndpointAddress); 250 sprintf(name, "ep_%02x", endpoint->desc.bEndpointAddress);
253 retval = sysfs_create_link(&parent->kobj, 251 retval = sysfs_create_link(&parent->kobj, &ep_dev->dev.kobj, name);
254 &endpoint->ep_dev->dev.kobj, name);
255 if (retval) 252 if (retval)
256 goto error_link; 253 goto error_link;
257exit: 254 endpoint->ep_dev = ep_dev;
258 return retval; 255 return retval;
259 256
260error_link: 257error_link:
261 sysfs_remove_group(&ep_dev->dev.kobj, &ep_dev_attr_grp); 258 sysfs_remove_group(&ep_dev->dev.kobj, &ep_dev_attr_grp);
262
263error_group: 259error_group:
264 device_unregister(&ep_dev->dev); 260 device_unregister(&ep_dev->dev);
265 endpoint->ep_dev = NULL;
266 destroy_endpoint_class(); 261 destroy_endpoint_class();
267 return retval; 262 return retval;
268error: 263
264error_register:
269 kfree(ep_dev); 265 kfree(ep_dev);
266error_alloc:
270 destroy_endpoint_class(); 267 destroy_endpoint_class();
268exit:
271 return retval; 269 return retval;
272} 270}
273 271
@@ -282,8 +280,6 @@ void usb_remove_ep_files(struct usb_host_endpoint *endpoint)
282 sysfs_remove_group(&endpoint->ep_dev->dev.kobj, &ep_dev_attr_grp); 280 sysfs_remove_group(&endpoint->ep_dev->dev.kobj, &ep_dev_attr_grp);
283 device_unregister(&endpoint->ep_dev->dev); 281 device_unregister(&endpoint->ep_dev->dev);
284 endpoint->ep_dev = NULL; 282 endpoint->ep_dev = NULL;
283 destroy_endpoint_class();
285 } 284 }
286 destroy_endpoint_class();
287} 285}
288
289
diff --git a/drivers/usb/core/hcd.c b/drivers/usb/core/hcd.c
index e658089f7b50..afa2dd203329 100644
--- a/drivers/usb/core/hcd.c
+++ b/drivers/usb/core/hcd.c
@@ -522,7 +522,7 @@ error:
522 if (urb->status == -EINPROGRESS) 522 if (urb->status == -EINPROGRESS)
523 urb->status = status; 523 urb->status = status;
524 spin_unlock (&urb->lock); 524 spin_unlock (&urb->lock);
525 usb_hcd_giveback_urb (hcd, urb, NULL); 525 usb_hcd_giveback_urb (hcd, urb);
526 local_irq_restore (flags); 526 local_irq_restore (flags);
527 return 0; 527 return 0;
528} 528}
@@ -572,7 +572,7 @@ void usb_hcd_poll_rh_status(struct usb_hcd *hcd)
572 572
573 /* local irqs are always blocked in completions */ 573 /* local irqs are always blocked in completions */
574 if (length > 0) 574 if (length > 0)
575 usb_hcd_giveback_urb (hcd, urb, NULL); 575 usb_hcd_giveback_urb (hcd, urb);
576 else 576 else
577 hcd->poll_pending = 1; 577 hcd->poll_pending = 1;
578 local_irq_restore (flags); 578 local_irq_restore (flags);
@@ -656,7 +656,7 @@ static int usb_rh_urb_dequeue (struct usb_hcd *hcd, struct urb *urb)
656 urb = NULL; /* wasn't fully queued */ 656 urb = NULL; /* wasn't fully queued */
657 spin_unlock (&hcd_root_hub_lock); 657 spin_unlock (&hcd_root_hub_lock);
658 if (urb) 658 if (urb)
659 usb_hcd_giveback_urb (hcd, urb, NULL); 659 usb_hcd_giveback_urb (hcd, urb);
660 local_irq_restore (flags); 660 local_irq_restore (flags);
661 } 661 }
662 662
@@ -1498,7 +1498,6 @@ EXPORT_SYMBOL (usb_bus_start_enum);
1498 * usb_hcd_giveback_urb - return URB from HCD to device driver 1498 * usb_hcd_giveback_urb - return URB from HCD to device driver
1499 * @hcd: host controller returning the URB 1499 * @hcd: host controller returning the URB
1500 * @urb: urb being returned to the USB device driver. 1500 * @urb: urb being returned to the USB device driver.
1501 * @regs: pt_regs, passed down to the URB completion handler
1502 * Context: in_interrupt() 1501 * Context: in_interrupt()
1503 * 1502 *
1504 * This hands the URB from HCD to its USB device driver, using its 1503 * This hands the URB from HCD to its USB device driver, using its
@@ -1507,7 +1506,7 @@ EXPORT_SYMBOL (usb_bus_start_enum);
1507 * the device driver won't cause problems if it frees, modifies, 1506 * the device driver won't cause problems if it frees, modifies,
1508 * or resubmits this URB. 1507 * or resubmits this URB.
1509 */ 1508 */
1510void usb_hcd_giveback_urb (struct usb_hcd *hcd, struct urb *urb, struct pt_regs *regs) 1509void usb_hcd_giveback_urb (struct usb_hcd *hcd, struct urb *urb)
1511{ 1510{
1512 int at_root_hub; 1511 int at_root_hub;
1513 1512
@@ -1534,7 +1533,7 @@ void usb_hcd_giveback_urb (struct usb_hcd *hcd, struct urb *urb, struct pt_regs
1534 1533
1535 usbmon_urb_complete (&hcd->self, urb); 1534 usbmon_urb_complete (&hcd->self, urb);
1536 /* pass ownership to the completion handler */ 1535 /* pass ownership to the completion handler */
1537 urb->complete (urb, regs); 1536 urb->complete (urb);
1538 atomic_dec (&urb->use_count); 1537 atomic_dec (&urb->use_count);
1539 if (unlikely (urb->reject)) 1538 if (unlikely (urb->reject))
1540 wake_up (&usb_kill_urb_queue); 1539 wake_up (&usb_kill_urb_queue);
@@ -1553,7 +1552,7 @@ EXPORT_SYMBOL (usb_hcd_giveback_urb);
1553 * If the controller isn't HALTed, calls the driver's irq handler. 1552 * If the controller isn't HALTed, calls the driver's irq handler.
1554 * Checks whether the controller is now dead. 1553 * Checks whether the controller is now dead.
1555 */ 1554 */
1556irqreturn_t usb_hcd_irq (int irq, void *__hcd, struct pt_regs * r) 1555irqreturn_t usb_hcd_irq (int irq, void *__hcd)
1557{ 1556{
1558 struct usb_hcd *hcd = __hcd; 1557 struct usb_hcd *hcd = __hcd;
1559 int start = hcd->state; 1558 int start = hcd->state;
@@ -1561,7 +1560,7 @@ irqreturn_t usb_hcd_irq (int irq, void *__hcd, struct pt_regs * r)
1561 if (unlikely(start == HC_STATE_HALT || 1560 if (unlikely(start == HC_STATE_HALT ||
1562 !test_bit(HCD_FLAG_HW_ACCESSIBLE, &hcd->flags))) 1561 !test_bit(HCD_FLAG_HW_ACCESSIBLE, &hcd->flags)))
1563 return IRQ_NONE; 1562 return IRQ_NONE;
1564 if (hcd->driver->irq (hcd, r) == IRQ_NONE) 1563 if (hcd->driver->irq (hcd) == IRQ_NONE)
1565 return IRQ_NONE; 1564 return IRQ_NONE;
1566 1565
1567 set_bit(HCD_FLAG_SAW_IRQ, &hcd->flags); 1566 set_bit(HCD_FLAG_SAW_IRQ, &hcd->flags);
diff --git a/drivers/usb/core/hcd.h b/drivers/usb/core/hcd.h
index 676877c15f81..8f8df0d4382e 100644
--- a/drivers/usb/core/hcd.h
+++ b/drivers/usb/core/hcd.h
@@ -143,15 +143,13 @@ struct hcd_timeout { /* timeouts we allocate */
143/*-------------------------------------------------------------------------*/ 143/*-------------------------------------------------------------------------*/
144 144
145 145
146struct pt_regs;
147
148struct hc_driver { 146struct hc_driver {
149 const char *description; /* "ehci-hcd" etc */ 147 const char *description; /* "ehci-hcd" etc */
150 const char *product_desc; /* product/vendor string */ 148 const char *product_desc; /* product/vendor string */
151 size_t hcd_priv_size; /* size of private data */ 149 size_t hcd_priv_size; /* size of private data */
152 150
153 /* irq handler */ 151 /* irq handler */
154 irqreturn_t (*irq) (struct usb_hcd *hcd, struct pt_regs *regs); 152 irqreturn_t (*irq) (struct usb_hcd *hcd);
155 153
156 int flags; 154 int flags;
157#define HCD_MEMORY 0x0001 /* HC regs use memory (else I/O) */ 155#define HCD_MEMORY 0x0001 /* HC regs use memory (else I/O) */
@@ -205,8 +203,7 @@ struct hc_driver {
205 203
206extern int usb_hcd_submit_urb (struct urb *urb, gfp_t mem_flags); 204extern int usb_hcd_submit_urb (struct urb *urb, gfp_t mem_flags);
207extern int usb_hcd_unlink_urb (struct urb *urb, int status); 205extern int usb_hcd_unlink_urb (struct urb *urb, int status);
208extern void usb_hcd_giveback_urb (struct usb_hcd *hcd, struct urb *urb, 206extern void usb_hcd_giveback_urb (struct usb_hcd *hcd, struct urb *urb);
209 struct pt_regs *regs);
210extern void usb_hcd_endpoint_disable (struct usb_device *udev, 207extern void usb_hcd_endpoint_disable (struct usb_device *udev,
211 struct usb_host_endpoint *ep); 208 struct usb_host_endpoint *ep);
212extern int usb_hcd_get_frame_number (struct usb_device *udev); 209extern int usb_hcd_get_frame_number (struct usb_device *udev);
@@ -248,7 +245,7 @@ void hcd_buffer_free (struct usb_bus *bus, size_t size,
248 void *addr, dma_addr_t dma); 245 void *addr, dma_addr_t dma);
249 246
250/* generic bus glue, needed for host controllers that don't use PCI */ 247/* generic bus glue, needed for host controllers that don't use PCI */
251extern irqreturn_t usb_hcd_irq (int irq, void *__hcd, struct pt_regs *r); 248extern irqreturn_t usb_hcd_irq (int irq, void *__hcd);
252 249
253extern void usb_hc_died (struct usb_hcd *hcd); 250extern void usb_hc_died (struct usb_hcd *hcd);
254extern void usb_hcd_poll_rh_status(struct usb_hcd *hcd); 251extern void usb_hcd_poll_rh_status(struct usb_hcd *hcd);
diff --git a/drivers/usb/core/hub.c b/drivers/usb/core/hub.c
index 7676690a0386..ba165aff9ea4 100644
--- a/drivers/usb/core/hub.c
+++ b/drivers/usb/core/hub.c
@@ -291,7 +291,7 @@ void usb_kick_khubd(struct usb_device *hdev)
291 291
292 292
293/* completion function, fires on port status changes and various faults */ 293/* completion function, fires on port status changes and various faults */
294static void hub_irq(struct urb *urb, struct pt_regs *regs) 294static void hub_irq(struct urb *urb)
295{ 295{
296 struct usb_hub *hub = urb->context; 296 struct usb_hub *hub = urb->context;
297 int status; 297 int status;
@@ -1188,6 +1188,7 @@ static inline void show_string(struct usb_device *udev, char *id, char *string)
1188 1188
1189#ifdef CONFIG_USB_OTG 1189#ifdef CONFIG_USB_OTG
1190#include "otg_whitelist.h" 1190#include "otg_whitelist.h"
1191static int __usb_port_suspend(struct usb_device *, int port1);
1191#endif 1192#endif
1192 1193
1193/** 1194/**
@@ -1289,8 +1290,6 @@ int usb_new_device(struct usb_device *udev)
1289 * (Includes HNP test device.) 1290 * (Includes HNP test device.)
1290 */ 1291 */
1291 if (udev->bus->b_hnp_enable || udev->bus->is_b_host) { 1292 if (udev->bus->b_hnp_enable || udev->bus->is_b_host) {
1292 static int __usb_port_suspend(struct usb_device *,
1293 int port1);
1294 err = __usb_port_suspend(udev, udev->bus->otg_port); 1293 err = __usb_port_suspend(udev, udev->bus->otg_port);
1295 if (err < 0) 1294 if (err < 0)
1296 dev_dbg(&udev->dev, "HNP fail, %d\n", err); 1295 dev_dbg(&udev->dev, "HNP fail, %d\n", err);
diff --git a/drivers/usb/core/message.c b/drivers/usb/core/message.c
index 85b1cd18336f..7729c0744886 100644
--- a/drivers/usb/core/message.c
+++ b/drivers/usb/core/message.c
@@ -17,7 +17,7 @@
17#include "hcd.h" /* for usbcore internals */ 17#include "hcd.h" /* for usbcore internals */
18#include "usb.h" 18#include "usb.h"
19 19
20static void usb_api_blocking_completion(struct urb *urb, struct pt_regs *regs) 20static void usb_api_blocking_completion(struct urb *urb)
21{ 21{
22 complete((struct completion *)urb->context); 22 complete((struct completion *)urb->context);
23} 23}
@@ -246,7 +246,7 @@ static void sg_clean (struct usb_sg_request *io)
246 io->dev = NULL; 246 io->dev = NULL;
247} 247}
248 248
249static void sg_complete (struct urb *urb, struct pt_regs *regs) 249static void sg_complete (struct urb *urb)
250{ 250{
251 struct usb_sg_request *io = urb->context; 251 struct usb_sg_request *io = urb->context;
252 252
@@ -828,10 +828,7 @@ char *usb_cache_string(struct usb_device *udev, int index)
828 * Context: !in_interrupt () 828 * Context: !in_interrupt ()
829 * 829 *
830 * Updates the copy of the device descriptor stored in the device structure, 830 * Updates the copy of the device descriptor stored in the device structure,
831 * which dedicates space for this purpose. Note that several fields are 831 * which dedicates space for this purpose.
832 * converted to the host CPU's byte order: the USB version (bcdUSB), and
833 * vendors product and version fields (idVendor, idProduct, and bcdDevice).
834 * That lets device drivers compare against non-byteswapped constants.
835 * 832 *
836 * Not exported, only for use by the core. If drivers really want to read 833 * Not exported, only for use by the core. If drivers really want to read
837 * the device descriptor directly, they can call usb_get_descriptor() with 834 * the device descriptor directly, they can call usb_get_descriptor() with
diff --git a/drivers/usb/gadget/at91_udc.c b/drivers/usb/gadget/at91_udc.c
index 77beba485a84..72f3db99ff94 100644
--- a/drivers/usb/gadget/at91_udc.c
+++ b/drivers/usb/gadget/at91_udc.c
@@ -1366,7 +1366,7 @@ static void handle_ep0(struct at91_udc *udc)
1366 } 1366 }
1367} 1367}
1368 1368
1369static irqreturn_t at91_udc_irq (int irq, void *_udc, struct pt_regs *r) 1369static irqreturn_t at91_udc_irq (int irq, void *_udc)
1370{ 1370{
1371 struct at91_udc *udc = _udc; 1371 struct at91_udc *udc = _udc;
1372 u32 rescans = 5; 1372 u32 rescans = 5;
@@ -1552,7 +1552,7 @@ static struct at91_udc controller = {
1552 /* ep6 and ep7 are also reserved (custom silicon might use them) */ 1552 /* ep6 and ep7 are also reserved (custom silicon might use them) */
1553}; 1553};
1554 1554
1555static irqreturn_t at91_vbus_irq(int irq, void *_udc, struct pt_regs *r) 1555static irqreturn_t at91_vbus_irq(int irq, void *_udc)
1556{ 1556{
1557 struct at91_udc *udc = _udc; 1557 struct at91_udc *udc = _udc;
1558 unsigned value; 1558 unsigned value;
diff --git a/drivers/usb/gadget/dummy_hcd.c b/drivers/usb/gadget/dummy_hcd.c
index 4d2946e540cf..f1f32d7be5f9 100644
--- a/drivers/usb/gadget/dummy_hcd.c
+++ b/drivers/usb/gadget/dummy_hcd.c
@@ -1551,7 +1551,7 @@ return_urb:
1551 ep->already_seen = ep->setup_stage = 0; 1551 ep->already_seen = ep->setup_stage = 0;
1552 1552
1553 spin_unlock (&dum->lock); 1553 spin_unlock (&dum->lock);
1554 usb_hcd_giveback_urb (dummy_to_hcd(dum), urb, NULL); 1554 usb_hcd_giveback_urb (dummy_to_hcd(dum), urb);
1555 spin_lock (&dum->lock); 1555 spin_lock (&dum->lock);
1556 1556
1557 goto restart; 1557 goto restart;
diff --git a/drivers/usb/gadget/goku_udc.c b/drivers/usb/gadget/goku_udc.c
index 7cf2999e8616..a3076da3f4eb 100644
--- a/drivers/usb/gadget/goku_udc.c
+++ b/drivers/usb/gadget/goku_udc.c
@@ -1628,7 +1628,7 @@ stall:
1628 handled = 1; \ 1628 handled = 1; \
1629 } 1629 }
1630 1630
1631static irqreturn_t goku_irq(int irq, void *_dev, struct pt_regs *r) 1631static irqreturn_t goku_irq(int irq, void *_dev)
1632{ 1632{
1633 struct goku_udc *dev = _dev; 1633 struct goku_udc *dev = _dev;
1634 struct goku_udc_regs __iomem *regs = dev->regs; 1634 struct goku_udc_regs __iomem *regs = dev->regs;
diff --git a/drivers/usb/gadget/lh7a40x_udc.c b/drivers/usb/gadget/lh7a40x_udc.c
index 36db72579377..179259664c18 100644
--- a/drivers/usb/gadget/lh7a40x_udc.c
+++ b/drivers/usb/gadget/lh7a40x_udc.c
@@ -922,7 +922,7 @@ static void lh7a40x_reset_intr(struct lh7a40x_udc *dev)
922/* 922/*
923 * lh7a40x usb client interrupt handler. 923 * lh7a40x usb client interrupt handler.
924 */ 924 */
925static irqreturn_t lh7a40x_udc_irq(int irq, void *_dev, struct pt_regs *r) 925static irqreturn_t lh7a40x_udc_irq(int irq, void *_dev)
926{ 926{
927 struct lh7a40x_udc *dev = _dev; 927 struct lh7a40x_udc *dev = _dev;
928 928
diff --git a/drivers/usb/gadget/net2280.c b/drivers/usb/gadget/net2280.c
index 3bda37f9a35f..3acc896a5d4c 100644
--- a/drivers/usb/gadget/net2280.c
+++ b/drivers/usb/gadget/net2280.c
@@ -1774,8 +1774,8 @@ static DEVICE_ATTR (queues, S_IRUGO, show_queues, NULL);
1774 1774
1775#else 1775#else
1776 1776
1777#define device_create_file(a,b) do {} while (0) 1777#define device_create_file(a,b) (0)
1778#define device_remove_file device_create_file 1778#define device_remove_file(a,b) do { } while (0)
1779 1779
1780#endif 1780#endif
1781 1781
@@ -2044,8 +2044,10 @@ int usb_gadget_register_driver (struct usb_gadget_driver *driver)
2044 return retval; 2044 return retval;
2045 } 2045 }
2046 2046
2047 device_create_file (&dev->pdev->dev, &dev_attr_function); 2047 retval = device_create_file (&dev->pdev->dev, &dev_attr_function);
2048 device_create_file (&dev->pdev->dev, &dev_attr_queues); 2048 if (retval) goto err_unbind;
2049 retval = device_create_file (&dev->pdev->dev, &dev_attr_queues);
2050 if (retval) goto err_func;
2049 2051
2050 /* ... then enable host detection and ep0; and we're ready 2052 /* ... then enable host detection and ep0; and we're ready
2051 * for set_configuration as well as eventual disconnect. 2053 * for set_configuration as well as eventual disconnect.
@@ -2060,6 +2062,14 @@ int usb_gadget_register_driver (struct usb_gadget_driver *driver)
2060 2062
2061 /* pci writes may still be posted */ 2063 /* pci writes may still be posted */
2062 return 0; 2064 return 0;
2065
2066err_func:
2067 device_remove_file (&dev->pdev->dev, &dev_attr_function);
2068err_unbind:
2069 driver->unbind (&dev->gadget);
2070 dev->gadget.dev.driver = NULL;
2071 dev->driver = NULL;
2072 return retval;
2063} 2073}
2064EXPORT_SYMBOL (usb_gadget_register_driver); 2074EXPORT_SYMBOL (usb_gadget_register_driver);
2065 2075
@@ -2753,7 +2763,7 @@ static void handle_stat1_irqs (struct net2280 *dev, u32 stat)
2753 DEBUG (dev, "unhandled irqstat1 %08x\n", stat); 2763 DEBUG (dev, "unhandled irqstat1 %08x\n", stat);
2754} 2764}
2755 2765
2756static irqreturn_t net2280_irq (int irq, void *_dev, struct pt_regs * r) 2766static irqreturn_t net2280_irq (int irq, void *_dev)
2757{ 2767{
2758 struct net2280 *dev = _dev; 2768 struct net2280 *dev = _dev;
2759 2769
@@ -2974,8 +2984,10 @@ static int net2280_probe (struct pci_dev *pdev, const struct pci_device_id *id)
2974 : "disabled"); 2984 : "disabled");
2975 the_controller = dev; 2985 the_controller = dev;
2976 2986
2977 device_register (&dev->gadget.dev); 2987 retval = device_register (&dev->gadget.dev);
2978 device_create_file (&pdev->dev, &dev_attr_registers); 2988 if (retval) goto done;
2989 retval = device_create_file (&pdev->dev, &dev_attr_registers);
2990 if (retval) goto done;
2979 2991
2980 return 0; 2992 return 0;
2981 2993
diff --git a/drivers/usb/gadget/omap_udc.c b/drivers/usb/gadget/omap_udc.c
index 8c18df869833..48a09fd89d18 100644
--- a/drivers/usb/gadget/omap_udc.c
+++ b/drivers/usb/gadget/omap_udc.c
@@ -1815,8 +1815,7 @@ static void devstate_irq(struct omap_udc *udc, u16 irq_src)
1815 UDC_IRQ_SRC_REG = UDC_DS_CHG; 1815 UDC_IRQ_SRC_REG = UDC_DS_CHG;
1816} 1816}
1817 1817
1818static irqreturn_t 1818static irqreturn_t omap_udc_irq(int irq, void *_udc)
1819omap_udc_irq(int irq, void *_udc, struct pt_regs *r)
1820{ 1819{
1821 struct omap_udc *udc = _udc; 1820 struct omap_udc *udc = _udc;
1822 u16 irq_src; 1821 u16 irq_src;
@@ -1888,8 +1887,7 @@ static void pio_out_timer(unsigned long _ep)
1888 spin_unlock_irqrestore(&ep->udc->lock, flags); 1887 spin_unlock_irqrestore(&ep->udc->lock, flags);
1889} 1888}
1890 1889
1891static irqreturn_t 1890static irqreturn_t omap_udc_pio_irq(int irq, void *_dev)
1892omap_udc_pio_irq(int irq, void *_dev, struct pt_regs *r)
1893{ 1891{
1894 u16 epn_stat, irq_src; 1892 u16 epn_stat, irq_src;
1895 irqreturn_t status = IRQ_NONE; 1893 irqreturn_t status = IRQ_NONE;
@@ -1968,8 +1966,7 @@ omap_udc_pio_irq(int irq, void *_dev, struct pt_regs *r)
1968} 1966}
1969 1967
1970#ifdef USE_ISO 1968#ifdef USE_ISO
1971static irqreturn_t 1969static irqreturn_t omap_udc_iso_irq(int irq, void *_dev)
1972omap_udc_iso_irq(int irq, void *_dev, struct pt_regs *r)
1973{ 1970{
1974 struct omap_udc *udc = _dev; 1971 struct omap_udc *udc = _dev;
1975 struct omap_ep *ep; 1972 struct omap_ep *ep;
diff --git a/drivers/usb/gadget/pxa2xx_udc.c b/drivers/usb/gadget/pxa2xx_udc.c
index f1adcf8b2023..671c24bc6d75 100644
--- a/drivers/usb/gadget/pxa2xx_udc.c
+++ b/drivers/usb/gadget/pxa2xx_udc.c
@@ -43,11 +43,11 @@
43#include <linux/mm.h> 43#include <linux/mm.h>
44#include <linux/platform_device.h> 44#include <linux/platform_device.h>
45#include <linux/dma-mapping.h> 45#include <linux/dma-mapping.h>
46#include <linux/irq.h>
46 47
47#include <asm/byteorder.h> 48#include <asm/byteorder.h>
48#include <asm/dma.h> 49#include <asm/dma.h>
49#include <asm/io.h> 50#include <asm/io.h>
50#include <asm/irq.h>
51#include <asm/system.h> 51#include <asm/system.h>
52#include <asm/mach-types.h> 52#include <asm/mach-types.h>
53#include <asm/unaligned.h> 53#include <asm/unaligned.h>
@@ -110,7 +110,7 @@ static int use_dma = 1;
110module_param(use_dma, bool, 0); 110module_param(use_dma, bool, 0);
111MODULE_PARM_DESC (use_dma, "true to use dma"); 111MODULE_PARM_DESC (use_dma, "true to use dma");
112 112
113static void dma_nodesc_handler (int dmach, void *_ep, struct pt_regs *r); 113static void dma_nodesc_handler (int dmach, void *_ep);
114static void kick_dma(struct pxa2xx_ep *ep, struct pxa2xx_request *req); 114static void kick_dma(struct pxa2xx_ep *ep, struct pxa2xx_request *req);
115 115
116#ifdef USE_OUT_DMA 116#ifdef USE_OUT_DMA
@@ -828,7 +828,7 @@ static void cancel_dma(struct pxa2xx_ep *ep)
828} 828}
829 829
830/* dma channel stopped ... normal tx end (IN), or on error (IN/OUT) */ 830/* dma channel stopped ... normal tx end (IN), or on error (IN/OUT) */
831static void dma_nodesc_handler(int dmach, void *_ep, struct pt_regs *r) 831static void dma_nodesc_handler(int dmach, void *_ep)
832{ 832{
833 struct pxa2xx_ep *ep = _ep; 833 struct pxa2xx_ep *ep = _ep;
834 struct pxa2xx_request *req; 834 struct pxa2xx_request *req;
@@ -1724,7 +1724,7 @@ EXPORT_SYMBOL(usb_gadget_unregister_driver);
1724 */ 1724 */
1725 1725
1726static irqreturn_t 1726static irqreturn_t
1727lubbock_vbus_irq(int irq, void *_dev, struct pt_regs *r) 1727lubbock_vbus_irq(int irq, void *_dev)
1728{ 1728{
1729 struct pxa2xx_udc *dev = _dev; 1729 struct pxa2xx_udc *dev = _dev;
1730 int vbus; 1730 int vbus;
@@ -1754,8 +1754,7 @@ lubbock_vbus_irq(int irq, void *_dev, struct pt_regs *r)
1754 1754
1755#endif 1755#endif
1756 1756
1757static irqreturn_t 1757static irqreturn_t udc_vbus_irq(int irq, void *_dev)
1758udc_vbus_irq(int irq, void *_dev, struct pt_regs *r)
1759{ 1758{
1760 struct pxa2xx_udc *dev = _dev; 1759 struct pxa2xx_udc *dev = _dev;
1761 int vbus = pxa_gpio_get(dev->mach->gpio_vbus); 1760 int vbus = pxa_gpio_get(dev->mach->gpio_vbus);
@@ -2084,7 +2083,7 @@ static void handle_ep(struct pxa2xx_ep *ep)
2084 * could cause usb protocol errors. 2083 * could cause usb protocol errors.
2085 */ 2084 */
2086static irqreturn_t 2085static irqreturn_t
2087pxa2xx_udc_irq(int irq, void *_dev, struct pt_regs *r) 2086pxa2xx_udc_irq(int irq, void *_dev)
2088{ 2087{
2089 struct pxa2xx_udc *dev = _dev; 2088 struct pxa2xx_udc *dev = _dev;
2090 int handled; 2089 int handled;
diff --git a/drivers/usb/host/ehci-dbg.c b/drivers/usb/host/ehci-dbg.c
index 23b95b2bfe15..34b7a31cd85b 100644
--- a/drivers/usb/host/ehci-dbg.c
+++ b/drivers/usb/host/ehci-dbg.c
@@ -754,7 +754,9 @@ show_registers (struct class_device *class_dev, char *buf)
754 } 754 }
755 755
756 if (ehci->reclaim) { 756 if (ehci->reclaim) {
757 temp = scnprintf (next, size, "reclaim qh %p\n", ehci->reclaim); 757 temp = scnprintf (next, size, "reclaim qh %p%s\n",
758 ehci->reclaim,
759 ehci->reclaim_ready ? " ready" : "");
758 size -= temp; 760 size -= temp;
759 next += temp; 761 next += temp;
760 } 762 }
diff --git a/drivers/usb/host/ehci-hcd.c b/drivers/usb/host/ehci-hcd.c
index 5ac918591131..9030994aba98 100644
--- a/drivers/usb/host/ehci-hcd.c
+++ b/drivers/usb/host/ehci-hcd.c
@@ -111,7 +111,7 @@ static const char hcd_name [] = "ehci_hcd";
111#define EHCI_TUNE_MULT_TT 1 111#define EHCI_TUNE_MULT_TT 1
112#define EHCI_TUNE_FLS 2 /* (small) 256 frame schedule */ 112#define EHCI_TUNE_FLS 2 /* (small) 256 frame schedule */
113 113
114#define EHCI_IAA_MSECS 10 /* arbitrary */ 114#define EHCI_IAA_JIFFIES (HZ/100) /* arbitrary; ~10 msec */
115#define EHCI_IO_JIFFIES (HZ/10) /* io watchdog > irq_thresh */ 115#define EHCI_IO_JIFFIES (HZ/10) /* io watchdog > irq_thresh */
116#define EHCI_ASYNC_JIFFIES (HZ/20) /* async idle timeout */ 116#define EHCI_ASYNC_JIFFIES (HZ/20) /* async idle timeout */
117#define EHCI_SHRINK_JIFFIES (HZ/200) /* async qh unlink delay */ 117#define EHCI_SHRINK_JIFFIES (HZ/200) /* async qh unlink delay */
@@ -254,8 +254,7 @@ static void ehci_quiesce (struct ehci_hcd *ehci)
254 254
255/*-------------------------------------------------------------------------*/ 255/*-------------------------------------------------------------------------*/
256 256
257static void end_unlink_async (struct ehci_hcd *ehci, struct pt_regs *regs); 257static void ehci_work(struct ehci_hcd *ehci);
258static void ehci_work(struct ehci_hcd *ehci, struct pt_regs *regs);
259 258
260#include "ehci-hub.c" 259#include "ehci-hub.c"
261#include "ehci-mem.c" 260#include "ehci-mem.c"
@@ -264,42 +263,30 @@ static void ehci_work(struct ehci_hcd *ehci, struct pt_regs *regs);
264 263
265/*-------------------------------------------------------------------------*/ 264/*-------------------------------------------------------------------------*/
266 265
267static void ehci_iaa_watchdog (unsigned long param) 266static void ehci_watchdog (unsigned long param)
268{ 267{
269 struct ehci_hcd *ehci = (struct ehci_hcd *) param; 268 struct ehci_hcd *ehci = (struct ehci_hcd *) param;
270 unsigned long flags; 269 unsigned long flags;
271 u32 status;
272 270
273 spin_lock_irqsave (&ehci->lock, flags); 271 spin_lock_irqsave (&ehci->lock, flags);
274 WARN_ON(!ehci->reclaim);
275 272
276 /* lost IAA irqs wedge things badly; seen first with a vt8235 */ 273 /* lost IAA irqs wedge things badly; seen with a vt8235 */
277 if (ehci->reclaim) { 274 if (ehci->reclaim) {
278 status = readl (&ehci->regs->status); 275 u32 status = readl (&ehci->regs->status);
279 if (status & STS_IAA) { 276 if (status & STS_IAA) {
280 ehci_vdbg (ehci, "lost IAA\n"); 277 ehci_vdbg (ehci, "lost IAA\n");
281 COUNT (ehci->stats.lost_iaa); 278 COUNT (ehci->stats.lost_iaa);
282 writel (STS_IAA, &ehci->regs->status); 279 writel (STS_IAA, &ehci->regs->status);
283 end_unlink_async (ehci, NULL); 280 ehci->reclaim_ready = 1;
284 } 281 }
285 } 282 }
286 283
287 spin_unlock_irqrestore (&ehci->lock, flags); 284 /* stop async processing after it's idled a bit */
288}
289
290static void ehci_watchdog (unsigned long param)
291{
292 struct ehci_hcd *ehci = (struct ehci_hcd *) param;
293 unsigned long flags;
294
295 spin_lock_irqsave (&ehci->lock, flags);
296
297 /* stop async processing after it's idled a bit */
298 if (test_bit (TIMER_ASYNC_OFF, &ehci->actions)) 285 if (test_bit (TIMER_ASYNC_OFF, &ehci->actions))
299 start_unlink_async (ehci, ehci->async); 286 start_unlink_async (ehci, ehci->async);
300 287
301 /* ehci could run by timer, without IRQs ... */ 288 /* ehci could run by timer, without IRQs ... */
302 ehci_work (ehci, NULL); 289 ehci_work (ehci);
303 290
304 spin_unlock_irqrestore (&ehci->lock, flags); 291 spin_unlock_irqrestore (&ehci->lock, flags);
305} 292}
@@ -342,9 +329,11 @@ static void ehci_port_power (struct ehci_hcd *ehci, int is_on)
342 * ehci_work is called from some interrupts, timers, and so on. 329 * ehci_work is called from some interrupts, timers, and so on.
343 * it calls driver completion functions, after dropping ehci->lock. 330 * it calls driver completion functions, after dropping ehci->lock.
344 */ 331 */
345static void ehci_work (struct ehci_hcd *ehci, struct pt_regs *regs) 332static void ehci_work (struct ehci_hcd *ehci)
346{ 333{
347 timer_action_done (ehci, TIMER_IO_WATCHDOG); 334 timer_action_done (ehci, TIMER_IO_WATCHDOG);
335 if (ehci->reclaim_ready)
336 end_unlink_async (ehci);
348 337
349 /* another CPU may drop ehci->lock during a schedule scan while 338 /* another CPU may drop ehci->lock during a schedule scan while
350 * it reports urb completions. this flag guards against bogus 339 * it reports urb completions. this flag guards against bogus
@@ -353,9 +342,9 @@ static void ehci_work (struct ehci_hcd *ehci, struct pt_regs *regs)
353 if (ehci->scanning) 342 if (ehci->scanning)
354 return; 343 return;
355 ehci->scanning = 1; 344 ehci->scanning = 1;
356 scan_async (ehci, regs); 345 scan_async (ehci);
357 if (ehci->next_uframe != -1) 346 if (ehci->next_uframe != -1)
358 scan_periodic (ehci, regs); 347 scan_periodic (ehci);
359 ehci->scanning = 0; 348 ehci->scanning = 0;
360 349
361 /* the IO watchdog guards against hardware or driver bugs that 350 /* the IO watchdog guards against hardware or driver bugs that
@@ -379,7 +368,6 @@ static void ehci_stop (struct usb_hcd *hcd)
379 368
380 /* no more interrupts ... */ 369 /* no more interrupts ... */
381 del_timer_sync (&ehci->watchdog); 370 del_timer_sync (&ehci->watchdog);
382 del_timer_sync (&ehci->iaa_watchdog);
383 371
384 spin_lock_irq(&ehci->lock); 372 spin_lock_irq(&ehci->lock);
385 if (HC_IS_RUNNING (hcd->state)) 373 if (HC_IS_RUNNING (hcd->state))
@@ -397,7 +385,7 @@ static void ehci_stop (struct usb_hcd *hcd)
397 /* root hub is shut down separately (first, when possible) */ 385 /* root hub is shut down separately (first, when possible) */
398 spin_lock_irq (&ehci->lock); 386 spin_lock_irq (&ehci->lock);
399 if (ehci->async) 387 if (ehci->async)
400 ehci_work (ehci, NULL); 388 ehci_work (ehci);
401 spin_unlock_irq (&ehci->lock); 389 spin_unlock_irq (&ehci->lock);
402 ehci_mem_cleanup (ehci); 390 ehci_mem_cleanup (ehci);
403 391
@@ -426,10 +414,6 @@ static int ehci_init(struct usb_hcd *hcd)
426 ehci->watchdog.function = ehci_watchdog; 414 ehci->watchdog.function = ehci_watchdog;
427 ehci->watchdog.data = (unsigned long) ehci; 415 ehci->watchdog.data = (unsigned long) ehci;
428 416
429 init_timer(&ehci->iaa_watchdog);
430 ehci->iaa_watchdog.function = ehci_iaa_watchdog;
431 ehci->iaa_watchdog.data = (unsigned long) ehci;
432
433 /* 417 /*
434 * hw default: 1K periodic list heads, one per frame. 418 * hw default: 1K periodic list heads, one per frame.
435 * periodic_size can shrink by USBCMD update if hcc_params allows. 419 * periodic_size can shrink by USBCMD update if hcc_params allows.
@@ -446,6 +430,7 @@ static int ehci_init(struct usb_hcd *hcd)
446 ehci->i_thresh = 2 + HCC_ISOC_THRES(hcc_params); 430 ehci->i_thresh = 2 + HCC_ISOC_THRES(hcc_params);
447 431
448 ehci->reclaim = NULL; 432 ehci->reclaim = NULL;
433 ehci->reclaim_ready = 0;
449 ehci->next_uframe = -1; 434 ehci->next_uframe = -1;
450 435
451 /* 436 /*
@@ -573,7 +558,7 @@ static int ehci_run (struct usb_hcd *hcd)
573 558
574/*-------------------------------------------------------------------------*/ 559/*-------------------------------------------------------------------------*/
575 560
576static irqreturn_t ehci_irq (struct usb_hcd *hcd, struct pt_regs *regs) 561static irqreturn_t ehci_irq (struct usb_hcd *hcd)
577{ 562{
578 struct ehci_hcd *ehci = hcd_to_ehci (hcd); 563 struct ehci_hcd *ehci = hcd_to_ehci (hcd);
579 u32 status; 564 u32 status;
@@ -619,7 +604,7 @@ static irqreturn_t ehci_irq (struct usb_hcd *hcd, struct pt_regs *regs)
619 /* complete the unlinking of some qh [4.15.2.3] */ 604 /* complete the unlinking of some qh [4.15.2.3] */
620 if (status & STS_IAA) { 605 if (status & STS_IAA) {
621 COUNT (ehci->stats.reclaim); 606 COUNT (ehci->stats.reclaim);
622 end_unlink_async (ehci, regs); 607 ehci->reclaim_ready = 1;
623 bh = 1; 608 bh = 1;
624 } 609 }
625 610
@@ -670,7 +655,7 @@ dead:
670 } 655 }
671 656
672 if (bh) 657 if (bh)
673 ehci_work (ehci, regs); 658 ehci_work (ehci);
674 spin_unlock (&ehci->lock); 659 spin_unlock (&ehci->lock);
675 return IRQ_HANDLED; 660 return IRQ_HANDLED;
676} 661}
@@ -723,14 +708,10 @@ static int ehci_urb_enqueue (
723 708
724static void unlink_async (struct ehci_hcd *ehci, struct ehci_qh *qh) 709static void unlink_async (struct ehci_hcd *ehci, struct ehci_qh *qh)
725{ 710{
726 // BUG_ON(qh->qh_state != QH_STATE_LINKED); 711 /* if we need to use IAA and it's busy, defer */
727 712 if (qh->qh_state == QH_STATE_LINKED
728 /* failfast */ 713 && ehci->reclaim
729 if (!HC_IS_RUNNING (ehci_to_hcd(ehci)->state)) 714 && HC_IS_RUNNING (ehci_to_hcd(ehci)->state)) {
730 end_unlink_async (ehci, NULL);
731
732 /* defer till later if busy */
733 else if (ehci->reclaim) {
734 struct ehci_qh *last; 715 struct ehci_qh *last;
735 716
736 for (last = ehci->reclaim; 717 for (last = ehci->reclaim;
@@ -740,8 +721,12 @@ static void unlink_async (struct ehci_hcd *ehci, struct ehci_qh *qh)
740 qh->qh_state = QH_STATE_UNLINK_WAIT; 721 qh->qh_state = QH_STATE_UNLINK_WAIT;
741 last->reclaim = qh; 722 last->reclaim = qh;
742 723
743 /* start IAA cycle */ 724 /* bypass IAA if the hc can't care */
744 } else 725 } else if (!HC_IS_RUNNING (ehci_to_hcd(ehci)->state) && ehci->reclaim)
726 end_unlink_async (ehci);
727
728 /* something else might have unlinked the qh by now */
729 if (qh->qh_state == QH_STATE_LINKED)
745 start_unlink_async (ehci, qh); 730 start_unlink_async (ehci, qh);
746} 731}
747 732
@@ -763,19 +748,7 @@ static int ehci_urb_dequeue (struct usb_hcd *hcd, struct urb *urb)
763 qh = (struct ehci_qh *) urb->hcpriv; 748 qh = (struct ehci_qh *) urb->hcpriv;
764 if (!qh) 749 if (!qh)
765 break; 750 break;
766 switch (qh->qh_state) { 751 unlink_async (ehci, qh);
767 case QH_STATE_LINKED:
768 case QH_STATE_COMPLETING:
769 unlink_async (ehci, qh);
770 break;
771 case QH_STATE_UNLINK:
772 case QH_STATE_UNLINK_WAIT:
773 /* already started */
774 break;
775 case QH_STATE_IDLE:
776 WARN_ON(1);
777 break;
778 }
779 break; 752 break;
780 753
781 case PIPE_INTERRUPT: 754 case PIPE_INTERRUPT:
@@ -787,7 +760,7 @@ static int ehci_urb_dequeue (struct usb_hcd *hcd, struct urb *urb)
787 intr_deschedule (ehci, qh); 760 intr_deschedule (ehci, qh);
788 /* FALL THROUGH */ 761 /* FALL THROUGH */
789 case QH_STATE_IDLE: 762 case QH_STATE_IDLE:
790 qh_completions (ehci, qh, NULL); 763 qh_completions (ehci, qh);
791 break; 764 break;
792 default: 765 default:
793 ehci_dbg (ehci, "bogus qh %p state %d\n", 766 ehci_dbg (ehci, "bogus qh %p state %d\n",
@@ -867,7 +840,6 @@ rescan:
867 unlink_async (ehci, qh); 840 unlink_async (ehci, qh);
868 /* FALL THROUGH */ 841 /* FALL THROUGH */
869 case QH_STATE_UNLINK: /* wait for hw to finish? */ 842 case QH_STATE_UNLINK: /* wait for hw to finish? */
870 case QH_STATE_UNLINK_WAIT:
871idle_timeout: 843idle_timeout:
872 spin_unlock_irqrestore (&ehci->lock, flags); 844 spin_unlock_irqrestore (&ehci->lock, flags);
873 schedule_timeout_uninterruptible(1); 845 schedule_timeout_uninterruptible(1);
diff --git a/drivers/usb/host/ehci-hub.c b/drivers/usb/host/ehci-hub.c
index b2ee13c58517..1b20722c102b 100644
--- a/drivers/usb/host/ehci-hub.c
+++ b/drivers/usb/host/ehci-hub.c
@@ -48,8 +48,8 @@ static int ehci_bus_suspend (struct usb_hcd *hcd)
48 } 48 }
49 ehci->command = readl (&ehci->regs->command); 49 ehci->command = readl (&ehci->regs->command);
50 if (ehci->reclaim) 50 if (ehci->reclaim)
51 end_unlink_async (ehci, NULL); 51 ehci->reclaim_ready = 1;
52 ehci_work(ehci, NULL); 52 ehci_work(ehci);
53 53
54 /* suspend any active/unsuspended ports, maybe allow wakeup */ 54 /* suspend any active/unsuspended ports, maybe allow wakeup */
55 while (port--) { 55 while (port--) {
diff --git a/drivers/usb/host/ehci-pci.c b/drivers/usb/host/ehci-pci.c
index 08d0472d4f57..e51c1ed81ac4 100644
--- a/drivers/usb/host/ehci-pci.c
+++ b/drivers/usb/host/ehci-pci.c
@@ -303,8 +303,8 @@ restart:
303 /* emptying the schedule aborts any urbs */ 303 /* emptying the schedule aborts any urbs */
304 spin_lock_irq(&ehci->lock); 304 spin_lock_irq(&ehci->lock);
305 if (ehci->reclaim) 305 if (ehci->reclaim)
306 end_unlink_async (ehci, NULL); 306 ehci->reclaim_ready = 1;
307 ehci_work(ehci, NULL); 307 ehci_work(ehci);
308 spin_unlock_irq(&ehci->lock); 308 spin_unlock_irq(&ehci->lock);
309 309
310 /* restart; khubd will disconnect devices */ 310 /* restart; khubd will disconnect devices */
diff --git a/drivers/usb/host/ehci-q.c b/drivers/usb/host/ehci-q.c
index 7fc25b6bd7d2..62e46dc60e86 100644
--- a/drivers/usb/host/ehci-q.c
+++ b/drivers/usb/host/ehci-q.c
@@ -214,7 +214,7 @@ static void qtd_copy_status (
214} 214}
215 215
216static void 216static void
217ehci_urb_done (struct ehci_hcd *ehci, struct urb *urb, struct pt_regs *regs) 217ehci_urb_done (struct ehci_hcd *ehci, struct urb *urb)
218__releases(ehci->lock) 218__releases(ehci->lock)
219__acquires(ehci->lock) 219__acquires(ehci->lock)
220{ 220{
@@ -262,7 +262,7 @@ __acquires(ehci->lock)
262 262
263 /* complete() can reenter this HCD */ 263 /* complete() can reenter this HCD */
264 spin_unlock (&ehci->lock); 264 spin_unlock (&ehci->lock);
265 usb_hcd_giveback_urb (ehci_to_hcd(ehci), urb, regs); 265 usb_hcd_giveback_urb (ehci_to_hcd(ehci), urb);
266 spin_lock (&ehci->lock); 266 spin_lock (&ehci->lock);
267} 267}
268 268
@@ -279,7 +279,7 @@ static int qh_schedule (struct ehci_hcd *ehci, struct ehci_qh *qh);
279 */ 279 */
280#define HALT_BIT __constant_cpu_to_le32(QTD_STS_HALT) 280#define HALT_BIT __constant_cpu_to_le32(QTD_STS_HALT)
281static unsigned 281static unsigned
282qh_completions (struct ehci_hcd *ehci, struct ehci_qh *qh, struct pt_regs *regs) 282qh_completions (struct ehci_hcd *ehci, struct ehci_qh *qh)
283{ 283{
284 struct ehci_qtd *last = NULL, *end = qh->dummy; 284 struct ehci_qtd *last = NULL, *end = qh->dummy;
285 struct list_head *entry, *tmp; 285 struct list_head *entry, *tmp;
@@ -317,7 +317,7 @@ qh_completions (struct ehci_hcd *ehci, struct ehci_qh *qh, struct pt_regs *regs)
317 /* clean up any state from previous QTD ...*/ 317 /* clean up any state from previous QTD ...*/
318 if (last) { 318 if (last) {
319 if (likely (last->urb != urb)) { 319 if (likely (last->urb != urb)) {
320 ehci_urb_done (ehci, last->urb, regs); 320 ehci_urb_done (ehci, last->urb);
321 count++; 321 count++;
322 } 322 }
323 ehci_qtd_free (ehci, last); 323 ehci_qtd_free (ehci, last);
@@ -407,7 +407,7 @@ halt:
407 407
408 /* last urb's completion might still need calling */ 408 /* last urb's completion might still need calling */
409 if (likely (last != NULL)) { 409 if (likely (last != NULL)) {
410 ehci_urb_done (ehci, last->urb, regs); 410 ehci_urb_done (ehci, last->urb);
411 count++; 411 count++;
412 ehci_qtd_free (ehci, last); 412 ehci_qtd_free (ehci, last);
413 } 413 }
@@ -962,12 +962,12 @@ submit_async (
962 962
963/* the async qh for the qtds being reclaimed are now unlinked from the HC */ 963/* the async qh for the qtds being reclaimed are now unlinked from the HC */
964 964
965static void end_unlink_async (struct ehci_hcd *ehci, struct pt_regs *regs) 965static void end_unlink_async (struct ehci_hcd *ehci)
966{ 966{
967 struct ehci_qh *qh = ehci->reclaim; 967 struct ehci_qh *qh = ehci->reclaim;
968 struct ehci_qh *next; 968 struct ehci_qh *next;
969 969
970 iaa_watchdog_done (ehci); 970 timer_action_done (ehci, TIMER_IAA_WATCHDOG);
971 971
972 // qh->hw_next = cpu_to_le32 (qh->qh_dma); 972 // qh->hw_next = cpu_to_le32 (qh->qh_dma);
973 qh->qh_state = QH_STATE_IDLE; 973 qh->qh_state = QH_STATE_IDLE;
@@ -977,9 +977,10 @@ static void end_unlink_async (struct ehci_hcd *ehci, struct pt_regs *regs)
977 /* other unlink(s) may be pending (in QH_STATE_UNLINK_WAIT) */ 977 /* other unlink(s) may be pending (in QH_STATE_UNLINK_WAIT) */
978 next = qh->reclaim; 978 next = qh->reclaim;
979 ehci->reclaim = next; 979 ehci->reclaim = next;
980 ehci->reclaim_ready = 0;
980 qh->reclaim = NULL; 981 qh->reclaim = NULL;
981 982
982 qh_completions (ehci, qh, regs); 983 qh_completions (ehci, qh);
983 984
984 if (!list_empty (&qh->qtd_list) 985 if (!list_empty (&qh->qtd_list)
985 && HC_IS_RUNNING (ehci_to_hcd(ehci)->state)) 986 && HC_IS_RUNNING (ehci_to_hcd(ehci)->state))
@@ -1047,20 +1048,20 @@ static void start_unlink_async (struct ehci_hcd *ehci, struct ehci_qh *qh)
1047 /* if (unlikely (qh->reclaim != 0)) 1048 /* if (unlikely (qh->reclaim != 0))
1048 * this will recurse, probably not much 1049 * this will recurse, probably not much
1049 */ 1050 */
1050 end_unlink_async (ehci, NULL); 1051 end_unlink_async (ehci);
1051 return; 1052 return;
1052 } 1053 }
1053 1054
1055 ehci->reclaim_ready = 0;
1054 cmd |= CMD_IAAD; 1056 cmd |= CMD_IAAD;
1055 writel (cmd, &ehci->regs->command); 1057 writel (cmd, &ehci->regs->command);
1056 (void) readl (&ehci->regs->command); 1058 (void) readl (&ehci->regs->command);
1057 iaa_watchdog_start (ehci); 1059 timer_action (ehci, TIMER_IAA_WATCHDOG);
1058} 1060}
1059 1061
1060/*-------------------------------------------------------------------------*/ 1062/*-------------------------------------------------------------------------*/
1061 1063
1062static void 1064static void scan_async (struct ehci_hcd *ehci)
1063scan_async (struct ehci_hcd *ehci, struct pt_regs *regs)
1064{ 1065{
1065 struct ehci_qh *qh; 1066 struct ehci_qh *qh;
1066 enum ehci_timer_action action = TIMER_IO_WATCHDOG; 1067 enum ehci_timer_action action = TIMER_IO_WATCHDOG;
@@ -1084,7 +1085,7 @@ rescan:
1084 */ 1085 */
1085 qh = qh_get (qh); 1086 qh = qh_get (qh);
1086 qh->stamp = ehci->stamp; 1087 qh->stamp = ehci->stamp;
1087 temp = qh_completions (ehci, qh, regs); 1088 temp = qh_completions (ehci, qh);
1088 qh_put (qh); 1089 qh_put (qh);
1089 if (temp != 0) { 1090 if (temp != 0) {
1090 goto rescan; 1091 goto rescan;
diff --git a/drivers/usb/host/ehci-sched.c b/drivers/usb/host/ehci-sched.c
index e5e9c653c907..65c402a0fa7a 100644
--- a/drivers/usb/host/ehci-sched.c
+++ b/drivers/usb/host/ehci-sched.c
@@ -1553,8 +1553,7 @@ itd_link_urb (
1553static unsigned 1553static unsigned
1554itd_complete ( 1554itd_complete (
1555 struct ehci_hcd *ehci, 1555 struct ehci_hcd *ehci,
1556 struct ehci_itd *itd, 1556 struct ehci_itd *itd
1557 struct pt_regs *regs
1558) { 1557) {
1559 struct urb *urb = itd->urb; 1558 struct urb *urb = itd->urb;
1560 struct usb_iso_packet_descriptor *desc; 1559 struct usb_iso_packet_descriptor *desc;
@@ -1613,7 +1612,7 @@ itd_complete (
1613 1612
1614 /* give urb back to the driver ... can be out-of-order */ 1613 /* give urb back to the driver ... can be out-of-order */
1615 dev = urb->dev; 1614 dev = urb->dev;
1616 ehci_urb_done (ehci, urb, regs); 1615 ehci_urb_done (ehci, urb);
1617 urb = NULL; 1616 urb = NULL;
1618 1617
1619 /* defer stopping schedule; completion can submit */ 1618 /* defer stopping schedule; completion can submit */
@@ -1930,8 +1929,7 @@ sitd_link_urb (
1930static unsigned 1929static unsigned
1931sitd_complete ( 1930sitd_complete (
1932 struct ehci_hcd *ehci, 1931 struct ehci_hcd *ehci,
1933 struct ehci_sitd *sitd, 1932 struct ehci_sitd *sitd
1934 struct pt_regs *regs
1935) { 1933) {
1936 struct urb *urb = sitd->urb; 1934 struct urb *urb = sitd->urb;
1937 struct usb_iso_packet_descriptor *desc; 1935 struct usb_iso_packet_descriptor *desc;
@@ -1978,7 +1976,7 @@ sitd_complete (
1978 1976
1979 /* give urb back to the driver */ 1977 /* give urb back to the driver */
1980 dev = urb->dev; 1978 dev = urb->dev;
1981 ehci_urb_done (ehci, urb, regs); 1979 ehci_urb_done (ehci, urb);
1982 urb = NULL; 1980 urb = NULL;
1983 1981
1984 /* defer stopping schedule; completion can submit */ 1982 /* defer stopping schedule; completion can submit */
@@ -2065,8 +2063,7 @@ sitd_submit (struct ehci_hcd *ehci, struct urb *urb, gfp_t mem_flags)
2065static inline unsigned 2063static inline unsigned
2066sitd_complete ( 2064sitd_complete (
2067 struct ehci_hcd *ehci, 2065 struct ehci_hcd *ehci,
2068 struct ehci_sitd *sitd, 2066 struct ehci_sitd *sitd
2069 struct pt_regs *regs
2070) { 2067) {
2071 ehci_err (ehci, "sitd_complete %p?\n", sitd); 2068 ehci_err (ehci, "sitd_complete %p?\n", sitd);
2072 return 0; 2069 return 0;
@@ -2077,7 +2074,7 @@ sitd_complete (
2077/*-------------------------------------------------------------------------*/ 2074/*-------------------------------------------------------------------------*/
2078 2075
2079static void 2076static void
2080scan_periodic (struct ehci_hcd *ehci, struct pt_regs *regs) 2077scan_periodic (struct ehci_hcd *ehci)
2081{ 2078{
2082 unsigned frame, clock, now_uframe, mod; 2079 unsigned frame, clock, now_uframe, mod;
2083 unsigned modified; 2080 unsigned modified;
@@ -2131,7 +2128,7 @@ restart:
2131 temp.qh = qh_get (q.qh); 2128 temp.qh = qh_get (q.qh);
2132 type = Q_NEXT_TYPE (q.qh->hw_next); 2129 type = Q_NEXT_TYPE (q.qh->hw_next);
2133 q = q.qh->qh_next; 2130 q = q.qh->qh_next;
2134 modified = qh_completions (ehci, temp.qh, regs); 2131 modified = qh_completions (ehci, temp.qh);
2135 if (unlikely (list_empty (&temp.qh->qtd_list))) 2132 if (unlikely (list_empty (&temp.qh->qtd_list)))
2136 intr_deschedule (ehci, temp.qh); 2133 intr_deschedule (ehci, temp.qh);
2137 qh_put (temp.qh); 2134 qh_put (temp.qh);
@@ -2169,7 +2166,7 @@ restart:
2169 *hw_p = q.itd->hw_next; 2166 *hw_p = q.itd->hw_next;
2170 type = Q_NEXT_TYPE (q.itd->hw_next); 2167 type = Q_NEXT_TYPE (q.itd->hw_next);
2171 wmb(); 2168 wmb();
2172 modified = itd_complete (ehci, q.itd, regs); 2169 modified = itd_complete (ehci, q.itd);
2173 q = *q_p; 2170 q = *q_p;
2174 break; 2171 break;
2175 case Q_TYPE_SITD: 2172 case Q_TYPE_SITD:
@@ -2185,7 +2182,7 @@ restart:
2185 *hw_p = q.sitd->hw_next; 2182 *hw_p = q.sitd->hw_next;
2186 type = Q_NEXT_TYPE (q.sitd->hw_next); 2183 type = Q_NEXT_TYPE (q.sitd->hw_next);
2187 wmb(); 2184 wmb();
2188 modified = sitd_complete (ehci, q.sitd, regs); 2185 modified = sitd_complete (ehci, q.sitd);
2189 q = *q_p; 2186 q = *q_p;
2190 break; 2187 break;
2191 default: 2188 default:
diff --git a/drivers/usb/host/ehci.h b/drivers/usb/host/ehci.h
index 6aac39f50e07..bbc3082a73d7 100644
--- a/drivers/usb/host/ehci.h
+++ b/drivers/usb/host/ehci.h
@@ -58,6 +58,7 @@ struct ehci_hcd { /* one per controller */
58 /* async schedule support */ 58 /* async schedule support */
59 struct ehci_qh *async; 59 struct ehci_qh *async;
60 struct ehci_qh *reclaim; 60 struct ehci_qh *reclaim;
61 unsigned reclaim_ready : 1;
61 unsigned scanning : 1; 62 unsigned scanning : 1;
62 63
63 /* periodic schedule support */ 64 /* periodic schedule support */
@@ -80,7 +81,6 @@ struct ehci_hcd { /* one per controller */
80 struct dma_pool *itd_pool; /* itd per iso urb */ 81 struct dma_pool *itd_pool; /* itd per iso urb */
81 struct dma_pool *sitd_pool; /* sitd per split iso urb */ 82 struct dma_pool *sitd_pool; /* sitd per split iso urb */
82 83
83 struct timer_list iaa_watchdog;
84 struct timer_list watchdog; 84 struct timer_list watchdog;
85 unsigned long actions; 85 unsigned long actions;
86 unsigned stamp; 86 unsigned stamp;
@@ -114,21 +114,9 @@ static inline struct usb_hcd *ehci_to_hcd (struct ehci_hcd *ehci)
114} 114}
115 115
116 116
117static inline void
118iaa_watchdog_start (struct ehci_hcd *ehci)
119{
120 WARN_ON(timer_pending(&ehci->iaa_watchdog));
121 mod_timer (&ehci->iaa_watchdog,
122 jiffies + msecs_to_jiffies(EHCI_IAA_MSECS));
123}
124
125static inline void iaa_watchdog_done (struct ehci_hcd *ehci)
126{
127 del_timer (&ehci->iaa_watchdog);
128}
129
130enum ehci_timer_action { 117enum ehci_timer_action {
131 TIMER_IO_WATCHDOG, 118 TIMER_IO_WATCHDOG,
119 TIMER_IAA_WATCHDOG,
132 TIMER_ASYNC_SHRINK, 120 TIMER_ASYNC_SHRINK,
133 TIMER_ASYNC_OFF, 121 TIMER_ASYNC_OFF,
134}; 122};
@@ -146,6 +134,9 @@ timer_action (struct ehci_hcd *ehci, enum ehci_timer_action action)
146 unsigned long t; 134 unsigned long t;
147 135
148 switch (action) { 136 switch (action) {
137 case TIMER_IAA_WATCHDOG:
138 t = EHCI_IAA_JIFFIES;
139 break;
149 case TIMER_IO_WATCHDOG: 140 case TIMER_IO_WATCHDOG:
150 t = EHCI_IO_JIFFIES; 141 t = EHCI_IO_JIFFIES;
151 break; 142 break;
@@ -162,7 +153,8 @@ timer_action (struct ehci_hcd *ehci, enum ehci_timer_action action)
162 // async queue SHRINK often precedes IAA. while it's ready 153 // async queue SHRINK often precedes IAA. while it's ready
163 // to go OFF neither can matter, and afterwards the IO 154 // to go OFF neither can matter, and afterwards the IO
164 // watchdog stops unless there's still periodic traffic. 155 // watchdog stops unless there's still periodic traffic.
165 if (time_before_eq(t, ehci->watchdog.expires) 156 if (action != TIMER_IAA_WATCHDOG
157 && t > ehci->watchdog.expires
166 && timer_pending (&ehci->watchdog)) 158 && timer_pending (&ehci->watchdog))
167 return; 159 return;
168 mod_timer (&ehci->watchdog, t); 160 mod_timer (&ehci->watchdog, t);
diff --git a/drivers/usb/host/hc_crisv10.c b/drivers/usb/host/hc_crisv10.c
index 61e571782cf7..87eca6aeacf2 100644
--- a/drivers/usb/host/hc_crisv10.c
+++ b/drivers/usb/host/hc_crisv10.c
@@ -478,9 +478,9 @@ static int etrax_usb_submit_urb(struct urb *urb, unsigned mem_flags);
478static int etrax_usb_unlink_urb(struct urb *urb, int status); 478static int etrax_usb_unlink_urb(struct urb *urb, int status);
479static int etrax_usb_get_frame_number(struct usb_device *usb_dev); 479static int etrax_usb_get_frame_number(struct usb_device *usb_dev);
480 480
481static irqreturn_t etrax_usb_tx_interrupt(int irq, void *vhc, struct pt_regs *regs); 481static irqreturn_t etrax_usb_tx_interrupt(int irq, void *vhc);
482static irqreturn_t etrax_usb_rx_interrupt(int irq, void *vhc, struct pt_regs *regs); 482static irqreturn_t etrax_usb_rx_interrupt(int irq, void *vhc);
483static irqreturn_t etrax_usb_hc_interrupt_top_half(int irq, void *vhc, struct pt_regs *regs); 483static irqreturn_t etrax_usb_hc_interrupt_top_half(int irq, void *vhc);
484static void etrax_usb_hc_interrupt_bottom_half(void *data); 484static void etrax_usb_hc_interrupt_bottom_half(void *data);
485 485
486static void etrax_usb_isoc_descr_interrupt_bottom_half(void *data); 486static void etrax_usb_isoc_descr_interrupt_bottom_half(void *data);
@@ -1573,7 +1573,7 @@ static int etrax_usb_get_frame_number(struct usb_device *usb_dev)
1573 return (*R_USB_FM_NUMBER & 0x7ff); 1573 return (*R_USB_FM_NUMBER & 0x7ff);
1574} 1574}
1575 1575
1576static irqreturn_t etrax_usb_tx_interrupt(int irq, void *vhc, struct pt_regs *regs) 1576static irqreturn_t etrax_usb_tx_interrupt(int irq, void *vhc)
1577{ 1577{
1578 DBFENTER; 1578 DBFENTER;
1579 1579
@@ -1839,7 +1839,7 @@ static void etrax_usb_isoc_descr_interrupt_bottom_half(void *data)
1839 1839
1840 1840
1841 1841
1842static irqreturn_t etrax_usb_rx_interrupt(int irq, void *vhc, struct pt_regs *regs) 1842static irqreturn_t etrax_usb_rx_interrupt(int irq, void *vhc)
1843{ 1843{
1844 struct urb *urb; 1844 struct urb *urb;
1845 etrax_urb_priv_t *urb_priv; 1845 etrax_urb_priv_t *urb_priv;
@@ -3280,7 +3280,7 @@ static void etrax_usb_complete_urb(struct urb *urb, int status)
3280 3280
3281 3281
3282 3282
3283static irqreturn_t etrax_usb_hc_interrupt_top_half(int irq, void *vhc, struct pt_regs *regs) 3283static irqreturn_t etrax_usb_hc_interrupt_top_half(int irq, void *vhc)
3284{ 3284{
3285 usb_interrupt_registers_t *reg; 3285 usb_interrupt_registers_t *reg;
3286 unsigned long flags; 3286 unsigned long flags;
diff --git a/drivers/usb/host/isp116x-hcd.c b/drivers/usb/host/isp116x-hcd.c
index a72e041df8e7..2718b5dc4ec1 100644
--- a/drivers/usb/host/isp116x-hcd.c
+++ b/drivers/usb/host/isp116x-hcd.c
@@ -418,7 +418,7 @@ static void postproc_atl_queue(struct isp116x *isp116x)
418 processed urbs. 418 processed urbs.
419*/ 419*/
420static void finish_request(struct isp116x *isp116x, struct isp116x_ep *ep, 420static void finish_request(struct isp116x *isp116x, struct isp116x_ep *ep,
421 struct urb *urb, struct pt_regs *regs) 421 struct urb *urb)
422__releases(isp116x->lock) __acquires(isp116x->lock) 422__releases(isp116x->lock) __acquires(isp116x->lock)
423{ 423{
424 unsigned i; 424 unsigned i;
@@ -432,7 +432,7 @@ __releases(isp116x->lock) __acquires(isp116x->lock)
432 urb_dbg(urb, "Finish"); 432 urb_dbg(urb, "Finish");
433 433
434 spin_unlock(&isp116x->lock); 434 spin_unlock(&isp116x->lock);
435 usb_hcd_giveback_urb(isp116x_to_hcd(isp116x), urb, regs); 435 usb_hcd_giveback_urb(isp116x_to_hcd(isp116x), urb);
436 spin_lock(&isp116x->lock); 436 spin_lock(&isp116x->lock);
437 437
438 /* take idle endpoints out of the schedule */ 438 /* take idle endpoints out of the schedule */
@@ -568,7 +568,7 @@ static void start_atl_transfers(struct isp116x *isp116x)
568/* 568/*
569 Finish the processed transfers 569 Finish the processed transfers
570*/ 570*/
571static void finish_atl_transfers(struct isp116x *isp116x, struct pt_regs *regs) 571static void finish_atl_transfers(struct isp116x *isp116x)
572{ 572{
573 struct isp116x_ep *ep; 573 struct isp116x_ep *ep;
574 struct urb *urb; 574 struct urb *urb;
@@ -590,12 +590,12 @@ static void finish_atl_transfers(struct isp116x *isp116x, struct pt_regs *regs)
590 occured, while URB_SHORT_NOT_OK was set */ 590 occured, while URB_SHORT_NOT_OK was set */
591 if (urb && urb->status != -EINPROGRESS 591 if (urb && urb->status != -EINPROGRESS
592 && ep->nextpid != USB_PID_ACK) 592 && ep->nextpid != USB_PID_ACK)
593 finish_request(isp116x, ep, urb, regs); 593 finish_request(isp116x, ep, urb);
594 } 594 }
595 atomic_dec(&isp116x->atl_finishing); 595 atomic_dec(&isp116x->atl_finishing);
596} 596}
597 597
598static irqreturn_t isp116x_irq(struct usb_hcd *hcd, struct pt_regs *regs) 598static irqreturn_t isp116x_irq(struct usb_hcd *hcd)
599{ 599{
600 struct isp116x *isp116x = hcd_to_isp116x(hcd); 600 struct isp116x *isp116x = hcd_to_isp116x(hcd);
601 u16 irqstat; 601 u16 irqstat;
@@ -608,7 +608,7 @@ static irqreturn_t isp116x_irq(struct usb_hcd *hcd, struct pt_regs *regs)
608 608
609 if (irqstat & (HCuPINT_ATL | HCuPINT_SOF)) { 609 if (irqstat & (HCuPINT_ATL | HCuPINT_SOF)) {
610 ret = IRQ_HANDLED; 610 ret = IRQ_HANDLED;
611 finish_atl_transfers(isp116x, regs); 611 finish_atl_transfers(isp116x);
612 } 612 }
613 613
614 if (irqstat & HCuPINT_OPR) { 614 if (irqstat & HCuPINT_OPR) {
@@ -824,7 +824,7 @@ static int isp116x_urb_enqueue(struct usb_hcd *hcd,
824 spin_lock(&urb->lock); 824 spin_lock(&urb->lock);
825 if (urb->status != -EINPROGRESS) { 825 if (urb->status != -EINPROGRESS) {
826 spin_unlock(&urb->lock); 826 spin_unlock(&urb->lock);
827 finish_request(isp116x, ep, urb, NULL); 827 finish_request(isp116x, ep, urb);
828 ret = 0; 828 ret = 0;
829 goto fail; 829 goto fail;
830 } 830 }
@@ -870,7 +870,7 @@ static int isp116x_urb_dequeue(struct usb_hcd *hcd, struct urb *urb)
870 } 870 }
871 871
872 if (urb) 872 if (urb)
873 finish_request(isp116x, ep, urb, NULL); 873 finish_request(isp116x, ep, urb);
874 874
875 spin_unlock_irqrestore(&isp116x->lock, flags); 875 spin_unlock_irqrestore(&isp116x->lock, flags);
876 return 0; 876 return 0;
diff --git a/drivers/usb/host/ohci-hcd.c b/drivers/usb/host/ohci-hcd.c
index d1d68c402251..ea4714e557e4 100644
--- a/drivers/usb/host/ohci-hcd.c
+++ b/drivers/usb/host/ohci-hcd.c
@@ -261,7 +261,7 @@ static int ohci_urb_enqueue (
261 if (urb->status != -EINPROGRESS) { 261 if (urb->status != -EINPROGRESS) {
262 spin_unlock (&urb->lock); 262 spin_unlock (&urb->lock);
263 urb->hcpriv = urb_priv; 263 urb->hcpriv = urb_priv;
264 finish_urb (ohci, urb, NULL); 264 finish_urb (ohci, urb);
265 retval = 0; 265 retval = 0;
266 goto fail; 266 goto fail;
267 } 267 }
@@ -337,7 +337,7 @@ static int ohci_urb_dequeue (struct usb_hcd *hcd, struct urb *urb)
337 * any more ... just clean up every urb's memory. 337 * any more ... just clean up every urb's memory.
338 */ 338 */
339 if (urb->hcpriv) 339 if (urb->hcpriv)
340 finish_urb (ohci, urb, NULL); 340 finish_urb (ohci, urb);
341 } 341 }
342 spin_unlock_irqrestore (&ohci->lock, flags); 342 spin_unlock_irqrestore (&ohci->lock, flags);
343 return 0; 343 return 0;
@@ -369,7 +369,7 @@ rescan:
369 if (!HC_IS_RUNNING (hcd->state)) { 369 if (!HC_IS_RUNNING (hcd->state)) {
370sanitize: 370sanitize:
371 ed->state = ED_IDLE; 371 ed->state = ED_IDLE;
372 finish_unlinks (ohci, 0, NULL); 372 finish_unlinks (ohci, 0);
373 } 373 }
374 374
375 switch (ed->state) { 375 switch (ed->state) {
@@ -691,7 +691,7 @@ retry:
691 691
692/* an interrupt happens */ 692/* an interrupt happens */
693 693
694static irqreturn_t ohci_irq (struct usb_hcd *hcd, struct pt_regs *ptregs) 694static irqreturn_t ohci_irq (struct usb_hcd *hcd)
695{ 695{
696 struct ohci_hcd *ohci = hcd_to_ohci (hcd); 696 struct ohci_hcd *ohci = hcd_to_ohci (hcd);
697 struct ohci_regs __iomem *regs = ohci->regs; 697 struct ohci_regs __iomem *regs = ohci->regs;
@@ -715,13 +715,6 @@ static irqreturn_t ohci_irq (struct usb_hcd *hcd, struct pt_regs *ptregs)
715 return IRQ_NOTMINE; 715 return IRQ_NOTMINE;
716 } 716 }
717 717
718 if (ints & OHCI_INTR_RHSC) {
719 ohci_vdbg (ohci, "rhsc\n");
720 ohci->next_statechange = jiffies + STATECHANGE_DELAY;
721 ohci_writel (ohci, OHCI_INTR_RHSC, &regs->intrstatus);
722 usb_hcd_poll_rh_status(hcd);
723 }
724
725 if (ints & OHCI_INTR_UE) { 718 if (ints & OHCI_INTR_UE) {
726 disable (ohci); 719 disable (ohci);
727 ohci_err (ohci, "OHCI Unrecoverable Error, disabled\n"); 720 ohci_err (ohci, "OHCI Unrecoverable Error, disabled\n");
@@ -731,9 +724,21 @@ static irqreturn_t ohci_irq (struct usb_hcd *hcd, struct pt_regs *ptregs)
731 ohci_usb_reset (ohci); 724 ohci_usb_reset (ohci);
732 } 725 }
733 726
734 if (ints & OHCI_INTR_RD) { 727 if (ints & OHCI_INTR_RHSC) {
735 ohci_vdbg (ohci, "resume detect\n"); 728 ohci_vdbg(ohci, "rhsc\n");
736 ohci_writel (ohci, OHCI_INTR_RD, &regs->intrstatus); 729 ohci->next_statechange = jiffies + STATECHANGE_DELAY;
730 ohci_writel(ohci, OHCI_INTR_RD | OHCI_INTR_RHSC,
731 &regs->intrstatus);
732 usb_hcd_poll_rh_status(hcd);
733 }
734
735 /* For connect and disconnect events, we expect the controller
736 * to turn on RHSC along with RD. But for remote wakeup events
737 * this might not happen.
738 */
739 else if (ints & OHCI_INTR_RD) {
740 ohci_vdbg(ohci, "resume detect\n");
741 ohci_writel(ohci, OHCI_INTR_RD, &regs->intrstatus);
737 hcd->poll_rh = 1; 742 hcd->poll_rh = 1;
738 if (ohci->autostop) { 743 if (ohci->autostop) {
739 spin_lock (&ohci->lock); 744 spin_lock (&ohci->lock);
@@ -747,7 +752,7 @@ static irqreturn_t ohci_irq (struct usb_hcd *hcd, struct pt_regs *ptregs)
747 if (HC_IS_RUNNING(hcd->state)) 752 if (HC_IS_RUNNING(hcd->state))
748 ohci_writel (ohci, OHCI_INTR_WDH, &regs->intrdisable); 753 ohci_writel (ohci, OHCI_INTR_WDH, &regs->intrdisable);
749 spin_lock (&ohci->lock); 754 spin_lock (&ohci->lock);
750 dl_done_list (ohci, ptregs); 755 dl_done_list (ohci);
751 spin_unlock (&ohci->lock); 756 spin_unlock (&ohci->lock);
752 if (HC_IS_RUNNING(hcd->state)) 757 if (HC_IS_RUNNING(hcd->state))
753 ohci_writel (ohci, OHCI_INTR_WDH, &regs->intrenable); 758 ohci_writel (ohci, OHCI_INTR_WDH, &regs->intrenable);
@@ -760,7 +765,7 @@ static irqreturn_t ohci_irq (struct usb_hcd *hcd, struct pt_regs *ptregs)
760 */ 765 */
761 spin_lock (&ohci->lock); 766 spin_lock (&ohci->lock);
762 if (ohci->ed_rm_list) 767 if (ohci->ed_rm_list)
763 finish_unlinks (ohci, ohci_frame_no(ohci), ptregs); 768 finish_unlinks (ohci, ohci_frame_no(ohci));
764 if ((ints & OHCI_INTR_SF) != 0 && !ohci->ed_rm_list 769 if ((ints & OHCI_INTR_SF) != 0 && !ohci->ed_rm_list
765 && HC_IS_RUNNING(hcd->state)) 770 && HC_IS_RUNNING(hcd->state))
766 ohci_writel (ohci, OHCI_INTR_SF, &regs->intrdisable); 771 ohci_writel (ohci, OHCI_INTR_SF, &regs->intrdisable);
@@ -852,7 +857,7 @@ static int ohci_restart (struct ohci_hcd *ohci)
852 urb->status = -ESHUTDOWN; 857 urb->status = -ESHUTDOWN;
853 spin_unlock (&urb->lock); 858 spin_unlock (&urb->lock);
854 } 859 }
855 finish_unlinks (ohci, 0, NULL); 860 finish_unlinks (ohci, 0);
856 spin_unlock_irq(&ohci->lock); 861 spin_unlock_irq(&ohci->lock);
857 862
858 /* paranoia, in case that didn't work: */ 863 /* paranoia, in case that didn't work: */
diff --git a/drivers/usb/host/ohci-hub.c b/drivers/usb/host/ohci-hub.c
index ec75774abeac..6995ea36f2e8 100644
--- a/drivers/usb/host/ohci-hub.c
+++ b/drivers/usb/host/ohci-hub.c
@@ -47,8 +47,8 @@ static void ohci_rhsc_enable (struct usb_hcd *hcd)
47#define OHCI_SCHED_ENABLES \ 47#define OHCI_SCHED_ENABLES \
48 (OHCI_CTRL_CLE|OHCI_CTRL_BLE|OHCI_CTRL_PLE|OHCI_CTRL_IE) 48 (OHCI_CTRL_CLE|OHCI_CTRL_BLE|OHCI_CTRL_PLE|OHCI_CTRL_IE)
49 49
50static void dl_done_list (struct ohci_hcd *, struct pt_regs *); 50static void dl_done_list (struct ohci_hcd *);
51static void finish_unlinks (struct ohci_hcd *, u16 , struct pt_regs *); 51static void finish_unlinks (struct ohci_hcd *, u16);
52 52
53static int ohci_rh_suspend (struct ohci_hcd *ohci, int autostop) 53static int ohci_rh_suspend (struct ohci_hcd *ohci, int autostop)
54__releases(ohci->lock) 54__releases(ohci->lock)
@@ -94,8 +94,8 @@ __acquires(ohci->lock)
94 msleep (8); 94 msleep (8);
95 spin_lock_irq (&ohci->lock); 95 spin_lock_irq (&ohci->lock);
96 } 96 }
97 dl_done_list (ohci, NULL); 97 dl_done_list (ohci);
98 finish_unlinks (ohci, ohci_frame_no(ohci), NULL); 98 finish_unlinks (ohci, ohci_frame_no(ohci));
99 99
100 /* maybe resume can wake root hub */ 100 /* maybe resume can wake root hub */
101 if (device_may_wakeup(&ohci_to_hcd(ohci)->self.root_hub->dev) || 101 if (device_may_wakeup(&ohci_to_hcd(ohci)->self.root_hub->dev) ||
@@ -169,7 +169,8 @@ __acquires(ohci->lock)
169 break; 169 break;
170 case OHCI_USB_RESUME: 170 case OHCI_USB_RESUME:
171 /* HCFS changes sometime after INTR_RD */ 171 /* HCFS changes sometime after INTR_RD */
172 ohci_info (ohci, "wakeup\n"); 172 ohci_info(ohci, "%swakeup\n",
173 autostopped ? "auto-" : "");
173 break; 174 break;
174 case OHCI_USB_OPER: 175 case OHCI_USB_OPER:
175 /* this can happen after resuming a swsusp snapshot */ 176 /* this can happen after resuming a swsusp snapshot */
@@ -422,7 +423,8 @@ ohci_hub_status_data (struct usb_hcd *hcd, char *buf)
422 ohci->autostop = 0; 423 ohci->autostop = 0;
423 ohci->next_statechange = jiffies + 424 ohci->next_statechange = jiffies +
424 STATECHANGE_DELAY; 425 STATECHANGE_DELAY;
425 } else if (time_after_eq (jiffies, 426 } else if (device_may_wakeup(&hcd->self.root_hub->dev)
427 && time_after_eq(jiffies,
426 ohci->next_statechange) 428 ohci->next_statechange)
427 && !ohci->ed_rm_list 429 && !ohci->ed_rm_list
428 && !(ohci->hc_control & 430 && !(ohci->hc_control &
diff --git a/drivers/usb/host/ohci-pnx4008.c b/drivers/usb/host/ohci-pnx4008.c
index 82cb22f002e7..2dbb77414905 100644
--- a/drivers/usb/host/ohci-pnx4008.c
+++ b/drivers/usb/host/ohci-pnx4008.c
@@ -262,6 +262,7 @@ static const struct hc_driver ohci_pnx4008_hc_driver = {
262 */ 262 */
263 .start = ohci_pnx4008_start, 263 .start = ohci_pnx4008_start,
264 .stop = ohci_stop, 264 .stop = ohci_stop,
265 .shutdown = ohci_shutdown,
265 266
266 /* 267 /*
267 * managing i/o requests and associated device resources 268 * managing i/o requests and associated device resources
@@ -280,7 +281,11 @@ static const struct hc_driver ohci_pnx4008_hc_driver = {
280 */ 281 */
281 .hub_status_data = ohci_hub_status_data, 282 .hub_status_data = ohci_hub_status_data,
282 .hub_control = ohci_hub_control, 283 .hub_control = ohci_hub_control,
283 284 .hub_irq_enable = ohci_rhsc_enable,
285#ifdef CONFIG_PM
286 .bus_suspend = ohci_bus_suspend,
287 .bus_resume = ohci_bus_resume,
288#endif
284 .start_port_reset = ohci_start_port_reset, 289 .start_port_reset = ohci_start_port_reset,
285}; 290};
286 291
@@ -410,8 +415,6 @@ static int __devinit usb_hcd_pnx4008_probe(struct platform_device *pdev)
410 goto out4; 415 goto out4;
411 } 416 }
412 417
413 hcd->self.hcpriv = (void *)hcd;
414
415 pnx4008_start_hc(); 418 pnx4008_start_hc();
416 platform_set_drvdata(pdev, hcd); 419 platform_set_drvdata(pdev, hcd);
417 ohci = hcd_to_ohci(hcd); 420 ohci = hcd_to_ohci(hcd);
diff --git a/drivers/usb/host/ohci-q.c b/drivers/usb/host/ohci-q.c
index e372306ed0da..fe1fe2f97cb5 100644
--- a/drivers/usb/host/ohci-q.c
+++ b/drivers/usb/host/ohci-q.c
@@ -7,6 +7,8 @@
7 * This file is licenced under the GPL. 7 * This file is licenced under the GPL.
8 */ 8 */
9 9
10#include <linux/irq.h>
11
10static void urb_free_priv (struct ohci_hcd *hc, urb_priv_t *urb_priv) 12static void urb_free_priv (struct ohci_hcd *hc, urb_priv_t *urb_priv)
11{ 13{
12 int last = urb_priv->length - 1; 14 int last = urb_priv->length - 1;
@@ -34,7 +36,7 @@ static void urb_free_priv (struct ohci_hcd *hc, urb_priv_t *urb_priv)
34 * PRECONDITION: ohci lock held, irqs blocked. 36 * PRECONDITION: ohci lock held, irqs blocked.
35 */ 37 */
36static void 38static void
37finish_urb (struct ohci_hcd *ohci, struct urb *urb, struct pt_regs *regs) 39finish_urb (struct ohci_hcd *ohci, struct urb *urb)
38__releases(ohci->lock) 40__releases(ohci->lock)
39__acquires(ohci->lock) 41__acquires(ohci->lock)
40{ 42{
@@ -73,7 +75,7 @@ __acquires(ohci->lock)
73 75
74 /* urb->complete() can reenter this HCD */ 76 /* urb->complete() can reenter this HCD */
75 spin_unlock (&ohci->lock); 77 spin_unlock (&ohci->lock);
76 usb_hcd_giveback_urb (ohci_to_hcd(ohci), urb, regs); 78 usb_hcd_giveback_urb (ohci_to_hcd(ohci), urb);
77 spin_lock (&ohci->lock); 79 spin_lock (&ohci->lock);
78 80
79 /* stop periodic dma if it's not needed */ 81 /* stop periodic dma if it's not needed */
@@ -910,7 +912,7 @@ static struct td *dl_reverse_done_list (struct ohci_hcd *ohci)
910 912
911/* there are some urbs/eds to unlink; called in_irq(), with HCD locked */ 913/* there are some urbs/eds to unlink; called in_irq(), with HCD locked */
912static void 914static void
913finish_unlinks (struct ohci_hcd *ohci, u16 tick, struct pt_regs *regs) 915finish_unlinks (struct ohci_hcd *ohci, u16 tick)
914{ 916{
915 struct ed *ed, **last; 917 struct ed *ed, **last;
916 918
@@ -923,7 +925,7 @@ rescan_all:
923 /* only take off EDs that the HC isn't using, accounting for 925 /* only take off EDs that the HC isn't using, accounting for
924 * frame counter wraps and EDs with partially retired TDs 926 * frame counter wraps and EDs with partially retired TDs
925 */ 927 */
926 if (likely (regs && HC_IS_RUNNING(ohci_to_hcd(ohci)->state))) { 928 if (likely (HC_IS_RUNNING(ohci_to_hcd(ohci)->state))) {
927 if (tick_before (tick, ed->tick)) { 929 if (tick_before (tick, ed->tick)) {
928skip_ed: 930skip_ed:
929 last = &ed->ed_next; 931 last = &ed->ed_next;
@@ -990,7 +992,7 @@ rescan_this:
990 /* if URB is done, clean up */ 992 /* if URB is done, clean up */
991 if (urb_priv->td_cnt == urb_priv->length) { 993 if (urb_priv->td_cnt == urb_priv->length) {
992 modified = completed = 1; 994 modified = completed = 1;
993 finish_urb (ohci, urb, regs); 995 finish_urb (ohci, urb);
994 } 996 }
995 } 997 }
996 if (completed && !list_empty (&ed->td_list)) 998 if (completed && !list_empty (&ed->td_list))
@@ -1068,7 +1070,7 @@ rescan_this:
1068 * scanning the (re-reversed) donelist as this does. 1070 * scanning the (re-reversed) donelist as this does.
1069 */ 1071 */
1070static void 1072static void
1071dl_done_list (struct ohci_hcd *ohci, struct pt_regs *regs) 1073dl_done_list (struct ohci_hcd *ohci)
1072{ 1074{
1073 struct td *td = dl_reverse_done_list (ohci); 1075 struct td *td = dl_reverse_done_list (ohci);
1074 1076
@@ -1084,7 +1086,7 @@ dl_done_list (struct ohci_hcd *ohci, struct pt_regs *regs)
1084 1086
1085 /* If all this urb's TDs are done, call complete() */ 1087 /* If all this urb's TDs are done, call complete() */
1086 if (urb_priv->td_cnt == urb_priv->length) 1088 if (urb_priv->td_cnt == urb_priv->length)
1087 finish_urb (ohci, urb, regs); 1089 finish_urb (ohci, urb);
1088 1090
1089 /* clean schedule: unlink EDs that are no longer busy */ 1091 /* clean schedule: unlink EDs that are no longer busy */
1090 if (list_empty (&ed->td_list)) { 1092 if (list_empty (&ed->td_list)) {
diff --git a/drivers/usb/host/sl811-hcd.c b/drivers/usb/host/sl811-hcd.c
index 3a586aab3939..5fa5647ea095 100644
--- a/drivers/usb/host/sl811-hcd.c
+++ b/drivers/usb/host/sl811-hcd.c
@@ -428,7 +428,6 @@ static void finish_request(
428 struct sl811 *sl811, 428 struct sl811 *sl811,
429 struct sl811h_ep *ep, 429 struct sl811h_ep *ep,
430 struct urb *urb, 430 struct urb *urb,
431 struct pt_regs *regs,
432 int status 431 int status
433) __releases(sl811->lock) __acquires(sl811->lock) 432) __releases(sl811->lock) __acquires(sl811->lock)
434{ 433{
@@ -444,7 +443,7 @@ static void finish_request(
444 spin_unlock(&urb->lock); 443 spin_unlock(&urb->lock);
445 444
446 spin_unlock(&sl811->lock); 445 spin_unlock(&sl811->lock);
447 usb_hcd_giveback_urb(sl811_to_hcd(sl811), urb, regs); 446 usb_hcd_giveback_urb(sl811_to_hcd(sl811), urb);
448 spin_lock(&sl811->lock); 447 spin_lock(&sl811->lock);
449 448
450 /* leave active endpoints in the schedule */ 449 /* leave active endpoints in the schedule */
@@ -484,7 +483,7 @@ static void finish_request(
484} 483}
485 484
486static void 485static void
487done(struct sl811 *sl811, struct sl811h_ep *ep, u8 bank, struct pt_regs *regs) 486done(struct sl811 *sl811, struct sl811h_ep *ep, u8 bank)
488{ 487{
489 u8 status; 488 u8 status;
490 struct urb *urb; 489 struct urb *urb;
@@ -608,7 +607,7 @@ done(struct sl811 *sl811, struct sl811h_ep *ep, u8 bank, struct pt_regs *regs)
608 } 607 }
609 608
610 if (urb && (urbstat != -EINPROGRESS || urb->status != -EINPROGRESS)) 609 if (urb && (urbstat != -EINPROGRESS || urb->status != -EINPROGRESS))
611 finish_request(sl811, ep, urb, regs, urbstat); 610 finish_request(sl811, ep, urb, urbstat);
612} 611}
613 612
614static inline u8 checkdone(struct sl811 *sl811) 613static inline u8 checkdone(struct sl811 *sl811)
@@ -641,7 +640,7 @@ static inline u8 checkdone(struct sl811 *sl811)
641 return irqstat; 640 return irqstat;
642} 641}
643 642
644static irqreturn_t sl811h_irq(struct usb_hcd *hcd, struct pt_regs *regs) 643static irqreturn_t sl811h_irq(struct usb_hcd *hcd)
645{ 644{
646 struct sl811 *sl811 = hcd_to_sl811(hcd); 645 struct sl811 *sl811 = hcd_to_sl811(hcd);
647 u8 irqstat; 646 u8 irqstat;
@@ -670,13 +669,13 @@ retry:
670 * issued ... that's fine if they're different endpoints. 669 * issued ... that's fine if they're different endpoints.
671 */ 670 */
672 if (irqstat & SL11H_INTMASK_DONE_A) { 671 if (irqstat & SL11H_INTMASK_DONE_A) {
673 done(sl811, sl811->active_a, SL811_EP_A(SL811_HOST_BUF), regs); 672 done(sl811, sl811->active_a, SL811_EP_A(SL811_HOST_BUF));
674 sl811->active_a = NULL; 673 sl811->active_a = NULL;
675 sl811->stat_a++; 674 sl811->stat_a++;
676 } 675 }
677#ifdef USE_B 676#ifdef USE_B
678 if (irqstat & SL11H_INTMASK_DONE_B) { 677 if (irqstat & SL11H_INTMASK_DONE_B) {
679 done(sl811, sl811->active_b, SL811_EP_B(SL811_HOST_BUF), regs); 678 done(sl811, sl811->active_b, SL811_EP_B(SL811_HOST_BUF));
680 sl811->active_b = NULL; 679 sl811->active_b = NULL;
681 sl811->stat_b++; 680 sl811->stat_b++;
682 } 681 }
@@ -723,7 +722,7 @@ retry:
723 container_of(sl811->active_a 722 container_of(sl811->active_a
724 ->hep->urb_list.next, 723 ->hep->urb_list.next,
725 struct urb, urb_list), 724 struct urb, urb_list),
726 NULL, -ESHUTDOWN); 725 -ESHUTDOWN);
727 sl811->active_a = NULL; 726 sl811->active_a = NULL;
728 } 727 }
729#ifdef USE_B 728#ifdef USE_B
@@ -957,7 +956,7 @@ static int sl811h_urb_enqueue(
957 spin_lock(&urb->lock); 956 spin_lock(&urb->lock);
958 if (urb->status != -EINPROGRESS) { 957 if (urb->status != -EINPROGRESS) {
959 spin_unlock(&urb->lock); 958 spin_unlock(&urb->lock);
960 finish_request(sl811, ep, urb, NULL, 0); 959 finish_request(sl811, ep, urb, 0);
961 retval = 0; 960 retval = 0;
962 goto fail; 961 goto fail;
963 } 962 }
@@ -1026,7 +1025,7 @@ static int sl811h_urb_dequeue(struct usb_hcd *hcd, struct urb *urb)
1026 } 1025 }
1027 1026
1028 if (urb) 1027 if (urb)
1029 finish_request(sl811, ep, urb, NULL, 0); 1028 finish_request(sl811, ep, urb, 0);
1030 else 1029 else
1031 VDBG("dequeue, urb %p active %s; wait4irq\n", urb, 1030 VDBG("dequeue, urb %p active %s; wait4irq\n", urb,
1032 (sl811->active_a == ep) ? "A" : "B"); 1031 (sl811->active_a == ep) ? "A" : "B");
@@ -1083,7 +1082,7 @@ sl811h_hub_status_data(struct usb_hcd *hcd, char *buf)
1083 */ 1082 */
1084 local_irq_save(flags); 1083 local_irq_save(flags);
1085 if (!timer_pending(&sl811->timer)) { 1084 if (!timer_pending(&sl811->timer)) {
1086 if (sl811h_irq( /* ~0, */ hcd, NULL) != IRQ_NONE) 1085 if (sl811h_irq( /* ~0, */ hcd) != IRQ_NONE)
1087 sl811->stat_lost++; 1086 sl811->stat_lost++;
1088 } 1087 }
1089 local_irq_restore(flags); 1088 local_irq_restore(flags);
diff --git a/drivers/usb/host/u132-hcd.c b/drivers/usb/host/u132-hcd.c
index 0a315200b331..32c635ecbf31 100644
--- a/drivers/usb/host/u132-hcd.c
+++ b/drivers/usb/host/u132-hcd.c
@@ -557,7 +557,7 @@ static void u132_hcd_giveback_urb(struct u132 *u132, struct u132_endp *endp,
557 u132_ring_queue_work(u132, ring, 0); 557 u132_ring_queue_work(u132, ring, 0);
558 up(&u132->scheduler_lock); 558 up(&u132->scheduler_lock);
559 u132_endp_put_kref(u132, endp); 559 u132_endp_put_kref(u132, endp);
560 usb_hcd_giveback_urb(hcd, urb, NULL); 560 usb_hcd_giveback_urb(hcd, urb);
561 return; 561 return;
562} 562}
563 563
@@ -590,7 +590,7 @@ static void u132_hcd_abandon_urb(struct u132 *u132, struct u132_endp *endp,
590 endp->active = 0; 590 endp->active = 0;
591 spin_unlock_irqrestore(&endp->queue_lock.slock, irqs); 591 spin_unlock_irqrestore(&endp->queue_lock.slock, irqs);
592 kfree(urbq); 592 kfree(urbq);
593 } usb_hcd_giveback_urb(hcd, urb, NULL); 593 } usb_hcd_giveback_urb(hcd, urb);
594 return; 594 return;
595} 595}
596 596
@@ -2434,7 +2434,7 @@ static int dequeue_from_overflow_chain(struct u132 *u132,
2434 endp->queue_size -= 1; 2434 endp->queue_size -= 1;
2435 urb->error_count = 0; 2435 urb->error_count = 0;
2436 urb->hcpriv = NULL; 2436 urb->hcpriv = NULL;
2437 usb_hcd_giveback_urb(hcd, urb, NULL); 2437 usb_hcd_giveback_urb(hcd, urb);
2438 return 0; 2438 return 0;
2439 } else 2439 } else
2440 continue; 2440 continue;
@@ -2512,7 +2512,7 @@ static int u132_endp_urb_dequeue(struct u132 *u132, struct u132_endp *endp,
2512 kfree(urbq); 2512 kfree(urbq);
2513 } urb->error_count = 0; 2513 } urb->error_count = 0;
2514 urb->hcpriv = NULL; 2514 urb->hcpriv = NULL;
2515 usb_hcd_giveback_urb(hcd, urb, NULL); 2515 usb_hcd_giveback_urb(hcd, urb);
2516 return 0; 2516 return 0;
2517 } else if (list_empty(&endp->urb_more)) { 2517 } else if (list_empty(&endp->urb_more)) {
2518 dev_err(&u132->platform_dev->dev, "urb=%p not found in " 2518 dev_err(&u132->platform_dev->dev, "urb=%p not found in "
diff --git a/drivers/usb/host/uhci-hcd.c b/drivers/usb/host/uhci-hcd.c
index eb4eab98e8bf..226bf3de8edd 100644
--- a/drivers/usb/host/uhci-hcd.c
+++ b/drivers/usb/host/uhci-hcd.c
@@ -40,6 +40,7 @@
40#include <linux/dma-mapping.h> 40#include <linux/dma-mapping.h>
41#include <linux/usb.h> 41#include <linux/usb.h>
42#include <linux/bitops.h> 42#include <linux/bitops.h>
43#include <linux/dmi.h>
43 44
44#include <asm/uaccess.h> 45#include <asm/uaccess.h>
45#include <asm/io.h> 46#include <asm/io.h>
@@ -196,12 +197,42 @@ static int resume_detect_interrupts_are_broken(struct uhci_hcd *uhci)
196 return 0; 197 return 0;
197} 198}
198 199
200static int remote_wakeup_is_broken(struct uhci_hcd *uhci)
201{
202 static struct dmi_system_id broken_wakeup_table[] = {
203 {
204 .ident = "Asus A7V8X",
205 .matches = {
206 DMI_MATCH(DMI_BOARD_VENDOR, "ASUSTeK"),
207 DMI_MATCH(DMI_BOARD_NAME, "A7V8X"),
208 DMI_MATCH(DMI_BOARD_VERSION, "REV 1.xx"),
209 }
210 },
211 { }
212 };
213 int port;
214
215 /* One of Asus's motherboards has a bug which causes it to
216 * wake up immediately from suspend-to-RAM if any of the ports
217 * are connected. In such cases we will not set EGSM.
218 */
219 if (dmi_check_system(broken_wakeup_table)) {
220 for (port = 0; port < uhci->rh_numports; ++port) {
221 if (inw(uhci->io_addr + USBPORTSC1 + port * 2) &
222 USBPORTSC_CCS)
223 return 1;
224 }
225 }
226
227 return 0;
228}
229
199static void suspend_rh(struct uhci_hcd *uhci, enum uhci_rh_state new_state) 230static void suspend_rh(struct uhci_hcd *uhci, enum uhci_rh_state new_state)
200__releases(uhci->lock) 231__releases(uhci->lock)
201__acquires(uhci->lock) 232__acquires(uhci->lock)
202{ 233{
203 int auto_stop; 234 int auto_stop;
204 int int_enable; 235 int int_enable, egsm_enable;
205 236
206 auto_stop = (new_state == UHCI_RH_AUTO_STOPPED); 237 auto_stop = (new_state == UHCI_RH_AUTO_STOPPED);
207 dev_dbg(&uhci_to_hcd(uhci)->self.root_hub->dev, 238 dev_dbg(&uhci_to_hcd(uhci)->self.root_hub->dev,
@@ -217,15 +248,18 @@ __acquires(uhci->lock)
217 } 248 }
218 249
219 /* Enable resume-detect interrupts if they work. 250 /* Enable resume-detect interrupts if they work.
220 * Then enter Global Suspend mode, still configured. 251 * Then enter Global Suspend mode if _it_ works, still configured.
221 */ 252 */
253 egsm_enable = USBCMD_EGSM;
222 uhci->working_RD = 1; 254 uhci->working_RD = 1;
223 int_enable = USBINTR_RESUME; 255 int_enable = USBINTR_RESUME;
224 if (resume_detect_interrupts_are_broken(uhci)) { 256 if (remote_wakeup_is_broken(uhci))
257 egsm_enable = 0;
258 if (resume_detect_interrupts_are_broken(uhci) || !egsm_enable)
225 uhci->working_RD = int_enable = 0; 259 uhci->working_RD = int_enable = 0;
226 } 260
227 outw(int_enable, uhci->io_addr + USBINTR); 261 outw(int_enable, uhci->io_addr + USBINTR);
228 outw(USBCMD_EGSM | USBCMD_CF, uhci->io_addr + USBCMD); 262 outw(egsm_enable | USBCMD_CF, uhci->io_addr + USBCMD);
229 mb(); 263 mb();
230 udelay(5); 264 udelay(5);
231 265
@@ -252,7 +286,7 @@ __acquires(uhci->lock)
252 uhci->is_stopped = UHCI_IS_STOPPED; 286 uhci->is_stopped = UHCI_IS_STOPPED;
253 uhci_to_hcd(uhci)->poll_rh = !int_enable; 287 uhci_to_hcd(uhci)->poll_rh = !int_enable;
254 288
255 uhci_scan_schedule(uhci, NULL); 289 uhci_scan_schedule(uhci);
256 uhci_fsbr_off(uhci); 290 uhci_fsbr_off(uhci);
257} 291}
258 292
@@ -309,7 +343,7 @@ __acquires(uhci->lock)
309 mod_timer(&uhci_to_hcd(uhci)->rh_timer, jiffies); 343 mod_timer(&uhci_to_hcd(uhci)->rh_timer, jiffies);
310} 344}
311 345
312static irqreturn_t uhci_irq(struct usb_hcd *hcd, struct pt_regs *regs) 346static irqreturn_t uhci_irq(struct usb_hcd *hcd)
313{ 347{
314 struct uhci_hcd *uhci = hcd_to_uhci(hcd); 348 struct uhci_hcd *uhci = hcd_to_uhci(hcd);
315 unsigned short status; 349 unsigned short status;
@@ -358,7 +392,7 @@ static irqreturn_t uhci_irq(struct usb_hcd *hcd, struct pt_regs *regs)
358 usb_hcd_poll_rh_status(hcd); 392 usb_hcd_poll_rh_status(hcd);
359 else { 393 else {
360 spin_lock_irqsave(&uhci->lock, flags); 394 spin_lock_irqsave(&uhci->lock, flags);
361 uhci_scan_schedule(uhci, regs); 395 uhci_scan_schedule(uhci);
362 spin_unlock_irqrestore(&uhci->lock, flags); 396 spin_unlock_irqrestore(&uhci->lock, flags);
363 } 397 }
364 398
@@ -671,7 +705,7 @@ static void uhci_stop(struct usb_hcd *hcd)
671 spin_lock_irq(&uhci->lock); 705 spin_lock_irq(&uhci->lock);
672 if (test_bit(HCD_FLAG_HW_ACCESSIBLE, &hcd->flags) && !uhci->dead) 706 if (test_bit(HCD_FLAG_HW_ACCESSIBLE, &hcd->flags) && !uhci->dead)
673 uhci_hc_died(uhci); 707 uhci_hc_died(uhci);
674 uhci_scan_schedule(uhci, NULL); 708 uhci_scan_schedule(uhci);
675 spin_unlock_irq(&uhci->lock); 709 spin_unlock_irq(&uhci->lock);
676 710
677 del_timer_sync(&uhci->fsbr_timer); 711 del_timer_sync(&uhci->fsbr_timer);
diff --git a/drivers/usb/host/uhci-hub.c b/drivers/usb/host/uhci-hub.c
index 16fb72eb6fc9..f8347f1a10b6 100644
--- a/drivers/usb/host/uhci-hub.c
+++ b/drivers/usb/host/uhci-hub.c
@@ -176,7 +176,7 @@ static int uhci_hub_status_data(struct usb_hcd *hcd, char *buf)
176 176
177 spin_lock_irqsave(&uhci->lock, flags); 177 spin_lock_irqsave(&uhci->lock, flags);
178 178
179 uhci_scan_schedule(uhci, NULL); 179 uhci_scan_schedule(uhci);
180 if (!test_bit(HCD_FLAG_HW_ACCESSIBLE, &hcd->flags) || uhci->dead) 180 if (!test_bit(HCD_FLAG_HW_ACCESSIBLE, &hcd->flags) || uhci->dead)
181 goto done; 181 goto done;
182 uhci_check_ports(uhci); 182 uhci_check_ports(uhci);
diff --git a/drivers/usb/host/uhci-q.c b/drivers/usb/host/uhci-q.c
index 431e8f31f1a9..06115f22a4fa 100644
--- a/drivers/usb/host/uhci-q.c
+++ b/drivers/usb/host/uhci-q.c
@@ -1244,7 +1244,7 @@ done:
1244 * Finish unlinking an URB and give it back 1244 * Finish unlinking an URB and give it back
1245 */ 1245 */
1246static void uhci_giveback_urb(struct uhci_hcd *uhci, struct uhci_qh *qh, 1246static void uhci_giveback_urb(struct uhci_hcd *uhci, struct uhci_qh *qh,
1247 struct urb *urb, struct pt_regs *regs) 1247 struct urb *urb)
1248__releases(uhci->lock) 1248__releases(uhci->lock)
1249__acquires(uhci->lock) 1249__acquires(uhci->lock)
1250{ 1250{
@@ -1293,7 +1293,7 @@ __acquires(uhci->lock)
1293 } 1293 }
1294 1294
1295 spin_unlock(&uhci->lock); 1295 spin_unlock(&uhci->lock);
1296 usb_hcd_giveback_urb(uhci_to_hcd(uhci), urb, regs); 1296 usb_hcd_giveback_urb(uhci_to_hcd(uhci), urb);
1297 spin_lock(&uhci->lock); 1297 spin_lock(&uhci->lock);
1298 1298
1299 /* If the queue is now empty, we can unlink the QH and give up its 1299 /* If the queue is now empty, we can unlink the QH and give up its
@@ -1313,8 +1313,7 @@ __acquires(uhci->lock)
1313 (qh->state == QH_STATE_UNLINKING && \ 1313 (qh->state == QH_STATE_UNLINKING && \
1314 uhci->frame_number + uhci->is_stopped != qh->unlink_frame) 1314 uhci->frame_number + uhci->is_stopped != qh->unlink_frame)
1315 1315
1316static void uhci_scan_qh(struct uhci_hcd *uhci, struct uhci_qh *qh, 1316static void uhci_scan_qh(struct uhci_hcd *uhci, struct uhci_qh *qh)
1317 struct pt_regs *regs)
1318{ 1317{
1319 struct urb_priv *urbp; 1318 struct urb_priv *urbp;
1320 struct urb *urb; 1319 struct urb *urb;
@@ -1347,7 +1346,7 @@ static void uhci_scan_qh(struct uhci_hcd *uhci, struct uhci_qh *qh,
1347 return; 1346 return;
1348 } 1347 }
1349 1348
1350 uhci_giveback_urb(uhci, qh, urb, regs); 1349 uhci_giveback_urb(uhci, qh, urb);
1351 if (status < 0 && qh->type != USB_ENDPOINT_XFER_ISOC) 1350 if (status < 0 && qh->type != USB_ENDPOINT_XFER_ISOC)
1352 break; 1351 break;
1353 } 1352 }
@@ -1372,7 +1371,7 @@ restart:
1372 qh->is_stopped = 0; 1371 qh->is_stopped = 0;
1373 return; 1372 return;
1374 } 1373 }
1375 uhci_giveback_urb(uhci, qh, urb, regs); 1374 uhci_giveback_urb(uhci, qh, urb);
1376 goto restart; 1375 goto restart;
1377 } 1376 }
1378 } 1377 }
@@ -1487,7 +1486,7 @@ done:
1487/* 1486/*
1488 * Process events in the schedule, but only in one thread at a time 1487 * Process events in the schedule, but only in one thread at a time
1489 */ 1488 */
1490static void uhci_scan_schedule(struct uhci_hcd *uhci, struct pt_regs *regs) 1489static void uhci_scan_schedule(struct uhci_hcd *uhci)
1491{ 1490{
1492 int i; 1491 int i;
1493 struct uhci_qh *qh; 1492 struct uhci_qh *qh;
@@ -1515,7 +1514,7 @@ rescan:
1515 struct uhci_qh, node); 1514 struct uhci_qh, node);
1516 1515
1517 if (uhci_advance_check(uhci, qh)) { 1516 if (uhci_advance_check(uhci, qh)) {
1518 uhci_scan_qh(uhci, qh, regs); 1517 uhci_scan_qh(uhci, qh);
1519 if (qh->state == QH_STATE_ACTIVE) { 1518 if (qh->state == QH_STATE_ACTIVE) {
1520 uhci_urbp_wants_fsbr(uhci, 1519 uhci_urbp_wants_fsbr(uhci,
1521 list_entry(qh->queue.next, struct urb_priv, node)); 1520 list_entry(qh->queue.next, struct urb_priv, node));
diff --git a/drivers/usb/image/mdc800.c b/drivers/usb/image/mdc800.c
index ca6305c1d64c..63a84bbc310d 100644
--- a/drivers/usb/image/mdc800.c
+++ b/drivers/usb/image/mdc800.c
@@ -280,7 +280,7 @@ static int mdc800_isReady (char *ch)
280/* 280/*
281 * USB IRQ Handler for InputLine 281 * USB IRQ Handler for InputLine
282 */ 282 */
283static void mdc800_usb_irq (struct urb *urb, struct pt_regs *res) 283static void mdc800_usb_irq (struct urb *urb)
284{ 284{
285 int data_received=0, wake_up; 285 int data_received=0, wake_up;
286 unsigned char* b=urb->transfer_buffer; 286 unsigned char* b=urb->transfer_buffer;
@@ -374,7 +374,7 @@ static int mdc800_usb_waitForIRQ (int mode, int msec)
374/* 374/*
375 * The write_urb callback function 375 * The write_urb callback function
376 */ 376 */
377static void mdc800_usb_write_notify (struct urb *urb, struct pt_regs *res) 377static void mdc800_usb_write_notify (struct urb *urb)
378{ 378{
379 struct mdc800_data* mdc800=urb->context; 379 struct mdc800_data* mdc800=urb->context;
380 380
@@ -394,7 +394,7 @@ static void mdc800_usb_write_notify (struct urb *urb, struct pt_regs *res)
394/* 394/*
395 * The download_urb callback function 395 * The download_urb callback function
396 */ 396 */
397static void mdc800_usb_download_notify (struct urb *urb, struct pt_regs *res) 397static void mdc800_usb_download_notify (struct urb *urb)
398{ 398{
399 struct mdc800_data* mdc800=urb->context; 399 struct mdc800_data* mdc800=urb->context;
400 400
diff --git a/drivers/usb/image/microtek.c b/drivers/usb/image/microtek.c
index 5f861331932a..3038ed0700d3 100644
--- a/drivers/usb/image/microtek.c
+++ b/drivers/usb/image/microtek.c
@@ -370,7 +370,7 @@ static int
370mts_scsi_queuecommand(struct scsi_cmnd *srb, mts_scsi_cmnd_callback callback); 370mts_scsi_queuecommand(struct scsi_cmnd *srb, mts_scsi_cmnd_callback callback);
371 371
372static void mts_transfer_cleanup( struct urb *transfer ); 372static void mts_transfer_cleanup( struct urb *transfer );
373static void mts_do_sg(struct urb * transfer, struct pt_regs *regs); 373static void mts_do_sg(struct urb * transfer);
374 374
375static inline 375static inline
376void mts_int_submit_urb (struct urb* transfer, 376void mts_int_submit_urb (struct urb* transfer,
@@ -417,7 +417,7 @@ static void mts_transfer_cleanup( struct urb *transfer )
417 417
418} 418}
419 419
420static void mts_transfer_done( struct urb *transfer, struct pt_regs *regs ) 420static void mts_transfer_done( struct urb *transfer )
421{ 421{
422 MTS_INT_INIT(); 422 MTS_INT_INIT();
423 423
@@ -443,7 +443,7 @@ static void mts_get_status( struct urb *transfer )
443 mts_transfer_done ); 443 mts_transfer_done );
444} 444}
445 445
446static void mts_data_done( struct urb* transfer, struct pt_regs *regs ) 446static void mts_data_done( struct urb* transfer )
447/* Interrupt context! */ 447/* Interrupt context! */
448{ 448{
449 MTS_INT_INIT(); 449 MTS_INT_INIT();
@@ -460,7 +460,7 @@ static void mts_data_done( struct urb* transfer, struct pt_regs *regs )
460} 460}
461 461
462 462
463static void mts_command_done( struct urb *transfer, struct pt_regs *regs ) 463static void mts_command_done( struct urb *transfer )
464/* Interrupt context! */ 464/* Interrupt context! */
465{ 465{
466 MTS_INT_INIT(); 466 MTS_INT_INIT();
@@ -501,7 +501,7 @@ static void mts_command_done( struct urb *transfer, struct pt_regs *regs )
501 return; 501 return;
502} 502}
503 503
504static void mts_do_sg (struct urb* transfer, struct pt_regs *regs) 504static void mts_do_sg (struct urb* transfer)
505{ 505{
506 struct scatterlist * sg; 506 struct scatterlist * sg;
507 MTS_INT_INIT(); 507 MTS_INT_INIT();
diff --git a/drivers/usb/input/Kconfig b/drivers/usb/input/Kconfig
index 21cd22640080..20db36448ab3 100644
--- a/drivers/usb/input/Kconfig
+++ b/drivers/usb/input/Kconfig
@@ -348,13 +348,3 @@ config USB_APPLETOUCH
348 348
349 To compile this driver as a module, choose M here: the 349 To compile this driver as a module, choose M here: the
350 module will be called appletouch. 350 module will be called appletouch.
351
352config USB_TRANCEVIBRATOR
353 tristate "PlayStation 2 Trance Vibrator driver support"
354 depends on USB
355 help
356 Say Y here if you want to connect a PlayStation 2 Trance Vibrator
357 device to your computer's USB port.
358
359 To compile this driver as a module, choose M here: the
360 module will be called trancevibrator.
diff --git a/drivers/usb/input/Makefile b/drivers/usb/input/Makefile
index 295f459d1079..d946d5213b30 100644
--- a/drivers/usb/input/Makefile
+++ b/drivers/usb/input/Makefile
@@ -3,7 +3,7 @@
3# 3#
4 4
5# Multipart objects. 5# Multipart objects.
6wacom-objs := wacom_sys.o wacom_wac.o 6wacom-objs := wacom_wac.o wacom_sys.o
7usbhid-objs := hid-core.o 7usbhid-objs := hid-core.o
8 8
9# Optional parts of multipart objects. 9# Optional parts of multipart objects.
@@ -48,7 +48,6 @@ obj-$(CONFIG_USB_ACECAD) += acecad.o
48obj-$(CONFIG_USB_YEALINK) += yealink.o 48obj-$(CONFIG_USB_YEALINK) += yealink.o
49obj-$(CONFIG_USB_XPAD) += xpad.o 49obj-$(CONFIG_USB_XPAD) += xpad.o
50obj-$(CONFIG_USB_APPLETOUCH) += appletouch.o 50obj-$(CONFIG_USB_APPLETOUCH) += appletouch.o
51obj-$(CONFIG_USB_TRANCEVIBRATOR) += trancevibrator.o
52 51
53ifeq ($(CONFIG_USB_DEBUG),y) 52ifeq ($(CONFIG_USB_DEBUG),y)
54EXTRA_CFLAGS += -DDEBUG 53EXTRA_CFLAGS += -DDEBUG
diff --git a/drivers/usb/input/acecad.c b/drivers/usb/input/acecad.c
index d83603ba40ae..0096373b5f98 100644
--- a/drivers/usb/input/acecad.c
+++ b/drivers/usb/input/acecad.c
@@ -58,7 +58,7 @@ struct usb_acecad {
58 dma_addr_t data_dma; 58 dma_addr_t data_dma;
59}; 59};
60 60
61static void usb_acecad_irq(struct urb *urb, struct pt_regs *regs) 61static void usb_acecad_irq(struct urb *urb)
62{ 62{
63 struct usb_acecad *acecad = urb->context; 63 struct usb_acecad *acecad = urb->context;
64 unsigned char *data = acecad->data; 64 unsigned char *data = acecad->data;
diff --git a/drivers/usb/input/aiptek.c b/drivers/usb/input/aiptek.c
index b138dae2b055..bf428184608f 100644
--- a/drivers/usb/input/aiptek.c
+++ b/drivers/usb/input/aiptek.c
@@ -396,7 +396,7 @@ static int aiptek_convert_from_2s_complement(unsigned char c)
396 * replaced with the input_sync() method (which emits EV_SYN.) 396 * replaced with the input_sync() method (which emits EV_SYN.)
397 */ 397 */
398 398
399static void aiptek_irq(struct urb *urb, struct pt_regs *regs) 399static void aiptek_irq(struct urb *urb)
400{ 400{
401 struct aiptek *aiptek = urb->context; 401 struct aiptek *aiptek = urb->context;
402 unsigned char *data = aiptek->data; 402 unsigned char *data = aiptek->data;
@@ -442,8 +442,6 @@ static void aiptek_irq(struct urb *urb, struct pt_regs *regs)
442 aiptek->diagnostic = 442 aiptek->diagnostic =
443 AIPTEK_DIAGNOSTIC_SENDING_RELATIVE_IN_ABSOLUTE; 443 AIPTEK_DIAGNOSTIC_SENDING_RELATIVE_IN_ABSOLUTE;
444 } else { 444 } else {
445 input_regs(inputdev, regs);
446
447 x = aiptek_convert_from_2s_complement(data[2]); 445 x = aiptek_convert_from_2s_complement(data[2]);
448 y = aiptek_convert_from_2s_complement(data[3]); 446 y = aiptek_convert_from_2s_complement(data[3]);
449 447
@@ -488,8 +486,6 @@ static void aiptek_irq(struct urb *urb, struct pt_regs *regs)
488 (aiptek->curSetting.pointerMode)) { 486 (aiptek->curSetting.pointerMode)) {
489 aiptek->diagnostic = AIPTEK_DIAGNOSTIC_TOOL_DISALLOWED; 487 aiptek->diagnostic = AIPTEK_DIAGNOSTIC_TOOL_DISALLOWED;
490 } else { 488 } else {
491 input_regs(inputdev, regs);
492
493 x = le16_to_cpu(get_unaligned((__le16 *) (data + 1))); 489 x = le16_to_cpu(get_unaligned((__le16 *) (data + 1)));
494 y = le16_to_cpu(get_unaligned((__le16 *) (data + 3))); 490 y = le16_to_cpu(get_unaligned((__le16 *) (data + 3)));
495 z = le16_to_cpu(get_unaligned((__le16 *) (data + 6))); 491 z = le16_to_cpu(get_unaligned((__le16 *) (data + 6)));
@@ -568,7 +564,6 @@ static void aiptek_irq(struct urb *urb, struct pt_regs *regs)
568 (aiptek->curSetting.pointerMode)) { 564 (aiptek->curSetting.pointerMode)) {
569 aiptek->diagnostic = AIPTEK_DIAGNOSTIC_TOOL_DISALLOWED; 565 aiptek->diagnostic = AIPTEK_DIAGNOSTIC_TOOL_DISALLOWED;
570 } else { 566 } else {
571 input_regs(inputdev, regs);
572 x = le16_to_cpu(get_unaligned((__le16 *) (data + 1))); 567 x = le16_to_cpu(get_unaligned((__le16 *) (data + 1)));
573 y = le16_to_cpu(get_unaligned((__le16 *) (data + 3))); 568 y = le16_to_cpu(get_unaligned((__le16 *) (data + 3)));
574 569
@@ -631,8 +626,6 @@ static void aiptek_irq(struct urb *urb, struct pt_regs *regs)
631 z = le16_to_cpu(get_unaligned((__le16 *) (data + 4))); 626 z = le16_to_cpu(get_unaligned((__le16 *) (data + 4)));
632 627
633 if (dv != 0) { 628 if (dv != 0) {
634 input_regs(inputdev, regs);
635
636 /* If we've not already sent a tool_button_?? code, do 629 /* If we've not already sent a tool_button_?? code, do
637 * so now. Then set FIRED_BIT so it won't be resent unless 630 * so now. Then set FIRED_BIT so it won't be resent unless
638 * the user forces FIRED_BIT off. 631 * the user forces FIRED_BIT off.
@@ -681,8 +674,6 @@ static void aiptek_irq(struct urb *urb, struct pt_regs *regs)
681 macro = data[3]; 674 macro = data[3];
682 675
683 if (dv != 0) { 676 if (dv != 0) {
684 input_regs(inputdev, regs);
685
686 /* If we've not already sent a tool_button_?? code, do 677 /* If we've not already sent a tool_button_?? code, do
687 * so now. Then set FIRED_BIT so it won't be resent unless 678 * so now. Then set FIRED_BIT so it won't be resent unless
688 * the user forces FIRED_BIT off. 679 * the user forces FIRED_BIT off.
@@ -726,8 +717,6 @@ static void aiptek_irq(struct urb *urb, struct pt_regs *regs)
726 */ 717 */
727 else if (data[0] == 6) { 718 else if (data[0] == 6) {
728 macro = le16_to_cpu(get_unaligned((__le16 *) (data + 1))); 719 macro = le16_to_cpu(get_unaligned((__le16 *) (data + 1)));
729 input_regs(inputdev, regs);
730
731 if (macro > 0) { 720 if (macro > 0) {
732 input_report_key(inputdev, macroKeyEvents[macro - 1], 721 input_report_key(inputdev, macroKeyEvents[macro - 1],
733 0); 722 0);
diff --git a/drivers/usb/input/appletouch.c b/drivers/usb/input/appletouch.c
index 0aa9cc2bfd69..4c213513484d 100644
--- a/drivers/usb/input/appletouch.c
+++ b/drivers/usb/input/appletouch.c
@@ -210,7 +210,7 @@ static inline void atp_report_fingers(struct input_dev *input, int fingers)
210 input_report_key(input, BTN_TOOL_TRIPLETAP, fingers > 2); 210 input_report_key(input, BTN_TOOL_TRIPLETAP, fingers > 2);
211} 211}
212 212
213static void atp_complete(struct urb* urb, struct pt_regs* regs) 213static void atp_complete(struct urb* urb)
214{ 214{
215 int x, y, x_z, y_z, x_f, y_f; 215 int x, y, x_z, y_z, x_f, y_f;
216 int retval, i, j; 216 int retval, i, j;
diff --git a/drivers/usb/input/ati_remote.c b/drivers/usb/input/ati_remote.c
index 3558d7ed99b9..787b847d38cc 100644
--- a/drivers/usb/input/ati_remote.c
+++ b/drivers/usb/input/ati_remote.c
@@ -283,9 +283,9 @@ static void ati_remote_dump (unsigned char *data, unsigned int actual_length);
283static int ati_remote_open (struct input_dev *inputdev); 283static int ati_remote_open (struct input_dev *inputdev);
284static void ati_remote_close (struct input_dev *inputdev); 284static void ati_remote_close (struct input_dev *inputdev);
285static int ati_remote_sendpacket (struct ati_remote *ati_remote, u16 cmd, unsigned char *data); 285static int ati_remote_sendpacket (struct ati_remote *ati_remote, u16 cmd, unsigned char *data);
286static void ati_remote_irq_out (struct urb *urb, struct pt_regs *regs); 286static void ati_remote_irq_out (struct urb *urb);
287static void ati_remote_irq_in (struct urb *urb, struct pt_regs *regs); 287static void ati_remote_irq_in (struct urb *urb);
288static void ati_remote_input_report (struct urb *urb, struct pt_regs *regs); 288static void ati_remote_input_report (struct urb *urb);
289static int ati_remote_initialize (struct ati_remote *ati_remote); 289static int ati_remote_initialize (struct ati_remote *ati_remote);
290static int ati_remote_probe (struct usb_interface *interface, const struct usb_device_id *id); 290static int ati_remote_probe (struct usb_interface *interface, const struct usb_device_id *id);
291static void ati_remote_disconnect (struct usb_interface *interface); 291static void ati_remote_disconnect (struct usb_interface *interface);
@@ -344,7 +344,7 @@ static void ati_remote_close(struct input_dev *inputdev)
344/* 344/*
345 * ati_remote_irq_out 345 * ati_remote_irq_out
346 */ 346 */
347static void ati_remote_irq_out(struct urb *urb, struct pt_regs *regs) 347static void ati_remote_irq_out(struct urb *urb)
348{ 348{
349 struct ati_remote *ati_remote = urb->context; 349 struct ati_remote *ati_remote = urb->context;
350 350
@@ -453,7 +453,7 @@ static int ati_remote_compute_accel(struct ati_remote *ati_remote)
453/* 453/*
454 * ati_remote_report_input 454 * ati_remote_report_input
455 */ 455 */
456static void ati_remote_input_report(struct urb *urb, struct pt_regs *regs) 456static void ati_remote_input_report(struct urb *urb)
457{ 457{
458 struct ati_remote *ati_remote = urb->context; 458 struct ati_remote *ati_remote = urb->context;
459 unsigned char *data= ati_remote->inbuf; 459 unsigned char *data= ati_remote->inbuf;
@@ -491,7 +491,6 @@ static void ati_remote_input_report(struct urb *urb, struct pt_regs *regs)
491 remote_num, data[1], data[2], index, ati_remote_tbl[index].code); 491 remote_num, data[1], data[2], index, ati_remote_tbl[index].code);
492 492
493 if (ati_remote_tbl[index].kind == KIND_LITERAL) { 493 if (ati_remote_tbl[index].kind == KIND_LITERAL) {
494 input_regs(dev, regs);
495 input_event(dev, ati_remote_tbl[index].type, 494 input_event(dev, ati_remote_tbl[index].type,
496 ati_remote_tbl[index].code, 495 ati_remote_tbl[index].code,
497 ati_remote_tbl[index].value); 496 ati_remote_tbl[index].value);
@@ -520,7 +519,6 @@ static void ati_remote_input_report(struct urb *urb, struct pt_regs *regs)
520 return; 519 return;
521 520
522 521
523 input_regs(dev, regs);
524 input_event(dev, ati_remote_tbl[index].type, 522 input_event(dev, ati_remote_tbl[index].type,
525 ati_remote_tbl[index].code, 1); 523 ati_remote_tbl[index].code, 1);
526 input_sync(dev); 524 input_sync(dev);
@@ -537,7 +535,6 @@ static void ati_remote_input_report(struct urb *urb, struct pt_regs *regs)
537 */ 535 */
538 acc = ati_remote_compute_accel(ati_remote); 536 acc = ati_remote_compute_accel(ati_remote);
539 537
540 input_regs(dev, regs);
541 switch (ati_remote_tbl[index].kind) { 538 switch (ati_remote_tbl[index].kind) {
542 case KIND_ACCEL: 539 case KIND_ACCEL:
543 input_event(dev, ati_remote_tbl[index].type, 540 input_event(dev, ati_remote_tbl[index].type,
@@ -575,14 +572,14 @@ static void ati_remote_input_report(struct urb *urb, struct pt_regs *regs)
575/* 572/*
576 * ati_remote_irq_in 573 * ati_remote_irq_in
577 */ 574 */
578static void ati_remote_irq_in(struct urb *urb, struct pt_regs *regs) 575static void ati_remote_irq_in(struct urb *urb)
579{ 576{
580 struct ati_remote *ati_remote = urb->context; 577 struct ati_remote *ati_remote = urb->context;
581 int retval; 578 int retval;
582 579
583 switch (urb->status) { 580 switch (urb->status) {
584 case 0: /* success */ 581 case 0: /* success */
585 ati_remote_input_report(urb, regs); 582 ati_remote_input_report(urb);
586 break; 583 break;
587 case -ECONNRESET: /* unlink */ 584 case -ECONNRESET: /* unlink */
588 case -ENOENT: 585 case -ENOENT:
@@ -639,13 +636,11 @@ static void ati_remote_free_buffers(struct ati_remote *ati_remote)
639 if (ati_remote->out_urb) 636 if (ati_remote->out_urb)
640 usb_free_urb(ati_remote->out_urb); 637 usb_free_urb(ati_remote->out_urb);
641 638
642 if (ati_remote->inbuf) 639 usb_buffer_free(ati_remote->udev, DATA_BUFSIZE,
643 usb_buffer_free(ati_remote->udev, DATA_BUFSIZE, 640 ati_remote->inbuf, ati_remote->inbuf_dma);
644 ati_remote->inbuf, ati_remote->inbuf_dma);
645 641
646 if (ati_remote->outbuf) 642 usb_buffer_free(ati_remote->udev, DATA_BUFSIZE,
647 usb_buffer_free(ati_remote->udev, DATA_BUFSIZE, 643 ati_remote->outbuf, ati_remote->outbuf_dma);
648 ati_remote->inbuf, ati_remote->outbuf_dma);
649} 644}
650 645
651static void ati_remote_input_init(struct ati_remote *ati_remote) 646static void ati_remote_input_init(struct ati_remote *ati_remote)
diff --git a/drivers/usb/input/ati_remote2.c b/drivers/usb/input/ati_remote2.c
index ea71de81ca6b..f982a2b4a7f9 100644
--- a/drivers/usb/input/ati_remote2.c
+++ b/drivers/usb/input/ati_remote2.c
@@ -142,7 +142,7 @@ static void ati_remote2_close(struct input_dev *idev)
142 usb_kill_urb(ar2->urb[1]); 142 usb_kill_urb(ar2->urb[1]);
143} 143}
144 144
145static void ati_remote2_input_mouse(struct ati_remote2 *ar2, struct pt_regs *regs) 145static void ati_remote2_input_mouse(struct ati_remote2 *ar2)
146{ 146{
147 struct input_dev *idev = ar2->idev; 147 struct input_dev *idev = ar2->idev;
148 u8 *data = ar2->buf[0]; 148 u8 *data = ar2->buf[0];
@@ -157,7 +157,6 @@ static void ati_remote2_input_mouse(struct ati_remote2 *ar2, struct pt_regs *reg
157 if (!((1 << data[0]) & mode_mask)) 157 if (!((1 << data[0]) & mode_mask))
158 return; 158 return;
159 159
160 input_regs(idev, regs);
161 input_event(idev, EV_REL, REL_X, (s8) data[1]); 160 input_event(idev, EV_REL, REL_X, (s8) data[1]);
162 input_event(idev, EV_REL, REL_Y, (s8) data[2]); 161 input_event(idev, EV_REL, REL_Y, (s8) data[2]);
163 input_sync(idev); 162 input_sync(idev);
@@ -174,7 +173,7 @@ static int ati_remote2_lookup(unsigned int hw_code)
174 return -1; 173 return -1;
175} 174}
176 175
177static void ati_remote2_input_key(struct ati_remote2 *ar2, struct pt_regs *regs) 176static void ati_remote2_input_key(struct ati_remote2 *ar2)
178{ 177{
179 struct input_dev *idev = ar2->idev; 178 struct input_dev *idev = ar2->idev;
180 u8 *data = ar2->buf[1]; 179 u8 *data = ar2->buf[1];
@@ -245,19 +244,18 @@ static void ati_remote2_input_key(struct ati_remote2 *ar2, struct pt_regs *regs)
245 return; 244 return;
246 } 245 }
247 246
248 input_regs(idev, regs);
249 input_event(idev, EV_KEY, ati_remote2_key_table[index].key_code, data[1]); 247 input_event(idev, EV_KEY, ati_remote2_key_table[index].key_code, data[1]);
250 input_sync(idev); 248 input_sync(idev);
251} 249}
252 250
253static void ati_remote2_complete_mouse(struct urb *urb, struct pt_regs *regs) 251static void ati_remote2_complete_mouse(struct urb *urb)
254{ 252{
255 struct ati_remote2 *ar2 = urb->context; 253 struct ati_remote2 *ar2 = urb->context;
256 int r; 254 int r;
257 255
258 switch (urb->status) { 256 switch (urb->status) {
259 case 0: 257 case 0:
260 ati_remote2_input_mouse(ar2, regs); 258 ati_remote2_input_mouse(ar2);
261 break; 259 break;
262 case -ENOENT: 260 case -ENOENT:
263 case -EILSEQ: 261 case -EILSEQ:
@@ -277,14 +275,14 @@ static void ati_remote2_complete_mouse(struct urb *urb, struct pt_regs *regs)
277 "%s(): usb_submit_urb() = %d\n", __FUNCTION__, r); 275 "%s(): usb_submit_urb() = %d\n", __FUNCTION__, r);
278} 276}
279 277
280static void ati_remote2_complete_key(struct urb *urb, struct pt_regs *regs) 278static void ati_remote2_complete_key(struct urb *urb)
281{ 279{
282 struct ati_remote2 *ar2 = urb->context; 280 struct ati_remote2 *ar2 = urb->context;
283 int r; 281 int r;
284 282
285 switch (urb->status) { 283 switch (urb->status) {
286 case 0: 284 case 0:
287 ati_remote2_input_key(ar2, regs); 285 ati_remote2_input_key(ar2);
288 break; 286 break;
289 case -ENOENT: 287 case -ENOENT:
290 case -EILSEQ: 288 case -EILSEQ:
diff --git a/drivers/usb/input/hid-core.c b/drivers/usb/input/hid-core.c
index e0fd11605b43..6d08a3bcc952 100644
--- a/drivers/usb/input/hid-core.c
+++ b/drivers/usb/input/hid-core.c
@@ -270,7 +270,7 @@ static int hid_add_field(struct hid_parser *parser, unsigned report_type, unsign
270 * Read data value from item. 270 * Read data value from item.
271 */ 271 */
272 272
273static __inline__ __u32 item_udata(struct hid_item *item) 273static u32 item_udata(struct hid_item *item)
274{ 274{
275 switch (item->size) { 275 switch (item->size) {
276 case 1: return item->data.u8; 276 case 1: return item->data.u8;
@@ -280,7 +280,7 @@ static __inline__ __u32 item_udata(struct hid_item *item)
280 return 0; 280 return 0;
281} 281}
282 282
283static __inline__ __s32 item_sdata(struct hid_item *item) 283static s32 item_sdata(struct hid_item *item)
284{ 284{
285 switch (item->size) { 285 switch (item->size) {
286 case 1: return item->data.s8; 286 case 1: return item->data.s8;
@@ -727,7 +727,7 @@ static struct hid_device *hid_parse_report(__u8 *start, unsigned size)
727 * done by hand. 727 * done by hand.
728 */ 728 */
729 729
730static __inline__ __s32 snto32(__u32 value, unsigned n) 730static s32 snto32(__u32 value, unsigned n)
731{ 731{
732 switch (n) { 732 switch (n) {
733 case 8: return ((__s8)value); 733 case 8: return ((__s8)value);
@@ -741,30 +741,65 @@ static __inline__ __s32 snto32(__u32 value, unsigned n)
741 * Convert a signed 32-bit integer to a signed n-bit integer. 741 * Convert a signed 32-bit integer to a signed n-bit integer.
742 */ 742 */
743 743
744static __inline__ __u32 s32ton(__s32 value, unsigned n) 744static u32 s32ton(__s32 value, unsigned n)
745{ 745{
746 __s32 a = value >> (n - 1); 746 s32 a = value >> (n - 1);
747 if (a && a != -1) 747 if (a && a != -1)
748 return value < 0 ? 1 << (n - 1) : (1 << (n - 1)) - 1; 748 return value < 0 ? 1 << (n - 1) : (1 << (n - 1)) - 1;
749 return value & ((1 << n) - 1); 749 return value & ((1 << n) - 1);
750} 750}
751 751
752/* 752/*
753 * Extract/implement a data field from/to a report. 753 * Extract/implement a data field from/to a little endian report (bit array).
754 *
755 * Code sort-of follows HID spec:
756 * http://www.usb.org/developers/devclass_docs/HID1_11.pdf
757 *
758 * While the USB HID spec allows unlimited length bit fields in "report
759 * descriptors", most devices never use more than 16 bits.
760 * One model of UPS is claimed to report "LINEV" as a 32-bit field.
761 * Search linux-kernel and linux-usb-devel archives for "hid-core extract".
754 */ 762 */
755 763
756static __inline__ __u32 extract(__u8 *report, unsigned offset, unsigned n) 764static __inline__ __u32 extract(__u8 *report, unsigned offset, unsigned n)
757{ 765{
758 report += (offset >> 5) << 2; offset &= 31; 766 u64 x;
759 return (le64_to_cpu(get_unaligned((__le64*)report)) >> offset) & ((1ULL << n) - 1); 767
768 WARN_ON(n > 32);
769
770 report += offset >> 3; /* adjust byte index */
771 offset &= 7; /* now only need bit offset into one byte */
772 x = get_unaligned((u64 *) report);
773 x = le64_to_cpu(x);
774 x = (x >> offset) & ((1ULL << n) - 1); /* extract bit field */
775 return (u32) x;
760} 776}
761 777
778/*
779 * "implement" : set bits in a little endian bit stream.
780 * Same concepts as "extract" (see comments above).
781 * The data mangled in the bit stream remains in little endian
782 * order the whole time. It make more sense to talk about
783 * endianness of register values by considering a register
784 * a "cached" copy of the little endiad bit stream.
785 */
762static __inline__ void implement(__u8 *report, unsigned offset, unsigned n, __u32 value) 786static __inline__ void implement(__u8 *report, unsigned offset, unsigned n, __u32 value)
763{ 787{
764 report += (offset >> 5) << 2; offset &= 31; 788 u64 x;
765 put_unaligned((get_unaligned((__le64*)report) 789 u64 m = (1ULL << n) - 1;
766 & cpu_to_le64(~((((__u64) 1 << n) - 1) << offset))) 790
767 | cpu_to_le64((__u64)value << offset), (__le64*)report); 791 WARN_ON(n > 32);
792
793 WARN_ON(value > m);
794 value &= m;
795
796 report += offset >> 3;
797 offset &= 7;
798
799 x = get_unaligned((u64 *)report);
800 x &= cpu_to_le64(~(m << offset));
801 x |= cpu_to_le64(((u64) value) << offset);
802 put_unaligned(x, (u64 *) report);
768} 803}
769 804
770/* 805/*
@@ -780,13 +815,13 @@ static __inline__ int search(__s32 *array, __s32 value, unsigned n)
780 return -1; 815 return -1;
781} 816}
782 817
783static void hid_process_event(struct hid_device *hid, struct hid_field *field, struct hid_usage *usage, __s32 value, int interrupt, struct pt_regs *regs) 818static void hid_process_event(struct hid_device *hid, struct hid_field *field, struct hid_usage *usage, __s32 value, int interrupt)
784{ 819{
785 hid_dump_input(usage, value); 820 hid_dump_input(usage, value);
786 if (hid->claimed & HID_CLAIMED_INPUT) 821 if (hid->claimed & HID_CLAIMED_INPUT)
787 hidinput_hid_event(hid, field, usage, value, regs); 822 hidinput_hid_event(hid, field, usage, value);
788 if (hid->claimed & HID_CLAIMED_HIDDEV && interrupt) 823 if (hid->claimed & HID_CLAIMED_HIDDEV && interrupt)
789 hiddev_hid_event(hid, field, usage, value, regs); 824 hiddev_hid_event(hid, field, usage, value);
790} 825}
791 826
792/* 827/*
@@ -795,7 +830,7 @@ static void hid_process_event(struct hid_device *hid, struct hid_field *field, s
795 * reporting to the layer). 830 * reporting to the layer).
796 */ 831 */
797 832
798static void hid_input_field(struct hid_device *hid, struct hid_field *field, __u8 *data, int interrupt, struct pt_regs *regs) 833static void hid_input_field(struct hid_device *hid, struct hid_field *field, __u8 *data, int interrupt)
799{ 834{
800 unsigned n; 835 unsigned n;
801 unsigned count = field->report_count; 836 unsigned count = field->report_count;
@@ -822,19 +857,19 @@ static void hid_input_field(struct hid_device *hid, struct hid_field *field, __u
822 for (n = 0; n < count; n++) { 857 for (n = 0; n < count; n++) {
823 858
824 if (HID_MAIN_ITEM_VARIABLE & field->flags) { 859 if (HID_MAIN_ITEM_VARIABLE & field->flags) {
825 hid_process_event(hid, field, &field->usage[n], value[n], interrupt, regs); 860 hid_process_event(hid, field, &field->usage[n], value[n], interrupt);
826 continue; 861 continue;
827 } 862 }
828 863
829 if (field->value[n] >= min && field->value[n] <= max 864 if (field->value[n] >= min && field->value[n] <= max
830 && field->usage[field->value[n] - min].hid 865 && field->usage[field->value[n] - min].hid
831 && search(value, field->value[n], count)) 866 && search(value, field->value[n], count))
832 hid_process_event(hid, field, &field->usage[field->value[n] - min], 0, interrupt, regs); 867 hid_process_event(hid, field, &field->usage[field->value[n] - min], 0, interrupt);
833 868
834 if (value[n] >= min && value[n] <= max 869 if (value[n] >= min && value[n] <= max
835 && field->usage[value[n] - min].hid 870 && field->usage[value[n] - min].hid
836 && search(field->value, value[n], count)) 871 && search(field->value, value[n], count))
837 hid_process_event(hid, field, &field->usage[value[n] - min], 1, interrupt, regs); 872 hid_process_event(hid, field, &field->usage[value[n] - min], 1, interrupt);
838 } 873 }
839 874
840 memcpy(field->value, value, count * sizeof(__s32)); 875 memcpy(field->value, value, count * sizeof(__s32));
@@ -842,7 +877,7 @@ exit:
842 kfree(value); 877 kfree(value);
843} 878}
844 879
845static int hid_input_report(int type, struct urb *urb, int interrupt, struct pt_regs *regs) 880static int hid_input_report(int type, struct urb *urb, int interrupt)
846{ 881{
847 struct hid_device *hid = urb->context; 882 struct hid_device *hid = urb->context;
848 struct hid_report_enum *report_enum = hid->report_enum + type; 883 struct hid_report_enum *report_enum = hid->report_enum + type;
@@ -892,7 +927,7 @@ static int hid_input_report(int type, struct urb *urb, int interrupt, struct pt_
892 hiddev_report_event(hid, report); 927 hiddev_report_event(hid, report);
893 928
894 for (n = 0; n < report->maxfield; n++) 929 for (n = 0; n < report->maxfield; n++)
895 hid_input_field(hid, report->field[n], data, interrupt, regs); 930 hid_input_field(hid, report->field[n], data, interrupt);
896 931
897 if (hid->claimed & HID_CLAIMED_INPUT) 932 if (hid->claimed & HID_CLAIMED_INPUT)
898 hidinput_report_event(hid, report); 933 hidinput_report_event(hid, report);
@@ -1004,7 +1039,7 @@ done:
1004 * Input interrupt completion handler. 1039 * Input interrupt completion handler.
1005 */ 1040 */
1006 1041
1007static void hid_irq_in(struct urb *urb, struct pt_regs *regs) 1042static void hid_irq_in(struct urb *urb)
1008{ 1043{
1009 struct hid_device *hid = urb->context; 1044 struct hid_device *hid = urb->context;
1010 int status; 1045 int status;
@@ -1012,7 +1047,7 @@ static void hid_irq_in(struct urb *urb, struct pt_regs *regs)
1012 switch (urb->status) { 1047 switch (urb->status) {
1013 case 0: /* success */ 1048 case 0: /* success */
1014 hid->retry_delay = 0; 1049 hid->retry_delay = 0;
1015 hid_input_report(HID_INPUT_REPORT, urb, 1, regs); 1050 hid_input_report(HID_INPUT_REPORT, urb, 1);
1016 break; 1051 break;
1017 case -ECONNRESET: /* unlink */ 1052 case -ECONNRESET: /* unlink */
1018 case -ENOENT: 1053 case -ENOENT:
@@ -1193,7 +1228,7 @@ static int hid_submit_ctrl(struct hid_device *hid)
1193 * Output interrupt completion handler. 1228 * Output interrupt completion handler.
1194 */ 1229 */
1195 1230
1196static void hid_irq_out(struct urb *urb, struct pt_regs *regs) 1231static void hid_irq_out(struct urb *urb)
1197{ 1232{
1198 struct hid_device *hid = urb->context; 1233 struct hid_device *hid = urb->context;
1199 unsigned long flags; 1234 unsigned long flags;
@@ -1238,7 +1273,7 @@ static void hid_irq_out(struct urb *urb, struct pt_regs *regs)
1238 * Control pipe completion handler. 1273 * Control pipe completion handler.
1239 */ 1274 */
1240 1275
1241static void hid_ctrl(struct urb *urb, struct pt_regs *regs) 1276static void hid_ctrl(struct urb *urb)
1242{ 1277{
1243 struct hid_device *hid = urb->context; 1278 struct hid_device *hid = urb->context;
1244 unsigned long flags; 1279 unsigned long flags;
@@ -1249,7 +1284,7 @@ static void hid_ctrl(struct urb *urb, struct pt_regs *regs)
1249 switch (urb->status) { 1284 switch (urb->status) {
1250 case 0: /* success */ 1285 case 0: /* success */
1251 if (hid->ctrl[hid->ctrltail].dir == USB_DIR_IN) 1286 if (hid->ctrl[hid->ctrltail].dir == USB_DIR_IN)
1252 hid_input_report(hid->ctrl[hid->ctrltail].report->type, urb, 0, regs); 1287 hid_input_report(hid->ctrl[hid->ctrltail].report->type, urb, 0);
1253 break; 1288 break;
1254 case -ESHUTDOWN: /* unplug */ 1289 case -ESHUTDOWN: /* unplug */
1255 unplug = 1; 1290 unplug = 1;
@@ -1381,6 +1416,9 @@ void hid_close(struct hid_device *hid)
1381 1416
1382#define USB_VENDOR_ID_PANJIT 0x134c 1417#define USB_VENDOR_ID_PANJIT 0x134c
1383 1418
1419#define USB_VENDOR_ID_TURBOX 0x062a
1420#define USB_DEVICE_ID_TURBOX_KEYBOARD 0x0201
1421
1384/* 1422/*
1385 * Initialize all reports 1423 * Initialize all reports
1386 */ 1424 */
@@ -1602,6 +1640,9 @@ void hid_init_reports(struct hid_device *hid)
1602#define USB_VENDOR_ID_SUN 0x0430 1640#define USB_VENDOR_ID_SUN 0x0430
1603#define USB_DEVICE_ID_RARITAN_KVM_DONGLE 0xcdab 1641#define USB_DEVICE_ID_RARITAN_KVM_DONGLE 0xcdab
1604 1642
1643#define USB_VENDOR_ID_AIRCABLE 0x16CA
1644#define USB_DEVICE_ID_AIRCABLE1 0x1502
1645
1605/* 1646/*
1606 * Alphabetically sorted blacklist by quirk type. 1647 * Alphabetically sorted blacklist by quirk type.
1607 */ 1648 */
@@ -1619,6 +1660,7 @@ static const struct hid_blacklist {
1619 { USB_VENDOR_ID_AIPTEK, USB_DEVICE_ID_AIPTEK_22, HID_QUIRK_IGNORE }, 1660 { USB_VENDOR_ID_AIPTEK, USB_DEVICE_ID_AIPTEK_22, HID_QUIRK_IGNORE },
1620 { USB_VENDOR_ID_AIPTEK, USB_DEVICE_ID_AIPTEK_23, HID_QUIRK_IGNORE }, 1661 { USB_VENDOR_ID_AIPTEK, USB_DEVICE_ID_AIPTEK_23, HID_QUIRK_IGNORE },
1621 { USB_VENDOR_ID_AIPTEK, USB_DEVICE_ID_AIPTEK_24, HID_QUIRK_IGNORE }, 1662 { USB_VENDOR_ID_AIPTEK, USB_DEVICE_ID_AIPTEK_24, HID_QUIRK_IGNORE },
1663 { USB_VENDOR_ID_AIRCABLE, USB_DEVICE_ID_AIRCABLE1, HID_QUIRK_IGNORE },
1622 { USB_VENDOR_ID_ALCOR, USB_DEVICE_ID_ALCOR_USBRS232, HID_QUIRK_IGNORE }, 1664 { USB_VENDOR_ID_ALCOR, USB_DEVICE_ID_ALCOR_USBRS232, HID_QUIRK_IGNORE },
1623 { USB_VENDOR_ID_BERKSHIRE, USB_DEVICE_ID_BERKSHIRE_PCWD, HID_QUIRK_IGNORE }, 1665 { USB_VENDOR_ID_BERKSHIRE, USB_DEVICE_ID_BERKSHIRE_PCWD, HID_QUIRK_IGNORE },
1624 { USB_VENDOR_ID_CODEMERCS, USB_DEVICE_ID_CODEMERCS_IOW40, HID_QUIRK_IGNORE }, 1666 { USB_VENDOR_ID_CODEMERCS, USB_DEVICE_ID_CODEMERCS_IOW40, HID_QUIRK_IGNORE },
@@ -1755,11 +1797,12 @@ static const struct hid_blacklist {
1755 { USB_VENDOR_ID_APPLE, 0x020E, HID_QUIRK_POWERBOOK_HAS_FN }, 1797 { USB_VENDOR_ID_APPLE, 0x020E, HID_QUIRK_POWERBOOK_HAS_FN },
1756 { USB_VENDOR_ID_APPLE, 0x020F, HID_QUIRK_POWERBOOK_HAS_FN }, 1798 { USB_VENDOR_ID_APPLE, 0x020F, HID_QUIRK_POWERBOOK_HAS_FN },
1757 { USB_VENDOR_ID_APPLE, 0x0214, HID_QUIRK_POWERBOOK_HAS_FN }, 1799 { USB_VENDOR_ID_APPLE, 0x0214, HID_QUIRK_POWERBOOK_HAS_FN },
1758 { USB_VENDOR_ID_APPLE, 0x0215, HID_QUIRK_POWERBOOK_HAS_FN }, 1800 { USB_VENDOR_ID_APPLE, 0x0215, HID_QUIRK_POWERBOOK_HAS_FN | HID_QUIRK_POWERBOOK_ISO_KEYBOARD},
1759 { USB_VENDOR_ID_APPLE, 0x0216, HID_QUIRK_POWERBOOK_HAS_FN }, 1801 { USB_VENDOR_ID_APPLE, 0x0216, HID_QUIRK_POWERBOOK_HAS_FN },
1760 { USB_VENDOR_ID_APPLE, 0x0217, HID_QUIRK_POWERBOOK_HAS_FN }, 1802 { USB_VENDOR_ID_APPLE, 0x0217, HID_QUIRK_POWERBOOK_HAS_FN },
1761 { USB_VENDOR_ID_APPLE, 0x0218, HID_QUIRK_POWERBOOK_HAS_FN }, 1803 { USB_VENDOR_ID_APPLE, 0x0218, HID_QUIRK_POWERBOOK_HAS_FN | HID_QUIRK_POWERBOOK_ISO_KEYBOARD},
1762 { USB_VENDOR_ID_APPLE, 0x0219, HID_QUIRK_POWERBOOK_HAS_FN }, 1804 { USB_VENDOR_ID_APPLE, 0x0219, HID_QUIRK_POWERBOOK_HAS_FN },
1805 { USB_VENDOR_ID_APPLE, 0x021B, HID_QUIRK_POWERBOOK_HAS_FN },
1763 { USB_VENDOR_ID_APPLE, 0x030A, HID_QUIRK_POWERBOOK_HAS_FN }, 1806 { USB_VENDOR_ID_APPLE, 0x030A, HID_QUIRK_POWERBOOK_HAS_FN },
1764 { USB_VENDOR_ID_APPLE, 0x030B, HID_QUIRK_POWERBOOK_HAS_FN }, 1807 { USB_VENDOR_ID_APPLE, 0x030B, HID_QUIRK_POWERBOOK_HAS_FN },
1765 1808
@@ -1768,6 +1811,8 @@ static const struct hid_blacklist {
1768 { USB_VENDOR_ID_PANJIT, 0x0003, HID_QUIRK_IGNORE }, 1811 { USB_VENDOR_ID_PANJIT, 0x0003, HID_QUIRK_IGNORE },
1769 { USB_VENDOR_ID_PANJIT, 0x0004, HID_QUIRK_IGNORE }, 1812 { USB_VENDOR_ID_PANJIT, 0x0004, HID_QUIRK_IGNORE },
1770 1813
1814 { USB_VENDOR_ID_TURBOX, USB_DEVICE_ID_TURBOX_KEYBOARD, HID_QUIRK_NOGET },
1815
1771 { 0, 0 } 1816 { 0, 0 }
1772}; 1817};
1773 1818
diff --git a/drivers/usb/input/hid-input.c b/drivers/usb/input/hid-input.c
index 4c62afbeb430..68e7ebb978a9 100644
--- a/drivers/usb/input/hid-input.c
+++ b/drivers/usb/input/hid-input.c
@@ -121,6 +121,12 @@ static struct hidinput_key_translation powerbook_numlock_keys[] = {
121 { } 121 { }
122}; 122};
123 123
124static struct hidinput_key_translation powerbook_iso_keyboard[] = {
125 { KEY_GRAVE, KEY_102ND },
126 { KEY_102ND, KEY_GRAVE },
127 { }
128};
129
124static int usbhid_pb_fnmode = 1; 130static int usbhid_pb_fnmode = 1;
125module_param_named(pb_fnmode, usbhid_pb_fnmode, int, 0644); 131module_param_named(pb_fnmode, usbhid_pb_fnmode, int, 0644);
126MODULE_PARM_DESC(pb_fnmode, 132MODULE_PARM_DESC(pb_fnmode,
@@ -195,6 +201,14 @@ static int hidinput_pb_event(struct hid_device *hid, struct input_dev *input,
195 } 201 }
196 } 202 }
197 203
204 if (hid->quirks & HID_QUIRK_POWERBOOK_ISO_KEYBOARD) {
205 trans = find_translation(powerbook_iso_keyboard, usage->code);
206 if (trans) {
207 input_event(input, usage->type, trans->to, value);
208 return 1;
209 }
210 }
211
198 return 0; 212 return 0;
199} 213}
200 214
@@ -210,6 +224,9 @@ static void hidinput_pb_setup(struct input_dev *input)
210 224
211 for (trans = powerbook_numlock_keys; trans->from; trans++) 225 for (trans = powerbook_numlock_keys; trans->from; trans++)
212 set_bit(trans->to, input->keybit); 226 set_bit(trans->to, input->keybit);
227
228 for (trans = powerbook_iso_keyboard; trans->from; trans++)
229 set_bit(trans->to, input->keybit);
213} 230}
214#else 231#else
215static inline int hidinput_pb_event(struct hid_device *hid, struct input_dev *input, 232static inline int hidinput_pb_event(struct hid_device *hid, struct input_dev *input,
@@ -613,7 +630,7 @@ ignore:
613 return; 630 return;
614} 631}
615 632
616void hidinput_hid_event(struct hid_device *hid, struct hid_field *field, struct hid_usage *usage, __s32 value, struct pt_regs *regs) 633void hidinput_hid_event(struct hid_device *hid, struct hid_field *field, struct hid_usage *usage, __s32 value)
617{ 634{
618 struct input_dev *input; 635 struct input_dev *input;
619 int *quirks = &hid->quirks; 636 int *quirks = &hid->quirks;
@@ -623,8 +640,6 @@ void hidinput_hid_event(struct hid_device *hid, struct hid_field *field, struct
623 640
624 input = field->hidinput->input; 641 input = field->hidinput->input;
625 642
626 input_regs(input, regs);
627
628 if (!usage->type) 643 if (!usage->type)
629 return; 644 return;
630 645
diff --git a/drivers/usb/input/hid.h b/drivers/usb/input/hid.h
index b03fd9b075df..0e76e6dcac37 100644
--- a/drivers/usb/input/hid.h
+++ b/drivers/usb/input/hid.h
@@ -260,6 +260,7 @@ struct hid_item {
260#define HID_QUIRK_POWERBOOK_HAS_FN 0x00001000 260#define HID_QUIRK_POWERBOOK_HAS_FN 0x00001000
261#define HID_QUIRK_POWERBOOK_FN_ON 0x00002000 261#define HID_QUIRK_POWERBOOK_FN_ON 0x00002000
262#define HID_QUIRK_INVERT_HWHEEL 0x00004000 262#define HID_QUIRK_INVERT_HWHEEL 0x00004000
263#define HID_QUIRK_POWERBOOK_ISO_KEYBOARD 0x00008000
263 264
264/* 265/*
265 * This is the global environment of the parser. This information is 266 * This is the global environment of the parser. This information is
@@ -499,13 +500,13 @@ struct hid_descriptor {
499/* Applications from HID Usage Tables 4/8/99 Version 1.1 */ 500/* Applications from HID Usage Tables 4/8/99 Version 1.1 */
500/* We ignore a few input applications that are not widely used */ 501/* We ignore a few input applications that are not widely used */
501#define IS_INPUT_APPLICATION(a) (((a >= 0x00010000) && (a <= 0x00010008)) || (a == 0x00010080) || (a == 0x000c0001)) 502#define IS_INPUT_APPLICATION(a) (((a >= 0x00010000) && (a <= 0x00010008)) || (a == 0x00010080) || (a == 0x000c0001))
502extern void hidinput_hid_event(struct hid_device *, struct hid_field *, struct hid_usage *, __s32, struct pt_regs *regs); 503extern void hidinput_hid_event(struct hid_device *, struct hid_field *, struct hid_usage *, __s32);
503extern void hidinput_report_event(struct hid_device *hid, struct hid_report *report); 504extern void hidinput_report_event(struct hid_device *hid, struct hid_report *report);
504extern int hidinput_connect(struct hid_device *); 505extern int hidinput_connect(struct hid_device *);
505extern void hidinput_disconnect(struct hid_device *); 506extern void hidinput_disconnect(struct hid_device *);
506#else 507#else
507#define IS_INPUT_APPLICATION(a) (0) 508#define IS_INPUT_APPLICATION(a) (0)
508static inline void hidinput_hid_event(struct hid_device *hid, struct hid_field *field, struct hid_usage *usage, __s32 value, struct pt_regs *regs) { } 509static inline void hidinput_hid_event(struct hid_device *hid, struct hid_field *field, struct hid_usage *usage, __s32 value) { }
509static inline void hidinput_report_event(struct hid_device *hid, struct hid_report *report) { } 510static inline void hidinput_report_event(struct hid_device *hid, struct hid_report *report) { }
510static inline int hidinput_connect(struct hid_device *hid) { return -ENODEV; } 511static inline int hidinput_connect(struct hid_device *hid) { return -ENODEV; }
511static inline void hidinput_disconnect(struct hid_device *hid) { } 512static inline void hidinput_disconnect(struct hid_device *hid) { }
diff --git a/drivers/usb/input/hiddev.c b/drivers/usb/input/hiddev.c
index a2b419d13740..7dc14d0cacc1 100644
--- a/drivers/usb/input/hiddev.c
+++ b/drivers/usb/input/hiddev.c
@@ -179,7 +179,7 @@ static void hiddev_send_event(struct hid_device *hid,
179 * the interrupt pipe 179 * the interrupt pipe
180 */ 180 */
181void hiddev_hid_event(struct hid_device *hid, struct hid_field *field, 181void hiddev_hid_event(struct hid_device *hid, struct hid_field *field,
182 struct hid_usage *usage, __s32 value, struct pt_regs *regs) 182 struct hid_usage *usage, __s32 value)
183{ 183{
184 unsigned type = field->report_type; 184 unsigned type = field->report_type;
185 struct hiddev_usage_ref uref; 185 struct hiddev_usage_ref uref;
diff --git a/drivers/usb/input/itmtouch.c b/drivers/usb/input/itmtouch.c
index 61966d719ca3..aac968aab860 100644
--- a/drivers/usb/input/itmtouch.c
+++ b/drivers/usb/input/itmtouch.c
@@ -36,7 +36,11 @@
36 * 36 *
37 * 1.2.1 09/03/2005 (HCE) hc@mivu.no 37 * 1.2.1 09/03/2005 (HCE) hc@mivu.no
38 * Code cleanup and adjusting syntax to start matching kernel standards 38 * Code cleanup and adjusting syntax to start matching kernel standards
39 * 39 *
40 * 1.2.2 10/05/2006 (MJA) massad@gmail.com
41 * Flag for detecting if the screen was being touch was incorrectly
42 * inverted, so no touch events were being detected.
43 *
40 *****************************************************************************/ 44 *****************************************************************************/
41 45
42#include <linux/kernel.h> 46#include <linux/kernel.h>
@@ -53,7 +57,7 @@
53#define USB_PRODUCT_ID_TOUCHPANEL 0xf9e9 57#define USB_PRODUCT_ID_TOUCHPANEL 0xf9e9
54 58
55#define DRIVER_AUTHOR "Hans-Christian Egtvedt <hc@mivu.no>" 59#define DRIVER_AUTHOR "Hans-Christian Egtvedt <hc@mivu.no>"
56#define DRIVER_VERSION "v1.2.1" 60#define DRIVER_VERSION "v1.2.2"
57#define DRIVER_DESC "USB ITM Inc Touch Panel Driver" 61#define DRIVER_DESC "USB ITM Inc Touch Panel Driver"
58#define DRIVER_LICENSE "GPL" 62#define DRIVER_LICENSE "GPL"
59 63
@@ -76,7 +80,7 @@ static struct usb_device_id itmtouch_ids [] = {
76 { } 80 { }
77}; 81};
78 82
79static void itmtouch_irq(struct urb *urb, struct pt_regs *regs) 83static void itmtouch_irq(struct urb *urb)
80{ 84{
81 struct itmtouch_dev *itmtouch = urb->context; 85 struct itmtouch_dev *itmtouch = urb->context;
82 unsigned char *data = urb->transfer_buffer; 86 unsigned char *data = urb->transfer_buffer;
@@ -105,10 +109,8 @@ static void itmtouch_irq(struct urb *urb, struct pt_regs *regs)
105 goto exit; 109 goto exit;
106 } 110 }
107 111
108 input_regs(dev, regs);
109
110 /* if pressure has been released, then don't report X/Y */ 112 /* if pressure has been released, then don't report X/Y */
111 if (data[7] & 0x20) { 113 if (!(data[7] & 0x20)) {
112 input_report_abs(dev, ABS_X, (data[0] & 0x1F) << 7 | (data[3] & 0x7F)); 114 input_report_abs(dev, ABS_X, (data[0] & 0x1F) << 7 | (data[3] & 0x7F));
113 input_report_abs(dev, ABS_Y, (data[1] & 0x1F) << 7 | (data[4] & 0x7F)); 115 input_report_abs(dev, ABS_Y, (data[1] & 0x1F) << 7 | (data[4] & 0x7F));
114 } 116 }
diff --git a/drivers/usb/input/kbtab.c b/drivers/usb/input/kbtab.c
index 604ade356ead..fedbcb127c21 100644
--- a/drivers/usb/input/kbtab.c
+++ b/drivers/usb/input/kbtab.c
@@ -41,7 +41,7 @@ struct kbtab {
41 char phys[32]; 41 char phys[32];
42}; 42};
43 43
44static void kbtab_irq(struct urb *urb, struct pt_regs *regs) 44static void kbtab_irq(struct urb *urb)
45{ 45{
46 struct kbtab *kbtab = urb->context; 46 struct kbtab *kbtab = urb->context;
47 unsigned char *data = kbtab->data; 47 unsigned char *data = kbtab->data;
diff --git a/drivers/usb/input/keyspan_remote.c b/drivers/usb/input/keyspan_remote.c
index a90359551575..50aa8108a50b 100644
--- a/drivers/usb/input/keyspan_remote.c
+++ b/drivers/usb/input/keyspan_remote.c
@@ -176,7 +176,7 @@ static int keyspan_load_tester(struct usb_keyspan* dev, int bits_needed)
176/* 176/*
177 * Routine that handles all the logic needed to parse out the message from the remote. 177 * Routine that handles all the logic needed to parse out the message from the remote.
178 */ 178 */
179static void keyspan_check_data(struct usb_keyspan *remote, struct pt_regs *regs) 179static void keyspan_check_data(struct usb_keyspan *remote)
180{ 180{
181 int i; 181 int i;
182 int found = 0; 182 int found = 0;
@@ -311,7 +311,6 @@ static void keyspan_check_data(struct usb_keyspan *remote, struct pt_regs *regs)
311 __FUNCTION__, message.system, message.button, message.toggle); 311 __FUNCTION__, message.system, message.button, message.toggle);
312 312
313 if (message.toggle != remote->toggle) { 313 if (message.toggle != remote->toggle) {
314 input_regs(remote->input, regs);
315 input_report_key(remote->input, keyspan_key_table[message.button], 1); 314 input_report_key(remote->input, keyspan_key_table[message.button], 1);
316 input_report_key(remote->input, keyspan_key_table[message.button], 0); 315 input_report_key(remote->input, keyspan_key_table[message.button], 0);
317 input_sync(remote->input); 316 input_sync(remote->input);
@@ -361,7 +360,7 @@ static int keyspan_setup(struct usb_device* dev)
361/* 360/*
362 * Routine used to handle a new message that has come in. 361 * Routine used to handle a new message that has come in.
363 */ 362 */
364static void keyspan_irq_recv(struct urb *urb, struct pt_regs *regs) 363static void keyspan_irq_recv(struct urb *urb)
365{ 364{
366 struct usb_keyspan *dev = urb->context; 365 struct usb_keyspan *dev = urb->context;
367 int retval; 366 int retval;
@@ -385,7 +384,7 @@ static void keyspan_irq_recv(struct urb *urb, struct pt_regs *regs)
385 if (debug) 384 if (debug)
386 keyspan_print(dev); 385 keyspan_print(dev);
387 386
388 keyspan_check_data(dev, regs); 387 keyspan_check_data(dev);
389 388
390resubmit: 389resubmit:
391 retval = usb_submit_urb(urb, GFP_ATOMIC); 390 retval = usb_submit_urb(urb, GFP_ATOMIC);
diff --git a/drivers/usb/input/mtouchusb.c b/drivers/usb/input/mtouchusb.c
index 5dce951f2751..79a85d46cb13 100644
--- a/drivers/usb/input/mtouchusb.c
+++ b/drivers/usb/input/mtouchusb.c
@@ -98,7 +98,7 @@ static struct usb_device_id mtouchusb_devices[] = {
98 { } 98 { }
99}; 99};
100 100
101static void mtouchusb_irq(struct urb *urb, struct pt_regs *regs) 101static void mtouchusb_irq(struct urb *urb)
102{ 102{
103 struct mtouch_usb *mtouch = urb->context; 103 struct mtouch_usb *mtouch = urb->context;
104 int retval; 104 int retval;
@@ -125,7 +125,6 @@ static void mtouchusb_irq(struct urb *urb, struct pt_regs *regs)
125 goto exit; 125 goto exit;
126 } 126 }
127 127
128 input_regs(mtouch->input, regs);
129 input_report_key(mtouch->input, BTN_TOUCH, 128 input_report_key(mtouch->input, BTN_TOUCH,
130 MTOUCHUSB_GET_TOUCHED(mtouch->data)); 129 MTOUCHUSB_GET_TOUCHED(mtouch->data));
131 input_report_abs(mtouch->input, ABS_X, MTOUCHUSB_GET_XC(mtouch->data)); 130 input_report_abs(mtouch->input, ABS_X, MTOUCHUSB_GET_XC(mtouch->data));
diff --git a/drivers/usb/input/powermate.c b/drivers/usb/input/powermate.c
index f0f8db6810a2..0bf91778c40d 100644
--- a/drivers/usb/input/powermate.c
+++ b/drivers/usb/input/powermate.c
@@ -80,10 +80,10 @@ struct powermate_device {
80static char pm_name_powermate[] = "Griffin PowerMate"; 80static char pm_name_powermate[] = "Griffin PowerMate";
81static char pm_name_soundknob[] = "Griffin SoundKnob"; 81static char pm_name_soundknob[] = "Griffin SoundKnob";
82 82
83static void powermate_config_complete(struct urb *urb, struct pt_regs *regs); 83static void powermate_config_complete(struct urb *urb);
84 84
85/* Callback for data arriving from the PowerMate over the USB interrupt pipe */ 85/* Callback for data arriving from the PowerMate over the USB interrupt pipe */
86static void powermate_irq(struct urb *urb, struct pt_regs *regs) 86static void powermate_irq(struct urb *urb)
87{ 87{
88 struct powermate_device *pm = urb->context; 88 struct powermate_device *pm = urb->context;
89 int retval; 89 int retval;
@@ -104,7 +104,6 @@ static void powermate_irq(struct urb *urb, struct pt_regs *regs)
104 } 104 }
105 105
106 /* handle updates to device state */ 106 /* handle updates to device state */
107 input_regs(pm->input, regs);
108 input_report_key(pm->input, BTN_0, pm->data[0] & 0x01); 107 input_report_key(pm->input, BTN_0, pm->data[0] & 0x01);
109 input_report_rel(pm->input, REL_DIAL, pm->data[1]); 108 input_report_rel(pm->input, REL_DIAL, pm->data[1]);
110 input_sync(pm->input); 109 input_sync(pm->input);
@@ -191,7 +190,7 @@ static void powermate_sync_state(struct powermate_device *pm)
191} 190}
192 191
193/* Called when our asynchronous control message completes. We may need to issue another immediately */ 192/* Called when our asynchronous control message completes. We may need to issue another immediately */
194static void powermate_config_complete(struct urb *urb, struct pt_regs *regs) 193static void powermate_config_complete(struct urb *urb)
195{ 194{
196 struct powermate_device *pm = urb->context; 195 struct powermate_device *pm = urb->context;
197 unsigned long flags; 196 unsigned long flags;
diff --git a/drivers/usb/input/touchkitusb.c b/drivers/usb/input/touchkitusb.c
index 30b9f820e7a8..05c0d1ca39ab 100644
--- a/drivers/usb/input/touchkitusb.c
+++ b/drivers/usb/input/touchkitusb.c
@@ -92,8 +92,7 @@ static inline int touchkit_get_y(char *data)
92 92
93 93
94/* processes one input packet. */ 94/* processes one input packet. */
95static void touchkit_process_pkt(struct touchkit_usb *touchkit, 95static void touchkit_process_pkt(struct touchkit_usb *touchkit, char *pkt)
96 struct pt_regs *regs, char *pkt)
97{ 96{
98 int x, y; 97 int x, y;
99 98
@@ -109,7 +108,6 @@ static void touchkit_process_pkt(struct touchkit_usb *touchkit,
109 y = touchkit_get_y(pkt); 108 y = touchkit_get_y(pkt);
110 } 109 }
111 110
112 input_regs(touchkit->input, regs);
113 input_report_key(touchkit->input, BTN_TOUCH, touchkit_get_touched(pkt)); 111 input_report_key(touchkit->input, BTN_TOUCH, touchkit_get_touched(pkt));
114 input_report_abs(touchkit->input, ABS_X, x); 112 input_report_abs(touchkit->input, ABS_X, x);
115 input_report_abs(touchkit->input, ABS_Y, y); 113 input_report_abs(touchkit->input, ABS_Y, y);
@@ -130,8 +128,7 @@ static int touchkit_get_pkt_len(char *buf)
130 return 0; 128 return 0;
131} 129}
132 130
133static void touchkit_process(struct touchkit_usb *touchkit, int len, 131static void touchkit_process(struct touchkit_usb *touchkit, int len)
134 struct pt_regs *regs)
135{ 132{
136 char *buffer; 133 char *buffer;
137 int pkt_len, buf_len, pos; 134 int pkt_len, buf_len, pos;
@@ -153,7 +150,7 @@ static void touchkit_process(struct touchkit_usb *touchkit, int len,
153 /* append, process */ 150 /* append, process */
154 tmp = pkt_len - touchkit->buf_len; 151 tmp = pkt_len - touchkit->buf_len;
155 memcpy(touchkit->buffer + touchkit->buf_len, touchkit->data, tmp); 152 memcpy(touchkit->buffer + touchkit->buf_len, touchkit->data, tmp);
156 touchkit_process_pkt(touchkit, regs, touchkit->buffer); 153 touchkit_process_pkt(touchkit, touchkit->buffer);
157 154
158 buffer = touchkit->data + tmp; 155 buffer = touchkit->data + tmp;
159 buf_len = len - tmp; 156 buf_len = len - tmp;
@@ -181,7 +178,7 @@ static void touchkit_process(struct touchkit_usb *touchkit, int len,
181 178
182 /* full packet: process */ 179 /* full packet: process */
183 if (likely(pkt_len <= buf_len)) { 180 if (likely(pkt_len <= buf_len)) {
184 touchkit_process_pkt(touchkit, regs, buffer + pos); 181 touchkit_process_pkt(touchkit, buffer + pos);
185 } else { 182 } else {
186 /* incomplete packet: save in buffer */ 183 /* incomplete packet: save in buffer */
187 memcpy(touchkit->buffer, buffer + pos, buf_len - pos); 184 memcpy(touchkit->buffer, buffer + pos, buf_len - pos);
@@ -192,7 +189,7 @@ static void touchkit_process(struct touchkit_usb *touchkit, int len,
192} 189}
193 190
194 191
195static void touchkit_irq(struct urb *urb, struct pt_regs *regs) 192static void touchkit_irq(struct urb *urb)
196{ 193{
197 struct touchkit_usb *touchkit = urb->context; 194 struct touchkit_usb *touchkit = urb->context;
198 int retval; 195 int retval;
@@ -219,7 +216,7 @@ static void touchkit_irq(struct urb *urb, struct pt_regs *regs)
219 goto exit; 216 goto exit;
220 } 217 }
221 218
222 touchkit_process(touchkit, urb->actual_length, regs); 219 touchkit_process(touchkit, urb->actual_length);
223 220
224exit: 221exit:
225 retval = usb_submit_urb(urb, GFP_ATOMIC); 222 retval = usb_submit_urb(urb, GFP_ATOMIC);
diff --git a/drivers/usb/input/usbkbd.c b/drivers/usb/input/usbkbd.c
index 5067a6ae650f..c73285cf8558 100644
--- a/drivers/usb/input/usbkbd.c
+++ b/drivers/usb/input/usbkbd.c
@@ -80,7 +80,7 @@ struct usb_kbd {
80 dma_addr_t leds_dma; 80 dma_addr_t leds_dma;
81}; 81};
82 82
83static void usb_kbd_irq(struct urb *urb, struct pt_regs *regs) 83static void usb_kbd_irq(struct urb *urb)
84{ 84{
85 struct usb_kbd *kbd = urb->context; 85 struct usb_kbd *kbd = urb->context;
86 int i; 86 int i;
@@ -97,8 +97,6 @@ static void usb_kbd_irq(struct urb *urb, struct pt_regs *regs)
97 goto resubmit; 97 goto resubmit;
98 } 98 }
99 99
100 input_regs(kbd->dev, regs);
101
102 for (i = 0; i < 8; i++) 100 for (i = 0; i < 8; i++)
103 input_report_key(kbd->dev, usb_kbd_keycode[i + 224], (kbd->new[0] >> i) & 1); 101 input_report_key(kbd->dev, usb_kbd_keycode[i + 224], (kbd->new[0] >> i) & 1);
104 102
@@ -158,7 +156,7 @@ static int usb_kbd_event(struct input_dev *dev, unsigned int type,
158 return 0; 156 return 0;
159} 157}
160 158
161static void usb_kbd_led(struct urb *urb, struct pt_regs *regs) 159static void usb_kbd_led(struct urb *urb)
162{ 160{
163 struct usb_kbd *kbd = urb->context; 161 struct usb_kbd *kbd = urb->context;
164 162
diff --git a/drivers/usb/input/usbmouse.c b/drivers/usb/input/usbmouse.c
index 0fb792be95ef..cbbbea332ed7 100644
--- a/drivers/usb/input/usbmouse.c
+++ b/drivers/usb/input/usbmouse.c
@@ -55,7 +55,7 @@ struct usb_mouse {
55 dma_addr_t data_dma; 55 dma_addr_t data_dma;
56}; 56};
57 57
58static void usb_mouse_irq(struct urb *urb, struct pt_regs *regs) 58static void usb_mouse_irq(struct urb *urb)
59{ 59{
60 struct usb_mouse *mouse = urb->context; 60 struct usb_mouse *mouse = urb->context;
61 signed char *data = mouse->data; 61 signed char *data = mouse->data;
@@ -74,8 +74,6 @@ static void usb_mouse_irq(struct urb *urb, struct pt_regs *regs)
74 goto resubmit; 74 goto resubmit;
75 } 75 }
76 76
77 input_regs(dev, regs);
78
79 input_report_key(dev, BTN_LEFT, data[0] & 0x01); 77 input_report_key(dev, BTN_LEFT, data[0] & 0x01);
80 input_report_key(dev, BTN_RIGHT, data[0] & 0x02); 78 input_report_key(dev, BTN_RIGHT, data[0] & 0x02);
81 input_report_key(dev, BTN_MIDDLE, data[0] & 0x04); 79 input_report_key(dev, BTN_MIDDLE, data[0] & 0x04);
diff --git a/drivers/usb/input/usbtouchscreen.c b/drivers/usb/input/usbtouchscreen.c
index 923e22db18d4..933ceddf3dee 100644
--- a/drivers/usb/input/usbtouchscreen.c
+++ b/drivers/usb/input/usbtouchscreen.c
@@ -61,7 +61,7 @@ struct usbtouch_device_info {
61 int rept_size; 61 int rept_size;
62 int flags; 62 int flags;
63 63
64 void (*process_pkt) (struct usbtouch_usb *usbtouch, struct pt_regs *regs, unsigned char *pkt, int len); 64 void (*process_pkt) (struct usbtouch_usb *usbtouch, unsigned char *pkt, int len);
65 int (*get_pkt_len) (unsigned char *pkt, int len); 65 int (*get_pkt_len) (unsigned char *pkt, int len);
66 int (*read_data) (unsigned char *pkt, int *x, int *y, int *touch, int *press); 66 int (*read_data) (unsigned char *pkt, int *x, int *y, int *touch, int *press);
67 int (*init) (struct usbtouch_usb *usbtouch); 67 int (*init) (struct usbtouch_usb *usbtouch);
@@ -91,7 +91,6 @@ struct usbtouch_usb {
91 91
92#ifdef MULTI_PACKET 92#ifdef MULTI_PACKET
93static void usbtouch_process_multi(struct usbtouch_usb *usbtouch, 93static void usbtouch_process_multi(struct usbtouch_usb *usbtouch,
94 struct pt_regs *regs,
95 unsigned char *pkt, int len); 94 unsigned char *pkt, int len);
96#endif 95#endif
97 96
@@ -257,10 +256,10 @@ static int itm_read_data(unsigned char *pkt, int *x, int *y, int *touch, int *pr
257{ 256{
258 *x = ((pkt[0] & 0x1F) << 7) | (pkt[3] & 0x7F); 257 *x = ((pkt[0] & 0x1F) << 7) | (pkt[3] & 0x7F);
259 *y = ((pkt[1] & 0x1F) << 7) | (pkt[4] & 0x7F); 258 *y = ((pkt[1] & 0x1F) << 7) | (pkt[4] & 0x7F);
260 *press = ((pkt[2] & 0x1F) << 7) | (pkt[5] & 0x7F); 259 *press = ((pkt[2] & 0x01) << 7) | (pkt[5] & 0x7F);
261 *touch = ~pkt[7] & 0x20; 260 *touch = ~pkt[7] & 0x20;
262 261
263 return 1; 262 return *touch;
264} 263}
265#endif 264#endif
266 265
@@ -397,7 +396,7 @@ static struct usbtouch_device_info usbtouch_dev_info[] = {
397 * Generic Part 396 * Generic Part
398 */ 397 */
399static void usbtouch_process_pkt(struct usbtouch_usb *usbtouch, 398static void usbtouch_process_pkt(struct usbtouch_usb *usbtouch,
400 struct pt_regs *regs, unsigned char *pkt, int len) 399 unsigned char *pkt, int len)
401{ 400{
402 int x, y, touch, press; 401 int x, y, touch, press;
403 struct usbtouch_device_info *type = usbtouch->type; 402 struct usbtouch_device_info *type = usbtouch->type;
@@ -405,7 +404,6 @@ static void usbtouch_process_pkt(struct usbtouch_usb *usbtouch,
405 if (!type->read_data(pkt, &x, &y, &touch, &press)) 404 if (!type->read_data(pkt, &x, &y, &touch, &press))
406 return; 405 return;
407 406
408 input_regs(usbtouch->input, regs);
409 input_report_key(usbtouch->input, BTN_TOUCH, touch); 407 input_report_key(usbtouch->input, BTN_TOUCH, touch);
410 408
411 if (swap_xy) { 409 if (swap_xy) {
@@ -423,7 +421,6 @@ static void usbtouch_process_pkt(struct usbtouch_usb *usbtouch,
423 421
424#ifdef MULTI_PACKET 422#ifdef MULTI_PACKET
425static void usbtouch_process_multi(struct usbtouch_usb *usbtouch, 423static void usbtouch_process_multi(struct usbtouch_usb *usbtouch,
426 struct pt_regs *regs,
427 unsigned char *pkt, int len) 424 unsigned char *pkt, int len)
428{ 425{
429 unsigned char *buffer; 426 unsigned char *buffer;
@@ -460,7 +457,7 @@ static void usbtouch_process_multi(struct usbtouch_usb *usbtouch,
460 if (usbtouch->buf_len + tmp >= usbtouch->type->rept_size) 457 if (usbtouch->buf_len + tmp >= usbtouch->type->rept_size)
461 goto out_flush_buf; 458 goto out_flush_buf;
462 memcpy(usbtouch->buffer + usbtouch->buf_len, pkt, tmp); 459 memcpy(usbtouch->buffer + usbtouch->buf_len, pkt, tmp);
463 usbtouch_process_pkt(usbtouch, regs, usbtouch->buffer, pkt_len); 460 usbtouch_process_pkt(usbtouch, usbtouch->buffer, pkt_len);
464 461
465 buffer = pkt + tmp; 462 buffer = pkt + tmp;
466 buf_len = len - tmp; 463 buf_len = len - tmp;
@@ -481,7 +478,7 @@ static void usbtouch_process_multi(struct usbtouch_usb *usbtouch,
481 478
482 /* full packet: process */ 479 /* full packet: process */
483 if (likely((pkt_len > 0) && (pkt_len <= buf_len - pos))) { 480 if (likely((pkt_len > 0) && (pkt_len <= buf_len - pos))) {
484 usbtouch_process_pkt(usbtouch, regs, buffer + pos, pkt_len); 481 usbtouch_process_pkt(usbtouch, buffer + pos, pkt_len);
485 } else { 482 } else {
486 /* incomplete packet: save in buffer */ 483 /* incomplete packet: save in buffer */
487 memcpy(usbtouch->buffer, buffer + pos, buf_len - pos); 484 memcpy(usbtouch->buffer, buffer + pos, buf_len - pos);
@@ -498,7 +495,7 @@ out_flush_buf:
498#endif 495#endif
499 496
500 497
501static void usbtouch_irq(struct urb *urb, struct pt_regs *regs) 498static void usbtouch_irq(struct urb *urb)
502{ 499{
503 struct usbtouch_usb *usbtouch = urb->context; 500 struct usbtouch_usb *usbtouch = urb->context;
504 int retval; 501 int retval;
@@ -525,7 +522,7 @@ static void usbtouch_irq(struct urb *urb, struct pt_regs *regs)
525 goto exit; 522 goto exit;
526 } 523 }
527 524
528 usbtouch->type->process_pkt(usbtouch, regs, usbtouch->data, urb->actual_length); 525 usbtouch->type->process_pkt(usbtouch, usbtouch->data, urb->actual_length);
529 526
530exit: 527exit:
531 retval = usb_submit_urb(urb, GFP_ATOMIC); 528 retval = usb_submit_urb(urb, GFP_ATOMIC);
@@ -643,7 +640,7 @@ static int usbtouch_probe(struct usb_interface *intf,
643 type->max_press, 0, 0); 640 type->max_press, 0, 0);
644 641
645 usb_fill_int_urb(usbtouch->irq, usbtouch->udev, 642 usb_fill_int_urb(usbtouch->irq, usbtouch->udev,
646 usb_rcvintpipe(usbtouch->udev, 0x81), 643 usb_rcvintpipe(usbtouch->udev, endpoint->bEndpointAddress),
647 usbtouch->data, type->rept_size, 644 usbtouch->data, type->rept_size,
648 usbtouch_irq, usbtouch, endpoint->bInterval); 645 usbtouch_irq, usbtouch, endpoint->bInterval);
649 646
diff --git a/drivers/usb/input/wacom.h b/drivers/usb/input/wacom.h
index 832737b658cf..1cf08f02c50e 100644
--- a/drivers/usb/input/wacom.h
+++ b/drivers/usb/input/wacom.h
@@ -63,6 +63,7 @@
63 * v1.46 (pc) - Split wacom.c into wacom_sys.c and wacom_wac.c, 63 * v1.46 (pc) - Split wacom.c into wacom_sys.c and wacom_wac.c,
64 * - where wacom_sys.c deals with system specific code, 64 * - where wacom_sys.c deals with system specific code,
65 * - and wacom_wac.c deals with Wacom specific code 65 * - and wacom_wac.c deals with Wacom specific code
66 * - Support Intuos3 4x6
66 */ 67 */
67 68
68/* 69/*
@@ -106,20 +107,19 @@ struct wacom {
106struct wacom_combo { 107struct wacom_combo {
107 struct wacom * wacom; 108 struct wacom * wacom;
108 struct urb * urb; 109 struct urb * urb;
109 struct pt_regs *regs;
110}; 110};
111 111
112extern int wacom_wac_irq(struct wacom_wac * wacom_wac, void * wcombo); 112extern int wacom_wac_irq(struct wacom_wac * wacom_wac, void * wcombo);
113extern void wacom_sys_irq(struct urb *urb, struct pt_regs *regs); 113extern void wacom_sys_irq(struct urb *urb);
114extern void wacom_report_abs(void *wcombo, unsigned int abs_type, int abs_data); 114extern void wacom_report_abs(void *wcombo, unsigned int abs_type, int abs_data);
115extern void wacom_report_rel(void *wcombo, unsigned int rel_type, int rel_data); 115extern void wacom_report_rel(void *wcombo, unsigned int rel_type, int rel_data);
116extern void wacom_report_key(void *wcombo, unsigned int key_type, int key_data); 116extern void wacom_report_key(void *wcombo, unsigned int key_type, int key_data);
117extern void wacom_input_event(void *wcombo, unsigned int type, unsigned int code, int value); 117extern void wacom_input_event(void *wcombo, unsigned int type, unsigned int code, int value);
118extern void wacom_input_regs(void *wcombo);
119extern void wacom_input_sync(void *wcombo); 118extern void wacom_input_sync(void *wcombo);
120extern void wacom_init_input_dev(struct input_dev *input_dev, struct wacom_wac *wacom_wac); 119extern void wacom_init_input_dev(struct input_dev *input_dev, struct wacom_wac *wacom_wac);
121extern void input_dev_g4(struct input_dev *input_dev, struct wacom_wac *wacom_wac); 120extern void input_dev_g4(struct input_dev *input_dev, struct wacom_wac *wacom_wac);
122extern void input_dev_g(struct input_dev *input_dev, struct wacom_wac *wacom_wac); 121extern void input_dev_g(struct input_dev *input_dev, struct wacom_wac *wacom_wac);
122extern void input_dev_i3s(struct input_dev *input_dev, struct wacom_wac *wacom_wac);
123extern void input_dev_i3(struct input_dev *input_dev, struct wacom_wac *wacom_wac); 123extern void input_dev_i3(struct input_dev *input_dev, struct wacom_wac *wacom_wac);
124extern void input_dev_i(struct input_dev *input_dev, struct wacom_wac *wacom_wac); 124extern void input_dev_i(struct input_dev *input_dev, struct wacom_wac *wacom_wac);
125extern void input_dev_pl(struct input_dev *input_dev, struct wacom_wac *wacom_wac); 125extern void input_dev_pl(struct input_dev *input_dev, struct wacom_wac *wacom_wac);
diff --git a/drivers/usb/input/wacom_sys.c b/drivers/usb/input/wacom_sys.c
index 7c3b52bdd9d6..3498b893b53b 100644
--- a/drivers/usb/input/wacom_sys.c
+++ b/drivers/usb/input/wacom_sys.c
@@ -42,7 +42,7 @@ static struct input_dev * get_input_dev(struct wacom_combo *wcombo)
42 return wcombo->wacom->dev; 42 return wcombo->wacom->dev;
43} 43}
44 44
45void wacom_sys_irq(struct urb *urb, struct pt_regs *regs) 45void wacom_sys_irq(struct urb *urb)
46{ 46{
47 struct wacom *wacom = urb->context; 47 struct wacom *wacom = urb->context;
48 struct wacom_combo wcombo; 48 struct wacom_combo wcombo;
@@ -65,7 +65,6 @@ void wacom_sys_irq(struct urb *urb, struct pt_regs *regs)
65 65
66 wcombo.wacom = wacom; 66 wcombo.wacom = wacom;
67 wcombo.urb = urb; 67 wcombo.urb = urb;
68 wcombo.regs = regs;
69 68
70 if (wacom_wac_irq(wacom->wacom_wac, (void *)&wcombo)) 69 if (wacom_wac_irq(wacom->wacom_wac, (void *)&wcombo))
71 input_sync(get_input_dev(&wcombo)); 70 input_sync(get_input_dev(&wcombo));
@@ -111,16 +110,10 @@ __u16 wacom_be16_to_cpu(unsigned char *data)
111__u16 wacom_le16_to_cpu(unsigned char *data) 110__u16 wacom_le16_to_cpu(unsigned char *data)
112{ 111{
113 __u16 value; 112 __u16 value;
114 value = be16_to_cpu(*(__be16 *) data); 113 value = le16_to_cpu(*(__le16 *) data);
115 return value; 114 return value;
116} 115}
117 116
118void wacom_input_regs(void *wcombo)
119{
120 input_regs(get_input_dev((struct wacom_combo *)wcombo), ((struct wacom_combo *)wcombo)->regs);
121 return;
122}
123
124void wacom_input_sync(void *wcombo) 117void wacom_input_sync(void *wcombo)
125{ 118{
126 input_sync(get_input_dev((struct wacom_combo *)wcombo)); 119 input_sync(get_input_dev((struct wacom_combo *)wcombo));
@@ -150,7 +143,7 @@ void input_dev_g4(struct input_dev *input_dev, struct wacom_wac *wacom_wac)
150 input_dev->evbit[0] |= BIT(EV_MSC); 143 input_dev->evbit[0] |= BIT(EV_MSC);
151 input_dev->mscbit[0] |= BIT(MSC_SERIAL); 144 input_dev->mscbit[0] |= BIT(MSC_SERIAL);
152 input_dev->keybit[LONG(BTN_DIGI)] |= BIT(BTN_TOOL_FINGER); 145 input_dev->keybit[LONG(BTN_DIGI)] |= BIT(BTN_TOOL_FINGER);
153 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); 146 input_dev->keybit[LONG(BTN_LEFT)] |= BIT(BTN_0) | BIT(BTN_4);
154} 147}
155 148
156void input_dev_g(struct input_dev *input_dev, struct wacom_wac *wacom_wac) 149void input_dev_g(struct input_dev *input_dev, struct wacom_wac *wacom_wac)
@@ -162,11 +155,16 @@ void input_dev_g(struct input_dev *input_dev, struct wacom_wac *wacom_wac)
162 input_set_abs_params(input_dev, ABS_DISTANCE, 0, wacom_wac->features->distance_max, 0, 0); 155 input_set_abs_params(input_dev, ABS_DISTANCE, 0, wacom_wac->features->distance_max, 0, 0);
163} 156}
164 157
165void input_dev_i3(struct input_dev *input_dev, struct wacom_wac *wacom_wac) 158void input_dev_i3s(struct input_dev *input_dev, struct wacom_wac *wacom_wac)
166{ 159{
167 input_dev->keybit[LONG(BTN_DIGI)] |= BIT(BTN_TOOL_FINGER); 160 input_dev->keybit[LONG(BTN_DIGI)] |= BIT(BTN_TOOL_FINGER);
168 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); 161 input_dev->keybit[LONG(BTN_LEFT)] |= BIT(BTN_0) | BIT(BTN_1) | BIT(BTN_2) | BIT(BTN_3);
169 input_set_abs_params(input_dev, ABS_RX, 0, 4097, 0, 0); 162 input_set_abs_params(input_dev, ABS_RX, 0, 4097, 0, 0);
163}
164
165void input_dev_i3(struct input_dev *input_dev, struct wacom_wac *wacom_wac)
166{
167 input_dev->keybit[LONG(BTN_LEFT)] |= BIT(BTN_4) | BIT(BTN_5) | BIT(BTN_6) | BIT(BTN_7);
170 input_set_abs_params(input_dev, ABS_RY, 0, 4097, 0, 0); 168 input_set_abs_params(input_dev, ABS_RY, 0, 4097, 0, 0);
171} 169}
172 170
@@ -225,8 +223,7 @@ static int wacom_probe(struct usb_interface *intf, const struct usb_device_id *i
225 strlcat(wacom->phys, "/input0", sizeof(wacom->phys)); 223 strlcat(wacom->phys, "/input0", sizeof(wacom->phys));
226 224
227 wacom_wac->features = get_wacom_feature(id); 225 wacom_wac->features = get_wacom_feature(id);
228 if (wacom_wac->features->pktlen > 10) 226 BUG_ON(wacom_wac->features->pktlen > 10);
229 BUG();
230 227
231 input_dev->name = wacom_wac->features->name; 228 input_dev->name = wacom_wac->features->name;
232 wacom->wacom_wac = wacom_wac; 229 wacom->wacom_wac = wacom_wac;
@@ -251,7 +248,7 @@ static int wacom_probe(struct usb_interface *intf, const struct usb_device_id *i
251 usb_fill_int_urb(wacom->irq, dev, 248 usb_fill_int_urb(wacom->irq, dev,
252 usb_rcvintpipe(dev, endpoint->bEndpointAddress), 249 usb_rcvintpipe(dev, endpoint->bEndpointAddress),
253 wacom_wac->data, wacom_wac->features->pktlen, 250 wacom_wac->data, wacom_wac->features->pktlen,
254 wacom_wac->features->irq, wacom, endpoint->bInterval); 251 wacom_sys_irq, wacom, endpoint->bInterval);
255 wacom->irq->transfer_dma = wacom->data_dma; 252 wacom->irq->transfer_dma = wacom->data_dma;
256 wacom->irq->transfer_flags |= URB_NO_TRANSFER_DMA_MAP; 253 wacom->irq->transfer_flags |= URB_NO_TRANSFER_DMA_MAP;
257 254
@@ -285,8 +282,8 @@ static void wacom_disconnect(struct usb_interface *intf)
285 input_unregister_device(wacom->dev); 282 input_unregister_device(wacom->dev);
286 usb_free_urb(wacom->irq); 283 usb_free_urb(wacom->irq);
287 usb_buffer_free(interface_to_usbdev(intf), 10, wacom->wacom_wac->data, wacom->data_dma); 284 usb_buffer_free(interface_to_usbdev(intf), 10, wacom->wacom_wac->data, wacom->data_dma);
288 kfree(wacom);
289 kfree(wacom->wacom_wac); 285 kfree(wacom->wacom_wac);
286 kfree(wacom);
290 } 287 }
291} 288}
292 289
diff --git a/drivers/usb/input/wacom_wac.c b/drivers/usb/input/wacom_wac.c
index 85d458c98b6e..92726fe89379 100644
--- a/drivers/usb/input/wacom_wac.c
+++ b/drivers/usb/input/wacom_wac.c
@@ -20,7 +20,6 @@ static int wacom_penpartner_irq(struct wacom_wac *wacom, void *wcombo)
20 20
21 switch (data[0]) { 21 switch (data[0]) {
22 case 1: 22 case 1:
23 wacom_input_regs(wcombo);
24 if (data[5] & 0x80) { 23 if (data[5] & 0x80) {
25 wacom->tool[0] = (data[5] & 0x20) ? BTN_TOOL_RUBBER : BTN_TOOL_PEN; 24 wacom->tool[0] = (data[5] & 0x20) ? BTN_TOOL_RUBBER : BTN_TOOL_PEN;
26 wacom->id[0] = (data[5] & 0x20) ? ERASER_DEVICE_ID : STYLUS_DEVICE_ID; 25 wacom->id[0] = (data[5] & 0x20) ? ERASER_DEVICE_ID : STYLUS_DEVICE_ID;
@@ -39,7 +38,6 @@ static int wacom_penpartner_irq(struct wacom_wac *wacom, void *wcombo)
39 } 38 }
40 break; 39 break;
41 case 2: 40 case 2:
42 wacom_input_regs(wcombo);
43 wacom_report_key(wcombo, BTN_TOOL_PEN, 1); 41 wacom_report_key(wcombo, BTN_TOOL_PEN, 1);
44 wacom_report_abs(wcombo, ABS_MISC, STYLUS_DEVICE_ID); /* report tool id */ 42 wacom_report_abs(wcombo, ABS_MISC, STYLUS_DEVICE_ID); /* report tool id */
45 wacom_report_abs(wcombo, ABS_X, wacom_le16_to_cpu(&data[1])); 43 wacom_report_abs(wcombo, ABS_X, wacom_le16_to_cpu(&data[1]));
@@ -67,8 +65,6 @@ static int wacom_pl_irq(struct wacom_wac *wacom, void *wcombo)
67 65
68 prox = data[1] & 0x40; 66 prox = data[1] & 0x40;
69 67
70 wacom_input_regs(wcombo);
71
72 id = ERASER_DEVICE_ID; 68 id = ERASER_DEVICE_ID;
73 if (prox) { 69 if (prox) {
74 70
@@ -138,7 +134,6 @@ static int wacom_ptu_irq(struct wacom_wac *wacom, void *wcombo)
138 return 0; 134 return 0;
139 } 135 }
140 136
141 wacom_input_regs(wcombo);
142 if (data[1] & 0x04) { 137 if (data[1] & 0x04) {
143 wacom_report_key(wcombo, BTN_TOOL_RUBBER, data[1] & 0x20); 138 wacom_report_key(wcombo, BTN_TOOL_RUBBER, data[1] & 0x20);
144 wacom_report_key(wcombo, BTN_TOUCH, data[1] & 0x08); 139 wacom_report_key(wcombo, BTN_TOUCH, data[1] & 0x08);
@@ -167,8 +162,6 @@ static int wacom_graphire_irq(struct wacom_wac *wacom, void *wcombo)
167 return 0; 162 return 0;
168 } 163 }
169 164
170 wacom_input_regs(wcombo);
171
172 id = STYLUS_DEVICE_ID; 165 id = STYLUS_DEVICE_ID;
173 if (data[1] & 0x10) { /* in prox */ 166 if (data[1] & 0x10) { /* in prox */
174 167
@@ -198,9 +191,9 @@ static int wacom_graphire_irq(struct wacom_wac *wacom, void *wcombo)
198 wacom_report_key(wcombo, BTN_LEFT, data[1] & 0x01); 191 wacom_report_key(wcombo, BTN_LEFT, data[1] & 0x01);
199 wacom_report_key(wcombo, BTN_RIGHT, data[1] & 0x02); 192 wacom_report_key(wcombo, BTN_RIGHT, data[1] & 0x02);
200 if (wacom->features->type == WACOM_G4) 193 if (wacom->features->type == WACOM_G4)
201 wacom_report_abs(wcombo, ABS_DISTANCE, data[6]); 194 wacom_report_abs(wcombo, ABS_DISTANCE, data[6] & 0x3f);
202 else 195 else
203 wacom_report_abs(wcombo, ABS_DISTANCE, data[7]); 196 wacom_report_abs(wcombo, ABS_DISTANCE, data[7] & 0x3f);
204 break; 197 break;
205 } 198 }
206 } 199 }
@@ -310,8 +303,9 @@ static int wacom_intuos_inout(struct wacom_wac *wacom, void *wcombo)
310 wacom->tool[idx] = BTN_TOOL_PEN; 303 wacom->tool[idx] = BTN_TOOL_PEN;
311 } 304 }
312 /* only large I3 support Lens Cursor */ 305 /* only large I3 support Lens Cursor */
313 if(!((wacom->tool[idx] == BTN_TOOL_LENS) && 306 if(!((wacom->tool[idx] == BTN_TOOL_LENS)
314 (wacom->features->type == INTUOS3))) { 307 && ((wacom->features->type == INTUOS3)
308 || (wacom->features->type == INTUOS3S)))) {
315 wacom_report_abs(wcombo, ABS_MISC, wacom->id[idx]); /* report tool id */ 309 wacom_report_abs(wcombo, ABS_MISC, wacom->id[idx]); /* report tool id */
316 wacom_report_key(wcombo, wacom->tool[idx], 1); 310 wacom_report_key(wcombo, wacom->tool[idx], 1);
317 wacom_input_event(wcombo, EV_MSC, MSC_SERIAL, wacom->serial[idx]); 311 wacom_input_event(wcombo, EV_MSC, MSC_SERIAL, wacom->serial[idx]);
@@ -322,10 +316,14 @@ static int wacom_intuos_inout(struct wacom_wac *wacom, void *wcombo)
322 316
323 /* Exit report */ 317 /* Exit report */
324 if ((data[1] & 0xfe) == 0x80) { 318 if ((data[1] & 0xfe) == 0x80) {
325 wacom_report_key(wcombo, wacom->tool[idx], 0); 319 if(!((wacom->tool[idx] == BTN_TOOL_LENS)
326 wacom_report_abs(wcombo, ABS_MISC, 0); /* reset tool id */ 320 && ((wacom->features->type == INTUOS3)
327 wacom_input_event(wcombo, EV_MSC, MSC_SERIAL, wacom->serial[idx]); 321 || (wacom->features->type == INTUOS3S)))) {
328 return 2; 322 wacom_report_key(wcombo, wacom->tool[idx], 0);
323 wacom_report_abs(wcombo, ABS_MISC, 0); /* reset tool id */
324 wacom_input_event(wcombo, EV_MSC, MSC_SERIAL, wacom->serial[idx]);
325 return 2;
326 }
329 } 327 }
330 return 0; 328 return 0;
331} 329}
@@ -369,8 +367,6 @@ static int wacom_intuos_irq(struct wacom_wac *wacom, void *wcombo)
369 return 0; 367 return 0;
370 } 368 }
371 369
372 wacom_input_regs(wcombo);
373
374 /* tool number */ 370 /* tool number */
375 idx = data[1] & 0x01; 371 idx = data[1] & 0x01;
376 372
@@ -391,7 +387,8 @@ static int wacom_intuos_irq(struct wacom_wac *wacom, void *wcombo)
391 wacom_report_abs(wcombo, ABS_RX, ((data[1] & 0x1f) << 8) | data[2]); 387 wacom_report_abs(wcombo, ABS_RX, ((data[1] & 0x1f) << 8) | data[2]);
392 wacom_report_abs(wcombo, ABS_RY, ((data[3] & 0x1f) << 8) | data[4]); 388 wacom_report_abs(wcombo, ABS_RY, ((data[3] & 0x1f) << 8) | data[4]);
393 389
394 if((data[5] & 0x0f) | (data[6] & 0x0f) | (data[1] & 0x1f) | data[2]) 390 if((data[5] & 0x0f) | (data[6] & 0x0f) | (data[1] & 0x1f) |
391 data[2] | (data[3] & 0x1f) | data[4])
395 wacom_report_key(wcombo, wacom->tool[1], 1); 392 wacom_report_key(wcombo, wacom->tool[1], 1);
396 else 393 else
397 wacom_report_key(wcombo, wacom->tool[1], 0); 394 wacom_report_key(wcombo, wacom->tool[1], 0);
@@ -441,7 +438,7 @@ static int wacom_intuos_irq(struct wacom_wac *wacom, void *wcombo)
441 ((t - 1) / 2) : -t / 2); 438 ((t - 1) / 2) : -t / 2);
442 } 439 }
443 440
444 } else if (!(data[1] & 0x10) && wacom->features->type < INTUOS3) { 441 } else if (!(data[1] & 0x10) && wacom->features->type < INTUOS3S) {
445 /* 4D mouse packet */ 442 /* 4D mouse packet */
446 wacom_report_key(wcombo, BTN_LEFT, data[8] & 0x01); 443 wacom_report_key(wcombo, BTN_LEFT, data[8] & 0x01);
447 wacom_report_key(wcombo, BTN_MIDDLE, data[8] & 0x02); 444 wacom_report_key(wcombo, BTN_MIDDLE, data[8] & 0x02);
@@ -461,12 +458,12 @@ static int wacom_intuos_irq(struct wacom_wac *wacom, void *wcombo)
461 - ((data[8] & 0x02) >> 1)); 458 - ((data[8] & 0x02) >> 1));
462 459
463 /* I3 2D mouse side buttons */ 460 /* I3 2D mouse side buttons */
464 if (wacom->features->type == INTUOS3) { 461 if (wacom->features->type >= INTUOS3S && wacom->features->type <= INTUOS3L) {
465 wacom_report_key(wcombo, BTN_SIDE, data[8] & 0x40); 462 wacom_report_key(wcombo, BTN_SIDE, data[8] & 0x40);
466 wacom_report_key(wcombo, BTN_EXTRA, data[8] & 0x20); 463 wacom_report_key(wcombo, BTN_EXTRA, data[8] & 0x20);
467 } 464 }
468 465
469 } else if (wacom->features->type < INTUOS3) { 466 } else if (wacom->features->type < INTUOS3S || wacom->features->type == INTUOS3L) {
470 /* Lens cursor packets */ 467 /* Lens cursor packets */
471 wacom_report_key(wcombo, BTN_LEFT, data[8] & 0x01); 468 wacom_report_key(wcombo, BTN_LEFT, data[8] & 0x01);
472 wacom_report_key(wcombo, BTN_MIDDLE, data[8] & 0x02); 469 wacom_report_key(wcombo, BTN_MIDDLE, data[8] & 0x02);
@@ -499,6 +496,7 @@ int wacom_wac_irq(struct wacom_wac *wacom_wac, void *wcombo)
499 return (wacom_ptu_irq(wacom_wac, wcombo)); 496 return (wacom_ptu_irq(wacom_wac, wcombo));
500 break; 497 break;
501 case INTUOS: 498 case INTUOS:
499 case INTUOS3S:
502 case INTUOS3: 500 case INTUOS3:
503 case INTUOS3L: 501 case INTUOS3L:
504 case CINTIQ: 502 case CINTIQ:
@@ -524,6 +522,8 @@ void wacom_init_input_dev(struct input_dev *input_dev, struct wacom_wac *wacom_w
524 case CINTIQ: 522 case CINTIQ:
525 input_dev_i3(input_dev, wacom_wac); 523 input_dev_i3(input_dev, wacom_wac);
526 /* fall through */ 524 /* fall through */
525 case INTUOS3S:
526 input_dev_i3s(input_dev, wacom_wac);
527 case INTUOS: 527 case INTUOS:
528 input_dev_i(input_dev, wacom_wac); 528 input_dev_i(input_dev, wacom_wac);
529 break; 529 break;
@@ -539,49 +539,50 @@ void wacom_init_input_dev(struct input_dev *input_dev, struct wacom_wac *wacom_w
539} 539}
540 540
541static struct wacom_features wacom_features[] = { 541static struct wacom_features wacom_features[] = {
542 { "Wacom Penpartner", 7, 5040, 3780, 255, 32, PENPARTNER, wacom_sys_irq }, 542 { "Wacom Penpartner", 7, 5040, 3780, 255, 0, PENPARTNER },
543 { "Wacom Graphire", 8, 10206, 7422, 511, 32, GRAPHIRE, wacom_sys_irq }, 543 { "Wacom Graphire", 8, 10206, 7422, 511, 63, GRAPHIRE },
544 { "Wacom Graphire2 4x5", 8, 10206, 7422, 511, 32, GRAPHIRE, wacom_sys_irq }, 544 { "Wacom Graphire2 4x5", 8, 10206, 7422, 511, 63, GRAPHIRE },
545 { "Wacom Graphire2 5x7", 8, 13918, 10206, 511, 32, GRAPHIRE, wacom_sys_irq }, 545 { "Wacom Graphire2 5x7", 8, 13918, 10206, 511, 63, GRAPHIRE },
546 { "Wacom Graphire3", 8, 10208, 7424, 511, 32, GRAPHIRE, wacom_sys_irq }, 546 { "Wacom Graphire3", 8, 10208, 7424, 511, 63, GRAPHIRE },
547 { "Wacom Graphire3 6x8", 8, 16704, 12064, 511, 32, GRAPHIRE, wacom_sys_irq }, 547 { "Wacom Graphire3 6x8", 8, 16704, 12064, 511, 63, GRAPHIRE },
548 { "Wacom Graphire4 4x5", 8, 10208, 7424, 511, 32, WACOM_G4, wacom_sys_irq }, 548 { "Wacom Graphire4 4x5", 8, 10208, 7424, 511, 63, WACOM_G4 },
549 { "Wacom Graphire4 6x8", 8, 16704, 12064, 511, 32, WACOM_G4, wacom_sys_irq }, 549 { "Wacom Graphire4 6x8", 8, 16704, 12064, 511, 63, WACOM_G4 },
550 { "Wacom Volito", 8, 5104, 3712, 511, 32, GRAPHIRE, wacom_sys_irq }, 550 { "Wacom Volito", 8, 5104, 3712, 511, 0, GRAPHIRE },
551 { "Wacom PenStation2", 8, 3250, 2320, 255, 32, GRAPHIRE, wacom_sys_irq }, 551 { "Wacom PenStation2", 8, 3250, 2320, 255, 0, GRAPHIRE },
552 { "Wacom Volito2 4x5", 8, 5104, 3712, 511, 32, GRAPHIRE, wacom_sys_irq }, 552 { "Wacom Volito2 4x5", 8, 5104, 3712, 511, 0, GRAPHIRE },
553 { "Wacom Volito2 2x3", 8, 3248, 2320, 511, 32, GRAPHIRE, wacom_sys_irq }, 553 { "Wacom Volito2 2x3", 8, 3248, 2320, 511, 0, GRAPHIRE },
554 { "Wacom PenPartner2", 8, 3250, 2320, 255, 32, GRAPHIRE, wacom_sys_irq }, 554 { "Wacom PenPartner2", 8, 3250, 2320, 255, 0, GRAPHIRE },
555 { "Wacom Intuos 4x5", 10, 12700, 10600, 1023, 15, INTUOS, wacom_sys_irq}, 555 { "Wacom Intuos 4x5", 10, 12700, 10600, 1023, 63, INTUOS },
556 { "Wacom Intuos 6x8", 10, 20320, 16240, 1023, 15, INTUOS, wacom_sys_irq }, 556 { "Wacom Intuos 6x8", 10, 20320, 16240, 1023, 63, INTUOS },
557 { "Wacom Intuos 9x12", 10, 30480, 24060, 1023, 15, INTUOS, wacom_sys_irq }, 557 { "Wacom Intuos 9x12", 10, 30480, 24060, 1023, 63, INTUOS },
558 { "Wacom Intuos 12x12", 10, 30480, 31680, 1023, 15, INTUOS, wacom_sys_irq }, 558 { "Wacom Intuos 12x12", 10, 30480, 31680, 1023, 63, INTUOS },
559 { "Wacom Intuos 12x18", 10, 45720, 31680, 1023, 15, INTUOS, wacom_sys_irq}, 559 { "Wacom Intuos 12x18", 10, 45720, 31680, 1023, 63, INTUOS },
560 { "Wacom PL400", 8, 5408, 4056, 255, 32, PL, wacom_sys_irq }, 560 { "Wacom PL400", 8, 5408, 4056, 255, 0, PL },
561 { "Wacom PL500", 8, 6144, 4608, 255, 32, PL, wacom_sys_irq }, 561 { "Wacom PL500", 8, 6144, 4608, 255, 0, PL },
562 { "Wacom PL600", 8, 6126, 4604, 255, 32, PL, wacom_sys_irq }, 562 { "Wacom PL600", 8, 6126, 4604, 255, 0, PL },
563 { "Wacom PL600SX", 8, 6260, 5016, 255, 32, PL, wacom_sys_irq }, 563 { "Wacom PL600SX", 8, 6260, 5016, 255, 0, PL },
564 { "Wacom PL550", 8, 6144, 4608, 511, 32, PL, wacom_sys_irq }, 564 { "Wacom PL550", 8, 6144, 4608, 511, 0, PL },
565 { "Wacom PL800", 8, 7220, 5780, 511, 32, PL, wacom_sys_irq }, 565 { "Wacom PL800", 8, 7220, 5780, 511, 0, PL },
566 { "Wacom PL700", 8, 6758, 5406, 511, 32, PL, wacom_sys_irq }, 566 { "Wacom PL700", 8, 6758, 5406, 511, 0, PL },
567 { "Wacom PL510", 8, 6282, 4762, 511, 32, PL, wacom_sys_irq }, 567 { "Wacom PL510", 8, 6282, 4762, 511, 0, PL },
568 { "Wacom DTU710", 8, 34080, 27660, 511, 32, PL, wacom_sys_irq }, 568 { "Wacom DTU710", 8, 34080, 27660, 511, 0, PL },
569 { "Wacom DTF521", 8, 6282, 4762, 511, 32, PL, wacom_sys_irq }, 569 { "Wacom DTF521", 8, 6282, 4762, 511, 0, PL },
570 { "Wacom DTF720", 8, 6858, 5506, 511, 32, PL, wacom_sys_irq }, 570 { "Wacom DTF720", 8, 6858, 5506, 511, 0, PL },
571 { "Wacom Cintiq Partner",8, 20480, 15360, 511, 32, PTU, wacom_sys_irq }, 571 { "Wacom Cintiq Partner",8, 20480, 15360, 511, 0, PTU },
572 { "Wacom Intuos2 4x5", 10, 12700, 10600, 1023, 15, INTUOS, wacom_sys_irq }, 572 { "Wacom Intuos2 4x5", 10, 12700, 10600, 1023, 63, INTUOS },
573 { "Wacom Intuos2 6x8", 10, 20320, 16240, 1023, 15, INTUOS, wacom_sys_irq }, 573 { "Wacom Intuos2 6x8", 10, 20320, 16240, 1023, 63, INTUOS },
574 { "Wacom Intuos2 9x12", 10, 30480, 24060, 1023, 15, INTUOS, wacom_sys_irq }, 574 { "Wacom Intuos2 9x12", 10, 30480, 24060, 1023, 63, INTUOS },
575 { "Wacom Intuos2 12x12", 10, 30480, 31680, 1023, 15, INTUOS, wacom_sys_irq }, 575 { "Wacom Intuos2 12x12", 10, 30480, 31680, 1023, 63, INTUOS },
576 { "Wacom Intuos2 12x18", 10, 45720, 31680, 1023, 15, INTUOS, wacom_sys_irq }, 576 { "Wacom Intuos2 12x18", 10, 45720, 31680, 1023, 63, INTUOS },
577 { "Wacom Intuos3 4x5", 10, 25400, 20320, 1023, 15, INTUOS3, wacom_sys_irq }, 577 { "Wacom Intuos3 4x5", 10, 25400, 20320, 1023, 63, INTUOS3S },
578 { "Wacom Intuos3 6x8", 10, 40640, 30480, 1023, 15, INTUOS3, wacom_sys_irq }, 578 { "Wacom Intuos3 6x8", 10, 40640, 30480, 1023, 63, INTUOS3 },
579 { "Wacom Intuos3 9x12", 10, 60960, 45720, 1023, 15, INTUOS3, wacom_sys_irq }, 579 { "Wacom Intuos3 9x12", 10, 60960, 45720, 1023, 63, INTUOS3 },
580 { "Wacom Intuos3 12x12", 10, 60960, 60960, 1023, 15, INTUOS3L, wacom_sys_irq }, 580 { "Wacom Intuos3 12x12", 10, 60960, 60960, 1023, 63, INTUOS3L },
581 { "Wacom Intuos3 12x19", 10, 97536, 60960, 1023, 15, INTUOS3L, wacom_sys_irq }, 581 { "Wacom Intuos3 12x19", 10, 97536, 60960, 1023, 63, INTUOS3L },
582 { "Wacom Intuos3 6x11", 10, 54204, 31750, 1023, 15, INTUOS3, wacom_sys_irq }, 582 { "Wacom Intuos3 6x11", 10, 54204, 31750, 1023, 63, INTUOS3 },
583 { "Wacom Cintiq 21UX", 10, 87200, 65600, 1023, 15, CINTIQ, wacom_sys_irq }, 583 { "Wacom Intuos3 4x6", 10, 31496, 19685, 1023, 15, INTUOS3S },
584 { "Wacom Intuos2 6x8", 10, 20320, 16240, 1023, 15, INTUOS, wacom_sys_irq }, 584 { "Wacom Cintiq 21UX", 10, 87200, 65600, 1023, 63, CINTIQ },
585 { "Wacom Intuos2 6x8", 10, 20320, 16240, 1023, 63, INTUOS },
585 { } 586 { }
586}; 587};
587 588
@@ -627,6 +628,7 @@ static struct usb_device_id wacom_ids[] = {
627 { USB_DEVICE(USB_VENDOR_ID_WACOM, 0xB3) }, 628 { USB_DEVICE(USB_VENDOR_ID_WACOM, 0xB3) },
628 { USB_DEVICE(USB_VENDOR_ID_WACOM, 0xB4) }, 629 { USB_DEVICE(USB_VENDOR_ID_WACOM, 0xB4) },
629 { USB_DEVICE(USB_VENDOR_ID_WACOM, 0xB5) }, 630 { USB_DEVICE(USB_VENDOR_ID_WACOM, 0xB5) },
631 { USB_DEVICE(USB_VENDOR_ID_WACOM, 0xB7) },
630 { USB_DEVICE(USB_VENDOR_ID_WACOM, 0x3F) }, 632 { USB_DEVICE(USB_VENDOR_ID_WACOM, 0x3F) },
631 { USB_DEVICE(USB_VENDOR_ID_WACOM, 0x47) }, 633 { USB_DEVICE(USB_VENDOR_ID_WACOM, 0x47) },
632 { } 634 { }
diff --git a/drivers/usb/input/wacom_wac.h b/drivers/usb/input/wacom_wac.h
index ceae7bf59d9f..a1d9ce007970 100644
--- a/drivers/usb/input/wacom_wac.h
+++ b/drivers/usb/input/wacom_wac.h
@@ -20,6 +20,7 @@ enum {
20 PTU, 20 PTU,
21 PL, 21 PL,
22 INTUOS, 22 INTUOS,
23 INTUOS3S,
23 INTUOS3, 24 INTUOS3,
24 INTUOS3L, 25 INTUOS3L,
25 CINTIQ, 26 CINTIQ,
@@ -34,7 +35,6 @@ struct wacom_features {
34 int pressure_max; 35 int pressure_max;
35 int distance_max; 36 int distance_max;
36 int type; 37 int type;
37 usb_complete_t irq;
38}; 38};
39 39
40struct wacom_wac { 40struct wacom_wac {
diff --git a/drivers/usb/input/xpad.c b/drivers/usb/input/xpad.c
index 9889b1cda05b..df97e5c803f9 100644
--- a/drivers/usb/input/xpad.c
+++ b/drivers/usb/input/xpad.c
@@ -1,8 +1,13 @@
1/* 1/*
2 * X-Box gamepad - v0.0.5 2 * X-Box gamepad - v0.0.6
3 * 3 *
4 * Copyright (c) 2002 Marko Friedemann <mfr@bmx-chemnitz.de> 4 * Copyright (c) 2002 Marko Friedemann <mfr@bmx-chemnitz.de>
5 * 5 * 2004 Oliver Schwartz <Oliver.Schwartz@gmx.de>,
6 * Steven Toth <steve@toth.demon.co.uk>,
7 * Franz Lehner <franz@caos.at>,
8 * Ivan Hawkes <blackhawk@ivanhawkes.com>
9 * 2005 Dominic Cerquetti <binary1230@yahoo.com>
10 * 2006 Adam Buchbinder <adam.buchbinder@gmail.com>
6 * 11 *
7 * This program is free software; you can redistribute it and/or 12 * This program is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU General Public License as 13 * modify it under the terms of the GNU General Public License as
@@ -28,11 +33,13 @@
28 * - ITO Takayuki for providing essential xpad information on his website 33 * - ITO Takayuki for providing essential xpad information on his website
29 * - Vojtech Pavlik - iforce driver / input subsystem 34 * - Vojtech Pavlik - iforce driver / input subsystem
30 * - Greg Kroah-Hartman - usb-skeleton driver 35 * - Greg Kroah-Hartman - usb-skeleton driver
36 * - XBOX Linux project - extra USB id's
31 * 37 *
32 * TODO: 38 * TODO:
33 * - fine tune axes 39 * - fine tune axes (especially trigger axes)
34 * - fix "analog" buttons (reported as digital now) 40 * - fix "analog" buttons (reported as digital now)
35 * - get rumble working 41 * - get rumble working
42 * - need USB IDs for other dance pads
36 * 43 *
37 * History: 44 * History:
38 * 45 *
@@ -52,30 +59,79 @@
52 * - fixed d-pad to axes mapping 59 * - fixed d-pad to axes mapping
53 * 60 *
54 * 2002-07-17 - 0.0.5 : simplified d-pad handling 61 * 2002-07-17 - 0.0.5 : simplified d-pad handling
62 *
63 * 2004-10-02 - 0.0.6 : DDR pad support
64 * - borrowed from the XBOX linux kernel
65 * - USB id's for commonly used dance pads are present
66 * - dance pads will map D-PAD to buttons, not axes
67 * - pass the module paramater 'dpad_to_buttons' to force
68 * the D-PAD to map to buttons if your pad is not detected
55 */ 69 */
56 70
57#include <linux/kernel.h> 71#include <linux/kernel.h>
58#include <linux/init.h> 72#include <linux/init.h>
59#include <linux/slab.h> 73#include <linux/slab.h>
74#include <linux/stat.h>
60#include <linux/module.h> 75#include <linux/module.h>
76#include <linux/moduleparam.h>
61#include <linux/smp_lock.h> 77#include <linux/smp_lock.h>
62#include <linux/usb/input.h> 78#include <linux/usb/input.h>
63 79
64#define DRIVER_VERSION "v0.0.5" 80#define DRIVER_VERSION "v0.0.6"
65#define DRIVER_AUTHOR "Marko Friedemann <mfr@bmx-chemnitz.de>" 81#define DRIVER_AUTHOR "Marko Friedemann <mfr@bmx-chemnitz.de>"
66#define DRIVER_DESC "X-Box pad driver" 82#define DRIVER_DESC "X-Box pad driver"
67 83
68#define XPAD_PKT_LEN 32 84#define XPAD_PKT_LEN 32
69 85
86/* xbox d-pads should map to buttons, as is required for DDR pads
87 but we map them to axes when possible to simplify things */
88#define MAP_DPAD_TO_BUTTONS 0
89#define MAP_DPAD_TO_AXES 1
90#define MAP_DPAD_UNKNOWN -1
91
92static int dpad_to_buttons;
93module_param(dpad_to_buttons, bool, S_IRUGO);
94MODULE_PARM_DESC(dpad_to_buttons, "Map D-PAD to buttons rather than axes for unknown pads");
95
70static const struct xpad_device { 96static const struct xpad_device {
71 u16 idVendor; 97 u16 idVendor;
72 u16 idProduct; 98 u16 idProduct;
73 char *name; 99 char *name;
100 u8 dpad_mapping;
74} xpad_device[] = { 101} xpad_device[] = {
75 { 0x045e, 0x0202, "Microsoft X-Box pad (US)" }, 102 { 0x045e, 0x0202, "Microsoft X-Box pad v1 (US)", MAP_DPAD_TO_AXES },
76 { 0x045e, 0x0285, "Microsoft X-Box pad (Japan)" }, 103 { 0x045e, 0x0289, "Microsoft X-Box pad v2 (US)", MAP_DPAD_TO_AXES },
77 { 0x05fd, 0x107a, "InterAct 'PowerPad Pro' X-Box pad (Germany)" }, 104 { 0x045e, 0x0285, "Microsoft X-Box pad (Japan)", MAP_DPAD_TO_AXES },
78 { 0x0000, 0x0000, "X-Box pad" } 105 { 0x045e, 0x0287, "Microsoft Xbox Controller S", MAP_DPAD_TO_AXES },
106 { 0x0c12, 0x8809, "RedOctane Xbox Dance Pad", MAP_DPAD_TO_BUTTONS },
107 { 0x044f, 0x0f07, "Thrustmaster, Inc. Controller", MAP_DPAD_TO_AXES },
108 { 0x046d, 0xca84, "Logitech Xbox Cordless Controller", MAP_DPAD_TO_AXES },
109 { 0x046d, 0xca88, "Logitech Compact Controller for Xbox", MAP_DPAD_TO_AXES },
110 { 0x05fd, 0x1007, "Mad Catz Controller (unverified)", MAP_DPAD_TO_AXES },
111 { 0x05fd, 0x107a, "InterAct 'PowerPad Pro' X-Box pad (Germany)", MAP_DPAD_TO_AXES },
112 { 0x0738, 0x4516, "Mad Catz Control Pad", MAP_DPAD_TO_AXES },
113 { 0x0738, 0x4522, "Mad Catz LumiCON", MAP_DPAD_TO_AXES },
114 { 0x0738, 0x4526, "Mad Catz Control Pad Pro", MAP_DPAD_TO_AXES },
115 { 0x0738, 0x4536, "Mad Catz MicroCON", MAP_DPAD_TO_AXES },
116 { 0x0738, 0x4540, "Mad Catz Beat Pad", MAP_DPAD_TO_BUTTONS },
117 { 0x0738, 0x4556, "Mad Catz Lynx Wireless Controller", MAP_DPAD_TO_AXES },
118 { 0x0738, 0x6040, "Mad Catz Beat Pad Pro", MAP_DPAD_TO_BUTTONS },
119 { 0x0c12, 0x8802, "Zeroplus Xbox Controller", MAP_DPAD_TO_AXES },
120 { 0x0c12, 0x8810, "Zeroplus Xbox Controller", MAP_DPAD_TO_AXES },
121 { 0x0c12, 0x9902, "HAMA VibraX - *FAULTY HARDWARE*", MAP_DPAD_TO_AXES },
122 { 0x0e4c, 0x1097, "Radica Gamester Controller", MAP_DPAD_TO_AXES },
123 { 0x0e4c, 0x2390, "Radica Games Jtech Controller", MAP_DPAD_TO_AXES},
124 { 0x0e6f, 0x0003, "Logic3 Freebird wireless Controller", MAP_DPAD_TO_AXES },
125 { 0x0e6f, 0x0005, "Eclipse wireless Controller", MAP_DPAD_TO_AXES },
126 { 0x0e6f, 0x0006, "Edge wireless Controller", MAP_DPAD_TO_AXES },
127 { 0x0e8f, 0x0201, "SmartJoy Frag Xpad/PS2 adaptor", MAP_DPAD_TO_AXES },
128 { 0x0f30, 0x0202, "Joytech Advanced Controller", MAP_DPAD_TO_AXES },
129 { 0x0f30, 0x8888, "BigBen XBMiniPad Controller", MAP_DPAD_TO_AXES },
130 { 0x102c, 0xff0c, "Joytech Wireless Advanced Controller", MAP_DPAD_TO_AXES },
131 { 0x12ab, 0x8809, "Xbox DDR dancepad", MAP_DPAD_TO_BUTTONS },
132 { 0x1430, 0x8888, "TX6500+ Dance Pad (first generation)", MAP_DPAD_TO_BUTTONS },
133 { 0xffff, 0xffff, "Chinese-made Xbox Controller", MAP_DPAD_TO_AXES },
134 { 0x0000, 0x0000, "Generic X-Box pad", MAP_DPAD_UNKNOWN }
79}; 135};
80 136
81static const signed short xpad_btn[] = { 137static const signed short xpad_btn[] = {
@@ -84,11 +140,23 @@ static const signed short xpad_btn[] = {
84 -1 /* terminating entry */ 140 -1 /* terminating entry */
85}; 141};
86 142
143/* only used if MAP_DPAD_TO_BUTTONS */
144static const signed short xpad_btn_pad[] = {
145 BTN_LEFT, BTN_RIGHT, /* d-pad left, right */
146 BTN_0, BTN_1, /* d-pad up, down (XXX names??) */
147 -1 /* terminating entry */
148};
149
87static const signed short xpad_abs[] = { 150static const signed short xpad_abs[] = {
88 ABS_X, ABS_Y, /* left stick */ 151 ABS_X, ABS_Y, /* left stick */
89 ABS_RX, ABS_RY, /* right stick */ 152 ABS_RX, ABS_RY, /* right stick */
90 ABS_Z, ABS_RZ, /* triggers left/right */ 153 ABS_Z, ABS_RZ, /* triggers left/right */
91 ABS_HAT0X, ABS_HAT0Y, /* digital pad */ 154 -1 /* terminating entry */
155};
156
157/* only used if MAP_DPAD_TO_AXES */
158static const signed short xpad_abs_pad[] = {
159 ABS_HAT0X, ABS_HAT0Y, /* d-pad axes */
92 -1 /* terminating entry */ 160 -1 /* terminating entry */
93}; 161};
94 162
@@ -100,14 +168,16 @@ static struct usb_device_id xpad_table [] = {
100MODULE_DEVICE_TABLE (usb, xpad_table); 168MODULE_DEVICE_TABLE (usb, xpad_table);
101 169
102struct usb_xpad { 170struct usb_xpad {
103 struct input_dev *dev; /* input device interface */ 171 struct input_dev *dev; /* input device interface */
104 struct usb_device *udev; /* usb device */ 172 struct usb_device *udev; /* usb device */
105 173
106 struct urb *irq_in; /* urb for interrupt in report */ 174 struct urb *irq_in; /* urb for interrupt in report */
107 unsigned char *idata; /* input data */ 175 unsigned char *idata; /* input data */
108 dma_addr_t idata_dma; 176 dma_addr_t idata_dma;
109 177
110 char phys[65]; /* physical device path */ 178 char phys[65]; /* physical device path */
179
180 int dpad_mapping; /* map d-pad to buttons or to axes */
111}; 181};
112 182
113/* 183/*
@@ -120,12 +190,10 @@ struct usb_xpad {
120 * http://euc.jp/periphs/xbox-controller.ja.html 190 * http://euc.jp/periphs/xbox-controller.ja.html
121 */ 191 */
122 192
123static void xpad_process_packet(struct usb_xpad *xpad, u16 cmd, unsigned char *data, struct pt_regs *regs) 193static void xpad_process_packet(struct usb_xpad *xpad, u16 cmd, unsigned char *data)
124{ 194{
125 struct input_dev *dev = xpad->dev; 195 struct input_dev *dev = xpad->dev;
126 196
127 input_regs(dev, regs);
128
129 /* left stick */ 197 /* left stick */
130 input_report_abs(dev, ABS_X, (__s16) (((__s16)data[13] << 8) | data[12])); 198 input_report_abs(dev, ABS_X, (__s16) (((__s16)data[13] << 8) | data[12]));
131 input_report_abs(dev, ABS_Y, (__s16) (((__s16)data[15] << 8) | data[14])); 199 input_report_abs(dev, ABS_Y, (__s16) (((__s16)data[15] << 8) | data[14]));
@@ -139,14 +207,21 @@ static void xpad_process_packet(struct usb_xpad *xpad, u16 cmd, unsigned char *d
139 input_report_abs(dev, ABS_RZ, data[11]); 207 input_report_abs(dev, ABS_RZ, data[11]);
140 208
141 /* digital pad */ 209 /* digital pad */
142 input_report_abs(dev, ABS_HAT0X, !!(data[2] & 0x08) - !!(data[2] & 0x04)); 210 if (xpad->dpad_mapping == MAP_DPAD_TO_AXES) {
143 input_report_abs(dev, ABS_HAT0Y, !!(data[2] & 0x02) - !!(data[2] & 0x01)); 211 input_report_abs(dev, ABS_HAT0X, !!(data[2] & 0x08) - !!(data[2] & 0x04));
212 input_report_abs(dev, ABS_HAT0Y, !!(data[2] & 0x02) - !!(data[2] & 0x01));
213 } else /* xpad->dpad_mapping == MAP_DPAD_TO_BUTTONS */ {
214 input_report_key(dev, BTN_LEFT, data[2] & 0x04);
215 input_report_key(dev, BTN_RIGHT, data[2] & 0x08);
216 input_report_key(dev, BTN_0, data[2] & 0x01); // up
217 input_report_key(dev, BTN_1, data[2] & 0x02); // down
218 }
144 219
145 /* start/back buttons and stick press left/right */ 220 /* start/back buttons and stick press left/right */
146 input_report_key(dev, BTN_START, (data[2] & 0x10) >> 4); 221 input_report_key(dev, BTN_START, data[2] & 0x10);
147 input_report_key(dev, BTN_BACK, (data[2] & 0x20) >> 5); 222 input_report_key(dev, BTN_BACK, data[2] & 0x20);
148 input_report_key(dev, BTN_THUMBL, (data[2] & 0x40) >> 6); 223 input_report_key(dev, BTN_THUMBL, data[2] & 0x40);
149 input_report_key(dev, BTN_THUMBR, data[2] >> 7); 224 input_report_key(dev, BTN_THUMBR, data[2] & 0x80);
150 225
151 /* "analog" buttons A, B, X, Y */ 226 /* "analog" buttons A, B, X, Y */
152 input_report_key(dev, BTN_A, data[4]); 227 input_report_key(dev, BTN_A, data[4]);
@@ -161,7 +236,7 @@ static void xpad_process_packet(struct usb_xpad *xpad, u16 cmd, unsigned char *d
161 input_sync(dev); 236 input_sync(dev);
162} 237}
163 238
164static void xpad_irq_in(struct urb *urb, struct pt_regs *regs) 239static void xpad_irq_in(struct urb *urb)
165{ 240{
166 struct usb_xpad *xpad = urb->context; 241 struct usb_xpad *xpad = urb->context;
167 int retval; 242 int retval;
@@ -181,7 +256,7 @@ static void xpad_irq_in(struct urb *urb, struct pt_regs *regs)
181 goto exit; 256 goto exit;
182 } 257 }
183 258
184 xpad_process_packet(xpad, 0, xpad->idata, regs); 259 xpad_process_packet(xpad, 0, xpad->idata);
185 260
186exit: 261exit:
187 retval = usb_submit_urb (urb, GFP_ATOMIC); 262 retval = usb_submit_urb (urb, GFP_ATOMIC);
@@ -208,6 +283,28 @@ static void xpad_close (struct input_dev *dev)
208 usb_kill_urb(xpad->irq_in); 283 usb_kill_urb(xpad->irq_in);
209} 284}
210 285
286static void xpad_set_up_abs(struct input_dev *input_dev, signed short abs)
287{
288 set_bit(abs, input_dev->absbit);
289
290 switch (abs) {
291 case ABS_X:
292 case ABS_Y:
293 case ABS_RX:
294 case ABS_RY: /* the two sticks */
295 input_set_abs_params(input_dev, abs, -32768, 32767, 16, 128);
296 break;
297 case ABS_Z:
298 case ABS_RZ: /* the triggers */
299 input_set_abs_params(input_dev, abs, 0, 255, 0, 0);
300 break;
301 case ABS_HAT0X:
302 case ABS_HAT0Y: /* the d-pad (only if MAP_DPAD_TO_AXES) */
303 input_set_abs_params(input_dev, abs, -1, 1, 0, 0);
304 break;
305 }
306}
307
211static int xpad_probe(struct usb_interface *intf, const struct usb_device_id *id) 308static int xpad_probe(struct usb_interface *intf, const struct usb_device_id *id)
212{ 309{
213 struct usb_device *udev = interface_to_usbdev (intf); 310 struct usb_device *udev = interface_to_usbdev (intf);
@@ -237,6 +334,9 @@ static int xpad_probe(struct usb_interface *intf, const struct usb_device_id *id
237 goto fail2; 334 goto fail2;
238 335
239 xpad->udev = udev; 336 xpad->udev = udev;
337 xpad->dpad_mapping = xpad_device[i].dpad_mapping;
338 if (xpad->dpad_mapping == MAP_DPAD_UNKNOWN)
339 xpad->dpad_mapping = dpad_to_buttons;
240 xpad->dev = input_dev; 340 xpad->dev = input_dev;
241 usb_make_path(udev, xpad->phys, sizeof(xpad->phys)); 341 usb_make_path(udev, xpad->phys, sizeof(xpad->phys));
242 strlcat(xpad->phys, "/input0", sizeof(xpad->phys)); 342 strlcat(xpad->phys, "/input0", sizeof(xpad->phys));
@@ -251,32 +351,19 @@ static int xpad_probe(struct usb_interface *intf, const struct usb_device_id *id
251 351
252 input_dev->evbit[0] = BIT(EV_KEY) | BIT(EV_ABS); 352 input_dev->evbit[0] = BIT(EV_KEY) | BIT(EV_ABS);
253 353
354 /* set up buttons */
254 for (i = 0; xpad_btn[i] >= 0; i++) 355 for (i = 0; xpad_btn[i] >= 0; i++)
255 set_bit(xpad_btn[i], input_dev->keybit); 356 set_bit(xpad_btn[i], input_dev->keybit);
357 if (xpad->dpad_mapping == MAP_DPAD_TO_BUTTONS)
358 for (i = 0; xpad_btn_pad[i] >= 0; i++)
359 set_bit(xpad_btn_pad[i], input_dev->keybit);
256 360
257 for (i = 0; xpad_abs[i] >= 0; i++) { 361 /* set up axes */
258 362 for (i = 0; xpad_abs[i] >= 0; i++)
259 signed short t = xpad_abs[i]; 363 xpad_set_up_abs(input_dev, xpad_abs[i]);
260 364 if (xpad->dpad_mapping == MAP_DPAD_TO_AXES)
261 set_bit(t, input_dev->absbit); 365 for (i = 0; xpad_abs_pad[i] >= 0; i++)
262 366 xpad_set_up_abs(input_dev, xpad_abs_pad[i]);
263 switch (t) {
264 case ABS_X:
265 case ABS_Y:
266 case ABS_RX:
267 case ABS_RY: /* the two sticks */
268 input_set_abs_params(input_dev, t, -32768, 32767, 16, 128);
269 break;
270 case ABS_Z:
271 case ABS_RZ: /* the triggers */
272 input_set_abs_params(input_dev, t, 0, 255, 0, 0);
273 break;
274 case ABS_HAT0X:
275 case ABS_HAT0Y: /* the d-pad */
276 input_set_abs_params(input_dev, t, -1, 1, 0, 0);
277 break;
278 }
279 }
280 367
281 ep_irq_in = &intf->cur_altsetting->endpoint[0].desc; 368 ep_irq_in = &intf->cur_altsetting->endpoint[0].desc;
282 usb_fill_int_urb(xpad->irq_in, udev, 369 usb_fill_int_urb(xpad->irq_in, udev,
@@ -307,7 +394,8 @@ static void xpad_disconnect(struct usb_interface *intf)
307 usb_kill_urb(xpad->irq_in); 394 usb_kill_urb(xpad->irq_in);
308 input_unregister_device(xpad->dev); 395 input_unregister_device(xpad->dev);
309 usb_free_urb(xpad->irq_in); 396 usb_free_urb(xpad->irq_in);
310 usb_buffer_free(interface_to_usbdev(intf), XPAD_PKT_LEN, xpad->idata, xpad->idata_dma); 397 usb_buffer_free(interface_to_usbdev(intf), XPAD_PKT_LEN,
398 xpad->idata, xpad->idata_dma);
311 kfree(xpad); 399 kfree(xpad);
312 } 400 }
313} 401}
diff --git a/drivers/usb/input/yealink.c b/drivers/usb/input/yealink.c
index 7291e7a2717b..905bf6398257 100644
--- a/drivers/usb/input/yealink.c
+++ b/drivers/usb/input/yealink.c
@@ -233,11 +233,10 @@ static int map_p1k_to_key(int scancode)
233 * 233 *
234 * The key parameter can be cascaded: key2 << 8 | key1 234 * The key parameter can be cascaded: key2 << 8 | key1
235 */ 235 */
236static void report_key(struct yealink_dev *yld, int key, struct pt_regs *regs) 236static void report_key(struct yealink_dev *yld, int key)
237{ 237{
238 struct input_dev *idev = yld->idev; 238 struct input_dev *idev = yld->idev;
239 239
240 input_regs(idev, regs);
241 if (yld->key_code >= 0) { 240 if (yld->key_code >= 0) {
242 /* old key up */ 241 /* old key up */
243 input_report_key(idev, yld->key_code & 0xff, 0); 242 input_report_key(idev, yld->key_code & 0xff, 0);
@@ -422,7 +421,7 @@ send_update:
422 * error,start 421 * error,start
423 * 422 *
424 */ 423 */
425static void urb_irq_callback(struct urb *urb, struct pt_regs *regs) 424static void urb_irq_callback(struct urb *urb)
426{ 425{
427 struct yealink_dev *yld = urb->context; 426 struct yealink_dev *yld = urb->context;
428 int ret; 427 int ret;
@@ -439,7 +438,7 @@ static void urb_irq_callback(struct urb *urb, struct pt_regs *regs)
439 case CMD_SCANCODE: 438 case CMD_SCANCODE:
440 dbg("get scancode %x", yld->irq_data->data[0]); 439 dbg("get scancode %x", yld->irq_data->data[0]);
441 440
442 report_key(yld, map_p1k_to_key(yld->irq_data->data[0]), regs); 441 report_key(yld, map_p1k_to_key(yld->irq_data->data[0]));
443 break; 442 break;
444 443
445 default: 444 default:
@@ -453,7 +452,7 @@ static void urb_irq_callback(struct urb *urb, struct pt_regs *regs)
453 err("%s - usb_submit_urb failed %d", __FUNCTION__, ret); 452 err("%s - usb_submit_urb failed %d", __FUNCTION__, ret);
454} 453}
455 454
456static void urb_ctl_callback(struct urb *urb, struct pt_regs *regs) 455static void urb_ctl_callback(struct urb *urb)
457{ 456{
458 struct yealink_dev *yld = urb->context; 457 struct yealink_dev *yld = urb->context;
459 int ret; 458 int ret;
diff --git a/drivers/usb/misc/Kconfig b/drivers/usb/misc/Kconfig
index c29658f69e2a..a74bf8617e7f 100644
--- a/drivers/usb/misc/Kconfig
+++ b/drivers/usb/misc/Kconfig
@@ -223,6 +223,16 @@ config USB_LD
223 To compile this driver as a module, choose M here: the 223 To compile this driver as a module, choose M here: the
224 module will be called ldusb. 224 module will be called ldusb.
225 225
226config USB_TRANCEVIBRATOR
227 tristate "PlayStation 2 Trance Vibrator driver support"
228 depends on USB
229 help
230 Say Y here if you want to connect a PlayStation 2 Trance Vibrator
231 device to your computer's USB port.
232
233 To compile this driver as a module, choose M here: the
234 module will be called trancevibrator.
235
226config USB_TEST 236config USB_TEST
227 tristate "USB testing driver (DEVELOPMENT)" 237 tristate "USB testing driver (DEVELOPMENT)"
228 depends on USB && USB_DEVICEFS && EXPERIMENTAL 238 depends on USB && USB_DEVICEFS && EXPERIMENTAL
diff --git a/drivers/usb/misc/Makefile b/drivers/usb/misc/Makefile
index 2be70fa259bf..11dc59540cda 100644
--- a/drivers/usb/misc/Makefile
+++ b/drivers/usb/misc/Makefile
@@ -21,6 +21,7 @@ obj-$(CONFIG_USB_PHIDGETMOTORCONTROL) += phidgetmotorcontrol.o
21obj-$(CONFIG_USB_PHIDGETSERVO) += phidgetservo.o 21obj-$(CONFIG_USB_PHIDGETSERVO) += phidgetservo.o
22obj-$(CONFIG_USB_RIO500) += rio500.o 22obj-$(CONFIG_USB_RIO500) += rio500.o
23obj-$(CONFIG_USB_TEST) += usbtest.o 23obj-$(CONFIG_USB_TEST) += usbtest.o
24obj-$(CONFIG_USB_TRANCEVIBRATOR) += trancevibrator.o
24obj-$(CONFIG_USB_USS720) += uss720.o 25obj-$(CONFIG_USB_USS720) += uss720.o
25 26
26obj-$(CONFIG_USB_SISUSBVGA) += sisusbvga/ 27obj-$(CONFIG_USB_SISUSBVGA) += sisusbvga/
diff --git a/drivers/usb/misc/adutux.c b/drivers/usb/misc/adutux.c
index d3963199b6ec..af2934e016a7 100644
--- a/drivers/usb/misc/adutux.c
+++ b/drivers/usb/misc/adutux.c
@@ -177,7 +177,7 @@ static void adu_delete(struct adu_device *dev)
177 dbg(2, "%s : leave", __FUNCTION__); 177 dbg(2, "%s : leave", __FUNCTION__);
178} 178}
179 179
180static void adu_interrupt_in_callback(struct urb *urb, struct pt_regs *regs) 180static void adu_interrupt_in_callback(struct urb *urb)
181{ 181{
182 struct adu_device *dev = urb->context; 182 struct adu_device *dev = urb->context;
183 183
@@ -221,7 +221,7 @@ exit:
221 dbg(4," %s : leave, status %d", __FUNCTION__, urb->status); 221 dbg(4," %s : leave, status %d", __FUNCTION__, urb->status);
222} 222}
223 223
224static void adu_interrupt_out_callback(struct urb *urb, struct pt_regs *regs) 224static void adu_interrupt_out_callback(struct urb *urb)
225{ 225{
226 struct adu_device *dev = urb->context; 226 struct adu_device *dev = urb->context;
227 227
@@ -370,7 +370,8 @@ static int adu_release(struct inode *inode, struct file *file)
370 retval = adu_release_internal(dev); 370 retval = adu_release_internal(dev);
371 371
372exit: 372exit:
373 up(&dev->sem); 373 if (dev)
374 up(&dev->sem);
374 dbg(2," %s : leave, return value %d", __FUNCTION__, retval); 375 dbg(2," %s : leave, return value %d", __FUNCTION__, retval);
375 return retval; 376 return retval;
376} 377}
diff --git a/drivers/usb/misc/appledisplay.c b/drivers/usb/misc/appledisplay.c
index fc6cc147996f..6b23a1def9fe 100644
--- a/drivers/usb/misc/appledisplay.c
+++ b/drivers/usb/misc/appledisplay.c
@@ -84,7 +84,7 @@ struct appledisplay {
84static atomic_t count_displays = ATOMIC_INIT(0); 84static atomic_t count_displays = ATOMIC_INIT(0);
85static struct workqueue_struct *wq; 85static struct workqueue_struct *wq;
86 86
87static void appledisplay_complete(struct urb *urb, struct pt_regs *regs) 87static void appledisplay_complete(struct urb *urb)
88{ 88{
89 struct appledisplay *pdata = urb->context; 89 struct appledisplay *pdata = urb->context;
90 unsigned long flags; 90 unsigned long flags;
diff --git a/drivers/usb/misc/auerswald.c b/drivers/usb/misc/auerswald.c
index 4fd2110b3411..e4971d6aaafb 100644
--- a/drivers/usb/misc/auerswald.c
+++ b/drivers/usb/misc/auerswald.c
@@ -267,7 +267,7 @@ typedef struct
267 267
268/*-------------------------------------------------------------------*/ 268/*-------------------------------------------------------------------*/
269/* Forwards */ 269/* Forwards */
270static void auerswald_ctrlread_complete (struct urb * urb, struct pt_regs *regs); 270static void auerswald_ctrlread_complete (struct urb * urb);
271static void auerswald_removeservice (pauerswald_t cp, pauerscon_t scp); 271static void auerswald_removeservice (pauerswald_t cp, pauerscon_t scp);
272static struct usb_driver auerswald_driver; 272static struct usb_driver auerswald_driver;
273 273
@@ -277,7 +277,7 @@ static struct usb_driver auerswald_driver;
277/* -------------------------- */ 277/* -------------------------- */
278 278
279/* completion function for chained urbs */ 279/* completion function for chained urbs */
280static void auerchain_complete (struct urb * urb, struct pt_regs *regs) 280static void auerchain_complete (struct urb * urb)
281{ 281{
282 unsigned long flags; 282 unsigned long flags;
283 int result; 283 int result;
@@ -296,7 +296,7 @@ static void auerchain_complete (struct urb * urb, struct pt_regs *regs)
296 NOTE: this function may lead to more urbs submitted into the chain. 296 NOTE: this function may lead to more urbs submitted into the chain.
297 (no chain lock at calling complete()!) 297 (no chain lock at calling complete()!)
298 acp->active != NULL is protecting us against recursion.*/ 298 acp->active != NULL is protecting us against recursion.*/
299 urb->complete (urb, regs); 299 urb->complete (urb);
300 300
301 /* detach element from chain data structure */ 301 /* detach element from chain data structure */
302 spin_lock_irqsave (&acp->lock, flags); 302 spin_lock_irqsave (&acp->lock, flags);
@@ -331,7 +331,7 @@ static void auerchain_complete (struct urb * urb, struct pt_regs *regs)
331 urb->status = result; 331 urb->status = result;
332 dbg("auerchain_complete: usb_submit_urb with error code %d", result); 332 dbg("auerchain_complete: usb_submit_urb with error code %d", result);
333 /* and do error handling via *this* completion function (recursive) */ 333 /* and do error handling via *this* completion function (recursive) */
334 auerchain_complete( urb, NULL); 334 auerchain_complete( urb);
335 } 335 }
336 } else { 336 } else {
337 /* simple return without submitting a new urb. 337 /* simple return without submitting a new urb.
@@ -408,7 +408,7 @@ static int auerchain_submit_urb_list (pauerchain_t acp, struct urb * urb, int ea
408 urb->status = result; 408 urb->status = result;
409 dbg("auerchain_submit_urb: usb_submit_urb with error code %d", result); 409 dbg("auerchain_submit_urb: usb_submit_urb with error code %d", result);
410 /* and do error handling via completion function */ 410 /* and do error handling via completion function */
411 auerchain_complete( urb, NULL); 411 auerchain_complete( urb);
412 } 412 }
413 } 413 }
414 414
@@ -448,7 +448,7 @@ static int auerchain_unlink_urb (pauerchain_t acp, struct urb * urb)
448 spin_unlock_irqrestore (&acp->lock, flags); 448 spin_unlock_irqrestore (&acp->lock, flags);
449 dbg ("unlink waiting urb"); 449 dbg ("unlink waiting urb");
450 urb->status = -ENOENT; 450 urb->status = -ENOENT;
451 urb->complete (urb, NULL); 451 urb->complete (urb);
452 return 0; 452 return 0;
453 } 453 }
454 } 454 }
@@ -505,7 +505,7 @@ static void auerchain_unlink_all (pauerchain_t acp)
505 spin_unlock_irqrestore (&acp->lock, flags); 505 spin_unlock_irqrestore (&acp->lock, flags);
506 dbg ("unlink waiting urb"); 506 dbg ("unlink waiting urb");
507 urbp->status = -ENOENT; 507 urbp->status = -ENOENT;
508 urbp->complete (urbp, NULL); 508 urbp->complete (urbp);
509 spin_lock_irqsave (&acp->lock, flags); 509 spin_lock_irqsave (&acp->lock, flags);
510 } 510 }
511 spin_unlock_irqrestore (&acp->lock, flags); 511 spin_unlock_irqrestore (&acp->lock, flags);
@@ -591,7 +591,7 @@ ac_fail:/* free the elements */
591 591
592 592
593/* completion handler for synchronous chained URBs */ 593/* completion handler for synchronous chained URBs */
594static void auerchain_blocking_completion (struct urb *urb, struct pt_regs *regs) 594static void auerchain_blocking_completion (struct urb *urb)
595{ 595{
596 pauerchain_chs_t pchs = (pauerchain_chs_t)urb->context; 596 pauerchain_chs_t pchs = (pauerchain_chs_t)urb->context;
597 pchs->done = 1; 597 pchs->done = 1;
@@ -780,7 +780,7 @@ static int auerbuf_setup (pauerbufctl_t bcp, unsigned int numElements, unsigned
780 780
781bl_fail:/* not enough memory. Free allocated elements */ 781bl_fail:/* not enough memory. Free allocated elements */
782 dbg ("auerbuf_setup: no more memory"); 782 dbg ("auerbuf_setup: no more memory");
783 kfree(bep); 783 auerbuf_free(bep);
784 auerbuf_free_buffers (bcp); 784 auerbuf_free_buffers (bcp);
785 return -ENOMEM; 785 return -ENOMEM;
786} 786}
@@ -846,7 +846,7 @@ static int auerswald_status_retry (int status)
846} 846}
847 847
848/* Completion of asynchronous write block */ 848/* Completion of asynchronous write block */
849static void auerchar_ctrlwrite_complete (struct urb * urb, struct pt_regs *regs) 849static void auerchar_ctrlwrite_complete (struct urb * urb)
850{ 850{
851 pauerbuf_t bp = (pauerbuf_t) urb->context; 851 pauerbuf_t bp = (pauerbuf_t) urb->context;
852 pauerswald_t cp = ((pauerswald_t)((char *)(bp->list)-(unsigned long)(&((pauerswald_t)0)->bufctl))); 852 pauerswald_t cp = ((pauerswald_t)((char *)(bp->list)-(unsigned long)(&((pauerswald_t)0)->bufctl)));
@@ -859,7 +859,7 @@ static void auerchar_ctrlwrite_complete (struct urb * urb, struct pt_regs *regs)
859} 859}
860 860
861/* Completion handler for dummy retry packet */ 861/* Completion handler for dummy retry packet */
862static void auerswald_ctrlread_wretcomplete (struct urb * urb, struct pt_regs *regs) 862static void auerswald_ctrlread_wretcomplete (struct urb * urb)
863{ 863{
864 pauerbuf_t bp = (pauerbuf_t) urb->context; 864 pauerbuf_t bp = (pauerbuf_t) urb->context;
865 pauerswald_t cp; 865 pauerswald_t cp;
@@ -893,12 +893,12 @@ static void auerswald_ctrlread_wretcomplete (struct urb * urb, struct pt_regs *r
893 if (ret) { 893 if (ret) {
894 dbg ("auerswald_ctrlread_complete: nonzero result of auerchain_submit_urb_list %d", ret); 894 dbg ("auerswald_ctrlread_complete: nonzero result of auerchain_submit_urb_list %d", ret);
895 bp->urbp->status = ret; 895 bp->urbp->status = ret;
896 auerswald_ctrlread_complete (bp->urbp, NULL); 896 auerswald_ctrlread_complete (bp->urbp);
897 } 897 }
898} 898}
899 899
900/* completion handler for receiving of control messages */ 900/* completion handler for receiving of control messages */
901static void auerswald_ctrlread_complete (struct urb * urb, struct pt_regs *regs) 901static void auerswald_ctrlread_complete (struct urb * urb)
902{ 902{
903 unsigned int serviceid; 903 unsigned int serviceid;
904 pauerswald_t cp; 904 pauerswald_t cp;
@@ -941,7 +941,7 @@ static void auerswald_ctrlread_complete (struct urb * urb, struct pt_regs *regs)
941 if (ret) { 941 if (ret) {
942 dbg ("auerswald_ctrlread_complete: nonzero result of auerchain_submit_urb_list %d", ret); 942 dbg ("auerswald_ctrlread_complete: nonzero result of auerchain_submit_urb_list %d", ret);
943 bp->urbp->status = ret; 943 bp->urbp->status = ret;
944 auerswald_ctrlread_wretcomplete (bp->urbp, regs); 944 auerswald_ctrlread_wretcomplete (bp->urbp);
945 } 945 }
946 return; 946 return;
947 } 947 }
@@ -970,7 +970,7 @@ static void auerswald_ctrlread_complete (struct urb * urb, struct pt_regs *regs)
970 messages from the USB device. 970 messages from the USB device.
971*/ 971*/
972/* int completion handler. */ 972/* int completion handler. */
973static void auerswald_int_complete (struct urb * urb, struct pt_regs *regs) 973static void auerswald_int_complete (struct urb * urb)
974{ 974{
975 unsigned long flags; 975 unsigned long flags;
976 unsigned int channelid; 976 unsigned int channelid;
@@ -1070,7 +1070,7 @@ static void auerswald_int_complete (struct urb * urb, struct pt_regs *regs)
1070 if (ret) { 1070 if (ret) {
1071 dbg ("auerswald_int_complete: nonzero result of auerchain_submit_urb %d", ret); 1071 dbg ("auerswald_int_complete: nonzero result of auerchain_submit_urb %d", ret);
1072 bp->urbp->status = ret; 1072 bp->urbp->status = ret;
1073 auerswald_ctrlread_complete( bp->urbp, NULL); 1073 auerswald_ctrlread_complete( bp->urbp);
1074 /* here applies the same problem as above: device locking! */ 1074 /* here applies the same problem as above: device locking! */
1075 } 1075 }
1076exit: 1076exit:
diff --git a/drivers/usb/misc/ftdi-elan.c b/drivers/usb/misc/ftdi-elan.c
index c6f2f488a40f..9b591b8b9369 100644
--- a/drivers/usb/misc/ftdi-elan.c
+++ b/drivers/usb/misc/ftdi-elan.c
@@ -513,8 +513,6 @@ static void ftdi_elan_respond_work(void *data)
513 ftdi->disconnected += 1; 513 ftdi->disconnected += 1;
514 } else if (retval == -ENODEV) { 514 } else if (retval == -ENODEV) {
515 ftdi->disconnected += 1; 515 ftdi->disconnected += 1;
516 } else if (retval == -ENODEV) {
517 ftdi->disconnected += 1;
518 } else if (retval == -EILSEQ) { 516 } else if (retval == -EILSEQ) {
519 ftdi->disconnected += 1; 517 ftdi->disconnected += 1;
520 } else { 518 } else {
@@ -758,7 +756,7 @@ static ssize_t ftdi_elan_read(struct file *file, char __user *buffer,
758 return bytes_read; 756 return bytes_read;
759} 757}
760 758
761static void ftdi_elan_write_bulk_callback(struct urb *urb, struct pt_regs *regs) 759static void ftdi_elan_write_bulk_callback(struct urb *urb)
762{ 760{
763 struct usb_ftdi *ftdi = (struct usb_ftdi *)urb->context; 761 struct usb_ftdi *ftdi = (struct usb_ftdi *)urb->context;
764 if (urb->status && !(urb->status == -ENOENT || urb->status == 762 if (urb->status && !(urb->status == -ENOENT || urb->status ==
@@ -1186,11 +1184,8 @@ static ssize_t ftdi_elan_write(struct file *file,
1186 int retval = 0; 1184 int retval = 0;
1187 struct urb *urb; 1185 struct urb *urb;
1188 char *buf; 1186 char *buf;
1189 char data[30 *3 + 4]; 1187 struct usb_ftdi *ftdi = file->private_data;
1190 char *d = data; 1188
1191 const char __user *s = user_buffer;
1192 int m = (sizeof(data) - 1) / 3;
1193 struct usb_ftdi *ftdi = (struct usb_ftdi *)file->private_data;
1194 if (ftdi->disconnected > 0) { 1189 if (ftdi->disconnected > 0) {
1195 return -ENODEV; 1190 return -ENODEV;
1196 } 1191 }
@@ -1220,27 +1215,18 @@ static ssize_t ftdi_elan_write(struct file *file,
1220 if (retval) { 1215 if (retval) {
1221 dev_err(&ftdi->udev->dev, "failed submitting write urb, error %" 1216 dev_err(&ftdi->udev->dev, "failed submitting write urb, error %"
1222 "d\n", retval); 1217 "d\n", retval);
1223 goto error_4; 1218 goto error_3;
1224 } 1219 }
1225 usb_free_urb(urb); 1220 usb_free_urb(urb);
1226 exit:; 1221
1227 if (count > m) { 1222exit:
1228 int I = m - 1;
1229 while (I-- > 0) {
1230 d += sprintf(d, " %02X", 0x000000FF & *s++);
1231 }
1232 d += sprintf(d, " ..");
1233 } else {
1234 int I = count;
1235 while (I-- > 0) {
1236 d += sprintf(d, " %02X", 0x000000FF & *s++);
1237 }
1238 }
1239 return count; 1223 return count;
1240 error_4: error_3:usb_buffer_free(ftdi->udev, count, buf, 1224error_3:
1241 urb->transfer_dma); 1225 usb_buffer_free(ftdi->udev, count, buf, urb->transfer_dma);
1242 error_2:usb_free_urb(urb); 1226error_2:
1243 error_1:return retval; 1227 usb_free_urb(urb);
1228error_1:
1229 return retval;
1244} 1230}
1245 1231
1246static struct file_operations ftdi_elan_fops = { 1232static struct file_operations ftdi_elan_fops = {
diff --git a/drivers/usb/misc/ldusb.c b/drivers/usb/misc/ldusb.c
index 10b640339d8d..788a11e6772f 100644
--- a/drivers/usb/misc/ldusb.c
+++ b/drivers/usb/misc/ldusb.c
@@ -212,7 +212,7 @@ static void ld_usb_delete(struct ld_usb *dev)
212/** 212/**
213 * ld_usb_interrupt_in_callback 213 * ld_usb_interrupt_in_callback
214 */ 214 */
215static void ld_usb_interrupt_in_callback(struct urb *urb, struct pt_regs *regs) 215static void ld_usb_interrupt_in_callback(struct urb *urb)
216{ 216{
217 struct ld_usb *dev = urb->context; 217 struct ld_usb *dev = urb->context;
218 size_t *actual_buffer; 218 size_t *actual_buffer;
@@ -264,7 +264,7 @@ exit:
264/** 264/**
265 * ld_usb_interrupt_out_callback 265 * ld_usb_interrupt_out_callback
266 */ 266 */
267static void ld_usb_interrupt_out_callback(struct urb *urb, struct pt_regs *regs) 267static void ld_usb_interrupt_out_callback(struct urb *urb)
268{ 268{
269 struct ld_usb *dev = urb->context; 269 struct ld_usb *dev = urb->context;
270 270
diff --git a/drivers/usb/misc/legousbtower.c b/drivers/usb/misc/legousbtower.c
index 77c36e63c7bf..27089497e717 100644
--- a/drivers/usb/misc/legousbtower.c
+++ b/drivers/usb/misc/legousbtower.c
@@ -248,8 +248,8 @@ static loff_t tower_llseek (struct file *file, loff_t off, int whence);
248 248
249static void tower_abort_transfers (struct lego_usb_tower *dev); 249static void tower_abort_transfers (struct lego_usb_tower *dev);
250static void tower_check_for_read_packet (struct lego_usb_tower *dev); 250static void tower_check_for_read_packet (struct lego_usb_tower *dev);
251static void tower_interrupt_in_callback (struct urb *urb, struct pt_regs *regs); 251static void tower_interrupt_in_callback (struct urb *urb);
252static void tower_interrupt_out_callback (struct urb *urb, struct pt_regs *regs); 252static void tower_interrupt_out_callback (struct urb *urb);
253 253
254static int tower_probe (struct usb_interface *interface, const struct usb_device_id *id); 254static int tower_probe (struct usb_interface *interface, const struct usb_device_id *id);
255static void tower_disconnect (struct usb_interface *interface); 255static void tower_disconnect (struct usb_interface *interface);
@@ -755,7 +755,7 @@ exit:
755/** 755/**
756 * tower_interrupt_in_callback 756 * tower_interrupt_in_callback
757 */ 757 */
758static void tower_interrupt_in_callback (struct urb *urb, struct pt_regs *regs) 758static void tower_interrupt_in_callback (struct urb *urb)
759{ 759{
760 struct lego_usb_tower *dev = (struct lego_usb_tower *)urb->context; 760 struct lego_usb_tower *dev = (struct lego_usb_tower *)urb->context;
761 int retval; 761 int retval;
@@ -811,7 +811,7 @@ exit:
811/** 811/**
812 * tower_interrupt_out_callback 812 * tower_interrupt_out_callback
813 */ 813 */
814static void tower_interrupt_out_callback (struct urb *urb, struct pt_regs *regs) 814static void tower_interrupt_out_callback (struct urb *urb)
815{ 815{
816 struct lego_usb_tower *dev = (struct lego_usb_tower *)urb->context; 816 struct lego_usb_tower *dev = (struct lego_usb_tower *)urb->context;
817 817
diff --git a/drivers/usb/misc/phidgetkit.c b/drivers/usb/misc/phidgetkit.c
index 78e419904abf..abb4dcd811ac 100644
--- a/drivers/usb/misc/phidgetkit.c
+++ b/drivers/usb/misc/phidgetkit.c
@@ -300,7 +300,7 @@ out:
300 300
301static DEVICE_ATTR(lcd, S_IWUGO, NULL, enable_lcd_files); 301static DEVICE_ATTR(lcd, S_IWUGO, NULL, enable_lcd_files);
302 302
303static void interfacekit_irq(struct urb *urb, struct pt_regs *regs) 303static void interfacekit_irq(struct urb *urb)
304{ 304{
305 struct interfacekit *kit = urb->context; 305 struct interfacekit *kit = urb->context;
306 unsigned char *buffer = kit->data; 306 unsigned char *buffer = kit->data;
diff --git a/drivers/usb/misc/phidgetmotorcontrol.c b/drivers/usb/misc/phidgetmotorcontrol.c
index 6b59b620d616..5c780cab92e0 100644
--- a/drivers/usb/misc/phidgetmotorcontrol.c
+++ b/drivers/usb/misc/phidgetmotorcontrol.c
@@ -90,7 +90,7 @@ static int set_motor(struct motorcontrol *mc, int motor)
90 return retval < 0 ? retval : 0; 90 return retval < 0 ? retval : 0;
91} 91}
92 92
93static void motorcontrol_irq(struct urb *urb, struct pt_regs *regs) 93static void motorcontrol_irq(struct urb *urb)
94{ 94{
95 struct motorcontrol *mc = urb->context; 95 struct motorcontrol *mc = urb->context;
96 unsigned char *buffer = mc->data; 96 unsigned char *buffer = mc->data;
diff --git a/drivers/usb/misc/sisusbvga/sisusb.c b/drivers/usb/misc/sisusbvga/sisusb.c
index a287836e39f1..b99ca9c79821 100644
--- a/drivers/usb/misc/sisusbvga/sisusb.c
+++ b/drivers/usb/misc/sisusbvga/sisusb.c
@@ -209,7 +209,7 @@ sisusb_free_outbuf(struct sisusb_usb_data *sisusb, int index)
209/* completion callback */ 209/* completion callback */
210 210
211static void 211static void
212sisusb_bulk_completeout(struct urb *urb, struct pt_regs *regs) 212sisusb_bulk_completeout(struct urb *urb)
213{ 213{
214 struct sisusb_urb_context *context = urb->context; 214 struct sisusb_urb_context *context = urb->context;
215 struct sisusb_usb_data *sisusb; 215 struct sisusb_usb_data *sisusb;
@@ -288,7 +288,7 @@ sisusb_bulkout_msg(struct sisusb_usb_data *sisusb, int index, unsigned int pipe,
288/* completion callback */ 288/* completion callback */
289 289
290static void 290static void
291sisusb_bulk_completein(struct urb *urb, struct pt_regs *regs) 291sisusb_bulk_completein(struct urb *urb)
292{ 292{
293 struct sisusb_usb_data *sisusb = urb->context; 293 struct sisusb_usb_data *sisusb = urb->context;
294 294
diff --git a/drivers/usb/input/trancevibrator.c b/drivers/usb/misc/trancevibrator.c
index 33cd91d11eca..33cd91d11eca 100644
--- a/drivers/usb/input/trancevibrator.c
+++ b/drivers/usb/misc/trancevibrator.c
diff --git a/drivers/usb/misc/usblcd.c b/drivers/usb/misc/usblcd.c
index dbaca9f1efad..ada2ebc464ae 100644
--- a/drivers/usb/misc/usblcd.c
+++ b/drivers/usb/misc/usblcd.c
@@ -165,7 +165,7 @@ static int lcd_ioctl(struct inode *inode, struct file *file, unsigned int cmd, u
165 return 0; 165 return 0;
166} 166}
167 167
168static void lcd_write_bulk_callback(struct urb *urb, struct pt_regs *regs) 168static void lcd_write_bulk_callback(struct urb *urb)
169{ 169{
170 struct usb_lcd *dev; 170 struct usb_lcd *dev;
171 171
diff --git a/drivers/usb/misc/usbtest.c b/drivers/usb/misc/usbtest.c
index 983e104dd452..7c2cbdf81d20 100644
--- a/drivers/usb/misc/usbtest.c
+++ b/drivers/usb/misc/usbtest.c
@@ -198,7 +198,7 @@ found:
198 * them with non-zero test data (or test for it) when appropriate. 198 * them with non-zero test data (or test for it) when appropriate.
199 */ 199 */
200 200
201static void simple_callback (struct urb *urb, struct pt_regs *regs) 201static void simple_callback (struct urb *urb)
202{ 202{
203 complete ((struct completion *) urb->context); 203 complete ((struct completion *) urb->context);
204} 204}
@@ -730,7 +730,7 @@ struct subcase {
730 int expected; 730 int expected;
731}; 731};
732 732
733static void ctrl_complete (struct urb *urb, struct pt_regs *regs) 733static void ctrl_complete (struct urb *urb)
734{ 734{
735 struct ctrl_ctx *ctx = urb->context; 735 struct ctrl_ctx *ctx = urb->context;
736 struct usb_ctrlrequest *reqp; 736 struct usb_ctrlrequest *reqp;
@@ -1035,7 +1035,7 @@ cleanup:
1035 1035
1036/*-------------------------------------------------------------------------*/ 1036/*-------------------------------------------------------------------------*/
1037 1037
1038static void unlink1_callback (struct urb *urb, struct pt_regs *regs) 1038static void unlink1_callback (struct urb *urb)
1039{ 1039{
1040 int status = urb->status; 1040 int status = urb->status;
1041 1041
@@ -1343,7 +1343,7 @@ struct iso_context {
1343 struct usbtest_dev *dev; 1343 struct usbtest_dev *dev;
1344}; 1344};
1345 1345
1346static void iso_callback (struct urb *urb, struct pt_regs *regs) 1346static void iso_callback (struct urb *urb)
1347{ 1347{
1348 struct iso_context *ctx = urb->context; 1348 struct iso_context *ctx = urb->context;
1349 1349
diff --git a/drivers/usb/misc/uss720.c b/drivers/usb/misc/uss720.c
index 4081990b7d1a..7e8a0acd52ee 100644
--- a/drivers/usb/misc/uss720.c
+++ b/drivers/usb/misc/uss720.c
@@ -106,7 +106,7 @@ static void destroy_async(struct kref *kref)
106 106
107/* --------------------------------------------------------------------- */ 107/* --------------------------------------------------------------------- */
108 108
109static void async_complete(struct urb *urb, struct pt_regs *ptregs) 109static void async_complete(struct urb *urb)
110{ 110{
111 struct uss720_async_request *rq; 111 struct uss720_async_request *rq;
112 struct parport *pp; 112 struct parport *pp;
@@ -127,7 +127,7 @@ static void async_complete(struct urb *urb, struct pt_regs *ptregs)
127#endif 127#endif
128 /* if nAck interrupts are enabled and we have an interrupt, call the interrupt procedure */ 128 /* if nAck interrupts are enabled and we have an interrupt, call the interrupt procedure */
129 if (rq->reg[2] & rq->reg[1] & 0x10 && pp) 129 if (rq->reg[2] & rq->reg[1] & 0x10 && pp)
130 parport_generic_irq(0, pp, NULL); 130 parport_generic_irq(0, pp);
131 } 131 }
132 complete(&rq->compl); 132 complete(&rq->compl);
133 kref_put(&rq->ref_count, destroy_async); 133 kref_put(&rq->ref_count, destroy_async);
diff --git a/drivers/usb/net/Kconfig b/drivers/usb/net/Kconfig
index 054059632a21..e081836014ac 100644
--- a/drivers/usb/net/Kconfig
+++ b/drivers/usb/net/Kconfig
@@ -92,8 +92,13 @@ config USB_RTL8150
92 To compile this driver as a module, choose M here: the 92 To compile this driver as a module, choose M here: the
93 module will be called rtl8150. 93 module will be called rtl8150.
94 94
95config USB_USBNET_MII
96 tristate
97 default n
98
95config USB_USBNET 99config USB_USBNET
96 tristate "Multi-purpose USB Networking Framework" 100 tristate "Multi-purpose USB Networking Framework"
101 select MII if USBNET_MII != n
97 ---help--- 102 ---help---
98 This driver supports several kinds of network links over USB, 103 This driver supports several kinds of network links over USB,
99 with "minidrivers" built around a common network driver core 104 with "minidrivers" built around a common network driver core
@@ -129,7 +134,7 @@ config USB_NET_AX8817X
129 tristate "ASIX AX88xxx Based USB 2.0 Ethernet Adapters" 134 tristate "ASIX AX88xxx Based USB 2.0 Ethernet Adapters"
130 depends on USB_USBNET && NET_ETHERNET 135 depends on USB_USBNET && NET_ETHERNET
131 select CRC32 136 select CRC32
132 select MII 137 select USB_USBNET_MII
133 default y 138 default y
134 help 139 help
135 This option adds support for ASIX AX88xxx based USB 2.0 140 This option adds support for ASIX AX88xxx based USB 2.0
@@ -207,6 +212,15 @@ config USB_NET_PLUSB
207 Choose this option if you're using a host-to-host cable 212 Choose this option if you're using a host-to-host cable
208 with one of these chips. 213 with one of these chips.
209 214
215config USB_NET_MCS7830
216 tristate "MosChip MCS7830 based Ethernet adapters"
217 depends on USB_USBNET
218 select USB_USBNET_MII
219 help
220 Choose this option if you're using a 10/100 Ethernet USB2
221 adapter based on the MosChip 7830 controller. This includes
222 adapters marketed under the DeLOCK brand.
223
210config USB_NET_RNDIS_HOST 224config USB_NET_RNDIS_HOST
211 tristate "Host for RNDIS devices (EXPERIMENTAL)" 225 tristate "Host for RNDIS devices (EXPERIMENTAL)"
212 depends on USB_USBNET && EXPERIMENTAL 226 depends on USB_USBNET && EXPERIMENTAL
diff --git a/drivers/usb/net/Makefile b/drivers/usb/net/Makefile
index 160f19dbdf12..7b51964de171 100644
--- a/drivers/usb/net/Makefile
+++ b/drivers/usb/net/Makefile
@@ -14,6 +14,7 @@ obj-$(CONFIG_USB_NET_PLUSB) += plusb.o
14obj-$(CONFIG_USB_NET_RNDIS_HOST) += rndis_host.o 14obj-$(CONFIG_USB_NET_RNDIS_HOST) += rndis_host.o
15obj-$(CONFIG_USB_NET_CDC_SUBSET) += cdc_subset.o 15obj-$(CONFIG_USB_NET_CDC_SUBSET) += cdc_subset.o
16obj-$(CONFIG_USB_NET_ZAURUS) += zaurus.o 16obj-$(CONFIG_USB_NET_ZAURUS) += zaurus.o
17obj-$(CONFIG_USB_NET_MCS7830) += mcs7830.o
17obj-$(CONFIG_USB_USBNET) += usbnet.o 18obj-$(CONFIG_USB_USBNET) += usbnet.o
18 19
19ifeq ($(CONFIG_USB_DEBUG),y) 20ifeq ($(CONFIG_USB_DEBUG),y)
diff --git a/drivers/usb/net/asix.c b/drivers/usb/net/asix.c
index 9c0eacf7055c..881841e600de 100644
--- a/drivers/usb/net/asix.c
+++ b/drivers/usb/net/asix.c
@@ -214,7 +214,7 @@ static int asix_write_cmd(struct usbnet *dev, u8 cmd, u16 value, u16 index,
214 USB_CTRL_SET_TIMEOUT); 214 USB_CTRL_SET_TIMEOUT);
215} 215}
216 216
217static void asix_async_cmd_callback(struct urb *urb, struct pt_regs *regs) 217static void asix_async_cmd_callback(struct urb *urb)
218{ 218{
219 struct usb_ctrlrequest *req = (struct usb_ctrlrequest *)urb->context; 219 struct usb_ctrlrequest *req = (struct usb_ctrlrequest *)urb->context;
220 220
@@ -569,10 +569,12 @@ static int asix_mdio_read(struct net_device *netdev, int phy_id, int loc)
569 struct usbnet *dev = netdev_priv(netdev); 569 struct usbnet *dev = netdev_priv(netdev);
570 u16 res; 570 u16 res;
571 571
572 mutex_lock(&dev->phy_mutex);
572 asix_set_sw_mii(dev); 573 asix_set_sw_mii(dev);
573 asix_read_cmd(dev, AX_CMD_READ_MII_REG, phy_id, 574 asix_read_cmd(dev, AX_CMD_READ_MII_REG, phy_id,
574 (__u16)loc, 2, (u16 *)&res); 575 (__u16)loc, 2, (u16 *)&res);
575 asix_set_hw_mii(dev); 576 asix_set_hw_mii(dev);
577 mutex_unlock(&dev->phy_mutex);
576 578
577 devdbg(dev, "asix_mdio_read() phy_id=0x%02x, loc=0x%02x, returns=0x%04x", phy_id, loc, le16_to_cpu(res & 0xffff)); 579 devdbg(dev, "asix_mdio_read() phy_id=0x%02x, loc=0x%02x, returns=0x%04x", phy_id, loc, le16_to_cpu(res & 0xffff));
578 580
@@ -586,10 +588,12 @@ asix_mdio_write(struct net_device *netdev, int phy_id, int loc, int val)
586 u16 res = cpu_to_le16(val); 588 u16 res = cpu_to_le16(val);
587 589
588 devdbg(dev, "asix_mdio_write() phy_id=0x%02x, loc=0x%02x, val=0x%04x", phy_id, loc, val); 590 devdbg(dev, "asix_mdio_write() phy_id=0x%02x, loc=0x%02x, val=0x%04x", phy_id, loc, val);
591 mutex_lock(&dev->phy_mutex);
589 asix_set_sw_mii(dev); 592 asix_set_sw_mii(dev);
590 asix_write_cmd(dev, AX_CMD_WRITE_MII_REG, phy_id, 593 asix_write_cmd(dev, AX_CMD_WRITE_MII_REG, phy_id,
591 (__u16)loc, 2, (u16 *)&res); 594 (__u16)loc, 2, (u16 *)&res);
592 asix_set_hw_mii(dev); 595 asix_set_hw_mii(dev);
596 mutex_unlock(&dev->phy_mutex);
593} 597}
594 598
595/* Get the PHY Identifier from the PHYSID1 & PHYSID2 MII registers */ 599/* Get the PHY Identifier from the PHYSID1 & PHYSID2 MII registers */
@@ -700,32 +704,6 @@ static void asix_get_drvinfo (struct net_device *net,
700 info->eedump_len = data->eeprom_len; 704 info->eedump_len = data->eeprom_len;
701} 705}
702 706
703static int asix_get_settings(struct net_device *net, struct ethtool_cmd *cmd)
704{
705 struct usbnet *dev = netdev_priv(net);
706
707 return mii_ethtool_gset(&dev->mii,cmd);
708}
709
710static int asix_set_settings(struct net_device *net, struct ethtool_cmd *cmd)
711{
712 struct usbnet *dev = netdev_priv(net);
713 int res = mii_ethtool_sset(&dev->mii,cmd);
714
715 /* link speed/duplex might have changed */
716 if (dev->driver_info->link_reset)
717 dev->driver_info->link_reset(dev);
718
719 return res;
720}
721
722static int asix_nway_reset(struct net_device *net)
723{
724 struct usbnet *dev = netdev_priv(net);
725
726 return mii_nway_restart(&dev->mii);
727}
728
729static u32 asix_get_link(struct net_device *net) 707static u32 asix_get_link(struct net_device *net)
730{ 708{
731 struct usbnet *dev = netdev_priv(net); 709 struct usbnet *dev = netdev_priv(net);
@@ -746,15 +724,15 @@ static int asix_ioctl (struct net_device *net, struct ifreq *rq, int cmd)
746static struct ethtool_ops ax88172_ethtool_ops = { 724static struct ethtool_ops ax88172_ethtool_ops = {
747 .get_drvinfo = asix_get_drvinfo, 725 .get_drvinfo = asix_get_drvinfo,
748 .get_link = asix_get_link, 726 .get_link = asix_get_link,
749 .nway_reset = asix_nway_reset,
750 .get_msglevel = usbnet_get_msglevel, 727 .get_msglevel = usbnet_get_msglevel,
751 .set_msglevel = usbnet_set_msglevel, 728 .set_msglevel = usbnet_set_msglevel,
752 .get_wol = asix_get_wol, 729 .get_wol = asix_get_wol,
753 .set_wol = asix_set_wol, 730 .set_wol = asix_set_wol,
754 .get_eeprom_len = asix_get_eeprom_len, 731 .get_eeprom_len = asix_get_eeprom_len,
755 .get_eeprom = asix_get_eeprom, 732 .get_eeprom = asix_get_eeprom,
756 .get_settings = asix_get_settings, 733 .get_settings = usbnet_get_settings,
757 .set_settings = asix_set_settings, 734 .set_settings = usbnet_set_settings,
735 .nway_reset = usbnet_nway_reset,
758}; 736};
759 737
760static void ax88172_set_multicast(struct net_device *net) 738static void ax88172_set_multicast(struct net_device *net)
@@ -885,15 +863,15 @@ out1:
885static struct ethtool_ops ax88772_ethtool_ops = { 863static struct ethtool_ops ax88772_ethtool_ops = {
886 .get_drvinfo = asix_get_drvinfo, 864 .get_drvinfo = asix_get_drvinfo,
887 .get_link = asix_get_link, 865 .get_link = asix_get_link,
888 .nway_reset = asix_nway_reset,
889 .get_msglevel = usbnet_get_msglevel, 866 .get_msglevel = usbnet_get_msglevel,
890 .set_msglevel = usbnet_set_msglevel, 867 .set_msglevel = usbnet_set_msglevel,
891 .get_wol = asix_get_wol, 868 .get_wol = asix_get_wol,
892 .set_wol = asix_set_wol, 869 .set_wol = asix_set_wol,
893 .get_eeprom_len = asix_get_eeprom_len, 870 .get_eeprom_len = asix_get_eeprom_len,
894 .get_eeprom = asix_get_eeprom, 871 .get_eeprom = asix_get_eeprom,
895 .get_settings = asix_get_settings, 872 .get_settings = usbnet_get_settings,
896 .set_settings = asix_set_settings, 873 .set_settings = usbnet_set_settings,
874 .nway_reset = usbnet_nway_reset,
897}; 875};
898 876
899static int ax88772_link_reset(struct usbnet *dev) 877static int ax88772_link_reset(struct usbnet *dev)
@@ -1046,15 +1024,15 @@ out1:
1046static struct ethtool_ops ax88178_ethtool_ops = { 1024static struct ethtool_ops ax88178_ethtool_ops = {
1047 .get_drvinfo = asix_get_drvinfo, 1025 .get_drvinfo = asix_get_drvinfo,
1048 .get_link = asix_get_link, 1026 .get_link = asix_get_link,
1049 .nway_reset = asix_nway_reset,
1050 .get_msglevel = usbnet_get_msglevel, 1027 .get_msglevel = usbnet_get_msglevel,
1051 .set_msglevel = usbnet_set_msglevel, 1028 .set_msglevel = usbnet_set_msglevel,
1052 .get_wol = asix_get_wol, 1029 .get_wol = asix_get_wol,
1053 .set_wol = asix_set_wol, 1030 .set_wol = asix_set_wol,
1054 .get_eeprom_len = asix_get_eeprom_len, 1031 .get_eeprom_len = asix_get_eeprom_len,
1055 .get_eeprom = asix_get_eeprom, 1032 .get_eeprom = asix_get_eeprom,
1056 .get_settings = asix_get_settings, 1033 .get_settings = usbnet_get_settings,
1057 .set_settings = asix_set_settings, 1034 .set_settings = usbnet_set_settings,
1035 .nway_reset = usbnet_nway_reset,
1058}; 1036};
1059 1037
1060static int marvell_phy_init(struct usbnet *dev) 1038static int marvell_phy_init(struct usbnet *dev)
diff --git a/drivers/usb/net/catc.c b/drivers/usb/net/catc.c
index be5f5e142dd0..f740325abac4 100644
--- a/drivers/usb/net/catc.c
+++ b/drivers/usb/net/catc.c
@@ -223,7 +223,7 @@ struct catc {
223 * Receive routines. 223 * Receive routines.
224 */ 224 */
225 225
226static void catc_rx_done(struct urb *urb, struct pt_regs *regs) 226static void catc_rx_done(struct urb *urb)
227{ 227{
228 struct catc *catc = urb->context; 228 struct catc *catc = urb->context;
229 u8 *pkt_start = urb->transfer_buffer; 229 u8 *pkt_start = urb->transfer_buffer;
@@ -289,7 +289,7 @@ static void catc_rx_done(struct urb *urb, struct pt_regs *regs)
289 } 289 }
290} 290}
291 291
292static void catc_irq_done(struct urb *urb, struct pt_regs *regs) 292static void catc_irq_done(struct urb *urb)
293{ 293{
294 struct catc *catc = urb->context; 294 struct catc *catc = urb->context;
295 u8 *data = urb->transfer_buffer; 295 u8 *data = urb->transfer_buffer;
@@ -376,7 +376,7 @@ static void catc_tx_run(struct catc *catc)
376 catc->netdev->trans_start = jiffies; 376 catc->netdev->trans_start = jiffies;
377} 377}
378 378
379static void catc_tx_done(struct urb *urb, struct pt_regs *regs) 379static void catc_tx_done(struct urb *urb)
380{ 380{
381 struct catc *catc = urb->context; 381 struct catc *catc = urb->context;
382 unsigned long flags; 382 unsigned long flags;
@@ -486,7 +486,7 @@ static void catc_ctrl_run(struct catc *catc)
486 err("submit(ctrl_urb) status %d", status); 486 err("submit(ctrl_urb) status %d", status);
487} 487}
488 488
489static void catc_ctrl_done(struct urb *urb, struct pt_regs *regs) 489static void catc_ctrl_done(struct urb *urb)
490{ 490{
491 struct catc *catc = urb->context; 491 struct catc *catc = urb->context;
492 struct ctrl_queue *q; 492 struct ctrl_queue *q;
diff --git a/drivers/usb/net/cdc_ether.c b/drivers/usb/net/cdc_ether.c
index 82ce0358d9a3..f6971b88349d 100644
--- a/drivers/usb/net/cdc_ether.c
+++ b/drivers/usb/net/cdc_ether.c
@@ -498,7 +498,7 @@ static struct usb_driver cdc_driver = {
498 498
499static int __init cdc_init(void) 499static int __init cdc_init(void)
500{ 500{
501 BUG_ON((sizeof(((struct usbnet *)0)->data) 501 BUILD_BUG_ON((sizeof(((struct usbnet *)0)->data)
502 < sizeof(struct cdc_state))); 502 < sizeof(struct cdc_state)));
503 503
504 return usb_register(&cdc_driver); 504 return usb_register(&cdc_driver);
diff --git a/drivers/usb/net/gl620a.c b/drivers/usb/net/gl620a.c
index 3155f25f1d48..a3242be21959 100644
--- a/drivers/usb/net/gl620a.c
+++ b/drivers/usb/net/gl620a.c
@@ -106,7 +106,7 @@ static inline int gl_control_write(struct usbnet *dev, u8 request, u16 value)
106 return retval; 106 return retval;
107} 107}
108 108
109static void gl_interrupt_complete(struct urb *urb, struct pt_regs *regs) 109static void gl_interrupt_complete(struct urb *urb)
110{ 110{
111 int status = urb->status; 111 int status = urb->status;
112 112
diff --git a/drivers/usb/net/kaweth.c b/drivers/usb/net/kaweth.c
index 544d41fe9b92..7c906a43e497 100644
--- a/drivers/usb/net/kaweth.c
+++ b/drivers/usb/net/kaweth.c
@@ -65,16 +65,6 @@
65 65
66#undef DEBUG 66#undef DEBUG
67 67
68#ifdef DEBUG
69#define kaweth_dbg(format, arg...) printk(KERN_DEBUG __FILE__ ": " format "\n" ,##arg)
70#else
71#define kaweth_dbg(format, arg...) do {} while (0)
72#endif
73#define kaweth_err(format, arg...) printk(KERN_ERR __FILE__ ": " format "\n" ,##arg)
74#define kaweth_info(format, arg...) printk(KERN_INFO __FILE__ ": " format "\n" , ##arg)
75#define kaweth_warn(format, arg...) printk(KERN_WARNING __FILE__ ": " format "\n" , ##arg)
76
77
78#include "kawethfw.h" 68#include "kawethfw.h"
79 69
80#define KAWETH_MTU 1514 70#define KAWETH_MTU 1514
@@ -86,6 +76,9 @@
86 76
87#define KAWETH_STATUS_BROKEN 0x0000001 77#define KAWETH_STATUS_BROKEN 0x0000001
88#define KAWETH_STATUS_CLOSING 0x0000002 78#define KAWETH_STATUS_CLOSING 0x0000002
79#define KAWETH_STATUS_SUSPENDING 0x0000004
80
81#define KAWETH_STATUS_BLOCKED (KAWETH_STATUS_CLOSING | KAWETH_STATUS_SUSPENDING)
89 82
90#define KAWETH_PACKET_FILTER_PROMISCUOUS 0x01 83#define KAWETH_PACKET_FILTER_PROMISCUOUS 0x01
91#define KAWETH_PACKET_FILTER_ALL_MULTICAST 0x02 84#define KAWETH_PACKET_FILTER_ALL_MULTICAST 0x02
@@ -112,6 +105,8 @@
112#define STATE_MASK 0x40 105#define STATE_MASK 0x40
113#define STATE_SHIFT 5 106#define STATE_SHIFT 5
114 107
108#define IS_BLOCKED(s) (s & KAWETH_STATUS_BLOCKED)
109
115 110
116MODULE_AUTHOR("Michael Zappe <zapman@interlan.net>, Stephane Alnet <stephane@u-picardie.fr>, Brad Hards <bhards@bigpond.net.au> and Oliver Neukum <oliver@neukum.org>"); 111MODULE_AUTHOR("Michael Zappe <zapman@interlan.net>, Stephane Alnet <stephane@u-picardie.fr>, Brad Hards <bhards@bigpond.net.au> and Oliver Neukum <oliver@neukum.org>");
117MODULE_DESCRIPTION("KL5USB101 USB Ethernet driver"); 112MODULE_DESCRIPTION("KL5USB101 USB Ethernet driver");
@@ -128,6 +123,8 @@ static int kaweth_internal_control_msg(struct usb_device *usb_dev,
128 unsigned int pipe, 123 unsigned int pipe,
129 struct usb_ctrlrequest *cmd, void *data, 124 struct usb_ctrlrequest *cmd, void *data,
130 int len, int timeout); 125 int len, int timeout);
126static int kaweth_suspend(struct usb_interface *intf, pm_message_t message);
127static int kaweth_resume(struct usb_interface *intf);
131 128
132/**************************************************************** 129/****************************************************************
133 * usb_device_id 130 * usb_device_id
@@ -179,6 +176,8 @@ static struct usb_driver kaweth_driver = {
179 .name = driver_name, 176 .name = driver_name,
180 .probe = kaweth_probe, 177 .probe = kaweth_probe,
181 .disconnect = kaweth_disconnect, 178 .disconnect = kaweth_disconnect,
179 .suspend = kaweth_suspend,
180 .resume = kaweth_resume,
182 .id_table = usb_klsi_table, 181 .id_table = usb_klsi_table,
183}; 182};
184 183
@@ -222,6 +221,7 @@ struct kaweth_device
222 int suspend_lowmem_rx; 221 int suspend_lowmem_rx;
223 int suspend_lowmem_ctrl; 222 int suspend_lowmem_ctrl;
224 int linkstate; 223 int linkstate;
224 int opened;
225 struct work_struct lowmem_work; 225 struct work_struct lowmem_work;
226 226
227 struct usb_device *dev; 227 struct usb_device *dev;
@@ -265,17 +265,17 @@ static int kaweth_control(struct kaweth_device *kaweth,
265{ 265{
266 struct usb_ctrlrequest *dr; 266 struct usb_ctrlrequest *dr;
267 267
268 kaweth_dbg("kaweth_control()"); 268 dbg("kaweth_control()");
269 269
270 if(in_interrupt()) { 270 if(in_interrupt()) {
271 kaweth_dbg("in_interrupt()"); 271 dbg("in_interrupt()");
272 return -EBUSY; 272 return -EBUSY;
273 } 273 }
274 274
275 dr = kmalloc(sizeof(struct usb_ctrlrequest), GFP_ATOMIC); 275 dr = kmalloc(sizeof(struct usb_ctrlrequest), GFP_ATOMIC);
276 276
277 if (!dr) { 277 if (!dr) {
278 kaweth_dbg("kmalloc() failed"); 278 dbg("kmalloc() failed");
279 return -ENOMEM; 279 return -ENOMEM;
280 } 280 }
281 281
@@ -300,7 +300,7 @@ static int kaweth_read_configuration(struct kaweth_device *kaweth)
300{ 300{
301 int retval; 301 int retval;
302 302
303 kaweth_dbg("Reading kaweth configuration"); 303 dbg("Reading kaweth configuration");
304 304
305 retval = kaweth_control(kaweth, 305 retval = kaweth_control(kaweth,
306 usb_rcvctrlpipe(kaweth->dev, 0), 306 usb_rcvctrlpipe(kaweth->dev, 0),
@@ -322,7 +322,7 @@ static int kaweth_set_urb_size(struct kaweth_device *kaweth, __u16 urb_size)
322{ 322{
323 int retval; 323 int retval;
324 324
325 kaweth_dbg("Setting URB size to %d", (unsigned)urb_size); 325 dbg("Setting URB size to %d", (unsigned)urb_size);
326 326
327 retval = kaweth_control(kaweth, 327 retval = kaweth_control(kaweth,
328 usb_sndctrlpipe(kaweth->dev, 0), 328 usb_sndctrlpipe(kaweth->dev, 0),
@@ -344,7 +344,7 @@ static int kaweth_set_sofs_wait(struct kaweth_device *kaweth, __u16 sofs_wait)
344{ 344{
345 int retval; 345 int retval;
346 346
347 kaweth_dbg("Set SOFS wait to %d", (unsigned)sofs_wait); 347 dbg("Set SOFS wait to %d", (unsigned)sofs_wait);
348 348
349 retval = kaweth_control(kaweth, 349 retval = kaweth_control(kaweth,
350 usb_sndctrlpipe(kaweth->dev, 0), 350 usb_sndctrlpipe(kaweth->dev, 0),
@@ -367,7 +367,7 @@ static int kaweth_set_receive_filter(struct kaweth_device *kaweth,
367{ 367{
368 int retval; 368 int retval;
369 369
370 kaweth_dbg("Set receive filter to %d", (unsigned)receive_filter); 370 dbg("Set receive filter to %d", (unsigned)receive_filter);
371 371
372 retval = kaweth_control(kaweth, 372 retval = kaweth_control(kaweth,
373 usb_sndctrlpipe(kaweth->dev, 0), 373 usb_sndctrlpipe(kaweth->dev, 0),
@@ -392,7 +392,7 @@ static int kaweth_download_firmware(struct kaweth_device *kaweth,
392 __u8 type) 392 __u8 type)
393{ 393{
394 if(data_len > KAWETH_FIRMWARE_BUF_SIZE) { 394 if(data_len > KAWETH_FIRMWARE_BUF_SIZE) {
395 kaweth_err("Firmware too big: %d", data_len); 395 err("Firmware too big: %d", data_len);
396 return -ENOSPC; 396 return -ENOSPC;
397 } 397 }
398 398
@@ -403,13 +403,13 @@ static int kaweth_download_firmware(struct kaweth_device *kaweth,
403 kaweth->firmware_buf[4] = type; 403 kaweth->firmware_buf[4] = type;
404 kaweth->firmware_buf[5] = interrupt; 404 kaweth->firmware_buf[5] = interrupt;
405 405
406 kaweth_dbg("High: %i, Low:%i", kaweth->firmware_buf[3], 406 dbg("High: %i, Low:%i", kaweth->firmware_buf[3],
407 kaweth->firmware_buf[2]); 407 kaweth->firmware_buf[2]);
408 408
409 kaweth_dbg("Downloading firmware at %p to kaweth device at %p", 409 dbg("Downloading firmware at %p to kaweth device at %p",
410 data, 410 data,
411 kaweth); 411 kaweth);
412 kaweth_dbg("Firmware length: %d", data_len); 412 dbg("Firmware length: %d", data_len);
413 413
414 return kaweth_control(kaweth, 414 return kaweth_control(kaweth,
415 usb_sndctrlpipe(kaweth->dev, 0), 415 usb_sndctrlpipe(kaweth->dev, 0),
@@ -437,7 +437,7 @@ static int kaweth_trigger_firmware(struct kaweth_device *kaweth,
437 kaweth->firmware_buf[6] = 0x00; 437 kaweth->firmware_buf[6] = 0x00;
438 kaweth->firmware_buf[7] = 0x00; 438 kaweth->firmware_buf[7] = 0x00;
439 439
440 kaweth_dbg("Triggering firmware"); 440 dbg("Triggering firmware");
441 441
442 return kaweth_control(kaweth, 442 return kaweth_control(kaweth,
443 usb_sndctrlpipe(kaweth->dev, 0), 443 usb_sndctrlpipe(kaweth->dev, 0),
@@ -457,7 +457,7 @@ static int kaweth_reset(struct kaweth_device *kaweth)
457{ 457{
458 int result; 458 int result;
459 459
460 kaweth_dbg("kaweth_reset(%p)", kaweth); 460 dbg("kaweth_reset(%p)", kaweth);
461 result = kaweth_control(kaweth, 461 result = kaweth_control(kaweth,
462 usb_sndctrlpipe(kaweth->dev, 0), 462 usb_sndctrlpipe(kaweth->dev, 0),
463 USB_REQ_SET_CONFIGURATION, 463 USB_REQ_SET_CONFIGURATION,
@@ -470,12 +470,12 @@ static int kaweth_reset(struct kaweth_device *kaweth)
470 470
471 mdelay(10); 471 mdelay(10);
472 472
473 kaweth_dbg("kaweth_reset() returns %d.",result); 473 dbg("kaweth_reset() returns %d.",result);
474 474
475 return result; 475 return result;
476} 476}
477 477
478static void kaweth_usb_receive(struct urb *, struct pt_regs *regs); 478static void kaweth_usb_receive(struct urb *);
479static int kaweth_resubmit_rx_urb(struct kaweth_device *, gfp_t); 479static int kaweth_resubmit_rx_urb(struct kaweth_device *, gfp_t);
480 480
481/**************************************************************** 481/****************************************************************
@@ -500,7 +500,7 @@ static void kaweth_resubmit_int_urb(struct kaweth_device *kaweth, gfp_t mf)
500 kaweth->dev->devpath, status); 500 kaweth->dev->devpath, status);
501} 501}
502 502
503static void int_callback(struct urb *u, struct pt_regs *regs) 503static void int_callback(struct urb *u)
504{ 504{
505 struct kaweth_device *kaweth = u->context; 505 struct kaweth_device *kaweth = u->context;
506 int act_state; 506 int act_state;
@@ -534,7 +534,7 @@ static void kaweth_resubmit_tl(void *d)
534{ 534{
535 struct kaweth_device *kaweth = (struct kaweth_device *)d; 535 struct kaweth_device *kaweth = (struct kaweth_device *)d;
536 536
537 if (kaweth->status | KAWETH_STATUS_CLOSING) 537 if (IS_BLOCKED(kaweth->status))
538 return; 538 return;
539 539
540 if (kaweth->suspend_lowmem_rx) 540 if (kaweth->suspend_lowmem_rx)
@@ -568,7 +568,7 @@ static int kaweth_resubmit_rx_urb(struct kaweth_device *kaweth,
568 kaweth->suspend_lowmem_rx = 1; 568 kaweth->suspend_lowmem_rx = 1;
569 schedule_delayed_work(&kaweth->lowmem_work, HZ/4); 569 schedule_delayed_work(&kaweth->lowmem_work, HZ/4);
570 } 570 }
571 kaweth_err("resubmitting rx_urb %d failed", result); 571 err("resubmitting rx_urb %d failed", result);
572 } else { 572 } else {
573 kaweth->suspend_lowmem_rx = 0; 573 kaweth->suspend_lowmem_rx = 0;
574 } 574 }
@@ -581,7 +581,7 @@ static void kaweth_async_set_rx_mode(struct kaweth_device *kaweth);
581/**************************************************************** 581/****************************************************************
582 * kaweth_usb_receive 582 * kaweth_usb_receive
583 ****************************************************************/ 583 ****************************************************************/
584static void kaweth_usb_receive(struct urb *urb, struct pt_regs *regs) 584static void kaweth_usb_receive(struct urb *urb)
585{ 585{
586 struct kaweth_device *kaweth = urb->context; 586 struct kaweth_device *kaweth = urb->context;
587 struct net_device *net = kaweth->net; 587 struct net_device *net = kaweth->net;
@@ -601,11 +601,15 @@ static void kaweth_usb_receive(struct urb *urb, struct pt_regs *regs)
601 return; 601 return;
602 } 602 }
603 603
604 if (kaweth->status & KAWETH_STATUS_CLOSING) 604 spin_lock(&kaweth->device_lock);
605 if (IS_BLOCKED(kaweth->status)) {
606 spin_unlock(&kaweth->device_lock);
605 return; 607 return;
608 }
609 spin_unlock(&kaweth->device_lock);
606 610
607 if(urb->status && urb->status != -EREMOTEIO && count != 1) { 611 if(urb->status && urb->status != -EREMOTEIO && count != 1) {
608 kaweth_err("%s RX status: %d count: %d packet_len: %d", 612 err("%s RX status: %d count: %d packet_len: %d",
609 net->name, 613 net->name,
610 urb->status, 614 urb->status,
611 count, 615 count,
@@ -616,9 +620,9 @@ static void kaweth_usb_receive(struct urb *urb, struct pt_regs *regs)
616 620
617 if(kaweth->net && (count > 2)) { 621 if(kaweth->net && (count > 2)) {
618 if(pkt_len > (count - 2)) { 622 if(pkt_len > (count - 2)) {
619 kaweth_err("Packet length too long for USB frame (pkt_len: %x, count: %x)",pkt_len, count); 623 err("Packet length too long for USB frame (pkt_len: %x, count: %x)",pkt_len, count);
620 kaweth_err("Packet len & 2047: %x", pkt_len & 2047); 624 err("Packet len & 2047: %x", pkt_len & 2047);
621 kaweth_err("Count 2: %x", count2); 625 err("Count 2: %x", count2);
622 kaweth_resubmit_rx_urb(kaweth, GFP_ATOMIC); 626 kaweth_resubmit_rx_urb(kaweth, GFP_ATOMIC);
623 return; 627 return;
624 } 628 }
@@ -655,7 +659,7 @@ static int kaweth_open(struct net_device *net)
655 struct kaweth_device *kaweth = netdev_priv(net); 659 struct kaweth_device *kaweth = netdev_priv(net);
656 int res; 660 int res;
657 661
658 kaweth_dbg("Opening network device."); 662 dbg("Opening network device.");
659 663
660 res = kaweth_resubmit_rx_urb(kaweth, GFP_KERNEL); 664 res = kaweth_resubmit_rx_urb(kaweth, GFP_KERNEL);
661 if (res) 665 if (res)
@@ -678,6 +682,7 @@ static int kaweth_open(struct net_device *net)
678 usb_kill_urb(kaweth->rx_urb); 682 usb_kill_urb(kaweth->rx_urb);
679 return -EIO; 683 return -EIO;
680 } 684 }
685 kaweth->opened = 1;
681 686
682 netif_start_queue(net); 687 netif_start_queue(net);
683 688
@@ -688,14 +693,8 @@ static int kaweth_open(struct net_device *net)
688/**************************************************************** 693/****************************************************************
689 * kaweth_close 694 * kaweth_close
690 ****************************************************************/ 695 ****************************************************************/
691static int kaweth_close(struct net_device *net) 696static void kaweth_kill_urbs(struct kaweth_device *kaweth)
692{ 697{
693 struct kaweth_device *kaweth = netdev_priv(net);
694
695 netif_stop_queue(net);
696
697 kaweth->status |= KAWETH_STATUS_CLOSING;
698
699 usb_kill_urb(kaweth->irq_urb); 698 usb_kill_urb(kaweth->irq_urb);
700 usb_kill_urb(kaweth->rx_urb); 699 usb_kill_urb(kaweth->rx_urb);
701 usb_kill_urb(kaweth->tx_urb); 700 usb_kill_urb(kaweth->tx_urb);
@@ -706,6 +705,21 @@ static int kaweth_close(struct net_device *net)
706 we hit them again */ 705 we hit them again */
707 usb_kill_urb(kaweth->irq_urb); 706 usb_kill_urb(kaweth->irq_urb);
708 usb_kill_urb(kaweth->rx_urb); 707 usb_kill_urb(kaweth->rx_urb);
708}
709
710/****************************************************************
711 * kaweth_close
712 ****************************************************************/
713static int kaweth_close(struct net_device *net)
714{
715 struct kaweth_device *kaweth = netdev_priv(net);
716
717 netif_stop_queue(net);
718 kaweth->opened = 0;
719
720 kaweth->status |= KAWETH_STATUS_CLOSING;
721
722 kaweth_kill_urbs(kaweth);
709 723
710 kaweth->status &= ~KAWETH_STATUS_CLOSING; 724 kaweth->status &= ~KAWETH_STATUS_CLOSING;
711 725
@@ -725,14 +739,14 @@ static struct ethtool_ops ops = {
725/**************************************************************** 739/****************************************************************
726 * kaweth_usb_transmit_complete 740 * kaweth_usb_transmit_complete
727 ****************************************************************/ 741 ****************************************************************/
728static void kaweth_usb_transmit_complete(struct urb *urb, struct pt_regs *regs) 742static void kaweth_usb_transmit_complete(struct urb *urb)
729{ 743{
730 struct kaweth_device *kaweth = urb->context; 744 struct kaweth_device *kaweth = urb->context;
731 struct sk_buff *skb = kaweth->tx_skb; 745 struct sk_buff *skb = kaweth->tx_skb;
732 746
733 if (unlikely(urb->status != 0)) 747 if (unlikely(urb->status != 0))
734 if (urb->status != -ENOENT) 748 if (urb->status != -ENOENT)
735 kaweth_dbg("%s: TX status %d.", kaweth->net->name, urb->status); 749 dbg("%s: TX status %d.", kaweth->net->name, urb->status);
736 750
737 netif_wake_queue(kaweth->net); 751 netif_wake_queue(kaweth->net);
738 dev_kfree_skb_irq(skb); 752 dev_kfree_skb_irq(skb);
@@ -752,6 +766,9 @@ static int kaweth_start_xmit(struct sk_buff *skb, struct net_device *net)
752 766
753 kaweth_async_set_rx_mode(kaweth); 767 kaweth_async_set_rx_mode(kaweth);
754 netif_stop_queue(net); 768 netif_stop_queue(net);
769 if (IS_BLOCKED(kaweth->status)) {
770 goto skip;
771 }
755 772
756 /* We now decide whether we can put our special header into the sk_buff */ 773 /* We now decide whether we can put our special header into the sk_buff */
757 if (skb_cloned(skb) || skb_headroom(skb) < 2) { 774 if (skb_cloned(skb) || skb_headroom(skb) < 2) {
@@ -783,7 +800,8 @@ static int kaweth_start_xmit(struct sk_buff *skb, struct net_device *net)
783 800
784 if((res = usb_submit_urb(kaweth->tx_urb, GFP_ATOMIC))) 801 if((res = usb_submit_urb(kaweth->tx_urb, GFP_ATOMIC)))
785 { 802 {
786 kaweth_warn("kaweth failed tx_urb %d", res); 803 warn("kaweth failed tx_urb %d", res);
804skip:
787 kaweth->stats.tx_errors++; 805 kaweth->stats.tx_errors++;
788 806
789 netif_start_queue(net); 807 netif_start_queue(net);
@@ -812,7 +830,7 @@ static void kaweth_set_rx_mode(struct net_device *net)
812 KAWETH_PACKET_FILTER_BROADCAST | 830 KAWETH_PACKET_FILTER_BROADCAST |
813 KAWETH_PACKET_FILTER_MULTICAST; 831 KAWETH_PACKET_FILTER_MULTICAST;
814 832
815 kaweth_dbg("Setting Rx mode to %d", packet_filter_bitmap); 833 dbg("Setting Rx mode to %d", packet_filter_bitmap);
816 834
817 netif_stop_queue(net); 835 netif_stop_queue(net);
818 836
@@ -850,10 +868,10 @@ static void kaweth_async_set_rx_mode(struct kaweth_device *kaweth)
850 KAWETH_CONTROL_TIMEOUT); 868 KAWETH_CONTROL_TIMEOUT);
851 869
852 if(result < 0) { 870 if(result < 0) {
853 kaweth_err("Failed to set Rx mode: %d", result); 871 err("Failed to set Rx mode: %d", result);
854 } 872 }
855 else { 873 else {
856 kaweth_dbg("Set Rx mode to %d", packet_filter_bitmap); 874 dbg("Set Rx mode to %d", packet_filter_bitmap);
857 } 875 }
858 } 876 }
859} 877}
@@ -874,7 +892,7 @@ static void kaweth_tx_timeout(struct net_device *net)
874{ 892{
875 struct kaweth_device *kaweth = netdev_priv(net); 893 struct kaweth_device *kaweth = netdev_priv(net);
876 894
877 kaweth_warn("%s: Tx timed out. Resetting.", net->name); 895 warn("%s: Tx timed out. Resetting.", net->name);
878 kaweth->stats.tx_errors++; 896 kaweth->stats.tx_errors++;
879 net->trans_start = jiffies; 897 net->trans_start = jiffies;
880 898
@@ -882,6 +900,42 @@ static void kaweth_tx_timeout(struct net_device *net)
882} 900}
883 901
884/**************************************************************** 902/****************************************************************
903 * kaweth_suspend
904 ****************************************************************/
905static int kaweth_suspend(struct usb_interface *intf, pm_message_t message)
906{
907 struct kaweth_device *kaweth = usb_get_intfdata(intf);
908 unsigned long flags;
909
910 spin_lock_irqsave(&kaweth->device_lock, flags);
911 kaweth->status |= KAWETH_STATUS_SUSPENDING;
912 spin_unlock_irqrestore(&kaweth->device_lock, flags);
913
914 kaweth_kill_urbs(kaweth);
915 return 0;
916}
917
918/****************************************************************
919 * kaweth_resume
920 ****************************************************************/
921static int kaweth_resume(struct usb_interface *intf)
922{
923 struct kaweth_device *kaweth = usb_get_intfdata(intf);
924 unsigned long flags;
925
926 spin_lock_irqsave(&kaweth->device_lock, flags);
927 kaweth->status &= ~KAWETH_STATUS_SUSPENDING;
928 spin_unlock_irqrestore(&kaweth->device_lock, flags);
929
930 if (!kaweth->opened)
931 return 0;
932 kaweth_resubmit_rx_urb(kaweth, GFP_NOIO);
933 kaweth_resubmit_int_urb(kaweth, GFP_NOIO);
934
935 return 0;
936}
937
938/****************************************************************
885 * kaweth_probe 939 * kaweth_probe
886 ****************************************************************/ 940 ****************************************************************/
887static int kaweth_probe( 941static int kaweth_probe(
@@ -895,15 +949,15 @@ static int kaweth_probe(
895 const eth_addr_t bcast_addr = { 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF }; 949 const eth_addr_t bcast_addr = { 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF };
896 int result = 0; 950 int result = 0;
897 951
898 kaweth_dbg("Kawasaki Device Probe (Device number:%d): 0x%4.4x:0x%4.4x:0x%4.4x", 952 dbg("Kawasaki Device Probe (Device number:%d): 0x%4.4x:0x%4.4x:0x%4.4x",
899 dev->devnum, 953 dev->devnum,
900 le16_to_cpu(dev->descriptor.idVendor), 954 le16_to_cpu(dev->descriptor.idVendor),
901 le16_to_cpu(dev->descriptor.idProduct), 955 le16_to_cpu(dev->descriptor.idProduct),
902 le16_to_cpu(dev->descriptor.bcdDevice)); 956 le16_to_cpu(dev->descriptor.bcdDevice));
903 957
904 kaweth_dbg("Device at %p", dev); 958 dbg("Device at %p", dev);
905 959
906 kaweth_dbg("Descriptor length: %x type: %x", 960 dbg("Descriptor length: %x type: %x",
907 (int)dev->descriptor.bLength, 961 (int)dev->descriptor.bLength,
908 (int)dev->descriptor.bDescriptorType); 962 (int)dev->descriptor.bDescriptorType);
909 963
@@ -918,7 +972,7 @@ static int kaweth_probe(
918 spin_lock_init(&kaweth->device_lock); 972 spin_lock_init(&kaweth->device_lock);
919 init_waitqueue_head(&kaweth->term_wait); 973 init_waitqueue_head(&kaweth->term_wait);
920 974
921 kaweth_dbg("Resetting."); 975 dbg("Resetting.");
922 976
923 kaweth_reset(kaweth); 977 kaweth_reset(kaweth);
924 978
@@ -928,17 +982,17 @@ static int kaweth_probe(
928 */ 982 */
929 983
930 if (le16_to_cpu(dev->descriptor.bcdDevice) >> 8) { 984 if (le16_to_cpu(dev->descriptor.bcdDevice) >> 8) {
931 kaweth_info("Firmware present in device."); 985 info("Firmware present in device.");
932 } else { 986 } else {
933 /* Download the firmware */ 987 /* Download the firmware */
934 kaweth_info("Downloading firmware..."); 988 info("Downloading firmware...");
935 kaweth->firmware_buf = (__u8 *)__get_free_page(GFP_KERNEL); 989 kaweth->firmware_buf = (__u8 *)__get_free_page(GFP_KERNEL);
936 if ((result = kaweth_download_firmware(kaweth, 990 if ((result = kaweth_download_firmware(kaweth,
937 kaweth_new_code, 991 kaweth_new_code,
938 len_kaweth_new_code, 992 len_kaweth_new_code,
939 100, 993 100,
940 2)) < 0) { 994 2)) < 0) {
941 kaweth_err("Error downloading firmware (%d)", result); 995 err("Error downloading firmware (%d)", result);
942 goto err_fw; 996 goto err_fw;
943 } 997 }
944 998
@@ -947,7 +1001,7 @@ static int kaweth_probe(
947 len_kaweth_new_code_fix, 1001 len_kaweth_new_code_fix,
948 100, 1002 100,
949 3)) < 0) { 1003 3)) < 0) {
950 kaweth_err("Error downloading firmware fix (%d)", result); 1004 err("Error downloading firmware fix (%d)", result);
951 goto err_fw; 1005 goto err_fw;
952 } 1006 }
953 1007
@@ -956,7 +1010,7 @@ static int kaweth_probe(
956 len_kaweth_trigger_code, 1010 len_kaweth_trigger_code,
957 126, 1011 126,
958 2)) < 0) { 1012 2)) < 0) {
959 kaweth_err("Error downloading trigger code (%d)", result); 1013 err("Error downloading trigger code (%d)", result);
960 goto err_fw; 1014 goto err_fw;
961 1015
962 } 1016 }
@@ -966,18 +1020,18 @@ static int kaweth_probe(
966 len_kaweth_trigger_code_fix, 1020 len_kaweth_trigger_code_fix,
967 126, 1021 126,
968 3)) < 0) { 1022 3)) < 0) {
969 kaweth_err("Error downloading trigger code fix (%d)", result); 1023 err("Error downloading trigger code fix (%d)", result);
970 goto err_fw; 1024 goto err_fw;
971 } 1025 }
972 1026
973 1027
974 if ((result = kaweth_trigger_firmware(kaweth, 126)) < 0) { 1028 if ((result = kaweth_trigger_firmware(kaweth, 126)) < 0) {
975 kaweth_err("Error triggering firmware (%d)", result); 1029 err("Error triggering firmware (%d)", result);
976 goto err_fw; 1030 goto err_fw;
977 } 1031 }
978 1032
979 /* Device will now disappear for a moment... */ 1033 /* Device will now disappear for a moment... */
980 kaweth_info("Firmware loaded. I'll be back..."); 1034 info("Firmware loaded. I'll be back...");
981err_fw: 1035err_fw:
982 free_page((unsigned long)kaweth->firmware_buf); 1036 free_page((unsigned long)kaweth->firmware_buf);
983 free_netdev(netdev); 1037 free_netdev(netdev);
@@ -987,14 +1041,14 @@ err_fw:
987 result = kaweth_read_configuration(kaweth); 1041 result = kaweth_read_configuration(kaweth);
988 1042
989 if(result < 0) { 1043 if(result < 0) {
990 kaweth_err("Error reading configuration (%d), no net device created", result); 1044 err("Error reading configuration (%d), no net device created", result);
991 goto err_free_netdev; 1045 goto err_free_netdev;
992 } 1046 }
993 1047
994 kaweth_info("Statistics collection: %x", kaweth->configuration.statistics_mask); 1048 info("Statistics collection: %x", kaweth->configuration.statistics_mask);
995 kaweth_info("Multicast filter limit: %x", kaweth->configuration.max_multicast_filters & ((1 << 15) - 1)); 1049 info("Multicast filter limit: %x", kaweth->configuration.max_multicast_filters & ((1 << 15) - 1));
996 kaweth_info("MTU: %d", le16_to_cpu(kaweth->configuration.segment_size)); 1050 info("MTU: %d", le16_to_cpu(kaweth->configuration.segment_size));
997 kaweth_info("Read MAC address %2.2x:%2.2x:%2.2x:%2.2x:%2.2x:%2.2x", 1051 info("Read MAC address %2.2x:%2.2x:%2.2x:%2.2x:%2.2x:%2.2x",
998 (int)kaweth->configuration.hw_addr[0], 1052 (int)kaweth->configuration.hw_addr[0],
999 (int)kaweth->configuration.hw_addr[1], 1053 (int)kaweth->configuration.hw_addr[1],
1000 (int)kaweth->configuration.hw_addr[2], 1054 (int)kaweth->configuration.hw_addr[2],
@@ -1005,17 +1059,17 @@ err_fw:
1005 if(!memcmp(&kaweth->configuration.hw_addr, 1059 if(!memcmp(&kaweth->configuration.hw_addr,
1006 &bcast_addr, 1060 &bcast_addr,
1007 sizeof(bcast_addr))) { 1061 sizeof(bcast_addr))) {
1008 kaweth_err("Firmware not functioning properly, no net device created"); 1062 err("Firmware not functioning properly, no net device created");
1009 goto err_free_netdev; 1063 goto err_free_netdev;
1010 } 1064 }
1011 1065
1012 if(kaweth_set_urb_size(kaweth, KAWETH_BUF_SIZE) < 0) { 1066 if(kaweth_set_urb_size(kaweth, KAWETH_BUF_SIZE) < 0) {
1013 kaweth_dbg("Error setting URB size"); 1067 dbg("Error setting URB size");
1014 goto err_free_netdev; 1068 goto err_free_netdev;
1015 } 1069 }
1016 1070
1017 if(kaweth_set_sofs_wait(kaweth, KAWETH_SOFS_TO_WAIT) < 0) { 1071 if(kaweth_set_sofs_wait(kaweth, KAWETH_SOFS_TO_WAIT) < 0) {
1018 kaweth_err("Error setting SOFS wait"); 1072 err("Error setting SOFS wait");
1019 goto err_free_netdev; 1073 goto err_free_netdev;
1020 } 1074 }
1021 1075
@@ -1025,11 +1079,11 @@ err_fw:
1025 KAWETH_PACKET_FILTER_MULTICAST); 1079 KAWETH_PACKET_FILTER_MULTICAST);
1026 1080
1027 if(result < 0) { 1081 if(result < 0) {
1028 kaweth_err("Error setting receive filter"); 1082 err("Error setting receive filter");
1029 goto err_free_netdev; 1083 goto err_free_netdev;
1030 } 1084 }
1031 1085
1032 kaweth_dbg("Initializing net device."); 1086 dbg("Initializing net device.");
1033 1087
1034 kaweth->tx_urb = usb_alloc_urb(0, GFP_KERNEL); 1088 kaweth->tx_urb = usb_alloc_urb(0, GFP_KERNEL);
1035 if (!kaweth->tx_urb) 1089 if (!kaweth->tx_urb)
@@ -1086,13 +1140,13 @@ err_fw:
1086 1140
1087 SET_NETDEV_DEV(netdev, &intf->dev); 1141 SET_NETDEV_DEV(netdev, &intf->dev);
1088 if (register_netdev(netdev) != 0) { 1142 if (register_netdev(netdev) != 0) {
1089 kaweth_err("Error registering netdev."); 1143 err("Error registering netdev.");
1090 goto err_intfdata; 1144 goto err_intfdata;
1091 } 1145 }
1092 1146
1093 kaweth_info("kaweth interface created at %s", kaweth->net->name); 1147 info("kaweth interface created at %s", kaweth->net->name);
1094 1148
1095 kaweth_dbg("Kaweth probe returning."); 1149 dbg("Kaweth probe returning.");
1096 1150
1097 return 0; 1151 return 0;
1098 1152
@@ -1121,16 +1175,16 @@ static void kaweth_disconnect(struct usb_interface *intf)
1121 struct kaweth_device *kaweth = usb_get_intfdata(intf); 1175 struct kaweth_device *kaweth = usb_get_intfdata(intf);
1122 struct net_device *netdev; 1176 struct net_device *netdev;
1123 1177
1124 kaweth_info("Unregistering"); 1178 info("Unregistering");
1125 1179
1126 usb_set_intfdata(intf, NULL); 1180 usb_set_intfdata(intf, NULL);
1127 if (!kaweth) { 1181 if (!kaweth) {
1128 kaweth_warn("unregistering non-existant device"); 1182 warn("unregistering non-existant device");
1129 return; 1183 return;
1130 } 1184 }
1131 netdev = kaweth->net; 1185 netdev = kaweth->net;
1132 1186
1133 kaweth_dbg("Unregistering net device"); 1187 dbg("Unregistering net device");
1134 unregister_netdev(netdev); 1188 unregister_netdev(netdev);
1135 1189
1136 usb_free_urb(kaweth->rx_urb); 1190 usb_free_urb(kaweth->rx_urb);
@@ -1154,7 +1208,7 @@ struct usb_api_data {
1154/*-------------------------------------------------------------------* 1208/*-------------------------------------------------------------------*
1155 * completion handler for compatibility wrappers (sync control/bulk) * 1209 * completion handler for compatibility wrappers (sync control/bulk) *
1156 *-------------------------------------------------------------------*/ 1210 *-------------------------------------------------------------------*/
1157static void usb_api_blocking_completion(struct urb *urb, struct pt_regs *regs) 1211static void usb_api_blocking_completion(struct urb *urb)
1158{ 1212{
1159 struct usb_api_data *awd = (struct usb_api_data *)urb->context; 1213 struct usb_api_data *awd = (struct usb_api_data *)urb->context;
1160 1214
@@ -1185,7 +1239,7 @@ static int usb_start_wait_urb(struct urb *urb, int timeout, int* actual_length)
1185 1239
1186 if (!wait_event_timeout(awd.wqh, awd.done, timeout)) { 1240 if (!wait_event_timeout(awd.wqh, awd.done, timeout)) {
1187 // timeout 1241 // timeout
1188 kaweth_warn("usb_control/bulk_msg: timeout"); 1242 warn("usb_control/bulk_msg: timeout");
1189 usb_kill_urb(urb); // remove urb safely 1243 usb_kill_urb(urb); // remove urb safely
1190 status = -ETIMEDOUT; 1244 status = -ETIMEDOUT;
1191 } 1245 }
@@ -1234,7 +1288,7 @@ static int kaweth_internal_control_msg(struct usb_device *usb_dev,
1234 ****************************************************************/ 1288 ****************************************************************/
1235static int __init kaweth_init(void) 1289static int __init kaweth_init(void)
1236{ 1290{
1237 kaweth_dbg("Driver loading"); 1291 dbg("Driver loading");
1238 return usb_register(&kaweth_driver); 1292 return usb_register(&kaweth_driver);
1239} 1293}
1240 1294
diff --git a/drivers/usb/net/mcs7830.c b/drivers/usb/net/mcs7830.c
new file mode 100644
index 000000000000..6240b978fe3d
--- /dev/null
+++ b/drivers/usb/net/mcs7830.c
@@ -0,0 +1,534 @@
1/*
2 * MosChips MCS7830 based USB 2.0 Ethernet Devices
3 *
4 * based on usbnet.c, asix.c and the vendor provided mcs7830 driver
5 *
6 * Copyright (C) 2006 Arnd Bergmann <arnd@arndb.de>
7 * Copyright (C) 2003-2005 David Hollis <dhollis@davehollis.com>
8 * Copyright (C) 2005 Phil Chang <pchang23@sbcglobal.net>
9 * Copyright (c) 2002-2003 TiVo Inc.
10 *
11 * This program is free software; you can redistribute it and/or modify
12 * it under the terms of the GNU General Public License as published by
13 * the Free Software Foundation; either version 2 of the License, or
14 * (at your option) any later version.
15 *
16 * This program is distributed in the hope that it will be useful,
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 * GNU General Public License for more details.
20 *
21 * You should have received a copy of the GNU General Public License
22 * along with this program; if not, write to the Free Software
23 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
24 */
25
26#include <linux/crc32.h>
27#include <linux/etherdevice.h>
28#include <linux/ethtool.h>
29#include <linux/init.h>
30#include <linux/mii.h>
31#include <linux/module.h>
32#include <linux/netdevice.h>
33#include <linux/usb.h>
34
35#include "usbnet.h"
36
37/* requests */
38#define MCS7830_RD_BMREQ (USB_DIR_IN | USB_TYPE_VENDOR | \
39 USB_RECIP_DEVICE)
40#define MCS7830_WR_BMREQ (USB_DIR_OUT | USB_TYPE_VENDOR | \
41 USB_RECIP_DEVICE)
42#define MCS7830_RD_BREQ 0x0E
43#define MCS7830_WR_BREQ 0x0D
44
45#define MCS7830_CTRL_TIMEOUT 1000
46#define MCS7830_MAX_MCAST 64
47
48#define MCS7830_VENDOR_ID 0x9710
49#define MCS7830_PRODUCT_ID 0x7830
50
51#define MCS7830_MII_ADVERTISE (ADVERTISE_PAUSE_CAP | ADVERTISE_100FULL | \
52 ADVERTISE_100HALF | ADVERTISE_10FULL | \
53 ADVERTISE_10HALF | ADVERTISE_CSMA)
54
55/* HIF_REG_XX coressponding index value */
56enum {
57 HIF_REG_MULTICAST_HASH = 0x00,
58 HIF_REG_PACKET_GAP1 = 0x08,
59 HIF_REG_PACKET_GAP2 = 0x09,
60 HIF_REG_PHY_DATA = 0x0a,
61 HIF_REG_PHY_CMD1 = 0x0c,
62 HIF_REG_PHY_CMD1_READ = 0x40,
63 HIF_REG_PHY_CMD1_WRITE = 0x20,
64 HIF_REG_PHY_CMD1_PHYADDR = 0x01,
65 HIF_REG_PHY_CMD2 = 0x0d,
66 HIF_REG_PHY_CMD2_PEND_FLAG_BIT = 0x80,
67 HIF_REG_PHY_CMD2_READY_FLAG_BIT = 0x40,
68 HIF_REG_CONFIG = 0x0e,
69 HIF_REG_CONFIG_CFG = 0x80,
70 HIF_REG_CONFIG_SPEED100 = 0x40,
71 HIF_REG_CONFIG_FULLDUPLEX_ENABLE = 0x20,
72 HIF_REG_CONFIG_RXENABLE = 0x10,
73 HIF_REG_CONFIG_TXENABLE = 0x08,
74 HIF_REG_CONFIG_SLEEPMODE = 0x04,
75 HIF_REG_CONFIG_ALLMULTICAST = 0x02,
76 HIF_REG_CONFIG_PROMISCIOUS = 0x01,
77 HIF_REG_ETHERNET_ADDR = 0x0f,
78 HIF_REG_22 = 0x15,
79 HIF_REG_PAUSE_THRESHOLD = 0x16,
80 HIF_REG_PAUSE_THRESHOLD_DEFAULT = 0,
81};
82
83struct mcs7830_data {
84 u8 multi_filter[8];
85 u8 config;
86};
87
88static const char driver_name[] = "MOSCHIP usb-ethernet driver";
89
90static int mcs7830_get_reg(struct usbnet *dev, u16 index, u16 size, void *data)
91{
92 struct usb_device *xdev = dev->udev;
93 int ret;
94
95 ret = usb_control_msg(xdev, usb_rcvctrlpipe(xdev, 0), MCS7830_RD_BREQ,
96 MCS7830_RD_BMREQ, 0x0000, index, data,
97 size, msecs_to_jiffies(MCS7830_CTRL_TIMEOUT));
98 return ret;
99}
100
101static int mcs7830_set_reg(struct usbnet *dev, u16 index, u16 size, void *data)
102{
103 struct usb_device *xdev = dev->udev;
104 int ret;
105
106 ret = usb_control_msg(xdev, usb_sndctrlpipe(xdev, 0), MCS7830_WR_BREQ,
107 MCS7830_WR_BMREQ, 0x0000, index, data,
108 size, msecs_to_jiffies(MCS7830_CTRL_TIMEOUT));
109 return ret;
110}
111
112static void mcs7830_async_cmd_callback(struct urb *urb)
113{
114 struct usb_ctrlrequest *req = (struct usb_ctrlrequest *)urb->context;
115
116 if (urb->status < 0)
117 printk(KERN_DEBUG "mcs7830_async_cmd_callback() failed with %d",
118 urb->status);
119
120 kfree(req);
121 usb_free_urb(urb);
122}
123
124static void mcs7830_set_reg_async(struct usbnet *dev, u16 index, u16 size, void *data)
125{
126 struct usb_ctrlrequest *req;
127 int ret;
128 struct urb *urb;
129
130 urb = usb_alloc_urb(0, GFP_ATOMIC);
131 if (!urb) {
132 dev_dbg(&dev->udev->dev, "Error allocating URB "
133 "in write_cmd_async!");
134 return;
135 }
136
137 req = kmalloc(sizeof *req, GFP_ATOMIC);
138 if (!req) {
139 dev_err(&dev->udev->dev, "Failed to allocate memory for "
140 "control request");
141 goto out;
142 }
143 req->bRequestType = MCS7830_WR_BMREQ;
144 req->bRequest = MCS7830_WR_BREQ;
145 req->wValue = 0;
146 req->wIndex = cpu_to_le16(index);
147 req->wLength = cpu_to_le16(size);
148
149 usb_fill_control_urb(urb, dev->udev,
150 usb_sndctrlpipe(dev->udev, 0),
151 (void *)req, data, size,
152 mcs7830_async_cmd_callback, req);
153
154 ret = usb_submit_urb(urb, GFP_ATOMIC);
155 if (ret < 0) {
156 dev_err(&dev->udev->dev, "Error submitting the control "
157 "message: ret=%d", ret);
158 goto out;
159 }
160 return;
161out:
162 kfree(req);
163 usb_free_urb(urb);
164}
165
166static int mcs7830_get_address(struct usbnet *dev)
167{
168 int ret;
169 ret = mcs7830_get_reg(dev, HIF_REG_ETHERNET_ADDR, ETH_ALEN,
170 dev->net->dev_addr);
171 if (ret < 0)
172 return ret;
173 return 0;
174}
175
176static int mcs7830_read_phy(struct usbnet *dev, u8 index)
177{
178 int ret;
179 int i;
180 __le16 val;
181
182 u8 cmd[2] = {
183 HIF_REG_PHY_CMD1_READ | HIF_REG_PHY_CMD1_PHYADDR,
184 HIF_REG_PHY_CMD2_PEND_FLAG_BIT | index,
185 };
186
187 mutex_lock(&dev->phy_mutex);
188 /* write the MII command */
189 ret = mcs7830_set_reg(dev, HIF_REG_PHY_CMD1, 2, cmd);
190 if (ret < 0)
191 goto out;
192
193 /* wait for the data to become valid, should be within < 1ms */
194 for (i = 0; i < 10; i++) {
195 ret = mcs7830_get_reg(dev, HIF_REG_PHY_CMD1, 2, cmd);
196 if ((ret < 0) || (cmd[1] & HIF_REG_PHY_CMD2_READY_FLAG_BIT))
197 break;
198 ret = -EIO;
199 msleep(1);
200 }
201 if (ret < 0)
202 goto out;
203
204 /* read actual register contents */
205 ret = mcs7830_get_reg(dev, HIF_REG_PHY_DATA, 2, &val);
206 if (ret < 0)
207 goto out;
208 ret = le16_to_cpu(val);
209 dev_dbg(&dev->udev->dev, "read PHY reg %02x: %04x (%d tries)\n",
210 index, val, i);
211out:
212 mutex_unlock(&dev->phy_mutex);
213 return ret;
214}
215
216static int mcs7830_write_phy(struct usbnet *dev, u8 index, u16 val)
217{
218 int ret;
219 int i;
220 __le16 le_val;
221
222 u8 cmd[2] = {
223 HIF_REG_PHY_CMD1_WRITE | HIF_REG_PHY_CMD1_PHYADDR,
224 HIF_REG_PHY_CMD2_PEND_FLAG_BIT | (index & 0x1F),
225 };
226
227 mutex_lock(&dev->phy_mutex);
228
229 /* write the new register contents */
230 le_val = cpu_to_le16(val);
231 ret = mcs7830_set_reg(dev, HIF_REG_PHY_DATA, 2, &le_val);
232 if (ret < 0)
233 goto out;
234
235 /* write the MII command */
236 ret = mcs7830_set_reg(dev, HIF_REG_PHY_CMD1, 2, cmd);
237 if (ret < 0)
238 goto out;
239
240 /* wait for the command to be accepted by the PHY */
241 for (i = 0; i < 10; i++) {
242 ret = mcs7830_get_reg(dev, HIF_REG_PHY_CMD1, 2, cmd);
243 if ((ret < 0) || (cmd[1] & HIF_REG_PHY_CMD2_READY_FLAG_BIT))
244 break;
245 ret = -EIO;
246 msleep(1);
247 }
248 if (ret < 0)
249 goto out;
250
251 ret = 0;
252 dev_dbg(&dev->udev->dev, "write PHY reg %02x: %04x (%d tries)\n",
253 index, val, i);
254out:
255 mutex_unlock(&dev->phy_mutex);
256 return ret;
257}
258
259/*
260 * This algorithm comes from the original mcs7830 version 1.4 driver,
261 * not sure if it is needed.
262 */
263static int mcs7830_set_autoneg(struct usbnet *dev, int ptrUserPhyMode)
264{
265 int ret;
266 /* Enable all media types */
267 ret = mcs7830_write_phy(dev, MII_ADVERTISE, MCS7830_MII_ADVERTISE);
268
269 /* First reset BMCR */
270 if (!ret)
271 ret = mcs7830_write_phy(dev, MII_BMCR, 0x0000);
272 /* Enable Auto Neg */
273 if (!ret)
274 ret = mcs7830_write_phy(dev, MII_BMCR, BMCR_ANENABLE);
275 /* Restart Auto Neg (Keep the Enable Auto Neg Bit Set) */
276 if (!ret)
277 ret = mcs7830_write_phy(dev, MII_BMCR,
278 BMCR_ANENABLE | BMCR_ANRESTART );
279 return ret < 0 ? : 0;
280}
281
282
283/*
284 * if we can read register 22, the chip revision is C or higher
285 */
286static int mcs7830_get_rev(struct usbnet *dev)
287{
288 u8 dummy[2];
289 int ret;
290 ret = mcs7830_get_reg(dev, HIF_REG_22, 2, dummy);
291 if (ret > 0)
292 return 2; /* Rev C or later */
293 return 1; /* earlier revision */
294}
295
296/*
297 * On rev. C we need to set the pause threshold
298 */
299static void mcs7830_rev_C_fixup(struct usbnet *dev)
300{
301 u8 pause_threshold = HIF_REG_PAUSE_THRESHOLD_DEFAULT;
302 int retry;
303
304 for (retry = 0; retry < 2; retry++) {
305 if (mcs7830_get_rev(dev) == 2) {
306 dev_info(&dev->udev->dev, "applying rev.C fixup\n");
307 mcs7830_set_reg(dev, HIF_REG_PAUSE_THRESHOLD,
308 1, &pause_threshold);
309 }
310 msleep(1);
311 }
312}
313
314static int mcs7830_init_dev(struct usbnet *dev)
315{
316 int ret;
317 int retry;
318
319 /* Read MAC address from EEPROM */
320 ret = -EINVAL;
321 for (retry = 0; retry < 5 && ret; retry++)
322 ret = mcs7830_get_address(dev);
323 if (ret) {
324 dev_warn(&dev->udev->dev, "Cannot read MAC address\n");
325 goto out;
326 }
327
328 /* Set up PHY */
329 ret = mcs7830_set_autoneg(dev, 0);
330 if (ret) {
331 dev_info(&dev->udev->dev, "Cannot set autoneg\n");
332 goto out;
333 }
334
335 mcs7830_rev_C_fixup(dev);
336 ret = 0;
337out:
338 return ret;
339}
340
341static int mcs7830_mdio_read(struct net_device *netdev, int phy_id,
342 int location)
343{
344 struct usbnet *dev = netdev->priv;
345 return mcs7830_read_phy(dev, location);
346}
347
348static void mcs7830_mdio_write(struct net_device *netdev, int phy_id,
349 int location, int val)
350{
351 struct usbnet *dev = netdev->priv;
352 mcs7830_write_phy(dev, location, val);
353}
354
355static int mcs7830_ioctl(struct net_device *net, struct ifreq *rq, int cmd)
356{
357 struct usbnet *dev = netdev_priv(net);
358 return generic_mii_ioctl(&dev->mii, if_mii(rq), cmd, NULL);
359}
360
361/* credits go to asix_set_multicast */
362static void mcs7830_set_multicast(struct net_device *net)
363{
364 struct usbnet *dev = netdev_priv(net);
365 struct mcs7830_data *data = (struct mcs7830_data *)&dev->data;
366
367 data->config = HIF_REG_CONFIG_TXENABLE;
368
369 /* this should not be needed, but it doesn't work otherwise */
370 data->config |= HIF_REG_CONFIG_ALLMULTICAST;
371
372 if (net->flags & IFF_PROMISC) {
373 data->config |= HIF_REG_CONFIG_PROMISCIOUS;
374 } else if (net->flags & IFF_ALLMULTI
375 || net->mc_count > MCS7830_MAX_MCAST) {
376 data->config |= HIF_REG_CONFIG_ALLMULTICAST;
377 } else if (net->mc_count == 0) {
378 /* just broadcast and directed */
379 } else {
380 /* We use the 20 byte dev->data
381 * for our 8 byte filter buffer
382 * to avoid allocating memory that
383 * is tricky to free later */
384 struct dev_mc_list *mc_list = net->mc_list;
385 u32 crc_bits;
386 int i;
387
388 memset(data->multi_filter, 0, sizeof data->multi_filter);
389
390 /* Build the multicast hash filter. */
391 for (i = 0; i < net->mc_count; i++) {
392 crc_bits = ether_crc(ETH_ALEN, mc_list->dmi_addr) >> 26;
393 data->multi_filter[crc_bits >> 3] |= 1 << (crc_bits & 7);
394 mc_list = mc_list->next;
395 }
396
397 mcs7830_set_reg_async(dev, HIF_REG_MULTICAST_HASH,
398 sizeof data->multi_filter,
399 data->multi_filter);
400 }
401
402 mcs7830_set_reg_async(dev, HIF_REG_CONFIG, 1, &data->config);
403}
404
405static int mcs7830_get_regs_len(struct net_device *net)
406{
407 struct usbnet *dev = netdev_priv(net);
408
409 switch (mcs7830_get_rev(dev)) {
410 case 1:
411 return 21;
412 case 2:
413 return 32;
414 }
415 return 0;
416}
417
418static void mcs7830_get_drvinfo(struct net_device *net, struct ethtool_drvinfo *drvinfo)
419{
420 usbnet_get_drvinfo(net, drvinfo);
421 drvinfo->regdump_len = mcs7830_get_regs_len(net);
422}
423
424static void mcs7830_get_regs(struct net_device *net, struct ethtool_regs *regs, void *data)
425{
426 struct usbnet *dev = netdev_priv(net);
427
428 regs->version = mcs7830_get_rev(dev);
429 mcs7830_get_reg(dev, 0, regs->len, data);
430}
431
432static struct ethtool_ops mcs7830_ethtool_ops = {
433 .get_drvinfo = mcs7830_get_drvinfo,
434 .get_regs_len = mcs7830_get_regs_len,
435 .get_regs = mcs7830_get_regs,
436
437 /* common usbnet calls */
438 .get_link = usbnet_get_link,
439 .get_msglevel = usbnet_get_msglevel,
440 .set_msglevel = usbnet_set_msglevel,
441 .get_settings = usbnet_get_settings,
442 .set_settings = usbnet_set_settings,
443 .nway_reset = usbnet_nway_reset,
444};
445
446static int mcs7830_bind(struct usbnet *dev, struct usb_interface *udev)
447{
448 struct net_device *net = dev->net;
449 int ret;
450
451 ret = mcs7830_init_dev(dev);
452 if (ret)
453 goto out;
454
455 net->do_ioctl = mcs7830_ioctl;
456 net->ethtool_ops = &mcs7830_ethtool_ops;
457 net->set_multicast_list = mcs7830_set_multicast;
458 mcs7830_set_multicast(net);
459
460 /* reserve space for the status byte on rx */
461 dev->rx_urb_size = ETH_FRAME_LEN + 1;
462
463 dev->mii.mdio_read = mcs7830_mdio_read;
464 dev->mii.mdio_write = mcs7830_mdio_write;
465 dev->mii.dev = net;
466 dev->mii.phy_id_mask = 0x3f;
467 dev->mii.reg_num_mask = 0x1f;
468 dev->mii.phy_id = *((u8 *) net->dev_addr + 1);
469
470 ret = usbnet_get_endpoints(dev, udev);
471out:
472 return ret;
473}
474
475/* The chip always appends a status bytes that we need to strip */
476static int mcs7830_rx_fixup(struct usbnet *dev, struct sk_buff *skb)
477{
478 u8 status;
479
480 if (skb->len == 0) {
481 dev_err(&dev->udev->dev, "unexpected empty rx frame\n");
482 return 0;
483 }
484
485 skb_trim(skb, skb->len - 1);
486 status = skb->data[skb->len];
487
488 if (status != 0x20)
489 dev_dbg(&dev->udev->dev, "rx fixup status %x\n", status);
490
491 return skb->len > 0;
492}
493
494static const struct driver_info moschip_info = {
495 .description = "MOSCHIP 7830 usb-NET adapter",
496 .bind = mcs7830_bind,
497 .rx_fixup = mcs7830_rx_fixup,
498 .flags = FLAG_ETHER,
499 .in = 1,
500 .out = 2,
501};
502
503static const struct usb_device_id products[] = {
504 {
505 USB_DEVICE(MCS7830_VENDOR_ID, MCS7830_PRODUCT_ID),
506 .driver_info = (unsigned long) &moschip_info,
507 },
508 {},
509};
510MODULE_DEVICE_TABLE(usb, products);
511
512static struct usb_driver mcs7830_driver = {
513 .name = driver_name,
514 .id_table = products,
515 .probe = usbnet_probe,
516 .disconnect = usbnet_disconnect,
517 .suspend = usbnet_suspend,
518 .resume = usbnet_resume,
519};
520
521static int __init mcs7830_init(void)
522{
523 return usb_register(&mcs7830_driver);
524}
525module_init(mcs7830_init);
526
527static void __exit mcs7830_exit(void)
528{
529 usb_deregister(&mcs7830_driver);
530}
531module_exit(mcs7830_exit);
532
533MODULE_DESCRIPTION("USB to network adapter MCS7830)");
534MODULE_LICENSE("GPL");
diff --git a/drivers/usb/net/net1080.c b/drivers/usb/net/net1080.c
index 301baa72bac7..ce00de8f13a1 100644
--- a/drivers/usb/net/net1080.c
+++ b/drivers/usb/net/net1080.c
@@ -368,7 +368,7 @@ static int net1080_check_connect(struct usbnet *dev)
368 return 0; 368 return 0;
369} 369}
370 370
371static void nc_flush_complete(struct urb *urb, struct pt_regs *regs) 371static void nc_flush_complete(struct urb *urb)
372{ 372{
373 kfree(urb->context); 373 kfree(urb->context);
374 usb_free_urb(urb); 374 usb_free_urb(urb);
diff --git a/drivers/usb/net/pegasus.c b/drivers/usb/net/pegasus.c
index 918cf5a77c08..33abbd2176b6 100644
--- a/drivers/usb/net/pegasus.c
+++ b/drivers/usb/net/pegasus.c
@@ -96,7 +96,7 @@ MODULE_DEVICE_TABLE(usb, pegasus_ids);
96 96
97static int update_eth_regs_async(pegasus_t *); 97static int update_eth_regs_async(pegasus_t *);
98/* Aargh!!! I _really_ hate such tweaks */ 98/* Aargh!!! I _really_ hate such tweaks */
99static void ctrl_callback(struct urb *urb, struct pt_regs *regs) 99static void ctrl_callback(struct urb *urb)
100{ 100{
101 pegasus_t *pegasus = urb->context; 101 pegasus_t *pegasus = urb->context;
102 102
@@ -605,7 +605,7 @@ static inline struct sk_buff *pull_skb(pegasus_t * pegasus)
605 return NULL; 605 return NULL;
606} 606}
607 607
608static void read_bulk_callback(struct urb *urb, struct pt_regs *regs) 608static void read_bulk_callback(struct urb *urb)
609{ 609{
610 pegasus_t *pegasus = urb->context; 610 pegasus_t *pegasus = urb->context;
611 struct net_device *net; 611 struct net_device *net;
@@ -764,7 +764,7 @@ done:
764 spin_unlock_irqrestore(&pegasus->rx_pool_lock, flags); 764 spin_unlock_irqrestore(&pegasus->rx_pool_lock, flags);
765} 765}
766 766
767static void write_bulk_callback(struct urb *urb, struct pt_regs *regs) 767static void write_bulk_callback(struct urb *urb)
768{ 768{
769 pegasus_t *pegasus = urb->context; 769 pegasus_t *pegasus = urb->context;
770 struct net_device *net = pegasus->net; 770 struct net_device *net = pegasus->net;
@@ -801,7 +801,7 @@ static void write_bulk_callback(struct urb *urb, struct pt_regs *regs)
801 netif_wake_queue(net); 801 netif_wake_queue(net);
802} 802}
803 803
804static void intr_callback(struct urb *urb, struct pt_regs *regs) 804static void intr_callback(struct urb *urb)
805{ 805{
806 pegasus_t *pegasus = urb->context; 806 pegasus_t *pegasus = urb->context;
807 struct net_device *net; 807 struct net_device *net;
@@ -1226,7 +1226,7 @@ static void pegasus_set_multicast(struct net_device *net)
1226 } 1226 }
1227 1227
1228 pegasus->flags |= ETH_REGS_CHANGE; 1228 pegasus->flags |= ETH_REGS_CHANGE;
1229 ctrl_callback(pegasus->ctrl_urb, NULL); 1229 ctrl_callback(pegasus->ctrl_urb);
1230} 1230}
1231 1231
1232static __u8 mii_phy_probe(pegasus_t * pegasus) 1232static __u8 mii_phy_probe(pegasus_t * pegasus)
@@ -1433,11 +1433,11 @@ static int pegasus_resume (struct usb_interface *intf)
1433 if (netif_running(pegasus->net)) { 1433 if (netif_running(pegasus->net)) {
1434 pegasus->rx_urb->status = 0; 1434 pegasus->rx_urb->status = 0;
1435 pegasus->rx_urb->actual_length = 0; 1435 pegasus->rx_urb->actual_length = 0;
1436 read_bulk_callback(pegasus->rx_urb, NULL); 1436 read_bulk_callback(pegasus->rx_urb);
1437 1437
1438 pegasus->intr_urb->status = 0; 1438 pegasus->intr_urb->status = 0;
1439 pegasus->intr_urb->actual_length = 0; 1439 pegasus->intr_urb->actual_length = 0;
1440 intr_callback(pegasus->intr_urb, NULL); 1440 intr_callback(pegasus->intr_urb);
1441 } 1441 }
1442 queue_delayed_work(pegasus_workqueue, &pegasus->carrier_check, 1442 queue_delayed_work(pegasus_workqueue, &pegasus->carrier_check,
1443 CARRIER_CHECK_DELAY); 1443 CARRIER_CHECK_DELAY);
diff --git a/drivers/usb/net/rtl8150.c b/drivers/usb/net/rtl8150.c
index 2364c2099387..72171f94ded4 100644
--- a/drivers/usb/net/rtl8150.c
+++ b/drivers/usb/net/rtl8150.c
@@ -208,7 +208,7 @@ static int set_registers(rtl8150_t * dev, u16 indx, u16 size, void *data)
208 indx, 0, data, size, 500); 208 indx, 0, data, size, 500);
209} 209}
210 210
211static void ctrl_callback(struct urb *urb, struct pt_regs *regs) 211static void ctrl_callback(struct urb *urb)
212{ 212{
213 rtl8150_t *dev; 213 rtl8150_t *dev;
214 214
@@ -415,7 +415,7 @@ static inline struct sk_buff *pull_skb(rtl8150_t *dev)
415 return NULL; 415 return NULL;
416} 416}
417 417
418static void read_bulk_callback(struct urb *urb, struct pt_regs *regs) 418static void read_bulk_callback(struct urb *urb)
419{ 419{
420 rtl8150_t *dev; 420 rtl8150_t *dev;
421 unsigned pkt_len, res; 421 unsigned pkt_len, res;
@@ -525,7 +525,7 @@ tlsched:
525 tasklet_schedule(&dev->tl); 525 tasklet_schedule(&dev->tl);
526} 526}
527 527
528static void write_bulk_callback(struct urb *urb, struct pt_regs *regs) 528static void write_bulk_callback(struct urb *urb)
529{ 529{
530 rtl8150_t *dev; 530 rtl8150_t *dev;
531 531
@@ -541,7 +541,7 @@ static void write_bulk_callback(struct urb *urb, struct pt_regs *regs)
541 netif_wake_queue(dev->netdev); 541 netif_wake_queue(dev->netdev);
542} 542}
543 543
544static void intr_callback(struct urb *urb, struct pt_regs *regs) 544static void intr_callback(struct urb *urb)
545{ 545{
546 rtl8150_t *dev; 546 rtl8150_t *dev;
547 __u8 *d; 547 __u8 *d;
@@ -617,11 +617,11 @@ static int rtl8150_resume(struct usb_interface *intf)
617 if (netif_running(dev->netdev)) { 617 if (netif_running(dev->netdev)) {
618 dev->rx_urb->status = 0; 618 dev->rx_urb->status = 0;
619 dev->rx_urb->actual_length = 0; 619 dev->rx_urb->actual_length = 0;
620 read_bulk_callback(dev->rx_urb, NULL); 620 read_bulk_callback(dev->rx_urb);
621 621
622 dev->intr_urb->status = 0; 622 dev->intr_urb->status = 0;
623 dev->intr_urb->actual_length = 0; 623 dev->intr_urb->actual_length = 0;
624 intr_callback(dev->intr_urb, NULL); 624 intr_callback(dev->intr_urb);
625 } 625 }
626 return 0; 626 return 0;
627} 627}
diff --git a/drivers/usb/net/usbnet.c b/drivers/usb/net/usbnet.c
index 98a522f1e264..760b5327b81b 100644
--- a/drivers/usb/net/usbnet.c
+++ b/drivers/usb/net/usbnet.c
@@ -158,7 +158,7 @@ int usbnet_get_endpoints(struct usbnet *dev, struct usb_interface *intf)
158} 158}
159EXPORT_SYMBOL_GPL(usbnet_get_endpoints); 159EXPORT_SYMBOL_GPL(usbnet_get_endpoints);
160 160
161static void intr_complete (struct urb *urb, struct pt_regs *regs); 161static void intr_complete (struct urb *urb);
162 162
163static int init_status (struct usbnet *dev, struct usb_interface *intf) 163static int init_status (struct usbnet *dev, struct usb_interface *intf)
164{ 164{
@@ -295,7 +295,7 @@ EXPORT_SYMBOL_GPL(usbnet_defer_kevent);
295 295
296/*-------------------------------------------------------------------------*/ 296/*-------------------------------------------------------------------------*/
297 297
298static void rx_complete (struct urb *urb, struct pt_regs *regs); 298static void rx_complete (struct urb *urb);
299 299
300static void rx_submit (struct usbnet *dev, struct urb *urb, gfp_t flags) 300static void rx_submit (struct usbnet *dev, struct urb *urb, gfp_t flags)
301{ 301{
@@ -383,7 +383,7 @@ error:
383 383
384/*-------------------------------------------------------------------------*/ 384/*-------------------------------------------------------------------------*/
385 385
386static void rx_complete (struct urb *urb, struct pt_regs *regs) 386static void rx_complete (struct urb *urb)
387{ 387{
388 struct sk_buff *skb = (struct sk_buff *) urb->context; 388 struct sk_buff *skb = (struct sk_buff *) urb->context;
389 struct skb_data *entry = (struct skb_data *) skb->cb; 389 struct skb_data *entry = (struct skb_data *) skb->cb;
@@ -467,7 +467,7 @@ block:
467 devdbg (dev, "no read resubmitted"); 467 devdbg (dev, "no read resubmitted");
468} 468}
469 469
470static void intr_complete (struct urb *urb, struct pt_regs *regs) 470static void intr_complete (struct urb *urb)
471{ 471{
472 struct usbnet *dev = urb->context; 472 struct usbnet *dev = urb->context;
473 int status = urb->status; 473 int status = urb->status;
@@ -554,7 +554,7 @@ static int usbnet_stop (struct net_device *net)
554{ 554{
555 struct usbnet *dev = netdev_priv(net); 555 struct usbnet *dev = netdev_priv(net);
556 int temp; 556 int temp;
557 DECLARE_WAIT_QUEUE_HEAD (unlink_wakeup); 557 DECLARE_WAIT_QUEUE_HEAD_ONSTACK (unlink_wakeup);
558 DECLARE_WAITQUEUE (wait, current); 558 DECLARE_WAITQUEUE (wait, current);
559 559
560 netif_stop_queue (net); 560 netif_stop_queue (net);
@@ -669,20 +669,40 @@ done:
669 * they'll probably want to use this base set. 669 * they'll probably want to use this base set.
670 */ 670 */
671 671
672void usbnet_get_drvinfo (struct net_device *net, struct ethtool_drvinfo *info) 672#if defined(CONFIG_MII) || defined(CONFIG_MII_MODULE)
673#define HAVE_MII
674
675int usbnet_get_settings (struct net_device *net, struct ethtool_cmd *cmd)
673{ 676{
674 struct usbnet *dev = netdev_priv(net); 677 struct usbnet *dev = netdev_priv(net);
675 678
676 /* REVISIT don't always return "usbnet" */ 679 if (!dev->mii.mdio_read)
677 strncpy (info->driver, driver_name, sizeof info->driver); 680 return -EOPNOTSUPP;
678 strncpy (info->version, DRIVER_VERSION, sizeof info->version); 681
679 strncpy (info->fw_version, dev->driver_info->description, 682 return mii_ethtool_gset(&dev->mii, cmd);
680 sizeof info->fw_version);
681 usb_make_path (dev->udev, info->bus_info, sizeof info->bus_info);
682} 683}
683EXPORT_SYMBOL_GPL(usbnet_get_drvinfo); 684EXPORT_SYMBOL_GPL(usbnet_get_settings);
685
686int usbnet_set_settings (struct net_device *net, struct ethtool_cmd *cmd)
687{
688 struct usbnet *dev = netdev_priv(net);
689 int retval;
690
691 if (!dev->mii.mdio_write)
692 return -EOPNOTSUPP;
684 693
685static u32 usbnet_get_link (struct net_device *net) 694 retval = mii_ethtool_sset(&dev->mii, cmd);
695
696 /* link speed/duplex might have changed */
697 if (dev->driver_info->link_reset)
698 dev->driver_info->link_reset(dev);
699
700 return retval;
701
702}
703EXPORT_SYMBOL_GPL(usbnet_set_settings);
704
705u32 usbnet_get_link (struct net_device *net)
686{ 706{
687 struct usbnet *dev = netdev_priv(net); 707 struct usbnet *dev = netdev_priv(net);
688 708
@@ -690,9 +710,40 @@ static u32 usbnet_get_link (struct net_device *net)
690 if (dev->driver_info->check_connect) 710 if (dev->driver_info->check_connect)
691 return dev->driver_info->check_connect (dev) == 0; 711 return dev->driver_info->check_connect (dev) == 0;
692 712
713 /* if the device has mii operations, use those */
714 if (dev->mii.mdio_read)
715 return mii_link_ok(&dev->mii);
716
693 /* Otherwise, say we're up (to avoid breaking scripts) */ 717 /* Otherwise, say we're up (to avoid breaking scripts) */
694 return 1; 718 return 1;
695} 719}
720EXPORT_SYMBOL_GPL(usbnet_get_link);
721
722int usbnet_nway_reset(struct net_device *net)
723{
724 struct usbnet *dev = netdev_priv(net);
725
726 if (!dev->mii.mdio_write)
727 return -EOPNOTSUPP;
728
729 return mii_nway_restart(&dev->mii);
730}
731EXPORT_SYMBOL_GPL(usbnet_nway_reset);
732
733#endif /* HAVE_MII */
734
735void usbnet_get_drvinfo (struct net_device *net, struct ethtool_drvinfo *info)
736{
737 struct usbnet *dev = netdev_priv(net);
738
739 /* REVISIT don't always return "usbnet" */
740 strncpy (info->driver, driver_name, sizeof info->driver);
741 strncpy (info->version, DRIVER_VERSION, sizeof info->version);
742 strncpy (info->fw_version, dev->driver_info->description,
743 sizeof info->fw_version);
744 usb_make_path (dev->udev, info->bus_info, sizeof info->bus_info);
745}
746EXPORT_SYMBOL_GPL(usbnet_get_drvinfo);
696 747
697u32 usbnet_get_msglevel (struct net_device *net) 748u32 usbnet_get_msglevel (struct net_device *net)
698{ 749{
@@ -712,8 +763,13 @@ EXPORT_SYMBOL_GPL(usbnet_set_msglevel);
712 763
713/* drivers may override default ethtool_ops in their bind() routine */ 764/* drivers may override default ethtool_ops in their bind() routine */
714static struct ethtool_ops usbnet_ethtool_ops = { 765static struct ethtool_ops usbnet_ethtool_ops = {
715 .get_drvinfo = usbnet_get_drvinfo, 766#ifdef HAVE_MII
767 .get_settings = usbnet_get_settings,
768 .set_settings = usbnet_set_settings,
716 .get_link = usbnet_get_link, 769 .get_link = usbnet_get_link,
770 .nway_reset = usbnet_nway_reset,
771#endif
772 .get_drvinfo = usbnet_get_drvinfo,
717 .get_msglevel = usbnet_get_msglevel, 773 .get_msglevel = usbnet_get_msglevel,
718 .set_msglevel = usbnet_set_msglevel, 774 .set_msglevel = usbnet_set_msglevel,
719}; 775};
@@ -797,7 +853,7 @@ kevent (void *data)
797 853
798/*-------------------------------------------------------------------------*/ 854/*-------------------------------------------------------------------------*/
799 855
800static void tx_complete (struct urb *urb, struct pt_regs *regs) 856static void tx_complete (struct urb *urb)
801{ 857{
802 struct sk_buff *skb = (struct sk_buff *) urb->context; 858 struct sk_buff *skb = (struct sk_buff *) urb->context;
803 struct skb_data *entry = (struct skb_data *) skb->cb; 859 struct skb_data *entry = (struct skb_data *) skb->cb;
@@ -1094,6 +1150,7 @@ usbnet_probe (struct usb_interface *udev, const struct usb_device_id *prod)
1094 dev->delay.function = usbnet_bh; 1150 dev->delay.function = usbnet_bh;
1095 dev->delay.data = (unsigned long) dev; 1151 dev->delay.data = (unsigned long) dev;
1096 init_timer (&dev->delay); 1152 init_timer (&dev->delay);
1153 mutex_init (&dev->phy_mutex);
1097 1154
1098 SET_MODULE_OWNER (net); 1155 SET_MODULE_OWNER (net);
1099 dev->net = net; 1156 dev->net = net;
@@ -1225,7 +1282,7 @@ EXPORT_SYMBOL_GPL(usbnet_resume);
1225static int __init usbnet_init(void) 1282static int __init usbnet_init(void)
1226{ 1283{
1227 /* compiler should optimize this out */ 1284 /* compiler should optimize this out */
1228 BUG_ON (sizeof (((struct sk_buff *)0)->cb) 1285 BUILD_BUG_ON (sizeof (((struct sk_buff *)0)->cb)
1229 < sizeof (struct skb_data)); 1286 < sizeof (struct skb_data));
1230 1287
1231 random_ether_addr(node_id); 1288 random_ether_addr(node_id);
diff --git a/drivers/usb/net/usbnet.h b/drivers/usb/net/usbnet.h
index c0746f0454af..07c70abbe0ec 100644
--- a/drivers/usb/net/usbnet.h
+++ b/drivers/usb/net/usbnet.h
@@ -30,6 +30,7 @@ struct usbnet {
30 struct usb_device *udev; 30 struct usb_device *udev;
31 struct driver_info *driver_info; 31 struct driver_info *driver_info;
32 wait_queue_head_t *wait; 32 wait_queue_head_t *wait;
33 struct mutex phy_mutex;
33 34
34 /* i/o info: pipes etc */ 35 /* i/o info: pipes etc */
35 unsigned in, out; 36 unsigned in, out;
@@ -168,9 +169,13 @@ extern void usbnet_defer_kevent (struct usbnet *, int);
168extern void usbnet_skb_return (struct usbnet *, struct sk_buff *); 169extern void usbnet_skb_return (struct usbnet *, struct sk_buff *);
169extern void usbnet_unlink_rx_urbs(struct usbnet *); 170extern void usbnet_unlink_rx_urbs(struct usbnet *);
170 171
172extern int usbnet_get_settings (struct net_device *net, struct ethtool_cmd *cmd);
173extern int usbnet_set_settings (struct net_device *net, struct ethtool_cmd *cmd);
174extern u32 usbnet_get_link (struct net_device *net);
171extern u32 usbnet_get_msglevel (struct net_device *); 175extern u32 usbnet_get_msglevel (struct net_device *);
172extern void usbnet_set_msglevel (struct net_device *, u32); 176extern void usbnet_set_msglevel (struct net_device *, u32);
173extern void usbnet_get_drvinfo (struct net_device *, struct ethtool_drvinfo *); 177extern void usbnet_get_drvinfo (struct net_device *, struct ethtool_drvinfo *);
178extern int usbnet_nway_reset(struct net_device *net);
174 179
175/* messaging support includes the interface name, so it must not be 180/* messaging support includes the interface name, so it must not be
176 * used before it has one ... notably, in minidriver bind() calls. 181 * used before it has one ... notably, in minidriver bind() calls.
diff --git a/drivers/usb/serial/Kconfig b/drivers/usb/serial/Kconfig
index 5076b9d97057..2a8dd4cc943d 100644
--- a/drivers/usb/serial/Kconfig
+++ b/drivers/usb/serial/Kconfig
@@ -54,10 +54,10 @@ config USB_SERIAL_GENERIC
54 properly. 54 properly.
55 55
56config USB_SERIAL_AIRCABLE 56config USB_SERIAL_AIRCABLE
57 tristate "AIRcable USB Bluetooth Dongle Driver (EXPERIMENTAL)" 57 tristate "USB AIRcable Bluetooth Dongle Driver (EXPERIMENTAL)"
58 depends on USB_SERIAL && EXPERIMENTAL 58 depends on USB_SERIAL && EXPERIMENTAL
59 help 59 help
60 Say Y here if you want to use AIRcable USB Bluetoot Dongle. 60 Say Y here if you want to use USB AIRcable Bluetooth Dongle.
61 61
62 To compile this driver as a module, choose M here: the module 62 To compile this driver as a module, choose M here: the module
63 will be called aircable. 63 will be called aircable.
@@ -422,6 +422,16 @@ config USB_SERIAL_MCT_U232
422 To compile this driver as a module, choose M here: the 422 To compile this driver as a module, choose M here: the
423 module will be called mct_u232. 423 module will be called mct_u232.
424 424
425config USB_SERIAL_MOS7720
426 tristate "USB Moschip 7720 Single Port Serial Driver"
427 depends on USB_SERIAL
428 ---help---
429 Say Y here if you want to use a USB Serial single port adapter from
430 Moschip Semiconductor Tech.
431
432 To compile this driver as a module, choose M here: the
433 module will be called mos7720.
434
425config USB_SERIAL_MOS7840 435config USB_SERIAL_MOS7840
426 tristate "USB Moschip 7840/7820 USB Serial Driver" 436 tristate "USB Moschip 7840/7820 USB Serial Driver"
427 depends on USB_SERIAL 437 depends on USB_SERIAL
@@ -527,8 +537,7 @@ config USB_SERIAL_OPTION
527 The USB bus on these cards is not accessible externally. 537 The USB bus on these cards is not accessible externally.
528 538
529 Supported devices include (some of?) those made by: 539 Supported devices include (some of?) those made by:
530 Option, Huawei, Audiovox, Sierra Wireless, Novatel Wireless, or 540 Option, Huawei, Audiovox, Novatel Wireless, or Anydata.
531 Anydata.
532 541
533 To compile this driver as a module, choose M here: the 542 To compile this driver as a module, choose M here: the
534 module will be called option. 543 module will be called option.
diff --git a/drivers/usb/serial/Makefile b/drivers/usb/serial/Makefile
index 8dce83340e31..a5047dc599bb 100644
--- a/drivers/usb/serial/Makefile
+++ b/drivers/usb/serial/Makefile
@@ -34,6 +34,7 @@ obj-$(CONFIG_USB_SERIAL_KEYSPAN_PDA) += keyspan_pda.o
34obj-$(CONFIG_USB_SERIAL_KLSI) += kl5kusb105.o 34obj-$(CONFIG_USB_SERIAL_KLSI) += kl5kusb105.o
35obj-$(CONFIG_USB_SERIAL_KOBIL_SCT) += kobil_sct.o 35obj-$(CONFIG_USB_SERIAL_KOBIL_SCT) += kobil_sct.o
36obj-$(CONFIG_USB_SERIAL_MCT_U232) += mct_u232.o 36obj-$(CONFIG_USB_SERIAL_MCT_U232) += mct_u232.o
37obj-$(CONFIG_USB_SERIAL_MOS7720) += mos7720.o
37obj-$(CONFIG_USB_SERIAL_MOS7840) += mos7840.o 38obj-$(CONFIG_USB_SERIAL_MOS7840) += mos7840.o
38obj-$(CONFIG_USB_SERIAL_NAVMAN) += navman.o 39obj-$(CONFIG_USB_SERIAL_NAVMAN) += navman.o
39obj-$(CONFIG_USB_SERIAL_OMNINET) += omninet.o 40obj-$(CONFIG_USB_SERIAL_OMNINET) += omninet.o
diff --git a/drivers/usb/serial/aircable.c b/drivers/usb/serial/aircable.c
index 2ccd9ded52a5..812275509137 100644
--- a/drivers/usb/serial/aircable.c
+++ b/drivers/usb/serial/aircable.c
@@ -403,7 +403,7 @@ static int aircable_write(struct usb_serial_port *port,
403 403
404} 404}
405 405
406static void aircable_write_bulk_callback(struct urb *urb, struct pt_regs *regs) 406static void aircable_write_bulk_callback(struct urb *urb)
407{ 407{
408 struct usb_serial_port *port = urb->context; 408 struct usb_serial_port *port = urb->context;
409 int result; 409 int result;
@@ -444,7 +444,7 @@ static void aircable_write_bulk_callback(struct urb *urb, struct pt_regs *regs)
444 aircable_send(port); 444 aircable_send(port);
445} 445}
446 446
447static void aircable_read_bulk_callback(struct urb *urb, struct pt_regs *regs) 447static void aircable_read_bulk_callback(struct urb *urb)
448{ 448{
449 struct usb_serial_port *port = urb->context; 449 struct usb_serial_port *port = urb->context;
450 struct aircable_private *priv = usb_get_serial_port_data(port); 450 struct aircable_private *priv = usb_get_serial_port_data(port);
diff --git a/drivers/usb/serial/airprime.c b/drivers/usb/serial/airprime.c
index 6e1a84a858d4..7f5d546da39a 100644
--- a/drivers/usb/serial/airprime.c
+++ b/drivers/usb/serial/airprime.c
@@ -18,12 +18,8 @@
18 18
19static struct usb_device_id id_table [] = { 19static struct usb_device_id id_table [] = {
20 { USB_DEVICE(0x0c88, 0x17da) }, /* Kyocera Wireless KPC650/Passport */ 20 { USB_DEVICE(0x0c88, 0x17da) }, /* Kyocera Wireless KPC650/Passport */
21 { USB_DEVICE(0x0f3d, 0x0112) }, /* AirPrime CDMA Wireless PC Card */
22 { USB_DEVICE(0x1199, 0x0017) }, /* Sierra Wireless EM5625 */
23 { USB_DEVICE(0x1199, 0x0018) }, /* Sierra Wireless MC5720 */
24 { USB_DEVICE(0x1199, 0x0112) }, /* Sierra Wireless Aircard 580 */
25 { USB_DEVICE(0x1199, 0x0218) }, /* Sierra Wireless MC5720 */
26 { USB_DEVICE(0x1410, 0x1110) }, /* Novatel Wireless Merlin CDMA */ 21 { USB_DEVICE(0x1410, 0x1110) }, /* Novatel Wireless Merlin CDMA */
22 { USB_DEVICE(0x1410, 0x1100) }, /* ExpressCard34 Qualcomm 3G CDMA */
27 { }, 23 { },
28}; 24};
29MODULE_DEVICE_TABLE(usb, id_table); 25MODULE_DEVICE_TABLE(usb, id_table);
@@ -46,7 +42,7 @@ struct airprime_private {
46 struct urb *read_urbp[NUM_READ_URBS]; 42 struct urb *read_urbp[NUM_READ_URBS];
47}; 43};
48 44
49static void airprime_read_bulk_callback(struct urb *urb, struct pt_regs *regs) 45static void airprime_read_bulk_callback(struct urb *urb)
50{ 46{
51 struct usb_serial_port *port = urb->context; 47 struct usb_serial_port *port = urb->context;
52 unsigned char *data = urb->transfer_buffer; 48 unsigned char *data = urb->transfer_buffer;
@@ -80,7 +76,7 @@ static void airprime_read_bulk_callback(struct urb *urb, struct pt_regs *regs)
80 return; 76 return;
81} 77}
82 78
83static void airprime_write_bulk_callback(struct urb *urb, struct pt_regs *regs) 79static void airprime_write_bulk_callback(struct urb *urb)
84{ 80{
85 struct usb_serial_port *port = urb->context; 81 struct usb_serial_port *port = urb->context;
86 struct airprime_private *priv = usb_get_serial_port_data(port); 82 struct airprime_private *priv = usb_get_serial_port_data(port);
@@ -133,6 +129,7 @@ static int airprime_open(struct usb_serial_port *port, struct file *filp)
133 } 129 }
134 urb = usb_alloc_urb(0, GFP_KERNEL); 130 urb = usb_alloc_urb(0, GFP_KERNEL);
135 if (!urb) { 131 if (!urb) {
132 kfree(buffer);
136 dev_err(&port->dev, "%s - no more urbs?\n", 133 dev_err(&port->dev, "%s - no more urbs?\n",
137 __FUNCTION__); 134 __FUNCTION__);
138 result = -ENOMEM; 135 result = -ENOMEM;
diff --git a/drivers/usb/serial/belkin_sa.c b/drivers/usb/serial/belkin_sa.c
index 70ece9e01ce4..8835bb58ca9b 100644
--- a/drivers/usb/serial/belkin_sa.c
+++ b/drivers/usb/serial/belkin_sa.c
@@ -91,7 +91,7 @@ static int belkin_sa_startup (struct usb_serial *serial);
91static void belkin_sa_shutdown (struct usb_serial *serial); 91static void belkin_sa_shutdown (struct usb_serial *serial);
92static int belkin_sa_open (struct usb_serial_port *port, struct file *filp); 92static int belkin_sa_open (struct usb_serial_port *port, struct file *filp);
93static void belkin_sa_close (struct usb_serial_port *port, struct file *filp); 93static void belkin_sa_close (struct usb_serial_port *port, struct file *filp);
94static void belkin_sa_read_int_callback (struct urb *urb, struct pt_regs *regs); 94static void belkin_sa_read_int_callback (struct urb *urb);
95static void belkin_sa_set_termios (struct usb_serial_port *port, struct termios * old); 95static void belkin_sa_set_termios (struct usb_serial_port *port, struct termios * old);
96static int belkin_sa_ioctl (struct usb_serial_port *port, struct file * file, unsigned int cmd, unsigned long arg); 96static int belkin_sa_ioctl (struct usb_serial_port *port, struct file * file, unsigned int cmd, unsigned long arg);
97static void belkin_sa_break_ctl (struct usb_serial_port *port, int break_state ); 97static void belkin_sa_break_ctl (struct usb_serial_port *port, int break_state );
@@ -248,7 +248,7 @@ static void belkin_sa_close (struct usb_serial_port *port, struct file *filp)
248} /* belkin_sa_close */ 248} /* belkin_sa_close */
249 249
250 250
251static void belkin_sa_read_int_callback (struct urb *urb, struct pt_regs *regs) 251static void belkin_sa_read_int_callback (struct urb *urb)
252{ 252{
253 struct usb_serial_port *port = (struct usb_serial_port *)urb->context; 253 struct usb_serial_port *port = (struct usb_serial_port *)urb->context;
254 struct belkin_sa_private *priv; 254 struct belkin_sa_private *priv;
diff --git a/drivers/usb/serial/cp2101.c b/drivers/usb/serial/cp2101.c
index 486c7411b9a7..f95d42c0d16a 100644
--- a/drivers/usb/serial/cp2101.c
+++ b/drivers/usb/serial/cp2101.c
@@ -64,7 +64,11 @@ static struct usb_device_id id_table [] = {
64 { USB_DEVICE(0x10C4, 0x80F6) }, /* Suunto sports instrument */ 64 { USB_DEVICE(0x10C4, 0x80F6) }, /* Suunto sports instrument */
65 { USB_DEVICE(0x10C4, 0x813D) }, /* Burnside Telecom Deskmobile */ 65 { USB_DEVICE(0x10C4, 0x813D) }, /* Burnside Telecom Deskmobile */
66 { USB_DEVICE(0x10C4, 0x815E) }, /* Helicomm IP-Link 1220-DVM */ 66 { USB_DEVICE(0x10C4, 0x815E) }, /* Helicomm IP-Link 1220-DVM */
67 { USB_DEVICE(0x10C4, 0x81C8) }, /* Lipowsky Industrie Elektronik GmbH, Baby-JTAG */
68 { USB_DEVICE(0x10C4, 0x81E2) }, /* Lipowsky Industrie Elektronik GmbH, Baby-LIN */
69 { USB_DEVICE(0x10C4, 0x8218) }, /* Lipowsky Industrie Elektronik GmbH, HARP-1 */
67 { USB_DEVICE(0x10C4, 0xEA60) }, /* Silicon Labs factory default */ 70 { USB_DEVICE(0x10C4, 0xEA60) }, /* Silicon Labs factory default */
71 { USB_DEVICE(0x10C4, 0xEA61) }, /* Silicon Labs factory default */
68 { USB_DEVICE(0x16D6, 0x0001) }, /* Jablotron serial interface */ 72 { USB_DEVICE(0x16D6, 0x0001) }, /* Jablotron serial interface */
69 { } /* Terminating Entry */ 73 { } /* Terminating Entry */
70}; 74};
diff --git a/drivers/usb/serial/cyberjack.c b/drivers/usb/serial/cyberjack.c
index d954ec34b018..a63c3286caa0 100644
--- a/drivers/usb/serial/cyberjack.c
+++ b/drivers/usb/serial/cyberjack.c
@@ -63,9 +63,9 @@ static int cyberjack_open (struct usb_serial_port *port, struct file *filp);
63static void cyberjack_close (struct usb_serial_port *port, struct file *filp); 63static void cyberjack_close (struct usb_serial_port *port, struct file *filp);
64static int cyberjack_write (struct usb_serial_port *port, const unsigned char *buf, int count); 64static int cyberjack_write (struct usb_serial_port *port, const unsigned char *buf, int count);
65static int cyberjack_write_room( struct usb_serial_port *port ); 65static int cyberjack_write_room( struct usb_serial_port *port );
66static void cyberjack_read_int_callback (struct urb *urb, struct pt_regs *regs); 66static void cyberjack_read_int_callback (struct urb *urb);
67static void cyberjack_read_bulk_callback (struct urb *urb, struct pt_regs *regs); 67static void cyberjack_read_bulk_callback (struct urb *urb);
68static void cyberjack_write_bulk_callback (struct urb *urb, struct pt_regs *regs); 68static void cyberjack_write_bulk_callback (struct urb *urb);
69 69
70static struct usb_device_id id_table [] = { 70static struct usb_device_id id_table [] = {
71 { USB_DEVICE(CYBERJACK_VENDOR_ID, CYBERJACK_PRODUCT_ID) }, 71 { USB_DEVICE(CYBERJACK_VENDOR_ID, CYBERJACK_PRODUCT_ID) },
@@ -299,7 +299,7 @@ static int cyberjack_write_room( struct usb_serial_port *port )
299 return CYBERJACK_LOCAL_BUF_SIZE; 299 return CYBERJACK_LOCAL_BUF_SIZE;
300} 300}
301 301
302static void cyberjack_read_int_callback( struct urb *urb, struct pt_regs *regs ) 302static void cyberjack_read_int_callback( struct urb *urb )
303{ 303{
304 struct usb_serial_port *port = (struct usb_serial_port *)urb->context; 304 struct usb_serial_port *port = (struct usb_serial_port *)urb->context;
305 struct cyberjack_private *priv = usb_get_serial_port_data(port); 305 struct cyberjack_private *priv = usb_get_serial_port_data(port);
@@ -356,7 +356,7 @@ resubmit:
356 dbg("%s - usb_submit_urb(int urb)", __FUNCTION__); 356 dbg("%s - usb_submit_urb(int urb)", __FUNCTION__);
357} 357}
358 358
359static void cyberjack_read_bulk_callback (struct urb *urb, struct pt_regs *regs) 359static void cyberjack_read_bulk_callback (struct urb *urb)
360{ 360{
361 struct usb_serial_port *port = (struct usb_serial_port *)urb->context; 361 struct usb_serial_port *port = (struct usb_serial_port *)urb->context;
362 struct cyberjack_private *priv = usb_get_serial_port_data(port); 362 struct cyberjack_private *priv = usb_get_serial_port_data(port);
@@ -406,7 +406,7 @@ static void cyberjack_read_bulk_callback (struct urb *urb, struct pt_regs *regs)
406 } 406 }
407} 407}
408 408
409static void cyberjack_write_bulk_callback (struct urb *urb, struct pt_regs *regs) 409static void cyberjack_write_bulk_callback (struct urb *urb)
410{ 410{
411 struct usb_serial_port *port = (struct usb_serial_port *)urb->context; 411 struct usb_serial_port *port = (struct usb_serial_port *)urb->context;
412 struct cyberjack_private *priv = usb_get_serial_port_data(port); 412 struct cyberjack_private *priv = usb_get_serial_port_data(port);
diff --git a/drivers/usb/serial/cypress_m8.c b/drivers/usb/serial/cypress_m8.c
index e1173c1aee37..f2e89a083659 100644
--- a/drivers/usb/serial/cypress_m8.c
+++ b/drivers/usb/serial/cypress_m8.c
@@ -172,8 +172,8 @@ static int cypress_chars_in_buffer (struct usb_serial_port *port);
172static void cypress_throttle (struct usb_serial_port *port); 172static void cypress_throttle (struct usb_serial_port *port);
173static void cypress_unthrottle (struct usb_serial_port *port); 173static void cypress_unthrottle (struct usb_serial_port *port);
174static void cypress_set_dead (struct usb_serial_port *port); 174static void cypress_set_dead (struct usb_serial_port *port);
175static void cypress_read_int_callback (struct urb *urb, struct pt_regs *regs); 175static void cypress_read_int_callback (struct urb *urb);
176static void cypress_write_int_callback (struct urb *urb, struct pt_regs *regs); 176static void cypress_write_int_callback (struct urb *urb);
177/* baud helper functions */ 177/* baud helper functions */
178static int mask_to_rate (unsigned mask); 178static int mask_to_rate (unsigned mask);
179static unsigned rate_to_mask (int rate); 179static unsigned rate_to_mask (int rate);
@@ -1275,7 +1275,7 @@ static void cypress_unthrottle (struct usb_serial_port *port)
1275} 1275}
1276 1276
1277 1277
1278static void cypress_read_int_callback(struct urb *urb, struct pt_regs *regs) 1278static void cypress_read_int_callback(struct urb *urb)
1279{ 1279{
1280 struct usb_serial_port *port = (struct usb_serial_port *)urb->context; 1280 struct usb_serial_port *port = (struct usb_serial_port *)urb->context;
1281 struct cypress_private *priv = usb_get_serial_port_data(port); 1281 struct cypress_private *priv = usb_get_serial_port_data(port);
@@ -1426,7 +1426,7 @@ continue_read:
1426} /* cypress_read_int_callback */ 1426} /* cypress_read_int_callback */
1427 1427
1428 1428
1429static void cypress_write_int_callback(struct urb *urb, struct pt_regs *regs) 1429static void cypress_write_int_callback(struct urb *urb)
1430{ 1430{
1431 struct usb_serial_port *port = (struct usb_serial_port *)urb->context; 1431 struct usb_serial_port *port = (struct usb_serial_port *)urb->context;
1432 struct cypress_private *priv = usb_get_serial_port_data(port); 1432 struct cypress_private *priv = usb_get_serial_port_data(port);
diff --git a/drivers/usb/serial/digi_acceleport.c b/drivers/usb/serial/digi_acceleport.c
index 9b225183fc7a..bdb58100fc1d 100644
--- a/drivers/usb/serial/digi_acceleport.c
+++ b/drivers/usb/serial/digi_acceleport.c
@@ -456,7 +456,7 @@ static int digi_tiocmget( struct usb_serial_port *port, struct file *file );
456static int digi_tiocmset( struct usb_serial_port *port, struct file *file, 456static int digi_tiocmset( struct usb_serial_port *port, struct file *file,
457 unsigned int set, unsigned int clear ); 457 unsigned int set, unsigned int clear );
458static int digi_write( struct usb_serial_port *port, const unsigned char *buf, int count ); 458static int digi_write( struct usb_serial_port *port, const unsigned char *buf, int count );
459static void digi_write_bulk_callback( struct urb *urb, struct pt_regs *regs ); 459static void digi_write_bulk_callback( struct urb *urb );
460static int digi_write_room( struct usb_serial_port *port ); 460static int digi_write_room( struct usb_serial_port *port );
461static int digi_chars_in_buffer( struct usb_serial_port *port ); 461static int digi_chars_in_buffer( struct usb_serial_port *port );
462static int digi_open( struct usb_serial_port *port, struct file *filp ); 462static int digi_open( struct usb_serial_port *port, struct file *filp );
@@ -464,7 +464,7 @@ static void digi_close( struct usb_serial_port *port, struct file *filp );
464static int digi_startup_device( struct usb_serial *serial ); 464static int digi_startup_device( struct usb_serial *serial );
465static int digi_startup( struct usb_serial *serial ); 465static int digi_startup( struct usb_serial *serial );
466static void digi_shutdown( struct usb_serial *serial ); 466static void digi_shutdown( struct usb_serial *serial );
467static void digi_read_bulk_callback( struct urb *urb, struct pt_regs *regs ); 467static void digi_read_bulk_callback( struct urb *urb );
468static int digi_read_inb_callback( struct urb *urb ); 468static int digi_read_inb_callback( struct urb *urb );
469static int digi_read_oob_callback( struct urb *urb ); 469static int digi_read_oob_callback( struct urb *urb );
470 470
@@ -1336,7 +1336,7 @@ dbg( "digi_write: returning %d", ret );
1336} 1336}
1337 1337
1338 1338
1339static void digi_write_bulk_callback( struct urb *urb, struct pt_regs *regs ) 1339static void digi_write_bulk_callback( struct urb *urb )
1340{ 1340{
1341 1341
1342 struct usb_serial_port *port = (struct usb_serial_port *)urb->context; 1342 struct usb_serial_port *port = (struct usb_serial_port *)urb->context;
@@ -1754,7 +1754,7 @@ dbg( "digi_shutdown: TOP, in_interrupt()=%ld", in_interrupt() );
1754} 1754}
1755 1755
1756 1756
1757static void digi_read_bulk_callback( struct urb *urb, struct pt_regs *regs ) 1757static void digi_read_bulk_callback( struct urb *urb )
1758{ 1758{
1759 1759
1760 struct usb_serial_port *port = (struct usb_serial_port *)urb->context; 1760 struct usb_serial_port *port = (struct usb_serial_port *)urb->context;
diff --git a/drivers/usb/serial/empeg.c b/drivers/usb/serial/empeg.c
index daafe405d86d..4ce10a831953 100644
--- a/drivers/usb/serial/empeg.c
+++ b/drivers/usb/serial/empeg.c
@@ -93,8 +93,8 @@ static int empeg_ioctl (struct usb_serial_port *port,
93 unsigned int cmd, 93 unsigned int cmd,
94 unsigned long arg); 94 unsigned long arg);
95static void empeg_set_termios (struct usb_serial_port *port, struct termios *old_termios); 95static void empeg_set_termios (struct usb_serial_port *port, struct termios *old_termios);
96static void empeg_write_bulk_callback (struct urb *urb, struct pt_regs *regs); 96static void empeg_write_bulk_callback (struct urb *urb);
97static void empeg_read_bulk_callback (struct urb *urb, struct pt_regs *regs); 97static void empeg_read_bulk_callback (struct urb *urb);
98 98
99static struct usb_device_id id_table [] = { 99static struct usb_device_id id_table [] = {
100 { USB_DEVICE(EMPEG_VENDOR_ID, EMPEG_PRODUCT_ID) }, 100 { USB_DEVICE(EMPEG_VENDOR_ID, EMPEG_PRODUCT_ID) },
@@ -323,7 +323,7 @@ static int empeg_chars_in_buffer (struct usb_serial_port *port)
323} 323}
324 324
325 325
326static void empeg_write_bulk_callback (struct urb *urb, struct pt_regs *regs) 326static void empeg_write_bulk_callback (struct urb *urb)
327{ 327{
328 struct usb_serial_port *port = (struct usb_serial_port *)urb->context; 328 struct usb_serial_port *port = (struct usb_serial_port *)urb->context;
329 329
@@ -338,7 +338,7 @@ static void empeg_write_bulk_callback (struct urb *urb, struct pt_regs *regs)
338} 338}
339 339
340 340
341static void empeg_read_bulk_callback (struct urb *urb, struct pt_regs *regs) 341static void empeg_read_bulk_callback (struct urb *urb)
342{ 342{
343 struct usb_serial_port *port = (struct usb_serial_port *)urb->context; 343 struct usb_serial_port *port = (struct usb_serial_port *)urb->context;
344 struct tty_struct *tty; 344 struct tty_struct *tty;
diff --git a/drivers/usb/serial/ftdi_sio.c b/drivers/usb/serial/ftdi_sio.c
index e774a27c6c98..c186b4e73c72 100644
--- a/drivers/usb/serial/ftdi_sio.c
+++ b/drivers/usb/serial/ftdi_sio.c
@@ -1,16 +1,16 @@
1/* 1/*
2 * USB FTDI SIO driver 2 * USB FTDI SIO driver
3 * 3 *
4 * Copyright (C) 1999 - 2001 4 * Copyright (C) 1999 - 2001
5 * Greg Kroah-Hartman (greg@kroah.com) 5 * Greg Kroah-Hartman (greg@kroah.com)
6 * Bill Ryder (bryder@sgi.com) 6 * Bill Ryder (bryder@sgi.com)
7 * Copyright (C) 2002 7 * Copyright (C) 2002
8 * Kuba Ober (kuba@mareimbrium.org) 8 * Kuba Ober (kuba@mareimbrium.org)
9 * 9 *
10 * This program is free software; you can redistribute it and/or modify 10 * This program is free software; you can redistribute it and/or modify
11 * it under the terms of the GNU General Public License as published by 11 * it under the terms of the GNU General Public License as published by
12 * the Free Software Foundation; either version 2 of the License, or 12 * the Free Software Foundation; either version 2 of the License, or
13 * (at your option) any later version. 13 * (at your option) any later version.
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 *
@@ -32,7 +32,7 @@
32 * Changed full name of USB-UIRT device to avoid "/" character. 32 * Changed full name of USB-UIRT device to avoid "/" character.
33 * Added FTDI's alternate PID (0x6006) for FT232/245 devices. 33 * Added FTDI's alternate PID (0x6006) for FT232/245 devices.
34 * Added PID for "ELV USB Module UO100" from Stefan Frings. 34 * Added PID for "ELV USB Module UO100" from Stefan Frings.
35 * 35 *
36 * (21/Oct/2003) Ian Abbott 36 * (21/Oct/2003) Ian Abbott
37 * Renamed some VID/PID macros for Matrix Orbital and Perle Systems 37 * Renamed some VID/PID macros for Matrix Orbital and Perle Systems
38 * devices. Removed Matrix Orbital and Perle Systems devices from the 38 * devices. Removed Matrix Orbital and Perle Systems devices from the
@@ -69,7 +69,7 @@
69 * does not incure any measurable overhead. This also relies on the fact 69 * does not incure any measurable overhead. This also relies on the fact
70 * that we have proper reference counting logic for urbs. I nicked this 70 * that we have proper reference counting logic for urbs. I nicked this
71 * from Greg KH's Visor driver. 71 * from Greg KH's Visor driver.
72 * 72 *
73 * (23/Jun/2003) Ian Abbott 73 * (23/Jun/2003) Ian Abbott
74 * Reduced flip buffer pushes and corrected a data length test in 74 * Reduced flip buffer pushes and corrected a data length test in
75 * ftdi_read_bulk_callback. 75 * ftdi_read_bulk_callback.
@@ -77,7 +77,7 @@
77 * 77 *
78 * (21/Jun/2003) Erik Nygren 78 * (21/Jun/2003) Erik Nygren
79 * Added support for Home Electronics Tira-1 IR transceiver using FT232BM chip. 79 * Added support for Home Electronics Tira-1 IR transceiver using FT232BM chip.
80 * See <http://www.home-electro.com/tira1.htm>. Only operates properly 80 * See <http://www.home-electro.com/tira1.htm>. Only operates properly
81 * at 100000 and RTS-CTS, so set custom divisor mode on startup. 81 * at 100000 and RTS-CTS, so set custom divisor mode on startup.
82 * Also force the Tira-1 and USB-UIRT to only use their custom baud rates. 82 * Also force the Tira-1 and USB-UIRT to only use their custom baud rates.
83 * 83 *
@@ -137,17 +137,17 @@
137 * (17/Feb/2003) Bill Ryder 137 * (17/Feb/2003) Bill Ryder
138 * Added write urb buffer pool on a per device basis 138 * Added write urb buffer pool on a per device basis
139 * Added more checking for open file on callbacks (fixed OOPS) 139 * Added more checking for open file on callbacks (fixed OOPS)
140 * Added CrystalFontz 632 and 634 PIDs 140 * Added CrystalFontz 632 and 634 PIDs
141 * (thanx to CrystalFontz for the sample devices - they flushed out 141 * (thanx to CrystalFontz for the sample devices - they flushed out
142 * some driver bugs) 142 * some driver bugs)
143 * Minor debugging message changes 143 * Minor debugging message changes
144 * Added throttle, unthrottle and chars_in_buffer functions 144 * Added throttle, unthrottle and chars_in_buffer functions
145 * Fixed FTDI_SIO (the original device) bug 145 * Fixed FTDI_SIO (the original device) bug
146 * Fixed some shutdown handling 146 * Fixed some shutdown handling
147 * 147 *
148 * 148 *
149 * 149 *
150 * 150 *
151 * (07/Jun/2002) Kuba Ober 151 * (07/Jun/2002) Kuba Ober
152 * Changed FTDI_SIO_BASE_BAUD_TO_DIVISOR macro into ftdi_baud_to_divisor 152 * Changed FTDI_SIO_BASE_BAUD_TO_DIVISOR macro into ftdi_baud_to_divisor
153 * function. It was getting too complex. 153 * function. It was getting too complex.
@@ -158,7 +158,7 @@
158 * 158 *
159 * (25/Jul/2002) Bill Ryder inserted Dmitri's TIOCMIWAIT patch 159 * (25/Jul/2002) Bill Ryder inserted Dmitri's TIOCMIWAIT patch
160 * Not tested by me but it doesn't break anything I use. 160 * Not tested by me but it doesn't break anything I use.
161 * 161 *
162 * (04/Jan/2002) Kuba Ober 162 * (04/Jan/2002) Kuba Ober
163 * Implemented 38400 baudrate kludge, where it can be substituted with other 163 * Implemented 38400 baudrate kludge, where it can be substituted with other
164 * values. That's the only way to set custom baudrates. 164 * values. That's the only way to set custom baudrates.
@@ -179,7 +179,7 @@
179 * (the previous version caused panics) 179 * (the previous version caused panics)
180 * Removed port iteration code since the device only has one I/O port and it 180 * Removed port iteration code since the device only has one I/O port and it
181 * was wrong anyway. 181 * was wrong anyway.
182 * 182 *
183 * (31/May/2001) gkh 183 * (31/May/2001) gkh
184 * Switched from using spinlock to a semaphore, which fixes lots of problems. 184 * Switched from using spinlock to a semaphore, which fixes lots of problems.
185 * 185 *
@@ -188,16 +188,16 @@
188 * Cleaned up comments for 8U232 188 * Cleaned up comments for 8U232
189 * Added parity, framing and overrun error handling 189 * Added parity, framing and overrun error handling
190 * Added receive break handling. 190 * Added receive break handling.
191 * 191 *
192 * (04/08/2001) gb 192 * (04/08/2001) gb
193 * Identify version on module load. 193 * Identify version on module load.
194 * 194 *
195 * (18/March/2001) Bill Ryder 195 * (18/March/2001) Bill Ryder
196 * (Not released) 196 * (Not released)
197 * Added send break handling. (requires kernel patch too) 197 * Added send break handling. (requires kernel patch too)
198 * Fixed 8U232AM hardware RTS/CTS etc status reporting. 198 * Fixed 8U232AM hardware RTS/CTS etc status reporting.
199 * Added flipbuf fix copied from generic device 199 * Added flipbuf fix copied from generic device
200 * 200 *
201 * (12/3/2000) Bill Ryder 201 * (12/3/2000) Bill Ryder
202 * Added support for 8U232AM device. 202 * Added support for 8U232AM device.
203 * Moved PID and VIDs into header file only. 203 * Moved PID and VIDs into header file only.
@@ -211,14 +211,14 @@
211 * Cleaned up comments. Removed multiple PID/VID definitions. 211 * Cleaned up comments. Removed multiple PID/VID definitions.
212 * Factorised cts/dtr code 212 * Factorised cts/dtr code
213 * Made use of __FUNCTION__ in dbg's 213 * Made use of __FUNCTION__ in dbg's
214 * 214 *
215 * (11/01/2000) Adam J. Richter 215 * (11/01/2000) Adam J. Richter
216 * usb_device_id table support 216 * usb_device_id table support
217 * 217 *
218 * (10/05/2000) gkh 218 * (10/05/2000) gkh
219 * Fixed bug with urb->dev not being set properly, now that the usb 219 * Fixed bug with urb->dev not being set properly, now that the usb
220 * core needs it. 220 * core needs it.
221 * 221 *
222 * (09/11/2000) gkh 222 * (09/11/2000) gkh
223 * Removed DEBUG #ifdefs with call to usb_serial_debug_data 223 * Removed DEBUG #ifdefs with call to usb_serial_debug_data
224 * 224 *
@@ -226,11 +226,11 @@
226 * Added module_init and module_exit functions to handle the fact that this 226 * Added module_init and module_exit functions to handle the fact that this
227 * driver is a loadable module now. 227 * driver is a loadable module now.
228 * 228 *
229 * (04/04/2000) Bill Ryder 229 * (04/04/2000) Bill Ryder
230 * Fixed bugs in TCGET/TCSET ioctls (by removing them - they are 230 * Fixed bugs in TCGET/TCSET ioctls (by removing them - they are
231 * handled elsewhere in the tty io driver chain). 231 * handled elsewhere in the tty io driver chain).
232 * 232 *
233 * (03/30/2000) Bill Ryder 233 * (03/30/2000) Bill Ryder
234 * Implemented lots of ioctls 234 * Implemented lots of ioctls
235 * Fixed a race condition in write 235 * Fixed a race condition in write
236 * Changed some dbg's to errs 236 * Changed some dbg's to errs
@@ -311,6 +311,7 @@ static struct usb_device_id id_table_combined [] = {
311 { USB_DEVICE(FTDI_VID, FTDI_ACTZWAVE_PID) }, 311 { USB_DEVICE(FTDI_VID, FTDI_ACTZWAVE_PID) },
312 { USB_DEVICE(FTDI_VID, FTDI_IRTRANS_PID) }, 312 { USB_DEVICE(FTDI_VID, FTDI_IRTRANS_PID) },
313 { USB_DEVICE(FTDI_VID, FTDI_IPLUS_PID) }, 313 { USB_DEVICE(FTDI_VID, FTDI_IPLUS_PID) },
314 { USB_DEVICE(FTDI_VID, FTDI_DMX4ALL) },
314 { USB_DEVICE(FTDI_VID, FTDI_SIO_PID) }, 315 { USB_DEVICE(FTDI_VID, FTDI_SIO_PID) },
315 { USB_DEVICE(FTDI_VID, FTDI_8U232AM_PID) }, 316 { USB_DEVICE(FTDI_VID, FTDI_8U232AM_PID) },
316 { USB_DEVICE(FTDI_VID, FTDI_8U232AM_ALT_PID) }, 317 { USB_DEVICE(FTDI_VID, FTDI_8U232AM_ALT_PID) },
@@ -444,13 +445,13 @@ static struct usb_device_id id_table_combined [] = {
444 /* { USB_DEVICE(FTDI_VID, FTDI_ELV_WS300PC_PID) }, */ 445 /* { USB_DEVICE(FTDI_VID, FTDI_ELV_WS300PC_PID) }, */
445 /* { USB_DEVICE(FTDI_VID, FTDI_ELV_FHZ1300PC_PID) }, */ 446 /* { USB_DEVICE(FTDI_VID, FTDI_ELV_FHZ1300PC_PID) }, */
446 /* { USB_DEVICE(FTDI_VID, FTDI_ELV_WS500_PID) }, */ 447 /* { USB_DEVICE(FTDI_VID, FTDI_ELV_WS500_PID) }, */
447 { USB_DEVICE(FTDI_VID, LINX_SDMUSBQSS_PID) }, 448 { USB_DEVICE(FTDI_VID, LINX_SDMUSBQSS_PID) },
448 { USB_DEVICE(FTDI_VID, LINX_MASTERDEVEL2_PID) }, 449 { USB_DEVICE(FTDI_VID, LINX_MASTERDEVEL2_PID) },
449 { USB_DEVICE(FTDI_VID, LINX_FUTURE_0_PID) }, 450 { USB_DEVICE(FTDI_VID, LINX_FUTURE_0_PID) },
450 { USB_DEVICE(FTDI_VID, LINX_FUTURE_1_PID) }, 451 { USB_DEVICE(FTDI_VID, LINX_FUTURE_1_PID) },
451 { USB_DEVICE(FTDI_VID, LINX_FUTURE_2_PID) }, 452 { USB_DEVICE(FTDI_VID, LINX_FUTURE_2_PID) },
452 { USB_DEVICE(FTDI_VID, FTDI_CCSICDU20_0_PID) }, 453 { USB_DEVICE(FTDI_VID, FTDI_CCSICDU20_0_PID) },
453 { USB_DEVICE(FTDI_VID, FTDI_CCSICDU40_1_PID) }, 454 { USB_DEVICE(FTDI_VID, FTDI_CCSICDU40_1_PID) },
454 { USB_DEVICE(FTDI_VID, INSIDE_ACCESSO) }, 455 { USB_DEVICE(FTDI_VID, INSIDE_ACCESSO) },
455 { USB_DEVICE(INTREPID_VID, INTREPID_VALUECAN_PID) }, 456 { USB_DEVICE(INTREPID_VID, INTREPID_VALUECAN_PID) },
456 { USB_DEVICE(INTREPID_VID, INTREPID_NEOVI_PID) }, 457 { USB_DEVICE(INTREPID_VID, INTREPID_NEOVI_PID) },
@@ -511,6 +512,7 @@ static struct usb_device_id id_table_combined [] = {
511 { USB_DEVICE(FTDI_VID, FTDI_TACTRIX_OPENPORT_13M_PID) }, 512 { USB_DEVICE(FTDI_VID, FTDI_TACTRIX_OPENPORT_13M_PID) },
512 { USB_DEVICE(FTDI_VID, FTDI_TACTRIX_OPENPORT_13S_PID) }, 513 { USB_DEVICE(FTDI_VID, FTDI_TACTRIX_OPENPORT_13S_PID) },
513 { USB_DEVICE(FTDI_VID, FTDI_TACTRIX_OPENPORT_13U_PID) }, 514 { USB_DEVICE(FTDI_VID, FTDI_TACTRIX_OPENPORT_13U_PID) },
515 { USB_DEVICE(ELEKTOR_VID, ELEKTOR_FT323R_PID) },
514 { }, /* Optional parameter entry */ 516 { }, /* Optional parameter entry */
515 { } /* Terminating entry */ 517 { } /* Terminating entry */
516}; 518};
@@ -522,7 +524,7 @@ static struct usb_driver ftdi_driver = {
522 .probe = usb_serial_probe, 524 .probe = usb_serial_probe,
523 .disconnect = usb_serial_disconnect, 525 .disconnect = usb_serial_disconnect,
524 .id_table = id_table_combined, 526 .id_table = id_table_combined,
525 .no_dynamic_id = 1, 527 .no_dynamic_id = 1,
526}; 528};
527 529
528static const char *ftdi_chip_name[] = { 530static const char *ftdi_chip_name[] = {
@@ -548,13 +550,13 @@ struct ftdi_private {
548 int custom_divisor; /* custom_divisor kludge, this is for baud_base (different from what goes to the chip!) */ 550 int custom_divisor; /* custom_divisor kludge, this is for baud_base (different from what goes to the chip!) */
549 __u16 last_set_data_urb_value ; 551 __u16 last_set_data_urb_value ;
550 /* the last data state set - needed for doing a break */ 552 /* the last data state set - needed for doing a break */
551 int write_offset; /* This is the offset in the usb data block to write the serial data - 553 int write_offset; /* This is the offset in the usb data block to write the serial data -
552 * it is different between devices 554 * it is different between devices
553 */ 555 */
554 int flags; /* some ASYNC_xxxx flags are supported */ 556 int flags; /* some ASYNC_xxxx flags are supported */
555 unsigned long last_dtr_rts; /* saved modem control outputs */ 557 unsigned long last_dtr_rts; /* saved modem control outputs */
556 wait_queue_head_t delta_msr_wait; /* Used for TIOCMIWAIT */ 558 wait_queue_head_t delta_msr_wait; /* Used for TIOCMIWAIT */
557 char prev_status, diff_status; /* Used for TIOCMIWAIT */ 559 char prev_status, diff_status; /* Used for TIOCMIWAIT */
558 __u8 rx_flags; /* receive state flags (throttling) */ 560 __u8 rx_flags; /* receive state flags (throttling) */
559 spinlock_t rx_lock; /* spinlock for receive state */ 561 spinlock_t rx_lock; /* spinlock for receive state */
560 struct work_struct rx_work; 562 struct work_struct rx_work;
@@ -589,8 +591,8 @@ static void ftdi_close (struct usb_serial_port *port, struct file *filp);
589static int ftdi_write (struct usb_serial_port *port, const unsigned char *buf, int count); 591static int ftdi_write (struct usb_serial_port *port, const unsigned char *buf, int count);
590static int ftdi_write_room (struct usb_serial_port *port); 592static int ftdi_write_room (struct usb_serial_port *port);
591static int ftdi_chars_in_buffer (struct usb_serial_port *port); 593static int ftdi_chars_in_buffer (struct usb_serial_port *port);
592static void ftdi_write_bulk_callback (struct urb *urb, struct pt_regs *regs); 594static void ftdi_write_bulk_callback (struct urb *urb);
593static void ftdi_read_bulk_callback (struct urb *urb, struct pt_regs *regs); 595static void ftdi_read_bulk_callback (struct urb *urb);
594static void ftdi_process_read (void *param); 596static void ftdi_process_read (void *param);
595static void ftdi_set_termios (struct usb_serial_port *port, struct termios * old); 597static void ftdi_set_termios (struct usb_serial_port *port, struct termios * old);
596static int ftdi_tiocmget (struct usb_serial_port *port, struct file *file); 598static int ftdi_tiocmget (struct usb_serial_port *port, struct file *file);
@@ -721,7 +723,7 @@ static int update_mctrl(struct usb_serial_port *port, unsigned int set, unsigned
721 urb_value |= FTDI_SIO_SET_RTS_HIGH; 723 urb_value |= FTDI_SIO_SET_RTS_HIGH;
722 rv = usb_control_msg(port->serial->dev, 724 rv = usb_control_msg(port->serial->dev,
723 usb_sndctrlpipe(port->serial->dev, 0), 725 usb_sndctrlpipe(port->serial->dev, 0),
724 FTDI_SIO_SET_MODEM_CTRL_REQUEST, 726 FTDI_SIO_SET_MODEM_CTRL_REQUEST,
725 FTDI_SIO_SET_MODEM_CTRL_REQUEST_TYPE, 727 FTDI_SIO_SET_MODEM_CTRL_REQUEST_TYPE,
726 urb_value, priv->interface, 728 urb_value, priv->interface,
727 buf, 0, WDR_TIMEOUT); 729 buf, 0, WDR_TIMEOUT);
@@ -768,7 +770,7 @@ static int change_speed(struct usb_serial_port *port)
768 if (priv->interface) { /* FT2232C */ 770 if (priv->interface) { /* FT2232C */
769 urb_index = (__u16)((urb_index << 8) | priv->interface); 771 urb_index = (__u16)((urb_index << 8) | priv->interface);
770 } 772 }
771 773
772 rv = usb_control_msg(port->serial->dev, 774 rv = usb_control_msg(port->serial->dev,
773 usb_sndctrlpipe(port->serial->dev, 0), 775 usb_sndctrlpipe(port->serial->dev, 0),
774 FTDI_SIO_SET_BAUDRATE_REQUEST, 776 FTDI_SIO_SET_BAUDRATE_REQUEST,
@@ -827,7 +829,7 @@ static __u32 get_ftdi_divisor(struct usb_serial_port * port)
827 829
828 /* 3. Convert baudrate to device-specific divisor */ 830 /* 3. Convert baudrate to device-specific divisor */
829 831
830 if (!baud) baud = 9600; 832 if (!baud) baud = 9600;
831 switch(priv->chip_type) { 833 switch(priv->chip_type) {
832 case SIO: /* SIO chip */ 834 case SIO: /* SIO chip */
833 switch(baud) { 835 switch(baud) {
@@ -843,7 +845,7 @@ static __u32 get_ftdi_divisor(struct usb_serial_port * port)
843 case 115200: div_value = ftdi_sio_b115200; break; 845 case 115200: div_value = ftdi_sio_b115200; break;
844 } /* baud */ 846 } /* baud */
845 if (div_value == 0) { 847 if (div_value == 0) {
846 dbg("%s - Baudrate (%d) requested is not supported", __FUNCTION__, baud); 848 dbg("%s - Baudrate (%d) requested is not supported", __FUNCTION__, baud);
847 div_value = ftdi_sio_b9600; 849 div_value = ftdi_sio_b9600;
848 div_okay = 0; 850 div_okay = 0;
849 } 851 }
@@ -925,7 +927,7 @@ static int set_serial_info(struct usb_serial_port * port, struct serial_struct _
925 /* Make the changes - these are privileged changes! */ 927 /* Make the changes - these are privileged changes! */
926 928
927 priv->flags = ((priv->flags & ~ASYNC_FLAGS) | 929 priv->flags = ((priv->flags & ~ASYNC_FLAGS) |
928 (new_serial.flags & ASYNC_FLAGS)); 930 (new_serial.flags & ASYNC_FLAGS));
929 priv->custom_divisor = new_serial.custom_divisor; 931 priv->custom_divisor = new_serial.custom_divisor;
930 932
931 port->tty->low_latency = (priv->flags & ASYNC_LOW_LATENCY) ? 1 : 0; 933 port->tty->low_latency = (priv->flags & ASYNC_LOW_LATENCY) ? 1 : 0;
@@ -950,7 +952,7 @@ check_and_exit:
950 (old_priv.custom_divisor != priv->custom_divisor))) { 952 (old_priv.custom_divisor != priv->custom_divisor))) {
951 change_speed(port); 953 change_speed(port);
952 } 954 }
953 955
954 return (0); 956 return (0);
955 957
956} /* set_serial_info */ 958} /* set_serial_info */
@@ -1022,18 +1024,18 @@ static ssize_t show_latency_timer(struct device *dev, struct device_attribute *a
1022 struct usb_device *udev; 1024 struct usb_device *udev;
1023 unsigned short latency = 0; 1025 unsigned short latency = 0;
1024 int rv = 0; 1026 int rv = 0;
1025 1027
1026 udev = to_usb_device(dev); 1028 udev = to_usb_device(dev);
1027 1029
1028 dbg("%s",__FUNCTION__); 1030 dbg("%s",__FUNCTION__);
1029 1031
1030 rv = usb_control_msg(udev, 1032 rv = usb_control_msg(udev,
1031 usb_rcvctrlpipe(udev, 0), 1033 usb_rcvctrlpipe(udev, 0),
1032 FTDI_SIO_GET_LATENCY_TIMER_REQUEST, 1034 FTDI_SIO_GET_LATENCY_TIMER_REQUEST,
1033 FTDI_SIO_GET_LATENCY_TIMER_REQUEST_TYPE, 1035 FTDI_SIO_GET_LATENCY_TIMER_REQUEST_TYPE,
1034 0, priv->interface, 1036 0, priv->interface,
1035 (char*) &latency, 1, WDR_TIMEOUT); 1037 (char*) &latency, 1, WDR_TIMEOUT);
1036 1038
1037 if (rv < 0) { 1039 if (rv < 0) {
1038 dev_err(dev, "Unable to read latency timer: %i", rv); 1040 dev_err(dev, "Unable to read latency timer: %i", rv);
1039 return -EIO; 1041 return -EIO;
@@ -1051,23 +1053,23 @@ static ssize_t store_latency_timer(struct device *dev, struct device_attribute *
1051 char buf[1]; 1053 char buf[1];
1052 int v = simple_strtoul(valbuf, NULL, 10); 1054 int v = simple_strtoul(valbuf, NULL, 10);
1053 int rv = 0; 1055 int rv = 0;
1054 1056
1055 udev = to_usb_device(dev); 1057 udev = to_usb_device(dev);
1056 1058
1057 dbg("%s: setting latency timer = %i", __FUNCTION__, v); 1059 dbg("%s: setting latency timer = %i", __FUNCTION__, v);
1058 1060
1059 rv = usb_control_msg(udev, 1061 rv = usb_control_msg(udev,
1060 usb_sndctrlpipe(udev, 0), 1062 usb_sndctrlpipe(udev, 0),
1061 FTDI_SIO_SET_LATENCY_TIMER_REQUEST, 1063 FTDI_SIO_SET_LATENCY_TIMER_REQUEST,
1062 FTDI_SIO_SET_LATENCY_TIMER_REQUEST_TYPE, 1064 FTDI_SIO_SET_LATENCY_TIMER_REQUEST_TYPE,
1063 v, priv->interface, 1065 v, priv->interface,
1064 buf, 0, WDR_TIMEOUT); 1066 buf, 0, WDR_TIMEOUT);
1065 1067
1066 if (rv < 0) { 1068 if (rv < 0) {
1067 dev_err(dev, "Unable to write latency timer: %i", rv); 1069 dev_err(dev, "Unable to write latency timer: %i", rv);
1068 return -EIO; 1070 return -EIO;
1069 } 1071 }
1070 1072
1071 return count; 1073 return count;
1072} 1074}
1073 1075
@@ -1082,23 +1084,23 @@ static ssize_t store_event_char(struct device *dev, struct device_attribute *att
1082 char buf[1]; 1084 char buf[1];
1083 int v = simple_strtoul(valbuf, NULL, 10); 1085 int v = simple_strtoul(valbuf, NULL, 10);
1084 int rv = 0; 1086 int rv = 0;
1085 1087
1086 udev = to_usb_device(dev); 1088 udev = to_usb_device(dev);
1087 1089
1088 dbg("%s: setting event char = %i", __FUNCTION__, v); 1090 dbg("%s: setting event char = %i", __FUNCTION__, v);
1089 1091
1090 rv = usb_control_msg(udev, 1092 rv = usb_control_msg(udev,
1091 usb_sndctrlpipe(udev, 0), 1093 usb_sndctrlpipe(udev, 0),
1092 FTDI_SIO_SET_EVENT_CHAR_REQUEST, 1094 FTDI_SIO_SET_EVENT_CHAR_REQUEST,
1093 FTDI_SIO_SET_EVENT_CHAR_REQUEST_TYPE, 1095 FTDI_SIO_SET_EVENT_CHAR_REQUEST_TYPE,
1094 v, priv->interface, 1096 v, priv->interface,
1095 buf, 0, WDR_TIMEOUT); 1097 buf, 0, WDR_TIMEOUT);
1096 1098
1097 if (rv < 0) { 1099 if (rv < 0) {
1098 dbg("Unable to write event character: %i", rv); 1100 dbg("Unable to write event character: %i", rv);
1099 return -EIO; 1101 return -EIO;
1100 } 1102 }
1101 1103
1102 return count; 1104 return count;
1103} 1105}
1104 1106
@@ -1135,11 +1137,11 @@ static void remove_sysfs_attrs(struct usb_serial *serial)
1135 struct ftdi_private *priv; 1137 struct ftdi_private *priv;
1136 struct usb_device *udev; 1138 struct usb_device *udev;
1137 1139
1138 dbg("%s",__FUNCTION__); 1140 dbg("%s",__FUNCTION__);
1139 1141
1140 priv = usb_get_serial_port_data(serial->port[0]); 1142 priv = usb_get_serial_port_data(serial->port[0]);
1141 udev = serial->dev; 1143 udev = serial->dev;
1142 1144
1143 /* XXX see create_sysfs_attrs */ 1145 /* XXX see create_sysfs_attrs */
1144 if (priv->chip_type != SIO) { 1146 if (priv->chip_type != SIO) {
1145 device_remove_file(&udev->dev, &dev_attr_event_char); 1147 device_remove_file(&udev->dev, &dev_attr_event_char);
@@ -1147,7 +1149,7 @@ static void remove_sysfs_attrs(struct usb_serial *serial)
1147 device_remove_file(&udev->dev, &dev_attr_latency_timer); 1149 device_remove_file(&udev->dev, &dev_attr_latency_timer);
1148 } 1150 }
1149 } 1151 }
1150 1152
1151} 1153}
1152 1154
1153/* 1155/*
@@ -1258,7 +1260,7 @@ static void ftdi_HE_TIRA1_setup (struct usb_serial *serial)
1258} /* ftdi_HE_TIRA1_setup */ 1260} /* ftdi_HE_TIRA1_setup */
1259 1261
1260 1262
1261/* ftdi_shutdown is called from usbserial:usb_serial_disconnect 1263/* ftdi_shutdown is called from usbserial:usb_serial_disconnect
1262 * it is called when the usb device is disconnected 1264 * it is called when the usb device is disconnected
1263 * 1265 *
1264 * usbserial:usb_serial_disconnect 1266 * usbserial:usb_serial_disconnect
@@ -1269,16 +1271,16 @@ static void ftdi_HE_TIRA1_setup (struct usb_serial *serial)
1269 1271
1270static void ftdi_shutdown (struct usb_serial *serial) 1272static void ftdi_shutdown (struct usb_serial *serial)
1271{ /* ftdi_shutdown */ 1273{ /* ftdi_shutdown */
1272 1274
1273 struct usb_serial_port *port = serial->port[0]; 1275 struct usb_serial_port *port = serial->port[0];
1274 struct ftdi_private *priv = usb_get_serial_port_data(port); 1276 struct ftdi_private *priv = usb_get_serial_port_data(port);
1275 1277
1276 dbg("%s", __FUNCTION__); 1278 dbg("%s", __FUNCTION__);
1277 1279
1278 remove_sysfs_attrs(serial); 1280 remove_sysfs_attrs(serial);
1279 1281
1280 /* all open ports are closed at this point 1282 /* all open ports are closed at this point
1281 * (by usbserial.c:__serial_close, which calls ftdi_close) 1283 * (by usbserial.c:__serial_close, which calls ftdi_close)
1282 */ 1284 */
1283 1285
1284 if (priv) { 1286 if (priv) {
@@ -1293,7 +1295,7 @@ static int ftdi_open (struct usb_serial_port *port, struct file *filp)
1293 struct usb_device *dev = port->serial->dev; 1295 struct usb_device *dev = port->serial->dev;
1294 struct ftdi_private *priv = usb_get_serial_port_data(port); 1296 struct ftdi_private *priv = usb_get_serial_port_data(port);
1295 unsigned long flags; 1297 unsigned long flags;
1296 1298
1297 int result = 0; 1299 int result = 0;
1298 char buf[1]; /* Needed for the usb_control_msg I think */ 1300 char buf[1]; /* Needed for the usb_control_msg I think */
1299 1301
@@ -1312,8 +1314,8 @@ static int ftdi_open (struct usb_serial_port *port, struct file *filp)
1312 /* No error checking for this (will get errors later anyway) */ 1314 /* No error checking for this (will get errors later anyway) */
1313 /* See ftdi_sio.h for description of what is reset */ 1315 /* See ftdi_sio.h for description of what is reset */
1314 usb_control_msg(dev, usb_sndctrlpipe(dev, 0), 1316 usb_control_msg(dev, usb_sndctrlpipe(dev, 0),
1315 FTDI_SIO_RESET_REQUEST, FTDI_SIO_RESET_REQUEST_TYPE, 1317 FTDI_SIO_RESET_REQUEST, FTDI_SIO_RESET_REQUEST_TYPE,
1316 FTDI_SIO_RESET_SIO, 1318 FTDI_SIO_RESET_SIO,
1317 priv->interface, buf, 0, WDR_TIMEOUT); 1319 priv->interface, buf, 0, WDR_TIMEOUT);
1318 1320
1319 /* Termios defaults are set by usb_serial_init. We don't change 1321 /* Termios defaults are set by usb_serial_init. We don't change
@@ -1350,12 +1352,12 @@ static int ftdi_open (struct usb_serial_port *port, struct file *filp)
1350 1352
1351 1353
1352 1354
1353/* 1355/*
1354 * usbserial:__serial_close only calls ftdi_close if the point is open 1356 * usbserial:__serial_close only calls ftdi_close if the point is open
1355 * 1357 *
1356 * This only gets called when it is the last close 1358 * This only gets called when it is the last close
1357 * 1359 *
1358 * 1360 *
1359 */ 1361 */
1360 1362
1361static void ftdi_close (struct usb_serial_port *port, struct file *filp) 1363static void ftdi_close (struct usb_serial_port *port, struct file *filp)
@@ -1368,14 +1370,14 @@ static void ftdi_close (struct usb_serial_port *port, struct file *filp)
1368 1370
1369 if (c_cflag & HUPCL){ 1371 if (c_cflag & HUPCL){
1370 /* Disable flow control */ 1372 /* Disable flow control */
1371 if (usb_control_msg(port->serial->dev, 1373 if (usb_control_msg(port->serial->dev,
1372 usb_sndctrlpipe(port->serial->dev, 0), 1374 usb_sndctrlpipe(port->serial->dev, 0),
1373 FTDI_SIO_SET_FLOW_CTRL_REQUEST, 1375 FTDI_SIO_SET_FLOW_CTRL_REQUEST,
1374 FTDI_SIO_SET_FLOW_CTRL_REQUEST_TYPE, 1376 FTDI_SIO_SET_FLOW_CTRL_REQUEST_TYPE,
1375 0, priv->interface, buf, 0, 1377 0, priv->interface, buf, 0,
1376 WDR_TIMEOUT) < 0) { 1378 WDR_TIMEOUT) < 0) {
1377 err("error from flowcontrol urb"); 1379 err("error from flowcontrol urb");
1378 } 1380 }
1379 1381
1380 /* drop RTS and DTR */ 1382 /* drop RTS and DTR */
1381 clear_mctrl(port, TIOCM_DTR | TIOCM_RTS); 1383 clear_mctrl(port, TIOCM_DTR | TIOCM_RTS);
@@ -1384,14 +1386,14 @@ static void ftdi_close (struct usb_serial_port *port, struct file *filp)
1384 /* cancel any scheduled reading */ 1386 /* cancel any scheduled reading */
1385 cancel_delayed_work(&priv->rx_work); 1387 cancel_delayed_work(&priv->rx_work);
1386 flush_scheduled_work(); 1388 flush_scheduled_work();
1387 1389
1388 /* shutdown our bulk read */ 1390 /* shutdown our bulk read */
1389 if (port->read_urb) 1391 if (port->read_urb)
1390 usb_kill_urb(port->read_urb); 1392 usb_kill_urb(port->read_urb);
1391} /* ftdi_close */ 1393} /* ftdi_close */
1392 1394
1393 1395
1394 1396
1395/* The SIO requires the first byte to have: 1397/* The SIO requires the first byte to have:
1396 * B0 1 1398 * B0 1
1397 * B1 0 1399 * B1 0
@@ -1423,7 +1425,7 @@ static int ftdi_write (struct usb_serial_port *port,
1423 return 0; 1425 return 0;
1424 } 1426 }
1425 spin_unlock_irqrestore(&priv->tx_lock, flags); 1427 spin_unlock_irqrestore(&priv->tx_lock, flags);
1426 1428
1427 data_offset = priv->write_offset; 1429 data_offset = priv->write_offset;
1428 dbg("data_offset set to %d",data_offset); 1430 dbg("data_offset set to %d",data_offset);
1429 1431
@@ -1462,7 +1464,7 @@ static int ftdi_write (struct usb_serial_port *port,
1462 user_pktsz = todo; 1464 user_pktsz = todo;
1463 } 1465 }
1464 /* Write the control byte at the front of the packet*/ 1466 /* Write the control byte at the front of the packet*/
1465 *first_byte = 1 | ((user_pktsz) << 2); 1467 *first_byte = 1 | ((user_pktsz) << 2);
1466 /* Copy data for packet */ 1468 /* Copy data for packet */
1467 memcpy (first_byte + data_offset, 1469 memcpy (first_byte + data_offset,
1468 current_position, user_pktsz); 1470 current_position, user_pktsz);
@@ -1479,7 +1481,7 @@ static int ftdi_write (struct usb_serial_port *port,
1479 usb_serial_debug_data(debug, &port->dev, __FUNCTION__, transfer_size, buffer); 1481 usb_serial_debug_data(debug, &port->dev, __FUNCTION__, transfer_size, buffer);
1480 1482
1481 /* fill the buffer and send it */ 1483 /* fill the buffer and send it */
1482 usb_fill_bulk_urb(urb, port->serial->dev, 1484 usb_fill_bulk_urb(urb, port->serial->dev,
1483 usb_sndbulkpipe(port->serial->dev, port->bulk_out_endpointAddress), 1485 usb_sndbulkpipe(port->serial->dev, port->bulk_out_endpointAddress),
1484 buffer, transfer_size, 1486 buffer, transfer_size,
1485 ftdi_write_bulk_callback, port); 1487 ftdi_write_bulk_callback, port);
@@ -1508,7 +1510,7 @@ static int ftdi_write (struct usb_serial_port *port,
1508 1510
1509/* This function may get called when the device is closed */ 1511/* This function may get called when the device is closed */
1510 1512
1511static void ftdi_write_bulk_callback (struct urb *urb, struct pt_regs *regs) 1513static void ftdi_write_bulk_callback (struct urb *urb)
1512{ 1514{
1513 unsigned long flags; 1515 unsigned long flags;
1514 struct usb_serial_port *port = (struct usb_serial_port *)urb->context; 1516 struct usb_serial_port *port = (struct usb_serial_port *)urb->context;
@@ -1520,7 +1522,7 @@ static void ftdi_write_bulk_callback (struct urb *urb, struct pt_regs *regs)
1520 kfree (urb->transfer_buffer); 1522 kfree (urb->transfer_buffer);
1521 1523
1522 dbg("%s - port %d", __FUNCTION__, port->number); 1524 dbg("%s - port %d", __FUNCTION__, port->number);
1523 1525
1524 if (urb->status) { 1526 if (urb->status) {
1525 dbg("nonzero write bulk status received: %d", urb->status); 1527 dbg("nonzero write bulk status received: %d", urb->status);
1526 return; 1528 return;
@@ -1591,7 +1593,7 @@ static int ftdi_chars_in_buffer (struct usb_serial_port *port)
1591 1593
1592 1594
1593 1595
1594static void ftdi_read_bulk_callback (struct urb *urb, struct pt_regs *regs) 1596static void ftdi_read_bulk_callback (struct urb *urb)
1595{ /* ftdi_read_bulk_callback */ 1597{ /* ftdi_read_bulk_callback */
1596 struct usb_serial_port *port = (struct usb_serial_port *)urb->context; 1598 struct usb_serial_port *port = (struct usb_serial_port *)urb->context;
1597 struct tty_struct *tty; 1599 struct tty_struct *tty;
@@ -1651,7 +1653,7 @@ static void ftdi_process_read (void *param)
1651 struct tty_struct *tty; 1653 struct tty_struct *tty;
1652 struct ftdi_private *priv; 1654 struct ftdi_private *priv;
1653 char error_flag; 1655 char error_flag;
1654 unsigned char *data; 1656 unsigned char *data;
1655 1657
1656 int i; 1658 int i;
1657 int result; 1659 int result;
@@ -1759,7 +1761,7 @@ static void ftdi_process_read (void *param)
1759 } 1761 }
1760 if (length > 0) { 1762 if (length > 0) {
1761 for (i = 2; i < length+2; i++) { 1763 for (i = 2; i < length+2; i++) {
1762 /* Note that the error flag is duplicated for 1764 /* Note that the error flag is duplicated for
1763 every character received since we don't know 1765 every character received since we don't know
1764 which character it applied to */ 1766 which character it applied to */
1765 tty_insert_flip_char(tty, data[packet_offset+i], error_flag); 1767 tty_insert_flip_char(tty, data[packet_offset+i], error_flag);
@@ -1773,7 +1775,7 @@ static void ftdi_process_read (void *param)
1773 This doesn't work well since the application receives a never 1775 This doesn't work well since the application receives a never
1774 ending stream of bad data - even though new data hasn't been sent. 1776 ending stream of bad data - even though new data hasn't been sent.
1775 Therefore I (bill) have taken this out. 1777 Therefore I (bill) have taken this out.
1776 However - this might make sense for framing errors and so on 1778 However - this might make sense for framing errors and so on
1777 so I am leaving the code in for now. 1779 so I am leaving the code in for now.
1778 */ 1780 */
1779 else { 1781 else {
@@ -1827,7 +1829,7 @@ static void ftdi_process_read (void *param)
1827 /* if the port is closed stop trying to read */ 1829 /* if the port is closed stop trying to read */
1828 if (port->open_count > 0){ 1830 if (port->open_count > 0){
1829 /* Continue trying to always read */ 1831 /* Continue trying to always read */
1830 usb_fill_bulk_urb(port->read_urb, port->serial->dev, 1832 usb_fill_bulk_urb(port->read_urb, port->serial->dev,
1831 usb_rcvbulkpipe(port->serial->dev, port->bulk_in_endpointAddress), 1833 usb_rcvbulkpipe(port->serial->dev, port->bulk_in_endpointAddress),
1832 port->read_urb->transfer_buffer, port->read_urb->transfer_buffer_length, 1834 port->read_urb->transfer_buffer, port->read_urb->transfer_buffer_length,
1833 ftdi_read_bulk_callback, port); 1835 ftdi_read_bulk_callback, port);
@@ -1844,9 +1846,9 @@ static void ftdi_process_read (void *param)
1844static void ftdi_break_ctl( struct usb_serial_port *port, int break_state ) 1846static void ftdi_break_ctl( struct usb_serial_port *port, int break_state )
1845{ 1847{
1846 struct ftdi_private *priv = usb_get_serial_port_data(port); 1848 struct ftdi_private *priv = usb_get_serial_port_data(port);
1847 __u16 urb_value = 0; 1849 __u16 urb_value = 0;
1848 char buf[1]; 1850 char buf[1];
1849 1851
1850 /* break_state = -1 to turn on break, and 0 to turn off break */ 1852 /* break_state = -1 to turn on break, and 0 to turn off break */
1851 /* see drivers/char/tty_io.c to see it used */ 1853 /* see drivers/char/tty_io.c to see it used */
1852 /* last_set_data_urb_value NEVER has the break bit set in it */ 1854 /* last_set_data_urb_value NEVER has the break bit set in it */
@@ -1854,20 +1856,20 @@ static void ftdi_break_ctl( struct usb_serial_port *port, int break_state )
1854 if (break_state) { 1856 if (break_state) {
1855 urb_value = priv->last_set_data_urb_value | FTDI_SIO_SET_BREAK; 1857 urb_value = priv->last_set_data_urb_value | FTDI_SIO_SET_BREAK;
1856 } else { 1858 } else {
1857 urb_value = priv->last_set_data_urb_value; 1859 urb_value = priv->last_set_data_urb_value;
1858 } 1860 }
1859 1861
1860 1862
1861 if (usb_control_msg(port->serial->dev, usb_sndctrlpipe(port->serial->dev, 0), 1863 if (usb_control_msg(port->serial->dev, usb_sndctrlpipe(port->serial->dev, 0),
1862 FTDI_SIO_SET_DATA_REQUEST, 1864 FTDI_SIO_SET_DATA_REQUEST,
1863 FTDI_SIO_SET_DATA_REQUEST_TYPE, 1865 FTDI_SIO_SET_DATA_REQUEST_TYPE,
1864 urb_value , priv->interface, 1866 urb_value , priv->interface,
1865 buf, 0, WDR_TIMEOUT) < 0) { 1867 buf, 0, WDR_TIMEOUT) < 0) {
1866 err("%s FAILED to enable/disable break state (state was %d)", __FUNCTION__,break_state); 1868 err("%s FAILED to enable/disable break state (state was %d)", __FUNCTION__,break_state);
1867 } 1869 }
1868 1870
1869 dbg("%s break state is %d - urb is %d", __FUNCTION__,break_state, urb_value); 1871 dbg("%s break state is %d - urb is %d", __FUNCTION__,break_state, urb_value);
1870 1872
1871} 1873}
1872 1874
1873 1875
@@ -1883,12 +1885,12 @@ static void ftdi_set_termios (struct usb_serial_port *port, struct termios *old_
1883 struct ftdi_private *priv = usb_get_serial_port_data(port); 1885 struct ftdi_private *priv = usb_get_serial_port_data(port);
1884 __u16 urb_value; /* will hold the new flags */ 1886 __u16 urb_value; /* will hold the new flags */
1885 char buf[1]; /* Perhaps I should dynamically alloc this? */ 1887 char buf[1]; /* Perhaps I should dynamically alloc this? */
1886 1888
1887 // Added for xon/xoff support 1889 // Added for xon/xoff support
1888 unsigned int iflag = port->tty->termios->c_iflag; 1890 unsigned int iflag = port->tty->termios->c_iflag;
1889 unsigned char vstop; 1891 unsigned char vstop;
1890 unsigned char vstart; 1892 unsigned char vstart;
1891 1893
1892 dbg("%s", __FUNCTION__); 1894 dbg("%s", __FUNCTION__);
1893 1895
1894 /* Force baud rate if this device requires it, unless it is set to B0. */ 1896 /* Force baud rate if this device requires it, unless it is set to B0. */
@@ -1906,20 +1908,20 @@ static void ftdi_set_termios (struct usb_serial_port *port, struct termios *old_
1906 1908
1907 cflag = port->tty->termios->c_cflag; 1909 cflag = port->tty->termios->c_cflag;
1908 1910
1909 /* FIXME -For this cut I don't care if the line is really changing or 1911 /* FIXME -For this cut I don't care if the line is really changing or
1910 not - so just do the change regardless - should be able to 1912 not - so just do the change regardless - should be able to
1911 compare old_termios and tty->termios */ 1913 compare old_termios and tty->termios */
1912 /* NOTE These routines can get interrupted by 1914 /* NOTE These routines can get interrupted by
1913 ftdi_sio_read_bulk_callback - need to examine what this 1915 ftdi_sio_read_bulk_callback - need to examine what this
1914 means - don't see any problems yet */ 1916 means - don't see any problems yet */
1915 1917
1916 /* Set number of data bits, parity, stop bits */ 1918 /* Set number of data bits, parity, stop bits */
1917 1919
1918 urb_value = 0; 1920 urb_value = 0;
1919 urb_value |= (cflag & CSTOPB ? FTDI_SIO_SET_DATA_STOP_BITS_2 : 1921 urb_value |= (cflag & CSTOPB ? FTDI_SIO_SET_DATA_STOP_BITS_2 :
1920 FTDI_SIO_SET_DATA_STOP_BITS_1); 1922 FTDI_SIO_SET_DATA_STOP_BITS_1);
1921 urb_value |= (cflag & PARENB ? 1923 urb_value |= (cflag & PARENB ?
1922 (cflag & PARODD ? FTDI_SIO_SET_DATA_PARITY_ODD : 1924 (cflag & PARODD ? FTDI_SIO_SET_DATA_PARITY_ODD :
1923 FTDI_SIO_SET_DATA_PARITY_EVEN) : 1925 FTDI_SIO_SET_DATA_PARITY_EVEN) :
1924 FTDI_SIO_SET_DATA_PARITY_NONE); 1926 FTDI_SIO_SET_DATA_PARITY_NONE);
1925 if (cflag & CSIZE) { 1927 if (cflag & CSIZE) {
@@ -1936,25 +1938,25 @@ static void ftdi_set_termios (struct usb_serial_port *port, struct termios *old_
1936 /* This is needed by the break command since it uses the same command - but is 1938 /* This is needed by the break command since it uses the same command - but is
1937 * or'ed with this value */ 1939 * or'ed with this value */
1938 priv->last_set_data_urb_value = urb_value; 1940 priv->last_set_data_urb_value = urb_value;
1939 1941
1940 if (usb_control_msg(dev, usb_sndctrlpipe(dev, 0), 1942 if (usb_control_msg(dev, usb_sndctrlpipe(dev, 0),
1941 FTDI_SIO_SET_DATA_REQUEST, 1943 FTDI_SIO_SET_DATA_REQUEST,
1942 FTDI_SIO_SET_DATA_REQUEST_TYPE, 1944 FTDI_SIO_SET_DATA_REQUEST_TYPE,
1943 urb_value , priv->interface, 1945 urb_value , priv->interface,
1944 buf, 0, WDR_SHORT_TIMEOUT) < 0) { 1946 buf, 0, WDR_SHORT_TIMEOUT) < 0) {
1945 err("%s FAILED to set databits/stopbits/parity", __FUNCTION__); 1947 err("%s FAILED to set databits/stopbits/parity", __FUNCTION__);
1946 } 1948 }
1947 1949
1948 /* Now do the baudrate */ 1950 /* Now do the baudrate */
1949 if ((cflag & CBAUD) == B0 ) { 1951 if ((cflag & CBAUD) == B0 ) {
1950 /* Disable flow control */ 1952 /* Disable flow control */
1951 if (usb_control_msg(dev, usb_sndctrlpipe(dev, 0), 1953 if (usb_control_msg(dev, usb_sndctrlpipe(dev, 0),
1952 FTDI_SIO_SET_FLOW_CTRL_REQUEST, 1954 FTDI_SIO_SET_FLOW_CTRL_REQUEST,
1953 FTDI_SIO_SET_FLOW_CTRL_REQUEST_TYPE, 1955 FTDI_SIO_SET_FLOW_CTRL_REQUEST_TYPE,
1954 0, priv->interface, 1956 0, priv->interface,
1955 buf, 0, WDR_TIMEOUT) < 0) { 1957 buf, 0, WDR_TIMEOUT) < 0) {
1956 err("%s error from disable flowcontrol urb", __FUNCTION__); 1958 err("%s error from disable flowcontrol urb", __FUNCTION__);
1957 } 1959 }
1958 /* Drop RTS and DTR */ 1960 /* Drop RTS and DTR */
1959 clear_mctrl(port, TIOCM_DTR | TIOCM_RTS); 1961 clear_mctrl(port, TIOCM_DTR | TIOCM_RTS);
1960 } else { 1962 } else {
@@ -1972,16 +1974,16 @@ static void ftdi_set_termios (struct usb_serial_port *port, struct termios *old_
1972 /* Note device also supports DTR/CD (ugh) and Xon/Xoff in hardware */ 1974 /* Note device also supports DTR/CD (ugh) and Xon/Xoff in hardware */
1973 if (cflag & CRTSCTS) { 1975 if (cflag & CRTSCTS) {
1974 dbg("%s Setting to CRTSCTS flow control", __FUNCTION__); 1976 dbg("%s Setting to CRTSCTS flow control", __FUNCTION__);
1975 if (usb_control_msg(dev, 1977 if (usb_control_msg(dev,
1976 usb_sndctrlpipe(dev, 0), 1978 usb_sndctrlpipe(dev, 0),
1977 FTDI_SIO_SET_FLOW_CTRL_REQUEST, 1979 FTDI_SIO_SET_FLOW_CTRL_REQUEST,
1978 FTDI_SIO_SET_FLOW_CTRL_REQUEST_TYPE, 1980 FTDI_SIO_SET_FLOW_CTRL_REQUEST_TYPE,
1979 0 , (FTDI_SIO_RTS_CTS_HS | priv->interface), 1981 0 , (FTDI_SIO_RTS_CTS_HS | priv->interface),
1980 buf, 0, WDR_TIMEOUT) < 0) { 1982 buf, 0, WDR_TIMEOUT) < 0) {
1981 err("urb failed to set to rts/cts flow control"); 1983 err("urb failed to set to rts/cts flow control");
1982 } 1984 }
1983 1985
1984 } else { 1986 } else {
1985 /* 1987 /*
1986 * Xon/Xoff code 1988 * Xon/Xoff code
1987 * 1989 *
@@ -2011,16 +2013,16 @@ static void ftdi_set_termios (struct usb_serial_port *port, struct termios *old_
2011 /* else clause to only run if cfag ! CRTSCTS and iflag ! XOFF */ 2013 /* else clause to only run if cfag ! CRTSCTS and iflag ! XOFF */
2012 /* CHECKME Assuming XON/XOFF handled by tty stack - not by device */ 2014 /* CHECKME Assuming XON/XOFF handled by tty stack - not by device */
2013 dbg("%s Turning off hardware flow control", __FUNCTION__); 2015 dbg("%s Turning off hardware flow control", __FUNCTION__);
2014 if (usb_control_msg(dev, 2016 if (usb_control_msg(dev,
2015 usb_sndctrlpipe(dev, 0), 2017 usb_sndctrlpipe(dev, 0),
2016 FTDI_SIO_SET_FLOW_CTRL_REQUEST, 2018 FTDI_SIO_SET_FLOW_CTRL_REQUEST,
2017 FTDI_SIO_SET_FLOW_CTRL_REQUEST_TYPE, 2019 FTDI_SIO_SET_FLOW_CTRL_REQUEST_TYPE,
2018 0, priv->interface, 2020 0, priv->interface,
2019 buf, 0, WDR_TIMEOUT) < 0) { 2021 buf, 0, WDR_TIMEOUT) < 0) {
2020 err("urb failed to clear flow control"); 2022 err("urb failed to clear flow control");
2021 } 2023 }
2022 } 2024 }
2023 2025
2024 } 2026 }
2025 return; 2027 return;
2026} /* ftdi_termios */ 2028} /* ftdi_termios */
@@ -2036,11 +2038,11 @@ static int ftdi_tiocmget (struct usb_serial_port *port, struct file *file)
2036 switch (priv->chip_type) { 2038 switch (priv->chip_type) {
2037 case SIO: 2039 case SIO:
2038 /* Request the status from the device */ 2040 /* Request the status from the device */
2039 if ((ret = usb_control_msg(port->serial->dev, 2041 if ((ret = usb_control_msg(port->serial->dev,
2040 usb_rcvctrlpipe(port->serial->dev, 0), 2042 usb_rcvctrlpipe(port->serial->dev, 0),
2041 FTDI_SIO_GET_MODEM_STATUS_REQUEST, 2043 FTDI_SIO_GET_MODEM_STATUS_REQUEST,
2042 FTDI_SIO_GET_MODEM_STATUS_REQUEST_TYPE, 2044 FTDI_SIO_GET_MODEM_STATUS_REQUEST_TYPE,
2043 0, 0, 2045 0, 0,
2044 buf, 1, WDR_TIMEOUT)) < 0 ) { 2046 buf, 1, WDR_TIMEOUT)) < 0 ) {
2045 err("%s Could not get modem status of device - err: %d", __FUNCTION__, 2047 err("%s Could not get modem status of device - err: %d", __FUNCTION__,
2046 ret); 2048 ret);
@@ -2052,11 +2054,11 @@ static int ftdi_tiocmget (struct usb_serial_port *port, struct file *file)
2052 case FT2232C: 2054 case FT2232C:
2053 /* the 8U232AM returns a two byte value (the sio is a 1 byte value) - in the same 2055 /* the 8U232AM returns a two byte value (the sio is a 1 byte value) - in the same
2054 format as the data returned from the in point */ 2056 format as the data returned from the in point */
2055 if ((ret = usb_control_msg(port->serial->dev, 2057 if ((ret = usb_control_msg(port->serial->dev,
2056 usb_rcvctrlpipe(port->serial->dev, 0), 2058 usb_rcvctrlpipe(port->serial->dev, 0),
2057 FTDI_SIO_GET_MODEM_STATUS_REQUEST, 2059 FTDI_SIO_GET_MODEM_STATUS_REQUEST,
2058 FTDI_SIO_GET_MODEM_STATUS_REQUEST_TYPE, 2060 FTDI_SIO_GET_MODEM_STATUS_REQUEST_TYPE,
2059 0, priv->interface, 2061 0, priv->interface,
2060 buf, 2, WDR_TIMEOUT)) < 0 ) { 2062 buf, 2, WDR_TIMEOUT)) < 0 ) {
2061 err("%s Could not get modem status of device - err: %d", __FUNCTION__, 2063 err("%s Could not get modem status of device - err: %d", __FUNCTION__,
2062 ret); 2064 ret);
@@ -2067,12 +2069,12 @@ static int ftdi_tiocmget (struct usb_serial_port *port, struct file *file)
2067 return -EFAULT; 2069 return -EFAULT;
2068 break; 2070 break;
2069 } 2071 }
2070 2072
2071 return (buf[0] & FTDI_SIO_DSR_MASK ? TIOCM_DSR : 0) | 2073 return (buf[0] & FTDI_SIO_DSR_MASK ? TIOCM_DSR : 0) |
2072 (buf[0] & FTDI_SIO_CTS_MASK ? TIOCM_CTS : 0) | 2074 (buf[0] & FTDI_SIO_CTS_MASK ? TIOCM_CTS : 0) |
2073 (buf[0] & FTDI_SIO_RI_MASK ? TIOCM_RI : 0) | 2075 (buf[0] & FTDI_SIO_RI_MASK ? TIOCM_RI : 0) |
2074 (buf[0] & FTDI_SIO_RLSD_MASK ? TIOCM_CD : 0) | 2076 (buf[0] & FTDI_SIO_RLSD_MASK ? TIOCM_CD : 0) |
2075 priv->last_dtr_rts; 2077 priv->last_dtr_rts;
2076} 2078}
2077 2079
2078static int ftdi_tiocmset(struct usb_serial_port *port, struct file * file, unsigned int set, unsigned int clear) 2080static int ftdi_tiocmset(struct usb_serial_port *port, struct file * file, unsigned int set, unsigned int clear)
@@ -2138,11 +2140,11 @@ static int ftdi_ioctl (struct usb_serial_port *port, struct file * file, unsigne
2138 break; 2140 break;
2139 default: 2141 default:
2140 break; 2142 break;
2141 2143
2142 } 2144 }
2143 2145
2144 2146
2145 /* This is not necessarily an error - turns out the higher layers will do 2147 /* This is not necessarily an error - turns out the higher layers will do
2146 * some ioctls itself (see comment above) 2148 * some ioctls itself (see comment above)
2147 */ 2149 */
2148 dbg("%s arg not supported - it was 0x%04x - check /usr/include/asm/ioctls.h", __FUNCTION__, cmd); 2150 dbg("%s arg not supported - it was 0x%04x - check /usr/include/asm/ioctls.h", __FUNCTION__, cmd);
@@ -2199,7 +2201,7 @@ static int __init ftdi_init (void)
2199 if (retval) 2201 if (retval)
2200 goto failed_sio_register; 2202 goto failed_sio_register;
2201 retval = usb_register(&ftdi_driver); 2203 retval = usb_register(&ftdi_driver);
2202 if (retval) 2204 if (retval)
2203 goto failed_usb_register; 2205 goto failed_usb_register;
2204 2206
2205 info(DRIVER_VERSION ":" DRIVER_DESC); 2207 info(DRIVER_VERSION ":" DRIVER_DESC);
diff --git a/drivers/usb/serial/ftdi_sio.h b/drivers/usb/serial/ftdi_sio.h
index f0edb87d2dd5..bae117d359af 100644
--- a/drivers/usb/serial/ftdi_sio.h
+++ b/drivers/usb/serial/ftdi_sio.h
@@ -55,6 +55,9 @@
55/* iPlus device */ 55/* iPlus device */
56#define FTDI_IPLUS_PID 0xD070 /* Product Id */ 56#define FTDI_IPLUS_PID 0xD070 /* Product Id */
57 57
58/* DMX4ALL DMX Interfaces */
59#define FTDI_DMX4ALL 0xC850
60
58/* www.crystalfontz.com devices - thanx for providing free devices for evaluation ! */ 61/* www.crystalfontz.com devices - thanx for providing free devices for evaluation ! */
59/* they use the ftdi chipset for the USB interface and the vendor id is the same */ 62/* they use the ftdi chipset for the USB interface and the vendor id is the same */
60#define FTDI_XF_632_PID 0xFC08 /* 632: 16x2 Character Display */ 63#define FTDI_XF_632_PID 0xFC08 /* 632: 16x2 Character Display */
@@ -175,9 +178,15 @@
175#define FTDI_ASK_RDR400_PID 0xC991 /* ASK RDR 400 series card reader */ 178#define FTDI_ASK_RDR400_PID 0xC991 /* ASK RDR 400 series card reader */
176 179
177/* 180/*
181 * FTDI USB UART chips used in construction projects from the
182 * Elektor Electronics magazine (http://elektor-electronics.co.uk)
183 */
184#define ELEKTOR_VID 0x0C7D
185#define ELEKTOR_FT323R_PID 0x0005 /* RFID-Reader, issue 09-2006 */
186
187/*
178 * DSS-20 Sync Station for Sony Ericsson P800 188 * DSS-20 Sync Station for Sony Ericsson P800
179 */ 189 */
180
181#define FTDI_DSS20_PID 0xFC82 190#define FTDI_DSS20_PID 0xFC82
182 191
183/* 192/*
diff --git a/drivers/usb/serial/garmin_gps.c b/drivers/usb/serial/garmin_gps.c
index 4b1196a8b09e..4543152a9966 100644
--- a/drivers/usb/serial/garmin_gps.c
+++ b/drivers/usb/serial/garmin_gps.c
@@ -1031,7 +1031,7 @@ static void garmin_close (struct usb_serial_port *port, struct file * filp)
1031} 1031}
1032 1032
1033 1033
1034static void garmin_write_bulk_callback (struct urb *urb, struct pt_regs *regs) 1034static void garmin_write_bulk_callback (struct urb *urb)
1035{ 1035{
1036 unsigned long flags; 1036 unsigned long flags;
1037 struct usb_serial_port *port = (struct usb_serial_port *)urb->context; 1037 struct usb_serial_port *port = (struct usb_serial_port *)urb->context;
@@ -1274,7 +1274,7 @@ static void garmin_read_process(struct garmin_data * garmin_data_p,
1274} 1274}
1275 1275
1276 1276
1277static void garmin_read_bulk_callback (struct urb *urb, struct pt_regs *regs) 1277static void garmin_read_bulk_callback (struct urb *urb)
1278{ 1278{
1279 unsigned long flags; 1279 unsigned long flags;
1280 struct usb_serial_port *port = (struct usb_serial_port *)urb->context; 1280 struct usb_serial_port *port = (struct usb_serial_port *)urb->context;
@@ -1330,7 +1330,7 @@ static void garmin_read_bulk_callback (struct urb *urb, struct pt_regs *regs)
1330} 1330}
1331 1331
1332 1332
1333static void garmin_read_int_callback (struct urb *urb, struct pt_regs *regs) 1333static void garmin_read_int_callback (struct urb *urb)
1334{ 1334{
1335 unsigned long flags; 1335 unsigned long flags;
1336 int status; 1336 int status;
diff --git a/drivers/usb/serial/generic.c b/drivers/usb/serial/generic.c
index 21cbaa0fb96b..36042937e77f 100644
--- a/drivers/usb/serial/generic.c
+++ b/drivers/usb/serial/generic.c
@@ -248,7 +248,7 @@ int usb_serial_generic_chars_in_buffer (struct usb_serial_port *port)
248 return (chars); 248 return (chars);
249} 249}
250 250
251void usb_serial_generic_read_bulk_callback (struct urb *urb, struct pt_regs *regs) 251void usb_serial_generic_read_bulk_callback (struct urb *urb)
252{ 252{
253 struct usb_serial_port *port = (struct usb_serial_port *)urb->context; 253 struct usb_serial_port *port = (struct usb_serial_port *)urb->context;
254 struct usb_serial *serial = port->serial; 254 struct usb_serial *serial = port->serial;
@@ -287,7 +287,7 @@ void usb_serial_generic_read_bulk_callback (struct urb *urb, struct pt_regs *reg
287} 287}
288EXPORT_SYMBOL_GPL(usb_serial_generic_read_bulk_callback); 288EXPORT_SYMBOL_GPL(usb_serial_generic_read_bulk_callback);
289 289
290void usb_serial_generic_write_bulk_callback (struct urb *urb, struct pt_regs *regs) 290void usb_serial_generic_write_bulk_callback (struct urb *urb)
291{ 291{
292 struct usb_serial_port *port = (struct usb_serial_port *)urb->context; 292 struct usb_serial_port *port = (struct usb_serial_port *)urb->context;
293 293
diff --git a/drivers/usb/serial/io_edgeport.c b/drivers/usb/serial/io_edgeport.c
index c49976c3ad52..91bd3014ef1e 100644
--- a/drivers/usb/serial/io_edgeport.c
+++ b/drivers/usb/serial/io_edgeport.c
@@ -216,10 +216,10 @@ static int CmdUrbs = 0; /* Number of outstanding Command Write Urbs */
216/* local function prototypes */ 216/* local function prototypes */
217 217
218/* function prototypes for all URB callbacks */ 218/* function prototypes for all URB callbacks */
219static void edge_interrupt_callback (struct urb *urb, struct pt_regs *regs); 219static void edge_interrupt_callback (struct urb *urb);
220static void edge_bulk_in_callback (struct urb *urb, struct pt_regs *regs); 220static void edge_bulk_in_callback (struct urb *urb);
221static void edge_bulk_out_data_callback (struct urb *urb, struct pt_regs *regs); 221static void edge_bulk_out_data_callback (struct urb *urb);
222static void edge_bulk_out_cmd_callback (struct urb *urb, struct pt_regs *regs); 222static void edge_bulk_out_cmd_callback (struct urb *urb);
223 223
224/* function prototypes for the usbserial callbacks */ 224/* function prototypes for the usbserial callbacks */
225static int edge_open (struct usb_serial_port *port, struct file *filp); 225static int edge_open (struct usb_serial_port *port, struct file *filp);
@@ -534,7 +534,7 @@ static void get_product_info(struct edgeport_serial *edge_serial)
534 * this is the callback function for when we have received data on the 534 * this is the callback function for when we have received data on the
535 * interrupt endpoint. 535 * interrupt endpoint.
536 *****************************************************************************/ 536 *****************************************************************************/
537static void edge_interrupt_callback (struct urb *urb, struct pt_regs *regs) 537static void edge_interrupt_callback (struct urb *urb)
538{ 538{
539 struct edgeport_serial *edge_serial = (struct edgeport_serial *)urb->context; 539 struct edgeport_serial *edge_serial = (struct edgeport_serial *)urb->context;
540 struct edgeport_port *edge_port; 540 struct edgeport_port *edge_port;
@@ -631,7 +631,7 @@ exit:
631 * this is the callback function for when we have received data on the 631 * this is the callback function for when we have received data on the
632 * bulk in endpoint. 632 * bulk in endpoint.
633 *****************************************************************************/ 633 *****************************************************************************/
634static void edge_bulk_in_callback (struct urb *urb, struct pt_regs *regs) 634static void edge_bulk_in_callback (struct urb *urb)
635{ 635{
636 struct edgeport_serial *edge_serial = (struct edgeport_serial *)urb->context; 636 struct edgeport_serial *edge_serial = (struct edgeport_serial *)urb->context;
637 unsigned char *data = urb->transfer_buffer; 637 unsigned char *data = urb->transfer_buffer;
@@ -687,7 +687,7 @@ static void edge_bulk_in_callback (struct urb *urb, struct pt_regs *regs)
687 * this is the callback function for when we have finished sending serial data 687 * this is the callback function for when we have finished sending serial data
688 * on the bulk out endpoint. 688 * on the bulk out endpoint.
689 *****************************************************************************/ 689 *****************************************************************************/
690static void edge_bulk_out_data_callback (struct urb *urb, struct pt_regs *regs) 690static void edge_bulk_out_data_callback (struct urb *urb)
691{ 691{
692 struct edgeport_port *edge_port = (struct edgeport_port *)urb->context; 692 struct edgeport_port *edge_port = (struct edgeport_port *)urb->context;
693 struct tty_struct *tty; 693 struct tty_struct *tty;
@@ -718,7 +718,7 @@ static void edge_bulk_out_data_callback (struct urb *urb, struct pt_regs *regs)
718 * this is the callback function for when we have finished sending a command 718 * this is the callback function for when we have finished sending a command
719 * on the bulk out endpoint. 719 * on the bulk out endpoint.
720 *****************************************************************************/ 720 *****************************************************************************/
721static void edge_bulk_out_cmd_callback (struct urb *urb, struct pt_regs *regs) 721static void edge_bulk_out_cmd_callback (struct urb *urb)
722{ 722{
723 struct edgeport_port *edge_port = (struct edgeport_port *)urb->context; 723 struct edgeport_port *edge_port = (struct edgeport_port *)urb->context;
724 struct tty_struct *tty; 724 struct tty_struct *tty;
diff --git a/drivers/usb/serial/io_ti.c b/drivers/usb/serial/io_ti.c
index 17c5b1d2311a..ee0c921e1520 100644
--- a/drivers/usb/serial/io_ti.c
+++ b/drivers/usb/serial/io_ti.c
@@ -1697,7 +1697,7 @@ static void handle_new_lsr (struct edgeport_port *edge_port, int lsr_data, __u8
1697} 1697}
1698 1698
1699 1699
1700static void edge_interrupt_callback (struct urb *urb, struct pt_regs *regs) 1700static void edge_interrupt_callback (struct urb *urb)
1701{ 1701{
1702 struct edgeport_serial *edge_serial = (struct edgeport_serial *)urb->context; 1702 struct edgeport_serial *edge_serial = (struct edgeport_serial *)urb->context;
1703 struct usb_serial_port *port; 1703 struct usb_serial_port *port;
@@ -1787,7 +1787,7 @@ exit:
1787 __FUNCTION__, status); 1787 __FUNCTION__, status);
1788} 1788}
1789 1789
1790static void edge_bulk_in_callback (struct urb *urb, struct pt_regs *regs) 1790static void edge_bulk_in_callback (struct urb *urb)
1791{ 1791{
1792 struct edgeport_port *edge_port = (struct edgeport_port *)urb->context; 1792 struct edgeport_port *edge_port = (struct edgeport_port *)urb->context;
1793 unsigned char *data = urb->transfer_buffer; 1793 unsigned char *data = urb->transfer_buffer;
@@ -1879,7 +1879,7 @@ static void edge_tty_recv(struct device *dev, struct tty_struct *tty, unsigned c
1879 tty_flip_buffer_push(tty); 1879 tty_flip_buffer_push(tty);
1880} 1880}
1881 1881
1882static void edge_bulk_out_callback (struct urb *urb, struct pt_regs *regs) 1882static void edge_bulk_out_callback (struct urb *urb)
1883{ 1883{
1884 struct usb_serial_port *port = (struct usb_serial_port *)urb->context; 1884 struct usb_serial_port *port = (struct usb_serial_port *)urb->context;
1885 struct edgeport_port *edge_port = usb_get_serial_port_data(port); 1885 struct edgeport_port *edge_port = usb_get_serial_port_data(port);
diff --git a/drivers/usb/serial/ipaq.c b/drivers/usb/serial/ipaq.c
index cbc725a6c58e..d72cf8bc7f76 100644
--- a/drivers/usb/serial/ipaq.c
+++ b/drivers/usb/serial/ipaq.c
@@ -83,8 +83,8 @@ static int ipaq_write(struct usb_serial_port *port, const unsigned char *buf,
83static int ipaq_write_bulk(struct usb_serial_port *port, const unsigned char *buf, 83static int ipaq_write_bulk(struct usb_serial_port *port, const unsigned char *buf,
84 int count); 84 int count);
85static void ipaq_write_gather(struct usb_serial_port *port); 85static void ipaq_write_gather(struct usb_serial_port *port);
86static void ipaq_read_bulk_callback (struct urb *urb, struct pt_regs *regs); 86static void ipaq_read_bulk_callback (struct urb *urb);
87static void ipaq_write_bulk_callback(struct urb *urb, struct pt_regs *regs); 87static void ipaq_write_bulk_callback(struct urb *urb);
88static int ipaq_write_room(struct usb_serial_port *port); 88static int ipaq_write_room(struct usb_serial_port *port);
89static int ipaq_chars_in_buffer(struct usb_serial_port *port); 89static int ipaq_chars_in_buffer(struct usb_serial_port *port);
90static void ipaq_destroy_lists(struct usb_serial_port *port); 90static void ipaq_destroy_lists(struct usb_serial_port *port);
@@ -320,6 +320,7 @@ static struct usb_device_id ipaq_id_table [] = {
320 { USB_DEVICE(0x0B05, 0x9200) }, /* ASUS USB Sync */ 320 { USB_DEVICE(0x0B05, 0x9200) }, /* ASUS USB Sync */
321 { USB_DEVICE(0x0B05, 0x9202) }, /* ASUS USB Sync */ 321 { USB_DEVICE(0x0B05, 0x9202) }, /* ASUS USB Sync */
322 { USB_DEVICE(0x0BB4, 0x00CE) }, /* HTC USB Sync */ 322 { USB_DEVICE(0x0BB4, 0x00CE) }, /* HTC USB Sync */
323 { USB_DEVICE(0x0BB4, 0x00CF) }, /* HTC USB Modem */
323 { USB_DEVICE(0x0BB4, 0x0A01) }, /* PocketPC USB Sync */ 324 { USB_DEVICE(0x0BB4, 0x0A01) }, /* PocketPC USB Sync */
324 { USB_DEVICE(0x0BB4, 0x0A02) }, /* PocketPC USB Sync */ 325 { USB_DEVICE(0x0BB4, 0x0A02) }, /* PocketPC USB Sync */
325 { USB_DEVICE(0x0BB4, 0x0A03) }, /* PocketPC USB Sync */ 326 { USB_DEVICE(0x0BB4, 0x0A03) }, /* PocketPC USB Sync */
@@ -721,7 +722,7 @@ static void ipaq_close(struct usb_serial_port *port, struct file *filp)
721 /* info ("Bytes In = %d Bytes Out = %d", bytes_in, bytes_out); */ 722 /* info ("Bytes In = %d Bytes Out = %d", bytes_in, bytes_out); */
722} 723}
723 724
724static void ipaq_read_bulk_callback(struct urb *urb, struct pt_regs *regs) 725static void ipaq_read_bulk_callback(struct urb *urb)
725{ 726{
726 struct usb_serial_port *port = (struct usb_serial_port *)urb->context; 727 struct usb_serial_port *port = (struct usb_serial_port *)urb->context;
727 struct tty_struct *tty; 728 struct tty_struct *tty;
@@ -859,7 +860,7 @@ static void ipaq_write_gather(struct usb_serial_port *port)
859 return; 860 return;
860} 861}
861 862
862static void ipaq_write_bulk_callback(struct urb *urb, struct pt_regs *regs) 863static void ipaq_write_bulk_callback(struct urb *urb)
863{ 864{
864 struct usb_serial_port *port = (struct usb_serial_port *)urb->context; 865 struct usb_serial_port *port = (struct usb_serial_port *)urb->context;
865 struct ipaq_private *priv = usb_get_serial_port_data(port); 866 struct ipaq_private *priv = usb_get_serial_port_data(port);
diff --git a/drivers/usb/serial/ipw.c b/drivers/usb/serial/ipw.c
index 812bc213a963..2a4bb66691ad 100644
--- a/drivers/usb/serial/ipw.c
+++ b/drivers/usb/serial/ipw.c
@@ -161,7 +161,7 @@ static struct usb_driver usb_ipw_driver = {
161 161
162static int debug; 162static int debug;
163 163
164static void ipw_read_bulk_callback(struct urb *urb, struct pt_regs *regs) 164static void ipw_read_bulk_callback(struct urb *urb)
165{ 165{
166 struct usb_serial_port *port = urb->context; 166 struct usb_serial_port *port = urb->context;
167 unsigned char *data = urb->transfer_buffer; 167 unsigned char *data = urb->transfer_buffer;
@@ -367,7 +367,7 @@ static void ipw_close(struct usb_serial_port *port, struct file * filp)
367 usb_kill_urb(port->write_urb); 367 usb_kill_urb(port->write_urb);
368} 368}
369 369
370static void ipw_write_bulk_callback(struct urb *urb, struct pt_regs *regs) 370static void ipw_write_bulk_callback(struct urb *urb)
371{ 371{
372 struct usb_serial_port *port = urb->context; 372 struct usb_serial_port *port = urb->context;
373 373
diff --git a/drivers/usb/serial/ir-usb.c b/drivers/usb/serial/ir-usb.c
index 1b348df388ed..331bf81556fc 100644
--- a/drivers/usb/serial/ir-usb.c
+++ b/drivers/usb/serial/ir-usb.c
@@ -105,8 +105,8 @@ static int ir_startup (struct usb_serial *serial);
105static int ir_open (struct usb_serial_port *port, struct file *filep); 105static int ir_open (struct usb_serial_port *port, struct file *filep);
106static void ir_close (struct usb_serial_port *port, struct file *filep); 106static void ir_close (struct usb_serial_port *port, struct file *filep);
107static int ir_write (struct usb_serial_port *port, const unsigned char *buf, int count); 107static int ir_write (struct usb_serial_port *port, const unsigned char *buf, int count);
108static void ir_write_bulk_callback (struct urb *urb, struct pt_regs *regs); 108static void ir_write_bulk_callback (struct urb *urb);
109static void ir_read_bulk_callback (struct urb *urb, struct pt_regs *regs); 109static void ir_read_bulk_callback (struct urb *urb);
110static void ir_set_termios (struct usb_serial_port *port, struct termios *old_termios); 110static void ir_set_termios (struct usb_serial_port *port, struct termios *old_termios);
111 111
112static u8 ir_baud = 0; 112static u8 ir_baud = 0;
@@ -388,7 +388,7 @@ static int ir_write (struct usb_serial_port *port, const unsigned char *buf, int
388 return result; 388 return result;
389} 389}
390 390
391static void ir_write_bulk_callback (struct urb *urb, struct pt_regs *regs) 391static void ir_write_bulk_callback (struct urb *urb)
392{ 392{
393 struct usb_serial_port *port = (struct usb_serial_port *)urb->context; 393 struct usb_serial_port *port = (struct usb_serial_port *)urb->context;
394 394
@@ -410,7 +410,7 @@ static void ir_write_bulk_callback (struct urb *urb, struct pt_regs *regs)
410 usb_serial_port_softint(port); 410 usb_serial_port_softint(port);
411} 411}
412 412
413static void ir_read_bulk_callback (struct urb *urb, struct pt_regs *regs) 413static void ir_read_bulk_callback (struct urb *urb)
414{ 414{
415 struct usb_serial_port *port = (struct usb_serial_port *)urb->context; 415 struct usb_serial_port *port = (struct usb_serial_port *)urb->context;
416 struct tty_struct *tty; 416 struct tty_struct *tty;
diff --git a/drivers/usb/serial/keyspan.c b/drivers/usb/serial/keyspan.c
index 015ad6cc1bbb..53be824eb1bf 100644
--- a/drivers/usb/serial/keyspan.c
+++ b/drivers/usb/serial/keyspan.c
@@ -412,7 +412,7 @@ static int keyspan_write(struct usb_serial_port *port,
412 return count - left; 412 return count - left;
413} 413}
414 414
415static void usa26_indat_callback(struct urb *urb, struct pt_regs *regs) 415static void usa26_indat_callback(struct urb *urb)
416{ 416{
417 int i, err; 417 int i, err;
418 int endpoint; 418 int endpoint;
@@ -470,7 +470,7 @@ static void usa26_indat_callback(struct urb *urb, struct pt_regs *regs)
470} 470}
471 471
472 /* Outdat handling is common for all devices */ 472 /* Outdat handling is common for all devices */
473static void usa2x_outdat_callback(struct urb *urb, struct pt_regs *regs) 473static void usa2x_outdat_callback(struct urb *urb)
474{ 474{
475 struct usb_serial_port *port; 475 struct usb_serial_port *port;
476 struct keyspan_port_private *p_priv; 476 struct keyspan_port_private *p_priv;
@@ -483,13 +483,13 @@ static void usa2x_outdat_callback(struct urb *urb, struct pt_regs *regs)
483 usb_serial_port_softint(port); 483 usb_serial_port_softint(port);
484} 484}
485 485
486static void usa26_inack_callback(struct urb *urb, struct pt_regs *regs) 486static void usa26_inack_callback(struct urb *urb)
487{ 487{
488 dbg ("%s", __FUNCTION__); 488 dbg ("%s", __FUNCTION__);
489 489
490} 490}
491 491
492static void usa26_outcont_callback(struct urb *urb, struct pt_regs *regs) 492static void usa26_outcont_callback(struct urb *urb)
493{ 493{
494 struct usb_serial_port *port; 494 struct usb_serial_port *port;
495 struct keyspan_port_private *p_priv; 495 struct keyspan_port_private *p_priv;
@@ -503,7 +503,7 @@ static void usa26_outcont_callback(struct urb *urb, struct pt_regs *regs)
503 } 503 }
504} 504}
505 505
506static void usa26_instat_callback(struct urb *urb, struct pt_regs *regs) 506static void usa26_instat_callback(struct urb *urb)
507{ 507{
508 unsigned char *data = urb->transfer_buffer; 508 unsigned char *data = urb->transfer_buffer;
509 struct keyspan_usa26_portStatusMessage *msg; 509 struct keyspan_usa26_portStatusMessage *msg;
@@ -565,14 +565,14 @@ static void usa26_instat_callback(struct urb *urb, struct pt_regs *regs)
565exit: ; 565exit: ;
566} 566}
567 567
568static void usa26_glocont_callback(struct urb *urb, struct pt_regs *regs) 568static void usa26_glocont_callback(struct urb *urb)
569{ 569{
570 dbg ("%s", __FUNCTION__); 570 dbg ("%s", __FUNCTION__);
571 571
572} 572}
573 573
574 574
575static void usa28_indat_callback(struct urb *urb, struct pt_regs *regs) 575static void usa28_indat_callback(struct urb *urb)
576{ 576{
577 int i, err; 577 int i, err;
578 struct usb_serial_port *port; 578 struct usb_serial_port *port;
@@ -620,12 +620,12 @@ static void usa28_indat_callback(struct urb *urb, struct pt_regs *regs)
620 } while (urb->status != -EINPROGRESS); 620 } while (urb->status != -EINPROGRESS);
621} 621}
622 622
623static void usa28_inack_callback(struct urb *urb, struct pt_regs *regs) 623static void usa28_inack_callback(struct urb *urb)
624{ 624{
625 dbg ("%s", __FUNCTION__); 625 dbg ("%s", __FUNCTION__);
626} 626}
627 627
628static void usa28_outcont_callback(struct urb *urb, struct pt_regs *regs) 628static void usa28_outcont_callback(struct urb *urb)
629{ 629{
630 struct usb_serial_port *port; 630 struct usb_serial_port *port;
631 struct keyspan_port_private *p_priv; 631 struct keyspan_port_private *p_priv;
@@ -639,7 +639,7 @@ static void usa28_outcont_callback(struct urb *urb, struct pt_regs *regs)
639 } 639 }
640} 640}
641 641
642static void usa28_instat_callback(struct urb *urb, struct pt_regs *regs) 642static void usa28_instat_callback(struct urb *urb)
643{ 643{
644 int err; 644 int err;
645 unsigned char *data = urb->transfer_buffer; 645 unsigned char *data = urb->transfer_buffer;
@@ -700,13 +700,13 @@ static void usa28_instat_callback(struct urb *urb, struct pt_regs *regs)
700exit: ; 700exit: ;
701} 701}
702 702
703static void usa28_glocont_callback(struct urb *urb, struct pt_regs *regs) 703static void usa28_glocont_callback(struct urb *urb)
704{ 704{
705 dbg ("%s", __FUNCTION__); 705 dbg ("%s", __FUNCTION__);
706} 706}
707 707
708 708
709static void usa49_glocont_callback(struct urb *urb, struct pt_regs *regs) 709static void usa49_glocont_callback(struct urb *urb)
710{ 710{
711 struct usb_serial *serial; 711 struct usb_serial *serial;
712 struct usb_serial_port *port; 712 struct usb_serial_port *port;
@@ -730,7 +730,7 @@ static void usa49_glocont_callback(struct urb *urb, struct pt_regs *regs)
730 730
731 /* This is actually called glostat in the Keyspan 731 /* This is actually called glostat in the Keyspan
732 doco */ 732 doco */
733static void usa49_instat_callback(struct urb *urb, struct pt_regs *regs) 733static void usa49_instat_callback(struct urb *urb)
734{ 734{
735 int err; 735 int err;
736 unsigned char *data = urb->transfer_buffer; 736 unsigned char *data = urb->transfer_buffer;
@@ -793,12 +793,12 @@ static void usa49_instat_callback(struct urb *urb, struct pt_regs *regs)
793exit: ; 793exit: ;
794} 794}
795 795
796static void usa49_inack_callback(struct urb *urb, struct pt_regs *regs) 796static void usa49_inack_callback(struct urb *urb)
797{ 797{
798 dbg ("%s", __FUNCTION__); 798 dbg ("%s", __FUNCTION__);
799} 799}
800 800
801static void usa49_indat_callback(struct urb *urb, struct pt_regs *regs) 801static void usa49_indat_callback(struct urb *urb)
802{ 802{
803 int i, err; 803 int i, err;
804 int endpoint; 804 int endpoint;
@@ -851,12 +851,12 @@ static void usa49_indat_callback(struct urb *urb, struct pt_regs *regs)
851} 851}
852 852
853/* not used, usa-49 doesn't have per-port control endpoints */ 853/* not used, usa-49 doesn't have per-port control endpoints */
854static void usa49_outcont_callback(struct urb *urb, struct pt_regs *regs) 854static void usa49_outcont_callback(struct urb *urb)
855{ 855{
856 dbg ("%s", __FUNCTION__); 856 dbg ("%s", __FUNCTION__);
857} 857}
858 858
859static void usa90_indat_callback(struct urb *urb, struct pt_regs *regs) 859static void usa90_indat_callback(struct urb *urb)
860{ 860{
861 int i, err; 861 int i, err;
862 int endpoint; 862 int endpoint;
@@ -930,7 +930,7 @@ static void usa90_indat_callback(struct urb *urb, struct pt_regs *regs)
930} 930}
931 931
932 932
933static void usa90_instat_callback(struct urb *urb, struct pt_regs *regs) 933static void usa90_instat_callback(struct urb *urb)
934{ 934{
935 unsigned char *data = urb->transfer_buffer; 935 unsigned char *data = urb->transfer_buffer;
936 struct keyspan_usa90_portStatusMessage *msg; 936 struct keyspan_usa90_portStatusMessage *msg;
@@ -981,7 +981,7 @@ exit:
981 ; 981 ;
982} 982}
983 983
984static void usa90_outcont_callback(struct urb *urb, struct pt_regs *regs) 984static void usa90_outcont_callback(struct urb *urb)
985{ 985{
986 struct usb_serial_port *port; 986 struct usb_serial_port *port;
987 struct keyspan_port_private *p_priv; 987 struct keyspan_port_private *p_priv;
@@ -1277,7 +1277,7 @@ static int keyspan_fake_startup (struct usb_serial *serial)
1277/* Helper functions used by keyspan_setup_urbs */ 1277/* Helper functions used by keyspan_setup_urbs */
1278static struct urb *keyspan_setup_urb (struct usb_serial *serial, int endpoint, 1278static struct urb *keyspan_setup_urb (struct usb_serial *serial, int endpoint,
1279 int dir, void *ctx, char *buf, int len, 1279 int dir, void *ctx, char *buf, int len,
1280 void (*callback)(struct urb *, struct pt_regs *regs)) 1280 void (*callback)(struct urb *))
1281{ 1281{
1282 struct urb *urb; 1282 struct urb *urb;
1283 1283
@@ -1300,12 +1300,12 @@ static struct urb *keyspan_setup_urb (struct usb_serial *serial, int endpoint,
1300} 1300}
1301 1301
1302static struct callbacks { 1302static struct callbacks {
1303 void (*instat_callback)(struct urb *, struct pt_regs *regs); 1303 void (*instat_callback)(struct urb *);
1304 void (*glocont_callback)(struct urb *, struct pt_regs *regs); 1304 void (*glocont_callback)(struct urb *);
1305 void (*indat_callback)(struct urb *, struct pt_regs *regs); 1305 void (*indat_callback)(struct urb *);
1306 void (*outdat_callback)(struct urb *, struct pt_regs *regs); 1306 void (*outdat_callback)(struct urb *);
1307 void (*inack_callback)(struct urb *, struct pt_regs *regs); 1307 void (*inack_callback)(struct urb *);
1308 void (*outcont_callback)(struct urb *, struct pt_regs *regs); 1308 void (*outcont_callback)(struct urb *);
1309} keyspan_callbacks[] = { 1309} keyspan_callbacks[] = {
1310 { 1310 {
1311 /* msg_usa26 callbacks */ 1311 /* msg_usa26 callbacks */
diff --git a/drivers/usb/serial/keyspan_pda.c b/drivers/usb/serial/keyspan_pda.c
index 59e777f1e8fd..909005107ea2 100644
--- a/drivers/usb/serial/keyspan_pda.c
+++ b/drivers/usb/serial/keyspan_pda.c
@@ -210,7 +210,7 @@ static void keyspan_pda_request_unthrottle( struct usb_serial *serial )
210} 210}
211 211
212 212
213static void keyspan_pda_rx_interrupt (struct urb *urb, struct pt_regs *regs) 213static void keyspan_pda_rx_interrupt (struct urb *urb)
214{ 214{
215 struct usb_serial_port *port = (struct usb_serial_port *)urb->context; 215 struct usb_serial_port *port = (struct usb_serial_port *)urb->context;
216 struct tty_struct *tty = port->tty; 216 struct tty_struct *tty = port->tty;
@@ -601,7 +601,7 @@ exit:
601} 601}
602 602
603 603
604static void keyspan_pda_write_bulk_callback (struct urb *urb, struct pt_regs *regs) 604static void keyspan_pda_write_bulk_callback (struct urb *urb)
605{ 605{
606 struct usb_serial_port *port = (struct usb_serial_port *)urb->context; 606 struct usb_serial_port *port = (struct usb_serial_port *)urb->context;
607 struct keyspan_pda_private *priv; 607 struct keyspan_pda_private *priv;
diff --git a/drivers/usb/serial/kl5kusb105.c b/drivers/usb/serial/kl5kusb105.c
index 2a2f3e2da055..17e205699c2b 100644
--- a/drivers/usb/serial/kl5kusb105.c
+++ b/drivers/usb/serial/kl5kusb105.c
@@ -80,11 +80,11 @@ static void klsi_105_close (struct usb_serial_port *port,
80static int klsi_105_write (struct usb_serial_port *port, 80static int klsi_105_write (struct usb_serial_port *port,
81 const unsigned char *buf, 81 const unsigned char *buf,
82 int count); 82 int count);
83static void klsi_105_write_bulk_callback (struct urb *urb, struct pt_regs *regs); 83static void klsi_105_write_bulk_callback (struct urb *urb);
84static int klsi_105_chars_in_buffer (struct usb_serial_port *port); 84static int klsi_105_chars_in_buffer (struct usb_serial_port *port);
85static int klsi_105_write_room (struct usb_serial_port *port); 85static int klsi_105_write_room (struct usb_serial_port *port);
86 86
87static void klsi_105_read_bulk_callback (struct urb *urb, struct pt_regs *regs); 87static void klsi_105_read_bulk_callback (struct urb *urb);
88static void klsi_105_set_termios (struct usb_serial_port *port, 88static void klsi_105_set_termios (struct usb_serial_port *port,
89 struct termios * old); 89 struct termios * old);
90static int klsi_105_ioctl (struct usb_serial_port *port, 90static int klsi_105_ioctl (struct usb_serial_port *port,
@@ -556,7 +556,7 @@ exit:
556 return bytes_sent; /* that's how much we wrote */ 556 return bytes_sent; /* that's how much we wrote */
557} /* klsi_105_write */ 557} /* klsi_105_write */
558 558
559static void klsi_105_write_bulk_callback ( struct urb *urb, struct pt_regs *regs) 559static void klsi_105_write_bulk_callback ( struct urb *urb)
560{ 560{
561 struct usb_serial_port *port = (struct usb_serial_port *)urb->context; 561 struct usb_serial_port *port = (struct usb_serial_port *)urb->context;
562 562
@@ -616,7 +616,7 @@ static int klsi_105_write_room (struct usb_serial_port *port)
616 616
617 617
618 618
619static void klsi_105_read_bulk_callback (struct urb *urb, struct pt_regs *regs) 619static void klsi_105_read_bulk_callback (struct urb *urb)
620{ 620{
621 struct usb_serial_port *port = (struct usb_serial_port *)urb->context; 621 struct usb_serial_port *port = (struct usb_serial_port *)urb->context;
622 struct klsi_105_private *priv = usb_get_serial_port_data(port); 622 struct klsi_105_private *priv = usb_get_serial_port_data(port);
diff --git a/drivers/usb/serial/kobil_sct.c b/drivers/usb/serial/kobil_sct.c
index d50dce034958..ff03331e0bcf 100644
--- a/drivers/usb/serial/kobil_sct.c
+++ b/drivers/usb/serial/kobil_sct.c
@@ -80,8 +80,8 @@ static int kobil_ioctl(struct usb_serial_port *port, struct file *file,
80static int kobil_tiocmget(struct usb_serial_port *port, struct file *file); 80static int kobil_tiocmget(struct usb_serial_port *port, struct file *file);
81static int kobil_tiocmset(struct usb_serial_port *port, struct file *file, 81static int kobil_tiocmset(struct usb_serial_port *port, struct file *file,
82 unsigned int set, unsigned int clear); 82 unsigned int set, unsigned int clear);
83static void kobil_read_int_callback( struct urb *urb, struct pt_regs *regs ); 83static void kobil_read_int_callback( struct urb *urb );
84static void kobil_write_callback( struct urb *purb, struct pt_regs *regs ); 84static void kobil_write_callback( struct urb *purb );
85 85
86 86
87static struct usb_device_id id_table [] = { 87static struct usb_device_id id_table [] = {
@@ -360,7 +360,7 @@ static void kobil_close (struct usb_serial_port *port, struct file *filp)
360} 360}
361 361
362 362
363static void kobil_read_int_callback( struct urb *purb, struct pt_regs *regs) 363static void kobil_read_int_callback( struct urb *purb)
364{ 364{
365 int result; 365 int result;
366 struct usb_serial_port *port = (struct usb_serial_port *) purb->context; 366 struct usb_serial_port *port = (struct usb_serial_port *) purb->context;
@@ -405,7 +405,7 @@ static void kobil_read_int_callback( struct urb *purb, struct pt_regs *regs)
405} 405}
406 406
407 407
408static void kobil_write_callback( struct urb *purb, struct pt_regs *regs ) 408static void kobil_write_callback( struct urb *purb )
409{ 409{
410} 410}
411 411
diff --git a/drivers/usb/serial/mct_u232.c b/drivers/usb/serial/mct_u232.c
index f4d4305c2c02..b7582cc496dc 100644
--- a/drivers/usb/serial/mct_u232.c
+++ b/drivers/usb/serial/mct_u232.c
@@ -96,7 +96,7 @@ static int mct_u232_open (struct usb_serial_port *port,
96 struct file *filp); 96 struct file *filp);
97static void mct_u232_close (struct usb_serial_port *port, 97static void mct_u232_close (struct usb_serial_port *port,
98 struct file *filp); 98 struct file *filp);
99static void mct_u232_read_int_callback (struct urb *urb, struct pt_regs *regs); 99static void mct_u232_read_int_callback (struct urb *urb);
100static void mct_u232_set_termios (struct usb_serial_port *port, 100static void mct_u232_set_termios (struct usb_serial_port *port,
101 struct termios * old); 101 struct termios * old);
102static int mct_u232_ioctl (struct usb_serial_port *port, 102static int mct_u232_ioctl (struct usb_serial_port *port,
@@ -466,7 +466,7 @@ static void mct_u232_close (struct usb_serial_port *port, struct file *filp)
466} /* mct_u232_close */ 466} /* mct_u232_close */
467 467
468 468
469static void mct_u232_read_int_callback (struct urb *urb, struct pt_regs *regs) 469static void mct_u232_read_int_callback (struct urb *urb)
470{ 470{
471 struct usb_serial_port *port = (struct usb_serial_port *)urb->context; 471 struct usb_serial_port *port = (struct usb_serial_port *)urb->context;
472 struct mct_u232_private *priv = usb_get_serial_port_data(port); 472 struct mct_u232_private *priv = usb_get_serial_port_data(port);
diff --git a/drivers/usb/serial/mos7720.c b/drivers/usb/serial/mos7720.c
new file mode 100644
index 000000000000..82cd15b894b0
--- /dev/null
+++ b/drivers/usb/serial/mos7720.c
@@ -0,0 +1,1683 @@
1/*
2 * mos7720.c
3 * Controls the Moschip 7720 usb to dual port serial convertor
4 *
5 * Copyright 2006 Moschip Semiconductor Tech. Ltd.
6 *
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
9 * the Free Software Foundation, version 2 of the License.
10 *
11 * Developed by:
12 * VijayaKumar.G.N. <vijaykumar@aspirecom.net>
13 * AjayKumar <ajay@aspirecom.net>
14 * Gurudeva.N. <gurudev@aspirecom.net>
15 *
16 * Cleaned up from the original by:
17 * Greg Kroah-Hartman <gregkh@suse.de>
18 *
19 * Originally based on drivers/usb/serial/io_edgeport.c which is:
20 * Copyright (C) 2000 Inside Out Networks, All rights reserved.
21 * Copyright (C) 2001-2002 Greg Kroah-Hartman <greg@kroah.com>
22 */
23#include <linux/kernel.h>
24#include <linux/errno.h>
25#include <linux/init.h>
26#include <linux/slab.h>
27#include <linux/tty.h>
28#include <linux/tty_driver.h>
29#include <linux/tty_flip.h>
30#include <linux/module.h>
31#include <linux/spinlock.h>
32#include <linux/serial.h>
33#include <linux/serial_reg.h>
34#include <linux/usb.h>
35#include <linux/usb/serial.h>
36#include <asm/uaccess.h>
37
38
39/*
40 * Version Information
41 */
42#define DRIVER_VERSION "1.0.0.4F"
43#define DRIVER_AUTHOR "Aspire Communications pvt Ltd."
44#define DRIVER_DESC "Moschip USB Serial Driver"
45
46/* default urb timeout */
47#define MOS_WDR_TIMEOUT (HZ * 5)
48
49#define MOS_PORT1 0x0200
50#define MOS_PORT2 0x0300
51#define MOS_VENREG 0x0000
52#define MOS_MAX_PORT 0x02
53#define MOS_WRITE 0x0E
54#define MOS_READ 0x0D
55
56/* Interrupt Rotinue Defines */
57#define SERIAL_IIR_RLS 0x06
58#define SERIAL_IIR_RDA 0x04
59#define SERIAL_IIR_CTI 0x0c
60#define SERIAL_IIR_THR 0x02
61#define SERIAL_IIR_MS 0x00
62
63#define NUM_URBS 16 /* URB Count */
64#define URB_TRANSFER_BUFFER_SIZE 32 /* URB Size */
65
66/* This structure holds all of the local port information */
67struct moschip_port
68{
69 __u8 shadowLCR; /* last LCR value received */
70 __u8 shadowMCR; /* last MCR value received */
71 __u8 shadowMSR; /* last MSR value received */
72 char open;
73 struct async_icount icount;
74 struct usb_serial_port *port; /* loop back to the owner */
75 struct urb *write_urb_pool[NUM_URBS];
76};
77
78/* This structure holds all of the individual serial device information */
79struct moschip_serial
80{
81 int interrupt_started;
82};
83
84static int debug;
85
86#define USB_VENDOR_ID_MOSCHIP 0x9710
87#define MOSCHIP_DEVICE_ID_7720 0x7720
88#define MOSCHIP_DEVICE_ID_7715 0x7715
89
90static struct usb_device_id moschip_port_id_table [] = {
91 { USB_DEVICE(USB_VENDOR_ID_MOSCHIP,MOSCHIP_DEVICE_ID_7720) },
92 { } /* terminating entry */
93};
94MODULE_DEVICE_TABLE(usb, moschip_port_id_table);
95
96
97/*
98 * mos7720_interrupt_callback
99 * this is the callback function for when we have received data on the
100 * interrupt endpoint.
101 */
102static void mos7720_interrupt_callback(struct urb *urb)
103{
104 int result;
105 int length;
106 __u32 *data;
107 unsigned int status;
108 __u8 sp1;
109 __u8 sp2;
110 __u8 st;
111
112 dbg("%s"," : Entering\n");
113
114 if (!urb) {
115 dbg("%s","Invalid Pointer !!!!:\n");
116 return;
117 }
118
119 switch (urb->status) {
120 case 0:
121 /* success */
122 break;
123 case -ECONNRESET:
124 case -ENOENT:
125 case -ESHUTDOWN:
126 /* this urb is terminated, clean up */
127 dbg("%s - urb shutting down with status: %d", __FUNCTION__,
128 urb->status);
129 return;
130 default:
131 dbg("%s - nonzero urb status received: %d", __FUNCTION__,
132 urb->status);
133 goto exit;
134 }
135
136 length = urb->actual_length;
137 data = urb->transfer_buffer;
138
139 /* Moschip get 4 bytes
140 * Byte 1 IIR Port 1 (port.number is 0)
141 * Byte 2 IIR Port 2 (port.number is 1)
142 * Byte 3 --------------
143 * Byte 4 FIFO status for both */
144 if (length && length > 4) {
145 dbg("Wrong data !!!");
146 return;
147 }
148
149 status = *data;
150
151 sp1 = (status & 0xff000000)>>24;
152 sp2 = (status & 0x00ff0000)>>16;
153 st = status & 0x000000ff;
154
155 if ((sp1 & 0x01) || (sp2 & 0x01)) {
156 /* No Interrupt Pending in both the ports */
157 dbg("No Interrupt !!!");
158 } else {
159 switch (sp1 & 0x0f) {
160 case SERIAL_IIR_RLS:
161 dbg("Serial Port 1: Receiver status error or address "
162 "bit detected in 9-bit mode\n");
163 break;
164 case SERIAL_IIR_CTI:
165 dbg("Serial Port 1: Receiver time out");
166 break;
167 case SERIAL_IIR_MS:
168 dbg("Serial Port 1: Modem status change");
169 break;
170 }
171
172 switch (sp2 & 0x0f) {
173 case SERIAL_IIR_RLS:
174 dbg("Serial Port 2: Receiver status error or address "
175 "bit detected in 9-bit mode");
176 break;
177 case SERIAL_IIR_CTI:
178 dbg("Serial Port 2: Receiver time out");
179 break;
180 case SERIAL_IIR_MS:
181 dbg("Serial Port 2: Modem status change");
182 break;
183 }
184 }
185
186exit:
187 result = usb_submit_urb(urb, GFP_ATOMIC);
188 if (result)
189 dev_err(&urb->dev->dev,
190 "%s - Error %d submitting control urb\n",
191 __FUNCTION__, result);
192 return;
193}
194
195/*
196 * mos7720_bulk_in_callback
197 * this is the callback function for when we have received data on the
198 * bulk in endpoint.
199 */
200static void mos7720_bulk_in_callback(struct urb *urb)
201{
202 int status;
203 unsigned char *data ;
204 struct usb_serial_port *port;
205 struct moschip_port *mos7720_port;
206 struct tty_struct *tty;
207
208 if (urb->status) {
209 dbg("nonzero read bulk status received: %d",urb->status);
210 return;
211 }
212
213 mos7720_port = urb->context;
214 if (!mos7720_port) {
215 dbg("%s","NULL mos7720_port pointer \n");
216 return ;
217 }
218
219 port = mos7720_port->port;
220
221 dbg("Entering...%s", __FUNCTION__);
222
223 data = urb->transfer_buffer;
224
225 tty = port->tty;
226 if (tty && urb->actual_length) {
227 tty_buffer_request_room(tty, urb->actual_length);
228 tty_insert_flip_string(tty, data, urb->actual_length);
229 tty_flip_buffer_push(tty);
230 }
231
232 if (!port->read_urb) {
233 dbg("URB KILLED !!!");
234 return;
235 }
236
237 if (port->read_urb->status != -EINPROGRESS) {
238 port->read_urb->dev = port->serial->dev;
239
240 status = usb_submit_urb(port->read_urb, GFP_ATOMIC);
241 if (status)
242 dbg("usb_submit_urb(read bulk) failed, status = %d",
243 status);
244 }
245}
246
247/*
248 * mos7720_bulk_out_data_callback
249 * this is the callback function for when we have finished sending serial
250 * data on the bulk out endpoint.
251 */
252static void mos7720_bulk_out_data_callback(struct urb *urb)
253{
254 struct moschip_port *mos7720_port;
255 struct tty_struct *tty;
256
257 if (urb->status) {
258 dbg("nonzero write bulk status received:%d", urb->status);
259 return;
260 }
261
262 mos7720_port = urb->context;
263 if (!mos7720_port) {
264 dbg("NULL mos7720_port pointer");
265 return ;
266 }
267
268 dbg("Entering .........");
269
270 tty = mos7720_port->port->tty;
271
272 if (tty && mos7720_port->open) {
273 /* let the tty driver wakeup if it has a special *
274 * write_wakeup function */
275 if ((tty->flags & (1 << TTY_DO_WRITE_WAKEUP)) &&
276 tty->ldisc.write_wakeup)
277 (tty->ldisc.write_wakeup)(tty);
278
279 /* tell the tty driver that something has changed */
280 wake_up_interruptible(&tty->write_wait);
281 }
282
283 /* schedule_work(&mos7720_port->port->work); */
284}
285
286/*
287 * send_mos_cmd
288 * this function will be used for sending command to device
289 */
290static int send_mos_cmd(struct usb_serial *serial, __u8 request, __u16 value,
291 __u16 index, void *data)
292{
293 int status;
294 unsigned int pipe;
295 u16 product = le16_to_cpu(serial->dev->descriptor.idProduct);
296 __u8 requesttype;
297 __u16 size = 0x0000;
298
299 if (value < MOS_MAX_PORT) {
300 if (product == MOSCHIP_DEVICE_ID_7715) {
301 value = value*0x100+0x100;
302 } else {
303 value = value*0x100+0x200;
304 }
305 } else {
306 value = 0x0000;
307 if ((product == MOSCHIP_DEVICE_ID_7715) &&
308 (index != 0x08)) {
309 dbg("serial->product== MOSCHIP_DEVICE_ID_7715");
310 //index = 0x01 ;
311 }
312 }
313
314 if (request == MOS_WRITE) {
315 request = (__u8)MOS_WRITE;
316 requesttype = (__u8)0x40;
317 value = value + (__u16)*((unsigned char *)data);
318 data = NULL;
319 pipe = usb_sndctrlpipe(serial->dev, 0);
320 } else {
321 request = (__u8)MOS_READ;
322 requesttype = (__u8)0xC0;
323 size = 0x01;
324 pipe = usb_rcvctrlpipe(serial->dev,0);
325 }
326
327 status = usb_control_msg(serial->dev, pipe, request, requesttype,
328 value, index, data, size, MOS_WDR_TIMEOUT);
329
330 if (status < 0)
331 dbg("Command Write failed Value %x index %x\n",value,index);
332
333 return status;
334}
335
336static int mos7720_open(struct usb_serial_port *port, struct file * filp)
337{
338 struct usb_serial *serial;
339 struct usb_serial_port *port0;
340 struct urb *urb;
341 struct moschip_serial *mos7720_serial;
342 struct moschip_port *mos7720_port;
343 int response;
344 int port_number;
345 char data;
346 int j;
347
348 serial = port->serial;
349
350 mos7720_port = usb_get_serial_port_data(port);
351 if (mos7720_port == NULL)
352 return -ENODEV;
353
354 port0 = serial->port[0];
355
356 mos7720_serial = usb_get_serial_data(serial);
357
358 if (mos7720_serial == NULL || port0 == NULL)
359 return -ENODEV;
360
361 usb_clear_halt(serial->dev, port->write_urb->pipe);
362 usb_clear_halt(serial->dev, port->read_urb->pipe);
363
364 /* Initialising the write urb pool */
365 for (j = 0; j < NUM_URBS; ++j) {
366 urb = usb_alloc_urb(0,SLAB_ATOMIC);
367 mos7720_port->write_urb_pool[j] = urb;
368
369 if (urb == NULL) {
370 err("No more urbs???");
371 continue;
372 }
373
374 urb->transfer_buffer = kmalloc(URB_TRANSFER_BUFFER_SIZE,
375 GFP_KERNEL);
376 if (!urb->transfer_buffer) {
377 err("%s-out of memory for urb buffers.", __FUNCTION__);
378 continue;
379 }
380 }
381
382 /* Initialize MCS7720 -- Write Init values to corresponding Registers
383 *
384 * Register Index
385 * 1 : IER
386 * 2 : FCR
387 * 3 : LCR
388 * 4 : MCR
389 *
390 * 0x08 : SP1/2 Control Reg
391 */
392 port_number = port->number - port->serial->minor;
393 send_mos_cmd(port->serial, MOS_READ, port_number, UART_LSR, &data);
394 dbg("SS::%p LSR:%x\n",mos7720_port, data);
395
396 dbg("Check:Sending Command ..........");
397
398 data = 0x02;
399 send_mos_cmd(serial, MOS_WRITE, MOS_MAX_PORT, 0x01, &data);
400 data = 0x02;
401 send_mos_cmd(serial, MOS_WRITE, MOS_MAX_PORT, 0x02, &data);
402
403 data = 0x00;
404 send_mos_cmd(serial, MOS_WRITE, port_number, 0x01, &data);
405 data = 0x00;
406 send_mos_cmd(serial, MOS_WRITE, port_number, 0x02, &data);
407
408 data = 0xCF;
409 send_mos_cmd(serial, MOS_WRITE, port_number, 0x02, &data);
410 data = 0x03;
411 mos7720_port->shadowLCR = data;
412 send_mos_cmd(serial, MOS_WRITE, port_number, 0x03, &data);
413 data = 0x0b;
414 mos7720_port->shadowMCR = data;
415 send_mos_cmd(serial, MOS_WRITE, port_number, 0x04, &data);
416 data = 0x0b;
417 send_mos_cmd(serial, MOS_WRITE, port_number, 0x04, &data);
418
419 data = 0x00;
420 send_mos_cmd(serial, MOS_READ, MOS_MAX_PORT, 0x08, &data);
421 data = 0x00;
422 send_mos_cmd(serial, MOS_WRITE, MOS_MAX_PORT, 0x08, &data);
423
424/* data = 0x00;
425 send_mos_cmd(serial, MOS_READ, MOS_MAX_PORT, port_number + 1, &data);
426 data = 0x03;
427 send_mos_cmd(serial, MOS_WRITE, MOS_MAX_PORT, port_number + 1, &data);
428 data = 0x00;
429 send_mos_cmd(port->serial, MOS_WRITE, MOS_MAX_PORT, port_number + 1, &data);
430*/
431 data = 0x00;
432 send_mos_cmd(serial, MOS_READ, MOS_MAX_PORT, 0x08, &data);
433
434 data = data | (port->number - port->serial->minor + 1);
435 send_mos_cmd(serial, MOS_WRITE, MOS_MAX_PORT, 0x08, &data);
436
437 data = 0x83;
438 mos7720_port->shadowLCR = data;
439 send_mos_cmd(serial, MOS_WRITE, port_number, 0x03, &data);
440 data = 0x0c;
441 send_mos_cmd(serial, MOS_WRITE, port_number, 0x00, &data);
442 data = 0x00;
443 send_mos_cmd(serial, MOS_WRITE, port_number, 0x01, &data);
444 data = 0x03;
445 mos7720_port->shadowLCR = data;
446 send_mos_cmd(serial, MOS_WRITE, port_number, 0x03, &data);
447 data = 0x0c;
448 send_mos_cmd(serial, MOS_WRITE, port_number, 0x01, &data);
449 data = 0x0c;
450 send_mos_cmd(serial, MOS_WRITE, port_number, 0x01, &data);
451
452//Matrix
453
454 /* force low_latency on so that our tty_push actually forces *
455 * the data through,otherwise it is scheduled, and with *
456 * high data rates (like with OHCI) data can get lost. */
457
458 if (port->tty)
459 port->tty->low_latency = 1;
460
461 /* see if we've set up our endpoint info yet *
462 * (can't set it up in mos7720_startup as the *
463 * structures were not set up at that time.) */
464 if (!mos7720_serial->interrupt_started) {
465 dbg("Interrupt buffer NULL !!!");
466
467 /* not set up yet, so do it now */
468 mos7720_serial->interrupt_started = 1;
469
470 dbg("To Submit URB !!!");
471
472 /* set up our interrupt urb */
473 usb_fill_int_urb(port0->interrupt_in_urb, serial->dev,
474 usb_rcvintpipe(serial->dev,
475 port->interrupt_in_endpointAddress),
476 port0->interrupt_in_buffer,
477 port0->interrupt_in_urb->transfer_buffer_length,
478 mos7720_interrupt_callback, mos7720_port,
479 port0->interrupt_in_urb->interval);
480
481 /* start interrupt read for this mos7720 this interrupt *
482 * will continue as long as the mos7720 is connected */
483 dbg("Submit URB over !!!");
484 response = usb_submit_urb(port0->interrupt_in_urb, GFP_KERNEL);
485 if (response)
486 dev_err(&port->dev,
487 "%s - Error %d submitting control urb",
488 __FUNCTION__, response);
489 }
490
491 /* set up our bulk in urb */
492 usb_fill_bulk_urb(port->read_urb, serial->dev,
493 usb_rcvbulkpipe(serial->dev,
494 port->bulk_in_endpointAddress),
495 port->bulk_in_buffer,
496 port->read_urb->transfer_buffer_length,
497 mos7720_bulk_in_callback, mos7720_port);
498 response = usb_submit_urb(port->read_urb, GFP_KERNEL);
499 if (response)
500 dev_err(&port->dev,
501 "%s - Error %d submitting read urb", __FUNCTION__, response);
502
503 /* initialize our icount structure */
504 memset(&(mos7720_port->icount), 0x00, sizeof(mos7720_port->icount));
505
506 /* initialize our port settings */
507 mos7720_port->shadowMCR = UART_MCR_OUT2; /* Must set to enable ints! */
508
509 /* send a open port command */
510 mos7720_port->open = 1;
511
512 return 0;
513}
514
515/*
516 * mos7720_chars_in_buffer
517 * this function is called by the tty driver when it wants to know how many
518 * bytes of data we currently have outstanding in the port (data that has
519 * been written, but hasn't made it out the port yet)
520 * If successful, we return the number of bytes left to be written in the
521 * system,
522 * Otherwise we return a negative error number.
523 */
524static int mos7720_chars_in_buffer(struct usb_serial_port *port)
525{
526 int i;
527 int chars = 0;
528 struct moschip_port *mos7720_port;
529
530 dbg("%s:entering ...........", __FUNCTION__);
531
532 mos7720_port = usb_get_serial_port_data(port);
533 if (mos7720_port == NULL) {
534 dbg("%s:leaving ...........", __FUNCTION__);
535 return -ENODEV;
536 }
537
538 for (i = 0; i < NUM_URBS; ++i) {
539 if (mos7720_port->write_urb_pool[i]->status == -EINPROGRESS)
540 chars += URB_TRANSFER_BUFFER_SIZE;
541 }
542 dbg("%s - returns %d", __FUNCTION__, chars);
543 return chars;
544}
545
546static void mos7720_close(struct usb_serial_port *port, struct file *filp)
547{
548 struct usb_serial *serial;
549 struct moschip_port *mos7720_port;
550 char data;
551 int j;
552
553 dbg("mos7720_close:entering...");
554
555 serial = port->serial;
556
557 mos7720_port = usb_get_serial_port_data(port);
558 if (mos7720_port == NULL)
559 return;
560
561 for (j = 0; j < NUM_URBS; ++j)
562 usb_kill_urb(mos7720_port->write_urb_pool[j]);
563
564 /* Freeing Write URBs */
565 for (j = 0; j < NUM_URBS; ++j) {
566 if (mos7720_port->write_urb_pool[j]) {
567 kfree(mos7720_port->write_urb_pool[j]->transfer_buffer);
568 usb_free_urb(mos7720_port->write_urb_pool[j]);
569 }
570 }
571
572 /* While closing port, shutdown all bulk read, write *
573 * and interrupt read if they exists */
574 if (serial->dev) {
575 dbg("Shutdown bulk write");
576 usb_kill_urb(port->write_urb);
577 dbg("Shutdown bulk read");
578 usb_kill_urb(port->read_urb);
579 }
580
581 data = 0x00;
582 send_mos_cmd(serial, MOS_WRITE, port->number - port->serial->minor,
583 0x04, &data);
584
585 data = 0x00;
586 send_mos_cmd(serial, MOS_WRITE, port->number - port->serial->minor,
587 0x01, &data);
588
589 mos7720_port->open = 0;
590
591 dbg("Leaving %s", __FUNCTION__);
592}
593
594static void mos7720_break(struct usb_serial_port *port, int break_state)
595{
596 unsigned char data;
597 struct usb_serial *serial;
598 struct moschip_port *mos7720_port;
599
600 dbg("Entering %s", __FUNCTION__);
601
602 serial = port->serial;
603
604 mos7720_port = usb_get_serial_port_data(port);
605 if (mos7720_port == NULL)
606 return;
607
608 if (break_state == -1)
609 data = mos7720_port->shadowLCR | UART_LCR_SBC;
610 else
611 data = mos7720_port->shadowLCR & ~UART_LCR_SBC;
612
613 mos7720_port->shadowLCR = data;
614 send_mos_cmd(serial, MOS_WRITE, port->number - port->serial->minor,
615 0x03, &data);
616
617 return;
618}
619
620/*
621 * mos7720_write_room
622 * this function is called by the tty driver when it wants to know how many
623 * bytes of data we can accept for a specific port.
624 * If successful, we return the amount of room that we have for this port
625 * Otherwise we return a negative error number.
626 */
627static int mos7720_write_room(struct usb_serial_port *port)
628{
629 struct moschip_port *mos7720_port;
630 int room = 0;
631 int i;
632
633 dbg("%s:entering ...........", __FUNCTION__);
634
635 mos7720_port = usb_get_serial_port_data(port);
636 if (mos7720_port == NULL) {
637 dbg("%s:leaving ...........", __FUNCTION__);
638 return -ENODEV;
639 }
640
641 for (i = 0; i < NUM_URBS; ++i) {
642 if (mos7720_port->write_urb_pool[i]->status != -EINPROGRESS)
643 room += URB_TRANSFER_BUFFER_SIZE;
644 }
645
646 dbg("%s - returns %d", __FUNCTION__, room);
647 return room;
648}
649
650static int mos7720_write(struct usb_serial_port *port,
651 const unsigned char *data, int count)
652{
653 int status;
654 int i;
655 int bytes_sent = 0;
656 int transfer_size;
657
658 struct moschip_port *mos7720_port;
659 struct usb_serial *serial;
660 struct urb *urb;
661 const unsigned char *current_position = data;
662
663 dbg("%s:entering ...........", __FUNCTION__);
664
665 serial = port->serial;
666
667 mos7720_port = usb_get_serial_port_data(port);
668 if (mos7720_port == NULL) {
669 dbg("mos7720_port is NULL");
670 return -ENODEV;
671 }
672
673 /* try to find a free urb in the list */
674 urb = NULL;
675
676 for (i = 0; i < NUM_URBS; ++i) {
677 if (mos7720_port->write_urb_pool[i]->status != -EINPROGRESS) {
678 urb = mos7720_port->write_urb_pool[i];
679 dbg("URB:%d",i);
680 break;
681 }
682 }
683
684 if (urb == NULL) {
685 dbg("%s - no more free urbs", __FUNCTION__);
686 goto exit;
687 }
688
689 if (urb->transfer_buffer == NULL) {
690 urb->transfer_buffer = kmalloc(URB_TRANSFER_BUFFER_SIZE,
691 GFP_KERNEL);
692 if (urb->transfer_buffer == NULL) {
693 err("%s no more kernel memory...", __FUNCTION__);
694 goto exit;
695 }
696 }
697 transfer_size = min (count, URB_TRANSFER_BUFFER_SIZE);
698
699 memcpy(urb->transfer_buffer, current_position, transfer_size);
700 usb_serial_debug_data(debug, &port->dev, __FUNCTION__, transfer_size,
701 urb->transfer_buffer);
702
703 /* fill urb with data and submit */
704 usb_fill_bulk_urb(urb, serial->dev,
705 usb_sndbulkpipe(serial->dev,
706 port->bulk_out_endpointAddress),
707 urb->transfer_buffer, transfer_size,
708 mos7720_bulk_out_data_callback, mos7720_port);
709
710 /* send it down the pipe */
711 status = usb_submit_urb(urb,GFP_ATOMIC);
712 if (status) {
713 err("%s - usb_submit_urb(write bulk) failed with status = %d",
714 __FUNCTION__, status);
715 bytes_sent = status;
716 goto exit;
717 }
718 bytes_sent = transfer_size;
719
720exit:
721 return bytes_sent;
722}
723
724static void mos7720_throttle(struct usb_serial_port *port)
725{
726 struct moschip_port *mos7720_port;
727 struct tty_struct *tty;
728 int status;
729
730 dbg("%s- port %d\n", __FUNCTION__, port->number);
731
732 mos7720_port = usb_get_serial_port_data(port);
733
734 if (mos7720_port == NULL)
735 return;
736
737 if (!mos7720_port->open) {
738 dbg("port not opened");
739 return;
740 }
741
742 dbg("%s: Entering ..........", __FUNCTION__);
743
744 tty = port->tty;
745 if (!tty) {
746 dbg("%s - no tty available", __FUNCTION__);
747 return;
748 }
749
750 /* if we are implementing XON/XOFF, send the stop character */
751 if (I_IXOFF(tty)) {
752 unsigned char stop_char = STOP_CHAR(tty);
753 status = mos7720_write(port, &stop_char, 1);
754 if (status <= 0)
755 return;
756 }
757
758 /* if we are implementing RTS/CTS, toggle that line */
759 if (tty->termios->c_cflag & CRTSCTS) {
760 mos7720_port->shadowMCR &= ~UART_MCR_RTS;
761 status = send_mos_cmd(port->serial, MOS_WRITE,
762 port->number - port->serial->minor,
763 UART_MCR, &mos7720_port->shadowMCR);
764 if (status != 0)
765 return;
766 }
767}
768
769static void mos7720_unthrottle(struct usb_serial_port *port)
770{
771 struct tty_struct *tty;
772 int status;
773 struct moschip_port *mos7720_port = usb_get_serial_port_data(port);
774
775 if (mos7720_port == NULL)
776 return;
777
778 if (!mos7720_port->open) {
779 dbg("%s - port not opened", __FUNCTION__);
780 return;
781 }
782
783 dbg("%s: Entering ..........", __FUNCTION__);
784
785 tty = port->tty;
786 if (!tty) {
787 dbg("%s - no tty available", __FUNCTION__);
788 return;
789 }
790
791 /* if we are implementing XON/XOFF, send the start character */
792 if (I_IXOFF(tty)) {
793 unsigned char start_char = START_CHAR(tty);
794 status = mos7720_write(port, &start_char, 1);
795 if (status <= 0)
796 return;
797 }
798
799 /* if we are implementing RTS/CTS, toggle that line */
800 if (tty->termios->c_cflag & CRTSCTS) {
801 mos7720_port->shadowMCR |= UART_MCR_RTS;
802 status = send_mos_cmd(port->serial, MOS_WRITE,
803 port->number - port->serial->minor,
804 UART_MCR, &mos7720_port->shadowMCR);
805 if (status != 0)
806 return;
807 }
808}
809
810static int set_higher_rates(struct moschip_port *mos7720_port,
811 unsigned int baud)
812{
813 unsigned char data;
814 struct usb_serial_port *port;
815 struct usb_serial *serial;
816 int port_number;
817
818 if (mos7720_port == NULL)
819 return -EINVAL;
820
821 port = mos7720_port->port;
822 serial = port->serial;
823
824 /***********************************************
825 * Init Sequence for higher rates
826 ***********************************************/
827 dbg("Sending Setting Commands ..........");
828 port_number = port->number - port->serial->minor;
829
830 data = 0x000;
831 send_mos_cmd(serial, MOS_WRITE, port_number, 0x01, &data);
832 data = 0x000;
833 send_mos_cmd(serial, MOS_WRITE, port_number, 0x02, &data);
834 data = 0x0CF;
835 send_mos_cmd(serial, MOS_WRITE, port->number, 0x02, &data);
836 data = 0x00b;
837 mos7720_port->shadowMCR = data;
838 send_mos_cmd(serial, MOS_WRITE, port_number, 0x04, &data);
839 data = 0x00b;
840 send_mos_cmd(serial, MOS_WRITE, port_number, 0x04, &data);
841
842 data = 0x000;
843 send_mos_cmd(serial, MOS_READ, MOS_MAX_PORT, 0x08, &data);
844 data = 0x000;
845 send_mos_cmd(serial, MOS_WRITE, MOS_MAX_PORT, 0x08, &data);
846
847
848 /***********************************************
849 * Set for higher rates *
850 ***********************************************/
851
852 data = baud * 0x10;
853 send_mos_cmd(serial, MOS_WRITE, MOS_MAX_PORT, port_number + 1,&data);
854
855 data = 0x003;
856 send_mos_cmd(serial, MOS_READ, MOS_MAX_PORT, 0x08, &data);
857 data = 0x003;
858 send_mos_cmd(serial, MOS_WRITE, MOS_MAX_PORT, 0x08, &data);
859
860 data = 0x02b;
861 mos7720_port->shadowMCR = data;
862 send_mos_cmd(serial, MOS_WRITE, port_number, 0x04, &data);
863 data = 0x02b;
864 send_mos_cmd(serial, MOS_WRITE, port_number, 0x04, &data);
865
866 /***********************************************
867 * Set DLL/DLM
868 ***********************************************/
869
870 data = mos7720_port->shadowLCR | UART_LCR_DLAB;
871 mos7720_port->shadowLCR = data;
872 send_mos_cmd(serial, MOS_WRITE, port_number, 0x03, &data);
873
874 data = 0x001; /* DLL */
875 send_mos_cmd(serial, MOS_WRITE, port_number, 0x00, &data);
876 data = 0x000; /* DLM */
877 send_mos_cmd(serial, MOS_WRITE, port_number, 0x01, &data);
878
879 data = mos7720_port->shadowLCR & ~UART_LCR_DLAB;
880 mos7720_port->shadowLCR = data;
881 send_mos_cmd(serial, MOS_WRITE, port_number, 0x03, &data);
882
883 return 0;
884}
885
886/* baud rate information */
887struct divisor_table_entry
888{
889 __u32 baudrate;
890 __u16 divisor;
891};
892
893/* Define table of divisors for moschip 7720 hardware *
894 * These assume a 3.6864MHz crystal, the standard /16, and *
895 * MCR.7 = 0. */
896static struct divisor_table_entry divisor_table[] = {
897 { 50, 2304},
898 { 110, 1047}, /* 2094.545455 => 230450 => .0217 % over */
899 { 134, 857}, /* 1713.011152 => 230398.5 => .00065% under */
900 { 150, 768},
901 { 300, 384},
902 { 600, 192},
903 { 1200, 96},
904 { 1800, 64},
905 { 2400, 48},
906 { 4800, 24},
907 { 7200, 16},
908 { 9600, 12},
909 { 19200, 6},
910 { 38400, 3},
911 { 57600, 2},
912 { 115200, 1},
913};
914
915/*****************************************************************************
916 * calc_baud_rate_divisor
917 * this function calculates the proper baud rate divisor for the specified
918 * baud rate.
919 *****************************************************************************/
920static int calc_baud_rate_divisor(int baudrate, int *divisor)
921{
922 int i;
923 __u16 custom;
924 __u16 round1;
925 __u16 round;
926
927
928 dbg("%s - %d", __FUNCTION__, baudrate);
929
930 for (i = 0; i < ARRAY_SIZE(divisor_table); i++) {
931 if (divisor_table[i].baudrate == baudrate) {
932 *divisor = divisor_table[i].divisor;
933 return 0;
934 }
935 }
936
937 /* After trying for all the standard baud rates *
938 * Try calculating the divisor for this baud rate */
939 if (baudrate > 75 && baudrate < 230400) {
940 /* get the divisor */
941 custom = (__u16)(230400L / baudrate);
942
943 /* Check for round off */
944 round1 = (__u16)(2304000L / baudrate);
945 round = (__u16)(round1 - (custom * 10));
946 if (round > 4)
947 custom++;
948 *divisor = custom;
949
950 dbg("Baud %d = %d",baudrate, custom);
951 return 0;
952 }
953
954 dbg("Baud calculation Failed...");
955 return -EINVAL;
956}
957
958/*
959 * send_cmd_write_baud_rate
960 * this function sends the proper command to change the baud rate of the
961 * specified port.
962 */
963static int send_cmd_write_baud_rate(struct moschip_port *mos7720_port,
964 int baudrate)
965{
966 struct usb_serial_port *port;
967 struct usb_serial *serial;
968 int divisor;
969 int status;
970 unsigned char data;
971 unsigned char number;
972
973 if (mos7720_port == NULL)
974 return -1;
975
976 port = mos7720_port->port;
977 serial = port->serial;
978
979 dbg("%s: Entering ..........", __FUNCTION__);
980
981 number = port->number - port->serial->minor;
982 dbg("%s - port = %d, baud = %d", __FUNCTION__, port->number, baudrate);
983
984 /* Calculate the Divisor */
985 status = calc_baud_rate_divisor(baudrate, &divisor);
986 if (status) {
987 err("%s - bad baud rate", __FUNCTION__);
988 return status;
989 }
990
991 /* Enable access to divisor latch */
992 data = mos7720_port->shadowLCR | UART_LCR_DLAB;
993 mos7720_port->shadowLCR = data;
994 send_mos_cmd(serial, MOS_WRITE, number, UART_LCR, &data);
995
996 /* Write the divisor */
997 data = ((unsigned char)(divisor & 0xff));
998 send_mos_cmd(serial, MOS_WRITE, number, 0x00, &data);
999
1000 data = ((unsigned char)((divisor & 0xff00) >> 8));
1001 send_mos_cmd(serial, MOS_WRITE, number, 0x01, &data);
1002
1003 /* Disable access to divisor latch */
1004 data = mos7720_port->shadowLCR & ~UART_LCR_DLAB;
1005 mos7720_port->shadowLCR = data;
1006 send_mos_cmd(serial, MOS_WRITE, number, 0x03, &data);
1007
1008 return status;
1009}
1010
1011/*
1012 * change_port_settings
1013 * This routine is called to set the UART on the device to match
1014 * the specified new settings.
1015 */
1016static void change_port_settings(struct moschip_port *mos7720_port,
1017 struct termios *old_termios)
1018{
1019 struct usb_serial_port *port;
1020 struct usb_serial *serial;
1021 struct tty_struct *tty;
1022 int baud;
1023 unsigned cflag;
1024 unsigned iflag;
1025 __u8 mask = 0xff;
1026 __u8 lData;
1027 __u8 lParity;
1028 __u8 lStop;
1029 int status;
1030 int port_number;
1031 char data;
1032
1033 if (mos7720_port == NULL)
1034 return ;
1035
1036 port = mos7720_port->port;
1037 serial = port->serial;
1038 port_number = port->number - port->serial->minor;
1039
1040 dbg("%s - port %d", __FUNCTION__, port->number);
1041
1042 if (!mos7720_port->open) {
1043 dbg("%s - port not opened", __FUNCTION__);
1044 return;
1045 }
1046
1047 tty = mos7720_port->port->tty;
1048
1049 if ((!tty) || (!tty->termios)) {
1050 dbg("%s - no tty structures", __FUNCTION__);
1051 return;
1052 }
1053
1054 dbg("%s: Entering ..........", __FUNCTION__);
1055
1056 lData = UART_LCR_WLEN8;
1057 lStop = 0x00; /* 1 stop bit */
1058 lParity = 0x00; /* No parity */
1059
1060 cflag = tty->termios->c_cflag;
1061 iflag = tty->termios->c_iflag;
1062
1063 /* Change the number of bits */
1064 switch (cflag & CSIZE) {
1065 case CS5:
1066 lData = UART_LCR_WLEN5;
1067 mask = 0x1f;
1068 break;
1069
1070 case CS6:
1071 lData = UART_LCR_WLEN6;
1072 mask = 0x3f;
1073 break;
1074
1075 case CS7:
1076 lData = UART_LCR_WLEN7;
1077 mask = 0x7f;
1078 break;
1079 default:
1080 case CS8:
1081 lData = UART_LCR_WLEN8;
1082 break;
1083 }
1084
1085 /* Change the Parity bit */
1086 if (cflag & PARENB) {
1087 if (cflag & PARODD) {
1088 lParity = UART_LCR_PARITY;
1089 dbg("%s - parity = odd", __FUNCTION__);
1090 } else {
1091 lParity = (UART_LCR_EPAR | UART_LCR_PARITY);
1092 dbg("%s - parity = even", __FUNCTION__);
1093 }
1094
1095 } else {
1096 dbg("%s - parity = none", __FUNCTION__);
1097 }
1098
1099 if (cflag & CMSPAR)
1100 lParity = lParity | 0x20;
1101
1102 /* Change the Stop bit */
1103 if (cflag & CSTOPB) {
1104 lStop = UART_LCR_STOP;
1105 dbg("%s - stop bits = 2", __FUNCTION__);
1106 } else {
1107 lStop = 0x00;
1108 dbg("%s - stop bits = 1", __FUNCTION__);
1109 }
1110
1111#define LCR_BITS_MASK 0x03 /* Mask for bits/char field */
1112#define LCR_STOP_MASK 0x04 /* Mask for stop bits field */
1113#define LCR_PAR_MASK 0x38 /* Mask for parity field */
1114
1115 /* Update the LCR with the correct value */
1116 mos7720_port->shadowLCR &= ~(LCR_BITS_MASK | LCR_STOP_MASK | LCR_PAR_MASK);
1117 mos7720_port->shadowLCR |= (lData | lParity | lStop);
1118
1119
1120 /* Disable Interrupts */
1121 data = 0x00;
1122 send_mos_cmd(serial,MOS_WRITE,port->number - port->serial->minor, UART_IER, &data);
1123
1124 data = 0x00;
1125 send_mos_cmd(serial, MOS_WRITE, port_number, UART_FCR, &data);
1126
1127 data = 0xcf;
1128 send_mos_cmd(serial, MOS_WRITE, port_number, UART_FCR, &data);
1129
1130 /* Send the updated LCR value to the mos7720 */
1131 data = mos7720_port->shadowLCR;
1132 send_mos_cmd(serial, MOS_WRITE, port_number, UART_LCR, &data);
1133
1134 data = 0x00b;
1135 mos7720_port->shadowMCR = data;
1136 send_mos_cmd(serial, MOS_WRITE, port_number, 0x04, &data);
1137 data = 0x00b;
1138 send_mos_cmd(serial, MOS_WRITE, port_number, 0x04, &data);
1139
1140 /* set up the MCR register and send it to the mos7720 */
1141 mos7720_port->shadowMCR = UART_MCR_OUT2;
1142 if (cflag & CBAUD)
1143 mos7720_port->shadowMCR |= (UART_MCR_DTR | UART_MCR_RTS);
1144
1145 if (cflag & CRTSCTS) {
1146 mos7720_port->shadowMCR |= (UART_MCR_XONANY);
1147
1148 /* To set hardware flow control to the specified *
1149 * serial port, in SP1/2_CONTROL_REG */
1150 if (port->number) {
1151 data = 0x001;
1152 send_mos_cmd(serial, MOS_WRITE, MOS_MAX_PORT,
1153 0x08, &data);
1154 } else {
1155 data = 0x002;
1156 send_mos_cmd(serial, MOS_WRITE, MOS_MAX_PORT,
1157 0x08, &data);
1158 }
1159 } else {
1160 mos7720_port->shadowMCR &= ~(UART_MCR_XONANY);
1161 }
1162
1163 data = mos7720_port->shadowMCR;
1164 send_mos_cmd(serial, MOS_WRITE, port_number, UART_MCR, &data);
1165
1166 /* Determine divisor based on baud rate */
1167 baud = tty_get_baud_rate(tty);
1168 if (!baud) {
1169 /* pick a default, any default... */
1170 dbg("Picked default baud...");
1171 baud = 9600;
1172 }
1173
1174 if (baud >= 230400) {
1175 set_higher_rates(mos7720_port, baud);
1176 /* Enable Interrupts */
1177 data = 0x0c;
1178 send_mos_cmd(serial, MOS_WRITE, port_number, UART_IER, &data);
1179 return;
1180 }
1181
1182 dbg("%s - baud rate = %d", __FUNCTION__, baud);
1183 status = send_cmd_write_baud_rate(mos7720_port, baud);
1184
1185 /* Enable Interrupts */
1186 data = 0x0c;
1187 send_mos_cmd(serial, MOS_WRITE, port_number, UART_IER, &data);
1188
1189 if (port->read_urb->status != -EINPROGRESS) {
1190 port->read_urb->dev = serial->dev;
1191
1192 status = usb_submit_urb(port->read_urb, GFP_ATOMIC);
1193 if (status)
1194 dbg("usb_submit_urb(read bulk) failed, status = %d",
1195 status);
1196 }
1197 return;
1198}
1199
1200/*
1201 * mos7720_set_termios
1202 * this function is called by the tty driver when it wants to change the
1203 * termios structure.
1204 */
1205static void mos7720_set_termios(struct usb_serial_port *port,
1206 struct termios *old_termios)
1207{
1208 int status;
1209 unsigned int cflag;
1210 struct usb_serial *serial;
1211 struct moschip_port *mos7720_port;
1212 struct tty_struct *tty;
1213
1214 serial = port->serial;
1215
1216 mos7720_port = usb_get_serial_port_data(port);
1217
1218 if (mos7720_port == NULL)
1219 return;
1220
1221 tty = port->tty;
1222
1223 if (!port->tty || !port->tty->termios) {
1224 dbg("%s - no tty or termios", __FUNCTION__);
1225 return;
1226 }
1227
1228 if (!mos7720_port->open) {
1229 dbg("%s - port not opened", __FUNCTION__);
1230 return;
1231 }
1232
1233 dbg("%s\n","setting termios - ASPIRE");
1234
1235 cflag = tty->termios->c_cflag;
1236
1237 if (!cflag) {
1238 printk("%s %s\n",__FUNCTION__,"cflag is NULL");
1239 return;
1240 }
1241
1242 /* check that they really want us to change something */
1243 if (old_termios) {
1244 if ((cflag == old_termios->c_cflag) &&
1245 (RELEVANT_IFLAG(tty->termios->c_iflag) ==
1246 RELEVANT_IFLAG(old_termios->c_iflag))) {
1247 dbg("Nothing to change");
1248 return;
1249 }
1250 }
1251
1252 dbg("%s - clfag %08x iflag %08x", __FUNCTION__,
1253 tty->termios->c_cflag,
1254 RELEVANT_IFLAG(tty->termios->c_iflag));
1255
1256 if (old_termios)
1257 dbg("%s - old clfag %08x old iflag %08x", __FUNCTION__,
1258 old_termios->c_cflag,
1259 RELEVANT_IFLAG(old_termios->c_iflag));
1260
1261 dbg("%s - port %d", __FUNCTION__, port->number);
1262
1263 /* change the port settings to the new ones specified */
1264 change_port_settings(mos7720_port, old_termios);
1265
1266 if(!port->read_urb) {
1267 dbg("%s","URB KILLED !!!!!\n");
1268 return;
1269 }
1270
1271 if(port->read_urb->status != -EINPROGRESS) {
1272 port->read_urb->dev = serial->dev;
1273 status = usb_submit_urb(port->read_urb, GFP_ATOMIC);
1274 if (status)
1275 dbg("usb_submit_urb(read bulk) failed, status = %d",
1276 status);
1277 }
1278 return;
1279}
1280
1281/*
1282 * get_lsr_info - get line status register info
1283 *
1284 * Purpose: Let user call ioctl() to get info when the UART physically
1285 * is emptied. On bus types like RS485, the transmitter must
1286 * release the bus after transmitting. This must be done when
1287 * the transmit shift register is empty, not be done when the
1288 * transmit holding register is empty. This functionality
1289 * allows an RS485 driver to be written in user space.
1290 */
1291static int get_lsr_info(struct moschip_port *mos7720_port,
1292 unsigned int __user *value)
1293{
1294 int count;
1295 unsigned int result = 0;
1296
1297 count = mos7720_chars_in_buffer(mos7720_port->port);
1298 if (count == 0) {
1299 dbg("%s -- Empty", __FUNCTION__);
1300 result = TIOCSER_TEMT;
1301 }
1302
1303 if (copy_to_user(value, &result, sizeof(int)))
1304 return -EFAULT;
1305 return 0;
1306}
1307
1308/*
1309 * get_number_bytes_avail - get number of bytes available
1310 *
1311 * Purpose: Let user call ioctl to get the count of number of bytes available.
1312 */
1313static int get_number_bytes_avail(struct moschip_port *mos7720_port,
1314 unsigned int __user *value)
1315{
1316 unsigned int result = 0;
1317 struct tty_struct *tty = mos7720_port->port->tty;
1318
1319 if (!tty)
1320 return -ENOIOCTLCMD;
1321
1322 result = tty->read_cnt;
1323
1324 dbg("%s(%d) = %d", __FUNCTION__, mos7720_port->port->number, result);
1325 if (copy_to_user(value, &result, sizeof(int)))
1326 return -EFAULT;
1327
1328 return -ENOIOCTLCMD;
1329}
1330
1331static int set_modem_info(struct moschip_port *mos7720_port, unsigned int cmd,
1332 unsigned int __user *value)
1333{
1334 unsigned int mcr ;
1335 unsigned int arg;
1336 unsigned char data;
1337
1338 struct usb_serial_port *port;
1339
1340 if (mos7720_port == NULL)
1341 return -1;
1342
1343 port = (struct usb_serial_port*)mos7720_port->port;
1344 mcr = mos7720_port->shadowMCR;
1345
1346 if (copy_from_user(&arg, value, sizeof(int)))
1347 return -EFAULT;
1348
1349 switch (cmd) {
1350 case TIOCMBIS:
1351 if (arg & TIOCM_RTS)
1352 mcr |= UART_MCR_RTS;
1353 if (arg & TIOCM_DTR)
1354 mcr |= UART_MCR_RTS;
1355 if (arg & TIOCM_LOOP)
1356 mcr |= UART_MCR_LOOP;
1357 break;
1358
1359 case TIOCMBIC:
1360 if (arg & TIOCM_RTS)
1361 mcr &= ~UART_MCR_RTS;
1362 if (arg & TIOCM_DTR)
1363 mcr &= ~UART_MCR_RTS;
1364 if (arg & TIOCM_LOOP)
1365 mcr &= ~UART_MCR_LOOP;
1366 break;
1367
1368 case TIOCMSET:
1369 /* turn off the RTS and DTR and LOOPBACK
1370 * and then only turn on what was asked to */
1371 mcr &= ~(UART_MCR_RTS | UART_MCR_DTR | UART_MCR_LOOP);
1372 mcr |= ((arg & TIOCM_RTS) ? UART_MCR_RTS : 0);
1373 mcr |= ((arg & TIOCM_DTR) ? UART_MCR_DTR : 0);
1374 mcr |= ((arg & TIOCM_LOOP) ? UART_MCR_LOOP : 0);
1375 break;
1376 }
1377
1378 mos7720_port->shadowMCR = mcr;
1379
1380 data = mos7720_port->shadowMCR;
1381 send_mos_cmd(port->serial, MOS_WRITE,
1382 port->number - port->serial->minor, UART_MCR, &data);
1383
1384 return 0;
1385}
1386
1387static int get_modem_info(struct moschip_port *mos7720_port,
1388 unsigned int __user *value)
1389{
1390 unsigned int result = 0;
1391 unsigned int msr = mos7720_port->shadowMSR;
1392 unsigned int mcr = mos7720_port->shadowMCR;
1393
1394 result = ((mcr & UART_MCR_DTR) ? TIOCM_DTR: 0) /* 0x002 */
1395 | ((mcr & UART_MCR_RTS) ? TIOCM_RTS: 0) /* 0x004 */
1396 | ((msr & UART_MSR_CTS) ? TIOCM_CTS: 0) /* 0x020 */
1397 | ((msr & UART_MSR_DCD) ? TIOCM_CAR: 0) /* 0x040 */
1398 | ((msr & UART_MSR_RI) ? TIOCM_RI: 0) /* 0x080 */
1399 | ((msr & UART_MSR_DSR) ? TIOCM_DSR: 0); /* 0x100 */
1400
1401
1402 dbg("%s -- %x", __FUNCTION__, result);
1403
1404 if (copy_to_user(value, &result, sizeof(int)))
1405 return -EFAULT;
1406 return 0;
1407}
1408
1409static int get_serial_info(struct moschip_port *mos7720_port,
1410 struct serial_struct __user *retinfo)
1411{
1412 struct serial_struct tmp;
1413
1414 if (!retinfo)
1415 return -EFAULT;
1416
1417 memset(&tmp, 0, sizeof(tmp));
1418
1419 tmp.type = PORT_16550A;
1420 tmp.line = mos7720_port->port->serial->minor;
1421 tmp.port = mos7720_port->port->number;
1422 tmp.irq = 0;
1423 tmp.flags = ASYNC_SKIP_TEST | ASYNC_AUTO_IRQ;
1424 tmp.xmit_fifo_size = NUM_URBS * URB_TRANSFER_BUFFER_SIZE;
1425 tmp.baud_base = 9600;
1426 tmp.close_delay = 5*HZ;
1427 tmp.closing_wait = 30*HZ;
1428
1429 if (copy_to_user(retinfo, &tmp, sizeof(*retinfo)))
1430 return -EFAULT;
1431 return 0;
1432}
1433
1434static int mos7720_ioctl(struct usb_serial_port *port, struct file *file,
1435 unsigned int cmd, unsigned long arg)
1436{
1437 struct moschip_port *mos7720_port;
1438 struct async_icount cnow;
1439 struct async_icount cprev;
1440 struct serial_icounter_struct icount;
1441
1442 mos7720_port = usb_get_serial_port_data(port);
1443 if (mos7720_port == NULL)
1444 return -ENODEV;
1445
1446 dbg("%s - port %d, cmd = 0x%x", __FUNCTION__, port->number, cmd);
1447
1448 switch (cmd) {
1449 case TIOCINQ:
1450 /* return number of bytes available */
1451 dbg("%s (%d) TIOCINQ", __FUNCTION__, port->number);
1452 return get_number_bytes_avail(mos7720_port,
1453 (unsigned int __user *)arg);
1454 break;
1455
1456 case TIOCSERGETLSR:
1457 dbg("%s (%d) TIOCSERGETLSR", __FUNCTION__, port->number);
1458 return get_lsr_info(mos7720_port, (unsigned int __user *)arg);
1459 return 0;
1460
1461 case TIOCMBIS:
1462 case TIOCMBIC:
1463 case TIOCMSET:
1464 dbg("%s (%d) TIOCMSET/TIOCMBIC/TIOCMSET", __FUNCTION__,
1465 port->number);
1466 return set_modem_info(mos7720_port, cmd,
1467 (unsigned int __user *)arg);
1468
1469 case TIOCMGET:
1470 dbg("%s (%d) TIOCMGET", __FUNCTION__, port->number);
1471 return get_modem_info(mos7720_port,
1472 (unsigned int __user *)arg);
1473
1474 case TIOCGSERIAL:
1475 dbg("%s (%d) TIOCGSERIAL", __FUNCTION__, port->number);
1476 return get_serial_info(mos7720_port,
1477 (struct serial_struct __user *)arg);
1478
1479 case TIOCSSERIAL:
1480 dbg("%s (%d) TIOCSSERIAL", __FUNCTION__, port->number);
1481 break;
1482
1483 case TIOCMIWAIT:
1484 dbg("%s (%d) TIOCMIWAIT", __FUNCTION__, port->number);
1485 cprev = mos7720_port->icount;
1486 while (1) {
1487 if (signal_pending(current))
1488 return -ERESTARTSYS;
1489 cnow = mos7720_port->icount;
1490 if (cnow.rng == cprev.rng && cnow.dsr == cprev.dsr &&
1491 cnow.dcd == cprev.dcd && cnow.cts == cprev.cts)
1492 return -EIO; /* no change => error */
1493 if (((arg & TIOCM_RNG) && (cnow.rng != cprev.rng)) ||
1494 ((arg & TIOCM_DSR) && (cnow.dsr != cprev.dsr)) ||
1495 ((arg & TIOCM_CD) && (cnow.dcd != cprev.dcd)) ||
1496 ((arg & TIOCM_CTS) && (cnow.cts != cprev.cts)) ) {
1497 return 0;
1498 }
1499 cprev = cnow;
1500 }
1501 /* NOTREACHED */
1502 break;
1503
1504 case TIOCGICOUNT:
1505 cnow = mos7720_port->icount;
1506 icount.cts = cnow.cts;
1507 icount.dsr = cnow.dsr;
1508 icount.rng = cnow.rng;
1509 icount.dcd = cnow.dcd;
1510 icount.rx = cnow.rx;
1511 icount.tx = cnow.tx;
1512 icount.frame = cnow.frame;
1513 icount.overrun = cnow.overrun;
1514 icount.parity = cnow.parity;
1515 icount.brk = cnow.brk;
1516 icount.buf_overrun = cnow.buf_overrun;
1517
1518 dbg("%s (%d) TIOCGICOUNT RX=%d, TX=%d", __FUNCTION__,
1519 port->number, icount.rx, icount.tx );
1520 if (copy_to_user((void __user *)arg, &icount, sizeof(icount)))
1521 return -EFAULT;
1522 return 0;
1523 }
1524
1525 return -ENOIOCTLCMD;
1526}
1527
1528static int mos7720_startup(struct usb_serial *serial)
1529{
1530 struct moschip_serial *mos7720_serial;
1531 struct moschip_port *mos7720_port;
1532 struct usb_device *dev;
1533 int i;
1534 char data;
1535
1536 dbg("%s: Entering ..........", __FUNCTION__);
1537
1538 if (!serial) {
1539 dbg("Invalid Handler");
1540 return -ENODEV;
1541 }
1542
1543 dev = serial->dev;
1544
1545 /* create our private serial structure */
1546 mos7720_serial = kzalloc(sizeof(struct moschip_serial), GFP_KERNEL);
1547 if (mos7720_serial == NULL) {
1548 err("%s - Out of memory", __FUNCTION__);
1549 return -ENOMEM;
1550 }
1551
1552 usb_set_serial_data(serial, mos7720_serial);
1553
1554 /* we set up the pointers to the endpoints in the mos7720_open *
1555 * function, as the structures aren't created yet. */
1556
1557 /* set up port private structures */
1558 for (i = 0; i < serial->num_ports; ++i) {
1559 mos7720_port = kzalloc(sizeof(struct moschip_port), GFP_KERNEL);
1560 if (mos7720_port == NULL) {
1561 err("%s - Out of memory", __FUNCTION__);
1562 usb_set_serial_data(serial, NULL);
1563 kfree(mos7720_serial);
1564 return -ENOMEM;
1565 }
1566
1567 /* Initialize all port interrupt end point to port 0 int
1568 * endpoint. Our device has only one interrupt endpoint
1569 * comman to all ports */
1570 serial->port[i]->interrupt_in_endpointAddress = serial->port[0]->interrupt_in_endpointAddress;
1571
1572 mos7720_port->port = serial->port[i];
1573 usb_set_serial_port_data(serial->port[i], mos7720_port);
1574
1575 dbg("port number is %d", serial->port[i]->number);
1576 dbg("serial number is %d", serial->minor);
1577 }
1578
1579
1580 /* setting configuration feature to one */
1581 usb_control_msg(serial->dev, usb_sndctrlpipe(serial->dev, 0),
1582 (__u8)0x03, 0x00,0x01,0x00, NULL, 0x00, 5*HZ);
1583
1584 send_mos_cmd(serial,MOS_READ,0x00, UART_LSR, &data); // LSR For Port 1
1585 dbg("LSR:%x",data);
1586
1587 send_mos_cmd(serial,MOS_READ,0x01, UART_LSR, &data); // LSR For Port 2
1588 dbg("LSR:%x",data);
1589
1590 return 0;
1591}
1592
1593static void mos7720_shutdown(struct usb_serial *serial)
1594{
1595 int i;
1596
1597 /* free private structure allocated for serial port */
1598 for (i=0; i < serial->num_ports; ++i) {
1599 kfree(usb_get_serial_port_data(serial->port[i]));
1600 usb_set_serial_port_data(serial->port[i], NULL);
1601 }
1602
1603 /* free private structure allocated for serial device */
1604 kfree(usb_get_serial_data(serial));
1605 usb_set_serial_data(serial, NULL);
1606}
1607
1608static struct usb_serial_driver moschip7720_2port_driver = {
1609 .driver = {
1610 .owner = THIS_MODULE,
1611 .name = "moschip7720",
1612 },
1613 .description = "Moschip 2 port adapter",
1614 .id_table = moschip_port_id_table,
1615 .num_interrupt_in = 1,
1616 .num_bulk_in = 2,
1617 .num_bulk_out = 2,
1618 .num_ports = 2,
1619 .open = mos7720_open,
1620 .close = mos7720_close,
1621 .throttle = mos7720_throttle,
1622 .unthrottle = mos7720_unthrottle,
1623 .attach = mos7720_startup,
1624 .shutdown = mos7720_shutdown,
1625 .ioctl = mos7720_ioctl,
1626 .set_termios = mos7720_set_termios,
1627 .write = mos7720_write,
1628 .write_room = mos7720_write_room,
1629 .chars_in_buffer = mos7720_chars_in_buffer,
1630 .break_ctl = mos7720_break,
1631 .read_bulk_callback = mos7720_bulk_in_callback,
1632};
1633
1634static struct usb_driver usb_driver = {
1635 .name = "moschip7720",
1636 .probe = usb_serial_probe,
1637 .disconnect = usb_serial_disconnect,
1638 .id_table = moschip_port_id_table,
1639};
1640
1641static int __init moschip7720_init(void)
1642{
1643 int retval;
1644
1645 dbg("%s: Entering ..........", __FUNCTION__);
1646
1647 /* Register with the usb serial */
1648 retval = usb_serial_register(&moschip7720_2port_driver);
1649 if (retval)
1650 goto failed_port_device_register;
1651
1652 info(DRIVER_DESC " " DRIVER_VERSION);
1653
1654 /* Register with the usb */
1655 retval = usb_register(&usb_driver);
1656 if (retval)
1657 goto failed_usb_register;
1658
1659 return 0;
1660
1661failed_usb_register:
1662 usb_serial_deregister(&moschip7720_2port_driver);
1663
1664failed_port_device_register:
1665 return retval;
1666}
1667
1668static void __exit moschip7720_exit(void)
1669{
1670 usb_deregister(&usb_driver);
1671 usb_serial_deregister(&moschip7720_2port_driver);
1672}
1673
1674module_init(moschip7720_init);
1675module_exit(moschip7720_exit);
1676
1677/* Module information */
1678MODULE_AUTHOR( DRIVER_AUTHOR );
1679MODULE_DESCRIPTION( DRIVER_DESC );
1680MODULE_LICENSE("GPL");
1681
1682module_param(debug, bool, S_IRUGO | S_IWUSR);
1683MODULE_PARM_DESC(debug, "Debug enabled or not");
diff --git a/drivers/usb/serial/mos7840.c b/drivers/usb/serial/mos7840.c
index 95bf57166c59..5b71962d0351 100644
--- a/drivers/usb/serial/mos7840.c
+++ b/drivers/usb/serial/mos7840.c
@@ -421,7 +421,7 @@ static int mos7840_handle_new_lsr(struct moschip_port *port, __u8 new_lsr)
421/************************************************************************/ 421/************************************************************************/
422/************************************************************************/ 422/************************************************************************/
423 423
424static void mos7840_control_callback(struct urb *urb, struct pt_regs *regs) 424static void mos7840_control_callback(struct urb *urb)
425{ 425{
426 unsigned char *data; 426 unsigned char *data;
427 struct moschip_port *mos7840_port; 427 struct moschip_port *mos7840_port;
@@ -497,7 +497,7 @@ static int mos7840_get_reg(struct moschip_port *mcs, __u16 Wval, __u16 reg,
497 * interrupt endpoint. 497 * interrupt endpoint.
498 *****************************************************************************/ 498 *****************************************************************************/
499 499
500static void mos7840_interrupt_callback(struct urb *urb, struct pt_regs *regs) 500static void mos7840_interrupt_callback(struct urb *urb)
501{ 501{
502 int result; 502 int result;
503 int length; 503 int length;
@@ -647,7 +647,7 @@ static struct usb_serial *mos7840_get_usb_serial(struct usb_serial_port *port,
647 * bulk in endpoint. 647 * bulk in endpoint.
648 *****************************************************************************/ 648 *****************************************************************************/
649 649
650static void mos7840_bulk_in_callback(struct urb *urb, struct pt_regs *regs) 650static void mos7840_bulk_in_callback(struct urb *urb)
651{ 651{
652 int status; 652 int status;
653 unsigned char *data; 653 unsigned char *data;
@@ -726,8 +726,7 @@ static void mos7840_bulk_in_callback(struct urb *urb, struct pt_regs *regs)
726 * on the bulk out endpoint. 726 * on the bulk out endpoint.
727 *****************************************************************************/ 727 *****************************************************************************/
728 728
729static void mos7840_bulk_out_data_callback(struct urb *urb, 729static void mos7840_bulk_out_data_callback(struct urb *urb)
730 struct pt_regs *regs)
731{ 730{
732 struct moschip_port *mos7840_port; 731 struct moschip_port *mos7840_port;
733 struct tty_struct *tty; 732 struct tty_struct *tty;
@@ -1088,7 +1087,7 @@ static int mos7840_open(struct usb_serial_port *port, struct file *filp)
1088 mos7840_port->icount.tx = 0; 1087 mos7840_port->icount.tx = 0;
1089 mos7840_port->icount.rx = 0; 1088 mos7840_port->icount.rx = 0;
1090 1089
1091 dbg("\n\nusb_serial serial:%x mos7840_port:%x\n usb_serial_port port:%x\n\n", (unsigned int)serial, (unsigned int)mos7840_port, (unsigned int)port); 1090 dbg("\n\nusb_serial serial:%p mos7840_port:%p\n usb_serial_port port:%p\n\n", serial, mos7840_port, port);
1092 1091
1093 return 0; 1092 return 0;
1094 1093
@@ -1421,7 +1420,6 @@ static int mos7840_write(struct usb_serial_port *port,
1421 int i; 1420 int i;
1422 int bytes_sent = 0; 1421 int bytes_sent = 0;
1423 int transfer_size; 1422 int transfer_size;
1424 int from_user = 0;
1425 1423
1426 struct moschip_port *mos7840_port; 1424 struct moschip_port *mos7840_port;
1427 struct usb_serial *serial; 1425 struct usb_serial *serial;
@@ -1512,15 +1510,7 @@ static int mos7840_write(struct usb_serial_port *port,
1512 } 1510 }
1513 transfer_size = min(count, URB_TRANSFER_BUFFER_SIZE); 1511 transfer_size = min(count, URB_TRANSFER_BUFFER_SIZE);
1514 1512
1515 if (from_user) { 1513 memcpy(urb->transfer_buffer, current_position, transfer_size);
1516 if (copy_from_user
1517 (urb->transfer_buffer, current_position, transfer_size)) {
1518 bytes_sent = -EFAULT;
1519 goto exit;
1520 }
1521 } else {
1522 memcpy(urb->transfer_buffer, current_position, transfer_size);
1523 }
1524 1514
1525 /* fill urb with data and submit */ 1515 /* fill urb with data and submit */
1526 usb_fill_bulk_urb(urb, 1516 usb_fill_bulk_urb(urb,
@@ -2226,7 +2216,7 @@ static void mos7840_set_termios(struct usb_serial_port *port,
2226 *****************************************************************************/ 2216 *****************************************************************************/
2227 2217
2228static int mos7840_get_lsr_info(struct moschip_port *mos7840_port, 2218static int mos7840_get_lsr_info(struct moschip_port *mos7840_port,
2229 unsigned int *value) 2219 unsigned int __user *value)
2230{ 2220{
2231 int count; 2221 int count;
2232 unsigned int result = 0; 2222 unsigned int result = 0;
@@ -2249,7 +2239,7 @@ static int mos7840_get_lsr_info(struct moschip_port *mos7840_port,
2249 *****************************************************************************/ 2239 *****************************************************************************/
2250 2240
2251static int mos7840_get_bytes_avail(struct moschip_port *mos7840_port, 2241static int mos7840_get_bytes_avail(struct moschip_port *mos7840_port,
2252 unsigned int *value) 2242 unsigned int __user *value)
2253{ 2243{
2254 unsigned int result = 0; 2244 unsigned int result = 0;
2255 struct tty_struct *tty = mos7840_port->port->tty; 2245 struct tty_struct *tty = mos7840_port->port->tty;
@@ -2272,7 +2262,7 @@ static int mos7840_get_bytes_avail(struct moschip_port *mos7840_port,
2272 *****************************************************************************/ 2262 *****************************************************************************/
2273 2263
2274static int mos7840_set_modem_info(struct moschip_port *mos7840_port, 2264static int mos7840_set_modem_info(struct moschip_port *mos7840_port,
2275 unsigned int cmd, unsigned int *value) 2265 unsigned int cmd, unsigned int __user *value)
2276{ 2266{
2277 unsigned int mcr; 2267 unsigned int mcr;
2278 unsigned int arg; 2268 unsigned int arg;
@@ -2342,7 +2332,7 @@ static int mos7840_set_modem_info(struct moschip_port *mos7840_port,
2342 *****************************************************************************/ 2332 *****************************************************************************/
2343 2333
2344static int mos7840_get_modem_info(struct moschip_port *mos7840_port, 2334static int mos7840_get_modem_info(struct moschip_port *mos7840_port,
2345 unsigned int *value) 2335 unsigned int __user *value)
2346{ 2336{
2347 unsigned int result = 0; 2337 unsigned int result = 0;
2348 __u16 msr; 2338 __u16 msr;
@@ -2371,7 +2361,7 @@ static int mos7840_get_modem_info(struct moschip_port *mos7840_port,
2371 *****************************************************************************/ 2361 *****************************************************************************/
2372 2362
2373static int mos7840_get_serial_info(struct moschip_port *mos7840_port, 2363static int mos7840_get_serial_info(struct moschip_port *mos7840_port,
2374 struct serial_struct *retinfo) 2364 struct serial_struct __user *retinfo)
2375{ 2365{
2376 struct serial_struct tmp; 2366 struct serial_struct tmp;
2377 2367
@@ -2406,6 +2396,7 @@ static int mos7840_get_serial_info(struct moschip_port *mos7840_port,
2406static int mos7840_ioctl(struct usb_serial_port *port, struct file *file, 2396static int mos7840_ioctl(struct usb_serial_port *port, struct file *file,
2407 unsigned int cmd, unsigned long arg) 2397 unsigned int cmd, unsigned long arg)
2408{ 2398{
2399 void __user *argp = (void __user *)arg;
2409 struct moschip_port *mos7840_port; 2400 struct moschip_port *mos7840_port;
2410 struct tty_struct *tty; 2401 struct tty_struct *tty;
2411 2402
@@ -2422,11 +2413,12 @@ static int mos7840_ioctl(struct usb_serial_port *port, struct file *file,
2422 } 2413 }
2423 2414
2424 mos7840_port = mos7840_get_port_private(port); 2415 mos7840_port = mos7840_get_port_private(port);
2425 tty = mos7840_port->port->tty;
2426 2416
2427 if (mos7840_port == NULL) 2417 if (mos7840_port == NULL)
2428 return -1; 2418 return -1;
2429 2419
2420 tty = mos7840_port->port->tty;
2421
2430 dbg("%s - port %d, cmd = 0x%x", __FUNCTION__, port->number, cmd); 2422 dbg("%s - port %d, cmd = 0x%x", __FUNCTION__, port->number, cmd);
2431 2423
2432 switch (cmd) { 2424 switch (cmd) {
@@ -2434,16 +2426,13 @@ static int mos7840_ioctl(struct usb_serial_port *port, struct file *file,
2434 2426
2435 case TIOCINQ: 2427 case TIOCINQ:
2436 dbg("%s (%d) TIOCINQ", __FUNCTION__, port->number); 2428 dbg("%s (%d) TIOCINQ", __FUNCTION__, port->number);
2437 return mos7840_get_bytes_avail(mos7840_port, 2429 return mos7840_get_bytes_avail(mos7840_port, argp);
2438 (unsigned int *)arg);
2439 break;
2440 2430
2441 case TIOCOUTQ: 2431 case TIOCOUTQ:
2442 dbg("%s (%d) TIOCOUTQ", __FUNCTION__, port->number); 2432 dbg("%s (%d) TIOCOUTQ", __FUNCTION__, port->number);
2443 return put_user(tty->driver->chars_in_buffer ? 2433 return put_user(tty->driver->chars_in_buffer ?
2444 tty->driver->chars_in_buffer(tty) : 0, 2434 tty->driver->chars_in_buffer(tty) : 0,
2445 (int __user *)arg); 2435 (int __user *)arg);
2446 break;
2447 2436
2448 case TCFLSH: 2437 case TCFLSH:
2449 retval = tty_check_change(tty); 2438 retval = tty_check_change(tty);
@@ -2473,13 +2462,13 @@ static int mos7840_ioctl(struct usb_serial_port *port, struct file *file,
2473 2462
2474 case TCGETS: 2463 case TCGETS:
2475 if (kernel_termios_to_user_termios 2464 if (kernel_termios_to_user_termios
2476 ((struct termios __user *)arg, tty->termios)) 2465 ((struct termios __user *)argp, tty->termios))
2477 return -EFAULT; 2466 return -EFAULT;
2478 return 0; 2467 return 0;
2479 2468
2480 case TIOCSERGETLSR: 2469 case TIOCSERGETLSR:
2481 dbg("%s (%d) TIOCSERGETLSR", __FUNCTION__, port->number); 2470 dbg("%s (%d) TIOCSERGETLSR", __FUNCTION__, port->number);
2482 return mos7840_get_lsr_info(mos7840_port, (unsigned int *)arg); 2471 return mos7840_get_lsr_info(mos7840_port, argp);
2483 return 0; 2472 return 0;
2484 2473
2485 case TIOCMBIS: 2474 case TIOCMBIS:
@@ -2488,19 +2477,16 @@ static int mos7840_ioctl(struct usb_serial_port *port, struct file *file,
2488 dbg("%s (%d) TIOCMSET/TIOCMBIC/TIOCMSET", __FUNCTION__, 2477 dbg("%s (%d) TIOCMSET/TIOCMBIC/TIOCMSET", __FUNCTION__,
2489 port->number); 2478 port->number);
2490 mosret = 2479 mosret =
2491 mos7840_set_modem_info(mos7840_port, cmd, 2480 mos7840_set_modem_info(mos7840_port, cmd, argp);
2492 (unsigned int *)arg);
2493 return mosret; 2481 return mosret;
2494 2482
2495 case TIOCMGET: 2483 case TIOCMGET:
2496 dbg("%s (%d) TIOCMGET", __FUNCTION__, port->number); 2484 dbg("%s (%d) TIOCMGET", __FUNCTION__, port->number);
2497 return mos7840_get_modem_info(mos7840_port, 2485 return mos7840_get_modem_info(mos7840_port, argp);
2498 (unsigned int *)arg);
2499 2486
2500 case TIOCGSERIAL: 2487 case TIOCGSERIAL:
2501 dbg("%s (%d) TIOCGSERIAL", __FUNCTION__, port->number); 2488 dbg("%s (%d) TIOCGSERIAL", __FUNCTION__, port->number);
2502 return mos7840_get_serial_info(mos7840_port, 2489 return mos7840_get_serial_info(mos7840_port, argp);
2503 (struct serial_struct *)arg);
2504 2490
2505 case TIOCSSERIAL: 2491 case TIOCSSERIAL:
2506 dbg("%s (%d) TIOCSSERIAL", __FUNCTION__, port->number); 2492 dbg("%s (%d) TIOCSSERIAL", __FUNCTION__, port->number);
@@ -2550,7 +2536,7 @@ static int mos7840_ioctl(struct usb_serial_port *port, struct file *file,
2550 2536
2551 dbg("%s (%d) TIOCGICOUNT RX=%d, TX=%d", __FUNCTION__, 2537 dbg("%s (%d) TIOCGICOUNT RX=%d, TX=%d", __FUNCTION__,
2552 port->number, icount.rx, icount.tx); 2538 port->number, icount.rx, icount.tx);
2553 if (copy_to_user((void *)arg, &icount, sizeof(icount))) 2539 if (copy_to_user(argp, &icount, sizeof(icount)))
2554 return -EFAULT; 2540 return -EFAULT;
2555 return 0; 2541 return 0;
2556 2542
@@ -2818,7 +2804,7 @@ static int mos7840_startup(struct usb_serial *serial)
2818 2804
2819 /* setting configuration feature to one */ 2805 /* setting configuration feature to one */
2820 usb_control_msg(serial->dev, usb_sndctrlpipe(serial->dev, 0), 2806 usb_control_msg(serial->dev, usb_sndctrlpipe(serial->dev, 0),
2821 (__u8) 0x03, 0x00, 0x01, 0x00, 0x00, 0x00, 5 * HZ); 2807 (__u8) 0x03, 0x00, 0x01, 0x00, NULL, 0x00, 5 * HZ);
2822 return 0; 2808 return 0;
2823} 2809}
2824 2810
diff --git a/drivers/usb/serial/navman.c b/drivers/usb/serial/navman.c
index ac3f8b5d2c49..0610409a6568 100644
--- a/drivers/usb/serial/navman.c
+++ b/drivers/usb/serial/navman.c
@@ -32,7 +32,7 @@ static struct usb_driver navman_driver = {
32 .no_dynamic_id = 1, 32 .no_dynamic_id = 1,
33}; 33};
34 34
35static void navman_read_int_callback(struct urb *urb, struct pt_regs *regs) 35static void navman_read_int_callback(struct urb *urb)
36{ 36{
37 struct usb_serial_port *port = urb->context; 37 struct usb_serial_port *port = urb->context;
38 unsigned char *data = urb->transfer_buffer; 38 unsigned char *data = urb->transfer_buffer;
diff --git a/drivers/usb/serial/omninet.c b/drivers/usb/serial/omninet.c
index a764ff4e326c..bc91d3b726fc 100644
--- a/drivers/usb/serial/omninet.c
+++ b/drivers/usb/serial/omninet.c
@@ -64,8 +64,8 @@ static int debug;
64/* function prototypes */ 64/* function prototypes */
65static int omninet_open (struct usb_serial_port *port, struct file *filp); 65static int omninet_open (struct usb_serial_port *port, struct file *filp);
66static void omninet_close (struct usb_serial_port *port, struct file *filp); 66static void omninet_close (struct usb_serial_port *port, struct file *filp);
67static void omninet_read_bulk_callback (struct urb *urb, struct pt_regs *regs); 67static void omninet_read_bulk_callback (struct urb *urb);
68static void omninet_write_bulk_callback (struct urb *urb, struct pt_regs *regs); 68static void omninet_write_bulk_callback (struct urb *urb);
69static int omninet_write (struct usb_serial_port *port, const unsigned char *buf, int count); 69static int omninet_write (struct usb_serial_port *port, const unsigned char *buf, int count);
70static int omninet_write_room (struct usb_serial_port *port); 70static int omninet_write_room (struct usb_serial_port *port);
71static void omninet_shutdown (struct usb_serial *serial); 71static void omninet_shutdown (struct usb_serial *serial);
@@ -194,7 +194,7 @@ static void omninet_close (struct usb_serial_port *port, struct file * filp)
194#define OMNINET_HEADERLEN sizeof(struct omninet_header) 194#define OMNINET_HEADERLEN sizeof(struct omninet_header)
195#define OMNINET_BULKOUTSIZE (64 - OMNINET_HEADERLEN) 195#define OMNINET_BULKOUTSIZE (64 - OMNINET_HEADERLEN)
196 196
197static void omninet_read_bulk_callback (struct urb *urb, struct pt_regs *regs) 197static void omninet_read_bulk_callback (struct urb *urb)
198{ 198{
199 struct usb_serial_port *port = (struct usb_serial_port *)urb->context; 199 struct usb_serial_port *port = (struct usb_serial_port *)urb->context;
200 unsigned char *data = urb->transfer_buffer; 200 unsigned char *data = urb->transfer_buffer;
@@ -306,7 +306,7 @@ static int omninet_write_room (struct usb_serial_port *port)
306 return (room); 306 return (room);
307} 307}
308 308
309static void omninet_write_bulk_callback (struct urb *urb, struct pt_regs *regs) 309static void omninet_write_bulk_callback (struct urb *urb)
310{ 310{
311/* struct omninet_header *header = (struct omninet_header *) urb->transfer_buffer; */ 311/* struct omninet_header *header = (struct omninet_header *) urb->transfer_buffer; */
312 struct usb_serial_port *port = (struct usb_serial_port *) urb->context; 312 struct usb_serial_port *port = (struct usb_serial_port *) urb->context;
diff --git a/drivers/usb/serial/option.c b/drivers/usb/serial/option.c
index c856e6f40e22..130afbbd3fca 100644
--- a/drivers/usb/serial/option.c
+++ b/drivers/usb/serial/option.c
@@ -50,7 +50,7 @@ static void option_rx_throttle(struct usb_serial_port *port);
50static void option_rx_unthrottle(struct usb_serial_port *port); 50static void option_rx_unthrottle(struct usb_serial_port *port);
51static int option_write_room(struct usb_serial_port *port); 51static int option_write_room(struct usb_serial_port *port);
52 52
53static void option_instat_callback(struct urb *urb, struct pt_regs *regs); 53static void option_instat_callback(struct urb *urb);
54 54
55static int option_write(struct usb_serial_port *port, 55static int option_write(struct usb_serial_port *port,
56 const unsigned char *buf, int count); 56 const unsigned char *buf, int count);
@@ -337,7 +337,7 @@ static int option_write(struct usb_serial_port *port,
337 return count; 337 return count;
338} 338}
339 339
340static void option_indat_callback(struct urb *urb, struct pt_regs *regs) 340static void option_indat_callback(struct urb *urb)
341{ 341{
342 int err; 342 int err;
343 int endpoint; 343 int endpoint;
@@ -374,7 +374,7 @@ static void option_indat_callback(struct urb *urb, struct pt_regs *regs)
374 return; 374 return;
375} 375}
376 376
377static void option_outdat_callback(struct urb *urb, struct pt_regs *regs) 377static void option_outdat_callback(struct urb *urb)
378{ 378{
379 struct usb_serial_port *port; 379 struct usb_serial_port *port;
380 380
@@ -385,7 +385,7 @@ static void option_outdat_callback(struct urb *urb, struct pt_regs *regs)
385 usb_serial_port_softint(port); 385 usb_serial_port_softint(port);
386} 386}
387 387
388static void option_instat_callback(struct urb *urb, struct pt_regs *regs) 388static void option_instat_callback(struct urb *urb)
389{ 389{
390 int err; 390 int err;
391 struct usb_serial_port *port = (struct usb_serial_port *) urb->context; 391 struct usb_serial_port *port = (struct usb_serial_port *) urb->context;
@@ -565,7 +565,7 @@ static void option_close(struct usb_serial_port *port, struct file *filp)
565/* Helper functions used by option_setup_urbs */ 565/* Helper functions used by option_setup_urbs */
566static struct urb *option_setup_urb(struct usb_serial *serial, int endpoint, 566static struct urb *option_setup_urb(struct usb_serial *serial, int endpoint,
567 int dir, void *ctx, char *buf, int len, 567 int dir, void *ctx, char *buf, int len,
568 void (*callback)(struct urb *, struct pt_regs *regs)) 568 void (*callback)(struct urb *))
569{ 569{
570 struct urb *urb; 570 struct urb *urb;
571 571
diff --git a/drivers/usb/serial/pl2303.c b/drivers/usb/serial/pl2303.c
index 9c18173e33fb..bc800c8787a8 100644
--- a/drivers/usb/serial/pl2303.c
+++ b/drivers/usb/serial/pl2303.c
@@ -948,7 +948,7 @@ static void pl2303_update_line_status(struct usb_serial_port *port,
948 wake_up_interruptible(&priv->delta_msr_wait); 948 wake_up_interruptible(&priv->delta_msr_wait);
949} 949}
950 950
951static void pl2303_read_int_callback(struct urb *urb, struct pt_regs *regs) 951static void pl2303_read_int_callback(struct urb *urb)
952{ 952{
953 struct usb_serial_port *port = (struct usb_serial_port *) urb->context; 953 struct usb_serial_port *port = (struct usb_serial_port *) urb->context;
954 unsigned char *data = urb->transfer_buffer; 954 unsigned char *data = urb->transfer_buffer;
@@ -987,7 +987,7 @@ exit:
987 __FUNCTION__, status); 987 __FUNCTION__, status);
988} 988}
989 989
990static void pl2303_read_bulk_callback(struct urb *urb, struct pt_regs *regs) 990static void pl2303_read_bulk_callback(struct urb *urb)
991{ 991{
992 struct usb_serial_port *port = (struct usb_serial_port *) urb->context; 992 struct usb_serial_port *port = (struct usb_serial_port *) urb->context;
993 struct pl2303_private *priv = usb_get_serial_port_data(port); 993 struct pl2303_private *priv = usb_get_serial_port_data(port);
@@ -1070,7 +1070,7 @@ static void pl2303_read_bulk_callback(struct urb *urb, struct pt_regs *regs)
1070 return; 1070 return;
1071} 1071}
1072 1072
1073static void pl2303_write_bulk_callback(struct urb *urb, struct pt_regs *regs) 1073static void pl2303_write_bulk_callback(struct urb *urb)
1074{ 1074{
1075 struct usb_serial_port *port = (struct usb_serial_port *) urb->context; 1075 struct usb_serial_port *port = (struct usb_serial_port *) urb->context;
1076 struct pl2303_private *priv = usb_get_serial_port_data(port); 1076 struct pl2303_private *priv = usb_get_serial_port_data(port);
diff --git a/drivers/usb/serial/safe_serial.c b/drivers/usb/serial/safe_serial.c
index 1e07dfad6853..30b7ebc8d45d 100644
--- a/drivers/usb/serial/safe_serial.c
+++ b/drivers/usb/serial/safe_serial.c
@@ -204,7 +204,7 @@ static __u16 __inline__ fcs_compute10 (unsigned char *sp, int len, __u16 fcs)
204 return fcs; 204 return fcs;
205} 205}
206 206
207static void safe_read_bulk_callback (struct urb *urb, struct pt_regs *regs) 207static void safe_read_bulk_callback (struct urb *urb)
208{ 208{
209 struct usb_serial_port *port = (struct usb_serial_port *) urb->context; 209 struct usb_serial_port *port = (struct usb_serial_port *) urb->context;
210 unsigned char *data = urb->transfer_buffer; 210 unsigned char *data = urb->transfer_buffer;
diff --git a/drivers/usb/serial/sierra.c b/drivers/usb/serial/sierra.c
index d29638daa987..4b5097fa48d7 100644
--- a/drivers/usb/serial/sierra.c
+++ b/drivers/usb/serial/sierra.c
@@ -1,75 +1,713 @@
1/* 1/*
2 * Sierra Wireless CDMA Wireless Serial USB driver 2 USB Driver for Sierra Wireless
3 * 3
4 * Current Copy modified by: Kevin Lloyd <linux@sierrawireless.com> 4 Copyright (C) 2006 Kevin Lloyd <linux@sierrawireless.com>
5 * Original Copyright (C) 2005-2006 Greg Kroah-Hartman <gregkh@suse.de> 5
6 * 6 IMPORTANT DISCLAIMER: This driver is not commercially supported by
7 * This program is free software; you can redistribute it and/or 7 Sierra Wireless. Use at your own risk.
8 * modify it under the terms of the GNU General Public License version 8
9 * 2 as published by the Free Software Foundation. 9 This driver is free software; you can redistribute it and/or modify
10 */ 10 it under the terms of Version 2 of the GNU General Public License as
11 published by the Free Software Foundation.
12
13 Portions based on the option driver by Matthias Urlichs <smurf@smurf.noris.de>
14 Whom based his on the Keyspan driver by Hugh Blemings <hugh@blemings.org>
15
16 History:
17*/
18
19#define DRIVER_VERSION "v.1.0.5"
20#define DRIVER_AUTHOR "Kevin Lloyd <linux@sierrawireless.com>"
21#define DRIVER_DESC "USB Driver for Sierra Wireless USB modems"
11 22
12#include <linux/kernel.h> 23#include <linux/kernel.h>
13#include <linux/init.h> 24#include <linux/jiffies.h>
25#include <linux/errno.h>
14#include <linux/tty.h> 26#include <linux/tty.h>
27#include <linux/tty_flip.h>
15#include <linux/module.h> 28#include <linux/module.h>
16#include <linux/usb.h> 29#include <linux/usb.h>
17#include <linux/usb/serial.h> 30#include <linux/usb/serial.h>
18 31
32
19static struct usb_device_id id_table [] = { 33static struct usb_device_id id_table [] = {
20 { USB_DEVICE(0x1199, 0x0018) }, /* Sierra Wireless MC5720 */ 34 { USB_DEVICE(0x1199, 0x0018) }, /* Sierra Wireless MC5720 */
21 { USB_DEVICE(0x1199, 0x0020) }, /* Sierra Wireless MC5725 */ 35 { USB_DEVICE(0x1199, 0x0020) }, /* Sierra Wireless MC5725 */
22 { USB_DEVICE(0x1199, 0x0017) }, /* Sierra Wireless EM5625 */ 36 { USB_DEVICE(0x1199, 0x0017) }, /* Sierra Wireless EM5625 */
23 { USB_DEVICE(0x1199, 0x0019) }, /* Sierra Wireless AirCard 595 */ 37 { USB_DEVICE(0x1199, 0x0019) }, /* Sierra Wireless AirCard 595 */
38 { USB_DEVICE(0x1199, 0x0218) }, /* Sierra Wireless MC5720 */
24 { USB_DEVICE(0x1199, 0x6802) }, /* Sierra Wireless MC8755 */ 39 { USB_DEVICE(0x1199, 0x6802) }, /* Sierra Wireless MC8755 */
25 { USB_DEVICE(0x1199, 0x6803) }, /* Sierra Wireless MC8765 */ 40 { USB_DEVICE(0x1199, 0x6803) }, /* Sierra Wireless MC8765 */
41 { USB_DEVICE(0x1199, 0x6804) }, /* Sierra Wireless MC8755 for Europe */
26 { USB_DEVICE(0x1199, 0x6812) }, /* Sierra Wireless MC8775 */ 42 { USB_DEVICE(0x1199, 0x6812) }, /* Sierra Wireless MC8775 */
27 { USB_DEVICE(0x1199, 0x6820) }, /* Sierra Wireless AirCard 875 */ 43 { USB_DEVICE(0x1199, 0x6820) }, /* Sierra Wireless AirCard 875 */
28 /* Following devices are supported in the airprime.c driver */ 44
29 /* { USB_DEVICE(0x1199, 0x0112) }, */ /* Sierra Wireless AirCard 580 */ 45 { USB_DEVICE(0x1199, 0x0112) }, /* Sierra Wireless AirCard 580 */
30 /* { USB_DEVICE(0x0F3D, 0x0112) }, */ /* AirPrime/Sierra PC 5220 */ 46 { USB_DEVICE(0x0F3D, 0x0112) }, /* AirPrime/Sierra PC 5220 */
31 { } 47 { }
32}; 48};
33MODULE_DEVICE_TABLE(usb, id_table); 49MODULE_DEVICE_TABLE(usb, id_table);
34 50
51static struct usb_device_id id_table_1port [] = {
52 { USB_DEVICE(0x1199, 0x0112) }, /* Sierra Wireless AirCard 580 */
53 { USB_DEVICE(0x0F3D, 0x0112) }, /* AirPrime/Sierra PC 5220 */
54 { }
55};
56
57static struct usb_device_id id_table_3port [] = {
58 { USB_DEVICE(0x1199, 0x0018) }, /* Sierra Wireless MC5720 */
59 { USB_DEVICE(0x1199, 0x0020) }, /* Sierra Wireless MC5725 */
60 { USB_DEVICE(0x1199, 0x0017) }, /* Sierra Wireless EM5625 */
61 { USB_DEVICE(0x1199, 0x0019) }, /* Sierra Wireless AirCard 595 */
62 { USB_DEVICE(0x1199, 0x0218) }, /* Sierra Wireless MC5720 */
63 { USB_DEVICE(0x1199, 0x6802) }, /* Sierra Wireless MC8755 */
64 { USB_DEVICE(0x1199, 0x6803) }, /* Sierra Wireless MC8765 */
65 { USB_DEVICE(0x1199, 0x6804) }, /* Sierra Wireless MC8755 for Europe */
66 { USB_DEVICE(0x1199, 0x6812) }, /* Sierra Wireless MC8775 */
67 { USB_DEVICE(0x1199, 0x6820) }, /* Sierra Wireless AirCard 875 */
68 { }
69};
70
35static struct usb_driver sierra_driver = { 71static struct usb_driver sierra_driver = {
36 .name = "sierra_wireless", 72 .name = "sierra",
37 .probe = usb_serial_probe, 73 .probe = usb_serial_probe,
38 .disconnect = usb_serial_disconnect, 74 .disconnect = usb_serial_disconnect,
39 .id_table = id_table, 75 .id_table = id_table,
76 .no_dynamic_id = 1,
77};
78
79
80static int debug;
81
82/* per port private data */
83#define N_IN_URB 4
84#define N_OUT_URB 1
85#define IN_BUFLEN 4096
86#define OUT_BUFLEN 128
87
88struct sierra_port_private {
89 /* Input endpoints and buffer for this port */
90 struct urb *in_urbs[N_IN_URB];
91 char in_buffer[N_IN_URB][IN_BUFLEN];
92 /* Output endpoints and buffer for this port */
93 struct urb *out_urbs[N_OUT_URB];
94 char out_buffer[N_OUT_URB][OUT_BUFLEN];
95
96 /* Settings for the port */
97 int rts_state; /* Handshaking pins (outputs) */
98 int dtr_state;
99 int cts_state; /* Handshaking pins (inputs) */
100 int dsr_state;
101 int dcd_state;
102 int ri_state;
103
104 unsigned long tx_start_time[N_OUT_URB];
105};
106
107static int sierra_send_setup(struct usb_serial_port *port)
108{
109 struct usb_serial *serial = port->serial;
110 struct sierra_port_private *portdata;
111
112 dbg("%s", __FUNCTION__);
113
114 portdata = usb_get_serial_port_data(port);
115
116 if (port->tty) {
117 int val = 0;
118 if (portdata->dtr_state)
119 val |= 0x01;
120 if (portdata->rts_state)
121 val |= 0x02;
122
123 return usb_control_msg(serial->dev,
124 usb_rcvctrlpipe(serial->dev, 0),
125 0x22,0x21,val,0,NULL,0,USB_CTRL_SET_TIMEOUT);
126 }
127
128 return 0;
129}
130
131static void sierra_rx_throttle(struct usb_serial_port *port)
132{
133 dbg("%s", __FUNCTION__);
134}
135
136static void sierra_rx_unthrottle(struct usb_serial_port *port)
137{
138 dbg("%s", __FUNCTION__);
139}
140
141static void sierra_break_ctl(struct usb_serial_port *port, int break_state)
142{
143 /* Unfortunately, I don't know how to send a break */
144 dbg("%s", __FUNCTION__);
145}
146
147static void sierra_set_termios(struct usb_serial_port *port,
148 struct termios *old_termios)
149{
150 dbg("%s", __FUNCTION__);
151
152 sierra_send_setup(port);
153}
154
155static int sierra_tiocmget(struct usb_serial_port *port, struct file *file)
156{
157 unsigned int value;
158 struct sierra_port_private *portdata;
159
160 portdata = usb_get_serial_port_data(port);
161
162 value = ((portdata->rts_state) ? TIOCM_RTS : 0) |
163 ((portdata->dtr_state) ? TIOCM_DTR : 0) |
164 ((portdata->cts_state) ? TIOCM_CTS : 0) |
165 ((portdata->dsr_state) ? TIOCM_DSR : 0) |
166 ((portdata->dcd_state) ? TIOCM_CAR : 0) |
167 ((portdata->ri_state) ? TIOCM_RNG : 0);
168
169 return value;
170}
171
172static int sierra_tiocmset(struct usb_serial_port *port, struct file *file,
173 unsigned int set, unsigned int clear)
174{
175 struct sierra_port_private *portdata;
176
177 portdata = usb_get_serial_port_data(port);
178
179 if (set & TIOCM_RTS)
180 portdata->rts_state = 1;
181 if (set & TIOCM_DTR)
182 portdata->dtr_state = 1;
183
184 if (clear & TIOCM_RTS)
185 portdata->rts_state = 0;
186 if (clear & TIOCM_DTR)
187 portdata->dtr_state = 0;
188 return sierra_send_setup(port);
189}
190
191static int sierra_ioctl(struct usb_serial_port *port, struct file *file,
192 unsigned int cmd, unsigned long arg)
193{
194 return -ENOIOCTLCMD;
195}
196
197/* Write */
198static int sierra_write(struct usb_serial_port *port,
199 const unsigned char *buf, int count)
200{
201 struct sierra_port_private *portdata;
202 int i;
203 int left, todo;
204 struct urb *this_urb = NULL; /* spurious */
205 int err;
206
207 portdata = usb_get_serial_port_data(port);
208
209 dbg("%s: write (%d chars)", __FUNCTION__, count);
210
211 i = 0;
212 left = count;
213 for (i=0; left > 0 && i < N_OUT_URB; i++) {
214 todo = left;
215 if (todo > OUT_BUFLEN)
216 todo = OUT_BUFLEN;
217
218 this_urb = portdata->out_urbs[i];
219 if (this_urb->status == -EINPROGRESS) {
220 if (time_before(jiffies,
221 portdata->tx_start_time[i] + 10 * HZ))
222 continue;
223 usb_unlink_urb(this_urb);
224 continue;
225 }
226 if (this_urb->status != 0)
227 dbg("usb_write %p failed (err=%d)",
228 this_urb, this_urb->status);
229
230 dbg("%s: endpoint %d buf %d", __FUNCTION__,
231 usb_pipeendpoint(this_urb->pipe), i);
232
233 /* send the data */
234 memcpy (this_urb->transfer_buffer, buf, todo);
235 this_urb->transfer_buffer_length = todo;
236
237 this_urb->dev = port->serial->dev;
238 err = usb_submit_urb(this_urb, GFP_ATOMIC);
239 if (err) {
240 dbg("usb_submit_urb %p (write bulk) failed "
241 "(%d, has %d)", this_urb,
242 err, this_urb->status);
243 continue;
244 }
245 portdata->tx_start_time[i] = jiffies;
246 buf += todo;
247 left -= todo;
248 }
249
250 count -= left;
251 dbg("%s: wrote (did %d)", __FUNCTION__, count);
252 return count;
253}
254
255static void sierra_indat_callback(struct urb *urb)
256{
257 int err;
258 int endpoint;
259 struct usb_serial_port *port;
260 struct tty_struct *tty;
261 unsigned char *data = urb->transfer_buffer;
262
263 dbg("%s: %p", __FUNCTION__, urb);
264
265 endpoint = usb_pipeendpoint(urb->pipe);
266 port = (struct usb_serial_port *) urb->context;
267
268 if (urb->status) {
269 dbg("%s: nonzero status: %d on endpoint %02x.",
270 __FUNCTION__, urb->status, endpoint);
271 } else {
272 tty = port->tty;
273 if (urb->actual_length) {
274 tty_buffer_request_room(tty, urb->actual_length);
275 tty_insert_flip_string(tty, data, urb->actual_length);
276 tty_flip_buffer_push(tty);
277 } else {
278 dbg("%s: empty read urb received", __FUNCTION__);
279 }
280
281 /* Resubmit urb so we continue receiving */
282 if (port->open_count && urb->status != -ESHUTDOWN) {
283 err = usb_submit_urb(urb, GFP_ATOMIC);
284 if (err)
285 printk(KERN_ERR "%s: resubmit read urb failed. "
286 "(%d)", __FUNCTION__, err);
287 }
288 }
289 return;
290}
291
292static void sierra_outdat_callback(struct urb *urb)
293{
294 struct usb_serial_port *port;
295
296 dbg("%s", __FUNCTION__);
297
298 port = (struct usb_serial_port *) urb->context;
299
300 usb_serial_port_softint(port);
301}
302
303static void sierra_instat_callback(struct urb *urb)
304{
305 int err;
306 struct usb_serial_port *port = (struct usb_serial_port *) urb->context;
307 struct sierra_port_private *portdata = usb_get_serial_port_data(port);
308 struct usb_serial *serial = port->serial;
309
310 dbg("%s", __FUNCTION__);
311 dbg("%s: urb %p port %p has data %p", __FUNCTION__,urb,port,portdata);
312
313 if (urb->status == 0) {
314 struct usb_ctrlrequest *req_pkt =
315 (struct usb_ctrlrequest *)urb->transfer_buffer;
316
317 if (!req_pkt) {
318 dbg("%s: NULL req_pkt\n", __FUNCTION__);
319 return;
320 }
321 if ((req_pkt->bRequestType == 0xA1) &&
322 (req_pkt->bRequest == 0x20)) {
323 int old_dcd_state;
324 unsigned char signals = *((unsigned char *)
325 urb->transfer_buffer +
326 sizeof(struct usb_ctrlrequest));
327
328 dbg("%s: signal x%x", __FUNCTION__, signals);
329
330 old_dcd_state = portdata->dcd_state;
331 portdata->cts_state = 1;
332 portdata->dcd_state = ((signals & 0x01) ? 1 : 0);
333 portdata->dsr_state = ((signals & 0x02) ? 1 : 0);
334 portdata->ri_state = ((signals & 0x08) ? 1 : 0);
335
336 if (port->tty && !C_CLOCAL(port->tty) &&
337 old_dcd_state && !portdata->dcd_state)
338 tty_hangup(port->tty);
339 } else {
340 dbg("%s: type %x req %x", __FUNCTION__,
341 req_pkt->bRequestType,req_pkt->bRequest);
342 }
343 } else
344 dbg("%s: error %d", __FUNCTION__, urb->status);
345
346 /* Resubmit urb so we continue receiving IRQ data */
347 if (urb->status != -ESHUTDOWN) {
348 urb->dev = serial->dev;
349 err = usb_submit_urb(urb, GFP_ATOMIC);
350 if (err)
351 dbg("%s: resubmit intr urb failed. (%d)",
352 __FUNCTION__, err);
353 }
354}
355
356static int sierra_write_room(struct usb_serial_port *port)
357{
358 struct sierra_port_private *portdata;
359 int i;
360 int data_len = 0;
361 struct urb *this_urb;
362
363 portdata = usb_get_serial_port_data(port);
364
365 for (i=0; i < N_OUT_URB; i++) {
366 this_urb = portdata->out_urbs[i];
367 if (this_urb && this_urb->status != -EINPROGRESS)
368 data_len += OUT_BUFLEN;
369 }
370
371 dbg("%s: %d", __FUNCTION__, data_len);
372 return data_len;
373}
374
375static int sierra_chars_in_buffer(struct usb_serial_port *port)
376{
377 struct sierra_port_private *portdata;
378 int i;
379 int data_len = 0;
380 struct urb *this_urb;
381
382 portdata = usb_get_serial_port_data(port);
383
384 for (i=0; i < N_OUT_URB; i++) {
385 this_urb = portdata->out_urbs[i];
386 if (this_urb && this_urb->status == -EINPROGRESS)
387 data_len += this_urb->transfer_buffer_length;
388 }
389 dbg("%s: %d", __FUNCTION__, data_len);
390 return data_len;
391}
392
393static int sierra_open(struct usb_serial_port *port, struct file *filp)
394{
395 struct sierra_port_private *portdata;
396 struct usb_serial *serial = port->serial;
397 int i, err;
398 struct urb *urb;
399
400 portdata = usb_get_serial_port_data(port);
401
402 dbg("%s", __FUNCTION__);
403
404 /* Set some sane defaults */
405 portdata->rts_state = 1;
406 portdata->dtr_state = 1;
407
408 /* Reset low level data toggle and start reading from endpoints */
409 for (i = 0; i < N_IN_URB; i++) {
410 urb = portdata->in_urbs[i];
411 if (! urb)
412 continue;
413 if (urb->dev != serial->dev) {
414 dbg("%s: dev %p != %p", __FUNCTION__,
415 urb->dev, serial->dev);
416 continue;
417 }
418
419 /*
420 * make sure endpoint data toggle is synchronized with the
421 * device
422 */
423 usb_clear_halt(urb->dev, urb->pipe);
424
425 err = usb_submit_urb(urb, GFP_KERNEL);
426 if (err) {
427 dbg("%s: submit urb %d failed (%d) %d",
428 __FUNCTION__, i, err,
429 urb->transfer_buffer_length);
430 }
431 }
432
433 /* Reset low level data toggle on out endpoints */
434 for (i = 0; i < N_OUT_URB; i++) {
435 urb = portdata->out_urbs[i];
436 if (! urb)
437 continue;
438 urb->dev = serial->dev;
439 /* usb_settoggle(urb->dev, usb_pipeendpoint(urb->pipe),
440 usb_pipeout(urb->pipe), 0); */
441 }
442
443 port->tty->low_latency = 1;
444
445 sierra_send_setup(port);
446
447 return (0);
448}
449
450static inline void stop_urb(struct urb *urb)
451{
452 if (urb && urb->status == -EINPROGRESS)
453 usb_kill_urb(urb);
454}
455
456static void sierra_close(struct usb_serial_port *port, struct file *filp)
457{
458 int i;
459 struct usb_serial *serial = port->serial;
460 struct sierra_port_private *portdata;
461
462 dbg("%s", __FUNCTION__);
463 portdata = usb_get_serial_port_data(port);
464
465 portdata->rts_state = 0;
466 portdata->dtr_state = 0;
467
468 if (serial->dev) {
469 sierra_send_setup(port);
470
471 /* Stop reading/writing urbs */
472 for (i = 0; i < N_IN_URB; i++)
473 stop_urb(portdata->in_urbs[i]);
474 for (i = 0; i < N_OUT_URB; i++)
475 stop_urb(portdata->out_urbs[i]);
476 }
477 port->tty = NULL;
478}
479
480/* Helper functions used by sierra_setup_urbs */
481static struct urb *sierra_setup_urb(struct usb_serial *serial, int endpoint,
482 int dir, void *ctx, char *buf, int len,
483 usb_complete_t callback)
484{
485 struct urb *urb;
486
487 if (endpoint == -1)
488 return NULL; /* endpoint not needed */
489
490 urb = usb_alloc_urb(0, GFP_KERNEL); /* No ISO */
491 if (urb == NULL) {
492 dbg("%s: alloc for endpoint %d failed.", __FUNCTION__, endpoint);
493 return NULL;
494 }
495
496 /* Fill URB using supplied data. */
497 usb_fill_bulk_urb(urb, serial->dev,
498 usb_sndbulkpipe(serial->dev, endpoint) | dir,
499 buf, len, callback, ctx);
500
501 return urb;
502}
503
504/* Setup urbs */
505static void sierra_setup_urbs(struct usb_serial *serial)
506{
507 int i,j;
508 struct usb_serial_port *port;
509 struct sierra_port_private *portdata;
510
511 dbg("%s", __FUNCTION__);
512
513 for (i = 0; i < serial->num_ports; i++) {
514 port = serial->port[i];
515 portdata = usb_get_serial_port_data(port);
516
517 /* Do indat endpoints first */
518 for (j = 0; j < N_IN_URB; ++j) {
519 portdata->in_urbs[j] = sierra_setup_urb (serial,
520 port->bulk_in_endpointAddress, USB_DIR_IN, port,
521 portdata->in_buffer[j], IN_BUFLEN, sierra_indat_callback);
522 }
523
524 /* outdat endpoints */
525 for (j = 0; j < N_OUT_URB; ++j) {
526 portdata->out_urbs[j] = sierra_setup_urb (serial,
527 port->bulk_out_endpointAddress, USB_DIR_OUT, port,
528 portdata->out_buffer[j], OUT_BUFLEN, sierra_outdat_callback);
529 }
530 }
531}
532
533static int sierra_startup(struct usb_serial *serial)
534{
535 int i, err;
536 struct usb_serial_port *port;
537 struct sierra_port_private *portdata;
538
539 dbg("%s", __FUNCTION__);
540
541 /* Now setup per port private data */
542 for (i = 0; i < serial->num_ports; i++) {
543 port = serial->port[i];
544 portdata = kzalloc(sizeof(*portdata), GFP_KERNEL);
545 if (!portdata) {
546 dbg("%s: kmalloc for sierra_port_private (%d) failed!.",
547 __FUNCTION__, i);
548 return (1);
549 }
550
551 usb_set_serial_port_data(port, portdata);
552
553 if (! port->interrupt_in_urb)
554 continue;
555 err = usb_submit_urb(port->interrupt_in_urb, GFP_KERNEL);
556 if (err)
557 dbg("%s: submit irq_in urb failed %d",
558 __FUNCTION__, err);
559 }
560
561 sierra_setup_urbs(serial);
562
563 return (0);
564}
565
566static void sierra_shutdown(struct usb_serial *serial)
567{
568 int i, j;
569 struct usb_serial_port *port;
570 struct sierra_port_private *portdata;
571
572 dbg("%s", __FUNCTION__);
573
574 /* Stop reading/writing urbs */
575 for (i = 0; i < serial->num_ports; ++i) {
576 port = serial->port[i];
577 portdata = usb_get_serial_port_data(port);
578 for (j = 0; j < N_IN_URB; j++)
579 stop_urb(portdata->in_urbs[j]);
580 for (j = 0; j < N_OUT_URB; j++)
581 stop_urb(portdata->out_urbs[j]);
582 }
583
584 /* Now free them */
585 for (i = 0; i < serial->num_ports; ++i) {
586 port = serial->port[i];
587 portdata = usb_get_serial_port_data(port);
588
589 for (j = 0; j < N_IN_URB; j++) {
590 if (portdata->in_urbs[j]) {
591 usb_free_urb(portdata->in_urbs[j]);
592 portdata->in_urbs[j] = NULL;
593 }
594 }
595 for (j = 0; j < N_OUT_URB; j++) {
596 if (portdata->out_urbs[j]) {
597 usb_free_urb(portdata->out_urbs[j]);
598 portdata->out_urbs[j] = NULL;
599 }
600 }
601 }
602
603 /* Now free per port private data */
604 for (i = 0; i < serial->num_ports; i++) {
605 port = serial->port[i];
606 kfree(usb_get_serial_port_data(port));
607 }
608}
609
610static struct usb_serial_driver sierra_1port_device = {
611 .driver = {
612 .owner = THIS_MODULE,
613 .name = "sierra1",
614 },
615 .description = "Sierra USB modem (1 port)",
616 .id_table = id_table_1port,
617 .num_interrupt_in = NUM_DONT_CARE,
618 .num_bulk_in = 1,
619 .num_bulk_out = 1,
620 .num_ports = 1,
621 .open = sierra_open,
622 .close = sierra_close,
623 .write = sierra_write,
624 .write_room = sierra_write_room,
625 .chars_in_buffer = sierra_chars_in_buffer,
626 .throttle = sierra_rx_throttle,
627 .unthrottle = sierra_rx_unthrottle,
628 .ioctl = sierra_ioctl,
629 .set_termios = sierra_set_termios,
630 .break_ctl = sierra_break_ctl,
631 .tiocmget = sierra_tiocmget,
632 .tiocmset = sierra_tiocmset,
633 .attach = sierra_startup,
634 .shutdown = sierra_shutdown,
635 .read_int_callback = sierra_instat_callback,
40}; 636};
41 637
42static struct usb_serial_driver sierra_device = { 638static struct usb_serial_driver sierra_3port_device = {
43 .driver = { 639 .driver = {
44 .owner = THIS_MODULE, 640 .owner = THIS_MODULE,
45 .name = "Sierra_Wireless", 641 .name = "sierra3",
46 }, 642 },
47 .id_table = id_table, 643 .description = "Sierra USB modem (3 port)",
48 .num_interrupt_in = NUM_DONT_CARE, 644 .id_table = id_table_3port,
49 .num_bulk_in = NUM_DONT_CARE, 645 .num_interrupt_in = NUM_DONT_CARE,
50 .num_bulk_out = NUM_DONT_CARE, 646 .num_bulk_in = 3,
51 .num_ports = 3, 647 .num_bulk_out = 3,
648 .num_ports = 3,
649 .open = sierra_open,
650 .close = sierra_close,
651 .write = sierra_write,
652 .write_room = sierra_write_room,
653 .chars_in_buffer = sierra_chars_in_buffer,
654 .throttle = sierra_rx_throttle,
655 .unthrottle = sierra_rx_unthrottle,
656 .ioctl = sierra_ioctl,
657 .set_termios = sierra_set_termios,
658 .break_ctl = sierra_break_ctl,
659 .tiocmget = sierra_tiocmget,
660 .tiocmset = sierra_tiocmset,
661 .attach = sierra_startup,
662 .shutdown = sierra_shutdown,
663 .read_int_callback = sierra_instat_callback,
52}; 664};
53 665
666/* Functions used by new usb-serial code. */
54static int __init sierra_init(void) 667static int __init sierra_init(void)
55{ 668{
56 int retval; 669 int retval;
57 670 retval = usb_serial_register(&sierra_1port_device);
58 retval = usb_serial_register(&sierra_device); 671 if (retval)
672 goto failed_1port_device_register;
673 retval = usb_serial_register(&sierra_3port_device);
59 if (retval) 674 if (retval)
60 return retval; 675 goto failed_3port_device_register;
676
677
61 retval = usb_register(&sierra_driver); 678 retval = usb_register(&sierra_driver);
62 if (retval) 679 if (retval)
63 usb_serial_deregister(&sierra_device); 680 goto failed_driver_register;
681
682 info(DRIVER_DESC ": " DRIVER_VERSION);
683
684 return 0;
685
686failed_driver_register:
687 usb_serial_deregister(&sierra_3port_device);
688failed_3port_device_register:
689 usb_serial_deregister(&sierra_1port_device);
690failed_1port_device_register:
64 return retval; 691 return retval;
65} 692}
66 693
67static void __exit sierra_exit(void) 694static void __exit sierra_exit(void)
68{ 695{
69 usb_deregister(&sierra_driver); 696 usb_deregister (&sierra_driver);
70 usb_serial_deregister(&sierra_device); 697 usb_serial_deregister(&sierra_1port_device);
698 usb_serial_deregister(&sierra_3port_device);
71} 699}
72 700
73module_init(sierra_init); 701module_init(sierra_init);
74module_exit(sierra_exit); 702module_exit(sierra_exit);
703
704MODULE_AUTHOR(DRIVER_AUTHOR);
705MODULE_DESCRIPTION(DRIVER_DESC);
706MODULE_VERSION(DRIVER_VERSION);
75MODULE_LICENSE("GPL"); 707MODULE_LICENSE("GPL");
708
709#ifdef CONFIG_USB_DEBUG
710module_param(debug, bool, S_IRUGO | S_IWUSR);
711MODULE_PARM_DESC(debug, "Debug messages");
712#endif
713
diff --git a/drivers/usb/serial/ti_usb_3410_5052.c b/drivers/usb/serial/ti_usb_3410_5052.c
index ac9b8ee52d44..07400c0c8a8c 100644
--- a/drivers/usb/serial/ti_usb_3410_5052.c
+++ b/drivers/usb/serial/ti_usb_3410_5052.c
@@ -166,9 +166,9 @@ static int ti_tiocmget(struct usb_serial_port *port, struct file *file);
166static int ti_tiocmset(struct usb_serial_port *port, struct file *file, 166static int ti_tiocmset(struct usb_serial_port *port, struct file *file,
167 unsigned int set, unsigned int clear); 167 unsigned int set, unsigned int clear);
168static void ti_break(struct usb_serial_port *port, int break_state); 168static void ti_break(struct usb_serial_port *port, int break_state);
169static void ti_interrupt_callback(struct urb *urb, struct pt_regs *regs); 169static void ti_interrupt_callback(struct urb *urb);
170static void ti_bulk_in_callback(struct urb *urb, struct pt_regs *regs); 170static void ti_bulk_in_callback(struct urb *urb);
171static void ti_bulk_out_callback(struct urb *urb, struct pt_regs *regs); 171static void ti_bulk_out_callback(struct urb *urb);
172 172
173static void ti_recv(struct device *dev, struct tty_struct *tty, 173static void ti_recv(struct device *dev, struct tty_struct *tty,
174 unsigned char *data, int length); 174 unsigned char *data, int length);
@@ -1098,7 +1098,7 @@ static void ti_break(struct usb_serial_port *port, int break_state)
1098} 1098}
1099 1099
1100 1100
1101static void ti_interrupt_callback(struct urb *urb, struct pt_regs *regs) 1101static void ti_interrupt_callback(struct urb *urb)
1102{ 1102{
1103 struct ti_device *tdev = (struct ti_device *)urb->context; 1103 struct ti_device *tdev = (struct ti_device *)urb->context;
1104 struct usb_serial_port *port; 1104 struct usb_serial_port *port;
@@ -1178,7 +1178,7 @@ exit:
1178} 1178}
1179 1179
1180 1180
1181static void ti_bulk_in_callback(struct urb *urb, struct pt_regs *regs) 1181static void ti_bulk_in_callback(struct urb *urb)
1182{ 1182{
1183 struct ti_port *tport = (struct ti_port *)urb->context; 1183 struct ti_port *tport = (struct ti_port *)urb->context;
1184 struct usb_serial_port *port = tport->tp_port; 1184 struct usb_serial_port *port = tport->tp_port;
@@ -1241,7 +1241,7 @@ exit:
1241} 1241}
1242 1242
1243 1243
1244static void ti_bulk_out_callback(struct urb *urb, struct pt_regs *regs) 1244static void ti_bulk_out_callback(struct urb *urb)
1245{ 1245{
1246 struct ti_port *tport = (struct ti_port *)urb->context; 1246 struct ti_port *tport = (struct ti_port *)urb->context;
1247 struct usb_serial_port *port = tport->tp_port; 1247 struct usb_serial_port *port = tport->tp_port;
diff --git a/drivers/usb/serial/visor.c b/drivers/usb/serial/visor.c
index 88949f7884ca..befe2e11a041 100644
--- a/drivers/usb/serial/visor.c
+++ b/drivers/usb/serial/visor.c
@@ -47,9 +47,9 @@ static int visor_calc_num_ports(struct usb_serial *serial);
47static void visor_shutdown (struct usb_serial *serial); 47static void visor_shutdown (struct usb_serial *serial);
48static int visor_ioctl (struct usb_serial_port *port, struct file * file, unsigned int cmd, unsigned long arg); 48static int visor_ioctl (struct usb_serial_port *port, struct file * file, unsigned int cmd, unsigned long arg);
49static void visor_set_termios (struct usb_serial_port *port, struct termios *old_termios); 49static void visor_set_termios (struct usb_serial_port *port, struct termios *old_termios);
50static void visor_write_bulk_callback (struct urb *urb, struct pt_regs *regs); 50static void visor_write_bulk_callback (struct urb *urb);
51static void visor_read_bulk_callback (struct urb *urb, struct pt_regs *regs); 51static void visor_read_bulk_callback (struct urb *urb);
52static void visor_read_int_callback (struct urb *urb, struct pt_regs *regs); 52static void visor_read_int_callback (struct urb *urb);
53static int clie_3_5_startup (struct usb_serial *serial); 53static int clie_3_5_startup (struct usb_serial *serial);
54static int treo_attach (struct usb_serial *serial); 54static int treo_attach (struct usb_serial *serial);
55static int clie_5_attach (struct usb_serial *serial); 55static int clie_5_attach (struct usb_serial *serial);
@@ -471,7 +471,7 @@ static int visor_chars_in_buffer (struct usb_serial_port *port)
471} 471}
472 472
473 473
474static void visor_write_bulk_callback (struct urb *urb, struct pt_regs *regs) 474static void visor_write_bulk_callback (struct urb *urb)
475{ 475{
476 struct usb_serial_port *port = (struct usb_serial_port *)urb->context; 476 struct usb_serial_port *port = (struct usb_serial_port *)urb->context;
477 struct visor_private *priv = usb_get_serial_port_data(port); 477 struct visor_private *priv = usb_get_serial_port_data(port);
@@ -494,7 +494,7 @@ static void visor_write_bulk_callback (struct urb *urb, struct pt_regs *regs)
494} 494}
495 495
496 496
497static void visor_read_bulk_callback (struct urb *urb, struct pt_regs *regs) 497static void visor_read_bulk_callback (struct urb *urb)
498{ 498{
499 struct usb_serial_port *port = (struct usb_serial_port *)urb->context; 499 struct usb_serial_port *port = (struct usb_serial_port *)urb->context;
500 struct visor_private *priv = usb_get_serial_port_data(port); 500 struct visor_private *priv = usb_get_serial_port_data(port);
@@ -539,7 +539,7 @@ static void visor_read_bulk_callback (struct urb *urb, struct pt_regs *regs)
539 return; 539 return;
540} 540}
541 541
542static void visor_read_int_callback (struct urb *urb, struct pt_regs *regs) 542static void visor_read_int_callback (struct urb *urb)
543{ 543{
544 struct usb_serial_port *port = (struct usb_serial_port *)urb->context; 544 struct usb_serial_port *port = (struct usb_serial_port *)urb->context;
545 int result; 545 int result;
diff --git a/drivers/usb/serial/whiteheat.c b/drivers/usb/serial/whiteheat.c
index 6e6c7934be32..4d1cd7aeccd3 100644
--- a/drivers/usb/serial/whiteheat.c
+++ b/drivers/usb/serial/whiteheat.c
@@ -152,8 +152,8 @@ static void whiteheat_break_ctl (struct usb_serial_port *port, int break_state)
152static int whiteheat_chars_in_buffer (struct usb_serial_port *port); 152static int whiteheat_chars_in_buffer (struct usb_serial_port *port);
153static void whiteheat_throttle (struct usb_serial_port *port); 153static void whiteheat_throttle (struct usb_serial_port *port);
154static void whiteheat_unthrottle (struct usb_serial_port *port); 154static void whiteheat_unthrottle (struct usb_serial_port *port);
155static void whiteheat_read_callback (struct urb *urb, struct pt_regs *regs); 155static void whiteheat_read_callback (struct urb *urb);
156static void whiteheat_write_callback (struct urb *urb, struct pt_regs *regs); 156static void whiteheat_write_callback (struct urb *urb);
157 157
158static struct usb_serial_driver whiteheat_fake_device = { 158static struct usb_serial_driver whiteheat_fake_device = {
159 .driver = { 159 .driver = {
@@ -235,8 +235,8 @@ struct whiteheat_private {
235/* local function prototypes */ 235/* local function prototypes */
236static int start_command_port(struct usb_serial *serial); 236static int start_command_port(struct usb_serial *serial);
237static void stop_command_port(struct usb_serial *serial); 237static void stop_command_port(struct usb_serial *serial);
238static void command_port_write_callback(struct urb *urb, struct pt_regs *regs); 238static void command_port_write_callback(struct urb *urb);
239static void command_port_read_callback(struct urb *urb, struct pt_regs *regs); 239static void command_port_read_callback(struct urb *urb);
240 240
241static int start_port_read(struct usb_serial_port *port); 241static int start_port_read(struct usb_serial_port *port);
242static struct whiteheat_urb_wrap *urb_to_wrap(struct urb *urb, struct list_head *head); 242static struct whiteheat_urb_wrap *urb_to_wrap(struct urb *urb, struct list_head *head);
@@ -958,7 +958,7 @@ static void whiteheat_unthrottle (struct usb_serial_port *port)
958/***************************************************************************** 958/*****************************************************************************
959 * Connect Tech's White Heat callback routines 959 * Connect Tech's White Heat callback routines
960 *****************************************************************************/ 960 *****************************************************************************/
961static void command_port_write_callback (struct urb *urb, struct pt_regs *regs) 961static void command_port_write_callback (struct urb *urb)
962{ 962{
963 dbg("%s", __FUNCTION__); 963 dbg("%s", __FUNCTION__);
964 964
@@ -969,7 +969,7 @@ static void command_port_write_callback (struct urb *urb, struct pt_regs *regs)
969} 969}
970 970
971 971
972static void command_port_read_callback (struct urb *urb, struct pt_regs *regs) 972static void command_port_read_callback (struct urb *urb)
973{ 973{
974 struct usb_serial_port *command_port = (struct usb_serial_port *)urb->context; 974 struct usb_serial_port *command_port = (struct usb_serial_port *)urb->context;
975 struct whiteheat_command_private *command_info; 975 struct whiteheat_command_private *command_info;
@@ -1019,7 +1019,7 @@ static void command_port_read_callback (struct urb *urb, struct pt_regs *regs)
1019} 1019}
1020 1020
1021 1021
1022static void whiteheat_read_callback(struct urb *urb, struct pt_regs *regs) 1022static void whiteheat_read_callback(struct urb *urb)
1023{ 1023{
1024 struct usb_serial_port *port = (struct usb_serial_port *)urb->context; 1024 struct usb_serial_port *port = (struct usb_serial_port *)urb->context;
1025 struct whiteheat_urb_wrap *wrap; 1025 struct whiteheat_urb_wrap *wrap;
@@ -1061,7 +1061,7 @@ static void whiteheat_read_callback(struct urb *urb, struct pt_regs *regs)
1061} 1061}
1062 1062
1063 1063
1064static void whiteheat_write_callback(struct urb *urb, struct pt_regs *regs) 1064static void whiteheat_write_callback(struct urb *urb)
1065{ 1065{
1066 struct usb_serial_port *port = (struct usb_serial_port *)urb->context; 1066 struct usb_serial_port *port = (struct usb_serial_port *)urb->context;
1067 struct whiteheat_private *info = usb_get_serial_port_data(port); 1067 struct whiteheat_private *info = usb_get_serial_port_data(port);
diff --git a/drivers/usb/storage/onetouch.c b/drivers/usb/storage/onetouch.c
index f843a0bcf107..3baf448e300d 100644
--- a/drivers/usb/storage/onetouch.c
+++ b/drivers/usb/storage/onetouch.c
@@ -53,7 +53,7 @@ struct usb_onetouch {
53 unsigned int is_open:1; 53 unsigned int is_open:1;
54}; 54};
55 55
56static void usb_onetouch_irq(struct urb *urb, struct pt_regs *regs) 56static void usb_onetouch_irq(struct urb *urb)
57{ 57{
58 struct usb_onetouch *onetouch = urb->context; 58 struct usb_onetouch *onetouch = urb->context;
59 signed char *data = onetouch->data; 59 signed char *data = onetouch->data;
@@ -72,7 +72,6 @@ static void usb_onetouch_irq(struct urb *urb, struct pt_regs *regs)
72 goto resubmit; 72 goto resubmit;
73 } 73 }
74 74
75 input_regs(dev, regs);
76 input_report_key(dev, ONETOUCH_BUTTON, data[0] & 0x02); 75 input_report_key(dev, ONETOUCH_BUTTON, data[0] & 0x02);
77 input_sync(dev); 76 input_sync(dev);
78 77
diff --git a/drivers/usb/storage/transport.c b/drivers/usb/storage/transport.c
index f23514c4e649..47644b5b6155 100644
--- a/drivers/usb/storage/transport.c
+++ b/drivers/usb/storage/transport.c
@@ -108,7 +108,7 @@
108/* This is the completion handler which will wake us up when an URB 108/* This is the completion handler which will wake us up when an URB
109 * completes. 109 * completes.
110 */ 110 */
111static void usb_stor_blocking_completion(struct urb *urb, struct pt_regs *regs) 111static void usb_stor_blocking_completion(struct urb *urb)
112{ 112{
113 struct completion *urb_done_ptr = (struct completion *)urb->context; 113 struct completion *urb_done_ptr = (struct completion *)urb->context;
114 114
diff --git a/drivers/usb/storage/unusual_devs.h b/drivers/usb/storage/unusual_devs.h
index c9a8d50106d1..efb047f431e8 100644
--- a/drivers/usb/storage/unusual_devs.h
+++ b/drivers/usb/storage/unusual_devs.h
@@ -55,7 +55,8 @@ UNUSUAL_DEV( 0x03eb, 0x2002, 0x0100, 0x0100,
55 US_SC_DEVICE, US_PR_DEVICE, NULL, 55 US_SC_DEVICE, US_PR_DEVICE, NULL,
56 US_FL_IGNORE_RESIDUE), 56 US_FL_IGNORE_RESIDUE),
57 57
58UNUSUAL_DEV( 0x03ee, 0x6901, 0x0000, 0x0100, 58/* modified by Tobias Lorenz <tobias.lorenz@gmx.net> */
59UNUSUAL_DEV( 0x03ee, 0x6901, 0x0000, 0x0200,
59 "Mitsumi", 60 "Mitsumi",
60 "USB FDD", 61 "USB FDD",
61 US_SC_DEVICE, US_PR_DEVICE, NULL, 62 US_SC_DEVICE, US_PR_DEVICE, NULL,
@@ -182,6 +183,20 @@ UNUSUAL_DEV( 0x0421, 0x044e, 0x0100, 0x0100,
182 US_SC_DEVICE, US_PR_DEVICE, NULL, 183 US_SC_DEVICE, US_PR_DEVICE, NULL,
183 US_FL_IGNORE_RESIDUE | US_FL_FIX_CAPACITY ), 184 US_FL_IGNORE_RESIDUE | US_FL_FIX_CAPACITY ),
184 185
186/* Reported by Bardur Arantsson <bardur@scientician.net> */
187UNUSUAL_DEV( 0x0421, 0x047c, 0x0370, 0x0370,
188 "Nokia",
189 "6131",
190 US_SC_DEVICE, US_PR_DEVICE, NULL,
191 US_FL_MAX_SECTORS_64 ),
192
193/* Reported by Alex Corcoles <alex@corcoles.net> */
194UNUSUAL_DEV( 0x0421, 0x0495, 0x0370, 0x0370,
195 "Nokia",
196 "6234",
197 US_SC_DEVICE, US_PR_DEVICE, NULL,
198 US_FL_MAX_SECTORS_64 ),
199
185/* Reported by Olaf Hering <olh@suse.de> from novell bug #105878 */ 200/* Reported by Olaf Hering <olh@suse.de> from novell bug #105878 */
186UNUSUAL_DEV( 0x0424, 0x0fdc, 0x0210, 0x0210, 201UNUSUAL_DEV( 0x0424, 0x0fdc, 0x0210, 0x0210,
187 "SMSC", 202 "SMSC",
@@ -1221,7 +1236,7 @@ UNUSUAL_DEV( 0x0e21, 0x0520, 0x0100, 0x0100,
1221 "Cowon Systems", 1236 "Cowon Systems",
1222 "iAUDIO M5", 1237 "iAUDIO M5",
1223 US_SC_DEVICE, US_PR_BULK, NULL, 1238 US_SC_DEVICE, US_PR_BULK, NULL,
1224 0 ), 1239 US_FL_NEED_OVERRIDE ),
1225 1240
1226/* Submitted by Antoine Mairesse <antoine.mairesse@free.fr> */ 1241/* Submitted by Antoine Mairesse <antoine.mairesse@free.fr> */
1227UNUSUAL_DEV( 0x0ed1, 0x6660, 0x0100, 0x0300, 1242UNUSUAL_DEV( 0x0ed1, 0x6660, 0x0100, 0x0300,
@@ -1294,8 +1309,10 @@ UNUSUAL_DEV( 0x0fce, 0xe030, 0x0000, 0x0000,
1294/* Reported by Kevin Cernekee <kpc-usbdev@gelato.uiuc.edu> 1309/* Reported by Kevin Cernekee <kpc-usbdev@gelato.uiuc.edu>
1295 * Tested on hardware version 1.10. 1310 * Tested on hardware version 1.10.
1296 * Entry is needed only for the initializer function override. 1311 * Entry is needed only for the initializer function override.
1312 * Devices with bcd > 110 seem to not need it while those
1313 * with bcd < 110 appear to need it.
1297 */ 1314 */
1298UNUSUAL_DEV( 0x1019, 0x0c55, 0x0110, 0x0110, 1315UNUSUAL_DEV( 0x1019, 0x0c55, 0x0000, 0x0110,
1299 "Desknote", 1316 "Desknote",
1300 "UCR-61S2B", 1317 "UCR-61S2B",
1301 US_SC_DEVICE, US_PR_DEVICE, usb_stor_ucr61s2b_init, 1318 US_SC_DEVICE, US_PR_DEVICE, usb_stor_ucr61s2b_init,
diff --git a/drivers/usb/usb-skeleton.c b/drivers/usb/usb-skeleton.c
index 1b51d3187a95..296b091cf168 100644
--- a/drivers/usb/usb-skeleton.c
+++ b/drivers/usb/usb-skeleton.c
@@ -158,7 +158,7 @@ exit:
158 return retval; 158 return retval;
159} 159}
160 160
161static void skel_write_bulk_callback(struct urb *urb, struct pt_regs *regs) 161static void skel_write_bulk_callback(struct urb *urb)
162{ 162{
163 struct usb_skel *dev; 163 struct usb_skel *dev;
164 164