From patchwork Fri Oct 20 16:57:39 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Masahiro Yamada X-Patchwork-Id: 116519 Delivered-To: patch@linaro.org Received: by 10.140.22.164 with SMTP id 33csp1907790qgn; Fri, 20 Oct 2017 10:02:25 -0700 (PDT) X-Google-Smtp-Source: ABhQp+SekZOqzo6+W1MT5j5p8p+XfwyOhFha6JYKnDWZvyNr3rG5Fyfl019+JfxI7LpjMgzyG9Z/ X-Received: by 10.159.203.140 with SMTP id ay12mr4753942plb.143.1508518945085; Fri, 20 Oct 2017 10:02:25 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1508518945; cv=none; d=google.com; s=arc-20160816; b=GToFi6HQHTNGvCq1tX4IHqdWv39Ql8+5Lez4Ec1xs/AOctUuZ3cuLn397uko/ogO7H j8JXcCZYp73cul0J+nx6tYGALMGuoeQwlzEIhVUOFxY0vKtJDdZkVHlPoR6Osy31PVub ZREu7miev/xfR/FrM2Ohu2TJUVGumEjTSShShIP099YljtPGYLPZeSUR0Boq8QFRPMjU sAaF6kr1j846Q5JvSI/Vtl4xxIrFQuDFneXM3J9rMlXVCVtI0h/gvWPoMyLJPvLzRgpk HC0v04pdrw+y403VxntrvMCTZjeev6SbwoyO4ctFTi5kASnxZdpXO0zwfvSVczKwaMnf nzIw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:dkim-signature:dkim-filter :arc-authentication-results; bh=/6LPxfNB1Fz9oVolwWQBnNbnkyfC7E3dbGAEJl7KMnw=; b=ANc1qUYgWQwqj5OxOwHR9G7xdb2aBnLAUBd1ZZ+TQBb5fomNy03BcpstoJ7/PXZwT0 yGK249tb18xXZ38dW+oJVQ7Q5eVI5pnVSAoaJs1wExhNnzqH2IkL6piL2wu0QsO15B5z 7UVusIPhqRk7EFa62fnYf8+AnMtkkAcB3lj7NuMP2hQ7YdpTHgSTmayujD/DAeIOQ7JH w3uN6ZHkSgcWis1ijPo9YP7pv0X/lkcW7ppG6h54+DIlfnB9fj9+1ciFHO0fgxwf2kcS sOHcMECML86EJoTcxqTf8CQYzJVde8MhtNllF12O+Fu6zNAJrSSecdGXoayyIpk/DB0v W4ew== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@nifty.com header.s=dec2015msa header.b=r4Z/QvEy; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id o61si790217pld.490.2017.10.20.10.02.24; Fri, 20 Oct 2017 10:02:25 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@nifty.com header.s=dec2015msa header.b=r4Z/QvEy; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753306AbdJTQ66 (ORCPT + 27 others); Fri, 20 Oct 2017 12:58:58 -0400 Received: from conuserg-07.nifty.com ([210.131.2.74]:25133 "EHLO conuserg-07.nifty.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753275AbdJTQ65 (ORCPT ); Fri, 20 Oct 2017 12:58:57 -0400 Received: from grover.sesame (FL1-122-131-185-176.osk.mesh.ad.jp [122.131.185.176]) (authenticated) by conuserg-07.nifty.com with ESMTP id v9KGwC3a005656; Sat, 21 Oct 2017 01:58:13 +0900 DKIM-Filter: OpenDKIM Filter v2.10.3 conuserg-07.nifty.com v9KGwC3a005656 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nifty.com; s=dec2015msa; t=1508518694; bh=/6LPxfNB1Fz9oVolwWQBnNbnkyfC7E3dbGAEJl7KMnw=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=r4Z/QvEyEsm+1FgJtRqt7nKIxD5eyTTW5kpXqAdpU1Cvh/7WRBrVJxtgeZGGyqjXt 6SjNlWGUiHn+9tDoUV1I0qJzXOHAZwqaq9b/A/kJyq0ilf9Y0vZoRzWUUYrkB+gJao 5qDLWzbiv87IMt2fLkOvW/RL+TpPGHyv6wjN4BooAoCNVYeDufzlqk2Pi/nUEEK7Sr 89d9QaqMpJKc6Qni35QpaexUnJCnKvCJuByphDbTTZoxFQG0knUeU0WL5UCUkyjUP/ bSqW3nWwqw86Ehw/Su/0OdQ5JJ504yWepjAS/RAmKhxFJuVOJw6j/Mb5orWWAjs9cq BiBJfaRgGC5Mw== X-Nifty-SrcIP: [122.131.185.176] From: Masahiro Yamada To: Greg Kroah-Hartman , linux-kernel@vger.kernel.org Cc: Srinivas Kandagatla , Masahiro Yamada Subject: [RESEND PATCH 2/5] nvmem: mtk-efuse: use stack for nvmem_config instead of malloc'ing it Date: Sat, 21 Oct 2017 01:57:39 +0900 Message-Id: <1508518662-8800-3-git-send-email-yamada.masahiro@socionext.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1508518662-8800-1-git-send-email-yamada.masahiro@socionext.com> References: <1508518662-8800-1-git-send-email-yamada.masahiro@socionext.com> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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 Signed-off-by: Srinivas Kandagatla --- drivers/nvmem/mtk-efuse.c | 24 ++++++++++-------------- 1 file changed, 10 insertions(+), 14 deletions(-) -- 2.7.4 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);