summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--device/dev_hdr.h7
-rw-r--r--device/dev_lookup.c2
-rw-r--r--device/ds_routines.c2
3 files changed, 6 insertions, 5 deletions
diff --git a/device/dev_hdr.h b/device/dev_hdr.h
index ff7d2ef..5f80d4a 100644
--- a/device/dev_hdr.h
+++ b/device/dev_hdr.h
@@ -82,7 +82,7 @@ typedef struct device *device_t;
struct mach_device {
decl_simple_lock_data(,ref_lock)/* lock for reference count */
int ref_count; /* reference count */
- decl_simple_lock_data(, lock) /* lock for rest of state */
+ struct lock lock; /* lock for rest of state */
short state; /* state: */
#define DEV_STATE_INIT 0 /* not open */
#define DEV_STATE_OPENING 1 /* being opened */
@@ -127,8 +127,9 @@ boolean_t dev_map(boolean_t (*)(), mach_port_t);
/*
* To lock and unlock state and open-count
*/
-#define device_lock(device) simple_lock(&(device)->lock)
-#define device_unlock(device) simple_unlock(&(device)->lock)
+#define device_lock_init(device) lock_init(&(device)->lock, FALSE)
+#define device_lock(device) lock_write(&(device)->lock)
+#define device_unlock(device) lock_write_done(&(device)->lock)
/*
* device name lookup
diff --git a/device/dev_lookup.c b/device/dev_lookup.c
index a80830c..297dcde 100644
--- a/device/dev_lookup.c
+++ b/device/dev_lookup.c
@@ -154,7 +154,7 @@ device_lookup(char *name)
new_device = (mach_device_t) kmem_cache_alloc(&dev_hdr_cache);
simple_lock_init(&new_device->ref_lock);
new_device->ref_count = 1;
- simple_lock_init(&new_device->lock);
+ device_lock_init(new_device);
new_device->state = DEV_STATE_INIT;
new_device->flag = 0;
new_device->open_count = 0;
diff --git a/device/ds_routines.c b/device/ds_routines.c
index 43ed5b5..33cfd89 100644
--- a/device/ds_routines.c
+++ b/device/ds_routines.c
@@ -443,7 +443,7 @@ device_open(const ipc_port_t reply_port,
while (device->state == DEV_STATE_OPENING ||
device->state == DEV_STATE_CLOSING) {
device->io_wait = TRUE;
- thread_sleep((event_t)device, simple_lock_addr(device->lock), TRUE);
+ thread_sleep_lock((event_t)device, &device->lock, TRUE);
device_lock(device);
}