patch-2.1.127 linux/drivers/sbus/char/sab82532.c

Next file: linux/drivers/sbus/char/su.c
Previous file: linux/drivers/sbus/char/pcikbd.c
Back to the patch index
Back to the overall index

diff -u --recursive --new-file v2.1.126/linux/drivers/sbus/char/sab82532.c linux/drivers/sbus/char/sab82532.c
@@ -1,4 +1,4 @@
-/* $Id: sab82532.c,v 1.23 1998/09/16 03:20:25 ecd Exp $
+/* $Id: sab82532.c,v 1.26 1998/10/25 06:46:41 ecd Exp $
  * sab82532.c: ASYNC Driver for the SIEMENS SAB82532 DUSCC.
  *
  * Copyright (C) 1997  Eddie C. Dost  (ecd@skynet.be)
@@ -88,6 +88,7 @@
 	"V(0x08)", "V(0x09)", "V(0x0a)", "V(0x0b)",
 	"V(0x0c)", "V(0x0d)", "V(0x0e)", "V(0x0f)"
 };
+static char serial_version[16];
 
 /*
  * tmp_buf is used as a temporary buffer by sab82532_write.  We need to
@@ -505,7 +506,7 @@
 #endif
 	}
 	if ((info->regs->r.pvr & info->pvr_dsr_bit) ^ info->dsr) {
-		info->dsr = info->regs->r.pvr & info->pvr_dsr_bit;
+		info->dsr = (info->regs->r.pvr & info->pvr_dsr_bit) ? 0 : 1;
 		info->icount.dsr++;
 		modem_change++;
 #if 0
@@ -786,6 +787,12 @@
 	 */
 	sab82532_init_line(info);
 
+	if (info->tty->termios->c_cflag & CBAUD) {
+		info->regs->rw.mode &= ~(SAB82532_MODE_FRTS);
+		info->regs->rw.mode |= SAB82532_MODE_RTS;
+		info->regs->rw.pvr &= ~(info->pvr_dtr_bit);
+	}
+
 	/*
 	 * Finally, enable interrupts
 	 */
@@ -951,8 +958,9 @@
 	ebrg = ebrg_table[i].n;
 	ebrg |= (ebrg_table[i].m << 6);
 
-	if (ebrg_table[i].baud)
-		info->timeout = (info->xmit_fifo_size * HZ * bits) / ebrg_table[i].baud;
+	info->baud = ebrg_table[i].baud;
+	if (info->baud)
+		info->timeout = (info->xmit_fifo_size * HZ * bits) / info->baud;
 	else
 		info->timeout = 0;
 	info->timeout += HZ / 50;		/* Add .02 seconds of slop */
