o Move to using PCCARD_SOFTC(dev)

o fill in the size of the actual softc, rather than 1 in data structure
o minor debugging improvements.
This commit is contained in:
Warner Losh 2000-08-19 19:22:04 +00:00
parent 943e2bf6f6
commit c8ce264e17
4 changed files with 16 additions and 20 deletions

View file

@ -93,8 +93,7 @@ pccard_ccr_write(pf, ccr, val)
static int
pccard_attach_card(device_t dev)
{
struct pccard_softc *sc = (struct pccard_softc *)
device_get_softc(dev);
struct pccard_softc *sc = PCCARD_SOFTC(dev);
struct pccard_function *pf;
device_t child;
int attached;
@ -111,9 +110,6 @@ pccard_attach_card(device_t dev)
DEVPRINTF((dev, "read_cis\n"));
pccard_read_cis(sc);
DEVPRINTF((dev, "chip_socket_disable\n"));
POWER_DISABLE_SOCKET(device_get_parent(dev), dev);
DEVPRINTF((dev, "check_cis_quirks\n"));
pccard_check_cis_quirks(dev);
@ -137,13 +133,16 @@ pccard_attach_card(device_t dev)
if (STAILQ_EMPTY(&pf->cfe_head))
continue;
printf ("pf %x sc %x\n", pf, sc);
printf ("pf %p sc %p\n", pf, sc);
pf->sc = sc;
pf->cfe = NULL;
pf->ih_fct = NULL;
pf->ih_arg = NULL;
}
DEVPRINTF((dev, "chip_socket_disable\n"));
POWER_DISABLE_SOCKET(device_get_parent(dev), dev);
STAILQ_FOREACH(pf, &sc->card.pf_head, pf_list) {
if (STAILQ_EMPTY(&pf->cfe_head))
continue;
@ -163,7 +162,7 @@ pccard_attach_card(device_t dev)
child = device_add_child(dev, NULL, -1);
pccard_function_init(pf, STAILQ_FIRST(&pf->cfe_head));
pccard_function_enable(pf);
device_printf(dev, "pf %x pf->sc %x\n", pf, pf->sc);
device_printf(dev, "pf %p pf->sc %p\n", pf, pf->sc);
if (device_probe_and_attach(child) == 0) {
attached++;
@ -183,8 +182,7 @@ pccard_attach_card(device_t dev)
static int
pccard_detach_card(device_t dev, int flags)
{
struct pccard_softc *sc = (struct pccard_softc *)
device_get_softc(dev);
struct pccard_softc *sc = PCCARD_SOFTC(dev);
struct pccard_function *pf;
/*
@ -204,8 +202,7 @@ pccard_detach_card(device_t dev, int flags)
static int
pccard_card_gettype(device_t dev, int *type)
{
struct pccard_softc *sc = (struct pccard_softc *)
device_get_softc(dev);
struct pccard_softc *sc = PCCARD_SOFTC(dev);
struct pccard_function *pf;
/*
@ -515,11 +512,11 @@ pccard_probe(device_t dev)
static int
pccard_attach(device_t dev)
{
struct pccard_softc *sc;
struct pccard_softc *sc = PCCARD_SOFTC(dev);
sc = (struct pccard_softc *) device_get_softc(dev);
sc->dev = dev;
sc->sc_enabled_count = 0;
DEVPRINTF((dev, "pccard_attach %p\n", dev));
return bus_generic_attach(dev);
}
@ -684,7 +681,7 @@ static device_method_t pccard_methods[] = {
static driver_t pccard_driver = {
"pccard",
pccard_methods,
1, /* no softc */
sizeof(struct pccard_softc)
};
devclass_t pccard_devclass;

View file

@ -427,7 +427,7 @@ done:
void
pccard_print_cis(device_t dev)
{
struct pccard_softc *sc = (struct pccard_softc *) device_get_softc(dev);
struct pccard_softc *sc = PCCARD_SOFTC(dev);
struct pccard_card *card = &sc->card;
struct pccard_function *pf;
struct pccard_config_entry *cfe;

View file

@ -185,8 +185,7 @@ static int n_pccard_cis_quirks =
void pccard_check_cis_quirks(device_t dev)
{
struct pccard_softc *sc = (struct pccard_softc *)
device_get_softc(dev);
struct pccard_softc *sc = PCCARD_SOFTC(dev);
int wiped = 0;
int i, j;
struct pccard_function *pf, *pf_next, *pf_last;

View file

@ -241,6 +241,8 @@ void pccard_ccr_write(struct pccard_function *, int, int);
#define pccard_mfc(sc) (STAILQ_FIRST(&(sc)->card.pf_head) && \
STAILQ_NEXT(STAILQ_FIRST(&(sc)->card.pf_head),pf_list))
/* The following is the vestages of the NetBSD driver api */
void pccard_function_init(struct pccard_function *,
struct pccard_config_entry *);
int pccard_function_enable(struct pccard_function *);
@ -259,14 +261,11 @@ void pccard_io_unmap(struct pccard_function *, int);
#define pccard_mem_alloc(pf, size, pcmhp) \
(pccard_chip_mem_alloc((pf)->sc->pct, (pf)->sc->pch, (size), (pcmhp)))
#define pccard_mem_free(pf, pcmhp) \
(pccard_chip_mem_free((pf)->sc->pct, (pf)->sc->pch, (pcmhp)))
#define pccard_mem_map(pf, kind, card_addr, size, pcmhp, offsetp, windowp) \
(pccard_chip_mem_map((pf)->sc->pct, (pf)->sc->pch, (kind), \
(card_addr), (size), (pcmhp), (offsetp), (windowp)))
#define pccard_mem_unmap(pf, window) \
(pccard_chip_mem_unmap((pf)->sc->pct, (pf)->sc->pch, (window)))
@ -287,3 +286,4 @@ enum {
PCCARD_A_MEM_ATTR = 0x1
};
#define PCCARD_SOFTC(d) (struct pccard_softc *) device_get_softc(d)