aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/oprofile/oprof.c
diff options
context:
space:
mode:
authorMarkus Armbruster <armbru@redhat.com>2006-06-25 08:47:33 -0400
committerLinus Torvalds <torvalds@g5.osdl.org>2006-06-25 13:01:04 -0400
commit59cc185ada89245204c658ebcf64422968736672 (patch)
tree042e46cfe90c2ad5b711e2791b05f73ab1fe7725 /drivers/oprofile/oprof.c
parenta2926b1449bcc3d348e2228114b04869dc2f3986 (diff)
[PATCH] oprofile: convert from semaphores to mutexes
Signed-off-by: Markus Armbruster <armbru@redhat.com> Cc: Philippe Elie <phil.el@wanadoo.fr> Cc: John Levon <levon@movementarian.org> Signed-off-by: Andrew Morton <akpm@osdl.org> Signed-off-by: Linus Torvalds <torvalds@osdl.org>
Diffstat (limited to 'drivers/oprofile/oprof.c')
-rw-r--r--drivers/oprofile/oprof.c26
1 files changed, 13 insertions, 13 deletions
diff --git a/drivers/oprofile/oprof.c b/drivers/oprofile/oprof.c
index b3f1cd6a24c1..e5162a64018b 100644
--- a/drivers/oprofile/oprof.c
+++ b/drivers/oprofile/oprof.c
@@ -12,7 +12,7 @@
12#include <linux/init.h> 12#include <linux/init.h>
13#include <linux/oprofile.h> 13#include <linux/oprofile.h>
14#include <linux/moduleparam.h> 14#include <linux/moduleparam.h>
15#include <asm/semaphore.h> 15#include <asm/mutex.h>
16 16
17#include "oprof.h" 17#include "oprof.h"
18#include "event_buffer.h" 18#include "event_buffer.h"
@@ -25,7 +25,7 @@ struct oprofile_operations oprofile_ops;
25unsigned long oprofile_started; 25unsigned long oprofile_started;
26unsigned long backtrace_depth; 26unsigned long backtrace_depth;
27static unsigned long is_setup; 27static unsigned long is_setup;
28static DECLARE_MUTEX(start_sem); 28static DEFINE_MUTEX(start_mutex);
29 29
30/* timer 30/* timer
31 0 - use performance monitoring hardware if available 31 0 - use performance monitoring hardware if available
@@ -37,7 +37,7 @@ int oprofile_setup(void)
37{ 37{
38 int err; 38 int err;
39 39
40 down(&start_sem); 40 mutex_lock(&start_mutex);
41 41
42 if ((err = alloc_cpu_buffers())) 42 if ((err = alloc_cpu_buffers()))
43 goto out; 43 goto out;
@@ -57,7 +57,7 @@ int oprofile_setup(void)
57 goto out3; 57 goto out3;
58 58
59 is_setup = 1; 59 is_setup = 1;
60 up(&start_sem); 60 mutex_unlock(&start_mutex);
61 return 0; 61 return 0;
62 62
63out3: 63out3:
@@ -68,7 +68,7 @@ out2:
68out1: 68out1:
69 free_cpu_buffers(); 69 free_cpu_buffers();
70out: 70out:
71 up(&start_sem); 71 mutex_unlock(&start_mutex);
72 return err; 72 return err;
73} 73}
74 74
@@ -78,7 +78,7 @@ int oprofile_start(void)
78{ 78{
79 int err = -EINVAL; 79 int err = -EINVAL;
80 80
81 down(&start_sem); 81 mutex_lock(&start_mutex);
82 82
83 if (!is_setup) 83 if (!is_setup)
84 goto out; 84 goto out;
@@ -95,7 +95,7 @@ int oprofile_start(void)
95 95
96 oprofile_started = 1; 96 oprofile_started = 1;
97out: 97out:
98 up(&start_sem); 98 mutex_unlock(&start_mutex);
99 return err; 99 return err;
100} 100}
101 101
@@ -103,7 +103,7 @@ out:
103/* echo 0>/dev/oprofile/enable */ 103/* echo 0>/dev/oprofile/enable */
104void oprofile_stop(void) 104void oprofile_stop(void)
105{ 105{
106 down(&start_sem); 106 mutex_lock(&start_mutex);
107 if (!oprofile_started) 107 if (!oprofile_started)
108 goto out; 108 goto out;
109 oprofile_ops.stop(); 109 oprofile_ops.stop();
@@ -111,20 +111,20 @@ void oprofile_stop(void)
111 /* wake up the daemon to read what remains */ 111 /* wake up the daemon to read what remains */
112 wake_up_buffer_waiter(); 112 wake_up_buffer_waiter();
113out: 113out:
114 up(&start_sem); 114 mutex_unlock(&start_mutex);
115} 115}
116 116
117 117
118void oprofile_shutdown(void) 118void oprofile_shutdown(void)
119{ 119{
120 down(&start_sem); 120 mutex_lock(&start_mutex);
121 sync_stop(); 121 sync_stop();
122 if (oprofile_ops.shutdown) 122 if (oprofile_ops.shutdown)
123 oprofile_ops.shutdown(); 123 oprofile_ops.shutdown();
124 is_setup = 0; 124 is_setup = 0;
125 free_event_buffer(); 125 free_event_buffer();
126 free_cpu_buffers(); 126 free_cpu_buffers();
127 up(&start_sem); 127 mutex_unlock(&start_mutex);
128} 128}
129 129
130 130
@@ -132,7 +132,7 @@ int oprofile_set_backtrace(unsigned long val)
132{ 132{
133 int err = 0; 133 int err = 0;
134 134
135 down(&start_sem); 135 mutex_lock(&start_mutex);
136 136
137 if (oprofile_started) { 137 if (oprofile_started) {
138 err = -EBUSY; 138 err = -EBUSY;
@@ -147,7 +147,7 @@ int oprofile_set_backtrace(unsigned long val)
147 backtrace_depth = val; 147 backtrace_depth = val;
148 148
149out: 149out:
150 up(&start_sem); 150 mutex_unlock(&start_mutex);
151 return err; 151 return err;
152} 152}
153 153