Changeset View
Changeset View
Standalone View
Standalone View
sys/dev/extres/syscon/syscon_generic.c
Show First 20 Lines • Show All 155 Lines • ▼ Show 20 Lines | syscon_generic_probe(device_t dev) | ||||
device_set_desc(dev, "syscon"); | device_set_desc(dev, "syscon"); | ||||
if (!bootverbose) | if (!bootverbose) | ||||
device_quiet(dev); | device_quiet(dev); | ||||
return (BUS_PROBE_GENERIC); | return (BUS_PROBE_GENERIC); | ||||
} | } | ||||
static int | int | ||||
syscon_generic_attach(device_t dev) | syscon_generic_attach(device_t dev) | ||||
{ | { | ||||
struct syscon_generic_softc *sc; | struct syscon_generic_softc *sc; | ||||
int rid, rv; | int rid, rv; | ||||
sc = device_get_softc(dev); | sc = device_get_softc(dev); | ||||
sc->dev = dev; | sc->dev = dev; | ||||
rid = 0; | rid = 0; | ||||
Show All 40 Lines | if (sc->simplebus_attached) | ||||
simplebus_detach(dev); | simplebus_detach(dev); | ||||
SYSCON_LOCK_DESTROY(sc); | SYSCON_LOCK_DESTROY(sc); | ||||
if (sc->mem_res != NULL) | if (sc->mem_res != NULL) | ||||
bus_release_resource(dev, SYS_RES_MEMORY, 0, sc->mem_res); | bus_release_resource(dev, SYS_RES_MEMORY, 0, sc->mem_res); | ||||
return (0); | return (0); | ||||
} | } | ||||
static int | |||||
syscon_generic_get_handle(device_t dev, struct syscon **syscon) | |||||
{ | |||||
struct syscon_generic_softc *sc; | |||||
sc = device_get_softc(dev); | |||||
*syscon = sc->syscon; | |||||
if (*syscon == NULL) | |||||
return (ENODEV); | |||||
return (0); | |||||
} | |||||
static device_method_t syscon_generic_dmethods[] = { | static device_method_t syscon_generic_dmethods[] = { | ||||
/* Device interface */ | /* Device interface */ | ||||
DEVMETHOD(device_probe, syscon_generic_probe), | DEVMETHOD(device_probe, syscon_generic_probe), | ||||
DEVMETHOD(device_attach, syscon_generic_attach), | DEVMETHOD(device_attach, syscon_generic_attach), | ||||
DEVMETHOD(device_detach, syscon_generic_detach), | DEVMETHOD(device_detach, syscon_generic_detach), | ||||
/* syscon interface */ | |||||
DEVMETHOD(syscon_get_handle, syscon_generic_get_handle), | |||||
DEVMETHOD(syscon_device_lock, syscon_generic_lock), | DEVMETHOD(syscon_device_lock, syscon_generic_lock), | ||||
DEVMETHOD(syscon_device_unlock, syscon_generic_unlock), | DEVMETHOD(syscon_device_unlock, syscon_generic_unlock), | ||||
DEVMETHOD_END | DEVMETHOD_END | ||||
}; | }; | ||||
DEFINE_CLASS_1(syscon_generic_dev, syscon_generic_driver, syscon_generic_dmethods, | DEFINE_CLASS_1(syscon_generic_dev, syscon_generic_driver, syscon_generic_dmethods, | ||||
sizeof(struct syscon_generic_softc), simplebus_driver); | sizeof(struct syscon_generic_softc), simplebus_driver); | ||||
static devclass_t syscon_generic_devclass; | static devclass_t syscon_generic_devclass; | ||||
EARLY_DRIVER_MODULE(syscon_generic, simplebus, syscon_generic_driver, | EARLY_DRIVER_MODULE(syscon_generic, simplebus, syscon_generic_driver, | ||||
syscon_generic_devclass, 0, 0, BUS_PASS_DEFAULT); | syscon_generic_devclass, 0, 0, BUS_PASS_DEFAULT); | ||||
MODULE_VERSION(syscon_generic, 1); | MODULE_VERSION(syscon_generic, 1); |