shpchp_core.c 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630
  1. /*
  2. * Standard Hot Plug Controller Driver
  3. *
  4. * Copyright (C) 1995,2001 Compaq Computer Corporation
  5. * Copyright (C) 2001 Greg Kroah-Hartman (greg@kroah.com)
  6. * Copyright (C) 2001 IBM Corp.
  7. * Copyright (C) 2003-2004 Intel Corporation
  8. *
  9. * All rights reserved.
  10. *
  11. * This program is free software; you can redistribute it and/or modify
  12. * it under the terms of the GNU General Public License as published by
  13. * the Free Software Foundation; either version 2 of the License, or (at
  14. * your option) any later version.
  15. *
  16. * This program is distributed in the hope that it will be useful, but
  17. * WITHOUT ANY WARRANTY; without even the implied warranty of
  18. * MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE, GOOD TITLE or
  19. * NON INFRINGEMENT. See the GNU General Public License for more
  20. * details.
  21. *
  22. * You should have received a copy of the GNU General Public License
  23. * along with this program; if not, write to the Free Software
  24. * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  25. *
  26. * Send feedback to <greg@kroah.com>, <kristen.c.accardi@intel.com>
  27. *
  28. */
  29. #include <linux/config.h>
  30. #include <linux/module.h>
  31. #include <linux/moduleparam.h>
  32. #include <linux/kernel.h>
  33. #include <linux/types.h>
  34. #include <linux/proc_fs.h>
  35. #include <linux/slab.h>
  36. #include <linux/workqueue.h>
  37. #include <linux/pci.h>
  38. #include <linux/init.h>
  39. #include <asm/uaccess.h>
  40. #include "shpchp.h"
  41. #include "shpchprm.h"
  42. /* Global variables */
  43. int shpchp_debug;
  44. int shpchp_poll_mode;
  45. int shpchp_poll_time;
  46. struct controller *shpchp_ctrl_list; /* = NULL */
  47. struct pci_func *shpchp_slot_list[256];
  48. #define DRIVER_VERSION "0.4"
  49. #define DRIVER_AUTHOR "Dan Zink <dan.zink@compaq.com>, Greg Kroah-Hartman <greg@kroah.com>, Dely Sy <dely.l.sy@intel.com>"
  50. #define DRIVER_DESC "Standard Hot Plug PCI Controller Driver"
  51. MODULE_AUTHOR(DRIVER_AUTHOR);
  52. MODULE_DESCRIPTION(DRIVER_DESC);
  53. MODULE_LICENSE("GPL");
  54. module_param(shpchp_debug, bool, 0644);
  55. module_param(shpchp_poll_mode, bool, 0644);
  56. module_param(shpchp_poll_time, int, 0644);
  57. MODULE_PARM_DESC(shpchp_debug, "Debugging mode enabled or not");
  58. MODULE_PARM_DESC(shpchp_poll_mode, "Using polling mechanism for hot-plug events or not");
  59. MODULE_PARM_DESC(shpchp_poll_time, "Polling mechanism frequency, in seconds");
  60. #define SHPC_MODULE_NAME "shpchp"
  61. static int shpc_start_thread (void);
  62. static int set_attention_status (struct hotplug_slot *slot, u8 value);
  63. static int enable_slot (struct hotplug_slot *slot);
  64. static int disable_slot (struct hotplug_slot *slot);
  65. static int get_power_status (struct hotplug_slot *slot, u8 *value);
  66. static int get_attention_status (struct hotplug_slot *slot, u8 *value);
  67. static int get_latch_status (struct hotplug_slot *slot, u8 *value);
  68. static int get_adapter_status (struct hotplug_slot *slot, u8 *value);
  69. static int get_max_bus_speed (struct hotplug_slot *slot, enum pci_bus_speed *value);
  70. static int get_cur_bus_speed (struct hotplug_slot *slot, enum pci_bus_speed *value);
  71. static struct hotplug_slot_ops shpchp_hotplug_slot_ops = {
  72. .owner = THIS_MODULE,
  73. .set_attention_status = set_attention_status,
  74. .enable_slot = enable_slot,
  75. .disable_slot = disable_slot,
  76. .get_power_status = get_power_status,
  77. .get_attention_status = get_attention_status,
  78. .get_latch_status = get_latch_status,
  79. .get_adapter_status = get_adapter_status,
  80. .get_max_bus_speed = get_max_bus_speed,
  81. .get_cur_bus_speed = get_cur_bus_speed,
  82. };
  83. /**
  84. * release_slot - free up the memory used by a slot
  85. * @hotplug_slot: slot to free
  86. */
  87. static void release_slot(struct hotplug_slot *hotplug_slot)
  88. {
  89. struct slot *slot = hotplug_slot->private;
  90. dbg("%s - physical_slot = %s\n", __FUNCTION__, hotplug_slot->name);
  91. kfree(slot->hotplug_slot->info);
  92. kfree(slot->hotplug_slot->name);
  93. kfree(slot->hotplug_slot);
  94. kfree(slot);
  95. }
  96. static int init_slots(struct controller *ctrl)
  97. {
  98. struct slot *new_slot;
  99. u8 number_of_slots;
  100. u8 slot_device;
  101. u32 slot_number, sun;
  102. int result = -ENOMEM;
  103. dbg("%s\n",__FUNCTION__);
  104. number_of_slots = ctrl->num_slots;
  105. slot_device = ctrl->slot_device_offset;
  106. slot_number = ctrl->first_slot;
  107. while (number_of_slots) {
  108. new_slot = (struct slot *) kmalloc(sizeof(struct slot), GFP_KERNEL);
  109. if (!new_slot)
  110. goto error;
  111. memset(new_slot, 0, sizeof(struct slot));
  112. new_slot->hotplug_slot = kmalloc (sizeof (struct hotplug_slot), GFP_KERNEL);
  113. if (!new_slot->hotplug_slot)
  114. goto error_slot;
  115. memset(new_slot->hotplug_slot, 0, sizeof (struct hotplug_slot));
  116. new_slot->hotplug_slot->info = kmalloc (sizeof (struct hotplug_slot_info), GFP_KERNEL);
  117. if (!new_slot->hotplug_slot->info)
  118. goto error_hpslot;
  119. memset(new_slot->hotplug_slot->info, 0, sizeof (struct hotplug_slot_info));
  120. new_slot->hotplug_slot->name = kmalloc (SLOT_NAME_SIZE, GFP_KERNEL);
  121. if (!new_slot->hotplug_slot->name)
  122. goto error_info;
  123. new_slot->magic = SLOT_MAGIC;
  124. new_slot->ctrl = ctrl;
  125. new_slot->bus = ctrl->slot_bus;
  126. new_slot->device = slot_device;
  127. new_slot->hpc_ops = ctrl->hpc_ops;
  128. if (shpchprm_get_physical_slot_number(ctrl, &sun,
  129. new_slot->bus, new_slot->device))
  130. goto error_name;
  131. new_slot->number = sun;
  132. new_slot->hp_slot = slot_device - ctrl->slot_device_offset;
  133. /* register this slot with the hotplug pci core */
  134. new_slot->hotplug_slot->private = new_slot;
  135. new_slot->hotplug_slot->release = &release_slot;
  136. make_slot_name(new_slot->hotplug_slot->name, SLOT_NAME_SIZE, new_slot);
  137. new_slot->hotplug_slot->ops = &shpchp_hotplug_slot_ops;
  138. new_slot->hpc_ops->get_power_status(new_slot, &(new_slot->hotplug_slot->info->power_status));
  139. new_slot->hpc_ops->get_attention_status(new_slot, &(new_slot->hotplug_slot->info->attention_status));
  140. new_slot->hpc_ops->get_latch_status(new_slot, &(new_slot->hotplug_slot->info->latch_status));
  141. new_slot->hpc_ops->get_adapter_status(new_slot, &(new_slot->hotplug_slot->info->adapter_status));
  142. dbg("Registering bus=%x dev=%x hp_slot=%x sun=%x slot_device_offset=%x\n", new_slot->bus,
  143. new_slot->device, new_slot->hp_slot, new_slot->number, ctrl->slot_device_offset);
  144. result = pci_hp_register (new_slot->hotplug_slot);
  145. if (result) {
  146. err ("pci_hp_register failed with error %d\n", result);
  147. goto error_name;
  148. }
  149. new_slot->next = ctrl->slot;
  150. ctrl->slot = new_slot;
  151. number_of_slots--;
  152. slot_device++;
  153. slot_number += ctrl->slot_num_inc;
  154. }
  155. return 0;
  156. error_name:
  157. kfree(new_slot->hotplug_slot->name);
  158. error_info:
  159. kfree(new_slot->hotplug_slot->info);
  160. error_hpslot:
  161. kfree(new_slot->hotplug_slot);
  162. error_slot:
  163. kfree(new_slot);
  164. error:
  165. return result;
  166. }
  167. static void cleanup_slots(struct controller *ctrl)
  168. {
  169. struct slot *old_slot, *next_slot;
  170. old_slot = ctrl->slot;
  171. ctrl->slot = NULL;
  172. while (old_slot) {
  173. next_slot = old_slot->next;
  174. pci_hp_deregister(old_slot->hotplug_slot);
  175. old_slot = next_slot;
  176. }
  177. }
  178. static int get_ctlr_slot_config(struct controller *ctrl)
  179. {
  180. int num_ctlr_slots;
  181. int first_device_num;
  182. int physical_slot_num;
  183. int updown;
  184. int rc;
  185. int flags;
  186. rc = shpc_get_ctlr_slot_config(ctrl, &num_ctlr_slots, &first_device_num, &physical_slot_num, &updown, &flags);
  187. if (rc) {
  188. err("%s: get_ctlr_slot_config fail for b:d (%x:%x)\n", __FUNCTION__, ctrl->bus, ctrl->device);
  189. return -1;
  190. }
  191. ctrl->num_slots = num_ctlr_slots;
  192. ctrl->slot_device_offset = first_device_num;
  193. ctrl->first_slot = physical_slot_num;
  194. ctrl->slot_num_inc = updown; /* either -1 or 1 */
  195. dbg("%s: num_slot(0x%x) 1st_dev(0x%x) psn(0x%x) updown(%d) for b:d (%x:%x)\n",
  196. __FUNCTION__, num_ctlr_slots, first_device_num, physical_slot_num, updown, ctrl->bus, ctrl->device);
  197. return 0;
  198. }
  199. /*
  200. * set_attention_status - Turns the Amber LED for a slot on, off or blink
  201. */
  202. static int set_attention_status (struct hotplug_slot *hotplug_slot, u8 status)
  203. {
  204. struct slot *slot = get_slot (hotplug_slot, __FUNCTION__);
  205. dbg("%s - physical_slot = %s\n", __FUNCTION__, hotplug_slot->name);
  206. hotplug_slot->info->attention_status = status;
  207. slot->hpc_ops->set_attention_status(slot, status);
  208. return 0;
  209. }
  210. static int enable_slot (struct hotplug_slot *hotplug_slot)
  211. {
  212. struct slot *slot = get_slot (hotplug_slot, __FUNCTION__);
  213. dbg("%s - physical_slot = %s\n", __FUNCTION__, hotplug_slot->name);
  214. return shpchp_enable_slot(slot);
  215. }
  216. static int disable_slot (struct hotplug_slot *hotplug_slot)
  217. {
  218. struct slot *slot = get_slot (hotplug_slot, __FUNCTION__);
  219. dbg("%s - physical_slot = %s\n", __FUNCTION__, hotplug_slot->name);
  220. return shpchp_disable_slot(slot);
  221. }
  222. static int get_power_status (struct hotplug_slot *hotplug_slot, u8 *value)
  223. {
  224. struct slot *slot = get_slot (hotplug_slot, __FUNCTION__);
  225. int retval;
  226. dbg("%s - physical_slot = %s\n", __FUNCTION__, hotplug_slot->name);
  227. retval = slot->hpc_ops->get_power_status(slot, value);
  228. if (retval < 0)
  229. *value = hotplug_slot->info->power_status;
  230. return 0;
  231. }
  232. static int get_attention_status (struct hotplug_slot *hotplug_slot, u8 *value)
  233. {
  234. struct slot *slot = get_slot (hotplug_slot, __FUNCTION__);
  235. int retval;
  236. dbg("%s - physical_slot = %s\n", __FUNCTION__, hotplug_slot->name);
  237. retval = slot->hpc_ops->get_attention_status(slot, value);
  238. if (retval < 0)
  239. *value = hotplug_slot->info->attention_status;
  240. return 0;
  241. }
  242. static int get_latch_status (struct hotplug_slot *hotplug_slot, u8 *value)
  243. {
  244. struct slot *slot = get_slot (hotplug_slot, __FUNCTION__);
  245. int retval;
  246. dbg("%s - physical_slot = %s\n", __FUNCTION__, hotplug_slot->name);
  247. retval = slot->hpc_ops->get_latch_status(slot, value);
  248. if (retval < 0)
  249. *value = hotplug_slot->info->latch_status;
  250. return 0;
  251. }
  252. static int get_adapter_status (struct hotplug_slot *hotplug_slot, u8 *value)
  253. {
  254. struct slot *slot = get_slot (hotplug_slot, __FUNCTION__);
  255. int retval;
  256. dbg("%s - physical_slot = %s\n", __FUNCTION__, hotplug_slot->name);
  257. retval = slot->hpc_ops->get_adapter_status(slot, value);
  258. if (retval < 0)
  259. *value = hotplug_slot->info->adapter_status;
  260. return 0;
  261. }
  262. static int get_max_bus_speed (struct hotplug_slot *hotplug_slot, enum pci_bus_speed *value)
  263. {
  264. struct slot *slot = get_slot (hotplug_slot, __FUNCTION__);
  265. int retval;
  266. dbg("%s - physical_slot = %s\n", __FUNCTION__, hotplug_slot->name);
  267. retval = slot->hpc_ops->get_max_bus_speed(slot, value);
  268. if (retval < 0)
  269. *value = PCI_SPEED_UNKNOWN;
  270. return 0;
  271. }
  272. static int get_cur_bus_speed (struct hotplug_slot *hotplug_slot, enum pci_bus_speed *value)
  273. {
  274. struct slot *slot = get_slot (hotplug_slot, __FUNCTION__);
  275. int retval;
  276. dbg("%s - physical_slot = %s\n", __FUNCTION__, hotplug_slot->name);
  277. retval = slot->hpc_ops->get_cur_bus_speed(slot, value);
  278. if (retval < 0)
  279. *value = PCI_SPEED_UNKNOWN;
  280. return 0;
  281. }
  282. static int shpc_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
  283. {
  284. int rc;
  285. struct controller *ctrl;
  286. struct slot *t_slot;
  287. int first_device_num; /* first PCI device number supported by this SHPC */
  288. int num_ctlr_slots; /* number of slots supported by this SHPC */
  289. ctrl = (struct controller *) kmalloc(sizeof(struct controller), GFP_KERNEL);
  290. if (!ctrl) {
  291. err("%s : out of memory\n", __FUNCTION__);
  292. goto err_out_none;
  293. }
  294. memset(ctrl, 0, sizeof(struct controller));
  295. dbg("DRV_thread pid = %d\n", current->pid);
  296. rc = shpc_init(ctrl, pdev,
  297. (php_intr_callback_t) shpchp_handle_attention_button,
  298. (php_intr_callback_t) shpchp_handle_switch_change,
  299. (php_intr_callback_t) shpchp_handle_presence_change,
  300. (php_intr_callback_t) shpchp_handle_power_fault);
  301. if (rc) {
  302. dbg("%s: controller initialization failed\n", SHPC_MODULE_NAME);
  303. goto err_out_free_ctrl;
  304. }
  305. dbg("%s: controller initialization success\n", __FUNCTION__);
  306. ctrl->pci_dev = pdev; /* pci_dev of the P2P bridge */
  307. pci_set_drvdata(pdev, ctrl);
  308. ctrl->pci_bus = kmalloc (sizeof (*ctrl->pci_bus), GFP_KERNEL);
  309. if (!ctrl->pci_bus) {
  310. err("out of memory\n");
  311. rc = -ENOMEM;
  312. goto err_out_unmap_mmio_region;
  313. }
  314. memcpy (ctrl->pci_bus, pdev->bus, sizeof (*ctrl->pci_bus));
  315. ctrl->bus = pdev->bus->number;
  316. ctrl->slot_bus = pdev->subordinate->number;
  317. ctrl->device = PCI_SLOT(pdev->devfn);
  318. ctrl->function = PCI_FUNC(pdev->devfn);
  319. dbg("ctrl bus=0x%x, device=%x, function=%x, irq=%x\n", ctrl->bus, ctrl->device, ctrl->function, pdev->irq);
  320. /*
  321. * Save configuration headers for this and subordinate PCI buses
  322. */
  323. rc = get_ctlr_slot_config(ctrl);
  324. if (rc) {
  325. err(msg_initialization_err, rc);
  326. goto err_out_free_ctrl_bus;
  327. }
  328. first_device_num = ctrl->slot_device_offset;
  329. num_ctlr_slots = ctrl->num_slots;
  330. /* Store PCI Config Space for all devices on this bus */
  331. rc = shpchp_save_config(ctrl, ctrl->slot_bus, num_ctlr_slots, first_device_num);
  332. if (rc) {
  333. err("%s: unable to save PCI configuration data, error %d\n", __FUNCTION__, rc);
  334. goto err_out_free_ctrl_bus;
  335. }
  336. /* Get IO, memory, and IRQ resources for new devices */
  337. rc = shpchprm_find_available_resources(ctrl);
  338. ctrl->add_support = !rc;
  339. if (rc) {
  340. dbg("shpchprm_find_available_resources = %#x\n", rc);
  341. err("unable to locate PCI configuration resources for hot plug add.\n");
  342. goto err_out_free_ctrl_bus;
  343. }
  344. /* Setup the slot information structures */
  345. rc = init_slots(ctrl);
  346. if (rc) {
  347. err(msg_initialization_err, 6);
  348. goto err_out_free_ctrl_slot;
  349. }
  350. /* Now hpc_functions (slot->hpc_ops->functions) are ready */
  351. t_slot = shpchp_find_slot(ctrl, first_device_num);
  352. /* Check for operation bus speed */
  353. rc = t_slot->hpc_ops->get_cur_bus_speed(t_slot, &ctrl->speed);
  354. dbg("%s: t_slot->hp_slot %x\n", __FUNCTION__,t_slot->hp_slot);
  355. if (rc || ctrl->speed == PCI_SPEED_UNKNOWN) {
  356. err(SHPC_MODULE_NAME ": Can't get current bus speed. Set to 33MHz PCI.\n");
  357. ctrl->speed = PCI_SPEED_33MHz;
  358. }
  359. /* Finish setting up the hot plug ctrl device */
  360. ctrl->next_event = 0;
  361. if (!shpchp_ctrl_list) {
  362. shpchp_ctrl_list = ctrl;
  363. ctrl->next = NULL;
  364. } else {
  365. ctrl->next = shpchp_ctrl_list;
  366. shpchp_ctrl_list = ctrl;
  367. }
  368. shpchp_create_ctrl_files(ctrl);
  369. return 0;
  370. err_out_free_ctrl_slot:
  371. cleanup_slots(ctrl);
  372. err_out_free_ctrl_bus:
  373. kfree(ctrl->pci_bus);
  374. err_out_unmap_mmio_region:
  375. ctrl->hpc_ops->release_ctlr(ctrl);
  376. err_out_free_ctrl:
  377. kfree(ctrl);
  378. err_out_none:
  379. return -ENODEV;
  380. }
  381. static int shpc_start_thread(void)
  382. {
  383. int loop;
  384. int retval = 0;
  385. dbg("Initialize + Start the notification/polling mechanism \n");
  386. retval = shpchp_event_start_thread();
  387. if (retval) {
  388. dbg("shpchp_event_start_thread() failed\n");
  389. return retval;
  390. }
  391. dbg("Initialize slot lists\n");
  392. /* One slot list for each bus in the system */
  393. for (loop = 0; loop < 256; loop++) {
  394. shpchp_slot_list[loop] = NULL;
  395. }
  396. return retval;
  397. }
  398. static inline void __exit
  399. free_shpchp_res(struct pci_resource *res)
  400. {
  401. struct pci_resource *tres;
  402. while (res) {
  403. tres = res;
  404. res = res->next;
  405. kfree(tres);
  406. }
  407. }
  408. static void __exit unload_shpchpd(void)
  409. {
  410. struct pci_func *next;
  411. struct pci_func *TempSlot;
  412. int loop;
  413. struct controller *ctrl;
  414. struct controller *tctrl;
  415. ctrl = shpchp_ctrl_list;
  416. while (ctrl) {
  417. cleanup_slots(ctrl);
  418. free_shpchp_res(ctrl->io_head);
  419. free_shpchp_res(ctrl->mem_head);
  420. free_shpchp_res(ctrl->p_mem_head);
  421. free_shpchp_res(ctrl->bus_head);
  422. kfree (ctrl->pci_bus);
  423. dbg("%s: calling release_ctlr\n", __FUNCTION__);
  424. ctrl->hpc_ops->release_ctlr(ctrl);
  425. tctrl = ctrl;
  426. ctrl = ctrl->next;
  427. kfree(tctrl);
  428. }
  429. for (loop = 0; loop < 256; loop++) {
  430. next = shpchp_slot_list[loop];
  431. while (next != NULL) {
  432. free_shpchp_res(next->io_head);
  433. free_shpchp_res(next->mem_head);
  434. free_shpchp_res(next->p_mem_head);
  435. free_shpchp_res(next->bus_head);
  436. TempSlot = next;
  437. next = next->next;
  438. kfree(TempSlot);
  439. }
  440. }
  441. /* Stop the notification mechanism */
  442. shpchp_event_stop_thread();
  443. }
  444. static struct pci_device_id shpcd_pci_tbl[] = {
  445. {
  446. .class = ((PCI_CLASS_BRIDGE_PCI << 8) | 0x00),
  447. .class_mask = ~0,
  448. .vendor = PCI_ANY_ID,
  449. .device = PCI_ANY_ID,
  450. .subvendor = PCI_ANY_ID,
  451. .subdevice = PCI_ANY_ID,
  452. },
  453. { /* end: all zeroes */ }
  454. };
  455. MODULE_DEVICE_TABLE(pci, shpcd_pci_tbl);
  456. static struct pci_driver shpc_driver = {
  457. .name = SHPC_MODULE_NAME,
  458. .id_table = shpcd_pci_tbl,
  459. .probe = shpc_probe,
  460. /* remove: shpc_remove_one, */
  461. };
  462. static int __init shpcd_init(void)
  463. {
  464. int retval = 0;
  465. #ifdef CONFIG_HOTPLUG_PCI_SHPC_POLL_EVENT_MODE
  466. shpchp_poll_mode = 1;
  467. #endif
  468. retval = shpc_start_thread();
  469. if (retval)
  470. goto error_hpc_init;
  471. retval = shpchprm_init(PCI);
  472. if (!retval) {
  473. retval = pci_register_driver(&shpc_driver);
  474. dbg("%s: pci_register_driver = %d\n", __FUNCTION__, retval);
  475. info(DRIVER_DESC " version: " DRIVER_VERSION "\n");
  476. }
  477. error_hpc_init:
  478. if (retval) {
  479. shpchprm_cleanup();
  480. shpchp_event_stop_thread();
  481. } else
  482. shpchprm_print_pirt();
  483. return retval;
  484. }
  485. static void __exit shpcd_cleanup(void)
  486. {
  487. dbg("unload_shpchpd()\n");
  488. unload_shpchpd();
  489. shpchprm_cleanup();
  490. dbg("pci_unregister_driver\n");
  491. pci_unregister_driver(&shpc_driver);
  492. info(DRIVER_DESC " version: " DRIVER_VERSION " unloaded\n");
  493. }
  494. module_init(shpcd_init);
  495. module_exit(shpcd_cleanup);