1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23#include <linux/kernel.h>
24#include <linux/module.h>
25#include <linux/pci.h>
26
27#include <pcmcia/ss.h>
28
29
30static void cardbus_config_irq_and_cls(struct pci_bus *bus, int irq)
31{
32 struct pci_dev *dev;
33
34 list_for_each_entry(dev, &bus->devices, bus_list) {
35 u8 irq_pin;
36
37
38
39
40
41
42 pci_read_config_byte(dev, PCI_INTERRUPT_PIN, &irq_pin);
43 if (irq_pin) {
44 dev->irq = irq;
45 pci_write_config_byte(dev, PCI_INTERRUPT_LINE, dev->irq);
46 }
47
48
49
50
51
52
53 pci_set_cacheline_size(dev);
54
55 if (dev->subordinate)
56 cardbus_config_irq_and_cls(dev->subordinate, irq);
57 }
58}
59
60
61
62
63
64
65
66
67int __ref cb_alloc(struct pcmcia_socket *s)
68{
69 struct pci_bus *bus = s->cb_dev->subordinate;
70 struct pci_dev *dev;
71 unsigned int max, pass;
72
73 pci_lock_rescan_remove();
74
75 s->functions = pci_scan_slot(bus, PCI_DEVFN(0, 0));
76 pci_fixup_cardbus(bus);
77
78 max = bus->busn_res.start;
79 for (pass = 0; pass < 2; pass++)
80 for_each_pci_bridge(dev, bus)
81 max = pci_scan_bridge(bus, dev, max, pass);
82
83
84
85
86 pci_bus_size_bridges(bus);
87 pci_bus_assign_resources(bus);
88 cardbus_config_irq_and_cls(bus, s->pci_irq);
89
90
91 if (s->tune_bridge)
92 s->tune_bridge(s, bus);
93
94 pci_bus_add_devices(bus);
95
96 pci_unlock_rescan_remove();
97 return 0;
98}
99
100
101
102
103
104
105
106void cb_free(struct pcmcia_socket *s)
107{
108 struct pci_dev *bridge, *dev, *tmp;
109 struct pci_bus *bus;
110
111 bridge = s->cb_dev;
112 if (!bridge)
113 return;
114
115 bus = bridge->subordinate;
116 if (!bus)
117 return;
118
119 pci_lock_rescan_remove();
120
121 list_for_each_entry_safe(dev, tmp, &bus->devices, bus_list)
122 pci_stop_and_remove_bus_device(dev);
123
124 pci_unlock_rescan_remove();
125}
126