diff options
Diffstat (limited to 'drivers/oprofile/event_buffer.c')
-rw-r--r-- | drivers/oprofile/event_buffer.c | 34 |
1 files changed, 17 insertions, 17 deletions
diff --git a/drivers/oprofile/event_buffer.c b/drivers/oprofile/event_buffer.c index 8d692a5c8e73..d962ba0dd87a 100644 --- a/drivers/oprofile/event_buffer.c +++ b/drivers/oprofile/event_buffer.c | |||
@@ -19,16 +19,16 @@ | |||
19 | #include <linux/dcookies.h> | 19 | #include <linux/dcookies.h> |
20 | #include <linux/fs.h> | 20 | #include <linux/fs.h> |
21 | #include <asm/uaccess.h> | 21 | #include <asm/uaccess.h> |
22 | 22 | ||
23 | #include "oprof.h" | 23 | #include "oprof.h" |
24 | #include "event_buffer.h" | 24 | #include "event_buffer.h" |
25 | #include "oprofile_stats.h" | 25 | #include "oprofile_stats.h" |
26 | 26 | ||
27 | DEFINE_MUTEX(buffer_mutex); | 27 | DEFINE_MUTEX(buffer_mutex); |
28 | 28 | ||
29 | static unsigned long buffer_opened; | 29 | static unsigned long buffer_opened; |
30 | static DECLARE_WAIT_QUEUE_HEAD(buffer_wait); | 30 | static DECLARE_WAIT_QUEUE_HEAD(buffer_wait); |
31 | static unsigned long * event_buffer; | 31 | static unsigned long *event_buffer; |
32 | static unsigned long buffer_size; | 32 | static unsigned long buffer_size; |
33 | static unsigned long buffer_watershed; | 33 | static unsigned long buffer_watershed; |
34 | static size_t buffer_pos; | 34 | static size_t buffer_pos; |
@@ -66,7 +66,7 @@ void wake_up_buffer_waiter(void) | |||
66 | mutex_unlock(&buffer_mutex); | 66 | mutex_unlock(&buffer_mutex); |
67 | } | 67 | } |
68 | 68 | ||
69 | 69 | ||
70 | int alloc_event_buffer(void) | 70 | int alloc_event_buffer(void) |
71 | { | 71 | { |
72 | int err = -ENOMEM; | 72 | int err = -ENOMEM; |
@@ -76,13 +76,13 @@ int alloc_event_buffer(void) | |||
76 | buffer_size = fs_buffer_size; | 76 | buffer_size = fs_buffer_size; |
77 | buffer_watershed = fs_buffer_watershed; | 77 | buffer_watershed = fs_buffer_watershed; |
78 | spin_unlock_irqrestore(&oprofilefs_lock, flags); | 78 | spin_unlock_irqrestore(&oprofilefs_lock, flags); |
79 | 79 | ||
80 | if (buffer_watershed >= buffer_size) | 80 | if (buffer_watershed >= buffer_size) |
81 | return -EINVAL; | 81 | return -EINVAL; |
82 | 82 | ||
83 | event_buffer = vmalloc(sizeof(unsigned long) * buffer_size); | 83 | event_buffer = vmalloc(sizeof(unsigned long) * buffer_size); |
84 | if (!event_buffer) | 84 | if (!event_buffer) |
85 | goto out; | 85 | goto out; |
86 | 86 | ||
87 | err = 0; | 87 | err = 0; |
88 | out: | 88 | out: |
@@ -97,8 +97,8 @@ void free_event_buffer(void) | |||
97 | event_buffer = NULL; | 97 | event_buffer = NULL; |
98 | } | 98 | } |
99 | 99 | ||
100 | 100 | ||
101 | static int event_buffer_open(struct inode * inode, struct file * file) | 101 | static int event_buffer_open(struct inode *inode, struct file *file) |
102 | { | 102 | { |
103 | int err = -EPERM; | 103 | int err = -EPERM; |
104 | 104 | ||
@@ -116,14 +116,14 @@ static int event_buffer_open(struct inode * inode, struct file * file) | |||
116 | file->private_data = dcookie_register(); | 116 | file->private_data = dcookie_register(); |
117 | if (!file->private_data) | 117 | if (!file->private_data) |
118 | goto out; | 118 | goto out; |
119 | 119 | ||
120 | if ((err = oprofile_setup())) | 120 | if ((err = oprofile_setup())) |
121 | goto fail; | 121 | goto fail; |
122 | 122 | ||
123 | /* NB: the actual start happens from userspace | 123 | /* NB: the actual start happens from userspace |
124 | * echo 1 >/dev/oprofile/enable | 124 | * echo 1 >/dev/oprofile/enable |
125 | */ | 125 | */ |
126 | 126 | ||
127 | return 0; | 127 | return 0; |
128 | 128 | ||
129 | fail: | 129 | fail: |
@@ -134,7 +134,7 @@ out: | |||
134 | } | 134 | } |
135 | 135 | ||
136 | 136 | ||
137 | static int event_buffer_release(struct inode * inode, struct file * file) | 137 | static int event_buffer_release(struct inode *inode, struct file *file) |
138 | { | 138 | { |
139 | oprofile_stop(); | 139 | oprofile_stop(); |
140 | oprofile_shutdown(); | 140 | oprofile_shutdown(); |
@@ -146,8 +146,8 @@ static int event_buffer_release(struct inode * inode, struct file * file) | |||
146 | } | 146 | } |
147 | 147 | ||
148 | 148 | ||
149 | static ssize_t event_buffer_read(struct file * file, char __user * buf, | 149 | static ssize_t event_buffer_read(struct file *file, char __user *buf, |
150 | size_t count, loff_t * offset) | 150 | size_t count, loff_t *offset) |
151 | { | 151 | { |
152 | int retval = -EINVAL; | 152 | int retval = -EINVAL; |
153 | size_t const max = buffer_size * sizeof(unsigned long); | 153 | size_t const max = buffer_size * sizeof(unsigned long); |
@@ -172,18 +172,18 @@ static ssize_t event_buffer_read(struct file * file, char __user * buf, | |||
172 | retval = -EFAULT; | 172 | retval = -EFAULT; |
173 | 173 | ||
174 | count = buffer_pos * sizeof(unsigned long); | 174 | count = buffer_pos * sizeof(unsigned long); |
175 | 175 | ||
176 | if (copy_to_user(buf, event_buffer, count)) | 176 | if (copy_to_user(buf, event_buffer, count)) |
177 | goto out; | 177 | goto out; |
178 | 178 | ||
179 | retval = count; | 179 | retval = count; |
180 | buffer_pos = 0; | 180 | buffer_pos = 0; |
181 | 181 | ||
182 | out: | 182 | out: |
183 | mutex_unlock(&buffer_mutex); | 183 | mutex_unlock(&buffer_mutex); |
184 | return retval; | 184 | return retval; |
185 | } | 185 | } |
186 | 186 | ||
187 | const struct file_operations event_buffer_fops = { | 187 | const struct file_operations event_buffer_fops = { |
188 | .open = event_buffer_open, | 188 | .open = event_buffer_open, |
189 | .release = event_buffer_release, | 189 | .release = event_buffer_release, |