aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJiri Slaby <jslaby@suse.cz>2012-03-05 08:52:32 -0500
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2012-03-08 15:48:27 -0500
commit7f32f8dd349bae106eccb0b9759c932875d6622e (patch)
tree31a0a78613d2428b1d2f1be8ccbc8a76bc9d85cb
parent3c4782dcd9b8d02e79f0f0bd1fe6e30a79790526 (diff)
TTY: simserial, define local tty_port pointer
And use it to make the code more readable. Since tport doesn't conflict with port anymore and there are not many tport accessors left, do also s/\<tport\>/port/g. 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>
-rw-r--r--arch/ia64/hp/sim/simserial.c84
1 files changed, 44 insertions, 40 deletions
diff --git a/arch/ia64/hp/sim/simserial.c b/arch/ia64/hp/sim/simserial.c
index 120aad4d5362..909357e32c8d 100644
--- a/arch/ia64/hp/sim/simserial.c
+++ b/arch/ia64/hp/sim/simserial.c
@@ -47,7 +47,7 @@
47#define NR_PORTS 1 /* only one port for now */ 47#define NR_PORTS 1 /* only one port for now */
48 48
49struct serial_state { 49struct serial_state {
50 struct tty_port tport; 50 struct tty_port port;
51 struct circ_buf xmit; 51 struct circ_buf xmit;
52 int irq; 52 int irq;
53 int x_char; 53 int x_char;
@@ -132,8 +132,9 @@ static void receive_chars(struct tty_struct *tty)
132static irqreturn_t rs_interrupt_single(int irq, void *dev_id) 132static irqreturn_t rs_interrupt_single(int irq, void *dev_id)
133{ 133{
134 struct serial_state *info = dev_id; 134 struct serial_state *info = dev_id;
135 struct tty_struct *tty = info->port.tty;
135 136
136 if (!info->tport.tty) { 137 if (!tty) {
137 printk(KERN_INFO "simrs_interrupt_single: info|tty=0 info=%p problem\n", info); 138 printk(KERN_INFO "simrs_interrupt_single: info|tty=0 info=%p problem\n", info);
138 return IRQ_NONE; 139 return IRQ_NONE;
139 } 140 }
@@ -141,7 +142,7 @@ static irqreturn_t rs_interrupt_single(int irq, void *dev_id)
141 * pretty simple in our case, because we only get interrupts 142 * pretty simple in our case, because we only get interrupts
142 * on inbound traffic 143 * on inbound traffic
143 */ 144 */
144 receive_chars(info->tport.tty); 145 receive_chars(tty);
145 return IRQ_HANDLED; 146 return IRQ_HANDLED;
146} 147}
147 148
@@ -416,7 +417,7 @@ static void shutdown(struct tty_struct *tty, struct serial_state *info)
416{ 417{
417 unsigned long flags; 418 unsigned long flags;
418 419
419 if (!(info->tport.flags & ASYNC_INITIALIZED)) 420 if (!(info->port.flags & ASYNC_INITIALIZED))
420 return; 421 return;
421 422
422#ifdef SIMSERIAL_DEBUG 423#ifdef SIMSERIAL_DEBUG
@@ -436,7 +437,7 @@ static void shutdown(struct tty_struct *tty, struct serial_state *info)
436 437
437 set_bit(TTY_IO_ERROR, &tty->flags); 438 set_bit(TTY_IO_ERROR, &tty->flags);
438 439
439 info->tport.flags &= ~ASYNC_INITIALIZED; 440 info->port.flags &= ~ASYNC_INITIALIZED;
440 } 441 }
441 local_irq_restore(flags); 442 local_irq_restore(flags);
442} 443}
@@ -454,6 +455,7 @@ static void shutdown(struct tty_struct *tty, struct serial_state *info)
454static void rs_close(struct tty_struct *tty, struct file * filp) 455static void rs_close(struct tty_struct *tty, struct file * filp)
455{ 456{
456 struct serial_state *info = tty->driver_data; 457 struct serial_state *info = tty->driver_data;
458 struct tty_port *port = &info->port;
457 unsigned long flags; 459 unsigned long flags;
458 460
459 if (!info) 461 if (!info)
@@ -468,30 +470,30 @@ static void rs_close(struct tty_struct *tty, struct file * filp)
468 return; 470 return;
469 } 471 }
470#ifdef SIMSERIAL_DEBUG 472#ifdef SIMSERIAL_DEBUG
471 printk("rs_close ttys%d, count = %d\n", info->line, info->tport.count); 473 printk("rs_close ttys%d, count = %d\n", info->line, port->count);
472#endif 474#endif
473 if ((tty->count == 1) && (info->tport.count != 1)) { 475 if ((tty->count == 1) && (port->count != 1)) {
474 /* 476 /*
475 * Uh, oh. tty->count is 1, which means that the tty 477 * Uh, oh. tty->count is 1, which means that the tty
476 * structure will be freed. info->tport.count should always 478 * structure will be freed. port->count should always
477 * be one in these conditions. If it's greater than 479 * be one in these conditions. If it's greater than
478 * one, we've got real problems, since it means the 480 * one, we've got real problems, since it means the
479 * serial port won't be shutdown. 481 * serial port won't be shutdown.
480 */ 482 */
481 printk(KERN_ERR "rs_close: bad serial port count; tty->count is 1, " 483 printk(KERN_ERR "rs_close: bad serial port count; tty->count is 1, "
482 "info->tport.count is %d\n", info->tport.count); 484 "port->count is %d\n", port->count);
483 info->tport.count = 1; 485 port->count = 1;
484 } 486 }
485 if (--info->tport.count < 0) { 487 if (--port->count < 0) {
486 printk(KERN_ERR "rs_close: bad serial port count for ttys%d: %d\n", 488 printk(KERN_ERR "rs_close: bad serial port count for ttys%d: %d\n",
487 tty->index, info->tport.count); 489 tty->index, port->count);
488 info->tport.count = 0; 490 port->count = 0;
489 } 491 }
490 if (info->tport.count) { 492 if (port->count) {
491 local_irq_restore(flags); 493 local_irq_restore(flags);
492 return; 494 return;
493 } 495 }
494 info->tport.flags |= ASYNC_CLOSING; 496 port->flags |= ASYNC_CLOSING;
495 local_irq_restore(flags); 497 local_irq_restore(flags);
496 498
497 /* 499 /*
@@ -501,14 +503,14 @@ static void rs_close(struct tty_struct *tty, struct file * filp)
501 shutdown(tty, info); 503 shutdown(tty, info);
502 rs_flush_buffer(tty); 504 rs_flush_buffer(tty);
503 tty_ldisc_flush(tty); 505 tty_ldisc_flush(tty);
504 info->tport.tty = NULL; 506 port->tty = NULL;
505 if (info->tport.blocked_open) { 507 if (port->blocked_open) {
506 if (info->tport.close_delay) 508 if (port->close_delay)
507 schedule_timeout_interruptible(info->tport.close_delay); 509 schedule_timeout_interruptible(port->close_delay);
508 wake_up_interruptible(&info->tport.open_wait); 510 wake_up_interruptible(&port->open_wait);
509 } 511 }
510 info->tport.flags &= ~(ASYNC_NORMAL_ACTIVE|ASYNC_CLOSING); 512 port->flags &= ~(ASYNC_NORMAL_ACTIVE|ASYNC_CLOSING);
511 wake_up_interruptible(&info->tport.close_wait); 513 wake_up_interruptible(&port->close_wait);
512} 514}
513 515
514/* 516/*
@@ -525,26 +527,27 @@ static void rs_wait_until_sent(struct tty_struct *tty, int timeout)
525static void rs_hangup(struct tty_struct *tty) 527static void rs_hangup(struct tty_struct *tty)
526{ 528{
527 struct serial_state *info = tty->driver_data; 529 struct serial_state *info = tty->driver_data;
530 struct tty_port *port = &info->port;
528 531
529#ifdef SIMSERIAL_DEBUG 532#ifdef SIMSERIAL_DEBUG
530 printk("rs_hangup: called\n"); 533 printk("rs_hangup: called\n");
531#endif 534#endif
532 535
533 rs_flush_buffer(tty); 536 rs_flush_buffer(tty);
534 if (info->tport.flags & ASYNC_CLOSING) 537 if (port->flags & ASYNC_CLOSING)
535 return; 538 return;
536 shutdown(tty, info); 539 shutdown(tty, info);
537 540
538 info->tport.count = 0; 541 port->count = 0;
539 info->tport.flags &= ~ASYNC_NORMAL_ACTIVE; 542 port->flags &= ~ASYNC_NORMAL_ACTIVE;
540 info->tport.tty = NULL; 543 port->tty = NULL;
541 wake_up_interruptible(&info->tport.open_wait); 544 wake_up_interruptible(&port->open_wait);
542} 545}
543 546
544 547
545static int startup(struct tty_struct *tty, struct serial_state *state) 548static int startup(struct tty_struct *tty, struct serial_state *state)
546{ 549{
547 struct tty_port *port = &state->tport; 550 struct tty_port *port = &state->port;
548 unsigned long flags; 551 unsigned long flags;
549 int retval=0; 552 int retval=0;
550 unsigned long page; 553 unsigned long page;
@@ -622,26 +625,27 @@ errout:
622static int rs_open(struct tty_struct *tty, struct file * filp) 625static int rs_open(struct tty_struct *tty, struct file * filp)
623{ 626{
624 struct serial_state *info = rs_table + tty->index; 627 struct serial_state *info = rs_table + tty->index;
625 int retval; 628 struct tty_port *port = &info->port;
629 int retval;
626 630
627 info->tport.count++; 631 port->count++;
628 info->tport.tty = tty; 632 port->tty = tty;
629 tty->driver_data = info; 633 tty->driver_data = info;
630 tty->port = &info->tport; 634 tty->port = port;
631 635
632#ifdef SIMSERIAL_DEBUG 636#ifdef SIMSERIAL_DEBUG
633 printk("rs_open %s, count = %d\n", tty->name, info->tport.count); 637 printk("rs_open %s, count = %d\n", tty->name, port->count);
634#endif 638#endif
635 tty->low_latency = (info->tport.flags & ASYNC_LOW_LATENCY) ? 1 : 0; 639 tty->low_latency = (port->flags & ASYNC_LOW_LATENCY) ? 1 : 0;
636 640
637 /* 641 /*
638 * If the port is the middle of closing, bail out now 642 * If the port is the middle of closing, bail out now
639 */ 643 */
640 if (tty_hung_up_p(filp) || (info->tport.flags & ASYNC_CLOSING)) { 644 if (tty_hung_up_p(filp) || (port->flags & ASYNC_CLOSING)) {
641 if (info->tport.flags & ASYNC_CLOSING) 645 if (port->flags & ASYNC_CLOSING)
642 interruptible_sleep_on(&info->tport.close_wait); 646 interruptible_sleep_on(&port->close_wait);
643#ifdef SERIAL_DO_RESTART 647#ifdef SERIAL_DO_RESTART
644 return ((info->tport.flags & ASYNC_HUP_NOTIFY) ? 648 return ((port->flags & ASYNC_HUP_NOTIFY) ?
645 -EAGAIN : -ERESTARTSYS); 649 -EAGAIN : -ERESTARTSYS);
646#else 650#else
647 return -EAGAIN; 651 return -EAGAIN;
@@ -774,8 +778,8 @@ static int __init simrs_init(void)
774 * Let's have a little bit of fun ! 778 * Let's have a little bit of fun !
775 */ 779 */
776 state = rs_table; 780 state = rs_table;
777 tty_port_init(&state->tport); 781 tty_port_init(&state->port);
778 state->tport.close_delay = 0; /* XXX really 0? */ 782 state->port.close_delay = 0; /* XXX really 0? */
779 783
780 retval = hpsim_get_irq(KEYBOARD_INTR); 784 retval = hpsim_get_irq(KEYBOARD_INTR);
781 if (retval < 0) { 785 if (retval < 0) {