From f9d517f0edb4be18e55c9d2d021faf605914e20c Mon Sep 17 00:00:00 2001 From: phk Date: Sat, 1 Feb 2003 11:17:22 +0000 Subject: [PATCH] Eliminate the sc_openmask, ccdopen() and ccdclose() functions, we can use the flag maintained by geom_disk.c Having only a strategy method to intialize, don't waste space using a cdevsw structure to do so. --- sys/dev/ccd/ccd.c | 52 ++++++--------------------------------------- sys/geom/geom_ccd.c | 52 ++++++--------------------------------------- sys/sys/ccdvar.h | 1 - 3 files changed, 12 insertions(+), 93 deletions(-) diff --git a/sys/dev/ccd/ccd.c b/sys/dev/ccd/ccd.c index 75694202d50d..f0cbb06c3008 100644 --- a/sys/dev/ccd/ccd.c +++ b/sys/dev/ccd/ccd.c @@ -107,8 +107,6 @@ struct ccdbuf { static dev_t ccdctldev; -static d_open_t ccdopen; -static d_close_t ccdclose; static d_strategy_t ccdstrategy; static d_ioctl_t ccdctlioctl; @@ -132,24 +130,6 @@ static struct cdevsw ccdctl_cdevsw = { /* flags */ 0 }; -static struct cdevsw ccd_cdevsw = { - /* open */ ccdopen, - /* close */ ccdclose, - /* read */ physread, - /* write */ physwrite, - /* ioctl */ noioctl, - /* poll */ nopoll, - /* mmap */ nommap, - /* strategy */ ccdstrategy, - /* name */ "ccd", - /* maj */ CDEV_MAJOR, - /* dump */ nodump, - /* psize */ nopsize, - /* flags */ D_DISK, -}; - -static struct cdevsw ccddisk_cdevsw; - static LIST_HEAD(, ccd_s) ccd_softc_list = LIST_HEAD_INITIALIZER(&ccd_softc_list); @@ -550,27 +530,6 @@ ccdinterleave(struct ccd_s *cs, int unit) } } -static int -ccdopen(dev_t dev, int flags, int fmt, struct thread *td) -{ - struct ccd_s *cs; - - cs = dev->si_drv1; - cs->sc_openmask = 1; - return (0); -} - -/* ARGSUSED */ -static int -ccdclose(dev_t dev, int flags, int fmt, struct thread *td) -{ - struct ccd_s *cs; - - cs = dev->si_drv1; - cs->sc_openmask = 0; - return (0); -} - static void ccdstrategy(struct bio *bp) { @@ -1164,16 +1123,17 @@ ccdioctltoo(int unit, u_long cmd, caddr_t data, int flag, struct thread *td) */ ccio->ccio_unit = unit; ccio->ccio_size = cs->sc_size; - cs->sc_disk = malloc(sizeof(struct disk), M_CCD, 0); - cs->sc_dev = disk_create(unit, cs->sc_disk, 0, - &ccd_cdevsw, &ccddisk_cdevsw); - cs->sc_dev->si_drv1 = cs; ccg = &cs->sc_geom; + cs->sc_disk = malloc(sizeof(struct disk), M_CCD, M_ZERO); + cs->sc_disk->d_strategy = ccdstrategy; + cs->sc_disk->d_name = "ccd"; cs->sc_disk->d_sectorsize = ccg->ccg_secsize; cs->sc_disk->d_mediasize = cs->sc_size * (off_t)ccg->ccg_secsize; cs->sc_disk->d_fwsectors = ccg->ccg_nsectors; cs->sc_disk->d_fwheads = ccg->ccg_ntracks; + cs->sc_dev = disk_create(unit, cs->sc_disk, 0, NULL, NULL); + cs->sc_dev->si_drv1 = cs; ccdunlock(cs); @@ -1193,7 +1153,7 @@ ccdioctltoo(int unit, u_long cmd, caddr_t data, int flag, struct thread *td) return (error); /* Don't unconfigure if any other partitions are open */ - if (cs->sc_openmask) { + if (cs->sc_disk->d_flags & DISKFLAG_OPEN) { ccdunlock(cs); return (EBUSY); } diff --git a/sys/geom/geom_ccd.c b/sys/geom/geom_ccd.c index 75694202d50d..f0cbb06c3008 100644 --- a/sys/geom/geom_ccd.c +++ b/sys/geom/geom_ccd.c @@ -107,8 +107,6 @@ struct ccdbuf { static dev_t ccdctldev; -static d_open_t ccdopen; -static d_close_t ccdclose; static d_strategy_t ccdstrategy; static d_ioctl_t ccdctlioctl; @@ -132,24 +130,6 @@ static struct cdevsw ccdctl_cdevsw = { /* flags */ 0 }; -static struct cdevsw ccd_cdevsw = { - /* open */ ccdopen, - /* close */ ccdclose, - /* read */ physread, - /* write */ physwrite, - /* ioctl */ noioctl, - /* poll */ nopoll, - /* mmap */ nommap, - /* strategy */ ccdstrategy, - /* name */ "ccd", - /* maj */ CDEV_MAJOR, - /* dump */ nodump, - /* psize */ nopsize, - /* flags */ D_DISK, -}; - -static struct cdevsw ccddisk_cdevsw; - static LIST_HEAD(, ccd_s) ccd_softc_list = LIST_HEAD_INITIALIZER(&ccd_softc_list); @@ -550,27 +530,6 @@ ccdinterleave(struct ccd_s *cs, int unit) } } -static int -ccdopen(dev_t dev, int flags, int fmt, struct thread *td) -{ - struct ccd_s *cs; - - cs = dev->si_drv1; - cs->sc_openmask = 1; - return (0); -} - -/* ARGSUSED */ -static int -ccdclose(dev_t dev, int flags, int fmt, struct thread *td) -{ - struct ccd_s *cs; - - cs = dev->si_drv1; - cs->sc_openmask = 0; - return (0); -} - static void ccdstrategy(struct bio *bp) { @@ -1164,16 +1123,17 @@ ccdioctltoo(int unit, u_long cmd, caddr_t data, int flag, struct thread *td) */ ccio->ccio_unit = unit; ccio->ccio_size = cs->sc_size; - cs->sc_disk = malloc(sizeof(struct disk), M_CCD, 0); - cs->sc_dev = disk_create(unit, cs->sc_disk, 0, - &ccd_cdevsw, &ccddisk_cdevsw); - cs->sc_dev->si_drv1 = cs; ccg = &cs->sc_geom; + cs->sc_disk = malloc(sizeof(struct disk), M_CCD, M_ZERO); + cs->sc_disk->d_strategy = ccdstrategy; + cs->sc_disk->d_name = "ccd"; cs->sc_disk->d_sectorsize = ccg->ccg_secsize; cs->sc_disk->d_mediasize = cs->sc_size * (off_t)ccg->ccg_secsize; cs->sc_disk->d_fwsectors = ccg->ccg_nsectors; cs->sc_disk->d_fwheads = ccg->ccg_ntracks; + cs->sc_dev = disk_create(unit, cs->sc_disk, 0, NULL, NULL); + cs->sc_dev->si_drv1 = cs; ccdunlock(cs); @@ -1193,7 +1153,7 @@ ccdioctltoo(int unit, u_long cmd, caddr_t data, int flag, struct thread *td) return (error); /* Don't unconfigure if any other partitions are open */ - if (cs->sc_openmask) { + if (cs->sc_disk->d_flags & DISKFLAG_OPEN) { ccdunlock(cs); return (EBUSY); } diff --git a/sys/sys/ccdvar.h b/sys/sys/ccdvar.h index 5ef975a74cfa..63c17fd283fe 100644 --- a/sys/sys/ccdvar.h +++ b/sys/sys/ccdvar.h @@ -170,7 +170,6 @@ struct ccd_s { struct ccdiinfo *sc_itable; /* interleave table */ struct devstat device_stats; /* device statistics */ struct ccdgeom sc_geom; /* pseudo geometry info */ - int sc_openmask; int sc_pick; /* side of mirror picked */ daddr_t sc_blk[2]; /* mirror localization */ struct disk *sc_disk;