aboutsummaryrefslogtreecommitdiffstats
path: root/drivers
diff options
context:
space:
mode:
authorJiri Slaby <jslaby@suse.cz>2012-03-05 08:52:20 -0500
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2012-03-08 15:28:48 -0500
commit916b765675b7044bd5895b7430a2aa2c63ea4545 (patch)
tree55a876c662dc2efa4990984de7f3286cc3371b63 /drivers
parent13c9062122a8d05e0881ca8bd9037d2e57e56860 (diff)
TTY: serialP, merge serial_state and async_struct
This is the final step to get rid of the one of the structures. A further cleanup will follow. And I struct serial_state deserves cease to exist after a switch to tty_port too. While changing the lines, it removes also pointless tty->driver_data casts. Signed-off-by: Jiri Slaby <jslaby@suse.cz> Cc: Geert Uytterhoeven <geert@linux-m68k.org> 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 'drivers')
-rw-r--r--drivers/tty/amiserial.c301
1 files changed, 121 insertions, 180 deletions
diff --git a/drivers/tty/amiserial.c b/drivers/tty/amiserial.c
index 7607c6ebd39a..410e8e7e6bfe 100644
--- a/drivers/tty/amiserial.c
+++ b/drivers/tty/amiserial.c
@@ -45,7 +45,7 @@
45 45
46#if defined(MODULE) && defined(SERIAL_DEBUG_MCOUNT) 46#if defined(MODULE) && defined(SERIAL_DEBUG_MCOUNT)
47#define DBG_CNT(s) printk("(%s): [%x] refc=%d, serc=%d, ttyc=%d -> %s\n", \ 47#define DBG_CNT(s) printk("(%s): [%x] refc=%d, serc=%d, ttyc=%d -> %s\n", \
48 tty->name, (info->state->flags), serial_driver->refcount,info->count,tty->count,s) 48 tty->name, (info->flags), serial_driver->refcount,info->count,tty->count,s)
49#else 49#else
50#define DBG_CNT(s) 50#define DBG_CNT(s)
51#endif 51#endif
@@ -102,7 +102,7 @@ static struct tty_driver *serial_driver;
102 102
103static unsigned char current_ctl_bits; 103static unsigned char current_ctl_bits;
104 104
105static void change_speed(struct async_struct *info, struct ktermios *old); 105static void change_speed(struct serial_state *info, struct ktermios *old);
106static void rs_wait_until_sent(struct tty_struct *tty, int timeout); 106static void rs_wait_until_sent(struct tty_struct *tty, int timeout);
107 107
108 108
@@ -115,7 +115,7 @@ static struct serial_state rs_table[1];
115#define serial_isroot() (capable(CAP_SYS_ADMIN)) 115#define serial_isroot() (capable(CAP_SYS_ADMIN))
116 116
117 117
118static inline int serial_paranoia_check(struct async_struct *info, 118static inline int serial_paranoia_check(struct serial_state *info,
119 char *name, const char *routine) 119 char *name, const char *routine)
120{ 120{
121#ifdef SERIAL_PARANOIA_CHECK 121#ifdef SERIAL_PARANOIA_CHECK
@@ -168,7 +168,7 @@ static __inline__ void rtsdtr_ctrl(int bits)
168 */ 168 */
169static void rs_stop(struct tty_struct *tty) 169static void rs_stop(struct tty_struct *tty)
170{ 170{
171 struct async_struct *info = tty->driver_data; 171 struct serial_state *info = tty->driver_data;
172 unsigned long flags; 172 unsigned long flags;
173 173
174 if (serial_paranoia_check(info, tty->name, "rs_stop")) 174 if (serial_paranoia_check(info, tty->name, "rs_stop"))
@@ -188,7 +188,7 @@ static void rs_stop(struct tty_struct *tty)
188 188
189static void rs_start(struct tty_struct *tty) 189static void rs_start(struct tty_struct *tty)
190{ 190{
191 struct async_struct *info = tty->driver_data; 191 struct serial_state *info = tty->driver_data;
192 unsigned long flags; 192 unsigned long flags;
193 193
194 if (serial_paranoia_check(info, tty->name, "rs_start")) 194 if (serial_paranoia_check(info, tty->name, "rs_start"))
@@ -229,7 +229,7 @@ static void rs_start(struct tty_struct *tty)
229 * ----------------------------------------------------------------------- 229 * -----------------------------------------------------------------------
230 */ 230 */
231 231
232static void receive_chars(struct async_struct *info) 232static void receive_chars(struct serial_state *info)
233{ 233{
234 int status; 234 int status;
235 int serdatr; 235 int serdatr;
@@ -238,7 +238,7 @@ static void receive_chars(struct async_struct *info)
238 struct async_icount *icount; 238 struct async_icount *icount;
239 int oe = 0; 239 int oe = 0;
240 240
241 icount = &info->state->icount; 241 icount = &info->icount;
242 242
243 status = UART_LSR_DR; /* We obviously have a character! */ 243 status = UART_LSR_DR; /* We obviously have a character! */
244 serdatr = custom.serdatr; 244 serdatr = custom.serdatr;
@@ -295,7 +295,7 @@ static void receive_chars(struct async_struct *info)
295 printk("handling break...."); 295 printk("handling break....");
296#endif 296#endif
297 flag = TTY_BREAK; 297 flag = TTY_BREAK;
298 if (info->state->flags & ASYNC_SAK) 298 if (info->flags & ASYNC_SAK)
299 do_SAK(tty); 299 do_SAK(tty);
300 } else if (status & UART_LSR_PE) 300 } else if (status & UART_LSR_PE)
301 flag = TTY_PARITY; 301 flag = TTY_PARITY;
@@ -318,14 +318,14 @@ out:
318 return; 318 return;
319} 319}
320 320
321static void transmit_chars(struct async_struct *info) 321static void transmit_chars(struct serial_state *info)
322{ 322{
323 custom.intreq = IF_TBE; 323 custom.intreq = IF_TBE;
324 mb(); 324 mb();
325 if (info->x_char) { 325 if (info->x_char) {
326 custom.serdat = info->x_char | 0x100; 326 custom.serdat = info->x_char | 0x100;
327 mb(); 327 mb();
328 info->state->icount.tx++; 328 info->icount.tx++;
329 info->x_char = 0; 329 info->x_char = 0;
330 return; 330 return;
331 } 331 }
@@ -341,7 +341,7 @@ static void transmit_chars(struct async_struct *info)
341 custom.serdat = info->xmit.buf[info->xmit.tail++] | 0x100; 341 custom.serdat = info->xmit.buf[info->xmit.tail++] | 0x100;
342 mb(); 342 mb();
343 info->xmit.tail = info->xmit.tail & (SERIAL_XMIT_SIZE-1); 343 info->xmit.tail = info->xmit.tail & (SERIAL_XMIT_SIZE-1);
344 info->state->icount.tx++; 344 info->icount.tx++;
345 345
346 if (CIRC_CNT(info->xmit.head, 346 if (CIRC_CNT(info->xmit.head,
347 info->xmit.tail, 347 info->xmit.tail,
@@ -358,7 +358,7 @@ static void transmit_chars(struct async_struct *info)
358 } 358 }
359} 359}
360 360
361static void check_modem_status(struct async_struct *info) 361static void check_modem_status(struct serial_state *info)
362{ 362{
363 unsigned char status = ciab.pra & (SER_DCD | SER_CTS | SER_DSR); 363 unsigned char status = ciab.pra & (SER_DCD | SER_CTS | SER_DSR);
364 unsigned char dstatus; 364 unsigned char dstatus;
@@ -369,14 +369,14 @@ static void check_modem_status(struct async_struct *info)
369 current_ctl_bits = status; 369 current_ctl_bits = status;
370 370
371 if (dstatus) { 371 if (dstatus) {
372 icount = &info->state->icount; 372 icount = &info->icount;
373 /* update input line counters */ 373 /* update input line counters */
374 if (dstatus & SER_DSR) 374 if (dstatus & SER_DSR)
375 icount->dsr++; 375 icount->dsr++;
376 if (dstatus & SER_DCD) { 376 if (dstatus & SER_DCD) {
377 icount->dcd++; 377 icount->dcd++;
378#ifdef CONFIG_HARD_PPS 378#ifdef CONFIG_HARD_PPS
379 if ((info->state->flags & ASYNC_HARDPPS_CD) && 379 if ((info->flags & ASYNC_HARDPPS_CD) &&
380 !(status & SER_DCD)) 380 !(status & SER_DCD))
381 hardpps(); 381 hardpps();
382#endif 382#endif
@@ -386,7 +386,7 @@ static void check_modem_status(struct async_struct *info)
386 wake_up_interruptible(&info->delta_msr_wait); 386 wake_up_interruptible(&info->delta_msr_wait);
387 } 387 }
388 388
389 if ((info->state->flags & ASYNC_CHECK_CD) && (dstatus & SER_DCD)) { 389 if ((info->flags & ASYNC_CHECK_CD) && (dstatus & SER_DCD)) {
390#if (defined(SERIAL_DEBUG_OPEN) || defined(SERIAL_DEBUG_INTR)) 390#if (defined(SERIAL_DEBUG_OPEN) || defined(SERIAL_DEBUG_INTR))
391 printk("ttyS%d CD now %s...", info->line, 391 printk("ttyS%d CD now %s...", info->line,
392 (!(status & SER_DCD)) ? "on" : "off"); 392 (!(status & SER_DCD)) ? "on" : "off");
@@ -401,7 +401,7 @@ static void check_modem_status(struct async_struct *info)
401 tty_hangup(info->tty); 401 tty_hangup(info->tty);
402 } 402 }
403 } 403 }
404 if (info->state->flags & ASYNC_CTS_FLOW) { 404 if (info->flags & ASYNC_CTS_FLOW) {
405 if (info->tty->hw_stopped) { 405 if (info->tty->hw_stopped) {
406 if (!(status & SER_CTS)) { 406 if (!(status & SER_CTS)) {
407#if (defined(SERIAL_DEBUG_INTR) || defined(SERIAL_DEBUG_FLOW)) 407#if (defined(SERIAL_DEBUG_INTR) || defined(SERIAL_DEBUG_FLOW))
@@ -437,7 +437,7 @@ static void check_modem_status(struct async_struct *info)
437static irqreturn_t ser_vbl_int( int irq, void *data) 437static irqreturn_t ser_vbl_int( int irq, void *data)
438{ 438{
439 /* vbl is just a periodic interrupt we tie into to update modem status */ 439 /* vbl is just a periodic interrupt we tie into to update modem status */
440 struct async_struct *info = data; 440 struct serial_state *info = data;
441 /* 441 /*
442 * TBD - is it better to unregister from this interrupt or to 442 * TBD - is it better to unregister from this interrupt or to
443 * ignore it if MSI is clear ? 443 * ignore it if MSI is clear ?
@@ -449,14 +449,13 @@ static irqreturn_t ser_vbl_int( int irq, void *data)
449 449
450static irqreturn_t ser_rx_int(int irq, void *dev_id) 450static irqreturn_t ser_rx_int(int irq, void *dev_id)
451{ 451{
452 struct serial_state *state = dev_id; 452 struct serial_state *info = dev_id;
453 struct async_struct *info = state->info;
454 453
455#ifdef SERIAL_DEBUG_INTR 454#ifdef SERIAL_DEBUG_INTR
456 printk("ser_rx_int..."); 455 printk("ser_rx_int...");
457#endif 456#endif
458 457
459 if (!info || !info->tty) 458 if (!info->tty)
460 return IRQ_NONE; 459 return IRQ_NONE;
461 460
462 receive_chars(info); 461 receive_chars(info);
@@ -468,15 +467,14 @@ static irqreturn_t ser_rx_int(int irq, void *dev_id)
468 467
469static irqreturn_t ser_tx_int(int irq, void *dev_id) 468static irqreturn_t ser_tx_int(int irq, void *dev_id)
470{ 469{
471 struct serial_state *state = dev_id; 470 struct serial_state *info = dev_id;
472 struct async_struct *info = state->info;
473 471
474 if (custom.serdatr & SDR_TBE) { 472 if (custom.serdatr & SDR_TBE) {
475#ifdef SERIAL_DEBUG_INTR 473#ifdef SERIAL_DEBUG_INTR
476 printk("ser_tx_int..."); 474 printk("ser_tx_int...");
477#endif 475#endif
478 476
479 if (!info || !info->tty) 477 if (!info->tty)
480 return IRQ_NONE; 478 return IRQ_NONE;
481 479
482 transmit_chars(info); 480 transmit_chars(info);
@@ -502,7 +500,7 @@ static irqreturn_t ser_tx_int(int irq, void *dev_id)
502 * --------------------------------------------------------------- 500 * ---------------------------------------------------------------
503 */ 501 */
504 502
505static int startup(struct async_struct * info) 503static int startup(struct serial_state *info)
506{ 504{
507 unsigned long flags; 505 unsigned long flags;
508 int retval=0; 506 int retval=0;
@@ -514,7 +512,7 @@ static int startup(struct async_struct * info)
514 512
515 local_irq_save(flags); 513 local_irq_save(flags);
516 514
517 if (info->state->flags & ASYNC_INITIALIZED) { 515 if (info->flags & ASYNC_INITIALIZED) {
518 free_page(page); 516 free_page(page);
519 goto errout; 517 goto errout;
520 } 518 }
@@ -565,13 +563,13 @@ static int startup(struct async_struct * info)
565 * Set up the tty->alt_speed kludge 563 * Set up the tty->alt_speed kludge
566 */ 564 */
567 if (info->tty) { 565 if (info->tty) {
568 if ((info->state->flags & ASYNC_SPD_MASK) == ASYNC_SPD_HI) 566 if ((info->flags & ASYNC_SPD_MASK) == ASYNC_SPD_HI)
569 info->tty->alt_speed = 57600; 567 info->tty->alt_speed = 57600;
570 if ((info->state->flags & ASYNC_SPD_MASK) == ASYNC_SPD_VHI) 568 if ((info->flags & ASYNC_SPD_MASK) == ASYNC_SPD_VHI)
571 info->tty->alt_speed = 115200; 569 info->tty->alt_speed = 115200;
572 if ((info->state->flags & ASYNC_SPD_MASK) == ASYNC_SPD_SHI) 570 if ((info->flags & ASYNC_SPD_MASK) == ASYNC_SPD_SHI)
573 info->tty->alt_speed = 230400; 571 info->tty->alt_speed = 230400;
574 if ((info->state->flags & ASYNC_SPD_MASK) == ASYNC_SPD_WARP) 572 if ((info->flags & ASYNC_SPD_MASK) == ASYNC_SPD_WARP)
575 info->tty->alt_speed = 460800; 573 info->tty->alt_speed = 460800;
576 } 574 }
577 575
@@ -580,7 +578,7 @@ static int startup(struct async_struct * info)
580 */ 578 */
581 change_speed(info, NULL); 579 change_speed(info, NULL);
582 580
583 info->state->flags |= ASYNC_INITIALIZED; 581 info->flags |= ASYNC_INITIALIZED;
584 local_irq_restore(flags); 582 local_irq_restore(flags);
585 return 0; 583 return 0;
586 584
@@ -593,15 +591,15 @@ errout:
593 * This routine will shutdown a serial port; interrupts are disabled, and 591 * This routine will shutdown a serial port; interrupts are disabled, and
594 * DTR is dropped if the hangup on close termio flag is on. 592 * DTR is dropped if the hangup on close termio flag is on.
595 */ 593 */
596static void shutdown(struct async_struct * info) 594static void shutdown(struct serial_state *info)
597{ 595{
598 unsigned long flags; 596 unsigned long flags;
599 struct serial_state *state; 597 struct serial_state *state;
600 598
601 if (!(info->state->flags & ASYNC_INITIALIZED)) 599 if (!(info->flags & ASYNC_INITIALIZED))
602 return; 600 return;
603 601
604 state = info->state; 602 state = info;
605 603
606#ifdef SERIAL_DEBUG_OPEN 604#ifdef SERIAL_DEBUG_OPEN
607 printk("Shutting down serial port %d ....\n", info->line); 605 printk("Shutting down serial port %d ....\n", info->line);
@@ -640,7 +638,7 @@ static void shutdown(struct async_struct * info)
640 if (info->tty) 638 if (info->tty)
641 set_bit(TTY_IO_ERROR, &info->tty->flags); 639 set_bit(TTY_IO_ERROR, &info->tty->flags);
642 640
643 info->state->flags &= ~ASYNC_INITIALIZED; 641 info->flags &= ~ASYNC_INITIALIZED;
644 local_irq_restore(flags); 642 local_irq_restore(flags);
645} 643}
646 644
@@ -649,7 +647,7 @@ static void shutdown(struct async_struct * info)
649 * This routine is called to set the UART divisor registers to match 647 * This routine is called to set the UART divisor registers to match
650 * the specified baud rate for a serial port. 648 * the specified baud rate for a serial port.
651 */ 649 */
652static void change_speed(struct async_struct *info, 650static void change_speed(struct serial_state *info,
653 struct ktermios *old_termios) 651 struct ktermios *old_termios)
654{ 652{
655 int quot = 0, baud_base, baud; 653 int quot = 0, baud_base, baud;
@@ -683,10 +681,10 @@ static void change_speed(struct async_struct *info,
683 baud = tty_get_baud_rate(info->tty); 681 baud = tty_get_baud_rate(info->tty);
684 if (!baud) 682 if (!baud)
685 baud = 9600; /* B0 transition handled in rs_set_termios */ 683 baud = 9600; /* B0 transition handled in rs_set_termios */
686 baud_base = info->state->baud_base; 684 baud_base = info->baud_base;
687 if (baud == 38400 && 685 if (baud == 38400 &&
688 ((info->state->flags & ASYNC_SPD_MASK) == ASYNC_SPD_CUST)) 686 ((info->flags & ASYNC_SPD_MASK) == ASYNC_SPD_CUST))
689 quot = info->state->custom_divisor; 687 quot = info->custom_divisor;
690 else { 688 else {
691 if (baud == 134) 689 if (baud == 134)
692 /* Special case since 134 is really 134.5 */ 690 /* Special case since 134 is really 134.5 */
@@ -703,8 +701,8 @@ static void change_speed(struct async_struct *info,
703 if (!baud) 701 if (!baud)
704 baud = 9600; 702 baud = 9600;
705 if (baud == 38400 && 703 if (baud == 38400 &&
706 ((info->state->flags & ASYNC_SPD_MASK) == ASYNC_SPD_CUST)) 704 ((info->flags & ASYNC_SPD_MASK) == ASYNC_SPD_CUST))
707 quot = info->state->custom_divisor; 705 quot = info->custom_divisor;
708 else { 706 else {
709 if (baud == 134) 707 if (baud == 134)
710 /* Special case since 134 is really 134.5 */ 708 /* Special case since 134 is really 134.5 */
@@ -717,22 +715,22 @@ static void change_speed(struct async_struct *info,
717 if (!quot) 715 if (!quot)
718 quot = baud_base / 9600; 716 quot = baud_base / 9600;
719 info->quot = quot; 717 info->quot = quot;
720 info->timeout = ((info->state->xmit_fifo_size*HZ*bits*quot) / baud_base); 718 info->timeout = ((info->xmit_fifo_size*HZ*bits*quot) / baud_base);
721 info->timeout += HZ/50; /* Add .02 seconds of slop */ 719 info->timeout += HZ/50; /* Add .02 seconds of slop */
722 720
723 /* CTS flow control flag and modem status interrupts */ 721 /* CTS flow control flag and modem status interrupts */
724 info->IER &= ~UART_IER_MSI; 722 info->IER &= ~UART_IER_MSI;
725 if (info->state->flags & ASYNC_HARDPPS_CD) 723 if (info->flags & ASYNC_HARDPPS_CD)
726 info->IER |= UART_IER_MSI; 724 info->IER |= UART_IER_MSI;
727 if (cflag & CRTSCTS) { 725 if (cflag & CRTSCTS) {
728 info->state->flags |= ASYNC_CTS_FLOW; 726 info->flags |= ASYNC_CTS_FLOW;
729 info->IER |= UART_IER_MSI; 727 info->IER |= UART_IER_MSI;
730 } else 728 } else
731 info->state->flags &= ~ASYNC_CTS_FLOW; 729 info->flags &= ~ASYNC_CTS_FLOW;
732 if (cflag & CLOCAL) 730 if (cflag & CLOCAL)
733 info->state->flags &= ~ASYNC_CHECK_CD; 731 info->flags &= ~ASYNC_CHECK_CD;
734 else { 732 else {
735 info->state->flags |= ASYNC_CHECK_CD; 733 info->flags |= ASYNC_CHECK_CD;
736 info->IER |= UART_IER_MSI; 734 info->IER |= UART_IER_MSI;
737 } 735 }
738 /* TBD: 736 /* TBD:
@@ -791,7 +789,7 @@ static void change_speed(struct async_struct *info,
791 789
792static int rs_put_char(struct tty_struct *tty, unsigned char ch) 790static int rs_put_char(struct tty_struct *tty, unsigned char ch)
793{ 791{
794 struct async_struct *info; 792 struct serial_state *info;
795 unsigned long flags; 793 unsigned long flags;
796 794
797 info = tty->driver_data; 795 info = tty->driver_data;
@@ -818,7 +816,7 @@ static int rs_put_char(struct tty_struct *tty, unsigned char ch)
818 816
819static void rs_flush_chars(struct tty_struct *tty) 817static void rs_flush_chars(struct tty_struct *tty)
820{ 818{
821 struct async_struct *info = tty->driver_data; 819 struct serial_state *info = tty->driver_data;
822 unsigned long flags; 820 unsigned long flags;
823 821
824 if (serial_paranoia_check(info, tty->name, "rs_flush_chars")) 822 if (serial_paranoia_check(info, tty->name, "rs_flush_chars"))
@@ -843,11 +841,9 @@ static void rs_flush_chars(struct tty_struct *tty)
843static int rs_write(struct tty_struct * tty, const unsigned char *buf, int count) 841static int rs_write(struct tty_struct * tty, const unsigned char *buf, int count)
844{ 842{
845 int c, ret = 0; 843 int c, ret = 0;
846 struct async_struct *info; 844 struct serial_state *info = tty->driver_data;
847 unsigned long flags; 845 unsigned long flags;
848 846
849 info = tty->driver_data;
850
851 if (serial_paranoia_check(info, tty->name, "rs_write")) 847 if (serial_paranoia_check(info, tty->name, "rs_write"))
852 return 0; 848 return 0;
853 849
@@ -891,7 +887,7 @@ static int rs_write(struct tty_struct * tty, const unsigned char *buf, int count
891 887
892static int rs_write_room(struct tty_struct *tty) 888static int rs_write_room(struct tty_struct *tty)
893{ 889{
894 struct async_struct *info = tty->driver_data; 890 struct serial_state *info = tty->driver_data;
895 891
896 if (serial_paranoia_check(info, tty->name, "rs_write_room")) 892 if (serial_paranoia_check(info, tty->name, "rs_write_room"))
897 return 0; 893 return 0;
@@ -900,7 +896,7 @@ static int rs_write_room(struct tty_struct *tty)
900 896
901static int rs_chars_in_buffer(struct tty_struct *tty) 897static int rs_chars_in_buffer(struct tty_struct *tty)
902{ 898{
903 struct async_struct *info = tty->driver_data; 899 struct serial_state *info = tty->driver_data;
904 900
905 if (serial_paranoia_check(info, tty->name, "rs_chars_in_buffer")) 901 if (serial_paranoia_check(info, tty->name, "rs_chars_in_buffer"))
906 return 0; 902 return 0;
@@ -909,7 +905,7 @@ static int rs_chars_in_buffer(struct tty_struct *tty)
909 905
910static void rs_flush_buffer(struct tty_struct *tty) 906static void rs_flush_buffer(struct tty_struct *tty)
911{ 907{
912 struct async_struct *info = tty->driver_data; 908 struct serial_state *info = tty->driver_data;
913 unsigned long flags; 909 unsigned long flags;
914 910
915 if (serial_paranoia_check(info, tty->name, "rs_flush_buffer")) 911 if (serial_paranoia_check(info, tty->name, "rs_flush_buffer"))
@@ -926,7 +922,7 @@ static void rs_flush_buffer(struct tty_struct *tty)
926 */ 922 */
927static void rs_send_xchar(struct tty_struct *tty, char ch) 923static void rs_send_xchar(struct tty_struct *tty, char ch)
928{ 924{
929 struct async_struct *info = tty->driver_data; 925 struct serial_state *info = tty->driver_data;
930 unsigned long flags; 926 unsigned long flags;
931 927
932 if (serial_paranoia_check(info, tty->name, "rs_send_char")) 928 if (serial_paranoia_check(info, tty->name, "rs_send_char"))
@@ -961,7 +957,7 @@ static void rs_send_xchar(struct tty_struct *tty, char ch)
961 */ 957 */
962static void rs_throttle(struct tty_struct * tty) 958static void rs_throttle(struct tty_struct * tty)
963{ 959{
964 struct async_struct *info = tty->driver_data; 960 struct serial_state *info = tty->driver_data;
965 unsigned long flags; 961 unsigned long flags;
966#ifdef SERIAL_DEBUG_THROTTLE 962#ifdef SERIAL_DEBUG_THROTTLE
967 char buf[64]; 963 char buf[64];
@@ -986,7 +982,7 @@ static void rs_throttle(struct tty_struct * tty)
986 982
987static void rs_unthrottle(struct tty_struct * tty) 983static void rs_unthrottle(struct tty_struct * tty)
988{ 984{
989 struct async_struct *info = tty->driver_data; 985 struct serial_state *info = tty->driver_data;
990 unsigned long flags; 986 unsigned long flags;
991#ifdef SERIAL_DEBUG_THROTTLE 987#ifdef SERIAL_DEBUG_THROTTLE
992 char buf[64]; 988 char buf[64];
@@ -1017,11 +1013,10 @@ static void rs_unthrottle(struct tty_struct * tty)
1017 * ------------------------------------------------------------ 1013 * ------------------------------------------------------------
1018 */ 1014 */
1019 1015
1020static int get_serial_info(struct async_struct * info, 1016static int get_serial_info(struct serial_state *state,
1021 struct serial_struct __user * retinfo) 1017 struct serial_struct __user * retinfo)
1022{ 1018{
1023 struct serial_struct tmp; 1019 struct serial_struct tmp;
1024 struct serial_state *state = info->state;
1025 1020
1026 if (!retinfo) 1021 if (!retinfo)
1027 return -EFAULT; 1022 return -EFAULT;
@@ -1043,11 +1038,11 @@ static int get_serial_info(struct async_struct * info,
1043 return 0; 1038 return 0;
1044} 1039}
1045 1040
1046static int set_serial_info(struct async_struct * info, 1041static int set_serial_info(struct serial_state *state,
1047 struct serial_struct __user * new_info) 1042 struct serial_struct __user * new_info)
1048{ 1043{
1049 struct serial_struct new_serial; 1044 struct serial_struct new_serial;
1050 struct serial_state old_state, *state; 1045 struct serial_state old_state;
1051 unsigned int change_irq,change_port; 1046 unsigned int change_irq,change_port;
1052 int retval = 0; 1047 int retval = 0;
1053 1048
@@ -1055,7 +1050,6 @@ static int set_serial_info(struct async_struct * info,
1055 return -EFAULT; 1050 return -EFAULT;
1056 1051
1057 tty_lock(); 1052 tty_lock();
1058 state = info->state;
1059 old_state = *state; 1053 old_state = *state;
1060 1054
1061 change_irq = new_serial.irq != state->irq; 1055 change_irq = new_serial.irq != state->irq;
@@ -1094,7 +1088,7 @@ static int set_serial_info(struct async_struct * info,
1094 state->custom_divisor = new_serial.custom_divisor; 1088 state->custom_divisor = new_serial.custom_divisor;
1095 state->close_delay = new_serial.close_delay * HZ/100; 1089 state->close_delay = new_serial.close_delay * HZ/100;
1096 state->closing_wait = new_serial.closing_wait * HZ/100; 1090 state->closing_wait = new_serial.closing_wait * HZ/100;
1097 info->tty->low_latency = (state->flags & ASYNC_LOW_LATENCY) ? 1 : 0; 1091 state->tty->low_latency = (state->flags & ASYNC_LOW_LATENCY) ? 1 : 0;
1098 1092
1099check_and_exit: 1093check_and_exit:
1100 if (state->flags & ASYNC_INITIALIZED) { 1094 if (state->flags & ASYNC_INITIALIZED) {
@@ -1102,17 +1096,17 @@ check_and_exit:
1102 (state->flags & ASYNC_SPD_MASK)) || 1096 (state->flags & ASYNC_SPD_MASK)) ||
1103 (old_state.custom_divisor != state->custom_divisor)) { 1097 (old_state.custom_divisor != state->custom_divisor)) {
1104 if ((state->flags & ASYNC_SPD_MASK) == ASYNC_SPD_HI) 1098 if ((state->flags & ASYNC_SPD_MASK) == ASYNC_SPD_HI)
1105 info->tty->alt_speed = 57600; 1099 state->tty->alt_speed = 57600;
1106 if ((state->flags & ASYNC_SPD_MASK) == ASYNC_SPD_VHI) 1100 if ((state->flags & ASYNC_SPD_MASK) == ASYNC_SPD_VHI)
1107 info->tty->alt_speed = 115200; 1101 state->tty->alt_speed = 115200;
1108 if ((state->flags & ASYNC_SPD_MASK) == ASYNC_SPD_SHI) 1102 if ((state->flags & ASYNC_SPD_MASK) == ASYNC_SPD_SHI)
1109 info->tty->alt_speed = 230400; 1103 state->tty->alt_speed = 230400;
1110 if ((state->flags & ASYNC_SPD_MASK) == ASYNC_SPD_WARP) 1104 if ((state->flags & ASYNC_SPD_MASK) == ASYNC_SPD_WARP)
1111 info->tty->alt_speed = 460800; 1105 state->tty->alt_speed = 460800;
1112 change_speed(info, NULL); 1106 change_speed(state, NULL);
1113 } 1107 }
1114 } else 1108 } else
1115 retval = startup(info); 1109 retval = startup(state);
1116 tty_unlock(); 1110 tty_unlock();
1117 return retval; 1111 return retval;
1118} 1112}
@@ -1128,7 +1122,7 @@ check_and_exit:
1128 * transmit holding register is empty. This functionality 1122 * transmit holding register is empty. This functionality
1129 * allows an RS485 driver to be written in user space. 1123 * allows an RS485 driver to be written in user space.
1130 */ 1124 */
1131static int get_lsr_info(struct async_struct * info, unsigned int __user *value) 1125static int get_lsr_info(struct serial_state *info, unsigned int __user *value)
1132{ 1126{
1133 unsigned char status; 1127 unsigned char status;
1134 unsigned int result; 1128 unsigned int result;
@@ -1147,7 +1141,7 @@ static int get_lsr_info(struct async_struct * info, unsigned int __user *value)
1147 1141
1148static int rs_tiocmget(struct tty_struct *tty) 1142static int rs_tiocmget(struct tty_struct *tty)
1149{ 1143{
1150 struct async_struct * info = tty->driver_data; 1144 struct serial_state *info = tty->driver_data;
1151 unsigned char control, status; 1145 unsigned char control, status;
1152 unsigned long flags; 1146 unsigned long flags;
1153 1147
@@ -1170,7 +1164,7 @@ static int rs_tiocmget(struct tty_struct *tty)
1170static int rs_tiocmset(struct tty_struct *tty, unsigned int set, 1164static int rs_tiocmset(struct tty_struct *tty, unsigned int set,
1171 unsigned int clear) 1165 unsigned int clear)
1172{ 1166{
1173 struct async_struct * info = tty->driver_data; 1167 struct serial_state *info = tty->driver_data;
1174 unsigned long flags; 1168 unsigned long flags;
1175 1169
1176 if (serial_paranoia_check(info, tty->name, "rs_ioctl")) 1170 if (serial_paranoia_check(info, tty->name, "rs_ioctl"))
@@ -1197,7 +1191,7 @@ static int rs_tiocmset(struct tty_struct *tty, unsigned int set,
1197 */ 1191 */
1198static int rs_break(struct tty_struct *tty, int break_state) 1192static int rs_break(struct tty_struct *tty, int break_state)
1199{ 1193{
1200 struct async_struct * info = tty->driver_data; 1194 struct serial_state *info = tty->driver_data;
1201 unsigned long flags; 1195 unsigned long flags;
1202 1196
1203 if (serial_paranoia_check(info, tty->name, "rs_break")) 1197 if (serial_paranoia_check(info, tty->name, "rs_break"))
@@ -1222,12 +1216,12 @@ static int rs_break(struct tty_struct *tty, int break_state)
1222static int rs_get_icount(struct tty_struct *tty, 1216static int rs_get_icount(struct tty_struct *tty,
1223 struct serial_icounter_struct *icount) 1217 struct serial_icounter_struct *icount)
1224{ 1218{
1225 struct async_struct *info = tty->driver_data; 1219 struct serial_state *info = tty->driver_data;
1226 struct async_icount cnow; 1220 struct async_icount cnow;
1227 unsigned long flags; 1221 unsigned long flags;
1228 1222
1229 local_irq_save(flags); 1223 local_irq_save(flags);
1230 cnow = info->state->icount; 1224 cnow = info->icount;
1231 local_irq_restore(flags); 1225 local_irq_restore(flags);
1232 icount->cts = cnow.cts; 1226 icount->cts = cnow.cts;
1233 icount->dsr = cnow.dsr; 1227 icount->dsr = cnow.dsr;
@@ -1247,7 +1241,7 @@ static int rs_get_icount(struct tty_struct *tty,
1247static int rs_ioctl(struct tty_struct *tty, 1241static int rs_ioctl(struct tty_struct *tty,
1248 unsigned int cmd, unsigned long arg) 1242 unsigned int cmd, unsigned long arg)
1249{ 1243{
1250 struct async_struct * info = tty->driver_data; 1244 struct serial_state *info = tty->driver_data;
1251 struct async_icount cprev, cnow; /* kernel counter temps */ 1245 struct async_icount cprev, cnow; /* kernel counter temps */
1252 void __user *argp = (void __user *)arg; 1246 void __user *argp = (void __user *)arg;
1253 unsigned long flags; 1247 unsigned long flags;
@@ -1275,7 +1269,7 @@ static int rs_ioctl(struct tty_struct *tty,
1275 1269
1276 case TIOCSERGSTRUCT: 1270 case TIOCSERGSTRUCT:
1277 if (copy_to_user(argp, 1271 if (copy_to_user(argp,
1278 info, sizeof(struct async_struct))) 1272 info, sizeof(struct serial_state)))
1279 return -EFAULT; 1273 return -EFAULT;
1280 return 0; 1274 return 0;
1281 1275
@@ -1288,7 +1282,7 @@ static int rs_ioctl(struct tty_struct *tty,
1288 case TIOCMIWAIT: 1282 case TIOCMIWAIT:
1289 local_irq_save(flags); 1283 local_irq_save(flags);
1290 /* note the counters on entry */ 1284 /* note the counters on entry */
1291 cprev = info->state->icount; 1285 cprev = info->icount;
1292 local_irq_restore(flags); 1286 local_irq_restore(flags);
1293 while (1) { 1287 while (1) {
1294 interruptible_sleep_on(&info->delta_msr_wait); 1288 interruptible_sleep_on(&info->delta_msr_wait);
@@ -1296,7 +1290,7 @@ static int rs_ioctl(struct tty_struct *tty,
1296 if (signal_pending(current)) 1290 if (signal_pending(current))
1297 return -ERESTARTSYS; 1291 return -ERESTARTSYS;
1298 local_irq_save(flags); 1292 local_irq_save(flags);
1299 cnow = info->state->icount; /* atomic copy */ 1293 cnow = info->icount; /* atomic copy */
1300 local_irq_restore(flags); 1294 local_irq_restore(flags);
1301 if (cnow.rng == cprev.rng && cnow.dsr == cprev.dsr && 1295 if (cnow.rng == cprev.rng && cnow.dsr == cprev.dsr &&
1302 cnow.dcd == cprev.dcd && cnow.cts == cprev.cts) 1296 cnow.dcd == cprev.dcd && cnow.cts == cprev.cts)
@@ -1325,7 +1319,7 @@ static int rs_ioctl(struct tty_struct *tty,
1325 1319
1326static void rs_set_termios(struct tty_struct *tty, struct ktermios *old_termios) 1320static void rs_set_termios(struct tty_struct *tty, struct ktermios *old_termios)
1327{ 1321{
1328 struct async_struct *info = tty->driver_data; 1322 struct serial_state *info = tty->driver_data;
1329 unsigned long flags; 1323 unsigned long flags;
1330 unsigned int cflag = tty->termios->c_cflag; 1324 unsigned int cflag = tty->termios->c_cflag;
1331 1325
@@ -1385,15 +1379,12 @@ static void rs_set_termios(struct tty_struct *tty, struct ktermios *old_termios)
1385 */ 1379 */
1386static void rs_close(struct tty_struct *tty, struct file * filp) 1380static void rs_close(struct tty_struct *tty, struct file * filp)
1387{ 1381{
1388 struct async_struct * info = tty->driver_data; 1382 struct serial_state *state = tty->driver_data;
1389 struct serial_state *state;
1390 unsigned long flags; 1383 unsigned long flags;
1391 1384
1392 if (!info || serial_paranoia_check(info, tty->name, "rs_close")) 1385 if (!state || serial_paranoia_check(state, tty->name, "rs_close"))
1393 return; 1386 return;
1394 1387
1395 state = info->state;
1396
1397 local_irq_save(flags); 1388 local_irq_save(flags);
1398 1389
1399 if (tty_hung_up_p(filp)) { 1390 if (tty_hung_up_p(filp)) {
@@ -1403,7 +1394,7 @@ static void rs_close(struct tty_struct *tty, struct file * filp)
1403 } 1394 }
1404 1395
1405#ifdef SERIAL_DEBUG_OPEN 1396#ifdef SERIAL_DEBUG_OPEN
1406 printk("rs_close ttys%d, count = %d\n", info->line, state->count); 1397 printk("rs_close ttys%d, count = %d\n", state->line, state->count);
1407#endif 1398#endif
1408 if ((tty->count == 1) && (state->count != 1)) { 1399 if ((tty->count == 1) && (state->count != 1)) {
1409 /* 1400 /*
@@ -1441,7 +1432,7 @@ static void rs_close(struct tty_struct *tty, struct file * filp)
1441 * interrupt driver to stop checking the data ready bit in the 1432 * interrupt driver to stop checking the data ready bit in the
1442 * line status register. 1433 * line status register.
1443 */ 1434 */
1444 info->read_status_mask &= ~UART_LSR_DR; 1435 state->read_status_mask &= ~UART_LSR_DR;
1445 if (state->flags & ASYNC_INITIALIZED) { 1436 if (state->flags & ASYNC_INITIALIZED) {
1446 /* disable receive interrupts */ 1437 /* disable receive interrupts */
1447 custom.intena = IF_RBF; 1438 custom.intena = IF_RBF;
@@ -1455,22 +1446,22 @@ static void rs_close(struct tty_struct *tty, struct file * filp)
1455 * has completely drained; this is especially 1446 * has completely drained; this is especially
1456 * important if there is a transmit FIFO! 1447 * important if there is a transmit FIFO!
1457 */ 1448 */
1458 rs_wait_until_sent(tty, info->timeout); 1449 rs_wait_until_sent(tty, state->timeout);
1459 } 1450 }
1460 shutdown(info); 1451 shutdown(state);
1461 rs_flush_buffer(tty); 1452 rs_flush_buffer(tty);
1462 1453
1463 tty_ldisc_flush(tty); 1454 tty_ldisc_flush(tty);
1464 tty->closing = 0; 1455 tty->closing = 0;
1465 info->tty = NULL; 1456 state->tty = NULL;
1466 if (info->blocked_open) { 1457 if (state->blocked_open) {
1467 if (state->close_delay) { 1458 if (state->close_delay) {
1468 msleep_interruptible(jiffies_to_msecs(state->close_delay)); 1459 msleep_interruptible(jiffies_to_msecs(state->close_delay));
1469 } 1460 }
1470 wake_up_interruptible(&info->open_wait); 1461 wake_up_interruptible(&state->open_wait);
1471 } 1462 }
1472 state->flags &= ~(ASYNC_NORMAL_ACTIVE|ASYNC_CLOSING); 1463 state->flags &= ~(ASYNC_NORMAL_ACTIVE|ASYNC_CLOSING);
1473 wake_up_interruptible(&info->close_wait); 1464 wake_up_interruptible(&state->close_wait);
1474 local_irq_restore(flags); 1465 local_irq_restore(flags);
1475} 1466}
1476 1467
@@ -1479,14 +1470,14 @@ static void rs_close(struct tty_struct *tty, struct file * filp)
1479 */ 1470 */
1480static void rs_wait_until_sent(struct tty_struct *tty, int timeout) 1471static void rs_wait_until_sent(struct tty_struct *tty, int timeout)
1481{ 1472{
1482 struct async_struct * info = tty->driver_data; 1473 struct serial_state *info = tty->driver_data;
1483 unsigned long orig_jiffies, char_time; 1474 unsigned long orig_jiffies, char_time;
1484 int lsr; 1475 int lsr;
1485 1476
1486 if (serial_paranoia_check(info, tty->name, "rs_wait_until_sent")) 1477 if (serial_paranoia_check(info, tty->name, "rs_wait_until_sent"))
1487 return; 1478 return;
1488 1479
1489 if (info->state->xmit_fifo_size == 0) 1480 if (info->xmit_fifo_size == 0)
1490 return; /* Just in case.... */ 1481 return; /* Just in case.... */
1491 1482
1492 orig_jiffies = jiffies; 1483 orig_jiffies = jiffies;
@@ -1499,7 +1490,7 @@ static void rs_wait_until_sent(struct tty_struct *tty, int timeout)
1499 * Note: we have to use pretty tight timings here to satisfy 1490 * Note: we have to use pretty tight timings here to satisfy
1500 * the NIST-PCTS. 1491 * the NIST-PCTS.
1501 */ 1492 */
1502 char_time = (info->timeout - HZ/50) / info->state->xmit_fifo_size; 1493 char_time = (info->timeout - HZ/50) / info->xmit_fifo_size;
1503 char_time = char_time / 5; 1494 char_time = char_time / 5;
1504 if (char_time == 0) 1495 if (char_time == 0)
1505 char_time = 1; 1496 char_time = 1;
@@ -1542,18 +1533,15 @@ static void rs_wait_until_sent(struct tty_struct *tty, int timeout)
1542 */ 1533 */
1543static void rs_hangup(struct tty_struct *tty) 1534static void rs_hangup(struct tty_struct *tty)
1544{ 1535{
1545 struct async_struct * info = tty->driver_data; 1536 struct serial_state *info = tty->driver_data;
1546 struct serial_state *state = info->state;
1547 1537
1548 if (serial_paranoia_check(info, tty->name, "rs_hangup")) 1538 if (serial_paranoia_check(info, tty->name, "rs_hangup"))
1549 return; 1539 return;
1550 1540
1551 state = info->state;
1552
1553 rs_flush_buffer(tty); 1541 rs_flush_buffer(tty);
1554 shutdown(info); 1542 shutdown(info);
1555 state->count = 0; 1543 info->count = 0;
1556 state->flags &= ~ASYNC_NORMAL_ACTIVE; 1544 info->flags &= ~ASYNC_NORMAL_ACTIVE;
1557 info->tty = NULL; 1545 info->tty = NULL;
1558 wake_up_interruptible(&info->open_wait); 1546 wake_up_interruptible(&info->open_wait);
1559} 1547}
@@ -1564,14 +1552,13 @@ static void rs_hangup(struct tty_struct *tty)
1564 * ------------------------------------------------------------ 1552 * ------------------------------------------------------------
1565 */ 1553 */
1566static int block_til_ready(struct tty_struct *tty, struct file * filp, 1554static int block_til_ready(struct tty_struct *tty, struct file * filp,
1567 struct async_struct *info) 1555 struct serial_state *info)
1568{ 1556{
1569#ifdef DECLARE_WAITQUEUE 1557#ifdef DECLARE_WAITQUEUE
1570 DECLARE_WAITQUEUE(wait, current); 1558 DECLARE_WAITQUEUE(wait, current);
1571#else 1559#else
1572 struct wait_queue wait = { current, NULL }; 1560 struct wait_queue wait = { current, NULL };
1573#endif 1561#endif
1574 struct serial_state *state = info->state;
1575 int retval; 1562 int retval;
1576 int do_clocal = 0, extra_count = 0; 1563 int do_clocal = 0, extra_count = 0;
1577 unsigned long flags; 1564 unsigned long flags;
@@ -1581,11 +1568,11 @@ static int block_til_ready(struct tty_struct *tty, struct file * filp,
1581 * until it's done, and then try again. 1568 * until it's done, and then try again.
1582 */ 1569 */
1583 if (tty_hung_up_p(filp) || 1570 if (tty_hung_up_p(filp) ||
1584 (state->flags & ASYNC_CLOSING)) { 1571 (info->flags & ASYNC_CLOSING)) {
1585 if (state->flags & ASYNC_CLOSING) 1572 if (info->flags & ASYNC_CLOSING)
1586 interruptible_sleep_on(&info->close_wait); 1573 interruptible_sleep_on(&info->close_wait);
1587#ifdef SERIAL_DO_RESTART 1574#ifdef SERIAL_DO_RESTART
1588 return ((state->flags & ASYNC_HUP_NOTIFY) ? 1575 return ((info->flags & ASYNC_HUP_NOTIFY) ?
1589 -EAGAIN : -ERESTARTSYS); 1576 -EAGAIN : -ERESTARTSYS);
1590#else 1577#else
1591 return -EAGAIN; 1578 return -EAGAIN;
@@ -1598,7 +1585,7 @@ static int block_til_ready(struct tty_struct *tty, struct file * filp,
1598 */ 1585 */
1599 if ((filp->f_flags & O_NONBLOCK) || 1586 if ((filp->f_flags & O_NONBLOCK) ||
1600 (tty->flags & (1 << TTY_IO_ERROR))) { 1587 (tty->flags & (1 << TTY_IO_ERROR))) {
1601 state->flags |= ASYNC_NORMAL_ACTIVE; 1588 info->flags |= ASYNC_NORMAL_ACTIVE;
1602 return 0; 1589 return 0;
1603 } 1590 }
1604 1591
@@ -1608,7 +1595,7 @@ static int block_til_ready(struct tty_struct *tty, struct file * filp,
1608 /* 1595 /*
1609 * Block waiting for the carrier detect and the line to become 1596 * Block waiting for the carrier detect and the line to become
1610 * free (i.e., not in use by the callout). While we are in 1597 * free (i.e., not in use by the callout). While we are in
1611 * this loop, state->count is dropped by one, so that 1598 * this loop, info->count is dropped by one, so that
1612 * rs_close() knows when to free things. We restore it upon 1599 * rs_close() knows when to free things. We restore it upon
1613 * exit, either normal or abnormal. 1600 * exit, either normal or abnormal.
1614 */ 1601 */
@@ -1616,12 +1603,12 @@ static int block_til_ready(struct tty_struct *tty, struct file * filp,
1616 add_wait_queue(&info->open_wait, &wait); 1603 add_wait_queue(&info->open_wait, &wait);
1617#ifdef SERIAL_DEBUG_OPEN 1604#ifdef SERIAL_DEBUG_OPEN
1618 printk("block_til_ready before block: ttys%d, count = %d\n", 1605 printk("block_til_ready before block: ttys%d, count = %d\n",
1619 state->line, state->count); 1606 info->line, info->count);
1620#endif 1607#endif
1621 local_irq_save(flags); 1608 local_irq_save(flags);
1622 if (!tty_hung_up_p(filp)) { 1609 if (!tty_hung_up_p(filp)) {
1623 extra_count = 1; 1610 extra_count = 1;
1624 state->count--; 1611 info->count--;
1625 } 1612 }
1626 local_irq_restore(flags); 1613 local_irq_restore(flags);
1627 info->blocked_open++; 1614 info->blocked_open++;
@@ -1632,9 +1619,9 @@ static int block_til_ready(struct tty_struct *tty, struct file * filp,
1632 local_irq_restore(flags); 1619 local_irq_restore(flags);
1633 set_current_state(TASK_INTERRUPTIBLE); 1620 set_current_state(TASK_INTERRUPTIBLE);
1634 if (tty_hung_up_p(filp) || 1621 if (tty_hung_up_p(filp) ||
1635 !(state->flags & ASYNC_INITIALIZED)) { 1622 !(info->flags & ASYNC_INITIALIZED)) {
1636#ifdef SERIAL_DO_RESTART 1623#ifdef SERIAL_DO_RESTART
1637 if (state->flags & ASYNC_HUP_NOTIFY) 1624 if (info->flags & ASYNC_HUP_NOTIFY)
1638 retval = -EAGAIN; 1625 retval = -EAGAIN;
1639 else 1626 else
1640 retval = -ERESTARTSYS; 1627 retval = -ERESTARTSYS;
@@ -1643,7 +1630,7 @@ static int block_til_ready(struct tty_struct *tty, struct file * filp,
1643#endif 1630#endif
1644 break; 1631 break;
1645 } 1632 }
1646 if (!(state->flags & ASYNC_CLOSING) && 1633 if (!(info->flags & ASYNC_CLOSING) &&
1647 (do_clocal || (!(ciab.pra & SER_DCD)) )) 1634 (do_clocal || (!(ciab.pra & SER_DCD)) ))
1648 break; 1635 break;
1649 if (signal_pending(current)) { 1636 if (signal_pending(current)) {
@@ -1652,7 +1639,7 @@ static int block_til_ready(struct tty_struct *tty, struct file * filp,
1652 } 1639 }
1653#ifdef SERIAL_DEBUG_OPEN 1640#ifdef SERIAL_DEBUG_OPEN
1654 printk("block_til_ready blocking: ttys%d, count = %d\n", 1641 printk("block_til_ready blocking: ttys%d, count = %d\n",
1655 info->line, state->count); 1642 info->line, info->count);
1656#endif 1643#endif
1657 tty_unlock(); 1644 tty_unlock();
1658 schedule(); 1645 schedule();
@@ -1661,46 +1648,15 @@ static int block_til_ready(struct tty_struct *tty, struct file * filp,
1661 __set_current_state(TASK_RUNNING); 1648 __set_current_state(TASK_RUNNING);
1662 remove_wait_queue(&info->open_wait, &wait); 1649 remove_wait_queue(&info->open_wait, &wait);
1663 if (extra_count) 1650 if (extra_count)
1664 state->count++; 1651 info->count++;
1665 info->blocked_open--; 1652 info->blocked_open--;
1666#ifdef SERIAL_DEBUG_OPEN 1653#ifdef SERIAL_DEBUG_OPEN
1667 printk("block_til_ready after blocking: ttys%d, count = %d\n", 1654 printk("block_til_ready after blocking: ttys%d, count = %d\n",
1668 info->line, state->count); 1655 info->line, info->count);
1669#endif 1656#endif
1670 if (retval) 1657 if (retval)
1671 return retval; 1658 return retval;
1672 state->flags |= ASYNC_NORMAL_ACTIVE; 1659 info->flags |= ASYNC_NORMAL_ACTIVE;
1673 return 0;
1674}
1675
1676static int get_async_struct(int line, struct async_struct **ret_info)
1677{
1678 struct async_struct *info;
1679 struct serial_state *sstate;
1680
1681 sstate = rs_table + line;
1682 sstate->count++;
1683 if (sstate->info) {
1684 *ret_info = sstate->info;
1685 return 0;
1686 }
1687 info = kzalloc(sizeof(struct async_struct), GFP_KERNEL);
1688 if (!info) {
1689 sstate->count--;
1690 return -ENOMEM;
1691 }
1692#ifdef DECLARE_WAITQUEUE
1693 init_waitqueue_head(&info->open_wait);
1694 init_waitqueue_head(&info->close_wait);
1695 init_waitqueue_head(&info->delta_msr_wait);
1696#endif
1697 info->state = sstate;
1698 if (sstate->info) {
1699 kfree(info);
1700 *ret_info = sstate->info;
1701 return 0;
1702 }
1703 *ret_info = sstate->info = info;
1704 return 0; 1660 return 0;
1705} 1661}
1706 1662
@@ -1712,32 +1668,29 @@ static int get_async_struct(int line, struct async_struct **ret_info)
1712 */ 1668 */
1713static int rs_open(struct tty_struct *tty, struct file * filp) 1669static int rs_open(struct tty_struct *tty, struct file * filp)
1714{ 1670{
1715 struct async_struct *info; 1671 struct serial_state *info = rs_table + tty->index;
1716 int retval; 1672 int retval;
1717 1673
1718 retval = get_async_struct(tty->index, &info); 1674 info->count++;
1719 if (retval) {
1720 return retval;
1721 }
1722 tty->driver_data = info;
1723 info->tty = tty; 1675 info->tty = tty;
1676 tty->driver_data = info;
1724 if (serial_paranoia_check(info, tty->name, "rs_open")) 1677 if (serial_paranoia_check(info, tty->name, "rs_open"))
1725 return -ENODEV; 1678 return -ENODEV;
1726 1679
1727#ifdef SERIAL_DEBUG_OPEN 1680#ifdef SERIAL_DEBUG_OPEN
1728 printk("rs_open %s, count = %d\n", tty->name, info->state->count); 1681 printk("rs_open %s, count = %d\n", tty->name, info->count);
1729#endif 1682#endif
1730 info->tty->low_latency = (info->state->flags & ASYNC_LOW_LATENCY) ? 1 : 0; 1683 tty->low_latency = (info->flags & ASYNC_LOW_LATENCY) ? 1 : 0;
1731 1684
1732 /* 1685 /*
1733 * If the port is the middle of closing, bail out now 1686 * If the port is the middle of closing, bail out now
1734 */ 1687 */
1735 if (tty_hung_up_p(filp) || 1688 if (tty_hung_up_p(filp) ||
1736 (info->state->flags & ASYNC_CLOSING)) { 1689 (info->flags & ASYNC_CLOSING)) {
1737 if (info->state->flags & ASYNC_CLOSING) 1690 if (info->flags & ASYNC_CLOSING)
1738 interruptible_sleep_on(&info->close_wait); 1691 interruptible_sleep_on(&info->close_wait);
1739#ifdef SERIAL_DO_RESTART 1692#ifdef SERIAL_DO_RESTART
1740 return ((info->state->flags & ASYNC_HUP_NOTIFY) ? 1693 return ((info->flags & ASYNC_HUP_NOTIFY) ?
1741 -EAGAIN : -ERESTARTSYS); 1694 -EAGAIN : -ERESTARTSYS);
1742#else 1695#else
1743 return -EAGAIN; 1696 return -EAGAIN;
@@ -1773,24 +1726,14 @@ static int rs_open(struct tty_struct *tty, struct file * filp)
1773 1726
1774static inline void line_info(struct seq_file *m, struct serial_state *state) 1727static inline void line_info(struct seq_file *m, struct serial_state *state)
1775{ 1728{
1776 struct async_struct *info = state->info, scr_info;
1777 char stat_buf[30], control, status; 1729 char stat_buf[30], control, status;
1778 unsigned long flags; 1730 unsigned long flags;
1779 1731
1780 seq_printf(m, "%d: uart:amiga_builtin",state->line); 1732 seq_printf(m, "%d: uart:amiga_builtin",state->line);
1781 1733
1782 /*
1783 * Figure out the current RS-232 lines
1784 */
1785 if (!info) {
1786 info = &scr_info; /* This is just for serial_{in,out} */
1787
1788 info->quot = 0;
1789 info->tty = NULL;
1790 }
1791 local_irq_save(flags); 1734 local_irq_save(flags);
1792 status = ciab.pra; 1735 status = ciab.pra;
1793 control = info ? info->MCR : status; 1736 control = (state->flags & ASYNC_INITIALIZED) ? state->MCR : status;
1794 local_irq_restore(flags); 1737 local_irq_restore(flags);
1795 1738
1796 stat_buf[0] = 0; 1739 stat_buf[0] = 0;
@@ -1806,9 +1749,8 @@ static inline void line_info(struct seq_file *m, struct serial_state *state)
1806 if(!(status & SER_DCD)) 1749 if(!(status & SER_DCD))
1807 strcat(stat_buf, "|CD"); 1750 strcat(stat_buf, "|CD");
1808 1751
1809 if (info->quot) { 1752 if (state->quot)
1810 seq_printf(m, " baud:%d", state->baud_base / info->quot); 1753 seq_printf(m, " baud:%d", state->baud_base / state->quot);
1811 }
1812 1754
1813 seq_printf(m, " tx:%d rx:%d", state->icount.tx, state->icount.rx); 1755 seq_printf(m, " tx:%d rx:%d", state->icount.tx, state->icount.rx);
1814 1756
@@ -1938,6 +1880,9 @@ static int __init amiga_serial_probe(struct platform_device *pdev)
1938 state->icount.rx = state->icount.tx = 0; 1880 state->icount.rx = state->icount.tx = 0;
1939 state->icount.frame = state->icount.parity = 0; 1881 state->icount.frame = state->icount.parity = 0;
1940 state->icount.overrun = state->icount.brk = 0; 1882 state->icount.overrun = state->icount.brk = 0;
1883 init_waitqueue_head(&state->open_wait);
1884 init_waitqueue_head(&state->close_wait);
1885 init_waitqueue_head(&state->delta_msr_wait);
1941 1886
1942 printk(KERN_INFO "ttyS%d is the amiga builtin serial port\n", 1887 printk(KERN_INFO "ttyS%d is the amiga builtin serial port\n",
1943 state->line); 1888 state->line);
@@ -1993,7 +1938,6 @@ static int __exit amiga_serial_remove(struct platform_device *pdev)
1993{ 1938{
1994 int error; 1939 int error;
1995 struct serial_state *state = platform_get_drvdata(pdev); 1940 struct serial_state *state = platform_get_drvdata(pdev);
1996 struct async_struct *info = state->info;
1997 1941
1998 /* printk("Unloading %s: version %s\n", serial_name, serial_version); */ 1942 /* printk("Unloading %s: version %s\n", serial_name, serial_version); */
1999 if ((error = tty_unregister_driver(serial_driver))) 1943 if ((error = tty_unregister_driver(serial_driver)))
@@ -2001,11 +1945,8 @@ static int __exit amiga_serial_remove(struct platform_device *pdev)
2001 error); 1945 error);
2002 put_tty_driver(serial_driver); 1946 put_tty_driver(serial_driver);
2003 1947
2004 rs_table[0].info = NULL; 1948 free_irq(IRQ_AMIGA_TBE, state);
2005 kfree(info); 1949 free_irq(IRQ_AMIGA_RBF, state);
2006
2007 free_irq(IRQ_AMIGA_TBE, rs_table);
2008 free_irq(IRQ_AMIGA_RBF, rs_table);
2009 1950
2010 platform_set_drvdata(pdev, NULL); 1951 platform_set_drvdata(pdev, NULL);
2011 1952