summaryrefslogtreecommitdiffstats
path: root/include/linux/nvmem-consumer.h
diff options
context:
space:
mode:
authorSrinivas Kandagatla <srinivas.kandagatla@linaro.org>2015-07-27 07:13:45 -0400
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2015-08-05 16:43:44 -0400
commite2a5402ec7c6d0442cca370a0097e75750f81398 (patch)
treef52d6cbb6926345bb556c0b14d4a639abc4f9cec /include/linux/nvmem-consumer.h
parent69aba7948cbe53f2f1827e84e9dd0ae470a5072e (diff)
nvmem: Add nvmem_device based consumer apis.
This patch adds read/write apis which are based on nvmem_device. It is common that the drivers like omap cape manager or qcom cpr driver to access bytes directly at particular offset in the eeprom and not from nvmem cell info in DT. These driver would need to get access to the nvmem directly, which is what these new APIS provide. These wrapper apis would help such users to avoid code duplication in there drivers and also avoid them reading a big eeprom blob and parsing it internally in there driver. Signed-off-by: Srinivas Kandagatla <srinivas.kandagatla@linaro.org> Tested-by: Stefan Wahren <stefan.wahren@i2se.com> Tested-by: Philipp Zabel <p.zabel@pengutronix.de> Tested-by: Rajendra Nayak <rnayak@codeaurora.org> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'include/linux/nvmem-consumer.h')
-rw-r--r--include/linux/nvmem-consumer.h73
1 files changed, 73 insertions, 0 deletions
diff --git a/include/linux/nvmem-consumer.h b/include/linux/nvmem-consumer.h
index 297cc67b7211..9bb77d3ed6e0 100644
--- a/include/linux/nvmem-consumer.h
+++ b/include/linux/nvmem-consumer.h
@@ -16,6 +16,7 @@ struct device;
16struct device_node; 16struct device_node;
17/* consumer cookie */ 17/* consumer cookie */
18struct nvmem_cell; 18struct nvmem_cell;
19struct nvmem_device;
19 20
20struct nvmem_cell_info { 21struct nvmem_cell_info {
21 const char *name; 22 const char *name;
@@ -35,6 +36,21 @@ void devm_nvmem_cell_put(struct device *dev, struct nvmem_cell *cell);
35void *nvmem_cell_read(struct nvmem_cell *cell, size_t *len); 36void *nvmem_cell_read(struct nvmem_cell *cell, size_t *len);
36int nvmem_cell_write(struct nvmem_cell *cell, void *buf, size_t len); 37int nvmem_cell_write(struct nvmem_cell *cell, void *buf, size_t len);
37 38
39/* direct nvmem device read/write interface */
40struct nvmem_device *nvmem_device_get(struct device *dev, const char *name);
41struct nvmem_device *devm_nvmem_device_get(struct device *dev,
42 const char *name);
43void nvmem_device_put(struct nvmem_device *nvmem);
44void devm_nvmem_device_put(struct device *dev, struct nvmem_device *nvmem);
45int nvmem_device_read(struct nvmem_device *nvmem, unsigned int offset,
46 size_t bytes, void *buf);
47int nvmem_device_write(struct nvmem_device *nvmem, unsigned int offset,
48 size_t bytes, void *buf);
49ssize_t nvmem_device_cell_read(struct nvmem_device *nvmem,
50 struct nvmem_cell_info *info, void *buf);
51int nvmem_device_cell_write(struct nvmem_device *nvmem,
52 struct nvmem_cell_info *info, void *buf);
53
38#else 54#else
39 55
40static inline struct nvmem_cell *nvmem_cell_get(struct device *dev, 56static inline struct nvmem_cell *nvmem_cell_get(struct device *dev,
@@ -68,17 +84,74 @@ static inline int nvmem_cell_write(struct nvmem_cell *cell,
68{ 84{
69 return -ENOSYS; 85 return -ENOSYS;
70} 86}
87
88static inline struct nvmem_device *nvmem_device_get(struct device *dev,
89 const char *name)
90{
91 return ERR_PTR(-ENOSYS);
92}
93
94static inline struct nvmem_device *devm_nvmem_device_get(struct device *dev,
95 const char *name)
96{
97 return ERR_PTR(-ENOSYS);
98}
99
100static inline void nvmem_device_put(struct nvmem_device *nvmem)
101{
102}
103
104static inline void devm_nvmem_device_put(struct device *dev,
105 struct nvmem_device *nvmem)
106{
107}
108
109static inline ssize_t nvmem_device_cell_read(struct nvmem_device *nvmem,
110 struct nvmem_cell_info *info,
111 void *buf)
112{
113 return -ENOSYS;
114}
115
116static inline int nvmem_device_cell_write(struct nvmem_device *nvmem,
117 struct nvmem_cell_info *info,
118 void *buf)
119{
120 return -ENOSYS;
121}
122
123static inline int nvmem_device_read(struct nvmem_device *nvmem,
124 unsigned int offset, size_t bytes,
125 void *buf)
126{
127 return -ENOSYS;
128}
129
130static inline int nvmem_device_write(struct nvmem_device *nvmem,
131 unsigned int offset, size_t bytes,
132 void *buf)
133{
134 return -ENOSYS;
135}
71#endif /* CONFIG_NVMEM */ 136#endif /* CONFIG_NVMEM */
72 137
73#if IS_ENABLED(CONFIG_NVMEM) && IS_ENABLED(CONFIG_OF) 138#if IS_ENABLED(CONFIG_NVMEM) && IS_ENABLED(CONFIG_OF)
74struct nvmem_cell *of_nvmem_cell_get(struct device_node *np, 139struct nvmem_cell *of_nvmem_cell_get(struct device_node *np,
75 const char *name); 140 const char *name);
141struct nvmem_device *of_nvmem_device_get(struct device_node *np,
142 const char *name);
76#else 143#else
77static inline struct nvmem_cell *of_nvmem_cell_get(struct device_node *np, 144static inline struct nvmem_cell *of_nvmem_cell_get(struct device_node *np,
78 const char *name) 145 const char *name)
79{ 146{
80 return ERR_PTR(-ENOSYS); 147 return ERR_PTR(-ENOSYS);
81} 148}
149
150static inline struct nvmem_device *of_nvmem_device_get(struct device_node *np,
151 const char *name)
152{
153 return ERR_PTR(-ENOSYS);
154}
82#endif /* CONFIG_NVMEM && CONFIG_OF */ 155#endif /* CONFIG_NVMEM && CONFIG_OF */
83 156
84#endif /* ifndef _LINUX_NVMEM_CONSUMER_H */ 157#endif /* ifndef _LINUX_NVMEM_CONSUMER_H */