From: Masahiro Yamada <yamada.masahiro@socionext.com>
To: Srinivas Kandagatla <srinivas.kandagatla@linaro.org>
Cc: Keiji Hayashibara <hayashibara.keiji@socionext.com>,
Masami Hiramatsu <mhiramat@kernel.org>,
Jassi Brar <jaswinder.singh@linaro.org>,
Masahiro Yamada <yamada.masahiro@socionext.com>,
linux-kernel@vger.kernel.org, linux-mediatek@lists.infradead.org,
linux-arm-kernel@lists.infradead.org,
Matthias Brugger <matthias.bgg@gmail.com>
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 [thread overview]
Message-ID: <1505134864-11975-3-git-send-email-yamada.masahiro@socionext.com> (raw)
In-Reply-To: <1505134864-11975-1-git-send-email-yamada.masahiro@socionext.com>
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 <yamada.masahiro@socionext.com>
---
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);
--
2.7.4
next prev parent reply other threads:[~2017-09-11 13:02 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-09-11 13:00 [PATCH 0/5] nvmem: some cleanups and sparse warning fixes Masahiro Yamada
2017-09-11 13:01 ` [PATCH 1/5] nvmem: imx-iim: use stack for nvmem_config instead of malloc'ing it Masahiro Yamada
2017-09-11 13:01 ` Masahiro Yamada [this message]
2017-09-20 16:32 ` [PATCH 2/5] nvmem: mtk-efuse: " Sean Wang
2017-09-21 2:09 ` Masahiro Yamada
2017-09-22 3:59 ` Sean Wang
2017-09-11 13:01 ` [PATCH 3/5] nvmem: mtk-efuse: fix different address space warnings of sparse Masahiro Yamada
2017-09-20 16:19 ` Sean Wang
2017-09-11 13:01 ` [PATCH 4/5] nvmem: qfprom: " Masahiro Yamada
2017-09-11 13:01 ` [PATCH 5/5] nvmem: set nvmem->owner to nvmem->dev->driver->owner if unset Masahiro Yamada
2017-09-20 10:02 ` [PATCH 0/5] nvmem: some cleanups and sparse warning fixes Masahiro Yamada
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1505134864-11975-3-git-send-email-yamada.masahiro@socionext.com \
--to=yamada.masahiro@socionext.com \
--cc=hayashibara.keiji@socionext.com \
--cc=jaswinder.singh@linaro.org \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mediatek@lists.infradead.org \
--cc=matthias.bgg@gmail.com \
--cc=mhiramat@kernel.org \
--cc=srinivas.kandagatla@linaro.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®