aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--drivers/reset/core.c39
-rw-r--r--include/linux/reset.h4
2 files changed, 34 insertions, 9 deletions
diff --git a/drivers/reset/core.c b/drivers/reset/core.c
index 217d2fa4fd95..baeaf82d40d9 100644
--- a/drivers/reset/core.c
+++ b/drivers/reset/core.c
@@ -126,15 +126,16 @@ int reset_control_deassert(struct reset_control *rstc)
126EXPORT_SYMBOL_GPL(reset_control_deassert); 126EXPORT_SYMBOL_GPL(reset_control_deassert);
127 127
128/** 128/**
129 * reset_control_get - Lookup and obtain a reference to a reset controller. 129 * of_reset_control_get - Lookup and obtain a reference to a reset controller.
130 * @dev: device to be reset by the controller 130 * @node: device to be reset by the controller
131 * @id: reset line name 131 * @id: reset line name
132 * 132 *
133 * Returns a struct reset_control or IS_ERR() condition containing errno. 133 * Returns a struct reset_control or IS_ERR() condition containing errno.
134 * 134 *
135 * Use of id names is optional. 135 * Use of id names is optional.
136 */ 136 */
137struct reset_control *reset_control_get(struct device *dev, const char *id) 137struct reset_control *of_reset_control_get(struct device_node *node,
138 const char *id)
138{ 139{
139 struct reset_control *rstc = ERR_PTR(-EPROBE_DEFER); 140 struct reset_control *rstc = ERR_PTR(-EPROBE_DEFER);
140 struct reset_controller_dev *r, *rcdev; 141 struct reset_controller_dev *r, *rcdev;
@@ -143,13 +144,10 @@ struct reset_control *reset_control_get(struct device *dev, const char *id)
143 int rstc_id; 144 int rstc_id;
144 int ret; 145 int ret;
145 146
146 if (!dev)
147 return ERR_PTR(-EINVAL);
148
149 if (id) 147 if (id)
150 index = of_property_match_string(dev->of_node, 148 index = of_property_match_string(node,
151 "reset-names", id); 149 "reset-names", id);
152 ret = of_parse_phandle_with_args(dev->of_node, "resets", "#reset-cells", 150 ret = of_parse_phandle_with_args(node, "resets", "#reset-cells",
153 index, &args); 151 index, &args);
154 if (ret) 152 if (ret)
155 return ERR_PTR(ret); 153 return ERR_PTR(ret);
@@ -184,12 +182,35 @@ struct reset_control *reset_control_get(struct device *dev, const char *id)
184 return ERR_PTR(-ENOMEM); 182 return ERR_PTR(-ENOMEM);
185 } 183 }
186 184
187 rstc->dev = dev;
188 rstc->rcdev = rcdev; 185 rstc->rcdev = rcdev;
189 rstc->id = rstc_id; 186 rstc->id = rstc_id;
190 187
191 return rstc; 188 return rstc;
192} 189}
190EXPORT_SYMBOL_GPL(of_reset_control_get);
191
192/**
193 * reset_control_get - Lookup and obtain a reference to a reset controller.
194 * @dev: device to be reset by the controller
195 * @id: reset line name
196 *
197 * Returns a struct reset_control or IS_ERR() condition containing errno.
198 *
199 * Use of id names is optional.
200 */
201struct reset_control *reset_control_get(struct device *dev, const char *id)
202{
203 struct reset_control *rstc;
204
205 if (!dev)
206 return ERR_PTR(-EINVAL);
207
208 rstc = of_reset_control_get(dev->of_node, id);
209 if (!IS_ERR(rstc))
210 rstc->dev = dev;
211
212 return rstc;
213}
193EXPORT_SYMBOL_GPL(reset_control_get); 214EXPORT_SYMBOL_GPL(reset_control_get);
194 215
195/** 216/**
diff --git a/include/linux/reset.h b/include/linux/reset.h
index 6082247feab1..a398025d1138 100644
--- a/include/linux/reset.h
+++ b/include/linux/reset.h
@@ -1,6 +1,8 @@
1#ifndef _LINUX_RESET_H_ 1#ifndef _LINUX_RESET_H_
2#define _LINUX_RESET_H_ 2#define _LINUX_RESET_H_
3 3
4#include <linux/of.h>
5
4struct device; 6struct device;
5struct reset_control; 7struct reset_control;
6 8
@@ -8,6 +10,8 @@ int reset_control_reset(struct reset_control *rstc);
8int reset_control_assert(struct reset_control *rstc); 10int reset_control_assert(struct reset_control *rstc);
9int reset_control_deassert(struct reset_control *rstc); 11int reset_control_deassert(struct reset_control *rstc);
10 12
13struct reset_control *of_reset_control_get(struct device_node *node,
14 const char *id);
11struct reset_control *reset_control_get(struct device *dev, const char *id); 15struct reset_control *reset_control_get(struct device *dev, const char *id);
12void reset_control_put(struct reset_control *rstc); 16void reset_control_put(struct reset_control *rstc);
13struct reset_control *devm_reset_control_get(struct device *dev, const char *id); 17struct reset_control *devm_reset_control_get(struct device *dev, const char *id);