]>
git.proxmox.com Git - mirror_ubuntu-zesty-kernel.git/blob - include/linux/nvmem-consumer.h
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
21 struct nvmem_cell_info
{
25 unsigned int bit_offset
;
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
,
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
);
56 static inline struct nvmem_cell
*nvmem_cell_get(struct device
*dev
,
59 return ERR_PTR(-ENOSYS
);
62 static inline struct nvmem_cell
*devm_nvmem_cell_get(struct device
*dev
,
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 char *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
)
88 static inline struct nvmem_device
*nvmem_device_get(struct device
*dev
,
91 return ERR_PTR(-ENOSYS
);
94 static inline struct nvmem_device
*devm_nvmem_device_get(struct device
*dev
,
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
,
116 static inline int nvmem_device_cell_write(struct nvmem_device
*nvmem
,
117 struct nvmem_cell_info
*info
,
123 static inline int nvmem_device_read(struct nvmem_device
*nvmem
,
124 unsigned int offset
, size_t bytes
,
130 static inline int nvmem_device_write(struct nvmem_device
*nvmem
,
131 unsigned int offset
, size_t bytes
,
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
,
141 struct nvmem_device
*of_nvmem_device_get(struct device_node
*np
,
144 static inline struct nvmem_cell
*of_nvmem_cell_get(struct device_node
*np
,
147 return ERR_PTR(-ENOSYS
);
150 static inline struct nvmem_device
*of_nvmem_device_get(struct device_node
*np
,
153 return ERR_PTR(-ENOSYS
);
155 #endif /* CONFIG_NVMEM && CONFIG_OF */
157 #endif /* ifndef _LINUX_NVMEM_CONSUMER_H */