pci_hotplug_core.c 17 KB

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