Showing error 533

User: Jiri Slaby
Error type: Calling function from invalid context
Error type description: Some function is called at inappropriate place like sleep inside critical sections or interrupt handlers
File location: drivers/usb/gadget/printer.c
Line in file: 721
Project: Linux Kernel
Project version: 2.6.28
Tools: Stanse (1.2)
Entered: 2011-11-07 22:19:02 UTC


Source:

 691        size_t                        size;        /* Amount of data in a TX request. */
 692        size_t                        bytes_copied = 0;
 693        struct usb_request        *req;
 694
 695        DBG(dev, "printer_write trying to send %d bytes\n", (int)len);
 696
 697        if (len == 0)
 698                return -EINVAL;
 699
 700        spin_lock(&dev->lock_printer_io);
 701        spin_lock_irqsave(&dev->lock, flags);
 702
 703        /* Check if a printer reset happens while we have interrupts on */
 704        dev->reset_printer = 0;
 705
 706        /* Check if there is any available write buffers */
 707        if (likely(list_empty(&dev->tx_reqs))) {
 708                /* Turn interrupts back on before sleeping. */
 709                spin_unlock_irqrestore(&dev->lock, flags);
 710
 711                /*
 712                 * If write buffers are available check if this is
 713                 * a NON-Blocking call or not.
 714                 */
 715                if (fd->f_flags & (O_NONBLOCK|O_NDELAY)) {
 716                        spin_unlock(&dev->lock_printer_io);
 717                        return -EAGAIN;
 718                }
 719
 720                /* Sleep until a write buffer is available */
 721                wait_event_interruptible(dev->tx_wait,
 722                                (likely(!list_empty(&dev->tx_reqs))));
 723                spin_lock_irqsave(&dev->lock, flags);
 724        }
 725
 726        while (likely(!list_empty(&dev->tx_reqs)) && len) {
 727
 728                if (len > USB_BUFSIZE)
 729                        size = USB_BUFSIZE;
 730                else
 731                        size = len;
Show full sources