Lines Matching refs:n_hdlc

145 struct n_hdlc {  struct
169 static struct n_hdlc *n_hdlc_alloc (void); argument
196 #define tty2n_hdlc(tty) ((struct n_hdlc *) ((tty)->disc_data))
197 #define n_hdlc2tty(n_hdlc) ((n_hdlc)->tty) argument
201 struct n_hdlc *n_hdlc = tty2n_hdlc(tty); in flush_rx_queue() local
204 while ((buf = n_hdlc_buf_get(&n_hdlc->rx_buf_list))) in flush_rx_queue()
205 n_hdlc_buf_put(&n_hdlc->rx_free_buf_list, buf); in flush_rx_queue()
210 struct n_hdlc *n_hdlc = tty2n_hdlc(tty); in flush_tx_queue() local
214 while ((buf = n_hdlc_buf_get(&n_hdlc->tx_buf_list))) in flush_tx_queue()
215 n_hdlc_buf_put(&n_hdlc->tx_free_buf_list, buf); in flush_tx_queue()
216 spin_lock_irqsave(&n_hdlc->tx_buf_list.spinlock, flags); in flush_tx_queue()
217 if (n_hdlc->tbuf) { in flush_tx_queue()
218 n_hdlc_buf_put(&n_hdlc->tx_free_buf_list, n_hdlc->tbuf); in flush_tx_queue()
219 n_hdlc->tbuf = NULL; in flush_tx_queue()
221 spin_unlock_irqrestore(&n_hdlc->tx_buf_list.spinlock, flags); in flush_tx_queue()
243 static void n_hdlc_release(struct n_hdlc *n_hdlc) in n_hdlc_release() argument
245 struct tty_struct *tty = n_hdlc2tty (n_hdlc); in n_hdlc_release()
255 if (tty->disc_data == n_hdlc) in n_hdlc_release()
260 buf = n_hdlc_buf_get(&n_hdlc->rx_free_buf_list); in n_hdlc_release()
267 buf = n_hdlc_buf_get(&n_hdlc->tx_free_buf_list); in n_hdlc_release()
274 buf = n_hdlc_buf_get(&n_hdlc->rx_buf_list); in n_hdlc_release()
281 buf = n_hdlc_buf_get(&n_hdlc->tx_buf_list); in n_hdlc_release()
287 kfree(n_hdlc->tbuf); in n_hdlc_release()
288 kfree(n_hdlc); in n_hdlc_release()
301 struct n_hdlc *n_hdlc = tty2n_hdlc (tty); in n_hdlc_tty_close() local
306 if (n_hdlc != NULL) { in n_hdlc_tty_close()
307 if (n_hdlc->magic != HDLC_MAGIC) { in n_hdlc_tty_close()
315 if (tty == n_hdlc->backup_tty) in n_hdlc_tty_close()
316 n_hdlc->backup_tty = NULL; in n_hdlc_tty_close()
317 if (tty != n_hdlc->tty) in n_hdlc_tty_close()
319 if (n_hdlc->backup_tty) { in n_hdlc_tty_close()
320 n_hdlc->tty = n_hdlc->backup_tty; in n_hdlc_tty_close()
322 n_hdlc_release (n_hdlc); in n_hdlc_tty_close()
339 struct n_hdlc *n_hdlc = tty2n_hdlc (tty); in n_hdlc_tty_open() local
347 if (n_hdlc) { in n_hdlc_tty_open()
352 n_hdlc = n_hdlc_alloc(); in n_hdlc_tty_open()
353 if (!n_hdlc) { in n_hdlc_tty_open()
358 tty->disc_data = n_hdlc; in n_hdlc_tty_open()
359 n_hdlc->tty = tty; in n_hdlc_tty_open()
386 static void n_hdlc_send_frames(struct n_hdlc *n_hdlc, struct tty_struct *tty) in n_hdlc_send_frames() argument
396 spin_lock_irqsave(&n_hdlc->tx_buf_list.spinlock, flags); in n_hdlc_send_frames()
397 if (n_hdlc->tbusy) { in n_hdlc_send_frames()
398 n_hdlc->woke_up = 1; in n_hdlc_send_frames()
399 spin_unlock_irqrestore(&n_hdlc->tx_buf_list.spinlock, flags); in n_hdlc_send_frames()
402 n_hdlc->tbusy = 1; in n_hdlc_send_frames()
403 n_hdlc->woke_up = 0; in n_hdlc_send_frames()
404 spin_unlock_irqrestore(&n_hdlc->tx_buf_list.spinlock, flags); in n_hdlc_send_frames()
409 tbuf = n_hdlc->tbuf; in n_hdlc_send_frames()
411 tbuf = n_hdlc_buf_get(&n_hdlc->tx_buf_list); in n_hdlc_send_frames()
424 n_hdlc->tbuf = tbuf; in n_hdlc_send_frames()
438 n_hdlc_buf_put(&n_hdlc->tx_free_buf_list, tbuf); in n_hdlc_send_frames()
441 n_hdlc->tbuf = NULL; in n_hdlc_send_frames()
447 tbuf = n_hdlc_buf_get(&n_hdlc->tx_buf_list); in n_hdlc_send_frames()
455 n_hdlc->tbuf = tbuf; in n_hdlc_send_frames()
464 spin_lock_irqsave(&n_hdlc->tx_buf_list.spinlock, flags); in n_hdlc_send_frames()
465 n_hdlc->tbusy = 0; in n_hdlc_send_frames()
466 spin_unlock_irqrestore(&n_hdlc->tx_buf_list.spinlock, flags); in n_hdlc_send_frames()
468 if (n_hdlc->woke_up) in n_hdlc_send_frames()
484 struct n_hdlc *n_hdlc = tty2n_hdlc(tty); in n_hdlc_tty_wakeup() local
489 if (!n_hdlc) in n_hdlc_tty_wakeup()
492 if (tty != n_hdlc->tty) { in n_hdlc_tty_wakeup()
497 n_hdlc_send_frames (n_hdlc, tty); in n_hdlc_tty_wakeup()
514 register struct n_hdlc *n_hdlc = tty2n_hdlc (tty); in n_hdlc_tty_receive() local
522 if (!n_hdlc || tty != n_hdlc->tty) in n_hdlc_tty_receive()
526 if (n_hdlc->magic != HDLC_MAGIC) { in n_hdlc_tty_receive()
540 buf = n_hdlc_buf_get(&n_hdlc->rx_free_buf_list); in n_hdlc_tty_receive()
544 if (n_hdlc->rx_buf_list.count < MAX_RX_BUF_COUNT) in n_hdlc_tty_receive()
560 n_hdlc_buf_put(&n_hdlc->rx_buf_list, buf); in n_hdlc_tty_receive()
564 if (n_hdlc->tty->fasync != NULL) in n_hdlc_tty_receive()
565 kill_fasync (&n_hdlc->tty->fasync, SIGIO, POLL_IN); in n_hdlc_tty_receive()
581 struct n_hdlc *n_hdlc = tty2n_hdlc(tty); in n_hdlc_tty_read() local
590 if (!n_hdlc) in n_hdlc_tty_read()
612 rbuf = n_hdlc_buf_get(&n_hdlc->rx_buf_list); in n_hdlc_tty_read()
624 if (n_hdlc->rx_free_buf_list.count > in n_hdlc_tty_read()
628 n_hdlc_buf_put(&n_hdlc->rx_free_buf_list, rbuf); in n_hdlc_tty_read()
665 struct n_hdlc *n_hdlc = tty2n_hdlc (tty); in n_hdlc_tty_write() local
675 if (!n_hdlc) in n_hdlc_tty_write()
678 if (n_hdlc->magic != HDLC_MAGIC) in n_hdlc_tty_write()
696 tbuf = n_hdlc_buf_get(&n_hdlc->tx_free_buf_list); in n_hdlc_tty_write()
706 n_hdlc = tty2n_hdlc (tty); in n_hdlc_tty_write()
707 if (!n_hdlc || n_hdlc->magic != HDLC_MAGIC || in n_hdlc_tty_write()
708 tty != n_hdlc->tty) { in n_hdlc_tty_write()
709 printk("n_hdlc_tty_write: %p invalid after wait!\n", n_hdlc); in n_hdlc_tty_write()
729 n_hdlc_buf_put(&n_hdlc->tx_buf_list,tbuf); in n_hdlc_tty_write()
730 n_hdlc_send_frames(n_hdlc,tty); in n_hdlc_tty_write()
749 struct n_hdlc *n_hdlc = tty2n_hdlc (tty); in n_hdlc_tty_ioctl() local
759 if (!n_hdlc || n_hdlc->magic != HDLC_MAGIC) in n_hdlc_tty_ioctl()
766 spin_lock_irqsave(&n_hdlc->rx_buf_list.spinlock,flags); in n_hdlc_tty_ioctl()
767 if (n_hdlc->rx_buf_list.head) in n_hdlc_tty_ioctl()
768 count = n_hdlc->rx_buf_list.head->count; in n_hdlc_tty_ioctl()
771 spin_unlock_irqrestore(&n_hdlc->rx_buf_list.spinlock,flags); in n_hdlc_tty_ioctl()
779 spin_lock_irqsave(&n_hdlc->tx_buf_list.spinlock,flags); in n_hdlc_tty_ioctl()
780 if (n_hdlc->tx_buf_list.head) in n_hdlc_tty_ioctl()
781 count += n_hdlc->tx_buf_list.head->count; in n_hdlc_tty_ioctl()
782 spin_unlock_irqrestore(&n_hdlc->tx_buf_list.spinlock,flags); in n_hdlc_tty_ioctl()
815 struct n_hdlc *n_hdlc = tty2n_hdlc (tty); in n_hdlc_tty_poll() local
821 if (n_hdlc && n_hdlc->magic == HDLC_MAGIC && tty == n_hdlc->tty) { in n_hdlc_tty_poll()
829 if (n_hdlc->rx_buf_list.head) in n_hdlc_tty_poll()
836 n_hdlc->tx_free_buf_list.head) in n_hdlc_tty_poll()
847 static struct n_hdlc *n_hdlc_alloc(void) in n_hdlc_alloc()
851 struct n_hdlc *n_hdlc = kzalloc(sizeof(*n_hdlc), GFP_KERNEL); in n_hdlc_alloc() local
853 if (!n_hdlc) in n_hdlc_alloc()
856 n_hdlc_buf_list_init(&n_hdlc->rx_free_buf_list); in n_hdlc_alloc()
857 n_hdlc_buf_list_init(&n_hdlc->tx_free_buf_list); in n_hdlc_alloc()
858 n_hdlc_buf_list_init(&n_hdlc->rx_buf_list); in n_hdlc_alloc()
859 n_hdlc_buf_list_init(&n_hdlc->tx_buf_list); in n_hdlc_alloc()
865 n_hdlc_buf_put(&n_hdlc->rx_free_buf_list,buf); in n_hdlc_alloc()
874 n_hdlc_buf_put(&n_hdlc->tx_free_buf_list,buf); in n_hdlc_alloc()
880 n_hdlc->magic = HDLC_MAGIC; in n_hdlc_alloc()
881 n_hdlc->flags = 0; in n_hdlc_alloc()
883 return n_hdlc; in n_hdlc_alloc()