diff options
author | Sakari Ailus <sakari.ailus@linux.intel.com> | 2017-09-19 05:39:11 -0400 |
---|---|---|
committer | Rafael J. Wysocki <rafael.j.wysocki@intel.com> | 2017-11-08 18:17:22 -0500 |
commit | cf89a31ca55272e1dfb9527b5a61eee4d417747a (patch) | |
tree | 7888feac76cd19e3a31890a1473927d915133e8e | |
parent | 39dae59d66acd86d1de24294bd2f343fd5e7a625 (diff) |
device property: Make fwnode_handle_get() return the fwnode
The fwnode_handle_get() function is used to obtain a reference to an
fwnode. A common usage pattern for the OF equivalent of the function is:
mynode = of_node_get(node);
Similarly make fwnode_handle_get() return the fwnode to which the
reference was obtained.
Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
-rw-r--r-- | drivers/base/property.c | 9 | ||||
-rw-r--r-- | drivers/of/property.c | 4 | ||||
-rw-r--r-- | include/linux/fwnode.h | 2 | ||||
-rw-r--r-- | include/linux/property.h | 2 |
4 files changed, 11 insertions, 6 deletions
diff --git a/drivers/base/property.c b/drivers/base/property.c index 7ed99c1b2a8b..851b1b6596a4 100644 --- a/drivers/base/property.c +++ b/drivers/base/property.c | |||
@@ -1044,10 +1044,15 @@ EXPORT_SYMBOL_GPL(device_get_named_child_node); | |||
1044 | /** | 1044 | /** |
1045 | * fwnode_handle_get - Obtain a reference to a device node | 1045 | * fwnode_handle_get - Obtain a reference to a device node |
1046 | * @fwnode: Pointer to the device node to obtain the reference to. | 1046 | * @fwnode: Pointer to the device node to obtain the reference to. |
1047 | * | ||
1048 | * Returns the fwnode handle. | ||
1047 | */ | 1049 | */ |
1048 | void fwnode_handle_get(struct fwnode_handle *fwnode) | 1050 | struct fwnode_handle *fwnode_handle_get(struct fwnode_handle *fwnode) |
1049 | { | 1051 | { |
1050 | fwnode_call_void_op(fwnode, get); | 1052 | if (!fwnode_has_op(fwnode, get)) |
1053 | return fwnode; | ||
1054 | |||
1055 | return fwnode_call_ptr_op(fwnode, get); | ||
1051 | } | 1056 | } |
1052 | EXPORT_SYMBOL_GPL(fwnode_handle_get); | 1057 | EXPORT_SYMBOL_GPL(fwnode_handle_get); |
1053 | 1058 | ||
diff --git a/drivers/of/property.c b/drivers/of/property.c index 264c355ba1ff..8ad33a44a7b8 100644 --- a/drivers/of/property.c +++ b/drivers/of/property.c | |||
@@ -817,9 +817,9 @@ struct device_node *of_graph_get_remote_node(const struct device_node *node, | |||
817 | } | 817 | } |
818 | EXPORT_SYMBOL(of_graph_get_remote_node); | 818 | EXPORT_SYMBOL(of_graph_get_remote_node); |
819 | 819 | ||
820 | static void of_fwnode_get(struct fwnode_handle *fwnode) | 820 | static struct fwnode_handle *of_fwnode_get(struct fwnode_handle *fwnode) |
821 | { | 821 | { |
822 | of_node_get(to_of_node(fwnode)); | 822 | return of_fwnode_handle(of_node_get(to_of_node(fwnode))); |
823 | } | 823 | } |
824 | 824 | ||
825 | static void of_fwnode_put(struct fwnode_handle *fwnode) | 825 | static void of_fwnode_put(struct fwnode_handle *fwnode) |
diff --git a/include/linux/fwnode.h b/include/linux/fwnode.h index 0c35b6caf0f6..411a84c6c400 100644 --- a/include/linux/fwnode.h +++ b/include/linux/fwnode.h | |||
@@ -68,7 +68,7 @@ struct fwnode_reference_args { | |||
68 | * @graph_parse_endpoint: Parse endpoint for port and endpoint id. | 68 | * @graph_parse_endpoint: Parse endpoint for port and endpoint id. |
69 | */ | 69 | */ |
70 | struct fwnode_operations { | 70 | struct fwnode_operations { |
71 | void (*get)(struct fwnode_handle *fwnode); | 71 | struct fwnode_handle *(*get)(struct fwnode_handle *fwnode); |
72 | void (*put)(struct fwnode_handle *fwnode); | 72 | void (*put)(struct fwnode_handle *fwnode); |
73 | bool (*device_is_available)(const struct fwnode_handle *fwnode); | 73 | bool (*device_is_available)(const struct fwnode_handle *fwnode); |
74 | bool (*property_present)(const struct fwnode_handle *fwnode, | 74 | bool (*property_present)(const struct fwnode_handle *fwnode, |
diff --git a/include/linux/property.h b/include/linux/property.h index 6bebee13c5e0..42069c20caee 100644 --- a/include/linux/property.h +++ b/include/linux/property.h | |||
@@ -100,7 +100,7 @@ struct fwnode_handle *fwnode_get_named_child_node( | |||
100 | struct fwnode_handle *device_get_named_child_node(struct device *dev, | 100 | struct fwnode_handle *device_get_named_child_node(struct device *dev, |
101 | const char *childname); | 101 | const char *childname); |
102 | 102 | ||
103 | void fwnode_handle_get(struct fwnode_handle *fwnode); | 103 | struct fwnode_handle *fwnode_handle_get(struct fwnode_handle *fwnode); |
104 | void fwnode_handle_put(struct fwnode_handle *fwnode); | 104 | void fwnode_handle_put(struct fwnode_handle *fwnode); |
105 | 105 | ||
106 | unsigned int device_get_child_node_count(struct device *dev); | 106 | unsigned int device_get_child_node_count(struct device *dev); |