aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/acpi
diff options
context:
space:
mode:
authorRafael J. Wysocki <rafael.j.wysocki@intel.com>2013-10-27 20:10:20 -0400
committerRafael J. Wysocki <rafael.j.wysocki@intel.com>2013-10-27 20:10:20 -0400
commit8e32e47dbb98fd24e4c541753427a576e6ab5bb3 (patch)
treeae9e3eb57380171a25af431dea1e4665ef9c7abf /drivers/acpi
parent959f58544b7f20c92d5eb43d1232c96c15c01bfb (diff)
parent7744da5e90a2782ff0d48628c2cb120efcd300f3 (diff)
Merge branch 'acpi-cleanup'
* acpi-cleanup: (34 commits) ACPI / proc: Remove alarm proc file ACPI: Remove CONFIG_ACPI_PROCFS_POWER and cm_sbsc.c ACPI / SBS: Remove SBS's proc directory ACPI / Battery: Remove battery's proc directory ACP / fan: trivial style cleanup ACPI / processor: remove superfluous pr == NULL checks ACPI / mm: use NUMA_NO_NODE toshiba_acpi: convert acpi_evaluate_object() to acpi_evaluate_integer() intel-smartconnect: convert acpi_evaluate_object() to acpi_evaluate_integer() intel-rst: convert acpi_evaluate_object() to acpi_evaluate_integer() fujitsu-laptop: convert acpi_evaluate_object() to acpi_evaluate_integer() i2c-hid: convert acpi_evaluate_object() to acpi_evaluate_integer() ACPI: dock: convert acpi_evaluate_object() to acpi_evaluate_integer() acpi_processor: convert acpi_evaluate_object() to acpi_evaluate_integer() pnpacpi: convert acpi_get_handle() to acpi_has_method() wmi: convert acpi_get_handle() to acpi_has_method() toshiba_acpi: convert acpi_get_handle() to acpi_has_method() sony-laptop: convert acpi_get_handle() to acpi_has_method() intel_menlow: convert acpi_get_handle() to acpi_has_method() fujitsu-laptop: convert acpi_get_handle() to acpi_has_method() ...
Diffstat (limited to 'drivers/acpi')
-rw-r--r--drivers/acpi/Kconfig17
-rw-r--r--drivers/acpi/Makefile1
-rw-r--r--drivers/acpi/acpi_memhotplug.c2
-rw-r--r--drivers/acpi/acpi_processor.c6
-rw-r--r--drivers/acpi/battery.c328
-rw-r--r--drivers/acpi/cm_sbs.c105
-rw-r--r--drivers/acpi/dock.c6
-rw-r--r--drivers/acpi/fan.c2
-rw-r--r--drivers/acpi/numa.c4
-rw-r--r--drivers/acpi/proc.c305
-rw-r--r--drivers/acpi/processor_idle.c15
-rw-r--r--drivers/acpi/sbs.c325
12 files changed, 15 insertions, 1101 deletions
diff --git a/drivers/acpi/Kconfig b/drivers/acpi/Kconfig
index 6efe2ac6902f..10e399f97189 100644
--- a/drivers/acpi/Kconfig
+++ b/drivers/acpi/Kconfig
@@ -56,23 +56,6 @@ config ACPI_PROCFS
56 56
57 Say N to delete /proc/acpi/ files that have moved to /sys/ 57 Say N to delete /proc/acpi/ files that have moved to /sys/
58 58
59config ACPI_PROCFS_POWER
60 bool "Deprecated power /proc/acpi directories"
61 depends on PROC_FS
62 help
63 For backwards compatibility, this option allows
64 deprecated power /proc/acpi/ directories to exist, even when
65 they have been replaced by functions in /sys.
66 The deprecated directories (and their replacements) include:
67 /proc/acpi/battery/* (/sys/class/power_supply/*)
68 /proc/acpi/ac_adapter/* (sys/class/power_supply/*)
69 This option has no effect on /proc/acpi/ directories
70 and functions, which do not yet exist in /sys
71 This option, together with the proc directories, will be
72 deleted in 2.6.39.
73
74 Say N to delete power /proc/acpi/ directories that have moved to /sys/
75
76config ACPI_EC_DEBUGFS 59config ACPI_EC_DEBUGFS
77 tristate "EC read/write access through /sys/kernel/debug/ec" 60 tristate "EC read/write access through /sys/kernel/debug/ec"
78 default n 61 default n
diff --git a/drivers/acpi/Makefile b/drivers/acpi/Makefile
index cdaf68b58b00..a55fc06db4ae 100644
--- a/drivers/acpi/Makefile
+++ b/drivers/acpi/Makefile
@@ -47,7 +47,6 @@ acpi-y += sysfs.o
47acpi-$(CONFIG_X86) += acpi_cmos_rtc.o 47acpi-$(CONFIG_X86) += acpi_cmos_rtc.o
48acpi-$(CONFIG_DEBUG_FS) += debugfs.o 48acpi-$(CONFIG_DEBUG_FS) += debugfs.o
49acpi-$(CONFIG_ACPI_NUMA) += numa.o 49acpi-$(CONFIG_ACPI_NUMA) += numa.o
50acpi-$(CONFIG_ACPI_PROCFS_POWER) += cm_sbs.o
51ifdef CONFIG_ACPI_VIDEO 50ifdef CONFIG_ACPI_VIDEO
52acpi-y += video_detect.o 51acpi-y += video_detect.o
53endif 52endif
diff --git a/drivers/acpi/acpi_memhotplug.c b/drivers/acpi/acpi_memhotplug.c
index 999adb5499c7..c00a3a73409b 100644
--- a/drivers/acpi/acpi_memhotplug.c
+++ b/drivers/acpi/acpi_memhotplug.c
@@ -281,7 +281,7 @@ static void acpi_memory_remove_memory(struct acpi_memory_device *mem_device)
281 if (!info->enabled) 281 if (!info->enabled)
282 continue; 282 continue;
283 283
284 if (nid < 0) 284 if (nid == NUMA_NO_NODE)
285 nid = memory_add_physaddr_to_nid(info->start_addr); 285 nid = memory_add_physaddr_to_nid(info->start_addr);
286 286
287 acpi_unbind_memory_blocks(info, handle); 287 acpi_unbind_memory_blocks(info, handle);
diff --git a/drivers/acpi/acpi_processor.c b/drivers/acpi/acpi_processor.c
index f29e06efa479..357abdc1406a 100644
--- a/drivers/acpi/acpi_processor.c
+++ b/drivers/acpi/acpi_processor.c
@@ -219,6 +219,7 @@ static int acpi_processor_get_info(struct acpi_device *device)
219 int cpu_index, device_declaration = 0; 219 int cpu_index, device_declaration = 0;
220 acpi_status status = AE_OK; 220 acpi_status status = AE_OK;
221 static int cpu0_initialized; 221 static int cpu0_initialized;
222 unsigned long long value;
222 223
223 if (num_online_cpus() > 1) 224 if (num_online_cpus() > 1)
224 errata.smp = TRUE; 225 errata.smp = TRUE;
@@ -258,7 +259,6 @@ static int acpi_processor_get_info(struct acpi_device *device)
258 * Declared with "Device" statement; match _UID. 259 * Declared with "Device" statement; match _UID.
259 * Note that we don't handle string _UIDs yet. 260 * Note that we don't handle string _UIDs yet.
260 */ 261 */
261 unsigned long long value;
262 status = acpi_evaluate_integer(pr->handle, METHOD_NAME__UID, 262 status = acpi_evaluate_integer(pr->handle, METHOD_NAME__UID,
263 NULL, &value); 263 NULL, &value);
264 if (ACPI_FAILURE(status)) { 264 if (ACPI_FAILURE(status)) {
@@ -332,9 +332,9 @@ static int acpi_processor_get_info(struct acpi_device *device)
332 * ensure we get the right value in the "physical id" field 332 * ensure we get the right value in the "physical id" field
333 * of /proc/cpuinfo 333 * of /proc/cpuinfo
334 */ 334 */
335 status = acpi_evaluate_object(pr->handle, "_SUN", NULL, &buffer); 335 status = acpi_evaluate_integer(pr->handle, "_SUN", NULL, &value);
336 if (ACPI_SUCCESS(status)) 336 if (ACPI_SUCCESS(status))
337 arch_fix_phys_package_id(pr->id, object.integer.value); 337 arch_fix_phys_package_id(pr->id, value);
338 338
339 return 0; 339 return 0;
340} 340}
diff --git a/drivers/acpi/battery.c b/drivers/acpi/battery.c
index 2c9958cd7a43..fbf1aceda8b8 100644
--- a/drivers/acpi/battery.c
+++ b/drivers/acpi/battery.c
@@ -36,12 +36,6 @@
36#include <linux/suspend.h> 36#include <linux/suspend.h>
37#include <asm/unaligned.h> 37#include <asm/unaligned.h>
38 38
39#ifdef CONFIG_ACPI_PROCFS_POWER
40#include <linux/proc_fs.h>
41#include <linux/seq_file.h>
42#include <asm/uaccess.h>
43#endif
44
45#include <acpi/acpi_bus.h> 39#include <acpi/acpi_bus.h>
46#include <acpi/acpi_drivers.h> 40#include <acpi/acpi_drivers.h>
47#include <linux/power_supply.h> 41#include <linux/power_supply.h>
@@ -72,19 +66,6 @@ static unsigned int cache_time = 1000;
72module_param(cache_time, uint, 0644); 66module_param(cache_time, uint, 0644);
73MODULE_PARM_DESC(cache_time, "cache time in milliseconds"); 67MODULE_PARM_DESC(cache_time, "cache time in milliseconds");
74 68
75#ifdef CONFIG_ACPI_PROCFS_POWER
76extern struct proc_dir_entry *acpi_lock_battery_dir(void);
77extern void *acpi_unlock_battery_dir(struct proc_dir_entry *acpi_battery_dir);
78
79enum acpi_battery_files {
80 info_tag = 0,
81 state_tag,
82 alarm_tag,
83 ACPI_BATTERY_NUMFILES,
84};
85
86#endif
87
88static const struct acpi_device_id battery_device_ids[] = { 69static const struct acpi_device_id battery_device_ids[] = {
89 {"PNP0C0A", 0}, 70 {"PNP0C0A", 0},
90 {"", 0}, 71 {"", 0},
@@ -320,14 +301,6 @@ static enum power_supply_property energy_battery_props[] = {
320 POWER_SUPPLY_PROP_SERIAL_NUMBER, 301 POWER_SUPPLY_PROP_SERIAL_NUMBER,
321}; 302};
322 303
323#ifdef CONFIG_ACPI_PROCFS_POWER
324inline char *acpi_battery_units(struct acpi_battery *battery)
325{
326 return (battery->power_unit == ACPI_BATTERY_POWER_UNIT_MA) ?
327 "mA" : "mW";
328}
329#endif
330
331/* -------------------------------------------------------------------------- 304/* --------------------------------------------------------------------------
332 Battery Management 305 Battery Management
333 -------------------------------------------------------------------------- */ 306 -------------------------------------------------------------------------- */
@@ -741,279 +714,6 @@ static void acpi_battery_refresh(struct acpi_battery *battery)
741} 714}
742 715
743/* -------------------------------------------------------------------------- 716/* --------------------------------------------------------------------------
744 FS Interface (/proc)
745 -------------------------------------------------------------------------- */
746
747#ifdef CONFIG_ACPI_PROCFS_POWER
748static struct proc_dir_entry *acpi_battery_dir;
749
750static int acpi_battery_print_info(struct seq_file *seq, int result)
751{
752 struct acpi_battery *battery = seq->private;
753
754 if (result)
755 goto end;
756
757 seq_printf(seq, "present: %s\n",
758 acpi_battery_present(battery) ? "yes" : "no");
759 if (!acpi_battery_present(battery))
760 goto end;
761 if (battery->design_capacity == ACPI_BATTERY_VALUE_UNKNOWN)
762 seq_printf(seq, "design capacity: unknown\n");
763 else
764 seq_printf(seq, "design capacity: %d %sh\n",
765 battery->design_capacity,
766 acpi_battery_units(battery));
767
768 if (battery->full_charge_capacity == ACPI_BATTERY_VALUE_UNKNOWN)
769 seq_printf(seq, "last full capacity: unknown\n");
770 else
771 seq_printf(seq, "last full capacity: %d %sh\n",
772 battery->full_charge_capacity,
773 acpi_battery_units(battery));
774
775 seq_printf(seq, "battery technology: %srechargeable\n",
776 (!battery->technology)?"non-":"");
777
778 if (battery->design_voltage == ACPI_BATTERY_VALUE_UNKNOWN)
779 seq_printf(seq, "design voltage: unknown\n");
780 else
781 seq_printf(seq, "design voltage: %d mV\n",
782 battery->design_voltage);
783 seq_printf(seq, "design capacity warning: %d %sh\n",
784 battery->design_capacity_warning,
785 acpi_battery_units(battery));
786 seq_printf(seq, "design capacity low: %d %sh\n",
787 battery->design_capacity_low,
788 acpi_battery_units(battery));
789 seq_printf(seq, "cycle count: %i\n", battery->cycle_count);
790 seq_printf(seq, "capacity granularity 1: %d %sh\n",
791 battery->capacity_granularity_1,
792 acpi_battery_units(battery));
793 seq_printf(seq, "capacity granularity 2: %d %sh\n",
794 battery->capacity_granularity_2,
795 acpi_battery_units(battery));
796 seq_printf(seq, "model number: %s\n", battery->model_number);
797 seq_printf(seq, "serial number: %s\n", battery->serial_number);
798 seq_printf(seq, "battery type: %s\n", battery->type);
799 seq_printf(seq, "OEM info: %s\n", battery->oem_info);
800 end:
801 if (result)
802 seq_printf(seq, "ERROR: Unable to read battery info\n");
803 return result;
804}
805
806static int acpi_battery_print_state(struct seq_file *seq, int result)
807{
808 struct acpi_battery *battery = seq->private;
809
810 if (result)
811 goto end;
812
813 seq_printf(seq, "present: %s\n",
814 acpi_battery_present(battery) ? "yes" : "no");
815 if (!acpi_battery_present(battery))
816 goto end;
817
818 seq_printf(seq, "capacity state: %s\n",
819 (battery->state & 0x04) ? "critical" : "ok");
820 if ((battery->state & 0x01) && (battery->state & 0x02))
821 seq_printf(seq,
822 "charging state: charging/discharging\n");
823 else if (battery->state & 0x01)
824 seq_printf(seq, "charging state: discharging\n");
825 else if (battery->state & 0x02)
826 seq_printf(seq, "charging state: charging\n");
827 else
828 seq_printf(seq, "charging state: charged\n");
829
830 if (battery->rate_now == ACPI_BATTERY_VALUE_UNKNOWN)
831 seq_printf(seq, "present rate: unknown\n");
832 else
833 seq_printf(seq, "present rate: %d %s\n",
834 battery->rate_now, acpi_battery_units(battery));
835
836 if (battery->capacity_now == ACPI_BATTERY_VALUE_UNKNOWN)
837 seq_printf(seq, "remaining capacity: unknown\n");
838 else
839 seq_printf(seq, "remaining capacity: %d %sh\n",
840 battery->capacity_now, acpi_battery_units(battery));
841 if (battery->voltage_now == ACPI_BATTERY_VALUE_UNKNOWN)
842 seq_printf(seq, "present voltage: unknown\n");
843 else
844 seq_printf(seq, "present voltage: %d mV\n",
845 battery->voltage_now);
846 end:
847 if (result)
848 seq_printf(seq, "ERROR: Unable to read battery state\n");
849
850 return result;
851}
852
853static int acpi_battery_print_alarm(struct seq_file *seq, int result)
854{
855 struct acpi_battery *battery = seq->private;
856
857 if (result)
858 goto end;
859
860 if (!acpi_battery_present(battery)) {
861 seq_printf(seq, "present: no\n");
862 goto end;
863 }
864 seq_printf(seq, "alarm: ");
865 if (!battery->alarm)
866 seq_printf(seq, "unsupported\n");
867 else
868 seq_printf(seq, "%u %sh\n", battery->alarm,
869 acpi_battery_units(battery));
870 end:
871 if (result)
872 seq_printf(seq, "ERROR: Unable to read battery alarm\n");
873 return result;
874}
875
876static ssize_t acpi_battery_write_alarm(struct file *file,
877 const char __user * buffer,
878 size_t count, loff_t * ppos)
879{
880 int result = 0;
881 char alarm_string[12] = { '\0' };
882 struct seq_file *m = file->private_data;
883 struct acpi_battery *battery = m->private;
884
885 if (!battery || (count > sizeof(alarm_string) - 1))
886 return -EINVAL;
887 if (!acpi_battery_present(battery)) {
888 result = -ENODEV;
889 goto end;
890 }
891 if (copy_from_user(alarm_string, buffer, count)) {
892 result = -EFAULT;
893 goto end;
894 }
895 alarm_string[count] = '\0';
896 battery->alarm = simple_strtol(alarm_string, NULL, 0);
897 result = acpi_battery_set_alarm(battery);
898 end:
899 if (!result)
900 return count;
901 return result;
902}
903
904typedef int(*print_func)(struct seq_file *seq, int result);
905
906static print_func acpi_print_funcs[ACPI_BATTERY_NUMFILES] = {
907 acpi_battery_print_info,
908 acpi_battery_print_state,
909 acpi_battery_print_alarm,
910};
911
912static int acpi_battery_read(int fid, struct seq_file *seq)
913{
914 struct acpi_battery *battery = seq->private;
915 int result = acpi_battery_update(battery);
916 return acpi_print_funcs[fid](seq, result);
917}
918
919#define DECLARE_FILE_FUNCTIONS(_name) \
920static int acpi_battery_read_##_name(struct seq_file *seq, void *offset) \
921{ \
922 return acpi_battery_read(_name##_tag, seq); \
923} \
924static int acpi_battery_##_name##_open_fs(struct inode *inode, struct file *file) \
925{ \
926 return single_open(file, acpi_battery_read_##_name, PDE_DATA(inode)); \
927}
928
929DECLARE_FILE_FUNCTIONS(info);
930DECLARE_FILE_FUNCTIONS(state);
931DECLARE_FILE_FUNCTIONS(alarm);
932
933#undef DECLARE_FILE_FUNCTIONS
934
935#define FILE_DESCRIPTION_RO(_name) \
936 { \
937 .name = __stringify(_name), \
938 .mode = S_IRUGO, \
939 .ops = { \
940 .open = acpi_battery_##_name##_open_fs, \
941 .read = seq_read, \
942 .llseek = seq_lseek, \
943 .release = single_release, \
944 .owner = THIS_MODULE, \
945 }, \
946 }
947
948#define FILE_DESCRIPTION_RW(_name) \
949 { \
950 .name = __stringify(_name), \
951 .mode = S_IFREG | S_IRUGO | S_IWUSR, \
952 .ops = { \
953 .open = acpi_battery_##_name##_open_fs, \
954 .read = seq_read, \
955 .llseek = seq_lseek, \
956 .write = acpi_battery_write_##_name, \
957 .release = single_release, \
958 .owner = THIS_MODULE, \
959 }, \
960 }
961
962static const struct battery_file {
963 struct file_operations ops;
964 umode_t mode;
965 const char *name;
966} acpi_battery_file[] = {
967 FILE_DESCRIPTION_RO(info),
968 FILE_DESCRIPTION_RO(state),
969 FILE_DESCRIPTION_RW(alarm),
970};
971
972#undef FILE_DESCRIPTION_RO
973#undef FILE_DESCRIPTION_RW
974
975static int acpi_battery_add_fs(struct acpi_device *device)
976{
977 struct proc_dir_entry *entry = NULL;
978 int i;
979
980 printk(KERN_WARNING PREFIX "Deprecated procfs I/F for battery is loaded,"
981 " please retry with CONFIG_ACPI_PROCFS_POWER cleared\n");
982 if (!acpi_device_dir(device)) {
983 acpi_device_dir(device) = proc_mkdir(acpi_device_bid(device),
984 acpi_battery_dir);
985 if (!acpi_device_dir(device))
986 return -ENODEV;
987 }
988
989 for (i = 0; i < ACPI_BATTERY_NUMFILES; ++i) {
990 entry = proc_create_data(acpi_battery_file[i].name,
991 acpi_battery_file[i].mode,
992 acpi_device_dir(device),
993 &acpi_battery_file[i].ops,
994 acpi_driver_data(device));
995 if (!entry)
996 return -ENODEV;
997 }
998 return 0;
999}
1000
1001static void acpi_battery_remove_fs(struct acpi_device *device)
1002{
1003 int i;
1004 if (!acpi_device_dir(device))
1005 return;
1006 for (i = 0; i < ACPI_BATTERY_NUMFILES; ++i)
1007 remove_proc_entry(acpi_battery_file[i].name,
1008 acpi_device_dir(device));
1009
1010 remove_proc_entry(acpi_device_bid(device), acpi_battery_dir);
1011 acpi_device_dir(device) = NULL;
1012}
1013
1014#endif
1015
1016/* --------------------------------------------------------------------------
1017 Driver Interface 717 Driver Interface
1018 -------------------------------------------------------------------------- */ 718 -------------------------------------------------------------------------- */
1019 719
@@ -1075,15 +775,6 @@ static int acpi_battery_add(struct acpi_device *device)
1075 result = acpi_battery_update(battery); 775 result = acpi_battery_update(battery);
1076 if (result) 776 if (result)
1077 goto fail; 777 goto fail;
1078#ifdef CONFIG_ACPI_PROCFS_POWER
1079 result = acpi_battery_add_fs(device);
1080#endif
1081 if (result) {
1082#ifdef CONFIG_ACPI_PROCFS_POWER
1083 acpi_battery_remove_fs(device);
1084#endif
1085 goto fail;
1086 }
1087 778
1088 printk(KERN_INFO PREFIX "%s Slot [%s] (battery %s)\n", 779 printk(KERN_INFO PREFIX "%s Slot [%s] (battery %s)\n",
1089 ACPI_BATTERY_DEVICE_NAME, acpi_device_bid(device), 780 ACPI_BATTERY_DEVICE_NAME, acpi_device_bid(device),
@@ -1110,9 +801,6 @@ static int acpi_battery_remove(struct acpi_device *device)
1110 return -EINVAL; 801 return -EINVAL;
1111 battery = acpi_driver_data(device); 802 battery = acpi_driver_data(device);
1112 unregister_pm_notifier(&battery->pm_nb); 803 unregister_pm_notifier(&battery->pm_nb);
1113#ifdef CONFIG_ACPI_PROCFS_POWER
1114 acpi_battery_remove_fs(device);
1115#endif
1116 sysfs_remove_battery(battery); 804 sysfs_remove_battery(battery);
1117 mutex_destroy(&battery->lock); 805 mutex_destroy(&battery->lock);
1118 mutex_destroy(&battery->sysfs_lock); 806 mutex_destroy(&battery->sysfs_lock);
@@ -1158,18 +846,7 @@ static void __init acpi_battery_init_async(void *unused, async_cookie_t cookie)
1158{ 846{
1159 if (acpi_disabled) 847 if (acpi_disabled)
1160 return; 848 return;
1161#ifdef CONFIG_ACPI_PROCFS_POWER 849 acpi_bus_register_driver(&acpi_battery_driver);
1162 acpi_battery_dir = acpi_lock_battery_dir();
1163 if (!acpi_battery_dir)
1164 return;
1165#endif
1166 if (acpi_bus_register_driver(&acpi_battery_driver) < 0) {
1167#ifdef CONFIG_ACPI_PROCFS_POWER
1168 acpi_unlock_battery_dir(acpi_battery_dir);
1169#endif
1170 return;
1171 }
1172 return;
1173} 850}
1174 851
1175static int __init acpi_battery_init(void) 852static int __init acpi_battery_init(void)
@@ -1181,9 +858,6 @@ static int __init acpi_battery_init(void)
1181static void __exit acpi_battery_exit(void) 858static void __exit acpi_battery_exit(void)
1182{ 859{
1183 acpi_bus_unregister_driver(&acpi_battery_driver); 860 acpi_bus_unregister_driver(&acpi_battery_driver);
1184#ifdef CONFIG_ACPI_PROCFS_POWER
1185 acpi_unlock_battery_dir(acpi_battery_dir);
1186#endif
1187} 861}
1188 862
1189module_init(acpi_battery_init); 863module_init(acpi_battery_init);
diff --git a/drivers/acpi/cm_sbs.c b/drivers/acpi/cm_sbs.c
deleted file mode 100644
index 6c9ee68e46fb..000000000000
--- a/drivers/acpi/cm_sbs.c
+++ /dev/null
@@ -1,105 +0,0 @@
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
31#define PREFIX "ACPI: "
32
33ACPI_MODULE_NAME("cm_sbs");
34#define ACPI_AC_CLASS "ac_adapter"
35#define ACPI_BATTERY_CLASS "battery"
36#define _COMPONENT ACPI_SBS_COMPONENT
37static struct proc_dir_entry *acpi_ac_dir;
38static struct proc_dir_entry *acpi_battery_dir;
39
40static DEFINE_MUTEX(cm_sbs_mutex);
41
42static int lock_ac_dir_cnt;
43static int lock_battery_dir_cnt;
44
45struct proc_dir_entry *acpi_lock_ac_dir(void)
46{
47 mutex_lock(&cm_sbs_mutex);
48 if (!acpi_ac_dir)
49 acpi_ac_dir = proc_mkdir(ACPI_AC_CLASS, acpi_root_dir);
50 if (acpi_ac_dir) {
51 lock_ac_dir_cnt++;
52 } else {
53 printk(KERN_ERR PREFIX
54 "Cannot create %s\n", ACPI_AC_CLASS);
55 }
56 mutex_unlock(&cm_sbs_mutex);
57 return acpi_ac_dir;
58}
59EXPORT_SYMBOL(acpi_lock_ac_dir);
60
61void acpi_unlock_ac_dir(struct proc_dir_entry *acpi_ac_dir_param)
62{
63 mutex_lock(&cm_sbs_mutex);
64 if (acpi_ac_dir_param)
65 lock_ac_dir_cnt--;
66 if (lock_ac_dir_cnt == 0 && acpi_ac_dir_param && acpi_ac_dir) {
67 remove_proc_entry(ACPI_AC_CLASS, acpi_root_dir);
68 acpi_ac_dir = NULL;
69 }
70 mutex_unlock(&cm_sbs_mutex);
71}
72EXPORT_SYMBOL(acpi_unlock_ac_dir);
73
74struct proc_dir_entry *acpi_lock_battery_dir(void)
75{
76 mutex_lock(&cm_sbs_mutex);
77 if (!acpi_battery_dir) {
78 acpi_battery_dir =
79 proc_mkdir(ACPI_BATTERY_CLASS, acpi_root_dir);
80 }
81 if (acpi_battery_dir) {
82 lock_battery_dir_cnt++;
83 } else {
84 printk(KERN_ERR PREFIX
85 "Cannot create %s\n", ACPI_BATTERY_CLASS);
86 }
87 mutex_unlock(&cm_sbs_mutex);
88 return acpi_battery_dir;
89}
90EXPORT_SYMBOL(acpi_lock_battery_dir);
91
92void acpi_unlock_battery_dir(struct proc_dir_entry *acpi_battery_dir_param)
93{
94 mutex_lock(&cm_sbs_mutex);
95 if (acpi_battery_dir_param)
96 lock_battery_dir_cnt--;
97 if (lock_battery_dir_cnt == 0 && acpi_battery_dir_param
98 && acpi_battery_dir) {
99 remove_proc_entry(ACPI_BATTERY_CLASS, acpi_root_dir);
100 acpi_battery_dir = NULL;
101 }
102 mutex_unlock(&cm_sbs_mutex);
103 return;
104}
105EXPORT_SYMBOL(acpi_unlock_battery_dir);
diff --git a/drivers/acpi/dock.c b/drivers/acpi/dock.c
index 05ea4be01a83..ca86c1ce7c8a 100644
--- a/drivers/acpi/dock.c
+++ b/drivers/acpi/dock.c
@@ -441,7 +441,7 @@ static void handle_dock(struct dock_station *ds, int dock)
441 acpi_status status; 441 acpi_status status;
442 struct acpi_object_list arg_list; 442 struct acpi_object_list arg_list;
443 union acpi_object arg; 443 union acpi_object arg;
444 struct acpi_buffer buffer = { ACPI_ALLOCATE_BUFFER, NULL }; 444 unsigned long long value;
445 445
446 acpi_handle_info(ds->handle, "%s\n", dock ? "docking" : "undocking"); 446 acpi_handle_info(ds->handle, "%s\n", dock ? "docking" : "undocking");
447 447
@@ -450,12 +450,10 @@ static void handle_dock(struct dock_station *ds, int dock)
450 arg_list.pointer = &arg; 450 arg_list.pointer = &arg;
451 arg.type = ACPI_TYPE_INTEGER; 451 arg.type = ACPI_TYPE_INTEGER;
452 arg.integer.value = dock; 452 arg.integer.value = dock;
453 status = acpi_evaluate_object(ds->handle, "_DCK", &arg_list, &buffer); 453 status = acpi_evaluate_integer(ds->handle, "_DCK", &arg_list, &value);
454 if (ACPI_FAILURE(status) && status != AE_NOT_FOUND) 454 if (ACPI_FAILURE(status) && status != AE_NOT_FOUND)
455 acpi_handle_err(ds->handle, "Failed to execute _DCK (0x%x)\n", 455 acpi_handle_err(ds->handle, "Failed to execute _DCK (0x%x)\n",
456 status); 456 status);
457
458 kfree(buffer.pointer);
459} 457}
460 458
461static inline void dock(struct dock_station *ds) 459static inline void dock(struct dock_station *ds)
diff --git a/drivers/acpi/fan.c b/drivers/acpi/fan.c
index 41ade6570bc0..ba3da88cee45 100644
--- a/drivers/acpi/fan.c
+++ b/drivers/acpi/fan.c
@@ -168,7 +168,7 @@ static int acpi_fan_add(struct acpi_device *device)
168 acpi_device_name(device), acpi_device_bid(device), 168 acpi_device_name(device), acpi_device_bid(device),
169 !device->power.state ? "on" : "off"); 169 !device->power.state ? "on" : "off");
170 170
171 end: 171end:
172 return result; 172 return result;
173} 173}
174 174
diff --git a/drivers/acpi/numa.c b/drivers/acpi/numa.c
index 2e82e5d76930..a2343a1d9e0b 100644
--- a/drivers/acpi/numa.c
+++ b/drivers/acpi/numa.c
@@ -73,7 +73,7 @@ int acpi_map_pxm_to_node(int pxm)
73{ 73{
74 int node = pxm_to_node_map[pxm]; 74 int node = pxm_to_node_map[pxm];
75 75
76 if (node < 0) { 76 if (node == NUMA_NO_NODE) {
77 if (nodes_weight(nodes_found_map) >= MAX_NUMNODES) 77 if (nodes_weight(nodes_found_map) >= MAX_NUMNODES)
78 return NUMA_NO_NODE; 78 return NUMA_NO_NODE;
79 node = first_unset_node(nodes_found_map); 79 node = first_unset_node(nodes_found_map);
@@ -334,7 +334,7 @@ int acpi_get_pxm(acpi_handle h)
334 334
335int acpi_get_node(acpi_handle *handle) 335int acpi_get_node(acpi_handle *handle)
336{ 336{
337 int pxm, node = -1; 337 int pxm, node = NUMA_NO_NODE;
338 338
339 pxm = acpi_get_pxm(handle); 339 pxm = acpi_get_pxm(handle);
340 if (pxm >= 0 && pxm < MAX_PXM_DOMAINS) 340 if (pxm >= 0 && pxm < MAX_PXM_DOMAINS)
diff --git a/drivers/acpi/proc.c b/drivers/acpi/proc.c
index 04a13784dd20..6a5b152ad4d0 100644
--- a/drivers/acpi/proc.c
+++ b/drivers/acpi/proc.c
@@ -8,289 +8,17 @@
8#include <acpi/acpi_bus.h> 8#include <acpi/acpi_bus.h>
9#include <acpi/acpi_drivers.h> 9#include <acpi/acpi_drivers.h>
10 10
11#ifdef CONFIG_X86
12#include <linux/mc146818rtc.h>
13#endif
14
15#include "sleep.h" 11#include "sleep.h"
16 12
17#define _COMPONENT ACPI_SYSTEM_COMPONENT 13#define _COMPONENT ACPI_SYSTEM_COMPONENT
18 14
19/* 15/*
20 * this file provides support for: 16 * this file provides support for:
21 * /proc/acpi/alarm
22 * /proc/acpi/wakeup 17 * /proc/acpi/wakeup
23 */ 18 */
24 19
25ACPI_MODULE_NAME("sleep") 20ACPI_MODULE_NAME("sleep")
26 21
27#if defined(CONFIG_RTC_DRV_CMOS) || defined(CONFIG_RTC_DRV_CMOS_MODULE) || !defined(CONFIG_X86)
28/* use /sys/class/rtc/rtcX/wakealarm instead; it's not ACPI-specific */
29#else
30#define HAVE_ACPI_LEGACY_ALARM
31#endif
32
33#ifdef HAVE_ACPI_LEGACY_ALARM
34
35static u32 cmos_bcd_read(int offset, int rtc_control);
36
37static int acpi_system_alarm_seq_show(struct seq_file *seq, void *offset)
38{
39 u32 sec, min, hr;
40 u32 day, mo, yr, cent = 0;
41 u32 today = 0;
42 unsigned char rtc_control = 0;
43 unsigned long flags;
44
45 spin_lock_irqsave(&rtc_lock, flags);
46
47 rtc_control = CMOS_READ(RTC_CONTROL);
48 sec = cmos_bcd_read(RTC_SECONDS_ALARM, rtc_control);
49 min = cmos_bcd_read(RTC_MINUTES_ALARM, rtc_control);
50 hr = cmos_bcd_read(RTC_HOURS_ALARM, rtc_control);
51
52 /* If we ever get an FACP with proper values... */
53 if (acpi_gbl_FADT.day_alarm) {
54 /* ACPI spec: only low 6 its should be cared */
55 day = CMOS_READ(acpi_gbl_FADT.day_alarm) & 0x3F;
56 if (!(rtc_control & RTC_DM_BINARY) || RTC_ALWAYS_BCD)
57 day = bcd2bin(day);
58 } else
59 day = cmos_bcd_read(RTC_DAY_OF_MONTH, rtc_control);
60 if (acpi_gbl_FADT.month_alarm)
61 mo = cmos_bcd_read(acpi_gbl_FADT.month_alarm, rtc_control);
62 else {
63 mo = cmos_bcd_read(RTC_MONTH, rtc_control);
64 today = cmos_bcd_read(RTC_DAY_OF_MONTH, rtc_control);
65 }
66 if (acpi_gbl_FADT.century)
67 cent = cmos_bcd_read(acpi_gbl_FADT.century, rtc_control);
68
69 yr = cmos_bcd_read(RTC_YEAR, rtc_control);
70
71 spin_unlock_irqrestore(&rtc_lock, flags);
72
73 /* we're trusting the FADT (see above) */
74 if (!acpi_gbl_FADT.century)
75 /* If we're not trusting the FADT, we should at least make it
76 * right for _this_ century... ehm, what is _this_ century?
77 *
78 * TBD:
79 * ASAP: find piece of code in the kernel, e.g. star tracker driver,
80 * which we can trust to determine the century correctly. Atom
81 * watch driver would be nice, too...
82 *
83 * if that has not happened, change for first release in 2050:
84 * if (yr<50)
85 * yr += 2100;
86 * else
87 * yr += 2000; // current line of code
88 *
89 * if that has not happened either, please do on 2099/12/31:23:59:59
90 * s/2000/2100
91 *
92 */
93 yr += 2000;
94 else
95 yr += cent * 100;
96
97 /*
98 * Show correct dates for alarms up to a month into the future.
99 * This solves issues for nearly all situations with the common
100 * 30-day alarm clocks in PC hardware.
101 */
102 if (day < today) {
103 if (mo < 12) {
104 mo += 1;
105 } else {
106 mo = 1;
107 yr += 1;
108 }
109 }
110
111 seq_printf(seq, "%4.4u-", yr);
112 (mo > 12) ? seq_puts(seq, "**-") : seq_printf(seq, "%2.2u-", mo);
113 (day > 31) ? seq_puts(seq, "** ") : seq_printf(seq, "%2.2u ", day);
114 (hr > 23) ? seq_puts(seq, "**:") : seq_printf(seq, "%2.2u:", hr);
115 (min > 59) ? seq_puts(seq, "**:") : seq_printf(seq, "%2.2u:", min);
116 (sec > 59) ? seq_puts(seq, "**\n") : seq_printf(seq, "%2.2u\n", sec);
117
118 return 0;
119}
120
121static int acpi_system_alarm_open_fs(struct inode *inode, struct file *file)
122{
123 return single_open(file, acpi_system_alarm_seq_show, PDE_DATA(inode));
124}
125
126static int get_date_field(char **p, u32 * value)
127{
128 char *next = NULL;
129 char *string_end = NULL;
130 int result = -EINVAL;
131
132 /*
133 * Try to find delimeter, only to insert null. The end of the
134 * string won't have one, but is still valid.
135 */
136 if (*p == NULL)
137 return result;
138
139 next = strpbrk(*p, "- :");
140 if (next)
141 *next++ = '\0';
142
143 *value = simple_strtoul(*p, &string_end, 10);
144
145 /* Signal success if we got a good digit */
146 if (string_end != *p)
147 result = 0;
148
149 if (next)
150 *p = next;
151 else
152 *p = NULL;
153
154 return result;
155}
156
157/* Read a possibly BCD register, always return binary */
158static u32 cmos_bcd_read(int offset, int rtc_control)
159{
160 u32 val = CMOS_READ(offset);
161 if (!(rtc_control & RTC_DM_BINARY) || RTC_ALWAYS_BCD)
162 val = bcd2bin(val);
163 return val;
164}
165
166/* Write binary value into possibly BCD register */
167static void cmos_bcd_write(u32 val, int offset, int rtc_control)
168{
169 if (!(rtc_control & RTC_DM_BINARY) || RTC_ALWAYS_BCD)
170 val = bin2bcd(val);
171 CMOS_WRITE(val, offset);
172}
173
174static ssize_t
175acpi_system_write_alarm(struct file *file,
176 const char __user * buffer, size_t count, loff_t * ppos)
177{
178 int result = 0;
179 char alarm_string[30] = { '\0' };
180 char *p = alarm_string;
181 u32 sec, min, hr, day, mo, yr;
182 int adjust = 0;
183 unsigned char rtc_control = 0;
184
185 if (count > sizeof(alarm_string) - 1)
186 return -EINVAL;
187
188 if (copy_from_user(alarm_string, buffer, count))
189 return -EFAULT;
190
191 alarm_string[count] = '\0';
192
193 /* check for time adjustment */
194 if (alarm_string[0] == '+') {
195 p++;
196 adjust = 1;
197 }
198
199 if ((result = get_date_field(&p, &yr)))
200 goto end;
201 if ((result = get_date_field(&p, &mo)))
202 goto end;
203 if ((result = get_date_field(&p, &day)))
204 goto end;
205 if ((result = get_date_field(&p, &hr)))
206 goto end;
207 if ((result = get_date_field(&p, &min)))
208 goto end;
209 if ((result = get_date_field(&p, &sec)))
210 goto end;
211
212 spin_lock_irq(&rtc_lock);
213
214 rtc_control = CMOS_READ(RTC_CONTROL);
215
216 if (adjust) {
217 yr += cmos_bcd_read(RTC_YEAR, rtc_control);
218 mo += cmos_bcd_read(RTC_MONTH, rtc_control);
219 day += cmos_bcd_read(RTC_DAY_OF_MONTH, rtc_control);
220 hr += cmos_bcd_read(RTC_HOURS, rtc_control);
221 min += cmos_bcd_read(RTC_MINUTES, rtc_control);
222 sec += cmos_bcd_read(RTC_SECONDS, rtc_control);
223 }
224
225 spin_unlock_irq(&rtc_lock);
226
227 if (sec > 59) {
228 min += sec/60;
229 sec = sec%60;
230 }
231 if (min > 59) {
232 hr += min/60;
233 min = min%60;
234 }
235 if (hr > 23) {
236 day += hr/24;
237 hr = hr%24;
238 }
239 if (day > 31) {
240 mo += day/32;
241 day = day%32;
242 }
243 if (mo > 12) {
244 yr += mo/13;
245 mo = mo%13;
246 }
247
248 spin_lock_irq(&rtc_lock);
249 /*
250 * Disable alarm interrupt before setting alarm timer or else
251 * when ACPI_EVENT_RTC is enabled, a spurious ACPI interrupt occurs
252 */
253 rtc_control &= ~RTC_AIE;
254 CMOS_WRITE(rtc_control, RTC_CONTROL);
255 CMOS_READ(RTC_INTR_FLAGS);
256
257 /* write the fields the rtc knows about */
258 cmos_bcd_write(hr, RTC_HOURS_ALARM, rtc_control);
259 cmos_bcd_write(min, RTC_MINUTES_ALARM, rtc_control);
260 cmos_bcd_write(sec, RTC_SECONDS_ALARM, rtc_control);
261
262 /*
263 * If the system supports an enhanced alarm it will have non-zero
264 * offsets into the CMOS RAM here -- which for some reason are pointing
265 * to the RTC area of memory.
266 */
267 if (acpi_gbl_FADT.day_alarm)
268 cmos_bcd_write(day, acpi_gbl_FADT.day_alarm, rtc_control);
269 if (acpi_gbl_FADT.month_alarm)
270 cmos_bcd_write(mo, acpi_gbl_FADT.month_alarm, rtc_control);
271 if (acpi_gbl_FADT.century) {
272 if (adjust)
273 yr += cmos_bcd_read(acpi_gbl_FADT.century, rtc_control) * 100;
274 cmos_bcd_write(yr / 100, acpi_gbl_FADT.century, rtc_control);
275 }
276 /* enable the rtc alarm interrupt */
277 rtc_control |= RTC_AIE;
278 CMOS_WRITE(rtc_control, RTC_CONTROL);
279 CMOS_READ(RTC_INTR_FLAGS);
280
281 spin_unlock_irq(&rtc_lock);
282
283 acpi_clear_event(ACPI_EVENT_RTC);
284 acpi_enable_event(ACPI_EVENT_RTC, 0);
285
286 *ppos += count;
287
288 result = 0;
289 end:
290 return result ? result : count;
291}
292#endif /* HAVE_ACPI_LEGACY_ALARM */
293
294static int 22static int
295acpi_system_wakeup_device_seq_show(struct seq_file *seq, void *offset) 23acpi_system_wakeup_device_seq_show(struct seq_file *seq, void *offset)
296{ 24{
@@ -417,41 +145,8 @@ static const struct file_operations acpi_system_wakeup_device_fops = {
417 .release = single_release, 145 .release = single_release,
418}; 146};
419 147
420#ifdef HAVE_ACPI_LEGACY_ALARM
421static const struct file_operations acpi_system_alarm_fops = {
422 .owner = THIS_MODULE,
423 .open = acpi_system_alarm_open_fs,
424 .read = seq_read,
425 .write = acpi_system_write_alarm,
426 .llseek = seq_lseek,
427 .release = single_release,
428};
429
430static u32 rtc_handler(void *context)
431{
432 acpi_clear_event(ACPI_EVENT_RTC);
433 acpi_disable_event(ACPI_EVENT_RTC, 0);
434
435 return ACPI_INTERRUPT_HANDLED;
436}
437#endif /* HAVE_ACPI_LEGACY_ALARM */
438
439int __init acpi_sleep_proc_init(void) 148int __init acpi_sleep_proc_init(void)
440{ 149{
441#ifdef HAVE_ACPI_LEGACY_ALARM
442 /* 'alarm' [R/W] */
443 proc_create("alarm", S_IFREG | S_IRUGO | S_IWUSR,
444 acpi_root_dir, &acpi_system_alarm_fops);
445
446 acpi_install_fixed_event_handler(ACPI_EVENT_RTC, rtc_handler, NULL);
447 /*
448 * Disable the RTC event after installing RTC handler.
449 * Only when RTC alarm is set will it be enabled.
450 */
451 acpi_clear_event(ACPI_EVENT_RTC);
452 acpi_disable_event(ACPI_EVENT_RTC, 0);
453#endif /* HAVE_ACPI_LEGACY_ALARM */
454
455 /* 'wakeup device' [R/W] */ 150 /* 'wakeup device' [R/W] */
456 proc_create("wakeup", S_IFREG | S_IRUGO | S_IWUSR, 151 proc_create("wakeup", S_IFREG | S_IRUGO | S_IWUSR,
457 acpi_root_dir, &acpi_system_wakeup_device_fops); 152 acpi_root_dir, &acpi_system_wakeup_device_fops);
diff --git a/drivers/acpi/processor_idle.c b/drivers/acpi/processor_idle.c
index f98dd00b51a9..35c8f2bbcc40 100644
--- a/drivers/acpi/processor_idle.c
+++ b/drivers/acpi/processor_idle.c
@@ -272,9 +272,6 @@ static void tsc_check_state(int state) { return; }
272static int acpi_processor_get_power_info_fadt(struct acpi_processor *pr) 272static int acpi_processor_get_power_info_fadt(struct acpi_processor *pr)
273{ 273{
274 274
275 if (!pr)
276 return -EINVAL;
277
278 if (!pr->pblk) 275 if (!pr->pblk)
279 return -ENODEV; 276 return -ENODEV;
280 277
@@ -1076,12 +1073,8 @@ int acpi_processor_hotplug(struct acpi_processor *pr)
1076 if (disabled_by_idle_boot_param()) 1073 if (disabled_by_idle_boot_param())
1077 return 0; 1074 return 0;
1078 1075
1079 if (!pr) 1076 if (nocst)
1080 return -EINVAL;
1081
1082 if (nocst) {
1083 return -ENODEV; 1077 return -ENODEV;
1084 }
1085 1078
1086 if (!pr->flags.power_setup_done) 1079 if (!pr->flags.power_setup_done)
1087 return -ENODEV; 1080 return -ENODEV;
@@ -1108,9 +1101,6 @@ int acpi_processor_cst_has_changed(struct acpi_processor *pr)
1108 if (disabled_by_idle_boot_param()) 1101 if (disabled_by_idle_boot_param())
1109 return 0; 1102 return 0;
1110 1103
1111 if (!pr)
1112 return -EINVAL;
1113
1114 if (nocst) 1104 if (nocst)
1115 return -ENODEV; 1105 return -ENODEV;
1116 1106
@@ -1183,9 +1173,6 @@ int acpi_processor_power_init(struct acpi_processor *pr)
1183 first_run++; 1173 first_run++;
1184 } 1174 }
1185 1175
1186 if (!pr)
1187 return -EINVAL;
1188
1189 if (acpi_gbl_FADT.cst_control && !nocst) { 1176 if (acpi_gbl_FADT.cst_control && !nocst) {
1190 status = 1177 status =
1191 acpi_os_write_port(acpi_gbl_FADT.smi_command, acpi_gbl_FADT.cst_control, 8); 1178 acpi_os_write_port(acpi_gbl_FADT.smi_command, acpi_gbl_FADT.cst_control, 8);
diff --git a/drivers/acpi/sbs.c b/drivers/acpi/sbs.c
index aef7e1cd1e5d..d465ae6cdd00 100644
--- a/drivers/acpi/sbs.c
+++ b/drivers/acpi/sbs.c
@@ -30,12 +30,6 @@
30#include <linux/moduleparam.h> 30#include <linux/moduleparam.h>
31#include <linux/kernel.h> 31#include <linux/kernel.h>
32 32
33#ifdef CONFIG_ACPI_PROCFS_POWER
34#include <linux/proc_fs.h>
35#include <linux/seq_file.h>
36#include <asm/uaccess.h>
37#endif
38
39#include <linux/acpi.h> 33#include <linux/acpi.h>
40#include <linux/timer.h> 34#include <linux/timer.h>
41#include <linux/jiffies.h> 35#include <linux/jiffies.h>
@@ -67,11 +61,6 @@ static unsigned int cache_time = 1000;
67module_param(cache_time, uint, 0644); 61module_param(cache_time, uint, 0644);
68MODULE_PARM_DESC(cache_time, "cache time in milliseconds"); 62MODULE_PARM_DESC(cache_time, "cache time in milliseconds");
69 63
70extern struct proc_dir_entry *acpi_lock_ac_dir(void);
71extern struct proc_dir_entry *acpi_lock_battery_dir(void);
72extern void acpi_unlock_ac_dir(struct proc_dir_entry *acpi_ac_dir);
73extern void acpi_unlock_battery_dir(struct proc_dir_entry *acpi_battery_dir);
74
75#define MAX_SBS_BAT 4 64#define MAX_SBS_BAT 4
76#define ACPI_SBS_BLOCK_MAX 32 65#define ACPI_SBS_BLOCK_MAX 32
77 66
@@ -84,9 +73,6 @@ MODULE_DEVICE_TABLE(acpi, sbs_device_ids);
84struct acpi_battery { 73struct acpi_battery {
85 struct power_supply bat; 74 struct power_supply bat;
86 struct acpi_sbs *sbs; 75 struct acpi_sbs *sbs;
87#ifdef CONFIG_ACPI_PROCFS_POWER
88 struct proc_dir_entry *proc_entry;
89#endif
90 unsigned long update_time; 76 unsigned long update_time;
91 char name[8]; 77 char name[8];
92 char manufacturer_name[ACPI_SBS_BLOCK_MAX]; 78 char manufacturer_name[ACPI_SBS_BLOCK_MAX];
@@ -119,9 +105,6 @@ struct acpi_sbs {
119 struct acpi_device *device; 105 struct acpi_device *device;
120 struct acpi_smb_hc *hc; 106 struct acpi_smb_hc *hc;
121 struct mutex lock; 107 struct mutex lock;
122#ifdef CONFIG_ACPI_PROCFS_POWER
123 struct proc_dir_entry *charger_entry;
124#endif
125 struct acpi_battery battery[MAX_SBS_BAT]; 108 struct acpi_battery battery[MAX_SBS_BAT];
126 u8 batteries_supported:4; 109 u8 batteries_supported:4;
127 u8 manager_present:1; 110 u8 manager_present:1;
@@ -482,261 +465,6 @@ static struct device_attribute alarm_attr = {
482}; 465};
483 466
484/* -------------------------------------------------------------------------- 467/* --------------------------------------------------------------------------
485 FS Interface (/proc/acpi)
486 -------------------------------------------------------------------------- */
487
488#ifdef CONFIG_ACPI_PROCFS_POWER
489/* Generic Routines */
490static int
491acpi_sbs_add_fs(struct proc_dir_entry **dir,
492 struct proc_dir_entry *parent_dir,
493 char *dir_name,
494 const struct file_operations *info_fops,
495 const struct file_operations *state_fops,
496 const struct file_operations *alarm_fops, void *data)
497{
498 printk(KERN_WARNING PREFIX "Deprecated procfs I/F for SBS is loaded,"
499 " please retry with CONFIG_ACPI_PROCFS_POWER cleared\n");
500 if (!*dir) {
501 *dir = proc_mkdir(dir_name, parent_dir);
502 if (!*dir) {
503 return -ENODEV;
504 }
505 }
506
507 /* 'info' [R] */
508 if (info_fops)
509 proc_create_data(ACPI_SBS_FILE_INFO, S_IRUGO, *dir,
510 info_fops, data);
511
512 /* 'state' [R] */
513 if (state_fops)
514 proc_create_data(ACPI_SBS_FILE_STATE, S_IRUGO, *dir,
515 state_fops, data);
516
517 /* 'alarm' [R/W] */
518 if (alarm_fops)
519 proc_create_data(ACPI_SBS_FILE_ALARM, S_IRUGO, *dir,
520 alarm_fops, data);
521 return 0;
522}
523
524/* Smart Battery Interface */
525static struct proc_dir_entry *acpi_battery_dir = NULL;
526
527static inline char *acpi_battery_units(struct acpi_battery *battery)
528{
529 return acpi_battery_mode(battery) ? " mW" : " mA";
530}
531
532
533static int acpi_battery_read_info(struct seq_file *seq, void *offset)
534{
535 struct acpi_battery *battery = seq->private;
536 struct acpi_sbs *sbs = battery->sbs;
537 int result = 0;
538
539 mutex_lock(&sbs->lock);
540
541 seq_printf(seq, "present: %s\n",
542 (battery->present) ? "yes" : "no");
543 if (!battery->present)
544 goto end;
545
546 seq_printf(seq, "design capacity: %i%sh\n",
547 battery->design_capacity * acpi_battery_scale(battery),
548 acpi_battery_units(battery));
549 seq_printf(seq, "last full capacity: %i%sh\n",
550 battery->full_charge_capacity * acpi_battery_scale(battery),
551 acpi_battery_units(battery));
552 seq_printf(seq, "battery technology: rechargeable\n");
553 seq_printf(seq, "design voltage: %i mV\n",
554 battery->design_voltage * acpi_battery_vscale(battery));
555 seq_printf(seq, "design capacity warning: unknown\n");
556 seq_printf(seq, "design capacity low: unknown\n");
557 seq_printf(seq, "cycle count: %i\n", battery->cycle_count);
558 seq_printf(seq, "capacity granularity 1: unknown\n");
559 seq_printf(seq, "capacity granularity 2: unknown\n");
560 seq_printf(seq, "model number: %s\n", battery->device_name);
561 seq_printf(seq, "serial number: %i\n",
562 battery->serial_number);
563 seq_printf(seq, "battery type: %s\n",
564 battery->device_chemistry);
565 seq_printf(seq, "OEM info: %s\n",
566 battery->manufacturer_name);
567 end:
568 mutex_unlock(&sbs->lock);
569 return result;
570}
571
572static int acpi_battery_info_open_fs(struct inode *inode, struct file *file)
573{
574 return single_open(file, acpi_battery_read_info, PDE_DATA(inode));
575}
576
577static int acpi_battery_read_state(struct seq_file *seq, void *offset)
578{
579 struct acpi_battery *battery = seq->private;
580 struct acpi_sbs *sbs = battery->sbs;
581 int rate;
582
583 mutex_lock(&sbs->lock);
584 seq_printf(seq, "present: %s\n",
585 (battery->present) ? "yes" : "no");
586 if (!battery->present)
587 goto end;
588
589 acpi_battery_get_state(battery);
590 seq_printf(seq, "capacity state: %s\n",
591 (battery->state & 0x0010) ? "critical" : "ok");
592 seq_printf(seq, "charging state: %s\n",
593 (battery->rate_now < 0) ? "discharging" :
594 ((battery->rate_now > 0) ? "charging" : "charged"));
595 rate = abs(battery->rate_now) * acpi_battery_ipscale(battery);
596 rate *= (acpi_battery_mode(battery))?(battery->voltage_now *
597 acpi_battery_vscale(battery)/1000):1;
598 seq_printf(seq, "present rate: %d%s\n", rate,
599 acpi_battery_units(battery));
600 seq_printf(seq, "remaining capacity: %i%sh\n",
601 battery->capacity_now * acpi_battery_scale(battery),
602 acpi_battery_units(battery));
603 seq_printf(seq, "present voltage: %i mV\n",
604 battery->voltage_now * acpi_battery_vscale(battery));
605
606 end:
607 mutex_unlock(&sbs->lock);
608 return 0;
609}
610
611static int acpi_battery_state_open_fs(struct inode *inode, struct file *file)
612{
613 return single_open(file, acpi_battery_read_state, PDE_DATA(inode));
614}
615
616static int acpi_battery_read_alarm(struct seq_file *seq, void *offset)
617{
618 struct acpi_battery *battery = seq->private;
619 struct acpi_sbs *sbs = battery->sbs;
620 int result = 0;
621
622 mutex_lock(&sbs->lock);
623
624 if (!battery->present) {
625 seq_printf(seq, "present: no\n");
626 goto end;
627 }
628
629 acpi_battery_get_alarm(battery);
630 seq_printf(seq, "alarm: ");
631 if (battery->alarm_capacity)
632 seq_printf(seq, "%i%sh\n",
633 battery->alarm_capacity *
634 acpi_battery_scale(battery),
635 acpi_battery_units(battery));
636 else
637 seq_printf(seq, "disabled\n");
638 end:
639 mutex_unlock(&sbs->lock);
640 return result;
641}
642
643static ssize_t
644acpi_battery_write_alarm(struct file *file, const char __user * buffer,
645 size_t count, loff_t * ppos)
646{
647 struct seq_file *seq = file->private_data;
648 struct acpi_battery *battery = seq->private;
649 struct acpi_sbs *sbs = battery->sbs;
650 char alarm_string[12] = { '\0' };
651 int result = 0;
652 mutex_lock(&sbs->lock);
653 if (!battery->present) {
654 result = -ENODEV;
655 goto end;
656 }
657 if (count > sizeof(alarm_string) - 1) {
658 result = -EINVAL;
659 goto end;
660 }
661 if (copy_from_user(alarm_string, buffer, count)) {
662 result = -EFAULT;
663 goto end;
664 }
665 alarm_string[count] = 0;
666 battery->alarm_capacity = simple_strtoul(alarm_string, NULL, 0) /
667 acpi_battery_scale(battery);
668 acpi_battery_set_alarm(battery);
669 end:
670 mutex_unlock(&sbs->lock);
671 if (result)
672 return result;
673 return count;
674}
675
676static int acpi_battery_alarm_open_fs(struct inode *inode, struct file *file)
677{
678 return single_open(file, acpi_battery_read_alarm, PDE_DATA(inode));
679}
680
681static const struct file_operations acpi_battery_info_fops = {
682 .open = acpi_battery_info_open_fs,
683 .read = seq_read,
684 .llseek = seq_lseek,
685 .release = single_release,
686 .owner = THIS_MODULE,
687};
688
689static const struct file_operations acpi_battery_state_fops = {
690 .open = acpi_battery_state_open_fs,
691 .read = seq_read,
692 .llseek = seq_lseek,
693 .release = single_release,
694 .owner = THIS_MODULE,
695};
696
697static const struct file_operations acpi_battery_alarm_fops = {
698 .open = acpi_battery_alarm_open_fs,
699 .read = seq_read,
700 .write = acpi_battery_write_alarm,
701 .llseek = seq_lseek,
702 .release = single_release,
703 .owner = THIS_MODULE,
704};
705
706/* Legacy AC Adapter Interface */
707
708static struct proc_dir_entry *acpi_ac_dir = NULL;
709
710static int acpi_ac_read_state(struct seq_file *seq, void *offset)
711{
712
713 struct acpi_sbs *sbs = seq->private;
714
715 mutex_lock(&sbs->lock);
716
717 seq_printf(seq, "state: %s\n",
718 sbs->charger_present ? "on-line" : "off-line");
719
720 mutex_unlock(&sbs->lock);
721 return 0;
722}
723
724static int acpi_ac_state_open_fs(struct inode *inode, struct file *file)
725{
726 return single_open(file, acpi_ac_read_state, PDE_DATA(inode));
727}
728
729static const struct file_operations acpi_ac_state_fops = {
730 .open = acpi_ac_state_open_fs,
731 .read = seq_read,
732 .llseek = seq_lseek,
733 .release = single_release,
734 .owner = THIS_MODULE,
735};
736
737#endif
738
739/* --------------------------------------------------------------------------
740 Driver Interface 468 Driver Interface
741 -------------------------------------------------------------------------- */ 469 -------------------------------------------------------------------------- */
742static int acpi_battery_read(struct acpi_battery *battery) 470static int acpi_battery_read(struct acpi_battery *battery)
@@ -781,12 +509,6 @@ static int acpi_battery_add(struct acpi_sbs *sbs, int id)
781 return result; 509 return result;
782 510
783 sprintf(battery->name, ACPI_BATTERY_DIR_NAME, id); 511 sprintf(battery->name, ACPI_BATTERY_DIR_NAME, id);
784#ifdef CONFIG_ACPI_PROCFS_POWER
785 acpi_sbs_add_fs(&battery->proc_entry, acpi_battery_dir,
786 battery->name, &acpi_battery_info_fops,
787 &acpi_battery_state_fops, &acpi_battery_alarm_fops,
788 battery);
789#endif
790 battery->bat.name = battery->name; 512 battery->bat.name = battery->name;
791 battery->bat.type = POWER_SUPPLY_TYPE_BATTERY; 513 battery->bat.type = POWER_SUPPLY_TYPE_BATTERY;
792 if (!acpi_battery_mode(battery)) { 514 if (!acpi_battery_mode(battery)) {
@@ -822,10 +544,6 @@ static void acpi_battery_remove(struct acpi_sbs *sbs, int id)
822 device_remove_file(battery->bat.dev, &alarm_attr); 544 device_remove_file(battery->bat.dev, &alarm_attr);
823 power_supply_unregister(&battery->bat); 545 power_supply_unregister(&battery->bat);
824 } 546 }
825#ifdef CONFIG_ACPI_PROCFS_POWER
826 proc_remove(battery->proc_entry);
827 battery->proc_entry = NULL;
828#endif
829} 547}
830 548
831static int acpi_charger_add(struct acpi_sbs *sbs) 549static int acpi_charger_add(struct acpi_sbs *sbs)
@@ -835,13 +553,7 @@ static int acpi_charger_add(struct acpi_sbs *sbs)
835 result = acpi_ac_get_present(sbs); 553 result = acpi_ac_get_present(sbs);
836 if (result) 554 if (result)
837 goto end; 555 goto end;
838#ifdef CONFIG_ACPI_PROCFS_POWER 556
839 result = acpi_sbs_add_fs(&sbs->charger_entry, acpi_ac_dir,
840 ACPI_AC_DIR_NAME, NULL,
841 &acpi_ac_state_fops, NULL, sbs);
842 if (result)
843 goto end;
844#endif
845 sbs->charger.name = "sbs-charger"; 557 sbs->charger.name = "sbs-charger";
846 sbs->charger.type = POWER_SUPPLY_TYPE_MAINS; 558 sbs->charger.type = POWER_SUPPLY_TYPE_MAINS;
847 sbs->charger.properties = sbs_ac_props; 559 sbs->charger.properties = sbs_ac_props;
@@ -859,10 +571,6 @@ static void acpi_charger_remove(struct acpi_sbs *sbs)
859{ 571{
860 if (sbs->charger.dev) 572 if (sbs->charger.dev)
861 power_supply_unregister(&sbs->charger); 573 power_supply_unregister(&sbs->charger);
862#ifdef CONFIG_ACPI_PROCFS_POWER
863 proc_remove(sbs->charger_entry);
864 sbs->charger_entry = NULL;
865#endif
866} 574}
867 575
868static void acpi_sbs_callback(void *context) 576static void acpi_sbs_callback(void *context)
@@ -950,20 +658,6 @@ static int acpi_sbs_remove(struct acpi_device *device)
950 return 0; 658 return 0;
951} 659}
952 660
953static void acpi_sbs_rmdirs(void)
954{
955#ifdef CONFIG_ACPI_PROCFS_POWER
956 if (acpi_ac_dir) {
957 acpi_unlock_ac_dir(acpi_ac_dir);
958 acpi_ac_dir = NULL;
959 }
960 if (acpi_battery_dir) {
961 acpi_unlock_battery_dir(acpi_battery_dir);
962 acpi_battery_dir = NULL;
963 }
964#endif
965}
966
967#ifdef CONFIG_PM_SLEEP 661#ifdef CONFIG_PM_SLEEP
968static int acpi_sbs_resume(struct device *dev) 662static int acpi_sbs_resume(struct device *dev)
969{ 663{
@@ -995,28 +689,17 @@ static int __init acpi_sbs_init(void)
995 689
996 if (acpi_disabled) 690 if (acpi_disabled)
997 return -ENODEV; 691 return -ENODEV;
998#ifdef CONFIG_ACPI_PROCFS_POWER 692
999 acpi_ac_dir = acpi_lock_ac_dir();
1000 if (!acpi_ac_dir)
1001 return -ENODEV;
1002 acpi_battery_dir = acpi_lock_battery_dir();
1003 if (!acpi_battery_dir) {
1004 acpi_sbs_rmdirs();
1005 return -ENODEV;
1006 }
1007#endif
1008 result = acpi_bus_register_driver(&acpi_sbs_driver); 693 result = acpi_bus_register_driver(&acpi_sbs_driver);
1009 if (result < 0) { 694 if (result < 0)
1010 acpi_sbs_rmdirs();
1011 return -ENODEV; 695 return -ENODEV;
1012 } 696
1013 return 0; 697 return 0;
1014} 698}
1015 699
1016static void __exit acpi_sbs_exit(void) 700static void __exit acpi_sbs_exit(void)
1017{ 701{
1018 acpi_bus_unregister_driver(&acpi_sbs_driver); 702 acpi_bus_unregister_driver(&acpi_sbs_driver);
1019 acpi_sbs_rmdirs();
1020 return; 703 return;
1021} 704}
1022 705