[PATCH 0/3] [media] DVB-frontends: Deletion of a few unnecessary checks

2014-11-20 Thread SF Markus Elfring
From: Markus Elfring elfr...@users.sourceforge.net
Date: Wed, 19 Nov 2014 23:30:37 +0100

Another update suggestion was taken into account after a patch was applied
from static source code analysis.

Markus Elfring (3):
  DVB-frontends: Deletion of unnecessary checks before the function
call release_firmware
  m88ds3103: One function call less in m88ds3103_init() after error detection
  si2168: One function call less in si2168_init() after error detection

 drivers/media/dvb-frontends/drx39xyj/drxj.c |  3 +--
 drivers/media/dvb-frontends/drxk_hard.c |  3 +--
 drivers/media/dvb-frontends/m88ds3103.c | 12 ++--
 drivers/media/dvb-frontends/si2168.c| 10 +-
 4 files changed, 13 insertions(+), 15 deletions(-)

-- 
2.1.3

--
To unsubscribe from this list: send the line unsubscribe linux-media in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 2/3] [media] m88ds3103: One function call less in m88ds3103_init() after error detection

2014-11-20 Thread SF Markus Elfring
From: Markus Elfring elfr...@users.sourceforge.net
Date: Wed, 19 Nov 2014 23:20:51 +0100

The release_firmware() function was called in some cases by the
m88ds3103_init() function during error handling even if the passed variable
contained still a null pointer. This implementation detail could be improved
by the introduction of another jump label.

Signed-off-by: Markus Elfring elfr...@users.sourceforge.net
---
 drivers/media/dvb-frontends/m88ds3103.c | 11 ++-
 1 file changed, 6 insertions(+), 5 deletions(-)

diff --git a/drivers/media/dvb-frontends/m88ds3103.c 
b/drivers/media/dvb-frontends/m88ds3103.c
index e88f0f6..82da715 100644
--- a/drivers/media/dvb-frontends/m88ds3103.c
+++ b/drivers/media/dvb-frontends/m88ds3103.c
@@ -590,7 +590,7 @@ static int m88ds3103_init(struct dvb_frontend *fe)
 
ret = m88ds3103_wr_reg(priv, 0xb2, 0x01);
if (ret)
-   goto err;
+   goto error_fw_release;
 
for (remaining = fw-size; remaining  0;
remaining -= (priv-cfg-i2c_wr_max - 1)) {
@@ -604,13 +604,13 @@ static int m88ds3103_init(struct dvb_frontend *fe)
dev_err(priv-i2c-dev,
%s: firmware download failed=%d\n,
KBUILD_MODNAME, ret);
-   goto err;
+   goto error_fw_release;
}
}
 
ret = m88ds3103_wr_reg(priv, 0xb2, 0x00);
if (ret)
-   goto err;
+   goto error_fw_release;
 
release_firmware(fw);
fw = NULL;
@@ -636,9 +636,10 @@ skip_fw_download:
priv-warm = true;
 
return 0;
-err:
-   release_firmware(fw);
 
+error_fw_release:
+   release_firmware(fw);
+err:
dev_dbg(priv-i2c-dev, %s: failed=%d\n, __func__, ret);
return ret;
 }
-- 
2.1.3

--
To unsubscribe from this list: send the line unsubscribe linux-media in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 1/3] [media] DVB-frontends: Deletion of unnecessary checks before the function call release_firmware

2014-11-20 Thread SF Markus Elfring
From: Markus Elfring elfr...@users.sourceforge.net
Date: Wed, 19 Nov 2014 22:27:24 +0100

The release_firmware() function tests whether its argument is NULL
and then returns immediately. Thus the test around the call is not needed.

This issue was detected by using the Coccinelle software.

Signed-off-by: Markus Elfring elfr...@users.sourceforge.net
---
 drivers/media/dvb-frontends/drx39xyj/drxj.c | 3 +--
 drivers/media/dvb-frontends/drxk_hard.c | 3 +--
 drivers/media/dvb-frontends/m88ds3103.c | 3 +--
 drivers/media/dvb-frontends/si2168.c| 3 +--
 4 files changed, 4 insertions(+), 8 deletions(-)

diff --git a/drivers/media/dvb-frontends/drx39xyj/drxj.c 
b/drivers/media/dvb-frontends/drx39xyj/drxj.c
index 7ca7a21..08e6ca5 100644
--- a/drivers/media/dvb-frontends/drx39xyj/drxj.c
+++ b/drivers/media/dvb-frontends/drx39xyj/drxj.c
@@ -12255,8 +12255,7 @@ static void drx39xxj_release(struct dvb_frontend *fe)
kfree(demod-my_ext_attr);
kfree(demod-my_common_attr);
kfree(demod-my_i2c_dev_addr);
-   if (demod-firmware)
-   release_firmware(demod-firmware);
+   release_firmware(demod-firmware);
kfree(demod);
kfree(state);
 }
diff --git a/drivers/media/dvb-frontends/drxk_hard.c 
b/drivers/media/dvb-frontends/drxk_hard.c
index cce94a7..f871478 100644
--- a/drivers/media/dvb-frontends/drxk_hard.c
+++ b/drivers/media/dvb-frontends/drxk_hard.c
@@ -6309,8 +6309,7 @@ static void drxk_release(struct dvb_frontend *fe)
struct drxk_state *state = fe-demodulator_priv;
 
dprintk(1, \n);
-   if (state-fw)
-   release_firmware(state-fw);
+   release_firmware(state-fw);
 
kfree(state);
 }
diff --git a/drivers/media/dvb-frontends/m88ds3103.c 
b/drivers/media/dvb-frontends/m88ds3103.c
index dfe0c2f..e88f0f6 100644
--- a/drivers/media/dvb-frontends/m88ds3103.c
+++ b/drivers/media/dvb-frontends/m88ds3103.c
@@ -637,8 +637,7 @@ skip_fw_download:
 
return 0;
 err:
-   if (fw)
-   release_firmware(fw);
+   release_firmware(fw);
 
dev_dbg(priv-i2c-dev, %s: failed=%d\n, __func__, ret);
return ret;
diff --git a/drivers/media/dvb-frontends/si2168.c 
b/drivers/media/dvb-frontends/si2168.c
index 8f81d97..6a455f9 100644
--- a/drivers/media/dvb-frontends/si2168.c
+++ b/drivers/media/dvb-frontends/si2168.c
@@ -469,8 +469,7 @@ static int si2168_init(struct dvb_frontend *fe)
 
return 0;
 err:
-   if (fw)
-   release_firmware(fw);
+   release_firmware(fw);
 
dev_dbg(s-client-dev, %s: failed=%d\n, __func__, ret);
return ret;
-- 
2.1.3

--
To unsubscribe from this list: send the line unsubscribe linux-media in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 3/3] [media] si2168: One function call less in si2168_init() after error detection

2014-11-20 Thread SF Markus Elfring
From: Markus Elfring elfr...@users.sourceforge.net
Date: Wed, 19 Nov 2014 23:23:15 +0100

The release_firmware() function was called in some cases by the
si2168_init() function during error handling even if the passed variable
contained still a null pointer. This implementation detail could be improved
by the introduction of another jump label.

Signed-off-by: Markus Elfring elfr...@users.sourceforge.net
---
 drivers/media/dvb-frontends/si2168.c | 9 +
 1 file changed, 5 insertions(+), 4 deletions(-)

diff --git a/drivers/media/dvb-frontends/si2168.c 
b/drivers/media/dvb-frontends/si2168.c
index 6a455f9..b8c6372 100644
--- a/drivers/media/dvb-frontends/si2168.c
+++ b/drivers/media/dvb-frontends/si2168.c
@@ -428,7 +428,7 @@ static int si2168_init(struct dvb_frontend *fe)
dev_err(s-client-dev,
%s: firmware file '%s' not found\n,
KBUILD_MODNAME, fw_file);
-   goto err;
+   goto error_fw_release;
}
}
 
@@ -448,7 +448,7 @@ static int si2168_init(struct dvb_frontend *fe)
dev_err(s-client-dev,
%s: firmware download failed=%d\n,
KBUILD_MODNAME, ret);
-   goto err;
+   goto error_fw_release;
}
}
 
@@ -468,9 +468,10 @@ static int si2168_init(struct dvb_frontend *fe)
s-active = true;
 
return 0;
-err:
-   release_firmware(fw);
 
+error_fw_release:
+   release_firmware(fw);
+err:
dev_dbg(s-client-dev, %s: failed=%d\n, __func__, ret);
return ret;
 }
-- 
2.1.3

--
To unsubscribe from this list: send the line unsubscribe linux-media in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 1/1] [media] firewire: Deletion of an unnecessary check before the function call dvb_unregister_device

2014-11-20 Thread SF Markus Elfring
From: Markus Elfring elfr...@users.sourceforge.net
Date: Thu, 20 Nov 2014 10:49:07 +0100

The dvb_unregister_device() function tests whether its argument is NULL
and then returns immediately. Thus the test around the call is not needed.

This issue was detected by using the Coccinelle software.

Signed-off-by: Markus Elfring elfr...@users.sourceforge.net
---
 drivers/media/firewire/firedtv-ci.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/drivers/media/firewire/firedtv-ci.c 
b/drivers/media/firewire/firedtv-ci.c
index e5ebdbf..e63f582 100644
--- a/drivers/media/firewire/firedtv-ci.c
+++ b/drivers/media/firewire/firedtv-ci.c
@@ -253,6 +253,5 @@ int fdtv_ca_register(struct firedtv *fdtv)
 
 void fdtv_ca_release(struct firedtv *fdtv)
 {
-   if (fdtv-cadev)
-   dvb_unregister_device(fdtv-cadev);
+   dvb_unregister_device(fdtv-cadev);
 }
-- 
2.1.3

--
To unsubscribe from this list: send the line unsubscribe linux-media in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 1/1] [media] i2c: Deletion of an unnecessary check before the function call rc_unregister_device

2014-11-20 Thread SF Markus Elfring
From: Markus Elfring elfr...@users.sourceforge.net
Date: Thu, 20 Nov 2014 11:13:16 +0100

The rc_unregister_device() function tests whether its argument is NULL
and then returns immediately. Thus the test around the call is not needed.

This issue was detected by using the Coccinelle software.

Signed-off-by: Markus Elfring elfr...@users.sourceforge.net
---
 drivers/media/i2c/ir-kbd-i2c.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/drivers/media/i2c/ir-kbd-i2c.c b/drivers/media/i2c/ir-kbd-i2c.c
index 8311f1a..175a761 100644
--- a/drivers/media/i2c/ir-kbd-i2c.c
+++ b/drivers/media/i2c/ir-kbd-i2c.c
@@ -464,8 +464,7 @@ static int ir_remove(struct i2c_client *client)
cancel_delayed_work_sync(ir-work);
 
/* unregister device */
-   if (ir-rc)
-   rc_unregister_device(ir-rc);
+   rc_unregister_device(ir-rc);
 
/* free memory */
return 0;
-- 
2.1.3

--
To unsubscribe from this list: send the line unsubscribe linux-media in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 1/1] [media] platform: Deletion of unnecessary checks before two function calls

2014-11-20 Thread SF Markus Elfring
From: Markus Elfring elfr...@users.sourceforge.net
Date: Thu, 20 Nov 2014 11:44:20 +0100

The functions i2c_put_adapter() and release_firmware() test whether their
argument is NULL and then return immediately. Thus the test around the call
is not needed.

This issue was detected by using the Coccinelle software.

Signed-off-by: Markus Elfring elfr...@users.sourceforge.net
---
 drivers/media/platform/exynos4-is/fimc-is.c   | 6 ++
 drivers/media/platform/s3c-camif/camif-core.c | 3 +--
 2 files changed, 3 insertions(+), 6 deletions(-)

diff --git a/drivers/media/platform/exynos4-is/fimc-is.c 
b/drivers/media/platform/exynos4-is/fimc-is.c
index 5476dce..a1db27b 100644
--- a/drivers/media/platform/exynos4-is/fimc-is.c
+++ b/drivers/media/platform/exynos4-is/fimc-is.c
@@ -428,8 +428,7 @@ static void fimc_is_load_firmware(const struct firmware 
*fw, void *context)
 * needed around for copying to the IS working memory every
 * time before the Cortex-A5 is restarted.
 */
-   if (is-fw.f_w)
-   release_firmware(is-fw.f_w);
+   release_firmware(is-fw.f_w);
is-fw.f_w = fw;
 done:
mutex_unlock(is-lock);
@@ -937,8 +936,7 @@ static int fimc_is_remove(struct platform_device *pdev)
vb2_dma_contig_cleanup_ctx(is-alloc_ctx);
fimc_is_put_clocks(is);
fimc_is_debugfs_remove(is);
-   if (is-fw.f_w)
-   release_firmware(is-fw.f_w);
+   release_firmware(is-fw.f_w);
fimc_is_free_cpu_memory(is);
 
return 0;
diff --git a/drivers/media/platform/s3c-camif/camif-core.c 
b/drivers/media/platform/s3c-camif/camif-core.c
index b385747..3b09b5b 100644
--- a/drivers/media/platform/s3c-camif/camif-core.c
+++ b/drivers/media/platform/s3c-camif/camif-core.c
@@ -256,8 +256,7 @@ static void camif_unregister_sensor(struct camif_dev *camif)
v4l2_device_unregister_subdev(sd);
camif-sensor.sd = NULL;
i2c_unregister_device(client);
-   if (adapter)
-   i2c_put_adapter(adapter);
+   i2c_put_adapter(adapter);
 }
 
 static int camif_create_media_links(struct camif_dev *camif)
-- 
2.1.3

--
To unsubscribe from this list: send the line unsubscribe linux-media in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 1/1] [media] rc: Deletion of unnecessary checks before two function calls

2014-11-20 Thread SF Markus Elfring
From: Markus Elfring elfr...@users.sourceforge.net
Date: Thu, 20 Nov 2014 13:01:32 +0100

The functions input_free_device() and rc_close() test whether their argument
is NULL and then return immediately. Thus the test around the call
is not needed.

This issue was detected by using the Coccinelle software.

Signed-off-by: Markus Elfring elfr...@users.sourceforge.net
---
 drivers/media/rc/lirc_dev.c | 3 +--
 drivers/media/rc/rc-main.c  | 3 +--
 2 files changed, 2 insertions(+), 4 deletions(-)

diff --git a/drivers/media/rc/lirc_dev.c b/drivers/media/rc/lirc_dev.c
index dc5cbff..5c232e6 100644
--- a/drivers/media/rc/lirc_dev.c
+++ b/drivers/media/rc/lirc_dev.c
@@ -518,8 +518,7 @@ int lirc_dev_fop_close(struct inode *inode, struct file 
*file)
 
WARN_ON(mutex_lock_killable(lirc_dev_lock));
 
-   if (ir-d.rdev)
-   rc_close(ir-d.rdev);
+   rc_close(ir-d.rdev);
 
ir-open--;
if (ir-attached) {
diff --git a/drivers/media/rc/rc-main.c b/drivers/media/rc/rc-main.c
index 8d3b74c..66df9fb 100644
--- a/drivers/media/rc/rc-main.c
+++ b/drivers/media/rc/rc-main.c
@@ -1298,8 +1298,7 @@ void rc_free_device(struct rc_dev *dev)
if (!dev)
return;
 
-   if (dev-input_dev)
-   input_free_device(dev-input_dev);
+   input_free_device(dev-input_dev);
 
put_device(dev-dev);
 
-- 
2.1.3

--
To unsubscribe from this list: send the line unsubscribe linux-media in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 1/1] [media] USB: Deletion of unnecessary checks before three function calls

2014-11-20 Thread SF Markus Elfring
From: Markus Elfring elfr...@users.sourceforge.net
Date: Thu, 20 Nov 2014 13:26:36 +0100

The functions pvr2_hdw_destroy(), rc_unregister_device() and vfree() perform
also input parameter validation. Thus the test around the call is not needed.

This issue was detected by using the Coccinelle software.

Signed-off-by: Markus Elfring elfr...@users.sourceforge.net
---
 drivers/media/usb/au0828/au0828-input.c | 3 +--
 drivers/media/usb/em28xx/em28xx-input.c | 3 +--
 drivers/media/usb/pvrusb2/pvrusb2-context.c | 2 +-
 drivers/media/usb/s2255/s2255drv.c  | 3 +--
 4 files changed, 4 insertions(+), 7 deletions(-)

diff --git a/drivers/media/usb/au0828/au0828-input.c 
b/drivers/media/usb/au0828/au0828-input.c
index fd0d3a90..3357141 100644
--- a/drivers/media/usb/au0828/au0828-input.c
+++ b/drivers/media/usb/au0828/au0828-input.c
@@ -353,8 +353,7 @@ void au0828_rc_unregister(struct au0828_dev *dev)
if (!ir)
return;
 
-   if (ir-rc)
-   rc_unregister_device(ir-rc);
+   rc_unregister_device(ir-rc);
 
/* done */
kfree(ir);
diff --git a/drivers/media/usb/em28xx/em28xx-input.c 
b/drivers/media/usb/em28xx/em28xx-input.c
index ed843bd..67a22f4 100644
--- a/drivers/media/usb/em28xx/em28xx-input.c
+++ b/drivers/media/usb/em28xx/em28xx-input.c
@@ -838,8 +838,7 @@ static int em28xx_ir_fini(struct em28xx *dev)
if (!ir)
goto ref_put;
 
-   if (ir-rc)
-   rc_unregister_device(ir-rc);
+   rc_unregister_device(ir-rc);
 
/* done */
kfree(ir);
diff --git a/drivers/media/usb/pvrusb2/pvrusb2-context.c 
b/drivers/media/usb/pvrusb2/pvrusb2-context.c
index 7c19ff7..c8761c7 100644
--- a/drivers/media/usb/pvrusb2/pvrusb2-context.c
+++ b/drivers/media/usb/pvrusb2/pvrusb2-context.c
@@ -80,7 +80,7 @@ static void pvr2_context_set_notify(struct pvr2_context *mp, 
int fl)
 static void pvr2_context_destroy(struct pvr2_context *mp)
 {
pvr2_trace(PVR2_TRACE_CTXT,pvr2_context %p (destroy),mp);
-   if (mp-hdw) pvr2_hdw_destroy(mp-hdw);
+   pvr2_hdw_destroy(mp-hdw);
pvr2_context_set_notify(mp, 0);
mutex_lock(pvr2_context_mutex);
if (mp-exist_next) {
diff --git a/drivers/media/usb/s2255/s2255drv.c 
b/drivers/media/usb/s2255/s2255drv.c
index 2c90186..3cab886 100644
--- a/drivers/media/usb/s2255/s2255drv.c
+++ b/drivers/media/usb/s2255/s2255drv.c
@@ -1976,8 +1976,7 @@ static int s2255_release_sys_buffers(struct s2255_vc *vc)
 {
unsigned long i;
for (i = 0; i  SYS_FRAMES; i++) {
-   if (vc-buffer.frame[i].lpvbits)
-   vfree(vc-buffer.frame[i].lpvbits);
+   vfree(vc-buffer.frame[i].lpvbits);
vc-buffer.frame[i].lpvbits = NULL;
}
return 0;
-- 
2.1.3

--
To unsubscribe from this list: send the line unsubscribe linux-media in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 1/1] [media] Siano: Deletion of an unnecessary check before the function call rc_unregister_device

2014-11-24 Thread SF Markus Elfring
From: Markus Elfring elfr...@users.sourceforge.net
Date: Mon, 24 Nov 2014 22:32:30 +0100

The rc_unregister_device() function tests whether its argument is NULL
and then returns immediately. Thus the test around the call
is not needed.

This issue was detected by using the Coccinelle software.

Signed-off-by: Markus Elfring elfr...@users.sourceforge.net
---
 drivers/media/common/siano/smsir.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/drivers/media/common/siano/smsir.c 
b/drivers/media/common/siano/smsir.c
index 273043e..35d0e88 100644
--- a/drivers/media/common/siano/smsir.c
+++ b/drivers/media/common/siano/smsir.c
@@ -107,8 +107,7 @@ int sms_ir_init(struct smscore_device_t *coredev)
 
 void sms_ir_exit(struct smscore_device_t *coredev)
 {
-   if (coredev-ir.dev)
-   rc_unregister_device(coredev-ir.dev);
+   rc_unregister_device(coredev-ir.dev);
 
sms_log();
 }
-- 
2.1.3

--
To unsubscribe from this list: send the line unsubscribe linux-media in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 0/2] [media] tuners: Deletion of two unnecessary checks

2014-11-30 Thread SF Markus Elfring
From: Markus Elfring elfr...@users.sourceforge.net
Date: Sun, 30 Nov 2014 20:50:15 +0100

Another update suggestion was taken into account after a patch was applied
from static source code analysis.

Markus Elfring (2):
  Deletion of unnecessary checks before the function call release_firmware
  One function call less in si2157_init() after error detection

 drivers/media/tuners/si2157.c | 9 -
 drivers/media/tuners/xc5000.c | 3 +--
 2 files changed, 5 insertions(+), 7 deletions(-)

-- 
2.1.3

--
To unsubscribe from this list: send the line unsubscribe linux-media in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 1/2] [media] tuners: Deletion of unnecessary checks before the function call release_firmware

