diff options
author | Sascha Hauer <s.hauer@pengutronix.de> | 2021-02-22 10:39:39 +0100 |
---|---|---|
committer | Sascha Hauer <s.hauer@pengutronix.de> | 2021-02-22 10:39:39 +0100 |
commit | 774f731a63500deec5d529bb17a75a983f3a4629 (patch) | |
tree | 475c1496d3ed114f01d50755d8f88555969577c6 | |
parent | 0299293b8d2a8546f1c72780ecb6511cf9ca3894 (diff) | |
parent | 1b5dbc63a02472db2dc40ae929f9b2615137ca6c (diff) | |
download | barebox-774f731a63500deec5d529bb17a75a983f3a4629.tar.gz barebox-774f731a63500deec5d529bb17a75a983f3a4629.tar.xz |
Merge branch 'for-next/nvmem'
-rw-r--r-- | drivers/nvmem/core.c | 13 | ||||
-rw-r--r-- | include/linux/nvmem-consumer.h | 43 |
2 files changed, 42 insertions, 14 deletions
diff --git a/drivers/nvmem/core.c b/drivers/nvmem/core.c index 02d0af6e1d..2a1c4b6941 100644 --- a/drivers/nvmem/core.c +++ b/drivers/nvmem/core.c @@ -48,12 +48,6 @@ struct nvmem_cell { static LIST_HEAD(nvmem_cells); static LIST_HEAD(nvmem_devs); -int nvmem_device_read(struct nvmem_device *nvmem, unsigned int offset, - size_t bytes, void *buf); -int nvmem_device_write(struct nvmem_device *nvmem, unsigned int offset, - size_t bytes, const void *buf); - - static ssize_t nvmem_cdev_read(struct cdev *cdev, void *buf, size_t count, loff_t offset, unsigned long flags) { @@ -290,13 +284,14 @@ struct nvmem_device *of_nvmem_device_get(struct device_node *np, const char *id) { struct device_node *nvmem_np; - int index; + int index = 0; - index = of_property_match_string(np, "nvmem-names", id); + if (id) + index = of_property_match_string(np, "nvmem-names", id); nvmem_np = of_parse_phandle(np, "nvmem", index); if (!nvmem_np) - return ERR_PTR(-EINVAL); + return ERR_PTR(-ENOENT); return __nvmem_device_get(nvmem_np, NULL, NULL); } diff --git a/include/linux/nvmem-consumer.h b/include/linux/nvmem-consumer.h index 9e0fd4265e..5d3d72837b 100644 --- a/include/linux/nvmem-consumer.h +++ b/include/linux/nvmem-consumer.h @@ -40,6 +40,10 @@ int nvmem_cell_write(struct nvmem_cell *cell, void *buf, size_t len); /* direct nvmem device read/write interface */ struct nvmem_device *nvmem_device_get(struct device_d *dev, const char *name); void nvmem_device_put(struct nvmem_device *nvmem); +int nvmem_device_read(struct nvmem_device *nvmem, unsigned int offset, + size_t bytes, void *buf); +int nvmem_device_write(struct nvmem_device *nvmem, unsigned int offset, + size_t bytes, const void *buf); ssize_t nvmem_device_cell_read(struct nvmem_device *nvmem, struct nvmem_cell_info *info, void *buf); int nvmem_device_cell_write(struct nvmem_device *nvmem, @@ -50,7 +54,7 @@ int nvmem_device_cell_write(struct nvmem_device *nvmem, static inline struct nvmem_cell *nvmem_cell_get(struct device_d *dev, const char *name) { - return ERR_PTR(-ENOSYS); + return ERR_PTR(-EOPNOTSUPP); } static inline void nvmem_cell_put(struct nvmem_cell *cell) @@ -59,31 +63,60 @@ static inline void nvmem_cell_put(struct nvmem_cell *cell) static inline char *nvmem_cell_read(struct nvmem_cell *cell, size_t *len) { - return ERR_PTR(-ENOSYS); + return ERR_PTR(-EOPNOTSUPP); } static inline void *nvmem_cell_get_and_read(struct device_node *np, const char *cell_name, size_t bytes) { - return ERR_PTR(-ENOSYS); + return ERR_PTR(-EOPNOTSUPP); } static inline int nvmem_cell_write(struct nvmem_cell *cell, const char *buf, size_t len) { - return -ENOSYS; + return -EOPNOTSUPP; } static inline struct nvmem_device *nvmem_device_get(struct device_d *dev, const char *name) { - return ERR_PTR(-ENOSYS); + return ERR_PTR(-EOPNOTSUPP); } static inline void nvmem_device_put(struct nvmem_device *nvmem) { } + +static inline ssize_t nvmem_device_cell_read(struct nvmem_device *nvmem, + struct nvmem_cell_info *info, + void *buf) +{ + return -EOPNOTSUPP; +} + +static inline int nvmem_device_cell_write(struct nvmem_device *nvmem, + struct nvmem_cell_info *info, + void *buf) +{ + return -EOPNOTSUPP; +} + +static inline int nvmem_device_read(struct nvmem_device *nvmem, + unsigned int offset, size_t bytes, + void *buf) +{ + return -EOPNOTSUPP; +} + +static inline int nvmem_device_write(struct nvmem_device *nvmem, + unsigned int offset, size_t bytes, + const void *buf) +{ + return -EOPNOTSUPP; +} + #endif /* CONFIG_NVMEM */ #if IS_ENABLED(CONFIG_NVMEM) && IS_ENABLED(CONFIG_OFTREE) |