diff options
author | takawata <takawata@FreeBSD.org> | 2005-06-10 16:12:43 +0000 |
---|---|---|
committer | takawata <takawata@FreeBSD.org> | 2005-06-10 16:12:43 +0000 |
commit | 024ebcc52b509051395cceb59fa99050e956b50c (patch) | |
tree | 2cd076dd2fc7197365fd6d324bae56838d28caab | |
parent | 6ee6d8891675b656ba92d6c73aa98b03a975c2fe (diff) | |
download | FreeBSD-src-024ebcc52b509051395cceb59fa99050e956b50c.zip FreeBSD-src-024ebcc52b509051395cceb59fa99050e956b50c.tar.gz |
Make ichsmb(4) child device handling properly.
-rw-r--r-- | sys/dev/ichsmb/ichsmb.c | 30 | ||||
-rw-r--r-- | sys/dev/ichsmb/ichsmb_pci.c | 7 | ||||
-rw-r--r-- | sys/dev/ichsmb/ichsmb_var.h | 2 |
3 files changed, 31 insertions, 8 deletions
diff --git a/sys/dev/ichsmb/ichsmb.c b/sys/dev/ichsmb/ichsmb.c index aed9396..2cfb564 100644 --- a/sys/dev/ichsmb/ichsmb.c +++ b/sys/dev/ichsmb/ichsmb.c @@ -96,14 +96,6 @@ static int ichsmb_wait(sc_p sc); int ichsmb_probe(device_t dev) { - device_t smb; - - /* Add child: an instance of the "smbus" device */ - if ((smb = device_add_child(dev, DRIVER_SMBUS, -1)) == NULL) { - log(LOG_ERR, "%s: no \"%s\" child found\n", - device_get_nameunit(dev), DRIVER_SMBUS); - return (ENXIO); - } return (BUS_PROBE_DEFAULT); } @@ -116,6 +108,14 @@ ichsmb_attach(device_t dev) { const sc_p sc = device_get_softc(dev); int error; + device_t smb; + + /* Add child: an instance of the "smbus" device */ + if ((smb = device_add_child(dev, DRIVER_SMBUS, -1)) == NULL) { + log(LOG_ERR, "%s: no \"%s\" child found\n", + device_get_nameunit(dev), DRIVER_SMBUS); + return (ENXIO); + } /* Clear interrupt conditions */ bus_space_write_1(sc->io_bst, sc->io_bsh, ICH_HST_STA, 0xff); @@ -675,3 +675,17 @@ ichsmb_release_resources(sc_p sc) } } +int ichsmb_detach(device_t dev) +{ +#if 0 + const sc_p sc = device_get_softc(dev); + bus_generic_detach(dev); + device_delete_child(dev, sc->smb); + ichsmb_release_resources(sc); + + return 0; +#else + /*smbus drivers don't handle detach child properly*/ + return EBUSY; +#endif +} diff --git a/sys/dev/ichsmb/ichsmb_pci.c b/sys/dev/ichsmb/ichsmb_pci.c index e4412af..41f7c29 100644 --- a/sys/dev/ichsmb/ichsmb_pci.c +++ b/sys/dev/ichsmb/ichsmb_pci.c @@ -80,12 +80,17 @@ __FBSDID("$FreeBSD$"); /* Internal functions */ static int ichsmb_pci_probe(device_t dev); static int ichsmb_pci_attach(device_t dev); +/*Use generic one for now*/ +#if 0 +static int ichsmb_pci_detach(device_t dev); +#endif /* Device methods */ static device_method_t ichsmb_pci_methods[] = { /* Device interface */ DEVMETHOD(device_probe, ichsmb_pci_probe), DEVMETHOD(device_attach, ichsmb_pci_attach), + DEVMETHOD(device_detach, ichsmb_detach), /* Bus methods */ DEVMETHOD(bus_print_child, bus_generic_print_child), @@ -224,6 +229,8 @@ fail: return (error); } + MODULE_DEPEND(ichsmb, pci, 1, 1, 1); MODULE_DEPEND(ichsmb, smbus, SMBUS_MINVER, SMBUS_PREFVER, SMBUS_MAXVER); MODULE_VERSION(ichsmb, 1); +; diff --git a/sys/dev/ichsmb/ichsmb_var.h b/sys/dev/ichsmb/ichsmb_var.h index d8def6d..a7d0dcb 100644 --- a/sys/dev/ichsmb/ichsmb_var.h +++ b/sys/dev/ichsmb/ichsmb_var.h @@ -48,6 +48,7 @@ struct ichsmb_softc { /* Device/bus stuff */ device_t dev; /* this device */ + device_t smb; /* smb device */ struct resource *io_res; /* i/o port resource */ int io_rid; /* i/o port bus id */ bus_space_tag_t io_bst; /* bus space tag */ @@ -85,6 +86,7 @@ extern void ichsmb_device_intr(void *cookie); extern void ichsmb_release_resources(sc_p sc); extern int ichsmb_probe(device_t dev); extern int ichsmb_attach(device_t dev); +extern int ichsmb_detach(device_t dev); #endif /* _DEV_ICHSMB_ICHSMB_VAR_H */ |