2014-11-30 Thread SF Markus Elfring
From: Markus Elfring elfr...@users.sourceforge.net
Date: Sun, 30 Nov 2014 19:05:48 +0100

The release_firmware() function tests whether its argument is NULL
and then returns immediately. Thus the test around the call is not needed.

This issue was detected by using the Coccinelle software.

Signed-off-by: Markus Elfring elfr...@users.sourceforge.net
---
 drivers/media/tuners/si2157.c | 3 +--
 drivers/media/tuners/xc5000.c | 3 +--
 2 files changed, 2 insertions(+), 4 deletions(-)

diff --git a/drivers/media/tuners/si2157.c b/drivers/media/tuners/si2157.c
index 8e57696..e17ab1f 100644
--- a/drivers/media/tuners/si2157.c
+++ b/drivers/media/tuners/si2157.c
@@ -196,8 +196,7 @@ warm:
return 0;
 
 err:
-   if (fw)
-   release_firmware(fw);
+   release_firmware(fw);
 
dev_dbg(s-client-dev, failed=%d\n, ret);
return ret;
diff --git a/drivers/media/tuners/xc5000.c b/drivers/media/tuners/xc5000.c
index 705c258..2a039de 100644
--- a/drivers/media/tuners/xc5000.c
+++ b/drivers/media/tuners/xc5000.c
@@ -1336,8 +1336,7 @@ static int xc5000_release(struct dvb_frontend *fe)
 
if (priv) {
cancel_delayed_work(priv-timer_sleep);
-   if (priv-firmware)
-   release_firmware(priv-firmware);
+   release_firmware(priv-firmware);
hybrid_tuner_release_state(priv);
}
 
-- 
2.1.3

--
To unsubscribe from this list: send the line unsubscribe linux-media in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 2/2] [media] tuners-si2157: One function call less in si2157_init() after error detection

2014-11-30 Thread SF Markus Elfring
From: Markus Elfring elfr...@users.sourceforge.net
Date: Sun, 30 Nov 2014 20:48:24 +0100

The release_firmware() function was called in some cases by the si2157_init()
function during error handling even if the passed variable contained still
a null pointer. This implementation detail could be improved
by the introduction of another jump label.

Signed-off-by: Markus Elfring elfr...@users.sourceforge.net
---
 drivers/media/tuners/si2157.c | 8 
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/drivers/media/tuners/si2157.c b/drivers/media/tuners/si2157.c
index e17ab1f..2180de9 100644
--- a/drivers/media/tuners/si2157.c
+++ b/drivers/media/tuners/si2157.c
@@ -157,7 +157,7 @@ static int si2157_init(struct dvb_frontend *fe)
dev_err(s-client-dev, firmware file '%s' is invalid\n,
fw_file);
ret = -EINVAL;
-   goto err;
+   goto fw_release_exit;
}
 
dev_info(s-client-dev, downloading firmware from file '%s'\n,
@@ -173,7 +173,7 @@ static int si2157_init(struct dvb_frontend *fe)
dev_err(s-client-dev,
firmware download failed=%d\n,
ret);
-   goto err;
+   goto fw_release_exit;
}
}
 
@@ -195,9 +195,9 @@ warm:
s-active = true;
return 0;
 
-err:
+fw_release_exit:
release_firmware(fw);
-
+err:
dev_dbg(s-client-dev, failed=%d\n, ret);
return ret;
 }
-- 
2.1.3

--
To unsubscribe from this list: send the line unsubscribe linux-media in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 1/1] [media] ddbridge: Deletion of an unnecessary check before the function call dvb_unregister_device

2014-11-30 Thread SF Markus Elfring
From: Markus Elfring elfr...@users.sourceforge.net
Date: Sun, 30 Nov 2014 22:50:20 +0100

The dvb_unregister_device() function tests whether its argument is NULL
and then returns immediately. Thus the test around the call is not needed.

This issue was detected by using the Coccinelle software.

Signed-off-by: Markus Elfring elfr...@users.sourceforge.net
---
 drivers/media/pci/ddbridge/ddbridge-core.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/drivers/media/pci/ddbridge/ddbridge-core.c 
b/drivers/media/pci/ddbridge/ddbridge-core.c
index c82e855..9e3492e 100644
--- a/drivers/media/pci/ddbridge/ddbridge-core.c
+++ b/drivers/media/pci/ddbridge/ddbridge-core.c
@@ -1118,8 +1118,7 @@ static void ddb_ports_detach(struct ddb *dev)
dvb_input_detach(port-input[1]);
break;
case DDB_PORT_CI:
-   if (port-output-dev)
-   dvb_unregister_device(port-output-dev);
+   dvb_unregister_device(port-output-dev);
if (port-en) {
ddb_input_stop(port-input[0]);
ddb_output_stop(port-output);
-- 
2.1.3

--
To unsubscribe from this list: send the line unsubscribe linux-media in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 1/1] [media] V4L2: Deletion of an unnecessary check before the function call vb2_put_vma

2014-11-30 Thread SF Markus Elfring
From: Markus Elfring elfr...@users.sourceforge.net
Date: Sun, 30 Nov 2014 23:10:51 +0100

The vb2_put_vma() function tests whether its argument is NULL and then
returns immediately. Thus the test around the call is not needed.

This issue was detected by using the Coccinelle software.

Signed-off-by: Markus Elfring elfr...@users.sourceforge.net
---
 drivers/media/v4l2-core/videobuf2-vmalloc.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/drivers/media/v4l2-core/videobuf2-vmalloc.c 
b/drivers/media/v4l2-core/videobuf2-vmalloc.c
index 3966b12..fba944e 100644
--- a/drivers/media/v4l2-core/videobuf2-vmalloc.c
+++ b/drivers/media/v4l2-core/videobuf2-vmalloc.c
@@ -154,8 +154,7 @@ static void vb2_vmalloc_put_userptr(void *buf_priv)
}
kfree(buf-pages);
} else {
-   if (buf-vma)
-   vb2_put_vma(buf-vma);
+   vb2_put_vma(buf-vma);
iounmap(buf-vaddr);
}
kfree(buf);
-- 
2.1.3

--
To unsubscribe from this list: send the line unsubscribe linux-media in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 1/1] [media] lirc_zilog: Deletion of unnecessary checks before the function call vfree

2014-12-01 Thread SF Markus Elfring
From: Markus Elfring elfr...@users.sourceforge.net
Date: Mon, 1 Dec 2014 19:49:39 +0100

The vfree() function performs also input parameter validation. Thus the test
around the call is not needed.

This issue was detected by using the Coccinelle software.

Signed-off-by: Markus Elfring elfr...@users.sourceforge.net
---
 drivers/staging/media/lirc/lirc_zilog.c | 6 ++
 1 file changed, 2 insertions(+), 4 deletions(-)

diff --git a/drivers/staging/media/lirc/lirc_zilog.c 
b/drivers/staging/media/lirc/lirc_zilog.c
index 3259aac..50b255a 100644
--- a/drivers/staging/media/lirc/lirc_zilog.c
+++ b/drivers/staging/media/lirc/lirc_zilog.c
@@ -729,11 +729,9 @@ static int send_boot_data(struct IR_tx *tx)
 static void fw_unload_locked(void)
 {
if (tx_data) {
-   if (tx_data-code_sets)
-   vfree(tx_data-code_sets);
+   vfree(tx_data-code_sets);
 
-   if (tx_data-datap)
-   vfree(tx_data-datap);
+   vfree(tx_data-datap);
 
vfree(tx_data);
tx_data = NULL;
-- 
2.1.3

--
To unsubscribe from this list: send the line unsubscribe linux-media in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 0/2] [media] mn88473: Delete an unnecessary check

2014-12-01 Thread SF Markus Elfring
From: Markus Elfring elfr...@users.sourceforge.net
Date: Mon, 1 Dec 2014 23:16:34 +0100

Another update suggestion was taken into account after a patch was applied
from static source code analysis.

Markus Elfring (2):
  Deletion of an unnecessary check before the function call release_firmware
  One function call less in mn88473_init() after error detection

 drivers/staging/media/mn88473/mn88473.c | 8 
 1 file changed, 4 insertions(+), 4 deletions(-)

-- 
2.1.3

--
To unsubscribe from this list: send the line unsubscribe linux-media in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 1/2] [media] mn88473: Deletion of an unnecessary check before the function call release_firmware

2014-12-01 Thread SF Markus Elfring
From: Markus Elfring elfr...@users.sourceforge.net
Date: Mon, 1 Dec 2014 22:55:29 +0100

The release_firmware() function tests whether its argument is NULL and then
returns immediately. Thus the test around the call is not needed.

This issue was detected by using the Coccinelle software.

Signed-off-by: Markus Elfring elfr...@users.sourceforge.net
---
 drivers/staging/media/mn88473/mn88473.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/drivers/staging/media/mn88473/mn88473.c 
b/drivers/staging/media/mn88473/mn88473.c
index 1659335..52180bb 100644
--- a/drivers/staging/media/mn88473/mn88473.c
+++ b/drivers/staging/media/mn88473/mn88473.c
@@ -262,8 +262,7 @@ static int mn88473_init(struct dvb_frontend *fe)
 
return 0;
 err:
-   if (fw)
-   release_firmware(fw);
+   release_firmware(fw);
 
dev_dbg(client-dev, failed=%d\n, ret);
return ret;
-- 
2.1.3

--
To unsubscribe from this list: send the line unsubscribe linux-media in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 2/2] [media] mn88473: One function call less in mn88473_init() after error detection

2014-12-01 Thread SF Markus Elfring
From: Markus Elfring elfr...@users.sourceforge.net
Date: Mon, 1 Dec 2014 23:15:20 +0100

The release_firmware() function was called by the mn88473_init() function even
if a previous function call request_firmware failed.
This implementation detail could be improved by the introduction of another
jump label.

Signed-off-by: Markus Elfring elfr...@users.sourceforge.net
---
 drivers/staging/media/mn88473/mn88473.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/drivers/staging/media/mn88473/mn88473.c 
b/drivers/staging/media/mn88473/mn88473.c
index 52180bb..a333744 100644
--- a/drivers/staging/media/mn88473/mn88473.c
+++ b/drivers/staging/media/mn88473/mn88473.c
@@ -225,7 +225,7 @@ static int mn88473_init(struct dvb_frontend *fe)
ret = request_firmware(fw, fw_file, client-dev);
if (ret) {
dev_err(client-dev, firmare file '%s' not found\n, fw_file);
-   goto err;
+   goto err_request_firmware;
}
 
dev_info(client-dev, downloading firmware from file '%s'\n,
@@ -261,9 +261,10 @@ static int mn88473_init(struct dvb_frontend *fe)
dev-warm = true;
 
return 0;
+
 err:
release_firmware(fw);
-
+err_request_firmware:
dev_dbg(client-dev, failed=%d\n, ret);
return ret;
 }
-- 
2.1.3

--
To unsubscribe from this list: send the line unsubscribe linux-media in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [git:media_tree/master] [media] tuners: remove unneeded checks before release_firmware()

2014-12-04 Thread SF Markus Elfring
 This is an automatic generated email to let you know that the following patch 
 were queued at the 
 http://git.linuxtv.org/media_tree.git tree:
 
 Subject: [media] tuners: remove uneeded checks before release_firmware()

Would you like to amend a typo in the commit title?

Regards,
Markus
--
To unsubscribe from this list: send the line unsubscribe linux-media in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH] [media] V4L2: Delete an unnecessary check before the function call media_entity_put

2015-02-03 Thread SF Markus Elfring
From: Markus Elfring elfr...@users.sourceforge.net
Date: Tue, 3 Feb 2015 15:27:38 +0100

The media_entity_put() function tests whether its argument is NULL and then
returns immediately. Thus the test around the call is not needed.

This issue was detected by using the Coccinelle software.

Signed-off-by: Markus Elfring elfr...@users.sourceforge.net
---
 drivers/media/v4l2-core/v4l2-subdev.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/drivers/media/v4l2-core/v4l2-subdev.c 
b/drivers/media/v4l2-core/v4l2-subdev.c
index 543631c..b9ff7fd 100644
--- a/drivers/media/v4l2-core/v4l2-subdev.c
+++ b/drivers/media/v4l2-core/v4l2-subdev.c
@@ -93,8 +93,7 @@ static int subdev_open(struct file *file)
 
 err:
 #if defined(CONFIG_MEDIA_CONTROLLER)
-   if (entity)
-   media_entity_put(entity);
+   media_entity_put(entity);
 #endif
v4l2_fh_del(subdev_fh-vfh);
v4l2_fh_exit(subdev_fh-vfh);
-- 
2.2.2

--
To unsubscribe from this list: send the line unsubscribe linux-media in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[media] staging: bcm2048: Delete an unnecessary check before the function call video_unregister_device

2015-02-02 Thread SF Markus Elfring
From: Markus Elfring elfr...@users.sourceforge.net
Date: Mon, 2 Feb 2015 13:20:23 +0100

The video_unregister_device() function tests whether its argument is NULL
and then returns immediately. Thus the test around the call is not needed.

This issue was detected by using the Coccinelle software.

Signed-off-by: Markus Elfring elfr...@users.sourceforge.net
---
 drivers/staging/media/bcm2048/radio-bcm2048.c | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)

diff --git a/drivers/staging/media/bcm2048/radio-bcm2048.c 
b/drivers/staging/media/bcm2048/radio-bcm2048.c
index 60a57b2..f308078 100644
--- a/drivers/staging/media/bcm2048/radio-bcm2048.c
+++ b/drivers/staging/media/bcm2048/radio-bcm2048.c
@@ -2684,9 +2684,7 @@ static int __exit bcm2048_i2c_driver_remove(struct 
i2c_client *client)
vd = bdev-videodev;
 
bcm2048_sysfs_unregister_properties(bdev, ARRAY_SIZE(attrs));
-
-   if (vd)
-   video_unregister_device(vd);
+   video_unregister_device(vd);
 
if (bdev-power_state)
bcm2048_set_power_state(bdev, BCM2048_POWER_OFF);
-- 
2.2.2

--
To unsubscribe from this list: send the line unsubscribe linux-media in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 0/2] DVB: Deletion of a few unnecessary checks

2015-02-03 Thread SF Markus Elfring
From: Markus Elfring elfr...@users.sourceforge.net
Date: Tue, 3 Feb 2015 16:50:07 +0100

Another update suggestion was taken into account after a patch was applied
from static source code analysis.

Markus Elfring (2):
  Delete an unnecessary check before the function call dvb_unregister_device
  Less function calls in dvb_ca_en50221_init() after error detection

 drivers/media/dvb-core/dvb_ca_en50221.c | 24 
 1 file changed, 12 insertions(+), 12 deletions(-)

-- 
2.2.2

--
To unsubscribe from this list: send the line unsubscribe linux-media in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 2/2] [media] DVB: Less function calls in dvb_ca_en50221_init() after error detection

2015-02-03 Thread SF Markus Elfring
From: Markus Elfring elfr...@users.sourceforge.net
Date: Tue, 3 Feb 2015 16:47:48 +0100

The functions dvb_unregister_device and kfree could still be called
by the dvb_ca_en50221_init() function in the case that a previous resource
allocation failed.

* Corresponding details could be improved by adjustments for jump targets.

* Let us delete also an unnecessary check for the variable ca there.

Signed-off-by: Markus Elfring elfr...@users.sourceforge.net
---
 drivers/media/dvb-core/dvb_ca_en50221.c | 23 ---
 1 file changed, 12 insertions(+), 11 deletions(-)

diff --git a/drivers/media/dvb-core/dvb_ca_en50221.c 
b/drivers/media/dvb-core/dvb_ca_en50221.c
index b999689..9842fd1 100644
--- a/drivers/media/dvb-core/dvb_ca_en50221.c
+++ b/drivers/media/dvb-core/dvb_ca_en50221.c
@@ -1676,14 +1676,14 @@ int dvb_ca_en50221_init(struct dvb_adapter *dvb_adapter,
/* initialise the system data */
if ((ca = kzalloc(sizeof(struct dvb_ca_private), GFP_KERNEL)) == NULL) {
ret = -ENOMEM;
-   goto error;
+   goto exit;
}
ca-pub = pubca;
ca-flags = flags;
ca-slot_count = slot_count;
if ((ca-slot_info = kcalloc(slot_count, sizeof(struct dvb_ca_slot), 
GFP_KERNEL)) == NULL) {
ret = -ENOMEM;
-   goto error;
+   goto free_ca;
}
init_waitqueue_head(ca-wait_queue);
ca-open = 0;
@@ -1694,7 +1694,7 @@ int dvb_ca_en50221_init(struct dvb_adapter *dvb_adapter,
/* register the DVB device */
ret = dvb_register_device(dvb_adapter, ca-dvbdev, dvbdev_ca, ca, 
DVB_DEVICE_CA);
if (ret)
-   goto error;
+   goto free_slot_info;
 
/* now initialise each slot */
for (i = 0; i  slot_count; i++) {
@@ -1709,7 +1709,7 @@ int dvb_ca_en50221_init(struct dvb_adapter *dvb_adapter,
 
if (signal_pending(current)) {
ret = -EINTR;
-   goto error;
+   goto unregister_device;
}
mb();
 
@@ -1720,16 +1720,17 @@ int dvb_ca_en50221_init(struct dvb_adapter *dvb_adapter,
ret = PTR_ERR(ca-thread);
printk(dvb_ca_init: failed to start kernel_thread (%d)\n,
ret);
-   goto error;
+   goto unregister_device;
}
return 0;
 
-error:
-   if (ca != NULL) {
-   dvb_unregister_device(ca-dvbdev);
-   kfree(ca-slot_info);
-   kfree(ca);
-   }
+unregister_device:
+   dvb_unregister_device(ca-dvbdev);
+free_slot_info:
+   kfree(ca-slot_info);
+free_ca:
+   kfree(ca);
+exit:
pubca-private = NULL;
return ret;
 }
-- 
2.2.2

--
To unsubscribe from this list: send the line unsubscribe linux-media in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 1/2] [media] DVB: Delete an unnecessary check before the function call dvb_unregister_device

2015-02-03 Thread SF Markus Elfring
From: Markus Elfring elfr...@users.sourceforge.net
Date: Tue, 3 Feb 2015 16:01:40 +0100

The dvb_unregister_device() function tests whether its argument is NULL
and then returns immediately. Thus the test around the call is not needed.

This issue was detected by using the Coccinelle software.

Signed-off-by: Markus Elfring elfr...@users.sourceforge.net
---
 drivers/media/dvb-core/dvb_ca_en50221.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/drivers/media/dvb-core/dvb_ca_en50221.c 
b/drivers/media/dvb-core/dvb_ca_en50221.c
index 0aac309..b999689 100644
--- a/drivers/media/dvb-core/dvb_ca_en50221.c
+++ b/drivers/media/dvb-core/dvb_ca_en50221.c
@@ -1726,8 +1726,7 @@ int dvb_ca_en50221_init(struct dvb_adapter *dvb_adapter,
 
 error:
if (ca != NULL) {
-   if (ca-dvbdev != NULL)
-   dvb_unregister_device(ca-dvbdev);
+   dvb_unregister_device(ca-dvbdev);
kfree(ca-slot_info);
kfree(ca);
}
-- 
2.2.2

--
To unsubscribe from this list: send the line unsubscribe linux-media in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH] [media] sp2: Delete an unnecessary check before the function call kfree

2015-02-03 Thread SF Markus Elfring
From: Markus Elfring elfr...@users.sourceforge.net
Date: Tue, 3 Feb 2015 15:05:26 +0100

The kfree() function tests whether its argument is NULL and then
returns immediately. Thus the test around the call is not needed.

This issue was detected by using the Coccinelle software.

Signed-off-by: Markus Elfring elfr...@users.sourceforge.net
---
 drivers/media/dvb-frontends/sp2.c | 5 +
 1 file changed, 1 insertion(+), 4 deletions(-)

diff --git a/drivers/media/dvb-frontends/sp2.c 
b/drivers/media/dvb-frontends/sp2.c
index cc1ef96..8fd4276 100644
--- a/drivers/media/dvb-frontends/sp2.c
+++ b/drivers/media/dvb-frontends/sp2.c
@@ -413,11 +413,8 @@ static int sp2_remove(struct i2c_client *client)
struct sp2 *s = i2c_get_clientdata(client);
 
dev_dbg(client-dev, \n);
-
sp2_exit(client);
-   if (s != NULL)
-   kfree(s);
-
+   kfree(s);
return 0;
 }
 
-- 
2.2.2

--
To unsubscribe from this list: send the line unsubscribe linux-media in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH] [media] stk-webcam: Delete an unnecessary check before the function call vfree

