[PATCH 4/4] v4l2-clk: v4l2_clk_get() also need to find the of_fullname clock

From: Josh Wu
Date: Wed Oct 28 2015 - 05:43:10 EST

The soc-camera host will be probed and register a v4l2_clk, but if on
that moment, the i2c device is not available, then the registered
v4l2_clk name is a OF string not a I2C string.

So when i2c sensor probed and call v4l2_clk_get(), it only search the
clock with I2C string, like "1-0030".

This patch will search the clock with OF string name if fail to find the
clock with I2C string name.

Signed-off-by: Josh Wu <josh.wu@xxxxxxxxx>

drivers/media/v4l2-core/v4l2-clk.c | 9 +++++++++
1 file changed, 9 insertions(+)

diff --git a/drivers/media/v4l2-core/v4l2-clk.c b/drivers/media/v4l2-core/v4l2-clk.c
index 34e416a..297e10e 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)
@@ -57,6 +59,13 @@ struct v4l2_clk *v4l2_clk_get(struct device *dev, const char *id)
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))

To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/