aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/isdn/isdnloop
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/isdn/isdnloop')
-rw-r--r--drivers/isdn/isdnloop/isdnloop.c64
1 files changed, 30 insertions, 34 deletions
diff --git a/drivers/isdn/isdnloop/isdnloop.c b/drivers/isdn/isdnloop/isdnloop.c
index 5a4da94aefb0..ef9c8e4f1fa2 100644
--- a/drivers/isdn/isdnloop/isdnloop.c
+++ b/drivers/isdn/isdnloop/isdnloop.c
@@ -59,7 +59,8 @@ isdnloop_bchan_send(isdnloop_card *card, int ch)
59 isdn_ctrl cmd; 59 isdn_ctrl cmd;
60 60
61 while (card->sndcount[ch]) { 61 while (card->sndcount[ch]) {
62 if ((skb = skb_dequeue(&card->bqueue[ch]))) { 62 skb = skb_dequeue(&card->bqueue[ch]);
63 if (skb) {
63 len = skb->len; 64 len = skb->len;
64 card->sndcount[ch] -= len; 65 card->sndcount[ch] -= len;
65 ack = *(skb->head); /* used as scratch area */ 66 ack = *(skb->head); /* used as scratch area */
@@ -149,8 +150,7 @@ typedef struct isdnloop_stat {
149 int action; 150 int action;
150} isdnloop_stat; 151} isdnloop_stat;
151/* *INDENT-OFF* */ 152/* *INDENT-OFF* */
152static isdnloop_stat isdnloop_stat_table[] = 153static isdnloop_stat isdnloop_stat_table[] = {
153{
154 {"BCON_", ISDN_STAT_BCONN, 1}, /* B-Channel connected */ 154 {"BCON_", ISDN_STAT_BCONN, 1}, /* B-Channel connected */
155 {"BDIS_", ISDN_STAT_BHUP, 2}, /* B-Channel disconnected */ 155 {"BDIS_", ISDN_STAT_BHUP, 2}, /* B-Channel disconnected */
156 {"DCON_", ISDN_STAT_DCONN, 0}, /* D-Channel connected */ 156 {"DCON_", ISDN_STAT_DCONN, 0}, /* D-Channel connected */
@@ -317,7 +317,8 @@ isdnloop_polldchan(unsigned long data)
317 u_char *p; 317 u_char *p;
318 isdn_ctrl cmd; 318 isdn_ctrl cmd;
319 319
320 if ((skb = skb_dequeue(&card->dqueue))) 320 skb = skb_dequeue(&card->dqueue);
321 if (skb)
321 avail = skb->len; 322 avail = skb->len;
322 else 323 else
323 avail = 0; 324 avail = 0;
@@ -471,8 +472,8 @@ isdnloop_fake(isdnloop_card *card, char *s, int ch)
471{ 472{
472 struct sk_buff *skb; 473 struct sk_buff *skb;
473 int len = strlen(s) + ((ch >= 0) ? 3 : 0); 474 int len = strlen(s) + ((ch >= 0) ? 3 : 0);
474 475 skb = dev_alloc_skb(len);
475 if (!(skb = dev_alloc_skb(len))) { 476 if (!skb) {
476 printk(KERN_WARNING "isdnloop: Out of memory in isdnloop_fake\n"); 477 printk(KERN_WARNING "isdnloop: Out of memory in isdnloop_fake\n");
477 return 1; 478 return 1;
478 } 479 }
@@ -483,8 +484,7 @@ isdnloop_fake(isdnloop_card *card, char *s, int ch)
483 return 0; 484 return 0;
484} 485}
485/* *INDENT-OFF* */ 486/* *INDENT-OFF* */
486static isdnloop_stat isdnloop_cmd_table[] = 487static isdnloop_stat isdnloop_cmd_table[] = {
487{
488 {"BCON_R", 0, 1}, /* B-Channel connect */ 488 {"BCON_R", 0, 1}, /* B-Channel connect */
489 {"BCON_I", 0, 17}, /* B-Channel connect ind */ 489 {"BCON_I", 0, 17}, /* B-Channel connect ind */
490 {"BDIS_R", 0, 2}, /* B-Channel disconnect */ 490 {"BDIS_R", 0, 2}, /* B-Channel disconnect */
@@ -525,10 +525,8 @@ isdnloop_fake_err(isdnloop_card *card)
525 isdnloop_fake(card, "NAK", -1); 525 isdnloop_fake(card, "NAK", -1);
526} 526}
527 527
528static u_char ctable_eu[] = 528static u_char ctable_eu[] = {0x00, 0x11, 0x01, 0x12};
529{0x00, 0x11, 0x01, 0x12}; 529static u_char ctable_1t[] = {0x00, 0x3b, 0x01, 0x3a};
530static u_char ctable_1t[] =
531{0x00, 0x3b, 0x01, 0x3a};
532 530
533/* 531/*
534 * Assemble a simplified cause message depending on the 532 * Assemble a simplified cause message depending on the
@@ -554,9 +552,9 @@ isdnloop_unicause(isdnloop_card *card, int loc, int cau)
554 sprintf(buf, "%02X44", ctable_1t[cau]); 552 sprintf(buf, "%02X44", ctable_1t[cau]);
555 break; 553 break;
556 default: 554 default:
557 return ("0000"); 555 return "0000";
558 } 556 }
559 return (buf); 557 return buf;
560} 558}
561 559
562/* 560/*
@@ -647,10 +645,8 @@ isdnloop_kill_ctimer(isdnloop_card *card, int ch)
647 spin_unlock_irqrestore(&card->isdnloop_lock, flags); 645 spin_unlock_irqrestore(&card->isdnloop_lock, flags);
648} 646}
649 647
650static u_char si2bit[] = 648static u_char si2bit[] = {0, 1, 0, 0, 0, 2, 0, 4, 0, 0};
651{0, 1, 0, 0, 0, 2, 0, 4, 0, 0}; 649static u_char bit2si[] = {1, 5, 7};
652static u_char bit2si[] =
653{1, 5, 7};
654 650
655/* 651/*
656 * Try finding a listener for an outgoing call. 652 * Try finding a listener for an outgoing call.
@@ -754,17 +750,17 @@ isdnloop_vstphone(isdnloop_card *card, char *phone, int caller)
754 if (caller) { 750 if (caller) {
755 for (i = 0; i < 2; i++) 751 for (i = 0; i < 2; i++)
756 if (!(strcmp(card->s0num[i], phone))) 752 if (!(strcmp(card->s0num[i], phone)))
757 return (phone); 753 return phone;
758 return (card->s0num[0]); 754 return card->s0num[0];
759 } 755 }
760 return (phone); 756 return phone;
761 break; 757 break;
762 case ISDN_PTYPE_1TR6: 758 case ISDN_PTYPE_1TR6:
763 if (caller) { 759 if (caller) {
764 sprintf(nphone, "%s%c", card->s0num[0], phone[0]); 760 sprintf(nphone, "%s%c", card->s0num[0], phone[0]);
765 return (nphone); 761 return nphone;
766 } else 762 } else
767 return (&phone[strlen(phone) - 1]); 763 return &phone[strlen(phone) - 1];
768 break; 764 break;
769 } 765 }
770 return ""; 766 return "";
@@ -1148,14 +1144,14 @@ isdnloop_command(isdn_ctrl *c, isdnloop_card *card)
1148 case ISDNLOOP_IOCTL_STARTUP: 1144 case ISDNLOOP_IOCTL_STARTUP:
1149 if (!access_ok(VERIFY_READ, (void *) a, sizeof(isdnloop_sdef))) 1145 if (!access_ok(VERIFY_READ, (void *) a, sizeof(isdnloop_sdef)))
1150 return -EFAULT; 1146 return -EFAULT;
1151 return (isdnloop_start(card, (isdnloop_sdef *) a)); 1147 return isdnloop_start(card, (isdnloop_sdef *) a);
1152 break; 1148 break;
1153 case ISDNLOOP_IOCTL_ADDCARD: 1149 case ISDNLOOP_IOCTL_ADDCARD:
1154 if (copy_from_user((char *)&cdef, 1150 if (copy_from_user((char *)&cdef,
1155 (char *)a, 1151 (char *)a,
1156 sizeof(cdef))) 1152 sizeof(cdef)))
1157 return -EFAULT; 1153 return -EFAULT;
1158 return (isdnloop_addcard(cdef.id1)); 1154 return isdnloop_addcard(cdef.id1);
1159 break; 1155 break;
1160 case ISDNLOOP_IOCTL_LEASEDCFG: 1156 case ISDNLOOP_IOCTL_LEASEDCFG:
1161 if (a) { 1157 if (a) {
@@ -1377,7 +1373,7 @@ if_command(isdn_ctrl *c)
1377 isdnloop_card *card = isdnloop_findcard(c->driver); 1373 isdnloop_card *card = isdnloop_findcard(c->driver);
1378 1374
1379 if (card) 1375 if (card)
1380 return (isdnloop_command(c, card)); 1376 return isdnloop_command(c, card);
1381 printk(KERN_ERR 1377 printk(KERN_ERR
1382 "isdnloop: if_command called with invalid driverId!\n"); 1378 "isdnloop: if_command called with invalid driverId!\n");
1383 return -ENODEV; 1379 return -ENODEV;
@@ -1391,7 +1387,7 @@ if_writecmd(const u_char __user *buf, int len, int id, int channel)
1391 if (card) { 1387 if (card) {
1392 if (!(card->flags & ISDNLOOP_FLAGS_RUNNING)) 1388 if (!(card->flags & ISDNLOOP_FLAGS_RUNNING))
1393 return -ENODEV; 1389 return -ENODEV;
1394 return (isdnloop_writecmd(buf, len, 1, card)); 1390 return isdnloop_writecmd(buf, len, 1, card);
1395 } 1391 }
1396 printk(KERN_ERR 1392 printk(KERN_ERR
1397 "isdnloop: if_writecmd called with invalid driverId!\n"); 1393 "isdnloop: if_writecmd called with invalid driverId!\n");
@@ -1406,7 +1402,7 @@ if_readstatus(u_char __user *buf, int len, int id, int channel)
1406 if (card) { 1402 if (card) {
1407 if (!(card->flags & ISDNLOOP_FLAGS_RUNNING)) 1403 if (!(card->flags & ISDNLOOP_FLAGS_RUNNING))
1408 return -ENODEV; 1404 return -ENODEV;
1409 return (isdnloop_readstatus(buf, len, card)); 1405 return isdnloop_readstatus(buf, len, card);
1410 } 1406 }
1411 printk(KERN_ERR 1407 printk(KERN_ERR
1412 "isdnloop: if_readstatus called with invalid driverId!\n"); 1408 "isdnloop: if_readstatus called with invalid driverId!\n");
@@ -1423,7 +1419,7 @@ if_sendbuf(int id, int channel, int ack, struct sk_buff *skb)
1423 return -ENODEV; 1419 return -ENODEV;
1424 /* ack request stored in skb scratch area */ 1420 /* ack request stored in skb scratch area */
1425 *(skb->head) = ack; 1421 *(skb->head) = ack;
1426 return (isdnloop_sendbuf(channel, skb, card)); 1422 return isdnloop_sendbuf(channel, skb, card);
1427 } 1423 }
1428 printk(KERN_ERR 1424 printk(KERN_ERR
1429 "isdnloop: if_sendbuf called with invalid driverId!\n"); 1425 "isdnloop: if_sendbuf called with invalid driverId!\n");
@@ -1439,8 +1435,8 @@ isdnloop_initcard(char *id)
1439{ 1435{
1440 isdnloop_card *card; 1436 isdnloop_card *card;
1441 int i; 1437 int i;
1442 1438 card = kzalloc(sizeof(isdnloop_card), GFP_KERNEL);
1443 if (!(card = kzalloc(sizeof(isdnloop_card), GFP_KERNEL))) { 1439 if (!card) {
1444 printk(KERN_WARNING 1440 printk(KERN_WARNING
1445 "isdnloop: (%s) Could not allocate card-struct.\n", id); 1441 "isdnloop: (%s) Could not allocate card-struct.\n", id);
1446 return (isdnloop_card *) 0; 1442 return (isdnloop_card *) 0;
@@ -1489,8 +1485,8 @@ static int
1489isdnloop_addcard(char *id1) 1485isdnloop_addcard(char *id1)
1490{ 1486{
1491 isdnloop_card *card; 1487 isdnloop_card *card;
1492 1488 card = isdnloop_initcard(id1);
1493 if (!(card = isdnloop_initcard(id1))) { 1489 if (!card) {
1494 return -EIO; 1490 return -EIO;
1495 } 1491 }
1496 printk(KERN_INFO 1492 printk(KERN_INFO
@@ -1503,7 +1499,7 @@ static int __init
1503isdnloop_init(void) 1499isdnloop_init(void)
1504{ 1500{
1505 if (isdnloop_id) 1501 if (isdnloop_id)
1506 return (isdnloop_addcard(isdnloop_id)); 1502 return isdnloop_addcard(isdnloop_id);
1507 1503
1508 return 0; 1504 return 0;
1509} 1505}