diff options
author | Mike Turquette <mturquette@linaro.org> | 2013-08-22 02:58:09 -0400 |
---|---|---|
committer | Mike Turquette <mturquette@linaro.org> | 2013-08-22 02:58:09 -0400 |
commit | 89ac8d7ae1cde0f8c7a2f85c2e3b475d54aa9163 (patch) | |
tree | 840a7dba0e72740e9155fa57974a46728015faeb /drivers/clk | |
parent | bddbd13453d838a30baf84869c56076c8ce2b211 (diff) |
clk: handle NULL struct clk gracefully
At some point changes to clk_set_rate and clk_set_parent introduced a
bug whereby NULL struct clk pointers were treated as an error. This is
in violation of the API in include/linux/clk.h. Reintroduce graceful
handling of NULL clk's by bailing from clk_set_rate and clk_set_parent
with return codes of zero.
Signed-off-by: Mike Turquette <mturquette@linaro.org>
Diffstat (limited to 'drivers/clk')
-rw-r--r-- | drivers/clk/clk.c | 8 |
1 files changed, 7 insertions, 1 deletions
diff --git a/drivers/clk/clk.c b/drivers/clk/clk.c index bc020372106b..7c4376289865 100644 --- a/drivers/clk/clk.c +++ b/drivers/clk/clk.c | |||
@@ -1428,6 +1428,9 @@ int clk_set_rate(struct clk *clk, unsigned long rate) | |||
1428 | struct clk *top, *fail_clk; | 1428 | struct clk *top, *fail_clk; |
1429 | int ret = 0; | 1429 | int ret = 0; |
1430 | 1430 | ||
1431 | if (!clk) | ||
1432 | return 0; | ||
1433 | |||
1431 | /* prevent racing with updates to the clock topology */ | 1434 | /* prevent racing with updates to the clock topology */ |
1432 | clk_prepare_lock(); | 1435 | clk_prepare_lock(); |
1433 | 1436 | ||
@@ -1567,7 +1570,10 @@ int clk_set_parent(struct clk *clk, struct clk *parent) | |||
1567 | u8 p_index = 0; | 1570 | u8 p_index = 0; |
1568 | unsigned long p_rate = 0; | 1571 | unsigned long p_rate = 0; |
1569 | 1572 | ||
1570 | if (!clk || !clk->ops) | 1573 | if (!clk) |
1574 | return 0; | ||
1575 | |||
1576 | if (!clk->ops) | ||
1571 | return -EINVAL; | 1577 | return -EINVAL; |
1572 | 1578 | ||
1573 | /* verify ops for for multi-parent clks */ | 1579 | /* verify ops for for multi-parent clks */ |