aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/pci
diff options
context:
space:
mode:
authorLinas Vepstas <linas@austin.ibm.com>2007-04-13 18:34:16 -0400
committerGreg Kroah-Hartman <gregkh@suse.de>2007-05-02 22:02:39 -0400
commit03a667559138d47cea487823332c4712fc6fbec7 (patch)
tree00c81741546123b2280e4aefe860f314c8f4d879 /drivers/pci
parentebf42c0edd5ee325043d4ae8fbb8caebd707e791 (diff)
PCI: rpaphp: Remove setup_pci_slot()
The setup_pci_slot() routine appears to be nothing else than a big, complicated wrapper around pcibios_add_pci_devices(). Remove the wrapping, and call pcibios_add_pci_devices() directly. Signed-off-by: Linas Vepstas <linas@austin.ibm.com> Cc: John Rose <johnrose@austin.ibm.com> Signed-off-by: Kristen Carlson Accardi <kristen.c.accardi@intel.com> Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
Diffstat (limited to 'drivers/pci')
-rw-r--r--drivers/pci/hotplug/rpaphp_pci.c96
1 files changed, 33 insertions, 63 deletions
diff --git a/drivers/pci/hotplug/rpaphp_pci.c b/drivers/pci/hotplug/rpaphp_pci.c
index b6a991ab9b7e..6417b7074ed4 100644
--- a/drivers/pci/hotplug/rpaphp_pci.c
+++ b/drivers/pci/hotplug/rpaphp_pci.c
@@ -92,64 +92,15 @@ static void set_slot_name(struct slot *slot)
92 bus->number); 92 bus->number);
93} 93}
94 94
95static int setup_pci_slot(struct slot *slot)
96{
97 struct device_node *dn = slot->dn;
98 struct pci_bus *bus;
99
100 BUG_ON(!dn);
101 bus = pcibios_find_pci_bus(dn);
102 if (!bus) {
103 err("%s: no pci_bus for dn %s\n", __FUNCTION__, dn->full_name);
104 goto exit_rc;
105 }
106
107 slot->bus = bus;
108 slot->pci_devs = &bus->devices;
109 set_slot_name(slot);
110
111 /* find slot's pci_dev if it's not empty */
112 if (slot->hotplug_slot->info->adapter_status == EMPTY) {
113 slot->state = EMPTY; /* slot is empty */
114 } else {
115 /* slot is occupied */
116 if (!dn->child) {
117 /* non-empty slot has to have child */
118 err("%s: slot[%s]'s device_node doesn't have child for adapter\n",
119 __FUNCTION__, slot->name);
120 goto exit_rc;
121 }
122
123 if (slot->hotplug_slot->info->adapter_status == NOT_CONFIGURED) {
124 dbg("%s CONFIGURING pci adapter in slot[%s]\n",
125 __FUNCTION__, slot->name);
126 pcibios_add_pci_devices(slot->bus);
127
128 } else if (slot->hotplug_slot->info->adapter_status != CONFIGURED) {
129 err("%s: slot[%s]'s adapter_status is NOT_VALID.\n",
130 __FUNCTION__, slot->name);
131 goto exit_rc;
132 }
133 print_slot_pci_funcs(slot->bus);
134 if (!list_empty(slot->pci_devs)) {
135 slot->state = CONFIGURED;
136 } else {
137 /* DLPAR add as opposed to
138 * boot time */
139 slot->state = NOT_CONFIGURED;
140 }
141 }
142 return 0;
143exit_rc:
144 return -EINVAL;
145}
146
147int rpaphp_register_pci_slot(struct slot *slot) 95int rpaphp_register_pci_slot(struct slot *slot)
148{ 96{
149 int rc, level, state; 97 int rc, level, state;
150 struct pci_bus *bus; 98 struct pci_bus *bus;
151 struct hotplug_slot_info *info = slot->hotplug_slot->info; 99 struct hotplug_slot_info *info = slot->hotplug_slot->info;
152 100
101 info->adapter_status = NOT_VALID;
102 slot->state = EMPTY;
103
153 /* Find out if the power is turned on for the slot */ 104 /* Find out if the power is turned on for the slot */
154 rc = rtas_get_power_level(slot->power_domain, &level); 105 rc = rtas_get_power_level(slot->power_domain, &level);
155 if (rc) 106 if (rc)
@@ -157,23 +108,42 @@ int rpaphp_register_pci_slot(struct slot *slot)
157 info->power_status = level; 108 info->power_status = level;
158 109
159 /* Figure out if there is an adapter in the slot */ 110 /* Figure out if there is an adapter in the slot */
160 info->adapter_status = NOT_VALID;
161 rc = rpaphp_get_sensor_state(slot, &state); 111 rc = rpaphp_get_sensor_state(slot, &state);
162 if (rc) 112 if (rc)
163 return rc; 113 return rc;
164 114
165 if (state == EMPTY) 115 bus = pcibios_find_pci_bus(slot->dn);
166 info->adapter_status = EMPTY; 116 if (!bus) {
167 else if (state == PRESENT) { 117 err("%s: no pci_bus for dn %s\n", __FUNCTION__, slot->dn->full_name);
168 bus = pcibios_find_pci_bus(slot->dn); 118 return -EINVAL;
169 if (bus && !list_empty(&bus->devices))
170 info->adapter_status = CONFIGURED;
171 else
172 info->adapter_status = NOT_CONFIGURED;
173 } 119 }
174 120
175 if (setup_pci_slot(slot)) 121 info->adapter_status = EMPTY;
176 return -EINVAL; 122 slot->bus = bus;
123 slot->pci_devs = &bus->devices;
124 set_slot_name(slot);
125
126 /* if there's an adapter in the slot, go add the pci devices */
127 if (state == PRESENT) {
128 info->adapter_status = NOT_CONFIGURED;
129 slot->state = NOT_CONFIGURED;
130
131 /* non-empty slot has to have child */
132 if (!slot->dn->child) {
133 err("%s: slot[%s]'s device_node doesn't have child for adapter\n",
134 __FUNCTION__, slot->name);
135 return -EINVAL;
136 }
137
138 if (list_empty(&bus->devices))
139 pcibios_add_pci_devices(bus);
140
141 print_slot_pci_funcs(bus);
142 if (!list_empty(&bus->devices)) {
143 info->adapter_status = CONFIGURED;
144 slot->state = CONFIGURED;
145 }
146 }
177 147
178 return rpaphp_register_slot(slot); 148 return rpaphp_register_slot(slot);
179} 149}