1 Index: linux-2.6.28.9/drivers/serial/crisv10.c
2 ===================================================================
3 --- linux-2.6.28.9.orig/drivers/serial/crisv10.c 2009-04-10 12:58:18.000000000 +0200
4 +++ linux-2.6.28.9/drivers/serial/crisv10.c 2009-04-10 12:58:22.000000000 +0200
6 #include <linux/mutex.h>
7 #include <linux/bitops.h>
8 #include <linux/device.h>
9 +#include <linux/seq_file.h>
10 +#include <linux/delay.h>
11 +#include <linux/module.h>
12 +#include <linux/uaccess.h>
13 +#include <linux/io.h>
18 #include <asm/system.h>
19 -#include <linux/delay.h>
21 #include <arch/svinto.h>
25 #define NR_PORTS (sizeof(rs_table)/sizeof(struct e100_serial))
27 -static struct ktermios *serial_termios[NR_PORTS];
28 #ifdef CONFIG_ETRAX_SERIAL_FAST_TIMER
29 static struct fast_timer fast_timers[NR_PORTS];
31 @@ -4221,151 +4223,132 @@
35 +#ifdef CONFIG_PROC_FS
37 * /proc fs routines....
40 -static int line_info(char *buf, struct e100_serial *info)
41 +static void seq_line_info(struct seq_file *m, struct e100_serial *info)
47 - ret = sprintf(buf, "%d: uart:E100 port:%lX irq:%d",
48 - info->line, (unsigned long)info->ioport, info->irq);
49 + seq_printf(m, "%d: uart:E100 port:%lX irq:%d",
50 + info->line, (unsigned long)info->ioport, info->irq);
52 if (!info->ioport || (info->type == PORT_UNKNOWN)) {
53 - ret += sprintf(buf+ret, "\n");
55 + seq_printf(m, "\n");
61 - if (!E100_RTS_GET(info))
62 - strcat(stat_buf, "|RTS");
63 - if (!E100_CTS_GET(info))
64 - strcat(stat_buf, "|CTS");
65 - if (!E100_DTR_GET(info))
66 - strcat(stat_buf, "|DTR");
67 - if (!E100_DSR_GET(info))
68 - strcat(stat_buf, "|DSR");
69 - if (!E100_CD_GET(info))
70 - strcat(stat_buf, "|CD");
71 - if (!E100_RI_GET(info))
72 - strcat(stat_buf, "|RI");
74 - ret += sprintf(buf+ret, " baud:%d", info->baud);
76 - ret += sprintf(buf+ret, " tx:%lu rx:%lu",
77 + seq_printf(m, " baud:%d", info->baud);
78 + seq_printf(m, " tx:%lu rx:%lu",
79 (unsigned long)info->icount.tx,
80 (unsigned long)info->icount.rx);
81 tmp = CIRC_CNT(info->xmit.head, info->xmit.tail, SERIAL_XMIT_SIZE);
83 - ret += sprintf(buf+ret, " tx_pend:%lu/%lu",
85 - (unsigned long)SERIAL_XMIT_SIZE);
88 - ret += sprintf(buf+ret, " rx_pend:%lu/%lu",
89 - (unsigned long)info->recv_cnt,
90 - (unsigned long)info->max_recv_cnt);
92 + seq_printf(m, " tx_pend:%lu/%lu",
94 + (unsigned long)SERIAL_XMIT_SIZE);
96 + seq_printf(m, " rx_pend:%lu/%lu",
97 + (unsigned long)info->recv_cnt,
98 + (unsigned long)info->max_recv_cnt);
101 if (info->port.tty) {
103 if (info->port.tty->stopped)
104 - ret += sprintf(buf+ret, " stopped:%i",
105 - (int)info->port.tty->stopped);
106 + seq_printf(m, " stopped:%i",
107 + (int)info->port.tty->stopped);
108 if (info->port.tty->hw_stopped)
109 - ret += sprintf(buf+ret, " hw_stopped:%i",
110 - (int)info->port.tty->hw_stopped);
111 + seq_printf(m, " hw_stopped:%i",
112 + (int)info->port.tty->hw_stopped);
116 unsigned char rstat = info->ioport[REG_STATUS];
117 - if (rstat & IO_MASK(R_SERIAL0_STATUS, xoff_detect) )
118 - ret += sprintf(buf+ret, " xoff_detect:1");
119 + if (rstat & IO_MASK(R_SERIAL0_STATUS, xoff_detect))
120 + seq_printf(m, " xoff_detect:1");
128 if (info->icount.frame)
129 - ret += sprintf(buf+ret, " fe:%lu",
130 - (unsigned long)info->icount.frame);
131 + seq_printf(m, " fe:%lu", (unsigned long)info->icount.frame);
133 if (info->icount.parity)
134 - ret += sprintf(buf+ret, " pe:%lu",
135 - (unsigned long)info->icount.parity);
136 + seq_printf(m, " pe:%lu", (unsigned long)info->icount.parity);
138 if (info->icount.brk)
139 - ret += sprintf(buf+ret, " brk:%lu",
140 - (unsigned long)info->icount.brk);
141 + seq_printf(m, " brk:%lu", (unsigned long)info->icount.brk);
143 if (info->icount.overrun)
144 - ret += sprintf(buf+ret, " oe:%lu",
145 - (unsigned long)info->icount.overrun);
146 + seq_printf(m, " oe:%lu", (unsigned long)info->icount.overrun);
149 * Last thing is the RS-232 status lines
151 - ret += sprintf(buf+ret, " %s\n", stat_buf+1);
153 + if (!E100_RTS_GET(info))
154 + seq_puts(m, "|RTS");
155 + if (!E100_CTS_GET(info))
156 + seq_puts(m, "|CTS");
157 + if (!E100_DTR_GET(info))
158 + seq_puts(m, "|DTR");
159 + if (!E100_DSR_GET(info))
160 + seq_puts(m, "|DSR");
161 + if (!E100_CD_GET(info))
162 + seq_puts(m, "|CD");
163 + if (!E100_RI_GET(info))
164 + seq_puts(m, "|RI");
168 -int rs_read_proc(char *page, char **start, off_t off, int count,
169 - int *eof, void *data)
171 +static int crisv10_proc_show(struct seq_file *m, void *v)
177 + seq_printf(m, "serinfo:1.0 driver:%s\n", serial_version);
179 - len += sprintf(page, "serinfo:1.0 driver:%s\n",
181 - for (i = 0; i < NR_PORTS && len < 4000; i++) {
182 + for (i = 0; i < NR_PORTS; i++) {
183 if (!rs_table[i].enabled)
185 - l = line_info(page + len, &rs_table[i]);
187 - if (len+begin > off+count)
189 - if (len+begin < off) {
193 + seq_line_info(m, &rs_table[i]);
195 #ifdef DEBUG_LOG_INCLUDED
196 for (i = 0; i < debug_log_pos; i++) {
197 - len += sprintf(page + len, "%-4i %lu.%lu ", i, debug_log[i].time, timer_data_to_ns(debug_log[i].timer_data));
198 - len += sprintf(page + len, debug_log[i].string, debug_log[i].value);
199 - if (len+begin > off+count)
201 - if (len+begin < off) {
205 + seq_printf(m, "%-4i %lu.%lu ",
206 + i, debug_log[i].time,
207 + timer_data_to_ns(debug_log[i].timer_data));
208 + seq_printf(m, debug_log[i].string, debug_log[i].value);
210 - len += sprintf(page + len, "debug_log %i/%i %li bytes\n",
211 - i, DEBUG_LOG_SIZE, begin+len);
212 + seq_printf(m, "debug_log %i/%i\n", i, DEBUG_LOG_SIZE);
220 - if (off >= len+begin)
222 - *start = page + (off-begin);
223 - return ((count < begin+len-off) ? count : begin+len-off);
224 +static int crisv10_proc_open(struct inode *inode, struct file *file)
226 + return single_open(file, crisv10_proc_show, NULL);
229 +static const struct file_operations crisv10_proc_fops = {
230 + .owner = THIS_MODULE,
231 + .open = crisv10_proc_open,
233 + .llseek = seq_lseek,
234 + .release = single_release,
239 /* Finally, routines used to initialize the serial driver. */
242 -show_serial_version(void)
243 +static void show_serial_version(void)
246 - "ETRAX 100LX serial-driver %s, (c) 2000-2004 Axis Communications AB\r\n",
247 + "ETRAX 100LX serial-driver %s, "
248 + "(c) 2000-2004 Axis Communications AB\r\n",
249 &serial_version[11]); /* "$Revision: x.yy" */
252 @@ -4389,9 +4372,11 @@
253 .break_ctl = rs_break,
254 .send_xchar = rs_send_xchar,
255 .wait_until_sent = rs_wait_until_sent,
256 - .read_proc = rs_read_proc,
257 .tiocmget = rs_tiocmget,
258 - .tiocmset = rs_tiocmset
259 + .tiocmset = rs_tiocmset,
260 +#ifdef CONFIG_PROC_FS
261 + .proc_fops = &crisv10_proc_fops,
265 static struct class *rs_class;