aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSoren Brinkmann <soren.brinkmann@xilinx.com>2013-04-03 15:17:12 -0400
committerMike Turquette <mturquette@linaro.org>2013-04-10 19:33:53 -0400
commitfb72a0590b770f7da6a02bde6b8a147a3d9f6168 (patch)
treeb842b02beb3a44b0d595f0b6020b8ed71c8f448e
parent312f0f0b9a4e3e2cc8ad1bbc4577a6dff025cdf6 (diff)
clk: Properly handle notifier return values
Notifiers may return NOTIFY_(OK|DONE|STOP|BAD). The CCF uses an inconsistent mix of checking against NOTIFY_STOP or NOTIFY_BAD. This inconsistency leaves errors undetected in some cases: clk_set_parent() calls __clk_speculate_rates(), which stops when it hits a NOTIFIER_BAD (STOP is ignored), and passes this value back to the caller. clk_set_parent() compares this return value against NOTIFY_STOP only, ignoring NOTIFY_BAD returns. Use NOTIFY_STOP_MASK to detect a negative notifier return value and document all four return value options. Signed-off-by: Soren Brinkmann <soren.brinkmann@xilinx.com> Signed-off-by: Mike Turquette <mturquette@linaro.org>
-rw-r--r--drivers/clk/clk.c10
-rw-r--r--include/linux/clk.h8
2 files changed, 9 insertions, 9 deletions
diff --git a/drivers/clk/clk.c b/drivers/clk/clk.c
index de6b459de78e..d65ef178e6eb 100644
--- a/drivers/clk/clk.c
+++ b/drivers/clk/clk.c
@@ -1027,16 +1027,16 @@ static int __clk_speculate_rates(struct clk *clk, unsigned long parent_rate)
1027 else 1027 else
1028 new_rate = parent_rate; 1028 new_rate = parent_rate;
1029 1029
1030 /* abort the rate change if a driver returns NOTIFY_BAD */ 1030 /* abort rate change if a driver returns NOTIFY_BAD or NOTIFY_STOP */
1031 if (clk->notifier_count) 1031 if (clk->notifier_count)
1032 ret = __clk_notify(clk, PRE_RATE_CHANGE, clk->rate, new_rate); 1032 ret = __clk_notify(clk, PRE_RATE_CHANGE, clk->rate, new_rate);
1033 1033
1034 if (ret == NOTIFY_BAD) 1034 if (ret & NOTIFY_STOP_MASK)
1035 goto out; 1035 goto out;
1036 1036
1037 hlist_for_each_entry(child, &clk->children, child_node) { 1037 hlist_for_each_entry(child, &clk->children, child_node) {
1038 ret = __clk_speculate_rates(child, new_rate); 1038 ret = __clk_speculate_rates(child, new_rate);
1039 if (ret == NOTIFY_BAD) 1039 if (ret & NOTIFY_STOP_MASK)
1040 break; 1040 break;
1041 } 1041 }
1042 1042
@@ -1129,7 +1129,7 @@ static struct clk *clk_propagate_rate_change(struct clk *clk, unsigned long even
1129 1129
1130 if (clk->notifier_count) { 1130 if (clk->notifier_count) {
1131 ret = __clk_notify(clk, event, clk->rate, clk->new_rate); 1131 ret = __clk_notify(clk, event, clk->rate, clk->new_rate);
1132 if (ret == NOTIFY_BAD) 1132 if (ret & NOTIFY_STOP_MASK)
1133 fail_clk = clk; 1133 fail_clk = clk;
1134 } 1134 }
1135 1135
@@ -1484,7 +1484,7 @@ int clk_set_parent(struct clk *clk, struct clk *parent)
1484 ret = __clk_speculate_rates(clk, p_rate); 1484 ret = __clk_speculate_rates(clk, p_rate);
1485 1485
1486 /* abort if a driver objects */ 1486 /* abort if a driver objects */
1487 if (ret == NOTIFY_STOP) 1487 if (ret & NOTIFY_STOP_MASK)
1488 goto out; 1488 goto out;
1489 1489
1490 /* do the re-parent */ 1490 /* do the re-parent */
diff --git a/include/linux/clk.h b/include/linux/clk.h
index b3ac22d0fc1f..9a6d04524b1a 100644
--- a/include/linux/clk.h
+++ b/include/linux/clk.h
@@ -28,16 +28,16 @@ struct clk;
28 * PRE_RATE_CHANGE - called immediately before the clk rate is changed, 28 * PRE_RATE_CHANGE - called immediately before the clk rate is changed,
29 * to indicate that the rate change will proceed. Drivers must 29 * to indicate that the rate change will proceed. Drivers must
30 * immediately terminate any operations that will be affected by the 30 * immediately terminate any operations that will be affected by the
31 * rate change. Callbacks may either return NOTIFY_DONE or 31 * rate change. Callbacks may either return NOTIFY_DONE, NOTIFY_OK,
32 * NOTIFY_STOP. 32 * NOTIFY_STOP or NOTIFY_BAD.
33 * 33 *
34 * ABORT_RATE_CHANGE: called if the rate change failed for some reason 34 * ABORT_RATE_CHANGE: called if the rate change failed for some reason
35 * after PRE_RATE_CHANGE. In this case, all registered notifiers on 35 * after PRE_RATE_CHANGE. In this case, all registered notifiers on
36 * the clk will be called with ABORT_RATE_CHANGE. Callbacks must 36 * the clk will be called with ABORT_RATE_CHANGE. Callbacks must
37 * always return NOTIFY_DONE. 37 * always return NOTIFY_DONE or NOTIFY_OK.
38 * 38 *
39 * POST_RATE_CHANGE - called after the clk rate change has successfully 39 * POST_RATE_CHANGE - called after the clk rate change has successfully
40 * completed. Callbacks must always return NOTIFY_DONE. 40 * completed. Callbacks must always return NOTIFY_DONE or NOTIFY_OK.
41 * 41 *
42 */ 42 */
43#define PRE_RATE_CHANGE BIT(0) 43#define PRE_RATE_CHANGE BIT(0)