From patchwork Mon Sep 11 13:01:01 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Masahiro Yamada X-Patchwork-Id: 9947343 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 5AFD7602C9 for ; Mon, 11 Sep 2017 13:02:27 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 4431F285DB for ; Mon, 11 Sep 2017 13:02:27 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 38EF6286AB; Mon, 11 Sep 2017 13:02:27 +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,DKIM_SIGNED, DKIM_VALID,RCVD_IN_DNSWL_MED autolearn=ham version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [65.50.211.133]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id B9AD7285DB for ; Mon, 11 Sep 2017 13:02:26 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:MIME-Version:Cc:List-Subscribe: List-Help:List-Post:List-Archive:List-Unsubscribe:List-Id:References: In-Reply-To:Message-Id:Date:Subject:To:From:Reply-To:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Owner; bh=PBbYE1xRpENd67YQRMwZmSoVYhcfbVrniBC1J5KNzUE=; b=dLtAKie+2Aj+B7XfOh53FaSOYw AYbyP3NViQySkvqbDFGIh6qtvppAMBUFvv4piG+k+KbrFZ1ygwttenFGuzAbbh9542VM6iwNp6Sam mnLfECJi4b9UJJQYW7/eWZt+48RQ03SvlwJIz6apuDTGYd41ZsLWXndIkzADeqC4PCL/jVB6JiwLb +nu9Slu0KE/I8sT8W309PhCn3fWDOWib4z/exU3fz5RVbrjUzRrcyjhzV8l5UIaltgiCr/IijqGyI 9BzWnxdePIbd/gIIq7caSLSXLTc9I8l1vtT96FcchZEZ0sNuooIfkc49gtVBGSDJoW9sdvp2CXhLq 9Ks5Brsw==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.87 #1 (Red Hat Linux)) id 1drOM1-0004KH-2g; Mon, 11 Sep 2017 13:02:21 +0000 Received: from conuserg-12.nifty.com ([210.131.2.79]) by bombadil.infradead.org with esmtps (Exim 4.87 #1 (Red Hat Linux)) id 1drOLx-0004Hk-Mn; Mon, 11 Sep 2017 13:02:19 +0000 Received: from pug.e01.socionext.com (p14092-ipngnfx01kyoto.kyoto.ocn.ne.jp [153.142.97.92]) (authenticated) by conuserg-12.nifty.com with ESMTP id v8BD1I4Y001997; Mon, 11 Sep 2017 22:01:20 +0900 DKIM-Filter: OpenDKIM Filter v2.10.3 conuserg-12.nifty.com v8BD1I4Y001997 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nifty.com; s=dec2015msa; t=1505134881; bh=X52ca2UoLyliDphAC/BBOhOi9nkkHyWNjTnaUBEjfuU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=mg7IGa0z0vyikbs77/pFU6hFd+4npdwN63QZ/luczRe+ZrcSyBpuqFfnG566SvjYs YHsW+828Fr0/kHK5c2yC0/fv6QTF747CYVp2ySmSuratQVbWAEmO+VdoZ/TTU62/CZ zoHAvttuSDhTvk7mCmuNkLq/W3C1oQJtfP6PzIXHCt0udhP8dXZ8Y8ecvZn2cVOjbO I/WfLB4Bk9KiwIr+Rlwm9nMfiSDHH0jWbpSzv2W8QzyPejuEEsBvorc9wlsSsCImU6 m5P1tSE3MGZ7naYrnWyvtCjQmENUOcy/gCA69kAeHY9eoHgvArAs1TxdzY5I2riDt3 bQ4xacP9Jy2fA== X-Nifty-SrcIP: [153.142.97.92] From: Masahiro Yamada To: Srinivas Kandagatla Subject: [PATCH 2/5] nvmem: mtk-efuse: use stack for nvmem_config instead of malloc'ing it Date: Mon, 11 Sep 2017 22:01:01 +0900 Message-Id: <1505134864-11975-3-git-send-email-yamada.masahiro@socionext.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1505134864-11975-1-git-send-email-yamada.masahiro@socionext.com> References: <1505134864-11975-1-git-send-email-yamada.masahiro@socionext.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20170911_060218_003708_D790ACE9 X-CRM114-Status: UNSURE ( 8.21 ) X-CRM114-Notice: Please train this message. X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Jassi Brar , Keiji Hayashibara , linux-kernel@vger.kernel.org, Masahiro Yamada , linux-mediatek@lists.infradead.org, Masami Hiramatsu , Matthias Brugger , linux-arm-kernel@lists.infradead.org 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 nvmem_register() copies all the members of nvmem_config to nvmem_device. So, nvmem_config is one-time use data during probing. There is no point to keep it until the driver detach. Using stack should be no problem because nvmem_config is pretty small. Signed-off-by: Masahiro Yamada Acked-by: Sean Wang --- drivers/nvmem/mtk-efuse.c | 24 ++++++++++-------------- 1 file changed, 10 insertions(+), 14 deletions(-) diff --git a/drivers/nvmem/mtk-efuse.c b/drivers/nvmem/mtk-efuse.c index 32fd572..fa7a0f6 100644 --- a/drivers/nvmem/mtk-efuse.c +++ b/drivers/nvmem/mtk-efuse.c @@ -49,7 +49,7 @@ static int mtk_efuse_probe(struct platform_device *pdev) struct device *dev = &pdev->dev; struct resource *res; struct nvmem_device *nvmem; - struct nvmem_config *econfig; + struct nvmem_config econfig = {}; void __iomem *base; res = platform_get_resource(pdev, IORESOURCE_MEM, 0); @@ -57,19 +57,15 @@ static int mtk_efuse_probe(struct platform_device *pdev) if (IS_ERR(base)) return PTR_ERR(base); - econfig = devm_kzalloc(dev, sizeof(*econfig), GFP_KERNEL); - if (!econfig) - return -ENOMEM; - - econfig->stride = 4; - econfig->word_size = 4; - econfig->reg_read = mtk_reg_read; - econfig->reg_write = mtk_reg_write; - econfig->size = resource_size(res); - econfig->priv = base; - econfig->dev = dev; - econfig->owner = THIS_MODULE; - nvmem = nvmem_register(econfig); + econfig.stride = 4; + econfig.word_size = 4; + econfig.reg_read = mtk_reg_read; + econfig.reg_write = mtk_reg_write; + econfig.size = resource_size(res); + econfig.priv = base; + econfig.dev = dev; + econfig.owner = THIS_MODULE; + nvmem = nvmem_register(&econfig); if (IS_ERR(nvmem)) return PTR_ERR(nvmem);