nvmem: Remove unused nvmem cell table support
authorGeert Uytterhoeven <geert+renesas@glider.be>
Fri, 9 May 2025 12:24:50 +0000 (13:24 +0100)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Wed, 21 May 2025 12:28:27 +0000 (14:28 +0200)
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>
Documentation/driver-api/nvmem.rst
drivers/nvmem/core.c
include/linux/nvmem-provider.h

index 5d9500d21ecc425419dab992fcde74de0542cef4..790e2dc652c00c3a70bb2451579c195a114fcc43 100644 (file)
@@ -59,10 +59,10 @@ For example, a simple nvram case::
        devm_nvmem_register(&config);
   }
 
-Users of board files can define and register nvmem cells using the
-nvmem_cell_table struct::
+Device drivers can define and register an nvmem cell using the nvmem_cell_info
+struct::
 
-  static struct nvmem_cell_info foo_nvmem_cells[] = {
+  static const struct nvmem_cell_info foo_nvmem_cell = {
        {
                .name           = "macaddr",
                .offset         = 0x7f00,
@@ -70,13 +70,7 @@ nvmem_cell_table struct::
        }
   };
 
-  static struct nvmem_cell_table foo_nvmem_cell_table = {
-       .nvmem_name             = "i2c-eeprom",
-       .cells                  = foo_nvmem_cells,
-       .ncells                 = ARRAY_SIZE(foo_nvmem_cells),
-  };
-
-  nvmem_add_cell_table(&foo_nvmem_cell_table);
+  int nvmem_add_one_cell(nvmem, &foo_nvmem_cell);
 
 Additionally it is possible to create nvmem cell lookup entries and register
 them with the nvmem framework from machine code as shown in the example below::
index e206efc29a0044739f9d56e1b131af2809365201..fd2a9698d1c93ee52a4d86f6e0a19d2dfb6efb54 100644 (file)
@@ -47,9 +47,6 @@ struct nvmem_cell {
 static DEFINE_MUTEX(nvmem_mutex);
 static DEFINE_IDA(nvmem_ida);
 
-static DEFINE_MUTEX(nvmem_cell_mutex);
-static LIST_HEAD(nvmem_cell_tables);
-
 static DEFINE_MUTEX(nvmem_lookup_mutex);
 static LIST_HEAD(nvmem_lookup_list);
 
@@ -719,41 +716,6 @@ int nvmem_unregister_notifier(struct notifier_block *nb)
 }
 EXPORT_SYMBOL_GPL(nvmem_unregister_notifier);
 
-static int nvmem_add_cells_from_table(struct nvmem_device *nvmem)
-{
-       const struct nvmem_cell_info *info;
-       struct nvmem_cell_table *table;
-       struct nvmem_cell_entry *cell;
-       int rval = 0, i;
-
-       mutex_lock(&nvmem_cell_mutex);
-       list_for_each_entry(table, &nvmem_cell_tables, node) {
-               if (strcmp(nvmem_dev_name(nvmem), table->nvmem_name) == 0) {
-                       for (i = 0; i < table->ncells; i++) {
-                               info = &table->cells[i];
-
-                               cell = kzalloc(sizeof(*cell), GFP_KERNEL);
-                               if (!cell) {
-                                       rval = -ENOMEM;
-                                       goto out;
-                               }
-
-                               rval = nvmem_cell_info_to_nvmem_cell_entry(nvmem, info, cell);
-                               if (rval) {
-                                       kfree(cell);
-                                       goto out;
-                               }
-
-                               nvmem_cell_entry_add(cell);
-                       }
-               }
-       }
-
-out:
-       mutex_unlock(&nvmem_cell_mutex);
-       return rval;
-}
-
 static struct nvmem_cell_entry *
 nvmem_find_cell_entry_by_name(struct nvmem_device *nvmem, const char *cell_id)
 {
@@ -1040,10 +1002,6 @@ struct nvmem_device *nvmem_register(const struct nvmem_config *config)
                        goto err_remove_cells;
        }
 
-       rval = nvmem_add_cells_from_table(nvmem);
-       if (rval)
-               goto err_remove_cells;
-
        if (config->add_legacy_fixed_of_cells) {
                rval = nvmem_add_cells_from_legacy_of(nvmem);
                if (rval)
@@ -2151,32 +2109,6 @@ int nvmem_device_write(struct nvmem_device *nvmem,
 }
 EXPORT_SYMBOL_GPL(nvmem_device_write);
 
-/**
- * nvmem_add_cell_table() - register a table of cell info entries
- *
- * @table: table of cell info entries
- */
-void nvmem_add_cell_table(struct nvmem_cell_table *table)
-{
-       mutex_lock(&nvmem_cell_mutex);
-       list_add_tail(&table->node, &nvmem_cell_tables);
-       mutex_unlock(&nvmem_cell_mutex);
-}
-EXPORT_SYMBOL_GPL(nvmem_add_cell_table);
-
-/**
- * nvmem_del_cell_table() - remove a previously registered cell info table
- *
- * @table: table of cell info entries
- */
-void nvmem_del_cell_table(struct nvmem_cell_table *table)
-{
-       mutex_lock(&nvmem_cell_mutex);
-       list_del(&table->node);
-       mutex_unlock(&nvmem_cell_mutex);
-}
-EXPORT_SYMBOL_GPL(nvmem_del_cell_table);
-
 /**
  * nvmem_add_cell_lookups() - register a list of cell lookup entries
  *
index 515676ebe59875fa0ab8a4e772542bdc90ead8e3..615a560d9edb84d1a5b8a1d8a374b8bf7c9c772e 100644 (file)
@@ -137,25 +137,6 @@ struct nvmem_config {
        struct device           *base_dev;
 };
 
-/**
- * struct nvmem_cell_table - NVMEM cell definitions for given provider
- *
- * @nvmem_name:                Provider name.
- * @cells:             Array of cell definitions.
- * @ncells:            Number of cell definitions in the array.
- * @node:              List node.
- *
- * This structure together with related helper functions is provided for users
- * that don't can't access the nvmem provided structure but wish to register
- * cell definitions for it e.g. board files registering an EEPROM device.
- */
-struct nvmem_cell_table {
-       const char              *nvmem_name;
-       const struct nvmem_cell_info    *cells;
-       size_t                  ncells;
-       struct list_head        node;
-};
-
 /**
  * struct nvmem_layout - NVMEM layout definitions
  *
@@ -190,9 +171,6 @@ void nvmem_unregister(struct nvmem_device *nvmem);
 struct nvmem_device *devm_nvmem_register(struct device *dev,
                                         const struct nvmem_config *cfg);
 
-void nvmem_add_cell_table(struct nvmem_cell_table *table);
-void nvmem_del_cell_table(struct nvmem_cell_table *table);
-
 int nvmem_add_one_cell(struct nvmem_device *nvmem,
                       const struct nvmem_cell_info *info);
 
@@ -223,8 +201,6 @@ devm_nvmem_register(struct device *dev, const struct nvmem_config *c)
        return nvmem_register(c);
 }
 
-static inline void nvmem_add_cell_table(struct nvmem_cell_table *table) {}
-static inline void nvmem_del_cell_table(struct nvmem_cell_table *table) {}
 static inline int nvmem_add_one_cell(struct nvmem_device *nvmem,
                                     const struct nvmem_cell_info *info)
 {