aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/tty
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/tty')
-rw-r--r--drivers/tty/cyclades.c2
-rw-r--r--drivers/tty/serial/crisv10.c15
-rw-r--r--drivers/tty/serial/serial_core.c8
-rw-r--r--drivers/tty/synclink.c10
-rw-r--r--drivers/tty/synclink_gt.c10
-rw-r--r--drivers/tty/synclinkmp.c11
-rw-r--r--drivers/tty/tty_port.c8
7 files changed, 18 insertions, 46 deletions
diff --git a/drivers/tty/cyclades.c b/drivers/tty/cyclades.c
index a57bb5ab761c..fd66f57390d0 100644
--- a/drivers/tty/cyclades.c
+++ b/drivers/tty/cyclades.c
@@ -1579,7 +1579,7 @@ static int cy_open(struct tty_struct *tty, struct file *filp)
1579 /* 1579 /*
1580 * If the port is the middle of closing, bail out now 1580 * If the port is the middle of closing, bail out now
1581 */ 1581 */
1582 if (tty_hung_up_p(filp) || (info->port.flags & ASYNC_CLOSING)) { 1582 if (info->port.flags & ASYNC_CLOSING) {
1583 wait_event_interruptible_tty(tty, info->port.close_wait, 1583 wait_event_interruptible_tty(tty, info->port.close_wait,
1584 !(info->port.flags & ASYNC_CLOSING)); 1584 !(info->port.flags & ASYNC_CLOSING));
1585 return (info->port.flags & ASYNC_HUP_NOTIFY) ? -EAGAIN: -ERESTARTSYS; 1585 return (info->port.flags & ASYNC_HUP_NOTIFY) ? -EAGAIN: -ERESTARTSYS;
diff --git a/drivers/tty/serial/crisv10.c b/drivers/tty/serial/crisv10.c
index d567ac5d3af4..58e6f61a87e4 100644
--- a/drivers/tty/serial/crisv10.c
+++ b/drivers/tty/serial/crisv10.c
@@ -3831,14 +3831,13 @@ block_til_ready(struct tty_struct *tty, struct file * filp,
3831 DECLARE_WAITQUEUE(wait, current); 3831 DECLARE_WAITQUEUE(wait, current);
3832 unsigned long flags; 3832 unsigned long flags;
3833 int retval; 3833 int retval;
3834 int do_clocal = 0, extra_count = 0; 3834 int do_clocal = 0;
3835 3835
3836 /* 3836 /*
3837 * If the device is in the middle of being closed, then block 3837 * If the device is in the middle of being closed, then block
3838 * until it's done, and then try again. 3838 * until it's done, and then try again.
3839 */ 3839 */
3840 if (tty_hung_up_p(filp) || 3840 if (info->port.flags & ASYNC_CLOSING) {
3841 (info->port.flags & ASYNC_CLOSING)) {
3842 wait_event_interruptible_tty(tty, info->port.close_wait, 3841 wait_event_interruptible_tty(tty, info->port.close_wait,
3843 !(info->port.flags & ASYNC_CLOSING)); 3842 !(info->port.flags & ASYNC_CLOSING));
3844#ifdef SERIAL_DO_RESTART 3843#ifdef SERIAL_DO_RESTART
@@ -3879,10 +3878,7 @@ block_til_ready(struct tty_struct *tty, struct file * filp,
3879 info->line, info->port.count); 3878 info->line, info->port.count);
3880#endif 3879#endif
3881 local_irq_save(flags); 3880 local_irq_save(flags);
3882 if (!tty_hung_up_p(filp)) { 3881 info->port.count--;
3883 extra_count++;
3884 info->port.count--;
3885 }
3886 local_irq_restore(flags); 3882 local_irq_restore(flags);
3887 info->port.blocked_open++; 3883 info->port.blocked_open++;
3888 while (1) { 3884 while (1) {
@@ -3921,7 +3917,7 @@ block_til_ready(struct tty_struct *tty, struct file * filp,
3921 } 3917 }
3922 set_current_state(TASK_RUNNING); 3918 set_current_state(TASK_RUNNING);
3923 remove_wait_queue(&info->port.open_wait, &wait); 3919 remove_wait_queue(&info->port.open_wait, &wait);
3924 if (extra_count) 3920 if (!tty_hung_up_p(filp))
3925 info->port.count++; 3921 info->port.count++;
3926 info->port.blocked_open--; 3922 info->port.blocked_open--;
3927#ifdef SERIAL_DEBUG_OPEN 3923#ifdef SERIAL_DEBUG_OPEN
@@ -3976,8 +3972,7 @@ rs_open(struct tty_struct *tty, struct file * filp)
3976 /* 3972 /*
3977 * If the port is in the middle of closing, bail out now 3973 * If the port is in the middle of closing, bail out now
3978 */ 3974 */
3979 if (tty_hung_up_p(filp) || 3975 if (info->port.flags & ASYNC_CLOSING) {
3980 (info->port.flags & ASYNC_CLOSING)) {
3981 wait_event_interruptible_tty(tty, info->port.close_wait, 3976 wait_event_interruptible_tty(tty, info->port.close_wait,
3982 !(info->port.flags & ASYNC_CLOSING)); 3977 !(info->port.flags & ASYNC_CLOSING));
3983#ifdef SERIAL_DO_RESTART 3978#ifdef SERIAL_DO_RESTART
diff --git a/drivers/tty/serial/serial_core.c b/drivers/tty/serial/serial_core.c
index 3e08df52d68d..1a5fbf7ab347 100644
--- a/drivers/tty/serial/serial_core.c
+++ b/drivers/tty/serial/serial_core.c
@@ -1584,14 +1584,6 @@ static int uart_open(struct tty_struct *tty, struct file *filp)
1584 tty_port_tty_set(port, tty); 1584 tty_port_tty_set(port, tty);
1585 1585
1586 /* 1586 /*
1587 * If the port is in the middle of closing, bail out now.
1588 */
1589 if (tty_hung_up_p(filp)) {
1590 retval = -EAGAIN;
1591 goto err_dec_count;
1592 }
1593
1594 /*
1595 * Start up the serial port. 1587 * Start up the serial port.
1596 */ 1588 */
1597 retval = uart_startup(tty, state, 0); 1589 retval = uart_startup(tty, state, 0);
diff --git a/drivers/tty/synclink.c b/drivers/tty/synclink.c
index d48e040cd8c5..b7991707ffc0 100644
--- a/drivers/tty/synclink.c
+++ b/drivers/tty/synclink.c
@@ -3267,7 +3267,6 @@ static int block_til_ready(struct tty_struct *tty, struct file * filp,
3267 DECLARE_WAITQUEUE(wait, current); 3267 DECLARE_WAITQUEUE(wait, current);
3268 int retval; 3268 int retval;
3269 bool do_clocal = false; 3269 bool do_clocal = false;
3270 bool extra_count = false;
3271 unsigned long flags; 3270 unsigned long flags;
3272 int dcd; 3271 int dcd;
3273 struct tty_port *port = &info->port; 3272 struct tty_port *port = &info->port;
@@ -3300,10 +3299,7 @@ static int block_til_ready(struct tty_struct *tty, struct file * filp,
3300 __FILE__,__LINE__, tty->driver->name, port->count ); 3299 __FILE__,__LINE__, tty->driver->name, port->count );
3301 3300
3302 spin_lock_irqsave(&info->irq_spinlock, flags); 3301 spin_lock_irqsave(&info->irq_spinlock, flags);
3303 if (!tty_hung_up_p(filp)) { 3302 port->count--;
3304 extra_count = true;
3305 port->count--;
3306 }
3307 spin_unlock_irqrestore(&info->irq_spinlock, flags); 3303 spin_unlock_irqrestore(&info->irq_spinlock, flags);
3308 port->blocked_open++; 3304 port->blocked_open++;
3309 3305
@@ -3342,7 +3338,7 @@ static int block_til_ready(struct tty_struct *tty, struct file * filp,
3342 remove_wait_queue(&port->open_wait, &wait); 3338 remove_wait_queue(&port->open_wait, &wait);
3343 3339
3344 /* FIXME: Racy on hangup during close wait */ 3340 /* FIXME: Racy on hangup during close wait */
3345 if (extra_count) 3341 if (!tty_hung_up_p(filp))
3346 port->count++; 3342 port->count++;
3347 port->blocked_open--; 3343 port->blocked_open--;
3348 3344
@@ -3403,7 +3399,7 @@ static int mgsl_open(struct tty_struct *tty, struct file * filp)
3403 __FILE__,__LINE__,tty->driver->name, info->port.count); 3399 __FILE__,__LINE__,tty->driver->name, info->port.count);
3404 3400
3405 /* If port is closing, signal caller to try again */ 3401 /* If port is closing, signal caller to try again */
3406 if (tty_hung_up_p(filp) || info->port.flags & ASYNC_CLOSING){ 3402 if (info->port.flags & ASYNC_CLOSING){
3407 wait_event_interruptible_tty(tty, info->port.close_wait, 3403 wait_event_interruptible_tty(tty, info->port.close_wait,
3408 !(info->port.flags & ASYNC_CLOSING)); 3404 !(info->port.flags & ASYNC_CLOSING));
3409 retval = ((info->port.flags & ASYNC_HUP_NOTIFY) ? 3405 retval = ((info->port.flags & ASYNC_HUP_NOTIFY) ?
diff --git a/drivers/tty/synclink_gt.c b/drivers/tty/synclink_gt.c
index c359a91f7346..ba1dbcdf4609 100644
--- a/drivers/tty/synclink_gt.c
+++ b/drivers/tty/synclink_gt.c
@@ -673,7 +673,7 @@ static int open(struct tty_struct *tty, struct file *filp)
673 DBGINFO(("%s open, old ref count = %d\n", info->device_name, info->port.count)); 673 DBGINFO(("%s open, old ref count = %d\n", info->device_name, info->port.count));
674 674
675 /* If port is closing, signal caller to try again */ 675 /* If port is closing, signal caller to try again */
676 if (tty_hung_up_p(filp) || info->port.flags & ASYNC_CLOSING){ 676 if (info->port.flags & ASYNC_CLOSING){
677 wait_event_interruptible_tty(tty, info->port.close_wait, 677 wait_event_interruptible_tty(tty, info->port.close_wait,
678 !(info->port.flags & ASYNC_CLOSING)); 678 !(info->port.flags & ASYNC_CLOSING));
679 retval = ((info->port.flags & ASYNC_HUP_NOTIFY) ? 679 retval = ((info->port.flags & ASYNC_HUP_NOTIFY) ?
@@ -3273,7 +3273,6 @@ static int block_til_ready(struct tty_struct *tty, struct file *filp,
3273 DECLARE_WAITQUEUE(wait, current); 3273 DECLARE_WAITQUEUE(wait, current);
3274 int retval; 3274 int retval;
3275 bool do_clocal = false; 3275 bool do_clocal = false;
3276 bool extra_count = false;
3277 unsigned long flags; 3276 unsigned long flags;
3278 int cd; 3277 int cd;
3279 struct tty_port *port = &info->port; 3278 struct tty_port *port = &info->port;
@@ -3300,10 +3299,7 @@ static int block_til_ready(struct tty_struct *tty, struct file *filp,
3300 add_wait_queue(&port->open_wait, &wait); 3299 add_wait_queue(&port->open_wait, &wait);
3301 3300
3302 spin_lock_irqsave(&info->lock, flags); 3301 spin_lock_irqsave(&info->lock, flags);
3303 if (!tty_hung_up_p(filp)) { 3302 port->count--;
3304 extra_count = true;
3305 port->count--;
3306 }
3307 spin_unlock_irqrestore(&info->lock, flags); 3303 spin_unlock_irqrestore(&info->lock, flags);
3308 port->blocked_open++; 3304 port->blocked_open++;
3309 3305
@@ -3338,7 +3334,7 @@ static int block_til_ready(struct tty_struct *tty, struct file *filp,
3338 set_current_state(TASK_RUNNING); 3334 set_current_state(TASK_RUNNING);
3339 remove_wait_queue(&port->open_wait, &wait); 3335 remove_wait_queue(&port->open_wait, &wait);
3340 3336
3341 if (extra_count) 3337 if (!tty_hung_up_p(filp))
3342 port->count++; 3338 port->count++;
3343 port->blocked_open--; 3339 port->blocked_open--;
3344 3340
diff --git a/drivers/tty/synclinkmp.c b/drivers/tty/synclinkmp.c
index 53ba8537de8d..c3f90910fed9 100644
--- a/drivers/tty/synclinkmp.c
+++ b/drivers/tty/synclinkmp.c
@@ -753,7 +753,7 @@ static int open(struct tty_struct *tty, struct file *filp)
753 __FILE__,__LINE__,tty->driver->name, info->port.count); 753 __FILE__,__LINE__,tty->driver->name, info->port.count);
754 754
755 /* If port is closing, signal caller to try again */ 755 /* If port is closing, signal caller to try again */
756 if (tty_hung_up_p(filp) || info->port.flags & ASYNC_CLOSING){ 756 if (info->port.flags & ASYNC_CLOSING){
757 wait_event_interruptible_tty(tty, info->port.close_wait, 757 wait_event_interruptible_tty(tty, info->port.close_wait,
758 !(info->port.flags & ASYNC_CLOSING)); 758 !(info->port.flags & ASYNC_CLOSING));
759 retval = ((info->port.flags & ASYNC_HUP_NOTIFY) ? 759 retval = ((info->port.flags & ASYNC_HUP_NOTIFY) ?
@@ -3288,7 +3288,6 @@ static int block_til_ready(struct tty_struct *tty, struct file *filp,
3288 DECLARE_WAITQUEUE(wait, current); 3288 DECLARE_WAITQUEUE(wait, current);
3289 int retval; 3289 int retval;
3290 bool do_clocal = false; 3290 bool do_clocal = false;
3291 bool extra_count = false;
3292 unsigned long flags; 3291 unsigned long flags;
3293 int cd; 3292 int cd;
3294 struct tty_port *port = &info->port; 3293 struct tty_port *port = &info->port;
@@ -3322,10 +3321,7 @@ static int block_til_ready(struct tty_struct *tty, struct file *filp,
3322 __FILE__,__LINE__, tty->driver->name, port->count ); 3321 __FILE__,__LINE__, tty->driver->name, port->count );
3323 3322
3324 spin_lock_irqsave(&info->lock, flags); 3323 spin_lock_irqsave(&info->lock, flags);
3325 if (!tty_hung_up_p(filp)) { 3324 port->count--;
3326 extra_count = true;
3327 port->count--;
3328 }
3329 spin_unlock_irqrestore(&info->lock, flags); 3325 spin_unlock_irqrestore(&info->lock, flags);
3330 port->blocked_open++; 3326 port->blocked_open++;
3331 3327
@@ -3362,8 +3358,7 @@ static int block_til_ready(struct tty_struct *tty, struct file *filp,
3362 3358
3363 set_current_state(TASK_RUNNING); 3359 set_current_state(TASK_RUNNING);
3364 remove_wait_queue(&port->open_wait, &wait); 3360 remove_wait_queue(&port->open_wait, &wait);
3365 3361 if (!tty_hung_up_p(filp))
3366 if (extra_count)
3367 port->count++; 3362 port->count++;
3368 port->blocked_open--; 3363 port->blocked_open--;
3369 3364
diff --git a/drivers/tty/tty_port.c b/drivers/tty/tty_port.c
index 9209d6331b8e..1b9335796da4 100644
--- a/drivers/tty/tty_port.c
+++ b/drivers/tty/tty_port.c
@@ -365,7 +365,7 @@ int tty_port_block_til_ready(struct tty_port *port,
365 DEFINE_WAIT(wait); 365 DEFINE_WAIT(wait);
366 366
367 /* block if port is in the process of being closed */ 367 /* block if port is in the process of being closed */
368 if (tty_hung_up_p(filp) || port->flags & ASYNC_CLOSING) { 368 if (port->flags & ASYNC_CLOSING) {
369 wait_event_interruptible_tty(tty, port->close_wait, 369 wait_event_interruptible_tty(tty, port->close_wait,
370 !(port->flags & ASYNC_CLOSING)); 370 !(port->flags & ASYNC_CLOSING));
371 if (port->flags & ASYNC_HUP_NOTIFY) 371 if (port->flags & ASYNC_HUP_NOTIFY)
@@ -399,8 +399,7 @@ int tty_port_block_til_ready(struct tty_port *port,
399 399
400 /* The port lock protects the port counts */ 400 /* The port lock protects the port counts */
401 spin_lock_irqsave(&port->lock, flags); 401 spin_lock_irqsave(&port->lock, flags);
402 if (!tty_hung_up_p(filp)) 402 port->count--;
403 port->count--;
404 port->blocked_open++; 403 port->blocked_open++;
405 spin_unlock_irqrestore(&port->lock, flags); 404 spin_unlock_irqrestore(&port->lock, flags);
406 405
@@ -593,8 +592,7 @@ int tty_port_open(struct tty_port *port, struct tty_struct *tty,
593 struct file *filp) 592 struct file *filp)
594{ 593{
595 spin_lock_irq(&port->lock); 594 spin_lock_irq(&port->lock);
596 if (!tty_hung_up_p(filp)) 595 ++port->count;
597 ++port->count;
598 spin_unlock_irq(&port->lock); 596 spin_unlock_irq(&port->lock);
599 tty_port_tty_set(port, tty); 597 tty_port_tty_set(port, tty);
600 598