Module Name:    src
Committed By:   dyoung
Date:           Fri Nov 13 01:14:35 UTC 2009

Modified Files:
        src/sys/dev/pcmcia: if_xi.c mhzc.c xirc.c

Log Message:
Don't use com_activate(), it's gone away.  Thanks to Andreas Wrede
for pointing out that these drivers still used com_activate().

Use device_private().  Join some lines.

Remove superfluous activation hooks.

Add child-detachment hooks (not used, yet).

TBD: device_t/softc split.


To generate a diff of this commit:
cvs rdiff -u -r1.67 -r1.68 src/sys/dev/pcmcia/if_xi.c
cvs rdiff -u -r1.46 -r1.47 src/sys/dev/pcmcia/mhzc.c
cvs rdiff -u -r1.29 -r1.30 src/sys/dev/pcmcia/xirc.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/dev/pcmcia/if_xi.c
diff -u src/sys/dev/pcmcia/if_xi.c:1.67 src/sys/dev/pcmcia/if_xi.c:1.68
--- src/sys/dev/pcmcia/if_xi.c:1.67	Tue May 12 14:42:18 2009
+++ src/sys/dev/pcmcia/if_xi.c	Fri Nov 13 01:14:35 2009
@@ -1,4 +1,4 @@
-/*	$NetBSD: if_xi.c,v 1.67 2009/05/12 14:42:18 cegger Exp $ */
+/*	$NetBSD: if_xi.c,v 1.68 2009/11/13 01:14:35 dyoung Exp $ */
 /*	OpenBSD: if_xe.c,v 1.9 1999/09/16 11:28:42 niklas Exp 	*/
 
 /*
@@ -55,7 +55,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: if_xi.c,v 1.67 2009/05/12 14:42:18 cegger Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_xi.c,v 1.68 2009/11/13 01:14:35 dyoung Exp $");
 
 #include "opt_inet.h"
 #include "opt_ipx.h"
@@ -259,7 +259,7 @@
 int
 xi_detach(device_t self, int flags)
 {
-	struct xi_softc *sc = (void *)self;
+	struct xi_softc *sc = device_private(self);
 	struct ifnet *ifp = &sc->sc_ethercom.ec_if;
 
 	DPRINTF(XID_CONFIG, ("xi_detach()\n"));
@@ -279,28 +279,6 @@
 }
 
 int
-xi_activate(device_t self, enum devact act)
-{
-	struct xi_softc *sc = (void *)self;
-	int s, rv = 0;
-
-	DPRINTF(XID_CONFIG, ("xi_activate()\n"));
-
-	s = splnet();
-	switch (act) {
-	case DVACT_ACTIVATE:
-		rv = EOPNOTSUPP;
-		break;
-
-	case DVACT_DEACTIVATE:
-		if_deactivate(&sc->sc_ethercom.ec_if);
-		break;
-	}
-	splx(s);
-	return (rv);
-}
-
-int
 xi_intr(void *arg)
 {
 	struct xi_softc *sc = arg;
@@ -597,7 +575,7 @@
 STATIC int
 xi_mdi_read(device_t self, int phy, int reg)
 {
-	struct xi_softc *sc = (struct xi_softc *)self;
+	struct xi_softc *sc = device_private(self);
 	int i;
 	u_int32_t mask;
 	u_int32_t data = 0;
@@ -627,7 +605,7 @@
 STATIC void
 xi_mdi_write(device_t self, int phy, int reg, int value)
 {
-	struct xi_softc *sc = (struct xi_softc *)self;
+	struct xi_softc *sc = device_private(self);
 	int i;
 
 	PAGE(sc, 2);

Index: src/sys/dev/pcmcia/mhzc.c
diff -u src/sys/dev/pcmcia/mhzc.c:1.46 src/sys/dev/pcmcia/mhzc.c:1.47
--- src/sys/dev/pcmcia/mhzc.c:1.46	Tue May 12 14:42:19 2009
+++ src/sys/dev/pcmcia/mhzc.c	Fri Nov 13 01:14:35 2009
@@ -1,4 +1,4 @@
-/*	$NetBSD: mhzc.c,v 1.46 2009/05/12 14:42:19 cegger Exp $	*/
+/*	$NetBSD: mhzc.c,v 1.47 2009/11/13 01:14:35 dyoung Exp $	*/
 
 /*-
  * Copyright (c) 1999, 2000, 2004 The NetBSD Foundation, Inc.
@@ -39,7 +39,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: mhzc.c,v 1.46 2009/05/12 14:42:19 cegger Exp $");
+__KERNEL_RCSID(0, "$NetBSD: mhzc.c,v 1.47 2009/11/13 01:14:35 dyoung Exp $");
 
 #include "opt_inet.h"
 #include "bpfilter.h"
@@ -129,11 +129,11 @@
 
 int	mhzc_match(device_t, cfdata_t, void *);
 void	mhzc_attach(device_t, device_t, void *);
+void	mhzc_childdet(device_t, device_t);
 int	mhzc_detach(device_t, int);
-int	mhzc_activate(device_t, enum devact);
 
 CFATTACH_DECL(mhzc, sizeof(struct mhzc_softc),
-    mhzc_match, mhzc_attach, mhzc_detach, mhzc_activate);
+    mhzc_match, mhzc_attach, mhzc_detach, NULL);
 
 int	mhzc_em3336_enaddr(struct mhzc_softc *, u_int8_t *);
 int	mhzc_em3336_enable(struct mhzc_softc *);
@@ -165,8 +165,7 @@
 int	mhzc_intr(void *);
 
 int
-mhzc_match(device_t parent, cfdata_t match,
-    void *aux)
+mhzc_match(device_t parent, cfdata_t match, void *aux)
 {
 	struct pcmcia_attach_args *pa = aux;
 
@@ -179,7 +178,7 @@
 void
 mhzc_attach(device_t parent, device_t self, void *aux)
 {
-	struct mhzc_softc *sc = (void *)self;
+	struct mhzc_softc *sc = device_private(self);
 	struct pcmcia_attach_args *pa = aux;
 	struct pcmcia_config_entry *cfe;
 	int error;
@@ -323,24 +322,31 @@
 	return (UNCONF);
 }
 
+void
+mhzc_childdet(device_t self, device_t child)
+{
+	struct mhzc_softc *sc = device_private(self);
+
+	if (sc->sc_ethernet == child)
+		sc->sc_ethernet = NULL;
+	if (sc->sc_modem == child)
+		sc->sc_modem = NULL;
+}
+
 int
 mhzc_detach(device_t self, int flags)
 {
-	struct mhzc_softc *sc = (void *)self;
+	struct mhzc_softc *sc = device_private(self);
 	int rv;
 
 	if (sc->sc_ethernet != NULL) {
-		rv = config_detach(sc->sc_ethernet, flags);
-		if (rv != 0)
-			return (rv);
-		sc->sc_ethernet = NULL;
+		if ((rv = config_detach(sc->sc_ethernet, flags)) != 0)
+			return rv;
 	}
 
 	if (sc->sc_modem != NULL) {
-		rv = config_detach(sc->sc_modem, flags);
-		if (rv != 0)
-			return (rv);
-		sc->sc_modem = NULL;
+		if ((rv = config_detach(sc->sc_modem, flags)) != 0)
+			return rv;
 	}
 
 	/* Unmap our i/o windows. */
