diff options
author | Alan Cox <alan@lxorguk.ukuu.org.uk> | 2005-09-06 18:16:44 -0400 |
---|---|---|
committer | Linus Torvalds <torvalds@g5.osdl.org> | 2005-09-07 19:57:20 -0400 |
commit | f2cf8e25ba4cf4e0881e612125858b4eed563ee4 (patch) | |
tree | 194b4015f7265924fc02da4741150f379e7f2c7a /drivers/char/epca.c | |
parent | 5dd42c262bd742fa3602180bbe5550b4828de8f3 (diff) |
[PATCH] Clean up the old digi support and rescue it
Signed-off-by: Alan Cox <alan@redhat.com>
Signed-off-by: Andrew Morton <akpm@osdl.org>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
Diffstat (limited to 'drivers/char/epca.c')
-rw-r--r-- | drivers/char/epca.c | 1588 |
1 files changed, 459 insertions, 1129 deletions
diff --git a/drivers/char/epca.c b/drivers/char/epca.c index 6025e1866c7e..58d3738a2b7f 100644 --- a/drivers/char/epca.c +++ b/drivers/char/epca.c | |||
@@ -6,6 +6,8 @@ | |||
6 | For technical support please email digiLinux@dgii.com or | 6 | For technical support please email digiLinux@dgii.com or |
7 | call Digi tech support at (612) 912-3456 | 7 | call Digi tech support at (612) 912-3456 |
8 | 8 | ||
9 | ** This driver is no longer supported by Digi ** | ||
10 | |||
9 | Much of this design and code came from epca.c which was | 11 | Much of this design and code came from epca.c which was |
10 | copyright (C) 1994, 1995 Troy De Jongh, and subsquently | 12 | copyright (C) 1994, 1995 Troy De Jongh, and subsquently |
11 | modified by David Nugent, Christoph Lameter, Mike McLagan. | 13 | modified by David Nugent, Christoph Lameter, Mike McLagan. |
@@ -43,31 +45,19 @@ | |||
43 | #include <linux/interrupt.h> | 45 | #include <linux/interrupt.h> |
44 | #include <asm/uaccess.h> | 46 | #include <asm/uaccess.h> |
45 | #include <asm/io.h> | 47 | #include <asm/io.h> |
46 | 48 | #include <linux/spinlock.h> | |
47 | #ifdef CONFIG_PCI | ||
48 | #define ENABLE_PCI | ||
49 | #endif /* CONFIG_PCI */ | ||
50 | |||
51 | #define putUser(arg1, arg2) put_user(arg1, (unsigned long __user *)arg2) | ||
52 | #define getUser(arg1, arg2) get_user(arg1, (unsigned __user *)arg2) | ||
53 | |||
54 | #ifdef ENABLE_PCI | ||
55 | #include <linux/pci.h> | 49 | #include <linux/pci.h> |
56 | #include "digiPCI.h" | 50 | #include "digiPCI.h" |
57 | #endif /* ENABLE_PCI */ | 51 | |
58 | 52 | ||
59 | #include "digi1.h" | 53 | #include "digi1.h" |
60 | #include "digiFep1.h" | 54 | #include "digiFep1.h" |
61 | #include "epca.h" | 55 | #include "epca.h" |
62 | #include "epcaconfig.h" | 56 | #include "epcaconfig.h" |
63 | 57 | ||
64 | #if BITS_PER_LONG != 32 | ||
65 | # error FIXME: this driver only works on 32-bit platforms | ||
66 | #endif | ||
67 | |||
68 | /* ---------------------- Begin defines ------------------------ */ | 58 | /* ---------------------- Begin defines ------------------------ */ |
69 | 59 | ||
70 | #define VERSION "1.3.0.1-LK" | 60 | #define VERSION "1.3.0.1-LK2.6" |
71 | 61 | ||
72 | /* This major needs to be submitted to Linux to join the majors list */ | 62 | /* This major needs to be submitted to Linux to join the majors list */ |
73 | 63 | ||
@@ -81,13 +71,17 @@ | |||
81 | 71 | ||
82 | /* ----------------- Begin global definitions ------------------- */ | 72 | /* ----------------- Begin global definitions ------------------- */ |
83 | 73 | ||
84 | static char mesg[100]; | ||
85 | static int nbdevs, num_cards, liloconfig; | 74 | static int nbdevs, num_cards, liloconfig; |
86 | static int digi_poller_inhibited = 1 ; | 75 | static int digi_poller_inhibited = 1 ; |
87 | 76 | ||
88 | static int setup_error_code; | 77 | static int setup_error_code; |
89 | static int invalid_lilo_config; | 78 | static int invalid_lilo_config; |
90 | 79 | ||
80 | /* The ISA boards do window flipping into the same spaces so its only sane | ||
81 | with a single lock. It's still pretty efficient */ | ||
82 | |||
83 | static spinlock_t epca_lock = SPIN_LOCK_UNLOCKED; | ||
84 | |||
91 | /* ----------------------------------------------------------------------- | 85 | /* ----------------------------------------------------------------------- |
92 | MAXBOARDS is typically 12, but ISA and EISA cards are restricted to | 86 | MAXBOARDS is typically 12, but ISA and EISA cards are restricted to |
93 | 7 below. | 87 | 7 below. |
@@ -129,58 +123,58 @@ static struct timer_list epca_timer; | |||
129 | configured. | 123 | configured. |
130 | ----------------------------------------------------------------------- */ | 124 | ----------------------------------------------------------------------- */ |
131 | 125 | ||
132 | static inline void memwinon(struct board_info *b, unsigned int win); | 126 | static void memwinon(struct board_info *b, unsigned int win); |
133 | static inline void memwinoff(struct board_info *b, unsigned int win); | 127 | static void memwinoff(struct board_info *b, unsigned int win); |
134 | static inline void globalwinon(struct channel *ch); | 128 | static void globalwinon(struct channel *ch); |
135 | static inline void rxwinon(struct channel *ch); | 129 | static void rxwinon(struct channel *ch); |
136 | static inline void txwinon(struct channel *ch); | 130 | static void txwinon(struct channel *ch); |
137 | static inline void memoff(struct channel *ch); | 131 | static void memoff(struct channel *ch); |
138 | static inline void assertgwinon(struct channel *ch); | 132 | static void assertgwinon(struct channel *ch); |
139 | static inline void assertmemoff(struct channel *ch); | 133 | static void assertmemoff(struct channel *ch); |
140 | 134 | ||
141 | /* ---- Begin more 'specific' memory functions for cx_like products --- */ | 135 | /* ---- Begin more 'specific' memory functions for cx_like products --- */ |
142 | 136 | ||
143 | static inline void pcxem_memwinon(struct board_info *b, unsigned int win); | 137 | static void pcxem_memwinon(struct board_info *b, unsigned int win); |
144 | static inline void pcxem_memwinoff(struct board_info *b, unsigned int win); | 138 | static void pcxem_memwinoff(struct board_info *b, unsigned int win); |
145 | static inline void pcxem_globalwinon(struct channel *ch); | 139 | static void pcxem_globalwinon(struct channel *ch); |
146 | static inline void pcxem_rxwinon(struct channel *ch); | 140 | static void pcxem_rxwinon(struct channel *ch); |
147 | static inline void pcxem_txwinon(struct channel *ch); | 141 | static void pcxem_txwinon(struct channel *ch); |
148 | static inline void pcxem_memoff(struct channel *ch); | 142 | static void pcxem_memoff(struct channel *ch); |
149 | 143 | ||
150 | /* ------ Begin more 'specific' memory functions for the pcxe ------- */ | 144 | /* ------ Begin more 'specific' memory functions for the pcxe ------- */ |
151 | 145 | ||
152 | static inline void pcxe_memwinon(struct board_info *b, unsigned int win); | 146 | static void pcxe_memwinon(struct board_info *b, unsigned int win); |
153 | static inline void pcxe_memwinoff(struct board_info *b, unsigned int win); | 147 | static void pcxe_memwinoff(struct board_info *b, unsigned int win); |
154 | static inline void pcxe_globalwinon(struct channel *ch); | 148 | static void pcxe_globalwinon(struct channel *ch); |
155 | static inline void pcxe_rxwinon(struct channel *ch); | 149 | static void pcxe_rxwinon(struct channel *ch); |
156 | static inline void pcxe_txwinon(struct channel *ch); | 150 | static void pcxe_txwinon(struct channel *ch); |
157 | static inline void pcxe_memoff(struct channel *ch); | 151 | static void pcxe_memoff(struct channel *ch); |
158 | 152 | ||
159 | /* ---- Begin more 'specific' memory functions for the pc64xe and pcxi ---- */ | 153 | /* ---- Begin more 'specific' memory functions for the pc64xe and pcxi ---- */ |
160 | /* Note : pc64xe and pcxi share the same windowing routines */ | 154 | /* Note : pc64xe and pcxi share the same windowing routines */ |
161 | 155 | ||
162 | static inline void pcxi_memwinon(struct board_info *b, unsigned int win); | 156 | static void pcxi_memwinon(struct board_info *b, unsigned int win); |
163 | static inline void pcxi_memwinoff(struct board_info *b, unsigned int win); | 157 | static void pcxi_memwinoff(struct board_info *b, unsigned int win); |
164 | static inline void pcxi_globalwinon(struct channel *ch); | 158 | static void pcxi_globalwinon(struct channel *ch); |
165 | static inline void pcxi_rxwinon(struct channel *ch); | 159 | static void pcxi_rxwinon(struct channel *ch); |
166 | static inline void pcxi_txwinon(struct channel *ch); | 160 | static void pcxi_txwinon(struct channel *ch); |
167 | static inline void pcxi_memoff(struct channel *ch); | 161 | static void pcxi_memoff(struct channel *ch); |
168 | 162 | ||
169 | /* - Begin 'specific' do nothing memory functions needed for some cards - */ | 163 | /* - Begin 'specific' do nothing memory functions needed for some cards - */ |
170 | 164 | ||
171 | static inline void dummy_memwinon(struct board_info *b, unsigned int win); | 165 | static void dummy_memwinon(struct board_info *b, unsigned int win); |
172 | static inline void dummy_memwinoff(struct board_info *b, unsigned int win); | 166 | static void dummy_memwinoff(struct board_info *b, unsigned int win); |
173 | static inline void dummy_globalwinon(struct channel *ch); | 167 | static void dummy_globalwinon(struct channel *ch); |
174 | static inline void dummy_rxwinon(struct channel *ch); | 168 | static void dummy_rxwinon(struct channel *ch); |
175 | static inline void dummy_txwinon(struct channel *ch); | 169 | static void dummy_txwinon(struct channel *ch); |
176 | static inline void dummy_memoff(struct channel *ch); | 170 | static void dummy_memoff(struct channel *ch); |
177 | static inline void dummy_assertgwinon(struct channel *ch); | 171 | static void dummy_assertgwinon(struct channel *ch); |
178 | static inline void dummy_assertmemoff(struct channel *ch); | 172 | static void dummy_assertmemoff(struct channel *ch); |
179 | 173 | ||
180 | /* ------------------- Begin declare functions ----------------------- */ | 174 | /* ------------------- Begin declare functions ----------------------- */ |
181 | 175 | ||
182 | static inline struct channel *verifyChannel(register struct tty_struct *); | 176 | static struct channel *verifyChannel(struct tty_struct *); |
183 | static inline void pc_sched_event(struct channel *, int); | 177 | static void pc_sched_event(struct channel *, int); |
184 | static void epca_error(int, char *); | 178 | static void epca_error(int, char *); |
185 | static void pc_close(struct tty_struct *, struct file *); | 179 | static void pc_close(struct tty_struct *, struct file *); |
186 | static void shutdown(struct channel *); | 180 | static void shutdown(struct channel *); |
@@ -215,15 +209,11 @@ static void pc_unthrottle(struct tty_struct *tty); | |||
215 | static void digi_send_break(struct channel *ch, int msec); | 209 | static void digi_send_break(struct channel *ch, int msec); |
216 | static void setup_empty_event(struct tty_struct *tty, struct channel *ch); | 210 | static void setup_empty_event(struct tty_struct *tty, struct channel *ch); |
217 | void epca_setup(char *, int *); | 211 | void epca_setup(char *, int *); |
218 | void console_print(const char *); | ||
219 | 212 | ||
220 | static int get_termio(struct tty_struct *, struct termio __user *); | 213 | static int get_termio(struct tty_struct *, struct termio __user *); |
221 | static int pc_write(struct tty_struct *, const unsigned char *, int); | 214 | static int pc_write(struct tty_struct *, const unsigned char *, int); |
222 | int pc_init(void); | 215 | static int pc_init(void); |
223 | |||
224 | #ifdef ENABLE_PCI | ||
225 | static int init_PCI(void); | 216 | static int init_PCI(void); |
226 | #endif /* ENABLE_PCI */ | ||
227 | 217 | ||
228 | 218 | ||
229 | /* ------------------------------------------------------------------ | 219 | /* ------------------------------------------------------------------ |
@@ -237,41 +227,41 @@ static int init_PCI(void); | |||
237 | making direct calls deserves what they get. | 227 | making direct calls deserves what they get. |
238 | -------------------------------------------------------------------- */ | 228 | -------------------------------------------------------------------- */ |
239 | 229 | ||
240 | static inline void memwinon(struct board_info *b, unsigned int win) | 230 | static void memwinon(struct board_info *b, unsigned int win) |
241 | { | 231 | { |
242 | (b->memwinon)(b, win); | 232 | (b->memwinon)(b, win); |
243 | } | 233 | } |
244 | 234 | ||
245 | static inline void memwinoff(struct board_info *b, unsigned int win) | 235 | static void memwinoff(struct board_info *b, unsigned int win) |
246 | { | 236 | { |
247 | (b->memwinoff)(b, win); | 237 | (b->memwinoff)(b, win); |
248 | } | 238 | } |
249 | 239 | ||
250 | static inline void globalwinon(struct channel *ch) | 240 | static void globalwinon(struct channel *ch) |
251 | { | 241 | { |
252 | (ch->board->globalwinon)(ch); | 242 | (ch->board->globalwinon)(ch); |
253 | } | 243 | } |
254 | 244 | ||
255 | static inline void rxwinon(struct channel *ch) | 245 | static void rxwinon(struct channel *ch) |
256 | { | 246 | { |
257 | (ch->board->rxwinon)(ch); | 247 | (ch->board->rxwinon)(ch); |
258 | } | 248 | } |
259 | 249 | ||
260 | static inline void txwinon(struct channel *ch) | 250 | static void txwinon(struct channel *ch) |
261 | { | 251 | { |
262 | (ch->board->txwinon)(ch); | 252 | (ch->board->txwinon)(ch); |
263 | } | 253 | } |
264 | 254 | ||
265 | static inline void memoff(struct channel *ch) | 255 | static void memoff(struct channel *ch) |
266 | { | 256 | { |
267 | (ch->board->memoff)(ch); | 257 | (ch->board->memoff)(ch); |
268 | } | 258 | } |
269 | static inline void assertgwinon(struct channel *ch) | 259 | static void assertgwinon(struct channel *ch) |
270 | { | 260 | { |
271 | (ch->board->assertgwinon)(ch); | 261 | (ch->board->assertgwinon)(ch); |
272 | } | 262 | } |
273 | 263 | ||
274 | static inline void assertmemoff(struct channel *ch) | 264 | static void assertmemoff(struct channel *ch) |
275 | { | 265 | { |
276 | (ch->board->assertmemoff)(ch); | 266 | (ch->board->assertmemoff)(ch); |
277 | } | 267 | } |
@@ -281,66 +271,66 @@ static inline void assertmemoff(struct channel *ch) | |||
281 | and CX series cards. | 271 | and CX series cards. |
282 | ------------------------------------------------------------ */ | 272 | ------------------------------------------------------------ */ |
283 | 273 | ||
284 | static inline void pcxem_memwinon(struct board_info *b, unsigned int win) | 274 | static void pcxem_memwinon(struct board_info *b, unsigned int win) |
285 | { | 275 | { |
286 | outb_p(FEPWIN|win, (int)b->port + 1); | 276 | outb_p(FEPWIN|win, b->port + 1); |
287 | } | 277 | } |
288 | 278 | ||
289 | static inline void pcxem_memwinoff(struct board_info *b, unsigned int win) | 279 | static void pcxem_memwinoff(struct board_info *b, unsigned int win) |
290 | { | 280 | { |
291 | outb_p(0, (int)b->port + 1); | 281 | outb_p(0, b->port + 1); |
292 | } | 282 | } |
293 | 283 | ||
294 | static inline void pcxem_globalwinon(struct channel *ch) | 284 | static void pcxem_globalwinon(struct channel *ch) |
295 | { | 285 | { |
296 | outb_p( FEPWIN, (int)ch->board->port + 1); | 286 | outb_p( FEPWIN, (int)ch->board->port + 1); |
297 | } | 287 | } |
298 | 288 | ||
299 | static inline void pcxem_rxwinon(struct channel *ch) | 289 | static void pcxem_rxwinon(struct channel *ch) |
300 | { | 290 | { |
301 | outb_p(ch->rxwin, (int)ch->board->port + 1); | 291 | outb_p(ch->rxwin, (int)ch->board->port + 1); |
302 | } | 292 | } |
303 | 293 | ||
304 | static inline void pcxem_txwinon(struct channel *ch) | 294 | static void pcxem_txwinon(struct channel *ch) |
305 | { | 295 | { |
306 | outb_p(ch->txwin, (int)ch->board->port + 1); | 296 | outb_p(ch->txwin, (int)ch->board->port + 1); |
307 | } | 297 | } |
308 | 298 | ||
309 | static inline void pcxem_memoff(struct channel *ch) | 299 | static void pcxem_memoff(struct channel *ch) |
310 | { | 300 | { |
311 | outb_p(0, (int)ch->board->port + 1); | 301 | outb_p(0, (int)ch->board->port + 1); |
312 | } | 302 | } |
313 | 303 | ||
314 | /* ----------------- Begin pcxe memory window stuff ------------------ */ | 304 | /* ----------------- Begin pcxe memory window stuff ------------------ */ |
315 | 305 | ||
316 | static inline void pcxe_memwinon(struct board_info *b, unsigned int win) | 306 | static void pcxe_memwinon(struct board_info *b, unsigned int win) |
317 | { | 307 | { |
318 | outb_p(FEPWIN | win, (int)b->port + 1); | 308 | outb_p(FEPWIN | win, b->port + 1); |
319 | } | 309 | } |
320 | 310 | ||
321 | static inline void pcxe_memwinoff(struct board_info *b, unsigned int win) | 311 | static void pcxe_memwinoff(struct board_info *b, unsigned int win) |
322 | { | 312 | { |
323 | outb_p(inb((int)b->port) & ~FEPMEM, | 313 | outb_p(inb(b->port) & ~FEPMEM, |
324 | (int)b->port + 1); | 314 | b->port + 1); |
325 | outb_p(0, (int)b->port + 1); | 315 | outb_p(0, b->port + 1); |
326 | } | 316 | } |
327 | 317 | ||
328 | static inline void pcxe_globalwinon(struct channel *ch) | 318 | static void pcxe_globalwinon(struct channel *ch) |
329 | { | 319 | { |
330 | outb_p( FEPWIN, (int)ch->board->port + 1); | 320 | outb_p( FEPWIN, (int)ch->board->port + 1); |
331 | } | 321 | } |
332 | 322 | ||
333 | static inline void pcxe_rxwinon(struct channel *ch) | 323 | static void pcxe_rxwinon(struct channel *ch) |
334 | { | 324 | { |
335 | outb_p(ch->rxwin, (int)ch->board->port + 1); | 325 | outb_p(ch->rxwin, (int)ch->board->port + 1); |
336 | } | 326 | } |
337 | 327 | ||
338 | static inline void pcxe_txwinon(struct channel *ch) | 328 | static void pcxe_txwinon(struct channel *ch) |
339 | { | 329 | { |
340 | outb_p(ch->txwin, (int)ch->board->port + 1); | 330 | outb_p(ch->txwin, (int)ch->board->port + 1); |
341 | } | 331 | } |
342 | 332 | ||
343 | static inline void pcxe_memoff(struct channel *ch) | 333 | static void pcxe_memoff(struct channel *ch) |
344 | { | 334 | { |
345 | outb_p(0, (int)ch->board->port); | 335 | outb_p(0, (int)ch->board->port); |
346 | outb_p(0, (int)ch->board->port + 1); | 336 | outb_p(0, (int)ch->board->port + 1); |
@@ -348,44 +338,44 @@ static inline void pcxe_memoff(struct channel *ch) | |||
348 | 338 | ||
349 | /* ------------- Begin pc64xe and pcxi memory window stuff -------------- */ | 339 | /* ------------- Begin pc64xe and pcxi memory window stuff -------------- */ |
350 | 340 | ||
351 | static inline void pcxi_memwinon(struct board_info *b, unsigned int win) | 341 | static void pcxi_memwinon(struct board_info *b, unsigned int win) |
352 | { | 342 | { |
353 | outb_p(inb((int)b->port) | FEPMEM, (int)b->port); | 343 | outb_p(inb(b->port) | FEPMEM, b->port); |
354 | } | 344 | } |
355 | 345 | ||
356 | static inline void pcxi_memwinoff(struct board_info *b, unsigned int win) | 346 | static void pcxi_memwinoff(struct board_info *b, unsigned int win) |
357 | { | 347 | { |
358 | outb_p(inb((int)b->port) & ~FEPMEM, (int)b->port); | 348 | outb_p(inb(b->port) & ~FEPMEM, b->port); |
359 | } | 349 | } |
360 | 350 | ||
361 | static inline void pcxi_globalwinon(struct channel *ch) | 351 | static void pcxi_globalwinon(struct channel *ch) |
362 | { | 352 | { |
363 | outb_p(FEPMEM, (int)ch->board->port); | 353 | outb_p(FEPMEM, ch->board->port); |
364 | } | 354 | } |
365 | 355 | ||
366 | static inline void pcxi_rxwinon(struct channel *ch) | 356 | static void pcxi_rxwinon(struct channel *ch) |
367 | { | 357 | { |
368 | outb_p(FEPMEM, (int)ch->board->port); | 358 | outb_p(FEPMEM, ch->board->port); |
369 | } | 359 | } |
370 | 360 | ||
371 | static inline void pcxi_txwinon(struct channel *ch) | 361 | static void pcxi_txwinon(struct channel *ch) |
372 | { | 362 | { |
373 | outb_p(FEPMEM, (int)ch->board->port); | 363 | outb_p(FEPMEM, ch->board->port); |
374 | } | 364 | } |
375 | 365 | ||
376 | static inline void pcxi_memoff(struct channel *ch) | 366 | static void pcxi_memoff(struct channel *ch) |
377 | { | 367 | { |
378 | outb_p(0, (int)ch->board->port); | 368 | outb_p(0, ch->board->port); |
379 | } | 369 | } |
380 | 370 | ||
381 | static inline void pcxi_assertgwinon(struct channel *ch) | 371 | static void pcxi_assertgwinon(struct channel *ch) |
382 | { | 372 | { |
383 | epcaassert(inb((int)ch->board->port) & FEPMEM, "Global memory off"); | 373 | epcaassert(inb(ch->board->port) & FEPMEM, "Global memory off"); |
384 | } | 374 | } |
385 | 375 | ||
386 | static inline void pcxi_assertmemoff(struct channel *ch) | 376 | static void pcxi_assertmemoff(struct channel *ch) |
387 | { | 377 | { |
388 | epcaassert(!(inb((int)ch->board->port) & FEPMEM), "Memory on"); | 378 | epcaassert(!(inb(ch->board->port) & FEPMEM), "Memory on"); |
389 | } | 379 | } |
390 | 380 | ||
391 | 381 | ||
@@ -398,185 +388,143 @@ static inline void pcxi_assertmemoff(struct channel *ch) | |||
398 | may or may not do anything. | 388 | may or may not do anything. |
399 | ---------------------------------------------------------------------------*/ | 389 | ---------------------------------------------------------------------------*/ |
400 | 390 | ||
401 | static inline void dummy_memwinon(struct board_info *b, unsigned int win) | 391 | static void dummy_memwinon(struct board_info *b, unsigned int win) |
402 | { | 392 | { |
403 | } | 393 | } |
404 | 394 | ||
405 | static inline void dummy_memwinoff(struct board_info *b, unsigned int win) | 395 | static void dummy_memwinoff(struct board_info *b, unsigned int win) |
406 | { | 396 | { |
407 | } | 397 | } |
408 | 398 | ||
409 | static inline void dummy_globalwinon(struct channel *ch) | 399 | static void dummy_globalwinon(struct channel *ch) |
410 | { | 400 | { |
411 | } | 401 | } |
412 | 402 | ||
413 | static inline void dummy_rxwinon(struct channel *ch) | 403 | static void dummy_rxwinon(struct channel *ch) |
414 | { | 404 | { |
415 | } | 405 | } |
416 | 406 | ||
417 | static inline void dummy_txwinon(struct channel *ch) | 407 | static void dummy_txwinon(struct channel *ch) |
418 | { | 408 | { |
419 | } | 409 | } |
420 | 410 | ||
421 | static inline void dummy_memoff(struct channel *ch) | 411 | static void dummy_memoff(struct channel *ch) |
422 | { | 412 | { |
423 | } | 413 | } |
424 | 414 | ||
425 | static inline void dummy_assertgwinon(struct channel *ch) | 415 | static void dummy_assertgwinon(struct channel *ch) |
426 | { | 416 | { |
427 | } | 417 | } |
428 | 418 | ||
429 | static inline void dummy_assertmemoff(struct channel *ch) | 419 | static void dummy_assertmemoff(struct channel *ch) |
430 | { | 420 | { |
431 | } | 421 | } |
432 | 422 | ||
433 | /* ----------------- Begin verifyChannel function ----------------------- */ | 423 | /* ----------------- Begin verifyChannel function ----------------------- */ |
434 | static inline struct channel *verifyChannel(register struct tty_struct *tty) | 424 | static struct channel *verifyChannel(struct tty_struct *tty) |
435 | { /* Begin verifyChannel */ | 425 | { /* Begin verifyChannel */ |
436 | |||
437 | /* -------------------------------------------------------------------- | 426 | /* -------------------------------------------------------------------- |
438 | This routine basically provides a sanity check. It insures that | 427 | This routine basically provides a sanity check. It insures that |
439 | the channel returned is within the proper range of addresses as | 428 | the channel returned is within the proper range of addresses as |
440 | well as properly initialized. If some bogus info gets passed in | 429 | well as properly initialized. If some bogus info gets passed in |
441 | through tty->driver_data this should catch it. | 430 | through tty->driver_data this should catch it. |
442 | --------------------------------------------------------------------- */ | 431 | --------------------------------------------------------------------- */ |
443 | 432 | if (tty) { | |
444 | if (tty) | 433 | struct channel *ch = (struct channel *)tty->driver_data; |
445 | { /* Begin if tty */ | 434 | if ((ch >= &digi_channels[0]) && (ch < &digi_channels[nbdevs])) { |
446 | |||
447 | register struct channel *ch = (struct channel *)tty->driver_data; | ||
448 | |||
449 | if ((ch >= &digi_channels[0]) && (ch < &digi_channels[nbdevs])) | ||
450 | { | ||
451 | if (ch->magic == EPCA_MAGIC) | 435 | if (ch->magic == EPCA_MAGIC) |
452 | return ch; | 436 | return ch; |
453 | } | 437 | } |
454 | 438 | } | |
455 | } /* End if tty */ | ||
456 | |||
457 | /* Else return a NULL for invalid */ | ||
458 | return NULL; | 439 | return NULL; |
459 | 440 | ||
460 | } /* End verifyChannel */ | 441 | } /* End verifyChannel */ |
461 | 442 | ||
462 | /* ------------------ Begin pc_sched_event ------------------------- */ | 443 | /* ------------------ Begin pc_sched_event ------------------------- */ |
463 | 444 | ||
464 | static inline void pc_sched_event(struct channel *ch, int event) | 445 | static void pc_sched_event(struct channel *ch, int event) |
465 | { /* Begin pc_sched_event */ | 446 | { |
466 | |||
467 | |||
468 | /* ---------------------------------------------------------------------- | 447 | /* ---------------------------------------------------------------------- |
469 | We call this to schedule interrupt processing on some event. The | 448 | We call this to schedule interrupt processing on some event. The |
470 | kernel sees our request and calls the related routine in OUR driver. | 449 | kernel sees our request and calls the related routine in OUR driver. |
471 | -------------------------------------------------------------------------*/ | 450 | -------------------------------------------------------------------------*/ |
472 | |||
473 | ch->event |= 1 << event; | 451 | ch->event |= 1 << event; |
474 | schedule_work(&ch->tqueue); | 452 | schedule_work(&ch->tqueue); |
475 | |||
476 | |||
477 | } /* End pc_sched_event */ | 453 | } /* End pc_sched_event */ |
478 | 454 | ||
479 | /* ------------------ Begin epca_error ------------------------- */ | 455 | /* ------------------ Begin epca_error ------------------------- */ |
480 | 456 | ||
481 | static void epca_error(int line, char *msg) | 457 | static void epca_error(int line, char *msg) |
482 | { /* Begin epca_error */ | 458 | { |
483 | |||
484 | printk(KERN_ERR "epca_error (Digi): line = %d %s\n",line,msg); | 459 | printk(KERN_ERR "epca_error (Digi): line = %d %s\n",line,msg); |
485 | return; | 460 | } |
486 | |||
487 | } /* End epca_error */ | ||
488 | 461 | ||
489 | /* ------------------ Begin pc_close ------------------------- */ | 462 | /* ------------------ Begin pc_close ------------------------- */ |
490 | static void pc_close(struct tty_struct * tty, struct file * filp) | 463 | static void pc_close(struct tty_struct * tty, struct file * filp) |
491 | { /* Begin pc_close */ | 464 | { |
492 | |||
493 | struct channel *ch; | 465 | struct channel *ch; |
494 | unsigned long flags; | 466 | unsigned long flags; |
495 | |||
496 | /* --------------------------------------------------------- | 467 | /* --------------------------------------------------------- |
497 | verifyChannel returns the channel from the tty struct | 468 | verifyChannel returns the channel from the tty struct |
498 | if it is valid. This serves as a sanity check. | 469 | if it is valid. This serves as a sanity check. |
499 | ------------------------------------------------------------- */ | 470 | ------------------------------------------------------------- */ |
500 | 471 | if ((ch = verifyChannel(tty)) != NULL) { /* Begin if ch != NULL */ | |
501 | if ((ch = verifyChannel(tty)) != NULL) | 472 | spin_lock_irqsave(&epca_lock, flags); |
502 | { /* Begin if ch != NULL */ | 473 | if (tty_hung_up_p(filp)) { |
503 | 474 | spin_unlock_irqrestore(&epca_lock, flags); | |
504 | save_flags(flags); | ||
505 | cli(); | ||
506 | |||
507 | if (tty_hung_up_p(filp)) | ||
508 | { | ||
509 | restore_flags(flags); | ||
510 | return; | 475 | return; |
511 | } | 476 | } |
512 | |||
513 | /* Check to see if the channel is open more than once */ | 477 | /* Check to see if the channel is open more than once */ |
514 | if (ch->count-- > 1) | 478 | if (ch->count-- > 1) { |
515 | { /* Begin channel is open more than once */ | 479 | /* Begin channel is open more than once */ |
516 | |||
517 | /* ------------------------------------------------------------- | 480 | /* ------------------------------------------------------------- |
518 | Return without doing anything. Someone might still be using | 481 | Return without doing anything. Someone might still be using |
519 | the channel. | 482 | the channel. |
520 | ---------------------------------------------------------------- */ | 483 | ---------------------------------------------------------------- */ |
521 | 484 | spin_unlock_irqrestore(&epca_lock, flags); | |
522 | restore_flags(flags); | ||
523 | return; | 485 | return; |
524 | } /* End channel is open more than once */ | 486 | } /* End channel is open more than once */ |
525 | 487 | ||
526 | /* Port open only once go ahead with shutdown & reset */ | 488 | /* Port open only once go ahead with shutdown & reset */ |
527 | 489 | if (ch->count < 0) | |
528 | if (ch->count < 0) | 490 | BUG(); |
529 | { | ||
530 | ch->count = 0; | ||
531 | } | ||
532 | 491 | ||
533 | /* --------------------------------------------------------------- | 492 | /* --------------------------------------------------------------- |
534 | Let the rest of the driver know the channel is being closed. | 493 | Let the rest of the driver know the channel is being closed. |
535 | This becomes important if an open is attempted before close | 494 | This becomes important if an open is attempted before close |
536 | is finished. | 495 | is finished. |
537 | ------------------------------------------------------------------ */ | 496 | ------------------------------------------------------------------ */ |
538 | |||
539 | ch->asyncflags |= ASYNC_CLOSING; | 497 | ch->asyncflags |= ASYNC_CLOSING; |
540 | |||
541 | tty->closing = 1; | 498 | tty->closing = 1; |
542 | 499 | ||
543 | if (ch->asyncflags & ASYNC_INITIALIZED) | 500 | spin_unlock_irqrestore(&epca_lock, flags); |
544 | { | 501 | |
502 | if (ch->asyncflags & ASYNC_INITIALIZED) { | ||
545 | /* Setup an event to indicate when the transmit buffer empties */ | 503 | /* Setup an event to indicate when the transmit buffer empties */ |
546 | setup_empty_event(tty, ch); | 504 | setup_empty_event(tty, ch); |
547 | tty_wait_until_sent(tty, 3000); /* 30 seconds timeout */ | 505 | tty_wait_until_sent(tty, 3000); /* 30 seconds timeout */ |
548 | } | 506 | } |
549 | |||
550 | if (tty->driver->flush_buffer) | 507 | if (tty->driver->flush_buffer) |
551 | tty->driver->flush_buffer(tty); | 508 | tty->driver->flush_buffer(tty); |
552 | 509 | ||
553 | tty_ldisc_flush(tty); | 510 | tty_ldisc_flush(tty); |
554 | shutdown(ch); | 511 | shutdown(ch); |
512 | |||
513 | spin_lock_irqsave(&epca_lock, flags); | ||
555 | tty->closing = 0; | 514 | tty->closing = 0; |
556 | ch->event = 0; | 515 | ch->event = 0; |
557 | ch->tty = NULL; | 516 | ch->tty = NULL; |
517 | spin_unlock_irqrestore(&epca_lock, flags); | ||
558 | 518 | ||
559 | if (ch->blocked_open) | 519 | if (ch->blocked_open) { /* Begin if blocked_open */ |
560 | { /* Begin if blocked_open */ | ||
561 | |||
562 | if (ch->close_delay) | 520 | if (ch->close_delay) |
563 | { | ||
564 | msleep_interruptible(jiffies_to_msecs(ch->close_delay)); | 521 | msleep_interruptible(jiffies_to_msecs(ch->close_delay)); |
565 | } | ||
566 | |||
567 | wake_up_interruptible(&ch->open_wait); | 522 | wake_up_interruptible(&ch->open_wait); |
568 | |||
569 | } /* End if blocked_open */ | 523 | } /* End if blocked_open */ |
570 | |||
571 | ch->asyncflags &= ~(ASYNC_NORMAL_ACTIVE | ASYNC_INITIALIZED | | 524 | ch->asyncflags &= ~(ASYNC_NORMAL_ACTIVE | ASYNC_INITIALIZED | |
572 | ASYNC_CLOSING); | 525 | ASYNC_CLOSING); |
573 | wake_up_interruptible(&ch->close_wait); | 526 | wake_up_interruptible(&ch->close_wait); |
574 | |||
575 | |||
576 | restore_flags(flags); | ||
577 | |||
578 | } /* End if ch != NULL */ | 527 | } /* End if ch != NULL */ |
579 | |||
580 | } /* End pc_close */ | 528 | } /* End pc_close */ |
581 | 529 | ||
582 | /* ------------------ Begin shutdown ------------------------- */ | 530 | /* ------------------ Begin shutdown ------------------------- */ |
@@ -586,15 +534,14 @@ static void shutdown(struct channel *ch) | |||
586 | 534 | ||
587 | unsigned long flags; | 535 | unsigned long flags; |
588 | struct tty_struct *tty; | 536 | struct tty_struct *tty; |
589 | volatile struct board_chan *bc; | 537 | struct board_chan *bc; |
590 | 538 | ||
591 | if (!(ch->asyncflags & ASYNC_INITIALIZED)) | 539 | if (!(ch->asyncflags & ASYNC_INITIALIZED)) |
592 | return; | 540 | return; |
593 | 541 | ||
594 | save_flags(flags); | 542 | spin_lock_irqsave(&epca_lock, flags); |
595 | cli(); | ||
596 | globalwinon(ch); | ||
597 | 543 | ||
544 | globalwinon(ch); | ||
598 | bc = ch->brdchan; | 545 | bc = ch->brdchan; |
599 | 546 | ||
600 | /* ------------------------------------------------------------------ | 547 | /* ------------------------------------------------------------------ |
@@ -604,20 +551,17 @@ static void shutdown(struct channel *ch) | |||
604 | --------------------------------------------------------------------- */ | 551 | --------------------------------------------------------------------- */ |
605 | 552 | ||
606 | if (bc) | 553 | if (bc) |
607 | bc->idata = 0; | 554 | writeb(0, &bc->idata); |
608 | |||
609 | tty = ch->tty; | 555 | tty = ch->tty; |
610 | 556 | ||
611 | /* ---------------------------------------------------------------- | 557 | /* ---------------------------------------------------------------- |
612 | If we're a modem control device and HUPCL is on, drop RTS & DTR. | 558 | If we're a modem control device and HUPCL is on, drop RTS & DTR. |
613 | ------------------------------------------------------------------ */ | 559 | ------------------------------------------------------------------ */ |
614 | 560 | ||
615 | if (tty->termios->c_cflag & HUPCL) | 561 | if (tty->termios->c_cflag & HUPCL) { |
616 | { | ||
617 | ch->omodem &= ~(ch->m_rts | ch->m_dtr); | 562 | ch->omodem &= ~(ch->m_rts | ch->m_dtr); |
618 | fepcmd(ch, SETMODEM, 0, ch->m_dtr | ch->m_rts, 10, 1); | 563 | fepcmd(ch, SETMODEM, 0, ch->m_dtr | ch->m_rts, 10, 1); |
619 | } | 564 | } |
620 | |||
621 | memoff(ch); | 565 | memoff(ch); |
622 | 566 | ||
623 | /* ------------------------------------------------------------------ | 567 | /* ------------------------------------------------------------------ |
@@ -628,7 +572,7 @@ static void shutdown(struct channel *ch) | |||
628 | /* Prevent future Digi programmed interrupts from coming active */ | 572 | /* Prevent future Digi programmed interrupts from coming active */ |
629 | 573 | ||
630 | ch->asyncflags &= ~ASYNC_INITIALIZED; | 574 | ch->asyncflags &= ~ASYNC_INITIALIZED; |
631 | restore_flags(flags); | 575 | spin_unlock_irqrestore(&epca_lock, flags); |
632 | 576 | ||
633 | } /* End shutdown */ | 577 | } /* End shutdown */ |
634 | 578 | ||
@@ -636,7 +580,6 @@ static void shutdown(struct channel *ch) | |||
636 | 580 | ||
637 | static void pc_hangup(struct tty_struct *tty) | 581 | static void pc_hangup(struct tty_struct *tty) |
638 | { /* Begin pc_hangup */ | 582 | { /* Begin pc_hangup */ |
639 | |||
640 | struct channel *ch; | 583 | struct channel *ch; |
641 | 584 | ||
642 | /* --------------------------------------------------------- | 585 | /* --------------------------------------------------------- |
@@ -644,25 +587,21 @@ static void pc_hangup(struct tty_struct *tty) | |||
644 | if it is valid. This serves as a sanity check. | 587 | if it is valid. This serves as a sanity check. |
645 | ------------------------------------------------------------- */ | 588 | ------------------------------------------------------------- */ |
646 | 589 | ||
647 | if ((ch = verifyChannel(tty)) != NULL) | 590 | if ((ch = verifyChannel(tty)) != NULL) { /* Begin if ch != NULL */ |
648 | { /* Begin if ch != NULL */ | ||
649 | |||
650 | unsigned long flags; | 591 | unsigned long flags; |
651 | 592 | ||
652 | save_flags(flags); | ||
653 | cli(); | ||
654 | if (tty->driver->flush_buffer) | 593 | if (tty->driver->flush_buffer) |
655 | tty->driver->flush_buffer(tty); | 594 | tty->driver->flush_buffer(tty); |
656 | tty_ldisc_flush(tty); | 595 | tty_ldisc_flush(tty); |
657 | shutdown(ch); | 596 | shutdown(ch); |
658 | 597 | ||
598 | spin_lock_irqsave(&epca_lock, flags); | ||
659 | ch->tty = NULL; | 599 | ch->tty = NULL; |
660 | ch->event = 0; | 600 | ch->event = 0; |
661 | ch->count = 0; | 601 | ch->count = 0; |
662 | restore_flags(flags); | ||
663 | ch->asyncflags &= ~(ASYNC_NORMAL_ACTIVE | ASYNC_INITIALIZED); | 602 | ch->asyncflags &= ~(ASYNC_NORMAL_ACTIVE | ASYNC_INITIALIZED); |
603 | spin_unlock_irqrestore(&epca_lock, flags); | ||
664 | wake_up_interruptible(&ch->open_wait); | 604 | wake_up_interruptible(&ch->open_wait); |
665 | |||
666 | } /* End if ch != NULL */ | 605 | } /* End if ch != NULL */ |
667 | 606 | ||
668 | } /* End pc_hangup */ | 607 | } /* End pc_hangup */ |
@@ -672,18 +611,14 @@ static void pc_hangup(struct tty_struct *tty) | |||
672 | static int pc_write(struct tty_struct * tty, | 611 | static int pc_write(struct tty_struct * tty, |
673 | const unsigned char *buf, int bytesAvailable) | 612 | const unsigned char *buf, int bytesAvailable) |
674 | { /* Begin pc_write */ | 613 | { /* Begin pc_write */ |
675 | 614 | unsigned int head, tail; | |
676 | register unsigned int head, tail; | 615 | int dataLen; |
677 | register int dataLen; | 616 | int size; |
678 | register int size; | 617 | int amountCopied; |
679 | register int amountCopied; | ||
680 | |||
681 | |||
682 | struct channel *ch; | 618 | struct channel *ch; |
683 | unsigned long flags; | 619 | unsigned long flags; |
684 | int remain; | 620 | int remain; |
685 | volatile struct board_chan *bc; | 621 | struct board_chan *bc; |
686 | |||
687 | 622 | ||
688 | /* ---------------------------------------------------------------- | 623 | /* ---------------------------------------------------------------- |
689 | pc_write is primarily called directly by the kernel routine | 624 | pc_write is primarily called directly by the kernel routine |
@@ -706,24 +641,20 @@ static int pc_write(struct tty_struct * tty, | |||
706 | 641 | ||
707 | bc = ch->brdchan; | 642 | bc = ch->brdchan; |
708 | size = ch->txbufsize; | 643 | size = ch->txbufsize; |
709 | |||
710 | amountCopied = 0; | 644 | amountCopied = 0; |
711 | save_flags(flags); | ||
712 | cli(); | ||
713 | 645 | ||
646 | spin_lock_irqsave(&epca_lock, flags); | ||
714 | globalwinon(ch); | 647 | globalwinon(ch); |
715 | 648 | ||
716 | head = bc->tin & (size - 1); | 649 | head = readw(&bc->tin) & (size - 1); |
717 | tail = bc->tout; | 650 | tail = readw(&bc->tout); |
718 | 651 | ||
719 | if (tail != bc->tout) | 652 | if (tail != readw(&bc->tout)) |
720 | tail = bc->tout; | 653 | tail = readw(&bc->tout); |
721 | tail &= (size - 1); | 654 | tail &= (size - 1); |
722 | 655 | ||
723 | /* If head >= tail, head has not wrapped around. */ | 656 | /* If head >= tail, head has not wrapped around. */ |
724 | if (head >= tail) | 657 | if (head >= tail) { /* Begin head has not wrapped */ |
725 | { /* Begin head has not wrapped */ | ||
726 | |||
727 | /* --------------------------------------------------------------- | 658 | /* --------------------------------------------------------------- |
728 | remain (much like dataLen above) represents the total amount of | 659 | remain (much like dataLen above) represents the total amount of |
729 | space available on the card for data. Here dataLen represents | 660 | space available on the card for data. Here dataLen represents |
@@ -731,26 +662,19 @@ static int pc_write(struct tty_struct * tty, | |||
731 | buffer. This is important because a memcpy cannot be told to | 662 | buffer. This is important because a memcpy cannot be told to |
732 | automatically wrap around when it hits the buffer end. | 663 | automatically wrap around when it hits the buffer end. |
733 | ------------------------------------------------------------------ */ | 664 | ------------------------------------------------------------------ */ |
734 | |||
735 | dataLen = size - head; | 665 | dataLen = size - head; |
736 | remain = size - (head - tail) - 1; | 666 | remain = size - (head - tail) - 1; |
737 | 667 | } else { /* Begin head has wrapped around */ | |
738 | } /* End head has not wrapped */ | ||
739 | else | ||
740 | { /* Begin head has wrapped around */ | ||
741 | 668 | ||
742 | remain = tail - head - 1; | 669 | remain = tail - head - 1; |
743 | dataLen = remain; | 670 | dataLen = remain; |
744 | 671 | ||
745 | } /* End head has wrapped around */ | 672 | } /* End head has wrapped around */ |
746 | |||
747 | /* ------------------------------------------------------------------- | 673 | /* ------------------------------------------------------------------- |
748 | Check the space on the card. If we have more data than | 674 | Check the space on the card. If we have more data than |
749 | space; reduce the amount of data to fit the space. | 675 | space; reduce the amount of data to fit the space. |
750 | ---------------------------------------------------------------------- */ | 676 | ---------------------------------------------------------------------- */ |
751 | |||
752 | bytesAvailable = min(remain, bytesAvailable); | 677 | bytesAvailable = min(remain, bytesAvailable); |
753 | |||
754 | txwinon(ch); | 678 | txwinon(ch); |
755 | while (bytesAvailable > 0) | 679 | while (bytesAvailable > 0) |
756 | { /* Begin while there is data to copy onto card */ | 680 | { /* Begin while there is data to copy onto card */ |
@@ -767,26 +691,21 @@ static int pc_write(struct tty_struct * tty, | |||
767 | amountCopied += dataLen; | 691 | amountCopied += dataLen; |
768 | bytesAvailable -= dataLen; | 692 | bytesAvailable -= dataLen; |
769 | 693 | ||
770 | if (head >= size) | 694 | if (head >= size) { |
771 | { | ||
772 | head = 0; | 695 | head = 0; |
773 | dataLen = tail; | 696 | dataLen = tail; |
774 | } | 697 | } |
775 | |||
776 | } /* End while there is data to copy onto card */ | 698 | } /* End while there is data to copy onto card */ |
777 | |||
778 | ch->statusflags |= TXBUSY; | 699 | ch->statusflags |= TXBUSY; |
779 | globalwinon(ch); | 700 | globalwinon(ch); |
780 | bc->tin = head; | 701 | writew(head, &bc->tin); |
781 | 702 | ||
782 | if ((ch->statusflags & LOWWAIT) == 0) | 703 | if ((ch->statusflags & LOWWAIT) == 0) { |
783 | { | ||
784 | ch->statusflags |= LOWWAIT; | 704 | ch->statusflags |= LOWWAIT; |
785 | bc->ilow = 1; | 705 | writeb(1, &bc->ilow); |
786 | } | 706 | } |
787 | memoff(ch); | 707 | memoff(ch); |
788 | restore_flags(flags); | 708 | spin_unlock_irqrestore(&epca_lock, flags); |
789 | |||
790 | return(amountCopied); | 709 | return(amountCopied); |
791 | 710 | ||
792 | } /* End pc_write */ | 711 | } /* End pc_write */ |
@@ -795,11 +714,7 @@ static int pc_write(struct tty_struct * tty, | |||
795 | 714 | ||
796 | static void pc_put_char(struct tty_struct *tty, unsigned char c) | 715 | static void pc_put_char(struct tty_struct *tty, unsigned char c) |
797 | { /* Begin pc_put_char */ | 716 | { /* Begin pc_put_char */ |
798 | |||
799 | |||
800 | pc_write(tty, &c, 1); | 717 | pc_write(tty, &c, 1); |
801 | return; | ||
802 | |||
803 | } /* End pc_put_char */ | 718 | } /* End pc_put_char */ |
804 | 719 | ||
805 | /* ------------------ Begin pc_write_room ------------------------- */ | 720 | /* ------------------ Begin pc_write_room ------------------------- */ |
@@ -811,7 +726,7 @@ static int pc_write_room(struct tty_struct *tty) | |||
811 | struct channel *ch; | 726 | struct channel *ch; |
812 | unsigned long flags; | 727 | unsigned long flags; |
813 | unsigned int head, tail; | 728 | unsigned int head, tail; |
814 | volatile struct board_chan *bc; | 729 | struct board_chan *bc; |
815 | 730 | ||
816 | remain = 0; | 731 | remain = 0; |
817 | 732 | ||
@@ -820,33 +735,29 @@ static int pc_write_room(struct tty_struct *tty) | |||
820 | if it is valid. This serves as a sanity check. | 735 | if it is valid. This serves as a sanity check. |
821 | ------------------------------------------------------------- */ | 736 | ------------------------------------------------------------- */ |
822 | 737 | ||
823 | if ((ch = verifyChannel(tty)) != NULL) | 738 | if ((ch = verifyChannel(tty)) != NULL) { |
824 | { | 739 | spin_lock_irqsave(&epca_lock, flags); |
825 | save_flags(flags); | ||
826 | cli(); | ||
827 | globalwinon(ch); | 740 | globalwinon(ch); |
828 | 741 | ||
829 | bc = ch->brdchan; | 742 | bc = ch->brdchan; |
830 | head = bc->tin & (ch->txbufsize - 1); | 743 | head = readw(&bc->tin) & (ch->txbufsize - 1); |
831 | tail = bc->tout; | 744 | tail = readw(&bc->tout); |
832 | 745 | ||
833 | if (tail != bc->tout) | 746 | if (tail != readw(&bc->tout)) |
834 | tail = bc->tout; | 747 | tail = readw(&bc->tout); |
835 | /* Wrap tail if necessary */ | 748 | /* Wrap tail if necessary */ |
836 | tail &= (ch->txbufsize - 1); | 749 | tail &= (ch->txbufsize - 1); |
837 | 750 | ||
838 | if ((remain = tail - head - 1) < 0 ) | 751 | if ((remain = tail - head - 1) < 0 ) |
839 | remain += ch->txbufsize; | 752 | remain += ch->txbufsize; |
840 | 753 | ||
841 | if (remain && (ch->statusflags & LOWWAIT) == 0) | 754 | if (remain && (ch->statusflags & LOWWAIT) == 0) { |
842 | { | ||
843 | ch->statusflags |= LOWWAIT; | 755 | ch->statusflags |= LOWWAIT; |
844 | bc->ilow = 1; | 756 | writeb(1, &bc->ilow); |
845 | } | 757 | } |
846 | memoff(ch); | 758 | memoff(ch); |
847 | restore_flags(flags); | 759 | spin_unlock_irqrestore(&epca_lock, flags); |
848 | } | 760 | } |
849 | |||
850 | /* Return how much room is left on card */ | 761 | /* Return how much room is left on card */ |
851 | return remain; | 762 | return remain; |
852 | 763 | ||
@@ -862,8 +773,7 @@ static int pc_chars_in_buffer(struct tty_struct *tty) | |||
862 | int remain; | 773 | int remain; |
863 | unsigned long flags; | 774 | unsigned long flags; |
864 | struct channel *ch; | 775 | struct channel *ch; |
865 | volatile struct board_chan *bc; | 776 | struct board_chan *bc; |
866 | |||
867 | 777 | ||
868 | /* --------------------------------------------------------- | 778 | /* --------------------------------------------------------- |
869 | verifyChannel returns the channel from the tty struct | 779 | verifyChannel returns the channel from the tty struct |
@@ -873,34 +783,27 @@ static int pc_chars_in_buffer(struct tty_struct *tty) | |||
873 | if ((ch = verifyChannel(tty)) == NULL) | 783 | if ((ch = verifyChannel(tty)) == NULL) |
874 | return(0); | 784 | return(0); |
875 | 785 | ||
876 | save_flags(flags); | 786 | spin_lock_irqsave(&epca_lock, flags); |
877 | cli(); | ||
878 | globalwinon(ch); | 787 | globalwinon(ch); |
879 | 788 | ||
880 | bc = ch->brdchan; | 789 | bc = ch->brdchan; |
881 | tail = bc->tout; | 790 | tail = readw(&bc->tout); |
882 | head = bc->tin; | 791 | head = readw(&bc->tin); |
883 | ctail = ch->mailbox->cout; | 792 | ctail = readw(&ch->mailbox->cout); |
884 | 793 | ||
885 | if (tail == head && ch->mailbox->cin == ctail && bc->tbusy == 0) | 794 | if (tail == head && readw(&ch->mailbox->cin) == ctail && readb(&bc->tbusy) == 0) |
886 | chars = 0; | 795 | chars = 0; |
887 | else | 796 | else { /* Begin if some space on the card has been used */ |
888 | { /* Begin if some space on the card has been used */ | 797 | head = readw(&bc->tin) & (ch->txbufsize - 1); |
889 | |||
890 | head = bc->tin & (ch->txbufsize - 1); | ||
891 | tail &= (ch->txbufsize - 1); | 798 | tail &= (ch->txbufsize - 1); |
892 | |||
893 | /* -------------------------------------------------------------- | 799 | /* -------------------------------------------------------------- |
894 | The logic here is basically opposite of the above pc_write_room | 800 | The logic here is basically opposite of the above pc_write_room |
895 | here we are finding the amount of bytes in the buffer filled. | 801 | here we are finding the amount of bytes in the buffer filled. |
896 | Not the amount of bytes empty. | 802 | Not the amount of bytes empty. |
897 | ------------------------------------------------------------------- */ | 803 | ------------------------------------------------------------------- */ |
898 | |||
899 | if ((remain = tail - head - 1) < 0 ) | 804 | if ((remain = tail - head - 1) < 0 ) |
900 | remain += ch->txbufsize; | 805 | remain += ch->txbufsize; |
901 | |||
902 | chars = (int)(ch->txbufsize - remain); | 806 | chars = (int)(ch->txbufsize - remain); |
903 | |||
904 | /* ------------------------------------------------------------- | 807 | /* ------------------------------------------------------------- |
905 | Make it possible to wakeup anything waiting for output | 808 | Make it possible to wakeup anything waiting for output |
906 | in tty_ioctl.c, etc. | 809 | in tty_ioctl.c, etc. |
@@ -908,15 +811,12 @@ static int pc_chars_in_buffer(struct tty_struct *tty) | |||
908 | If not already set. Setup an event to indicate when the | 811 | If not already set. Setup an event to indicate when the |
909 | transmit buffer empties | 812 | transmit buffer empties |
910 | ----------------------------------------------------------------- */ | 813 | ----------------------------------------------------------------- */ |
911 | |||
912 | if (!(ch->statusflags & EMPTYWAIT)) | 814 | if (!(ch->statusflags & EMPTYWAIT)) |
913 | setup_empty_event(tty,ch); | 815 | setup_empty_event(tty,ch); |
914 | 816 | ||
915 | } /* End if some space on the card has been used */ | 817 | } /* End if some space on the card has been used */ |
916 | |||
917 | memoff(ch); | 818 | memoff(ch); |
918 | restore_flags(flags); | 819 | spin_unlock_irqrestore(&epca_lock, flags); |
919 | |||
920 | /* Return number of characters residing on card. */ | 820 | /* Return number of characters residing on card. */ |
921 | return(chars); | 821 | return(chars); |
922 | 822 | ||
@@ -930,67 +830,46 @@ static void pc_flush_buffer(struct tty_struct *tty) | |||
930 | unsigned int tail; | 830 | unsigned int tail; |
931 | unsigned long flags; | 831 | unsigned long flags; |
932 | struct channel *ch; | 832 | struct channel *ch; |
933 | volatile struct board_chan *bc; | 833 | struct board_chan *bc; |
934 | |||
935 | |||
936 | /* --------------------------------------------------------- | 834 | /* --------------------------------------------------------- |
937 | verifyChannel returns the channel from the tty struct | 835 | verifyChannel returns the channel from the tty struct |
938 | if it is valid. This serves as a sanity check. | 836 | if it is valid. This serves as a sanity check. |
939 | ------------------------------------------------------------- */ | 837 | ------------------------------------------------------------- */ |
940 | |||
941 | if ((ch = verifyChannel(tty)) == NULL) | 838 | if ((ch = verifyChannel(tty)) == NULL) |
942 | return; | 839 | return; |
943 | 840 | ||
944 | save_flags(flags); | 841 | spin_lock_irqsave(&epca_lock, flags); |
945 | cli(); | ||
946 | |||
947 | globalwinon(ch); | 842 | globalwinon(ch); |
948 | |||
949 | bc = ch->brdchan; | 843 | bc = ch->brdchan; |
950 | tail = bc->tout; | 844 | tail = readw(&bc->tout); |
951 | |||
952 | /* Have FEP move tout pointer; effectively flushing transmit buffer */ | 845 | /* Have FEP move tout pointer; effectively flushing transmit buffer */ |
953 | |||
954 | fepcmd(ch, STOUT, (unsigned) tail, 0, 0, 0); | 846 | fepcmd(ch, STOUT, (unsigned) tail, 0, 0, 0); |
955 | |||
956 | memoff(ch); | 847 | memoff(ch); |
957 | restore_flags(flags); | 848 | spin_unlock_irqrestore(&epca_lock, flags); |
958 | |||
959 | wake_up_interruptible(&tty->write_wait); | 849 | wake_up_interruptible(&tty->write_wait); |
960 | tty_wakeup(tty); | 850 | tty_wakeup(tty); |
961 | |||
962 | } /* End pc_flush_buffer */ | 851 | } /* End pc_flush_buffer */ |
963 | 852 | ||
964 | /* ------------------ Begin pc_flush_chars ---------------------- */ | 853 | /* ------------------ Begin pc_flush_chars ---------------------- */ |
965 | 854 | ||
966 | static void pc_flush_chars(struct tty_struct *tty) | 855 | static void pc_flush_chars(struct tty_struct *tty) |
967 | { /* Begin pc_flush_chars */ | 856 | { /* Begin pc_flush_chars */ |
968 | |||
969 | struct channel * ch; | 857 | struct channel * ch; |
970 | |||
971 | /* --------------------------------------------------------- | 858 | /* --------------------------------------------------------- |
972 | verifyChannel returns the channel from the tty struct | 859 | verifyChannel returns the channel from the tty struct |
973 | if it is valid. This serves as a sanity check. | 860 | if it is valid. This serves as a sanity check. |
974 | ------------------------------------------------------------- */ | 861 | ------------------------------------------------------------- */ |
975 | 862 | if ((ch = verifyChannel(tty)) != NULL) { | |
976 | if ((ch = verifyChannel(tty)) != NULL) | ||
977 | { | ||
978 | unsigned long flags; | 863 | unsigned long flags; |
979 | 864 | spin_lock_irqsave(&epca_lock, flags); | |
980 | save_flags(flags); | ||
981 | cli(); | ||
982 | |||
983 | /* ---------------------------------------------------------------- | 865 | /* ---------------------------------------------------------------- |
984 | If not already set and the transmitter is busy setup an event | 866 | If not already set and the transmitter is busy setup an event |
985 | to indicate when the transmit empties. | 867 | to indicate when the transmit empties. |
986 | ------------------------------------------------------------------- */ | 868 | ------------------------------------------------------------------- */ |
987 | |||
988 | if ((ch->statusflags & TXBUSY) && !(ch->statusflags & EMPTYWAIT)) | 869 | if ((ch->statusflags & TXBUSY) && !(ch->statusflags & EMPTYWAIT)) |
989 | setup_empty_event(tty,ch); | 870 | setup_empty_event(tty,ch); |
990 | 871 | spin_unlock_irqrestore(&epca_lock, flags); | |
991 | restore_flags(flags); | ||
992 | } | 872 | } |
993 | |||
994 | } /* End pc_flush_chars */ | 873 | } /* End pc_flush_chars */ |
995 | 874 | ||
996 | /* ------------------ Begin block_til_ready ---------------------- */ | 875 | /* ------------------ Begin block_til_ready ---------------------- */ |
@@ -998,14 +877,11 @@ static void pc_flush_chars(struct tty_struct *tty) | |||
998 | static int block_til_ready(struct tty_struct *tty, | 877 | static int block_til_ready(struct tty_struct *tty, |
999 | struct file *filp, struct channel *ch) | 878 | struct file *filp, struct channel *ch) |
1000 | { /* Begin block_til_ready */ | 879 | { /* Begin block_til_ready */ |
1001 | |||
1002 | DECLARE_WAITQUEUE(wait,current); | 880 | DECLARE_WAITQUEUE(wait,current); |
1003 | int retval, do_clocal = 0; | 881 | int retval, do_clocal = 0; |
1004 | unsigned long flags; | 882 | unsigned long flags; |
1005 | 883 | ||
1006 | 884 | if (tty_hung_up_p(filp)) { | |
1007 | if (tty_hung_up_p(filp)) | ||
1008 | { | ||
1009 | if (ch->asyncflags & ASYNC_HUP_NOTIFY) | 885 | if (ch->asyncflags & ASYNC_HUP_NOTIFY) |
1010 | retval = -EAGAIN; | 886 | retval = -EAGAIN; |
1011 | else | 887 | else |
@@ -1017,8 +893,7 @@ static int block_til_ready(struct tty_struct *tty, | |||
1017 | If the device is in the middle of being closed, then block | 893 | If the device is in the middle of being closed, then block |
1018 | until it's done, and then try again. | 894 | until it's done, and then try again. |
1019 | -------------------------------------------------------------------- */ | 895 | -------------------------------------------------------------------- */ |
1020 | if (ch->asyncflags & ASYNC_CLOSING) | 896 | if (ch->asyncflags & ASYNC_CLOSING) { |
1021 | { | ||
1022 | interruptible_sleep_on(&ch->close_wait); | 897 | interruptible_sleep_on(&ch->close_wait); |
1023 | 898 | ||
1024 | if (ch->asyncflags & ASYNC_HUP_NOTIFY) | 899 | if (ch->asyncflags & ASYNC_HUP_NOTIFY) |
@@ -1027,43 +902,29 @@ static int block_til_ready(struct tty_struct *tty, | |||
1027 | return -ERESTARTSYS; | 902 | return -ERESTARTSYS; |
1028 | } | 903 | } |
1029 | 904 | ||
1030 | if (filp->f_flags & O_NONBLOCK) | 905 | if (filp->f_flags & O_NONBLOCK) { |
1031 | { | ||
1032 | /* ----------------------------------------------------------------- | 906 | /* ----------------------------------------------------------------- |
1033 | If non-blocking mode is set, then make the check up front | 907 | If non-blocking mode is set, then make the check up front |
1034 | and then exit. | 908 | and then exit. |
1035 | -------------------------------------------------------------------- */ | 909 | -------------------------------------------------------------------- */ |
1036 | |||
1037 | ch->asyncflags |= ASYNC_NORMAL_ACTIVE; | 910 | ch->asyncflags |= ASYNC_NORMAL_ACTIVE; |
1038 | |||
1039 | return 0; | 911 | return 0; |
1040 | } | 912 | } |
1041 | |||
1042 | |||
1043 | if (tty->termios->c_cflag & CLOCAL) | 913 | if (tty->termios->c_cflag & CLOCAL) |
1044 | do_clocal = 1; | 914 | do_clocal = 1; |
1045 | 915 | /* Block waiting for the carrier detect and the line to become free */ | |
1046 | /* Block waiting for the carrier detect and the line to become free */ | ||
1047 | 916 | ||
1048 | retval = 0; | 917 | retval = 0; |
1049 | add_wait_queue(&ch->open_wait, &wait); | 918 | add_wait_queue(&ch->open_wait, &wait); |
1050 | save_flags(flags); | ||
1051 | cli(); | ||
1052 | |||
1053 | 919 | ||
920 | spin_lock_irqsave(&epca_lock, flags); | ||
1054 | /* We dec count so that pc_close will know when to free things */ | 921 | /* We dec count so that pc_close will know when to free things */ |
1055 | if (!tty_hung_up_p(filp)) | 922 | if (!tty_hung_up_p(filp)) |
1056 | ch->count--; | 923 | ch->count--; |
1057 | |||
1058 | restore_flags(flags); | ||
1059 | |||
1060 | ch->blocked_open++; | 924 | ch->blocked_open++; |
1061 | |||
1062 | while(1) | 925 | while(1) |
1063 | { /* Begin forever while */ | 926 | { /* Begin forever while */ |
1064 | |||
1065 | set_current_state(TASK_INTERRUPTIBLE); | 927 | set_current_state(TASK_INTERRUPTIBLE); |
1066 | |||
1067 | if (tty_hung_up_p(filp) || | 928 | if (tty_hung_up_p(filp) || |
1068 | !(ch->asyncflags & ASYNC_INITIALIZED)) | 929 | !(ch->asyncflags & ASYNC_INITIALIZED)) |
1069 | { | 930 | { |
@@ -1073,17 +934,14 @@ static int block_til_ready(struct tty_struct *tty, | |||
1073 | retval = -ERESTARTSYS; | 934 | retval = -ERESTARTSYS; |
1074 | break; | 935 | break; |
1075 | } | 936 | } |
1076 | |||
1077 | if (!(ch->asyncflags & ASYNC_CLOSING) && | 937 | if (!(ch->asyncflags & ASYNC_CLOSING) && |
1078 | (do_clocal || (ch->imodem & ch->dcd))) | 938 | (do_clocal || (ch->imodem & ch->dcd))) |
1079 | break; | 939 | break; |
1080 | 940 | if (signal_pending(current)) { | |
1081 | if (signal_pending(current)) | ||
1082 | { | ||
1083 | retval = -ERESTARTSYS; | 941 | retval = -ERESTARTSYS; |
1084 | break; | 942 | break; |
1085 | } | 943 | } |
1086 | 944 | spin_unlock_irqrestore(&epca_lock, flags); | |
1087 | /* --------------------------------------------------------------- | 945 | /* --------------------------------------------------------------- |
1088 | Allow someone else to be scheduled. We will occasionally go | 946 | Allow someone else to be scheduled. We will occasionally go |
1089 | through this loop until one of the above conditions change. | 947 | through this loop until one of the above conditions change. |
@@ -1091,25 +949,23 @@ static int block_til_ready(struct tty_struct *tty, | |||
1091 | prevent this loop from hogging the cpu. | 949 | prevent this loop from hogging the cpu. |
1092 | ------------------------------------------------------------------ */ | 950 | ------------------------------------------------------------------ */ |
1093 | schedule(); | 951 | schedule(); |
952 | spin_lock_irqsave(&epca_lock, flags); | ||
1094 | 953 | ||
1095 | } /* End forever while */ | 954 | } /* End forever while */ |
1096 | 955 | ||
1097 | current->state = TASK_RUNNING; | 956 | current->state = TASK_RUNNING; |
1098 | remove_wait_queue(&ch->open_wait, &wait); | 957 | remove_wait_queue(&ch->open_wait, &wait); |
1099 | cli(); | ||
1100 | if (!tty_hung_up_p(filp)) | 958 | if (!tty_hung_up_p(filp)) |
1101 | ch->count++; | 959 | ch->count++; |
1102 | restore_flags(flags); | ||
1103 | |||
1104 | ch->blocked_open--; | 960 | ch->blocked_open--; |
1105 | 961 | ||
962 | spin_unlock_irqrestore(&epca_lock, flags); | ||
963 | |||
1106 | if (retval) | 964 | if (retval) |
1107 | return retval; | 965 | return retval; |
1108 | 966 | ||
1109 | ch->asyncflags |= ASYNC_NORMAL_ACTIVE; | 967 | ch->asyncflags |= ASYNC_NORMAL_ACTIVE; |
1110 | |||
1111 | return 0; | 968 | return 0; |
1112 | |||
1113 | } /* End block_til_ready */ | 969 | } /* End block_til_ready */ |
1114 | 970 | ||
1115 | /* ------------------ Begin pc_open ---------------------- */ | 971 | /* ------------------ Begin pc_open ---------------------- */ |
@@ -1120,17 +976,12 @@ static int pc_open(struct tty_struct *tty, struct file * filp) | |||
1120 | struct channel *ch; | 976 | struct channel *ch; |
1121 | unsigned long flags; | 977 | unsigned long flags; |
1122 | int line, retval, boardnum; | 978 | int line, retval, boardnum; |
1123 | volatile struct board_chan *bc; | 979 | struct board_chan *bc; |
1124 | volatile unsigned int head; | 980 | unsigned int head; |
1125 | 981 | ||
1126 | line = tty->index; | 982 | line = tty->index; |
1127 | if (line < 0 || line >= nbdevs) | 983 | if (line < 0 || line >= nbdevs) |
1128 | { | 984 | return -ENODEV; |
1129 | printk(KERN_ERR "<Error> - pc_open : line out of range in pc_open\n"); | ||
1130 | tty->driver_data = NULL; | ||
1131 | return(-ENODEV); | ||
1132 | } | ||
1133 | |||
1134 | 985 | ||
1135 | ch = &digi_channels[line]; | 986 | ch = &digi_channels[line]; |
1136 | boardnum = ch->boardnum; | 987 | boardnum = ch->boardnum; |
@@ -1143,66 +994,49 @@ static int pc_open(struct tty_struct *tty, struct file * filp) | |||
1143 | goes here. | 994 | goes here. |
1144 | ---------------------------------------------------------------------- */ | 995 | ---------------------------------------------------------------------- */ |
1145 | 996 | ||
1146 | if (invalid_lilo_config) | 997 | if (invalid_lilo_config) { |
1147 | { | ||
1148 | if (setup_error_code & INVALID_BOARD_TYPE) | 998 | if (setup_error_code & INVALID_BOARD_TYPE) |
1149 | printk(KERN_ERR "<Error> - pc_open: Invalid board type specified in LILO command\n"); | 999 | printk(KERN_ERR "epca: pc_open: Invalid board type specified in kernel options.\n"); |
1150 | |||
1151 | if (setup_error_code & INVALID_NUM_PORTS) | 1000 | if (setup_error_code & INVALID_NUM_PORTS) |
1152 | printk(KERN_ERR "<Error> - pc_open: Invalid number of ports specified in LILO command\n"); | 1001 | printk(KERN_ERR "epca: pc_open: Invalid number of ports specified in kernel options.\n"); |
1153 | |||
1154 | if (setup_error_code & INVALID_MEM_BASE) | 1002 | if (setup_error_code & INVALID_MEM_BASE) |
1155 | printk(KERN_ERR "<Error> - pc_open: Invalid board memory address specified in LILO command\n"); | 1003 | printk(KERN_ERR "epca: pc_open: Invalid board memory address specified in kernel options.\n"); |
1156 | |||
1157 | if (setup_error_code & INVALID_PORT_BASE) | 1004 | if (setup_error_code & INVALID_PORT_BASE) |
1158 | printk(KERN_ERR "<Error> - pc_open: Invalid board port address specified in LILO command\n"); | 1005 | printk(KERN_ERR "epca; pc_open: Invalid board port address specified in kernel options.\n"); |
1159 | |||
1160 | if (setup_error_code & INVALID_BOARD_STATUS) | 1006 | if (setup_error_code & INVALID_BOARD_STATUS) |
1161 | printk(KERN_ERR "<Error> - pc_open: Invalid board status specified in LILO command\n"); | 1007 | printk(KERN_ERR "epca: pc_open: Invalid board status specified in kernel options.\n"); |
1162 | |||
1163 | if (setup_error_code & INVALID_ALTPIN) | 1008 | if (setup_error_code & INVALID_ALTPIN) |
1164 | printk(KERN_ERR "<Error> - pc_open: Invalid board altpin specified in LILO command\n"); | 1009 | printk(KERN_ERR "epca: pc_open: Invalid board altpin specified in kernel options;\n"); |
1165 | |||
1166 | tty->driver_data = NULL; /* Mark this device as 'down' */ | 1010 | tty->driver_data = NULL; /* Mark this device as 'down' */ |
1167 | return(-ENODEV); | 1011 | return -ENODEV; |
1168 | } | 1012 | } |
1169 | 1013 | if (boardnum >= num_cards || boards[boardnum].status == DISABLED) { | |
1170 | if ((boardnum >= num_cards) || (boards[boardnum].status == DISABLED)) | ||
1171 | { | ||
1172 | tty->driver_data = NULL; /* Mark this device as 'down' */ | 1014 | tty->driver_data = NULL; /* Mark this device as 'down' */ |
1173 | return(-ENODEV); | 1015 | return(-ENODEV); |
1174 | } | 1016 | } |
1175 | 1017 | ||
1176 | if (( bc = ch->brdchan) == 0) | 1018 | if ((bc = ch->brdchan) == 0) { |
1177 | { | ||
1178 | tty->driver_data = NULL; | 1019 | tty->driver_data = NULL; |
1179 | return(-ENODEV); | 1020 | return -ENODEV; |
1180 | } | 1021 | } |
1181 | 1022 | ||
1023 | spin_lock_irqsave(&epca_lock, flags); | ||
1182 | /* ------------------------------------------------------------------ | 1024 | /* ------------------------------------------------------------------ |
1183 | Every time a channel is opened, increment a counter. This is | 1025 | Every time a channel is opened, increment a counter. This is |
1184 | necessary because we do not wish to flush and shutdown the channel | 1026 | necessary because we do not wish to flush and shutdown the channel |
1185 | until the last app holding the channel open, closes it. | 1027 | until the last app holding the channel open, closes it. |
1186 | --------------------------------------------------------------------- */ | 1028 | --------------------------------------------------------------------- */ |
1187 | |||
1188 | ch->count++; | 1029 | ch->count++; |
1189 | |||
1190 | /* ---------------------------------------------------------------- | 1030 | /* ---------------------------------------------------------------- |
1191 | Set a kernel structures pointer to our local channel | 1031 | Set a kernel structures pointer to our local channel |
1192 | structure. This way we can get to it when passed only | 1032 | structure. This way we can get to it when passed only |
1193 | a tty struct. | 1033 | a tty struct. |
1194 | ------------------------------------------------------------------ */ | 1034 | ------------------------------------------------------------------ */ |
1195 | |||
1196 | tty->driver_data = ch; | 1035 | tty->driver_data = ch; |
1197 | |||
1198 | /* ---------------------------------------------------------------- | 1036 | /* ---------------------------------------------------------------- |
1199 | If this is the first time the channel has been opened, initialize | 1037 | If this is the first time the channel has been opened, initialize |
1200 | the tty->termios struct otherwise let pc_close handle it. | 1038 | the tty->termios struct otherwise let pc_close handle it. |
1201 | -------------------------------------------------------------------- */ | 1039 | -------------------------------------------------------------------- */ |
1202 | |||
1203 | save_flags(flags); | ||
1204 | cli(); | ||
1205 | |||
1206 | globalwinon(ch); | 1040 | globalwinon(ch); |
1207 | ch->statusflags = 0; | 1041 | ch->statusflags = 0; |
1208 | 1042 | ||
@@ -1213,8 +1047,8 @@ static int pc_open(struct tty_struct *tty, struct file * filp) | |||
1213 | Set receive head and tail ptrs to each other. This indicates | 1047 | Set receive head and tail ptrs to each other. This indicates |
1214 | no data available to read. | 1048 | no data available to read. |
1215 | ----------------------------------------------------------------- */ | 1049 | ----------------------------------------------------------------- */ |
1216 | head = bc->rin; | 1050 | head = readw(&bc->rin); |
1217 | bc->rout = head; | 1051 | writew(head, &bc->rout); |
1218 | 1052 | ||
1219 | /* Set the channels associated tty structure */ | 1053 | /* Set the channels associated tty structure */ |
1220 | ch->tty = tty; | 1054 | ch->tty = tty; |
@@ -1224,122 +1058,74 @@ static int pc_open(struct tty_struct *tty, struct file * filp) | |||
1224 | issues, etc.... It effect both control flags and input flags. | 1058 | issues, etc.... It effect both control flags and input flags. |
1225 | -------------------------------------------------------------------- */ | 1059 | -------------------------------------------------------------------- */ |
1226 | epcaparam(tty,ch); | 1060 | epcaparam(tty,ch); |
1227 | |||
1228 | ch->asyncflags |= ASYNC_INITIALIZED; | 1061 | ch->asyncflags |= ASYNC_INITIALIZED; |
1229 | memoff(ch); | 1062 | memoff(ch); |
1230 | 1063 | spin_unlock_irqrestore(&epca_lock, flags); | |
1231 | restore_flags(flags); | ||
1232 | 1064 | ||
1233 | retval = block_til_ready(tty, filp, ch); | 1065 | retval = block_til_ready(tty, filp, ch); |
1234 | if (retval) | 1066 | if (retval) |
1235 | { | ||
1236 | return retval; | 1067 | return retval; |
1237 | } | ||
1238 | |||
1239 | /* ------------------------------------------------------------- | 1068 | /* ------------------------------------------------------------- |
1240 | Set this again in case a hangup set it to zero while this | 1069 | Set this again in case a hangup set it to zero while this |
1241 | open() was waiting for the line... | 1070 | open() was waiting for the line... |
1242 | --------------------------------------------------------------- */ | 1071 | --------------------------------------------------------------- */ |
1072 | spin_lock_irqsave(&epca_lock, flags); | ||
1243 | ch->tty = tty; | 1073 | ch->tty = tty; |
1244 | |||
1245 | save_flags(flags); | ||
1246 | cli(); | ||
1247 | globalwinon(ch); | 1074 | globalwinon(ch); |
1248 | |||
1249 | /* Enable Digi Data events */ | 1075 | /* Enable Digi Data events */ |
1250 | bc->idata = 1; | 1076 | writeb(1, &bc->idata); |
1251 | |||
1252 | memoff(ch); | 1077 | memoff(ch); |
1253 | restore_flags(flags); | 1078 | spin_unlock_irqrestore(&epca_lock, flags); |
1254 | |||
1255 | return 0; | 1079 | return 0; |
1256 | |||
1257 | } /* End pc_open */ | 1080 | } /* End pc_open */ |
1258 | 1081 | ||
1259 | #ifdef MODULE | ||
1260 | static int __init epca_module_init(void) | 1082 | static int __init epca_module_init(void) |
1261 | { /* Begin init_module */ | 1083 | { /* Begin init_module */ |
1262 | 1084 | return pc_init(); | |
1263 | unsigned long flags; | ||
1264 | |||
1265 | save_flags(flags); | ||
1266 | cli(); | ||
1267 | |||
1268 | pc_init(); | ||
1269 | |||
1270 | restore_flags(flags); | ||
1271 | |||
1272 | return(0); | ||
1273 | } | 1085 | } |
1274 | 1086 | ||
1275 | module_init(epca_module_init); | 1087 | module_init(epca_module_init); |
1276 | #endif | ||
1277 | 1088 | ||
1278 | #ifdef ENABLE_PCI | ||
1279 | static struct pci_driver epca_driver; | 1089 | static struct pci_driver epca_driver; |
1280 | #endif | ||
1281 | |||
1282 | #ifdef MODULE | ||
1283 | /* -------------------- Begin cleanup_module ---------------------- */ | ||
1284 | 1090 | ||
1285 | static void __exit epca_module_exit(void) | 1091 | static void __exit epca_module_exit(void) |
1286 | { | 1092 | { |
1287 | |||
1288 | int count, crd; | 1093 | int count, crd; |
1289 | struct board_info *bd; | 1094 | struct board_info *bd; |
1290 | struct channel *ch; | 1095 | struct channel *ch; |
1291 | unsigned long flags; | ||
1292 | 1096 | ||
1293 | del_timer_sync(&epca_timer); | 1097 | del_timer_sync(&epca_timer); |
1294 | 1098 | ||
1295 | save_flags(flags); | ||
1296 | cli(); | ||
1297 | |||
1298 | if ((tty_unregister_driver(pc_driver)) || | 1099 | if ((tty_unregister_driver(pc_driver)) || |
1299 | (tty_unregister_driver(pc_info))) | 1100 | (tty_unregister_driver(pc_info))) |
1300 | { | 1101 | { |
1301 | printk(KERN_WARNING "<Error> - DIGI : cleanup_module failed to un-register tty driver\n"); | 1102 | printk(KERN_WARNING "epca: cleanup_module failed to un-register tty driver\n"); |
1302 | restore_flags(flags); | ||
1303 | return; | 1103 | return; |
1304 | } | 1104 | } |
1305 | put_tty_driver(pc_driver); | 1105 | put_tty_driver(pc_driver); |
1306 | put_tty_driver(pc_info); | 1106 | put_tty_driver(pc_info); |
1307 | 1107 | ||
1308 | for (crd = 0; crd < num_cards; crd++) | 1108 | for (crd = 0; crd < num_cards; crd++) { /* Begin for each card */ |
1309 | { /* Begin for each card */ | ||
1310 | |||
1311 | bd = &boards[crd]; | 1109 | bd = &boards[crd]; |
1312 | |||
1313 | if (!bd) | 1110 | if (!bd) |
1314 | { /* Begin sanity check */ | 1111 | { /* Begin sanity check */ |
1315 | printk(KERN_ERR "<Error> - Digi : cleanup_module failed\n"); | 1112 | printk(KERN_ERR "<Error> - Digi : cleanup_module failed\n"); |
1316 | return; | 1113 | return; |
1317 | } /* End sanity check */ | 1114 | } /* End sanity check */ |
1318 | 1115 | ch = card_ptr[crd]; | |
1319 | ch = card_ptr[crd]; | ||
1320 | |||
1321 | for (count = 0; count < bd->numports; count++, ch++) | 1116 | for (count = 0; count < bd->numports; count++, ch++) |
1322 | { /* Begin for each port */ | 1117 | { /* Begin for each port */ |
1323 | 1118 | if (ch) { | |
1324 | if (ch) | ||
1325 | { | ||
1326 | if (ch->tty) | 1119 | if (ch->tty) |
1327 | tty_hangup(ch->tty); | 1120 | tty_hangup(ch->tty); |
1328 | kfree(ch->tmp_buf); | 1121 | kfree(ch->tmp_buf); |
1329 | } | 1122 | } |
1330 | |||
1331 | } /* End for each port */ | 1123 | } /* End for each port */ |
1332 | } /* End for each card */ | 1124 | } /* End for each card */ |
1333 | |||
1334 | #ifdef ENABLE_PCI | ||
1335 | pci_unregister_driver (&epca_driver); | 1125 | pci_unregister_driver (&epca_driver); |
1336 | #endif | ||
1337 | |||
1338 | restore_flags(flags); | ||
1339 | |||
1340 | } | 1126 | } |
1127 | |||
1341 | module_exit(epca_module_exit); | 1128 | module_exit(epca_module_exit); |
1342 | #endif /* MODULE */ | ||
1343 | 1129 | ||
1344 | static struct tty_operations pc_ops = { | 1130 | static struct tty_operations pc_ops = { |
1345 | .open = pc_open, | 1131 | .open = pc_open, |
@@ -1371,34 +1157,15 @@ static struct tty_operations info_ops = { | |||
1371 | 1157 | ||
1372 | /* ------------------ Begin pc_init ---------------------- */ | 1158 | /* ------------------ Begin pc_init ---------------------- */ |
1373 | 1159 | ||
1374 | int __init pc_init(void) | 1160 | static int __init pc_init(void) |
1375 | { /* Begin pc_init */ | 1161 | { /* Begin pc_init */ |
1376 | |||
1377 | /* ---------------------------------------------------------------- | ||
1378 | pc_init is called by the operating system during boot up prior to | ||
1379 | any open calls being made. In the older versions of Linux (Prior | ||
1380 | to 2.0.0) an entry is made into tty_io.c. A pointer to the last | ||
1381 | memory location (from kernel space) used (kmem_start) is passed | ||
1382 | to pc_init. It is pc_inits responsibility to modify this value | ||
1383 | for any memory that the Digi driver might need and then return | ||
1384 | this value to the operating system. For example if the driver | ||
1385 | wishes to allocate 1K of kernel memory, pc_init would return | ||
1386 | (kmem_start + 1024). This memory (Between kmem_start and kmem_start | ||
1387 | + 1024) would then be available for use exclusively by the driver. | ||
1388 | In this case our driver does not allocate any of this kernel | ||
1389 | memory. | ||
1390 | ------------------------------------------------------------------*/ | ||
1391 | |||
1392 | ulong flags; | ||
1393 | int crd; | 1162 | int crd; |
1394 | struct board_info *bd; | 1163 | struct board_info *bd; |
1395 | unsigned char board_id = 0; | 1164 | unsigned char board_id = 0; |
1396 | 1165 | ||
1397 | #ifdef ENABLE_PCI | ||
1398 | int pci_boards_found, pci_count; | 1166 | int pci_boards_found, pci_count; |
1399 | 1167 | ||
1400 | pci_count = 0; | 1168 | pci_count = 0; |
1401 | #endif /* ENABLE_PCI */ | ||
1402 | 1169 | ||
1403 | pc_driver = alloc_tty_driver(MAX_ALLOC); | 1170 | pc_driver = alloc_tty_driver(MAX_ALLOC); |
1404 | if (!pc_driver) | 1171 | if (!pc_driver) |
@@ -1416,8 +1183,7 @@ int __init pc_init(void) | |||
1416 | Note : If LILO has ran epca_setup then epca_setup will handle defining | 1183 | Note : If LILO has ran epca_setup then epca_setup will handle defining |
1417 | num_cards as well as copying the data into the board structure. | 1184 | num_cards as well as copying the data into the board structure. |
1418 | -------------------------------------------------------------------------- */ | 1185 | -------------------------------------------------------------------------- */ |
1419 | if (!liloconfig) | 1186 | if (!liloconfig) { /* Begin driver has been configured via. epcaconfig */ |
1420 | { /* Begin driver has been configured via. epcaconfig */ | ||
1421 | 1187 | ||
1422 | nbdevs = NBDEVS; | 1188 | nbdevs = NBDEVS; |
1423 | num_cards = NUMCARDS; | 1189 | num_cards = NUMCARDS; |
@@ -1440,8 +1206,6 @@ int __init pc_init(void) | |||
1440 | 1206 | ||
1441 | printk(KERN_INFO "DIGI epca driver version %s loaded.\n",VERSION); | 1207 | printk(KERN_INFO "DIGI epca driver version %s loaded.\n",VERSION); |
1442 | 1208 | ||
1443 | #ifdef ENABLE_PCI | ||
1444 | |||
1445 | /* ------------------------------------------------------------------ | 1209 | /* ------------------------------------------------------------------ |
1446 | NOTE : This code assumes that the number of ports found in | 1210 | NOTE : This code assumes that the number of ports found in |
1447 | the boards array is correct. This could be wrong if | 1211 | the boards array is correct. This could be wrong if |
@@ -1467,8 +1231,6 @@ int __init pc_init(void) | |||
1467 | pci_boards_found += init_PCI(); | 1231 | pci_boards_found += init_PCI(); |
1468 | num_cards += pci_boards_found; | 1232 | num_cards += pci_boards_found; |
1469 | 1233 | ||
1470 | #endif /* ENABLE_PCI */ | ||
1471 | |||
1472 | pc_driver->owner = THIS_MODULE; | 1234 | pc_driver->owner = THIS_MODULE; |
1473 | pc_driver->name = "ttyD"; | 1235 | pc_driver->name = "ttyD"; |
1474 | pc_driver->devfs_name = "tts/D"; | 1236 | pc_driver->devfs_name = "tts/D"; |
@@ -1499,9 +1261,6 @@ int __init pc_init(void) | |||
1499 | tty_set_operations(pc_info, &info_ops); | 1261 | tty_set_operations(pc_info, &info_ops); |
1500 | 1262 | ||
1501 | 1263 | ||
1502 | save_flags(flags); | ||
1503 | cli(); | ||
1504 | |||
1505 | for (crd = 0; crd < num_cards; crd++) | 1264 | for (crd = 0; crd < num_cards; crd++) |
1506 | { /* Begin for each card */ | 1265 | { /* Begin for each card */ |
1507 | 1266 | ||
@@ -1610,11 +1369,7 @@ int __init pc_init(void) | |||
1610 | if ((board_id & 0x30) == 0x30) | 1369 | if ((board_id & 0x30) == 0x30) |
1611 | bd->memory_seg = 0x8000; | 1370 | bd->memory_seg = 0x8000; |
1612 | 1371 | ||
1613 | } /* End it is an XI card */ | 1372 | } else printk(KERN_ERR "epca: Board at 0x%x doesn't appear to be an XI\n",(int)bd->port); |
1614 | else | ||
1615 | { | ||
1616 | printk(KERN_ERR "<Error> - Board at 0x%x doesn't appear to be an XI\n",(int)bd->port); | ||
1617 | } | ||
1618 | break; | 1373 | break; |
1619 | 1374 | ||
1620 | } /* End switch on bd->type */ | 1375 | } /* End switch on bd->type */ |
@@ -1634,9 +1389,6 @@ int __init pc_init(void) | |||
1634 | init_timer(&epca_timer); | 1389 | init_timer(&epca_timer); |
1635 | epca_timer.function = epcapoll; | 1390 | epca_timer.function = epcapoll; |
1636 | mod_timer(&epca_timer, jiffies + HZ/25); | 1391 | mod_timer(&epca_timer, jiffies + HZ/25); |
1637 | |||
1638 | restore_flags(flags); | ||
1639 | |||
1640 | return 0; | 1392 | return 0; |
1641 | 1393 | ||
1642 | } /* End pc_init */ | 1394 | } /* End pc_init */ |
@@ -1647,10 +1399,10 @@ static void post_fep_init(unsigned int crd) | |||
1647 | { /* Begin post_fep_init */ | 1399 | { /* Begin post_fep_init */ |
1648 | 1400 | ||
1649 | int i; | 1401 | int i; |
1650 | unchar *memaddr; | 1402 | unsigned char *memaddr; |
1651 | volatile struct global_data *gd; | 1403 | struct global_data *gd; |
1652 | struct board_info *bd; | 1404 | struct board_info *bd; |
1653 | volatile struct board_chan *bc; | 1405 | struct board_chan *bc; |
1654 | struct channel *ch; | 1406 | struct channel *ch; |
1655 | int shrinkmem = 0, lowwater ; | 1407 | int shrinkmem = 0, lowwater ; |
1656 | 1408 | ||
@@ -1669,9 +1421,7 @@ static void post_fep_init(unsigned int crd) | |||
1669 | after DIGI_INIT has been called will return the proper values. | 1421 | after DIGI_INIT has been called will return the proper values. |
1670 | ------------------------------------------------------------------- */ | 1422 | ------------------------------------------------------------------- */ |
1671 | 1423 | ||
1672 | if (bd->type >= PCIXEM) /* If the board in question is PCI */ | 1424 | if (bd->type >= PCIXEM) { /* Begin get PCI number of ports */ |
1673 | { /* Begin get PCI number of ports */ | ||
1674 | |||
1675 | /* -------------------------------------------------------------------- | 1425 | /* -------------------------------------------------------------------- |
1676 | Below we use XEMPORTS as a memory offset regardless of which PCI | 1426 | Below we use XEMPORTS as a memory offset regardless of which PCI |
1677 | card it is. This is because all of the supported PCI cards have | 1427 | card it is. This is because all of the supported PCI cards have |
@@ -1685,15 +1435,15 @@ static void post_fep_init(unsigned int crd) | |||
1685 | (FYI - The id should be located at 0x1ac (And may use up to 4 bytes | 1435 | (FYI - The id should be located at 0x1ac (And may use up to 4 bytes |
1686 | if the box in question is a XEM or CX)). | 1436 | if the box in question is a XEM or CX)). |
1687 | ------------------------------------------------------------------------ */ | 1437 | ------------------------------------------------------------------------ */ |
1688 | 1438 | /* PCI cards are already remapped at this point ISA are not */ | |
1689 | bd->numports = (unsigned short)*(unsigned char *)bus_to_virt((unsigned long) | 1439 | bd->numports = readw(bd->re_map_membase + XEMPORTS); |
1690 | (bd->re_map_membase + XEMPORTS)); | ||
1691 | |||
1692 | |||
1693 | epcaassert(bd->numports <= 64,"PCI returned a invalid number of ports"); | 1440 | epcaassert(bd->numports <= 64,"PCI returned a invalid number of ports"); |
1694 | nbdevs += (bd->numports); | 1441 | nbdevs += (bd->numports); |
1695 | 1442 | } else { | |
1696 | } /* End get PCI number of ports */ | 1443 | /* Fix up the mappings for ISA/EISA etc */ |
1444 | /* FIXME: 64K - can we be smarter ? */ | ||
1445 | bd->re_map_membase = ioremap(bd->membase, 0x10000); | ||
1446 | } | ||
1697 | 1447 | ||
1698 | if (crd != 0) | 1448 | if (crd != 0) |
1699 | card_ptr[crd] = card_ptr[crd-1] + boards[crd-1].numports; | 1449 | card_ptr[crd] = card_ptr[crd-1] + boards[crd-1].numports; |
@@ -1701,19 +1451,9 @@ static void post_fep_init(unsigned int crd) | |||
1701 | card_ptr[crd] = &digi_channels[crd]; /* <- For card 0 only */ | 1451 | card_ptr[crd] = &digi_channels[crd]; /* <- For card 0 only */ |
1702 | 1452 | ||
1703 | ch = card_ptr[crd]; | 1453 | ch = card_ptr[crd]; |
1704 | |||
1705 | |||
1706 | epcaassert(ch <= &digi_channels[nbdevs - 1], "ch out of range"); | 1454 | epcaassert(ch <= &digi_channels[nbdevs - 1], "ch out of range"); |
1707 | 1455 | ||
1708 | memaddr = (unchar *)bd->re_map_membase; | 1456 | memaddr = bd->re_map_membase; |
1709 | |||
1710 | /* | ||
1711 | The below command is necessary because newer kernels (2.1.x and | ||
1712 | up) do not have a 1:1 virtual to physical mapping. The below | ||
1713 | call adjust for that. | ||
1714 | */ | ||
1715 | |||
1716 | memaddr = (unsigned char *)bus_to_virt((unsigned long)memaddr); | ||
1717 | 1457 | ||
1718 | /* ----------------------------------------------------------------- | 1458 | /* ----------------------------------------------------------------- |
1719 | The below assignment will set bc to point at the BEGINING of | 1459 | The below assignment will set bc to point at the BEGINING of |
@@ -1721,7 +1461,7 @@ static void post_fep_init(unsigned int crd) | |||
1721 | 8 and 64 of these structures. | 1461 | 8 and 64 of these structures. |
1722 | -------------------------------------------------------------------- */ | 1462 | -------------------------------------------------------------------- */ |
1723 | 1463 | ||
1724 | bc = (volatile struct board_chan *)((ulong)memaddr + CHANSTRUCT); | 1464 | bc = (struct board_chan *)(memaddr + CHANSTRUCT); |
1725 | 1465 | ||
1726 | /* ------------------------------------------------------------------- | 1466 | /* ------------------------------------------------------------------- |
1727 | The below assignment will set gd to point at the BEGINING of | 1467 | The below assignment will set gd to point at the BEGINING of |
@@ -1730,20 +1470,18 @@ static void post_fep_init(unsigned int crd) | |||
1730 | pointer begins at 0xd10. | 1470 | pointer begins at 0xd10. |
1731 | ---------------------------------------------------------------------- */ | 1471 | ---------------------------------------------------------------------- */ |
1732 | 1472 | ||
1733 | gd = (volatile struct global_data *)((ulong)memaddr + GLOBAL); | 1473 | gd = (struct global_data *)(memaddr + GLOBAL); |
1734 | 1474 | ||
1735 | /* -------------------------------------------------------------------- | 1475 | /* -------------------------------------------------------------------- |
1736 | XEPORTS (address 0xc22) points at the number of channels the | 1476 | XEPORTS (address 0xc22) points at the number of channels the |
1737 | card supports. (For 64XE, XI, XEM, and XR use 0xc02) | 1477 | card supports. (For 64XE, XI, XEM, and XR use 0xc02) |
1738 | ----------------------------------------------------------------------- */ | 1478 | ----------------------------------------------------------------------- */ |
1739 | 1479 | ||
1740 | if (((bd->type == PCXEVE) | (bd->type == PCXE)) && | 1480 | if ((bd->type == PCXEVE || bd->type == PCXE) && (readw(memaddr + XEPORTS) < 3)) |
1741 | (*(ushort *)((ulong)memaddr + XEPORTS) < 3)) | ||
1742 | shrinkmem = 1; | 1481 | shrinkmem = 1; |
1743 | if (bd->type < PCIXEM) | 1482 | if (bd->type < PCIXEM) |
1744 | if (!request_region((int)bd->port, 4, board_desc[bd->type])) | 1483 | if (!request_region((int)bd->port, 4, board_desc[bd->type])) |
1745 | return; | 1484 | return; |
1746 | |||
1747 | memwinon(bd, 0); | 1485 | memwinon(bd, 0); |
1748 | 1486 | ||
1749 | /* -------------------------------------------------------------------- | 1487 | /* -------------------------------------------------------------------- |
@@ -1753,17 +1491,16 @@ static void post_fep_init(unsigned int crd) | |||
1753 | 1491 | ||
1754 | /* For every port on the card do ..... */ | 1492 | /* For every port on the card do ..... */ |
1755 | 1493 | ||
1756 | for (i = 0; i < bd->numports; i++, ch++, bc++) | 1494 | for (i = 0; i < bd->numports; i++, ch++, bc++) { /* Begin for each port */ |
1757 | { /* Begin for each port */ | 1495 | unsigned long flags; |
1758 | 1496 | ||
1759 | ch->brdchan = bc; | 1497 | ch->brdchan = bc; |
1760 | ch->mailbox = gd; | 1498 | ch->mailbox = gd; |
1761 | INIT_WORK(&ch->tqueue, do_softint, ch); | 1499 | INIT_WORK(&ch->tqueue, do_softint, ch); |
1762 | ch->board = &boards[crd]; | 1500 | ch->board = &boards[crd]; |
1763 | 1501 | ||
1764 | switch (bd->type) | 1502 | spin_lock_irqsave(&epca_lock, flags); |
1765 | { /* Begin switch bd->type */ | 1503 | switch (bd->type) { |
1766 | |||
1767 | /* ---------------------------------------------------------------- | 1504 | /* ---------------------------------------------------------------- |
1768 | Since some of the boards use different bitmaps for their | 1505 | Since some of the boards use different bitmaps for their |
1769 | control signals we cannot hard code these values and retain | 1506 | control signals we cannot hard code these values and retain |
@@ -1796,14 +1533,12 @@ static void post_fep_init(unsigned int crd) | |||
1796 | 1533 | ||
1797 | } /* End switch bd->type */ | 1534 | } /* End switch bd->type */ |
1798 | 1535 | ||
1799 | if (boards[crd].altpin) | 1536 | if (boards[crd].altpin) { |
1800 | { | ||
1801 | ch->dsr = ch->m_dcd; | 1537 | ch->dsr = ch->m_dcd; |
1802 | ch->dcd = ch->m_dsr; | 1538 | ch->dcd = ch->m_dsr; |
1803 | ch->digiext.digi_flags |= DIGI_ALTPIN; | 1539 | ch->digiext.digi_flags |= DIGI_ALTPIN; |
1804 | } | 1540 | } |
1805 | else | 1541 | else { |
1806 | { | ||
1807 | ch->dcd = ch->m_dcd; | 1542 | ch->dcd = ch->m_dcd; |
1808 | ch->dsr = ch->m_dsr; | 1543 | ch->dsr = ch->m_dsr; |
1809 | } | 1544 | } |
@@ -1813,14 +1548,12 @@ static void post_fep_init(unsigned int crd) | |||
1813 | ch->magic = EPCA_MAGIC; | 1548 | ch->magic = EPCA_MAGIC; |
1814 | ch->tty = NULL; | 1549 | ch->tty = NULL; |
1815 | 1550 | ||
1816 | if (shrinkmem) | 1551 | if (shrinkmem) { |
1817 | { | ||
1818 | fepcmd(ch, SETBUFFER, 32, 0, 0, 0); | 1552 | fepcmd(ch, SETBUFFER, 32, 0, 0, 0); |
1819 | shrinkmem = 0; | 1553 | shrinkmem = 0; |
1820 | } | 1554 | } |
1821 | 1555 | ||
1822 | switch (bd->type) | 1556 | switch (bd->type) { |
1823 | { /* Begin switch bd->type */ | ||
1824 | 1557 | ||
1825 | case PCIXEM: | 1558 | case PCIXEM: |
1826 | case PCIXRJ: | 1559 | case PCIXRJ: |
@@ -1878,13 +1611,13 @@ static void post_fep_init(unsigned int crd) | |||
1878 | 1611 | ||
1879 | fepcmd(ch, SRXHWATER, (3 * ch->rxbufsize / 4), 0, 10, 0); | 1612 | fepcmd(ch, SRXHWATER, (3 * ch->rxbufsize / 4), 0, 10, 0); |
1880 | 1613 | ||
1881 | bc->edelay = 100; | 1614 | writew(100, &bc->edelay); |
1882 | bc->idata = 1; | 1615 | writeb(1, &bc->idata); |
1883 | 1616 | ||
1884 | ch->startc = bc->startc; | 1617 | ch->startc = readb(&bc->startc); |
1885 | ch->stopc = bc->stopc; | 1618 | ch->stopc = readb(&bc->stopc); |
1886 | ch->startca = bc->startca; | 1619 | ch->startca = readb(&bc->startca); |
1887 | ch->stopca = bc->stopca; | 1620 | ch->stopca = readb(&bc->stopca); |
1888 | 1621 | ||
1889 | ch->fepcflag = 0; | 1622 | ch->fepcflag = 0; |
1890 | ch->fepiflag = 0; | 1623 | ch->fepiflag = 0; |
@@ -1899,27 +1632,23 @@ static void post_fep_init(unsigned int crd) | |||
1899 | ch->blocked_open = 0; | 1632 | ch->blocked_open = 0; |
1900 | init_waitqueue_head(&ch->open_wait); | 1633 | init_waitqueue_head(&ch->open_wait); |
1901 | init_waitqueue_head(&ch->close_wait); | 1634 | init_waitqueue_head(&ch->close_wait); |
1635 | |||
1636 | spin_unlock_irqrestore(&epca_lock, flags); | ||
1637 | |||
1902 | ch->tmp_buf = kmalloc(ch->txbufsize,GFP_KERNEL); | 1638 | ch->tmp_buf = kmalloc(ch->txbufsize,GFP_KERNEL); |
1903 | if (!(ch->tmp_buf)) | 1639 | if (!ch->tmp_buf) { |
1904 | { | ||
1905 | printk(KERN_ERR "POST FEP INIT : kmalloc failed for port 0x%x\n",i); | 1640 | printk(KERN_ERR "POST FEP INIT : kmalloc failed for port 0x%x\n",i); |
1906 | release_region((int)bd->port, 4); | 1641 | release_region((int)bd->port, 4); |
1907 | while(i-- > 0) | 1642 | while(i-- > 0) |
1908 | kfree((ch--)->tmp_buf); | 1643 | kfree((ch--)->tmp_buf); |
1909 | return; | 1644 | return; |
1910 | } | 1645 | } else |
1911 | else | ||
1912 | memset((void *)ch->tmp_buf,0,ch->txbufsize); | 1646 | memset((void *)ch->tmp_buf,0,ch->txbufsize); |
1913 | } /* End for each port */ | 1647 | } /* End for each port */ |
1914 | 1648 | ||
1915 | printk(KERN_INFO | 1649 | printk(KERN_INFO |
1916 | "Digi PC/Xx Driver V%s: %s I/O = 0x%lx Mem = 0x%lx Ports = %d\n", | 1650 | "Digi PC/Xx Driver V%s: %s I/O = 0x%lx Mem = 0x%lx Ports = %d\n", |
1917 | VERSION, board_desc[bd->type], (long)bd->port, (long)bd->membase, bd->numports); | 1651 | VERSION, board_desc[bd->type], (long)bd->port, (long)bd->membase, bd->numports); |
1918 | sprintf(mesg, | ||
1919 | "Digi PC/Xx Driver V%s: %s I/O = 0x%lx Mem = 0x%lx Ports = %d\n", | ||
1920 | VERSION, board_desc[bd->type], (long)bd->port, (long)bd->membase, bd->numports); | ||
1921 | console_print(mesg); | ||
1922 | |||
1923 | memwinoff(bd, 0); | 1652 | memwinoff(bd, 0); |
1924 | 1653 | ||
1925 | } /* End post_fep_init */ | 1654 | } /* End post_fep_init */ |
@@ -1943,9 +1672,6 @@ static void epcapoll(unsigned long ignored) | |||
1943 | buffer empty) and acts on those events. | 1672 | buffer empty) and acts on those events. |
1944 | ----------------------------------------------------------------------- */ | 1673 | ----------------------------------------------------------------------- */ |
1945 | 1674 | ||
1946 | save_flags(flags); | ||
1947 | cli(); | ||
1948 | |||
1949 | for (crd = 0; crd < num_cards; crd++) | 1675 | for (crd = 0; crd < num_cards; crd++) |
1950 | { /* Begin for each card */ | 1676 | { /* Begin for each card */ |
1951 | 1677 | ||
@@ -1961,6 +1687,8 @@ static void epcapoll(unsigned long ignored) | |||
1961 | some legacy boards. | 1687 | some legacy boards. |
1962 | ---------------------------------------------------------------- */ | 1688 | ---------------------------------------------------------------- */ |
1963 | 1689 | ||
1690 | spin_lock_irqsave(&epca_lock, flags); | ||
1691 | |||
1964 | assertmemoff(ch); | 1692 | assertmemoff(ch); |
1965 | 1693 | ||
1966 | globalwinon(ch); | 1694 | globalwinon(ch); |
@@ -1970,21 +1698,19 @@ static void epcapoll(unsigned long ignored) | |||
1970 | the transmit or receive queue. | 1698 | the transmit or receive queue. |
1971 | ------------------------------------------------------------------- */ | 1699 | ------------------------------------------------------------------- */ |
1972 | 1700 | ||
1973 | head = ch->mailbox->ein; | 1701 | head = readw(&ch->mailbox->ein); |
1974 | tail = ch->mailbox->eout; | 1702 | tail = readw(&ch->mailbox->eout); |
1975 | 1703 | ||
1976 | /* If head isn't equal to tail we have an event */ | 1704 | /* If head isn't equal to tail we have an event */ |
1977 | 1705 | ||
1978 | if (head != tail) | 1706 | if (head != tail) |
1979 | doevent(crd); | 1707 | doevent(crd); |
1980 | |||
1981 | memoff(ch); | 1708 | memoff(ch); |
1982 | 1709 | ||
1983 | } /* End for each card */ | 1710 | spin_unlock_irqrestore(&epca_lock, flags); |
1984 | 1711 | ||
1712 | } /* End for each card */ | ||
1985 | mod_timer(&epca_timer, jiffies + (HZ / 25)); | 1713 | mod_timer(&epca_timer, jiffies + (HZ / 25)); |
1986 | |||
1987 | restore_flags(flags); | ||
1988 | } /* End epcapoll */ | 1714 | } /* End epcapoll */ |
1989 | 1715 | ||
1990 | /* --------------------- Begin doevent ------------------------ */ | 1716 | /* --------------------- Begin doevent ------------------------ */ |
@@ -1992,53 +1718,42 @@ static void epcapoll(unsigned long ignored) | |||
1992 | static void doevent(int crd) | 1718 | static void doevent(int crd) |
1993 | { /* Begin doevent */ | 1719 | { /* Begin doevent */ |
1994 | 1720 | ||
1995 | volatile unchar *eventbuf; | 1721 | void *eventbuf; |
1996 | struct channel *ch, *chan0; | 1722 | struct channel *ch, *chan0; |
1997 | static struct tty_struct *tty; | 1723 | static struct tty_struct *tty; |
1998 | volatile struct board_info *bd; | 1724 | struct board_info *bd; |
1999 | volatile struct board_chan *bc; | 1725 | struct board_chan *bc; |
2000 | register volatile unsigned int tail, head; | 1726 | unsigned int tail, head; |
2001 | register int event, channel; | 1727 | int event, channel; |
2002 | register int mstat, lstat; | 1728 | int mstat, lstat; |
2003 | 1729 | ||
2004 | /* ------------------------------------------------------------------- | 1730 | /* ------------------------------------------------------------------- |
2005 | This subroutine is called by epcapoll when an event is detected | 1731 | This subroutine is called by epcapoll when an event is detected |
2006 | in the event queue. This routine responds to those events. | 1732 | in the event queue. This routine responds to those events. |
2007 | --------------------------------------------------------------------- */ | 1733 | --------------------------------------------------------------------- */ |
2008 | |||
2009 | bd = &boards[crd]; | 1734 | bd = &boards[crd]; |
2010 | 1735 | ||
2011 | chan0 = card_ptr[crd]; | 1736 | chan0 = card_ptr[crd]; |
2012 | epcaassert(chan0 <= &digi_channels[nbdevs - 1], "ch out of range"); | 1737 | epcaassert(chan0 <= &digi_channels[nbdevs - 1], "ch out of range"); |
2013 | |||
2014 | assertgwinon(chan0); | 1738 | assertgwinon(chan0); |
2015 | 1739 | while ((tail = readw(&chan0->mailbox->eout)) != (head = readw(&chan0->mailbox->ein))) | |
2016 | while ((tail = chan0->mailbox->eout) != (head = chan0->mailbox->ein)) | ||
2017 | { /* Begin while something in event queue */ | 1740 | { /* Begin while something in event queue */ |
2018 | |||
2019 | assertgwinon(chan0); | 1741 | assertgwinon(chan0); |
2020 | 1742 | eventbuf = bd->re_map_membase + tail + ISTART; | |
2021 | eventbuf = (volatile unchar *)bus_to_virt((ulong)(bd->re_map_membase + tail + ISTART)); | ||
2022 | |||
2023 | /* Get the channel the event occurred on */ | 1743 | /* Get the channel the event occurred on */ |
2024 | channel = eventbuf[0]; | 1744 | channel = readb(eventbuf); |
2025 | |||
2026 | /* Get the actual event code that occurred */ | 1745 | /* Get the actual event code that occurred */ |
2027 | event = eventbuf[1]; | 1746 | event = readb(eventbuf + 1); |
2028 | |||
2029 | /* ---------------------------------------------------------------- | 1747 | /* ---------------------------------------------------------------- |
2030 | The two assignments below get the current modem status (mstat) | 1748 | The two assignments below get the current modem status (mstat) |
2031 | and the previous modem status (lstat). These are useful becuase | 1749 | and the previous modem status (lstat). These are useful becuase |
2032 | an event could signal a change in modem signals itself. | 1750 | an event could signal a change in modem signals itself. |
2033 | ------------------------------------------------------------------- */ | 1751 | ------------------------------------------------------------------- */ |
2034 | 1752 | mstat = readb(eventbuf + 2); | |
2035 | mstat = eventbuf[2]; | 1753 | lstat = readb(eventbuf + 3); |
2036 | lstat = eventbuf[3]; | ||
2037 | 1754 | ||
2038 | ch = chan0 + channel; | 1755 | ch = chan0 + channel; |
2039 | 1756 | if ((unsigned)channel >= bd->numports || !ch) { | |
2040 | if ((unsigned)channel >= bd->numports || !ch) | ||
2041 | { | ||
2042 | if (channel >= bd->numports) | 1757 | if (channel >= bd->numports) |
2043 | ch = chan0; | 1758 | ch = chan0; |
2044 | bc = ch->brdchan; | 1759 | bc = ch->brdchan; |
@@ -2048,97 +1763,53 @@ static void doevent(int crd) | |||
2048 | if ((bc = ch->brdchan) == NULL) | 1763 | if ((bc = ch->brdchan) == NULL) |
2049 | goto next; | 1764 | goto next; |
2050 | 1765 | ||
2051 | if (event & DATA_IND) | 1766 | if (event & DATA_IND) { /* Begin DATA_IND */ |
2052 | { /* Begin DATA_IND */ | ||
2053 | |||
2054 | receive_data(ch); | 1767 | receive_data(ch); |
2055 | assertgwinon(ch); | 1768 | assertgwinon(ch); |
2056 | |||
2057 | } /* End DATA_IND */ | 1769 | } /* End DATA_IND */ |
2058 | /* else *//* Fix for DCD transition missed bug */ | 1770 | /* else *//* Fix for DCD transition missed bug */ |
2059 | if (event & MODEMCHG_IND) | 1771 | if (event & MODEMCHG_IND) { /* Begin MODEMCHG_IND */ |
2060 | { /* Begin MODEMCHG_IND */ | ||
2061 | |||
2062 | /* A modem signal change has been indicated */ | 1772 | /* A modem signal change has been indicated */ |
2063 | |||
2064 | ch->imodem = mstat; | 1773 | ch->imodem = mstat; |
2065 | 1774 | if (ch->asyncflags & ASYNC_CHECK_CD) { | |
2066 | if (ch->asyncflags & ASYNC_CHECK_CD) | ||
2067 | { | ||
2068 | if (mstat & ch->dcd) /* We are now receiving dcd */ | 1775 | if (mstat & ch->dcd) /* We are now receiving dcd */ |
2069 | wake_up_interruptible(&ch->open_wait); | 1776 | wake_up_interruptible(&ch->open_wait); |
2070 | else | 1777 | else |
2071 | pc_sched_event(ch, EPCA_EVENT_HANGUP); /* No dcd; hangup */ | 1778 | pc_sched_event(ch, EPCA_EVENT_HANGUP); /* No dcd; hangup */ |
2072 | } | 1779 | } |
2073 | |||
2074 | } /* End MODEMCHG_IND */ | 1780 | } /* End MODEMCHG_IND */ |
2075 | |||
2076 | tty = ch->tty; | 1781 | tty = ch->tty; |
2077 | if (tty) | 1782 | if (tty) { /* Begin if valid tty */ |
2078 | { /* Begin if valid tty */ | 1783 | if (event & BREAK_IND) { /* Begin if BREAK_IND */ |
2079 | |||
2080 | if (event & BREAK_IND) | ||
2081 | { /* Begin if BREAK_IND */ | ||
2082 | |||
2083 | /* A break has been indicated */ | 1784 | /* A break has been indicated */ |
2084 | |||
2085 | tty->flip.count++; | 1785 | tty->flip.count++; |
2086 | *tty->flip.flag_buf_ptr++ = TTY_BREAK; | 1786 | *tty->flip.flag_buf_ptr++ = TTY_BREAK; |
2087 | |||
2088 | *tty->flip.char_buf_ptr++ = 0; | 1787 | *tty->flip.char_buf_ptr++ = 0; |
2089 | |||
2090 | tty_schedule_flip(tty); | 1788 | tty_schedule_flip(tty); |
2091 | 1789 | } else if (event & LOWTX_IND) { /* Begin LOWTX_IND */ | |
2092 | } /* End if BREAK_IND */ | ||
2093 | else | ||
2094 | if (event & LOWTX_IND) | ||
2095 | { /* Begin LOWTX_IND */ | ||
2096 | |||
2097 | if (ch->statusflags & LOWWAIT) | 1790 | if (ch->statusflags & LOWWAIT) |
2098 | { /* Begin if LOWWAIT */ | 1791 | { /* Begin if LOWWAIT */ |
2099 | |||
2100 | ch->statusflags &= ~LOWWAIT; | 1792 | ch->statusflags &= ~LOWWAIT; |
2101 | tty_wakeup(tty); | 1793 | tty_wakeup(tty); |
2102 | wake_up_interruptible(&tty->write_wait); | 1794 | wake_up_interruptible(&tty->write_wait); |
2103 | |||
2104 | } /* End if LOWWAIT */ | 1795 | } /* End if LOWWAIT */ |
2105 | 1796 | } else if (event & EMPTYTX_IND) { /* Begin EMPTYTX_IND */ | |
2106 | } /* End LOWTX_IND */ | ||
2107 | else | ||
2108 | if (event & EMPTYTX_IND) | ||
2109 | { /* Begin EMPTYTX_IND */ | ||
2110 | |||
2111 | /* This event is generated by setup_empty_event */ | 1797 | /* This event is generated by setup_empty_event */ |
2112 | |||
2113 | ch->statusflags &= ~TXBUSY; | 1798 | ch->statusflags &= ~TXBUSY; |
2114 | if (ch->statusflags & EMPTYWAIT) | 1799 | if (ch->statusflags & EMPTYWAIT) { /* Begin if EMPTYWAIT */ |
2115 | { /* Begin if EMPTYWAIT */ | ||
2116 | |||
2117 | ch->statusflags &= ~EMPTYWAIT; | 1800 | ch->statusflags &= ~EMPTYWAIT; |
2118 | tty_wakeup(tty); | 1801 | tty_wakeup(tty); |
2119 | |||
2120 | wake_up_interruptible(&tty->write_wait); | 1802 | wake_up_interruptible(&tty->write_wait); |
2121 | |||
2122 | } /* End if EMPTYWAIT */ | 1803 | } /* End if EMPTYWAIT */ |
2123 | |||
2124 | } /* End EMPTYTX_IND */ | 1804 | } /* End EMPTYTX_IND */ |
2125 | |||
2126 | } /* End if valid tty */ | 1805 | } /* End if valid tty */ |
2127 | |||
2128 | |||
2129 | next: | 1806 | next: |
2130 | globalwinon(ch); | 1807 | globalwinon(ch); |
2131 | 1808 | BUG_ON(!bc); | |
2132 | if (!bc) | 1809 | writew(1, &bc->idata); |
2133 | printk(KERN_ERR "<Error> - bc == NULL in doevent!\n"); | 1810 | writew((tail + 4) & (IMAX - ISTART - 4), &chan0->mailbox->eout); |
2134 | else | ||
2135 | bc->idata = 1; | ||
2136 | |||
2137 | chan0->mailbox->eout = (tail + 4) & (IMAX - ISTART - 4); | ||
2138 | globalwinon(chan0); | 1811 | globalwinon(chan0); |
2139 | |||
2140 | } /* End while something in event queue */ | 1812 | } /* End while something in event queue */ |
2141 | |||
2142 | } /* End doevent */ | 1813 | } /* End doevent */ |
2143 | 1814 | ||
2144 | /* --------------------- Begin fepcmd ------------------------ */ | 1815 | /* --------------------- Begin fepcmd ------------------------ */ |
@@ -2146,7 +1817,6 @@ static void doevent(int crd) | |||
2146 | static void fepcmd(struct channel *ch, int cmd, int word_or_byte, | 1817 | static void fepcmd(struct channel *ch, int cmd, int word_or_byte, |
2147 | int byte2, int ncmds, int bytecmd) | 1818 | int byte2, int ncmds, int bytecmd) |
2148 | { /* Begin fepcmd */ | 1819 | { /* Begin fepcmd */ |
2149 | |||
2150 | unchar *memaddr; | 1820 | unchar *memaddr; |
2151 | unsigned int head, cmdTail, cmdStart, cmdMax; | 1821 | unsigned int head, cmdTail, cmdStart, cmdMax; |
2152 | long count; | 1822 | long count; |
@@ -2155,93 +1825,57 @@ static void fepcmd(struct channel *ch, int cmd, int word_or_byte, | |||
2155 | /* This is the routine in which commands may be passed to the card. */ | 1825 | /* This is the routine in which commands may be passed to the card. */ |
2156 | 1826 | ||
2157 | if (ch->board->status == DISABLED) | 1827 | if (ch->board->status == DISABLED) |
2158 | { | ||
2159 | return; | 1828 | return; |
2160 | } | ||
2161 | |||
2162 | assertgwinon(ch); | 1829 | assertgwinon(ch); |
2163 | |||
2164 | /* Remember head (As well as max) is just an offset not a base addr */ | 1830 | /* Remember head (As well as max) is just an offset not a base addr */ |
2165 | head = ch->mailbox->cin; | 1831 | head = readw(&ch->mailbox->cin); |
2166 | |||
2167 | /* cmdStart is a base address */ | 1832 | /* cmdStart is a base address */ |
2168 | cmdStart = ch->mailbox->cstart; | 1833 | cmdStart = readw(&ch->mailbox->cstart); |
2169 | |||
2170 | /* ------------------------------------------------------------------ | 1834 | /* ------------------------------------------------------------------ |
2171 | We do the addition below because we do not want a max pointer | 1835 | We do the addition below because we do not want a max pointer |
2172 | relative to cmdStart. We want a max pointer that points at the | 1836 | relative to cmdStart. We want a max pointer that points at the |
2173 | physical end of the command queue. | 1837 | physical end of the command queue. |
2174 | -------------------------------------------------------------------- */ | 1838 | -------------------------------------------------------------------- */ |
2175 | 1839 | cmdMax = (cmdStart + 4 + readw(&ch->mailbox->cmax)); | |
2176 | cmdMax = (cmdStart + 4 + (ch->mailbox->cmax)); | ||
2177 | |||
2178 | memaddr = ch->board->re_map_membase; | 1840 | memaddr = ch->board->re_map_membase; |
2179 | 1841 | ||
2180 | /* | 1842 | if (head >= (cmdMax - cmdStart) || (head & 03)) { |
2181 | The below command is necessary because newer kernels (2.1.x and | 1843 | printk(KERN_ERR "line %d: Out of range, cmd = %x, head = %x\n", __LINE__, cmd, head); |
2182 | up) do not have a 1:1 virtual to physical mapping. The below | 1844 | printk(KERN_ERR "line %d: Out of range, cmdMax = %x, cmdStart = %x\n", __LINE__, cmdMax, cmdStart); |
2183 | call adjust for that. | ||
2184 | */ | ||
2185 | |||
2186 | memaddr = (unsigned char *)bus_to_virt((unsigned long)memaddr); | ||
2187 | |||
2188 | if (head >= (cmdMax - cmdStart) || (head & 03)) | ||
2189 | { | ||
2190 | printk(KERN_ERR "line %d: Out of range, cmd = %x, head = %x\n", __LINE__, | ||
2191 | cmd, head); | ||
2192 | printk(KERN_ERR "line %d: Out of range, cmdMax = %x, cmdStart = %x\n", __LINE__, | ||
2193 | cmdMax, cmdStart); | ||
2194 | return; | 1845 | return; |
2195 | } | 1846 | } |
2196 | 1847 | if (bytecmd) { | |
2197 | if (bytecmd) | 1848 | writeb(cmd, memaddr + head + cmdStart + 0); |
2198 | { | 1849 | writeb(ch->channelnum, memaddr + head + cmdStart + 1); |
2199 | *(volatile unchar *)(memaddr + head + cmdStart + 0) = (unchar)cmd; | ||
2200 | |||
2201 | *(volatile unchar *)(memaddr + head + cmdStart + 1) = (unchar)ch->channelnum; | ||
2202 | /* Below word_or_byte is bits to set */ | 1850 | /* Below word_or_byte is bits to set */ |
2203 | *(volatile unchar *)(memaddr + head + cmdStart + 2) = (unchar)word_or_byte; | 1851 | writeb(word_or_byte, memaddr + head + cmdStart + 2); |
2204 | /* Below byte2 is bits to reset */ | 1852 | /* Below byte2 is bits to reset */ |
2205 | *(volatile unchar *)(memaddr + head + cmdStart + 3) = (unchar)byte2; | 1853 | writeb(byte2, memaddr + head + cmdStart + 3); |
2206 | 1854 | } else { | |
2207 | } | 1855 | writeb(cmd, memaddr + head + cmdStart + 0); |
2208 | else | 1856 | writeb(ch->channelnum, memaddr + head + cmdStart + 1); |
2209 | { | 1857 | writeb(word_or_byte, memaddr + head + cmdStart + 2); |
2210 | *(volatile unchar *)(memaddr + head + cmdStart + 0) = (unchar)cmd; | ||
2211 | *(volatile unchar *)(memaddr + head + cmdStart + 1) = (unchar)ch->channelnum; | ||
2212 | *(volatile ushort*)(memaddr + head + cmdStart + 2) = (ushort)word_or_byte; | ||
2213 | } | 1858 | } |
2214 | |||
2215 | head = (head + 4) & (cmdMax - cmdStart - 4); | 1859 | head = (head + 4) & (cmdMax - cmdStart - 4); |
2216 | ch->mailbox->cin = head; | 1860 | writew(head, &ch->mailbox->cin); |
2217 | |||
2218 | count = FEPTIMEOUT; | 1861 | count = FEPTIMEOUT; |
2219 | 1862 | ||
2220 | for (;;) | 1863 | for (;;) { /* Begin forever loop */ |
2221 | { /* Begin forever loop */ | ||
2222 | |||
2223 | count--; | 1864 | count--; |
2224 | if (count == 0) | 1865 | if (count == 0) { |
2225 | { | ||
2226 | printk(KERN_ERR "<Error> - Fep not responding in fepcmd()\n"); | 1866 | printk(KERN_ERR "<Error> - Fep not responding in fepcmd()\n"); |
2227 | return; | 1867 | return; |
2228 | } | 1868 | } |
2229 | 1869 | head = readw(&ch->mailbox->cin); | |
2230 | head = ch->mailbox->cin; | 1870 | cmdTail = readw(&ch->mailbox->cout); |
2231 | cmdTail = ch->mailbox->cout; | ||
2232 | |||
2233 | n = (head - cmdTail) & (cmdMax - cmdStart - 4); | 1871 | n = (head - cmdTail) & (cmdMax - cmdStart - 4); |
2234 | |||
2235 | /* ---------------------------------------------------------- | 1872 | /* ---------------------------------------------------------- |
2236 | Basically this will break when the FEP acknowledges the | 1873 | Basically this will break when the FEP acknowledges the |
2237 | command by incrementing cmdTail (Making it equal to head). | 1874 | command by incrementing cmdTail (Making it equal to head). |
2238 | ------------------------------------------------------------- */ | 1875 | ------------------------------------------------------------- */ |
2239 | |||
2240 | if (n <= ncmds * (sizeof(short) * 4)) | 1876 | if (n <= ncmds * (sizeof(short) * 4)) |
2241 | break; /* Well nearly forever :-) */ | 1877 | break; /* Well nearly forever :-) */ |
2242 | |||
2243 | } /* End forever loop */ | 1878 | } /* End forever loop */ |
2244 | |||
2245 | } /* End fepcmd */ | 1879 | } /* End fepcmd */ |
2246 | 1880 | ||
2247 | /* --------------------------------------------------------------------- | 1881 | /* --------------------------------------------------------------------- |
@@ -2255,11 +1889,9 @@ static void fepcmd(struct channel *ch, int cmd, int word_or_byte, | |||
2255 | 1889 | ||
2256 | static unsigned termios2digi_h(struct channel *ch, unsigned cflag) | 1890 | static unsigned termios2digi_h(struct channel *ch, unsigned cflag) |
2257 | { /* Begin termios2digi_h */ | 1891 | { /* Begin termios2digi_h */ |
2258 | |||
2259 | unsigned res = 0; | 1892 | unsigned res = 0; |
2260 | 1893 | ||
2261 | if (cflag & CRTSCTS) | 1894 | if (cflag & CRTSCTS) { |
2262 | { | ||
2263 | ch->digiext.digi_flags |= (RTSPACE | CTSPACE); | 1895 | ch->digiext.digi_flags |= (RTSPACE | CTSPACE); |
2264 | res |= ((ch->m_cts) | (ch->m_rts)); | 1896 | res |= ((ch->m_cts) | (ch->m_rts)); |
2265 | } | 1897 | } |
@@ -2295,7 +1927,6 @@ static unsigned termios2digi_i(struct channel *ch, unsigned iflag) | |||
2295 | 1927 | ||
2296 | unsigned res = iflag & (IGNBRK | BRKINT | IGNPAR | PARMRK | | 1928 | unsigned res = iflag & (IGNBRK | BRKINT | IGNPAR | PARMRK | |
2297 | INPCK | ISTRIP|IXON|IXANY|IXOFF); | 1929 | INPCK | ISTRIP|IXON|IXANY|IXOFF); |
2298 | |||
2299 | if (ch->digiext.digi_flags & DIGI_AIXON) | 1930 | if (ch->digiext.digi_flags & DIGI_AIXON) |
2300 | res |= IAIXON; | 1931 | res |= IAIXON; |
2301 | return res; | 1932 | return res; |
@@ -2308,28 +1939,15 @@ static unsigned termios2digi_c(struct channel *ch, unsigned cflag) | |||
2308 | { /* Begin termios2digi_c */ | 1939 | { /* Begin termios2digi_c */ |
2309 | 1940 | ||
2310 | unsigned res = 0; | 1941 | unsigned res = 0; |
2311 | 1942 | if (cflag & CBAUDEX) { /* Begin detected CBAUDEX */ | |
2312 | #ifdef SPEED_HACK | ||
2313 | /* CL: HACK to force 115200 at 38400 and 57600 at 19200 Baud */ | ||
2314 | if ((cflag & CBAUD)== B38400) cflag=cflag - B38400 + B115200; | ||
2315 | if ((cflag & CBAUD)== B19200) cflag=cflag - B19200 + B57600; | ||
2316 | #endif /* SPEED_HACK */ | ||
2317 | |||
2318 | if (cflag & CBAUDEX) | ||
2319 | { /* Begin detected CBAUDEX */ | ||
2320 | |||
2321 | ch->digiext.digi_flags |= DIGI_FAST; | 1943 | ch->digiext.digi_flags |= DIGI_FAST; |
2322 | |||
2323 | /* ------------------------------------------------------------- | 1944 | /* ------------------------------------------------------------- |
2324 | HUPCL bit is used by FEP to indicate fast baud | 1945 | HUPCL bit is used by FEP to indicate fast baud |
2325 | table is to be used. | 1946 | table is to be used. |
2326 | ----------------------------------------------------------------- */ | 1947 | ----------------------------------------------------------------- */ |
2327 | |||
2328 | res |= FEP_HUPCL; | 1948 | res |= FEP_HUPCL; |
2329 | |||
2330 | } /* End detected CBAUDEX */ | 1949 | } /* End detected CBAUDEX */ |
2331 | else ch->digiext.digi_flags &= ~DIGI_FAST; | 1950 | else ch->digiext.digi_flags &= ~DIGI_FAST; |
2332 | |||
2333 | /* ------------------------------------------------------------------- | 1951 | /* ------------------------------------------------------------------- |
2334 | CBAUD has bit position 0x1000 set these days to indicate Linux | 1952 | CBAUD has bit position 0x1000 set these days to indicate Linux |
2335 | baud rate remap. Digi hardware can't handle the bit assignment. | 1953 | baud rate remap. Digi hardware can't handle the bit assignment. |
@@ -2337,7 +1955,6 @@ static unsigned termios2digi_c(struct channel *ch, unsigned cflag) | |||
2337 | bit out. | 1955 | bit out. |
2338 | ---------------------------------------------------------------------- */ | 1956 | ---------------------------------------------------------------------- */ |
2339 | res |= cflag & ((CBAUD ^ CBAUDEX) | PARODD | PARENB | CSTOPB | CSIZE); | 1957 | res |= cflag & ((CBAUD ^ CBAUDEX) | PARODD | PARENB | CSTOPB | CSIZE); |
2340 | |||
2341 | /* ------------------------------------------------------------- | 1958 | /* ------------------------------------------------------------- |
2342 | This gets a little confusing. The Digi cards have their own | 1959 | This gets a little confusing. The Digi cards have their own |
2343 | representation of c_cflags controling baud rate. For the most | 1960 | representation of c_cflags controling baud rate. For the most |
@@ -2357,10 +1974,8 @@ static unsigned termios2digi_c(struct channel *ch, unsigned cflag) | |||
2357 | should be checked for a screened out prior to termios2digi_c | 1974 | should be checked for a screened out prior to termios2digi_c |
2358 | returning. Since CLOCAL isn't used by the board this can be | 1975 | returning. Since CLOCAL isn't used by the board this can be |
2359 | ignored as long as the returned value is used only by Digi hardware. | 1976 | ignored as long as the returned value is used only by Digi hardware. |
2360 | ----------------------------------------------------------------- */ | 1977 | ----------------------------------------------------------------- */ |
2361 | 1978 | if (cflag & CBAUDEX) { | |
2362 | if (cflag & CBAUDEX) | ||
2363 | { | ||
2364 | /* ------------------------------------------------------------- | 1979 | /* ------------------------------------------------------------- |
2365 | The below code is trying to guarantee that only baud rates | 1980 | The below code is trying to guarantee that only baud rates |
2366 | 115200 and 230400 are remapped. We use exclusive or because | 1981 | 115200 and 230400 are remapped. We use exclusive or because |
@@ -2371,138 +1986,96 @@ static unsigned termios2digi_c(struct channel *ch, unsigned cflag) | |||
2371 | 1986 | ||
2372 | if ((!((cflag & 0x7) ^ (B115200 & ~CBAUDEX))) || | 1987 | if ((!((cflag & 0x7) ^ (B115200 & ~CBAUDEX))) || |
2373 | (!((cflag & 0x7) ^ (B230400 & ~CBAUDEX)))) | 1988 | (!((cflag & 0x7) ^ (B230400 & ~CBAUDEX)))) |
2374 | { | ||
2375 | res += 1; | 1989 | res += 1; |
2376 | } | ||
2377 | } | 1990 | } |
2378 | |||
2379 | return res; | 1991 | return res; |
2380 | 1992 | ||
2381 | } /* End termios2digi_c */ | 1993 | } /* End termios2digi_c */ |
2382 | 1994 | ||
2383 | /* --------------------- Begin epcaparam ----------------------- */ | 1995 | /* --------------------- Begin epcaparam ----------------------- */ |
2384 | 1996 | ||
1997 | /* Caller must hold the locks */ | ||
2385 | static void epcaparam(struct tty_struct *tty, struct channel *ch) | 1998 | static void epcaparam(struct tty_struct *tty, struct channel *ch) |
2386 | { /* Begin epcaparam */ | 1999 | { /* Begin epcaparam */ |
2387 | 2000 | ||
2388 | unsigned int cmdHead; | 2001 | unsigned int cmdHead; |
2389 | struct termios *ts; | 2002 | struct termios *ts; |
2390 | volatile struct board_chan *bc; | 2003 | struct board_chan *bc; |
2391 | unsigned mval, hflow, cflag, iflag; | 2004 | unsigned mval, hflow, cflag, iflag; |
2392 | 2005 | ||
2393 | bc = ch->brdchan; | 2006 | bc = ch->brdchan; |
2394 | epcaassert(bc !=0, "bc out of range"); | 2007 | epcaassert(bc !=0, "bc out of range"); |
2395 | 2008 | ||
2396 | assertgwinon(ch); | 2009 | assertgwinon(ch); |
2397 | |||
2398 | ts = tty->termios; | 2010 | ts = tty->termios; |
2399 | 2011 | if ((ts->c_cflag & CBAUD) == 0) { /* Begin CBAUD detected */ | |
2400 | if ((ts->c_cflag & CBAUD) == 0) | 2012 | cmdHead = readw(&bc->rin); |
2401 | { /* Begin CBAUD detected */ | ||
2402 | |||
2403 | cmdHead = bc->rin; | ||
2404 | bc->rout = cmdHead; | 2013 | bc->rout = cmdHead; |
2405 | cmdHead = bc->tin; | 2014 | cmdHead = readw(&bc->tin); |
2406 | |||
2407 | /* Changing baud in mid-stream transmission can be wonderful */ | 2015 | /* Changing baud in mid-stream transmission can be wonderful */ |
2408 | /* --------------------------------------------------------------- | 2016 | /* --------------------------------------------------------------- |
2409 | Flush current transmit buffer by setting cmdTail pointer (tout) | 2017 | Flush current transmit buffer by setting cmdTail pointer (tout) |
2410 | to cmdHead pointer (tin). Hopefully the transmit buffer is empty. | 2018 | to cmdHead pointer (tin). Hopefully the transmit buffer is empty. |
2411 | ----------------------------------------------------------------- */ | 2019 | ----------------------------------------------------------------- */ |
2412 | |||
2413 | fepcmd(ch, STOUT, (unsigned) cmdHead, 0, 0, 0); | 2020 | fepcmd(ch, STOUT, (unsigned) cmdHead, 0, 0, 0); |
2414 | mval = 0; | 2021 | mval = 0; |
2415 | 2022 | } else { /* Begin CBAUD not detected */ | |
2416 | } /* End CBAUD detected */ | ||
2417 | else | ||
2418 | { /* Begin CBAUD not detected */ | ||
2419 | |||
2420 | /* ------------------------------------------------------------------- | 2023 | /* ------------------------------------------------------------------- |
2421 | c_cflags have changed but that change had nothing to do with BAUD. | 2024 | c_cflags have changed but that change had nothing to do with BAUD. |
2422 | Propagate the change to the card. | 2025 | Propagate the change to the card. |
2423 | ---------------------------------------------------------------------- */ | 2026 | ---------------------------------------------------------------------- */ |
2424 | |||
2425 | cflag = termios2digi_c(ch, ts->c_cflag); | 2027 | cflag = termios2digi_c(ch, ts->c_cflag); |
2426 | 2028 | if (cflag != ch->fepcflag) { | |
2427 | if (cflag != ch->fepcflag) | ||
2428 | { | ||
2429 | ch->fepcflag = cflag; | 2029 | ch->fepcflag = cflag; |
2430 | /* Set baud rate, char size, stop bits, parity */ | 2030 | /* Set baud rate, char size, stop bits, parity */ |
2431 | fepcmd(ch, SETCTRLFLAGS, (unsigned) cflag, 0, 0, 0); | 2031 | fepcmd(ch, SETCTRLFLAGS, (unsigned) cflag, 0, 0, 0); |
2432 | } | 2032 | } |
2433 | |||
2434 | |||
2435 | /* ---------------------------------------------------------------- | 2033 | /* ---------------------------------------------------------------- |
2436 | If the user has not forced CLOCAL and if the device is not a | 2034 | If the user has not forced CLOCAL and if the device is not a |
2437 | CALLOUT device (Which is always CLOCAL) we set flags such that | 2035 | CALLOUT device (Which is always CLOCAL) we set flags such that |
2438 | the driver will wait on carrier detect. | 2036 | the driver will wait on carrier detect. |
2439 | ------------------------------------------------------------------- */ | 2037 | ------------------------------------------------------------------- */ |
2440 | |||
2441 | if (ts->c_cflag & CLOCAL) | 2038 | if (ts->c_cflag & CLOCAL) |
2442 | { /* Begin it is a cud device or a ttyD device with CLOCAL on */ | ||
2443 | ch->asyncflags &= ~ASYNC_CHECK_CD; | 2039 | ch->asyncflags &= ~ASYNC_CHECK_CD; |
2444 | } /* End it is a cud device or a ttyD device with CLOCAL on */ | ||
2445 | else | 2040 | else |
2446 | { /* Begin it is a ttyD device */ | ||
2447 | ch->asyncflags |= ASYNC_CHECK_CD; | 2041 | ch->asyncflags |= ASYNC_CHECK_CD; |
2448 | } /* End it is a ttyD device */ | ||
2449 | |||
2450 | mval = ch->m_dtr | ch->m_rts; | 2042 | mval = ch->m_dtr | ch->m_rts; |
2451 | |||
2452 | } /* End CBAUD not detected */ | 2043 | } /* End CBAUD not detected */ |
2453 | |||
2454 | iflag = termios2digi_i(ch, ts->c_iflag); | 2044 | iflag = termios2digi_i(ch, ts->c_iflag); |
2455 | |||
2456 | /* Check input mode flags */ | 2045 | /* Check input mode flags */ |
2457 | 2046 | if (iflag != ch->fepiflag) { | |
2458 | if (iflag != ch->fepiflag) | ||
2459 | { | ||
2460 | ch->fepiflag = iflag; | 2047 | ch->fepiflag = iflag; |
2461 | |||
2462 | /* --------------------------------------------------------------- | 2048 | /* --------------------------------------------------------------- |
2463 | Command sets channels iflag structure on the board. Such things | 2049 | Command sets channels iflag structure on the board. Such things |
2464 | as input soft flow control, handling of parity errors, and | 2050 | as input soft flow control, handling of parity errors, and |
2465 | break handling are all set here. | 2051 | break handling are all set here. |
2466 | ------------------------------------------------------------------- */ | 2052 | ------------------------------------------------------------------- */ |
2467 | |||
2468 | /* break handling, parity handling, input stripping, flow control chars */ | 2053 | /* break handling, parity handling, input stripping, flow control chars */ |
2469 | fepcmd(ch, SETIFLAGS, (unsigned int) ch->fepiflag, 0, 0, 0); | 2054 | fepcmd(ch, SETIFLAGS, (unsigned int) ch->fepiflag, 0, 0, 0); |
2470 | } | 2055 | } |
2471 | |||
2472 | /* --------------------------------------------------------------- | 2056 | /* --------------------------------------------------------------- |
2473 | Set the board mint value for this channel. This will cause hardware | 2057 | Set the board mint value for this channel. This will cause hardware |
2474 | events to be generated each time the DCD signal (Described in mint) | 2058 | events to be generated each time the DCD signal (Described in mint) |
2475 | changes. | 2059 | changes. |
2476 | ------------------------------------------------------------------- */ | 2060 | ------------------------------------------------------------------- */ |
2477 | bc->mint = ch->dcd; | 2061 | writeb(ch->dcd, &bc->mint); |
2478 | |||
2479 | if ((ts->c_cflag & CLOCAL) || (ch->digiext.digi_flags & DIGI_FORCEDCD)) | 2062 | if ((ts->c_cflag & CLOCAL) || (ch->digiext.digi_flags & DIGI_FORCEDCD)) |
2480 | if (ch->digiext.digi_flags & DIGI_FORCEDCD) | 2063 | if (ch->digiext.digi_flags & DIGI_FORCEDCD) |
2481 | bc->mint = 0; | 2064 | writeb(0, &bc->mint); |
2482 | 2065 | ch->imodem = readb(&bc->mstat); | |
2483 | ch->imodem = bc->mstat; | ||
2484 | |||
2485 | hflow = termios2digi_h(ch, ts->c_cflag); | 2066 | hflow = termios2digi_h(ch, ts->c_cflag); |
2486 | 2067 | if (hflow != ch->hflow) { | |
2487 | if (hflow != ch->hflow) | ||
2488 | { | ||
2489 | ch->hflow = hflow; | 2068 | ch->hflow = hflow; |
2490 | |||
2491 | /* -------------------------------------------------------------- | 2069 | /* -------------------------------------------------------------- |
2492 | Hard flow control has been selected but the board is not | 2070 | Hard flow control has been selected but the board is not |
2493 | using it. Activate hard flow control now. | 2071 | using it. Activate hard flow control now. |
2494 | ----------------------------------------------------------------- */ | 2072 | ----------------------------------------------------------------- */ |
2495 | |||
2496 | fepcmd(ch, SETHFLOW, hflow, 0xff, 0, 1); | 2073 | fepcmd(ch, SETHFLOW, hflow, 0xff, 0, 1); |
2497 | } | 2074 | } |
2498 | |||
2499 | |||
2500 | mval ^= ch->modemfake & (mval ^ ch->modem); | 2075 | mval ^= ch->modemfake & (mval ^ ch->modem); |
2501 | 2076 | ||
2502 | if (ch->omodem ^ mval) | 2077 | if (ch->omodem ^ mval) { |
2503 | { | ||
2504 | ch->omodem = mval; | 2078 | ch->omodem = mval; |
2505 | |||
2506 | /* -------------------------------------------------------------- | 2079 | /* -------------------------------------------------------------- |
2507 | The below command sets the DTR and RTS mstat structure. If | 2080 | The below command sets the DTR and RTS mstat structure. If |
2508 | hard flow control is NOT active these changes will drive the | 2081 | hard flow control is NOT active these changes will drive the |
@@ -2514,87 +2087,65 @@ static void epcaparam(struct tty_struct *tty, struct channel *ch) | |||
2514 | /* First reset DTR & RTS; then set them */ | 2087 | /* First reset DTR & RTS; then set them */ |
2515 | fepcmd(ch, SETMODEM, 0, ((ch->m_dtr)|(ch->m_rts)), 0, 1); | 2088 | fepcmd(ch, SETMODEM, 0, ((ch->m_dtr)|(ch->m_rts)), 0, 1); |
2516 | fepcmd(ch, SETMODEM, mval, 0, 0, 1); | 2089 | fepcmd(ch, SETMODEM, mval, 0, 0, 1); |
2517 | |||
2518 | } | 2090 | } |
2519 | 2091 | if (ch->startc != ch->fepstartc || ch->stopc != ch->fepstopc) { | |
2520 | if (ch->startc != ch->fepstartc || ch->stopc != ch->fepstopc) | ||
2521 | { | ||
2522 | ch->fepstartc = ch->startc; | 2092 | ch->fepstartc = ch->startc; |
2523 | ch->fepstopc = ch->stopc; | 2093 | ch->fepstopc = ch->stopc; |
2524 | |||
2525 | /* ------------------------------------------------------------ | 2094 | /* ------------------------------------------------------------ |
2526 | The XON / XOFF characters have changed; propagate these | 2095 | The XON / XOFF characters have changed; propagate these |
2527 | changes to the card. | 2096 | changes to the card. |
2528 | --------------------------------------------------------------- */ | 2097 | --------------------------------------------------------------- */ |
2529 | |||
2530 | fepcmd(ch, SONOFFC, ch->fepstartc, ch->fepstopc, 0, 1); | 2098 | fepcmd(ch, SONOFFC, ch->fepstartc, ch->fepstopc, 0, 1); |
2531 | } | 2099 | } |
2532 | 2100 | if (ch->startca != ch->fepstartca || ch->stopca != ch->fepstopca) { | |
2533 | if (ch->startca != ch->fepstartca || ch->stopca != ch->fepstopca) | ||
2534 | { | ||
2535 | ch->fepstartca = ch->startca; | 2101 | ch->fepstartca = ch->startca; |
2536 | ch->fepstopca = ch->stopca; | 2102 | ch->fepstopca = ch->stopca; |
2537 | |||
2538 | /* --------------------------------------------------------------- | 2103 | /* --------------------------------------------------------------- |
2539 | Similar to the above, this time the auxilarly XON / XOFF | 2104 | Similar to the above, this time the auxilarly XON / XOFF |
2540 | characters have changed; propagate these changes to the card. | 2105 | characters have changed; propagate these changes to the card. |
2541 | ------------------------------------------------------------------ */ | 2106 | ------------------------------------------------------------------ */ |
2542 | |||
2543 | fepcmd(ch, SAUXONOFFC, ch->fepstartca, ch->fepstopca, 0, 1); | 2107 | fepcmd(ch, SAUXONOFFC, ch->fepstartca, ch->fepstopca, 0, 1); |
2544 | } | 2108 | } |
2545 | |||
2546 | } /* End epcaparam */ | 2109 | } /* End epcaparam */ |
2547 | 2110 | ||
2548 | /* --------------------- Begin receive_data ----------------------- */ | 2111 | /* --------------------- Begin receive_data ----------------------- */ |
2549 | 2112 | /* Caller holds lock */ | |
2550 | static void receive_data(struct channel *ch) | 2113 | static void receive_data(struct channel *ch) |
2551 | { /* Begin receive_data */ | 2114 | { /* Begin receive_data */ |
2552 | 2115 | ||
2553 | unchar *rptr; | 2116 | unchar *rptr; |
2554 | struct termios *ts = NULL; | 2117 | struct termios *ts = NULL; |
2555 | struct tty_struct *tty; | 2118 | struct tty_struct *tty; |
2556 | volatile struct board_chan *bc; | 2119 | struct board_chan *bc; |
2557 | register int dataToRead, wrapgap, bytesAvailable; | 2120 | int dataToRead, wrapgap, bytesAvailable; |
2558 | register unsigned int tail, head; | 2121 | unsigned int tail, head; |
2559 | unsigned int wrapmask; | 2122 | unsigned int wrapmask; |
2560 | int rc; | 2123 | int rc; |
2561 | 2124 | ||
2562 | |||
2563 | /* --------------------------------------------------------------- | 2125 | /* --------------------------------------------------------------- |
2564 | This routine is called by doint when a receive data event | 2126 | This routine is called by doint when a receive data event |
2565 | has taken place. | 2127 | has taken place. |
2566 | ------------------------------------------------------------------- */ | 2128 | ------------------------------------------------------------------- */ |
2567 | 2129 | ||
2568 | globalwinon(ch); | 2130 | globalwinon(ch); |
2569 | |||
2570 | if (ch->statusflags & RXSTOPPED) | 2131 | if (ch->statusflags & RXSTOPPED) |
2571 | return; | 2132 | return; |
2572 | |||
2573 | tty = ch->tty; | 2133 | tty = ch->tty; |
2574 | if (tty) | 2134 | if (tty) |
2575 | ts = tty->termios; | 2135 | ts = tty->termios; |
2576 | |||
2577 | bc = ch->brdchan; | 2136 | bc = ch->brdchan; |
2578 | 2137 | BUG_ON(!bc); | |
2579 | if (!bc) | ||
2580 | { | ||
2581 | printk(KERN_ERR "<Error> - bc is NULL in receive_data!\n"); | ||
2582 | return; | ||
2583 | } | ||
2584 | |||
2585 | wrapmask = ch->rxbufsize - 1; | 2138 | wrapmask = ch->rxbufsize - 1; |
2586 | 2139 | ||
2587 | /* --------------------------------------------------------------------- | 2140 | /* --------------------------------------------------------------------- |
2588 | Get the head and tail pointers to the receiver queue. Wrap the | 2141 | Get the head and tail pointers to the receiver queue. Wrap the |
2589 | head pointer if it has reached the end of the buffer. | 2142 | head pointer if it has reached the end of the buffer. |
2590 | ------------------------------------------------------------------------ */ | 2143 | ------------------------------------------------------------------------ */ |
2591 | 2144 | head = readw(&bc->rin); | |
2592 | head = bc->rin; | ||
2593 | head &= wrapmask; | 2145 | head &= wrapmask; |
2594 | tail = bc->rout & wrapmask; | 2146 | tail = readw(&bc->rout) & wrapmask; |
2595 | 2147 | ||
2596 | bytesAvailable = (head - tail) & wrapmask; | 2148 | bytesAvailable = (head - tail) & wrapmask; |
2597 | |||
2598 | if (bytesAvailable == 0) | 2149 | if (bytesAvailable == 0) |
2599 | return; | 2150 | return; |
2600 | 2151 | ||
@@ -2602,8 +2153,7 @@ static void receive_data(struct channel *ch) | |||
2602 | If CREAD bit is off or device not open, set TX tail to head | 2153 | If CREAD bit is off or device not open, set TX tail to head |
2603 | --------------------------------------------------------------------- */ | 2154 | --------------------------------------------------------------------- */ |
2604 | 2155 | ||
2605 | if (!tty || !ts || !(ts->c_cflag & CREAD)) | 2156 | if (!tty || !ts || !(ts->c_cflag & CREAD)) { |
2606 | { | ||
2607 | bc->rout = head; | 2157 | bc->rout = head; |
2608 | return; | 2158 | return; |
2609 | } | 2159 | } |
@@ -2611,64 +2161,45 @@ static void receive_data(struct channel *ch) | |||
2611 | if (tty->flip.count == TTY_FLIPBUF_SIZE) | 2161 | if (tty->flip.count == TTY_FLIPBUF_SIZE) |
2612 | return; | 2162 | return; |
2613 | 2163 | ||
2614 | if (bc->orun) | 2164 | if (readb(&bc->orun)) { |
2615 | { | 2165 | writeb(0, &bc->orun); |
2616 | bc->orun = 0; | 2166 | printk(KERN_WARNING "epca; overrun! DigiBoard device %s\n",tty->name); |
2617 | printk(KERN_WARNING "overrun! DigiBoard device %s\n",tty->name); | ||
2618 | } | 2167 | } |
2619 | |||
2620 | rxwinon(ch); | 2168 | rxwinon(ch); |
2621 | rptr = tty->flip.char_buf_ptr; | 2169 | rptr = tty->flip.char_buf_ptr; |
2622 | rc = tty->flip.count; | 2170 | rc = tty->flip.count; |
2623 | 2171 | while (bytesAvailable > 0) { /* Begin while there is data on the card */ | |
2624 | while (bytesAvailable > 0) | ||
2625 | { /* Begin while there is data on the card */ | ||
2626 | |||
2627 | wrapgap = (head >= tail) ? head - tail : ch->rxbufsize - tail; | 2172 | wrapgap = (head >= tail) ? head - tail : ch->rxbufsize - tail; |
2628 | |||
2629 | /* --------------------------------------------------------------- | 2173 | /* --------------------------------------------------------------- |
2630 | Even if head has wrapped around only report the amount of | 2174 | Even if head has wrapped around only report the amount of |
2631 | data to be equal to the size - tail. Remember memcpy can't | 2175 | data to be equal to the size - tail. Remember memcpy can't |
2632 | automaticly wrap around the receive buffer. | 2176 | automaticly wrap around the receive buffer. |
2633 | ----------------------------------------------------------------- */ | 2177 | ----------------------------------------------------------------- */ |
2634 | |||
2635 | dataToRead = (wrapgap < bytesAvailable) ? wrapgap : bytesAvailable; | 2178 | dataToRead = (wrapgap < bytesAvailable) ? wrapgap : bytesAvailable; |
2636 | |||
2637 | /* -------------------------------------------------------------- | 2179 | /* -------------------------------------------------------------- |
2638 | Make sure we don't overflow the buffer | 2180 | Make sure we don't overflow the buffer |
2639 | ----------------------------------------------------------------- */ | 2181 | ----------------------------------------------------------------- */ |
2640 | |||
2641 | if ((rc + dataToRead) > TTY_FLIPBUF_SIZE) | 2182 | if ((rc + dataToRead) > TTY_FLIPBUF_SIZE) |
2642 | dataToRead = TTY_FLIPBUF_SIZE - rc; | 2183 | dataToRead = TTY_FLIPBUF_SIZE - rc; |
2643 | |||
2644 | if (dataToRead == 0) | 2184 | if (dataToRead == 0) |
2645 | break; | 2185 | break; |
2646 | |||
2647 | /* --------------------------------------------------------------- | 2186 | /* --------------------------------------------------------------- |
2648 | Move data read from our card into the line disciplines buffer | 2187 | Move data read from our card into the line disciplines buffer |
2649 | for translation if necessary. | 2188 | for translation if necessary. |
2650 | ------------------------------------------------------------------ */ | 2189 | ------------------------------------------------------------------ */ |
2651 | 2190 | memcpy_fromio(rptr, ch->rxptr + tail, dataToRead); | |
2652 | if ((memcpy(rptr, ch->rxptr + tail, dataToRead)) != rptr) | ||
2653 | printk(KERN_ERR "<Error> - receive_data : memcpy failed\n"); | ||
2654 | |||
2655 | rc += dataToRead; | 2191 | rc += dataToRead; |
2656 | rptr += dataToRead; | 2192 | rptr += dataToRead; |
2657 | tail = (tail + dataToRead) & wrapmask; | 2193 | tail = (tail + dataToRead) & wrapmask; |
2658 | bytesAvailable -= dataToRead; | 2194 | bytesAvailable -= dataToRead; |
2659 | |||
2660 | } /* End while there is data on the card */ | 2195 | } /* End while there is data on the card */ |
2661 | |||
2662 | |||
2663 | tty->flip.count = rc; | 2196 | tty->flip.count = rc; |
2664 | tty->flip.char_buf_ptr = rptr; | 2197 | tty->flip.char_buf_ptr = rptr; |
2665 | globalwinon(ch); | 2198 | globalwinon(ch); |
2666 | bc->rout = tail; | 2199 | writew(tail, &bc->rout); |
2667 | |||
2668 | /* Must be called with global data */ | 2200 | /* Must be called with global data */ |
2669 | tty_schedule_flip(ch->tty); | 2201 | tty_schedule_flip(ch->tty); |
2670 | return; | 2202 | return; |
2671 | |||
2672 | } /* End receive_data */ | 2203 | } /* End receive_data */ |
2673 | 2204 | ||
2674 | static int info_ioctl(struct tty_struct *tty, struct file * file, | 2205 | static int info_ioctl(struct tty_struct *tty, struct file * file, |
@@ -2676,17 +2207,15 @@ static int info_ioctl(struct tty_struct *tty, struct file * file, | |||
2676 | { | 2207 | { |
2677 | switch (cmd) | 2208 | switch (cmd) |
2678 | { /* Begin switch cmd */ | 2209 | { /* Begin switch cmd */ |
2679 | |||
2680 | case DIGI_GETINFO: | 2210 | case DIGI_GETINFO: |
2681 | { /* Begin case DIGI_GETINFO */ | 2211 | { /* Begin case DIGI_GETINFO */ |
2682 | |||
2683 | struct digi_info di ; | 2212 | struct digi_info di ; |
2684 | int brd; | 2213 | int brd; |
2685 | 2214 | ||
2686 | getUser(brd, (unsigned int __user *)arg); | 2215 | if(get_user(brd, (unsigned int __user *)arg)) |
2687 | 2216 | return -EFAULT; | |
2688 | if ((brd < 0) || (brd >= num_cards) || (num_cards == 0)) | 2217 | if (brd < 0 || brd >= num_cards || num_cards == 0) |
2689 | return (-ENODEV); | 2218 | return -ENODEV; |
2690 | 2219 | ||
2691 | memset(&di, 0, sizeof(di)); | 2220 | memset(&di, 0, sizeof(di)); |
2692 | 2221 | ||
@@ -2694,8 +2223,9 @@ static int info_ioctl(struct tty_struct *tty, struct file * file, | |||
2694 | di.status = boards[brd].status; | 2223 | di.status = boards[brd].status; |
2695 | di.type = boards[brd].type ; | 2224 | di.type = boards[brd].type ; |
2696 | di.numports = boards[brd].numports ; | 2225 | di.numports = boards[brd].numports ; |
2697 | di.port = boards[brd].port ; | 2226 | /* Legacy fixups - just move along nothing to see */ |
2698 | di.membase = boards[brd].membase ; | 2227 | di.port = (unsigned char *)boards[brd].port ; |
2228 | di.membase = (unsigned char *)boards[brd].membase ; | ||
2699 | 2229 | ||
2700 | if (copy_to_user((void __user *)arg, &di, sizeof (di))) | 2230 | if (copy_to_user((void __user *)arg, &di, sizeof (di))) |
2701 | return -EFAULT; | 2231 | return -EFAULT; |
@@ -2709,39 +2239,29 @@ static int info_ioctl(struct tty_struct *tty, struct file * file, | |||
2709 | int brd = arg & 0xff000000 >> 16 ; | 2239 | int brd = arg & 0xff000000 >> 16 ; |
2710 | unsigned char state = arg & 0xff ; | 2240 | unsigned char state = arg & 0xff ; |
2711 | 2241 | ||
2712 | if ((brd < 0) || (brd >= num_cards)) | 2242 | if (brd < 0 || brd >= num_cards) { |
2713 | { | 2243 | printk(KERN_ERR "epca: DIGI POLLER : brd not valid!\n"); |
2714 | printk(KERN_ERR "<Error> - DIGI POLLER : brd not valid!\n"); | ||
2715 | return (-ENODEV); | 2244 | return (-ENODEV); |
2716 | } | 2245 | } |
2717 | |||
2718 | digi_poller_inhibited = state ; | 2246 | digi_poller_inhibited = state ; |
2719 | break ; | 2247 | break ; |
2720 | |||
2721 | } /* End case DIGI_POLLER */ | 2248 | } /* End case DIGI_POLLER */ |
2722 | 2249 | ||
2723 | case DIGI_INIT: | 2250 | case DIGI_INIT: |
2724 | { /* Begin case DIGI_INIT */ | 2251 | { /* Begin case DIGI_INIT */ |
2725 | |||
2726 | /* ------------------------------------------------------------ | 2252 | /* ------------------------------------------------------------ |
2727 | This call is made by the apps to complete the initilization | 2253 | This call is made by the apps to complete the initilization |
2728 | of the board(s). This routine is responsible for setting | 2254 | of the board(s). This routine is responsible for setting |
2729 | the card to its initial state and setting the drivers control | 2255 | the card to its initial state and setting the drivers control |
2730 | fields to the sutianle settings for the card in question. | 2256 | fields to the sutianle settings for the card in question. |
2731 | ---------------------------------------------------------------- */ | 2257 | ---------------------------------------------------------------- */ |
2732 | |||
2733 | int crd ; | 2258 | int crd ; |
2734 | for (crd = 0; crd < num_cards; crd++) | 2259 | for (crd = 0; crd < num_cards; crd++) |
2735 | post_fep_init (crd); | 2260 | post_fep_init (crd); |
2736 | |||
2737 | break ; | 2261 | break ; |
2738 | |||
2739 | } /* End case DIGI_INIT */ | 2262 | } /* End case DIGI_INIT */ |
2740 | |||
2741 | |||
2742 | default: | 2263 | default: |
2743 | return -ENOIOCTLCMD; | 2264 | return -ENOTTY; |
2744 | |||
2745 | } /* End switch cmd */ | 2265 | } /* End switch cmd */ |
2746 | return (0) ; | 2266 | return (0) ; |
2747 | } | 2267 | } |
@@ -2750,43 +2270,33 @@ static int info_ioctl(struct tty_struct *tty, struct file * file, | |||
2750 | static int pc_tiocmget(struct tty_struct *tty, struct file *file) | 2270 | static int pc_tiocmget(struct tty_struct *tty, struct file *file) |
2751 | { | 2271 | { |
2752 | struct channel *ch = (struct channel *) tty->driver_data; | 2272 | struct channel *ch = (struct channel *) tty->driver_data; |
2753 | volatile struct board_chan *bc; | 2273 | struct board_chan *bc; |
2754 | unsigned int mstat, mflag = 0; | 2274 | unsigned int mstat, mflag = 0; |
2755 | unsigned long flags; | 2275 | unsigned long flags; |
2756 | 2276 | ||
2757 | if (ch) | 2277 | if (ch) |
2758 | bc = ch->brdchan; | 2278 | bc = ch->brdchan; |
2759 | else | 2279 | else |
2760 | { | 2280 | return -EINVAL; |
2761 | printk(KERN_ERR "<Error> - ch is NULL in pc_tiocmget!\n"); | ||
2762 | return(-EINVAL); | ||
2763 | } | ||
2764 | 2281 | ||
2765 | save_flags(flags); | 2282 | spin_lock_irqsave(&epca_lock, flags); |
2766 | cli(); | ||
2767 | globalwinon(ch); | 2283 | globalwinon(ch); |
2768 | mstat = bc->mstat; | 2284 | mstat = readb(&bc->mstat); |
2769 | memoff(ch); | 2285 | memoff(ch); |
2770 | restore_flags(flags); | 2286 | spin_unlock_irqrestore(&epca_lock, flags); |
2771 | 2287 | ||
2772 | if (mstat & ch->m_dtr) | 2288 | if (mstat & ch->m_dtr) |
2773 | mflag |= TIOCM_DTR; | 2289 | mflag |= TIOCM_DTR; |
2774 | |||
2775 | if (mstat & ch->m_rts) | 2290 | if (mstat & ch->m_rts) |
2776 | mflag |= TIOCM_RTS; | 2291 | mflag |= TIOCM_RTS; |
2777 | |||
2778 | if (mstat & ch->m_cts) | 2292 | if (mstat & ch->m_cts) |
2779 | mflag |= TIOCM_CTS; | 2293 | mflag |= TIOCM_CTS; |
2780 | |||
2781 | if (mstat & ch->dsr) | 2294 | if (mstat & ch->dsr) |
2782 | mflag |= TIOCM_DSR; | 2295 | mflag |= TIOCM_DSR; |
2783 | |||
2784 | if (mstat & ch->m_ri) | 2296 | if (mstat & ch->m_ri) |
2785 | mflag |= TIOCM_RI; | 2297 | mflag |= TIOCM_RI; |
2786 | |||
2787 | if (mstat & ch->dcd) | 2298 | if (mstat & ch->dcd) |
2788 | mflag |= TIOCM_CD; | 2299 | mflag |= TIOCM_CD; |
2789 | |||
2790 | return mflag; | 2300 | return mflag; |
2791 | } | 2301 | } |
2792 | 2302 | ||
@@ -2796,13 +2306,10 @@ static int pc_tiocmset(struct tty_struct *tty, struct file *file, | |||
2796 | struct channel *ch = (struct channel *) tty->driver_data; | 2306 | struct channel *ch = (struct channel *) tty->driver_data; |
2797 | unsigned long flags; | 2307 | unsigned long flags; |
2798 | 2308 | ||
2799 | if (!ch) { | 2309 | if (!ch) |
2800 | printk(KERN_ERR "<Error> - ch is NULL in pc_tiocmset!\n"); | 2310 | return -EINVAL; |
2801 | return(-EINVAL); | ||
2802 | } | ||
2803 | 2311 | ||
2804 | save_flags(flags); | 2312 | spin_lock_irqsave(&epca_lock, flags); |
2805 | cli(); | ||
2806 | /* | 2313 | /* |
2807 | * I think this modemfake stuff is broken. It doesn't | 2314 | * I think this modemfake stuff is broken. It doesn't |
2808 | * correctly reflect the behaviour desired by the TIOCM* | 2315 | * correctly reflect the behaviour desired by the TIOCM* |
@@ -2824,17 +2331,14 @@ static int pc_tiocmset(struct tty_struct *tty, struct file *file, | |||
2824 | ch->modemfake |= ch->m_dtr; | 2331 | ch->modemfake |= ch->m_dtr; |
2825 | ch->modem &= ~ch->m_dtr; | 2332 | ch->modem &= ~ch->m_dtr; |
2826 | } | 2333 | } |
2827 | |||
2828 | globalwinon(ch); | 2334 | globalwinon(ch); |
2829 | |||
2830 | /* -------------------------------------------------------------- | 2335 | /* -------------------------------------------------------------- |
2831 | The below routine generally sets up parity, baud, flow control | 2336 | The below routine generally sets up parity, baud, flow control |
2832 | issues, etc.... It effect both control flags and input flags. | 2337 | issues, etc.... It effect both control flags and input flags. |
2833 | ------------------------------------------------------------------ */ | 2338 | ------------------------------------------------------------------ */ |
2834 | |||
2835 | epcaparam(tty,ch); | 2339 | epcaparam(tty,ch); |
2836 | memoff(ch); | 2340 | memoff(ch); |
2837 | restore_flags(flags); | 2341 | spin_unlock_irqrestore(&epca_lock, flags); |
2838 | return 0; | 2342 | return 0; |
2839 | } | 2343 | } |
2840 | 2344 | ||
@@ -2847,19 +2351,14 @@ static int pc_ioctl(struct tty_struct *tty, struct file * file, | |||
2847 | unsigned long flags; | 2351 | unsigned long flags; |
2848 | unsigned int mflag, mstat; | 2352 | unsigned int mflag, mstat; |
2849 | unsigned char startc, stopc; | 2353 | unsigned char startc, stopc; |
2850 | volatile struct board_chan *bc; | 2354 | struct board_chan *bc; |
2851 | struct channel *ch = (struct channel *) tty->driver_data; | 2355 | struct channel *ch = (struct channel *) tty->driver_data; |
2852 | void __user *argp = (void __user *)arg; | 2356 | void __user *argp = (void __user *)arg; |
2853 | 2357 | ||
2854 | if (ch) | 2358 | if (ch) |
2855 | bc = ch->brdchan; | 2359 | bc = ch->brdchan; |
2856 | else | 2360 | else |
2857 | { | 2361 | return -EINVAL; |
2858 | printk(KERN_ERR "<Error> - ch is NULL in pc_ioctl!\n"); | ||
2859 | return(-EINVAL); | ||
2860 | } | ||
2861 | |||
2862 | save_flags(flags); | ||
2863 | 2362 | ||
2864 | /* ------------------------------------------------------------------- | 2363 | /* ------------------------------------------------------------------- |
2865 | For POSIX compliance we need to add more ioctls. See tty_ioctl.c | 2364 | For POSIX compliance we need to add more ioctls. See tty_ioctl.c |
@@ -2871,46 +2370,39 @@ static int pc_ioctl(struct tty_struct *tty, struct file * file, | |||
2871 | { /* Begin switch cmd */ | 2370 | { /* Begin switch cmd */ |
2872 | 2371 | ||
2873 | case TCGETS: | 2372 | case TCGETS: |
2874 | if (copy_to_user(argp, | 2373 | if (copy_to_user(argp, tty->termios, sizeof(struct termios))) |
2875 | tty->termios, sizeof(struct termios))) | ||
2876 | return -EFAULT; | 2374 | return -EFAULT; |
2877 | return(0); | 2375 | return 0; |
2878 | |||
2879 | case TCGETA: | 2376 | case TCGETA: |
2880 | return get_termio(tty, argp); | 2377 | return get_termio(tty, argp); |
2881 | |||
2882 | case TCSBRK: /* SVID version: non-zero arg --> no break */ | 2378 | case TCSBRK: /* SVID version: non-zero arg --> no break */ |
2883 | |||
2884 | retval = tty_check_change(tty); | 2379 | retval = tty_check_change(tty); |
2885 | if (retval) | 2380 | if (retval) |
2886 | return retval; | 2381 | return retval; |
2887 | |||
2888 | /* Setup an event to indicate when the transmit buffer empties */ | 2382 | /* Setup an event to indicate when the transmit buffer empties */ |
2889 | 2383 | spin_lock_irqsave(&epca_lock, flags); | |
2890 | setup_empty_event(tty,ch); | 2384 | setup_empty_event(tty,ch); |
2385 | spin_unlock_irqrestore(&epca_lock, flags); | ||
2891 | tty_wait_until_sent(tty, 0); | 2386 | tty_wait_until_sent(tty, 0); |
2892 | if (!arg) | 2387 | if (!arg) |
2893 | digi_send_break(ch, HZ/4); /* 1/4 second */ | 2388 | digi_send_break(ch, HZ/4); /* 1/4 second */ |
2894 | return 0; | 2389 | return 0; |
2895 | |||
2896 | case TCSBRKP: /* support for POSIX tcsendbreak() */ | 2390 | case TCSBRKP: /* support for POSIX tcsendbreak() */ |
2897 | |||
2898 | retval = tty_check_change(tty); | 2391 | retval = tty_check_change(tty); |
2899 | if (retval) | 2392 | if (retval) |
2900 | return retval; | 2393 | return retval; |
2901 | 2394 | ||
2902 | /* Setup an event to indicate when the transmit buffer empties */ | 2395 | /* Setup an event to indicate when the transmit buffer empties */ |
2903 | 2396 | spin_lock_irqsave(&epca_lock, flags); | |
2904 | setup_empty_event(tty,ch); | 2397 | setup_empty_event(tty,ch); |
2398 | spin_unlock_irqrestore(&epca_lock, flags); | ||
2905 | tty_wait_until_sent(tty, 0); | 2399 | tty_wait_until_sent(tty, 0); |
2906 | digi_send_break(ch, arg ? arg*(HZ/10) : HZ/4); | 2400 | digi_send_break(ch, arg ? arg*(HZ/10) : HZ/4); |
2907 | return 0; | 2401 | return 0; |
2908 | |||
2909 | case TIOCGSOFTCAR: | 2402 | case TIOCGSOFTCAR: |
2910 | if (put_user(C_CLOCAL(tty)?1:0, (unsigned long __user *)arg)) | 2403 | if (put_user(C_CLOCAL(tty)?1:0, (unsigned long __user *)arg)) |
2911 | return -EFAULT; | 2404 | return -EFAULT; |
2912 | return 0; | 2405 | return 0; |
2913 | |||
2914 | case TIOCSSOFTCAR: | 2406 | case TIOCSSOFTCAR: |
2915 | { | 2407 | { |
2916 | unsigned int value; | 2408 | unsigned int value; |
@@ -2922,75 +2414,63 @@ static int pc_ioctl(struct tty_struct *tty, struct file * file, | |||
2922 | (value ? CLOCAL : 0)); | 2414 | (value ? CLOCAL : 0)); |
2923 | return 0; | 2415 | return 0; |
2924 | } | 2416 | } |
2925 | |||
2926 | case TIOCMODG: | 2417 | case TIOCMODG: |
2927 | mflag = pc_tiocmget(tty, file); | 2418 | mflag = pc_tiocmget(tty, file); |
2928 | if (put_user(mflag, (unsigned long __user *)argp)) | 2419 | if (put_user(mflag, (unsigned long __user *)argp)) |
2929 | return -EFAULT; | 2420 | return -EFAULT; |
2930 | break; | 2421 | break; |
2931 | |||
2932 | case TIOCMODS: | 2422 | case TIOCMODS: |
2933 | if (get_user(mstat, (unsigned __user *)argp)) | 2423 | if (get_user(mstat, (unsigned __user *)argp)) |
2934 | return -EFAULT; | 2424 | return -EFAULT; |
2935 | return pc_tiocmset(tty, file, mstat, ~mstat); | 2425 | return pc_tiocmset(tty, file, mstat, ~mstat); |
2936 | |||
2937 | case TIOCSDTR: | 2426 | case TIOCSDTR: |
2427 | spin_lock_irqsave(&epca_lock, flags); | ||
2938 | ch->omodem |= ch->m_dtr; | 2428 | ch->omodem |= ch->m_dtr; |
2939 | cli(); | ||
2940 | globalwinon(ch); | 2429 | globalwinon(ch); |
2941 | fepcmd(ch, SETMODEM, ch->m_dtr, 0, 10, 1); | 2430 | fepcmd(ch, SETMODEM, ch->m_dtr, 0, 10, 1); |
2942 | memoff(ch); | 2431 | memoff(ch); |
2943 | restore_flags(flags); | 2432 | spin_unlock_irqrestore(&epca_lock, flags); |
2944 | break; | 2433 | break; |
2945 | 2434 | ||
2946 | case TIOCCDTR: | 2435 | case TIOCCDTR: |
2436 | spin_lock_irqsave(&epca_lock, flags); | ||
2947 | ch->omodem &= ~ch->m_dtr; | 2437 | ch->omodem &= ~ch->m_dtr; |
2948 | cli(); | ||
2949 | globalwinon(ch); | 2438 | globalwinon(ch); |
2950 | fepcmd(ch, SETMODEM, 0, ch->m_dtr, 10, 1); | 2439 | fepcmd(ch, SETMODEM, 0, ch->m_dtr, 10, 1); |
2951 | memoff(ch); | 2440 | memoff(ch); |
2952 | restore_flags(flags); | 2441 | spin_unlock_irqrestore(&epca_lock, flags); |
2953 | break; | 2442 | break; |
2954 | |||
2955 | case DIGI_GETA: | 2443 | case DIGI_GETA: |
2956 | if (copy_to_user(argp, &ch->digiext, sizeof(digi_t))) | 2444 | if (copy_to_user(argp, &ch->digiext, sizeof(digi_t))) |
2957 | return -EFAULT; | 2445 | return -EFAULT; |
2958 | break; | 2446 | break; |
2959 | |||
2960 | case DIGI_SETAW: | 2447 | case DIGI_SETAW: |
2961 | case DIGI_SETAF: | 2448 | case DIGI_SETAF: |
2962 | if ((cmd) == (DIGI_SETAW)) | 2449 | if (cmd == DIGI_SETAW) { |
2963 | { | ||
2964 | /* Setup an event to indicate when the transmit buffer empties */ | 2450 | /* Setup an event to indicate when the transmit buffer empties */ |
2965 | 2451 | spin_lock_irqsave(&epca_lock, flags); | |
2966 | setup_empty_event(tty,ch); | 2452 | setup_empty_event(tty,ch); |
2453 | spin_unlock_irqrestore(&epca_lock, flags); | ||
2967 | tty_wait_until_sent(tty, 0); | 2454 | tty_wait_until_sent(tty, 0); |
2968 | } | 2455 | } else { |
2969 | else | ||
2970 | { | ||
2971 | /* ldisc lock already held in ioctl */ | 2456 | /* ldisc lock already held in ioctl */ |
2972 | if (tty->ldisc.flush_buffer) | 2457 | if (tty->ldisc.flush_buffer) |
2973 | tty->ldisc.flush_buffer(tty); | 2458 | tty->ldisc.flush_buffer(tty); |
2974 | } | 2459 | } |
2975 | |||
2976 | /* Fall Thru */ | 2460 | /* Fall Thru */ |
2977 | |||
2978 | case DIGI_SETA: | 2461 | case DIGI_SETA: |
2979 | if (copy_from_user(&ch->digiext, argp, sizeof(digi_t))) | 2462 | if (copy_from_user(&ch->digiext, argp, sizeof(digi_t))) |
2980 | return -EFAULT; | 2463 | return -EFAULT; |
2981 | 2464 | ||
2982 | if (ch->digiext.digi_flags & DIGI_ALTPIN) | 2465 | if (ch->digiext.digi_flags & DIGI_ALTPIN) { |
2983 | { | ||
2984 | ch->dcd = ch->m_dsr; | 2466 | ch->dcd = ch->m_dsr; |
2985 | ch->dsr = ch->m_dcd; | 2467 | ch->dsr = ch->m_dcd; |
2986 | } | 2468 | } else { |
2987 | else | ||
2988 | { | ||
2989 | ch->dcd = ch->m_dcd; | 2469 | ch->dcd = ch->m_dcd; |
2990 | ch->dsr = ch->m_dsr; | 2470 | ch->dsr = ch->m_dsr; |
2991 | } | 2471 | } |
2992 | 2472 | ||
2993 | cli(); | 2473 | spin_lock_irqsave(&epca_lock, flags); |
2994 | globalwinon(ch); | 2474 | globalwinon(ch); |
2995 | 2475 | ||
2996 | /* ----------------------------------------------------------------- | 2476 | /* ----------------------------------------------------------------- |
@@ -3000,25 +2480,22 @@ static int pc_ioctl(struct tty_struct *tty, struct file * file, | |||
3000 | 2480 | ||
3001 | epcaparam(tty,ch); | 2481 | epcaparam(tty,ch); |
3002 | memoff(ch); | 2482 | memoff(ch); |
3003 | restore_flags(flags); | 2483 | spin_unlock_irqrestore(&epca_lock, flags); |
3004 | break; | 2484 | break; |
3005 | 2485 | ||
3006 | case DIGI_GETFLOW: | 2486 | case DIGI_GETFLOW: |
3007 | case DIGI_GETAFLOW: | 2487 | case DIGI_GETAFLOW: |
3008 | cli(); | 2488 | spin_lock_irqsave(&epca_lock, flags); |
3009 | globalwinon(ch); | 2489 | globalwinon(ch); |
3010 | if ((cmd) == (DIGI_GETFLOW)) | 2490 | if (cmd == DIGI_GETFLOW) { |
3011 | { | 2491 | dflow.startc = readb(&bc->startc); |
3012 | dflow.startc = bc->startc; | 2492 | dflow.stopc = readb(&bc->stopc); |
3013 | dflow.stopc = bc->stopc; | 2493 | } else { |
3014 | } | 2494 | dflow.startc = readb(&bc->startca); |
3015 | else | 2495 | dflow.stopc = readb(&bc->stopca); |
3016 | { | ||
3017 | dflow.startc = bc->startca; | ||
3018 | dflow.stopc = bc->stopca; | ||
3019 | } | 2496 | } |
3020 | memoff(ch); | 2497 | memoff(ch); |
3021 | restore_flags(flags); | 2498 | spin_unlock_irqrestore(&epca_lock, flags); |
3022 | 2499 | ||
3023 | if (copy_to_user(argp, &dflow, sizeof(dflow))) | 2500 | if (copy_to_user(argp, &dflow, sizeof(dflow))) |
3024 | return -EFAULT; | 2501 | return -EFAULT; |
@@ -3026,13 +2503,10 @@ static int pc_ioctl(struct tty_struct *tty, struct file * file, | |||
3026 | 2503 | ||
3027 | case DIGI_SETAFLOW: | 2504 | case DIGI_SETAFLOW: |
3028 | case DIGI_SETFLOW: | 2505 | case DIGI_SETFLOW: |
3029 | if ((cmd) == (DIGI_SETFLOW)) | 2506 | if (cmd == DIGI_SETFLOW) { |
3030 | { | ||
3031 | startc = ch->startc; | 2507 | startc = ch->startc; |
3032 | stopc = ch->stopc; | 2508 | stopc = ch->stopc; |
3033 | } | 2509 | } else { |
3034 | else | ||
3035 | { | ||
3036 | startc = ch->startca; | 2510 | startc = ch->startca; |
3037 | stopc = ch->stopca; | 2511 | stopc = ch->stopca; |
3038 | } | 2512 | } |
@@ -3040,40 +2514,31 @@ static int pc_ioctl(struct tty_struct *tty, struct file * file, | |||
3040 | if (copy_from_user(&dflow, argp, sizeof(dflow))) | 2514 | if (copy_from_user(&dflow, argp, sizeof(dflow))) |
3041 | return -EFAULT; | 2515 | return -EFAULT; |
3042 | 2516 | ||
3043 | if (dflow.startc != startc || dflow.stopc != stopc) | 2517 | if (dflow.startc != startc || dflow.stopc != stopc) { /* Begin if setflow toggled */ |
3044 | { /* Begin if setflow toggled */ | 2518 | spin_lock_irqsave(&epca_lock, flags); |
3045 | cli(); | ||
3046 | globalwinon(ch); | 2519 | globalwinon(ch); |
3047 | 2520 | ||
3048 | if ((cmd) == (DIGI_SETFLOW)) | 2521 | if (cmd == DIGI_SETFLOW) { |
3049 | { | ||
3050 | ch->fepstartc = ch->startc = dflow.startc; | 2522 | ch->fepstartc = ch->startc = dflow.startc; |
3051 | ch->fepstopc = ch->stopc = dflow.stopc; | 2523 | ch->fepstopc = ch->stopc = dflow.stopc; |
3052 | fepcmd(ch, SONOFFC, ch->fepstartc, ch->fepstopc, 0, 1); | 2524 | fepcmd(ch, SONOFFC, ch->fepstartc, ch->fepstopc, 0, 1); |
3053 | } | 2525 | } else { |
3054 | else | ||
3055 | { | ||
3056 | ch->fepstartca = ch->startca = dflow.startc; | 2526 | ch->fepstartca = ch->startca = dflow.startc; |
3057 | ch->fepstopca = ch->stopca = dflow.stopc; | 2527 | ch->fepstopca = ch->stopca = dflow.stopc; |
3058 | fepcmd(ch, SAUXONOFFC, ch->fepstartca, ch->fepstopca, 0, 1); | 2528 | fepcmd(ch, SAUXONOFFC, ch->fepstartca, ch->fepstopca, 0, 1); |
3059 | } | 2529 | } |
3060 | 2530 | ||
3061 | if (ch->statusflags & TXSTOPPED) | 2531 | if (ch->statusflags & TXSTOPPED) |
3062 | pc_start(tty); | 2532 | pc_start(tty); |
3063 | 2533 | ||
3064 | memoff(ch); | 2534 | memoff(ch); |
3065 | restore_flags(flags); | 2535 | spin_unlock_irqrestore(&epca_lock, flags); |
3066 | |||
3067 | } /* End if setflow toggled */ | 2536 | } /* End if setflow toggled */ |
3068 | break; | 2537 | break; |
3069 | |||
3070 | default: | 2538 | default: |
3071 | return -ENOIOCTLCMD; | 2539 | return -ENOIOCTLCMD; |
3072 | |||
3073 | } /* End switch cmd */ | 2540 | } /* End switch cmd */ |
3074 | |||
3075 | return 0; | 2541 | return 0; |
3076 | |||
3077 | } /* End pc_ioctl */ | 2542 | } /* End pc_ioctl */ |
3078 | 2543 | ||
3079 | /* --------------------- Begin pc_set_termios ----------------------- */ | 2544 | /* --------------------- Begin pc_set_termios ----------------------- */ |
@@ -3083,20 +2548,16 @@ static void pc_set_termios(struct tty_struct *tty, struct termios *old_termios) | |||
3083 | 2548 | ||
3084 | struct channel *ch; | 2549 | struct channel *ch; |
3085 | unsigned long flags; | 2550 | unsigned long flags; |
3086 | |||
3087 | /* --------------------------------------------------------- | 2551 | /* --------------------------------------------------------- |
3088 | verifyChannel returns the channel from the tty struct | 2552 | verifyChannel returns the channel from the tty struct |
3089 | if it is valid. This serves as a sanity check. | 2553 | if it is valid. This serves as a sanity check. |
3090 | ------------------------------------------------------------- */ | 2554 | ------------------------------------------------------------- */ |
3091 | 2555 | if ((ch = verifyChannel(tty)) != NULL) { /* Begin if channel valid */ | |
3092 | if ((ch = verifyChannel(tty)) != NULL) | 2556 | spin_lock_irqsave(&epca_lock, flags); |
3093 | { /* Begin if channel valid */ | ||
3094 | |||
3095 | save_flags(flags); | ||
3096 | cli(); | ||
3097 | globalwinon(ch); | 2557 | globalwinon(ch); |
3098 | epcaparam(tty, ch); | 2558 | epcaparam(tty, ch); |
3099 | memoff(ch); | 2559 | memoff(ch); |
2560 | spin_unlock_irqrestore(&epca_lock, flags); | ||
3100 | 2561 | ||
3101 | if ((old_termios->c_cflag & CRTSCTS) && | 2562 | if ((old_termios->c_cflag & CRTSCTS) && |
3102 | ((tty->termios->c_cflag & CRTSCTS) == 0)) | 2563 | ((tty->termios->c_cflag & CRTSCTS) == 0)) |
@@ -3106,8 +2567,6 @@ static void pc_set_termios(struct tty_struct *tty, struct termios *old_termios) | |||
3106 | (tty->termios->c_cflag & CLOCAL)) | 2567 | (tty->termios->c_cflag & CLOCAL)) |
3107 | wake_up_interruptible(&ch->open_wait); | 2568 | wake_up_interruptible(&ch->open_wait); |
3108 | 2569 | ||
3109 | restore_flags(flags); | ||
3110 | |||
3111 | } /* End if channel valid */ | 2570 | } /* End if channel valid */ |
3112 | 2571 | ||
3113 | } /* End pc_set_termios */ | 2572 | } /* End pc_set_termios */ |
@@ -3116,29 +2575,18 @@ static void pc_set_termios(struct tty_struct *tty, struct termios *old_termios) | |||
3116 | 2575 | ||
3117 | static void do_softint(void *private_) | 2576 | static void do_softint(void *private_) |
3118 | { /* Begin do_softint */ | 2577 | { /* Begin do_softint */ |
3119 | |||
3120 | struct channel *ch = (struct channel *) private_; | 2578 | struct channel *ch = (struct channel *) private_; |
3121 | |||
3122 | |||
3123 | /* Called in response to a modem change event */ | 2579 | /* Called in response to a modem change event */ |
3124 | 2580 | if (ch && ch->magic == EPCA_MAGIC) { /* Begin EPCA_MAGIC */ | |
3125 | if (ch && ch->magic == EPCA_MAGIC) | ||
3126 | { /* Begin EPCA_MAGIC */ | ||
3127 | |||
3128 | struct tty_struct *tty = ch->tty; | 2581 | struct tty_struct *tty = ch->tty; |
3129 | 2582 | ||
3130 | if (tty && tty->driver_data) | 2583 | if (tty && tty->driver_data) { |
3131 | { | 2584 | if (test_and_clear_bit(EPCA_EVENT_HANGUP, &ch->event)) { /* Begin if clear_bit */ |
3132 | if (test_and_clear_bit(EPCA_EVENT_HANGUP, &ch->event)) | ||
3133 | { /* Begin if clear_bit */ | ||
3134 | |||
3135 | tty_hangup(tty); /* FIXME: module removal race here - AKPM */ | 2585 | tty_hangup(tty); /* FIXME: module removal race here - AKPM */ |
3136 | wake_up_interruptible(&ch->open_wait); | 2586 | wake_up_interruptible(&ch->open_wait); |
3137 | ch->asyncflags &= ~ASYNC_NORMAL_ACTIVE; | 2587 | ch->asyncflags &= ~ASYNC_NORMAL_ACTIVE; |
3138 | |||
3139 | } /* End if clear_bit */ | 2588 | } /* End if clear_bit */ |
3140 | } | 2589 | } |
3141 | |||
3142 | } /* End EPCA_MAGIC */ | 2590 | } /* End EPCA_MAGIC */ |
3143 | } /* End do_softint */ | 2591 | } /* End do_softint */ |
3144 | 2592 | ||
@@ -3154,82 +2602,49 @@ static void pc_stop(struct tty_struct *tty) | |||
3154 | 2602 | ||
3155 | struct channel *ch; | 2603 | struct channel *ch; |
3156 | unsigned long flags; | 2604 | unsigned long flags; |
3157 | |||
3158 | /* --------------------------------------------------------- | 2605 | /* --------------------------------------------------------- |
3159 | verifyChannel returns the channel from the tty struct | 2606 | verifyChannel returns the channel from the tty struct |
3160 | if it is valid. This serves as a sanity check. | 2607 | if it is valid. This serves as a sanity check. |
3161 | ------------------------------------------------------------- */ | 2608 | ------------------------------------------------------------- */ |
3162 | 2609 | if ((ch = verifyChannel(tty)) != NULL) { /* Begin if valid channel */ | |
3163 | if ((ch = verifyChannel(tty)) != NULL) | 2610 | spin_lock_irqsave(&epca_lock, flags); |
3164 | { /* Begin if valid channel */ | 2611 | if ((ch->statusflags & TXSTOPPED) == 0) { /* Begin if transmit stop requested */ |
3165 | |||
3166 | save_flags(flags); | ||
3167 | cli(); | ||
3168 | |||
3169 | if ((ch->statusflags & TXSTOPPED) == 0) | ||
3170 | { /* Begin if transmit stop requested */ | ||
3171 | |||
3172 | globalwinon(ch); | 2612 | globalwinon(ch); |
3173 | |||
3174 | /* STOP transmitting now !! */ | 2613 | /* STOP transmitting now !! */ |
3175 | |||
3176 | fepcmd(ch, PAUSETX, 0, 0, 0, 0); | 2614 | fepcmd(ch, PAUSETX, 0, 0, 0, 0); |
3177 | |||
3178 | ch->statusflags |= TXSTOPPED; | 2615 | ch->statusflags |= TXSTOPPED; |
3179 | memoff(ch); | 2616 | memoff(ch); |
3180 | |||
3181 | } /* End if transmit stop requested */ | 2617 | } /* End if transmit stop requested */ |
3182 | 2618 | spin_unlock_irqrestore(&epca_lock, flags); | |
3183 | restore_flags(flags); | ||
3184 | |||
3185 | } /* End if valid channel */ | 2619 | } /* End if valid channel */ |
3186 | |||
3187 | } /* End pc_stop */ | 2620 | } /* End pc_stop */ |
3188 | 2621 | ||
3189 | /* --------------------- Begin pc_start ----------------------- */ | 2622 | /* --------------------- Begin pc_start ----------------------- */ |
3190 | 2623 | ||
3191 | static void pc_start(struct tty_struct *tty) | 2624 | static void pc_start(struct tty_struct *tty) |
3192 | { /* Begin pc_start */ | 2625 | { /* Begin pc_start */ |
3193 | |||
3194 | struct channel *ch; | 2626 | struct channel *ch; |
3195 | |||
3196 | /* --------------------------------------------------------- | 2627 | /* --------------------------------------------------------- |
3197 | verifyChannel returns the channel from the tty struct | 2628 | verifyChannel returns the channel from the tty struct |
3198 | if it is valid. This serves as a sanity check. | 2629 | if it is valid. This serves as a sanity check. |
3199 | ------------------------------------------------------------- */ | 2630 | ------------------------------------------------------------- */ |
3200 | 2631 | if ((ch = verifyChannel(tty)) != NULL) { /* Begin if channel valid */ | |
3201 | if ((ch = verifyChannel(tty)) != NULL) | ||
3202 | { /* Begin if channel valid */ | ||
3203 | |||
3204 | unsigned long flags; | 2632 | unsigned long flags; |
3205 | 2633 | spin_lock_irqsave(&epca_lock, flags); | |
3206 | save_flags(flags); | ||
3207 | cli(); | ||
3208 | |||
3209 | /* Just in case output was resumed because of a change in Digi-flow */ | 2634 | /* Just in case output was resumed because of a change in Digi-flow */ |
3210 | if (ch->statusflags & TXSTOPPED) | 2635 | if (ch->statusflags & TXSTOPPED) { /* Begin transmit resume requested */ |
3211 | { /* Begin transmit resume requested */ | 2636 | struct board_chan *bc; |
3212 | |||
3213 | volatile struct board_chan *bc; | ||
3214 | |||
3215 | globalwinon(ch); | 2637 | globalwinon(ch); |
3216 | bc = ch->brdchan; | 2638 | bc = ch->brdchan; |
3217 | if (ch->statusflags & LOWWAIT) | 2639 | if (ch->statusflags & LOWWAIT) |
3218 | bc->ilow = 1; | 2640 | writeb(1, &bc->ilow); |
3219 | |||
3220 | /* Okay, you can start transmitting again... */ | 2641 | /* Okay, you can start transmitting again... */ |
3221 | |||
3222 | fepcmd(ch, RESUMETX, 0, 0, 0, 0); | 2642 | fepcmd(ch, RESUMETX, 0, 0, 0, 0); |
3223 | |||
3224 | ch->statusflags &= ~TXSTOPPED; | 2643 | ch->statusflags &= ~TXSTOPPED; |
3225 | memoff(ch); | 2644 | memoff(ch); |
3226 | |||
3227 | } /* End transmit resume requested */ | 2645 | } /* End transmit resume requested */ |
3228 | 2646 | spin_unlock_irqrestore(&epca_lock, flags); | |
3229 | restore_flags(flags); | ||
3230 | |||
3231 | } /* End if channel valid */ | 2647 | } /* End if channel valid */ |
3232 | |||
3233 | } /* End pc_start */ | 2648 | } /* End pc_start */ |
3234 | 2649 | ||
3235 | /* ------------------------------------------------------------------ | 2650 | /* ------------------------------------------------------------------ |
@@ -3244,86 +2659,55 @@ ______________________________________________________________________ */ | |||
3244 | 2659 | ||
3245 | static void pc_throttle(struct tty_struct * tty) | 2660 | static void pc_throttle(struct tty_struct * tty) |
3246 | { /* Begin pc_throttle */ | 2661 | { /* Begin pc_throttle */ |
3247 | |||
3248 | struct channel *ch; | 2662 | struct channel *ch; |
3249 | unsigned long flags; | 2663 | unsigned long flags; |
3250 | |||
3251 | /* --------------------------------------------------------- | 2664 | /* --------------------------------------------------------- |
3252 | verifyChannel returns the channel from the tty struct | 2665 | verifyChannel returns the channel from the tty struct |
3253 | if it is valid. This serves as a sanity check. | 2666 | if it is valid. This serves as a sanity check. |
3254 | ------------------------------------------------------------- */ | 2667 | ------------------------------------------------------------- */ |
3255 | 2668 | if ((ch = verifyChannel(tty)) != NULL) { /* Begin if channel valid */ | |
3256 | if ((ch = verifyChannel(tty)) != NULL) | 2669 | spin_lock_irqsave(&epca_lock, flags); |
3257 | { /* Begin if channel valid */ | 2670 | if ((ch->statusflags & RXSTOPPED) == 0) { |
3258 | |||
3259 | |||
3260 | save_flags(flags); | ||
3261 | cli(); | ||
3262 | |||
3263 | if ((ch->statusflags & RXSTOPPED) == 0) | ||
3264 | { | ||
3265 | globalwinon(ch); | 2671 | globalwinon(ch); |
3266 | fepcmd(ch, PAUSERX, 0, 0, 0, 0); | 2672 | fepcmd(ch, PAUSERX, 0, 0, 0, 0); |
3267 | |||
3268 | ch->statusflags |= RXSTOPPED; | 2673 | ch->statusflags |= RXSTOPPED; |
3269 | memoff(ch); | 2674 | memoff(ch); |
3270 | } | 2675 | } |
3271 | restore_flags(flags); | 2676 | spin_unlock_irqrestore(&epca_lock, flags); |
3272 | |||
3273 | } /* End if channel valid */ | 2677 | } /* End if channel valid */ |
3274 | |||
3275 | } /* End pc_throttle */ | 2678 | } /* End pc_throttle */ |
3276 | 2679 | ||
3277 | /* --------------------- Begin unthrottle ----------------------- */ | 2680 | /* --------------------- Begin unthrottle ----------------------- */ |
3278 | 2681 | ||
3279 | static void pc_unthrottle(struct tty_struct *tty) | 2682 | static void pc_unthrottle(struct tty_struct *tty) |
3280 | { /* Begin pc_unthrottle */ | 2683 | { /* Begin pc_unthrottle */ |
3281 | |||
3282 | struct channel *ch; | 2684 | struct channel *ch; |
3283 | unsigned long flags; | 2685 | unsigned long flags; |
3284 | volatile struct board_chan *bc; | ||
3285 | |||
3286 | |||
3287 | /* --------------------------------------------------------- | 2686 | /* --------------------------------------------------------- |
3288 | verifyChannel returns the channel from the tty struct | 2687 | verifyChannel returns the channel from the tty struct |
3289 | if it is valid. This serves as a sanity check. | 2688 | if it is valid. This serves as a sanity check. |
3290 | ------------------------------------------------------------- */ | 2689 | ------------------------------------------------------------- */ |
3291 | 2690 | if ((ch = verifyChannel(tty)) != NULL) { /* Begin if channel valid */ | |
3292 | if ((ch = verifyChannel(tty)) != NULL) | ||
3293 | { /* Begin if channel valid */ | ||
3294 | |||
3295 | |||
3296 | /* Just in case output was resumed because of a change in Digi-flow */ | 2691 | /* Just in case output was resumed because of a change in Digi-flow */ |
3297 | save_flags(flags); | 2692 | spin_lock_irqsave(&epca_lock, flags); |
3298 | cli(); | 2693 | if (ch->statusflags & RXSTOPPED) { |
3299 | |||
3300 | if (ch->statusflags & RXSTOPPED) | ||
3301 | { | ||
3302 | |||
3303 | globalwinon(ch); | 2694 | globalwinon(ch); |
3304 | bc = ch->brdchan; | ||
3305 | fepcmd(ch, RESUMERX, 0, 0, 0, 0); | 2695 | fepcmd(ch, RESUMERX, 0, 0, 0, 0); |
3306 | |||
3307 | ch->statusflags &= ~RXSTOPPED; | 2696 | ch->statusflags &= ~RXSTOPPED; |
3308 | memoff(ch); | 2697 | memoff(ch); |
3309 | } | 2698 | } |
3310 | restore_flags(flags); | 2699 | spin_unlock_irqrestore(&epca_lock, flags); |
3311 | |||
3312 | } /* End if channel valid */ | 2700 | } /* End if channel valid */ |
3313 | |||
3314 | } /* End pc_unthrottle */ | 2701 | } /* End pc_unthrottle */ |
3315 | 2702 | ||
3316 | /* --------------------- Begin digi_send_break ----------------------- */ | 2703 | /* --------------------- Begin digi_send_break ----------------------- */ |
3317 | 2704 | ||
3318 | void digi_send_break(struct channel *ch, int msec) | 2705 | void digi_send_break(struct channel *ch, int msec) |
3319 | { /* Begin digi_send_break */ | 2706 | { /* Begin digi_send_break */ |
3320 | |||
3321 | unsigned long flags; | 2707 | unsigned long flags; |
3322 | 2708 | ||
3323 | save_flags(flags); | 2709 | spin_lock_irqsave(&epca_lock, flags); |
3324 | cli(); | ||
3325 | globalwinon(ch); | 2710 | globalwinon(ch); |
3326 | |||
3327 | /* -------------------------------------------------------------------- | 2711 | /* -------------------------------------------------------------------- |
3328 | Maybe I should send an infinite break here, schedule() for | 2712 | Maybe I should send an infinite break here, schedule() for |
3329 | msec amount of time, and then stop the break. This way, | 2713 | msec amount of time, and then stop the break. This way, |
@@ -3331,36 +2715,28 @@ void digi_send_break(struct channel *ch, int msec) | |||
3331 | to be called (i.e. via an ioctl()) more than once in msec amount | 2715 | to be called (i.e. via an ioctl()) more than once in msec amount |
3332 | of time. Try this for now... | 2716 | of time. Try this for now... |
3333 | ------------------------------------------------------------------------ */ | 2717 | ------------------------------------------------------------------------ */ |
3334 | |||
3335 | fepcmd(ch, SENDBREAK, msec, 0, 10, 0); | 2718 | fepcmd(ch, SENDBREAK, msec, 0, 10, 0); |
3336 | memoff(ch); | 2719 | memoff(ch); |
3337 | 2720 | spin_unlock_irqrestore(&epca_lock, flags); | |
3338 | restore_flags(flags); | ||
3339 | |||
3340 | } /* End digi_send_break */ | 2721 | } /* End digi_send_break */ |
3341 | 2722 | ||
3342 | /* --------------------- Begin setup_empty_event ----------------------- */ | 2723 | /* --------------------- Begin setup_empty_event ----------------------- */ |
3343 | 2724 | ||
2725 | /* Caller MUST hold the lock */ | ||
2726 | |||
3344 | static void setup_empty_event(struct tty_struct *tty, struct channel *ch) | 2727 | static void setup_empty_event(struct tty_struct *tty, struct channel *ch) |
3345 | { /* Begin setup_empty_event */ | 2728 | { /* Begin setup_empty_event */ |
3346 | 2729 | ||
3347 | volatile struct board_chan *bc = ch->brdchan; | 2730 | struct board_chan *bc = ch->brdchan; |
3348 | unsigned long int flags; | ||
3349 | 2731 | ||
3350 | save_flags(flags); | ||
3351 | cli(); | ||
3352 | globalwinon(ch); | 2732 | globalwinon(ch); |
3353 | ch->statusflags |= EMPTYWAIT; | 2733 | ch->statusflags |= EMPTYWAIT; |
3354 | |||
3355 | /* ------------------------------------------------------------------ | 2734 | /* ------------------------------------------------------------------ |
3356 | When set the iempty flag request a event to be generated when the | 2735 | When set the iempty flag request a event to be generated when the |
3357 | transmit buffer is empty (If there is no BREAK in progress). | 2736 | transmit buffer is empty (If there is no BREAK in progress). |
3358 | --------------------------------------------------------------------- */ | 2737 | --------------------------------------------------------------------- */ |
3359 | 2738 | writeb(1, &bc->iempty); | |
3360 | bc->iempty = 1; | ||
3361 | memoff(ch); | 2739 | memoff(ch); |
3362 | restore_flags(flags); | ||
3363 | |||
3364 | } /* End setup_empty_event */ | 2740 | } /* End setup_empty_event */ |
3365 | 2741 | ||
3366 | /* --------------------- Begin get_termio ----------------------- */ | 2742 | /* --------------------- Begin get_termio ----------------------- */ |
@@ -3369,10 +2745,10 @@ static int get_termio(struct tty_struct * tty, struct termio __user * termio) | |||
3369 | { /* Begin get_termio */ | 2745 | { /* Begin get_termio */ |
3370 | return kernel_termios_to_user_termio(termio, tty->termios); | 2746 | return kernel_termios_to_user_termio(termio, tty->termios); |
3371 | } /* End get_termio */ | 2747 | } /* End get_termio */ |
2748 | |||
3372 | /* ---------------------- Begin epca_setup -------------------------- */ | 2749 | /* ---------------------- Begin epca_setup -------------------------- */ |
3373 | void epca_setup(char *str, int *ints) | 2750 | void epca_setup(char *str, int *ints) |
3374 | { /* Begin epca_setup */ | 2751 | { /* Begin epca_setup */ |
3375 | |||
3376 | struct board_info board; | 2752 | struct board_info board; |
3377 | int index, loop, last; | 2753 | int index, loop, last; |
3378 | char *temp, *t2; | 2754 | char *temp, *t2; |
@@ -3394,49 +2770,41 @@ void epca_setup(char *str, int *ints) | |||
3394 | for (last = 0, index = 1; index <= ints[0]; index++) | 2770 | for (last = 0, index = 1; index <= ints[0]; index++) |
3395 | switch(index) | 2771 | switch(index) |
3396 | { /* Begin parse switch */ | 2772 | { /* Begin parse switch */ |
3397 | |||
3398 | case 1: | 2773 | case 1: |
3399 | board.status = ints[index]; | 2774 | board.status = ints[index]; |
3400 | |||
3401 | /* --------------------------------------------------------- | 2775 | /* --------------------------------------------------------- |
3402 | We check for 2 (As opposed to 1; because 2 is a flag | 2776 | We check for 2 (As opposed to 1; because 2 is a flag |
3403 | instructing the driver to ignore epcaconfig.) For this | 2777 | instructing the driver to ignore epcaconfig.) For this |
3404 | reason we check for 2. | 2778 | reason we check for 2. |
3405 | ------------------------------------------------------------ */ | 2779 | ------------------------------------------------------------ */ |
3406 | if (board.status == 2) | 2780 | if (board.status == 2) { /* Begin ignore epcaconfig as well as lilo cmd line */ |
3407 | { /* Begin ignore epcaconfig as well as lilo cmd line */ | ||
3408 | nbdevs = 0; | 2781 | nbdevs = 0; |
3409 | num_cards = 0; | 2782 | num_cards = 0; |
3410 | return; | 2783 | return; |
3411 | } /* End ignore epcaconfig as well as lilo cmd line */ | 2784 | } /* End ignore epcaconfig as well as lilo cmd line */ |
3412 | 2785 | ||
3413 | if (board.status > 2) | 2786 | if (board.status > 2) { |
3414 | { | 2787 | printk(KERN_ERR "epca_setup: Invalid board status 0x%x\n", board.status); |
3415 | printk(KERN_ERR "<Error> - epca_setup: Invalid board status 0x%x\n", board.status); | ||
3416 | invalid_lilo_config = 1; | 2788 | invalid_lilo_config = 1; |
3417 | setup_error_code |= INVALID_BOARD_STATUS; | 2789 | setup_error_code |= INVALID_BOARD_STATUS; |
3418 | return; | 2790 | return; |
3419 | } | 2791 | } |
3420 | last = index; | 2792 | last = index; |
3421 | break; | 2793 | break; |
3422 | |||
3423 | case 2: | 2794 | case 2: |
3424 | board.type = ints[index]; | 2795 | board.type = ints[index]; |
3425 | if (board.type >= PCIXEM) | 2796 | if (board.type >= PCIXEM) { |
3426 | { | 2797 | printk(KERN_ERR "epca_setup: Invalid board type 0x%x\n", board.type); |
3427 | printk(KERN_ERR "<Error> - epca_setup: Invalid board type 0x%x\n", board.type); | ||
3428 | invalid_lilo_config = 1; | 2798 | invalid_lilo_config = 1; |
3429 | setup_error_code |= INVALID_BOARD_TYPE; | 2799 | setup_error_code |= INVALID_BOARD_TYPE; |
3430 | return; | 2800 | return; |
3431 | } | 2801 | } |
3432 | last = index; | 2802 | last = index; |
3433 | break; | 2803 | break; |
3434 | |||
3435 | case 3: | 2804 | case 3: |
3436 | board.altpin = ints[index]; | 2805 | board.altpin = ints[index]; |
3437 | if (board.altpin > 1) | 2806 | if (board.altpin > 1) { |
3438 | { | 2807 | printk(KERN_ERR "epca_setup: Invalid board altpin 0x%x\n", board.altpin); |
3439 | printk(KERN_ERR "<Error> - epca_setup: Invalid board altpin 0x%x\n", board.altpin); | ||
3440 | invalid_lilo_config = 1; | 2808 | invalid_lilo_config = 1; |
3441 | setup_error_code |= INVALID_ALTPIN; | 2809 | setup_error_code |= INVALID_ALTPIN; |
3442 | return; | 2810 | return; |
@@ -3446,9 +2814,8 @@ void epca_setup(char *str, int *ints) | |||
3446 | 2814 | ||
3447 | case 4: | 2815 | case 4: |
3448 | board.numports = ints[index]; | 2816 | board.numports = ints[index]; |
3449 | if ((board.numports < 2) || (board.numports > 256)) | 2817 | if (board.numports < 2 || board.numports > 256) { |
3450 | { | 2818 | printk(KERN_ERR "epca_setup: Invalid board numports 0x%x\n", board.numports); |
3451 | printk(KERN_ERR "<Error> - epca_setup: Invalid board numports 0x%x\n", board.numports); | ||
3452 | invalid_lilo_config = 1; | 2819 | invalid_lilo_config = 1; |
3453 | setup_error_code |= INVALID_NUM_PORTS; | 2820 | setup_error_code |= INVALID_NUM_PORTS; |
3454 | return; | 2821 | return; |
@@ -3458,10 +2825,9 @@ void epca_setup(char *str, int *ints) | |||
3458 | break; | 2825 | break; |
3459 | 2826 | ||
3460 | case 5: | 2827 | case 5: |
3461 | board.port = (unsigned char *)ints[index]; | 2828 | board.port = ints[index]; |
3462 | if (ints[index] <= 0) | 2829 | if (ints[index] <= 0) { |
3463 | { | 2830 | printk(KERN_ERR "epca_setup: Invalid io port 0x%x\n", (unsigned int)board.port); |
3464 | printk(KERN_ERR "<Error> - epca_setup: Invalid io port 0x%x\n", (unsigned int)board.port); | ||
3465 | invalid_lilo_config = 1; | 2831 | invalid_lilo_config = 1; |
3466 | setup_error_code |= INVALID_PORT_BASE; | 2832 | setup_error_code |= INVALID_PORT_BASE; |
3467 | return; | 2833 | return; |
@@ -3470,10 +2836,9 @@ void epca_setup(char *str, int *ints) | |||
3470 | break; | 2836 | break; |
3471 | 2837 | ||
3472 | case 6: | 2838 | case 6: |
3473 | board.membase = (unsigned char *)ints[index]; | 2839 | board.membase = ints[index]; |
3474 | if (ints[index] <= 0) | 2840 | if (ints[index] <= 0) { |
3475 | { | 2841 | printk(KERN_ERR "epca_setup: Invalid memory base 0x%x\n",(unsigned int)board.membase); |
3476 | printk(KERN_ERR "<Error> - epca_setup: Invalid memory base 0x%x\n",(unsigned int)board.membase); | ||
3477 | invalid_lilo_config = 1; | 2842 | invalid_lilo_config = 1; |
3478 | setup_error_code |= INVALID_MEM_BASE; | 2843 | setup_error_code |= INVALID_MEM_BASE; |
3479 | return; | 2844 | return; |
@@ -3487,21 +2852,16 @@ void epca_setup(char *str, int *ints) | |||
3487 | 2852 | ||
3488 | } /* End parse switch */ | 2853 | } /* End parse switch */ |
3489 | 2854 | ||
3490 | while (str && *str) | 2855 | while (str && *str) { /* Begin while there is a string arg */ |
3491 | { /* Begin while there is a string arg */ | ||
3492 | |||
3493 | /* find the next comma or terminator */ | 2856 | /* find the next comma or terminator */ |
3494 | temp = str; | 2857 | temp = str; |
3495 | |||
3496 | /* While string is not null, and a comma hasn't been found */ | 2858 | /* While string is not null, and a comma hasn't been found */ |
3497 | while (*temp && (*temp != ',')) | 2859 | while (*temp && (*temp != ',')) |
3498 | temp++; | 2860 | temp++; |
3499 | |||
3500 | if (!*temp) | 2861 | if (!*temp) |
3501 | temp = NULL; | 2862 | temp = NULL; |
3502 | else | 2863 | else |
3503 | *temp++ = 0; | 2864 | *temp++ = 0; |
3504 | |||
3505 | /* Set index to the number of args + 1 */ | 2865 | /* Set index to the number of args + 1 */ |
3506 | index = last + 1; | 2866 | index = last + 1; |
3507 | 2867 | ||
@@ -3511,12 +2871,10 @@ void epca_setup(char *str, int *ints) | |||
3511 | len = strlen(str); | 2871 | len = strlen(str); |
3512 | if (strncmp("Disable", str, len) == 0) | 2872 | if (strncmp("Disable", str, len) == 0) |
3513 | board.status = 0; | 2873 | board.status = 0; |
3514 | else | 2874 | else if (strncmp("Enable", str, len) == 0) |
3515 | if (strncmp("Enable", str, len) == 0) | ||
3516 | board.status = 1; | 2875 | board.status = 1; |
3517 | else | 2876 | else { |
3518 | { | 2877 | printk(KERN_ERR "epca_setup: Invalid status %s\n", str); |
3519 | printk(KERN_ERR "<Error> - epca_setup: Invalid status %s\n", str); | ||
3520 | invalid_lilo_config = 1; | 2878 | invalid_lilo_config = 1; |
3521 | setup_error_code |= INVALID_BOARD_STATUS; | 2879 | setup_error_code |= INVALID_BOARD_STATUS; |
3522 | return; | 2880 | return; |
@@ -3525,22 +2883,17 @@ void epca_setup(char *str, int *ints) | |||
3525 | break; | 2883 | break; |
3526 | 2884 | ||
3527 | case 2: | 2885 | case 2: |
3528 | |||
3529 | for(loop = 0; loop < EPCA_NUM_TYPES; loop++) | 2886 | for(loop = 0; loop < EPCA_NUM_TYPES; loop++) |
3530 | if (strcmp(board_desc[loop], str) == 0) | 2887 | if (strcmp(board_desc[loop], str) == 0) |
3531 | break; | 2888 | break; |
3532 | |||
3533 | |||
3534 | /* --------------------------------------------------------------- | 2889 | /* --------------------------------------------------------------- |
3535 | If the index incremented above refers to a legitamate board | 2890 | If the index incremented above refers to a legitamate board |
3536 | type set it here. | 2891 | type set it here. |
3537 | ------------------------------------------------------------------*/ | 2892 | ------------------------------------------------------------------*/ |
3538 | |||
3539 | if (index < EPCA_NUM_TYPES) | 2893 | if (index < EPCA_NUM_TYPES) |
3540 | board.type = loop; | 2894 | board.type = loop; |
3541 | else | 2895 | else { |
3542 | { | 2896 | printk(KERN_ERR "epca_setup: Invalid board type: %s\n", str); |
3543 | printk(KERN_ERR "<Error> - epca_setup: Invalid board type: %s\n", str); | ||
3544 | invalid_lilo_config = 1; | 2897 | invalid_lilo_config = 1; |
3545 | setup_error_code |= INVALID_BOARD_TYPE; | 2898 | setup_error_code |= INVALID_BOARD_TYPE; |
3546 | return; | 2899 | return; |
@@ -3552,12 +2905,10 @@ void epca_setup(char *str, int *ints) | |||
3552 | len = strlen(str); | 2905 | len = strlen(str); |
3553 | if (strncmp("Disable", str, len) == 0) | 2906 | if (strncmp("Disable", str, len) == 0) |
3554 | board.altpin = 0; | 2907 | board.altpin = 0; |
3555 | else | 2908 | else if (strncmp("Enable", str, len) == 0) |
3556 | if (strncmp("Enable", str, len) == 0) | ||
3557 | board.altpin = 1; | 2909 | board.altpin = 1; |
3558 | else | 2910 | else { |
3559 | { | 2911 | printk(KERN_ERR "epca_setup: Invalid altpin %s\n", str); |
3560 | printk(KERN_ERR "<Error> - epca_setup: Invalid altpin %s\n", str); | ||
3561 | invalid_lilo_config = 1; | 2912 | invalid_lilo_config = 1; |
3562 | setup_error_code |= INVALID_ALTPIN; | 2913 | setup_error_code |= INVALID_ALTPIN; |
3563 | return; | 2914 | return; |
@@ -3570,9 +2921,8 @@ void epca_setup(char *str, int *ints) | |||
3570 | while (isdigit(*t2)) | 2921 | while (isdigit(*t2)) |
3571 | t2++; | 2922 | t2++; |
3572 | 2923 | ||
3573 | if (*t2) | 2924 | if (*t2) { |
3574 | { | 2925 | printk(KERN_ERR "epca_setup: Invalid port count %s\n", str); |
3575 | printk(KERN_ERR "<Error> - epca_setup: Invalid port count %s\n", str); | ||
3576 | invalid_lilo_config = 1; | 2926 | invalid_lilo_config = 1; |
3577 | setup_error_code |= INVALID_NUM_PORTS; | 2927 | setup_error_code |= INVALID_NUM_PORTS; |
3578 | return; | 2928 | return; |
@@ -3601,15 +2951,14 @@ void epca_setup(char *str, int *ints) | |||
3601 | while (isxdigit(*t2)) | 2951 | while (isxdigit(*t2)) |
3602 | t2++; | 2952 | t2++; |
3603 | 2953 | ||
3604 | if (*t2) | 2954 | if (*t2) { |
3605 | { | 2955 | printk(KERN_ERR "epca_setup: Invalid i/o address %s\n", str); |
3606 | printk(KERN_ERR "<Error> - epca_setup: Invalid i/o address %s\n", str); | ||
3607 | invalid_lilo_config = 1; | 2956 | invalid_lilo_config = 1; |
3608 | setup_error_code |= INVALID_PORT_BASE; | 2957 | setup_error_code |= INVALID_PORT_BASE; |
3609 | return; | 2958 | return; |
3610 | } | 2959 | } |
3611 | 2960 | ||
3612 | board.port = (unsigned char *)simple_strtoul(str, NULL, 16); | 2961 | board.port = simple_strtoul(str, NULL, 16); |
3613 | last = index; | 2962 | last = index; |
3614 | break; | 2963 | break; |
3615 | 2964 | ||
@@ -3618,52 +2967,38 @@ void epca_setup(char *str, int *ints) | |||
3618 | while (isxdigit(*t2)) | 2967 | while (isxdigit(*t2)) |
3619 | t2++; | 2968 | t2++; |
3620 | 2969 | ||
3621 | if (*t2) | 2970 | if (*t2) { |
3622 | { | 2971 | printk(KERN_ERR "epca_setup: Invalid memory base %s\n",str); |
3623 | printk(KERN_ERR "<Error> - epca_setup: Invalid memory base %s\n",str); | ||
3624 | invalid_lilo_config = 1; | 2972 | invalid_lilo_config = 1; |
3625 | setup_error_code |= INVALID_MEM_BASE; | 2973 | setup_error_code |= INVALID_MEM_BASE; |
3626 | return; | 2974 | return; |
3627 | } | 2975 | } |
3628 | 2976 | board.membase = simple_strtoul(str, NULL, 16); | |
3629 | board.membase = (unsigned char *)simple_strtoul(str, NULL, 16); | ||
3630 | last = index; | 2977 | last = index; |
3631 | break; | 2978 | break; |
3632 | |||
3633 | default: | 2979 | default: |
3634 | printk(KERN_ERR "PC/Xx: Too many string parms\n"); | 2980 | printk(KERN_ERR "epca: Too many string parms\n"); |
3635 | return; | 2981 | return; |
3636 | } | 2982 | } |
3637 | str = temp; | 2983 | str = temp; |
3638 | |||
3639 | } /* End while there is a string arg */ | 2984 | } /* End while there is a string arg */ |
3640 | 2985 | ||
3641 | 2986 | if (last < 6) { | |
3642 | if (last < 6) | 2987 | printk(KERN_ERR "epca: Insufficient parms specified\n"); |
3643 | { | ||
3644 | printk(KERN_ERR "PC/Xx: Insufficient parms specified\n"); | ||
3645 | return; | 2988 | return; |
3646 | } | 2989 | } |
3647 | 2990 | ||
3648 | /* I should REALLY validate the stuff here */ | 2991 | /* I should REALLY validate the stuff here */ |
3649 | |||
3650 | /* Copies our local copy of board into boards */ | 2992 | /* Copies our local copy of board into boards */ |
3651 | memcpy((void *)&boards[num_cards],(void *)&board, sizeof(board)); | 2993 | memcpy((void *)&boards[num_cards],(void *)&board, sizeof(board)); |
3652 | |||
3653 | |||
3654 | /* Does this get called once per lilo arg are what ? */ | 2994 | /* Does this get called once per lilo arg are what ? */ |
3655 | |||
3656 | printk(KERN_INFO "PC/Xx: Added board %i, %s %i ports at 0x%4.4X base 0x%6.6X\n", | 2995 | printk(KERN_INFO "PC/Xx: Added board %i, %s %i ports at 0x%4.4X base 0x%6.6X\n", |
3657 | num_cards, board_desc[board.type], | 2996 | num_cards, board_desc[board.type], |
3658 | board.numports, (int)board.port, (unsigned int) board.membase); | 2997 | board.numports, (int)board.port, (unsigned int) board.membase); |
3659 | |||
3660 | num_cards++; | 2998 | num_cards++; |
3661 | |||
3662 | } /* End epca_setup */ | 2999 | } /* End epca_setup */ |
3663 | 3000 | ||
3664 | 3001 | ||
3665 | |||
3666 | #ifdef ENABLE_PCI | ||
3667 | /* ------------------------ Begin init_PCI --------------------------- */ | 3002 | /* ------------------------ Begin init_PCI --------------------------- */ |
3668 | 3003 | ||
3669 | enum epic_board_types { | 3004 | enum epic_board_types { |
@@ -3685,7 +3020,6 @@ static struct { | |||
3685 | { PCIXRJ, 2, }, | 3020 | { PCIXRJ, 2, }, |
3686 | }; | 3021 | }; |
3687 | 3022 | ||
3688 | |||
3689 | static int __devinit epca_init_one (struct pci_dev *pdev, | 3023 | static int __devinit epca_init_one (struct pci_dev *pdev, |
3690 | const struct pci_device_id *ent) | 3024 | const struct pci_device_id *ent) |
3691 | { | 3025 | { |
@@ -3711,10 +3045,8 @@ static int __devinit epca_init_one (struct pci_dev *pdev, | |||
3711 | boards[board_idx].status = ENABLED; | 3045 | boards[board_idx].status = ENABLED; |
3712 | boards[board_idx].type = epca_info_tbl[info_idx].board_type; | 3046 | boards[board_idx].type = epca_info_tbl[info_idx].board_type; |
3713 | boards[board_idx].numports = 0x0; | 3047 | boards[board_idx].numports = 0x0; |
3714 | boards[board_idx].port = | 3048 | boards[board_idx].port = addr + PCI_IO_OFFSET; |
3715 | (unsigned char *)((char *) addr + PCI_IO_OFFSET); | 3049 | boards[board_idx].membase = addr; |
3716 | boards[board_idx].membase = | ||
3717 | (unsigned char *)((char *) addr); | ||
3718 | 3050 | ||
3719 | if (!request_mem_region (addr + PCI_IO_OFFSET, 0x200000, "epca")) { | 3051 | if (!request_mem_region (addr + PCI_IO_OFFSET, 0x200000, "epca")) { |
3720 | printk (KERN_ERR PFX "resource 0x%x @ 0x%lx unavailable\n", | 3052 | printk (KERN_ERR PFX "resource 0x%x @ 0x%lx unavailable\n", |
@@ -3775,15 +3107,13 @@ static struct pci_device_id epca_pci_tbl[] = { | |||
3775 | MODULE_DEVICE_TABLE(pci, epca_pci_tbl); | 3107 | MODULE_DEVICE_TABLE(pci, epca_pci_tbl); |
3776 | 3108 | ||
3777 | int __init init_PCI (void) | 3109 | int __init init_PCI (void) |
3778 | { /* Begin init_PCI */ | 3110 | { /* Begin init_PCI */ |
3779 | memset (&epca_driver, 0, sizeof (epca_driver)); | 3111 | memset (&epca_driver, 0, sizeof (epca_driver)); |
3780 | epca_driver.name = "epca"; | 3112 | epca_driver.name = "epca"; |
3781 | epca_driver.id_table = epca_pci_tbl; | 3113 | epca_driver.id_table = epca_pci_tbl; |
3782 | epca_driver.probe = epca_init_one; | 3114 | epca_driver.probe = epca_init_one; |
3783 | 3115 | ||
3784 | return pci_register_driver(&epca_driver); | 3116 | return pci_register_driver(&epca_driver); |
3785 | } /* End init_PCI */ | 3117 | } |
3786 | |||
3787 | #endif /* ENABLE_PCI */ | ||
3788 | 3118 | ||
3789 | MODULE_LICENSE("GPL"); | 3119 | MODULE_LICENSE("GPL"); |