Re: [PATCH v2 01/29] nvmem: add support for cell lookups

From: Srinivas Kandagatla
Date: Tue Aug 28 2018 - 11:09:14 EST




On 28/08/18 15:53, Boris Brezillon wrote:
On Tue, 28 Aug 2018 16:41:04 +0200
Bartosz Golaszewski <brgl@xxxxxxxx> 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!.