Skip to content

Commit 580d27b

Browse files
Jiri Slabygregkh
authored andcommitted
TTY: ircomm, use open counts from tty_port
Switch to tty_port->count and blocked_open. 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 2a0213c commit 580d27b

2 files changed

Lines changed: 21 additions & 24 deletions

File tree

‎include/net/irda/ircomm_tty.h‎

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -101,9 +101,6 @@ struct ircomm_tty_cb {
101101
struct timer_list watchdog_timer;
102102
struct work_struct tqueue;
103103

104-
int open_count;
105-
int blocked_open; /* # of blocked opens */
106-
107104
/* Protect concurent access to :
108105
* o self->open_count
109106
* o self->ctrl_skb

‎net/irda/ircomm/ircomm_tty.c‎

Lines changed: 21 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -272,7 +272,7 @@ static int ircomm_tty_block_til_ready(struct ircomm_tty_cb *self,
272272

273273
/* Wait for carrier detect and the line to become
274274
* free (i.e., not in use by the callout). While we are in
275-
* this loop, self->open_count is dropped by one, so that
275+
* this loop, self->port.count is dropped by one, so that
276276
* mgsl_close() knows when to free things. We restore it upon
277277
* exit, either normal or abnormal.
278278
*/
@@ -281,16 +281,16 @@ static int ircomm_tty_block_til_ready(struct ircomm_tty_cb *self,
281281
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",
284-
__FILE__,__LINE__, tty->driver->name, self->open_count );
284+
__FILE__, __LINE__, tty->driver->name, self->port.count);
285285

286-
/* As far as I can see, we protect open_count - Jean II */
286+
/* As far as I can see, we protect port.count - Jean II */
287287
spin_lock_irqsave(&self->spinlock, flags);
288288
if (!tty_hung_up_p(filp)) {
289289
extra_count = 1;
290-
self->open_count--;
290+
self->port.count--;
291291
}
292292
spin_unlock_irqrestore(&self->spinlock, flags);
293-
self->blocked_open++;
293+
self->port.blocked_open++;
294294

295295
while (1) {
296296
if (tty->termios->c_cflag & CBAUD) {
@@ -330,7 +330,7 @@ static int ircomm_tty_block_til_ready(struct ircomm_tty_cb *self,
330330
}
331331

332332
IRDA_DEBUG(1, "%s(%d):block_til_ready blocking on %s open_count=%d\n",
333-
__FILE__,__LINE__, tty->driver->name, self->open_count );
333+
__FILE__, __LINE__, tty->driver->name, self->port.count);
334334

335335
schedule();
336336
}
@@ -341,13 +341,13 @@ static int ircomm_tty_block_til_ready(struct ircomm_tty_cb *self,
341341
if (extra_count) {
342342
/* ++ is not atomic, so this should be protected - Jean II */
343343
spin_lock_irqsave(&self->spinlock, flags);
344-
self->open_count++;
344+
self->port.count++;
345345
spin_unlock_irqrestore(&self->spinlock, flags);
346346
}
347-
self->blocked_open--;
347+
self->port.blocked_open--;
348348

349349
IRDA_DEBUG(1, "%s(%d):block_til_ready after blocking on %s open_count=%d\n",
350-
__FILE__,__LINE__, tty->driver->name, self->open_count);
350+
__FILE__, __LINE__, tty->driver->name, self->port.count);
351351

352352
if (!retval)
353353
self->flags |= ASYNC_NORMAL_ACTIVE;
@@ -410,14 +410,14 @@ static int ircomm_tty_open(struct tty_struct *tty, struct file *filp)
410410
}
411411
/* ++ is not atomic, so this should be protected - Jean II */
412412
spin_lock_irqsave(&self->spinlock, flags);
413-
self->open_count++;
413+
self->port.count++;
414414

415415
tty->driver_data = self;
416416
self->tty = tty;
417417
spin_unlock_irqrestore(&self->spinlock, flags);
418418

419419
IRDA_DEBUG(1, "%s(), %s%d, count = %d\n", __func__ , tty->driver->name,
420-
self->line, self->open_count);
420+
self->line, self->port.count);
421421

422422
/* Not really used by us, but lets do it anyway */
423423
self->tty->low_latency = (self->flags & ASYNC_LOW_LATENCY) ? 1 : 0;
@@ -504,7 +504,7 @@ static void ircomm_tty_close(struct tty_struct *tty, struct file *filp)
504504
return;
505505
}
506506

507-
if ((tty->count == 1) && (self->open_count != 1)) {
507+
if ((tty->count == 1) && (self->port.count != 1)) {
508508
/*
509509
* Uh, oh. tty->count is 1, which means that the tty
510510
* structure will be freed. state->count should always
@@ -514,16 +514,16 @@ static void ircomm_tty_close(struct tty_struct *tty, struct file *filp)
514514
*/
515515
IRDA_DEBUG(0, "%s(), bad serial port count; "
516516
"tty->count is 1, state->count is %d\n", __func__ ,
517-
self->open_count);
518-
self->open_count = 1;
517+
self->port.count);
518+
self->port.count = 1;
519519
}
520520

521-
if (--self->open_count < 0) {
521+
if (--self->port.count < 0) {
522522
IRDA_ERROR("%s(), bad serial port count for ttys%d: %d\n",
523-
__func__, self->line, self->open_count);
524-
self->open_count = 0;
523+
__func__, self->line, self->port.count);
524+
self->port.count = 0;
525525
}
526-
if (self->open_count) {
526+
if (self->port.count) {
527527
spin_unlock_irqrestore(&self->spinlock, flags);
528528

529529
IRDA_DEBUG(0, "%s(), open count > 0\n", __func__ );
@@ -555,7 +555,7 @@ static void ircomm_tty_close(struct tty_struct *tty, struct file *filp)
555555
tty->closing = 0;
556556
self->tty = NULL;
557557

558-
if (self->blocked_open) {
558+
if (self->port.blocked_open) {
559559
if (self->port.close_delay)
560560
schedule_timeout_interruptible(self->port.close_delay);
561561
wake_up_interruptible(&self->port.open_wait);
@@ -1007,7 +1007,7 @@ static void ircomm_tty_hangup(struct tty_struct *tty)
10071007
spin_lock_irqsave(&self->spinlock, flags);
10081008
self->flags &= ~ASYNC_NORMAL_ACTIVE;
10091009
self->tty = NULL;
1010-
self->open_count = 0;
1010+
self->port.count = 0;
10111011
spin_unlock_irqrestore(&self->spinlock, flags);
10121012

10131013
wake_up_interruptible(&self->port.open_wait);
@@ -1354,7 +1354,7 @@ static void ircomm_tty_line_info(struct ircomm_tty_cb *self, struct seq_file *m)
13541354
seq_putc(m, '\n');
13551355

13561356
seq_printf(m, "Role: %s\n", self->client ? "client" : "server");
1357-
seq_printf(m, "Open count: %d\n", self->open_count);
1357+
seq_printf(m, "Open count: %d\n", self->port.count);
13581358
seq_printf(m, "Max data size: %d\n", self->max_data_size);
13591359
seq_printf(m, "Max header size: %d\n", self->max_header_size);
13601360

0 commit comments

Comments
 (0)