aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/acpi/thermal.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/acpi/thermal.c')
-rw-r--r--drivers/acpi/thermal.c86
1 files changed, 53 insertions, 33 deletions
diff --git a/drivers/acpi/thermal.c b/drivers/acpi/thermal.c
index efad1f33aeb5..2f8f17131d9f 100644
--- a/drivers/acpi/thermal.c
+++ b/drivers/acpi/thermal.c
@@ -37,10 +37,14 @@
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
40#include <linux/proc_fs.h> 42#include <linux/proc_fs.h>
43#include <linux/seq_file.h>
44#endif
45
41#include <linux/jiffies.h> 46#include <linux/jiffies.h>
42#include <linux/kmod.h> 47#include <linux/kmod.h>
43#include <linux/seq_file.h>
44#include <linux/reboot.h> 48#include <linux/reboot.h>
45#include <linux/device.h> 49#include <linux/device.h>
46#include <asm/uaccess.h> 50#include <asm/uaccess.h>
@@ -102,16 +106,6 @@ static int acpi_thermal_add(struct acpi_device *device);
102static int acpi_thermal_remove(struct acpi_device *device, int type); 106static int acpi_thermal_remove(struct acpi_device *device, int type);
103static int acpi_thermal_resume(struct acpi_device *device); 107static int acpi_thermal_resume(struct acpi_device *device);
104static void acpi_thermal_notify(struct acpi_device *device, u32 event); 108static void acpi_thermal_notify(struct acpi_device *device, u32 event);
105static int acpi_thermal_state_open_fs(struct inode *inode, struct file *file);
106static int acpi_thermal_temp_open_fs(struct inode *inode, struct file *file);
107static int acpi_thermal_trip_open_fs(struct inode *inode, struct file *file);
108static int acpi_thermal_cooling_open_fs(struct inode *inode, struct file *file);
109static ssize_t acpi_thermal_write_cooling_mode(struct file *,
110 const char __user *, size_t,
111 loff_t *);
112static int acpi_thermal_polling_open_fs(struct inode *inode, struct file *file);
113static ssize_t acpi_thermal_write_polling(struct file *, const char __user *,
114 size_t, loff_t *);
115 109
116static const struct acpi_device_id thermal_device_ids[] = { 110static const struct acpi_device_id thermal_device_ids[] = {
117 {ACPI_THERMAL_HID, 0}, 111 {ACPI_THERMAL_HID, 0},
@@ -201,6 +195,18 @@ struct acpi_thermal {
201 struct mutex lock; 195 struct mutex lock;
202}; 196};
203 197
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
204static const struct file_operations acpi_thermal_state_fops = { 210static const struct file_operations acpi_thermal_state_fops = {
205 .owner = THIS_MODULE, 211 .owner = THIS_MODULE,
206 .open = acpi_thermal_state_open_fs, 212 .open = acpi_thermal_state_open_fs,
@@ -242,6 +248,7 @@ static const struct file_operations acpi_thermal_polling_fops = {
242 .llseek = seq_lseek, 248 .llseek = seq_lseek,
243 .release = single_release, 249 .release = single_release,
244}; 250};
251#endif /* CONFIG_ACPI_PROCFS*/
245 252
246/* -------------------------------------------------------------------------- 253/* --------------------------------------------------------------------------
247 Thermal Zone Management 254 Thermal Zone Management
@@ -287,26 +294,6 @@ static int acpi_thermal_get_polling_frequency(struct acpi_thermal *tz)
287 return 0; 294 return 0;
288} 295}
289 296
290static int acpi_thermal_set_polling(struct acpi_thermal *tz, int seconds)
291{
292
293 if (!tz)
294 return -EINVAL;
295
296 tz->polling_frequency = seconds * 10; /* Convert value to deci-seconds */
297
298 tz->thermal_zone->polling_delay = seconds * 1000;
299
300 if (tz->tz_enabled)
301 thermal_zone_device_update(tz->thermal_zone);
302
303 ACPI_DEBUG_PRINT((ACPI_DB_INFO,
304 "Polling frequency set to %lu seconds\n",
305 tz->polling_frequency/10));
306
307 return 0;
308}
309
310static int acpi_thermal_set_cooling_mode(struct acpi_thermal *tz, int mode) 297static int acpi_thermal_set_cooling_mode(struct acpi_thermal *tz, int mode)
311{ 298{
312 acpi_status status = AE_OK; 299 acpi_status status = AE_OK;
@@ -973,7 +960,7 @@ static void acpi_thermal_unregister_thermal_zone(struct acpi_thermal *tz)
973/* -------------------------------------------------------------------------- 960/* --------------------------------------------------------------------------
974 FS Interface (/proc) 961 FS Interface (/proc)
975 -------------------------------------------------------------------------- */ 962 -------------------------------------------------------------------------- */
976 963#ifdef CONFIG_ACPI_PROCFS
977static struct proc_dir_entry *acpi_thermal_dir; 964static struct proc_dir_entry *acpi_thermal_dir;
978 965
979static int acpi_thermal_state_seq_show(struct seq_file *seq, void *offset) 966static int acpi_thermal_state_seq_show(struct seq_file *seq, void *offset)
@@ -1187,6 +1174,26 @@ static int acpi_thermal_polling_open_fs(struct inode *inode, struct file *file)
1187 PDE(inode)->data); 1174 PDE(inode)->data);
1188} 1175}
1189 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
1190static ssize_t 1197static ssize_t
1191acpi_thermal_write_polling(struct file *file, 1198acpi_thermal_write_polling(struct file *file,
1192 const char __user * buffer, 1199 const char __user * buffer,
@@ -1295,7 +1302,13 @@ static int acpi_thermal_remove_fs(struct acpi_device *device)
1295 1302
1296 return 0; 1303 return 0;
1297} 1304}
1298 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 */
1299/* -------------------------------------------------------------------------- 1312/* --------------------------------------------------------------------------
1300 Driver Interface 1313 Driver Interface
1301 -------------------------------------------------------------------------- */ 1314 -------------------------------------------------------------------------- */
@@ -1566,13 +1579,18 @@ static int __init acpi_thermal_init(void)
1566 printk(KERN_NOTICE "ACPI: thermal control disabled\n"); 1579 printk(KERN_NOTICE "ACPI: thermal control disabled\n");
1567 return -ENODEV; 1580 return -ENODEV;
1568 } 1581 }
1582
1583#ifdef CONFIG_ACPI_PROCFS
1569 acpi_thermal_dir = proc_mkdir(ACPI_THERMAL_CLASS, acpi_root_dir); 1584 acpi_thermal_dir = proc_mkdir(ACPI_THERMAL_CLASS, acpi_root_dir);
1570 if (!acpi_thermal_dir) 1585 if (!acpi_thermal_dir)
1571 return -ENODEV; 1586 return -ENODEV;
1587#endif
1572 1588
1573 result = acpi_bus_register_driver(&acpi_thermal_driver); 1589 result = acpi_bus_register_driver(&acpi_thermal_driver);
1574 if (result < 0) { 1590 if (result < 0) {
1591#ifdef CONFIG_ACPI_PROCFS
1575 remove_proc_entry(ACPI_THERMAL_CLASS, acpi_root_dir); 1592 remove_proc_entry(ACPI_THERMAL_CLASS, acpi_root_dir);
1593#endif
1576 return -ENODEV; 1594 return -ENODEV;
1577 } 1595 }
1578 1596
@@ -1584,7 +1602,9 @@ static void __exit acpi_thermal_exit(void)
1584 1602
1585 acpi_bus_unregister_driver(&acpi_thermal_driver); 1603 acpi_bus_unregister_driver(&acpi_thermal_driver);
1586 1604
1605#ifdef CONFIG_ACPI_PROCFS
1587 remove_proc_entry(ACPI_THERMAL_CLASS, acpi_root_dir); 1606 remove_proc_entry(ACPI_THERMAL_CLASS, acpi_root_dir);
1607#endif
1588 1608
1589 return; 1609 return;
1590} 1610}