Пример #1
0
void usb_serial_generic_read_bulk_callback(struct urb *urb)
{
	struct usb_serial_port *port = urb->context;
	unsigned char *data = urb->transfer_buffer;
	int status = urb->status;
	unsigned long flags;

	dbg("%s - port %d", __func__, port->number);

	if (unlikely(status != 0)) {
		dbg("%s - nonzero read bulk status received: %d",
		    __func__, status);
		return;
	}

	usb_serial_debug_data(debug, &port->dev, __func__,
						urb->actual_length, data);

	/* Throttle the device if requested by tty */
	spin_lock_irqsave(&port->lock, flags);
	port->throttled = port->throttle_req;
	if (!port->throttled) {
		spin_unlock_irqrestore(&port->lock, flags);
		flush_and_resubmit_read_urb(port);
	} else
		spin_unlock_irqrestore(&port->lock, flags);
}
Пример #2
0
void usb_serial_generic_read_bulk_callback (struct urb *urb)
{
	struct usb_serial_port *port = (struct usb_serial_port *)urb->context;
	unsigned char *data = urb->transfer_buffer;
	int is_throttled;
	unsigned long flags;

	dbg("%s - port %d", __FUNCTION__, port->number);

	if (urb->status) {
		dbg("%s - nonzero read bulk status received: %d", __FUNCTION__, urb->status);
		return;
	}

	usb_serial_debug_data(debug, &port->dev, __FUNCTION__, urb->actual_length, data);

	/* Throttle the device if requested by tty */
	if (urb->actual_length) {
		spin_lock_irqsave(&port->lock, flags);
		is_throttled = port->throttled = port->throttle_req;
		spin_unlock_irqrestore(&port->lock, flags);
		if (is_throttled) {
			/* Let the received data linger in the read URB;
			 * usb_serial_generic_unthrottle() will pick it
			 * up later. */
			dbg("%s - throttling device", __FUNCTION__);
			return;
		}
	}

	/* Handle data and continue reading from device */
	flush_and_resubmit_read_urb(port);
}
Пример #3
0
void usb_serial_generic_unthrottle (struct usb_serial_port *port)
{
	int was_throttled;
	unsigned long flags;

	dbg("%s - port %d", __FUNCTION__, port->number);

	/* Clear the throttle flags */
	spin_lock_irqsave(&port->lock, flags);
	was_throttled = port->throttled;
	port->throttled = port->throttle_req = 0;
	spin_unlock_irqrestore(&port->lock, flags);

	if (was_throttled) {
		/* Handle pending data and resume reading from device */
		flush_and_resubmit_read_urb(port);
	}
}
Пример #4
0
void usb_serial_generic_unthrottle(struct tty_struct *tty)
{
    struct usb_serial_port *port = tty->driver_data;
    int was_throttled;
    unsigned long flags;

    dbg("%s - port %d", __func__, port->number);

    /* Clear the throttle flags */
    spin_lock_irqsave(&port->lock, flags);
    was_throttled = port->throttled;
    port->throttled = port->throttle_req = 0;
    spin_unlock_irqrestore(&port->lock, flags);

    if (was_throttled) {
        /* Resume reading from device */
        flush_and_resubmit_read_urb(port);
    }
}