aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/tty/serial/68328serial.c
diff options
context:
space:
mode:
authorJiri Slaby <jslaby@suse.cz>2012-04-02 07:54:46 -0400
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2012-04-09 15:02:45 -0400
commit8e32841634958d4927a85b484faf9d2c3c222e4d (patch)
tree388a0ffe7224e9981497e04c7ad3ba3801e7c7f3 /drivers/tty/serial/68328serial.c
parent665569d0269be3dd67b768fb65061e1b54bb2faf (diff)
TTY: 68328serial, use tty_port_block_til_ready
Since the code is identical, use the tty_port_block_til_ready helper instead of re-implemented variant. The code does not perform rtsdts handling, hence we do not need to provide tty port hooks for them. The default ones will be used instead. The only necessary thing is to provide tty_port_operations. It is empty, but has to be there... Signed-off-by: Jiri Slaby <jslaby@suse.cz> Cc: Geert Uytterhoeven <geert@linux-m68k.org> Cc: linux-m68k@lists.linux-m68k.org Acked-by: Greg Ungerer <gerg@uclinux.org> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'drivers/tty/serial/68328serial.c')
-rw-r--r--drivers/tty/serial/68328serial.c96
1 files changed, 5 insertions, 91 deletions
diff --git a/drivers/tty/serial/68328serial.c b/drivers/tty/serial/68328serial.c
index 77e10bb89e4b..3ed20e435e59 100644
--- a/drivers/tty/serial/68328serial.c
+++ b/drivers/tty/serial/68328serial.c
@@ -1104,96 +1104,6 @@ void rs_hangup(struct tty_struct *tty)
1104} 1104}
1105 1105
1106/* 1106/*
1107 * ------------------------------------------------------------
1108 * rs_open() and friends
1109 * ------------------------------------------------------------
1110 */
1111static int block_til_ready(struct tty_struct *tty, struct file * filp,
1112 struct m68k_serial *info)
1113{
1114 struct tty_port *port = &info->tport;
1115 DECLARE_WAITQUEUE(wait, current);
1116 int retval;
1117 int do_clocal = 0;
1118
1119 /*
1120 * If the device is in the middle of being closed, then block
1121 * until it's done, and then try again.
1122 */
1123 if (port->flags & ASYNC_CLOSING) {
1124 interruptible_sleep_on(&port->close_wait);
1125#ifdef SERIAL_DO_RESTART
1126 if (port->flags & ASYNC_HUP_NOTIFY)
1127 return -EAGAIN;
1128 else
1129 return -ERESTARTSYS;
1130#else
1131 return -EAGAIN;
1132#endif
1133 }
1134
1135 /*
1136 * If non-blocking mode is set, or the port is not enabled,
1137 * then make the check up front and then exit.
1138 */
1139 if ((filp->f_flags & O_NONBLOCK) ||
1140 (tty->flags & (1 << TTY_IO_ERROR))) {
1141 port->flags |= ASYNC_NORMAL_ACTIVE;
1142 return 0;
1143 }
1144
1145 if (tty->termios->c_cflag & CLOCAL)
1146 do_clocal = 1;
1147
1148 /*
1149 * Block waiting for the carrier detect and the line to become
1150 * free (i.e., not in use by the callout). While we are in
1151 * this loop, port->count is dropped by one, so that
1152 * rs_close() knows when to free things. We restore it upon
1153 * exit, either normal or abnormal.
1154 */
1155 retval = 0;
1156 add_wait_queue(&port->open_wait, &wait);
1157
1158 port->count--;
1159 port->blocked_open++;
1160 while (1) {
1161 current->state = TASK_INTERRUPTIBLE;
1162 if (tty_hung_up_p(filp) ||
1163 !(port->flags & ASYNC_INITIALIZED)) {
1164#ifdef SERIAL_DO_RESTART
1165 if (port->flags & ASYNC_HUP_NOTIFY)
1166 retval = -EAGAIN;
1167 else
1168 retval = -ERESTARTSYS;
1169#else
1170 retval = -EAGAIN;
1171#endif
1172 break;
1173 }
1174 if (!(port->flags & ASYNC_CLOSING) && do_clocal)
1175 break;
1176 if (signal_pending(current)) {
1177 retval = -ERESTARTSYS;
1178 break;
1179 }
1180 tty_unlock();
1181 schedule();
1182 tty_lock();
1183 }
1184 current->state = TASK_RUNNING;
1185 remove_wait_queue(&port->open_wait, &wait);
1186 if (!tty_hung_up_p(filp))
1187 port->count++;
1188 port->blocked_open--;
1189
1190 if (retval)
1191 return retval;
1192 port->flags |= ASYNC_NORMAL_ACTIVE;
1193 return 0;
1194}
1195
1196/*
1197 * This routine is called whenever a serial port is opened. It 1107 * This routine is called whenever a serial port is opened. It
1198 * enables interrupts for a serial port, linking in its S structure into 1108 * enables interrupts for a serial port, linking in its S structure into
1199 * the IRQ chain. It also performs the serial-specific 1109 * the IRQ chain. It also performs the serial-specific
@@ -1220,7 +1130,7 @@ int rs_open(struct tty_struct *tty, struct file * filp)
1220 if (retval) 1130 if (retval)
1221 return retval; 1131 return retval;
1222 1132
1223 return block_til_ready(tty, filp, info); 1133 return tty_port_block_til_ready(&info->tport, tty, filp);
1224} 1134}
1225 1135
1226/* Finally, routines used to initialize the serial driver. */ 1136/* Finally, routines used to initialize the serial driver. */
@@ -1248,6 +1158,9 @@ static const struct tty_operations rs_ops = {
1248 .set_ldisc = rs_set_ldisc, 1158 .set_ldisc = rs_set_ldisc,
1249}; 1159};
1250 1160
1161static const struct tty_port_operations rs_port_ops = {
1162};
1163
1251/* rs_init inits the driver */ 1164/* rs_init inits the driver */
1252static int __init 1165static int __init
1253rs68328_init(void) 1166rs68328_init(void)
@@ -1288,6 +1201,7 @@ rs68328_init(void)
1288 1201
1289 info = &m68k_soft[i]; 1202 info = &m68k_soft[i];
1290 tty_port_init(&info->tport); 1203 tty_port_init(&info->tport);
1204 info->tport.ops = &rs_port_ops;
1291 info->magic = SERIAL_MAGIC; 1205 info->magic = SERIAL_MAGIC;
1292 info->port = (int) &uart_addr[i]; 1206 info->port = (int) &uart_addr[i];
1293 info->irq = uart_irqs[i]; 1207 info->irq = uart_irqs[i];