From 877f1af154ec427d9c3c936a39a10afda95dcb97 Mon Sep 17 00:00:00 2001 From: Fabio Estevam Date: Sun, 27 Aug 2017 13:30:37 -0300 Subject: [media] ov2640: Propagate the real error on devm_clk_get() failure devm_clk_get() may return different error codes other than -EPROBE_DEFER, so it is better to return the real error code instead. Signed-off-by: Fabio Estevam Signed-off-by: Sakari Ailus Signed-off-by: Mauro Carvalho Chehab --- drivers/media/i2c/ov2640.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'drivers/media/i2c/ov2640.c') diff --git a/drivers/media/i2c/ov2640.c b/drivers/media/i2c/ov2640.c index e6d0c1f64f0b..e6cbe01bc4cf 100644 --- a/drivers/media/i2c/ov2640.c +++ b/drivers/media/i2c/ov2640.c @@ -1107,7 +1107,7 @@ static int ov2640_probe(struct i2c_client *client, if (client->dev.of_node) { priv->clk = devm_clk_get(&client->dev, "xvclk"); if (IS_ERR(priv->clk)) - return -EPROBE_DEFER; + return PTR_ERR(priv->clk); clk_prepare_enable(priv->clk); } -- cgit v1.2.3 From c3d14780249814f200317cfed1e5d288aeefb528 Mon Sep 17 00:00:00 2001 From: Fabio Estevam Date: Sun, 27 Aug 2017 13:30:38 -0300 Subject: [media] ov2640: Check the return value from clk_prepare_enable() clk_prepare_enable() may fail, so we should better check its return value and propagate it in the case of error. Signed-off-by: Fabio Estevam Signed-off-by: Sakari Ailus Signed-off-by: Mauro Carvalho Chehab --- drivers/media/i2c/ov2640.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'drivers/media/i2c/ov2640.c') diff --git a/drivers/media/i2c/ov2640.c b/drivers/media/i2c/ov2640.c index e6cbe01bc4cf..5f013c8cbdb5 100644 --- a/drivers/media/i2c/ov2640.c +++ b/drivers/media/i2c/ov2640.c @@ -1108,7 +1108,9 @@ static int ov2640_probe(struct i2c_client *client, priv->clk = devm_clk_get(&client->dev, "xvclk"); if (IS_ERR(priv->clk)) return PTR_ERR(priv->clk); - clk_prepare_enable(priv->clk); + ret = clk_prepare_enable(priv->clk); + if (ret) + return ret; } ret = ov2640_probe_dt(client, priv); -- cgit v1.2.3 From 0fd58435890aa9f2d44baaa2f328f7f8f512f4dc Mon Sep 17 00:00:00 2001 From: Markus Elfring Date: Sat, 2 Sep 2017 11:07:31 -0300 Subject: [media] i2c: Delete an error messages for failed memory allocation Omit extra messages for memory allocation failures. This issue was detected by using the Coccinelle software. [mchehab@s-opensource.com: merged similar patches] Signed-off-by: Markus Elfring Signed-off-by: Sakari Ailus Signed-off-by: Mauro Carvalho Chehab --- drivers/media/i2c/ov2640.c | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) (limited to 'drivers/media/i2c/ov2640.c') diff --git a/drivers/media/i2c/ov2640.c b/drivers/media/i2c/ov2640.c index 5f013c8cbdb5..c0d0c50f1d02 100644 --- a/drivers/media/i2c/ov2640.c +++ b/drivers/media/i2c/ov2640.c @@ -1098,11 +1098,8 @@ static int ov2640_probe(struct i2c_client *client, } priv = devm_kzalloc(&client->dev, sizeof(struct ov2640_priv), GFP_KERNEL); - if (!priv) { - dev_err(&adapter->dev, - "Failed to allocate memory for private data!\n"); + if (!priv) return -ENOMEM; - } if (client->dev.of_node) { priv->clk = devm_clk_get(&client->dev, "xvclk"); -- cgit v1.2.3 From 19fab6fe67d815eb90095e21e3273a1fbe0c8fd9 Mon Sep 17 00:00:00 2001 From: Markus Elfring Date: Sat, 2 Sep 2017 11:09:35 -0300 Subject: [media] i2c: Improve a size determination Replace the specification of a data structure by pointer dereferences as the parameter for the operator "sizeof" to make size determination a bit safer according to the Linux coding style convention. This issue was detected by using the Coccinelle software. [mchehab@s-opensource.com: merged similar patches] Signed-off-by: Markus Elfring Signed-off-by: Sakari Ailus Signed-off-by: Mauro Carvalho Chehab --- drivers/media/i2c/ov2640.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'drivers/media/i2c/ov2640.c') diff --git a/drivers/media/i2c/ov2640.c b/drivers/media/i2c/ov2640.c index c0d0c50f1d02..cc3882c1e10e 100644 --- a/drivers/media/i2c/ov2640.c +++ b/drivers/media/i2c/ov2640.c @@ -1097,7 +1097,7 @@ static int ov2640_probe(struct i2c_client *client, return -EIO; } - priv = devm_kzalloc(&client->dev, sizeof(struct ov2640_priv), GFP_KERNEL); + priv = devm_kzalloc(&client->dev, sizeof(*priv), GFP_KERNEL); if (!priv) return -ENOMEM; -- cgit v1.2.3 From 91c158dd26b82207c80970b85ff7aa473da42312 Mon Sep 17 00:00:00 2001 From: Colin Ian King Date: Tue, 12 Sep 2017 06:11:15 -0300 Subject: [media] ov2640: make array reset_seq static, reduces object code size Don't populate the array reset_seq on the stack, instead make it static. Makes the object code smaller by over 50 bytes: Before: text data bss dec hex filename 11737 6000 64 17801 4589 drivers/media/i2c/ov2640.o After: text data bss dec hex filename 11582 6096 64 17742 454e drivers/media/i2c/ov2640.o Signed-off-by: Colin Ian King Signed-off-by: Sakari Ailus Signed-off-by: Mauro Carvalho Chehab --- drivers/media/i2c/ov2640.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'drivers/media/i2c/ov2640.c') diff --git a/drivers/media/i2c/ov2640.c b/drivers/media/i2c/ov2640.c index cc3882c1e10e..38b8bab7e6aa 100644 --- a/drivers/media/i2c/ov2640.c +++ b/drivers/media/i2c/ov2640.c @@ -685,7 +685,7 @@ static int ov2640_mask_set(struct i2c_client *client, static int ov2640_reset(struct i2c_client *client) { int ret; - const struct regval_list reset_seq[] = { + static const struct regval_list reset_seq[] = { {BANK_SEL, BANK_SEL_SENS}, {COM7, COM7_SRST}, ENDMARKER, -- cgit v1.2.3 From 6b725eb682a634c6742660f85aa5736ee1009a42 Mon Sep 17 00:00:00 2001 From: Akinobu Mita Date: Thu, 19 Oct 2017 12:31:22 -0400 Subject: media: ov2640: don't clear V4L2_SUBDEV_FL_IS_I2C The v4l2_i2c_subdev_init() sets V4L2_SUBDEV_FL_IS_I2C flag in the subdev->flags. But this driver overwrites subdev->flags immediately after calling v4l2_i2c_subdev_init(). So V4L2_SUBDEV_FL_IS_I2C is not set after all. This stops breaking subdev->flags and preserves V4L2_SUBDEV_FL_IS_I2C. Side note: According to the comment in v4l2_device_unregister(), this is problematic only if the device is platform bus device. Device tree or ACPI based devices are not affected. Cc: Mauro Carvalho Chehab Signed-off-by: Akinobu Mita Signed-off-by: Sakari Ailus Signed-off-by: Mauro Carvalho Chehab --- drivers/media/i2c/ov2640.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'drivers/media/i2c/ov2640.c') diff --git a/drivers/media/i2c/ov2640.c b/drivers/media/i2c/ov2640.c index 38b8bab7e6aa..518868388d65 100644 --- a/drivers/media/i2c/ov2640.c +++ b/drivers/media/i2c/ov2640.c @@ -1115,7 +1115,7 @@ static int ov2640_probe(struct i2c_client *client, goto err_clk; v4l2_i2c_subdev_init(&priv->subdev, client, &ov2640_subdev_ops); - priv->subdev.flags = V4L2_SUBDEV_FL_HAS_DEVNODE; + priv->subdev.flags |= V4L2_SUBDEV_FL_HAS_DEVNODE; v4l2_ctrl_handler_init(&priv->hdl, 2); v4l2_ctrl_new_std(&priv->hdl, &ov2640_ctrl_ops, V4L2_CID_VFLIP, 0, 1, 1, 0); -- cgit v1.2.3