etrax: dump to 2.6.29
[openwrt/openwrt.git] / target / linux / etrax / patches-2.6.29 / 600-fix_serial_cris.patch
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
5 @@ -28,12 +28,15 @@
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>
14
15 -#include <asm/io.h>
16 #include <asm/irq.h>
17 #include <asm/dma.h>
18 #include <asm/system.h>
19 -#include <linux/delay.h>
20
21 #include <arch/svinto.h>
22
23 @@ -457,7 +460,6 @@
24
25 #define NR_PORTS (sizeof(rs_table)/sizeof(struct e100_serial))
26
27 -static struct ktermios *serial_termios[NR_PORTS];
28 #ifdef CONFIG_ETRAX_SERIAL_FAST_TIMER
29 static struct fast_timer fast_timers[NR_PORTS];
30 #endif
31 @@ -4221,151 +4223,132 @@
32 return 0;
33 }
34
35 +#ifdef CONFIG_PROC_FS
36 /*
37 * /proc fs routines....
38 */
39
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)
42 {
43 - char stat_buf[30];
44 - int ret;
45 unsigned long tmp;
46
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);
51
52 if (!info->ioport || (info->type == PORT_UNKNOWN)) {
53 - ret += sprintf(buf+ret, "\n");
54 - return ret;
55 + seq_printf(m, "\n");
56 + return;
57 }
58
59 - stat_buf[0] = 0;
60 - stat_buf[1] = 0;
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");
73 -
74 - ret += sprintf(buf+ret, " baud:%d", info->baud);
75 -
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);
82 - if (tmp) {
83 - ret += sprintf(buf+ret, " tx_pend:%lu/%lu",
84 - (unsigned long)tmp,
85 - (unsigned long)SERIAL_XMIT_SIZE);
86 - }
87 -
88 - ret += sprintf(buf+ret, " rx_pend:%lu/%lu",
89 - (unsigned long)info->recv_cnt,
90 - (unsigned long)info->max_recv_cnt);
91 + if (tmp)
92 + seq_printf(m, " tx_pend:%lu/%lu",
93 + (unsigned long)tmp,
94 + (unsigned long)SERIAL_XMIT_SIZE);
95 +
96 + seq_printf(m, " rx_pend:%lu/%lu",
97 + (unsigned long)info->recv_cnt,
98 + (unsigned long)info->max_recv_cnt);
99
100 #if 1
101 if (info->port.tty) {
102 -
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);
113 }
114
115 {
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");
121 }
122
123 #endif
124
125 -
126 -
127 -
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);
132
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);
137
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);
142
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);
147
148 /*
149 * Last thing is the RS-232 status lines
150 */
151 - ret += sprintf(buf+ret, " %s\n", stat_buf+1);
152 - return ret;
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");
165 + seq_puts(m, "\n");
166 }
167
168 -int rs_read_proc(char *page, char **start, off_t off, int count,
169 - int *eof, void *data)
170 +
171 +static int crisv10_proc_show(struct seq_file *m, void *v)
172 {
173 - int i, len = 0, l;
174 - off_t begin = 0;
175 + int i;
176 +
177 + seq_printf(m, "serinfo:1.0 driver:%s\n", serial_version);
178
179 - len += sprintf(page, "serinfo:1.0 driver:%s\n",
180 - serial_version);
181 - for (i = 0; i < NR_PORTS && len < 4000; i++) {
182 + for (i = 0; i < NR_PORTS; i++) {
183 if (!rs_table[i].enabled)
184 continue;
185 - l = line_info(page + len, &rs_table[i]);
186 - len += l;
187 - if (len+begin > off+count)
188 - goto done;
189 - if (len+begin < off) {
190 - begin += len;
191 - len = 0;
192 - }
193 + seq_line_info(m, &rs_table[i]);
194 }
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)
200 - goto done;
201 - if (len+begin < off) {
202 - begin += len;
203 - len = 0;
204 - }
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);
209 }
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);
213 debug_log_pos = 0;
214 #endif
215 + return 0;
216 +}
217
218 - *eof = 1;
219 -done:
220 - if (off >= len+begin)
221 - return 0;
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)
225 +{
226 + return single_open(file, crisv10_proc_show, NULL);
227 }
228
229 +static const struct file_operations crisv10_proc_fops = {
230 + .owner = THIS_MODULE,
231 + .open = crisv10_proc_open,
232 + .read = seq_read,
233 + .llseek = seq_lseek,
234 + .release = single_release,
235 +};
236 +#endif
237 +
238 +
239 /* Finally, routines used to initialize the serial driver. */
240
241 -static void
242 -show_serial_version(void)
243 +static void show_serial_version(void)
244 {
245 printk(KERN_INFO
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" */
250 }
251
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,
262 +#endif
263 };
264
265 static struct class *rs_class;