Commit 68417bcd authored by Paul Mackerras's avatar Paul Mackerras Committed by Linus Torvalds

[PATCH] ppc64: error code cleanups rpa(php,dlpar)

This patch is from John Rose <johnrose@austin.ibm.com>

This patch changes the RPA PCI Hotplug and DLPAR modules to use more
conventional error values for return codes.  The goal is to make failure
conditions obvious in the wrapper functions and in the caller code.
Signed-off-by: default avatarJohn Rose <johnrose@austin.ibm.com>
Signed-off-by: default avatarPaul Mackerras <paulus@samba.org>
Signed-off-by: default avatarLinus Torvalds <torvalds@osdl.org>
parent 76cc4499
......@@ -142,7 +142,7 @@ static int pci_add_secondary_bus(struct device_node *dn,
child = pci_add_new_bus(bridge_dev->bus, bridge_dev, sec_busno);
if (!child) {
printk(KERN_ERR "%s: could not add secondary bus\n", __FUNCTION__);
return 1;
return -ENOMEM;
}
sprintf(child->name, "PCI Bus #%02x", child->number);
......@@ -204,7 +204,7 @@ static int dlpar_pci_remove_bus(struct pci_dev *bridge_dev)
if (!bridge_dev) {
printk(KERN_ERR "%s: unexpected null device\n",
__FUNCTION__);
return 1;
return -EINVAL;
}
secondary_bus = bridge_dev->subordinate;
......@@ -212,7 +212,7 @@ static int dlpar_pci_remove_bus(struct pci_dev *bridge_dev)
if (unmap_bus_range(secondary_bus)) {
printk(KERN_ERR "%s: failed to unmap bus range\n",
__FUNCTION__);
return 1;
return -ERANGE;
}
pci_remove_bus_device(bridge_dev);
......@@ -282,7 +282,7 @@ static int dlpar_remove_phb(struct slot *slot)
}
rc = dlpar_remove_root_bus(phb);
if (rc)
if (rc < 0)
return rc;
return 0;
......@@ -294,7 +294,7 @@ static int dlpar_add_phb(struct device_node *dn)
phb = init_phb_dynamic(dn);
if (!phb)
return 1;
return -EINVAL;
return 0;
}
......
......@@ -45,11 +45,6 @@
#define LED_ID 2 /* slow blinking */
#define LED_ACTION 3 /* fast blinking */
/* Error status from rtas_get-sensor */
#define NEED_POWER -9000 /* slot must be power up and unisolated to get state */
#define PWR_ONLY -9001 /* slot must be powerd up to get state, leave isolated */
#define ERR_SENSE_USE -9002 /* No DR operation will succeed, slot is unusable */
/* Sensor values from rtas_get-sensor */
#define EMPTY 0 /* No card in slot */
#define PRESENT 1 /* Card in slot */
......
......@@ -256,12 +256,12 @@ int rpaphp_get_drc_props(struct device_node *dn, int *drc_index,
my_index = (int *) get_property(dn, "ibm,my-drc-index", NULL);
if (!my_index) {
/* Node isn't DLPAR/hotplug capable */
return 1;
return -EINVAL;
}
rc = get_children_props(dn->parent, &indexes, &names, &types, &domains);
if (rc < 0) {
return 1;
return -EINVAL;
}
name_tmp = (char *) &names[1];
......@@ -284,7 +284,7 @@ int rpaphp_get_drc_props(struct device_node *dn, int *drc_index,
type_tmp += (strlen(type_tmp) + 1);
}
return 1;
return -EINVAL;
}
static int is_php_type(char *drc_type)
......
......@@ -81,8 +81,8 @@ static int rpaphp_get_sensor_state(struct slot *slot, int *state)
rc = rtas_get_sensor(DR_ENTITY_SENSE, slot->index, state);
if (rc) {
if (rc == NEED_POWER || rc == PWR_ONLY) {
if (rc < 0) {
if (rc == -EFAULT || rc == -EEXIST) {
dbg("%s: slot must be power up to get sensor-state\n",
__FUNCTION__);
......@@ -91,14 +91,14 @@ static int rpaphp_get_sensor_state(struct slot *slot, int *state)
*/
rc = rtas_set_power_level(slot->power_domain, POWER_ON,
&setlevel);
if (rc) {
if (rc < 0) {
dbg("%s: power on slot[%s] failed rc=%d.\n",
__FUNCTION__, slot->name, rc);
} else {
rc = rtas_get_sensor(DR_ENTITY_SENSE,
slot->index, state);
}
} else if (rc == ERR_SENSE_USE)
} else if (rc == -ENODEV)
info("%s: slot is unusable\n", __FUNCTION__);
else
err("%s failed to get sensor state\n", __FUNCTION__);
......@@ -413,7 +413,7 @@ static int setup_pci_hotplug_slot_info(struct slot *slot)
if (slot->hotplug_slot->info->adapter_status == NOT_VALID) {
err("%s: NOT_VALID: skip dn->full_name=%s\n",
__FUNCTION__, slot->dn->full_name);
return -1;
return -EINVAL;
}
return 0;
}
......@@ -426,15 +426,15 @@ static int set_phb_slot_name(struct slot *slot)
dn = slot->dn;
if (!dn) {
return 1;
return -EINVAL;
}
phb = dn->phb;
if (!phb) {
return 1;
return -EINVAL;
}
bus = phb->bus;
if (!bus) {
return 1;
return -EINVAL;
}
sprintf(slot->name, "%04x:%02x:%02x.%x", pci_domain_nr(bus),
......@@ -448,7 +448,7 @@ static int setup_pci_slot(struct slot *slot)
if (slot->type == PHB) {
rc = set_phb_slot_name(slot);
if (rc) {
if (rc < 0) {
err("%s: failed to set phb slot name\n", __FUNCTION__);
goto exit_rc;
}
......@@ -509,12 +509,12 @@ static int setup_pci_slot(struct slot *slot)
return 0;
exit_rc:
dealloc_slot_struct(slot);
return 1;
return -EINVAL;
}
int register_pci_slot(struct slot *slot)
{
int rc = 1;
int rc = -EINVAL;
slot->dev_type = PCI_DEV;
if ((slot->type == EMBEDDED) || (slot->type == PHB))
......
......@@ -211,7 +211,7 @@ int register_slot(struct slot *slot)
if (is_registered(slot)) { /* should't be here */
err("register_slot: slot[%s] is already registered\n", slot->name);
rpaphp_release_slot(slot->hotplug_slot);
return 1;
return -EAGAIN;
}
retval = pci_hp_register(slot->hotplug_slot);
if (retval) {
......@@ -270,7 +270,7 @@ int rpaphp_set_attention_status(struct slot *slot, u8 status)
/* status: LED_OFF or LED_ON */
rc = rtas_set_indicator(DR_INDICATOR, slot->index, status);
if (rc)
if (rc < 0)
err("slot(name=%s location=%s index=0x%x) set attention-status(%d) failed! rc=0x%x\n",
slot->name, slot->location, slot->index, status, rc);
......
......@@ -71,11 +71,11 @@ int register_vio_slot(struct device_node *dn)
{
u32 *index;
char *name;
int rc = 1;
int rc = -EINVAL;
struct slot *slot = NULL;
rc = rpaphp_get_drc_props(dn, NULL, &name, NULL, NULL);
if (rc)
if (rc < 0)
goto exit_rc;
index = (u32 *) get_property(dn, "ibm,my-drc-index", NULL);
if (!index)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment