I2O: Fix "defined but not used" build warnings
[linux-2.6] / drivers / ssb / pcihost_wrapper.c
1 /*
2  * Sonics Silicon Backplane
3  * PCI Hostdevice wrapper
4  *
5  * Copyright (c) 2005 Martin Langer <martin-langer@gmx.de>
6  * Copyright (c) 2005 Stefano Brivio <st3@riseup.net>
7  * Copyright (c) 2005 Danny van Dyk <kugelfang@gentoo.org>
8  * Copyright (c) 2005 Andreas Jaggi <andreas.jaggi@waterwave.ch>
9  * Copyright (c) 2005-2007 Michael Buesch <mbuesch@freenet.de>
10  *
11  * Licensed under the GNU/GPL. See COPYING for details.
12  */
13
14 #include <linux/pci.h>
15 #include <linux/ssb/ssb.h>
16
17
18 #ifdef CONFIG_PM
19 static int ssb_pcihost_suspend(struct pci_dev *dev, pm_message_t state)
20 {
21         pci_save_state(dev);
22         pci_disable_device(dev);
23         pci_set_power_state(dev, pci_choose_state(dev, state));
24
25         return 0;
26 }
27
28 static int ssb_pcihost_resume(struct pci_dev *dev)
29 {
30         int err;
31
32         pci_set_power_state(dev, 0);
33         err = pci_enable_device(dev);
34         if (err)
35                 return err;
36         pci_restore_state(dev);
37
38         return 0;
39 }
40 #else /* CONFIG_PM */
41 # define ssb_pcihost_suspend    NULL
42 # define ssb_pcihost_resume     NULL
43 #endif /* CONFIG_PM */
44
45 static int ssb_pcihost_probe(struct pci_dev *dev,
46                              const struct pci_device_id *id)
47 {
48         struct ssb_bus *ssb;
49         int err = -ENOMEM;
50         const char *name;
51
52         ssb = kzalloc(sizeof(*ssb), GFP_KERNEL);
53         if (!ssb)
54                 goto out;
55         err = pci_enable_device(dev);
56         if (err)
57                 goto err_kfree_ssb;
58         name = dev->dev.bus_id;
59         if (dev->driver && dev->driver->name)
60                 name = dev->driver->name;
61         err = pci_request_regions(dev, name);
62         if (err)
63                 goto err_pci_disable;
64         pci_set_master(dev);
65
66         err = ssb_bus_pcibus_register(ssb, dev);
67         if (err)
68                 goto err_pci_release_regions;
69
70         pci_set_drvdata(dev, ssb);
71
72 out:
73         return err;
74
75 err_pci_release_regions:
76         pci_release_regions(dev);
77 err_pci_disable:
78         pci_disable_device(dev);
79 err_kfree_ssb:
80         kfree(ssb);
81         return err;
82 }
83
84 static void ssb_pcihost_remove(struct pci_dev *dev)
85 {
86         struct ssb_bus *ssb = pci_get_drvdata(dev);
87
88         ssb_bus_unregister(ssb);
89         pci_release_regions(dev);
90         pci_disable_device(dev);
91         kfree(ssb);
92         pci_set_drvdata(dev, NULL);
93 }
94
95 int ssb_pcihost_register(struct pci_driver *driver)
96 {
97         driver->probe = ssb_pcihost_probe;
98         driver->remove = ssb_pcihost_remove;
99         driver->suspend = ssb_pcihost_suspend;
100         driver->resume = ssb_pcihost_resume;
101
102         return pci_register_driver(driver);
103 }
104 EXPORT_SYMBOL(ssb_pcihost_register);