Skip to content

Commit 01465f2

Browse files
geertugregkh
authored andcommitted
nvmem: Remove unused nvmem cell table support
Board files are deprecated by DT, and the last user of nvmem_add_cell_table() was removed by commit 2af4fcc ("ARM: davinci: remove unused board support") in v6.3. Hence remove all support for nvmem cell tables, and update the documentation. Device drivers can still register a single cell using nvmem_add_one_cell() (which was not documented before). Signed-off-by: Geert Uytterhoeven <geert+renesas@glider.be> Acked-by: Arnd Bergmann <arnd@arndb.de> Signed-off-by: Srinivas Kandagatla <srini@kernel.org> Link: https://lore.kernel.org/r/20250509122452.11827-2-srini@kernel.org Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
1 parent fe8abdd commit 01465f2

File tree

3 files changed

+4
-102
lines changed

3 files changed

+4
-102
lines changed

Documentation/driver-api/nvmem.rst

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -59,24 +59,18 @@ For example, a simple nvram case::
5959
devm_nvmem_register(&config);
6060
}
6161

62-
Users of board files can define and register nvmem cells using the
63-
nvmem_cell_table struct::
62+
Device drivers can define and register an nvmem cell using the nvmem_cell_info
63+
struct::
6464

65-
static struct nvmem_cell_info foo_nvmem_cells[] = {
65+
static const struct nvmem_cell_info foo_nvmem_cell = {
6666
{
6767
.name = "macaddr",
6868
.offset = 0x7f00,
6969
.bytes = ETH_ALEN,
7070
}
7171
};
7272

73-
static struct nvmem_cell_table foo_nvmem_cell_table = {
74-
.nvmem_name = "i2c-eeprom",
75-
.cells = foo_nvmem_cells,
76-
.ncells = ARRAY_SIZE(foo_nvmem_cells),
77-
};
78-
79-
nvmem_add_cell_table(&foo_nvmem_cell_table);
73+
int nvmem_add_one_cell(nvmem, &foo_nvmem_cell);
8074

8175
Additionally it is possible to create nvmem cell lookup entries and register
8276
them with the nvmem framework from machine code as shown in the example below::

drivers/nvmem/core.c

Lines changed: 0 additions & 68 deletions
Original file line numberDiff line numberDiff line change
@@ -47,9 +47,6 @@ struct nvmem_cell {
4747
static DEFINE_MUTEX(nvmem_mutex);
4848
static DEFINE_IDA(nvmem_ida);
4949

50-
static DEFINE_MUTEX(nvmem_cell_mutex);
51-
static LIST_HEAD(nvmem_cell_tables);
52-
5350
static DEFINE_MUTEX(nvmem_lookup_mutex);
5451
static LIST_HEAD(nvmem_lookup_list);
5552

@@ -719,41 +716,6 @@ int nvmem_unregister_notifier(struct notifier_block *nb)
719716
}
720717
EXPORT_SYMBOL_GPL(nvmem_unregister_notifier);
721718

722-
static int nvmem_add_cells_from_table(struct nvmem_device *nvmem)
723-
{
724-
const struct nvmem_cell_info *info;
725-
struct nvmem_cell_table *table;
726-
struct nvmem_cell_entry *cell;
727-
int rval = 0, i;
728-
729-
mutex_lock(&nvmem_cell_mutex);
730-
list_for_each_entry(table, &nvmem_cell_tables, node) {
731-
if (strcmp(nvmem_dev_name(nvmem), table->nvmem_name) == 0) {
732-
for (i = 0; i < table->ncells; i++) {
733-
info = &table->cells[i];
734-
735-
cell = kzalloc(sizeof(*cell), GFP_KERNEL);
736-
if (!cell) {
737-
rval = -ENOMEM;
738-
goto out;
739-
}
740-
741-
rval = nvmem_cell_info_to_nvmem_cell_entry(nvmem, info, cell);
742-
if (rval) {
743-
kfree(cell);
744-
goto out;
745-
}
746-
747-
nvmem_cell_entry_add(cell);
748-
}
749-
}
750-
}
751-
752-
out:
753-
mutex_unlock(&nvmem_cell_mutex);
754-
return rval;
755-
}
756-
757719
static struct nvmem_cell_entry *
758720
nvmem_find_cell_entry_by_name(struct nvmem_device *nvmem, const char *cell_id)
759721
{
@@ -1040,10 +1002,6 @@ struct nvmem_device *nvmem_register(const struct nvmem_config *config)
10401002
goto err_remove_cells;
10411003
}
10421004

1043-
rval = nvmem_add_cells_from_table(nvmem);
1044-
if (rval)
1045-
goto err_remove_cells;
1046-
10471005
if (config->add_legacy_fixed_of_cells) {
10481006
rval = nvmem_add_cells_from_legacy_of(nvmem);
10491007
if (rval)
@@ -2151,32 +2109,6 @@ int nvmem_device_write(struct nvmem_device *nvmem,
21512109
}
21522110
EXPORT_SYMBOL_GPL(nvmem_device_write);
21532111

2154-
/**
2155-
* nvmem_add_cell_table() - register a table of cell info entries
2156-
*
2157-
* @table: table of cell info entries
2158-
*/
2159-
void nvmem_add_cell_table(struct nvmem_cell_table *table)
2160-
{
2161-
mutex_lock(&nvmem_cell_mutex);
2162-
list_add_tail(&table->node, &nvmem_cell_tables);
2163-
mutex_unlock(&nvmem_cell_mutex);
2164-
}
2165-
EXPORT_SYMBOL_GPL(nvmem_add_cell_table);
2166-
2167-
/**
2168-
* nvmem_del_cell_table() - remove a previously registered cell info table
2169-
*
2170-
* @table: table of cell info entries
2171-
*/
2172-
void nvmem_del_cell_table(struct nvmem_cell_table *table)
2173-
{
2174-
mutex_lock(&nvmem_cell_mutex);
2175-
list_del(&table->node);
2176-
mutex_unlock(&nvmem_cell_mutex);
2177-
}
2178-
EXPORT_SYMBOL_GPL(nvmem_del_cell_table);
2179-
21802112
/**
21812113
* nvmem_add_cell_lookups() - register a list of cell lookup entries
21822114
*

include/linux/nvmem-provider.h

Lines changed: 0 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -137,25 +137,6 @@ struct nvmem_config {
137137
struct device *base_dev;
138138
};
139139

140-
/**
141-
* struct nvmem_cell_table - NVMEM cell definitions for given provider
142-
*
143-
* @nvmem_name: Provider name.
144-
* @cells: Array of cell definitions.
145-
* @ncells: Number of cell definitions in the array.
146-
* @node: List node.
147-
*
148-
* This structure together with related helper functions is provided for users
149-
* that don't can't access the nvmem provided structure but wish to register
150-
* cell definitions for it e.g. board files registering an EEPROM device.
151-
*/
152-
struct nvmem_cell_table {
153-
const char *nvmem_name;
154-
const struct nvmem_cell_info *cells;
155-
size_t ncells;
156-
struct list_head node;
157-
};
158-
159140
/**
160141
* struct nvmem_layout - NVMEM layout definitions
161142
*
@@ -190,9 +171,6 @@ void nvmem_unregister(struct nvmem_device *nvmem);
190171
struct nvmem_device *devm_nvmem_register(struct device *dev,
191172
const struct nvmem_config *cfg);
192173

193-
void nvmem_add_cell_table(struct nvmem_cell_table *table);
194-
void nvmem_del_cell_table(struct nvmem_cell_table *table);
195-
196174
int nvmem_add_one_cell(struct nvmem_device *nvmem,
197175
const struct nvmem_cell_info *info);
198176

@@ -223,8 +201,6 @@ devm_nvmem_register(struct device *dev, const struct nvmem_config *c)
223201
return nvmem_register(c);
224202
}
225203

226-
static inline void nvmem_add_cell_table(struct nvmem_cell_table *table) {}
227-
static inline void nvmem_del_cell_table(struct nvmem_cell_table *table) {}
228204
static inline int nvmem_add_one_cell(struct nvmem_device *nvmem,
229205
const struct nvmem_cell_info *info)
230206
{

0 commit comments

Comments
 (0)