aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorThierry Reding <treding@nvidia.com>2019-02-21 10:25:55 -0500
committerPhilipp Zabel <p.zabel@pengutronix.de>2019-03-20 06:18:53 -0400
commit22815f1825e4c50314e7084ca375f7368704fdd4 (patch)
tree8024963b4f3f1a794b6aea2c76b5cb74903f89cf
parentf31d5c24fb2ea6fcfa4d300886eb87b662fbc0da (diff)
reset: Add acquire/release support for arrays
Add implementations that apply acquire and release operations to all reset controls part of a reset control array. Signed-off-by: Thierry Reding <treding@nvidia.com> Reviewed-by: Philipp Zabel <p.zabel@pengutronix.de> Signed-off-by: Philipp Zabel <p.zabel@pengutronix.de>
-rw-r--r--drivers/reset/core.c36
-rw-r--r--include/linux/reset.h6
2 files changed, 41 insertions, 1 deletions
diff --git a/drivers/reset/core.c b/drivers/reset/core.c
index f94da91c22af..81ea77cba123 100644
--- a/drivers/reset/core.c
+++ b/drivers/reset/core.c
@@ -245,6 +245,34 @@ err:
245 return ret; 245 return ret;
246} 246}
247 247
248static int reset_control_array_acquire(struct reset_control_array *resets)
249{
250 unsigned int i;
251 int err;
252
253 for (i = 0; i < resets->num_rstcs; i++) {
254 err = reset_control_acquire(resets->rstc[i]);
255 if (err < 0)
256 goto release;
257 }
258
259 return 0;
260
261release:
262 while (i--)
263 reset_control_release(resets->rstc[i]);
264
265 return err;
266}
267
268static void reset_control_array_release(struct reset_control_array *resets)
269{
270 unsigned int i;
271
272 for (i = 0; i < resets->num_rstcs; i++)
273 reset_control_release(resets->rstc[i]);
274}
275
248static inline bool reset_control_is_array(struct reset_control *rstc) 276static inline bool reset_control_is_array(struct reset_control *rstc)
249{ 277{
250 return rstc->array; 278 return rstc->array;
@@ -464,6 +492,9 @@ int reset_control_acquire(struct reset_control *rstc)
464 if (WARN_ON(IS_ERR(rstc))) 492 if (WARN_ON(IS_ERR(rstc)))
465 return -EINVAL; 493 return -EINVAL;
466 494
495 if (reset_control_is_array(rstc))
496 return reset_control_array_acquire(rstc_to_array(rstc));
497
467 mutex_lock(&reset_list_mutex); 498 mutex_lock(&reset_list_mutex);
468 499
469 if (rstc->acquired) { 500 if (rstc->acquired) {
@@ -502,7 +533,10 @@ void reset_control_release(struct reset_control *rstc)
502 if (!rstc || WARN_ON(IS_ERR(rstc))) 533 if (!rstc || WARN_ON(IS_ERR(rstc)))
503 return; 534 return;
504 535
505 rstc->acquired = false; 536 if (reset_control_is_array(rstc))
537 reset_control_array_release(rstc_to_array(rstc));
538 else
539 rstc->acquired = false;
506} 540}
507EXPORT_SYMBOL_GPL(reset_control_release); 541EXPORT_SYMBOL_GPL(reset_control_release);
508 542
diff --git a/include/linux/reset.h b/include/linux/reset.h
index a01b32bf51d4..95d555c2130a 100644
--- a/include/linux/reset.h
+++ b/include/linux/reset.h
@@ -471,6 +471,12 @@ of_reset_control_array_get_exclusive(struct device_node *node)
471} 471}
472 472
473static inline struct reset_control * 473static inline struct reset_control *
474of_reset_control_array_get_exclusive_released(struct device_node *node)
475{
476 return of_reset_control_array_get(node, false, false, false);
477}
478
479static inline struct reset_control *
474of_reset_control_array_get_shared(struct device_node *node) 480of_reset_control_array_get_shared(struct device_node *node)
475{ 481{
476 return of_reset_control_array_get(node, true, false, true); 482 return of_reset_control_array_get(node, true, false, true);