linux-arm-kernel.lists.infradead.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 1/1] [media] platform: Deletion of unnecessary checks before two function calls
       [not found]                               ` <5317A59D.4@users.sourceforge.net>
@ 2014-11-20 10:50                                 ` SF Markus Elfring
  2014-11-20 13:50                                 ` [PATCH 1/1] net: Xilinx: " SF Markus Elfring
                                                   ` (17 subsequent siblings)
  18 siblings, 0 replies; 64+ messages in thread
From: SF Markus Elfring @ 2014-11-20 10:50 UTC (permalink / raw)
  To: linux-arm-kernel

From: Markus Elfring <elfring@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 <elfring@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

^ permalink raw reply related	[flat|nested] 64+ messages in thread

* [PATCH 1/1] net: Xilinx: Deletion of unnecessary checks before two function calls
       [not found]                               ` <5317A59D.4@users.sourceforge.net>
  2014-11-20 10:50                                 ` [PATCH 1/1] [media] platform: Deletion of unnecessary checks before two function calls SF Markus Elfring
@ 2014-11-20 13:50                                 ` SF Markus Elfring
  2014-11-20 17:29                                   ` Sören Brinkmann
  2014-11-21 20:14                                   ` David Miller
  2014-11-21 10:12                                 ` [PATCH 1/1] thermal: Exynos: " SF Markus Elfring
                                                   ` (16 subsequent siblings)
  18 siblings, 2 replies; 64+ messages in thread
From: SF Markus Elfring @ 2014-11-20 13:50 UTC (permalink / raw)
  To: linux-arm-kernel

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Thu, 20 Nov 2014 14:47:12 +0100

The functions kfree() and of_node_put() 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 <elfring@users.sourceforge.net>
---
 drivers/net/ethernet/xilinx/ll_temac_main.c   | 3 +--
 drivers/net/ethernet/xilinx/xilinx_emaclite.c | 3 +--
 2 files changed, 2 insertions(+), 4 deletions(-)

diff --git a/drivers/net/ethernet/xilinx/ll_temac_main.c b/drivers/net/ethernet/xilinx/ll_temac_main.c
index fda5891..af60867 100644
--- a/drivers/net/ethernet/xilinx/ll_temac_main.c
+++ b/drivers/net/ethernet/xilinx/ll_temac_main.c
@@ -224,8 +224,7 @@ static void temac_dma_bd_release(struct net_device *ndev)
 		dma_free_coherent(ndev->dev.parent,
 				sizeof(*lp->tx_bd_v) * TX_BD_NUM,
 				lp->tx_bd_v, lp->tx_bd_p);
-	if (lp->rx_skb)
-		kfree(lp->rx_skb);
+	kfree(lp->rx_skb);
 }
 
 /**
diff --git a/drivers/net/ethernet/xilinx/xilinx_emaclite.c b/drivers/net/ethernet/xilinx/xilinx_emaclite.c
index 28dbbdc..2485879 100644
--- a/drivers/net/ethernet/xilinx/xilinx_emaclite.c
+++ b/drivers/net/ethernet/xilinx/xilinx_emaclite.c
@@ -1200,8 +1200,7 @@ static int xemaclite_of_remove(struct platform_device *of_dev)
 
 	unregister_netdev(ndev);
 
-	if (lp->phy_node)
-		of_node_put(lp->phy_node);
+	of_node_put(lp->phy_node);
 	lp->phy_node = NULL;
 
 	xemaclite_remove_ndev(ndev);
-- 
2.1.3

^ permalink raw reply related	[flat|nested] 64+ messages in thread

* [PATCH 1/1] net: Xilinx: Deletion of unnecessary checks before two function calls
  2014-11-20 13:50                                 ` [PATCH 1/1] net: Xilinx: " SF Markus Elfring
@ 2014-11-20 17:29                                   ` Sören Brinkmann
  2014-11-21 20:14                                   ` David Miller
  1 sibling, 0 replies; 64+ messages in thread
From: Sören Brinkmann @ 2014-11-20 17:29 UTC (permalink / raw)
  To: linux-arm-kernel

On Thu, 2014-11-20 at 02:50PM +0100, SF Markus Elfring wrote:
> From: Markus Elfring <elfring@users.sourceforge.net>
> Date: Thu, 20 Nov 2014 14:47:12 +0100
> 
> The functions kfree() and of_node_put() 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 <elfring@users.sourceforge.net>
Reviewed-by: Soren Brinkmann <soren.brinkmann@xilinx.com>

	S?ren

^ permalink raw reply	[flat|nested] 64+ messages in thread

* [PATCH 1/1] thermal: Exynos: Deletion of unnecessary checks before two function calls
       [not found]                               ` <5317A59D.4@users.sourceforge.net>
  2014-11-20 10:50                                 ` [PATCH 1/1] [media] platform: Deletion of unnecessary checks before two function calls SF Markus Elfring
  2014-11-20 13:50                                 ` [PATCH 1/1] net: Xilinx: " SF Markus Elfring
@ 2014-11-21 10:12                                 ` SF Markus Elfring
  2014-11-21 10:17                                   ` Julia Lawall
  2014-11-22 10:00                                 ` [PATCH 1/1] ARM: OMAP2: Deletion of unnecessary checks before three " SF Markus Elfring
                                                   ` (15 subsequent siblings)
  18 siblings, 1 reply; 64+ messages in thread
From: SF Markus Elfring @ 2014-11-21 10:12 UTC (permalink / raw)
  To: linux-arm-kernel

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Fri, 21 Nov 2014 11:06:33 +0100

The functions cpufreq_cooling_unregister() and thermal_zone_device_unregister()
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 <elfring@users.sourceforge.net>
---
 drivers/thermal/samsung/exynos_thermal_common.c | 6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)

diff --git a/drivers/thermal/samsung/exynos_thermal_common.c b/drivers/thermal/samsung/exynos_thermal_common.c
index 3f5ad25..1cbb9d0 100644
--- a/drivers/thermal/samsung/exynos_thermal_common.c
+++ b/drivers/thermal/samsung/exynos_thermal_common.c
@@ -417,12 +417,10 @@ void exynos_unregister_thermal(struct thermal_sensor_conf *sensor_conf)
 
 	th_zone = sensor_conf->pzone_data;
 
-	if (th_zone->therm_dev)
-		thermal_zone_device_unregister(th_zone->therm_dev);
+	thermal_zone_device_unregister(th_zone->therm_dev);
 
 	for (i = 0; i < th_zone->cool_dev_size; i++) {
-		if (th_zone->cool_dev[i])
-			cpufreq_cooling_unregister(th_zone->cool_dev[i]);
+		cpufreq_cooling_unregister(th_zone->cool_dev[i]);
 	}
 
 	dev_info(sensor_conf->dev,
-- 
2.1.3

^ permalink raw reply related	[flat|nested] 64+ messages in thread

* [PATCH 1/1] thermal: Exynos: Deletion of unnecessary checks before two function calls
  2014-11-21 10:12                                 ` [PATCH 1/1] thermal: Exynos: " SF Markus Elfring
@ 2014-11-21 10:17                                   ` Julia Lawall
  2014-11-21 13:25                                     ` SF Markus Elfring
  2014-11-21 16:17                                     ` [PATCH v2] " SF Markus Elfring
  0 siblings, 2 replies; 64+ messages in thread
From: Julia Lawall @ 2014-11-21 10:17 UTC (permalink / raw)
  To: linux-arm-kernel

On Fri, 21 Nov 2014, SF Markus Elfring wrote:

> From: Markus Elfring <elfring@users.sourceforge.net>
> Date: Fri, 21 Nov 2014 11:06:33 +0100
>
> The functions cpufreq_cooling_unregister() and thermal_zone_device_unregister()
> 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 <elfring@users.sourceforge.net>
> ---
>  drivers/thermal/samsung/exynos_thermal_common.c | 6 ++----
>  1 file changed, 2 insertions(+), 4 deletions(-)
>
> diff --git a/drivers/thermal/samsung/exynos_thermal_common.c b/drivers/thermal/samsung/exynos_thermal_common.c
> index 3f5ad25..1cbb9d0 100644
> --- a/drivers/thermal/samsung/exynos_thermal_common.c
> +++ b/drivers/thermal/samsung/exynos_thermal_common.c
> @@ -417,12 +417,10 @@ void exynos_unregister_thermal(struct thermal_sensor_conf *sensor_conf)
>
>  	th_zone = sensor_conf->pzone_data;
>
> -	if (th_zone->therm_dev)
> -		thermal_zone_device_unregister(th_zone->therm_dev);
> +	thermal_zone_device_unregister(th_zone->therm_dev);
>
>  	for (i = 0; i < th_zone->cool_dev_size; i++) {
> -		if (th_zone->cool_dev[i])
> -			cpufreq_cooling_unregister(th_zone->cool_dev[i]);
> +		cpufreq_cooling_unregister(th_zone->cool_dev[i]);
>  	}

Now you have unnecessary {}

julia

>
>  	dev_info(sensor_conf->dev,
> --
> 2.1.3
>
>

^ permalink raw reply	[flat|nested] 64+ messages in thread

* thermal: Exynos: Deletion of unnecessary checks before two function calls
  2014-11-21 10:17                                   ` Julia Lawall
@ 2014-11-21 13:25                                     ` SF Markus Elfring
  2014-11-21 16:17                                     ` [PATCH v2] " SF Markus Elfring
  1 sibling, 0 replies; 64+ messages in thread
From: SF Markus Elfring @ 2014-11-21 13:25 UTC (permalink / raw)
  To: linux-arm-kernel

>>  	for (i = 0; i < th_zone->cool_dev_size; i++) {
>> -		if (th_zone->cool_dev[i])
>> -			cpufreq_cooling_unregister(th_zone->cool_dev[i]);
>> +		cpufreq_cooling_unregister(th_zone->cool_dev[i]);
>>  	}
> 
> Now you have unnecessary {}

How are the chances that your source code transformation tool
can also consider the deletion of curly brackets in such an use case?

Can any more pretty-printing rules be integrated from a specific
coding style configuration?

Regards,
Markus

^ permalink raw reply	[flat|nested] 64+ messages in thread

* [PATCH v2] thermal: Exynos: Deletion of unnecessary checks before two function calls
  2014-11-21 10:17                                   ` Julia Lawall
  2014-11-21 13:25                                     ` SF Markus Elfring
@ 2014-11-21 16:17                                     ` SF Markus Elfring
  1 sibling, 0 replies; 64+ messages in thread
From: SF Markus Elfring @ 2014-11-21 16:17 UTC (permalink / raw)
  To: linux-arm-kernel

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Fri, 21 Nov 2014 17:11:49 +0100

The functions cpufreq_cooling_unregister() and thermal_zone_device_unregister()
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 <elfring@users.sourceforge.net>
---
 drivers/thermal/samsung/exynos_thermal_common.c | 9 +++------
 1 file changed, 3 insertions(+), 6 deletions(-)

diff --git a/drivers/thermal/samsung/exynos_thermal_common.c b/drivers/thermal/samsung/exynos_thermal_common.c
index 3f5ad25..b6be572 100644
--- a/drivers/thermal/samsung/exynos_thermal_common.c
+++ b/drivers/thermal/samsung/exynos_thermal_common.c
@@ -417,13 +417,10 @@ void exynos_unregister_thermal(struct thermal_sensor_conf *sensor_conf)
 
 	th_zone = sensor_conf->pzone_data;
 
-	if (th_zone->therm_dev)
-		thermal_zone_device_unregister(th_zone->therm_dev);
+	thermal_zone_device_unregister(th_zone->therm_dev);
 
-	for (i = 0; i < th_zone->cool_dev_size; i++) {
-		if (th_zone->cool_dev[i])
-			cpufreq_cooling_unregister(th_zone->cool_dev[i]);
-	}
+	for (i = 0; i < th_zone->cool_dev_size; ++i)
+		cpufreq_cooling_unregister(th_zone->cool_dev[i]);
 
 	dev_info(sensor_conf->dev,
 		"Exynos: Kernel Thermal management unregistered\n");
-- 
2.1.3

^ permalink raw reply related	[flat|nested] 64+ messages in thread

* [PATCH 1/1] net: Xilinx: Deletion of unnecessary checks before two function calls
  2014-11-20 13:50                                 ` [PATCH 1/1] net: Xilinx: " SF Markus Elfring
  2014-11-20 17:29                                   ` Sören Brinkmann
@ 2014-11-21 20:14                                   ` David Miller
  1 sibling, 0 replies; 64+ messages in thread
From: David Miller @ 2014-11-21 20:14 UTC (permalink / raw)
  To: linux-arm-kernel

From: SF Markus Elfring <elfring@users.sourceforge.net>
Date: Thu, 20 Nov 2014 14:50:26 +0100

> From: Markus Elfring <elfring@users.sourceforge.net>
> Date: Thu, 20 Nov 2014 14:47:12 +0100
> 
> The functions kfree() and of_node_put() 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 <elfring@users.sourceforge.net>

Applied.

^ permalink raw reply	[flat|nested] 64+ messages in thread

* [PATCH 1/1] ARM: OMAP2: Deletion of unnecessary checks before three function calls
       [not found]                               ` <5317A59D.4@users.sourceforge.net>
                                                   ` (2 preceding siblings ...)
  2014-11-21 10:12                                 ` [PATCH 1/1] thermal: Exynos: " SF Markus Elfring
@ 2014-11-22 10:00                                 ` SF Markus Elfring
  2015-06-30 12:10                                   ` [PATCH] ARM: OMAP2: Delete " SF Markus Elfring
  2014-11-22 10:40                                 ` [PATCH 1/1] ARM-kernel: Deletion of unnecessary checks before two " SF Markus Elfring
                                                   ` (14 subsequent siblings)
  18 siblings, 1 reply; 64+ messages in thread
From: SF Markus Elfring @ 2014-11-22 10:00 UTC (permalink / raw)
  To: linux-arm-kernel

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Sat, 22 Nov 2014 10:50:33 +0100

The functions clk_disable(), of_node_put() and omap_device_delete() 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 <elfring@users.sourceforge.net>
---
 arch/arm/mach-omap2/omap_device.c | 3 +--
 arch/arm/mach-omap2/omap_hwmod.c  | 3 +--
 arch/arm/mach-omap2/timer.c       | 3 +--
 3 files changed, 3 insertions(+), 6 deletions(-)

diff --git a/arch/arm/mach-omap2/omap_device.c b/arch/arm/mach-omap2/omap_device.c
index d22c30d..5108859 100644
--- a/arch/arm/mach-omap2/omap_device.c
+++ b/arch/arm/mach-omap2/omap_device.c
@@ -199,8 +199,7 @@ static int _omap_device_notifier_call(struct notifier_block *nb,
 
 	switch (event) {
 	case BUS_NOTIFY_DEL_DEVICE:
-		if (pdev->archdata.od)
-			omap_device_delete(pdev->archdata.od);
+		omap_device_delete(pdev->archdata.od);
 		break;
 	case BUS_NOTIFY_ADD_DEVICE:
 		if (pdev->dev.of_node)
diff --git a/arch/arm/mach-omap2/omap_hwmod.c b/arch/arm/mach-omap2/omap_hwmod.c
index 9e91a4e..e2406c4 100644
--- a/arch/arm/mach-omap2/omap_hwmod.c
+++ b/arch/arm/mach-omap2/omap_hwmod.c
@@ -917,8 +917,7 @@ static int _disable_clocks(struct omap_hwmod *oh)
 
 	pr_debug("omap_hwmod: %s: disabling clocks\n", oh->name);
 
-	if (oh->_clk)
-		clk_disable(oh->_clk);
+	clk_disable(oh->_clk);
 
 	p = oh->slave_ports.next;
 
diff --git a/arch/arm/mach-omap2/timer.c b/arch/arm/mach-omap2/timer.c
index 43d03fb..5b428a0 100644
--- a/arch/arm/mach-omap2/timer.c
+++ b/arch/arm/mach-omap2/timer.c
@@ -205,8 +205,7 @@ static void __init omap_dmtimer_init(void)
 	/* If we are a secure device, remove any secure timer nodes */
 	if ((omap_type() != OMAP2_DEVICE_TYPE_GP)) {
 		np = omap_get_timer_dt(omap_timer_match, "ti,timer-secure");
-		if (np)
-			of_node_put(np);
+		of_node_put(np);
 	}
 }
 
-- 
2.1.3

^ permalink raw reply related	[flat|nested] 64+ messages in thread

* [PATCH 1/1] ARM-kernel: Deletion of unnecessary checks before two function calls
       [not found]                               ` <5317A59D.4@users.sourceforge.net>
                                                   ` (3 preceding siblings ...)
  2014-11-22 10:00                                 ` [PATCH 1/1] ARM: OMAP2: Deletion of unnecessary checks before three " SF Markus Elfring
@ 2014-11-22 10:40                                 ` SF Markus Elfring
  2014-12-03  8:15                                 ` [PATCH] ARM: DaVinci: Deletion of an unnecessary check before the function call "__clk_disable" SF Markus Elfring
                                                   ` (13 subsequent siblings)
  18 siblings, 0 replies; 64+ messages in thread
From: SF Markus Elfring @ 2014-11-22 10:40 UTC (permalink / raw)
  To: linux-arm-kernel

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Sat, 22 Nov 2014 11:33:16 +0100

The functions smp_set_ops() and unwind_table_del() 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 <elfring@users.sourceforge.net>
---
 arch/arm/kernel/module.c | 3 +--
 arch/arm/kernel/setup.c  | 2 +-
 2 files changed, 2 insertions(+), 3 deletions(-)

diff --git a/arch/arm/kernel/module.c b/arch/arm/kernel/module.c
index 6a4dffe..3dffad1 100644
--- a/arch/arm/kernel/module.c
+++ b/arch/arm/kernel/module.c
@@ -350,7 +350,6 @@ module_arch_cleanup(struct module *mod)
 	int i;
 
 	for (i = 0; i < ARM_SEC_MAX; i++)
-		if (mod->arch.unwind[i])
-			unwind_table_del(mod->arch.unwind[i]);
+		unwind_table_del(mod->arch.unwind[i]);
 #endif
 }
diff --git a/arch/arm/kernel/setup.c b/arch/arm/kernel/setup.c
index 84db893d..a7018a2 100644
--- a/arch/arm/kernel/setup.c
+++ b/arch/arm/kernel/setup.c
@@ -929,7 +929,7 @@ void __init setup_arch(char **cmdline_p)
 		if (!mdesc->smp_init || !mdesc->smp_init()) {
 			if (psci_smp_available())
 				smp_set_ops(&psci_smp_ops);
-			else if (mdesc->smp)
+			else
 				smp_set_ops(mdesc->smp);
 		}
 		smp_init_cpus();
-- 
2.1.3

^ permalink raw reply related	[flat|nested] 64+ messages in thread

* [PATCH] ARM: DaVinci: Deletion of an unnecessary check before the function call "__clk_disable"
       [not found]                               ` <5317A59D.4@users.sourceforge.net>
                                                   ` (4 preceding siblings ...)
  2014-11-22 10:40                                 ` [PATCH 1/1] ARM-kernel: Deletion of unnecessary checks before two " SF Markus Elfring
