diff options
Diffstat (limited to 'drivers/acpi/cm_sbs.c')
-rw-r--r-- | drivers/acpi/cm_sbs.c | 131 |
1 files changed, 131 insertions, 0 deletions
diff --git a/drivers/acpi/cm_sbs.c b/drivers/acpi/cm_sbs.c new file mode 100644 index 000000000000..574a75a166c5 --- /dev/null +++ b/drivers/acpi/cm_sbs.c | |||
@@ -0,0 +1,131 @@ | |||
1 | /* | ||
2 | * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ | ||
3 | * | ||
4 | * This program is free software; you can redistribute it and/or modify | ||
5 | * it under the terms of the GNU General Public License as published by | ||
6 | * the Free Software Foundation; either version 2 of the License, or (at | ||
7 | * your option) any later version. | ||
8 | * | ||
9 | * This program is distributed in the hope that it will be useful, but | ||
10 | * WITHOUT ANY WARRANTY; without even the implied warranty of | ||
11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
12 | * General Public License for more details. | ||
13 | * | ||
14 | * You should have received a copy of the GNU General Public License along | ||
15 | * with this program; if not, write to the Free Software Foundation, Inc., | ||
16 | * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. | ||
17 | * | ||
18 | * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ | ||
19 | */ | ||
20 | |||
21 | #include <linux/kernel.h> | ||
22 | #include <linux/module.h> | ||
23 | #include <linux/init.h> | ||
24 | #include <linux/acpi.h> | ||
25 | #include <linux/types.h> | ||
26 | #include <linux/proc_fs.h> | ||
27 | #include <linux/seq_file.h> | ||
28 | #include <acpi/acpi_bus.h> | ||
29 | #include <acpi/acpi_drivers.h> | ||
30 | #include <acpi/acmacros.h> | ||
31 | #include <acpi/actypes.h> | ||
32 | #include <acpi/acutils.h> | ||
33 | |||
34 | ACPI_MODULE_NAME("cm_sbs") | ||
35 | #define ACPI_AC_CLASS "ac_adapter" | ||
36 | #define ACPI_BATTERY_CLASS "battery" | ||
37 | #define ACPI_SBS_COMPONENT 0x00080000 | ||
38 | #define _COMPONENT ACPI_SBS_COMPONENT | ||
39 | static struct proc_dir_entry *acpi_ac_dir; | ||
40 | static struct proc_dir_entry *acpi_battery_dir; | ||
41 | |||
42 | static struct semaphore cm_sbs_sem; | ||
43 | |||
44 | static int lock_ac_dir_cnt = 0; | ||
45 | static int lock_battery_dir_cnt = 0; | ||
46 | |||
47 | struct proc_dir_entry *acpi_lock_ac_dir(void) | ||
48 | { | ||
49 | |||
50 | down(&cm_sbs_sem); | ||
51 | if (!acpi_ac_dir) { | ||
52 | acpi_ac_dir = proc_mkdir(ACPI_AC_CLASS, acpi_root_dir); | ||
53 | } | ||
54 | if (acpi_ac_dir) { | ||
55 | lock_ac_dir_cnt++; | ||
56 | } else { | ||
57 | ACPI_DEBUG_PRINT((ACPI_DB_ERROR, | ||
58 | "Cannot create %s\n", ACPI_AC_CLASS)); | ||
59 | } | ||
60 | up(&cm_sbs_sem); | ||
61 | return acpi_ac_dir; | ||
62 | } | ||
63 | |||
64 | EXPORT_SYMBOL(acpi_lock_ac_dir); | ||
65 | |||
66 | void acpi_unlock_ac_dir(struct proc_dir_entry *acpi_ac_dir_param) | ||
67 | { | ||
68 | |||
69 | down(&cm_sbs_sem); | ||
70 | if (acpi_ac_dir_param) { | ||
71 | lock_ac_dir_cnt--; | ||
72 | } | ||
73 | if (lock_ac_dir_cnt == 0 && acpi_ac_dir_param && acpi_ac_dir) { | ||
74 | remove_proc_entry(ACPI_AC_CLASS, acpi_root_dir); | ||
75 | acpi_ac_dir = 0; | ||
76 | } | ||
77 | up(&cm_sbs_sem); | ||
78 | } | ||
79 | |||
80 | EXPORT_SYMBOL(acpi_unlock_ac_dir); | ||
81 | |||
82 | struct proc_dir_entry *acpi_lock_battery_dir(void) | ||
83 | { | ||
84 | |||
85 | down(&cm_sbs_sem); | ||
86 | if (!acpi_battery_dir) { | ||
87 | acpi_battery_dir = | ||
88 | proc_mkdir(ACPI_BATTERY_CLASS, acpi_root_dir); | ||
89 | } | ||
90 | if (acpi_battery_dir) { | ||
91 | lock_battery_dir_cnt++; | ||
92 | } else { | ||
93 | ACPI_DEBUG_PRINT((ACPI_DB_ERROR, | ||
94 | "Cannot create %s\n", ACPI_BATTERY_CLASS)); | ||
95 | } | ||
96 | up(&cm_sbs_sem); | ||
97 | return acpi_battery_dir; | ||
98 | } | ||
99 | |||
100 | EXPORT_SYMBOL(acpi_lock_battery_dir); | ||
101 | |||
102 | void acpi_unlock_battery_dir(struct proc_dir_entry *acpi_battery_dir_param) | ||
103 | { | ||
104 | |||
105 | down(&cm_sbs_sem); | ||
106 | if (acpi_battery_dir_param) { | ||
107 | lock_battery_dir_cnt--; | ||
108 | } | ||
109 | if (lock_battery_dir_cnt == 0 && acpi_battery_dir_param | ||
110 | && acpi_battery_dir) { | ||
111 | remove_proc_entry(ACPI_BATTERY_CLASS, acpi_root_dir); | ||
112 | acpi_battery_dir = 0; | ||
113 | } | ||
114 | up(&cm_sbs_sem); | ||
115 | return; | ||
116 | } | ||
117 | |||
118 | EXPORT_SYMBOL(acpi_unlock_battery_dir); | ||
119 | |||
120 | static int __init acpi_cm_sbs_init(void) | ||
121 | { | ||
122 | |||
123 | if (acpi_disabled) | ||
124 | return 0; | ||
125 | |||
126 | init_MUTEX(&cm_sbs_sem); | ||
127 | |||
128 | return 0; | ||
129 | } | ||
130 | |||
131 | subsys_initcall(acpi_cm_sbs_init); | ||