cpci_hotplug_core.c 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743
  1. /*
  2. * CompactPCI Hot Plug Driver
  3. *
  4. * Copyright (C) 2002,2005 SOMA Networks, Inc.
  5. * Copyright (C) 2001 Greg Kroah-Hartman (greg@kroah.com)
  6. * Copyright (C) 2001 IBM Corp.
  7. *
  8. * All rights reserved.
  9. *
  10. * This program is free software; you can redistribute it and/or modify
  11. * it under the terms of the GNU General Public License as published by
  12. * the Free Software Foundation; either version 2 of the License, or (at
  13. * your option) any later version.
  14. *
  15. * This program is distributed in the hope that it will be useful, but
  16. * WITHOUT ANY WARRANTY; without even the implied warranty of
  17. * MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE, GOOD TITLE or
  18. * NON INFRINGEMENT. See the GNU General Public License for more
  19. * details.
  20. *
  21. * You should have received a copy of the GNU General Public License
  22. * along with this program; if not, write to the Free Software
  23. * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  24. *
  25. * Send feedback to <scottm@somanetworks.com>
  26. */
  27. #include <linux/module.h>
  28. #include <linux/kernel.h>
  29. #include <linux/slab.h>
  30. #include <linux/pci.h>
  31. #include <linux/pci_hotplug.h>
  32. #include <linux/init.h>
  33. #include <linux/interrupt.h>
  34. #include <linux/smp_lock.h>
  35. #include <asm/atomic.h>
  36. #include <linux/delay.h>
  37. #include <linux/kthread.h>
  38. #include "cpci_hotplug.h"
  39. #define DRIVER_AUTHOR "Scott Murray <scottm@somanetworks.com>"
  40. #define DRIVER_DESC "CompactPCI Hot Plug Core"
  41. #define MY_NAME "cpci_hotplug"
  42. #define dbg(format, arg...) \
  43. do { \
  44. if (cpci_debug) \
  45. printk (KERN_DEBUG "%s: " format "\n", \
  46. MY_NAME , ## arg); \
  47. } while (0)
  48. #define err(format, arg...) printk(KERN_ERR "%s: " format "\n", MY_NAME , ## arg)
  49. #define info(format, arg...) printk(KERN_INFO "%s: " format "\n", MY_NAME , ## arg)
  50. #define warn(format, arg...) printk(KERN_WARNING "%s: " format "\n", MY_NAME , ## arg)
  51. /* local variables */
  52. static DECLARE_RWSEM(list_rwsem);
  53. static LIST_HEAD(slot_list);
  54. static int slots;
  55. static atomic_t extracting;
  56. int cpci_debug;
  57. static struct cpci_hp_controller *controller;
  58. static struct task_struct *cpci_thread;
  59. static int thread_finished;
  60. static int enable_slot(struct hotplug_slot *slot);
  61. static int disable_slot(struct hotplug_slot *slot);
  62. static int set_attention_status(struct hotplug_slot *slot, u8 value);
  63. static int get_power_status(struct hotplug_slot *slot, u8 * value);
  64. static int get_attention_status(struct hotplug_slot *slot, u8 * value);
  65. static int get_adapter_status(struct hotplug_slot *slot, u8 * value);
  66. static int get_latch_status(struct hotplug_slot *slot, u8 * value);
  67. static struct hotplug_slot_ops cpci_hotplug_slot_ops = {
  68. .owner = THIS_MODULE,
  69. .enable_slot = enable_slot,
  70. .disable_slot = disable_slot,
  71. .set_attention_status = set_attention_status,
  72. .get_power_status = get_power_status,
  73. .get_attention_status = get_attention_status,
  74. .get_adapter_status = get_adapter_status,
  75. .get_latch_status = get_latch_status,
  76. };
  77. static int
  78. update_latch_status(struct hotplug_slot *hotplug_slot, u8 value)
  79. {
  80. struct hotplug_slot_info info;
  81. memcpy(&info, hotplug_slot->info, sizeof(struct hotplug_slot_info));
  82. info.latch_status = value;
  83. return pci_hp_change_slot_info(hotplug_slot, &info);
  84. }
  85. static int
  86. update_adapter_status(struct hotplug_slot *hotplug_slot, u8 value)
  87. {
  88. struct hotplug_slot_info info;
  89. memcpy(&info, hotplug_slot->info, sizeof(struct hotplug_slot_info));
  90. info.adapter_status = value;
  91. return pci_hp_change_slot_info(hotplug_slot, &info);
  92. }
  93. static int
  94. enable_slot(struct hotplug_slot *hotplug_slot)
  95. {
  96. struct slot *slot = hotplug_slot->private;
  97. int retval = 0;
  98. dbg("%s - physical_slot = %s", __func__, hotplug_slot->name);
  99. if (controller->ops->set_power)
  100. retval = controller->ops->set_power(slot, 1);
  101. return retval;
  102. }
  103. static int
  104. disable_slot(struct hotplug_slot *hotplug_slot)
  105. {
  106. struct slot *slot = hotplug_slot->private;
  107. int retval = 0;
  108. dbg("%s - physical_slot = %s", __func__, hotplug_slot->name);
  109. down_write(&list_rwsem);
  110. /* Unconfigure device */
  111. dbg("%s - unconfiguring slot %s",
  112. __func__, slot->hotplug_slot->name);
  113. if ((retval = cpci_unconfigure_slot(slot))) {
  114. err("%s - could not unconfigure slot %s",
  115. __func__, slot->hotplug_slot->name);
  116. goto disable_error;
  117. }
  118. dbg("%s - finished unconfiguring slot %s",
  119. __func__, slot->hotplug_slot->name);
  120. /* Clear EXT (by setting it) */
  121. if (cpci_clear_ext(slot)) {
  122. err("%s - could not clear EXT for slot %s",
  123. __func__, slot->hotplug_slot->name);
  124. retval = -ENODEV;
  125. goto disable_error;
  126. }
  127. cpci_led_on(slot);
  128. if (controller->ops->set_power)
  129. if ((retval = controller->ops->set_power(slot, 0)))
  130. goto disable_error;
  131. if (update_adapter_status(slot->hotplug_slot, 0))
  132. warn("failure to update adapter file");
  133. if (slot->extracting) {
  134. slot->extracting = 0;
  135. atomic_dec(&extracting);
  136. }
  137. disable_error:
  138. up_write(&list_rwsem);
  139. return retval;
  140. }
  141. static u8
  142. cpci_get_power_status(struct slot *slot)
  143. {
  144. u8 power = 1;
  145. if (controller->ops->get_power)
  146. power = controller->ops->get_power(slot);
  147. return power;
  148. }
  149. static int
  150. get_power_status(struct hotplug_slot *hotplug_slot, u8 * value)
  151. {
  152. struct slot *slot = hotplug_slot->private;
  153. *value = cpci_get_power_status(slot);
  154. return 0;
  155. }
  156. static int
  157. get_attention_status(struct hotplug_slot *hotplug_slot, u8 * value)
  158. {
  159. struct slot *slot = hotplug_slot->private;
  160. *value = cpci_get_attention_status(slot);
  161. return 0;
  162. }
  163. static int
  164. set_attention_status(struct hotplug_slot *hotplug_slot, u8 status)
  165. {
  166. return cpci_set_attention_status(hotplug_slot->private, status);
  167. }
  168. static int
  169. get_adapter_status(struct hotplug_slot *hotplug_slot, u8 * value)
  170. {
  171. *value = hotplug_slot->info->adapter_status;
  172. return 0;
  173. }
  174. static int
  175. get_latch_status(struct hotplug_slot *hotplug_slot, u8 * value)
  176. {
  177. *value = hotplug_slot->info->latch_status;
  178. return 0;
  179. }
  180. static void release_slot(struct hotplug_slot *hotplug_slot)
  181. {
  182. struct slot *slot = hotplug_slot->private;
  183. kfree(slot->hotplug_slot->info);
  184. kfree(slot->hotplug_slot->name);
  185. kfree(slot->hotplug_slot);
  186. if (slot->dev)
  187. pci_dev_put(slot->dev);
  188. kfree(slot);
  189. }
  190. #define SLOT_NAME_SIZE 6
  191. static void
  192. make_slot_name(struct slot *slot)
  193. {
  194. snprintf(slot->hotplug_slot->name,
  195. SLOT_NAME_SIZE, "%02x:%02x", slot->bus->number, slot->number);
  196. }
  197. int
  198. cpci_hp_register_bus(struct pci_bus *bus, u8 first, u8 last)
  199. {
  200. struct slot *slot;
  201. struct hotplug_slot *hotplug_slot;
  202. struct hotplug_slot_info *info;
  203. char *name;
  204. int status = -ENOMEM;
  205. int i;
  206. if (!(controller && bus))
  207. return -ENODEV;
  208. /*
  209. * Create a structure for each slot, and register that slot
  210. * with the pci_hotplug subsystem.
  211. */
  212. for (i = first; i <= last; ++i) {
  213. slot = kzalloc(sizeof (struct slot), GFP_KERNEL);
  214. if (!slot)
  215. goto error;
  216. hotplug_slot =
  217. kzalloc(sizeof (struct hotplug_slot), GFP_KERNEL);
  218. if (!hotplug_slot)
  219. goto error_slot;
  220. slot->hotplug_slot = hotplug_slot;
  221. info = kzalloc(sizeof (struct hotplug_slot_info), GFP_KERNEL);
  222. if (!info)
  223. goto error_hpslot;
  224. hotplug_slot->info = info;
  225. name = kmalloc(SLOT_NAME_SIZE, GFP_KERNEL);
  226. if (!name)
  227. goto error_info;
  228. hotplug_slot->name = name;
  229. slot->bus = bus;
  230. slot->number = i;
  231. slot->devfn = PCI_DEVFN(i, 0);
  232. hotplug_slot->private = slot;
  233. hotplug_slot->release = &release_slot;
  234. make_slot_name(slot);
  235. hotplug_slot->ops = &cpci_hotplug_slot_ops;
  236. /*
  237. * Initialize the slot info structure with some known
  238. * good values.
  239. */
  240. dbg("initializing slot %s", slot->hotplug_slot->name);
  241. info->power_status = cpci_get_power_status(slot);
  242. info->attention_status = cpci_get_attention_status(slot);
  243. dbg("registering slot %s", slot->hotplug_slot->name);
  244. status = pci_hp_register(slot->hotplug_slot, bus, i);
  245. if (status) {
  246. err("pci_hp_register failed with error %d", status);
  247. goto error_name;
  248. }
  249. /* Add slot to our internal list */
  250. down_write(&list_rwsem);
  251. list_add(&slot->slot_list, &slot_list);
  252. slots++;
  253. up_write(&list_rwsem);
  254. }
  255. return 0;
  256. error_name:
  257. kfree(name);
  258. error_info:
  259. kfree(info);
  260. error_hpslot:
  261. kfree(hotplug_slot);
  262. error_slot:
  263. kfree(slot);
  264. error:
  265. return status;
  266. }
  267. int
  268. cpci_hp_unregister_bus(struct pci_bus *bus)
  269. {
  270. struct slot *slot;
  271. struct slot *tmp;
  272. int status = 0;
  273. down_write(&list_rwsem);
  274. if (!slots) {
  275. up_write(&list_rwsem);
  276. return -1;
  277. }
  278. list_for_each_entry_safe(slot, tmp, &slot_list, slot_list) {
  279. if (slot->bus == bus) {
  280. list_del(&slot->slot_list);
  281. slots--;
  282. dbg("deregistering slot %s", slot->hotplug_slot->name);
  283. status = pci_hp_deregister(slot->hotplug_slot);
  284. if (status) {
  285. err("pci_hp_deregister failed with error %d",
  286. status);
  287. break;
  288. }
  289. }
  290. }
  291. up_write(&list_rwsem);
  292. return status;
  293. }
  294. /* This is the interrupt mode interrupt handler */
  295. static irqreturn_t
  296. cpci_hp_intr(int irq, void *data)
  297. {
  298. dbg("entered cpci_hp_intr");
  299. /* Check to see if it was our interrupt */
  300. if ((controller->irq_flags & IRQF_SHARED) &&
  301. !controller->ops->check_irq(controller->dev_id)) {
  302. dbg("exited cpci_hp_intr, not our interrupt");
  303. return IRQ_NONE;
  304. }
  305. /* Disable ENUM interrupt */
  306. controller->ops->disable_irq();
  307. /* Trigger processing by the event thread */
  308. wake_up_process(cpci_thread);
  309. return IRQ_HANDLED;
  310. }
  311. /*
  312. * According to PICMG 2.1 R2.0, section 6.3.2, upon
  313. * initialization, the system driver shall clear the
  314. * INS bits of the cold-inserted devices.
  315. */
  316. static int
  317. init_slots(int clear_ins)
  318. {
  319. struct slot *slot;
  320. struct pci_dev* dev;
  321. dbg("%s - enter", __func__);
  322. down_read(&list_rwsem);
  323. if (!slots) {
  324. up_read(&list_rwsem);
  325. return -1;
  326. }
  327. list_for_each_entry(slot, &slot_list, slot_list) {
  328. dbg("%s - looking at slot %s",
  329. __func__, slot->hotplug_slot->name);
  330. if (clear_ins && cpci_check_and_clear_ins(slot))
  331. dbg("%s - cleared INS for slot %s",
  332. __func__, slot->hotplug_slot->name);
  333. dev = pci_get_slot(slot->bus, PCI_DEVFN(slot->number, 0));
  334. if (dev) {
  335. if (update_adapter_status(slot->hotplug_slot, 1))
  336. warn("failure to update adapter file");
  337. if (update_latch_status(slot->hotplug_slot, 1))
  338. warn("failure to update latch file");
  339. slot->dev = dev;
  340. }
  341. }
  342. up_read(&list_rwsem);
  343. dbg("%s - exit", __func__);
  344. return 0;
  345. }
  346. static int
  347. check_slots(void)
  348. {
  349. struct slot *slot;
  350. int extracted;
  351. int inserted;
  352. u16 hs_csr;
  353. down_read(&list_rwsem);
  354. if (!slots) {
  355. up_read(&list_rwsem);
  356. err("no slots registered, shutting down");
  357. return -1;
  358. }
  359. extracted = inserted = 0;
  360. list_for_each_entry(slot, &slot_list, slot_list) {
  361. dbg("%s - looking at slot %s",
  362. __func__, slot->hotplug_slot->name);
  363. if (cpci_check_and_clear_ins(slot)) {
  364. /*
  365. * Some broken hardware (e.g. PLX 9054AB) asserts
  366. * ENUM# twice...
  367. */
  368. if (slot->dev) {
  369. warn("slot %s already inserted",
  370. slot->hotplug_slot->name);
  371. inserted++;
  372. continue;
  373. }
  374. /* Process insertion */
  375. dbg("%s - slot %s inserted",
  376. __func__, slot->hotplug_slot->name);
  377. /* GSM, debug */
  378. hs_csr = cpci_get_hs_csr(slot);
  379. dbg("%s - slot %s HS_CSR (1) = %04x",
  380. __func__, slot->hotplug_slot->name, hs_csr);
  381. /* Configure device */
  382. dbg("%s - configuring slot %s",
  383. __func__, slot->hotplug_slot->name);
  384. if (cpci_configure_slot(slot)) {
  385. err("%s - could not configure slot %s",
  386. __func__, slot->hotplug_slot->name);
  387. continue;
  388. }
  389. dbg("%s - finished configuring slot %s",
  390. __func__, slot->hotplug_slot->name);
  391. /* GSM, debug */
  392. hs_csr = cpci_get_hs_csr(slot);
  393. dbg("%s - slot %s HS_CSR (2) = %04x",
  394. __func__, slot->hotplug_slot->name, hs_csr);
  395. if (update_latch_status(slot->hotplug_slot, 1))
  396. warn("failure to update latch file");
  397. if (update_adapter_status(slot->hotplug_slot, 1))
  398. warn("failure to update adapter file");
  399. cpci_led_off(slot);
  400. /* GSM, debug */
  401. hs_csr = cpci_get_hs_csr(slot);
  402. dbg("%s - slot %s HS_CSR (3) = %04x",
  403. __func__, slot->hotplug_slot->name, hs_csr);
  404. inserted++;
  405. } else if (cpci_check_ext(slot)) {
  406. /* Process extraction request */
  407. dbg("%s - slot %s extracted",
  408. __func__, slot->hotplug_slot->name);
  409. /* GSM, debug */
  410. hs_csr = cpci_get_hs_csr(slot);
  411. dbg("%s - slot %s HS_CSR = %04x",
  412. __func__, slot->hotplug_slot->name, hs_csr);
  413. if (!slot->extracting) {
  414. if (update_latch_status(slot->hotplug_slot, 0)) {
  415. warn("failure to update latch file");
  416. }
  417. slot->extracting = 1;
  418. atomic_inc(&extracting);
  419. }
  420. extracted++;
  421. } else if (slot->extracting) {
  422. hs_csr = cpci_get_hs_csr(slot);
  423. if (hs_csr == 0xffff) {
  424. /*
  425. * Hmmm, we're likely hosed at this point, should we
  426. * bother trying to tell the driver or not?
  427. */
  428. err("card in slot %s was improperly removed",
  429. slot->hotplug_slot->name);
  430. if (update_adapter_status(slot->hotplug_slot, 0))
  431. warn("failure to update adapter file");
  432. slot->extracting = 0;
  433. atomic_dec(&extracting);
  434. }
  435. }
  436. }
  437. up_read(&list_rwsem);
  438. dbg("inserted=%d, extracted=%d, extracting=%d",
  439. inserted, extracted, atomic_read(&extracting));
  440. if (inserted || extracted)
  441. return extracted;
  442. else if (!atomic_read(&extracting)) {
  443. err("cannot find ENUM# source, shutting down");
  444. return -1;
  445. }
  446. return 0;
  447. }
  448. /* This is the interrupt mode worker thread body */
  449. static int
  450. event_thread(void *data)
  451. {
  452. int rc;
  453. dbg("%s - event thread started", __func__);
  454. while (1) {
  455. dbg("event thread sleeping");
  456. set_current_state(TASK_INTERRUPTIBLE);
  457. schedule();
  458. if (kthread_should_stop())
  459. break;
  460. do {
  461. rc = check_slots();
  462. if (rc > 0) {
  463. /* Give userspace a chance to handle extraction */
  464. msleep(500);
  465. } else if (rc < 0) {
  466. dbg("%s - error checking slots", __func__);
  467. thread_finished = 1;
  468. goto out;
  469. }
  470. } while (atomic_read(&extracting) && !kthread_should_stop());
  471. if (kthread_should_stop())
  472. break;
  473. /* Re-enable ENUM# interrupt */
  474. dbg("%s - re-enabling irq", __func__);
  475. controller->ops->enable_irq();
  476. }
  477. out:
  478. return 0;
  479. }
  480. /* This is the polling mode worker thread body */
  481. static int
  482. poll_thread(void *data)
  483. {
  484. int rc;
  485. while (1) {
  486. if (kthread_should_stop() || signal_pending(current))
  487. break;
  488. if (controller->ops->query_enum()) {
  489. do {
  490. rc = check_slots();
  491. if (rc > 0) {
  492. /* Give userspace a chance to handle extraction */
  493. msleep(500);
  494. } else if (rc < 0) {
  495. dbg("%s - error checking slots", __func__);
  496. thread_finished = 1;
  497. goto out;
  498. }
  499. } while (atomic_read(&extracting) && !kthread_should_stop());
  500. }
  501. msleep(100);
  502. }
  503. out:
  504. return 0;
  505. }
  506. static int
  507. cpci_start_thread(void)
  508. {
  509. if (controller->irq)
  510. cpci_thread = kthread_run(event_thread, NULL, "cpci_hp_eventd");
  511. else
  512. cpci_thread = kthread_run(poll_thread, NULL, "cpci_hp_polld");
  513. if (IS_ERR(cpci_thread)) {
  514. err("Can't start up our thread");
  515. return PTR_ERR(cpci_thread);
  516. }
  517. thread_finished = 0;
  518. return 0;
  519. }
  520. static void
  521. cpci_stop_thread(void)
  522. {
  523. kthread_stop(cpci_thread);
  524. thread_finished = 1;
  525. }
  526. int
  527. cpci_hp_register_controller(struct cpci_hp_controller *new_controller)
  528. {
  529. int status = 0;
  530. if (controller)
  531. return -1;
  532. if (!(new_controller && new_controller->ops))
  533. return -EINVAL;
  534. if (new_controller->irq) {
  535. if (!(new_controller->ops->enable_irq &&
  536. new_controller->ops->disable_irq))
  537. status = -EINVAL;
  538. if (request_irq(new_controller->irq,
  539. cpci_hp_intr,
  540. new_controller->irq_flags,
  541. MY_NAME,
  542. new_controller->dev_id)) {
  543. err("Can't get irq %d for the hotplug cPCI controller",
  544. new_controller->irq);
  545. status = -ENODEV;
  546. }
  547. dbg("%s - acquired controller irq %d",
  548. __func__, new_controller->irq);
  549. }
  550. if (!status)
  551. controller = new_controller;
  552. return status;
  553. }
  554. static void
  555. cleanup_slots(void)
  556. {
  557. struct slot *slot;
  558. struct slot *tmp;
  559. /*
  560. * Unregister all of our slots with the pci_hotplug subsystem,
  561. * and free up all memory that we had allocated.
  562. */
  563. down_write(&list_rwsem);
  564. if (!slots)
  565. goto cleanup_null;
  566. list_for_each_entry_safe(slot, tmp, &slot_list, slot_list) {
  567. list_del(&slot->slot_list);
  568. pci_hp_deregister(slot->hotplug_slot);
  569. }
  570. cleanup_null:
  571. up_write(&list_rwsem);
  572. return;
  573. }
  574. int
  575. cpci_hp_unregister_controller(struct cpci_hp_controller *old_controller)
  576. {
  577. int status = 0;
  578. if (controller) {
  579. if (!thread_finished)
  580. cpci_stop_thread();
  581. if (controller->irq)
  582. free_irq(controller->irq, controller->dev_id);
  583. controller = NULL;
  584. cleanup_slots();
  585. } else
  586. status = -ENODEV;
  587. return status;
  588. }
  589. int
  590. cpci_hp_start(void)
  591. {
  592. static int first = 1;
  593. int status;
  594. dbg("%s - enter", __func__);
  595. if (!controller)
  596. return -ENODEV;
  597. down_read(&list_rwsem);
  598. if (list_empty(&slot_list)) {
  599. up_read(&list_rwsem);
  600. return -ENODEV;
  601. }
  602. up_read(&list_rwsem);
  603. status = init_slots(first);
  604. if (first)
  605. first = 0;
  606. if (status)
  607. return status;
  608. status = cpci_start_thread();
  609. if (status)
  610. return status;
  611. dbg("%s - thread started", __func__);
  612. if (controller->irq) {
  613. /* Start enum interrupt processing */
  614. dbg("%s - enabling irq", __func__);
  615. controller->ops->enable_irq();
  616. }
  617. dbg("%s - exit", __func__);
  618. return 0;
  619. }
  620. int
  621. cpci_hp_stop(void)
  622. {
  623. if (!controller)
  624. return -ENODEV;
  625. if (controller->irq) {
  626. /* Stop enum interrupt processing */
  627. dbg("%s - disabling irq", __func__);
  628. controller->ops->disable_irq();
  629. }
  630. cpci_stop_thread();
  631. return 0;
  632. }
  633. int __init
  634. cpci_hotplug_init(int debug)
  635. {
  636. cpci_debug = debug;
  637. return 0;
  638. }
  639. void __exit
  640. cpci_hotplug_exit(void)
  641. {
  642. /*
  643. * Clean everything up.
  644. */
  645. cpci_hp_stop();
  646. cpci_hp_unregister_controller(controller);
  647. }
  648. EXPORT_SYMBOL_GPL(cpci_hp_register_controller);
  649. EXPORT_SYMBOL_GPL(cpci_hp_unregister_controller);
  650. EXPORT_SYMBOL_GPL(cpci_hp_register_bus);
  651. EXPORT_SYMBOL_GPL(cpci_hp_unregister_bus);
  652. EXPORT_SYMBOL_GPL(cpci_hp_start);
  653. EXPORT_SYMBOL_GPL(cpci_hp_stop);