@ 2014-12-03  8:15                                 ` SF Markus Elfring
  2014-12-03  9:10                                   ` SF Markus Elfring
  2015-02-04 21:00                                 ` [PATCH] GPU-DRM-Exynos: Delete unnecessary checks before two function calls SF Markus Elfring
                                                   ` (12 subsequent siblings)
  18 siblings, 1 reply; 64+ messages in thread
From: SF Markus Elfring @ 2014-12-03  8:15 UTC (permalink / raw)
  To: linux-arm-kernel

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Wed, 3 Dec 2014 09:01:33 +0100

The __clk_disable() 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 <elfring@users.sourceforge.net>
---
 arch/arm/mach-davinci/clock.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/arch/arm/mach-davinci/clock.c b/arch/arm/mach-davinci/clock.c
index c70bb0a..8f2c2d8 100644
--- a/arch/arm/mach-davinci/clock.c
+++ b/arch/arm/mach-davinci/clock.c
@@ -55,8 +55,7 @@ static void __clk_disable(struct clk *clk)
 		else if (clk->clk_disable)
 			clk->clk_disable(clk);
 	}
-	if (clk->parent)
-		__clk_disable(clk->parent);
+	__clk_disable(clk->parent);
 }
 
 int davinci_clk_reset(struct clk *clk, bool reset)
-- 
2.1.3

^ permalink raw reply related	[flat|nested] 64+ messages in thread

* ARM: DaVinci: Deletion of an unnecessary check before the function call "__clk_disable"
  2014-12-03  8:15                                 ` [PATCH] ARM: DaVinci: Deletion of an unnecessary check before the function call "__clk_disable" SF Markus Elfring
@ 2014-12-03  9:10                                   ` SF Markus Elfring
  0 siblings, 0 replies; 64+ messages in thread
From: SF Markus Elfring @ 2014-12-03  9:10 UTC (permalink / raw)
  To: linux-arm-kernel

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

I was a bit too quick to send you this notification. I stumbled once more
on the detail that my source code analysis approach is incomplete for
static functions so far.

https://git.kernel.org/cgit/linux/kernel/git/next/linux-next.git/tree/arch/arm/mach-davinci/clock.c?id=a7ca2bcf2d2ef15c343a12f2a4c2e06380a0f495#n47
https://git.kernel.org/cgit/linux/kernel/git/stable/linux-stable.git/tree/drivers/clk/clk.c?id=4dc7ed32f398fa76b9e1d243a852420b1dad0150#n846

I would like to apologise for confusion I introduced here.

Regards,
Markus

^ permalink raw reply	[flat|nested] 64+ messages in thread

* [PATCH] GPU-DRM-Exynos: Delete unnecessary checks before two function calls
       [not found]                               ` <5317A59D.4@users.sourceforge.net>
                                                   ` (5 preceding siblings ...)
  2014-12-03  8:15                                 ` [PATCH] ARM: DaVinci: Deletion of an unnecessary check before the function call "__clk_disable" SF Markus Elfring
@ 2015-02-04 21:00                                 ` SF Markus Elfring
  2015-02-05  8:29                                   ` Joonyoung Shim
  2015-06-25 11:33                                 ` [PATCH 0/2] ARM-OMAP2+: Deletion of unnecessary checks before two function calls SF Markus Elfring
                                                   ` (11 subsequent siblings)
  18 siblings, 1 reply; 64+ messages in thread
From: SF Markus Elfring @ 2015-02-04 21:00 UTC (permalink / raw)
  To: linux-arm-kernel

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Wed, 4 Feb 2015 21:54:45 +0100

The functions phy_power_on() and vunmap() perform also input
parameter validation. Thus the test around their calls is not needed.

This issue was detected by using the Coccinelle software.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 drivers/gpu/drm/exynos/exynos_dp_core.c   | 6 ++----
 drivers/gpu/drm/exynos/exynos_drm_fbdev.c | 2 +-
 2 files changed, 3 insertions(+), 5 deletions(-)

diff --git a/drivers/gpu/drm/exynos/exynos_dp_core.c b/drivers/gpu/drm/exynos/exynos_dp_core.c
index 34d46aa..306cf1d 100644
--- a/drivers/gpu/drm/exynos/exynos_dp_core.c
+++ b/drivers/gpu/drm/exynos/exynos_dp_core.c
@@ -1057,14 +1057,12 @@ static int exynos_dp_create_connector(struct exynos_drm_display *display,
 
 static void exynos_dp_phy_init(struct exynos_dp_device *dp)
 {
-	if (dp->phy)
-		phy_power_on(dp->phy);
+	phy_power_on(dp->phy);
 }
 
 static void exynos_dp_phy_exit(struct exynos_dp_device *dp)
 {
-	if (dp->phy)
-		phy_power_off(dp->phy);
+	phy_power_off(dp->phy);
 }
 
 static void exynos_dp_poweron(struct exynos_drm_display *display)
diff --git a/drivers/gpu/drm/exynos/exynos_drm_fbdev.c b/drivers/gpu/drm/exynos/exynos_drm_fbdev.c
index e12ea90..0dd448a 100644
--- a/drivers/gpu/drm/exynos/exynos_drm_fbdev.c
+++ b/drivers/gpu/drm/exynos/exynos_drm_fbdev.c
@@ -313,7 +313,7 @@ static void exynos_drm_fbdev_destroy(struct drm_device *dev,
 	struct exynos_drm_gem_obj *exynos_gem_obj = exynos_fbd->exynos_gem_obj;
 	struct drm_framebuffer *fb;
 
-	if (is_drm_iommu_supported(dev) && exynos_gem_obj->buffer->kvaddr)
+	if (is_drm_iommu_supported(dev))
 		vunmap(exynos_gem_obj->buffer->kvaddr);
 
 	/* release drm framebuffer and real buffer */
-- 
2.2.2

^ permalink raw reply related	[flat|nested] 64+ messages in thread

* [PATCH] GPU-DRM-Exynos: Delete unnecessary checks before two function calls
  2015-02-04 21:00                                 ` [PATCH] GPU-DRM-Exynos: Delete unnecessary checks before two function calls SF Markus Elfring
@ 2015-02-05  8:29                                   ` Joonyoung Shim
  2015-06-27 17:17                                     ` SF Markus Elfring
  2016-07-21 17:42                                     ` [PATCH] GPU-DRM-Exynos: Delete an unnecessary check before the function call "vunmap" SF Markus Elfring
  0 siblings, 2 replies; 64+ messages in thread
From: Joonyoung Shim @ 2015-02-05  8:29 UTC (permalink / raw)
  To: linux-arm-kernel

Hi,

On 02/05/2015 06:00 AM, SF Markus Elfring wrote:
> From: Markus Elfring <elfring@users.sourceforge.net>
> Date: Wed, 4 Feb 2015 21:54:45 +0100
> 
> The functions phy_power_on() and vunmap() perform also input
> parameter validation. Thus the test around their calls is not needed.
> 
> This issue was detected by using the Coccinelle software.
> 
> Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
> ---
>  drivers/gpu/drm/exynos/exynos_dp_core.c   | 6 ++----
>  drivers/gpu/drm/exynos/exynos_drm_fbdev.c | 2 +-
>  2 files changed, 3 insertions(+), 5 deletions(-)
> 
> diff --git a/drivers/gpu/drm/exynos/exynos_dp_core.c b/drivers/gpu/drm/exynos/exynos_dp_core.c
> index 34d46aa..306cf1d 100644
> --- a/drivers/gpu/drm/exynos/exynos_dp_core.c
> +++ b/drivers/gpu/drm/exynos/exynos_dp_core.c
> @@ -1057,14 +1057,12 @@ static int exynos_dp_create_connector(struct exynos_drm_display *display,
>  
>  static void exynos_dp_phy_init(struct exynos_dp_device *dp)
>  {
> -	if (dp->phy)
> -		phy_power_on(dp->phy);
> +	phy_power_on(dp->phy);
>  }
>  
>  static void exynos_dp_phy_exit(struct exynos_dp_device *dp)
>  {
> -	if (dp->phy)
> -		phy_power_off(dp->phy);
> +	phy_power_off(dp->phy);
>  }
>  
>  static void exynos_dp_poweron(struct exynos_drm_display *display)
> diff --git a/drivers/gpu/drm/exynos/exynos_drm_fbdev.c b/drivers/gpu/drm/exynos/exynos_drm_fbdev.c
> index e12ea90..0dd448a 100644
> --- a/drivers/gpu/drm/exynos/exynos_drm_fbdev.c
> +++ b/drivers/gpu/drm/exynos/exynos_drm_fbdev.c
> @@ -313,7 +313,7 @@ static void exynos_drm_fbdev_destroy(struct drm_device *dev,
>  	struct exynos_drm_gem_obj *exynos_gem_obj = exynos_fbd->exynos_gem_obj;
>  	struct drm_framebuffer *fb;
>  
> -	if (is_drm_iommu_supported(dev) && exynos_gem_obj->buffer->kvaddr)
> +	if (is_drm_iommu_supported(dev))
>  		vunmap(exynos_gem_obj->buffer->kvaddr);
>  
>  	/* release drm framebuffer and real buffer */
> 

Acked-by: Joonyoung Shim <jy0922.shim@samsung.com>

Thanks.

^ permalink raw reply	[flat|nested] 64+ messages in thread

* [PATCH 0/2] ARM-OMAP2+: Deletion of unnecessary checks before two function calls
       [not found]                               ` <5317A59D.4@users.sourceforge.net>
                                                   ` (6 preceding siblings ...)
  2015-02-04 21:00                                 ` [PATCH] GPU-DRM-Exynos: Delete unnecessary checks before two function calls SF Markus Elfring
@ 2015-06-25 11:33                                 ` SF Markus Elfring
  2015-06-25 11:38                                   ` [PATCH 1/2] ARM-OMAP2+: Delete an unnecessary check before the function call "omap_device_delete" SF Markus Elfring
                                                     ` (2 more replies)
  2015-06-25 13:27                                 ` [PATCH 0/2] ARM-kernel: " SF Markus Elfring
                                                   ` (10 subsequent siblings)
  18 siblings, 3 replies; 64+ messages in thread
From: SF Markus Elfring @ 2015-06-25 11:33 UTC (permalink / raw)
  To: linux-arm-kernel

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Thu, 25 Jun 2015 13:24:35 +0200

Some functions which release a system resource tolerate the passing
of a null pointer. I do not see a need because of this fact
that a function caller repeats a corresponding check.

Markus Elfring (2):
  Delete a check before the function call "omap_device_delete"
  Delete a check before the function call "of_node_put"

 arch/arm/mach-omap2/omap_device.c | 3 +--
 arch/arm/mach-omap2/timer.c       | 3 +--
 2 files changed, 2 insertions(+), 4 deletions(-)

-- 
2.4.4

^ permalink raw reply	[flat|nested] 64+ messages in thread

* [PATCH 1/2] ARM-OMAP2+: Delete an unnecessary check before the function call "omap_device_delete"
  2015-06-25 11:33                                 ` [PATCH 0/2] ARM-OMAP2+: Deletion of unnecessary checks before two function calls SF Markus Elfring
@ 2015-06-25 11:38                                   ` SF Markus Elfring
  2015-06-25 11:40                                   ` [PATCH 2/2] ARM-OMAP2+: Delete an unnecessary check before the function call "of_node_put" SF Markus Elfring
  2015-07-15  6:41                                   ` [PATCH 0/2] ARM-OMAP2+: Deletion of unnecessary checks before two function calls Tony Lindgren
  2 siblings, 0 replies; 64+ messages in thread
From: SF Markus Elfring @ 2015-06-25 11:38 UTC (permalink / raw)
  To: linux-arm-kernel

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Thu, 25 Jun 2015 13:00:11 +0200

The omap_device_delete() 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 <elfring@users.sourceforge.net>
---
 arch/arm/mach-omap2/omap_device.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/arch/arm/mach-omap2/omap_device.c b/arch/arm/mach-omap2/omap_device.c
index 4cb8fd9..196366e 100644
--- a/arch/arm/mach-omap2/omap_device.c
+++ b/arch/arm/mach-omap2/omap_device.c
@@ -193,8 +193,7 @@ static int _omap_device_notifier_call(struct notifier_block *nb,
 
 	switch (event) {
 	case BUS_NOTIFY_DEL_DEVICE:
-		if (pdev->archdata.od)
-			omap_device_delete(pdev->archdata.od);
+		omap_device_delete(pdev->archdata.od);
 		break;
 	case BUS_NOTIFY_ADD_DEVICE:
 		if (pdev->dev.of_node)
-- 
2.4.4

^ permalink raw reply related	[flat|nested] 64+ messages in thread

* [PATCH 2/2] ARM-OMAP2+: Delete an unnecessary check before the function call "of_node_put"
  2015-06-25 11:33                                 ` [PATCH 0/2] ARM-OMAP2+: Deletion of unnecessary checks before two function calls SF Markus Elfring
  2015-06-25 11:38                                   ` [PATCH 1/2] ARM-OMAP2+: Delete an unnecessary check before the function call "omap_device_delete" SF Markus Elfring
@ 2015-06-25 11:40                                   ` SF Markus Elfring
  2015-07-15  6:41                                   ` [PATCH 0/2] ARM-OMAP2+: Deletion of unnecessary checks before two function calls Tony Lindgren
  2 siblings, 0 replies; 64+ messages in thread
From: SF Markus Elfring @ 2015-06-25 11:40 UTC (permalink / raw)
  To: linux-arm-kernel

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Thu, 25 Jun 2015 13:05:28 +0200

The of_node_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 <elfring@users.sourceforge.net>
---
 arch/arm/mach-omap2/timer.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/arch/arm/mach-omap2/timer.c b/arch/arm/mach-omap2/timer.c
index cac46d8..15448221 100644
--- a/arch/arm/mach-omap2/timer.c
+++ b/arch/arm/mach-omap2/timer.c
@@ -208,8 +208,7 @@ static void __init omap_dmtimer_init(void)
 	/* If we are a secure device, remove any secure timer nodes */
 	if ((omap_type() != OMAP2_DEVICE_TYPE_GP)) {
 		np = omap_get_timer_dt(omap_timer_match, "ti,timer-secure");
-		if (np)
-			of_node_put(np);
+		of_node_put(np);
 	}
 }
 
-- 
2.4.4

^ permalink raw reply related	[flat|nested] 64+ messages in thread

* [PATCH 0/2] ARM-kernel: Deletion of unnecessary checks before two function calls
       [not found]                               ` <5317A59D.4@users.sourceforge.net>
                                                   ` (7 preceding siblings ...)
  2015-06-25 11:33                                 ` [PATCH 0/2] ARM-OMAP2+: Deletion of unnecessary checks before two function calls SF Markus Elfring
@ 2015-06-25 13:27                                 ` SF Markus Elfring
  2015-06-25 13:30                                   ` [PATCH 1/2] ARM-kernel: Delete an unnecessary check before the function call "smp_set_ops" SF Markus Elfring
  2015-06-25 13:32                                   ` [PATCH 2/2] ARM-kernel: Delete an unnecessary check before the function call "unwind_table_del" SF Markus Elfring
  2015-06-28 14:05                                 ` [PATCH] iommu/arm-smmu: Delete an unnecessary check before the function call "free_io_pgtable_ops" SF Markus Elfring
                                                   ` (9 subsequent siblings)
  18 siblings, 2 replies; 64+ messages in thread
From: SF Markus Elfring @ 2015-06-25 13:27 UTC (permalink / raw)
  To: linux-arm-kernel

From: Markus Elfring <elfring@users.sourceforge.net>

Some functions tolerate the passing of a null pointer. I do not see a need
because of this fact that a function caller repeats a corresponding check.

Markus Elfring (2):
  Delete a check before the function call "smp_set_ops"
  Delete a check before the function call "unwind_table_del"

 arch/arm/kernel/module.c | 3 +--
 arch/arm/kernel/setup.c  | 2 +-
 2 files changed, 2 insertions(+), 3 deletions(-)

-- 
2.4.4

^ permalink raw reply	[flat|nested] 64+ messages in thread

* [PATCH 1/2] ARM-kernel: Delete an unnecessary check before the function call "smp_set_ops"
  2015-06-25 13:27                                 ` [PATCH 0/2] ARM-kernel: " SF Markus Elfring
@ 2015-06-25 13:30                                   ` SF Markus Elfring
  2015-06-25 13:32                                   ` [PATCH 2/2] ARM-kernel: Delete an unnecessary check before the function call "unwind_table_del" SF Markus Elfring
  1 sibling, 0 replies; 64+ messages in thread
From: SF Markus Elfring @ 2015-06-25 13:30 UTC (permalink / raw)
  To: linux-arm-kernel

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Thu, 25 Jun 2015 15:00:17 +0200

The smp_set_ops() 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 <elfring@users.sourceforge.net>
---
 arch/arm/kernel/setup.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/arch/arm/kernel/setup.c b/arch/arm/kernel/setup.c