2015-02-03 Thread SF Markus Elfring
From: Markus Elfring elfr...@users.sourceforge.net
Date: Tue, 3 Feb 2015 18:36:35 +0100

The vfree() function performs also input parameter validation.
Thus the test around the call is not needed.

This issue was detected by using the Coccinelle software.

Signed-off-by: Markus Elfring elfr...@users.sourceforge.net
---
 drivers/media/usb/stkwebcam/stk-webcam.c | 6 ++
 1 file changed, 2 insertions(+), 4 deletions(-)

diff --git a/drivers/media/usb/stkwebcam/stk-webcam.c 
b/drivers/media/usb/stkwebcam/stk-webcam.c
index 3588dc3..3686c4e 100644
--- a/drivers/media/usb/stkwebcam/stk-webcam.c
+++ b/drivers/media/usb/stkwebcam/stk-webcam.c
@@ -556,10 +556,8 @@ static int stk_free_sio_buffers(struct stk_camera *dev)
nbufs = dev-n_sbufs;
dev-n_sbufs = 0;
spin_unlock_irqrestore(dev-spinlock, flags);
-   for (i = 0; i  nbufs; i++) {
-   if (dev-sio_bufs[i].buffer != NULL)
-   vfree(dev-sio_bufs[i].buffer);
-   }
+   for (i = 0; i  nbufs; i++)
+   vfree(dev-sio_bufs[i].buffer);
kfree(dev-sio_bufs);
dev-sio_bufs = NULL;
return 0;
-- 
2.2.2

--
To unsubscribe from this list: send the line unsubscribe linux-media in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH] [media] au0828: Delete unnecessary checks before the function call video_unregister_device

2015-02-03 Thread SF Markus Elfring
From: Markus Elfring elfr...@users.sourceforge.net
Date: Tue, 3 Feb 2015 19:00:25 +0100

The video_unregister_device() function tests whether its argument is NULL
and then returns immediately. Thus the test around the call is not needed.

This issue was detected by using the Coccinelle software.

Signed-off-by: Markus Elfring elfr...@users.sourceforge.net
---
 drivers/media/usb/au0828/au0828-video.c | 8 ++--
 1 file changed, 2 insertions(+), 6 deletions(-)

diff --git a/drivers/media/usb/au0828/au0828-video.c 
b/drivers/media/usb/au0828/au0828-video.c
index 5f337b1..e593fb5 100644
--- a/drivers/media/usb/au0828/au0828-video.c
+++ b/drivers/media/usb/au0828/au0828-video.c
@@ -870,12 +870,8 @@ void au0828_analog_unregister(struct au0828_dev *dev)
 {
dprintk(1, au0828_release_resources called\n);
mutex_lock(au0828_sysfs_lock);
-
-   if (dev-vdev)
-   video_unregister_device(dev-vdev);
-   if (dev-vbi_dev)
-   video_unregister_device(dev-vbi_dev);
-
+   video_unregister_device(dev-vdev);
+   video_unregister_device(dev-vbi_dev);
mutex_unlock(au0828_sysfs_lock);
 }
 
-- 
2.2.2

--
To unsubscribe from this list: send the line unsubscribe linux-media in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 2/2] [media] mn88472: One function call less in mn88472_init() after error detection

2015-02-01 Thread SF Markus Elfring
From: Markus Elfring elfr...@users.sourceforge.net
Date: Sun, 1 Feb 2015 19:34:37 +0100

The release_firmware() function was called in three cases by the mn88472_init()
function during error handling even if the passed variable fw contained still
a null pointer.

This implementation detail could be improved by the introduction of another
jump label.

Signed-off-by: Markus Elfring elfr...@users.sourceforge.net
---
 drivers/staging/media/mn88472/mn88472.c | 10 +-
 1 file changed, 5 insertions(+), 5 deletions(-)

diff --git a/drivers/staging/media/mn88472/mn88472.c 
b/drivers/staging/media/mn88472/mn88472.c
index e7874ae..3975a57 100644
--- a/drivers/staging/media/mn88472/mn88472.c
+++ b/drivers/staging/media/mn88472/mn88472.c
@@ -286,7 +286,7 @@ static int mn88472_init(struct dvb_frontend *fe)
 
ret = regmap_write(dev-regmap[0], 0xf5, 0x03);
if (ret)
-   goto err;
+   goto firmware_release;
 
for (remaining = fw-size; remaining  0;
remaining -= (dev-i2c_wr_max - 1)) {
@@ -299,13 +299,13 @@ static int mn88472_init(struct dvb_frontend *fe)
if (ret) {
dev_err(client-dev,
firmware download failed=%d\n, ret);
-   goto err;
+   goto firmware_release;
}
}
 
ret = regmap_write(dev-regmap[0], 0xf5, 0x00);
if (ret)
-   goto err;
+   goto firmware_release;
 
release_firmware(fw);
fw = NULL;
@@ -314,9 +314,9 @@ static int mn88472_init(struct dvb_frontend *fe)
dev-warm = true;
 
return 0;
-err:
+firmware_release:
release_firmware(fw);
-
+err:
dev_dbg(client-dev, failed=%d\n, ret);
return ret;
 }
-- 
2.2.2

--
To unsubscribe from this list: send the line unsubscribe linux-media in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 1/2] [media] mn88472: Deletion of an unnecessary check before the function call release_firmware

2015-02-01 Thread SF Markus Elfring
From: Markus Elfring elfr...@users.sourceforge.net
Date: Sun, 1 Feb 2015 19:12:56 +0100

The release_firmware() function tests whether its argument is NULL and then
returns immediately. Thus the test around the call is not needed.

This issue was detected by using the Coccinelle software.

Signed-off-by: Markus Elfring elfr...@users.sourceforge.net
---
 drivers/staging/media/mn88472/mn88472.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/drivers/staging/media/mn88472/mn88472.c 
b/drivers/staging/media/mn88472/mn88472.c
index 52de8f8..e7874ae 100644
--- a/drivers/staging/media/mn88472/mn88472.c
+++ b/drivers/staging/media/mn88472/mn88472.c
@@ -315,8 +315,7 @@ static int mn88472_init(struct dvb_frontend *fe)
 
return 0;
 err:
-   if (fw)
-   release_firmware(fw);
+   release_firmware(fw);
 
dev_dbg(client-dev, failed=%d\n, ret);
return ret;
-- 
2.2.2

--
To unsubscribe from this list: send the line unsubscribe linux-media in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 0/2] [media] mn88472: Delete an unnecessary check

2015-02-01 Thread SF Markus Elfring
From: Markus Elfring elfr...@users.sourceforge.net
Date: Sun, 1 Feb 2015 20:00:17 +0100

Another update suggestion was taken into account after a patch was applied
from static source code analysis.

Markus Elfring (2):
  Deletion of an unnecessary check before the function call release_firmware
  One function call less in mn88472_init() after error detection

 drivers/staging/media/mn88472/mn88472.c | 11 +--
 1 file changed, 5 insertions(+), 6 deletions(-)

-- 
2.2.2

--
To unsubscribe from this list: send the line unsubscribe linux-media in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 0/2] [media] c8sectpfe: Deletion of a few unnecessary checks

2015-11-05 Thread SF Markus Elfring
From: Markus Elfring 
Date: Thu, 5 Nov 2015 19:39:32 +0100

Another update suggestion was taken into account after a patch was applied
from static source code analysis.

Markus Elfring (2):
  Delete unnecessary checks before two function calls
  Combine three checks into a single if block

 drivers/media/platform/sti/c8sectpfe/c8sectpfe-common.c | 16 
 1 file changed, 8 insertions(+), 8 deletions(-)

-- 
2.6.2

--
To unsubscribe from this list: send the line "unsubscribe linux-media" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 1/2] [media] c8sectpfe: Delete unnecessary checks before two function calls

2015-11-05 Thread SF Markus Elfring
From: Markus Elfring 
Date: Thu, 5 Nov 2015 18:55:19 +0100

The functions i2c_put_adapter() and module_put() test whether their
argument is NULL and then return immediately.
Thus the tests around their calls are not needed.

This issue was detected by using the Coccinelle software.

Signed-off-by: Markus Elfring 
---
 drivers/media/platform/sti/c8sectpfe/c8sectpfe-common.c | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)

diff --git a/drivers/media/platform/sti/c8sectpfe/c8sectpfe-common.c 
b/drivers/media/platform/sti/c8sectpfe/c8sectpfe-common.c
index 95223ab..07fd6d9 100644
--- a/drivers/media/platform/sti/c8sectpfe/c8sectpfe-common.c
+++ b/drivers/media/platform/sti/c8sectpfe/c8sectpfe-common.c
@@ -214,12 +214,11 @@ void c8sectpfe_tuner_unregister_frontend(struct c8sectpfe 
*c8sectpfe,
dvb_frontend_detach(tsin->frontend);
}
 
-   if (tsin && tsin->i2c_adapter)
+   if (tsin)
i2c_put_adapter(tsin->i2c_adapter);
 
if (tsin && tsin->i2c_client) {
-   if (tsin->i2c_client->dev.driver->owner)
-   module_put(tsin->i2c_client->dev.driver->owner);
+   module_put(tsin->i2c_client->dev.driver->owner);
i2c_unregister_device(tsin->i2c_client);
}
}
-- 
2.6.2

--
To unsubscribe from this list: send the line "unsubscribe linux-media" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 2/2] [media] c8sectpfe: Combine three checks into a single if block

2015-11-05 Thread SF Markus Elfring
From: Markus Elfring 
Date: Thu, 5 Nov 2015 19:23:50 +0100

The variable "tsin" was checked three times in a loop iteration of the
c8sectpfe_tuner_unregister_frontend() function.
This implementation detail could be improved by the combination of the
involved statements into a single if block so that this variable will be
checked only once there.

Signed-off-by: Markus Elfring 
---
 drivers/media/platform/sti/c8sectpfe/c8sectpfe-common.c | 17 +
 1 file changed, 9 insertions(+), 8 deletions(-)

diff --git a/drivers/media/platform/sti/c8sectpfe/c8sectpfe-common.c 
b/drivers/media/platform/sti/c8sectpfe/c8sectpfe-common.c
index 07fd6d9..2dfbe8a 100644
--- a/drivers/media/platform/sti/c8sectpfe/c8sectpfe-common.c
+++ b/drivers/media/platform/sti/c8sectpfe/c8sectpfe-common.c
@@ -209,17 +209,18 @@ void c8sectpfe_tuner_unregister_frontend(struct c8sectpfe 
*c8sectpfe,
 
tsin = fei->channel_data[n];
 
-   if (tsin && tsin->frontend) {
-   dvb_unregister_frontend(tsin->frontend);
-   dvb_frontend_detach(tsin->frontend);
-   }
+   if (tsin) {
+   if (tsin->frontend) {
+   dvb_unregister_frontend(tsin->frontend);
+   dvb_frontend_detach(tsin->frontend);
+   }
 
-   if (tsin)
i2c_put_adapter(tsin->i2c_adapter);
 
-   if (tsin && tsin->i2c_client) {
-   module_put(tsin->i2c_client->dev.driver->owner);
-   i2c_unregister_device(tsin->i2c_client);
+   if (tsin->i2c_client) {
+   module_put(tsin->i2c_client->dev.driver->owner);
+   i2c_unregister_device(tsin->i2c_client);
+   }
}
}
 
-- 
2.6.2

--
To unsubscribe from this list: send the line "unsubscribe linux-media" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [Cocci] [PATCH v2] coccinelle: api: check for propagation of error from platform_get_irq

2015-12-27 Thread SF Markus Elfring
>> https://cwe.mitre.org/data/definitions/252.html
> 
> The value is not unchecked.

Would you like to express any stronger relationship between
the function call example and the occurrence of an if statement
by the discussed SmPL script?


> I made a specific rule because the specific problem is quite common.

Can it become also interesting to generalise this search pattern?

Regards,
Markus
--
To unsubscribe from this list: send the line "unsubscribe linux-media" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[media] af9013: Checking for register accesses?

2015-12-27 Thread SF Markus Elfring
Hello,

I have looked at the implementations of functions like the following once more.
https://git.kernel.org/cgit/linux/kernel/git/next/linux-next.git/tree/drivers/media/dvb-frontends/af9013.c?id=80c75a0f1d81922bf322c0634d1e1a15825a89e6#n124
* af9013_rd_regs
* af9013_wr_regs

Both functions will always return zero so far. Should they eventually forward
an error code from other function calls?

Regards,
Markus
--
To unsubscribe from this list: send the line "unsubscribe linux-media" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH] [media] bttv: Returning only value constants in two functions

2015-12-27 Thread SF Markus Elfring
From: Markus Elfring 
Date: Sun, 27 Dec 2015 22:02:21 +0100

Return constant integer values without storing them in the local
variable "err" or "rc".

Signed-off-by: Markus Elfring 
---
 drivers/media/pci/bt8xx/bttv-driver.c | 25 ++---
 1 file changed, 6 insertions(+), 19 deletions(-)

diff --git a/drivers/media/pci/bt8xx/bttv-driver.c 
b/drivers/media/pci/bt8xx/bttv-driver.c
index 9400e99..cd7d6ef 100644
--- a/drivers/media/pci/bt8xx/bttv-driver.c
+++ b/drivers/media/pci/bt8xx/bttv-driver.c
@@ -1726,22 +1726,15 @@ static int bttv_s_std(struct file *file, void *priv, 
v4l2_std_id id)
struct bttv_fh *fh  = priv;
struct bttv *btv = fh->btv;
unsigned int i;
-   int err = 0;
 
for (i = 0; i < BTTV_TVNORMS; i++)
if (id & bttv_tvnorms[i].v4l2_id)
break;
-   if (i == BTTV_TVNORMS) {
-   err = -EINVAL;
-   goto err;
-   }
-
+   if (i == BTTV_TVNORMS)
+   return -EINVAL;
btv->std = id;
set_tvnorm(btv, i);
-
-err:
-
-   return err;
+   return 0;
 }
 
 static int bttv_g_std(struct file *file, void *priv, v4l2_std_id *id)
@@ -1770,12 +1763,9 @@ static int bttv_enum_input(struct file *file, void *priv,
 {
struct bttv_fh *fh = priv;
struct bttv *btv = fh->btv;
-   int rc = 0;
 
-   if (i->index >= bttv_tvcards[btv->c.type].video_inputs) {
-   rc = -EINVAL;
-   goto err;
-   }
+   if (i->index >= bttv_tvcards[btv->c.type].video_inputs)
+   return -EINVAL;
 
i->type = V4L2_INPUT_TYPE_CAMERA;
i->audioset = 0;
@@ -1799,10 +1789,7 @@ static int bttv_enum_input(struct file *file, void *priv,
}
 
i->std = BTTV_NORMS;
-
-err:
-
-   return rc;
+   return 0;
 }
 
 static int bttv_g_input(struct file *file, void *priv, unsigned int *i)
-- 
2.6.3

--
To unsubscribe from this list: send the line "unsubscribe linux-media" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH] [media] si2165: Refactoring for si2165_writereg_mask8()

2015-12-27 Thread SF Markus Elfring
From: Markus Elfring 
Date: Sun, 27 Dec 2015 18:23:57 +0100

This issue was detected by using the Coccinelle software.

1. Let us return directly if a call of the si2165_readreg8()
   function failed.

2. Reduce the scope for the local variables "ret" and "tmp" to one branch
   of an if statement.

3. Delete the jump label "err" then.

4. Return the value from a call of the si2165_writereg8() function
   without using an extra assignment for the variable "ret" at the end.

Signed-off-by: Markus Elfring 
---
 drivers/media/dvb-frontends/si2165.c | 14 +-
 1 file changed, 5 insertions(+), 9 deletions(-)

diff --git a/drivers/media/dvb-frontends/si2165.c 
b/drivers/media/dvb-frontends/si2165.c
index 2b93241..e8518ae 100644
--- a/drivers/media/dvb-frontends/si2165.c
+++ b/drivers/media/dvb-frontends/si2165.c
@@ -225,22 +225,18 @@ static int si2165_writereg32(struct si2165_state *state, 
const u16 reg, u32 val)
 static int si2165_writereg_mask8(struct si2165_state *state, const u16 reg,
 u8 val, u8 mask)
 {
-   int ret;
-   u8 tmp;
-
if (mask != 0xff) {
-   ret = si2165_readreg8(state, reg, );
+   u8 tmp;
+   int ret = si2165_readreg8(state, reg, );
+
if (ret < 0)
-   goto err;
+   return ret;
 
val &= mask;
tmp &= ~mask;
val |= tmp;
}
-
-   ret = si2165_writereg8(state, reg, val);
-err:
-   return ret;
+   return si2165_writereg8(state, reg, val);
 }
 
 #define REG16(reg, val) { (reg), (val) & 0xff }, { (reg)+1, (val)>>8 & 0xff }
-- 
2.6.3

--
To unsubscribe from this list: send the line "unsubscribe linux-media" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH] [media] au0828: Refactoring for start_urb_transfer()

2015-12-28 Thread SF Markus Elfring
From: Markus Elfring 
Date: Mon, 28 Dec 2015 22:52:48 +0100

This issue was detected by using the Coccinelle software.

1. Let us return directly if a buffer allocation failed.

2. Delete the jump label "err" then.

3. Drop the explicit initialisation for the variable "ret"
   at the beginning.

4. Return zero as a constant at the end.

Signed-off-by: Markus Elfring 
---
 drivers/media/usb/au0828/au0828-dvb.c | 12 +---
 1 file changed, 5 insertions(+), 7 deletions(-)

diff --git a/drivers/media/usb/au0828/au0828-dvb.c 
b/drivers/media/usb/au0828/au0828-dvb.c
index cd542b4..e5f1e20 100644
--- a/drivers/media/usb/au0828/au0828-dvb.c
+++ b/drivers/media/usb/au0828/au0828-dvb.c
@@ -181,7 +181,7 @@ static int stop_urb_transfer(struct au0828_dev *dev)
 static int start_urb_transfer(struct au0828_dev *dev)
 {
struct urb *purb;
-   int i, ret = -ENOMEM;
+   int i, ret;
 
dprintk(2, "%s()\n", __func__);
 
@@ -194,7 +194,7 @@ static int start_urb_transfer(struct au0828_dev *dev)
 
dev->urbs[i] = usb_alloc_urb(0, GFP_KERNEL);
if (!dev->urbs[i])
-   goto err;
+   return -ENOMEM;
 
purb = dev->urbs[i];
 
@@ -207,9 +207,10 @@ static int start_urb_transfer(struct au0828_dev *dev)
if (!purb->transfer_buffer) {
usb_free_urb(purb);
dev->urbs[i] = NULL;
+   ret = -ENOMEM;
pr_err("%s: failed big buffer allocation, err = %d\n",
   __func__, ret);
-   goto err;
+   return ret;
}
 
purb->status = -EINPROGRESS;
@@ -235,10 +236,7 @@ static int start_urb_transfer(struct au0828_dev *dev)
}
 
dev->urb_streaming = true;
-   ret = 0;
-
-err:
-   return ret;
+   return 0;
 }
 
 static void au0828_start_transport(struct au0828_dev *dev)
-- 
2.6.3

--
To unsubscribe from this list: send the line "unsubscribe linux-media" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [Cocci] [PATCH v2] coccinelle: api: check for propagation of error from platform_get_irq

2015-12-27 Thread SF Markus Elfring
> The error return value of platform_get_irq seems to often get dropped.

How do you think about any more fine-tuning here?

Commit message:
* … of the platform_get_irq() function seems to get dropped too often.

* Why do you concentrate on a single function name?
  Do you plan to extend this source code analysis approach?


> +@script:python r_report depends on report@
> +j0 << r.j0;
> +j1 << r.j1;
> +@@
> +
> +msg = "Propagate return value of platform_get_irq around line %s." % 
> (j1[0].line)

Are there more unchecked return values which are interesting
for further considerations?
https://cwe.mitre.org/data/definitions/252.html

