]> git.proxmox.com Git - mirror_ubuntu-artful-kernel.git/blame - drivers/acpi/cm_sbs.c
ACPI: clean up ACPI_MODULE_NAME() use
[mirror_ubuntu-artful-kernel.git] / drivers / acpi / cm_sbs.c
CommitLineData
3f86b832
RT
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
f52fd66d 34ACPI_MODULE_NAME("cm_sbs");
3f86b832
RT
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
39static struct proc_dir_entry *acpi_ac_dir;
40static struct proc_dir_entry *acpi_battery_dir;
41
8970bfe7 42static DEFINE_MUTEX(cm_sbs_mutex);
3f86b832 43
8970bfe7
AM
44static int lock_ac_dir_cnt;
45static int lock_battery_dir_cnt;
3f86b832
RT
46
47struct proc_dir_entry *acpi_lock_ac_dir(void)
48{
8970bfe7
AM
49 mutex_lock(&cm_sbs_mutex);
50 if (!acpi_ac_dir)
3f86b832 51 acpi_ac_dir = proc_mkdir(ACPI_AC_CLASS, acpi_root_dir);
3f86b832
RT
52 if (acpi_ac_dir) {
53 lock_ac_dir_cnt++;
54 } else {
55 ACPI_DEBUG_PRINT((ACPI_DB_ERROR,
56 "Cannot create %s\n", ACPI_AC_CLASS));
57 }
8970bfe7 58 mutex_unlock(&cm_sbs_mutex);
635227ee 59 return acpi_ac_dir;
3f86b832 60}
3f86b832
RT
61EXPORT_SYMBOL(acpi_lock_ac_dir);
62
63void acpi_unlock_ac_dir(struct proc_dir_entry *acpi_ac_dir_param)
64{
8970bfe7
AM
65 mutex_lock(&cm_sbs_mutex);
66 if (acpi_ac_dir_param)
3f86b832 67 lock_ac_dir_cnt--;
3f86b832
RT
68 if (lock_ac_dir_cnt == 0 && acpi_ac_dir_param && acpi_ac_dir) {
69 remove_proc_entry(ACPI_AC_CLASS, acpi_root_dir);
4370df97 70 acpi_ac_dir = NULL;
3f86b832 71 }
8970bfe7 72 mutex_unlock(&cm_sbs_mutex);
3f86b832 73}
3f86b832
RT
74EXPORT_SYMBOL(acpi_unlock_ac_dir);
75
76struct proc_dir_entry *acpi_lock_battery_dir(void)
77{
8970bfe7 78 mutex_lock(&cm_sbs_mutex);
3f86b832
RT
79 if (!acpi_battery_dir) {
80 acpi_battery_dir =
81 proc_mkdir(ACPI_BATTERY_CLASS, acpi_root_dir);
82 }
83 if (acpi_battery_dir) {
84 lock_battery_dir_cnt++;
85 } else {
86 ACPI_DEBUG_PRINT((ACPI_DB_ERROR,
87 "Cannot create %s\n", ACPI_BATTERY_CLASS));
88 }
8970bfe7 89 mutex_unlock(&cm_sbs_mutex);
635227ee 90 return acpi_battery_dir;
3f86b832 91}
3f86b832
RT
92EXPORT_SYMBOL(acpi_lock_battery_dir);
93
94void acpi_unlock_battery_dir(struct proc_dir_entry *acpi_battery_dir_param)
95{
8970bfe7
AM
96 mutex_lock(&cm_sbs_mutex);
97 if (acpi_battery_dir_param)
3f86b832 98 lock_battery_dir_cnt--;
3f86b832
RT
99 if (lock_battery_dir_cnt == 0 && acpi_battery_dir_param
100 && acpi_battery_dir) {
101 remove_proc_entry(ACPI_BATTERY_CLASS, acpi_root_dir);
4370df97 102 acpi_battery_dir = NULL;
3f86b832 103 }
8970bfe7 104 mutex_unlock(&cm_sbs_mutex);
635227ee 105 return;
3f86b832 106}
3f86b832
RT
107EXPORT_SYMBOL(acpi_unlock_battery_dir);
108
109static int __init acpi_cm_sbs_init(void)
110{
635227ee 111 return 0;
3f86b832 112}
3f86b832 113subsys_initcall(acpi_cm_sbs_init);