Lines Matching refs:n_hdlc

134 struct n_hdlc {  struct
157 static struct n_hdlc *n_hdlc_alloc(void); argument
165 struct n_hdlc *n_hdlc = tty->disc_data; in flush_rx_queue() local
168 while ((buf = n_hdlc_buf_get(&n_hdlc->rx_buf_list))) in flush_rx_queue()
169 n_hdlc_buf_put(&n_hdlc->rx_free_buf_list, buf); in flush_rx_queue()
174 struct n_hdlc *n_hdlc = tty->disc_data; in flush_tx_queue() local
177 while ((buf = n_hdlc_buf_get(&n_hdlc->tx_buf_list))) in flush_tx_queue()
178 n_hdlc_buf_put(&n_hdlc->tx_free_buf_list, buf); in flush_tx_queue()
200 struct n_hdlc *n_hdlc = tty->disc_data; in n_hdlc_tty_close() local
202 if (n_hdlc->magic != HDLC_MAGIC) { in n_hdlc_tty_close()
215 cancel_work_sync(&n_hdlc->write_work); in n_hdlc_tty_close()
217 n_hdlc_free_buf_list(&n_hdlc->rx_free_buf_list); in n_hdlc_tty_close()
218 n_hdlc_free_buf_list(&n_hdlc->tx_free_buf_list); in n_hdlc_tty_close()
219 n_hdlc_free_buf_list(&n_hdlc->rx_buf_list); in n_hdlc_tty_close()
220 n_hdlc_free_buf_list(&n_hdlc->tx_buf_list); in n_hdlc_tty_close()
221 kfree(n_hdlc); in n_hdlc_tty_close()
232 struct n_hdlc *n_hdlc = tty->disc_data; in n_hdlc_tty_open() local
237 if (n_hdlc) { in n_hdlc_tty_open()
242 n_hdlc = n_hdlc_alloc(); in n_hdlc_tty_open()
243 if (!n_hdlc) { in n_hdlc_tty_open()
248 INIT_WORK(&n_hdlc->write_work, n_hdlc_tty_write_work); in n_hdlc_tty_open()
249 n_hdlc->tty_for_write_work = tty; in n_hdlc_tty_open()
250 tty->disc_data = n_hdlc; in n_hdlc_tty_open()
272 static void n_hdlc_send_frames(struct n_hdlc *n_hdlc, struct tty_struct *tty) in n_hdlc_send_frames() argument
280 spin_lock_irqsave(&n_hdlc->tx_buf_list.spinlock, flags); in n_hdlc_send_frames()
281 if (n_hdlc->tbusy) { in n_hdlc_send_frames()
282 n_hdlc->woke_up = true; in n_hdlc_send_frames()
283 spin_unlock_irqrestore(&n_hdlc->tx_buf_list.spinlock, flags); in n_hdlc_send_frames()
286 n_hdlc->tbusy = true; in n_hdlc_send_frames()
287 n_hdlc->woke_up = false; in n_hdlc_send_frames()
288 spin_unlock_irqrestore(&n_hdlc->tx_buf_list.spinlock, flags); in n_hdlc_send_frames()
290 tbuf = n_hdlc_buf_get(&n_hdlc->tx_buf_list); in n_hdlc_send_frames()
300 n_hdlc_buf_return(&n_hdlc->tx_buf_list, tbuf); in n_hdlc_send_frames()
312 n_hdlc_buf_put(&n_hdlc->tx_free_buf_list, tbuf); in n_hdlc_send_frames()
318 tbuf = n_hdlc_buf_get(&n_hdlc->tx_buf_list); in n_hdlc_send_frames()
326 n_hdlc_buf_return(&n_hdlc->tx_buf_list, tbuf); in n_hdlc_send_frames()
335 spin_lock_irqsave(&n_hdlc->tx_buf_list.spinlock, flags); in n_hdlc_send_frames()
336 n_hdlc->tbusy = false; in n_hdlc_send_frames()
337 spin_unlock_irqrestore(&n_hdlc->tx_buf_list.spinlock, flags); in n_hdlc_send_frames()
339 if (n_hdlc->woke_up) in n_hdlc_send_frames()
351 struct n_hdlc *n_hdlc = container_of(work, struct n_hdlc, write_work); in n_hdlc_tty_write_work() local
352 struct tty_struct *tty = n_hdlc->tty_for_write_work; in n_hdlc_tty_write_work()
354 n_hdlc_send_frames(n_hdlc, tty); in n_hdlc_tty_write_work()
365 struct n_hdlc *n_hdlc = tty->disc_data; in n_hdlc_tty_wakeup() local
367 schedule_work(&n_hdlc->write_work); in n_hdlc_tty_wakeup()
383 register struct n_hdlc *n_hdlc = tty->disc_data; in n_hdlc_tty_receive() local
389 if (n_hdlc->magic != HDLC_MAGIC) { in n_hdlc_tty_receive()
400 buf = n_hdlc_buf_get(&n_hdlc->rx_free_buf_list); in n_hdlc_tty_receive()
406 if (n_hdlc->rx_buf_list.count < MAX_RX_BUF_COUNT) in n_hdlc_tty_receive()
421 n_hdlc_buf_put(&n_hdlc->rx_buf_list, buf); in n_hdlc_tty_receive()
443 struct n_hdlc *n_hdlc = tty->disc_data; in n_hdlc_tty_read() local
465 rbuf = n_hdlc_buf_get(&n_hdlc->rx_buf_list); in n_hdlc_tty_read()
514 if (n_hdlc->rx_free_buf_list.count > DEFAULT_RX_BUF_COUNT) in n_hdlc_tty_read()
517 n_hdlc_buf_put(&n_hdlc->rx_free_buf_list, rbuf); in n_hdlc_tty_read()
535 struct n_hdlc *n_hdlc = tty->disc_data; in n_hdlc_tty_write() local
542 if (n_hdlc->magic != HDLC_MAGIC) in n_hdlc_tty_write()
557 tbuf = n_hdlc_buf_get(&n_hdlc->tx_free_buf_list); in n_hdlc_tty_write()
582 n_hdlc_buf_put(&n_hdlc->tx_buf_list, tbuf); in n_hdlc_tty_write()
583 n_hdlc_send_frames(n_hdlc, tty); in n_hdlc_tty_write()
602 struct n_hdlc *n_hdlc = tty->disc_data; in n_hdlc_tty_ioctl() local
611 if (n_hdlc->magic != HDLC_MAGIC) in n_hdlc_tty_ioctl()
618 spin_lock_irqsave(&n_hdlc->rx_buf_list.spinlock, flags); in n_hdlc_tty_ioctl()
619 buf = list_first_entry_or_null(&n_hdlc->rx_buf_list.list, in n_hdlc_tty_ioctl()
625 spin_unlock_irqrestore(&n_hdlc->rx_buf_list.spinlock, flags); in n_hdlc_tty_ioctl()
633 spin_lock_irqsave(&n_hdlc->tx_buf_list.spinlock, flags); in n_hdlc_tty_ioctl()
634 buf = list_first_entry_or_null(&n_hdlc->tx_buf_list.list, in n_hdlc_tty_ioctl()
638 spin_unlock_irqrestore(&n_hdlc->tx_buf_list.spinlock, flags); in n_hdlc_tty_ioctl()
671 struct n_hdlc *n_hdlc = tty->disc_data; in n_hdlc_tty_poll() local
674 if (n_hdlc->magic != HDLC_MAGIC) in n_hdlc_tty_poll()
685 if (!list_empty(&n_hdlc->rx_buf_list.list)) in n_hdlc_tty_poll()
692 !list_empty(&n_hdlc->tx_free_buf_list.list)) in n_hdlc_tty_poll()
720 static struct n_hdlc *n_hdlc_alloc(void) in n_hdlc_alloc()
722 struct n_hdlc *n_hdlc = kzalloc(sizeof(*n_hdlc), GFP_KERNEL); in n_hdlc_alloc() local
724 if (!n_hdlc) in n_hdlc_alloc()
727 spin_lock_init(&n_hdlc->rx_free_buf_list.spinlock); in n_hdlc_alloc()
728 spin_lock_init(&n_hdlc->tx_free_buf_list.spinlock); in n_hdlc_alloc()
729 spin_lock_init(&n_hdlc->rx_buf_list.spinlock); in n_hdlc_alloc()
730 spin_lock_init(&n_hdlc->tx_buf_list.spinlock); in n_hdlc_alloc()
732 INIT_LIST_HEAD(&n_hdlc->rx_free_buf_list.list); in n_hdlc_alloc()
733 INIT_LIST_HEAD(&n_hdlc->tx_free_buf_list.list); in n_hdlc_alloc()
734 INIT_LIST_HEAD(&n_hdlc->rx_buf_list.list); in n_hdlc_alloc()
735 INIT_LIST_HEAD(&n_hdlc->tx_buf_list.list); in n_hdlc_alloc()
737 n_hdlc_alloc_buf(&n_hdlc->rx_free_buf_list, DEFAULT_RX_BUF_COUNT, "rx"); in n_hdlc_alloc()
738 n_hdlc_alloc_buf(&n_hdlc->tx_free_buf_list, DEFAULT_TX_BUF_COUNT, "tx"); in n_hdlc_alloc()
741 n_hdlc->magic = HDLC_MAGIC; in n_hdlc_alloc()
743 return n_hdlc; in n_hdlc_alloc()