Merge branch 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/jmorris...
[sfrench/cifs-2.6.git] / drivers / pci / hotplug / pci_hotplug_core.c
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
28 #include <linux/module.h>
29 #include <linux/moduleparam.h>
30 #include <linux/kernel.h>
31 #include <linux/types.h>
32 #include <linux/list.h>
33 #include <linux/kobject.h>
34 #include <linux/sysfs.h>
35 #include <linux/pagemap.h>
36 #include <linux/slab.h>
37 #include <linux/init.h>
38 #include <linux/mount.h>
39 #include <linux/namei.h>
40 #include <linux/pci.h>
41 #include <linux/pci_hotplug.h>
42 #include <asm/uaccess.h>
43
44 #define MY_NAME "pci_hotplug"
45
46 #define dbg(fmt, arg...) do { if (debug) printk(KERN_DEBUG "%s: %s: " fmt , MY_NAME , __FUNCTION__ , ## arg); } while (0)
47 #define err(format, arg...) printk(KERN_ERR "%s: " format , MY_NAME , ## arg)
48 #define info(format, arg...) printk(KERN_INFO "%s: " format , MY_NAME , ## arg)
49 #define warn(format, arg...) printk(KERN_WARNING "%s: " format , MY_NAME , ## arg)
50
51
52 /* local variables */
53 static int debug;
54
55 #define DRIVER_VERSION  "0.5"
56 #define DRIVER_AUTHOR   "Greg Kroah-Hartman <greg@kroah.com>, Scott Murray <scottm@somanetworks.com>"
57 #define DRIVER_DESC     "PCI Hot Plug PCI Core"
58
59
60 //////////////////////////////////////////////////////////////////
61
62 static LIST_HEAD(pci_hotplug_slot_list);
63
64 struct kset *pci_hotplug_slots_kset;
65
66 static ssize_t hotplug_slot_attr_show(struct kobject *kobj,
67                 struct attribute *attr, char *buf)
68 {
69         struct hotplug_slot *slot = to_hotplug_slot(kobj);
70         struct hotplug_slot_attribute *attribute = to_hotplug_attr(attr);
71         return attribute->show ? attribute->show(slot, buf) : -EIO;
72 }
73
74 static ssize_t hotplug_slot_attr_store(struct kobject *kobj,
75                 struct attribute *attr, const char *buf, size_t len)
76 {
77         struct hotplug_slot *slot = to_hotplug_slot(kobj);
78         struct hotplug_slot_attribute *attribute = to_hotplug_attr(attr);
79         return attribute->store ? attribute->store(slot, buf, len) : -EIO;
80 }
81
82 static struct sysfs_ops hotplug_slot_sysfs_ops = {
83         .show = hotplug_slot_attr_show,
84         .store = hotplug_slot_attr_store,
85 };
86
87 static void hotplug_slot_release(struct kobject *kobj)
88 {
89         struct hotplug_slot *slot = to_hotplug_slot(kobj);
90         if (slot->release)
91                 slot->release(slot);
92 }
93
94 static struct kobj_type hotplug_slot_ktype = {
95         .sysfs_ops = &hotplug_slot_sysfs_ops,
96         .release = &hotplug_slot_release,
97 };
98
99 /* these strings match up with the values in pci_bus_speed */
100 static char *pci_bus_speed_strings[] = {
101         "33 MHz PCI",           /* 0x00 */
102         "66 MHz PCI",           /* 0x01 */
103         "66 MHz PCIX",          /* 0x02 */
104         "100 MHz PCIX",         /* 0x03 */
105         "133 MHz PCIX",         /* 0x04 */
106         NULL,                   /* 0x05 */
107         NULL,                   /* 0x06 */
108         NULL,                   /* 0x07 */
109         NULL,                   /* 0x08 */
110         "66 MHz PCIX 266",      /* 0x09 */
111         "100 MHz PCIX 266",     /* 0x0a */
112         "133 MHz PCIX 266",     /* 0x0b */
113         NULL,                   /* 0x0c */
114         NULL,                   /* 0x0d */
115         NULL,                   /* 0x0e */
116         NULL,                   /* 0x0f */
117         NULL,                   /* 0x10 */
118         "66 MHz PCIX 533",      /* 0x11 */
119         "100 MHz PCIX 533",     /* 0x12 */
120         "133 MHz PCIX 533",     /* 0x13 */
121         "25 GBps PCI-E",        /* 0x14 */
122 };
123
124 #ifdef CONFIG_HOTPLUG_PCI_CPCI
125 extern int cpci_hotplug_init(int debug);
126 extern void cpci_hotplug_exit(void);
127 #else
128 static inline int cpci_hotplug_init(int debug) { return 0; }
129 static inline void cpci_hotplug_exit(void) { }
130 #endif
131
132 /* Weee, fun with macros... */
133 #define GET_STATUS(name,type)   \
134 static int get_##name (struct hotplug_slot *slot, type *value)          \
135 {                                                                       \
136         struct hotplug_slot_ops *ops = slot->ops;                       \
137         int retval = 0;                                                 \
138         if (try_module_get(ops->owner)) {                               \
139                 if (ops->get_##name)                                    \
140                         retval = ops->get_##name (slot, value);         \
141                 else                                                    \
142                         *value = slot->info->name;                      \
143                 module_put(ops->owner);                                 \
144         }                                                               \
145         return retval;                                                  \
146 }
147
148 GET_STATUS(power_status, u8)
149 GET_STATUS(attention_status, u8)
150 GET_STATUS(latch_status, u8)
151 GET_STATUS(adapter_status, u8)
152 GET_STATUS(address, u32)
153 GET_STATUS(max_bus_speed, enum pci_bus_speed)
154 GET_STATUS(cur_bus_speed, enum pci_bus_speed)
155
156 static ssize_t power_read_file (struct hotplug_slot *slot, char *buf)
157 {
158         int retval;
159         u8 value;
160
161         retval = get_power_status (slot, &value);
162         if (retval)
163                 goto exit;
164         retval = sprintf (buf, "%d\n", value);
165 exit:
166         return retval;
167 }
168
169 static ssize_t power_write_file (struct hotplug_slot *slot, const char *buf,
170                 size_t count)
171 {
172         unsigned long lpower;
173         u8 power;
174         int retval = 0;
175
176         lpower = simple_strtoul (buf, NULL, 10);
177         power = (u8)(lpower & 0xff);
178         dbg ("power = %d\n", power);
179
180         if (!try_module_get(slot->ops->owner)) {
181                 retval = -ENODEV;
182                 goto exit;
183         }
184         switch (power) {
185                 case 0:
186                         if (slot->ops->disable_slot)
187                                 retval = slot->ops->disable_slot(slot);
188                         break;
189
190                 case 1:
191                         if (slot->ops->enable_slot)
192                                 retval = slot->ops->enable_slot(slot);
193                         break;
194
195                 default:
196                         err ("Illegal value specified for power\n");
197                         retval = -EINVAL;
198         }
199         module_put(slot->ops->owner);
200
201 exit:   
202         if (retval)
203                 return retval;
204         return count;
205 }
206
207 static struct hotplug_slot_attribute hotplug_slot_attr_power = {
208         .attr = {.name = "power", .mode = S_IFREG | S_IRUGO | S_IWUSR},
209         .show = power_read_file,
210         .store = power_write_file
211 };
212
213 static ssize_t attention_read_file (struct hotplug_slot *slot, char *buf)
214 {
215         int retval;
216         u8 value;
217
218         retval = get_attention_status (slot, &value);
219         if (retval)
220                 goto exit;
221         retval = sprintf (buf, "%d\n", value);
222
223 exit:
224         return retval;
225 }
226
227 static ssize_t attention_write_file (struct hotplug_slot *slot, const char *buf,
228                 size_t count)
229 {
230         unsigned long lattention;
231         u8 attention;
232         int retval = 0;
233
234         lattention = simple_strtoul (buf, NULL, 10);
235         attention = (u8)(lattention & 0xff);
236         dbg (" - attention = %d\n", attention);
237
238         if (!try_module_get(slot->ops->owner)) {
239                 retval = -ENODEV;
240                 goto exit;
241         }
242         if (slot->ops->set_attention_status)
243                 retval = slot->ops->set_attention_status(slot, attention);
244         module_put(slot->ops->owner);
245
246 exit:   
247         if (retval)
248                 return retval;
249         return count;
250 }
251
252 static struct hotplug_slot_attribute hotplug_slot_attr_attention = {
253         .attr = {.name = "attention", .mode = S_IFREG | S_IRUGO | S_IWUSR},
254         .show = attention_read_file,
255         .store = attention_write_file
256 };
257
258 static ssize_t latch_read_file (struct hotplug_slot *slot, char *buf)
259 {
260         int retval;
261         u8 value;
262
263         retval = get_latch_status (slot, &value);
264         if (retval)
265                 goto exit;
266         retval = sprintf (buf, "%d\n", value);
267
268 exit:
269         return retval;
270 }
271
272 static struct hotplug_slot_attribute hotplug_slot_attr_latch = {
273         .attr = {.name = "latch", .mode = S_IFREG | S_IRUGO},
274         .show = latch_read_file,
275 };
276
277 static ssize_t presence_read_file (struct hotplug_slot *slot, char *buf)
278 {
279         int retval;
280         u8 value;
281
282         retval = get_adapter_status (slot, &value);
283         if (retval)
284                 goto exit;
285         retval = sprintf (buf, "%d\n", value);
286
287 exit:
288         return retval;
289 }
290
291 static struct hotplug_slot_attribute hotplug_slot_attr_presence = {
292         .attr = {.name = "adapter", .mode = S_IFREG | S_IRUGO},
293         .show = presence_read_file,
294 };
295
296 static ssize_t address_read_file (struct hotplug_slot *slot, char *buf)
297 {
298         int retval;
299         u32 address;
300
301         retval = get_address (slot, &address);
302         if (retval)
303                 goto exit;
304         retval = sprintf (buf, "%04x:%02x:%02x\n",
305                           (address >> 16) & 0xffff,
306                           (address >> 8) & 0xff,
307                           address & 0xff);
308
309 exit:
310         return retval;
311 }
312
313 static struct hotplug_slot_attribute hotplug_slot_attr_address = {
314         .attr = {.name = "address", .mode = S_IFREG | S_IRUGO},
315         .show = address_read_file,
316 };
317
318 static char *unknown_speed = "Unknown bus speed";
319
320 static ssize_t max_bus_speed_read_file (struct hotplug_slot *slot, char *buf)
321 {
322         char *speed_string;
323         int retval;
324         enum pci_bus_speed value;
325         
326         retval = get_max_bus_speed (slot, &value);
327         if (retval)
328                 goto exit;
329
330         if (value == PCI_SPEED_UNKNOWN)
331                 speed_string = unknown_speed;
332         else
333                 speed_string = pci_bus_speed_strings[value];
334         
335         retval = sprintf (buf, "%s\n", speed_string);
336
337 exit:
338         return retval;
339 }
340
341 static struct hotplug_slot_attribute hotplug_slot_attr_max_bus_speed = {
342         .attr = {.name = "max_bus_speed", .mode = S_IFREG | S_IRUGO},
343         .show = max_bus_speed_read_file,
344 };
345
346 static ssize_t cur_bus_speed_read_file (struct hotplug_slot *slot, char *buf)
347 {
348         char *speed_string;
349         int retval;
350         enum pci_bus_speed value;
351
352         retval = get_cur_bus_speed (slot, &value);
353         if (retval)
354                 goto exit;
355
356         if (value == PCI_SPEED_UNKNOWN)
357                 speed_string = unknown_speed;
358         else
359                 speed_string = pci_bus_speed_strings[value];
360         
361         retval = sprintf (buf, "%s\n", speed_string);
362
363 exit:
364         return retval;
365 }
366
367 static struct hotplug_slot_attribute hotplug_slot_attr_cur_bus_speed = {
368         .attr = {.name = "cur_bus_speed", .mode = S_IFREG | S_IRUGO},
369         .show = cur_bus_speed_read_file,
370 };
371
372 static ssize_t test_write_file (struct hotplug_slot *slot, const char *buf,
373                 size_t count)
374 {
375         unsigned long ltest;
376         u32 test;
377         int retval = 0;
378
379         ltest = simple_strtoul (buf, NULL, 10);
380         test = (u32)(ltest & 0xffffffff);
381         dbg ("test = %d\n", test);
382
383         if (!try_module_get(slot->ops->owner)) {
384                 retval = -ENODEV;
385                 goto exit;
386         }
387         if (slot->ops->hardware_test)
388                 retval = slot->ops->hardware_test(slot, test);
389         module_put(slot->ops->owner);
390
391 exit:   
392         if (retval)
393                 return retval;
394         return count;
395 }
396
397 static struct hotplug_slot_attribute hotplug_slot_attr_test = {
398         .attr = {.name = "test", .mode = S_IFREG | S_IRUGO | S_IWUSR},
399         .store = test_write_file
400 };
401
402 static int has_power_file (struct hotplug_slot *slot)
403 {
404         if ((!slot) || (!slot->ops))
405                 return -ENODEV;
406         if ((slot->ops->enable_slot) ||
407             (slot->ops->disable_slot) ||
408             (slot->ops->get_power_status))
409                 return 0;
410         return -ENOENT;
411 }
412
413 static int has_attention_file (struct hotplug_slot *slot)
414 {
415         if ((!slot) || (!slot->ops))
416                 return -ENODEV;
417         if ((slot->ops->set_attention_status) ||
418             (slot->ops->get_attention_status))
419                 return 0;
420         return -ENOENT;
421 }
422
423 static int has_latch_file (struct hotplug_slot *slot)
424 {
425         if ((!slot) || (!slot->ops))
426                 return -ENODEV;
427         if (slot->ops->get_latch_status)
428                 return 0;
429         return -ENOENT;
430 }
431
432 static int has_adapter_file (struct hotplug_slot *slot)
433 {
434         if ((!slot) || (!slot->ops))
435                 return -ENODEV;
436         if (slot->ops->get_adapter_status)
437                 return 0;
438         return -ENOENT;
439 }
440
441 static int has_address_file (struct hotplug_slot *slot)
442 {
443         if ((!slot) || (!slot->ops))
444                 return -ENODEV;
445         if (slot->ops->get_address)
446                 return 0;
447         return -ENOENT;
448 }
449
450 static int has_max_bus_speed_file (struct hotplug_slot *slot)
451 {
452         if ((!slot) || (!slot->ops))
453                 return -ENODEV;
454         if (slot->ops->get_max_bus_speed)
455                 return 0;
456         return -ENOENT;
457 }
458
459 static int has_cur_bus_speed_file (struct hotplug_slot *slot)
460 {
461         if ((!slot) || (!slot->ops))
462                 return -ENODEV;
463         if (slot->ops->get_cur_bus_speed)
464                 return 0;
465         return -ENOENT;
466 }
467
468 static int has_test_file (struct hotplug_slot *slot)
469 {
470         if ((!slot) || (!slot->ops))
471                 return -ENODEV;
472         if (slot->ops->hardware_test)
473                 return 0;
474         return -ENOENT;
475 }
476
477 static int fs_add_slot (struct hotplug_slot *slot)
478 {
479         int retval = 0;
480
481         if (has_power_file(slot) == 0) {
482                 retval = sysfs_create_file(&slot->kobj, &hotplug_slot_attr_power.attr);
483                 if (retval)
484                         goto exit_power;
485         }
486
487         if (has_attention_file(slot) == 0) {
488                 retval = sysfs_create_file(&slot->kobj,
489                                            &hotplug_slot_attr_attention.attr);
490                 if (retval)
491                         goto exit_attention;
492         }
493
494         if (has_latch_file(slot) == 0) {
495                 retval = sysfs_create_file(&slot->kobj,
496                                            &hotplug_slot_attr_latch.attr);
497                 if (retval)
498                         goto exit_latch;
499         }
500
501         if (has_adapter_file(slot) == 0) {
502                 retval = sysfs_create_file(&slot->kobj,
503                                            &hotplug_slot_attr_presence.attr);
504                 if (retval)
505                         goto exit_adapter;
506         }
507
508         if (has_address_file(slot) == 0) {
509                 retval = sysfs_create_file(&slot->kobj,
510                                            &hotplug_slot_attr_address.attr);
511                 if (retval)
512                         goto exit_address;
513         }
514
515         if (has_max_bus_speed_file(slot) == 0) {
516                 retval = sysfs_create_file(&slot->kobj,
517                                            &hotplug_slot_attr_max_bus_speed.attr);
518                 if (retval)
519                         goto exit_max_speed;
520         }
521
522         if (has_cur_bus_speed_file(slot) == 0) {
523                 retval = sysfs_create_file(&slot->kobj,
524                                            &hotplug_slot_attr_cur_bus_speed.attr);
525                 if (retval)
526                         goto exit_cur_speed;
527         }
528
529         if (has_test_file(slot) == 0) {
530                 retval = sysfs_create_file(&slot->kobj,
531                                            &hotplug_slot_attr_test.attr);
532                 if (retval)
533                         goto exit_test;
534         }
535
536         goto exit;
537
538 exit_test:
539         if (has_cur_bus_speed_file(slot) == 0)
540                 sysfs_remove_file(&slot->kobj, &hotplug_slot_attr_cur_bus_speed.attr);
541
542 exit_cur_speed:
543         if (has_max_bus_speed_file(slot) == 0)
544                 sysfs_remove_file(&slot->kobj, &hotplug_slot_attr_max_bus_speed.attr);
545
546 exit_max_speed:
547         if (has_address_file(slot) == 0)
548                 sysfs_remove_file(&slot->kobj, &hotplug_slot_attr_address.attr);
549
550 exit_address:
551         if (has_adapter_file(slot) == 0)
552                 sysfs_remove_file(&slot->kobj, &hotplug_slot_attr_presence.attr);
553
554 exit_adapter:
555         if (has_latch_file(slot) == 0)
556                 sysfs_remove_file(&slot->kobj, &hotplug_slot_attr_latch.attr);
557
558 exit_latch:
559         if (has_attention_file(slot) == 0)
560                 sysfs_remove_file(&slot->kobj, &hotplug_slot_attr_attention.attr);
561
562 exit_attention:
563         if (has_power_file(slot) == 0)
564                 sysfs_remove_file(&slot->kobj, &hotplug_slot_attr_power.attr);
565 exit_power:
566 exit:
567         return retval;
568 }
569
570 static void fs_remove_slot (struct hotplug_slot *slot)
571 {
572         if (has_power_file(slot) == 0)
573                 sysfs_remove_file(&slot->kobj, &hotplug_slot_attr_power.attr);
574
575         if (has_attention_file(slot) == 0)
576                 sysfs_remove_file(&slot->kobj, &hotplug_slot_attr_attention.attr);
577
578         if (has_latch_file(slot) == 0)
579                 sysfs_remove_file(&slot->kobj, &hotplug_slot_attr_latch.attr);
580
581         if (has_adapter_file(slot) == 0)
582                 sysfs_remove_file(&slot->kobj, &hotplug_slot_attr_presence.attr);
583
584         if (has_address_file(slot) == 0)
585                 sysfs_remove_file(&slot->kobj, &hotplug_slot_attr_address.attr);
586
587         if (has_max_bus_speed_file(slot) == 0)
588                 sysfs_remove_file(&slot->kobj, &hotplug_slot_attr_max_bus_speed.attr);
589
590         if (has_cur_bus_speed_file(slot) == 0)
591                 sysfs_remove_file(&slot->kobj, &hotplug_slot_attr_cur_bus_speed.attr);
592
593         if (has_test_file(slot) == 0)
594                 sysfs_remove_file(&slot->kobj, &hotplug_slot_attr_test.attr);
595 }
596
597 static struct hotplug_slot *get_slot_from_name (const char *name)
598 {
599         struct hotplug_slot *slot;
600         struct list_head *tmp;
601
602         list_for_each (tmp, &pci_hotplug_slot_list) {
603                 slot = list_entry (tmp, struct hotplug_slot, slot_list);
604                 if (strcmp(slot->name, name) == 0)
605                         return slot;
606         }
607         return NULL;
608 }
609
610 /**
611  * pci_hp_register - register a hotplug_slot with the PCI hotplug subsystem
612  * @slot: pointer to the &struct hotplug_slot to register
613  *
614  * Registers a hotplug slot with the pci hotplug subsystem, which will allow
615  * userspace interaction to the slot.
616  *
617  * Returns 0 if successful, anything else for an error.
618  */
619 int pci_hp_register (struct hotplug_slot *slot)
620 {
621         int result;
622
623         if (slot == NULL)
624                 return -ENODEV;
625         if ((slot->info == NULL) || (slot->ops == NULL))
626                 return -EINVAL;
627         if (slot->release == NULL) {
628                 dbg("Why are you trying to register a hotplug slot"
629                     "without a proper release function?\n");
630                 return -EINVAL;
631         }
632
633         /* this can fail if we have already registered a slot with the same name */
634         slot->kobj.kset = pci_hotplug_slots_kset;
635         result = kobject_init_and_add(&slot->kobj, &hotplug_slot_ktype, NULL,
636                                       "%s", slot->name);
637         if (result) {
638                 err("Unable to register kobject '%s'", slot->name);
639                 return -EINVAL;
640         }
641
642         list_add (&slot->slot_list, &pci_hotplug_slot_list);
643
644         result = fs_add_slot (slot);
645         kobject_uevent(&slot->kobj, KOBJ_ADD);
646         dbg ("Added slot %s to the list\n", slot->name);
647         return result;
648 }
649
650 /**
651  * pci_hp_deregister - deregister a hotplug_slot with the PCI hotplug subsystem
652  * @slot: pointer to the &struct hotplug_slot to deregister
653  *
654  * The @slot must have been registered with the pci hotplug subsystem
655  * previously with a call to pci_hp_register().
656  *
657  * Returns 0 if successful, anything else for an error.
658  */
659 int pci_hp_deregister (struct hotplug_slot *slot)
660 {
661         struct hotplug_slot *temp;
662
663         if (slot == NULL)
664                 return -ENODEV;
665
666         temp = get_slot_from_name (slot->name);
667         if (temp != slot) {
668                 return -ENODEV;
669         }
670         list_del (&slot->slot_list);
671
672         fs_remove_slot (slot);
673         dbg ("Removed slot %s from the list\n", slot->name);
674         kobject_put(&slot->kobj);
675         return 0;
676 }
677
678 /**
679  * pci_hp_change_slot_info - changes the slot's information structure in the core
680  * @slot: pointer to the slot whose info has changed
681  * @info: pointer to the info copy into the slot's info structure
682  *
683  * @slot must have been registered with the pci 
684  * hotplug subsystem previously with a call to pci_hp_register().
685  *
686  * Returns 0 if successful, anything else for an error.
687  */
688 int __must_check pci_hp_change_slot_info(struct hotplug_slot *slot,
689                                          struct hotplug_slot_info *info)
690 {
691         if ((slot == NULL) || (info == NULL))
692                 return -ENODEV;
693
694         memcpy (slot->info, info, sizeof (struct hotplug_slot_info));
695
696         return 0;
697 }
698
699 static int __init pci_hotplug_init (void)
700 {
701         int result;
702         struct kset *pci_bus_kset;
703
704         pci_bus_kset = bus_get_kset(&pci_bus_type);
705
706         pci_hotplug_slots_kset = kset_create_and_add("slots", NULL,
707                                                      &pci_bus_kset->kobj);
708         if (!pci_hotplug_slots_kset) {
709                 result = -ENOMEM;
710                 err("Register subsys error\n");
711                 goto exit;
712         }
713         result = cpci_hotplug_init(debug);
714         if (result) {
715                 err ("cpci_hotplug_init with error %d\n", result);
716                 goto err_subsys;
717         }
718
719         info (DRIVER_DESC " version: " DRIVER_VERSION "\n");
720         goto exit;
721
722 err_subsys:
723         kset_unregister(pci_hotplug_slots_kset);
724 exit:
725         return result;
726 }
727
728 static void __exit pci_hotplug_exit (void)
729 {
730         cpci_hotplug_exit();
731         kset_unregister(pci_hotplug_slots_kset);
732 }
733
734 module_init(pci_hotplug_init);
735 module_exit(pci_hotplug_exit);
736
737 MODULE_AUTHOR(DRIVER_AUTHOR);
738 MODULE_DESCRIPTION(DRIVER_DESC);
739 MODULE_LICENSE("GPL");
740 module_param(debug, bool, 0644);
741 MODULE_PARM_DESC(debug, "Debugging mode enabled or not");
742
743 EXPORT_SYMBOL_GPL(pci_hotplug_slots_kset);
744 EXPORT_SYMBOL_GPL(pci_hp_register);
745 EXPORT_SYMBOL_GPL(pci_hp_deregister);
746 EXPORT_SYMBOL_GPL(pci_hp_change_slot_info);