index e6d8c76..9ac786d 100644
--- a/arch/arm/kernel/setup.c
+++ b/arch/arm/kernel/setup.c
@@ -977,7 +977,7 @@ void __init setup_arch(char **cmdline_p)
 		if (!mdesc->smp_init || !mdesc->smp_init()) {
 			if (psci_smp_available())
 				smp_set_ops(&psci_smp_ops);
-			else if (mdesc->smp)
+			else
 				smp_set_ops(mdesc->smp);
 		}
 		smp_init_cpus();
-- 
2.4.4

^ permalink raw reply related	[flat|nested] 64+ messages in thread

* [PATCH 2/2] ARM-kernel: Delete an unnecessary check before the function call "unwind_table_del"
  2015-06-25 13:27                                 ` [PATCH 0/2] ARM-kernel: " SF Markus Elfring
  2015-06-25 13:30                                   ` [PATCH 1/2] ARM-kernel: Delete an unnecessary check before the function call "smp_set_ops" SF Markus Elfring
@ 2015-06-25 13:32                                   ` SF Markus Elfring
  1 sibling, 0 replies; 64+ messages in thread
From: SF Markus Elfring @ 2015-06-25 13:32 UTC (permalink / raw)
  To: linux-arm-kernel

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Thu, 25 Jun 2015 15:05:21 +0200

The unwind_table_del() 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 <elfring@users.sourceforge.net>
---
 arch/arm/kernel/module.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/arch/arm/kernel/module.c b/arch/arm/kernel/module.c
index efdddcb..0cc1afa 100644
--- a/arch/arm/kernel/module.c
+++ b/arch/arm/kernel/module.c
@@ -390,7 +390,6 @@ module_arch_cleanup(struct module *mod)
 	int i;
 
 	for (i = 0; i < ARM_SEC_MAX; i++)
-		if (mod->arch.unwind[i])
-			unwind_table_del(mod->arch.unwind[i]);
+		unwind_table_del(mod->arch.unwind[i]);
 #endif
 }
-- 
2.4.4

^ permalink raw reply related	[flat|nested] 64+ messages in thread

* [PATCH] GPU-DRM-Exynos: Delete unnecessary checks before two function calls
  2015-02-05  8:29                                   ` Joonyoung Shim
@ 2015-06-27 17:17                                     ` SF Markus Elfring
  2016-07-21 17:42                                     ` [PATCH] GPU-DRM-Exynos: Delete an unnecessary check before the function call "vunmap" SF Markus Elfring
  1 sibling, 0 replies; 64+ messages in thread
From: SF Markus Elfring @ 2015-06-27 17:17 UTC (permalink / raw)
  To: linux-arm-kernel

