aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/acpi
diff options
context:
space:
mode:
authorZhang Rui <rui.zhang@intel.com>2010-07-14 22:46:30 -0400
committerLen Brown <len.brown@intel.com>2010-08-15 00:26:30 -0400
commit1c8fce27e275fd7c6b75bc6455745f02d3903ee6 (patch)
tree3d98b0879ba6bf0b8dca08e6ff185b5febb8026a /drivers/acpi
parentc172cb73bc79fe69915b1a1a48e374aa4b1f8a59 (diff)
ACPI: introduce drivers/acpi/sysfs.c
Introduce drivers/acpi/sysfs.c. code for ACPI sysfs I/F, including #ifdef ACPI_DEBUG /sys/module/acpi/parameters/debug_layer /sys/module/acpi/parameters/debug_level /sys/module/acpi/parameters/trace_method_name /sys/module/acpi/parameters/trace_debug_layer /sys/module/acpi/parameters/trace_debug_level /sys/module/acpi/parameters/trace_state #endif /sys/module/acpi/parameters/acpica_version /sys/firmware/acpi/tables/ /sys/firmware/acpi/interrupts/ is moved to this file. No function change in this patch. Signed-off-by: Zhang Rui <rui.zhang@intel.com> Signed-off-by: Len Brown <len.brown@intel.com>
Diffstat (limited to 'drivers/acpi')
-rw-r--r--drivers/acpi/Makefile1
-rw-r--r--drivers/acpi/bus.c1
-rw-r--r--drivers/acpi/debug.c104
-rw-r--r--drivers/acpi/internal.h1
-rw-r--r--drivers/acpi/sysfs.c685
-rw-r--r--drivers/acpi/system.c467
6 files changed, 688 insertions, 571 deletions
diff --git a/drivers/acpi/Makefile b/drivers/acpi/Makefile
index 7891904419fc..03a81a844d23 100644
--- a/drivers/acpi/Makefile
+++ b/drivers/acpi/Makefile
@@ -38,6 +38,7 @@ acpi-$(CONFIG_ACPI_DOCK) += dock.o
38acpi-y += pci_root.o pci_link.o pci_irq.o pci_bind.o 38acpi-y += pci_root.o pci_link.o pci_irq.o pci_bind.o
39acpi-y += power.o 39acpi-y += power.o
40acpi-y += system.o event.o 40acpi-y += system.o event.o
41acpi-y += sysfs.o
41acpi-$(CONFIG_ACPI_DEBUG) += debug.o 42acpi-$(CONFIG_ACPI_DEBUG) += debug.o
42acpi-$(CONFIG_DEBUG_FS) += debugfs.o 43acpi-$(CONFIG_DEBUG_FS) += debugfs.o
43acpi-$(CONFIG_ACPI_NUMA) += numa.o 44acpi-$(CONFIG_ACPI_NUMA) += numa.o
diff --git a/drivers/acpi/bus.c b/drivers/acpi/bus.c
index 7136f24e3002..bd9708b0f3f3 100644
--- a/drivers/acpi/bus.c
+++ b/drivers/acpi/bus.c
@@ -1036,6 +1036,7 @@ static int __init acpi_init(void)
1036 acpi_power_init(); 1036 acpi_power_init();
1037 acpi_system_init(); 1037 acpi_system_init();
1038 acpi_debug_init(); 1038 acpi_debug_init();
1039 acpi_sysfs_init();
1039 acpi_debugfs_init(); 1040 acpi_debugfs_init();
1040 acpi_sleep_proc_init(); 1041 acpi_sleep_proc_init();
1041 acpi_wakeup_device_init(); 1042 acpi_wakeup_device_init();
diff --git a/drivers/acpi/debug.c b/drivers/acpi/debug.c
index 22476eab2b08..f82240dbbba3 100644
--- a/drivers/acpi/debug.c
+++ b/drivers/acpi/debug.c
@@ -94,110 +94,6 @@ static const struct acpi_dlevel acpi_debug_levels[] = {
94}; 94};
95 95
96/* -------------------------------------------------------------------------- 96/* --------------------------------------------------------------------------
97 FS Interface (/sys)
98 -------------------------------------------------------------------------- */
99static int param_get_debug_layer(char *buffer, struct kernel_param *kp) {
100 int result = 0;
101 int i;
102
103 result = sprintf(buffer, "%-25s\tHex SET\n", "Description");
104
105 for(i = 0; i <ARRAY_SIZE(acpi_debug_layers); i++) {
106 result += sprintf(buffer+result, "%-25s\t0x%08lX [%c]\n",
107 acpi_debug_layers[i].name,
108 acpi_debug_layers[i].value,
109 (acpi_dbg_layer & acpi_debug_layers[i].value) ? '*' : ' ');
110 }
111 result += sprintf(buffer+result, "%-25s\t0x%08X [%c]\n", "ACPI_ALL_DRIVERS",
112 ACPI_ALL_DRIVERS,
113 (acpi_dbg_layer & ACPI_ALL_DRIVERS) ==
114 ACPI_ALL_DRIVERS ? '*' : (acpi_dbg_layer &
115 ACPI_ALL_DRIVERS) == 0 ? ' ' : '-');
116 result += sprintf(buffer+result, "--\ndebug_layer = 0x%08X ( * = enabled)\n", acpi_dbg_layer);
117
118 return result;
119}
120
121static int param_get_debug_level(char *buffer, struct kernel_param *kp) {
122 int result = 0;
123 int i;
124
125 result = sprintf(buffer, "%-25s\tHex SET\n", "Description");
126
127 for (i = 0; i < ARRAY_SIZE(acpi_debug_levels); i++) {
128 result += sprintf(buffer+result, "%-25s\t0x%08lX [%c]\n",
129 acpi_debug_levels[i].name,
130 acpi_debug_levels[i].value,
131 (acpi_dbg_level & acpi_debug_levels[i].
132 value) ? '*' : ' ');
133 }
134 result += sprintf(buffer+result, "--\ndebug_level = 0x%08X (* = enabled)\n",
135 acpi_dbg_level);
136
137 return result;
138}
139
140module_param_call(debug_layer, param_set_uint, param_get_debug_layer, &acpi_dbg_layer, 0644);
141module_param_call(debug_level, param_set_uint, param_get_debug_level, &acpi_dbg_level, 0644);
142
143static char trace_method_name[6];
144module_param_string(trace_method_name, trace_method_name, 6, 0644);
145static unsigned int trace_debug_layer;
146module_param(trace_debug_layer, uint, 0644);
147static unsigned int trace_debug_level;
148module_param(trace_debug_level, uint, 0644);
149
150static int param_set_trace_state(const char *val, struct kernel_param *kp)
151{
152 int result = 0;
153
154 if (!strncmp(val, "enable", strlen("enable") - 1)) {
155 result = acpi_debug_trace(trace_method_name, trace_debug_level,
156 trace_debug_layer, 0);
157 if (result)
158 result = -EBUSY;
159 goto exit;
160 }
161
162 if (!strncmp(val, "disable", strlen("disable") - 1)) {
163 int name = 0;
164 result = acpi_debug_trace((char *)&name, trace_debug_level,
165 trace_debug_layer, 0);
166 if (result)
167 result = -EBUSY;
168 goto exit;
169 }
170
171 if (!strncmp(val, "1", 1)) {
172 result = acpi_debug_trace(trace_method_name, trace_debug_level,
173 trace_debug_layer, 1);
174 if (result)
175 result = -EBUSY;
176 goto exit;
177 }
178
179 result = -EINVAL;
180exit:
181 return result;
182}
183
184static int param_get_trace_state(char *buffer, struct kernel_param *kp)
185{
186 if (!acpi_gbl_trace_method_name)
187 return sprintf(buffer, "disable");
188 else {
189 if (acpi_gbl_trace_flags & 1)
190 return sprintf(buffer, "1");
191 else
192 return sprintf(buffer, "enable");
193 }
194 return 0;
195}
196
197module_param_call(trace_state, param_set_trace_state, param_get_trace_state,
198 NULL, 0644);
199
200/* --------------------------------------------------------------------------
201 FS Interface (/proc) 97 FS Interface (/proc)
202 -------------------------------------------------------------------------- */ 98 -------------------------------------------------------------------------- */
203#ifdef CONFIG_ACPI_PROCFS 99#ifdef CONFIG_ACPI_PROCFS
diff --git a/drivers/acpi/internal.h b/drivers/acpi/internal.h
index 0650e343867e..eed823418559 100644
--- a/drivers/acpi/internal.h
+++ b/drivers/acpi/internal.h
@@ -23,6 +23,7 @@
23int init_acpi_device_notify(void); 23int init_acpi_device_notify(void);
24int acpi_scan_init(void); 24int acpi_scan_init(void);
25int acpi_system_init(void); 25int acpi_system_init(void);
26int acpi_sysfs_init(void);
26 27
27#ifdef CONFIG_ACPI_DEBUG 28#ifdef CONFIG_ACPI_DEBUG
28int acpi_debug_init(void); 29int acpi_debug_init(void);
diff --git a/drivers/acpi/sysfs.c b/drivers/acpi/sysfs.c
new file mode 100644
index 000000000000..68e2e4582fa2
--- /dev/null
+++ b/drivers/acpi/sysfs.c
@@ -0,0 +1,685 @@
1/*
2 * sysfs.c - ACPI sysfs interface to userspace.
3 */
4
5#include <linux/init.h>
6#include <linux/kernel.h>
7#include <linux/moduleparam.h>
8#include <acpi/acpi_drivers.h>
9
10#define _COMPONENT ACPI_SYSTEM_COMPONENT
11ACPI_MODULE_NAME("sysfs");
12
13#define PREFIX "ACPI: "
14
15#ifdef CONFIG_ACPI_DEBUG
16/*
17 * ACPI debug sysfs I/F, including:
18 * /sys/modules/acpi/parameters/debug_layer
19 * /sys/modules/acpi/parameters/debug_level
20 * /sys/modules/acpi/parameters/trace_method_name
21 * /sys/modules/acpi/parameters/trace_state
22 * /sys/modules/acpi/parameters/trace_debug_layer
23 * /sys/modules/acpi/parameters/trace_debug_level
24 */
25
26struct acpi_dlayer {
27 const char *name;
28 unsigned long value;
29};
30struct acpi_dlevel {
31 const char *name;
32 unsigned long value;
33};
34#define ACPI_DEBUG_INIT(v) { .name = #v, .value = v }
35
36static const struct acpi_dlayer acpi_debug_layers[] = {
37 ACPI_DEBUG_INIT(ACPI_UTILITIES),
38 ACPI_DEBUG_INIT(ACPI_HARDWARE),
39 ACPI_DEBUG_INIT(ACPI_EVENTS),
40 ACPI_DEBUG_INIT(ACPI_TABLES),
41 ACPI_DEBUG_INIT(ACPI_NAMESPACE),
42 ACPI_DEBUG_INIT(ACPI_PARSER),
43 ACPI_DEBUG_INIT(ACPI_DISPATCHER),
44 ACPI_DEBUG_INIT(ACPI_EXECUTER),
45 ACPI_DEBUG_INIT(ACPI_RESOURCES),
46 ACPI_DEBUG_INIT(ACPI_CA_DEBUGGER),
47 ACPI_DEBUG_INIT(ACPI_OS_SERVICES),
48 ACPI_DEBUG_INIT(ACPI_CA_DISASSEMBLER),
49 ACPI_DEBUG_INIT(ACPI_COMPILER),
50 ACPI_DEBUG_INIT(ACPI_TOOLS),
51
52 ACPI_DEBUG_INIT(ACPI_BUS_COMPONENT),
53 ACPI_DEBUG_INIT(ACPI_AC_COMPONENT),
54 ACPI_DEBUG_INIT(ACPI_BATTERY_COMPONENT),
55 ACPI_DEBUG_INIT(ACPI_BUTTON_COMPONENT),
56 ACPI_DEBUG_INIT(ACPI_SBS_COMPONENT),
57 ACPI_DEBUG_INIT(ACPI_FAN_COMPONENT),
58 ACPI_DEBUG_INIT(ACPI_PCI_COMPONENT),
59 ACPI_DEBUG_INIT(ACPI_POWER_COMPONENT),
60 ACPI_DEBUG_INIT(ACPI_CONTAINER_COMPONENT),
61 ACPI_DEBUG_INIT(ACPI_SYSTEM_COMPONENT),
62 ACPI_DEBUG_INIT(ACPI_THERMAL_COMPONENT),
63 ACPI_DEBUG_INIT(ACPI_MEMORY_DEVICE_COMPONENT),
64 ACPI_DEBUG_INIT(ACPI_VIDEO_COMPONENT),
65 ACPI_DEBUG_INIT(ACPI_PROCESSOR_COMPONENT),
66};
67
68static const struct acpi_dlevel acpi_debug_levels[] = {
69 ACPI_DEBUG_INIT(ACPI_LV_INIT),
70 ACPI_DEBUG_INIT(ACPI_LV_DEBUG_OBJECT),
71 ACPI_DEBUG_INIT(ACPI_LV_INFO),
72
73 ACPI_DEBUG_INIT(ACPI_LV_INIT_NAMES),
74 ACPI_DEBUG_INIT(ACPI_LV_PARSE),
75 ACPI_DEBUG_INIT(ACPI_LV_LOAD),
76 ACPI_DEBUG_INIT(ACPI_LV_DISPATCH),
77 ACPI_DEBUG_INIT(ACPI_LV_EXEC),
78 ACPI_DEBUG_INIT(ACPI_LV_NAMES),
79 ACPI_DEBUG_INIT(ACPI_LV_OPREGION),
80 ACPI_DEBUG_INIT(ACPI_LV_BFIELD),
81 ACPI_DEBUG_INIT(ACPI_LV_TABLES),
82 ACPI_DEBUG_INIT(ACPI_LV_VALUES),
83 ACPI_DEBUG_INIT(ACPI_LV_OBJECTS),
84 ACPI_DEBUG_INIT(ACPI_LV_RESOURCES),
85 ACPI_DEBUG_INIT(ACPI_LV_USER_REQUESTS),
86 ACPI_DEBUG_INIT(ACPI_LV_PACKAGE),
87
88 ACPI_DEBUG_INIT(ACPI_LV_ALLOCATIONS),
89 ACPI_DEBUG_INIT(ACPI_LV_FUNCTIONS),
90 ACPI_DEBUG_INIT(ACPI_LV_OPTIMIZATIONS),
91
92 ACPI_DEBUG_INIT(ACPI_LV_MUTEX),
93 ACPI_DEBUG_INIT(ACPI_LV_THREADS),
94 ACPI_DEBUG_INIT(ACPI_LV_IO),
95 ACPI_DEBUG_INIT(ACPI_LV_INTERRUPTS),
96
97 ACPI_DEBUG_INIT(ACPI_LV_AML_DISASSEMBLE),
98 ACPI_DEBUG_INIT(ACPI_LV_VERBOSE_INFO),
99 ACPI_DEBUG_INIT(ACPI_LV_FULL_TABLES),
100 ACPI_DEBUG_INIT(ACPI_LV_EVENTS),
101};
102
103static int param_get_debug_layer(char *buffer, struct kernel_param *kp)
104{
105 int result = 0;
106 int i;
107
108 result = sprintf(buffer, "%-25s\tHex SET\n", "Description");
109
110 for (i = 0; i < ARRAY_SIZE(acpi_debug_layers); i++) {
111 result += sprintf(buffer + result, "%-25s\t0x%08lX [%c]\n",
112 acpi_debug_layers[i].name,
113 acpi_debug_layers[i].value,
114 (acpi_dbg_layer & acpi_debug_layers[i].value)
115 ? '*' : ' ');
116 }
117 result +=
118 sprintf(buffer + result, "%-25s\t0x%08X [%c]\n", "ACPI_ALL_DRIVERS",
119 ACPI_ALL_DRIVERS,
120 (acpi_dbg_layer & ACPI_ALL_DRIVERS) ==
121 ACPI_ALL_DRIVERS ? '*' : (acpi_dbg_layer & ACPI_ALL_DRIVERS)
122 == 0 ? ' ' : '-');
123 result +=
124 sprintf(buffer + result,
125 "--\ndebug_layer = 0x%08X ( * = enabled)\n",
126 acpi_dbg_layer);
127
128 return result;
129}
130
131static int param_get_debug_level(char *buffer, struct kernel_param *kp)
132{
133 int result = 0;
134 int i;
135
136 result = sprintf(buffer, "%-25s\tHex SET\n", "Description");
137
138 for (i = 0; i < ARRAY_SIZE(acpi_debug_levels); i++) {
139 result += sprintf(buffer + result, "%-25s\t0x%08lX [%c]\n",
140 acpi_debug_levels[i].name,
141 acpi_debug_levels[i].value,
142 (acpi_dbg_level & acpi_debug_levels[i].value)
143 ? '*' : ' ');
144 }
145 result +=
146 sprintf(buffer + result, "--\ndebug_level = 0x%08X (* = enabled)\n",
147 acpi_dbg_level);
148
149 return result;
150}
151
152module_param_call(debug_layer, param_set_uint, param_get_debug_layer,
153 &acpi_dbg_layer, 0644);
154module_param_call(debug_level, param_set_uint, param_get_debug_level,
155 &acpi_dbg_level, 0644);
156
157static char trace_method_name[6];
158module_param_string(trace_method_name, trace_method_name, 6, 0644);
159static unsigned int trace_debug_layer;
160module_param(trace_debug_layer, uint, 0644);
161static unsigned int trace_debug_level;
162module_param(trace_debug_level, uint, 0644);
163
164static int param_set_trace_state(const char *val, struct kernel_param *kp)
165{
166 int result = 0;
167
168 if (!strncmp(val, "enable", strlen("enable") - 1)) {
169 result = acpi_debug_trace(trace_method_name, trace_debug_level,
170 trace_debug_layer, 0);
171 if (result)
172 result = -EBUSY;
173 goto exit;
174 }
175
176 if (!strncmp(val, "disable", strlen("disable") - 1)) {
177 int name = 0;
178 result = acpi_debug_trace((char *)&name, trace_debug_level,
179 trace_debug_layer, 0);
180 if (result)
181 result = -EBUSY;
182 goto exit;
183 }
184
185 if (!strncmp(val, "1", 1)) {
186 result = acpi_debug_trace(trace_method_name, trace_debug_level,
187 trace_debug_layer, 1);
188 if (result)
189 result = -EBUSY;
190 goto exit;
191 }
192
193 result = -EINVAL;
194exit:
195 return result;
196}
197
198static int param_get_trace_state(char *buffer, struct kernel_param *kp)
199{
200 if (!acpi_gbl_trace_method_name)
201 return sprintf(buffer, "disable");
202 else {
203 if (acpi_gbl_trace_flags & 1)
204 return sprintf(buffer, "1");
205 else
206 return sprintf(buffer, "enable");
207 }
208 return 0;
209}
210
211module_param_call(trace_state, param_set_trace_state, param_get_trace_state,
212 NULL, 0644);
213#endif /* CONFIG_ACPI_DEBUG */
214
215/* /sys/module/acpi/parameters/acpica_version */
216static int param_get_acpica_version(char *buffer, struct kernel_param *kp)
217{
218 int result;
219
220 result = sprintf(buffer, "%x", ACPI_CA_VERSION);
221
222 return result;
223}
224
225module_param_call(acpica_version, NULL, param_get_acpica_version, NULL, 0444);
226
227/*
228 * ACPI table sysfs I/F:
229 * /sys/firmware/acpi/tables/
230 * /sys/firmware/acpi/tables/dynamic/
231 */
232
233static LIST_HEAD(acpi_table_attr_list);
234static struct kobject *tables_kobj;
235static struct kobject *dynamic_tables_kobj;
236
237struct acpi_table_attr {
238 struct bin_attribute attr;
239 char name[8];
240 int instance;
241 struct list_head node;
242};
243
244static ssize_t acpi_table_show(struct file *filp, struct kobject *kobj,
245 struct bin_attribute *bin_attr, char *buf,
246 loff_t offset, size_t count)
247{
248 struct acpi_table_attr *table_attr =
249 container_of(bin_attr, struct acpi_table_attr, attr);
250 struct acpi_table_header *table_header = NULL;
251 acpi_status status;
252 char name[ACPI_NAME_SIZE];
253
254 if (strncmp(table_attr->name, "NULL", 4))
255 memcpy(name, table_attr->name, ACPI_NAME_SIZE);
256 else
257 memcpy(name, "\0\0\0\0", 4);
258
259 status = acpi_get_table(name, table_attr->instance, &table_header);
260 if (ACPI_FAILURE(status))
261 return -ENODEV;
262
263 return memory_read_from_buffer(buf, count, &offset,
264 table_header, table_header->length);
265}
266
267static void acpi_table_attr_init(struct acpi_table_attr *table_attr,
268 struct acpi_table_header *table_header)
269{
270 struct acpi_table_header *header = NULL;
271 struct acpi_table_attr *attr = NULL;
272
273 sysfs_attr_init(&table_attr->attr.attr);
274 if (table_header->signature[0] != '\0')
275 memcpy(table_attr->name, table_header->signature,
276 ACPI_NAME_SIZE);
277 else
278 memcpy(table_attr->name, "NULL", 4);
279
280 list_for_each_entry(attr, &acpi_table_attr_list, node) {
281 if (!memcmp(table_attr->name, attr->name, ACPI_NAME_SIZE))
282 if (table_attr->instance < attr->instance)
283 table_attr->instance = attr->instance;
284 }
285 table_attr->instance++;
286
287 if (table_attr->instance > 1 || (table_attr->instance == 1 &&
288 !acpi_get_table
289 (table_header->signature, 2, &header)))
290 sprintf(table_attr->name + ACPI_NAME_SIZE, "%d",
291 table_attr->instance);
292
293 table_attr->attr.size = 0;
294 table_attr->attr.read = acpi_table_show;
295 table_attr->attr.attr.name = table_attr->name;
296 table_attr->attr.attr.mode = 0400;
297
298 return;
299}
300
301static acpi_status
302acpi_sysfs_table_handler(u32 event, void *table, void *context)
303{
304 struct acpi_table_attr *table_attr;
305
306 switch (event) {
307 case ACPI_TABLE_EVENT_LOAD:
308 table_attr =
309 kzalloc(sizeof(struct acpi_table_attr), GFP_KERNEL);
310 if (!table_attr)
311 return AE_NO_MEMORY;
312
313 acpi_table_attr_init(table_attr, table);
314 if (sysfs_create_bin_file(dynamic_tables_kobj,
315 &table_attr->attr)) {
316 kfree(table_attr);
317 return AE_ERROR;
318 } else
319 list_add_tail(&table_attr->node, &acpi_table_attr_list);
320 break;
321 case ACPI_TABLE_EVENT_UNLOAD:
322 /*
323 * we do not need to do anything right now
324 * because the table is not deleted from the
325 * global table list when unloading it.
326 */
327 break;
328 default:
329 return AE_BAD_PARAMETER;
330 }
331 return AE_OK;
332}
333
334static int acpi_tables_sysfs_init(void)
335{
336 struct acpi_table_attr *table_attr;
337 struct acpi_table_header *table_header = NULL;
338 int table_index = 0;
339 int result;
340
341 tables_kobj = kobject_create_and_add("tables", acpi_kobj);
342 if (!tables_kobj)
343 goto err;
344
345 dynamic_tables_kobj = kobject_create_and_add("dynamic", tables_kobj);
346 if (!dynamic_tables_kobj)
347 goto err_dynamic_tables;
348
349 do {
350 result = acpi_get_table_by_index(table_index, &table_header);
351 if (!result) {
352 table_index++;
353 table_attr = NULL;
354 table_attr =
355 kzalloc(sizeof(struct acpi_table_attr), GFP_KERNEL);
356 if (!table_attr)
357 return -ENOMEM;
358
359 acpi_table_attr_init(table_attr, table_header);
360 result =
361 sysfs_create_bin_file(tables_kobj,
362 &table_attr->attr);
363 if (result) {
364 kfree(table_attr);
365 return result;
366 } else
367 list_add_tail(&table_attr->node,
368 &acpi_table_attr_list);
369 }
370 } while (!result);
371 kobject_uevent(tables_kobj, KOBJ_ADD);
372 kobject_uevent(dynamic_tables_kobj, KOBJ_ADD);
373 result = acpi_install_table_handler(acpi_sysfs_table_handler, NULL);
374
375 return result == AE_OK ? 0 : -EINVAL;
376err_dynamic_tables:
377 kobject_put(tables_kobj);
378err:
379 return -ENOMEM;
380}
381
382/*
383 * Detailed ACPI IRQ counters:
384 * /sys/firmware/acpi/interrupts/
385 */
386
387u32 acpi_irq_handled;
388u32 acpi_irq_not_handled;
389
390#define COUNT_GPE 0
391#define COUNT_SCI 1 /* acpi_irq_handled */
392#define COUNT_SCI_NOT 2 /* acpi_irq_not_handled */
393#define COUNT_ERROR 3 /* other */
394#define NUM_COUNTERS_EXTRA 4
395
396struct event_counter {
397 u32 count;
398 u32 flags;
399};
400
401static struct event_counter *all_counters;
402static u32 num_gpes;
403static u32 num_counters;
404static struct attribute **all_attrs;
405static u32 acpi_gpe_count;
406
407static struct attribute_group interrupt_stats_attr_group = {
408 .name = "interrupts",
409};
410
411static struct kobj_attribute *counter_attrs;
412
413static void delete_gpe_attr_array(void)
414{
415 struct event_counter *tmp = all_counters;
416
417 all_counters = NULL;
418 kfree(tmp);
419
420 if (counter_attrs) {
421 int i;
422
423 for (i = 0; i < num_gpes; i++)
424 kfree(counter_attrs[i].attr.name);
425
426 kfree(counter_attrs);
427 }
428 kfree(all_attrs);
429
430 return;
431}
432
433void acpi_os_gpe_count(u32 gpe_number)
434{
435 acpi_gpe_count++;
436
437 if (!all_counters)
438 return;
439
440 if (gpe_number < num_gpes)
441 all_counters[gpe_number].count++;
442 else
443 all_counters[num_gpes + ACPI_NUM_FIXED_EVENTS +
444 COUNT_ERROR].count++;
445
446 return;
447}
448
449void acpi_os_fixed_event_count(u32 event_number)
450{
451 if (!all_counters)
452 return;
453
454 if (event_number < ACPI_NUM_FIXED_EVENTS)
455 all_counters[num_gpes + event_number].count++;
456 else
457 all_counters[num_gpes + ACPI_NUM_FIXED_EVENTS +
458 COUNT_ERROR].count++;
459
460 return;
461}
462
463static int get_status(u32 index, acpi_event_status *status,
464 acpi_handle *handle)
465{
466 int result = 0;
467
468 if (index >= num_gpes + ACPI_NUM_FIXED_EVENTS)
469 goto end;
470
471 if (index < num_gpes) {
472 result = acpi_get_gpe_device(index, handle);
473 if (result) {
474 ACPI_EXCEPTION((AE_INFO, AE_NOT_FOUND,
475 "Invalid GPE 0x%x\n", index));
476 goto end;
477 }
478 result = acpi_get_gpe_status(*handle, index, status);
479 } else if (index < (num_gpes + ACPI_NUM_FIXED_EVENTS))
480 result = acpi_get_event_status(index - num_gpes, status);
481
482end:
483 return result;
484}
485
486static ssize_t counter_show(struct kobject *kobj,
487 struct kobj_attribute *attr, char *buf)
488{
489 int index = attr - counter_attrs;
490 int size;
491 acpi_handle handle;
492 acpi_event_status status;
493 int result = 0;
494
495 all_counters[num_gpes + ACPI_NUM_FIXED_EVENTS + COUNT_SCI].count =
496 acpi_irq_handled;
497 all_counters[num_gpes + ACPI_NUM_FIXED_EVENTS + COUNT_SCI_NOT].count =
498 acpi_irq_not_handled;
499 all_counters[num_gpes + ACPI_NUM_FIXED_EVENTS + COUNT_GPE].count =
500 acpi_gpe_count;
501 size = sprintf(buf, "%8d", all_counters[index].count);
502
503 /* "gpe_all" or "sci" */
504 if (index >= num_gpes + ACPI_NUM_FIXED_EVENTS)
505 goto end;
506
507 result = get_status(index, &status, &handle);
508 if (result)
509 goto end;
510
511 if (!(status & ACPI_EVENT_FLAG_HANDLE))
512 size += sprintf(buf + size, " invalid");
513 else if (status & ACPI_EVENT_FLAG_ENABLED)
514 size += sprintf(buf + size, " enabled");
515 else if (status & ACPI_EVENT_FLAG_WAKE_ENABLED)
516 size += sprintf(buf + size, " wake_enabled");
517 else
518 size += sprintf(buf + size, " disabled");
519
520end:
521 size += sprintf(buf + size, "\n");
522 return result ? result : size;
523}
524
525/*
526 * counter_set() sets the specified counter.
527 * setting the total "sci" file to any value clears all counters.
528 * enable/disable/clear a gpe/fixed event in user space.
529 */
530static ssize_t counter_set(struct kobject *kobj,
531 struct kobj_attribute *attr, const char *buf,
532 size_t size)
533{
534 int index = attr - counter_attrs;
535 acpi_event_status status;
536 acpi_handle handle;
537 int result = 0;
538
539 if (index == num_gpes + ACPI_NUM_FIXED_EVENTS + COUNT_SCI) {
540 int i;
541 for (i = 0; i < num_counters; ++i)
542 all_counters[i].count = 0;
543 acpi_gpe_count = 0;
544 acpi_irq_handled = 0;
545 acpi_irq_not_handled = 0;
546 goto end;
547 }
548
549 /* show the event status for both GPEs and Fixed Events */
550 result = get_status(index, &status, &handle);
551 if (result)
552 goto end;
553
554 if (!(status & ACPI_EVENT_FLAG_HANDLE)) {
555 printk(KERN_WARNING PREFIX
556 "Can not change Invalid GPE/Fixed Event status\n");
557 return -EINVAL;
558 }
559
560 if (index < num_gpes) {
561 if (!strcmp(buf, "disable\n") &&
562 (status & ACPI_EVENT_FLAG_ENABLED))
563 result = acpi_disable_gpe(handle, index);
564 else if (!strcmp(buf, "enable\n") &&
565 !(status & ACPI_EVENT_FLAG_ENABLED))
566 result = acpi_enable_gpe(handle, index);
567 else if (!strcmp(buf, "clear\n") &&
568 (status & ACPI_EVENT_FLAG_SET))
569 result = acpi_clear_gpe(handle, index);
570 else
571 all_counters[index].count = strtoul(buf, NULL, 0);
572 } else if (index < num_gpes + ACPI_NUM_FIXED_EVENTS) {
573 int event = index - num_gpes;
574 if (!strcmp(buf, "disable\n") &&
575 (status & ACPI_EVENT_FLAG_ENABLED))
576 result = acpi_disable_event(event, ACPI_NOT_ISR);
577 else if (!strcmp(buf, "enable\n") &&
578 !(status & ACPI_EVENT_FLAG_ENABLED))
579 result = acpi_enable_event(event, ACPI_NOT_ISR);
580 else if (!strcmp(buf, "clear\n") &&
581 (status & ACPI_EVENT_FLAG_SET))
582 result = acpi_clear_event(event);
583 else
584 all_counters[index].count = strtoul(buf, NULL, 0);
585 } else
586 all_counters[index].count = strtoul(buf, NULL, 0);
587
588 if (ACPI_FAILURE(result))
589 result = -EINVAL;
590end:
591 return result ? result : size;
592}
593
594void acpi_irq_stats_init(void)
595{
596 int i;
597
598 if (all_counters)
599 return;
600
601 num_gpes = acpi_current_gpe_count;
602 num_counters = num_gpes + ACPI_NUM_FIXED_EVENTS + NUM_COUNTERS_EXTRA;
603
604 all_attrs = kzalloc(sizeof(struct attribute *) * (num_counters + 1),
605 GFP_KERNEL);
606 if (all_attrs == NULL)
607 return;
608
609 all_counters = kzalloc(sizeof(struct event_counter) * (num_counters),
610 GFP_KERNEL);
611 if (all_counters == NULL)
612 goto fail;
613
614 counter_attrs = kzalloc(sizeof(struct kobj_attribute) * (num_counters),
615 GFP_KERNEL);
616 if (counter_attrs == NULL)
617 goto fail;
618
619 for (i = 0; i < num_counters; ++i) {
620 char buffer[12];
621 char *name;
622
623 if (i < num_gpes)
624 sprintf(buffer, "gpe%02X", i);
625 else if (i == num_gpes + ACPI_EVENT_PMTIMER)
626 sprintf(buffer, "ff_pmtimer");
627 else if (i == num_gpes + ACPI_EVENT_GLOBAL)
628 sprintf(buffer, "ff_gbl_lock");
629 else if (i == num_gpes + ACPI_EVENT_POWER_BUTTON)
630 sprintf(buffer, "ff_pwr_btn");
631 else if (i == num_gpes + ACPI_EVENT_SLEEP_BUTTON)
632 sprintf(buffer, "ff_slp_btn");
633 else if (i == num_gpes + ACPI_EVENT_RTC)
634 sprintf(buffer, "ff_rt_clk");
635 else if (i == num_gpes + ACPI_NUM_FIXED_EVENTS + COUNT_GPE)
636 sprintf(buffer, "gpe_all");
637 else if (i == num_gpes + ACPI_NUM_FIXED_EVENTS + COUNT_SCI)
638 sprintf(buffer, "sci");
639 else if (i == num_gpes + ACPI_NUM_FIXED_EVENTS + COUNT_SCI_NOT)
640 sprintf(buffer, "sci_not");
641 else if (i == num_gpes + ACPI_NUM_FIXED_EVENTS + COUNT_ERROR)
642 sprintf(buffer, "error");
643 else
644 sprintf(buffer, "bug%02X", i);
645
646 name = kzalloc(strlen(buffer) + 1, GFP_KERNEL);
647 if (name == NULL)
648 goto fail;
649 strncpy(name, buffer, strlen(buffer) + 1);
650
651 sysfs_attr_init(&counter_attrs[i].attr);
652 counter_attrs[i].attr.name = name;
653 counter_attrs[i].attr.mode = 0644;
654 counter_attrs[i].show = counter_show;
655 counter_attrs[i].store = counter_set;
656
657 all_attrs[i] = &counter_attrs[i].attr;
658 }
659
660 interrupt_stats_attr_group.attrs = all_attrs;
661 if (!sysfs_create_group(acpi_kobj, &interrupt_stats_attr_group))
662 return;
663
664fail:
665 delete_gpe_attr_array();
666 return;
667}
668
669static void __exit interrupt_stats_exit(void)
670{
671 sysfs_remove_group(acpi_kobj, &interrupt_stats_attr_group);
672
673 delete_gpe_attr_array();
674
675 return;
676}
677
678int __init acpi_sysfs_init(void)
679{
680 int result;
681
682 result = acpi_tables_sysfs_init();
683
684 return result;
685}
diff --git a/drivers/acpi/system.c b/drivers/acpi/system.c
index 5981bd07e20e..d70481f32c89 100644
--- a/drivers/acpi/system.c
+++ b/drivers/acpi/system.c
@@ -40,469 +40,6 @@ ACPI_MODULE_NAME("system");
40#define ACPI_SYSTEM_CLASS "system" 40#define ACPI_SYSTEM_CLASS "system"
41#define ACPI_SYSTEM_DEVICE_NAME "System" 41#define ACPI_SYSTEM_DEVICE_NAME "System"
42 42
43u32 acpi_irq_handled;
44u32 acpi_irq_not_handled;
45
46/*
47 * Make ACPICA version work as module param
48 */
49static int param_get_acpica_version(char *buffer, struct kernel_param *kp)
50{
51 int result;
52
53 result = sprintf(buffer, "%x", ACPI_CA_VERSION);
54
55 return result;
56}
57
58module_param_call(acpica_version, NULL, param_get_acpica_version, NULL, 0444);
59
60/* --------------------------------------------------------------------------
61 FS Interface (/sys)
62 -------------------------------------------------------------------------- */
63static LIST_HEAD(acpi_table_attr_list);
64static struct kobject *tables_kobj;
65static struct kobject *dynamic_tables_kobj;
66
67struct acpi_table_attr {
68 struct bin_attribute attr;
69 char name[8];
70 int instance;
71 struct list_head node;
72};
73
74static ssize_t acpi_table_show(struct file *filp, struct kobject *kobj,
75 struct bin_attribute *bin_attr, char *buf,
76 loff_t offset, size_t count)
77{
78 struct acpi_table_attr *table_attr =
79 container_of(bin_attr, struct acpi_table_attr, attr);
80 struct acpi_table_header *table_header = NULL;
81 acpi_status status;
82 char name[ACPI_NAME_SIZE];
83
84 if (strncmp(table_attr->name, "NULL", 4))
85 memcpy(name, table_attr->name, ACPI_NAME_SIZE);
86 else
87 memcpy(name, "\0\0\0\0", 4);
88
89 status =
90 acpi_get_table(name, table_attr->instance,
91 &table_header);
92 if (ACPI_FAILURE(status))
93 return -ENODEV;
94
95 return memory_read_from_buffer(buf, count, &offset,
96 table_header, table_header->length);
97}
98
99static void acpi_table_attr_init(struct acpi_table_attr *table_attr,
100 struct acpi_table_header *table_header)
101{
102 struct acpi_table_header *header = NULL;
103 struct acpi_table_attr *attr = NULL;
104
105 sysfs_attr_init(&table_attr->attr.attr);
106 if (table_header->signature[0] != '\0')
107 memcpy(table_attr->name, table_header->signature,
108 ACPI_NAME_SIZE);
109 else
110 memcpy(table_attr->name, "NULL", 4);
111
112 list_for_each_entry(attr, &acpi_table_attr_list, node) {
113 if (!memcmp(table_attr->name, attr->name, ACPI_NAME_SIZE))
114 if (table_attr->instance < attr->instance)
115 table_attr->instance = attr->instance;
116 }
117 table_attr->instance++;
118
119 if (table_attr->instance > 1 || (table_attr->instance == 1 &&
120 !acpi_get_table
121 (table_header->signature, 2, &header)))
122 sprintf(table_attr->name + ACPI_NAME_SIZE, "%d",
123 table_attr->instance);
124
125 table_attr->attr.size = 0;
126 table_attr->attr.read = acpi_table_show;
127 table_attr->attr.attr.name = table_attr->name;
128 table_attr->attr.attr.mode = 0400;
129
130 return;
131}
132
133static acpi_status
134acpi_sysfs_table_handler(u32 event, void *table, void *context)
135{
136 struct acpi_table_attr *table_attr;
137
138 switch (event) {
139 case ACPI_TABLE_EVENT_LOAD:
140 table_attr =
141 kzalloc(sizeof(struct acpi_table_attr), GFP_KERNEL);
142 if (!table_attr)
143 return AE_NO_MEMORY;
144
145 acpi_table_attr_init(table_attr, table);
146 if (sysfs_create_bin_file(dynamic_tables_kobj,
147 &table_attr->attr)) {
148 kfree(table_attr);
149 return AE_ERROR;
150 } else
151 list_add_tail(&table_attr->node,
152 &acpi_table_attr_list);
153 break;
154 case ACPI_TABLE_EVENT_UNLOAD:
155 /*
156 * we do not need to do anything right now
157 * because the table is not deleted from the
158 * global table list when unloading it.
159 */
160 break;
161 default:
162 return AE_BAD_PARAMETER;
163 }
164 return AE_OK;
165}
166
167static int acpi_system_sysfs_init(void)
168{
169 struct acpi_table_attr *table_attr;
170 struct acpi_table_header *table_header = NULL;
171 int table_index = 0;
172 int result;
173
174 tables_kobj = kobject_create_and_add("tables", acpi_kobj);
175 if (!tables_kobj)
176 goto err;
177
178 dynamic_tables_kobj = kobject_create_and_add("dynamic", tables_kobj);
179 if (!dynamic_tables_kobj)
180 goto err_dynamic_tables;
181
182 do {
183 result = acpi_get_table_by_index(table_index, &table_header);
184 if (!result) {
185 table_index++;
186 table_attr = NULL;
187 table_attr =
188 kzalloc(sizeof(struct acpi_table_attr), GFP_KERNEL);
189 if (!table_attr)
190 return -ENOMEM;
191
192 acpi_table_attr_init(table_attr, table_header);
193 result =
194 sysfs_create_bin_file(tables_kobj,
195 &table_attr->attr);
196 if (result) {
197 kfree(table_attr);
198 return result;
199 } else
200 list_add_tail(&table_attr->node,
201 &acpi_table_attr_list);
202 }
203 } while (!result);
204 kobject_uevent(tables_kobj, KOBJ_ADD);
205 kobject_uevent(dynamic_tables_kobj, KOBJ_ADD);
206 result = acpi_install_table_handler(acpi_sysfs_table_handler, NULL);
207
208 return result == AE_OK ? 0 : -EINVAL;
209err_dynamic_tables:
210 kobject_put(tables_kobj);
211err:
212 return -ENOMEM;
213}
214
215/*
216 * Detailed ACPI IRQ counters in /sys/firmware/acpi/interrupts/
217 * See Documentation/ABI/testing/sysfs-firmware-acpi
218 */
219
220#define COUNT_GPE 0
221#define COUNT_SCI 1 /* acpi_irq_handled */
222#define COUNT_SCI_NOT 2 /* acpi_irq_not_handled */
223#define COUNT_ERROR 3 /* other */
224#define NUM_COUNTERS_EXTRA 4
225
226struct event_counter {
227 u32 count;
228 u32 flags;
229};
230
231static struct event_counter *all_counters;
232static u32 num_gpes;
233static u32 num_counters;
234static struct attribute **all_attrs;
235static u32 acpi_gpe_count;
236
237static struct attribute_group interrupt_stats_attr_group = {
238 .name = "interrupts",
239};
240static struct kobj_attribute *counter_attrs;
241
242static void delete_gpe_attr_array(void)
243{
244 struct event_counter *tmp = all_counters;
245
246 all_counters = NULL;
247 kfree(tmp);
248
249 if (counter_attrs) {
250 int i;
251
252 for (i = 0; i < num_gpes; i++)
253 kfree(counter_attrs[i].attr.name);
254
255 kfree(counter_attrs);
256 }
257 kfree(all_attrs);
258
259 return;
260}
261
262void acpi_os_gpe_count(u32 gpe_number)
263{
264 acpi_gpe_count++;
265
266 if (!all_counters)
267 return;
268
269 if (gpe_number < num_gpes)
270 all_counters[gpe_number].count++;
271 else
272 all_counters[num_gpes + ACPI_NUM_FIXED_EVENTS + COUNT_ERROR].
273 count++;
274
275 return;
276}
277
278void acpi_os_fixed_event_count(u32 event_number)
279{
280 if (!all_counters)
281 return;
282
283 if (event_number < ACPI_NUM_FIXED_EVENTS)
284 all_counters[num_gpes + event_number].count++;
285 else
286 all_counters[num_gpes + ACPI_NUM_FIXED_EVENTS + COUNT_ERROR].
287 count++;
288
289 return;
290}
291
292static int get_status(u32 index, acpi_event_status *status, acpi_handle *handle)
293{
294 int result = 0;
295
296 if (index >= num_gpes + ACPI_NUM_FIXED_EVENTS)
297 goto end;
298
299 if (index < num_gpes) {
300 result = acpi_get_gpe_device(index, handle);
301 if (result) {
302 ACPI_EXCEPTION((AE_INFO, AE_NOT_FOUND,
303 "Invalid GPE 0x%x\n", index));
304 goto end;
305 }
306 result = acpi_get_gpe_status(*handle, index, status);
307 } else if (index < (num_gpes + ACPI_NUM_FIXED_EVENTS))
308 result = acpi_get_event_status(index - num_gpes, status);
309
310end:
311 return result;
312}
313
314static ssize_t counter_show(struct kobject *kobj,
315 struct kobj_attribute *attr, char *buf)
316{
317 int index = attr - counter_attrs;
318 int size;
319 acpi_handle handle;
320 acpi_event_status status;
321 int result = 0;
322
323 all_counters[num_gpes + ACPI_NUM_FIXED_EVENTS + COUNT_SCI].count =
324 acpi_irq_handled;
325 all_counters[num_gpes + ACPI_NUM_FIXED_EVENTS + COUNT_SCI_NOT].count =
326 acpi_irq_not_handled;
327 all_counters[num_gpes + ACPI_NUM_FIXED_EVENTS + COUNT_GPE].count =
328 acpi_gpe_count;
329
330 size = sprintf(buf, "%8d", all_counters[index].count);
331
332 /* "gpe_all" or "sci" */
333 if (index >= num_gpes + ACPI_NUM_FIXED_EVENTS)
334 goto end;
335
336 result = get_status(index, &status, &handle);
337 if (result)
338 goto end;
339
340 if (!(status & ACPI_EVENT_FLAG_HANDLE))
341 size += sprintf(buf + size, " invalid");
342 else if (status & ACPI_EVENT_FLAG_ENABLED)
343 size += sprintf(buf + size, " enabled");
344 else if (status & ACPI_EVENT_FLAG_WAKE_ENABLED)
345 size += sprintf(buf + size, " wake_enabled");
346 else
347 size += sprintf(buf + size, " disabled");
348
349end:
350 size += sprintf(buf + size, "\n");
351 return result ? result : size;
352}
353
354/*
355 * counter_set() sets the specified counter.
356 * setting the total "sci" file to any value clears all counters.
357 * enable/disable/clear a gpe/fixed event in user space.
358 */
359static ssize_t counter_set(struct kobject *kobj,
360 struct kobj_attribute *attr, const char *buf, size_t size)
361{
362 int index = attr - counter_attrs;
363 acpi_event_status status;
364 acpi_handle handle;
365 int result = 0;
366
367 if (index == num_gpes + ACPI_NUM_FIXED_EVENTS + COUNT_SCI) {
368 int i;
369 for (i = 0; i < num_counters; ++i)
370 all_counters[i].count = 0;
371 acpi_gpe_count = 0;
372 acpi_irq_handled = 0;
373 acpi_irq_not_handled = 0;
374 goto end;
375 }
376
377 /* show the event status for both GPEs and Fixed Events */
378 result = get_status(index, &status, &handle);
379 if (result)
380 goto end;
381
382 if (!(status & ACPI_EVENT_FLAG_HANDLE)) {
383 printk(KERN_WARNING PREFIX
384 "Can not change Invalid GPE/Fixed Event status\n");
385 return -EINVAL;
386 }
387
388 if (index < num_gpes) {
389 if (!strcmp(buf, "disable\n") &&
390 (status & ACPI_EVENT_FLAG_ENABLED))
391 result = acpi_disable_gpe(handle, index);
392 else if (!strcmp(buf, "enable\n") &&
393 !(status & ACPI_EVENT_FLAG_ENABLED))
394 result = acpi_enable_gpe(handle, index);
395 else if (!strcmp(buf, "clear\n") &&
396 (status & ACPI_EVENT_FLAG_SET))
397 result = acpi_clear_gpe(handle, index);
398 else
399 all_counters[index].count = strtoul(buf, NULL, 0);
400 } else if (index < num_gpes + ACPI_NUM_FIXED_EVENTS) {
401 int event = index - num_gpes;
402 if (!strcmp(buf, "disable\n") &&
403 (status & ACPI_EVENT_FLAG_ENABLED))
404 result = acpi_disable_event(event, ACPI_NOT_ISR);
405 else if (!strcmp(buf, "enable\n") &&
406 !(status & ACPI_EVENT_FLAG_ENABLED))
407 result = acpi_enable_event(event, ACPI_NOT_ISR);
408 else if (!strcmp(buf, "clear\n") &&
409 (status & ACPI_EVENT_FLAG_SET))
410 result = acpi_clear_event(event);
411 else
412 all_counters[index].count = strtoul(buf, NULL, 0);
413 } else
414 all_counters[index].count = strtoul(buf, NULL, 0);
415
416 if (ACPI_FAILURE(result))
417 result = -EINVAL;
418end:
419 return result ? result : size;
420}
421
422void acpi_irq_stats_init(void)
423{
424 int i;
425
426 if (all_counters)
427 return;
428
429 num_gpes = acpi_current_gpe_count;
430 num_counters = num_gpes + ACPI_NUM_FIXED_EVENTS + NUM_COUNTERS_EXTRA;
431
432 all_attrs = kzalloc(sizeof(struct attribute *) * (num_counters + 1),
433 GFP_KERNEL);
434 if (all_attrs == NULL)
435 return;
436
437 all_counters = kzalloc(sizeof(struct event_counter) * (num_counters),
438 GFP_KERNEL);
439 if (all_counters == NULL)
440 goto fail;
441
442 counter_attrs = kzalloc(sizeof(struct kobj_attribute) * (num_counters),
443 GFP_KERNEL);
444 if (counter_attrs == NULL)
445 goto fail;
446
447 for (i = 0; i < num_counters; ++i) {
448 char buffer[12];
449 char *name;
450
451 if (i < num_gpes)
452 sprintf(buffer, "gpe%02X", i);
453 else if (i == num_gpes + ACPI_EVENT_PMTIMER)
454 sprintf(buffer, "ff_pmtimer");
455 else if (i == num_gpes + ACPI_EVENT_GLOBAL)
456 sprintf(buffer, "ff_gbl_lock");
457 else if (i == num_gpes + ACPI_EVENT_POWER_BUTTON)
458 sprintf(buffer, "ff_pwr_btn");
459 else if (i == num_gpes + ACPI_EVENT_SLEEP_BUTTON)
460 sprintf(buffer, "ff_slp_btn");
461 else if (i == num_gpes + ACPI_EVENT_RTC)
462 sprintf(buffer, "ff_rt_clk");
463 else if (i == num_gpes + ACPI_NUM_FIXED_EVENTS + COUNT_GPE)
464 sprintf(buffer, "gpe_all");
465 else if (i == num_gpes + ACPI_NUM_FIXED_EVENTS + COUNT_SCI)
466 sprintf(buffer, "sci");
467 else if (i == num_gpes + ACPI_NUM_FIXED_EVENTS + COUNT_SCI_NOT)
468 sprintf(buffer, "sci_not");
469 else if (i == num_gpes + ACPI_NUM_FIXED_EVENTS + COUNT_ERROR)
470 sprintf(buffer, "error");
471 else
472 sprintf(buffer, "bug%02X", i);
473
474 name = kzalloc(strlen(buffer) + 1, GFP_KERNEL);
475 if (name == NULL)
476 goto fail;
477 strncpy(name, buffer, strlen(buffer) + 1);
478
479 sysfs_attr_init(&counter_attrs[i].attr);
480 counter_attrs[i].attr.name = name;
481 counter_attrs[i].attr.mode = 0644;
482 counter_attrs[i].show = counter_show;
483 counter_attrs[i].store = counter_set;
484
485 all_attrs[i] = &counter_attrs[i].attr;
486 }
487
488 interrupt_stats_attr_group.attrs = all_attrs;
489 if (!sysfs_create_group(acpi_kobj, &interrupt_stats_attr_group))
490 return;
491
492fail:
493 delete_gpe_attr_array();
494 return;
495}
496
497static void __exit interrupt_stats_exit(void)
498{
499 sysfs_remove_group(acpi_kobj, &interrupt_stats_attr_group);
500
501 delete_gpe_attr_array();
502
503 return;
504}
505
506/* -------------------------------------------------------------------------- 43/* --------------------------------------------------------------------------
507 FS Interface (/proc) 44 FS Interface (/proc)
508 -------------------------------------------------------------------------- */ 45 -------------------------------------------------------------------------- */
@@ -628,10 +165,6 @@ int __init acpi_system_init(void)
628 int result; 165 int result;
629 166
630 result = acpi_system_procfs_init(); 167 result = acpi_system_procfs_init();
631 if (result)
632 return result;
633
634 result = acpi_system_sysfs_init();
635 168
636 return result; 169 return result;
637} 170}