Gcc 4.3.3 default for etrax
[openwrt/svn-archive/archive.git] / target / linux / etrax / patches-2.6.29 / 600-fix_serial_cris.patch
1 --- a/drivers/serial/crisv10.c
2 +++ b/drivers/serial/crisv10.c
3 @@ -28,12 +28,15 @@ static char *serial_version = "$Revision
4 #include <linux/mutex.h>
5 #include <linux/bitops.h>
6 #include <linux/device.h>
7 +#include <linux/seq_file.h>
8 +#include <linux/delay.h>
9 +#include <linux/module.h>
10 +#include <linux/uaccess.h>
11 +#include <linux/io.h>
12
13 -#include <asm/io.h>
14 #include <asm/irq.h>
15 #include <asm/dma.h>
16 #include <asm/system.h>
17 -#include <linux/delay.h>
18
19 #include <arch/svinto.h>
20
21 @@ -457,7 +460,6 @@ static struct e100_serial rs_table[] = {
22
23 #define NR_PORTS (sizeof(rs_table)/sizeof(struct e100_serial))
24
25 -static struct ktermios *serial_termios[NR_PORTS];
26 #ifdef CONFIG_ETRAX_SERIAL_FAST_TIMER
27 static struct fast_timer fast_timers[NR_PORTS];
28 #endif
29 @@ -4221,151 +4223,132 @@ rs_open(struct tty_struct *tty, struct f
30 return 0;
31 }
32
33 +#ifdef CONFIG_PROC_FS
34 /*
35 * /proc fs routines....
36 */
37
38 -static int line_info(char *buf, struct e100_serial *info)
39 +static void seq_line_info(struct seq_file *m, struct e100_serial *info)
40 {
41 - char stat_buf[30];
42 - int ret;
43 unsigned long tmp;
44
45 - ret = sprintf(buf, "%d: uart:E100 port:%lX irq:%d",
46 - info->line, (unsigned long)info->ioport, info->irq);
47 + seq_printf(m, "%d: uart:E100 port:%lX irq:%d",
48 + info->line, (unsigned long)info->ioport, info->irq);
49
50 if (!info->ioport || (info->type == PORT_UNKNOWN)) {
51 - ret += sprintf(buf+ret, "\n");
52 - return ret;
53 + seq_printf(m, "\n");
54 + return;
55 }
56
57 - stat_buf[0] = 0;
58 - stat_buf[1] = 0;
59 - if (!E100_RTS_GET(info))
60 - strcat(stat_buf, "|RTS");
61 - if (!E100_CTS_GET(info))
62 - strcat(stat_buf, "|CTS");
63 - if (!E100_DTR_GET(info))
64 - strcat(stat_buf, "|DTR");
65 - if (!E100_DSR_GET(info))
66 - strcat(stat_buf, "|DSR");
67 - if (!E100_CD_GET(info))
68 - strcat(stat_buf, "|CD");
69 - if (!E100_RI_GET(info))
70 - strcat(stat_buf, "|RI");
71 -
72 - ret += sprintf(buf+ret, " baud:%d", info->baud);
73 -
74 - ret += sprintf(buf+ret, " tx:%lu rx:%lu",
75 + seq_printf(m, " baud:%d", info->baud);
76 + seq_printf(m, " tx:%lu rx:%lu",
77 (unsigned long)info->icount.tx,
78 (unsigned long)info->icount.rx);
79 tmp = CIRC_CNT(info->xmit.head, info->xmit.tail, SERIAL_XMIT_SIZE);
80 - if (tmp) {
81 - ret += sprintf(buf+ret, " tx_pend:%lu/%lu",
82 - (unsigned long)tmp,
83 - (unsigned long)SERIAL_XMIT_SIZE);
84 - }
85 -
86 - ret += sprintf(buf+ret, " rx_pend:%lu/%lu",
87 - (unsigned long)info->recv_cnt,
88 - (unsigned long)info->max_recv_cnt);
89 + if (tmp)
90 + seq_printf(m, " tx_pend:%lu/%lu",
91 + (unsigned long)tmp,
92 + (unsigned long)SERIAL_XMIT_SIZE);
93 +
94 + seq_printf(m, " rx_pend:%lu/%lu",
95 + (unsigned long)info->recv_cnt,
96 + (unsigned long)info->max_recv_cnt);
97
98 #if 1
99 if (info->port.tty) {
100 -
101 if (info->port.tty->stopped)
102 - ret += sprintf(buf+ret, " stopped:%i",
103 - (int)info->port.tty->stopped);
104 + seq_printf(m, " stopped:%i",
105 + (int)info->port.tty->stopped);
106 if (info->port.tty->hw_stopped)
107 - ret += sprintf(buf+ret, " hw_stopped:%i",
108 - (int)info->port.tty->hw_stopped);
109 + seq_printf(m, " hw_stopped:%i",
110 + (int)info->port.tty->hw_stopped);
111 }
112
113 {
114 unsigned char rstat = info->ioport[REG_STATUS];
115 - if (rstat & IO_MASK(R_SERIAL0_STATUS, xoff_detect) )
116 - ret += sprintf(buf+ret, " xoff_detect:1");
117 + if (rstat & IO_MASK(R_SERIAL0_STATUS, xoff_detect))
118 + seq_printf(m, " xoff_detect:1");
119 }
120
121 #endif
122
123 -
124 -
125 -
126 if (info->icount.frame)
127 - ret += sprintf(buf+ret, " fe:%lu",
128 - (unsigned long)info->icount.frame);
129 + seq_printf(m, " fe:%lu", (unsigned long)info->icount.frame);
130
131 if (info->icount.parity)
132 - ret += sprintf(buf+ret, " pe:%lu",
133 - (unsigned long)info->icount.parity);
134 + seq_printf(m, " pe:%lu", (unsigned long)info->icount.parity);
135
136 if (info->icount.brk)
137 - ret += sprintf(buf+ret, " brk:%lu",
138 - (unsigned long)info->icount.brk);
139 + seq_printf(m, " brk:%lu", (unsigned long)info->icount.brk);
140
141 if (info->icount.overrun)
142 - ret += sprintf(buf+ret, " oe:%lu",
143 - (unsigned long)info->icount.overrun);
144 + seq_printf(m, " oe:%lu", (unsigned long)info->icount.overrun);
145
146 /*
147 * Last thing is the RS-232 status lines
148 */
149 - ret += sprintf(buf+ret, " %s\n", stat_buf+1);
150 - return ret;
151 + if (!E100_RTS_GET(info))
152 + seq_puts(m, "|RTS");
153 + if (!E100_CTS_GET(info))
154 + seq_puts(m, "|CTS");
155 + if (!E100_DTR_GET(info))
156 + seq_puts(m, "|DTR");
157 + if (!E100_DSR_GET(info))
158 + seq_puts(m, "|DSR");
159 + if (!E100_CD_GET(info))
160 + seq_puts(m, "|CD");
161 + if (!E100_RI_GET(info))
162 + seq_puts(m, "|RI");
163 + seq_puts(m, "\n");
164 }
165
166 -int rs_read_proc(char *page, char **start, off_t off, int count,
167 - int *eof, void *data)
168 +
169 +static int crisv10_proc_show(struct seq_file *m, void *v)
170 {
171 - int i, len = 0, l;
172 - off_t begin = 0;
173 + int i;
174 +
175 + seq_printf(m, "serinfo:1.0 driver:%s\n", serial_version);
176
177 - len += sprintf(page, "serinfo:1.0 driver:%s\n",
178 - serial_version);
179 - for (i = 0; i < NR_PORTS && len < 4000; i++) {
180 + for (i = 0; i < NR_PORTS; i++) {
181 if (!rs_table[i].enabled)
182 continue;
183 - l = line_info(page + len, &rs_table[i]);
184 - len += l;
185 - if (len+begin > off+count)
186 - goto done;
187 - if (len+begin < off) {
188 - begin += len;
189 - len = 0;
190 - }
191 + seq_line_info(m, &rs_table[i]);
192 }
193 #ifdef DEBUG_LOG_INCLUDED
194 for (i = 0; i < debug_log_pos; i++) {
195 - len += sprintf(page + len, "%-4i %lu.%lu ", i, debug_log[i].time, timer_data_to_ns(debug_log[i].timer_data));
196 - len += sprintf(page + len, debug_log[i].string, debug_log[i].value);
197 - if (len+begin > off+count)
198 - goto done;
199 - if (len+begin < off) {
200 - begin += len;
201 - len = 0;
202 - }
203 + seq_printf(m, "%-4i %lu.%lu ",
204 + i, debug_log[i].time,
205 + timer_data_to_ns(debug_log[i].timer_data));
206 + seq_printf(m, debug_log[i].string, debug_log[i].value);
207 }
208 - len += sprintf(page + len, "debug_log %i/%i %li bytes\n",
209 - i, DEBUG_LOG_SIZE, begin+len);
210 + seq_printf(m, "debug_log %i/%i\n", i, DEBUG_LOG_SIZE);
211 debug_log_pos = 0;
212 #endif
213 + return 0;
214 +}
215
216 - *eof = 1;
217 -done:
218 - if (off >= len+begin)
219 - return 0;
220 - *start = page + (off-begin);
221 - return ((count < begin+len-off) ? count : begin+len-off);
222 +static int crisv10_proc_open(struct inode *inode, struct file *file)
223 +{
224 + return single_open(file, crisv10_proc_show, NULL);
225 }
226
227 +static const struct file_operations crisv10_proc_fops = {
228 + .owner = THIS_MODULE,
229 + .open = crisv10_proc_open,
230 + .read = seq_read,
231 + .llseek = seq_lseek,
232 + .release = single_release,
233 +};
234 +#endif
235 +
236 +
237 /* Finally, routines used to initialize the serial driver. */
238
239 -static void
240 -show_serial_version(void)
241 +static void show_serial_version(void)
242 {
243 printk(KERN_INFO
244 - "ETRAX 100LX serial-driver %s, (c) 2000-2004 Axis Communications AB\r\n",
245 + "ETRAX 100LX serial-driver %s, "
246 + "(c) 2000-2004 Axis Communications AB\r\n",
247 &serial_version[11]); /* "$Revision: x.yy" */
248 }
249
250 @@ -4389,9 +4372,11 @@ static const struct tty_operations rs_op
251 .break_ctl = rs_break,
252 .send_xchar = rs_send_xchar,
253 .wait_until_sent = rs_wait_until_sent,
254 - .read_proc = rs_read_proc,
255 .tiocmget = rs_tiocmget,
256 - .tiocmset = rs_tiocmset
257 + .tiocmset = rs_tiocmset,
258 +#ifdef CONFIG_PROC_FS
259 + .proc_fops = &crisv10_proc_fops,
260 +#endif
261 };
262
263 static struct class *rs_class;