Changeset View
Changeset View
Standalone View
Standalone View
sys/dev/cardbus/cardbus.c
Show First 20 Lines • Show All 90 Lines • ▼ Show 20 Lines | cardbus_probe(device_t cbdev) | ||||
device_set_desc(cbdev, "CardBus bus"); | device_set_desc(cbdev, "CardBus bus"); | ||||
return (0); | return (0); | ||||
} | } | ||||
static int | static int | ||||
cardbus_attach(device_t cbdev) | cardbus_attach(device_t cbdev) | ||||
{ | { | ||||
struct cardbus_softc *sc; | struct cardbus_softc *sc; | ||||
#ifdef PCI_RES_BUS | |||||
int rid; | int rid; | ||||
#endif | |||||
sc = device_get_softc(cbdev); | sc = device_get_softc(cbdev); | ||||
sc->sc_dev = cbdev; | sc->sc_dev = cbdev; | ||||
#ifdef PCI_RES_BUS | |||||
rid = 0; | rid = 0; | ||||
sc->sc_bus = bus_alloc_resource(cbdev, PCI_RES_BUS, &rid, | sc->sc_bus = bus_alloc_resource(cbdev, PCI_RES_BUS, &rid, | ||||
pcib_get_bus(cbdev), pcib_get_bus(cbdev), 1, 0); | pcib_get_bus(cbdev), pcib_get_bus(cbdev), 1, 0); | ||||
if (sc->sc_bus == NULL) { | if (sc->sc_bus == NULL) { | ||||
device_printf(cbdev, "failed to allocate bus number\n"); | device_printf(cbdev, "failed to allocate bus number\n"); | ||||
return (ENXIO); | return (ENXIO); | ||||
} | } | ||||
#else | |||||
device_printf(cbdev, "Your bus numbers may be AFU\n"); | |||||
#endif | |||||
return (0); | return (0); | ||||
} | } | ||||
static int | static int | ||||
cardbus_detach(device_t cbdev) | cardbus_detach(device_t cbdev) | ||||
{ | { | ||||
#ifdef PCI_RES_BUS | |||||
struct cardbus_softc *sc; | struct cardbus_softc *sc; | ||||
#endif | |||||
cardbus_detach_card(cbdev); | cardbus_detach_card(cbdev); | ||||
#ifdef PCI_RES_BUS | |||||
sc = device_get_softc(cbdev); | sc = device_get_softc(cbdev); | ||||
device_printf(cbdev, "Freeing up the allocatd bus\n"); | device_printf(cbdev, "Freeing up the allocatd bus\n"); | ||||
(void)bus_release_resource(cbdev, PCI_RES_BUS, 0, sc->sc_bus); | (void)bus_release_resource(cbdev, PCI_RES_BUS, 0, sc->sc_bus); | ||||
#endif | |||||
return (0); | return (0); | ||||
} | } | ||||
static int | static int | ||||
cardbus_suspend(device_t self) | cardbus_suspend(device_t self) | ||||
{ | { | ||||
cardbus_detach_card(self); | cardbus_detach_card(self); | ||||
▲ Show 20 Lines • Show All 234 Lines • Show Last 20 Lines |