]> git.karo-electronics.de Git - karo-tx-linux.git/commitdiff
device property: Add fwnode_get_next_parent()
authorSakari Ailus <sakari.ailus@linux.intel.com>
Tue, 28 Mar 2017 07:52:26 +0000 (10:52 +0300)
committerRafael J. Wysocki <rafael.j.wysocki@intel.com>
Tue, 28 Mar 2017 22:00:29 +0000 (00:00 +0200)
In order to differentiate the functionality between dropping a reference
to the node (or not) for the benefit of OF, introduce
fwnode_get_next_parent().

Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>
Reviewed-by: Mika Westerberg <mika.westerberg@linux.intel.com>
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
drivers/base/property.c
include/linux/property.h

index 8a53b8f1db662f81e05e9fb98b7e62212eb6408e..627ebc9b570dc6b28e42cdc1c5d53d99da8e076f 100644 (file)
@@ -933,6 +933,27 @@ int device_add_properties(struct device *dev,
 }
 EXPORT_SYMBOL_GPL(device_add_properties);
 
+/**
+ * fwnode_get_next_parent - Iterate to the node's parent
+ * @fwnode: Firmware whose parent is retrieved
+ *
+ * This is like fwnode_get_parent() except that it drops the refcount
+ * on the passed node, making it suitable for iterating through a
+ * node's parents.
+ *
+ * Returns a node pointer with refcount incremented, use
+ * fwnode_handle_node() on it when done.
+ */
+struct fwnode_handle *fwnode_get_next_parent(struct fwnode_handle *fwnode)
+{
+       struct fwnode_handle *parent = fwnode_get_parent(fwnode);
+
+       fwnode_handle_put(fwnode);
+
+       return parent;
+}
+EXPORT_SYMBOL_GPL(fwnode_get_next_parent);
+
 /**
  * fwnode_get_parent - Return parent firwmare node
  * @fwnode: Firmware whose parent is retrieved
index 3a4e43599e0196410635c94210f81041a90d10e9..2f482616a2f22e2e26192a0a47a1c1b22d2bf015 100644 (file)
@@ -73,6 +73,7 @@ int fwnode_property_match_string(struct fwnode_handle *fwnode,
                                 const char *propname, const char *string);
 
 struct fwnode_handle *fwnode_get_parent(struct fwnode_handle *fwnode);
+struct fwnode_handle *fwnode_get_next_parent(struct fwnode_handle *fwnode);
 struct fwnode_handle *fwnode_get_next_child_node(struct fwnode_handle *fwnode,
                                                 struct fwnode_handle *child);