of_graph: add of_graph_get_port_parent()
[linux-2.6/btrfs-unstable.git] / include / linux / nvmem-consumer.h
blobc2256d74654333b9103fab444c4e318e2c7d422a
1 /*
2 * nvmem framework consumer.
4 * Copyright (C) 2015 Srinivas Kandagatla <srinivas.kandagatla@linaro.org>
5 * Copyright (C) 2013 Maxime Ripard <maxime.ripard@free-electrons.com>
7 * This file is licensed under the terms of the GNU General Public
8 * License version 2. This program is licensed "as is" without any
9 * warranty of any kind, whether express or implied.
12 #ifndef _LINUX_NVMEM_CONSUMER_H
13 #define _LINUX_NVMEM_CONSUMER_H
15 struct device;
16 struct device_node;
17 /* consumer cookie */
18 struct nvmem_cell;
19 struct nvmem_device;
21 struct nvmem_cell_info {
22 const char *name;
23 unsigned int offset;
24 unsigned int bytes;
25 unsigned int bit_offset;
26 unsigned int nbits;
29 #if IS_ENABLED(CONFIG_NVMEM)
31 /* Cell based interface */
32 struct nvmem_cell *nvmem_cell_get(struct device *dev, const char *name);
33 struct nvmem_cell *devm_nvmem_cell_get(struct device *dev, const char *name);
34 void nvmem_cell_put(struct nvmem_cell *cell);
35 void devm_nvmem_cell_put(struct device *dev, struct nvmem_cell *cell);
36 void *nvmem_cell_read(struct nvmem_cell *cell, size_t *len);
37 int nvmem_cell_write(struct nvmem_cell *cell, void *buf, size_t len);
39 /* direct nvmem device read/write interface */
40 struct nvmem_device *nvmem_device_get(struct device *dev, const char *name);
41 struct nvmem_device *devm_nvmem_device_get(struct device *dev,
42 const char *name);
43 void nvmem_device_put(struct nvmem_device *nvmem);
44 void devm_nvmem_device_put(struct device *dev, struct nvmem_device *nvmem);
45 int nvmem_device_read(struct nvmem_device *nvmem, unsigned int offset,
46 size_t bytes, void *buf);
47 int nvmem_device_write(struct nvmem_device *nvmem, unsigned int offset,
48 size_t bytes, void *buf);
49 ssize_t nvmem_device_cell_read(struct nvmem_device *nvmem,
50 struct nvmem_cell_info *info, void *buf);
51 int nvmem_device_cell_write(struct nvmem_device *nvmem,
52 struct nvmem_cell_info *info, void *buf);
54 #else
56 static inline struct nvmem_cell *nvmem_cell_get(struct device *dev,
57 const char *name)
59 return ERR_PTR(-ENOSYS);
62 static inline struct nvmem_cell *devm_nvmem_cell_get(struct device *dev,
63 const char *name)
65 return ERR_PTR(-ENOSYS);
68 static inline void devm_nvmem_cell_put(struct device *dev,
69 struct nvmem_cell *cell)
73 static inline void nvmem_cell_put(struct nvmem_cell *cell)
77 static inline void *nvmem_cell_read(struct nvmem_cell *cell, size_t *len)
79 return ERR_PTR(-ENOSYS);
82 static inline int nvmem_cell_write(struct nvmem_cell *cell,
83 const char *buf, size_t len)
85 return -ENOSYS;
88 static inline struct nvmem_device *nvmem_device_get(struct device *dev,
89 const char *name)
91 return ERR_PTR(-ENOSYS);
94 static inline struct nvmem_device *devm_nvmem_device_get(struct device *dev,
95 const char *name)
97 return ERR_PTR(-ENOSYS);
100 static inline void nvmem_device_put(struct nvmem_device *nvmem)
104 static inline void devm_nvmem_device_put(struct device *dev,
105 struct nvmem_device *nvmem)
109 static inline ssize_t nvmem_device_cell_read(struct nvmem_device *nvmem,
110 struct nvmem_cell_info *info,
111 void *buf)
113 return -ENOSYS;
116 static inline int nvmem_device_cell_write(struct nvmem_device *nvmem,
117 struct nvmem_cell_info *info,
118 void *buf)
120 return -ENOSYS;
123 static inline int nvmem_device_read(struct nvmem_device *nvmem,
124 unsigned int offset, size_t bytes,
125 void *buf)
127 return -ENOSYS;
130 static inline int nvmem_device_write(struct nvmem_device *nvmem,
131 unsigned int offset, size_t bytes,
132 void *buf)
134 return -ENOSYS;
136 #endif /* CONFIG_NVMEM */
138 #if IS_ENABLED(CONFIG_NVMEM) && IS_ENABLED(CONFIG_OF)
139 struct nvmem_cell *of_nvmem_cell_get(struct device_node *np,
140 const char *name);
141 struct nvmem_device *of_nvmem_device_get(struct device_node *np,
142 const char *name);
143 #else
144 static inline struct nvmem_cell *of_nvmem_cell_get(struct device_node *np,
145 const char *name)
147 return ERR_PTR(-ENOSYS);
150 static inline struct nvmem_device *of_nvmem_device_get(struct device_node *np,
151 const char *name)
153 return ERR_PTR(-ENOSYS);
155 #endif /* CONFIG_NVMEM && CONFIG_OF */
157 #endif /* ifndef _LINUX_NVMEM_CONSUMER_H */