patch-2_6_7-vs1_9_1_12
[linux-2.6.git] / drivers / pci / hotplug / cpci_hotplug_core.c
1 /*
2  * CompactPCI Hot Plug Driver
3  *
4  * Copyright (C) 2002 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
28 #include <linux/config.h>
29 #include <linux/module.h>
30 #include <linux/kernel.h>
31 #include <linux/slab.h>
32 #include <linux/pci.h>
33 #include <linux/init.h>
34 #include <linux/interrupt.h>
35 #include <linux/smp_lock.h>
36 #include "pci_hotplug.h"
37 #include "cpci_hotplug.h"
38
39 #define DRIVER_VERSION  "0.2"
40 #define DRIVER_AUTHOR   "Scott Murray <scottm@somanetworks.com>"
41 #define DRIVER_DESC     "CompactPCI Hot Plug Core"
42
43 #define MY_NAME "cpci_hotplug"
44
45 #define dbg(format, arg...)                                     \
46         do {                                                    \
47                 if(cpci_debug)                                  \
48                         printk (KERN_DEBUG "%s: " format "\n",  \
49                                 MY_NAME , ## arg);              \
50         } while(0)
51 #define err(format, arg...) printk(KERN_ERR "%s: " format "\n", MY_NAME , ## arg)
52 #define info(format, arg...) printk(KERN_INFO "%s: " format "\n", MY_NAME , ## arg)
53 #define warn(format, arg...) printk(KERN_WARNING "%s: " format "\n", MY_NAME , ## arg)
54
55 /* local variables */
56 static spinlock_t list_lock;
57 static LIST_HEAD(slot_list);
58 static int slots;
59 int cpci_debug;
60 static struct cpci_hp_controller *controller;
61 static struct semaphore event_semaphore;        /* mutex for process loop (up if something to process) */
62 static struct semaphore thread_exit;            /* guard ensure thread has exited before calling it quits */
63 static int thread_finished = 1;
64
65 static int enable_slot(struct hotplug_slot *slot);
66 static int disable_slot(struct hotplug_slot *slot);
67 static int set_attention_status(struct hotplug_slot *slot, u8 value);
68 static int get_power_status(struct hotplug_slot *slot, u8 * value);
69 static int get_attention_status(struct hotplug_slot *slot, u8 * value);
70
71 static struct hotplug_slot_ops cpci_hotplug_slot_ops = {
72         .owner = THIS_MODULE,
73         .enable_slot = enable_slot,
74         .disable_slot = disable_slot,
75         .set_attention_status = set_attention_status,
76         .get_power_status = get_power_status,
77         .get_attention_status = get_attention_status,
78 };
79
80 static int
81 update_latch_status(struct hotplug_slot *hotplug_slot, u8 value)
82 {
83         struct hotplug_slot_info info;
84
85         memcpy(&info, hotplug_slot->info, sizeof(struct hotplug_slot_info));
86         info.latch_status = value;
87         return pci_hp_change_slot_info(hotplug_slot, &info);
88 }
89
90 static int
91 update_adapter_status(struct hotplug_slot *hotplug_slot, u8 value)
92 {
93         struct hotplug_slot_info info;
94
95         memcpy(&info, hotplug_slot->info, sizeof(struct hotplug_slot_info));
96         info.adapter_status = value;
97         return pci_hp_change_slot_info(hotplug_slot, &info);
98 }
99
100 static int
101 enable_slot(struct hotplug_slot *hotplug_slot)
102 {
103         struct slot *slot = hotplug_slot->private;
104         int retval = 0;
105
106         dbg("%s - physical_slot = %s", __FUNCTION__, hotplug_slot->name);
107
108         if(controller->ops->set_power) {
109                 retval = controller->ops->set_power(slot, 1);
110         }
111
112         return retval;
113 }
114
115 static int
116 disable_slot(struct hotplug_slot *hotplug_slot)
117 {
118         struct slot *slot = hotplug_slot->private;
119         int retval = 0;
120
121         dbg("%s - physical_slot = %s", __FUNCTION__, hotplug_slot->name);
122
123         /* Unconfigure device */
124         dbg("%s - unconfiguring slot %s",
125             __FUNCTION__, slot->hotplug_slot->name);
126         if((retval = cpci_unconfigure_slot(slot))) {
127                 err("%s - could not unconfigure slot %s",
128                     __FUNCTION__, slot->hotplug_slot->name);
129                 return retval;
130         }
131         dbg("%s - finished unconfiguring slot %s",
132             __FUNCTION__, slot->hotplug_slot->name);
133
134         /* Clear EXT (by setting it) */
135         if(cpci_clear_ext(slot)) {
136                 err("%s - could not clear EXT for slot %s",
137                     __FUNCTION__, slot->hotplug_slot->name);
138                 retval = -ENODEV;
139         }
140         cpci_led_on(slot);
141
142         if(controller->ops->set_power) {
143                 retval = controller->ops->set_power(slot, 0);
144         }
145
146         if(update_adapter_status(slot->hotplug_slot, 0)) {
147                 warn("failure to update adapter file");
148         }
149
150         slot->extracting = 0;
151
152         return retval;
153 }
154
155 static u8
156 cpci_get_power_status(struct slot *slot)
157 {
158         u8 power = 1;
159
160         if(controller->ops->get_power) {
161                 power = controller->ops->get_power(slot);
162         }
163         return power;
164 }
165
166 static int
167 get_power_status(struct hotplug_slot *hotplug_slot, u8 * value)
168 {
169         struct slot *slot = hotplug_slot->private;
170
171         *value = cpci_get_power_status(slot);
172         return 0;
173 }
174
175 static int
176 get_attention_status(struct hotplug_slot *hotplug_slot, u8 * value)
177 {
178         struct slot *slot = hotplug_slot->private;
179
180         *value = cpci_get_attention_status(slot);
181         return 0;
182 }
183
184 static int
185 set_attention_status(struct hotplug_slot *hotplug_slot, u8 status)
186 {
187         return cpci_set_attention_status(hotplug_slot->private, status);
188 }
189
190 static void release_slot(struct hotplug_slot *hotplug_slot)
191 {
192         struct slot *slot = hotplug_slot->private;
193
194         kfree(slot->hotplug_slot->info);
195         kfree(slot->hotplug_slot->name);
196         kfree(slot->hotplug_slot);
197         kfree(slot);
198 }
199
200 #define SLOT_NAME_SIZE  6
201 static void
202 make_slot_name(struct slot *slot)
203 {
204         snprintf(slot->hotplug_slot->name,
205                  SLOT_NAME_SIZE, "%02x:%02x", slot->bus->number, slot->number);
206 }
207
208 int
209 cpci_hp_register_bus(struct pci_bus *bus, u8 first, u8 last)
210 {
211         struct slot *slot;
212         struct hotplug_slot *hotplug_slot;
213         struct hotplug_slot_info *info;
214         char *name;
215         int status = -ENOMEM;
216         int i;
217
218         if(!(controller && bus)) {
219                 return -ENODEV;
220         }
221
222         /*
223          * Create a structure for each slot, and register that slot
224          * with the pci_hotplug subsystem.
225          */
226         for (i = first; i <= last; ++i) {
227                 slot = kmalloc(sizeof (struct slot), GFP_KERNEL);
228                 if (!slot)
229                         goto error;
230                 memset(slot, 0, sizeof (struct slot));
231
232                 hotplug_slot =
233                     kmalloc(sizeof (struct hotplug_slot), GFP_KERNEL);
234                 if (!hotplug_slot)
235                         goto error_slot;
236                 memset(hotplug_slot, 0, sizeof (struct hotplug_slot));
237                 slot->hotplug_slot = hotplug_slot;
238
239                 info = kmalloc(sizeof (struct hotplug_slot_info), GFP_KERNEL);
240                 if (!info)
241                         goto error_hpslot;
242                 memset(info, 0, sizeof (struct hotplug_slot_info));
243                 hotplug_slot->info = info;
244
245                 name = kmalloc(SLOT_NAME_SIZE, GFP_KERNEL);
246                 if (!name)
247                         goto error_info;
248                 hotplug_slot->name = name;
249
250                 slot->bus = bus;
251                 slot->number = i;
252                 slot->devfn = PCI_DEVFN(i, 0);
253
254                 hotplug_slot->private = slot;
255                 hotplug_slot->release = &release_slot;
256                 make_slot_name(slot);
257                 hotplug_slot->ops = &cpci_hotplug_slot_ops;
258
259                 /*
260                  * Initialize the slot info structure with some known
261                  * good values.
262                  */
263                 dbg("initializing slot %s", slot->hotplug_slot->name);
264                 info->power_status = cpci_get_power_status(slot);
265                 info->attention_status = cpci_get_attention_status(slot);
266
267                 dbg("registering slot %s", slot->hotplug_slot->name);
268                 status = pci_hp_register(slot->hotplug_slot);
269                 if (status) {
270                         err("pci_hp_register failed with error %d", status);
271                         goto error_name;
272                 }
273
274                 /* Add slot to our internal list */
275                 spin_lock(&list_lock);
276                 list_add(&slot->slot_list, &slot_list);
277                 slots++;
278                 spin_unlock(&list_lock);
279         }
280         return 0;
281 error_name:
282         kfree(name);
283 error_info:
284         kfree(info);
285 error_hpslot:
286         kfree(hotplug_slot);
287 error_slot:
288         kfree(slot);
289 error:
290         return status;
291 }
292
293 int
294 cpci_hp_unregister_bus(struct pci_bus *bus)
295 {
296         struct slot *slot;
297         struct list_head *tmp;
298         struct list_head *next;
299         int status;
300
301         spin_lock(&list_lock);
302         if(!slots) {
303                 spin_unlock(&list_lock);
304                 return -1;
305         }
306         list_for_each_safe(tmp, next, &slot_list) {
307                 slot = list_entry(tmp, struct slot, slot_list);
308                 if(slot->bus == bus) {
309                         dbg("deregistering slot %s", slot->hotplug_slot->name);
310                         status = pci_hp_deregister(slot->hotplug_slot);
311                         if(status) {
312                                 err("pci_hp_deregister failed with error %d",
313                                     status);
314                                 return status;
315                         }
316
317                         list_del(&slot->slot_list);
318                         slots--;
319                 }
320         }
321         spin_unlock(&list_lock);
322         return 0;
323 }
324
325 /* This is the interrupt mode interrupt handler */
326 static irqreturn_t
327 cpci_hp_intr(int irq, void *data, struct pt_regs *regs)
328 {
329         dbg("entered cpci_hp_intr");
330
331         /* Check to see if it was our interrupt */
332         if((controller->irq_flags & SA_SHIRQ) &&
333             !controller->ops->check_irq(controller->dev_id)) {
334                 dbg("exited cpci_hp_intr, not our interrupt");
335                 return IRQ_NONE;
336         }
337
338         /* Disable ENUM interrupt */
339         controller->ops->disable_irq();
340
341         /* Trigger processing by the event thread */
342         dbg("Signal event_semaphore");
343         up(&event_semaphore);
344         dbg("exited cpci_hp_intr");
345         return IRQ_HANDLED;
346 }
347
348 /*
349  * According to PICMG 2.12 R2.0, section 6.3.2, upon
350  * initialization, the system driver shall clear the
351  * INS bits of the cold-inserted devices.
352  */
353 static int
354 init_slots(void)
355 {
356         struct slot *slot;
357         struct list_head *tmp;
358         struct pci_dev* dev;
359
360         dbg("%s - enter", __FUNCTION__);
361         spin_lock(&list_lock);
362         if(!slots) {
363                 spin_unlock(&list_lock);
364                 return -1;
365         }
366         list_for_each(tmp, &slot_list) {
367                 slot = list_entry(tmp, struct slot, slot_list);
368                 dbg("%s - looking at slot %s",
369                     __FUNCTION__, slot->hotplug_slot->name);
370                 if(cpci_check_and_clear_ins(slot)) {
371                         dbg("%s - cleared INS for slot %s",
372                             __FUNCTION__, slot->hotplug_slot->name);
373                         dev = pci_find_slot(slot->bus->number, PCI_DEVFN(slot->number, 0));
374                         if(dev) {
375                                 if(update_adapter_status(slot->hotplug_slot, 1)) {
376                                         warn("failure to update adapter file");
377                                 }
378                                 if(update_latch_status(slot->hotplug_slot, 1)) {
379                                         warn("failure to update latch file");
380                                 }
381                                 slot->dev = dev;
382                         } else {
383                                 err("%s - no driver attached to device in slot %s",
384                                     __FUNCTION__, slot->hotplug_slot->name);
385                         }
386                 }
387         }
388         spin_unlock(&list_lock);
389         dbg("%s - exit", __FUNCTION__);
390         return 0;
391 }
392
393 static int
394 check_slots(void)
395 {
396         struct slot *slot;
397         struct list_head *tmp;
398         int extracted;
399         int inserted;
400
401         spin_lock(&list_lock);
402         if(!slots) {
403                 spin_unlock(&list_lock);
404                 err("no slots registered, shutting down");
405                 return -1;
406         }
407         extracted = inserted = 0;
408         list_for_each(tmp, &slot_list) {
409                 slot = list_entry(tmp, struct slot, slot_list);
410                 dbg("%s - looking at slot %s",
411                     __FUNCTION__, slot->hotplug_slot->name);
412                 if(cpci_check_and_clear_ins(slot)) {
413                         u16 hs_csr;
414
415                         /* Some broken hardware (e.g. PLX 9054AB) asserts ENUM# twice... */
416                         if(slot->dev) {
417                                 warn("slot %s already inserted", slot->hotplug_slot->name);
418                                 inserted++;
419                                 continue;
420                         }
421
422                         /* Process insertion */
423                         dbg("%s - slot %s inserted",
424                             __FUNCTION__, slot->hotplug_slot->name);
425
426                         /* GSM, debug */
427                         hs_csr = cpci_get_hs_csr(slot);
428                         dbg("%s - slot %s HS_CSR (1) = %04x",
429                             __FUNCTION__, slot->hotplug_slot->name, hs_csr);
430
431                         /* Configure device */
432                         dbg("%s - configuring slot %s",
433                             __FUNCTION__, slot->hotplug_slot->name);
434                         if(cpci_configure_slot(slot)) {
435                                 err("%s - could not configure slot %s",
436                                     __FUNCTION__, slot->hotplug_slot->name);
437                                 continue;
438                         }
439                         dbg("%s - finished configuring slot %s",
440                             __FUNCTION__, slot->hotplug_slot->name);
441
442                         /* GSM, debug */
443                         hs_csr = cpci_get_hs_csr(slot);
444                         dbg("%s - slot %s HS_CSR (2) = %04x",
445                             __FUNCTION__, slot->hotplug_slot->name, hs_csr);
446
447                         if(update_latch_status(slot->hotplug_slot, 1)) {
448                                 warn("failure to update latch file");
449                         }
450
451                         if(update_adapter_status(slot->hotplug_slot, 1)) {
452                                 warn("failure to update adapter file");
453                         }
454
455                         cpci_led_off(slot);
456
457                         /* GSM, debug */
458                         hs_csr = cpci_get_hs_csr(slot);
459                         dbg("%s - slot %s HS_CSR (3) = %04x",
460                             __FUNCTION__, slot->hotplug_slot->name, hs_csr);
461
462                         inserted++;
463                 } else if(cpci_check_ext(slot)) {
464                         u16 hs_csr;
465
466                         /* Process extraction request */
467                         dbg("%s - slot %s extracted",
468                             __FUNCTION__, slot->hotplug_slot->name);
469
470                         /* GSM, debug */
471                         hs_csr = cpci_get_hs_csr(slot);
472                         dbg("%s - slot %s HS_CSR = %04x",
473                             __FUNCTION__, slot->hotplug_slot->name, hs_csr);
474
475                         if(!slot->extracting) {
476                                 if(update_latch_status(slot->hotplug_slot, 0)) {
477                                         warn("failure to update latch file");
478                                 }
479                                 slot->extracting = 1;
480                         }
481                         extracted++;
482                 }
483         }
484         spin_unlock(&list_lock);
485         if(inserted || extracted) {
486                 return extracted;
487         }
488         else {
489                 err("cannot find ENUM# source, shutting down");
490                 return -1;
491         }
492 }
493
494 /* This is the interrupt mode worker thread body */
495 static int
496 event_thread(void *data)
497 {
498         int rc;
499         struct slot *slot;
500         struct list_head *tmp;
501
502         lock_kernel();
503         daemonize("cpci_hp_eventd");
504         unlock_kernel();
505
506         dbg("%s - event thread started", __FUNCTION__);
507         while(1) {
508                 dbg("event thread sleeping");
509                 down_interruptible(&event_semaphore);
510                 dbg("event thread woken, thread_finished = %d",
511                     thread_finished);
512                 if(thread_finished || signal_pending(current))
513                         break;
514                 while(controller->ops->query_enum()) {
515                         rc = check_slots();
516                         if(rc > 0) {
517                                 /* Give userspace a chance to handle extraction */
518                                 set_current_state(TASK_INTERRUPTIBLE);
519                                 schedule_timeout(HZ / 2);
520                         } else if(rc < 0) {
521                                 dbg("%s - error checking slots", __FUNCTION__);
522                                 thread_finished = 1;
523                                 break;
524                         }
525                 }
526                 /* Check for someone yanking out a board */
527                 list_for_each(tmp, &slot_list) {
528                         slot = list_entry(tmp, struct slot, slot_list);
529                         if(slot->extracting) {
530                                 /*
531                                  * Hmmm, we're likely hosed at this point, should we
532                                  * bother trying to tell the driver or not?
533                                  */
534                                 err("card in slot %s was improperly removed",
535                                     slot->hotplug_slot->name);
536                                 if(update_adapter_status(slot->hotplug_slot, 0)) {
537                                         warn("failure to update adapter file");
538                                 }
539                                 slot->extracting = 0;
540                         }
541                 }
542
543                 /* Re-enable ENUM# interrupt */
544                 dbg("%s - re-enabling irq", __FUNCTION__);
545                 controller->ops->enable_irq();
546         }
547
548         dbg("%s - event thread signals exit", __FUNCTION__);
549         up(&thread_exit);
550         return 0;
551 }
552
553 /* This is the polling mode worker thread body */
554 static int
555 poll_thread(void *data)
556 {
557         int rc;
558         struct slot *slot;
559         struct list_head *tmp;
560
561         lock_kernel();
562         daemonize("cpci_hp_polld");
563         unlock_kernel();
564
565         while(1) {
566                 if(thread_finished || signal_pending(current))
567                         break;
568
569                 while(controller->ops->query_enum()) {
570                         rc = check_slots();
571                         if(rc > 0) {
572                                 /* Give userspace a chance to handle extraction */
573                                 set_current_state(TASK_INTERRUPTIBLE);
574                                 schedule_timeout(HZ / 2);
575                         } else if(rc < 0) {
576                                 dbg("%s - error checking slots", __FUNCTION__);
577                                 thread_finished = 1;
578                                 break;
579                         }
580                 }
581                 /* Check for someone yanking out a board */
582                 list_for_each(tmp, &slot_list) {
583                         slot = list_entry(tmp, struct slot, slot_list);
584                         if(slot->extracting) {
585                                 /*
586                                  * Hmmm, we're likely hosed at this point, should we
587                                  * bother trying to tell the driver or not?
588                                  */
589                                 err("card in slot %s was improperly removed",
590                                     slot->hotplug_slot->name);
591                                 if(update_adapter_status(slot->hotplug_slot, 0)) {
592                                         warn("failure to update adapter file");
593                                 }
594                                 slot->extracting = 0;
595                         }
596                 }
597
598                 set_current_state(TASK_INTERRUPTIBLE);
599                 schedule_timeout(HZ / 10);
600         }
601         dbg("poll thread signals exit");
602         up(&thread_exit);
603         return 0;
604 }
605
606 static int
607 cpci_start_thread(void)
608 {
609         int pid;
610
611         /* initialize our semaphores */
612         init_MUTEX_LOCKED(&event_semaphore);
613         init_MUTEX_LOCKED(&thread_exit);
614         thread_finished = 0;
615
616         if(controller->irq) {
617                 pid = kernel_thread(event_thread, 0, 0);
618         } else {
619                 pid = kernel_thread(poll_thread, 0, 0);
620         }
621         if(pid < 0) {
622                 err("Can't start up our thread");
623                 return -1;
624         }
625         dbg("Our thread pid = %d", pid);
626         return 0;
627 }
628
629 static void
630 cpci_stop_thread(void)
631 {
632         thread_finished = 1;
633         dbg("thread finish command given");
634         if(controller->irq) {
635                 up(&event_semaphore);
636         }
637         dbg("wait for thread to exit");
638         down(&thread_exit);
639 }
640
641 int
642 cpci_hp_register_controller(struct cpci_hp_controller *new_controller)
643 {
644         int status = 0;
645
646         if(!controller) {
647                 controller = new_controller;
648                 if(controller->irq) {
649                         if(request_irq(controller->irq,
650                                         cpci_hp_intr,
651                                         controller->irq_flags,
652                                         MY_NAME, controller->dev_id)) {
653                                 err("Can't get irq %d for the hotplug cPCI controller", controller->irq);
654                                 status = -ENODEV;
655                         }
656                         dbg("%s - acquired controller irq %d", __FUNCTION__,
657                             controller->irq);
658                 }
659         } else {
660                 err("cPCI hotplug controller already registered");
661                 status = -1;
662         }
663         return status;
664 }
665
666 int
667 cpci_hp_unregister_controller(struct cpci_hp_controller *old_controller)
668 {
669         int status = 0;
670
671         if(controller) {
672                 if(!thread_finished) {
673                         cpci_stop_thread();
674                 }
675                 if(controller->irq) {
676                         free_irq(controller->irq, controller->dev_id);
677                 }
678                 controller = NULL;
679         } else {
680                 status = -ENODEV;
681         }
682         return status;
683 }
684
685 int
686 cpci_hp_start(void)
687 {
688         static int first = 1;
689         int status;
690
691         dbg("%s - enter", __FUNCTION__);
692         if(!controller) {
693                 return -ENODEV;
694         }
695
696         spin_lock(&list_lock);
697         if(!slots) {
698                 spin_unlock(&list_lock);
699                 return -ENODEV;
700         }
701         spin_unlock(&list_lock);
702
703         if(first) {
704                 status = init_slots();
705                 if(status) {
706                         return status;
707                 }
708                 first = 0;
709         }
710
711         status = cpci_start_thread();
712         if(status) {
713                 return status;
714         }
715         dbg("%s - thread started", __FUNCTION__);
716
717         if(controller->irq) {
718                 /* Start enum interrupt processing */
719                 dbg("%s - enabling irq", __FUNCTION__);
720                 controller->ops->enable_irq();
721         }
722         dbg("%s - exit", __FUNCTION__);
723         return 0;
724 }
725
726 int
727 cpci_hp_stop(void)
728 {
729         if(!controller) {
730                 return -ENODEV;
731         }
732
733         if(controller->irq) {
734                 /* Stop enum interrupt processing */
735                 dbg("%s - disabling irq", __FUNCTION__);
736                 controller->ops->disable_irq();
737         }
738         cpci_stop_thread();
739         return 0;
740 }
741
742 static void __exit
743 cleanup_slots(void)
744 {
745         struct list_head *tmp;
746         struct slot *slot;
747
748         /*
749          * Unregister all of our slots with the pci_hotplug subsystem,
750          * and free up all memory that we had allocated.
751          */
752         spin_lock(&list_lock);
753         if(!slots) {
754                 goto null_cleanup;
755         }
756         list_for_each(tmp, &slot_list) {
757                 slot = list_entry(tmp, struct slot, slot_list);
758                 list_del(&slot->slot_list);
759                 pci_hp_deregister(slot->hotplug_slot);
760                 kfree(slot->hotplug_slot->info);
761                 kfree(slot->hotplug_slot->name);
762                 kfree(slot->hotplug_slot);
763                 kfree(slot);
764         }
765       null_cleanup:
766         spin_unlock(&list_lock);
767         return;
768 }
769
770 int __init
771 cpci_hotplug_init(int debug)
772 {
773         spin_lock_init(&list_lock);
774         cpci_debug = debug;
775
776         info(DRIVER_DESC " version: " DRIVER_VERSION);
777         return 0;
778 }
779
780 void __exit
781 cpci_hotplug_exit(void)
782 {
783         /*
784          * Clean everything up.
785          */
786         cleanup_slots();
787 }
788
789 EXPORT_SYMBOL_GPL(cpci_hp_register_controller);
790 EXPORT_SYMBOL_GPL(cpci_hp_unregister_controller);
791 EXPORT_SYMBOL_GPL(cpci_hp_register_bus);
792 EXPORT_SYMBOL_GPL(cpci_hp_unregister_bus);
793 EXPORT_SYMBOL_GPL(cpci_hp_start);
794 EXPORT_SYMBOL_GPL(cpci_hp_stop);