ACPI: clean up ACPI_MODULE_NAME() use
[deliverable/linux.git] / drivers / acpi / system.c
CommitLineData
1da177e4
LT
1/*
2 * acpi_system.c - ACPI System Driver ($Revision: 63 $)
3 *
4 * Copyright (C) 2001, 2002 Andy Grover <andrew.grover@intel.com>
5 * Copyright (C) 2001, 2002 Paul Diefenbaugh <paul.s.diefenbaugh@intel.com>
6 *
7 * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
8 *
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.
13 *
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.
18 *
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.
22 *
23 * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
24 */
25
26#include <linux/proc_fs.h>
27#include <linux/seq_file.h>
28#include <linux/init.h>
29#include <asm/uaccess.h>
30
31#include <acpi/acpi_drivers.h>
32
1da177e4 33#define _COMPONENT ACPI_SYSTEM_COMPONENT
f52fd66d 34ACPI_MODULE_NAME("system");
5bb730fd
ZR
35#ifdef MODULE_PARAM_PREFIX
36#undef MODULE_PARAM_PREFIX
37#endif
38#define MODULE_PARAM_PREFIX "acpi."
39
1da177e4
LT
40#define ACPI_SYSTEM_CLASS "system"
41#define ACPI_SYSTEM_DRIVER_NAME "ACPI System Driver"
42#define ACPI_SYSTEM_DEVICE_NAME "System"
43#define ACPI_SYSTEM_FILE_INFO "info"
44#define ACPI_SYSTEM_FILE_EVENT "event"
45#define ACPI_SYSTEM_FILE_DSDT "dsdt"
46#define ACPI_SYSTEM_FILE_FADT "fadt"
1da177e4 47
5bb730fd
ZR
48/*
49 * Make ACPICA version work as module param
50 */
51static int param_get_acpica_version(char *buffer, struct kernel_param *kp) {
52 int result;
53
54 result = sprintf(buffer, "%x", ACPI_CA_VERSION);
55
56 return result;
57}
58
59module_param_call(acpica_version, NULL, param_get_acpica_version, NULL, 0444);
60
1da177e4
LT
61/* --------------------------------------------------------------------------
62 FS Interface (/proc)
63 -------------------------------------------------------------------------- */
5bb730fd 64#ifdef CONFIG_ACPI_PROCFS
1da177e4 65
4be44fcd 66static int acpi_system_read_info(struct seq_file *seq, void *offset)
1da177e4 67{
1da177e4
LT
68
69 seq_printf(seq, "version: %x\n", ACPI_CA_VERSION);
d550d98d 70 return 0;
1da177e4
LT
71}
72
73static int acpi_system_info_open_fs(struct inode *inode, struct file *file)
74{
75 return single_open(file, acpi_system_read_info, PDE(inode)->data);
76}
77
d7508032 78static const struct file_operations acpi_system_info_ops = {
4be44fcd
LB
79 .open = acpi_system_info_open_fs,
80 .read = seq_read,
81 .llseek = seq_lseek,
82 .release = single_release,
1da177e4 83};
5bb730fd 84#endif
1da177e4 85
4be44fcd
LB
86static ssize_t acpi_system_read_dsdt(struct file *, char __user *, size_t,
87 loff_t *);
1da177e4 88
d7508032 89static const struct file_operations acpi_system_dsdt_ops = {
4be44fcd 90 .read = acpi_system_read_dsdt,
1da177e4
LT
91};
92
93static ssize_t
4be44fcd
LB
94acpi_system_read_dsdt(struct file *file,
95 char __user * buffer, size_t count, loff_t * ppos)
1da177e4 96{
4be44fcd 97 acpi_status status = AE_OK;
ad71860a 98 struct acpi_table_header *dsdt = NULL;
4be44fcd 99 ssize_t res;
1da177e4 100
1da177e4 101
ad71860a 102 status = acpi_get_table(ACPI_SIG_DSDT, 1, &dsdt);
1da177e4 103 if (ACPI_FAILURE(status))
d550d98d 104 return -ENODEV;
1da177e4
LT
105
106 res = simple_read_from_buffer(buffer, count, ppos,
ad71860a 107 dsdt, dsdt->length);
1da177e4 108
d550d98d 109 return res;
1da177e4
LT
110}
111
4be44fcd
LB
112static ssize_t acpi_system_read_fadt(struct file *, char __user *, size_t,
113 loff_t *);
1da177e4 114
d7508032 115static const struct file_operations acpi_system_fadt_ops = {
4be44fcd 116 .read = acpi_system_read_fadt,
1da177e4
LT
117};
118
119static ssize_t
4be44fcd
LB
120acpi_system_read_fadt(struct file *file,
121 char __user * buffer, size_t count, loff_t * ppos)
1da177e4 122{
4be44fcd 123 acpi_status status = AE_OK;
ad71860a 124 struct acpi_table_header *fadt = NULL;
4be44fcd 125 ssize_t res;
1da177e4 126
1da177e4 127
ad71860a 128 status = acpi_get_table(ACPI_SIG_FADT, 1, &fadt);
1da177e4 129 if (ACPI_FAILURE(status))
d550d98d 130 return -ENODEV;
1da177e4
LT
131
132 res = simple_read_from_buffer(buffer, count, ppos,
ad71860a 133 fadt, fadt->length);
1da177e4 134
d550d98d 135 return res;
1da177e4
LT
136}
137
4be44fcd 138static int __init acpi_system_init(void)
1da177e4 139{
4be44fcd 140 struct proc_dir_entry *entry;
1da177e4 141 int error = 0;
4be44fcd 142 char *name;
1da177e4 143
1da177e4
LT
144
145 if (acpi_disabled)
d550d98d 146 return 0;
1da177e4 147
5bb730fd 148#ifdef CONFIG_ACPI_PROCFS
1da177e4
LT
149 /* 'info' [R] */
150 name = ACPI_SYSTEM_FILE_INFO;
4be44fcd 151 entry = create_proc_entry(name, S_IRUGO, acpi_root_dir);
1da177e4
LT
152 if (!entry)
153 goto Error;
154 else {
155 entry->proc_fops = &acpi_system_info_ops;
156 }
5bb730fd 157#endif
1da177e4
LT
158
159 /* 'dsdt' [R] */
160 name = ACPI_SYSTEM_FILE_DSDT;
161 entry = create_proc_entry(name, S_IRUSR, acpi_root_dir);
162 if (entry)
163 entry->proc_fops = &acpi_system_dsdt_ops;
4be44fcd 164 else
1da177e4
LT
165 goto Error;
166
167 /* 'fadt' [R] */
168 name = ACPI_SYSTEM_FILE_FADT;
169 entry = create_proc_entry(name, S_IRUSR, acpi_root_dir);
170 if (entry)
171 entry->proc_fops = &acpi_system_fadt_ops;
172 else
173 goto Error;
174
4be44fcd 175 Done:
d550d98d 176 return error;
1da177e4 177
4be44fcd 178 Error:
1da177e4
LT
179 remove_proc_entry(ACPI_SYSTEM_FILE_FADT, acpi_root_dir);
180 remove_proc_entry(ACPI_SYSTEM_FILE_DSDT, acpi_root_dir);
5bb730fd 181#ifdef CONFIG_ACPI_PROCFS
1da177e4 182 remove_proc_entry(ACPI_SYSTEM_FILE_INFO, acpi_root_dir);
5bb730fd 183#endif
1da177e4
LT
184
185 error = -EFAULT;
186 goto Done;
187}
188
1da177e4 189subsys_initcall(acpi_system_init);
This page took 0.160367 seconds and 5 git commands to generate.