diff options
author | kaf24@firebug.cl.cam.ac.uk <kaf24@firebug.cl.cam.ac.uk> | 2006-03-22 11:55:43 +0100 |
---|---|---|
committer | kaf24@firebug.cl.cam.ac.uk <kaf24@firebug.cl.cam.ac.uk> | 2006-03-22 11:55:43 +0100 |
commit | ea509d3a44c36e91766edff2ffbc5715f05ff449 (patch) | |
tree | c068f551f6b6b8f7d996ee025954379fef7f6754 | |
parent | 8d9256b041f86b7999a82e0daa2ac87056f9e637 (diff) | |
download | xen-ea509d3a44c36e91766edff2ffbc5715f05ff449.tar.gz xen-ea509d3a44c36e91766edff2ffbc5715f05ff449.tar.bz2 xen-ea509d3a44c36e91766edff2ffbc5715f05ff449.zip |
Use shiny new mutexes instead of semaphores where possible in our Linux code.
Signed-off-by: Keir Fraser <keir@xensource.com>
-rw-r--r-- | linux-2.6-xen-sparse/drivers/xen/core/reboot.c | 2 | ||||
-rw-r--r-- | linux-2.6-xen-sparse/drivers/xen/tpmfront/tpmfront.c | 35 | ||||
-rw-r--r-- | linux-2.6-xen-sparse/drivers/xen/xenbus/xenbus_probe.c | 6 | ||||
-rw-r--r-- | linux-2.6-xen-sparse/drivers/xen/xenbus/xenbus_xs.c | 35 | ||||
-rw-r--r-- | linux-2.6-xen-sparse/include/xen/xenbus.h | 2 |
5 files changed, 40 insertions, 40 deletions
diff --git a/linux-2.6-xen-sparse/drivers/xen/core/reboot.c b/linux-2.6-xen-sparse/drivers/xen/core/reboot.c index 1fa1f567c7..4ed9b2de3e 100644 --- a/linux-2.6-xen-sparse/drivers/xen/core/reboot.c +++ b/linux-2.6-xen-sparse/drivers/xen/core/reboot.c @@ -122,7 +122,7 @@ static int __do_suspend(void *ignore) lock_cpu_hotplug(); #ifdef CONFIG_SMP /* - * Take all other CPUs offline. We hold the hotplug semaphore to + * Take all other CPUs offline. We hold the hotplug mutex to * avoid other processes bringing up CPUs under our feet. */ cpus_clear(prev_online_cpus); diff --git a/linux-2.6-xen-sparse/drivers/xen/tpmfront/tpmfront.c b/linux-2.6-xen-sparse/drivers/xen/tpmfront/tpmfront.c index 2edb97ed3f..03a2ab9ea0 100644 --- a/linux-2.6-xen-sparse/drivers/xen/tpmfront/tpmfront.c +++ b/linux-2.6-xen-sparse/drivers/xen/tpmfront/tpmfront.c @@ -43,8 +43,7 @@ #include <linux/init.h> #include <xen/tpmfe.h> #include <linux/err.h> - -#include <asm/semaphore.h> +#include <linux/mutex.h> #include <asm/io.h> #include <xen/evtchn.h> #include <xen/interface/grant_table.h> @@ -153,8 +152,8 @@ static inline void tpm_private_free(void) **************************************************************/ -static DECLARE_MUTEX(upperlayer_lock); -static DECLARE_MUTEX(suspend_lock); +static DEFINE_MUTEX(upperlayer_lock); +static DEFINE_MUTEX(suspend_lock); static struct tpmfe_device *upperlayer_tpmfe; /* @@ -164,9 +163,9 @@ int tpm_fe_send(struct tpm_private *tp, const u8 * buf, size_t count, void *ptr) { int sent; - down(&suspend_lock); + mutex_lock(&suspend_lock); sent = tpm_xmit(tp, buf, count, 0, ptr); - up(&suspend_lock); + mutex_unlock(&suspend_lock); return sent; } @@ -179,7 +178,7 @@ int tpm_fe_register_receiver(struct tpmfe_device *tpmfe_dev) { int rc = 0; - down(&upperlayer_lock); + mutex_lock(&upperlayer_lock); if (NULL == upperlayer_tpmfe) { upperlayer_tpmfe = tpmfe_dev; tpmfe_dev->max_tx_size = TPMIF_TX_RING_SIZE * PAGE_SIZE; @@ -190,7 +189,7 @@ int tpm_fe_register_receiver(struct tpmfe_device *tpmfe_dev) } else { rc = -EBUSY; } - up(&upperlayer_lock); + mutex_unlock(&upperlayer_lock); return rc; } EXPORT_SYMBOL(tpm_fe_register_receiver); @@ -200,9 +199,9 @@ EXPORT_SYMBOL(tpm_fe_register_receiver); */ void tpm_fe_unregister_receiver(void) { - down(&upperlayer_lock); + mutex_lock(&upperlayer_lock); upperlayer_tpmfe = NULL; - up(&upperlayer_lock); + mutex_unlock(&upperlayer_lock); } EXPORT_SYMBOL(tpm_fe_unregister_receiver); @@ -215,12 +214,12 @@ static int tpm_fe_send_upperlayer(const u8 * buf, size_t count, { int rc = 0; - down(&upperlayer_lock); + mutex_lock(&upperlayer_lock); if (upperlayer_tpmfe && upperlayer_tpmfe->receive) rc = upperlayer_tpmfe->receive(buf, count, ptr); - up(&upperlayer_lock); + mutex_unlock(&upperlayer_lock); return rc; } @@ -415,7 +414,7 @@ tpmfront_suspend(struct xenbus_device *dev) u32 ctr; /* lock, so no app can send */ - down(&suspend_lock); + mutex_lock(&suspend_lock); tp->is_suspended = 1; for (ctr = 0; atomic_read(&tp->tx_busy) && ctr <= 25; ctr++) { @@ -647,7 +646,7 @@ static void tpmif_notify_upperlayer(struct tpm_private *tp) * Notify upper layer about the state of the connection * to the BE. */ - down(&upperlayer_lock); + mutex_lock(&upperlayer_lock); if (upperlayer_tpmfe != NULL) { if (tp->is_connected) { @@ -656,7 +655,7 @@ static void tpmif_notify_upperlayer(struct tpm_private *tp) upperlayer_tpmfe->status(0); } } - up(&upperlayer_lock); + mutex_unlock(&upperlayer_lock); } @@ -665,21 +664,21 @@ static void tpmif_set_connected_state(struct tpm_private *tp, u8 is_connected) /* * Don't notify upper layer if we are in suspend mode and * should disconnect - assumption is that we will resume - * The semaphore keeps apps from sending. + * The mutex keeps apps from sending. */ if (is_connected == 0 && tp->is_suspended == 1) { return; } /* - * Unlock the semaphore if we are connected again + * Unlock the mutex if we are connected again * after being suspended - now resuming. * This also removes the suspend state. */ if (is_connected == 1 && tp->is_suspended == 1) { tp->is_suspended = 0; /* unlock, so apps can resume sending */ - up(&suspend_lock); + mutex_unlock(&suspend_lock); } if (is_connected != tp->is_connected) { diff --git a/linux-2.6-xen-sparse/drivers/xen/xenbus/xenbus_probe.c b/linux-2.6-xen-sparse/drivers/xen/xenbus/xenbus_probe.c index b7d3b18a4a..89060dde9e 100644 --- a/linux-2.6-xen-sparse/drivers/xen/xenbus/xenbus_probe.c +++ b/linux-2.6-xen-sparse/drivers/xen/xenbus/xenbus_probe.c @@ -52,7 +52,7 @@ #include "xenbus_comms.h" -extern struct semaphore xenwatch_mutex; +extern struct mutex xenwatch_mutex; #define streq(a, b) (strcmp((a), (b)) == 0) @@ -399,9 +399,9 @@ static int xenbus_register_driver_common(struct xenbus_driver *drv, drv->driver.probe = xenbus_dev_probe; drv->driver.remove = xenbus_dev_remove; - down(&xenwatch_mutex); + mutex_lock(&xenwatch_mutex); ret = driver_register(&drv->driver); - up(&xenwatch_mutex); + mutex_unlock(&xenwatch_mutex); return ret; } diff --git a/linux-2.6-xen-sparse/drivers/xen/xenbus/xenbus_xs.c b/linux-2.6-xen-sparse/drivers/xen/xenbus/xenbus_xs.c index 07cf37069d..3016b81753 100644 --- a/linux-2.6-xen-sparse/drivers/xen/xenbus/xenbus_xs.c +++ b/linux-2.6-xen-sparse/drivers/xen/xenbus/xenbus_xs.c @@ -41,6 +41,7 @@ #include <linux/slab.h> #include <linux/fcntl.h> #include <linux/kthread.h> +#include <linux/rwsem.h> #include <xen/xenbus.h> #include "xenbus_comms.h" @@ -76,7 +77,7 @@ struct xs_handle { wait_queue_head_t reply_waitq; /* One request at a time. */ - struct semaphore request_mutex; + struct mutex request_mutex; /* Protect transactions against save/restore. */ struct rw_semaphore suspend_mutex; @@ -99,7 +100,7 @@ static DEFINE_SPINLOCK(watch_events_lock); * carrying out work. */ static pid_t xenwatch_pid; -/* static */ DECLARE_MUTEX(xenwatch_mutex); +/* static */ DEFINE_MUTEX(xenwatch_mutex); static DECLARE_WAIT_QUEUE_HEAD(watch_events_waitq); static int get_error(const char *errorstring) @@ -156,12 +157,12 @@ void xenbus_debug_write(const char *str, unsigned int count) msg.type = XS_DEBUG; msg.len = sizeof("print") + count + 1; - down(&xs_state.request_mutex); + mutex_lock(&xs_state.request_mutex); xb_write(&msg, sizeof(msg)); xb_write("print", sizeof("print")); xb_write(str, count); xb_write("", 1); - up(&xs_state.request_mutex); + mutex_unlock(&xs_state.request_mutex); } void *xenbus_dev_request_and_reply(struct xsd_sockmsg *msg) @@ -173,7 +174,7 @@ void *xenbus_dev_request_and_reply(struct xsd_sockmsg *msg) if (req_msg.type == XS_TRANSACTION_START) down_read(&xs_state.suspend_mutex); - down(&xs_state.request_mutex); + mutex_lock(&xs_state.request_mutex); err = xb_write(msg, sizeof(*msg) + msg->len); if (err) { @@ -182,7 +183,7 @@ void *xenbus_dev_request_and_reply(struct xsd_sockmsg *msg) } else ret = read_reply(&msg->type, &msg->len); - up(&xs_state.request_mutex); + mutex_unlock(&xs_state.request_mutex); if ((msg->type == XS_TRANSACTION_END) || ((req_msg.type == XS_TRANSACTION_START) && @@ -211,25 +212,25 @@ static void *xs_talkv(xenbus_transaction_t t, for (i = 0; i < num_vecs; i++) msg.len += iovec[i].iov_len; - down(&xs_state.request_mutex); + mutex_lock(&xs_state.request_mutex); err = xb_write(&msg, sizeof(msg)); if (err) { - up(&xs_state.request_mutex); + mutex_unlock(&xs_state.request_mutex); return ERR_PTR(err); } for (i = 0; i < num_vecs; i++) { err = xb_write(iovec[i].iov_base, iovec[i].iov_len);; if (err) { - up(&xs_state.request_mutex); + mutex_unlock(&xs_state.request_mutex); return ERR_PTR(err); } } ret = read_reply(&msg.type, len); - up(&xs_state.request_mutex); + mutex_unlock(&xs_state.request_mutex); if (IS_ERR(ret)) return ret; @@ -658,8 +659,8 @@ void unregister_xenbus_watch(struct xenbus_watch *watch) /* Flush any currently-executing callback, unless we are it. :-) */ if (current->pid != xenwatch_pid) { - down(&xenwatch_mutex); - up(&xenwatch_mutex); + mutex_lock(&xenwatch_mutex); + mutex_unlock(&xenwatch_mutex); } } EXPORT_SYMBOL_GPL(unregister_xenbus_watch); @@ -667,7 +668,7 @@ EXPORT_SYMBOL_GPL(unregister_xenbus_watch); void xs_suspend(void) { down_write(&xs_state.suspend_mutex); - down(&xs_state.request_mutex); + mutex_lock(&xs_state.request_mutex); } void xs_resume(void) @@ -675,7 +676,7 @@ void xs_resume(void) struct xenbus_watch *watch; char token[sizeof(watch) * 2 + 1]; - up(&xs_state.request_mutex); + mutex_unlock(&xs_state.request_mutex); /* No need for watches_lock: the suspend_mutex is sufficient. */ list_for_each_entry(watch, &watches, list) { @@ -698,7 +699,7 @@ static int xenwatch_thread(void *unused) if (kthread_should_stop()) break; - down(&xenwatch_mutex); + mutex_lock(&xenwatch_mutex); spin_lock(&watch_events_lock); ent = watch_events.next; @@ -716,7 +717,7 @@ static int xenwatch_thread(void *unused) kfree(msg); } - up(&xenwatch_mutex); + mutex_unlock(&xenwatch_mutex); } return 0; @@ -809,7 +810,7 @@ int xs_init(void) spin_lock_init(&xs_state.reply_lock); init_waitqueue_head(&xs_state.reply_waitq); - init_MUTEX(&xs_state.request_mutex); + mutex_init(&xs_state.request_mutex); init_rwsem(&xs_state.suspend_mutex); /* Initialize the shared memory rings to talk to xenstored */ diff --git a/linux-2.6-xen-sparse/include/xen/xenbus.h b/linux-2.6-xen-sparse/include/xen/xenbus.h index 1fed138c26..122480584f 100644 --- a/linux-2.6-xen-sparse/include/xen/xenbus.h +++ b/linux-2.6-xen-sparse/include/xen/xenbus.h @@ -36,7 +36,7 @@ #include <linux/device.h> #include <linux/notifier.h> -#include <asm/semaphore.h> +#include <linux/mutex.h> #include <xen/interface/xen.h> #include <xen/interface/grant_table.h> #include <xen/interface/io/xenbus.h> |