* [PATCH 0/4] soc-camera: fix the bug which will fail to search the registered v4l2-clk
@ 2015-10-28 9:48 Josh Wu
2015-10-28 9:48 ` [PATCH 1/4] soc_camera: get the clock name by using macro: v4l2_clk_name_i2c() Josh Wu
` (3 more replies)
0 siblings, 4 replies; 5+ messages in thread
From: Josh Wu @ 2015-10-28 9:48 UTC (permalink / raw)
To: Guennadi Liakhovetski, Laurent Pinchart
Cc: Linux Media Mailing List, Josh Wu, Mauro Carvalho Chehab, linux-kernel
This patch set will fix a bug in soc-camera, which will fail to search
the v4l2-clk if the i2c sensor is probed later than soc-camera host.
It also add some clean up for v4l2-clk code and usage.
Josh Wu (4):
soc_camera: get the clock name by using macro: v4l2_clk_name_i2c()
v4l2-clk: add new macro for v4l2_clk_name_of()
v4l2-clk: add new definition: V4L2_CLK_NAME_SIZE
v4l2-clk: v4l2_clk_get() also need to find the of_fullname clock
drivers/media/platform/soc_camera/soc_camera.c | 23 ++++++++++++-----------
drivers/media/usb/em28xx/em28xx-camera.c | 2 +-
drivers/media/v4l2-core/v4l2-clk.c | 9 +++++++++
include/media/v4l2-clk.h | 5 +++++
4 files changed, 27 insertions(+), 12 deletions(-)
--
1.9.1
^ permalink raw reply [flat|nested] 5+ messages in thread
* [PATCH 1/4] soc_camera: get the clock name by using macro: v4l2_clk_name_i2c()
2015-10-28 9:48 [PATCH 0/4] soc-camera: fix the bug which will fail to search the registered v4l2-clk Josh Wu
@ 2015-10-28 9:48 ` Josh Wu
2015-10-28 9:48 ` [PATCH 2/4] v4l2-clk: add new macro for v4l2_clk_name_of() Josh Wu
` (2 subsequent siblings)
3 siblings, 0 replies; 5+ messages in thread
From: Josh Wu @ 2015-10-28 9:48 UTC (permalink / raw)
To: Guennadi Liakhovetski, Laurent Pinchart
Cc: Linux Media Mailing List, Josh Wu, Mauro Carvalho Chehab, linux-kernel
Since v4l2_clk_name_i2c() is defined, so just reuse it.
Signed-off-by: Josh Wu <josh.wu@atmel.com>
---
drivers/media/platform/soc_camera/soc_camera.c | 13 +++++++------
1 file changed, 7 insertions(+), 6 deletions(-)
diff --git a/drivers/media/platform/soc_camera/soc_camera.c b/drivers/media/platform/soc_camera/soc_camera.c
index 9d24d44..d165bff 100644
--- a/drivers/media/platform/soc_camera/soc_camera.c
+++ b/drivers/media/platform/soc_camera/soc_camera.c
@@ -1393,8 +1393,8 @@ static int soc_camera_i2c_init(struct soc_camera_device *icd,
ssdd->sd_pdata.regulators = NULL;
shd->board_info->platform_data = ssdd;
- snprintf(clk_name, sizeof(clk_name), "%d-%04x",
- shd->i2c_adapter_id, shd->board_info->addr);
+ v4l2_clk_name_i2c(clk_name, sizeof(clk_name),
+ shd->i2c_adapter_id, shd->board_info->addr);
icd->clk = v4l2_clk_register(&soc_camera_clk_ops, clk_name, icd);
if (IS_ERR(icd->clk)) {
@@ -1574,8 +1574,9 @@ static int scan_async_group(struct soc_camera_host *ici,
icd->sasc = sasc;
icd->parent = ici->v4l2_dev.dev;
- snprintf(clk_name, sizeof(clk_name), "%d-%04x",
- sasd->asd.match.i2c.adapter_id, sasd->asd.match.i2c.address);
+ v4l2_clk_name_i2c(clk_name, sizeof(clk_name),
+ sasd->asd.match.i2c.adapter_id,
+ sasd->asd.match.i2c.address);
icd->clk = v4l2_clk_register(&soc_camera_clk_ops, clk_name, icd);
if (IS_ERR(icd->clk)) {
@@ -1676,8 +1677,8 @@ static int soc_of_bind(struct soc_camera_host *ici,
client = of_find_i2c_device_by_node(remote);
if (client)
- snprintf(clk_name, sizeof(clk_name), "%d-%04x",
- client->adapter->nr, client->addr);
+ v4l2_clk_name_i2c(clk_name, sizeof(clk_name),
+ client->adapter->nr, client->addr);
else
snprintf(clk_name, sizeof(clk_name), "of-%s",
of_node_full_name(remote));
--
1.9.1
^ permalink raw reply related [flat|nested] 5+ messages in thread
* [PATCH 2/4] v4l2-clk: add new macro for v4l2_clk_name_of()
2015-10-28 9:48 [PATCH 0/4] soc-camera: fix the bug which will fail to search the registered v4l2-clk Josh Wu
2015-10-28 9:48 ` [PATCH 1/4] soc_camera: get the clock name by using macro: v4l2_clk_name_i2c() Josh Wu
@ 2015-10-28 9:48 ` Josh Wu
2015-10-28 9:48 ` [PATCH 3/4] v4l2-clk: add new definition: V4L2_CLK_NAME_SIZE Josh Wu
2015-10-28 9:48 ` [PATCH 4/4] v4l2-clk: v4l2_clk_get() also need to find the of_fullname clock Josh Wu
3 siblings, 0 replies; 5+ messages in thread
From: Josh Wu @ 2015-10-28 9:48 UTC (permalink / raw)
To: Guennadi Liakhovetski, Laurent Pinchart
Cc: Linux Media Mailing List, Josh Wu, Mauro Carvalho Chehab, linux-kernel
This macro is used to generate a OF string for a v4l2 clock.
Signed-off-by: Josh Wu <josh.wu@atmel.com>
---
drivers/media/platform/soc_camera/soc_camera.c | 4 ++--
include/media/v4l2-clk.h | 3 +++
2 files changed, 5 insertions(+), 2 deletions(-)
diff --git a/drivers/media/platform/soc_camera/soc_camera.c b/drivers/media/platform/soc_camera/soc_camera.c
index d165bff..673f1d4 100644
--- a/drivers/media/platform/soc_camera/soc_camera.c
+++ b/drivers/media/platform/soc_camera/soc_camera.c
@@ -1680,8 +1680,8 @@ static int soc_of_bind(struct soc_camera_host *ici,
v4l2_clk_name_i2c(clk_name, sizeof(clk_name),
client->adapter->nr, client->addr);
else
- snprintf(clk_name, sizeof(clk_name), "of-%s",
- of_node_full_name(remote));
+ v4l2_clk_name_of(clk_name, sizeof(clk_name),
+ of_node_full_name(remote));
icd->clk = v4l2_clk_register(&soc_camera_clk_ops, clk_name, icd);
if (IS_ERR(icd->clk)) {
diff --git a/include/media/v4l2-clk.h b/include/media/v4l2-clk.h
index 3ef6e3d..34891ea 100644
--- a/include/media/v4l2-clk.h
+++ b/include/media/v4l2-clk.h
@@ -68,4 +68,7 @@ static inline struct v4l2_clk *v4l2_clk_register_fixed(const char *dev_id,
#define v4l2_clk_name_i2c(name, size, adap, client) snprintf(name, size, \
"%d-%04x", adap, client)
+#define v4l2_clk_name_of(name, size, of_full_name) snprintf(name, size, \
+ "of-%s", of_full_name)
+
#endif
--
1.9.1
^ permalink raw reply related [flat|nested] 5+ messages in thread
* [PATCH 3/4] v4l2-clk: add new definition: V4L2_CLK_NAME_SIZE
2015-10-28 9:48 [PATCH 0/4] soc-camera: fix the bug which will fail to search the registered v4l2-clk Josh Wu
2015-10-28 9:48 ` [PATCH 1/4] soc_camera: get the clock name by using macro: v4l2_clk_name_i2c() Josh Wu
2015-10-28 9:48 ` [PATCH 2/4] v4l2-clk: add new macro for v4l2_clk_name_of() Josh Wu
@ 2015-10-28 9:48 ` Josh Wu
2015-10-28 9:48 ` [PATCH 4/4] v4l2-clk: v4l2_clk_get() also need to find the of_fullname clock Josh Wu
3 siblings, 0 replies; 5+ messages in thread
From: Josh Wu @ 2015-10-28 9:48 UTC (permalink / raw)
To: Guennadi Liakhovetski, Laurent Pinchart
Cc: Linux Media Mailing List, Josh Wu, Mauro Carvalho Chehab, linux-kernel
Make all v4l2-clk's clock name use V4L2_CLK_NAME_SIZE definition.
In future, if the string increased we just need to change the
V4L2_CLK_NAME_SIZE once.
Signed-off-by: Josh Wu <josh.wu@atmel.com>
---
drivers/media/platform/soc_camera/soc_camera.c | 6 +++---
drivers/media/usb/em28xx/em28xx-camera.c | 2 +-
include/media/v4l2-clk.h | 2 ++
3 files changed, 6 insertions(+), 4 deletions(-)
diff --git a/drivers/media/platform/soc_camera/soc_camera.c b/drivers/media/platform/soc_camera/soc_camera.c
index 673f1d4..506a569 100644
--- a/drivers/media/platform/soc_camera/soc_camera.c
+++ b/drivers/media/platform/soc_camera/soc_camera.c
@@ -1362,7 +1362,7 @@ static int soc_camera_i2c_init(struct soc_camera_device *icd,
struct soc_camera_host_desc *shd = &sdesc->host_desc;
struct i2c_adapter *adap;
struct v4l2_subdev *subdev;
- char clk_name[V4L2_SUBDEV_NAME_SIZE];
+ char clk_name[V4L2_CLK_NAME_SIZE];
int ret;
/* First find out how we link the main client */
@@ -1528,7 +1528,7 @@ static int scan_async_group(struct soc_camera_host *ici,
struct soc_camera_async_client *sasc;
struct soc_camera_device *icd;
struct soc_camera_desc sdesc = {.host_desc.bus_id = ici->nr,};
- char clk_name[V4L2_SUBDEV_NAME_SIZE];
+ char clk_name[V4L2_CLK_NAME_SIZE];
unsigned int i;
int ret;
@@ -1634,7 +1634,7 @@ static int soc_of_bind(struct soc_camera_host *ici,
struct soc_camera_async_client *sasc;
struct soc_of_info *info;
struct i2c_client *client;
- char clk_name[V4L2_SUBDEV_NAME_SIZE + 32];
+ char clk_name[V4L2_CLK_NAME_SIZE];
int ret;
/* allocate a new subdev and add match info to it */
diff --git a/drivers/media/usb/em28xx/em28xx-camera.c b/drivers/media/usb/em28xx/em28xx-camera.c
index ed0b3a8..121cdfc 100644
--- a/drivers/media/usb/em28xx/em28xx-camera.c
+++ b/drivers/media/usb/em28xx/em28xx-camera.c
@@ -322,7 +322,7 @@ int em28xx_detect_sensor(struct em28xx *dev)
int em28xx_init_camera(struct em28xx *dev)
{
- char clk_name[V4L2_SUBDEV_NAME_SIZE];
+ char clk_name[V4L2_CLK_NAME_SIZE];
struct i2c_client *client = &dev->i2c_client[dev->def_i2c_bus];
struct i2c_adapter *adap = &dev->i2c_adap[dev->def_i2c_bus];
struct em28xx_v4l2 *v4l2 = dev->v4l2;
diff --git a/include/media/v4l2-clk.h b/include/media/v4l2-clk.h
index 34891ea..2b94662 100644
--- a/include/media/v4l2-clk.h
+++ b/include/media/v4l2-clk.h
@@ -65,6 +65,8 @@ static inline struct v4l2_clk *v4l2_clk_register_fixed(const char *dev_id,
return __v4l2_clk_register_fixed(dev_id, rate, THIS_MODULE);
}
+#define V4L2_CLK_NAME_SIZE 64
+
#define v4l2_clk_name_i2c(name, size, adap, client) snprintf(name, size, \
"%d-%04x", adap, client)
--
1.9.1
^ permalink raw reply related [flat|nested] 5+ messages in thread
* [PATCH 4/4] v4l2-clk: v4l2_clk_get() also need to find the of_fullname clock
2015-10-28 9:48 [PATCH 0/4] soc-camera: fix the bug which will fail to search the registered v4l2-clk Josh Wu
` (2 preceding siblings ...)
2015-10-28 9:48 ` [PATCH 3/4] v4l2-clk: add new definition: V4L2_CLK_NAME_SIZE Josh Wu
@ 2015-10-28 9:48 ` Josh Wu
3 siblings, 0 replies; 5+ messages in thread
From: Josh Wu @ 2015-10-28 9:48 UTC (permalink / raw)
To: Guennadi Liakhovetski, Laurent Pinchart
Cc: Linux Media Mailing List, Josh Wu, Mauro Carvalho Chehab, linux-kernel
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@atmel.com>
---
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)
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);
--
1.9.1
^ permalink raw reply related [flat|nested] 5+ messages in thread
end of thread, other threads:[~2015-10-28 9:42 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-10-28 9:48 [PATCH 0/4] soc-camera: fix the bug which will fail to search the registered v4l2-clk Josh Wu
2015-10-28 9:48 ` [PATCH 1/4] soc_camera: get the clock name by using macro: v4l2_clk_name_i2c() Josh Wu
2015-10-28 9:48 ` [PATCH 2/4] v4l2-clk: add new macro for v4l2_clk_name_of() Josh Wu
2015-10-28 9:48 ` [PATCH 3/4] v4l2-clk: add new definition: V4L2_CLK_NAME_SIZE Josh Wu
2015-10-28 9:48 ` [PATCH 4/4] v4l2-clk: v4l2_clk_get() also need to find the of_fullname clock Josh Wu
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).