Merge git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/usb-2.6

* git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/usb-2.6: (22 commits)
USB: gadget: f_mass_storage: stale common->fsg value bug fix
USB: gadget: f_mass_storage: fixed fs descriptors not being updated
USB: musb: Enable the maximum supported burst mode for DMA
USB: musb: fix Blackfin ulpi stubs
USB: MUSB: make non-OMAP platforms build with CONFIG_PM=y
USB: musb_core: make disconnect and suspend interrupts work again
USB: obey the sysfs power/wakeup setting
USB: gadget eth: Fix calculate CRC32 in EEM
USB: qcserial: fix a memory leak in qcprobe error path
USB: gadget/printer, fix sleep inside atomic
USB: isp1362-hcd, fix double lock
USB: serial: ftdi: correct merge conflict with CONTEC id
USB: fix oops in usb_sg_init()
USB: s3c2410: deactivate endpoints before gadget unbinding
USB: ehci-mxc: bail out on transceiver problems
USB: otg/ulpi: bail out on read errors
usb: musb: Fix a bug by making suspend interrupt available in device mode
USB: r8a66597: Fix failure in change of status
USB: xHCI: Fix bug in link TRB activation change.
USB: gadget: g_fs: possible invalid pointer reference bug fixed
...

+208 -224
+3 -10
drivers/usb/core/driver.c
··· 1272 1272 1273 1273 static void choose_wakeup(struct usb_device *udev, pm_message_t msg) 1274 1274 { 1275 - int w, i; 1276 - struct usb_interface *intf; 1275 + int w; 1277 1276 1278 1277 /* Remote wakeup is needed only when we actually go to sleep. 1279 1278 * For things like FREEZE and QUIESCE, if the device is already ··· 1284 1285 return; 1285 1286 } 1286 1287 1287 - /* If remote wakeup is permitted, see whether any interface drivers 1288 + /* Enable remote wakeup if it is allowed, even if no interface drivers 1288 1289 * actually want it. 1289 1290 */ 1290 - w = 0; 1291 - if (device_may_wakeup(&udev->dev) && udev->actconfig) { 1292 - for (i = 0; i < udev->actconfig->desc.bNumInterfaces; i++) { 1293 - intf = udev->actconfig->interface[i]; 1294 - w |= intf->needs_remote_wakeup; 1295 - } 1296 - } 1291 + w = device_may_wakeup(&udev->dev); 1297 1292 1298 1293 /* If the device is autosuspended with the wrong wakeup setting, 1299 1294 * autoresume now so the setting can be changed.
+5 -2
drivers/usb/core/message.c
··· 416 416 /* A length of zero means transfer the whole sg list */ 417 417 len = length; 418 418 if (len == 0) { 419 - for_each_sg(sg, sg, nents, i) 420 - len += sg->length; 419 + struct scatterlist *sg2; 420 + int j; 421 + 422 + for_each_sg(sg, sg2, nents, j) 423 + len += sg2->length; 421 424 } 422 425 } else { 423 426 /*
+1 -2
drivers/usb/gadget/f_eem.c
··· 469 469 crc = get_unaligned_le32(skb->data + len 470 470 - ETH_FCS_LEN); 471 471 crc2 = ~crc32_le(~0, 472 - skb->data, 473 - skb->len - ETH_FCS_LEN); 472 + skb->data, len - ETH_FCS_LEN); 474 473 } else { 475 474 crc = get_unaligned_be32(skb->data + len 476 475 - ETH_FCS_LEN);
+73 -121
drivers/usb/gadget/f_mass_storage.c
··· 321 321 /* Data shared by all the FSG instances. */ 322 322 struct fsg_common { 323 323 struct usb_gadget *gadget; 324 - struct fsg_dev *fsg; 325 - struct fsg_dev *prev_fsg; 324 + struct fsg_dev *fsg, *new_fsg; 325 + wait_queue_head_t fsg_wait; 326 326 327 327 /* filesem protects: backing files in use */ 328 328 struct rw_semaphore filesem; ··· 351 351 enum fsg_state state; /* For exception handling */ 352 352 unsigned int exception_req_tag; 353 353 354 - u8 config, new_config; 355 354 enum data_direction data_dir; 356 355 u32 data_size; 357 356 u32 data_size_from_cmnd; ··· 594 595 u16 w_value = le16_to_cpu(ctrl->wValue); 595 596 u16 w_length = le16_to_cpu(ctrl->wLength); 596 597 597 - if (!fsg->common->config) 598 + if (!fsg_is_set(fsg->common)) 598 599 return -EOPNOTSUPP; 599 600 600 601 switch (ctrl->bRequest) { ··· 2302 2303 return -ENOMEM; 2303 2304 } 2304 2305 2305 - /* 2306 - * Reset interface setting and re-init endpoint state (toggle etc). 2307 - * Call with altsetting < 0 to disable the interface. The only other 2308 - * available altsetting is 0, which enables the interface. 2309 - */ 2310 - static int do_set_interface(struct fsg_common *common, int altsetting) 2306 + /* Reset interface setting and re-init endpoint state (toggle etc). */ 2307 + static int do_set_interface(struct fsg_common *common, struct fsg_dev *new_fsg) 2311 2308 { 2312 - int rc = 0; 2313 - int i; 2314 - const struct usb_endpoint_descriptor *d; 2309 + const struct usb_endpoint_descriptor *d; 2310 + struct fsg_dev *fsg; 2311 + int i, rc = 0; 2315 2312 2316 2313 if (common->running) 2317 2314 DBG(common, "reset interface\n"); 2318 2315 2319 2316 reset: 2320 2317 /* Deallocate the requests */ 2321 - if (common->prev_fsg) { 2322 - struct fsg_dev *fsg = common->prev_fsg; 2318 + if (common->fsg) { 2319 + fsg = common->fsg; 2323 2320 2324 2321 for (i = 0; i < FSG_NUM_BUFFERS; ++i) { 2325 2322 struct fsg_buffhd *bh = &common->buffhds[i]; ··· 2340 2345 fsg->bulk_out_enabled = 0; 2341 2346 } 2342 2347 2343 - common->prev_fsg = 0; 2348 + common->fsg = NULL; 2349 + wake_up(&common->fsg_wait); 2344 2350 } 2345 2351 2346 2352 common->running = 0; 2347 - if (altsetting < 0 || rc != 0) 2353 + if (!new_fsg || rc) 2348 2354 return rc; 2349 2355 2350 - DBG(common, "set interface %d\n", altsetting); 2356 + common->fsg = new_fsg; 2357 + fsg = common->fsg; 2351 2358 2352 - if (fsg_is_set(common)) { 2353 - struct fsg_dev *fsg = common->fsg; 2354 - common->prev_fsg = common->fsg; 2359 + /* Enable the endpoints */ 2360 + d = fsg_ep_desc(common->gadget, 2361 + &fsg_fs_bulk_in_desc, &fsg_hs_bulk_in_desc); 2362 + rc = enable_endpoint(common, fsg->bulk_in, d); 2363 + if (rc) 2364 + goto reset; 2365 + fsg->bulk_in_enabled = 1; 2355 2366 2356 - /* Enable the endpoints */ 2357 - d = fsg_ep_desc(common->gadget, 2358 - &fsg_fs_bulk_in_desc, &fsg_hs_bulk_in_desc); 2359 - rc = enable_endpoint(common, fsg->bulk_in, d); 2367 + d = fsg_ep_desc(common->gadget, 2368 + &fsg_fs_bulk_out_desc, &fsg_hs_bulk_out_desc); 2369 + rc = enable_endpoint(common, fsg->bulk_out, d); 2370 + if (rc) 2371 + goto reset; 2372 + fsg->bulk_out_enabled = 1; 2373 + common->bulk_out_maxpacket = le16_to_cpu(d->wMaxPacketSize); 2374 + clear_bit(IGNORE_BULK_OUT, &fsg->atomic_bitflags); 2375 + 2376 + /* Allocate the requests */ 2377 + for (i = 0; i < FSG_NUM_BUFFERS; ++i) { 2378 + struct fsg_buffhd *bh = &common->buffhds[i]; 2379 + 2380 + rc = alloc_request(common, fsg->bulk_in, &bh->inreq); 2360 2381 if (rc) 2361 2382 goto reset; 2362 - fsg->bulk_in_enabled = 1; 2363 - 2364 - d = fsg_ep_desc(common->gadget, 2365 - &fsg_fs_bulk_out_desc, &fsg_hs_bulk_out_desc); 2366 - rc = enable_endpoint(common, fsg->bulk_out, d); 2383 + rc = alloc_request(common, fsg->bulk_out, &bh->outreq); 2367 2384 if (rc) 2368 2385 goto reset; 2369 - fsg->bulk_out_enabled = 1; 2370 - common->bulk_out_maxpacket = le16_to_cpu(d->wMaxPacketSize); 2371 - clear_bit(IGNORE_BULK_OUT, &fsg->atomic_bitflags); 2372 - 2373 - /* Allocate the requests */ 2374 - for (i = 0; i < FSG_NUM_BUFFERS; ++i) { 2375 - struct fsg_buffhd *bh = &common->buffhds[i]; 2376 - 2377 - rc = alloc_request(common, fsg->bulk_in, &bh->inreq); 2378 - if (rc) 2379 - goto reset; 2380 - rc = alloc_request(common, fsg->bulk_out, &bh->outreq); 2381 - if (rc) 2382 - goto reset; 2383 - bh->inreq->buf = bh->outreq->buf = bh->buf; 2384 - bh->inreq->context = bh->outreq->context = bh; 2385 - bh->inreq->complete = bulk_in_complete; 2386 - bh->outreq->complete = bulk_out_complete; 2387 - } 2388 - 2389 - common->running = 1; 2390 - for (i = 0; i < common->nluns; ++i) 2391 - common->luns[i].unit_attention_data = SS_RESET_OCCURRED; 2392 - return rc; 2393 - } else { 2394 - return -EIO; 2395 - } 2396 - } 2397 - 2398 - 2399 - /* 2400 - * Change our operational configuration. This code must agree with the code 2401 - * that returns config descriptors, and with interface altsetting code. 2402 - * 2403 - * It's also responsible for power management interactions. Some 2404 - * configurations might not work with our current power sources. 2405 - * For now we just assume the gadget is always self-powered. 2406 - */ 2407 - static int do_set_config(struct fsg_common *common, u8 new_config) 2408 - { 2409 - int rc = 0; 2410 - 2411 - /* Disable the single interface */ 2412 - if (common->config != 0) { 2413 - DBG(common, "reset config\n"); 2414 - common->config = 0; 2415 - rc = do_set_interface(common, -1); 2386 + bh->inreq->buf = bh->outreq->buf = bh->buf; 2387 + bh->inreq->context = bh->outreq->context = bh; 2388 + bh->inreq->complete = bulk_in_complete; 2389 + bh->outreq->complete = bulk_out_complete; 2416 2390 } 2417 2391 2418 - /* Enable the interface */ 2419 - if (new_config != 0) { 2420 - common->config = new_config; 2421 - rc = do_set_interface(common, 0); 2422 - if (rc != 0) 2423 - common->config = 0; /* Reset on errors */ 2424 - } 2392 + common->running = 1; 2393 + for (i = 0; i < common->nluns; ++i) 2394 + common->luns[i].unit_attention_data = SS_RESET_OCCURRED; 2425 2395 return rc; 2426 2396 } 2427 2397 ··· 2397 2437 static int fsg_set_alt(struct usb_function *f, unsigned intf, unsigned alt) 2398 2438 { 2399 2439 struct fsg_dev *fsg = fsg_from_func(f); 2400 - fsg->common->prev_fsg = fsg->common->fsg; 2401 - fsg->common->fsg = fsg; 2402 - fsg->common->new_config = 1; 2440 + fsg->common->new_fsg = fsg; 2403 2441 raise_exception(fsg->common, FSG_STATE_CONFIG_CHANGE); 2404 2442 return 0; 2405 2443 } ··· 2405 2447 static void fsg_disable(struct usb_function *f) 2406 2448 { 2407 2449 struct fsg_dev *fsg = fsg_from_func(f); 2408 - fsg->common->prev_fsg = fsg->common->fsg; 2409 - fsg->common->fsg = fsg; 2410 - fsg->common->new_config = 0; 2450 + fsg->common->new_fsg = NULL; 2411 2451 raise_exception(fsg->common, FSG_STATE_CONFIG_CHANGE); 2412 2452 } 2413 2453 ··· 2415 2459 static void handle_exception(struct fsg_common *common) 2416 2460 { 2417 2461 siginfo_t info; 2418 - int sig; 2419 2462 int i; 2420 2463 struct fsg_buffhd *bh; 2421 2464 enum fsg_state old_state; 2422 - u8 new_config; 2423 2465 struct fsg_lun *curlun; 2424 2466 unsigned int exception_req_tag; 2425 - int rc; 2426 2467 2427 2468 /* Clear the existing signals. Anything but SIGUSR1 is converted 2428 2469 * into a high-priority EXIT exception. */ 2429 2470 for (;;) { 2430 - sig = dequeue_signal_lock(current, &current->blocked, &info); 2471 + int sig = 2472 + dequeue_signal_lock(current, &current->blocked, &info); 2431 2473 if (!sig) 2432 2474 break; 2433 2475 if (sig != SIGUSR1) { ··· 2436 2482 } 2437 2483 2438 2484 /* Cancel all the pending transfers */ 2439 - if (fsg_is_set(common)) { 2485 + if (likely(common->fsg)) { 2440 2486 for (i = 0; i < FSG_NUM_BUFFERS; ++i) { 2441 2487 bh = &common->buffhds[i]; 2442 2488 if (bh->inreq_busy) ··· 2477 2523 common->next_buffhd_to_fill = &common->buffhds[0]; 2478 2524 common->next_buffhd_to_drain = &common->buffhds[0]; 2479 2525 exception_req_tag = common->exception_req_tag; 2480 - new_config = common->new_config; 2481 2526 old_state = common->state; 2482 2527 2483 2528 if (old_state == FSG_STATE_ABORT_BULK_OUT) ··· 2526 2573 break; 2527 2574 2528 2575 case FSG_STATE_CONFIG_CHANGE: 2529 - rc = do_set_config(common, new_config); 2576 + do_set_interface(common, common->new_fsg); 2530 2577 break; 2531 2578 2532 2579 case FSG_STATE_EXIT: 2533 2580 case FSG_STATE_TERMINATED: 2534 - do_set_config(common, 0); /* Free resources */ 2581 + do_set_interface(common, NULL); /* Free resources */ 2535 2582 spin_lock_irq(&common->lock); 2536 2583 common->state = FSG_STATE_TERMINATED; /* Stop the thread */ 2537 2584 spin_unlock_irq(&common->lock); ··· 2816 2863 goto error_release; 2817 2864 } 2818 2865 init_completion(&common->thread_notifier); 2866 + init_waitqueue_head(&common->fsg_wait); 2819 2867 #undef OR 2820 2868 2821 2869 ··· 2911 2957 static void fsg_unbind(struct usb_configuration *c, struct usb_function *f) 2912 2958 { 2913 2959 struct fsg_dev *fsg = fsg_from_func(f); 2960 + struct fsg_common *common = fsg->common; 2914 2961 2915 2962 DBG(fsg, "unbind\n"); 2916 - fsg_common_put(fsg->common); 2963 + if (fsg->common->fsg == fsg) { 2964 + fsg->common->new_fsg = NULL; 2965 + raise_exception(fsg->common, FSG_STATE_CONFIG_CHANGE); 2966 + /* FIXME: make interruptible or killable somehow? */ 2967 + wait_event(common->fsg_wait, common->fsg != fsg); 2968 + } 2969 + 2970 + fsg_common_put(common); 2917 2971 usb_free_descriptors(fsg->function.descriptors); 2918 2972 usb_free_descriptors(fsg->function.hs_descriptors); 2919 2973 kfree(fsg); ··· 2932 2970 { 2933 2971 struct fsg_dev *fsg = fsg_from_func(f); 2934 2972 struct usb_gadget *gadget = c->cdev->gadget; 2935 - int rc; 2936 2973 int i; 2937 2974 struct usb_ep *ep; 2938 2975 ··· 2957 2996 ep->driver_data = fsg->common; /* claim the endpoint */ 2958 2997 fsg->bulk_out = ep; 2959 2998 2999 + /* Copy descriptors */ 3000 + f->descriptors = usb_copy_descriptors(fsg_fs_function); 3001 + if (unlikely(!f->descriptors)) 3002 + return -ENOMEM; 3003 + 2960 3004 if (gadget_is_dualspeed(gadget)) { 2961 3005 /* Assume endpoint addresses are the same for both speeds */ 2962 3006 fsg_hs_bulk_in_desc.bEndpointAddress = ··· 2969 3003 fsg_hs_bulk_out_desc.bEndpointAddress = 2970 3004 fsg_fs_bulk_out_desc.bEndpointAddress; 2971 3005 f->hs_descriptors = usb_copy_descriptors(fsg_hs_function); 2972 - if (unlikely(!f->hs_descriptors)) 3006 + if (unlikely(!f->hs_descriptors)) { 3007 + usb_free_descriptors(f->descriptors); 2973 3008 return -ENOMEM; 3009 + } 2974 3010 } 2975 3011 2976 3012 return 0; 2977 3013 2978 3014 autoconf_fail: 2979 3015 ERROR(fsg, "unable to autoconfigure all endpoints\n"); 2980 - rc = -ENOTSUPP; 2981 - return rc; 3016 + return -ENOTSUPP; 2982 3017 } 2983 3018 2984 3019 ··· 3003 3036 3004 3037 fsg->function.name = FSG_DRIVER_DESC; 3005 3038 fsg->function.strings = fsg_strings_array; 3006 - fsg->function.descriptors = usb_copy_descriptors(fsg_fs_function); 3007 - if (unlikely(!fsg->function.descriptors)) { 3008 - rc = -ENOMEM; 3009 - goto error_free_fsg; 3010 - } 3011 3039 fsg->function.bind = fsg_bind; 3012 3040 fsg->function.unbind = fsg_unbind; 3013 3041 fsg->function.setup = fsg_setup; ··· 3018 3056 3019 3057 rc = usb_add_function(c, &fsg->function); 3020 3058 if (unlikely(rc)) 3021 - goto error_free_all; 3022 - 3023 - fsg_common_get(fsg->common); 3024 - return 0; 3025 - 3026 - error_free_all: 3027 - usb_free_descriptors(fsg->function.descriptors); 3028 - /* fsg_bind() might have copied those; or maybe not? who cares 3029 - * -- free it just in case. */ 3030 - usb_free_descriptors(fsg->function.hs_descriptors); 3031 - error_free_fsg: 3032 - kfree(fsg); 3033 - 3059 + kfree(fsg); 3060 + else 3061 + fsg_common_get(fsg->common); 3034 3062 return rc; 3035 3063 } 3036 3064
+11
drivers/usb/gadget/g_ffs.c
··· 392 392 if (unlikely(ret < 0)) 393 393 return ret; 394 394 395 + /* After previous do_configs there may be some invalid 396 + * pointers in c->interface array. This happens every time 397 + * a user space function with fewer interfaces than a user 398 + * space function that was run before the new one is run. The 399 + * compasit's set_config() assumes that if there is no more 400 + * then MAX_CONFIG_INTERFACES interfaces in a configuration 401 + * then there is a NULL pointer after the last interface in 402 + * c->interface array. We need to make sure this is true. */ 403 + if (c->next_interface_id < ARRAY_SIZE(c->interface)) 404 + c->interface[c->next_interface_id] = NULL; 405 + 395 406 return 0; 396 407 } 397 408
+16 -16
drivers/usb/gadget/printer.c
··· 82 82 struct printer_dev { 83 83 spinlock_t lock; /* lock this structure */ 84 84 /* lock buffer lists during read/write calls */ 85 - spinlock_t lock_printer_io; 85 + struct mutex lock_printer_io; 86 86 struct usb_gadget *gadget; 87 87 struct usb_request *req; /* for control responses */ 88 88 u8 config; ··· 567 567 568 568 DBG(dev, "printer_read trying to read %d bytes\n", (int)len); 569 569 570 - spin_lock(&dev->lock_printer_io); 570 + mutex_lock(&dev->lock_printer_io); 571 571 spin_lock_irqsave(&dev->lock, flags); 572 572 573 573 /* We will use this flag later to check if a printer reset happened ··· 601 601 * call or not. 602 602 */ 603 603 if (fd->f_flags & (O_NONBLOCK|O_NDELAY)) { 604 - spin_unlock(&dev->lock_printer_io); 604 + mutex_unlock(&dev->lock_printer_io); 605 605 return -EAGAIN; 606 606 } 607 607 ··· 648 648 if (dev->reset_printer) { 649 649 list_add(&current_rx_req->list, &dev->rx_reqs); 650 650 spin_unlock_irqrestore(&dev->lock, flags); 651 - spin_unlock(&dev->lock_printer_io); 651 + mutex_unlock(&dev->lock_printer_io); 652 652 return -EAGAIN; 653 653 } 654 654 ··· 673 673 dev->current_rx_buf = current_rx_buf; 674 674 675 675 spin_unlock_irqrestore(&dev->lock, flags); 676 - spin_unlock(&dev->lock_printer_io); 676 + mutex_unlock(&dev->lock_printer_io); 677 677 678 678 DBG(dev, "printer_read returned %d bytes\n", (int)bytes_copied); 679 679 ··· 697 697 if (len == 0) 698 698 return -EINVAL; 699 699 700 - spin_lock(&dev->lock_printer_io); 700 + mutex_lock(&dev->lock_printer_io); 701 701 spin_lock_irqsave(&dev->lock, flags); 702 702 703 703 /* Check if a printer reset happens while we have interrupts on */ ··· 713 713 * a NON-Blocking call or not. 714 714 */ 715 715 if (fd->f_flags & (O_NONBLOCK|O_NDELAY)) { 716 - spin_unlock(&dev->lock_printer_io); 716 + mutex_unlock(&dev->lock_printer_io); 717 717 return -EAGAIN; 718 718 } 719 719 ··· 752 752 753 753 if (copy_from_user(req->buf, buf, size)) { 754 754 list_add(&req->list, &dev->tx_reqs); 755 - spin_unlock(&dev->lock_printer_io); 755 + mutex_unlock(&dev->lock_printer_io); 756 756 return bytes_copied; 757 757 } 758 758 ··· 766 766 if (dev->reset_printer) { 767 767 list_add(&req->list, &dev->tx_reqs); 768 768 spin_unlock_irqrestore(&dev->lock, flags); 769 - spin_unlock(&dev->lock_printer_io); 769 + mutex_unlock(&dev->lock_printer_io); 770 770 return -EAGAIN; 771 771 } 772 772 773 773 if (usb_ep_queue(dev->in_ep, req, GFP_ATOMIC)) { 774 774 list_add(&req->list, &dev->tx_reqs); 775 775 spin_unlock_irqrestore(&dev->lock, flags); 776 - spin_unlock(&dev->lock_printer_io); 776 + mutex_unlock(&dev->lock_printer_io); 777 777 return -EAGAIN; 778 778 } 779 779 ··· 782 782 } 783 783 784 784 spin_unlock_irqrestore(&dev->lock, flags); 785 - spin_unlock(&dev->lock_printer_io); 785 + mutex_unlock(&dev->lock_printer_io); 786 786 787 787 DBG(dev, "printer_write sent %d bytes\n", (int)bytes_copied); 788 788 ··· 820 820 unsigned long flags; 821 821 int status = 0; 822 822 823 - spin_lock(&dev->lock_printer_io); 823 + mutex_lock(&dev->lock_printer_io); 824 824 spin_lock_irqsave(&dev->lock, flags); 825 825 setup_rx_reqs(dev); 826 826 spin_unlock_irqrestore(&dev->lock, flags); 827 - spin_unlock(&dev->lock_printer_io); 827 + mutex_unlock(&dev->lock_printer_io); 828 828 829 829 poll_wait(fd, &dev->rx_wait, wait); 830 830 poll_wait(fd, &dev->tx_wait, wait); ··· 1461 1461 } 1462 1462 1463 1463 spin_lock_init(&dev->lock); 1464 - spin_lock_init(&dev->lock_printer_io); 1464 + mutex_init(&dev->lock_printer_io); 1465 1465 INIT_LIST_HEAD(&dev->tx_reqs); 1466 1466 INIT_LIST_HEAD(&dev->tx_reqs_active); 1467 1467 INIT_LIST_HEAD(&dev->rx_reqs); ··· 1594 1594 { 1595 1595 int status; 1596 1596 1597 - spin_lock(&usb_printer_gadget.lock_printer_io); 1597 + mutex_lock(&usb_printer_gadget.lock_printer_io); 1598 1598 class_destroy(usb_gadget_class); 1599 1599 unregister_chrdev_region(g_printer_devno, 2); 1600 1600 ··· 1602 1602 if (status) 1603 1603 ERROR(dev, "usb_gadget_unregister_driver %x\n", status); 1604 1604 1605 - spin_unlock(&usb_printer_gadget.lock_printer_io); 1605 + mutex_unlock(&usb_printer_gadget.lock_printer_io); 1606 1606 } 1607 1607 module_exit(cleanup);
+5 -1
drivers/usb/gadget/s3c2410_udc.c
··· 1700 1700 if (!driver || driver != udc->driver || !driver->unbind) 1701 1701 return -EINVAL; 1702 1702 1703 - dprintk(DEBUG_NORMAL,"usb_gadget_register_driver() '%s'\n", 1703 + dprintk(DEBUG_NORMAL, "usb_gadget_unregister_driver() '%s'\n", 1704 1704 driver->driver.name); 1705 + 1706 + /* report disconnect */ 1707 + if (driver->disconnect) 1708 + driver->disconnect(&udc->gadget); 1705 1709 1706 1710 driver->unbind(&udc->gadget); 1707 1711
+3 -13
drivers/usb/gadget/u_serial.c
··· 536 536 list_move(&req->list, &port->read_pool); 537 537 } 538 538 539 - /* Push from tty to ldisc; this is immediate with low_latency, and 540 - * may trigger callbacks to this driver ... so drop the spinlock. 539 + /* Push from tty to ldisc; without low_latency set this is handled by 540 + * a workqueue, so we won't get callbacks and can hold port_lock 541 541 */ 542 542 if (tty && do_push) { 543 - spin_unlock_irq(&port->port_lock); 544 543 tty_flip_buffer_push(tty); 545 - wake_up_interruptible(&tty->read_wait); 546 - spin_lock_irq(&port->port_lock); 547 - 548 - /* tty may have been closed */ 549 - tty = port->port_tty; 550 544 } 551 545 552 546 ··· 777 783 778 784 port->open_count = 1; 779 785 port->openclose = false; 780 - 781 - /* low_latency means ldiscs work in tasklet context, without 782 - * needing a workqueue schedule ... easier to keep up. 783 - */ 784 - tty->low_latency = 1; 785 786 786 787 /* if connected, start the I/O stream */ 787 788 if (port->port_usb) { ··· 1184 1195 n_ports = 0; 1185 1196 1186 1197 tty_unregister_driver(gs_tty_driver); 1198 + put_tty_driver(gs_tty_driver); 1187 1199 gs_tty_driver = NULL; 1188 1200 1189 1201 pr_debug("%s: cleaned up ttyGS* support\n", __func__);
+10 -3
drivers/usb/host/ehci-mxc.c
··· 207 207 /* Initialize the transceiver */ 208 208 if (pdata->otg) { 209 209 pdata->otg->io_priv = hcd->regs + ULPI_VIEWPORT_OFFSET; 210 - if (otg_init(pdata->otg) != 0) 211 - dev_err(dev, "unable to init transceiver\n"); 212 - else if (otg_set_vbus(pdata->otg, 1) != 0) 210 + ret = otg_init(pdata->otg); 211 + if (ret) { 212 + dev_err(dev, "unable to init transceiver, probably missing\n"); 213 + ret = -ENODEV; 214 + goto err_add; 215 + } 216 + ret = otg_set_vbus(pdata->otg, 1); 217 + if (ret) { 213 218 dev_err(dev, "unable to enable vbus on transceiver\n"); 219 + goto err_add; 220 + } 214 221 } 215 222 216 223 priv->hcd = hcd;
+10 -5
drivers/usb/host/isp1362-hcd.c
··· 2224 2224 2225 2225 /*-------------------------------------------------------------------------*/ 2226 2226 2227 - static void isp1362_sw_reset(struct isp1362_hcd *isp1362_hcd) 2227 + static void __isp1362_sw_reset(struct isp1362_hcd *isp1362_hcd) 2228 2228 { 2229 2229 int tmp = 20; 2230 - unsigned long flags; 2231 - 2232 - spin_lock_irqsave(&isp1362_hcd->lock, flags); 2233 2230 2234 2231 isp1362_write_reg16(isp1362_hcd, HCSWRES, HCSWRES_MAGIC); 2235 2232 isp1362_write_reg32(isp1362_hcd, HCCMDSTAT, OHCI_HCR); ··· 2237 2240 } 2238 2241 if (!tmp) 2239 2242 pr_err("Software reset timeout\n"); 2243 + } 2244 + 2245 + static void isp1362_sw_reset(struct isp1362_hcd *isp1362_hcd) 2246 + { 2247 + unsigned long flags; 2248 + 2249 + spin_lock_irqsave(&isp1362_hcd->lock, flags); 2250 + __isp1362_sw_reset(isp1362_hcd); 2240 2251 spin_unlock_irqrestore(&isp1362_hcd->lock, flags); 2241 2252 } 2242 2253 ··· 2423 2418 if (isp1362_hcd->board && isp1362_hcd->board->reset) 2424 2419 isp1362_hcd->board->reset(hcd->self.controller, 1); 2425 2420 else 2426 - isp1362_sw_reset(isp1362_hcd); 2421 + __isp1362_sw_reset(isp1362_hcd); 2427 2422 2428 2423 if (isp1362_hcd->board && isp1362_hcd->board->clock) 2429 2424 isp1362_hcd->board->clock(hcd->self.controller, 0);
+1 -1
drivers/usb/host/r8a66597-hcd.c
··· 1065 1065 else if (speed == LSMODE) 1066 1066 rh->port |= USB_PORT_STAT_LOW_SPEED; 1067 1067 1068 - rh->port &= USB_PORT_STAT_RESET; 1068 + rh->port &= ~USB_PORT_STAT_RESET; 1069 1069 rh->port |= USB_PORT_STAT_ENABLE; 1070 1070 } 1071 1071
+46 -16
drivers/usb/host/xhci-ring.c
··· 182 182 * set, but other sections talk about dealing with the chain bit set. This was 183 183 * fixed in the 0.96 specification errata, but we have to assume that all 0.95 184 184 * xHCI hardware can't handle the chain bit being cleared on a link TRB. 185 + * 186 + * @more_trbs_coming: Will you enqueue more TRBs before calling 187 + * prepare_transfer()? 185 188 */ 186 - static void inc_enq(struct xhci_hcd *xhci, struct xhci_ring *ring, bool consumer) 189 + static void inc_enq(struct xhci_hcd *xhci, struct xhci_ring *ring, 190 + bool consumer, bool more_trbs_coming) 187 191 { 188 192 u32 chain; 189 193 union xhci_trb *next; ··· 203 199 while (last_trb(xhci, ring, ring->enq_seg, next)) { 204 200 if (!consumer) { 205 201 if (ring != xhci->event_ring) { 206 - if (chain) { 207 - next->link.control |= TRB_CHAIN; 208 - 209 - /* Give this link TRB to the hardware */ 210 - wmb(); 211 - next->link.control ^= TRB_CYCLE; 212 - } else { 202 + /* 203 + * If the caller doesn't plan on enqueueing more 204 + * TDs before ringing the doorbell, then we 205 + * don't want to give the link TRB to the 206 + * hardware just yet. We'll give the link TRB 207 + * back in prepare_ring() just before we enqueue 208 + * the TD at the top of the ring. 209 + */ 210 + if (!chain && !more_trbs_coming) 213 211 break; 212 + 213 + /* If we're not dealing with 0.95 hardware, 214 + * carry over the chain bit of the previous TRB 215 + * (which may mean the chain bit is cleared). 216 + */ 217 + if (!xhci_link_trb_quirk(xhci)) { 218 + next->link.control &= ~TRB_CHAIN; 219 + next->link.control |= chain; 214 220 } 221 + /* Give this link TRB to the hardware */ 222 + wmb(); 223 + next->link.control ^= TRB_CYCLE; 215 224 } 216 225 /* Toggle the cycle bit after the last ring segment. */ 217 226 if (last_trb_on_last_seg(xhci, ring, ring->enq_seg, next)) { ··· 1724 1707 /* 1725 1708 * Generic function for queueing a TRB on a ring. 1726 1709 * The caller must have checked to make sure there's room on the ring. 1710 + * 1711 + * @more_trbs_coming: Will you enqueue more TRBs before calling 1712 + * prepare_transfer()? 1727 1713 */ 1728 1714 static void queue_trb(struct xhci_hcd *xhci, struct xhci_ring *ring, 1729 - bool consumer, 1715 + bool consumer, bool more_trbs_coming, 1730 1716 u32 field1, u32 field2, u32 field3, u32 field4) 1731 1717 { 1732 1718 struct xhci_generic_trb *trb; ··· 1739 1719 trb->field[1] = field2; 1740 1720 trb->field[2] = field3; 1741 1721 trb->field[3] = field4; 1742 - inc_enq(xhci, ring, consumer); 1722 + inc_enq(xhci, ring, consumer, more_trbs_coming); 1743 1723 } 1744 1724 1745 1725 /* ··· 2008 1988 int trb_buff_len, this_sg_len, running_total; 2009 1989 bool first_trb; 2010 1990 u64 addr; 1991 + bool more_trbs_coming; 2011 1992 2012 1993 struct xhci_generic_trb *start_trb; 2013 1994 int start_cycle; ··· 2094 2073 length_field = TRB_LEN(trb_buff_len) | 2095 2074 remainder | 2096 2075 TRB_INTR_TARGET(0); 2097 - queue_trb(xhci, ep_ring, false, 2076 + if (num_trbs > 1) 2077 + more_trbs_coming = true; 2078 + else 2079 + more_trbs_coming = false; 2080 + queue_trb(xhci, ep_ring, false, more_trbs_coming, 2098 2081 lower_32_bits(addr), 2099 2082 upper_32_bits(addr), 2100 2083 length_field, ··· 2149 2124 int num_trbs; 2150 2125 struct xhci_generic_trb *start_trb; 2151 2126 bool first_trb; 2127 + bool more_trbs_coming; 2152 2128 int start_cycle; 2153 2129 u32 field, length_field; 2154 2130 ··· 2238 2212 length_field = TRB_LEN(trb_buff_len) | 2239 2213 remainder | 2240 2214 TRB_INTR_TARGET(0); 2241 - queue_trb(xhci, ep_ring, false, 2215 + if (num_trbs > 1) 2216 + more_trbs_coming = true; 2217 + else 2218 + more_trbs_coming = false; 2219 + queue_trb(xhci, ep_ring, false, more_trbs_coming, 2242 2220 lower_32_bits(addr), 2243 2221 upper_32_bits(addr), 2244 2222 length_field, ··· 2321 2291 /* Queue setup TRB - see section 6.4.1.2.1 */ 2322 2292 /* FIXME better way to translate setup_packet into two u32 fields? */ 2323 2293 setup = (struct usb_ctrlrequest *) urb->setup_packet; 2324 - queue_trb(xhci, ep_ring, false, 2294 + queue_trb(xhci, ep_ring, false, true, 2325 2295 /* FIXME endianness is probably going to bite my ass here. */ 2326 2296 setup->bRequestType | setup->bRequest << 8 | setup->wValue << 16, 2327 2297 setup->wIndex | setup->wLength << 16, ··· 2337 2307 if (urb->transfer_buffer_length > 0) { 2338 2308 if (setup->bRequestType & USB_DIR_IN) 2339 2309 field |= TRB_DIR_IN; 2340 - queue_trb(xhci, ep_ring, false, 2310 + queue_trb(xhci, ep_ring, false, true, 2341 2311 lower_32_bits(urb->transfer_dma), 2342 2312 upper_32_bits(urb->transfer_dma), 2343 2313 length_field, ··· 2354 2324 field = 0; 2355 2325 else 2356 2326 field = TRB_DIR_IN; 2357 - queue_trb(xhci, ep_ring, false, 2327 + queue_trb(xhci, ep_ring, false, false, 2358 2328 0, 2359 2329 0, 2360 2330 TRB_INTR_TARGET(0), ··· 2391 2361 "unfailable commands failed.\n"); 2392 2362 return -ENOMEM; 2393 2363 } 2394 - queue_trb(xhci, xhci->cmd_ring, false, field1, field2, field3, 2364 + queue_trb(xhci, xhci->cmd_ring, false, false, field1, field2, field3, 2395 2365 field4 | xhci->cmd_ring->cycle_state); 2396 2366 return 0; 2397 2367 }
+5 -8
drivers/usb/musb/musb_core.c
··· 219 219 return 0; 220 220 } 221 221 #else 222 - #define musb_ulpi_read(a, b) NULL 223 - #define musb_ulpi_write(a, b, c) NULL 222 + #define musb_ulpi_read NULL 223 + #define musb_ulpi_write NULL 224 224 #endif 225 225 226 226 static struct otg_io_access_ops musb_ulpi_access = { ··· 451 451 * @param power 452 452 */ 453 453 454 - #define STAGE0_MASK (MUSB_INTR_RESUME | MUSB_INTR_SESSREQ \ 455 - | MUSB_INTR_VBUSERROR | MUSB_INTR_CONNECT \ 456 - | MUSB_INTR_RESET) 457 - 458 454 static irqreturn_t musb_stage0_irq(struct musb *musb, u8 int_usb, 459 455 u8 devctl, u8 power) 460 456 { ··· 638 642 handled = IRQ_HANDLED; 639 643 } 640 644 641 - 645 + #endif 642 646 if (int_usb & MUSB_INTR_SUSPEND) { 643 647 DBG(1, "SUSPEND (%s) devctl %02x power %02x\n", 644 648 otg_state_string(musb), devctl, power); ··· 701 705 } 702 706 } 703 707 708 + #ifdef CONFIG_USB_MUSB_HDRC_HCD 704 709 if (int_usb & MUSB_INTR_CONNECT) { 705 710 struct usb_hcd *hcd = musb_to_hcd(musb); 706 711 void __iomem *mbase = musb->mregs; ··· 1594 1597 /* the core can interrupt us for multiple reasons; docs have 1595 1598 * a generic interrupt flowchart to follow 1596 1599 */ 1597 - if (musb->int_usb & STAGE0_MASK) 1600 + if (musb->int_usb) 1598 1601 retval |= musb_stage0_irq(musb, musb->int_usb, 1599 1602 devctl, power); 1600 1603
+4 -2
drivers/usb/musb/musb_core.h
··· 470 470 471 471 struct musb_context_registers { 472 472 473 - #ifdef CONFIG_PM 473 + #if defined(CONFIG_ARCH_OMAP2430) || defined(CONFIG_ARCH_OMAP3) || \ 474 + defined(CONFIG_ARCH_OMAP4) 474 475 u32 otg_sysconfig, otg_forcestandby; 475 476 #endif 476 477 u8 power; ··· 485 484 struct musb_csr_regs index_regs[MUSB_C_NUM_EPS]; 486 485 }; 487 486 488 - #ifdef CONFIG_PM 487 + #if defined(CONFIG_ARCH_OMAP2430) || defined(CONFIG_ARCH_OMAP3) || \ 488 + defined(CONFIG_ARCH_OMAP4) 489 489 extern void musb_platform_save_context(struct musb *musb, 490 490 struct musb_context_registers *musb_context); 491 491 extern void musb_platform_restore_context(struct musb *musb,
+2 -11
drivers/usb/musb/musbhsdma.c
··· 132 132 if (mode) { 133 133 csr |= 1 << MUSB_HSDMA_MODE1_SHIFT; 134 134 BUG_ON(len < packet_sz); 135 - 136 - if (packet_sz >= 64) { 137 - csr |= MUSB_HSDMA_BURSTMODE_INCR16 138 - << MUSB_HSDMA_BURSTMODE_SHIFT; 139 - } else if (packet_sz >= 32) { 140 - csr |= MUSB_HSDMA_BURSTMODE_INCR8 141 - << MUSB_HSDMA_BURSTMODE_SHIFT; 142 - } else if (packet_sz >= 16) { 143 - csr |= MUSB_HSDMA_BURSTMODE_INCR4 144 - << MUSB_HSDMA_BURSTMODE_SHIFT; 145 - } 146 135 } 136 + csr |= MUSB_HSDMA_BURSTMODE_INCR16 137 + << MUSB_HSDMA_BURSTMODE_SHIFT; 147 138 148 139 csr |= (musb_channel->epnum << MUSB_HSDMA_ENDPOINT_SHIFT) 149 140 | (1 << MUSB_HSDMA_ENABLE_SHIFT)
+10 -5
drivers/usb/otg/ulpi.c
··· 59 59 60 60 static int ulpi_init(struct otg_transceiver *otg) 61 61 { 62 - int i, vid, pid; 62 + int i, vid, pid, ret; 63 + u32 ulpi_id = 0; 63 64 64 - vid = (otg_io_read(otg, ULPI_VENDOR_ID_HIGH) << 8) | 65 - otg_io_read(otg, ULPI_VENDOR_ID_LOW); 66 - pid = (otg_io_read(otg, ULPI_PRODUCT_ID_HIGH) << 8) | 67 - otg_io_read(otg, ULPI_PRODUCT_ID_LOW); 65 + for (i = 0; i < 4; i++) { 66 + ret = otg_io_read(otg, ULPI_PRODUCT_ID_HIGH - i); 67 + if (ret < 0) 68 + return ret; 69 + ulpi_id = (ulpi_id << 8) | ret; 70 + } 71 + vid = ulpi_id & 0xffff; 72 + pid = ulpi_id >> 16; 68 73 69 74 pr_info("ULPI transceiver vendor/product ID 0x%04x/0x%04x\n", vid, pid); 70 75
-1
drivers/usb/serial/ftdi_sio.c
··· 653 653 { USB_DEVICE(EVOLUTION_VID, EVOLUTION_ER1_PID) }, 654 654 { USB_DEVICE(EVOLUTION_VID, EVO_HYBRID_PID) }, 655 655 { USB_DEVICE(EVOLUTION_VID, EVO_RCM4_PID) }, 656 - { USB_DEVICE(CONTEC_VID, CONTEC_COM1USBH_PID) }, 657 656 { USB_DEVICE(FTDI_VID, FTDI_ARTEMIS_PID) }, 658 657 { USB_DEVICE(FTDI_VID, FTDI_ATIK_ATK16_PID) }, 659 658 { USB_DEVICE(FTDI_VID, FTDI_ATIK_ATK16C_PID) },
-7
drivers/usb/serial/ftdi_sio_ids.h
··· 501 501 #define CONTEC_COM1USBH_PID 0x8311 /* COM-1(USB)H */ 502 502 503 503 /* 504 - * Contec products (http://www.contec.com) 505 - * Submitted by Daniel Sangorrin 506 - */ 507 - #define CONTEC_VID 0x06CE /* Vendor ID */ 508 - #define CONTEC_COM1USBH_PID 0x8311 /* COM-1(USB)H */ 509 - 510 - /* 511 504 * Definitions for B&B Electronics products. 512 505 */ 513 506 #define BANDB_VID 0x0856 /* B&B Electronics Vendor ID */
+3
drivers/usb/serial/qcserial.c
··· 139 139 "Could not set interface, error %d\n", 140 140 retval); 141 141 retval = -ENODEV; 142 + kfree(data); 142 143 } 143 144 return retval; 144 145 } ··· 156 155 "Could not set interface, error %d\n", 157 156 retval); 158 157 retval = -ENODEV; 158 + kfree(data); 159 159 } 160 160 return retval; 161 161 } ··· 165 163 default: 166 164 dev_err(&serial->dev->dev, 167 165 "unknown number of interfaces: %d\n", nintf); 166 + kfree(data); 168 167 return -ENODEV; 169 168 } 170 169