From 2405d5b1d140e655feb9dfc571e61d68b6e37ea6 Mon Sep 17 00:00:00 2001 From: Theo de Raadt Date: Sun, 19 Jun 2011 04:35:07 +0000 Subject: Use disk_lock/disk_unlock directly and in the same way in these drivers, rather than using various wrappings. Convert vnd to using the sc_dk rwlock instead of using one of its own. ok matthew --- sys/arch/hp300/dev/hd.c | 12 +++++------- sys/arch/octeon/dev/octcf.c | 19 ++++++++----------- 2 files changed, 13 insertions(+), 18 deletions(-) (limited to 'sys/arch') diff --git a/sys/arch/hp300/dev/hd.c b/sys/arch/hp300/dev/hd.c index 6763c4c9a35..c742eb48971 100644 --- a/sys/arch/hp300/dev/hd.c +++ b/sys/arch/hp300/dev/hd.c @@ -1,4 +1,4 @@ -/* $OpenBSD: hd.c,v 1.65 2011/06/05 18:40:33 matthew Exp $ */ +/* $OpenBSD: hd.c,v 1.66 2011/06/19 04:35:06 deraadt Exp $ */ /* $NetBSD: rd.c,v 1.33 1997/07/10 18:14:08 kleink Exp $ */ /* @@ -263,8 +263,6 @@ struct cfdriver hd_cd = { NULL, "hd", DV_DISK }; -#define hdlock(rs) disk_lock(&(rs)->sc_dkdev) -#define hdunlock(rs) disk_unlock(&(rs)->sc_dkdev) #define hdlookup(unit) (struct hd_softc *)device_lookup(&hd_cd, (unit)) int @@ -546,7 +544,7 @@ hdopen(dev, flags, mode, p) return (error); } - if ((error = hdlock(rs)) != 0) { + if ((error = disk_lock(&rs->sc_dkdev)) != 0) { device_unref(&rs->sc_dev); return (error); } @@ -589,7 +587,7 @@ hdopen(dev, flags, mode, p) error = 0; out: - hdunlock(rs); + disk_unlock(&rs->sc_dkdev); device_unref(&rs->sc_dev); return (error); } @@ -610,7 +608,7 @@ hdclose(dev, flag, mode, p) if (rs == NULL) return (ENXIO); - if ((error = hdlock(rs)) != 0) { + if ((error = disk_lock(&rs->sc_dkdev)) != 0) { device_unref(&rs->sc_dev); return (error); } @@ -644,7 +642,7 @@ hdclose(dev, flag, mode, p) rs->sc_flags &= ~(HDF_CLOSING); } - hdunlock(rs); + disk_unlock(&rs->sc_dkdev); device_unref(&rs->sc_dev); return (0); } diff --git a/sys/arch/octeon/dev/octcf.c b/sys/arch/octeon/dev/octcf.c index cce7fc391f1..208fcff2b82 100644 --- a/sys/arch/octeon/dev/octcf.c +++ b/sys/arch/octeon/dev/octcf.c @@ -1,4 +1,4 @@ -/* $OpenBSD: octcf.c,v 1.4 2011/06/05 18:40:33 matthew Exp $ */ +/* $OpenBSD: octcf.c,v 1.5 2011/06/19 04:35:06 deraadt Exp $ */ /* $NetBSD: wd.c,v 1.193 1999/02/28 17:15:27 explorer Exp $ */ /* @@ -145,9 +145,6 @@ void octcfdone(void *); cdev_decl(octcf); bdev_decl(octcf); -#define octcflock(wd) disk_lock(&(wd)->sc_dk) -#define octcfunlock(wd) disk_unlock(&(wd)->sc_dk) - #define octcflookup(unit) (struct octcf_softc *)disk_lookup(&octcf_cd, (unit)) int octcf_write_sectors(struct octcf_softc *, uint32_t, uint32_t, void *); @@ -443,7 +440,7 @@ octcfopen(dev_t dev, int flag, int fmt, struct proc *p) * If this is the first open of this device, add a reference * to the adapter. */ - if ((error = octcflock(wd)) != 0) + if ((error = disk_lock(&wd->sc_dk)) != 0) goto bad4; if (wd->sc_dk.dk_openmask != 0) { @@ -493,7 +490,7 @@ octcfopen(dev_t dev, int flag, int fmt, struct proc *p) wd->sc_dk.dk_openmask = wd->sc_dk.dk_copenmask | wd->sc_dk.dk_bopenmask; - octcfunlock(wd); + disk_unlock(&wd->sc_dk); device_unref(&wd->sc_dev); return 0; @@ -502,7 +499,7 @@ bad: } bad3: - octcfunlock(wd); + disk_unlock(&wd->sc_dk); bad4: device_unref(&wd->sc_dev); return error; @@ -520,7 +517,7 @@ octcfclose(dev_t dev, int flag, int fmt, struct proc *p) return ENXIO; OCTCFDEBUG_PRINT(("octcfclose\n"), DEBUG_FUNCS); - if ((error = octcflock(wd)) != 0) + if ((error = disk_lock(&wd->sc_dk)) != 0) goto exit; switch (fmt) { @@ -534,7 +531,7 @@ octcfclose(dev_t dev, int flag, int fmt, struct proc *p) wd->sc_dk.dk_openmask = wd->sc_dk.dk_copenmask | wd->sc_dk.dk_bopenmask; - octcfunlock(wd); + disk_unlock(&wd->sc_dk); exit: device_unref(&wd->sc_dev); @@ -630,7 +627,7 @@ octcfioctl(dev_t dev, u_long xfer, caddr_t addr, int flag, struct proc *p) goto exit; } - if ((error = octcflock(wd)) != 0) + if ((error = disk_lock(&wd->sc_dk)) != 0) goto exit; error = setdisklabel(wd->sc_dk.dk_label, @@ -641,7 +638,7 @@ octcfioctl(dev_t dev, u_long xfer, caddr_t addr, int flag, struct proc *p) octcfstrategy, wd->sc_dk.dk_label); } - octcfunlock(wd); + disk_unlock(&wd->sc_dk); goto exit; #ifdef notyet -- cgit v1.2.3