From 0b7ed341e106c1583e873116529015d2ae042fd0 Mon Sep 17 00:00:00 2001 From: Poul-Henning Kamp Date: Wed, 18 Feb 2004 21:36:53 +0000 Subject: Change the disk(9) API in order to make device removal more robust. Previously the "struct disk" were owned by the device driver and this gave us problems when the device disappared and the users of that device were not immediately disappearing. Now the struct disk is allocate with a new call, disk_alloc() and owned by geom_disk and just abandonned by the device driver when disk_create() is called. Unfortunately, this results in a ton of "s/\./->/" changes to device drivers. Since I'm doing the sweep anyway, a couple of other API improvements have been carried out at the same time: The Giant awareness flag has been flipped from DISKFLAG_NOGIANT to DISKFLAG_NEEDSGIANT A version number have been added to disk_create() so that we can detect, report and ignore binary drivers with old ABI in the future. Manual page update to follow shortly. --- sys/dev/ofw/ofw_disk.c | 23 +++++++++++++---------- 1 file changed, 13 insertions(+), 10 deletions(-) (limited to 'sys/dev/ofw') diff --git a/sys/dev/ofw/ofw_disk.c b/sys/dev/ofw/ofw_disk.c index 8d4ae8238157..f3e143a731cb 100644 --- a/sys/dev/ofw/ofw_disk.c +++ b/sys/dev/ofw/ofw_disk.c @@ -48,7 +48,7 @@ __FBSDID("$FreeBSD$"); struct ofwd_softc { device_t ofwd_dev; - struct disk ofwd_disk; + struct disk *ofwd_disk; phandle_t ofwd_package; ihandle_t ofwd_instance; }; @@ -203,15 +203,18 @@ ofwd_attach(device_t dev) return (ENXIO); } - sc->ofwd_disk.d_strategy = ofwd_strategy; - sc->ofwd_disk.d_name = "ofwd"; - sc->ofwd_disk.d_sectorsize = OFWD_BLOCKSIZE; - sc->ofwd_disk.d_mediasize = (off_t)33554432 * OFWD_BLOCKSIZE; - sc->ofwd_disk.d_fwsectors = 0; - sc->ofwd_disk.d_fwheads = 0; - sc->ofwd_disk.d_drv1 = sc; - sc->ofwd_disk.d_maxsize = PAGE_SIZE; - disk_create(device_get_unit(dev), &sc->ofwd_disk, 0, NULL, NULL); + sc->ofwd_disk = disk_alloc(); + sc->ofwd_disk->d_strategy = ofwd_strategy; + sc->ofwd_disk->d_name = "ofwd"; + sc->ofwd_disk->d_sectorsize = OFWD_BLOCKSIZE; + sc->ofwd_disk->d_mediasize = (off_t)33554432 * OFWD_BLOCKSIZE; + sc->ofwd_disk->d_fwsectors = 0; + sc->ofwd_disk->d_fwheads = 0; + sc->ofwd_disk->d_drv1 = sc; + sc->ofwd_disk->d_maxsize = PAGE_SIZE; + sc->ofwd_disk->d_unit = device_get_unit(dev); + sc->ofwd_disk->d_flags = DISKFLAG_NEEDSGIANT; + disk_create(sc->ofwd_disk, DISK_VERSION); return (0); } -- cgit v1.3