Regards,
Markus
--
To unsubscribe from this list: send the line "unsubscribe linux-media" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [media] tuners: One check less in m88rs6000t_get_rf_strength() after error detection

2015-12-28 Thread SF Markus Elfring
>> Move the jump label directly before the desired log statement
>> so that the variable "ret" will not be checked once more
>> after it was determined that a function call failed.
> 
> Why not avoid both unnecessary ifs

I would find such a fine-tuning also nice in principle at more source code 
places.


> and the enormous ugliness of a label inside an if by making two returns:
> a return 0 for success and a dev_dbg and return ret for failure?

How should your suggestion finally work when the desired execution success
can be determined for such functions only after several other calls succeeded?

Is consistent checking of failure predicates usually required?

Regards,
Markus
--
To unsubscribe from this list: send the line "unsubscribe linux-media" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH] [media] tuners: One check less in m88rs6000t_get_rf_strength() after error detection

2015-12-28 Thread SF Markus Elfring
From: Markus Elfring 
Date: Mon, 28 Dec 2015 10:10:34 +0100

This issue was detected by using the Coccinelle software.

Move the jump label directly before the desired log statement
so that the variable "ret" will not be checked once more
after it was determined that a function call failed.

Signed-off-by: Markus Elfring 
---
 drivers/media/tuners/m88rs6000t.c | 16 +---
 1 file changed, 9 insertions(+), 7 deletions(-)

diff --git a/drivers/media/tuners/m88rs6000t.c 
b/drivers/media/tuners/m88rs6000t.c
index 504bfbc..b45594e 100644
--- a/drivers/media/tuners/m88rs6000t.c
+++ b/drivers/media/tuners/m88rs6000t.c
@@ -510,27 +510,27 @@ static int m88rs6000t_get_rf_strength(struct dvb_frontend 
*fe, u16 *strength)
 
ret = regmap_read(dev->regmap, 0x5A, );
if (ret)
-   goto err;
+   goto report_failure;
RF_GC = val & 0x0f;
 
ret = regmap_read(dev->regmap, 0x5F, );
if (ret)
-   goto err;
+   goto report_failure;
IF_GC = val & 0x0f;
 
ret = regmap_read(dev->regmap, 0x3F, );
if (ret)
-   goto err;
+   goto report_failure;
TIA_GC = (val >> 4) & 0x07;
 
ret = regmap_read(dev->regmap, 0x77, );
if (ret)
-   goto err;
+   goto report_failure;
BB_GC = (val >> 4) & 0x0f;
 
ret = regmap_read(dev->regmap, 0x76, );
if (ret)
-   goto err;
+   goto report_failure;
PGA2_GC = val & 0x3f;
PGA2_cri = PGA2_GC >> 2;
PGA2_crf = PGA2_GC & 0x03;
@@ -562,9 +562,11 @@ static int m88rs6000t_get_rf_strength(struct dvb_frontend 
*fe, u16 *strength)
/* scale value to 0x-0x */
gain = clamp_val(gain, 1000U, 10500U);
*strength = (10500 - gain) * 0x / (10500 - 1000);
-err:
-   if (ret)
+
+   if (ret) {
+report_failure:
dev_dbg(>client->dev, "failed=%d\n", ret);
+   }
return ret;
 }
 
-- 
2.6.3

--
To unsubscribe from this list: send the line "unsubscribe linux-media" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 1/2] [media] m88rs6000t: Better exception handling in five functions

2015-12-28 Thread SF Markus Elfring
From: Markus Elfring 
Date: Mon, 28 Dec 2015 15:10:30 +0100

This issue was detected by using the Coccinelle software.

Move the jump label directly before the desired log statement
so that the variable "ret" will not be checked once more
after a function call.
Use the identifier "report_failure" instead of "err".

Suggested-by: Julia Lawall 
Signed-off-by: Markus Elfring 
---
 drivers/media/tuners/m88rs6000t.c | 154 +++---
 1 file changed, 78 insertions(+), 76 deletions(-)

diff --git a/drivers/media/tuners/m88rs6000t.c 
b/drivers/media/tuners/m88rs6000t.c
index 504bfbc..7e59a9f 100644
--- a/drivers/media/tuners/m88rs6000t.c
+++ b/drivers/media/tuners/m88rs6000t.c
@@ -44,7 +44,7 @@ static int m88rs6000t_set_demod_mclk(struct dvb_frontend *fe)
/* select demod main mclk */
ret = regmap_read(dev->regmap, 0x15, );
if (ret)
-   goto err;
+   goto report_failure;
reg15 = utmp;
if (c->symbol_rate > 4501) {
reg11 = 0x0E;
@@ -106,7 +106,7 @@ static int m88rs6000t_set_demod_mclk(struct dvb_frontend 
*fe)
 
ret = regmap_read(dev->regmap, 0x1D, );
if (ret)
-   goto err;
+   goto report_failure;
reg1D = utmp;
reg1D &= ~0x03;
reg1D |= N - 1;
@@ -116,42 +116,42 @@ static int m88rs6000t_set_demod_mclk(struct dvb_frontend 
*fe)
/* program and recalibrate demod PLL */
ret = regmap_write(dev->regmap, 0x05, 0x40);
if (ret)
-   goto err;
+   goto report_failure;
ret = regmap_write(dev->regmap, 0x11, 0x08);
if (ret)
-   goto err;
+   goto report_failure;
ret = regmap_write(dev->regmap, 0x15, reg15);
if (ret)
-   goto err;
+   goto report_failure;
ret = regmap_write(dev->regmap, 0x16, reg16);
if (ret)
-   goto err;
+   goto report_failure;
ret = regmap_write(dev->regmap, 0x1D, reg1D);
if (ret)
-   goto err;
+   goto report_failure;
ret = regmap_write(dev->regmap, 0x1E, reg1E);
if (ret)
-   goto err;
+   goto report_failure;
ret = regmap_write(dev->regmap, 0x1F, reg1F);
if (ret)
-   goto err;
+   goto report_failure;
ret = regmap_write(dev->regmap, 0x17, 0xc1);
if (ret)
-   goto err;
+   goto report_failure;
ret = regmap_write(dev->regmap, 0x17, 0x81);
if (ret)
-   goto err;
+   goto report_failure;
usleep_range(5000, 5);
ret = regmap_write(dev->regmap, 0x05, 0x00);
if (ret)
-   goto err;
+   goto report_failure;
ret = regmap_write(dev->regmap, 0x11, reg11);
if (ret)
-   goto err;
+   goto report_failure;
usleep_range(5000, 5);
-err:
-   if (ret)
-   dev_dbg(>client->dev, "failed=%d\n", ret);
+   return 0;
+report_failure:
+   dev_dbg(>client->dev, "failed=%d\n", ret);
return ret;
 }
 
@@ -169,13 +169,13 @@ static int m88rs6000t_set_pll_freq(struct m88rs6000t_dev 
*dev,
 
ret = regmap_write(dev->regmap, 0x36, (refDiv - 8));
if (ret)
-   goto err;
+   goto report_failure;
ret = regmap_write(dev->regmap, 0x31, 0x00);
if (ret)
-   goto err;
+   goto report_failure;
ret = regmap_write(dev->regmap, 0x2c, 0x02);
if (ret)
-   goto err;
+   goto report_failure;
 
if (tuner_freq_MHz >= 1550) {
ucLoDiv1 = 2;
@@ -227,105 +227,105 @@ static int m88rs6000t_set_pll_freq(struct 
m88rs6000t_dev *dev,
reg27 = (((ulNDiv1 >> 8) & 0x0F) + ucLomod1) & 0x7F;
ret = regmap_write(dev->regmap, 0x27, reg27);
if (ret)
-   goto err;
+   goto report_failure;
ret = regmap_write(dev->regmap, 0x28, (u8)(ulNDiv1 & 0xFF));
if (ret)
-   goto err;
+   goto report_failure;
reg29 = (((ulNDiv2 >> 8) & 0x0F) + ucLomod2) & 0x7f;
ret = regmap_write(dev->regmap, 0x29, reg29);
if (ret)
-   goto err;
+   goto report_failure;
ret = regmap_write(dev->regmap, 0x2a, (u8)(ulNDiv2 & 0xFF));
if (ret)
-   goto err;
+   goto report_failure;
ret = regmap_write(dev->regmap, 0x2F, 0xf5);
if (ret)
-   goto err;
+   goto report_failure;
ret = regmap_write(dev->regmap, 0x30, 0x05);
if (ret)
-   goto err;
+   goto report_failure;
ret = regmap_write(dev->regmap, 0x08, 0x1f);
if (ret)
-   goto err;
+   

[media] r820t: Checking lock scopes around i2c_gate_ctrl() calls?

2015-12-28 Thread SF Markus Elfring
Hello,

I have looked at the implementation of the function "r820t_signal" once more.
https://git.kernel.org/cgit/linux/kernel/git/next/linux-next.git/tree/drivers/media/tuners/r820t.c?id=80c75a0f1d81922bf322c0634d1e1a15825a89e6#n2242

The function which was assigned to the pointer "i2c_gate_ctrl" from
the variable "fe" (data structure "dvb_frontend") is called after a mutex
was locked. Would it make sense to reconsider the size of this lock scope?

Regards,
Markus
--
To unsubscribe from this list: send the line "unsubscribe linux-media" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 2/2] [media] tuners: Refactoring for m88rs6000t_sleep()

2015-12-28 Thread SF Markus Elfring
From: Markus Elfring 
Date: Mon, 28 Dec 2015 15:20:45 +0100

This issue was detected by using the Coccinelle software.

1. Let us return directly if a call of the regmap_write() function failed.

2. Delete the jump label "err" then.

3. Return zero as a constant at the end.

Signed-off-by: Markus Elfring 
---
 drivers/media/tuners/m88rs6000t.c | 11 +--
 1 file changed, 5 insertions(+), 6 deletions(-)

diff --git a/drivers/media/tuners/m88rs6000t.c 
b/drivers/media/tuners/m88rs6000t.c
index 7e59a9f..8d10798 100644
--- a/drivers/media/tuners/m88rs6000t.c
+++ b/drivers/media/tuners/m88rs6000t.c
@@ -463,13 +463,12 @@ static int m88rs6000t_sleep(struct dvb_frontend *fe)
dev_dbg(>client->dev, "%s:\n", __func__);
 
ret = regmap_write(dev->regmap, 0x07, 0x6d);
-   if (ret)
-   goto err;
-   usleep_range(5000, 1);
-err:
-   if (ret)
+   if (ret) {
dev_dbg(>client->dev, "failed=%d\n", ret);
-   return ret;
+   return ret;
+   }
+   usleep_range(5000, 1);
+   return 0;
 }
 
 static int m88rs6000t_get_frequency(struct dvb_frontend *fe, u32 *frequency)
-- 
2.6.3

--
To unsubscribe from this list: send the line "unsubscribe linux-media" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 0/2] [media] m88rs6000t: Fine-tuning for some function implementations

2015-12-28 Thread SF Markus Elfring
From: Markus Elfring 
Date: Mon, 28 Dec 2015 15:32:20 +0100

A few update suggestions were taken into account
from static source code analysis.

Markus Elfring (2):
  Better exception handling in five functions
  Refactoring for m88rs6000t_sleep()

 drivers/media/tuners/m88rs6000t.c | 165 +++---
 1 file changed, 83 insertions(+), 82 deletions(-)

-- 
2.6.3

--
To unsubscribe from this list: send the line "unsubscribe linux-media" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [media] m88rs6000t: Better exception handling in five functions

2015-12-28 Thread SF Markus Elfring
>> Move the jump label directly before the desired log statement
>> so that the variable "ret" will not be checked once more
>> after a function call.
> 
> This commit message fits with the previous change.

Do you prefer an other wording?


> It could be nice to put a blank line before the error handling code.

Is it really a coding style requirement to insert another blank line between
the suggested placement of the statement "return 0;" and the jump label?

Regards,
Markus
--
To unsubscribe from this list: send the line "unsubscribe linux-media" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 1/2] [media] r820t: Delete an unnecessary variable initialisation in generic_set_freq()

2015-12-28 Thread SF Markus Elfring
From: Markus Elfring 
Date: Mon, 28 Dec 2015 16:36:44 +0100

The variable "rc" will be set to an appropriate value from a call of
the r820t_set_tv_standard() function.
Thus let us omit the explicit initialisation at the beginning.

Signed-off-by: Markus Elfring 
---
 drivers/media/tuners/r820t.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/media/tuners/r820t.c b/drivers/media/tuners/r820t.c
index a7a8452..6ab35e3 100644
--- a/drivers/media/tuners/r820t.c
+++ b/drivers/media/tuners/r820t.c
@@ -1295,7 +1295,7 @@ static int generic_set_freq(struct dvb_frontend *fe,
v4l2_std_id std, u32 delsys)
 {
struct r820t_priv   *priv = fe->tuner_priv;
-   int rc = -EINVAL;
+   int rc;
u32 lo_freq;
 
tuner_dbg("should set frequency to %d kHz, bw %d MHz\n",
-- 
2.6.3

--
To unsubscribe from this list: send the line "unsubscribe linux-media" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 2/2] [media] r820t: Better exception handling in generic_set_freq()

2015-12-28 Thread SF Markus Elfring
From: Markus Elfring 
Date: Mon, 28 Dec 2015 17:13:02 +0100

This issue was detected by using the Coccinelle software.

Move the jump label directly before the desired log statement
so that the variable "rc" will not be checked once more
after a function call.
Use the identifier "report_failure" instead of "err".

The error logging is performed in a separate section at the end now.

Signed-off-by: Markus Elfring 
---
 drivers/media/tuners/r820t.c | 16 +++-
 1 file changed, 7 insertions(+), 9 deletions(-)

diff --git a/drivers/media/tuners/r820t.c b/drivers/media/tuners/r820t.c
index 6ab35e3..f71642e 100644
--- a/drivers/media/tuners/r820t.c
+++ b/drivers/media/tuners/r820t.c
@@ -1303,7 +1303,7 @@ static int generic_set_freq(struct dvb_frontend *fe,
 
rc = r820t_set_tv_standard(priv, bw, type, std, delsys);
if (rc < 0)
-   goto err;
+   goto report_failure;
 
if ((type == V4L2_TUNER_ANALOG_TV) && (std == V4L2_STD_SECAM_LC))
lo_freq = freq - priv->int_freq;
@@ -1312,23 +1312,21 @@ static int generic_set_freq(struct dvb_frontend *fe,
 
rc = r820t_set_mux(priv, lo_freq);
if (rc < 0)
-   goto err;
+   goto report_failure;
 
rc = r820t_set_pll(priv, type, lo_freq);
if (rc < 0 || !priv->has_lock)
-   goto err;
+   goto report_failure;
 
rc = r820t_sysfreq_sel(priv, freq, type, std, delsys);
if (rc < 0)
-   goto err;
+   goto report_failure;
 
tuner_dbg("%s: PLL locked on frequency %d Hz, gain=%d\n",
  __func__, freq, r820t_read_gain(priv));
-
-err:
-
-   if (rc < 0)
-   tuner_dbg("%s: failed=%d\n", __func__, rc);
+   return 0;
+report_failure:
+   tuner_dbg("%s: failed=%d\n", __func__, rc);
return rc;
 }
 
-- 
2.6.3

--
To unsubscribe from this list: send the line "unsubscribe linux-media" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 0/2] [media] r820t: Fine-tuning for generic_set_freq()

2015-12-28 Thread SF Markus Elfring
From: Markus Elfring 
Date: Mon, 28 Dec 2015 17:18:34 +0100

A few update suggestions were taken into account
from static source code analysis.

Markus Elfring (2):
  Delete an unnecessary variable initialisation
  Better exception handling

 drivers/media/tuners/r820t.c | 18 --
 1 file changed, 8 insertions(+), 10 deletions(-)

-- 
2.6.3

--
To unsubscribe from this list: send the line "unsubscribe linux-media" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH] [media] airspy: Better exception handling in two functions

2015-12-28 Thread SF Markus Elfring
From: Markus Elfring 
Date: Mon, 28 Dec 2015 22:10:28 +0100

This issue was detected by using the Coccinelle software.

Move the jump label directly before the desired log statement
so that the variable "ret" will not be checked once more
after a function call.
Use the identifier "report_failure" instead of "err".

The error logging is performed in a separate section at the end now.

Signed-off-by: Markus Elfring 
---
 drivers/media/usb/airspy/airspy.c | 22 ++
 1 file changed, 10 insertions(+), 12 deletions(-)

diff --git a/drivers/media/usb/airspy/airspy.c 
b/drivers/media/usb/airspy/airspy.c
index 0d4ac59..cf2444a 100644
--- a/drivers/media/usb/airspy/airspy.c
+++ b/drivers/media/usb/airspy/airspy.c
@@ -889,18 +889,17 @@ static int airspy_set_lna_gain(struct airspy *s)
ret = airspy_ctrl_msg(s, CMD_SET_LNA_AGC, 0, s->lna_gain_auto->val,
, 1);
if (ret)
-   goto err;
+   goto report_failure;
 
if (s->lna_gain_auto->val == false) {
ret = airspy_ctrl_msg(s, CMD_SET_LNA_GAIN, 0, s->lna_gain->val,
, 1);
if (ret)
-   goto err;
+   goto report_failure;
}
-err:
-   if (ret)
-   dev_dbg(s->dev, "failed=%d\n", ret);
-
+   return 0;
+report_failure:
+   dev_dbg(s->dev, "failed=%d\n", ret);
return ret;
 }
 
@@ -916,18 +915,17 @@ static int airspy_set_mixer_gain(struct airspy *s)
ret = airspy_ctrl_msg(s, CMD_SET_MIXER_AGC, 0, s->mixer_gain_auto->val,
, 1);
if (ret)
-   goto err;
+   goto report_failure;
 
if (s->mixer_gain_auto->val == false) {
ret = airspy_ctrl_msg(s, CMD_SET_MIXER_GAIN, 0,
s->mixer_gain->val, , 1);
if (ret)
-   goto err;
+   goto report_failure;
}
-err:
-   if (ret)
-   dev_dbg(s->dev, "failed=%d\n", ret);
-
+   return 0;
+report_failure:
+   dev_dbg(s->dev, "failed=%d\n", ret);
return ret;
 }
 
-- 
2.6.3

--
To unsubscribe from this list: send the line "unsubscribe linux-media" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH] [media] xc5000: Faster result reporting in xc_load_fw_and_init_tuner()

2015-12-28 Thread SF Markus Elfring
From: Markus Elfring 
Date: Mon, 28 Dec 2015 20:10:30 +0100

This issue was detected by using the Coccinelle software.

Split the previous if statement at the end so that each final log statement
will eventually be performed by a direct jump to these labels.
* report_failure
* report_success

A check repetition can be excluded for the variable "ret" at the end then.


Apply also two recommendations from the script "checkpatch.pl".

Signed-off-by: Markus Elfring 
---
 drivers/media/tuners/xc5000.c | 16 +++-
 1 file changed, 7 insertions(+), 9 deletions(-)

diff --git a/drivers/media/tuners/xc5000.c b/drivers/media/tuners/xc5000.c
index e6e5e90..1360677 100644
--- a/drivers/media/tuners/xc5000.c
+++ b/drivers/media/tuners/xc5000.c
@@ -1166,7 +1166,7 @@ static int xc_load_fw_and_init_tuner(struct dvb_frontend 
*fe, int force)
 
ret = xc5000_fwupload(fe, desired_fw, fw);
if (ret != 0)
-   goto err;
+   goto report_failure;
 
msleep(20);
 
@@ -1229,18 +1229,16 @@ static int xc_load_fw_and_init_tuner(struct 
dvb_frontend *fe, int force)
/* Default to "CABLE" mode */
ret = xc_write_reg(priv, XREG_SIGNALSOURCE, XC_RF_MODE_CABLE);
if (!ret)
-   break;
+   goto report_success;
printk(KERN_ERR "xc5000: can't set to cable mode.");
}
 
-err:
-   if (!ret)
-   printk(KERN_INFO "xc5000: Firmware %s loaded and running.\n",
-  desired_fw->name);
-   else
-   printk(KERN_CONT " - too many retries. Giving up\n");
-
+report_failure:
+   pr_cont(" - too many retries. Giving up\n");
return ret;
+report_success:
+   pr_info("xc5000: Firmware %s loaded and running.\n", desired_fw->name);
+   return 0;
 }
 
 static void xc5000_do_timer_sleep(struct work_struct *timer_sleep)
-- 
2.6.3

--
To unsubscribe from this list: send the line "unsubscribe linux-media" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH] [media] gsc-m2m: Use an unsigned data type for a variable

2015-12-19 Thread SF Markus Elfring
From: Markus Elfring 
Date: Sat, 19 Dec 2015 15:28:37 +0100

