aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/acpi
diff options
context:
space:
mode:
authorLen Brown <len.brown@intel.com>2010-10-25 02:11:49 -0400
committerLen Brown <len.brown@intel.com>2010-10-25 02:11:49 -0400
commitf3ab69a321d08ce123dce8166eabe7fddd94b949 (patch)
tree9de4e6e018cd57d4c84aa82dfbd02bf9f2800ade /drivers/acpi
parentaca209e5e654951a3a90f5aaa8e04e0c470993b4 (diff)
parent03e7c3432d40d067476eaf49ede29128b637998f (diff)
Merge branch 'procfs-cleanup-v2' into release
Diffstat (limited to 'drivers/acpi')
-rw-r--r--drivers/acpi/Kconfig11
-rw-r--r--drivers/acpi/ac.c14
-rw-r--r--drivers/acpi/battery.c21
-rw-r--r--drivers/acpi/fan.c139
-rw-r--r--drivers/acpi/pci_irq.c1
-rw-r--r--drivers/acpi/pci_link.c1
-rw-r--r--drivers/acpi/pci_root.c1
-rw-r--r--drivers/acpi/processor_driver.c20
-rw-r--r--drivers/acpi/processor_throttling.c4
-rw-r--r--drivers/acpi/sbs.c25
-rw-r--r--drivers/acpi/thermal.c436
-rw-r--r--drivers/acpi/video.c771
12 files changed, 29 insertions, 1415 deletions
diff --git a/drivers/acpi/Kconfig b/drivers/acpi/Kconfig
index 88681aca88c5..0f9de2b44c0c 100644
--- a/drivers/acpi/Kconfig
+++ b/drivers/acpi/Kconfig
@@ -66,7 +66,6 @@ config ACPI_PROCFS
66config ACPI_PROCFS_POWER 66config ACPI_PROCFS_POWER
67 bool "Deprecated power /proc/acpi directories" 67 bool "Deprecated power /proc/acpi directories"
68 depends on PROC_FS 68 depends on PROC_FS
69 default y
70 help 69 help
71 For backwards compatibility, this option allows 70 For backwards compatibility, this option allows
72 deprecated power /proc/acpi/ directories to exist, even when 71 deprecated power /proc/acpi/ directories to exist, even when
@@ -90,13 +89,6 @@ config ACPI_POWER_METER
90 To compile this driver as a module, choose M here: 89 To compile this driver as a module, choose M here:
91 the module will be called power-meter. 90 the module will be called power-meter.
92 91
93config ACPI_SYSFS_POWER
94 bool "Future power /sys interface"
95 select POWER_SUPPLY
96 default y
97 help
98 Say N to disable power /sys interface
99
100config ACPI_EC_DEBUGFS 92config ACPI_EC_DEBUGFS
101 tristate "EC read/write access through /sys/kernel/debug/ec" 93 tristate "EC read/write access through /sys/kernel/debug/ec"
102 default n 94 default n
@@ -136,6 +128,7 @@ config ACPI_PROC_EVENT
136config ACPI_AC 128config ACPI_AC
137 tristate "AC Adapter" 129 tristate "AC Adapter"
138 depends on X86 130 depends on X86
131 select POWER_SUPPLY
139 default y 132 default y
140 help 133 help
141 This driver supports the AC Adapter object, which indicates 134 This driver supports the AC Adapter object, which indicates
@@ -148,6 +141,7 @@ config ACPI_AC
148config ACPI_BATTERY 141config ACPI_BATTERY
149 tristate "Battery" 142 tristate "Battery"
150 depends on X86 143 depends on X86
144 select POWER_SUPPLY
151 default y 145 default y
152 help 146 help
153 This driver adds support for battery information through 147 This driver adds support for battery information through
@@ -364,6 +358,7 @@ config ACPI_HOTPLUG_MEMORY
364config ACPI_SBS 358config ACPI_SBS
365 tristate "Smart Battery System" 359 tristate "Smart Battery System"
366 depends on X86 360 depends on X86
361 select POWER_SUPPLY
367 help 362 help
368 This driver supports the Smart Battery System, another 363 This driver supports the Smart Battery System, another
369 type of access to battery information, found on some laptops. 364 type of access to battery information, found on some laptops.
diff --git a/drivers/acpi/ac.c b/drivers/acpi/ac.c
index 56205a0b85df..ba9afeaa23ac 100644
--- a/drivers/acpi/ac.c
+++ b/drivers/acpi/ac.c
@@ -32,9 +32,7 @@
32#include <linux/proc_fs.h> 32#include <linux/proc_fs.h>
33#include <linux/seq_file.h> 33#include <linux/seq_file.h>
34#endif 34#endif
35#ifdef CONFIG_ACPI_SYSFS_POWER
36#include <linux/power_supply.h> 35#include <linux/power_supply.h>
37#endif
38#include <acpi/acpi_bus.h> 36#include <acpi/acpi_bus.h>
39#include <acpi/acpi_drivers.h> 37#include <acpi/acpi_drivers.h>
40 38
@@ -86,9 +84,7 @@ static struct acpi_driver acpi_ac_driver = {
86}; 84};
87 85
88struct acpi_ac { 86struct acpi_ac {
89#ifdef CONFIG_ACPI_SYSFS_POWER
90 struct power_supply charger; 87 struct power_supply charger;
91#endif
92 struct acpi_device * device; 88 struct acpi_device * device;
93 unsigned long long state; 89 unsigned long long state;
94}; 90};
@@ -104,7 +100,6 @@ static const struct file_operations acpi_ac_fops = {
104 .release = single_release, 100 .release = single_release,
105}; 101};
106#endif 102#endif
107#ifdef CONFIG_ACPI_SYSFS_POWER
108static int get_ac_property(struct power_supply *psy, 103static int get_ac_property(struct power_supply *psy,
109 enum power_supply_property psp, 104 enum power_supply_property psp,
110 union power_supply_propval *val) 105 union power_supply_propval *val)
@@ -123,7 +118,6 @@ static int get_ac_property(struct power_supply *psy,
123static enum power_supply_property ac_props[] = { 118static enum power_supply_property ac_props[] = {
124 POWER_SUPPLY_PROP_ONLINE, 119 POWER_SUPPLY_PROP_ONLINE,
125}; 120};
126#endif
127/* -------------------------------------------------------------------------- 121/* --------------------------------------------------------------------------
128 AC Adapter Management 122 AC Adapter Management
129 -------------------------------------------------------------------------- */ 123 -------------------------------------------------------------------------- */
@@ -247,9 +241,7 @@ static void acpi_ac_notify(struct acpi_device *device, u32 event)
247 dev_name(&device->dev), event, 241 dev_name(&device->dev), event,
248 (u32) ac->state); 242 (u32) ac->state);
249 acpi_notifier_call_chain(device, event, (u32) ac->state); 243 acpi_notifier_call_chain(device, event, (u32) ac->state);
250#ifdef CONFIG_ACPI_SYSFS_POWER
251 kobject_uevent(&ac->charger.dev->kobj, KOBJ_CHANGE); 244 kobject_uevent(&ac->charger.dev->kobj, KOBJ_CHANGE);
252#endif
253 } 245 }
254 246
255 return; 247 return;
@@ -282,14 +274,12 @@ static int acpi_ac_add(struct acpi_device *device)
282#endif 274#endif
283 if (result) 275 if (result)
284 goto end; 276 goto end;
285#ifdef CONFIG_ACPI_SYSFS_POWER
286 ac->charger.name = acpi_device_bid(device); 277 ac->charger.name = acpi_device_bid(device);
287 ac->charger.type = POWER_SUPPLY_TYPE_MAINS; 278 ac->charger.type = POWER_SUPPLY_TYPE_MAINS;
288 ac->charger.properties = ac_props; 279 ac->charger.properties = ac_props;
289 ac->charger.num_properties = ARRAY_SIZE(ac_props); 280 ac->charger.num_properties = ARRAY_SIZE(ac_props);
290 ac->charger.get_property = get_ac_property; 281 ac->charger.get_property = get_ac_property;
291 power_supply_register(&ac->device->dev, &ac->charger); 282 power_supply_register(&ac->device->dev, &ac->charger);
292#endif
293 283
294 printk(KERN_INFO PREFIX "%s [%s] (%s)\n", 284 printk(KERN_INFO PREFIX "%s [%s] (%s)\n",
295 acpi_device_name(device), acpi_device_bid(device), 285 acpi_device_name(device), acpi_device_bid(device),
@@ -316,10 +306,8 @@ static int acpi_ac_resume(struct acpi_device *device)
316 old_state = ac->state; 306 old_state = ac->state;
317 if (acpi_ac_get_state(ac)) 307 if (acpi_ac_get_state(ac))
318 return 0; 308 return 0;
319#ifdef CONFIG_ACPI_SYSFS_POWER
320 if (old_state != ac->state) 309 if (old_state != ac->state)
321 kobject_uevent(&ac->charger.dev->kobj, KOBJ_CHANGE); 310 kobject_uevent(&ac->charger.dev->kobj, KOBJ_CHANGE);
322#endif
323 return 0; 311 return 0;
324} 312}
325 313
@@ -333,10 +321,8 @@ static int acpi_ac_remove(struct acpi_device *device, int type)
333 321
334 ac = acpi_driver_data(device); 322 ac = acpi_driver_data(device);
335 323
336#ifdef CONFIG_ACPI_SYSFS_POWER
337 if (ac->charger.dev) 324 if (ac->charger.dev)
338 power_supply_unregister(&ac->charger); 325 power_supply_unregister(&ac->charger);
339#endif
340#ifdef CONFIG_ACPI_PROCFS_POWER 326#ifdef CONFIG_ACPI_PROCFS_POWER
341 acpi_ac_remove_fs(device); 327 acpi_ac_remove_fs(device);
342#endif 328#endif
diff --git a/drivers/acpi/battery.c b/drivers/acpi/battery.c
index 98417201e9ce..7b8787b490f6 100644
--- a/drivers/acpi/battery.c
+++ b/drivers/acpi/battery.c
@@ -42,10 +42,7 @@
42 42
43#include <acpi/acpi_bus.h> 43#include <acpi/acpi_bus.h>
44#include <acpi/acpi_drivers.h> 44#include <acpi/acpi_drivers.h>
45
46#ifdef CONFIG_ACPI_SYSFS_POWER
47#include <linux/power_supply.h> 45#include <linux/power_supply.h>
48#endif
49 46
50#define PREFIX "ACPI: " 47#define PREFIX "ACPI: "
51 48
@@ -102,9 +99,7 @@ enum {
102 99
103struct acpi_battery { 100struct acpi_battery {
104 struct mutex lock; 101 struct mutex lock;
105#ifdef CONFIG_ACPI_SYSFS_POWER
106 struct power_supply bat; 102 struct power_supply bat;
107#endif
108 struct acpi_device *device; 103 struct acpi_device *device;
109 unsigned long update_time; 104 unsigned long update_time;
110 int rate_now; 105 int rate_now;
@@ -141,7 +136,6 @@ inline int acpi_battery_present(struct acpi_battery *battery)
141 return battery->device->status.battery_present; 136 return battery->device->status.battery_present;
142} 137}
143 138
144#ifdef CONFIG_ACPI_SYSFS_POWER
145static int acpi_battery_technology(struct acpi_battery *battery) 139static int acpi_battery_technology(struct acpi_battery *battery)
146{ 140{
147 if (!strcasecmp("NiCd", battery->type)) 141 if (!strcasecmp("NiCd", battery->type))
@@ -281,7 +275,6 @@ static enum power_supply_property energy_battery_props[] = {
281 POWER_SUPPLY_PROP_MANUFACTURER, 275 POWER_SUPPLY_PROP_MANUFACTURER,
282 POWER_SUPPLY_PROP_SERIAL_NUMBER, 276 POWER_SUPPLY_PROP_SERIAL_NUMBER,
283}; 277};
284#endif
285 278
286#ifdef CONFIG_ACPI_PROCFS_POWER 279#ifdef CONFIG_ACPI_PROCFS_POWER
287inline char *acpi_battery_units(struct acpi_battery *battery) 280inline char *acpi_battery_units(struct acpi_battery *battery)
@@ -492,7 +485,6 @@ static int acpi_battery_init_alarm(struct acpi_battery *battery)
492 return acpi_battery_set_alarm(battery); 485 return acpi_battery_set_alarm(battery);
493} 486}
494 487
495#ifdef CONFIG_ACPI_SYSFS_POWER
496static ssize_t acpi_battery_alarm_show(struct device *dev, 488static ssize_t acpi_battery_alarm_show(struct device *dev,
497 struct device_attribute *attr, 489 struct device_attribute *attr,
498 char *buf) 490 char *buf)
@@ -552,7 +544,6 @@ static void sysfs_remove_battery(struct acpi_battery *battery)
552 power_supply_unregister(&battery->bat); 544 power_supply_unregister(&battery->bat);
553 battery->bat.dev = NULL; 545 battery->bat.dev = NULL;
554} 546}
555#endif
556 547
557static void acpi_battery_quirks(struct acpi_battery *battery) 548static void acpi_battery_quirks(struct acpi_battery *battery)
558{ 549{
@@ -568,9 +559,7 @@ static int acpi_battery_update(struct acpi_battery *battery)
568 if (result) 559 if (result)
569 return result; 560 return result;
570 if (!acpi_battery_present(battery)) { 561 if (!acpi_battery_present(battery)) {
571#ifdef CONFIG_ACPI_SYSFS_POWER
572 sysfs_remove_battery(battery); 562 sysfs_remove_battery(battery);
573#endif
574 battery->update_time = 0; 563 battery->update_time = 0;
575 return 0; 564 return 0;
576 } 565 }
@@ -582,10 +571,8 @@ static int acpi_battery_update(struct acpi_battery *battery)
582 acpi_battery_quirks(battery); 571 acpi_battery_quirks(battery);
583 acpi_battery_init_alarm(battery); 572 acpi_battery_init_alarm(battery);
584 } 573 }
585#ifdef CONFIG_ACPI_SYSFS_POWER
586 if (!battery->bat.dev) 574 if (!battery->bat.dev)
587 sysfs_add_battery(battery); 575 sysfs_add_battery(battery);
588#endif
589 return acpi_battery_get_state(battery); 576 return acpi_battery_get_state(battery);
590} 577}
591 578
@@ -867,26 +854,20 @@ static void acpi_battery_remove_fs(struct acpi_device *device)
867static void acpi_battery_notify(struct acpi_device *device, u32 event) 854static void acpi_battery_notify(struct acpi_device *device, u32 event)
868{ 855{
869 struct acpi_battery *battery = acpi_driver_data(device); 856 struct acpi_battery *battery = acpi_driver_data(device);
870#ifdef CONFIG_ACPI_SYSFS_POWER
871 struct device *old; 857 struct device *old;
872#endif
873 858
874 if (!battery) 859 if (!battery)
875 return; 860 return;
876#ifdef CONFIG_ACPI_SYSFS_POWER
877 old = battery->bat.dev; 861 old = battery->bat.dev;
878#endif
879 acpi_battery_update(battery); 862 acpi_battery_update(battery);
880 acpi_bus_generate_proc_event(device, event, 863 acpi_bus_generate_proc_event(device, event,
881 acpi_battery_present(battery)); 864 acpi_battery_present(battery));
882 acpi_bus_generate_netlink_event(device->pnp.device_class, 865 acpi_bus_generate_netlink_event(device->pnp.device_class,
883 dev_name(&device->dev), event, 866 dev_name(&device->dev), event,
884 acpi_battery_present(battery)); 867 acpi_battery_present(battery));
885#ifdef CONFIG_ACPI_SYSFS_POWER
886 /* acpi_battery_update could remove power_supply object */ 868 /* acpi_battery_update could remove power_supply object */
887 if (old && battery->bat.dev) 869 if (old && battery->bat.dev)
888 power_supply_changed(&battery->bat); 870 power_supply_changed(&battery->bat);
889#endif
890} 871}
891 872
892static int acpi_battery_add(struct acpi_device *device) 873static int acpi_battery_add(struct acpi_device *device)
@@ -934,9 +915,7 @@ static int acpi_battery_remove(struct acpi_device *device, int type)
934#ifdef CONFIG_ACPI_PROCFS_POWER 915#ifdef CONFIG_ACPI_PROCFS_POWER
935 acpi_battery_remove_fs(device); 916 acpi_battery_remove_fs(device);
936#endif 917#endif
937#ifdef CONFIG_ACPI_SYSFS_POWER
938 sysfs_remove_battery(battery); 918 sysfs_remove_battery(battery);
939#endif
940 mutex_destroy(&battery->lock); 919 mutex_destroy(&battery->lock);
941 kfree(battery); 920 kfree(battery);
942 return 0; 921 return 0;
diff --git a/drivers/acpi/fan.c b/drivers/acpi/fan.c
index d94d2953c974..60049080c869 100644
--- a/drivers/acpi/fan.c
+++ b/drivers/acpi/fan.c
@@ -27,8 +27,6 @@
27#include <linux/module.h> 27#include <linux/module.h>
28#include <linux/init.h> 28#include <linux/init.h>
29#include <linux/types.h> 29#include <linux/types.h>
30#include <linux/proc_fs.h>
31#include <linux/seq_file.h>
32#include <asm/uaccess.h> 30#include <asm/uaccess.h>
33#include <linux/thermal.h> 31#include <linux/thermal.h>
34#include <acpi/acpi_bus.h> 32#include <acpi/acpi_bus.h>
@@ -119,122 +117,6 @@ static struct thermal_cooling_device_ops fan_cooling_ops = {
119}; 117};
120 118
121/* -------------------------------------------------------------------------- 119/* --------------------------------------------------------------------------
122 FS Interface (/proc)
123 -------------------------------------------------------------------------- */
124#ifdef CONFIG_ACPI_PROCFS
125
126static struct proc_dir_entry *acpi_fan_dir;
127
128static int acpi_fan_read_state(struct seq_file *seq, void *offset)
129{
130 struct acpi_device *device = seq->private;
131 int state = 0;
132
133
134 if (device) {
135 if (acpi_bus_get_power(device->handle, &state))
136 seq_printf(seq, "status: ERROR\n");
137 else
138 seq_printf(seq, "status: %s\n",
139 !state ? "on" : "off");
140 }
141 return 0;
142}
143
144static int acpi_fan_state_open_fs(struct inode *inode, struct file *file)
145{
146 return single_open(file, acpi_fan_read_state, PDE(inode)->data);
147}
148
149static ssize_t
150acpi_fan_write_state(struct file *file, const char __user * buffer,
151 size_t count, loff_t * ppos)
152{
153 int result = 0;
154 struct seq_file *m = file->private_data;
155 struct acpi_device *device = m->private;
156 char state_string[3] = { '\0' };
157
158 if (count > sizeof(state_string) - 1)
159 return -EINVAL;
160
161 if (copy_from_user(state_string, buffer, count))
162 return -EFAULT;
163
164 state_string[count] = '\0';
165 if ((state_string[0] < '0') || (state_string[0] > '3'))
166 return -EINVAL;
167 if (state_string[1] == '\n')
168 state_string[1] = '\0';
169 if (state_string[1] != '\0')
170 return -EINVAL;
171
172 result = acpi_bus_set_power(device->handle,
173 simple_strtoul(state_string, NULL, 0));
174 if (result)
175 return result;
176
177 return count;
178}
179
180static const struct file_operations acpi_fan_state_ops = {
181 .open = acpi_fan_state_open_fs,
182 .read = seq_read,
183 .write = acpi_fan_write_state,
184 .llseek = seq_lseek,
185 .release = single_release,
186 .owner = THIS_MODULE,
187};
188
189static int acpi_fan_add_fs(struct acpi_device *device)
190{
191 struct proc_dir_entry *entry = NULL;
192
193
194 if (!device)
195 return -EINVAL;
196
197 if (!acpi_device_dir(device)) {
198 acpi_device_dir(device) = proc_mkdir(acpi_device_bid(device),
199 acpi_fan_dir);
200 if (!acpi_device_dir(device))
201 return -ENODEV;
202 }
203
204 /* 'status' [R/W] */
205 entry = proc_create_data(ACPI_FAN_FILE_STATE,
206 S_IFREG | S_IRUGO | S_IWUSR,
207 acpi_device_dir(device),
208 &acpi_fan_state_ops,
209 device);
210 if (!entry)
211 return -ENODEV;
212 return 0;
213}
214
215static int acpi_fan_remove_fs(struct acpi_device *device)
216{
217
218 if (acpi_device_dir(device)) {
219 remove_proc_entry(ACPI_FAN_FILE_STATE, acpi_device_dir(device));
220 remove_proc_entry(acpi_device_bid(device), acpi_fan_dir);
221 acpi_device_dir(device) = NULL;
222 }
223
224 return 0;
225}
226#else
227static int acpi_fan_add_fs(struct acpi_device *device)
228{
229 return 0;
230}
231
232static int acpi_fan_remove_fs(struct acpi_device *device)
233{
234 return 0;
235}
236#endif
237/* --------------------------------------------------------------------------
238 Driver Interface 120 Driver Interface
239 -------------------------------------------------------------------------- */ 121 -------------------------------------------------------------------------- */
240 122
@@ -284,10 +166,6 @@ static int acpi_fan_add(struct acpi_device *device)
284 dev_err(&device->dev, "Failed to create sysfs link " 166 dev_err(&device->dev, "Failed to create sysfs link "
285 "'device'\n"); 167 "'device'\n");
286 168
287 result = acpi_fan_add_fs(device);
288 if (result)
289 goto end;
290
291 printk(KERN_INFO PREFIX "%s [%s] (%s)\n", 169 printk(KERN_INFO PREFIX "%s [%s] (%s)\n",
292 acpi_device_name(device), acpi_device_bid(device), 170 acpi_device_name(device), acpi_device_bid(device),
293 !device->power.state ? "on" : "off"); 171 !device->power.state ? "on" : "off");
@@ -303,7 +181,6 @@ static int acpi_fan_remove(struct acpi_device *device, int type)
303 if (!device || !cdev) 181 if (!device || !cdev)
304 return -EINVAL; 182 return -EINVAL;
305 183
306 acpi_fan_remove_fs(device);
307 sysfs_remove_link(&device->dev.kobj, "thermal_cooling"); 184 sysfs_remove_link(&device->dev.kobj, "thermal_cooling");
308 sysfs_remove_link(&cdev->device.kobj, "device"); 185 sysfs_remove_link(&cdev->device.kobj, "device");
309 thermal_cooling_device_unregister(cdev); 186 thermal_cooling_device_unregister(cdev);
@@ -347,19 +224,9 @@ static int __init acpi_fan_init(void)
347{ 224{
348 int result = 0; 225 int result = 0;
349 226
350#ifdef CONFIG_ACPI_PROCFS
351 acpi_fan_dir = proc_mkdir(ACPI_FAN_CLASS, acpi_root_dir);
352 if (!acpi_fan_dir)
353 return -ENODEV;
354#endif
355
356 result = acpi_bus_register_driver(&acpi_fan_driver); 227 result = acpi_bus_register_driver(&acpi_fan_driver);
357 if (result < 0) { 228 if (result < 0)
358#ifdef CONFIG_ACPI_PROCFS
359 remove_proc_entry(ACPI_FAN_CLASS, acpi_root_dir);
360#endif
361 return -ENODEV; 229 return -ENODEV;
362 }
363 230
364 return 0; 231 return 0;
365} 232}
@@ -369,10 +236,6 @@ static void __exit acpi_fan_exit(void)
369 236
370 acpi_bus_unregister_driver(&acpi_fan_driver); 237 acpi_bus_unregister_driver(&acpi_fan_driver);
371 238
372#ifdef CONFIG_ACPI_PROCFS
373 remove_proc_entry(ACPI_FAN_CLASS, acpi_root_dir);
374#endif
375
376 return; 239 return;
377} 240}
378 241
diff --git a/drivers/acpi/pci_irq.c b/drivers/acpi/pci_irq.c
index e4804fb05e23..f907cfbfa13c 100644
--- a/drivers/acpi/pci_irq.c
+++ b/drivers/acpi/pci_irq.c
@@ -32,7 +32,6 @@
32#include <linux/module.h> 32#include <linux/module.h>
33#include <linux/init.h> 33#include <linux/init.h>
34#include <linux/types.h> 34#include <linux/types.h>
35#include <linux/proc_fs.h>
36#include <linux/spinlock.h> 35#include <linux/spinlock.h>
37#include <linux/pm.h> 36#include <linux/pm.h>
38#include <linux/pci.h> 37#include <linux/pci.h>
diff --git a/drivers/acpi/pci_link.c b/drivers/acpi/pci_link.c
index 8d47a5846aeb..9ff80a7e9f6a 100644
--- a/drivers/acpi/pci_link.c
+++ b/drivers/acpi/pci_link.c
@@ -34,7 +34,6 @@
34#include <linux/module.h> 34#include <linux/module.h>
35#include <linux/init.h> 35#include <linux/init.h>
36#include <linux/types.h> 36#include <linux/types.h>
37#include <linux/proc_fs.h>
38#include <linux/spinlock.h> 37#include <linux/spinlock.h>
39#include <linux/pm.h> 38#include <linux/pm.h>
40#include <linux/pci.h> 39#include <linux/pci.h>
diff --git a/drivers/acpi/pci_root.c b/drivers/acpi/pci_root.c
index 3ba8d1f44a73..96668ad09622 100644
--- a/drivers/acpi/pci_root.c
+++ b/drivers/acpi/pci_root.c
@@ -27,7 +27,6 @@
27#include <linux/module.h> 27#include <linux/module.h>
28#include <linux/init.h> 28#include <linux/init.h>
29#include <linux/types.h> 29#include <linux/types.h>
30#include <linux/proc_fs.h>
31#include <linux/spinlock.h> 30#include <linux/spinlock.h>
32#include <linux/pm.h> 31#include <linux/pm.h>
33#include <linux/pm_runtime.h> 32#include <linux/pm_runtime.h>
diff --git a/drivers/acpi/processor_driver.c b/drivers/acpi/processor_driver.c
index 347eb21b2353..356c320bdd08 100644
--- a/drivers/acpi/processor_driver.c
+++ b/drivers/acpi/processor_driver.c
@@ -40,8 +40,10 @@
40#include <linux/pm.h> 40#include <linux/pm.h>
41#include <linux/cpufreq.h> 41#include <linux/cpufreq.h>
42#include <linux/cpu.h> 42#include <linux/cpu.h>
43#ifdef CONFIG_ACPI_PROCFS
43#include <linux/proc_fs.h> 44#include <linux/proc_fs.h>
44#include <linux/seq_file.h> 45#include <linux/seq_file.h>
46#endif
45#include <linux/dmi.h> 47#include <linux/dmi.h>
46#include <linux/moduleparam.h> 48#include <linux/moduleparam.h>
47#include <linux/cpuidle.h> 49#include <linux/cpuidle.h>
@@ -244,6 +246,7 @@ static int acpi_processor_errata(struct acpi_processor *pr)
244 return result; 246 return result;
245} 247}
246 248
249#ifdef CONFIG_ACPI_PROCFS
247static struct proc_dir_entry *acpi_processor_dir = NULL; 250static struct proc_dir_entry *acpi_processor_dir = NULL;
248 251
249static int __cpuinit acpi_processor_add_fs(struct acpi_device *device) 252static int __cpuinit acpi_processor_add_fs(struct acpi_device *device)
@@ -280,7 +283,16 @@ static int acpi_processor_remove_fs(struct acpi_device *device)
280 283
281 return 0; 284 return 0;
282} 285}
283 286#else
287static inline int acpi_processor_add_fs(struct acpi_device *device)
288{
289 return 0;
290}
291static inline int acpi_processor_remove_fs(struct acpi_device *device)
292{
293 return 0;
294}
295#endif
284/* -------------------------------------------------------------------------- 296/* --------------------------------------------------------------------------
285 Driver Interface 297 Driver Interface
286 -------------------------------------------------------------------------- */ 298 -------------------------------------------------------------------------- */
@@ -842,9 +854,11 @@ static int __init acpi_processor_init(void)
842 854
843 memset(&errata, 0, sizeof(errata)); 855 memset(&errata, 0, sizeof(errata));
844 856
857#ifdef CONFIG_ACPI_PROCFS
845 acpi_processor_dir = proc_mkdir(ACPI_PROCESSOR_CLASS, acpi_root_dir); 858 acpi_processor_dir = proc_mkdir(ACPI_PROCESSOR_CLASS, acpi_root_dir);
846 if (!acpi_processor_dir) 859 if (!acpi_processor_dir)
847 return -ENOMEM; 860 return -ENOMEM;
861#endif
848 862
849 if (!cpuidle_register_driver(&acpi_idle_driver)) { 863 if (!cpuidle_register_driver(&acpi_idle_driver)) {
850 printk(KERN_DEBUG "ACPI: %s registered with cpuidle\n", 864 printk(KERN_DEBUG "ACPI: %s registered with cpuidle\n",
@@ -871,7 +885,9 @@ static int __init acpi_processor_init(void)
871out_cpuidle: 885out_cpuidle:
872 cpuidle_unregister_driver(&acpi_idle_driver); 886 cpuidle_unregister_driver(&acpi_idle_driver);
873 887
888#ifdef CONFIG_ACPI_PROCFS
874 remove_proc_entry(ACPI_PROCESSOR_CLASS, acpi_root_dir); 889 remove_proc_entry(ACPI_PROCESSOR_CLASS, acpi_root_dir);
890#endif
875 891
876 return result; 892 return result;
877} 893}
@@ -891,7 +907,9 @@ static void __exit acpi_processor_exit(void)
891 907
892 cpuidle_unregister_driver(&acpi_idle_driver); 908 cpuidle_unregister_driver(&acpi_idle_driver);
893 909
910#ifdef CONFIG_ACPI_PROCFS
894 remove_proc_entry(ACPI_PROCESSOR_CLASS, acpi_root_dir); 911 remove_proc_entry(ACPI_PROCESSOR_CLASS, acpi_root_dir);
912#endif
895 913
896 return; 914 return;
897} 915}
diff --git a/drivers/acpi/processor_throttling.c b/drivers/acpi/processor_throttling.c
index 730863855ed5..ff3632717c51 100644
--- a/drivers/acpi/processor_throttling.c
+++ b/drivers/acpi/processor_throttling.c
@@ -32,8 +32,10 @@
32#include <linux/init.h> 32#include <linux/init.h>
33#include <linux/sched.h> 33#include <linux/sched.h>
34#include <linux/cpufreq.h> 34#include <linux/cpufreq.h>
35#ifdef CONFIG_ACPI_PROCFS
35#include <linux/proc_fs.h> 36#include <linux/proc_fs.h>
36#include <linux/seq_file.h> 37#include <linux/seq_file.h>
38#endif
37 39
38#include <asm/io.h> 40#include <asm/io.h>
39#include <asm/uaccess.h> 41#include <asm/uaccess.h>
@@ -1214,6 +1216,7 @@ int acpi_processor_get_throttling_info(struct acpi_processor *pr)
1214 return result; 1216 return result;
1215} 1217}
1216 1218
1219#ifdef CONFIG_ACPI_PROCFS
1217/* proc interface */ 1220/* proc interface */
1218static int acpi_processor_throttling_seq_show(struct seq_file *seq, 1221static int acpi_processor_throttling_seq_show(struct seq_file *seq,
1219 void *offset) 1222 void *offset)
@@ -1322,3 +1325,4 @@ const struct file_operations acpi_processor_throttling_fops = {
1322 .llseek = seq_lseek, 1325 .llseek = seq_lseek,
1323 .release = single_release, 1326 .release = single_release,
1324}; 1327};
1328#endif
diff --git a/drivers/acpi/sbs.c b/drivers/acpi/sbs.c
index 4ff76e8174eb..e5dbedb16bbf 100644
--- a/drivers/acpi/sbs.c
+++ b/drivers/acpi/sbs.c
@@ -40,10 +40,7 @@
40#include <linux/timer.h> 40#include <linux/timer.h>
41#include <linux/jiffies.h> 41#include <linux/jiffies.h>
42#include <linux/delay.h> 42#include <linux/delay.h>
43
44#ifdef CONFIG_ACPI_SYSFS_POWER
45#include <linux/power_supply.h> 43#include <linux/power_supply.h>
46#endif
47 44
48#include "sbshc.h" 45#include "sbshc.h"
49 46
@@ -85,9 +82,7 @@ static const struct acpi_device_id sbs_device_ids[] = {
85MODULE_DEVICE_TABLE(acpi, sbs_device_ids); 82MODULE_DEVICE_TABLE(acpi, sbs_device_ids);
86 83
87struct acpi_battery { 84struct acpi_battery {
88#ifdef CONFIG_ACPI_SYSFS_POWER
89 struct power_supply bat; 85 struct power_supply bat;
90#endif
91 struct acpi_sbs *sbs; 86 struct acpi_sbs *sbs;
92#ifdef CONFIG_ACPI_PROCFS_POWER 87#ifdef CONFIG_ACPI_PROCFS_POWER
93 struct proc_dir_entry *proc_entry; 88 struct proc_dir_entry *proc_entry;
@@ -120,9 +115,7 @@ struct acpi_battery {
120#define to_acpi_battery(x) container_of(x, struct acpi_battery, bat); 115#define to_acpi_battery(x) container_of(x, struct acpi_battery, bat);
121 116
122struct acpi_sbs { 117struct acpi_sbs {
123#ifdef CONFIG_ACPI_SYSFS_POWER
124 struct power_supply charger; 118 struct power_supply charger;
125#endif
126 struct acpi_device *device; 119 struct acpi_device *device;
127 struct acpi_smb_hc *hc; 120 struct acpi_smb_hc *hc;
128 struct mutex lock; 121 struct mutex lock;
@@ -166,7 +159,6 @@ static inline int acpi_battery_scale(struct acpi_battery *battery)
166 acpi_battery_ipscale(battery); 159 acpi_battery_ipscale(battery);
167} 160}
168 161
169#ifdef CONFIG_ACPI_SYSFS_POWER
170static int sbs_get_ac_property(struct power_supply *psy, 162static int sbs_get_ac_property(struct power_supply *psy,
171 enum power_supply_property psp, 163 enum power_supply_property psp,
172 union power_supply_propval *val) 164 union power_supply_propval *val)
@@ -313,7 +305,6 @@ static enum power_supply_property sbs_energy_battery_props[] = {
313 POWER_SUPPLY_PROP_MANUFACTURER, 305 POWER_SUPPLY_PROP_MANUFACTURER,
314}; 306};
315 307
316#endif
317 308
318/* -------------------------------------------------------------------------- 309/* --------------------------------------------------------------------------
319 Smart Battery System Management 310 Smart Battery System Management
@@ -449,7 +440,6 @@ static int acpi_ac_get_present(struct acpi_sbs *sbs)
449 return result; 440 return result;
450} 441}
451 442
452#ifdef CONFIG_ACPI_SYSFS_POWER
453static ssize_t acpi_battery_alarm_show(struct device *dev, 443static ssize_t acpi_battery_alarm_show(struct device *dev,
454 struct device_attribute *attr, 444 struct device_attribute *attr,
455 char *buf) 445 char *buf)
@@ -479,7 +469,6 @@ static struct device_attribute alarm_attr = {
479 .show = acpi_battery_alarm_show, 469 .show = acpi_battery_alarm_show,
480 .store = acpi_battery_alarm_store, 470 .store = acpi_battery_alarm_store,
481}; 471};
482#endif
483 472
484/* -------------------------------------------------------------------------- 473/* --------------------------------------------------------------------------
485 FS Interface (/proc/acpi) 474 FS Interface (/proc/acpi)
@@ -798,7 +787,6 @@ static int acpi_battery_add(struct acpi_sbs *sbs, int id)
798 &acpi_battery_state_fops, &acpi_battery_alarm_fops, 787 &acpi_battery_state_fops, &acpi_battery_alarm_fops,
799 battery); 788 battery);
800#endif 789#endif
801#ifdef CONFIG_ACPI_SYSFS_POWER
802 battery->bat.name = battery->name; 790 battery->bat.name = battery->name;
803 battery->bat.type = POWER_SUPPLY_TYPE_BATTERY; 791 battery->bat.type = POWER_SUPPLY_TYPE_BATTERY;
804 if (!acpi_battery_mode(battery)) { 792 if (!acpi_battery_mode(battery)) {
@@ -819,7 +807,6 @@ static int acpi_battery_add(struct acpi_sbs *sbs, int id)
819 goto end; 807 goto end;
820 battery->have_sysfs_alarm = 1; 808 battery->have_sysfs_alarm = 1;
821 end: 809 end:
822#endif
823 printk(KERN_INFO PREFIX "%s [%s]: Battery Slot [%s] (battery %s)\n", 810 printk(KERN_INFO PREFIX "%s [%s]: Battery Slot [%s] (battery %s)\n",
824 ACPI_SBS_DEVICE_NAME, acpi_device_bid(sbs->device), 811 ACPI_SBS_DEVICE_NAME, acpi_device_bid(sbs->device),
825 battery->name, battery->present ? "present" : "absent"); 812 battery->name, battery->present ? "present" : "absent");
@@ -828,17 +815,13 @@ static int acpi_battery_add(struct acpi_sbs *sbs, int id)
828 815
829static void acpi_battery_remove(struct acpi_sbs *sbs, int id) 816static void acpi_battery_remove(struct acpi_sbs *sbs, int id)
830{ 817{
831#if defined(CONFIG_ACPI_SYSFS_POWER) || defined(CONFIG_ACPI_PROCFS_POWER)
832 struct acpi_battery *battery = &sbs->battery[id]; 818 struct acpi_battery *battery = &sbs->battery[id];
833#endif
834 819
835#ifdef CONFIG_ACPI_SYSFS_POWER
836 if (battery->bat.dev) { 820 if (battery->bat.dev) {
837 if (battery->have_sysfs_alarm) 821 if (battery->have_sysfs_alarm)
838 device_remove_file(battery->bat.dev, &alarm_attr); 822 device_remove_file(battery->bat.dev, &alarm_attr);
839 power_supply_unregister(&battery->bat); 823 power_supply_unregister(&battery->bat);
840 } 824 }
841#endif
842#ifdef CONFIG_ACPI_PROCFS_POWER 825#ifdef CONFIG_ACPI_PROCFS_POWER
843 if (battery->proc_entry) 826 if (battery->proc_entry)
844 acpi_sbs_remove_fs(&battery->proc_entry, acpi_battery_dir); 827 acpi_sbs_remove_fs(&battery->proc_entry, acpi_battery_dir);
@@ -859,14 +842,12 @@ static int acpi_charger_add(struct acpi_sbs *sbs)
859 if (result) 842 if (result)
860 goto end; 843 goto end;
861#endif 844#endif
862#ifdef CONFIG_ACPI_SYSFS_POWER
863 sbs->charger.name = "sbs-charger"; 845 sbs->charger.name = "sbs-charger";
864 sbs->charger.type = POWER_SUPPLY_TYPE_MAINS; 846 sbs->charger.type = POWER_SUPPLY_TYPE_MAINS;
865 sbs->charger.properties = sbs_ac_props; 847 sbs->charger.properties = sbs_ac_props;
866 sbs->charger.num_properties = ARRAY_SIZE(sbs_ac_props); 848 sbs->charger.num_properties = ARRAY_SIZE(sbs_ac_props);
867 sbs->charger.get_property = sbs_get_ac_property; 849 sbs->charger.get_property = sbs_get_ac_property;
868 power_supply_register(&sbs->device->dev, &sbs->charger); 850 power_supply_register(&sbs->device->dev, &sbs->charger);
869#endif
870 printk(KERN_INFO PREFIX "%s [%s]: AC Adapter [%s] (%s)\n", 851 printk(KERN_INFO PREFIX "%s [%s]: AC Adapter [%s] (%s)\n",
871 ACPI_SBS_DEVICE_NAME, acpi_device_bid(sbs->device), 852 ACPI_SBS_DEVICE_NAME, acpi_device_bid(sbs->device),
872 ACPI_AC_DIR_NAME, sbs->charger_present ? "on-line" : "off-line"); 853 ACPI_AC_DIR_NAME, sbs->charger_present ? "on-line" : "off-line");
@@ -876,10 +857,8 @@ static int acpi_charger_add(struct acpi_sbs *sbs)
876 857
877static void acpi_charger_remove(struct acpi_sbs *sbs) 858static void acpi_charger_remove(struct acpi_sbs *sbs)
878{ 859{
879#ifdef CONFIG_ACPI_SYSFS_POWER
880 if (sbs->charger.dev) 860 if (sbs->charger.dev)
881 power_supply_unregister(&sbs->charger); 861 power_supply_unregister(&sbs->charger);
882#endif
883#ifdef CONFIG_ACPI_PROCFS_POWER 862#ifdef CONFIG_ACPI_PROCFS_POWER
884 if (sbs->charger_entry) 863 if (sbs->charger_entry)
885 acpi_sbs_remove_fs(&sbs->charger_entry, acpi_ac_dir); 864 acpi_sbs_remove_fs(&sbs->charger_entry, acpi_ac_dir);
@@ -900,9 +879,7 @@ static void acpi_sbs_callback(void *context)
900 ACPI_SBS_NOTIFY_STATUS, 879 ACPI_SBS_NOTIFY_STATUS,
901 sbs->charger_present); 880 sbs->charger_present);
902#endif 881#endif
903#ifdef CONFIG_ACPI_SYSFS_POWER
904 kobject_uevent(&sbs->charger.dev->kobj, KOBJ_CHANGE); 882 kobject_uevent(&sbs->charger.dev->kobj, KOBJ_CHANGE);
905#endif
906 } 883 }
907 if (sbs->manager_present) { 884 if (sbs->manager_present) {
908 for (id = 0; id < MAX_SBS_BAT; ++id) { 885 for (id = 0; id < MAX_SBS_BAT; ++id) {
@@ -919,9 +896,7 @@ static void acpi_sbs_callback(void *context)
919 ACPI_SBS_NOTIFY_STATUS, 896 ACPI_SBS_NOTIFY_STATUS,
920 bat->present); 897 bat->present);
921#endif 898#endif
922#ifdef CONFIG_ACPI_SYSFS_POWER
923 kobject_uevent(&bat->bat.dev->kobj, KOBJ_CHANGE); 899 kobject_uevent(&bat->bat.dev->kobj, KOBJ_CHANGE);
924#endif
925 } 900 }
926 } 901 }
927} 902}
diff --git a/drivers/acpi/thermal.c b/drivers/acpi/thermal.c
index 2f8f17131d9f..5a27b0a31315 100644
--- a/drivers/acpi/thermal.c
+++ b/drivers/acpi/thermal.c
@@ -37,12 +37,6 @@
37#include <linux/init.h> 37#include <linux/init.h>
38#include <linux/slab.h> 38#include <linux/slab.h>
39#include <linux/types.h> 39#include <linux/types.h>
40
41#ifdef CONFIG_ACPI_PROCFS
42#include <linux/proc_fs.h>
43#include <linux/seq_file.h>
44#endif
45
46#include <linux/jiffies.h> 40#include <linux/jiffies.h>
47#include <linux/kmod.h> 41#include <linux/kmod.h>
48#include <linux/reboot.h> 42#include <linux/reboot.h>
@@ -195,61 +189,6 @@ struct acpi_thermal {
195 struct mutex lock; 189 struct mutex lock;
196}; 190};
197 191
198#ifdef CONFIG_ACPI_PROCFS
199static int acpi_thermal_state_open_fs(struct inode *inode, struct file *file);
200static int acpi_thermal_temp_open_fs(struct inode *inode, struct file *file);
201static int acpi_thermal_trip_open_fs(struct inode *inode, struct file *file);
202static int acpi_thermal_cooling_open_fs(struct inode *inode, struct file *file);
203static ssize_t acpi_thermal_write_cooling_mode(struct file *,
204 const char __user *, size_t,
205 loff_t *);
206static int acpi_thermal_polling_open_fs(struct inode *inode, struct file *file);
207static ssize_t acpi_thermal_write_polling(struct file *, const char __user *,
208 size_t, loff_t *);
209
210static const struct file_operations acpi_thermal_state_fops = {
211 .owner = THIS_MODULE,
212 .open = acpi_thermal_state_open_fs,
213 .read = seq_read,
214 .llseek = seq_lseek,
215 .release = single_release,
216};
217
218static const struct file_operations acpi_thermal_temp_fops = {
219 .owner = THIS_MODULE,
220 .open = acpi_thermal_temp_open_fs,
221 .read = seq_read,
222 .llseek = seq_lseek,
223 .release = single_release,
224};
225
226static const struct file_operations acpi_thermal_trip_fops = {
227 .owner = THIS_MODULE,
228 .open = acpi_thermal_trip_open_fs,
229 .read = seq_read,
230 .llseek = seq_lseek,
231 .release = single_release,
232};
233
234static const struct file_operations acpi_thermal_cooling_fops = {
235 .owner = THIS_MODULE,
236 .open = acpi_thermal_cooling_open_fs,
237 .read = seq_read,
238 .write = acpi_thermal_write_cooling_mode,
239 .llseek = seq_lseek,
240 .release = single_release,
241};
242
243static const struct file_operations acpi_thermal_polling_fops = {
244 .owner = THIS_MODULE,
245 .open = acpi_thermal_polling_open_fs,
246 .read = seq_read,
247 .write = acpi_thermal_write_polling,
248 .llseek = seq_lseek,
249 .release = single_release,
250};
251#endif /* CONFIG_ACPI_PROCFS*/
252
253/* -------------------------------------------------------------------------- 192/* --------------------------------------------------------------------------
254 Thermal Zone Management 193 Thermal Zone Management
255 -------------------------------------------------------------------------- */ 194 -------------------------------------------------------------------------- */
@@ -958,358 +897,6 @@ static void acpi_thermal_unregister_thermal_zone(struct acpi_thermal *tz)
958 897
959 898
960/* -------------------------------------------------------------------------- 899/* --------------------------------------------------------------------------
961 FS Interface (/proc)
962 -------------------------------------------------------------------------- */
963#ifdef CONFIG_ACPI_PROCFS
964static struct proc_dir_entry *acpi_thermal_dir;
965
966static int acpi_thermal_state_seq_show(struct seq_file *seq, void *offset)
967{
968 struct acpi_thermal *tz = seq->private;
969
970
971 if (!tz)
972 goto end;
973
974 seq_puts(seq, "state: ");
975
976 if (!tz->state.critical && !tz->state.hot && !tz->state.passive
977 && !tz->state.active)
978 seq_puts(seq, "ok\n");
979 else {
980 if (tz->state.critical)
981 seq_puts(seq, "critical ");
982 if (tz->state.hot)
983 seq_puts(seq, "hot ");
984 if (tz->state.passive)
985 seq_puts(seq, "passive ");
986 if (tz->state.active)
987 seq_printf(seq, "active[%d]", tz->state.active_index);
988 seq_puts(seq, "\n");
989 }
990
991 end:
992 return 0;
993}
994
995static int acpi_thermal_state_open_fs(struct inode *inode, struct file *file)
996{
997 return single_open(file, acpi_thermal_state_seq_show, PDE(inode)->data);
998}
999
1000static int acpi_thermal_temp_seq_show(struct seq_file *seq, void *offset)
1001{
1002 int result = 0;
1003 struct acpi_thermal *tz = seq->private;
1004
1005
1006 if (!tz)
1007 goto end;
1008
1009 result = acpi_thermal_get_temperature(tz);
1010 if (result)
1011 goto end;
1012
1013 seq_printf(seq, "temperature: %ld C\n",
1014 KELVIN_TO_CELSIUS(tz->temperature));
1015
1016 end:
1017 return 0;
1018}
1019
1020static int acpi_thermal_temp_open_fs(struct inode *inode, struct file *file)
1021{
1022 return single_open(file, acpi_thermal_temp_seq_show, PDE(inode)->data);
1023}
1024
1025static int acpi_thermal_trip_seq_show(struct seq_file *seq, void *offset)
1026{
1027 struct acpi_thermal *tz = seq->private;
1028 struct acpi_device *device;
1029 acpi_status status;
1030
1031 int i = 0;
1032 int j = 0;
1033
1034
1035 if (!tz)
1036 goto end;
1037
1038 if (tz->trips.critical.flags.valid)
1039 seq_printf(seq, "critical (S5): %ld C%s",
1040 KELVIN_TO_CELSIUS(tz->trips.critical.temperature),
1041 nocrt ? " <disabled>\n" : "\n");
1042
1043 if (tz->trips.hot.flags.valid)
1044 seq_printf(seq, "hot (S4): %ld C%s",
1045 KELVIN_TO_CELSIUS(tz->trips.hot.temperature),
1046 nocrt ? " <disabled>\n" : "\n");
1047
1048 if (tz->trips.passive.flags.valid) {
1049 seq_printf(seq,
1050 "passive: %ld C: tc1=%lu tc2=%lu tsp=%lu devices=",
1051 KELVIN_TO_CELSIUS(tz->trips.passive.temperature),
1052 tz->trips.passive.tc1, tz->trips.passive.tc2,
1053 tz->trips.passive.tsp);
1054 for (j = 0; j < tz->trips.passive.devices.count; j++) {
1055 status = acpi_bus_get_device(tz->trips.passive.devices.
1056 handles[j], &device);
1057 seq_printf(seq, "%4.4s ", status ? "" :
1058 acpi_device_bid(device));
1059 }
1060 seq_puts(seq, "\n");
1061 } else {
1062 seq_printf(seq, "passive (forced):");
1063 if (tz->thermal_zone->forced_passive)
1064 seq_printf(seq, " %i C\n",
1065 tz->thermal_zone->forced_passive / 1000);
1066 else
1067 seq_printf(seq, "<not set>\n");
1068 }
1069
1070 for (i = 0; i < ACPI_THERMAL_MAX_ACTIVE; i++) {
1071 if (!(tz->trips.active[i].flags.valid))
1072 break;
1073 seq_printf(seq, "active[%d]: %ld C: devices=",
1074 i,
1075 KELVIN_TO_CELSIUS(tz->trips.active[i].temperature));
1076 for (j = 0; j < tz->trips.active[i].devices.count; j++){
1077 status = acpi_bus_get_device(tz->trips.active[i].
1078 devices.handles[j],
1079 &device);
1080 seq_printf(seq, "%4.4s ", status ? "" :
1081 acpi_device_bid(device));
1082 }
1083 seq_puts(seq, "\n");
1084 }
1085
1086 end:
1087 return 0;
1088}
1089
1090static int acpi_thermal_trip_open_fs(struct inode *inode, struct file *file)
1091{
1092 return single_open(file, acpi_thermal_trip_seq_show, PDE(inode)->data);
1093}
1094
1095static int acpi_thermal_cooling_seq_show(struct seq_file *seq, void *offset)
1096{
1097 struct acpi_thermal *tz = seq->private;
1098
1099
1100 if (!tz)
1101 goto end;
1102
1103 if (!tz->flags.cooling_mode)
1104 seq_puts(seq, "<setting not supported>\n");
1105 else
1106 seq_puts(seq, "0 - Active; 1 - Passive\n");
1107
1108 end:
1109 return 0;
1110}
1111
1112static int acpi_thermal_cooling_open_fs(struct inode *inode, struct file *file)
1113{
1114 return single_open(file, acpi_thermal_cooling_seq_show,
1115 PDE(inode)->data);
1116}
1117
1118static ssize_t
1119acpi_thermal_write_cooling_mode(struct file *file,
1120 const char __user * buffer,
1121 size_t count, loff_t * ppos)
1122{
1123 struct seq_file *m = file->private_data;
1124 struct acpi_thermal *tz = m->private;
1125 int result = 0;
1126 char mode_string[12] = { '\0' };
1127
1128
1129 if (!tz || (count > sizeof(mode_string) - 1))
1130 return -EINVAL;
1131
1132 if (!tz->flags.cooling_mode)
1133 return -ENODEV;
1134
1135 if (copy_from_user(mode_string, buffer, count))
1136 return -EFAULT;
1137
1138 mode_string[count] = '\0';
1139
1140 result = acpi_thermal_set_cooling_mode(tz,
1141 simple_strtoul(mode_string, NULL,
1142 0));
1143 if (result)
1144 return result;
1145
1146 acpi_thermal_check(tz);
1147
1148 return count;
1149}
1150
1151static int acpi_thermal_polling_seq_show(struct seq_file *seq, void *offset)
1152{
1153 struct acpi_thermal *tz = seq->private;
1154
1155
1156 if (!tz)
1157 goto end;
1158
1159 if (!tz->thermal_zone->polling_delay) {
1160 seq_puts(seq, "<polling disabled>\n");
1161 goto end;
1162 }
1163
1164 seq_printf(seq, "polling frequency: %d seconds\n",
1165 (tz->thermal_zone->polling_delay / 1000));
1166
1167 end:
1168 return 0;
1169}
1170
1171static int acpi_thermal_polling_open_fs(struct inode *inode, struct file *file)
1172{
1173 return single_open(file, acpi_thermal_polling_seq_show,
1174 PDE(inode)->data);
1175}
1176
1177static int acpi_thermal_set_polling(struct acpi_thermal *tz, int seconds)
1178{
1179 if (!tz)
1180 return -EINVAL;
1181
1182 /* Convert value to deci-seconds */
1183 tz->polling_frequency = seconds * 10;
1184
1185 tz->thermal_zone->polling_delay = seconds * 1000;
1186
1187 if (tz->tz_enabled)
1188 thermal_zone_device_update(tz->thermal_zone);
1189
1190 ACPI_DEBUG_PRINT((ACPI_DB_INFO,
1191 "Polling frequency set to %lu seconds\n",
1192 tz->polling_frequency/10));
1193
1194 return 0;
1195}
1196
1197static ssize_t
1198acpi_thermal_write_polling(struct file *file,
1199 const char __user * buffer,
1200 size_t count, loff_t * ppos)
1201{
1202 struct seq_file *m = file->private_data;
1203 struct acpi_thermal *tz = m->private;
1204 int result = 0;
1205 char polling_string[12] = { '\0' };
1206 int seconds = 0;
1207
1208
1209 if (!tz || (count > sizeof(polling_string) - 1))
1210 return -EINVAL;
1211
1212 if (copy_from_user(polling_string, buffer, count))
1213 return -EFAULT;
1214
1215 polling_string[count] = '\0';
1216
1217 seconds = simple_strtoul(polling_string, NULL, 0);
1218
1219 result = acpi_thermal_set_polling(tz, seconds);
1220 if (result)
1221 return result;
1222
1223 acpi_thermal_check(tz);
1224
1225 return count;
1226}
1227
1228static int acpi_thermal_add_fs(struct acpi_device *device)
1229{
1230 struct proc_dir_entry *entry = NULL;
1231
1232
1233 if (!acpi_device_dir(device)) {
1234 acpi_device_dir(device) = proc_mkdir(acpi_device_bid(device),
1235 acpi_thermal_dir);
1236 if (!acpi_device_dir(device))
1237 return -ENODEV;
1238 }
1239
1240 /* 'state' [R] */
1241 entry = proc_create_data(ACPI_THERMAL_FILE_STATE,
1242 S_IRUGO, acpi_device_dir(device),
1243 &acpi_thermal_state_fops,
1244 acpi_driver_data(device));
1245 if (!entry)
1246 return -ENODEV;
1247
1248 /* 'temperature' [R] */
1249 entry = proc_create_data(ACPI_THERMAL_FILE_TEMPERATURE,
1250 S_IRUGO, acpi_device_dir(device),
1251 &acpi_thermal_temp_fops,
1252 acpi_driver_data(device));
1253 if (!entry)
1254 return -ENODEV;
1255
1256 /* 'trip_points' [R] */
1257 entry = proc_create_data(ACPI_THERMAL_FILE_TRIP_POINTS,
1258 S_IRUGO,
1259 acpi_device_dir(device),
1260 &acpi_thermal_trip_fops,
1261 acpi_driver_data(device));
1262 if (!entry)
1263 return -ENODEV;
1264
1265 /* 'cooling_mode' [R/W] */
1266 entry = proc_create_data(ACPI_THERMAL_FILE_COOLING_MODE,
1267 S_IFREG | S_IRUGO | S_IWUSR,
1268 acpi_device_dir(device),
1269 &acpi_thermal_cooling_fops,
1270 acpi_driver_data(device));
1271 if (!entry)
1272 return -ENODEV;
1273
1274 /* 'polling_frequency' [R/W] */
1275 entry = proc_create_data(ACPI_THERMAL_FILE_POLLING_FREQ,
1276 S_IFREG | S_IRUGO | S_IWUSR,
1277 acpi_device_dir(device),
1278 &acpi_thermal_polling_fops,
1279 acpi_driver_data(device));
1280 if (!entry)
1281 return -ENODEV;
1282 return 0;
1283}
1284
1285static int acpi_thermal_remove_fs(struct acpi_device *device)
1286{
1287
1288 if (acpi_device_dir(device)) {
1289 remove_proc_entry(ACPI_THERMAL_FILE_POLLING_FREQ,
1290 acpi_device_dir(device));
1291 remove_proc_entry(ACPI_THERMAL_FILE_COOLING_MODE,
1292 acpi_device_dir(device));
1293 remove_proc_entry(ACPI_THERMAL_FILE_TRIP_POINTS,
1294 acpi_device_dir(device));
1295 remove_proc_entry(ACPI_THERMAL_FILE_TEMPERATURE,
1296 acpi_device_dir(device));
1297 remove_proc_entry(ACPI_THERMAL_FILE_STATE,
1298 acpi_device_dir(device));
1299 remove_proc_entry(acpi_device_bid(device), acpi_thermal_dir);
1300 acpi_device_dir(device) = NULL;
1301 }
1302
1303 return 0;
1304}
1305#else
1306static inline int acpi_thermal_add_fs(struct acpi_device *device) { return 0; }
1307static inline int acpi_thermal_remove_fs(struct acpi_device *device)
1308{
1309 return 0;
1310}
1311#endif /* CONFIG_ACPI_PROCFS */
1312/* --------------------------------------------------------------------------
1313 Driver Interface 900 Driver Interface
1314 -------------------------------------------------------------------------- */ 901 -------------------------------------------------------------------------- */
1315 902
@@ -1428,17 +1015,11 @@ static int acpi_thermal_add(struct acpi_device *device)
1428 if (result) 1015 if (result)
1429 goto free_memory; 1016 goto free_memory;
1430 1017
1431 result = acpi_thermal_add_fs(device);
1432 if (result)
1433 goto unregister_thermal_zone;
1434
1435 printk(KERN_INFO PREFIX "%s [%s] (%ld C)\n", 1018 printk(KERN_INFO PREFIX "%s [%s] (%ld C)\n",
1436 acpi_device_name(device), acpi_device_bid(device), 1019 acpi_device_name(device), acpi_device_bid(device),
1437 KELVIN_TO_CELSIUS(tz->temperature)); 1020 KELVIN_TO_CELSIUS(tz->temperature));
1438 goto end; 1021 goto end;
1439 1022
1440unregister_thermal_zone:
1441 thermal_zone_device_unregister(tz->thermal_zone);
1442free_memory: 1023free_memory:
1443 kfree(tz); 1024 kfree(tz);
1444end: 1025end:
@@ -1454,7 +1035,6 @@ static int acpi_thermal_remove(struct acpi_device *device, int type)
1454 1035
1455 tz = acpi_driver_data(device); 1036 tz = acpi_driver_data(device);
1456 1037
1457 acpi_thermal_remove_fs(device);
1458 acpi_thermal_unregister_thermal_zone(tz); 1038 acpi_thermal_unregister_thermal_zone(tz);
1459 mutex_destroy(&tz->lock); 1039 mutex_destroy(&tz->lock);
1460 kfree(tz); 1040 kfree(tz);
@@ -1580,19 +1160,9 @@ static int __init acpi_thermal_init(void)
1580 return -ENODEV; 1160 return -ENODEV;
1581 } 1161 }
1582 1162
1583#ifdef CONFIG_ACPI_PROCFS
1584 acpi_thermal_dir = proc_mkdir(ACPI_THERMAL_CLASS, acpi_root_dir);
1585 if (!acpi_thermal_dir)
1586 return -ENODEV;
1587#endif
1588
1589 result = acpi_bus_register_driver(&acpi_thermal_driver); 1163 result = acpi_bus_register_driver(&acpi_thermal_driver);
1590 if (result < 0) { 1164 if (result < 0)
1591#ifdef CONFIG_ACPI_PROCFS
1592 remove_proc_entry(ACPI_THERMAL_CLASS, acpi_root_dir);
1593#endif
1594 return -ENODEV; 1165 return -ENODEV;
1595 }
1596 1166
1597 return 0; 1167 return 0;
1598} 1168}
@@ -1602,10 +1172,6 @@ static void __exit acpi_thermal_exit(void)
1602 1172
1603 acpi_bus_unregister_driver(&acpi_thermal_driver); 1173 acpi_bus_unregister_driver(&acpi_thermal_driver);
1604 1174
1605#ifdef CONFIG_ACPI_PROCFS
1606 remove_proc_entry(ACPI_THERMAL_CLASS, acpi_root_dir);
1607#endif
1608
1609 return; 1175 return;
1610} 1176}
1611 1177
diff --git a/drivers/acpi/video.c b/drivers/acpi/video.c
index 67dec0c675aa..5cd0228d2daa 100644
--- a/drivers/acpi/video.c
+++ b/drivers/acpi/video.c
@@ -30,8 +30,6 @@
30#include <linux/types.h> 30#include <linux/types.h>
31#include <linux/list.h> 31#include <linux/list.h>
32#include <linux/mutex.h> 32#include <linux/mutex.h>
33#include <linux/proc_fs.h>
34#include <linux/seq_file.h>
35#include <linux/input.h> 33#include <linux/input.h>
36#include <linux/backlight.h> 34#include <linux/backlight.h>
37#include <linux/thermal.h> 35#include <linux/thermal.h>
@@ -152,9 +150,6 @@ struct acpi_video_bus {
152 struct acpi_video_bus_flags flags; 150 struct acpi_video_bus_flags flags;
153 struct list_head video_device_list; 151 struct list_head video_device_list;
154 struct mutex device_list_lock; /* protects video_device_list */ 152 struct mutex device_list_lock; /* protects video_device_list */
155#ifdef CONFIG_ACPI_PROCFS
156 struct proc_dir_entry *dir;
157#endif
158 struct input_dev *input; 153 struct input_dev *input;
159 char phys[32]; /* for input device */ 154 char phys[32]; /* for input device */
160 struct notifier_block pm_nb; 155 struct notifier_block pm_nb;
@@ -210,108 +205,6 @@ struct acpi_video_device {
210 struct output_device *output_dev; 205 struct output_device *output_dev;
211}; 206};
212 207
213#ifdef CONFIG_ACPI_PROCFS
214/* bus */
215static int acpi_video_bus_info_open_fs(struct inode *inode, struct file *file);
216static const struct file_operations acpi_video_bus_info_fops = {
217 .owner = THIS_MODULE,
218 .open = acpi_video_bus_info_open_fs,
219 .read = seq_read,
220 .llseek = seq_lseek,
221 .release = single_release,
222};
223
224static int acpi_video_bus_ROM_open_fs(struct inode *inode, struct file *file);
225static const struct file_operations acpi_video_bus_ROM_fops = {
226 .owner = THIS_MODULE,
227 .open = acpi_video_bus_ROM_open_fs,
228 .read = seq_read,
229 .llseek = seq_lseek,
230 .release = single_release,
231};
232
233static int acpi_video_bus_POST_info_open_fs(struct inode *inode,
234 struct file *file);
235static const struct file_operations acpi_video_bus_POST_info_fops = {
236 .owner = THIS_MODULE,
237 .open = acpi_video_bus_POST_info_open_fs,
238 .read = seq_read,
239 .llseek = seq_lseek,
240 .release = single_release,
241};
242
243static int acpi_video_bus_POST_open_fs(struct inode *inode, struct file *file);
244static ssize_t acpi_video_bus_write_POST(struct file *file,
245 const char __user *buffer, size_t count, loff_t *data);
246static const struct file_operations acpi_video_bus_POST_fops = {
247 .owner = THIS_MODULE,
248 .open = acpi_video_bus_POST_open_fs,
249 .read = seq_read,
250 .write = acpi_video_bus_write_POST,
251 .llseek = seq_lseek,
252 .release = single_release,
253};
254
255static int acpi_video_bus_DOS_open_fs(struct inode *inode, struct file *file);
256static ssize_t acpi_video_bus_write_DOS(struct file *file,
257 const char __user *buffer, size_t count, loff_t *data);
258static const struct file_operations acpi_video_bus_DOS_fops = {
259 .owner = THIS_MODULE,
260 .open = acpi_video_bus_DOS_open_fs,
261 .read = seq_read,
262 .write = acpi_video_bus_write_DOS,
263 .llseek = seq_lseek,
264 .release = single_release,
265};
266
267/* device */
268static int acpi_video_device_info_open_fs(struct inode *inode,
269 struct file *file);
270static const struct file_operations acpi_video_device_info_fops = {
271 .owner = THIS_MODULE,
272 .open = acpi_video_device_info_open_fs,
273 .read = seq_read,
274 .llseek = seq_lseek,
275 .release = single_release,
276};
277
278static int acpi_video_device_state_open_fs(struct inode *inode,
279 struct file *file);
280static ssize_t acpi_video_device_write_state(struct file *file,
281 const char __user *buffer, size_t count, loff_t *data);
282static const struct file_operations acpi_video_device_state_fops = {
283 .owner = THIS_MODULE,
284 .open = acpi_video_device_state_open_fs,
285 .read = seq_read,
286 .write = acpi_video_device_write_state,
287 .llseek = seq_lseek,
288 .release = single_release,
289};
290
291static int acpi_video_device_brightness_open_fs(struct inode *inode,
292 struct file *file);
293static ssize_t acpi_video_device_write_brightness(struct file *file,
294 const char __user *buffer, size_t count, loff_t *data);
295static const struct file_operations acpi_video_device_brightness_fops = {
296 .owner = THIS_MODULE,
297 .open = acpi_video_device_brightness_open_fs,
298 .read = seq_read,
299 .write = acpi_video_device_write_brightness,
300 .llseek = seq_lseek,
301 .release = single_release,
302};
303
304static int acpi_video_device_EDID_open_fs(struct inode *inode,
305 struct file *file);
306static const struct file_operations acpi_video_device_EDID_fops = {
307 .owner = THIS_MODULE,
308 .open = acpi_video_device_EDID_open_fs,
309 .read = seq_read,
310 .llseek = seq_lseek,
311 .release = single_release,
312};
313#endif /* CONFIG_ACPI_PROCFS */
314
315static const char device_decode[][30] = { 208static const char device_decode[][30] = {
316 "motherboard VGA device", 209 "motherboard VGA device",
317 "PCI VGA device", 210 "PCI VGA device",
@@ -1111,646 +1004,6 @@ static int acpi_video_bus_check(struct acpi_video_bus *video)
1111} 1004}
1112 1005
1113/* -------------------------------------------------------------------------- 1006/* --------------------------------------------------------------------------
1114 FS Interface (/proc)
1115 -------------------------------------------------------------------------- */
1116#ifdef CONFIG_ACPI_PROCFS
1117
1118static struct proc_dir_entry *acpi_video_dir;
1119
1120/* video devices */
1121
1122static int acpi_video_device_info_seq_show(struct seq_file *seq, void *offset)
1123{
1124 struct acpi_video_device *dev = seq->private;
1125
1126
1127 if (!dev)
1128 goto end;
1129
1130 seq_printf(seq, "device_id: 0x%04x\n", (u32) dev->device_id);
1131 seq_printf(seq, "type: ");
1132 if (dev->flags.crt)
1133 seq_printf(seq, "CRT\n");
1134 else if (dev->flags.lcd)
1135 seq_printf(seq, "LCD\n");
1136 else if (dev->flags.tvout)
1137 seq_printf(seq, "TVOUT\n");
1138 else if (dev->flags.dvi)
1139 seq_printf(seq, "DVI\n");
1140 else
1141 seq_printf(seq, "UNKNOWN\n");
1142
1143 seq_printf(seq, "known by bios: %s\n", dev->flags.bios ? "yes" : "no");
1144
1145 end:
1146 return 0;
1147}
1148
1149static int
1150acpi_video_device_info_open_fs(struct inode *inode, struct file *file)
1151{
1152 return single_open(file, acpi_video_device_info_seq_show,
1153 PDE(inode)->data);
1154}
1155
1156static int
1157acpi_video_device_query(struct acpi_video_device *device,
1158 unsigned long long *state)
1159{
1160 int status;
1161
1162 status = acpi_evaluate_integer(device->dev->handle, "_DGS",
1163 NULL, state);
1164
1165 return status;
1166}
1167
1168static int acpi_video_device_state_seq_show(struct seq_file *seq, void *offset)
1169{
1170 int status;
1171 struct acpi_video_device *dev = seq->private;
1172 unsigned long long state;
1173
1174
1175 if (!dev)
1176 goto end;
1177
1178 status = acpi_video_device_get_state(dev, &state);
1179 seq_printf(seq, "state: ");
1180 if (ACPI_SUCCESS(status))
1181 seq_printf(seq, "0x%02llx\n", state);
1182 else
1183 seq_printf(seq, "<not supported>\n");
1184
1185 status = acpi_video_device_query(dev, &state);
1186 seq_printf(seq, "query: ");
1187 if (ACPI_SUCCESS(status))
1188 seq_printf(seq, "0x%02llx\n", state);
1189 else
1190 seq_printf(seq, "<not supported>\n");
1191
1192 end:
1193 return 0;
1194}
1195
1196static int
1197acpi_video_device_state_open_fs(struct inode *inode, struct file *file)
1198{
1199 return single_open(file, acpi_video_device_state_seq_show,
1200 PDE(inode)->data);
1201}
1202
1203static ssize_t
1204acpi_video_device_write_state(struct file *file,
1205 const char __user * buffer,
1206 size_t count, loff_t * data)
1207{
1208 int status;
1209 struct seq_file *m = file->private_data;
1210 struct acpi_video_device *dev = m->private;
1211 char str[12] = { 0 };
1212 u32 state = 0;
1213
1214
1215 if (!dev || count >= sizeof(str))
1216 return -EINVAL;
1217
1218 if (copy_from_user(str, buffer, count))
1219 return -EFAULT;
1220
1221 str[count] = 0;
1222 state = simple_strtoul(str, NULL, 0);
1223 state &= ((1ul << 31) | (1ul << 30) | (1ul << 0));
1224
1225 status = acpi_video_device_set_state(dev, state);
1226
1227 if (status)
1228 return -EFAULT;
1229
1230 return count;
1231}
1232
1233static int
1234acpi_video_device_brightness_seq_show(struct seq_file *seq, void *offset)
1235{
1236 struct acpi_video_device *dev = seq->private;
1237 int i;
1238
1239
1240 if (!dev || !dev->brightness) {
1241 seq_printf(seq, "<not supported>\n");
1242 return 0;
1243 }
1244
1245 seq_printf(seq, "levels: ");
1246 for (i = 2; i < dev->brightness->count; i++)
1247 seq_printf(seq, " %d", dev->brightness->levels[i]);
1248 seq_printf(seq, "\ncurrent: %d\n", dev->brightness->curr);
1249
1250 return 0;
1251}
1252
1253static int
1254acpi_video_device_brightness_open_fs(struct inode *inode, struct file *file)
1255{
1256 return single_open(file, acpi_video_device_brightness_seq_show,
1257 PDE(inode)->data);
1258}
1259
1260static ssize_t
1261acpi_video_device_write_brightness(struct file *file,
1262 const char __user * buffer,
1263 size_t count, loff_t * data)
1264{
1265 struct seq_file *m = file->private_data;
1266 struct acpi_video_device *dev = m->private;
1267 char str[5] = { 0 };
1268 unsigned int level = 0;
1269 int i;
1270
1271
1272 if (!dev || !dev->brightness || count >= sizeof(str))
1273 return -EINVAL;
1274
1275 if (copy_from_user(str, buffer, count))
1276 return -EFAULT;
1277
1278 str[count] = 0;
1279 level = simple_strtoul(str, NULL, 0);
1280
1281 if (level > 100)
1282 return -EFAULT;
1283
1284 /* validate through the list of available levels */
1285 for (i = 2; i < dev->brightness->count; i++)
1286 if (level == dev->brightness->levels[i]) {
1287 if (!acpi_video_device_lcd_set_level(dev, level))
1288 return count;
1289 break;
1290 }
1291
1292 return -EINVAL;
1293}
1294
1295static int acpi_video_device_EDID_seq_show(struct seq_file *seq, void *offset)
1296{
1297 struct acpi_video_device *dev = seq->private;
1298 int status;
1299 int i;
1300 union acpi_object *edid = NULL;
1301
1302
1303 if (!dev)
1304 goto out;
1305
1306 status = acpi_video_device_EDID(dev, &edid, 128);
1307 if (ACPI_FAILURE(status)) {
1308 status = acpi_video_device_EDID(dev, &edid, 256);
1309 }
1310
1311 if (ACPI_FAILURE(status)) {
1312 goto out;
1313 }
1314
1315 if (edid && edid->type == ACPI_TYPE_BUFFER) {
1316 for (i = 0; i < edid->buffer.length; i++)
1317 seq_putc(seq, edid->buffer.pointer[i]);
1318 }
1319
1320 out:
1321 if (!edid)
1322 seq_printf(seq, "<not supported>\n");
1323 else
1324 kfree(edid);
1325
1326 return 0;
1327}
1328
1329static int
1330acpi_video_device_EDID_open_fs(struct inode *inode, struct file *file)
1331{
1332 return single_open(file, acpi_video_device_EDID_seq_show,
1333 PDE(inode)->data);
1334}
1335
1336static int acpi_video_device_add_fs(struct acpi_device *device)
1337{
1338 struct proc_dir_entry *entry, *device_dir;
1339 struct acpi_video_device *vid_dev;
1340
1341 vid_dev = acpi_driver_data(device);
1342 if (!vid_dev)
1343 return -ENODEV;
1344
1345 device_dir = proc_mkdir(acpi_device_bid(device),
1346 vid_dev->video->dir);
1347 if (!device_dir)
1348 return -ENOMEM;
1349
1350 /* 'info' [R] */
1351 entry = proc_create_data("info", S_IRUGO, device_dir,
1352 &acpi_video_device_info_fops, acpi_driver_data(device));
1353 if (!entry)
1354 goto err_remove_dir;
1355
1356 /* 'state' [R/W] */
1357 entry = proc_create_data("state", S_IFREG | S_IRUGO | S_IWUSR,
1358 device_dir,
1359 &acpi_video_device_state_fops,
1360 acpi_driver_data(device));
1361 if (!entry)
1362 goto err_remove_info;
1363
1364 /* 'brightness' [R/W] */
1365 entry = proc_create_data("brightness", S_IFREG | S_IRUGO | S_IWUSR,
1366 device_dir,
1367 &acpi_video_device_brightness_fops,
1368 acpi_driver_data(device));
1369 if (!entry)
1370 goto err_remove_state;
1371
1372 /* 'EDID' [R] */
1373 entry = proc_create_data("EDID", S_IRUGO, device_dir,
1374 &acpi_video_device_EDID_fops,
1375 acpi_driver_data(device));
1376 if (!entry)
1377 goto err_remove_brightness;
1378
1379 acpi_device_dir(device) = device_dir;
1380
1381 return 0;
1382
1383 err_remove_brightness:
1384 remove_proc_entry("brightness", device_dir);
1385 err_remove_state:
1386 remove_proc_entry("state", device_dir);
1387 err_remove_info:
1388 remove_proc_entry("info", device_dir);
1389 err_remove_dir:
1390 remove_proc_entry(acpi_device_bid(device), vid_dev->video->dir);
1391 return -ENOMEM;
1392}
1393
1394static int acpi_video_device_remove_fs(struct acpi_device *device)
1395{
1396 struct acpi_video_device *vid_dev;
1397 struct proc_dir_entry *device_dir;
1398
1399 vid_dev = acpi_driver_data(device);
1400 if (!vid_dev || !vid_dev->video || !vid_dev->video->dir)
1401 return -ENODEV;
1402
1403 device_dir = acpi_device_dir(device);
1404 if (device_dir) {
1405 remove_proc_entry("info", device_dir);
1406 remove_proc_entry("state", device_dir);
1407 remove_proc_entry("brightness", device_dir);
1408 remove_proc_entry("EDID", device_dir);
1409 remove_proc_entry(acpi_device_bid(device), vid_dev->video->dir);
1410 acpi_device_dir(device) = NULL;
1411 }
1412
1413 return 0;
1414}
1415
1416/* video bus */
1417static int acpi_video_bus_info_seq_show(struct seq_file *seq, void *offset)
1418{
1419 struct acpi_video_bus *video = seq->private;
1420
1421
1422 if (!video)
1423 goto end;
1424
1425 seq_printf(seq, "Switching heads: %s\n",
1426 video->flags.multihead ? "yes" : "no");
1427 seq_printf(seq, "Video ROM: %s\n",
1428 video->flags.rom ? "yes" : "no");
1429 seq_printf(seq, "Device to be POSTed on boot: %s\n",
1430 video->flags.post ? "yes" : "no");
1431
1432 end:
1433 return 0;
1434}
1435
1436static int acpi_video_bus_info_open_fs(struct inode *inode, struct file *file)
1437{
1438 return single_open(file, acpi_video_bus_info_seq_show,
1439 PDE(inode)->data);
1440}
1441
1442static int acpi_video_bus_ROM_seq_show(struct seq_file *seq, void *offset)
1443{
1444 struct acpi_video_bus *video = seq->private;
1445
1446
1447 if (!video)
1448 goto end;
1449
1450 printk(KERN_INFO PREFIX "Please implement %s\n", __func__);
1451 seq_printf(seq, "<TODO>\n");
1452
1453 end:
1454 return 0;
1455}
1456
1457static int acpi_video_bus_ROM_open_fs(struct inode *inode, struct file *file)
1458{
1459 return single_open(file, acpi_video_bus_ROM_seq_show, PDE(inode)->data);
1460}
1461
1462static int
1463acpi_video_bus_POST_options(struct acpi_video_bus *video,
1464 unsigned long long *options)
1465{
1466 int status;
1467
1468 status = acpi_evaluate_integer(video->device->handle, "_VPO",
1469 NULL, options);
1470 *options &= 3;
1471
1472 return status;
1473}
1474
1475static int acpi_video_bus_POST_info_seq_show(struct seq_file *seq, void *offset)
1476{
1477 struct acpi_video_bus *video = seq->private;
1478 unsigned long long options;
1479 int status;
1480
1481
1482 if (!video)
1483 goto end;
1484
1485 status = acpi_video_bus_POST_options(video, &options);
1486 if (ACPI_SUCCESS(status)) {
1487 if (!(options & 1)) {
1488 printk(KERN_WARNING PREFIX
1489 "The motherboard VGA device is not listed as a possible POST device.\n");
1490 printk(KERN_WARNING PREFIX
1491 "This indicates a BIOS bug. Please contact the manufacturer.\n");
1492 }
1493 printk(KERN_WARNING "%llx\n", options);
1494 seq_printf(seq, "can POST: <integrated video>");
1495 if (options & 2)
1496 seq_printf(seq, " <PCI video>");
1497 if (options & 4)
1498 seq_printf(seq, " <AGP video>");
1499 seq_putc(seq, '\n');
1500 } else
1501 seq_printf(seq, "<not supported>\n");
1502 end:
1503 return 0;
1504}
1505
1506static int
1507acpi_video_bus_POST_info_open_fs(struct inode *inode, struct file *file)
1508{
1509 return single_open(file, acpi_video_bus_POST_info_seq_show,
1510 PDE(inode)->data);
1511}
1512
1513static int
1514acpi_video_bus_get_POST(struct acpi_video_bus *video, unsigned long long *id)
1515{
1516 int status;
1517
1518 status = acpi_evaluate_integer(video->device->handle, "_GPD", NULL, id);
1519
1520 return status;
1521}
1522
1523static int acpi_video_bus_POST_seq_show(struct seq_file *seq, void *offset)
1524{
1525 struct acpi_video_bus *video = seq->private;
1526 int status;
1527 unsigned long long id;
1528
1529
1530 if (!video)
1531 goto end;
1532
1533 status = acpi_video_bus_get_POST(video, &id);
1534 if (!ACPI_SUCCESS(status)) {
1535 seq_printf(seq, "<not supported>\n");
1536 goto end;
1537 }
1538 seq_printf(seq, "device POSTed is <%s>\n", device_decode[id & 3]);
1539
1540 end:
1541 return 0;
1542}
1543
1544static int acpi_video_bus_DOS_seq_show(struct seq_file *seq, void *offset)
1545{
1546 struct acpi_video_bus *video = seq->private;
1547
1548
1549 seq_printf(seq, "DOS setting: <%d>\n", video->dos_setting);
1550
1551 return 0;
1552}
1553
1554static int acpi_video_bus_POST_open_fs(struct inode *inode, struct file *file)
1555{
1556 return single_open(file, acpi_video_bus_POST_seq_show,
1557 PDE(inode)->data);
1558}
1559
1560static int acpi_video_bus_DOS_open_fs(struct inode *inode, struct file *file)
1561{
1562 return single_open(file, acpi_video_bus_DOS_seq_show, PDE(inode)->data);
1563}
1564
1565static int
1566acpi_video_bus_set_POST(struct acpi_video_bus *video, unsigned long option)
1567{
1568 int status;
1569 unsigned long long tmp;
1570 union acpi_object arg0 = { ACPI_TYPE_INTEGER };
1571 struct acpi_object_list args = { 1, &arg0 };
1572
1573
1574 arg0.integer.value = option;
1575
1576 status = acpi_evaluate_integer(video->device->handle, "_SPD",
1577 &args, &tmp);
1578 if (ACPI_SUCCESS(status))
1579 status = tmp ? (-EINVAL) : (AE_OK);
1580
1581 return status;
1582}
1583
1584static ssize_t
1585acpi_video_bus_write_POST(struct file *file,
1586 const char __user * buffer,
1587 size_t count, loff_t * data)
1588{
1589 int status;
1590 struct seq_file *m = file->private_data;
1591 struct acpi_video_bus *video = m->private;
1592 char str[12] = { 0 };
1593 unsigned long long opt, options;
1594
1595
1596 if (!video || count >= sizeof(str))
1597 return -EINVAL;
1598
1599 status = acpi_video_bus_POST_options(video, &options);
1600 if (!ACPI_SUCCESS(status))
1601 return -EINVAL;
1602
1603 if (copy_from_user(str, buffer, count))
1604 return -EFAULT;
1605
1606 str[count] = 0;
1607 opt = strtoul(str, NULL, 0);
1608 if (opt > 3)
1609 return -EFAULT;
1610
1611 /* just in case an OEM 'forgot' the motherboard... */
1612 options |= 1;
1613
1614 if (options & (1ul << opt)) {
1615 status = acpi_video_bus_set_POST(video, opt);
1616 if (!ACPI_SUCCESS(status))
1617 return -EFAULT;
1618
1619 }
1620
1621 return count;
1622}
1623
1624static ssize_t
1625acpi_video_bus_write_DOS(struct file *file,
1626 const char __user * buffer,
1627 size_t count, loff_t * data)
1628{
1629 int status;
1630 struct seq_file *m = file->private_data;
1631 struct acpi_video_bus *video = m->private;
1632 char str[12] = { 0 };
1633 unsigned long opt;
1634
1635
1636 if (!video || count >= sizeof(str))
1637 return -EINVAL;
1638
1639 if (copy_from_user(str, buffer, count))
1640 return -EFAULT;
1641
1642 str[count] = 0;
1643 opt = strtoul(str, NULL, 0);
1644 if (opt > 7)
1645 return -EFAULT;
1646
1647 status = acpi_video_bus_DOS(video, opt & 0x3, (opt & 0x4) >> 2);
1648
1649 if (!ACPI_SUCCESS(status))
1650 return -EFAULT;
1651
1652 return count;
1653}
1654
1655static int acpi_video_bus_add_fs(struct acpi_device *device)
1656{
1657 struct acpi_video_bus *video = acpi_driver_data(device);
1658 struct proc_dir_entry *device_dir;
1659 struct proc_dir_entry *entry;
1660
1661 device_dir = proc_mkdir(acpi_device_bid(device), acpi_video_dir);
1662 if (!device_dir)
1663 return -ENOMEM;
1664
1665 /* 'info' [R] */
1666 entry = proc_create_data("info", S_IRUGO, device_dir,
1667 &acpi_video_bus_info_fops,
1668 acpi_driver_data(device));
1669 if (!entry)
1670 goto err_remove_dir;
1671
1672 /* 'ROM' [R] */
1673 entry = proc_create_data("ROM", S_IRUGO, device_dir,
1674 &acpi_video_bus_ROM_fops,
1675 acpi_driver_data(device));
1676 if (!entry)
1677 goto err_remove_info;
1678
1679 /* 'POST_info' [R] */
1680 entry = proc_create_data("POST_info", S_IRUGO, device_dir,
1681 &acpi_video_bus_POST_info_fops,
1682 acpi_driver_data(device));
1683 if (!entry)
1684 goto err_remove_rom;
1685
1686 /* 'POST' [R/W] */
1687 entry = proc_create_data("POST", S_IFREG | S_IRUGO | S_IWUSR,
1688 device_dir,
1689 &acpi_video_bus_POST_fops,
1690 acpi_driver_data(device));
1691 if (!entry)
1692 goto err_remove_post_info;
1693
1694 /* 'DOS' [R/W] */
1695 entry = proc_create_data("DOS", S_IFREG | S_IRUGO | S_IWUSR,
1696 device_dir,
1697 &acpi_video_bus_DOS_fops,
1698 acpi_driver_data(device));
1699 if (!entry)
1700 goto err_remove_post;
1701
1702 video->dir = acpi_device_dir(device) = device_dir;
1703 return 0;
1704
1705 err_remove_post:
1706 remove_proc_entry("POST", device_dir);
1707 err_remove_post_info:
1708 remove_proc_entry("POST_info", device_dir);
1709 err_remove_rom:
1710 remove_proc_entry("ROM", device_dir);
1711 err_remove_info:
1712 remove_proc_entry("info", device_dir);
1713 err_remove_dir:
1714 remove_proc_entry(acpi_device_bid(device), acpi_video_dir);
1715 return -ENOMEM;
1716}
1717
1718static int acpi_video_bus_remove_fs(struct acpi_device *device)
1719{
1720 struct proc_dir_entry *device_dir = acpi_device_dir(device);
1721
1722 if (device_dir) {
1723 remove_proc_entry("info", device_dir);
1724 remove_proc_entry("ROM", device_dir);
1725 remove_proc_entry("POST_info", device_dir);
1726 remove_proc_entry("POST", device_dir);
1727 remove_proc_entry("DOS", device_dir);
1728 remove_proc_entry(acpi_device_bid(device), acpi_video_dir);
1729 acpi_device_dir(device) = NULL;
1730 }
1731
1732 return 0;
1733}
1734#else
1735static inline int acpi_video_device_add_fs(struct acpi_device *device)
1736{
1737 return 0;
1738}
1739static inline int acpi_video_device_remove_fs(struct acpi_device *device)
1740{
1741 return 0;
1742}
1743static inline int acpi_video_bus_add_fs(struct acpi_device *device)
1744{
1745 return 0;
1746}
1747static inline int acpi_video_bus_remove_fs(struct acpi_device *device)
1748{
1749 return 0;
1750}
1751#endif /* CONFIG_ACPI_PROCFS */
1752
1753/* --------------------------------------------------------------------------
1754 Driver Interface 1007 Driver Interface
1755 -------------------------------------------------------------------------- */ 1008 -------------------------------------------------------------------------- */
1756 1009
@@ -1877,8 +1130,6 @@ acpi_video_bus_get_one_device(struct acpi_device *device,
1877 list_add_tail(&data->entry, &video->video_device_list); 1130 list_add_tail(&data->entry, &video->video_device_list);
1878 mutex_unlock(&video->device_list_lock); 1131 mutex_unlock(&video->device_list_lock);
1879 1132
1880 acpi_video_device_add_fs(device);
1881
1882 return 0; 1133 return 0;
1883 } 1134 }
1884 1135
@@ -2181,8 +1432,6 @@ static int acpi_video_bus_put_one_device(struct acpi_video_device *device)
2181 if (!device || !device->video) 1432 if (!device || !device->video)
2182 return -ENOENT; 1433 return -ENOENT;
2183 1434
2184 acpi_video_device_remove_fs(device->dev);
2185
2186 status = acpi_remove_notify_handler(device->dev->handle, 1435 status = acpi_remove_notify_handler(device->dev->handle,
2187 ACPI_DEVICE_NOTIFY, 1436 ACPI_DEVICE_NOTIFY,
2188 acpi_video_device_notify); 1437 acpi_video_device_notify);
@@ -2466,10 +1715,6 @@ static int acpi_video_bus_add(struct acpi_device *device)
2466 if (error) 1715 if (error)
2467 goto err_free_video; 1716 goto err_free_video;
2468 1717
2469 error = acpi_video_bus_add_fs(device);
2470 if (error)
2471 goto err_free_video;
2472
2473 mutex_init(&video->device_list_lock); 1718 mutex_init(&video->device_list_lock);
2474 INIT_LIST_HEAD(&video->video_device_list); 1719 INIT_LIST_HEAD(&video->video_device_list);
2475 1720
@@ -2522,7 +1767,6 @@ static int acpi_video_bus_add(struct acpi_device *device)
2522 acpi_video_bus_stop_devices(video); 1767 acpi_video_bus_stop_devices(video);
2523 acpi_video_bus_put_devices(video); 1768 acpi_video_bus_put_devices(video);
2524 kfree(video->attached_array); 1769 kfree(video->attached_array);
2525 acpi_video_bus_remove_fs(device);
2526 err_free_video: 1770 err_free_video:
2527 kfree(video); 1771 kfree(video);
2528 device->driver_data = NULL; 1772 device->driver_data = NULL;
@@ -2544,7 +1788,6 @@ static int acpi_video_bus_remove(struct acpi_device *device, int type)
2544 1788
2545 acpi_video_bus_stop_devices(video); 1789 acpi_video_bus_stop_devices(video);
2546 acpi_video_bus_put_devices(video); 1790 acpi_video_bus_put_devices(video);
2547 acpi_video_bus_remove_fs(device);
2548 1791
2549 input_unregister_device(video->input); 1792 input_unregister_device(video->input);
2550 kfree(video->attached_array); 1793 kfree(video->attached_array);
@@ -2584,17 +1827,9 @@ int acpi_video_register(void)
2584 return 0; 1827 return 0;
2585 } 1828 }
2586 1829
2587#ifdef CONFIG_ACPI_PROCFS
2588 acpi_video_dir = proc_mkdir(ACPI_VIDEO_CLASS, acpi_root_dir);
2589 if (!acpi_video_dir)
2590 return -ENODEV;
2591#endif
2592
2593 result = acpi_bus_register_driver(&acpi_video_bus); 1830 result = acpi_bus_register_driver(&acpi_video_bus);
2594 if (result < 0) { 1831 if (result < 0)
2595 remove_proc_entry(ACPI_VIDEO_CLASS, acpi_root_dir);
2596 return -ENODEV; 1832 return -ENODEV;
2597 }
2598 1833
2599 /* 1834 /*
2600 * When the acpi_video_bus is loaded successfully, increase 1835 * When the acpi_video_bus is loaded successfully, increase
@@ -2617,10 +1852,6 @@ void acpi_video_unregister(void)
2617 } 1852 }
2618 acpi_bus_unregister_driver(&acpi_video_bus); 1853 acpi_bus_unregister_driver(&acpi_video_bus);
2619 1854
2620#ifdef CONFIG_ACPI_PROCFS
2621 remove_proc_entry(ACPI_VIDEO_CLASS, acpi_root_dir);
2622#endif
2623
2624 register_count = 0; 1855 register_count = 0;
2625 1856
2626 return; 1857 return;