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 --- a/drivers/reset/core.c
20 +++ b/drivers/reset/core.c
21 @@ -141,27 +141,24 @@ int reset_control_status(struct reset_co
22 EXPORT_SYMBOL_GPL(reset_control_status);
25 - * of_reset_control_get - Lookup and obtain a reference to a reset controller.
26 + * of_reset_control_get_by_index - Lookup and obtain a reference to a reset
27 + * controller by index.
28 * @node: device to be reset by the controller
29 - * @id: reset line name
31 - * Returns a struct reset_control or IS_ERR() condition containing errno.
32 + * @index: index of the reset controller
34 - * Use of id names is optional.
35 + * This is to be used to perform a list of resets for a device or power domain
36 + * in whatever order. Returns a struct reset_control or IS_ERR() condition
39 -struct reset_control *of_reset_control_get(struct device_node *node,
41 +struct reset_control *of_reset_control_get_by_index(struct device_node *node,
44 struct reset_control *rstc = ERR_PTR(-EPROBE_DEFER);
45 struct reset_controller_dev *r, *rcdev;
46 struct of_phandle_args args;
52 - index = of_property_match_string(node,
54 ret = of_parse_phandle_with_args(node, "resets", "#reset-cells",
57 @@ -202,6 +199,27 @@ struct reset_control *of_reset_control_g
61 +EXPORT_SYMBOL_GPL(of_reset_control_get_by_index);
64 + * of_reset_control_get - Lookup and obtain a reference to a reset controller.
65 + * @node: device to be reset by the controller
66 + * @id: reset line name
68 + * Returns a struct reset_control or IS_ERR() condition containing errno.
70 + * Use of id names is optional.
72 +struct reset_control *of_reset_control_get(struct device_node *node,
78 + index = of_property_match_string(node,
80 + return of_reset_control_get_by_index(node, index);
82 EXPORT_SYMBOL_GPL(of_reset_control_get);
85 --- a/include/linux/reset.h
86 +++ b/include/linux/reset.h
87 @@ -38,6 +38,9 @@ static inline struct reset_control *devm
88 struct reset_control *of_reset_control_get(struct device_node *node,
91 +struct reset_control *of_reset_control_get_by_index(
92 + struct device_node *node, int index);
96 static inline int reset_control_reset(struct reset_control *rstc)
97 @@ -106,6 +109,12 @@ static inline struct reset_control *of_r
98 return ERR_PTR(-ENOSYS);
101 +static inline struct reset_control *of_reset_control_get_by_index(
102 + struct device_node *node, int index)
104 + return ERR_PTR(-ENOTSUPP);
107 #endif /* CONFIG_RESET_CONTROLLER */