The data type "int" was used by the variable "ret" in the
gsc_m2m_poll() function despite of the aspect that the type "unsigned int"
will usually be needed for the return value from a call of the
v4l2_m2m_poll() function.
Improve this implementation detail by addition of the type modifier then.

This issue was detected by using the Coccinelle software.

Signed-off-by: Markus Elfring 
---
 drivers/media/platform/exynos-gsc/gsc-m2m.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/media/platform/exynos-gsc/gsc-m2m.c 
b/drivers/media/platform/exynos-gsc/gsc-m2m.c
index d82e717..f2c091c 100644
--- a/drivers/media/platform/exynos-gsc/gsc-m2m.c
+++ b/drivers/media/platform/exynos-gsc/gsc-m2m.c
@@ -701,7 +701,7 @@ static unsigned int gsc_m2m_poll(struct file *file,
 {
struct gsc_ctx *ctx = fh_to_ctx(file->private_data);
struct gsc_dev *gsc = ctx->gsc_dev;
-   int ret;
+   unsigned int ret;
 
if (mutex_lock_interruptible(>lock))
return -ERESTARTSYS;
-- 
2.6.3

--
To unsubscribe from this list: send the line "unsubscribe linux-media" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[media] anysee: Checking failure reporting

2015-12-29 Thread SF Markus Elfring
Hello,

I have looked at the implementation of the function "anysee_del_i2c_dev" once 
more.
https://git.kernel.org/cgit/linux/kernel/git/next/linux-next.git/tree/drivers/media/usb/dvb-usb-v2/anysee.c?id=80c75a0f1d81922bf322c0634d1e1a15825a89e6#n685

Is it really appropriate to end this one with the message "failed"?
Would it be useful to move such a log statement a bit?

Regards,
Markus
--
To unsubscribe from this list: send the line "unsubscribe linux-media" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH] [media] msi2500: Delete an unnecessary check in msi2500_set_usb_adc()

2015-12-29 Thread SF Markus Elfring
From: Markus Elfring 
Date: Tue, 29 Dec 2015 12:32:41 +0100

This issue was detected by using the Coccinelle software.

Return the value from a call of the msi2500_ctrl_msg() function
without using an extra check for the variable "ret" at the end.

Signed-off-by: Markus Elfring 
---
 drivers/media/usb/msi2500/msi2500.c | 2 --
 1 file changed, 2 deletions(-)

diff --git a/drivers/media/usb/msi2500/msi2500.c 
b/drivers/media/usb/msi2500/msi2500.c
index c104315..2d33033 100644
--- a/drivers/media/usb/msi2500/msi2500.c
+++ b/drivers/media/usb/msi2500/msi2500.c
@@ -839,8 +839,6 @@ static int msi2500_set_usb_adc(struct msi2500_dev *dev)
goto err;
 
ret = msi2500_ctrl_msg(dev, CMD_WREG, reg3);
-   if (ret)
-   goto err;
 err:
return ret;
 }
-- 
2.6.3

--
To unsubscribe from this list: send the line "unsubscribe linux-media" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH] [media] hdpvr: Refactoring for hdpvr_read()

2015-12-29 Thread SF Markus Elfring
From: Markus Elfring 
Date: Tue, 29 Dec 2015 11:02:43 +0100

Let us return directly if the element "status" of the variable "buf"
indicates "BUFSTAT_READY".
A check repetition can be excluded for the variable "ret" at the end then.

Signed-off-by: Markus Elfring 
---
 drivers/media/usb/hdpvr/hdpvr-video.c | 6 ++
 1 file changed, 2 insertions(+), 4 deletions(-)

diff --git a/drivers/media/usb/hdpvr/hdpvr-video.c 
b/drivers/media/usb/hdpvr/hdpvr-video.c
index 7dee22d..ba7f022 100644
--- a/drivers/media/usb/hdpvr/hdpvr-video.c
+++ b/drivers/media/usb/hdpvr/hdpvr-video.c
@@ -462,10 +462,8 @@ static ssize_t hdpvr_read(struct file *file, char __user 
*buffer, size_t count,
}
 
if (wait_event_interruptible(dev->wait_data,
- buf->status == BUFSTAT_READY)) {
-   ret = -ERESTARTSYS;
-   goto err;
-   }
+ buf->status == BUFSTAT_READY))
+   return -ERESTARTSYS;
}
 
if (buf->status != BUFSTAT_READY)
-- 
2.6.3

--
To unsubscribe from this list: send the line "unsubscribe linux-media" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH] media/i2c: Delete owner assignment

2016-08-14 Thread SF Markus Elfring
From: Markus Elfring 
Date: Sun, 14 Aug 2016 22:20:26 +0200

The field "owner" is set by core. Thus delete an extra initialisation.

Generated by: scripts/coccinelle/api/platform_no_drv_owner.cocci
Signed-off-by: Markus Elfring 
---
 drivers/media/i2c/ad9389b.c  | 1 -
 drivers/media/i2c/adv7183.c  | 1 -
 drivers/media/i2c/adv7393.c  | 1 -
 drivers/media/i2c/cs3308.c   | 1 -
 drivers/media/i2c/s5k4ecgx.c | 1 -
 drivers/media/i2c/s5k6a3.c   | 1 -
 drivers/media/i2c/ths8200.c  | 1 -
 drivers/media/i2c/tlv320aic23b.c | 1 -
 drivers/media/i2c/tvp514x.c  | 1 -
 drivers/media/i2c/tvp7002.c  | 1 -
 drivers/media/i2c/vs6624.c   | 1 -
 11 files changed, 11 deletions(-)

