summaryrefslogtreecommitdiffstats
path: root/drivers/clk/clk-devres.c
diff options
context:
space:
mode:
authorPhil Edworthy2018-12-03 12:13:09 +0100
committerStephen Boyd2019-02-06 19:33:10 +0100
commit60b8f0ddf1a927ef02141a6610fd52575134f821 (patch)
tree60ea4fd636e291ff196d984885d2690571c9021b /drivers/clk/clk-devres.c
parentclk: Add comment about __of_clk_get_by_name() error values (diff)
downloadkernel-qcow2-linux-60b8f0ddf1a927ef02141a6610fd52575134f821.tar.gz
kernel-qcow2-linux-60b8f0ddf1a927ef02141a6610fd52575134f821.tar.xz
kernel-qcow2-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;