Commit c1314a49d7907b96d72f2c41f8927fc3c738e956

Authored by Alan Cox
Committed by Linus Torvalds
1 parent 6ed1dbaead

tty: Redo the rocket driver locking

Bring this driver into the port locking model

Signed-off-by: Alan Cox <alan@redhat.com>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>

Showing 2 changed files with 20 additions and 24 deletions Side-by-side Diff

... ... @@ -164,8 +164,6 @@
164 164 static int pc_chars_in_buffer(struct tty_struct *);
165 165 static void pc_flush_buffer(struct tty_struct *);
166 166 static void pc_flush_chars(struct tty_struct *);
167   -static int block_til_ready(struct tty_struct *, struct file *,
168   - struct channel *);
169 167 static int pc_open(struct tty_struct *, struct file *);
170 168 static void post_fep_init(unsigned int crd);
171 169 static void epcapoll(unsigned long);
... ... @@ -422,7 +420,6 @@
422 420 {
423 421 struct channel *ch;
424 422 struct tty_port *port;
425   - unsigned long flags;
426 423 /*
427 424 * verifyChannel returns the channel from the tty struct if it is
428 425 * valid. This serves as a sanity check.
... ... @@ -491,8 +488,6 @@
491 488 */
492 489 ch = verifyChannel(tty);
493 490 if (ch != NULL) {
494   - unsigned long flags;
495   -
496 491 pc_flush_buffer(tty);
497 492 tty_ldisc_flush(tty);
498 493 shutdown(ch, tty);
... ... @@ -750,7 +745,7 @@
750 745 return 0;
751 746 }
752 747  
753   -static void epca_raise_dtr_rts(struct tty_port *port0
  748 +static void epca_raise_dtr_rts(struct tty_port *port)
754 749 {
755 750 }
756 751  
... ... @@ -1268,7 +1263,7 @@
1268 1263 u16 tseg, rseg;
1269 1264  
1270 1265 tty_port_init(&ch->port);
1271   - ch->port.ops - &epca_port_ops;
  1266 + ch->port.ops = &epca_port_ops;
1272 1267 ch->brdchan = bc;
1273 1268 ch->mailbox = gd;
1274 1269 INIT_WORK(&ch->tqueue, do_softint);
drivers/char/rocket.c
... ... @@ -920,7 +920,7 @@
920 920 #ifdef ROCKET_DEBUG_OPEN
921 921 printk(KERN_INFO "block_til_ready before block: ttyR%d, count = %d\n", info->line, port->count);
922 922 #endif
923   - spin_lock_irqsave(&info->slock, flags);
  923 + spin_lock_irqsave(&port->lock, flags);
924 924  
925 925 #ifdef ROCKET_DISABLE_SIMUSAGE
926 926 info->flags |= ASYNC_NORMAL_ACTIVE;
... ... @@ -932,7 +932,7 @@
932 932 #endif
933 933 port->blocked_open++;
934 934  
935   - spin_unlock_irqrestore(&info->slock, flags);
  935 + spin_unlock_irqrestore(&port->lock, flags);
936 936  
937 937 while (1) {
938 938 if (tty->termios->c_cflag & CBAUD)
939 939  
... ... @@ -961,13 +961,13 @@
961 961 __set_current_state(TASK_RUNNING);
962 962 remove_wait_queue(&port->open_wait, &wait);
963 963  
964   - spin_lock_irqsave(&info->slock, flags);
  964 + spin_lock_irqsave(&port->lock, flags);
965 965  
966 966 if (extra_count)
967 967 port->count++;
968 968 port->blocked_open--;
969 969  
970   - spin_unlock_irqrestore(&info->slock, flags);
  970 + spin_unlock_irqrestore(&port->lock, flags);
971 971  
972 972 #ifdef ROCKET_DEBUG_OPEN
973 973 printk(KERN_INFO "block_til_ready after blocking: ttyR%d, count = %d\n",
... ... @@ -1095,6 +1095,7 @@
1095 1095 static void rp_close(struct tty_struct *tty, struct file *filp)
1096 1096 {
1097 1097 struct r_port *info = tty->driver_data;
  1098 + struct tty_port *port = &info->port;
1098 1099 unsigned long flags;
1099 1100 int timeout;
1100 1101 CHANNEL_t *cp;
1101 1102  
... ... @@ -1108,9 +1109,9 @@
1108 1109  
1109 1110 if (tty_hung_up_p(filp))
1110 1111 return;
1111   - spin_lock_irqsave(&info->slock, flags);
  1112 + spin_lock_irqsave(&port->lock, flags);
1112 1113  
1113   - if ((tty->count == 1) && (info->port.count != 1)) {
  1114 + if (tty->count == 1 && port->count != 1) {
1114 1115 /*
1115 1116 * Uh, oh. tty->count is 1, which means that the tty
1116 1117 * structure will be freed. Info->count should always
1117 1118  
1118 1119  
1119 1120  
1120 1121  
... ... @@ -1120,19 +1121,19 @@
1120 1121 */
1121 1122 printk(KERN_WARNING "rp_close: bad serial port count; "
1122 1123 "tty->count is 1, info->port.count is %d\n", info->port.count);
1123   - info->port.count = 1;
  1124 + port->count = 1;
1124 1125 }
1125   - if (--info->port.count < 0) {
  1126 + if (--port->count < 0) {
1126 1127 printk(KERN_WARNING "rp_close: bad serial port count for "
1127 1128 "ttyR%d: %d\n", info->line, info->port.count);
1128   - info->port.count = 0;
  1129 + port->count = 0;
1129 1130 }
1130   - if (info->port.count) {
1131   - spin_unlock_irqrestore(&info->slock, flags);
  1131 + if (port->count) {
  1132 + spin_unlock_irqrestore(&port->lock, flags);
1132 1133 return;
1133 1134 }
1134 1135 info->flags |= ASYNC_CLOSING;
1135   - spin_unlock_irqrestore(&info->slock, flags);
  1136 + spin_unlock_irqrestore(&port->lock, flags);
1136 1137  
1137 1138 cp = &info->channel;
1138 1139  
... ... @@ -1152,7 +1153,7 @@
1152 1153 * Wait for the transmit buffer to clear
1153 1154 */
1154 1155 if (info->port.closing_wait != ASYNC_CLOSING_WAIT_NONE)
1155   - tty_wait_until_sent(tty, info->port.closing_wait);
  1156 + tty_wait_until_sent(tty, port->closing_wait);
1156 1157 /*
1157 1158 * Before we drop DTR, make sure the UART transmitter
1158 1159 * has completely drained; this is especially
1159 1160  
... ... @@ -1181,11 +1182,11 @@
1181 1182  
1182 1183 clear_bit((info->aiop * 8) + info->chan, (void *) &xmit_flags[info->board]);
1183 1184  
1184   - if (info->port.blocked_open) {
1185   - if (info->port.close_delay) {
1186   - msleep_interruptible(jiffies_to_msecs(info->port.close_delay));
  1185 + if (port->blocked_open) {
  1186 + if (port->close_delay) {
  1187 + msleep_interruptible(jiffies_to_msecs(port->close_delay));
1187 1188 }
1188   - wake_up_interruptible(&info->port.open_wait);
  1189 + wake_up_interruptible(&port->open_wait);
1189 1190 } else {
1190 1191 if (info->xmit_buf) {
1191 1192 free_page((unsigned long) info->xmit_buf);