aboutsummaryrefslogtreecommitdiffstats
path: root/arch/ia64/hp
diff options
context:
space:
mode:
authorJiri Slaby <jslaby@suse.cz>2012-03-05 08:52:23 -0500
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2012-03-08 15:30:50 -0500
commit5e99d5458729b0eb763ca83a2fbb95f6276c4243 (patch)
tree47624b07b38be86dda2a91bacd60e791e37e68c5 /arch/ia64/hp
parent588993dd8d99bdbd9a7296abe0c7964ecc874300 (diff)
TTY: simserial, pass tty down to functions
This avoids pain with tty refcounting and touching tty_port in the future. It allows us to remove some state->tty tests because the tty passed down to them can never be NULL. 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')
-rw-r--r--arch/ia64/hp/sim/simserial.c50
1 files changed, 24 insertions, 26 deletions
diff --git a/arch/ia64/hp/sim/simserial.c b/arch/ia64/hp/sim/simserial.c
index 7b6e60e9167b..a76a27ed3de0 100644
--- a/arch/ia64/hp/sim/simserial.c
+++ b/arch/ia64/hp/sim/simserial.c
@@ -202,7 +202,8 @@ static int rs_put_char(struct tty_struct *tty, unsigned char ch)
202 return 1; 202 return 1;
203} 203}
204 204
205static void transmit_chars(struct serial_state *info, int *intr_done) 205static void transmit_chars(struct tty_struct *tty, struct serial_state *info,
206 int *intr_done)
206{ 207{
207 int count; 208 int count;
208 unsigned long flags; 209 unsigned long flags;
@@ -220,10 +221,11 @@ static void transmit_chars(struct serial_state *info, int *intr_done)
220 goto out; 221 goto out;
221 } 222 }
222 223
223 if (info->xmit.head == info->xmit.tail || info->tty->stopped || info->tty->hw_stopped) { 224 if (info->xmit.head == info->xmit.tail || tty->stopped ||
225 tty->hw_stopped) {
224#ifdef SIMSERIAL_DEBUG 226#ifdef SIMSERIAL_DEBUG
225 printk("transmit_chars: head=%d, tail=%d, stopped=%d\n", 227 printk("transmit_chars: head=%d, tail=%d, stopped=%d\n",
226 info->xmit.head, info->xmit.tail, info->tty->stopped); 228 info->xmit.head, info->xmit.tail, tty->stopped);
227#endif 229#endif
228 goto out; 230 goto out;
229 } 231 }
@@ -261,7 +263,7 @@ static void rs_flush_chars(struct tty_struct *tty)
261 !info->xmit.buf) 263 !info->xmit.buf)
262 return; 264 return;
263 265
264 transmit_chars(info, NULL); 266 transmit_chars(tty, info, NULL);
265} 267}
266 268
267 269
@@ -295,7 +297,7 @@ static int rs_write(struct tty_struct * tty,
295 */ 297 */
296 if (CIRC_CNT(info->xmit.head, info->xmit.tail, SERIAL_XMIT_SIZE) 298 if (CIRC_CNT(info->xmit.head, info->xmit.tail, SERIAL_XMIT_SIZE)
297 && !tty->stopped && !tty->hw_stopped) { 299 && !tty->stopped && !tty->hw_stopped) {
298 transmit_chars(info, NULL); 300 transmit_chars(tty, info, NULL);
299 } 301 }
300 return ret; 302 return ret;
301} 303}
@@ -340,7 +342,7 @@ static void rs_send_xchar(struct tty_struct *tty, char ch)
340 * I guess we could call console->write() directly but 342 * I guess we could call console->write() directly but
341 * let's do that for now. 343 * let's do that for now.
342 */ 344 */
343 transmit_chars(info, NULL); 345 transmit_chars(tty, info, NULL);
344 } 346 }
345} 347}
346 348
@@ -442,7 +444,7 @@ static void rs_set_termios(struct tty_struct *tty, struct ktermios *old_termios)
442 * This routine will shutdown a serial port; interrupts are disabled, and 444 * This routine will shutdown a serial port; interrupts are disabled, and
443 * DTR is dropped if the hangup on close termio flag is on. 445 * DTR is dropped if the hangup on close termio flag is on.
444 */ 446 */
445static void shutdown(struct serial_state *info) 447static void shutdown(struct tty_struct *tty, struct serial_state *info)
446{ 448{
447 unsigned long flags; 449 unsigned long flags;
448 450
@@ -464,7 +466,7 @@ static void shutdown(struct serial_state *info)
464 info->xmit.buf = NULL; 466 info->xmit.buf = NULL;
465 } 467 }
466 468
467 if (info->tty) set_bit(TTY_IO_ERROR, &info->tty->flags); 469 set_bit(TTY_IO_ERROR, &tty->flags);
468 470
469 info->flags &= ~ASYNC_INITIALIZED; 471 info->flags &= ~ASYNC_INITIALIZED;
470 } 472 }
@@ -528,7 +530,7 @@ static void rs_close(struct tty_struct *tty, struct file * filp)
528 * Now we wait for the transmit buffer to clear; and we notify 530 * Now we wait for the transmit buffer to clear; and we notify
529 * the line discipline to only process XON/XOFF characters. 531 * the line discipline to only process XON/XOFF characters.
530 */ 532 */
531 shutdown(info); 533 shutdown(tty, info);
532 rs_flush_buffer(tty); 534 rs_flush_buffer(tty);
533 tty_ldisc_flush(tty); 535 tty_ldisc_flush(tty);
534 info->tty = NULL; 536 info->tty = NULL;
@@ -563,7 +565,7 @@ static void rs_hangup(struct tty_struct *tty)
563 rs_flush_buffer(tty); 565 rs_flush_buffer(tty);
564 if (info->flags & ASYNC_CLOSING) 566 if (info->flags & ASYNC_CLOSING)
565 return; 567 return;
566 shutdown(info); 568 shutdown(tty, info);
567 569
568 info->count = 0; 570 info->count = 0;
569 info->flags &= ~ASYNC_NORMAL_ACTIVE; 571 info->flags &= ~ASYNC_NORMAL_ACTIVE;
@@ -572,7 +574,7 @@ static void rs_hangup(struct tty_struct *tty)
572} 574}
573 575
574 576
575static int startup(struct serial_state *state) 577static int startup(struct tty_struct *tty, struct serial_state *state)
576{ 578{
577 unsigned long flags; 579 unsigned long flags;
578 int retval=0; 580 int retval=0;
@@ -590,8 +592,7 @@ static int startup(struct serial_state *state)
590 } 592 }
591 593
592 if (!state->port || !state->type) { 594 if (!state->port || !state->type) {
593 if (state->tty) 595 set_bit(TTY_IO_ERROR, &tty->flags);
594 set_bit(TTY_IO_ERROR, &state->tty->flags);
595 free_page(page); 596 free_page(page);
596 goto errout; 597 goto errout;
597 } 598 }
@@ -614,8 +615,7 @@ static int startup(struct serial_state *state)
614 goto errout; 615 goto errout;
615 } 616 }
616 617
617 if (state->tty) 618 clear_bit(TTY_IO_ERROR, &tty->flags);
618 clear_bit(TTY_IO_ERROR, &state->tty->flags);
619 619
620 state->xmit.head = state->xmit.tail = 0; 620 state->xmit.head = state->xmit.tail = 0;
621 621
@@ -630,16 +630,14 @@ static int startup(struct serial_state *state)
630 /* 630 /*
631 * Set up the tty->alt_speed kludge 631 * Set up the tty->alt_speed kludge
632 */ 632 */
633 if (state->tty) { 633 if ((state->flags & ASYNC_SPD_MASK) == ASYNC_SPD_HI)
634 if ((state->flags & ASYNC_SPD_MASK) == ASYNC_SPD_HI) 634 tty->alt_speed = 57600;
635 state->tty->alt_speed = 57600; 635 if ((state->flags & ASYNC_SPD_MASK) == ASYNC_SPD_VHI)
636 if ((state->flags & ASYNC_SPD_MASK) == ASYNC_SPD_VHI) 636 tty->alt_speed = 115200;
637 state->tty->alt_speed = 115200; 637 if ((state->flags & ASYNC_SPD_MASK) == ASYNC_SPD_SHI)
638 if ((state->flags & ASYNC_SPD_MASK) == ASYNC_SPD_SHI) 638 tty->alt_speed = 230400;
639 state->tty->alt_speed = 230400; 639 if ((state->flags & ASYNC_SPD_MASK) == ASYNC_SPD_WARP)
640 if ((state->flags & ASYNC_SPD_MASK) == ASYNC_SPD_WARP) 640 tty->alt_speed = 460800;
641 state->tty->alt_speed = 460800;
642 }
643 641
644 state->flags |= ASYNC_INITIALIZED; 642 state->flags |= ASYNC_INITIALIZED;
645 local_irq_restore(flags); 643 local_irq_restore(flags);
@@ -699,7 +697,7 @@ static int rs_open(struct tty_struct *tty, struct file * filp)
699 /* 697 /*
700 * Start up serial port 698 * Start up serial port
701 */ 699 */
702 retval = startup(info); 700 retval = startup(tty, info);
703 if (retval) { 701 if (retval) {
704 return retval; 702 return retval;
705 } 703 }