summaryrefslogtreecommitdiffstats
path: root/drivers/clk/clk-devres.c
diff options
context:
space:
mode:
authorPhil Edworthy <phil.edworthy@renesas.com>2018-12-03 11:13:09 +0000
committerStephen Boyd <sboyd@kernel.org>2019-02-06 10:33:10 -0800
commit60b8f0ddf1a927ef02141a6610fd52575134f821 (patch)
tree60ea4fd636e291ff196d984885d2690571c9021b /drivers/clk/clk-devres.c
parent5c56dfe63b6e7da3d9fd84a6c553ff4d2753dd1c (diff)
downloadlinux-60b8f0ddf1a927ef02141a6610fd52575134f821.tar.gz
linux-60b8f0ddf1a927ef02141a6610fd52575134f821.tar.bz2
linux-60b8f0ddf1a927ef02141a6610fd52575134f821.zip
clk: Add (devm_)clk_get_optional() functions
This adds clk_get_optional() and devm_clk_get_optional() functions to get optional clocks. They behave the same as (devm_)clk_get() except where there is no clock producer. In this case, instead of returning -ENOENT, the function returns NULL. This makes error checking simpler and allows clk_prepare_enable, etc to be called on the returned reference without additional checks. Signed-off-by: Phil Edworthy <phil.edworthy@renesas.com> Reviewed-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com> Cc: Russell King <linux@armlinux.org.uk> [sboyd@kernel.org: Document in devres.txt] Signed-off-by: Stephen Boyd <sboyd@kernel.org>
Diffstat (limited to 'drivers/clk/clk-devres.c')
-rw-r--r--drivers/clk/clk-devres.c11
1 files changed, 11 insertions, 0 deletions
diff --git a/drivers/clk/clk-devres.c b/drivers/clk/clk-devres.c
index c9a86156ced8..daa1fc8fba53 100644
--- a/drivers/clk/clk-devres.c
+++ b/drivers/clk/clk-devres.c
@@ -29,6 +29,17 @@ struct clk *devm_clk_get(struct device *dev, const char *id)
}
EXPORT_SYMBOL(devm_clk_get);
+struct clk *devm_clk_get_optional(struct device *dev, const char *id)
+{
+ struct clk *clk = devm_clk_get(dev, id);
+
+ if (clk == ERR_PTR(-ENOENT))
+ return NULL;
+
+ return clk;
+}
+EXPORT_SYMBOL(devm_clk_get_optional);
+
struct clk_bulk_devres {
struct clk_bulk_data *clks;
int num_clks;