aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/tty/serial/68328serial.c
diff options
context:
space:
mode:
authorJiri Slaby <jslaby@suse.cz>2012-04-02 07:54:40 -0400
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2012-04-09 15:02:44 -0400
commit86264341bb1dafd4d38788b7c877de55b6c2f937 (patch)
tree1a8a7c33fc93d16c6ab55847c58290c4e657692d /drivers/tty/serial/68328serial.c
parent1bb2687c3bad13a061e98887bdfb1a6b9ad79542 (diff)
TTY: 68328serial, add tty_port
And use count and blocked_count from that. 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.c40
1 files changed, 20 insertions, 20 deletions
diff --git a/drivers/tty/serial/68328serial.c b/drivers/tty/serial/68328serial.c
index 116d932401ed..848662c3b16e 100644
--- a/drivers/tty/serial/68328serial.c
+++ b/drivers/tty/serial/68328serial.c
@@ -109,6 +109,7 @@
109 * For definitions of the flags field, see serial.h 109 * For definitions of the flags field, see serial.h
110 */ 110 */
111struct m68k_serial { 111struct m68k_serial {
112 struct tty_port tport;
112 char is_cons; /* Is this our console. */ 113 char is_cons; /* Is this our console. */
113 int magic; 114 int magic;
114 int baud_base; 115 int baud_base;
@@ -122,8 +123,6 @@ struct m68k_serial {
122 int close_delay; 123 int close_delay;
123 unsigned short closing_wait; 124 unsigned short closing_wait;
124 int line; 125 int line;
125 int count; /* # of fd on device */
126 int blocked_open; /* # of blocked opens */
127 unsigned char *xmit_buf; 126 unsigned char *xmit_buf;
128 int xmit_head; 127 int xmit_head;
129 int xmit_tail; 128 int xmit_tail;
@@ -866,7 +865,7 @@ static int set_serial_info(struct m68k_serial * info,
866 goto check_and_exit; 865 goto check_and_exit;
867 } 866 }
868 867
869 if (info->count > 1) 868 if (info->tport.count > 1)
870 return -EBUSY; 869 return -EBUSY;
871 870
872 /* 871 /*
@@ -1010,6 +1009,7 @@ static void rs_set_termios(struct tty_struct *tty, struct ktermios *old_termios)
1010static void rs_close(struct tty_struct *tty, struct file * filp) 1009static void rs_close(struct tty_struct *tty, struct file * filp)
1011{ 1010{
1012 struct m68k_serial * info = (struct m68k_serial *)tty->driver_data; 1011 struct m68k_serial * info = (struct m68k_serial *)tty->driver_data;
1012 struct tty_port *port = &info->tport;
1013 m68328_uart *uart = &uart_addr[info->line]; 1013 m68328_uart *uart = &uart_addr[info->line];
1014 unsigned long flags; 1014 unsigned long flags;
1015 1015
@@ -1023,7 +1023,7 @@ static void rs_close(struct tty_struct *tty, struct file * filp)
1023 return; 1023 return;
1024 } 1024 }
1025 1025
1026 if ((tty->count == 1) && (info->count != 1)) { 1026 if ((tty->count == 1) && (port->count != 1)) {
1027 /* 1027 /*
1028 * Uh, oh. tty->count is 1, which means that the tty 1028 * Uh, oh. tty->count is 1, which means that the tty
1029 * structure will be freed. Info->count should always 1029 * structure will be freed. Info->count should always
@@ -1032,15 +1032,15 @@ static void rs_close(struct tty_struct *tty, struct file * filp)
1032 * serial port won't be shutdown. 1032 * serial port won't be shutdown.
1033 */ 1033 */
1034 printk("rs_close: bad serial port count; tty->count is 1, " 1034 printk("rs_close: bad serial port count; tty->count is 1, "
1035 "info->count is %d\n", info->count); 1035 "port->count is %d\n", port->count);
1036 info->count = 1; 1036 port->count = 1;
1037 } 1037 }
1038 if (--info->count < 0) { 1038 if (--port->count < 0) {
1039 printk("rs_close: bad serial port count for ttyS%d: %d\n", 1039 printk("rs_close: bad serial port count for ttyS%d: %d\n",
1040 info->line, info->count); 1040 info->line, port->count);
1041 info->count = 0; 1041 port->count = 0;
1042 } 1042 }
1043 if (info->count) { 1043 if (port->count) {
1044 local_irq_restore(flags); 1044 local_irq_restore(flags);
1045 return; 1045 return;
1046 } 1046 }
@@ -1079,7 +1079,7 @@ static void rs_close(struct tty_struct *tty, struct file * filp)
1079 (tty->ldisc.open)(tty); 1079 (tty->ldisc.open)(tty);
1080 } 1080 }
1081#endif 1081#endif
1082 if (info->blocked_open) { 1082 if (port->blocked_open) {
1083 if (info->close_delay) { 1083 if (info->close_delay) {
1084 msleep_interruptible(jiffies_to_msecs(info->close_delay)); 1084 msleep_interruptible(jiffies_to_msecs(info->close_delay));
1085 } 1085 }
@@ -1102,7 +1102,7 @@ void rs_hangup(struct tty_struct *tty)
1102 1102
1103 rs_flush_buffer(tty); 1103 rs_flush_buffer(tty);
1104 shutdown(info); 1104 shutdown(info);
1105 info->count = 0; 1105 info->tport.count = 0;
1106 info->flags &= ~ASYNC_NORMAL_ACTIVE; 1106 info->flags &= ~ASYNC_NORMAL_ACTIVE;
1107 info->tty = NULL; 1107 info->tty = NULL;
1108 wake_up_interruptible(&info->open_wait); 1108 wake_up_interruptible(&info->open_wait);
@@ -1116,6 +1116,7 @@ void rs_hangup(struct tty_struct *tty)
1116static int block_til_ready(struct tty_struct *tty, struct file * filp, 1116static int block_til_ready(struct tty_struct *tty, struct file * filp,
1117 struct m68k_serial *info) 1117 struct m68k_serial *info)
1118{ 1118{
1119 struct tty_port *port = &info->tport;
1119 DECLARE_WAITQUEUE(wait, current); 1120 DECLARE_WAITQUEUE(wait, current);
1120 int retval; 1121 int retval;
1121 int do_clocal = 0; 1122 int do_clocal = 0;
@@ -1152,15 +1153,15 @@ static int block_til_ready(struct tty_struct *tty, struct file * filp,
1152 /* 1153 /*
1153 * Block waiting for the carrier detect and the line to become 1154 * Block waiting for the carrier detect and the line to become
1154 * free (i.e., not in use by the callout). While we are in 1155 * free (i.e., not in use by the callout). While we are in
1155 * this loop, info->count is dropped by one, so that 1156 * this loop, port->count is dropped by one, so that
1156 * rs_close() knows when to free things. We restore it upon 1157 * rs_close() knows when to free things. We restore it upon
1157 * exit, either normal or abnormal. 1158 * exit, either normal or abnormal.
1158 */ 1159 */
1159 retval = 0; 1160 retval = 0;
1160 add_wait_queue(&info->open_wait, &wait); 1161 add_wait_queue(&info->open_wait, &wait);
1161 1162
1162 info->count--; 1163 port->count--;
1163 info->blocked_open++; 1164 port->blocked_open++;
1164 while (1) { 1165 while (1) {
1165 current->state = TASK_INTERRUPTIBLE; 1166 current->state = TASK_INTERRUPTIBLE;
1166 if (tty_hung_up_p(filp) || 1167 if (tty_hung_up_p(filp) ||
@@ -1188,8 +1189,8 @@ static int block_til_ready(struct tty_struct *tty, struct file * filp,
1188 current->state = TASK_RUNNING; 1189 current->state = TASK_RUNNING;
1189 remove_wait_queue(&info->open_wait, &wait); 1190 remove_wait_queue(&info->open_wait, &wait);
1190 if (!tty_hung_up_p(filp)) 1191 if (!tty_hung_up_p(filp))
1191 info->count++; 1192 port->count++;
1192 info->blocked_open--; 1193 port->blocked_open--;
1193 1194
1194 if (retval) 1195 if (retval)
1195 return retval; 1196 return retval;
@@ -1213,7 +1214,7 @@ int rs_open(struct tty_struct *tty, struct file * filp)
1213 if (serial_paranoia_check(info, tty->name, "rs_open")) 1214 if (serial_paranoia_check(info, tty->name, "rs_open"))
1214 return -ENODEV; 1215 return -ENODEV;
1215 1216
1216 info->count++; 1217 info->tport.count++;
1217 tty->driver_data = info; 1218 tty->driver_data = info;
1218 info->tty = tty; 1219 info->tty = tty;
1219 1220
@@ -1291,6 +1292,7 @@ rs68328_init(void)
1291 for(i=0;i<NR_PORTS;i++) { 1292 for(i=0;i<NR_PORTS;i++) {
1292 1293
1293 info = &m68k_soft[i]; 1294 info = &m68k_soft[i];
1295 tty_port_init(&info->tport);
1294 info->magic = SERIAL_MAGIC; 1296 info->magic = SERIAL_MAGIC;
1295 info->port = (int) &uart_addr[i]; 1297 info->port = (int) &uart_addr[i];
1296 info->tty = NULL; 1298 info->tty = NULL;
@@ -1299,8 +1301,6 @@ rs68328_init(void)
1299 info->close_delay = 50; 1301 info->close_delay = 50;
1300 info->closing_wait = 3000; 1302 info->closing_wait = 3000;
1301 info->x_char = 0; 1303 info->x_char = 0;
1302 info->count = 0;
1303 info->blocked_open = 0;
1304 init_waitqueue_head(&info->open_wait); 1304 init_waitqueue_head(&info->open_wait);
1305 init_waitqueue_head(&info->close_wait); 1305 init_waitqueue_head(&info->close_wait);
1306 info->line = i; 1306 info->line = i;