summaryrefslogtreecommitdiffstats
path: root/include/linux/nvmem-provider.h
diff options
context:
space:
mode:
authorBartosz Golaszewski <bgolaszewski@baylibre.com>2018-09-21 09:40:15 -0400
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2018-09-28 09:14:54 -0400
commitb985f4cba6dbb3b60ad119c6f7e5cbad6f0d7e45 (patch)
tree6062e9d3fb702b0cbc496f8a8e2003f7696638fd /include/linux/nvmem-provider.h
parentc7235ee3f4b86a01507a12e96a4875ba9b4be842 (diff)
nvmem: add support for cell info
Add new structs and routines allowing users to define nvmem cells from machine code. This global list of entries is parsed when a provider is registered and cells are associated with the relevant nvmem_device struct. A possible improvement for the future is to allow users to register cell tables after the nvmem provider has been registered by updating the cell list at each call to nvmem_(add|del)_cell_table(). Signed-off-by: Bartosz Golaszewski <bgolaszewski@baylibre.com> Signed-off-by: Srinivas Kandagatla <srinivas.kandagatla@linaro.org> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'include/linux/nvmem-provider.h')
-rw-r--r--include/linux/nvmem-provider.h33
1 files changed, 24 insertions, 9 deletions
diff --git a/include/linux/nvmem-provider.h b/include/linux/nvmem-provider.h
index 0f357d0c1e75..5c9f205cac8f 100644
--- a/include/linux/nvmem-provider.h
+++ b/include/linux/nvmem-provider.h
@@ -67,6 +67,25 @@ struct nvmem_config {
67 struct device *base_dev; 67 struct device *base_dev;
68}; 68};
69 69
70/**
71 * struct nvmem_cell_table - NVMEM cell definitions for given provider
72 *
73 * @nvmem_name: Provider name.
74 * @cells: Array of cell definitions.
75 * @ncells: Number of cell definitions in the array.
76 * @node: List node.
77 *
78 * This structure together with related helper functions is provided for users
79 * that don't can't access the nvmem provided structure but wish to register
80 * cell definitions for it e.g. board files registering an EEPROM device.
81 */
82struct nvmem_cell_table {
83 const char *nvmem_name;
84 const struct nvmem_cell_info *cells;
85 size_t ncells;
86 struct list_head node;
87};
88
70#if IS_ENABLED(CONFIG_NVMEM) 89#if IS_ENABLED(CONFIG_NVMEM)
71 90
72struct nvmem_device *nvmem_register(const struct nvmem_config *cfg); 91struct nvmem_device *nvmem_register(const struct nvmem_config *cfg);
@@ -77,9 +96,9 @@ struct nvmem_device *devm_nvmem_register(struct device *dev,
77 96
78int devm_nvmem_unregister(struct device *dev, struct nvmem_device *nvmem); 97int devm_nvmem_unregister(struct device *dev, struct nvmem_device *nvmem);
79 98
80int nvmem_add_cells(struct nvmem_device *nvmem, 99void nvmem_add_cell_table(struct nvmem_cell_table *table);
81 const struct nvmem_cell_info *info, 100void nvmem_del_cell_table(struct nvmem_cell_table *table);
82 int ncells); 101
83#else 102#else
84 103
85static inline struct nvmem_device *nvmem_register(const struct nvmem_config *c) 104static inline struct nvmem_device *nvmem_register(const struct nvmem_config *c)
@@ -102,12 +121,8 @@ devm_nvmem_unregister(struct device *dev, struct nvmem_device *nvmem)
102 121
103} 122}
104 123
105static inline int nvmem_add_cells(struct nvmem_device *nvmem, 124static inline void nvmem_add_cell_table(struct nvmem_cell_table *table) {}
106 const struct nvmem_cell_info *info, 125static inline void nvmem_del_cell_table(struct nvmem_cell_table *table) {}
107 int ncells)
108{
109 return -ENOSYS;
110}
111 126
112#endif /* CONFIG_NVMEM */ 127#endif /* CONFIG_NVMEM */
113#endif /* ifndef _LINUX_NVMEM_PROVIDER_H */ 128#endif /* ifndef _LINUX_NVMEM_PROVIDER_H */