diff --git a/drivers/media/i2c/ad9389b.c b/drivers/media/i2c/ad9389b.c
index 0462f46..5a932e4 100644
--- a/drivers/media/i2c/ad9389b.c
+++ b/drivers/media/i2c/ad9389b.c
@@ -1231,7 +1231,6 @@ MODULE_DEVICE_TABLE(i2c, ad9389b_id);
 
 static struct i2c_driver ad9389b_driver = {
.driver = {
-   .owner = THIS_MODULE,
.name = "ad9389b",
},
.probe = ad9389b_probe,
diff --git a/drivers/media/i2c/adv7183.c b/drivers/media/i2c/adv7183.c
index 2bec737..04eecda 100644
--- a/drivers/media/i2c/adv7183.c
+++ b/drivers/media/i2c/adv7183.c
@@ -644,7 +644,6 @@ MODULE_DEVICE_TABLE(i2c, adv7183_id);
 
 static struct i2c_driver adv7183_driver = {
.driver = {
-   .owner  = THIS_MODULE,
.name   = "adv7183",
},
.probe  = adv7183_probe,
diff --git a/drivers/media/i2c/adv7393.c b/drivers/media/i2c/adv7393.c
index 76d9874..f19ad4e 100644
--- a/drivers/media/i2c/adv7393.c
+++ b/drivers/media/i2c/adv7393.c
@@ -456,7 +456,6 @@ MODULE_DEVICE_TABLE(i2c, adv7393_id);
 
 static struct i2c_driver adv7393_driver = {
.driver = {
-   .owner  = THIS_MODULE,
.name   = "adv7393",
},
.probe  = adv7393_probe,
diff --git a/drivers/media/i2c/cs3308.c b/drivers/media/i2c/cs3308.c
index d28b4f3..7da5f69 100644
--- a/drivers/media/i2c/cs3308.c
+++ b/drivers/media/i2c/cs3308.c
@@ -127,7 +127,6 @@ MODULE_DEVICE_TABLE(i2c, cs3308_id);
 
 static struct i2c_driver cs3308_driver = {
.driver = {
-   .owner  = THIS_MODULE,
.name   = "cs3308",
},
.probe  = cs3308_probe,
diff --git a/drivers/media/i2c/s5k4ecgx.c b/drivers/media/i2c/s5k4ecgx.c
index 8a0f22d..6ebcf25 100644
--- a/drivers/media/i2c/s5k4ecgx.c
+++ b/drivers/media/i2c/s5k4ecgx.c
@@ -1019,7 +1019,6 @@ MODULE_DEVICE_TABLE(i2c, s5k4ecgx_id);
 
 static struct i2c_driver v4l2_i2c_driver = {
.driver = {
-   .owner  = THIS_MODULE,
.name = S5K4ECGX_DRIVER_NAME,
},
.probe = s5k4ecgx_probe,
diff --git a/drivers/media/i2c/s5k6a3.c b/drivers/media/i2c/s5k6a3.c
index cbe4711..b1ecb44 100644
--- a/drivers/media/i2c/s5k6a3.c
+++ b/drivers/media/i2c/s5k6a3.c
@@ -376,7 +376,6 @@ static struct i2c_driver s5k6a3_driver = {
.driver = {
.of_match_table = of_match_ptr(s5k6a3_of_match),
.name   = S5K6A3_DRV_NAME,
-   .owner  = THIS_MODULE,
},
.probe  = s5k6a3_probe,
.remove = s5k6a3_remove,
diff --git a/drivers/media/i2c/ths8200.c b/drivers/media/i2c/ths8200.c
index 73fc42b..42340e3 100644
--- a/drivers/media/i2c/ths8200.c
+++ b/drivers/media/i2c/ths8200.c
@@ -499,7 +499,6 @@ MODULE_DEVICE_TABLE(of, ths8200_of_match);
 
 static struct i2c_driver ths8200_driver = {
.driver = {
-   .owner = THIS_MODULE,
.name = "ths8200",
.of_match_table = of_match_ptr(ths8200_of_match),
},
diff --git a/drivers/media/i2c/tlv320aic23b.c b/drivers/media/i2c/tlv320aic23b.c
index 0370dd8..2e06c06 100644
--- a/drivers/media/i2c/tlv320aic23b.c
+++ b/drivers/media/i2c/tlv320aic23b.c
@@ -210,7 +210,6 @@ MODULE_DEVICE_TABLE(i2c, tlv320aic23b_id);
 
 static struct i2c_driver tlv320aic23b_driver = {
.driver = {
-   .owner  = THIS_MODULE,
.name   = "tlv320aic23b",
},
.probe  = tlv320aic23b_probe,
diff --git a/drivers/media/i2c/tvp514x.c b/drivers/media/i2c/tvp514x.c
index 7cdd948..7cf749f 100644
--- a/drivers/media/i2c/tvp514x.c
+++ b/drivers/media/i2c/tvp514x.c
@@ -1233,7 +1233,6 @@ MODULE_DEVICE_TABLE(of, tvp514x_of_match);
 static struct i2c_driver tvp514x_driver = {
.driver = {
.of_match_table = of_match_ptr(tvp514x_of_match),
-   .owner = THIS_MODULE,
.name = TVP514X_MODULE_NAME,
},
.probe = tvp514x_probe,
diff --git a/drivers/media/i2c/tvp7002.c b/drivers/media/i2c/tvp7002.c
index 4df640c..3dc3341 100644
--- a/drivers/media/i2c/tvp7002.c
+++ b/drivers/media/i2c/tvp7002.c
@@ -1086,7 +1086,6 @@ MODULE_DEVICE_TABLE(of, 

[PATCH] [media] radio-si470x-i2c: Delete owner assignment

2016-08-14 Thread SF Markus Elfring
From: Markus Elfring 
Date: Mon, 15 Aug 2016 07:01:56 +0200

The field "owner" is set by core. Thus delete an extra initialisation.

Generated by: scripts/coccinelle/api/platform_no_drv_owner.cocci
Signed-off-by: Markus Elfring 
---
 drivers/media/radio/si470x/radio-si470x-i2c.c | 1 -
 1 file changed, 1 deletion(-)

diff --git a/drivers/media/radio/si470x/radio-si470x-i2c.c 
b/drivers/media/radio/si470x/radio-si470x-i2c.c
index 471d6a8..ee0470a 100644
--- a/drivers/media/radio/si470x/radio-si470x-i2c.c
+++ b/drivers/media/radio/si470x/radio-si470x-i2c.c
@@ -509,7 +509,6 @@ static SIMPLE_DEV_PM_OPS(si470x_i2c_pm, si470x_i2c_suspend, 
si470x_i2c_resume);
 static struct i2c_driver si470x_i2c_driver = {
.driver = {
.name   = "si470x",
-   .owner  = THIS_MODULE,
 #ifdef CONFIG_PM_SLEEP
.pm = _i2c_pm,
 #endif
-- 
2.9.2

--
To unsubscribe from this list: send the line "unsubscribe linux-media" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH] [media] cec: Delete an unnecessary check before the function call "rc_free_device"

2016-07-17 Thread SF Markus Elfring
From: Markus Elfring 
Date: Sun, 17 Jul 2016 22:52:49 +0200

The rc_free_device() function tests whether its argument is NULL
and then returns immediately. Thus the test around the call is not needed.

This issue was detected by using the Coccinelle software.

Signed-off-by: Markus Elfring 
---
 drivers/staging/media/cec/cec-core.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/drivers/staging/media/cec/cec-core.c 
b/drivers/staging/media/cec/cec-core.c
index 61a1e69..123e1bf 100644
--- a/drivers/staging/media/cec/cec-core.c
+++ b/drivers/staging/media/cec/cec-core.c
@@ -354,8 +354,7 @@ void cec_delete_adapter(struct cec_adapter *adap)
if (adap->kthread_config)
kthread_stop(adap->kthread_config);
 #if IS_ENABLED(CONFIG_RC_CORE)
-   if (adap->rc)
-   rc_free_device(adap->rc);
+   rc_free_device(adap->rc);
 #endif
kfree(adap);
 }
-- 
2.9.1

--
To unsubscribe from this list: send the line "unsubscribe linux-media" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH] [media] tw686x-kh: Delete an unnecessary check before the function call "video_unregister_device"

2016-07-17 Thread SF Markus Elfring
From: Markus Elfring 
Date: Sun, 17 Jul 2016 22:00:35 +0200

The video_unregister_device() function tests whether its argument is NULL
and then returns immediately. Thus the test around the call is not needed.

This issue was detected by using the Coccinelle software.

Signed-off-by: Markus Elfring 
---
 drivers/staging/media/tw686x-kh/tw686x-kh-video.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/drivers/staging/media/tw686x-kh/tw686x-kh-video.c 
b/drivers/staging/media/tw686x-kh/tw686x-kh-video.c
index 6ecb504..3f2830c 100644
--- a/drivers/staging/media/tw686x-kh/tw686x-kh-video.c
+++ b/drivers/staging/media/tw686x-kh/tw686x-kh-video.c
@@ -643,8 +643,7 @@ void tw686x_kh_video_free(struct tw686x_dev *dev)
struct tw686x_video_channel *vc = >video_channels[ch];
 
v4l2_ctrl_handler_free(>ctrl_handler);
-   if (vc->device)
-   video_unregister_device(vc->device);
+   video_unregister_device(vc->device);
vb2_dma_sg_cleanup_ctx(vc->alloc_ctx);
for (n = 0; n < 2; n++) {
struct dma_desc *descs = >sg_tables[n];
-- 
2.9.1

--
To unsubscribe from this list: send the line "unsubscribe linux-media" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH] [media] v4l2-common: Delete an unnecessary check before the function call "spi_unregister_device"

2016-07-19 Thread SF Markus Elfring
From: Markus Elfring 
Date: Tue, 19 Jul 2016 19:54:16 +0200

The spi_unregister_device() function tests whether its argument is NULL
and then returns immediately. Thus the test around the call is not needed.

This issue was detected by using the Coccinelle software.

Signed-off-by: Markus Elfring 
---
 drivers/media/v4l2-core/v4l2-common.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/media/v4l2-core/v4l2-common.c 
b/drivers/media/v4l2-core/v4l2-common.c
index 5b80850..57cfe26a 100644
--- a/drivers/media/v4l2-core/v4l2-common.c
+++ b/drivers/media/v4l2-core/v4l2-common.c
@@ -291,7 +291,7 @@ struct v4l2_subdev *v4l2_spi_new_subdev(struct v4l2_device 
*v4l2_dev,
 error:
/* If we have a client but no subdev, then something went wrong and
   we must unregister the client. */
-   if (spi && sd == NULL)
+   if (!sd)
spi_unregister_device(spi);
 
return sd;
-- 
2.9.2

--
To unsubscribe from this list: send the line "unsubscribe linux-media" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH] [media] tw686x: Delete an unnecessary check before the function call "video_unregister_device"

2016-07-19 Thread SF Markus Elfring
From: Markus Elfring 
Date: Tue, 19 Jul 2016 21:24:26 +0200

The video_unregister_device() function tests whether its argument is NULL
and then returns immediately. Thus the test around the call is not needed.

This issue was detected by using the Coccinelle software.

Signed-off-by: Markus Elfring 
---
 drivers/media/pci/tw686x/tw686x-video.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/drivers/media/pci/tw686x/tw686x-video.c 
b/drivers/media/pci/tw686x/tw686x-video.c
index cdb16de..4475a9d9 100644
--- a/drivers/media/pci/tw686x/tw686x-video.c
+++ b/drivers/media/pci/tw686x/tw686x-video.c
@@ -1093,8 +1093,7 @@ void tw686x_video_free(struct tw686x_dev *dev)
for (ch = 0; ch < max_channels(dev); ch++) {
struct tw686x_video_channel *vc = >video_channels[ch];
 
-   if (vc->device)
-   video_unregister_device(vc->device);
+   video_unregister_device(vc->device);
 
if (dev->dma_ops->free)
for (pb = 0; pb < 2; pb++)
-- 
2.9.2

--
To unsubscribe from this list: send the line "unsubscribe linux-media" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH] [media] dvb_frontend: Use memdup_user() rather than duplicating its implementation

2016-08-19 Thread SF Markus Elfring
From: Markus Elfring 
Date: Fri, 19 Aug 2016 10:04:54 +0200

* Reuse existing functionality from memdup_user() instead of keeping
  duplicate source code.

  This issue was detected by using the Coccinelle software.

* Return directly if this copy operation failed.

* Replace the specification of data structures by pointer dereferences
  to make the corresponding size determination a bit safer according to
  the Linux coding style convention.

Signed-off-by: Markus Elfring 
---
 drivers/media/dvb-core/dvb_frontend.c | 28 ++--
 1 file changed, 6 insertions(+), 22 deletions(-)

diff --git a/drivers/media/dvb-core/dvb_frontend.c 
b/drivers/media/dvb-core/dvb_frontend.c
index be99c8d..01511e5 100644
--- a/drivers/media/dvb-core/dvb_frontend.c
+++ b/drivers/media/dvb-core/dvb_frontend.c
@@ -1969,17 +1969,9 @@ static int dvb_frontend_ioctl_properties(struct file 
*file,
if ((tvps->num == 0) || (tvps->num > DTV_IOCTL_MAX_MSGS))
return -EINVAL;
 
-   tvp = kmalloc(tvps->num * sizeof(struct dtv_property), 
GFP_KERNEL);
-   if (!tvp) {
-   err = -ENOMEM;
-   goto out;
-   }
-
-   if (copy_from_user(tvp, (void __user *)tvps->props,
-  tvps->num * sizeof(struct dtv_property))) {
-   err = -EFAULT;
-   goto out;
-   }
+   tvp = memdup_user(tvps->props, tvps->num * sizeof(*tvp));
+   if (IS_ERR(tvp))
+   return PTR_ERR(tvp);
 
for (i = 0; i < tvps->num; i++) {
err = dtv_property_process_set(fe, tvp + i, file);
@@ -2002,17 +1994,9 @@ static int dvb_frontend_ioctl_properties(struct file 
*file,
if ((tvps->num == 0) || (tvps->num > DTV_IOCTL_MAX_MSGS))
return -EINVAL;
 
-   tvp = kmalloc(tvps->num * sizeof(struct dtv_property), 
GFP_KERNEL);
-   if (!tvp) {
-   err = -ENOMEM;
-   goto out;
-   }
-
-   if (copy_from_user(tvp, (void __user *)tvps->props,
-  tvps->num * sizeof(struct dtv_property))) {
-   err = -EFAULT;
-   goto out;
-   }
+   tvp = memdup_user(tvps->props, tvps->num * sizeof(*tvp));
+   if (IS_ERR(tvp))
+   return PTR_ERR(tvp);
 
/*
 * Let's use our own copy of property cache, in order to
-- 
2.9.3

--
To unsubscribe from this list: send the line "unsubscribe linux-media" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 1/2] uvc_v4l2: Use memdup_user() rather than duplicating its implementation

2016-08-19 Thread SF Markus Elfring
From: Markus Elfring 
Date: Fri, 19 Aug 2016 10:50:05 +0200

Reuse existing functionality from memdup_user() instead of keeping
duplicate source code.

This issue was detected by using the Coccinelle software.

Signed-off-by: Markus Elfring 
---
 drivers/media/usb/uvc/uvc_v4l2.c | 11 +++
 1 file changed, 3 insertions(+), 8 deletions(-)

diff --git a/drivers/media/usb/uvc/uvc_v4l2.c b/drivers/media/usb/uvc/uvc_v4l2.c
index 05eed4b..a7e12fd 100644
--- a/drivers/media/usb/uvc/uvc_v4l2.c
+++ b/drivers/media/usb/uvc/uvc_v4l2.c
@@ -70,14 +70,9 @@ static int uvc_ioctl_ctrl_map(struct uvc_video_chain *chain,
}
 
size = xmap->menu_count * sizeof(*map->menu_info);
-   map->menu_info = kmalloc(size, GFP_KERNEL);
-   if (map->menu_info == NULL) {
-   ret = -ENOMEM;
-   goto done;
-   }
-
-   if (copy_from_user(map->menu_info, xmap->menu_info, size)) {
-   ret = -EFAULT;
+   map->menu_info = memdup_user(xmap->menu_info, size);
+   if (IS_ERR(map->menu_info)) {
+   ret = PTR_ERR(map->menu_info);
goto done;
}
 
-- 
2.9.3

--
To unsubscribe from this list: send the line "unsubscribe linux-media" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 0/2] uvc_v4l2: Fine-tuning for uvc_ioctl_ctrl_map()

2016-08-19 Thread SF Markus Elfring
From: Markus Elfring 
Date: Fri, 19 Aug 2016 11:11:01 +0200

A few update suggestions were taken into account
from static source code analysis.

Markus Elfring (2):
  Use memdup_user() rather than duplicating its implementation
  One function call less after error detection

 drivers/media/usb/uvc/uvc_v4l2.c | 20 +++-
 1 file changed, 7 insertions(+), 13 deletions(-)

-- 
2.9.3

--
To unsubscribe from this list: send the line "unsubscribe linux-media" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 2/2] uvc_v4l2: One function call less in uvc_ioctl_ctrl_map() after error detection

2016-08-19 Thread SF Markus Elfring
From: Markus Elfring 
Date: Fri, 19 Aug 2016 11:00:38 +0200

The kfree() function was called in two cases by the uvc_ioctl_ctrl_map()
function during error handling even if the passed data structure element
contained a null pointer.

Adjust jump targets according to the Linux coding style convention.

Signed-off-by: Markus Elfring 
---
 drivers/media/usb/uvc/uvc_v4l2.c | 9 -
 1 file changed, 4 insertions(+), 5 deletions(-)

diff --git a/drivers/media/usb/uvc/uvc_v4l2.c b/drivers/media/usb/uvc/uvc_v4l2.c
index a7e12fd..52a2af8 100644
--- a/drivers/media/usb/uvc/uvc_v4l2.c
+++ b/drivers/media/usb/uvc/uvc_v4l2.c
@@ -66,14 +66,14 @@ static int uvc_ioctl_ctrl_map(struct uvc_video_chain *chain,
if (xmap->menu_count == 0 ||
xmap->menu_count > UVC_MAX_CONTROL_MENU_ENTRIES) {
ret = -EINVAL;
-   goto done;
+   goto free_map;
}
 
size = xmap->menu_count * sizeof(*map->menu_info);
map->menu_info = memdup_user(xmap->menu_info, size);
if (IS_ERR(map->menu_info)) {
ret = PTR_ERR(map->menu_info);
-   goto done;
+   goto free_map;
}
 
map->menu_count = xmap->menu_count;
@@ -83,13 +83,12 @@ static int uvc_ioctl_ctrl_map(struct uvc_video_chain *chain,
uvc_trace(UVC_TRACE_CONTROL, "Unsupported V4L2 control type "
  "%u.\n", xmap->v4l2_type);
ret = -ENOTTY;
-   goto done;
+   goto free_map;
}
 
ret = uvc_ctrl_add_mapping(chain, map);
-
-done:
kfree(map->menu_info);
+free_map:
kfree(map);
 
return ret;
-- 
2.9.3

--
To unsubscribe from this list: send the line "unsubscribe linux-media" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 2/2] [media] dvb-tc90522: Rename a jump label in tc90522_probe()

2016-10-07 Thread SF Markus Elfring
From: Markus Elfring 
Date: Fri, 7 Oct 2016 21:13:57 +0200

Adjust a jump label according to the Linux coding style convention.

Signed-off-by: Markus Elfring 
---
 drivers/media/dvb-frontends/tc90522.c | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)

diff --git a/drivers/media/dvb-frontends/tc90522.c 
b/drivers/media/dvb-frontends/tc90522.c
index c2d45f0..4687e15 100644
--- a/drivers/media/dvb-frontends/tc90522.c
+++ b/drivers/media/dvb-frontends/tc90522.c
@@ -794,14 +794,13 @@ static int tc90522_probe(struct i2c_client *client,
i2c_set_adapdata(adap, state);
ret = i2c_add_adapter(adap);
if (ret < 0)
-   goto err;
+   goto free_state;
cfg->tuner_i2c = state->cfg.tuner_i2c = adap;
 
i2c_set_clientdata(client, >cfg);
dev_info(>dev, "Toshiba TC90522 attached.\n");
return 0;
-
-err:
+free_state:
kfree(state);
return ret;
 }
-- 
2.10.1

--
To unsubscribe from this list: send the line "unsubscribe linux-media" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 0/2] [media] dvb-tc90522: Fine-tuning for two function implementations

2016-10-07 Thread SF Markus Elfring
From: Markus Elfring 
Date: Fri, 7 Oct 2016 21:38:12 +0200

A few update suggestions were taken into account
from static source code analysis.

Markus Elfring (2):
  Use kmalloc_array()
  Rename a jump label

 drivers/media/dvb-frontends/tc90522.c | 7 +++
 1 file changed, 3 insertions(+), 4 deletions(-)

-- 
2.10.1

--
To unsubscribe from this list: send the line "unsubscribe linux-media" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 1/2] [media] dvb-tc90522: Use kmalloc_array() in tc90522_master_xfer()

2016-10-07 Thread SF Markus Elfring
From: Markus Elfring 
Date: Fri, 7 Oct 2016 21:07:43 +0200

A multiplication for the size determination of a memory allocation
indicated that an array data structure should be processed.
Thus use the corresponding function "kmalloc_array".

This issue was detected by using the Coccinelle software.

Signed-off-by: Markus Elfring 
---
 drivers/media/dvb-frontends/tc90522.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/media/dvb-frontends/tc90522.c 
b/drivers/media/dvb-frontends/tc90522.c
index 31cd325..c2d45f0 100644
--- a/drivers/media/dvb-frontends/tc90522.c
+++ b/drivers/media/dvb-frontends/tc90522.c
@@ -656,7 +656,7 @@ tc90522_master_xfer(struct i2c_adapter *adap, struct 
i2c_msg *msgs, int num)
for (i = 0; i < num; i++)
if (msgs[i].flags & I2C_M_RD)
rd_num++;
-   new_msgs = kmalloc(sizeof(*new_msgs) * (num + rd_num), GFP_KERNEL);
+   new_msgs = kmalloc_array(num + rd_num, sizeof(*new_msgs), GFP_KERNEL);
if (!new_msgs)
return -ENOMEM;
 
-- 
2.10.1

--
To unsubscribe from this list: send the line "unsubscribe linux-media" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 0/2] [media] cx88-dsp: Fine-tuning for five function implementations

2016-10-08 Thread SF Markus Elfring
From: Markus Elfring 
Date: Fri, 8 Oct 2016 13:41:12 +0200

A few update suggestions were taken into account
from static source code analysis.

Markus Elfring (2):
  Use kmalloc_array()
  Add some spaces for better code readability

 drivers/media/pci/cx88/cx88-dsp.c | 43 +++
 1 file changed, 21 insertions(+), 22 deletions(-)

-- 
2.10.1

--
To unsubscribe from this list: send the line "unsubscribe linux-media" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 1/2] [media] cx88-dsp: Use kmalloc_array() in read_rds_samples()

2016-10-08 Thread SF Markus Elfring
From: Markus Elfring 
Date: Fri, 7 Oct 2016 22:07:27 +0200

* A multiplication for the size determination of a memory allocation
  indicated that an array data structure should be processed.
  Thus use the corresponding function "kmalloc_array".

  This issue was detected by using the Coccinelle software.

* Replace the specification of a data type by a pointer dereference
  to make the corresponding size determination a bit safer according to
  the Linux coding style convention.

Signed-off-by: Markus Elfring 
---
 drivers/media/pci/cx88/cx88-dsp.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/drivers/media/pci/cx88/cx88-dsp.c 
b/drivers/media/pci/cx88/cx88-dsp.c
index a990726..9acda12 100644
--- a/drivers/media/pci/cx88/cx88-dsp.c
+++ b/drivers/media/pci/cx88/cx88-dsp.c
@@ -245,8 +245,7 @@ static s16 *read_rds_samples(struct cx88_core *core, u32 *N)
"sample_count=%d, aud_intstat=%08x\n", current_address,
current_address - srch->fifo_start, sample_count,
cx_read(MO_AUD_INTSTAT));
-
-   samples = kmalloc(sizeof(s16)*sample_count, GFP_KERNEL);
+   samples = kmalloc_array(sample_count, sizeof(*samples), GFP_KERNEL);
if (!samples)
return NULL;
 
-- 
2.10.1

--
To unsubscribe from this list: send the line "unsubscribe linux-media" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 2/2] [media] cx88-dsp: Add some spaces for better code readability

2016-10-08 Thread SF Markus Elfring
From: Markus Elfring 
Date: Fri, 7 Oct 2016 22:30:40 +0200

Use space characters at some source code places according to
the Linux coding style convention.

Signed-off-by: Markus Elfring 
---
 drivers/media/pci/cx88/cx88-dsp.c | 40 +++
 1 file changed, 20 insertions(+), 20 deletions(-)

diff --git a/drivers/media/pci/cx88/cx88-dsp.c 
b/drivers/media/pci/cx88/cx88-dsp.c
index 9acda12..13f3a66 100644
--- a/drivers/media/pci/cx88/cx88-dsp.c
+++ b/drivers/media/pci/cx88/cx88-dsp.c
@@ -31,7 +31,7 @@
 #define INT_PI ((s32)(3.141592653589 * 32768.0))
 
 #define compat_remainder(a, b) \
-((float)(((s32)((a)*100))%((s32)((b)*100)))/100.0)
+((float)(((s32)((a) * 100)) % ((s32)((b) * 100))) / 100.0)
 
 #define baseband_freq(carrier, srate, tone) ((s32)( \
 (compat_remainder(carrier + tone, srate)) / srate * 2 * INT_PI))
@@ -82,15 +82,15 @@ static s32 int_cos(u32 x)
if (period % 2)
return -int_cos(x - INT_PI);
x = x % INT_PI;
-   if (x > INT_PI/2)
-   return -int_cos(INT_PI/2 - (x % (INT_PI/2)));
+   if (x > INT_PI / 2)
+   return -int_cos(INT_PI / 2 - (x % (INT_PI / 2)));
/* Now x is between 0 and INT_PI/2.
 * To calculate cos(x) we use it's Taylor polinom. */
-   t2 = x*x/32768/2;
-   t4 = t2*x/32768*x/32768/3/4;
-   t6 = t4*x/32768*x/32768/5/6;
-   t8 = t6*x/32768*x/32768/7/8;
-   ret = 32768-t2+t4-t6+t8;
+   t2 = x * x / 32768 / 2;
+   t4 = t2 * x / 32768 * x / 32768 / 3 / 4;
+   t6 = t4 * x / 32768 * x / 32768 / 5 / 6;
+   t8 = t6 * x / 32768 * x / 32768 / 7 / 8;
+   ret = 32768 - t2 + t4 - t6 + t8;
return ret;
 }
 
@@ -100,14 +100,14 @@ static u32 int_goertzel(s16 x[], u32 N, u32 freq)
 * given frequency in the signal */
s32 s_prev = 0;
s32 s_prev2 = 0;
-   s32 coeff = 2*int_cos(freq);
+   s32 coeff = 2 * int_cos(freq);
u32 i;
 
u64 tmp;
u32 divisor;
 
for (i = 0; i < N; i++) {
-   s32 s = x[i] + ((s64)coeff*s_prev/32768) - s_prev2;
+   s32 s = x[i] + ((s64)coeff * s_prev / 32768) - s_prev2;
s_prev2 = s_prev;
s_prev = s;
}
@@ -138,7 +138,7 @@ static u32 noise_magnitude(s16 x[], u32 N, u32 freq_start, 
u32 freq_end)
 
if (N > 192) {
/* The last 192 samples are enough for noise detection */
-   x += (N-192);
+   x += (N - 192);
N = 192;
}
 
@@ -196,8 +196,8 @@ static s32 detect_a2_a2m_eiaj(struct cx88_core *core, s16 
x[], u32 N)
 
if (core->tvaudio == WW_EIAJ) {
/* EIAJ checks may need adjustments */
-   if ((carrier > max(stereo, dual)*2) &&
-   (carrier < max(stereo, dual)*6) &&
+   if ((carrier > max(stereo, dual) * 2) &&
+   (carrier < max(stereo, dual) * 6) &&
(carrier > 20 && carrier < 200) &&
(max(stereo, dual) > min(stereo, dual))) {
/* For EIAJ the carrier is always present,
@@ -205,11 +205,11 @@ static s32 detect_a2_a2m_eiaj(struct cx88_core *core, s16 
x[], u32 N)
return ret;
}
} else {
-   if ((carrier > max(stereo, dual)*2) &&
-   (carrier < max(stereo, dual)*8) &&
+   if ((carrier > max(stereo, dual) * 2) &&
+   (carrier < max(stereo, dual) * 8) &&
(carrier > 20 && carrier < 200) &&
(noise < 10) &&
-   (max(stereo, dual) > min(stereo, dual)*2)) {
+   (max(stereo, dual) > min(stereo, dual) * 2)) {
return ret;
}
}
@@ -234,9 +234,9 @@ static s16 *read_rds_samples(struct cx88_core *core, u32 *N)
s16 *samples;
 
unsigned int i;
-   unsigned int bpl = srch->fifo_size/AUD_RDS_LINES;
-   unsigned int spl = bpl/4;
-   unsigned int sample_count = spl*(AUD_RDS_LINES-1);
+   unsigned int bpl = srch->fifo_size / AUD_RDS_LINES;
+   unsigned int spl = bpl / 4;
+   unsigned int sample_count = spl * (AUD_RDS_LINES - 1);
 
u32 current_address = cx_read(srch->ptr1_reg);
u32 offset = (current_address - srch->fifo_start + bpl);
@@ -252,7 +252,7 @@ static s16 *read_rds_samples(struct cx88_core *core, u32 *N)
*N = sample_count;
 
for (i = 0; i < sample_count; i++)  {
-   offset = offset % (AUD_RDS_LINES*bpl);
+   offset = offset % (AUD_RDS_LINES * bpl);
samples[i] = cx_read(srch->fifo_start + offset);
offset += 4;
}
-- 
2.10.1

--
To unsubscribe from this list: send the line "unsubscribe linux-media" in
the body of a message to majord...@vger.kernel.org
More majordomo 

[PATCH 2/2] [media] blackfin-capture: Delete an error message for a failed memory allocation

2016-10-09 Thread SF Markus Elfring
From: Markus Elfring 
Date: Sun, 9 Oct 2016 21:30:18 +0200

The script "checkpatch.pl" pointed information out like the following.

WARNING: Possible unnecessary 'out of memory' message

Thus remove such a statement here.

Link: 
http://events.linuxfoundation.org/sites/events/files/slides/LCJ16-Refactor_Strings-WSang_0.pdf

Signed-off-by: Markus Elfring 
---
 drivers/media/platform/blackfin/bfin_capture.c | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)

diff --git a/drivers/media/platform/blackfin/bfin_capture.c 
b/drivers/media/platform/blackfin/bfin_capture.c
index c5e1043..2e6edc0 100644
--- a/drivers/media/platform/blackfin/bfin_capture.c
+++ b/drivers/media/platform/blackfin/bfin_capture.c
@@ -802,10 +802,8 @@ static int bcap_probe(struct platform_device *pdev)
}
 
bcap_dev = kzalloc(sizeof(*bcap_dev), GFP_KERNEL);
-   if (!bcap_dev) {
-   v4l2_err(pdev->dev.driver, "Unable to alloc bcap_dev\n");
+   if (!bcap_dev)
return -ENOMEM;
-   }
 
bcap_dev->cfg = config;
 
-- 
2.10.1

--
To unsubscribe from this list: send the line "unsubscribe linux-media" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH v2 10/34] [media] DaVinci-VPBE: Check return value of a setup_if_config() call in vpbe_set_output()

2016-11-06 Thread SF Markus Elfring
From: Markus Elfring 
Date: Sun, 6 Nov 2016 20:40:20 +0100

* A function was called over the pointer "setup_if_config" in the data
  structure "venc_platform_data". But the return value was not used so far.
  Thus assign it to the local variable "ret" which will be checked with
  the next statement.

  Fixes: 9a7f95ad1c946efdd7a7a72df27db738260a0fd8 ("[media] davinci vpbe: add 
dm365 VPBE display driver changes")

* Pass a value to this function call without storing it in an intermediate
  variable before.

* Delete the local variable "if_params" which became unnecessary with
  this refactoring.

Acked-by: Lad, Prabhakar 
Reviewed-by: Hans Verkuil 
Signed-off-by: Markus Elfring 
---

v2: Keep the assignment statement on one line despite of its length
of 82 characters.

 drivers/media/platform/davinci/vpbe.c | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)

diff --git a/drivers/media/platform/davinci/vpbe.c 
b/drivers/media/platform/davinci/vpbe.c
index 19611a2..d04d6b7 100644
--- a/drivers/media/platform/davinci/vpbe.c
+++ b/drivers/media/platform/davinci/vpbe.c
@@ -227,7 +227,6 @@ static int vpbe_set_output(struct vpbe_device *vpbe_dev, 
int index)
vpbe_current_encoder_info(vpbe_dev);
struct vpbe_config *cfg = vpbe_dev->cfg;
struct venc_platform_data *venc_device = vpbe_dev->venc_device;
-   u32 if_params;
int enc_out_index;
int sd_index;
int ret = 0;
@@ -257,5 +257,4 @@ static int vpbe_set_output(struct vpbe_device *vpbe_dev, 
int index)
}
 
-   if_params = cfg->outputs[index].if_params;
-   venc_device->setup_if_config(if_params);
+   ret = 
venc_device->setup_if_config(cfg->outputs[index].if_params);
if (ret)
-- 
2.10.2

--
To unsubscribe from this list: send the line "unsubscribe linux-media" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH v2 17/34] [media] DaVinci-VPFE-Capture: Replace a memcpy() call by an assignment in vpfe_enum_input()

2016-11-06 Thread SF Markus Elfring
From: Markus Elfring 
Date: Sun, 6 Nov 2016 21:54:38 +0100

Use a direct assignment for an array element which can be set over the
pointer variable "inp" instead of calling the function "memcpy" here.

Suggested-by: Hans Verkuil 
Signed-off-by: Markus Elfring 
---
 drivers/media/platform/davinci/vpfe_capture.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/media/platform/davinci/vpfe_capture.c 
b/drivers/media/platform/davinci/vpfe_capture.c
index 8314c39..5417f6b 100644
--- a/drivers/media/platform/davinci/vpfe_capture.c
+++ b/drivers/media/platform/davinci/vpfe_capture.c
@@ -1091,7 +1091,7 @@ static int vpfe_enum_input(struct file *file, void *priv,
return -EINVAL;
}
sdinfo = _dev->cfg->sub_devs[subdev];
-   memcpy(inp, >inputs[index], sizeof(struct v4l2_input));
+   *inp = sdinfo->inputs[index];
return 0;
 }
 
-- 
2.10.2

--
To unsubscribe from this list: send the line "unsubscribe linux-media" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 3/5] [media] winbond-cir: Move assignments for three variables in wbcir_shutdown()

2016-10-14 Thread SF Markus Elfring
From: Markus Elfring 
Date: Fri, 14 Oct 2016 10:40:12 +0200

Move the setting for the local variables "mask", "match" and "rc6_csl"
behind the source code for a condition check by this function
at the beginning.

Signed-off-by: Markus Elfring 
---
 drivers/media/rc/winbond-cir.c | 8 
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/drivers/media/rc/winbond-cir.c b/drivers/media/rc/winbond-cir.c
index fd997f0..9d05e17 100644
--- a/drivers/media/rc/winbond-cir.c
+++ b/drivers/media/rc/winbond-cir.c
@@ -702,17 +702,17 @@ wbcir_shutdown(struct pnp_dev *device)
bool do_wake = true;
u8 match[11];
u8 mask[11];
-   u8 rc6_csl = 0;
+   u8 rc6_csl;
int i;
 
-   memset(match, 0, sizeof(match));
-   memset(mask, 0, sizeof(mask));
-
if (wake_sc == INVALID_SCANCODE || !device_may_wakeup(dev)) {
do_wake = false;
goto finish;
}
 
+   rc6_csl = 0;
+   memset(match, 0, sizeof(match));
+   memset(mask, 0, sizeof(mask));
switch (protocol) {
case IR_PROTOCOL_RC5:
if (wake_sc > 0xFFF) {
-- 
2.10.1

--
To unsubscribe from this list: send the line "unsubscribe linux-media" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 4/5] [media] winbond-cir: One variable and its check less in wbcir_shutdown() after error detection

2016-10-14 Thread SF Markus Elfring
From: Markus Elfring 
Date: Fri, 14 Oct 2016 12:48:41 +0200

The local variable "do_wake" was set to "false" after an invalid system
setting was detected so that a bit of error handling was triggered.

* Replace these assignments by direct jumps to the source code with the
desired exception handling.

* Delete this status variable and a corresponding check which became
  unnecessary with this refactoring.

Signed-off-by: Markus Elfring 
---
 drivers/media/rc/winbond-cir.c | 78 ++
 1 file changed, 34 insertions(+), 44 deletions(-)

diff --git a/drivers/media/rc/winbond-cir.c b/drivers/media/rc/winbond-cir.c
index 9d05e17..3d286b9 100644
--- a/drivers/media/rc/winbond-cir.c
+++ b/drivers/media/rc/winbond-cir.c
@@ -699,16 +699,13 @@ wbcir_shutdown(struct pnp_dev *device)
 {
struct device *dev = >dev;
struct wbcir_data *data = pnp_get_drvdata(device);
-   bool do_wake = true;
u8 match[11];
u8 mask[11];
u8 rc6_csl;
int i;
 
-   if (wake_sc == INVALID_SCANCODE || !device_may_wakeup(dev)) {
-   do_wake = false;
-   goto finish;
-   }
+   if (wake_sc == INVALID_SCANCODE || !device_may_wakeup(dev))
+   goto clear_bits;
 
rc6_csl = 0;
memset(match, 0, sizeof(match));
@@ -716,9 +713,8 @@ wbcir_shutdown(struct pnp_dev *device)
switch (protocol) {
case IR_PROTOCOL_RC5:
if (wake_sc > 0xFFF) {
-   do_wake = false;
dev_err(dev, "RC5 - Invalid wake scancode\n");
-   break;
+   goto clear_bits;
}
 
/* Mask = 13 bits, ex toggle */
@@ -735,9 +731,8 @@ wbcir_shutdown(struct pnp_dev *device)
 
case IR_PROTOCOL_NEC:
if (wake_sc > 0xFF) {
-   do_wake = false;
dev_err(dev, "NEC - Invalid wake scancode\n");
-   break;
+   goto clear_bits;
}
 
mask[0] = mask[1] = mask[2] = mask[3] = 0xFF;
@@ -757,9 +752,8 @@ wbcir_shutdown(struct pnp_dev *device)
 
if (wake_rc6mode == 0) {
if (wake_sc > 0x) {
-   do_wake = false;
dev_err(dev, "RC6 - Invalid wake scancode\n");
-   break;
+   goto clear_bits;
}
 
/* Command */
@@ -813,9 +807,8 @@ wbcir_shutdown(struct pnp_dev *device)
} else if (wake_sc <= 0x007F) {
rc6_csl = 60;
} else {
-   do_wake = false;
dev_err(dev, "RC6 - Invalid wake scancode\n");
-   break;
+   goto clear_bits;
}
 
/* Header */
@@ -825,49 +818,38 @@ wbcir_shutdown(struct pnp_dev *device)
mask[i++] = 0x0F;
 
} else {
-   do_wake = false;
dev_err(dev, "RC6 - Invalid wake mode\n");
+   goto clear_bits;
}
 
break;
 
default:
-   do_wake = false;
-   break;
+   goto clear_bits;
}
 
-finish:
-   if (do_wake) {
-   /* Set compare and compare mask */
-   wbcir_set_bits(data->wbase + WBCIR_REG_WCEIR_INDEX,
-  WBCIR_REGSEL_COMPARE | WBCIR_REG_ADDR0,
-  0x3F);
-   outsb(data->wbase + WBCIR_REG_WCEIR_DATA, match, 11);
-   wbcir_set_bits(data->wbase + WBCIR_REG_WCEIR_INDEX,
-  WBCIR_REGSEL_MASK | WBCIR_REG_ADDR0,
-  0x3F);
-   outsb(data->wbase + WBCIR_REG_WCEIR_DATA, mask, 11);
-
-   /* RC6 Compare String Len */
-   outb(rc6_csl, data->wbase + WBCIR_REG_WCEIR_CSL);
-
-   /* Clear status bits NEC_REP, BUFF, MSG_END, MATCH */
-   wbcir_set_bits(data->wbase + WBCIR_REG_WCEIR_STS, 0x17, 0x17);
+   /* Set compare and compare mask */
+   wbcir_set_bits(data->wbase + WBCIR_REG_WCEIR_INDEX,
+  WBCIR_REGSEL_COMPARE | WBCIR_REG_ADDR0,
+  0x3F);
+   outsb(data->wbase + WBCIR_REG_WCEIR_DATA, match, 11);
+   wbcir_set_bits(data->wbase + WBCIR_REG_WCEIR_INDEX,
+  WBCIR_REGSEL_MASK | WBCIR_REG_ADDR0,
+  0x3F);
+   outsb(data->wbase + WBCIR_REG_WCEIR_DATA, mask, 11);
 
-   /* Clear BUFF_EN, Clear END_EN, Set MATCH_EN */
-   wbcir_set_bits(data->wbase + WBCIR_REG_WCEIR_EV_EN, 

[PATCH 1/5] [media] winbond-cir: Use kmalloc_array() in wbcir_tx()

2016-10-14 Thread SF Markus Elfring
From: Markus Elfring 
Date: Fri, 14 Oct 2016 07:19:00 +0200

A multiplication for the size determination of a memory allocation
indicated that an array data structure should be processed.
Thus use the corresponding function "kmalloc_array".

This issue was detected by using the Coccinelle software.

Signed-off-by: Markus Elfring 
---
 drivers/media/rc/winbond-cir.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/media/rc/winbond-cir.c b/drivers/media/rc/winbond-cir.c
index 95ae60e..59050f5 100644
--- a/drivers/media/rc/winbond-cir.c
+++ b/drivers/media/rc/winbond-cir.c
@@ -660,7 +660,7 @@ wbcir_tx(struct rc_dev *dev, unsigned *b, unsigned count)
unsigned i;
unsigned long flags;
 
-   buf = kmalloc(count * sizeof(*b), GFP_KERNEL);
+   buf = kmalloc_array(count, sizeof(*b), GFP_KERNEL);
if (!buf)
return -ENOMEM;
 
-- 
2.10.1

--
To unsubscribe from this list: send the line "unsubscribe linux-media" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 5/5] [media] winbond-cir: Move a variable assignment in two functions

2016-10-14 Thread SF Markus Elfring
From: Markus Elfring 
Date: Fri, 14 Oct 2016 13:13:11 +0200

Move the assignment for the local variable "data" behind the source code
for condition checks by these functions.

Signed-off-by: Markus Elfring 
---
 drivers/media/rc/winbond-cir.c | 6 --
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/drivers/media/rc/winbond-cir.c b/drivers/media/rc/winbond-cir.c
index 3d286b9..716b1fe 100644
--- a/drivers/media/rc/winbond-cir.c
+++ b/drivers/media/rc/winbond-cir.c
@@ -566,7 +566,7 @@ wbcir_set_carrier_report(struct rc_dev *dev, int enable)
 static int
 wbcir_txcarrier(struct rc_dev *dev, u32 carrier)
 {
-   struct wbcir_data *data = dev->priv;
+   struct wbcir_data *data;
unsigned long flags;
u8 val;
u32 freq;
@@ -592,6 +592,7 @@ wbcir_txcarrier(struct rc_dev *dev, u32 carrier)
break;
}
 
+   data = dev->priv;
spin_lock_irqsave(>spinlock, flags);
if (data->txstate != WBCIR_TXSTATE_INACTIVE) {
spin_unlock_irqrestore(>spinlock, flags);
@@ -611,7 +612,7 @@ wbcir_txcarrier(struct rc_dev *dev, u32 carrier)
 static int
 wbcir_txmask(struct rc_dev *dev, u32 mask)
 {
-   struct wbcir_data *data = dev->priv;
+   struct wbcir_data *data;
unsigned long flags;
u8 val;
 
@@ -637,6 +638,7 @@ wbcir_txmask(struct rc_dev *dev, u32 mask)
return -EINVAL;
}
 
+   data = dev->priv;
spin_lock_irqsave(>spinlock, flags);
if (data->txstate != WBCIR_TXSTATE_INACTIVE) {
spin_unlock_irqrestore(>spinlock, flags);
-- 
2.10.1

--
To unsubscribe from this list: send the line "unsubscribe linux-media" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 2/5] [media] winbond-cir: Move a variable assignment in wbcir_tx()

2016-10-14 Thread SF Markus Elfring
From: Markus Elfring 
Date: Fri, 14 Oct 2016 07:34:46 +0200

Move the assignment for the local variable "data" behind the source code
for a memory allocation by this function.

Signed-off-by: Markus Elfring 
---
 drivers/media/rc/winbond-cir.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/drivers/media/rc/winbond-cir.c b/drivers/media/rc/winbond-cir.c
index 59050f5..fd997f0 100644
--- a/drivers/media/rc/winbond-cir.c
+++ b/drivers/media/rc/winbond-cir.c
@@ -655,7 +655,7 @@ wbcir_txmask(struct rc_dev *dev, u32 mask)
 static int
 wbcir_tx(struct rc_dev *dev, unsigned *b, unsigned count)
 {
-   struct wbcir_data *data = dev->priv;
+   struct wbcir_data *data;
unsigned *buf;
unsigned i;
unsigned long flags;
@@ -668,6 +668,7 @@ wbcir_tx(struct rc_dev *dev, unsigned *b, unsigned count)
for (i = 0; i < count; i++)
buf[i] = DIV_ROUND_CLOSEST(b[i], 10);
 
+   data = dev->priv;
/* Not sure if this is possible, but better safe than sorry */
spin_lock_irqsave(>spinlock, flags);
if (data->txstate != WBCIR_TXSTATE_INACTIVE) {
-- 
2.10.1

--
To unsubscribe from this list: send the line "unsubscribe linux-media" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [media] RedRat3: Move two assignments in redrat3_transmit_ir()?

2016-10-14 Thread SF Markus Elfring
> The original code was correct.

Your view can be appropriate for this function implementation to some degree.

I got the impression that it contains the specification of assignments
which will happen a bit too early here.
Is this a weakness for which software developers can care about?

Regards,
Markus
--
To unsubscribe from this list: send the line "unsubscribe linux-media" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 0/5] [media] winbond-cir: Fine-tuning for four function implementations

2016-10-14 Thread SF Markus Elfring
From: Markus Elfring 
Date: Fri, 14 Oct 2016 13:24:35 +0200

A few update suggestions were taken into account
from static source code analysis.

Markus Elfring (5):
  Use kmalloc_array() in wbcir_tx()
  Move a variable assignment in wbcir_tx()
  Move assignments for three variables in wbcir_shutdown()
  One variable and its check less in wbcir_shutdown() after error detection
  Move a variable assignment in two functions

 drivers/media/rc/winbond-cir.c | 95 +++---
 1 file changed, 44 insertions(+), 51 deletions(-)

-- 
2.10.1

--
To unsubscribe from this list: send the line "unsubscribe linux-media" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 1/3] [media] au0828-video: Use kcalloc() in au0828_init_isoc()

2016-10-24 Thread SF Markus Elfring
From: Markus Elfring 
Date: Mon, 24 Oct 2016 22:08:47 +0200

* Multiplications for the size determination of memory allocations
  indicated that array data structures should be processed.
  Thus use the corresponding function "kcalloc".

  This issue was detected by using the Coccinelle software.

* Replace the specification of data types by pointer dereferences
  to make the corresponding size determination a bit safer according to
  the Linux coding style convention.

Signed-off-by: Markus Elfring 
---
 drivers/media/usb/au0828/au0828-video.c | 11 +++
 1 file changed, 7 insertions(+), 4 deletions(-)

diff --git a/drivers/media/usb/au0828/au0828-video.c 
b/drivers/media/usb/au0828/au0828-video.c
index 85dd9a8..85b13c1 100644
--- a/drivers/media/usb/au0828/au0828-video.c
+++ b/drivers/media/usb/au0828/au0828-video.c
@@ -221,15 +221,18 @@ static int au0828_init_isoc(struct au0828_dev *dev, int 
max_packets,
 
dev->isoc_ctl.isoc_copy = isoc_copy;
dev->isoc_ctl.num_bufs = num_bufs;
-
-   dev->isoc_ctl.urb = kzalloc(sizeof(void *)*num_bufs,  GFP_KERNEL);
+   dev->isoc_ctl.urb = kcalloc(num_bufs,
+   sizeof(*dev->isoc_ctl.urb),
+   GFP_KERNEL);
if (!dev->isoc_ctl.urb) {
au0828_isocdbg("cannot alloc memory for usb buffers\n");
return -ENOMEM;
}
 
-   dev->isoc_ctl.transfer_buffer = kzalloc(sizeof(void *)*num_bufs,
- GFP_KERNEL);
+   dev->isoc_ctl.transfer_buffer = kcalloc(num_bufs,
+   sizeof(*dev->isoc_ctl
+  .transfer_buffer),
+   GFP_KERNEL);
if (!dev->isoc_ctl.transfer_buffer) {
au0828_isocdbg("cannot allocate memory for usb transfer\n");
kfree(dev->isoc_ctl.urb);
-- 
2.10.1

--
To unsubscribe from this list: send the line "unsubscribe linux-media" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 0/3] [media] au0828-video: Fine-tuning for au0828_init_isoc()

2016-10-24 Thread SF Markus Elfring
From: Markus Elfring 
Date: Mon, 24 Oct 2016 22:52:10 +0200

A few update suggestions were taken into account
from static source code analysis.

Markus Elfring (3):
  Use kcalloc()
  Delete three error messages for a failed memory allocation
  Move two assignments

 drivers/media/usb/au0828/au0828-video.c | 25 ++---
 1 file changed, 10 insertions(+), 15 deletions(-)

-- 
2.10.1

--
To unsubscribe from this list: send the line "unsubscribe linux-media" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 3/3] [media] au0828-video: Move two assignments in au0828_init_isoc()

2016-10-24 Thread SF Markus Elfring
From: Markus Elfring 
Date: Mon, 24 Oct 2016 22:44:02 +0200

Move the assignment for the data structure members "isoc_copy"
and "num_bufs" behind the source code for memory allocations
by this function.

Signed-off-by: Markus Elfring 
---
 drivers/media/usb/au0828/au0828-video.c | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)

diff --git a/drivers/media/usb/au0828/au0828-video.c 
b/drivers/media/usb/au0828/au0828-video.c
index b5c88a7..5ebda64 100644
--- a/drivers/media/usb/au0828/au0828-video.c
+++ b/drivers/media/usb/au0828/au0828-video.c
@@ -218,9 +218,6 @@ static int au0828_init_isoc(struct au0828_dev *dev, int 
max_packets,
int rc;
 
au0828_isocdbg("au0828: called au0828_prepare_isoc\n");
-
-   dev->isoc_ctl.isoc_copy = isoc_copy;
-   dev->isoc_ctl.num_bufs = num_bufs;
dev->isoc_ctl.urb = kcalloc(num_bufs,
sizeof(*dev->isoc_ctl.urb),
GFP_KERNEL);
@@ -240,6 +237,7 @@ static int au0828_init_isoc(struct au0828_dev *dev, int 
max_packets,
dev->isoc_ctl.buf = NULL;
 
sb_size = max_packets * dev->isoc_ctl.max_pkt_size;
+   dev->isoc_ctl.num_bufs = num_bufs;
 
/* allocate urbs and transfer buffers */
for (i = 0; i < dev->isoc_ctl.num_bufs; i++) {
@@ -276,6 +274,7 @@ static int au0828_init_isoc(struct au0828_dev *dev, int 
max_packets,
k += dev->isoc_ctl.max_pkt_size;
}
}
+   dev->isoc_ctl.isoc_copy = isoc_copy;
 
/* submit urbs and enables IRQ */
for (i = 0; i < dev->isoc_ctl.num_bufs; i++) {
-- 
2.10.1

--
To unsubscribe from this list: send the line "unsubscribe linux-media" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 2/3] [media] au0828-video: Delete three error messages for a failed memory allocation

2016-10-24 Thread SF Markus Elfring
From: Markus Elfring 
Date: Mon, 24 Oct 2016 22:28:03 +0200

Omit extra messages for a memory allocation failure in this function.

Link: 
http://events.linuxfoundation.org/sites/events/files/slides/LCJ16-Refactor_Strings-WSang_0.pdf
Signed-off-by: Markus Elfring 
---
 drivers/media/usb/au0828/au0828-video.c | 9 +
 1 file changed, 1 insertion(+), 8 deletions(-)

diff --git a/drivers/media/usb/au0828/au0828-video.c 
b/drivers/media/usb/au0828/au0828-video.c
index 85b13c1..b5c88a7 100644
--- a/drivers/media/usb/au0828/au0828-video.c
+++ b/drivers/media/usb/au0828/au0828-video.c
@@ -224,17 +224,14 @@ static int au0828_init_isoc(struct au0828_dev *dev, int 
max_packets,
dev->isoc_ctl.urb = kcalloc(num_bufs,
sizeof(*dev->isoc_ctl.urb),
GFP_KERNEL);
-   if (!dev->isoc_ctl.urb) {
-   au0828_isocdbg("cannot alloc memory for usb buffers\n");
+   if (!dev->isoc_ctl.urb)
return -ENOMEM;
-   }
 
dev->isoc_ctl.transfer_buffer = kcalloc(num_bufs,
sizeof(*dev->isoc_ctl
   .transfer_buffer),
GFP_KERNEL);
if (!dev->isoc_ctl.transfer_buffer) {
-   au0828_isocdbg("cannot allocate memory for usb transfer\n");
kfree(dev->isoc_ctl.urb);
return -ENOMEM;
}
@@ -256,10 +253,6 @@ static int au0828_init_isoc(struct au0828_dev *dev, int 
max_packets,
dev->isoc_ctl.transfer_buffer[i] = 
usb_alloc_coherent(dev->usbdev,
sb_size, GFP_KERNEL, >transfer_dma);
if (!dev->isoc_ctl.transfer_buffer[i]) {
-   printk("unable to allocate %i bytes for transfer"
-   " buffer %i%s\n",
-   sb_size, i,
-   in_interrupt() ? " while in int" : "");
au0828_uninit_isoc(dev);
return -ENOMEM;
}
-- 
2.10.1

--
To unsubscribe from this list: send the line "unsubscribe linux-media" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [media] winbond-cir: Move assignments for three variables in wbcir_shutdown()

2016-10-19 Thread SF Markus Elfring
 Move the setting for the local variables "mask", "match" and "rc6_csl"
 behind the source code for a condition check by this function
 at the beginning.
>>>
>>> Again, I can't see what the point is?
>>
>> * How do you think about to set these variables only after the initial
>> check succeded?
> 
> I prefer setting variables early so that no thinking about
> whether they're initialized or not is necessary later.

* How do you think about to reduce the scope for these variables then?

* Would you dare to move the corresponding source code into a separate function?

Regards,
Markus
--
To unsubscribe from this list: send the line "unsubscribe linux-media" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [media] winbond-cir: Move a variable assignment in wbcir_tx()

2016-10-19 Thread SF Markus Elfring
>> Move the assignment for the local variable "data" behind the source code
>> for a memory allocation by this function.
> 
> Sorry, I can't see what the point is?

* How do you think about to avoid a variable assignment in case
  that this memory allocation failed anyhow?

* Do you care for data access locality?

Regards,
Markus
--
To unsubscribe from this list: send the line "unsubscribe linux-media" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [media] winbond-cir: Move a variable assignment in wbcir_tx()

2016-10-19 Thread SF Markus Elfring
>> * How do you think about to avoid a variable assignment in case
>> that this memory allocation failed anyhow?
> 
> There is no memory allocation that can fail at this point.

Do you really know the failure probability for a call of the
function "kmalloc" (within the function "wbcir_tx") under all
possible run time situations?


>> * Do you care for data access locality?
> 
> Not unless you can show measurable performance improvements?

Did any software developer (before me) dare anything in this direction?

Regards,
Markus
--
To unsubscribe from this list: send the line "unsubscribe linux-media" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [media] winbond-cir: Move a variable assignment in two functions

2016-10-19 Thread SF Markus Elfring
>> Move the assignment for the local variable "data" behind the source code
>> for condition checks by these functions.
> 
> Why?

* Would you like to set these variables only after the initial
  check succeeded?

* Do you care for data access locality also in these cases?

Regards,
Markus

--
To unsubscribe from this list: send the line "unsubscribe linux-media" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [media] winbond-cir: Move assignments for three variables in wbcir_shutdown()

2016-10-19 Thread SF Markus Elfring
>> Move the setting for the local variables "mask", "match" and "rc6_csl"
>> behind the source code for a condition check by this function
>> at the beginning.
>  
> Again, I can't see what the point is?

* How do you think about to set these variables only after the initial
  check succeded?

* Do you care for data access locality?

Regards,
Markus
--
To unsubscribe from this list: send the line "unsubscribe linux-media" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH 4/5] [media] winbond-cir: One variable and its check less in wbcir_shutdown() after error detection

2016-10-19 Thread SF Markus Elfring
 + /* Set CEIR_EN */
 + wbcir_set_bits(data->wbase + WBCIR_REG_WCEIR_CTL, 0x01, 0x01);
 +set_irqmask:
 /*
 * ACPI will set the HW disable bit for SP3 which means that the
 * output signals are left in an undefined state which may cause
 @@ -876,6 +858,14 @@ wbcir_shutdown(struct pnp_dev *device)
 */
 wbcir_set_irqmask(data, WBCIR_IRQ_NONE);
 disable_irq(data->irq);
 + return;
 +clear_bits:
 + /* Clear BUFF_EN, Clear END_EN, Clear MATCH_EN */
 + wbcir_set_bits(data->wbase + WBCIR_REG_WCEIR_EV_EN, 0x00, 0x07);
 +
 + /* Clear CEIR_EN */
 + wbcir_set_bits(data->wbase + WBCIR_REG_WCEIR_CTL, 0x00, 0x01);
 + goto set_irqmask;
>>>
>>> I'm not convinced that adding a goto which goes backwards is making this
>>> code any more readible, just so that a local variable can be dropped.
>>
>> Thanks for your feedback.
>>
>> Is such a "backward jump" usual and finally required when you would like
>> to move a bit of common error handling code to the end without using extra
>> local variables and a few statements should still be performed after it?
>>
> 
> I'm sorry, I can't parse this.

Can an other update suggestion like "[PATCH 6/6] crypto-caamhash:
Move common error handling code in two functions" explain this technique
a bit better in principle?
https://patchwork.kernel.org/patch/9333861/
https://lkml.kernel.org/r/

Regards,
Markus
--
To unsubscribe from this list: send the line "unsubscribe linux-media" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH] [media] DaVinci-VPFE-Capture: fix error handling

2016-11-23 Thread SF Markus Elfring
> A recent cleanup had the right idea to remove the initialization
> of the error variable, but missed the actual benefit of that,
> which is that we get warnings if there is a bug in it.
> Now we get a warning about a bug that was introduced by this cleanup:
> 
> drivers/media/platform/davinci/vpfe_capture.c: In function 'vpfe_probe':
> drivers/media/platform/davinci/vpfe_capture.c:1992:9: error: 'ret' may be 
> used uninitialized in this function [-Werror=maybe-uninitialized]

Thanks for your information.


> This adds the missing initialization that the warning is about,

I have got the impression that an other wording would be more appropriate.


> and another one that was preexisting and that we did not get
> a warning for. That second bug has existed since the driver
> was first added.

Do you distinguish better between the setting for two return values because of 
either
a memory allocation failure and a failed call of the function 
"v4l2_i2c_new_subdev_board" here?


> Fixes: efb74461f5a6 ("[media] DaVinci-VPFE-Capture: Delete an unnecessary 
> variable initialisation in vpfe_probe()")
> Fixes: 7da8a6cb3e5b ("V4L/DVB (12248): v4l: vpfe capture bridge driver for 
> DM355 and DM6446")
> Signed-off-by: Arnd Bergmann 
> ---
>  drivers/media/platform/davinci/vpfe_capture.c | 5 -
>  1 file changed, 4 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/media/platform/davinci/vpfe_capture.c 
> b/drivers/media/platform/davinci/vpfe_capture.c
> index 6c41782b3ba0..ee1cd79739c8 100644
> --- a/drivers/media/platform/davinci/vpfe_capture.c
> +++ b/drivers/media/platform/davinci/vpfe_capture.c
> @@ -1847,8 +1847,10 @@ static int vpfe_probe(struct platform_device *pdev)
>  
>   /* Allocate memory for ccdc configuration */
>   ccdc_cfg = kmalloc(sizeof(*ccdc_cfg), GFP_KERNEL);
> - if (!ccdc_cfg)
> + if (!ccdc_cfg) {
> + ret = -ENOMEM;
>   goto probe_free_dev_mem;
> + }
>  
>   mutex_lock(_lock);
>  
> @@ -1964,6 +1966,7 @@ static int vpfe_probe(struct platform_device *pdev)
>   v4l2_info(_dev->v4l2_dev,
> "v4l2 sub device %s register fails\n",
> sdinfo->name);
> + ret = -ENXIO;
>   goto probe_sd_out;
>   }
>   }
> 

Thanks for your source code correction.

Regards,
Markus
--
To unsubscribe from this list: send the line "unsubscribe linux-media" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [patch] [media] uvcvideo: freeing an error pointer

2016-11-25 Thread SF Markus Elfring
> A recent cleanup introduced a potential dereference of -EFAULT when we
> call kfree(map->menu_info).
> 
> Fixes: 4cc5bed1caeb ("[media] uvcvideo: Use memdup_user() rather than 
> duplicating its implementation")
> Signed-off-by: Dan Carpenter 

Thanks for your information.


> diff --git a/drivers/media/usb/uvc/uvc_v4l2.c 
> b/drivers/media/usb/uvc/uvc_v4l2.c
> index a7e12fd..3e7e283 100644
> --- a/drivers/media/usb/uvc/uvc_v4l2.c
> +++ b/drivers/media/usb/uvc/uvc_v4l2.c
> @@ -66,14 +66,14 @@ static int uvc_ioctl_ctrl_map(struct uvc_video_chain 
> *chain,
>   if (xmap->menu_count == 0 ||
>   xmap->menu_count > UVC_MAX_CONTROL_MENU_ENTRIES) {
>   ret = -EINVAL;
> - goto done;
> + goto free_map;
>   }
>  
>   size = xmap->menu_count * sizeof(*map->menu_info);
>   map->menu_info = memdup_user(xmap->menu_info, size);
>   if (IS_ERR(map->menu_info)) {
>   ret = PTR_ERR(map->menu_info);
> - goto done;
> + goto free_map;
>   }
>  
>   map->menu_count = xmap->menu_count;
> @@ -83,13 +83,13 @@ static int uvc_ioctl_ctrl_map(struct uvc_video_chain 
> *chain,
>   uvc_trace(UVC_TRACE_CONTROL, "Unsupported V4L2 control type "
> "%u.\n", xmap->v4l2_type);
>   ret = -ENOTTY;
> - goto done;
> + goto free_map;
>   }
>  
>   ret = uvc_ctrl_add_mapping(chain, map);
>  
> -done:
>   kfree(map->menu_info);
> +free_map:
>   kfree(map);
>  
>   return ret;
> 

Did your update suggestion become also relevant just because the corresponding
update step “[PATCH 2/2] uvc_v4l2: One function call less in 
uvc_ioctl_ctrl_map()
after error detection” which I offered as another change possibility on 
2016-08-19
was rejected on 2016-11-22?

https://patchwork.linuxtv.org/patch/36528/
https://patchwork.kernel.org/patch/9289897/
https://lkml.kernel.org/r/<8f89ec37-1556-4c09-f0b7-df87b4169...@users.sourceforge.net>

Regards,
Markus
--
To unsubscribe from this list: send the line "unsubscribe linux-media" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH 3/3] [media] au0828-video: Move two assignments in au0828_init_isoc()

2016-11-03 Thread SF Markus Elfring
>> From: Markus Elfring 
>> Date: Mon, 24 Oct 2016 22:44:02 +0200
>>
>> Move the assignment for the data structure members "isoc_copy"
>> and "num_bufs" behind the source code for memory allocations
>> by this function.
> 
> I don't see the point,

Another explanation try …


> dropping this patch.

I proposed that these assignments should only be performed after the required
memory allocations succeeded. Is this detail worth for further considerations?


>> Signed-off-by: Markus Elfring 
>> ---
>>  drivers/media/usb/au0828/au0828-video.c | 5 ++---
>>  1 file changed, 2 insertions(+), 3 deletions(-)
>>
>> diff --git a/drivers/media/usb/au0828/au0828-video.c 
>> b/drivers/media/usb/au0828/au0828-video.c
>> index b5c88a7..5ebda64 100644
>> --- a/drivers/media/usb/au0828/au0828-video.c
>> +++ b/drivers/media/usb/au0828/au0828-video.c
>> @@ -218,9 +218,6 @@ static int au0828_init_isoc(struct au0828_dev *dev, int 
>> max_packets,
>>  int rc;
>>
>>  au0828_isocdbg("au0828: called au0828_prepare_isoc\n");
>> -
>> -dev->isoc_ctl.isoc_copy = isoc_copy;
>> -dev->isoc_ctl.num_bufs = num_bufs;
>>  dev->isoc_ctl.urb = kcalloc(num_bufs,
>>  sizeof(*dev->isoc_ctl.urb),
>>  GFP_KERNEL);
>> @@ -240,6 +237,7 @@ static int au0828_init_isoc(struct au0828_dev *dev, int 
>> max_packets,
>>  dev->isoc_ctl.buf = NULL;
>>
>>  sb_size = max_packets * dev->isoc_ctl.max_pkt_size;
>> +dev->isoc_ctl.num_bufs = num_bufs;
>>
>>  /* allocate urbs and transfer buffers */
>>  for (i = 0; i < dev->isoc_ctl.num_bufs; i++) {
>> @@ -276,6 +274,7 @@ static int au0828_init_isoc(struct au0828_dev *dev, int 
>> max_packets,
>>  k += dev->isoc_ctl.max_pkt_size;
>>  }
>>  }
>> +dev->isoc_ctl.isoc_copy = isoc_copy;
>>
>>  /* submit urbs and enables IRQ */
>>  for (i = 0; i < dev->isoc_ctl.num_bufs; i++) {
>>

--
To unsubscribe from this list: send the line "unsubscribe linux-media" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH 10/34] [media] DaVinci-VPBE: Check return value of a setup_if_config() call in vpbe_set_output()

2016-11-03 Thread SF Markus Elfring
>> From: Markus Elfring 
>> Date: Wed, 12 Oct 2016 09:56:56 +0200
>>
>> * A function was called over the pointer "setup_if_config" in the data
>>   structure "venc_platform_data". But the return value was not used so far.
>>   Thus assign it to the local variable "ret" which will be checked with
>>   the next statement.
>>
>>   Fixes: 9a7f95ad1c946efdd7a7a72df27db738260a0fd8 ("[media] davinci vpbe: 
>> add dm365 VPBE display driver changes")
>>
>> * Pass a value to this function call without storing it in an intermediate
>>   variable before.
>>
>> * Delete the local variable "if_params" which became unnecessary with
>>   this refactoring.
>>
>> Signed-off-by: Markus Elfring 
>> ---
>>  drivers/media/platform/davinci/vpbe.c | 5 ++---
>>  1 file changed, 2 insertions(+), 3 deletions(-)
>>
>> diff --git a/drivers/media/platform/davinci/vpbe.c 
>> b/drivers/media/platform/davinci/vpbe.c
>> index 19611a2..6e7b0df 100644
>> --- a/drivers/media/platform/davinci/vpbe.c
>> +++ b/drivers/media/platform/davinci/vpbe.c
>> @@ -227,7 +227,6 @@ static int vpbe_set_output(struct vpbe_device *vpbe_dev, 
>> int index)
>>  vpbe_current_encoder_info(vpbe_dev);
>>  struct vpbe_config *cfg = vpbe_dev->cfg;
>>  struct venc_platform_data *venc_device = vpbe_dev->venc_device;
>> -u32 if_params;
>>  int enc_out_index;
>>  int sd_index;
>>  int ret = 0;
>> @@ -257,8 +256,8 @@ static int vpbe_set_output(struct vpbe_device *vpbe_dev, 
>> int index)
>>  goto out;
>>  }
>>
>> -if_params = cfg->outputs[index].if_params;
>> -venc_device->setup_if_config(if_params);
>> +ret = venc_device->setup_if_config(cfg
>> +   ->outputs[index].if_params);
> 
> Either keep this as one line

Will you tolerate a line length of 82 characters then?


> or keep the if_params temp variable.

My proposal was to get rid of it.


> This odd linebreak is ugly.

I am curious on how the desired changes can be integrated after a couple of 
update
suggestions were accepted from this patch series.

Regards,
Markus
--
To unsubscribe from this list: send the line "unsubscribe linux-media" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH 17/34] [media] DaVinci-VPFE-Capture: Improve another size determination in vpfe_enum_input()

2016-11-03 Thread SF Markus Elfring
>> @@ -1091,7 +1091,7 @@ static int vpfe_enum_input(struct file *file, void 
>> *priv,
>>  return -EINVAL;
>>  }
>>  sdinfo = _dev->cfg->sub_devs[subdev];
>> -memcpy(inp, >inputs[index], sizeof(struct v4l2_input));
>> +memcpy(inp, >inputs[index], sizeof(*inp));
> 
> If I am not mistaken this can be written as:
> 
> *inp = sdinfo->inputs[index];
> 
> Much better.

At which position would you like to integrate a second approach for such a 
change
from this patch series?

* Do you expect me to send a "V2" for the whole series?

* Will an update step be appropriate if I would rebase it on other
  recently accepted suggestions?

Regards,
Markus
--
To unsubscribe from this list: send the line "unsubscribe linux-media" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 16/18] [media] RedRat3: Move a variable assignment in redrat3_set_timeout()

2016-10-13 Thread SF Markus Elfring
From: Markus Elfring 
Date: Thu, 13 Oct 2016 17:13:41 +0200

Move the assignment for the local variable "rr3" behind the source code
for a memory allocation by this function.

Signed-off-by: Markus Elfring 
---
 drivers/media/rc/redrat3.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/drivers/media/rc/redrat3.c b/drivers/media/rc/redrat3.c
index e46a92a..06c9eea 100644
--- a/drivers/media/rc/redrat3.c
+++ b/drivers/media/rc/redrat3.c
@@ -475,7 +475,7 @@ static u32 redrat3_get_timeout(struct redrat3_dev *rr3)
 
 static int redrat3_set_timeout(struct rc_dev *rc_dev, unsigned int timeoutns)
 {
-   struct redrat3_dev *rr3 = rc_dev->priv;
+   struct redrat3_dev *rr3;
__be32 *timeout;
int ret;
 
@@ -484,6 +484,7 @@ static int redrat3_set_timeout(struct rc_dev *rc_dev, 
unsigned int timeoutns)
return -ENOMEM;
 
*timeout = cpu_to_be32(redrat3_us_to_len(timeoutns / 1000));
+   rr3 = rc_dev->priv;
ret = usb_control_msg(rr3->udev,
  usb_sndctrlpipe(rr3->udev, 0),
  RR3_SET_IR_PARAM,
-- 
2.10.1

--
To unsubscribe from this list: send the line "unsubscribe linux-media" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 12/18] [media] RedRat3: Move a variable assignment in redrat3_init_rc_dev()

2016-10-13 Thread SF Markus Elfring
From: Markus Elfring 
Date: Thu, 13 Oct 2016 14:50:05 +0200

Move the assignment for the local variable "prod" behind the source code
for a memory allocation by this function.

Signed-off-by: Markus Elfring 
---
 drivers/media/rc/redrat3.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/drivers/media/rc/redrat3.c b/drivers/media/rc/redrat3.c
index b23a8bb..002030f 100644
--- a/drivers/media/rc/redrat3.c
+++ b/drivers/media/rc/redrat3.c
@@ -856,12 +856,13 @@ static struct rc_dev *redrat3_init_rc_dev(struct 
redrat3_dev *rr3)
 {
struct rc_dev *rc;
int ret;
-   u16 prod = le16_to_cpu(rr3->udev->descriptor.idProduct);
+   u16 prod;
 
rc = rc_allocate_device();
if (!rc)
goto out;
 
+   prod = le16_to_cpu(rr3->udev->descriptor.idProduct);
snprintf(rr3->name, sizeof(rr3->name), "RedRat3%s "
 "Infrared Remote Transceiver (%04x:%04x)",
 prod == USB_RR3IIUSB_PRODUCT_ID ? "-II" : "",
-- 
2.10.1

--
To unsubscribe from this list: send the line "unsubscribe linux-media" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 18/18] [media] RedRat3: Combine substrings for six messages

2016-10-13 Thread SF Markus Elfring
From: Markus Elfring 
Date: Thu, 13 Oct 2016 17:50:11 +0200

The script "checkpatch.pl" pointed information out like the following.

WARNING: quoted string split across lines

Thus fix the affected source code places.

Signed-off-by: Markus Elfring 
---
 drivers/media/rc/redrat3.c | 19 +++
 1 file changed, 7 insertions(+), 12 deletions(-)

diff --git a/drivers/media/rc/redrat3.c b/drivers/media/rc/redrat3.c
index a09d5cb..b8c4b98 100644
--- a/drivers/media/rc/redrat3.c
+++ b/drivers/media/rc/redrat3.c
@@ -233,8 +233,7 @@ static void redrat3_dump_fw_error(struct redrat3_dev *rr3, 
int code)
 
/* Codes 0x20 through 0x2f are IR Firmware Errors */
case 0x20:
-   pr_cont("Initial signal pulse not long enough "
-   "to measure carrier frequency\n");
+   pr_cont("Initial signal pulse not long enough to measure 
carrier frequency\n");
break;
case 0x21:
pr_cont("Not enough length values allocated for signal\n");
@@ -246,18 +245,15 @@ static void redrat3_dump_fw_error(struct redrat3_dev 
*rr3, int code)
pr_cont("Too many signal repeats\n");
break;
case 0x28:
-   pr_cont("Insufficient memory available for IR signal "
-   "data memory allocation\n");
+   pr_cont("Insufficient memory available for IR signal data 
memory allocation\n");
break;
case 0x29:
-   pr_cont("Insufficient memory available "
-   "for IrDa signal data memory allocation\n");
+   pr_cont("Insufficient memory available for IrDa signal data 
memory allocation\n");
break;
 
/* Codes 0x30 through 0x3f are USB Firmware Errors */
case 0x30:
-   pr_cont("Insufficient memory available for bulk "
-   "transfer structure\n");
+   pr_cont("Insufficient memory available for bulk transfer 
structure\n");
break;
 
/*
@@ -269,8 +265,7 @@ static void redrat3_dump_fw_error(struct redrat3_dev *rr3, 
int code)
pr_cont("Signal capture has been terminated\n");
break;
case 0x41:
-   pr_cont("Attempt to set/get and unknown signal I/O "
-   "algorithm parameter\n");
+   pr_cont("Attempt to set/get and unknown signal I/O algorithm 
parameter\n");
break;
case 0x42:
pr_cont("Signal capture already started\n");
@@ -866,8 +861,8 @@ static struct rc_dev *redrat3_init_rc_dev(struct 
redrat3_dev *rr3)
return NULL;
 
prod = le16_to_cpu(rr3->udev->descriptor.idProduct);
-   snprintf(rr3->name, sizeof(rr3->name), "RedRat3%s "
-"Infrared Remote Transceiver (%04x:%04x)",
+   snprintf(rr3->name, sizeof(rr3->name),
+"RedRat3%s Infrared Remote Transceiver (%04x:%04x)",
 prod == USB_RR3IIUSB_PRODUCT_ID ? "-II" : "",
 le16_to_cpu(rr3->udev->descriptor.idVendor), prod);
 
-- 
2.10.1

--
To unsubscribe from this list: send the line "unsubscribe linux-media" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


  1   2   3   4   5   6   >