diff options
Diffstat (limited to 'drivers/usb/misc')
-rw-r--r-- | drivers/usb/misc/appledisplay.c | 2 | ||||
-rw-r--r-- | drivers/usb/misc/auerswald.c | 10 | ||||
-rw-r--r-- | drivers/usb/misc/ftdi-elan.c | 592 | ||||
-rw-r--r-- | drivers/usb/misc/idmouse.c | 10 | ||||
-rw-r--r-- | drivers/usb/misc/phidgetservo.c | 1 | ||||
-rw-r--r-- | drivers/usb/misc/rio500.c | 54 | ||||
-rw-r--r-- | drivers/usb/misc/sisusbvga/sisusb.c | 2 | ||||
-rw-r--r-- | drivers/usb/misc/sisusbvga/sisusb_con.c | 12 | ||||
-rw-r--r-- | drivers/usb/misc/trancevibrator.c | 2 | ||||
-rw-r--r-- | drivers/usb/misc/uss720.c | 2 |
10 files changed, 442 insertions, 245 deletions
diff --git a/drivers/usb/misc/appledisplay.c b/drivers/usb/misc/appledisplay.c index 02cbb7fff24f..a7932a72d298 100644 --- a/drivers/usb/misc/appledisplay.c +++ b/drivers/usb/misc/appledisplay.c | |||
@@ -281,7 +281,7 @@ static int appledisplay_probe(struct usb_interface *iface, | |||
281 | /* Register backlight device */ | 281 | /* Register backlight device */ |
282 | snprintf(bl_name, sizeof(bl_name), "appledisplay%d", | 282 | snprintf(bl_name, sizeof(bl_name), "appledisplay%d", |
283 | atomic_inc_return(&count_displays) - 1); | 283 | atomic_inc_return(&count_displays) - 1); |
284 | pdata->bd = backlight_device_register(bl_name, pdata, | 284 | pdata->bd = backlight_device_register(bl_name, NULL, NULL, |
285 | &appledisplay_bl_data); | 285 | &appledisplay_bl_data); |
286 | if (IS_ERR(pdata->bd)) { | 286 | if (IS_ERR(pdata->bd)) { |
287 | err("appledisplay: Backlight registration failed"); | 287 | err("appledisplay: Backlight registration failed"); |
diff --git a/drivers/usb/misc/auerswald.c b/drivers/usb/misc/auerswald.c index c703f73e1655..b5332e679c46 100644 --- a/drivers/usb/misc/auerswald.c +++ b/drivers/usb/misc/auerswald.c | |||
@@ -766,7 +766,7 @@ static int auerbuf_setup (pauerbufctl_t bcp, unsigned int numElements, unsigned | |||
766 | bep->bufp = kmalloc (bufsize, GFP_KERNEL); | 766 | bep->bufp = kmalloc (bufsize, GFP_KERNEL); |
767 | if (!bep->bufp) | 767 | if (!bep->bufp) |
768 | goto bl_fail; | 768 | goto bl_fail; |
769 | bep->dr = (struct usb_ctrlrequest *) kmalloc (sizeof (struct usb_ctrlrequest), GFP_KERNEL); | 769 | bep->dr = kmalloc(sizeof (struct usb_ctrlrequest), GFP_KERNEL); |
770 | if (!bep->dr) | 770 | if (!bep->dr) |
771 | goto bl_fail; | 771 | goto bl_fail; |
772 | bep->urbp = usb_alloc_urb (0, GFP_KERNEL); | 772 | bep->urbp = usb_alloc_urb (0, GFP_KERNEL); |
@@ -1376,7 +1376,7 @@ static int auerchar_open (struct inode *inode, struct file *file) | |||
1376 | } | 1376 | } |
1377 | 1377 | ||
1378 | /* we have access to the device. Now lets allocate memory */ | 1378 | /* we have access to the device. Now lets allocate memory */ |
1379 | ccp = (pauerchar_t) kmalloc(sizeof(auerchar_t), GFP_KERNEL); | 1379 | ccp = kzalloc(sizeof(auerchar_t), GFP_KERNEL); |
1380 | if (ccp == NULL) { | 1380 | if (ccp == NULL) { |
1381 | err ("out of memory"); | 1381 | err ("out of memory"); |
1382 | ret = -ENOMEM; | 1382 | ret = -ENOMEM; |
@@ -1384,7 +1384,6 @@ static int auerchar_open (struct inode *inode, struct file *file) | |||
1384 | } | 1384 | } |
1385 | 1385 | ||
1386 | /* Initialize device descriptor */ | 1386 | /* Initialize device descriptor */ |
1387 | memset( ccp, 0, sizeof(auerchar_t)); | ||
1388 | init_MUTEX( &ccp->mutex); | 1387 | init_MUTEX( &ccp->mutex); |
1389 | init_MUTEX( &ccp->readmutex); | 1388 | init_MUTEX( &ccp->readmutex); |
1390 | auerbuf_init (&ccp->bufctl); | 1389 | auerbuf_init (&ccp->bufctl); |
@@ -1912,14 +1911,13 @@ static int auerswald_probe (struct usb_interface *intf, | |||
1912 | return -ENODEV; | 1911 | return -ENODEV; |
1913 | 1912 | ||
1914 | /* allocate memory for our device and initialize it */ | 1913 | /* allocate memory for our device and initialize it */ |
1915 | cp = kmalloc (sizeof(auerswald_t), GFP_KERNEL); | 1914 | cp = kzalloc (sizeof(auerswald_t), GFP_KERNEL); |
1916 | if (cp == NULL) { | 1915 | if (cp == NULL) { |
1917 | err ("out of memory"); | 1916 | err ("out of memory"); |
1918 | goto pfail; | 1917 | goto pfail; |
1919 | } | 1918 | } |
1920 | 1919 | ||
1921 | /* Initialize device descriptor */ | 1920 | /* Initialize device descriptor */ |
1922 | memset (cp, 0, sizeof(auerswald_t)); | ||
1923 | init_MUTEX (&cp->mutex); | 1921 | init_MUTEX (&cp->mutex); |
1924 | cp->usbdev = usbdev; | 1922 | cp->usbdev = usbdev; |
1925 | auerchain_init (&cp->controlchain); | 1923 | auerchain_init (&cp->controlchain); |
@@ -1969,7 +1967,7 @@ static int auerswald_probe (struct usb_interface *intf, | |||
1969 | info("device is a %s", cp->dev_desc); | 1967 | info("device is a %s", cp->dev_desc); |
1970 | 1968 | ||
1971 | /* get the maximum allowed control transfer length */ | 1969 | /* get the maximum allowed control transfer length */ |
1972 | pbuf = (__le16 *) kmalloc (2, GFP_KERNEL); /* use an allocated buffer because of urb target */ | 1970 | pbuf = kmalloc(2, GFP_KERNEL); /* use an allocated buffer because of urb target */ |
1973 | if (!pbuf) { | 1971 | if (!pbuf) { |
1974 | err( "out of memory"); | 1972 | err( "out of memory"); |
1975 | goto pfail; | 1973 | goto pfail; |
diff --git a/drivers/usb/misc/ftdi-elan.c b/drivers/usb/misc/ftdi-elan.c index 18b1925032a8..41c0161abdb9 100644 --- a/drivers/usb/misc/ftdi-elan.c +++ b/drivers/usb/misc/ftdi-elan.c | |||
@@ -40,6 +40,7 @@ | |||
40 | #include <linux/init.h> | 40 | #include <linux/init.h> |
41 | #include <linux/list.h> | 41 | #include <linux/list.h> |
42 | #include <linux/ioctl.h> | 42 | #include <linux/ioctl.h> |
43 | #include <linux/pci_ids.h> | ||
43 | #include <linux/slab.h> | 44 | #include <linux/slab.h> |
44 | #include <linux/module.h> | 45 | #include <linux/module.h> |
45 | #include <linux/kref.h> | 46 | #include <linux/kref.h> |
@@ -51,6 +52,10 @@ MODULE_AUTHOR("Tony Olech"); | |||
51 | MODULE_DESCRIPTION("FTDI ELAN driver"); | 52 | MODULE_DESCRIPTION("FTDI ELAN driver"); |
52 | MODULE_LICENSE("GPL"); | 53 | MODULE_LICENSE("GPL"); |
53 | #define INT_MODULE_PARM(n, v) static int n = v;module_param(n, int, 0444) | 54 | #define INT_MODULE_PARM(n, v) static int n = v;module_param(n, int, 0444) |
55 | static int distrust_firmware = 1; | ||
56 | module_param(distrust_firmware, bool, 0); | ||
57 | MODULE_PARM_DESC(distrust_firmware, "true to distrust firmware power/overcurren" | ||
58 | "t setup"); | ||
54 | extern struct platform_driver u132_platform_driver; | 59 | extern struct platform_driver u132_platform_driver; |
55 | static struct workqueue_struct *status_queue; | 60 | static struct workqueue_struct *status_queue; |
56 | static struct workqueue_struct *command_queue; | 61 | static struct workqueue_struct *command_queue; |
@@ -66,7 +71,9 @@ static struct list_head ftdi_static_list; | |||
66 | * end of the global variables protected by ftdi_module_lock | 71 | * end of the global variables protected by ftdi_module_lock |
67 | */ | 72 | */ |
68 | #include "usb_u132.h" | 73 | #include "usb_u132.h" |
69 | #define TD_DEVNOTRESP 5 | 74 | #include <asm/io.h> |
75 | #include "../core/hcd.h" | ||
76 | #include "../host/ohci.h" | ||
70 | /* Define these values to match your devices*/ | 77 | /* Define these values to match your devices*/ |
71 | #define USB_FTDI_ELAN_VENDOR_ID 0x0403 | 78 | #define USB_FTDI_ELAN_VENDOR_ID 0x0403 |
72 | #define USB_FTDI_ELAN_PRODUCT_ID 0xd6ea | 79 | #define USB_FTDI_ELAN_PRODUCT_ID 0xd6ea |
@@ -551,7 +558,7 @@ static void ftdi_elan_status_work(struct work_struct *work) | |||
551 | } else { | 558 | } else { |
552 | dev_err(&ftdi->udev->dev, "initialized failed - trying " | 559 | dev_err(&ftdi->udev->dev, "initialized failed - trying " |
553 | "again in 10 seconds\n"); | 560 | "again in 10 seconds\n"); |
554 | work_delay_in_msec = 10 *1000; | 561 | work_delay_in_msec = 1 *1000; |
555 | } | 562 | } |
556 | } else if (ftdi->registered == 0) { | 563 | } else if (ftdi->registered == 0) { |
557 | work_delay_in_msec = 10; | 564 | work_delay_in_msec = 10; |
@@ -2288,82 +2295,288 @@ static int ftdi_elan_checkingPCI(struct usb_ftdi *ftdi) | |||
2288 | } | 2295 | } |
2289 | } | 2296 | } |
2290 | 2297 | ||
2291 | static int ftdi_elan_enumeratePCI(struct usb_ftdi *ftdi) | 2298 | |
2299 | #define ftdi_read_pcimem(ftdi, member, data) ftdi_elan_read_pcimem(ftdi, \ | ||
2300 | offsetof(struct ohci_regs, member), 0, data); | ||
2301 | #define ftdi_write_pcimem(ftdi, member, data) ftdi_elan_write_pcimem(ftdi, \ | ||
2302 | offsetof(struct ohci_regs, member), 0, data); | ||
2303 | #define OHCI_QUIRK_AMD756 0x01 | ||
2304 | #define OHCI_QUIRK_SUPERIO 0x02 | ||
2305 | #define OHCI_QUIRK_INITRESET 0x04 | ||
2306 | #define OHCI_BIG_ENDIAN 0x08 | ||
2307 | #define OHCI_QUIRK_ZFMICRO 0x10 | ||
2308 | #define OHCI_CONTROL_INIT OHCI_CTRL_CBSR | ||
2309 | #define OHCI_INTR_INIT (OHCI_INTR_MIE | OHCI_INTR_UE | OHCI_INTR_RD | \ | ||
2310 | OHCI_INTR_WDH) | ||
2311 | static int ftdi_elan_check_controller(struct usb_ftdi *ftdi, int quirk) | ||
2312 | { | ||
2313 | int devices = 0; | ||
2314 | int retval; | ||
2315 | u32 hc_control; | ||
2316 | int num_ports; | ||
2317 | u32 control; | ||
2318 | u32 rh_a = -1; | ||
2319 | u32 status; | ||
2320 | u32 fminterval; | ||
2321 | u32 hc_fminterval; | ||
2322 | u32 periodicstart; | ||
2323 | u32 cmdstatus; | ||
2324 | u32 roothub_a; | ||
2325 | int mask = OHCI_INTR_INIT; | ||
2326 | int sleep_time = 0; | ||
2327 | int reset_timeout = 30; /* ... allow extra time */ | ||
2328 | int temp; | ||
2329 | retval = ftdi_write_pcimem(ftdi, intrdisable, OHCI_INTR_MIE); | ||
2330 | if (retval) | ||
2331 | return retval; | ||
2332 | retval = ftdi_read_pcimem(ftdi, control, &control); | ||
2333 | if (retval) | ||
2334 | return retval; | ||
2335 | retval = ftdi_read_pcimem(ftdi, roothub.a, &rh_a); | ||
2336 | if (retval) | ||
2337 | return retval; | ||
2338 | num_ports = rh_a & RH_A_NDP; | ||
2339 | retval = ftdi_read_pcimem(ftdi, fminterval, &hc_fminterval); | ||
2340 | if (retval) | ||
2341 | return retval; | ||
2342 | hc_fminterval &= 0x3fff; | ||
2343 | if (hc_fminterval != FI) { | ||
2344 | } | ||
2345 | hc_fminterval |= FSMP(hc_fminterval) << 16; | ||
2346 | retval = ftdi_read_pcimem(ftdi, control, &hc_control); | ||
2347 | if (retval) | ||
2348 | return retval; | ||
2349 | switch (hc_control & OHCI_CTRL_HCFS) { | ||
2350 | case OHCI_USB_OPER: | ||
2351 | sleep_time = 0; | ||
2352 | break; | ||
2353 | case OHCI_USB_SUSPEND: | ||
2354 | case OHCI_USB_RESUME: | ||
2355 | hc_control &= OHCI_CTRL_RWC; | ||
2356 | hc_control |= OHCI_USB_RESUME; | ||
2357 | sleep_time = 10; | ||
2358 | break; | ||
2359 | default: | ||
2360 | hc_control &= OHCI_CTRL_RWC; | ||
2361 | hc_control |= OHCI_USB_RESET; | ||
2362 | sleep_time = 50; | ||
2363 | break; | ||
2364 | } | ||
2365 | retval = ftdi_write_pcimem(ftdi, control, hc_control); | ||
2366 | if (retval) | ||
2367 | return retval; | ||
2368 | retval = ftdi_read_pcimem(ftdi, control, &control); | ||
2369 | if (retval) | ||
2370 | return retval; | ||
2371 | msleep(sleep_time); | ||
2372 | retval = ftdi_read_pcimem(ftdi, roothub.a, &roothub_a); | ||
2373 | if (retval) | ||
2374 | return retval; | ||
2375 | if (!(roothub_a & RH_A_NPS)) { /* power down each port */ | ||
2376 | for (temp = 0; temp < num_ports; temp++) { | ||
2377 | retval = ftdi_write_pcimem(ftdi, | ||
2378 | roothub.portstatus[temp], RH_PS_LSDA); | ||
2379 | if (retval) | ||
2380 | return retval; | ||
2381 | } | ||
2382 | } | ||
2383 | retval = ftdi_read_pcimem(ftdi, control, &control); | ||
2384 | if (retval) | ||
2385 | return retval; | ||
2386 | retry:retval = ftdi_read_pcimem(ftdi, cmdstatus, &status); | ||
2387 | if (retval) | ||
2388 | return retval; | ||
2389 | retval = ftdi_write_pcimem(ftdi, cmdstatus, OHCI_HCR); | ||
2390 | if (retval) | ||
2391 | return retval; | ||
2392 | extra:{ | ||
2393 | retval = ftdi_read_pcimem(ftdi, cmdstatus, &status); | ||
2394 | if (retval) | ||
2395 | return retval; | ||
2396 | if (0 != (status & OHCI_HCR)) { | ||
2397 | if (--reset_timeout == 0) { | ||
2398 | dev_err(&ftdi->udev->dev, "USB HC reset timed o" | ||
2399 | "ut!\n"); | ||
2400 | return -ENODEV; | ||
2401 | } else { | ||
2402 | msleep(5); | ||
2403 | goto extra; | ||
2404 | } | ||
2405 | } | ||
2406 | } | ||
2407 | if (quirk & OHCI_QUIRK_INITRESET) { | ||
2408 | retval = ftdi_write_pcimem(ftdi, control, hc_control); | ||
2409 | if (retval) | ||
2410 | return retval; | ||
2411 | retval = ftdi_read_pcimem(ftdi, control, &control); | ||
2412 | if (retval) | ||
2413 | return retval; | ||
2414 | } | ||
2415 | retval = ftdi_write_pcimem(ftdi, ed_controlhead, 0x00000000); | ||
2416 | if (retval) | ||
2417 | return retval; | ||
2418 | retval = ftdi_write_pcimem(ftdi, ed_bulkhead, 0x11000000); | ||
2419 | if (retval) | ||
2420 | return retval; | ||
2421 | retval = ftdi_write_pcimem(ftdi, hcca, 0x00000000); | ||
2422 | if (retval) | ||
2423 | return retval; | ||
2424 | retval = ftdi_read_pcimem(ftdi, fminterval, &fminterval); | ||
2425 | if (retval) | ||
2426 | return retval; | ||
2427 | retval = ftdi_write_pcimem(ftdi, fminterval, | ||
2428 | ((fminterval & FIT) ^ FIT) | hc_fminterval); | ||
2429 | if (retval) | ||
2430 | return retval; | ||
2431 | retval = ftdi_write_pcimem(ftdi, periodicstart, | ||
2432 | ((9 *hc_fminterval) / 10) & 0x3fff); | ||
2433 | if (retval) | ||
2434 | return retval; | ||
2435 | retval = ftdi_read_pcimem(ftdi, fminterval, &fminterval); | ||
2436 | if (retval) | ||
2437 | return retval; | ||
2438 | retval = ftdi_read_pcimem(ftdi, periodicstart, &periodicstart); | ||
2439 | if (retval) | ||
2440 | return retval; | ||
2441 | if (0 == (fminterval & 0x3fff0000) || 0 == periodicstart) { | ||
2442 | if (!(quirk & OHCI_QUIRK_INITRESET)) { | ||
2443 | quirk |= OHCI_QUIRK_INITRESET; | ||
2444 | goto retry; | ||
2445 | } else | ||
2446 | dev_err(&ftdi->udev->dev, "init err(%08x %04x)\n", | ||
2447 | fminterval, periodicstart); | ||
2448 | } /* start controller operations */ | ||
2449 | hc_control &= OHCI_CTRL_RWC; | ||
2450 | hc_control |= OHCI_CONTROL_INIT | OHCI_CTRL_BLE | OHCI_USB_OPER; | ||
2451 | retval = ftdi_write_pcimem(ftdi, control, hc_control); | ||
2452 | if (retval) | ||
2453 | return retval; | ||
2454 | retval = ftdi_write_pcimem(ftdi, cmdstatus, OHCI_BLF); | ||
2455 | if (retval) | ||
2456 | return retval; | ||
2457 | retval = ftdi_read_pcimem(ftdi, cmdstatus, &cmdstatus); | ||
2458 | if (retval) | ||
2459 | return retval; | ||
2460 | retval = ftdi_read_pcimem(ftdi, control, &control); | ||
2461 | if (retval) | ||
2462 | return retval; | ||
2463 | retval = ftdi_write_pcimem(ftdi, roothub.status, RH_HS_DRWE); | ||
2464 | if (retval) | ||
2465 | return retval; | ||
2466 | retval = ftdi_write_pcimem(ftdi, intrstatus, mask); | ||
2467 | if (retval) | ||
2468 | return retval; | ||
2469 | retval = ftdi_write_pcimem(ftdi, intrdisable, | ||
2470 | OHCI_INTR_MIE | OHCI_INTR_OC | OHCI_INTR_RHSC | OHCI_INTR_FNO | | ||
2471 | OHCI_INTR_UE | OHCI_INTR_RD | OHCI_INTR_SF | OHCI_INTR_WDH | | ||
2472 | OHCI_INTR_SO); | ||
2473 | if (retval) | ||
2474 | return retval; /* handle root hub init quirks ... */ | ||
2475 | retval = ftdi_read_pcimem(ftdi, roothub.a, &roothub_a); | ||
2476 | if (retval) | ||
2477 | return retval; | ||
2478 | roothub_a &= ~(RH_A_PSM | RH_A_OCPM); | ||
2479 | if (quirk & OHCI_QUIRK_SUPERIO) { | ||
2480 | roothub_a |= RH_A_NOCP; | ||
2481 | roothub_a &= ~(RH_A_POTPGT | RH_A_NPS); | ||
2482 | retval = ftdi_write_pcimem(ftdi, roothub.a, roothub_a); | ||
2483 | if (retval) | ||
2484 | return retval; | ||
2485 | } else if ((quirk & OHCI_QUIRK_AMD756) || distrust_firmware) { | ||
2486 | roothub_a |= RH_A_NPS; | ||
2487 | retval = ftdi_write_pcimem(ftdi, roothub.a, roothub_a); | ||
2488 | if (retval) | ||
2489 | return retval; | ||
2490 | } | ||
2491 | retval = ftdi_write_pcimem(ftdi, roothub.status, RH_HS_LPSC); | ||
2492 | if (retval) | ||
2493 | return retval; | ||
2494 | retval = ftdi_write_pcimem(ftdi, roothub.b, | ||
2495 | (roothub_a & RH_A_NPS) ? 0 : RH_B_PPCM); | ||
2496 | if (retval) | ||
2497 | return retval; | ||
2498 | retval = ftdi_read_pcimem(ftdi, control, &control); | ||
2499 | if (retval) | ||
2500 | return retval; | ||
2501 | mdelay((roothub_a >> 23) & 0x1fe); | ||
2502 | for (temp = 0; temp < num_ports; temp++) { | ||
2503 | u32 portstatus; | ||
2504 | retval = ftdi_read_pcimem(ftdi, roothub.portstatus[temp], | ||
2505 | &portstatus); | ||
2506 | if (retval) | ||
2507 | return retval; | ||
2508 | if (1 & portstatus) | ||
2509 | devices += 1; | ||
2510 | } | ||
2511 | return devices; | ||
2512 | } | ||
2513 | |||
2514 | static int ftdi_elan_setup_controller(struct usb_ftdi *ftdi, int fn) | ||
2292 | { | 2515 | { |
2293 | u32 latence_timer; | 2516 | u32 latence_timer; |
2294 | u32 controlreg; | ||
2295 | int UxxxStatus; | 2517 | int UxxxStatus; |
2296 | u32 pcidata; | 2518 | u32 pcidata; |
2297 | int reg = 0; | 2519 | int reg = 0; |
2298 | int foundOHCI = 0; | 2520 | int activePCIfn = fn << 8; |
2299 | u8 fn; | 2521 | UxxxStatus = ftdi_elan_write_reg(ftdi, 0x0000025FL | 0x2800); |
2300 | int activePCIfn = 0; | ||
2301 | u32 pciVID = 0; | ||
2302 | u32 pciPID = 0; | ||
2303 | UxxxStatus = ftdi_elan_read_reg(ftdi, &controlreg); | ||
2304 | if (UxxxStatus) | ||
2305 | return UxxxStatus; | ||
2306 | UxxxStatus = ftdi_elan_write_reg(ftdi, 0x00000000L); | ||
2307 | if (UxxxStatus) | ||
2308 | return UxxxStatus; | ||
2309 | msleep(750); | ||
2310 | UxxxStatus = ftdi_elan_write_reg(ftdi, 0x00000200L | 0x100); | ||
2311 | if (UxxxStatus) | 2522 | if (UxxxStatus) |
2312 | return UxxxStatus; | 2523 | return UxxxStatus; |
2313 | UxxxStatus = ftdi_elan_write_reg(ftdi, 0x00000200L | 0x500); | 2524 | reg = 16; |
2525 | UxxxStatus = ftdi_elan_write_config(ftdi, activePCIfn | reg, 0, | ||
2526 | 0xFFFFFFFF); | ||
2314 | if (UxxxStatus) | 2527 | if (UxxxStatus) |
2315 | return UxxxStatus; | 2528 | return UxxxStatus; |
2316 | UxxxStatus = ftdi_elan_read_reg(ftdi, &controlreg); | 2529 | UxxxStatus = ftdi_elan_read_config(ftdi, activePCIfn | reg, 0, |
2530 | &pcidata); | ||
2317 | if (UxxxStatus) | 2531 | if (UxxxStatus) |
2318 | return UxxxStatus; | 2532 | return UxxxStatus; |
2319 | UxxxStatus = ftdi_elan_write_reg(ftdi, 0x0000020CL | 0x000); | 2533 | UxxxStatus = ftdi_elan_write_config(ftdi, activePCIfn | reg, 0, |
2534 | 0xF0000000); | ||
2320 | if (UxxxStatus) | 2535 | if (UxxxStatus) |
2321 | return UxxxStatus; | 2536 | return UxxxStatus; |
2322 | UxxxStatus = ftdi_elan_write_reg(ftdi, 0x0000020DL | 0x000); | 2537 | UxxxStatus = ftdi_elan_read_config(ftdi, activePCIfn | reg, 0, |
2538 | &pcidata); | ||
2323 | if (UxxxStatus) | 2539 | if (UxxxStatus) |
2324 | return UxxxStatus; | 2540 | return UxxxStatus; |
2325 | msleep(250); | 2541 | reg = 12; |
2326 | UxxxStatus = ftdi_elan_write_reg(ftdi, 0x0000020FL | 0x000); | 2542 | UxxxStatus = ftdi_elan_read_config(ftdi, activePCIfn | reg, 0, |
2543 | &latence_timer); | ||
2327 | if (UxxxStatus) | 2544 | if (UxxxStatus) |
2328 | return UxxxStatus; | 2545 | return UxxxStatus; |
2329 | UxxxStatus = ftdi_elan_read_reg(ftdi, &controlreg); | 2546 | latence_timer &= 0xFFFF00FF; |
2547 | latence_timer |= 0x00001600; | ||
2548 | UxxxStatus = ftdi_elan_write_config(ftdi, activePCIfn | reg, 0x00, | ||
2549 | latence_timer); | ||
2330 | if (UxxxStatus) | 2550 | if (UxxxStatus) |
2331 | return UxxxStatus; | 2551 | return UxxxStatus; |
2332 | UxxxStatus = ftdi_elan_write_reg(ftdi, 0x0000025FL | 0x800); | 2552 | UxxxStatus = ftdi_elan_read_config(ftdi, activePCIfn | reg, 0, |
2553 | &pcidata); | ||
2333 | if (UxxxStatus) | 2554 | if (UxxxStatus) |
2334 | return UxxxStatus; | 2555 | return UxxxStatus; |
2335 | UxxxStatus = ftdi_elan_read_reg(ftdi, &controlreg); | 2556 | reg = 4; |
2557 | UxxxStatus = ftdi_elan_write_config(ftdi, activePCIfn | reg, 0x00, | ||
2558 | 0x06); | ||
2336 | if (UxxxStatus) | 2559 | if (UxxxStatus) |
2337 | return UxxxStatus; | 2560 | return UxxxStatus; |
2338 | UxxxStatus = ftdi_elan_read_reg(ftdi, &controlreg); | 2561 | UxxxStatus = ftdi_elan_read_config(ftdi, activePCIfn | reg, 0, |
2562 | &pcidata); | ||
2339 | if (UxxxStatus) | 2563 | if (UxxxStatus) |
2340 | return UxxxStatus; | 2564 | return UxxxStatus; |
2341 | msleep(1000); | 2565 | for (reg = 0; reg <= 0x54; reg += 4) { |
2342 | for (fn = 0; (fn < 4) && (!foundOHCI); fn++) { | 2566 | UxxxStatus = ftdi_elan_read_pcimem(ftdi, reg, 0, &pcidata); |
2343 | activePCIfn = fn << 8; | ||
2344 | ftdi->function = fn + 1; | ||
2345 | UxxxStatus = ftdi_elan_read_config(ftdi, activePCIfn | reg, 0, | ||
2346 | &pcidata); | ||
2347 | if (UxxxStatus) | 2567 | if (UxxxStatus) |
2348 | return UxxxStatus; | 2568 | return UxxxStatus; |
2349 | pciVID = pcidata & 0xFFFF; | ||
2350 | pciPID = (pcidata >> 16) & 0xFFFF; | ||
2351 | if ((pciVID == 0x1045) && (pciPID == 0xc861)) { | ||
2352 | foundOHCI = 1; | ||
2353 | } else if ((pciVID == 0x1033) && (pciPID == 0x0035)) { | ||
2354 | foundOHCI = 1; | ||
2355 | } else if ((pciVID == 0x10b9) && (pciPID == 0x5237)) { | ||
2356 | foundOHCI = 1; | ||
2357 | } else if ((pciVID == 0x11c1) && (pciPID == 0x5802)) { | ||
2358 | foundOHCI = 1; | ||
2359 | } else if ((pciVID == 0x11AB) && (pciPID == 0x1FA6)) { | ||
2360 | } | ||
2361 | } | ||
2362 | if (foundOHCI == 0) { | ||
2363 | return -ENXIO; | ||
2364 | } | 2569 | } |
2365 | ftdi->platform_data.vendor = pciVID; | 2570 | return 0; |
2366 | ftdi->platform_data.device = pciPID; | 2571 | } |
2572 | |||
2573 | static int ftdi_elan_close_controller(struct usb_ftdi *ftdi, int fn) | ||
2574 | { | ||
2575 | u32 latence_timer; | ||
2576 | int UxxxStatus; | ||
2577 | u32 pcidata; | ||
2578 | int reg = 0; | ||
2579 | int activePCIfn = fn << 8; | ||
2367 | UxxxStatus = ftdi_elan_write_reg(ftdi, 0x0000025FL | 0x2800); | 2580 | UxxxStatus = ftdi_elan_write_reg(ftdi, 0x0000025FL | 0x2800); |
2368 | if (UxxxStatus) | 2581 | if (UxxxStatus) |
2369 | return UxxxStatus; | 2582 | return UxxxStatus; |
@@ -2377,7 +2590,7 @@ static int ftdi_elan_enumeratePCI(struct usb_ftdi *ftdi) | |||
2377 | if (UxxxStatus) | 2590 | if (UxxxStatus) |
2378 | return UxxxStatus; | 2591 | return UxxxStatus; |
2379 | UxxxStatus = ftdi_elan_write_config(ftdi, activePCIfn | reg, 0, | 2592 | UxxxStatus = ftdi_elan_write_config(ftdi, activePCIfn | reg, 0, |
2380 | 0xF0000000); | 2593 | 0x00000000); |
2381 | if (UxxxStatus) | 2594 | if (UxxxStatus) |
2382 | return UxxxStatus; | 2595 | return UxxxStatus; |
2383 | UxxxStatus = ftdi_elan_read_config(ftdi, activePCIfn | reg, 0, | 2596 | UxxxStatus = ftdi_elan_read_config(ftdi, activePCIfn | reg, 0, |
@@ -2401,7 +2614,7 @@ static int ftdi_elan_enumeratePCI(struct usb_ftdi *ftdi) | |||
2401 | return UxxxStatus; | 2614 | return UxxxStatus; |
2402 | reg = 4; | 2615 | reg = 4; |
2403 | UxxxStatus = ftdi_elan_write_config(ftdi, activePCIfn | reg, 0x00, | 2616 | UxxxStatus = ftdi_elan_write_config(ftdi, activePCIfn | reg, 0x00, |
2404 | 0x06); | 2617 | 0x00); |
2405 | if (UxxxStatus) | 2618 | if (UxxxStatus) |
2406 | return UxxxStatus; | 2619 | return UxxxStatus; |
2407 | UxxxStatus = ftdi_elan_read_config(ftdi, activePCIfn | reg, 0, | 2620 | UxxxStatus = ftdi_elan_read_config(ftdi, activePCIfn | reg, 0, |
@@ -2411,159 +2624,139 @@ static int ftdi_elan_enumeratePCI(struct usb_ftdi *ftdi) | |||
2411 | return 0; | 2624 | return 0; |
2412 | } | 2625 | } |
2413 | 2626 | ||
2627 | static int ftdi_elan_found_controller(struct usb_ftdi *ftdi, int fn, int quirk) | ||
2628 | { | ||
2629 | int result; | ||
2630 | int UxxxStatus; | ||
2631 | UxxxStatus = ftdi_elan_setup_controller(ftdi, fn); | ||
2632 | if (UxxxStatus) | ||
2633 | return UxxxStatus; | ||
2634 | result = ftdi_elan_check_controller(ftdi, quirk); | ||
2635 | UxxxStatus = ftdi_elan_close_controller(ftdi, fn); | ||
2636 | if (UxxxStatus) | ||
2637 | return UxxxStatus; | ||
2638 | return result; | ||
2639 | } | ||
2640 | |||
2641 | static int ftdi_elan_enumeratePCI(struct usb_ftdi *ftdi) | ||
2642 | { | ||
2643 | u32 controlreg; | ||
2644 | u8 sensebits; | ||
2645 | int UxxxStatus; | ||
2646 | UxxxStatus = ftdi_elan_read_reg(ftdi, &controlreg); | ||
2647 | if (UxxxStatus) | ||
2648 | return UxxxStatus; | ||
2649 | UxxxStatus = ftdi_elan_write_reg(ftdi, 0x00000000L); | ||
2650 | if (UxxxStatus) | ||
2651 | return UxxxStatus; | ||
2652 | msleep(750); | ||
2653 | UxxxStatus = ftdi_elan_write_reg(ftdi, 0x00000200L | 0x100); | ||
2654 | if (UxxxStatus) | ||
2655 | return UxxxStatus; | ||
2656 | UxxxStatus = ftdi_elan_write_reg(ftdi, 0x00000200L | 0x500); | ||
2657 | if (UxxxStatus) | ||
2658 | return UxxxStatus; | ||
2659 | UxxxStatus = ftdi_elan_read_reg(ftdi, &controlreg); | ||
2660 | if (UxxxStatus) | ||
2661 | return UxxxStatus; | ||
2662 | UxxxStatus = ftdi_elan_write_reg(ftdi, 0x0000020CL | 0x000); | ||
2663 | if (UxxxStatus) | ||
2664 | return UxxxStatus; | ||
2665 | UxxxStatus = ftdi_elan_write_reg(ftdi, 0x0000020DL | 0x000); | ||
2666 | if (UxxxStatus) | ||
2667 | return UxxxStatus; | ||
2668 | msleep(250); | ||
2669 | UxxxStatus = ftdi_elan_write_reg(ftdi, 0x0000020FL | 0x000); | ||
2670 | if (UxxxStatus) | ||
2671 | return UxxxStatus; | ||
2672 | UxxxStatus = ftdi_elan_read_reg(ftdi, &controlreg); | ||
2673 | if (UxxxStatus) | ||
2674 | return UxxxStatus; | ||
2675 | UxxxStatus = ftdi_elan_write_reg(ftdi, 0x0000025FL | 0x800); | ||
2676 | if (UxxxStatus) | ||
2677 | return UxxxStatus; | ||
2678 | UxxxStatus = ftdi_elan_read_reg(ftdi, &controlreg); | ||
2679 | if (UxxxStatus) | ||
2680 | return UxxxStatus; | ||
2681 | UxxxStatus = ftdi_elan_read_reg(ftdi, &controlreg); | ||
2682 | if (UxxxStatus) | ||
2683 | return UxxxStatus; | ||
2684 | msleep(1000); | ||
2685 | sensebits = (controlreg >> 16) & 0x000F; | ||
2686 | if (0x0D == sensebits) | ||
2687 | return 0; | ||
2688 | else | ||
2689 | return - ENXIO; | ||
2690 | } | ||
2691 | |||
2414 | static int ftdi_elan_setupOHCI(struct usb_ftdi *ftdi) | 2692 | static int ftdi_elan_setupOHCI(struct usb_ftdi *ftdi) |
2415 | { | 2693 | { |
2694 | int UxxxStatus; | ||
2416 | u32 pcidata; | 2695 | u32 pcidata; |
2417 | int U132Status; | 2696 | int reg = 0; |
2418 | int reg; | 2697 | u8 fn; |
2419 | int reset_repeat = 0; | 2698 | int activePCIfn = 0; |
2420 | do_reset:reg = 8; | 2699 | int max_devices = 0; |
2421 | U132Status = ftdi_elan_write_pcimem(ftdi, reg, 0x0e, 0x01); | 2700 | int controllers = 0; |
2422 | if (U132Status) | 2701 | int unrecognized = 0; |
2423 | return U132Status; | 2702 | ftdi->function = 0; |
2424 | reset_check:{ | 2703 | for (fn = 0; (fn < 4); fn++) { |
2425 | U132Status = ftdi_elan_read_pcimem(ftdi, reg, 0, &pcidata); | 2704 | u32 pciVID = 0; |
2426 | if (U132Status) | 2705 | u32 pciPID = 0; |
2427 | return U132Status; | 2706 | int devices = 0; |
2428 | if (pcidata & 1) { | 2707 | activePCIfn = fn << 8; |
2429 | msleep(500); | 2708 | UxxxStatus = ftdi_elan_read_config(ftdi, activePCIfn | reg, 0, |
2430 | if (reset_repeat++ > 100) { | 2709 | &pcidata); |
2431 | reset_repeat = 0; | 2710 | if (UxxxStatus) |
2432 | goto do_reset; | 2711 | return UxxxStatus; |
2433 | } else | 2712 | pciVID = pcidata & 0xFFFF; |
2434 | goto reset_check; | 2713 | pciPID = (pcidata >> 16) & 0xFFFF; |
2714 | if ((pciVID == PCI_VENDOR_ID_OPTI) && (pciPID == 0xc861)) { | ||
2715 | devices = ftdi_elan_found_controller(ftdi, fn, 0); | ||
2716 | controllers += 1; | ||
2717 | } else if ((pciVID == PCI_VENDOR_ID_NEC) && (pciPID == 0x0035)) | ||
2718 | { | ||
2719 | devices = ftdi_elan_found_controller(ftdi, fn, 0); | ||
2720 | controllers += 1; | ||
2721 | } else if ((pciVID == PCI_VENDOR_ID_AL) && (pciPID == 0x5237)) { | ||
2722 | devices = ftdi_elan_found_controller(ftdi, fn, 0); | ||
2723 | controllers += 1; | ||
2724 | } else if ((pciVID == PCI_VENDOR_ID_ATT) && (pciPID == 0x5802)) | ||
2725 | { | ||
2726 | devices = ftdi_elan_found_controller(ftdi, fn, 0); | ||
2727 | controllers += 1; | ||
2728 | } else if (pciVID == PCI_VENDOR_ID_AMD && pciPID == 0x740c) { | ||
2729 | devices = ftdi_elan_found_controller(ftdi, fn, | ||
2730 | OHCI_QUIRK_AMD756); | ||
2731 | controllers += 1; | ||
2732 | } else if (pciVID == PCI_VENDOR_ID_COMPAQ && pciPID == 0xa0f8) { | ||
2733 | devices = ftdi_elan_found_controller(ftdi, fn, | ||
2734 | OHCI_QUIRK_ZFMICRO); | ||
2735 | controllers += 1; | ||
2736 | } else if (0 == pcidata) { | ||
2737 | } else | ||
2738 | unrecognized += 1; | ||
2739 | if (devices > max_devices) { | ||
2740 | max_devices = devices; | ||
2741 | ftdi->function = fn + 1; | ||
2742 | ftdi->platform_data.vendor = pciVID; | ||
2743 | ftdi->platform_data.device = pciPID; | ||
2435 | } | 2744 | } |
2436 | } | 2745 | } |
2437 | goto dump_regs; | 2746 | if (ftdi->function > 0) { |
2438 | msleep(500); | 2747 | UxxxStatus = ftdi_elan_setup_controller(ftdi, |
2439 | reg = 0x28; | 2748 | ftdi->function - 1); |
2440 | U132Status = ftdi_elan_write_pcimem(ftdi, reg, 0x00, 0x11000000); | 2749 | if (UxxxStatus) |
2441 | if (U132Status) | 2750 | return UxxxStatus; |
2442 | return U132Status; | 2751 | return 0; |
2443 | U132Status = ftdi_elan_read_pcimem(ftdi, reg, 0, &pcidata); | 2752 | } else if (controllers > 0) { |
2444 | if (U132Status) | 2753 | return -ENXIO; |
2445 | return U132Status; | 2754 | } else if (unrecognized > 0) { |
2446 | reg = 0x40; | 2755 | return -ENXIO; |
2447 | U132Status = ftdi_elan_write_pcimem(ftdi, reg, 0x00, 0x2edf); | 2756 | } else { |
2448 | if (U132Status) | 2757 | ftdi->enumerated = 0; |
2449 | return U132Status; | 2758 | return -ENXIO; |
2450 | U132Status = ftdi_elan_read_pcimem(ftdi, reg, 0, &pcidata); | ||
2451 | if (U132Status) | ||
2452 | return U132Status; | ||
2453 | reg = 0x34; | ||
2454 | U132Status = ftdi_elan_write_pcimem(ftdi, reg, 0x00, 0x2edf2edf); | ||
2455 | if (U132Status) | ||
2456 | return U132Status; | ||
2457 | U132Status = ftdi_elan_read_pcimem(ftdi, reg, 0, &pcidata); | ||
2458 | if (U132Status) | ||
2459 | return U132Status; | ||
2460 | reg = 4; | ||
2461 | U132Status = ftdi_elan_write_pcimem(ftdi, reg, 0x00, 0xA0); | ||
2462 | if (U132Status) | ||
2463 | return U132Status; | ||
2464 | U132Status = ftdi_elan_read_pcimem(ftdi, reg, 0, &pcidata); | ||
2465 | if (U132Status) | ||
2466 | return U132Status; | ||
2467 | msleep(250); | ||
2468 | reg = 8; | ||
2469 | U132Status = ftdi_elan_write_pcimem(ftdi, reg, 0x0e, 0x04); | ||
2470 | if (U132Status) | ||
2471 | return U132Status; | ||
2472 | U132Status = ftdi_elan_read_pcimem(ftdi, reg, 0, &pcidata); | ||
2473 | if (U132Status) | ||
2474 | return U132Status; | ||
2475 | reg = 0x28; | ||
2476 | U132Status = ftdi_elan_read_pcimem(ftdi, reg, 0, &pcidata); | ||
2477 | if (U132Status) | ||
2478 | return U132Status; | ||
2479 | reg = 8; | ||
2480 | U132Status = ftdi_elan_read_pcimem(ftdi, reg, 0, &pcidata); | ||
2481 | if (U132Status) | ||
2482 | return U132Status; | ||
2483 | reg = 0x48; | ||
2484 | U132Status = ftdi_elan_write_pcimem(ftdi, reg, 0x00, 0x00001200); | ||
2485 | if (U132Status) | ||
2486 | return U132Status; | ||
2487 | U132Status = ftdi_elan_read_pcimem(ftdi, reg, 0, &pcidata); | ||
2488 | if (U132Status) | ||
2489 | return U132Status; | ||
2490 | reg = 0x54; | ||
2491 | U132Status = ftdi_elan_read_pcimem(ftdi, reg, 0, &pcidata); | ||
2492 | if (U132Status) | ||
2493 | return U132Status; | ||
2494 | reg = 0x58; | ||
2495 | U132Status = ftdi_elan_read_pcimem(ftdi, reg, 0, &pcidata); | ||
2496 | if (U132Status) | ||
2497 | return U132Status; | ||
2498 | reg = 0x34; | ||
2499 | U132Status = ftdi_elan_write_pcimem(ftdi, reg, 0x00, 0x28002edf); | ||
2500 | if (U132Status) | ||
2501 | return U132Status; | ||
2502 | U132Status = ftdi_elan_read_pcimem(ftdi, reg, 0, &pcidata); | ||
2503 | if (U132Status) | ||
2504 | return U132Status; | ||
2505 | msleep(100); | ||
2506 | reg = 0x50; | ||
2507 | U132Status = ftdi_elan_write_pcimem(ftdi, reg, 0x00, 0x10000); | ||
2508 | if (U132Status) | ||
2509 | return U132Status; | ||
2510 | reg = 0x54; | ||
2511 | power_check:U132Status = ftdi_elan_read_pcimem(ftdi, reg, 0, &pcidata); | ||
2512 | if (U132Status) | ||
2513 | return U132Status; | ||
2514 | if (!(pcidata & 1)) { | ||
2515 | msleep(500); | ||
2516 | goto power_check; | ||
2517 | } | ||
2518 | msleep(3000); | ||
2519 | reg = 0x54; | ||
2520 | U132Status = ftdi_elan_read_pcimem(ftdi, reg, 0, &pcidata); | ||
2521 | if (U132Status) | ||
2522 | return U132Status; | ||
2523 | reg = 0x58; | ||
2524 | U132Status = ftdi_elan_read_pcimem(ftdi, reg, 0, &pcidata); | ||
2525 | if (U132Status) | ||
2526 | return U132Status; | ||
2527 | reg = 0x54; | ||
2528 | U132Status = ftdi_elan_write_pcimem(ftdi, reg, 0x00, 0x02); | ||
2529 | if (U132Status) | ||
2530 | return U132Status; | ||
2531 | U132Status = ftdi_elan_read_pcimem(ftdi, reg, 0, &pcidata); | ||
2532 | if (U132Status) | ||
2533 | return U132Status; | ||
2534 | reg = 0x54; | ||
2535 | U132Status = ftdi_elan_write_pcimem(ftdi, reg, 0x00, 0x10); | ||
2536 | if (U132Status) | ||
2537 | return U132Status; | ||
2538 | U132Status = ftdi_elan_read_pcimem(ftdi, reg, 0, &pcidata); | ||
2539 | if (U132Status) | ||
2540 | return U132Status; | ||
2541 | msleep(750); | ||
2542 | reg = 0x54; | ||
2543 | if (0) { | ||
2544 | U132Status = ftdi_elan_write_pcimem(ftdi, reg, 0x00, 0x02); | ||
2545 | if (U132Status) | ||
2546 | return U132Status; | ||
2547 | } | ||
2548 | if (0) { | ||
2549 | U132Status = ftdi_elan_read_pcimem(ftdi, reg, 0, &pcidata); | ||
2550 | if (U132Status) | ||
2551 | return U132Status; | ||
2552 | } | ||
2553 | reg = 0x54; | ||
2554 | U132Status = ftdi_elan_read_pcimem(ftdi, reg, 0, &pcidata); | ||
2555 | if (U132Status) | ||
2556 | return U132Status; | ||
2557 | reg = 0x58; | ||
2558 | U132Status = ftdi_elan_read_pcimem(ftdi, reg, 0, &pcidata); | ||
2559 | if (U132Status) | ||
2560 | return U132Status; | ||
2561 | dump_regs:for (reg = 0; reg <= 0x54; reg += 4) { | ||
2562 | U132Status = ftdi_elan_read_pcimem(ftdi, reg, 0, &pcidata); | ||
2563 | if (U132Status) | ||
2564 | return U132Status; | ||
2565 | } | 2759 | } |
2566 | return 0; | ||
2567 | } | 2760 | } |
2568 | 2761 | ||
2569 | 2762 | ||
@@ -2688,6 +2881,7 @@ static void ftdi_elan_disconnect(struct usb_interface *interface) | |||
2688 | platform_device_unregister(&ftdi->platform_dev); | 2881 | platform_device_unregister(&ftdi->platform_dev); |
2689 | ftdi->synchronized = 0; | 2882 | ftdi->synchronized = 0; |
2690 | ftdi->enumerated = 0; | 2883 | ftdi->enumerated = 0; |
2884 | ftdi->initialized = 0; | ||
2691 | ftdi->registered = 0; | 2885 | ftdi->registered = 0; |
2692 | } | 2886 | } |
2693 | flush_workqueue(status_queue); | 2887 | flush_workqueue(status_queue); |
diff --git a/drivers/usb/misc/idmouse.c b/drivers/usb/misc/idmouse.c index c9418535bef8..15c70bd048c4 100644 --- a/drivers/usb/misc/idmouse.c +++ b/drivers/usb/misc/idmouse.c | |||
@@ -269,7 +269,7 @@ static int idmouse_release(struct inode *inode, struct file *file) | |||
269 | /* prevent a race condition with open() */ | 269 | /* prevent a race condition with open() */ |
270 | mutex_lock(&disconnect_mutex); | 270 | mutex_lock(&disconnect_mutex); |
271 | 271 | ||
272 | dev = (struct usb_idmouse *) file->private_data; | 272 | dev = file->private_data; |
273 | 273 | ||
274 | if (dev == NULL) { | 274 | if (dev == NULL) { |
275 | mutex_unlock(&disconnect_mutex); | 275 | mutex_unlock(&disconnect_mutex); |
@@ -304,17 +304,15 @@ static int idmouse_release(struct inode *inode, struct file *file) | |||
304 | static ssize_t idmouse_read(struct file *file, char __user *buffer, size_t count, | 304 | static ssize_t idmouse_read(struct file *file, char __user *buffer, size_t count, |
305 | loff_t * ppos) | 305 | loff_t * ppos) |
306 | { | 306 | { |
307 | struct usb_idmouse *dev; | 307 | struct usb_idmouse *dev = file->private_data; |
308 | int result; | 308 | int result; |
309 | 309 | ||
310 | dev = (struct usb_idmouse *) file->private_data; | ||
311 | |||
312 | /* lock this object */ | 310 | /* lock this object */ |
313 | down (&dev->sem); | 311 | down(&dev->sem); |
314 | 312 | ||
315 | /* verify that the device wasn't unplugged */ | 313 | /* verify that the device wasn't unplugged */ |
316 | if (!dev->present) { | 314 | if (!dev->present) { |
317 | up (&dev->sem); | 315 | up(&dev->sem); |
318 | return -ENODEV; | 316 | return -ENODEV; |
319 | } | 317 | } |
320 | 318 | ||
diff --git a/drivers/usb/misc/phidgetservo.c b/drivers/usb/misc/phidgetservo.c index 7163f05c5b27..0d9de2f73930 100644 --- a/drivers/usb/misc/phidgetservo.c +++ b/drivers/usb/misc/phidgetservo.c | |||
@@ -282,6 +282,7 @@ servo_probe(struct usb_interface *interface, const struct usb_device_id *id) | |||
282 | dev->dev = NULL; | 282 | dev->dev = NULL; |
283 | goto out; | 283 | goto out; |
284 | } | 284 | } |
285 | dev_set_drvdata(dev->dev, dev); | ||
285 | 286 | ||
286 | servo_count = dev->type & SERVO_COUNT_QUAD ? 4 : 1; | 287 | servo_count = dev->type & SERVO_COUNT_QUAD ? 4 : 1; |
287 | 288 | ||
diff --git a/drivers/usb/misc/rio500.c b/drivers/usb/misc/rio500.c index 384fa3769805..fdf68479a166 100644 --- a/drivers/usb/misc/rio500.c +++ b/drivers/usb/misc/rio500.c | |||
@@ -69,7 +69,7 @@ struct rio_usb_data { | |||
69 | char *obuf, *ibuf; /* transfer buffers */ | 69 | char *obuf, *ibuf; /* transfer buffers */ |
70 | char bulk_in_ep, bulk_out_ep; /* Endpoint assignments */ | 70 | char bulk_in_ep, bulk_out_ep; /* Endpoint assignments */ |
71 | wait_queue_head_t wait_q; /* for timeouts */ | 71 | wait_queue_head_t wait_q; /* for timeouts */ |
72 | struct semaphore lock; /* general race avoidance */ | 72 | struct mutex lock; /* general race avoidance */ |
73 | }; | 73 | }; |
74 | 74 | ||
75 | static struct rio_usb_data rio_instance; | 75 | static struct rio_usb_data rio_instance; |
@@ -78,17 +78,17 @@ static int open_rio(struct inode *inode, struct file *file) | |||
78 | { | 78 | { |
79 | struct rio_usb_data *rio = &rio_instance; | 79 | struct rio_usb_data *rio = &rio_instance; |
80 | 80 | ||
81 | down(&(rio->lock)); | 81 | mutex_lock(&(rio->lock)); |
82 | 82 | ||
83 | if (rio->isopen || !rio->present) { | 83 | if (rio->isopen || !rio->present) { |
84 | up(&(rio->lock)); | 84 | mutex_unlock(&(rio->lock)); |
85 | return -EBUSY; | 85 | return -EBUSY; |
86 | } | 86 | } |
87 | rio->isopen = 1; | 87 | rio->isopen = 1; |
88 | 88 | ||
89 | init_waitqueue_head(&rio->wait_q); | 89 | init_waitqueue_head(&rio->wait_q); |
90 | 90 | ||
91 | up(&(rio->lock)); | 91 | mutex_unlock(&(rio->lock)); |
92 | 92 | ||
93 | info("Rio opened."); | 93 | info("Rio opened."); |
94 | 94 | ||
@@ -117,7 +117,7 @@ ioctl_rio(struct inode *inode, struct file *file, unsigned int cmd, | |||
117 | int retries; | 117 | int retries; |
118 | int retval=0; | 118 | int retval=0; |
119 | 119 | ||
120 | down(&(rio->lock)); | 120 | mutex_lock(&(rio->lock)); |
121 | /* Sanity check to make sure rio is connected, powered, etc */ | 121 | /* Sanity check to make sure rio is connected, powered, etc */ |
122 | if ( rio == NULL || | 122 | if ( rio == NULL || |
123 | rio->present == 0 || | 123 | rio->present == 0 || |
@@ -257,7 +257,7 @@ ioctl_rio(struct inode *inode, struct file *file, unsigned int cmd, | |||
257 | 257 | ||
258 | 258 | ||
259 | err_out: | 259 | err_out: |
260 | up(&(rio->lock)); | 260 | mutex_unlock(&(rio->lock)); |
261 | return retval; | 261 | return retval; |
262 | } | 262 | } |
263 | 263 | ||
@@ -275,14 +275,17 @@ write_rio(struct file *file, const char __user *buffer, | |||
275 | int result = 0; | 275 | int result = 0; |
276 | int maxretry; | 276 | int maxretry; |
277 | int errn = 0; | 277 | int errn = 0; |
278 | int intr; | ||
278 | 279 | ||
279 | down(&(rio->lock)); | 280 | intr = mutex_lock_interruptible(&(rio->lock)); |
281 | if (intr) | ||
282 | return -EINTR; | ||
280 | /* Sanity check to make sure rio is connected, powered, etc */ | 283 | /* Sanity check to make sure rio is connected, powered, etc */ |
281 | if ( rio == NULL || | 284 | if ( rio == NULL || |
282 | rio->present == 0 || | 285 | rio->present == 0 || |
283 | rio->rio_dev == NULL ) | 286 | rio->rio_dev == NULL ) |
284 | { | 287 | { |
285 | up(&(rio->lock)); | 288 | mutex_unlock(&(rio->lock)); |
286 | return -ENODEV; | 289 | return -ENODEV; |
287 | } | 290 | } |
288 | 291 | ||
@@ -305,7 +308,7 @@ write_rio(struct file *file, const char __user *buffer, | |||
305 | goto error; | 308 | goto error; |
306 | } | 309 | } |
307 | if (signal_pending(current)) { | 310 | if (signal_pending(current)) { |
308 | up(&(rio->lock)); | 311 | mutex_unlock(&(rio->lock)); |
309 | return bytes_written ? bytes_written : -EINTR; | 312 | return bytes_written ? bytes_written : -EINTR; |
310 | } | 313 | } |
311 | 314 | ||
@@ -341,12 +344,12 @@ write_rio(struct file *file, const char __user *buffer, | |||
341 | buffer += copy_size; | 344 | buffer += copy_size; |
342 | } while (count > 0); | 345 | } while (count > 0); |
343 | 346 | ||
344 | up(&(rio->lock)); | 347 | mutex_unlock(&(rio->lock)); |
345 | 348 | ||
346 | return bytes_written ? bytes_written : -EIO; | 349 | return bytes_written ? bytes_written : -EIO; |
347 | 350 | ||
348 | error: | 351 | error: |
349 | up(&(rio->lock)); | 352 | mutex_unlock(&(rio->lock)); |
350 | return errn; | 353 | return errn; |
351 | } | 354 | } |
352 | 355 | ||
@@ -361,14 +364,17 @@ read_rio(struct file *file, char __user *buffer, size_t count, loff_t * ppos) | |||
361 | int result; | 364 | int result; |
362 | int maxretry = 10; | 365 | int maxretry = 10; |
363 | char *ibuf; | 366 | char *ibuf; |
367 | int intr; | ||
364 | 368 | ||
365 | down(&(rio->lock)); | 369 | intr = mutex_lock_interruptible(&(rio->lock)); |
370 | if (intr) | ||
371 | return -EINTR; | ||
366 | /* Sanity check to make sure rio is connected, powered, etc */ | 372 | /* Sanity check to make sure rio is connected, powered, etc */ |
367 | if ( rio == NULL || | 373 | if ( rio == NULL || |
368 | rio->present == 0 || | 374 | rio->present == 0 || |
369 | rio->rio_dev == NULL ) | 375 | rio->rio_dev == NULL ) |
370 | { | 376 | { |
371 | up(&(rio->lock)); | 377 | mutex_unlock(&(rio->lock)); |
372 | return -ENODEV; | 378 | return -ENODEV; |
373 | } | 379 | } |
374 | 380 | ||
@@ -379,11 +385,11 @@ read_rio(struct file *file, char __user *buffer, size_t count, loff_t * ppos) | |||
379 | 385 | ||
380 | while (count > 0) { | 386 | while (count > 0) { |
381 | if (signal_pending(current)) { | 387 | if (signal_pending(current)) { |
382 | up(&(rio->lock)); | 388 | mutex_unlock(&(rio->lock)); |
383 | return read_count ? read_count : -EINTR; | 389 | return read_count ? read_count : -EINTR; |
384 | } | 390 | } |
385 | if (!rio->rio_dev) { | 391 | if (!rio->rio_dev) { |
386 | up(&(rio->lock)); | 392 | mutex_unlock(&(rio->lock)); |
387 | return -ENODEV; | 393 | return -ENODEV; |
388 | } | 394 | } |
389 | this_read = (count >= IBUF_SIZE) ? IBUF_SIZE : count; | 395 | this_read = (count >= IBUF_SIZE) ? IBUF_SIZE : count; |
@@ -400,7 +406,7 @@ read_rio(struct file *file, char __user *buffer, size_t count, loff_t * ppos) | |||
400 | count = this_read = partial; | 406 | count = this_read = partial; |
401 | } else if (result == -ETIMEDOUT || result == 15) { /* FIXME: 15 ??? */ | 407 | } else if (result == -ETIMEDOUT || result == 15) { /* FIXME: 15 ??? */ |
402 | if (!maxretry--) { | 408 | if (!maxretry--) { |
403 | up(&(rio->lock)); | 409 | mutex_unlock(&(rio->lock)); |
404 | err("read_rio: maxretry timeout"); | 410 | err("read_rio: maxretry timeout"); |
405 | return -ETIME; | 411 | return -ETIME; |
406 | } | 412 | } |
@@ -409,18 +415,18 @@ read_rio(struct file *file, char __user *buffer, size_t count, loff_t * ppos) | |||
409 | finish_wait(&rio->wait_q, &wait); | 415 | finish_wait(&rio->wait_q, &wait); |
410 | continue; | 416 | continue; |
411 | } else if (result != -EREMOTEIO) { | 417 | } else if (result != -EREMOTEIO) { |
412 | up(&(rio->lock)); | 418 | mutex_unlock(&(rio->lock)); |
413 | err("Read Whoops - result:%u partial:%u this_read:%u", | 419 | err("Read Whoops - result:%u partial:%u this_read:%u", |
414 | result, partial, this_read); | 420 | result, partial, this_read); |
415 | return -EIO; | 421 | return -EIO; |
416 | } else { | 422 | } else { |
417 | up(&(rio->lock)); | 423 | mutex_unlock(&(rio->lock)); |
418 | return (0); | 424 | return (0); |
419 | } | 425 | } |
420 | 426 | ||
421 | if (this_read) { | 427 | if (this_read) { |
422 | if (copy_to_user(buffer, ibuf, this_read)) { | 428 | if (copy_to_user(buffer, ibuf, this_read)) { |
423 | up(&(rio->lock)); | 429 | mutex_unlock(&(rio->lock)); |
424 | return -EFAULT; | 430 | return -EFAULT; |
425 | } | 431 | } |
426 | count -= this_read; | 432 | count -= this_read; |
@@ -428,7 +434,7 @@ read_rio(struct file *file, char __user *buffer, size_t count, loff_t * ppos) | |||
428 | buffer += this_read; | 434 | buffer += this_read; |
429 | } | 435 | } |
430 | } | 436 | } |
431 | up(&(rio->lock)); | 437 | mutex_unlock(&(rio->lock)); |
432 | return read_count; | 438 | return read_count; |
433 | } | 439 | } |
434 | 440 | ||
@@ -480,7 +486,7 @@ static int probe_rio(struct usb_interface *intf, | |||
480 | } | 486 | } |
481 | dbg("probe_rio: ibuf address:%p", rio->ibuf); | 487 | dbg("probe_rio: ibuf address:%p", rio->ibuf); |
482 | 488 | ||
483 | init_MUTEX(&(rio->lock)); | 489 | mutex_init(&(rio->lock)); |
484 | 490 | ||
485 | usb_set_intfdata (intf, rio); | 491 | usb_set_intfdata (intf, rio); |
486 | rio->present = 1; | 492 | rio->present = 1; |
@@ -496,12 +502,12 @@ static void disconnect_rio(struct usb_interface *intf) | |||
496 | if (rio) { | 502 | if (rio) { |
497 | usb_deregister_dev(intf, &usb_rio_class); | 503 | usb_deregister_dev(intf, &usb_rio_class); |
498 | 504 | ||
499 | down(&(rio->lock)); | 505 | mutex_lock(&(rio->lock)); |
500 | if (rio->isopen) { | 506 | if (rio->isopen) { |
501 | rio->isopen = 0; | 507 | rio->isopen = 0; |
502 | /* better let it finish - the release will do whats needed */ | 508 | /* better let it finish - the release will do whats needed */ |
503 | rio->rio_dev = NULL; | 509 | rio->rio_dev = NULL; |
504 | up(&(rio->lock)); | 510 | mutex_unlock(&(rio->lock)); |
505 | return; | 511 | return; |
506 | } | 512 | } |
507 | kfree(rio->ibuf); | 513 | kfree(rio->ibuf); |
@@ -510,7 +516,7 @@ static void disconnect_rio(struct usb_interface *intf) | |||
510 | info("USB Rio disconnected."); | 516 | info("USB Rio disconnected."); |
511 | 517 | ||
512 | rio->present = 0; | 518 | rio->present = 0; |
513 | up(&(rio->lock)); | 519 | mutex_unlock(&(rio->lock)); |
514 | } | 520 | } |
515 | } | 521 | } |
516 | 522 | ||
diff --git a/drivers/usb/misc/sisusbvga/sisusb.c b/drivers/usb/misc/sisusbvga/sisusb.c index b99ca9c79821..0398908b15d4 100644 --- a/drivers/usb/misc/sisusbvga/sisusb.c +++ b/drivers/usb/misc/sisusbvga/sisusb.c | |||
@@ -3168,7 +3168,7 @@ sisusb_compat_ioctl(struct file *f, unsigned int cmd, unsigned long arg) | |||
3168 | case SISUSB_GET_CONFIG: | 3168 | case SISUSB_GET_CONFIG: |
3169 | case SISUSB_COMMAND: | 3169 | case SISUSB_COMMAND: |
3170 | lock_kernel(); | 3170 | lock_kernel(); |
3171 | retval = sisusb_ioctl(f->f_dentry->d_inode, f, cmd, arg); | 3171 | retval = sisusb_ioctl(f->f_path.dentry->d_inode, f, cmd, arg); |
3172 | unlock_kernel(); | 3172 | unlock_kernel(); |
3173 | return retval; | 3173 | return retval; |
3174 | 3174 | ||
diff --git a/drivers/usb/misc/sisusbvga/sisusb_con.c b/drivers/usb/misc/sisusbvga/sisusb_con.c index bf26c3c56990..9148694627d5 100644 --- a/drivers/usb/misc/sisusbvga/sisusb_con.c +++ b/drivers/usb/misc/sisusbvga/sisusb_con.c | |||
@@ -403,7 +403,7 @@ sisusbcon_putc(struct vc_data *c, int ch, int y, int x) | |||
403 | 403 | ||
404 | 404 | ||
405 | sisusb_copy_memory(sisusb, (char *)SISUSB_VADDR(x, y), | 405 | sisusb_copy_memory(sisusb, (char *)SISUSB_VADDR(x, y), |
406 | (u32)SISUSB_HADDR(x, y), 2, &written); | 406 | (long)SISUSB_HADDR(x, y), 2, &written); |
407 | 407 | ||
408 | mutex_unlock(&sisusb->lock); | 408 | mutex_unlock(&sisusb->lock); |
409 | } | 409 | } |
@@ -438,7 +438,7 @@ sisusbcon_putcs(struct vc_data *c, const unsigned short *s, | |||
438 | } | 438 | } |
439 | 439 | ||
440 | sisusb_copy_memory(sisusb, (char *)SISUSB_VADDR(x, y), | 440 | sisusb_copy_memory(sisusb, (char *)SISUSB_VADDR(x, y), |
441 | (u32)SISUSB_HADDR(x, y), count * 2, &written); | 441 | (long)SISUSB_HADDR(x, y), count * 2, &written); |
442 | 442 | ||
443 | mutex_unlock(&sisusb->lock); | 443 | mutex_unlock(&sisusb->lock); |
444 | } | 444 | } |
@@ -492,7 +492,7 @@ sisusbcon_clear(struct vc_data *c, int y, int x, int height, int width) | |||
492 | 492 | ||
493 | 493 | ||
494 | sisusb_copy_memory(sisusb, (unsigned char *)SISUSB_VADDR(x, y), | 494 | sisusb_copy_memory(sisusb, (unsigned char *)SISUSB_VADDR(x, y), |
495 | (u32)SISUSB_HADDR(x, y), length, &written); | 495 | (long)SISUSB_HADDR(x, y), length, &written); |
496 | 496 | ||
497 | mutex_unlock(&sisusb->lock); | 497 | mutex_unlock(&sisusb->lock); |
498 | } | 498 | } |
@@ -564,7 +564,7 @@ sisusbcon_bmove(struct vc_data *c, int sy, int sx, | |||
564 | 564 | ||
565 | 565 | ||
566 | sisusb_copy_memory(sisusb, (unsigned char *)SISUSB_VADDR(dx, dy), | 566 | sisusb_copy_memory(sisusb, (unsigned char *)SISUSB_VADDR(dx, dy), |
567 | (u32)SISUSB_HADDR(dx, dy), length, &written); | 567 | (long)SISUSB_HADDR(dx, dy), length, &written); |
568 | 568 | ||
569 | mutex_unlock(&sisusb->lock); | 569 | mutex_unlock(&sisusb->lock); |
570 | } | 570 | } |
@@ -612,7 +612,7 @@ sisusbcon_switch(struct vc_data *c) | |||
612 | length); | 612 | length); |
613 | 613 | ||
614 | sisusb_copy_memory(sisusb, (unsigned char *)c->vc_origin, | 614 | sisusb_copy_memory(sisusb, (unsigned char *)c->vc_origin, |
615 | (u32)SISUSB_HADDR(0, 0), | 615 | (long)SISUSB_HADDR(0, 0), |
616 | length, &written); | 616 | length, &written); |
617 | 617 | ||
618 | mutex_unlock(&sisusb->lock); | 618 | mutex_unlock(&sisusb->lock); |
@@ -939,7 +939,7 @@ sisusbcon_scroll_area(struct vc_data *c, struct sisusb_usb_data *sisusb, | |||
939 | } | 939 | } |
940 | 940 | ||
941 | sisusb_copy_memory(sisusb, (char *)SISUSB_VADDR(0, t), | 941 | sisusb_copy_memory(sisusb, (char *)SISUSB_VADDR(0, t), |
942 | (u32)SISUSB_HADDR(0, t), length, &written); | 942 | (long)SISUSB_HADDR(0, t), length, &written); |
943 | 943 | ||
944 | mutex_unlock(&sisusb->lock); | 944 | mutex_unlock(&sisusb->lock); |
945 | 945 | ||
diff --git a/drivers/usb/misc/trancevibrator.c b/drivers/usb/misc/trancevibrator.c index 33cd91d11eca..67e2fc20eeeb 100644 --- a/drivers/usb/misc/trancevibrator.c +++ b/drivers/usb/misc/trancevibrator.c | |||
@@ -120,8 +120,8 @@ static void tv_disconnect(struct usb_interface *interface) | |||
120 | struct trancevibrator *dev; | 120 | struct trancevibrator *dev; |
121 | 121 | ||
122 | dev = usb_get_intfdata (interface); | 122 | dev = usb_get_intfdata (interface); |
123 | usb_set_intfdata(interface, NULL); | ||
124 | device_remove_file(&interface->dev, &dev_attr_speed); | 123 | device_remove_file(&interface->dev, &dev_attr_speed); |
124 | usb_set_intfdata(interface, NULL); | ||
125 | usb_put_dev(dev->udev); | 125 | usb_put_dev(dev->udev); |
126 | kfree(dev); | 126 | kfree(dev); |
127 | } | 127 | } |
diff --git a/drivers/usb/misc/uss720.c b/drivers/usb/misc/uss720.c index 7e8a0acd52ee..70250252ae2a 100644 --- a/drivers/usb/misc/uss720.c +++ b/drivers/usb/misc/uss720.c | |||
@@ -705,7 +705,7 @@ static int uss720_probe(struct usb_interface *intf, | |||
705 | /* | 705 | /* |
706 | * Allocate parport interface | 706 | * Allocate parport interface |
707 | */ | 707 | */ |
708 | if (!(priv = kcalloc(sizeof(struct parport_uss720_private), 1, GFP_KERNEL))) { | 708 | if (!(priv = kzalloc(sizeof(struct parport_uss720_private), GFP_KERNEL))) { |
709 | usb_put_dev(usbdev); | 709 | usb_put_dev(usbdev); |
710 | return -ENOMEM; | 710 | return -ENOMEM; |
711 | } | 711 | } |