Skip to content

Commit ecd8ee0

Browse files
committed
Merge branch 'procfs-cleanup' into release
2 parents feb29c5 + c637e48 commit ecd8ee0

File tree

8 files changed

+105
-77
lines changed

8 files changed

+105
-77
lines changed

Documentation/acpi/method-customizing.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,8 @@ Note: Only ACPI METHOD can be overridden, any other object types like
1919
"Device", "OperationRegion", are not recognized.
2020
Note: The same ACPI control method can be overridden for many times,
2121
and it's always the latest one that used by Linux/kernel.
22+
Note: To get the ACPI debug object output (Store (AAAA, Debug)),
23+
please run "echo 1 > /sys/module/acpi/parameters/aml_debug_output".
2224

2325
1. override an existing method
2426
a) get the ACPI table via ACPI sysfs I/F. e.g. to get the DSDT,

drivers/acpi/Makefile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ acpi-y += pci_root.o pci_link.o pci_irq.o pci_bind.o
3939
acpi-y += power.o
4040
acpi-y += system.o event.o
4141
acpi-$(CONFIG_ACPI_DEBUG) += debug.o
42+
acpi-$(CONFIG_DEBUG_FS) += debugfs.o
4243
acpi-$(CONFIG_ACPI_NUMA) += numa.o
4344
acpi-$(CONFIG_ACPI_PROCFS_POWER) += cm_sbs.o
4445
ifdef CONFIG_ACPI_VIDEO

drivers/acpi/acpica/acglobal.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,7 @@ u8 ACPI_INIT_GLOBAL(acpi_gbl_use_default_register_widths, TRUE);
115115
/*
116116
* Optionally enable output from the AML Debug Object.
117117
*/
118-
u8 ACPI_INIT_GLOBAL(acpi_gbl_enable_aml_debug_object, FALSE);
118+
u32 ACPI_INIT_GLOBAL(acpi_gbl_enable_aml_debug_object, FALSE);
119119

120120
/*
121121
* Optionally copy the entire DSDT to local memory (instead of simply

drivers/acpi/bus.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1036,6 +1036,7 @@ static int __init acpi_init(void)
10361036
acpi_power_init();
10371037
acpi_system_init();
10381038
acpi_debug_init();
1039+
acpi_debugfs_init();
10391040
acpi_sleep_proc_init();
10401041
acpi_wakeup_device_init();
10411042
return result;

drivers/acpi/debug.c

Lines changed: 0 additions & 75 deletions
Original file line numberDiff line numberDiff line change
@@ -197,80 +197,6 @@ static int param_get_trace_state(char *buffer, struct kernel_param *kp)
197197
module_param_call(trace_state, param_set_trace_state, param_get_trace_state,
198198
NULL, 0644);
199199

200-
/* --------------------------------------------------------------------------
201-
DebugFS Interface
202-
-------------------------------------------------------------------------- */
203-
204-
static ssize_t cm_write(struct file *file, const char __user *user_buf,
205-
size_t count, loff_t *ppos)
206-
{
207-
static char *buf;
208-
static int uncopied_bytes;
209-
struct acpi_table_header table;
210-
acpi_status status;
211-
212-
if (!(*ppos)) {
213-
/* parse the table header to get the table length */
214-
if (count <= sizeof(struct acpi_table_header))
215-
return -EINVAL;
216-
if (copy_from_user(&table, user_buf,
217-
sizeof(struct acpi_table_header)))
218-
return -EFAULT;
219-
uncopied_bytes = table.length;
220-
buf = kzalloc(uncopied_bytes, GFP_KERNEL);
221-
if (!buf)
222-
return -ENOMEM;
223-
}
224-
225-
if (uncopied_bytes < count) {
226-
kfree(buf);
227-
return -EINVAL;
228-
}
229-
230-
if (copy_from_user(buf + (*ppos), user_buf, count)) {
231-
kfree(buf);
232-
return -EFAULT;
233-
}
234-
235-
uncopied_bytes -= count;
236-
*ppos += count;
237-
238-
if (!uncopied_bytes) {
239-
status = acpi_install_method(buf);
240-
kfree(buf);
241-
if (ACPI_FAILURE(status))
242-
return -EINVAL;
243-
add_taint(TAINT_OVERRIDDEN_ACPI_TABLE);
244-
}
245-
246-
return count;
247-
}
248-
249-
static const struct file_operations cm_fops = {
250-
.write = cm_write,
251-
};
252-
253-
static int acpi_debugfs_init(void)
254-
{
255-
struct dentry *acpi_dir, *cm_dentry;
256-
257-
acpi_dir = debugfs_create_dir("acpi", NULL);
258-
if (!acpi_dir)
259-
goto err;
260-
261-
cm_dentry = debugfs_create_file("custom_method", S_IWUGO,
262-
acpi_dir, NULL, &cm_fops);
263-
if (!cm_dentry)
264-
goto err;
265-
266-
return 0;
267-
268-
err:
269-
if (acpi_dir)
270-
debugfs_remove(acpi_dir);
271-
return -EINVAL;
272-
}
273-
274200
/* --------------------------------------------------------------------------
275201
FS Interface (/proc)
276202
-------------------------------------------------------------------------- */
@@ -400,7 +326,6 @@ int __init acpi_procfs_init(void)
400326

