Merge tag 'for_linus' of git://git.kernel.org/pub/scm/linux/kernel/git/mst/vhost
[cris-mirror.git] / include / linux / nvmem-provider.h
blob497706f5adcacc5db666a3099931bb45d0fbfc28
1 /*
2 * nvmem framework provider.
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_PROVIDER_H
13 #define _LINUX_NVMEM_PROVIDER_H
15 #include <linux/err.h>
16 #include <linux/errno.h>
18 struct nvmem_device;
19 struct nvmem_cell_info;
20 typedef int (*nvmem_reg_read_t)(void *priv, unsigned int offset,
21 void *val, size_t bytes);
22 typedef int (*nvmem_reg_write_t)(void *priv, unsigned int offset,
23 void *val, size_t bytes);
25 struct nvmem_config {
26 struct device *dev;
27 const char *name;
28 int id;
29 struct module *owner;
30 const struct nvmem_cell_info *cells;
31 int ncells;
32 bool read_only;
33 bool root_only;
34 nvmem_reg_read_t reg_read;
35 nvmem_reg_write_t reg_write;
36 int size;
37 int word_size;
38 int stride;
39 void *priv;
40 /* To be only used by old driver/misc/eeprom drivers */
41 bool compat;
42 struct device *base_dev;
45 #if IS_ENABLED(CONFIG_NVMEM)
47 struct nvmem_device *nvmem_register(const struct nvmem_config *cfg);
48 int nvmem_unregister(struct nvmem_device *nvmem);
50 #else
52 static inline struct nvmem_device *nvmem_register(const struct nvmem_config *c)
54 return ERR_PTR(-ENOSYS);
57 static inline int nvmem_unregister(struct nvmem_device *nvmem)
59 return -ENOSYS;
62 #endif /* CONFIG_NVMEM */
63 #endif /* ifndef _LINUX_NVMEM_PROVIDER_H */