static ssize_t dlpar_cpu_probe(const char *buf, size_t count) { struct device_node *dn; unsigned long drc_index; char *cpu_name; int rc; cpu_hotplug_driver_lock(); rc = strict_strtoul(buf, 0, &drc_index); if (rc) { rc = -EINVAL; goto out; } dn = dlpar_configure_connector(drc_index); if (!dn) { rc = -EINVAL; goto out; } /* configure-connector reports cpus as living in the base * directory of the device tree. CPUs actually live in the * cpus directory so we need to fixup the full_name. */ cpu_name = kzalloc(strlen(dn->full_name) + strlen("/cpus") + 1, GFP_KERNEL); if (!cpu_name) { dlpar_free_cc_nodes(dn); rc = -ENOMEM; goto out; } sprintf(cpu_name, "/cpus%s", dn->full_name); kfree(dn->full_name); dn->full_name = cpu_name; rc = dlpar_acquire_drc(drc_index); if (rc) { dlpar_free_cc_nodes(dn); rc = -EINVAL; goto out; } rc = dlpar_attach_node(dn); if (rc) { dlpar_release_drc(drc_index); dlpar_free_cc_nodes(dn); } rc = dlpar_online_cpu(dn); out: cpu_hotplug_driver_unlock(); return rc ? rc : count; }
static ssize_t dlpar_cpu_probe(const char *buf, size_t count) { struct device_node *dn, *parent; unsigned long drc_index; int rc; cpu_hotplug_driver_lock(); rc = strict_strtoul(buf, 0, &drc_index); if (rc) { rc = -EINVAL; goto out; } parent = of_find_node_by_path("/cpus"); if (!parent) { rc = -ENODEV; goto out; } dn = dlpar_configure_connector(drc_index, parent); if (!dn) { rc = -EINVAL; goto out; } of_node_put(parent); rc = dlpar_acquire_drc(drc_index); if (rc) { dlpar_free_cc_nodes(dn); rc = -EINVAL; goto out; } rc = dlpar_attach_node(dn); if (rc) { dlpar_release_drc(drc_index); dlpar_free_cc_nodes(dn); goto out; } rc = dlpar_online_cpu(dn); out: cpu_hotplug_driver_unlock(); return rc ? rc : count; }
static int add_dt_node(u32 parent_phandle, u32 drc_index) { struct device_node *dn; struct device_node *parent_dn; int rc; parent_dn = of_find_node_by_phandle(parent_phandle); if (!parent_dn) return -ENOENT; dn = dlpar_configure_connector(drc_index, parent_dn); if (!dn) return -ENOENT; rc = dlpar_attach_node(dn); if (rc) dlpar_free_cc_nodes(dn); of_node_put(parent_dn); return rc; }
static ssize_t dlpar_cpu_probe(const char *buf, size_t count) { struct device_node *dn, *parent; u32 drc_index; int rc; rc = kstrtou32(buf, 0, &drc_index); if (rc) return -EINVAL; parent = of_find_node_by_path("/cpus"); if (!parent) return -ENODEV; dn = dlpar_configure_connector(cpu_to_be32(drc_index), parent); if (!dn) return -EINVAL; of_node_put(parent); rc = dlpar_acquire_drc(drc_index); if (rc) { dlpar_free_cc_nodes(dn); return -EINVAL; } rc = dlpar_attach_node(dn); if (rc) { dlpar_release_drc(drc_index); dlpar_free_cc_nodes(dn); return rc; } rc = dlpar_online_cpu(dn); if (rc) return rc; return count; }