Skip to content

Commit

Permalink
software node: Simplify software_node_release() function
Browse files Browse the repository at this point in the history
It's possible to release the node ID immediately when
fwnode_remove_software_node() is called, no need to wait for
software_node_release() with that.

Signed-off-by: Heikki Krogerus <[email protected]>
Tested-by: Hans de Goede <[email protected]>
Signed-off-by: Rafael J. Wysocki <[email protected]>
  • Loading branch information
Heikki Krogerus authored and rafaeljw committed Jun 3, 2019
1 parent a799698 commit 3df85a1
Showing 1 changed file with 10 additions and 10 deletions.
20 changes: 10 additions & 10 deletions drivers/base/swnode.c
Original file line number Diff line number Diff line change
Expand Up @@ -557,13 +557,6 @@ static void software_node_release(struct kobject *kobj)
{
struct software_node *swnode = kobj_to_swnode(kobj);

if (swnode->parent) {
ida_simple_remove(&swnode->parent->child_ids, swnode->id);
list_del(&swnode->entry);
} else {
ida_simple_remove(&swnode_root_ids, swnode->id);
}

ida_destroy(&swnode->child_ids);
property_entries_free(swnode->properties);
kfree(swnode);
Expand Down Expand Up @@ -610,9 +603,6 @@ fwnode_create_software_node(const struct property_entry *properties,
INIT_LIST_HEAD(&swnode->children);
swnode->parent = p;

if (p)
list_add_tail(&swnode->entry, &p->children);

ret = kobject_init_and_add(&swnode->kobj, &software_node_type,
p ? &p->kobj : NULL, "node%d", swnode->id);
if (ret) {
Expand All @@ -626,6 +616,9 @@ fwnode_create_software_node(const struct property_entry *properties,
return ERR_PTR(ret);
}

if (p)
list_add_tail(&swnode->entry, &p->children);

kobject_uevent(&swnode->kobj, KOBJ_ADD);
return &swnode->fwnode;
}
Expand All @@ -638,6 +631,13 @@ void fwnode_remove_software_node(struct fwnode_handle *fwnode)
if (!swnode)
return;

if (swnode->parent) {
ida_simple_remove(&swnode->parent->child_ids, swnode->id);
list_del(&swnode->entry);
} else {
ida_simple_remove(&swnode_root_ids, swnode->id);
}

kobject_put(&swnode->kobj);
}
EXPORT_SYMBOL_GPL(fwnode_remove_software_node);
Expand Down

0 comments on commit 3df85a1

Please sign in to comment.