From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752109AbdJTNcO (ORCPT ); Fri, 20 Oct 2017 09:32:14 -0400 Received: from mail.linuxfoundation.org ([140.211.169.12]:33332 "EHLO mail.linuxfoundation.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751733AbdJTNcN (ORCPT ); Fri, 20 Oct 2017 09:32:13 -0400 Date: Fri, 20 Oct 2017 15:32:20 +0200 From: Greg KH To: srinivas.kandagatla@linaro.org Cc: linux-kernel@vger.kernel.org, Masahiro Yamada Subject: Re: [PATCH 01/12] nvmem: imx-iim: use stack for nvmem_config instead of malloc'ing it Message-ID: <20171020133220.GA9301@kroah.com> References: <20171009132641.27169-1-srinivas.kandagatla@linaro.org> <20171009132641.27169-2-srinivas.kandagatla@linaro.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20171009132641.27169-2-srinivas.kandagatla@linaro.org> User-Agent: Mutt/1.9.1 (2017-09-22) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, Oct 09, 2017 at 03:26:30PM +0200, srinivas.kandagatla@linaro.org wrote: > From: Masahiro Yamada > > 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 > Signed-off-by: Srinivas Kandagatla > --- > drivers/nvmem/imx-iim.c | 27 ++++++++++++--------------- > 1 file changed, 12 insertions(+), 15 deletions(-) > > diff --git a/drivers/nvmem/imx-iim.c b/drivers/nvmem/imx-iim.c > index 52ff65e0673f..a5992602709a 100644 > --- a/drivers/nvmem/imx-iim.c > +++ b/drivers/nvmem/imx-iim.c > @@ -34,7 +34,6 @@ struct imx_iim_drvdata { > struct iim_priv { > void __iomem *base; > struct clk *clk; > - struct nvmem_config nvmem; > }; > > static int imx_iim_read(void *context, unsigned int offset, > @@ -108,7 +107,7 @@ static int imx_iim_probe(struct platform_device *pdev) > struct resource *res; > struct iim_priv *iim; > struct nvmem_device *nvmem; > - struct nvmem_config *cfg; > + struct nvmem_config cfg = {}; You do realize you are now not zeroing out this structure, and have to explicitly initialize all of the fields, right? What is the real problem with doing a dynamic allocation for this? Putting structures on the stack is a "bad idea" for all of the obvious reasons (small stack in the kernel, initialized data, lower layers expect it to be dma-able, etc.) thanks, greg k-h