static ssize_t add_slot_store(struct kobject *kobj, struct kobj_attribute *attr, const char *buf, size_t nbytes) { char drc_name[MAX_DRC_NAME_LEN]; char *end; int rc; if (nbytes >= MAX_DRC_NAME_LEN) return 0; memcpy(drc_name, buf, nbytes); end = strchr(drc_name, '\n'); if (!end) end = &drc_name[nbytes]; *end = '\0'; rc = dlpar_add_slot(drc_name); if (rc) return rc; return nbytes; }
/** * add_phb * * @param op * @returns 0 on success, !0 otherwise */ static int add_phb(struct options *opts) { struct dr_node *phb = NULL; int rc, n_children = 0; phb = get_node_by_name(opts->usr_drc_name, PHB_NODES); if (phb) { say(ERROR, "PHB is already owned by this partition\n"); rc = RC_ALREADY_OWN; goto phb_add_error; } rc = acquire_phb(opts->usr_drc_name, &phb); if (rc) return rc; rc = acquire_hp_children(phb->ofdt_path, &n_children); if (rc) { if (release_phb(phb)) { say(ERROR, "Unknown failure. Data may be out of sync " "and\nthe system may require a reboot.\n"); } goto phb_add_error; } rc = dlpar_add_slot(phb->drc_name); if (rc) { if (n_children) { if (release_hp_children(phb->drc_name)) { say(ERROR, "Unknown failure. Data may be out " "of sync and\nthe system may require " "a reboot.\n"); } } if (release_phb(phb)) { say(ERROR, "Unknown failure. Data may be out of sync " "and\nthe system may require a reboot.\n"); } goto phb_add_error; } if (n_children) { rc = enable_hp_children(phb->drc_name); if (rc) { say(ERROR, "Adapter configuration failed.\n"); if (release_hp_children(phb->drc_name)) { say(ERROR, "Unknown failure. Data may be out " "of sync and \nthe system may require " "a reboot.\n"); } if (dlpar_remove_slot(phb->drc_name)) { say(DEBUG, "remove %s from hotplug subsystem " "failed\n", phb->drc_name); say(ERROR, "Unknown failure. Data may be out " "of sync and \nthe system may require " "a reboot.\n"); } if (release_phb(phb)) { say(ERROR, "Unknown failure. Data may be out " "of sync and \nthe system may require " "a reboot.\n"); } } } phb_add_error: if (phb) free_node(phb); return rc; }