This commit was manufactured by cvs2svn to create branch 'vserver'.
[linux-2.6.git] / drivers / xen / pcifront / pci.c
1 /*
2  * PCI Frontend Operations - ensure only one PCI frontend runs at a time
3  *
4  *   Author: Ryan Wilson <hap9@epoch.ncsc.mil>
5  */
6 #include <linux/module.h>
7 #include <linux/init.h>
8 #include <linux/pci.h>
9 #include <linux/spinlock.h>
10 #include "pcifront.h"
11
12 DEFINE_SPINLOCK(pcifront_dev_lock);
13 static struct pcifront_device *pcifront_dev = NULL;
14
15 int pcifront_connect(struct pcifront_device *pdev)
16 {
17         int err = 0;
18
19         spin_lock(&pcifront_dev_lock);
20
21         if (!pcifront_dev) {
22                 dev_info(&pdev->xdev->dev, "Installing PCI frontend\n");
23                 pcifront_dev = pdev;
24         }
25         else {
26                 dev_err(&pdev->xdev->dev, "PCI frontend already installed!\n");
27                 err = -EEXIST;
28         }
29
30         spin_unlock(&pcifront_dev_lock);
31
32         return err;
33 }
34
35 void pcifront_disconnect(struct pcifront_device *pdev)
36 {
37         spin_lock(&pcifront_dev_lock);
38
39         if (pdev == pcifront_dev) {
40                 dev_info(&pdev->xdev->dev,
41                          "Disconnecting PCI Frontend Buses\n");
42                 pcifront_dev = NULL;
43         }
44
45         spin_unlock(&pcifront_dev_lock);
46 }