aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJan Kiszka <jan.kiszka@web.de>2010-02-08 05:12:10 -0500
committerDavid S. Miller <davem@davemloft.net>2010-02-16 19:01:20 -0500
commit522530311b35ec8fc4785062441dd2d63967ac55 (patch)
tree072ea48eb722d9aaca75b780485e44bd2ecbbd62
parent88549d6b76346e677da8d2d52b37615df18a4345 (diff)
CAPI: Call a controller 'controller', not 'card'
At least for our internal use, fix the misnomers that refer to a CAPI controller as 'card'. No functional changes. Signed-off-by: Jan Kiszka <jan.kiszka@web.de> Signed-off-by: David S. Miller <davem@davemloft.net>
-rw-r--r--drivers/isdn/capi/kcapi.c320
-rw-r--r--drivers/isdn/capi/kcapi.h8
-rw-r--r--drivers/isdn/capi/kcapi_proc.c17
-rw-r--r--include/linux/isdn/capilli.h2
4 files changed, 178 insertions, 169 deletions
diff --git a/drivers/isdn/capi/kcapi.c b/drivers/isdn/capi/kcapi.c
index ef564ee1c06c..f37c13b4ddc7 100644
--- a/drivers/isdn/capi/kcapi.c
+++ b/drivers/isdn/capi/kcapi.c
@@ -67,24 +67,24 @@ static DEFINE_RWLOCK(application_lock);
67static DEFINE_MUTEX(controller_mutex); 67static DEFINE_MUTEX(controller_mutex);
68 68
69struct capi20_appl *capi_applications[CAPI_MAXAPPL]; 69struct capi20_appl *capi_applications[CAPI_MAXAPPL];
70struct capi_ctr *capi_cards[CAPI_MAXCONTR]; 70struct capi_ctr *capi_controller[CAPI_MAXCONTR];
71 71
72static int ncards; 72static int ncontrollers;
73 73
74/* -------- controller ref counting -------------------------------------- */ 74/* -------- controller ref counting -------------------------------------- */
75 75
76static inline struct capi_ctr * 76static inline struct capi_ctr *
77capi_ctr_get(struct capi_ctr *card) 77capi_ctr_get(struct capi_ctr *ctr)
78{ 78{
79 if (!try_module_get(card->owner)) 79 if (!try_module_get(ctr->owner))
80 return NULL; 80 return NULL;
81 return card; 81 return ctr;
82} 82}
83 83
84static inline void 84static inline void
85capi_ctr_put(struct capi_ctr *card) 85capi_ctr_put(struct capi_ctr *ctr)
86{ 86{
87 module_put(card->owner); 87 module_put(ctr->owner);
88} 88}
89 89
90/* ------------------------------------------------------------- */ 90/* ------------------------------------------------------------- */
@@ -94,7 +94,7 @@ static inline struct capi_ctr *get_capi_ctr_by_nr(u16 contr)
94 if (contr - 1 >= CAPI_MAXCONTR) 94 if (contr - 1 >= CAPI_MAXCONTR)
95 return NULL; 95 return NULL;
96 96
97 return capi_cards[contr - 1]; 97 return capi_controller[contr - 1];
98} 98}
99 99
100static inline struct capi20_appl *get_capi_appl_by_nr(u16 applid) 100static inline struct capi20_appl *get_capi_appl_by_nr(u16 applid)
@@ -144,46 +144,48 @@ static inline int capi_subcmd_valid(u8 subcmd)
144 144
145/* ------------------------------------------------------------ */ 145/* ------------------------------------------------------------ */
146 146
147static void register_appl(struct capi_ctr *card, u16 applid, capi_register_params *rparam) 147static void
148register_appl(struct capi_ctr *ctr, u16 applid, capi_register_params *rparam)
148{ 149{
149 card = capi_ctr_get(card); 150 ctr = capi_ctr_get(ctr);
150 151
151 if (card) 152 if (ctr)
152 card->register_appl(card, applid, rparam); 153 ctr->register_appl(ctr, applid, rparam);
153 else 154 else
154 printk(KERN_WARNING "%s: cannot get card resources\n", __func__); 155 printk(KERN_WARNING "%s: cannot get controller resources\n",
156 __func__);
155} 157}
156 158
157 159
158static void release_appl(struct capi_ctr *card, u16 applid) 160static void release_appl(struct capi_ctr *ctr, u16 applid)
159{ 161{
160 DBG("applid %#x", applid); 162 DBG("applid %#x", applid);
161 163
162 card->release_appl(card, applid); 164 ctr->release_appl(ctr, applid);
163 capi_ctr_put(card); 165 capi_ctr_put(ctr);
164} 166}
165 167
166/* -------- KCI_CONTRUP --------------------------------------- */ 168/* -------- KCI_CONTRUP --------------------------------------- */
167 169
168static void notify_up(u32 contr) 170static void notify_up(u32 contr)
169{ 171{
170 struct capi_ctr *card = get_capi_ctr_by_nr(contr); 172 struct capi_ctr *ctr = get_capi_ctr_by_nr(contr);
171 struct capi20_appl *ap; 173 struct capi20_appl *ap;
172 u16 applid; 174 u16 applid;
173 175
174 if (showcapimsgs & 1) { 176 if (showcapimsgs & 1) {
175 printk(KERN_DEBUG "kcapi: notify up contr %d\n", contr); 177 printk(KERN_DEBUG "kcapi: notify up contr %d\n", contr);
176 } 178 }
177 if (!card) { 179 if (!ctr) {
178 printk(KERN_WARNING "%s: invalid contr %d\n", __func__, contr); 180 printk(KERN_WARNING "%s: invalid contr %d\n", __func__, contr);
179 return; 181 return;
180 } 182 }
181 for (applid = 1; applid <= CAPI_MAXAPPL; applid++) { 183 for (applid = 1; applid <= CAPI_MAXAPPL; applid++) {
182 ap = get_capi_appl_by_nr(applid); 184 ap = get_capi_appl_by_nr(applid);
183 if (!ap || ap->release_in_progress) continue; 185 if (!ap || ap->release_in_progress) continue;
184 register_appl(card, applid, &ap->rparam); 186 register_appl(ctr, applid, &ap->rparam);
185 if (ap->callback && !ap->release_in_progress) 187 if (ap->callback && !ap->release_in_progress)
186 ap->callback(KCI_CONTRUP, contr, &card->profile); 188 ap->callback(KCI_CONTRUP, contr, &ctr->profile);
187 } 189 }
188} 190}
189 191
@@ -269,14 +271,15 @@ static void recv_handler(struct work_struct *work)
269 271
270/** 272/**
271 * capi_ctr_handle_message() - handle incoming CAPI message 273 * capi_ctr_handle_message() - handle incoming CAPI message
272 * @card: controller descriptor structure. 274 * @ctr: controller descriptor structure.
273 * @appl: application ID. 275 * @appl: application ID.
274 * @skb: message. 276 * @skb: message.
275 * 277 *
276 * Called by hardware driver to pass a CAPI message to the application. 278 * Called by hardware driver to pass a CAPI message to the application.
277 */ 279 */
278 280
279void capi_ctr_handle_message(struct capi_ctr * card, u16 appl, struct sk_buff *skb) 281void capi_ctr_handle_message(struct capi_ctr *ctr, u16 appl,
282 struct sk_buff *skb)
280{ 283{
281 struct capi20_appl *ap; 284 struct capi20_appl *ap;
282 int showctl = 0; 285 int showctl = 0;
@@ -284,43 +287,45 @@ void capi_ctr_handle_message(struct capi_ctr * card, u16 appl, struct sk_buff *s
284 unsigned long flags; 287 unsigned long flags;
285 _cdebbuf *cdb; 288 _cdebbuf *cdb;
286 289
287 if (card->cardstate != CARD_RUNNING) { 290 if (ctr->state != CAPI_CTR_RUNNING) {
288 cdb = capi_message2str(skb->data); 291 cdb = capi_message2str(skb->data);
289 if (cdb) { 292 if (cdb) {
290 printk(KERN_INFO "kcapi: controller [%03d] not active, got: %s", 293 printk(KERN_INFO "kcapi: controller [%03d] not active, got: %s",
291 card->cnr, cdb->buf); 294 ctr->cnr, cdb->buf);
292 cdebbuf_free(cdb); 295 cdebbuf_free(cdb);
293 } else 296 } else
294 printk(KERN_INFO "kcapi: controller [%03d] not active, cannot trace\n", 297 printk(KERN_INFO "kcapi: controller [%03d] not active, cannot trace\n",
295 card->cnr); 298 ctr->cnr);
296 goto error; 299 goto error;
297 } 300 }
298 301
299 cmd = CAPIMSG_COMMAND(skb->data); 302 cmd = CAPIMSG_COMMAND(skb->data);
300 subcmd = CAPIMSG_SUBCOMMAND(skb->data); 303 subcmd = CAPIMSG_SUBCOMMAND(skb->data);
301 if (cmd == CAPI_DATA_B3 && subcmd == CAPI_IND) { 304 if (cmd == CAPI_DATA_B3 && subcmd == CAPI_IND) {
302 card->nrecvdatapkt++; 305 ctr->nrecvdatapkt++;
303 if (card->traceflag > 2) showctl |= 2; 306 if (ctr->traceflag > 2)
307 showctl |= 2;
304 } else { 308 } else {
305 card->nrecvctlpkt++; 309 ctr->nrecvctlpkt++;
306 if (card->traceflag) showctl |= 2; 310 if (ctr->traceflag)
311 showctl |= 2;
307 } 312 }
308 showctl |= (card->traceflag & 1); 313 showctl |= (ctr->traceflag & 1);
309 if (showctl & 2) { 314 if (showctl & 2) {
310 if (showctl & 1) { 315 if (showctl & 1) {
311 printk(KERN_DEBUG "kcapi: got [%03d] id#%d %s len=%u\n", 316 printk(KERN_DEBUG "kcapi: got [%03d] id#%d %s len=%u\n",
312 card->cnr, CAPIMSG_APPID(skb->data), 317 ctr->cnr, CAPIMSG_APPID(skb->data),
313 capi_cmd2str(cmd, subcmd), 318 capi_cmd2str(cmd, subcmd),
314 CAPIMSG_LEN(skb->data)); 319 CAPIMSG_LEN(skb->data));
315 } else { 320 } else {
316 cdb = capi_message2str(skb->data); 321 cdb = capi_message2str(skb->data);
317 if (cdb) { 322 if (cdb) {
318 printk(KERN_DEBUG "kcapi: got [%03d] %s\n", 323 printk(KERN_DEBUG "kcapi: got [%03d] %s\n",
319 card->cnr, cdb->buf); 324 ctr->cnr, cdb->buf);
320 cdebbuf_free(cdb); 325 cdebbuf_free(cdb);
321 } else 326 } else
322 printk(KERN_DEBUG "kcapi: got [%03d] id#%d %s len=%u, cannot trace\n", 327 printk(KERN_DEBUG "kcapi: got [%03d] id#%d %s len=%u, cannot trace\n",
323 card->cnr, CAPIMSG_APPID(skb->data), 328 ctr->cnr, CAPIMSG_APPID(skb->data),
324 capi_cmd2str(cmd, subcmd), 329 capi_cmd2str(cmd, subcmd),
325 CAPIMSG_LEN(skb->data)); 330 CAPIMSG_LEN(skb->data));
326 } 331 }
@@ -356,74 +361,75 @@ EXPORT_SYMBOL(capi_ctr_handle_message);
356 361
357/** 362/**
358 * capi_ctr_ready() - signal CAPI controller ready 363 * capi_ctr_ready() - signal CAPI controller ready
359 * @card: controller descriptor structure. 364 * @ctr: controller descriptor structure.
360 * 365 *
361 * Called by hardware driver to signal that the controller is up and running. 366 * Called by hardware driver to signal that the controller is up and running.
362 */ 367 */
363 368
364void capi_ctr_ready(struct capi_ctr * card) 369void capi_ctr_ready(struct capi_ctr *ctr)
365{ 370{
366 card->cardstate = CARD_RUNNING; 371 ctr->state = CAPI_CTR_RUNNING;
367 372
368 printk(KERN_NOTICE "kcapi: card [%03d] \"%s\" ready.\n", 373 printk(KERN_NOTICE "kcapi: controller [%03d] \"%s\" ready.\n",
369 card->cnr, card->name); 374 ctr->cnr, ctr->name);
370 375
371 notify_push(KCI_CONTRUP, card->cnr, 0, 0); 376 notify_push(KCI_CONTRUP, ctr->cnr, 0, 0);
372} 377}
373 378
374EXPORT_SYMBOL(capi_ctr_ready); 379EXPORT_SYMBOL(capi_ctr_ready);
375 380
376/** 381/**
377 * capi_ctr_down() - signal CAPI controller not ready 382 * capi_ctr_down() - signal CAPI controller not ready
378 * @card: controller descriptor structure. 383 * @ctr: controller descriptor structure.
379 * 384 *
380 * Called by hardware driver to signal that the controller is down and 385 * Called by hardware driver to signal that the controller is down and
381 * unavailable for use. 386 * unavailable for use.
382 */ 387 */
383 388
384void capi_ctr_down(struct capi_ctr * card) 389void capi_ctr_down(struct capi_ctr *ctr)
385{ 390{
386 u16 appl; 391 u16 appl;
387 392
388 DBG(""); 393 DBG("");
389 394
390 if (card->cardstate == CARD_DETECTED) 395 if (ctr->state == CAPI_CTR_DETECTED)
391 return; 396 return;
392 397
393 card->cardstate = CARD_DETECTED; 398 ctr->state = CAPI_CTR_DETECTED;
394 399
395 memset(card->manu, 0, sizeof(card->manu)); 400 memset(ctr->manu, 0, sizeof(ctr->manu));
396 memset(&card->version, 0, sizeof(card->version)); 401 memset(&ctr->version, 0, sizeof(ctr->version));
397 memset(&card->profile, 0, sizeof(card->profile)); 402 memset(&ctr->profile, 0, sizeof(ctr->profile));
398 memset(card->serial, 0, sizeof(card->serial)); 403 memset(ctr->serial, 0, sizeof(ctr->serial));
399 404
400 for (appl = 1; appl <= CAPI_MAXAPPL; appl++) { 405 for (appl = 1; appl <= CAPI_MAXAPPL; appl++) {
401 struct capi20_appl *ap = get_capi_appl_by_nr(appl); 406 struct capi20_appl *ap = get_capi_appl_by_nr(appl);
402 if (!ap || ap->release_in_progress) 407 if (!ap || ap->release_in_progress)
403 continue; 408 continue;
404 409
405 capi_ctr_put(card); 410 capi_ctr_put(ctr);
406 } 411 }
407 412
408 printk(KERN_NOTICE "kcapi: card [%03d] down.\n", card->cnr); 413 printk(KERN_NOTICE "kcapi: controller [%03d] down.\n", ctr->cnr);
409 414
410 notify_push(KCI_CONTRDOWN, card->cnr, 0, 0); 415 notify_push(KCI_CONTRDOWN, ctr->cnr, 0, 0);
411} 416}
412 417
413EXPORT_SYMBOL(capi_ctr_down); 418EXPORT_SYMBOL(capi_ctr_down);
414 419
415/** 420/**
416 * capi_ctr_suspend_output() - suspend controller 421 * capi_ctr_suspend_output() - suspend controller
417 * @card: controller descriptor structure. 422 * @ctr: controller descriptor structure.
418 * 423 *
419 * Called by hardware driver to stop data flow. 424 * Called by hardware driver to stop data flow.
420 */ 425 */
421 426
422void capi_ctr_suspend_output(struct capi_ctr *card) 427void capi_ctr_suspend_output(struct capi_ctr *ctr)
423{ 428{
424 if (!card->blocked) { 429 if (!ctr->blocked) {
425 printk(KERN_DEBUG "kcapi: card [%03d] suspend\n", card->cnr); 430 printk(KERN_DEBUG "kcapi: controller [%03d] suspend\n",
426 card->blocked = 1; 431 ctr->cnr);
432 ctr->blocked = 1;
427 } 433 }
428} 434}
429 435
@@ -431,16 +437,17 @@ EXPORT_SYMBOL(capi_ctr_suspend_output);
431 437
432/** 438/**
433 * capi_ctr_resume_output() - resume controller 439 * capi_ctr_resume_output() - resume controller
434 * @card: controller descriptor structure. 440 * @ctr: controller descriptor structure.
435 * 441 *
436 * Called by hardware driver to resume data flow. 442 * Called by hardware driver to resume data flow.
437 */ 443 */
438 444
439void capi_ctr_resume_output(struct capi_ctr *card) 445void capi_ctr_resume_output(struct capi_ctr *ctr)
440{ 446{
441 if (card->blocked) { 447 if (ctr->blocked) {
442 printk(KERN_DEBUG "kcapi: card [%03d] resume\n", card->cnr); 448 printk(KERN_DEBUG "kcapi: controller [%03d] resumed\n",
443 card->blocked = 0; 449 ctr->cnr);
450 ctr->blocked = 0;
444 } 451 }
445} 452}
446 453
@@ -450,21 +457,20 @@ EXPORT_SYMBOL(capi_ctr_resume_output);
450 457
451/** 458/**
452 * attach_capi_ctr() - register CAPI controller 459 * attach_capi_ctr() - register CAPI controller
453 * @card: controller descriptor structure. 460 * @ctr: controller descriptor structure.
454 * 461 *
455 * Called by hardware driver to register a controller with the CAPI subsystem. 462 * Called by hardware driver to register a controller with the CAPI subsystem.
456 * Return value: 0 on success, error code < 0 on error 463 * Return value: 0 on success, error code < 0 on error
457 */ 464 */
458 465
459int 466int attach_capi_ctr(struct capi_ctr *ctr)
460attach_capi_ctr(struct capi_ctr *card)
461{ 467{
462 int i; 468 int i;
463 469
464 mutex_lock(&controller_mutex); 470 mutex_lock(&controller_mutex);
465 471
466 for (i = 0; i < CAPI_MAXCONTR; i++) { 472 for (i = 0; i < CAPI_MAXCONTR; i++) {
467 if (capi_cards[i] == NULL) 473 if (!capi_controller[i])
468 break; 474 break;
469 } 475 }
470 if (i == CAPI_MAXCONTR) { 476 if (i == CAPI_MAXCONTR) {
@@ -472,25 +478,25 @@ attach_capi_ctr(struct capi_ctr *card)
472 printk(KERN_ERR "kcapi: out of controller slots\n"); 478 printk(KERN_ERR "kcapi: out of controller slots\n");
473 return -EBUSY; 479 return -EBUSY;
474 } 480 }
475 capi_cards[i] = card; 481 capi_controller[i] = ctr;
476 482
477 mutex_unlock(&controller_mutex); 483 mutex_unlock(&controller_mutex);
478 484
479 card->nrecvctlpkt = 0; 485 ctr->nrecvctlpkt = 0;
480 card->nrecvdatapkt = 0; 486 ctr->nrecvdatapkt = 0;
481 card->nsentctlpkt = 0; 487 ctr->nsentctlpkt = 0;
482 card->nsentdatapkt = 0; 488 ctr->nsentdatapkt = 0;
483 card->cnr = i + 1; 489 ctr->cnr = i + 1;
484 card->cardstate = CARD_DETECTED; 490 ctr->state = CAPI_CTR_DETECTED;
485 card->blocked = 0; 491 ctr->blocked = 0;
486 card->traceflag = showcapimsgs; 492 ctr->traceflag = showcapimsgs;
487 493
488 sprintf(card->procfn, "capi/controllers/%d", card->cnr); 494 sprintf(ctr->procfn, "capi/controllers/%d", ctr->cnr);
489 card->procent = proc_create_data(card->procfn, 0, NULL, card->proc_fops, card); 495 ctr->procent = proc_create_data(ctr->procfn, 0, NULL, ctr->proc_fops, ctr);
490 496
491 ncards++; 497 ncontrollers++;
492 printk(KERN_NOTICE "kcapi: Controller [%03d]: %s attached\n", 498 printk(KERN_NOTICE "kcapi: controller [%03d]: %s attached\n",
493 card->cnr, card->name); 499 ctr->cnr, ctr->name);
494 return 0; 500 return 0;
495} 501}
496 502
@@ -498,27 +504,27 @@ EXPORT_SYMBOL(attach_capi_ctr);
498 504
499/** 505/**
500 * detach_capi_ctr() - unregister CAPI controller 506 * detach_capi_ctr() - unregister CAPI controller
501 * @card: controller descriptor structure. 507 * @ctr: controller descriptor structure.
502 * 508 *
503 * Called by hardware driver to remove the registration of a controller 509 * Called by hardware driver to remove the registration of a controller
504 * with the CAPI subsystem. 510 * with the CAPI subsystem.
505 * Return value: 0 on success, error code < 0 on error 511 * Return value: 0 on success, error code < 0 on error
506 */ 512 */
507 513
508int detach_capi_ctr(struct capi_ctr *card) 514int detach_capi_ctr(struct capi_ctr *ctr)
509{ 515{
510 if (card->cardstate != CARD_DETECTED) 516 if (ctr->state != CAPI_CTR_DETECTED)
511 capi_ctr_down(card); 517 capi_ctr_down(ctr);
512 518
513 ncards--; 519 ncontrollers--;
514 520
515 if (card->procent) { 521 if (ctr->procent) {
516 remove_proc_entry(card->procfn, NULL); 522 remove_proc_entry(ctr->procfn, NULL);
517 card->procent = NULL; 523 ctr->procent = NULL;
518 } 524 }
519 capi_cards[card->cnr - 1] = NULL; 525 capi_controller[ctr->cnr - 1] = NULL;
520 printk(KERN_NOTICE "kcapi: Controller [%03d]: %s unregistered\n", 526 printk(KERN_NOTICE "kcapi: controller [%03d]: %s unregistered\n",
521 card->cnr, card->name); 527 ctr->cnr, ctr->name);
522 528
523 return 0; 529 return 0;
524} 530}
@@ -576,7 +582,8 @@ u16 capi20_isinstalled(void)
576{ 582{
577 int i; 583 int i;
578 for (i = 0; i < CAPI_MAXCONTR; i++) { 584 for (i = 0; i < CAPI_MAXCONTR; i++) {
579 if (capi_cards[i] && capi_cards[i]->cardstate == CARD_RUNNING) 585 if (capi_controller[i] &&
586 capi_controller[i]->state == CAPI_CTR_RUNNING)
580 return CAPI_NOERROR; 587 return CAPI_NOERROR;
581 } 588 }
582 return CAPI_REGNOTINSTALLED; 589 return CAPI_REGNOTINSTALLED;
@@ -635,9 +642,10 @@ u16 capi20_register(struct capi20_appl *ap)
635 642
636 mutex_lock(&controller_mutex); 643 mutex_lock(&controller_mutex);
637 for (i = 0; i < CAPI_MAXCONTR; i++) { 644 for (i = 0; i < CAPI_MAXCONTR; i++) {
638 if (!capi_cards[i] || capi_cards[i]->cardstate != CARD_RUNNING) 645 if (!capi_controller[i] ||
646 capi_controller[i]->state != CAPI_CTR_RUNNING)
639 continue; 647 continue;
640 register_appl(capi_cards[i], applid, &ap->rparam); 648 register_appl(capi_controller[i], applid, &ap->rparam);
641 } 649 }
642 mutex_unlock(&controller_mutex); 650 mutex_unlock(&controller_mutex);
643 651
@@ -674,9 +682,10 @@ u16 capi20_release(struct capi20_appl *ap)
674 682
675 mutex_lock(&controller_mutex); 683 mutex_lock(&controller_mutex);
676 for (i = 0; i < CAPI_MAXCONTR; i++) { 684 for (i = 0; i < CAPI_MAXCONTR; i++) {
677 if (!capi_cards[i] || capi_cards[i]->cardstate != CARD_RUNNING) 685 if (!capi_controller[i] ||
686 capi_controller[i]->state != CAPI_CTR_RUNNING)
678 continue; 687 continue;
679 release_appl(capi_cards[i], ap->applid); 688 release_appl(capi_controller[i], ap->applid);
680 } 689 }
681 mutex_unlock(&controller_mutex); 690 mutex_unlock(&controller_mutex);
682 691
@@ -703,13 +712,13 @@ EXPORT_SYMBOL(capi20_release);
703 712
704u16 capi20_put_message(struct capi20_appl *ap, struct sk_buff *skb) 713u16 capi20_put_message(struct capi20_appl *ap, struct sk_buff *skb)
705{ 714{
706 struct capi_ctr *card; 715 struct capi_ctr *ctr;
707 int showctl = 0; 716 int showctl = 0;
708 u8 cmd, subcmd; 717 u8 cmd, subcmd;
709 718
710 DBG("applid %#x", ap->applid); 719 DBG("applid %#x", ap->applid);
711 720
712 if (ncards == 0) 721 if (ncontrollers == 0)
713 return CAPI_REGNOTINSTALLED; 722 return CAPI_REGNOTINSTALLED;
714 if ((ap->applid == 0) || ap->release_in_progress) 723 if ((ap->applid == 0) || ap->release_in_progress)
715 return CAPI_ILLAPPNR; 724 return CAPI_ILLAPPNR;
@@ -717,28 +726,30 @@ u16 capi20_put_message(struct capi20_appl *ap, struct sk_buff *skb)
717 || !capi_cmd_valid(CAPIMSG_COMMAND(skb->data)) 726 || !capi_cmd_valid(CAPIMSG_COMMAND(skb->data))
718 || !capi_subcmd_valid(CAPIMSG_SUBCOMMAND(skb->data))) 727 || !capi_subcmd_valid(CAPIMSG_SUBCOMMAND(skb->data)))
719 return CAPI_ILLCMDORSUBCMDORMSGTOSMALL; 728 return CAPI_ILLCMDORSUBCMDORMSGTOSMALL;
720 card = get_capi_ctr_by_nr(CAPIMSG_CONTROLLER(skb->data)); 729 ctr = get_capi_ctr_by_nr(CAPIMSG_CONTROLLER(skb->data));
721 if (!card || card->cardstate != CARD_RUNNING) { 730 if (!ctr || ctr->state != CAPI_CTR_RUNNING) {
722 card = get_capi_ctr_by_nr(1); // XXX why? 731 ctr = get_capi_ctr_by_nr(1); /* XXX why? */
723 if (!card || card->cardstate != CARD_RUNNING) 732 if (!ctr || ctr->state != CAPI_CTR_RUNNING)
724 return CAPI_REGNOTINSTALLED; 733 return CAPI_REGNOTINSTALLED;
725 } 734 }
726 if (card->blocked) 735 if (ctr->blocked)
727 return CAPI_SENDQUEUEFULL; 736 return CAPI_SENDQUEUEFULL;
728 737
729 cmd = CAPIMSG_COMMAND(skb->data); 738 cmd = CAPIMSG_COMMAND(skb->data);
730 subcmd = CAPIMSG_SUBCOMMAND(skb->data); 739 subcmd = CAPIMSG_SUBCOMMAND(skb->data);
731 740
732 if (cmd == CAPI_DATA_B3 && subcmd== CAPI_REQ) { 741 if (cmd == CAPI_DATA_B3 && subcmd== CAPI_REQ) {
733 card->nsentdatapkt++; 742 ctr->nsentdatapkt++;
734 ap->nsentdatapkt++; 743 ap->nsentdatapkt++;
735 if (card->traceflag > 2) showctl |= 2; 744 if (ctr->traceflag > 2)
745 showctl |= 2;
736 } else { 746 } else {
737 card->nsentctlpkt++; 747 ctr->nsentctlpkt++;
738 ap->nsentctlpkt++; 748 ap->nsentctlpkt++;
739 if (card->traceflag) showctl |= 2; 749 if (ctr->traceflag)
750 showctl |= 2;
740 } 751 }
741 showctl |= (card->traceflag & 1); 752 showctl |= (ctr->traceflag & 1);
742 if (showctl & 2) { 753 if (showctl & 2) {
743 if (showctl & 1) { 754 if (showctl & 1) {
744 printk(KERN_DEBUG "kcapi: put [%03d] id#%d %s len=%u\n", 755 printk(KERN_DEBUG "kcapi: put [%03d] id#%d %s len=%u\n",
@@ -761,7 +772,7 @@ u16 capi20_put_message(struct capi20_appl *ap, struct sk_buff *skb)
761 CAPIMSG_LEN(skb->data)); 772 CAPIMSG_LEN(skb->data));
762 } 773 }
763 } 774 }
764 return card->send_message(card, skb); 775 return ctr->send_message(ctr, skb);
765} 776}
766 777
767EXPORT_SYMBOL(capi20_put_message); 778EXPORT_SYMBOL(capi20_put_message);
@@ -778,16 +789,16 @@ EXPORT_SYMBOL(capi20_put_message);
778 789
779u16 capi20_get_manufacturer(u32 contr, u8 *buf) 790u16 capi20_get_manufacturer(u32 contr, u8 *buf)
780{ 791{
781 struct capi_ctr *card; 792 struct capi_ctr *ctr;
782 793
783 if (contr == 0) { 794 if (contr == 0) {
784 strlcpy(buf, capi_manufakturer, CAPI_MANUFACTURER_LEN); 795 strlcpy(buf, capi_manufakturer, CAPI_MANUFACTURER_LEN);
785 return CAPI_NOERROR; 796 return CAPI_NOERROR;
786 } 797 }
787 card = get_capi_ctr_by_nr(contr); 798 ctr = get_capi_ctr_by_nr(contr);
788 if (!card || card->cardstate != CARD_RUNNING) 799 if (!ctr || ctr->state != CAPI_CTR_RUNNING)
789 return CAPI_REGNOTINSTALLED; 800 return CAPI_REGNOTINSTALLED;
790 strlcpy(buf, card->manu, CAPI_MANUFACTURER_LEN); 801 strlcpy(buf, ctr->manu, CAPI_MANUFACTURER_LEN);
791 return CAPI_NOERROR; 802 return CAPI_NOERROR;
792} 803}
793 804
@@ -805,17 +816,17 @@ EXPORT_SYMBOL(capi20_get_manufacturer);
805 816
806u16 capi20_get_version(u32 contr, struct capi_version *verp) 817u16 capi20_get_version(u32 contr, struct capi_version *verp)
807{ 818{
808 struct capi_ctr *card; 819 struct capi_ctr *ctr;
809 820
810 if (contr == 0) { 821 if (contr == 0) {
811 *verp = driver_version; 822 *verp = driver_version;
812 return CAPI_NOERROR; 823 return CAPI_NOERROR;
813 } 824 }
814 card = get_capi_ctr_by_nr(contr); 825 ctr = get_capi_ctr_by_nr(contr);
815 if (!card || card->cardstate != CARD_RUNNING) 826 if (!ctr || ctr->state != CAPI_CTR_RUNNING)
816 return CAPI_REGNOTINSTALLED; 827 return CAPI_REGNOTINSTALLED;
817 828
818 memcpy((void *) verp, &card->version, sizeof(capi_version)); 829 memcpy(verp, &ctr->version, sizeof(capi_version));
819 return CAPI_NOERROR; 830 return CAPI_NOERROR;
820} 831}
821 832
@@ -833,17 +844,17 @@ EXPORT_SYMBOL(capi20_get_version);
833 844
834u16 capi20_get_serial(u32 contr, u8 *serial) 845u16 capi20_get_serial(u32 contr, u8 *serial)
835{ 846{
836 struct capi_ctr *card; 847 struct capi_ctr *ctr;
837 848
838 if (contr == 0) { 849 if (contr == 0) {
839 strlcpy(serial, driver_serial, CAPI_SERIAL_LEN); 850 strlcpy(serial, driver_serial, CAPI_SERIAL_LEN);
840 return CAPI_NOERROR; 851 return CAPI_NOERROR;
841 } 852 }
842 card = get_capi_ctr_by_nr(contr); 853 ctr = get_capi_ctr_by_nr(contr);
843 if (!card || card->cardstate != CARD_RUNNING) 854 if (!ctr || ctr->state != CAPI_CTR_RUNNING)
844 return CAPI_REGNOTINSTALLED; 855 return CAPI_REGNOTINSTALLED;
845 856
846 strlcpy((void *) serial, card->serial, CAPI_SERIAL_LEN); 857 strlcpy(serial, ctr->serial, CAPI_SERIAL_LEN);
847 return CAPI_NOERROR; 858 return CAPI_NOERROR;
848} 859}
849 860
@@ -861,18 +872,17 @@ EXPORT_SYMBOL(capi20_get_serial);
861 872
862u16 capi20_get_profile(u32 contr, struct capi_profile *profp) 873u16 capi20_get_profile(u32 contr, struct capi_profile *profp)
863{ 874{
864 struct capi_ctr *card; 875 struct capi_ctr *ctr;
865 876
866 if (contr == 0) { 877 if (contr == 0) {
867 profp->ncontroller = ncards; 878 profp->ncontroller = ncontrollers;
868 return CAPI_NOERROR; 879 return CAPI_NOERROR;
869 } 880 }
870 card = get_capi_ctr_by_nr(contr); 881 ctr = get_capi_ctr_by_nr(contr);
871 if (!card || card->cardstate != CARD_RUNNING) 882 if (!ctr || ctr->state != CAPI_CTR_RUNNING)
872 return CAPI_REGNOTINSTALLED; 883 return CAPI_REGNOTINSTALLED;
873 884
874 memcpy((void *) profp, &card->profile, 885 memcpy(profp, &ctr->profile, sizeof(struct capi_profile));
875 sizeof(struct capi_profile));
876 return CAPI_NOERROR; 886 return CAPI_NOERROR;
877} 887}
878 888
@@ -885,7 +895,7 @@ static int old_capi_manufacturer(unsigned int cmd, void __user *data)
885 avmb1_extcarddef cdef; 895 avmb1_extcarddef cdef;
886 avmb1_resetdef rdef; 896 avmb1_resetdef rdef;
887 capicardparams cparams; 897 capicardparams cparams;
888 struct capi_ctr *card; 898 struct capi_ctr *ctr;
889 struct capi_driver *driver = NULL; 899 struct capi_driver *driver = NULL;
890 capiloaddata ldata; 900 capiloaddata ldata;
891 struct list_head *l; 901 struct list_head *l;
@@ -958,26 +968,26 @@ static int old_capi_manufacturer(unsigned int cmd, void __user *data)
958 sizeof(avmb1_loadandconfigdef))) 968 sizeof(avmb1_loadandconfigdef)))
959 return -EFAULT; 969 return -EFAULT;
960 } 970 }
961 card = get_capi_ctr_by_nr(ldef.contr); 971 ctr = get_capi_ctr_by_nr(ldef.contr);
962 if (!card) 972 if (!ctr)
963 return -EINVAL; 973 return -EINVAL;
964 card = capi_ctr_get(card); 974 ctr = capi_ctr_get(ctr);
965 if (!card) 975 if (!ctr)
966 return -ESRCH; 976 return -ESRCH;
967 if (card->load_firmware == NULL) { 977 if (ctr->load_firmware == NULL) {
968 printk(KERN_DEBUG "kcapi: load: no load function\n"); 978 printk(KERN_DEBUG "kcapi: load: no load function\n");
969 capi_ctr_put(card); 979 capi_ctr_put(ctr);
970 return -ESRCH; 980 return -ESRCH;
971 } 981 }
972 982
973 if (ldef.t4file.len <= 0) { 983 if (ldef.t4file.len <= 0) {
974 printk(KERN_DEBUG "kcapi: load: invalid parameter: length of t4file is %d ?\n", ldef.t4file.len); 984 printk(KERN_DEBUG "kcapi: load: invalid parameter: length of t4file is %d ?\n", ldef.t4file.len);
975 capi_ctr_put(card); 985 capi_ctr_put(ctr);
976 return -EINVAL; 986 return -EINVAL;
977 } 987 }
978 if (ldef.t4file.data == NULL) { 988 if (ldef.t4file.data == NULL) {
979 printk(KERN_DEBUG "kcapi: load: invalid parameter: dataptr is 0\n"); 989 printk(KERN_DEBUG "kcapi: load: invalid parameter: dataptr is 0\n");
980 capi_ctr_put(card); 990 capi_ctr_put(ctr);
981 return -EINVAL; 991 return -EINVAL;
982 } 992 }
983 993
@@ -988,46 +998,46 @@ static int old_capi_manufacturer(unsigned int cmd, void __user *data)
988 ldata.configuration.data = ldef.t4config.data; 998 ldata.configuration.data = ldef.t4config.data;
989 ldata.configuration.len = ldef.t4config.len; 999 ldata.configuration.len = ldef.t4config.len;
990 1000
991 if (card->cardstate != CARD_DETECTED) { 1001 if (ctr->state != CAPI_CTR_DETECTED) {
992 printk(KERN_INFO "kcapi: load: contr=%d not in detect state\n", ldef.contr); 1002 printk(KERN_INFO "kcapi: load: contr=%d not in detect state\n", ldef.contr);
993 capi_ctr_put(card); 1003 capi_ctr_put(ctr);
994 return -EBUSY; 1004 return -EBUSY;
995 } 1005 }
996 card->cardstate = CARD_LOADING; 1006 ctr->state = CAPI_CTR_LOADING;
997 1007
998 retval = card->load_firmware(card, &ldata); 1008 retval = ctr->load_firmware(ctr, &ldata);
999 1009
1000 if (retval) { 1010 if (retval) {
1001 card->cardstate = CARD_DETECTED; 1011 ctr->state = CAPI_CTR_DETECTED;
1002 capi_ctr_put(card); 1012 capi_ctr_put(ctr);
1003 return retval; 1013 return retval;
1004 } 1014 }
1005 1015
1006 while (card->cardstate != CARD_RUNNING) { 1016 while (ctr->state != CAPI_CTR_RUNNING) {
1007 1017
1008 msleep_interruptible(100); /* 0.1 sec */ 1018 msleep_interruptible(100); /* 0.1 sec */
1009 1019
1010 if (signal_pending(current)) { 1020 if (signal_pending(current)) {
1011 capi_ctr_put(card); 1021 capi_ctr_put(ctr);
1012 return -EINTR; 1022 return -EINTR;
1013 } 1023 }
1014 } 1024 }
1015 capi_ctr_put(card); 1025 capi_ctr_put(ctr);
1016 return 0; 1026 return 0;
1017 1027
1018 case AVMB1_RESETCARD: 1028 case AVMB1_RESETCARD:
1019 if (copy_from_user(&rdef, data, sizeof(avmb1_resetdef))) 1029 if (copy_from_user(&rdef, data, sizeof(avmb1_resetdef)))
1020 return -EFAULT; 1030 return -EFAULT;
1021 card = get_capi_ctr_by_nr(rdef.contr); 1031 ctr = get_capi_ctr_by_nr(rdef.contr);
1022 if (!card) 1032 if (!ctr)
1023 return -ESRCH; 1033 return -ESRCH;
1024 1034
1025 if (card->cardstate == CARD_DETECTED) 1035 if (ctr->state == CAPI_CTR_DETECTED)
1026 return 0; 1036 return 0;
1027 1037
1028 card->reset_ctr(card); 1038 ctr->reset_ctr(ctr);
1029 1039
1030 while (card->cardstate > CARD_DETECTED) { 1040 while (ctr->state > CAPI_CTR_DETECTED) {
1031 1041
1032 msleep_interruptible(100); /* 0.1 sec */ 1042 msleep_interruptible(100); /* 0.1 sec */
1033 1043
@@ -1052,7 +1062,7 @@ static int old_capi_manufacturer(unsigned int cmd, void __user *data)
1052 1062
1053int capi20_manufacturer(unsigned int cmd, void __user *data) 1063int capi20_manufacturer(unsigned int cmd, void __user *data)
1054{ 1064{
1055 struct capi_ctr *card; 1065 struct capi_ctr *ctr;
1056 1066
1057 switch (cmd) { 1067 switch (cmd) {
1058#ifdef AVMB1_COMPAT 1068#ifdef AVMB1_COMPAT
@@ -1070,13 +1080,13 @@ int capi20_manufacturer(unsigned int cmd, void __user *data)
1070 if (copy_from_user(&fdef, data, sizeof(kcapi_flagdef))) 1080 if (copy_from_user(&fdef, data, sizeof(kcapi_flagdef)))
1071 return -EFAULT; 1081 return -EFAULT;
1072 1082
1073 card = get_capi_ctr_by_nr(fdef.contr); 1083 ctr = get_capi_ctr_by_nr(fdef.contr);
1074 if (!card) 1084 if (!ctr)
1075 return -ESRCH; 1085 return -ESRCH;
1076 1086
1077 card->traceflag = fdef.flag; 1087 ctr->traceflag = fdef.flag;
1078 printk(KERN_INFO "kcapi: contr [%03d] set trace=%d\n", 1088 printk(KERN_INFO "kcapi: contr [%03d] set trace=%d\n",
1079 card->cnr, card->traceflag); 1089 ctr->cnr, ctr->traceflag);
1080 return 0; 1090 return 0;
1081 } 1091 }
1082 case KCAPI_CMD_ADDCARD: 1092 case KCAPI_CMD_ADDCARD:
diff --git a/drivers/isdn/capi/kcapi.h b/drivers/isdn/capi/kcapi.h
index 244711f7f838..f62c53bd6a97 100644
--- a/drivers/isdn/capi/kcapi.h
+++ b/drivers/isdn/capi/kcapi.h
@@ -24,16 +24,16 @@ printk(KERN_DEBUG "%s: " format "\n" , __func__ , ## arg); \
24#endif 24#endif
25 25
26enum { 26enum {
27 CARD_DETECTED = 1, 27 CAPI_CTR_DETECTED = 1,
28 CARD_LOADING = 2, 28 CAPI_CTR_LOADING = 2,
29 CARD_RUNNING = 3, 29 CAPI_CTR_RUNNING = 3,
30}; 30};
31 31
32extern struct list_head capi_drivers; 32extern struct list_head capi_drivers;
33extern rwlock_t capi_drivers_list_lock; 33extern rwlock_t capi_drivers_list_lock;
34 34
35extern struct capi20_appl *capi_applications[CAPI_MAXAPPL]; 35extern struct capi20_appl *capi_applications[CAPI_MAXAPPL];
36extern struct capi_ctr *capi_cards[CAPI_MAXCONTR]; 36extern struct capi_ctr *capi_controller[CAPI_MAXCONTR];
37 37
38#ifdef CONFIG_PROC_FS 38#ifdef CONFIG_PROC_FS
39 39
diff --git a/drivers/isdn/capi/kcapi_proc.c b/drivers/isdn/capi/kcapi_proc.c
index 09d4db764d22..59fd16a4ad8e 100644
--- a/drivers/isdn/capi/kcapi_proc.c
+++ b/drivers/isdn/capi/kcapi_proc.c
@@ -15,13 +15,12 @@
15#include <linux/seq_file.h> 15#include <linux/seq_file.h>
16#include <linux/init.h> 16#include <linux/init.h>
17 17
18static char * 18static char *state2str(unsigned short state)
19cardstate2str(unsigned short cardstate)
20{ 19{
21 switch (cardstate) { 20 switch (state) {
22 case CARD_DETECTED: return "detected"; 21 case CAPI_CTR_DETECTED: return "detected";
23 case CARD_LOADING: return "loading"; 22 case CAPI_CTR_LOADING: return "loading";
24 case CARD_RUNNING: return "running"; 23 case CAPI_CTR_RUNNING: return "running";
25 default: return "???"; 24 default: return "???";
26 } 25 }
27} 26}
@@ -38,7 +37,7 @@ cardstate2str(unsigned short cardstate)
38static void *controller_start(struct seq_file *seq, loff_t *pos) 37static void *controller_start(struct seq_file *seq, loff_t *pos)
39{ 38{
40 if (*pos < CAPI_MAXCONTR) 39 if (*pos < CAPI_MAXCONTR)
41 return &capi_cards[*pos]; 40 return &capi_controller[*pos];
42 41
43 return NULL; 42 return NULL;
44} 43}
@@ -47,7 +46,7 @@ static void *controller_next(struct seq_file *seq, void *v, loff_t *pos)
47{ 46{
48 ++*pos; 47 ++*pos;
49 if (*pos < CAPI_MAXCONTR) 48 if (*pos < CAPI_MAXCONTR)
50 return &capi_cards[*pos]; 49 return &capi_controller[*pos];
51 50
52 return NULL; 51 return NULL;
53} 52}
@@ -65,7 +64,7 @@ static int controller_show(struct seq_file *seq, void *v)
65 64
66 seq_printf(seq, "%d %-10s %-8s %-16s %s\n", 65 seq_printf(seq, "%d %-10s %-8s %-16s %s\n",
67 ctr->cnr, ctr->driver_name, 66 ctr->cnr, ctr->driver_name,
68 cardstate2str(ctr->cardstate), 67 state2str(ctr->state),
69 ctr->name, 68 ctr->name,
70 ctr->procinfo ? ctr->procinfo(ctr) : ""); 69 ctr->procinfo ? ctr->procinfo(ctr) : "");
71 70
diff --git a/include/linux/isdn/capilli.h b/include/linux/isdn/capilli.h
index d3e5e9da0c82..856f38eddd78 100644
--- a/include/linux/isdn/capilli.h
+++ b/include/linux/isdn/capilli.h
@@ -66,7 +66,7 @@ struct capi_ctr {
66 unsigned long nsentdatapkt; 66 unsigned long nsentdatapkt;
67 67
68 int cnr; /* controller number */ 68 int cnr; /* controller number */
69 volatile unsigned short cardstate; /* controller state */ 69 volatile unsigned short state; /* controller state */
70 volatile int blocked; /* output blocked */ 70 volatile int blocked; /* output blocked */
71 int traceflag; /* capi trace */ 71 int traceflag; /* capi trace */
72 72