@@ -357,38 +363,7 @@
 
 	sc->sc_flags = 0;
 
-	return (0);
-}
-
-int
-mhzc_activate(device_t self, enum devact act)
-{
-	struct mhzc_softc *sc = (void *)self;
-	int s, rv = 0;
-
-	s = splhigh();
-	switch (act) {
-	case DVACT_ACTIVATE:
-		rv = EOPNOTSUPP;
-		break;
-
-	case DVACT_DEACTIVATE:
-		if (sc->sc_ethernet != NULL) {
-			rv = config_deactivate(sc->sc_ethernet);
-			if (rv != 0)
-				goto out;
-		}
-
-		if (sc->sc_modem != NULL) {
-			rv = config_deactivate(sc->sc_modem);
-			if (rv != 0)
-				goto out;
-		}
-		break;
-	}
- out:
-	splx(s);
-	return (rv);
+	return 0;
 }
 
 int
@@ -622,7 +597,7 @@
 
 /* No mhzc-specific goo in the softc; it's all in the parent. */
 CFATTACH_DECL_NEW(com_mhzc, sizeof(struct com_softc),
-    com_mhzc_match, com_mhzc_attach, com_detach, com_activate);
+    com_mhzc_match, com_mhzc_attach, com_detach, NULL);
 
 int	com_mhzc_enable(struct com_softc *);
 void	com_mhzc_disable(struct com_softc *);