>> From: Markus Elfring <elfring@users.sourceforge.net>
>> Date: Wed, 4 Feb 2015 21:54:45 +0100
>>
>> The functions phy_power_on() and vunmap() perform also input
>> parameter validation. Thus the test around their calls is not needed.
>>
>> This issue was detected by using the Coccinelle software.
>>
>> Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
>> ---
>>  drivers/gpu/drm/exynos/exynos_dp_core.c   | 6 ++----
>>  drivers/gpu/drm/exynos/exynos_drm_fbdev.c | 2 +-
>>  2 files changed, 3 insertions(+), 5 deletions(-)
>>
>> diff --git a/drivers/gpu/drm/exynos/exynos_dp_core.c b/drivers/gpu/drm/exynos/exynos_dp_core.c
>> index 34d46aa..306cf1d 100644
>> --- a/drivers/gpu/drm/exynos/exynos_dp_core.c
>> +++ b/drivers/gpu/drm/exynos/exynos_dp_core.c
>> @@ -1057,14 +1057,12 @@ static int exynos_dp_create_connector(struct exynos_drm_display *display,
>>  
>>  static void exynos_dp_phy_init(struct exynos_dp_device *dp)
>>  {
>> -	if (dp->phy)
>> -		phy_power_on(dp->phy);
>> +	phy_power_on(dp->phy);
>>  }
>>  
>>  static void exynos_dp_phy_exit(struct exynos_dp_device *dp)
>>  {
>> -	if (dp->phy)
>> -		phy_power_off(dp->phy);
>> +	phy_power_off(dp->phy);
>>  }
>>  
>>  static void exynos_dp_poweron(struct exynos_drm_display *display)
>> diff --git a/drivers/gpu/drm/exynos/exynos_drm_fbdev.c b/drivers/gpu/drm/exynos/exynos_drm_fbdev.c
>> index e12ea90..0dd448a 100644
>> --- a/drivers/gpu/drm/exynos/exynos_drm_fbdev.c
>> +++ b/drivers/gpu/drm/exynos/exynos_drm_fbdev.c
>> @@ -313,7 +313,7 @@ static void exynos_drm_fbdev_destroy(struct drm_device *dev,
>>  	struct exynos_drm_gem_obj *exynos_gem_obj = exynos_fbd->exynos_gem_obj;
>>  	struct drm_framebuffer *fb;
>>  
>> -	if (is_drm_iommu_supported(dev) && exynos_gem_obj->buffer->kvaddr)
>> +	if (is_drm_iommu_supported(dev))
>>  		vunmap(exynos_gem_obj->buffer->kvaddr);
>>  
>>  	/* release drm framebuffer and real buffer */
>>
> 
> Acked-by: Joonyoung Shim <jy0922.shim@samsung.com>

Do the chances increase to integrate this update suggestion
into another source code repository?

Regards,
Markus

^ permalink raw reply	[flat|nested] 64+ messages in thread

* [PATCH] iommu/arm-smmu: Delete an unnecessary check before the function call "free_io_pgtable_ops"
       [not found]                               ` <5317A59D.4@users.sourceforge.net>
                                                   ` (8 preceding siblings ...)
  2015-06-25 13:27                                 ` [PATCH 0/2] ARM-kernel: " SF Markus Elfring
@ 2015-06-28 14:05                                 ` SF Markus Elfring
  2015-11-06 17:38                                   ` [PATCH] iommu/arm-smmu: Delete an unnecessary check before free_io_pgtable_ops() SF Markus Elfring
  2015-06-28 14:52                                 ` [PATCH] PCI-iproc: Delete unnecessary checks before two function calls SF Markus Elfring
                                                   ` (8 subsequent siblings)
  18 siblings, 1 reply; 64+ messages in thread
From: SF Markus Elfring @ 2015-06-28 14:05 UTC (permalink / raw)
  To: linux-arm-kernel

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Sun, 28 Jun 2015 15:55:11 +0200

The free_io_pgtable_ops() 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 <elfring@users.sourceforge.net>
---
 drivers/iommu/arm-smmu-v3.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/drivers/iommu/arm-smmu-v3.c b/drivers/iommu/arm-smmu-v3.c
index f141301..8e9ec81 100644
--- a/drivers/iommu/arm-smmu-v3.c
+++ b/drivers/iommu/arm-smmu-v3.c
@@ -1389,8 +1389,7 @@ static void arm_smmu_domain_free(struct iommu_domain *domain)
 	struct arm_smmu_domain *smmu_domain = to_smmu_domain(domain);
 	struct arm_smmu_device *smmu = smmu_domain->smmu;
 
-	if (smmu_domain->pgtbl_ops)
-		free_io_pgtable_ops(smmu_domain->pgtbl_ops);
+	free_io_pgtable_ops(smmu_domain->pgtbl_ops);
 
 	/* Free the CD and ASID, if we allocated them */
 	if (smmu_domain->stage == ARM_SMMU_DOMAIN_S1) {
-- 
2.4.4

^ permalink raw reply related	[flat|nested] 64+ messages in thread

* [PATCH] PCI-iproc: Delete unnecessary checks before two function calls
       [not found]                               ` <5317A59D.4@users.sourceforge.net>
                                                   ` (9 preceding siblings ...)
  2015-06-28 14:05                                 ` [PATCH] iommu/arm-smmu: Delete an unnecessary check before the function call "free_io_pgtable_ops" SF Markus Elfring
@ 2015-06-28 14:52                                 ` SF Markus Elfring
  2015-06-29 16:45                                   ` Ray Jui
  2015-07-14 20:10                                   ` Bjorn Helgaas
  2015-06-29 10:48                                 ` [PATCH] net-Liquidio: Delete unnecessary checks before the function call "vfree" SF Markus Elfring
                                                   ` (7 subsequent siblings)
  18 siblings, 2 replies; 64+ messages in thread
From: SF Markus Elfring @ 2015-06-28 14:52 UTC (permalink / raw)
  To: linux-arm-kernel

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Sun, 28 Jun 2015 16:42:04 +0200

The functions phy_exit() and phy_power_off() test whether their argument
is NULL and then return immediately.
Thus the test around the calls is not needed.

This issue was detected by using the Coccinelle software.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 drivers/pci/host/pcie-iproc.c | 7 ++-----
 1 file changed, 2 insertions(+), 5 deletions(-)

diff --git a/drivers/pci/host/pcie-iproc.c b/drivers/pci/host/pcie-iproc.c
index d77481e..f875821 100644
--- a/drivers/pci/host/pcie-iproc.c
+++ b/drivers/pci/host/pcie-iproc.c
@@ -239,12 +239,9 @@ err_rm_root_bus:
 	pci_remove_root_bus(bus);
 
 err_power_off_phy:
-	if (pcie->phy)
-		phy_power_off(pcie->phy);
+	phy_power_off(pcie->phy);
 err_exit_phy:
-	if (pcie->phy)
-		phy_exit(pcie->phy);
-
+	phy_exit(pcie->phy);
 	return ret;
 }
 EXPORT_SYMBOL(iproc_pcie_setup);
-- 
2.4.4

^ permalink raw reply related	[flat|nested] 64+ messages in thread

* [PATCH] net-Liquidio: Delete unnecessary checks before the function call "vfree"
       [not found]                               ` <5317A59D.4@users.sourceforge.net>
                                                   ` (10 preceding siblings ...)
  2015-06-28 14:52                                 ` [PATCH] PCI-iproc: Delete unnecessary checks before two function calls SF Markus Elfring
@ 2015-06-29 10:48                                 ` SF Markus Elfring
  2015-06-29 16:28                                   ` David Miller
  2015-11-05 16:17                                 ` [PATCH] pinctrl: Delete unnecessary checks before the function call "pinctrl_unregister" SF Markus Elfring
                                                   ` (6 subsequent siblings)
  18 siblings, 1 reply; 64+ messages in thread
From: SF Markus Elfring @ 2015-06-29 10:48 UTC (permalink / raw)
  To: linux-arm-kernel

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Mon, 29 Jun 2015 12:22:24 +0200

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 <elfring@users.sourceforge.net>
---
 drivers/net/ethernet/cavium/liquidio/octeon_device.c   | 11 +++--------
 drivers/net/ethernet/cavium/liquidio/octeon_droq.c     |  4 +---
 drivers/net/ethernet/cavium/liquidio/request_manager.c |  3 +--
 3 files changed, 5 insertions(+), 13 deletions(-)

diff --git a/drivers/net/ethernet/cavium/liquidio/octeon_device.c b/drivers/net/ethernet/cavium/liquidio/octeon_device.c
index 0d3106b..f67641a 100644
--- a/drivers/net/ethernet/cavium/liquidio/octeon_device.c
+++ b/drivers/net/ethernet/cavium/liquidio/octeon_device.c
@@ -650,14 +650,12 @@ void octeon_free_device_mem(struct octeon_device *oct)
 
 	for (i = 0; i < MAX_OCTEON_OUTPUT_QUEUES; i++) {
 		/* could check  mask as well */
-		if (oct->droq[i])
-			vfree(oct->droq[i]);
+		vfree(oct->droq[i]);
 	}
 
 	for (i = 0; i < MAX_OCTEON_INSTR_QUEUES; i++) {
 		/* could check mask as well */
-		if (oct->instr_queue[i])
-			vfree(oct->instr_queue[i]);
+		vfree(oct->instr_queue[i]);
 	}
 
 	i = oct->octeon_id;
@@ -1078,10 +1076,7 @@ octeon_unregister_dispatch_fn(struct octeon_device *oct, u16 opcode,
 		oct->dispatch.count--;
 
 	spin_unlock_bh(&oct->dispatch.lock);
-
-	if (dfree)
-		vfree(dfree);
-
+	vfree(dfree);
 	return retval;
 }
 
diff --git a/drivers/net/ethernet/cavium/liquidio/octeon_droq.c b/drivers/net/ethernet/cavium/liquidio/octeon_droq.c
index 94b502a..4dba86e 100644
--- a/drivers/net/ethernet/cavium/liquidio/octeon_droq.c
+++ b/drivers/net/ethernet/cavium/liquidio/octeon_droq.c
@@ -216,9 +216,7 @@ int octeon_delete_droq(struct octeon_device *oct, u32 q_no)
 	dev_dbg(&oct->pci_dev->dev, "%s[%d]\n", __func__, q_no);
 
 	octeon_droq_destroy_ring_buffers(oct, droq);
-
-	if (droq->recv_buf_list)
-		vfree(droq->recv_buf_list);
+	vfree(droq->recv_buf_list);
 
 	if (droq->info_base_addr)
 		cnnic_free_aligned_dma(oct->pci_dev, droq->info_list,
diff --git a/drivers/net/ethernet/cavium/liquidio/request_manager.c b/drivers/net/ethernet/cavium/liquidio/request_manager.c
index 356796b..a2a2465 100644
--- a/drivers/net/ethernet/cavium/liquidio/request_manager.c
+++ b/drivers/net/ethernet/cavium/liquidio/request_manager.c
@@ -175,8 +175,7 @@ int octeon_delete_instr_queue(struct octeon_device *oct, u32 iq_no)
 		desc_size =
 		    CFG_GET_IQ_INSTR_TYPE(CHIP_FIELD(oct, cn6xxx, conf));
 
-	if (iq->request_list)
-		vfree(iq->request_list);
+	vfree(iq->request_list);
 
 	if (iq->base_addr) {
 		q_size = iq->max_count * desc_size;
-- 
2.4.5

^ permalink raw reply related	[flat|nested] 64+ messages in thread

* [PATCH] net-Liquidio: Delete unnecessary checks before the function call "vfree"
  2015-06-29 10:48                                 ` [PATCH] net-Liquidio: Delete unnecessary checks before the function call "vfree" SF Markus Elfring
@ 2015-06-29 16:28                                   ` David Miller
  0 siblings, 0 replies; 64+ messages in thread
From: David Miller @ 2015-06-29 16:28 UTC (permalink / raw)
  To: linux-arm-kernel

From: SF Markus Elfring <elfring@users.sourceforge.net>
Date: Mon, 29 Jun 2015 12:48:16 +0200

> From: Markus Elfring <elfring@users.sourceforge.net>
> Date: Mon, 29 Jun 2015 12:22:24 +0200
> 
> 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 <elfring@users.sourceforge.net>

Applied.

^ permalink raw reply	[flat|nested] 64+ messages in thread

* [PATCH] PCI-iproc: Delete unnecessary checks before two function calls
  2015-06-28 14:52                                 ` [PATCH] PCI-iproc: Delete unnecessary checks before two function calls SF Markus Elfring
@ 2015-06-29 16:45                                   ` Ray Jui
  2015-07-14 20:10                                   ` Bjorn Helgaas
  1 sibling, 0 replies; 64+ messages in thread
From: Ray Jui @ 2015-06-29 16:45 UTC (permalink / raw)
  To: linux-arm-kernel

Hi Markus,

On 6/28/2015 7:52 AM, SF Markus Elfring wrote:
> From: Markus Elfring <elfring@users.sourceforge.net>
> Date: Sun, 28 Jun 2015 16:42:04 +0200
> 
> The functions phy_exit() and phy_power_off() test whether their argument
> is NULL and then return immediately.
> Thus the test around the calls is not needed.
> 
> This issue was detected by using the Coccinelle software.
> 
> Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
> ---
>  drivers/pci/host/pcie-iproc.c | 7 ++-----
>  1 file changed, 2 insertions(+), 5 deletions(-)
> 
> diff --git a/drivers/pci/host/pcie-iproc.c b/drivers/pci/host/pcie-iproc.c
> index d77481e..f875821 100644
> --- a/drivers/pci/host/pcie-iproc.c
> +++ b/drivers/pci/host/pcie-iproc.c
> @@ -239,12 +239,9 @@ err_rm_root_bus:
>  	pci_remove_root_bus(bus);
>  
>  err_power_off_phy:
> -	if (pcie->phy)
> -		phy_power_off(pcie->phy);
> +	phy_power_off(pcie->phy);
>  err_exit_phy:
> -	if (pcie->phy)
> -		phy_exit(pcie->phy);
> -
> +	phy_exit(pcie->phy);
>  	return ret;
>  }
>  EXPORT_SYMBOL(iproc_pcie_setup);
> 

Thanks for catching this. Could you please help to make similar changes
to both phy_init and phy_power_on calls in the driver, to make it
consistent?

Thanks,

Ray

^ permalink raw reply	[flat|nested] 64+ messages in thread

* [PATCH] ARM: OMAP2: Delete unnecessary checks before three function calls
  2014-11-22 10:00                                 ` [PATCH 1/1] ARM: OMAP2: Deletion of unnecessary checks before three " SF Markus Elfring
@ 2015-06-30 12:10                                   ` SF Markus Elfring
  2015-07-16  5:55                                     ` Paul Walmsley
  0 siblings, 1 reply; 64+ messages in thread
From: SF Markus Elfring @ 2015-06-30 12:10 UTC (permalink / raw)
  To: linux-arm-kernel

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Tue, 30 Jun 2015 14:00:16 +0200

The functions clk_disable(), of_node_put() and omap_device_delete() 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 <elfring@users.sourceforge.net>
---
 arch/arm/mach-omap2/omap_device.c | 3 +--
 arch/arm/mach-omap2/omap_hwmod.c  | 5 +----
 arch/arm/mach-omap2/timer.c       | 3 +--
 3 files changed, 3 insertions(+), 8 deletions(-)

diff --git a/arch/arm/mach-omap2/omap_device.c b/arch/arm/mach-omap2/omap_device.c
index 4cb8fd9..196366e 100644
--- a/arch/arm/mach-omap2/omap_device.c
+++ b/arch/arm/mach-omap2/omap_device.c
@@ -193,8 +193,7 @@ static int _omap_device_notifier_call(struct notifier_block *nb,
 
 	switch (event) {
 	case BUS_NOTIFY_DEL_DEVICE:
-		if (pdev->archdata.od)
-			omap_device_delete(pdev->archdata.od);
+		omap_device_delete(pdev->archdata.od);
 		break;
 	case BUS_NOTIFY_ADD_DEVICE:
 		if (pdev->dev.of_node)
diff --git a/arch/arm/mach-omap2/omap_hwmod.c b/arch/arm/mach-omap2/omap_hwmod.c
index d78c12e..1091ee7 100644
--- a/arch/arm/mach-omap2/omap_hwmod.c
+++ b/arch/arm/mach-omap2/omap_hwmod.c
@@ -921,10 +921,7 @@ static int _disable_clocks(struct omap_hwmod *oh)
 	int i = 0;
 
 	pr_debug("omap_hwmod: %s: disabling clocks\n", oh->name);
-
-	if (oh->_clk)
-		clk_disable(oh->_clk);
-
+	clk_disable(oh->_clk);
 	p = oh->slave_ports.next;
 
 	while (i < oh->slaves_cnt) {
diff --git a/arch/arm/mach-omap2/timer.c b/arch/arm/mach-omap2/timer.c
index cac46d8..15448221 100644
--- a/arch/arm/mach-omap2/timer.c
+++ b/arch/arm/mach-omap2/timer.c
@@ -208,8 +208,7 @@ static void __init omap_dmtimer_init(void)
 	/* If we are a secure device, remove any secure timer nodes */
 	if ((omap_type() != OMAP2_DEVICE_TYPE_GP)) {
 		np = omap_get_timer_dt(omap_timer_match, "ti,timer-secure");
-		if (np)
-			of_node_put(np);
+		of_node_put(np);
 	}
 }
 
-- 
2.4.5

^ permalink raw reply related	[flat|nested] 64+ messages in thread

* [PATCH] PCI-iproc: Delete unnecessary checks before two function calls
  2015-06-28 14:52                                 ` [PATCH] PCI-iproc: Delete unnecessary checks before two function calls SF Markus Elfring
  2015-06-29 16:45                                   ` Ray Jui
@ 2015-07-14 20:10                                   ` Bjorn Helgaas
  2015-07-14 20:23                                     ` Ray Jui
  1 sibling, 1 reply; 64+ messages in thread
From: Bjorn Helgaas @ 2015-07-14 20:10 UTC (permalink / raw)
  To: linux-arm-kernel

On Sun, Jun 28, 2015 at 04:52:16PM +0200, SF Markus Elfring wrote:
> From: Markus Elfring <elfring@users.sourceforge.net>
> Date: Sun, 28 Jun 2015 16:42:04 +0200
> 
> The functions phy_exit() and phy_power_off() test whether their argument
> is NULL and then return immediately.
> Thus the test around the calls is not needed.
> 
> This issue was detected by using the Coccinelle software.
> 
> Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>

I haven't seen a followup to Ray's review, but in the interest of making
progress, I updated and applied the patch as appended.  I also reviewed
other phy_*() calls under drivers/pci, and they all look OK (with no
unnecessary tests for NULL).

This is on the pci/host-iproc branch for v4.3.

> ---
>  drivers/pci/host/pcie-iproc.c | 7 ++-----
>  1 file changed, 2 insertions(+), 5 deletions(-)
> 
> diff --git a/drivers/pci/host/pcie-iproc.c b/drivers/pci/host/pcie-iproc.c
> index d77481e..f875821 100644
> --- a/drivers/pci/host/pcie-iproc.c
> +++ b/drivers/pci/host/pcie-iproc.c
> @@ -239,12 +239,9 @@ err_rm_root_bus:
>  	pci_remove_root_bus(bus);
>  
>  err_power_off_phy:
> -	if (pcie->phy)
> -		phy_power_off(pcie->phy);
> +	phy_power_off(pcie->phy);
>  err_exit_phy:
> -	if (pcie->phy)
> -		phy_exit(pcie->phy);
> -
> +	phy_exit(pcie->phy);
>  	return ret;
>  }
>  EXPORT_SYMBOL(iproc_pcie_setup);
> -- 
> 2.4.4

commit 55b5e16332eb9ffc1cbaf975585f4521417ab427
Author: Markus Elfring <elfring@users.sourceforge.net>
Date:   Sun Jun 28 16:42:04 2015 +0200

    PCI: iproc: Delete unnecessary checks before phy calls
    
    The functions phy_exit() and phy_power_off() test whether their argument is
    NULL and then return immediately.  Thus the test around the calls is not
    needed.
    
    This issue was detected by using the Coccinelle software.
    
    [bhelgaas: also phy_init() and phy_power_on(), as Ray Jui suggested]
    [bhelgaas: also remove tests in iproc_pcie_remove()]
    Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
    Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>

diff --git a/drivers/pci/host/pcie-iproc.c b/drivers/pci/host/pcie-iproc.c
index d77481e..9a00dca 100644
--- a/drivers/pci/host/pcie-iproc.c
+++ b/drivers/pci/host/pcie-iproc.c
@@ -191,19 +191,16 @@ int iproc_pcie_setup(struct iproc_pcie *pcie, struct list_head *res)
 	if (!pcie || !pcie->dev || !pcie->base)
 		return -EINVAL;
 
-	if (pcie->phy) {
-		ret = phy_init(pcie->phy);
-		if (ret) {
-			dev_err(pcie->dev, "unable to initialize PCIe PHY\n");
-			return ret;
-		}
-
-		ret = phy_power_on(pcie->phy);
-		if (ret) {
-			dev_err(pcie->dev, "unable to power on PCIe PHY\n");
-			goto err_exit_phy;
-		}
+	ret = phy_init(pcie->phy);
+	if (ret) {
+		dev_err(pcie->dev, "unable to initialize PCIe PHY\n");
+		return ret;
+	}
 
+	ret = phy_power_on(pcie->phy);
+	if (ret) {
+		dev_err(pcie->dev, "unable to power on PCIe PHY\n");
+		goto err_exit_phy;
 	}
 
 	iproc_pcie_reset(pcie);
@@ -239,12 +236,9 @@ err_rm_root_bus:
 	pci_remove_root_bus(bus);
 
 err_power_off_phy:
-	if (pcie->phy)
-		phy_power_off(pcie->phy);
+	phy_power_off(pcie->phy);
 err_exit_phy:
-	if (pcie->phy)
-		phy_exit(pcie->phy);
-
+	phy_exit(pcie->phy);
 	return ret;
 }
 EXPORT_SYMBOL(iproc_pcie_setup);
@@ -254,10 +248,8 @@ int iproc_pcie_remove(struct iproc_pcie *pcie)
 	pci_stop_root_bus(pcie->root_bus);
 	pci_remove_root_bus(pcie->root_bus);
 
-	if (pcie->phy) {
-		phy_power_off(pcie->phy);
-		phy_exit(pcie->phy);
-	}
+	phy_power_off(pcie->phy);
+	phy_exit(pcie->phy);
 
 	return 0;
 }

^ permalink raw reply related	[flat|nested] 64+ messages in thread

* [PATCH] PCI-iproc: Delete unnecessary checks before two function calls
  2015-07-14 20:10                                   ` Bjorn Helgaas
@ 2015-07-14 20:23                                     ` Ray Jui
  2015-07-14 20:51                                       ` Bjorn Helgaas
  0 siblings, 1 reply; 64+ messages in thread
From: Ray Jui @ 2015-07-14 20:23 UTC (permalink / raw)
  To: linux-arm-kernel

Hi Bjorn,

On 7/14/2015 1:10 PM, Bjorn Helgaas wrote:
> On Sun, Jun 28, 2015 at 04:52:16PM +0200, SF Markus Elfring wrote:
>> From: Markus Elfring <elfring@users.sourceforge.net>
>> Date: Sun, 28 Jun 2015 16:42:04 +0200
>>
>> The functions phy_exit() and phy_power_off() test whether their argument
>> is NULL and then return immediately.
>> Thus the test around the calls is not needed.
>>
>> This issue was detected by using the Coccinelle software.
>>
>> Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
> 
> I haven't seen a followup to Ray's review, but in the interest of making
> progress, I updated and applied the patch as appended.  I also reviewed
> other phy_*() calls under drivers/pci, and they all look OK (with no
> unnecessary tests for NULL).
> 
> This is on the pci/host-iproc branch for v4.3.
> 

Hmmm....I searched my mailbox but cannot find an email with this patch
(while I remember I reviewed and commented on the initial version of
this patch). It must have gone into some sub-folder or deleted by me by
accident. My bad.

Nevertheless,the current patch looks good to me!

Thanks,

Ray

>> ---
>>  drivers/pci/host/pcie-iproc.c | 7 ++-----
>>  1 file changed, 2 insertions(+), 5 deletions(-)
>>
>> diff --git a/drivers/pci/host/pcie-iproc.c b/drivers/pci/host/pcie-iproc.c
>> index d77481e..f875821 100644
>> --- a/drivers/pci/host/pcie-iproc.c
>> +++ b/drivers/pci/host/pcie-iproc.c
>> @@ -239,12 +239,9 @@ err_rm_root_bus:
>>  	pci_remove_root_bus(bus);
>>  
>>  err_power_off_phy:
>> -	if (pcie->phy)
>> -		phy_power_off(pcie->phy);
>> +	phy_power_off(pcie->phy);
>>  err_exit_phy:
>> -	if (pcie->phy)
>> -		phy_exit(pcie->phy);
>> -
>> +	phy_exit(pcie->phy);
>>  	return ret;
>>  }
>>  EXPORT_SYMBOL(iproc_pcie_setup);
>> -- 
>> 2.4.4
> 
> commit 55b5e16332eb9ffc1cbaf975585f4521417ab427
> Author: Markus Elfring <elfring@users.sourceforge.net>
> Date:   Sun Jun 28 16:42:04 2015 +0200
> 
>     PCI: iproc: Delete unnecessary checks before phy calls
>     
>     The functions phy_exit() and phy_power_off() test whether their argument is
>     NULL and then return immediately.  Thus the test around the calls is not
>     needed.
>     
>     This issue was detected by using the Coccinelle software.
>     
>     [bhelgaas: also phy_init() and phy_power_on(), as Ray Jui suggested]
>     [bhelgaas: also remove tests in iproc_pcie_remove()]
>     Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
>     Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
> 
> diff --git a/drivers/pci/host/pcie-iproc.c b/drivers/pci/host/pcie-iproc.c
> index d77481e..9a00dca 100644
> --- a/drivers/pci/host/pcie-iproc.c
> +++ b/drivers/pci/host/pcie-iproc.c
> @@ -191,19 +191,16 @@ int iproc_pcie_setup(struct iproc_pcie *pcie, struct list_head *res)
>  	if (!pcie || !pcie->dev || !pcie->base)
>  		return -EINVAL;
>  
> -	if (pcie->phy) {
> -		ret = phy_init(pcie->phy);
> -		if (ret) {
> -			dev_err(pcie->dev, "unable to initialize PCIe PHY\n");
> -			return ret;
> -		}
> -
> -		ret = phy_power_on(pcie->phy);
> -		if (ret) {
> -			dev_err(pcie->dev, "unable to power on PCIe PHY\n");
> -			goto err_exit_phy;
> -		}
> +	ret = phy_init(pcie->phy);
> +	if (ret) {
> +		dev_err(pcie->dev, "unable to initialize PCIe PHY\n");
> +		return ret;
> +	}
>  
> +	ret = phy_power_on(pcie->phy);
> +	if (ret) {
> +		dev_err(pcie->dev, "unable to power on PCIe PHY\n");
> +		goto err_exit_phy;
>  	}
>  
>  	iproc_pcie_reset(pcie);
> @@ -239,12 +236,9 @@ err_rm_root_bus:
>  	pci_remove_root_bus(bus);
>  
>  err_power_off_phy:
> -	if (pcie->phy)
> -		phy_power_off(pcie->phy);
> +	phy_power_off(pcie->phy);
>  err_exit_phy:
> -	if (pcie->phy)
> -		phy_exit(pcie->phy);
> -
> +	phy_exit(pcie->phy);
>  	return ret;
>  }
>  EXPORT_SYMBOL(iproc_pcie_setup);
> @@ -254,10 +248,8 @@ int iproc_pcie_remove(struct iproc_pcie *pcie)
>  	pci_stop_root_bus(pcie->root_bus);
>  	pci_remove_root_bus(pcie->root_bus);
>  
> -	if (pcie->phy) {
> -		phy_power_off(pcie->phy);
> -		phy_exit(pcie->phy);
> -	}
> +	phy_power_off(pcie->phy);
> +	phy_exit(pcie->phy);
>  
>  	return 0;
>  }
> 

^ permalink raw reply	[flat|nested] 64+ messages in thread

* [PATCH] PCI-iproc: Delete unnecessary checks before two function calls
  2015-07-14 20:23                                     ` Ray Jui
@ 2015-07-14 20:51                                       ` Bjorn Helgaas
  2015-07-14 20:53                                         ` Ray Jui
  0 siblings, 1 reply; 64+ messages in thread
From: Bjorn Helgaas @ 2015-07-14 20:51 UTC (permalink / raw)
  To: linux-arm-kernel

On Tue, Jul 14, 2015 at 01:23:23PM -0700, Ray Jui wrote:
> Hi Bjorn,
> 
> On 7/14/2015 1:10 PM, Bjorn Helgaas wrote:
> > On Sun, Jun 28, 2015 at 04:52:16PM +0200, SF Markus Elfring wrote:
> >> From: Markus Elfring <elfring@users.sourceforge.net>
> >> Date: Sun, 28 Jun 2015 16:42:04 +0200
> >>
> >> The functions phy_exit() and phy_power_off() test whether their argument
> >> is NULL and then return immediately.
> >> Thus the test around the calls is not needed.
> >>
> >> This issue was detected by using the Coccinelle software.
> >>
> >> Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
> > 
> > I haven't seen a followup to Ray's review, but in the interest of making
> > progress, I updated and applied the patch as appended.  I also reviewed
> > other phy_*() calls under drivers/pci, and they all look OK (with no
> > unnecessary tests for NULL).
> > 
> > This is on the pci/host-iproc branch for v4.3.
> > 
> 
> Hmmm....I searched my mailbox but cannot find an email with this patch
> (while I remember I reviewed and commented on the initial version of
> this patch). It must have gone into some sub-folder or deleted by me by
> accident. My bad.
> 
> Nevertheless,the current patch looks good to me!

Thanks for checking it out!  Can I add your Reviewed-by to the patch below?

> > commit 55b5e16332eb9ffc1cbaf975585f4521417ab427
> > Author: Markus Elfring <elfring@users.sourceforge.net>
> > Date:   Sun Jun 28 16:42:04 2015 +0200
> > 
> >     PCI: iproc: Delete unnecessary checks before phy calls
> >     
> >     The functions phy_exit() and phy_power_off() test whether their argument is
> >     NULL and then return immediately.  Thus the test around the calls is not
> >     needed.
> >     
> >     This issue was detected by using the Coccinelle software.
> >     
> >     [bhelgaas: also phy_init() and phy_power_on(), as Ray Jui suggested]
> >     [bhelgaas: also remove tests in iproc_pcie_remove()]
> >     Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
> >     Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
> > 
> > diff --git a/drivers/pci/host/pcie-iproc.c b/drivers/pci/host/pcie-iproc.c
> > index d77481e..9a00dca 100644
> > --- a/drivers/pci/host/pcie-iproc.c
> > +++ b/drivers/pci/host/pcie-iproc.c
> > @@ -191,19 +191,16 @@ int iproc_pcie_setup(struct iproc_pcie *pcie, struct list_head *res)
> >  	if (!pcie || !pcie->dev || !pcie->base)
> >  		return -EINVAL;
> >  
> > -	if (pcie->phy) {
> > -		ret = phy_init(pcie->phy);
> > -		if (ret) {
> > -			dev_err(pcie->dev, "unable to initialize PCIe PHY\n");
> > -			return ret;
> > -		}
> > -
> > -		ret = phy_power_on(pcie->phy);
> > -		if (ret) {
> > -			dev_err(pcie->dev, "unable to power on PCIe PHY\n");
> > -			goto err_exit_phy;
> > -		}
> > +	ret = phy_init(pcie->phy);
> > +	if (ret) {
> > +		dev_err(pcie->dev, "unable to initialize PCIe PHY\n");
> > +		return ret;
> > +	}
> >  
> > +	ret = phy_power_on(pcie->phy);
> > +	if (ret) {
> > +		dev_err(pcie->dev, "unable to power on PCIe PHY\n");
> > +		goto err_exit_phy;
> >  	}
> >  
> >  	iproc_pcie_reset(pcie);
> > @@ -239,12 +236,9 @@ err_rm_root_bus:
> >  	pci_remove_root_bus(bus);
> >  
> >  err_power_off_phy:
> > -	if (pcie->phy)
> > -		phy_power_off(pcie->phy);
> > +	phy_power_off(pcie->phy);
> >  err_exit_phy:
> > -	if (pcie->phy)
> > -		phy_exit(pcie->phy);
> > -
> > +	phy_exit(pcie->phy);
> >  	return ret;
> >  }
> >  EXPORT_SYMBOL(iproc_pcie_setup);
> > @@ -254,10 +248,8 @@ int iproc_pcie_remove(struct iproc_pcie *pcie)
> >  	pci_stop_root_bus(pcie->root_bus);
> >  	pci_remove_root_bus(pcie->root_bus);
> >  
> > -	if (pcie->phy) {
> > -		phy_power_off(pcie->phy);
> > -		phy_exit(pcie->phy);
> > -	}
> > +	phy_power_off(pcie->phy);
> > +	phy_exit(pcie->phy);
> >  
> >  	return 0;
> >  }
> > 

^ permalink raw reply	[flat|nested] 64+ messages in thread

* [PATCH] PCI-iproc: Delete unnecessary checks before two function calls
  2015-07-14 20:51                                       ` Bjorn Helgaas
@ 2015-07-14 20:53                                         ` Ray Jui
  0 siblings, 0 replies; 64+ messages in thread
From: Ray Jui @ 2015-07-14 20:53 UTC (permalink / raw)
  To: linux-arm-kernel



On 7/14/2015 1:51 PM, Bjorn Helgaas wrote:
> On Tue, Jul 14, 2015 at 01:23:23PM -0700, Ray Jui wrote:
>> Hi Bjorn,
>>
>> On 7/14/2015 1:10 PM, Bjorn Helgaas wrote:
>>> On Sun, Jun 28, 2015 at 04:52:16PM +0200, SF Markus Elfring wrote:
>>>> From: Markus Elfring <elfring@users.sourceforge.net>
>>>> Date: Sun, 28 Jun 2015 16:42:04 +0200
>>>>
>>>> The functions phy_exit() and phy_power_off() test whether their argument
>>>> is NULL and then return immediately.
>>>> Thus the test around the calls is not needed.
>>>>
>>>> This issue was detected by using the Coccinelle software.
>>>>
>>>> Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
>>>
>>> I haven't seen a followup to Ray's review, but in the interest of making
>>> progress, I updated and applied the patch as appended.  I also reviewed
>>> other phy_*() calls under drivers/pci, and they all look OK (with no
>>> unnecessary tests for NULL).
>>>
>>> This is on the pci/host-iproc branch for v4.3.
>>>
>>
>> Hmmm....I searched my mailbox but cannot find an email with this patch
>> (while I remember I reviewed and commented on the initial version of
>> this patch). It must have gone into some sub-folder or deleted by me by
>> accident. My bad.
>>
>> Nevertheless,the current patch looks good to me!
> 
> Thanks for checking it out!  Can I add your Reviewed-by to the patch below?
> 

Sure thanks!

Reviewed-by: Ray Jui <rjui@broadcom.com>

Ray

^ permalink raw reply	[flat|nested] 64+ messages in thread

* [PATCH 0/2] ARM-OMAP2+: Deletion of unnecessary checks before two function calls
  2015-06-25 11:33                                 ` [PATCH 0/2] ARM-OMAP2+: Deletion of unnecessary checks before two function calls SF Markus Elfring
  2015-06-25 11:38                                   ` [PATCH 1/2] ARM-OMAP2+: Delete an unnecessary check before the function call "omap_device_delete" SF Markus Elfring
  2015-06-25 11:40                                   ` [PATCH 2/2] ARM-OMAP2+: Delete an unnecessary check before the function call "of_node_put" SF Markus Elfring
@ 2015-07-15  6:41                                   ` Tony Lindgren
  2 siblings, 0 replies; 64+ messages in thread
From: Tony Lindgren @ 2015-07-15  6:41 UTC (permalink / raw)
  To: linux-arm-kernel

* SF Markus Elfring <elfring@users.sourceforge.net> [150625 04:35]:
> From: Markus Elfring <elfring@users.sourceforge.net>
> Date: Thu, 25 Jun 2015 13:24:35 +0200
> 
> Some functions which release a system resource tolerate the passing
> of a null pointer. I do not see a need because of this fact
> that a function caller repeats a corresponding check.
> 
> Markus Elfring (2):
>   Delete a check before the function call "omap_device_delete"
>   Delete a check before the function call "of_node_put"
> 
>  arch/arm/mach-omap2/omap_device.c | 3 +--
>  arch/arm/mach-omap2/timer.c       | 3 +--
>  2 files changed, 2 insertions(+), 4 deletions(-)

Applying both into omap-for-v4.3/soc thanks.

Tony

^ permalink raw reply	[flat|nested] 64+ messages in thread

* [PATCH] ARM: OMAP2: Delete unnecessary checks before three function calls
  2015-06-30 12:10                                   ` [PATCH] ARM: OMAP2: Delete " SF Markus Elfring
@ 2015-07-16  5:55                                     ` Paul Walmsley
  2015-07-16  6:23                                       ` Tony Lindgren
  2015-07-16  6:40                                       ` SF Markus Elfring
  0 siblings, 2 replies; 64+ messages in thread
From: Paul Walmsley @ 2015-07-16  5:55 UTC (permalink / raw)
  To: linux-arm-kernel

Hello Markus

On Tue, 30 Jun 2015, SF Markus Elfring wrote:

> From: Markus Elfring <elfring@users.sourceforge.net>
> Date: Tue, 30 Jun 2015 14:00:16 +0200
> 
> The functions clk_disable(), of_node_put() and omap_device_delete() 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 <elfring@users.sourceforge.net>

Thanks for the patch.  I have to say, I am a bit leery about applying the 
omap_device.c and omap_hwmod.c changes, since the called functions -- 
omap_device_delete() and clk_disable() -- don't explicitly document that 
NULLs are allowed to be passed in.  So there's no explicit contract that 
callers can rely upon, to (at least in theory) prevent those internal NULL 
pointer checks from being removed.

So I would suggest that those two functions' kerneldoc be patched first to 
explicitly state that passing in a NULL pointer is allowed.  Then I would 
feel a bit more comfortable applying the omap_device.c and omap_hwmod.c 
changes.

The kerneldoc for of_node_put() does explicitly allow NULLs to be passed 
in.  So I'll apply that change now for v4.3, touching up the commit 
message accordingly.

regards,

- Paul

> ---
>  arch/arm/mach-omap2/omap_device.c | 3 +--
>  arch/arm/mach-omap2/omap_hwmod.c  | 5 +----
>  arch/arm/mach-omap2/timer.c       | 3 +--
>  3 files changed, 3 insertions(+), 8 deletions(-)
> 
> diff --git a/arch/arm/mach-omap2/omap_device.c b/arch/arm/mach-omap2/omap_device.c
> index 4cb8fd9..196366e 100644
> --- a/arch/arm/mach-omap2/omap_device.c
> +++ b/arch/arm/mach-omap2/omap_device.c
> @@ -193,8 +193,7 @@ static int _omap_device_notifier_call(struct notifier_block *nb,
>  
>  	switch (event) {
>  	case BUS_NOTIFY_DEL_DEVICE:
> -		if (pdev->archdata.od)
> -			omap_device_delete(pdev->archdata.od);
> +		omap_device_delete(pdev->archdata.od);
>  		break;
>  	case BUS_NOTIFY_ADD_DEVICE:
>  		if (pdev->dev.of_node)
> diff --git a/arch/arm/mach-omap2/omap_hwmod.c b/arch/arm/mach-omap2/omap_hwmod.c
> index d78c12e..1091ee7 100644
> --- a/arch/arm/mach-omap2/omap_hwmod.c
> +++ b/arch/arm/mach-omap2/omap_hwmod.c
> @@ -921,10 +921,7 @@ static int _disable_clocks(struct omap_hwmod *oh)
>  	int i = 0;
>  
>  	pr_debug("omap_hwmod: %s: disabling clocks\n", oh->name);
> -
> -	if (oh->_clk)
> -		clk_disable(oh->_clk);
> -
> +	clk_disable(oh->_clk);
>  	p = oh->slave_ports.next;
>  
>  	while (i < oh->slaves_cnt) {
> diff --git a/arch/arm/mach-omap2/timer.c b/arch/arm/mach-omap2/timer.c
> index cac46d8..15448221 100644
> --- a/arch/arm/mach-omap2/timer.c
> +++ b/arch/arm/mach-omap2/timer.c
> @@ -208,8 +208,7 @@ static void __init omap_dmtimer_init(void)
>  	/* If we are a secure device, remove any secure timer nodes */
>  	if ((omap_type() != OMAP2_DEVICE_TYPE_GP)) {
>  		np = omap_get_timer_dt(omap_timer_match, "ti,timer-secure");
> -		if (np)
> -			of_node_put(np);
> +		of_node_put(np);
>  	}
>  }
>  
> -- 
> 2.4.5
> 


- Paul

^ permalink raw reply	[flat|nested] 64+ messages in thread

* [PATCH] ARM: OMAP2: Delete unnecessary checks before three function calls
  2015-07-16  5:55                                     ` Paul Walmsley
@ 2015-07-16  6:23                                       ` Tony Lindgren
  2015-07-16 14:06                                         ` Paul Walmsley
  2015-07-16  6:40                                       ` SF Markus Elfring
  1 sibling, 1 reply; 64+ messages in thread
From: Tony Lindgren @ 2015-07-16  6:23 UTC (permalink / raw)
  To: linux-arm-kernel

* Paul Walmsley <paul@pwsan.com> [150715 22:58]:
> Hello Markus
> 
> On Tue, 30 Jun 2015, SF Markus Elfring wrote:
> 
> > From: Markus Elfring <elfring@users.sourceforge.net>
> > Date: Tue, 30 Jun 2015 14:00:16 +0200
> > 
> > The functions clk_disable(), of_node_put() and omap_device_delete() 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 <elfring@users.sourceforge.net>
> 
> Thanks for the patch.  I have to say, I am a bit leery about applying the 
> omap_device.c and omap_hwmod.c changes, since the called functions -- 
> omap_device_delete() and clk_disable() -- don't explicitly document that 
> NULLs are allowed to be passed in.  So there's no explicit contract that 
> callers can rely upon, to (at least in theory) prevent those internal NULL 
> pointer checks from being removed.
> 
> So I would suggest that those two functions' kerneldoc be patched first to 
> explicitly state that passing in a NULL pointer is allowed.  Then I would 
> feel a bit more comfortable applying the omap_device.c and omap_hwmod.c 
> changes.
> 
> The kerneldoc for of_node_put() does explicitly allow NULLs to be passed 
> in.  So I'll apply that change now for v4.3, touching up the commit 
> message accordingly.

I have them applied from a later thread already, but will drop both in
my branch as I have not pushed them out yet.

Regards,

Tony

^ permalink raw reply	[flat|nested] 64+ messages in thread

* ARM: OMAP2: Delete unnecessary checks before three function calls
  2015-07-16  5:55                                     ` Paul Walmsley
  2015-07-16  6:23                                       ` Tony Lindgren
@ 2015-07-16  6:40                                       ` SF Markus Elfring
  1 sibling, 0 replies; 64+ messages in thread
From: SF Markus Elfring @ 2015-07-16  6:40 UTC (permalink / raw)
  To: linux-arm-kernel

> I have to say, I am a bit leery about applying the omap_device.c and
> omap_hwmod.c changes, since the called functions -- omap_device_delete()
> and clk_disable() -- don't explicitly document that NULLs are allowed
> to be passed in.

How are the chances to improve documentation around such implementation details?


> So there's no explicit contract that callers can rely upon, to (at least
> in theory) prevent those internal NULL pointer checks from being removed.

Are there any additional variations to consider for source files from different
processor architectures?


> So I would suggest that those two functions' kerneldoc be patched first to 
> explicitly state that passing in a NULL pointer is allowed.

Should my static source code analysis approach help you any more to clarify
further open issues?


> So I'll apply that change now for v4.3, touching up the commit message accordingly.

Thanks for your constructive feedback.


>>  arch/arm/mach-omap2/omap_device.c | 3 +--
>>  arch/arm/mach-omap2/omap_hwmod.c  | 5 +----
>>  arch/arm/mach-omap2/timer.c       | 3 +--

Did Tony Lindgren pick a similar update suggestion up, too?
https://lkml.org/lkml/2015/7/15/112

Regards,
Markus

^ permalink raw reply	[flat|nested] 64+ messages in thread

* [PATCH] ARM: OMAP2: Delete unnecessary checks before three function calls
  2015-07-16  6:23                                       ` Tony Lindgren
@ 2015-07-16 14:06                                         ` Paul Walmsley
  2015-07-16 16:28                                           ` Tony Lindgren
  0 siblings, 1 reply; 64+ messages in thread
From: Paul Walmsley @ 2015-07-16 14:06 UTC (permalink / raw)
  To: linux-arm-kernel

On Wed, 15 Jul 2015, Tony Lindgren wrote:

> * Paul Walmsley <paul@pwsan.com> [150715 22:58]:
> > Hello Markus
> > 
> > On Tue, 30 Jun 2015, SF Markus Elfring wrote:
> > 
> > > From: Markus Elfring <elfring@users.sourceforge.net>
> > > Date: Tue, 30 Jun 2015 14:00:16 +0200
> > > 
> > > The functions clk_disable(), of_node_put() and omap_device_delete() 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 <elfring@users.sourceforge.net>
> > 
> > Thanks for the patch.  I have to say, I am a bit leery about applying the 
> > omap_device.c and omap_hwmod.c changes, since the called functions -- 
> > omap_device_delete() and clk_disable() -- don't explicitly document that 
> > NULLs are allowed to be passed in.  So there's no explicit contract that 
> > callers can rely upon, to (at least in theory) prevent those internal NULL 
> > pointer checks from being removed.
> > 
> > So I would suggest that those two functions' kerneldoc be patched first to 
> > explicitly state that passing in a NULL pointer is allowed.  Then I would 
> > feel a bit more comfortable applying the omap_device.c and omap_hwmod.c 
> > changes.
> > 
> > The kerneldoc for of_node_put() does explicitly allow NULLs to be passed 
> > in.  So I'll apply that change now for v4.3, touching up the commit 
> > message accordingly.
> 
> I have them applied from a later thread already, but will drop both in
> my branch as I have not pushed them out yet.

Oops sorry about stepping on your toes - I obviously missed that followup.

- Paul

^ permalink raw reply	[flat|nested] 64+ messages in thread

* [PATCH] ARM: OMAP2: Delete unnecessary checks before three function calls
  2015-07-16 14:06                                         ` Paul Walmsley
@ 2015-07-16 16:28                                           ` Tony Lindgren
  0 siblings, 0 replies; 64+ messages in thread
From: Tony Lindgren @ 2015-07-16 16:28 UTC (permalink / raw)
  To: linux-arm-kernel

* Paul Walmsley <paul@pwsan.com> [150716 07:09]:
> On Wed, 15 Jul 2015, Tony Lindgren wrote:
> 
> > * Paul Walmsley <paul@pwsan.com> [150715 22:58]:
> > > Hello Markus
> > > 
> > > On Tue, 30 Jun 2015, SF Markus Elfring wrote:
> > > 
> > > > From: Markus Elfring <elfring@users.sourceforge.net>
> > > > Date: Tue, 30 Jun 2015 14:00:16 +0200
> > > > 
> > > > The functions clk_disable(), of_node_put() and omap_device_delete() 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 <elfring@users.sourceforge.net>
> > > 
> > > Thanks for the patch.  I have to say, I am a bit leery about applying the 
> > > omap_device.c and omap_hwmod.c changes, since the called functions -- 
> > > omap_device_delete() and clk_disable() -- don't explicitly document that 
> > > NULLs are allowed to be passed in.  So there's no explicit contract that 
> > > callers can rely upon, to (at least in theory) prevent those internal NULL 
> > > pointer checks from being removed.
> > > 
> > > So I would suggest that those two functions' kerneldoc be patched first to 
> > > explicitly state that passing in a NULL pointer is allowed.  Then I would 
> > > feel a bit more comfortable applying the omap_device.c and omap_hwmod.c 
> > > changes.
> > > 
> > > The kerneldoc for of_node_put() does explicitly allow NULLs to be passed 
> > > in.  So I'll apply that change now for v4.3, touching up the commit 
> > > message accordingly.
> > 
> > I have them applied from a later thread already, but will drop both in
> > my branch as I have not pushed them out yet.
> 
> Oops sorry about stepping on your toes - I obviously missed that followup.

No problem :)

Tony

^ permalink raw reply	[flat|nested] 64+ messages in thread

* [PATCH] pinctrl: Delete unnecessary checks before the function call "pinctrl_unregister"
       [not found]                               ` <5317A59D.4@users.sourceforge.net>
                                                   ` (11 preceding siblings ...)
  2015-06-29 10:48                                 ` [PATCH] net-Liquidio: Delete unnecessary checks before the function call "vfree" SF Markus Elfring
@ 2015-11-05 16:17                                 ` SF Markus Elfring
  2015-11-05 16:53                                   ` Ray Jui
  2015-11-17 10:50                                   ` Linus Walleij
  2015-11-05 18:45                                 ` [PATCH 0/2] [media] c8sectpfe: Deletion of a few unnecessary checks SF Markus Elfring
                                                   ` (5 subsequent siblings)
  18 siblings, 2 replies; 64+ messages in thread
From: SF Markus Elfring @ 2015-11-05 16:17 UTC (permalink / raw)
  To: linux-arm-kernel

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Thu, 5 Nov 2015 17:10:22 +0100

The pinctrl_unregister() 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 <elfring@users.sourceforge.net>
---
 drivers/pinctrl/bcm/pinctrl-cygnus-gpio.c | 3 +--
 drivers/pinctrl/pinctrl-single.c          | 5 +----
 2 files changed, 2 insertions(+), 6 deletions(-)

diff --git a/drivers/pinctrl/bcm/pinctrl-cygnus-gpio.c b/drivers/pinctrl/bcm/pinctrl-cygnus-gpio.c
index 12a48f4..663ad0a 100644
--- a/drivers/pinctrl/bcm/pinctrl-cygnus-gpio.c
+++ b/drivers/pinctrl/bcm/pinctrl-cygnus-gpio.c
@@ -638,8 +638,7 @@ static int cygnus_gpio_register_pinconf(struct cygnus_gpio *chip)
 
 static void cygnus_gpio_unregister_pinconf(struct cygnus_gpio *chip)
 {
-	if (chip->pctl)
-		pinctrl_unregister(chip->pctl);
+	pinctrl_unregister(chip->pctl);
 }
 
 struct cygnus_gpio_data {
diff --git a/drivers/pinctrl/pinctrl-single.c b/drivers/pinctrl/pinctrl-single.c
index ef04b96..d24e5f1 100644
--- a/drivers/pinctrl/pinctrl-single.c
+++ b/drivers/pinctrl/pinctrl-single.c
@@ -1484,10 +1484,7 @@ static void pcs_irq_free(struct pcs_device *pcs)
 static void pcs_free_resources(struct pcs_device *pcs)
 {
 	pcs_irq_free(pcs);
-
-	if (pcs->pctl)
-		pinctrl_unregister(pcs->pctl);
-
+	pinctrl_unregister(pcs->pctl);
 	pcs_free_funcs(pcs);
 	pcs_free_pingroups(pcs);
 }
-- 
2.6.2

^ permalink raw reply related	[flat|nested] 64+ messages in thread

* [PATCH] pinctrl: Delete unnecessary checks before the function call "pinctrl_unregister"
  2015-11-05 16:17                                 ` [PATCH] pinctrl: Delete unnecessary checks before the function call "pinctrl_unregister" SF Markus Elfring
@ 2015-11-05 16:53                                   ` Ray Jui
  2015-11-17 10:50                                   ` Linus Walleij
  1 sibling, 0 replies; 64+ messages in thread
From: Ray Jui @ 2015-11-05 16:53 UTC (permalink / raw)
  To: linux-arm-kernel


On 11/5/2015 8:17 AM, SF Markus Elfring wrote:
> From: Markus Elfring <elfring@users.sourceforge.net>
> Date: Thu, 5 Nov 2015 17:10:22 +0100
>
> The pinctrl_unregister() 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 <elfring@users.sourceforge.net>
> ---
>   drivers/pinctrl/bcm/pinctrl-cygnus-gpio.c | 3 +--
>   drivers/pinctrl/pinctrl-single.c          | 5 +----
>   2 files changed, 2 insertions(+), 6 deletions(-)
>
> diff --git a/drivers/pinctrl/bcm/pinctrl-cygnus-gpio.c b/drivers/pinctrl/bcm/pinctrl-cygnus-gpio.c
> index 12a48f4..663ad0a 100644
> --- a/drivers/pinctrl/bcm/pinctrl-cygnus-gpio.c
> +++ b/drivers/pinctrl/bcm/pinctrl-cygnus-gpio.c
> @@ -638,8 +638,7 @@ static int cygnus_gpio_register_pinconf(struct cygnus_gpio *chip)
>
>   static void cygnus_gpio_unregister_pinconf(struct cygnus_gpio *chip)
>   {
> -	if (chip->pctl)
> -		pinctrl_unregister(chip->pctl);
> +	pinctrl_unregister(chip->pctl);
>   }
>
>   struct cygnus_gpio_data {
> diff --git a/drivers/pinctrl/pinctrl-single.c b/drivers/pinctrl/pinctrl-single.c
> index ef04b96..d24e5f1 100644
> --- a/drivers/pinctrl/pinctrl-single.c
> +++ b/drivers/pinctrl/pinctrl-single.c
> @@ -1484,10 +1484,7 @@ static void pcs_irq_free(struct pcs_device *pcs)
>   static void pcs_free_resources(struct pcs_device *pcs)
>   {
>   	pcs_irq_free(pcs);
> -
> -	if (pcs->pctl)
> -		pinctrl_unregister(pcs->pctl);
> -
> +	pinctrl_unregister(pcs->pctl);
>   	pcs_free_funcs(pcs);
>   	pcs_free_pingroups(pcs);
>   }
>

The change looks good to me, thanks!

Reviewed-by: Ray Jui <rjui@broadcom.com>

+ Pramod since he's working on changes on the pinctrl-cygnus-gpio driver.

Ray

^ permalink raw reply	[flat|nested] 64+ messages in thread

* [PATCH 0/2] [media] c8sectpfe: Deletion of a few unnecessary checks
       [not found]                               ` <5317A59D.4@users.sourceforge.net>
                                                   ` (12 preceding siblings ...)
  2015-11-05 16:17                                 ` [PATCH] pinctrl: Delete unnecessary checks before the function call "pinctrl_unregister" SF Markus Elfring
@ 2015-11-05 18:45                                 ` SF Markus Elfring
  2015-11-05 18:49                                   ` [PATCH 1/2] [media] c8sectpfe: Delete unnecessary checks before two function calls SF Markus Elfring
                                                     ` (2 more replies)
  2015-11-16 21:20                                 ` [PATCH 0/3] ste_dma40: " SF Markus Elfring
                                                   ` (4 subsequent siblings)
  18 siblings, 3 replies; 64+ messages in thread
From: SF Markus Elfring @ 2015-11-05 18:45 UTC (permalink / raw)
  To: linux-arm-kernel

From: Markus Elfring <elfring@users.sourceforge.net>
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

^ permalink raw reply	[flat|nested] 64+ messages in thread

* [PATCH 1/2] [media] c8sectpfe: Delete unnecessary checks before two function calls
  2015-11-05 18:45                                 ` [PATCH 0/2] [media] c8sectpfe: Deletion of a few unnecessary checks SF Markus Elfring
@ 2015-11-05 18:49                                   ` SF Markus Elfring
  2015-11-05 18:50                                   ` [PATCH 2/2] [media] c8sectpfe: Combine three checks into a single if block SF Markus Elfring
  2015-11-06  7:50                                   ` [PATCH 0/2] [media] c8sectpfe: Deletion of a few unnecessary checks Maxime Coquelin
  2 siblings, 0 replies; 64+ messages in thread
From: SF Markus Elfring @ 2015-11-05 18:49 UTC (permalink / raw)
  To: linux-arm-kernel

From: Markus Elfring <elfring@users.sourceforge.net>
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 <elfring@users.sourceforge.net>
---
 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

^ permalink raw reply related	[flat|nested] 64+ messages in thread

* [PATCH 2/2] [media] c8sectpfe: Combine three checks into a single if block
  2015-11-05 18:45                                 ` [PATCH 0/2] [media] c8sectpfe: Deletion of a few unnecessary checks SF Markus Elfring
  2015-11-05 18:49                                   ` [PATCH 1/2] [media] c8sectpfe: Delete unnecessary checks before two function calls SF Markus Elfring
@ 2015-11-05 18:50                                   ` SF Markus Elfring
  2015-11-06 10:09                                     ` walter harms
  2015-11-06  7:50                                   ` [PATCH 0/2] [media] c8sectpfe: Deletion of a few unnecessary checks Maxime Coquelin
  2 siblings, 1 reply; 64+ messages in thread
From: SF Markus Elfring @ 2015-11-05 18:50 UTC (permalink / raw)
  To: linux-arm-kernel

From: Markus Elfring <elfring@users.sourceforge.net>
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 <elfring@users.sourceforge.net>
---
 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

^ permalink raw reply related	[flat|nested] 64+ messages in thread

* [PATCH 0/2] [media] c8sectpfe: Deletion of a few unnecessary checks
  2015-11-05 18:45                                 ` [PATCH 0/2] [media] c8sectpfe: Deletion of a few unnecessary checks SF Markus Elfring
  2015-11-05 18:49                                   ` [PATCH 1/2] [media] c8sectpfe: Delete unnecessary checks before two function calls SF Markus Elfring
  2015-11-05 18:50                                   ` [PATCH 2/2] [media] c8sectpfe: Combine three checks into a single if block SF Markus Elfring
@ 2015-11-06  7:50                                   ` Maxime Coquelin
  2 siblings, 0 replies; 64+ messages in thread
From: Maxime Coquelin @ 2015-11-06  7:50 UTC (permalink / raw)
  To: linux-arm-kernel

Hi Markus,

On 11/05/2015 07:45 PM, SF Markus Elfring wrote:
> From: Markus Elfring <elfring@users.sourceforge.net>
> 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(-)
>
For the series:
Acked-by: Maxime Coquelin <maxime.coquelin@st.com>

Thanks!
Maxime

^ permalink raw reply	[flat|nested] 64+ messages in thread

* [PATCH 2/2] [media] c8sectpfe: Combine three checks into a single if block
  2015-11-05 18:50                                   ` [PATCH 2/2] [media] c8sectpfe: Combine three checks into a single if block SF Markus Elfring
@ 2015-11-06 10:09                                     ` walter harms
  0 siblings, 0 replies; 64+ messages in thread
From: walter harms @ 2015-11-06 10:09 UTC (permalink / raw)
  To: linux-arm-kernel



Am 05.11.2015 19:50, schrieb SF Markus Elfring:
> From: Markus Elfring <elfring@users.sourceforge.net>
> 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 <elfring@users.sourceforge.net>
> ---
>  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 you do "if (!tsin) continue ;"
you can save one indent level

re,
 wh

>  
> -		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);
> +			}
>  		}
>  	}
>  

^ permalink raw reply	[flat|nested] 64+ messages in thread

* [PATCH] iommu/arm-smmu: Delete an unnecessary check before free_io_pgtable_ops()
  2015-06-28 14:05                                 ` [PATCH] iommu/arm-smmu: Delete an unnecessary check before the function call "free_io_pgtable_ops" SF Markus Elfring
@ 2015-11-06 17:38                                   ` SF Markus Elfring
  0 siblings, 0 replies; 64+ messages in thread
From: SF Markus Elfring @ 2015-11-06 17:38 UTC (permalink / raw)
  To: linux-arm-kernel

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Fri, 6 Nov 2015 18:32:41 +0100

The free_io_pgtable_ops() 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 <elfring@users.sourceforge.net>
---
 drivers/iommu/arm-smmu.c | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)

