diff options
author | Miod Vallat <miod@cvs.openbsd.org> | 2006-01-21 12:18:50 +0000 |
---|---|---|
committer | Miod Vallat <miod@cvs.openbsd.org> | 2006-01-21 12:18:50 +0000 |
commit | 4beeeb807c32f82be0cbea3575a39a581c703b00 (patch) | |
tree | 8710bab9d5a179ff6e2bbd4d70ee28c03ff08552 | |
parent | 5753cb9ef99c0f2c418a4a77f544a1ab2c879e2f (diff) |
Invoke disk_detach() and related cleanup work in detach(), rather than
zeroref() - just to be on the safe side, should we mess up our ref count.
-rw-r--r-- | sys/dev/ata/wd.c | 17 | ||||
-rw-r--r-- | sys/scsi/cd.c | 18 | ||||
-rw-r--r-- | sys/scsi/scsiconf.c | 21 | ||||
-rw-r--r-- | sys/scsi/sd.c | 18 |
4 files changed, 24 insertions, 50 deletions
diff --git a/sys/dev/ata/wd.c b/sys/dev/ata/wd.c index 89fb2089b52..640cb8f727b 100644 --- a/sys/dev/ata/wd.c +++ b/sys/dev/ata/wd.c @@ -1,4 +1,4 @@ -/* $OpenBSD: wd.c,v 1.45 2005/11/09 19:05:48 uwe Exp $ */ +/* $OpenBSD: wd.c,v 1.46 2006/01/21 12:18:47 miod Exp $ */ /* $NetBSD: wd.c,v 1.193 1999/02/28 17:15:27 explorer Exp $ */ /* @@ -182,12 +182,11 @@ int wdprobe(struct device *, void *, void *); void wdattach(struct device *, struct device *, void *); int wddetach(struct device *, int); int wdactivate(struct device *, enum devact); -void wdzeroref(struct device *); int wdprint(void *, char *); struct cfattach wd_ca = { sizeof(struct wd_softc), wdprobe, wdattach, - wddetach, wdactivate, wdzeroref + wddetach, wdactivate }; #ifdef __OpenBSD__ @@ -445,6 +444,9 @@ wddetach(struct device *self, int flags) if (sc->sc_sdhook != NULL) shutdownhook_disestablish(sc->sc_sdhook); + /* Detach disk. */ + disk_detach(&sc->sc_dk); + #if NRND > 0 /* Unhook the entropy source. */ rnd_detach_source(&sc->rnd_source); @@ -453,15 +455,6 @@ wddetach(struct device *self, int flags) return (0); } -void -wdzeroref(struct device *self) -{ - struct wd_softc *sc = (struct wd_softc *)self; - - /* Detach disk. */ - disk_detach(&sc->sc_dk); -} - /* * Read/write routine for a buffer. Validates the arguments and schedules the * transfer. Does not wait for the transfer to complete. diff --git a/sys/scsi/cd.c b/sys/scsi/cd.c index d31e6f80c65..750429f9418 100644 --- a/sys/scsi/cd.c +++ b/sys/scsi/cd.c @@ -1,4 +1,4 @@ -/* $OpenBSD: cd.c,v 1.103 2006/01/17 20:22:22 miod Exp $ */ +/* $OpenBSD: cd.c,v 1.104 2006/01/21 12:18:49 miod Exp $ */ /* $NetBSD: cd.c,v 1.100 1997/04/02 02:29:30 mycroft Exp $ */ /* @@ -100,7 +100,6 @@ int cdmatch(struct device *, void *, void *); void cdattach(struct device *, struct device *, void *); int cdactivate(struct device *, enum devact); int cddetach(struct device *, int); -void cdzeroref(struct device *); void cdstart(void *); void cdminphys(struct buf *); @@ -136,7 +135,7 @@ int dvd_read_struct(struct cd_softc *, union dvd_struct *); struct cfattach cd_ca = { sizeof(struct cd_softc), cdmatch, cdattach, - cddetach, cdactivate, cdzeroref + cddetach, cdactivate }; struct cfdriver cd_cd = { @@ -277,19 +276,12 @@ cddetach(self, flags) for (cmaj = 0; cmaj < nchrdev; cmaj++) if (cdevsw[cmaj].d_open == cdopen) vdevgone(cmaj, mn, mn + MAXPARTITIONS - 1, VCHR); - return (0); -} - -void -cdzeroref(self) - struct device *self; -{ - struct cd_softc *cd = (struct cd_softc *)self; /* Detach disk. */ - disk_detach(&cd->sc_dk); -} + disk_detach(&sc->sc_dk); + return (0); +} /* * Open the device. Make sure the partition info is as up-to-date as can be. diff --git a/sys/scsi/scsiconf.c b/sys/scsi/scsiconf.c index 9d2750dd769..7eb632a4ba4 100644 --- a/sys/scsi/scsiconf.c +++ b/sys/scsi/scsiconf.c @@ -1,4 +1,4 @@ -/* $OpenBSD: scsiconf.c,v 1.99 2006/01/18 19:54:49 krw Exp $ */ +/* $OpenBSD: scsiconf.c,v 1.100 2006/01/21 12:18:49 miod Exp $ */ /* $NetBSD: scsiconf.c,v 1.57 1996/05/02 01:09:01 neil Exp $ */ /* @@ -89,7 +89,6 @@ int scsibusmatch(struct device *, void *, void *); void scsibusattach(struct device *, struct device *, void *); int scsibusactivate(struct device *, enum devact); int scsibusdetach(struct device *, int); -void scsibuszeroref(struct device *); int scsibussubmatch(struct device *, void *, void *); @@ -97,7 +96,7 @@ int scsibussubmatch(struct device *, void *, void *); struct cfattach scsibus_ca = { sizeof(struct scsibus_softc), scsibusmatch, scsibusattach, - scsibusdetach, scsibusactivate, scsibuszeroref + scsibusdetach, scsibusactivate }; struct cfdriver scsibus_cd = { @@ -192,19 +191,15 @@ scsibusactivate(dev, act) } int -scsibusdetach (dev, type) +scsibusdetach(dev, type) struct device *dev; int type; { - return (config_detach_children(dev, type)); -} - -void -scsibuszeroref(dev) - struct device *dev; -{ struct scsibus_softc *sb = (struct scsibus_softc *)dev; - int i; + int i, error; + + if ((error = config_detach_children(dev, type)) != 0) + return (error); for (i = 0; i < sb->sc_buswidth; i++) { if (sb->sc_link[i] != NULL) @@ -212,6 +207,8 @@ scsibuszeroref(dev) } free(sb->sc_link, M_DEVBUF); + + return (0); } diff --git a/sys/scsi/sd.c b/sys/scsi/sd.c index ebf18ab7be3..c2c13b249ea 100644 --- a/sys/scsi/sd.c +++ b/sys/scsi/sd.c @@ -1,4 +1,4 @@ -/* $OpenBSD: sd.c,v 1.100 2005/11/17 23:58:41 miod Exp $ */ +/* $OpenBSD: sd.c,v 1.101 2006/01/21 12:18:49 miod Exp $ */ /* $NetBSD: sd.c,v 1.111 1997/04/02 02:29:41 mycroft Exp $ */ /*- @@ -93,7 +93,6 @@ int sdmatch(struct device *, void *, void *); void sdattach(struct device *, struct device *, void *); int sdactivate(struct device *, enum devact); int sddetach(struct device *, int); -void sdzeroref(struct device *); void sdminphys(struct buf *); void sdgetdisklabel(dev_t, struct sd_softc *, struct disklabel *, @@ -110,7 +109,7 @@ void viscpy(u_char *, u_char *, int); struct cfattach sd_ca = { sizeof(struct sd_softc), sdmatch, sdattach, - sddetach, sdactivate, sdzeroref + sddetach, sdactivate }; struct cfdriver sd_cd = { @@ -315,6 +314,9 @@ sddetach(self, flags) if (sc->sc_sdhook != NULL) shutdownhook_disestablish(sc->sc_sdhook); + /* Detach disk. */ + disk_detach(&sc->sc_dk); + #if NRND > 0 /* Unhook the entropy source. */ rnd_detach_source(&sc->rnd_source); @@ -323,16 +325,6 @@ sddetach(self, flags) return (0); } -void -sdzeroref(self) - struct device *self; -{ - struct sd_softc *sd = (struct sd_softc *)self; - - /* Detach disk. */ - disk_detach(&sd->sc_dk); -} - /* * Open the device. Make sure the partition info is as up-to-date as can be. */ |