This source file includes following definitions.
- acpi_lock_ac_dir
- acpi_unlock_ac_dir
- acpi_lock_battery_dir
- acpi_unlock_battery_dir
1
2
3 #include <linux/kernel.h>
4 #include <linux/module.h>
5 #include <linux/init.h>
6 #include <linux/acpi.h>
7 #include <linux/types.h>
8 #include <linux/proc_fs.h>
9 #include <linux/seq_file.h>
10 #include <acpi/acpi_bus.h>
11 #include <acpi/acpi_drivers.h>
12
13 #define PREFIX "ACPI: "
14
15 ACPI_MODULE_NAME("cm_sbs");
16 #define ACPI_AC_CLASS "ac_adapter"
17 #define ACPI_BATTERY_CLASS "battery"
18 #define _COMPONENT ACPI_SBS_COMPONENT
19 static struct proc_dir_entry *acpi_ac_dir;
20 static struct proc_dir_entry *acpi_battery_dir;
21
22 static DEFINE_MUTEX(cm_sbs_mutex);
23
24 static int lock_ac_dir_cnt;
25 static int lock_battery_dir_cnt;
26
27 struct proc_dir_entry *acpi_lock_ac_dir(void)
28 {
29 mutex_lock(&cm_sbs_mutex);
30 if (!acpi_ac_dir)
31 acpi_ac_dir = proc_mkdir(ACPI_AC_CLASS, acpi_root_dir);
32 if (acpi_ac_dir) {
33 lock_ac_dir_cnt++;
34 } else {
35 printk(KERN_ERR PREFIX
36 "Cannot create %s\n", ACPI_AC_CLASS);
37 }
38 mutex_unlock(&cm_sbs_mutex);
39 return acpi_ac_dir;
40 }
41 EXPORT_SYMBOL(acpi_lock_ac_dir);
42
43 void acpi_unlock_ac_dir(struct proc_dir_entry *acpi_ac_dir_param)
44 {
45 mutex_lock(&cm_sbs_mutex);
46 if (acpi_ac_dir_param)
47 lock_ac_dir_cnt--;
48 if (lock_ac_dir_cnt == 0 && acpi_ac_dir_param && acpi_ac_dir) {
49 remove_proc_entry(ACPI_AC_CLASS, acpi_root_dir);
50 acpi_ac_dir = NULL;
51 }
52 mutex_unlock(&cm_sbs_mutex);
53 }
54 EXPORT_SYMBOL(acpi_unlock_ac_dir);
55
56 struct proc_dir_entry *acpi_lock_battery_dir(void)
57 {
58 mutex_lock(&cm_sbs_mutex);
59 if (!acpi_battery_dir) {
60 acpi_battery_dir =
61 proc_mkdir(ACPI_BATTERY_CLASS, acpi_root_dir);
62 }
63 if (acpi_battery_dir) {
64 lock_battery_dir_cnt++;
65 } else {
66 printk(KERN_ERR PREFIX
67 "Cannot create %s\n", ACPI_BATTERY_CLASS);
68 }
69 mutex_unlock(&cm_sbs_mutex);
70 return acpi_battery_dir;
71 }
72 EXPORT_SYMBOL(acpi_lock_battery_dir);
73
74 void acpi_unlock_battery_dir(struct proc_dir_entry *acpi_battery_dir_param)
75 {
76 mutex_lock(&cm_sbs_mutex);
77 if (acpi_battery_dir_param)
78 lock_battery_dir_cnt--;
79 if (lock_battery_dir_cnt == 0 && acpi_battery_dir_param
80 && acpi_battery_dir) {
81 remove_proc_entry(ACPI_BATTERY_CLASS, acpi_root_dir);
82 acpi_battery_dir = NULL;
83 }
84 mutex_unlock(&cm_sbs_mutex);
85 return;
86 }
87 EXPORT_SYMBOL(acpi_unlock_battery_dir);