Lines Matching refs:port

106 int usb_serial_generic_open(struct tty_struct *tty, struct usb_serial_port *port)  in usb_serial_generic_open()  argument
110 clear_bit(USB_SERIAL_THROTTLED, &port->flags); in usb_serial_generic_open()
112 if (port->bulk_in_size) in usb_serial_generic_open()
113 result = usb_serial_generic_submit_read_urbs(port, GFP_KERNEL); in usb_serial_generic_open()
119 void usb_serial_generic_close(struct usb_serial_port *port) in usb_serial_generic_close() argument
124 if (port->bulk_out_size) { in usb_serial_generic_close()
125 for (i = 0; i < ARRAY_SIZE(port->write_urbs); ++i) in usb_serial_generic_close()
126 usb_kill_urb(port->write_urbs[i]); in usb_serial_generic_close()
128 spin_lock_irqsave(&port->lock, flags); in usb_serial_generic_close()
129 kfifo_reset_out(&port->write_fifo); in usb_serial_generic_close()
130 spin_unlock_irqrestore(&port->lock, flags); in usb_serial_generic_close()
132 if (port->bulk_in_size) { in usb_serial_generic_close()
133 for (i = 0; i < ARRAY_SIZE(port->read_urbs); ++i) in usb_serial_generic_close()
134 usb_kill_urb(port->read_urbs[i]); in usb_serial_generic_close()
139 int usb_serial_generic_prepare_write_buffer(struct usb_serial_port *port, in usb_serial_generic_prepare_write_buffer() argument
142 return kfifo_out_locked(&port->write_fifo, dest, size, &port->lock); in usb_serial_generic_prepare_write_buffer()
154 int usb_serial_generic_write_start(struct usb_serial_port *port, in usb_serial_generic_write_start() argument
162 if (test_and_set_bit_lock(USB_SERIAL_WRITE_BUSY, &port->flags)) in usb_serial_generic_write_start()
165 spin_lock_irqsave(&port->lock, flags); in usb_serial_generic_write_start()
166 if (!port->write_urbs_free || !kfifo_len(&port->write_fifo)) { in usb_serial_generic_write_start()
167 clear_bit_unlock(USB_SERIAL_WRITE_BUSY, &port->flags); in usb_serial_generic_write_start()
168 spin_unlock_irqrestore(&port->lock, flags); in usb_serial_generic_write_start()
171 i = (int)find_first_bit(&port->write_urbs_free, in usb_serial_generic_write_start()
172 ARRAY_SIZE(port->write_urbs)); in usb_serial_generic_write_start()
173 spin_unlock_irqrestore(&port->lock, flags); in usb_serial_generic_write_start()
175 urb = port->write_urbs[i]; in usb_serial_generic_write_start()
176 count = port->serial->type->prepare_write_buffer(port, in usb_serial_generic_write_start()
178 port->bulk_out_size); in usb_serial_generic_write_start()
180 usb_serial_debug_data(&port->dev, __func__, count, urb->transfer_buffer); in usb_serial_generic_write_start()
181 spin_lock_irqsave(&port->lock, flags); in usb_serial_generic_write_start()
182 port->tx_bytes += count; in usb_serial_generic_write_start()
183 spin_unlock_irqrestore(&port->lock, flags); in usb_serial_generic_write_start()
185 clear_bit(i, &port->write_urbs_free); in usb_serial_generic_write_start()
188 dev_err_console(port, "%s - error submitting urb: %d\n", in usb_serial_generic_write_start()
190 set_bit(i, &port->write_urbs_free); in usb_serial_generic_write_start()
191 spin_lock_irqsave(&port->lock, flags); in usb_serial_generic_write_start()
192 port->tx_bytes -= count; in usb_serial_generic_write_start()
193 spin_unlock_irqrestore(&port->lock, flags); in usb_serial_generic_write_start()
195 clear_bit_unlock(USB_SERIAL_WRITE_BUSY, &port->flags); in usb_serial_generic_write_start()
214 struct usb_serial_port *port, const unsigned char *buf, int count) in usb_serial_generic_write() argument
218 if (!port->bulk_out_size) in usb_serial_generic_write()
224 count = kfifo_in_locked(&port->write_fifo, buf, count, &port->lock); in usb_serial_generic_write()
225 result = usb_serial_generic_write_start(port, GFP_ATOMIC); in usb_serial_generic_write()
235 struct usb_serial_port *port = tty->driver_data; in usb_serial_generic_write_room() local
239 if (!port->bulk_out_size) in usb_serial_generic_write_room()
242 spin_lock_irqsave(&port->lock, flags); in usb_serial_generic_write_room()
243 room = kfifo_avail(&port->write_fifo); in usb_serial_generic_write_room()
244 spin_unlock_irqrestore(&port->lock, flags); in usb_serial_generic_write_room()
246 dev_dbg(&port->dev, "%s - returns %u\n", __func__, room); in usb_serial_generic_write_room()
252 struct usb_serial_port *port = tty->driver_data; in usb_serial_generic_chars_in_buffer() local
256 if (!port->bulk_out_size) in usb_serial_generic_chars_in_buffer()
259 spin_lock_irqsave(&port->lock, flags); in usb_serial_generic_chars_in_buffer()
260 chars = kfifo_len(&port->write_fifo) + port->tx_bytes; in usb_serial_generic_chars_in_buffer()
261 spin_unlock_irqrestore(&port->lock, flags); in usb_serial_generic_chars_in_buffer()
263 dev_dbg(&port->dev, "%s - returns %u\n", __func__, chars); in usb_serial_generic_chars_in_buffer()
270 struct usb_serial_port *port = tty->driver_data; in usb_serial_generic_wait_until_sent() local
286 dev_dbg(&port->dev, "%s - timeout = %u ms, period = %u ms\n", in usb_serial_generic_wait_until_sent()
290 while (!port->serial->type->tx_empty(port)) { in usb_serial_generic_wait_until_sent()
300 static int usb_serial_generic_submit_read_urb(struct usb_serial_port *port, in usb_serial_generic_submit_read_urb() argument
305 if (!test_and_clear_bit(index, &port->read_urbs_free)) in usb_serial_generic_submit_read_urb()
308 dev_dbg(&port->dev, "%s - urb %d\n", __func__, index); in usb_serial_generic_submit_read_urb()
310 res = usb_submit_urb(port->read_urbs[index], mem_flags); in usb_serial_generic_submit_read_urb()
313 dev_err(&port->dev, in usb_serial_generic_submit_read_urb()
317 set_bit(index, &port->read_urbs_free); in usb_serial_generic_submit_read_urb()
324 int usb_serial_generic_submit_read_urbs(struct usb_serial_port *port, in usb_serial_generic_submit_read_urbs() argument
330 for (i = 0; i < ARRAY_SIZE(port->read_urbs); ++i) { in usb_serial_generic_submit_read_urbs()
331 res = usb_serial_generic_submit_read_urb(port, i, mem_flags); in usb_serial_generic_submit_read_urbs()
339 usb_kill_urb(port->read_urbs[i]); in usb_serial_generic_submit_read_urbs()
347 struct usb_serial_port *port = urb->context; in usb_serial_generic_process_read_urb() local
358 if (port->sysrq) { in usb_serial_generic_process_read_urb()
360 if (!usb_serial_handle_sysrq_char(port, *ch)) in usb_serial_generic_process_read_urb()
361 tty_insert_flip_char(&port->port, *ch, TTY_NORMAL); in usb_serial_generic_process_read_urb()
364 tty_insert_flip_string(&port->port, ch, urb->actual_length); in usb_serial_generic_process_read_urb()
366 tty_flip_buffer_push(&port->port); in usb_serial_generic_process_read_urb()
372 struct usb_serial_port *port = urb->context; in usb_serial_generic_read_bulk_callback() local
378 for (i = 0; i < ARRAY_SIZE(port->read_urbs); ++i) { in usb_serial_generic_read_bulk_callback()
379 if (urb == port->read_urbs[i]) in usb_serial_generic_read_bulk_callback()
383 dev_dbg(&port->dev, "%s - urb %d, len %d\n", __func__, i, in usb_serial_generic_read_bulk_callback()
387 usb_serial_debug_data(&port->dev, __func__, urb->actual_length, in usb_serial_generic_read_bulk_callback()
389 port->serial->type->process_read_urb(urb); in usb_serial_generic_read_bulk_callback()
394 dev_dbg(&port->dev, "%s - urb stopped: %d\n", in usb_serial_generic_read_bulk_callback()
399 dev_err(&port->dev, "%s - urb stopped: %d\n", in usb_serial_generic_read_bulk_callback()
404 dev_dbg(&port->dev, "%s - nonzero urb status: %d\n", in usb_serial_generic_read_bulk_callback()
416 set_bit(i, &port->read_urbs_free); in usb_serial_generic_read_bulk_callback()
427 if (test_bit(USB_SERIAL_THROTTLED, &port->flags)) in usb_serial_generic_read_bulk_callback()
430 usb_serial_generic_submit_read_urb(port, i, GFP_ATOMIC); in usb_serial_generic_read_bulk_callback()
437 struct usb_serial_port *port = urb->context; in usb_serial_generic_write_bulk_callback() local
441 for (i = 0; i < ARRAY_SIZE(port->write_urbs); ++i) { in usb_serial_generic_write_bulk_callback()
442 if (port->write_urbs[i] == urb) in usb_serial_generic_write_bulk_callback()
445 spin_lock_irqsave(&port->lock, flags); in usb_serial_generic_write_bulk_callback()
446 port->tx_bytes -= urb->transfer_buffer_length; in usb_serial_generic_write_bulk_callback()
447 set_bit(i, &port->write_urbs_free); in usb_serial_generic_write_bulk_callback()
448 spin_unlock_irqrestore(&port->lock, flags); in usb_serial_generic_write_bulk_callback()
456 dev_dbg(&port->dev, "%s - urb stopped: %d\n", in usb_serial_generic_write_bulk_callback()
460 dev_err_console(port, "%s - urb stopped: %d\n", in usb_serial_generic_write_bulk_callback()
464 dev_err_console(port, "%s - nonzero urb status: %d\n", in usb_serial_generic_write_bulk_callback()
469 usb_serial_generic_write_start(port, GFP_ATOMIC); in usb_serial_generic_write_bulk_callback()
470 usb_serial_port_softint(port); in usb_serial_generic_write_bulk_callback()
476 struct usb_serial_port *port = tty->driver_data; in usb_serial_generic_throttle() local
478 set_bit(USB_SERIAL_THROTTLED, &port->flags); in usb_serial_generic_throttle()
484 struct usb_serial_port *port = tty->driver_data; in usb_serial_generic_unthrottle() local
486 clear_bit(USB_SERIAL_THROTTLED, &port->flags); in usb_serial_generic_unthrottle()
494 usb_serial_generic_submit_read_urbs(port, GFP_KERNEL); in usb_serial_generic_unthrottle()
501 struct usb_serial_port *port = tty->driver_data; in usb_serial_generic_msr_changed() local
510 if (!tty_port_initialized(&port->port)) in usb_serial_generic_msr_changed()
513 spin_lock_irqsave(&port->lock, flags); in usb_serial_generic_msr_changed()
514 cnow = port->icount; /* atomic copy*/ in usb_serial_generic_msr_changed()
515 spin_unlock_irqrestore(&port->lock, flags); in usb_serial_generic_msr_changed()
529 struct usb_serial_port *port = tty->driver_data; in usb_serial_generic_tiocmiwait() local
534 spin_lock_irqsave(&port->lock, flags); in usb_serial_generic_tiocmiwait()
535 cnow = port->icount; /* atomic copy */ in usb_serial_generic_tiocmiwait()
536 spin_unlock_irqrestore(&port->lock, flags); in usb_serial_generic_tiocmiwait()
538 ret = wait_event_interruptible(port->port.delta_msr_wait, in usb_serial_generic_tiocmiwait()
540 if (!ret && !tty_port_initialized(&port->port)) in usb_serial_generic_tiocmiwait()
550 struct usb_serial_port *port = tty->driver_data; in usb_serial_generic_get_icount() local
554 spin_lock_irqsave(&port->lock, flags); in usb_serial_generic_get_icount()
555 cnow = port->icount; /* atomic copy */ in usb_serial_generic_get_icount()
556 spin_unlock_irqrestore(&port->lock, flags); in usb_serial_generic_get_icount()
575 int usb_serial_handle_sysrq_char(struct usb_serial_port *port, unsigned int ch) in usb_serial_handle_sysrq_char() argument
577 if (port->sysrq) { in usb_serial_handle_sysrq_char()
578 if (ch && time_before(jiffies, port->sysrq)) { in usb_serial_handle_sysrq_char()
580 port->sysrq = 0; in usb_serial_handle_sysrq_char()
583 port->sysrq = 0; in usb_serial_handle_sysrq_char()
589 int usb_serial_handle_break(struct usb_serial_port *port) in usb_serial_handle_break() argument
591 if (!port->port.console) in usb_serial_handle_break()
594 if (!port->sysrq) { in usb_serial_handle_break()
595 port->sysrq = jiffies + HZ*5; in usb_serial_handle_break()
598 port->sysrq = 0; in usb_serial_handle_break()
610 void usb_serial_handle_dcd_change(struct usb_serial_port *port, in usb_serial_handle_dcd_change() argument
613 dev_dbg(&port->dev, "%s - status %d\n", __func__, status); in usb_serial_handle_dcd_change()
626 wake_up_interruptible(&port->port.open_wait); in usb_serial_handle_dcd_change()
634 struct usb_serial_port *port; in usb_serial_generic_resume() local
638 port = serial->port[i]; in usb_serial_generic_resume()
639 if (!tty_port_initialized(&port->port)) in usb_serial_generic_resume()
642 if (port->bulk_in_size) { in usb_serial_generic_resume()
643 r = usb_serial_generic_submit_read_urbs(port, in usb_serial_generic_resume()
649 if (port->bulk_out_size) { in usb_serial_generic_resume()
650 r = usb_serial_generic_write_start(port, GFP_NOIO); in usb_serial_generic_resume()