* [PATCH 1/3] nvmem: core: Remove unused nvmem_device_cell_(read|write)
2025-02-21 1:58 [PATCH 0/3] Remove nvmem deadcode linux
@ 2025-02-21 1:58 ` linux
2025-02-21 1:58 ` [PATCH 2/3] nvmem: core: Remove nvmem_(add|del)_cell_table linux
` (2 subsequent siblings)
3 siblings, 0 replies; 5+ messages in thread
From: linux @ 2025-02-21 1:58 UTC (permalink / raw)
To: srinivas.kandagatla
Cc: corbet, linux-doc, linux-kernel, Dr. David Alan Gilbert
From: "Dr. David Alan Gilbert" <linux@treblig.org>
nvmem_device_cell_read() and nvmem_device_cell_write() were
added in 2015's
commit e2a5402ec7c6 ("nvmem: Add nvmem_device based consumer apis.")
but have remained unused.
Remove them.
Signed-off-by: Dr. David Alan Gilbert <linux@treblig.org>
---
Documentation/driver-api/nvmem.rst | 4 ---
drivers/nvmem/core.c | 58 ------------------------------
include/linux/nvmem-consumer.h | 4 ---
3 files changed, 66 deletions(-)
diff --git a/Documentation/driver-api/nvmem.rst b/Documentation/driver-api/nvmem.rst
index 5d9500d21ecc..595ee207d199 100644
--- a/Documentation/driver-api/nvmem.rst
+++ b/Documentation/driver-api/nvmem.rst
@@ -132,10 +132,6 @@ To facilitate such consumers NVMEM framework provides below apis::
size_t bytes, void *buf);
int nvmem_device_write(struct nvmem_device *nvmem, unsigned int offset,
size_t bytes, void *buf);
- int nvmem_device_cell_read(struct nvmem_device *nvmem,
- struct nvmem_cell_info *info, void *buf);
- int nvmem_device_cell_write(struct nvmem_device *nvmem,
- struct nvmem_cell_info *info, void *buf);
Before the consumers can read/write NVMEM directly, it should get hold
of nvmem_controller from one of the `*nvmem_device_get()` api.
diff --git a/drivers/nvmem/core.c b/drivers/nvmem/core.c
index fff85bbf0ecd..fd8f148b8aad 100644
--- a/drivers/nvmem/core.c
+++ b/drivers/nvmem/core.c
@@ -2011,64 +2011,6 @@ int nvmem_cell_read_variable_le_u64(struct device *dev, const char *cell_id,
}
EXPORT_SYMBOL_GPL(nvmem_cell_read_variable_le_u64);
-/**
- * nvmem_device_cell_read() - Read a given nvmem device and cell
- *
- * @nvmem: nvmem device to read from.
- * @info: nvmem cell info to be read.
- * @buf: buffer pointer which will be populated on successful read.
- *
- * Return: length of successful bytes read on success and negative
- * error code on error.
- */
-ssize_t nvmem_device_cell_read(struct nvmem_device *nvmem,
- struct nvmem_cell_info *info, void *buf)
-{
- struct nvmem_cell_entry cell;
- int rc;
- ssize_t len;
-
- if (!nvmem)
- return -EINVAL;
-
- rc = nvmem_cell_info_to_nvmem_cell_entry_nodup(nvmem, info, &cell);
- if (rc)
- return rc;
-
- rc = __nvmem_cell_read(nvmem, &cell, buf, &len, NULL, 0);
- if (rc)
- return rc;
-
- return len;
-}
-EXPORT_SYMBOL_GPL(nvmem_device_cell_read);
-
-/**
- * nvmem_device_cell_write() - Write cell to a given nvmem device
- *
- * @nvmem: nvmem device to be written to.
- * @info: nvmem cell info to be written.
- * @buf: buffer to be written to cell.
- *
- * Return: length of bytes written or negative error code on failure.
- */
-int nvmem_device_cell_write(struct nvmem_device *nvmem,
- struct nvmem_cell_info *info, void *buf)
-{
- struct nvmem_cell_entry cell;
- int rc;
-
- if (!nvmem)
- return -EINVAL;
-
- rc = nvmem_cell_info_to_nvmem_cell_entry_nodup(nvmem, info, &cell);
- if (rc)
- return rc;
-
- return __nvmem_cell_entry_write(&cell, buf, cell.bytes);
-}
-EXPORT_SYMBOL_GPL(nvmem_device_cell_write);
-
/**
* nvmem_device_read() - Read from a given nvmem device
*
diff --git a/include/linux/nvmem-consumer.h b/include/linux/nvmem-consumer.h
index 34c0e58dfa26..1222b3f9819d 100644
--- a/include/linux/nvmem-consumer.h
+++ b/include/linux/nvmem-consumer.h
@@ -75,10 +75,6 @@ int nvmem_device_read(struct nvmem_device *nvmem, unsigned int offset,
size_t bytes, void *buf);
int nvmem_device_write(struct nvmem_device *nvmem, unsigned int offset,
size_t bytes, void *buf);
-ssize_t nvmem_device_cell_read(struct nvmem_device *nvmem,
- struct nvmem_cell_info *info, void *buf);
-int nvmem_device_cell_write(struct nvmem_device *nvmem,
- struct nvmem_cell_info *info, void *buf);
const char *nvmem_dev_name(struct nvmem_device *nvmem);
size_t nvmem_dev_size(struct nvmem_device *nvmem);
--
2.48.1
^ permalink raw reply related [flat|nested] 5+ messages in thread* [PATCH 2/3] nvmem: core: Remove nvmem_(add|del)_cell_table
2025-02-21 1:58 [PATCH 0/3] Remove nvmem deadcode linux
2025-02-21 1:58 ` [PATCH 1/3] nvmem: core: Remove unused nvmem_device_cell_(read|write) linux
@ 2025-02-21 1:58 ` linux
2025-02-21 1:58 ` [PATCH 3/3] nvmem: core: Remove remains of nvmem_cell_table linux
2025-04-02 17:44 ` [PATCH 0/3] Remove nvmem deadcode Dr. David Alan Gilbert
3 siblings, 0 replies; 5+ messages in thread
From: linux @ 2025-02-21 1:58 UTC (permalink / raw)
To: srinivas.kandagatla
Cc: corbet, linux-doc, linux-kernel, Dr. David Alan Gilbert
From: "Dr. David Alan Gilbert" <linux@treblig.org>
nvmem_del_cell_table() was added in 2018's
commit b985f4cba6db ("nvmem: add support for cell info")
but remained unused.
nvmem_add_cell_table() was also added in that commit, however
it's last use was removed in 2022 by
commit 2af4fcc0d357 ("ARM: davinci: remove unused board support")
Remove them.
Signed-off-by: Dr. David Alan Gilbert <linux@treblig.org>
---
Documentation/driver-api/nvmem.rst | 2 --
drivers/nvmem/core.c | 26 --------------------------
include/linux/nvmem-provider.h | 5 -----
3 files changed, 33 deletions(-)
diff --git a/Documentation/driver-api/nvmem.rst b/Documentation/driver-api/nvmem.rst
index 595ee207d199..27534d5e8fba 100644
--- a/Documentation/driver-api/nvmem.rst
+++ b/Documentation/driver-api/nvmem.rst
@@ -76,8 +76,6 @@ nvmem_cell_table struct::
.ncells = ARRAY_SIZE(foo_nvmem_cells),
};
- nvmem_add_cell_table(&foo_nvmem_cell_table);
-
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::
diff --git a/drivers/nvmem/core.c b/drivers/nvmem/core.c
index fd8f148b8aad..90fbfc00950e 100644
--- a/drivers/nvmem/core.c
+++ b/drivers/nvmem/core.c
@@ -2069,32 +2069,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
*
diff --git a/include/linux/nvmem-provider.h b/include/linux/nvmem-provider.h
index 515676ebe598..20c9fbd45b24 100644
--- a/include/linux/nvmem-provider.h
+++ b/include/linux/nvmem-provider.h
@@ -190,9 +190,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 +220,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)
{
--
2.48.1
^ permalink raw reply related [flat|nested] 5+ messages in thread* [PATCH 3/3] nvmem: core: Remove remains of nvmem_cell_table
2025-02-21 1:58 [PATCH 0/3] Remove nvmem deadcode linux
2025-02-21 1:58 ` [PATCH 1/3] nvmem: core: Remove unused nvmem_device_cell_(read|write) linux
2025-02-21 1:58 ` [PATCH 2/3] nvmem: core: Remove nvmem_(add|del)_cell_table linux
@ 2025-02-21 1:58 ` linux
2025-04-02 17:44 ` [PATCH 0/3] Remove nvmem deadcode Dr. David Alan Gilbert
3 siblings, 0 replies; 5+ messages in thread
From: linux @ 2025-02-21 1:58 UTC (permalink / raw)
To: srinivas.kandagatla
Cc: corbet, linux-doc, linux-kernel, Dr. David Alan Gilbert
From: "Dr. David Alan Gilbert" <linux@treblig.org>
With the previous patch removing the unused nvmem_add_cell_table, there's
no way to add a table, and thus the rest of the table infrastructure
can go.
Signed-off-by: Dr. David Alan Gilbert <linux@treblig.org>
---
Documentation/driver-api/nvmem.rst | 17 ------------
drivers/nvmem/core.c | 42 ------------------------------
include/linux/nvmem-provider.h | 19 --------------
3 files changed, 78 deletions(-)
diff --git a/Documentation/driver-api/nvmem.rst b/Documentation/driver-api/nvmem.rst
index 27534d5e8fba..6e73bb2d2ca5 100644
--- a/Documentation/driver-api/nvmem.rst
+++ b/Documentation/driver-api/nvmem.rst
@@ -59,23 +59,6 @@ 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::
-
- static struct nvmem_cell_info foo_nvmem_cells[] = {
- {
- .name = "macaddr",
- .offset = 0x7f00,
- .bytes = ETH_ALEN,
- }
- };
-
- static struct nvmem_cell_table foo_nvmem_cell_table = {
- .nvmem_name = "i2c-eeprom",
- .cells = foo_nvmem_cells,
- .ncells = ARRAY_SIZE(foo_nvmem_cells),
- };
-
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::
diff --git a/drivers/nvmem/core.c b/drivers/nvmem/core.c
index 90fbfc00950e..6f7f2a84701f 100644
--- a/drivers/nvmem/core.c
+++ b/drivers/nvmem/core.c
@@ -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);
@@ -705,41 +702,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)
{
@@ -1024,10 +986,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)
diff --git a/include/linux/nvmem-provider.h b/include/linux/nvmem-provider.h
index 20c9fbd45b24..615a560d9edb 100644
--- a/include/linux/nvmem-provider.h
+++ b/include/linux/nvmem-provider.h
@@ -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
*
--
2.48.1
^ permalink raw reply related [flat|nested] 5+ messages in thread* Re: [PATCH 0/3] Remove nvmem deadcode
2025-02-21 1:58 [PATCH 0/3] Remove nvmem deadcode linux
` (2 preceding siblings ...)
2025-02-21 1:58 ` [PATCH 3/3] nvmem: core: Remove remains of nvmem_cell_table linux
@ 2025-04-02 17:44 ` Dr. David Alan Gilbert
3 siblings, 0 replies; 5+ messages in thread
From: Dr. David Alan Gilbert @ 2025-04-02 17:44 UTC (permalink / raw)
To: srinivas.kandagatla; +Cc: corbet, linux-doc, linux-kernel
* linux@treblig.org (linux@treblig.org) wrote:
> From: "Dr. David Alan Gilbert" <linux@treblig.org>
>
> Hi,
> This series removes some uncalled deadcode in nvmem.
> The third patch probably deserves a bit closer inspection.
>
> The first one removes nvmem_device_cell_read/write functions
> that haven't been used in ~10 years.
>
> The second removes nvmem_add/del_cell_table - again this is
> removing uncalled functions; nvmem_add_cell_table is unused
> after the removal of the Davinci machines.
>
> The third one removes the remaining nvmem_cell_table code - including
> a function that's called ( nvmem_add_cells_from_table ) - but
> my reading is that from the previous patch there's no way for this
> function to do anything active any more since the list it walks is
> empty.
>
> Build tested only.
>
> Signed-off-by: Dr. David Alan Gilbert <linux@treblig.org>
Hi,
I'd appreciate a review on this series if you get a chance.
Dave (cleaning up his patch queue)
>
>
> Dr. David Alan Gilbert (3):
> nvmem: core: Remove unused nvmem_device_cell_(read|write)
> nvmem: core: Remove nvmem_(add|del)_cell_table
> nvmem: core: Remove remains of nvmem_cell_table
>
> Documentation/driver-api/nvmem.rst | 23 ------
> drivers/nvmem/core.c | 126 -----------------------------
> include/linux/nvmem-consumer.h | 4 -
> include/linux/nvmem-provider.h | 24 ------
> 4 files changed, 177 deletions(-)
>
> --
> 2.48.1
>
--
-----Open up your eyes, open up your mind, open up your code -------
/ Dr. David Alan Gilbert | Running GNU/Linux | Happy \
\ dave @ treblig.org | | In Hex /
\ _________________________|_____ http://www.treblig.org |_______/
^ permalink raw reply [flat|nested] 5+ messages in thread