Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932467AbcLGPPf (ORCPT ); Wed, 7 Dec 2016 10:15:35 -0500 Received: from mail-pg0-f67.google.com ([74.125.83.67]:34951 "EHLO mail-pg0-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932192AbcLGPPd (ORCPT ); Wed, 7 Dec 2016 10:15:33 -0500 From: Arvind Yadav To: boris.brezillon@free-electrons.com, richard@nod.at, dwmw2@infradead.org, computersforpeace@gmail.com, marek.vasut@gmail.com, cyrille.pitchen@atmel.com Cc: linux-mtd@lists.infradead.org, linux-kernel@vger.kernel.org Subject: [PATCH V1] mtd : nand : denali :- No need of devm functions Date: Wed, 7 Dec 2016 20:45:11 +0530 Message-Id: <1481123711-7205-1-git-send-email-arvind.yadav.cs@gmail.com> X-Mailer: git-send-email 2.7.4 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1639 Lines: 49 In function denali_init, the memory allocated for denali->buf.buf is live within the function only. After the allocation it is immediately freed with devm_kfree. There is no need to allocate memory for denali->buf.buf with devm function so replace devm_kzalloc with kzalloc and devm_kfree with kfree. Signed-off-by: Arvind Yadav --- drivers/mtd/nand/denali.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/drivers/mtd/nand/denali.c b/drivers/mtd/nand/denali.c index 0476ae8..ce3c31f 100644 --- a/drivers/mtd/nand/denali.c +++ b/drivers/mtd/nand/denali.c @@ -1476,8 +1476,7 @@ int denali_init(struct denali_nand_info *denali) } /* allocate a temporary buffer for nand_scan_ident() */ - denali->buf.buf = devm_kzalloc(denali->dev, PAGE_SIZE, - GFP_DMA | GFP_KERNEL); + denali->buf.buf = kzalloc(PAGE_SIZE, GFP_DMA | GFP_KERNEL); if (!denali->buf.buf) return -ENOMEM; @@ -1492,6 +1491,7 @@ int denali_init(struct denali_nand_info *denali) if (request_irq(denali->irq, denali_isr, IRQF_SHARED, DENALI_NAND_NAME, denali)) { pr_err("Spectra: Unable to allocate IRQ\n"); + kfree(denali->buf.buf); return -ENODEV; } @@ -1512,11 +1512,12 @@ int denali_init(struct denali_nand_info *denali) */ if (nand_scan_ident(mtd, denali->max_banks, NULL)) { ret = -ENXIO; + kfree(denali->buf.buf); goto failed_req_irq; } /* allocate the right size buffer now */ - devm_kfree(denali->dev, denali->buf.buf); + kfree(denali->buf.buf); denali->buf.buf = devm_kzalloc(denali->dev, mtd->writesize + mtd->oobsize, GFP_KERNEL); -- 2.7.4