aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/bus
diff options
context:
space:
mode:
authorWei Yongjun <yongjun_wei@trendmicro.com.cn>2013-09-22 01:04:23 -0400
committerWill Deacon <will.deacon@arm.com>2013-09-24 09:03:05 -0400
commitfee4f2c66a3b0f0e97e16b3084e8c4151ae9196f (patch)
tree0813f6628bfa21f58428d8cd5891671636fb0644 /drivers/bus
parentb91c8f284acc2cb2aa43a1ce58322573ad983a14 (diff)
drivers: CCI: fix the error handle in cci_pmu_probe()
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> Signed-off-by: Will Deacon <will.deacon@arm.com>
Diffstat (limited to 'drivers/bus')
-rw-r--r--drivers/bus/arm-cci.c33
1 files changed, 7 insertions, 26 deletions
diff --git a/drivers/bus/arm-cci.c b/drivers/bus/arm-cci.c
index dc6528e8b8fb..bb5b90e8e768 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)
565 return -ENOMEM; 565 return -ENOMEM;
566 566
567 res = platform_get_resource(pdev, IORESOURCE_MEM, 0); 567 res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
568 if (!res) {
569 dev_warn(&pdev->dev, "Failed to get mem resource\n");
570 ret = -EINVAL;
571 goto memalloc_err;
572 };
573
574 pmu->base = devm_ioremap_resource(&pdev->dev, res); 568 pmu->base = devm_ioremap_resource(&pdev->dev, res);
575 if (!pmu->base) { 569 if (IS_ERR(pmu->base))
576 dev_warn(&pdev->dev, "Failed to ioremap\n"); 570 return -ENOMEM;
577 ret = -ENOMEM;
578 goto memalloc_err;
579 }
580 571
581 /* 572 /*
582 * CCI PMU has 5 overflow signals - one per counter; but some may be tied 573 * 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)
601 if (i < CCI_PMU_MAX_HW_EVENTS) { 592 if (i < CCI_PMU_MAX_HW_EVENTS) {
602 dev_warn(&pdev->dev, "In-correct number of interrupts: %d, should be %d\n", 593 dev_warn(&pdev->dev, "In-correct number of interrupts: %d, should be %d\n",
603 i, CCI_PMU_MAX_HW_EVENTS); 594 i, CCI_PMU_MAX_HW_EVENTS);
604 ret = -EINVAL; 595 return -EINVAL;
605 goto memalloc_err;
606 } 596 }
607 597
608 pmu->port_ranges = port_range_by_rev(); 598 pmu->port_ranges = port_range_by_rev();
609 if (!pmu->port_ranges) { 599 if (!pmu->port_ranges) {
610 dev_warn(&pdev->dev, "CCI PMU version not supported\n"); 600 dev_warn(&pdev->dev, "CCI PMU version not supported\n");
611 ret = -EINVAL; 601 return -EINVAL;
612 goto memalloc_err;
613 } 602 }
614 603
615 pmu->cci_pmu = devm_kzalloc(&pdev->dev, sizeof(*(pmu->cci_pmu)), GFP_KERNEL); 604 pmu->cci_pmu = devm_kzalloc(&pdev->dev, sizeof(*(pmu->cci_pmu)), GFP_KERNEL);
616 if (!pmu->cci_pmu) { 605 if (!pmu->cci_pmu)
617 ret = -ENOMEM; 606 return -ENOMEM;
618 goto memalloc_err;
619 }
620 607
621 pmu->hw_events.events = pmu->events; 608 pmu->hw_events.events = pmu->events;
622 pmu->hw_events.used_mask = pmu->used_mask; 609 pmu->hw_events.used_mask = pmu->used_mask;
@@ -624,15 +611,9 @@ static int cci_pmu_probe(struct platform_device *pdev)
624 611
625 ret = cci_pmu_init(pmu->cci_pmu, pdev); 612 ret = cci_pmu_init(pmu->cci_pmu, pdev);
626 if (ret) 613 if (ret)
627 goto pmuinit_err; 614 return ret;
628 615
629 return 0; 616 return 0;
630
631pmuinit_err:
632 kfree(pmu->cci_pmu);
633memalloc_err:
634 kfree(pmu);
635 return ret;
636} 617}
637 618
638static int cci_platform_probe(struct platform_device *pdev) 619static int cci_platform_probe(struct platform_device *pdev)