@@ -1278,7 +1286,9 @@
 {
 	unsigned int result;
 
-	result =  ((info->regs->r.mode & SAB82532_MODE_FRTS) ? 0 : TIOCM_RTS)
+	result =  ((info->regs->r.mode & SAB82532_MODE_RTS) ? 
+		    ((info->regs->r.mode & SAB82532_MODE_FRTS) ? 0 : TIOCM_RTS)
+							    : TIOCM_RTS)
 		| ((info->regs->r.pvr & info->pvr_dtr_bit) ? 0 : TIOCM_DTR)
 		| ((info->regs->r.vstr & SAB82532_VSTR_CD) ? 0 : TIOCM_CAR)
 		| ((info->regs->r.pvr & info->pvr_dsr_bit) ? 0 : TIOCM_DSR)
@@ -1619,8 +1629,7 @@
 	if (info->blocked_open) {
 		if (info->close_delay) {
 			current->state = TASK_INTERRUPTIBLE;
-			current->timeout = jiffies + info->close_delay;
-			schedule();
+			schedule_timeout(info->close_delay);
 		}
 		wake_up_interruptible(&info->open_wait);
 	}
@@ -1664,8 +1673,7 @@
 	while (info->xmit_cnt || !info->all_sent) {
 		current->state = TASK_INTERRUPTIBLE;
 		current->counter = 0;
-		current->timeout = jiffies + char_time;
-		schedule();
+		schedule_timeout(char_time);
 		if (signal_pending(current))
 			break;
 		if (timeout && (orig_jiffies + timeout) < jiffies)
@@ -1952,9 +1960,11 @@
  * /proc fs routines....
  */
 
-static int inline line_info(char *buf, struct tty_struct *tty)
+static __inline__ int
+line_info(char *buf, struct sab82532 *info)
 {
-	struct sab82532 *info = (struct sab82532 *)tty->driver_data;
+	unsigned long flags;
+	char stat_buf[30];
 	int ret;
 
 	ret = sprintf(buf, "%d: uart:SAB82532 ", info->line);
@@ -1972,8 +1982,8 @@
 			ret += sprintf(buf+ret, "V?.? ");
 			break;
 	}
-	ret += sprintf(buf+ret, "port:%lX irq:%d",
-		       (unsigned long)info->regs, info->irq);
+	ret += sprintf(buf+ret, "port:%lX irq:%s",
+		       (unsigned long)info->regs, __irq_itoa(info->irq));
 
 	if (!info->regs) {
 		ret += sprintf(buf+ret, "\n");
@@ -1983,20 +1993,57 @@
 	/*
 	 * Figure out the current RS-232 lines
 	 */
+	stat_buf[0] = 0;
+	stat_buf[1] = 0;
+	save_flags(flags); cli();
+	if (info->regs->r.mode & SAB82532_MODE_RTS) {
+		if (!(info->regs->r.mode & SAB82532_MODE_FRTS))
+			strcat(stat_buf, "|RTS");
+	} else {
+		strcat(stat_buf, "|RTS");
+	}
+	if (info->regs->r.star & SAB82532_STAR_CTS)
+		strcat(stat_buf, "|CTS");
+	if (!(info->regs->r.pvr & info->pvr_dtr_bit))
+		strcat(stat_buf, "|DTR");
+	if (!(info->regs->r.pvr & info->pvr_dsr_bit))
+		strcat(stat_buf, "|DSR");
+	if (!(info->regs->r.vstr & SAB82532_VSTR_CD))
+		strcat(stat_buf, "|CD");
+	restore_flags(flags);
+
+	if (info->baud)
+		ret += sprintf(buf+ret, " baud:%d", info->baud);
+
+	if (info->icount.frame)
+		ret += sprintf(buf+ret, " fe:%d", info->icount.frame);
+
+	if (info->icount.parity)
+		ret += sprintf(buf+ret, " pe:%d", info->icount.parity);
+
+	if (info->icount.brk)
+		ret += sprintf(buf+ret, " brk:%d", info->icount.brk);
 
-	ret += sprintf(buf+ret, "\n");
+	if (info->icount.overrun)
+		ret += sprintf(buf+ret, " oe:%d", info->icount.overrun);
+
+	/*
+	 * Last thing is the RS-232 status lines.
+	 */
+	ret += sprintf(buf+ret, " %s\n", stat_buf + 1);
 	return ret;
 }
 
 int sab82532_read_proc(char *page, char **start, off_t off, int count,
 		       int *eof, void *data)
 {
-	int i, len = 0;
-	off_t	begin = 0;
-
-	len += sprintf(page, "serinfo:1.0 driver:%s\n", "$Revision: 1.23 $");
-	for (i = 0; i < NR_PORTS && len < 4000; i++) {
-		len += line_info(page + len, sab82532_table[i]);
+	struct sab82532 *info = sab82532_chain;
+	off_t begin = 0;
+	int len = 0;
+
+	len += sprintf(page, "serinfo:1.0 driver:%s\n", serial_version);
+	for (info = sab82532_chain; info && len < 4000; info = info->next) {
+		len += line_info(page + len, info);
 		if (len+begin > off+count)
 			goto done;
 		if (len+begin < off) {
@@ -2089,13 +2136,14 @@
 
 __initfunc(static inline void show_serial_version(void))
 {
-	char *revision = "$Revision: 1.23 $";
+	char *revision = "$Revision: 1.26 $";
 	char *version, *p;
 
 	version = strchr(revision, ' ');
-	p = strchr(++version, ' ');
+	strcpy(serial_version, ++version);
+	p = strchr(serial_version, ' ');
 	*p = '\0';
-	printk("SAB82532 serial driver version %s\n", version);
+	printk("SAB82532 serial driver version %s\n", serial_version);
 }
 
 /*
@@ -2456,8 +2504,9 @@
 	ebrg = ebrg_table[i].n;
 	ebrg |= (ebrg_table[i].m << 6);
 
-	if (ebrg_table[i].baud)
-		info->timeout = (info->xmit_fifo_size * HZ * bits) / ebrg_table[i].baud;
+	info->baud = ebrg_table[i].baud;
+	if (info->baud)
+		info->timeout = (info->xmit_fifo_size * HZ * bits) / info->baud;
 	else
 		info->timeout = 0;
 	info->timeout += HZ / 50;		/* Add .02 seconds of slop */
@@ -2490,6 +2539,7 @@
 		info->regs->rw.mode &= ~(SAB82532_MODE_FRTS);
 		info->regs->rw.mode |= SAB82532_MODE_FCTS;
 	}
+	info->regs->rw.pvr &= ~(info->pvr_dtr_bit);
 	info->regs->rw.mode |= SAB82532_MODE_RAC;
 	restore_flags(flags);
 

FUNET's LINUX-ADM group, linux-adm@nic.funet.fi
TCL-scripts by Sam Shen, slshen@lbl.gov