Index: fdc.c =================================================================== RCS file: /pool/ncvs/src/sys/dev/fdc/fdc.c,v retrieving revision 1.313 diff -u -r1.313 fdc.c --- fdc.c 8 Sep 2006 21:46:00 -0000 1.313 +++ fdc.c 6 Nov 2006 11:26:40 -0000 @@ -426,7 +426,7 @@ step += step; DELAY(step); } - return (fdc_err(fdc, bootverbose? "input ready timeout\n": 0)); + return (fdc_err(fdc, bootverbose? "input ready timeout\n": NULL)); } static int @@ -446,7 +446,7 @@ step += step; DELAY(step); } - return (fdc_err(fdc, bootverbose? "output ready timeout\n": 0)); + return (fdc_err(fdc, bootverbose? "output ready timeout\n": NULL)); } /* @@ -470,7 +470,7 @@ i = va_arg(ap, int); if (n == 0) cmd = i; - if (fdc_out(fdc, i) < 0) { + if (fdc_out(fdc, i)) { char msg[50]; snprintf(msg, sizeof(msg), "cmd %x failed at out byte %d of %d\n", @@ -483,7 +483,7 @@ n_in = va_arg(ap, int); for (n = 0; n < n_in; n++) { int *ptr = va_arg(ap, int *); - if (fdc_in(fdc, ptr) < 0) { + if (fdc_in(fdc, ptr)) { char msg[50]; snprintf(msg, sizeof(msg), "cmd %02x failed at in byte %d of %d\n", @@ -577,7 +577,7 @@ return (FD_NOT_VALID); } - if (fdc_in(fdc, &cyl) < 0) + if (fdc_in(fdc, &cyl)) return fdc_err(fdc, "can't get cyl num\n"); if (cylp) @@ -1014,7 +1014,7 @@ fdc_pio(fdc); } - switch(bp->bio_cmd) { + switch (bp->bio_cmd) { case BIO_FMT: /* formatting */ finfo = (struct fd_formb *)bp->bio_data; @@ -1142,7 +1142,7 @@ return (1); } /* All OK */ - switch(bp->bio_cmd) { + switch (bp->bio_cmd) { case BIO_RDID: /* copy out ID field contents */ idp = (struct fdc_readid *)bp->bio_data; @@ -1537,9 +1537,7 @@ break; } return (error); -}; - - +} /* * Configuration/initialization stuff, per controller. @@ -1998,16 +1996,24 @@ fd_detach(device_t dev) { struct fd_data *fd; + struct g_provider *gp; + int error; + error = 0; fd = device_get_softc(dev); + DROP_GIANT(); g_topology_lock(); - g_wither_geom(fd->fd_geom, ENXIO); + gp = fd->fd_provider; + KASSERT(gp != NULL, ("NULL provider")); + if (gp->acr > 0 || gp->acw > 0 || gp->ace > 0) + error = EBUSY; + if (error == 0) + g_wither_geom(fd->fd_geom, ENXIO); g_topology_unlock(); - while (device_get_state(dev) == DS_BUSY) - tsleep(fd, PZERO, "fdd", hz/10); callout_drain(&fd->toffhandle); + PICKUP_GIANT(); - return (0); + return (error); } static device_method_t fd_methods[] = { @@ -2031,8 +2037,7 @@ fdc_modevent(module_t mod, int type, void *data) { - g_modevent(NULL, type, &g_fd_class); - return (0); + return (g_modevent(NULL, type, &g_fd_class)); } DRIVER_MODULE(fd, fdc, fd_driver, fd_devclass, fdc_modevent, 0);