aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAlan Cox <alan@lxorguk.ukuu.org.uk>2005-09-06 18:16:44 -0400
committerLinus Torvalds <torvalds@g5.osdl.org>2005-09-07 19:57:20 -0400
commitf2cf8e25ba4cf4e0881e612125858b4eed563ee4 (patch)
tree194b4015f7265924fc02da4741150f379e7f2c7a
parent5dd42c262bd742fa3602180bbe5550b4828de8f3 (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>
-rw-r--r--drivers/char/Kconfig2
-rw-r--r--drivers/char/digi1.h38
-rw-r--r--drivers/char/digiFep1.h154
-rw-r--r--drivers/char/epca.c1588
-rw-r--r--drivers/char/epca.h108
5 files changed, 610 insertions, 1280 deletions
diff --git a/drivers/char/Kconfig b/drivers/char/Kconfig
index a1de06d76de6..2bc9d64db106 100644
--- a/drivers/char/Kconfig
+++ b/drivers/char/Kconfig
@@ -138,7 +138,7 @@ config CYZ_INTR
138 138
139config DIGIEPCA 139config DIGIEPCA
140 tristate "Digiboard Intelligent Async Support" 140 tristate "Digiboard Intelligent Async Support"
141 depends on SERIAL_NONSTANDARD && BROKEN_ON_SMP && (!64BIT || BROKEN) 141 depends on SERIAL_NONSTANDARD
142 ---help--- 142 ---help---
143 This is a driver for Digi International's Xx, Xeve, and Xem series 143 This is a driver for Digi International's Xx, Xeve, and Xem series
144 of cards which provide multiple serial ports. You would need 144 of cards which provide multiple serial ports. You would need
diff --git a/drivers/char/digi1.h b/drivers/char/digi1.h
index 184378d23f8c..94d4eab5d3ca 100644
--- a/drivers/char/digi1.h
+++ b/drivers/char/digi1.h
@@ -1,46 +1,46 @@
1/* Definitions for DigiBoard ditty(1) command. */ 1/* Definitions for DigiBoard ditty(1) command. */
2 2
3#if !defined(TIOCMODG) 3#if !defined(TIOCMODG)
4#define TIOCMODG ('d'<<8) | 250 /* get modem ctrl state */ 4#define TIOCMODG (('d'<<8) | 250) /* get modem ctrl state */
5#define TIOCMODS ('d'<<8) | 251 /* set modem ctrl state */ 5#define TIOCMODS (('d'<<8) | 251) /* set modem ctrl state */
6#endif 6#endif
7 7
8#if !defined(TIOCMSET) 8#if !defined(TIOCMSET)
9#define TIOCMSET ('d'<<8) | 252 /* set modem ctrl state */ 9#define TIOCMSET (('d'<<8) | 252) /* set modem ctrl state */
10#define TIOCMGET ('d'<<8) | 253 /* set modem ctrl state */ 10#define TIOCMGET (('d'<<8) | 253) /* set modem ctrl state */
11#endif 11#endif
12 12
13#if !defined(TIOCMBIC) 13#if !defined(TIOCMBIC)
14#define TIOCMBIC ('d'<<8) | 254 /* set modem ctrl state */ 14#define TIOCMBIC (('d'<<8) | 254) /* set modem ctrl state */
15#define TIOCMBIS ('d'<<8) | 255 /* set modem ctrl state */ 15#define TIOCMBIS (('d'<<8) | 255) /* set modem ctrl state */
16#endif 16#endif
17 17
18#if !defined(TIOCSDTR) 18#if !defined(TIOCSDTR)
19#define TIOCSDTR ('e'<<8) | 0 /* set DTR */ 19#define TIOCSDTR (('e'<<8) | 0) /* set DTR */
20#define TIOCCDTR ('e'<<8) | 1 /* clear DTR */ 20#define TIOCCDTR (('e'<<8) | 1) /* clear DTR */
21#endif 21#endif
22 22
23/************************************************************************ 23/************************************************************************
24 * Ioctl command arguments for DIGI parameters. 24 * Ioctl command arguments for DIGI parameters.
25 ************************************************************************/ 25 ************************************************************************/
26#define DIGI_GETA ('e'<<8) | 94 /* Read params */ 26#define DIGI_GETA (('e'<<8) | 94) /* Read params */
27 27
28#define DIGI_SETA ('e'<<8) | 95 /* Set params */ 28#define DIGI_SETA (('e'<<8) | 95) /* Set params */
29#define DIGI_SETAW ('e'<<8) | 96 /* Drain & set params */ 29#define DIGI_SETAW (('e'<<8) | 96) /* Drain & set params */
30#define DIGI_SETAF ('e'<<8) | 97 /* Drain, flush & set params */ 30#define DIGI_SETAF (('e'<<8) | 97) /* Drain, flush & set params */
31 31
32#define DIGI_GETFLOW ('e'<<8) | 99 /* Get startc/stopc flow */ 32#define DIGI_GETFLOW (('e'<<8) | 99) /* Get startc/stopc flow */
33 /* control characters */ 33 /* control characters */
34#define DIGI_SETFLOW ('e'<<8) | 100 /* Set startc/stopc flow */ 34#define DIGI_SETFLOW (('e'<<8) | 100) /* Set startc/stopc flow */
35 /* control characters */ 35 /* control characters */
36#define DIGI_GETAFLOW ('e'<<8) | 101 /* Get Aux. startc/stopc */ 36#define DIGI_GETAFLOW (('e'<<8) | 101) /* Get Aux. startc/stopc */
37 /* flow control chars */ 37 /* flow control chars */
38#define DIGI_SETAFLOW ('e'<<8) | 102 /* Set Aux. startc/stopc */ 38#define DIGI_SETAFLOW (('e'<<8) | 102) /* Set Aux. startc/stopc */
39 /* flow control chars */ 39 /* flow control chars */
40 40
41#define DIGI_GETINFO ('e'<<8) | 103 /* Fill in digi_info */ 41#define DIGI_GETINFO (('e'<<8) | 103) /* Fill in digi_info */
42#define DIGI_POLLER ('e'<<8) | 104 /* Turn on/off poller */ 42#define DIGI_POLLER (('e'<<8) | 104) /* Turn on/off poller */
43#define DIGI_INIT ('e'<<8) | 105 /* Allow things to run. */ 43#define DIGI_INIT (('e'<<8) | 105) /* Allow things to run. */
44 44
45struct digiflow_struct 45struct digiflow_struct
46{ 46{
diff --git a/drivers/char/digiFep1.h b/drivers/char/digiFep1.h
index c47d7fcb8400..3c1f1922c798 100644
--- a/drivers/char/digiFep1.h
+++ b/drivers/char/digiFep1.h
@@ -13,88 +13,88 @@
13 13
14struct global_data 14struct global_data
15{ 15{
16 volatile ushort cin; 16 u16 cin;
17 volatile ushort cout; 17 u16 cout;
18 volatile ushort cstart; 18 u16 cstart;
19 volatile ushort cmax; 19 u16 cmax;
20 volatile ushort ein; 20 u16 ein;
21 volatile ushort eout; 21 u16 eout;
22 volatile ushort istart; 22 u16 istart;
23 volatile ushort imax; 23 u16 imax;
24}; 24};
25 25
26 26
27struct board_chan 27struct board_chan
28{ 28{
29 int filler1; 29 u32 filler1;
30 int filler2; 30 u32 filler2;
31 volatile ushort tseg; 31 u16 tseg;
32 volatile ushort tin; 32 u16 tin;
33 volatile ushort tout; 33 u16 tout;
34 volatile ushort tmax; 34 u16 tmax;
35 35
36 volatile ushort rseg; 36 u16 rseg;
37 volatile ushort rin; 37 u16 rin;
38 volatile ushort rout; 38 u16 rout;
39 volatile ushort rmax; 39 u16 rmax;
40 40
41 volatile ushort tlow; 41 u16 tlow;
42 volatile ushort rlow; 42 u16 rlow;
43 volatile ushort rhigh; 43 u16 rhigh;
44 volatile ushort incr; 44 u16 incr;
45 45
46 volatile ushort etime; 46 u16 etime;
47 volatile ushort edelay; 47 u16 edelay;
48 volatile unchar *dev; 48 unchar *dev;
49 49
50 volatile ushort iflag; 50 u16 iflag;
51 volatile ushort oflag; 51 u16 oflag;
52 volatile ushort cflag; 52 u16 cflag;
53 volatile ushort gmask; 53 u16 gmask;
54 54
55 volatile ushort col; 55 u16 col;
56 volatile ushort delay; 56 u16 delay;
57 volatile ushort imask; 57 u16 imask;
58 volatile ushort tflush; 58 u16 tflush;
59 59
60 int filler3; 60 u32 filler3;
61 int filler4; 61 u32 filler4;
62 int filler5; 62 u32 filler5;
63 int filler6; 63 u32 filler6;
64 64
65 volatile unchar num; 65 u8 num;
66 volatile unchar ract; 66 u8 ract;
67 volatile unchar bstat; 67 u8 bstat;
68 volatile unchar tbusy; 68 u8 tbusy;
69 volatile unchar iempty; 69 u8 iempty;
70 volatile unchar ilow; 70 u8 ilow;
71 volatile unchar idata; 71 u8 idata;
72 volatile unchar eflag; 72 u8 eflag;
73 73
74 volatile unchar tflag; 74 u8 tflag;
75 volatile unchar rflag; 75 u8 rflag;
76 volatile unchar xmask; 76 u8 xmask;
77 volatile unchar xval; 77 u8 xval;
78 volatile unchar mstat; 78 u8 mstat;
79 volatile unchar mchange; 79 u8 mchange;
80 volatile unchar mint; 80 u8 mint;
81 volatile unchar lstat; 81 u8 lstat;
82 82
83 volatile unchar mtran; 83 u8 mtran;
84 volatile unchar orun; 84 u8 orun;
85 volatile unchar startca; 85 u8 startca;
86 volatile unchar stopca; 86 u8 stopca;
87 volatile unchar startc; 87 u8 startc;
88 volatile unchar stopc; 88 u8 stopc;
89 volatile unchar vnext; 89 u8 vnext;
90 volatile unchar hflow; 90 u8 hflow;
91 91
92 volatile unchar fillc; 92 u8 fillc;
93 volatile unchar ochar; 93 u8 ochar;
94 volatile unchar omask; 94 u8 omask;
95 95
96 unchar filler7; 96 u8 filler7;
97 unchar filler8[28]; 97 u8 filler8[28];
98}; 98};
99 99
100 100
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
84static char mesg[100];
85static int nbdevs, num_cards, liloconfig; 74static int nbdevs, num_cards, liloconfig;
86static int digi_poller_inhibited = 1 ; 75static int digi_poller_inhibited = 1 ;
87 76
88static int setup_error_code; 77static int setup_error_code;
89static int invalid_lilo_config; 78static 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
83static 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
132static inline void memwinon(struct board_info *b, unsigned int win); 126static void memwinon(struct board_info *b, unsigned int win);
133static inline void memwinoff(struct board_info *b, unsigned int win); 127static void memwinoff(struct board_info *b, unsigned int win);
134static inline void globalwinon(struct channel *ch); 128static void globalwinon(struct channel *ch);
135static inline void rxwinon(struct channel *ch); 129static void rxwinon(struct channel *ch);
136static inline void txwinon(struct channel *ch); 130static void txwinon(struct channel *ch);
137static inline void memoff(struct channel *ch); 131static void memoff(struct channel *ch);
138static inline void assertgwinon(struct channel *ch); 132static void assertgwinon(struct channel *ch);
139static inline void assertmemoff(struct channel *ch); 133static 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
143static inline void pcxem_memwinon(struct board_info *b, unsigned int win); 137static void pcxem_memwinon(struct board_info *b, unsigned int win);
144static inline void pcxem_memwinoff(struct board_info *b, unsigned int win); 138static void pcxem_memwinoff(struct board_info *b, unsigned int win);
145static inline void pcxem_globalwinon(struct channel *ch); 139static void pcxem_globalwinon(struct channel *ch);
146static inline void pcxem_rxwinon(struct channel *ch); 140static void pcxem_rxwinon(struct channel *ch);
147static inline void pcxem_txwinon(struct channel *ch); 141static void pcxem_txwinon(struct channel *ch);
148static inline void pcxem_memoff(struct channel *ch); 142static 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
152static inline void pcxe_memwinon(struct board_info *b, unsigned int win); 146static void pcxe_memwinon(struct board_info *b, unsigned int win);
153static inline void pcxe_memwinoff(struct board_info *b, unsigned int win); 147static void pcxe_memwinoff(struct board_info *b, unsigned int win);
154static inline void pcxe_globalwinon(struct channel *ch); 148static void pcxe_globalwinon(struct channel *ch);
155static inline void pcxe_rxwinon(struct channel *ch); 149static void pcxe_rxwinon(struct channel *ch);
156static inline void pcxe_txwinon(struct channel *ch); 150static void pcxe_txwinon(struct channel *ch);
157static inline void pcxe_memoff(struct channel *ch); 151static 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
162static inline void pcxi_memwinon(struct board_info *b, unsigned int win); 156static void pcxi_memwinon(struct board_info *b, unsigned int win);
163static inline void pcxi_memwinoff(struct board_info *b, unsigned int win); 157static void pcxi_memwinoff(struct board_info *b, unsigned int win);
164static inline void pcxi_globalwinon(struct channel *ch); 158static void pcxi_globalwinon(struct channel *ch);
165static inline void pcxi_rxwinon(struct channel *ch); 159static void pcxi_rxwinon(struct channel *ch);
166static inline void pcxi_txwinon(struct channel *ch); 160static void pcxi_txwinon(struct channel *ch);
167static inline void pcxi_memoff(struct channel *ch); 161static 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
171static inline void dummy_memwinon(struct board_info *b, unsigned int win); 165static void dummy_memwinon(struct board_info *b, unsigned int win);
172static inline void dummy_memwinoff(struct board_info *b, unsigned int win); 166static void dummy_memwinoff(struct board_info *b, unsigned int win);
173static inline void dummy_globalwinon(struct channel *ch); 167static void dummy_globalwinon(struct channel *ch);
174static inline void dummy_rxwinon(struct channel *ch); 168static void dummy_rxwinon(struct channel *ch);
175static inline void dummy_txwinon(struct channel *ch); 169static void dummy_txwinon(struct channel *ch);
176static inline void dummy_memoff(struct channel *ch); 170static void dummy_memoff(struct channel *ch);
177static inline void dummy_assertgwinon(struct channel *ch); 171static void dummy_assertgwinon(struct channel *ch);
178static inline void dummy_assertmemoff(struct channel *ch); 172static void dummy_assertmemoff(struct channel *ch);
179 173
180/* ------------------- Begin declare functions ----------------------- */ 174/* ------------------- Begin declare functions ----------------------- */
181 175
182static inline struct channel *verifyChannel(register struct tty_struct *); 176static struct channel *verifyChannel(struct tty_struct *);
183static inline void pc_sched_event(struct channel *, int); 177static void pc_sched_event(struct channel *, int);
184static void epca_error(int, char *); 178static void epca_error(int, char *);
185static void pc_close(struct tty_struct *, struct file *); 179static void pc_close(struct tty_struct *, struct file *);
186static void shutdown(struct channel *); 180static void shutdown(struct channel *);
@@ -215,15 +209,11 @@ static void pc_unthrottle(struct tty_struct *tty);
215static void digi_send_break(struct channel *ch, int msec); 209static void digi_send_break(struct channel *ch, int msec);
216static void setup_empty_event(struct tty_struct *tty, struct channel *ch); 210static void setup_empty_event(struct tty_struct *tty, struct channel *ch);
217void epca_setup(char *, int *); 211void epca_setup(char *, int *);
218void console_print(const char *);
219 212
220static int get_termio(struct tty_struct *, struct termio __user *); 213static int get_termio(struct tty_struct *, struct termio __user *);
221static int pc_write(struct tty_struct *, const unsigned char *, int); 214static int pc_write(struct tty_struct *, const unsigned char *, int);
222int pc_init(void); 215static int pc_init(void);
223
224#ifdef ENABLE_PCI
225static int init_PCI(void); 216static 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
240static inline void memwinon(struct board_info *b, unsigned int win) 230static 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
245static inline void memwinoff(struct board_info *b, unsigned int win) 235static 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
250static inline void globalwinon(struct channel *ch) 240static void globalwinon(struct channel *ch)
251{ 241{
252 (ch->board->globalwinon)(ch); 242 (ch->board->globalwinon)(ch);
253} 243}
254 244
255static inline void rxwinon(struct channel *ch) 245static void rxwinon(struct channel *ch)
256{ 246{
257 (ch->board->rxwinon)(ch); 247 (ch->board->rxwinon)(ch);
258} 248}
259 249
260static inline void txwinon(struct channel *ch) 250static void txwinon(struct channel *ch)
261{ 251{
262 (ch->board->txwinon)(ch); 252 (ch->board->txwinon)(ch);
263} 253}
264 254
265static inline void memoff(struct channel *ch) 255static void memoff(struct channel *ch)
266{ 256{
267 (ch->board->memoff)(ch); 257 (ch->board->memoff)(ch);
268} 258}
269static inline void assertgwinon(struct channel *ch) 259static void assertgwinon(struct channel *ch)
270{ 260{
271 (ch->board->assertgwinon)(ch); 261 (ch->board->assertgwinon)(ch);
272} 262}
273 263
274static inline void assertmemoff(struct channel *ch) 264static 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
284static inline void pcxem_memwinon(struct board_info *b, unsigned int win) 274static 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
289static inline void pcxem_memwinoff(struct board_info *b, unsigned int win) 279static 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
294static inline void pcxem_globalwinon(struct channel *ch) 284static 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
299static inline void pcxem_rxwinon(struct channel *ch) 289static 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
304static inline void pcxem_txwinon(struct channel *ch) 294static 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
309static inline void pcxem_memoff(struct channel *ch) 299static 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
316static inline void pcxe_memwinon(struct board_info *b, unsigned int win) 306static 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
321static inline void pcxe_memwinoff(struct board_info *b, unsigned int win) 311static 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
328static inline void pcxe_globalwinon(struct channel *ch) 318static 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
333static inline void pcxe_rxwinon(struct channel *ch) 323static 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
338static inline void pcxe_txwinon(struct channel *ch) 328static 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
343static inline void pcxe_memoff(struct channel *ch) 333static 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
351static inline void pcxi_memwinon(struct board_info *b, unsigned int win) 341static 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
356static inline void pcxi_memwinoff(struct board_info *b, unsigned int win) 346static 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
361static inline void pcxi_globalwinon(struct channel *ch) 351static 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
366static inline void pcxi_rxwinon(struct channel *ch) 356static 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
371static inline void pcxi_txwinon(struct channel *ch) 361static 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
376static inline void pcxi_memoff(struct channel *ch) 366static 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
381static inline void pcxi_assertgwinon(struct channel *ch) 371static 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
386static inline void pcxi_assertmemoff(struct channel *ch) 376static 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
401static inline void dummy_memwinon(struct board_info *b, unsigned int win) 391static void dummy_memwinon(struct board_info *b, unsigned int win)
402{ 392{
403} 393}
404 394
405static inline void dummy_memwinoff(struct board_info *b, unsigned int win) 395static void dummy_memwinoff(struct board_info *b, unsigned int win)
406{ 396{
407} 397}
408 398
409static inline void dummy_globalwinon(struct channel *ch) 399static void dummy_globalwinon(struct channel *ch)
410{ 400{
411} 401}
412 402
413static inline void dummy_rxwinon(struct channel *ch) 403static void dummy_rxwinon(struct channel *ch)
414{ 404{
415} 405}
416 406
417static inline void dummy_txwinon(struct channel *ch) 407static void dummy_txwinon(struct channel *ch)
418{ 408{
419} 409}
420 410
421static inline void dummy_memoff(struct channel *ch) 411static void dummy_memoff(struct channel *ch)
422{ 412{
423} 413}
424 414
425static inline void dummy_assertgwinon(struct channel *ch) 415static void dummy_assertgwinon(struct channel *ch)
426{ 416{
427} 417}
428 418
429static inline void dummy_assertmemoff(struct channel *ch) 419static void dummy_assertmemoff(struct channel *ch)
430{ 420{
431} 421}
432 422
433/* ----------------- Begin verifyChannel function ----------------------- */ 423/* ----------------- Begin verifyChannel function ----------------------- */
434static inline struct channel *verifyChannel(register struct tty_struct *tty) 424static 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
464static inline void pc_sched_event(struct channel *ch, int event) 445static 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
481static void epca_error(int line, char *msg) 457static 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 ------------------------- */
490static void pc_close(struct tty_struct * tty, struct file * filp) 463static 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
637static void pc_hangup(struct tty_struct *tty) 581static 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)
672static int pc_write(struct tty_struct * tty, 611static 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
796static void pc_put_char(struct tty_struct *tty, unsigned char c) 715static 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
966static void pc_flush_chars(struct tty_struct *tty) 855static 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)
998static int block_til_ready(struct tty_struct *tty, 877static 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
1260static int __init epca_module_init(void) 1082static 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
1275module_init(epca_module_init); 1087module_init(epca_module_init);
1276#endif
1277 1088
1278#ifdef ENABLE_PCI
1279static struct pci_driver epca_driver; 1089static struct pci_driver epca_driver;
1280#endif
1281
1282#ifdef MODULE
1283/* -------------------- Begin cleanup_module ---------------------- */
1284 1090
1285static void __exit epca_module_exit(void) 1091static 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
1341module_exit(epca_module_exit); 1128module_exit(epca_module_exit);
1342#endif /* MODULE */
1343 1129
1344static struct tty_operations pc_ops = { 1130static 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
1374int __init pc_init(void) 1160static 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)
1992static void doevent(int crd) 1718static 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)
2146static void fepcmd(struct channel *ch, int cmd, int word_or_byte, 1817static 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
2256static unsigned termios2digi_h(struct channel *ch, unsigned cflag) 1890static 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 */
2385static void epcaparam(struct tty_struct *tty, struct channel *ch) 1998static 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 */
2550static void receive_data(struct channel *ch) 2113static 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
2674static int info_ioctl(struct tty_struct *tty, struct file * file, 2205static 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,
2750static int pc_tiocmget(struct tty_struct *tty, struct file *file) 2270static 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
3117static void do_softint(void *private_) 2576static 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
3191static void pc_start(struct tty_struct *tty) 2624static 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
3245static void pc_throttle(struct tty_struct * tty) 2660static 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
3279static void pc_unthrottle(struct tty_struct *tty) 2682static 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
3318void digi_send_break(struct channel *ch, int msec) 2705void 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
3344static void setup_empty_event(struct tty_struct *tty, struct channel *ch) 2727static 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 -------------------------- */
3373void epca_setup(char *str, int *ints) 2750void 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
3669enum epic_board_types { 3004enum epic_board_types {
@@ -3685,7 +3020,6 @@ static struct {
3685 { PCIXRJ, 2, }, 3020 { PCIXRJ, 2, },
3686}; 3021};
3687 3022
3688
3689static int __devinit epca_init_one (struct pci_dev *pdev, 3023static 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[] = {
3775MODULE_DEVICE_TABLE(pci, epca_pci_tbl); 3107MODULE_DEVICE_TABLE(pci, epca_pci_tbl);
3776 3108
3777int __init init_PCI (void) 3109int __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
3789MODULE_LICENSE("GPL"); 3119MODULE_LICENSE("GPL");
diff --git a/drivers/char/epca.h b/drivers/char/epca.h
index 52205ef71314..20eeb5a70e1a 100644
--- a/drivers/char/epca.h
+++ b/drivers/char/epca.h
@@ -85,73 +85,73 @@ static char *board_desc[] =
85struct channel 85struct channel
86{ 86{
87 long magic; 87 long magic;
88 unchar boardnum; 88 unsigned char boardnum;
89 unchar channelnum; 89 unsigned char channelnum;
90 unchar omodem; /* FEP output modem status */ 90 unsigned char omodem; /* FEP output modem status */
91 unchar imodem; /* FEP input modem status */ 91 unsigned char imodem; /* FEP input modem status */
92 unchar modemfake; /* Modem values to be forced */ 92 unsigned char modemfake; /* Modem values to be forced */
93 unchar modem; /* Force values */ 93 unsigned char modem; /* Force values */
94 unchar hflow; 94 unsigned char hflow;
95 unchar dsr; 95 unsigned char dsr;
96 unchar dcd; 96 unsigned char dcd;
97 unchar m_rts ; /* The bits used in whatever FEP */ 97 unsigned char m_rts ; /* The bits used in whatever FEP */
98 unchar m_dcd ; /* is indiginous to this board to */ 98 unsigned char m_dcd ; /* is indiginous to this board to */
99 unchar m_dsr ; /* represent each of the physical */ 99 unsigned char m_dsr ; /* represent each of the physical */
100 unchar m_cts ; /* handshake lines */ 100 unsigned char m_cts ; /* handshake lines */
101 unchar m_ri ; 101 unsigned char m_ri ;
102 unchar m_dtr ; 102 unsigned char m_dtr ;
103 unchar stopc; 103 unsigned char stopc;
104 unchar startc; 104 unsigned char startc;
105 unchar stopca; 105 unsigned char stopca;
106 unchar startca; 106 unsigned char startca;
107 unchar fepstopc; 107 unsigned char fepstopc;
108 unchar fepstartc; 108 unsigned char fepstartc;
109 unchar fepstopca; 109 unsigned char fepstopca;
110 unchar fepstartca; 110 unsigned char fepstartca;
111 unchar txwin; 111 unsigned char txwin;
112 unchar rxwin; 112 unsigned char rxwin;
113 ushort fepiflag; 113 unsigned short fepiflag;
114 ushort fepcflag; 114 unsigned short fepcflag;
115 ushort fepoflag; 115 unsigned short fepoflag;
116 ushort txbufhead; 116 unsigned short txbufhead;
117 ushort txbufsize; 117 unsigned short txbufsize;
118 ushort rxbufhead; 118 unsigned short rxbufhead;
119 ushort rxbufsize; 119 unsigned short rxbufsize;
120 int close_delay; 120 int close_delay;
121 int count; 121 int count;
122 int blocked_open; 122 int blocked_open;
123 ulong event; 123 unsigned long event;
124 int asyncflags; 124 int asyncflags;
125 uint dev; 125 uint dev;
126 ulong statusflags; 126 unsigned long statusflags;
127 ulong c_iflag; 127 unsigned long c_iflag;
128 ulong c_cflag; 128 unsigned long c_cflag;
129 ulong c_lflag; 129 unsigned long c_lflag;
130 ulong c_oflag; 130 unsigned long c_oflag;
131 unchar *txptr; 131 unsigned char *txptr;
132 unchar *rxptr; 132 unsigned char *rxptr;
133 unchar *tmp_buf; 133 unsigned char *tmp_buf;
134 struct board_info *board; 134 struct board_info *board;
135 volatile struct board_chan *brdchan; 135 struct board_chan *brdchan;
136 struct digi_struct digiext; 136 struct digi_struct digiext;
137 struct tty_struct *tty; 137 struct tty_struct *tty;
138 wait_queue_head_t open_wait; 138 wait_queue_head_t open_wait;
139 wait_queue_head_t close_wait; 139 wait_queue_head_t close_wait;
140 struct work_struct tqueue; 140 struct work_struct tqueue;
141 volatile struct global_data *mailbox; 141 struct global_data *mailbox;
142}; 142};
143 143
144struct board_info 144struct board_info
145{ 145{
146 unchar status; 146 unsigned char status;
147 unchar type; 147 unsigned char type;
148 unchar altpin; 148 unsigned char altpin;
149 ushort numports; 149 unsigned short numports;
150 unchar *port; 150 unsigned long port;
151 unchar *membase; 151 unsigned long membase;
152 unchar __iomem *re_map_port; 152 unsigned char __iomem *re_map_port;
153 unchar *re_map_membase; 153 unsigned char *re_map_membase;
154 ulong memory_seg; 154 unsigned long memory_seg;
155 void ( * memwinon ) (struct board_info *, unsigned int) ; 155 void ( * memwinon ) (struct board_info *, unsigned int) ;
156 void ( * memwinoff ) (struct board_info *, unsigned int) ; 156 void ( * memwinoff ) (struct board_info *, unsigned int) ;
157 void ( * globalwinon ) (struct channel *) ; 157 void ( * globalwinon ) (struct channel *) ;
@@ -160,6 +160,6 @@ struct board_info
160 void ( * memoff ) (struct channel *) ; 160 void ( * memoff ) (struct channel *) ;
161 void ( * assertgwinon ) (struct channel *) ; 161 void ( * assertgwinon ) (struct channel *) ;
162 void ( * assertmemoff ) (struct channel *) ; 162 void ( * assertmemoff ) (struct channel *) ;
163 unchar poller_inhibited ; 163 unsigned char poller_inhibited ;
164}; 164};
165 165