1 From cc5bdd323dde6494623f3ffe3a5b887fa21cd375 Mon Sep 17 00:00:00 2001
2 From: Michael Walle <michael@walle.cc>
3 Date: Mon, 6 Feb 2023 13:43:48 +0000
4 Subject: [PATCH] nvmem: core: drop the removal of the cells in
7 If nvmem_add_cells() fails, the whole nvmem_register() will fail
8 and the cells will then be removed anyway. This is a preparation
9 to introduce a nvmem_add_one_cell() which can then be used by
12 This is then the same to what nvmem_add_cells_from_table() and
13 nvmem_add_cells_from_of() do.
15 Signed-off-by: Michael Walle <michael@walle.cc>
16 Signed-off-by: Srinivas Kandagatla <srinivas.kandagatla@linaro.org>
17 Link: https://lore.kernel.org/r/20230206134356.839737-15-srinivas.kandagatla@linaro.org
18 Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
20 drivers/nvmem/core.c | 14 ++++----------
21 1 file changed, 4 insertions(+), 10 deletions(-)
23 --- a/drivers/nvmem/core.c
24 +++ b/drivers/nvmem/core.c
25 @@ -515,7 +515,7 @@ static int nvmem_add_cells(struct nvmem_
28 struct nvmem_cell_entry **cells;
32 cells = kcalloc(ncells, sizeof(*cells), GFP_KERNEL);
34 @@ -525,28 +525,22 @@ static int nvmem_add_cells(struct nvmem_
35 cells[i] = kzalloc(sizeof(**cells), GFP_KERNEL);
42 rval = nvmem_cell_info_to_nvmem_cell_entry(nvmem, &info[i], cells[i]);
49 nvmem_cell_entry_add(cells[i]);
53 /* remove tmp array */
59 - nvmem_cell_entry_drop(cells[i]);