patch-2.2.15 linux/drivers/isdn/avmb1/kcapi.c

Next file: linux/drivers/isdn/avmb1/t1isa.c
Previous file: linux/drivers/isdn/avmb1/capi.c
Back to the patch index
Back to the overall index

diff -u --new-file --recursive --exclude-from ../../exclude v2.2.14/drivers/isdn/avmb1/kcapi.c linux/drivers/isdn/avmb1/kcapi.c
@@ -1,11 +1,15 @@
 /*
- * $Id: kcapi.c,v 1.11 1999/11/23 13:29:29 calle Exp $
+ * $Id: kcapi.c,v 1.12 2000/01/28 16:45:39 calle Exp $
  * 
  * Kernel CAPI 2.0 Module
  * 
  * (c) Copyright 1999 by Carsten Paeth (calle@calle.in-berlin.de)
  * 
  * $Log: kcapi.c,v $
+ * Revision 1.12  2000/01/28 16:45:39  calle
+ * new manufacturer command KCAPI_CMD_ADDCARD (generic addcard),
+ * will search named driver and call the add_card function if one exist.
+ *
  * Revision 1.11  1999/11/23 13:29:29  calle
  * Bugfix: incoming capi message were never traced.
  *
@@ -82,7 +86,7 @@
 #include <linux/b1lli.h>
 #endif
 
-static char *revision = "$Revision: 1.11 $";
+static char *revision = "$Revision: 1.12 $";
 
 /* ------------------------------------------------------------- */
 
@@ -157,10 +161,6 @@
 static struct sk_buff_head recv_queue;
 static struct capi_interface_user *capi_users = 0;
 static struct capi_driver *drivers;
-#ifdef CONFIG_AVMB1_COMPAT
-static struct capi_driver *b1isa_driver;
-static struct capi_driver *t1isa_driver;
-#endif
 static long notify_up_set = 0;
 static long notify_down_set = 0;
 
@@ -956,12 +956,6 @@
 	driver->next = 0;
 	*pp = driver;
 	printk(KERN_NOTICE "kcapi: driver %s attached\n", driver->name);
-#ifdef CONFIG_AVMB1_COMPAT
-        if (strcmp(driver->name, "b1isa") == 0 && driver->add_card)
-		b1isa_driver = driver;
-        if (strcmp(driver->name, "t1isa") == 0 && driver->add_card)
-		t1isa_driver = driver;
-#endif
 	sprintf(driver->procfn, "capi/drivers/%s", driver->name);
 	driver->procent = create_proc_entry(driver->procfn, 0, 0);
 	if (driver->procent) {
@@ -983,10 +977,6 @@
 	for (pp = &drivers; *pp && *pp != driver; pp = &(*pp)->next) ;
 	if (*pp) {
 		*pp = (*pp)->next;
-#ifdef CONFIG_AVMB1_COMPAT
-		if (driver == b1isa_driver) b1isa_driver = 0;
-		if (driver == t1isa_driver) t1isa_driver = 0;
-#endif
 		printk(KERN_NOTICE "kcapi: driver %s detached\n", driver->name);
 	} else {
 		printk(KERN_ERR "kcapi: driver %s double detach ?\n", driver->name);
@@ -1201,6 +1191,15 @@
 	return CAPI_NOERROR;
 }
 
+static struct capi_driver *find_driver(char *name)
+{
+	struct capi_driver *dp;
+	for (dp = drivers; dp; dp = dp->next)
+		if (strcmp(dp->name, name) == 0)
+			return dp;
+	return 0;
+}
+
 #ifdef CONFIG_AVMB1_COMPAT
 static int old_capi_manufacturer(unsigned int cmd, void *data)
 {
@@ -1232,9 +1231,15 @@
 		cparams.cardnr = cdef.cardnr;
 
                 switch (cdef.cardtype) {
-			case AVM_CARDTYPE_B1: driver = b1isa_driver; break;
-			case AVM_CARDTYPE_T1: driver = t1isa_driver; break;
-			default: driver = 0;
+			case AVM_CARDTYPE_B1:
+				driver = find_driver("b1isa");
+				break;
+			case AVM_CARDTYPE_T1:
+				driver = find_driver("t1isa");
+				break;
+			default:
+				driver = 0;
+				break;
 		}
 		if (!driver) {
 			printk(KERN_ERR "kcapi: driver not loaded.\n");
@@ -1346,9 +1351,7 @@
 			return -ESRCH;
 
 		gdef.cardstate = card->cardstate;
-		if (card->driver == b1isa_driver)
-			gdef.cardtype = AVM_CARDTYPE_B1;
-		else if (card->driver == t1isa_driver)
+		if (card->driver == find_driver("t1isa"))
 			gdef.cardtype = AVM_CARDTYPE_T1;
 		else gdef.cardtype = AVM_CARDTYPE_B1;
 
@@ -1392,7 +1395,6 @@
 static int capi_manufacturer(unsigned int cmd, void *data)
 {
         struct capi_ctr *card;
-	kcapi_flagdef fdef;
 	int retval;
 
 	switch (cmd) {
@@ -1407,6 +1409,9 @@
 		return old_capi_manufacturer(cmd, data);
 #endif
 	case KCAPI_CMD_TRACE:
+	{
+		kcapi_flagdef fdef;
+
 		if ((retval = copy_from_user((void *) &fdef, data,
 					 sizeof(kcapi_flagdef))))
 			return retval;
@@ -1420,6 +1425,44 @@
 		printk(KERN_INFO "kcapi: contr %d set trace=%d\n",
 			card->cnr, card->traceflag);
 		return 0;
+	}
+
+	case KCAPI_CMD_ADDCARD:
+	{
+		struct capi_driver *driver;
+		capicardparams cparams;
+		kcapi_carddef cdef;
+
+		if ((retval = copy_from_user((void *) &cdef, data,
+							sizeof(cdef))))
+			return retval;
+
+		cparams.port = cdef.port;
+		cparams.irq = cdef.irq;
+		cparams.membase = cdef.membase;
+		cparams.cardnr = cdef.cardnr;
+		cparams.cardtype = 0;
+		cdef.driver[sizeof(cdef.driver)-1] = 0;
+
+		if ((driver = find_driver(cdef.driver)) == 0) {
+			printk(KERN_ERR "kcapi: driver \"%s\" not loaded.\n",
+					cdef.driver);
+			return -ESRCH;
+		}
+
+		if (!driver->add_card) {
+			printk(KERN_ERR "kcapi: driver \"%s\" has no add card function.\n", cdef.driver);
+			return -EIO;
+		}
+
+		return driver->add_card(driver, &cparams);
+	}
+
+	default:
+		printk(KERN_ERR "kcapi: manufacturer command %d unknown.\n",
+					cmd);
+		break;
+
 	}
 	return -EINVAL;
 }

FUNET's LINUX-ADM group, linux-adm@nic.funet.fi
TCL-scripts by Sam Shen (who was at: slshen@lbl.gov)