Swetha Chikkaboraiah | aa9b066 | 2019-04-26 15:21:52 +0530 | [diff] [blame] | 1 | /* SPDX-License-Identifier: GPL-2.0 */ |
| 2 | |
| 3 | #ifndef _DRIVERS_NVMEM_H |
| 4 | #define _DRIVERS_NVMEM_H |
| 5 | |
| 6 | #include <linux/device.h> |
| 7 | #include <linux/fs.h> |
| 8 | #include <linux/kref.h> |
| 9 | #include <linux/list.h> |
| 10 | #include <linux/nvmem-consumer.h> |
| 11 | #include <linux/nvmem-provider.h> |
| 12 | |
| 13 | struct nvmem_device { |
| 14 | const char *name; |
| 15 | struct module *owner; |
| 16 | struct device dev; |
| 17 | int stride; |
| 18 | int word_size; |
| 19 | int ncells; |
| 20 | int id; |
| 21 | int users; |
| 22 | size_t size; |
| 23 | bool read_only; |
| 24 | int flags; |
| 25 | struct bin_attribute eeprom; |
| 26 | struct device *base_dev; |
| 27 | nvmem_reg_read_t reg_read; |
| 28 | nvmem_reg_write_t reg_write; |
| 29 | void *priv; |
| 30 | }; |
| 31 | |
| 32 | #define to_nvmem_device(d) container_of(d, struct nvmem_device, dev) |
| 33 | #define FLAG_COMPAT BIT(0) |
| 34 | |
| 35 | #ifdef CONFIG_NVMEM_SYSFS |
| 36 | const struct attribute_group **nvmem_sysfs_get_groups( |
| 37 | struct nvmem_device *nvmem, |
| 38 | const struct nvmem_config *config); |
| 39 | int nvmem_sysfs_setup_compat(struct nvmem_device *nvmem, |
| 40 | const struct nvmem_config *config); |
| 41 | void nvmem_sysfs_remove_compat(struct nvmem_device *nvmem, |
| 42 | const struct nvmem_config *config); |
| 43 | #else |
| 44 | static inline const struct attribute_group **nvmem_sysfs_get_groups( |
| 45 | struct nvmem_device *nvmem, |
| 46 | const struct nvmem_config *config) |
| 47 | { |
| 48 | return NULL; |
| 49 | } |
| 50 | |
| 51 | static inline int nvmem_sysfs_setup_compat(struct nvmem_device *nvmem, |
| 52 | const struct nvmem_config *config) |
| 53 | { |
| 54 | return -ENOSYS; |
| 55 | } |
| 56 | static inline void nvmem_sysfs_remove_compat(struct nvmem_device *nvmem, |
| 57 | const struct nvmem_config *config) |
| 58 | { |
| 59 | } |
| 60 | #endif /* CONFIG_NVMEM_SYSFS */ |
| 61 | |
| 62 | #endif /* _DRIVERS_NVMEM_H */ |