summaryrefslogtreecommitdiffstats
path: root/drivers/base
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@linux-foundation.org>2019-09-17 22:39:59 -0400
committerLinus Torvalds <torvalds@linux-foundation.org>2019-09-17 22:39:59 -0400
commit35f7a95266153b1cf0caca3aa9661cb721864527 (patch)
tree670f1a57e48937cc79fa5d0fd440872273ed725a /drivers/base
parentd2aaa49e281959828370667edbc1cdcc7fc4026a (diff)
parent016049a816774edc9c3cd81afa7724d7ab001585 (diff)
Merge tag 'devprop-5.4-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/rafael/linux-pm
Pull device properties framework updates from Rafael Wysocki: "Improve software node support (Heikki Krogerus) and clean up two assorted pieces of code (Andy Shevchenko, Geert Uytterhoeven)" * tag 'devprop-5.4-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/rafael/linux-pm: software node: Initialize the return value in software_node_find_by_name() software node: Initialize the return value in software_node_to_swnode() ACPI / property: Fix acpi_graph_get_remote_endpoint() name in kerneldoc device property: Remove duplicate test for NULL platform/x86: intel_cht_int33fe: Use new API to gain access to the role switch usb: roles: intel_xhci: Supplying software node for the role mux software node: Add software_node_find_by_name()
Diffstat (limited to 'drivers/base')
-rw-r--r--drivers/base/swnode.c39
1 files changed, 38 insertions, 1 deletions
diff --git a/drivers/base/swnode.c b/drivers/base/swnode.c
index e7b3aa3bd55a..a1f3f0994f9f 100644
--- a/drivers/base/swnode.c
+++ b/drivers/base/swnode.c
@@ -51,7 +51,7 @@ EXPORT_SYMBOL_GPL(is_software_node);
51static struct swnode * 51static struct swnode *
52software_node_to_swnode(const struct software_node *node) 52software_node_to_swnode(const struct software_node *node)
53{ 53{
54 struct swnode *swnode; 54 struct swnode *swnode = NULL;
55 struct kobject *k; 55 struct kobject *k;
56 56
57 if (!node) 57 if (!node)
@@ -620,6 +620,43 @@ static const struct fwnode_operations software_node_ops = {
620 620
621/* -------------------------------------------------------------------------- */ 621/* -------------------------------------------------------------------------- */
622 622
623/**
624 * software_node_find_by_name - Find software node by name
625 * @parent: Parent of the software node
626 * @name: Name of the software node
627 *
628 * The function will find a node that is child of @parent and that is named
629 * @name. If no node is found, the function returns NULL.
630 *
631 * NOTE: you will need to drop the reference with fwnode_handle_put() after use.
632 */
633const struct software_node *
634software_node_find_by_name(const struct software_node *parent, const char *name)
635{
636 struct swnode *swnode = NULL;
637 struct kobject *k;
638
639 if (!name)
640 return NULL;
641
642 spin_lock(&swnode_kset->list_lock);
643
644 list_for_each_entry(k, &swnode_kset->list, entry) {
645 swnode = kobj_to_swnode(k);
646 if (parent == swnode->node->parent && swnode->node->name &&
647 !strcmp(name, swnode->node->name)) {
648 kobject_get(&swnode->kobj);
649 break;
650 }
651 swnode = NULL;
652 }
653
654 spin_unlock(&swnode_kset->list_lock);
655
656 return swnode ? swnode->node : NULL;
657}
658EXPORT_SYMBOL_GPL(software_node_find_by_name);
659
623static int 660static int
624software_node_register_properties(struct software_node *node, 661software_node_register_properties(struct software_node *node,
625 const struct property_entry *properties) 662 const struct property_entry *properties)