thermal.c 33 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320
  1. /*
  2. * acpi_thermal.c - ACPI Thermal Zone Driver ($Revision: 41 $)
  3. *
  4. * Copyright (C) 2001, 2002 Andy Grover <andrew.grover@intel.com>
  5. * Copyright (C) 2001, 2002 Paul Diefenbaugh <paul.s.diefenbaugh@intel.com>
  6. *
  7. * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  8. *
  9. * This program is free software; you can redistribute it and/or modify
  10. * it under the terms of the GNU General Public License as published by
  11. * the Free Software Foundation; either version 2 of the License, or (at
  12. * your option) any later version.
  13. *
  14. * This program is distributed in the hope that it will be useful, but
  15. * WITHOUT ANY WARRANTY; without even the implied warranty of
  16. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  17. * General Public License for more details.
  18. *
  19. * You should have received a copy of the GNU General Public License along
  20. * with this program; if not, write to the Free Software Foundation, Inc.,
  21. * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
  22. *
  23. * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  24. *
  25. * This driver fully implements the ACPI thermal policy as described in the
  26. * ACPI 2.0 Specification.
  27. *
  28. * TBD: 1. Implement passive cooling hysteresis.
  29. * 2. Enhance passive cooling (CPU) states/limit interface to support
  30. * concepts of 'multiple limiters', upper/lower limits, etc.
  31. *
  32. */
  33. #include <linux/kernel.h>
  34. #include <linux/module.h>
  35. #include <linux/init.h>
  36. #include <linux/types.h>
  37. #include <linux/proc_fs.h>
  38. #include <linux/timer.h>
  39. #include <linux/jiffies.h>
  40. #include <linux/kmod.h>
  41. #include <linux/seq_file.h>
  42. #include <asm/uaccess.h>
  43. #include <acpi/acpi_bus.h>
  44. #include <acpi/acpi_drivers.h>
  45. #define ACPI_THERMAL_COMPONENT 0x04000000
  46. #define ACPI_THERMAL_CLASS "thermal_zone"
  47. #define ACPI_THERMAL_DEVICE_NAME "Thermal Zone"
  48. #define ACPI_THERMAL_FILE_STATE "state"
  49. #define ACPI_THERMAL_FILE_TEMPERATURE "temperature"
  50. #define ACPI_THERMAL_FILE_TRIP_POINTS "trip_points"
  51. #define ACPI_THERMAL_FILE_COOLING_MODE "cooling_mode"
  52. #define ACPI_THERMAL_FILE_POLLING_FREQ "polling_frequency"
  53. #define ACPI_THERMAL_NOTIFY_TEMPERATURE 0x80
  54. #define ACPI_THERMAL_NOTIFY_THRESHOLDS 0x81
  55. #define ACPI_THERMAL_NOTIFY_DEVICES 0x82
  56. #define ACPI_THERMAL_NOTIFY_CRITICAL 0xF0
  57. #define ACPI_THERMAL_NOTIFY_HOT 0xF1
  58. #define ACPI_THERMAL_MODE_ACTIVE 0x00
  59. #define ACPI_THERMAL_PATH_POWEROFF "/sbin/poweroff"
  60. #define ACPI_THERMAL_MAX_ACTIVE 10
  61. #define ACPI_THERMAL_MAX_LIMIT_STR_LEN 65
  62. #define KELVIN_TO_CELSIUS(t) (long)(((long)t-2732>=0) ? ((long)t-2732+5)/10 : ((long)t-2732-5)/10)
  63. #define CELSIUS_TO_KELVIN(t) ((t+273)*10)
  64. #define _COMPONENT ACPI_THERMAL_COMPONENT
  65. ACPI_MODULE_NAME("thermal");
  66. MODULE_AUTHOR("Paul Diefenbaugh");
  67. MODULE_DESCRIPTION("ACPI Thermal Zone Driver");
  68. MODULE_LICENSE("GPL");
  69. static int tzp;
  70. module_param(tzp, int, 0);
  71. MODULE_PARM_DESC(tzp, "Thermal zone polling frequency, in 1/10 seconds.\n");
  72. static int acpi_thermal_add(struct acpi_device *device);
  73. static int acpi_thermal_remove(struct acpi_device *device, int type);
  74. static int acpi_thermal_resume(struct acpi_device *device);
  75. static int acpi_thermal_state_open_fs(struct inode *inode, struct file *file);
  76. static int acpi_thermal_temp_open_fs(struct inode *inode, struct file *file);
  77. static int acpi_thermal_trip_open_fs(struct inode *inode, struct file *file);
  78. static int acpi_thermal_cooling_open_fs(struct inode *inode, struct file *file);
  79. static ssize_t acpi_thermal_write_cooling_mode(struct file *,
  80. const char __user *, size_t,
  81. loff_t *);
  82. static int acpi_thermal_polling_open_fs(struct inode *inode, struct file *file);
  83. static ssize_t acpi_thermal_write_polling(struct file *, const char __user *,
  84. size_t, loff_t *);
  85. static struct acpi_driver acpi_thermal_driver = {
  86. .name = "thermal",
  87. .class = ACPI_THERMAL_CLASS,
  88. .ids = ACPI_THERMAL_HID,
  89. .ops = {
  90. .add = acpi_thermal_add,
  91. .remove = acpi_thermal_remove,
  92. .resume = acpi_thermal_resume,
  93. },
  94. };
  95. struct acpi_thermal_state {
  96. u8 critical:1;
  97. u8 hot:1;
  98. u8 passive:1;
  99. u8 active:1;
  100. u8 reserved:4;
  101. int active_index;
  102. };
  103. struct acpi_thermal_state_flags {
  104. u8 valid:1;
  105. u8 enabled:1;
  106. u8 reserved:6;
  107. };
  108. struct acpi_thermal_critical {
  109. struct acpi_thermal_state_flags flags;
  110. unsigned long temperature;
  111. };
  112. struct acpi_thermal_hot {
  113. struct acpi_thermal_state_flags flags;
  114. unsigned long temperature;
  115. };
  116. struct acpi_thermal_passive {
  117. struct acpi_thermal_state_flags flags;
  118. unsigned long temperature;
  119. unsigned long tc1;
  120. unsigned long tc2;
  121. unsigned long tsp;
  122. struct acpi_handle_list devices;
  123. };
  124. struct acpi_thermal_active {
  125. struct acpi_thermal_state_flags flags;
  126. unsigned long temperature;
  127. struct acpi_handle_list devices;
  128. };
  129. struct acpi_thermal_trips {
  130. struct acpi_thermal_critical critical;
  131. struct acpi_thermal_hot hot;
  132. struct acpi_thermal_passive passive;
  133. struct acpi_thermal_active active[ACPI_THERMAL_MAX_ACTIVE];
  134. };
  135. struct acpi_thermal_flags {
  136. u8 cooling_mode:1; /* _SCP */
  137. u8 devices:1; /* _TZD */
  138. u8 reserved:6;
  139. };
  140. struct acpi_thermal {
  141. struct acpi_device * device;
  142. acpi_bus_id name;
  143. unsigned long temperature;
  144. unsigned long last_temperature;
  145. unsigned long polling_frequency;
  146. volatile u8 zombie;
  147. struct acpi_thermal_flags flags;
  148. struct acpi_thermal_state state;
  149. struct acpi_thermal_trips trips;
  150. struct acpi_handle_list devices;
  151. struct timer_list timer;
  152. };
  153. static const struct file_operations acpi_thermal_state_fops = {
  154. .open = acpi_thermal_state_open_fs,
  155. .read = seq_read,
  156. .llseek = seq_lseek,
  157. .release = single_release,
  158. };
  159. static const struct file_operations acpi_thermal_temp_fops = {
  160. .open = acpi_thermal_temp_open_fs,
  161. .read = seq_read,
  162. .llseek = seq_lseek,
  163. .release = single_release,
  164. };
  165. static const struct file_operations acpi_thermal_trip_fops = {
  166. .open = acpi_thermal_trip_open_fs,
  167. .read = seq_read,
  168. .llseek = seq_lseek,
  169. .release = single_release,
  170. };
  171. static const struct file_operations acpi_thermal_cooling_fops = {
  172. .open = acpi_thermal_cooling_open_fs,
  173. .read = seq_read,
  174. .write = acpi_thermal_write_cooling_mode,
  175. .llseek = seq_lseek,
  176. .release = single_release,
  177. };
  178. static const struct file_operations acpi_thermal_polling_fops = {
  179. .open = acpi_thermal_polling_open_fs,
  180. .read = seq_read,
  181. .write = acpi_thermal_write_polling,
  182. .llseek = seq_lseek,
  183. .release = single_release,
  184. };
  185. /* --------------------------------------------------------------------------
  186. Thermal Zone Management
  187. -------------------------------------------------------------------------- */
  188. static int acpi_thermal_get_temperature(struct acpi_thermal *tz)
  189. {
  190. acpi_status status = AE_OK;
  191. if (!tz)
  192. return -EINVAL;
  193. tz->last_temperature = tz->temperature;
  194. status =
  195. acpi_evaluate_integer(tz->device->handle, "_TMP", NULL, &tz->temperature);
  196. if (ACPI_FAILURE(status))
  197. return -ENODEV;
  198. ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Temperature is %lu dK\n",
  199. tz->temperature));
  200. return 0;
  201. }
  202. static int acpi_thermal_get_polling_frequency(struct acpi_thermal *tz)
  203. {
  204. acpi_status status = AE_OK;
  205. if (!tz)
  206. return -EINVAL;
  207. status =
  208. acpi_evaluate_integer(tz->device->handle, "_TZP", NULL,
  209. &tz->polling_frequency);
  210. if (ACPI_FAILURE(status))
  211. return -ENODEV;
  212. ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Polling frequency is %lu dS\n",
  213. tz->polling_frequency));
  214. return 0;
  215. }
  216. static int acpi_thermal_set_polling(struct acpi_thermal *tz, int seconds)
  217. {
  218. if (!tz)
  219. return -EINVAL;
  220. tz->polling_frequency = seconds * 10; /* Convert value to deci-seconds */
  221. ACPI_DEBUG_PRINT((ACPI_DB_INFO,
  222. "Polling frequency set to %lu seconds\n",
  223. tz->polling_frequency/10));
  224. return 0;
  225. }
  226. static int acpi_thermal_set_cooling_mode(struct acpi_thermal *tz, int mode)
  227. {
  228. acpi_status status = AE_OK;
  229. union acpi_object arg0 = { ACPI_TYPE_INTEGER };
  230. struct acpi_object_list arg_list = { 1, &arg0 };
  231. acpi_handle handle = NULL;
  232. if (!tz)
  233. return -EINVAL;
  234. status = acpi_get_handle(tz->device->handle, "_SCP", &handle);
  235. if (ACPI_FAILURE(status)) {
  236. ACPI_DEBUG_PRINT((ACPI_DB_INFO, "_SCP not present\n"));
  237. return -ENODEV;
  238. }
  239. arg0.integer.value = mode;
  240. status = acpi_evaluate_object(handle, NULL, &arg_list, NULL);
  241. if (ACPI_FAILURE(status))
  242. return -ENODEV;
  243. return 0;
  244. }
  245. static int acpi_thermal_get_trip_points(struct acpi_thermal *tz)
  246. {
  247. acpi_status status = AE_OK;
  248. int i = 0;
  249. if (!tz)
  250. return -EINVAL;
  251. /* Critical Shutdown (required) */
  252. status = acpi_evaluate_integer(tz->device->handle, "_CRT", NULL,
  253. &tz->trips.critical.temperature);
  254. if (ACPI_FAILURE(status)) {
  255. tz->trips.critical.flags.valid = 0;
  256. ACPI_EXCEPTION((AE_INFO, status, "No critical threshold"));
  257. return -ENODEV;
  258. } else {
  259. tz->trips.critical.flags.valid = 1;
  260. ACPI_DEBUG_PRINT((ACPI_DB_INFO,
  261. "Found critical threshold [%lu]\n",
  262. tz->trips.critical.temperature));
  263. }
  264. /* Critical Sleep (optional) */
  265. status =
  266. acpi_evaluate_integer(tz->device->handle, "_HOT", NULL,
  267. &tz->trips.hot.temperature);
  268. if (ACPI_FAILURE(status)) {
  269. tz->trips.hot.flags.valid = 0;
  270. ACPI_DEBUG_PRINT((ACPI_DB_INFO, "No hot threshold\n"));
  271. } else {
  272. tz->trips.hot.flags.valid = 1;
  273. ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Found hot threshold [%lu]\n",
  274. tz->trips.hot.temperature));
  275. }
  276. /* Passive: Processors (optional) */
  277. status =
  278. acpi_evaluate_integer(tz->device->handle, "_PSV", NULL,
  279. &tz->trips.passive.temperature);
  280. if (ACPI_FAILURE(status)) {
  281. tz->trips.passive.flags.valid = 0;
  282. ACPI_DEBUG_PRINT((ACPI_DB_INFO, "No passive threshold\n"));
  283. } else {
  284. tz->trips.passive.flags.valid = 1;
  285. status =
  286. acpi_evaluate_integer(tz->device->handle, "_TC1", NULL,
  287. &tz->trips.passive.tc1);
  288. if (ACPI_FAILURE(status))
  289. tz->trips.passive.flags.valid = 0;
  290. status =
  291. acpi_evaluate_integer(tz->device->handle, "_TC2", NULL,
  292. &tz->trips.passive.tc2);
  293. if (ACPI_FAILURE(status))
  294. tz->trips.passive.flags.valid = 0;
  295. status =
  296. acpi_evaluate_integer(tz->device->handle, "_TSP", NULL,
  297. &tz->trips.passive.tsp);
  298. if (ACPI_FAILURE(status))
  299. tz->trips.passive.flags.valid = 0;
  300. status =
  301. acpi_evaluate_reference(tz->device->handle, "_PSL", NULL,
  302. &tz->trips.passive.devices);
  303. if (ACPI_FAILURE(status))
  304. tz->trips.passive.flags.valid = 0;
  305. if (!tz->trips.passive.flags.valid)
  306. printk(KERN_WARNING PREFIX "Invalid passive threshold\n");
  307. else
  308. ACPI_DEBUG_PRINT((ACPI_DB_INFO,
  309. "Found passive threshold [%lu]\n",
  310. tz->trips.passive.temperature));
  311. }
  312. /* Active: Fans, etc. (optional) */
  313. for (i = 0; i < ACPI_THERMAL_MAX_ACTIVE; i++) {
  314. char name[5] = { '_', 'A', 'C', ('0' + i), '\0' };
  315. status =
  316. acpi_evaluate_integer(tz->device->handle, name, NULL,
  317. &tz->trips.active[i].temperature);
  318. if (ACPI_FAILURE(status))
  319. break;
  320. name[2] = 'L';
  321. status =
  322. acpi_evaluate_reference(tz->device->handle, name, NULL,
  323. &tz->trips.active[i].devices);
  324. if (ACPI_SUCCESS(status)) {
  325. tz->trips.active[i].flags.valid = 1;
  326. ACPI_DEBUG_PRINT((ACPI_DB_INFO,
  327. "Found active threshold [%d]:[%lu]\n",
  328. i, tz->trips.active[i].temperature));
  329. } else
  330. ACPI_EXCEPTION((AE_INFO, status,
  331. "Invalid active threshold [%d]", i));
  332. }
  333. return 0;
  334. }
  335. static int acpi_thermal_get_devices(struct acpi_thermal *tz)
  336. {
  337. acpi_status status = AE_OK;
  338. if (!tz)
  339. return -EINVAL;
  340. status =
  341. acpi_evaluate_reference(tz->device->handle, "_TZD", NULL, &tz->devices);
  342. if (ACPI_FAILURE(status))
  343. return -ENODEV;
  344. return 0;
  345. }
  346. static int acpi_thermal_call_usermode(char *path)
  347. {
  348. char *argv[2] = { NULL, NULL };
  349. char *envp[3] = { NULL, NULL, NULL };
  350. if (!path)
  351. return -EINVAL;
  352. argv[0] = path;
  353. /* minimal command environment */
  354. envp[0] = "HOME=/";
  355. envp[1] = "PATH=/sbin:/bin:/usr/sbin:/usr/bin";
  356. call_usermodehelper(argv[0], argv, envp, 0);
  357. return 0;
  358. }
  359. static int acpi_thermal_critical(struct acpi_thermal *tz)
  360. {
  361. if (!tz || !tz->trips.critical.flags.valid)
  362. return -EINVAL;
  363. if (tz->temperature >= tz->trips.critical.temperature) {
  364. printk(KERN_WARNING PREFIX "Critical trip point\n");
  365. tz->trips.critical.flags.enabled = 1;
  366. } else if (tz->trips.critical.flags.enabled)
  367. tz->trips.critical.flags.enabled = 0;
  368. printk(KERN_EMERG
  369. "Critical temperature reached (%ld C), shutting down.\n",
  370. KELVIN_TO_CELSIUS(tz->temperature));
  371. acpi_bus_generate_event(tz->device, ACPI_THERMAL_NOTIFY_CRITICAL,
  372. tz->trips.critical.flags.enabled);
  373. acpi_thermal_call_usermode(ACPI_THERMAL_PATH_POWEROFF);
  374. return 0;
  375. }
  376. static int acpi_thermal_hot(struct acpi_thermal *tz)
  377. {
  378. if (!tz || !tz->trips.hot.flags.valid)
  379. return -EINVAL;
  380. if (tz->temperature >= tz->trips.hot.temperature) {
  381. printk(KERN_WARNING PREFIX "Hot trip point\n");
  382. tz->trips.hot.flags.enabled = 1;
  383. } else if (tz->trips.hot.flags.enabled)
  384. tz->trips.hot.flags.enabled = 0;
  385. acpi_bus_generate_event(tz->device, ACPI_THERMAL_NOTIFY_HOT,
  386. tz->trips.hot.flags.enabled);
  387. /* TBD: Call user-mode "sleep(S4)" function */
  388. return 0;
  389. }
  390. static void acpi_thermal_passive(struct acpi_thermal *tz)
  391. {
  392. int result = 1;
  393. struct acpi_thermal_passive *passive = NULL;
  394. int trend = 0;
  395. int i = 0;
  396. if (!tz || !tz->trips.passive.flags.valid)
  397. return;
  398. passive = &(tz->trips.passive);
  399. /*
  400. * Above Trip?
  401. * -----------
  402. * Calculate the thermal trend (using the passive cooling equation)
  403. * and modify the performance limit for all passive cooling devices
  404. * accordingly. Note that we assume symmetry.
  405. */
  406. if (tz->temperature >= passive->temperature) {
  407. trend =
  408. (passive->tc1 * (tz->temperature - tz->last_temperature)) +
  409. (passive->tc2 * (tz->temperature - passive->temperature));
  410. ACPI_DEBUG_PRINT((ACPI_DB_INFO,
  411. "trend[%d]=(tc1[%lu]*(tmp[%lu]-last[%lu]))+(tc2[%lu]*(tmp[%lu]-psv[%lu]))\n",
  412. trend, passive->tc1, tz->temperature,
  413. tz->last_temperature, passive->tc2,
  414. tz->temperature, passive->temperature));
  415. passive->flags.enabled = 1;
  416. /* Heating up? */
  417. if (trend > 0)
  418. for (i = 0; i < passive->devices.count; i++)
  419. acpi_processor_set_thermal_limit(passive->
  420. devices.
  421. handles[i],
  422. ACPI_PROCESSOR_LIMIT_INCREMENT);
  423. /* Cooling off? */
  424. else if (trend < 0) {
  425. for (i = 0; i < passive->devices.count; i++)
  426. /*
  427. * assume that we are on highest
  428. * freq/lowest thrott and can leave
  429. * passive mode, even in error case
  430. */
  431. if (!acpi_processor_set_thermal_limit
  432. (passive->devices.handles[i],
  433. ACPI_PROCESSOR_LIMIT_DECREMENT))
  434. result = 0;
  435. /*
  436. * Leave cooling mode, even if the temp might
  437. * higher than trip point This is because some
  438. * machines might have long thermal polling
  439. * frequencies (tsp) defined. We will fall back
  440. * into passive mode in next cycle (probably quicker)
  441. */
  442. if (result) {
  443. passive->flags.enabled = 0;
  444. ACPI_DEBUG_PRINT((ACPI_DB_INFO,
  445. "Disabling passive cooling, still above threshold,"
  446. " but we are cooling down\n"));
  447. }
  448. }
  449. return;
  450. }
  451. /*
  452. * Below Trip?
  453. * -----------
  454. * Implement passive cooling hysteresis to slowly increase performance
  455. * and avoid thrashing around the passive trip point. Note that we
  456. * assume symmetry.
  457. */
  458. if (!passive->flags.enabled)
  459. return;
  460. for (i = 0; i < passive->devices.count; i++)
  461. if (!acpi_processor_set_thermal_limit
  462. (passive->devices.handles[i],
  463. ACPI_PROCESSOR_LIMIT_DECREMENT))
  464. result = 0;
  465. if (result) {
  466. passive->flags.enabled = 0;
  467. ACPI_DEBUG_PRINT((ACPI_DB_INFO,
  468. "Disabling passive cooling (zone is cool)\n"));
  469. }
  470. }
  471. static void acpi_thermal_active(struct acpi_thermal *tz)
  472. {
  473. int result = 0;
  474. struct acpi_thermal_active *active = NULL;
  475. int i = 0;
  476. int j = 0;
  477. unsigned long maxtemp = 0;
  478. if (!tz)
  479. return;
  480. for (i = 0; i < ACPI_THERMAL_MAX_ACTIVE; i++) {
  481. active = &(tz->trips.active[i]);
  482. if (!active || !active->flags.valid)
  483. break;
  484. if (tz->temperature >= active->temperature) {
  485. /*
  486. * Above Threshold?
  487. * ----------------
  488. * If not already enabled, turn ON all cooling devices
  489. * associated with this active threshold.
  490. */
  491. if (active->temperature > maxtemp)
  492. tz->state.active_index = i;
  493. maxtemp = active->temperature;
  494. if (active->flags.enabled)
  495. continue;
  496. for (j = 0; j < active->devices.count; j++) {
  497. result =
  498. acpi_bus_set_power(active->devices.
  499. handles[j],
  500. ACPI_STATE_D0);
  501. if (result) {
  502. printk(KERN_WARNING PREFIX
  503. "Unable to turn cooling device [%p] 'on'\n",
  504. active->devices.
  505. handles[j]);
  506. continue;
  507. }
  508. active->flags.enabled = 1;
  509. ACPI_DEBUG_PRINT((ACPI_DB_INFO,
  510. "Cooling device [%p] now 'on'\n",
  511. active->devices.handles[j]));
  512. }
  513. continue;
  514. }
  515. if (!active->flags.enabled)
  516. continue;
  517. /*
  518. * Below Threshold?
  519. * ----------------
  520. * Turn OFF all cooling devices associated with this
  521. * threshold.
  522. */
  523. for (j = 0; j < active->devices.count; j++) {
  524. result = acpi_bus_set_power(active->devices.handles[j],
  525. ACPI_STATE_D3);
  526. if (result) {
  527. printk(KERN_WARNING PREFIX
  528. "Unable to turn cooling device [%p] 'off'\n",
  529. active->devices.handles[j]);
  530. continue;
  531. }
  532. active->flags.enabled = 0;
  533. ACPI_DEBUG_PRINT((ACPI_DB_INFO,
  534. "Cooling device [%p] now 'off'\n",
  535. active->devices.handles[j]));
  536. }
  537. }
  538. }
  539. static void acpi_thermal_check(void *context);
  540. static void acpi_thermal_run(unsigned long data)
  541. {
  542. struct acpi_thermal *tz = (struct acpi_thermal *)data;
  543. if (!tz->zombie)
  544. acpi_os_execute(OSL_GPE_HANDLER, acpi_thermal_check, (void *)data);
  545. }
  546. static void acpi_thermal_check(void *data)
  547. {
  548. int result = 0;
  549. struct acpi_thermal *tz = data;
  550. unsigned long sleep_time = 0;
  551. int i = 0;
  552. struct acpi_thermal_state state;
  553. if (!tz) {
  554. printk(KERN_ERR PREFIX "Invalid (NULL) context\n");
  555. return;
  556. }
  557. state = tz->state;
  558. result = acpi_thermal_get_temperature(tz);
  559. if (result)
  560. return;
  561. memset(&tz->state, 0, sizeof(tz->state));
  562. /*
  563. * Check Trip Points
  564. * -----------------
  565. * Compare the current temperature to the trip point values to see
  566. * if we've entered one of the thermal policy states. Note that
  567. * this function determines when a state is entered, but the
  568. * individual policy decides when it is exited (e.g. hysteresis).
  569. */
  570. if (tz->trips.critical.flags.valid)
  571. state.critical |=
  572. (tz->temperature >= tz->trips.critical.temperature);
  573. if (tz->trips.hot.flags.valid)
  574. state.hot |= (tz->temperature >= tz->trips.hot.temperature);
  575. if (tz->trips.passive.flags.valid)
  576. state.passive |=
  577. (tz->temperature >= tz->trips.passive.temperature);
  578. for (i = 0; i < ACPI_THERMAL_MAX_ACTIVE; i++)
  579. if (tz->trips.active[i].flags.valid)
  580. state.active |=
  581. (tz->temperature >=
  582. tz->trips.active[i].temperature);
  583. /*
  584. * Invoke Policy
  585. * -------------
  586. * Separated from the above check to allow individual policy to
  587. * determine when to exit a given state.
  588. */
  589. if (state.critical)
  590. acpi_thermal_critical(tz);
  591. if (state.hot)
  592. acpi_thermal_hot(tz);
  593. if (state.passive)
  594. acpi_thermal_passive(tz);
  595. if (state.active)
  596. acpi_thermal_active(tz);
  597. /*
  598. * Calculate State
  599. * ---------------
  600. * Again, separated from the above two to allow independent policy
  601. * decisions.
  602. */
  603. tz->state.critical = tz->trips.critical.flags.enabled;
  604. tz->state.hot = tz->trips.hot.flags.enabled;
  605. tz->state.passive = tz->trips.passive.flags.enabled;
  606. tz->state.active = 0;
  607. for (i = 0; i < ACPI_THERMAL_MAX_ACTIVE; i++)
  608. tz->state.active |= tz->trips.active[i].flags.enabled;
  609. /*
  610. * Calculate Sleep Time
  611. * --------------------
  612. * If we're in the passive state, use _TSP's value. Otherwise
  613. * use the default polling frequency (e.g. _TZP). If no polling
  614. * frequency is specified then we'll wait forever (at least until
  615. * a thermal event occurs). Note that _TSP and _TZD values are
  616. * given in 1/10th seconds (we must covert to milliseconds).
  617. */
  618. if (tz->state.passive)
  619. sleep_time = tz->trips.passive.tsp * 100;
  620. else if (tz->polling_frequency > 0)
  621. sleep_time = tz->polling_frequency * 100;
  622. ACPI_DEBUG_PRINT((ACPI_DB_INFO, "%s: temperature[%lu] sleep[%lu]\n",
  623. tz->name, tz->temperature, sleep_time));
  624. /*
  625. * Schedule Next Poll
  626. * ------------------
  627. */
  628. if (!sleep_time) {
  629. if (timer_pending(&(tz->timer)))
  630. del_timer(&(tz->timer));
  631. } else {
  632. if (timer_pending(&(tz->timer)))
  633. mod_timer(&(tz->timer),
  634. jiffies + (HZ * sleep_time) / 1000);
  635. else {
  636. tz->timer.data = (unsigned long)tz;
  637. tz->timer.function = acpi_thermal_run;
  638. tz->timer.expires = jiffies + (HZ * sleep_time) / 1000;
  639. add_timer(&(tz->timer));
  640. }
  641. }
  642. return;
  643. }
  644. /* --------------------------------------------------------------------------
  645. FS Interface (/proc)
  646. -------------------------------------------------------------------------- */
  647. static struct proc_dir_entry *acpi_thermal_dir;
  648. static int acpi_thermal_state_seq_show(struct seq_file *seq, void *offset)
  649. {
  650. struct acpi_thermal *tz = seq->private;
  651. if (!tz)
  652. goto end;
  653. seq_puts(seq, "state: ");
  654. if (!tz->state.critical && !tz->state.hot && !tz->state.passive
  655. && !tz->state.active)
  656. seq_puts(seq, "ok\n");
  657. else {
  658. if (tz->state.critical)
  659. seq_puts(seq, "critical ");
  660. if (tz->state.hot)
  661. seq_puts(seq, "hot ");
  662. if (tz->state.passive)
  663. seq_puts(seq, "passive ");
  664. if (tz->state.active)
  665. seq_printf(seq, "active[%d]", tz->state.active_index);
  666. seq_puts(seq, "\n");
  667. }
  668. end:
  669. return 0;
  670. }
  671. static int acpi_thermal_state_open_fs(struct inode *inode, struct file *file)
  672. {
  673. return single_open(file, acpi_thermal_state_seq_show, PDE(inode)->data);
  674. }
  675. static int acpi_thermal_temp_seq_show(struct seq_file *seq, void *offset)
  676. {
  677. int result = 0;
  678. struct acpi_thermal *tz = seq->private;
  679. if (!tz)
  680. goto end;
  681. result = acpi_thermal_get_temperature(tz);
  682. if (result)
  683. goto end;
  684. seq_printf(seq, "temperature: %ld C\n",
  685. KELVIN_TO_CELSIUS(tz->temperature));
  686. end:
  687. return 0;
  688. }
  689. static int acpi_thermal_temp_open_fs(struct inode *inode, struct file *file)
  690. {
  691. return single_open(file, acpi_thermal_temp_seq_show, PDE(inode)->data);
  692. }
  693. static int acpi_thermal_trip_seq_show(struct seq_file *seq, void *offset)
  694. {
  695. struct acpi_thermal *tz = seq->private;
  696. int i = 0;
  697. int j = 0;
  698. if (!tz)
  699. goto end;
  700. if (tz->trips.critical.flags.valid)
  701. seq_printf(seq, "critical (S5): %ld C\n",
  702. KELVIN_TO_CELSIUS(tz->trips.critical.temperature));
  703. if (tz->trips.hot.flags.valid)
  704. seq_printf(seq, "hot (S4): %ld C\n",
  705. KELVIN_TO_CELSIUS(tz->trips.hot.temperature));
  706. if (tz->trips.passive.flags.valid) {
  707. seq_printf(seq,
  708. "passive: %ld C: tc1=%lu tc2=%lu tsp=%lu devices=",
  709. KELVIN_TO_CELSIUS(tz->trips.passive.temperature),
  710. tz->trips.passive.tc1, tz->trips.passive.tc2,
  711. tz->trips.passive.tsp);
  712. for (j = 0; j < tz->trips.passive.devices.count; j++) {
  713. seq_printf(seq, "0x%p ",
  714. tz->trips.passive.devices.handles[j]);
  715. }
  716. seq_puts(seq, "\n");
  717. }
  718. for (i = 0; i < ACPI_THERMAL_MAX_ACTIVE; i++) {
  719. if (!(tz->trips.active[i].flags.valid))
  720. break;
  721. seq_printf(seq, "active[%d]: %ld C: devices=",
  722. i,
  723. KELVIN_TO_CELSIUS(tz->trips.active[i].temperature));
  724. for (j = 0; j < tz->trips.active[i].devices.count; j++)
  725. seq_printf(seq, "0x%p ",
  726. tz->trips.active[i].devices.handles[j]);
  727. seq_puts(seq, "\n");
  728. }
  729. end:
  730. return 0;
  731. }
  732. static int acpi_thermal_trip_open_fs(struct inode *inode, struct file *file)
  733. {
  734. return single_open(file, acpi_thermal_trip_seq_show, PDE(inode)->data);
  735. }
  736. static int acpi_thermal_cooling_seq_show(struct seq_file *seq, void *offset)
  737. {
  738. struct acpi_thermal *tz = seq->private;
  739. if (!tz)
  740. goto end;
  741. if (!tz->flags.cooling_mode)
  742. seq_puts(seq, "<setting not supported>\n");
  743. else
  744. seq_puts(seq, "0 - Active; 1 - Passive\n");
  745. end:
  746. return 0;
  747. }
  748. static int acpi_thermal_cooling_open_fs(struct inode *inode, struct file *file)
  749. {
  750. return single_open(file, acpi_thermal_cooling_seq_show,
  751. PDE(inode)->data);
  752. }
  753. static ssize_t
  754. acpi_thermal_write_cooling_mode(struct file *file,
  755. const char __user * buffer,
  756. size_t count, loff_t * ppos)
  757. {
  758. struct seq_file *m = file->private_data;
  759. struct acpi_thermal *tz = m->private;
  760. int result = 0;
  761. char mode_string[12] = { '\0' };
  762. if (!tz || (count > sizeof(mode_string) - 1))
  763. return -EINVAL;
  764. if (!tz->flags.cooling_mode)
  765. return -ENODEV;
  766. if (copy_from_user(mode_string, buffer, count))
  767. return -EFAULT;
  768. mode_string[count] = '\0';
  769. result = acpi_thermal_set_cooling_mode(tz,
  770. simple_strtoul(mode_string, NULL,
  771. 0));
  772. if (result)
  773. return result;
  774. acpi_thermal_check(tz);
  775. return count;
  776. }
  777. static int acpi_thermal_polling_seq_show(struct seq_file *seq, void *offset)
  778. {
  779. struct acpi_thermal *tz = seq->private;
  780. if (!tz)
  781. goto end;
  782. if (!tz->polling_frequency) {
  783. seq_puts(seq, "<polling disabled>\n");
  784. goto end;
  785. }
  786. seq_printf(seq, "polling frequency: %lu seconds\n",
  787. (tz->polling_frequency / 10));
  788. end:
  789. return 0;
  790. }
  791. static int acpi_thermal_polling_open_fs(struct inode *inode, struct file *file)
  792. {
  793. return single_open(file, acpi_thermal_polling_seq_show,
  794. PDE(inode)->data);
  795. }
  796. static ssize_t
  797. acpi_thermal_write_polling(struct file *file,
  798. const char __user * buffer,
  799. size_t count, loff_t * ppos)
  800. {
  801. struct seq_file *m = file->private_data;
  802. struct acpi_thermal *tz = m->private;
  803. int result = 0;
  804. char polling_string[12] = { '\0' };
  805. int seconds = 0;
  806. if (!tz || (count > sizeof(polling_string) - 1))
  807. return -EINVAL;
  808. if (copy_from_user(polling_string, buffer, count))
  809. return -EFAULT;
  810. polling_string[count] = '\0';
  811. seconds = simple_strtoul(polling_string, NULL, 0);
  812. result = acpi_thermal_set_polling(tz, seconds);
  813. if (result)
  814. return result;
  815. acpi_thermal_check(tz);
  816. return count;
  817. }
  818. static int acpi_thermal_add_fs(struct acpi_device *device)
  819. {
  820. struct proc_dir_entry *entry = NULL;
  821. if (!acpi_device_dir(device)) {
  822. acpi_device_dir(device) = proc_mkdir(acpi_device_bid(device),
  823. acpi_thermal_dir);
  824. if (!acpi_device_dir(device))
  825. return -ENODEV;
  826. acpi_device_dir(device)->owner = THIS_MODULE;
  827. }
  828. /* 'state' [R] */
  829. entry = create_proc_entry(ACPI_THERMAL_FILE_STATE,
  830. S_IRUGO, acpi_device_dir(device));
  831. if (!entry)
  832. return -ENODEV;
  833. else {
  834. entry->proc_fops = &acpi_thermal_state_fops;
  835. entry->data = acpi_driver_data(device);
  836. entry->owner = THIS_MODULE;
  837. }
  838. /* 'temperature' [R] */
  839. entry = create_proc_entry(ACPI_THERMAL_FILE_TEMPERATURE,
  840. S_IRUGO, acpi_device_dir(device));
  841. if (!entry)
  842. return -ENODEV;
  843. else {
  844. entry->proc_fops = &acpi_thermal_temp_fops;
  845. entry->data = acpi_driver_data(device);
  846. entry->owner = THIS_MODULE;
  847. }
  848. /* 'trip_points' [R/W] */
  849. entry = create_proc_entry(ACPI_THERMAL_FILE_TRIP_POINTS,
  850. S_IFREG | S_IRUGO | S_IWUSR,
  851. acpi_device_dir(device));
  852. if (!entry)
  853. return -ENODEV;
  854. else {
  855. entry->proc_fops = &acpi_thermal_trip_fops;
  856. entry->data = acpi_driver_data(device);
  857. entry->owner = THIS_MODULE;
  858. }
  859. /* 'cooling_mode' [R/W] */
  860. entry = create_proc_entry(ACPI_THERMAL_FILE_COOLING_MODE,
  861. S_IFREG | S_IRUGO | S_IWUSR,
  862. acpi_device_dir(device));
  863. if (!entry)
  864. return -ENODEV;
  865. else {
  866. entry->proc_fops = &acpi_thermal_cooling_fops;
  867. entry->data = acpi_driver_data(device);
  868. entry->owner = THIS_MODULE;
  869. }
  870. /* 'polling_frequency' [R/W] */
  871. entry = create_proc_entry(ACPI_THERMAL_FILE_POLLING_FREQ,
  872. S_IFREG | S_IRUGO | S_IWUSR,
  873. acpi_device_dir(device));
  874. if (!entry)
  875. return -ENODEV;
  876. else {
  877. entry->proc_fops = &acpi_thermal_polling_fops;
  878. entry->data = acpi_driver_data(device);
  879. entry->owner = THIS_MODULE;
  880. }
  881. return 0;
  882. }
  883. static int acpi_thermal_remove_fs(struct acpi_device *device)
  884. {
  885. if (acpi_device_dir(device)) {
  886. remove_proc_entry(ACPI_THERMAL_FILE_POLLING_FREQ,
  887. acpi_device_dir(device));
  888. remove_proc_entry(ACPI_THERMAL_FILE_COOLING_MODE,
  889. acpi_device_dir(device));
  890. remove_proc_entry(ACPI_THERMAL_FILE_TRIP_POINTS,
  891. acpi_device_dir(device));
  892. remove_proc_entry(ACPI_THERMAL_FILE_TEMPERATURE,
  893. acpi_device_dir(device));
  894. remove_proc_entry(ACPI_THERMAL_FILE_STATE,
  895. acpi_device_dir(device));
  896. remove_proc_entry(acpi_device_bid(device), acpi_thermal_dir);
  897. acpi_device_dir(device) = NULL;
  898. }
  899. return 0;
  900. }
  901. /* --------------------------------------------------------------------------
  902. Driver Interface
  903. -------------------------------------------------------------------------- */
  904. static void acpi_thermal_notify(acpi_handle handle, u32 event, void *data)
  905. {
  906. struct acpi_thermal *tz = data;
  907. struct acpi_device *device = NULL;
  908. if (!tz)
  909. return;
  910. device = tz->device;
  911. switch (event) {
  912. case ACPI_THERMAL_NOTIFY_TEMPERATURE:
  913. acpi_thermal_check(tz);
  914. break;
  915. case ACPI_THERMAL_NOTIFY_THRESHOLDS:
  916. acpi_thermal_get_trip_points(tz);
  917. acpi_thermal_check(tz);
  918. acpi_bus_generate_event(device, event, 0);
  919. break;
  920. case ACPI_THERMAL_NOTIFY_DEVICES:
  921. if (tz->flags.devices)
  922. acpi_thermal_get_devices(tz);
  923. acpi_bus_generate_event(device, event, 0);
  924. break;
  925. default:
  926. ACPI_DEBUG_PRINT((ACPI_DB_INFO,
  927. "Unsupported event [0x%x]\n", event));
  928. break;
  929. }
  930. return;
  931. }
  932. static int acpi_thermal_get_info(struct acpi_thermal *tz)
  933. {
  934. int result = 0;
  935. if (!tz)
  936. return -EINVAL;
  937. /* Get temperature [_TMP] (required) */
  938. result = acpi_thermal_get_temperature(tz);
  939. if (result)
  940. return result;
  941. /* Get trip points [_CRT, _PSV, etc.] (required) */
  942. result = acpi_thermal_get_trip_points(tz);
  943. if (result)
  944. return result;
  945. /* Set the cooling mode [_SCP] to active cooling (default) */
  946. result = acpi_thermal_set_cooling_mode(tz, ACPI_THERMAL_MODE_ACTIVE);
  947. if (!result)
  948. tz->flags.cooling_mode = 1;
  949. /* Get default polling frequency [_TZP] (optional) */
  950. if (tzp)
  951. tz->polling_frequency = tzp;
  952. else
  953. acpi_thermal_get_polling_frequency(tz);
  954. /* Get devices in this thermal zone [_TZD] (optional) */
  955. result = acpi_thermal_get_devices(tz);
  956. if (!result)
  957. tz->flags.devices = 1;
  958. return 0;
  959. }
  960. static int acpi_thermal_add(struct acpi_device *device)
  961. {
  962. int result = 0;
  963. acpi_status status = AE_OK;
  964. struct acpi_thermal *tz = NULL;
  965. if (!device)
  966. return -EINVAL;
  967. tz = kzalloc(sizeof(struct acpi_thermal), GFP_KERNEL);
  968. if (!tz)
  969. return -ENOMEM;
  970. tz->device = device;
  971. strcpy(tz->name, device->pnp.bus_id);
  972. strcpy(acpi_device_name(device), ACPI_THERMAL_DEVICE_NAME);
  973. strcpy(acpi_device_class(device), ACPI_THERMAL_CLASS);
  974. acpi_driver_data(device) = tz;
  975. result = acpi_thermal_get_info(tz);
  976. if (result)
  977. goto end;
  978. result = acpi_thermal_add_fs(device);
  979. if (result)
  980. goto end;
  981. init_timer(&tz->timer);
  982. acpi_thermal_check(tz);
  983. status = acpi_install_notify_handler(device->handle,
  984. ACPI_DEVICE_NOTIFY,
  985. acpi_thermal_notify, tz);
  986. if (ACPI_FAILURE(status)) {
  987. result = -ENODEV;
  988. goto end;
  989. }
  990. printk(KERN_INFO PREFIX "%s [%s] (%ld C)\n",
  991. acpi_device_name(device), acpi_device_bid(device),
  992. KELVIN_TO_CELSIUS(tz->temperature));
  993. end:
  994. if (result) {
  995. acpi_thermal_remove_fs(device);
  996. kfree(tz);
  997. }
  998. return result;
  999. }
  1000. static int acpi_thermal_remove(struct acpi_device *device, int type)
  1001. {
  1002. acpi_status status = AE_OK;
  1003. struct acpi_thermal *tz = NULL;
  1004. if (!device || !acpi_driver_data(device))
  1005. return -EINVAL;
  1006. tz = acpi_driver_data(device);
  1007. /* avoid timer adding new defer task */
  1008. tz->zombie = 1;
  1009. /* wait for running timer (on other CPUs) finish */
  1010. del_timer_sync(&(tz->timer));
  1011. /* synchronize deferred task */
  1012. acpi_os_wait_events_complete(NULL);
  1013. /* deferred task may reinsert timer */
  1014. del_timer_sync(&(tz->timer));
  1015. status = acpi_remove_notify_handler(device->handle,
  1016. ACPI_DEVICE_NOTIFY,
  1017. acpi_thermal_notify);
  1018. /* Terminate policy */
  1019. if (tz->trips.passive.flags.valid && tz->trips.passive.flags.enabled) {
  1020. tz->trips.passive.flags.enabled = 0;
  1021. acpi_thermal_passive(tz);
  1022. }
  1023. if (tz->trips.active[0].flags.valid
  1024. && tz->trips.active[0].flags.enabled) {
  1025. tz->trips.active[0].flags.enabled = 0;
  1026. acpi_thermal_active(tz);
  1027. }
  1028. acpi_thermal_remove_fs(device);
  1029. kfree(tz);
  1030. return 0;
  1031. }
  1032. static int acpi_thermal_resume(struct acpi_device *device)
  1033. {
  1034. struct acpi_thermal *tz = NULL;
  1035. int i, j, power_state, result;
  1036. if (!device || !acpi_driver_data(device))
  1037. return -EINVAL;
  1038. tz = acpi_driver_data(device);
  1039. for (i = 0; i < ACPI_THERMAL_MAX_ACTIVE; i++) {
  1040. if (!(&tz->trips.active[i]))
  1041. break;
  1042. if (!tz->trips.active[i].flags.valid)
  1043. break;
  1044. tz->trips.active[i].flags.enabled = 1;
  1045. for (j = 0; j < tz->trips.active[i].devices.count; j++) {
  1046. result = acpi_bus_get_power(tz->trips.active[i].devices.
  1047. handles[j], &power_state);
  1048. if (result || (power_state != ACPI_STATE_D0)) {
  1049. tz->trips.active[i].flags.enabled = 0;
  1050. break;
  1051. }
  1052. }
  1053. tz->state.active |= tz->trips.active[i].flags.enabled;
  1054. }
  1055. acpi_thermal_check(tz);
  1056. return AE_OK;
  1057. }
  1058. static int __init acpi_thermal_init(void)
  1059. {
  1060. int result = 0;
  1061. acpi_thermal_dir = proc_mkdir(ACPI_THERMAL_CLASS, acpi_root_dir);
  1062. if (!acpi_thermal_dir)
  1063. return -ENODEV;
  1064. acpi_thermal_dir->owner = THIS_MODULE;
  1065. result = acpi_bus_register_driver(&acpi_thermal_driver);
  1066. if (result < 0) {
  1067. remove_proc_entry(ACPI_THERMAL_CLASS, acpi_root_dir);
  1068. return -ENODEV;
  1069. }
  1070. return 0;
  1071. }
  1072. static void __exit acpi_thermal_exit(void)
  1073. {
  1074. acpi_bus_unregister_driver(&acpi_thermal_driver);
  1075. remove_proc_entry(ACPI_THERMAL_CLASS, acpi_root_dir);
  1076. return;
  1077. }
  1078. module_init(acpi_thermal_init);
  1079. module_exit(acpi_thermal_exit);