pciehp_core.c 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636
  1. /*
  2. * PCI Express 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 "pciehp.h"
  41. #include <linux/interrupt.h>
  42. /* Global variables */
  43. int pciehp_debug;
  44. int pciehp_poll_mode;
  45. int pciehp_poll_time;
  46. struct controller *pciehp_ctrl_list;
  47. struct pci_func *pciehp_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 "PCI Express Hot Plug Controller Driver"
  51. MODULE_AUTHOR(DRIVER_AUTHOR);
  52. MODULE_DESCRIPTION(DRIVER_DESC);
  53. MODULE_LICENSE("GPL");
  54. module_param(pciehp_debug, bool, 0644);
  55. module_param(pciehp_poll_mode, bool, 0644);
  56. module_param(pciehp_poll_time, int, 0644);
  57. MODULE_PARM_DESC(pciehp_debug, "Debugging mode enabled or not");
  58. MODULE_PARM_DESC(pciehp_poll_mode, "Using polling mechanism for hot-plug events or not");
  59. MODULE_PARM_DESC(pciehp_poll_time, "Polling mechanism frequency, in seconds");
  60. #define PCIE_MODULE_NAME "pciehp"
  61. static int pcie_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 pciehp_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;
  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 = kmalloc(sizeof(*new_slot), GFP_KERNEL);
  109. if (!new_slot)
  110. goto error;
  111. memset(new_slot, 0, sizeof(struct slot));
  112. new_slot->hotplug_slot =
  113. kmalloc(sizeof(*(new_slot->hotplug_slot)),
  114. GFP_KERNEL);
  115. if (!new_slot->hotplug_slot)
  116. goto error_slot;
  117. memset(new_slot->hotplug_slot, 0, sizeof(struct hotplug_slot));
  118. new_slot->hotplug_slot->info =
  119. kmalloc(sizeof(*(new_slot->hotplug_slot->info)),
  120. GFP_KERNEL);
  121. if (!new_slot->hotplug_slot->info)
  122. goto error_hpslot;
  123. memset(new_slot->hotplug_slot->info, 0,
  124. sizeof(struct hotplug_slot_info));
  125. new_slot->hotplug_slot->name = kmalloc(SLOT_NAME_SIZE,
  126. GFP_KERNEL);
  127. if (!new_slot->hotplug_slot->name)
  128. goto error_info;
  129. new_slot->ctrl = ctrl;
  130. new_slot->bus = ctrl->slot_bus;
  131. new_slot->device = slot_device;
  132. new_slot->hpc_ops = ctrl->hpc_ops;
  133. new_slot->number = ctrl->first_slot;
  134. new_slot->hp_slot = slot_device - ctrl->slot_device_offset;
  135. /* register this slot with the hotplug pci core */
  136. new_slot->hotplug_slot->private = new_slot;
  137. new_slot->hotplug_slot->release = &release_slot;
  138. make_slot_name(new_slot->hotplug_slot->name, SLOT_NAME_SIZE, new_slot);
  139. new_slot->hotplug_slot->ops = &pciehp_hotplug_slot_ops;
  140. new_slot->hpc_ops->get_power_status(new_slot, &(new_slot->hotplug_slot->info->power_status));
  141. new_slot->hpc_ops->get_attention_status(new_slot, &(new_slot->hotplug_slot->info->attention_status));
  142. new_slot->hpc_ops->get_latch_status(new_slot, &(new_slot->hotplug_slot->info->latch_status));
  143. new_slot->hpc_ops->get_adapter_status(new_slot, &(new_slot->hotplug_slot->info->adapter_status));
  144. dbg("Registering bus=%x dev=%x hp_slot=%x sun=%x slot_device_offset=%x\n",
  145. new_slot->bus, new_slot->device, new_slot->hp_slot, new_slot->number, ctrl->slot_device_offset);
  146. result = pci_hp_register (new_slot->hotplug_slot);
  147. if (result) {
  148. err ("pci_hp_register failed with error %d\n", result);
  149. goto error_name;
  150. }
  151. new_slot->next = ctrl->slot;
  152. ctrl->slot = new_slot;
  153. number_of_slots--;
  154. slot_device++;
  155. slot_number += ctrl->slot_num_inc;
  156. }
  157. return 0;
  158. error_name:
  159. kfree(new_slot->hotplug_slot->name);
  160. error_info:
  161. kfree(new_slot->hotplug_slot->info);
  162. error_hpslot:
  163. kfree(new_slot->hotplug_slot);
  164. error_slot:
  165. kfree(new_slot);
  166. error:
  167. return result;
  168. }
  169. static int cleanup_slots (struct controller * ctrl)
  170. {
  171. struct slot *old_slot, *next_slot;
  172. old_slot = ctrl->slot;
  173. ctrl->slot = NULL;
  174. while (old_slot) {
  175. next_slot = old_slot->next;
  176. pci_hp_deregister (old_slot->hotplug_slot);
  177. old_slot = next_slot;
  178. }
  179. return(0);
  180. }
  181. static int get_ctlr_slot_config(struct controller *ctrl)
  182. {
  183. int num_ctlr_slots; /* Not needed; PCI Express has 1 slot per port*/
  184. int first_device_num; /* Not needed */
  185. int physical_slot_num;
  186. u8 ctrlcap;
  187. int rc;
  188. rc = pcie_get_ctlr_slot_config(ctrl, &num_ctlr_slots, &first_device_num, &physical_slot_num, &ctrlcap);
  189. if (rc) {
  190. err("%s: get_ctlr_slot_config fail for b:d (%x:%x)\n", __FUNCTION__, ctrl->bus, ctrl->device);
  191. return (-1);
  192. }
  193. ctrl->num_slots = num_ctlr_slots; /* PCI Express has 1 slot per port */
  194. ctrl->slot_device_offset = first_device_num;
  195. ctrl->first_slot = physical_slot_num;
  196. ctrl->ctrlcap = ctrlcap;
  197. dbg("%s: bus(0x%x) num_slot(0x%x) 1st_dev(0x%x) psn(0x%x) ctrlcap(%x) for b:d (%x:%x)\n",
  198. __FUNCTION__, ctrl->slot_bus, num_ctlr_slots, first_device_num, physical_slot_num, ctrlcap,
  199. ctrl->bus, ctrl->device);
  200. return (0);
  201. }
  202. /*
  203. * set_attention_status - Turns the Amber LED for a slot on, off or blink
  204. */
  205. static int set_attention_status(struct hotplug_slot *hotplug_slot, u8 status)
  206. {
  207. struct slot *slot = hotplug_slot->private;
  208. dbg("%s - physical_slot = %s\n", __FUNCTION__, hotplug_slot->name);
  209. hotplug_slot->info->attention_status = status;
  210. if (ATTN_LED(slot->ctrl->ctrlcap))
  211. slot->hpc_ops->set_attention_status(slot, status);
  212. return 0;
  213. }
  214. static int enable_slot(struct hotplug_slot *hotplug_slot)
  215. {
  216. struct slot *slot = hotplug_slot->private;
  217. dbg("%s - physical_slot = %s\n", __FUNCTION__, hotplug_slot->name);
  218. return pciehp_enable_slot(slot);
  219. }
  220. static int disable_slot(struct hotplug_slot *hotplug_slot)
  221. {
  222. struct slot *slot = hotplug_slot->private;
  223. dbg("%s - physical_slot = %s\n", __FUNCTION__, hotplug_slot->name);
  224. return pciehp_disable_slot(slot);
  225. }
  226. static int get_power_status(struct hotplug_slot *hotplug_slot, u8 *value)
  227. {
  228. struct slot *slot = hotplug_slot->private;
  229. int retval;
  230. dbg("%s - physical_slot = %s\n", __FUNCTION__, hotplug_slot->name);
  231. retval = slot->hpc_ops->get_power_status(slot, value);
  232. if (retval < 0)
  233. *value = hotplug_slot->info->power_status;
  234. return 0;
  235. }
  236. static int get_attention_status(struct hotplug_slot *hotplug_slot, u8 *value)
  237. {
  238. struct slot *slot = hotplug_slot->private;
  239. int retval;
  240. dbg("%s - physical_slot = %s\n", __FUNCTION__, hotplug_slot->name);
  241. retval = slot->hpc_ops->get_attention_status(slot, value);
  242. if (retval < 0)
  243. *value = hotplug_slot->info->attention_status;
  244. return 0;
  245. }
  246. static int get_latch_status(struct hotplug_slot *hotplug_slot, u8 *value)
  247. {
  248. struct slot *slot = hotplug_slot->private;
  249. int retval;
  250. dbg("%s - physical_slot = %s\n", __FUNCTION__, hotplug_slot->name);
  251. retval = slot->hpc_ops->get_latch_status(slot, value);
  252. if (retval < 0)
  253. *value = hotplug_slot->info->latch_status;
  254. return 0;
  255. }
  256. static int get_adapter_status(struct hotplug_slot *hotplug_slot, u8 *value)
  257. {
  258. struct slot *slot = hotplug_slot->private;
  259. int retval;
  260. dbg("%s - physical_slot = %s\n", __FUNCTION__, hotplug_slot->name);
  261. retval = slot->hpc_ops->get_adapter_status(slot, value);
  262. if (retval < 0)
  263. *value = hotplug_slot->info->adapter_status;
  264. return 0;
  265. }
  266. static int get_max_bus_speed(struct hotplug_slot *hotplug_slot, enum pci_bus_speed *value)
  267. {
  268. struct slot *slot = hotplug_slot->private;
  269. int retval;
  270. dbg("%s - physical_slot = %s\n", __FUNCTION__, hotplug_slot->name);
  271. retval = slot->hpc_ops->get_max_bus_speed(slot, value);
  272. if (retval < 0)
  273. *value = PCI_SPEED_UNKNOWN;
  274. return 0;
  275. }
  276. static int get_cur_bus_speed(struct hotplug_slot *hotplug_slot, enum pci_bus_speed *value)
  277. {
  278. struct slot *slot = hotplug_slot->private;
  279. int retval;
  280. dbg("%s - physical_slot = %s\n", __FUNCTION__, hotplug_slot->name);
  281. retval = slot->hpc_ops->get_cur_bus_speed(slot, value);
  282. if (retval < 0)
  283. *value = PCI_SPEED_UNKNOWN;
  284. return 0;
  285. }
  286. static int pciehp_probe(struct pcie_device *dev, const struct pcie_port_service_id *id)
  287. {
  288. int rc;
  289. struct controller *ctrl;
  290. struct slot *t_slot;
  291. int first_device_num = 0 ; /* first PCI device number supported by this PCIE */
  292. int num_ctlr_slots; /* number of slots supported by this HPC */
  293. u8 value;
  294. struct pci_dev *pdev;
  295. dbg("%s: Called by hp_drv\n", __FUNCTION__);
  296. ctrl = kmalloc(sizeof(*ctrl), GFP_KERNEL);
  297. if (!ctrl) {
  298. err("%s : out of memory\n", __FUNCTION__);
  299. goto err_out_none;
  300. }
  301. memset(ctrl, 0, sizeof(struct controller));
  302. dbg("%s: DRV_thread pid = %d\n", __FUNCTION__, current->pid);
  303. pdev = dev->port;
  304. ctrl->pci_dev = pdev;
  305. rc = pcie_init(ctrl, dev,
  306. (php_intr_callback_t) pciehp_handle_attention_button,
  307. (php_intr_callback_t) pciehp_handle_switch_change,
  308. (php_intr_callback_t) pciehp_handle_presence_change,
  309. (php_intr_callback_t) pciehp_handle_power_fault);
  310. if (rc) {
  311. dbg("%s: controller initialization failed\n", PCIE_MODULE_NAME);
  312. goto err_out_free_ctrl;
  313. }
  314. pci_set_drvdata(pdev, ctrl);
  315. ctrl->pci_bus = kmalloc(sizeof(*ctrl->pci_bus), GFP_KERNEL);
  316. if (!ctrl->pci_bus) {
  317. err("%s: out of memory\n", __FUNCTION__);
  318. rc = -ENOMEM;
  319. goto err_out_unmap_mmio_region;
  320. }
  321. dbg("%s: ctrl->pci_bus %p\n", __FUNCTION__, ctrl->pci_bus);
  322. memcpy (ctrl->pci_bus, pdev->bus, sizeof (*ctrl->pci_bus));
  323. ctrl->bus = pdev->bus->number; /* ctrl bus */
  324. ctrl->slot_bus = pdev->subordinate->number; /* bus controlled by this HPC */
  325. ctrl->device = PCI_SLOT(pdev->devfn);
  326. ctrl->function = PCI_FUNC(pdev->devfn);
  327. dbg("%s: ctrl bus=0x%x, device=%x, function=%x, irq=%x\n", __FUNCTION__,
  328. ctrl->bus, ctrl->device, ctrl->function, pdev->irq);
  329. /*
  330. * Save configuration headers for this and subordinate PCI buses
  331. */
  332. rc = get_ctlr_slot_config(ctrl);
  333. if (rc) {
  334. err(msg_initialization_err, rc);
  335. goto err_out_free_ctrl_bus;
  336. }
  337. first_device_num = ctrl->slot_device_offset;
  338. num_ctlr_slots = ctrl->num_slots;
  339. /* Store PCI Config Space for all devices on this bus */
  340. dbg("%s: Before calling pciehp_save_config, ctrl->bus %x,ctrl->slot_bus %x\n",
  341. __FUNCTION__,ctrl->bus, ctrl->slot_bus);
  342. rc = pciehp_save_config(ctrl, ctrl->slot_bus, num_ctlr_slots, first_device_num);
  343. if (rc) {
  344. err("%s: unable to save PCI configuration data, error %d\n", __FUNCTION__, rc);
  345. goto err_out_free_ctrl_bus;
  346. }
  347. ctrl->add_support = 1;
  348. /* Setup the slot information structures */
  349. rc = init_slots(ctrl);
  350. if (rc) {
  351. err(msg_initialization_err, 6);
  352. goto err_out_free_ctrl_slot;
  353. }
  354. t_slot = pciehp_find_slot(ctrl, first_device_num);
  355. dbg("%s: t_slot %p\n", __FUNCTION__, t_slot);
  356. /* Finish setting up the hot plug ctrl device */
  357. ctrl->next_event = 0;
  358. if (!pciehp_ctrl_list) {
  359. pciehp_ctrl_list = ctrl;
  360. ctrl->next = NULL;
  361. } else {
  362. ctrl->next = pciehp_ctrl_list;
  363. pciehp_ctrl_list = ctrl;
  364. }
  365. /* Wait for exclusive access to hardware */
  366. down(&ctrl->crit_sect);
  367. t_slot->hpc_ops->get_adapter_status(t_slot, &value); /* Check if slot is occupied */
  368. dbg("%s: adpater value %x\n", __FUNCTION__, value);
  369. if ((POWER_CTRL(ctrl->ctrlcap)) && !value) {
  370. rc = t_slot->hpc_ops->power_off_slot(t_slot); /* Power off slot if not occupied*/
  371. if (rc) {
  372. /* Done with exclusive hardware access */
  373. up(&ctrl->crit_sect);
  374. goto err_out_free_ctrl_slot;
  375. } else
  376. /* Wait for the command to complete */
  377. wait_for_ctrl_irq (ctrl);
  378. }
  379. /* Done with exclusive hardware access */
  380. up(&ctrl->crit_sect);
  381. return 0;
  382. err_out_free_ctrl_slot:
  383. cleanup_slots(ctrl);
  384. err_out_free_ctrl_bus:
  385. kfree(ctrl->pci_bus);
  386. err_out_unmap_mmio_region:
  387. ctrl->hpc_ops->release_ctlr(ctrl);
  388. err_out_free_ctrl:
  389. kfree(ctrl);
  390. err_out_none:
  391. return -ENODEV;
  392. }
  393. static int pcie_start_thread(void)
  394. {
  395. int loop;
  396. int retval = 0;
  397. dbg("Initialize + Start the notification/polling mechanism \n");
  398. retval = pciehp_event_start_thread();
  399. if (retval) {
  400. dbg("pciehp_event_start_thread() failed\n");
  401. return retval;
  402. }
  403. dbg("Initialize slot lists\n");
  404. /* One slot list for each bus in the system */
  405. for (loop = 0; loop < 256; loop++) {
  406. pciehp_slot_list[loop] = NULL;
  407. }
  408. return retval;
  409. }
  410. static void __exit unload_pciehpd(void)
  411. {
  412. struct pci_func *next;
  413. struct pci_func *TempSlot;
  414. int loop;
  415. struct controller *ctrl;
  416. struct controller *tctrl;
  417. ctrl = pciehp_ctrl_list;
  418. while (ctrl) {
  419. cleanup_slots(ctrl);
  420. kfree (ctrl->pci_bus);
  421. ctrl->hpc_ops->release_ctlr(ctrl);
  422. tctrl = ctrl;
  423. ctrl = ctrl->next;
  424. kfree(tctrl);
  425. }
  426. for (loop = 0; loop < 256; loop++) {
  427. next = pciehp_slot_list[loop];
  428. while (next != NULL) {
  429. TempSlot = next;
  430. next = next->next;
  431. kfree(TempSlot);
  432. }
  433. }
  434. /* Stop the notification mechanism */
  435. pciehp_event_stop_thread();
  436. }
  437. int hpdriver_context = 0;
  438. static void pciehp_remove (struct pcie_device *device)
  439. {
  440. printk("%s ENTRY\n", __FUNCTION__);
  441. printk("%s -> Call free_irq for irq = %d\n",
  442. __FUNCTION__, device->irq);
  443. free_irq(device->irq, &hpdriver_context);
  444. }
  445. #ifdef CONFIG_PM
  446. static int pciehp_suspend (struct pcie_device *dev, pm_message_t state)
  447. {
  448. printk("%s ENTRY\n", __FUNCTION__);
  449. return 0;
  450. }
  451. static int pciehp_resume (struct pcie_device *dev)
  452. {
  453. printk("%s ENTRY\n", __FUNCTION__);
  454. return 0;
  455. }
  456. #endif
  457. static struct pcie_port_service_id port_pci_ids[] = { {
  458. .vendor = PCI_ANY_ID,
  459. .device = PCI_ANY_ID,
  460. .port_type = PCIE_ANY_PORT,
  461. .service_type = PCIE_PORT_SERVICE_HP,
  462. .driver_data = 0,
  463. }, { /* end: all zeroes */ }
  464. };
  465. static const char device_name[] = "hpdriver";
  466. static struct pcie_port_service_driver hpdriver_portdrv = {
  467. .name = (char *)device_name,
  468. .id_table = &port_pci_ids[0],
  469. .probe = pciehp_probe,
  470. .remove = pciehp_remove,
  471. #ifdef CONFIG_PM
  472. .suspend = pciehp_suspend,
  473. .resume = pciehp_resume,
  474. #endif /* PM */
  475. };
  476. static int __init pcied_init(void)
  477. {
  478. int retval = 0;
  479. #ifdef CONFIG_HOTPLUG_PCI_PCIE_POLL_EVENT_MODE
  480. pciehp_poll_mode = 1;
  481. #endif
  482. retval = pcie_start_thread();
  483. if (retval)
  484. goto error_hpc_init;
  485. retval = pcie_port_service_register(&hpdriver_portdrv);
  486. dbg("pcie_port_service_register = %d\n", retval);
  487. info(DRIVER_DESC " version: " DRIVER_VERSION "\n");
  488. if (retval)
  489. dbg("%s: Failure to register service\n", __FUNCTION__);
  490. error_hpc_init:
  491. if (retval) {
  492. pciehp_event_stop_thread();
  493. };
  494. return retval;
  495. }
  496. static void __exit pcied_cleanup(void)
  497. {
  498. dbg("unload_pciehpd()\n");
  499. unload_pciehpd();
  500. dbg("pcie_port_service_unregister\n");
  501. pcie_port_service_unregister(&hpdriver_portdrv);
  502. info(DRIVER_DESC " version: " DRIVER_VERSION " unloaded\n");
  503. }
  504. module_init(pcied_init);
  505. module_exit(pcied_cleanup);