LKML Archive on lore.kernel.org
help / color / mirror / Atom feed
* [PATCH 01/14] [ISDN] HiSax: modularize card setup
  2007-07-18  3:04 [PATCH 00/14] [ISDN] HiSax hotplug conversion Jeff Garzik
@ 2007-07-18  3:04 ` Jeff Garzik
  2008-02-15 13:38   ` Sam Ravnborg
  2007-07-18  3:46 ` [PATCH 04/14] [ISDN] HiSax bkm_a4t: convert to PCI hotplug API Jeff Garzik
                   ` (16 subsequent siblings)
  17 siblings, 1 reply; 28+ messages in thread
From: Jeff Garzik @ 2007-07-18  3:04 UTC (permalink / raw)
  To: linux-kernel, kkeil, isdn4linux

Now that the previous no-behavior-change code movement patches have
occurred, we can easily replace the big per-card "call the setup
function for <this card>" switch statement with a function pointer.

Signed-off-by: Jeff Garzik <jeff@garzik.org>
---
 drivers/isdn/hisax/config.c    |   14 +++++++++-----
 drivers/isdn/hisax/hisax_cfg.h |    2 ++
 2 files changed, 11 insertions(+), 5 deletions(-)

diff --git a/drivers/isdn/hisax/config.c b/drivers/isdn/hisax/config.c
index a0ee43c..f395a72 100644
--- a/drivers/isdn/hisax/config.c
+++ b/drivers/isdn/hisax/config.c
@@ -1169,7 +1169,9 @@ outf_cs:
 /* Used from an exported function but calls __devinit functions.
  * Tell modpost not to warn (__ref)
  */
-static int __ref checkcard(int cardnr, char *id, int *busy_flag, struct module *lockowner)
+static int __ref checkcard(int cardnr, char *id, int *busy_flag,
+			   struct module *lockowner,
+		    	   hisax_setup_func_t card_setup)
 {
 	int ret;
 	struct IsdnCard *card = cards + cardnr;
@@ -1187,7 +1189,7 @@ static int __ref checkcard(int cardnr, char *id, int *busy_flag, struct module *
 	       (card->protocol == ISDN_PTYPE_NI1) ? "NI1" :
 	       "NONE", cs->iif.id, cs->myid);
 
-	ret = hisax_cs_setup_card(card);
+	ret = card_setup(card);
 	if (!ret) {
 		ll_unload(cs);
 		goto outf_cs;
@@ -1241,7 +1243,8 @@ static int HiSax_inithardware(int *busy_flag)
 			else
 				sprintf(ids, "%s%d", id, i);
 		}
-		if (checkcard(i, ids, busy_flag, THIS_MODULE)) {
+		if (checkcard(i, ids, busy_flag, THIS_MODULE,
+			      hisax_cs_setup_card)) {
 			foundcards++;
 			i++;
 		} else {
@@ -1549,7 +1552,8 @@ int hisax_init_pcmcia(void *pcm_iob, int *busy_flag, struct IsdnCard *card)
 		sprintf(ids, "HiSax%d", nrcards);
 	else
 		sprintf(ids, "HiSax");
-	if (!checkcard(nrcards, ids, busy_flag, THIS_MODULE))
+	if (!checkcard(nrcards, ids, busy_flag, THIS_MODULE,
+		       hisax_cs_setup_card))
 		goto error;
 
 	ret = nrcards;
@@ -1595,7 +1599,7 @@ int hisax_register(struct hisax_d_if *hisax_d_if, struct hisax_b_if *b_if[],
 	cards[i].protocol = protocol;
 	sprintf(id, "%s%d", name, i);
 	nrcards++;
-	retval = checkcard(i, id, NULL, hisax_d_if->owner);
+	retval = checkcard(i, id, NULL, hisax_d_if->owner, hisax_cs_setup_card);
 	if (retval == 0) { // yuck
 		cards[i].typ = 0;
 		nrcards--;
diff --git a/drivers/isdn/hisax/hisax_cfg.h b/drivers/isdn/hisax/hisax_cfg.h
index ca3fe62..17a2fea 100644
--- a/drivers/isdn/hisax/hisax_cfg.h
+++ b/drivers/isdn/hisax/hisax_cfg.h
@@ -60,5 +60,7 @@ struct IsdnCard {
 	IsdnCardState_t	*cs;
 };
 
+typedef int (*hisax_setup_func_t)(struct IsdnCard *card);
+
 extern void	HiSax_closecard(int);
 extern int	hisax_init_pcmcia(void *, int *, IsdnCard_t *);
-- 
1.5.3.8


^ permalink raw reply	[flat|nested] 28+ messages in thread

* [PATCH 00/14] [ISDN] HiSax hotplug conversion
@ 2007-07-18  3:04 Jeff Garzik
  2007-07-18  3:04 ` [PATCH 01/14] [ISDN] HiSax: modularize card setup Jeff Garzik
                   ` (17 more replies)
  0 siblings, 18 replies; 28+ messages in thread
From: Jeff Garzik @ 2007-07-18  3:04 UTC (permalink / raw)
  To: linux-kernel, kkeil, isdn4linux; +Cc: Greg KH


This is a refresh of an on-going work-in-progress:  convert the last
remaining users of pci_find_device() to the ISA/PCI/etc.  hotplug APIs
now in standard use.  After SCSI's gdth, ISDN's HiSax suite of drivers
are just about the last place using the older API.

A few rough edges remain, and I'm not sure how much of ISDN userland
will explode (I have no ISDN hardware, nor much want any:)), but this
should get us almost all the way there.

The patches are diff'd against 2.6.25-rc1.

Comments/review/testing welcome.  Especially "it works" or "its dead"
testing.


^ permalink raw reply	[flat|nested] 28+ messages in thread

* [PATCH 04/14] [ISDN] HiSax bkm_a4t: convert to PCI hotplug API
  2007-07-18  3:04 [PATCH 00/14] [ISDN] HiSax hotplug conversion Jeff Garzik
  2007-07-18  3:04 ` [PATCH 01/14] [ISDN] HiSax: modularize card setup Jeff Garzik
@ 2007-07-18  3:46 ` Jeff Garzik
  2008-02-15 13:33   ` Sam Ravnborg
  2007-07-18  3:49 ` [PATCH 05/14] [ISDN] HiSax enternow: " Jeff Garzik
                   ` (15 subsequent siblings)
  17 siblings, 1 reply; 28+ messages in thread
From: Jeff Garzik @ 2007-07-18  3:46 UTC (permalink / raw)
  To: linux-kernel, kkeil, isdn4linux

Signed-off-by: Jeff Garzik <jeff@garzik.org>
---
 drivers/isdn/hisax/Kconfig   |    4 +-
 drivers/isdn/hisax/Makefile  |    3 +-
 drivers/isdn/hisax/bkm_a4t.c |  115 ++++++++++++++++++++++++++++--------------
 drivers/isdn/hisax/config.c  |   27 ++++------
 4 files changed, 92 insertions(+), 57 deletions(-)

diff --git a/drivers/isdn/hisax/Kconfig b/drivers/isdn/hisax/Kconfig
index 7832d8b..e7808f5 100644
--- a/drivers/isdn/hisax/Kconfig
+++ b/drivers/isdn/hisax/Kconfig
@@ -286,8 +286,8 @@ config HISAX_HSTSAPHIR
 	  settings.
 
 config HISAX_BKM_A4T
-	bool "Telekom A4T card"
-	depends on PCI && PCI_LEGACY
+	tristate "Telekom A4T card"
+	depends on PCI
 	help
 	  This enables HiSax support for the Telekom A4T card.
 
diff --git a/drivers/isdn/hisax/Makefile b/drivers/isdn/hisax/Makefile
index b0b09e9..42bfc2f 100644
--- a/drivers/isdn/hisax/Makefile
+++ b/drivers/isdn/hisax/Makefile
@@ -15,7 +15,9 @@ obj-$(CONFIG_HISAX_ST5481)		+= hisax_st5481.o
 obj-$(CONFIG_HISAX_HFCUSB)		+= hfc_usb.o
 obj-$(CONFIG_HISAX_HFC4S8S)		+= hfc4s8s_l1.o
 obj-$(CONFIG_HISAX_FRITZ_PCIPNP)        += hisax_isac.o hisax_fcpcipnp.o
+obj-$(CONFIG_HISAX_BKM_A4T)		+= bkm_a4t_pci.o libhisax.o
 
+bkm_a4t_pci-objs			:= bkm_a4t.o jade.o
 libhisax-objs				:= netjet.o isac.o arcofi.o hscx.o
 
 ifdef CONFIG_HISAX_HDLC
@@ -56,7 +58,6 @@ hisax-$(CONFIG_HISAX_HFC_SX)		+= hfc_sx.o
 hisax-$(CONFIG_HISAX_NICCY)		+= niccy.o
 hisax-$(CONFIG_HISAX_ISURF)		+= isurf.o isar.o
 hisax-$(CONFIG_HISAX_HSTSAPHIR)		+= saphir.o
-hisax-$(CONFIG_HISAX_BKM_A4T)		+= bkm_a4t.o jade.o
 hisax-$(CONFIG_HISAX_SCT_QUADRO)	+= bkm_a8.o
 hisax-$(CONFIG_HISAX_GAZEL)		+= gazel.o
 hisax-$(CONFIG_HISAX_W6692)		+= w6692.o
diff --git a/drivers/isdn/hisax/bkm_a4t.c b/drivers/isdn/hisax/bkm_a4t.c
index 9ca2ee5..61eda77 100644
--- a/drivers/isdn/hisax/bkm_a4t.c
+++ b/drivers/isdn/hisax/bkm_a4t.c
@@ -13,6 +13,7 @@
 
 #include <linux/init.h>
 #include "hisax.h"
+#include "hisax_proto.h"
 #include "isac.h"
 #include "hscx.h"
 #include "jade.h"
@@ -20,6 +21,8 @@
 #include <linux/pci.h>
 #include "bkm_ax.h"
 
+static int a4t_protocol;		/* 0 == use DEFAULT_PROTO */
+
 static const char *bkm_a4t_revision = "$Revision: 1.22.2.4 $";
 
 
@@ -255,24 +258,21 @@ BKM_card_msg(struct IsdnCardState *cs, int mt, void *arg)
 
 static int __devinit a4t_pci_probe(struct pci_dev *dev_a4t,
 				   struct IsdnCardState *cs,
-				   u_int *found,
 				   u_int *pci_memaddr)
 {
-	u16 sub_sys;
-	u16 sub_vendor;
-
-	sub_vendor = dev_a4t->subsystem_vendor;
-	sub_sys = dev_a4t->subsystem_device;
-	if ((sub_sys == PCI_DEVICE_ID_BERKOM_A4T) && (sub_vendor == PCI_VENDOR_ID_BERKOM)) {
-		if (pci_enable_device(dev_a4t))
-			return (0);	/* end loop & function */
-		*found = 1;
-		*pci_memaddr = pci_resource_start(dev_a4t, 0);
-		cs->irq = dev_a4t->irq;
-		return (1);		/* end loop */
+	if (pci_enable_device(dev_a4t))
+		return (0);	/* error */
+
+	*pci_memaddr = pci_resource_start(dev_a4t, 0);
+	if (!(*pci_memaddr)) {
+		printk(KERN_WARNING "HiSax bkm_a4t: No Memory base address\n");
+		return (0);
 	}
 
-	return (-1);			/* continue looping */
+	cs->irq = dev_a4t->irq;
+
+	cs->hw.ax.dev = dev_a4t;
+	return (1);		/* success */
 }
 
 static int __devinit a4t_cs_init(struct IsdnCard *card,
@@ -323,40 +323,79 @@ static int __devinit a4t_cs_init(struct IsdnCard *card,
 	return (1);
 }
 
-static struct pci_dev *dev_a4t __devinitdata = NULL;
-
-int __devinit
+static int __devinit
 setup_bkm_a4t(struct IsdnCard *card)
 {
 	struct IsdnCardState *cs = card->cs;
 	char tmp[64];
-	u_int pci_memaddr = 0, found = 0;
+	u_int pci_memaddr = 0;
 	int ret;
+	struct pci_dev *dev_a4t = (void *) card->para[0];
 
 	strcpy(tmp, bkm_a4t_revision);
 	printk(KERN_INFO "HiSax: T-Berkom driver Rev. %s\n", HiSax_getrev(tmp));
-	if (cs->typ == ISDN_CTYPE_BKM_A4T) {
-		cs->subtyp = BKM_A4T;
-	} else
-		return (0);
 
-	while ((dev_a4t = pci_find_device(PCI_VENDOR_ID_ZORAN,
-		PCI_DEVICE_ID_ZORAN_36120, dev_a4t))) {
-		ret = a4t_pci_probe(dev_a4t, cs, &found, &pci_memaddr);
-		if (!ret)
-			return (0);
-		if (ret > 0)
-			break;
-	}
-	if (!found) {
-		printk(KERN_WARNING "HiSax: Telekom A4T: Card not found\n");
-		return (0);
-	}
-	if (!pci_memaddr) {
-		printk(KERN_WARNING "HiSax: Telekom A4T: "
-		       "No Memory base address\n");
+	WARN_ON(cs->typ != ISDN_CTYPE_BKM_A4T);
+
+	cs->subtyp = BKM_A4T;
+
+	ret = a4t_pci_probe(dev_a4t, cs, &pci_memaddr);
+	if (!ret)
 		return (0);
-	}
 
 	return a4t_cs_init(card, cs, pci_memaddr);
 }
+
+static int __devinit a4t_pci_init_one(struct pci_dev *pdev,
+				      const struct pci_device_id *ent)
+{
+	struct IsdnCard icard = { ISDN_CTYPE_BKM_A4T, };
+	int cardnr;
+
+	icard.para[0] = (unsigned long) pdev;
+	if (!a4t_protocol)
+		icard.protocol = DEFAULT_PROTO;
+	else
+		icard.protocol = a4t_protocol;
+
+	cardnr = hisax_init_hotplug(&icard, setup_bkm_a4t);
+	if (cardnr < 0)
+		return -ENODEV;
+	
+	pci_set_drvdata(pdev, (void *)(unsigned long) cardnr);
+	return 0;
+}
+
+static struct pci_device_id a4t_pci_table[] = {
+	{ PCI_VENDOR_ID_ZORAN, PCI_DEVICE_ID_ZORAN_36120,
+	  PCI_VENDOR_ID_BERKOM, PCI_DEVICE_ID_BERKOM_A4T, },
+
+	{ }		/* terminate list */
+};
+
+static struct pci_driver a4t_pci_driver = {
+	.name		= "bkm_a4t",
+	.id_table	= a4t_pci_table,
+	.probe		= a4t_pci_init_one,
+	.remove		= hisax_pci_remove_one,
+};
+
+static int __init a4t_mod_init(void)
+{
+	return pci_register_driver(&a4t_pci_driver);
+}
+
+static void __exit a4t_mod_exit(void)
+{
+	pci_unregister_driver(&a4t_pci_driver);
+}
+
+module_init(a4t_mod_init);
+module_exit(a4t_mod_exit);
+
+module_param_named(protocol, a4t_protocol, int, 0444);
+MODULE_PARM_DESC(protocol, "Values 0 (default) through 4. See ISDN_PTYPE_xxx in linux/isdnif.h");
+
+MODULE_DEVICE_TABLE(pci, a4t_pci_table);
+MODULE_DESCRIPTION("ISDN HiSax BKM A4T PCI driver");
+MODULE_LICENSE("GPL");
diff --git a/drivers/isdn/hisax/config.c b/drivers/isdn/hisax/config.c
index 6112013..7638cf5 100644
--- a/drivers/isdn/hisax/config.c
+++ b/drivers/isdn/hisax/config.c
@@ -250,13 +250,6 @@ const char *CardType[] = {
 #define DEFAULT_CFG {5,0x250,0,0}
 #endif
 
-#ifdef CONFIG_HISAX_BKM_A4T
-#undef DEFAULT_CARD
-#undef DEFAULT_CFG
-#define DEFAULT_CARD ISDN_CTYPE_BKM_A4T
-#define DEFAULT_CFG {0,0x0,0,0}
-#endif
-
 #ifdef CONFIG_HISAX_SCT_QUADRO
 #undef DEFAULT_CARD
 #undef DEFAULT_CFG
@@ -531,10 +524,6 @@ extern int setup_isurf(struct IsdnCard *card);
 extern int setup_saphir(struct IsdnCard *card);
 #endif
 
-#if CARD_BKM_A4T
-extern int setup_bkm_a4t(struct IsdnCard *card);
-#endif
-
 #if CARD_SCT_QUADRO
 extern int setup_sct_quadro(struct IsdnCard *card);
 #endif
@@ -954,11 +943,6 @@ static int __devinit hisax_cs_setup_card(struct IsdnCard *card)
 		ret = setup_saphir(card);
 		break;
 #endif
-#if	CARD_BKM_A4T
-	case ISDN_CTYPE_BKM_A4T:
-		ret = setup_bkm_a4t(card);
-		break;
-#endif
 #if	CARD_SCT_QUADRO
 	case ISDN_CTYPE_SCT_QUADRO:
 		ret = setup_sct_quadro(card);
@@ -987,6 +971,14 @@ static int __devinit hisax_cs_setup_card(struct IsdnCard *card)
 	case ISDN_CTYPE_DYNAMIC:
 		ret = 2;
 		break;
+
+	case ISDN_CTYPE_BKM_A4T:
+		printk(KERN_WARNING "HiSax: Support for %s Card has moved "
+		       "to separate PCI driver module\n",
+		       CardType[card->typ]);
+		ret = 0;
+		break;
+
 	default:
 		printk(KERN_WARNING
 		       "HiSax: Support for %s Card not selected\n",
@@ -1447,8 +1439,11 @@ static int __init HiSax_init(void)
 		case ISDN_CTYPE_W6692:
 		case ISDN_CTYPE_NETJET_U:
 			break;
+
+		/* the following block are excluded from std HiSax init */
 		case ISDN_CTYPE_BKM_A4T:
 			break;
+
 		case ISDN_CTYPE_SCT_QUADRO:
 			if (irq[i]) {
 				cards[j].para[0] = irq[i];
-- 
1.5.3.8


^ permalink raw reply	[flat|nested] 28+ messages in thread

* [PATCH 05/14] [ISDN] HiSax enternow: convert to PCI hotplug API
  2007-07-18  3:04 [PATCH 00/14] [ISDN] HiSax hotplug conversion Jeff Garzik
  2007-07-18  3:04 ` [PATCH 01/14] [ISDN] HiSax: modularize card setup Jeff Garzik
  2007-07-18  3:46 ` [PATCH 04/14] [ISDN] HiSax bkm_a4t: convert to PCI hotplug API Jeff Garzik
@ 2007-07-18  3:49 ` Jeff Garzik
  2008-02-15 13:21   ` Jan Engelhardt
  2007-07-18  3:54 ` [PATCH 06/14] [ISDN] HiSax hfc_pci, w6692: " Jeff Garzik
                   ` (14 subsequent siblings)
  17 siblings, 1 reply; 28+ messages in thread
From: Jeff Garzik @ 2007-07-18  3:49 UTC (permalink / raw)
  To: linux-kernel, kkeil, isdn4linux

Signed-off-by: Jeff Garzik <jeff@garzik.org>
---
 drivers/isdn/hisax/Kconfig        |    4 +-
 drivers/isdn/hisax/Makefile       |    3 +-
 drivers/isdn/hisax/config.c       |   11 +----
 drivers/isdn/hisax/enternow_pci.c |   93 ++++++++++++++++++++++++++-----------
 4 files changed, 72 insertions(+), 39 deletions(-)

diff --git a/drivers/isdn/hisax/Kconfig b/drivers/isdn/hisax/Kconfig
index e7808f5..2a69acc 100644
--- a/drivers/isdn/hisax/Kconfig
+++ b/drivers/isdn/hisax/Kconfig
@@ -340,8 +340,8 @@ config HISAX_HFC_SX
 	  cards. This code is not finished yet.
 
 config HISAX_ENTERNOW_PCI
-	bool "Formula-n enter:now PCI card"
-	depends on HISAX_NETJET && PCI && PCI_LEGACY && (BROKEN || !(SPARC || PPC || PARISC || M68K || (MIPS && !CPU_LITTLE_ENDIAN) || FRV))
+	tristate "Formula-n enter:now PCI card"
+	depends on HISAX_NETJET && PCI && (BROKEN || !(SPARC || PPC || PARISC || M68K || (MIPS && !CPU_LITTLE_ENDIAN) || FRV))
 	help
 	  This enables HiSax support for the Formula-n enter:now PCI
 	  ISDN card.
diff --git a/drivers/isdn/hisax/Makefile b/drivers/isdn/hisax/Makefile
index 42bfc2f..c72fb28 100644
--- a/drivers/isdn/hisax/Makefile
+++ b/drivers/isdn/hisax/Makefile
@@ -16,8 +16,10 @@ obj-$(CONFIG_HISAX_HFCUSB)		+= hfc_usb.o
 obj-$(CONFIG_HISAX_HFC4S8S)		+= hfc4s8s_l1.o
 obj-$(CONFIG_HISAX_FRITZ_PCIPNP)        += hisax_isac.o hisax_fcpcipnp.o
 obj-$(CONFIG_HISAX_BKM_A4T)		+= bkm_a4t_pci.o libhisax.o
+obj-$(CONFIG_HISAX_ENTERNOW_PCI)	+= enternow.o libhisax.o
 
 bkm_a4t_pci-objs			:= bkm_a4t.o jade.o
+enternow-objs				:= enternow_pci.o amd7930_fn.o
 libhisax-objs				:= netjet.o isac.o arcofi.o hscx.o
 
 ifdef CONFIG_HISAX_HDLC
@@ -61,5 +63,4 @@ hisax-$(CONFIG_HISAX_HSTSAPHIR)		+= saphir.o
 hisax-$(CONFIG_HISAX_SCT_QUADRO)	+= bkm_a8.o
 hisax-$(CONFIG_HISAX_GAZEL)		+= gazel.o
 hisax-$(CONFIG_HISAX_W6692)		+= w6692.o
-hisax-$(CONFIG_HISAX_ENTERNOW_PCI)	+= enternow_pci.o amd7930_fn.o
 
diff --git a/drivers/isdn/hisax/config.c b/drivers/isdn/hisax/config.c
index 7638cf5..90e499d 100644
--- a/drivers/isdn/hisax/config.c
+++ b/drivers/isdn/hisax/config.c
@@ -540,10 +540,6 @@ extern int setup_w6692(struct IsdnCard *card);
 extern int setup_netjet_u(struct IsdnCard *card);
 #endif
 
-#if CARD_FN_ENTERNOW_PCI
-extern int setup_enternow_pci(struct IsdnCard *card);
-#endif
-
 /*
  * Find card with given driverId
  */
@@ -963,16 +959,12 @@ static int __devinit hisax_cs_setup_card(struct IsdnCard *card)
 		ret = setup_netjet_u(card);
 		break;
 #endif
-#if CARD_FN_ENTERNOW_PCI
-	case ISDN_CTYPE_ENTERNOW:
-		ret = setup_enternow_pci(card);
-		break;
-#endif
 	case ISDN_CTYPE_DYNAMIC:
 		ret = 2;
 		break;
 
 	case ISDN_CTYPE_BKM_A4T:
+	case ISDN_CTYPE_ENTERNOW:
 		printk(KERN_WARNING "HiSax: Support for %s Card has moved "
 		       "to separate PCI driver module\n",
 		       CardType[card->typ]);
@@ -1442,6 +1434,7 @@ static int __init HiSax_init(void)
 
 		/* the following block are excluded from std HiSax init */
 		case ISDN_CTYPE_BKM_A4T:
+		case ISDN_CTYPE_ENTERNOW:
 			break;
 
 		case ISDN_CTYPE_SCT_QUADRO:
diff --git a/drivers/isdn/hisax/enternow_pci.c b/drivers/isdn/hisax/enternow_pci.c
index 39f421e..b37a483 100644
--- a/drivers/isdn/hisax/enternow_pci.c
+++ b/drivers/isdn/hisax/enternow_pci.c
@@ -61,6 +61,7 @@
 
 
 #include "hisax.h"
+#include "hisax_proto.h"
 #include "isac.h"
 #include "isdnl1.h"
 #include "amd7930_fn.h"
@@ -70,7 +71,7 @@
 #include <linux/init.h>
 #include "netjet.h"
 
-
+static int en_protocol;		/* 0 == use DEFAULT_PROTO */
 
 static const char *enternow_pci_rev = "$Revision: 1.1.4.5 $";
 
@@ -305,6 +306,8 @@ static int __devinit en_pci_probe(struct pci_dev *dev_netjet,
 {
 	if (pci_enable_device(dev_netjet))
 		return(0);
+
+	cs->hw.njet.dev = dev_netjet;
 	cs->irq = dev_netjet->irq;
 	if (!cs->irq) {
 		printk(KERN_WARNING "enter:now PCI: No IRQ for PCI card found\n");
@@ -315,13 +318,6 @@ static int __devinit en_pci_probe(struct pci_dev *dev_netjet,
 		printk(KERN_WARNING "enter:now PCI: No IO-Adr for PCI card found\n");
 		return(0);
 	}
-	/* checks Sub-Vendor ID because system crashes with Traverse-Card */
-	if ((dev_netjet->subsystem_vendor != 0x55) ||
-	    (dev_netjet->subsystem_device != 0x02)) {
-		printk(KERN_WARNING "enter:now: You tried to load this driver with an incompatible TigerJet-card\n");
-		printk(KERN_WARNING "Use type=20 for Traverse NetJet PCI Card.\n");
-		return(0);
-	}
 
 	return(1);
 }
@@ -384,15 +380,14 @@ static int __devinit en_cs_init_rest(struct IsdnCard *card,
 	return (1);
 }
 
-static struct pci_dev *dev_netjet __devinitdata = NULL;
-
 /* called by config.c */
-int __devinit
+static int __devinit
 setup_enternow_pci(struct IsdnCard *card)
 {
 	int ret;
 	struct IsdnCardState *cs = card->cs;
 	char tmp[64];
+	struct pci_dev *dev_netjet = (void *) card->para[0];
 
 #ifdef __BIG_ENDIAN
 #error "not running on big endian machines now"
@@ -400,25 +395,69 @@ setup_enternow_pci(struct IsdnCard *card)
 
         strcpy(tmp, enternow_pci_rev);
 	printk(KERN_INFO "HiSax: Formula-n Europe AG enter:now ISDN PCI driver Rev. %s\n", HiSax_getrev(tmp));
-	if (cs->typ != ISDN_CTYPE_ENTERNOW)
-		return(0);
+
+	WARN_ON(cs->typ != ISDN_CTYPE_ENTERNOW);
+
 	test_and_clear_bit(FLG_LOCK_ATOMIC, &cs->HW_Flags);
 
-	for ( ;; )
-	{
-		if ((dev_netjet = pci_find_device(PCI_VENDOR_ID_TIGERJET,
-			PCI_DEVICE_ID_TIGERJET_300,  dev_netjet))) {
-			ret = en_pci_probe(dev_netjet, cs);
-			if (!ret)
-				return(0);
-		} else {
-                        printk(KERN_WARNING "enter:now PCI: No PCI card found\n");
-			return(0);
-		}
+	ret = en_pci_probe(dev_netjet, cs);
+	if (!ret)
+		return(0);
 
-		en_cs_init(card, cs);
-		break;
-	}
+	en_cs_init(card, cs);
 
         return en_cs_init_rest(card, cs);
 }
+
+static int __devinit en_pci_init_one(struct pci_dev *pdev,
+				      const struct pci_device_id *ent)
+{
+	struct IsdnCard icard = { ISDN_CTYPE_ENTERNOW, };
+	int cardnr;
+
+	icard.para[0] = (unsigned long) pdev;
+	if (!en_protocol)
+		icard.protocol = DEFAULT_PROTO;
+	else
+		icard.protocol = en_protocol;
+
+	cardnr = hisax_init_hotplug(&icard, setup_enternow_pci);
+	if (cardnr < 0)
+		return -ENODEV;
+	
+	pci_set_drvdata(pdev, (void *)(unsigned long) cardnr);
+	return 0;
+}
+
+static struct pci_device_id en_pci_table[] = {
+	{ PCI_VENDOR_ID_TIGERJET, PCI_DEVICE_ID_TIGERJET_300, 0x55, 0x02, },
+
+	{ }		/* terminate list */
+};
+
+static struct pci_driver en_pci_driver = {
+	.name		= "enternow_pci",
+	.id_table	= en_pci_table,
+	.probe		= en_pci_init_one,
+	.remove		= hisax_pci_remove_one,
+};
+
+static int __init en_mod_init(void)
+{
+	return pci_register_driver(&en_pci_driver);
+}
+
+static void __exit en_mod_exit(void)
+{
+	pci_unregister_driver(&en_pci_driver);
+}
+
+module_init(en_mod_init);
+module_exit(en_mod_exit);
+
+module_param_named(protocol, en_protocol, int, 0444);
+MODULE_PARM_DESC(protocol, "Values 0 (default) through 4. See ISDN_PTYPE_xxx in linux/isdnif.h");
+
+MODULE_DEVICE_TABLE(pci, en_pci_table);
+MODULE_DESCRIPTION("ISDN HiSax enter:now PCI driver");
+MODULE_LICENSE("GPL");
-- 
1.5.3.8


^ permalink raw reply	[flat|nested] 28+ messages in thread

* [PATCH 06/14] [ISDN] HiSax hfc_pci, w6692: convert to PCI hotplug API
  2007-07-18  3:04 [PATCH 00/14] [ISDN] HiSax hotplug conversion Jeff Garzik
                   ` (2 preceding siblings ...)
  2007-07-18  3:49 ` [PATCH 05/14] [ISDN] HiSax enternow: " Jeff Garzik
@ 2007-07-18  3:54 ` Jeff Garzik
  2007-07-18  3:59 ` [PATCH 07/14] [ISDN] HiSax nj_s, nj_u: " Jeff Garzik
                   ` (13 subsequent siblings)
  17 siblings, 0 replies; 28+ messages in thread
From: Jeff Garzik @ 2007-07-18  3:54 UTC (permalink / raw)
  To: linux-kernel, kkeil, isdn4linux

Signed-off-by: Jeff Garzik <jeff@garzik.org>
---
 drivers/isdn/hisax/Kconfig   |    8 +-
 drivers/isdn/hisax/Makefile  |    4 +-
 drivers/isdn/hisax/config.c  |   66 +------------------
 drivers/isdn/hisax/hfc_pci.c |  142 ++++++++++++++++++++++++++++++++----------
 drivers/isdn/hisax/w6692.c   |  111 ++++++++++++++++++++++-----------
 5 files changed, 194 insertions(+), 137 deletions(-)

diff --git a/drivers/isdn/hisax/Kconfig b/drivers/isdn/hisax/Kconfig
index 2a69acc..a37a616 100644
--- a/drivers/isdn/hisax/Kconfig
+++ b/drivers/isdn/hisax/Kconfig
@@ -315,8 +315,8 @@ config HISAX_GAZEL
 	  settings.
 
 config HISAX_HFC_PCI
-	bool "HFC PCI-Bus cards"
-	depends on PCI && PCI_LEGACY && (BROKEN || !(SPARC || PPC || PARISC || M68K || (MIPS && !CPU_LITTLE_ENDIAN) || FRV))
+	tristate "HFC PCI-Bus cards"
+	depends on PCI && (BROKEN || !(SPARC || PPC || PARISC || M68K || (MIPS && !CPU_LITTLE_ENDIAN) || FRV))
 	help
 	  This enables HiSax support for the HFC-S PCI 2BDS0 based cards.
 
@@ -324,8 +324,8 @@ config HISAX_HFC_PCI
 	  <file:Documentation/isdn/README.hfc-pci>.
 
 config HISAX_W6692
-	bool "Winbond W6692 based cards"
-	depends on PCI && PCI_LEGACY
+	tristate "Winbond W6692 based cards"
+	depends on PCI
 	help
 	  This enables HiSax support for Winbond W6692 based PCI ISDN cards.
 
diff --git a/drivers/isdn/hisax/Makefile b/drivers/isdn/hisax/Makefile
index c72fb28..c3e2ea2 100644
--- a/drivers/isdn/hisax/Makefile
+++ b/drivers/isdn/hisax/Makefile
@@ -17,6 +17,8 @@ obj-$(CONFIG_HISAX_HFC4S8S)		+= hfc4s8s_l1.o
 obj-$(CONFIG_HISAX_FRITZ_PCIPNP)        += hisax_isac.o hisax_fcpcipnp.o
 obj-$(CONFIG_HISAX_BKM_A4T)		+= bkm_a4t_pci.o libhisax.o
 obj-$(CONFIG_HISAX_ENTERNOW_PCI)	+= enternow.o libhisax.o
+obj-$(CONFIG_HISAX_HFC_PCI)		+= hfc_pci.o libhisax.o
+obj-$(CONFIG_HISAX_W6692)		+= w6692.o libhisax.o
 
 bkm_a4t_pci-objs			:= bkm_a4t.o jade.o
 enternow-objs				:= enternow_pci.o amd7930_fn.o
@@ -55,12 +57,10 @@ hisax-$(CONFIG_HISAX_MIC)		+= mic.o
 hisax-$(CONFIG_HISAX_NETJET)		+= nj_s.o
 hisax-$(CONFIG_HISAX_NETJET_U)		+= nj_u.o icc.o
 hisax-$(CONFIG_HISAX_HFCS)		+= hfcscard.o hfc_2bds0.o
-hisax-$(CONFIG_HISAX_HFC_PCI)		+= hfc_pci.o
 hisax-$(CONFIG_HISAX_HFC_SX)		+= hfc_sx.o
 hisax-$(CONFIG_HISAX_NICCY)		+= niccy.o
 hisax-$(CONFIG_HISAX_ISURF)		+= isurf.o isar.o
 hisax-$(CONFIG_HISAX_HSTSAPHIR)		+= saphir.o
 hisax-$(CONFIG_HISAX_SCT_QUADRO)	+= bkm_a8.o
 hisax-$(CONFIG_HISAX_GAZEL)		+= gazel.o
-hisax-$(CONFIG_HISAX_W6692)		+= w6692.o
 
diff --git a/drivers/isdn/hisax/config.c b/drivers/isdn/hisax/config.c
index 90e499d..cba06ba 100644
--- a/drivers/isdn/hisax/config.c
+++ b/drivers/isdn/hisax/config.c
@@ -215,13 +215,6 @@ const char *CardType[] = {
 #define DEFAULT_CFG {5,0x500,0,0}
 #endif
 
-#ifdef CONFIG_HISAX_HFC_PCI
-#undef DEFAULT_CARD
-#undef DEFAULT_CFG
-#define DEFAULT_CARD ISDN_CTYPE_HFC_PCI
-#define DEFAULT_CFG {0,0,0,0}
-#endif
-
 #ifdef CONFIG_HISAX_HFC_SX
 #undef DEFAULT_CARD
 #undef DEFAULT_CFG
@@ -264,13 +257,6 @@ const char *CardType[] = {
 #define DEFAULT_CFG {15,0x180,0,0}
 #endif
 
-#ifdef CONFIG_HISAX_W6692
-#undef DEFAULT_CARD
-#undef DEFAULT_CFG
-#define DEFAULT_CARD ISDN_CTYPE_W6692
-#define DEFAULT_CFG {0,0,0,0}
-#endif
-
 #ifdef CONFIG_HISAX_NETJET_U
 #undef DEFAULT_CARD
 #undef DEFAULT_CFG
@@ -504,10 +490,6 @@ extern int setup_netjet_s(struct IsdnCard *card);
 extern int setup_hfcs(struct IsdnCard *card);
 #endif
 
-#if CARD_HFC_PCI
-extern int setup_hfcpci(struct IsdnCard *card);
-#endif
-
 #if CARD_HFC_SX
 extern int setup_hfcsx(struct IsdnCard *card);
 #endif
@@ -532,10 +514,6 @@ extern int setup_sct_quadro(struct IsdnCard *card);
 extern int setup_gazel(struct IsdnCard *card);
 #endif
 
-#if CARD_W6692
-extern int setup_w6692(struct IsdnCard *card);
-#endif
-
 #if CARD_NETJET_U
 extern int setup_netjet_u(struct IsdnCard *card);
 #endif
@@ -914,11 +892,6 @@ static int __devinit hisax_cs_setup_card(struct IsdnCard *card)
 		ret = setup_hfcs(card);
 		break;
 #endif
-#if CARD_HFC_PCI
-	case ISDN_CTYPE_HFC_PCI:
-		ret = setup_hfcpci(card);
-		break;
-#endif
 #if CARD_HFC_SX
 	case ISDN_CTYPE_HFC_SX:
 		ret = setup_hfcsx(card);
@@ -949,11 +922,6 @@ static int __devinit hisax_cs_setup_card(struct IsdnCard *card)
 		ret = setup_gazel(card);
 		break;
 #endif
-#if CARD_W6692
-	case ISDN_CTYPE_W6692:
-		ret = setup_w6692(card);
-		break;
-#endif
 #if CARD_NETJET_U
 	case ISDN_CTYPE_NETJET_U:
 		ret = setup_netjet_u(card);
@@ -965,6 +933,8 @@ static int __devinit hisax_cs_setup_card(struct IsdnCard *card)
 
 	case ISDN_CTYPE_BKM_A4T:
 	case ISDN_CTYPE_ENTERNOW:
+	case ISDN_CTYPE_HFC_PCI:
+	case ISDN_CTYPE_W6692:
 		printk(KERN_WARNING "HiSax: Support for %s Card has moved "
 		       "to separate PCI driver module\n",
 		       CardType[card->typ]);
@@ -1391,7 +1361,6 @@ static int __init HiSax_init(void)
 			break;
 #endif
 		case ISDN_CTYPE_ELSA:
-		case ISDN_CTYPE_HFC_PCI:
 			cards[j].para[0] = io[i];
 			break;
 		case ISDN_CTYPE_16_3:
@@ -1428,13 +1397,14 @@ static int __init HiSax_init(void)
 		case ISDN_CTYPE_ELSA_PCI:
 		case ISDN_CTYPE_NETJET_S:
 		case ISDN_CTYPE_TELESPCI:
-		case ISDN_CTYPE_W6692:
 		case ISDN_CTYPE_NETJET_U:
 			break;
 
 		/* the following block are excluded from std HiSax init */
 		case ISDN_CTYPE_BKM_A4T:
 		case ISDN_CTYPE_ENTERNOW:
+		case ISDN_CTYPE_HFC_PCI:
+		case ISDN_CTYPE_W6692:
 			break;
 
 		case ISDN_CTYPE_SCT_QUADRO:
@@ -1944,34 +1914,6 @@ static struct pci_device_id hisax_pci_tbl[] __devinitdata = {
 #if defined(CONFIG_HISAX_TELESPCI) || defined(CONFIG_HISAX_SCT_QUADRO)
 	{PCI_VENDOR_ID_ZORAN,    PCI_DEVICE_ID_ZORAN_36120,      PCI_ANY_ID,PCI_ANY_ID},
 #endif
-#ifdef CONFIG_HISAX_W6692
-	{PCI_VENDOR_ID_DYNALINK, PCI_DEVICE_ID_DYNALINK_IS64PH,  PCI_ANY_ID,PCI_ANY_ID},
-	{PCI_VENDOR_ID_WINBOND2, PCI_DEVICE_ID_WINBOND2_6692,    PCI_ANY_ID,PCI_ANY_ID},
-#endif
-#ifdef CONFIG_HISAX_HFC_PCI
-	{PCI_VENDOR_ID_CCD,      PCI_DEVICE_ID_CCD_2BD0,         PCI_ANY_ID, PCI_ANY_ID},
-	{PCI_VENDOR_ID_CCD,      PCI_DEVICE_ID_CCD_B000,         PCI_ANY_ID, PCI_ANY_ID},
-	{PCI_VENDOR_ID_CCD,      PCI_DEVICE_ID_CCD_B006,         PCI_ANY_ID, PCI_ANY_ID},
-	{PCI_VENDOR_ID_CCD,      PCI_DEVICE_ID_CCD_B007,         PCI_ANY_ID, PCI_ANY_ID},
-	{PCI_VENDOR_ID_CCD,      PCI_DEVICE_ID_CCD_B008,         PCI_ANY_ID, PCI_ANY_ID},
-	{PCI_VENDOR_ID_CCD,      PCI_DEVICE_ID_CCD_B009,         PCI_ANY_ID, PCI_ANY_ID},
-	{PCI_VENDOR_ID_CCD,      PCI_DEVICE_ID_CCD_B00A,         PCI_ANY_ID, PCI_ANY_ID},
-	{PCI_VENDOR_ID_CCD,      PCI_DEVICE_ID_CCD_B00B,         PCI_ANY_ID, PCI_ANY_ID},
-	{PCI_VENDOR_ID_CCD,      PCI_DEVICE_ID_CCD_B00C,         PCI_ANY_ID, PCI_ANY_ID},
-	{PCI_VENDOR_ID_CCD,      PCI_DEVICE_ID_CCD_B100,         PCI_ANY_ID, PCI_ANY_ID},
-	{PCI_VENDOR_ID_CCD,      PCI_DEVICE_ID_CCD_B700,         PCI_ANY_ID, PCI_ANY_ID},
-	{PCI_VENDOR_ID_CCD,      PCI_DEVICE_ID_CCD_B701,         PCI_ANY_ID, PCI_ANY_ID},
-	{PCI_VENDOR_ID_ABOCOM,   PCI_DEVICE_ID_ABOCOM_2BD1,      PCI_ANY_ID, PCI_ANY_ID},
-	{PCI_VENDOR_ID_ASUSTEK,  PCI_DEVICE_ID_ASUSTEK_0675,     PCI_ANY_ID, PCI_ANY_ID},
-	{PCI_VENDOR_ID_BERKOM,   PCI_DEVICE_ID_BERKOM_T_CONCEPT, PCI_ANY_ID, PCI_ANY_ID},
-	{PCI_VENDOR_ID_BERKOM,   PCI_DEVICE_ID_BERKOM_A1T,       PCI_ANY_ID, PCI_ANY_ID},
-	{PCI_VENDOR_ID_ANIGMA,   PCI_DEVICE_ID_ANIGMA_MC145575,  PCI_ANY_ID, PCI_ANY_ID},
-	{PCI_VENDOR_ID_ZOLTRIX,  PCI_DEVICE_ID_ZOLTRIX_2BD0,     PCI_ANY_ID, PCI_ANY_ID},
-	{PCI_VENDOR_ID_DIGI,     PCI_DEVICE_ID_DIGI_DF_M_IOM2_E, PCI_ANY_ID, PCI_ANY_ID},
-	{PCI_VENDOR_ID_DIGI,     PCI_DEVICE_ID_DIGI_DF_M_E,      PCI_ANY_ID, PCI_ANY_ID},
-	{PCI_VENDOR_ID_DIGI,     PCI_DEVICE_ID_DIGI_DF_M_IOM2_A, PCI_ANY_ID, PCI_ANY_ID},
-	{PCI_VENDOR_ID_DIGI,     PCI_DEVICE_ID_DIGI_DF_M_A,      PCI_ANY_ID, PCI_ANY_ID},
-#endif
 	{ }				/* Terminating entry */
 };
 
diff --git a/drivers/isdn/hisax/hfc_pci.c b/drivers/isdn/hisax/hfc_pci.c
index f126566..ce9e3e1 100644
--- a/drivers/isdn/hisax/hfc_pci.c
+++ b/drivers/isdn/hisax/hfc_pci.c
@@ -17,11 +17,14 @@
 
 #include <linux/init.h>
 #include "hisax.h"
+#include "hisax_proto.h"
 #include "hfc_pci.h"
 #include "isdnl1.h"
 #include <linux/pci.h>
 #include <linux/interrupt.h>
 
+static int hfc_protocol;		/* 0 == use DEFAULT_PROTO */
+
 static const char *hfcpci_revision = "$Revision: 1.48.2.4 $";
 
 /* table entry in the PCI devices list */
@@ -1630,18 +1633,14 @@ hfcpci_card_msg(struct IsdnCardState *cs, int mt, void *arg)
 	return (0);
 }
 
-
-/* this variable is used as card index when more than one cards are present */
-static struct pci_dev *dev_hfcpci __devinitdata = NULL;
-
-int __devinit
+static int __devinit
 setup_hfcpci(struct IsdnCard *card)
 {
 	u_long flags;
 	struct IsdnCardState *cs = card->cs;
 	char tmp[64];
-	int i;
-	struct pci_dev *tmp_hfcpci = NULL;
+	struct pci_dev *dev_hfcpci = (void *) card->para[0];
+	unsigned int idx = card->para[1];
 
 #ifdef __BIG_ENDIAN
 #error "not running on big endian machines now"
@@ -1653,33 +1652,12 @@ setup_hfcpci(struct IsdnCard *card)
 	cs->hw.hfcpci.int_s1 = 0;
 	cs->dc.hfcpci.ph_state = 0;
 	cs->hw.hfcpci.fifo = 255;
-	if (cs->typ != ISDN_CTYPE_HFC_PCI)
-		return(0);
-
-	i = 0;
-	while (id_list[i].vendor_id) {
-		tmp_hfcpci = pci_find_device(id_list[i].vendor_id,
-					     id_list[i].device_id,
-					     dev_hfcpci);
-		i++;
-		if (tmp_hfcpci) {
-			if (pci_enable_device(tmp_hfcpci))
-				continue;
-			pci_set_master(tmp_hfcpci);
-			if ((card->para[0]) && (card->para[0] != (tmp_hfcpci->resource[ 0].start & PCI_BASE_ADDRESS_IO_MASK)))
-				continue;
-			else
-				break;
-		}
-	}
+	WARN_ON(cs->typ != ISDN_CTYPE_HFC_PCI);
 
-	if (!tmp_hfcpci) {
-		printk(KERN_WARNING "HFC-PCI: No PCI card found\n");
+	if (pci_enable_device(dev_hfcpci))
 		return (0);
-	}
+	pci_set_master(dev_hfcpci);
 
-	i--;
-	dev_hfcpci = tmp_hfcpci;	/* old device */
 	cs->hw.hfcpci.dev = dev_hfcpci;
 	cs->irq = dev_hfcpci->irq;
 	if (!cs->irq) {
@@ -1687,7 +1665,8 @@ setup_hfcpci(struct IsdnCard *card)
 		return (0);
 	}
 	cs->hw.hfcpci.pci_io = (char *)(unsigned long)dev_hfcpci->resource[1].start;
-	printk(KERN_INFO "HiSax: HFC-PCI card manufacturer: %s card name: %s\n", id_list[i].vendor_name, id_list[i].card_name);
+	printk(KERN_INFO "HiSax: HFC-PCI card manufacturer: %s card name: %s\n",
+	       id_list[idx].vendor_name, id_list[idx].card_name);
 
 	if (!cs->hw.hfcpci.pci_io) {
 		printk(KERN_WARNING "HFC-PCI: No IO-Mem for PCI card found\n");
@@ -1742,3 +1721,102 @@ setup_hfcpci(struct IsdnCard *card)
 
 	return (1);
 }
+
+static int __devinit hfc_pci_init_one(struct pci_dev *pdev,
+				      const struct pci_device_id *ent)
+{
+	struct IsdnCard icard = { ISDN_CTYPE_HFC_PCI, };
+	int cardnr;
+
+	icard.para[0] = (unsigned long) pdev;
+	icard.para[1] = ent->driver_data;
+	if (!hfc_protocol)
+		icard.protocol = DEFAULT_PROTO;
+	else
+		icard.protocol = hfc_protocol;
+
+	cardnr = hisax_init_hotplug(&icard, setup_hfcpci);
+	if (cardnr < 0)
+		return -ENODEV;
+	
+	pci_set_drvdata(pdev, (void *)(unsigned long) cardnr);
+	return 0;
+}
+
+static struct pci_device_id hfc_pci_table[] = {
+	{ PCI_VENDOR_ID_CCD,      PCI_DEVICE_ID_CCD_2BD0,
+	  PCI_ANY_ID, PCI_ANY_ID, 0 },
+	{ PCI_VENDOR_ID_CCD,      PCI_DEVICE_ID_CCD_B000,
+	  PCI_ANY_ID, PCI_ANY_ID, 1 },
+	{ PCI_VENDOR_ID_CCD,      PCI_DEVICE_ID_CCD_B006,
+	  PCI_ANY_ID, PCI_ANY_ID, 2 },
+	{ PCI_VENDOR_ID_CCD,      PCI_DEVICE_ID_CCD_B007,
+	  PCI_ANY_ID, PCI_ANY_ID, 3 },
+	{ PCI_VENDOR_ID_CCD,      PCI_DEVICE_ID_CCD_B008,
+	  PCI_ANY_ID, PCI_ANY_ID, 4 },
+	{ PCI_VENDOR_ID_CCD,      PCI_DEVICE_ID_CCD_B009,
+	  PCI_ANY_ID, PCI_ANY_ID, 5 },
+	{ PCI_VENDOR_ID_CCD,      PCI_DEVICE_ID_CCD_B00A,
+	  PCI_ANY_ID, PCI_ANY_ID, 6 },
+	{ PCI_VENDOR_ID_CCD,      PCI_DEVICE_ID_CCD_B00B,
+	  PCI_ANY_ID, PCI_ANY_ID, 7 },
+	{ PCI_VENDOR_ID_CCD,      PCI_DEVICE_ID_CCD_B00C,
+	  PCI_ANY_ID, PCI_ANY_ID, 8 },
+	{ PCI_VENDOR_ID_CCD,      PCI_DEVICE_ID_CCD_B100,
+	  PCI_ANY_ID, PCI_ANY_ID, 9 },
+	{ PCI_VENDOR_ID_CCD,      PCI_DEVICE_ID_CCD_B700,
+	  PCI_ANY_ID, PCI_ANY_ID, 10 },
+	{ PCI_VENDOR_ID_CCD,      PCI_DEVICE_ID_CCD_B701,
+	  PCI_ANY_ID, PCI_ANY_ID, 11 },
+	{ PCI_VENDOR_ID_ABOCOM,   PCI_DEVICE_ID_ABOCOM_2BD1,
+	  PCI_ANY_ID, PCI_ANY_ID, 12 },
+	{ PCI_VENDOR_ID_ASUSTEK,  PCI_DEVICE_ID_ASUSTEK_0675,
+	  PCI_ANY_ID, PCI_ANY_ID, 13 },
+	{ PCI_VENDOR_ID_BERKOM,   PCI_DEVICE_ID_BERKOM_T_CONCEPT,
+	  PCI_ANY_ID, PCI_ANY_ID, 14 },
+	{ PCI_VENDOR_ID_BERKOM,   PCI_DEVICE_ID_BERKOM_A1T,
+	  PCI_ANY_ID, PCI_ANY_ID, 15 },
+	{ PCI_VENDOR_ID_ANIGMA,   PCI_DEVICE_ID_ANIGMA_MC145575,
+	  PCI_ANY_ID, PCI_ANY_ID, 16 },
+	{ PCI_VENDOR_ID_ZOLTRIX,  PCI_DEVICE_ID_ZOLTRIX_2BD0,
+	  PCI_ANY_ID, PCI_ANY_ID, 17 },
+	{ PCI_VENDOR_ID_DIGI,     PCI_DEVICE_ID_DIGI_DF_M_IOM2_E,
+	  PCI_ANY_ID, PCI_ANY_ID, 18 },
+	{ PCI_VENDOR_ID_DIGI,     PCI_DEVICE_ID_DIGI_DF_M_E,
+	  PCI_ANY_ID, PCI_ANY_ID, 19 },
+	{ PCI_VENDOR_ID_DIGI,     PCI_DEVICE_ID_DIGI_DF_M_IOM2_A,
+	  PCI_ANY_ID, PCI_ANY_ID, 20 },
+	{ PCI_VENDOR_ID_DIGI,     PCI_DEVICE_ID_DIGI_DF_M_A,
+	  PCI_ANY_ID, PCI_ANY_ID, 21 },
+	{ PCI_VENDOR_ID_SITECOM, PCI_DEVICE_ID_SITECOM_DC105V2,
+	  PCI_ANY_ID, PCI_ANY_ID, 22 },
+
+	{ }		/* terminate list */
+};
+
+static struct pci_driver hfc_pci_driver = {
+	.name		= "hfc_pci",
+	.id_table	= hfc_pci_table,
+	.probe		= hfc_pci_init_one,
+	.remove		= hisax_pci_remove_one,
+};
+
+static int __init hfc_mod_init(void)
+{
+	return pci_register_driver(&hfc_pci_driver);
+}
+
+static void __exit hfc_mod_exit(void)
+{
+	pci_unregister_driver(&hfc_pci_driver);
+}
+
+module_init(hfc_mod_init);
+module_exit(hfc_mod_exit);
+
+module_param_named(protocol, hfc_protocol, int, 0444);
+MODULE_PARM_DESC(protocol, "Values 0 (default) through 4. See ISDN_PTYPE_xxx in linux/isdnif.h");
+
+MODULE_DEVICE_TABLE(pci, hfc_pci_table);
+MODULE_DESCRIPTION("ISDN HiSax HFC PCI driver");
+MODULE_LICENSE("GPL");
diff --git a/drivers/isdn/hisax/w6692.c b/drivers/isdn/hisax/w6692.c
index bb1c8dd..93c601f 100644
--- a/drivers/isdn/hisax/w6692.c
+++ b/drivers/isdn/hisax/w6692.c
@@ -12,11 +12,14 @@
 
 #include <linux/init.h>
 #include "hisax.h"
+#include "hisax_proto.h"
 #include "w6692.h"
 #include "isdnl1.h"
 #include <linux/interrupt.h>
 #include <linux/pci.h>
 
+static int w6692_protocol;		/* 0 == use DEFAULT_PROTO */
+
 /* table entry in the PCI devices list */
 typedef struct {
 	int vendor_id;
@@ -990,54 +993,29 @@ w6692_card_msg(struct IsdnCardState *cs, int mt, void *arg)
 	return (0);
 }
 
-static int id_idx ;
-
-static struct pci_dev *dev_w6692 __devinitdata = NULL;
-
-int __devinit
+static int __devinit
 setup_w6692(struct IsdnCard *card)
 {
 	struct IsdnCardState *cs = card->cs;
 	char tmp[64];
-	u_char found = 0;
 	u_char pci_irq = 0;
 	u_int pci_ioaddr = 0;
+	struct pci_dev *dev_w6692 = (void *) card->para[0];
 
 	strcpy(tmp, w6692_revision);
 	printk(KERN_INFO "HiSax: W6692 driver Rev. %s\n", HiSax_getrev(tmp));
-	if (cs->typ != ISDN_CTYPE_W6692)
-		return (0);
+	WARN_ON(cs->typ != ISDN_CTYPE_W6692);
 
-	while (id_list[id_idx].vendor_id) {
-		dev_w6692 = pci_find_device(id_list[id_idx].vendor_id,
-					    id_list[id_idx].device_id,
-					    dev_w6692);
-		if (dev_w6692) {
-			if (pci_enable_device(dev_w6692))
-				continue;
-			cs->subtyp = id_idx;
-			break;
-		}
-		id_idx++;
-	}
-	if (dev_w6692) {
-		found = 1;
-		pci_irq = dev_w6692->irq;
-		/* I think address 0 is allways the configuration area */
-		/* and address 1 is the real IO space KKe 03.09.99 */
-		pci_ioaddr = pci_resource_start(dev_w6692, 1);
-		/* USR ISDN PCI card TA need some special handling */
-		if (cs->subtyp == W6692_WINBOND) {
-			if ((W6692_SV_USR == dev_w6692->subsystem_vendor) &&
-			    (W6692_SD_USR == dev_w6692->subsystem_device)) {
-				cs->subtyp = W6692_USR;
-			}
-		}
-	}
-	if (!found) {
-		printk(KERN_WARNING "W6692: No PCI card found\n");
+	if (pci_enable_device(dev_w6692))
 		return (0);
-	}
+
+	cs->subtyp = card->para[1];
+
+	pci_irq = dev_w6692->irq;
+	/* I think address 0 is allways the configuration area */
+	/* and address 1 is the real IO space KKe 03.09.99 */
+	pci_ioaddr = pci_resource_start(dev_w6692, 1);
+
 	cs->irq = pci_irq;
 	if (!cs->irq) {
 		printk(KERN_WARNING "W6692: No IRQ for PCI card found\n");
@@ -1084,3 +1062,62 @@ setup_w6692(struct IsdnCard *card)
 	printk(KERN_INFO "W6692 D_RSTA=0x%X\n", ReadW6692(cs, W_D_RSTA));
 	return (1);
 }
+
+static int __devinit w6692_pci_init_one(struct pci_dev *pdev,
+				      const struct pci_device_id *ent)
+{
+	struct IsdnCard icard = { ISDN_CTYPE_W6692, };
+	int cardnr;
+
+	icard.para[0] = (unsigned long) pdev;
+	icard.para[1] = ent->driver_data;
+	if (!w6692_protocol)
+		icard.protocol = DEFAULT_PROTO;
+	else
+		icard.protocol = w6692_protocol;
+
+	cardnr = hisax_init_hotplug(&icard, setup_w6692);
+	if (cardnr < 0)
+		return -ENODEV;
+	
+	pci_set_drvdata(pdev, (void *)(unsigned long) cardnr);
+	return 0;
+}
+
+static struct pci_device_id w6692_pci_table[] = {
+	{ PCI_VENDOR_ID_DYNALINK, PCI_DEVICE_ID_DYNALINK_IS64PH,
+	  PCI_ANY_ID, PCI_ANY_ID, 0, 0, W6692_DYNALINK },
+	{ PCI_VENDOR_ID_WINBOND2, PCI_DEVICE_ID_WINBOND2_6692,
+	  W6692_SV_USR, W6692_SD_USR, 0, 0, W6692_USR },
+	{ PCI_VENDOR_ID_WINBOND2, PCI_DEVICE_ID_WINBOND2_6692,
+	  PCI_ANY_ID, PCI_ANY_ID, 0, 0, W6692_WINBOND },
+
+	{ }		/* terminate list */
+};
+
+static struct pci_driver w6692_pci_driver = {
+	.name		= "w6692",
+	.id_table	= w6692_pci_table,
+	.probe		= w6692_pci_init_one,
+	.remove		= hisax_pci_remove_one,
+};
+
+static int __init w6692_mod_init(void)
+{
+	return pci_register_driver(&w6692_pci_driver);
+}
+
+static void __exit w6692_mod_exit(void)
+{
+	pci_unregister_driver(&w6692_pci_driver);
+}
+
+module_init(w6692_mod_init);
+module_exit(w6692_mod_exit);
+
+module_param_named(protocol, w6692_protocol, int, 0444);
+MODULE_PARM_DESC(protocol, "Values 0 (default) through 4. See ISDN_PTYPE_xxx in linux/isdnif.h");
+
+MODULE_DEVICE_TABLE(pci, w6692_pci_table);
+MODULE_DESCRIPTION("ISDN HiSax W6692 PCI driver");
+MODULE_LICENSE("GPL");
-- 
1.5.3.8


^ permalink raw reply	[flat|nested] 28+ messages in thread

* [PATCH 07/14] [ISDN] HiSax nj_s, nj_u: convert to PCI hotplug API
  2007-07-18  3:04 [PATCH 00/14] [ISDN] HiSax hotplug conversion Jeff Garzik
                   ` (3 preceding siblings ...)
  2007-07-18  3:54 ` [PATCH 06/14] [ISDN] HiSax hfc_pci, w6692: " Jeff Garzik
@ 2007-07-18  3:59 ` Jeff Garzik
  2007-07-18  4:02 ` [PATCH 08/14] [ISDN] HiSax telespci: " Jeff Garzik
                   ` (12 subsequent siblings)
  17 siblings, 0 replies; 28+ messages in thread
From: Jeff Garzik @ 2007-07-18  3:59 UTC (permalink / raw)
  To: linux-kernel, kkeil, isdn4linux

Signed-off-by: Jeff Garzik <jeff@garzik.org>
---
 drivers/isdn/hisax/Kconfig  |    8 ++--
 drivers/isdn/hisax/Makefile |    6 ++-
 drivers/isdn/hisax/config.c |   41 ++----------------
 drivers/isdn/hisax/nj_s.c   |  100 +++++++++++++++++++++++++++++++------------
 drivers/isdn/hisax/nj_u.c   |   99 +++++++++++++++++++++++++++++++-----------
 5 files changed, 158 insertions(+), 96 deletions(-)

diff --git a/drivers/isdn/hisax/Kconfig b/drivers/isdn/hisax/Kconfig
index a37a616..508bc2b 100644
--- a/drivers/isdn/hisax/Kconfig
+++ b/drivers/isdn/hisax/Kconfig
@@ -236,8 +236,8 @@ config HISAX_MIC
 	  settings.
 
 config HISAX_NETJET
-	bool "NETjet card"
-	depends on PCI && PCI_LEGACY && (BROKEN || !(SPARC || PPC || PARISC || M68K || (MIPS && !CPU_LITTLE_ENDIAN) || FRV))
+	tristate "NETjet card"
+	depends on PCI && (BROKEN || !(SPARC || PPC || PARISC || M68K || (MIPS && !CPU_LITTLE_ENDIAN) || FRV))
 	help
 	  This enables HiSax support for the NetJet from Traverse
 	  Technologies.
@@ -247,8 +247,8 @@ config HISAX_NETJET
 	  settings.
 
 config HISAX_NETJET_U
-	bool "NETspider U card"
-	depends on PCI && PCI_LEGACY && (BROKEN || !(SPARC || PPC || PARISC || M68K || (MIPS && !CPU_LITTLE_ENDIAN) || FRV))
+	tristate "NETspider U card"
+	depends on PCI && (BROKEN || !(SPARC || PPC || PARISC || M68K || (MIPS && !CPU_LITTLE_ENDIAN) || FRV))
 	help
 	  This enables HiSax support for the Netspider U interface ISDN card
 	  from Traverse Technologies.
diff --git a/drivers/isdn/hisax/Makefile b/drivers/isdn/hisax/Makefile
index c3e2ea2..30fdd94 100644
--- a/drivers/isdn/hisax/Makefile
+++ b/drivers/isdn/hisax/Makefile
@@ -19,9 +19,13 @@ obj-$(CONFIG_HISAX_BKM_A4T)		+= bkm_a4t_pci.o libhisax.o
 obj-$(CONFIG_HISAX_ENTERNOW_PCI)	+= enternow.o libhisax.o
 obj-$(CONFIG_HISAX_HFC_PCI)		+= hfc_pci.o libhisax.o
 obj-$(CONFIG_HISAX_W6692)		+= w6692.o libhisax.o
+obj-$(CONFIG_HISAX_NETJET)		+= netjet_s.o libhisax.o
+obj-$(CONFIG_HISAX_NETJET_U)		+= netjet_u.o libhisax.o
 
 bkm_a4t_pci-objs			:= bkm_a4t.o jade.o
 enternow-objs				:= enternow_pci.o amd7930_fn.o
+netjet_s-objs				:= nj_s.o
+netjet_u-objs				:= nj_u.o icc.o
 libhisax-objs				:= netjet.o isac.o arcofi.o hscx.o
 
 ifdef CONFIG_HISAX_HDLC
@@ -54,8 +58,6 @@ hisax-$(CONFIG_HISAX_TELEINT)		+= teleint.o hfc_2bs0.o
 hisax-$(CONFIG_HISAX_SEDLBAUER)		+= sedlbauer.o isar.o
 hisax-$(CONFIG_HISAX_SPORTSTER)		+= sportster.o
 hisax-$(CONFIG_HISAX_MIC)		+= mic.o
-hisax-$(CONFIG_HISAX_NETJET)		+= nj_s.o
-hisax-$(CONFIG_HISAX_NETJET_U)		+= nj_u.o icc.o
 hisax-$(CONFIG_HISAX_HFCS)		+= hfcscard.o hfc_2bds0.o
 hisax-$(CONFIG_HISAX_HFC_SX)		+= hfc_sx.o
 hisax-$(CONFIG_HISAX_NICCY)		+= niccy.o
diff --git a/drivers/isdn/hisax/config.c b/drivers/isdn/hisax/config.c
index cba06ba..09f6c12 100644
--- a/drivers/isdn/hisax/config.c
+++ b/drivers/isdn/hisax/config.c
@@ -201,13 +201,6 @@ const char *CardType[] = {
 #define DEFAULT_CFG {12,0x3e0,0,0}
 #endif
 
-#ifdef CONFIG_HISAX_NETJET
-#undef DEFAULT_CARD
-#undef DEFAULT_CFG
-#define DEFAULT_CARD ISDN_CTYPE_NETJET_S
-#define DEFAULT_CFG {0,0,0,0}
-#endif
-
 #ifdef CONFIG_HISAX_HFCS
 #undef DEFAULT_CARD
 #undef DEFAULT_CFG
@@ -257,13 +250,6 @@ const char *CardType[] = {
 #define DEFAULT_CFG {15,0x180,0,0}
 #endif
 
-#ifdef CONFIG_HISAX_NETJET_U
-#undef DEFAULT_CARD
-#undef DEFAULT_CFG
-#define DEFAULT_CARD ISDN_CTYPE_NETJET_U
-#define DEFAULT_CFG {0,0,0,0}
-#endif
-
 #ifndef DEFAULT_CARD
 #define DEFAULT_CARD 0
 #define DEFAULT_CFG {0,0,0,0}
@@ -482,10 +468,6 @@ extern int setup_sportster(struct IsdnCard *card);
 extern int setup_mic(struct IsdnCard *card);
 #endif
 
-#if CARD_NETJET_S
-extern int setup_netjet_s(struct IsdnCard *card);
-#endif
-
 #if CARD_HFCS
 extern int setup_hfcs(struct IsdnCard *card);
 #endif
@@ -514,10 +496,6 @@ extern int setup_sct_quadro(struct IsdnCard *card);
 extern int setup_gazel(struct IsdnCard *card);
 #endif
 
-#if CARD_NETJET_U
-extern int setup_netjet_u(struct IsdnCard *card);
-#endif
-
 /*
  * Find card with given driverId
  */
@@ -881,11 +859,6 @@ static int __devinit hisax_cs_setup_card(struct IsdnCard *card)
 		ret = setup_mic(card);
 		break;
 #endif
-#if CARD_NETJET_S
-	case ISDN_CTYPE_NETJET_S:
-		ret = setup_netjet_s(card);
-		break;
-#endif
 #if CARD_HFCS
 	case ISDN_CTYPE_TELES3C:
 	case ISDN_CTYPE_ACERP10:
@@ -922,11 +895,6 @@ static int __devinit hisax_cs_setup_card(struct IsdnCard *card)
 		ret = setup_gazel(card);
 		break;
 #endif
-#if CARD_NETJET_U
-	case ISDN_CTYPE_NETJET_U:
-		ret = setup_netjet_u(card);
-		break;
-#endif
 	case ISDN_CTYPE_DYNAMIC:
 		ret = 2;
 		break;
@@ -935,6 +903,8 @@ static int __devinit hisax_cs_setup_card(struct IsdnCard *card)
 	case ISDN_CTYPE_ENTERNOW:
 	case ISDN_CTYPE_HFC_PCI:
 	case ISDN_CTYPE_W6692:
+	case ISDN_CTYPE_NETJET_S:
+	case ISDN_CTYPE_NETJET_U:
 		printk(KERN_WARNING "HiSax: Support for %s Card has moved "
 		       "to separate PCI driver module\n",
 		       CardType[card->typ]);
@@ -1395,9 +1365,7 @@ static int __init HiSax_init(void)
 			cards[j].para[2] = mem[i];
 			break;
 		case ISDN_CTYPE_ELSA_PCI:
-		case ISDN_CTYPE_NETJET_S:
 		case ISDN_CTYPE_TELESPCI:
-		case ISDN_CTYPE_NETJET_U:
 			break;
 
 		/* the following block are excluded from std HiSax init */
@@ -1405,6 +1373,8 @@ static int __init HiSax_init(void)
 		case ISDN_CTYPE_ENTERNOW:
 		case ISDN_CTYPE_HFC_PCI:
 		case ISDN_CTYPE_W6692:
+		case ISDN_CTYPE_NETJET_S:
+		case ISDN_CTYPE_NETJET_U:
 			break;
 
 		case ISDN_CTYPE_SCT_QUADRO:
@@ -1908,9 +1878,6 @@ static struct pci_device_id hisax_pci_tbl[] __devinitdata = {
 #ifdef CONFIG_HISAX_SEDLBAUER
 	{PCI_VENDOR_ID_TIGERJET, PCI_DEVICE_ID_TIGERJET_100,     PCI_ANY_ID,PCI_ANY_ID},
 #endif
-#if defined(CONFIG_HISAX_NETJET) || defined(CONFIG_HISAX_NETJET_U)
-	{PCI_VENDOR_ID_TIGERJET, PCI_DEVICE_ID_TIGERJET_300,     PCI_ANY_ID,PCI_ANY_ID},
-#endif
 #if defined(CONFIG_HISAX_TELESPCI) || defined(CONFIG_HISAX_SCT_QUADRO)
 	{PCI_VENDOR_ID_ZORAN,    PCI_DEVICE_ID_ZORAN_36120,      PCI_ANY_ID,PCI_ANY_ID},
 #endif
diff --git a/drivers/isdn/hisax/nj_s.c b/drivers/isdn/hisax/nj_s.c
index 8d36ccc..a50c1ae 100644
--- a/drivers/isdn/hisax/nj_s.c
+++ b/drivers/isdn/hisax/nj_s.c
@@ -7,6 +7,7 @@
 
 #include <linux/init.h>
 #include "hisax.h"
+#include "hisax_proto.h"
 #include "isac.h"
 #include "isdnl1.h"
 #include <linux/pci.h>
@@ -14,6 +15,8 @@
 #include <linux/ppp_defs.h>
 #include "netjet.h"
 
+static int njs_protocol = 0;		/* 0 == use DEFAULT_PROTO */
+
 static const char *NETjet_S_revision = "$Revision: 2.13.2.4 $";
 
 static u_char dummyrr(struct IsdnCardState *cs, int chan, u_char off)
@@ -156,6 +159,8 @@ static int __devinit njs_pci_probe(struct pci_dev *dev_netjet,
 	if (pci_enable_device(dev_netjet))
 		return(0);
 	pci_set_master(dev_netjet);
+
+	cs->hw.njet.dev = dev_netjet;
 	cs->irq = dev_netjet->irq;
 	if (!cs->irq) {
 		printk(KERN_WARNING "NETjet-S: No IRQ for PCI card found\n");
@@ -212,17 +217,17 @@ static int __devinit njs_cs_init(struct IsdnCard *card,
 	switch ( ( ( NETjet_ReadIC( cs, ISAC_RBCH ) >> 5 ) & 3 ) )
 	{
 		case 0 :
-			return 1;	/* end loop */
+			return 1;	/* found card */
 
 		case 3 :
 			printk( KERN_WARNING "NETjet-S: NETspider-U PCI card found\n" );
-			return -1;	/* continue looping */
+			return 0;	/* no NETjet-S found */
 
 		default :
 			printk( KERN_WARNING "NETjet-S: No PCI card found\n" );
-			return 0;	/* end loop & function */
+			return 0;	/* no NETjet-S found */
 	}
-	return 1;			/* end loop */
+	return 1;			/* found card */
 }
 
 static int __devinit njs_cs_init_rest(struct IsdnCard *card,
@@ -256,43 +261,84 @@ static int __devinit njs_cs_init_rest(struct IsdnCard *card,
 	return (1);
 }
 
-static struct pci_dev *dev_netjet __devinitdata = NULL;
-
-int __devinit
+static int __devinit
 setup_netjet_s(struct IsdnCard *card)
 {
 	int ret;
 	struct IsdnCardState *cs = card->cs;
 	char tmp[64];
+	struct pci_dev *dev_netjet = (void *) card->para[0];
 
 #ifdef __BIG_ENDIAN
 #error "not running on big endian machines now"
 #endif
 	strcpy(tmp, NETjet_S_revision);
 	printk(KERN_INFO "HiSax: Traverse Tech. NETjet-S driver Rev. %s\n", HiSax_getrev(tmp));
-	if (cs->typ != ISDN_CTYPE_NETJET_S)
-		return(0);
+
+	WARN_ON(cs->typ != ISDN_CTYPE_NETJET_S);
+
 	test_and_clear_bit(FLG_LOCK_ATOMIC, &cs->HW_Flags);
 
-	for ( ;; )
-	{
-		if ((dev_netjet = pci_find_device(PCI_VENDOR_ID_TIGERJET,
-			PCI_DEVICE_ID_TIGERJET_300,  dev_netjet))) {
-			ret = njs_pci_probe(dev_netjet, cs);
-			if (!ret)
-				return(0);
-		} else {
-			printk(KERN_WARNING "NETjet-S: No PCI card found\n");
-			return(0);
-		}
+	ret = njs_pci_probe(dev_netjet, cs);
+	if (!ret)
+		return(0);
 
-		ret = njs_cs_init(card, cs);
-		if (!ret)
-			return(0);
-		if (ret > 0)
-			break;
-		/* otherwise, ret < 0, continue looping */
-	}
+	ret = njs_cs_init(card, cs);
+	if (ret <= 0)
+		return(0);
 
 	return njs_cs_init_rest(card, cs);
 }
+
+static int __devinit njs_pci_init_one(struct pci_dev *pdev,
+				      const struct pci_device_id *ent)
+{
+	struct IsdnCard icard = { ISDN_CTYPE_NETJET_S, };
+	int cardnr;
+
+	icard.para[0] = (unsigned long) pdev;
+	if (!njs_protocol)
+		icard.protocol = DEFAULT_PROTO;
+	else
+		icard.protocol = njs_protocol;
+
+	cardnr = hisax_init_hotplug(&icard, setup_netjet_s);
+	if (cardnr < 0)
+		return -ENODEV;
+	
+	pci_set_drvdata(pdev, (void *)(unsigned long) cardnr);
+	return 0;
+}
+
+static struct pci_device_id njs_pci_table[] = {
+	{ PCI_VDEVICE(TIGERJET, PCI_DEVICE_ID_TIGERJET_300) },
+
+	{ }		/* terminate list */
+};
+
+static struct pci_driver njs_pci_driver = {
+	.name		= "nj_s",
+	.id_table	= njs_pci_table,
+	.probe		= njs_pci_init_one,
+	.remove		= hisax_pci_remove_one,
+};
+
+static int __init njs_mod_init(void)
+{
+	return pci_register_driver(&njs_pci_driver);
+}
+
+static void __exit njs_mod_exit(void)
+{
+	pci_unregister_driver(&njs_pci_driver);
+}
+
+module_init(njs_mod_init);
+module_exit(njs_mod_exit);
+
+module_param_named(protocol, njs_protocol, int, 0444);
+MODULE_PARM_DESC(protocol, "Values 0 (default) through 4. See ISDN_PTYPE_xxx in linux/isdnif.h");
+
+MODULE_DEVICE_TABLE(pci, njs_pci_table);
+MODULE_DESCRIPTION("ISDN HiSax NETjet-S PCI driver");
+MODULE_LICENSE("GPL");
diff --git a/drivers/isdn/hisax/nj_u.c b/drivers/isdn/hisax/nj_u.c
index d306c94..c30d173 100644
--- a/drivers/isdn/hisax/nj_u.c
+++ b/drivers/isdn/hisax/nj_u.c
@@ -7,6 +7,7 @@
 
 #include <linux/init.h>
 #include "hisax.h"
+#include "hisax_proto.h"
 #include "icc.h"
 #include "isdnl1.h"
 #include <linux/pci.h>
@@ -14,6 +15,8 @@
 #include <linux/ppp_defs.h>
 #include "netjet.h"
 
+static int nju_protocol;	/* 0 == use DEFAULT_PROTO */
+
 static const char *NETjet_U_revision = "$Revision: 2.14.2.3 $";
 
 static u_char dummyrr(struct IsdnCardState *cs, int chan, u_char off)
@@ -133,7 +136,10 @@ static int __devinit nju_pci_probe(struct pci_dev *dev_netjet,
 {
 	if (pci_enable_device(dev_netjet))
 		return(0);
+
 	pci_set_master(dev_netjet);
+
+	cs->hw.njet.dev = dev_netjet;
 	cs->irq = dev_netjet->irq;
 	if (!cs->irq) {
 		printk(KERN_WARNING "NETspider-U: No IRQ for PCI card found\n");
@@ -174,17 +180,17 @@ static int __devinit nju_cs_init(struct IsdnCard *card,
 	switch ( ( ( NETjet_ReadIC( cs, ICC_RBCH ) >> 5 ) & 3 ) )
 	{
 		case 3 :
-			return 1;	/* end loop */
+			return 1;	/* found card */
 
 		case 0 :
 			printk( KERN_WARNING "NETspider-U: NETjet-S PCI card found\n" );
-			return -1;	/* continue looping */
+			return 0;	/* no NETjet-U found */
 
 		default :
 			printk( KERN_WARNING "NETspider-U: No PCI card found\n" );
-			return 0;	/* end loop & function */
+			return 0;	/* no NETjet-U found */
 	}
-	return 1;			/* end loop */
+	return 1;			/* found card */
 }
 
 static int __devinit nju_cs_init_rest(struct IsdnCard *card,
@@ -219,14 +225,14 @@ static int __devinit nju_cs_init_rest(struct IsdnCard *card,
 	return (1);
 }
 
-static struct pci_dev *dev_netjet __devinitdata = NULL;
 
-int __devinit
+static int __devinit
 setup_netjet_u(struct IsdnCard *card)
 {
 	int ret;
 	struct IsdnCardState *cs = card->cs;
 	char tmp[64];
+	struct pci_dev *dev_netjet = (void *) card->para[0];
 
 #ifdef __BIG_ENDIAN
 #error "not running on big endian machines now"
@@ -234,29 +240,70 @@ setup_netjet_u(struct IsdnCard *card)
 
 	strcpy(tmp, NETjet_U_revision);
 	printk(KERN_INFO "HiSax: Traverse Tech. NETspider-U driver Rev. %s\n", HiSax_getrev(tmp));
-	if (cs->typ != ISDN_CTYPE_NETJET_U)
-		return(0);
+
+	WARN_ON(cs->typ != ISDN_CTYPE_NETJET_U);
+
 	test_and_clear_bit(FLG_LOCK_ATOMIC, &cs->HW_Flags);
 
-	for ( ;; )
-	{
-		if ((dev_netjet = pci_find_device(PCI_VENDOR_ID_TIGERJET,
-			PCI_DEVICE_ID_TIGERJET_300,  dev_netjet))) {
-			ret = nju_pci_probe(dev_netjet, cs);
-			if (!ret)
-				return(0);
-		} else {
-			printk(KERN_WARNING "NETspider-U: No PCI card found\n");
-			return(0);
-		}
+	ret = nju_pci_probe(dev_netjet, cs);
+	if (!ret)
 
-		ret = nju_cs_init(card, cs);
-		if (!ret)
-			return (0);
-		if (ret > 0)
-			break;
-		/* ret < 0 == continue looping */
-	}
+	ret = nju_cs_init(card, cs);
+	if (!ret)
+		return (0);
 
 	return nju_cs_init_rest(card, cs);
 }
+
+static int __devinit nju_pci_init_one(struct pci_dev *pdev,
+				      const struct pci_device_id *ent)
+{
+	struct IsdnCard icard = { ISDN_CTYPE_NETJET_U, };
+	int cardnr;
+
+	icard.para[0] = (unsigned long) pdev;
+	if (!nju_protocol)
+		icard.protocol = DEFAULT_PROTO;
+	else
+		icard.protocol = nju_protocol;
+
+	cardnr = hisax_init_hotplug(&icard, setup_netjet_u);
+	if (cardnr < 0)
+		return -ENODEV;
+	
+	pci_set_drvdata(pdev, (void *)(unsigned long) cardnr);
+	return 0;
+}
+
+static struct pci_device_id nju_pci_table[] = {
+	{ PCI_VDEVICE(TIGERJET, PCI_DEVICE_ID_TIGERJET_300) },
+
+	{ }		/* terminate list */
+};
+
+static struct pci_driver nju_pci_driver = {
+	.name		= "nj_u",
+	.id_table	= nju_pci_table,
+	.probe		= nju_pci_init_one,
+	.remove		= hisax_pci_remove_one,
+};
+
+static int __init nju_mod_init(void)
+{
+	return pci_register_driver(&nju_pci_driver);
+}
+
+static void __exit nju_mod_exit(void)
+{
+	pci_unregister_driver(&nju_pci_driver);
+}
+
+module_init(nju_mod_init);
+module_exit(nju_mod_exit);
+
+module_param_named(protocol, nju_protocol, int, 0444);
+MODULE_PARM_DESC(protocol, "Values 0 (default) through 4. See ISDN_PTYPE_xxx in linux/isdnif.h");
+
+MODULE_DEVICE_TABLE(pci, nju_pci_table);
+MODULE_DESCRIPTION("ISDN HiSax NETjet-U PCI driver");
+MODULE_LICENSE("GPL");
-- 
1.5.3.8


^ permalink raw reply	[flat|nested] 28+ messages in thread

* [PATCH 08/14] [ISDN] HiSax telespci: convert to PCI hotplug API
  2007-07-18  3:04 [PATCH 00/14] [ISDN] HiSax hotplug conversion Jeff Garzik
                   ` (4 preceding siblings ...)
  2007-07-18  3:59 ` [PATCH 07/14] [ISDN] HiSax nj_s, nj_u: " Jeff Garzik
@ 2007-07-18  4:02 ` Jeff Garzik
  2007-07-24 12:26 ` [PATCH 11/14] [ISDN] HiSax niccy: convert to modern ISA/PNP/PCI probing Jeff Garzik
                   ` (11 subsequent siblings)
  17 siblings, 0 replies; 28+ messages in thread
From: Jeff Garzik @ 2007-07-18  4:02 UTC (permalink / raw)
  To: linux-kernel, kkeil, isdn4linux

Signed-off-by: Jeff Garzik <jeff@garzik.org>
---
 drivers/isdn/hisax/Kconfig    |    4 +-
 drivers/isdn/hisax/Makefile   |    2 +-
 drivers/isdn/hisax/config.c   |   21 +--------
 drivers/isdn/hisax/telespci.c |   95 ++++++++++++++++++++++++++++++++---------
 4 files changed, 81 insertions(+), 41 deletions(-)

diff --git a/drivers/isdn/hisax/Kconfig b/drivers/isdn/hisax/Kconfig
index 508bc2b..4f98afb 100644
--- a/drivers/isdn/hisax/Kconfig
+++ b/drivers/isdn/hisax/Kconfig
@@ -108,8 +108,8 @@ config HISAX_16_3
 	  non-standard IRQ/port settings.
 
 config HISAX_TELESPCI
-	bool "Teles PCI"
-	depends on PCI && PCI_LEGACY && (BROKEN || !(SPARC || PPC || PARISC || M68K || (MIPS && !CPU_LITTLE_ENDIAN) || FRV))
+	tristate "Teles PCI"
+	depends on PCI && (BROKEN || !(SPARC || PPC || PARISC || M68K || (MIPS && !CPU_LITTLE_ENDIAN) || FRV))
 	help
 	  This enables HiSax support for the Teles PCI.
 	  See <file:Documentation/isdn/README.HiSax> on how to configure it.
diff --git a/drivers/isdn/hisax/Makefile b/drivers/isdn/hisax/Makefile
index 30fdd94..d3e464a 100644
--- a/drivers/isdn/hisax/Makefile
+++ b/drivers/isdn/hisax/Makefile
@@ -21,6 +21,7 @@ obj-$(CONFIG_HISAX_HFC_PCI)		+= hfc_pci.o libhisax.o
 obj-$(CONFIG_HISAX_W6692)		+= w6692.o libhisax.o
 obj-$(CONFIG_HISAX_NETJET)		+= netjet_s.o libhisax.o
 obj-$(CONFIG_HISAX_NETJET_U)		+= netjet_u.o libhisax.o
+obj-$(CONFIG_HISAX_TELESPCI)		+= telespci.o libhisax.o
 
 bkm_a4t_pci-objs			:= bkm_a4t.o jade.o
 enternow-objs				:= enternow_pci.o amd7930_fn.o
@@ -45,7 +46,6 @@ hisax-$(CONFIG_HISAX_1TR6)		+= l3_1tr6.o
 
 hisax-$(CONFIG_HISAX_16_0)		+= teles0.o
 hisax-$(CONFIG_HISAX_16_3)		+= teles3.o
-hisax-$(CONFIG_HISAX_TELESPCI)		+= telespci.o
 hisax-$(CONFIG_HISAX_S0BOX)		+= s0box.o
 hisax-$(CONFIG_HISAX_AVM_A1)		+= avm_a1.o
 hisax-$(CONFIG_HISAX_AVM_A1_PCMCIA)	+= avm_a1p.o
diff --git a/drivers/isdn/hisax/config.c b/drivers/isdn/hisax/config.c
index 09f6c12..77c00c9 100644
--- a/drivers/isdn/hisax/config.c
+++ b/drivers/isdn/hisax/config.c
@@ -145,13 +145,6 @@ const char *CardType[] = {
 #define DEFAULT_CFG {15,0xd0000,0xd80,0}
 #endif
 
-#ifdef CONFIG_HISAX_TELESPCI
-#undef DEFAULT_CARD
-#undef DEFAULT_CFG
-#define DEFAULT_CARD ISDN_CTYPE_TELESPCI
-#define DEFAULT_CFG {0,0,0,0}
-#endif
-
 #ifdef CONFIG_HISAX_IX1MICROR2
 #undef DEFAULT_CARD
 #undef DEFAULT_CFG
@@ -420,10 +413,6 @@ extern int setup_teles3(struct IsdnCard *card);
 extern int setup_s0box(struct IsdnCard *card);
 #endif
 
-#if CARD_TELESPCI
-extern int setup_telespci(struct IsdnCard *card);
-#endif
-
 #if CARD_AVM_A1
 extern int setup_avm_a1(struct IsdnCard *card);
 #endif
@@ -794,11 +783,6 @@ static int __devinit hisax_cs_setup_card(struct IsdnCard *card)
 		ret = setup_s0box(card);
 		break;
 #endif
-#if CARD_TELESPCI
-	case ISDN_CTYPE_TELESPCI:
-		ret = setup_telespci(card);
-		break;
-#endif
 #if CARD_AVM_A1
 	case ISDN_CTYPE_A1:
 		ret = setup_avm_a1(card);
@@ -905,6 +889,7 @@ static int __devinit hisax_cs_setup_card(struct IsdnCard *card)
 	case ISDN_CTYPE_W6692:
 	case ISDN_CTYPE_NETJET_S:
 	case ISDN_CTYPE_NETJET_U:
+	case ISDN_CTYPE_TELESPCI:
 		printk(KERN_WARNING "HiSax: Support for %s Card has moved "
 		       "to separate PCI driver module\n",
 		       CardType[card->typ]);
@@ -1365,7 +1350,6 @@ static int __init HiSax_init(void)
 			cards[j].para[2] = mem[i];
 			break;
 		case ISDN_CTYPE_ELSA_PCI:
-		case ISDN_CTYPE_TELESPCI:
 			break;
 
 		/* the following block are excluded from std HiSax init */
@@ -1375,6 +1359,7 @@ static int __init HiSax_init(void)
 		case ISDN_CTYPE_W6692:
 		case ISDN_CTYPE_NETJET_S:
 		case ISDN_CTYPE_NETJET_U:
+		case ISDN_CTYPE_TELESPCI:
 			break;
 
 		case ISDN_CTYPE_SCT_QUADRO:
@@ -1878,7 +1863,7 @@ static struct pci_device_id hisax_pci_tbl[] __devinitdata = {
 #ifdef CONFIG_HISAX_SEDLBAUER
 	{PCI_VENDOR_ID_TIGERJET, PCI_DEVICE_ID_TIGERJET_100,     PCI_ANY_ID,PCI_ANY_ID},
 #endif
-#if defined(CONFIG_HISAX_TELESPCI) || defined(CONFIG_HISAX_SCT_QUADRO)
+#if defined(CONFIG_HISAX_SCT_QUADRO)
 	{PCI_VENDOR_ID_ZORAN,    PCI_DEVICE_ID_ZORAN_36120,      PCI_ANY_ID,PCI_ANY_ID},
 #endif
 	{ }				/* Terminating entry */
diff --git a/drivers/isdn/hisax/telespci.c b/drivers/isdn/hisax/telespci.c
index 28b08de..a06d043 100644
--- a/drivers/isdn/hisax/telespci.c
+++ b/drivers/isdn/hisax/telespci.c
@@ -14,11 +14,14 @@
 
 #include <linux/init.h>
 #include "hisax.h"
+#include "hisax_proto.h"
 #include "isac.h"
 #include "hscx.h"
 #include "isdnl1.h"
 #include <linux/pci.h>
 
+static int teles_protocol;		/* 0 == use DEFAULT_PROTO */
+
 static const char *telespci_revision = "$Revision: 2.23.2.3 $";
 
 #define ZORAN_PO_RQ_PEN	0x02000000
@@ -283,12 +286,11 @@ TelesPCI_card_msg(struct IsdnCardState *cs, int mt, void *arg)
 	return(0);
 }
 
-static struct pci_dev *dev_tel __devinitdata = NULL;
-
-int __devinit
+static int __devinit
 setup_telespci(struct IsdnCard *card)
 {
 	struct IsdnCardState *cs = card->cs;
+	struct pci_dev *dev_tel = (void *) card->para[0];
 	char tmp[64];
 
 #ifdef __BIG_ENDIAN
@@ -297,26 +299,24 @@ setup_telespci(struct IsdnCard *card)
 
 	strcpy(tmp, telespci_revision);
 	printk(KERN_INFO "HiSax: Teles/PCI driver Rev. %s\n", HiSax_getrev(tmp));
-	if (cs->typ != ISDN_CTYPE_TELESPCI)
-		return (0);
+	WARN_ON(cs->typ != ISDN_CTYPE_TELESPCI);
 
-	if ((dev_tel = pci_find_device (PCI_VENDOR_ID_ZORAN, PCI_DEVICE_ID_ZORAN_36120, dev_tel))) {
-		if (pci_enable_device(dev_tel))
-			return(0);
-		cs->irq = dev_tel->irq;
-		if (!cs->irq) {
-			printk(KERN_WARNING "Teles: No IRQ for PCI card found\n");
-			return(0);
-		}
-		cs->hw.teles0.membase = ioremap(pci_resource_start(dev_tel, 0),
-			PAGE_SIZE);
-		printk(KERN_INFO "Found: Zoran, base-address: 0x%llx, irq: 0x%x\n",
-			(unsigned long long)pci_resource_start(dev_tel, 0),
-			dev_tel->irq);
-	} else {
-		printk(KERN_WARNING "TelesPCI: No PCI card found\n");
+	if (pci_enable_device(dev_tel))
+		return(0);
+	cs->irq = dev_tel->irq;
+	if (!cs->irq) {
+		printk(KERN_WARNING "Teles: No IRQ for PCI card found\n");
 		return(0);
 	}
+	cs->hw.teles0.membase = ioremap(pci_resource_start(dev_tel, 0),
+		PAGE_SIZE);
+	if (!cs->hw.teles0.membase) {
+		printk(KERN_WARNING "Teles: ioremap failed\n");
+		return(0);
+	}
+	printk(KERN_INFO "Found: Zoran, base-address: 0x%llx, irq: 0x%x\n",
+		(unsigned long long)pci_resource_start(dev_tel, 0),
+		dev_tel->irq);
 
 	/* Initialize Zoran PCI controller */
 	writel(0x00000000, cs->hw.teles0.membase + 0x28);
@@ -352,3 +352,58 @@ setup_telespci(struct IsdnCard *card)
 	}
 	return (1);
 }
+
+static int __devinit teles_pci_init_one(struct pci_dev *pdev,
+				      const struct pci_device_id *ent)
+{
+	struct IsdnCard icard = { ISDN_CTYPE_TELESPCI, };
+	int cardnr;
+
+	icard.para[0] = (unsigned long) pdev;
+	icard.para[1] = ent->driver_data;
+	if (!teles_protocol)
+		icard.protocol = DEFAULT_PROTO;
+	else
+		icard.protocol = teles_protocol;
+
+	cardnr = hisax_init_hotplug(&icard, setup_telespci);
+	if (cardnr < 0)
+		return -ENODEV;
+	
+	pci_set_drvdata(pdev, (void *)(unsigned long) cardnr);
+	return 0;
+}
+
+static struct pci_device_id teles_pci_table[] = {
+	{ PCI_VENDOR_ID_ZORAN, PCI_DEVICE_ID_ZORAN_36120,
+	  PCI_ANY_ID, PCI_ANY_ID, },
+
+	{ }		/* terminate list */
+};
+
+static struct pci_driver teles_pci_driver = {
+	.name		= "telespci",
+	.id_table	= teles_pci_table,
+	.probe		= teles_pci_init_one,
+	.remove		= hisax_pci_remove_one,
+};
+
+static int __init teles_mod_init(void)
+{
+	return pci_register_driver(&teles_pci_driver);
+}
+
+static void __exit teles_mod_exit(void)
+{
+	pci_unregister_driver(&teles_pci_driver);
+}
+
+module_init(teles_mod_init);
+module_exit(teles_mod_exit);
+
+module_param_named(protocol, teles_protocol, int, 0444);
+MODULE_PARM_DESC(protocol, "Values 0 (default) through 4. See ISDN_PTYPE_xxx in linux/isdnif.h");
+
+MODULE_DEVICE_TABLE(pci, teles_pci_table);
+MODULE_DESCRIPTION("ISDN HiSax Teles PCI driver");
+MODULE_LICENSE("GPL");
-- 
1.5.3.8


^ permalink raw reply	[flat|nested] 28+ messages in thread

* [PATCH 11/14] [ISDN] HiSax niccy: convert to modern ISA/PNP/PCI probing
  2007-07-18  3:04 [PATCH 00/14] [ISDN] HiSax hotplug conversion Jeff Garzik
                   ` (5 preceding siblings ...)
  2007-07-18  4:02 ` [PATCH 08/14] [ISDN] HiSax telespci: " Jeff Garzik
@ 2007-07-24 12:26 ` Jeff Garzik
  2007-08-02 12:37 ` [PATCH 13/14] [ISDN] HiSax bkm_a8: convert to PCI hotplug API Jeff Garzik
                   ` (10 subsequent siblings)
  17 siblings, 0 replies; 28+ messages in thread
From: Jeff Garzik @ 2007-07-24 12:26 UTC (permalink / raw)
  To: linux-kernel, kkeil, isdn4linux

Signed-off-by: Jeff Garzik <jeff@garzik.org>
---
 drivers/isdn/hisax/Kconfig  |    3 +-
 drivers/isdn/hisax/Makefile |    2 +-
 drivers/isdn/hisax/config.c |   26 +---
 drivers/isdn/hisax/niccy.c  |  460 +++++++++++++++++++++++++++++++------------
 4 files changed, 334 insertions(+), 157 deletions(-)

diff --git a/drivers/isdn/hisax/Kconfig b/drivers/isdn/hisax/Kconfig
index dbc296e..02cdc57 100644
--- a/drivers/isdn/hisax/Kconfig
+++ b/drivers/isdn/hisax/Kconfig
@@ -257,7 +257,8 @@ config HISAX_NETJET_U
 	  settings.
 
 config HISAX_NICCY
-	bool "Niccy PnP/PCI card"
+	tristate "Niccy PnP/PCI card"
+	depends on (ISA || PCI)
 	help
 	  This enables HiSax support for the Dr. Neuhaus Niccy PnP or PCI.
 
diff --git a/drivers/isdn/hisax/Makefile b/drivers/isdn/hisax/Makefile
index e67bf92..f840b23 100644
--- a/drivers/isdn/hisax/Makefile
+++ b/drivers/isdn/hisax/Makefile
@@ -24,6 +24,7 @@ obj-$(CONFIG_HISAX_NETJET_U)		+= netjet_u.o libhisax.o
 obj-$(CONFIG_HISAX_TELESPCI)		+= telespci.o libhisax.o
 obj-$(CONFIG_HISAX_FRITZPCI)		+= avm_pci.o libhisax.o
 obj-$(CONFIG_HISAX_GAZEL)		+= gazel.o libhisax.o
+obj-$(CONFIG_HISAX_NICCY)		+= niccy.o libhisax.o
 
 bkm_a4t_pci-objs			:= bkm_a4t.o jade.o
 enternow-objs				:= enternow_pci.o amd7930_fn.o
@@ -61,7 +62,6 @@ hisax-$(CONFIG_HISAX_SPORTSTER)		+= sportster.o
 hisax-$(CONFIG_HISAX_MIC)		+= mic.o
 hisax-$(CONFIG_HISAX_HFCS)		+= hfcscard.o hfc_2bds0.o
 hisax-$(CONFIG_HISAX_HFC_SX)		+= hfc_sx.o
-hisax-$(CONFIG_HISAX_NICCY)		+= niccy.o
 hisax-$(CONFIG_HISAX_ISURF)		+= isurf.o isar.o
 hisax-$(CONFIG_HISAX_HSTSAPHIR)		+= saphir.o
 hisax-$(CONFIG_HISAX_SCT_QUADRO)	+= bkm_a8.o
diff --git a/drivers/isdn/hisax/config.c b/drivers/isdn/hisax/config.c
index ec949f6..7a1eb7d 100644
--- a/drivers/isdn/hisax/config.c
+++ b/drivers/isdn/hisax/config.c
@@ -201,13 +201,6 @@ const char *CardType[] = {
 #define DEFAULT_CFG {5,0x2E0,0,0}
 #endif
 
-#ifdef CONFIG_HISAX_NICCY
-#undef DEFAULT_CARD
-#undef DEFAULT_CFG
-#define DEFAULT_CARD ISDN_CTYPE_NICCY
-#define DEFAULT_CFG {0,0x0,0,0}
-#endif
-
 #ifdef CONFIG_HISAX_ISURF
 #undef DEFAULT_CARD
 #undef DEFAULT_CFG
@@ -258,10 +251,6 @@ static int io[HISAX_MAX_CARDS] = { 0, };
 #ifdef CONFIG_HISAX_16_3
 #define IO0_IO1
 #endif
-#ifdef CONFIG_HISAX_NICCY
-#undef IO0_IO1
-#define IO0_IO1
-#endif
 #ifdef IO0_IO1
 static int io0[HISAX_MAX_CARDS] __devinitdata = { 0, };
 static int io1[HISAX_MAX_CARDS] __devinitdata = { 0, };
@@ -447,10 +436,6 @@ extern int setup_hfcs(struct IsdnCard *card);
 extern int setup_hfcsx(struct IsdnCard *card);
 #endif
 
-#if CARD_NICCY
-extern int setup_niccy(struct IsdnCard *card);
-#endif
-
 #if CARD_ISURF
 extern int setup_isurf(struct IsdnCard *card);
 #endif
@@ -827,11 +812,6 @@ static int __devinit hisax_cs_setup_card(struct IsdnCard *card)
 		ret = setup_hfcsx(card);
 		break;
 #endif
-#if CARD_NICCY
-	case ISDN_CTYPE_NICCY:
-		ret = setup_niccy(card);
-		break;
-#endif
 #if CARD_ISURF
 	case ISDN_CTYPE_ISURF:
 		ret = setup_isurf(card);
@@ -860,6 +840,7 @@ static int __devinit hisax_cs_setup_card(struct IsdnCard *card)
 	case ISDN_CTYPE_TELESPCI:
 	case ISDN_CTYPE_FRITZPCI:
 	case ISDN_CTYPE_GAZEL:
+	case ISDN_CTYPE_NICCY:
 		printk(KERN_WARNING "HiSax: Support for %s Card has moved "
 		       "to separate PCI driver module\n",
 		       CardType[card->typ]);
@@ -1273,7 +1254,6 @@ static int __init HiSax_init(void)
 
 #ifdef IO0_IO1
 		case ISDN_CTYPE_PNP:
-		case ISDN_CTYPE_NICCY:
 			cards[j].para[0] = irq[i];
 			cards[j].para[1] = io0[i];
 			cards[j].para[2] = io1[i];
@@ -1330,6 +1310,7 @@ static int __init HiSax_init(void)
 		case ISDN_CTYPE_TELESPCI:
 		case ISDN_CTYPE_FRITZPCI:
 		case ISDN_CTYPE_GAZEL:
+		case ISDN_CTYPE_NICCY:
 			break;
 
 		case ISDN_CTYPE_SCT_QUADRO:
@@ -1818,9 +1799,6 @@ static struct pci_device_id hisax_pci_tbl[] __devinitdata = {
 #ifdef CONFIG_HISAX_SCT_QUADRO
 	{PCI_VENDOR_ID_PLX,      PCI_DEVICE_ID_PLX_9050,         PCI_ANY_ID, PCI_ANY_ID},
 #endif
-#ifdef CONFIG_HISAX_NICCY
-	{PCI_VENDOR_ID_SATSAGEM, PCI_DEVICE_ID_SATSAGEM_NICCY,   PCI_ANY_ID,PCI_ANY_ID},
-#endif
 #ifdef CONFIG_HISAX_SEDLBAUER
 	{PCI_VENDOR_ID_TIGERJET, PCI_DEVICE_ID_TIGERJET_100,     PCI_ANY_ID,PCI_ANY_ID},
 #endif
diff --git a/drivers/isdn/hisax/niccy.c b/drivers/isdn/hisax/niccy.c
index 421b8e6..20d4285 100644
--- a/drivers/isdn/hisax/niccy.c
+++ b/drivers/isdn/hisax/niccy.c
@@ -15,11 +15,21 @@
 
 #include <linux/init.h>
 #include "hisax.h"
+#include "hisax_proto.h"
 #include "isac.h"
 #include "hscx.h"
 #include "isdnl1.h"
 #include <linux/pci.h>
-#include <linux/isapnp.h>
+#include <linux/pnp.h>
+#include <linux/isa.h>
+
+static int niccy_protocol;		/* 0 == use DEFAULT_PROTO */
+
+#ifdef CONFIG_ISA
+static int niccy_base0;
+static int niccy_base1;
+static int niccy_irq;
+#endif /* CONFIG_ISA */
 
 static const char *niccy_revision = "$Revision: 1.21.2.4 $";
 
@@ -222,142 +232,18 @@ static int niccy_card_msg(struct IsdnCardState *cs, int mt, void *arg)
 	return 0;
 }
 
-#ifdef __ISAPNP__
-static struct pnp_card *pnp_c __devinitdata = NULL;
-#endif
-
-int __devinit setup_niccy(struct IsdnCard *card)
+static int __devinit setup_niccy(struct IsdnCard *card)
 {
 	struct IsdnCardState *cs = card->cs;
 	char tmp[64];
 
 	strcpy(tmp, niccy_revision);
 	printk(KERN_INFO "HiSax: Niccy driver Rev. %s\n", HiSax_getrev(tmp));
-	if (cs->typ != ISDN_CTYPE_NICCY)
-		return 0;
-#ifdef __ISAPNP__
-	if (!card->para[1] && isapnp_present()) {
-		struct pnp_dev *pnp_d = NULL;
-		int err;
-
-		pnp_c = pnp_find_card(ISAPNP_VENDOR('S', 'D', 'A'),
-				ISAPNP_FUNCTION(0x0150), pnp_c);
-		if (pnp_c) {
-			pnp_d = pnp_find_dev(pnp_c,
-					ISAPNP_VENDOR('S', 'D', 'A'),
-					ISAPNP_FUNCTION(0x0150), pnp_d);
-			if (!pnp_d) {
-				printk(KERN_ERR "NiccyPnP: PnP error card "
-					"found, no device\n");
-				return 0;
-			}
-			pnp_disable_dev(pnp_d);
-			err = pnp_activate_dev(pnp_d);
-			if (err < 0) {
-				printk(KERN_WARNING "%s: pnp_activate_dev "
-					"ret(%d)\n", __FUNCTION__, err);
-				return 0;
-			}
-			card->para[1] = pnp_port_start(pnp_d, 0);
-			card->para[2] = pnp_port_start(pnp_d, 1);
-			card->para[0] = pnp_irq(pnp_d, 0);
-			if (!card->para[0] || !card->para[1] ||
-					!card->para[2]) {
-				printk(KERN_ERR "NiccyPnP:some resources are "
-					"missing %ld/%lx/%lx\n",
-					card->para[0], card->para[1],
-					card->para[2]);
-				pnp_disable_dev(pnp_d);
-				return 0;
-			}
-		} else
-			printk(KERN_INFO "NiccyPnP: no ISAPnP card found\n");
-	}
-#endif
-	if (card->para[1]) {
-		cs->hw.niccy.isac = card->para[1] + ISAC_PNP;
-		cs->hw.niccy.hscx = card->para[1] + HSCX_PNP;
-		cs->hw.niccy.isac_ale = card->para[2] + ISAC_PNP;
-		cs->hw.niccy.hscx_ale = card->para[2] + HSCX_PNP;
-		cs->hw.niccy.cfg_reg = 0;
-		cs->subtyp = NICCY_PNP;
-		cs->irq = card->para[0];
-		if (!request_region(cs->hw.niccy.isac, 2, "niccy data")) {
-			printk(KERN_WARNING "HiSax: NICCY data port %x-%x "
-				"already in use\n",
-				cs->hw.niccy.isac, cs->hw.niccy.isac + 1);
-			return 0;
-		}
-		if (!request_region(cs->hw.niccy.isac_ale, 2, "niccy addr")) {
-			printk(KERN_WARNING "HiSax: NICCY address port %x-%x "
-				"already in use\n",
-				cs->hw.niccy.isac_ale,
-				cs->hw.niccy.isac_ale + 1);
-			release_region(cs->hw.niccy.isac, 2);
-			return 0;
-		}
-	} else {
-#ifdef CONFIG_PCI_LEGACY
-		static struct pci_dev *niccy_dev __devinitdata;
-
-		u_int pci_ioaddr;
-		cs->subtyp = 0;
-		if ((niccy_dev = pci_find_device(PCI_VENDOR_ID_SATSAGEM,
-						 PCI_DEVICE_ID_SATSAGEM_NICCY,
-						 niccy_dev))) {
-			if (pci_enable_device(niccy_dev))
-				return 0;
-			/* get IRQ */
-			if (!niccy_dev->irq) {
-				printk(KERN_WARNING
-				       "Niccy: No IRQ for PCI card found\n");
-				return 0;
-			}
-			cs->irq = niccy_dev->irq;
-			cs->hw.niccy.cfg_reg = pci_resource_start(niccy_dev, 0);
-			if (!cs->hw.niccy.cfg_reg) {
-				printk(KERN_WARNING
-				       "Niccy: No IO-Adr for PCI cfg found\n");
-				return 0;
-			}
-			pci_ioaddr = pci_resource_start(niccy_dev, 1);
-			if (!pci_ioaddr) {
-				printk(KERN_WARNING
-				       "Niccy: No IO-Adr for PCI card found\n");
-				return 0;
-			}
-			cs->subtyp = NICCY_PCI;
-		} else {
-			printk(KERN_WARNING "Niccy: No PCI card found\n");
-			return 0;
-		}
-		cs->irq_flags |= IRQF_SHARED;
-		cs->hw.niccy.isac = pci_ioaddr + ISAC_PCI_DATA;
-		cs->hw.niccy.isac_ale = pci_ioaddr + ISAC_PCI_ADDR;
-		cs->hw.niccy.hscx = pci_ioaddr + HSCX_PCI_DATA;
-		cs->hw.niccy.hscx_ale = pci_ioaddr + HSCX_PCI_ADDR;
-		if (!request_region(cs->hw.niccy.isac, 4, "niccy")) {
-			printk(KERN_WARNING
-			       "HiSax: NICCY data port %x-%x already in use\n",
-			       cs->hw.niccy.isac, cs->hw.niccy.isac + 4);
-			return 0;
-		}
-		if (!request_region(cs->hw.niccy.cfg_reg, 0x40, "niccy pci")) {
-			printk(KERN_WARNING
-			       "HiSax: NICCY pci port %x-%x already in use\n",
-			       cs->hw.niccy.cfg_reg,
-			       cs->hw.niccy.cfg_reg + 0x40);
-			release_region(cs->hw.niccy.isac, 4);
-			return 0;
-		}
-#else
-		printk(KERN_WARNING "Niccy: io0 0 and NO_PCI_BIOS\n");
-		printk(KERN_WARNING "Niccy: unable to config NICCY PCI\n");
-		return 0;
-#endif				/* CONFIG_PCI_LEGACY */
-	}
-	printk(KERN_INFO "HiSax: NICCY %s config irq:%d data:0x%X ale:0x%X\n",
-		(cs->subtyp == 1) ? "PnP" : "PCI",
+
+	WARN_ON(cs->typ != ISDN_CTYPE_NICCY);
+
+	printk(KERN_INFO "HiSax: %s %s config irq:%d data:0x%X ale:0x%X\n",
+		"niccy", (cs->subtyp == 1) ? "PnP" : "PCI",
 		cs->irq, cs->hw.niccy.isac, cs->hw.niccy.isac_ale);
 	setup_isac(cs);
 	cs->readisac = &ReadISAC;
@@ -378,3 +264,315 @@ int __devinit setup_niccy(struct IsdnCard *card)
 	}
 	return 1;
 }
+
+#ifdef CONFIG_ISA
+
+static int __devinit niccy_isa_setup(struct IsdnCard *card)
+{
+	struct IsdnCardState *cs = card->cs;
+
+	cs->hw.niccy.isac = card->para[1] + ISAC_PNP;
+	cs->hw.niccy.hscx = card->para[1] + HSCX_PNP;
+	cs->hw.niccy.isac_ale = card->para[2] + ISAC_PNP;
+	cs->hw.niccy.hscx_ale = card->para[2] + HSCX_PNP;
+	cs->hw.niccy.cfg_reg = 0;
+	cs->subtyp = NICCY_PNP;
+	cs->irq = card->para[0];
+	if (!request_region(cs->hw.niccy.isac, 2, "niccy data")) {
+		printk(KERN_WARNING "HiSax: %s data port %x-%x "
+			"already in use\n", "niccy",
+			cs->hw.niccy.isac, cs->hw.niccy.isac + 1);
+		return 0;
+	}
+	if (!request_region(cs->hw.niccy.isac_ale, 2, "niccy addr")) {
+		printk(KERN_WARNING "HiSax: %s address port %x-%x "
+			"already in use\n", "niccy",
+			cs->hw.niccy.isac_ale,
+			cs->hw.niccy.isac_ale + 1);
+		release_region(cs->hw.niccy.isac, 2);
+		return 0;
+	}
+
+	return setup_niccy(card);
+}
+
+static int __devinit niccy_isa_init_one(struct device *dev, unsigned int id)
+{
+	struct IsdnCard icard = { ISDN_CTYPE_NICCY, };
+	int cardnr;
+
+	icard.para[0] = niccy_irq;
+	icard.para[1] = niccy_base0;
+	icard.para[2] = niccy_base1;
+	if (!niccy_protocol)
+		icard.protocol = DEFAULT_PROTO;
+	else
+		icard.protocol = niccy_protocol;
+
+	cardnr = hisax_init_hotplug(&icard, niccy_isa_setup);
+	if (cardnr < 0)
+		return -ENODEV;
+	
+	dev_set_drvdata(dev, (void *)(unsigned long) cardnr);
+	return 0;
+}
+
+static int __devexit niccy_isa_remove_one(struct device *dev, unsigned int id)
+{
+	int cardnr = (unsigned long) dev_get_drvdata(dev);
+
+	HiSax_closecard(cardnr);
+	return 0;
+}
+
+static struct isa_driver niccy_isa_driver = {
+	.probe		= niccy_isa_init_one,
+	.remove		= __devexit_p(niccy_isa_remove_one),
+	.driver = {
+		.owner	= THIS_MODULE,
+		.name	= "niccy_pci",
+	},
+};
+
+#ifdef CONFIG_PNP
+
+static int __devinit niccy_pnp_setup(struct IsdnCard *card)
+{
+	struct pnp_dev *pnp_d = (void *) card->para[0];
+	int err;
+
+	pnp_disable_dev(pnp_d);
+	err = pnp_activate_dev(pnp_d);
+	if (err < 0) {
+		printk(KERN_WARNING "%s: pnp_activate_dev "
+			"ret(%d)\n", __FUNCTION__, err);
+		return 0;
+	}
+	card->para[1] = pnp_port_start(pnp_d, 0);
+	card->para[2] = pnp_port_start(pnp_d, 1);
+	card->para[0] = pnp_irq(pnp_d, 0);
+	if (!card->para[0] || !card->para[1] ||
+			!card->para[2]) {
+		printk(KERN_ERR "NiccyPnP:some resources are "
+			"missing %ld/%lx/%lx\n",
+			card->para[0], card->para[1],
+			card->para[2]);
+		pnp_disable_dev(pnp_d);
+		return 0;
+	}
+
+	return niccy_isa_setup(card);
+}
+
+static int __devinit niccy_pnp_init_one(struct pnp_dev *pdev,
+				       const struct pnp_device_id *dev_id)
+{
+	struct IsdnCard icard = { ISDN_CTYPE_NICCY, };
+	int cardnr;
+
+	icard.para[0] = (unsigned long) pdev;
+	if (!niccy_protocol)
+		icard.protocol = DEFAULT_PROTO;
+	else
+		icard.protocol = niccy_protocol;
+
+	cardnr = hisax_init_hotplug(&icard, niccy_pnp_setup);
+	if (cardnr < 0)
+		return -ENODEV;
+	
+	pnp_set_drvdata(pdev, (void *)(unsigned long) cardnr);
+	return 0;
+}
+
+static void __devexit niccy_pnp_remove_one(struct pnp_dev *pdev)
+{
+	int cardnr = (unsigned long) pnp_get_drvdata(pdev);
+
+	HiSax_closecard(cardnr);
+}
+
+static struct pnp_device_id niccy_pnp_table[] = {
+	{ .id = "SDA0150", },
+
+	{ .id = "" }		/* terminate list */
+};
+
+static struct pnp_driver niccy_pnp_driver = {
+	.name		= "niccy",
+	.id_table	= niccy_pnp_table,
+	.probe		= niccy_pnp_init_one,
+	.remove		= __devexit_p(niccy_pnp_remove_one),
+};
+#endif /* CONFIG_PNP */
+#endif /* CONFIG_ISA */
+
+#ifdef CONFIG_PCI
+
+static int __devinit niccy_pci_setup(struct IsdnCard *card)
+{
+	u_int pci_ioaddr;
+	struct pci_dev *niccy_dev = (void *) card->para[0];
+	struct IsdnCardState *cs = card->cs;
+
+	cs->subtyp = 0;
+	if (pci_enable_device(niccy_dev))
+		return 0;
+	/* get IRQ */
+	if (!niccy_dev->irq) {
+		printk(KERN_WARNING
+		       "Niccy: No IRQ for PCI card found\n");
+		return 0;
+	}
+	cs->irq = niccy_dev->irq;
+	cs->hw.niccy.cfg_reg = pci_resource_start(niccy_dev, 0);
+	if (!cs->hw.niccy.cfg_reg) {
+		printk(KERN_WARNING
+		       "Niccy: No IO-Adr for PCI cfg found\n");
+		return 0;
+	}
+	pci_ioaddr = pci_resource_start(niccy_dev, 1);
+	if (!pci_ioaddr) {
+		printk(KERN_WARNING
+		       "Niccy: No IO-Adr for PCI card found\n");
+		return 0;
+	}
+	cs->subtyp = NICCY_PCI;
+	cs->irq_flags |= IRQF_SHARED;
+	cs->hw.niccy.isac = pci_ioaddr + ISAC_PCI_DATA;
+	cs->hw.niccy.isac_ale = pci_ioaddr + ISAC_PCI_ADDR;
+	cs->hw.niccy.hscx = pci_ioaddr + HSCX_PCI_DATA;
+	cs->hw.niccy.hscx_ale = pci_ioaddr + HSCX_PCI_ADDR;
+	if (!request_region(cs->hw.niccy.isac, 4, "niccy")) {
+		printk(KERN_WARNING
+		       "HiSax: %s data port %x-%x already in use\n",
+		       "niccy",
+		       cs->hw.niccy.isac, cs->hw.niccy.isac + 4);
+		return 0;
+	}
+	if (!request_region(cs->hw.niccy.cfg_reg, 0x40, "niccy pci")) {
+		printk(KERN_WARNING
+		       "HiSax: %s pci port %x-%x already in use\n",
+		       "niccy",
+		       cs->hw.niccy.cfg_reg,
+		       cs->hw.niccy.cfg_reg + 0x40);
+		release_region(cs->hw.niccy.isac, 4);
+		return 0;
+	}
+
+	return setup_niccy(card);
+}
+
+static int __devinit niccy_pci_init_one(struct pci_dev *pdev,
+				      const struct pci_device_id *ent)
+{
+	struct IsdnCard icard = { ISDN_CTYPE_NICCY, };
+	int cardnr;
+
+	icard.para[0] = (unsigned long) pdev;
+	if (!niccy_protocol)
+		icard.protocol = DEFAULT_PROTO;
+	else
+		icard.protocol = niccy_protocol;
+
+	cardnr = hisax_init_hotplug(&icard, niccy_pci_setup);
+	if (cardnr < 0)
+		return -ENODEV;
+	
+	pci_set_drvdata(pdev, (void *)(unsigned long) cardnr);
+	return 0;
+}
+
+static struct pci_device_id niccy_pci_table[] = {
+	{ PCI_VDEVICE(SATSAGEM, PCI_DEVICE_ID_SATSAGEM_NICCY) },
+
+	{ }		/* terminate list */
+};
+
+static struct pci_driver niccy_pci_driver = {
+	.name		= "niccy",
+	.id_table	= niccy_pci_table,
+	.probe		= niccy_pci_init_one,
+	.remove		= hisax_pci_remove_one,
+};
+
+#endif /* CONFIG_PCI */
+
+static int __init niccy_mod_init(void)
+{
+	int rc = 0;
+
+#ifdef CONFIG_ISA
+	if (niccy_irq && niccy_base0 && niccy_base1) {
+		rc = isa_register_driver(&niccy_isa_driver, 1);
+		if (rc)
+			return rc;
+	}
+#ifdef CONFIG_PNP
+	else {
+		rc = pnp_register_driver(&niccy_pnp_driver);
+		if (rc)
+			return rc;
+	}
+#endif
+#endif /* CONFIG_ISA */
+
+#ifdef CONFIG_PCI
+	rc = pci_register_driver(&niccy_pci_driver);
+	if (rc)
+		goto err_out_isa;
+#endif /* CONFIG_PCI */
+
+	return 0;
+
+#ifdef CONFIG_PCI
+err_out_isa:
+
+#ifdef CONFIG_ISA
+	if (niccy_irq && niccy_base0 && niccy_base1)
+		isa_unregister_driver(&niccy_isa_driver);
+#ifdef CONFIG_PNP
+	else
+		pnp_unregister_driver(&niccy_pnp_driver);
+#endif /* CONFIG_PNP */
+#endif /* CONFIG_ISA */
+
+	return rc;
+#endif /* CONFIG_PCI */
+}
+
+static void __exit niccy_mod_exit(void)
+{
+#ifdef CONFIG_PCI
+	pci_unregister_driver(&niccy_pci_driver);
+#endif /* CONFIG_PCI */
+
+#ifdef CONFIG_ISA
+	if (niccy_irq && niccy_base0 && niccy_base1)
+		isa_unregister_driver(&niccy_isa_driver);
+#ifdef CONFIG_PNP
+	else
+		pnp_unregister_driver(&niccy_pnp_driver);
+#endif /* CONFIG_PNP */
+#endif /* CONFIG_ISA */
+}
+
+module_init(niccy_mod_init);
+module_exit(niccy_mod_exit);
+
+#ifdef CONFIG_ISA
+module_param_named(irq, niccy_irq, int, 0444);
+MODULE_PARM_DESC(irq, "ISA IRQ.  Zero disables ISA support (default).");
+
+module_param_named(base0, niccy_base0, int, 0444);
+MODULE_PARM_DESC(base0, "ISA I/O base #0.  Zero disables ISA support (default).");
+
+module_param_named(base1, niccy_base1, int, 0444);
+MODULE_PARM_DESC(base1, "ISA I/O base #1.  Zero disables ISA support (default).");
+#endif /* CONFIG_ISA */
+
+module_param_named(protocol, niccy_protocol, int, 0444);
+MODULE_PARM_DESC(protocol, "Values 0 (default) through 4. See ISDN_PTYPE_xxx in linux/isdnif.h");
+
+MODULE_DEVICE_TABLE(pci, niccy_pci_table);
+MODULE_DESCRIPTION("ISDN HiSax Niccy PCI/PNP driver");
+MODULE_LICENSE("GPL");
-- 
1.5.3.8


^ permalink raw reply	[flat|nested] 28+ messages in thread

* [PATCH 13/14] [ISDN] HiSax bkm_a8: convert to PCI hotplug API
  2007-07-18  3:04 [PATCH 00/14] [ISDN] HiSax hotplug conversion Jeff Garzik
                   ` (6 preceding siblings ...)
  2007-07-24 12:26 ` [PATCH 11/14] [ISDN] HiSax niccy: convert to modern ISA/PNP/PCI probing Jeff Garzik
@ 2007-08-02 12:37 ` Jeff Garzik
  2007-10-31  5:10 ` [PATCH 03/14] [ISDN] Ready HiSax driver for modularization Jeff Garzik
                   ` (9 subsequent siblings)
  17 siblings, 0 replies; 28+ messages in thread
From: Jeff Garzik @ 2007-08-02 12:37 UTC (permalink / raw)
  To: linux-kernel, kkeil, isdn4linux

---
 drivers/isdn/hisax/Kconfig  |    4 +-
 drivers/isdn/hisax/Makefile |    2 +-
 drivers/isdn/hisax/bkm_a8.c |  186 +++++++++++++++++++++++++++++-------------
 drivers/isdn/hisax/config.c |   48 +-----------
 4 files changed, 133 insertions(+), 107 deletions(-)

diff --git a/drivers/isdn/hisax/Kconfig b/drivers/isdn/hisax/Kconfig
index 36af79f..8e18f7c 100644
--- a/drivers/isdn/hisax/Kconfig
+++ b/drivers/isdn/hisax/Kconfig
@@ -298,8 +298,8 @@ config HISAX_BKM_A4T
 	  settings.
 
 config HISAX_SCT_QUADRO
-	bool "Scitel Quadro card"
-	depends on PCI && PCI_LEGACY
+	tristate "Scitel Quadro card"
+	depends on PCI
 	help
 	  This enables HiSax support for the Scitel Quadro card.
 
diff --git a/drivers/isdn/hisax/Makefile b/drivers/isdn/hisax/Makefile
index 81ae5be..d95a31d 100644
--- a/drivers/isdn/hisax/Makefile
+++ b/drivers/isdn/hisax/Makefile
@@ -26,6 +26,7 @@ obj-$(CONFIG_HISAX_FRITZPCI)		+= avm_pci.o libhisax.o
 obj-$(CONFIG_HISAX_GAZEL)		+= gazel.o libhisax.o
 obj-$(CONFIG_HISAX_NICCY)		+= niccy.o libhisax.o
 obj-$(CONFIG_HISAX_DIEHLDIVA)		+= hisaxdiva.o libhisax.o
+obj-$(CONFIG_HISAX_SCT_QUADRO)		+= bkm_a8.o libhisax.o
 
 bkm_a4t_pci-objs			:= bkm_a4t.o jade.o
 enternow-objs				:= enternow_pci.o amd7930_fn.o
@@ -65,5 +66,4 @@ hisax-$(CONFIG_HISAX_HFCS)		+= hfcscard.o hfc_2bds0.o
 hisax-$(CONFIG_HISAX_HFC_SX)		+= hfc_sx.o
 hisax-$(CONFIG_HISAX_ISURF)		+= isurf.o isar.o
 hisax-$(CONFIG_HISAX_HSTSAPHIR)		+= saphir.o
-hisax-$(CONFIG_HISAX_SCT_QUADRO)	+= bkm_a8.o
 
diff --git a/drivers/isdn/hisax/bkm_a8.c b/drivers/isdn/hisax/bkm_a8.c
index e1ff471..8530327 100644
--- a/drivers/isdn/hisax/bkm_a8.c
+++ b/drivers/isdn/hisax/bkm_a8.c
@@ -13,6 +13,7 @@
 
 #include <linux/init.h>
 #include "hisax.h"
+#include "hisax_proto.h"
 #include "isac.h"
 #include "ipac.h"
 #include "hscx.h"
@@ -20,6 +21,8 @@
 #include <linux/pci.h>
 #include "bkm_ax.h"
 
+static int a8_protocol;		/* 0 == use DEFAULT_PROTO */
+
 #define	ATTEMPT_PCI_REMAPPING	/* Required for PLX rev 1 */
 
 static const char sct_quadro_revision[] = "$Revision: 1.22.2.4 $";
@@ -267,63 +270,23 @@ sct_alloc_io(u_int adr, u_int len)
 	return(0);
 }
 
-static struct pci_dev *dev_a8 __devinitdata = NULL;
-static u16  sub_vendor_id __devinitdata = 0;
-static u16  sub_sys_id __devinitdata = 0;
-static u_char pci_bus __devinitdata = 0;
-static u_char pci_device_fn __devinitdata = 0;
-static u_char pci_irq __devinitdata = 0;
-
-int __devinit
+static int __devinit
 setup_sct_quadro(struct IsdnCard *card)
 {
 	struct IsdnCardState *cs = card->cs;
+	u_int pci_ioaddr2, pci_ioaddr3, pci_ioaddr4, pci_ioaddr5;
 	char tmp[64];
-	u_int found = 0;
-	u_int pci_ioaddr1, pci_ioaddr2, pci_ioaddr3, pci_ioaddr4, pci_ioaddr5;
+	struct pci_dev *dev_a8 = (void *) card->para[1];
+	u_int pci_ioaddr1 = pci_resource_start(dev_a8, 1);
+	u_char pci_irq = dev_a8->irq;
 
 	strcpy(tmp, sct_quadro_revision);
 	printk(KERN_INFO "HiSax: T-Berkom driver Rev. %s\n", HiSax_getrev(tmp));
-	if (cs->typ == ISDN_CTYPE_SCT_QUADRO) {
-		cs->subtyp = SCT_1;	/* Preset */
-	} else
-		return (0);
 
-	/* Identify subtype by para[0] */
-	if (card->para[0] >= SCT_1 && card->para[0] <= SCT_4)
-		cs->subtyp = card->para[0];
-	else {
-		printk(KERN_WARNING "HiSax: Scitel Quadro: Invalid "
-		       "subcontroller in configuration, default to 1\n");
-		return (0);
-	}
-	if ((cs->subtyp != SCT_1) && ((sub_sys_id != PCI_DEVICE_ID_BERKOM_SCITEL_QUADRO) ||
-		(sub_vendor_id != PCI_VENDOR_ID_BERKOM)))
-		return (0);
+	cs->subtyp = card->para[0];
+
 	if (cs->subtyp == SCT_1) {
-		while ((dev_a8 = pci_find_device(PCI_VENDOR_ID_PLX,
-			PCI_DEVICE_ID_PLX_9050, dev_a8))) {
-			
-			sub_vendor_id = dev_a8->subsystem_vendor;
-			sub_sys_id = dev_a8->subsystem_device;
-			if ((sub_sys_id == PCI_DEVICE_ID_BERKOM_SCITEL_QUADRO) &&
-				(sub_vendor_id == PCI_VENDOR_ID_BERKOM)) {
-				if (pci_enable_device(dev_a8))
-					return(0);
-				pci_ioaddr1 = pci_resource_start(dev_a8, 1);
-				pci_irq = dev_a8->irq;
-				pci_bus = dev_a8->bus->number;
-				pci_device_fn = dev_a8->devfn;
-				found = 1;
-				break;
-			}
-		}
-		if (!found) {
-			printk(KERN_WARNING "HiSax: Scitel Quadro (%s): "
-				"Card not found\n",
-				sct_quadro_subtypes[cs->subtyp]);
-			return (0);
-		}
+
 #ifdef ATTEMPT_PCI_REMAPPING
 /* HACK: PLX revision 1 bug: PLX address bit 7 must not be set */
 		if ((pci_ioaddr1 & 0x80) && (dev_a8->revision == 1)) {
@@ -345,22 +308,19 @@ setup_sct_quadro(struct IsdnCard *card)
 		       sct_quadro_subtypes[cs->subtyp]);
 		return (0);
 	}
-	pci_read_config_dword(dev_a8, PCI_BASE_ADDRESS_1, &pci_ioaddr1);
-	pci_read_config_dword(dev_a8, PCI_BASE_ADDRESS_2, &pci_ioaddr2);
-	pci_read_config_dword(dev_a8, PCI_BASE_ADDRESS_3, &pci_ioaddr3);
-	pci_read_config_dword(dev_a8, PCI_BASE_ADDRESS_4, &pci_ioaddr4);
-	pci_read_config_dword(dev_a8, PCI_BASE_ADDRESS_5, &pci_ioaddr5);
+
+	pci_ioaddr2 = pci_resource_start(dev_a8, 2);
+	pci_ioaddr3 = pci_resource_start(dev_a8, 3);
+	pci_ioaddr4 = pci_resource_start(dev_a8, 4);
+	pci_ioaddr5 = pci_resource_start(dev_a8, 5);
+
 	if (!pci_ioaddr1 || !pci_ioaddr2 || !pci_ioaddr3 || !pci_ioaddr4 || !pci_ioaddr5) {
 		printk(KERN_WARNING "HiSax: Scitel Quadro (%s): "
 		       "No IO base address(es)\n",
 		       sct_quadro_subtypes[cs->subtyp]);
 		return (0);
 	}
-	pci_ioaddr1 &= PCI_BASE_ADDRESS_IO_MASK;
-	pci_ioaddr2 &= PCI_BASE_ADDRESS_IO_MASK;
-	pci_ioaddr3 &= PCI_BASE_ADDRESS_IO_MASK;
-	pci_ioaddr4 &= PCI_BASE_ADDRESS_IO_MASK;
-	pci_ioaddr5 &= PCI_BASE_ADDRESS_IO_MASK;
+
 	/* Take over */
 	cs->irq = pci_irq;
 	cs->irq_flags |= IRQF_SHARED;
@@ -433,3 +393,113 @@ setup_sct_quadro(struct IsdnCard *card)
 		readreg(cs->hw.ax.base, cs->hw.ax.data_adr, IPAC_ID));
 	return (1);
 }
+
+enum {
+	a8_bri_count	= 4,
+};
+
+struct a8_pci_bri {
+	int		cardnr;
+};
+
+struct a8_pci_info {
+	struct a8_pci_bri	bri[a8_bri_count];
+};
+
+static int __devinit a8_pci_init_one(struct pci_dev *pdev,
+				      const struct pci_device_id *ent)
+{
+	struct IsdnCard icard = { ISDN_CTYPE_SCT_QUADRO, };
+	int rc, i, found = 0;
+	struct a8_pci_info *api;
+
+	rc = pci_enable_device(pdev);
+	if (rc)
+		return rc;
+
+	api = kzalloc(sizeof(*api), GFP_KERNEL);
+	if (!api) {
+		rc = -ENOMEM;
+		goto err_out;
+	}
+
+	icard.para[1] = (unsigned long) pdev;
+	if (!a8_protocol)
+		icard.protocol = DEFAULT_PROTO;
+	else
+		icard.protocol = a8_protocol;
+
+	for (i = 0; i < a8_bri_count; i++) {
+		icard.para[0] = SCT_1 + i;
+		api->bri[i].cardnr =
+			hisax_init_hotplug(&icard, setup_sct_quadro);
+		if (api->bri[i].cardnr >= 0)
+			found = 1;
+	}
+
+	if (!found) {
+		rc = -ENODEV;
+		goto err_out_api;
+	}
+	
+	pci_set_drvdata(pdev, api);
+	return 0;
+
+err_out_api:
+	kfree(api);
+err_out:
+	pci_disable_device(pdev);
+	return rc;
+}
+
+static void __devexit a8_pci_remove_one(struct pci_dev *pdev)
+{
+	struct a8_pci_info *api = pci_get_drvdata(pdev);
+	int i;
+
+	pci_set_drvdata(pdev, NULL);
+
+	for (i = 0; i < a8_bri_count; i++) {
+		struct a8_pci_bri *bri = &api->bri[i];
+
+		if (bri->cardnr >= 0)
+			HiSax_closecard(bri->cardnr);
+	}
+
+	kfree(api);
+	pci_disable_device(pdev);
+}
+
+static struct pci_device_id a8_pci_table[] = {
+	{ PCI_VENDOR_ID_PLX, PCI_DEVICE_ID_PLX_9050,
+	  PCI_VENDOR_ID_BERKOM, PCI_DEVICE_ID_BERKOM_SCITEL_QUADRO, },
+
+	{ }		/* terminate list */
+};
+
+static struct pci_driver a8_pci_driver = {
+	.name		= "bkm_a8",
+	.id_table	= a8_pci_table,
+	.probe		= a8_pci_init_one,
+	.remove		= __devexit_p(a8_pci_remove_one),
+};
+
+static int __init a8_mod_init(void)
+{
+	return pci_register_driver(&a8_pci_driver);
+}
+
+static void __exit a8_mod_exit(void)
+{
+	pci_unregister_driver(&a8_pci_driver);
+}
+
+module_init(a8_mod_init);
+module_exit(a8_mod_exit);
+
+module_param_named(protocol, a8_protocol, int, 0444);
+MODULE_PARM_DESC(protocol, "Values 0 (default) through 4. See ISDN_PTYPE_xxx in linux/isdnif.h");
+
+MODULE_DEVICE_TABLE(pci, a8_pci_table);
+MODULE_DESCRIPTION("ISDN HiSax BKM SCT QUADRO (A8) PCI driver");
+MODULE_LICENSE("GPL");
diff --git a/drivers/isdn/hisax/config.c b/drivers/isdn/hisax/config.c
index fd8a564..0c379e8 100644
--- a/drivers/isdn/hisax/config.c
+++ b/drivers/isdn/hisax/config.c
@@ -208,13 +208,6 @@ const char *CardType[] = {
 #define DEFAULT_CFG {5,0x250,0,0}
 #endif
 
-#ifdef CONFIG_HISAX_SCT_QUADRO
-#undef DEFAULT_CARD
-#undef DEFAULT_CFG
-#define DEFAULT_CARD ISDN_CTYPE_SCT_QUADRO
-#define DEFAULT_CFG {1,0x0,0,0}
-#endif
-
 #ifndef DEFAULT_CARD
 #define DEFAULT_CARD 0
 #define DEFAULT_CFG {0,0,0,0}
@@ -433,10 +426,6 @@ extern int setup_isurf(struct IsdnCard *card);
 extern int setup_saphir(struct IsdnCard *card);
 #endif
 
-#if CARD_SCT_QUADRO
-extern int setup_sct_quadro(struct IsdnCard *card);
-#endif
-
 /*
  * Find card with given driverId
  */
@@ -806,11 +795,6 @@ static int __devinit hisax_cs_setup_card(struct IsdnCard *card)
 		ret = setup_saphir(card);
 		break;
 #endif
-#if	CARD_SCT_QUADRO
-	case ISDN_CTYPE_SCT_QUADRO:
-		ret = setup_sct_quadro(card);
-		break;
-#endif
 	case ISDN_CTYPE_DYNAMIC:
 		ret = 2;
 		break;
@@ -826,6 +810,7 @@ static int __devinit hisax_cs_setup_card(struct IsdnCard *card)
 	case ISDN_CTYPE_GAZEL:
 	case ISDN_CTYPE_NICCY:
 	case ISDN_CTYPE_DIEHLDIVA:
+	case ISDN_CTYPE_SCT_QUADRO:
 		printk(KERN_WARNING "HiSax: Support for %s Card has moved "
 		       "to separate PCI driver module\n",
 		       CardType[card->typ]);
@@ -1296,32 +1281,9 @@ static int __init HiSax_init(void)
 		case ISDN_CTYPE_GAZEL:
 		case ISDN_CTYPE_NICCY:
 		case ISDN_CTYPE_DIEHLDIVA:
-			break;
-
 		case ISDN_CTYPE_SCT_QUADRO:
-			if (irq[i]) {
-				cards[j].para[0] = irq[i];
-			} else {
-				/* QUADRO is a 4 BRI card */
-				cards[j++].para[0] = 1;
-				/* we need to check if further cards can be added */
-				if (j < HISAX_MAX_CARDS) {
-					cards[j].typ = ISDN_CTYPE_SCT_QUADRO;
-					cards[j].protocol = protocol[i];
-					cards[j++].para[0] = 2;
-				}
-				if (j < HISAX_MAX_CARDS) {
-					cards[j].typ = ISDN_CTYPE_SCT_QUADRO;
-					cards[j].protocol = protocol[i];
-					cards[j++].para[0] = 3;
-				}
-				if (j < HISAX_MAX_CARDS) {
-					cards[j].typ = ISDN_CTYPE_SCT_QUADRO;
-					cards[j].protocol = protocol[i];
-					cards[j].para[0] = 4;
-				}
-			}
 			break;
+
 		}
 		j++;
 	}
@@ -1773,15 +1735,9 @@ static struct pci_device_id hisax_pci_tbl[] __devinitdata = {
 	{PCI_VENDOR_ID_ELSA,     PCI_DEVICE_ID_ELSA_MICROLINK,   PCI_ANY_ID, PCI_ANY_ID},
 	{PCI_VENDOR_ID_ELSA,     PCI_DEVICE_ID_ELSA_QS3000,      PCI_ANY_ID, PCI_ANY_ID},
 #endif
-#ifdef CONFIG_HISAX_SCT_QUADRO
-	{PCI_VENDOR_ID_PLX,      PCI_DEVICE_ID_PLX_9050,         PCI_ANY_ID, PCI_ANY_ID},
-#endif
 #ifdef CONFIG_HISAX_SEDLBAUER
 	{PCI_VENDOR_ID_TIGERJET, PCI_DEVICE_ID_TIGERJET_100,     PCI_ANY_ID,PCI_ANY_ID},
 #endif
-#if defined(CONFIG_HISAX_SCT_QUADRO)
-	{PCI_VENDOR_ID_ZORAN,    PCI_DEVICE_ID_ZORAN_36120,      PCI_ANY_ID,PCI_ANY_ID},
-#endif
 	{ }				/* Terminating entry */
 };
 
-- 
1.5.3.8


^ permalink raw reply	[flat|nested] 28+ messages in thread

* [PATCH 03/14] [ISDN] Ready HiSax driver for modularization
  2007-07-18  3:04 [PATCH 00/14] [ISDN] HiSax hotplug conversion Jeff Garzik
                   ` (7 preceding siblings ...)
  2007-08-02 12:37 ` [PATCH 13/14] [ISDN] HiSax bkm_a8: convert to PCI hotplug API Jeff Garzik
@ 2007-10-31  5:10 ` Jeff Garzik
  2008-02-15 13:45   ` Sam Ravnborg
  2007-10-31  5:11 ` [PATCH 09/14] [ISDN] HiSax avm_pci: convert to modern PCI/ISA/PNP probing Jeff Garzik
                   ` (8 subsequent siblings)
  17 siblings, 1 reply; 28+ messages in thread
From: Jeff Garzik @ 2007-10-31  5:10 UTC (permalink / raw)
  To: linux-kernel, kkeil, isdn4linux

* move netjet, isac, arcofi, hscx common sub-modules to new libhisax.ko
* export several symbols that are used by external drivers
* move DEFAULT_PROTO* deterination to shareable header file
* add hotplug and PCI-remove APIs

Signed-off-by: Jeff Garzik <jeff@garzik.org>
---
 drivers/isdn/hisax/Makefile    |   51 ++++++++++++++++++-----------------
 drivers/isdn/hisax/arcofi.c    |    4 +++
 drivers/isdn/hisax/config.c    |   57 ++++++++++++++++++++++++++--------------
 drivers/isdn/hisax/hisax_cfg.h |    2 +
 drivers/isdn/hisax/hscx.c      |    8 +++++
 drivers/isdn/hisax/isac.c      |    6 ++++
 drivers/isdn/hisax/isdnl1.c    |   12 +++++++-
 drivers/isdn/hisax/lmgr.c      |    2 +
 drivers/isdn/hisax/netjet.c    |    9 ++++++
 drivers/isdn/hisax/q931.c      |    4 +++
 10 files changed, 109 insertions(+), 46 deletions(-)

diff --git a/drivers/isdn/hisax/Makefile b/drivers/isdn/hisax/Makefile
index c7a3794..b0b09e9 100644
--- a/drivers/isdn/hisax/Makefile
+++ b/drivers/isdn/hisax/Makefile
@@ -6,7 +6,7 @@
 
 EXTRA_CFLAGS      += -DHISAX_MAX_CARDS=$(CONFIG_HISAX_MAX_CARDS)
 
-obj-$(CONFIG_ISDN_DRV_HISAX)		+= hisax.o
+obj-$(CONFIG_ISDN_DRV_HISAX)		+= hisax.o libhisax.o
 obj-$(CONFIG_HISAX_SEDLBAUER_CS)	+= sedlbauer_cs.o
 obj-$(CONFIG_HISAX_ELSA_CS)		+= elsa_cs.o
 obj-$(CONFIG_HISAX_AVM_A1_CS)		+= avma1_cs.o
@@ -16,6 +16,8 @@ obj-$(CONFIG_HISAX_HFCUSB)		+= hfc_usb.o
 obj-$(CONFIG_HISAX_HFC4S8S)		+= hfc4s8s_l1.o
 obj-$(CONFIG_HISAX_FRITZ_PCIPNP)        += hisax_isac.o hisax_fcpcipnp.o
 
+libhisax-objs				:= netjet.o isac.o arcofi.o hscx.o
+
 ifdef CONFIG_HISAX_HDLC
 obj-$(CONFIG_ISDN_DRV_HISAX)		+= isdnhdlc.o
 endif
@@ -31,33 +33,32 @@ hisax-$(CONFIG_HISAX_EURO)		+= l3dss1.o
 hisax-$(CONFIG_HISAX_NI1)		+= l3ni1.o
 hisax-$(CONFIG_HISAX_1TR6)		+= l3_1tr6.o
 
-hisax-$(CONFIG_HISAX_16_0)		+= teles0.o isac.o arcofi.o hscx.o
-hisax-$(CONFIG_HISAX_16_3)		+= teles3.o isac.o arcofi.o hscx.o
-hisax-$(CONFIG_HISAX_TELESPCI)		+= telespci.o isac.o arcofi.o hscx.o
-hisax-$(CONFIG_HISAX_S0BOX)		+= s0box.o isac.o arcofi.o hscx.o
-hisax-$(CONFIG_HISAX_AVM_A1)		+= avm_a1.o isac.o arcofi.o hscx.o
-hisax-$(CONFIG_HISAX_AVM_A1_PCMCIA)	+= avm_a1p.o isac.o arcofi.o hscx.o
-hisax-$(CONFIG_HISAX_FRITZPCI)		+= avm_pci.o isac.o arcofi.o
-hisax-$(CONFIG_HISAX_ELSA)		+= elsa.o isac.o arcofi.o hscx.o
-hisax-$(CONFIG_HISAX_IX1MICROR2)	+= ix1_micro.o isac.o arcofi.o hscx.o
-hisax-$(CONFIG_HISAX_DIEHLDIVA)		+= diva.o isac.o arcofi.o hscx.o ipacx.o 
-hisax-$(CONFIG_HISAX_ASUSCOM)		+= asuscom.o isac.o arcofi.o hscx.o
-hisax-$(CONFIG_HISAX_TELEINT)		+= teleint.o isac.o arcofi.o hfc_2bs0.o
-hisax-$(CONFIG_HISAX_SEDLBAUER)		+= sedlbauer.o isac.o arcofi.o hscx.o \
-					   isar.o
-hisax-$(CONFIG_HISAX_SPORTSTER)		+= sportster.o isac.o arcofi.o hscx.o
-hisax-$(CONFIG_HISAX_MIC)		+= mic.o isac.o arcofi.o hscx.o
-hisax-$(CONFIG_HISAX_NETJET)		+= nj_s.o netjet.o isac.o arcofi.o
-hisax-$(CONFIG_HISAX_NETJET_U)		+= nj_u.o netjet.o icc.o
+hisax-$(CONFIG_HISAX_16_0)		+= teles0.o
+hisax-$(CONFIG_HISAX_16_3)		+= teles3.o
+hisax-$(CONFIG_HISAX_TELESPCI)		+= telespci.o
+hisax-$(CONFIG_HISAX_S0BOX)		+= s0box.o
+hisax-$(CONFIG_HISAX_AVM_A1)		+= avm_a1.o
+hisax-$(CONFIG_HISAX_AVM_A1_PCMCIA)	+= avm_a1p.o
+hisax-$(CONFIG_HISAX_FRITZPCI)		+= avm_pci.o
+hisax-$(CONFIG_HISAX_ELSA)		+= elsa.o
+hisax-$(CONFIG_HISAX_IX1MICROR2)	+= ix1_micro.o
+hisax-$(CONFIG_HISAX_DIEHLDIVA)		+= diva.o ipacx.o 
+hisax-$(CONFIG_HISAX_ASUSCOM)		+= asuscom.o
+hisax-$(CONFIG_HISAX_TELEINT)		+= teleint.o hfc_2bs0.o
+hisax-$(CONFIG_HISAX_SEDLBAUER)		+= sedlbauer.o isar.o
+hisax-$(CONFIG_HISAX_SPORTSTER)		+= sportster.o
+hisax-$(CONFIG_HISAX_MIC)		+= mic.o
+hisax-$(CONFIG_HISAX_NETJET)		+= nj_s.o
+hisax-$(CONFIG_HISAX_NETJET_U)		+= nj_u.o icc.o
 hisax-$(CONFIG_HISAX_HFCS)		+= hfcscard.o hfc_2bds0.o
 hisax-$(CONFIG_HISAX_HFC_PCI)		+= hfc_pci.o
 hisax-$(CONFIG_HISAX_HFC_SX)		+= hfc_sx.o
-hisax-$(CONFIG_HISAX_NICCY)		+= niccy.o isac.o arcofi.o hscx.o
-hisax-$(CONFIG_HISAX_ISURF)		+= isurf.o isac.o arcofi.o isar.o
-hisax-$(CONFIG_HISAX_HSTSAPHIR)		+= saphir.o isac.o arcofi.o hscx.o
-hisax-$(CONFIG_HISAX_BKM_A4T)		+= bkm_a4t.o isac.o arcofi.o jade.o
-hisax-$(CONFIG_HISAX_SCT_QUADRO)	+= bkm_a8.o isac.o arcofi.o hscx.o
-hisax-$(CONFIG_HISAX_GAZEL)		+= gazel.o isac.o arcofi.o hscx.o
+hisax-$(CONFIG_HISAX_NICCY)		+= niccy.o
+hisax-$(CONFIG_HISAX_ISURF)		+= isurf.o isar.o
+hisax-$(CONFIG_HISAX_HSTSAPHIR)		+= saphir.o
+hisax-$(CONFIG_HISAX_BKM_A4T)		+= bkm_a4t.o jade.o
+hisax-$(CONFIG_HISAX_SCT_QUADRO)	+= bkm_a8.o
+hisax-$(CONFIG_HISAX_GAZEL)		+= gazel.o
 hisax-$(CONFIG_HISAX_W6692)		+= w6692.o
 hisax-$(CONFIG_HISAX_ENTERNOW_PCI)	+= enternow_pci.o amd7930_fn.o
 
diff --git a/drivers/isdn/hisax/arcofi.c b/drivers/isdn/hisax/arcofi.c
index d30ce5b..bf2e10d 100644
--- a/drivers/isdn/hisax/arcofi.c
+++ b/drivers/isdn/hisax/arcofi.c
@@ -132,3 +132,7 @@ init_arcofi(struct IsdnCardState *cs) {
 	init_waitqueue_head(&cs->dc.isac.arcofi_wait);
 	test_and_set_bit(HW_ARCOFI, &cs->HW_Flags);
 }
+
+EXPORT_SYMBOL(init_arcofi);
+EXPORT_SYMBOL(clear_arcofi);
+EXPORT_SYMBOL(arcofi_fsm);
diff --git a/drivers/isdn/hisax/config.c b/drivers/isdn/hisax/config.c
index f395a72..6112013 100644
--- a/drivers/isdn/hisax/config.c
+++ b/drivers/isdn/hisax/config.c
@@ -19,10 +19,12 @@
 #include <linux/timer.h>
 #include <linux/init.h>
 #include "hisax.h"
+#include "hisax_proto.h"
 #include <linux/module.h>
 #include <linux/kernel_stat.h>
 #include <linux/workqueue.h>
 #include <linux/interrupt.h>
+#include <linux/pci.h>
 #define HISAX_STATUS_BUFSIZE 4096
 
 /*
@@ -283,26 +285,6 @@ const char *CardType[] = {
 #define DEFAULT_CFG {0,0,0,0}
 #endif
 
-#ifdef CONFIG_HISAX_1TR6
-#define DEFAULT_PROTO ISDN_PTYPE_1TR6
-#define DEFAULT_PROTO_NAME "1TR6"
-#endif
-#ifdef CONFIG_HISAX_NI1
-#undef DEFAULT_PROTO
-#define DEFAULT_PROTO ISDN_PTYPE_NI1
-#undef DEFAULT_PROTO_NAME
-#define DEFAULT_PROTO_NAME "NI1"
-#endif
-#ifdef CONFIG_HISAX_EURO
-#undef DEFAULT_PROTO
-#define DEFAULT_PROTO ISDN_PTYPE_EURO
-#undef DEFAULT_PROTO_NAME
-#define DEFAULT_PROTO_NAME "EURO"
-#endif
-#ifndef DEFAULT_PROTO
-#define DEFAULT_PROTO ISDN_PTYPE_UNKNOWN
-#define DEFAULT_PROTO_NAME "UNKNOWN"
-#endif
 #ifndef DEFAULT_CARD
 #define DEFAULT_CARD 0
 #define DEFAULT_CFG {0,0,0,0}
@@ -1542,6 +1524,38 @@ static void __exit HiSax_exit(void)
 	printk(KERN_INFO "HiSax module removed\n");
 }
 
+#ifdef CONFIG_PCI
+void hisax_pci_remove_one(struct pci_dev *pdev)
+{
+	int cardnr = (unsigned long) pci_get_drvdata(pdev);
+
+	HiSax_closecard(cardnr);
+	pci_disable_device(pdev);
+	pci_set_drvdata(pdev, NULL);
+}
+
+EXPORT_SYMBOL(hisax_pci_remove_one);
+#endif /* CONFIG_PCI */
+
+int hisax_init_hotplug(struct IsdnCard *card, hisax_setup_func_t card_setup)
+{
+	u_char ids[16];
+	int ret = -1;
+
+	cards[nrcards] = *card;
+	if (nrcards)
+		sprintf(ids, "HiSax%d", nrcards);
+	else
+		sprintf(ids, "HiSax");
+	if (!checkcard(nrcards, ids, NULL, THIS_MODULE, card_setup))
+		goto error;
+
+	ret = nrcards;
+	nrcards++;
+error:
+	return ret;
+}
+
 int hisax_init_pcmcia(void *pcm_iob, int *busy_flag, struct IsdnCard *card)
 {
 	u_char ids[16];
@@ -1563,7 +1577,10 @@ error:
 }
 
 EXPORT_SYMBOL(hisax_init_pcmcia);
+EXPORT_SYMBOL(hisax_init_hotplug);
 EXPORT_SYMBOL(HiSax_closecard);
+EXPORT_SYMBOL(HiSax_getrev);
+EXPORT_SYMBOL(HiSax_putstatus);
 
 #include "hisax_if.h"
 
diff --git a/drivers/isdn/hisax/hisax_cfg.h b/drivers/isdn/hisax/hisax_cfg.h
index 17a2fea..0625756 100644
--- a/drivers/isdn/hisax/hisax_cfg.h
+++ b/drivers/isdn/hisax/hisax_cfg.h
@@ -64,3 +64,5 @@ typedef int (*hisax_setup_func_t)(struct IsdnCard *card);
 
 extern void	HiSax_closecard(int);
 extern int	hisax_init_pcmcia(void *, int *, IsdnCard_t *);
+extern int	hisax_init_hotplug(IsdnCard_t *, hisax_setup_func_t card_setup);
+extern void	hisax_pci_remove_one(struct pci_dev *pdev);
diff --git a/drivers/isdn/hisax/hscx.c b/drivers/isdn/hisax/hscx.c
index c8f9951..a01e961 100644
--- a/drivers/isdn/hisax/hscx.c
+++ b/drivers/isdn/hisax/hscx.c
@@ -274,3 +274,11 @@ inithscxisac(struct IsdnCardState *cs, int part)
 		cs->writeisac(cs, ISAC_CMDR, 0x41);
 	}
 }
+
+EXPORT_SYMBOL(HscxVersion);
+EXPORT_SYMBOL(inithscxisac);
+EXPORT_SYMBOL(inithscx);
+EXPORT_SYMBOL(clear_pending_hscx_ints);
+EXPORT_SYMBOL(hscx_l2l1);
+EXPORT_SYMBOL(open_hscxstate);
+EXPORT_SYMBOL(modehscx);
diff --git a/drivers/isdn/hisax/isac.c b/drivers/isdn/hisax/isac.c
index 07b1673..40bb5f8 100644
--- a/drivers/isdn/hisax/isac.c
+++ b/drivers/isdn/hisax/isac.c
@@ -678,3 +678,9 @@ setup_isac(struct IsdnCardState *cs)
 	cs->dbusytimer.data = (long) cs;
 	init_timer(&cs->dbusytimer);
 }
+
+EXPORT_SYMBOL(isac_interrupt);
+EXPORT_SYMBOL(initisac);
+EXPORT_SYMBOL(clear_pending_isac_ints);
+EXPORT_SYMBOL(ISACVersion);
+EXPORT_SYMBOL(setup_isac);
diff --git a/drivers/isdn/hisax/isdnl1.c b/drivers/isdn/hisax/isdnl1.c
index a14204e..ec81b12 100644
--- a/drivers/isdn/hisax/isdnl1.c
+++ b/drivers/isdn/hisax/isdnl1.c
@@ -451,7 +451,7 @@ Logl2Frame(struct IsdnCardState *cs, struct sk_buff *skb, char *buf, int dir)
 			(dir ? "<-" : "->"), buf, l2frames(ptr),
 			((ptr[0] & 2) >> 1) == dir ? 'C' : 'R', ptr[0] >> 2, ptr[1] >> 1);
 }
-#endif
+#endif /* L2FRAME_DEBUG */
 
 static void
 l1_reset(struct FsmInst *fi, int event, void *arg)
@@ -933,3 +933,13 @@ setstack_l1_B(struct PStack *st)
 	st->l1.Flags = 0;
 	FsmInitTimer(&st->l1.l1m, &st->l1.timer);
 }
+
+EXPORT_SYMBOL(l1_msg);
+EXPORT_SYMBOL(l1_msg_b);
+EXPORT_SYMBOL(debugl1);
+EXPORT_SYMBOL(setstack_l1_B);
+EXPORT_SYMBOL(DChannel_proc_rcv);
+EXPORT_SYMBOL(DChannel_proc_xmt);
+#ifdef L2FRAME_DEBUG
+EXPORT_SYMBOL(Logl2Frame);
+#endif
diff --git a/drivers/isdn/hisax/lmgr.c b/drivers/isdn/hisax/lmgr.c
index d4f86d6..5980490 100644
--- a/drivers/isdn/hisax/lmgr.c
+++ b/drivers/isdn/hisax/lmgr.c
@@ -48,3 +48,5 @@ setstack_manager(struct PStack *st)
 {
 	st->ma.layer = hisax_manager;
 }
+
+EXPORT_SYMBOL(setstack_manager);
diff --git a/drivers/isdn/hisax/netjet.c b/drivers/isdn/hisax/netjet.c
index 02c6fba..1e3e45b 100644
--- a/drivers/isdn/hisax/netjet.c
+++ b/drivers/isdn/hisax/netjet.c
@@ -979,3 +979,12 @@ release_io_netjet(struct IsdnCardState *cs)
 	release_region(cs->hw.njet.base, 256);
 }
 
+EXPORT_SYMBOL(NETjet_WriteICfifo);
+EXPORT_SYMBOL(NETjet_ReadICfifo);
+EXPORT_SYMBOL(NETjet_WriteIC);
+EXPORT_SYMBOL(NETjet_ReadIC);
+EXPORT_SYMBOL(write_tiger);
+EXPORT_SYMBOL(read_tiger);
+EXPORT_SYMBOL(inittiger);
+EXPORT_SYMBOL(netjet_fill_dma);
+EXPORT_SYMBOL(release_io_netjet);
diff --git a/drivers/isdn/hisax/q931.c b/drivers/isdn/hisax/q931.c
index aacbf0d..8a4e60b 100644
--- a/drivers/isdn/hisax/q931.c
+++ b/drivers/isdn/hisax/q931.c
@@ -1520,3 +1520,7 @@ dlogframe(struct IsdnCardState *cs, struct sk_buff *skb, int dir)
 	*dp = 0;
 	HiSax_putstatus(cs, NULL, cs->dlog);
 }
+
+EXPORT_SYMBOL(dlogframe);
+EXPORT_SYMBOL(LogFrame);
+EXPORT_SYMBOL(QuickHex);
-- 
1.5.3.8


^ permalink raw reply	[flat|nested] 28+ messages in thread

* [PATCH 09/14] [ISDN] HiSax avm_pci: convert to modern PCI/ISA/PNP probing
  2007-07-18  3:04 [PATCH 00/14] [ISDN] HiSax hotplug conversion Jeff Garzik
                   ` (8 preceding siblings ...)
  2007-10-31  5:10 ` [PATCH 03/14] [ISDN] Ready HiSax driver for modularization Jeff Garzik
@ 2007-10-31  5:11 ` Jeff Garzik
  2007-10-31  5:12 ` [PATCH 10/14] [ISDN] HiSax gazel: convert to modern ISA/PCI probing Jeff Garzik
                   ` (7 subsequent siblings)
  17 siblings, 0 replies; 28+ messages in thread
From: Jeff Garzik @ 2007-10-31  5:11 UTC (permalink / raw)
  To: linux-kernel, kkeil, isdn4linux

Signed-off-by: Jeff Garzik <jgarzik@redhat.com>
---
 drivers/isdn/hisax/Kconfig   |    4 +-
 drivers/isdn/hisax/Makefile  |    2 +-
 drivers/isdn/hisax/avm_pci.c |  322 ++++++++++++++++++++++++++++++------------
 drivers/isdn/hisax/config.c  |   22 +---
 4 files changed, 235 insertions(+), 115 deletions(-)

diff --git a/drivers/isdn/hisax/Kconfig b/drivers/isdn/hisax/Kconfig
index 4f98afb..14951c0 100644
--- a/drivers/isdn/hisax/Kconfig
+++ b/drivers/isdn/hisax/Kconfig
@@ -132,8 +132,8 @@ config HISAX_AVM_A1
 	  non-standard IRQ/port settings.
 
 config HISAX_FRITZPCI
-	bool "AVM PnP/PCI (Fritz!PnP/PCI)"
-	depends on BROKEN || !PPC64
+	tristate "AVM PnP/PCI (Fritz!PnP/PCI)"
+	depends on (ISA || PNP || PCI) && (BROKEN || !PPC64)
 	help
 	  This enables HiSax support for the AVM "Fritz!PnP" and "Fritz!PCI".
 	  See <file:Documentation/isdn/README.HiSax> on how to configure it.
diff --git a/drivers/isdn/hisax/Makefile b/drivers/isdn/hisax/Makefile
index d3e464a..e03b4ce 100644
--- a/drivers/isdn/hisax/Makefile
+++ b/drivers/isdn/hisax/Makefile
@@ -22,6 +22,7 @@ obj-$(CONFIG_HISAX_W6692)		+= w6692.o libhisax.o
 obj-$(CONFIG_HISAX_NETJET)		+= netjet_s.o libhisax.o
 obj-$(CONFIG_HISAX_NETJET_U)		+= netjet_u.o libhisax.o
 obj-$(CONFIG_HISAX_TELESPCI)		+= telespci.o libhisax.o
+obj-$(CONFIG_HISAX_FRITZPCI)		+= avm_pci.o libhisax.o
 
 bkm_a4t_pci-objs			:= bkm_a4t.o jade.o
 enternow-objs				:= enternow_pci.o amd7930_fn.o
@@ -49,7 +50,6 @@ hisax-$(CONFIG_HISAX_16_3)		+= teles3.o
 hisax-$(CONFIG_HISAX_S0BOX)		+= s0box.o
 hisax-$(CONFIG_HISAX_AVM_A1)		+= avm_a1.o
 hisax-$(CONFIG_HISAX_AVM_A1_PCMCIA)	+= avm_a1p.o
-hisax-$(CONFIG_HISAX_FRITZPCI)		+= avm_pci.o
 hisax-$(CONFIG_HISAX_ELSA)		+= elsa.o
 hisax-$(CONFIG_HISAX_IX1MICROR2)	+= ix1_micro.o
 hisax-$(CONFIG_HISAX_DIEHLDIVA)		+= diva.o ipacx.o 
diff --git a/drivers/isdn/hisax/avm_pci.c b/drivers/isdn/hisax/avm_pci.c
index 0f1db1f..69f8389 100644
--- a/drivers/isdn/hisax/avm_pci.c
+++ b/drivers/isdn/hisax/avm_pci.c
@@ -14,13 +14,20 @@
 
 #include <linux/init.h>
 #include "hisax.h"
+#include "hisax_proto.h"
 #include "isac.h"
 #include "isdnl1.h"
 #include <linux/pci.h>
+#include <linux/isa.h>
 #include <linux/isapnp.h>
 #include <linux/interrupt.h>
 
-static const char *avm_pci_rev = "$Revision: 1.29.2.4 $";
+static int avm_protocol;		/* 0 == use DEFAULT_PROTO */
+
+#ifdef CONFIG_ISA
+static int avm_irq;			/* 0 == disable ISA probing */
+static int avm_io_base;			/* 0 == disable ISA probing */
+#endif
 
 #define  AVM_FRITZ_PCI		1
 #define  AVM_FRITZ_PNP		2
@@ -767,136 +774,267 @@ static int __devinit avm_setup_rest(struct IsdnCardState *cs)
 	return (1);
 }
 
-#ifndef __ISAPNP__
+#ifdef CONFIG_ISA
 
-static int __devinit avm_pnp_setup(struct IsdnCardState *cs)
+static int __devinit avm_isa_setup(struct IsdnCard *card)
 {
-	return(1);	/* no-op: success */
+	struct IsdnCardState *cs = card->cs;
+
+	/* old manual method */
+	cs->hw.avm.cfg_reg = avm_io_base;
+	cs->irq = avm_irq;
+	cs->subtyp = AVM_FRITZ_PNP;
+
+	return avm_setup_rest(cs);
 }
 
-#else
+static int __devinit avm_isa_init_one(struct device *dev, unsigned int id)
+{
+	struct IsdnCard icard = { ISDN_CTYPE_FRITZPCI, };
+	int cardnr;
 
-static struct pnp_card *pnp_avm_c __devinitdata = NULL;
+	icard.para[0] = (unsigned long) dev;
+	if (!avm_protocol)
+		icard.protocol = DEFAULT_PROTO;
+	else
+		icard.protocol = avm_protocol;
+
+	cardnr = hisax_init_hotplug(&icard, avm_isa_setup);
+	if (cardnr < 0)
+		return -ENODEV;
+	
+	dev_set_drvdata(dev, (void *)(unsigned long) cardnr);
+	return 0;
+}
 
-static int __devinit avm_pnp_setup(struct IsdnCardState *cs)
+static int __devexit avm_isa_remove_one(struct device *dev, unsigned int id)
 {
-	struct pnp_dev *pnp_avm_d = NULL;
+	int cardnr = (unsigned long) dev_get_drvdata(dev);
 
-	if (!isapnp_present())
-		return(1);	/* no-op: success */
+	HiSax_closecard(cardnr);
+	return 0;
+}
 
-	if ((pnp_avm_c = pnp_find_card(
-		ISAPNP_VENDOR('A', 'V', 'M'),
-		ISAPNP_FUNCTION(0x0900), pnp_avm_c))) {
-		if ((pnp_avm_d = pnp_find_dev(pnp_avm_c,
-			ISAPNP_VENDOR('A', 'V', 'M'),
-			ISAPNP_FUNCTION(0x0900), pnp_avm_d))) {
-			int err;
+static struct isa_driver avm_isa_driver = {
+	.probe		= avm_isa_init_one,
+	.remove		= __devexit_p(avm_isa_remove_one),
+	.driver = {
+		.owner	= THIS_MODULE,
+		.name	= "avm_pci",
+	},
+};
+
+#ifdef CONFIG_PNP
+static int __devinit avm_pnp_setup(struct IsdnCard *card)
+{
+	struct IsdnCardState *cs = card->cs;
+	struct pnp_dev *pnp_avm_d = (void *) card->para[0];
+	int err;
 
-			pnp_disable_dev(pnp_avm_d);
-			err = pnp_activate_dev(pnp_avm_d);
-			if (err<0) {
-				printk(KERN_WARNING "%s: pnp_activate_dev ret(%d)\n",
-					__FUNCTION__, err);
-				return(0);
-			}
-			cs->hw.avm.cfg_reg =
-				pnp_port_start(pnp_avm_d, 0);
-			cs->irq = pnp_irq(pnp_avm_d, 0);
-			if (!cs->irq) {
-				printk(KERN_ERR "FritzPnP:No IRQ\n");
-				return(0);
-			}
-			if (!cs->hw.avm.cfg_reg) {
-				printk(KERN_ERR "FritzPnP:No IO address\n");
-				return(0);
-			}
-			cs->subtyp = AVM_FRITZ_PNP;
+	pnp_disable_dev(pnp_avm_d);
 
-			return (2);	/* goto 'ready' label */
-		}
+	err = pnp_activate_dev(pnp_avm_d);
+	if (err<0) {
+		printk(KERN_WARNING "%s: pnp_activate_dev ret(%d)\n",
+			__FUNCTION__, err);
+		return(0);
 	}
 
-	return (1);
+	cs->irq = pnp_irq(pnp_avm_d, 0);
+	if (!cs->irq) {
+		printk(KERN_ERR "FritzPnP:No IRQ\n");
+		return(0);
+	}
+
+	cs->hw.avm.cfg_reg = pnp_port_start(pnp_avm_d, 0);
+	if (!cs->hw.avm.cfg_reg) {
+		printk(KERN_ERR "FritzPnP:No IO address\n");
+		return(0);
+	}
+	cs->subtyp = AVM_FRITZ_PNP;
+
+	return avm_setup_rest(cs);
 }
 
-#endif /* __ISAPNP__ */
+static int __devinit avm_pnp_init_one(struct pnp_dev *pdev,
+				       const struct pnp_device_id *dev_id)
+{
+	struct IsdnCard icard = { ISDN_CTYPE_FRITZPCI, };
+	int cardnr;
 
-#ifndef CONFIG_PCI_LEGACY
+	icard.para[0] = (unsigned long) pdev;
+	if (!avm_protocol)
+		icard.protocol = DEFAULT_PROTO;
+	else
+		icard.protocol = avm_protocol;
+
+	cardnr = hisax_init_hotplug(&icard, avm_pnp_setup);
+	if (cardnr < 0)
+		return -ENODEV;
+	
+	pnp_set_drvdata(pdev, (void *)(unsigned long) cardnr);
+	return 0;
+}
 
-static int __devinit avm_pci_setup(struct IsdnCardState *cs)
+static void __devexit avm_pnp_remove_one(struct pnp_dev *pdev)
 {
-	return(1);	/* no-op: success */
+	int cardnr = (unsigned long) pnp_get_drvdata(pdev);
+
+	HiSax_closecard(cardnr);
 }
 
-#else
+static struct pnp_device_id avm_pnp_table[] = {
+	{ .id = "AVM0900", },
 
-static struct pci_dev *dev_avm __devinitdata = NULL;
+	{ .id = "" }		/* terminate list */
+};
 
-static int __devinit avm_pci_setup(struct IsdnCardState *cs)
-{
-	if ((dev_avm = pci_find_device(PCI_VENDOR_ID_AVM,
-		PCI_DEVICE_ID_AVM_A1, dev_avm))) {
+static struct pnp_driver avm_pnp_driver = {
+	.name		= "avm_pci",
+	.id_table	= avm_pnp_table,
+	.probe		= avm_pnp_init_one,
+	.remove		= __devexit_p(avm_pnp_remove_one),
+};
+#endif /* CONFIG_PNP */
+#endif /* CONFIG_ISA */
 
-		if (pci_enable_device(dev_avm))
-			return(0);
+#ifdef CONFIG_PCI
 
-		cs->irq = dev_avm->irq;
-		if (!cs->irq) {
-			printk(KERN_ERR "FritzPCI: No IRQ for PCI card found\n");
-			return(0);
-		}
+static int __devinit avm_pci_setup(struct IsdnCard *card)
+{
+	struct IsdnCardState *cs = card->cs;
+	struct pci_dev *dev_avm = (void *) card->para[0];
 
-		cs->hw.avm.cfg_reg = pci_resource_start(dev_avm, 1);
-		if (!cs->hw.avm.cfg_reg) {
-			printk(KERN_ERR "FritzPCI: No IO-Adr for PCI card found\n");
-			return(0);
-		}
+	if (pci_enable_device(dev_avm))
+		return(0);
 
-		cs->subtyp = AVM_FRITZ_PCI;
-	} else {
-		printk(KERN_WARNING "FritzPCI: No PCI card found\n");
+	cs->irq = dev_avm->irq;
+	if (!cs->irq) {
+		printk(KERN_ERR "FritzPCI: No IRQ for PCI card found\n");
 		return(0);
 	}
 
+	cs->hw.avm.cfg_reg = pci_resource_start(dev_avm, 1);
+	if (!cs->hw.avm.cfg_reg) {
+		printk(KERN_ERR "FritzPCI: No IO-Adr for PCI card found\n");
+		return(0);
+	}
+
+	cs->subtyp = AVM_FRITZ_PCI;
+
 	cs->irq_flags |= IRQF_SHARED;
 
-	return (1);
+	return avm_setup_rest(cs);
 }
 
-#endif /* CONFIG_PCI_LEGACY */
-
-int __devinit
-setup_avm_pcipnp(struct IsdnCard *card)
+static int __devinit avm_pci_init_one(struct pci_dev *pdev,
+				      const struct pci_device_id *ent)
 {
-	struct IsdnCardState *cs = card->cs;
-	char tmp[64];
-	int rc;
+	struct IsdnCard icard = { ISDN_CTYPE_FRITZPCI, };
+	int cardnr;
 
-	strcpy(tmp, avm_pci_rev);
-	printk(KERN_INFO "HiSax: AVM PCI driver Rev. %s\n", HiSax_getrev(tmp));
+	icard.para[0] = (unsigned long) pdev;
+	if (!avm_protocol)
+		icard.protocol = DEFAULT_PROTO;
+	else
+		icard.protocol = avm_protocol;
+
+	cardnr = hisax_init_hotplug(&icard, avm_pci_setup);
+	if (cardnr < 0)
+		return -ENODEV;
+	
+	pci_set_drvdata(pdev, (void *)(unsigned long) cardnr);
+	return 0;
+}
 
-	if (cs->typ != ISDN_CTYPE_FRITZPCI)
-		return (0);
+static struct pci_device_id avm_pci_table[] = {
+	{ PCI_VDEVICE(AVM, PCI_DEVICE_ID_AVM_A1) },
+
+	{ }		/* terminate list */
+};
+
+static struct pci_driver avm_pci_driver = {
+	.name		= "avm_pci",
+	.id_table	= avm_pci_table,
+	.probe		= avm_pci_init_one,
+	.remove		= hisax_pci_remove_one,
+};
+
+#endif /* CONFIG_PCI */
 
-	if (card->para[1]) {
-		/* old manual method */
-		cs->hw.avm.cfg_reg = card->para[1];
-		cs->irq = card->para[0];
-		cs->subtyp = AVM_FRITZ_PNP;
-		goto ready;
+static int __init avm_mod_init(void)
+{
+	int rc = 0;
+
+#ifdef CONFIG_ISA
+	if (avm_irq && avm_io_base) {
+		rc = isa_register_driver(&avm_isa_driver, 1);
+		if (rc)
+			return rc;
+	}
+#ifdef CONFIG_PNP
+	else {
+		rc = pnp_register_driver(&avm_pnp_driver);
+		if (rc)
+			return rc;
 	}
+#endif
+#endif /* CONFIG_ISA */
 
-	rc = avm_pnp_setup(cs);
-	if (rc < 1)
-		return (0);
-	if (rc == 2)
-		goto ready;
+#ifdef CONFIG_PCI
+	rc = pci_register_driver(&avm_pci_driver);
+	if (rc)
+		goto err_out_isa;
+#endif /* CONFIG_PCI */
 
-	rc = avm_pci_setup(cs);
-	if (rc < 1)
-		return (0);
+	return 0;
 
-ready:
-	return avm_setup_rest(cs);
+#ifdef CONFIG_PCI
+err_out_isa:
+
+#ifdef CONFIG_ISA
+	if (avm_irq && avm_io_base)
+		isa_unregister_driver(&avm_isa_driver);
+#ifdef CONFIG_PNP
+	else
+		pnp_unregister_driver(&avm_pnp_driver);
+#endif /* CONFIG_PNP */
+#endif /* CONFIG_ISA */
+
+	return rc;
+#endif /* CONFIG_PCI */
 }
+
+static void __exit avm_mod_exit(void)
+{
+#ifdef CONFIG_PCI
+	pci_unregister_driver(&avm_pci_driver);
+#endif /* CONFIG_PCI */
+
+#ifdef CONFIG_ISA
+	if (avm_irq && avm_io_base)
+		isa_unregister_driver(&avm_isa_driver);
+#ifdef CONFIG_PNP
+	else
+		pnp_unregister_driver(&avm_pnp_driver);
+#endif /* CONFIG_PNP */
+#endif /* CONFIG_ISA */
+}
+
+module_init(avm_mod_init);
+module_exit(avm_mod_exit);
+
+#ifdef CONFIG_ISA
+module_param_named(irq, avm_irq, int, 0444);
+MODULE_PARM_DESC(irq, "ISA IRQ.  Zero disables ISA support (default).");
+
+module_param_named(io, avm_io_base, int, 0444);
+MODULE_PARM_DESC(io, "ISA I/O base.  Zero disables ISA support (default).");
+#endif /* CONFIG_ISA */
+
+module_param_named(protocol, avm_protocol, int, 0444);
+MODULE_PARM_DESC(protocol, "Values 0 (default) through 4. See ISDN_PTYPE_xxx in linux/isdnif.h");
+
+MODULE_DEVICE_TABLE(pci, avm_pci_table);
+MODULE_DESCRIPTION("ISDN HiSax Fritz!PCI/PNP driver");
+MODULE_LICENSE("GPL");
diff --git a/drivers/isdn/hisax/config.c b/drivers/isdn/hisax/config.c
index 77c00c9..62e4b85 100644
--- a/drivers/isdn/hisax/config.c
+++ b/drivers/isdn/hisax/config.c
@@ -117,13 +117,6 @@ const char *CardType[] = {
 #define DEFAULT_CFG {11,0x170,0,0}
 #endif
 
-#ifdef CONFIG_HISAX_FRITZPCI
-#undef DEFAULT_CARD
-#undef DEFAULT_CFG
-#define DEFAULT_CARD ISDN_CTYPE_FRITZPCI
-#define DEFAULT_CFG {0,0,0,0}
-#endif
-
 #ifdef CONFIG_HISAX_16_3
 #undef DEFAULT_CARD
 #undef DEFAULT_CFG
@@ -421,10 +414,6 @@ extern int setup_avm_a1(struct IsdnCard *card);
 extern int setup_avm_a1_pcmcia(struct IsdnCard *card);
 #endif
 
-#if CARD_FRITZPCI
-extern int setup_avm_pcipnp(struct IsdnCard *card);
-#endif
-
 #if CARD_ELSA
 extern int setup_elsa(struct IsdnCard *card);
 #endif
@@ -793,11 +782,6 @@ static int __devinit hisax_cs_setup_card(struct IsdnCard *card)
 		ret = setup_avm_a1_pcmcia(card);
 		break;
 #endif
-#if CARD_FRITZPCI
-	case ISDN_CTYPE_FRITZPCI:
-		ret = setup_avm_pcipnp(card);
-		break;
-#endif
 #if CARD_ELSA
 	case ISDN_CTYPE_ELSA:
 	case ISDN_CTYPE_ELSA_PNP:
@@ -890,6 +874,7 @@ static int __devinit hisax_cs_setup_card(struct IsdnCard *card)
 	case ISDN_CTYPE_NETJET_S:
 	case ISDN_CTYPE_NETJET_U:
 	case ISDN_CTYPE_TELESPCI:
+	case ISDN_CTYPE_FRITZPCI:
 		printk(KERN_WARNING "HiSax: Support for %s Card has moved "
 		       "to separate PCI driver module\n",
 		       CardType[card->typ]);
@@ -1336,7 +1321,6 @@ static int __init HiSax_init(void)
 		case ISDN_CTYPE_TELES3C:
 		case ISDN_CTYPE_ACERP10:
 		case ISDN_CTYPE_S0BOX:
-		case ISDN_CTYPE_FRITZPCI:
 		case ISDN_CTYPE_HSTSAPHIR:
 		case ISDN_CTYPE_GAZEL:
 		case ISDN_CTYPE_HFC_SX:
@@ -1360,6 +1344,7 @@ static int __init HiSax_init(void)
 		case ISDN_CTYPE_NETJET_S:
 		case ISDN_CTYPE_NETJET_U:
 		case ISDN_CTYPE_TELESPCI:
+		case ISDN_CTYPE_FRITZPCI:
 			break;
 
 		case ISDN_CTYPE_SCT_QUADRO:
@@ -1833,9 +1818,6 @@ static void EChannel_proc_rcv(struct hisax_d_if *d_if)
 #include <linux/pci.h>
 
 static struct pci_device_id hisax_pci_tbl[] __devinitdata = {
-#ifdef CONFIG_HISAX_FRITZPCI
-	{PCI_VENDOR_ID_AVM,      PCI_DEVICE_ID_AVM_A1,           PCI_ANY_ID, PCI_ANY_ID},
-#endif
 #ifdef CONFIG_HISAX_DIEHLDIVA
 	{PCI_VENDOR_ID_EICON,    PCI_DEVICE_ID_EICON_DIVA20,     PCI_ANY_ID, PCI_ANY_ID},
 	{PCI_VENDOR_ID_EICON,    PCI_DEVICE_ID_EICON_DIVA20_U,   PCI_ANY_ID, PCI_ANY_ID},
-- 
1.5.3.8


^ permalink raw reply	[flat|nested] 28+ messages in thread

* [PATCH 10/14] [ISDN] HiSax gazel: convert to modern ISA/PCI probing
  2007-07-18  3:04 [PATCH 00/14] [ISDN] HiSax hotplug conversion Jeff Garzik
                   ` (9 preceding siblings ...)
  2007-10-31  5:11 ` [PATCH 09/14] [ISDN] HiSax avm_pci: convert to modern PCI/ISA/PNP probing Jeff Garzik
@ 2007-10-31  5:12 ` Jeff Garzik
  2007-10-31  5:13 ` [PATCH 12/14] [ISDN] HiSax diva: convert to modern ISA/PNP/PCI probing Jeff Garzik
                   ` (6 subsequent siblings)
  17 siblings, 0 replies; 28+ messages in thread
From: Jeff Garzik @ 2007-10-31  5:12 UTC (permalink / raw)
  To: linux-kernel, kkeil, isdn4linux

Signed-off-by: Jeff Garzik <jgarzik@redhat.com>
---
 drivers/isdn/hisax/Kconfig  |    3 +-
 drivers/isdn/hisax/Makefile |    2 +-
 drivers/isdn/hisax/config.c |   25 +----
 drivers/isdn/hisax/gazel.c  |  248 ++++++++++++++++++++++++++++++++----------
 4 files changed, 194 insertions(+), 84 deletions(-)

diff --git a/drivers/isdn/hisax/Kconfig b/drivers/isdn/hisax/Kconfig
index 14951c0..dbc296e 100644
--- a/drivers/isdn/hisax/Kconfig
+++ b/drivers/isdn/hisax/Kconfig
@@ -306,7 +306,8 @@ config HISAX_SCT_QUADRO
 	  settings.
 
 config HISAX_GAZEL
-	bool "Gazel cards"
+	tristate "Gazel cards"
+	depends on (ISA || PCI)
 	help
 	  This enables HiSax support for the Gazel cards.
 
diff --git a/drivers/isdn/hisax/Makefile b/drivers/isdn/hisax/Makefile
index e03b4ce..e67bf92 100644
--- a/drivers/isdn/hisax/Makefile
+++ b/drivers/isdn/hisax/Makefile
@@ -23,6 +23,7 @@ obj-$(CONFIG_HISAX_NETJET)		+= netjet_s.o libhisax.o
 obj-$(CONFIG_HISAX_NETJET_U)		+= netjet_u.o libhisax.o
 obj-$(CONFIG_HISAX_TELESPCI)		+= telespci.o libhisax.o
 obj-$(CONFIG_HISAX_FRITZPCI)		+= avm_pci.o libhisax.o
+obj-$(CONFIG_HISAX_GAZEL)		+= gazel.o libhisax.o
 
 bkm_a4t_pci-objs			:= bkm_a4t.o jade.o
 enternow-objs				:= enternow_pci.o amd7930_fn.o
@@ -64,5 +65,4 @@ hisax-$(CONFIG_HISAX_NICCY)		+= niccy.o
 hisax-$(CONFIG_HISAX_ISURF)		+= isurf.o isar.o
 hisax-$(CONFIG_HISAX_HSTSAPHIR)		+= saphir.o
 hisax-$(CONFIG_HISAX_SCT_QUADRO)	+= bkm_a8.o
-hisax-$(CONFIG_HISAX_GAZEL)		+= gazel.o
 
diff --git a/drivers/isdn/hisax/config.c b/drivers/isdn/hisax/config.c
index 62e4b85..ec949f6 100644
--- a/drivers/isdn/hisax/config.c
+++ b/drivers/isdn/hisax/config.c
@@ -229,13 +229,6 @@ const char *CardType[] = {
 #define DEFAULT_CFG {1,0x0,0,0}
 #endif
 
-#ifdef CONFIG_HISAX_GAZEL
-#undef DEFAULT_CARD
-#undef DEFAULT_CFG
-#define DEFAULT_CARD ISDN_CTYPE_GAZEL
-#define DEFAULT_CFG {15,0x180,0,0}
-#endif
-
 #ifndef DEFAULT_CARD
 #define DEFAULT_CARD 0
 #define DEFAULT_CFG {0,0,0,0}
@@ -470,10 +463,6 @@ extern int setup_saphir(struct IsdnCard *card);
 extern int setup_sct_quadro(struct IsdnCard *card);
 #endif
 
-#if CARD_GAZEL
-extern int setup_gazel(struct IsdnCard *card);
-#endif
-
 /*
  * Find card with given driverId
  */
@@ -858,11 +847,6 @@ static int __devinit hisax_cs_setup_card(struct IsdnCard *card)
 		ret = setup_sct_quadro(card);
 		break;
 #endif
-#if CARD_GAZEL
-	case ISDN_CTYPE_GAZEL:
-		ret = setup_gazel(card);
-		break;
-#endif
 	case ISDN_CTYPE_DYNAMIC:
 		ret = 2;
 		break;
@@ -875,6 +859,7 @@ static int __devinit hisax_cs_setup_card(struct IsdnCard *card)
 	case ISDN_CTYPE_NETJET_U:
 	case ISDN_CTYPE_TELESPCI:
 	case ISDN_CTYPE_FRITZPCI:
+	case ISDN_CTYPE_GAZEL:
 		printk(KERN_WARNING "HiSax: Support for %s Card has moved "
 		       "to separate PCI driver module\n",
 		       CardType[card->typ]);
@@ -1322,7 +1307,6 @@ static int __init HiSax_init(void)
 		case ISDN_CTYPE_ACERP10:
 		case ISDN_CTYPE_S0BOX:
 		case ISDN_CTYPE_HSTSAPHIR:
-		case ISDN_CTYPE_GAZEL:
 		case ISDN_CTYPE_HFC_SX:
 		case ISDN_CTYPE_HFC_SP_PCMCIA:
 			cards[j].para[0] = irq[i];
@@ -1345,6 +1329,7 @@ static int __init HiSax_init(void)
 		case ISDN_CTYPE_NETJET_U:
 		case ISDN_CTYPE_TELESPCI:
 		case ISDN_CTYPE_FRITZPCI:
+		case ISDN_CTYPE_GAZEL:
 			break;
 
 		case ISDN_CTYPE_SCT_QUADRO:
@@ -1830,12 +1815,6 @@ static struct pci_device_id hisax_pci_tbl[] __devinitdata = {
 	{PCI_VENDOR_ID_ELSA,     PCI_DEVICE_ID_ELSA_MICROLINK,   PCI_ANY_ID, PCI_ANY_ID},
 	{PCI_VENDOR_ID_ELSA,     PCI_DEVICE_ID_ELSA_QS3000,      PCI_ANY_ID, PCI_ANY_ID},
 #endif
-#ifdef CONFIG_HISAX_GAZEL
-	{PCI_VENDOR_ID_PLX,      PCI_DEVICE_ID_PLX_R685,         PCI_ANY_ID, PCI_ANY_ID},
-	{PCI_VENDOR_ID_PLX,      PCI_DEVICE_ID_PLX_R753,         PCI_ANY_ID, PCI_ANY_ID},
-	{PCI_VENDOR_ID_PLX,      PCI_DEVICE_ID_PLX_DJINN_ITOO,   PCI_ANY_ID, PCI_ANY_ID},
-	{PCI_VENDOR_ID_PLX,      PCI_DEVICE_ID_PLX_OLITEC,       PCI_ANY_ID, PCI_ANY_ID},
-#endif
 #ifdef CONFIG_HISAX_SCT_QUADRO
 	{PCI_VENDOR_ID_PLX,      PCI_DEVICE_ID_PLX_9050,         PCI_ANY_ID, PCI_ANY_ID},
 #endif
diff --git a/drivers/isdn/hisax/gazel.c b/drivers/isdn/hisax/gazel.c
index 0ea3b46..4855e2a 100644
--- a/drivers/isdn/hisax/gazel.c
+++ b/drivers/isdn/hisax/gazel.c
@@ -13,12 +13,21 @@
 
 #include <linux/init.h>
 #include "hisax.h"
+#include "hisax_proto.h"
 #include "isac.h"
 #include "hscx.h"
 #include "isdnl1.h"
 #include "ipac.h"
+#include <linux/isa.h>
 #include <linux/pci.h>
 
+static int gazel_protocol;		/* 0 == use DEFAULT_PROTO */
+
+#ifdef CONFIG_ISA
+static int gazel_irq;			/* 0 == no ISA probing */
+static int gazel_io_base;		/* 0 == no ISA probing */
+#endif /* CONFIG_ISA */
+
 static const char *gazel_revision = "$Revision: 2.19.2.4 $";
 
 #define R647      1
@@ -483,7 +492,8 @@ reserve_regions(struct IsdnCard *card, struct IsdnCardState *cs)
 	return 1;
 }
 
-static int __devinit
+#ifdef CONFIG_ISA
+static void __devinit
 setup_gazelisa(struct IsdnCard *card, struct IsdnCardState *cs)
 {
 	printk(KERN_INFO "Gazel: ISA PnP card automatic recognition\n");
@@ -527,58 +537,35 @@ setup_gazelisa(struct IsdnCard *card, struct IsdnCardState *cs)
 			       cs->irq, cs->hw.gazel.ipac);
 			break;
 	}
-
-	return (0);
 }
+#endif /* CONFIG_ISA */
 
-#ifdef CONFIG_PCI_LEGACY
-static struct pci_dev *dev_tel __devinitdata = NULL;
-
+#ifdef CONFIG_PCI
 static int __devinit
-setup_gazelpci(struct IsdnCardState *cs)
+setup_gazelpci(struct IsdnCard *card)
 {
 	u_int pci_ioaddr0 = 0, pci_ioaddr1 = 0;
 	u_char pci_irq = 0, found;
-	u_int nbseek, seekcard;
+	u_int seekcard;
+	struct IsdnCardState *cs = card->cs;
+	struct pci_dev *dev_tel = (void *) card->para[0];
 
 	printk(KERN_WARNING "Gazel: PCI card automatic recognition\n");
 
 	found = 0;
-	seekcard = PCI_DEVICE_ID_PLX_R685;
-	for (nbseek = 0; nbseek < 4; nbseek++) {
-		if ((dev_tel = pci_find_device(PCI_VENDOR_ID_PLX,
-					seekcard, dev_tel))) {
-			if (pci_enable_device(dev_tel))
-				return 1;
-			pci_irq = dev_tel->irq;
-			pci_ioaddr0 = pci_resource_start(dev_tel, 1);
-			pci_ioaddr1 = pci_resource_start(dev_tel, 2);
-			found = 1;
-		}
-		if (found)
-			break;
-		else {
-			switch (seekcard) {
-				case PCI_DEVICE_ID_PLX_R685:
-					seekcard = PCI_DEVICE_ID_PLX_R753;
-					break;
-				case PCI_DEVICE_ID_PLX_R753:
-					seekcard = PCI_DEVICE_ID_PLX_DJINN_ITOO;
-					break;
-				case PCI_DEVICE_ID_PLX_DJINN_ITOO:
-					seekcard = PCI_DEVICE_ID_PLX_OLITEC;
-					break;
-			}
-		}
-	}
-	if (!found) {
-		printk(KERN_WARNING "Gazel: No PCI card found\n");
-		return (1);
-	}
+	seekcard = dev_tel->device;
+
+	if (pci_enable_device(dev_tel))
+		return 1;
+	pci_irq = dev_tel->irq;
+	pci_ioaddr0 = pci_resource_start(dev_tel, 1);
+	pci_ioaddr1 = pci_resource_start(dev_tel, 2);
+
 	if (!pci_irq) {
 		printk(KERN_WARNING "Gazel: No IRQ for PCI card found\n");
 		return 1;
 	}
+
 	cs->hw.gazel.pciaddr[0] = pci_ioaddr0;
 	cs->hw.gazel.pciaddr[1] = pci_ioaddr1;
 	setup_isac(cs);
@@ -620,10 +607,10 @@ setup_gazelpci(struct IsdnCardState *cs)
 
 	return (0);
 }
-#endif /* CONFIG_PCI_LEGACY */
+#endif /* CONFIG_PCI */
 
-int __devinit
-setup_gazel(struct IsdnCard *card)
+static int __devinit
+setup_gazel_rest(struct IsdnCard *card)
 {
 	struct IsdnCardState *cs = card->cs;
 	char tmp[64];
@@ -632,23 +619,6 @@ setup_gazel(struct IsdnCard *card)
 	strcpy(tmp, gazel_revision);
 	printk(KERN_INFO "Gazel: Driver Revision %s\n", HiSax_getrev(tmp));
 
-	if (cs->typ != ISDN_CTYPE_GAZEL)
-		return (0);
-
-	if (card->para[0]) {
-		if (setup_gazelisa(card, cs))
-			return (0);
-	} else {
-
-#ifdef CONFIG_PCI_LEGACY
-		if (setup_gazelpci(cs))
-			return (0);
-#else
-		printk(KERN_WARNING "Gazel: Card PCI requested and NO_PCI_BIOS, unable to config\n");
-		return (0);
-#endif				/* CONFIG_PCI */
-	}
-
 	if (reserve_regions(card, cs)) {
 		return (0);
 	}
@@ -688,3 +658,163 @@ setup_gazel(struct IsdnCard *card)
 
 	return (1);
 }
+
+#ifdef CONFIG_ISA
+
+static int __devinit gazel_isa_setup(struct IsdnCard *card)
+{
+	struct IsdnCardState *cs = card->cs;
+
+	setup_gazelisa(card, cs);
+
+	return setup_gazel_rest(card);
+}
+
+static int __devinit gazel_isa_init_one(struct device *dev, unsigned int id)
+{
+	struct IsdnCard icard = { ISDN_CTYPE_GAZEL, };
+	int cardnr;
+
+	icard.para[0] = gazel_irq;
+	icard.para[1] = gazel_io_base;
+	if (!gazel_protocol)
+		icard.protocol = DEFAULT_PROTO;
+	else
+		icard.protocol = gazel_protocol;
+
+	cardnr = hisax_init_hotplug(&icard, gazel_isa_setup);
+	if (cardnr < 0)
+		return -ENODEV;
+	
+	dev_set_drvdata(dev, (void *)(unsigned long) cardnr);
+	return 0;
+}
+
+static int __devexit gazel_isa_remove_one(struct device *dev, unsigned int id)
+{
+	int cardnr = (unsigned long) dev_get_drvdata(dev);
+
+	HiSax_closecard(cardnr);
+	return 0;
+}
+
+static struct isa_driver gazel_isa_driver = {
+	.probe		= gazel_isa_init_one,
+	.remove		= __devexit_p(gazel_isa_remove_one),
+	.driver = {
+		.owner	= THIS_MODULE,
+		.name	= "gazel_pci",
+	},
+};
+
+#endif /* CONFIG_ISA */
+
+#ifdef CONFIG_PCI
+
+static int __devinit gazel_pci_setup(struct IsdnCard *card)
+{
+	if (setup_gazelpci(card))
+		return 1;	/* error */
+
+	return setup_gazel_rest(card);
+}
+
+static int __devinit gazel_pci_init_one(struct pci_dev *pdev,
+				      const struct pci_device_id *ent)
+{
+	struct IsdnCard icard = { ISDN_CTYPE_GAZEL, };
+	int cardnr;
+
+	icard.para[0] = (unsigned long) pdev;
+	if (!gazel_protocol)
+		icard.protocol = DEFAULT_PROTO;
+	else
+		icard.protocol = gazel_protocol;
+
+	cardnr = hisax_init_hotplug(&icard, gazel_pci_setup);
+	if (cardnr < 0)
+		return -ENODEV;
+	
+	pci_set_drvdata(pdev, (void *)(unsigned long) cardnr);
+	return 0;
+}
+
+static struct pci_device_id gazel_pci_table[] = {
+	{ PCI_VDEVICE(PLX, PCI_DEVICE_ID_PLX_R685) },
+	{ PCI_VDEVICE(PLX, PCI_DEVICE_ID_PLX_R753) },
+	{ PCI_VDEVICE(PLX, PCI_DEVICE_ID_PLX_DJINN_ITOO) },
+	{ PCI_VDEVICE(PLX, PCI_DEVICE_ID_PLX_OLITEC) },
+
+	{ }		/* terminate list */
+};
+
+static struct pci_driver gazel_pci_driver = {
+	.name		= "gazel_pci",
+	.id_table	= gazel_pci_table,
+	.probe		= gazel_pci_init_one,
+	.remove		= hisax_pci_remove_one,
+};
+
+#endif /* CONFIG_PCI */
+
+static int __init gazel_mod_init(void)
+{
+	int rc = 0;
+
+#ifdef CONFIG_ISA
+	if (gazel_irq && gazel_io_base) {
+		rc = isa_register_driver(&gazel_isa_driver, 1);
+		if (rc)
+			return rc;
+	}
+#endif /* CONFIG_ISA */
+
+#ifdef CONFIG_PCI
+	rc = pci_register_driver(&gazel_pci_driver);
+	if (rc)
+		goto err_out_isa;
+#endif /* CONFIG_PCI */
+
+	return 0;
+
+#ifdef CONFIG_PCI
+err_out_isa:
+
+#ifdef CONFIG_ISA
+	if (gazel_irq && gazel_io_base)
+		isa_unregister_driver(&gazel_isa_driver);
+#endif /* CONFIG_ISA */
+
+	return rc;
+#endif /* CONFIG_PCI */
+}
+
+static void __exit gazel_mod_exit(void)
+{
+#ifdef CONFIG_PCI
+	pci_unregister_driver(&gazel_pci_driver);
+#endif /* CONFIG_PCI */
+
+#ifdef CONFIG_ISA
+	if (gazel_irq && gazel_io_base)
+		isa_unregister_driver(&gazel_isa_driver);
+#endif /* CONFIG_ISA */
+}
+
+module_init(gazel_mod_init);
+module_exit(gazel_mod_exit);
+
+#ifdef CONFIG_ISA
+module_param_named(irq, gazel_irq, int, 0444);
+MODULE_PARM_DESC(irq, "ISA IRQ.  Zero disables ISA support (default).");
+
+module_param_named(io, gazel_io_base, int, 0444);
+MODULE_PARM_DESC(io, "ISA I/O base.  Zero disables ISA support (default).");
+#endif /* CONFIG_ISA */
+
+module_param_named(protocol, gazel_protocol, int, 0444);
+MODULE_PARM_DESC(protocol, "Values 0 (default) through 4. See ISDN_PTYPE_xxx in linux/isdnif.h");
+
+MODULE_DEVICE_TABLE(pci, gazel_pci_table);
+MODULE_DESCRIPTION("ISDN HiSax Gazel PCI/ISA driver");
+MODULE_LICENSE("GPL");
-- 
1.5.3.8


^ permalink raw reply	[flat|nested] 28+ messages in thread

* [PATCH 12/14] [ISDN] HiSax diva: convert to modern ISA/PNP/PCI probing
  2007-07-18  3:04 [PATCH 00/14] [ISDN] HiSax hotplug conversion Jeff Garzik
                   ` (10 preceding siblings ...)
  2007-10-31  5:12 ` [PATCH 10/14] [ISDN] HiSax gazel: convert to modern ISA/PCI probing Jeff Garzik
@ 2007-10-31  5:13 ` Jeff Garzik
  2007-10-31  7:42 ` [PATCH 02/14] [ISDN] Hisax: eliminate many unnecessary references to CardType[] Jeff Garzik
                   ` (5 subsequent siblings)
  17 siblings, 0 replies; 28+ messages in thread
From: Jeff Garzik @ 2007-10-31  5:13 UTC (permalink / raw)
  To: linux-kernel, kkeil, isdn4linux

Signed-off-by: Jeff Garzik <jgarzik@redhat.com>
---
 drivers/isdn/hisax/Kconfig   |    3 +-
 drivers/isdn/hisax/Makefile  |    3 +-
 drivers/isdn/hisax/avm_pci.c |    9 +-
 drivers/isdn/hisax/config.c  |   27 +---
 drivers/isdn/hisax/diva.c    |  452 ++++++++++++++++++++++++++----------------
 drivers/isdn/hisax/niccy.c   |    2 +
 6 files changed, 290 insertions(+), 206 deletions(-)

diff --git a/drivers/isdn/hisax/Kconfig b/drivers/isdn/hisax/Kconfig
index 02cdc57..36af79f 100644
--- a/drivers/isdn/hisax/Kconfig
+++ b/drivers/isdn/hisax/Kconfig
@@ -165,7 +165,8 @@ config HISAX_IX1MICROR2
 	  non-standard IRQ/port settings.
 
 config HISAX_DIEHLDIVA
-	bool "Eicon.Diehl Diva cards"
+	tristate "Eicon.Diehl Diva cards"
+	depends on (ISA || PCI)
 	help
 	  This enables HiSax support for the Eicon.Diehl Diva none PRO
 	  versions passive ISDN cards.
diff --git a/drivers/isdn/hisax/Makefile b/drivers/isdn/hisax/Makefile
index f840b23..81ae5be 100644
--- a/drivers/isdn/hisax/Makefile
+++ b/drivers/isdn/hisax/Makefile
@@ -25,11 +25,13 @@ obj-$(CONFIG_HISAX_TELESPCI)		+= telespci.o libhisax.o
 obj-$(CONFIG_HISAX_FRITZPCI)		+= avm_pci.o libhisax.o
 obj-$(CONFIG_HISAX_GAZEL)		+= gazel.o libhisax.o
 obj-$(CONFIG_HISAX_NICCY)		+= niccy.o libhisax.o
+obj-$(CONFIG_HISAX_DIEHLDIVA)		+= hisaxdiva.o libhisax.o
 
 bkm_a4t_pci-objs			:= bkm_a4t.o jade.o
 enternow-objs				:= enternow_pci.o amd7930_fn.o
 netjet_s-objs				:= nj_s.o
 netjet_u-objs				:= nj_u.o icc.o
+hisaxdiva-objs				:= diva.o ipacx.o 
 libhisax-objs				:= netjet.o isac.o arcofi.o hscx.o
 
 ifdef CONFIG_HISAX_HDLC
@@ -54,7 +56,6 @@ hisax-$(CONFIG_HISAX_AVM_A1)		+= avm_a1.o
 hisax-$(CONFIG_HISAX_AVM_A1_PCMCIA)	+= avm_a1p.o
 hisax-$(CONFIG_HISAX_ELSA)		+= elsa.o
 hisax-$(CONFIG_HISAX_IX1MICROR2)	+= ix1_micro.o
-hisax-$(CONFIG_HISAX_DIEHLDIVA)		+= diva.o ipacx.o 
 hisax-$(CONFIG_HISAX_ASUSCOM)		+= asuscom.o
 hisax-$(CONFIG_HISAX_TELEINT)		+= teleint.o hfc_2bs0.o
 hisax-$(CONFIG_HISAX_SEDLBAUER)		+= sedlbauer.o isar.o
diff --git a/drivers/isdn/hisax/avm_pci.c b/drivers/isdn/hisax/avm_pci.c
index 69f8389..0b420aa 100644
--- a/drivers/isdn/hisax/avm_pci.c
+++ b/drivers/isdn/hisax/avm_pci.c
@@ -781,8 +781,8 @@ static int __devinit avm_isa_setup(struct IsdnCard *card)
 	struct IsdnCardState *cs = card->cs;
 
 	/* old manual method */
-	cs->hw.avm.cfg_reg = avm_io_base;
-	cs->irq = avm_irq;
+	cs->hw.avm.cfg_reg = card->para[1];
+	cs->irq = card->para[0];
 	cs->subtyp = AVM_FRITZ_PNP;
 
 	return avm_setup_rest(cs);
@@ -793,7 +793,8 @@ static int __devinit avm_isa_init_one(struct device *dev, unsigned int id)
 	struct IsdnCard icard = { ISDN_CTYPE_FRITZPCI, };
 	int cardnr;
 
-	icard.para[0] = (unsigned long) dev;
+	icard.para[0] = avm_irq;
+	icard.para[1] = avm_io_base;
 	if (!avm_protocol)
 		icard.protocol = DEFAULT_PROTO;
 	else
@@ -889,6 +890,8 @@ static struct pnp_device_id avm_pnp_table[] = {
 	{ .id = "" }		/* terminate list */
 };
 
+MODULE_DEVICE_TABLE(pnp, avm_pnp_table);
+
 static struct pnp_driver avm_pnp_driver = {
 	.name		= "avm_pci",
 	.id_table	= avm_pnp_table,
diff --git a/drivers/isdn/hisax/config.c b/drivers/isdn/hisax/config.c
index 7a1eb7d..fd8a564 100644
--- a/drivers/isdn/hisax/config.c
+++ b/drivers/isdn/hisax/config.c
@@ -145,13 +145,6 @@ const char *CardType[] = {
 #define DEFAULT_CFG {5,0x390,0,0}
 #endif
 
-#ifdef CONFIG_HISAX_DIEHLDIVA
-#undef DEFAULT_CARD
-#undef DEFAULT_CFG
-#define DEFAULT_CARD ISDN_CTYPE_DIEHLDIVA
-#define DEFAULT_CFG {0,0x0,0,0}
-#endif
-
 #ifdef CONFIG_HISAX_ASUSCOM
 #undef DEFAULT_CARD
 #undef DEFAULT_CFG
@@ -404,10 +397,6 @@ extern int setup_elsa(struct IsdnCard *card);
 extern int setup_ix1micro(struct IsdnCard *card);
 #endif
 
-#if CARD_DIEHLDIVA
-extern int setup_diva(struct IsdnCard *card);
-#endif
-
 #if CARD_ASUSCOM
 extern int setup_asuscom(struct IsdnCard *card);
 #endif
@@ -769,11 +758,6 @@ static int __devinit hisax_cs_setup_card(struct IsdnCard *card)
 		ret = setup_ix1micro(card);
 		break;
 #endif
-#if CARD_DIEHLDIVA
-	case ISDN_CTYPE_DIEHLDIVA:
-		ret = setup_diva(card);
-		break;
-#endif
 #if CARD_ASUSCOM
 	case ISDN_CTYPE_ASUSCOM:
 		ret = setup_asuscom(card);
@@ -841,6 +825,7 @@ static int __devinit hisax_cs_setup_card(struct IsdnCard *card)
 	case ISDN_CTYPE_FRITZPCI:
 	case ISDN_CTYPE_GAZEL:
 	case ISDN_CTYPE_NICCY:
+	case ISDN_CTYPE_DIEHLDIVA:
 		printk(KERN_WARNING "HiSax: Support for %s Card has moved "
 		       "to separate PCI driver module\n",
 		       CardType[card->typ]);
@@ -1275,7 +1260,6 @@ static int __init HiSax_init(void)
 		case ISDN_CTYPE_ELSA_PNP:
 		case ISDN_CTYPE_ELSA_PCMCIA:
 		case ISDN_CTYPE_IX1MICROR2:
-		case ISDN_CTYPE_DIEHLDIVA:
 		case ISDN_CTYPE_ASUSCOM:
 		case ISDN_CTYPE_TELEINT:
 		case ISDN_CTYPE_SEDLBAUER:
@@ -1311,6 +1295,7 @@ static int __init HiSax_init(void)
 		case ISDN_CTYPE_FRITZPCI:
 		case ISDN_CTYPE_GAZEL:
 		case ISDN_CTYPE_NICCY:
+		case ISDN_CTYPE_DIEHLDIVA:
 			break;
 
 		case ISDN_CTYPE_SCT_QUADRO:
@@ -1784,14 +1769,6 @@ static void EChannel_proc_rcv(struct hisax_d_if *d_if)
 #include <linux/pci.h>
 
 static struct pci_device_id hisax_pci_tbl[] __devinitdata = {
-#ifdef CONFIG_HISAX_DIEHLDIVA
-	{PCI_VENDOR_ID_EICON,    PCI_DEVICE_ID_EICON_DIVA20,     PCI_ANY_ID, PCI_ANY_ID},
-	{PCI_VENDOR_ID_EICON,    PCI_DEVICE_ID_EICON_DIVA20_U,   PCI_ANY_ID, PCI_ANY_ID},
-	{PCI_VENDOR_ID_EICON,    PCI_DEVICE_ID_EICON_DIVA201,    PCI_ANY_ID, PCI_ANY_ID},
-//#########################################################################################	
-	{PCI_VENDOR_ID_EICON,    PCI_DEVICE_ID_EICON_DIVA202,    PCI_ANY_ID, PCI_ANY_ID},
-//#########################################################################################	
-#endif
 #ifdef CONFIG_HISAX_ELSA
 	{PCI_VENDOR_ID_ELSA,     PCI_DEVICE_ID_ELSA_MICROLINK,   PCI_ANY_ID, PCI_ANY_ID},
 	{PCI_VENDOR_ID_ELSA,     PCI_DEVICE_ID_ELSA_QS3000,      PCI_ANY_ID, PCI_ANY_ID},
diff --git a/drivers/isdn/hisax/diva.c b/drivers/isdn/hisax/diva.c
index 2d67085..4fd5440 100644
--- a/drivers/isdn/hisax/diva.c
+++ b/drivers/isdn/hisax/diva.c
@@ -17,13 +17,22 @@
 
 #include <linux/init.h>
 #include "hisax.h"
+#include "hisax_proto.h"
 #include "isac.h"
 #include "hscx.h"
 #include "ipac.h"
 #include "ipacx.h"
 #include "isdnl1.h"
 #include <linux/pci.h>
-#include <linux/isapnp.h>
+#include <linux/isa.h>
+#include <linux/pnp.h>
+
+static int diva_protocol;		/* 0 == use DEFAULT_PROTO */
+
+#ifdef CONFIG_ISA
+static int diva_irq;			/* 0 == disable ISA */
+static int diva_io_base;		/* 0 == disable ISA */
+#endif
 
 static const char *Diva_revision = "$Revision: 1.33.2.6 $";
 
@@ -908,6 +917,13 @@ static int __devinit setup_diva_common(struct IsdnCardState *cs)
 {
 	int bytecnt;
 	u_char val;
+	char tmp[64];
+
+	strcpy(tmp, Diva_revision);
+	printk(KERN_INFO "HiSax: Eicon.Diehl Diva driver Rev. %s\n", HiSax_getrev(tmp));
+	if (cs->typ != ISDN_CTYPE_DIEHLDIVA)
+		return(0);
+	cs->hw.diva.status = 0;
 
 	if ((cs->subtyp == DIVA_ISA) || (cs->subtyp == DIVA_IPAC_ISA))
 		bytecnt = 8;
@@ -997,7 +1013,7 @@ static int __devinit setup_diva_common(struct IsdnCardState *cs)
 
 #ifdef CONFIG_ISA
 
-static int __devinit setup_diva_isa(struct IsdnCard *card)
+static int __devinit diva_isa_setup(struct IsdnCard *card)
 {
 	struct IsdnCardState *cs = card->cs;
 	u_char val;
@@ -1028,173 +1044,192 @@ static int __devinit setup_diva_isa(struct IsdnCard *card)
 	}
 	cs->irq = card->para[0];
 
-	return (1);		/* card found */
+	return setup_diva_common(cs);
 }
 
-#else	/* if !CONFIG_ISA */
+static int __devinit diva_isa_init_one(struct device *dev, unsigned int id)
+{
+	struct IsdnCard icard = { ISDN_CTYPE_DIEHLDIVA, };
+	int cardnr;
 
-static int __devinit setup_diva_isa(struct IsdnCard *card)
+	icard.para[0] = diva_irq;
+	icard.para[1] = diva_io_base;
+	if (!diva_protocol)
+		icard.protocol = DEFAULT_PROTO;
+	else
+		icard.protocol = diva_protocol;
+
+	cardnr = hisax_init_hotplug(&icard, diva_isa_setup);
+	if (cardnr < 0)
+		return -ENODEV;
+	
+	dev_set_drvdata(dev, (void *)(unsigned long) cardnr);
+	return 0;
+}
+
+static int __devexit diva_isa_remove_one(struct device *dev, unsigned int id)
 {
-	return (-1);	/* card not found; continue search */
+	int cardnr = (unsigned long) dev_get_drvdata(dev);
+
+	HiSax_closecard(cardnr);
+	return 0;
 }
 
-#endif	/* CONFIG_ISA */
-
-#ifdef __ISAPNP__
-static struct isapnp_device_id diva_ids[] __devinitdata = {
-	{ ISAPNP_VENDOR('G', 'D', 'I'), ISAPNP_FUNCTION(0x51),
-	  ISAPNP_VENDOR('G', 'D', 'I'), ISAPNP_FUNCTION(0x51), 
-	  (unsigned long) "Diva picola" },
-	{ ISAPNP_VENDOR('G', 'D', 'I'), ISAPNP_FUNCTION(0x51),
-	  ISAPNP_VENDOR('E', 'I', 'C'), ISAPNP_FUNCTION(0x51), 
-	  (unsigned long) "Diva picola" },
-	{ ISAPNP_VENDOR('G', 'D', 'I'), ISAPNP_FUNCTION(0x71),
-	  ISAPNP_VENDOR('G', 'D', 'I'), ISAPNP_FUNCTION(0x71), 
-	  (unsigned long) "Diva 2.0" },
-	{ ISAPNP_VENDOR('G', 'D', 'I'), ISAPNP_FUNCTION(0x71),
-	  ISAPNP_VENDOR('E', 'I', 'C'), ISAPNP_FUNCTION(0x71), 
-	  (unsigned long) "Diva 2.0" },
-	{ ISAPNP_VENDOR('G', 'D', 'I'), ISAPNP_FUNCTION(0xA1),
-	  ISAPNP_VENDOR('G', 'D', 'I'), ISAPNP_FUNCTION(0xA1), 
-	  (unsigned long) "Diva 2.01" },
-	{ ISAPNP_VENDOR('G', 'D', 'I'), ISAPNP_FUNCTION(0xA1),
-	  ISAPNP_VENDOR('E', 'I', 'C'), ISAPNP_FUNCTION(0xA1), 
-	  (unsigned long) "Diva 2.01" },
-	{ 0, }
+static struct isa_driver diva_isa_driver = {
+	.probe		= diva_isa_init_one,
+	.remove		= __devexit_p(diva_isa_remove_one),
+	.driver = {
+		.owner	= THIS_MODULE,
+		.name	= "diva_isa",
+	},
 };
 
-static struct isapnp_device_id *ipid __devinitdata = &diva_ids[0];
-static struct pnp_card *pnp_c __devinitdata = NULL;
-
-static int __devinit setup_diva_isapnp(struct IsdnCard *card)
+#ifdef CONFIG_PNP
+static int __devinit diva_pnp_setup(struct IsdnCard *card)
 {
 	struct IsdnCardState *cs = card->cs;
-	struct pnp_dev *pnp_d;
+	struct pnp_dev *pnp_d = (void *) card->para[0];
+	int ipid_function = card->para[1];
+	int err;
+
+	printk(KERN_INFO "HiSax: DIVA PNP detected\n");
+	pnp_disable_dev(pnp_d);
+	err = pnp_activate_dev(pnp_d);
+	if (err<0) {
+		printk(KERN_WARNING "%s: pnp_activate_dev ret(%d)\n",
+			__FUNCTION__, err);
+		return(0);
+	}
+	card->para[1] = pnp_port_start(pnp_d, 0);
+	card->para[0] = pnp_irq(pnp_d, 0);
+	if (!card->para[0] || !card->para[1]) {
+		printk(KERN_ERR "Diva PnP:some resources are missing %ld/%lx\n",
+			card->para[0], card->para[1]);
+		pnp_disable_dev(pnp_d); 
+		return(0);
+	}
+	cs->hw.diva.cfg_reg  = card->para[1];
+	cs->irq = card->para[0];
+	if (ipid_function == 0xA1) {
+		cs->subtyp = DIVA_IPAC_ISA;
+		cs->hw.diva.ctrl = 0;
+		cs->hw.diva.isac =
+			card->para[1] + DIVA_IPAC_DATA;
+		cs->hw.diva.hscx =
+			card->para[1] + DIVA_IPAC_DATA;
+		cs->hw.diva.isac_adr =
+			card->para[1] + DIVA_IPAC_ADR;
+		cs->hw.diva.hscx_adr =
+			card->para[1] + DIVA_IPAC_ADR;
+		test_and_set_bit(HW_IPAC, &cs->HW_Flags);
+	} else {
+		cs->subtyp = DIVA_ISA;
+		cs->hw.diva.ctrl =
+			card->para[1] + DIVA_ISA_CTRL;
+		cs->hw.diva.isac =
+			card->para[1] + DIVA_ISA_ISAC_DATA;
+		cs->hw.diva.hscx =
+			card->para[1] + DIVA_HSCX_DATA;
+		cs->hw.diva.isac_adr =
+			card->para[1] + DIVA_ISA_ISAC_ADR;
+		cs->hw.diva.hscx_adr =
+			card->para[1] + DIVA_HSCX_ADR;
+	}
 
-	if (!isapnp_present())
-		return (-1);	/* card not found; continue search */
+	return setup_diva_common(cs);
+}
 
-	while(ipid->card_vendor) {
-		if ((pnp_c = pnp_find_card(ipid->card_vendor,
-			ipid->card_device, pnp_c))) {
-			pnp_d = NULL;
-			if ((pnp_d = pnp_find_dev(pnp_c,
-				ipid->vendor, ipid->function, pnp_d))) {
-				int err;
-
-				printk(KERN_INFO "HiSax: %s detected\n",
-					(char *)ipid->driver_data);
-				pnp_disable_dev(pnp_d);
-				err = pnp_activate_dev(pnp_d);
-				if (err<0) {
-					printk(KERN_WARNING "%s: pnp_activate_dev ret(%d)\n",
-						__FUNCTION__, err);
-					return(0);
-				}
-				card->para[1] = pnp_port_start(pnp_d, 0);
-				card->para[0] = pnp_irq(pnp_d, 0);
-				if (!card->para[0] || !card->para[1]) {
-					printk(KERN_ERR "Diva PnP:some resources are missing %ld/%lx\n",
-						card->para[0], card->para[1]);
-					pnp_disable_dev(pnp_d); 
-					return(0);
-				}
-				cs->hw.diva.cfg_reg  = card->para[1];
-				cs->irq = card->para[0];
-				if (ipid->function == ISAPNP_FUNCTION(0xA1)) {
-					cs->subtyp = DIVA_IPAC_ISA;
-					cs->hw.diva.ctrl = 0;
-					cs->hw.diva.isac =
-						card->para[1] + DIVA_IPAC_DATA;
-					cs->hw.diva.hscx =
-						card->para[1] + DIVA_IPAC_DATA;
-					cs->hw.diva.isac_adr =
-						card->para[1] + DIVA_IPAC_ADR;
-					cs->hw.diva.hscx_adr =
-						card->para[1] + DIVA_IPAC_ADR;
-					test_and_set_bit(HW_IPAC, &cs->HW_Flags);
-				} else {
-					cs->subtyp = DIVA_ISA;
-					cs->hw.diva.ctrl =
-						card->para[1] + DIVA_ISA_CTRL;
-					cs->hw.diva.isac =
-						card->para[1] + DIVA_ISA_ISAC_DATA;
-					cs->hw.diva.hscx =
-						card->para[1] + DIVA_HSCX_DATA;
-					cs->hw.diva.isac_adr =
-						card->para[1] + DIVA_ISA_ISAC_ADR;
-					cs->hw.diva.hscx_adr =
-						card->para[1] + DIVA_HSCX_ADR;
-				}
-				return (1);		/* card found */
-			} else {
-				printk(KERN_ERR "Diva PnP: PnP error card found, no device\n");
-				return(0);
-			}
-		}
-		ipid++;
-		pnp_c=NULL;
-	} 
+static int __devinit diva_pnp_init_one(struct pnp_dev *pdev,
+				       const struct pnp_device_id *dev_id)
+{
+	struct IsdnCard icard = { ISDN_CTYPE_DIEHLDIVA, };
+	int cardnr;
 
-	return (-1);	/* card not found; continue search */
-}
+	icard.para[0] = (unsigned long) pdev;
+	icard.para[1] = dev_id->driver_data;
+	if (!diva_protocol)
+		icard.protocol = DEFAULT_PROTO;
+	else
+		icard.protocol = diva_protocol;
 
-#else	/* if !ISAPNP */
+	cardnr = hisax_init_hotplug(&icard, diva_pnp_setup);
+	if (cardnr < 0)
+		return -ENODEV;
+	
+	pnp_set_drvdata(pdev, (void *)(unsigned long) cardnr);
+	return 0;
+}
 
-static int __devinit setup_diva_isapnp(struct IsdnCard *card)
+static void __devexit diva_pnp_remove_one(struct pnp_dev *pdev)
 {
-	return (-1);	/* card not found; continue search */
+	int cardnr = (unsigned long) pnp_get_drvdata(pdev);
+
+	HiSax_closecard(cardnr);
 }
 
-#endif	/* ISAPNP */
+static struct pnp_device_id diva_pnp_table[] = {
+	{ .id = "GDI0051", 0 },
+	{ .id = "GDI0071", 0 },
+	{ .id = "GDI00A1", 0xA1 },
+	{ .id = "EIC0051", 0 },
+	{ .id = "EIC0071", 0 },
+	{ .id = "EIC00A1", 0xA1 },
+
+	{ .id = "" }		/* terminate list */
+};
+
+MODULE_DEVICE_TABLE(pnp, diva_pnp_table);
+
+static struct pnp_driver diva_pnp_driver = {
+	.name		= "diva_pnp",
+	.id_table	= diva_pnp_table,
+	.probe		= diva_pnp_init_one,
+	.remove		= __devexit_p(diva_pnp_remove_one),
+};
+#endif /* CONFIG_PNP */
+#endif /* CONFIG_ISA */
+
+#ifdef CONFIG_PCI
 
-#ifdef CONFIG_PCI_LEGACY
-static struct pci_dev *dev_diva __devinitdata = NULL;
-static struct pci_dev *dev_diva_u __devinitdata = NULL;
-static struct pci_dev *dev_diva201 __devinitdata = NULL;
-static struct pci_dev *dev_diva202 __devinitdata = NULL;
+enum diva_board_type {
+	diva20,
+	diva20_u,
+	diva201,
+	diva202,
+};
 
-static int __devinit setup_diva_pci(struct IsdnCard *card)
+static int __devinit diva_pci_setup(struct IsdnCard *card)
 {
 	struct IsdnCardState *cs = card->cs;
+	struct pci_dev *dev_diva = (void *) card->para[0];
+	enum diva_board_type btype = card->para[1];
 
 	cs->subtyp = 0;
-	if ((dev_diva = pci_find_device(PCI_VENDOR_ID_EICON,
-		PCI_DEVICE_ID_EICON_DIVA20, dev_diva))) {
-		if (pci_enable_device(dev_diva))
-			return(0);
+	cs->irq = dev_diva->irq;
+
+	if (pci_enable_device(dev_diva))
+		return(0);
+
+	if (btype == diva20) {
 		cs->subtyp = DIVA_PCI;
-		cs->irq = dev_diva->irq;
 		cs->hw.diva.cfg_reg = pci_resource_start(dev_diva, 2);
-	} else if ((dev_diva_u = pci_find_device(PCI_VENDOR_ID_EICON,
-		PCI_DEVICE_ID_EICON_DIVA20_U, dev_diva_u))) {
-		if (pci_enable_device(dev_diva_u))
-			return(0);
+	} else if (btype == diva20_u) {
 		cs->subtyp = DIVA_PCI;
-		cs->irq = dev_diva_u->irq;
-		cs->hw.diva.cfg_reg = pci_resource_start(dev_diva_u, 2);
-	} else if ((dev_diva201 = pci_find_device(PCI_VENDOR_ID_EICON,
-		PCI_DEVICE_ID_EICON_DIVA201, dev_diva201))) {
-		if (pci_enable_device(dev_diva201))
-			return(0);
+		cs->hw.diva.cfg_reg = pci_resource_start(dev_diva, 2);
+	} else if (btype == diva201) {
 		cs->subtyp = DIVA_IPAC_PCI;
-		cs->irq = dev_diva201->irq;
 		cs->hw.diva.pci_cfg =
-			(ulong) ioremap(pci_resource_start(dev_diva201, 0), 4096);
+			(ulong) ioremap(pci_resource_start(dev_diva, 0), 4096);
 		cs->hw.diva.cfg_reg =
-			(ulong) ioremap(pci_resource_start(dev_diva201, 1), 4096);
-	} else if ((dev_diva202 = pci_find_device(PCI_VENDOR_ID_EICON,
-		PCI_DEVICE_ID_EICON_DIVA202, dev_diva202))) {
-		if (pci_enable_device(dev_diva202))
-			return(0);
+			(ulong) ioremap(pci_resource_start(dev_diva, 1), 4096);
+	} else if (btype == diva202) {
 		cs->subtyp = DIVA_IPACX_PCI;
-		cs->irq = dev_diva202->irq;
 		cs->hw.diva.pci_cfg =
-			(ulong) ioremap(pci_resource_start(dev_diva202, 0), 4096);
+			(ulong) ioremap(pci_resource_start(dev_diva, 0), 4096);
 		cs->hw.diva.cfg_reg =
-			(ulong) ioremap(pci_resource_start(dev_diva202, 1), 4096);
+			(ulong) ioremap(pci_resource_start(dev_diva, 1), 4096);
 	} else {
-		return (-1);	/* card not found; continue search */
+		BUG();
 	}
 
 	if (!cs->irq) {
@@ -1226,58 +1261,123 @@ static int __devinit setup_diva_pci(struct IsdnCard *card)
 		cs->hw.diva.hscx_adr = cs->hw.diva.cfg_reg + DIVA_HSCX_ADR;
 	}
 
-	return (1);		/* card found */
+	return setup_diva_common(cs);
 }
 
-#else	/* if !CONFIG_PCI_LEGACY */
-
-static int __devinit setup_diva_pci(struct IsdnCard *card)
+static int __devinit diva_pci_init_one(struct pci_dev *pdev,
+				      const struct pci_device_id *ent)
 {
-	return (-1);	/* card not found; continue search */
+	struct IsdnCard icard = { ISDN_CTYPE_DIEHLDIVA, };
+	int cardnr;
+
+	icard.para[0] = (unsigned long) pdev;
+	icard.para[1] = ent->driver_data;
+	if (!diva_protocol)
+		icard.protocol = DEFAULT_PROTO;
+	else
+		icard.protocol = diva_protocol;
+
+	cardnr = hisax_init_hotplug(&icard, diva_pci_setup);
+	if (cardnr < 0)
+		return -ENODEV;
+	
+	pci_set_drvdata(pdev, (void *)(unsigned long) cardnr);
+	return 0;
 }
 
-#endif	/* CONFIG_PCI_LEGACY */
+static struct pci_device_id diva_pci_table[] = {
+	{ PCI_VDEVICE(EICON, PCI_DEVICE_ID_EICON_DIVA20),	diva20 },
+	{ PCI_VDEVICE(EICON, PCI_DEVICE_ID_EICON_DIVA20_U),	diva20_u },
+	{ PCI_VDEVICE(EICON, PCI_DEVICE_ID_EICON_DIVA201),	diva201 },
+//#########################################################################################	
+	{ PCI_VDEVICE(EICON, PCI_DEVICE_ID_EICON_DIVA202),	diva202 },
+//#########################################################################################	
 
-int __devinit
-setup_diva(struct IsdnCard *card)
-{
-	int rc, have_card = 0;
-	struct IsdnCardState *cs = card->cs;
-	char tmp[64];
+	{ }		/* terminate list */
+};
 
-	strcpy(tmp, Diva_revision);
-	printk(KERN_INFO "HiSax: Eicon.Diehl Diva driver Rev. %s\n", HiSax_getrev(tmp));
-	if (cs->typ != ISDN_CTYPE_DIEHLDIVA)
-		return(0);
-	cs->hw.diva.status = 0;
+static struct pci_driver diva_pci_driver = {
+	.name		= "diva",
+	.id_table	= diva_pci_table,
+	.probe		= diva_pci_init_one,
+	.remove		= hisax_pci_remove_one,
+};
 
-	rc = setup_diva_isa(card);
-	if (!rc)
-		return rc;
-	if (rc > 0) {
-		have_card = 1;
-		goto ready;
-	}
+#endif /* CONFIG_PCI */
+
+static int __init diva_mod_init(void)
+{
+	int rc = 0;
 
-	rc = setup_diva_isapnp(card);
-	if (!rc)
-		return rc;
-	if (rc > 0) {
-		have_card = 1;
-		goto ready;
+#ifdef CONFIG_ISA
+	if (diva_irq && diva_io_base) {
+		rc = isa_register_driver(&diva_isa_driver, 1);
+		if (rc)
+			return rc;
 	}
+#ifdef CONFIG_PNP
+	else {
+		rc = pnp_register_driver(&diva_pnp_driver);
+		if (rc)
+			return rc;
+	}
+#endif
+#endif /* CONFIG_ISA */
 
-	rc = setup_diva_pci(card);
-	if (!rc)
-		return rc;
-	if (rc > 0)
-		have_card = 1;
+#ifdef CONFIG_PCI
+	rc = pci_register_driver(&diva_pci_driver);
+	if (rc)
+		goto err_out_isa;
+#endif /* CONFIG_PCI */
 
-ready:
-	if (!have_card) {
-		printk(KERN_WARNING "Diva: No ISA, ISAPNP or PCI card found\n");
-		return(0);
-	}
+	return 0;
+
+#ifdef CONFIG_PCI
+err_out_isa:
+
+#ifdef CONFIG_ISA
+	if (diva_irq && diva_io_base)
+		isa_unregister_driver(&diva_isa_driver);
+#ifdef CONFIG_PNP
+	else
+		pnp_unregister_driver(&diva_pnp_driver);
+#endif /* CONFIG_PNP */
+#endif /* CONFIG_ISA */
 
-	return setup_diva_common(card->cs);
+	return rc;
+#endif /* CONFIG_PCI */
 }
+
+static void __exit diva_mod_exit(void)
+{
+#ifdef CONFIG_PCI
+	pci_unregister_driver(&diva_pci_driver);
+#endif /* CONFIG_PCI */
+
+#ifdef CONFIG_ISA
+	if (diva_irq && diva_io_base)
+		isa_unregister_driver(&diva_isa_driver);
+#ifdef CONFIG_PNP
+	else
+		pnp_unregister_driver(&diva_pnp_driver);
+#endif /* CONFIG_PNP */
+#endif /* CONFIG_ISA */
+}
+
+module_init(diva_mod_init);
+module_exit(diva_mod_exit);
+
+#ifdef CONFIG_ISA
+module_param_named(irq, diva_irq, int, 0444);
+MODULE_PARM_DESC(irq, "ISA IRQ.  Zero disables ISA support (default).");
+
+module_param_named(io, diva_io_base, int, 0444);
+MODULE_PARM_DESC(io, "ISA I/O base.  Zero disables ISA support (default).");
+#endif /* CONFIG_ISA */
+
+module_param_named(protocol, diva_protocol, int, 0444);
+MODULE_PARM_DESC(protocol, "Values 0 (default) through 4. See ISDN_PTYPE_xxx in linux/isdnif.h");
+
+MODULE_DEVICE_TABLE(pci, diva_pci_table);
+MODULE_DESCRIPTION("ISDN HiSax Diehldiva PCI/PNP/ISA driver");
+MODULE_LICENSE("GPL");
diff --git a/drivers/isdn/hisax/niccy.c b/drivers/isdn/hisax/niccy.c
index 20d4285..6b52c56 100644
--- a/drivers/isdn/hisax/niccy.c
+++ b/drivers/isdn/hisax/niccy.c
@@ -397,6 +397,8 @@ static struct pnp_device_id niccy_pnp_table[] = {
 	{ .id = "" }		/* terminate list */
 };
 
+MODULE_DEVICE_TABLE(pnp, niccy_pnp_table);
+
 static struct pnp_driver niccy_pnp_driver = {
 	.name		= "niccy",
 	.id_table	= niccy_pnp_table,
-- 
1.5.3.8


^ permalink raw reply	[flat|nested] 28+ messages in thread

* [PATCH 02/14] [ISDN] Hisax: eliminate many unnecessary references to CardType[]
  2007-07-18  3:04 [PATCH 00/14] [ISDN] HiSax hotplug conversion Jeff Garzik
                   ` (11 preceding siblings ...)
  2007-10-31  5:13 ` [PATCH 12/14] [ISDN] HiSax diva: convert to modern ISA/PNP/PCI probing Jeff Garzik
@ 2007-10-31  7:42 ` Jeff Garzik
  2008-02-15 13:37   ` Sam Ravnborg
  2007-11-06 14:41 ` [PATCH 14/14] [isdn-pci] add missing file Jeff Garzik
                   ` (4 subsequent siblings)
  17 siblings, 1 reply; 28+ messages in thread
From: Jeff Garzik @ 2007-10-31  7:42 UTC (permalink / raw)
  To: linux-kernel, kkeil, isdn4linux

For the vast majority of CardType[card->typ] uses (but not all!),
the string is constant for each driver.  Therefore, we may replace
CardType[card->typ] with the actual string describing the driver, making
each printk() a bit more simple.

This also has the nice, intended side effect of greatly reducing
external references to hisax global CardType[].  This will be of value
once the ISDN drivers are converted to the ISA/PCI/PNP hotplug APIs.

Signed-off-by: Jeff Garzik <jgarzik@redhat.com>
---
 drivers/isdn/hisax/asuscom.c   |    5 +----
 drivers/isdn/hisax/avm_a1.c    |   27 +++++++++------------------
 drivers/isdn/hisax/bkm_a4t.c   |   19 ++++++++++---------
 drivers/isdn/hisax/bkm_a8.c    |   31 +++++++++++++------------------
 drivers/isdn/hisax/gazel.c     |    5 ++---
 drivers/isdn/hisax/hfc_pci.c   |    2 --
 drivers/isdn/hisax/hfc_sx.c    |    2 --
 drivers/isdn/hisax/isurf.c     |   13 ++++---------
 drivers/isdn/hisax/ix1_micro.c |    9 ++++-----
 drivers/isdn/hisax/mic.c       |    5 +----
 drivers/isdn/hisax/netjet.h    |    2 --
 drivers/isdn/hisax/niccy.c     |   19 ++++++++-----------
 drivers/isdn/hisax/nj_s.c      |    3 +--
 drivers/isdn/hisax/nj_u.c      |    4 ++--
 drivers/isdn/hisax/s0box.c     |   13 ++++---------
 drivers/isdn/hisax/saphir.c    |    8 +++-----
 drivers/isdn/hisax/sportster.c |   11 +++++------
 drivers/isdn/hisax/teleint.c   |    5 +----
 drivers/isdn/hisax/telespci.c  |    5 ++---
 drivers/isdn/hisax/w6692.c     |    2 --
 20 files changed, 70 insertions(+), 120 deletions(-)

diff --git a/drivers/isdn/hisax/asuscom.c b/drivers/isdn/hisax/asuscom.c
index 61e69e9..b96f318 100644
--- a/drivers/isdn/hisax/asuscom.c
+++ b/drivers/isdn/hisax/asuscom.c
@@ -20,8 +20,6 @@
 #include "hscx.h"
 #include "isdnl1.h"
 
-extern const char *CardType[];
-
 static const char *Asuscom_revision = "$Revision: 1.14.2.4 $";
 
 #define byteout(addr,val) outb(val,addr)
@@ -376,8 +374,7 @@ setup_asuscom(struct IsdnCard *card)
 	cs->irq = card->para[0];
 	if (!request_region(cs->hw.asus.cfg_reg, bytecnt, "asuscom isdn")) {
 		printk(KERN_WARNING
-		       "HiSax: %s config port %x-%x already in use\n",
-		       CardType[card->typ],
+		       "HiSax: ISDNLink config port %x-%x already in use\n",
 		       cs->hw.asus.cfg_reg,
 		       cs->hw.asus.cfg_reg + bytecnt);
 		return (0);
diff --git a/drivers/isdn/hisax/avm_a1.c b/drivers/isdn/hisax/avm_a1.c
index d9028e9..eb6b432 100644
--- a/drivers/isdn/hisax/avm_a1.c
+++ b/drivers/isdn/hisax/avm_a1.c
@@ -16,7 +16,6 @@
 #include "hscx.h"
 #include "isdnl1.h"
 
-extern const char *CardType[];
 static const char *avm_revision = "$Revision: 2.15.2.4 $";
 
 #define	 AVM_A1_STAT_ISAC	0x01
@@ -200,16 +199,14 @@ setup_avm_a1(struct IsdnCard *card)
 	cs->irq = card->para[0];
 	if (!request_region(cs->hw.avm.cfg_reg, 8, "avm cfg")) {
 		printk(KERN_WARNING
-		       "HiSax: %s config port %x-%x already in use\n",
-		       CardType[card->typ],
+		       "HiSax: AVM A1 config port %x-%x already in use\n",
 		       cs->hw.avm.cfg_reg,
 		       cs->hw.avm.cfg_reg + 8);
 		return (0);
 	}
 	if (!request_region(cs->hw.avm.isac + 32, 32, "HiSax isac")) {
 		printk(KERN_WARNING
-		       "HiSax: %s isac ports %x-%x already in use\n",
-		       CardType[cs->typ],
+		       "HiSax: AVM A1 isac ports %x-%x already in use\n",
 		       cs->hw.avm.isac + 32,
 		       cs->hw.avm.isac + 64);
 		release_ioregs(cs, 0);
@@ -217,16 +214,14 @@ setup_avm_a1(struct IsdnCard *card)
 	}
 	if (!request_region(cs->hw.avm.isacfifo, 1, "HiSax isac fifo")) {
 		printk(KERN_WARNING
-		       "HiSax: %s isac fifo port %x already in use\n",
-		       CardType[cs->typ],
+		       "HiSax: AVM A1 isac fifo port %x already in use\n",
 		       cs->hw.avm.isacfifo);
 		release_ioregs(cs, 1);
 		return (0);
 	}
 	if (!request_region(cs->hw.avm.hscx[0] + 32, 32, "HiSax hscx A")) {
 		printk(KERN_WARNING
-		       "HiSax: %s hscx A ports %x-%x already in use\n",
-		       CardType[cs->typ],
+		       "HiSax: AVM A1 hscx A ports %x-%x already in use\n",
 		       cs->hw.avm.hscx[0] + 32,
 		       cs->hw.avm.hscx[0] + 64);
 		release_ioregs(cs, 3);
@@ -234,16 +229,14 @@ setup_avm_a1(struct IsdnCard *card)
 	}
 	if (!request_region(cs->hw.avm.hscxfifo[0], 1, "HiSax hscx A fifo")) {
 		printk(KERN_WARNING
-		       "HiSax: %s hscx A fifo port %x already in use\n",
-		       CardType[cs->typ],
+		       "HiSax: AVM A1 hscx A fifo port %x already in use\n",
 		       cs->hw.avm.hscxfifo[0]);
 		release_ioregs(cs, 7);
 		return (0);
 	}
 	if (!request_region(cs->hw.avm.hscx[1] + 32, 32, "HiSax hscx B")) {
 		printk(KERN_WARNING
-		       "HiSax: %s hscx B ports %x-%x already in use\n",
-		       CardType[cs->typ],
+		       "HiSax: AVM A1 hscx B ports %x-%x already in use\n",
 		       cs->hw.avm.hscx[1] + 32,
 		       cs->hw.avm.hscx[1] + 64);
 		release_ioregs(cs, 0xf);
@@ -251,8 +244,7 @@ setup_avm_a1(struct IsdnCard *card)
 	}
 	if (!request_region(cs->hw.avm.hscxfifo[1], 1, "HiSax hscx B fifo")) {
 		printk(KERN_WARNING
-		       "HiSax: %s hscx B fifo port %x already in use\n",
-		       CardType[cs->typ],
+		       "HiSax: AVM A1 hscx B fifo port %x already in use\n",
 		       cs->hw.avm.hscxfifo[1]);
 		release_ioregs(cs, 0x1f);
 		return (0);
@@ -284,9 +276,8 @@ setup_avm_a1(struct IsdnCard *card)
 	printk(KERN_INFO "AVM A1: Byte at %x is %x\n",
 	       cs->hw.avm.cfg_reg, val);
 
-	printk(KERN_INFO
-	       "HiSax: %s config irq:%d cfg:0x%X\n",
-	       CardType[cs->typ], cs->irq,
+	printk(KERN_INFO "HiSax: AVM A1 config irq:%d cfg:0x%X\n",
+	       cs->irq,
 	       cs->hw.avm.cfg_reg);
 	printk(KERN_INFO
 	       "HiSax: isac:0x%X/0x%X\n",
diff --git a/drivers/isdn/hisax/bkm_a4t.c b/drivers/isdn/hisax/bkm_a4t.c
index 3d1bdc8..9ca2ee5 100644
--- a/drivers/isdn/hisax/bkm_a4t.c
+++ b/drivers/isdn/hisax/bkm_a4t.c
@@ -20,8 +20,6 @@
 #include <linux/pci.h>
 #include "bkm_ax.h"
 
-extern const char *CardType[];
-
 static const char *bkm_a4t_revision = "$Revision: 1.22.2.4 $";
 
 
@@ -284,15 +282,16 @@ static int __devinit a4t_cs_init(struct IsdnCard *card,
 	I20_REGISTER_FILE *pI20_Regs;
 
 	if (!cs->irq) {		/* IRQ range check ?? */
-		printk(KERN_WARNING "HiSax: %s: No IRQ\n", CardType[card->typ]);
+		printk(KERN_WARNING "HiSax: Telekom A4T: No IRQ\n");
 		return (0);
 	}
 	cs->hw.ax.base = (long) ioremap(pci_memaddr, 4096);
 	/* Check suspecious address */
 	pI20_Regs = (I20_REGISTER_FILE *) (cs->hw.ax.base);
 	if ((pI20_Regs->i20IntStatus & 0x8EFFFFFF) != 0) {
-		printk(KERN_WARNING "HiSax: %s address %lx-%lx suspecious\n",
-		       CardType[card->typ], cs->hw.ax.base, cs->hw.ax.base + 4096);
+		printk(KERN_WARNING "HiSax: Telekom A4T address "
+		       "%lx-%lx suspicious\n",
+		       cs->hw.ax.base, cs->hw.ax.base + 4096);
 		iounmap((void *) cs->hw.ax.base);
 		cs->hw.ax.base = 0;
 		return (0);
@@ -302,8 +301,9 @@ static int __devinit a4t_cs_init(struct IsdnCard *card,
 	cs->hw.ax.isac_ale = GCS_1;
 	cs->hw.ax.jade_ale = GCS_3;
 
-	printk(KERN_INFO "HiSax: %s: Card configured at 0x%lX IRQ %d\n",
-	       CardType[card->typ], cs->hw.ax.base, cs->irq);
+	printk(KERN_INFO "HiSax: Telekom A4T: Card configured at "
+	       "0x%lX IRQ %d\n",
+	       cs->hw.ax.base, cs->irq);
 
 	setup_isac(cs);
 	cs->readisac = &ReadISAC;
@@ -349,11 +349,12 @@ setup_bkm_a4t(struct IsdnCard *card)
 			break;
 	}
 	if (!found) {
-		printk(KERN_WARNING "HiSax: %s: Card not found\n", CardType[card->typ]);
+		printk(KERN_WARNING "HiSax: Telekom A4T: Card not found\n");
 		return (0);
 	}
 	if (!pci_memaddr) {
-		printk(KERN_WARNING "HiSax: %s: No Memory base address\n", CardType[card->typ]);
+		printk(KERN_WARNING "HiSax: Telekom A4T: "
+		       "No Memory base address\n");
 		return (0);
 	}
 
diff --git a/drivers/isdn/hisax/bkm_a8.c b/drivers/isdn/hisax/bkm_a8.c
index 99ef3b4..e1ff471 100644
--- a/drivers/isdn/hisax/bkm_a8.c
+++ b/drivers/isdn/hisax/bkm_a8.c
@@ -22,8 +22,6 @@
 
 #define	ATTEMPT_PCI_REMAPPING	/* Required for PLX rev 1 */
 
-extern const char *CardType[];
-
 static const char sct_quadro_revision[] = "$Revision: 1.22.2.4 $";
 
 static const char *sct_quadro_subtypes[] =
@@ -181,8 +179,7 @@ bkm_interrupt_ipac(int intno, void *dev_id)
 		goto Start_IPAC;
 	}
 	if (!icnt)
-		printk(KERN_WARNING "HiSax: %s (%s) IRQ LOOP\n",
-		       CardType[cs->typ],
+		printk(KERN_WARNING "HiSax: Scitel Quadro (%s) IRQ LOOP\n",
 		       sct_quadro_subtypes[cs->subtyp]);
 	writereg(cs->hw.ax.base, cs->hw.ax.data_adr, IPAC_MASK, 0xFF);
 	writereg(cs->hw.ax.base, cs->hw.ax.data_adr, IPAC_MASK, 0xC0);
@@ -296,8 +293,8 @@ setup_sct_quadro(struct IsdnCard *card)
 	if (card->para[0] >= SCT_1 && card->para[0] <= SCT_4)
 		cs->subtyp = card->para[0];
 	else {
-		printk(KERN_WARNING "HiSax: %s: Invalid subcontroller in configuration, default to 1\n",
-			CardType[card->typ]);
+		printk(KERN_WARNING "HiSax: Scitel Quadro: Invalid "
+		       "subcontroller in configuration, default to 1\n");
 		return (0);
 	}
 	if ((cs->subtyp != SCT_1) && ((sub_sys_id != PCI_DEVICE_ID_BERKOM_SCITEL_QUADRO) ||
@@ -322,16 +319,16 @@ setup_sct_quadro(struct IsdnCard *card)
 			}
 		}
 		if (!found) {
-			printk(KERN_WARNING "HiSax: %s (%s): Card not found\n",
-				CardType[card->typ],
+			printk(KERN_WARNING "HiSax: Scitel Quadro (%s): "
+				"Card not found\n",
 				sct_quadro_subtypes[cs->subtyp]);
 			return (0);
 		}
 #ifdef ATTEMPT_PCI_REMAPPING
 /* HACK: PLX revision 1 bug: PLX address bit 7 must not be set */
 		if ((pci_ioaddr1 & 0x80) && (dev_a8->revision == 1)) {
-			printk(KERN_WARNING "HiSax: %s (%s): PLX rev 1, remapping required!\n",
-				CardType[card->typ],
+			printk(KERN_WARNING "HiSax: Scitel Quadro (%s): "
+				"PLX rev 1, remapping required!\n",
 				sct_quadro_subtypes[cs->subtyp]);
 			/* Restart PCI negotiation */
 			pci_write_config_dword(dev_a8, PCI_BASE_ADDRESS_1, (u_int) - 1);
@@ -344,8 +341,7 @@ setup_sct_quadro(struct IsdnCard *card)
 #endif /* End HACK */
 	}
 	if (!pci_irq) {		/* IRQ range check ?? */
-		printk(KERN_WARNING "HiSax: %s (%s): No IRQ\n",
-		       CardType[card->typ],
+		printk(KERN_WARNING "HiSax: Scitel Quadro (%s): No IRQ\n",
 		       sct_quadro_subtypes[cs->subtyp]);
 		return (0);
 	}
@@ -355,8 +351,8 @@ setup_sct_quadro(struct IsdnCard *card)
 	pci_read_config_dword(dev_a8, PCI_BASE_ADDRESS_4, &pci_ioaddr4);
 	pci_read_config_dword(dev_a8, PCI_BASE_ADDRESS_5, &pci_ioaddr5);
 	if (!pci_ioaddr1 || !pci_ioaddr2 || !pci_ioaddr3 || !pci_ioaddr4 || !pci_ioaddr5) {
-		printk(KERN_WARNING "HiSax: %s (%s): No IO base address(es)\n",
-		       CardType[card->typ],
+		printk(KERN_WARNING "HiSax: Scitel Quadro (%s): "
+		       "No IO base address(es)\n",
 		       sct_quadro_subtypes[cs->subtyp]);
 		return (0);
 	}
@@ -411,8 +407,8 @@ setup_sct_quadro(struct IsdnCard *card)
 	/* For isac and hscx data path */
 	cs->hw.ax.data_adr = cs->hw.ax.base + 4;
 
-	printk(KERN_INFO "HiSax: %s (%s) configured at 0x%.4lX, 0x%.4lX, 0x%.4lX and IRQ %d\n",
-	       CardType[card->typ],
+	printk(KERN_INFO "HiSax: Scitel Quadro (%s) configured at "
+	       "0x%.4lX, 0x%.4lX, 0x%.4lX and IRQ %d\n",
 	       sct_quadro_subtypes[cs->subtyp],
 	       cs->hw.ax.plx_adr,
 	       cs->hw.ax.base,
@@ -432,8 +428,7 @@ setup_sct_quadro(struct IsdnCard *card)
 	cs->cardmsg = &BKM_card_msg;
 	cs->irq_func = &bkm_interrupt_ipac;
 
-	printk(KERN_INFO "HiSax: %s (%s): IPAC Version %d\n",
-		CardType[card->typ],
+	printk(KERN_INFO "HiSax: Scitel Quadro (%s): IPAC Version %d\n",
 		sct_quadro_subtypes[cs->subtyp],
 		readreg(cs->hw.ax.base, cs->hw.ax.data_adr, IPAC_ID));
 	return (1);
diff --git a/drivers/isdn/hisax/gazel.c b/drivers/isdn/hisax/gazel.c
index f66620a..0ea3b46 100644
--- a/drivers/isdn/hisax/gazel.c
+++ b/drivers/isdn/hisax/gazel.c
@@ -19,7 +19,6 @@
 #include "ipac.h"
 #include <linux/pci.h>
 
-extern const char *CardType[];
 static const char *gazel_revision = "$Revision: 2.19.2.4 $";
 
 #define R647      1
@@ -479,8 +478,8 @@ reserve_regions(struct IsdnCard *card, struct IsdnCardState *cs)
 	return 0;
 
       error:
-	printk(KERN_WARNING "Gazel: %s io ports 0x%x-0x%x already in use\n",
-	       CardType[cs->typ], adr, adr + len);
+	printk(KERN_WARNING "Gazel: io ports 0x%x-0x%x already in use\n",
+	       adr, adr + len);
 	return 1;
 }
 
diff --git a/drivers/isdn/hisax/hfc_pci.c b/drivers/isdn/hisax/hfc_pci.c
index fba8b62..f126566 100644
--- a/drivers/isdn/hisax/hfc_pci.c
+++ b/drivers/isdn/hisax/hfc_pci.c
@@ -22,8 +22,6 @@
 #include <linux/pci.h>
 #include <linux/interrupt.h>
 
-extern const char *CardType[];
-
 static const char *hfcpci_revision = "$Revision: 1.48.2.4 $";
 
 /* table entry in the PCI devices list */
diff --git a/drivers/isdn/hisax/hfc_sx.c b/drivers/isdn/hisax/hfc_sx.c
index 05482d2..f4a2138 100644
--- a/drivers/isdn/hisax/hfc_sx.c
+++ b/drivers/isdn/hisax/hfc_sx.c
@@ -18,8 +18,6 @@
 #include <linux/interrupt.h>
 #include <linux/isapnp.h>
 
-extern const char *CardType[];
-
 static const char *hfcsx_revision = "$Revision: 1.12.2.5 $";
 
 /***************************************/
diff --git a/drivers/isdn/hisax/isurf.c b/drivers/isdn/hisax/isurf.c
index 55de069..ca41617 100644
--- a/drivers/isdn/hisax/isurf.c
+++ b/drivers/isdn/hisax/isurf.c
@@ -17,8 +17,6 @@
 #include "isdnl1.h"
 #include <linux/isapnp.h>
 
-extern const char *CardType[];
-
 static const char *ISurf_revision = "$Revision: 1.12.2.4 $";
 
 #define byteout(addr,val) outb(val,addr)
@@ -251,22 +249,19 @@ setup_isurf(struct IsdnCard *card)
 			return(0);
 		}
 #else
-		printk(KERN_WARNING "HiSax: %s port/mem not set\n",
-			CardType[card->typ]);
+		printk(KERN_WARNING "HiSax: Siemens I-Surf port/mem not set\n");
 		return (0);
 #endif
 	}
 	if (!request_region(cs->hw.isurf.reset, 1, "isurf isdn")) {
 		printk(KERN_WARNING
-			"HiSax: %s config port %x already in use\n",
-			CardType[card->typ],
+			"HiSax: Siemens I-Surf config port %x already in use\n",
 			cs->hw.isurf.reset);
 			return (0);
 	}
 	if (!request_region(cs->hw.isurf.phymem, ISURF_IOMEM_SIZE, "isurf iomem")) {
-		printk(KERN_WARNING
-			"HiSax: %s memory region %lx-%lx already in use\n",
-			CardType[card->typ],
+		printk(KERN_WARNING "HiSax: Siemens I-Surf memory region "
+			"%lx-%lx already in use\n",
 			cs->hw.isurf.phymem,
 			cs->hw.isurf.phymem + ISURF_IOMEM_SIZE);
 		release_region(cs->hw.isurf.reset, 1);
diff --git a/drivers/isdn/hisax/ix1_micro.c b/drivers/isdn/hisax/ix1_micro.c
index 252d79d..2d18d4f 100644
--- a/drivers/isdn/hisax/ix1_micro.c
+++ b/drivers/isdn/hisax/ix1_micro.c
@@ -24,7 +24,6 @@
 #include "hscx.h"
 #include "isdnl1.h"
 
-extern const char *CardType[];
 static const char *ix1_revision = "$Revision: 2.12.2.4 $";
 
 #define byteout(addr,val) outb(val,addr)
@@ -288,15 +287,15 @@ setup_ix1micro(struct IsdnCard *card)
 	if (cs->hw.ix1.cfg_reg) {
 		if (!request_region(cs->hw.ix1.cfg_reg, 4, "ix1micro cfg")) {
 			printk(KERN_WARNING
-			  "HiSax: %s config port %x-%x already in use\n",
-			       CardType[card->typ],
+			  "HiSax: ITK ix1-micro Rev.2 config port "
+			  "%x-%x already in use\n",
 			       cs->hw.ix1.cfg_reg,
 			       cs->hw.ix1.cfg_reg + 4);
 			return (0);
 		}
 	}
-	printk(KERN_INFO "HiSax: %s config irq:%d io:0x%X\n",
-		CardType[cs->typ], cs->irq, cs->hw.ix1.cfg_reg);
+	printk(KERN_INFO "HiSax: ITK ix1-micro Rev.2 config irq:%d io:0x%X\n",
+		cs->irq, cs->hw.ix1.cfg_reg);
 	setup_isac(cs);
 	cs->readisac = &ReadISAC;
 	cs->writeisac = &WriteISAC;
diff --git a/drivers/isdn/hisax/mic.c b/drivers/isdn/hisax/mic.c
index a81d175..2539430 100644
--- a/drivers/isdn/hisax/mic.c
+++ b/drivers/isdn/hisax/mic.c
@@ -16,8 +16,6 @@
 #include "hscx.h"
 #include "isdnl1.h"
 
-extern const char *CardType[];
-
 static const char *mic_revision = "$Revision: 1.12.2.4 $";
 
 #define byteout(addr,val) outb(val,addr)
@@ -210,8 +208,7 @@ setup_mic(struct IsdnCard *card)
 
 	if (!request_region(cs->hw.mic.cfg_reg, bytecnt, "mic isdn")) {
 		printk(KERN_WARNING
-		       "HiSax: %s config port %x-%x already in use\n",
-		       CardType[card->typ],
+		       "HiSax: ith mic config port %x-%x already in use\n",
 		       cs->hw.mic.cfg_reg,
 		       cs->hw.mic.cfg_reg + bytecnt);
 		return (0);
diff --git a/drivers/isdn/hisax/netjet.h b/drivers/isdn/hisax/netjet.h
index 4d89d3e..68e504d 100644
--- a/drivers/isdn/hisax/netjet.h
+++ b/drivers/isdn/hisax/netjet.h
@@ -12,8 +12,6 @@
  *
  */
 
-extern const char *CardType[];
-
 #define byteout(addr,val) outb(val,addr)
 #define bytein(addr) inb(addr)
 
diff --git a/drivers/isdn/hisax/niccy.c b/drivers/isdn/hisax/niccy.c
index bd99211..421b8e6 100644
--- a/drivers/isdn/hisax/niccy.c
+++ b/drivers/isdn/hisax/niccy.c
@@ -21,7 +21,6 @@
 #include <linux/pci.h>
 #include <linux/isapnp.h>
 
-extern const char *CardType[];
 static const char *niccy_revision = "$Revision: 1.21.2.4 $";
 
 #define byteout(addr,val) outb(val,addr)
@@ -284,14 +283,14 @@ int __devinit setup_niccy(struct IsdnCard *card)
 		cs->subtyp = NICCY_PNP;
 		cs->irq = card->para[0];
 		if (!request_region(cs->hw.niccy.isac, 2, "niccy data")) {
-			printk(KERN_WARNING "HiSax: %s data port %x-%x "
-				"already in use\n", CardType[card->typ],
+			printk(KERN_WARNING "HiSax: NICCY data port %x-%x "
+				"already in use\n",
 				cs->hw.niccy.isac, cs->hw.niccy.isac + 1);
 			return 0;
 		}
 		if (!request_region(cs->hw.niccy.isac_ale, 2, "niccy addr")) {
-			printk(KERN_WARNING "HiSax: %s address port %x-%x "
-				"already in use\n", CardType[card->typ],
+			printk(KERN_WARNING "HiSax: NICCY address port %x-%x "
+				"already in use\n",
 				cs->hw.niccy.isac_ale,
 				cs->hw.niccy.isac_ale + 1);
 			release_region(cs->hw.niccy.isac, 2);
@@ -339,15 +338,13 @@ int __devinit setup_niccy(struct IsdnCard *card)
 		cs->hw.niccy.hscx_ale = pci_ioaddr + HSCX_PCI_ADDR;
 		if (!request_region(cs->hw.niccy.isac, 4, "niccy")) {
 			printk(KERN_WARNING
-			       "HiSax: %s data port %x-%x already in use\n",
-			       CardType[card->typ],
+			       "HiSax: NICCY data port %x-%x already in use\n",
 			       cs->hw.niccy.isac, cs->hw.niccy.isac + 4);
 			return 0;
 		}
 		if (!request_region(cs->hw.niccy.cfg_reg, 0x40, "niccy pci")) {
 			printk(KERN_WARNING
-			       "HiSax: %s pci port %x-%x already in use\n",
-			       CardType[card->typ],
+			       "HiSax: NICCY pci port %x-%x already in use\n",
 			       cs->hw.niccy.cfg_reg,
 			       cs->hw.niccy.cfg_reg + 0x40);
 			release_region(cs->hw.niccy.isac, 4);
@@ -359,8 +356,8 @@ int __devinit setup_niccy(struct IsdnCard *card)
 		return 0;
 #endif				/* CONFIG_PCI_LEGACY */
 	}
-	printk(KERN_INFO "HiSax: %s %s config irq:%d data:0x%X ale:0x%X\n",
-		CardType[cs->typ], (cs->subtyp == 1) ? "PnP" : "PCI",
+	printk(KERN_INFO "HiSax: NICCY %s config irq:%d data:0x%X ale:0x%X\n",
+		(cs->subtyp == 1) ? "PnP" : "PCI",
 		cs->irq, cs->hw.niccy.isac, cs->hw.niccy.isac_ale);
 	setup_isac(cs);
 	cs->readisac = &ReadISAC;
diff --git a/drivers/isdn/hisax/nj_s.c b/drivers/isdn/hisax/nj_s.c
index a895dfe..8d36ccc 100644
--- a/drivers/isdn/hisax/nj_s.c
+++ b/drivers/isdn/hisax/nj_s.c
@@ -235,8 +235,7 @@ static int __devinit njs_cs_init_rest(struct IsdnCard *card,
 		cs->subtyp ? "TJ320" : "TJ300", cs->hw.njet.base, cs->irq);
 	if (!request_region(cs->hw.njet.base, bytecnt, "netjet-s isdn")) {
 		printk(KERN_WARNING
-		       "HiSax: %s config port %#lx-%#lx already in use\n",
-		       CardType[card->typ],
+		       "HiSax: NETjet-S config port %#lx-%#lx already in use\n",
 		       cs->hw.njet.base,
 		       cs->hw.njet.base + bytecnt);
 		return (0);
diff --git a/drivers/isdn/hisax/nj_u.c b/drivers/isdn/hisax/nj_u.c
index f017d38..d306c94 100644
--- a/drivers/isdn/hisax/nj_u.c
+++ b/drivers/isdn/hisax/nj_u.c
@@ -197,8 +197,8 @@ static int __devinit nju_cs_init_rest(struct IsdnCard *card,
 		cs->hw.njet.base, cs->irq);
 	if (!request_region(cs->hw.njet.base, bytecnt, "netspider-u isdn")) {
 		printk(KERN_WARNING
-		       "HiSax: %s config port %#lx-%#lx already in use\n",
-		       CardType[card->typ],
+		       "HiSax: NETspider-U config port %#lx-%#lx "
+		       "already in use\n",
 		       cs->hw.njet.base,
 		       cs->hw.njet.base + bytecnt);
 		return (0);
diff --git a/drivers/isdn/hisax/s0box.c b/drivers/isdn/hisax/s0box.c
index 150ef68..16d00b5 100644
--- a/drivers/isdn/hisax/s0box.c
+++ b/drivers/isdn/hisax/s0box.c
@@ -16,7 +16,6 @@
 #include "hscx.h"
 #include "isdnl1.h"
 
-extern const char *CardType[];
 static const char *s0box_revision = "$Revision: 2.6.2.4 $";
 
 static inline void
@@ -231,19 +230,15 @@ setup_s0box(struct IsdnCard *card)
 	cs->hw.teles3.hscxfifo[1] = cs->hw.teles3.hscx[1] + 0x3e;
 	cs->irq = card->para[0];
 	if (!request_region(cs->hw.teles3.cfg_reg,8, "S0Box parallel I/O")) {
-		printk(KERN_WARNING
-		       "HiSax: %s ports %x-%x already in use\n",
-		       CardType[cs->typ],
+		printk(KERN_WARNING "HiSax: S0Box ports %x-%x already in use\n",
                        cs->hw.teles3.cfg_reg,
                        cs->hw.teles3.cfg_reg + 7);
 		return 0;
 	}
-	printk(KERN_INFO
-		"HiSax: %s config irq:%d isac:0x%x  cfg:0x%x\n",
-		CardType[cs->typ], cs->irq,
+	printk(KERN_INFO "HiSax: S0Box config irq:%d isac:0x%x  cfg:0x%x\n",
+		cs->irq,
 		cs->hw.teles3.isac, cs->hw.teles3.cfg_reg);
-	printk(KERN_INFO
-		"HiSax: hscx A:0x%x  hscx B:0x%x\n",
+	printk(KERN_INFO "HiSax: hscx A:0x%x  hscx B:0x%x\n",
 		cs->hw.teles3.hscx[0], cs->hw.teles3.hscx[1]);
 	setup_isac(cs);
 	cs->readisac = &ReadISAC;
diff --git a/drivers/isdn/hisax/saphir.c b/drivers/isdn/hisax/saphir.c
index c99b166..b34a81d 100644
--- a/drivers/isdn/hisax/saphir.c
+++ b/drivers/isdn/hisax/saphir.c
@@ -18,7 +18,6 @@
 #include "hscx.h"
 #include "isdnl1.h"
 
-extern const char *CardType[];
 static char *saphir_rev = "$Revision: 1.10.2.4 $";
 
 #define byteout(addr,val) outb(val,addr)
@@ -260,15 +259,14 @@ setup_saphir(struct IsdnCard *card)
 	cs->irq = card->para[0];
 	if (!request_region(cs->hw.saphir.cfg_reg, 6, "saphir")) {
 		printk(KERN_WARNING
-			"HiSax: %s config port %x-%x already in use\n",
-			CardType[card->typ],
+			"HiSax: HST Saphir config port %x-%x already in use\n",
 			cs->hw.saphir.cfg_reg,
 			cs->hw.saphir.cfg_reg + 5);
 		return (0);
 	}
 
-	printk(KERN_INFO "HiSax: %s config irq:%d io:0x%X\n",
-		CardType[cs->typ], cs->irq, cs->hw.saphir.cfg_reg);
+	printk(KERN_INFO "HiSax: HST Saphir config irq:%d io:0x%X\n",
+	       cs->irq, cs->hw.saphir.cfg_reg);
 
 	setup_isac(cs);
 	cs->hw.saphir.timer.function = (void *) SaphirWatchDog;
diff --git a/drivers/isdn/hisax/sportster.c b/drivers/isdn/hisax/sportster.c
index 0220950..0a53759 100644
--- a/drivers/isdn/hisax/sportster.c
+++ b/drivers/isdn/hisax/sportster.c
@@ -18,7 +18,6 @@
 #include "hscx.h"
 #include "isdnl1.h"
 
-extern const char *CardType[];
 static const char *sportster_revision = "$Revision: 1.16.2.4 $";
 
 #define byteout(addr,val) outb(val,addr)
@@ -192,9 +191,9 @@ get_io_range(struct IsdnCardState *cs)
 	for (i=0;i<64;i++) {
 		adr = cs->hw.spt.cfg_reg + i *1024;
 		if (!request_region(adr, 8, "sportster")) {
-			printk(KERN_WARNING
-				"HiSax: %s config port %x-%x already in use\n",
-				CardType[cs->typ], adr, adr + 8);
+			printk(KERN_WARNING "HiSax: USR Sportster config port "
+				"%x-%x already in use\n",
+				adr, adr + 8);
 			break;
 		} 
 	}
@@ -247,8 +246,8 @@ setup_sportster(struct IsdnCard *card)
 			printk(KERN_WARNING "Sportster: wrong IRQ\n");
 			return(0);
 	}
-	printk(KERN_INFO "HiSax: %s config irq:%d cfg:0x%X\n",
-		CardType[cs->typ], cs->irq, cs->hw.spt.cfg_reg);
+	printk(KERN_INFO "HiSax: USR Sportster config irq:%d cfg:0x%X\n",
+		cs->irq, cs->hw.spt.cfg_reg);
 	setup_isac(cs);
 	cs->readisac = &ReadISAC;
 	cs->writeisac = &WriteISAC;
diff --git a/drivers/isdn/hisax/teleint.c b/drivers/isdn/hisax/teleint.c
index 0909662..b0ce4ae 100644
--- a/drivers/isdn/hisax/teleint.c
+++ b/drivers/isdn/hisax/teleint.c
@@ -16,8 +16,6 @@
 #include "hfc_2bs0.h"
 #include "isdnl1.h"
 
-extern const char *CardType[];
-
 static const char *TeleInt_revision = "$Revision: 1.16.2.5 $";
 
 #define byteout(addr,val) outb(val,addr)
@@ -286,8 +284,7 @@ setup_TeleInt(struct IsdnCard *card)
 	init_timer(&cs->hw.hfc.timer);
 	if (!request_region(cs->hw.hfc.addr, 2, "TeleInt isdn")) {
 		printk(KERN_WARNING
-		       "HiSax: %s config port %x-%x already in use\n",
-		       CardType[card->typ],
+		       "HiSax: TeleInt config port %x-%x already in use\n",
 		       cs->hw.hfc.addr,
 		       cs->hw.hfc.addr + 2);
 		return (0);
diff --git a/drivers/isdn/hisax/telespci.c b/drivers/isdn/hisax/telespci.c
index 4393003..28b08de 100644
--- a/drivers/isdn/hisax/telespci.c
+++ b/drivers/isdn/hisax/telespci.c
@@ -19,7 +19,6 @@
 #include "isdnl1.h"
 #include <linux/pci.h>
 
-extern const char *CardType[];
 static const char *telespci_revision = "$Revision: 2.23.2.3 $";
 
 #define ZORAN_PO_RQ_PEN	0x02000000
@@ -329,8 +328,8 @@ setup_telespci(struct IsdnCard *card)
 	/* writel(0x00800000, cs->hw.teles0.membase + 0x200); */
 
 	printk(KERN_INFO
-	       "HiSax: %s config irq:%d mem:%p\n",
-	       CardType[cs->typ], cs->irq,
+	       "HiSax: Teles PCI config irq:%d mem:%p\n",
+	       cs->irq,
 	       cs->hw.teles0.membase);
 
 	setup_isac(cs);
diff --git a/drivers/isdn/hisax/w6692.c b/drivers/isdn/hisax/w6692.c
index 39129b9..bb1c8dd 100644
--- a/drivers/isdn/hisax/w6692.c
+++ b/drivers/isdn/hisax/w6692.c
@@ -38,8 +38,6 @@ static const PCI_ENTRY id_list[] =
 #define W6692_DYNALINK 1
 #define W6692_USR      2
 
-extern const char *CardType[];
-
 static const char *w6692_revision = "$Revision: 1.18.2.4 $";
 
 #define DBUSY_TIMER_VALUE 80
-- 
1.5.3.8


^ permalink raw reply	[flat|nested] 28+ messages in thread

* [PATCH 14/14] [isdn-pci] add missing file
  2007-07-18  3:04 [PATCH 00/14] [ISDN] HiSax hotplug conversion Jeff Garzik
                   ` (12 preceding siblings ...)
  2007-10-31  7:42 ` [PATCH 02/14] [ISDN] Hisax: eliminate many unnecessary references to CardType[] Jeff Garzik
@ 2007-11-06 14:41 ` Jeff Garzik
  2008-02-14 23:52 ` [PATCH 00/14] [ISDN] HiSax hotplug conversion Greg KH
                   ` (3 subsequent siblings)
  17 siblings, 0 replies; 28+ messages in thread
From: Jeff Garzik @ 2007-11-06 14:41 UTC (permalink / raw)
  To: linux-kernel, kkeil, isdn4linux

---

SIDE NOTE -- this obviously needs to be ordered at the beginning of the
patchset.



 drivers/isdn/hisax/hisax_proto.h |   25 +++++++++++++++++++++++++
 1 files changed, 25 insertions(+), 0 deletions(-)
 create mode 100644 drivers/isdn/hisax/hisax_proto.h

diff --git a/drivers/isdn/hisax/hisax_proto.h b/drivers/isdn/hisax/hisax_proto.h
new file mode 100644
index 0000000..7eea361
--- /dev/null
+++ b/drivers/isdn/hisax/hisax_proto.h
@@ -0,0 +1,25 @@
+#ifndef __ISDN_HISAX_HISAX_PROTO_H__
+#define __ISDN_HISAX_HISAX_PROTO_H__
+
+#ifdef CONFIG_HISAX_1TR6
+#define DEFAULT_PROTO ISDN_PTYPE_1TR6
+#define DEFAULT_PROTO_NAME "1TR6"
+#endif
+#ifdef CONFIG_HISAX_NI1
+#undef DEFAULT_PROTO
+#define DEFAULT_PROTO ISDN_PTYPE_NI1
+#undef DEFAULT_PROTO_NAME
+#define DEFAULT_PROTO_NAME "NI1"
+#endif
+#ifdef CONFIG_HISAX_EURO
+#undef DEFAULT_PROTO
+#define DEFAULT_PROTO ISDN_PTYPE_EURO
+#undef DEFAULT_PROTO_NAME
+#define DEFAULT_PROTO_NAME "EURO"
+#endif
+#ifndef DEFAULT_PROTO
+#define DEFAULT_PROTO ISDN_PTYPE_UNKNOWN
+#define DEFAULT_PROTO_NAME "UNKNOWN"
+#endif
+
+#endif /* __ISDN_HISAX_HISAX_PROTO_H__ */
-- 
1.5.3.8


^ permalink raw reply	[flat|nested] 28+ messages in thread

* Re: [PATCH 00/14] [ISDN] HiSax hotplug conversion
  2008-02-14 23:52 ` [PATCH 00/14] [ISDN] HiSax hotplug conversion Greg KH
@ 2008-02-14 23:50   ` Jeff Garzik
  0 siblings, 0 replies; 28+ messages in thread
From: Jeff Garzik @ 2008-02-14 23:50 UTC (permalink / raw)
  To: Greg KH; +Cc: linux-kernel, kkeil, isdn4linux

Greg KH wrote:
> I have some patches in my pci tree to get rid of some pci_find_slot()
> usages, as well, so we are almost rid of these old functions.


Good...  I was avoiding that area, silently hoping that someone else 
would handle that part for me :)

	Jeff



^ permalink raw reply	[flat|nested] 28+ messages in thread

* Re: [PATCH 00/14] [ISDN] HiSax hotplug conversion
  2007-07-18  3:04 [PATCH 00/14] [ISDN] HiSax hotplug conversion Jeff Garzik
                   ` (13 preceding siblings ...)
  2007-11-06 14:41 ` [PATCH 14/14] [isdn-pci] add missing file Jeff Garzik
@ 2008-02-14 23:52 ` Greg KH
  2008-02-14 23:50   ` Jeff Garzik
  2008-02-14 23:53 ` Jeff Garzik
                   ` (2 subsequent siblings)
  17 siblings, 1 reply; 28+ messages in thread
From: Greg KH @ 2008-02-14 23:52 UTC (permalink / raw)
  To: Jeff Garzik; +Cc: linux-kernel, kkeil, isdn4linux

On Tue, Jul 17, 2007 at 11:04:04PM -0400, Jeff Garzik wrote:
> 
> This is a refresh of an on-going work-in-progress:  convert the last
> remaining users of pci_find_device() to the ISA/PCI/etc.  hotplug APIs
> now in standard use.  After SCSI's gdth, ISDN's HiSax suite of drivers
> are just about the last place using the older API.

Yeah!

I have some patches in my pci tree to get rid of some pci_find_slot()
usages, as well, so we are almost rid of these old functions.

Thanks a lot for doing this work, I really appreciate it.

greg k-h

^ permalink raw reply	[flat|nested] 28+ messages in thread

* Re: [PATCH 00/14] [ISDN] HiSax hotplug conversion
  2007-07-18  3:04 [PATCH 00/14] [ISDN] HiSax hotplug conversion Jeff Garzik
                   ` (14 preceding siblings ...)
  2008-02-14 23:52 ` [PATCH 00/14] [ISDN] HiSax hotplug conversion Greg KH
@ 2008-02-14 23:53 ` Jeff Garzik
  2008-02-15 13:27 ` Sam Ravnborg
  2008-02-16  1:09 ` Andrew Morton
  17 siblings, 0 replies; 28+ messages in thread
From: Jeff Garzik @ 2008-02-14 23:53 UTC (permalink / raw)
  To: linux-kernel, kkeil, isdn4linux; +Cc: Greg KH

Apologies to those who missed this patchset...  it carried the original 
patch creation date (July 2007).



^ permalink raw reply	[flat|nested] 28+ messages in thread

* Re: [PATCH 05/14] [ISDN] HiSax enternow: convert to PCI hotplug API
  2007-07-18  3:49 ` [PATCH 05/14] [ISDN] HiSax enternow: " Jeff Garzik
@ 2008-02-15 13:21   ` Jan Engelhardt
  0 siblings, 0 replies; 28+ messages in thread
From: Jan Engelhardt @ 2008-02-15 13:21 UTC (permalink / raw)
  To: Jeff Garzik; +Cc: linux-kernel, kkeil, isdn4linux


On Jul 17 2007 23:49, Jeff Garzik wrote:

>+static struct pci_device_id en_pci_table[] = {
>+	{ PCI_VENDOR_ID_TIGERJET, PCI_DEVICE_ID_TIGERJET_300, 0x55, 0x02, },
>+
>+	{ }		/* terminate list */
>+};

This can be

       v                                         v
static const struct pci_device_id en_pci_table[] __devinitconst = {
 ...
}

(also in other modules)

^ permalink raw reply	[flat|nested] 28+ messages in thread

* Re: [PATCH 00/14] [ISDN] HiSax hotplug conversion
  2007-07-18  3:04 [PATCH 00/14] [ISDN] HiSax hotplug conversion Jeff Garzik
                   ` (15 preceding siblings ...)
  2008-02-14 23:53 ` Jeff Garzik
@ 2008-02-15 13:27 ` Sam Ravnborg
  2008-02-15 15:13   ` Jeff Garzik
  2008-02-16  1:09 ` Andrew Morton
  17 siblings, 1 reply; 28+ messages in thread
From: Sam Ravnborg @ 2008-02-15 13:27 UTC (permalink / raw)
  To: Jeff Garzik; +Cc: linux-kernel, kkeil, isdn4linux, Greg KH

On Tue, Jul 17, 2007 at 11:04:04PM -0400, Jeff Garzik wrote:
> 
> This is a refresh of an on-going work-in-progress:  convert the last
> remaining users of pci_find_device() to the ISA/PCI/etc.  hotplug APIs
> now in standard use.  After SCSI's gdth, ISDN's HiSax suite of drivers
> are just about the last place using the older API.
> 
> A few rough edges remain, and I'm not sure how much of ISDN userland
> will explode (I have no ISDN hardware, nor much want any:)), but this
> should get us almost all the way there.
> 
> The patches are diff'd against 2.6.25-rc1.
> 
> Comments/review/testing welcome.  Especially "it works" or "its dead"
> testing.

Just ran checkpatch for the fun of it:
total: 28 errors, 86 warnings, 4896 lines checked
Most looks easy to fix.

Anyone with minimal interest in isdn could do so - hint!

	Sam

^ permalink raw reply	[flat|nested] 28+ messages in thread

* Re: [PATCH 04/14] [ISDN] HiSax bkm_a4t: convert to PCI hotplug API
  2007-07-18  3:46 ` [PATCH 04/14] [ISDN] HiSax bkm_a4t: convert to PCI hotplug API Jeff Garzik
@ 2008-02-15 13:33   ` Sam Ravnborg
  0 siblings, 0 replies; 28+ messages in thread
From: Sam Ravnborg @ 2008-02-15 13:33 UTC (permalink / raw)
  To: Jeff Garzik; +Cc: linux-kernel, kkeil, isdn4linux

On Tue, Jul 17, 2007 at 11:46:11PM -0400, Jeff Garzik wrote:
> Signed-off-by: Jeff Garzik <jeff@garzik.org>
> ---
>  drivers/isdn/hisax/Kconfig   |    4 +-
>  drivers/isdn/hisax/Makefile  |    3 +-
>  drivers/isdn/hisax/bkm_a4t.c |  115 ++++++++++++++++++++++++++++--------------
>  drivers/isdn/hisax/config.c  |   27 ++++------
>  4 files changed, 92 insertions(+), 57 deletions(-)
> 
> diff --git a/drivers/isdn/hisax/Kconfig b/drivers/isdn/hisax/Kconfig
> index 7832d8b..e7808f5 100644
> --- a/drivers/isdn/hisax/Kconfig
> +++ b/drivers/isdn/hisax/Kconfig
> @@ -286,8 +286,8 @@ config HISAX_HSTSAPHIR
>  	  settings.
>  
>  config HISAX_BKM_A4T
> -	bool "Telekom A4T card"
> -	depends on PCI && PCI_LEGACY
> +	tristate "Telekom A4T card"
> +	depends on PCI
>  	help
>  	  This enables HiSax support for the Telekom A4T card.
>  
> diff --git a/drivers/isdn/hisax/Makefile b/drivers/isdn/hisax/Makefile
> index b0b09e9..42bfc2f 100644
> --- a/drivers/isdn/hisax/Makefile
> +++ b/drivers/isdn/hisax/Makefile
> @@ -15,7 +15,9 @@ obj-$(CONFIG_HISAX_ST5481)		+= hisax_st5481.o
>  obj-$(CONFIG_HISAX_HFCUSB)		+= hfc_usb.o
>  obj-$(CONFIG_HISAX_HFC4S8S)		+= hfc4s8s_l1.o
>  obj-$(CONFIG_HISAX_FRITZ_PCIPNP)        += hisax_isac.o hisax_fcpcipnp.o
> +obj-$(CONFIG_HISAX_BKM_A4T)		+= bkm_a4t_pci.o libhisax.o
>  
> +bkm_a4t_pci-objs			:= bkm_a4t.o jade.o
Could we please use:
> +bkm_a4t_pci-y			:= bkm_a4t.o jade.o

> +static int __devinit
>  setup_bkm_a4t(struct IsdnCard *card)

One single line like you do here:

> +
> +static int __devinit a4t_pci_init_one(struct pci_dev *pdev,
> +				      const struct pci_device_id *ent)

> +
> +static struct pci_device_id a4t_pci_table[] = {
> +	{ PCI_VENDOR_ID_ZORAN, PCI_DEVICE_ID_ZORAN_36120,
> +	  PCI_VENDOR_ID_BERKOM, PCI_DEVICE_ID_BERKOM_A4T, },
> +
> +	{ }		/* terminate list */
> +};
const?

> +
> +static struct pci_driver a4t_pci_driver = {
> +	.name		= "bkm_a4t",
> +	.id_table	= a4t_pci_table,
> +	.probe		= a4t_pci_init_one,
> +	.remove		= hisax_pci_remove_one,
> +};
const?

> +module_param_named(protocol, a4t_protocol, int, 0444);
> +MODULE_PARM_DESC(protocol, "Values 0 (default) through 4. See ISDN_PTYPE_xxx in linux/isdnif.h");
> +
> +MODULE_DEVICE_TABLE(pci, a4t_pci_table);
> +MODULE_DESCRIPTION("ISDN HiSax BKM A4T PCI driver");
> +MODULE_LICENSE("GPL");

I thought this stuff belongs to top of file - not bottom.

	Sam

^ permalink raw reply	[flat|nested] 28+ messages in thread

* Re: [PATCH 02/14] [ISDN] Hisax: eliminate many unnecessary references to CardType[]
  2007-10-31  7:42 ` [PATCH 02/14] [ISDN] Hisax: eliminate many unnecessary references to CardType[] Jeff Garzik
@ 2008-02-15 13:37   ` Sam Ravnborg
  0 siblings, 0 replies; 28+ messages in thread
From: Sam Ravnborg @ 2008-02-15 13:37 UTC (permalink / raw)
  To: Jeff Garzik; +Cc: linux-kernel, kkeil, isdn4linux

On Wed, Oct 31, 2007 at 03:42:07AM -0400, Jeff Garzik wrote:
> For the vast majority of CardType[card->typ] uses (but not all!),
> the string is constant for each driver.  Therefore, we may replace
> CardType[card->typ] with the actual string describing the driver, making
> each printk() a bit more simple.
> 
> This also has the nice, intended side effect of greatly reducing
> external references to hisax global CardType[].  This will be of value
> once the ISDN drivers are converted to the ISA/PCI/PNP hotplug APIs.
> 
> Signed-off-by: Jeff Garzik <jgarzik@redhat.com>

Looks good. No comments.

	Sam

^ permalink raw reply	[flat|nested] 28+ messages in thread

* Re: [PATCH 01/14] [ISDN] HiSax: modularize card setup
  2007-07-18  3:04 ` [PATCH 01/14] [ISDN] HiSax: modularize card setup Jeff Garzik
@ 2008-02-15 13:38   ` Sam Ravnborg
  0 siblings, 0 replies; 28+ messages in thread
From: Sam Ravnborg @ 2008-02-15 13:38 UTC (permalink / raw)
  To: Jeff Garzik; +Cc: linux-kernel, kkeil, isdn4linux

On Tue, Jul 17, 2007 at 11:04:04PM -0400, Jeff Garzik wrote:
> Now that the previous no-behavior-change code movement patches have
> occurred, we can easily replace the big per-card "call the setup
> function for <this card>" switch statement with a function pointer.

I do not see the code changes matching the description.
There is no big switch that are gone with this patch.

	Sam

^ permalink raw reply	[flat|nested] 28+ messages in thread

* Re: [PATCH 03/14] [ISDN] Ready HiSax driver for modularization
  2007-10-31  5:10 ` [PATCH 03/14] [ISDN] Ready HiSax driver for modularization Jeff Garzik
@ 2008-02-15 13:45   ` Sam Ravnborg
  0 siblings, 0 replies; 28+ messages in thread
From: Sam Ravnborg @ 2008-02-15 13:45 UTC (permalink / raw)
  To: Jeff Garzik; +Cc: linux-kernel, kkeil, isdn4linux

On Wed, Oct 31, 2007 at 01:10:23AM -0400, Jeff Garzik wrote:
> * move netjet, isac, arcofi, hscx common sub-modules to new libhisax.ko
> * export several symbols that are used by external drivers
> * move DEFAULT_PROTO* deterination to shareable header file
> * add hotplug and PCI-remove APIs
> 
> Signed-off-by: Jeff Garzik <jeff@garzik.org>
> ---
>  drivers/isdn/hisax/Makefile    |   51 ++++++++++++++++++-----------------
>  drivers/isdn/hisax/arcofi.c    |    4 +++
>  drivers/isdn/hisax/config.c    |   57 ++++++++++++++++++++++++++--------------
>  drivers/isdn/hisax/hisax_cfg.h |    2 +
>  drivers/isdn/hisax/hscx.c      |    8 +++++
>  drivers/isdn/hisax/isac.c      |    6 ++++
>  drivers/isdn/hisax/isdnl1.c    |   12 +++++++-
>  drivers/isdn/hisax/lmgr.c      |    2 +
>  drivers/isdn/hisax/netjet.c    |    9 ++++++
>  drivers/isdn/hisax/q931.c      |    4 +++
>  10 files changed, 109 insertions(+), 46 deletions(-)
> 
> diff --git a/drivers/isdn/hisax/Makefile b/drivers/isdn/hisax/Makefile
> index c7a3794..b0b09e9 100644
> --- a/drivers/isdn/hisax/Makefile
> +++ b/drivers/isdn/hisax/Makefile
> @@ -6,7 +6,7 @@
>  
>  EXTRA_CFLAGS      += -DHISAX_MAX_CARDS=$(CONFIG_HISAX_MAX_CARDS)
>  
> -obj-$(CONFIG_ISDN_DRV_HISAX)		+= hisax.o
> +obj-$(CONFIG_ISDN_DRV_HISAX)		+= hisax.o libhisax.o
>  obj-$(CONFIG_HISAX_SEDLBAUER_CS)	+= sedlbauer_cs.o
>  obj-$(CONFIG_HISAX_ELSA_CS)		+= elsa_cs.o
>  obj-$(CONFIG_HISAX_AVM_A1_CS)		+= avma1_cs.o
> @@ -16,6 +16,8 @@ obj-$(CONFIG_HISAX_HFCUSB)		+= hfc_usb.o
>  obj-$(CONFIG_HISAX_HFC4S8S)		+= hfc4s8s_l1.o
>  obj-$(CONFIG_HISAX_FRITZ_PCIPNP)        += hisax_isac.o hisax_fcpcipnp.o
>  
> +libhisax-objs				:= netjet.o isac.o arcofi.o hscx.o

Please use
> +libhisax-y				:= netjet.o isac.o arcofi.o hscx.o

>  
> diff --git a/drivers/isdn/hisax/arcofi.c b/drivers/isdn/hisax/arcofi.c
> index d30ce5b..bf2e10d 100644
> --- a/drivers/isdn/hisax/arcofi.c
> +++ b/drivers/isdn/hisax/arcofi.c
> @@ -132,3 +132,7 @@ init_arcofi(struct IsdnCardState *cs) {
>  	init_waitqueue_head(&cs->dc.isac.arcofi_wait);
>  	test_and_set_bit(HW_ARCOFI, &cs->HW_Flags);
>  }
> +
> +EXPORT_SYMBOL(init_arcofi);
> +EXPORT_SYMBOL(clear_arcofi);
> +EXPORT_SYMBOL(arcofi_fsm);

Should be just below their respective implmentation.

> diff --git a/drivers/isdn/hisax/config.c b/drivers/isdn/hisax/config.c
> index f395a72..6112013 100644
> --- a/drivers/isdn/hisax/config.c
> +++ b/drivers/isdn/hisax/config.c
> @@ -19,10 +19,12 @@
>  #include <linux/timer.h>
>  #include <linux/init.h>
>  #include "hisax.h"
> +#include "hisax_proto.h"
Should be last in the include order - not mixed between
<linux/xxx.h> includes.

>  #include <linux/module.h>

> +#ifdef CONFIG_PCI
> +void hisax_pci_remove_one(struct pci_dev *pdev)
> +{
> +	int cardnr = (unsigned long) pci_get_drvdata(pdev);
> +
> +	HiSax_closecard(cardnr);
> +	pci_disable_device(pdev);
> +	pci_set_drvdata(pdev, NULL);
> +}
> +
> +EXPORT_SYMBOL(hisax_pci_remove_one);

No empty line above.

>  
>  EXPORT_SYMBOL(hisax_init_pcmcia);
> +EXPORT_SYMBOL(hisax_init_hotplug);
>  EXPORT_SYMBOL(HiSax_closecard);
> +EXPORT_SYMBOL(HiSax_getrev);
> +EXPORT_SYMBOL(HiSax_putstatus);

Exports right after implmentation.

> --- a/drivers/isdn/hisax/hscx.c
> +++ b/drivers/isdn/hisax/hscx.c
> @@ -274,3 +274,11 @@ inithscxisac(struct IsdnCardState *cs, int part)
>  		cs->writeisac(cs, ISAC_CMDR, 0x41);
>  	}
>  }
> +
> +EXPORT_SYMBOL(HscxVersion);
> +EXPORT_SYMBOL(inithscxisac);
> +EXPORT_SYMBOL(inithscx);
> +EXPORT_SYMBOL(clear_pending_hscx_ints);
> +EXPORT_SYMBOL(hscx_l2l1);
> +EXPORT_SYMBOL(open_hscxstate);
> +EXPORT_SYMBOL(modehscx);

exports right after implmentation.

> diff --git a/drivers/isdn/hisax/isac.c b/drivers/isdn/hisax/isac.c
> index 07b1673..40bb5f8 100644
> --- a/drivers/isdn/hisax/isac.c
> +++ b/drivers/isdn/hisax/isac.c
> @@ -678,3 +678,9 @@ setup_isac(struct IsdnCardState *cs)
>  	cs->dbusytimer.data = (long) cs;
>  	init_timer(&cs->dbusytimer);
>  }
> +
> +EXPORT_SYMBOL(isac_interrupt);
> +EXPORT_SYMBOL(initisac);
> +EXPORT_SYMBOL(clear_pending_isac_ints);
> +EXPORT_SYMBOL(ISACVersion);
> +EXPORT_SYMBOL(setup_isac);

exports right after implmentation.

> +
> +EXPORT_SYMBOL(l1_msg);
> +EXPORT_SYMBOL(l1_msg_b);
> +EXPORT_SYMBOL(debugl1);
> +EXPORT_SYMBOL(setstack_l1_B);
> +EXPORT_SYMBOL(DChannel_proc_rcv);
> +EXPORT_SYMBOL(DChannel_proc_xmt);
> +#ifdef L2FRAME_DEBUG
> +EXPORT_SYMBOL(Logl2Frame);
> +#endif

ditto

> diff --git a/drivers/isdn/hisax/lmgr.c b/drivers/isdn/hisax/lmgr.c
> index d4f86d6..5980490 100644
> --- a/drivers/isdn/hisax/lmgr.c
> +++ b/drivers/isdn/hisax/lmgr.c
> @@ -48,3 +48,5 @@ setstack_manager(struct PStack *st)
>  {
>  	st->ma.layer = hisax_manager;
>  }
> +
> +EXPORT_SYMBOL(setstack_manager);
Drop empty line above.

> diff --git a/drivers/isdn/hisax/netjet.c b/drivers/isdn/hisax/netjet.c
> index 02c6fba..1e3e45b 100644
> --- a/drivers/isdn/hisax/netjet.c
> +++ b/drivers/isdn/hisax/netjet.c
> @@ -979,3 +979,12 @@ release_io_netjet(struct IsdnCardState *cs)
>  	release_region(cs->hw.njet.base, 256);
>  }
>  
> +EXPORT_SYMBOL(NETjet_WriteICfifo);
> +EXPORT_SYMBOL(NETjet_ReadICfifo);
> +EXPORT_SYMBOL(NETjet_WriteIC);
> +EXPORT_SYMBOL(NETjet_ReadIC);
> +EXPORT_SYMBOL(write_tiger);
> +EXPORT_SYMBOL(read_tiger);
> +EXPORT_SYMBOL(inittiger);
> +EXPORT_SYMBOL(netjet_fill_dma);
> +EXPORT_SYMBOL(release_io_netjet);

exports right after implementation.

> diff --git a/drivers/isdn/hisax/q931.c b/drivers/isdn/hisax/q931.c
> index aacbf0d..8a4e60b 100644
> --- a/drivers/isdn/hisax/q931.c
> +++ b/drivers/isdn/hisax/q931.c
> @@ -1520,3 +1520,7 @@ dlogframe(struct IsdnCardState *cs, struct sk_buff *skb, int dir)
>  	*dp = 0;
>  	HiSax_putstatus(cs, NULL, cs->dlog);
>  }
> +
> +EXPORT_SYMBOL(dlogframe);
> +EXPORT_SYMBOL(LogFrame);
> +EXPORT_SYMBOL(QuickHex);

exports right after implementation.

^ permalink raw reply	[flat|nested] 28+ messages in thread

* Re: [PATCH 00/14] [ISDN] HiSax hotplug conversion
  2008-02-15 13:27 ` Sam Ravnborg
@ 2008-02-15 15:13   ` Jeff Garzik
  2008-02-15 19:11     ` Sam Ravnborg
  0 siblings, 1 reply; 28+ messages in thread
From: Jeff Garzik @ 2008-02-15 15:13 UTC (permalink / raw)
  To: Sam Ravnborg, Andrew Morton; +Cc: linux-kernel, kkeil, isdn4linux, Greg KH

Sam Ravnborg wrote:
> On Tue, Jul 17, 2007 at 11:04:04PM -0400, Jeff Garzik wrote:
>> This is a refresh of an on-going work-in-progress:  convert the last
>> remaining users of pci_find_device() to the ISA/PCI/etc.  hotplug APIs
>> now in standard use.  After SCSI's gdth, ISDN's HiSax suite of drivers
>> are just about the last place using the older API.
>>
>> A few rough edges remain, and I'm not sure how much of ISDN userland
>> will explode (I have no ISDN hardware, nor much want any:)), but this
>> should get us almost all the way there.
>>
>> The patches are diff'd against 2.6.25-rc1.
>>
>> Comments/review/testing welcome.  Especially "it works" or "its dead"
>> testing.
> 
> Just ran checkpatch for the fun of it:
> total: 28 errors, 86 warnings, 4896 lines checked
> Most looks easy to fix.

I'll take a look...  if its checkpatch stuff I caused, I'm happy to fix it.

But I'm trying to avoid cleanups for pre-existing conditions, i.e. 
flagged by checkpatch only because I moved existing code to a new location.

Down that path lies madness and way too much work :)  I didn't sign on 
to clean up ISDN :)

Anyway, thanks for the multiple comments, they will be taken into 
account in the next update of these patches.

	Jeff



^ permalink raw reply	[flat|nested] 28+ messages in thread

* Re: [PATCH 00/14] [ISDN] HiSax hotplug conversion
  2008-02-15 15:13   ` Jeff Garzik
@ 2008-02-15 19:11     ` Sam Ravnborg
  0 siblings, 0 replies; 28+ messages in thread
From: Sam Ravnborg @ 2008-02-15 19:11 UTC (permalink / raw)
  To: Jeff Garzik; +Cc: Andrew Morton, linux-kernel, kkeil, isdn4linux, Greg KH

> >
> >Just ran checkpatch for the fun of it:
> >total: 28 errors, 86 warnings, 4896 lines checked
> >Most looks easy to fix.
> 
> I'll take a look...  if its checkpatch stuff I caused, I'm happy to fix it.
> 
> But I'm trying to avoid cleanups for pre-existing conditions, i.e. 
> flagged by checkpatch only because I moved existing code to a new location.
> 
> Down that path lies madness and way too much work :)  I didn't sign on 
> to clean up ISDN :)
> 
> Anyway, thanks for the multiple comments, they will be taken into 
> account in the next update of these patches.

I was distracted when halfdone - but I assume that I would just
repeated myself for the rest of the drivers.

When you post an updated version I will try to take a little
bit deeper look. I did not get the full picture of the libification
you have made in hisax.

	Sam

^ permalink raw reply	[flat|nested] 28+ messages in thread

* Re: [PATCH 00/14] [ISDN] HiSax hotplug conversion
  2007-07-18  3:04 [PATCH 00/14] [ISDN] HiSax hotplug conversion Jeff Garzik
                   ` (16 preceding siblings ...)
  2008-02-15 13:27 ` Sam Ravnborg
@ 2008-02-16  1:09 ` Andrew Morton
  17 siblings, 0 replies; 28+ messages in thread
From: Andrew Morton @ 2008-02-16  1:09 UTC (permalink / raw)
  To: Jeff Garzik; +Cc: linux-kernel, kkeil, isdn4linux, greg

On Tue, 17 Jul 2007 23:04:04 -0400
Jeff Garzik <jeff@garzik.org> wrote:

> This is a refresh of an on-going work-in-progress:  convert the last
> remaining users of pci_find_device() to the ISA/PCI/etc.  hotplug APIs
> now in standard use.  After SCSI's gdth, ISDN's HiSax suite of drivers
> are just about the last place using the older API.
> 
> A few rough edges remain, and I'm not sure how much of ISDN userland
> will explode (I have no ISDN hardware, nor much want any:)), but this
> should get us almost all the way there.
> 
> The patches are diff'd against 2.6.25-rc1.
> 
> Comments/review/testing welcome.  Especially "it works" or "its dead"
> testing.

When `make modules_install' runs depmod using
http://userweb.kernel.org/~akpm/config-akpm2.txt these patches cause this:


WARNING: Module /lib/modules/2.6.25-rc2-mm1/kernel/drivers/isdn/hisax/teles_cs.ko ignored, due to loop
WARNING: Module /lib/modules/2.6.25-rc2-mm1/kernel/drivers/isdn/hisax/hisax_st5481.ko ignored, due to loop
WARNING: Module /lib/modules/2.6.25-rc2-mm1/kernel/drivers/isdn/hisax/elsa_cs.ko ignored, due to loop
WARNING: Module /lib/modules/2.6.25-rc2-mm1/kernel/drivers/isdn/hisax/hfc4s8s_l1.ko ignored, due to loop
WARNING: Module /lib/modules/2.6.25-rc2-mm1/kernel/drivers/isdn/hisax/hisax_isac.ko ignored, due to loop
WARNING: Module /lib/modules/2.6.25-rc2-mm1/kernel/drivers/isdn/hisax/avma1_cs.ko ignored, due to loop
WARNING: Module /lib/modules/2.6.25-rc2-mm1/kernel/drivers/isdn/hisax/libhisax.ko ignored, due to loop
WARNING: Loop detected: /lib/modules/2.6.25-rc2-mm1/kernel/drivers/isdn/hisax/hisax.ko needs libhisax.ko which needs hisax.ko again!
WARNING: Module /lib/modules/2.6.25-rc2-mm1/kernel/drivers/isdn/hisax/hisax.ko ignored, due to loop
WARNING: Module /lib/modules/2.6.25-rc2-mm1/kernel/drivers/isdn/hisax/sedlbauer_cs.ko ignored, due to loop
WARNING: Module /lib/modules/2.6.25-rc2-mm1/kernel/drivers/isdn/hisax/hisax_fcpcipnp.ko ignored, due to loop

^ permalink raw reply	[flat|nested] 28+ messages in thread

* [PATCH 11/14] [ISDN] HiSax niccy: convert to modern ISA/PNP/PCI probing
  2008-02-16  4:41 [PATCH 01/14] [ISDN] HiSax: modularization prep Jeff Garzik
@ 2007-07-24 12:26 ` Jeff Garzik
  0 siblings, 0 replies; 28+ messages in thread
From: Jeff Garzik @ 2007-07-24 12:26 UTC (permalink / raw)
  To: kkeil, isdn4linux, linux-kernel

Signed-off-by: Jeff Garzik <jgarzik@redhat.com>
---
 drivers/isdn/hisax/Kconfig  |    3 +-
 drivers/isdn/hisax/Makefile |    2 +-
 drivers/isdn/hisax/config.c |   26 +---
 drivers/isdn/hisax/niccy.c  |  460 +++++++++++++++++++++++++++++++------------
 4 files changed, 334 insertions(+), 157 deletions(-)

diff --git a/drivers/isdn/hisax/Kconfig b/drivers/isdn/hisax/Kconfig
index dbc296e..02cdc57 100644
--- a/drivers/isdn/hisax/Kconfig
+++ b/drivers/isdn/hisax/Kconfig
@@ -257,7 +257,8 @@ config HISAX_NETJET_U
 	  settings.
 
 config HISAX_NICCY
-	bool "Niccy PnP/PCI card"
+	tristate "Niccy PnP/PCI card"
+	depends on (ISA || PCI)
 	help
 	  This enables HiSax support for the Dr. Neuhaus Niccy PnP or PCI.
 
diff --git a/drivers/isdn/hisax/Makefile b/drivers/isdn/hisax/Makefile
index 10ab294..9efd189 100644
--- a/drivers/isdn/hisax/Makefile
+++ b/drivers/isdn/hisax/Makefile
@@ -24,6 +24,7 @@ obj-$(CONFIG_HISAX_NETJET_U)		+= netjet_u.o libhisax.o
 obj-$(CONFIG_HISAX_TELESPCI)		+= telespci.o libhisax.o
 obj-$(CONFIG_HISAX_FRITZPCI)		+= avm_pci.o libhisax.o
 obj-$(CONFIG_HISAX_GAZEL)		+= gazel.o libhisax.o
+obj-$(CONFIG_HISAX_NICCY)		+= niccy.o libhisax.o
 
 bkm_a4t_pci-y				:= bkm_a4t.o jade.o
 enternow-y				:= enternow_pci.o amd7930_fn.o
@@ -61,7 +62,6 @@ hisax-$(CONFIG_HISAX_SPORTSTER)		+= sportster.o
 hisax-$(CONFIG_HISAX_MIC)		+= mic.o
 hisax-$(CONFIG_HISAX_HFCS)		+= hfcscard.o hfc_2bds0.o
 hisax-$(CONFIG_HISAX_HFC_SX)		+= hfc_sx.o
-hisax-$(CONFIG_HISAX_NICCY)		+= niccy.o
 hisax-$(CONFIG_HISAX_ISURF)		+= isurf.o isar.o
 hisax-$(CONFIG_HISAX_HSTSAPHIR)		+= saphir.o
 hisax-$(CONFIG_HISAX_SCT_QUADRO)	+= bkm_a8.o
diff --git a/drivers/isdn/hisax/config.c b/drivers/isdn/hisax/config.c
index 63dba42..243c7c9 100644
--- a/drivers/isdn/hisax/config.c
+++ b/drivers/isdn/hisax/config.c
@@ -201,13 +201,6 @@ const char *CardType[] = {
 #define DEFAULT_CFG {5,0x2E0,0,0}
 #endif
 
-#ifdef CONFIG_HISAX_NICCY
-#undef DEFAULT_CARD
-#undef DEFAULT_CFG
-#define DEFAULT_CARD ISDN_CTYPE_NICCY
-#define DEFAULT_CFG {0,0x0,0,0}
-#endif
-
 #ifdef CONFIG_HISAX_ISURF
 #undef DEFAULT_CARD
 #undef DEFAULT_CFG
@@ -258,10 +251,6 @@ static int io[HISAX_MAX_CARDS] = { 0, };
 #ifdef CONFIG_HISAX_16_3
 #define IO0_IO1
 #endif
-#ifdef CONFIG_HISAX_NICCY
-#undef IO0_IO1
-#define IO0_IO1
-#endif
 #ifdef IO0_IO1
 static int io0[HISAX_MAX_CARDS] __devinitdata = { 0, };
 static int io1[HISAX_MAX_CARDS] __devinitdata = { 0, };
@@ -448,10 +437,6 @@ extern int setup_hfcs(struct IsdnCard *card);
 extern int setup_hfcsx(struct IsdnCard *card);
 #endif
 
-#if CARD_NICCY
-extern int setup_niccy(struct IsdnCard *card);
-#endif
-
 #if CARD_ISURF
 extern int setup_isurf(struct IsdnCard *card);
 #endif
@@ -829,11 +814,6 @@ static int __devinit hisax_cs_setup_card(struct IsdnCard *card)
 		ret = setup_hfcsx(card);
 		break;
 #endif
-#if CARD_NICCY
-	case ISDN_CTYPE_NICCY:
-		ret = setup_niccy(card);
-		break;
-#endif
 #if CARD_ISURF
 	case ISDN_CTYPE_ISURF:
 		ret = setup_isurf(card);
@@ -862,6 +842,7 @@ static int __devinit hisax_cs_setup_card(struct IsdnCard *card)
 	case ISDN_CTYPE_TELESPCI:
 	case ISDN_CTYPE_FRITZPCI:
 	case ISDN_CTYPE_GAZEL:
+	case ISDN_CTYPE_NICCY:
 		printk(KERN_WARNING "HiSax: Support for %s Card has moved "
 		       "to separate PCI driver module\n",
 		       CardType[card->typ]);
@@ -1276,7 +1257,6 @@ static int __init HiSax_init(void)
 
 #ifdef IO0_IO1
 		case ISDN_CTYPE_PNP:
-		case ISDN_CTYPE_NICCY:
 			cards[j].para[0] = irq[i];
 			cards[j].para[1] = io0[i];
 			cards[j].para[2] = io1[i];
@@ -1333,6 +1313,7 @@ static int __init HiSax_init(void)
 		case ISDN_CTYPE_TELESPCI:
 		case ISDN_CTYPE_FRITZPCI:
 		case ISDN_CTYPE_GAZEL:
+		case ISDN_CTYPE_NICCY:
 			break;
 
 		case ISDN_CTYPE_SCT_QUADRO:
@@ -1816,9 +1797,6 @@ static struct pci_device_id hisax_pci_tbl[] __devinitdata = {
 #ifdef CONFIG_HISAX_SCT_QUADRO
 	{PCI_VENDOR_ID_PLX,      PCI_DEVICE_ID_PLX_9050,         PCI_ANY_ID, PCI_ANY_ID},
 #endif
-#ifdef CONFIG_HISAX_NICCY
-	{PCI_VENDOR_ID_SATSAGEM, PCI_DEVICE_ID_SATSAGEM_NICCY,   PCI_ANY_ID,PCI_ANY_ID},
-#endif
 #ifdef CONFIG_HISAX_SEDLBAUER
 	{PCI_VENDOR_ID_TIGERJET, PCI_DEVICE_ID_TIGERJET_100,     PCI_ANY_ID,PCI_ANY_ID},
 #endif
diff --git a/drivers/isdn/hisax/niccy.c b/drivers/isdn/hisax/niccy.c
index 421b8e6..ef48515 100644
--- a/drivers/isdn/hisax/niccy.c
+++ b/drivers/isdn/hisax/niccy.c
@@ -15,11 +15,21 @@
 
 #include <linux/init.h>
 #include "hisax.h"
+#include "hisax_proto.h"
 #include "isac.h"
 #include "hscx.h"
 #include "isdnl1.h"
 #include <linux/pci.h>
-#include <linux/isapnp.h>
+#include <linux/pnp.h>
+#include <linux/isa.h>
+
+static int niccy_protocol;		/* 0 == use DEFAULT_PROTO */
+
+#ifdef CONFIG_ISA
+static int niccy_base0;
+static int niccy_base1;
+static int niccy_irq;
+#endif /* CONFIG_ISA */
 
 static const char *niccy_revision = "$Revision: 1.21.2.4 $";
 
@@ -222,142 +232,18 @@ static int niccy_card_msg(struct IsdnCardState *cs, int mt, void *arg)
 	return 0;
 }
 
-#ifdef __ISAPNP__
-static struct pnp_card *pnp_c __devinitdata = NULL;
-#endif
-
-int __devinit setup_niccy(struct IsdnCard *card)
+static int __devinit setup_niccy(struct IsdnCard *card)
 {
 	struct IsdnCardState *cs = card->cs;
 	char tmp[64];
 
 	strcpy(tmp, niccy_revision);
 	printk(KERN_INFO "HiSax: Niccy driver Rev. %s\n", HiSax_getrev(tmp));
-	if (cs->typ != ISDN_CTYPE_NICCY)
-		return 0;
-#ifdef __ISAPNP__
-	if (!card->para[1] && isapnp_present()) {
-		struct pnp_dev *pnp_d = NULL;
-		int err;
-
-		pnp_c = pnp_find_card(ISAPNP_VENDOR('S', 'D', 'A'),
-				ISAPNP_FUNCTION(0x0150), pnp_c);
-		if (pnp_c) {
-			pnp_d = pnp_find_dev(pnp_c,
-					ISAPNP_VENDOR('S', 'D', 'A'),
-					ISAPNP_FUNCTION(0x0150), pnp_d);
-			if (!pnp_d) {
-				printk(KERN_ERR "NiccyPnP: PnP error card "
-					"found, no device\n");
-				return 0;
-			}
-			pnp_disable_dev(pnp_d);
-			err = pnp_activate_dev(pnp_d);
-			if (err < 0) {
-				printk(KERN_WARNING "%s: pnp_activate_dev "
-					"ret(%d)\n", __FUNCTION__, err);
-				return 0;
-			}
-			card->para[1] = pnp_port_start(pnp_d, 0);
-			card->para[2] = pnp_port_start(pnp_d, 1);
-			card->para[0] = pnp_irq(pnp_d, 0);
-			if (!card->para[0] || !card->para[1] ||
-					!card->para[2]) {
-				printk(KERN_ERR "NiccyPnP:some resources are "
-					"missing %ld/%lx/%lx\n",
-					card->para[0], card->para[1],
-					card->para[2]);
-				pnp_disable_dev(pnp_d);
-				return 0;
-			}
-		} else
-			printk(KERN_INFO "NiccyPnP: no ISAPnP card found\n");
-	}
-#endif
-	if (card->para[1]) {
-		cs->hw.niccy.isac = card->para[1] + ISAC_PNP;
-		cs->hw.niccy.hscx = card->para[1] + HSCX_PNP;
-		cs->hw.niccy.isac_ale = card->para[2] + ISAC_PNP;
-		cs->hw.niccy.hscx_ale = card->para[2] + HSCX_PNP;
-		cs->hw.niccy.cfg_reg = 0;
-		cs->subtyp = NICCY_PNP;
-		cs->irq = card->para[0];
-		if (!request_region(cs->hw.niccy.isac, 2, "niccy data")) {
-			printk(KERN_WARNING "HiSax: NICCY data port %x-%x "
-				"already in use\n",
-				cs->hw.niccy.isac, cs->hw.niccy.isac + 1);
-			return 0;
-		}
-		if (!request_region(cs->hw.niccy.isac_ale, 2, "niccy addr")) {
-			printk(KERN_WARNING "HiSax: NICCY address port %x-%x "
-				"already in use\n",
-				cs->hw.niccy.isac_ale,
-				cs->hw.niccy.isac_ale + 1);
-			release_region(cs->hw.niccy.isac, 2);
-			return 0;
-		}
-	} else {
-#ifdef CONFIG_PCI_LEGACY
-		static struct pci_dev *niccy_dev __devinitdata;
-
-		u_int pci_ioaddr;
-		cs->subtyp = 0;
-		if ((niccy_dev = pci_find_device(PCI_VENDOR_ID_SATSAGEM,
-						 PCI_DEVICE_ID_SATSAGEM_NICCY,
-						 niccy_dev))) {
-			if (pci_enable_device(niccy_dev))
-				return 0;
-			/* get IRQ */
-			if (!niccy_dev->irq) {
-				printk(KERN_WARNING
-				       "Niccy: No IRQ for PCI card found\n");
-				return 0;
-			}
-			cs->irq = niccy_dev->irq;
-			cs->hw.niccy.cfg_reg = pci_resource_start(niccy_dev, 0);
-			if (!cs->hw.niccy.cfg_reg) {
-				printk(KERN_WARNING
-				       "Niccy: No IO-Adr for PCI cfg found\n");
-				return 0;
-			}
-			pci_ioaddr = pci_resource_start(niccy_dev, 1);
-			if (!pci_ioaddr) {
-				printk(KERN_WARNING
-				       "Niccy: No IO-Adr for PCI card found\n");
-				return 0;
-			}
-			cs->subtyp = NICCY_PCI;
-		} else {
-			printk(KERN_WARNING "Niccy: No PCI card found\n");
-			return 0;
-		}
-		cs->irq_flags |= IRQF_SHARED;
-		cs->hw.niccy.isac = pci_ioaddr + ISAC_PCI_DATA;
-		cs->hw.niccy.isac_ale = pci_ioaddr + ISAC_PCI_ADDR;
-		cs->hw.niccy.hscx = pci_ioaddr + HSCX_PCI_DATA;
-		cs->hw.niccy.hscx_ale = pci_ioaddr + HSCX_PCI_ADDR;
-		if (!request_region(cs->hw.niccy.isac, 4, "niccy")) {
-			printk(KERN_WARNING
-			       "HiSax: NICCY data port %x-%x already in use\n",
-			       cs->hw.niccy.isac, cs->hw.niccy.isac + 4);
-			return 0;
-		}
-		if (!request_region(cs->hw.niccy.cfg_reg, 0x40, "niccy pci")) {
-			printk(KERN_WARNING
-			       "HiSax: NICCY pci port %x-%x already in use\n",
-			       cs->hw.niccy.cfg_reg,
-			       cs->hw.niccy.cfg_reg + 0x40);
-			release_region(cs->hw.niccy.isac, 4);
-			return 0;
-		}
-#else
-		printk(KERN_WARNING "Niccy: io0 0 and NO_PCI_BIOS\n");
-		printk(KERN_WARNING "Niccy: unable to config NICCY PCI\n");
-		return 0;
-#endif				/* CONFIG_PCI_LEGACY */
-	}
-	printk(KERN_INFO "HiSax: NICCY %s config irq:%d data:0x%X ale:0x%X\n",
-		(cs->subtyp == 1) ? "PnP" : "PCI",
+
+	WARN_ON(cs->typ != ISDN_CTYPE_NICCY);
+
+	printk(KERN_INFO "HiSax: %s %s config irq:%d data:0x%X ale:0x%X\n",
+		"niccy", (cs->subtyp == 1) ? "PnP" : "PCI",
 		cs->irq, cs->hw.niccy.isac, cs->hw.niccy.isac_ale);
 	setup_isac(cs);
 	cs->readisac = &ReadISAC;
@@ -378,3 +264,315 @@ int __devinit setup_niccy(struct IsdnCard *card)
 	}
 	return 1;
 }
+
+#ifdef CONFIG_ISA
+
+static int __devinit niccy_isa_setup(struct IsdnCard *card)
+{
+	struct IsdnCardState *cs = card->cs;
+
+	cs->hw.niccy.isac = card->para[1] + ISAC_PNP;
+	cs->hw.niccy.hscx = card->para[1] + HSCX_PNP;
+	cs->hw.niccy.isac_ale = card->para[2] + ISAC_PNP;
+	cs->hw.niccy.hscx_ale = card->para[2] + HSCX_PNP;
+	cs->hw.niccy.cfg_reg = 0;
+	cs->subtyp = NICCY_PNP;
+	cs->irq = card->para[0];
+	if (!request_region(cs->hw.niccy.isac, 2, "niccy data")) {
+		printk(KERN_WARNING "HiSax: %s data port %x-%x "
+			"already in use\n", "niccy",
+			cs->hw.niccy.isac, cs->hw.niccy.isac + 1);
+		return 0;
+	}
+	if (!request_region(cs->hw.niccy.isac_ale, 2, "niccy addr")) {
+		printk(KERN_WARNING "HiSax: %s address port %x-%x "
+			"already in use\n", "niccy",
+			cs->hw.niccy.isac_ale,
+			cs->hw.niccy.isac_ale + 1);
+		release_region(cs->hw.niccy.isac, 2);
+		return 0;
+	}
+
+	return setup_niccy(card);
+}
+
+static int __devinit niccy_isa_init_one(struct device *dev, unsigned int id)
+{
+	struct IsdnCard icard = { ISDN_CTYPE_NICCY, };
+	int cardnr;
+
+	icard.para[0] = niccy_irq;
+	icard.para[1] = niccy_base0;
+	icard.para[2] = niccy_base1;
+	if (!niccy_protocol)
+		icard.protocol = DEFAULT_PROTO;
+	else
+		icard.protocol = niccy_protocol;
+
+	cardnr = hisax_init_hotplug(&icard, niccy_isa_setup);
+	if (cardnr < 0)
+		return -ENODEV;
+
+	dev_set_drvdata(dev, (void *)(unsigned long) cardnr);
+	return 0;
+}
+
+static int __devexit niccy_isa_remove_one(struct device *dev, unsigned int id)
+{
+	int cardnr = (unsigned long) dev_get_drvdata(dev);
+
+	HiSax_closecard(cardnr);
+	return 0;
+}
+
+static struct isa_driver niccy_isa_driver = {
+	.probe		= niccy_isa_init_one,
+	.remove		= __devexit_p(niccy_isa_remove_one),
+	.driver = {
+		.owner	= THIS_MODULE,
+		.name	= "niccy_pci",
+	},
+};
+
+#ifdef CONFIG_PNP
+
+static int __devinit niccy_pnp_setup(struct IsdnCard *card)
+{
+	struct pnp_dev *pnp_d = (void *) card->para[0];
+	int err;
+
+	pnp_disable_dev(pnp_d);
+	err = pnp_activate_dev(pnp_d);
+	if (err < 0) {
+		printk(KERN_WARNING "%s: pnp_activate_dev "
+			"ret(%d)\n", __func__, err);
+		return 0;
+	}
+	card->para[1] = pnp_port_start(pnp_d, 0);
+	card->para[2] = pnp_port_start(pnp_d, 1);
+	card->para[0] = pnp_irq(pnp_d, 0);
+	if (!card->para[0] || !card->para[1] ||
+			!card->para[2]) {
+		printk(KERN_ERR "NiccyPnP:some resources are "
+			"missing %ld/%lx/%lx\n",
+			card->para[0], card->para[1],
+			card->para[2]);
+		pnp_disable_dev(pnp_d);
+		return 0;
+	}
+
+	return niccy_isa_setup(card);
+}
+
+static int __devinit niccy_pnp_init_one(struct pnp_dev *pdev,
+				       const struct pnp_device_id *dev_id)
+{
+	struct IsdnCard icard = { ISDN_CTYPE_NICCY, };
+	int cardnr;
+
+	icard.para[0] = (unsigned long) pdev;
+	if (!niccy_protocol)
+		icard.protocol = DEFAULT_PROTO;
+	else
+		icard.protocol = niccy_protocol;
+
+	cardnr = hisax_init_hotplug(&icard, niccy_pnp_setup);
+	if (cardnr < 0)
+		return -ENODEV;
+
+	pnp_set_drvdata(pdev, (void *)(unsigned long) cardnr);
+	return 0;
+}
+
+static void __devexit niccy_pnp_remove_one(struct pnp_dev *pdev)
+{
+	int cardnr = (unsigned long) pnp_get_drvdata(pdev);
+
+	HiSax_closecard(cardnr);
+}
+
+static struct pnp_device_id niccy_pnp_table[] = {
+	{ .id = "SDA0150", },
+
+	{ .id = "" }		/* terminate list */
+};
+
+static struct pnp_driver niccy_pnp_driver = {
+	.name		= "niccy",
+	.id_table	= niccy_pnp_table,
+	.probe		= niccy_pnp_init_one,
+	.remove		= __devexit_p(niccy_pnp_remove_one),
+};
+#endif /* CONFIG_PNP */
+#endif /* CONFIG_ISA */
+
+#ifdef CONFIG_PCI
+
+static int __devinit niccy_pci_setup(struct IsdnCard *card)
+{
+	u_int pci_ioaddr;
+	struct pci_dev *niccy_dev = (void *) card->para[0];
+	struct IsdnCardState *cs = card->cs;
+
+	cs->subtyp = 0;
+	if (pci_enable_device(niccy_dev))
+		return 0;
+	/* get IRQ */
+	if (!niccy_dev->irq) {
+		printk(KERN_WARNING
+		       "Niccy: No IRQ for PCI card found\n");
+		return 0;
+	}
+	cs->irq = niccy_dev->irq;
+	cs->hw.niccy.cfg_reg = pci_resource_start(niccy_dev, 0);
+	if (!cs->hw.niccy.cfg_reg) {
+		printk(KERN_WARNING
+		       "Niccy: No IO-Adr for PCI cfg found\n");
+		return 0;
+	}
+	pci_ioaddr = pci_resource_start(niccy_dev, 1);
+	if (!pci_ioaddr) {
+		printk(KERN_WARNING
+		       "Niccy: No IO-Adr for PCI card found\n");
+		return 0;
+	}
+	cs->subtyp = NICCY_PCI;
+	cs->irq_flags |= IRQF_SHARED;
+	cs->hw.niccy.isac = pci_ioaddr + ISAC_PCI_DATA;
+	cs->hw.niccy.isac_ale = pci_ioaddr + ISAC_PCI_ADDR;
+	cs->hw.niccy.hscx = pci_ioaddr + HSCX_PCI_DATA;
+	cs->hw.niccy.hscx_ale = pci_ioaddr + HSCX_PCI_ADDR;
+	if (!request_region(cs->hw.niccy.isac, 4, "niccy")) {
+		printk(KERN_WARNING
+		       "HiSax: %s data port %x-%x already in use\n",
+		       "niccy",
+		       cs->hw.niccy.isac, cs->hw.niccy.isac + 4);
+		return 0;
+	}
+	if (!request_region(cs->hw.niccy.cfg_reg, 0x40, "niccy pci")) {
+		printk(KERN_WARNING
+		       "HiSax: %s pci port %x-%x already in use\n",
+		       "niccy",
+		       cs->hw.niccy.cfg_reg,
+		       cs->hw.niccy.cfg_reg + 0x40);
+		release_region(cs->hw.niccy.isac, 4);
+		return 0;
+	}
+
+	return setup_niccy(card);
+}
+
+static int __devinit niccy_pci_init_one(struct pci_dev *pdev,
+				      const struct pci_device_id *ent)
+{
+	struct IsdnCard icard = { ISDN_CTYPE_NICCY, };
+	int cardnr;
+
+	icard.para[0] = (unsigned long) pdev;
+	if (!niccy_protocol)
+		icard.protocol = DEFAULT_PROTO;
+	else
+		icard.protocol = niccy_protocol;
+
+	cardnr = hisax_init_hotplug(&icard, niccy_pci_setup);
+	if (cardnr < 0)
+		return -ENODEV;
+
+	pci_set_drvdata(pdev, (void *)(unsigned long) cardnr);
+	return 0;
+}
+
+static struct pci_device_id niccy_pci_table[] = {
+	{ PCI_VDEVICE(SATSAGEM, PCI_DEVICE_ID_SATSAGEM_NICCY) },
+
+	{ }		/* terminate list */
+};
+
+static struct pci_driver niccy_pci_driver = {
+	.name		= "niccy",
+	.id_table	= niccy_pci_table,
+	.probe		= niccy_pci_init_one,
+	.remove		= hisax_pci_remove_one,
+};
+
+#endif /* CONFIG_PCI */
+
+static int __init niccy_mod_init(void)
+{
+	int rc = 0;
+
+#ifdef CONFIG_ISA
+	if (niccy_irq && niccy_base0 && niccy_base1) {
+		rc = isa_register_driver(&niccy_isa_driver, 1);
+		if (rc)
+			return rc;
+	}
+#ifdef CONFIG_PNP
+	else {
+		rc = pnp_register_driver(&niccy_pnp_driver);
+		if (rc)
+			return rc;
+	}
+#endif
+#endif /* CONFIG_ISA */
+
+#ifdef CONFIG_PCI
+	rc = pci_register_driver(&niccy_pci_driver);
+	if (rc)
+		goto err_out_isa;
+#endif /* CONFIG_PCI */
+
+	return 0;
+
+#ifdef CONFIG_PCI
+err_out_isa:
+
+#ifdef CONFIG_ISA
+	if (niccy_irq && niccy_base0 && niccy_base1)
+		isa_unregister_driver(&niccy_isa_driver);
+#ifdef CONFIG_PNP
+	else
+		pnp_unregister_driver(&niccy_pnp_driver);
+#endif /* CONFIG_PNP */
+#endif /* CONFIG_ISA */
+
+	return rc;
+#endif /* CONFIG_PCI */
+}
+
+static void __exit niccy_mod_exit(void)
+{
+#ifdef CONFIG_PCI
+	pci_unregister_driver(&niccy_pci_driver);
+#endif /* CONFIG_PCI */
+
+#ifdef CONFIG_ISA
+	if (niccy_irq && niccy_base0 && niccy_base1)
+		isa_unregister_driver(&niccy_isa_driver);
+#ifdef CONFIG_PNP
+	else
+		pnp_unregister_driver(&niccy_pnp_driver);
+#endif /* CONFIG_PNP */
+#endif /* CONFIG_ISA */
+}
+
+module_init(niccy_mod_init);
+module_exit(niccy_mod_exit);
+
+#ifdef CONFIG_ISA
+module_param_named(irq, niccy_irq, int, 0444);
+MODULE_PARM_DESC(irq, "ISA IRQ.  Zero disables ISA support (default).");
+
+module_param_named(base0, niccy_base0, int, 0444);
+MODULE_PARM_DESC(base0, "ISA I/O base #0.  Zero disables ISA support (default).");
+
+module_param_named(base1, niccy_base1, int, 0444);
+MODULE_PARM_DESC(base1, "ISA I/O base #1.  Zero disables ISA support (default).");
+#endif /* CONFIG_ISA */
+
+module_param_named(protocol, niccy_protocol, int, 0444);
+MODULE_PARM_DESC(protocol, "Values 0 (default) through 4. See ISDN_PTYPE_xxx in linux/isdnif.h");
+
+MODULE_DEVICE_TABLE(pci, niccy_pci_table);
+MODULE_DESCRIPTION("ISDN HiSax Niccy PCI/PNP driver");
+MODULE_LICENSE("GPL");
-- 
1.5.3.8


^ permalink raw reply	[flat|nested] 28+ messages in thread

end of thread, other threads:[~2008-02-16 20:33 UTC | newest]

Thread overview: 28+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2007-07-18  3:04 [PATCH 00/14] [ISDN] HiSax hotplug conversion Jeff Garzik
2007-07-18  3:04 ` [PATCH 01/14] [ISDN] HiSax: modularize card setup Jeff Garzik
2008-02-15 13:38   ` Sam Ravnborg
2007-07-18  3:46 ` [PATCH 04/14] [ISDN] HiSax bkm_a4t: convert to PCI hotplug API Jeff Garzik
2008-02-15 13:33   ` Sam Ravnborg
2007-07-18  3:49 ` [PATCH 05/14] [ISDN] HiSax enternow: " Jeff Garzik
2008-02-15 13:21   ` Jan Engelhardt
2007-07-18  3:54 ` [PATCH 06/14] [ISDN] HiSax hfc_pci, w6692: " Jeff Garzik
2007-07-18  3:59 ` [PATCH 07/14] [ISDN] HiSax nj_s, nj_u: " Jeff Garzik
2007-07-18  4:02 ` [PATCH 08/14] [ISDN] HiSax telespci: " Jeff Garzik
2007-07-24 12:26 ` [PATCH 11/14] [ISDN] HiSax niccy: convert to modern ISA/PNP/PCI probing Jeff Garzik
2007-08-02 12:37 ` [PATCH 13/14] [ISDN] HiSax bkm_a8: convert to PCI hotplug API Jeff Garzik
2007-10-31  5:10 ` [PATCH 03/14] [ISDN] Ready HiSax driver for modularization Jeff Garzik
2008-02-15 13:45   ` Sam Ravnborg
2007-10-31  5:11 ` [PATCH 09/14] [ISDN] HiSax avm_pci: convert to modern PCI/ISA/PNP probing Jeff Garzik
2007-10-31  5:12 ` [PATCH 10/14] [ISDN] HiSax gazel: convert to modern ISA/PCI probing Jeff Garzik
2007-10-31  5:13 ` [PATCH 12/14] [ISDN] HiSax diva: convert to modern ISA/PNP/PCI probing Jeff Garzik
2007-10-31  7:42 ` [PATCH 02/14] [ISDN] Hisax: eliminate many unnecessary references to CardType[] Jeff Garzik
2008-02-15 13:37   ` Sam Ravnborg
2007-11-06 14:41 ` [PATCH 14/14] [isdn-pci] add missing file Jeff Garzik
2008-02-14 23:52 ` [PATCH 00/14] [ISDN] HiSax hotplug conversion Greg KH
2008-02-14 23:50   ` Jeff Garzik
2008-02-14 23:53 ` Jeff Garzik
2008-02-15 13:27 ` Sam Ravnborg
2008-02-15 15:13   ` Jeff Garzik
2008-02-15 19:11     ` Sam Ravnborg
2008-02-16  1:09 ` Andrew Morton
2008-02-16  4:41 [PATCH 01/14] [ISDN] HiSax: modularization prep Jeff Garzik
2007-07-24 12:26 ` [PATCH 11/14] [ISDN] HiSax niccy: convert to modern ISA/PNP/PCI probing Jeff Garzik

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).