Subject: Re: pcmcia modem problem on -current
To: None <tech-kern@netbsd.org>
From: Christos Zoulas <christos@tac.gw.com>
List: tech-kern
Date: 06/03/2005 01:50:41
In article <20050602213926.GA163@bsd.makhraj.bsd>,
Ja'far Railton <zen25058@zen.co.uk> wrote:
>On Thu, Jun 02, 2005 at 10:30:55PM +0300, Christos Zoulas wrote:
>> 
>> Where are the compiler errors?
>
>Sorry, here:
>

Try this patch:

Index: pccbb.c
===================================================================
RCS file: /cvsroot/src/sys/dev/pci/pccbb.c,v
retrieving revision 1.96.2.2
diff -u -u -r1.96.2.2 pccbb.c
--- pccbb.c	28 Jul 2004 21:33:34 -0000	1.96.2.2
+++ pccbb.c	2 Jun 2005 22:50:09 -0000
@@ -100,16 +100,16 @@
 #define DELAY_MS(time, param)						\
     do {								\
 	if (cold == 0) {						\
-	    int tick = (hz*(time))/1000;				\
+	    int xtick = (hz*(time))/1000;				\
 									\
-	    if (tick <= 1) {						\
-		tick = 2;						\
+	    if (xtick <= 1) {						\
+		xtick = 2;						\
 	    }								\
-	    tsleep((void *)(param), PWAIT, "pccbb", tick);		\
+	    tsleep((void *)(param), PWAIT, "pccbb", xtick);		\
 	} else {							\
 	    delay((time)*1000);						\
 	}								\
-    } while (0)
+    } while (/*CONSTCOND*/0)
 
 int pcicbbmatch __P((struct device *, struct cfdata *, void *));
 void pccbbattach __P((struct device *, struct device *, void *));
@@ -184,6 +184,7 @@
     void *));
 STATIC void pccbb_pcmcia_socket_enable __P((pcmcia_chipset_handle_t));
 STATIC void pccbb_pcmcia_socket_disable __P((pcmcia_chipset_handle_t));
+STATIC void pccbb_pcmcia_socket_settype(pcmcia_chipset_handle_t, int);
 STATIC int pccbb_pcmcia_card_detect __P((pcmcia_chipset_handle_t pch));
 
 static void pccbb_pcmcia_do_io_map __P((struct pcic_handle *, int));
@@ -242,6 +243,7 @@
 	pccbb_pcmcia_intr_disestablish,
 	pccbb_pcmcia_socket_enable,
 	pccbb_pcmcia_socket_disable,
+	pccbb_pcmcia_socket_settype,
 	pccbb_pcmcia_card_detect
 };
 
@@ -437,7 +439,7 @@
 
 	sc->sc_chipset = cb_chipset(pa->pa_id, &flags);
 
-	pci_devinfo(pa->pa_id, 0, 0, devinfo);
+	pci_devinfo(pa->pa_id, 0, 0, devinfo, sizeof(devinfo));
 	printf(": %s (rev. 0x%02x)", devinfo, PCI_REVISION(pa->pa_class));
 #ifdef CBB_DEBUG
 	printf(" (chipflags %x)", flags);
@@ -1414,6 +1416,29 @@
 	return 1;		       /* power changed correctly */
 }
 
+STATIC void
+pccbb_pcmcia_socket_settype(pch, type)
+	pcmcia_chipset_handle_t pch;
+	int type;
+{
+	struct pcic_handle *ph = (struct pcic_handle *)pch;
+	u_int8_t intr;
+
+	/* set the card type */
+
+	intr = Pcic_read(ph, PCIC_INTR);
+	intr &= ~(PCIC_INTR_IRQ_MASK | PCIC_INTR_CARDTYPE_MASK);
+	if (type == PCMCIA_IFTYPE_IO)
+		intr |= PCIC_INTR_CARDTYPE_IO;
+	else
+		intr |= PCIC_INTR_CARDTYPE_MEM;
+	Pcic_write(ph, PCIC_INTR, intr);
+
+	DPRINTF(("%s: pccbb_pcmcia_socket_settype %02x type %s %02x\n",
+	    ph->ph_parent->dv_xname, ph->sock,
+	    ((type == PCMCIA_IFTYPE_IO) ? "io" : "mem"), intr));
+}
+
 #if defined CB_PCMCIA_POLL
 struct cb_poll_str {
 	void *arg;
@@ -2403,7 +2428,7 @@
 {
 	struct pcic_handle *ph = (struct pcic_handle *)pch;
 	struct pccbb_softc *sc = (struct pccbb_softc *)ph->ph_parent;
-	int cardtype, win;
+	int win;
 	u_int8_t power, intr;
 	pcireg_t spsr;
 	int voltage;
@@ -2497,22 +2522,6 @@
 		return;
 	}
 
-	/* zero out the address windows */
-
-	Pcic_write(ph, PCIC_ADDRWIN_ENABLE, 0);
-
-	/* set the card type */
-
-	cardtype = pcmcia_card_gettype(ph->pcmcia);
-
-	intr |= ((cardtype == PCMCIA_IFTYPE_IO) ?
-	    PCIC_INTR_CARDTYPE_IO : PCIC_INTR_CARDTYPE_MEM);
-	Pcic_write(ph, PCIC_INTR, intr);
-
-	DPRINTF(("%s: pccbb_pcmcia_socket_enable %02x cardtype %s %02x\n",
-	    ph->ph_parent->dv_xname, ph->sock,
-	    ((cardtype == PCMCIA_IFTYPE_IO) ? "io" : "mem"), intr));
-
 	/* reinstall all the memory and io mappings */
 
 	for (win = 0; win < PCIC_MEM_WINS; ++win) {