16 #include <linux/module.h>
21 #include <linux/sched.h>
26 #include <linux/kernelcapi.h>
30 #include <linux/slab.h>
31 #include <asm/uaccess.h>
40 static int showcapimsgs = 0;
58 static struct capi_version driver_version = {2, 0, 1, 1 << 4};
60 static char capi_manufakturer[64] =
"AVM Berlin";
62 #define NCCI2CTRL(ncci) (((ncci) >> 24) & 0x7f)
72 static int ncontrollers;
81 if (!try_module_get(ctr->
owner))
89 module_put(ctr->
owner);
94 static inline struct capi_ctr *get_capi_ctr_by_nr(
u16 contr)
99 return capi_controller[contr - 1];
109 return capi_applications[applid - 1];
122 static inline int capi_cmd_valid(
u8 cmd)
145 static inline int capi_subcmd_valid(
u8 subcmd)
162 ctr = capi_ctr_get(ctr);
172 static void release_appl(
struct capi_ctr *ctr,
u16 applid)
174 DBG(
"applid %#x", applid);
180 static void notify_up(
u32 contr)
188 if (showcapimsgs & 1)
191 ctr = get_capi_ctr_by_nr(contr);
199 ap = __get_capi_appl_by_nr(applid);
228 ap = __get_capi_appl_by_nr(applid);
236 static void notify_down(
u32 contr)
242 if (showcapimsgs & 1)
245 ctr = get_capi_ctr_by_nr(contr);
276 (
void *)(
long)
event->controller);
358 printk(
KERN_INFO "kcapi: controller [%03d] not active, cannot trace\n",
402 printk(
KERN_ERR "kcapi: handle_message: applid %d state released (%s)\n",
406 printk(
KERN_ERR "kcapi: handle_message: applid %d state released (%s) cannot trace\n",
516 if (!capi_controller[i])
519 if (i == CAPI_MAXCONTR) {
524 capi_controller[
i] = ctr;
567 if (capi_controller[ctr->
cnr - 1] != ctr) {
571 capi_controller[ctr->
cnr - 1] =
NULL;
639 if (capi_controller[i] &&
686 if (capi_applications[applid - 1] ==
NULL)
695 capi_applications[applid - 1] = ap;
698 if (!capi_controller[i] ||
701 register_appl(capi_controller[i], applid, &ap->
rparam);
706 if (showcapimsgs & 1) {
739 if (!capi_controller[i] ||
742 release_appl(capi_controller[i], ap->
applid);
750 if (showcapimsgs & 1) {
776 if (ncontrollers == 0)
860 ctr = get_capi_ctr_by_nr(contr);
889 *verp = driver_version;
895 ctr = get_capi_ctr_by_nr(contr);
930 ctr = get_capi_ctr_by_nr(contr);
965 ctr = get_capi_ctr_by_nr(contr);
979 static int wait_on_ctr_state(
struct capi_ctr *ctr,
unsigned int state)
984 ctr = capi_ctr_get(ctr);
992 if (ctr->
state == state)
1015 static int old_capi_manufacturer(
unsigned int cmd,
void __user *
data)
1072 retval = driver->
add_card(driver, &cparams);
1094 ctr = get_capi_ctr_by_nr(ldef.
contr);
1097 goto load_unlock_out;
1103 goto load_unlock_out;
1109 goto load_unlock_out;
1114 goto load_unlock_out;
1127 goto load_unlock_out;
1134 goto load_unlock_out;
1151 ctr = get_capi_ctr_by_nr(rdef.
contr);
1154 goto reset_unlock_out;
1158 goto reset_unlock_out;
1163 goto reset_unlock_out;
1199 return old_capi_manufacturer(cmd, data);
1210 ctr = get_capi_ctr_by_nr(fdef.
contr);
1247 if (driver ==
NULL) {
1255 retval = driver->
add_card(driver, &cparams);
1281 .notifier_call = notify_handler,
1285 static int __init kcapi_init(
void)
1306 static void __exit kcapi_exit(
void)