Skip to content

Commit a53e35d

Browse files
Lee JonespH5
authored andcommitted
reset: Ensure drivers are explicit when requesting reset lines
Phasing out generic reset line requests enables us to make some better decisions on when and how to (de)assert said lines. If an 'exclusive' line is requested, we know a device *requires* a reset and that it's preferable to act upon a request right away. However, if a 'shared' reset line is requested, we can reasonably assume sure that placing a device into reset isn't a hard requirement, but probably a measure to save power and is thus able to cope with not being asserted if another device is still in use. In order allow gentle adoption and not to forcing all consumers to move to the API immediately, causing administration headache between subsystems, this patch adds some temporary stand-in shim-calls. This will ease the burden at merge time and allow subsystems to migrate over to the new API in a more realistic time-frame. Signed-off-by: Lee Jones <[email protected]> Signed-off-by: Philipp Zabel <[email protected]>
1 parent 3c35f6e commit a53e35d

File tree

1 file changed

+82
-24
lines changed

1 file changed

+82
-24
lines changed

include/linux/reset.h

Lines changed: 82 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -84,8 +84,8 @@ static inline struct reset_control *__devm_reset_control_get(
8484
#endif /* CONFIG_RESET_CONTROLLER */
8585

8686
/**
87-
* reset_control_get - Lookup and obtain an exclusive reference to a
88-
* reset controller.
87+
* reset_control_get_exclusive - Lookup and obtain an exclusive reference
88+
* to a reset controller.
8989
* @dev: device to be reset by the controller
9090
* @id: reset line name
9191
*
@@ -98,8 +98,8 @@ static inline struct reset_control *__devm_reset_control_get(
9898
*
9999
* Use of id names is optional.
100100
*/
101-
static inline struct reset_control *__must_check reset_control_get(
102-
struct device *dev, const char *id)
101+
static inline struct reset_control *
102+
__must_check reset_control_get_exclusive(struct device *dev, const char *id)
103103
{
104104
#ifndef CONFIG_RESET_CONTROLLER
105105
WARN_ON(1);
@@ -135,55 +135,60 @@ static inline struct reset_control *reset_control_get_shared(
135135
return __of_reset_control_get(dev ? dev->of_node : NULL, id, 0, 1);
136136
}
137137

138-
static inline struct reset_control *reset_control_get_optional(
138+
static inline struct reset_control *reset_control_get_optional_exclusive(
139139
struct device *dev, const char *id)
140140
{
141141
return __of_reset_control_get(dev ? dev->of_node : NULL, id, 0, 0);
142142
}
143143

144144
/**
145-
* of_reset_control_get - Lookup and obtain an exclusive reference to a
146-
* reset controller.
145+
* of_reset_control_get_exclusive - Lookup and obtain an exclusive reference
146+
* to a reset controller.
147147
* @node: device to be reset by the controller
148148
* @id: reset line name
149149
*
150150
* Returns a struct reset_control or IS_ERR() condition containing errno.
151151
*
152152
* Use of id names is optional.
153153
*/
154-
static inline struct reset_control *of_reset_control_get(
154+
static inline struct reset_control *of_reset_control_get_exclusive(
155155
struct device_node *node, const char *id)
156156
{
157157
return __of_reset_control_get(node, id, 0, 0);
158158
}
159159

160160
/**
161-
* of_reset_control_get_by_index - Lookup and obtain an exclusive reference to
162-
* a reset controller by index.
161+
* of_reset_control_get_exclusive_by_index - Lookup and obtain an exclusive
162+
* reference to a reset controller
163+
* by index.
163164
* @node: device to be reset by the controller
164165
* @index: index of the reset controller
165166
*
166167
* This is to be used to perform a list of resets for a device or power domain
167168
* in whatever order. Returns a struct reset_control or IS_ERR() condition
168169
* containing errno.
169170
*/
170-
static inline struct reset_control *of_reset_control_get_by_index(
171+
static inline struct reset_control *of_reset_control_get_exclusive_by_index(
171172
struct device_node *node, int index)
172173
{
173174
return __of_reset_control_get(node, NULL, index, 0);
174175
}
175176

176177
/**
177-
* devm_reset_control_get - resource managed reset_control_get()
178+
* devm_reset_control_get_exclusive - resource managed
179+
* reset_control_get_exclusive()
178180
* @dev: device to be reset by the controller
179181
* @id: reset line name
180182
*
181-
* Managed reset_control_get(). For reset controllers returned from this
182-
* function, reset_control_put() is called automatically on driver detach.
183-
* See reset_control_get() for more information.
183+
* Managed reset_control_get_exclusive(). For reset controllers returned
184+
* from this function, reset_control_put() is called automatically on driver
185+
* detach.
186+
*
187+
* See reset_control_get_exclusive() for more information.
184188
*/
185-
static inline struct reset_control *__must_check devm_reset_control_get(
186-
struct device *dev, const char *id)
189+
static inline struct reset_control *
190+
__must_check devm_reset_control_get_exclusive(struct device *dev,
191+
const char *id)
187192
{
188193
#ifndef CONFIG_RESET_CONTROLLER
189194
WARN_ON(1);
@@ -206,23 +211,26 @@ static inline struct reset_control *devm_reset_control_get_shared(
206211
return __devm_reset_control_get(dev, id, 0, 1);
207212
}
208213

209-
static inline struct reset_control *devm_reset_control_get_optional(
214+
static inline struct reset_control *devm_reset_control_get_optional_exclusive(
210215
struct device *dev, const char *id)
211216
{
212217
return __devm_reset_control_get(dev, id, 0, 0);
213218
}
214219

215220
/**
216-
* devm_reset_control_get_by_index - resource managed reset_control_get
221+
* devm_reset_control_get_exclusive_by_index - resource managed
222+
* reset_control_get_exclusive()
217223
* @dev: device to be reset by the controller
218224
* @index: index of the reset controller
219225
*
220-
* Managed reset_control_get(). For reset controllers returned from this
221-
* function, reset_control_put() is called automatically on driver detach.
222-
* See reset_control_get() for more information.
226+
* Managed reset_control_get_exclusive(). For reset controllers returned from
227+
* this function, reset_control_put() is called automatically on driver
228+
* detach.
229+
*
230+
* See reset_control_get_exclusive() for more information.
223231
*/
224-
static inline struct reset_control *devm_reset_control_get_by_index(
225-
struct device *dev, int index)
232+
static inline struct reset_control *
233+
devm_reset_control_get_exclusive_by_index(struct device *dev, int index)
226234
{
227235
return __devm_reset_control_get(dev, NULL, index, 0);
228236
}
@@ -243,4 +251,54 @@ static inline struct reset_control *devm_reset_control_get_shared_by_index(
243251
return __devm_reset_control_get(dev, NULL, index, 1);
244252
}
245253

254+
/*
255+
* TEMPORARY calls to use during transition:
256+
*
257+
* of_reset_control_get() => of_reset_control_get_exclusive()
258+
*
259+
* These inline function calls will be removed once all consumers
260+
* have been moved over to the new explicit API.
261+
*/
262+
static inline struct reset_control *reset_control_get(
263+
struct device *dev, const char *id)
264+
{
265+
return reset_control_get_exclusive(dev, id);
266+
}
267+
268+
static inline struct reset_control *reset_control_get_optional(
269+
struct device *dev, const char *id)
270+
{
271+
return reset_control_get_optional_exclusive(dev, id);
272+
}
273+
274+
static inline struct reset_control *of_reset_control_get(
275+
struct device_node *node, const char *id)
276+
{
277+
return of_reset_control_get_exclusive(node, id);
278+
}
279+
280+
static inline struct reset_control *of_reset_control_get_by_index(
281+
struct device_node *node, int index)
282+
{
283+
return of_reset_control_get_exclusive_by_index(node, index);
284+
}
285+
286+
static inline struct reset_control *devm_reset_control_get(
287+
struct device *dev, const char *id)
288+
{
289+
return devm_reset_control_get_exclusive(dev, id);
290+
}
291+
292+
static inline struct reset_control *devm_reset_control_get_optional(
293+
struct device *dev, const char *id)
294+
{
295+
return devm_reset_control_get_optional_exclusive(dev, id);
296+
297+
}
298+
299+
static inline struct reset_control *devm_reset_control_get_by_index(
300+
struct device *dev, int index)
301+
{
302+
return devm_reset_control_get_exclusive_by_index(dev, index);
303+
}
246304
#endif

0 commit comments

Comments
 (0)