From 024ebcc52b509051395cceb59fa99050e956b50c Mon Sep 17 00:00:00 2001 From: takawata Date: Fri, 10 Jun 2005 16:12:43 +0000 Subject: Make ichsmb(4) child device handling properly. --- sys/dev/ichsmb/ichsmb.c | 30 ++++++++++++++++++++++-------- 1 file changed, 22 insertions(+), 8 deletions(-) (limited to 'sys/dev/ichsmb/ichsmb.c') 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 +} -- cgit v1.1