diff options
author | Jiri Slaby <jirislaby@gmail.com> | 2009-09-19 16:13:13 -0400 |
---|---|---|
committer | Live-CD User <linux@linux.site> | 2009-09-19 16:13:13 -0400 |
commit | 23342262964722b41c7d06cfadc215039e48881b (patch) | |
tree | a422b1a07945d9b2bb6e3657de9c97478cdae920 /drivers | |
parent | 174e6fe01e7881caaa350b5e98e4c6189b6cb593 (diff) |
cyclades: close cleanup
Use new tty helpers for close, which allows much code removal.
The only real change is locking. card_lock for protecting was
used inappropriately (just to have a critical section, no matter
which lock is used), so the change to port->lock is fine.
Remove also useless debug printks while being there.
Signed-off-by: Jiri Slaby <jirislaby@gmail.com>
Signed-off-by: Alan Cox <alan@linux.intel.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
Diffstat (limited to 'drivers')
-rw-r--r-- | drivers/char/cyclades.c | 70 |
1 files changed, 2 insertions, 68 deletions
diff --git a/drivers/char/cyclades.c b/drivers/char/cyclades.c index 226175d605c3..87a40bc75646 100644 --- a/drivers/char/cyclades.c +++ b/drivers/char/cyclades.c | |||
@@ -2361,61 +2361,13 @@ static void cy_close(struct tty_struct *tty, struct file *filp) | |||
2361 | struct cyclades_card *card; | 2361 | struct cyclades_card *card; |
2362 | unsigned long flags; | 2362 | unsigned long flags; |
2363 | 2363 | ||
2364 | #ifdef CY_DEBUG_OTHER | ||
2365 | printk(KERN_DEBUG "cyc:cy_close ttyC%d\n", info->line); | ||
2366 | #endif | ||
2367 | |||
2368 | if (!info || serial_paranoia_check(info, tty->name, "cy_close")) | 2364 | if (!info || serial_paranoia_check(info, tty->name, "cy_close")) |
2369 | return; | 2365 | return; |
2370 | 2366 | ||
2371 | card = info->card; | 2367 | card = info->card; |
2372 | 2368 | ||
2373 | spin_lock_irqsave(&card->card_lock, flags); | 2369 | if (!tty_port_close_start(&info->port, tty, filp)) |
2374 | /* If the TTY is being hung up, nothing to do */ | ||
2375 | if (tty_hung_up_p(filp)) { | ||
2376 | spin_unlock_irqrestore(&card->card_lock, flags); | ||
2377 | return; | 2370 | return; |
2378 | } | ||
2379 | #ifdef CY_DEBUG_OPEN | ||
2380 | printk(KERN_DEBUG "cyc:cy_close ttyC%d, count = %d\n", info->line, | ||
2381 | info->port.count); | ||
2382 | #endif | ||
2383 | if ((tty->count == 1) && (info->port.count != 1)) { | ||
2384 | /* | ||
2385 | * Uh, oh. tty->count is 1, which means that the tty | ||
2386 | * structure will be freed. Info->count should always | ||
2387 | * be one in these conditions. If it's greater than | ||
2388 | * one, we've got real problems, since it means the | ||
2389 | * serial port won't be shutdown. | ||
2390 | */ | ||
2391 | printk(KERN_ERR "cyc:cy_close: bad serial port count; " | ||
2392 | "tty->count is 1, info->port.count is %d\n", info->port.count); | ||
2393 | info->port.count = 1; | ||
2394 | } | ||
2395 | #ifdef CY_DEBUG_COUNT | ||
2396 | printk(KERN_DEBUG "cyc:cy_close at (%d): decrementing count to %d\n", | ||
2397 | current->pid, info->port.count - 1); | ||
2398 | #endif | ||
2399 | if (--info->port.count < 0) { | ||
2400 | #ifdef CY_DEBUG_COUNT | ||
2401 | printk(KERN_DEBUG "cyc:cyc_close setting count to 0\n"); | ||
2402 | #endif | ||
2403 | info->port.count = 0; | ||
2404 | } | ||
2405 | if (info->port.count) { | ||
2406 | spin_unlock_irqrestore(&card->card_lock, flags); | ||
2407 | return; | ||
2408 | } | ||
2409 | info->port.flags |= ASYNC_CLOSING; | ||
2410 | |||
2411 | /* | ||
2412 | * Now we wait for the transmit buffer to clear; and we notify | ||
2413 | * the line discipline to only process XON/XOFF characters. | ||
2414 | */ | ||
2415 | tty->closing = 1; | ||
2416 | spin_unlock_irqrestore(&card->card_lock, flags); | ||
2417 | if (info->port.closing_wait != CY_CLOSING_WAIT_NONE) | ||
2418 | tty_wait_until_sent(tty, info->port.closing_wait); | ||
2419 | 2371 | ||
2420 | spin_lock_irqsave(&card->card_lock, flags); | 2372 | spin_lock_irqsave(&card->card_lock, flags); |
2421 | 2373 | ||
@@ -2460,28 +2412,10 @@ static void cy_close(struct tty_struct *tty, struct file *filp) | |||
2460 | spin_unlock_irqrestore(&card->card_lock, flags); | 2412 | spin_unlock_irqrestore(&card->card_lock, flags); |
2461 | cy_shutdown(info, tty); | 2413 | cy_shutdown(info, tty); |
2462 | cy_flush_buffer(tty); | 2414 | cy_flush_buffer(tty); |
2463 | tty_ldisc_flush(tty); | ||
2464 | spin_lock_irqsave(&card->card_lock, flags); | ||
2465 | 2415 | ||
2466 | tty->closing = 0; | ||
2467 | tty_port_tty_set(&info->port, NULL); | 2416 | tty_port_tty_set(&info->port, NULL); |
2468 | if (info->port.blocked_open) { | ||
2469 | spin_unlock_irqrestore(&card->card_lock, flags); | ||
2470 | if (info->port.close_delay) { | ||
2471 | msleep_interruptible(jiffies_to_msecs | ||
2472 | (info->port.close_delay)); | ||
2473 | } | ||
2474 | wake_up_interruptible(&info->port.open_wait); | ||
2475 | spin_lock_irqsave(&card->card_lock, flags); | ||
2476 | } | ||
2477 | info->port.flags &= ~(ASYNC_NORMAL_ACTIVE | ASYNC_CLOSING); | ||
2478 | wake_up_interruptible(&info->port.close_wait); | ||
2479 | 2417 | ||
2480 | #ifdef CY_DEBUG_OTHER | 2418 | tty_port_close_end(&info->port, tty); |
2481 | printk(KERN_DEBUG "cyc:cy_close done\n"); | ||
2482 | #endif | ||
2483 | |||
2484 | spin_unlock_irqrestore(&card->card_lock, flags); | ||
2485 | } /* cy_close */ | 2419 | } /* cy_close */ |
2486 | 2420 | ||
2487 | /* This routine gets called when tty_write has put something into | 2421 | /* This routine gets called when tty_write has put something into |