1
0
mirror of https://git.FreeBSD.org/src.git synced 2025-01-26 16:18:31 +00:00

o move to using PCIC_SOFTC(dev) to get the softc

o move pcic_deactivate into pcic_detach
o Better debug messages
This commit is contained in:
Warner Losh 2000-08-19 19:20:25 +00:00
parent bc061f046b
commit 943e2bf6f6
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=64849
3 changed files with 13 additions and 15 deletions

View File

@ -199,8 +199,7 @@ pcic_vendor_to_string(int vendor)
static int static int
pcic_activate(device_t dev) pcic_activate(device_t dev)
{ {
struct pcic_softc *sc = (struct pcic_softc *) struct pcic_softc *sc = PCIC_SOFTC(dev);
device_get_softc(dev);
int err; int err;
sc->port_rid = 0; sc->port_rid = 0;
@ -250,7 +249,7 @@ pcic_activate(device_t dev)
void void
pcic_deactivate(device_t dev) pcic_deactivate(device_t dev)
{ {
struct pcic_softc *sc = device_get_softc(dev); struct pcic_softc *sc = PCIC_SOFTC(dev);
if (sc->intrhand) if (sc->intrhand)
bus_teardown_intr(dev, sc->irq_res, sc->intrhand); bus_teardown_intr(dev, sc->irq_res, sc->intrhand);
@ -273,8 +272,7 @@ pcic_deactivate(device_t dev)
int int
pcic_attach(device_t dev) pcic_attach(device_t dev)
{ {
struct pcic_softc *sc = (struct pcic_softc *) struct pcic_softc *sc = PCIC_SOFTC(dev);
device_get_softc(dev);
struct pcic_handle *h; struct pcic_handle *h;
int vendor, count, i, reg, error; int vendor, count, i, reg, error;
@ -713,28 +711,28 @@ pcic_queue_event(struct pcic_handle *h, int event)
static void static void
pcic_attach_card(struct pcic_handle *h) pcic_attach_card(struct pcic_handle *h)
{ {
DPRINTF(("pcic_attach_card h %p h->dev %p %s %s\n", h, h->dev, DPRINTF(("pcic_attach_card h %p h->dev %p\n", h, h->dev));
device_get_name(h->dev), device_get_name(device_get_parent(h->dev))));
if (!(h->flags & PCIC_FLAG_CARDP)) { if (!(h->flags & PCIC_FLAG_CARDP)) {
DPRINTF(("Calling MI attach function\n"));
/* call the MI attach function */ /* call the MI attach function */
CARD_ATTACH_CARD(h->dev); CARD_ATTACH_CARD(h->dev);
h->flags |= PCIC_FLAG_CARDP; h->flags |= PCIC_FLAG_CARDP;
} else { } else {
DPRINTF(("pcic_attach_card: already attached")); DPRINTF(("pcic_attach_card: already attached\n"));
} }
} }
static void static void
pcic_detach_card(struct pcic_handle *h, int flags) pcic_detach_card(struct pcic_handle *h, int flags)
{ {
DPRINTF(("pcic_detach_card h %p h->dev %p\n", h, h->dev));
if (h->flags & PCIC_FLAG_CARDP) { if (h->flags & PCIC_FLAG_CARDP) {
h->flags &= ~PCIC_FLAG_CARDP; h->flags &= ~PCIC_FLAG_CARDP;
/* call the MI detach function */ /* call the MI detach function */
CARD_DETACH_CARD(h->dev, flags); CARD_DETACH_CARD(h->dev, flags);
} else { } else {
DPRINTF(("pcic_detach_card: already detached")); DPRINTF(("pcic_detach_card: already detached\n"));
} }
} }
@ -1517,18 +1515,18 @@ pcic_start_threads(void *arg)
int int
pcic_detach(device_t dev) pcic_detach(device_t dev)
{ {
device_t pccarddev;
device_t *kids; device_t *kids;
int nkids; int nkids;
int i; int i;
int ret; int ret;
pcic_deactivate(dev);
ret = bus_generic_detach(dev); ret = bus_generic_detach(dev);
if (ret != 0) if (ret != 0)
return (ret); return (ret);
device_get_children(dev, &kids, &nkids); device_get_children(dev, &kids, &nkids);
for (i = 0; i < nkids; i++) { for (i = 0; i < nkids; i++) {
if ((ret = device_delete_child(pccarddev, kids[i])) != 0) if ((ret = device_delete_child(dev, kids[i])) != 0)
device_printf(dev, "delete of %s failed: %d\n", device_printf(dev, "delete of %s failed: %d\n",
device_get_nameunit(kids[i]), ret); device_get_nameunit(kids[i]), ret);
} }

View File

@ -122,8 +122,7 @@ static struct isa_pnp_id pcic_ids[] = {
static void static void
pcic_isa_bus_width_probe (device_t dev) pcic_isa_bus_width_probe (device_t dev)
{ {
struct pcic_softc *sc = (struct pcic_softc *) struct pcic_softc *sc = PCIC_SOFTC(dev);
device_get_softc(dev);
bus_space_handle_t ioh_high; bus_space_handle_t ioh_high;
int i, iobuswidth, tmp1, tmp2; int i, iobuswidth, tmp1, tmp2;
int rid; int rid;
@ -358,7 +357,6 @@ pcic_isa_attach(device_t dev)
static int static int
pcic_isa_detach(device_t dev) pcic_isa_detach(device_t dev)
{ {
pcic_deactivate(dev);
pcic_detach(dev); pcic_detach(dev);
return 0; return 0;
} }

View File

@ -194,3 +194,5 @@ int pcic_set_res_flags(device_t dev, device_t child, int type, int rid,
u_int32_t flags); u_int32_t flags);
int pcic_set_memory_offset(device_t dev, device_t child, int rid, int pcic_set_memory_offset(device_t dev, device_t child, int rid,
u_int32_t offset); u_int32_t offset);
#define PCIC_SOFTC(d) (struct pcic_softc *) device_get_softc(d)