diff --git a/drivers/iommu/arm-smmu.c b/drivers/iommu/arm-smmu.c
index 47dc7a7..1ce4b85 100644
--- a/drivers/iommu/arm-smmu.c
+++ b/drivers/iommu/arm-smmu.c
@@ -945,9 +945,7 @@ static void arm_smmu_destroy_domain_context(struct iommu_domain *domain)
 		free_irq(irq, domain);
 	}
 
-	if (smmu_domain->pgtbl_ops)
-		free_io_pgtable_ops(smmu_domain->pgtbl_ops);
-
+	free_io_pgtable_ops(smmu_domain->pgtbl_ops);
 	__arm_smmu_free_bitmap(smmu->context_map, cfg->cbndx);
 }
 
-- 
2.6.2

^ permalink raw reply related	[flat|nested] 64+ messages in thread

* [PATCH 0/3] ste_dma40: Deletion of a few unnecessary checks
       [not found]                               ` <5317A59D.4@users.sourceforge.net>
                                                   ` (13 preceding siblings ...)
  2015-11-05 18:45                                 ` [PATCH 0/2] [media] c8sectpfe: Deletion of a few unnecessary checks SF Markus Elfring
@ 2015-11-16 21:20                                 ` SF Markus Elfring
  2015-11-16 21:23                                   ` [PATCH 1/3] ste_dma40: Delete an unnecessary check before the function call "kmem_cache_destroy" SF Markus Elfring
                                                     ` (3 more replies)
  2016-07-15 13:35                                 ` [PATCH] drm/rockchip: Delete an unnecessary check before drm_gem_object_unreference_unlocked() SF Markus Elfring
                                                   ` (3 subsequent siblings)
  18 siblings, 4 replies; 64+ messages in thread
