diff options
author | Niklas Hallqvist <niklas@cvs.openbsd.org> | 1999-07-23 19:45:22 +0000 |
---|---|---|
committer | Niklas Hallqvist <niklas@cvs.openbsd.org> | 1999-07-23 19:45:22 +0000 |
commit | c8f08420587e97d8e537a9a23a659d29d2d6adeb (patch) | |
tree | 675b42dd6b484f9277d8b69d4a3224f813fe0025 /sys | |
parent | 6d89a7d3896371689f01fe0fe591445d13161564 (diff) |
Remove obsolete detach logic in preparation of a newer one
Diffstat (limited to 'sys')
-rw-r--r-- | sys/kern/subr_autoconf.c | 145 | ||||
-rw-r--r-- | sys/sys/device.h | 9 |
2 files changed, 8 insertions, 146 deletions
diff --git a/sys/kern/subr_autoconf.c b/sys/kern/subr_autoconf.c index c7b5c014a44..866e1c9979a 100644 --- a/sys/kern/subr_autoconf.c +++ b/sys/kern/subr_autoconf.c @@ -1,4 +1,4 @@ -/* $OpenBSD: subr_autoconf.c,v 1.22 1999/01/11 05:12:23 millert Exp $ */ +/* $OpenBSD: subr_autoconf.c,v 1.23 1999/07/23 19:45:21 niklas Exp $ */ /* $NetBSD: subr_autoconf.c,v 1.21 1996/04/04 06:06:18 cgd Exp $ */ /* @@ -94,12 +94,6 @@ int autoconf_verbose = AUTOCONF_VERBOSE; /* trace probe calls */ static char *number __P((char *, int)); static void mapply __P((struct matchinfo *, struct cfdata *)); -static int haschild __P((struct device *)); -int detach_devices __P((cond_predicate_t, void *, - config_detach_callback_t, void *)); -int dev_matches_cfdata __P((struct device *dev, void *)); -int parentdev_matches_cfdata __P((struct device *dev, void *)); - struct devicelist alldevs; /* list of all devices */ struct evcntlist allevents; /* list of all event counters */ @@ -528,137 +522,7 @@ evcnt_attach(dev, name, ev) TAILQ_INSERT_TAIL(&allevents, ev, ev_list); } -static int -haschild(dev) - struct device *dev; -{ - struct device *d; - - for (d = alldevs.tqh_first; d != NULL; d = d->dv_list.tqe_next) { - if (d->dv_parent == dev) - return(1); - } - return(0); -} - -int -detach_devices(cond, condarg, callback, arg) - cond_predicate_t cond; - void *condarg; - config_detach_callback_t callback; - void *arg; -{ - struct device *d; - int alldone = 1; - - /* - * XXX should use circleq and run around the list backwards - * to allow for predicates to match children. - */ - d = alldevs.tqh_first; - while (d != NULL) { - if ((*cond)(d, condarg)) { - struct cfdriver *drv = d->dv_cfdata->cf_driver; - - /* device not busy? */ - /* driver's detach routine decides, upper - layer (eg bus dependent code) is notified - via callback */ -#ifdef DEBUG - printf("trying to detach device %s (%p)\n", - d->dv_xname, d); -#endif - if (!haschild(d) && - d->dv_cfdata->cf_attach->ca_detach && - ((*(d->dv_cfdata->cf_attach->ca_detach))(d)) == 0) { - int needit, i; - struct device *help; - - if (callback) - (*callback)(d, arg); - - /* remove reference in driver's devicelist */ - if ((d->dv_unit >= drv->cd_ndevs) || - (drv->cd_devs[d->dv_unit]!=d)) - panic("bad unit in detach_devices"); - drv->cd_devs[d->dv_unit] = NULL; - - /* driver is not needed anymore? */ - needit = 0; - for(i = 0; i<drv->cd_ndevs; i++) - if (drv->cd_devs[i]) - needit = 1; - - if (!needit) { - /* free devices array (alloc'd - in config_make_softc) */ - free(drv->cd_devs, M_DEVBUF); - drv->cd_ndevs = 0; - } - - /* remove entry in global device list */ - help = d->dv_list.tqe_next; - TAILQ_REMOVE(&alldevs, d, dv_list); -#ifdef DEBUG - printf("%s removed\n", d->dv_xname); -#endif - if (d->dv_cfdata->cf_fstate == FSTATE_FOUND) - d->dv_cfdata->cf_fstate = - FSTATE_NOTFOUND; - /* free memory for dev data (alloc'd - in config_make_softc) */ - free(d, M_DEVBUF); - d = help; - continue; - } else - alldone = 0; - } - d = d->dv_list.tqe_next; - } - return (!alldone); -} - -int -dev_matches_cfdata(dev, arg) - struct device *dev; - void *arg; -{ - struct cfdata *cfdata = arg; - return(/* device uses same driver ? */ - (dev->dv_cfdata->cf_driver == cfdata->cf_driver) - /* device instance described by this cfdata? */ - && ((cfdata->cf_fstate == FSTATE_STAR) - || ((cfdata->cf_fstate == FSTATE_FOUND) - && (dev->dv_unit == cfdata->cf_unit))) - ); -} - -int -parentdev_matches_cfdata(dev, arg) - struct device *dev; - void *arg; -{ - return (dev->dv_parent ? dev_matches_cfdata(dev->dv_parent, arg) : 0); -} - -int -config_detach(cf, callback, arg) - struct cfdata *cf; - config_detach_callback_t callback; - void *arg; -{ - return (detach_devices(dev_matches_cfdata, cf, callback, arg)); -} - -int -config_detach_children(cf, callback, arg) - struct cfdata *cf; - config_detach_callback_t callback; - void *arg; -{ - return (detach_devices(parentdev_matches_cfdata, cf, callback, arg)); -} - +#if 0 int attach_loadable(parentname, parentunit, cftable) char *parentname; @@ -688,10 +552,10 @@ attach_loadable(parentname, parentunit, cftable) return(found); } -static int +int devcf_intable __P((struct device *, void *)); -static int +int devcf_intable(dev, arg) struct device *dev; void *arg; @@ -715,3 +579,4 @@ detach_loadable(cftable) TAILQ_REMOVE(&allcftables, cftable, list); return(1); } +#endif diff --git a/sys/sys/device.h b/sys/sys/device.h index 017a585611c..a7980629246 100644 --- a/sys/sys/device.h +++ b/sys/sys/device.h @@ -1,4 +1,4 @@ -/* $OpenBSD: device.h,v 1.14 1999/04/28 18:01:22 deraadt Exp $ */ +/* $OpenBSD: device.h,v 1.15 1999/07/23 19:45:20 niklas Exp $ */ /* $NetBSD: device.h,v 1.15 1996/04/09 20:55:24 cgd Exp $ */ /* @@ -185,13 +185,10 @@ void evcnt_attach __P((struct device *, const char *, struct evcnt *)); /* compatibility definitions */ #define config_found(d, a, p) config_found_sm((d), (a), (p), NULL) +#if 0 extern int attach_loadable __P((char *, int, struct cftable *)); extern int detach_loadable __P((struct cftable *)); -typedef void (*config_detach_callback_t) __P((struct device *, void *)); -extern int config_detach __P((struct cfdata *, config_detach_callback_t, - void *)); -extern int config_detach_children __P((struct cfdata *, - config_detach_callback_t, void *)); +#endif #endif /* _KERNEL */ |