Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

isdn: capi: dead code removal

The staging isdn drivers are gone, and CONFIG_BT_CMTP is now
the only user. This means a lot of the code in the subsystem
has no remaining callers and can be removed.

Change the capi user space front-end to be part of kernelcapi,
and the combined module to only be compiled if BT_CMTP is
also enabled, then remove the interfaces that have no remaining
callers.

As the notifier list and the capi_drivers list have no callers
outside of kcapi.c, the implementation gets much simpler.

Some definitions from the include/linux/*.h headers are only
needed internally and are moved to kcapi.h.

Acked-by: David Miller <davem@davemloft.net>
Signed-off-by: Arnd Bergmann <arnd@arndb.de>
Link: https://lore.kernel.org/r/20191210210455.3475361-2-arnd@arndb.de
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

authored by

Arnd Bergmann and committed by
Greg Kroah-Hartman
f59aba2f f10870b0

+182 -1609
-71
Documentation/isdn/interface_capi.rst
··· 26 26 2. Driver and Device Registration 27 27 ================================= 28 28 29 - CAPI drivers optionally register themselves with Kernel CAPI by calling the 30 - Kernel CAPI function register_capi_driver() with a pointer to a struct 31 - capi_driver. This structure must be filled with the name and revision of the 32 - driver, and optionally a pointer to a callback function, add_card(). The 33 - registration can be revoked by calling the function unregister_capi_driver() 34 - with a pointer to the same struct capi_driver. 35 - 36 29 CAPI drivers must register each of the ISDN devices they control with Kernel 37 30 CAPI by calling the Kernel CAPI function attach_capi_ctr() with a pointer to a 38 31 struct capi_ctr before they can be used. This structure must be filled with ··· 82 89 the name of the driver, as a zero-terminated ASCII string 83 90 ``char revision[32]`` 84 91 the revision number of the driver, as a zero-terminated ASCII string 85 - ``int (*add_card)(struct capi_driver *driver, capicardparams *data)`` 86 - a callback function pointer (may be NULL) 87 - 88 92 89 93 4.2 struct capi_ctr 90 94 ------------------- ··· 168 178 pointer to a callback function returning the entry for the device in 169 179 the CAPI controller info table, /proc/capi/controller 170 180 171 - ``const struct file_operations *proc_fops`` 172 - pointers to callback functions for the device's proc file 173 - system entry, /proc/capi/controllers/<n>; pointer to the device's 174 - capi_ctr structure is available from struct proc_dir_entry::data 175 - which is available from struct inode. 176 - 177 181 Note: 178 182 Callback functions except send_message() are never called in interrupt 179 183 context. ··· 251 267 _cmsg structure members. 252 268 =========== ================================================================= 253 269 254 - Functions capi_cmsg2message() and capi_message2cmsg() are provided to convert 255 - messages between their transport encoding described in the CAPI 2.0 standard 256 - and their _cmsg structure representation. Note that capi_cmsg2message() does 257 - not know or check the size of its destination buffer. The caller must make 258 - sure it is big enough to accommodate the resulting CAPI message. 259 - 260 270 261 271 5. Lower Layer Interface Functions 262 272 ================================== 263 - 264 - (declared in <linux/isdn/capilli.h>) 265 - 266 - :: 267 - 268 - void register_capi_driver(struct capi_driver *drvr) 269 - void unregister_capi_driver(struct capi_driver *drvr) 270 - 271 - register/unregister a driver with Kernel CAPI 272 273 273 274 :: 274 275 ··· 271 302 272 303 :: 273 304 274 - void capi_ctr_suspend_output(struct capi_ctr *ctrlr) 275 - void capi_ctr_resume_output(struct capi_ctr *ctrlr) 276 - 277 - signal suspend/resume 278 - 279 - :: 280 - 281 305 void capi_ctr_handle_message(struct capi_ctr * ctrlr, u16 applid, 282 306 struct sk_buff *skb) 283 307 ··· 280 318 281 319 6. Helper Functions and Macros 282 320 ============================== 283 - 284 - Library functions (from <linux/isdn/capilli.h>): 285 - 286 - :: 287 - 288 - void capilib_new_ncci(struct list_head *head, u16 applid, 289 - u32 ncci, u32 winsize) 290 - void capilib_free_ncci(struct list_head *head, u16 applid, u32 ncci) 291 - void capilib_release_appl(struct list_head *head, u16 applid) 292 - void capilib_release(struct list_head *head) 293 - void capilib_data_b3_conf(struct list_head *head, u16 applid, 294 - u32 ncci, u16 msgid) 295 - u16 capilib_data_b3_req(struct list_head *head, u16 applid, 296 - u32 ncci, u16 msgid) 297 - 298 321 299 322 Macros to extract/set element values from/in a CAPI message header 300 323 (from <linux/isdn/capiutil.h>): ··· 303 356 304 357 Library functions for working with _cmsg structures 305 358 (from <linux/isdn/capiutil.h>): 306 - 307 - ``unsigned capi_cmsg2message(_cmsg *cmsg, u8 *msg)`` 308 - Assembles a CAPI 2.0 message from the parameters in ``*cmsg``, 309 - storing the result in ``*msg``. 310 - 311 - ``unsigned capi_message2cmsg(_cmsg *cmsg, u8 *msg)`` 312 - Disassembles the CAPI 2.0 message in ``*msg``, storing the parameters 313 - in ``*cmsg``. 314 - 315 - ``unsigned capi_cmsg_header(_cmsg *cmsg, u16 ApplId, u8 Command, u8 Subcommand, u16 Messagenumber, u32 Controller)`` 316 - Fills the header part and address field of the _cmsg structure ``*cmsg`` 317 - with the given values, zeroing the remainder of the structure so only 318 - parameters with non-default values need to be changed before sending 319 - the message. 320 - 321 - ``void capi_cmsg_answer(_cmsg *cmsg)`` 322 - Sets the low bit of the Subcommand field in ``*cmsg``, thereby 323 - converting ``_REQ`` to ``_CONF`` and ``_IND`` to ``_RESP``. 324 359 325 360 ``char *capi_cmd2str(u8 Command, u8 Subcommand)`` 326 361 Returns the CAPI 2.0 message name corresponding to the given command
+1 -1
drivers/isdn/Makefile
··· 3 3 4 4 # Object files in subdirectories 5 5 6 - obj-$(CONFIG_ISDN_CAPI) += capi/ 6 + obj-$(CONFIG_BT_CMTP) += capi/ 7 7 obj-$(CONFIG_MISDN) += mISDN/ 8 8 obj-$(CONFIG_ISDN) += hardware/
+4 -28
drivers/isdn/capi/Kconfig
··· 1 1 # SPDX-License-Identifier: GPL-2.0-only 2 - menuconfig ISDN_CAPI 3 - tristate "CAPI 2.0 subsystem" 2 + config ISDN_CAPI 3 + def_bool ISDN && BT 4 4 help 5 5 This provides CAPI (the Common ISDN Application Programming 6 6 Interface) Version 2.0, a standard making it easy for programs to ··· 15 15 See CONFIG_BT_CMTP for the last remaining regular driver 16 16 in the kernel that uses the CAPI subsystem. 17 17 18 - if ISDN_CAPI 19 - 20 18 config CAPI_TRACE 21 - bool "CAPI trace support" 22 - default y 19 + def_bool BT_CMTP 23 20 help 24 21 If you say Y here, the kernelcapi driver can make verbose traces 25 22 of CAPI messages. This feature can be enabled/disabled via IOCTL for 26 23 every controller (default disabled). 27 - This will increase the size of the kernelcapi module by 20 KB. 28 - If unsure, say Y. 29 - 30 - config ISDN_CAPI_CAPI20 31 - tristate "CAPI2.0 /dev/capi20 support" 32 - help 33 - This option will provide the CAPI 2.0 interface to userspace 34 - applications via /dev/capi20. Applications should use the 35 - standardized libcapi20 to access this functionality. You should say 36 - Y/M here. 37 24 38 25 config ISDN_CAPI_MIDDLEWARE 39 - bool "CAPI2.0 Middleware support" 40 - depends on ISDN_CAPI_CAPI20 && TTY 26 + def_bool BT_CMTP && TTY 41 27 help 42 28 This option will enhance the capabilities of the /dev/capi20 43 29 interface. It will provide a means of moving a data connection, 44 30 established via the usual /dev/capi20 interface to a special tty 45 31 device. If you want to use pppd with pppdcapiplugin to dial up to 46 32 your ISP, say Y here. 47 - 48 - config ISDN_CAPI_CAPIDRV_VERBOSE 49 - bool "Verbose reason code reporting" 50 - depends on ISDN_CAPI_CAPIDRV 51 - help 52 - If you say Y here, the capidrv interface will give verbose reasons 53 - for disconnecting. This will increase the size of the kernel by 7 KB. 54 - If unsure, say N. 55 - 56 - endif
+3 -15
drivers/isdn/capi/Makefile
··· 1 1 # SPDX-License-Identifier: GPL-2.0 2 - # Makefile for the CAPI subsystem. 2 + # Makefile for the CAPI subsystem used by BT_CMTP 3 3 4 - # Ordering constraints: kernelcapi.o first 5 - 6 - # Each configuration option enables a list of files. 7 - 8 - obj-$(CONFIG_ISDN_CAPI) += kernelcapi.o 9 - obj-$(CONFIG_ISDN_CAPI_CAPI20) += capi.o 10 - obj-$(CONFIG_ISDN_CAPI_CAPIDRV) += capidrv.o 11 - 12 - # Multipart objects. 13 - 14 - kernelcapi-y := kcapi.o capiutil.o capilib.o 15 - kernelcapi-$(CONFIG_PROC_FS) += kcapi_proc.o 16 - 17 - ccflags-y += -I$(srctree)/$(src)/../include -I$(srctree)/$(src)/../include/uapi 4 + obj-$(CONFIG_BT_CMTP) += kernelcapi.o 5 + kernelcapi-y := kcapi.o capiutil.o capi.o kcapi_proc.o
+13 -1
drivers/isdn/capi/capi.c
··· 39 39 #include <linux/isdn/capiutil.h> 40 40 #include <linux/isdn/capicmd.h> 41 41 42 - MODULE_DESCRIPTION("CAPI4Linux: Userspace /dev/capi20 interface"); 42 + #include "kcapi.h" 43 + 44 + MODULE_DESCRIPTION("CAPI4Linux: kernel CAPI layer and /dev/capi20 interface"); 43 45 MODULE_AUTHOR("Carsten Paeth"); 44 46 MODULE_LICENSE("GPL"); 45 47 ··· 1414 1412 { 1415 1413 const char *compileinfo; 1416 1414 int major_ret; 1415 + int ret; 1416 + 1417 + ret = kcapi_init(); 1418 + if (ret) 1419 + return ret; 1417 1420 1418 1421 major_ret = register_chrdev(capi_major, "capi20", &capi_fops); 1419 1422 if (major_ret < 0) { 1420 1423 printk(KERN_ERR "capi20: unable to get major %d\n", capi_major); 1424 + kcapi_exit(); 1421 1425 return major_ret; 1422 1426 } 1423 1427 capi_class = class_create(THIS_MODULE, "capi"); 1424 1428 if (IS_ERR(capi_class)) { 1425 1429 unregister_chrdev(capi_major, "capi20"); 1430 + kcapi_exit(); 1426 1431 return PTR_ERR(capi_class); 1427 1432 } 1428 1433 ··· 1439 1430 device_destroy(capi_class, MKDEV(capi_major, 0)); 1440 1431 class_destroy(capi_class); 1441 1432 unregister_chrdev(capi_major, "capi20"); 1433 + kcapi_exit(); 1442 1434 return -ENOMEM; 1443 1435 } 1444 1436 ··· 1465 1455 unregister_chrdev(capi_major, "capi20"); 1466 1456 1467 1457 capinc_tty_exit(); 1458 + 1459 + kcapi_exit(); 1468 1460 } 1469 1461 1470 1462 module_init(capi_init);
-202
drivers/isdn/capi/capilib.c
··· 1 - // SPDX-License-Identifier: GPL-2.0 2 - 3 - #include <linux/slab.h> 4 - #include <linux/kernel.h> 5 - #include <linux/module.h> 6 - #include <linux/isdn/capilli.h> 7 - 8 - #define DBG(format, arg...) do { \ 9 - printk(KERN_DEBUG "%s: " format "\n" , __func__ , ## arg); \ 10 - } while (0) 11 - 12 - struct capilib_msgidqueue { 13 - struct capilib_msgidqueue *next; 14 - u16 msgid; 15 - }; 16 - 17 - struct capilib_ncci { 18 - struct list_head list; 19 - u16 applid; 20 - u32 ncci; 21 - u32 winsize; 22 - int nmsg; 23 - struct capilib_msgidqueue *msgidqueue; 24 - struct capilib_msgidqueue *msgidlast; 25 - struct capilib_msgidqueue *msgidfree; 26 - struct capilib_msgidqueue msgidpool[CAPI_MAXDATAWINDOW]; 27 - }; 28 - 29 - // --------------------------------------------------------------------------- 30 - // NCCI Handling 31 - 32 - static inline void mq_init(struct capilib_ncci *np) 33 - { 34 - u_int i; 35 - np->msgidqueue = NULL; 36 - np->msgidlast = NULL; 37 - np->nmsg = 0; 38 - memset(np->msgidpool, 0, sizeof(np->msgidpool)); 39 - np->msgidfree = &np->msgidpool[0]; 40 - for (i = 1; i < np->winsize; i++) { 41 - np->msgidpool[i].next = np->msgidfree; 42 - np->msgidfree = &np->msgidpool[i]; 43 - } 44 - } 45 - 46 - static inline int mq_enqueue(struct capilib_ncci *np, u16 msgid) 47 - { 48 - struct capilib_msgidqueue *mq; 49 - if ((mq = np->msgidfree) == NULL) 50 - return 0; 51 - np->msgidfree = mq->next; 52 - mq->msgid = msgid; 53 - mq->next = NULL; 54 - if (np->msgidlast) 55 - np->msgidlast->next = mq; 56 - np->msgidlast = mq; 57 - if (!np->msgidqueue) 58 - np->msgidqueue = mq; 59 - np->nmsg++; 60 - return 1; 61 - } 62 - 63 - static inline int mq_dequeue(struct capilib_ncci *np, u16 msgid) 64 - { 65 - struct capilib_msgidqueue **pp; 66 - for (pp = &np->msgidqueue; *pp; pp = &(*pp)->next) { 67 - if ((*pp)->msgid == msgid) { 68 - struct capilib_msgidqueue *mq = *pp; 69 - *pp = mq->next; 70 - if (mq == np->msgidlast) 71 - np->msgidlast = NULL; 72 - mq->next = np->msgidfree; 73 - np->msgidfree = mq; 74 - np->nmsg--; 75 - return 1; 76 - } 77 - } 78 - return 0; 79 - } 80 - 81 - void capilib_new_ncci(struct list_head *head, u16 applid, u32 ncci, u32 winsize) 82 - { 83 - struct capilib_ncci *np; 84 - 85 - np = kmalloc(sizeof(*np), GFP_ATOMIC); 86 - if (!np) { 87 - printk(KERN_WARNING "capilib_new_ncci: no memory.\n"); 88 - return; 89 - } 90 - if (winsize > CAPI_MAXDATAWINDOW) { 91 - printk(KERN_ERR "capi_new_ncci: winsize %d too big\n", 92 - winsize); 93 - winsize = CAPI_MAXDATAWINDOW; 94 - } 95 - np->applid = applid; 96 - np->ncci = ncci; 97 - np->winsize = winsize; 98 - mq_init(np); 99 - list_add_tail(&np->list, head); 100 - DBG("kcapi: appl %d ncci 0x%x up", applid, ncci); 101 - } 102 - 103 - EXPORT_SYMBOL(capilib_new_ncci); 104 - 105 - void capilib_free_ncci(struct list_head *head, u16 applid, u32 ncci) 106 - { 107 - struct list_head *l; 108 - struct capilib_ncci *np; 109 - 110 - list_for_each(l, head) { 111 - np = list_entry(l, struct capilib_ncci, list); 112 - if (np->applid != applid) 113 - continue; 114 - if (np->ncci != ncci) 115 - continue; 116 - printk(KERN_INFO "kcapi: appl %d ncci 0x%x down\n", applid, ncci); 117 - list_del(&np->list); 118 - kfree(np); 119 - return; 120 - } 121 - printk(KERN_ERR "capilib_free_ncci: ncci 0x%x not found\n", ncci); 122 - } 123 - 124 - EXPORT_SYMBOL(capilib_free_ncci); 125 - 126 - void capilib_release_appl(struct list_head *head, u16 applid) 127 - { 128 - struct list_head *l, *n; 129 - struct capilib_ncci *np; 130 - 131 - list_for_each_safe(l, n, head) { 132 - np = list_entry(l, struct capilib_ncci, list); 133 - if (np->applid != applid) 134 - continue; 135 - printk(KERN_INFO "kcapi: appl %d ncci 0x%x forced down\n", applid, np->ncci); 136 - list_del(&np->list); 137 - kfree(np); 138 - } 139 - } 140 - 141 - EXPORT_SYMBOL(capilib_release_appl); 142 - 143 - void capilib_release(struct list_head *head) 144 - { 145 - struct list_head *l, *n; 146 - struct capilib_ncci *np; 147 - 148 - list_for_each_safe(l, n, head) { 149 - np = list_entry(l, struct capilib_ncci, list); 150 - printk(KERN_INFO "kcapi: appl %d ncci 0x%x forced down\n", np->applid, np->ncci); 151 - list_del(&np->list); 152 - kfree(np); 153 - } 154 - } 155 - 156 - EXPORT_SYMBOL(capilib_release); 157 - 158 - u16 capilib_data_b3_req(struct list_head *head, u16 applid, u32 ncci, u16 msgid) 159 - { 160 - struct list_head *l; 161 - struct capilib_ncci *np; 162 - 163 - list_for_each(l, head) { 164 - np = list_entry(l, struct capilib_ncci, list); 165 - if (np->applid != applid) 166 - continue; 167 - if (np->ncci != ncci) 168 - continue; 169 - 170 - if (mq_enqueue(np, msgid) == 0) 171 - return CAPI_SENDQUEUEFULL; 172 - 173 - return CAPI_NOERROR; 174 - } 175 - printk(KERN_ERR "capilib_data_b3_req: ncci 0x%x not found\n", ncci); 176 - return CAPI_NOERROR; 177 - } 178 - 179 - EXPORT_SYMBOL(capilib_data_b3_req); 180 - 181 - void capilib_data_b3_conf(struct list_head *head, u16 applid, u32 ncci, u16 msgid) 182 - { 183 - struct list_head *l; 184 - struct capilib_ncci *np; 185 - 186 - list_for_each(l, head) { 187 - np = list_entry(l, struct capilib_ncci, list); 188 - if (np->applid != applid) 189 - continue; 190 - if (np->ncci != ncci) 191 - continue; 192 - 193 - if (mq_dequeue(np, msgid) == 0) { 194 - printk(KERN_ERR "kcapi: msgid %hu ncci 0x%x not on queue\n", 195 - msgid, ncci); 196 - } 197 - return; 198 - } 199 - printk(KERN_ERR "capilib_data_b3_conf: ncci 0x%x not found\n", ncci); 200 - } 201 - 202 - EXPORT_SYMBOL(capilib_data_b3_conf);
+4 -227
drivers/isdn/capi/capiutil.c
··· 20 20 #include <linux/isdn/capiutil.h> 21 21 #include <linux/slab.h> 22 22 23 + #include "kcapi.h" 24 + 23 25 /* from CAPI2.0 DDK AVM Berlin GmbH */ 24 26 25 27 typedef struct { ··· 247 245 } 248 246 } 249 247 } 250 - /*-------------------------------------------------------*/ 251 - static void pars_2_message(_cmsg *cmsg) 252 - { 253 - 254 - for (; TYP != _CEND; cmsg->p++) { 255 - switch (TYP) { 256 - case _CBYTE: 257 - byteTLcpy(cmsg->m + cmsg->l, OFF); 258 - cmsg->l++; 259 - break; 260 - case _CWORD: 261 - wordTLcpy(cmsg->m + cmsg->l, OFF); 262 - cmsg->l += 2; 263 - break; 264 - case _CDWORD: 265 - dwordTLcpy(cmsg->m + cmsg->l, OFF); 266 - cmsg->l += 4; 267 - break; 268 - case _CSTRUCT: 269 - if (*(u8 **) OFF == NULL) { 270 - *(cmsg->m + cmsg->l) = '\0'; 271 - cmsg->l++; 272 - } else if (**(_cstruct *) OFF != 0xff) { 273 - structTLcpy(cmsg->m + cmsg->l, *(_cstruct *) OFF, 1 + **(_cstruct *) OFF); 274 - cmsg->l += 1 + **(_cstruct *) OFF; 275 - } else { 276 - _cstruct s = *(_cstruct *) OFF; 277 - structTLcpy(cmsg->m + cmsg->l, s, 3 + *(u16 *) (s + 1)); 278 - cmsg->l += 3 + *(u16 *) (s + 1); 279 - } 280 - break; 281 - case _CMSTRUCT: 282 - /*----- Metastruktur 0 -----*/ 283 - if (*(_cmstruct *) OFF == CAPI_DEFAULT) { 284 - *(cmsg->m + cmsg->l) = '\0'; 285 - cmsg->l++; 286 - jumpcstruct(cmsg); 287 - } 288 - /*----- Metastruktur wird composed -----*/ 289 - else { 290 - unsigned _l = cmsg->l; 291 - unsigned _ls; 292 - cmsg->l++; 293 - cmsg->p++; 294 - pars_2_message(cmsg); 295 - _ls = cmsg->l - _l - 1; 296 - if (_ls < 255) 297 - (cmsg->m + _l)[0] = (u8) _ls; 298 - else { 299 - structTLcpyovl(cmsg->m + _l + 3, cmsg->m + _l + 1, _ls); 300 - (cmsg->m + _l)[0] = 0xff; 301 - wordTLcpy(cmsg->m + _l + 1, &_ls); 302 - } 303 - } 304 - break; 305 - } 306 - } 307 - } 308 - 309 - /** 310 - * capi_cmsg2message() - assemble CAPI 2.0 message from _cmsg structure 311 - * @cmsg: _cmsg structure 312 - * @msg: buffer for assembled message 313 - * 314 - * Return value: 0 for success 315 - */ 316 - 317 - unsigned capi_cmsg2message(_cmsg *cmsg, u8 *msg) 318 - { 319 - cmsg->m = msg; 320 - cmsg->l = 8; 321 - cmsg->p = 0; 322 - cmsg->par = capi_cmd2par(cmsg->Command, cmsg->Subcommand); 323 - if (!cmsg->par) 324 - return 1; /* invalid command/subcommand */ 325 - 326 - pars_2_message(cmsg); 327 - 328 - wordTLcpy(msg + 0, &cmsg->l); 329 - byteTLcpy(cmsg->m + 4, &cmsg->Command); 330 - byteTLcpy(cmsg->m + 5, &cmsg->Subcommand); 331 - wordTLcpy(cmsg->m + 2, &cmsg->ApplId); 332 - wordTLcpy(cmsg->m + 6, &cmsg->Messagenumber); 333 - 334 - return 0; 335 - } 336 - 337 - /*-------------------------------------------------------*/ 338 - static void message_2_pars(_cmsg *cmsg) 339 - { 340 - for (; TYP != _CEND; cmsg->p++) { 341 - 342 - switch (TYP) { 343 - case _CBYTE: 344 - byteTRcpy(cmsg->m + cmsg->l, OFF); 345 - cmsg->l++; 346 - break; 347 - case _CWORD: 348 - wordTRcpy(cmsg->m + cmsg->l, OFF); 349 - cmsg->l += 2; 350 - break; 351 - case _CDWORD: 352 - dwordTRcpy(cmsg->m + cmsg->l, OFF); 353 - cmsg->l += 4; 354 - break; 355 - case _CSTRUCT: 356 - *(u8 **) OFF = cmsg->m + cmsg->l; 357 - 358 - if (cmsg->m[cmsg->l] != 0xff) 359 - cmsg->l += 1 + cmsg->m[cmsg->l]; 360 - else 361 - cmsg->l += 3 + *(u16 *) (cmsg->m + cmsg->l + 1); 362 - break; 363 - case _CMSTRUCT: 364 - /*----- Metastruktur 0 -----*/ 365 - if (cmsg->m[cmsg->l] == '\0') { 366 - *(_cmstruct *) OFF = CAPI_DEFAULT; 367 - cmsg->l++; 368 - jumpcstruct(cmsg); 369 - } else { 370 - unsigned _l = cmsg->l; 371 - *(_cmstruct *) OFF = CAPI_COMPOSE; 372 - cmsg->l = (cmsg->m + _l)[0] == 255 ? cmsg->l + 3 : cmsg->l + 1; 373 - cmsg->p++; 374 - message_2_pars(cmsg); 375 - } 376 - break; 377 - } 378 - } 379 - } 380 - 381 - /** 382 - * capi_message2cmsg() - disassemble CAPI 2.0 message into _cmsg structure 383 - * @cmsg: _cmsg structure 384 - * @msg: buffer for assembled message 385 - * 386 - * Return value: 0 for success 387 - */ 388 - 389 - unsigned capi_message2cmsg(_cmsg *cmsg, u8 *msg) 390 - { 391 - memset(cmsg, 0, sizeof(_cmsg)); 392 - cmsg->m = msg; 393 - cmsg->l = 8; 394 - cmsg->p = 0; 395 - byteTRcpy(cmsg->m + 4, &cmsg->Command); 396 - byteTRcpy(cmsg->m + 5, &cmsg->Subcommand); 397 - cmsg->par = capi_cmd2par(cmsg->Command, cmsg->Subcommand); 398 - if (!cmsg->par) 399 - return 1; /* invalid command/subcommand */ 400 - 401 - message_2_pars(cmsg); 402 - 403 - wordTRcpy(msg + 0, &cmsg->l); 404 - wordTRcpy(cmsg->m + 2, &cmsg->ApplId); 405 - wordTRcpy(cmsg->m + 6, &cmsg->Messagenumber); 406 - 407 - return 0; 408 - } 409 - 410 - /** 411 - * capi_cmsg_header() - initialize header part of _cmsg structure 412 - * @cmsg: _cmsg structure 413 - * @_ApplId: ApplID field value 414 - * @_Command: Command field value 415 - * @_Subcommand: Subcommand field value 416 - * @_Messagenumber: Message Number field value 417 - * @_Controller: Controller/PLCI/NCCI field value 418 - * 419 - * Return value: 0 for success 420 - */ 421 - 422 - unsigned capi_cmsg_header(_cmsg *cmsg, u16 _ApplId, 423 - u8 _Command, u8 _Subcommand, 424 - u16 _Messagenumber, u32 _Controller) 425 - { 426 - memset(cmsg, 0, sizeof(_cmsg)); 427 - cmsg->ApplId = _ApplId; 428 - cmsg->Command = _Command; 429 - cmsg->Subcommand = _Subcommand; 430 - cmsg->Messagenumber = _Messagenumber; 431 - cmsg->adr.adrController = _Controller; 432 - return 0; 433 - } 434 248 435 249 /*-------------------------------------------------------*/ 436 250 ··· 378 560 /*2e */ "Reject", 379 561 /*2f */ "Useruserdata" 380 562 }; 381 - 382 - 383 563 384 564 #include <stdarg.h> 385 565 ··· 616 800 return cdb; 617 801 } 618 802 619 - /** 620 - * capi_cmsg2str() - format _cmsg structure for printing 621 - * @cmsg: _cmsg structure 622 - * 623 - * Allocates a CAPI debug buffer and fills it with a printable representation 624 - * of the CAPI 2.0 message stored in @cmsg by a previous call to 625 - * capi_cmsg2message() or capi_message2cmsg(). 626 - * Return value: allocated debug buffer, NULL on error 627 - * The returned buffer should be freed by a call to cdebbuf_free() after use. 628 - */ 629 - 630 - _cdebbuf *capi_cmsg2str(_cmsg *cmsg) 631 - { 632 - _cdebbuf *cdb; 633 - 634 - if (!cmsg->m) 635 - return NULL; /* no message */ 636 - cdb = cdebbuf_alloc(); 637 - if (!cdb) 638 - return NULL; 639 - cmsg->l = 8; 640 - cmsg->p = 0; 641 - cdb = bufprint(cdb, "%s ID=%03d #0x%04x LEN=%04d\n", 642 - capi_cmd2str(cmsg->Command, cmsg->Subcommand), 643 - ((u16 *) cmsg->m)[1], 644 - ((u16 *) cmsg->m)[3], 645 - ((u16 *) cmsg->m)[0]); 646 - cdb = protocol_message_2_pars(cdb, cmsg, 1); 647 - return cdb; 648 - } 649 - 650 803 int __init cdebug_init(void) 651 804 { 652 805 g_cmsg = kmalloc(sizeof(_cmsg), GFP_KERNEL); ··· 639 854 return 0; 640 855 } 641 856 642 - void __exit cdebug_exit(void) 857 + void cdebug_exit(void) 643 858 { 644 859 if (g_debbuf) 645 860 kfree(g_debbuf->buf); ··· 670 885 return 0; 671 886 } 672 887 673 - void __exit cdebug_exit(void) 888 + void cdebug_exit(void) 674 889 { 675 890 } 676 891 677 892 #endif 678 - 679 - EXPORT_SYMBOL(cdebbuf_free); 680 - EXPORT_SYMBOL(capi_cmsg2message); 681 - EXPORT_SYMBOL(capi_message2cmsg); 682 - EXPORT_SYMBOL(capi_cmsg_header); 683 - EXPORT_SYMBOL(capi_cmd2str); 684 - EXPORT_SYMBOL(capi_cmsg2str); 685 - EXPORT_SYMBOL(capi_message2str);
+11 -404
drivers/isdn/capi/kcapi.c
··· 10 10 * 11 11 */ 12 12 13 - #define AVMB1_COMPAT 14 - 15 13 #include "kcapi.h" 16 14 #include <linux/module.h> 17 15 #include <linux/mm.h> ··· 29 31 #include <linux/uaccess.h> 30 32 #include <linux/isdn/capicmd.h> 31 33 #include <linux/isdn/capiutil.h> 32 - #ifdef AVMB1_COMPAT 33 - #include <linux/b1lli.h> 34 - #endif 35 34 #include <linux/mutex.h> 36 35 #include <linux/rcupdate.h> 37 36 38 37 static int showcapimsgs = 0; 39 38 static struct workqueue_struct *kcapi_wq; 40 39 41 - MODULE_DESCRIPTION("CAPI4Linux: kernel CAPI layer"); 42 - MODULE_AUTHOR("Carsten Paeth"); 43 - MODULE_LICENSE("GPL"); 44 40 module_param(showcapimsgs, uint, 0); 45 41 46 42 /* ------------------------------------------------------------- */ ··· 53 61 54 62 #define NCCI2CTRL(ncci) (((ncci) >> 24) & 0x7f) 55 63 56 - LIST_HEAD(capi_drivers); 57 - DEFINE_MUTEX(capi_drivers_lock); 58 - 59 64 struct capi_ctr *capi_controller[CAPI_MAXCONTR]; 60 65 DEFINE_MUTEX(capi_controller_lock); 61 66 62 67 struct capi20_appl *capi_applications[CAPI_MAXAPPL]; 63 68 64 69 static int ncontrollers; 65 - 66 - static BLOCKING_NOTIFIER_HEAD(ctr_notifier_list); 67 70 68 71 /* -------- controller ref counting -------------------------------------- */ 69 72 ··· 187 200 if (ap) 188 201 register_appl(ctr, applid, &ap->rparam); 189 202 } 190 - 191 - wake_up_interruptible_all(&ctr->state_wait_queue); 192 203 } else 193 204 printk(KERN_WARNING "%s: invalid contr %d\n", __func__, contr); 194 205 ··· 214 229 if (ap) 215 230 capi_ctr_put(ctr); 216 231 } 217 - 218 - wake_up_interruptible_all(&ctr->state_wait_queue); 219 232 } 220 233 221 234 static void notify_down(u32 contr) ··· 234 251 mutex_unlock(&capi_controller_lock); 235 252 } 236 253 237 - static int 238 - notify_handler(struct notifier_block *nb, unsigned long val, void *v) 239 - { 240 - u32 contr = (long)v; 241 - 242 - switch (val) { 243 - case CAPICTR_UP: 244 - notify_up(contr); 245 - break; 246 - case CAPICTR_DOWN: 247 - notify_down(contr); 248 - break; 249 - } 250 - return NOTIFY_OK; 251 - } 252 - 253 254 static void do_notify_work(struct work_struct *work) 254 255 { 255 256 struct capictr_event *event = 256 257 container_of(work, struct capictr_event, work); 257 258 258 - blocking_notifier_call_chain(&ctr_notifier_list, event->type, 259 - (void *)(long)event->controller); 259 + switch (event->type) { 260 + case CAPICTR_UP: 261 + notify_up(event->controller); 262 + break; 263 + case CAPICTR_DOWN: 264 + notify_down(event->controller); 265 + break; 266 + } 267 + 260 268 kfree(event); 261 269 } 262 270 263 - /* 264 - * The notifier will result in adding/deleteing of devices. Devices can 265 - * only removed in user process, not in bh. 266 - */ 267 271 static int notify_push(unsigned int event_type, u32 controller) 268 272 { 269 273 struct capictr_event *event = kmalloc(sizeof(*event), GFP_ATOMIC); ··· 265 295 queue_work(kcapi_wq, &event->work); 266 296 return 0; 267 297 } 268 - 269 - int register_capictr_notifier(struct notifier_block *nb) 270 - { 271 - return blocking_notifier_chain_register(&ctr_notifier_list, nb); 272 - } 273 - EXPORT_SYMBOL_GPL(register_capictr_notifier); 274 - 275 - int unregister_capictr_notifier(struct notifier_block *nb) 276 - { 277 - return blocking_notifier_chain_unregister(&ctr_notifier_list, nb); 278 - } 279 - EXPORT_SYMBOL_GPL(unregister_capictr_notifier); 280 298 281 299 /* -------- Receiver ------------------------------------------ */ 282 300 ··· 412 454 413 455 EXPORT_SYMBOL(capi_ctr_down); 414 456 415 - /** 416 - * capi_ctr_suspend_output() - suspend controller 417 - * @ctr: controller descriptor structure. 418 - * 419 - * Called by hardware driver to stop data flow. 420 - * 421 - * Note: The caller is responsible for synchronizing concurrent state changes 422 - * as well as invocations of capi_ctr_handle_message. 423 - */ 424 - 425 - void capi_ctr_suspend_output(struct capi_ctr *ctr) 426 - { 427 - if (!ctr->blocked) { 428 - printk(KERN_DEBUG "kcapi: controller [%03d] suspend\n", 429 - ctr->cnr); 430 - ctr->blocked = 1; 431 - } 432 - } 433 - 434 - EXPORT_SYMBOL(capi_ctr_suspend_output); 435 - 436 - /** 437 - * capi_ctr_resume_output() - resume controller 438 - * @ctr: controller descriptor structure. 439 - * 440 - * Called by hardware driver to resume data flow. 441 - * 442 - * Note: The caller is responsible for synchronizing concurrent state changes 443 - * as well as invocations of capi_ctr_handle_message. 444 - */ 445 - 446 - void capi_ctr_resume_output(struct capi_ctr *ctr) 447 - { 448 - if (ctr->blocked) { 449 - printk(KERN_DEBUG "kcapi: controller [%03d] resumed\n", 450 - ctr->cnr); 451 - ctr->blocked = 0; 452 - } 453 - } 454 - 455 - EXPORT_SYMBOL(capi_ctr_resume_output); 456 - 457 457 /* ------------------------------------------------------------- */ 458 458 459 459 /** ··· 447 531 ctr->state = CAPI_CTR_DETECTED; 448 532 ctr->blocked = 0; 449 533 ctr->traceflag = showcapimsgs; 450 - init_waitqueue_head(&ctr->state_wait_queue); 451 534 452 535 sprintf(ctr->procfn, "capi/controllers/%d", ctr->cnr); 453 536 ctr->procent = proc_create_single_data(ctr->procfn, 0, NULL, ··· 501 586 502 587 EXPORT_SYMBOL(detach_capi_ctr); 503 588 504 - /** 505 - * register_capi_driver() - register CAPI driver 506 - * @driver: driver descriptor structure. 507 - * 508 - * Called by hardware driver to register itself with the CAPI subsystem. 509 - */ 510 - 511 - void register_capi_driver(struct capi_driver *driver) 512 - { 513 - mutex_lock(&capi_drivers_lock); 514 - list_add_tail(&driver->list, &capi_drivers); 515 - mutex_unlock(&capi_drivers_lock); 516 - } 517 - 518 - EXPORT_SYMBOL(register_capi_driver); 519 - 520 - /** 521 - * unregister_capi_driver() - unregister CAPI driver 522 - * @driver: driver descriptor structure. 523 - * 524 - * Called by hardware driver to unregister itself from the CAPI subsystem. 525 - */ 526 - 527 - void unregister_capi_driver(struct capi_driver *driver) 528 - { 529 - mutex_lock(&capi_drivers_lock); 530 - list_del(&driver->list); 531 - mutex_unlock(&capi_drivers_lock); 532 - } 533 - 534 - EXPORT_SYMBOL(unregister_capi_driver); 535 - 536 589 /* ------------------------------------------------------------- */ 537 590 /* -------- CAPI2.0 Interface ---------------------------------- */ 538 591 /* ------------------------------------------------------------- */ ··· 530 647 531 648 return ret; 532 649 } 533 - 534 - EXPORT_SYMBOL(capi20_isinstalled); 535 650 536 651 /** 537 652 * capi20_register() - CAPI 2.0 operation CAPI_REGISTER ··· 592 711 return CAPI_NOERROR; 593 712 } 594 713 595 - EXPORT_SYMBOL(capi20_register); 596 - 597 714 /** 598 715 * capi20_release() - CAPI 2.0 operation CAPI_RELEASE 599 716 * @ap: CAPI application descriptor structure. ··· 633 754 634 755 return CAPI_NOERROR; 635 756 } 636 - 637 - EXPORT_SYMBOL(capi20_release); 638 757 639 758 /** 640 759 * capi20_put_message() - CAPI 2.0 operation CAPI_PUT_MESSAGE ··· 711 834 return ctr->send_message(ctr, skb); 712 835 } 713 836 714 - EXPORT_SYMBOL(capi20_put_message); 715 - 716 837 /** 717 838 * capi20_get_manufacturer() - CAPI 2.0 operation CAPI_GET_MANUFACTURER 718 839 * @contr: controller number. ··· 743 868 mutex_unlock(&capi_controller_lock); 744 869 return ret; 745 870 } 746 - 747 - EXPORT_SYMBOL(capi20_get_manufacturer); 748 871 749 872 /** 750 873 * capi20_get_version() - CAPI 2.0 operation CAPI_GET_VERSION ··· 777 904 return ret; 778 905 } 779 906 780 - EXPORT_SYMBOL(capi20_get_version); 781 - 782 907 /** 783 908 * capi20_get_serial() - CAPI 2.0 operation CAPI_GET_SERIAL_NUMBER 784 909 * @contr: controller number. ··· 809 938 mutex_unlock(&capi_controller_lock); 810 939 return ret; 811 940 } 812 - 813 - EXPORT_SYMBOL(capi20_get_serial); 814 941 815 942 /** 816 943 * capi20_get_profile() - CAPI 2.0 operation CAPI_GET_PROFILE ··· 843 974 return ret; 844 975 } 845 976 846 - EXPORT_SYMBOL(capi20_get_profile); 847 - 848 - /* Must be called with capi_controller_lock held. */ 849 - static int wait_on_ctr_state(struct capi_ctr *ctr, unsigned int state) 850 - { 851 - DEFINE_WAIT(wait); 852 - int retval = 0; 853 - 854 - ctr = capi_ctr_get(ctr); 855 - if (!ctr) 856 - return -ESRCH; 857 - 858 - for (;;) { 859 - prepare_to_wait(&ctr->state_wait_queue, &wait, 860 - TASK_INTERRUPTIBLE); 861 - 862 - if (ctr->state == state) 863 - break; 864 - if (ctr->state == CAPI_CTR_DETACHED) { 865 - retval = -ESRCH; 866 - break; 867 - } 868 - if (signal_pending(current)) { 869 - retval = -EINTR; 870 - break; 871 - } 872 - 873 - mutex_unlock(&capi_controller_lock); 874 - schedule(); 875 - mutex_lock(&capi_controller_lock); 876 - } 877 - finish_wait(&ctr->state_wait_queue, &wait); 878 - 879 - capi_ctr_put(ctr); 880 - 881 - return retval; 882 - } 883 - 884 - #ifdef AVMB1_COMPAT 885 - static int old_capi_manufacturer(unsigned int cmd, void __user *data) 886 - { 887 - avmb1_loadandconfigdef ldef; 888 - avmb1_extcarddef cdef; 889 - avmb1_resetdef rdef; 890 - capicardparams cparams; 891 - struct capi_ctr *ctr; 892 - struct capi_driver *driver = NULL; 893 - capiloaddata ldata; 894 - struct list_head *l; 895 - int retval; 896 - 897 - switch (cmd) { 898 - case AVMB1_ADDCARD: 899 - case AVMB1_ADDCARD_WITH_TYPE: 900 - if (cmd == AVMB1_ADDCARD) { 901 - if ((retval = copy_from_user(&cdef, data, 902 - sizeof(avmb1_carddef)))) 903 - return -EFAULT; 904 - cdef.cardtype = AVM_CARDTYPE_B1; 905 - cdef.cardnr = 0; 906 - } else { 907 - if ((retval = copy_from_user(&cdef, data, 908 - sizeof(avmb1_extcarddef)))) 909 - return -EFAULT; 910 - } 911 - cparams.port = cdef.port; 912 - cparams.irq = cdef.irq; 913 - cparams.cardnr = cdef.cardnr; 914 - 915 - mutex_lock(&capi_drivers_lock); 916 - 917 - switch (cdef.cardtype) { 918 - case AVM_CARDTYPE_B1: 919 - list_for_each(l, &capi_drivers) { 920 - driver = list_entry(l, struct capi_driver, list); 921 - if (strcmp(driver->name, "b1isa") == 0) 922 - break; 923 - } 924 - break; 925 - case AVM_CARDTYPE_T1: 926 - list_for_each(l, &capi_drivers) { 927 - driver = list_entry(l, struct capi_driver, list); 928 - if (strcmp(driver->name, "t1isa") == 0) 929 - break; 930 - } 931 - break; 932 - default: 933 - driver = NULL; 934 - break; 935 - } 936 - if (!driver) { 937 - printk(KERN_ERR "kcapi: driver not loaded.\n"); 938 - retval = -EIO; 939 - } else if (!driver->add_card) { 940 - printk(KERN_ERR "kcapi: driver has no add card function.\n"); 941 - retval = -EIO; 942 - } else 943 - retval = driver->add_card(driver, &cparams); 944 - 945 - mutex_unlock(&capi_drivers_lock); 946 - return retval; 947 - 948 - case AVMB1_LOAD: 949 - case AVMB1_LOAD_AND_CONFIG: 950 - 951 - if (cmd == AVMB1_LOAD) { 952 - if (copy_from_user(&ldef, data, 953 - sizeof(avmb1_loaddef))) 954 - return -EFAULT; 955 - ldef.t4config.len = 0; 956 - ldef.t4config.data = NULL; 957 - } else { 958 - if (copy_from_user(&ldef, data, 959 - sizeof(avmb1_loadandconfigdef))) 960 - return -EFAULT; 961 - } 962 - 963 - mutex_lock(&capi_controller_lock); 964 - 965 - ctr = get_capi_ctr_by_nr(ldef.contr); 966 - if (!ctr) { 967 - retval = -EINVAL; 968 - goto load_unlock_out; 969 - } 970 - 971 - if (ctr->load_firmware == NULL) { 972 - printk(KERN_DEBUG "kcapi: load: no load function\n"); 973 - retval = -ESRCH; 974 - goto load_unlock_out; 975 - } 976 - 977 - if (ldef.t4file.len <= 0) { 978 - printk(KERN_DEBUG "kcapi: load: invalid parameter: length of t4file is %d ?\n", ldef.t4file.len); 979 - retval = -EINVAL; 980 - goto load_unlock_out; 981 - } 982 - if (ldef.t4file.data == NULL) { 983 - printk(KERN_DEBUG "kcapi: load: invalid parameter: dataptr is 0\n"); 984 - retval = -EINVAL; 985 - goto load_unlock_out; 986 - } 987 - 988 - ldata.firmware.user = 1; 989 - ldata.firmware.data = ldef.t4file.data; 990 - ldata.firmware.len = ldef.t4file.len; 991 - ldata.configuration.user = 1; 992 - ldata.configuration.data = ldef.t4config.data; 993 - ldata.configuration.len = ldef.t4config.len; 994 - 995 - if (ctr->state != CAPI_CTR_DETECTED) { 996 - printk(KERN_INFO "kcapi: load: contr=%d not in detect state\n", ldef.contr); 997 - retval = -EBUSY; 998 - goto load_unlock_out; 999 - } 1000 - ctr->state = CAPI_CTR_LOADING; 1001 - 1002 - retval = ctr->load_firmware(ctr, &ldata); 1003 - if (retval) { 1004 - ctr->state = CAPI_CTR_DETECTED; 1005 - goto load_unlock_out; 1006 - } 1007 - 1008 - retval = wait_on_ctr_state(ctr, CAPI_CTR_RUNNING); 1009 - 1010 - load_unlock_out: 1011 - mutex_unlock(&capi_controller_lock); 1012 - return retval; 1013 - 1014 - case AVMB1_RESETCARD: 1015 - if (copy_from_user(&rdef, data, sizeof(avmb1_resetdef))) 1016 - return -EFAULT; 1017 - 1018 - retval = 0; 1019 - 1020 - mutex_lock(&capi_controller_lock); 1021 - 1022 - ctr = get_capi_ctr_by_nr(rdef.contr); 1023 - if (!ctr) { 1024 - retval = -ESRCH; 1025 - goto reset_unlock_out; 1026 - } 1027 - 1028 - if (ctr->state == CAPI_CTR_DETECTED) 1029 - goto reset_unlock_out; 1030 - 1031 - if (ctr->reset_ctr == NULL) { 1032 - printk(KERN_DEBUG "kcapi: reset: no reset function\n"); 1033 - retval = -ESRCH; 1034 - goto reset_unlock_out; 1035 - } 1036 - 1037 - ctr->reset_ctr(ctr); 1038 - 1039 - retval = wait_on_ctr_state(ctr, CAPI_CTR_DETECTED); 1040 - 1041 - reset_unlock_out: 1042 - mutex_unlock(&capi_controller_lock); 1043 - return retval; 1044 - } 1045 - return -EINVAL; 1046 - } 1047 - #endif 1048 - 1049 977 /** 1050 978 * capi20_manufacturer() - CAPI 2.0 operation CAPI_MANUFACTURER 1051 979 * @cmd: command. ··· 858 1192 int retval; 859 1193 860 1194 switch (cmd) { 861 - #ifdef AVMB1_COMPAT 862 - case AVMB1_LOAD: 863 - case AVMB1_LOAD_AND_CONFIG: 864 - case AVMB1_RESETCARD: 865 - case AVMB1_GET_CARDINFO: 866 - case AVMB1_REMOVECARD: 867 - return old_capi_manufacturer(cmd, data); 868 - #endif 869 1195 case KCAPI_CMD_TRACE: 870 1196 { 871 1197 kcapi_flagdef fdef; ··· 880 1222 881 1223 return retval; 882 1224 } 883 - case KCAPI_CMD_ADDCARD: 884 - { 885 - struct list_head *l; 886 - struct capi_driver *driver = NULL; 887 - capicardparams cparams; 888 - kcapi_carddef cdef; 889 - 890 - if ((retval = copy_from_user(&cdef, data, sizeof(cdef)))) 891 - return -EFAULT; 892 - 893 - cparams.port = cdef.port; 894 - cparams.irq = cdef.irq; 895 - cparams.membase = cdef.membase; 896 - cparams.cardnr = cdef.cardnr; 897 - cparams.cardtype = 0; 898 - cdef.driver[sizeof(cdef.driver) - 1] = 0; 899 - 900 - mutex_lock(&capi_drivers_lock); 901 - 902 - list_for_each(l, &capi_drivers) { 903 - driver = list_entry(l, struct capi_driver, list); 904 - if (strcmp(driver->name, cdef.driver) == 0) 905 - break; 906 - } 907 - if (driver == NULL) { 908 - printk(KERN_ERR "kcapi: driver \"%s\" not loaded.\n", 909 - cdef.driver); 910 - retval = -ESRCH; 911 - } else if (!driver->add_card) { 912 - printk(KERN_ERR "kcapi: driver \"%s\" has no add card function.\n", cdef.driver); 913 - retval = -EIO; 914 - } else 915 - retval = driver->add_card(driver, &cparams); 916 - 917 - mutex_unlock(&capi_drivers_lock); 918 - return retval; 919 - } 920 1225 921 1226 default: 922 1227 printk(KERN_ERR "kcapi: manufacturer command %lu unknown.\n", ··· 890 1269 return -EINVAL; 891 1270 } 892 1271 893 - EXPORT_SYMBOL(capi20_manufacturer); 894 - 895 1272 /* ------------------------------------------------------------- */ 896 1273 /* -------- Init & Cleanup ------------------------------------- */ 897 1274 /* ------------------------------------------------------------- */ ··· 898 1279 * init / exit functions 899 1280 */ 900 1281 901 - static struct notifier_block capictr_nb = { 902 - .notifier_call = notify_handler, 903 - .priority = INT_MAX, 904 - }; 905 - 906 - static int __init kcapi_init(void) 1282 + int __init kcapi_init(void) 907 1283 { 908 1284 int err; 909 1285 ··· 906 1292 if (!kcapi_wq) 907 1293 return -ENOMEM; 908 1294 909 - register_capictr_notifier(&capictr_nb); 910 - 911 1295 err = cdebug_init(); 912 1296 if (err) { 913 - unregister_capictr_notifier(&capictr_nb); 914 1297 destroy_workqueue(kcapi_wq); 915 1298 return err; 916 1299 } ··· 916 1305 return 0; 917 1306 } 918 1307 919 - static void __exit kcapi_exit(void) 1308 + void kcapi_exit(void) 920 1309 { 921 1310 kcapi_proc_exit(); 922 1311 923 - unregister_capictr_notifier(&capictr_nb); 924 1312 cdebug_exit(); 925 1313 destroy_workqueue(kcapi_wq); 926 1314 } 927 - 928 - module_init(kcapi_init); 929 - module_exit(kcapi_exit);
+140 -9
drivers/isdn/capi/kcapi.h
··· 30 30 CAPI_CTR_RUNNING = 3, 31 31 }; 32 32 33 - extern struct list_head capi_drivers; 34 - extern struct mutex capi_drivers_lock; 35 - 36 33 extern struct capi_ctr *capi_controller[CAPI_MAXCONTR]; 37 34 extern struct mutex capi_controller_lock; 38 35 39 36 extern struct capi20_appl *capi_applications[CAPI_MAXAPPL]; 40 37 41 - #ifdef CONFIG_PROC_FS 42 - 43 38 void kcapi_proc_init(void); 44 39 void kcapi_proc_exit(void); 45 40 46 - #else 41 + struct capi20_appl { 42 + u16 applid; 43 + capi_register_params rparam; 44 + void (*recv_message)(struct capi20_appl *ap, struct sk_buff *skb); 45 + void *private; 47 46 48 - static inline void kcapi_proc_init(void) { }; 49 - static inline void kcapi_proc_exit(void) { }; 47 + /* internal to kernelcapi.o */ 48 + unsigned long nrecvctlpkt; 49 + unsigned long nrecvdatapkt; 50 + unsigned long nsentctlpkt; 51 + unsigned long nsentdatapkt; 52 + struct mutex recv_mtx; 53 + struct sk_buff_head recv_queue; 54 + struct work_struct recv_work; 55 + int release_in_progress; 56 + }; 50 57 51 - #endif 58 + u16 capi20_isinstalled(void); 59 + u16 capi20_register(struct capi20_appl *ap); 60 + u16 capi20_release(struct capi20_appl *ap); 61 + u16 capi20_put_message(struct capi20_appl *ap, struct sk_buff *skb); 62 + u16 capi20_get_manufacturer(u32 contr, u8 buf[CAPI_MANUFACTURER_LEN]); 63 + u16 capi20_get_version(u32 contr, struct capi_version *verp); 64 + u16 capi20_get_serial(u32 contr, u8 serial[CAPI_SERIAL_LEN]); 65 + u16 capi20_get_profile(u32 contr, struct capi_profile *profp); 66 + int capi20_manufacturer(unsigned long cmd, void __user *data); 67 + 68 + #define CAPICTR_UP 0 69 + #define CAPICTR_DOWN 1 70 + 71 + int kcapi_init(void); 72 + void kcapi_exit(void); 73 + 74 + /*----- basic-type definitions -----*/ 75 + 76 + typedef __u8 *_cstruct; 77 + 78 + typedef enum { 79 + CAPI_COMPOSE, 80 + CAPI_DEFAULT 81 + } _cmstruct; 82 + 83 + /* 84 + The _cmsg structure contains all possible CAPI 2.0 parameter. 85 + All parameters are stored here first. The function CAPI_CMSG_2_MESSAGE 86 + assembles the parameter and builds CAPI2.0 conform messages. 87 + CAPI_MESSAGE_2_CMSG disassembles CAPI 2.0 messages and stores the 88 + parameter in the _cmsg structure 89 + */ 90 + 91 + typedef struct { 92 + /* Header */ 93 + __u16 ApplId; 94 + __u8 Command; 95 + __u8 Subcommand; 96 + __u16 Messagenumber; 97 + 98 + /* Parameter */ 99 + union { 100 + __u32 adrController; 101 + __u32 adrPLCI; 102 + __u32 adrNCCI; 103 + } adr; 104 + 105 + _cmstruct AdditionalInfo; 106 + _cstruct B1configuration; 107 + __u16 B1protocol; 108 + _cstruct B2configuration; 109 + __u16 B2protocol; 110 + _cstruct B3configuration; 111 + __u16 B3protocol; 112 + _cstruct BC; 113 + _cstruct BChannelinformation; 114 + _cmstruct BProtocol; 115 + _cstruct CalledPartyNumber; 116 + _cstruct CalledPartySubaddress; 117 + _cstruct CallingPartyNumber; 118 + _cstruct CallingPartySubaddress; 119 + __u32 CIPmask; 120 + __u32 CIPmask2; 121 + __u16 CIPValue; 122 + __u32 Class; 123 + _cstruct ConnectedNumber; 124 + _cstruct ConnectedSubaddress; 125 + __u32 Data; 126 + __u16 DataHandle; 127 + __u16 DataLength; 128 + _cstruct FacilityConfirmationParameter; 129 + _cstruct Facilitydataarray; 130 + _cstruct FacilityIndicationParameter; 131 + _cstruct FacilityRequestParameter; 132 + __u16 FacilitySelector; 133 + __u16 Flags; 134 + __u32 Function; 135 + _cstruct HLC; 136 + __u16 Info; 137 + _cstruct InfoElement; 138 + __u32 InfoMask; 139 + __u16 InfoNumber; 140 + _cstruct Keypadfacility; 141 + _cstruct LLC; 142 + _cstruct ManuData; 143 + __u32 ManuID; 144 + _cstruct NCPI; 145 + __u16 Reason; 146 + __u16 Reason_B3; 147 + __u16 Reject; 148 + _cstruct Useruserdata; 149 + 150 + /* intern */ 151 + unsigned l, p; 152 + unsigned char *par; 153 + __u8 *m; 154 + 155 + /* buffer to construct message */ 156 + __u8 buf[180]; 157 + 158 + } _cmsg; 159 + 160 + /*-----------------------------------------------------------------------*/ 161 + 162 + /* 163 + * Debugging / Tracing functions 164 + */ 165 + 166 + char *capi_cmd2str(__u8 cmd, __u8 subcmd); 167 + 168 + typedef struct { 169 + u_char *buf; 170 + u_char *p; 171 + size_t size; 172 + size_t pos; 173 + } _cdebbuf; 174 + 175 + #define CDEBUG_SIZE 1024 176 + #define CDEBUG_GSIZE 4096 177 + 178 + void cdebbuf_free(_cdebbuf *cdb); 179 + int cdebug_init(void); 180 + void cdebug_exit(void); 181 + 182 + _cdebbuf *capi_message2str(__u8 *msg);
+6 -28
drivers/isdn/capi/kcapi_proc.c
··· 192 192 193 193 // --------------------------------------------------------------------------- 194 194 195 - static void *capi_driver_start(struct seq_file *seq, loff_t *pos) 196 - __acquires(&capi_drivers_lock) 195 + /* /proc/capi/drivers is always empty */ 196 + static ssize_t empty_read(struct file *file, char __user *buf, 197 + size_t size, loff_t *off) 197 198 { 198 - mutex_lock(&capi_drivers_lock); 199 - return seq_list_start(&capi_drivers, *pos); 200 - } 201 - 202 - static void *capi_driver_next(struct seq_file *seq, void *v, loff_t *pos) 203 - { 204 - return seq_list_next(v, &capi_drivers, pos); 205 - } 206 - 207 - static void capi_driver_stop(struct seq_file *seq, void *v) 208 - __releases(&capi_drivers_lock) 209 - { 210 - mutex_unlock(&capi_drivers_lock); 211 - } 212 - 213 - static int capi_driver_show(struct seq_file *seq, void *v) 214 - { 215 - struct capi_driver *drv = list_entry(v, struct capi_driver, list); 216 - 217 - seq_printf(seq, "%-32s %s\n", drv->name, drv->revision); 218 199 return 0; 219 200 } 220 201 221 - static const struct seq_operations seq_capi_driver_ops = { 222 - .start = capi_driver_start, 223 - .next = capi_driver_next, 224 - .stop = capi_driver_stop, 225 - .show = capi_driver_show, 202 + static const struct file_operations empty_fops = { 203 + .read = empty_read, 226 204 }; 227 205 228 206 // --------------------------------------------------------------------------- ··· 214 236 proc_create_seq("capi/contrstats", 0, NULL, &seq_contrstats_ops); 215 237 proc_create_seq("capi/applications", 0, NULL, &seq_applications_ops); 216 238 proc_create_seq("capi/applstats", 0, NULL, &seq_applstats_ops); 217 - proc_create_seq("capi/driver", 0, NULL, &seq_capi_driver_ops); 239 + proc_create("capi/driver", 0, NULL, &empty_fops); 218 240 } 219 241 220 242 void __exit
-18
include/linux/isdn/capilli.h
··· 69 69 unsigned short state; /* controller state */ 70 70 int blocked; /* output blocked */ 71 71 int traceflag; /* capi trace */ 72 - wait_queue_head_t state_wait_queue; 73 72 74 73 struct proc_dir_entry *procent; 75 74 char procfn[128]; ··· 79 80 80 81 void capi_ctr_ready(struct capi_ctr * card); 81 82 void capi_ctr_down(struct capi_ctr * card); 82 - void capi_ctr_suspend_output(struct capi_ctr * card); 83 - void capi_ctr_resume_output(struct capi_ctr * card); 84 83 void capi_ctr_handle_message(struct capi_ctr * card, u16 appl, struct sk_buff *skb); 85 84 86 85 // --------------------------------------------------------------------------- ··· 88 91 char name[32]; /* driver name */ 89 92 char revision[32]; 90 93 91 - int (*add_card)(struct capi_driver *driver, capicardparams *data); 92 - 93 94 /* management information for kcapi */ 94 95 struct list_head list; 95 96 }; 96 - 97 - void register_capi_driver(struct capi_driver *driver); 98 - void unregister_capi_driver(struct capi_driver *driver); 99 - 100 - // --------------------------------------------------------------------------- 101 - // library functions for use by hardware controller drivers 102 - 103 - void capilib_new_ncci(struct list_head *head, u16 applid, u32 ncci, u32 winsize); 104 - void capilib_free_ncci(struct list_head *head, u16 applid, u32 ncci); 105 - void capilib_release_appl(struct list_head *head, u16 applid); 106 - void capilib_release(struct list_head *head); 107 - void capilib_data_b3_conf(struct list_head *head, u16 applid, u32 ncci, u16 msgid); 108 - u16 capilib_data_b3_req(struct list_head *head, u16 applid, u32 ncci, u16 msgid); 109 97 110 98 #endif /* __CAPILLI_H__ */
-456
include/linux/isdn/capiutil.h
··· 57 57 #define CAPIMSG_SETCONTROL(m, contr) capimsg_setu32(m, 8, contr) 58 58 #define CAPIMSG_SETDATALEN(m, len) capimsg_setu16(m, 16, len) 59 59 60 - /*----- basic-type definitions -----*/ 61 - 62 - typedef __u8 *_cstruct; 63 - 64 - typedef enum { 65 - CAPI_COMPOSE, 66 - CAPI_DEFAULT 67 - } _cmstruct; 68 - 69 - /* 70 - The _cmsg structure contains all possible CAPI 2.0 parameter. 71 - All parameters are stored here first. The function CAPI_CMSG_2_MESSAGE 72 - assembles the parameter and builds CAPI2.0 conform messages. 73 - CAPI_MESSAGE_2_CMSG disassembles CAPI 2.0 messages and stores the 74 - parameter in the _cmsg structure 75 - */ 76 - 77 - typedef struct { 78 - /* Header */ 79 - __u16 ApplId; 80 - __u8 Command; 81 - __u8 Subcommand; 82 - __u16 Messagenumber; 83 - 84 - /* Parameter */ 85 - union { 86 - __u32 adrController; 87 - __u32 adrPLCI; 88 - __u32 adrNCCI; 89 - } adr; 90 - 91 - _cmstruct AdditionalInfo; 92 - _cstruct B1configuration; 93 - __u16 B1protocol; 94 - _cstruct B2configuration; 95 - __u16 B2protocol; 96 - _cstruct B3configuration; 97 - __u16 B3protocol; 98 - _cstruct BC; 99 - _cstruct BChannelinformation; 100 - _cmstruct BProtocol; 101 - _cstruct CalledPartyNumber; 102 - _cstruct CalledPartySubaddress; 103 - _cstruct CallingPartyNumber; 104 - _cstruct CallingPartySubaddress; 105 - __u32 CIPmask; 106 - __u32 CIPmask2; 107 - __u16 CIPValue; 108 - __u32 Class; 109 - _cstruct ConnectedNumber; 110 - _cstruct ConnectedSubaddress; 111 - __u32 Data; 112 - __u16 DataHandle; 113 - __u16 DataLength; 114 - _cstruct FacilityConfirmationParameter; 115 - _cstruct Facilitydataarray; 116 - _cstruct FacilityIndicationParameter; 117 - _cstruct FacilityRequestParameter; 118 - __u16 FacilitySelector; 119 - __u16 Flags; 120 - __u32 Function; 121 - _cstruct HLC; 122 - __u16 Info; 123 - _cstruct InfoElement; 124 - __u32 InfoMask; 125 - __u16 InfoNumber; 126 - _cstruct Keypadfacility; 127 - _cstruct LLC; 128 - _cstruct ManuData; 129 - __u32 ManuID; 130 - _cstruct NCPI; 131 - __u16 Reason; 132 - __u16 Reason_B3; 133 - __u16 Reject; 134 - _cstruct Useruserdata; 135 - 136 - /* intern */ 137 - unsigned l, p; 138 - unsigned char *par; 139 - __u8 *m; 140 - 141 - /* buffer to construct message */ 142 - __u8 buf[180]; 143 - 144 - } _cmsg; 145 - 146 - /* 147 - * capi_cmsg2message() assembles the parameter from _cmsg to a CAPI 2.0 148 - * conform message 149 - */ 150 - unsigned capi_cmsg2message(_cmsg * cmsg, __u8 * msg); 151 - 152 - /* 153 - * capi_message2cmsg disassembles a CAPI message an writes the parameter 154 - * into _cmsg for easy access 155 - */ 156 - unsigned capi_message2cmsg(_cmsg * cmsg, __u8 * msg); 157 - 158 - /* 159 - * capi_cmsg_header() fills the _cmsg structure with default values, so only 160 - * parameter with non default values must be changed before sending the 161 - * message. 162 - */ 163 - unsigned capi_cmsg_header(_cmsg * cmsg, __u16 _ApplId, 164 - __u8 _Command, __u8 _Subcommand, 165 - __u16 _Messagenumber, __u32 _Controller); 166 - 167 - /*-----------------------------------------------------------------------*/ 168 - 169 - /* 170 - * Debugging / Tracing functions 171 - */ 172 - 173 - char *capi_cmd2str(__u8 cmd, __u8 subcmd); 174 - 175 - typedef struct { 176 - u_char *buf; 177 - u_char *p; 178 - size_t size; 179 - size_t pos; 180 - } _cdebbuf; 181 - 182 - #define CDEBUG_SIZE 1024 183 - #define CDEBUG_GSIZE 4096 184 - 185 - void cdebbuf_free(_cdebbuf *cdb); 186 - int cdebug_init(void); 187 - void cdebug_exit(void); 188 - 189 - _cdebbuf *capi_cmsg2str(_cmsg *cmsg); 190 - _cdebbuf *capi_message2str(__u8 *msg); 191 - 192 - /*-----------------------------------------------------------------------*/ 193 - 194 - static inline void capi_cmsg_answer(_cmsg * cmsg) 195 - { 196 - cmsg->Subcommand |= 0x01; 197 - } 198 - 199 - /*-----------------------------------------------------------------------*/ 200 - 201 - static inline void capi_fill_CONNECT_B3_REQ(_cmsg * cmsg, __u16 ApplId, __u16 Messagenumber, 202 - __u32 adr, 203 - _cstruct NCPI) 204 - { 205 - capi_cmsg_header(cmsg, ApplId, 0x82, 0x80, Messagenumber, adr); 206 - cmsg->NCPI = NCPI; 207 - } 208 - 209 - static inline void capi_fill_FACILITY_REQ(_cmsg * cmsg, __u16 ApplId, __u16 Messagenumber, 210 - __u32 adr, 211 - __u16 FacilitySelector, 212 - _cstruct FacilityRequestParameter) 213 - { 214 - capi_cmsg_header(cmsg, ApplId, 0x80, 0x80, Messagenumber, adr); 215 - cmsg->FacilitySelector = FacilitySelector; 216 - cmsg->FacilityRequestParameter = FacilityRequestParameter; 217 - } 218 - 219 - static inline void capi_fill_INFO_REQ(_cmsg * cmsg, __u16 ApplId, __u16 Messagenumber, 220 - __u32 adr, 221 - _cstruct CalledPartyNumber, 222 - _cstruct BChannelinformation, 223 - _cstruct Keypadfacility, 224 - _cstruct Useruserdata, 225 - _cstruct Facilitydataarray) 226 - { 227 - capi_cmsg_header(cmsg, ApplId, 0x08, 0x80, Messagenumber, adr); 228 - cmsg->CalledPartyNumber = CalledPartyNumber; 229 - cmsg->BChannelinformation = BChannelinformation; 230 - cmsg->Keypadfacility = Keypadfacility; 231 - cmsg->Useruserdata = Useruserdata; 232 - cmsg->Facilitydataarray = Facilitydataarray; 233 - } 234 - 235 - static inline void capi_fill_LISTEN_REQ(_cmsg * cmsg, __u16 ApplId, __u16 Messagenumber, 236 - __u32 adr, 237 - __u32 InfoMask, 238 - __u32 CIPmask, 239 - __u32 CIPmask2, 240 - _cstruct CallingPartyNumber, 241 - _cstruct CallingPartySubaddress) 242 - { 243 - capi_cmsg_header(cmsg, ApplId, 0x05, 0x80, Messagenumber, adr); 244 - cmsg->InfoMask = InfoMask; 245 - cmsg->CIPmask = CIPmask; 246 - cmsg->CIPmask2 = CIPmask2; 247 - cmsg->CallingPartyNumber = CallingPartyNumber; 248 - cmsg->CallingPartySubaddress = CallingPartySubaddress; 249 - } 250 - 251 - static inline void capi_fill_ALERT_REQ(_cmsg * cmsg, __u16 ApplId, __u16 Messagenumber, 252 - __u32 adr, 253 - _cstruct BChannelinformation, 254 - _cstruct Keypadfacility, 255 - _cstruct Useruserdata, 256 - _cstruct Facilitydataarray) 257 - { 258 - capi_cmsg_header(cmsg, ApplId, 0x01, 0x80, Messagenumber, adr); 259 - cmsg->BChannelinformation = BChannelinformation; 260 - cmsg->Keypadfacility = Keypadfacility; 261 - cmsg->Useruserdata = Useruserdata; 262 - cmsg->Facilitydataarray = Facilitydataarray; 263 - } 264 - 265 - static inline void capi_fill_CONNECT_REQ(_cmsg * cmsg, __u16 ApplId, __u16 Messagenumber, 266 - __u32 adr, 267 - __u16 CIPValue, 268 - _cstruct CalledPartyNumber, 269 - _cstruct CallingPartyNumber, 270 - _cstruct CalledPartySubaddress, 271 - _cstruct CallingPartySubaddress, 272 - __u16 B1protocol, 273 - __u16 B2protocol, 274 - __u16 B3protocol, 275 - _cstruct B1configuration, 276 - _cstruct B2configuration, 277 - _cstruct B3configuration, 278 - _cstruct BC, 279 - _cstruct LLC, 280 - _cstruct HLC, 281 - _cstruct BChannelinformation, 282 - _cstruct Keypadfacility, 283 - _cstruct Useruserdata, 284 - _cstruct Facilitydataarray) 285 - { 286 - 287 - capi_cmsg_header(cmsg, ApplId, 0x02, 0x80, Messagenumber, adr); 288 - cmsg->CIPValue = CIPValue; 289 - cmsg->CalledPartyNumber = CalledPartyNumber; 290 - cmsg->CallingPartyNumber = CallingPartyNumber; 291 - cmsg->CalledPartySubaddress = CalledPartySubaddress; 292 - cmsg->CallingPartySubaddress = CallingPartySubaddress; 293 - cmsg->B1protocol = B1protocol; 294 - cmsg->B2protocol = B2protocol; 295 - cmsg->B3protocol = B3protocol; 296 - cmsg->B1configuration = B1configuration; 297 - cmsg->B2configuration = B2configuration; 298 - cmsg->B3configuration = B3configuration; 299 - cmsg->BC = BC; 300 - cmsg->LLC = LLC; 301 - cmsg->HLC = HLC; 302 - cmsg->BChannelinformation = BChannelinformation; 303 - cmsg->Keypadfacility = Keypadfacility; 304 - cmsg->Useruserdata = Useruserdata; 305 - cmsg->Facilitydataarray = Facilitydataarray; 306 - } 307 - 308 - static inline void capi_fill_DATA_B3_REQ(_cmsg * cmsg, __u16 ApplId, __u16 Messagenumber, 309 - __u32 adr, 310 - __u32 Data, 311 - __u16 DataLength, 312 - __u16 DataHandle, 313 - __u16 Flags) 314 - { 315 - 316 - capi_cmsg_header(cmsg, ApplId, 0x86, 0x80, Messagenumber, adr); 317 - cmsg->Data = Data; 318 - cmsg->DataLength = DataLength; 319 - cmsg->DataHandle = DataHandle; 320 - cmsg->Flags = Flags; 321 - } 322 - 323 - static inline void capi_fill_DISCONNECT_REQ(_cmsg * cmsg, __u16 ApplId, __u16 Messagenumber, 324 - __u32 adr, 325 - _cstruct BChannelinformation, 326 - _cstruct Keypadfacility, 327 - _cstruct Useruserdata, 328 - _cstruct Facilitydataarray) 329 - { 330 - 331 - capi_cmsg_header(cmsg, ApplId, 0x04, 0x80, Messagenumber, adr); 332 - cmsg->BChannelinformation = BChannelinformation; 333 - cmsg->Keypadfacility = Keypadfacility; 334 - cmsg->Useruserdata = Useruserdata; 335 - cmsg->Facilitydataarray = Facilitydataarray; 336 - } 337 - 338 - static inline void capi_fill_DISCONNECT_B3_REQ(_cmsg * cmsg, __u16 ApplId, __u16 Messagenumber, 339 - __u32 adr, 340 - _cstruct NCPI) 341 - { 342 - 343 - capi_cmsg_header(cmsg, ApplId, 0x84, 0x80, Messagenumber, adr); 344 - cmsg->NCPI = NCPI; 345 - } 346 - 347 - static inline void capi_fill_MANUFACTURER_REQ(_cmsg * cmsg, __u16 ApplId, __u16 Messagenumber, 348 - __u32 adr, 349 - __u32 ManuID, 350 - __u32 Class, 351 - __u32 Function, 352 - _cstruct ManuData) 353 - { 354 - 355 - capi_cmsg_header(cmsg, ApplId, 0xff, 0x80, Messagenumber, adr); 356 - cmsg->ManuID = ManuID; 357 - cmsg->Class = Class; 358 - cmsg->Function = Function; 359 - cmsg->ManuData = ManuData; 360 - } 361 - 362 - static inline void capi_fill_RESET_B3_REQ(_cmsg * cmsg, __u16 ApplId, __u16 Messagenumber, 363 - __u32 adr, 364 - _cstruct NCPI) 365 - { 366 - 367 - capi_cmsg_header(cmsg, ApplId, 0x87, 0x80, Messagenumber, adr); 368 - cmsg->NCPI = NCPI; 369 - } 370 - 371 - static inline void capi_fill_SELECT_B_PROTOCOL_REQ(_cmsg * cmsg, __u16 ApplId, __u16 Messagenumber, 372 - __u32 adr, 373 - __u16 B1protocol, 374 - __u16 B2protocol, 375 - __u16 B3protocol, 376 - _cstruct B1configuration, 377 - _cstruct B2configuration, 378 - _cstruct B3configuration) 379 - { 380 - 381 - capi_cmsg_header(cmsg, ApplId, 0x41, 0x80, Messagenumber, adr); 382 - cmsg->B1protocol = B1protocol; 383 - cmsg->B2protocol = B2protocol; 384 - cmsg->B3protocol = B3protocol; 385 - cmsg->B1configuration = B1configuration; 386 - cmsg->B2configuration = B2configuration; 387 - cmsg->B3configuration = B3configuration; 388 - } 389 - 390 - static inline void capi_fill_CONNECT_RESP(_cmsg * cmsg, __u16 ApplId, __u16 Messagenumber, 391 - __u32 adr, 392 - __u16 Reject, 393 - __u16 B1protocol, 394 - __u16 B2protocol, 395 - __u16 B3protocol, 396 - _cstruct B1configuration, 397 - _cstruct B2configuration, 398 - _cstruct B3configuration, 399 - _cstruct ConnectedNumber, 400 - _cstruct ConnectedSubaddress, 401 - _cstruct LLC, 402 - _cstruct BChannelinformation, 403 - _cstruct Keypadfacility, 404 - _cstruct Useruserdata, 405 - _cstruct Facilitydataarray) 406 - { 407 - capi_cmsg_header(cmsg, ApplId, 0x02, 0x83, Messagenumber, adr); 408 - cmsg->Reject = Reject; 409 - cmsg->B1protocol = B1protocol; 410 - cmsg->B2protocol = B2protocol; 411 - cmsg->B3protocol = B3protocol; 412 - cmsg->B1configuration = B1configuration; 413 - cmsg->B2configuration = B2configuration; 414 - cmsg->B3configuration = B3configuration; 415 - cmsg->ConnectedNumber = ConnectedNumber; 416 - cmsg->ConnectedSubaddress = ConnectedSubaddress; 417 - cmsg->LLC = LLC; 418 - cmsg->BChannelinformation = BChannelinformation; 419 - cmsg->Keypadfacility = Keypadfacility; 420 - cmsg->Useruserdata = Useruserdata; 421 - cmsg->Facilitydataarray = Facilitydataarray; 422 - } 423 - 424 - static inline void capi_fill_CONNECT_ACTIVE_RESP(_cmsg * cmsg, __u16 ApplId, __u16 Messagenumber, 425 - __u32 adr) 426 - { 427 - 428 - capi_cmsg_header(cmsg, ApplId, 0x03, 0x83, Messagenumber, adr); 429 - } 430 - 431 - static inline void capi_fill_CONNECT_B3_ACTIVE_RESP(_cmsg * cmsg, __u16 ApplId, __u16 Messagenumber, 432 - __u32 adr) 433 - { 434 - 435 - capi_cmsg_header(cmsg, ApplId, 0x83, 0x83, Messagenumber, adr); 436 - } 437 - 438 - static inline void capi_fill_CONNECT_B3_RESP(_cmsg * cmsg, __u16 ApplId, __u16 Messagenumber, 439 - __u32 adr, 440 - __u16 Reject, 441 - _cstruct NCPI) 442 - { 443 - capi_cmsg_header(cmsg, ApplId, 0x82, 0x83, Messagenumber, adr); 444 - cmsg->Reject = Reject; 445 - cmsg->NCPI = NCPI; 446 - } 447 - 448 - static inline void capi_fill_CONNECT_B3_T90_ACTIVE_RESP(_cmsg * cmsg, __u16 ApplId, __u16 Messagenumber, 449 - __u32 adr) 450 - { 451 - 452 - capi_cmsg_header(cmsg, ApplId, 0x88, 0x83, Messagenumber, adr); 453 - } 454 - 455 - static inline void capi_fill_DATA_B3_RESP(_cmsg * cmsg, __u16 ApplId, __u16 Messagenumber, 456 - __u32 adr, 457 - __u16 DataHandle) 458 - { 459 - 460 - capi_cmsg_header(cmsg, ApplId, 0x86, 0x83, Messagenumber, adr); 461 - cmsg->DataHandle = DataHandle; 462 - } 463 - 464 - static inline void capi_fill_DISCONNECT_B3_RESP(_cmsg * cmsg, __u16 ApplId, __u16 Messagenumber, 465 - __u32 adr) 466 - { 467 - 468 - capi_cmsg_header(cmsg, ApplId, 0x84, 0x83, Messagenumber, adr); 469 - } 470 - 471 - static inline void capi_fill_DISCONNECT_RESP(_cmsg * cmsg, __u16 ApplId, __u16 Messagenumber, 472 - __u32 adr) 473 - { 474 - 475 - capi_cmsg_header(cmsg, ApplId, 0x04, 0x83, Messagenumber, adr); 476 - } 477 - 478 - static inline void capi_fill_FACILITY_RESP(_cmsg * cmsg, __u16 ApplId, __u16 Messagenumber, 479 - __u32 adr, 480 - __u16 FacilitySelector) 481 - { 482 - 483 - capi_cmsg_header(cmsg, ApplId, 0x80, 0x83, Messagenumber, adr); 484 - cmsg->FacilitySelector = FacilitySelector; 485 - } 486 - 487 - static inline void capi_fill_INFO_RESP(_cmsg * cmsg, __u16 ApplId, __u16 Messagenumber, 488 - __u32 adr) 489 - { 490 - 491 - capi_cmsg_header(cmsg, ApplId, 0x08, 0x83, Messagenumber, adr); 492 - } 493 - 494 - static inline void capi_fill_MANUFACTURER_RESP(_cmsg * cmsg, __u16 ApplId, __u16 Messagenumber, 495 - __u32 adr, 496 - __u32 ManuID, 497 - __u32 Class, 498 - __u32 Function, 499 - _cstruct ManuData) 500 - { 501 - 502 - capi_cmsg_header(cmsg, ApplId, 0xff, 0x83, Messagenumber, adr); 503 - cmsg->ManuID = ManuID; 504 - cmsg->Class = Class; 505 - cmsg->Function = Function; 506 - cmsg->ManuData = ManuData; 507 - } 508 - 509 - static inline void capi_fill_RESET_B3_RESP(_cmsg * cmsg, __u16 ApplId, __u16 Messagenumber, 510 - __u32 adr) 511 - { 512 - 513 - capi_cmsg_header(cmsg, ApplId, 0x87, 0x83, Messagenumber, adr); 514 - } 515 - 516 60 #endif /* __CAPIUTIL_H__ */
-75
include/linux/kernelcapi.h
··· 10 10 #ifndef __KERNELCAPI_H__ 11 11 #define __KERNELCAPI_H__ 12 12 13 - 14 13 #include <linux/list.h> 15 14 #include <linux/skbuff.h> 16 15 #include <linux/workqueue.h> 17 16 #include <linux/notifier.h> 18 17 #include <uapi/linux/kernelcapi.h> 19 - 20 - struct capi20_appl { 21 - u16 applid; 22 - capi_register_params rparam; 23 - void (*recv_message)(struct capi20_appl *ap, struct sk_buff *skb); 24 - void *private; 25 - 26 - /* internal to kernelcapi.o */ 27 - unsigned long nrecvctlpkt; 28 - unsigned long nrecvdatapkt; 29 - unsigned long nsentctlpkt; 30 - unsigned long nsentdatapkt; 31 - struct mutex recv_mtx; 32 - struct sk_buff_head recv_queue; 33 - struct work_struct recv_work; 34 - int release_in_progress; 35 - }; 36 - 37 - u16 capi20_isinstalled(void); 38 - u16 capi20_register(struct capi20_appl *ap); 39 - u16 capi20_release(struct capi20_appl *ap); 40 - u16 capi20_put_message(struct capi20_appl *ap, struct sk_buff *skb); 41 - u16 capi20_get_manufacturer(u32 contr, u8 buf[CAPI_MANUFACTURER_LEN]); 42 - u16 capi20_get_version(u32 contr, struct capi_version *verp); 43 - u16 capi20_get_serial(u32 contr, u8 serial[CAPI_SERIAL_LEN]); 44 - u16 capi20_get_profile(u32 contr, struct capi_profile *profp); 45 - int capi20_manufacturer(unsigned long cmd, void __user *data); 46 - 47 - #define CAPICTR_UP 0 48 - #define CAPICTR_DOWN 1 49 - 50 - int register_capictr_notifier(struct notifier_block *nb); 51 - int unregister_capictr_notifier(struct notifier_block *nb); 52 18 53 19 #define CAPI_NOERROR 0x0000 54 20 ··· 41 75 #define CAPI_MSGNOTINSTALLED 0x1109 42 76 #define CAPI_MSGCTRLERNOTSUPPORTEXTEQUIP 0x110a 43 77 #define CAPI_MSGCTRLERONLYSUPPORTEXTEQUIP 0x110b 44 - 45 - typedef enum { 46 - CapiMessageNotSupportedInCurrentState = 0x2001, 47 - CapiIllContrPlciNcci = 0x2002, 48 - CapiNoPlciAvailable = 0x2003, 49 - CapiNoNcciAvailable = 0x2004, 50 - CapiNoListenResourcesAvailable = 0x2005, 51 - CapiNoFaxResourcesAvailable = 0x2006, 52 - CapiIllMessageParmCoding = 0x2007, 53 - } RESOURCE_CODING_PROBLEM; 54 - 55 - typedef enum { 56 - CapiB1ProtocolNotSupported = 0x3001, 57 - CapiB2ProtocolNotSupported = 0x3002, 58 - CapiB3ProtocolNotSupported = 0x3003, 59 - CapiB1ProtocolParameterNotSupported = 0x3004, 60 - CapiB2ProtocolParameterNotSupported = 0x3005, 61 - CapiB3ProtocolParameterNotSupported = 0x3006, 62 - CapiBProtocolCombinationNotSupported = 0x3007, 63 - CapiNcpiNotSupported = 0x3008, 64 - CapiCipValueUnknown = 0x3009, 65 - CapiFlagsNotSupported = 0x300a, 66 - CapiFacilityNotSupported = 0x300b, 67 - CapiDataLengthNotSupportedByCurrentProtocol = 0x300c, 68 - CapiResetProcedureNotSupportedByCurrentProtocol = 0x300d, 69 - CapiTeiAssignmentFailed = 0x300e, 70 - } REQUESTED_SERVICES_PROBLEM; 71 - 72 - typedef enum { 73 - CapiSuccess = 0x0000, 74 - CapiSupplementaryServiceNotSupported = 0x300e, 75 - CapiRequestNotAllowedInThisState = 0x3010, 76 - } SUPPLEMENTARY_SERVICE_INFO; 77 - 78 - typedef enum { 79 - CapiProtocolErrorLayer1 = 0x3301, 80 - CapiProtocolErrorLayer2 = 0x3302, 81 - CapiProtocolErrorLayer3 = 0x3303, 82 - CapiTimeOut = 0x3303, // SuppServiceReason 83 - CapiCallGivenToOtherApplication = 0x3304, 84 - } CAPI_REASON; 85 78 86 79 #endif /* __KERNELCAPI_H__ */
-74
include/uapi/linux/b1lli.h
··· 1 - /* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */ 2 - /* $Id: b1lli.h,v 1.8.8.3 2001/09/23 22:25:05 kai Exp $ 3 - * 4 - * ISDN lowlevel-module for AVM B1-card. 5 - * 6 - * Copyright 1996 by Carsten Paeth (calle@calle.in-berlin.de) 7 - * 8 - * This software may be used and distributed according to the terms 9 - * of the GNU General Public License, incorporated herein by reference. 10 - * 11 - */ 12 - 13 - #ifndef _B1LLI_H_ 14 - #define _B1LLI_H_ 15 - /* 16 - * struct for loading t4 file 17 - */ 18 - typedef struct avmb1_t4file { 19 - int len; 20 - unsigned char *data; 21 - } avmb1_t4file; 22 - 23 - typedef struct avmb1_loaddef { 24 - int contr; 25 - avmb1_t4file t4file; 26 - } avmb1_loaddef; 27 - 28 - typedef struct avmb1_loadandconfigdef { 29 - int contr; 30 - avmb1_t4file t4file; 31 - avmb1_t4file t4config; 32 - } avmb1_loadandconfigdef; 33 - 34 - typedef struct avmb1_resetdef { 35 - int contr; 36 - } avmb1_resetdef; 37 - 38 - typedef struct avmb1_getdef { 39 - int contr; 40 - int cardtype; 41 - int cardstate; 42 - } avmb1_getdef; 43 - 44 - /* 45 - * struct for adding new cards 46 - */ 47 - typedef struct avmb1_carddef { 48 - int port; 49 - int irq; 50 - } avmb1_carddef; 51 - 52 - #define AVM_CARDTYPE_B1 0 53 - #define AVM_CARDTYPE_T1 1 54 - #define AVM_CARDTYPE_M1 2 55 - #define AVM_CARDTYPE_M2 3 56 - 57 - typedef struct avmb1_extcarddef { 58 - int port; 59 - int irq; 60 - int cardtype; 61 - int cardnr; /* for HEMA/T1 */ 62 - } avmb1_extcarddef; 63 - 64 - #define AVMB1_LOAD 0 /* load image to card */ 65 - #define AVMB1_ADDCARD 1 /* add a new card - OBSOLETE */ 66 - #define AVMB1_RESETCARD 2 /* reset a card */ 67 - #define AVMB1_LOAD_AND_CONFIG 3 /* load image and config to card */ 68 - #define AVMB1_ADDCARD_WITH_TYPE 4 /* add a new card, with cardtype */ 69 - #define AVMB1_GET_CARDINFO 5 /* get cardtype */ 70 - #define AVMB1_REMOVECARD 6 /* remove a card - OBSOLETE */ 71 - 72 - #define AVMB1_REGISTERCARD_IS_OBSOLETE 73 - 74 - #endif /* _B1LLI_H_ */