Current-Users archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
users of mhzc, pcmcom, sm at mhzc, xi, xirc
Please try this patch. I will commit it in a week.
The patch adds some child-detachment hooks, does a device_t/softc split,
and simplifies activation hooks.
Dave
--
David Young OJC Technologies
dyoung%ojctech.com@localhost Urbana, IL * (217) 278-3933
Index: sys/dev/pcmcia/if_xi.c
===================================================================
RCS file: /cvsroot/src/sys/dev/pcmcia/if_xi.c,v
retrieving revision 1.67
diff -p -u -u -p -r1.67 if_xi.c
--- sys/dev/pcmcia/if_xi.c 12 May 2009 14:42:18 -0000 1.67
+++ sys/dev/pcmcia/if_xi.c 3 Nov 2009 05:31:00 -0000
@@ -211,11 +211,11 @@ xi_attach(struct xi_softc *sc, u_int8_t
/* Reset and initialize the card. */
xi_full_reset(sc);
- printf("%s: MAC address %s\n", device_xname(&sc->sc_dev),
ether_sprintf(myea));
+ printf("%s: MAC address %s\n", device_xname(sc->sc_dev),
ether_sprintf(myea));
ifp = &sc->sc_ethercom.ec_if;
/* Initialize the ifnet structure. */
- strlcpy(ifp->if_xname, device_xname(&sc->sc_dev), IFNAMSIZ);
+ strlcpy(ifp->if_xname, device_xname(sc->sc_dev), IFNAMSIZ);
ifp->if_softc = sc;
ifp->if_start = xi_start;
ifp->if_ioctl = xi_ioctl;
@@ -242,9 +242,9 @@ xi_attach(struct xi_softc *sc, u_int8_t
ifmedia_init(&sc->sc_mii.mii_media, 0, xi_mediachange,
ether_mediastatus);
DPRINTF(XID_MII | XID_CONFIG,
- ("xi: bmsr %x\n", xi_mdi_read(&sc->sc_dev, 0, 1)));
+ ("xi: bmsr %x\n", xi_mdi_read(sc->sc_dev, 0, 1)));
- mii_attach(&sc->sc_dev, &sc->sc_mii, 0xffffffff, MII_PHY_ANY,
+ mii_attach(sc->sc_dev, &sc->sc_mii, 0xffffffff, MII_PHY_ANY,
MII_OFFSET_ANY, 0);
if (LIST_FIRST(&sc->sc_mii.mii_phys) == NULL)
ifmedia_add(&sc->sc_mii.mii_media, IFM_ETHER | IFM_AUTO, 0,
@@ -252,14 +252,14 @@ xi_attach(struct xi_softc *sc, u_int8_t
ifmedia_set(&sc->sc_mii.mii_media, IFM_ETHER | IFM_AUTO);
#if NRND > 0
- rnd_attach_source(&sc->sc_rnd_source, device_xname(&sc->sc_dev),
RND_TYPE_NET, 0);
+ rnd_attach_source(&sc->sc_rnd_source, device_xname(sc->sc_dev),
RND_TYPE_NET, 0);
#endif
}
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 @@ xi_detach(device_t self, int flags)
}
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;
@@ -310,8 +288,7 @@ xi_intr(void *arg)
DPRINTF(XID_CONFIG, ("xi_intr()\n"));
- if (sc->sc_enabled == 0 ||
- !device_is_active(&sc->sc_dev))
+ if (sc->sc_enabled == 0 || !device_is_active(sc->sc_dev))
return (0);
ifp->if_timer = 0; /* turn watchdog timer off */
@@ -329,7 +306,8 @@ xi_intr(void *arg)
/* Check to see if card has been ejected. */
if (isr == 0xff) {
#ifdef DIAGNOSTIC
- printf("%s: interrupt for dead card\n",
device_xname(&sc->sc_dev));
+ printf("%s: interrupt for dead card\n",
+ device_xname(sc->sc_dev));
#endif
goto end;
}
@@ -597,7 +575,7 @@ xi_mdi_pulse_bits(struct xi_softc *sc, u
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 @@ xi_mdi_read(device_t self, int phy, int
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);
@@ -686,7 +664,7 @@ xi_watchdog(struct ifnet *ifp)
{
struct xi_softc *sc = ifp->if_softc;
- printf("%s: device timeout\n", device_xname(&sc->sc_dev));
+ printf("%s: device timeout\n", device_xname(sc->sc_dev));
++ifp->if_oerrors;
xi_reset(sc);
Index: sys/dev/pcmcia/if_xivar.h
===================================================================
RCS file: /cvsroot/src/sys/dev/pcmcia/if_xivar.h,v
retrieving revision 1.5
diff -p -u -u -p -r1.5 if_xivar.h
--- sys/dev/pcmcia/if_xivar.h 12 May 2009 14:42:18 -0000 1.5
+++ sys/dev/pcmcia/if_xivar.h 3 Nov 2009 05:31:00 -0000
@@ -25,7 +25,7 @@
#endif
struct xi_softc {
- struct device sc_dev; /* Generic device info */
+ device_t sc_dev; /* Generic device info */
struct ethercom sc_ethercom; /* Ethernet common part */
struct mii_data sc_mii; /* MII media information */
Index: sys/dev/pcmcia/mhzc.c
===================================================================
RCS file: /cvsroot/src/sys/dev/pcmcia/mhzc.c,v
retrieving revision 1.46
diff -p -u -u -p -r1.46 mhzc.c
--- sys/dev/pcmcia/mhzc.c 12 May 2009 14:42:19 -0000 1.46
+++ sys/dev/pcmcia/mhzc.c 3 Nov 2009 05:31:00 -0000
@@ -95,7 +95,7 @@ __KERNEL_RCSID(0, "$NetBSD: mhzc.c,v 1.4
#include "mhzc.h"
struct mhzc_softc {
- struct device sc_dev; /* generic device glue */
+ device_t sc_dev; /* generic device glue */
struct pcmcia_function *sc_pf; /* our PCMCIA function */
void *sc_ih; /* interrupt handle */
@@ -129,11 +129,12 @@ struct mhzc_softc {
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);
+int mhzc_acti(device_t, enum devact);
-CFATTACH_DECL(mhzc, sizeof(struct mhzc_softc),
- mhzc_match, mhzc_attach, mhzc_detach, mhzc_activate);
+CFATTACH_DECL2_NEW(mhzc, sizeof(struct mhzc_softc),
+ mhzc_match, mhzc_attach, mhzc_detach, NULL, NULL, mhzc_childdet);
int mhzc_em3336_enaddr(struct mhzc_softc *, u_int8_t *);
int mhzc_em3336_enable(struct mhzc_softc *);
@@ -165,8 +166,7 @@ void mhzc_disable(struct mhzc_softc *, i
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,11 +179,12 @@ mhzc_match(device_t parent, cfdata_t mat
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;
+ sc->sc_dev = self;
sc->sc_pf = pa->pf;
sc->sc_product = pcmcia_product_lookup(pa, mhzc_products,
@@ -233,14 +234,14 @@ mhzc_attach(device_t parent, device_t se
if (pcmcia_io_map(sc->sc_pf, PCMCIA_WIDTH_IO8, &sc->sc_modem_pcioh,
&sc->sc_modem_io_window)) {
- aprint_error_dev(&sc->sc_dev, "unable to map I/O space\n");
+ aprint_error_dev(sc->sc_dev, "unable to map I/O space\n");
goto fail;
}
sc->sc_flags |= MHZC_MODEM_MAPPED;
if (pcmcia_io_map(sc->sc_pf, PCMCIA_WIDTH_AUTO, &sc->sc_ethernet_pcioh,
&sc->sc_ethernet_io_window)) {
- aprint_error_dev(&sc->sc_dev, "unable to map I/O space\n");
+ aprint_error_dev(sc->sc_dev, "unable to map I/O space\n");
goto fail;
}
sc->sc_flags |= MHZC_ETHERNET_MAPPED;
@@ -323,24 +324,31 @@ mhzc_print(void *aux, const char *pnp)
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 +365,7 @@ mhzc_detach(device_t self, int flags)
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
@@ -418,7 +395,7 @@ mhzc_enable(struct mhzc_softc *sc, int f
int error;
if ((sc->sc_flags & flag) == flag) {
- printf("%s: already enabled\n", device_xname(&sc->sc_dev));
+ printf("%s: already enabled\n", device_xname(sc->sc_dev));
return (0);
}
@@ -468,7 +445,7 @@ mhzc_disable(struct mhzc_softc *sc, int
{
if ((sc->sc_flags & flag) == 0) {
- printf("%s: already disabled\n", device_xname(&sc->sc_dev));
+ printf("%s: already disabled\n", device_xname(sc->sc_dev));
return;
}
@@ -493,10 +470,10 @@ mhzc_em3336_enaddr(struct mhzc_softc *sc
{
/* Get the station address from CIS tuple 0x81. */
- if (pcmcia_scan_cis(device_parent(&sc->sc_dev),
+ if (pcmcia_scan_cis(device_parent(sc->sc_dev),
mhzc_em3336_lannid_ciscallback, myla) != 1) {
printf("%s: unable to get Ethernet address from CIS\n",
- device_xname(&sc->sc_dev));
+ device_xname(sc->sc_dev));
return (0);
}
@@ -518,13 +495,13 @@ mhzc_em3336_enable(struct mhzc_softc *sc
/* Map the ISRPOWEREG. */
if (pcmcia_mem_alloc(sc->sc_pf, 0x1000, &memh) != 0) {
- aprint_error_dev(&sc->sc_dev, "unable to allocate memory
space\n");
+ aprint_error_dev(sc->sc_dev, "unable to allocate memory
space\n");
return (1);
}
if (pcmcia_mem_map(sc->sc_pf, PCMCIA_MEM_ATTR, 0, 0x1000,
&memh, &memoff, &memwin)) {
- aprint_error_dev(&sc->sc_dev, "unable to map memory space\n");
+ aprint_error_dev(sc->sc_dev, "unable to map memory space\n");
pcmcia_mem_free(sc->sc_pf, &memh);
return (1);
}
@@ -622,7 +599,7 @@ int com_mhzc_detach(device_t, int);
/* 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 +677,7 @@ int sm_mhzc_enable(struct smc91cxx_softc
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 +692,8 @@ sm_mhzc_match(device_t parent, cfdata_t
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 +714,17 @@ sm_mhzc_attach(device_t parent, device_t
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: sys/dev/pcmcia/pcmcom.c
===================================================================
RCS file: /cvsroot/src/sys/dev/pcmcia/pcmcom.c,v
retrieving revision 1.37
diff -p -u -u -p -r1.37 pcmcom.c
--- sys/dev/pcmcia/pcmcom.c 12 May 2009 14:42:19 -0000 1.37
+++ sys/dev/pcmcia/pcmcom.c 3 Nov 2009 05:31:00 -0000
@@ -68,7 +68,7 @@ __KERNEL_RCSID(0, "$NetBSD: pcmcom.c,v 1
#include "locators.h"
struct pcmcom_softc {
- struct device sc_dev; /* generic device glue */
+ device_t sc_dev; /* generic device glue */
struct pcmcia_function *sc_pf; /* our PCMCIA function */
void *sc_ih; /* interrupt handle */
@@ -92,10 +92,10 @@ int pcmcom_match(device_t, cfdata_t, voi
int pcmcom_validate_config(struct pcmcia_config_entry *);
void pcmcom_attach(device_t, device_t, void *);
int pcmcom_detach(device_t, int);
-int pcmcom_activate(device_t, enum devact);
+void pcmcom_childdet(device_t, device_t);
-CFATTACH_DECL(pcmcom, sizeof(struct pcmcom_softc),
- pcmcom_match, pcmcom_attach, pcmcom_detach, pcmcom_activate);
+CFATTACH_DECL2_NEW(pcmcom, sizeof(struct pcmcom_softc),
+ pcmcom_match, pcmcom_attach, pcmcom_detach, NULL, NULL, pcmcom_childdet);
const struct pcmcia_product pcmcom_products[] = {
{ PCMCIA_VENDOR_SOCKET, PCMCIA_PRODUCT_SOCKET_DUAL_RS232,
@@ -116,8 +116,7 @@ void pcmcom_disable(struct pcmcom_softc
int pcmcom_intr(void *);
int
-pcmcom_match(device_t parent, cfdata_t cf,
- void *aux)
+pcmcom_match(device_t parent, cfdata_t cf, void *aux)
{
struct pcmcia_attach_args *pa = aux;
@@ -139,19 +138,20 @@ pcmcom_validate_config(struct pcmcia_con
void
pcmcom_attach(device_t parent, device_t self, void *aux)
{
- struct pcmcom_softc *sc = (void *)self;
+ struct pcmcom_softc *sc = device_private(self);
struct pcmcia_attach_args *pa = aux;
struct pcmcia_config_entry *cfe;
int slave;
int error;
int locs[PCMCOMCF_NLOCS];
+ sc->sc_dev = self;
+
sc->sc_pf = pa->pf;
error = pcmcia_function_configure(pa->pf, pcmcom_validate_config);
if (error) {
- aprint_error_dev(self, "configure failed, error=%d\n",
- error);
+ aprint_error_dev(self, "configure failed, error=%d\n", error);
return;
}
@@ -174,7 +174,7 @@ pcmcom_attach(device_t parent, device_t
locs[PCMCOMCF_SLAVE] = slave;
- sc->sc_slaves[slave] = config_found_sm_loc(&sc->sc_dev,
+ sc->sc_slaves[slave] = config_found_sm_loc(sc->sc_dev,
"pcmcom", locs,
&pca, pcmcom_print, config_stdsubmatch);
}
@@ -187,10 +187,22 @@ fail:
pcmcia_function_unconfigure(pa->pf);
}
+void
+pcmcom_childdet(device_t self, device_t child)
+{
+ struct pcmcom_softc *sc = device_private(self);
+ int slave;
+
+ for (slave = sc->sc_nslaves - 1; slave >= 0; slave--) {
+ if (sc->sc_slaves[slave] == child)
+ sc->sc_slaves[slave] = NULL;
+ }
+}
+
int
pcmcom_detach(device_t self, int flags)
{
- struct pcmcom_softc *sc = (void *)self;
+ struct pcmcom_softc *sc = device_private(self);
int slave, error;
if (sc->sc_state != PCMCOM_ATTACHED)
@@ -202,7 +214,6 @@ pcmcom_detach(device_t self, int flags)
error = config_detach(sc->sc_slaves[slave], flags);
if (error)
return (error);
- sc->sc_slaves[slave] = 0;
}
}
@@ -212,37 +223,6 @@ pcmcom_detach(device_t self, int flags)
}
int
-pcmcom_activate(device_t self, enum devact act)
-{
- struct pcmcom_softc *sc = (void *)self;
- int slave, error = 0, s;
-
- s = splserial();
- switch (act) {
- case DVACT_ACTIVATE:
- error = EOPNOTSUPP;
- break;
-
- case DVACT_DEACTIVATE:
- for (slave = sc->sc_nslaves - 1; slave >= 0; slave--) {
- if (sc->sc_slaves[slave]) {
- /*
- * Deactivate the child. Doing so will cause
- * our own enabled count to drop to 0, once all
- * children are deactivated.
- */
- error = config_deactivate(sc->sc_slaves[slave]);
- if (error)
- break;
- }
- }
- break;
- }
- splx(s);
- return (error);
-}
-
-int
pcmcom_print(void *aux, const char *pnp)
{
struct pcmcom_attach_args *pca = aux;
@@ -320,7 +300,7 @@ void com_pcmcom_attach(device_t, device_
/* No pcmcom-specific goo in the softc; it's all in the parent. */
CFATTACH_DECL(com_pcmcom, sizeof(struct com_softc),
- com_pcmcom_match, com_pcmcom_attach, com_detach, com_activate);
+ com_pcmcom_match, com_pcmcom_attach, com_detach, NULL);
int com_pcmcom_enable(struct com_softc *);
void com_pcmcom_disable(struct com_softc *);
@@ -356,8 +336,7 @@ com_pcmcom_attach(device_t parent, devic
int
com_pcmcom_enable(struct com_softc *sc)
{
-
- return (pcmcom_enable(device_private(device_parent(sc->sc_dev))));
+ return pcmcom_enable(device_private(device_parent(sc->sc_dev)));
}
void
Index: sys/dev/pcmcia/xirc.c
===================================================================
RCS file: /cvsroot/src/sys/dev/pcmcia/xirc.c,v
retrieving revision 1.29
diff -p -u -u -p -r1.29 xirc.c
--- sys/dev/pcmcia/xirc.c 12 May 2009 14:42:19 -0000 1.29
+++ sys/dev/pcmcia/xirc.c 3 Nov 2009 05:31:00 -0000
@@ -89,7 +89,7 @@ __KERNEL_RCSID(0, "$NetBSD: xirc.c,v 1.2
#include <dev/pcmcia/if_xireg.h>
struct xirc_softc {
- struct device sc_dev; /* generic device glue */
+ device_t sc_dev; /* generic device glue */
struct pcmcia_function *sc_pf; /* our PCMCIA function */
void *sc_ih; /* interrupt handle */
@@ -124,10 +124,10 @@ struct xirc_softc {
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);
+CFATTACH_DECL2_NEW(xirc, sizeof(struct xirc_softc),
+ xirc_match, xirc_attach, xirc_detach, NULL, NULL, xirc_childdet);
int xirc_print(void *, const char *);
@@ -170,12 +170,14 @@ xirc_match(device_t parent, cfdata_t mat
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;
int error;
+ sc->sc_dev = self;
+
sc->sc_pf = pa->pf;
pcmcia_socket_enable(parent);
@@ -383,24 +385,32 @@ xirc_print(void *aux, const char *pnp)
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 +430,6 @@ xirc_detach(device_t self, int flags)
}
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;
@@ -477,7 +456,7 @@ xirc_enable(struct xirc_softc *sc, int f
int error;
if ((sc->sc_flags & flag) == flag) {
- printf("%s: already enabled\n", device_xname(&sc->sc_dev));
+ printf("%s: already enabled\n", device_xname(sc->sc_dev));
return (0);
}
@@ -524,7 +503,7 @@ xirc_disable(struct xirc_softc *sc, int
{
if ((sc->sc_flags & flag) == 0) {
- printf("%s: already disabled\n", device_xname(&sc->sc_dev));
+ printf("%s: already disabled\n", device_xname(sc->sc_dev));
return;
}
@@ -553,7 +532,7 @@ int com_xirc_detach(device_t, int);
/* 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 +606,14 @@ void xi_xirc_attach(device_t, device_t,
/* 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,10 +627,12 @@ xi_xirc_match(device_t parent, cfdata_t
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];
+ sc->sc_dev = self;
+
aprint_normal("\n");
sc->sc_bst = msc->sc_ethernet_pcioh.iot;
@@ -663,7 +643,7 @@ xi_xirc_attach(device_t parent, device_t
sc->sc_enable = xi_xirc_enable;
sc->sc_disable = xi_xirc_disable;
- if (!pcmcia_scan_cis(device_parent(&msc->sc_dev),
+ if (!pcmcia_scan_cis(device_parent(msc->sc_dev),
xi_xirc_lan_nid_ciscallback, myla)) {
aprint_error_dev(self, "can't find MAC address\n");
return;
@@ -676,8 +656,7 @@ xi_xirc_attach(device_t parent, device_t
int
xi_xirc_enable(struct xi_softc *sc)
{
- struct xirc_softc *msc =
- (struct xirc_softc *)device_parent(&sc->sc_dev);
+ struct xirc_softc *msc = device_private(device_parent(sc->sc_dev));
return (xirc_enable(msc, XIRC_ETHERNET_ENABLED, XIMEDIA_ETHER));
}
@@ -685,8 +664,7 @@ xi_xirc_enable(struct xi_softc *sc)
void
xi_xirc_disable(struct xi_softc *sc)
{
- struct xirc_softc *msc =
- (struct xirc_softc *)device_parent(&sc->sc_dev);
+ struct xirc_softc *msc = device_private(device_parent(sc->sc_dev));
xirc_disable(msc, XIRC_ETHERNET_ENABLED, XIMEDIA_ETHER);
}
Home |
Main Index |
Thread Index |
Old Index