diff options
author | imp <imp@FreeBSD.org> | 2008-08-07 20:55:20 +0000 |
---|---|---|
committer | imp <imp@FreeBSD.org> | 2008-08-07 20:55:20 +0000 |
commit | 9f16e510b9a765d8caed7f31ebaf16b600540db4 (patch) | |
tree | 91c57fb758ce59dac34df2da6fedde86cf673576 | |
parent | 1fbadc47e92419f3c5765760b8fd716a5acdcc83 (diff) | |
download | FreeBSD-src-9f16e510b9a765d8caed7f31ebaf16b600540db4.zip FreeBSD-src-9f16e510b9a765d8caed7f31ebaf16b600540db4.tar.gz |
Convert to new style PC Card front end driver. Add support for the
NEC PC-9801N-J02 and PC-9801N-J02R. I can't test the former because
it requires resources that conflict with my laptop. I can't test the
latter because my dog chewed up my -J02R card and it didn't survive
well enough for me to test.
-rw-r--r-- | sys/dev/snc/if_snc_pccard.c | 54 |
1 files changed, 35 insertions, 19 deletions
diff --git a/sys/dev/snc/if_snc_pccard.c b/sys/dev/snc/if_snc_pccard.c index 05babd1..2656730 100644 --- a/sys/dev/snc/if_snc_pccard.c +++ b/sys/dev/snc/if_snc_pccard.c @@ -55,6 +55,16 @@ __FBSDID("$FreeBSD$"); #include <dev/snc/if_sncvar.h> #include <dev/snc/if_sncreg.h> +#include <dev/pccard/pccardvar.h> +#include <dev/pccard/pccard_cis.h> +#include "pccarddevs.h" + +static const struct pccard_product snc_pccard_products[] = { + PCMCIA_CARD(NEC, PC9801N_J02), + PCMCIA_CARD(NEC, PC9801N_J02R), + { NULL } +}; + /* * PC Card (PCMCIA) specific code. */ @@ -112,34 +122,40 @@ snc_pccard_detach(device_t dev) static int snc_pccard_probe(device_t dev) { - int error; - - error = snc_alloc_port(dev, 0); - error = max(error, snc_alloc_memory(dev, 0)); - error = max(error, snc_alloc_irq(dev, 0, 0)); + const struct pccard_product *pp; - if (!error && !snc_probe(dev, SNEC_TYPE_PNP)) - error = ENOENT; - - snc_release_resources(dev); - return (error); + if ((pp = pccard_product_lookup(dev, snc_pccard_products, + sizeof(snc_pccard_products[0]), NULL)) == NULL) + return (EIO); + if (pp->pp_name != NULL) + device_set_desc(dev, pp->pp_name); + return (0); } static int snc_pccard_attach(device_t dev) { struct snc_softc *sc = device_get_softc(dev); + int error; - bzero(sc, sizeof(struct snc_softc)); - - snc_alloc_port(dev, 0); - snc_alloc_memory(dev, 0); - snc_alloc_irq(dev, 0, 0); - + /* + * Not sure that this belongs here or in snc_pccard_attach + */ + if ((error = snc_alloc_port(dev, 0)) != 0) + goto err; + if ((error = snc_alloc_memory(dev, 0)) != 0) + goto err; + if ((error = snc_alloc_irq(dev, 0, 0)) != 0) + goto err; + if ((error = snc_probe(dev, SNEC_TYPE_PNP)) != 0) + goto err; /* This interface is always enabled. */ sc->sc_enabled = 1; - /* pccard_get_ether(dev, ether_addr); */ - - return snc_attach(dev); + if ((error = snc_attach(dev)) != 0) + goto err; + return 0; +err:; + snc_release_resources(dev); + return error; } |