From patchwork Wed Dec 21 10:19:33 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexander Stein X-Patchwork-Id: 9482821 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 02E2360772 for ; Wed, 21 Dec 2016 10:22:00 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id E938627FB6 for ; Wed, 21 Dec 2016 10:21:59 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id DDEAD283FD; Wed, 21 Dec 2016 10:21:59 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-4.2 required=2.0 tests=BAYES_00, RCVD_IN_DNSWL_MED autolearn=ham version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.9]) (using TLSv1.2 with cipher AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 4174F27FB6 for ; Wed, 21 Dec 2016 10:21:59 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.85_2 #1 (Red Hat Linux)) id 1cJe0Q-0004wn-LM; Wed, 21 Dec 2016 10:20:18 +0000 Received: from webbox1416.server-home.net ([77.236.96.61]) by bombadil.infradead.org with esmtp (Exim 4.85_2 #1 (Red Hat Linux)) id 1cJe0L-00042k-Ou for linux-arm-kernel@lists.infradead.org; Wed, 21 Dec 2016 10:20:15 +0000 Received: from imapserver.systec-electronic.com (unknown [212.185.67.146]) by webbox1416.server-home.net (Postfix) with ESMTPA id 66C6D27A553; Wed, 21 Dec 2016 11:19:49 +0100 (CET) Received: from localhost (localhost [127.0.0.1]) by imapserver.systec-electronic.com (Postfix) with ESMTP id 25D46DA0A4F; Wed, 21 Dec 2016 11:19:49 +0100 (CET) X-Virus-Scanned: Debian amavisd-new at imapserver.systec-electronic.com Received: from imapserver.systec-electronic.com ([127.0.0.1]) by localhost (imapserver.systec-electronic.com [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id jTW0QuHNnJPk; Wed, 21 Dec 2016 11:19:46 +0100 (CET) Received: from localhost.localdomain (ws-stein.systec.local [192.168.10.118]) by imapserver.systec-electronic.com (Postfix) with ESMTP id 77771DA0A57; Wed, 21 Dec 2016 11:19:46 +0100 (CET) From: Alexander Stein To: Peter Zijlstra , Ingo Molnar , Arnaldo Carvalho de Melo , Alexander Shishkin , Will Deacon , Mark Rutland , Russell King Subject: [PATCH 1/3] drivers/perf: arm_pmu: Use devm_ allocators Date: Wed, 21 Dec 2016 11:19:33 +0100 Message-Id: <20161221101935.17178-2-alexander.stein@systec-electronic.com> X-Mailer: git-send-email 2.10.2 In-Reply-To: <20161221101935.17178-1-alexander.stein@systec-electronic.com> References: <20161221101935.17178-1-alexander.stein@systec-electronic.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20161221_022014_102259_BB5BE158 X-CRM114-Status: GOOD ( 11.32 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, Alexander Stein MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Virus-Scanned: ClamAV using ClamSMTP This eliminates several calls to kfree. Signed-off-by: Alexander Stein --- drivers/perf/arm_pmu.c | 14 ++++---------- 1 file changed, 4 insertions(+), 10 deletions(-) diff --git a/drivers/perf/arm_pmu.c b/drivers/perf/arm_pmu.c index b37b572..a9bbdbf 100644 --- a/drivers/perf/arm_pmu.c +++ b/drivers/perf/arm_pmu.c @@ -917,7 +917,8 @@ static int of_pmu_irq_cfg(struct arm_pmu *pmu) bool using_spi = false; struct platform_device *pdev = pmu->plat_device; - irqs = kcalloc(pdev->num_resources, sizeof(*irqs), GFP_KERNEL); + irqs = devm_kcalloc(&pdev->dev, pdev->num_resources, sizeof(*irqs), + GFP_KERNEL); if (!irqs) return -ENOMEM; @@ -939,7 +940,6 @@ static int of_pmu_irq_cfg(struct arm_pmu *pmu) pr_err("PPI/SPI IRQ type mismatch for %s!\n", dn->name); of_node_put(dn); - kfree(irqs); return -EINVAL; } @@ -988,10 +988,8 @@ static int of_pmu_irq_cfg(struct arm_pmu *pmu) int ret; ret = irq_get_percpu_devid_partition(irq, &pmu->supported_cpus); - if (ret) { - kfree(irqs); + if (ret) return ret; - } } else { /* Otherwise default to all CPUs */ cpumask_setall(&pmu->supported_cpus); @@ -1001,8 +999,6 @@ static int of_pmu_irq_cfg(struct arm_pmu *pmu) /* If we matched up the IRQ affinities, use them to route the SPIs */ if (using_spi && i == pdev->num_resources) pmu->irq_affinity = irqs; - else - kfree(irqs); return 0; } @@ -1017,7 +1013,7 @@ int arm_pmu_device_probe(struct platform_device *pdev, struct arm_pmu *pmu; int ret = -ENODEV; - pmu = kzalloc(sizeof(struct arm_pmu), GFP_KERNEL); + pmu = devm_kzalloc(&pdev->dev, sizeof(struct arm_pmu), GFP_KERNEL); if (!pmu) { pr_info("failed to allocate PMU device!\n"); return -ENOMEM; @@ -1074,8 +1070,6 @@ int arm_pmu_device_probe(struct platform_device *pdev, out_free: pr_info("%s: failed to register PMU devices!\n", of_node_full_name(node)); - kfree(pmu->irq_affinity); - kfree(pmu); return ret; }