Skip to content

Commit a3cc9fc

Browse files
Jiri Slabygregkh
authored andcommitted
TTY: ircomm, add tty_port
And use close/open_wait from there. Signed-off-by: Jiri Slaby <jslaby@suse.cz> Cc: Samuel Ortiz <samuel@sortiz.org> Cc: netdev@vger.kernel.org Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
1 parent 718c4ca commit a3cc9fc

3 files changed

Lines changed: 13 additions & 13 deletions

File tree

‎include/net/irda/ircomm_tty.h‎

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,7 @@
6262
*/
6363
struct ircomm_tty_cb {
6464
irda_queue_t queue; /* Must be first */
65+
struct tty_port port;
6566
magic_t magic;
6667

6768
int state; /* Connect state */
@@ -97,8 +98,6 @@ struct ircomm_tty_cb {
9798
void *skey;
9899
void *ckey;
99100

100-
wait_queue_head_t open_wait;
101-
wait_queue_head_t close_wait;
102101
struct timer_list watchdog_timer;
103102
struct work_struct tqueue;
104103

‎net/irda/ircomm/ircomm_tty.c‎

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -278,7 +278,7 @@ static int ircomm_tty_block_til_ready(struct ircomm_tty_cb *self,
278278
*/
279279

280280
retval = 0;
281-
add_wait_queue(&self->open_wait, &wait);
281+
add_wait_queue(&self->port.open_wait, &wait);
282282

283283
IRDA_DEBUG(2, "%s(%d):block_til_ready before block on %s open_count=%d\n",
284284
__FILE__,__LINE__, tty->driver->name, self->open_count );
@@ -336,7 +336,7 @@ static int ircomm_tty_block_til_ready(struct ircomm_tty_cb *self,
336336
}
337337

338338
__set_current_state(TASK_RUNNING);
339-
remove_wait_queue(&self->open_wait, &wait);
339+
remove_wait_queue(&self->port.open_wait, &wait);
340340

341341
if (extra_count) {
342342
/* ++ is not atomic, so this should be protected - Jean II */
@@ -381,6 +381,7 @@ static int ircomm_tty_open(struct tty_struct *tty, struct file *filp)
381381
return -ENOMEM;
382382
}
383383

384+
tty_port_init(&self->port);
384385
self->magic = IRCOMM_TTY_MAGIC;
385386
self->flow = FLOW_STOP;
386387

@@ -393,8 +394,6 @@ static int ircomm_tty_open(struct tty_struct *tty, struct file *filp)
393394

394395
/* Init some important stuff */
395396
init_timer(&self->watchdog_timer);
396-
init_waitqueue_head(&self->open_wait);
397-
init_waitqueue_head(&self->close_wait);
398397
spin_lock_init(&self->spinlock);
399398

400399
/*
@@ -408,6 +407,7 @@ static int ircomm_tty_open(struct tty_struct *tty, struct file *filp)
408407
tty->termios->c_oflag = 0;
409408

410409
/* Insert into hash */
410+
/* FIXME there is a window from find to here */
411411
hashbin_insert(ircomm_tty, (irda_queue_t *) self, line, NULL);
412412
}
413413
/* ++ is not atomic, so this should be protected - Jean II */
@@ -438,7 +438,8 @@ static int ircomm_tty_open(struct tty_struct *tty, struct file *filp)
438438
* probably better sleep uninterruptible?
439439
*/
440440

441-
if (wait_event_interruptible(self->close_wait, !test_bit(ASYNC_B_CLOSING, &self->flags))) {
441+
if (wait_event_interruptible(self->port.close_wait,
442+
!test_bit(ASYNC_B_CLOSING, &self->flags))) {
442443
IRDA_WARNING("%s - got signal while blocking on ASYNC_CLOSING!\n",
443444
__func__);
444445
return -ERESTARTSYS;
@@ -559,11 +560,11 @@ static void ircomm_tty_close(struct tty_struct *tty, struct file *filp)
559560
if (self->blocked_open) {
560561
if (self->close_delay)
561562
schedule_timeout_interruptible(self->close_delay);
562-
wake_up_interruptible(&self->open_wait);
563+
wake_up_interruptible(&self->port.open_wait);
563564
}
564565

565566
self->flags &= ~(ASYNC_NORMAL_ACTIVE|ASYNC_CLOSING);
566-
wake_up_interruptible(&self->close_wait);
567+
wake_up_interruptible(&self->port.close_wait);
567568
}
568569

569570
/*
@@ -1011,7 +1012,7 @@ static void ircomm_tty_hangup(struct tty_struct *tty)
10111012
self->open_count = 0;
10121013
spin_unlock_irqrestore(&self->spinlock, flags);
10131014

1014-
wake_up_interruptible(&self->open_wait);
1015+
wake_up_interruptible(&self->port.open_wait);
10151016
}
10161017

10171018
/*
@@ -1084,7 +1085,7 @@ void ircomm_tty_check_modem_status(struct ircomm_tty_cb *self)
10841085
(status & IRCOMM_CD) ? "on" : "off");
10851086

10861087
if (status & IRCOMM_CD) {
1087-
wake_up_interruptible(&self->open_wait);
1088+
wake_up_interruptible(&self->port.open_wait);
10881089
} else {
10891090
IRDA_DEBUG(2,
10901091
"%s(), Doing serial hangup..\n", __func__ );
@@ -1103,7 +1104,7 @@ void ircomm_tty_check_modem_status(struct ircomm_tty_cb *self)
11031104
tty->hw_stopped = 0;
11041105

11051106
/* Wake up processes blocked on open */
1106-
wake_up_interruptible(&self->open_wait);
1107+
wake_up_interruptible(&self->port.open_wait);
11071108

11081109
schedule_work(&self->tqueue);
11091110
return;

‎net/irda/ircomm/ircomm_tty_attach.c‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -575,7 +575,7 @@ void ircomm_tty_link_established(struct ircomm_tty_cb *self)
575575
self->tty->hw_stopped = 0;
576576

577577
/* Wake up processes blocked on open */
578-
wake_up_interruptible(&self->open_wait);
578+
wake_up_interruptible(&self->port.open_wait);
579579
}
580580

581581
schedule_work(&self->tqueue);

0 commit comments

Comments
 (0)