aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/isdn/act2000
diff options
context:
space:
mode:
authorJoe Perches <joe@perches.com>2012-02-19 22:52:38 -0500
committerJoe Perches <joe@perches.com>2012-02-21 12:04:01 -0500
commit475be4d85a274d0961593db41cf85689db1d583c (patch)
treeb2b8931eb747794730522c3cf1898e46948527b9 /drivers/isdn/act2000
parent0b0a635f79f91f3755b6518627ea06dd0dbfd523 (diff)
isdn: whitespace coding style cleanup
isdn source code uses a not-current coding style. Update the coding style used on a per-line basis so that git diff -w shows only elided blank lines at EOF. Done with emacs and some scripts and some typing. Built x86 allyesconfig. No detected change in objdump -d or size. Signed-off-by: Joe Perches <joe@perches.com>
Diffstat (limited to 'drivers/isdn/act2000')
-rw-r--r--drivers/isdn/act2000/act2000.h28
-rw-r--r--drivers/isdn/act2000/act2000_isa.c394
-rw-r--r--drivers/isdn/act2000/act2000_isa.h32
-rw-r--r--drivers/isdn/act2000/capi.c998
-rw-r--r--drivers/isdn/act2000/capi.h50
-rw-r--r--drivers/isdn/act2000/module.c806
6 files changed, 1154 insertions, 1154 deletions
diff --git a/drivers/isdn/act2000/act2000.h b/drivers/isdn/act2000/act2000.h
index 88c9423500d8..321d437f579e 100644
--- a/drivers/isdn/act2000/act2000.h
+++ b/drivers/isdn/act2000/act2000.h
@@ -4,7 +4,7 @@
4 * 4 *
5 * Author Fritz Elfert 5 * Author Fritz Elfert
6 * Copyright by Fritz Elfert <fritz@isdn4linux.de> 6 * Copyright by Fritz Elfert <fritz@isdn4linux.de>
7 * 7 *
8 * This software may be used and distributed according to the terms 8 * This software may be used and distributed according to the terms
9 * of the GNU General Public License, incorporated herein by reference. 9 * of the GNU General Public License, incorporated herein by reference.
10 * 10 *
@@ -40,21 +40,21 @@
40/* Struct for adding new cards */ 40/* Struct for adding new cards */
41typedef struct act2000_cdef { 41typedef struct act2000_cdef {
42 int bus; 42 int bus;
43 int port; 43 int port;
44 int irq; 44 int irq;
45 char id[10]; 45 char id[10];
46} act2000_cdef; 46} act2000_cdef;
47 47
48/* Struct for downloading firmware */ 48/* Struct for downloading firmware */
49typedef struct act2000_ddef { 49typedef struct act2000_ddef {
50 int length; /* Length of code */ 50 int length; /* Length of code */
51 char __user *buffer; /* Ptr. to code */ 51 char __user *buffer; /* Ptr. to code */
52} act2000_ddef; 52} act2000_ddef;
53 53
54typedef struct act2000_fwid { 54typedef struct act2000_fwid {
55 char isdn[4]; 55 char isdn[4];
56 char revlen[2]; 56 char revlen[2];
57 char revision[504]; 57 char revision[504];
58} act2000_fwid; 58} act2000_fwid;
59 59
60#if defined(__KERNEL__) || defined(__DEBUGVAR__) 60#if defined(__KERNEL__) || defined(__DEBUGVAR__)
@@ -128,8 +128,8 @@ typedef struct act2000_chan {
128 128
129typedef struct msn_entry { 129typedef struct msn_entry {
130 char eaz; 130 char eaz;
131 char msn[16]; 131 char msn[16];
132 struct msn_entry * next; 132 struct msn_entry *next;
133} msn_entry; 133} msn_entry;
134 134
135typedef struct irq_data_isa { 135typedef struct irq_data_isa {
@@ -183,17 +183,17 @@ typedef struct act2000_card {
183 183
184static inline void act2000_schedule_tx(act2000_card *card) 184static inline void act2000_schedule_tx(act2000_card *card)
185{ 185{
186 schedule_work(&card->snd_tq); 186 schedule_work(&card->snd_tq);
187} 187}
188 188
189static inline void act2000_schedule_rx(act2000_card *card) 189static inline void act2000_schedule_rx(act2000_card *card)
190{ 190{
191 schedule_work(&card->rcv_tq); 191 schedule_work(&card->rcv_tq);
192} 192}
193 193
194static inline void act2000_schedule_poll(act2000_card *card) 194static inline void act2000_schedule_poll(act2000_card *card)
195{ 195{
196 schedule_work(&card->poll_tq); 196 schedule_work(&card->poll_tq);
197} 197}
198 198
199extern char *act2000_find_eaz(act2000_card *, char); 199extern char *act2000_find_eaz(act2000_card *, char);
diff --git a/drivers/isdn/act2000/act2000_isa.c b/drivers/isdn/act2000/act2000_isa.c
index fea5b783335d..b5fad29a9ba6 100644
--- a/drivers/isdn/act2000/act2000_isa.c
+++ b/drivers/isdn/act2000/act2000_isa.c
@@ -4,7 +4,7 @@
4 * 4 *
5 * Author Fritz Elfert 5 * Author Fritz Elfert
6 * Copyright by Fritz Elfert <fritz@isdn4linux.de> 6 * Copyright by Fritz Elfert <fritz@isdn4linux.de>
7 * 7 *
8 * This software may be used and distributed according to the terms 8 * This software may be used and distributed according to the terms
9 * of the GNU General Public License, incorporated herein by reference. 9 * of the GNU General Public License, incorporated herein by reference.
10 * 10 *
@@ -25,99 +25,99 @@
25static int 25static int
26act2000_isa_reset(unsigned short portbase) 26act2000_isa_reset(unsigned short portbase)
27{ 27{
28 unsigned char reg; 28 unsigned char reg;
29 int i; 29 int i;
30 int found; 30 int found;
31 int serial = 0; 31 int serial = 0;
32 32
33 found = 0; 33 found = 0;
34 if ((reg = inb(portbase + ISA_COR)) != 0xff) { 34 if ((reg = inb(portbase + ISA_COR)) != 0xff) {
35 outb(reg | ISA_COR_RESET, portbase + ISA_COR); 35 outb(reg | ISA_COR_RESET, portbase + ISA_COR);
36 mdelay(10); 36 mdelay(10);
37 outb(reg, portbase + ISA_COR); 37 outb(reg, portbase + ISA_COR);
38 mdelay(10); 38 mdelay(10);
39 39
40 for (i = 0; i < 16; i++) { 40 for (i = 0; i < 16; i++) {
41 if (inb(portbase + ISA_ISR) & ISA_ISR_SERIAL) 41 if (inb(portbase + ISA_ISR) & ISA_ISR_SERIAL)
42 serial |= 0x10000; 42 serial |= 0x10000;
43 serial >>= 1; 43 serial >>= 1;
44 } 44 }
45 if (serial == ISA_SER_ID) 45 if (serial == ISA_SER_ID)
46 found++; 46 found++;
47 } 47 }
48 return found; 48 return found;
49} 49}
50 50
51int 51int
52act2000_isa_detect(unsigned short portbase) 52act2000_isa_detect(unsigned short portbase)
53{ 53{
54 int ret = 0; 54 int ret = 0;
55 55
56 if (request_region(portbase, ACT2000_PORTLEN, "act2000isa")) { 56 if (request_region(portbase, ACT2000_PORTLEN, "act2000isa")) {
57 ret = act2000_isa_reset(portbase); 57 ret = act2000_isa_reset(portbase);
58 release_region(portbase, ISA_REGION); 58 release_region(portbase, ISA_REGION);
59 } 59 }
60 return ret; 60 return ret;
61} 61}
62 62
63static irqreturn_t 63static irqreturn_t
64act2000_isa_interrupt(int dummy, void *dev_id) 64act2000_isa_interrupt(int dummy, void *dev_id)
65{ 65{
66 act2000_card *card = dev_id; 66 act2000_card *card = dev_id;
67 u_char istatus; 67 u_char istatus;
68 68
69 istatus = (inb(ISA_PORT_ISR) & 0x07); 69 istatus = (inb(ISA_PORT_ISR) & 0x07);
70 if (istatus & ISA_ISR_OUT) { 70 if (istatus & ISA_ISR_OUT) {
71 /* RX fifo has data */ 71 /* RX fifo has data */
72 istatus &= ISA_ISR_OUT_MASK; 72 istatus &= ISA_ISR_OUT_MASK;
73 outb(0, ISA_PORT_SIS); 73 outb(0, ISA_PORT_SIS);
74 act2000_isa_receive(card); 74 act2000_isa_receive(card);
75 outb(ISA_SIS_INT, ISA_PORT_SIS); 75 outb(ISA_SIS_INT, ISA_PORT_SIS);
76 } 76 }
77 if (istatus & ISA_ISR_ERR) { 77 if (istatus & ISA_ISR_ERR) {
78 /* Error Interrupt */ 78 /* Error Interrupt */
79 istatus &= ISA_ISR_ERR_MASK; 79 istatus &= ISA_ISR_ERR_MASK;
80 printk(KERN_WARNING "act2000: errIRQ\n"); 80 printk(KERN_WARNING "act2000: errIRQ\n");
81 } 81 }
82 if (istatus) 82 if (istatus)
83 printk(KERN_DEBUG "act2000: ?IRQ %d %02x\n", card->irq, istatus); 83 printk(KERN_DEBUG "act2000: ?IRQ %d %02x\n", card->irq, istatus);
84 return IRQ_HANDLED; 84 return IRQ_HANDLED;
85} 85}
86 86
87static void 87static void
88act2000_isa_select_irq(act2000_card * card) 88act2000_isa_select_irq(act2000_card *card)
89{ 89{
90 unsigned char reg; 90 unsigned char reg;
91 91
92 reg = (inb(ISA_PORT_COR) & ~ISA_COR_IRQOFF) | ISA_COR_PERR; 92 reg = (inb(ISA_PORT_COR) & ~ISA_COR_IRQOFF) | ISA_COR_PERR;
93 switch (card->irq) { 93 switch (card->irq) {
94 case 3: 94 case 3:
95 reg = ISA_COR_IRQ03; 95 reg = ISA_COR_IRQ03;
96 break; 96 break;
97 case 5: 97 case 5:
98 reg = ISA_COR_IRQ05; 98 reg = ISA_COR_IRQ05;
99 break; 99 break;
100 case 7: 100 case 7:
101 reg = ISA_COR_IRQ07; 101 reg = ISA_COR_IRQ07;
102 break; 102 break;
103 case 10: 103 case 10:
104 reg = ISA_COR_IRQ10; 104 reg = ISA_COR_IRQ10;
105 break; 105 break;
106 case 11: 106 case 11:
107 reg = ISA_COR_IRQ11; 107 reg = ISA_COR_IRQ11;
108 break; 108 break;
109 case 12: 109 case 12:
110 reg = ISA_COR_IRQ12; 110 reg = ISA_COR_IRQ12;
111 break; 111 break;
112 case 15: 112 case 15:
113 reg = ISA_COR_IRQ15; 113 reg = ISA_COR_IRQ15;
114 break; 114 break;
115 } 115 }
116 outb(reg, ISA_PORT_COR); 116 outb(reg, ISA_PORT_COR);
117} 117}
118 118
119static void 119static void
120act2000_isa_enable_irq(act2000_card * card) 120act2000_isa_enable_irq(act2000_card *card)
121{ 121{
122 act2000_isa_select_irq(card); 122 act2000_isa_select_irq(card);
123 /* Enable READ irq */ 123 /* Enable READ irq */
@@ -129,102 +129,102 @@ act2000_isa_enable_irq(act2000_card * card)
129 * If irq is -1, choose next free irq, else irq is given explicitly. 129 * If irq is -1, choose next free irq, else irq is given explicitly.
130 */ 130 */
131int 131int
132act2000_isa_config_irq(act2000_card * card, short irq) 132act2000_isa_config_irq(act2000_card *card, short irq)
133{ 133{
134 int old_irq; 134 int old_irq;
135 135
136 if (card->flags & ACT2000_FLAGS_IVALID) { 136 if (card->flags & ACT2000_FLAGS_IVALID) {
137 free_irq(card->irq, card); 137 free_irq(card->irq, card);
138 } 138 }
139 card->flags &= ~ACT2000_FLAGS_IVALID; 139 card->flags &= ~ACT2000_FLAGS_IVALID;
140 outb(ISA_COR_IRQOFF, ISA_PORT_COR); 140 outb(ISA_COR_IRQOFF, ISA_PORT_COR);
141 if (!irq) 141 if (!irq)
142 return 0; 142 return 0;
143 143
144 old_irq = card->irq; 144 old_irq = card->irq;
145 card->irq = irq; 145 card->irq = irq;
146 if (request_irq(irq, &act2000_isa_interrupt, 0, card->regname, card)) { 146 if (request_irq(irq, &act2000_isa_interrupt, 0, card->regname, card)) {
147 card->irq = old_irq; 147 card->irq = old_irq;
148 card->flags |= ACT2000_FLAGS_IVALID; 148 card->flags |= ACT2000_FLAGS_IVALID;
149 printk(KERN_WARNING 149 printk(KERN_WARNING
150 "act2000: Could not request irq %d\n",irq); 150 "act2000: Could not request irq %d\n", irq);
151 return -EBUSY; 151 return -EBUSY;
152 } else { 152 } else {
153 act2000_isa_select_irq(card); 153 act2000_isa_select_irq(card);
154 /* Disable READ and WRITE irq */ 154 /* Disable READ and WRITE irq */
155 outb(0, ISA_PORT_SIS); 155 outb(0, ISA_PORT_SIS);
156 outb(0, ISA_PORT_SOS); 156 outb(0, ISA_PORT_SOS);
157 } 157 }
158 return 0; 158 return 0;
159} 159}
160 160
161int 161int
162act2000_isa_config_port(act2000_card * card, unsigned short portbase) 162act2000_isa_config_port(act2000_card *card, unsigned short portbase)
163{ 163{
164 if (card->flags & ACT2000_FLAGS_PVALID) { 164 if (card->flags & ACT2000_FLAGS_PVALID) {
165 release_region(card->port, ISA_REGION); 165 release_region(card->port, ISA_REGION);
166 card->flags &= ~ACT2000_FLAGS_PVALID; 166 card->flags &= ~ACT2000_FLAGS_PVALID;
167 } 167 }
168 if (request_region(portbase, ACT2000_PORTLEN, card->regname) == NULL) 168 if (request_region(portbase, ACT2000_PORTLEN, card->regname) == NULL)
169 return -EBUSY; 169 return -EBUSY;
170 else { 170 else {
171 card->port = portbase; 171 card->port = portbase;
172 card->flags |= ACT2000_FLAGS_PVALID; 172 card->flags |= ACT2000_FLAGS_PVALID;
173 return 0; 173 return 0;
174 } 174 }
175} 175}
176 176
177/* 177/*
178 * Release ressources, used by an adaptor. 178 * Release ressources, used by an adaptor.
179 */ 179 */
180void 180void
181act2000_isa_release(act2000_card * card) 181act2000_isa_release(act2000_card *card)
182{ 182{
183 unsigned long flags; 183 unsigned long flags;
184 184
185 spin_lock_irqsave(&card->lock, flags); 185 spin_lock_irqsave(&card->lock, flags);
186 if (card->flags & ACT2000_FLAGS_IVALID) 186 if (card->flags & ACT2000_FLAGS_IVALID)
187 free_irq(card->irq, card); 187 free_irq(card->irq, card);
188 188
189 card->flags &= ~ACT2000_FLAGS_IVALID; 189 card->flags &= ~ACT2000_FLAGS_IVALID;
190 if (card->flags & ACT2000_FLAGS_PVALID) 190 if (card->flags & ACT2000_FLAGS_PVALID)
191 release_region(card->port, ISA_REGION); 191 release_region(card->port, ISA_REGION);
192 card->flags &= ~ACT2000_FLAGS_PVALID; 192 card->flags &= ~ACT2000_FLAGS_PVALID;
193 spin_unlock_irqrestore(&card->lock, flags); 193 spin_unlock_irqrestore(&card->lock, flags);
194} 194}
195 195
196static int 196static int
197act2000_isa_writeb(act2000_card * card, u_char data) 197act2000_isa_writeb(act2000_card *card, u_char data)
198{ 198{
199 u_char timeout = 40; 199 u_char timeout = 40;
200 200
201 while (timeout) { 201 while (timeout) {
202 if (inb(ISA_PORT_SOS) & ISA_SOS_READY) { 202 if (inb(ISA_PORT_SOS) & ISA_SOS_READY) {
203 outb(data, ISA_PORT_SDO); 203 outb(data, ISA_PORT_SDO);
204 return 0; 204 return 0;
205 } else { 205 } else {
206 timeout--; 206 timeout--;
207 udelay(10); 207 udelay(10);
208 } 208 }
209 } 209 }
210 return 1; 210 return 1;
211} 211}
212 212
213static int 213static int
214act2000_isa_readb(act2000_card * card, u_char * data) 214act2000_isa_readb(act2000_card *card, u_char *data)
215{ 215{
216 u_char timeout = 40; 216 u_char timeout = 40;
217 217
218 while (timeout) { 218 while (timeout) {
219 if (inb(ISA_PORT_SIS) & ISA_SIS_READY) { 219 if (inb(ISA_PORT_SIS) & ISA_SIS_READY) {
220 *data = inb(ISA_PORT_SDI); 220 *data = inb(ISA_PORT_SDI);
221 return 0; 221 return 0;
222 } else { 222 } else {
223 timeout--; 223 timeout--;
224 udelay(10); 224 udelay(10);
225 } 225 }
226 } 226 }
227 return 1; 227 return 1;
228} 228}
229 229
230void 230void
@@ -232,11 +232,11 @@ act2000_isa_receive(act2000_card *card)
232{ 232{
233 u_char c; 233 u_char c;
234 234
235 if (test_and_set_bit(ACT2000_LOCK_RX, (void *) &card->ilock) != 0) 235 if (test_and_set_bit(ACT2000_LOCK_RX, (void *) &card->ilock) != 0)
236 return; 236 return;
237 while (!act2000_isa_readb(card, &c)) { 237 while (!act2000_isa_readb(card, &c)) {
238 if (card->idat.isa.rcvidx < 8) { 238 if (card->idat.isa.rcvidx < 8) {
239 card->idat.isa.rcvhdr[card->idat.isa.rcvidx++] = c; 239 card->idat.isa.rcvhdr[card->idat.isa.rcvidx++] = c;
240 if (card->idat.isa.rcvidx == 8) { 240 if (card->idat.isa.rcvidx == 8) {
241 int valid = actcapi_chkhdr(card, (actcapi_msghdr *)&card->idat.isa.rcvhdr); 241 int valid = actcapi_chkhdr(card, (actcapi_msghdr *)&card->idat.isa.rcvhdr);
242 242
@@ -291,14 +291,14 @@ act2000_isa_receive(act2000_card *card)
291} 291}
292 292
293void 293void
294act2000_isa_send(act2000_card * card) 294act2000_isa_send(act2000_card *card)
295{ 295{
296 unsigned long flags; 296 unsigned long flags;
297 struct sk_buff *skb; 297 struct sk_buff *skb;
298 actcapi_msg *msg; 298 actcapi_msg *msg;
299 int l; 299 int l;
300 300
301 if (test_and_set_bit(ACT2000_LOCK_TX, (void *) &card->ilock) != 0) 301 if (test_and_set_bit(ACT2000_LOCK_TX, (void *) &card->ilock) != 0)
302 return; 302 return;
303 while (1) { 303 while (1) {
304 spin_lock_irqsave(&card->lock, flags); 304 spin_lock_irqsave(&card->lock, flags);
@@ -307,7 +307,7 @@ act2000_isa_send(act2000_card * card)
307 card->ack_msg = card->sbuf->data; 307 card->ack_msg = card->sbuf->data;
308 msg = (actcapi_msg *)card->sbuf->data; 308 msg = (actcapi_msg *)card->sbuf->data;
309 if ((msg->hdr.cmd.cmd == 0x86) && 309 if ((msg->hdr.cmd.cmd == 0x86) &&
310 (msg->hdr.cmd.subcmd == 0) ) { 310 (msg->hdr.cmd.subcmd == 0)) {
311 /* Save flags in message */ 311 /* Save flags in message */
312 card->need_b3ack = msg->msg.data_b3_req.flags; 312 card->need_b3ack = msg->msg.data_b3_req.flags;
313 msg->msg.data_b3_req.flags = 0; 313 msg->msg.data_b3_req.flags = 0;
@@ -335,7 +335,7 @@ act2000_isa_send(act2000_card * card)
335 } 335 }
336 msg = (actcapi_msg *)card->ack_msg; 336 msg = (actcapi_msg *)card->ack_msg;
337 if ((msg->hdr.cmd.cmd == 0x86) && 337 if ((msg->hdr.cmd.cmd == 0x86) &&
338 (msg->hdr.cmd.subcmd == 0) ) { 338 (msg->hdr.cmd.subcmd == 0)) {
339 /* 339 /*
340 * If it's user data, reset data-ptr 340 * If it's user data, reset data-ptr
341 * and put skb into ackq. 341 * and put skb into ackq.
@@ -354,90 +354,90 @@ act2000_isa_send(act2000_card * card)
354 * Get firmware ID, check for 'ISDN' signature. 354 * Get firmware ID, check for 'ISDN' signature.
355 */ 355 */
356static int 356static int
357act2000_isa_getid(act2000_card * card) 357act2000_isa_getid(act2000_card *card)
358{ 358{
359 359
360 act2000_fwid fid; 360 act2000_fwid fid;
361 u_char *p = (u_char *) & fid; 361 u_char *p = (u_char *)&fid;
362 int count = 0; 362 int count = 0;
363 363
364 while (1) { 364 while (1) {
365 if (count > 510) 365 if (count > 510)
366 return -EPROTO; 366 return -EPROTO;
367 if (act2000_isa_readb(card, p++)) 367 if (act2000_isa_readb(card, p++))
368 break; 368 break;
369 count++; 369 count++;
370 } 370 }
371 if (count <= 20) { 371 if (count <= 20) {
372 printk(KERN_WARNING "act2000: No Firmware-ID!\n"); 372 printk(KERN_WARNING "act2000: No Firmware-ID!\n");
373 return -ETIME; 373 return -ETIME;
374 } 374 }
375 *p = '\0'; 375 *p = '\0';
376 fid.revlen[0] = '\0'; 376 fid.revlen[0] = '\0';
377 if (strcmp(fid.isdn, "ISDN")) { 377 if (strcmp(fid.isdn, "ISDN")) {
378 printk(KERN_WARNING "act2000: Wrong Firmware-ID!\n"); 378 printk(KERN_WARNING "act2000: Wrong Firmware-ID!\n");
379 return -EPROTO; 379 return -EPROTO;
380 } 380 }
381 if ((p = strchr(fid.revision, '\n'))) 381 if ((p = strchr(fid.revision, '\n')))
382 *p = '\0'; 382 *p = '\0';
383 printk(KERN_INFO "act2000: Firmware-ID: %s\n", fid.revision); 383 printk(KERN_INFO "act2000: Firmware-ID: %s\n", fid.revision);
384 if (card->flags & ACT2000_FLAGS_IVALID) { 384 if (card->flags & ACT2000_FLAGS_IVALID) {
385 printk(KERN_DEBUG "Enabling Interrupts ...\n"); 385 printk(KERN_DEBUG "Enabling Interrupts ...\n");
386 act2000_isa_enable_irq(card); 386 act2000_isa_enable_irq(card);
387 } 387 }
388 return 0; 388 return 0;
389} 389}
390 390
391/* 391/*
392 * Download microcode into card, check Firmware signature. 392 * Download microcode into card, check Firmware signature.
393 */ 393 */
394int 394int
395act2000_isa_download(act2000_card * card, act2000_ddef __user * cb) 395act2000_isa_download(act2000_card *card, act2000_ddef __user *cb)
396{ 396{
397 unsigned int length; 397 unsigned int length;
398 int l; 398 int l;
399 int c; 399 int c;
400 long timeout; 400 long timeout;
401 u_char *b; 401 u_char *b;
402 u_char __user *p; 402 u_char __user *p;
403 u_char *buf; 403 u_char *buf;
404 act2000_ddef cblock; 404 act2000_ddef cblock;
405 405
406 if (!act2000_isa_reset(card->port)) 406 if (!act2000_isa_reset(card->port))
407 return -ENXIO; 407 return -ENXIO;
408 msleep_interruptible(500); 408 msleep_interruptible(500);
409 if (copy_from_user(&cblock, cb, sizeof(cblock))) 409 if (copy_from_user(&cblock, cb, sizeof(cblock)))
410 return -EFAULT; 410 return -EFAULT;
411 length = cblock.length; 411 length = cblock.length;
412 p = cblock.buffer; 412 p = cblock.buffer;
413 if (!access_ok(VERIFY_READ, p, length)) 413 if (!access_ok(VERIFY_READ, p, length))
414 return -EFAULT; 414 return -EFAULT;
415 buf = kmalloc(1024, GFP_KERNEL); 415 buf = kmalloc(1024, GFP_KERNEL);
416 if (!buf) 416 if (!buf)
417 return -ENOMEM; 417 return -ENOMEM;
418 timeout = 0; 418 timeout = 0;
419 while (length) { 419 while (length) {
420 l = (length > 1024) ? 1024 : length; 420 l = (length > 1024) ? 1024 : length;
421 c = 0; 421 c = 0;
422 b = buf; 422 b = buf;
423 if (copy_from_user(buf, p, l)) { 423 if (copy_from_user(buf, p, l)) {
424 kfree(buf); 424 kfree(buf);
425 return -EFAULT; 425 return -EFAULT;
426 } 426 }
427 while (c < l) { 427 while (c < l) {
428 if (act2000_isa_writeb(card, *b++)) { 428 if (act2000_isa_writeb(card, *b++)) {
429 printk(KERN_WARNING 429 printk(KERN_WARNING
430 "act2000: loader timed out" 430 "act2000: loader timed out"
431 " len=%d c=%d\n", length, c); 431 " len=%d c=%d\n", length, c);
432 kfree(buf); 432 kfree(buf);
433 return -ETIME; 433 return -ETIME;
434 } 434 }
435 c++; 435 c++;
436 } 436 }
437 length -= l; 437 length -= l;
438 p += l; 438 p += l;
439 } 439 }
440 kfree(buf); 440 kfree(buf);
441 msleep_interruptible(500); 441 msleep_interruptible(500);
442 return (act2000_isa_getid(card)); 442 return (act2000_isa_getid(card));
443} 443}
diff --git a/drivers/isdn/act2000/act2000_isa.h b/drivers/isdn/act2000/act2000_isa.h
index ad86c5ed9aad..1a728984ede1 100644
--- a/drivers/isdn/act2000/act2000_isa.h
+++ b/drivers/isdn/act2000/act2000_isa.h
@@ -4,7 +4,7 @@
4 * 4 *
5 * Author Fritz Elfert 5 * Author Fritz Elfert
6 * Copyright by Fritz Elfert <fritz@isdn4linux.de> 6 * Copyright by Fritz Elfert <fritz@isdn4linux.de>
7 * 7 *
8 * This software may be used and distributed according to the terms 8 * This software may be used and distributed according to the terms
9 * of the GNU General Public License, incorporated herein by reference. 9 * of the GNU General Public License, incorporated herein by reference.
10 * 10 *
@@ -18,9 +18,9 @@
18#define ISA_POLL_LOOP 40 /* Try to read-write before give up */ 18#define ISA_POLL_LOOP 40 /* Try to read-write before give up */
19 19
20typedef enum { 20typedef enum {
21 INT_NO_CHANGE = 0, /* Do not change the Mask */ 21 INT_NO_CHANGE = 0, /* Do not change the Mask */
22 INT_ON = 1, /* Set to Enable */ 22 INT_ON = 1, /* Set to Enable */
23 INT_OFF = 2, /* Set to Disable */ 23 INT_OFF = 2, /* Set to Disable */
24} ISA_INT_T; 24} ISA_INT_T;
25 25
26/**************************************************************************/ 26/**************************************************************************/
@@ -114,22 +114,22 @@ typedef enum {
114 114
115 115
116/* Macros for accessing ports */ 116/* Macros for accessing ports */
117#define ISA_PORT_COR (card->port+ISA_COR) 117#define ISA_PORT_COR (card->port + ISA_COR)
118#define ISA_PORT_ISR (card->port+ISA_ISR) 118#define ISA_PORT_ISR (card->port + ISA_ISR)
119#define ISA_PORT_EPR (card->port+ISA_EPR) 119#define ISA_PORT_EPR (card->port + ISA_EPR)
120#define ISA_PORT_EER (card->port+ISA_EER) 120#define ISA_PORT_EER (card->port + ISA_EER)
121#define ISA_PORT_SDI (card->port+ISA_SDI) 121#define ISA_PORT_SDI (card->port + ISA_SDI)
122#define ISA_PORT_SDO (card->port+ISA_SDO) 122#define ISA_PORT_SDO (card->port + ISA_SDO)
123#define ISA_PORT_SIS (card->port+ISA_SIS) 123#define ISA_PORT_SIS (card->port + ISA_SIS)
124#define ISA_PORT_SOS (card->port+ISA_SOS) 124#define ISA_PORT_SOS (card->port + ISA_SOS)
125 125
126/* Prototypes */ 126/* Prototypes */
127 127
128extern int act2000_isa_detect(unsigned short portbase); 128extern int act2000_isa_detect(unsigned short portbase);
129extern int act2000_isa_config_irq(act2000_card * card, short irq); 129extern int act2000_isa_config_irq(act2000_card *card, short irq);
130extern int act2000_isa_config_port(act2000_card * card, unsigned short portbase); 130extern int act2000_isa_config_port(act2000_card *card, unsigned short portbase);
131extern int act2000_isa_download(act2000_card * card, act2000_ddef __user * cb); 131extern int act2000_isa_download(act2000_card *card, act2000_ddef __user *cb);
132extern void act2000_isa_release(act2000_card * card); 132extern void act2000_isa_release(act2000_card *card);
133extern void act2000_isa_receive(act2000_card *card); 133extern void act2000_isa_receive(act2000_card *card);
134extern void act2000_isa_send(act2000_card *card); 134extern void act2000_isa_send(act2000_card *card);
135 135
diff --git a/drivers/isdn/act2000/capi.c b/drivers/isdn/act2000/capi.c
index 1f0a94906465..3f66ca20b5e5 100644
--- a/drivers/isdn/act2000/capi.c
+++ b/drivers/isdn/act2000/capi.c
@@ -5,7 +5,7 @@
5 * 5 *
6 * Author Fritz Elfert 6 * Author Fritz Elfert
7 * Copyright by Fritz Elfert <fritz@isdn4linux.de> 7 * Copyright by Fritz Elfert <fritz@isdn4linux.de>
8 * 8 *
9 * This software may be used and distributed according to the terms 9 * This software may be used and distributed according to the terms
10 * of the GNU General Public License, incorporated herein by reference. 10 * of the GNU General Public License, incorporated herein by reference.
11 * 11 *
@@ -64,14 +64,14 @@ static actcapi_msgdsc valid_msg[] = {
64 {{ 0x86, 0x00}, "DATA_B3_REQ"}, 64 {{ 0x86, 0x00}, "DATA_B3_REQ"},
65 {{ 0xff, 0x00}, "MANUFACTURER_REQ"}, 65 {{ 0xff, 0x00}, "MANUFACTURER_REQ"},
66 /* Responses */ 66 /* Responses */
67 {{ 0x01, 0x03}, "RESET_B3_RESP"}, 67 {{ 0x01, 0x03}, "RESET_B3_RESP"},
68 {{ 0x02, 0x03}, "CONNECT_RESP"}, 68 {{ 0x02, 0x03}, "CONNECT_RESP"},
69 {{ 0x03, 0x03}, "CONNECT_ACTIVE_RESP"}, 69 {{ 0x03, 0x03}, "CONNECT_ACTIVE_RESP"},
70 {{ 0x04, 0x03}, "DISCONNECT_RESP"}, 70 {{ 0x04, 0x03}, "DISCONNECT_RESP"},
71 {{ 0x07, 0x03}, "INFO_RESP"}, 71 {{ 0x07, 0x03}, "INFO_RESP"},
72 {{ 0x08, 0x03}, "DATA_RESP"}, 72 {{ 0x08, 0x03}, "DATA_RESP"},
73 {{ 0x82, 0x03}, "CONNECT_B3_RESP"}, 73 {{ 0x82, 0x03}, "CONNECT_B3_RESP"},
74 {{ 0x83, 0x03}, "CONNECT_B3_ACTIVE_RESP"}, 74 {{ 0x83, 0x03}, "CONNECT_B3_ACTIVE_RESP"},
75 {{ 0x84, 0x03}, "DISCONNECT_B3_RESP"}, 75 {{ 0x84, 0x03}, "DISCONNECT_B3_RESP"},
76 {{ 0x86, 0x03}, "DATA_B3_RESP"}, 76 {{ 0x86, 0x03}, "DATA_B3_RESP"},
77 {{ 0xff, 0x03}, "MANUFACTURER_RESP"}, 77 {{ 0xff, 0x03}, "MANUFACTURER_RESP"},
@@ -88,7 +88,7 @@ static actcapi_msgdsc valid_msg[] = {
88 * 2 = Valid message, B-Channel-data 88 * 2 = Valid message, B-Channel-data
89 */ 89 */
90int 90int
91actcapi_chkhdr(act2000_card * card, actcapi_msghdr *hdr) 91actcapi_chkhdr(act2000_card *card, actcapi_msghdr *hdr)
92{ 92{
93 int i; 93 int i;
94 94
@@ -99,33 +99,33 @@ actcapi_chkhdr(act2000_card * card, actcapi_msghdr *hdr)
99 for (i = 0; i < num_valid_imsg; i++) 99 for (i = 0; i < num_valid_imsg; i++)
100 if ((hdr->cmd.cmd == valid_msg[i].cmd.cmd) && 100 if ((hdr->cmd.cmd == valid_msg[i].cmd.cmd) &&
101 (hdr->cmd.subcmd == valid_msg[i].cmd.subcmd)) { 101 (hdr->cmd.subcmd == valid_msg[i].cmd.subcmd)) {
102 return (i?1:2); 102 return (i ? 1 : 2);
103 } 103 }
104 return 0; 104 return 0;
105} 105}
106 106
107#define ACTCAPI_MKHDR(l, c, s) { \ 107#define ACTCAPI_MKHDR(l, c, s) { \
108 skb = alloc_skb(l + 8, GFP_ATOMIC); \ 108 skb = alloc_skb(l + 8, GFP_ATOMIC); \
109 if (skb) { \ 109 if (skb) { \
110 m = (actcapi_msg *)skb_put(skb, l + 8); \ 110 m = (actcapi_msg *)skb_put(skb, l + 8); \
111 m->hdr.len = l + 8; \ 111 m->hdr.len = l + 8; \
112 m->hdr.applicationID = 1; \ 112 m->hdr.applicationID = 1; \
113 m->hdr.cmd.cmd = c; \ 113 m->hdr.cmd.cmd = c; \
114 m->hdr.cmd.subcmd = s; \ 114 m->hdr.cmd.subcmd = s; \
115 m->hdr.msgnum = actcapi_nextsmsg(card); \ 115 m->hdr.msgnum = actcapi_nextsmsg(card); \
116 } else m = NULL;\ 116 } else m = NULL; \
117} 117 }
118 118
119#define ACTCAPI_CHKSKB if (!skb) { \ 119#define ACTCAPI_CHKSKB if (!skb) { \
120 printk(KERN_WARNING "actcapi: alloc_skb failed\n"); \ 120 printk(KERN_WARNING "actcapi: alloc_skb failed\n"); \
121 return; \ 121 return; \
122} 122 }
123 123
124#define ACTCAPI_QUEUE_TX { \ 124#define ACTCAPI_QUEUE_TX { \
125 actcapi_debug_msg(skb, 1); \ 125 actcapi_debug_msg(skb, 1); \
126 skb_queue_tail(&card->sndq, skb); \ 126 skb_queue_tail(&card->sndq, skb); \
127 act2000_schedule_tx(card); \ 127 act2000_schedule_tx(card); \
128} 128 }
129 129
130int 130int
131actcapi_listen_req(act2000_card *card) 131actcapi_listen_req(act2000_card *card)
@@ -138,16 +138,16 @@ actcapi_listen_req(act2000_card *card)
138 for (i = 0; i < ACT2000_BCH; i++) 138 for (i = 0; i < ACT2000_BCH; i++)
139 eazmask |= card->bch[i].eazmask; 139 eazmask |= card->bch[i].eazmask;
140 ACTCAPI_MKHDR(9, 0x05, 0x00); 140 ACTCAPI_MKHDR(9, 0x05, 0x00);
141 if (!skb) { 141 if (!skb) {
142 printk(KERN_WARNING "actcapi: alloc_skb failed\n"); 142 printk(KERN_WARNING "actcapi: alloc_skb failed\n");
143 return -ENOMEM; 143 return -ENOMEM;
144 } 144 }
145 m->msg.listen_req.controller = 0; 145 m->msg.listen_req.controller = 0;
146 m->msg.listen_req.infomask = 0x3f; /* All information */ 146 m->msg.listen_req.infomask = 0x3f; /* All information */
147 m->msg.listen_req.eazmask = eazmask; 147 m->msg.listen_req.eazmask = eazmask;
148 m->msg.listen_req.simask = (eazmask)?0x86:0; /* All SI's */ 148 m->msg.listen_req.simask = (eazmask) ? 0x86 : 0; /* All SI's */
149 ACTCAPI_QUEUE_TX; 149 ACTCAPI_QUEUE_TX;
150 return 0; 150 return 0;
151} 151}
152 152
153int 153int
@@ -159,7 +159,7 @@ actcapi_connect_req(act2000_card *card, act2000_chan *chan, char *phone,
159 159
160 ACTCAPI_MKHDR((11 + strlen(phone)), 0x02, 0x00); 160 ACTCAPI_MKHDR((11 + strlen(phone)), 0x02, 0x00);
161 if (!skb) { 161 if (!skb) {
162 printk(KERN_WARNING "actcapi: alloc_skb failed\n"); 162 printk(KERN_WARNING "actcapi: alloc_skb failed\n");
163 chan->fsm_state = ACT2000_STATE_NULL; 163 chan->fsm_state = ACT2000_STATE_NULL;
164 return -ENOMEM; 164 return -ENOMEM;
165 } 165 }
@@ -168,7 +168,7 @@ actcapi_connect_req(act2000_card *card, act2000_chan *chan, char *phone,
168 m->msg.connect_req.infomask = 0x3f; 168 m->msg.connect_req.infomask = 0x3f;
169 m->msg.connect_req.si1 = si1; 169 m->msg.connect_req.si1 = si1;
170 m->msg.connect_req.si2 = si2; 170 m->msg.connect_req.si2 = si2;
171 m->msg.connect_req.eaz = eaz?eaz:'0'; 171 m->msg.connect_req.eaz = eaz ? eaz : '0';
172 m->msg.connect_req.addr.len = strlen(phone) + 1; 172 m->msg.connect_req.addr.len = strlen(phone) + 1;
173 m->msg.connect_req.addr.tnp = 0x81; 173 m->msg.connect_req.addr.tnp = 0x81;
174 memcpy(m->msg.connect_req.addr.num, phone, strlen(phone)); 174 memcpy(m->msg.connect_req.addr.num, phone, strlen(phone));
@@ -203,21 +203,21 @@ actcapi_manufacturer_req_net(act2000_card *card)
203 struct sk_buff *skb; 203 struct sk_buff *skb;
204 204
205 ACTCAPI_MKHDR(5, 0xff, 0x00); 205 ACTCAPI_MKHDR(5, 0xff, 0x00);
206 if (!skb) { 206 if (!skb) {
207 printk(KERN_WARNING "actcapi: alloc_skb failed\n"); 207 printk(KERN_WARNING "actcapi: alloc_skb failed\n");
208 return -ENOMEM; 208 return -ENOMEM;
209 } 209 }
210 m->msg.manufacturer_req_net.manuf_msg = 0x11; 210 m->msg.manufacturer_req_net.manuf_msg = 0x11;
211 m->msg.manufacturer_req_net.controller = 1; 211 m->msg.manufacturer_req_net.controller = 1;
212 m->msg.manufacturer_req_net.nettype = (card->ptype == ISDN_PTYPE_EURO)?1:0; 212 m->msg.manufacturer_req_net.nettype = (card->ptype == ISDN_PTYPE_EURO) ? 1 : 0;
213 ACTCAPI_QUEUE_TX; 213 ACTCAPI_QUEUE_TX;
214 printk(KERN_INFO "act2000 %s: D-channel protocol now %s\n", 214 printk(KERN_INFO "act2000 %s: D-channel protocol now %s\n",
215 card->interface.id, (card->ptype == ISDN_PTYPE_EURO)?"euro":"1tr6"); 215 card->interface.id, (card->ptype == ISDN_PTYPE_EURO) ? "euro" : "1tr6");
216 card->interface.features &= 216 card->interface.features &=
217 ~(ISDN_FEATURE_P_UNKNOWN | ISDN_FEATURE_P_EURO | ISDN_FEATURE_P_1TR6); 217 ~(ISDN_FEATURE_P_UNKNOWN | ISDN_FEATURE_P_EURO | ISDN_FEATURE_P_1TR6);
218 card->interface.features |= 218 card->interface.features |=
219 ((card->ptype == ISDN_PTYPE_EURO)?ISDN_FEATURE_P_EURO:ISDN_FEATURE_P_1TR6); 219 ((card->ptype == ISDN_PTYPE_EURO) ? ISDN_FEATURE_P_EURO : ISDN_FEATURE_P_1TR6);
220 return 0; 220 return 0;
221} 221}
222 222
223/* 223/*
@@ -231,16 +231,16 @@ actcapi_manufacturer_req_v42(act2000_card *card, ulong arg)
231 struct sk_buff *skb; 231 struct sk_buff *skb;
232 232
233 ACTCAPI_MKHDR(8, 0xff, 0x00); 233 ACTCAPI_MKHDR(8, 0xff, 0x00);
234 if (!skb) { 234 if (!skb) {
235 235
236 printk(KERN_WARNING "actcapi: alloc_skb failed\n"); 236 printk(KERN_WARNING "actcapi: alloc_skb failed\n");
237 return -ENOMEM; 237 return -ENOMEM;
238 } 238 }
239 m->msg.manufacturer_req_v42.manuf_msg = 0x10; 239 m->msg.manufacturer_req_v42.manuf_msg = 0x10;
240 m->msg.manufacturer_req_v42.controller = 0; 240 m->msg.manufacturer_req_v42.controller = 0;
241 m->msg.manufacturer_req_v42.v42control = (arg?1:0); 241 m->msg.manufacturer_req_v42.v42control = (arg ? 1 : 0);
242 ACTCAPI_QUEUE_TX; 242 ACTCAPI_QUEUE_TX;
243 return 0; 243 return 0;
244} 244}
245#endif /* 0 */ 245#endif /* 0 */
246 246
@@ -254,15 +254,15 @@ actcapi_manufacturer_req_errh(act2000_card *card)
254 struct sk_buff *skb; 254 struct sk_buff *skb;
255 255
256 ACTCAPI_MKHDR(4, 0xff, 0x00); 256 ACTCAPI_MKHDR(4, 0xff, 0x00);
257 if (!skb) { 257 if (!skb) {
258 258
259 printk(KERN_WARNING "actcapi: alloc_skb failed\n"); 259 printk(KERN_WARNING "actcapi: alloc_skb failed\n");
260 return -ENOMEM; 260 return -ENOMEM;
261 } 261 }
262 m->msg.manufacturer_req_err.manuf_msg = 0x03; 262 m->msg.manufacturer_req_err.manuf_msg = 0x03;
263 m->msg.manufacturer_req_err.controller = 0; 263 m->msg.manufacturer_req_err.controller = 0;
264 ACTCAPI_QUEUE_TX; 264 ACTCAPI_QUEUE_TX;
265 return 0; 265 return 0;
266} 266}
267 267
268/* 268/*
@@ -295,7 +295,7 @@ actcapi_manufacturer_req_msn(act2000_card *card)
295 } 295 }
296 p = p->next; 296 p = p->next;
297 } 297 }
298 return 0; 298 return 0;
299} 299}
300 300
301void 301void
@@ -311,24 +311,24 @@ actcapi_select_b2_protocol_req(act2000_card *card, act2000_chan *chan)
311 sizeof(m->msg.select_b2_protocol_req.dlpd)); 311 sizeof(m->msg.select_b2_protocol_req.dlpd));
312 m->msg.select_b2_protocol_req.dlpd.len = 6; 312 m->msg.select_b2_protocol_req.dlpd.len = 6;
313 switch (chan->l2prot) { 313 switch (chan->l2prot) {
314 case ISDN_PROTO_L2_TRANS: 314 case ISDN_PROTO_L2_TRANS:
315 m->msg.select_b2_protocol_req.protocol = 0x03; 315 m->msg.select_b2_protocol_req.protocol = 0x03;
316 m->msg.select_b2_protocol_req.dlpd.dlen = 4000; 316 m->msg.select_b2_protocol_req.dlpd.dlen = 4000;
317 break; 317 break;
318 case ISDN_PROTO_L2_HDLC: 318 case ISDN_PROTO_L2_HDLC:
319 m->msg.select_b2_protocol_req.protocol = 0x02; 319 m->msg.select_b2_protocol_req.protocol = 0x02;
320 m->msg.select_b2_protocol_req.dlpd.dlen = 4000; 320 m->msg.select_b2_protocol_req.dlpd.dlen = 4000;
321 break; 321 break;
322 case ISDN_PROTO_L2_X75I: 322 case ISDN_PROTO_L2_X75I:
323 case ISDN_PROTO_L2_X75UI: 323 case ISDN_PROTO_L2_X75UI:
324 case ISDN_PROTO_L2_X75BUI: 324 case ISDN_PROTO_L2_X75BUI:
325 m->msg.select_b2_protocol_req.protocol = 0x01; 325 m->msg.select_b2_protocol_req.protocol = 0x01;
326 m->msg.select_b2_protocol_req.dlpd.dlen = 4000; 326 m->msg.select_b2_protocol_req.dlpd.dlen = 4000;
327 m->msg.select_b2_protocol_req.dlpd.laa = 3; 327 m->msg.select_b2_protocol_req.dlpd.laa = 3;
328 m->msg.select_b2_protocol_req.dlpd.lab = 1; 328 m->msg.select_b2_protocol_req.dlpd.lab = 1;
329 m->msg.select_b2_protocol_req.dlpd.win = 7; 329 m->msg.select_b2_protocol_req.dlpd.win = 7;
330 m->msg.select_b2_protocol_req.dlpd.modulo = 8; 330 m->msg.select_b2_protocol_req.dlpd.modulo = 8;
331 break; 331 break;
332 } 332 }
333 ACTCAPI_QUEUE_TX; 333 ACTCAPI_QUEUE_TX;
334} 334}
@@ -345,11 +345,11 @@ actcapi_select_b3_protocol_req(act2000_card *card, act2000_chan *chan)
345 memset(&m->msg.select_b3_protocol_req.ncpd, 0, 345 memset(&m->msg.select_b3_protocol_req.ncpd, 0,
346 sizeof(m->msg.select_b3_protocol_req.ncpd)); 346 sizeof(m->msg.select_b3_protocol_req.ncpd));
347 switch (chan->l3prot) { 347 switch (chan->l3prot) {
348 case ISDN_PROTO_L3_TRANS: 348 case ISDN_PROTO_L3_TRANS:
349 m->msg.select_b3_protocol_req.protocol = 0x04; 349 m->msg.select_b3_protocol_req.protocol = 0x04;
350 m->msg.select_b3_protocol_req.ncpd.len = 13; 350 m->msg.select_b3_protocol_req.ncpd.len = 13;
351 m->msg.select_b3_protocol_req.ncpd.modulo = 8; 351 m->msg.select_b3_protocol_req.ncpd.modulo = 8;
352 break; 352 break;
353 } 353 }
354 ACTCAPI_QUEUE_TX; 354 ACTCAPI_QUEUE_TX;
355} 355}
@@ -434,7 +434,7 @@ actcapi_connect_b3_resp(act2000_card *card, act2000_chan *chan, __u8 rejectcause
434 actcapi_msg *m; 434 actcapi_msg *m;
435 struct sk_buff *skb; 435 struct sk_buff *skb;
436 436
437 ACTCAPI_MKHDR((rejectcause?3:17), 0x82, 0x03); 437 ACTCAPI_MKHDR((rejectcause ? 3 : 17), 0x82, 0x03);
438 ACTCAPI_CHKSKB; 438 ACTCAPI_CHKSKB;
439 m->msg.connect_b3_resp.ncci = chan->ncci; 439 m->msg.connect_b3_resp.ncci = chan->ncci;
440 m->msg.connect_b3_resp.rejectcause = rejectcause; 440 m->msg.connect_b3_resp.rejectcause = rejectcause;
@@ -563,10 +563,10 @@ actcapi_data_b3_ind(act2000_card *card, struct sk_buff *skb) {
563 blocknr = msg->msg.data_b3_ind.blocknr; 563 blocknr = msg->msg.data_b3_ind.blocknr;
564 skb_pull(skb, 19); 564 skb_pull(skb, 19);
565 card->interface.rcvcallb_skb(card->myid, chan, skb); 565 card->interface.rcvcallb_skb(card->myid, chan, skb);
566 if (!(skb = alloc_skb(11, GFP_ATOMIC))) { 566 if (!(skb = alloc_skb(11, GFP_ATOMIC))) {
567 printk(KERN_WARNING "actcapi: alloc_skb failed\n"); 567 printk(KERN_WARNING "actcapi: alloc_skb failed\n");
568 return 1; 568 return 1;
569 } 569 }
570 msg = (actcapi_msg *)skb_put(skb, 11); 570 msg = (actcapi_msg *)skb_put(skb, 11);
571 msg->hdr.len = 11; 571 msg->hdr.len = 11;
572 msg->hdr.applicationID = 1; 572 msg->hdr.applicationID = 1;
@@ -595,34 +595,34 @@ handle_ack(act2000_card *card, act2000_chan *chan, __u8 blocknr) {
595 spin_lock_irqsave(&card->lock, flags); 595 spin_lock_irqsave(&card->lock, flags);
596 skb = skb_peek(&card->ackq); 596 skb = skb_peek(&card->ackq);
597 spin_unlock_irqrestore(&card->lock, flags); 597 spin_unlock_irqrestore(&card->lock, flags);
598 if (!skb) { 598 if (!skb) {
599 printk(KERN_WARNING "act2000: handle_ack nothing found!\n"); 599 printk(KERN_WARNING "act2000: handle_ack nothing found!\n");
600 return 0; 600 return 0;
601 } 601 }
602 tmp = skb; 602 tmp = skb;
603 while (1) { 603 while (1) {
604 m = (actcapi_msg *)tmp->data; 604 m = (actcapi_msg *)tmp->data;
605 if ((((m->msg.data_b3_req.fakencci >> 8) & 0xff) == chan->ncci) && 605 if ((((m->msg.data_b3_req.fakencci >> 8) & 0xff) == chan->ncci) &&
606 (m->msg.data_b3_req.blocknr == blocknr)) { 606 (m->msg.data_b3_req.blocknr == blocknr)) {
607 /* found corresponding DATA_B3_REQ */ 607 /* found corresponding DATA_B3_REQ */
608 skb_unlink(tmp, &card->ackq); 608 skb_unlink(tmp, &card->ackq);
609 chan->queued -= m->msg.data_b3_req.datalen; 609 chan->queued -= m->msg.data_b3_req.datalen;
610 if (m->msg.data_b3_req.flags) 610 if (m->msg.data_b3_req.flags)
611 ret = m->msg.data_b3_req.datalen; 611 ret = m->msg.data_b3_req.datalen;
612 dev_kfree_skb(tmp); 612 dev_kfree_skb(tmp);
613 if (chan->queued < 0) 613 if (chan->queued < 0)
614 chan->queued = 0; 614 chan->queued = 0;
615 return ret; 615 return ret;
616 } 616 }
617 spin_lock_irqsave(&card->lock, flags); 617 spin_lock_irqsave(&card->lock, flags);
618 tmp = skb_peek((struct sk_buff_head *)tmp); 618 tmp = skb_peek((struct sk_buff_head *)tmp);
619 spin_unlock_irqrestore(&card->lock, flags); 619 spin_unlock_irqrestore(&card->lock, flags);
620 if ((tmp == skb) || (tmp == NULL)) { 620 if ((tmp == skb) || (tmp == NULL)) {
621 /* reached end of queue */ 621 /* reached end of queue */
622 printk(KERN_WARNING "act2000: handle_ack nothing found!\n"); 622 printk(KERN_WARNING "act2000: handle_ack nothing found!\n");
623 return 0; 623 return 0;
624 } 624 }
625 } 625 }
626} 626}
627 627
628void 628void
@@ -644,294 +644,294 @@ actcapi_dispatch(struct work_struct *work)
644 msg = (actcapi_msg *)skb->data; 644 msg = (actcapi_msg *)skb->data;
645 ccmd = ((msg->hdr.cmd.cmd << 8) | msg->hdr.cmd.subcmd); 645 ccmd = ((msg->hdr.cmd.cmd << 8) | msg->hdr.cmd.subcmd);
646 switch (ccmd) { 646 switch (ccmd) {
647 case 0x8602: 647 case 0x8602:
648 /* DATA_B3_IND */ 648 /* DATA_B3_IND */
649 if (actcapi_data_b3_ind(card, skb)) 649 if (actcapi_data_b3_ind(card, skb))
650 return; 650 return;
651 break; 651 break;
652 case 0x8601: 652 case 0x8601:
653 /* DATA_B3_CONF */ 653 /* DATA_B3_CONF */
654 chan = find_ncci(card, msg->msg.data_b3_conf.ncci); 654 chan = find_ncci(card, msg->msg.data_b3_conf.ncci);
655 if ((chan >= 0) && (card->bch[chan].fsm_state == ACT2000_STATE_ACTIVE)) { 655 if ((chan >= 0) && (card->bch[chan].fsm_state == ACT2000_STATE_ACTIVE)) {
656 if (msg->msg.data_b3_conf.info != 0) 656 if (msg->msg.data_b3_conf.info != 0)
657 printk(KERN_WARNING "act2000: DATA_B3_CONF: %04x\n", 657 printk(KERN_WARNING "act2000: DATA_B3_CONF: %04x\n",
658 msg->msg.data_b3_conf.info); 658 msg->msg.data_b3_conf.info);
659 len = handle_ack(card, &card->bch[chan], 659 len = handle_ack(card, &card->bch[chan],
660 msg->msg.data_b3_conf.blocknr); 660 msg->msg.data_b3_conf.blocknr);
661 if (len) { 661 if (len) {
662 cmd.driver = card->myid;
663 cmd.command = ISDN_STAT_BSENT;
664 cmd.arg = chan;
665 cmd.parm.length = len;
666 card->interface.statcallb(&cmd);
667 }
668 }
669 break;
670 case 0x0201:
671 /* CONNECT_CONF */
672 chan = find_dialing(card, msg->hdr.msgnum);
673 if (chan >= 0) {
674 if (msg->msg.connect_conf.info) {
675 card->bch[chan].fsm_state = ACT2000_STATE_NULL;
676 cmd.driver = card->myid;
677 cmd.command = ISDN_STAT_DHUP;
678 cmd.arg = chan;
679 card->interface.statcallb(&cmd);
680 } else {
681 card->bch[chan].fsm_state = ACT2000_STATE_OWAIT;
682 card->bch[chan].plci = msg->msg.connect_conf.plci;
683 }
684 }
685 break;
686 case 0x0202:
687 /* CONNECT_IND */
688 chan = new_plci(card, msg->msg.connect_ind.plci);
689 if (chan < 0) {
690 ctmp = (act2000_chan *)tmp;
691 ctmp->plci = msg->msg.connect_ind.plci;
692 actcapi_connect_resp(card, ctmp, 0x11); /* All Card-Cannels busy */
693 } else {
694 card->bch[chan].fsm_state = ACT2000_STATE_ICALL;
695 cmd.driver = card->myid;
696 cmd.command = ISDN_STAT_ICALL;
697 cmd.arg = chan;
698 cmd.parm.setup.si1 = msg->msg.connect_ind.si1;
699 cmd.parm.setup.si2 = msg->msg.connect_ind.si2;
700 if (card->ptype == ISDN_PTYPE_EURO)
701 strcpy(cmd.parm.setup.eazmsn,
702 act2000_find_eaz(card, msg->msg.connect_ind.eaz));
703 else {
704 cmd.parm.setup.eazmsn[0] = msg->msg.connect_ind.eaz;
705 cmd.parm.setup.eazmsn[1] = 0;
706 }
707 memset(cmd.parm.setup.phone, 0, sizeof(cmd.parm.setup.phone));
708 memcpy(cmd.parm.setup.phone, msg->msg.connect_ind.addr.num,
709 msg->msg.connect_ind.addr.len - 1);
710 cmd.parm.setup.plan = msg->msg.connect_ind.addr.tnp;
711 cmd.parm.setup.screen = 0;
712 if (card->interface.statcallb(&cmd) == 2)
713 actcapi_connect_resp(card, &card->bch[chan], 0x15); /* Reject Call */
714 }
715 break;
716 case 0x0302:
717 /* CONNECT_ACTIVE_IND */
718 chan = find_plci(card, msg->msg.connect_active_ind.plci);
719 if (chan >= 0)
720 switch (card->bch[chan].fsm_state) {
721 case ACT2000_STATE_IWAIT:
722 actcapi_connect_active_resp(card, &card->bch[chan]);
723 break;
724 case ACT2000_STATE_OWAIT:
725 actcapi_connect_active_resp(card, &card->bch[chan]);
726 actcapi_select_b2_protocol_req(card, &card->bch[chan]);
727 break;
728 }
729 break;
730 case 0x8202:
731 /* CONNECT_B3_IND */
732 chan = find_plci(card, msg->msg.connect_b3_ind.plci);
733 if ((chan >= 0) && (card->bch[chan].fsm_state == ACT2000_STATE_IBWAIT)) {
734 card->bch[chan].ncci = msg->msg.connect_b3_ind.ncci;
735 actcapi_connect_b3_resp(card, &card->bch[chan], 0);
736 } else {
737 ctmp = (act2000_chan *)tmp;
738 ctmp->ncci = msg->msg.connect_b3_ind.ncci;
739 actcapi_connect_b3_resp(card, ctmp, 0x11); /* All Card-Cannels busy */
740 }
741 break;
742 case 0x8302:
743 /* CONNECT_B3_ACTIVE_IND */
744 chan = find_ncci(card, msg->msg.connect_b3_active_ind.ncci);
745 if ((chan >= 0) && (card->bch[chan].fsm_state == ACT2000_STATE_BWAIT)) {
746 actcapi_connect_b3_active_resp(card, &card->bch[chan]);
747 cmd.driver = card->myid;
748 cmd.command = ISDN_STAT_BCONN;
749 cmd.arg = chan;
750 card->interface.statcallb(&cmd);
751 }
752 break;
753 case 0x8402:
754 /* DISCONNECT_B3_IND */
755 chan = find_ncci(card, msg->msg.disconnect_b3_ind.ncci);
756 if (chan >= 0) {
757 ctmp = &card->bch[chan];
758 actcapi_disconnect_b3_resp(card, ctmp);
759 switch (ctmp->fsm_state) {
760 case ACT2000_STATE_ACTIVE:
761 ctmp->fsm_state = ACT2000_STATE_DHWAIT2;
762 cmd.driver = card->myid;
763 cmd.command = ISDN_STAT_BHUP;
764 cmd.arg = chan;
765 card->interface.statcallb(&cmd);
766 break;
767 case ACT2000_STATE_BHWAIT2:
768 actcapi_disconnect_req(card, ctmp);
769 ctmp->fsm_state = ACT2000_STATE_DHWAIT;
770 cmd.driver = card->myid;
771 cmd.command = ISDN_STAT_BHUP;
772 cmd.arg = chan;
773 card->interface.statcallb(&cmd);
774 break;
775 }
776 }
777 break;
778 case 0x0402:
779 /* DISCONNECT_IND */
780 chan = find_plci(card, msg->msg.disconnect_ind.plci);
781 if (chan >= 0) {
782 ctmp = &card->bch[chan];
783 actcapi_disconnect_resp(card, ctmp);
784 ctmp->fsm_state = ACT2000_STATE_NULL;
785 cmd.driver = card->myid;
786 cmd.command = ISDN_STAT_DHUP;
787 cmd.arg = chan;
788 card->interface.statcallb(&cmd);
789 } else {
790 ctmp = (act2000_chan *)tmp;
791 ctmp->plci = msg->msg.disconnect_ind.plci;
792 actcapi_disconnect_resp(card, ctmp);
793 }
794 break;
795 case 0x4001:
796 /* SELECT_B2_PROTOCOL_CONF */
797 chan = find_plci(card, msg->msg.select_b2_protocol_conf.plci);
798 if (chan >= 0)
799 switch (card->bch[chan].fsm_state) {
800 case ACT2000_STATE_ICALL:
801 case ACT2000_STATE_OWAIT:
802 ctmp = &card->bch[chan];
803 if (msg->msg.select_b2_protocol_conf.info == 0)
804 actcapi_select_b3_protocol_req(card, ctmp);
805 else {
806 ctmp->fsm_state = ACT2000_STATE_NULL;
662 cmd.driver = card->myid; 807 cmd.driver = card->myid;
663 cmd.command = ISDN_STAT_BSENT; 808 cmd.command = ISDN_STAT_DHUP;
664 cmd.arg = chan; 809 cmd.arg = chan;
665 cmd.parm.length = len;
666 card->interface.statcallb(&cmd); 810 card->interface.statcallb(&cmd);
667 } 811 }
812 break;
668 } 813 }
669 break; 814 break;
670 case 0x0201: 815 case 0x8001:
671 /* CONNECT_CONF */ 816 /* SELECT_B3_PROTOCOL_CONF */
672 chan = find_dialing(card, msg->hdr.msgnum); 817 chan = find_plci(card, msg->msg.select_b3_protocol_conf.plci);
673 if (chan >= 0) { 818 if (chan >= 0)
674 if (msg->msg.connect_conf.info) { 819 switch (card->bch[chan].fsm_state) {
675 card->bch[chan].fsm_state = ACT2000_STATE_NULL; 820 case ACT2000_STATE_ICALL:
821 case ACT2000_STATE_OWAIT:
822 ctmp = &card->bch[chan];
823 if (msg->msg.select_b3_protocol_conf.info == 0)
824 actcapi_listen_b3_req(card, ctmp);
825 else {
826 ctmp->fsm_state = ACT2000_STATE_NULL;
676 cmd.driver = card->myid; 827 cmd.driver = card->myid;
677 cmd.command = ISDN_STAT_DHUP; 828 cmd.command = ISDN_STAT_DHUP;
678 cmd.arg = chan; 829 cmd.arg = chan;
679 card->interface.statcallb(&cmd); 830 card->interface.statcallb(&cmd);
680 } else {
681 card->bch[chan].fsm_state = ACT2000_STATE_OWAIT;
682 card->bch[chan].plci = msg->msg.connect_conf.plci;
683 } 831 }
684 } 832 }
685 break; 833 break;
686 case 0x0202: 834 case 0x8101:
687 /* CONNECT_IND */ 835 /* LISTEN_B3_CONF */
688 chan = new_plci(card, msg->msg.connect_ind.plci); 836 chan = find_plci(card, msg->msg.listen_b3_conf.plci);
689 if (chan < 0) { 837 if (chan >= 0)
690 ctmp = (act2000_chan *)tmp; 838 switch (card->bch[chan].fsm_state) {
691 ctmp->plci = msg->msg.connect_ind.plci; 839 case ACT2000_STATE_ICALL:
692 actcapi_connect_resp(card, ctmp, 0x11); /* All Card-Cannels busy */ 840 ctmp = &card->bch[chan];
693 } else { 841 if (msg->msg.listen_b3_conf.info == 0)
694 card->bch[chan].fsm_state = ACT2000_STATE_ICALL; 842 actcapi_connect_resp(card, ctmp, 0);
695 cmd.driver = card->myid;
696 cmd.command = ISDN_STAT_ICALL;
697 cmd.arg = chan;
698 cmd.parm.setup.si1 = msg->msg.connect_ind.si1;
699 cmd.parm.setup.si2 = msg->msg.connect_ind.si2;
700 if (card->ptype == ISDN_PTYPE_EURO)
701 strcpy(cmd.parm.setup.eazmsn,
702 act2000_find_eaz(card, msg->msg.connect_ind.eaz));
703 else { 843 else {
704 cmd.parm.setup.eazmsn[0] = msg->msg.connect_ind.eaz; 844 ctmp->fsm_state = ACT2000_STATE_NULL;
705 cmd.parm.setup.eazmsn[1] = 0; 845 cmd.driver = card->myid;
706 } 846 cmd.command = ISDN_STAT_DHUP;
707 memset(cmd.parm.setup.phone, 0, sizeof(cmd.parm.setup.phone)); 847 cmd.arg = chan;
708 memcpy(cmd.parm.setup.phone, msg->msg.connect_ind.addr.num, 848 card->interface.statcallb(&cmd);
709 msg->msg.connect_ind.addr.len - 1);
710 cmd.parm.setup.plan = msg->msg.connect_ind.addr.tnp;
711 cmd.parm.setup.screen = 0;
712 if (card->interface.statcallb(&cmd) == 2)
713 actcapi_connect_resp(card, &card->bch[chan], 0x15); /* Reject Call */
714 }
715 break;
716 case 0x0302:
717 /* CONNECT_ACTIVE_IND */
718 chan = find_plci(card, msg->msg.connect_active_ind.plci);
719 if (chan >= 0)
720 switch (card->bch[chan].fsm_state) {
721 case ACT2000_STATE_IWAIT:
722 actcapi_connect_active_resp(card, &card->bch[chan]);
723 break;
724 case ACT2000_STATE_OWAIT:
725 actcapi_connect_active_resp(card, &card->bch[chan]);
726 actcapi_select_b2_protocol_req(card, &card->bch[chan]);
727 break;
728 } 849 }
729 break; 850 break;
730 case 0x8202: 851 case ACT2000_STATE_OWAIT:
731 /* CONNECT_B3_IND */
732 chan = find_plci(card, msg->msg.connect_b3_ind.plci);
733 if ((chan >= 0) && (card->bch[chan].fsm_state == ACT2000_STATE_IBWAIT)) {
734 card->bch[chan].ncci = msg->msg.connect_b3_ind.ncci;
735 actcapi_connect_b3_resp(card, &card->bch[chan], 0);
736 } else {
737 ctmp = (act2000_chan *)tmp;
738 ctmp->ncci = msg->msg.connect_b3_ind.ncci;
739 actcapi_connect_b3_resp(card, ctmp, 0x11); /* All Card-Cannels busy */
740 }
741 break;
742 case 0x8302:
743 /* CONNECT_B3_ACTIVE_IND */
744 chan = find_ncci(card, msg->msg.connect_b3_active_ind.ncci);
745 if ((chan >= 0) && (card->bch[chan].fsm_state == ACT2000_STATE_BWAIT)) {
746 actcapi_connect_b3_active_resp(card, &card->bch[chan]);
747 cmd.driver = card->myid;
748 cmd.command = ISDN_STAT_BCONN;
749 cmd.arg = chan;
750 card->interface.statcallb(&cmd);
751 }
752 break;
753 case 0x8402:
754 /* DISCONNECT_B3_IND */
755 chan = find_ncci(card, msg->msg.disconnect_b3_ind.ncci);
756 if (chan >= 0) {
757 ctmp = &card->bch[chan]; 852 ctmp = &card->bch[chan];
758 actcapi_disconnect_b3_resp(card, ctmp); 853 if (msg->msg.listen_b3_conf.info == 0) {
759 switch (ctmp->fsm_state) { 854 actcapi_connect_b3_req(card, ctmp);
760 case ACT2000_STATE_ACTIVE: 855 ctmp->fsm_state = ACT2000_STATE_OBWAIT;
761 ctmp->fsm_state = ACT2000_STATE_DHWAIT2; 856 cmd.driver = card->myid;
762 cmd.driver = card->myid; 857 cmd.command = ISDN_STAT_DCONN;
763 cmd.command = ISDN_STAT_BHUP; 858 cmd.arg = chan;
764 cmd.arg = chan; 859 card->interface.statcallb(&cmd);
765 card->interface.statcallb(&cmd); 860 } else {
766 break; 861 ctmp->fsm_state = ACT2000_STATE_NULL;
767 case ACT2000_STATE_BHWAIT2: 862 cmd.driver = card->myid;
768 actcapi_disconnect_req(card, ctmp); 863 cmd.command = ISDN_STAT_DHUP;
769 ctmp->fsm_state = ACT2000_STATE_DHWAIT; 864 cmd.arg = chan;
770 cmd.driver = card->myid; 865 card->interface.statcallb(&cmd);
771 cmd.command = ISDN_STAT_BHUP;
772 cmd.arg = chan;
773 card->interface.statcallb(&cmd);
774 break;
775 } 866 }
867 break;
776 } 868 }
777 break; 869 break;
778 case 0x0402: 870 case 0x8201:
779 /* DISCONNECT_IND */ 871 /* CONNECT_B3_CONF */
780 chan = find_plci(card, msg->msg.disconnect_ind.plci); 872 chan = find_plci(card, msg->msg.connect_b3_conf.plci);
781 if (chan >= 0) { 873 if ((chan >= 0) && (card->bch[chan].fsm_state == ACT2000_STATE_OBWAIT)) {
782 ctmp = &card->bch[chan]; 874 ctmp = &card->bch[chan];
783 actcapi_disconnect_resp(card, ctmp); 875 if (msg->msg.connect_b3_conf.info) {
784 ctmp->fsm_state = ACT2000_STATE_NULL; 876 ctmp->fsm_state = ACT2000_STATE_NULL;
785 cmd.driver = card->myid; 877 cmd.driver = card->myid;
786 cmd.command = ISDN_STAT_DHUP; 878 cmd.command = ISDN_STAT_DHUP;
787 cmd.arg = chan; 879 cmd.arg = chan;
788 card->interface.statcallb(&cmd); 880 card->interface.statcallb(&cmd);
789 } else { 881 } else {
790 ctmp = (act2000_chan *)tmp; 882 ctmp->ncci = msg->msg.connect_b3_conf.ncci;
791 ctmp->plci = msg->msg.disconnect_ind.plci; 883 ctmp->fsm_state = ACT2000_STATE_BWAIT;
792 actcapi_disconnect_resp(card, ctmp);
793 } 884 }
794 break; 885 }
795 case 0x4001: 886 break;
796 /* SELECT_B2_PROTOCOL_CONF */ 887 case 0x8401:
797 chan = find_plci(card, msg->msg.select_b2_protocol_conf.plci); 888 /* DISCONNECT_B3_CONF */
798 if (chan >= 0) 889 chan = find_ncci(card, msg->msg.disconnect_b3_conf.ncci);
799 switch (card->bch[chan].fsm_state) { 890 if ((chan >= 0) && (card->bch[chan].fsm_state == ACT2000_STATE_BHWAIT))
800 case ACT2000_STATE_ICALL: 891 card->bch[chan].fsm_state = ACT2000_STATE_BHWAIT2;
801 case ACT2000_STATE_OWAIT: 892 break;
802 ctmp = &card->bch[chan]; 893 case 0x0702:
803 if (msg->msg.select_b2_protocol_conf.info == 0) 894 /* INFO_IND */
804 actcapi_select_b3_protocol_req(card, ctmp); 895 chan = find_plci(card, msg->msg.info_ind.plci);
805 else { 896 if (chan >= 0)
806 ctmp->fsm_state = ACT2000_STATE_NULL; 897 /* TODO: Eval Charging info / cause */
807 cmd.driver = card->myid; 898 actcapi_info_resp(card, &card->bch[chan]);
808 cmd.command = ISDN_STAT_DHUP; 899 break;
809 cmd.arg = chan; 900 case 0x0401:
810 card->interface.statcallb(&cmd); 901 /* LISTEN_CONF */
811 } 902 case 0x0501:
812 break; 903 /* LISTEN_CONF */
813 } 904 case 0xff01:
814 break; 905 /* MANUFACTURER_CONF */
815 case 0x8001: 906 break;
816 /* SELECT_B3_PROTOCOL_CONF */ 907 case 0xff02:
817 chan = find_plci(card, msg->msg.select_b3_protocol_conf.plci); 908 /* MANUFACTURER_IND */
818 if (chan >= 0) 909 if (msg->msg.manuf_msg == 3) {
819 switch (card->bch[chan].fsm_state) { 910 memset(tmp, 0, sizeof(tmp));
820 case ACT2000_STATE_ICALL: 911 strncpy(tmp,
821 case ACT2000_STATE_OWAIT: 912 &msg->msg.manufacturer_ind_err.errstring,
822 ctmp = &card->bch[chan]; 913 msg->hdr.len - 16);
823 if (msg->msg.select_b3_protocol_conf.info == 0) 914 if (msg->msg.manufacturer_ind_err.errcode)
824 actcapi_listen_b3_req(card, ctmp); 915 printk(KERN_WARNING "act2000: %s\n", tmp);
825 else { 916 else {
826 ctmp->fsm_state = ACT2000_STATE_NULL; 917 printk(KERN_DEBUG "act2000: %s\n", tmp);
827 cmd.driver = card->myid; 918 if ((!strncmp(tmp, "INFO: Trace buffer con", 22)) ||
828 cmd.command = ISDN_STAT_DHUP; 919 (!strncmp(tmp, "INFO: Compile Date/Tim", 22))) {
829 cmd.arg = chan; 920 card->flags |= ACT2000_FLAGS_RUNNING;
830 card->interface.statcallb(&cmd); 921 cmd.command = ISDN_STAT_RUN;
831 }
832 }
833 break;
834 case 0x8101:
835 /* LISTEN_B3_CONF */
836 chan = find_plci(card, msg->msg.listen_b3_conf.plci);
837 if (chan >= 0)
838 switch (card->bch[chan].fsm_state) {
839 case ACT2000_STATE_ICALL:
840 ctmp = &card->bch[chan];
841 if (msg->msg.listen_b3_conf.info == 0)
842 actcapi_connect_resp(card, ctmp, 0);
843 else {
844 ctmp->fsm_state = ACT2000_STATE_NULL;
845 cmd.driver = card->myid;
846 cmd.command = ISDN_STAT_DHUP;
847 cmd.arg = chan;
848 card->interface.statcallb(&cmd);
849 }
850 break;
851 case ACT2000_STATE_OWAIT:
852 ctmp = &card->bch[chan];
853 if (msg->msg.listen_b3_conf.info == 0) {
854 actcapi_connect_b3_req(card, ctmp);
855 ctmp->fsm_state = ACT2000_STATE_OBWAIT;
856 cmd.driver = card->myid;
857 cmd.command = ISDN_STAT_DCONN;
858 cmd.arg = chan;
859 card->interface.statcallb(&cmd);
860 } else {
861 ctmp->fsm_state = ACT2000_STATE_NULL;
862 cmd.driver = card->myid;
863 cmd.command = ISDN_STAT_DHUP;
864 cmd.arg = chan;
865 card->interface.statcallb(&cmd);
866 }
867 break;
868 }
869 break;
870 case 0x8201:
871 /* CONNECT_B3_CONF */
872 chan = find_plci(card, msg->msg.connect_b3_conf.plci);
873 if ((chan >= 0) && (card->bch[chan].fsm_state == ACT2000_STATE_OBWAIT)) {
874 ctmp = &card->bch[chan];
875 if (msg->msg.connect_b3_conf.info) {
876 ctmp->fsm_state = ACT2000_STATE_NULL;
877 cmd.driver = card->myid; 922 cmd.driver = card->myid;
878 cmd.command = ISDN_STAT_DHUP; 923 cmd.arg = 0;
879 cmd.arg = chan; 924 actcapi_manufacturer_req_net(card);
925 actcapi_manufacturer_req_msn(card);
926 actcapi_listen_req(card);
880 card->interface.statcallb(&cmd); 927 card->interface.statcallb(&cmd);
881 } else {
882 ctmp->ncci = msg->msg.connect_b3_conf.ncci;
883 ctmp->fsm_state = ACT2000_STATE_BWAIT;
884 } 928 }
885 } 929 }
886 break; 930 }
887 case 0x8401: 931 break;
888 /* DISCONNECT_B3_CONF */ 932 default:
889 chan = find_ncci(card, msg->msg.disconnect_b3_conf.ncci); 933 printk(KERN_WARNING "act2000: UNHANDLED Message %04x\n", ccmd);
890 if ((chan >= 0) && (card->bch[chan].fsm_state == ACT2000_STATE_BHWAIT)) 934 break;
891 card->bch[chan].fsm_state = ACT2000_STATE_BHWAIT2;
892 break;
893 case 0x0702:
894 /* INFO_IND */
895 chan = find_plci(card, msg->msg.info_ind.plci);
896 if (chan >= 0)
897 /* TODO: Eval Charging info / cause */
898 actcapi_info_resp(card, &card->bch[chan]);
899 break;
900 case 0x0401:
901 /* LISTEN_CONF */
902 case 0x0501:
903 /* LISTEN_CONF */
904 case 0xff01:
905 /* MANUFACTURER_CONF */
906 break;
907 case 0xff02:
908 /* MANUFACTURER_IND */
909 if (msg->msg.manuf_msg == 3) {
910 memset(tmp, 0, sizeof(tmp));
911 strncpy(tmp,
912 &msg->msg.manufacturer_ind_err.errstring,
913 msg->hdr.len - 16);
914 if (msg->msg.manufacturer_ind_err.errcode)
915 printk(KERN_WARNING "act2000: %s\n", tmp);
916 else {
917 printk(KERN_DEBUG "act2000: %s\n", tmp);
918 if ((!strncmp(tmp, "INFO: Trace buffer con", 22)) ||
919 (!strncmp(tmp, "INFO: Compile Date/Tim", 22))) {
920 card->flags |= ACT2000_FLAGS_RUNNING;
921 cmd.command = ISDN_STAT_RUN;
922 cmd.driver = card->myid;
923 cmd.arg = 0;
924 actcapi_manufacturer_req_net(card);
925 actcapi_manufacturer_req_msn(card);
926 actcapi_listen_req(card);
927 card->interface.statcallb(&cmd);
928 }
929 }
930 }
931 break;
932 default:
933 printk(KERN_WARNING "act2000: UNHANDLED Message %04x\n", ccmd);
934 break;
935 } 935 }
936 dev_kfree_skb(skb); 936 dev_kfree_skb(skb);
937 } 937 }
@@ -1015,7 +1015,7 @@ actcapi_debug_msg(struct sk_buff *skb, int direction)
1015 char *descr; 1015 char *descr;
1016 int i; 1016 int i;
1017 char tmp[170]; 1017 char tmp[170];
1018 1018
1019#ifndef DEBUG_DATA_MSG 1019#ifndef DEBUG_DATA_MSG
1020 if (msg->hdr.cmd.cmd == 0x86) 1020 if (msg->hdr.cmd.cmd == 0x86)
1021 return; 1021 return;
@@ -1030,151 +1030,151 @@ actcapi_debug_msg(struct sk_buff *skb, int direction)
1030 descr = valid_msg[i].description; 1030 descr = valid_msg[i].description;
1031 break; 1031 break;
1032 } 1032 }
1033 printk(KERN_DEBUG "%s %s msg\n", direction?"Outgoing":"Incoming", descr); 1033 printk(KERN_DEBUG "%s %s msg\n", direction ? "Outgoing" : "Incoming", descr);
1034 printk(KERN_DEBUG " ApplID = %d\n", msg->hdr.applicationID); 1034 printk(KERN_DEBUG " ApplID = %d\n", msg->hdr.applicationID);
1035 printk(KERN_DEBUG " Len = %d\n", msg->hdr.len); 1035 printk(KERN_DEBUG " Len = %d\n", msg->hdr.len);
1036 printk(KERN_DEBUG " MsgNum = 0x%04x\n", msg->hdr.msgnum); 1036 printk(KERN_DEBUG " MsgNum = 0x%04x\n", msg->hdr.msgnum);
1037 printk(KERN_DEBUG " Cmd = 0x%02x\n", msg->hdr.cmd.cmd); 1037 printk(KERN_DEBUG " Cmd = 0x%02x\n", msg->hdr.cmd.cmd);
1038 printk(KERN_DEBUG " SubCmd = 0x%02x\n", msg->hdr.cmd.subcmd); 1038 printk(KERN_DEBUG " SubCmd = 0x%02x\n", msg->hdr.cmd.subcmd);
1039 switch (i) { 1039 switch (i) {
1040 case 0: 1040 case 0:
1041 /* DATA B3 IND */ 1041 /* DATA B3 IND */
1042 printk(KERN_DEBUG " BLOCK = 0x%02x\n", 1042 printk(KERN_DEBUG " BLOCK = 0x%02x\n",
1043 msg->msg.data_b3_ind.blocknr); 1043 msg->msg.data_b3_ind.blocknr);
1044 break; 1044 break;
1045 case 2: 1045 case 2:
1046 /* CONNECT CONF */ 1046 /* CONNECT CONF */
1047 printk(KERN_DEBUG " PLCI = 0x%04x\n", 1047 printk(KERN_DEBUG " PLCI = 0x%04x\n",
1048 msg->msg.connect_conf.plci); 1048 msg->msg.connect_conf.plci);
1049 printk(KERN_DEBUG " Info = 0x%04x\n", 1049 printk(KERN_DEBUG " Info = 0x%04x\n",
1050 msg->msg.connect_conf.info); 1050 msg->msg.connect_conf.info);
1051 break; 1051 break;
1052 case 3:
1053 /* CONNECT IND */
1054 printk(KERN_DEBUG " PLCI = 0x%04x\n",
1055 msg->msg.connect_ind.plci);
1056 printk(KERN_DEBUG " Contr = %d\n",
1057 msg->msg.connect_ind.controller);
1058 printk(KERN_DEBUG " SI1 = %d\n",
1059 msg->msg.connect_ind.si1);
1060 printk(KERN_DEBUG " SI2 = %d\n",
1061 msg->msg.connect_ind.si2);
1062 printk(KERN_DEBUG " EAZ = '%c'\n",
1063 msg->msg.connect_ind.eaz);
1064 actcapi_debug_caddr(&msg->msg.connect_ind.addr);
1065 break;
1066 case 5:
1067 /* CONNECT ACTIVE IND */
1068 printk(KERN_DEBUG " PLCI = 0x%04x\n",
1069 msg->msg.connect_active_ind.plci);
1070 actcapi_debug_caddr(&msg->msg.connect_active_ind.addr);
1071 break;
1072 case 8:
1073 /* LISTEN CONF */
1074 printk(KERN_DEBUG " Contr = %d\n",
1075 msg->msg.listen_conf.controller);
1076 printk(KERN_DEBUG " Info = 0x%04x\n",
1077 msg->msg.listen_conf.info);
1078 break;
1079 case 11:
1080 /* INFO IND */
1081 printk(KERN_DEBUG " PLCI = 0x%04x\n",
1082 msg->msg.info_ind.plci);
1083 printk(KERN_DEBUG " Imsk = 0x%04x\n",
1084 msg->msg.info_ind.nr.mask);
1085 if (msg->hdr.len > 12) {
1086 int l = msg->hdr.len - 12;
1087 int j;
1088 char *p = tmp;
1089 for (j = 0; j < l; j++)
1090 p += sprintf(p, "%02x ", msg->msg.info_ind.el.display[j]);
1091 printk(KERN_DEBUG " D = '%s'\n", tmp);
1092 }
1093 break;
1094 case 14:
1095 /* SELECT B2 PROTOCOL CONF */
1096 printk(KERN_DEBUG " PLCI = 0x%04x\n",
1097 msg->msg.select_b2_protocol_conf.plci);
1098 printk(KERN_DEBUG " Info = 0x%04x\n",
1099 msg->msg.select_b2_protocol_conf.info);
1100 break;
1101 case 15:
1102 /* SELECT B3 PROTOCOL CONF */
1103 printk(KERN_DEBUG " PLCI = 0x%04x\n",
1104 msg->msg.select_b3_protocol_conf.plci);
1105 printk(KERN_DEBUG " Info = 0x%04x\n",
1106 msg->msg.select_b3_protocol_conf.info);
1107 break;
1108 case 16:
1109 /* LISTEN B3 CONF */
1110 printk(KERN_DEBUG " PLCI = 0x%04x\n",
1111 msg->msg.listen_b3_conf.plci);
1112 printk(KERN_DEBUG " Info = 0x%04x\n",
1113 msg->msg.listen_b3_conf.info);
1114 break;
1115 case 18:
1116 /* CONNECT B3 IND */
1117 printk(KERN_DEBUG " NCCI = 0x%04x\n",
1118 msg->msg.connect_b3_ind.ncci);
1119 printk(KERN_DEBUG " PLCI = 0x%04x\n",
1120 msg->msg.connect_b3_ind.plci);
1121 actcapi_debug_ncpi(&msg->msg.connect_b3_ind.ncpi);
1122 break;
1123 case 19:
1124 /* CONNECT B3 ACTIVE IND */
1125 printk(KERN_DEBUG " NCCI = 0x%04x\n",
1126 msg->msg.connect_b3_active_ind.ncci);
1127 actcapi_debug_ncpi(&msg->msg.connect_b3_active_ind.ncpi);
1128 break;
1129 case 26:
1130 /* MANUFACTURER IND */
1131 printk(KERN_DEBUG " Mmsg = 0x%02x\n",
1132 msg->msg.manufacturer_ind_err.manuf_msg);
1133 switch (msg->msg.manufacturer_ind_err.manuf_msg) {
1052 case 3: 1134 case 3:
1053 /* CONNECT IND */
1054 printk(KERN_DEBUG " PLCI = 0x%04x\n",
1055 msg->msg.connect_ind.plci);
1056 printk(KERN_DEBUG " Contr = %d\n", 1135 printk(KERN_DEBUG " Contr = %d\n",
1057 msg->msg.connect_ind.controller); 1136 msg->msg.manufacturer_ind_err.controller);
1058 printk(KERN_DEBUG " SI1 = %d\n", 1137 printk(KERN_DEBUG " Code = 0x%08x\n",
1059 msg->msg.connect_ind.si1); 1138 msg->msg.manufacturer_ind_err.errcode);
1060 printk(KERN_DEBUG " SI2 = %d\n", 1139 memset(tmp, 0, sizeof(tmp));
1061 msg->msg.connect_ind.si2); 1140 strncpy(tmp, &msg->msg.manufacturer_ind_err.errstring,
1062 printk(KERN_DEBUG " EAZ = '%c'\n", 1141 msg->hdr.len - 16);
1063 msg->msg.connect_ind.eaz); 1142 printk(KERN_DEBUG " Emsg = '%s'\n", tmp);
1064 actcapi_debug_caddr(&msg->msg.connect_ind.addr);
1065 break;
1066 case 5:
1067 /* CONNECT ACTIVE IND */
1068 printk(KERN_DEBUG " PLCI = 0x%04x\n",
1069 msg->msg.connect_active_ind.plci);
1070 actcapi_debug_caddr(&msg->msg.connect_active_ind.addr);
1071 break;
1072 case 8:
1073 /* LISTEN CONF */
1074 printk(KERN_DEBUG " Contr = %d\n",
1075 msg->msg.listen_conf.controller);
1076 printk(KERN_DEBUG " Info = 0x%04x\n",
1077 msg->msg.listen_conf.info);
1078 break;
1079 case 11:
1080 /* INFO IND */
1081 printk(KERN_DEBUG " PLCI = 0x%04x\n",
1082 msg->msg.info_ind.plci);
1083 printk(KERN_DEBUG " Imsk = 0x%04x\n",
1084 msg->msg.info_ind.nr.mask);
1085 if (msg->hdr.len > 12) {
1086 int l = msg->hdr.len - 12;
1087 int j;
1088 char *p = tmp;
1089 for (j = 0; j < l ; j++)
1090 p += sprintf(p, "%02x ", msg->msg.info_ind.el.display[j]);
1091 printk(KERN_DEBUG " D = '%s'\n", tmp);
1092 }
1093 break;
1094 case 14:
1095 /* SELECT B2 PROTOCOL CONF */
1096 printk(KERN_DEBUG " PLCI = 0x%04x\n",
1097 msg->msg.select_b2_protocol_conf.plci);
1098 printk(KERN_DEBUG " Info = 0x%04x\n",
1099 msg->msg.select_b2_protocol_conf.info);
1100 break;
1101 case 15:
1102 /* SELECT B3 PROTOCOL CONF */
1103 printk(KERN_DEBUG " PLCI = 0x%04x\n",
1104 msg->msg.select_b3_protocol_conf.plci);
1105 printk(KERN_DEBUG " Info = 0x%04x\n",
1106 msg->msg.select_b3_protocol_conf.info);
1107 break;
1108 case 16:
1109 /* LISTEN B3 CONF */
1110 printk(KERN_DEBUG " PLCI = 0x%04x\n",
1111 msg->msg.listen_b3_conf.plci);
1112 printk(KERN_DEBUG " Info = 0x%04x\n",
1113 msg->msg.listen_b3_conf.info);
1114 break;
1115 case 18:
1116 /* CONNECT B3 IND */
1117 printk(KERN_DEBUG " NCCI = 0x%04x\n",
1118 msg->msg.connect_b3_ind.ncci);
1119 printk(KERN_DEBUG " PLCI = 0x%04x\n",
1120 msg->msg.connect_b3_ind.plci);
1121 actcapi_debug_ncpi(&msg->msg.connect_b3_ind.ncpi);
1122 break;
1123 case 19:
1124 /* CONNECT B3 ACTIVE IND */
1125 printk(KERN_DEBUG " NCCI = 0x%04x\n",
1126 msg->msg.connect_b3_active_ind.ncci);
1127 actcapi_debug_ncpi(&msg->msg.connect_b3_active_ind.ncpi);
1128 break;
1129 case 26:
1130 /* MANUFACTURER IND */
1131 printk(KERN_DEBUG " Mmsg = 0x%02x\n",
1132 msg->msg.manufacturer_ind_err.manuf_msg);
1133 switch (msg->msg.manufacturer_ind_err.manuf_msg) {
1134 case 3:
1135 printk(KERN_DEBUG " Contr = %d\n",
1136 msg->msg.manufacturer_ind_err.controller);
1137 printk(KERN_DEBUG " Code = 0x%08x\n",
1138 msg->msg.manufacturer_ind_err.errcode);
1139 memset(tmp, 0, sizeof(tmp));
1140 strncpy(tmp, &msg->msg.manufacturer_ind_err.errstring,
1141 msg->hdr.len - 16);
1142 printk(KERN_DEBUG " Emsg = '%s'\n", tmp);
1143 break;
1144 }
1145 break;
1146 case 30:
1147 /* LISTEN REQ */
1148 printk(KERN_DEBUG " Imsk = 0x%08x\n",
1149 msg->msg.listen_req.infomask);
1150 printk(KERN_DEBUG " Emsk = 0x%04x\n",
1151 msg->msg.listen_req.eazmask);
1152 printk(KERN_DEBUG " Smsk = 0x%04x\n",
1153 msg->msg.listen_req.simask);
1154 break;
1155 case 35:
1156 /* SELECT_B2_PROTOCOL_REQ */
1157 printk(KERN_DEBUG " PLCI = 0x%04x\n",
1158 msg->msg.select_b2_protocol_req.plci);
1159 printk(KERN_DEBUG " prot = 0x%02x\n",
1160 msg->msg.select_b2_protocol_req.protocol);
1161 if (msg->hdr.len >= 11)
1162 printk(KERN_DEBUG "No dlpd\n");
1163 else
1164 actcapi_debug_dlpd(&msg->msg.select_b2_protocol_req.dlpd);
1165 break;
1166 case 44:
1167 /* CONNECT RESP */
1168 printk(KERN_DEBUG " PLCI = 0x%04x\n",
1169 msg->msg.connect_resp.plci);
1170 printk(KERN_DEBUG " CAUSE = 0x%02x\n",
1171 msg->msg.connect_resp.rejectcause);
1172 break;
1173 case 45:
1174 /* CONNECT ACTIVE RESP */
1175 printk(KERN_DEBUG " PLCI = 0x%04x\n",
1176 msg->msg.connect_active_resp.plci);
1177 break; 1143 break;
1144 }
1145 break;
1146 case 30:
1147 /* LISTEN REQ */
1148 printk(KERN_DEBUG " Imsk = 0x%08x\n",
1149 msg->msg.listen_req.infomask);
1150 printk(KERN_DEBUG " Emsk = 0x%04x\n",
1151 msg->msg.listen_req.eazmask);
1152 printk(KERN_DEBUG " Smsk = 0x%04x\n",
1153 msg->msg.listen_req.simask);
1154 break;
1155 case 35:
1156 /* SELECT_B2_PROTOCOL_REQ */
1157 printk(KERN_DEBUG " PLCI = 0x%04x\n",
1158 msg->msg.select_b2_protocol_req.plci);
1159 printk(KERN_DEBUG " prot = 0x%02x\n",
1160 msg->msg.select_b2_protocol_req.protocol);
1161 if (msg->hdr.len >= 11)
1162 printk(KERN_DEBUG "No dlpd\n");
1163 else
1164 actcapi_debug_dlpd(&msg->msg.select_b2_protocol_req.dlpd);
1165 break;
1166 case 44:
1167 /* CONNECT RESP */
1168 printk(KERN_DEBUG " PLCI = 0x%04x\n",
1169 msg->msg.connect_resp.plci);
1170 printk(KERN_DEBUG " CAUSE = 0x%02x\n",
1171 msg->msg.connect_resp.rejectcause);
1172 break;
1173 case 45:
1174 /* CONNECT ACTIVE RESP */
1175 printk(KERN_DEBUG " PLCI = 0x%04x\n",
1176 msg->msg.connect_active_resp.plci);
1177 break;
1178 } 1178 }
1179} 1179}
1180#endif 1180#endif
diff --git a/drivers/isdn/act2000/capi.h b/drivers/isdn/act2000/capi.h
index e55f6a931f66..01ccdecd43f7 100644
--- a/drivers/isdn/act2000/capi.h
+++ b/drivers/isdn/act2000/capi.h
@@ -4,7 +4,7 @@
4 * 4 *
5 * Author Fritz Elfert 5 * Author Fritz Elfert
6 * Copyright by Fritz Elfert <fritz@isdn4linux.de> 6 * Copyright by Fritz Elfert <fritz@isdn4linux.de>
7 * 7 *
8 * This software may be used and distributed according to the terms 8 * This software may be used and distributed according to the terms
9 * of the GNU General Public License, incorporated herein by reference. 9 * of the GNU General Public License, incorporated herein by reference.
10 * 10 *
@@ -46,10 +46,10 @@ typedef struct actcapi_addr {
46typedef union actcapi_infonr { /* info number */ 46typedef union actcapi_infonr { /* info number */
47 __u16 mask; /* info-mask field */ 47 __u16 mask; /* info-mask field */
48 struct bmask { /* bit definitions */ 48 struct bmask { /* bit definitions */
49 unsigned codes : 3; /* code set */ 49 unsigned codes:3; /* code set */
50 unsigned rsvd : 5; /* reserved */ 50 unsigned rsvd:5; /* reserved */
51 unsigned svind : 1; /* single, variable length ind. */ 51 unsigned svind:1; /* single, variable length ind. */
52 unsigned wtype : 7; /* W-element type */ 52 unsigned wtype:7; /* W-element type */
53 } bmask; 53 } bmask;
54} actcapi_infonr; 54} actcapi_infonr;
55 55
@@ -59,13 +59,13 @@ typedef union actcapi_infoel { /* info element */
59 __u8 display[40]; /* display contents */ 59 __u8 display[40]; /* display contents */
60 __u8 uuinfo[40]; /* User-user info field */ 60 __u8 uuinfo[40]; /* User-user info field */
61 struct cause { /* Cause information */ 61 struct cause { /* Cause information */
62 unsigned ext2 : 1; /* extension */ 62 unsigned ext2:1; /* extension */
63 unsigned cod : 2; /* coding standard */ 63 unsigned cod:2; /* coding standard */
64 unsigned spare : 1; /* spare */ 64 unsigned spare:1; /* spare */
65 unsigned loc : 4; /* location */ 65 unsigned loc:4; /* location */
66 unsigned ext1 : 1; /* extension */ 66 unsigned ext1:1; /* extension */
67 unsigned cval : 7; /* Cause value */ 67 unsigned cval:7; /* Cause value */
68 } cause; 68 } cause;
69 struct charge { /* Charging information */ 69 struct charge { /* Charging information */
70 __u8 toc; /* type of charging info */ 70 __u8 toc; /* type of charging info */
71 __u8 unit[10]; /* charging units */ 71 __u8 unit[10]; /* charging units */
@@ -111,14 +111,14 @@ typedef struct actcapi_ncpd {
111 * Bit 5-7 = Controller 111 * Bit 5-7 = Controller
112 * Bit 8-15 = NCCI 112 * Bit 8-15 = NCCI
113 */ 113 */
114#define MAKE_NCCI(plci,contr,ncci) \ 114#define MAKE_NCCI(plci, contr, ncci) \
115 ((plci & 0x1f) | ((contr & 0x7) << 5) | ((ncci & 0xff) << 8)) 115 ((plci & 0x1f) | ((contr & 0x7) << 5) | ((ncci & 0xff) << 8))
116 116
117#define EVAL_NCCI(fakencci,plci,contr,ncci) { \ 117#define EVAL_NCCI(fakencci, plci, contr, ncci) { \
118 plci = fakencci & 0x1f; \ 118 plci = fakencci & 0x1f; \
119 contr = (fakencci >> 5) & 0x7; \ 119 contr = (fakencci >> 5) & 0x7; \
120 ncci = (fakencci >> 8) & 0xff; \ 120 ncci = (fakencci >> 8) & 0xff; \
121} 121 }
122 122
123/* 123/*
124 * Layout of PLCI field in a B3 DATA CAPI message is different from 124 * Layout of PLCI field in a B3 DATA CAPI message is different from
@@ -128,13 +128,13 @@ typedef struct actcapi_ncpd {
128 * Bit 5-7 = Controller 128 * Bit 5-7 = Controller
129 * Bit 8-15 = reserved (must be 0) 129 * Bit 8-15 = reserved (must be 0)
130 */ 130 */
131#define MAKE_PLCI(plci,contr) \ 131#define MAKE_PLCI(plci, contr) \
132 ((plci & 0x1f) | ((contr & 0x7) << 5)) 132 ((plci & 0x1f) | ((contr & 0x7) << 5))
133 133
134#define EVAL_PLCI(fakeplci,plci,contr) { \ 134#define EVAL_PLCI(fakeplci, plci, contr) { \
135 plci = fakeplci & 0x1f; \ 135 plci = fakeplci & 0x1f; \
136 contr = (fakeplci >> 5) & 0x7; \ 136 contr = (fakeplci >> 5) & 0x7; \
137} 137 }
138 138
139typedef struct actcapi_msg { 139typedef struct actcapi_msg {
140 actcapi_msghdr hdr; 140 actcapi_msghdr hdr;
diff --git a/drivers/isdn/act2000/module.c b/drivers/isdn/act2000/module.c
index 05ed72c4cf59..b4147c0b14b7 100644
--- a/drivers/isdn/act2000/module.c
+++ b/drivers/isdn/act2000/module.c
@@ -4,7 +4,7 @@
4 * 4 *
5 * Author Fritz Elfert 5 * Author Fritz Elfert
6 * Copyright by Fritz Elfert <fritz@isdn4linux.de> 6 * Copyright by Fritz Elfert <fritz@isdn4linux.de>
7 * 7 *
8 * This software may be used and distributed according to the terms 8 * This software may be used and distributed according to the terms
9 * of the GNU General Public License, incorporated herein by reference. 9 * of the GNU General Public License, incorporated herein by reference.
10 * 10 *
@@ -21,8 +21,8 @@
21 21
22static unsigned short act2000_isa_ports[] = 22static unsigned short act2000_isa_ports[] =
23{ 23{
24 0x0200, 0x0240, 0x0280, 0x02c0, 0x0300, 0x0340, 0x0380, 24 0x0200, 0x0240, 0x0280, 0x02c0, 0x0300, 0x0340, 0x0380,
25 0xcfe0, 0xcfa0, 0xcf60, 0xcf20, 0xcee0, 0xcea0, 0xce60, 25 0xcfe0, 0xcfa0, 0xcf60, 0xcf20, 0xcee0, 0xcea0, 0xce60,
26}; 26};
27 27
28static act2000_card *cards = (act2000_card *) NULL; 28static act2000_card *cards = (act2000_card *) NULL;
@@ -33,14 +33,14 @@ static int act_port = -1; /* -1 = Autoprobe */
33static int act_irq = -1; 33static int act_irq = -1;
34static char *act_id = "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"; 34static char *act_id = "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0";
35 35
36MODULE_DESCRIPTION( "ISDN4Linux: Driver for IBM Active 2000 ISDN card"); 36MODULE_DESCRIPTION("ISDN4Linux: Driver for IBM Active 2000 ISDN card");
37MODULE_AUTHOR( "Fritz Elfert"); 37MODULE_AUTHOR("Fritz Elfert");
38MODULE_LICENSE( "GPL"); 38MODULE_LICENSE("GPL");
39MODULE_PARM_DESC(act_bus, "BusType of first card, 1=ISA, 2=MCA, 3=PCMCIA, currently only ISA"); 39MODULE_PARM_DESC(act_bus, "BusType of first card, 1=ISA, 2=MCA, 3=PCMCIA, currently only ISA");
40MODULE_PARM_DESC(membase, "Base port address of first card"); 40MODULE_PARM_DESC(membase, "Base port address of first card");
41MODULE_PARM_DESC(act_irq, "IRQ of first card"); 41MODULE_PARM_DESC(act_irq, "IRQ of first card");
42MODULE_PARM_DESC(act_id, "ID-String of first card"); 42MODULE_PARM_DESC(act_id, "ID-String of first card");
43module_param(act_bus, int, 0); 43module_param(act_bus, int, 0);
44module_param(act_port, int, 0); 44module_param(act_port, int, 0);
45module_param(act_irq, int, 0); 45module_param(act_irq, int, 0);
46module_param(act_id, charp, 0); 46module_param(act_id, charp, 0);
@@ -51,7 +51,7 @@ static act2000_chan *
51find_channel(act2000_card *card, int channel) 51find_channel(act2000_card *card, int channel)
52{ 52{
53 if ((channel >= 0) && (channel < ACT2000_BCH)) 53 if ((channel >= 0) && (channel < ACT2000_BCH))
54 return &(card->bch[channel]); 54 return &(card->bch[channel]);
55 printk(KERN_WARNING "act2000: Invalid channel %d\n", channel); 55 printk(KERN_WARNING "act2000: Invalid channel %d\n", channel);
56 return NULL; 56 return NULL;
57} 57}
@@ -84,7 +84,7 @@ act2000_clear_msn(act2000_card *card)
84static __u16 84static __u16
85act2000_find_msn(act2000_card *card, char *msn, int ia5) 85act2000_find_msn(act2000_card *card, char *msn, int ia5)
86{ 86{
87 struct msn_entry *p = card->msn_list; 87 struct msn_entry *p = card->msn_list;
88 __u8 eaz = '0'; 88 __u8 eaz = '0';
89 89
90 while (p) { 90 while (p) {
@@ -107,14 +107,14 @@ act2000_find_msn(act2000_card *card, char *msn, int ia5)
107char * 107char *
108act2000_find_eaz(act2000_card *card, char eaz) 108act2000_find_eaz(act2000_card *card, char eaz)
109{ 109{
110 struct msn_entry *p = card->msn_list; 110 struct msn_entry *p = card->msn_list;
111 111
112 while (p) { 112 while (p) {
113 if (p->eaz == eaz) 113 if (p->eaz == eaz)
114 return(p->msn); 114 return (p->msn);
115 p = p->next; 115 p = p->next;
116 } 116 }
117 return("\0"); 117 return ("\0");
118} 118}
119 119
120/* 120/*
@@ -126,11 +126,11 @@ act2000_find_eaz(act2000_card *card, char eaz)
126static int 126static int
127act2000_set_msn(act2000_card *card, char *eazmsn) 127act2000_set_msn(act2000_card *card, char *eazmsn)
128{ 128{
129 struct msn_entry *p = card->msn_list; 129 struct msn_entry *p = card->msn_list;
130 struct msn_entry *q = NULL; 130 struct msn_entry *q = NULL;
131 unsigned long flags; 131 unsigned long flags;
132 int i; 132 int i;
133 133
134 if (!strlen(eazmsn)) 134 if (!strlen(eazmsn))
135 return 0; 135 return 0;
136 if (strlen(eazmsn) > 16) 136 if (strlen(eazmsn) > 16)
@@ -138,7 +138,7 @@ act2000_set_msn(act2000_card *card, char *eazmsn)
138 for (i = 0; i < strlen(eazmsn); i++) 138 for (i = 0; i < strlen(eazmsn); i++)
139 if (!isdigit(eazmsn[i])) 139 if (!isdigit(eazmsn[i]))
140 return -EINVAL; 140 return -EINVAL;
141 if (strlen(eazmsn) == 1) { 141 if (strlen(eazmsn) == 1) {
142 /* Delete a single MSN */ 142 /* Delete a single MSN */
143 while (p) { 143 while (p) {
144 if (p->eaz == eazmsn[0]) { 144 if (p->eaz == eazmsn[0]) {
@@ -158,7 +158,7 @@ act2000_set_msn(act2000_card *card, char *eazmsn)
158 p = p->next; 158 p = p->next;
159 } 159 }
160 return 0; 160 return 0;
161 } 161 }
162 /* Add a single MSN */ 162 /* Add a single MSN */
163 while (p) { 163 while (p) {
164 /* Found in list, replace MSN */ 164 /* Found in list, replace MSN */
@@ -198,14 +198,14 @@ act2000_transmit(struct work_struct *work)
198 container_of(work, struct act2000_card, snd_tq); 198 container_of(work, struct act2000_card, snd_tq);
199 199
200 switch (card->bus) { 200 switch (card->bus) {
201 case ACT2000_BUS_ISA: 201 case ACT2000_BUS_ISA:
202 act2000_isa_send(card); 202 act2000_isa_send(card);
203 break; 203 break;
204 case ACT2000_BUS_PCMCIA: 204 case ACT2000_BUS_PCMCIA:
205 case ACT2000_BUS_MCA: 205 case ACT2000_BUS_MCA:
206 default: 206 default:
207 printk(KERN_WARNING 207 printk(KERN_WARNING
208 "act2000_transmit: Illegal bustype %d\n", card->bus); 208 "act2000_transmit: Illegal bustype %d\n", card->bus);
209 } 209 }
210} 210}
211 211
@@ -216,221 +216,221 @@ act2000_receive(struct work_struct *work)
216 container_of(work, struct act2000_card, poll_tq); 216 container_of(work, struct act2000_card, poll_tq);
217 217
218 switch (card->bus) { 218 switch (card->bus) {
219 case ACT2000_BUS_ISA: 219 case ACT2000_BUS_ISA:
220 act2000_isa_receive(card); 220 act2000_isa_receive(card);
221 break; 221 break;
222 case ACT2000_BUS_PCMCIA: 222 case ACT2000_BUS_PCMCIA:
223 case ACT2000_BUS_MCA: 223 case ACT2000_BUS_MCA:
224 default: 224 default:
225 printk(KERN_WARNING 225 printk(KERN_WARNING
226 "act2000_receive: Illegal bustype %d\n", card->bus); 226 "act2000_receive: Illegal bustype %d\n", card->bus);
227 } 227 }
228} 228}
229 229
230static void 230static void
231act2000_poll(unsigned long data) 231act2000_poll(unsigned long data)
232{ 232{
233 act2000_card * card = (act2000_card *)data; 233 act2000_card *card = (act2000_card *)data;
234 unsigned long flags; 234 unsigned long flags;
235 235
236 act2000_receive(&card->poll_tq); 236 act2000_receive(&card->poll_tq);
237 spin_lock_irqsave(&card->lock, flags); 237 spin_lock_irqsave(&card->lock, flags);
238 mod_timer(&card->ptimer, jiffies+3); 238 mod_timer(&card->ptimer, jiffies + 3);
239 spin_unlock_irqrestore(&card->lock, flags); 239 spin_unlock_irqrestore(&card->lock, flags);
240} 240}
241 241
242static int 242static int
243act2000_command(act2000_card * card, isdn_ctrl * c) 243act2000_command(act2000_card *card, isdn_ctrl *c)
244{ 244{
245 ulong a; 245 ulong a;
246 act2000_chan *chan; 246 act2000_chan *chan;
247 act2000_cdef cdef; 247 act2000_cdef cdef;
248 isdn_ctrl cmd; 248 isdn_ctrl cmd;
249 char tmp[17]; 249 char tmp[17];
250 int ret; 250 int ret;
251 unsigned long flags; 251 unsigned long flags;
252 void __user *arg; 252 void __user *arg;
253 253
254 switch (c->command) { 254 switch (c->command) {
255 case ISDN_CMD_IOCTL: 255 case ISDN_CMD_IOCTL:
256 memcpy(&a, c->parm.num, sizeof(ulong)); 256 memcpy(&a, c->parm.num, sizeof(ulong));
257 arg = (void __user *)a; 257 arg = (void __user *)a;
258 switch (c->arg) { 258 switch (c->arg) {
259 case ACT2000_IOCTL_LOADBOOT: 259 case ACT2000_IOCTL_LOADBOOT:
260 switch (card->bus) { 260 switch (card->bus) {
261 case ACT2000_BUS_ISA: 261 case ACT2000_BUS_ISA:
262 ret = act2000_isa_download(card, 262 ret = act2000_isa_download(card,
263 arg); 263 arg);
264 if (!ret) { 264 if (!ret) {
265 card->flags |= ACT2000_FLAGS_LOADED; 265 card->flags |= ACT2000_FLAGS_LOADED;
266 if (!(card->flags & ACT2000_FLAGS_IVALID)) { 266 if (!(card->flags & ACT2000_FLAGS_IVALID)) {
267 card->ptimer.expires = jiffies + 3; 267 card->ptimer.expires = jiffies + 3;
268 card->ptimer.function = act2000_poll; 268 card->ptimer.function = act2000_poll;
269 card->ptimer.data = (unsigned long)card; 269 card->ptimer.data = (unsigned long)card;
270 add_timer(&card->ptimer); 270 add_timer(&card->ptimer);
271 }
272 actcapi_manufacturer_req_errh(card);
273 }
274 break;
275 default:
276 printk(KERN_WARNING
277 "act2000: Illegal BUS type %d\n",
278 card->bus);
279 ret = -EIO;
280 } 271 }
281 return ret; 272 actcapi_manufacturer_req_errh(card);
282 case ACT2000_IOCTL_SETPROTO: 273 }
283 card->ptype = a?ISDN_PTYPE_EURO:ISDN_PTYPE_1TR6;
284 if (!(card->flags & ACT2000_FLAGS_RUNNING))
285 return 0;
286 actcapi_manufacturer_req_net(card);
287 return 0;
288 case ACT2000_IOCTL_SETMSN:
289 if (copy_from_user(tmp, arg,
290 sizeof(tmp)))
291 return -EFAULT;
292 if ((ret = act2000_set_msn(card, tmp)))
293 return ret;
294 if (card->flags & ACT2000_FLAGS_RUNNING)
295 return(actcapi_manufacturer_req_msn(card));
296 return 0;
297 case ACT2000_IOCTL_ADDCARD:
298 if (copy_from_user(&cdef, arg,
299 sizeof(cdef)))
300 return -EFAULT;
301 if (act2000_addcard(cdef.bus, cdef.port, cdef.irq, cdef.id))
302 return -EIO;
303 return 0;
304 case ACT2000_IOCTL_TEST:
305 if (!(card->flags & ACT2000_FLAGS_RUNNING))
306 return -ENODEV;
307 return 0;
308 default:
309 return -EINVAL;
310 }
311 break;
312 case ISDN_CMD_DIAL:
313 if (!(card->flags & ACT2000_FLAGS_RUNNING))
314 return -ENODEV;
315 if (!(chan = find_channel(card, c->arg & 0x0f)))
316 break; 274 break;
317 spin_lock_irqsave(&card->lock, flags); 275 default:
318 if (chan->fsm_state != ACT2000_STATE_NULL) { 276 printk(KERN_WARNING
319 spin_unlock_irqrestore(&card->lock, flags); 277 "act2000: Illegal BUS type %d\n",
320 printk(KERN_WARNING "Dial on channel with state %d\n", 278 card->bus);
321 chan->fsm_state); 279 ret = -EIO;
322 return -EBUSY;
323 }
324 if (card->ptype == ISDN_PTYPE_EURO)
325 tmp[0] = act2000_find_msn(card, c->parm.setup.eazmsn, 1);
326 else
327 tmp[0] = c->parm.setup.eazmsn[0];
328 chan->fsm_state = ACT2000_STATE_OCALL;
329 chan->callref = 0xffff;
330 spin_unlock_irqrestore(&card->lock, flags);
331 ret = actcapi_connect_req(card, chan, c->parm.setup.phone,
332 tmp[0], c->parm.setup.si1,
333 c->parm.setup.si2);
334 if (ret) {
335 cmd.driver = card->myid;
336 cmd.command = ISDN_STAT_DHUP;
337 cmd.arg &= 0x0f;
338 card->interface.statcallb(&cmd);
339 } 280 }
340 return ret; 281 return ret;
341 case ISDN_CMD_ACCEPTD: 282 case ACT2000_IOCTL_SETPROTO:
342 if (!(card->flags & ACT2000_FLAGS_RUNNING)) 283 card->ptype = a ? ISDN_PTYPE_EURO : ISDN_PTYPE_1TR6;
343 return -ENODEV;
344 if (!(chan = find_channel(card, c->arg & 0x0f)))
345 break;
346 if (chan->fsm_state == ACT2000_STATE_ICALL)
347 actcapi_select_b2_protocol_req(card, chan);
348 return 0;
349 case ISDN_CMD_ACCEPTB:
350 if (!(card->flags & ACT2000_FLAGS_RUNNING))
351 return -ENODEV;
352 return 0;
353 case ISDN_CMD_HANGUP:
354 if (!(card->flags & ACT2000_FLAGS_RUNNING)) 284 if (!(card->flags & ACT2000_FLAGS_RUNNING))
355 return -ENODEV; 285 return 0;
356 if (!(chan = find_channel(card, c->arg & 0x0f))) 286 actcapi_manufacturer_req_net(card);
357 break;
358 switch (chan->fsm_state) {
359 case ACT2000_STATE_ICALL:
360 case ACT2000_STATE_BSETUP:
361 actcapi_connect_resp(card, chan, 0x15);
362 break;
363 case ACT2000_STATE_ACTIVE:
364 actcapi_disconnect_b3_req(card, chan);
365 break;
366 }
367 return 0; 287 return 0;
368 case ISDN_CMD_SETEAZ: 288 case ACT2000_IOCTL_SETMSN:
369 if (!(card->flags & ACT2000_FLAGS_RUNNING)) 289 if (copy_from_user(tmp, arg,
370 return -ENODEV; 290 sizeof(tmp)))
371 if (!(chan = find_channel(card, c->arg & 0x0f))) 291 return -EFAULT;
372 break; 292 if ((ret = act2000_set_msn(card, tmp)))
373 if (strlen(c->parm.num)) { 293 return ret;
374 if (card->ptype == ISDN_PTYPE_EURO) { 294 if (card->flags & ACT2000_FLAGS_RUNNING)
375 chan->eazmask = act2000_find_msn(card, c->parm.num, 0); 295 return (actcapi_manufacturer_req_msn(card));
376 }
377 if (card->ptype == ISDN_PTYPE_1TR6) {
378 int i;
379 chan->eazmask = 0;
380 for (i = 0; i < strlen(c->parm.num); i++)
381 if (isdigit(c->parm.num[i]))
382 chan->eazmask |= (1 << (c->parm.num[i] - '0'));
383 }
384 } else
385 chan->eazmask = 0x3ff;
386 actcapi_listen_req(card);
387 return 0; 296 return 0;
388 case ISDN_CMD_CLREAZ: 297 case ACT2000_IOCTL_ADDCARD:
389 if (!(card->flags & ACT2000_FLAGS_RUNNING)) 298 if (copy_from_user(&cdef, arg,
390 return -ENODEV; 299 sizeof(cdef)))
391 if (!(chan = find_channel(card, c->arg & 0x0f))) 300 return -EFAULT;
392 break; 301 if (act2000_addcard(cdef.bus, cdef.port, cdef.irq, cdef.id))
393 chan->eazmask = 0; 302 return -EIO;
394 actcapi_listen_req(card);
395 return 0; 303 return 0;
396 case ISDN_CMD_SETL2: 304 case ACT2000_IOCTL_TEST:
397 if (!(card->flags & ACT2000_FLAGS_RUNNING)) 305 if (!(card->flags & ACT2000_FLAGS_RUNNING))
398 return -ENODEV; 306 return -ENODEV;
399 if (!(chan = find_channel(card, c->arg & 0x0f)))
400 break;
401 chan->l2prot = (c->arg >> 8);
402 return 0; 307 return 0;
403 case ISDN_CMD_SETL3: 308 default:
404 if (!(card->flags & ACT2000_FLAGS_RUNNING)) 309 return -EINVAL;
405 return -ENODEV; 310 }
406 if ((c->arg >> 8) != ISDN_PROTO_L3_TRANS) { 311 break;
407 printk(KERN_WARNING "L3 protocol unknown\n"); 312 case ISDN_CMD_DIAL:
408 return -1; 313 if (!(card->flags & ACT2000_FLAGS_RUNNING))
314 return -ENODEV;
315 if (!(chan = find_channel(card, c->arg & 0x0f)))
316 break;
317 spin_lock_irqsave(&card->lock, flags);
318 if (chan->fsm_state != ACT2000_STATE_NULL) {
319 spin_unlock_irqrestore(&card->lock, flags);
320 printk(KERN_WARNING "Dial on channel with state %d\n",
321 chan->fsm_state);
322 return -EBUSY;
323 }
324 if (card->ptype == ISDN_PTYPE_EURO)
325 tmp[0] = act2000_find_msn(card, c->parm.setup.eazmsn, 1);
326 else
327 tmp[0] = c->parm.setup.eazmsn[0];
328 chan->fsm_state = ACT2000_STATE_OCALL;
329 chan->callref = 0xffff;
330 spin_unlock_irqrestore(&card->lock, flags);
331 ret = actcapi_connect_req(card, chan, c->parm.setup.phone,
332 tmp[0], c->parm.setup.si1,
333 c->parm.setup.si2);
334 if (ret) {
335 cmd.driver = card->myid;
336 cmd.command = ISDN_STAT_DHUP;
337 cmd.arg &= 0x0f;
338 card->interface.statcallb(&cmd);
339 }
340 return ret;
341 case ISDN_CMD_ACCEPTD:
342 if (!(card->flags & ACT2000_FLAGS_RUNNING))
343 return -ENODEV;
344 if (!(chan = find_channel(card, c->arg & 0x0f)))
345 break;
346 if (chan->fsm_state == ACT2000_STATE_ICALL)
347 actcapi_select_b2_protocol_req(card, chan);
348 return 0;
349 case ISDN_CMD_ACCEPTB:
350 if (!(card->flags & ACT2000_FLAGS_RUNNING))
351 return -ENODEV;
352 return 0;
353 case ISDN_CMD_HANGUP:
354 if (!(card->flags & ACT2000_FLAGS_RUNNING))
355 return -ENODEV;
356 if (!(chan = find_channel(card, c->arg & 0x0f)))
357 break;
358 switch (chan->fsm_state) {
359 case ACT2000_STATE_ICALL:
360 case ACT2000_STATE_BSETUP:
361 actcapi_connect_resp(card, chan, 0x15);
362 break;
363 case ACT2000_STATE_ACTIVE:
364 actcapi_disconnect_b3_req(card, chan);
365 break;
366 }
367 return 0;
368 case ISDN_CMD_SETEAZ:
369 if (!(card->flags & ACT2000_FLAGS_RUNNING))
370 return -ENODEV;
371 if (!(chan = find_channel(card, c->arg & 0x0f)))
372 break;
373 if (strlen(c->parm.num)) {
374 if (card->ptype == ISDN_PTYPE_EURO) {
375 chan->eazmask = act2000_find_msn(card, c->parm.num, 0);
409 } 376 }
410 if (!(chan = find_channel(card, c->arg & 0x0f))) 377 if (card->ptype == ISDN_PTYPE_1TR6) {
411 break; 378 int i;
412 chan->l3prot = (c->arg >> 8); 379 chan->eazmask = 0;
413 return 0; 380 for (i = 0; i < strlen(c->parm.num); i++)
414 } 381 if (isdigit(c->parm.num[i]))
415 382 chan->eazmask |= (1 << (c->parm.num[i] - '0'));
416 return -EINVAL; 383 }
384 } else
385 chan->eazmask = 0x3ff;
386 actcapi_listen_req(card);
387 return 0;
388 case ISDN_CMD_CLREAZ:
389 if (!(card->flags & ACT2000_FLAGS_RUNNING))
390 return -ENODEV;
391 if (!(chan = find_channel(card, c->arg & 0x0f)))
392 break;
393 chan->eazmask = 0;
394 actcapi_listen_req(card);
395 return 0;
396 case ISDN_CMD_SETL2:
397 if (!(card->flags & ACT2000_FLAGS_RUNNING))
398 return -ENODEV;
399 if (!(chan = find_channel(card, c->arg & 0x0f)))
400 break;
401 chan->l2prot = (c->arg >> 8);
402 return 0;
403 case ISDN_CMD_SETL3:
404 if (!(card->flags & ACT2000_FLAGS_RUNNING))
405 return -ENODEV;
406 if ((c->arg >> 8) != ISDN_PROTO_L3_TRANS) {
407 printk(KERN_WARNING "L3 protocol unknown\n");
408 return -1;
409 }
410 if (!(chan = find_channel(card, c->arg & 0x0f)))
411 break;
412 chan->l3prot = (c->arg >> 8);
413 return 0;
414 }
415
416 return -EINVAL;
417} 417}
418 418
419static int 419static int
420act2000_sendbuf(act2000_card *card, int channel, int ack, struct sk_buff *skb) 420act2000_sendbuf(act2000_card *card, int channel, int ack, struct sk_buff *skb)
421{ 421{
422 struct sk_buff *xmit_skb; 422 struct sk_buff *xmit_skb;
423 int len; 423 int len;
424 act2000_chan *chan; 424 act2000_chan *chan;
425 actcapi_msg *msg; 425 actcapi_msg *msg;
426 426
427 if (!(chan = find_channel(card, channel))) 427 if (!(chan = find_channel(card, channel)))
428 return -1;
429 if (chan->fsm_state != ACT2000_STATE_ACTIVE)
428 return -1; 430 return -1;
429 if (chan->fsm_state != ACT2000_STATE_ACTIVE) 431 len = skb->len;
430 return -1; 432 if ((chan->queued + len) >= ACT2000_MAX_QUEUED)
431 len = skb->len; 433 return 0;
432 if ((chan->queued + len) >= ACT2000_MAX_QUEUED)
433 return 0;
434 if (!len) 434 if (!len)
435 return 0; 435 return 0;
436 if (skb_headroom(skb) < 19) { 436 if (skb_headroom(skb) < 19) {
@@ -462,28 +462,28 @@ act2000_sendbuf(act2000_card *card, int channel, int ack, struct sk_buff *skb)
462 msg->msg.data_b3_req.fakencci = MAKE_NCCI(chan->plci, 0, chan->ncci); 462 msg->msg.data_b3_req.fakencci = MAKE_NCCI(chan->plci, 0, chan->ncci);
463 msg->msg.data_b3_req.flags = ack; /* Will be set to 0 on actual sending */ 463 msg->msg.data_b3_req.flags = ack; /* Will be set to 0 on actual sending */
464 actcapi_debug_msg(xmit_skb, 1); 464 actcapi_debug_msg(xmit_skb, 1);
465 chan->queued += len; 465 chan->queued += len;
466 skb_queue_tail(&card->sndq, xmit_skb); 466 skb_queue_tail(&card->sndq, xmit_skb);
467 act2000_schedule_tx(card); 467 act2000_schedule_tx(card);
468 return len; 468 return len;
469} 469}
470 470
471 471
472/* Read the Status-replies from the Interface */ 472/* Read the Status-replies from the Interface */
473static int 473static int
474act2000_readstatus(u_char __user * buf, int len, act2000_card * card) 474act2000_readstatus(u_char __user *buf, int len, act2000_card *card)
475{ 475{
476 int count; 476 int count;
477 u_char __user *p; 477 u_char __user *p;
478 478
479 for (p = buf, count = 0; count < len; p++, count++) { 479 for (p = buf, count = 0; count < len; p++, count++) {
480 if (card->status_buf_read == card->status_buf_write) 480 if (card->status_buf_read == card->status_buf_write)
481 return count; 481 return count;
482 put_user(*card->status_buf_read++, p); 482 put_user(*card->status_buf_read++, p);
483 if (card->status_buf_read > card->status_buf_end) 483 if (card->status_buf_read > card->status_buf_end)
484 card->status_buf_read = card->status_buf; 484 card->status_buf_read = card->status_buf;
485 } 485 }
486 return count; 486 return count;
487} 487}
488 488
489/* 489/*
@@ -492,75 +492,75 @@ act2000_readstatus(u_char __user * buf, int len, act2000_card * card)
492static inline act2000_card * 492static inline act2000_card *
493act2000_findcard(int driverid) 493act2000_findcard(int driverid)
494{ 494{
495 act2000_card *p = cards; 495 act2000_card *p = cards;
496 496
497 while (p) { 497 while (p) {
498 if (p->myid == driverid) 498 if (p->myid == driverid)
499 return p; 499 return p;
500 p = p->next; 500 p = p->next;
501 } 501 }
502 return (act2000_card *) 0; 502 return (act2000_card *) 0;
503} 503}
504 504
505/* 505/*
506 * Wrapper functions for interface to linklevel 506 * Wrapper functions for interface to linklevel
507 */ 507 */
508static int 508static int
509if_command(isdn_ctrl * c) 509if_command(isdn_ctrl *c)
510{ 510{
511 act2000_card *card = act2000_findcard(c->driver); 511 act2000_card *card = act2000_findcard(c->driver);
512 512
513 if (card) 513 if (card)
514 return (act2000_command(card, c)); 514 return (act2000_command(card, c));
515 printk(KERN_ERR 515 printk(KERN_ERR
516 "act2000: if_command %d called with invalid driverId %d!\n", 516 "act2000: if_command %d called with invalid driverId %d!\n",
517 c->command, c->driver); 517 c->command, c->driver);
518 return -ENODEV; 518 return -ENODEV;
519} 519}
520 520
521static int 521static int
522if_writecmd(const u_char __user *buf, int len, int id, int channel) 522if_writecmd(const u_char __user *buf, int len, int id, int channel)
523{ 523{
524 act2000_card *card = act2000_findcard(id); 524 act2000_card *card = act2000_findcard(id);
525 525
526 if (card) { 526 if (card) {
527 if (!(card->flags & ACT2000_FLAGS_RUNNING)) 527 if (!(card->flags & ACT2000_FLAGS_RUNNING))
528 return -ENODEV; 528 return -ENODEV;
529 return (len); 529 return (len);
530 } 530 }
531 printk(KERN_ERR 531 printk(KERN_ERR
532 "act2000: if_writecmd called with invalid driverId!\n"); 532 "act2000: if_writecmd called with invalid driverId!\n");
533 return -ENODEV; 533 return -ENODEV;
534} 534}
535 535
536static int 536static int
537if_readstatus(u_char __user * buf, int len, int id, int channel) 537if_readstatus(u_char __user *buf, int len, int id, int channel)
538{ 538{
539 act2000_card *card = act2000_findcard(id); 539 act2000_card *card = act2000_findcard(id);
540 540
541 if (card) { 541 if (card) {
542 if (!(card->flags & ACT2000_FLAGS_RUNNING)) 542 if (!(card->flags & ACT2000_FLAGS_RUNNING))
543 return -ENODEV; 543 return -ENODEV;
544 return (act2000_readstatus(buf, len, card)); 544 return (act2000_readstatus(buf, len, card));
545 } 545 }
546 printk(KERN_ERR 546 printk(KERN_ERR
547 "act2000: if_readstatus called with invalid driverId!\n"); 547 "act2000: if_readstatus called with invalid driverId!\n");
548 return -ENODEV; 548 return -ENODEV;
549} 549}
550 550
551static int 551static int
552if_sendbuf(int id, int channel, int ack, struct sk_buff *skb) 552if_sendbuf(int id, int channel, int ack, struct sk_buff *skb)
553{ 553{
554 act2000_card *card = act2000_findcard(id); 554 act2000_card *card = act2000_findcard(id);
555 555
556 if (card) { 556 if (card) {
557 if (!(card->flags & ACT2000_FLAGS_RUNNING)) 557 if (!(card->flags & ACT2000_FLAGS_RUNNING))
558 return -ENODEV; 558 return -ENODEV;
559 return (act2000_sendbuf(card, channel, ack, skb)); 559 return (act2000_sendbuf(card, channel, ack, skb));
560 } 560 }
561 printk(KERN_ERR 561 printk(KERN_ERR
562 "act2000: if_sendbuf called with invalid driverId!\n"); 562 "act2000: if_sendbuf called with invalid driverId!\n");
563 return -ENODEV; 563 return -ENODEV;
564} 564}
565 565
566 566
@@ -572,14 +572,14 @@ static void
572act2000_alloccard(int bus, int port, int irq, char *id) 572act2000_alloccard(int bus, int port, int irq, char *id)
573{ 573{
574 int i; 574 int i;
575 act2000_card *card; 575 act2000_card *card;
576 if (!(card = kzalloc(sizeof(act2000_card), GFP_KERNEL))) { 576 if (!(card = kzalloc(sizeof(act2000_card), GFP_KERNEL))) {
577 printk(KERN_WARNING 577 printk(KERN_WARNING
578 "act2000: (%s) Could not allocate card-struct.\n", id); 578 "act2000: (%s) Could not allocate card-struct.\n", id);
579 return; 579 return;
580 } 580 }
581 spin_lock_init(&card->lock); 581 spin_lock_init(&card->lock);
582 spin_lock_init(&card->mnlock); 582 spin_lock_init(&card->mnlock);
583 skb_queue_head_init(&card->sndq); 583 skb_queue_head_init(&card->sndq);
584 skb_queue_head_init(&card->rcvq); 584 skb_queue_head_init(&card->rcvq);
585 skb_queue_head_init(&card->ackq); 585 skb_queue_head_init(&card->ackq);
@@ -588,82 +588,82 @@ act2000_alloccard(int bus, int port, int irq, char *id)
588 INIT_WORK(&card->poll_tq, act2000_receive); 588 INIT_WORK(&card->poll_tq, act2000_receive);
589 init_timer(&card->ptimer); 589 init_timer(&card->ptimer);
590 card->interface.owner = THIS_MODULE; 590 card->interface.owner = THIS_MODULE;
591 card->interface.channels = ACT2000_BCH; 591 card->interface.channels = ACT2000_BCH;
592 card->interface.maxbufsize = 4000; 592 card->interface.maxbufsize = 4000;
593 card->interface.command = if_command; 593 card->interface.command = if_command;
594 card->interface.writebuf_skb = if_sendbuf; 594 card->interface.writebuf_skb = if_sendbuf;
595 card->interface.writecmd = if_writecmd; 595 card->interface.writecmd = if_writecmd;
596 card->interface.readstat = if_readstatus; 596 card->interface.readstat = if_readstatus;
597 card->interface.features = 597 card->interface.features =
598 ISDN_FEATURE_L2_X75I | 598 ISDN_FEATURE_L2_X75I |
599 ISDN_FEATURE_L2_HDLC | 599 ISDN_FEATURE_L2_HDLC |
600 ISDN_FEATURE_L3_TRANS | 600 ISDN_FEATURE_L3_TRANS |
601 ISDN_FEATURE_P_UNKNOWN; 601 ISDN_FEATURE_P_UNKNOWN;
602 card->interface.hl_hdrlen = 20; 602 card->interface.hl_hdrlen = 20;
603 card->ptype = ISDN_PTYPE_EURO; 603 card->ptype = ISDN_PTYPE_EURO;
604 strlcpy(card->interface.id, id, sizeof(card->interface.id)); 604 strlcpy(card->interface.id, id, sizeof(card->interface.id));
605 for (i=0; i<ACT2000_BCH; i++) { 605 for (i = 0; i < ACT2000_BCH; i++) {
606 card->bch[i].plci = 0x8000; 606 card->bch[i].plci = 0x8000;
607 card->bch[i].ncci = 0x8000; 607 card->bch[i].ncci = 0x8000;
608 card->bch[i].l2prot = ISDN_PROTO_L2_X75I; 608 card->bch[i].l2prot = ISDN_PROTO_L2_X75I;
609 card->bch[i].l3prot = ISDN_PROTO_L3_TRANS; 609 card->bch[i].l3prot = ISDN_PROTO_L3_TRANS;
610 } 610 }
611 card->myid = -1; 611 card->myid = -1;
612 card->bus = bus; 612 card->bus = bus;
613 card->port = port; 613 card->port = port;
614 card->irq = irq; 614 card->irq = irq;
615 card->next = cards; 615 card->next = cards;
616 cards = card; 616 cards = card;
617} 617}
618 618
619/* 619/*
620 * register card at linklevel 620 * register card at linklevel
621 */ 621 */
622static int 622static int
623act2000_registercard(act2000_card * card) 623act2000_registercard(act2000_card *card)
624{ 624{
625 switch (card->bus) { 625 switch (card->bus) {
626 case ACT2000_BUS_ISA: 626 case ACT2000_BUS_ISA:
627 break; 627 break;
628 case ACT2000_BUS_MCA: 628 case ACT2000_BUS_MCA:
629 case ACT2000_BUS_PCMCIA: 629 case ACT2000_BUS_PCMCIA:
630 default: 630 default:
631 printk(KERN_WARNING 631 printk(KERN_WARNING
632 "act2000: Illegal BUS type %d\n", 632 "act2000: Illegal BUS type %d\n",
633 card->bus); 633 card->bus);
634 return -1; 634 return -1;
635 } 635 }
636 if (!register_isdn(&card->interface)) { 636 if (!register_isdn(&card->interface)) {
637 printk(KERN_WARNING 637 printk(KERN_WARNING
638 "act2000: Unable to register %s\n", 638 "act2000: Unable to register %s\n",
639 card->interface.id); 639 card->interface.id);
640 return -1; 640 return -1;
641 } 641 }
642 card->myid = card->interface.channels; 642 card->myid = card->interface.channels;
643 sprintf(card->regname, "act2000-isdn (%s)", card->interface.id); 643 sprintf(card->regname, "act2000-isdn (%s)", card->interface.id);
644 return 0; 644 return 0;
645} 645}
646 646
647static void 647static void
648unregister_card(act2000_card * card) 648unregister_card(act2000_card *card)
649{ 649{
650 isdn_ctrl cmd; 650 isdn_ctrl cmd;
651 651
652 cmd.command = ISDN_STAT_UNLOAD; 652 cmd.command = ISDN_STAT_UNLOAD;
653 cmd.driver = card->myid; 653 cmd.driver = card->myid;
654 card->interface.statcallb(&cmd); 654 card->interface.statcallb(&cmd);
655 switch (card->bus) { 655 switch (card->bus) {
656 case ACT2000_BUS_ISA: 656 case ACT2000_BUS_ISA:
657 act2000_isa_release(card); 657 act2000_isa_release(card);
658 break; 658 break;
659 case ACT2000_BUS_MCA: 659 case ACT2000_BUS_MCA:
660 case ACT2000_BUS_PCMCIA: 660 case ACT2000_BUS_PCMCIA:
661 default: 661 default:
662 printk(KERN_WARNING 662 printk(KERN_WARNING
663 "act2000: Invalid BUS type %d\n", 663 "act2000: Invalid BUS type %d\n",
664 card->bus); 664 card->bus);
665 break; 665 break;
666 } 666 }
667} 667}
668 668
669static int 669static int
@@ -690,23 +690,23 @@ act2000_addcard(int bus, int port, int irq, char *id)
690 for (i = 0; i < ARRAY_SIZE(act2000_isa_ports); i++) 690 for (i = 0; i < ARRAY_SIZE(act2000_isa_ports); i++)
691 if (act2000_isa_detect(act2000_isa_ports[i])) { 691 if (act2000_isa_detect(act2000_isa_ports[i])) {
692 printk(KERN_INFO "act2000: Detected " 692 printk(KERN_INFO "act2000: Detected "
693 "ISA card at port 0x%x\n", 693 "ISA card at port 0x%x\n",
694 act2000_isa_ports[i]); 694 act2000_isa_ports[i]);
695 act2000_alloccard(bus, 695 act2000_alloccard(bus,
696 act2000_isa_ports[i], irq, id); 696 act2000_isa_ports[i], irq, id);
697 } 697 }
698 break; 698 break;
699 case ACT2000_BUS_MCA: 699 case ACT2000_BUS_MCA:
700 case ACT2000_BUS_PCMCIA: 700 case ACT2000_BUS_PCMCIA:
701 default: 701 default:
702 printk(KERN_WARNING 702 printk(KERN_WARNING
703 "act2000: addcard: Invalid BUS type %d\n", bus); 703 "act2000: addcard: Invalid BUS type %d\n", bus);
704 } 704 }
705 } 705 }
706 if (!cards) 706 if (!cards)
707 return 1; 707 return 1;
708 p = cards; 708 p = cards;
709 while (p) { 709 while (p) {
710 initialized = 0; 710 initialized = 0;
711 if (!p->interface.statcallb) { 711 if (!p->interface.statcallb) {
712 /* Not yet registered. 712 /* Not yet registered.
@@ -714,99 +714,99 @@ act2000_addcard(int bus, int port, int irq, char *id)
714 */ 714 */
715 added++; 715 added++;
716 switch (p->bus) { 716 switch (p->bus) {
717 case ACT2000_BUS_ISA: 717 case ACT2000_BUS_ISA:
718 if (act2000_isa_detect(p->port)) { 718 if (act2000_isa_detect(p->port)) {
719 if (act2000_registercard(p)) 719 if (act2000_registercard(p))
720 break; 720 break;
721 if (act2000_isa_config_port(p, p->port)) { 721 if (act2000_isa_config_port(p, p->port)) {
722 printk(KERN_WARNING 722 printk(KERN_WARNING
723 "act2000: Could not request port 0x%04x\n", 723 "act2000: Could not request port 0x%04x\n",
724 p->port);
725 unregister_card(p);
726 p->interface.statcallb = NULL;
727 break;
728 }
729 if (act2000_isa_config_irq(p, p->irq)) {
730 printk(KERN_INFO
731 "act2000: No IRQ available, fallback to polling\n");
732 /* Fall back to polled operation */
733 p->irq = 0;
734 }
735 printk(KERN_INFO
736 "act2000: ISA"
737 "-type card at port "
738 "0x%04x ",
739 p->port); 724 p->port);
740 if (p->irq) 725 unregister_card(p);
741 printk("irq %d\n", p->irq); 726 p->interface.statcallb = NULL;
742 else 727 break;
743 printk("polled\n"); 728 }
744 initialized = 1; 729 if (act2000_isa_config_irq(p, p->irq)) {
730 printk(KERN_INFO
731 "act2000: No IRQ available, fallback to polling\n");
732 /* Fall back to polled operation */
733 p->irq = 0;
745 } 734 }
746 break; 735 printk(KERN_INFO
747 case ACT2000_BUS_MCA: 736 "act2000: ISA"
748 case ACT2000_BUS_PCMCIA: 737 "-type card at port "
749 default: 738 "0x%04x ",
750 printk(KERN_WARNING 739 p->port);
751 "act2000: addcard: Invalid BUS type %d\n", 740 if (p->irq)
752 p->bus); 741 printk("irq %d\n", p->irq);
742 else
743 printk("polled\n");
744 initialized = 1;
745 }
746 break;
747 case ACT2000_BUS_MCA:
748 case ACT2000_BUS_PCMCIA:
749 default:
750 printk(KERN_WARNING
751 "act2000: addcard: Invalid BUS type %d\n",
752 p->bus);
753 } 753 }
754 } else 754 } else
755 /* Card already initialized */ 755 /* Card already initialized */
756 initialized = 1; 756 initialized = 1;
757 if (initialized) { 757 if (initialized) {
758 /* Init OK, next card ... */ 758 /* Init OK, next card ... */
759 q = p; 759 q = p;
760 p = p->next; 760 p = p->next;
761 } else { 761 } else {
762 /* Init failed, remove card from list, free memory */ 762 /* Init failed, remove card from list, free memory */
763 printk(KERN_WARNING 763 printk(KERN_WARNING
764 "act2000: Initialization of %s failed\n", 764 "act2000: Initialization of %s failed\n",
765 p->interface.id); 765 p->interface.id);
766 if (q) { 766 if (q) {
767 q->next = p->next; 767 q->next = p->next;
768 kfree(p); 768 kfree(p);
769 p = q->next; 769 p = q->next;
770 } else { 770 } else {
771 cards = p->next; 771 cards = p->next;
772 kfree(p); 772 kfree(p);
773 p = cards; 773 p = cards;
774 } 774 }
775 failed++; 775 failed++;
776 } 776 }
777 } 777 }
778 return (added - failed); 778 return (added - failed);
779} 779}
780 780
781#define DRIVERNAME "IBM Active 2000 ISDN driver" 781#define DRIVERNAME "IBM Active 2000 ISDN driver"
782 782
783static int __init act2000_init(void) 783static int __init act2000_init(void)
784{ 784{
785 printk(KERN_INFO "%s\n", DRIVERNAME); 785 printk(KERN_INFO "%s\n", DRIVERNAME);
786 if (!cards) 786 if (!cards)
787 act2000_addcard(act_bus, act_port, act_irq, act_id); 787 act2000_addcard(act_bus, act_port, act_irq, act_id);
788 if (!cards) 788 if (!cards)
789 printk(KERN_INFO "act2000: No cards defined yet\n"); 789 printk(KERN_INFO "act2000: No cards defined yet\n");
790 return 0; 790 return 0;
791} 791}
792 792
793static void __exit act2000_exit(void) 793static void __exit act2000_exit(void)
794{ 794{
795 act2000_card *card = cards; 795 act2000_card *card = cards;
796 act2000_card *last; 796 act2000_card *last;
797 while (card) { 797 while (card) {
798 unregister_card(card); 798 unregister_card(card);
799 del_timer(&card->ptimer); 799 del_timer(&card->ptimer);
800 card = card->next; 800 card = card->next;
801 } 801 }
802 card = cards; 802 card = cards;
803 while (card) { 803 while (card) {
804 last = card; 804 last = card;
805 card = card->next; 805 card = card->next;
806 act2000_clear_msn(last); 806 act2000_clear_msn(last);
807 kfree(last); 807 kfree(last);
808 } 808 }
809 printk(KERN_INFO "%s unloaded\n", DRIVERNAME); 809 printk(KERN_INFO "%s unloaded\n", DRIVERNAME);
810} 810}
811 811
812module_init(act2000_init); 812module_init(act2000_init);