aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/char/n_hdlc.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/char/n_hdlc.c')
-rw-r--r--drivers/char/n_hdlc.c37
1 files changed, 23 insertions, 14 deletions
diff --git a/drivers/char/n_hdlc.c b/drivers/char/n_hdlc.c
index 82bcfb9c839a..a35bfd7ee80e 100644
--- a/drivers/char/n_hdlc.c
+++ b/drivers/char/n_hdlc.c
@@ -342,12 +342,10 @@ static int n_hdlc_tty_open (struct tty_struct *tty)
342#endif 342#endif
343 343
344 /* Flush any pending characters in the driver and discipline. */ 344 /* Flush any pending characters in the driver and discipline. */
345
346 if (tty->ldisc.flush_buffer) 345 if (tty->ldisc.flush_buffer)
347 tty->ldisc.flush_buffer (tty); 346 tty->ldisc.flush_buffer(tty);
348 347
349 if (tty->driver->flush_buffer) 348 tty_driver_flush_buffer(tty);
350 tty->driver->flush_buffer (tty);
351 349
352 if (debuglevel >= DEBUG_LEVEL_INFO) 350 if (debuglevel >= DEBUG_LEVEL_INFO)
353 printk("%s(%d)n_hdlc_tty_open() success\n",__FILE__,__LINE__); 351 printk("%s(%d)n_hdlc_tty_open() success\n",__FILE__,__LINE__);
@@ -399,7 +397,7 @@ static void n_hdlc_send_frames(struct n_hdlc *n_hdlc, struct tty_struct *tty)
399 397
400 /* Send the next block of data to device */ 398 /* Send the next block of data to device */
401 tty->flags |= (1 << TTY_DO_WRITE_WAKEUP); 399 tty->flags |= (1 << TTY_DO_WRITE_WAKEUP);
402 actual = tty->driver->write(tty, tbuf->buf, tbuf->count); 400 actual = tty->ops->write(tty, tbuf->buf, tbuf->count);
403 401
404 /* rollback was possible and has been done */ 402 /* rollback was possible and has been done */
405 if (actual == -ERESTARTSYS) { 403 if (actual == -ERESTARTSYS) {
@@ -501,7 +499,7 @@ static void n_hdlc_tty_receive(struct tty_struct *tty, const __u8 *data,
501 __FILE__,__LINE__, count); 499 __FILE__,__LINE__, count);
502 500
503 /* This can happen if stuff comes in on the backup tty */ 501 /* This can happen if stuff comes in on the backup tty */
504 if (n_hdlc == 0 || tty != n_hdlc->tty) 502 if (!n_hdlc || tty != n_hdlc->tty)
505 return; 503 return;
506 504
507 /* verify line is using HDLC discipline */ 505 /* verify line is using HDLC discipline */
@@ -578,26 +576,36 @@ static ssize_t n_hdlc_tty_read(struct tty_struct *tty, struct file *file,
578 return -EFAULT; 576 return -EFAULT;
579 } 577 }
580 578
579 lock_kernel();
580
581 for (;;) { 581 for (;;) {
582 if (test_bit(TTY_OTHER_CLOSED, &tty->flags)) 582 if (test_bit(TTY_OTHER_CLOSED, &tty->flags)) {
583 unlock_kernel();
583 return -EIO; 584 return -EIO;
585 }
584 586
585 n_hdlc = tty2n_hdlc (tty); 587 n_hdlc = tty2n_hdlc (tty);
586 if (!n_hdlc || n_hdlc->magic != HDLC_MAGIC || 588 if (!n_hdlc || n_hdlc->magic != HDLC_MAGIC ||
587 tty != n_hdlc->tty) 589 tty != n_hdlc->tty) {
590 unlock_kernel();
588 return 0; 591 return 0;
592 }
589 593
590 rbuf = n_hdlc_buf_get(&n_hdlc->rx_buf_list); 594 rbuf = n_hdlc_buf_get(&n_hdlc->rx_buf_list);
591 if (rbuf) 595 if (rbuf)
592 break; 596 break;
593 597
594 /* no data */ 598 /* no data */
595 if (file->f_flags & O_NONBLOCK) 599 if (file->f_flags & O_NONBLOCK) {
600 unlock_kernel();
596 return -EAGAIN; 601 return -EAGAIN;
602 }
597 603
598 interruptible_sleep_on (&tty->read_wait); 604 interruptible_sleep_on (&tty->read_wait);
599 if (signal_pending(current)) 605 if (signal_pending(current)) {
606 unlock_kernel();
600 return -EINTR; 607 return -EINTR;
608 }
601 } 609 }
602 610
603 if (rbuf->count > nr) 611 if (rbuf->count > nr)
@@ -618,7 +626,7 @@ static ssize_t n_hdlc_tty_read(struct tty_struct *tty, struct file *file,
618 kfree(rbuf); 626 kfree(rbuf);
619 else 627 else
620 n_hdlc_buf_put(&n_hdlc->rx_free_buf_list,rbuf); 628 n_hdlc_buf_put(&n_hdlc->rx_free_buf_list,rbuf);
621 629 unlock_kernel();
622 return ret; 630 return ret;
623 631
624} /* end of n_hdlc_tty_read() */ 632} /* end of n_hdlc_tty_read() */
@@ -661,6 +669,8 @@ static ssize_t n_hdlc_tty_write(struct tty_struct *tty, struct file *file,
661 count = maxframe; 669 count = maxframe;
662 } 670 }
663 671
672 lock_kernel();
673
664 add_wait_queue(&tty->write_wait, &wait); 674 add_wait_queue(&tty->write_wait, &wait);
665 set_current_state(TASK_INTERRUPTIBLE); 675 set_current_state(TASK_INTERRUPTIBLE);
666 676
@@ -695,7 +705,7 @@ static ssize_t n_hdlc_tty_write(struct tty_struct *tty, struct file *file,
695 n_hdlc_buf_put(&n_hdlc->tx_buf_list,tbuf); 705 n_hdlc_buf_put(&n_hdlc->tx_buf_list,tbuf);
696 n_hdlc_send_frames(n_hdlc,tty); 706 n_hdlc_send_frames(n_hdlc,tty);
697 } 707 }
698 708 unlock_kernel();
699 return error; 709 return error;
700 710
701} /* end of n_hdlc_tty_write() */ 711} /* end of n_hdlc_tty_write() */
@@ -740,8 +750,7 @@ static int n_hdlc_tty_ioctl(struct tty_struct *tty, struct file *file,
740 750
741 case TIOCOUTQ: 751 case TIOCOUTQ:
742 /* get the pending tx byte count in the driver */ 752 /* get the pending tx byte count in the driver */
743 count = tty->driver->chars_in_buffer ? 753 count = tty_chars_in_buffer(tty);
744 tty->driver->chars_in_buffer(tty) : 0;
745 /* add size of next output frame in queue */ 754 /* add size of next output frame in queue */
746 spin_lock_irqsave(&n_hdlc->tx_buf_list.spinlock,flags); 755 spin_lock_irqsave(&n_hdlc->tx_buf_list.spinlock,flags);
747 if (n_hdlc->tx_buf_list.head) 756 if (n_hdlc->tx_buf_list.head)