From: SF Markus Elfring @ 2015-11-16 21:20 UTC (permalink / raw)
  To: linux-arm-kernel

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Mon, 16 Nov 2015 22:12:23 +0100

Further update suggestions were taken into account after a patch
was applied from static source code analysis.

Markus Elfring (3):
  Delete an unnecessary check before the function call "kmem_cache_destroy"
  Delete another unnecessary check in d40_probe()
  Delete an unnecessary variable initialisation in d40_probe()

 drivers/dma/ste_dma40.c | 87 ++++++++++++++++++++++++-------------------------
 1 file changed, 42 insertions(+), 45 deletions(-)

-- 
2.6.2

^ permalink raw reply	[flat|nested] 64+ messages in thread

* [PATCH 1/3] ste_dma40: Delete an unnecessary check before the function call "kmem_cache_destroy"
  2015-11-16 21:20                                 ` [PATCH 0/3] ste_dma40: " SF Markus Elfring
@ 2015-11-16 21:23                                   ` SF Markus Elfring
  2015-11-29 21:26                                     ` Linus Walleij
  2015-11-16 21:24                                   ` [PATCH 2/3] ste_dma40: Delete another unnecessary check in d40_probe() SF Markus Elfring
                                                     ` (2 subsequent siblings)
  3 siblings, 1 reply; 64+ messages in thread
From: SF Markus Elfring @ 2015-11-16 21:23 UTC (permalink / raw)
  To: linux-arm-kernel

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Mon, 16 Nov 2015 20:26:27 +0100

The kmem_cache_destroy() 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 <elfring@users.sourceforge.net>
---
 drivers/dma/ste_dma40.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/drivers/dma/ste_dma40.c b/drivers/dma/ste_dma40.c
index dd3e7ba..9132ae0 100644
--- a/drivers/dma/ste_dma40.c
+++ b/drivers/dma/ste_dma40.c
@@ -3694,8 +3694,7 @@ static int __init d40_probe(struct platform_device *pdev)
 
 failure:
 	if (base) {
-		if (base->desc_slab)
-			kmem_cache_destroy(base->desc_slab);
+		kmem_cache_destroy(base->desc_slab);
 		if (base->virtbase)
 			iounmap(base->virtbase);
 
-- 
2.6.2

^ permalink raw reply related	[flat|nested] 64+ messages in thread

* [PATCH 2/3] ste_dma40: Delete another unnecessary check in d40_probe()
  2015-11-16 21:20                                 ` [PATCH 0/3] ste_dma40: " SF Markus Elfring
  2015-11-16 21:23                                   ` [PATCH 1/3] ste_dma40: Delete an unnecessary check before the function call "kmem_cache_destroy" SF Markus Elfring
@ 2015-11-16 21:24                                   ` SF Markus Elfring
  2015-11-29 21:28                                     ` Linus Walleij
  2015-11-16 21:26                                   ` [PATCH 3/3] ste_dma40: Delete an unnecessary variable initialisation " SF Markus Elfring
  2015-12-10  3:47                                   ` [PATCH 0/3] ste_dma40: Deletion of a few unnecessary checks Vinod Koul
  3 siblings, 1 reply; 64+ messages in thread
From: SF Markus Elfring @ 2015-11-16 21:24 UTC (permalink / raw)
  To: linux-arm-kernel

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Mon, 16 Nov 2015 21:56:07 +0100

A single jump label was used by the d40_probe() function in several cases
for error handling which was a bit inefficient here.

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

* Remove an extra check for the variable "base".

* Omit its explicit initialisation at the beginning then.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 drivers/dma/ste_dma40.c | 82 ++++++++++++++++++++++++-------------------------
 1 file changed, 40 insertions(+), 42 deletions(-)

diff --git a/drivers/dma/ste_dma40.c b/drivers/dma/ste_dma40.c
index 9132ae0..8ebfde1 100644
--- a/drivers/dma/ste_dma40.c
+++ b/drivers/dma/ste_dma40.c
@@ -3543,7 +3543,7 @@ static int __init d40_probe(struct platform_device *pdev)
 	struct stedma40_platform_data *plat_data = dev_get_platdata(&pdev->dev);
 	struct device_node *np = pdev->dev.of_node;
 	int ret = -ENOENT;
-	struct d40_base *base = NULL;
+	struct d40_base *base;
 	struct resource *res = NULL;
 	int num_reserved_chans;
 	u32 val;
@@ -3552,17 +3552,17 @@ static int __init d40_probe(struct platform_device *pdev)
 		if (np) {
 			if (d40_of_probe(pdev, np)) {
 				ret = -ENOMEM;
-				goto failure;
+				goto report_failure;
 			}
 		} else {
 			d40_err(&pdev->dev, "No pdata or Device Tree provided\n");
-			goto failure;
+			goto report_failure;
 		}
 	}
 
 	base = d40_hw_detect_init(pdev);
 	if (!base)
-		goto failure;
+		goto report_failure;
 
 	num_reserved_chans = d40_phy_res_init(base);
 
@@ -3693,50 +3693,48 @@ static int __init d40_probe(struct platform_device *pdev)
 	return 0;
 
 failure:
-	if (base) {
-		kmem_cache_destroy(base->desc_slab);
-		if (base->virtbase)
-			iounmap(base->virtbase);
+	kmem_cache_destroy(base->desc_slab);
+	if (base->virtbase)
+		iounmap(base->virtbase);
 
-		if (base->lcla_pool.base && base->plat_data->use_esram_lcla) {
-			iounmap(base->lcla_pool.base);
-			base->lcla_pool.base = NULL;
-		}
+	if (base->lcla_pool.base && base->plat_data->use_esram_lcla) {
+		iounmap(base->lcla_pool.base);
+		base->lcla_pool.base = NULL;
+	}
 
-		if (base->lcla_pool.dma_addr)
-			dma_unmap_single(base->dev, base->lcla_pool.dma_addr,
-					 SZ_1K * base->num_phy_chans,
-					 DMA_TO_DEVICE);
-
-		if (!base->lcla_pool.base_unaligned && base->lcla_pool.base)
-			free_pages((unsigned long)base->lcla_pool.base,
-				   base->lcla_pool.pages);
-
-		kfree(base->lcla_pool.base_unaligned);
-
-		if (base->phy_lcpa)
-			release_mem_region(base->phy_lcpa,
-					   base->lcpa_size);
-		if (base->phy_start)
-			release_mem_region(base->phy_start,
-					   base->phy_size);
-		if (base->clk) {
-			clk_disable_unprepare(base->clk);
-			clk_put(base->clk);
-		}
+	if (base->lcla_pool.dma_addr)
+		dma_unmap_single(base->dev, base->lcla_pool.dma_addr,
+				 SZ_1K * base->num_phy_chans,
+				 DMA_TO_DEVICE);
 
-		if (base->lcpa_regulator) {
-			regulator_disable(base->lcpa_regulator);
-			regulator_put(base->lcpa_regulator);
-		}
+	if (!base->lcla_pool.base_unaligned && base->lcla_pool.base)
+		free_pages((unsigned long)base->lcla_pool.base,
+			   base->lcla_pool.pages);
 
-		kfree(base->lcla_pool.alloc_map);
-		kfree(base->lookup_log_chans);
-		kfree(base->lookup_phy_chans);
-		kfree(base->phy_res);
-		kfree(base);
+	kfree(base->lcla_pool.base_unaligned);
+
+	if (base->phy_lcpa)
+		release_mem_region(base->phy_lcpa,
+				   base->lcpa_size);
+	if (base->phy_start)
+		release_mem_region(base->phy_start,
+				   base->phy_size);
+	if (base->clk) {
+		clk_disable_unprepare(base->clk);
+		clk_put(base->clk);
+	}
+
+	if (base->lcpa_regulator) {
+		regulator_disable(base->lcpa_regulator);
+		regulator_put(base->lcpa_regulator);
 	}
 
+	kfree(base->lcla_pool.alloc_map);
+	kfree(base->lookup_log_chans);
+	kfree(base->lookup_phy_chans);
+	kfree(base->phy_res);
+	kfree(base);
+report_failure:
 	d40_err(&pdev->dev, "probe failed\n");
 	return ret;
 }
-- 
2.6.2

^ permalink raw reply related	[flat|nested] 64+ messages in thread

* [PATCH 3/3] ste_dma40: Delete an unnecessary variable initialisation in d40_probe()
  2015-11-16 21:20                                 ` [PATCH 0/3] ste_dma40: " SF Markus Elfring
  2015-11-16 21:23                                   ` [PATCH 1/3] ste_dma40: Delete an unnecessary check before the function call "kmem_cache_destroy" SF Markus Elfring
  2015-11-16 21:24                                   ` [PATCH 2/3] ste_dma40: Delete another unnecessary check in d40_probe() SF Markus Elfring
