Lines Matching refs:n_hdlc
131 struct n_hdlc { struct
153 static struct n_hdlc *n_hdlc_alloc(void); argument
161 struct n_hdlc *n_hdlc = tty->disc_data; in flush_rx_queue() local
164 while ((buf = n_hdlc_buf_get(&n_hdlc->rx_buf_list))) in flush_rx_queue()
165 n_hdlc_buf_put(&n_hdlc->rx_free_buf_list, buf); in flush_rx_queue()
170 struct n_hdlc *n_hdlc = tty->disc_data; in flush_tx_queue() local
173 while ((buf = n_hdlc_buf_get(&n_hdlc->tx_buf_list))) in flush_tx_queue()
174 n_hdlc_buf_put(&n_hdlc->tx_free_buf_list, buf); in flush_tx_queue()
196 struct n_hdlc *n_hdlc = tty->disc_data; in n_hdlc_tty_close() local
207 cancel_work_sync(&n_hdlc->write_work); in n_hdlc_tty_close()
209 n_hdlc_free_buf_list(&n_hdlc->rx_free_buf_list); in n_hdlc_tty_close()
210 n_hdlc_free_buf_list(&n_hdlc->tx_free_buf_list); in n_hdlc_tty_close()
211 n_hdlc_free_buf_list(&n_hdlc->rx_buf_list); in n_hdlc_tty_close()
212 n_hdlc_free_buf_list(&n_hdlc->tx_buf_list); in n_hdlc_tty_close()
213 kfree(n_hdlc); in n_hdlc_tty_close()
224 struct n_hdlc *n_hdlc = tty->disc_data; in n_hdlc_tty_open() local
229 if (n_hdlc) { in n_hdlc_tty_open()
234 n_hdlc = n_hdlc_alloc(); in n_hdlc_tty_open()
235 if (!n_hdlc) { in n_hdlc_tty_open()
240 INIT_WORK(&n_hdlc->write_work, n_hdlc_tty_write_work); in n_hdlc_tty_open()
241 n_hdlc->tty_for_write_work = tty; in n_hdlc_tty_open()
242 tty->disc_data = n_hdlc; in n_hdlc_tty_open()
264 static void n_hdlc_send_frames(struct n_hdlc *n_hdlc, struct tty_struct *tty) in n_hdlc_send_frames() argument
272 spin_lock_irqsave(&n_hdlc->tx_buf_list.spinlock, flags); in n_hdlc_send_frames()
273 if (n_hdlc->tbusy) { in n_hdlc_send_frames()
274 n_hdlc->woke_up = true; in n_hdlc_send_frames()
275 spin_unlock_irqrestore(&n_hdlc->tx_buf_list.spinlock, flags); in n_hdlc_send_frames()
278 n_hdlc->tbusy = true; in n_hdlc_send_frames()
279 n_hdlc->woke_up = false; in n_hdlc_send_frames()
280 spin_unlock_irqrestore(&n_hdlc->tx_buf_list.spinlock, flags); in n_hdlc_send_frames()
282 tbuf = n_hdlc_buf_get(&n_hdlc->tx_buf_list); in n_hdlc_send_frames()
292 n_hdlc_buf_return(&n_hdlc->tx_buf_list, tbuf); in n_hdlc_send_frames()
304 n_hdlc_buf_put(&n_hdlc->tx_free_buf_list, tbuf); in n_hdlc_send_frames()
310 tbuf = n_hdlc_buf_get(&n_hdlc->tx_buf_list); in n_hdlc_send_frames()
318 n_hdlc_buf_return(&n_hdlc->tx_buf_list, tbuf); in n_hdlc_send_frames()
327 spin_lock_irqsave(&n_hdlc->tx_buf_list.spinlock, flags); in n_hdlc_send_frames()
328 n_hdlc->tbusy = false; in n_hdlc_send_frames()
329 spin_unlock_irqrestore(&n_hdlc->tx_buf_list.spinlock, flags); in n_hdlc_send_frames()
331 if (n_hdlc->woke_up) in n_hdlc_send_frames()
343 struct n_hdlc *n_hdlc = container_of(work, struct n_hdlc, write_work); in n_hdlc_tty_write_work() local
344 struct tty_struct *tty = n_hdlc->tty_for_write_work; in n_hdlc_tty_write_work()
346 n_hdlc_send_frames(n_hdlc, tty); in n_hdlc_tty_write_work()
357 struct n_hdlc *n_hdlc = tty->disc_data; in n_hdlc_tty_wakeup() local
359 schedule_work(&n_hdlc->write_work); in n_hdlc_tty_wakeup()
375 register struct n_hdlc *n_hdlc = tty->disc_data; in n_hdlc_tty_receive() local
386 buf = n_hdlc_buf_get(&n_hdlc->rx_free_buf_list); in n_hdlc_tty_receive()
392 if (n_hdlc->rx_buf_list.count < MAX_RX_BUF_COUNT) in n_hdlc_tty_receive()
407 n_hdlc_buf_put(&n_hdlc->rx_buf_list, buf); in n_hdlc_tty_receive()
431 struct n_hdlc *n_hdlc = tty->disc_data; in n_hdlc_tty_read() local
453 rbuf = n_hdlc_buf_get(&n_hdlc->rx_buf_list); in n_hdlc_tty_read()
502 if (n_hdlc->rx_free_buf_list.count > DEFAULT_RX_BUF_COUNT) in n_hdlc_tty_read()
505 n_hdlc_buf_put(&n_hdlc->rx_free_buf_list, rbuf); in n_hdlc_tty_read()
523 struct n_hdlc *n_hdlc = tty->disc_data; in n_hdlc_tty_write() local
542 tbuf = n_hdlc_buf_get(&n_hdlc->tx_free_buf_list); in n_hdlc_tty_write()
567 n_hdlc_buf_put(&n_hdlc->tx_buf_list, tbuf); in n_hdlc_tty_write()
568 n_hdlc_send_frames(n_hdlc, tty); in n_hdlc_tty_write()
586 struct n_hdlc *n_hdlc = tty->disc_data; in n_hdlc_tty_ioctl() local
598 spin_lock_irqsave(&n_hdlc->rx_buf_list.spinlock, flags); in n_hdlc_tty_ioctl()
599 buf = list_first_entry_or_null(&n_hdlc->rx_buf_list.list, in n_hdlc_tty_ioctl()
605 spin_unlock_irqrestore(&n_hdlc->rx_buf_list.spinlock, flags); in n_hdlc_tty_ioctl()
613 spin_lock_irqsave(&n_hdlc->tx_buf_list.spinlock, flags); in n_hdlc_tty_ioctl()
614 buf = list_first_entry_or_null(&n_hdlc->tx_buf_list.list, in n_hdlc_tty_ioctl()
618 spin_unlock_irqrestore(&n_hdlc->tx_buf_list.spinlock, flags); in n_hdlc_tty_ioctl()
651 struct n_hdlc *n_hdlc = tty->disc_data; in n_hdlc_tty_poll() local
662 if (!list_empty(&n_hdlc->rx_buf_list.list)) in n_hdlc_tty_poll()
669 !list_empty(&n_hdlc->tx_free_buf_list.list)) in n_hdlc_tty_poll()
697 static struct n_hdlc *n_hdlc_alloc(void) in n_hdlc_alloc()
699 struct n_hdlc *n_hdlc = kzalloc(sizeof(*n_hdlc), GFP_KERNEL); in n_hdlc_alloc() local
701 if (!n_hdlc) in n_hdlc_alloc()
704 spin_lock_init(&n_hdlc->rx_free_buf_list.spinlock); in n_hdlc_alloc()
705 spin_lock_init(&n_hdlc->tx_free_buf_list.spinlock); in n_hdlc_alloc()
706 spin_lock_init(&n_hdlc->rx_buf_list.spinlock); in n_hdlc_alloc()
707 spin_lock_init(&n_hdlc->tx_buf_list.spinlock); in n_hdlc_alloc()
709 INIT_LIST_HEAD(&n_hdlc->rx_free_buf_list.list); in n_hdlc_alloc()
710 INIT_LIST_HEAD(&n_hdlc->tx_free_buf_list.list); in n_hdlc_alloc()
711 INIT_LIST_HEAD(&n_hdlc->rx_buf_list.list); in n_hdlc_alloc()
712 INIT_LIST_HEAD(&n_hdlc->tx_buf_list.list); in n_hdlc_alloc()
714 n_hdlc_alloc_buf(&n_hdlc->rx_free_buf_list, DEFAULT_RX_BUF_COUNT, "rx"); in n_hdlc_alloc()
715 n_hdlc_alloc_buf(&n_hdlc->tx_free_buf_list, DEFAULT_TX_BUF_COUNT, "tx"); in n_hdlc_alloc()
717 return n_hdlc; in n_hdlc_alloc()