@@ -700,8 +675,7 @@
 void	sm_mhzc_disable(struct smc91cxx_softc *);
 
 int
-sm_mhzc_match(device_t parent, cfdata_t match,
-    void *aux)
+sm_mhzc_match(device_t parent, cfdata_t match, void *aux)
 {
 	extern struct cfdriver sm_cd;
 	const char *name = aux;
@@ -716,8 +690,8 @@
 void
 sm_mhzc_attach(device_t parent, device_t self, void *aux)
 {
-	struct smc91cxx_softc *sc = (void *)self;
-	struct mhzc_softc *msc = (void *)parent;
+	struct smc91cxx_softc *sc = device_private(self);
+	struct mhzc_softc *msc = device_private(parent);
 	u_int8_t myla[ETHER_ADDR_LEN];
 
 	aprint_normal("\n");
@@ -738,17 +712,17 @@
 int
 sm_mhzc_enable(struct smc91cxx_softc *sc)
 {
+	struct mhzc_softc *xsc = device_private(device_parent(&sc->sc_dev));
 
-	return (mhzc_enable((struct mhzc_softc *)device_parent(&sc->sc_dev),
-	    MHZC_ETHERNET_ENABLED));
+	return mhzc_enable(xsc, MHZC_ETHERNET_ENABLED);
 }
 
 void
 sm_mhzc_disable(struct smc91cxx_softc *sc)
 {
+	struct mhzc_softc *xsc = device_private(device_parent(&sc->sc_dev));
 
-	mhzc_disable((struct mhzc_softc *)device_parent(&sc->sc_dev),
-	    MHZC_ETHERNET_ENABLED);
+	mhzc_disable(xsc, MHZC_ETHERNET_ENABLED);
 }
 
 #endif /* NSM_MHZC > 0 */

Index: src/sys/dev/pcmcia/xirc.c
diff -u src/sys/dev/pcmcia/xirc.c:1.29 src/sys/dev/pcmcia/xirc.c:1.30
--- src/sys/dev/pcmcia/xirc.c:1.29	Tue May 12 14:42:19 2009
+++ src/sys/dev/pcmcia/xirc.c	Fri Nov 13 01:14:35 2009
@@ -1,4 +1,4 @@
-/*	$NetBSD: xirc.c,v 1.29 2009/05/12 14:42:19 cegger Exp $	*/
+/*	$NetBSD: xirc.c,v 1.30 2009/11/13 01:14:35 dyoung Exp $	*/
 
 /*-
  * Copyright (c) 1999, 2000, 2004 The NetBSD Foundation, Inc.
@@ -31,7 +31,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: xirc.c,v 1.29 2009/05/12 14:42:19 cegger Exp $");
+__KERNEL_RCSID(0, "$NetBSD: xirc.c,v 1.30 2009/11/13 01:14:35 dyoung Exp $");
 
 #include "opt_inet.h"
 #include "bpfilter.h"
@@ -124,10 +124,10 @@
 int	xirc_match(device_t, cfdata_t, void *);
 void	xirc_attach(device_t, device_t, void *);
 int	xirc_detach(device_t, int);
-int	xirc_activate(device_t, enum devact);
+void	xirc_childdet(device_t, device_t);
 
 CFATTACH_DECL(xirc, sizeof(struct xirc_softc),
-    xirc_match, xirc_attach, xirc_detach, xirc_activate);
+    xirc_match, xirc_attach, xirc_detach, NULL);
 
 int	xirc_print(void *, const char *);
 
@@ -170,7 +170,7 @@
 void
 xirc_attach(device_t parent, device_t self, void *aux)
 {
-	struct xirc_softc *sc = (void *)self;
+	struct xirc_softc *sc = device_private(self);
 	struct pcmcia_attach_args *pa = aux;
 	struct pcmcia_config_entry *cfe;
 	int rv;
@@ -383,24 +383,32 @@
 	return (UNCONF);
 }
 
+void
+xirc_childdet(device_t self, device_t child)
+{
+	struct xirc_softc *sc = device_private(self);
+
+	if (sc->sc_ethernet == child)
+		sc->sc_ethernet = NULL;
+
+	if (sc->sc_modem == child)
+		sc->sc_modem = NULL;
+}
+
 int
 xirc_detach(device_t self, int flags)
 {
-	struct xirc_softc *sc = (void *)self;
+	struct xirc_softc *sc = device_private(self);
 	int rv;
 
 	if (sc->sc_ethernet != NULL) {
-		rv = config_detach(sc->sc_ethernet, flags);
-		if (rv != 0)
-			return (rv);
-		sc->sc_ethernet = NULL;
+		if ((rv = config_detach(sc->sc_ethernet, flags)) != 0)
+			return rv;
 	}
 
 	if (sc->sc_modem != NULL) {
-		rv = config_detach(sc->sc_modem, flags);
-		if (rv != 0)
-			return (rv);
-		sc->sc_modem = NULL;
+		if ((rv = config_detach(sc->sc_modem, flags)) != 0)
+			return rv;
 	}
 
 	/* Unmap our i/o windows. */
@@ -420,37 +428,6 @@
 }
 
 int
-xirc_activate(device_t self, enum devact act)
-{
-	struct xirc_softc *sc = (void *)self;
-	int s, rv = 0;
-
-	s = splhigh();
-	switch (act) {
-	case DVACT_ACTIVATE:
-		rv = EOPNOTSUPP;
-		break;
-
-	case DVACT_DEACTIVATE:
-		if (sc->sc_ethernet != NULL) {
-			rv = config_deactivate(sc->sc_ethernet);
-			if (rv != 0)
-				goto out;
-		}
-
-		if (sc->sc_modem != NULL) {
-			rv = config_deactivate(sc->sc_modem);
-			if (rv != 0)
-				goto out;
-		}
-		break;
-	}
- out:
-	splx(s);
-	return (rv);
-}
-
-int
 xirc_intr(void *arg)
 {
 	struct xirc_softc *sc = arg;
@@ -553,7 +530,7 @@
 
 /* No xirc-specific goo in the softc; it's all in the parent. */
 CFATTACH_DECL_NEW(com_xirc, sizeof(struct com_softc),
-    com_xirc_match, com_xirc_attach, com_detach, com_activate);
+    com_xirc_match, com_xirc_attach, com_detach, NULL);
 
 int	com_xirc_enable(struct com_softc *);
 void	com_xirc_disable(struct com_softc *);
@@ -627,15 +604,14 @@
 
 /* No xirc-specific goo in the softc; it's all in the parent. */
 CFATTACH_DECL(xi_xirc, sizeof(struct xi_softc),
-    xi_xirc_match, xi_xirc_attach, xi_detach, xi_activate);
+    xi_xirc_match, xi_xirc_attach, xi_detach, NULL);
 
 int	xi_xirc_enable(struct xi_softc *);
 void	xi_xirc_disable(struct xi_softc *);
 int	xi_xirc_lan_nid_ciscallback(struct pcmcia_tuple *, void *);
 
 int
-xi_xirc_match(device_t parent, cfdata_t match,
-    void *aux)
+xi_xirc_match(device_t parent, cfdata_t match, void *aux)
 {
 	extern struct cfdriver xi_cd;
 	const char *name = aux;
@@ -649,8 +625,8 @@
 void
 xi_xirc_attach(device_t parent, device_t self, void *aux)
 {
-	struct xi_softc *sc = (void *)self;
-	struct xirc_softc *msc = (void *)parent;
+	struct xi_softc *sc = device_private(self);
+	struct xirc_softc *msc = device_private(parent);
 	u_int8_t myla[ETHER_ADDR_LEN];
 
 	aprint_normal("\n");

Reply via email to