From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-wr1-x444.google.com ([2a00:1450:4864:20::444]) by bombadil.infradead.org with esmtps (Exim 4.90_1 #2 (Red Hat Linux)) id 1fufcP-000254-Av for linux-mtd@lists.infradead.org; Tue, 28 Aug 2018 15:09:23 +0000 Received: by mail-wr1-x444.google.com with SMTP id a108-v6so1907898wrc.13 for ; Tue, 28 Aug 2018 08:09:11 -0700 (PDT) Subject: Re: [PATCH v2 01/29] nvmem: add support for cell lookups To: Boris Brezillon , Bartosz Golaszewski Cc: Andrew Lunn , linux-doc , Sekhar Nori , Bartosz Golaszewski , linux-i2c , Mauro Carvalho Chehab , Rob Herring , Florian Fainelli , Kevin Hilman , Richard Weinberger , Russell King , Marek Vasut , Paolo Abeni , Dan Carpenter , Grygorii Strashko , David Lechner , Arnd Bergmann , Sven Van Asbroeck , "open list:MEMORY TECHNOLOGY..." , Linux-OMAP , Linux ARM , Ivan Khoronzhuk , Greg Kroah-Hartman , Jonathan Corbet , Linux Kernel Mailing List , Lukas Wunner , Naren , netdev , Alban Bedel , Andrew Morton , Brian Norris , David Woodhouse , "David S . Miller" References: <20180810080526.27207-1-brgl@bgdev.pl> <20180810080526.27207-2-brgl@bgdev.pl> <20180824170848.29594318@bbrezillon> <20180824152740.GD27483@lunn.ch> <20180825082722.567e8c9a@bbrezillon> <20180827110055.122988d0@bbrezillon> <8cb75723-dc87-f127-2aab-54dd0b08eee8@linaro.org> <916e3e89-82b3-0d52-2b77-4374261a9d0f@linaro.org> <20180828165309.0594ae13@bbrezillon> From: Srinivas Kandagatla Message-ID: Date: Tue, 28 Aug 2018 16:09:07 +0100 MIME-Version: 1.0 In-Reply-To: <20180828165309.0594ae13@bbrezillon> Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 7bit List-Id: Linux MTD discussion mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , On 28/08/18 15:53, Boris Brezillon wrote: > On Tue, 28 Aug 2018 16:41:04 +0200 > Bartosz Golaszewski wrote: > ... > >>> >>> static struct nvmem_cell *nvmem_find_cell(const char *cell_id) > > Can we get rid of this function and just have the the version that > takes an nvmem_name and a cell_id. That should be feasible! >>>>> >>>>> I hope you got the reason why of_nvmem_cell_get() always allocates new >>>>> instance for every get!! >>>> >>>> >>>> >>>> I admit I didn't test it, but just from reading the code it seems like >>>> in nvmem_cell_get() for DT-users we'll always get to >>>> of_nvmem_cell_get() and in there we always end up calling line 873: >>>> cell = kzalloc(sizeof(*cell), GFP_KERNEL); >>>> >>> That is correct, this cell is created when we do a get and release when we >>> do a put(). >>> >> >> Shouldn't we add the cell to the list, and check first if it's there >> and only create it if not? > > Or even better: create the cells at registration time so that the > search code is the same for both DT and non-DT cases. Only the > registration would differ (with one path parsing the DT, and the other > one searching for nvmem cells defined with a nvmem-provider-lookup > table). Makes sense! and that would go very well with the plan of "nvmem-cell" compatible for cells!. >