summaryrefslogtreecommitdiff
path: root/sys
diff options
context:
space:
mode:
authorTheo de Raadt <deraadt@cvs.openbsd.org>2011-06-19 04:35:07 +0000
committerTheo de Raadt <deraadt@cvs.openbsd.org>2011-06-19 04:35:07 +0000
commit2405d5b1d140e655feb9dfc571e61d68b6e37ea6 (patch)
treed136b630b8820c10350ab8c7df7f32c87f09533a /sys
parente432fec524dc96ce4d87b45a1c6f2da98be595b7 (diff)
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
Diffstat (limited to 'sys')
-rw-r--r--sys/arch/hp300/dev/hd.c12
-rw-r--r--sys/arch/octeon/dev/octcf.c19
-rw-r--r--sys/dev/ata/wd.c18
-rw-r--r--sys/dev/flash.c18
-rw-r--r--sys/dev/vnd.c41
-rw-r--r--sys/scsi/cd.c20
-rw-r--r--sys/scsi/sd.c16
7 files changed, 63 insertions, 81 deletions
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
diff --git a/sys/dev/ata/wd.c b/sys/dev/ata/wd.c
index c24e4643394..145a42256b5 100644
--- a/sys/dev/ata/wd.c
+++ b/sys/dev/ata/wd.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: wd.c,v 1.103 2011/06/05 18:40:33 matthew Exp $ */
+/* $OpenBSD: wd.c,v 1.104 2011/06/19 04:35:06 deraadt Exp $ */
/* $NetBSD: wd.c,v 1.193 1999/02/28 17:15:27 explorer Exp $ */
/*
@@ -148,8 +148,6 @@ void wd_shutdown(void *);
cdev_decl(wd);
bdev_decl(wd);
-#define wdlock(wd) disk_lock(&(wd)->sc_dk)
-#define wdunlock(wd) disk_unlock(&(wd)->sc_dk)
#define wdlookup(unit) (struct wd_softc *)disk_lookup(&wd_cd, (unit))
@@ -666,7 +664,7 @@ wdopen(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 = wdlock(wd)) != 0)
+ if ((error = disk_lock(&wd->sc_dk)) != 0)
goto bad4;
if (wd->sc_dk.dk_openmask != 0) {
@@ -716,7 +714,7 @@ wdopen(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;
- wdunlock(wd);
+ disk_unlock(&wd->sc_dk);
device_unref(&wd->sc_dev);
return 0;
@@ -725,7 +723,7 @@ bad:
}
bad3:
- wdunlock(wd);
+ disk_unlock(&wd->sc_dk);
bad4:
device_unref(&wd->sc_dev);
return error;
@@ -743,7 +741,7 @@ wdclose(dev_t dev, int flag, int fmt, struct proc *p)
return ENXIO;
WDCDEBUG_PRINT(("wdclose\n"), DEBUG_FUNCS);
- if ((error = wdlock(wd)) != 0)
+ if ((error = disk_lock(&wd->sc_dk)) != 0)
goto exit;
switch (fmt) {
@@ -762,7 +760,7 @@ wdclose(dev_t dev, int flag, int fmt, struct proc *p)
/* XXXX Must wait for I/O to complete! */
}
- wdunlock(wd);
+ disk_unlock(&wd->sc_dk);
exit:
device_unref(&wd->sc_dev);
@@ -867,7 +865,7 @@ wdioctl(dev_t dev, u_long xfer, caddr_t addr, int flag, struct proc *p)
goto exit;
}
- if ((error = wdlock(wd)) != 0)
+ if ((error = disk_lock(&wd->sc_dk)) != 0)
goto exit;
error = setdisklabel(wd->sc_dk.dk_label,
@@ -880,7 +878,7 @@ wdioctl(dev_t dev, u_long xfer, caddr_t addr, int flag, struct proc *p)
wdstrategy, wd->sc_dk.dk_label);
}
- wdunlock(wd);
+ disk_unlock(&wd->sc_dk);
goto exit;
#ifdef notyet
diff --git a/sys/dev/flash.c b/sys/dev/flash.c
index 965052e5bfa..497ce1e659f 100644
--- a/sys/dev/flash.c
+++ b/sys/dev/flash.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: flash.c,v 1.21 2011/06/03 21:14:11 matthew Exp $ */
+/* $OpenBSD: flash.c,v 1.22 2011/06/19 04:35:03 deraadt Exp $ */
/*
* Copyright (c) 2005 Uwe Stuehler <uwe@openbsd.org>
@@ -54,8 +54,6 @@ int flash_wait_complete(struct flash_softc *);
cdev_decl(flash);
bdev_decl(flash);
-#define flashlock(sc) disk_lock(&(sc)->sc_dk)
-#define flashunlock(sc) disk_unlock(&(sc)->sc_dk)
#define flashlookup(unit) \
(struct flash_softc *)device_lookup(&flash_cd, (unit))
@@ -678,7 +676,7 @@ flashopen(dev_t dev, int oflags, int devtype, struct proc *p)
if (sc == NULL)
return ENXIO;
- if ((error = flashlock(sc)) != 0) {
+ if ((error = disk_lock(&sc->sc_dk)) != 0) {
device_unref(&sc->sc_dev);
return error;
}
@@ -698,14 +696,14 @@ flashopen(dev_t dev, int oflags, int devtype, struct proc *p)
sc->sc_flags |= FDK_SAFE;
if ((error = flashgetdisklabel(dev, sc,
sc->sc_dk.dk_label, 0)) != 0) {
- flashunlock(sc);
+ disk_unlock(&sc->sc_dk);
device_unref(&sc->sc_dev);
return error;
}
}
} else if (((sc->sc_flags & FDK_SAFE) == 0) !=
(flashsafe(dev) == 0)) {
- flashunlock(sc);
+ disk_unlock(&sc->sc_dk);
device_unref(&sc->sc_dev);
return EBUSY;
}
@@ -715,7 +713,7 @@ flashopen(dev_t dev, int oflags, int devtype, struct proc *p)
if (part != RAW_PART &&
(part >= sc->sc_dk.dk_label->d_npartitions ||
sc->sc_dk.dk_label->d_partitions[part].p_fstype == FS_UNUSED)) {
- flashunlock(sc);
+ disk_unlock(&sc->sc_dk);
device_unref(&sc->sc_dev);
return ENXIO;
}
@@ -732,7 +730,7 @@ flashopen(dev_t dev, int oflags, int devtype, struct proc *p)
sc->sc_dk.dk_openmask =
sc->sc_dk.dk_copenmask | sc->sc_dk.dk_bopenmask;
- flashunlock(sc);
+ disk_unlock(&sc->sc_dk);
device_unref(&sc->sc_dev);
return 0;
}
@@ -748,7 +746,7 @@ flashclose(dev_t dev, int fflag, int devtype, struct proc *p)
if (sc == NULL)
return ENXIO;
- if ((error = flashlock(sc)) != 0) {
+ if ((error = disk_lock(&sc->sc_dk)) != 0) {
device_unref(&sc->sc_dev);
return error;
}
@@ -770,7 +768,7 @@ flashclose(dev_t dev, int fflag, int devtype, struct proc *p)
/* XXX wait for I/O to complete? */
}
- flashunlock(sc);
+ disk_unlock(&sc->sc_dk);
device_unref(&sc->sc_dev);
return 0;
}
diff --git a/sys/dev/vnd.c b/sys/dev/vnd.c
index 75c91dab9d3..9d0199deb3d 100644
--- a/sys/dev/vnd.c
+++ b/sys/dev/vnd.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: vnd.c,v 1.128 2011/06/19 04:29:41 deraadt Exp $ */
+/* $OpenBSD: vnd.c,v 1.129 2011/06/19 04:35:03 deraadt Exp $ */
/* $NetBSD: vnd.c,v 1.26 1996/03/30 23:06:11 christos Exp $ */
/*
@@ -61,7 +61,6 @@
#include <sys/mount.h>
#include <sys/vnode.h>
#include <sys/file.h>
-#include <sys/rwlock.h>
#include <sys/uio.h>
#include <sys/conf.h>
#include <sys/dkio.h>
@@ -105,7 +104,6 @@ struct vnd_softc {
struct vnode *sc_vp; /* vnode */
struct ucred *sc_cred; /* credentials */
blf_ctx *sc_keyctx; /* key context */
- struct rwlock sc_rwlock;
};
/* sc_flags */
@@ -128,9 +126,6 @@ int vndgetdisklabel(dev_t, struct vnd_softc *, struct disklabel *, int);
void vndencrypt(struct vnd_softc *, caddr_t, size_t, daddr64_t, int);
size_t vndbdevsize(struct vnode *, struct proc *);
-#define vndlock(sc) rw_enter(&sc->sc_rwlock, RW_WRITE|RW_INTR)
-#define vndunlock(sc) rw_exit_write(&sc->sc_rwlock)
-
void
vndencrypt(struct vnd_softc *sc, caddr_t addr, size_t size, daddr64_t off,
int encrypt)
@@ -172,10 +167,10 @@ vndattach(int num)
for (i = 0; i < num; i++) {
struct vnd_softc *sc = &vnd_softc[i];
- rw_init(&sc->sc_rwlock, "vndlock");
sc->sc_dev.dv_unit = i;
snprintf(sc->sc_dev.dv_xname, sizeof(sc->sc_dev.dv_xname),
"vnd%d", i);
+ disk_construct(&sc->sc_dk);
device_ref(&sc->sc_dev);
}
numvnd = num;
@@ -194,7 +189,7 @@ vndopen(dev_t dev, int flags, int mode, struct proc *p)
return (ENXIO);
sc = &vnd_softc[unit];
- if ((error = vndlock(sc)) != 0)
+ if ((error = disk_lock(&sc->sc_dk)) != 0)
return (error);
if ((flags & FWRITE) && (sc->sc_flags & VNF_READONLY)) {
@@ -234,7 +229,7 @@ vndopen(dev_t dev, int flags, int mode, struct proc *p)
sc->sc_dk.dk_copenmask | sc->sc_dk.dk_bopenmask;
bad:
- vndunlock(sc);
+ disk_unlock(&sc->sc_dk);
return (error);
}
@@ -281,7 +276,7 @@ vndclose(dev_t dev, int flags, int mode, struct proc *p)
return (ENXIO);
sc = &vnd_softc[unit];
- if ((error = vndlock(sc)) != 0)
+ if ((error = disk_lock(&sc->sc_dk)) != 0)
return (error);
part = DISKPART(dev);
@@ -299,7 +294,7 @@ vndclose(dev_t dev, int flags, int mode, struct proc *p)
sc->sc_dk.dk_openmask =
sc->sc_dk.dk_copenmask | sc->sc_dk.dk_bopenmask;
- vndunlock(sc);
+ disk_unlock(&sc->sc_dk);
return (0);
}
@@ -487,12 +482,12 @@ vndioctl(dev_t dev, u_long cmd, caddr_t addr, int flag, struct proc *p)
if (sc->sc_flags & VNF_INITED)
return (EBUSY);
- if ((error = vndlock(sc)) != 0)
+ if ((error = disk_lock(&sc->sc_dk)) != 0)
return (error);
if ((error = copyinstr(vio->vnd_file, sc->sc_file,
sizeof(sc->sc_file), NULL))) {
- vndunlock(sc);
+ disk_unlock(&sc->sc_dk);
return (error);
}
@@ -514,7 +509,7 @@ vndioctl(dev_t dev, u_long cmd, caddr_t addr, int flag, struct proc *p)
error = vn_open(&nd, FREAD, 0);
}
if (error) {
- vndunlock(sc);
+ disk_unlock(&sc->sc_dk);
return (error);
}
@@ -525,7 +520,7 @@ vndioctl(dev_t dev, u_long cmd, caddr_t addr, int flag, struct proc *p)
if (error) {
VOP_UNLOCK(nd.ni_vp, 0, p);
vn_close(nd.ni_vp, VNDRW(sc), p->p_ucred, p);
- vndunlock(sc);
+ disk_unlock(&sc->sc_dk);
return (error);
}
sc->sc_size = vattr.va_size / sc->sc_secsize;
@@ -534,7 +529,7 @@ vndioctl(dev_t dev, u_long cmd, caddr_t addr, int flag, struct proc *p)
sc->sc_vp = nd.ni_vp;
if ((error = vndsetcred(sc, p->p_ucred)) != 0) {
(void) vn_close(nd.ni_vp, VNDRW(sc), p->p_ucred, p);
- vndunlock(sc);
+ disk_unlock(&sc->sc_dk);
return (error);
}
@@ -548,7 +543,7 @@ vndioctl(dev_t dev, u_long cmd, caddr_t addr, int flag, struct proc *p)
vio->vnd_keylen)) != 0) {
(void) vn_close(nd.ni_vp, VNDRW(sc),
p->p_ucred, p);
- vndunlock(sc);
+ disk_unlock(&sc->sc_dk);
return (error);
}
@@ -569,7 +564,7 @@ vndioctl(dev_t dev, u_long cmd, caddr_t addr, int flag, struct proc *p)
sc->sc_dk.dk_name = sc->sc_dev.dv_xname;
disk_attach(&sc->sc_dev, &sc->sc_dk);
- vndunlock(sc);
+ disk_unlock(&sc->sc_dk);
break;
@@ -577,7 +572,7 @@ vndioctl(dev_t dev, u_long cmd, caddr_t addr, int flag, struct proc *p)
if ((sc->sc_flags & VNF_INITED) == 0)
return (ENXIO);
- if ((error = vndlock(sc)) != 0)
+ if ((error = disk_lock(&sc->sc_dk)) != 0)
return (error);
/*
@@ -590,7 +585,7 @@ vndioctl(dev_t dev, u_long cmd, caddr_t addr, int flag, struct proc *p)
if ((sc->sc_dk.dk_openmask & ~pmask) ||
((sc->sc_dk.dk_bopenmask & pmask) &&
(sc->sc_dk.dk_copenmask & pmask))) {
- vndunlock(sc);
+ disk_unlock(&sc->sc_dk);
return (EBUSY);
}
@@ -605,7 +600,7 @@ vndioctl(dev_t dev, u_long cmd, caddr_t addr, int flag, struct proc *p)
/* Detach the disk. */
disk_detach(&sc->sc_dk);
- vndunlock(sc);
+ disk_unlock(&sc->sc_dk);
break;
case VNDIOCGET:
@@ -672,7 +667,7 @@ vndioctl(dev_t dev, u_long cmd, caddr_t addr, int flag, struct proc *p)
if ((flag & FWRITE) == 0)
return (EBADF);
- if ((error = vndlock(sc)) != 0)
+ if ((error = disk_lock(&sc->sc_dk)) != 0)
return (error);
error = setdisklabel(sc->sc_dk.dk_label,
@@ -683,7 +678,7 @@ vndioctl(dev_t dev, u_long cmd, caddr_t addr, int flag, struct proc *p)
vndstrategy, sc->sc_dk.dk_label);
}
- vndunlock(sc);
+ disk_unlock(&sc->sc_dk);
return (error);
default:
diff --git a/sys/scsi/cd.c b/sys/scsi/cd.c
index 9c9fb63a405..c3d07e90f1b 100644
--- a/sys/scsi/cd.c
+++ b/sys/scsi/cd.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: cd.c,v 1.202 2011/06/06 01:59:49 matthew Exp $ */
+/* $OpenBSD: cd.c,v 1.203 2011/06/19 04:35:06 deraadt Exp $ */
/* $NetBSD: cd.c,v 1.100 1997/04/02 02:29:30 mycroft Exp $ */
/*
@@ -172,8 +172,6 @@ const struct scsi_inquiry_pattern cd_patterns[] = {
#endif
};
-#define cdlock(softc) disk_lock(&(softc)->sc_dk)
-#define cdunlock(softc) disk_unlock(&(softc)->sc_dk)
#define cdlookup(unit) (struct cd_softc *)disk_lookup(&cd_cd, (unit))
int
@@ -315,7 +313,7 @@ cdopen(dev_t dev, int flag, int fmt, struct proc *p)
("cdopen: dev=0x%x (unit %d (of %d), partition %d)\n", dev, unit,
cd_cd.cd_ndevs, part));
- if ((error = cdlock(sc)) != 0) {
+ if ((error = disk_lock(&sc->sc_dk)) != 0) {
device_unref(&sc->sc_dev);
return (error);
}
@@ -410,7 +408,7 @@ bad:
sc_link->flags &= ~(SDEV_OPEN | SDEV_MEDIA_LOADED);
}
- cdunlock(sc);
+ disk_unlock(&sc->sc_dk);
device_unref(&sc->sc_dev);
return (error);
}
@@ -434,7 +432,7 @@ cdclose(dev_t dev, int flag, int fmt, struct proc *p)
return (ENXIO);
}
- if ((error = cdlock(sc)) != 0) {
+ if ((error = disk_lock(&sc->sc_dk)) != 0) {
device_unref(&sc->sc_dev);
return error;
}
@@ -467,7 +465,7 @@ cdclose(dev_t dev, int flag, int fmt, struct proc *p)
scsi_xsh_del(&sc->sc_xsh);
}
- cdunlock(sc);
+ disk_unlock(&sc->sc_dk);
device_unref(&sc->sc_dev);
return 0;
@@ -872,7 +870,7 @@ cdioctl(dev_t dev, u_long cmd, caddr_t addr, int flag, struct proc *p)
break;
}
- if ((error = cdlock(sc)) != 0)
+ if ((error = disk_lock(&sc->sc_dk)) != 0)
break;
error = setdisklabel(sc->sc_dk.dk_label,
@@ -880,7 +878,7 @@ cdioctl(dev_t dev, u_long cmd, caddr_t addr, int flag, struct proc *p)
if (error == 0) {
}
- cdunlock(sc);
+ disk_unlock(&sc->sc_dk);
break;
case CDIOCPLAYTRACKS: {
@@ -2186,7 +2184,7 @@ cd_eject(void)
if (cd_cd.cd_ndevs == 0 || (sc = cd_cd.cd_devs[0]) == NULL)
return (ENXIO);
- if ((error = cdlock(sc)) != 0)
+ if ((error = disk_lock(&sc->sc_dk)) != 0)
return (error);
if (sc->sc_dk.dk_openmask == 0) {
@@ -2201,7 +2199,7 @@ cd_eject(void)
sc->sc_link->flags &= ~SDEV_EJECTING;
}
- cdunlock(sc);
+ disk_unlock(&sc->sc_dk);
return (error);
}
diff --git a/sys/scsi/sd.c b/sys/scsi/sd.c
index 66805d2c73d..00b500266de 100644
--- a/sys/scsi/sd.c
+++ b/sys/scsi/sd.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: sd.c,v 1.228 2011/06/05 18:40:33 matthew Exp $ */
+/* $OpenBSD: sd.c,v 1.229 2011/06/19 04:35:06 deraadt Exp $ */
/* $NetBSD: sd.c,v 1.111 1997/04/02 02:29:41 mycroft Exp $ */
/*-
@@ -127,8 +127,6 @@ const struct scsi_inquiry_pattern sd_patterns[] = {
"", "", ""},
};
-#define sdlock(softc) disk_lock(&(softc)->sc_dk)
-#define sdunlock(softc) disk_unlock(&(softc)->sc_dk)
#define sdlookup(unit) (struct sd_softc *)disk_lookup(&sd_cd, (unit))
int
@@ -357,7 +355,7 @@ sdopen(dev_t dev, int flag, int fmt, struct proc *p)
("sdopen: dev=0x%x (unit %d (of %d), partition %d)\n", dev, unit,
sd_cd.cd_ndevs, part));
- if ((error = sdlock(sc)) != 0) {
+ if ((error = disk_lock(&sc->sc_dk)) != 0) {
device_unref(&sc->sc_dev);
return (error);
}
@@ -460,7 +458,7 @@ bad:
sc_link->flags &= ~(SDEV_OPEN | SDEV_MEDIA_LOADED);
}
- sdunlock(sc);
+ disk_unlock(&sc->sc_dk);
device_unref(&sc->sc_dev);
return (error);
}
@@ -484,7 +482,7 @@ sdclose(dev_t dev, int flag, int fmt, struct proc *p)
return (ENXIO);
}
- if ((error = sdlock(sc)) != 0) {
+ if ((error = disk_lock(&sc->sc_dk)) != 0) {
device_unref(&sc->sc_dev);
return (error);
}
@@ -518,7 +516,7 @@ sdclose(dev_t dev, int flag, int fmt, struct proc *p)
scsi_xsh_del(&sc->sc_xsh);
}
- sdunlock(sc);
+ disk_unlock(&sc->sc_dk);
device_unref(&sc->sc_dev);
return 0;
}
@@ -928,7 +926,7 @@ sdioctl(dev_t dev, u_long cmd, caddr_t addr, int flag, struct proc *p)
goto exit;
}
- if ((error = sdlock(sc)) != 0)
+ if ((error = disk_lock(&sc->sc_dk)) != 0)
goto exit;
error = setdisklabel(sc->sc_dk.dk_label,
@@ -939,7 +937,7 @@ sdioctl(dev_t dev, u_long cmd, caddr_t addr, int flag, struct proc *p)
sdstrategy, sc->sc_dk.dk_label);
}
- sdunlock(sc);
+ disk_unlock(&sc->sc_dk);
goto exit;
case DIOCLOCK: