mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH -next] drivers: CCI: fix the error handle in cci_pmu_probe()
@ 2013-09-22  5:04 Wei Yongjun
  2013-09-24  9:32 ` Will Deacon
  0 siblings, 1 reply; 2+ messages in thread
From: Wei Yongjun @ 2013-09-22  5:04 UTC (permalink / raw)
  To: grant.likely, rob.herring, nico, will.deacon, lorenzo.pieralisi,
	dave.martin, sudeep.karkadanagesha
  Cc: yongjun_wei, linux-kernel, devicetree

From: Wei Yongjun <yongjun_wei@trendmicro.com.cn>

This patch fix the error handle of function cci_pmu_probe():
- using IS_ERR() instead of NULL test for the return value of
  devm_ioremap_resource() since it nerver return NULL.
- remove kfree() for devm_kzalloc allocated memory
- remove dev_warn() since devm_ioremap_resource() has error message
  already.

Signed-off-by: Wei Yongjun <yongjun_wei@trendmicro.com.cn>
---
 drivers/bus/arm-cci.c | 33 +++++++--------------------------
 1 file changed, 7 insertions(+), 26 deletions(-)

diff --git a/drivers/bus/arm-cci.c b/drivers/bus/arm-cci.c
index dc6528e..edad26c 100644
--- a/drivers/bus/arm-cci.c
+++ b/drivers/bus/arm-cci.c
@@ -565,18 +565,9 @@ static int cci_pmu_probe(struct platform_device *pdev)
 		return -ENOMEM;
 
 	res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
-	if (!res) {
-		dev_warn(&pdev->dev, "Failed to get mem resource\n");
-		ret = -EINVAL;
-		goto memalloc_err;
-	};
-
 	pmu->base = devm_ioremap_resource(&pdev->dev, res);
-	if (!pmu->base) {
-		dev_warn(&pdev->dev, "Failed to ioremap\n");
-		ret = -ENOMEM;
-		goto memalloc_err;
-	}
+	if (IS_ERR(pmu->base))
+		return -ENOMEM;
 
 	/*
 	 * CCI PMU has 5 overflow signals - one per counter; but some may be tied
@@ -601,22 +592,18 @@ static int cci_pmu_probe(struct platform_device *pdev)
 	if (i < CCI_PMU_MAX_HW_EVENTS) {
 		dev_warn(&pdev->dev, "In-correct number of interrupts: %d, should be %d\n",
 			i, CCI_PMU_MAX_HW_EVENTS);
-		ret = -EINVAL;
-		goto memalloc_err;
+		return -EINVAL;
 	}
 
 	pmu->port_ranges = port_range_by_rev();
 	if (!pmu->port_ranges) {
 		dev_warn(&pdev->dev, "CCI PMU version not supported\n");
-		ret = -EINVAL;
-		goto memalloc_err;
+		return -EINVAL;
 	}
 
 	pmu->cci_pmu = devm_kzalloc(&pdev->dev, sizeof(*(pmu->cci_pmu)), GFP_KERNEL);
-	if (!pmu->cci_pmu) {
-		ret = -ENOMEM;
-		goto memalloc_err;
-	}
+	if (!pmu->cci_pmu)
+		return -ENOMEM;
 
 	pmu->hw_events.events = pmu->events;
 	pmu->hw_events.used_mask = pmu->used_mask;
@@ -624,15 +611,9 @@ static int cci_pmu_probe(struct platform_device *pdev)
 
 	ret = cci_pmu_init(pmu->cci_pmu, pdev);
 	if (ret)
-		goto pmuinit_err;
+		return ret;
 
 	return 0;
-
-pmuinit_err:
-	kfree(pmu->cci_pmu);
-memalloc_err:
-	kfree(pmu);
-	return ret;
 }
 
 static int cci_platform_probe(struct platform_device *pdev)


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

* Re: [PATCH -next] drivers: CCI: fix the error handle in cci_pmu_probe()
  2013-09-22  5:04 [PATCH -next] drivers: CCI: fix the error handle in cci_pmu_probe() Wei Yongjun
@ 2013-09-24  9:32 ` Will Deacon
  0 siblings, 0 replies; 2+ messages in thread
From: Will Deacon @ 2013-09-24  9:32 UTC (permalink / raw)
  To: Wei Yongjun
  Cc: grant.likely, rob.herring, nico, Lorenzo Pieralisi, dave.martin,
	Sudeep KarkadaNagesha, yongjun_wei, linux-kernel, devicetree

On Sun, Sep 22, 2013 at 06:04:23AM +0100, Wei Yongjun wrote:
> From: Wei Yongjun <yongjun_wei@trendmicro.com.cn>
> 
> This patch fix the error handle of function cci_pmu_probe():
> - using IS_ERR() instead of NULL test for the return value of
>   devm_ioremap_resource() since it nerver return NULL.
> - remove kfree() for devm_kzalloc allocated memory
> - remove dev_warn() since devm_ioremap_resource() has error message
>   already.
> 
> Signed-off-by: Wei Yongjun <yongjun_wei@trendmicro.com.cn>

Cheers Wei, I'll add this as a new patch on top of my perf branch.

Will

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

end of thread, other threads:[~2013-09-24  9:32 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-09-22  5:04 [PATCH -next] drivers: CCI: fix the error handle in cci_pmu_probe() Wei Yongjun
2013-09-24  9:32 ` Will Deacon

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®