@ 2015-11-16 21:26                                   ` SF Markus Elfring
  2015-11-29 21:29                                     ` Linus Walleij
  2015-12-10  3:47                                   ` [PATCH 0/3] ste_dma40: Deletion of a few unnecessary checks Vinod Koul
  3 siblings, 1 reply; 64+ messages in thread
From: SF Markus Elfring @ 2015-11-16 21:26 UTC (permalink / raw)
  To: linux-arm-kernel

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Mon, 16 Nov 2015 22:00:28 +0100

The variable "res" will eventually be set to a resource pointer from
a call of the d40_hw_detect_init(() function.
Thus let us omit the explicit initialisation at the beginning.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 drivers/dma/ste_dma40.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/dma/ste_dma40.c b/drivers/dma/ste_dma40.c
index 8ebfde1..6fb8307 100644
--- a/drivers/dma/ste_dma40.c
+++ b/drivers/dma/ste_dma40.c
@@ -3544,7 +3544,7 @@ static int __init d40_probe(struct platform_device *pdev)
 	struct device_node *np = pdev->dev.of_node;
 	int ret = -ENOENT;
 	struct d40_base *base;
-	struct resource *res = NULL;
+	struct resource *res;
 	int num_reserved_chans;
 	u32 val;
 
-- 
2.6.2

^ permalink raw reply related	[flat|nested] 64+ messages in thread

* [PATCH] pinctrl: Delete unnecessary checks before the function call "pinctrl_unregister"
  2015-11-05 16:17                                 ` [PATCH] pinctrl: Delete unnecessary checks before the function call "pinctrl_unregister" SF Markus Elfring
  2015-11-05 16:53                                   ` Ray Jui
@ 2015-11-17 10:50                                   ` Linus Walleij
  1 sibling, 0 replies; 64+ messages in thread
From: Linus Walleij @ 2015-11-17 10:50 UTC (permalink / raw)
  To: linux-arm-kernel

On Thu, Nov 5, 2015 at 5:17 PM, SF Markus Elfring
<elfring@users.sourceforge.net> wrote:

> From: Markus Elfring <elfring@users.sourceforge.net>
> Date: Thu, 5 Nov 2015 17:10:22 +0100
>
> The pinctrl_unregister() 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 <elfring@users.sourceforge.net>

Patch applied with Ray's Review tag.

Yours,
Linus Walleij

^ permalink raw reply	[flat|nested] 64+ messages in thread

* [PATCH 1/3] ste_dma40: Delete an unnecessary check before the function call "kmem_cache_destroy"
  2015-11-16 21:23                                   ` [PATCH 1/3] ste_dma40: Delete an unnecessary check before the function call "kmem_cache_destroy" SF Markus Elfring
@ 2015-11-29 21:26                                     ` Linus Walleij
  0 siblings, 0 replies; 64+ messages in thread
From: Linus Walleij @ 2015-11-29 21:26 UTC (permalink / raw)
  To: linux-arm-kernel

On Mon, Nov 16, 2015 at 10:23 PM, SF Markus Elfring
<elfring@users.sourceforge.net> wrote:

> From: Markus Elfring <elfring@users.sourceforge.net>
> Date: Mon, 16 Nov 2015 20:26:27 +0100
>
> The kmem_cache_destroy() 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 <elfring@users.sourceforge.net>

Acked-by: Linus Walleij <linus.walleij@linaro.org>

Yours,
Linus Walleij

^ permalink raw reply	[flat|nested] 64+ messages in thread

* [PATCH 2/3] ste_dma40: Delete another unnecessary check in d40_probe()
  2015-11-16 21:24                                   ` [PATCH 2/3] ste_dma40: Delete another unnecessary check in d40_probe() SF Markus Elfring
@ 2015-11-29 21:28                                     ` Linus Walleij
  0 siblings, 0 replies; 64+ messages in thread
From: Linus Walleij @ 2015-11-29 21:28 UTC (permalink / raw)
  To: linux-arm-kernel

On Mon, Nov 16, 2015 at 10:24 PM, SF Markus Elfring
<elfring@users.sourceforge.net> wrote:

> From: Markus Elfring <elfring@users.sourceforge.net>
> Date: Mon, 16 Nov 2015 21:56:07 +0100
>
> A single jump label was used by the d40_probe() function in several cases
> for error handling which was a bit inefficient here.
>
> * This implementation detail could be improved by the introduction
>   of another jump label.
>
> * Remove an extra check for the variable "base".
>
> * Omit its explicit initialisation at the beginning then.
>
> Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>

Acked-by: Linus Walleij <linus.walleij@linaro.org>

Yours,
Linus Walleij

^ permalink raw reply	[flat|nested] 64+ messages in thread

* [PATCH 3/3] ste_dma40: Delete an unnecessary variable initialisation in d40_probe()
  2015-11-16 21:26                                   ` [PATCH 3/3] ste_dma40: Delete an unnecessary variable initialisation " SF Markus Elfring
@ 2015-11-29 21:29                                     ` Linus Walleij
  0 siblings, 0 replies; 64+ messages in thread
From: Linus Walleij @ 2015-11-29 21:29 UTC (permalink / raw)
  To: linux-arm-kernel

On Mon, Nov 16, 2015 at 10:26 PM, SF Markus Elfring
<elfring@users.sourceforge.net> wrote:

> From: Markus Elfring <elfring@users.sourceforge.net>
> Date: Mon, 16 Nov 2015 22:00:28 +0100
>
> The variable "res" will eventually be set to a resource pointer from
> a call of the d40_hw_detect_init(() function.
> Thus let us omit the explicit initialisation at the beginning.
>
> Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>

Acked-by: Linus Walleij <linus.walleij@linaro.org>

Yours,
Linus Walleij

^ permalink raw reply	[flat|nested] 64+ messages in thread

* [PATCH 0/3] ste_dma40: Deletion of a few unnecessary checks
  2015-11-16 21:20                                 ` [PATCH 0/3] ste_dma40: " SF Markus Elfring
                                                     ` (2 preceding siblings ...)
  2015-11-16 21:26                                   ` [PATCH 3/3] ste_dma40: Delete an unnecessary variable initialisation " SF Markus Elfring
@ 2015-12-10  3:47                                   ` Vinod Koul
  3 siblings, 0 replies; 64+ messages in thread
From: Vinod Koul @ 2015-12-10  3:47 UTC (permalink / raw)
  To: linux-arm-kernel

On Mon, Nov 16, 2015 at 10:20:25PM +0100, SF Markus Elfring wrote:
> From: Markus Elfring <elfring@users.sourceforge.net>
> Date: Mon, 16 Nov 2015 22:12:23 +0100
> 
> Further update suggestions were taken into account after a patch
> was applied from static source code analysis.

Applied, thanks

-- 
~Vinod

^ permalink raw reply	[flat|nested] 64+ messages in thread

* [PATCH] drm/rockchip: Delete an unnecessary check before drm_gem_object_unreference_unlocked()
       [not found]                               ` <5317A59D.4@users.sourceforge.net>
                                                   ` (14 preceding siblings ...)
  2015-11-16 21:20                                 ` [PATCH 0/3] ste_dma40: " SF Markus Elfring
@ 2016-07-15 13:35                                 ` SF Markus Elfring
  2016-07-19  1:59                                   ` Mark yao
  2016-07-20 16:40                                 ` [PATCH] GPU-DRM-sun4i: Delete an unnecessary check before drm_fbdev_cma_hotplug_event() SF Markus Elfring
                                                   ` (2 subsequent siblings)
  18 siblings, 1 reply; 64+ messages in thread
From: SF Markus Elfring @ 2016-07-15 13:35 UTC (permalink / raw)
  To: linux-arm-kernel

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Fri, 15 Jul 2016 15:23:22 +0200

The drm_gem_object_unreference_unlocked() 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 <elfring@users.sourceforge.net>
---
 drivers/gpu/drm/rockchip/rockchip_drm_fb.c | 8 ++------
 1 file changed, 2 insertions(+), 6 deletions(-)

diff --git a/drivers/gpu/drm/rockchip/rockchip_drm_fb.c b/drivers/gpu/drm/rockchip/rockchip_drm_fb.c
index 20f12bc..6f64e79 100644
--- a/drivers/gpu/drm/rockchip/rockchip_drm_fb.c
+++ b/drivers/gpu/drm/rockchip/rockchip_drm_fb.c
@@ -43,14 +43,10 @@ struct drm_gem_object *rockchip_fb_get_gem_obj(struct drm_framebuffer *fb,
 static void rockchip_drm_fb_destroy(struct drm_framebuffer *fb)
 {
 	struct rockchip_drm_fb *rockchip_fb = to_rockchip_fb(fb);
-	struct drm_gem_object *obj;
 	int i;
 
-	for (i = 0; i < ROCKCHIP_MAX_FB_BUFFER; i++) {
-		obj = rockchip_fb->obj[i];
-		if (obj)
-			drm_gem_object_unreference_unlocked(obj);
-	}
+	for (i = 0; i < ROCKCHIP_MAX_FB_BUFFER; i++)
+		drm_gem_object_unreference_unlocked(rockchip_fb->obj[i]);
 
 	drm_framebuffer_cleanup(fb);
 	kfree(rockchip_fb);
-- 
2.9.1

^ permalink raw reply related	[flat|nested] 64+ messages in thread

* [PATCH] drm/rockchip: Delete an unnecessary check before drm_gem_object_unreference_unlocked()
  2016-07-15 13:35                                 ` [PATCH] drm/rockchip: Delete an unnecessary check before drm_gem_object_unreference_unlocked() SF Markus Elfring
@ 2016-07-19  1:59                                   ` Mark yao
  0 siblings, 0 replies; 64+ messages in thread
From: Mark yao @ 2016-07-19  1:59 UTC (permalink / raw)
  To: linux-arm-kernel

On 2016?07?15? 21:35, SF Markus Elfring wrote:
> From: Markus Elfring <elfring@users.sourceforge.net>
> Date: Fri, 15 Jul 2016 15:23:22 +0200
>
> The drm_gem_object_unreference_unlocked() 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 <elfring@users.sourceforge.net>
> ---
>   drivers/gpu/drm/rockchip/rockchip_drm_fb.c | 8 ++------
>   1 file changed, 2 insertions(+), 6 deletions(-)
>
> diff --git a/drivers/gpu/drm/rockchip/rockchip_drm_fb.c b/drivers/gpu/drm/rockchip/rockchip_drm_fb.c
> index 20f12bc..6f64e79 100644
> --- a/drivers/gpu/drm/rockchip/rockchip_drm_fb.c
> +++ b/drivers/gpu/drm/rockchip/rockchip_drm_fb.c
> @@ -43,14 +43,10 @@ struct drm_gem_object *rockchip_fb_get_gem_obj(struct drm_framebuffer *fb,
>   static void rockchip_drm_fb_destroy(struct drm_framebuffer *fb)
>   {
>   	struct rockchip_drm_fb *rockchip_fb = to_rockchip_fb(fb);
> -	struct drm_gem_object *obj;
>   	int i;
>   
> -	for (i = 0; i < ROCKCHIP_MAX_FB_BUFFER; i++) {
> -		obj = rockchip_fb->obj[i];
> -		if (obj)
> -			drm_gem_object_unreference_unlocked(obj);
> -	}
> +	for (i = 0; i < ROCKCHIP_MAX_FB_BUFFER; i++)
> +		drm_gem_object_unreference_unlocked(rockchip_fb->obj[i]);
>   
Good, Thanks for the fixes, Applied to my drm-fixes.

>   	drm_framebuffer_cleanup(fb);
>   	kfree(rockchip_fb);


-- 
?ark Yao

^ permalink raw reply	[flat|nested] 64+ messages in thread

* [PATCH] GPU-DRM-sun4i: Delete an unnecessary check before drm_fbdev_cma_hotplug_event()
       [not found]                               ` <5317A59D.4@users.sourceforge.net>
                                                   ` (15 preceding siblings ...)
  2016-07-15 13:35                                 ` [PATCH] drm/rockchip: Delete an unnecessary check before drm_gem_object_unreference_unlocked() SF Markus Elfring
@ 2016-07-20 16:40                                 ` SF Markus Elfring
  2016-07-20 17:47                                   ` Daniel Vetter
  2016-07-22 10:56                                 ` [PATCH] GPU-DRM: Delete an unnecessary check before drm_property_unreference_blob() SF Markus Elfring
  2016-07-23 18:08                                 ` [PATCH] coresight: tmc: Delete an unnecessary check before the function call "kfree" SF Markus Elfring
  18 siblings, 1 reply; 64+ messages in thread
From: SF Markus Elfring @ 2016-07-20 16:40 UTC (permalink / raw)
  To: linux-arm-kernel

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Wed, 20 Jul 2016 18:32:34 +0200

The drm_fbdev_cma_hotplug_event() 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 <elfring@users.sourceforge.net>
---
 drivers/gpu/drm/sun4i/sun4i_framebuffer.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/drivers/gpu/drm/sun4i/sun4i_framebuffer.c b/drivers/gpu/drm/sun4i/sun4i_framebuffer.c
index a0b30c2..70688fe 100644
--- a/drivers/gpu/drm/sun4i/sun4i_framebuffer.c
+++ b/drivers/gpu/drm/sun4i/sun4i_framebuffer.c
@@ -20,8 +20,7 @@ static void sun4i_de_output_poll_changed(struct drm_device *drm)
 {
 	struct sun4i_drv *drv = drm->dev_private;
 
-	if (drv->fbdev)
-		drm_fbdev_cma_hotplug_event(drv->fbdev);
+	drm_fbdev_cma_hotplug_event(drv->fbdev);
 }
 
 static const struct drm_mode_config_funcs sun4i_de_mode_config_funcs = {
-- 
2.9.2

^ permalink raw reply related	[flat|nested] 64+ messages in thread

* [PATCH] GPU-DRM-sun4i: Delete an unnecessary check before drm_fbdev_cma_hotplug_event()
  2016-07-20 16:40                                 ` [PATCH] GPU-DRM-sun4i: Delete an unnecessary check before drm_fbdev_cma_hotplug_event() SF Markus Elfring
@ 2016-07-20 17:47                                   ` Daniel Vetter
  0 siblings, 0 replies; 64+ messages in thread
From: Daniel Vetter @ 2016-07-20 17:47 UTC (permalink / raw)
  To: linux-arm-kernel

On Wed, Jul 20, 2016 at 06:40:49PM +0200, SF Markus Elfring wrote:
> From: Markus Elfring <elfring@users.sourceforge.net>
> Date: Wed, 20 Jul 2016 18:32:34 +0200
> 
> The drm_fbdev_cma_hotplug_event() 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 <elfring@users.sourceforge.net>

Applied to drm-misc, thanks.
-Daniel

> ---
>  drivers/gpu/drm/sun4i/sun4i_framebuffer.c | 3 +--
>  1 file changed, 1 insertion(+), 2 deletions(-)
> 
> diff --git a/drivers/gpu/drm/sun4i/sun4i_framebuffer.c b/drivers/gpu/drm/sun4i/sun4i_framebuffer.c
> index a0b30c2..70688fe 100644
> --- a/drivers/gpu/drm/sun4i/sun4i_framebuffer.c
> +++ b/drivers/gpu/drm/sun4i/sun4i_framebuffer.c
> @@ -20,8 +20,7 @@ static void sun4i_de_output_poll_changed(struct drm_device *drm)
>  {
>  	struct sun4i_drv *drv = drm->dev_private;
>  
> -	if (drv->fbdev)
> -		drm_fbdev_cma_hotplug_event(drv->fbdev);
> +	drm_fbdev_cma_hotplug_event(drv->fbdev);
>  }
>  
>  static const struct drm_mode_config_funcs sun4i_de_mode_config_funcs = {
> -- 
> 2.9.2
> 

-- 
Daniel Vetter
Software Engineer, Intel Corporation
http://blog.ffwll.ch

^ permalink raw reply	[flat|nested] 64+ messages in thread

* [PATCH] GPU-DRM-Exynos: Delete an unnecessary check before the function call "vunmap"
  2015-02-05  8:29                                   ` Joonyoung Shim
  2015-06-27 17:17                                     ` SF Markus Elfring
@ 2016-07-21 17:42                                     ` SF Markus Elfring
  2016-07-21 18:07                                       ` Sean Paul
  1 sibling, 1 reply; 64+ messages in thread
From: SF Markus Elfring @ 2016-07-21 17:42 UTC (permalink / raw)
  To: linux-arm-kernel

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Thu, 21 Jul 2016 19:23:25 +0200

The vunmap() 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 <elfring@users.sourceforge.net>
---
 drivers/gpu/drm/exynos/exynos_drm_fbdev.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/drivers/gpu/drm/exynos/exynos_drm_fbdev.c b/drivers/gpu/drm/exynos/exynos_drm_fbdev.c
index dd09117..4cfb39d 100644
--- a/drivers/gpu/drm/exynos/exynos_drm_fbdev.c
+++ b/drivers/gpu/drm/exynos/exynos_drm_fbdev.c
@@ -269,8 +269,7 @@ static void exynos_drm_fbdev_destroy(struct drm_device *dev,
 	struct exynos_drm_gem *exynos_gem = exynos_fbd->exynos_gem;
 	struct drm_framebuffer *fb;
 
-	if (exynos_gem->kvaddr)
-		vunmap(exynos_gem->kvaddr);
+	vunmap(exynos_gem->kvaddr);
 
 	/* release drm framebuffer and real buffer */
 	if (fb_helper->fb && fb_helper->fb->funcs) {
-- 
2.9.2

^ permalink raw reply related	[flat|nested] 64+ messages in thread

* [PATCH] GPU-DRM-Exynos: Delete an unnecessary check before the function call "vunmap"
  2016-07-21 17:42                                     ` [PATCH] GPU-DRM-Exynos: Delete an unnecessary check before the function call "vunmap" SF Markus Elfring
@ 2016-07-21 18:07                                       ` Sean Paul
  0 siblings, 0 replies; 64+ messages in thread
From: Sean Paul @ 2016-07-21 18:07 UTC (permalink / raw)
  To: linux-arm-kernel

On Thu, Jul 21, 2016 at 1:42 PM, SF Markus Elfring
<elfring@users.sourceforge.net> wrote:
> From: Markus Elfring <elfring@users.sourceforge.net>
> Date: Thu, 21 Jul 2016 19:23:25 +0200
>
> The vunmap() 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 <elfring@users.sourceforge.net>

Applied to drm-misc

> ---
>  drivers/gpu/drm/exynos/exynos_drm_fbdev.c | 3 +--
>  1 file changed, 1 insertion(+), 2 deletions(-)
>
> diff --git a/drivers/gpu/drm/exynos/exynos_drm_fbdev.c b/drivers/gpu/drm/exynos/exynos_drm_fbdev.c
> index dd09117..4cfb39d 100644
> --- a/drivers/gpu/drm/exynos/exynos_drm_fbdev.c
> +++ b/drivers/gpu/drm/exynos/exynos_drm_fbdev.c
> @@ -269,8 +269,7 @@ static void exynos_drm_fbdev_destroy(struct drm_device *dev,
>         struct exynos_drm_gem *exynos_gem = exynos_fbd->exynos_gem;
>         struct drm_framebuffer *fb;
>
> -       if (exynos_gem->kvaddr)
> -               vunmap(exynos_gem->kvaddr);
> +       vunmap(exynos_gem->kvaddr);
>
>         /* release drm framebuffer and real buffer */
>         if (fb_helper->fb && fb_helper->fb->funcs) {
> --
> 2.9.2
>
> _______________________________________________
> dri-devel mailing list
> dri-devel at lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/dri-devel

^ permalink raw reply	[flat|nested] 64+ messages in thread

* [PATCH] GPU-DRM: Delete an unnecessary check before drm_property_unreference_blob()
       [not found]                               ` <5317A59D.4@users.sourceforge.net>
                                                   ` (16 preceding siblings ...)
  2016-07-20 16:40                                 ` [PATCH] GPU-DRM-sun4i: Delete an unnecessary check before drm_fbdev_cma_hotplug_event() SF Markus Elfring
@ 2016-07-22 10:56                                 ` SF Markus Elfring
  2016-07-25  8:43                                   ` Matthias Brugger
  2016-07-23 18:08                                 ` [PATCH] coresight: tmc: Delete an unnecessary check before the function call "kfree" SF Markus Elfring
  18 siblings, 1 reply; 64+ messages in thread
From: SF Markus Elfring @ 2016-07-22 10:56 UTC (permalink / raw)
  To: linux-arm-kernel

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Fri, 22 Jul 2016 12:48:12 +0200

The drm_property_unreference_blob() 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 <elfring@users.sourceforge.net>
---
 drivers/gpu/drm/mediatek/mtk_drm_crtc.c | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)

diff --git a/drivers/gpu/drm/mediatek/mtk_drm_crtc.c b/drivers/gpu/drm/mediatek/mtk_drm_crtc.c
index 24aa3ba..07541d0 100644
--- a/drivers/gpu/drm/mediatek/mtk_drm_crtc.c
+++ b/drivers/gpu/drm/mediatek/mtk_drm_crtc.c
@@ -112,9 +112,7 @@ static void mtk_drm_crtc_reset(struct drm_crtc *crtc)
 	struct mtk_crtc_state *state;
 
 	if (crtc->state) {
-		if (crtc->state->mode_blob)
-			drm_property_unreference_blob(crtc->state->mode_blob);
-
+		drm_property_unreference_blob(crtc->state->mode_blob);
 		state = to_mtk_crtc_state(crtc->state);
 		memset(state, 0, sizeof(*state));
 	} else {
-- 
2.9.2

^ permalink raw reply related	[flat|nested] 64+ messages in thread

* [PATCH] coresight: tmc: Delete an unnecessary check before the function call "kfree"
       [not found]                               ` <5317A59D.4@users.sourceforge.net>
                                                   ` (17 preceding siblings ...)
  2016-07-22 10:56                                 ` [PATCH] GPU-DRM: Delete an unnecessary check before drm_property_unreference_blob() SF Markus Elfring
@ 2016-07-23 18:08                                 ` SF Markus Elfring
  2016-07-25 16:36                                   ` Mathieu Poirier
  18 siblings, 1 reply; 64+ messages in thread
From: SF Markus Elfring @ 2016-07-23 18:08 UTC (permalink / raw)
  To: linux-arm-kernel

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Sat, 23 Jul 2016 20:04:09 +0200

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 <elfring@users.sourceforge.net>
---
 drivers/hwtracing/coresight/coresight-tmc-etf.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/hwtracing/coresight/coresight-tmc-etf.c b/drivers/hwtracing/coresight/coresight-tmc-etf.c
index e68289b..5fa49c4 100644
--- a/drivers/hwtracing/coresight/coresight-tmc-etf.c
+++ b/drivers/hwtracing/coresight/coresight-tmc-etf.c
@@ -168,7 +168,7 @@ out:
 	spin_unlock_irqrestore(&drvdata->spinlock, flags);
 
 	/* Free memory outside the spinlock if need be */
-	if (!used && buf)
+	if (!used)
 		kfree(buf);
 
 	if (!ret)
-- 
2.9.2

^ permalink raw reply related	[flat|nested] 64+ messages in thread

* [PATCH] GPU-DRM: Delete an unnecessary check before drm_property_unreference_blob()
  2016-07-22 10:56                                 ` [PATCH] GPU-DRM: Delete an unnecessary check before drm_property_unreference_blob() SF Markus Elfring
@ 2016-07-25  8:43                                   ` Matthias Brugger
  0 siblings, 0 replies; 64+ messages in thread
From: Matthias Brugger @ 2016-07-25  8:43 UTC (permalink / raw)
  To: linux-arm-kernel



On 22/07/16 12:56, SF Markus Elfring wrote:
> From: Markus Elfring <elfring@users.sourceforge.net>
> Date: Fri, 22 Jul 2016 12:48:12 +0200
>
> The drm_property_unreference_blob() 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 <elfring@users.sourceforge.net>
> ---
>  drivers/gpu/drm/mediatek/mtk_drm_crtc.c | 4 +---
>  1 file changed, 1 insertion(+), 3 deletions(-)
>

Reviewed-by: Matthias Brugger <matthias.bgg@gmail.com>

> diff --git a/drivers/gpu/drm/mediatek/mtk_drm_crtc.c b/drivers/gpu/drm/mediatek/mtk_drm_crtc.c
> index 24aa3ba..07541d0 100644
> --- a/drivers/gpu/drm/mediatek/mtk_drm_crtc.c
> +++ b/drivers/gpu/drm/mediatek/mtk_drm_crtc.c
> @@ -112,9 +112,7 @@ static void mtk_drm_crtc_reset(struct drm_crtc *crtc)
>  	struct mtk_crtc_state *state;
>
>  	if (crtc->state) {
> -		if (crtc->state->mode_blob)
> -			drm_property_unreference_blob(crtc->state->mode_blob);
> -
> +		drm_property_unreference_blob(crtc->state->mode_blob);
>  		state = to_mtk_crtc_state(crtc->state);
>  		memset(state, 0, sizeof(*state));
>  	} else {
>

^ permalink raw reply	[flat|nested] 64+ messages in thread

* [PATCH] coresight: tmc: Delete an unnecessary check before the function call "kfree"
  2016-07-23 18:08                                 ` [PATCH] coresight: tmc: Delete an unnecessary check before the function call "kfree" SF Markus Elfring
@ 2016-07-25 16:36                                   ` Mathieu Poirier
  0 siblings, 0 replies; 64+ messages in thread
From: Mathieu Poirier @ 2016-07-25 16:36 UTC (permalink / raw)
  To: linux-arm-kernel

On 23 July 2016 at 12:08, SF Markus Elfring
<elfring@users.sourceforge.net> wrote:
> From: Markus Elfring <elfring@users.sourceforge.net>
> Date: Sat, 23 Jul 2016 20:04:09 +0200
>
> 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 <elfring@users.sourceforge.net>
> ---
>  drivers/hwtracing/coresight/coresight-tmc-etf.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/drivers/hwtracing/coresight/coresight-tmc-etf.c b/drivers/hwtracing/coresight/coresight-tmc-etf.c
> index e68289b..5fa49c4 100644
> --- a/drivers/hwtracing/coresight/coresight-tmc-etf.c
> +++ b/drivers/hwtracing/coresight/coresight-tmc-etf.c
> @@ -168,7 +168,7 @@ out:
>         spin_unlock_irqrestore(&drvdata->spinlock, flags);
>
>         /* Free memory outside the spinlock if need be */
> -       if (!used && buf)
> +       if (!used)
>                 kfree(buf);
>
>         if (!ret)
> --
> 2.9.2
>

Applied - thanks.
Mathieu

^ permalink raw reply	[flat|nested] 64+ messages in thread

end of thread, other threads:[~2016-07-25 16:36 UTC | newest]

Thread overview: 64+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
     [not found] <5307CAA2.8060406@users.sourceforge.net>
     [not found] ` <alpine.DEB.2.02.1402212321410.2043@localhost6.localdomain6>
     [not found]   ` <530A086E.8010901@users.sourceforge.net>
     [not found]     ` <alpine.DEB.2.02.1402231635510.1985@localhost6.localdomain6>
     [not found]       ` <530A72AA.3000601@users.sourceforge.net>
     [not found]         ` <alpine.DEB.2.02.1402240658210.2090@localhost6.localdomain6>
     [not found]           ` <530B5FB6.6010207@users.sourceforge.net>
     [not found]             ` <alpine.DEB.2.10.1402241710370.2074@hadrien>
     [not found]               ` <530C5E18.1020800@users.sourceforge.net>
     [not found]                 ` <alpine.DEB.2.10.1402251014170.2080@hadrien>
     [not found]                   ` <530CD2C4.4050903@users.sourceforge.net>
     [not found]                     ` <alpine.DEB.2.10.1402251840450.7035@hadrien>
     [not found]                       ` <530CF8FF.8080600@users.sourceforge.net>
     [not found]                         ` <alpine.DEB.2.02.1402252117150.2047@localhost6.localdomain6>
     [not found]                           ` <530DD06F.4090703@users.sourceforge.net>
     [not found]                             ` <alpine.DEB.2.02.1402262129250.2221@localhost6.localdomain6>
     [not found]                               ` <5317A59D.4@users.sourceforge.net>
2014-11-20 10:50                                 ` [PATCH 1/1] [media] platform: Deletion of unnecessary checks before two function calls SF Markus Elfring
2014-11-20 13:50                                 ` [PATCH 1/1] net: Xilinx: " SF Markus Elfring
2014-11-20 17:29                                   ` Sören Brinkmann
2014-11-21 20:14                                   ` David Miller
2014-11-21 10:12                                 ` [PATCH 1/1] thermal: Exynos: " SF Markus Elfring
2014-11-21 10:17                                   ` Julia Lawall
2014-11-21 13:25                                     ` SF Markus Elfring
2014-11-21 16:17                                     ` [PATCH v2] " SF Markus Elfring
2014-11-22 10:00                                 ` [PATCH 1/1] ARM: OMAP2: Deletion of unnecessary checks before three " SF Markus Elfring
2015-06-30 12:10                                   ` [PATCH] ARM: OMAP2: Delete " SF Markus Elfring
2015-07-16  5:55                                     ` Paul Walmsley
2015-07-16  6:23                                       ` Tony Lindgren
2015-07-16 14:06                                         ` Paul Walmsley
2015-07-16 16:28                                           ` Tony Lindgren
2015-07-16  6:40                                       ` SF Markus Elfring
2014-11-22 10:40                                 ` [PATCH 1/1] ARM-kernel: Deletion of unnecessary checks before two " SF Markus Elfring
2014-12-03  8:15                                 ` [PATCH] ARM: DaVinci: Deletion of an unnecessary check before the function call "__clk_disable" SF Markus Elfring
2014-12-03  9:10                                   ` SF Markus Elfring
2015-02-04 21:00                                 ` [PATCH] GPU-DRM-Exynos: Delete unnecessary checks before two function calls SF Markus Elfring
2015-02-05  8:29                                   ` Joonyoung Shim
2015-06-27 17:17                                     ` SF Markus Elfring
2016-07-21 17:42                                     ` [PATCH] GPU-DRM-Exynos: Delete an unnecessary check before the function call "vunmap" SF Markus Elfring
2016-07-21 18:07                                       ` Sean Paul
2015-06-25 11:33                                 ` [PATCH 0/2] ARM-OMAP2+: Deletion of unnecessary checks before two function calls SF Markus Elfring
2015-06-25 11:38                                   ` [PATCH 1/2] ARM-OMAP2+: Delete an unnecessary check before the function call "omap_device_delete" SF Markus Elfring
2015-06-25 11:40                                   ` [PATCH 2/2] ARM-OMAP2+: Delete an unnecessary check before the function call "of_node_put" SF Markus Elfring
2015-07-15  6:41                                   ` [PATCH 0/2] ARM-OMAP2+: Deletion of unnecessary checks before two function calls Tony Lindgren
2015-06-25 13:27                                 ` [PATCH 0/2] ARM-kernel: " SF Markus Elfring
2015-06-25 13:30                                   ` [PATCH 1/2] ARM-kernel: Delete an unnecessary check before the function call "smp_set_ops" SF Markus Elfring
2015-06-25 13:32                                   ` [PATCH 2/2] ARM-kernel: Delete an unnecessary check before the function call "unwind_table_del" SF Markus Elfring
2015-06-28 14:05                                 ` [PATCH] iommu/arm-smmu: Delete an unnecessary check before the function call "free_io_pgtable_ops" SF Markus Elfring
2015-11-06 17:38                                   ` [PATCH] iommu/arm-smmu: Delete an unnecessary check before free_io_pgtable_ops() SF Markus Elfring
2015-06-28 14:52                                 ` [PATCH] PCI-iproc: Delete unnecessary checks before two function calls SF Markus Elfring
2015-06-29 16:45                                   ` Ray Jui
2015-07-14 20:10                                   ` Bjorn Helgaas
2015-07-14 20:23                                     ` Ray Jui
2015-07-14 20:51                                       ` Bjorn Helgaas
2015-07-14 20:53                                         ` Ray Jui
2015-06-29 10:48                                 ` [PATCH] net-Liquidio: Delete unnecessary checks before the function call "vfree" SF Markus Elfring
2015-06-29 16:28                                   ` David Miller
2015-11-05 16:17                                 ` [PATCH] pinctrl: Delete unnecessary checks before the function call "pinctrl_unregister" SF Markus Elfring
2015-11-05 16:53                                   ` Ray Jui
2015-11-17 10:50                                   ` Linus Walleij
2015-11-05 18:45                                 ` [PATCH 0/2] [media] c8sectpfe: Deletion of a few unnecessary checks SF Markus Elfring
2015-11-05 18:49                                   ` [PATCH 1/2] [media] c8sectpfe: Delete unnecessary checks before two function calls SF Markus Elfring
2015-11-05 18:50                                   ` [PATCH 2/2] [media] c8sectpfe: Combine three checks into a single if block SF Markus Elfring
2015-11-06 10:09                                     ` walter harms
2015-11-06  7:50                                   ` [PATCH 0/2] [media] c8sectpfe: Deletion of a few unnecessary checks Maxime Coquelin
2015-11-16 21:20                                 ` [PATCH 0/3] ste_dma40: " SF Markus Elfring
2015-11-16 21:23                                   ` [PATCH 1/3] ste_dma40: Delete an unnecessary check before the function call "kmem_cache_destroy" SF Markus Elfring
2015-11-29 21:26                                     ` Linus Walleij
2015-11-16 21:24                                   ` [PATCH 2/3] ste_dma40: Delete another unnecessary check in d40_probe() SF Markus Elfring
2015-11-29 21:28                                     ` Linus Walleij
2015-11-16 21:26                                   ` [PATCH 3/3] ste_dma40: Delete an unnecessary variable initialisation " SF Markus Elfring
2015-11-29 21:29                                     ` Linus Walleij
2015-12-10  3:47                                   ` [PATCH 0/3] ste_dma40: Deletion of a few unnecessary checks Vinod Koul
2016-07-15 13:35                                 ` [PATCH] drm/rockchip: Delete an unnecessary check before drm_gem_object_unreference_unlocked() SF Markus Elfring
2016-07-19  1:59                                   ` Mark yao
2016-07-20 16:40                                 ` [PATCH] GPU-DRM-sun4i: Delete an unnecessary check before drm_fbdev_cma_hotplug_event() SF Markus Elfring
2016-07-20 17:47                                   ` Daniel Vetter
2016-07-22 10:56                                 ` [PATCH] GPU-DRM: Delete an unnecessary check before drm_property_unreference_blob() SF Markus Elfring
2016-07-25  8:43                                   ` Matthias Brugger
2016-07-23 18:08                                 ` [PATCH] coresight: tmc: Delete an unnecessary check before the function call "kfree" SF Markus Elfring
2016-07-25 16:36                                   ` Mathieu Poirier

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).