aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/pci/hotplug
diff options
context:
space:
mode:
authorlinas@austin.ibm.com <linas@austin.ibm.com>2006-01-12 19:28:22 -0500
committerGreg Kroah-Hartman <gregkh@suse.de>2006-01-31 21:00:13 -0500
commite06b80b78db96ca272db4ec0b26ce1092a1a9704 (patch)
tree77f8605f27e02c46b1513837e4fc1f02b6d2b66c /drivers/pci/hotplug
parent8fe64399cccf8dddcc4e5eaff270a12064f6fe9f (diff)
[PATCH] powerpc/PCI hotplug: merge rpaphp_enable_pci_slot()
Remove general baroqueness. The function rpaphp_enable_pci_slot() has a fairly simple logic structure, once all of the debug printk's are removed. Its called from only one place, and that place also has a very simple structure once he printk's are removed. Merge the two together. Signed-off-by: Linas Vepstas <linas@austin.ibm.com> Acked-by: John Rose <johnrose@austin.ibm.com> Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
Diffstat (limited to 'drivers/pci/hotplug')
-rw-r--r--drivers/pci/hotplug/rpaphp.h1
-rw-r--r--drivers/pci/hotplug/rpaphp_core.c38
-rw-r--r--drivers/pci/hotplug/rpaphp_pci.c30
3 files changed, 30 insertions, 39 deletions
diff --git a/drivers/pci/hotplug/rpaphp.h b/drivers/pci/hotplug/rpaphp.h
index 6e4f93ba6555..095c9aacaa16 100644
--- a/drivers/pci/hotplug/rpaphp.h
+++ b/drivers/pci/hotplug/rpaphp.h
@@ -91,6 +91,7 @@ extern int num_slots;
91extern int rpaphp_enable_pci_slot(struct slot *slot); 91extern int rpaphp_enable_pci_slot(struct slot *slot);
92extern int register_pci_slot(struct slot *slot); 92extern int register_pci_slot(struct slot *slot);
93extern int rpaphp_get_pci_adapter_status(struct slot *slot, int is_init, u8 * value); 93extern int rpaphp_get_pci_adapter_status(struct slot *slot, int is_init, u8 * value);
94extern int rpaphp_get_sensor_state(struct slot *slot, int *state);
94 95
95/* rpaphp_core.c */ 96/* rpaphp_core.c */
96extern int rpaphp_add_slot(struct device_node *dn); 97extern int rpaphp_add_slot(struct device_node *dn);
diff --git a/drivers/pci/hotplug/rpaphp_core.c b/drivers/pci/hotplug/rpaphp_core.c
index acf17645fd8a..341fdd59090b 100644
--- a/drivers/pci/hotplug/rpaphp_core.c
+++ b/drivers/pci/hotplug/rpaphp_core.c
@@ -393,22 +393,40 @@ static void __exit rpaphp_exit(void)
393 cleanup_slots(); 393 cleanup_slots();
394} 394}
395 395
396static int enable_slot(struct hotplug_slot *hotplug_slot) 396static int __enable_slot(struct slot *slot)
397{ 397{
398 int retval = 0; 398 int state;
399 struct slot *slot = (struct slot *)hotplug_slot->private; 399 int retval;
400 400
401 if (slot->state == CONFIGURED) { 401 if (slot->state == CONFIGURED)
402 dbg("%s: %s is already enabled\n", __FUNCTION__, slot->name); 402 return 0;
403 goto exit; 403
404 retval = rpaphp_get_sensor_state(slot, &state);
405 if (retval)
406 return retval;
407
408 if (state == PRESENT) {
409 pcibios_add_pci_devices(slot->bus);
410 slot->state = CONFIGURED;
411 } else if (state == EMPTY) {
412 slot->state = EMPTY;
413 } else {
414 err("%s: slot[%s] is in invalid state\n", __FUNCTION__, slot->name);
415 slot->state = NOT_VALID;
416 return -EINVAL;
404 } 417 }
418 return 0;
419}
420
421static int enable_slot(struct hotplug_slot *hotplug_slot)
422{
423 int retval;
424 struct slot *slot = (struct slot *)hotplug_slot->private;
405 425
406 dbg("ENABLING SLOT %s\n", slot->name);
407 down(&rpaphp_sem); 426 down(&rpaphp_sem);
408 retval = rpaphp_enable_pci_slot(slot); 427 retval = __enable_slot(slot);
409 up(&rpaphp_sem); 428 up(&rpaphp_sem);
410exit: 429
411 dbg("%s - Exit: rc[%d]\n", __FUNCTION__, retval);
412 return retval; 430 return retval;
413} 431}
414 432
diff --git a/drivers/pci/hotplug/rpaphp_pci.c b/drivers/pci/hotplug/rpaphp_pci.c
index ce7ebec05933..d1297d070a75 100644
--- a/drivers/pci/hotplug/rpaphp_pci.c
+++ b/drivers/pci/hotplug/rpaphp_pci.c
@@ -32,7 +32,7 @@
32#include "../pci.h" /* for pci_add_new_bus */ 32#include "../pci.h" /* for pci_add_new_bus */
33#include "rpaphp.h" 33#include "rpaphp.h"
34 34
35static int rpaphp_get_sensor_state(struct slot *slot, int *state) 35int rpaphp_get_sensor_state(struct slot *slot, int *state)
36{ 36{
37 int rc; 37 int rc;
38 int setlevel; 38 int setlevel;
@@ -212,31 +212,3 @@ exit_rc:
212 return rc; 212 return rc;
213} 213}
214 214
215int rpaphp_enable_pci_slot(struct slot *slot)
216{
217 int retval = 0, state;
218
219 retval = rpaphp_get_sensor_state(slot, &state);
220 if (retval)
221 goto exit;
222 dbg("%s: sensor state[%d]\n", __FUNCTION__, state);
223 /* if slot is not empty, enable the adapter */
224 if (state == PRESENT) {
225 dbg("%s : slot[%s] is occupied.\n", __FUNCTION__, slot->name);
226 pcibios_add_pci_devices(slot->bus);
227 slot->state = CONFIGURED;
228 info("%s: devices in slot[%s] configured\n",
229 __FUNCTION__, slot->name);
230 } else if (state == EMPTY) {
231 dbg("%s : slot[%s] is empty\n", __FUNCTION__, slot->name);
232 slot->state = EMPTY;
233 } else {
234 err("%s: slot[%s] is in invalid state\n", __FUNCTION__,
235 slot->name);
236 slot->state = NOT_VALID;
237 retval = -EINVAL;
238 }
239exit:
240 dbg("%s - Exit: rc[%d]\n", __FUNCTION__, retval);
241 return retval;
242}