[POWERPC] Don't use HOSTCFLAGS in BOOTCFLAGS
[linux-ginger.git] / drivers / acpi / system.c
blob83a8d3097904e99dbb825736ee84294bd4739de5
1 /*
2 * acpi_system.c - ACPI System Driver ($Revision: 63 $)
4 * Copyright (C) 2001, 2002 Andy Grover <andrew.grover@intel.com>
5 * Copyright (C) 2001, 2002 Paul Diefenbaugh <paul.s.diefenbaugh@intel.com>
7 * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
9 * This program is free software; you can redistribute it and/or modify
10 * it under the terms of the GNU General Public License as published by
11 * the Free Software Foundation; either version 2 of the License, or (at
12 * your option) any later version.
14 * This program is distributed in the hope that it will be useful, but
15 * WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
17 * General Public License for more details.
19 * You should have received a copy of the GNU General Public License along
20 * with this program; if not, write to the Free Software Foundation, Inc.,
21 * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
23 * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
26 #include <linux/proc_fs.h>
27 #include <linux/seq_file.h>
28 #include <linux/init.h>
29 #include <asm/uaccess.h>
31 #include <acpi/acpi_drivers.h>
33 #define _COMPONENT ACPI_SYSTEM_COMPONENT
34 ACPI_MODULE_NAME("system");
35 #ifdef MODULE_PARAM_PREFIX
36 #undef MODULE_PARAM_PREFIX
37 #endif
38 #define MODULE_PARAM_PREFIX "acpi."
40 #define ACPI_SYSTEM_CLASS "system"
41 #define ACPI_SYSTEM_DEVICE_NAME "System"
42 #define ACPI_SYSTEM_FILE_INFO "info"
43 #define ACPI_SYSTEM_FILE_EVENT "event"
44 #define ACPI_SYSTEM_FILE_DSDT "dsdt"
45 #define ACPI_SYSTEM_FILE_FADT "fadt"
48 * Make ACPICA version work as module param
50 static int param_get_acpica_version(char *buffer, struct kernel_param *kp) {
51 int result;
53 result = sprintf(buffer, "%x", ACPI_CA_VERSION);
55 return result;
58 module_param_call(acpica_version, NULL, param_get_acpica_version, NULL, 0444);
60 /* --------------------------------------------------------------------------
61 FS Interface (/proc)
62 -------------------------------------------------------------------------- */
63 #ifdef CONFIG_ACPI_PROCFS
65 static int acpi_system_read_info(struct seq_file *seq, void *offset)
68 seq_printf(seq, "version: %x\n", ACPI_CA_VERSION);
69 return 0;
72 static int acpi_system_info_open_fs(struct inode *inode, struct file *file)
74 return single_open(file, acpi_system_read_info, PDE(inode)->data);
77 static const struct file_operations acpi_system_info_ops = {
78 .open = acpi_system_info_open_fs,
79 .read = seq_read,
80 .llseek = seq_lseek,
81 .release = single_release,
83 #endif
85 static ssize_t acpi_system_read_dsdt(struct file *, char __user *, size_t,
86 loff_t *);
88 static const struct file_operations acpi_system_dsdt_ops = {
89 .read = acpi_system_read_dsdt,
92 static ssize_t
93 acpi_system_read_dsdt(struct file *file,
94 char __user * buffer, size_t count, loff_t * ppos)
96 acpi_status status = AE_OK;
97 struct acpi_table_header *dsdt = NULL;
98 ssize_t res;
101 status = acpi_get_table(ACPI_SIG_DSDT, 1, &dsdt);
102 if (ACPI_FAILURE(status))
103 return -ENODEV;
105 res = simple_read_from_buffer(buffer, count, ppos,
106 dsdt, dsdt->length);
108 return res;
111 static ssize_t acpi_system_read_fadt(struct file *, char __user *, size_t,
112 loff_t *);
114 static const struct file_operations acpi_system_fadt_ops = {
115 .read = acpi_system_read_fadt,
118 static ssize_t
119 acpi_system_read_fadt(struct file *file,
120 char __user * buffer, size_t count, loff_t * ppos)
122 acpi_status status = AE_OK;
123 struct acpi_table_header *fadt = NULL;
124 ssize_t res;
127 status = acpi_get_table(ACPI_SIG_FADT, 1, &fadt);
128 if (ACPI_FAILURE(status))
129 return -ENODEV;
131 res = simple_read_from_buffer(buffer, count, ppos,
132 fadt, fadt->length);
134 return res;
137 static int __init acpi_system_init(void)
139 struct proc_dir_entry *entry;
140 int error = 0;
141 char *name;
144 if (acpi_disabled)
145 return 0;
147 #ifdef CONFIG_ACPI_PROCFS
148 /* 'info' [R] */
149 name = ACPI_SYSTEM_FILE_INFO;
150 entry = create_proc_entry(name, S_IRUGO, acpi_root_dir);
151 if (!entry)
152 goto Error;
153 else {
154 entry->proc_fops = &acpi_system_info_ops;
156 #endif
158 /* 'dsdt' [R] */
159 name = ACPI_SYSTEM_FILE_DSDT;
160 entry = create_proc_entry(name, S_IRUSR, acpi_root_dir);
161 if (entry)
162 entry->proc_fops = &acpi_system_dsdt_ops;
163 else
164 goto Error;
166 /* 'fadt' [R] */
167 name = ACPI_SYSTEM_FILE_FADT;
168 entry = create_proc_entry(name, S_IRUSR, acpi_root_dir);
169 if (entry)
170 entry->proc_fops = &acpi_system_fadt_ops;
171 else
172 goto Error;
174 Done:
175 return error;
177 Error:
178 remove_proc_entry(ACPI_SYSTEM_FILE_FADT, acpi_root_dir);
179 remove_proc_entry(ACPI_SYSTEM_FILE_DSDT, acpi_root_dir);
180 #ifdef CONFIG_ACPI_PROCFS
181 remove_proc_entry(ACPI_SYSTEM_FILE_INFO, acpi_root_dir);
182 #endif
184 error = -EFAULT;
185 goto Done;
188 subsys_initcall(acpi_system_init);