summaryrefslogtreecommitdiff
path: root/drivers/media/v4l2-core/v4l2-clk.c
diff options
context:
space:
mode:
authorJosh Wu <josh.wu@atmel.com>2015-10-28 07:48:55 -0200
committerMauro Carvalho Chehab <mchehab@osg.samsung.com>2015-11-17 15:19:52 -0200
commitdc51b7d015b6a5da00fd5e61a798607294e31a3d (patch)
tree65214ed726313f016e89147453777ed8662aa8ba /drivers/media/v4l2-core/v4l2-clk.c
parent3d83078a081a2bac7639d09404d85085368c8b66 (diff)
[media] v4l2-clk: v4l2_clk_get() also need to find the of_fullname clock
The soc-camera host will be probed and register a v4l2_clk, but if at that moment, the i2c device is not available, then the registered v4l2_clk name is an OF string not a I2C string. So when i2c sensor probes and calls v4l2_clk_get(), it only searches a clock with I2C string, like "1-0030". This patch will search the clock with OF string name if no clock with I2C string name could be found. Signed-off-by: Josh Wu <josh.wu@atmel.com> Signed-off-by: Guennadi Liakhovetski <g.liakhovetski@gmx.de> Signed-off-by: Mauro Carvalho Chehab <mchehab@osg.samsung.com>
Diffstat (limited to 'drivers/media/v4l2-core/v4l2-clk.c')
-rw-r--r--drivers/media/v4l2-core/v4l2-clk.c9
1 files changed, 9 insertions, 0 deletions
diff --git a/drivers/media/v4l2-core/v4l2-clk.c b/drivers/media/v4l2-core/v4l2-clk.c
index 34e416a554f6..297e10e69898 100644
--- a/drivers/media/v4l2-core/v4l2-clk.c
+++ b/drivers/media/v4l2-core/v4l2-clk.c
@@ -15,6 +15,7 @@
#include <linux/list.h>
#include <linux/module.h>
#include <linux/mutex.h>
+#include <linux/of.h>
#include <linux/slab.h>
#include <linux/string.h>
@@ -39,6 +40,7 @@ struct v4l2_clk *v4l2_clk_get(struct device *dev, const char *id)
{
struct v4l2_clk *clk;
struct clk *ccf_clk = clk_get(dev, id);
+ char clk_name[V4L2_CLK_NAME_SIZE];
if (PTR_ERR(ccf_clk) == -EPROBE_DEFER)
return ERR_PTR(-EPROBE_DEFER);
@@ -57,6 +59,13 @@ struct v4l2_clk *v4l2_clk_get(struct device *dev, const char *id)
mutex_lock(&clk_lock);
clk = v4l2_clk_find(dev_name(dev));
+ /* if dev_name is not found, try use the OF name to find again */
+ if (PTR_ERR(clk) == -ENODEV && dev->of_node) {
+ v4l2_clk_name_of(clk_name, sizeof(clk_name),
+ of_node_full_name(dev->of_node));
+ clk = v4l2_clk_find(clk_name);
+ }
+
if (!IS_ERR(clk))
atomic_inc(&clk->use_count);
mutex_unlock(&clk_lock);