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, ...@@ -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); child = pci_add_new_bus(bridge_dev->bus, bridge_dev, sec_busno);
if (!child) { if (!child) {
printk(KERN_ERR "%s: could not add secondary bus\n", __FUNCTION__); printk(KERN_ERR "%s: could not add secondary bus\n", __FUNCTION__);
return 1; return -ENOMEM;
} }
sprintf(child->name, "PCI Bus #%02x", child->number); sprintf(child->name, "PCI Bus #%02x", child->number);
...@@ -204,7 +204,7 @@ static int dlpar_pci_remove_bus(struct pci_dev *bridge_dev) ...@@ -204,7 +204,7 @@ static int dlpar_pci_remove_bus(struct pci_dev *bridge_dev)
if (!bridge_dev) { if (!bridge_dev) {
printk(KERN_ERR "%s: unexpected null device\n", printk(KERN_ERR "%s: unexpected null device\n",
__FUNCTION__); __FUNCTION__);
return 1; return -EINVAL;
} }
secondary_bus = bridge_dev->subordinate; secondary_bus = bridge_dev->subordinate;
...@@ -212,7 +212,7 @@ static int dlpar_pci_remove_bus(struct pci_dev *bridge_dev) ...@@ -212,7 +212,7 @@ static int dlpar_pci_remove_bus(struct pci_dev *bridge_dev)
if (unmap_bus_range(secondary_bus)) { if (unmap_bus_range(secondary_bus)) {
printk(KERN_ERR "%s: failed to unmap bus range\n", printk(KERN_ERR "%s: failed to unmap bus range\n",
__FUNCTION__); __FUNCTION__);
return 1; return -ERANGE;
} }
pci_remove_bus_device(bridge_dev); pci_remove_bus_device(bridge_dev);
...@@ -282,7 +282,7 @@ static int dlpar_remove_phb(struct slot *slot) ...@@ -282,7 +282,7 @@ static int dlpar_remove_phb(struct slot *slot)
} }
rc = dlpar_remove_root_bus(phb); rc = dlpar_remove_root_bus(phb);
if (rc) if (rc < 0)
return rc; return rc;
return 0; return 0;
...@@ -294,7 +294,7 @@ static int dlpar_add_phb(struct device_node *dn) ...@@ -294,7 +294,7 @@ static int dlpar_add_phb(struct device_node *dn)
phb = init_phb_dynamic(dn); phb = init_phb_dynamic(dn);
if (!phb) if (!phb)
return 1; return -EINVAL;
return 0; return 0;
} }
......
...@@ -45,11 +45,6 @@ ...@@ -45,11 +45,6 @@
#define LED_ID 2 /* slow blinking */ #define LED_ID 2 /* slow blinking */
#define LED_ACTION 3 /* fast 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 */ /* Sensor values from rtas_get-sensor */
#define EMPTY 0 /* No card in slot */ #define EMPTY 0 /* No card in slot */
#define PRESENT 1 /* 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, ...@@ -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); my_index = (int *) get_property(dn, "ibm,my-drc-index", NULL);
if (!my_index) { if (!my_index) {
/* Node isn't DLPAR/hotplug capable */ /* Node isn't DLPAR/hotplug capable */
return 1; return -EINVAL;
} }
rc = get_children_props(dn->parent, &indexes, &names, &types, &domains); rc = get_children_props(dn->parent, &indexes, &names, &types, &domains);
if (rc < 0) { if (rc < 0) {
return 1; return -EINVAL;
} }
name_tmp = (char *) &names[1]; name_tmp = (char *) &names[1];
...@@ -284,7 +284,7 @@ int rpaphp_get_drc_props(struct device_node *dn, int *drc_index, ...@@ -284,7 +284,7 @@ int rpaphp_get_drc_props(struct device_node *dn, int *drc_index,
type_tmp += (strlen(type_tmp) + 1); type_tmp += (strlen(type_tmp) + 1);
} }
return 1; return -EINVAL;
} }
static int is_php_type(char *drc_type) static int is_php_type(char *drc_type)
......
...@@ -81,8 +81,8 @@ static int rpaphp_get_sensor_state(struct slot *slot, int *state) ...@@ -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); rc = rtas_get_sensor(DR_ENTITY_SENSE, slot->index, state);
if (rc) { if (rc < 0) {
if (rc == NEED_POWER || rc == PWR_ONLY) { if (rc == -EFAULT || rc == -EEXIST) {
dbg("%s: slot must be power up to get sensor-state\n", dbg("%s: slot must be power up to get sensor-state\n",
__FUNCTION__); __FUNCTION__);
...@@ -91,14 +91,14 @@ static int rpaphp_get_sensor_state(struct slot *slot, int *state) ...@@ -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, rc = rtas_set_power_level(slot->power_domain, POWER_ON,
&setlevel); &setlevel);
if (rc) { if (rc < 0) {
dbg("%s: power on slot[%s] failed rc=%d.\n", dbg("%s: power on slot[%s] failed rc=%d.\n",
__FUNCTION__, slot->name, rc); __FUNCTION__, slot->name, rc);
} else { } else {
rc = rtas_get_sensor(DR_ENTITY_SENSE, rc = rtas_get_sensor(DR_ENTITY_SENSE,
slot->index, state); slot->index, state);
} }
} else if (rc == ERR_SENSE_USE) } else if (rc == -ENODEV)
info("%s: slot is unusable\n", __FUNCTION__); info("%s: slot is unusable\n", __FUNCTION__);
else else
err("%s failed to get sensor state\n", __FUNCTION__); err("%s failed to get sensor state\n", __FUNCTION__);
...@@ -413,7 +413,7 @@ static int setup_pci_hotplug_slot_info(struct slot *slot) ...@@ -413,7 +413,7 @@ static int setup_pci_hotplug_slot_info(struct slot *slot)
if (slot->hotplug_slot->info->adapter_status == NOT_VALID) { if (slot->hotplug_slot->info->adapter_status == NOT_VALID) {
err("%s: NOT_VALID: skip dn->full_name=%s\n", err("%s: NOT_VALID: skip dn->full_name=%s\n",
__FUNCTION__, slot->dn->full_name); __FUNCTION__, slot->dn->full_name);
return -1; return -EINVAL;
} }
return 0; return 0;
} }
...@@ -426,15 +426,15 @@ static int set_phb_slot_name(struct slot *slot) ...@@ -426,15 +426,15 @@ static int set_phb_slot_name(struct slot *slot)
dn = slot->dn; dn = slot->dn;
if (!dn) { if (!dn) {
return 1; return -EINVAL;
} }
phb = dn->phb; phb = dn->phb;
if (!phb) { if (!phb) {
return 1; return -EINVAL;
} }
bus = phb->bus; bus = phb->bus;
if (!bus) { if (!bus) {
return 1; return -EINVAL;
} }
sprintf(slot->name, "%04x:%02x:%02x.%x", pci_domain_nr(bus), sprintf(slot->name, "%04x:%02x:%02x.%x", pci_domain_nr(bus),
...@@ -448,7 +448,7 @@ static int setup_pci_slot(struct slot *slot) ...@@ -448,7 +448,7 @@ static int setup_pci_slot(struct slot *slot)
if (slot->type == PHB) { if (slot->type == PHB) {
rc = set_phb_slot_name(slot); rc = set_phb_slot_name(slot);
if (rc) { if (rc < 0) {
err("%s: failed to set phb slot name\n", __FUNCTION__); err("%s: failed to set phb slot name\n", __FUNCTION__);
goto exit_rc; goto exit_rc;
} }
...@@ -509,12 +509,12 @@ static int setup_pci_slot(struct slot *slot) ...@@ -509,12 +509,12 @@ static int setup_pci_slot(struct slot *slot)
return 0; return 0;
exit_rc: exit_rc:
dealloc_slot_struct(slot); dealloc_slot_struct(slot);
return 1; return -EINVAL;
} }
int register_pci_slot(struct slot *slot) int register_pci_slot(struct slot *slot)
{ {
int rc = 1; int rc = -EINVAL;
slot->dev_type = PCI_DEV; slot->dev_type = PCI_DEV;
if ((slot->type == EMBEDDED) || (slot->type == PHB)) if ((slot->type == EMBEDDED) || (slot->type == PHB))
......
...@@ -211,7 +211,7 @@ int register_slot(struct slot *slot) ...@@ -211,7 +211,7 @@ int register_slot(struct slot *slot)
if (is_registered(slot)) { /* should't be here */ if (is_registered(slot)) { /* should't be here */
err("register_slot: slot[%s] is already registered\n", slot->name); err("register_slot: slot[%s] is already registered\n", slot->name);
rpaphp_release_slot(slot->hotplug_slot); rpaphp_release_slot(slot->hotplug_slot);
return 1; return -EAGAIN;
} }
retval = pci_hp_register(slot->hotplug_slot); retval = pci_hp_register(slot->hotplug_slot);
if (retval) { if (retval) {
...@@ -270,7 +270,7 @@ int rpaphp_set_attention_status(struct slot *slot, u8 status) ...@@ -270,7 +270,7 @@ int rpaphp_set_attention_status(struct slot *slot, u8 status)
/* status: LED_OFF or LED_ON */ /* status: LED_OFF or LED_ON */
rc = rtas_set_indicator(DR_INDICATOR, slot->index, status); 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", 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); slot->name, slot->location, slot->index, status, rc);
......
...@@ -71,11 +71,11 @@ int register_vio_slot(struct device_node *dn) ...@@ -71,11 +71,11 @@ int register_vio_slot(struct device_node *dn)
{ {
u32 *index; u32 *index;
char *name; char *name;
int rc = 1; int rc = -EINVAL;
struct slot *slot = NULL; struct slot *slot = NULL;
rc = rpaphp_get_drc_props(dn, NULL, &name, NULL, NULL); rc = rpaphp_get_drc_props(dn, NULL, &name, NULL, NULL);
if (rc) if (rc < 0)
goto exit_rc; goto exit_rc;
index = (u32 *) get_property(dn, "ibm,my-drc-index", NULL); index = (u32 *) get_property(dn, "ibm,my-drc-index", NULL);
if (!index) 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