pci_hotplug_core.c 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705
  1. /*
  2. * PCI HotPlug Controller Core
  3. *
  4. * Copyright (C) 2001-2002 Greg Kroah-Hartman (greg@kroah.com)
  5. * Copyright (C) 2001-2002 IBM Corp.
  6. *
  7. * All rights reserved.
  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, GOOD TITLE or
  17. * NON INFRINGEMENT. See the GNU General Public License for more
  18. * details.
  19. *
  20. * You should have received a copy of the GNU General Public License
  21. * along with this program; if not, write to the Free Software
  22. * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  23. *
  24. * Send feedback to <kristen.c.accardi@intel.com>
  25. *
  26. */
  27. #include <linux/module.h>
  28. #include <linux/moduleparam.h>
  29. #include <linux/kernel.h>
  30. #include <linux/types.h>
  31. #include <linux/list.h>
  32. #include <linux/kobject.h>
  33. #include <linux/sysfs.h>
  34. #include <linux/pagemap.h>
  35. #include <linux/slab.h>
  36. #include <linux/init.h>
  37. #include <linux/mount.h>
  38. #include <linux/namei.h>
  39. #include <linux/mutex.h>
  40. #include <linux/pci.h>
  41. #include <linux/pci_hotplug.h>
  42. #include <asm/uaccess.h>
  43. #include "../pci.h"
  44. #define MY_NAME "pci_hotplug"
  45. #define dbg(fmt, arg...) do { if (debug) printk(KERN_DEBUG "%s: %s: " fmt , MY_NAME , __func__ , ## arg); } while (0)
  46. #define err(format, arg...) printk(KERN_ERR "%s: " format , MY_NAME , ## arg)
  47. #define info(format, arg...) printk(KERN_INFO "%s: " format , MY_NAME , ## arg)
  48. #define warn(format, arg...) printk(KERN_WARNING "%s: " format , MY_NAME , ## arg)
  49. /* local variables */
  50. static int debug;
  51. #define DRIVER_VERSION "0.5"
  52. #define DRIVER_AUTHOR "Greg Kroah-Hartman <greg@kroah.com>, Scott Murray <scottm@somanetworks.com>"
  53. #define DRIVER_DESC "PCI Hot Plug PCI Core"
  54. //////////////////////////////////////////////////////////////////
  55. static LIST_HEAD(pci_hotplug_slot_list);
  56. static DEFINE_MUTEX(pci_hp_mutex);
  57. /* these strings match up with the values in pci_bus_speed */
  58. static char *pci_bus_speed_strings[] = {
  59. "33 MHz PCI", /* 0x00 */
  60. "66 MHz PCI", /* 0x01 */
  61. "66 MHz PCI-X", /* 0x02 */
  62. "100 MHz PCI-X", /* 0x03 */
  63. "133 MHz PCI-X", /* 0x04 */
  64. NULL, /* 0x05 */
  65. NULL, /* 0x06 */
  66. NULL, /* 0x07 */
  67. NULL, /* 0x08 */
  68. "66 MHz PCI-X 266", /* 0x09 */
  69. "100 MHz PCI-X 266", /* 0x0a */
  70. "133 MHz PCI-X 266", /* 0x0b */
  71. NULL, /* 0x0c */
  72. NULL, /* 0x0d */
  73. NULL, /* 0x0e */
  74. NULL, /* 0x0f */
  75. NULL, /* 0x10 */
  76. "66 MHz PCI-X 533", /* 0x11 */
  77. "100 MHz PCI-X 533", /* 0x12 */
  78. "133 MHz PCI-X 533", /* 0x13 */
  79. "2.5 GT/s PCIe", /* 0x14 */
  80. "5.0 GT/s PCIe", /* 0x15 */
  81. };
  82. #ifdef CONFIG_HOTPLUG_PCI_CPCI
  83. extern int cpci_hotplug_init(int debug);
  84. extern void cpci_hotplug_exit(void);
  85. #else
  86. static inline int cpci_hotplug_init(int debug) { return 0; }
  87. static inline void cpci_hotplug_exit(void) { }
  88. #endif
  89. /* Weee, fun with macros... */
  90. #define GET_STATUS(name,type) \
  91. static int get_##name (struct hotplug_slot *slot, type *value) \
  92. { \
  93. struct hotplug_slot_ops *ops = slot->ops; \
  94. int retval = 0; \
  95. if (!try_module_get(ops->owner)) \
  96. return -ENODEV; \
  97. if (ops->get_##name) \
  98. retval = ops->get_##name(slot, value); \
  99. else \
  100. *value = slot->info->name; \
  101. module_put(ops->owner); \
  102. return retval; \
  103. }
  104. GET_STATUS(power_status, u8)
  105. GET_STATUS(attention_status, u8)
  106. GET_STATUS(latch_status, u8)
  107. GET_STATUS(adapter_status, u8)
  108. GET_STATUS(max_bus_speed, enum pci_bus_speed)
  109. GET_STATUS(cur_bus_speed, enum pci_bus_speed)
  110. static ssize_t power_read_file(struct pci_slot *slot, char *buf)
  111. {
  112. int retval;
  113. u8 value;
  114. retval = get_power_status(slot->hotplug, &value);
  115. if (retval)
  116. goto exit;
  117. retval = sprintf (buf, "%d\n", value);
  118. exit:
  119. return retval;
  120. }
  121. static ssize_t power_write_file(struct pci_slot *pci_slot, const char *buf,
  122. size_t count)
  123. {
  124. struct hotplug_slot *slot = pci_slot->hotplug;
  125. unsigned long lpower;
  126. u8 power;
  127. int retval = 0;
  128. lpower = simple_strtoul (buf, NULL, 10);
  129. power = (u8)(lpower & 0xff);
  130. dbg ("power = %d\n", power);
  131. if (!try_module_get(slot->ops->owner)) {
  132. retval = -ENODEV;
  133. goto exit;
  134. }
  135. switch (power) {
  136. case 0:
  137. if (slot->ops->disable_slot)
  138. retval = slot->ops->disable_slot(slot);
  139. break;
  140. case 1:
  141. if (slot->ops->enable_slot)
  142. retval = slot->ops->enable_slot(slot);
  143. break;
  144. default:
  145. err ("Illegal value specified for power\n");
  146. retval = -EINVAL;
  147. }
  148. module_put(slot->ops->owner);
  149. exit:
  150. if (retval)
  151. return retval;
  152. return count;
  153. }
  154. static struct pci_slot_attribute hotplug_slot_attr_power = {
  155. .attr = {.name = "power", .mode = S_IFREG | S_IRUGO | S_IWUSR},
  156. .show = power_read_file,
  157. .store = power_write_file
  158. };
  159. static ssize_t attention_read_file(struct pci_slot *slot, char *buf)
  160. {
  161. int retval;
  162. u8 value;
  163. retval = get_attention_status(slot->hotplug, &value);
  164. if (retval)
  165. goto exit;
  166. retval = sprintf(buf, "%d\n", value);
  167. exit:
  168. return retval;
  169. }
  170. static ssize_t attention_write_file(struct pci_slot *slot, const char *buf,
  171. size_t count)
  172. {
  173. struct hotplug_slot_ops *ops = slot->hotplug->ops;
  174. unsigned long lattention;
  175. u8 attention;
  176. int retval = 0;
  177. lattention = simple_strtoul (buf, NULL, 10);
  178. attention = (u8)(lattention & 0xff);
  179. dbg (" - attention = %d\n", attention);
  180. if (!try_module_get(ops->owner)) {
  181. retval = -ENODEV;
  182. goto exit;
  183. }
  184. if (ops->set_attention_status)
  185. retval = ops->set_attention_status(slot->hotplug, attention);
  186. module_put(ops->owner);
  187. exit:
  188. if (retval)
  189. return retval;
  190. return count;
  191. }
  192. static struct pci_slot_attribute hotplug_slot_attr_attention = {
  193. .attr = {.name = "attention", .mode = S_IFREG | S_IRUGO | S_IWUSR},
  194. .show = attention_read_file,
  195. .store = attention_write_file
  196. };
  197. static ssize_t latch_read_file(struct pci_slot *slot, char *buf)
  198. {
  199. int retval;
  200. u8 value;
  201. retval = get_latch_status(slot->hotplug, &value);
  202. if (retval)
  203. goto exit;
  204. retval = sprintf (buf, "%d\n", value);
  205. exit:
  206. return retval;
  207. }
  208. static struct pci_slot_attribute hotplug_slot_attr_latch = {
  209. .attr = {.name = "latch", .mode = S_IFREG | S_IRUGO},
  210. .show = latch_read_file,
  211. };
  212. static ssize_t presence_read_file(struct pci_slot *slot, char *buf)
  213. {
  214. int retval;
  215. u8 value;
  216. retval = get_adapter_status(slot->hotplug, &value);
  217. if (retval)
  218. goto exit;
  219. retval = sprintf (buf, "%d\n", value);
  220. exit:
  221. return retval;
  222. }
  223. static struct pci_slot_attribute hotplug_slot_attr_presence = {
  224. .attr = {.name = "adapter", .mode = S_IFREG | S_IRUGO},
  225. .show = presence_read_file,
  226. };
  227. static char *unknown_speed = "Unknown bus speed";
  228. static ssize_t max_bus_speed_read_file(struct pci_slot *slot, char *buf)
  229. {
  230. char *speed_string;
  231. int retval;
  232. enum pci_bus_speed value;
  233. retval = get_max_bus_speed(slot->hotplug, &value);
  234. if (retval)
  235. goto exit;
  236. if (value == PCI_SPEED_UNKNOWN)
  237. speed_string = unknown_speed;
  238. else
  239. speed_string = pci_bus_speed_strings[value];
  240. retval = sprintf (buf, "%s\n", speed_string);
  241. exit:
  242. return retval;
  243. }
  244. static struct pci_slot_attribute hotplug_slot_attr_max_bus_speed = {
  245. .attr = {.name = "max_bus_speed", .mode = S_IFREG | S_IRUGO},
  246. .show = max_bus_speed_read_file,
  247. };
  248. static ssize_t cur_bus_speed_read_file(struct pci_slot *slot, char *buf)
  249. {
  250. char *speed_string;
  251. int retval;
  252. enum pci_bus_speed value;
  253. retval = get_cur_bus_speed(slot->hotplug, &value);
  254. if (retval)
  255. goto exit;
  256. if (value == PCI_SPEED_UNKNOWN)
  257. speed_string = unknown_speed;
  258. else
  259. speed_string = pci_bus_speed_strings[value];
  260. retval = sprintf (buf, "%s\n", speed_string);
  261. exit:
  262. return retval;
  263. }
  264. static struct pci_slot_attribute hotplug_slot_attr_cur_bus_speed = {
  265. .attr = {.name = "cur_bus_speed", .mode = S_IFREG | S_IRUGO},
  266. .show = cur_bus_speed_read_file,
  267. };
  268. static ssize_t test_write_file(struct pci_slot *pci_slot, const char *buf,
  269. size_t count)
  270. {
  271. struct hotplug_slot *slot = pci_slot->hotplug;
  272. unsigned long ltest;
  273. u32 test;
  274. int retval = 0;
  275. ltest = simple_strtoul (buf, NULL, 10);
  276. test = (u32)(ltest & 0xffffffff);
  277. dbg ("test = %d\n", test);
  278. if (!try_module_get(slot->ops->owner)) {
  279. retval = -ENODEV;
  280. goto exit;
  281. }
  282. if (slot->ops->hardware_test)
  283. retval = slot->ops->hardware_test(slot, test);
  284. module_put(slot->ops->owner);
  285. exit:
  286. if (retval)
  287. return retval;
  288. return count;
  289. }
  290. static struct pci_slot_attribute hotplug_slot_attr_test = {
  291. .attr = {.name = "test", .mode = S_IFREG | S_IRUGO | S_IWUSR},
  292. .store = test_write_file
  293. };
  294. static bool has_power_file(struct pci_slot *pci_slot)
  295. {
  296. struct hotplug_slot *slot = pci_slot->hotplug;
  297. if ((!slot) || (!slot->ops))
  298. return false;
  299. if ((slot->ops->enable_slot) ||
  300. (slot->ops->disable_slot) ||
  301. (slot->ops->get_power_status))
  302. return true;
  303. return false;
  304. }
  305. static bool has_attention_file(struct pci_slot *pci_slot)
  306. {
  307. struct hotplug_slot *slot = pci_slot->hotplug;
  308. if ((!slot) || (!slot->ops))
  309. return false;
  310. if ((slot->ops->set_attention_status) ||
  311. (slot->ops->get_attention_status))
  312. return true;
  313. return false;
  314. }
  315. static bool has_latch_file(struct pci_slot *pci_slot)
  316. {
  317. struct hotplug_slot *slot = pci_slot->hotplug;
  318. if ((!slot) || (!slot->ops))
  319. return false;
  320. if (slot->ops->get_latch_status)
  321. return true;
  322. return false;
  323. }
  324. static bool has_adapter_file(struct pci_slot *pci_slot)
  325. {
  326. struct hotplug_slot *slot = pci_slot->hotplug;
  327. if ((!slot) || (!slot->ops))
  328. return false;
  329. if (slot->ops->get_adapter_status)
  330. return true;
  331. return false;
  332. }
  333. static bool has_max_bus_speed_file(struct pci_slot *pci_slot)
  334. {
  335. struct hotplug_slot *slot = pci_slot->hotplug;
  336. if ((!slot) || (!slot->ops))
  337. return false;
  338. if (slot->ops->get_max_bus_speed)
  339. return true;
  340. return false;
  341. }
  342. static bool has_cur_bus_speed_file(struct pci_slot *pci_slot)
  343. {
  344. struct hotplug_slot *slot = pci_slot->hotplug;
  345. if ((!slot) || (!slot->ops))
  346. return false;
  347. if (slot->ops->get_cur_bus_speed)
  348. return true;
  349. return false;
  350. }
  351. static bool has_test_file(struct pci_slot *pci_slot)
  352. {
  353. struct hotplug_slot *slot = pci_slot->hotplug;
  354. if ((!slot) || (!slot->ops))
  355. return false;
  356. if (slot->ops->hardware_test)
  357. return true;
  358. return false;
  359. }
  360. static int fs_add_slot(struct pci_slot *slot)
  361. {
  362. int retval = 0;
  363. /* Create symbolic link to the hotplug driver module */
  364. pci_hp_create_module_link(slot);
  365. if (has_power_file(slot)) {
  366. retval = sysfs_create_file(&slot->kobj,
  367. &hotplug_slot_attr_power.attr);
  368. if (retval)
  369. goto exit_power;
  370. }
  371. if (has_attention_file(slot)) {
  372. retval = sysfs_create_file(&slot->kobj,
  373. &hotplug_slot_attr_attention.attr);
  374. if (retval)
  375. goto exit_attention;
  376. }
  377. if (has_latch_file(slot)) {
  378. retval = sysfs_create_file(&slot->kobj,
  379. &hotplug_slot_attr_latch.attr);
  380. if (retval)
  381. goto exit_latch;
  382. }
  383. if (has_adapter_file(slot)) {
  384. retval = sysfs_create_file(&slot->kobj,
  385. &hotplug_slot_attr_presence.attr);
  386. if (retval)
  387. goto exit_adapter;
  388. }
  389. if (has_max_bus_speed_file(slot)) {
  390. retval = sysfs_create_file(&slot->kobj,
  391. &hotplug_slot_attr_max_bus_speed.attr);
  392. if (retval)
  393. goto exit_max_speed;
  394. }
  395. if (has_cur_bus_speed_file(slot)) {
  396. retval = sysfs_create_file(&slot->kobj,
  397. &hotplug_slot_attr_cur_bus_speed.attr);
  398. if (retval)
  399. goto exit_cur_speed;
  400. }
  401. if (has_test_file(slot)) {
  402. retval = sysfs_create_file(&slot->kobj,
  403. &hotplug_slot_attr_test.attr);
  404. if (retval)
  405. goto exit_test;
  406. }
  407. goto exit;
  408. exit_test:
  409. if (has_cur_bus_speed_file(slot))
  410. sysfs_remove_file(&slot->kobj,
  411. &hotplug_slot_attr_cur_bus_speed.attr);
  412. exit_cur_speed:
  413. if (has_max_bus_speed_file(slot))
  414. sysfs_remove_file(&slot->kobj,
  415. &hotplug_slot_attr_max_bus_speed.attr);
  416. exit_max_speed:
  417. if (has_adapter_file(slot))
  418. sysfs_remove_file(&slot->kobj,
  419. &hotplug_slot_attr_presence.attr);
  420. exit_adapter:
  421. if (has_latch_file(slot))
  422. sysfs_remove_file(&slot->kobj, &hotplug_slot_attr_latch.attr);
  423. exit_latch:
  424. if (has_attention_file(slot))
  425. sysfs_remove_file(&slot->kobj,
  426. &hotplug_slot_attr_attention.attr);
  427. exit_attention:
  428. if (has_power_file(slot))
  429. sysfs_remove_file(&slot->kobj, &hotplug_slot_attr_power.attr);
  430. exit_power:
  431. pci_hp_remove_module_link(slot);
  432. exit:
  433. return retval;
  434. }
  435. static void fs_remove_slot(struct pci_slot *slot)
  436. {
  437. if (has_power_file(slot))
  438. sysfs_remove_file(&slot->kobj, &hotplug_slot_attr_power.attr);
  439. if (has_attention_file(slot))
  440. sysfs_remove_file(&slot->kobj,
  441. &hotplug_slot_attr_attention.attr);
  442. if (has_latch_file(slot))
  443. sysfs_remove_file(&slot->kobj, &hotplug_slot_attr_latch.attr);
  444. if (has_adapter_file(slot))
  445. sysfs_remove_file(&slot->kobj,
  446. &hotplug_slot_attr_presence.attr);
  447. if (has_max_bus_speed_file(slot))
  448. sysfs_remove_file(&slot->kobj,
  449. &hotplug_slot_attr_max_bus_speed.attr);
  450. if (has_cur_bus_speed_file(slot))
  451. sysfs_remove_file(&slot->kobj,
  452. &hotplug_slot_attr_cur_bus_speed.attr);
  453. if (has_test_file(slot))
  454. sysfs_remove_file(&slot->kobj, &hotplug_slot_attr_test.attr);
  455. pci_hp_remove_module_link(slot);
  456. }
  457. static struct hotplug_slot *get_slot_from_name (const char *name)
  458. {
  459. struct hotplug_slot *slot;
  460. struct list_head *tmp;
  461. list_for_each (tmp, &pci_hotplug_slot_list) {
  462. slot = list_entry (tmp, struct hotplug_slot, slot_list);
  463. if (strcmp(hotplug_slot_name(slot), name) == 0)
  464. return slot;
  465. }
  466. return NULL;
  467. }
  468. /**
  469. * __pci_hp_register - register a hotplug_slot with the PCI hotplug subsystem
  470. * @bus: bus this slot is on
  471. * @slot: pointer to the &struct hotplug_slot to register
  472. * @devnr: device number
  473. * @name: name registered with kobject core
  474. * @owner: caller module owner
  475. * @mod_name: caller module name
  476. *
  477. * Registers a hotplug slot with the pci hotplug subsystem, which will allow
  478. * userspace interaction to the slot.
  479. *
  480. * Returns 0 if successful, anything else for an error.
  481. */
  482. int __pci_hp_register(struct hotplug_slot *slot, struct pci_bus *bus,
  483. int devnr, const char *name,
  484. struct module *owner, const char *mod_name)
  485. {
  486. int result;
  487. struct pci_slot *pci_slot;
  488. if (slot == NULL)
  489. return -ENODEV;
  490. if ((slot->info == NULL) || (slot->ops == NULL))
  491. return -EINVAL;
  492. if (slot->release == NULL) {
  493. dbg("Why are you trying to register a hotplug slot "
  494. "without a proper release function?\n");
  495. return -EINVAL;
  496. }
  497. slot->ops->owner = owner;
  498. slot->ops->mod_name = mod_name;
  499. mutex_lock(&pci_hp_mutex);
  500. /*
  501. * No problems if we call this interface from both ACPI_PCI_SLOT
  502. * driver and call it here again. If we've already created the
  503. * pci_slot, the interface will simply bump the refcount.
  504. */
  505. pci_slot = pci_create_slot(bus, devnr, name, slot);
  506. if (IS_ERR(pci_slot)) {
  507. result = PTR_ERR(pci_slot);
  508. goto out;
  509. }
  510. slot->pci_slot = pci_slot;
  511. pci_slot->hotplug = slot;
  512. list_add(&slot->slot_list, &pci_hotplug_slot_list);
  513. result = fs_add_slot(pci_slot);
  514. kobject_uevent(&pci_slot->kobj, KOBJ_ADD);
  515. dbg("Added slot %s to the list\n", name);
  516. out:
  517. mutex_unlock(&pci_hp_mutex);
  518. return result;
  519. }
  520. /**
  521. * pci_hp_deregister - deregister a hotplug_slot with the PCI hotplug subsystem
  522. * @hotplug: pointer to the &struct hotplug_slot to deregister
  523. *
  524. * The @slot must have been registered with the pci hotplug subsystem
  525. * previously with a call to pci_hp_register().
  526. *
  527. * Returns 0 if successful, anything else for an error.
  528. */
  529. int pci_hp_deregister(struct hotplug_slot *hotplug)
  530. {
  531. struct hotplug_slot *temp;
  532. struct pci_slot *slot;
  533. if (!hotplug)
  534. return -ENODEV;
  535. mutex_lock(&pci_hp_mutex);
  536. temp = get_slot_from_name(hotplug_slot_name(hotplug));
  537. if (temp != hotplug) {
  538. mutex_unlock(&pci_hp_mutex);
  539. return -ENODEV;
  540. }
  541. list_del(&hotplug->slot_list);
  542. slot = hotplug->pci_slot;
  543. fs_remove_slot(slot);
  544. dbg("Removed slot %s from the list\n", hotplug_slot_name(hotplug));
  545. hotplug->release(hotplug);
  546. slot->hotplug = NULL;
  547. pci_destroy_slot(slot);
  548. mutex_unlock(&pci_hp_mutex);
  549. return 0;
  550. }
  551. /**
  552. * pci_hp_change_slot_info - changes the slot's information structure in the core
  553. * @hotplug: pointer to the slot whose info has changed
  554. * @info: pointer to the info copy into the slot's info structure
  555. *
  556. * @slot must have been registered with the pci
  557. * hotplug subsystem previously with a call to pci_hp_register().
  558. *
  559. * Returns 0 if successful, anything else for an error.
  560. */
  561. int __must_check pci_hp_change_slot_info(struct hotplug_slot *hotplug,
  562. struct hotplug_slot_info *info)
  563. {
  564. struct pci_slot *slot;
  565. if (!hotplug || !info)
  566. return -ENODEV;
  567. slot = hotplug->pci_slot;
  568. memcpy(hotplug->info, info, sizeof(struct hotplug_slot_info));
  569. return 0;
  570. }
  571. static int __init pci_hotplug_init (void)
  572. {
  573. int result;
  574. result = cpci_hotplug_init(debug);
  575. if (result) {
  576. err ("cpci_hotplug_init with error %d\n", result);
  577. goto err_cpci;
  578. }
  579. info (DRIVER_DESC " version: " DRIVER_VERSION "\n");
  580. err_cpci:
  581. return result;
  582. }
  583. static void __exit pci_hotplug_exit (void)
  584. {
  585. cpci_hotplug_exit();
  586. }
  587. module_init(pci_hotplug_init);
  588. module_exit(pci_hotplug_exit);
  589. MODULE_AUTHOR(DRIVER_AUTHOR);
  590. MODULE_DESCRIPTION(DRIVER_DESC);
  591. MODULE_LICENSE("GPL");
  592. module_param(debug, bool, 0644);
  593. MODULE_PARM_DESC(debug, "Debugging mode enabled or not");
  594. EXPORT_SYMBOL_GPL(__pci_hp_register);
  595. EXPORT_SYMBOL_GPL(pci_hp_deregister);
  596. EXPORT_SYMBOL_GPL(pci_hp_change_slot_info);