Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

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 2af4fcc0d3574482 ("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>

authored by

Geert Uytterhoeven and committed by
Greg Kroah-Hartman
01465f29 fe8abdd1

+4 -102
+4 -10
Documentation/driver-api/nvmem.rst
··· 59 59 devm_nvmem_register(&config); 60 60 } 61 61 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:: 64 64 65 - static struct nvmem_cell_info foo_nvmem_cells[] = { 65 + static const struct nvmem_cell_info foo_nvmem_cell = { 66 66 { 67 67 .name = "macaddr", 68 68 .offset = 0x7f00, ··· 70 70 } 71 71 }; 72 72 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); 80 74 81 75 Additionally it is possible to create nvmem cell lookup entries and register 82 76 them with the nvmem framework from machine code as shown in the example below::
-68
drivers/nvmem/core.c
··· 47 47 static DEFINE_MUTEX(nvmem_mutex); 48 48 static DEFINE_IDA(nvmem_ida); 49 49 50 - static DEFINE_MUTEX(nvmem_cell_mutex); 51 - static LIST_HEAD(nvmem_cell_tables); 52 - 53 50 static DEFINE_MUTEX(nvmem_lookup_mutex); 54 51 static LIST_HEAD(nvmem_lookup_list); 55 52 ··· 716 719 } 717 720 EXPORT_SYMBOL_GPL(nvmem_unregister_notifier); 718 721 719 - static int nvmem_add_cells_from_table(struct nvmem_device *nvmem) 720 - { 721 - const struct nvmem_cell_info *info; 722 - struct nvmem_cell_table *table; 723 - struct nvmem_cell_entry *cell; 724 - int rval = 0, i; 725 - 726 - mutex_lock(&nvmem_cell_mutex); 727 - list_for_each_entry(table, &nvmem_cell_tables, node) { 728 - if (strcmp(nvmem_dev_name(nvmem), table->nvmem_name) == 0) { 729 - for (i = 0; i < table->ncells; i++) { 730 - info = &table->cells[i]; 731 - 732 - cell = kzalloc(sizeof(*cell), GFP_KERNEL); 733 - if (!cell) { 734 - rval = -ENOMEM; 735 - goto out; 736 - } 737 - 738 - rval = nvmem_cell_info_to_nvmem_cell_entry(nvmem, info, cell); 739 - if (rval) { 740 - kfree(cell); 741 - goto out; 742 - } 743 - 744 - nvmem_cell_entry_add(cell); 745 - } 746 - } 747 - } 748 - 749 - out: 750 - mutex_unlock(&nvmem_cell_mutex); 751 - return rval; 752 - } 753 - 754 722 static struct nvmem_cell_entry * 755 723 nvmem_find_cell_entry_by_name(struct nvmem_device *nvmem, const char *cell_id) 756 724 { ··· 1001 1039 if (rval) 1002 1040 goto err_remove_cells; 1003 1041 } 1004 - 1005 - rval = nvmem_add_cells_from_table(nvmem); 1006 - if (rval) 1007 - goto err_remove_cells; 1008 1042 1009 1043 if (config->add_legacy_fixed_of_cells) { 1010 1044 rval = nvmem_add_cells_from_legacy_of(nvmem); ··· 2108 2150 return bytes; 2109 2151 } 2110 2152 EXPORT_SYMBOL_GPL(nvmem_device_write); 2111 - 2112 - /** 2113 - * nvmem_add_cell_table() - register a table of cell info entries 2114 - * 2115 - * @table: table of cell info entries 2116 - */ 2117 - void nvmem_add_cell_table(struct nvmem_cell_table *table) 2118 - { 2119 - mutex_lock(&nvmem_cell_mutex); 2120 - list_add_tail(&table->node, &nvmem_cell_tables); 2121 - mutex_unlock(&nvmem_cell_mutex); 2122 - } 2123 - EXPORT_SYMBOL_GPL(nvmem_add_cell_table); 2124 - 2125 - /** 2126 - * nvmem_del_cell_table() - remove a previously registered cell info table 2127 - * 2128 - * @table: table of cell info entries 2129 - */ 2130 - void nvmem_del_cell_table(struct nvmem_cell_table *table) 2131 - { 2132 - mutex_lock(&nvmem_cell_mutex); 2133 - list_del(&table->node); 2134 - mutex_unlock(&nvmem_cell_mutex); 2135 - } 2136 - EXPORT_SYMBOL_GPL(nvmem_del_cell_table); 2137 2153 2138 2154 /** 2139 2155 * nvmem_add_cell_lookups() - register a list of cell lookup entries
-24
include/linux/nvmem-provider.h
··· 138 138 }; 139 139 140 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 - 159 - /** 160 141 * struct nvmem_layout - NVMEM layout definitions 161 142 * 162 143 * @dev: Device-model layout device. ··· 171 190 struct nvmem_device *devm_nvmem_register(struct device *dev, 172 191 const struct nvmem_config *cfg); 173 192 174 - void nvmem_add_cell_table(struct nvmem_cell_table *table); 175 - void nvmem_del_cell_table(struct nvmem_cell_table *table); 176 - 177 193 int nvmem_add_one_cell(struct nvmem_device *nvmem, 178 194 const struct nvmem_cell_info *info); 179 195 ··· 201 223 return nvmem_register(c); 202 224 } 203 225 204 - static inline void nvmem_add_cell_table(struct nvmem_cell_table *table) {} 205 - static inline void nvmem_del_cell_table(struct nvmem_cell_table *table) {} 206 226 static inline int nvmem_add_one_cell(struct nvmem_device *nvmem, 207 227 const struct nvmem_cell_info *info) 208 228 {