ipmi_poweroff.c 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644
  1. /*
  2. * ipmi_poweroff.c
  3. *
  4. * MontaVista IPMI Poweroff extension to sys_reboot
  5. *
  6. * Author: MontaVista Software, Inc.
  7. * Steven Dake <sdake@mvista.com>
  8. * Corey Minyard <cminyard@mvista.com>
  9. * source@mvista.com
  10. *
  11. * Copyright 2002,2004 MontaVista Software Inc.
  12. *
  13. * This program is free software; you can redistribute it and/or modify it
  14. * under the terms of the GNU General Public License as published by the
  15. * Free Software Foundation; either version 2 of the License, or (at your
  16. * option) any later version.
  17. *
  18. *
  19. * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED
  20. * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
  21. * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
  22. * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
  23. * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
  24. * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
  25. * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
  26. * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
  27. * TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
  28. * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  29. *
  30. * You should have received a copy of the GNU General Public License along
  31. * with this program; if not, write to the Free Software Foundation, Inc.,
  32. * 675 Mass Ave, Cambridge, MA 02139, USA.
  33. */
  34. #include <linux/config.h>
  35. #include <linux/module.h>
  36. #include <linux/moduleparam.h>
  37. #include <linux/proc_fs.h>
  38. #include <linux/string.h>
  39. #include <linux/completion.h>
  40. #include <linux/kdev_t.h>
  41. #include <linux/ipmi.h>
  42. #include <linux/ipmi_smi.h>
  43. #define PFX "IPMI poweroff: "
  44. /* Where to we insert our poweroff function? */
  45. extern void (*pm_power_off)(void);
  46. /* Definitions for controlling power off (if the system supports it). It
  47. * conveniently matches the IPMI chassis control values. */
  48. #define IPMI_CHASSIS_POWER_DOWN 0 /* power down, the default. */
  49. #define IPMI_CHASSIS_POWER_CYCLE 0x02 /* power cycle */
  50. /* the IPMI data command */
  51. static int poweroff_control = IPMI_CHASSIS_POWER_DOWN;
  52. /* parameter definition to allow user to flag power cycle */
  53. module_param(poweroff_control, int, IPMI_CHASSIS_POWER_DOWN);
  54. MODULE_PARM_DESC(poweroff_control, " Set to 2 to enable power cycle instead of power down. Power cycle is contingent on hardware support, otherwise it defaults back to power down.");
  55. /* Stuff from the get device id command. */
  56. static unsigned int mfg_id;
  57. static unsigned int prod_id;
  58. static unsigned char capabilities;
  59. /* We use our own messages for this operation, we don't let the system
  60. allocate them, since we may be in a panic situation. The whole
  61. thing is single-threaded, anyway, so multiple messages are not
  62. required. */
  63. static void dummy_smi_free(struct ipmi_smi_msg *msg)
  64. {
  65. }
  66. static void dummy_recv_free(struct ipmi_recv_msg *msg)
  67. {
  68. }
  69. static struct ipmi_smi_msg halt_smi_msg =
  70. {
  71. .done = dummy_smi_free
  72. };
  73. static struct ipmi_recv_msg halt_recv_msg =
  74. {
  75. .done = dummy_recv_free
  76. };
  77. /*
  78. * Code to send a message and wait for the reponse.
  79. */
  80. static void receive_handler(struct ipmi_recv_msg *recv_msg, void *handler_data)
  81. {
  82. struct completion *comp = recv_msg->user_msg_data;
  83. if (comp)
  84. complete(comp);
  85. }
  86. static struct ipmi_user_hndl ipmi_poweroff_handler =
  87. {
  88. .ipmi_recv_hndl = receive_handler
  89. };
  90. static int ipmi_request_wait_for_response(ipmi_user_t user,
  91. struct ipmi_addr *addr,
  92. struct kernel_ipmi_msg *send_msg)
  93. {
  94. int rv;
  95. struct completion comp;
  96. init_completion(&comp);
  97. rv = ipmi_request_supply_msgs(user, addr, 0, send_msg, &comp,
  98. &halt_smi_msg, &halt_recv_msg, 0);
  99. if (rv)
  100. return rv;
  101. wait_for_completion(&comp);
  102. return halt_recv_msg.msg.data[0];
  103. }
  104. /* We are in run-to-completion mode, no completion is desired. */
  105. static int ipmi_request_in_rc_mode(ipmi_user_t user,
  106. struct ipmi_addr *addr,
  107. struct kernel_ipmi_msg *send_msg)
  108. {
  109. int rv;
  110. rv = ipmi_request_supply_msgs(user, addr, 0, send_msg, NULL,
  111. &halt_smi_msg, &halt_recv_msg, 0);
  112. if (rv)
  113. return rv;
  114. return halt_recv_msg.msg.data[0];
  115. }
  116. /*
  117. * ATCA Support
  118. */
  119. #define IPMI_NETFN_ATCA 0x2c
  120. #define IPMI_ATCA_SET_POWER_CMD 0x11
  121. #define IPMI_ATCA_GET_ADDR_INFO_CMD 0x01
  122. #define IPMI_PICMG_ID 0
  123. static int ipmi_atca_detect (ipmi_user_t user)
  124. {
  125. struct ipmi_system_interface_addr smi_addr;
  126. struct kernel_ipmi_msg send_msg;
  127. int rv;
  128. unsigned char data[1];
  129. /*
  130. * Configure IPMI address for local access
  131. */
  132. smi_addr.addr_type = IPMI_SYSTEM_INTERFACE_ADDR_TYPE;
  133. smi_addr.channel = IPMI_BMC_CHANNEL;
  134. smi_addr.lun = 0;
  135. /*
  136. * Use get address info to check and see if we are ATCA
  137. */
  138. send_msg.netfn = IPMI_NETFN_ATCA;
  139. send_msg.cmd = IPMI_ATCA_GET_ADDR_INFO_CMD;
  140. data[0] = IPMI_PICMG_ID;
  141. send_msg.data = data;
  142. send_msg.data_len = sizeof(data);
  143. rv = ipmi_request_wait_for_response(user,
  144. (struct ipmi_addr *) &smi_addr,
  145. &send_msg);
  146. return !rv;
  147. }
  148. static void ipmi_poweroff_atca (ipmi_user_t user)
  149. {
  150. struct ipmi_system_interface_addr smi_addr;
  151. struct kernel_ipmi_msg send_msg;
  152. int rv;
  153. unsigned char data[4];
  154. /*
  155. * Configure IPMI address for local access
  156. */
  157. smi_addr.addr_type = IPMI_SYSTEM_INTERFACE_ADDR_TYPE;
  158. smi_addr.channel = IPMI_BMC_CHANNEL;
  159. smi_addr.lun = 0;
  160. printk(KERN_INFO PFX "Powering down via ATCA power command\n");
  161. /*
  162. * Power down
  163. */
  164. send_msg.netfn = IPMI_NETFN_ATCA;
  165. send_msg.cmd = IPMI_ATCA_SET_POWER_CMD;
  166. data[0] = IPMI_PICMG_ID;
  167. data[1] = 0; /* FRU id */
  168. data[2] = 0; /* Power Level */
  169. data[3] = 0; /* Don't change saved presets */
  170. send_msg.data = data;
  171. send_msg.data_len = sizeof (data);
  172. rv = ipmi_request_in_rc_mode(user,
  173. (struct ipmi_addr *) &smi_addr,
  174. &send_msg);
  175. if (rv) {
  176. printk(KERN_ERR PFX "Unable to send ATCA powerdown message,"
  177. " IPMI error 0x%x\n", rv);
  178. goto out;
  179. }
  180. out:
  181. return;
  182. }
  183. /*
  184. * CPI1 Support
  185. */
  186. #define IPMI_NETFN_OEM_1 0xf8
  187. #define OEM_GRP_CMD_SET_RESET_STATE 0x84
  188. #define OEM_GRP_CMD_SET_POWER_STATE 0x82
  189. #define IPMI_NETFN_OEM_8 0xf8
  190. #define OEM_GRP_CMD_REQUEST_HOTSWAP_CTRL 0x80
  191. #define OEM_GRP_CMD_GET_SLOT_GA 0xa3
  192. #define IPMI_NETFN_SENSOR_EVT 0x10
  193. #define IPMI_CMD_GET_EVENT_RECEIVER 0x01
  194. #define IPMI_CPI1_PRODUCT_ID 0x000157
  195. #define IPMI_CPI1_MANUFACTURER_ID 0x0108
  196. static int ipmi_cpi1_detect (ipmi_user_t user)
  197. {
  198. return ((mfg_id == IPMI_CPI1_MANUFACTURER_ID)
  199. && (prod_id == IPMI_CPI1_PRODUCT_ID));
  200. }
  201. static void ipmi_poweroff_cpi1 (ipmi_user_t user)
  202. {
  203. struct ipmi_system_interface_addr smi_addr;
  204. struct ipmi_ipmb_addr ipmb_addr;
  205. struct kernel_ipmi_msg send_msg;
  206. int rv;
  207. unsigned char data[1];
  208. int slot;
  209. unsigned char hotswap_ipmb;
  210. unsigned char aer_addr;
  211. unsigned char aer_lun;
  212. /*
  213. * Configure IPMI address for local access
  214. */
  215. smi_addr.addr_type = IPMI_SYSTEM_INTERFACE_ADDR_TYPE;
  216. smi_addr.channel = IPMI_BMC_CHANNEL;
  217. smi_addr.lun = 0;
  218. printk(KERN_INFO PFX "Powering down via CPI1 power command\n");
  219. /*
  220. * Get IPMI ipmb address
  221. */
  222. send_msg.netfn = IPMI_NETFN_OEM_8 >> 2;
  223. send_msg.cmd = OEM_GRP_CMD_GET_SLOT_GA;
  224. send_msg.data = NULL;
  225. send_msg.data_len = 0;
  226. rv = ipmi_request_in_rc_mode(user,
  227. (struct ipmi_addr *) &smi_addr,
  228. &send_msg);
  229. if (rv)
  230. goto out;
  231. slot = halt_recv_msg.msg.data[1];
  232. hotswap_ipmb = (slot > 9) ? (0xb0 + 2 * slot) : (0xae + 2 * slot);
  233. /*
  234. * Get active event receiver
  235. */
  236. send_msg.netfn = IPMI_NETFN_SENSOR_EVT >> 2;
  237. send_msg.cmd = IPMI_CMD_GET_EVENT_RECEIVER;
  238. send_msg.data = NULL;
  239. send_msg.data_len = 0;
  240. rv = ipmi_request_in_rc_mode(user,
  241. (struct ipmi_addr *) &smi_addr,
  242. &send_msg);
  243. if (rv)
  244. goto out;
  245. aer_addr = halt_recv_msg.msg.data[1];
  246. aer_lun = halt_recv_msg.msg.data[2];
  247. /*
  248. * Setup IPMB address target instead of local target
  249. */
  250. ipmb_addr.addr_type = IPMI_IPMB_ADDR_TYPE;
  251. ipmb_addr.channel = 0;
  252. ipmb_addr.slave_addr = aer_addr;
  253. ipmb_addr.lun = aer_lun;
  254. /*
  255. * Send request hotswap control to remove blade from dpv
  256. */
  257. send_msg.netfn = IPMI_NETFN_OEM_8 >> 2;
  258. send_msg.cmd = OEM_GRP_CMD_REQUEST_HOTSWAP_CTRL;
  259. send_msg.data = &hotswap_ipmb;
  260. send_msg.data_len = 1;
  261. ipmi_request_in_rc_mode(user,
  262. (struct ipmi_addr *) &ipmb_addr,
  263. &send_msg);
  264. /*
  265. * Set reset asserted
  266. */
  267. send_msg.netfn = IPMI_NETFN_OEM_1 >> 2;
  268. send_msg.cmd = OEM_GRP_CMD_SET_RESET_STATE;
  269. send_msg.data = data;
  270. data[0] = 1; /* Reset asserted state */
  271. send_msg.data_len = 1;
  272. rv = ipmi_request_in_rc_mode(user,
  273. (struct ipmi_addr *) &smi_addr,
  274. &send_msg);
  275. if (rv)
  276. goto out;
  277. /*
  278. * Power down
  279. */
  280. send_msg.netfn = IPMI_NETFN_OEM_1 >> 2;
  281. send_msg.cmd = OEM_GRP_CMD_SET_POWER_STATE;
  282. send_msg.data = data;
  283. data[0] = 1; /* Power down state */
  284. send_msg.data_len = 1;
  285. rv = ipmi_request_in_rc_mode(user,
  286. (struct ipmi_addr *) &smi_addr,
  287. &send_msg);
  288. if (rv)
  289. goto out;
  290. out:
  291. return;
  292. }
  293. /*
  294. * Standard chassis support
  295. */
  296. #define IPMI_NETFN_CHASSIS_REQUEST 0
  297. #define IPMI_CHASSIS_CONTROL_CMD 0x02
  298. static int ipmi_chassis_detect (ipmi_user_t user)
  299. {
  300. /* Chassis support, use it. */
  301. return (capabilities & 0x80);
  302. }
  303. static void ipmi_poweroff_chassis (ipmi_user_t user)
  304. {
  305. struct ipmi_system_interface_addr smi_addr;
  306. struct kernel_ipmi_msg send_msg;
  307. int rv;
  308. unsigned char data[1];
  309. /*
  310. * Configure IPMI address for local access
  311. */
  312. smi_addr.addr_type = IPMI_SYSTEM_INTERFACE_ADDR_TYPE;
  313. smi_addr.channel = IPMI_BMC_CHANNEL;
  314. smi_addr.lun = 0;
  315. powercyclefailed:
  316. printk(KERN_INFO PFX "Powering %s via IPMI chassis control command\n",
  317. ((poweroff_control != IPMI_CHASSIS_POWER_CYCLE) ? "down" : "cycle"));
  318. /*
  319. * Power down
  320. */
  321. send_msg.netfn = IPMI_NETFN_CHASSIS_REQUEST;
  322. send_msg.cmd = IPMI_CHASSIS_CONTROL_CMD;
  323. data[0] = poweroff_control;
  324. send_msg.data = data;
  325. send_msg.data_len = sizeof(data);
  326. rv = ipmi_request_in_rc_mode(user,
  327. (struct ipmi_addr *) &smi_addr,
  328. &send_msg);
  329. if (rv) {
  330. switch (poweroff_control) {
  331. case IPMI_CHASSIS_POWER_CYCLE:
  332. /* power cycle failed, default to power down */
  333. printk(KERN_ERR PFX "Unable to send chassis power " \
  334. "cycle message, IPMI error 0x%x\n", rv);
  335. poweroff_control = IPMI_CHASSIS_POWER_DOWN;
  336. goto powercyclefailed;
  337. case IPMI_CHASSIS_POWER_DOWN:
  338. default:
  339. printk(KERN_ERR PFX "Unable to send chassis power " \
  340. "down message, IPMI error 0x%x\n", rv);
  341. break;
  342. }
  343. }
  344. return;
  345. }
  346. /* Table of possible power off functions. */
  347. struct poweroff_function {
  348. char *platform_type;
  349. int (*detect)(ipmi_user_t user);
  350. void (*poweroff_func)(ipmi_user_t user);
  351. };
  352. static struct poweroff_function poweroff_functions[] = {
  353. { .platform_type = "ATCA",
  354. .detect = ipmi_atca_detect,
  355. .poweroff_func = ipmi_poweroff_atca },
  356. { .platform_type = "CPI1",
  357. .detect = ipmi_cpi1_detect,
  358. .poweroff_func = ipmi_poweroff_cpi1 },
  359. /* Chassis should generally be last, other things should override
  360. it. */
  361. { .platform_type = "chassis",
  362. .detect = ipmi_chassis_detect,
  363. .poweroff_func = ipmi_poweroff_chassis },
  364. };
  365. #define NUM_PO_FUNCS (sizeof(poweroff_functions) \
  366. / sizeof(struct poweroff_function))
  367. /* Our local state. */
  368. static int ready = 0;
  369. static ipmi_user_t ipmi_user;
  370. static void (*specific_poweroff_func)(ipmi_user_t user) = NULL;
  371. /* Holds the old poweroff function so we can restore it on removal. */
  372. static void (*old_poweroff_func)(void);
  373. /* Called on a powerdown request. */
  374. static void ipmi_poweroff_function (void)
  375. {
  376. if (!ready)
  377. return;
  378. /* Use run-to-completion mode, since interrupts may be off. */
  379. ipmi_user_set_run_to_completion(ipmi_user, 1);
  380. specific_poweroff_func(ipmi_user);
  381. ipmi_user_set_run_to_completion(ipmi_user, 0);
  382. }
  383. /* Wait for an IPMI interface to be installed, the first one installed
  384. will be grabbed by this code and used to perform the powerdown. */
  385. static void ipmi_po_new_smi(int if_num)
  386. {
  387. struct ipmi_system_interface_addr smi_addr;
  388. struct kernel_ipmi_msg send_msg;
  389. int rv;
  390. int i;
  391. if (ready)
  392. return;
  393. rv = ipmi_create_user(if_num, &ipmi_poweroff_handler, NULL,
  394. &ipmi_user);
  395. if (rv) {
  396. printk(KERN_ERR PFX "could not create IPMI user, error %d\n",
  397. rv);
  398. return;
  399. }
  400. /*
  401. * Do a get device ide and store some results, since this is
  402. * used by several functions.
  403. */
  404. smi_addr.addr_type = IPMI_SYSTEM_INTERFACE_ADDR_TYPE;
  405. smi_addr.channel = IPMI_BMC_CHANNEL;
  406. smi_addr.lun = 0;
  407. send_msg.netfn = IPMI_NETFN_APP_REQUEST;
  408. send_msg.cmd = IPMI_GET_DEVICE_ID_CMD;
  409. send_msg.data = NULL;
  410. send_msg.data_len = 0;
  411. rv = ipmi_request_wait_for_response(ipmi_user,
  412. (struct ipmi_addr *) &smi_addr,
  413. &send_msg);
  414. if (rv) {
  415. printk(KERN_ERR PFX "Unable to send IPMI get device id info,"
  416. " IPMI error 0x%x\n", rv);
  417. goto out_err;
  418. }
  419. if (halt_recv_msg.msg.data_len < 12) {
  420. printk(KERN_ERR PFX "(chassis) IPMI get device id info too,"
  421. " short, was %d bytes, needed %d bytes\n",
  422. halt_recv_msg.msg.data_len, 12);
  423. goto out_err;
  424. }
  425. mfg_id = (halt_recv_msg.msg.data[7]
  426. | (halt_recv_msg.msg.data[8] << 8)
  427. | (halt_recv_msg.msg.data[9] << 16));
  428. prod_id = (halt_recv_msg.msg.data[10]
  429. | (halt_recv_msg.msg.data[11] << 8));
  430. capabilities = halt_recv_msg.msg.data[6];
  431. /* Scan for a poweroff method */
  432. for (i=0; i<NUM_PO_FUNCS; i++) {
  433. if (poweroff_functions[i].detect(ipmi_user))
  434. goto found;
  435. }
  436. out_err:
  437. printk(KERN_ERR PFX "Unable to find a poweroff function that"
  438. " will work, giving up\n");
  439. ipmi_destroy_user(ipmi_user);
  440. return;
  441. found:
  442. printk(KERN_INFO PFX "Found a %s style poweroff function\n",
  443. poweroff_functions[i].platform_type);
  444. specific_poweroff_func = poweroff_functions[i].poweroff_func;
  445. old_poweroff_func = pm_power_off;
  446. pm_power_off = ipmi_poweroff_function;
  447. ready = 1;
  448. }
  449. static void ipmi_po_smi_gone(int if_num)
  450. {
  451. /* This can never be called, because once poweroff driver is
  452. registered, the interface can't go away until the power
  453. driver is unregistered. */
  454. }
  455. static struct ipmi_smi_watcher smi_watcher =
  456. {
  457. .owner = THIS_MODULE,
  458. .new_smi = ipmi_po_new_smi,
  459. .smi_gone = ipmi_po_smi_gone
  460. };
  461. #ifdef CONFIG_PROC_FS
  462. /* displays properties to proc */
  463. static int proc_read_chassctrl(char *page, char **start, off_t off, int count,
  464. int *eof, void *data)
  465. {
  466. return sprintf(page, "%d\t[ 0=powerdown 2=powercycle ]\n",
  467. poweroff_control);
  468. }
  469. /* process property writes from proc */
  470. static int proc_write_chassctrl(struct file *file, const char *buffer,
  471. unsigned long count, void *data)
  472. {
  473. int rv = count;
  474. unsigned int newval = 0;
  475. sscanf(buffer, "%d", &newval);
  476. switch (newval) {
  477. case IPMI_CHASSIS_POWER_CYCLE:
  478. printk(KERN_INFO PFX "power cycle is now enabled\n");
  479. poweroff_control = newval;
  480. break;
  481. case IPMI_CHASSIS_POWER_DOWN:
  482. poweroff_control = IPMI_CHASSIS_POWER_DOWN;
  483. break;
  484. default:
  485. rv = -EINVAL;
  486. break;
  487. }
  488. return rv;
  489. }
  490. #endif /* CONFIG_PROC_FS */
  491. /*
  492. * Startup and shutdown functions.
  493. */
  494. static int ipmi_poweroff_init (void)
  495. {
  496. int rv;
  497. struct proc_dir_entry *file;
  498. printk ("Copyright (C) 2004 MontaVista Software -"
  499. " IPMI Powerdown via sys_reboot.\n");
  500. switch (poweroff_control) {
  501. case IPMI_CHASSIS_POWER_CYCLE:
  502. printk(KERN_INFO PFX "Power cycle is enabled.\n");
  503. break;
  504. case IPMI_CHASSIS_POWER_DOWN:
  505. default:
  506. poweroff_control = IPMI_CHASSIS_POWER_DOWN;
  507. break;
  508. }
  509. rv = ipmi_smi_watcher_register(&smi_watcher);
  510. if (rv) {
  511. printk(KERN_ERR PFX "Unable to register SMI watcher: %d\n", rv);
  512. goto out_err;
  513. }
  514. #ifdef CONFIG_PROC_FS
  515. file = create_proc_entry("poweroff_control", 0, proc_ipmi_root);
  516. if (!file) {
  517. printk(KERN_ERR PFX "Unable to create proc power control\n");
  518. } else {
  519. file->nlink = 1;
  520. file->read_proc = proc_read_chassctrl;
  521. file->write_proc = proc_write_chassctrl;
  522. file->owner = THIS_MODULE;
  523. }
  524. #endif
  525. out_err:
  526. return rv;
  527. }
  528. #ifdef MODULE
  529. static __exit void ipmi_poweroff_cleanup(void)
  530. {
  531. int rv;
  532. #ifdef CONFIG_PROC_FS
  533. remove_proc_entry("poweroff_control", proc_ipmi_root);
  534. #endif
  535. ipmi_smi_watcher_unregister(&smi_watcher);
  536. if (ready) {
  537. rv = ipmi_destroy_user(ipmi_user);
  538. if (rv)
  539. printk(KERN_ERR PFX "could not cleanup the IPMI"
  540. " user: 0x%x\n", rv);
  541. pm_power_off = old_poweroff_func;
  542. }
  543. }
  544. module_exit(ipmi_poweroff_cleanup);
  545. #endif
  546. module_init(ipmi_poweroff_init);
  547. MODULE_LICENSE("GPL");
  548. MODULE_AUTHOR("Corey Minyard <minyard@mvista.com>");
  549. MODULE_DESCRIPTION("IPMI Poweroff extension to sys_reboot");