Lines Matching refs:n_hdlc

142 struct n_hdlc {  struct
166 static struct n_hdlc *n_hdlc_alloc (void); argument
193 #define tty2n_hdlc(tty) ((struct n_hdlc *) ((tty)->disc_data))
194 #define n_hdlc2tty(n_hdlc) ((n_hdlc)->tty) argument
198 struct n_hdlc *n_hdlc = tty2n_hdlc(tty); in flush_rx_queue() local
201 while ((buf = n_hdlc_buf_get(&n_hdlc->rx_buf_list))) in flush_rx_queue()
202 n_hdlc_buf_put(&n_hdlc->rx_free_buf_list, buf); in flush_rx_queue()
207 struct n_hdlc *n_hdlc = tty2n_hdlc(tty); in flush_tx_queue() local
210 while ((buf = n_hdlc_buf_get(&n_hdlc->tx_buf_list))) in flush_tx_queue()
211 n_hdlc_buf_put(&n_hdlc->tx_free_buf_list, buf); in flush_tx_queue()
233 static void n_hdlc_release(struct n_hdlc *n_hdlc) in n_hdlc_release() argument
235 struct tty_struct *tty = n_hdlc2tty (n_hdlc); in n_hdlc_release()
245 if (tty->disc_data == n_hdlc) in n_hdlc_release()
250 buf = n_hdlc_buf_get(&n_hdlc->rx_free_buf_list); in n_hdlc_release()
257 buf = n_hdlc_buf_get(&n_hdlc->tx_free_buf_list); in n_hdlc_release()
264 buf = n_hdlc_buf_get(&n_hdlc->rx_buf_list); in n_hdlc_release()
271 buf = n_hdlc_buf_get(&n_hdlc->tx_buf_list); in n_hdlc_release()
277 kfree(n_hdlc); in n_hdlc_release()
290 struct n_hdlc *n_hdlc = tty2n_hdlc (tty); in n_hdlc_tty_close() local
295 if (n_hdlc != NULL) { in n_hdlc_tty_close()
296 if (n_hdlc->magic != HDLC_MAGIC) { in n_hdlc_tty_close()
304 if (tty == n_hdlc->backup_tty) in n_hdlc_tty_close()
305 n_hdlc->backup_tty = NULL; in n_hdlc_tty_close()
306 if (tty != n_hdlc->tty) in n_hdlc_tty_close()
308 if (n_hdlc->backup_tty) { in n_hdlc_tty_close()
309 n_hdlc->tty = n_hdlc->backup_tty; in n_hdlc_tty_close()
311 n_hdlc_release (n_hdlc); in n_hdlc_tty_close()
328 struct n_hdlc *n_hdlc = tty2n_hdlc (tty); in n_hdlc_tty_open() local
336 if (n_hdlc) { in n_hdlc_tty_open()
341 n_hdlc = n_hdlc_alloc(); in n_hdlc_tty_open()
342 if (!n_hdlc) { in n_hdlc_tty_open()
347 tty->disc_data = n_hdlc; in n_hdlc_tty_open()
348 n_hdlc->tty = tty; in n_hdlc_tty_open()
375 static void n_hdlc_send_frames(struct n_hdlc *n_hdlc, struct tty_struct *tty) in n_hdlc_send_frames() argument
385 spin_lock_irqsave(&n_hdlc->tx_buf_list.spinlock, flags); in n_hdlc_send_frames()
386 if (n_hdlc->tbusy) { in n_hdlc_send_frames()
387 n_hdlc->woke_up = 1; in n_hdlc_send_frames()
388 spin_unlock_irqrestore(&n_hdlc->tx_buf_list.spinlock, flags); in n_hdlc_send_frames()
391 n_hdlc->tbusy = 1; in n_hdlc_send_frames()
392 n_hdlc->woke_up = 0; in n_hdlc_send_frames()
393 spin_unlock_irqrestore(&n_hdlc->tx_buf_list.spinlock, flags); in n_hdlc_send_frames()
395 tbuf = n_hdlc_buf_get(&n_hdlc->tx_buf_list); in n_hdlc_send_frames()
407 n_hdlc_buf_return(&n_hdlc->tx_buf_list, tbuf); in n_hdlc_send_frames()
421 n_hdlc_buf_put(&n_hdlc->tx_free_buf_list, tbuf); in n_hdlc_send_frames()
427 tbuf = n_hdlc_buf_get(&n_hdlc->tx_buf_list); in n_hdlc_send_frames()
437 n_hdlc_buf_return(&n_hdlc->tx_buf_list, tbuf); in n_hdlc_send_frames()
446 spin_lock_irqsave(&n_hdlc->tx_buf_list.spinlock, flags); in n_hdlc_send_frames()
447 n_hdlc->tbusy = 0; in n_hdlc_send_frames()
448 spin_unlock_irqrestore(&n_hdlc->tx_buf_list.spinlock, flags); in n_hdlc_send_frames()
450 if (n_hdlc->woke_up) in n_hdlc_send_frames()
466 struct n_hdlc *n_hdlc = tty2n_hdlc(tty); in n_hdlc_tty_wakeup() local
471 if (!n_hdlc) in n_hdlc_tty_wakeup()
474 if (tty != n_hdlc->tty) { in n_hdlc_tty_wakeup()
479 n_hdlc_send_frames (n_hdlc, tty); in n_hdlc_tty_wakeup()
496 register struct n_hdlc *n_hdlc = tty2n_hdlc (tty); in n_hdlc_tty_receive() local
504 if (!n_hdlc || tty != n_hdlc->tty) in n_hdlc_tty_receive()
508 if (n_hdlc->magic != HDLC_MAGIC) { in n_hdlc_tty_receive()
522 buf = n_hdlc_buf_get(&n_hdlc->rx_free_buf_list); in n_hdlc_tty_receive()
526 if (n_hdlc->rx_buf_list.count < MAX_RX_BUF_COUNT) in n_hdlc_tty_receive()
542 n_hdlc_buf_put(&n_hdlc->rx_buf_list, buf); in n_hdlc_tty_receive()
546 if (n_hdlc->tty->fasync != NULL) in n_hdlc_tty_receive()
547 kill_fasync (&n_hdlc->tty->fasync, SIGIO, POLL_IN); in n_hdlc_tty_receive()
563 struct n_hdlc *n_hdlc = tty2n_hdlc(tty); in n_hdlc_tty_read() local
572 if (!n_hdlc) in n_hdlc_tty_read()
594 rbuf = n_hdlc_buf_get(&n_hdlc->rx_buf_list); in n_hdlc_tty_read()
607 if (n_hdlc->rx_free_buf_list.count > in n_hdlc_tty_read()
611 n_hdlc_buf_put(&n_hdlc->rx_free_buf_list, rbuf); in n_hdlc_tty_read()
648 struct n_hdlc *n_hdlc = tty2n_hdlc (tty); in n_hdlc_tty_write() local
658 if (!n_hdlc) in n_hdlc_tty_write()
661 if (n_hdlc->magic != HDLC_MAGIC) in n_hdlc_tty_write()
679 tbuf = n_hdlc_buf_get(&n_hdlc->tx_free_buf_list); in n_hdlc_tty_write()
689 n_hdlc = tty2n_hdlc (tty); in n_hdlc_tty_write()
690 if (!n_hdlc || n_hdlc->magic != HDLC_MAGIC || in n_hdlc_tty_write()
691 tty != n_hdlc->tty) { in n_hdlc_tty_write()
692 printk("n_hdlc_tty_write: %p invalid after wait!\n", n_hdlc); in n_hdlc_tty_write()
712 n_hdlc_buf_put(&n_hdlc->tx_buf_list,tbuf); in n_hdlc_tty_write()
713 n_hdlc_send_frames(n_hdlc,tty); in n_hdlc_tty_write()
732 struct n_hdlc *n_hdlc = tty2n_hdlc (tty); in n_hdlc_tty_ioctl() local
743 if (!n_hdlc || n_hdlc->magic != HDLC_MAGIC) in n_hdlc_tty_ioctl()
750 spin_lock_irqsave(&n_hdlc->rx_buf_list.spinlock,flags); in n_hdlc_tty_ioctl()
751 buf = list_first_entry_or_null(&n_hdlc->rx_buf_list.list, in n_hdlc_tty_ioctl()
757 spin_unlock_irqrestore(&n_hdlc->rx_buf_list.spinlock,flags); in n_hdlc_tty_ioctl()
765 spin_lock_irqsave(&n_hdlc->tx_buf_list.spinlock,flags); in n_hdlc_tty_ioctl()
766 buf = list_first_entry_or_null(&n_hdlc->tx_buf_list.list, in n_hdlc_tty_ioctl()
770 spin_unlock_irqrestore(&n_hdlc->tx_buf_list.spinlock,flags); in n_hdlc_tty_ioctl()
803 struct n_hdlc *n_hdlc = tty2n_hdlc (tty); in n_hdlc_tty_poll() local
809 if (n_hdlc && n_hdlc->magic == HDLC_MAGIC && tty == n_hdlc->tty) { in n_hdlc_tty_poll()
817 if (!list_empty(&n_hdlc->rx_buf_list.list)) in n_hdlc_tty_poll()
824 !list_empty(&n_hdlc->tx_free_buf_list.list)) in n_hdlc_tty_poll()
835 static struct n_hdlc *n_hdlc_alloc(void) in n_hdlc_alloc()
839 struct n_hdlc *n_hdlc = kzalloc(sizeof(*n_hdlc), GFP_KERNEL); in n_hdlc_alloc() local
841 if (!n_hdlc) in n_hdlc_alloc()
844 spin_lock_init(&n_hdlc->rx_free_buf_list.spinlock); in n_hdlc_alloc()
845 spin_lock_init(&n_hdlc->tx_free_buf_list.spinlock); in n_hdlc_alloc()
846 spin_lock_init(&n_hdlc->rx_buf_list.spinlock); in n_hdlc_alloc()
847 spin_lock_init(&n_hdlc->tx_buf_list.spinlock); in n_hdlc_alloc()
849 INIT_LIST_HEAD(&n_hdlc->rx_free_buf_list.list); in n_hdlc_alloc()
850 INIT_LIST_HEAD(&n_hdlc->tx_free_buf_list.list); in n_hdlc_alloc()
851 INIT_LIST_HEAD(&n_hdlc->rx_buf_list.list); in n_hdlc_alloc()
852 INIT_LIST_HEAD(&n_hdlc->tx_buf_list.list); in n_hdlc_alloc()
858 n_hdlc_buf_put(&n_hdlc->rx_free_buf_list,buf); in n_hdlc_alloc()
867 n_hdlc_buf_put(&n_hdlc->tx_free_buf_list,buf); in n_hdlc_alloc()
873 n_hdlc->magic = HDLC_MAGIC; in n_hdlc_alloc()
874 n_hdlc->flags = 0; in n_hdlc_alloc()
876 return n_hdlc; in n_hdlc_alloc()