diff options
author | Len Brown <len.brown@intel.com> | 2009-12-16 02:19:59 -0500 |
---|---|---|
committer | Len Brown <len.brown@intel.com> | 2009-12-16 02:19:59 -0500 |
commit | 1fc22fad1f9115f37778f159c07b414923ba1cdc (patch) | |
tree | 484b307b9eeedafa2c6b666c5fcac3fb3f2bc7d4 /drivers | |
parent | 8033c314b9b67f53eddb3afcbec74c39b57b56b6 (diff) | |
parent | 4bab30a041a2f27807b0b2a7fd36c8c8695c90c8 (diff) |
Merge branch 'debug-aml' into release
Diffstat (limited to 'drivers')
-rw-r--r-- | drivers/acpi/debug.c | 84 |
1 files changed, 83 insertions, 1 deletions
diff --git a/drivers/acpi/debug.c b/drivers/acpi/debug.c index 8a690c3b8e23..cc421b7ae166 100644 --- a/drivers/acpi/debug.c +++ b/drivers/acpi/debug.c | |||
@@ -8,6 +8,7 @@ | |||
8 | #include <linux/module.h> | 8 | #include <linux/module.h> |
9 | #include <linux/kernel.h> | 9 | #include <linux/kernel.h> |
10 | #include <linux/moduleparam.h> | 10 | #include <linux/moduleparam.h> |
11 | #include <linux/debugfs.h> | ||
11 | #include <asm/uaccess.h> | 12 | #include <asm/uaccess.h> |
12 | #include <acpi/acpi_drivers.h> | 13 | #include <acpi/acpi_drivers.h> |
13 | 14 | ||
@@ -196,6 +197,80 @@ module_param_call(trace_state, param_set_trace_state, param_get_trace_state, | |||
196 | NULL, 0644); | 197 | NULL, 0644); |
197 | 198 | ||
198 | /* -------------------------------------------------------------------------- | 199 | /* -------------------------------------------------------------------------- |
200 | DebugFS Interface | ||
201 | -------------------------------------------------------------------------- */ | ||
202 | |||
203 | static ssize_t cm_write(struct file *file, const char __user *user_buf, | ||
204 | size_t count, loff_t *ppos) | ||
205 | { | ||
206 | static char *buf; | ||
207 | static int uncopied_bytes; | ||
208 | struct acpi_table_header table; | ||
209 | acpi_status status; | ||
210 | |||
211 | if (!(*ppos)) { | ||
212 | /* parse the table header to get the table length */ | ||
213 | if (count <= sizeof(struct acpi_table_header)) | ||
214 | return -EINVAL; | ||
215 | if (copy_from_user(&table, user_buf, | ||
216 | sizeof(struct acpi_table_header))) | ||
217 | return -EFAULT; | ||
218 | uncopied_bytes = table.length; | ||
219 | buf = kzalloc(uncopied_bytes, GFP_KERNEL); | ||
220 | if (!buf) | ||
221 | return -ENOMEM; | ||
222 | } | ||
223 | |||
224 | if (uncopied_bytes < count) { | ||
225 | kfree(buf); | ||
226 | return -EINVAL; | ||
227 | } | ||
228 | |||
229 | if (copy_from_user(buf + (*ppos), user_buf, count)) { | ||
230 | kfree(buf); | ||
231 | return -EFAULT; | ||
232 | } | ||
233 | |||
234 | uncopied_bytes -= count; | ||
235 | *ppos += count; | ||
236 | |||
237 | if (!uncopied_bytes) { | ||
238 | status = acpi_install_method(buf); | ||
239 | kfree(buf); | ||
240 | if (ACPI_FAILURE(status)) | ||
241 | return -EINVAL; | ||
242 | add_taint(TAINT_OVERRIDDEN_ACPI_TABLE); | ||
243 | } | ||
244 | |||
245 | return count; | ||
246 | } | ||
247 | |||
248 | static const struct file_operations cm_fops = { | ||
249 | .write = cm_write, | ||
250 | }; | ||
251 | |||
252 | static int acpi_debugfs_init(void) | ||
253 | { | ||
254 | struct dentry *acpi_dir, *cm_dentry; | ||
255 | |||
256 | acpi_dir = debugfs_create_dir("acpi", NULL); | ||
257 | if (!acpi_dir) | ||
258 | goto err; | ||
259 | |||
260 | cm_dentry = debugfs_create_file("custom_method", S_IWUGO, | ||
261 | acpi_dir, NULL, &cm_fops); | ||
262 | if (!cm_dentry) | ||
263 | goto err; | ||
264 | |||
265 | return 0; | ||
266 | |||
267 | err: | ||
268 | if (acpi_dir) | ||
269 | debugfs_remove(acpi_dir); | ||
270 | return -EINVAL; | ||
271 | } | ||
272 | |||
273 | /* -------------------------------------------------------------------------- | ||
199 | FS Interface (/proc) | 274 | FS Interface (/proc) |
200 | -------------------------------------------------------------------------- */ | 275 | -------------------------------------------------------------------------- */ |
201 | #ifdef CONFIG_ACPI_PROCFS | 276 | #ifdef CONFIG_ACPI_PROCFS |
@@ -286,7 +361,7 @@ static const struct file_operations acpi_system_debug_proc_fops = { | |||
286 | }; | 361 | }; |
287 | #endif | 362 | #endif |
288 | 363 | ||
289 | int __init acpi_debug_init(void) | 364 | int __init acpi_procfs_init(void) |
290 | { | 365 | { |
291 | #ifdef CONFIG_ACPI_PROCFS | 366 | #ifdef CONFIG_ACPI_PROCFS |
292 | struct proc_dir_entry *entry; | 367 | struct proc_dir_entry *entry; |
@@ -321,3 +396,10 @@ int __init acpi_debug_init(void) | |||
321 | return 0; | 396 | return 0; |
322 | #endif | 397 | #endif |
323 | } | 398 | } |
399 | |||
400 | int __init acpi_debug_init(void) | ||
401 | { | ||
402 | acpi_debugfs_init(); | ||
403 | acpi_procfs_init(); | ||
404 | return 0; | ||
405 | } | ||