1 From b4faa163a7ebae9faab5d0aefe70143e3379178b Mon Sep 17 00:00:00 2001
2 From: Vince Hsu <vinceh@nvidia.com>
3 Date: Mon, 13 Jul 2015 13:39:39 +0100
4 Subject: [PATCH] reset: add of_reset_control_get_by_index()
6 Add of_reset_control_get_by_index() to allow the drivers to get reset
7 device without knowing its name.
9 Signed-off-by: Vince Hsu <vinceh@nvidia.com>
10 [jonathanh@nvidia.com: Updated stub function to return -ENOTSUPP instead
11 of -ENOSYS which should only be used for system calls.]
12 Signed-off-by: Jon Hunter <jonathanh@nvidia.com>
13 Signed-off-by: Philipp Zabel <p.zabel@pengutronix.de>
15 drivers/reset/core.c | 40 +++++++++++++++++++++++++++++-----------
16 include/linux/reset.h | 9 +++++++++
17 2 files changed, 38 insertions(+), 11 deletions(-)
19 diff --git a/drivers/reset/core.c b/drivers/reset/core.c
20 index 7955e00..81ae17d 100644
21 --- a/drivers/reset/core.c
22 +++ b/drivers/reset/core.c
23 @@ -141,27 +141,24 @@ int reset_control_status(struct reset_control *rstc)
24 EXPORT_SYMBOL_GPL(reset_control_status);
27 - * of_reset_control_get - Lookup and obtain a reference to a reset controller.
28 + * of_reset_control_get_by_index - Lookup and obtain a reference to a reset
29 + * controller by index.
30 * @node: device to be reset by the controller
31 - * @id: reset line name
33 - * Returns a struct reset_control or IS_ERR() condition containing errno.
34 + * @index: index of the reset controller
36 - * Use of id names is optional.
37 + * This is to be used to perform a list of resets for a device or power domain
38 + * in whatever order. Returns a struct reset_control or IS_ERR() condition
41 -struct reset_control *of_reset_control_get(struct device_node *node,
43 +struct reset_control *of_reset_control_get_by_index(struct device_node *node,
46 struct reset_control *rstc = ERR_PTR(-EPROBE_DEFER);
47 struct reset_controller_dev *r, *rcdev;
48 struct of_phandle_args args;
54 - index = of_property_match_string(node,
56 ret = of_parse_phandle_with_args(node, "resets", "#reset-cells",
59 @@ -202,6 +199,27 @@ struct reset_control *of_reset_control_get(struct device_node *node,
63 +EXPORT_SYMBOL_GPL(of_reset_control_get_by_index);
66 + * of_reset_control_get - Lookup and obtain a reference to a reset controller.
67 + * @node: device to be reset by the controller
68 + * @id: reset line name
70 + * Returns a struct reset_control or IS_ERR() condition containing errno.
72 + * Use of id names is optional.
74 +struct reset_control *of_reset_control_get(struct device_node *node,
80 + index = of_property_match_string(node,
82 + return of_reset_control_get_by_index(node, index);
84 EXPORT_SYMBOL_GPL(of_reset_control_get);
87 diff --git a/include/linux/reset.h b/include/linux/reset.h
88 index 7f65f9c..6db74ad 100644
89 --- a/include/linux/reset.h
90 +++ b/include/linux/reset.h
91 @@ -38,6 +38,9 @@ static inline struct reset_control *devm_reset_control_get_optional(
92 struct reset_control *of_reset_control_get(struct device_node *node,
95 +struct reset_control *of_reset_control_get_by_index(
96 + struct device_node *node, int index);
100 static inline int reset_control_reset(struct reset_control *rstc)
101 @@ -106,6 +109,12 @@ static inline struct reset_control *of_reset_control_get(
102 return ERR_PTR(-ENOSYS);
105 +static inline struct reset_control *of_reset_control_get_by_index(
106 + struct device_node *node, int index)
108 + return ERR_PTR(-ENOTSUPP);
111 #endif /* CONFIG_RESET_CONTROLLER */