Lines Matching full:port

105 int usb_serial_generic_open(struct tty_struct *tty, struct usb_serial_port *port)  in usb_serial_generic_open()  argument
109 clear_bit(USB_SERIAL_THROTTLED, &port->flags); in usb_serial_generic_open()
111 if (port->bulk_in_size) in usb_serial_generic_open()
112 result = usb_serial_generic_submit_read_urbs(port, GFP_KERNEL); in usb_serial_generic_open()
118 void usb_serial_generic_close(struct usb_serial_port *port) in usb_serial_generic_close() argument
123 if (port->bulk_out_size) { in usb_serial_generic_close()
124 for (i = 0; i < ARRAY_SIZE(port->write_urbs); ++i) in usb_serial_generic_close()
125 usb_kill_urb(port->write_urbs[i]); in usb_serial_generic_close()
127 spin_lock_irqsave(&port->lock, flags); in usb_serial_generic_close()
128 kfifo_reset_out(&port->write_fifo); in usb_serial_generic_close()
129 spin_unlock_irqrestore(&port->lock, flags); in usb_serial_generic_close()
131 if (port->bulk_in_size) { in usb_serial_generic_close()
132 for (i = 0; i < ARRAY_SIZE(port->read_urbs); ++i) in usb_serial_generic_close()
133 usb_kill_urb(port->read_urbs[i]); in usb_serial_generic_close()
138 int usb_serial_generic_prepare_write_buffer(struct usb_serial_port *port, in usb_serial_generic_prepare_write_buffer() argument
141 return kfifo_out_locked(&port->write_fifo, dest, size, &port->lock); in usb_serial_generic_prepare_write_buffer()
146 * @port: usb-serial port
153 int usb_serial_generic_write_start(struct usb_serial_port *port, in usb_serial_generic_write_start() argument
161 if (test_and_set_bit_lock(USB_SERIAL_WRITE_BUSY, &port->flags)) in usb_serial_generic_write_start()
164 spin_lock_irqsave(&port->lock, flags); in usb_serial_generic_write_start()
165 if (!port->write_urbs_free || !kfifo_len(&port->write_fifo)) { in usb_serial_generic_write_start()
166 clear_bit_unlock(USB_SERIAL_WRITE_BUSY, &port->flags); in usb_serial_generic_write_start()
167 spin_unlock_irqrestore(&port->lock, flags); in usb_serial_generic_write_start()
170 i = (int)find_first_bit(&port->write_urbs_free, in usb_serial_generic_write_start()
171 ARRAY_SIZE(port->write_urbs)); in usb_serial_generic_write_start()
172 spin_unlock_irqrestore(&port->lock, flags); in usb_serial_generic_write_start()
174 urb = port->write_urbs[i]; in usb_serial_generic_write_start()
175 count = port->serial->type->prepare_write_buffer(port, in usb_serial_generic_write_start()
177 port->bulk_out_size); in usb_serial_generic_write_start()
179 usb_serial_debug_data(&port->dev, __func__, count, urb->transfer_buffer); in usb_serial_generic_write_start()
180 spin_lock_irqsave(&port->lock, flags); in usb_serial_generic_write_start()
181 port->tx_bytes += count; in usb_serial_generic_write_start()
182 spin_unlock_irqrestore(&port->lock, flags); in usb_serial_generic_write_start()
184 clear_bit(i, &port->write_urbs_free); in usb_serial_generic_write_start()
187 dev_err_console(port, "%s - error submitting urb: %d\n", in usb_serial_generic_write_start()
189 set_bit(i, &port->write_urbs_free); in usb_serial_generic_write_start()
190 spin_lock_irqsave(&port->lock, flags); in usb_serial_generic_write_start()
191 port->tx_bytes -= count; in usb_serial_generic_write_start()
192 spin_unlock_irqrestore(&port->lock, flags); in usb_serial_generic_write_start()
194 clear_bit_unlock(USB_SERIAL_WRITE_BUSY, &port->flags); in usb_serial_generic_write_start()
204 * @tty: tty for the port
205 * @port: usb-serial port
213 struct usb_serial_port *port, const unsigned char *buf, int count) in usb_serial_generic_write() argument
217 if (!port->bulk_out_size) in usb_serial_generic_write()
223 count = kfifo_in_locked(&port->write_fifo, buf, count, &port->lock); in usb_serial_generic_write()
224 result = usb_serial_generic_write_start(port, GFP_ATOMIC); in usb_serial_generic_write()
234 struct usb_serial_port *port = tty->driver_data; in usb_serial_generic_write_room() local
238 if (!port->bulk_out_size) in usb_serial_generic_write_room()
241 spin_lock_irqsave(&port->lock, flags); in usb_serial_generic_write_room()
242 room = kfifo_avail(&port->write_fifo); in usb_serial_generic_write_room()
243 spin_unlock_irqrestore(&port->lock, flags); in usb_serial_generic_write_room()
245 dev_dbg(&port->dev, "%s - returns %u\n", __func__, room); in usb_serial_generic_write_room()
251 struct usb_serial_port *port = tty->driver_data; in usb_serial_generic_chars_in_buffer() local
255 if (!port->bulk_out_size) in usb_serial_generic_chars_in_buffer()
258 spin_lock_irqsave(&port->lock, flags); in usb_serial_generic_chars_in_buffer()
259 chars = kfifo_len(&port->write_fifo) + port->tx_bytes; in usb_serial_generic_chars_in_buffer()
260 spin_unlock_irqrestore(&port->lock, flags); in usb_serial_generic_chars_in_buffer()
262 dev_dbg(&port->dev, "%s - returns %u\n", __func__, chars); in usb_serial_generic_chars_in_buffer()
269 struct usb_serial_port *port = tty->driver_data; in usb_serial_generic_wait_until_sent() local
285 dev_dbg(&port->dev, "%s - timeout = %u ms, period = %u ms\n", in usb_serial_generic_wait_until_sent()
289 while (!port->serial->type->tx_empty(port)) { in usb_serial_generic_wait_until_sent()
299 static int usb_serial_generic_submit_read_urb(struct usb_serial_port *port, in usb_serial_generic_submit_read_urb() argument
304 if (!test_and_clear_bit(index, &port->read_urbs_free)) in usb_serial_generic_submit_read_urb()
307 dev_dbg(&port->dev, "%s - urb %d\n", __func__, index); in usb_serial_generic_submit_read_urb()
309 res = usb_submit_urb(port->read_urbs[index], mem_flags); in usb_serial_generic_submit_read_urb()
312 dev_err(&port->dev, in usb_serial_generic_submit_read_urb()
316 set_bit(index, &port->read_urbs_free); in usb_serial_generic_submit_read_urb()
323 int usb_serial_generic_submit_read_urbs(struct usb_serial_port *port, in usb_serial_generic_submit_read_urbs() argument
329 for (i = 0; i < ARRAY_SIZE(port->read_urbs); ++i) { in usb_serial_generic_submit_read_urbs()
330 res = usb_serial_generic_submit_read_urb(port, i, mem_flags); in usb_serial_generic_submit_read_urbs()
338 usb_kill_urb(port->read_urbs[i]); in usb_serial_generic_submit_read_urbs()
346 struct usb_serial_port *port = urb->context; in usb_serial_generic_process_read_urb() local
357 if (port->sysrq) { in usb_serial_generic_process_read_urb()
359 if (!usb_serial_handle_sysrq_char(port, *ch)) in usb_serial_generic_process_read_urb()
360 tty_insert_flip_char(&port->port, *ch, TTY_NORMAL); in usb_serial_generic_process_read_urb()
363 tty_insert_flip_string(&port->port, ch, urb->actual_length); in usb_serial_generic_process_read_urb()
365 tty_flip_buffer_push(&port->port); in usb_serial_generic_process_read_urb()
371 struct usb_serial_port *port = urb->context; in usb_serial_generic_read_bulk_callback() local
377 for (i = 0; i < ARRAY_SIZE(port->read_urbs); ++i) { in usb_serial_generic_read_bulk_callback()
378 if (urb == port->read_urbs[i]) in usb_serial_generic_read_bulk_callback()
382 dev_dbg(&port->dev, "%s - urb %d, len %d\n", __func__, i, in usb_serial_generic_read_bulk_callback()
386 usb_serial_debug_data(&port->dev, __func__, urb->actual_length, in usb_serial_generic_read_bulk_callback()
388 port->serial->type->process_read_urb(urb); in usb_serial_generic_read_bulk_callback()
393 dev_dbg(&port->dev, "%s - urb stopped: %d\n", in usb_serial_generic_read_bulk_callback()
398 dev_err(&port->dev, "%s - urb stopped: %d\n", in usb_serial_generic_read_bulk_callback()
403 dev_dbg(&port->dev, "%s - nonzero urb status: %d\n", in usb_serial_generic_read_bulk_callback()
415 set_bit(i, &port->read_urbs_free); in usb_serial_generic_read_bulk_callback()
426 if (test_bit(USB_SERIAL_THROTTLED, &port->flags)) in usb_serial_generic_read_bulk_callback()
429 usb_serial_generic_submit_read_urb(port, i, GFP_ATOMIC); in usb_serial_generic_read_bulk_callback()
436 struct usb_serial_port *port = urb->context; in usb_serial_generic_write_bulk_callback() local
440 for (i = 0; i < ARRAY_SIZE(port->write_urbs); ++i) { in usb_serial_generic_write_bulk_callback()
441 if (port->write_urbs[i] == urb) in usb_serial_generic_write_bulk_callback()
444 spin_lock_irqsave(&port->lock, flags); in usb_serial_generic_write_bulk_callback()
445 port->tx_bytes -= urb->transfer_buffer_length; in usb_serial_generic_write_bulk_callback()
446 set_bit(i, &port->write_urbs_free); in usb_serial_generic_write_bulk_callback()
447 spin_unlock_irqrestore(&port->lock, flags); in usb_serial_generic_write_bulk_callback()
455 dev_dbg(&port->dev, "%s - urb stopped: %d\n", in usb_serial_generic_write_bulk_callback()
459 dev_err_console(port, "%s - urb stopped: %d\n", in usb_serial_generic_write_bulk_callback()
463 dev_err_console(port, "%s - nonzero urb status: %d\n", in usb_serial_generic_write_bulk_callback()
468 usb_serial_generic_write_start(port, GFP_ATOMIC); in usb_serial_generic_write_bulk_callback()
469 usb_serial_port_softint(port); in usb_serial_generic_write_bulk_callback()
475 struct usb_serial_port *port = tty->driver_data; in usb_serial_generic_throttle() local
477 set_bit(USB_SERIAL_THROTTLED, &port->flags); in usb_serial_generic_throttle()
483 struct usb_serial_port *port = tty->driver_data; in usb_serial_generic_unthrottle() local
485 clear_bit(USB_SERIAL_THROTTLED, &port->flags); in usb_serial_generic_unthrottle()
493 usb_serial_generic_submit_read_urbs(port, GFP_KERNEL); in usb_serial_generic_unthrottle()
500 struct usb_serial_port *port = tty->driver_data; in usb_serial_generic_msr_changed() local
506 * Use tty-port initialised flag to detect all hangups including the in usb_serial_generic_msr_changed()
509 if (!tty_port_initialized(&port->port)) in usb_serial_generic_msr_changed()
512 spin_lock_irqsave(&port->lock, flags); in usb_serial_generic_msr_changed()
513 cnow = port->icount; /* atomic copy*/ in usb_serial_generic_msr_changed()
514 spin_unlock_irqrestore(&port->lock, flags); in usb_serial_generic_msr_changed()
528 struct usb_serial_port *port = tty->driver_data; in usb_serial_generic_tiocmiwait() local
533 spin_lock_irqsave(&port->lock, flags); in usb_serial_generic_tiocmiwait()
534 cnow = port->icount; /* atomic copy */ in usb_serial_generic_tiocmiwait()
535 spin_unlock_irqrestore(&port->lock, flags); in usb_serial_generic_tiocmiwait()
537 ret = wait_event_interruptible(port->port.delta_msr_wait, in usb_serial_generic_tiocmiwait()
539 if (!ret && !tty_port_initialized(&port->port)) in usb_serial_generic_tiocmiwait()
549 struct usb_serial_port *port = tty->driver_data; in usb_serial_generic_get_icount() local
553 spin_lock_irqsave(&port->lock, flags); in usb_serial_generic_get_icount()
554 cnow = port->icount; /* atomic copy */ in usb_serial_generic_get_icount()
555 spin_unlock_irqrestore(&port->lock, flags); in usb_serial_generic_get_icount()
574 int usb_serial_handle_sysrq_char(struct usb_serial_port *port, unsigned int ch) in usb_serial_handle_sysrq_char() argument
576 if (port->sysrq) { in usb_serial_handle_sysrq_char()
577 if (ch && time_before(jiffies, port->sysrq)) { in usb_serial_handle_sysrq_char()
579 port->sysrq = 0; in usb_serial_handle_sysrq_char()
582 port->sysrq = 0; in usb_serial_handle_sysrq_char()
588 int usb_serial_handle_break(struct usb_serial_port *port) in usb_serial_handle_break() argument
590 if (!port->port.console) in usb_serial_handle_break()
593 if (!port->sysrq) { in usb_serial_handle_break()
594 port->sysrq = jiffies + HZ*5; in usb_serial_handle_break()
597 port->sysrq = 0; in usb_serial_handle_break()
605 * @port: usb-serial port
606 * @tty: tty for the port
609 void usb_serial_handle_dcd_change(struct usb_serial_port *port, in usb_serial_handle_dcd_change() argument
612 dev_dbg(&port->dev, "%s - status %d\n", __func__, status); in usb_serial_handle_dcd_change()
625 wake_up_interruptible(&port->port.open_wait); in usb_serial_handle_dcd_change()
633 struct usb_serial_port *port; in usb_serial_generic_resume() local
637 port = serial->port[i]; in usb_serial_generic_resume()
638 if (!tty_port_initialized(&port->port)) in usb_serial_generic_resume()
641 if (port->bulk_in_size) { in usb_serial_generic_resume()
642 r = usb_serial_generic_submit_read_urbs(port, in usb_serial_generic_resume()
648 if (port->bulk_out_size) { in usb_serial_generic_resume()
649 r = usb_serial_generic_write_start(port, GFP_NOIO); in usb_serial_generic_resume()