sh_eth: fix EESIPR values for SH77{34|63}
[linux/fpc-iii.git] / drivers / acpi / cm_sbs.c
blobd0918d421f90a34d4b2ad292880a3e8ebc987b10
1 /*
2 * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
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.
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.
14 * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
17 #include <linux/kernel.h>
18 #include <linux/module.h>
19 #include <linux/init.h>
20 #include <linux/acpi.h>
21 #include <linux/types.h>
22 #include <linux/proc_fs.h>
23 #include <linux/seq_file.h>
24 #include <acpi/acpi_bus.h>
25 #include <acpi/acpi_drivers.h>
27 #define PREFIX "ACPI: "
29 ACPI_MODULE_NAME("cm_sbs");
30 #define ACPI_AC_CLASS "ac_adapter"
31 #define ACPI_BATTERY_CLASS "battery"
32 #define _COMPONENT ACPI_SBS_COMPONENT
33 static struct proc_dir_entry *acpi_ac_dir;
34 static struct proc_dir_entry *acpi_battery_dir;
36 static DEFINE_MUTEX(cm_sbs_mutex);
38 static int lock_ac_dir_cnt;
39 static int lock_battery_dir_cnt;
41 struct proc_dir_entry *acpi_lock_ac_dir(void)
43 mutex_lock(&cm_sbs_mutex);
44 if (!acpi_ac_dir)
45 acpi_ac_dir = proc_mkdir(ACPI_AC_CLASS, acpi_root_dir);
46 if (acpi_ac_dir) {
47 lock_ac_dir_cnt++;
48 } else {
49 printk(KERN_ERR PREFIX
50 "Cannot create %s\n", ACPI_AC_CLASS);
52 mutex_unlock(&cm_sbs_mutex);
53 return acpi_ac_dir;
55 EXPORT_SYMBOL(acpi_lock_ac_dir);
57 void acpi_unlock_ac_dir(struct proc_dir_entry *acpi_ac_dir_param)
59 mutex_lock(&cm_sbs_mutex);
60 if (acpi_ac_dir_param)
61 lock_ac_dir_cnt--;
62 if (lock_ac_dir_cnt == 0 && acpi_ac_dir_param && acpi_ac_dir) {
63 remove_proc_entry(ACPI_AC_CLASS, acpi_root_dir);
64 acpi_ac_dir = NULL;
66 mutex_unlock(&cm_sbs_mutex);
68 EXPORT_SYMBOL(acpi_unlock_ac_dir);
70 struct proc_dir_entry *acpi_lock_battery_dir(void)
72 mutex_lock(&cm_sbs_mutex);
73 if (!acpi_battery_dir) {
74 acpi_battery_dir =
75 proc_mkdir(ACPI_BATTERY_CLASS, acpi_root_dir);
77 if (acpi_battery_dir) {
78 lock_battery_dir_cnt++;
79 } else {
80 printk(KERN_ERR PREFIX
81 "Cannot create %s\n", ACPI_BATTERY_CLASS);
83 mutex_unlock(&cm_sbs_mutex);
84 return acpi_battery_dir;
86 EXPORT_SYMBOL(acpi_lock_battery_dir);
88 void acpi_unlock_battery_dir(struct proc_dir_entry *acpi_battery_dir_param)
90 mutex_lock(&cm_sbs_mutex);
91 if (acpi_battery_dir_param)
92 lock_battery_dir_cnt--;
93 if (lock_battery_dir_cnt == 0 && acpi_battery_dir_param
94 && acpi_battery_dir) {
95 remove_proc_entry(ACPI_BATTERY_CLASS, acpi_root_dir);
96 acpi_battery_dir = NULL;
98 mutex_unlock(&cm_sbs_mutex);
99 return;
101 EXPORT_SYMBOL(acpi_unlock_battery_dir);