diff options
Diffstat (limited to 'drivers/isdn/capi/capi.c')
-rw-r--r-- | drivers/isdn/capi/capi.c | 139 |
1 files changed, 36 insertions, 103 deletions
diff --git a/drivers/isdn/capi/capi.c b/drivers/isdn/capi/capi.c index 0d7088367038..e44933d58790 100644 --- a/drivers/isdn/capi/capi.c +++ b/drivers/isdn/capi/capi.c | |||
@@ -38,15 +38,10 @@ | |||
38 | #include <linux/isdn/capiutil.h> | 38 | #include <linux/isdn/capiutil.h> |
39 | #include <linux/isdn/capicmd.h> | 39 | #include <linux/isdn/capicmd.h> |
40 | 40 | ||
41 | #include "capifs.h" | ||
42 | |||
43 | MODULE_DESCRIPTION("CAPI4Linux: Userspace /dev/capi20 interface"); | 41 | MODULE_DESCRIPTION("CAPI4Linux: Userspace /dev/capi20 interface"); |
44 | MODULE_AUTHOR("Carsten Paeth"); | 42 | MODULE_AUTHOR("Carsten Paeth"); |
45 | MODULE_LICENSE("GPL"); | 43 | MODULE_LICENSE("GPL"); |
46 | 44 | ||
47 | #undef _DEBUG_TTYFUNCS /* call to tty_driver */ | ||
48 | #undef _DEBUG_DATAFLOW /* data flow */ | ||
49 | |||
50 | /* -------- driver information -------------------------------------- */ | 45 | /* -------- driver information -------------------------------------- */ |
51 | 46 | ||
52 | static DEFINE_MUTEX(capi_mutex); | 47 | static DEFINE_MUTEX(capi_mutex); |
@@ -85,7 +80,6 @@ struct capiminor { | |||
85 | struct kref kref; | 80 | struct kref kref; |
86 | 81 | ||
87 | unsigned int minor; | 82 | unsigned int minor; |
88 | struct dentry *capifs_dentry; | ||
89 | 83 | ||
90 | struct capi20_appl *ap; | 84 | struct capi20_appl *ap; |
91 | u32 ncci; | 85 | u32 ncci; |
@@ -300,17 +294,8 @@ static void capiminor_free(struct capiminor *mp) | |||
300 | 294 | ||
301 | static void capincci_alloc_minor(struct capidev *cdev, struct capincci *np) | 295 | static void capincci_alloc_minor(struct capidev *cdev, struct capincci *np) |
302 | { | 296 | { |
303 | struct capiminor *mp; | 297 | if (cdev->userflags & CAPIFLAG_HIGHJACKING) |
304 | dev_t device; | 298 | np->minorp = capiminor_alloc(&cdev->ap, np->ncci); |
305 | |||
306 | if (!(cdev->userflags & CAPIFLAG_HIGHJACKING)) | ||
307 | return; | ||
308 | |||
309 | mp = np->minorp = capiminor_alloc(&cdev->ap, np->ncci); | ||
310 | if (mp) { | ||
311 | device = MKDEV(capinc_tty_driver->major, mp->minor); | ||
312 | mp->capifs_dentry = capifs_new_ncci(mp->minor, device); | ||
313 | } | ||
314 | } | 299 | } |
315 | 300 | ||
316 | static void capincci_free_minor(struct capincci *np) | 301 | static void capincci_free_minor(struct capincci *np) |
@@ -319,8 +304,6 @@ static void capincci_free_minor(struct capincci *np) | |||
319 | struct tty_struct *tty; | 304 | struct tty_struct *tty; |
320 | 305 | ||
321 | if (mp) { | 306 | if (mp) { |
322 | capifs_free_ncci(mp->capifs_dentry); | ||
323 | |||
324 | tty = tty_port_tty_get(&mp->port); | 307 | tty = tty_port_tty_get(&mp->port); |
325 | if (tty) { | 308 | if (tty) { |
326 | tty_vhangup(tty); | 309 | tty_vhangup(tty); |
@@ -432,9 +415,7 @@ static int handle_recv_skb(struct capiminor *mp, struct sk_buff *skb) | |||
432 | 415 | ||
433 | tty = tty_port_tty_get(&mp->port); | 416 | tty = tty_port_tty_get(&mp->port); |
434 | if (!tty) { | 417 | if (!tty) { |
435 | #ifdef _DEBUG_DATAFLOW | 418 | pr_debug("capi: currently no receiver\n"); |
436 | printk(KERN_DEBUG "capi: currently no receiver\n"); | ||
437 | #endif | ||
438 | return -1; | 419 | return -1; |
439 | } | 420 | } |
440 | 421 | ||
@@ -447,23 +428,17 @@ static int handle_recv_skb(struct capiminor *mp, struct sk_buff *skb) | |||
447 | } | 428 | } |
448 | 429 | ||
449 | if (ld->ops->receive_buf == NULL) { | 430 | if (ld->ops->receive_buf == NULL) { |
450 | #if defined(_DEBUG_DATAFLOW) || defined(_DEBUG_TTYFUNCS) | 431 | pr_debug("capi: ldisc has no receive_buf function\n"); |
451 | printk(KERN_DEBUG "capi: ldisc has no receive_buf function\n"); | ||
452 | #endif | ||
453 | /* fatal error, do not requeue */ | 432 | /* fatal error, do not requeue */ |
454 | goto free_skb; | 433 | goto free_skb; |
455 | } | 434 | } |
456 | if (mp->ttyinstop) { | 435 | if (mp->ttyinstop) { |
457 | #if defined(_DEBUG_DATAFLOW) || defined(_DEBUG_TTYFUNCS) | 436 | pr_debug("capi: recv tty throttled\n"); |
458 | printk(KERN_DEBUG "capi: recv tty throttled\n"); | ||
459 | #endif | ||
460 | goto deref_ldisc; | 437 | goto deref_ldisc; |
461 | } | 438 | } |
462 | 439 | ||
463 | if (tty->receive_room < datalen) { | 440 | if (tty->receive_room < datalen) { |
464 | #if defined(_DEBUG_DATAFLOW) || defined(_DEBUG_TTYFUNCS) | 441 | pr_debug("capi: no room in tty\n"); |
465 | printk(KERN_DEBUG "capi: no room in tty\n"); | ||
466 | #endif | ||
467 | goto deref_ldisc; | 442 | goto deref_ldisc; |
468 | } | 443 | } |
469 | 444 | ||
@@ -479,10 +454,8 @@ static int handle_recv_skb(struct capiminor *mp, struct sk_buff *skb) | |||
479 | 454 | ||
480 | if (errcode == CAPI_NOERROR) { | 455 | if (errcode == CAPI_NOERROR) { |
481 | skb_pull(skb, CAPIMSG_LEN(skb->data)); | 456 | skb_pull(skb, CAPIMSG_LEN(skb->data)); |
482 | #ifdef _DEBUG_DATAFLOW | 457 | pr_debug("capi: DATA_B3_RESP %u len=%d => ldisc\n", |
483 | printk(KERN_DEBUG "capi: DATA_B3_RESP %u len=%d => ldisc\n", | 458 | datahandle, skb->len); |
484 | datahandle, skb->len); | ||
485 | #endif | ||
486 | ld->ops->receive_buf(tty, skb->data, NULL, skb->len); | 459 | ld->ops->receive_buf(tty, skb->data, NULL, skb->len); |
487 | } else { | 460 | } else { |
488 | printk(KERN_ERR "capi: send DATA_B3_RESP failed=%x\n", | 461 | printk(KERN_ERR "capi: send DATA_B3_RESP failed=%x\n", |
@@ -529,9 +502,7 @@ static void handle_minor_send(struct capiminor *mp) | |||
529 | return; | 502 | return; |
530 | 503 | ||
531 | if (mp->ttyoutstop) { | 504 | if (mp->ttyoutstop) { |
532 | #if defined(_DEBUG_DATAFLOW) || defined(_DEBUG_TTYFUNCS) | 505 | pr_debug("capi: send: tty stopped\n"); |
533 | printk(KERN_DEBUG "capi: send: tty stopped\n"); | ||
534 | #endif | ||
535 | tty_kref_put(tty); | 506 | tty_kref_put(tty); |
536 | return; | 507 | return; |
537 | } | 508 | } |
@@ -573,10 +544,8 @@ static void handle_minor_send(struct capiminor *mp) | |||
573 | } | 544 | } |
574 | errcode = capi20_put_message(mp->ap, skb); | 545 | errcode = capi20_put_message(mp->ap, skb); |
575 | if (errcode == CAPI_NOERROR) { | 546 | if (errcode == CAPI_NOERROR) { |
576 | #ifdef _DEBUG_DATAFLOW | 547 | pr_debug("capi: DATA_B3_REQ %u len=%u\n", |
577 | printk(KERN_DEBUG "capi: DATA_B3_REQ %u len=%u\n", | 548 | datahandle, len); |
578 | datahandle, len); | ||
579 | #endif | ||
580 | continue; | 549 | continue; |
581 | } | 550 | } |
582 | capiminor_del_ack(mp, datahandle); | 551 | capiminor_del_ack(mp, datahandle); |
@@ -650,10 +619,8 @@ static void capi_recv_message(struct capi20_appl *ap, struct sk_buff *skb) | |||
650 | } | 619 | } |
651 | if (CAPIMSG_SUBCOMMAND(skb->data) == CAPI_IND) { | 620 | if (CAPIMSG_SUBCOMMAND(skb->data) == CAPI_IND) { |
652 | datahandle = CAPIMSG_U16(skb->data, CAPIMSG_BASELEN+4+4+2); | 621 | datahandle = CAPIMSG_U16(skb->data, CAPIMSG_BASELEN+4+4+2); |
653 | #ifdef _DEBUG_DATAFLOW | 622 | pr_debug("capi_signal: DATA_B3_IND %u len=%d\n", |
654 | printk(KERN_DEBUG "capi_signal: DATA_B3_IND %u len=%d\n", | 623 | datahandle, skb->len-CAPIMSG_LEN(skb->data)); |
655 | datahandle, skb->len-CAPIMSG_LEN(skb->data)); | ||
656 | #endif | ||
657 | skb_queue_tail(&mp->inqueue, skb); | 624 | skb_queue_tail(&mp->inqueue, skb); |
658 | 625 | ||
659 | handle_minor_recv(mp); | 626 | handle_minor_recv(mp); |
@@ -661,11 +628,9 @@ static void capi_recv_message(struct capi20_appl *ap, struct sk_buff *skb) | |||
661 | } else if (CAPIMSG_SUBCOMMAND(skb->data) == CAPI_CONF) { | 628 | } else if (CAPIMSG_SUBCOMMAND(skb->data) == CAPI_CONF) { |
662 | 629 | ||
663 | datahandle = CAPIMSG_U16(skb->data, CAPIMSG_BASELEN+4); | 630 | datahandle = CAPIMSG_U16(skb->data, CAPIMSG_BASELEN+4); |
664 | #ifdef _DEBUG_DATAFLOW | 631 | pr_debug("capi_signal: DATA_B3_CONF %u 0x%x\n", |
665 | printk(KERN_DEBUG "capi_signal: DATA_B3_CONF %u 0x%x\n", | 632 | datahandle, |
666 | datahandle, | 633 | CAPIMSG_U16(skb->data, CAPIMSG_BASELEN+4+2)); |
667 | CAPIMSG_U16(skb->data, CAPIMSG_BASELEN+4+2)); | ||
668 | #endif | ||
669 | kfree_skb(skb); | 634 | kfree_skb(skb); |
670 | capiminor_del_ack(mp, datahandle); | 635 | capiminor_del_ack(mp, datahandle); |
671 | tty = tty_port_tty_get(&mp->port); | 636 | tty = tty_port_tty_get(&mp->port); |
@@ -1095,9 +1060,7 @@ static int capinc_tty_write(struct tty_struct *tty, | |||
1095 | struct capiminor *mp = tty->driver_data; | 1060 | struct capiminor *mp = tty->driver_data; |
1096 | struct sk_buff *skb; | 1061 | struct sk_buff *skb; |
1097 | 1062 | ||
1098 | #ifdef _DEBUG_TTYFUNCS | 1063 | pr_debug("capinc_tty_write(count=%d)\n", count); |
1099 | printk(KERN_DEBUG "capinc_tty_write(count=%d)\n", count); | ||
1100 | #endif | ||
1101 | 1064 | ||
1102 | spin_lock_bh(&mp->outlock); | 1065 | spin_lock_bh(&mp->outlock); |
1103 | skb = mp->outskb; | 1066 | skb = mp->outskb; |
@@ -1133,9 +1096,7 @@ static int capinc_tty_put_char(struct tty_struct *tty, unsigned char ch) | |||
1133 | struct sk_buff *skb; | 1096 | struct sk_buff *skb; |
1134 | int ret = 1; | 1097 | int ret = 1; |
1135 | 1098 | ||
1136 | #ifdef _DEBUG_TTYFUNCS | 1099 | pr_debug("capinc_put_char(%u)\n", ch); |
1137 | printk(KERN_DEBUG "capinc_put_char(%u)\n", ch); | ||
1138 | #endif | ||
1139 | 1100 | ||
1140 | spin_lock_bh(&mp->outlock); | 1101 | spin_lock_bh(&mp->outlock); |
1141 | skb = mp->outskb; | 1102 | skb = mp->outskb; |
@@ -1174,9 +1135,7 @@ static void capinc_tty_flush_chars(struct tty_struct *tty) | |||
1174 | struct capiminor *mp = tty->driver_data; | 1135 | struct capiminor *mp = tty->driver_data; |
1175 | struct sk_buff *skb; | 1136 | struct sk_buff *skb; |
1176 | 1137 | ||
1177 | #ifdef _DEBUG_TTYFUNCS | 1138 | pr_debug("capinc_tty_flush_chars\n"); |
1178 | printk(KERN_DEBUG "capinc_tty_flush_chars\n"); | ||
1179 | #endif | ||
1180 | 1139 | ||
1181 | spin_lock_bh(&mp->outlock); | 1140 | spin_lock_bh(&mp->outlock); |
1182 | skb = mp->outskb; | 1141 | skb = mp->outskb; |
@@ -1200,9 +1159,7 @@ static int capinc_tty_write_room(struct tty_struct *tty) | |||
1200 | 1159 | ||
1201 | room = CAPINC_MAX_SENDQUEUE-skb_queue_len(&mp->outqueue); | 1160 | room = CAPINC_MAX_SENDQUEUE-skb_queue_len(&mp->outqueue); |
1202 | room *= CAPI_MAX_BLKSIZE; | 1161 | room *= CAPI_MAX_BLKSIZE; |
1203 | #ifdef _DEBUG_TTYFUNCS | 1162 | pr_debug("capinc_tty_write_room = %d\n", room); |
1204 | printk(KERN_DEBUG "capinc_tty_write_room = %d\n", room); | ||
1205 | #endif | ||
1206 | return room; | 1163 | return room; |
1207 | } | 1164 | } |
1208 | 1165 | ||
@@ -1210,12 +1167,10 @@ static int capinc_tty_chars_in_buffer(struct tty_struct *tty) | |||
1210 | { | 1167 | { |
1211 | struct capiminor *mp = tty->driver_data; | 1168 | struct capiminor *mp = tty->driver_data; |
1212 | 1169 | ||
1213 | #ifdef _DEBUG_TTYFUNCS | 1170 | pr_debug("capinc_tty_chars_in_buffer = %d nack=%d sq=%d rq=%d\n", |
1214 | printk(KERN_DEBUG "capinc_tty_chars_in_buffer = %d nack=%d sq=%d rq=%d\n", | 1171 | mp->outbytes, mp->nack, |
1215 | mp->outbytes, mp->nack, | 1172 | skb_queue_len(&mp->outqueue), |
1216 | skb_queue_len(&mp->outqueue), | 1173 | skb_queue_len(&mp->inqueue)); |
1217 | skb_queue_len(&mp->inqueue)); | ||
1218 | #endif | ||
1219 | return mp->outbytes; | 1174 | return mp->outbytes; |
1220 | } | 1175 | } |
1221 | 1176 | ||
@@ -1227,17 +1182,13 @@ static int capinc_tty_ioctl(struct tty_struct *tty, | |||
1227 | 1182 | ||
1228 | static void capinc_tty_set_termios(struct tty_struct *tty, struct ktermios * old) | 1183 | static void capinc_tty_set_termios(struct tty_struct *tty, struct ktermios * old) |
1229 | { | 1184 | { |
1230 | #ifdef _DEBUG_TTYFUNCS | 1185 | pr_debug("capinc_tty_set_termios\n"); |
1231 | printk(KERN_DEBUG "capinc_tty_set_termios\n"); | ||
1232 | #endif | ||
1233 | } | 1186 | } |
1234 | 1187 | ||
1235 | static void capinc_tty_throttle(struct tty_struct *tty) | 1188 | static void capinc_tty_throttle(struct tty_struct *tty) |
1236 | { | 1189 | { |
1237 | struct capiminor *mp = tty->driver_data; | 1190 | struct capiminor *mp = tty->driver_data; |
1238 | #ifdef _DEBUG_TTYFUNCS | 1191 | pr_debug("capinc_tty_throttle\n"); |
1239 | printk(KERN_DEBUG "capinc_tty_throttle\n"); | ||
1240 | #endif | ||
1241 | mp->ttyinstop = 1; | 1192 | mp->ttyinstop = 1; |
1242 | } | 1193 | } |
1243 | 1194 | ||
@@ -1245,9 +1196,7 @@ static void capinc_tty_unthrottle(struct tty_struct *tty) | |||
1245 | { | 1196 | { |
1246 | struct capiminor *mp = tty->driver_data; | 1197 | struct capiminor *mp = tty->driver_data; |
1247 | 1198 | ||
1248 | #ifdef _DEBUG_TTYFUNCS | 1199 | pr_debug("capinc_tty_unthrottle\n"); |
1249 | printk(KERN_DEBUG "capinc_tty_unthrottle\n"); | ||
1250 | #endif | ||
1251 | mp->ttyinstop = 0; | 1200 | mp->ttyinstop = 0; |
1252 | handle_minor_recv(mp); | 1201 | handle_minor_recv(mp); |
1253 | } | 1202 | } |
@@ -1256,9 +1205,7 @@ static void capinc_tty_stop(struct tty_struct *tty) | |||
1256 | { | 1205 | { |
1257 | struct capiminor *mp = tty->driver_data; | 1206 | struct capiminor *mp = tty->driver_data; |
1258 | 1207 | ||
1259 | #ifdef _DEBUG_TTYFUNCS | 1208 | pr_debug("capinc_tty_stop\n"); |
1260 | printk(KERN_DEBUG "capinc_tty_stop\n"); | ||
1261 | #endif | ||
1262 | mp->ttyoutstop = 1; | 1209 | mp->ttyoutstop = 1; |
1263 | } | 1210 | } |
1264 | 1211 | ||
@@ -1266,9 +1213,7 @@ static void capinc_tty_start(struct tty_struct *tty) | |||
1266 | { | 1213 | { |
1267 | struct capiminor *mp = tty->driver_data; | 1214 | struct capiminor *mp = tty->driver_data; |
1268 | 1215 | ||
1269 | #ifdef _DEBUG_TTYFUNCS | 1216 | pr_debug("capinc_tty_start\n"); |
1270 | printk(KERN_DEBUG "capinc_tty_start\n"); | ||
1271 | #endif | ||
1272 | mp->ttyoutstop = 0; | 1217 | mp->ttyoutstop = 0; |
1273 | handle_minor_send(mp); | 1218 | handle_minor_send(mp); |
1274 | } | 1219 | } |
@@ -1277,39 +1222,29 @@ static void capinc_tty_hangup(struct tty_struct *tty) | |||
1277 | { | 1222 | { |
1278 | struct capiminor *mp = tty->driver_data; | 1223 | struct capiminor *mp = tty->driver_data; |
1279 | 1224 | ||
1280 | #ifdef _DEBUG_TTYFUNCS | 1225 | pr_debug("capinc_tty_hangup\n"); |
1281 | printk(KERN_DEBUG "capinc_tty_hangup\n"); | ||
1282 | #endif | ||
1283 | tty_port_hangup(&mp->port); | 1226 | tty_port_hangup(&mp->port); |
1284 | } | 1227 | } |
1285 | 1228 | ||
1286 | static int capinc_tty_break_ctl(struct tty_struct *tty, int state) | 1229 | static int capinc_tty_break_ctl(struct tty_struct *tty, int state) |
1287 | { | 1230 | { |
1288 | #ifdef _DEBUG_TTYFUNCS | 1231 | pr_debug("capinc_tty_break_ctl(%d)\n", state); |
1289 | printk(KERN_DEBUG "capinc_tty_break_ctl(%d)\n", state); | ||
1290 | #endif | ||
1291 | return 0; | 1232 | return 0; |
1292 | } | 1233 | } |
1293 | 1234 | ||
1294 | static void capinc_tty_flush_buffer(struct tty_struct *tty) | 1235 | static void capinc_tty_flush_buffer(struct tty_struct *tty) |
1295 | { | 1236 | { |
1296 | #ifdef _DEBUG_TTYFUNCS | 1237 | pr_debug("capinc_tty_flush_buffer\n"); |
1297 | printk(KERN_DEBUG "capinc_tty_flush_buffer\n"); | ||
1298 | #endif | ||
1299 | } | 1238 | } |
1300 | 1239 | ||
1301 | static void capinc_tty_set_ldisc(struct tty_struct *tty) | 1240 | static void capinc_tty_set_ldisc(struct tty_struct *tty) |
1302 | { | 1241 | { |
1303 | #ifdef _DEBUG_TTYFUNCS | 1242 | pr_debug("capinc_tty_set_ldisc\n"); |
1304 | printk(KERN_DEBUG "capinc_tty_set_ldisc\n"); | ||
1305 | #endif | ||
1306 | } | 1243 | } |
1307 | 1244 | ||
1308 | static void capinc_tty_send_xchar(struct tty_struct *tty, char ch) | 1245 | static void capinc_tty_send_xchar(struct tty_struct *tty, char ch) |
1309 | { | 1246 | { |
1310 | #ifdef _DEBUG_TTYFUNCS | 1247 | pr_debug("capinc_tty_send_xchar(%d)\n", ch); |
1311 | printk(KERN_DEBUG "capinc_tty_send_xchar(%d)\n", ch); | ||
1312 | #endif | ||
1313 | } | 1248 | } |
1314 | 1249 | ||
1315 | static const struct tty_operations capinc_ops = { | 1250 | static const struct tty_operations capinc_ops = { |
@@ -1514,10 +1449,8 @@ static int __init capi_init(void) | |||
1514 | 1449 | ||
1515 | proc_init(); | 1450 | proc_init(); |
1516 | 1451 | ||
1517 | #if defined(CONFIG_ISDN_CAPI_CAPIFS) || defined(CONFIG_ISDN_CAPI_CAPIFS_MODULE) | 1452 | #ifdef CONFIG_ISDN_CAPI_MIDDLEWARE |
1518 | compileinfo = " (middleware+capifs)"; | 1453 | compileinfo = " (middleware)"; |
1519 | #elif defined(CONFIG_ISDN_CAPI_MIDDLEWARE) | ||
1520 | compileinfo = " (no capifs)"; | ||
1521 | #else | 1454 | #else |
1522 | compileinfo = " (no middleware)"; | 1455 | compileinfo = " (no middleware)"; |
1523 | #endif | 1456 | #endif |