diff options
author | Jiri Slaby <jslaby@suse.cz> | 2012-03-05 08:52:38 -0500 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@linuxfoundation.org> | 2012-03-08 15:48:28 -0500 |
commit | 458cd31a4c33ce489eb538193f801ac73ff4010b (patch) | |
tree | 29209b308ae9c4425c7dbb636aea7be00dbdc8ed /arch/ia64/hp/sim/simserial.c | |
parent | 9aead90a7f5772fc74f733242d953688748b0ce4 (diff) |
TTY: simserial, use tty_port_hangup
Convert shutdown to be tty_port_operations->shutdown. Then we can use
tty_port_hangup. (And we have to use tty_port_close.)
This means we no longer touch ASYNC_INITIALIZED, TTY_IO_ERROR. Also we
do not need to do any peculiar TTY logic in the file now.
Signed-off-by: Jiri Slaby <jslaby@suse.cz>
Cc: Tony Luck <tony.luck@intel.com>
Cc: Fenghua Yu <fenghua.yu@intel.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'arch/ia64/hp/sim/simserial.c')
-rw-r--r-- | arch/ia64/hp/sim/simserial.c | 64 |
1 files changed, 7 insertions, 57 deletions
diff --git a/arch/ia64/hp/sim/simserial.c b/arch/ia64/hp/sim/simserial.c index e9c5fb7b923d..323c9325e570 100644 --- a/arch/ia64/hp/sim/simserial.c +++ b/arch/ia64/hp/sim/simserial.c | |||
@@ -388,17 +388,11 @@ static void rs_set_termios(struct tty_struct *tty, struct ktermios *old_termios) | |||
388 | * This routine will shutdown a serial port; interrupts are disabled, and | 388 | * This routine will shutdown a serial port; interrupts are disabled, and |
389 | * DTR is dropped if the hangup on close termio flag is on. | 389 | * DTR is dropped if the hangup on close termio flag is on. |
390 | */ | 390 | */ |
391 | static void shutdown(struct tty_struct *tty, struct serial_state *info) | 391 | static void shutdown(struct tty_port *port) |
392 | { | 392 | { |
393 | unsigned long flags; | 393 | struct serial_state *info = container_of(port, struct serial_state, |
394 | 394 | port); | |
395 | if (!(info->port.flags & ASYNC_INITIALIZED)) | 395 | unsigned long flags; |
396 | return; | ||
397 | |||
398 | #ifdef SIMSERIAL_DEBUG | ||
399 | printk("Shutting down serial port %d (irq %d)...\n", info->line, | ||
400 | info->irq); | ||
401 | #endif | ||
402 | 396 | ||
403 | local_irq_save(flags); | 397 | local_irq_save(flags); |
404 | { | 398 | { |
@@ -409,70 +403,25 @@ static void shutdown(struct tty_struct *tty, struct serial_state *info) | |||
409 | free_page((unsigned long) info->xmit.buf); | 403 | free_page((unsigned long) info->xmit.buf); |
410 | info->xmit.buf = NULL; | 404 | info->xmit.buf = NULL; |
411 | } | 405 | } |
412 | |||
413 | set_bit(TTY_IO_ERROR, &tty->flags); | ||
414 | |||
415 | info->port.flags &= ~ASYNC_INITIALIZED; | ||
416 | } | 406 | } |
417 | local_irq_restore(flags); | 407 | local_irq_restore(flags); |
418 | } | 408 | } |
419 | 409 | ||
420 | /* | ||
421 | * ------------------------------------------------------------ | ||
422 | * rs_close() | ||
423 | * | ||
424 | * This routine is called when the serial port gets closed. First, we | ||
425 | * wait for the last remaining data to be sent. Then, we unlink its | ||
426 | * async structure from the interrupt chain if necessary, and we free | ||
427 | * that IRQ if nothing is left in the chain. | ||
428 | * ------------------------------------------------------------ | ||
429 | */ | ||
430 | static void rs_close(struct tty_struct *tty, struct file * filp) | 410 | static void rs_close(struct tty_struct *tty, struct file * filp) |
431 | { | 411 | { |
432 | struct serial_state *info = tty->driver_data; | 412 | struct serial_state *info = tty->driver_data; |
433 | struct tty_port *port = &info->port; | ||
434 | |||
435 | if (!info) | ||
436 | return; | ||
437 | |||
438 | if (tty_port_close_start(port, tty, filp) == 0) | ||
439 | return; | ||
440 | |||
441 | /* | ||
442 | * Now we wait for the transmit buffer to clear; and we notify | ||
443 | * the line discipline to only process XON/XOFF characters. | ||
444 | */ | ||
445 | shutdown(tty, info); | ||
446 | rs_flush_buffer(tty); | ||
447 | 413 | ||
448 | tty_port_close_end(port, tty); | 414 | tty_port_close(&info->port, tty, filp); |
449 | tty_port_tty_set(port, NULL); | ||
450 | } | 415 | } |
451 | 416 | ||
452 | /* | ||
453 | * rs_hangup() --- called by tty_hangup() when a hangup is signaled. | ||
454 | */ | ||
455 | static void rs_hangup(struct tty_struct *tty) | 417 | static void rs_hangup(struct tty_struct *tty) |
456 | { | 418 | { |
457 | struct serial_state *info = tty->driver_data; | 419 | struct serial_state *info = tty->driver_data; |
458 | struct tty_port *port = &info->port; | ||
459 | |||
460 | #ifdef SIMSERIAL_DEBUG | ||
461 | printk("rs_hangup: called\n"); | ||
462 | #endif | ||
463 | 420 | ||
464 | rs_flush_buffer(tty); | 421 | rs_flush_buffer(tty); |
465 | if (port->flags & ASYNC_CLOSING) | 422 | tty_port_hangup(&info->port); |
466 | return; | ||
467 | shutdown(tty, info); | ||
468 | |||
469 | port->count = 0; | ||
470 | port->flags &= ~ASYNC_NORMAL_ACTIVE; | ||
471 | tty_port_tty_set(port, NULL); | ||
472 | wake_up_interruptible(&port->open_wait); | ||
473 | } | 423 | } |
474 | 424 | ||
475 | |||
476 | static int activate(struct tty_port *port, struct tty_struct *tty) | 425 | static int activate(struct tty_port *port, struct tty_struct *tty) |
477 | { | 426 | { |
478 | struct serial_state *state = container_of(port, struct serial_state, | 427 | struct serial_state *state = container_of(port, struct serial_state, |
@@ -615,6 +564,7 @@ static const struct tty_operations hp_ops = { | |||
615 | 564 | ||
616 | static const struct tty_port_operations hp_port_ops = { | 565 | static const struct tty_port_operations hp_port_ops = { |
617 | .activate = activate, | 566 | .activate = activate, |
567 | .shutdown = shutdown, | ||
618 | }; | 568 | }; |
619 | 569 | ||
620 | /* | 570 | /* |