Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/sys/dev/pcmcia Don't use com_activate(), it's gone away. Th...
details: https://anonhg.NetBSD.org/src/rev/ef526c6010b3
branches: trunk
changeset: 749012:ef526c6010b3
user: dyoung <dyoung%NetBSD.org@localhost>
date: Fri Nov 13 01:14:35 2009 +0000
description:
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.
diffstat:
sys/dev/pcmcia/if_xi.c | 32 ++---------------
sys/dev/pcmcia/mhzc.c | 88 +++++++++++++++++--------------------------------
sys/dev/pcmcia/xirc.c | 78 +++++++++++++++----------------------------
3 files changed, 63 insertions(+), 135 deletions(-)
diffs (truncated from 416 to 300 lines):
diff -r 21ecf25a03d7 -r ef526c6010b3 sys/dev/pcmcia/if_xi.c
--- a/sys/dev/pcmcia/if_xi.c Thu Nov 12 23:16:28 2009 +0000
+++ b/sys/dev/pcmcia/if_xi.c Fri Nov 13 01:14:35 2009 +0000
@@ -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);
diff -r 21ecf25a03d7 -r ef526c6010b3 sys/dev/pcmcia/mhzc.c
--- a/sys/dev/pcmcia/mhzc.c Thu Nov 12 23:16:28 2009 +0000
+++ b/sys/dev/pcmcia/mhzc.c Fri Nov 13 01:14:35 2009 +0000
@@ -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 */
diff -r 21ecf25a03d7 -r ef526c6010b3 sys/dev/pcmcia/xirc.c
--- a/sys/dev/pcmcia/xirc.c Thu Nov 12 23:16:28 2009 +0000
+++ b/sys/dev/pcmcia/xirc.c Fri Nov 13 01:14:35 2009 +0000
@@ -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);
Home |
Main Index |
Thread Index |
Old Index