401327
int __init acpi_debug_init(void)
402328
{
403-
acpi_debugfs_init();
404329
acpi_procfs_init();
405330
return 0;
406331
}

drivers/acpi/debugfs.c

Lines changed: 93 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,93 @@
1+
/*
2+
* debugfs.c - ACPI debugfs interface to userspace.
3+
*/
4+
5+
#include <linux/init.h>
6+
#include <linux/module.h>
7+
#include <linux/kernel.h>
8+
#include <linux/uaccess.h>
9+
#include <linux/debugfs.h>
10+
#include <acpi/acpi_drivers.h>
11+
12+
#define _COMPONENT ACPI_SYSTEM_COMPONENT
13+
ACPI_MODULE_NAME("debugfs");
14+
15+
16+
/* /sys/modules/acpi/parameters/aml_debug_output */
17+
18+
module_param_named(aml_debug_output, acpi_gbl_enable_aml_debug_object,
19+
bool, 0644);
20+
MODULE_PARM_DESC(aml_debug_output,
21+
"To enable/disable the ACPI Debug Object output.");
22+
23+
/* /sys/kernel/debug/acpi/custom_method */
24+
25+
static ssize_t cm_write(struct file *file, const char __user * user_buf,
26+
size_t count, loff_t *ppos)
27+
{
28+
static char *buf;
29+
static int uncopied_bytes;
30+
struct acpi_table_header table;
31+
acpi_status status;
32+
33+
if (!(*ppos)) {
34+
/* parse the table header to get the table length */
35+
if (count <= sizeof(struct acpi_table_header))
36+
return -EINVAL;
37+
if (copy_from_user(&table, user_buf,
38+
sizeof(struct acpi_table_header)))
39+
return -EFAULT;
40+
uncopied_bytes = table.length;
41+
buf = kzalloc(uncopied_bytes, GFP_KERNEL);
42+
if (!buf)
43+
return -ENOMEM;
44+
}
45+
46+
if (uncopied_bytes < count) {
47+
kfree(buf);
48+
return -EINVAL;
49+
}
50+
51+
if (copy_from_user(buf + (*ppos), user_buf, count)) {
52+
kfree(buf);
53+
return -EFAULT;
54+
}
55+
56+
uncopied_bytes -= count;
57+
*ppos += count;
58+
59+
if (!uncopied_bytes) {
60+
status = acpi_install_method(buf);
61+
kfree(buf);
62+
if (ACPI_FAILURE(status))
63+
return -EINVAL;
64+
add_taint(TAINT_OVERRIDDEN_ACPI_TABLE);
65+
}
66+
67+
return count;
68+
}
69+
70+
static const struct file_operations cm_fops = {
71+
.write = cm_write,
72+
};
73+
74+
int __init acpi_debugfs_init(void)
75+
{
76+
struct dentry *acpi_dir, *cm_dentry;
77+
78+
acpi_dir = debugfs_create_dir("acpi", NULL);
79+
if (!acpi_dir)
80+
goto err;
81+
82+
cm_dentry = debugfs_create_file("custom_method", S_IWUGO,
83+
acpi_dir, NULL, &cm_fops);
84+
if (!cm_dentry)
85+
goto err;
86+
87+
return 0;
88+
89+
err:
90+
if (acpi_dir)
91+
debugfs_remove(acpi_dir);
92+
return -EINVAL;
93+
}

drivers/acpi/internal.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,12 @@ int acpi_debug_init(void);
3030
static inline int acpi_debug_init(void) { return 0; }
3131
#endif
3232

33+
#ifdef CONFIG_DEBUG_FS
34+
int acpi_debugfs_init(void);
35+
#else
36+
static inline int acpi_debugfs_init(void) { return 0; }
37+
#endif
38+
3339
/* --------------------------------------------------------------------------
3440
Power Resource
3541
-------------------------------------------------------------------------- */

include/acpi/acpixf.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ extern u8 acpi_gbl_leave_wake_gpes_disabled;
6767
extern u8 acpi_gbl_use_default_register_widths;
6868
extern acpi_name acpi_gbl_trace_method_name;
6969
extern u32 acpi_gbl_trace_flags;
70-
extern u8 acpi_gbl_enable_aml_debug_object;
70+
extern u32 acpi_gbl_enable_aml_debug_object;
7171
extern u8 acpi_gbl_copy_dsdt_locally;
7272
extern u8 acpi_gbl_truncate_io_addresses;
7373

0 commit comments

Comments
 (0)