* [PATCH 2/4] nvmem: add missing stubs
2021-01-18 20:55 [PATCH 1/4] nvmem: sync stub return values with linux code Marco Felsch
@ 2021-01-18 20:55 ` Marco Felsch
2021-01-18 20:55 ` [PATCH 3/4] nvmem: make nvmem_device_write/read public Marco Felsch
` (2 subsequent siblings)
3 siblings, 0 replies; 5+ messages in thread
From: Marco Felsch @ 2021-01-18 20:55 UTC (permalink / raw)
To: barebox
Add missing stubs for nvmem_device_cell_read/write().
Signed-off-by: Marco Felsch <m.felsch@pengutronix.de>
---
include/linux/nvmem-consumer.h | 14 ++++++++++++++
1 file changed, 14 insertions(+)
diff --git a/include/linux/nvmem-consumer.h b/include/linux/nvmem-consumer.h
index 2f79014c0f..d86377bfda 100644
--- a/include/linux/nvmem-consumer.h
+++ b/include/linux/nvmem-consumer.h
@@ -84,6 +84,20 @@ static inline struct nvmem_device *nvmem_device_get(struct device_d *dev,
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;
+}
#endif /* CONFIG_NVMEM */
#if IS_ENABLED(CONFIG_NVMEM) && IS_ENABLED(CONFIG_OFTREE)
--
2.20.1
_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox
^ permalink raw reply [flat|nested] 5+ messages in thread
* [PATCH 3/4] nvmem: make nvmem_device_write/read public
2021-01-18 20:55 [PATCH 1/4] nvmem: sync stub return values with linux code Marco Felsch
2021-01-18 20:55 ` [PATCH 2/4] nvmem: add missing stubs Marco Felsch
@ 2021-01-18 20:55 ` Marco Felsch
2021-01-18 20:55 ` [PATCH 4/4] nvmem: make id optional for of_nvmem_device_get() Marco Felsch
2021-01-19 10:15 ` [PATCH 1/4] nvmem: sync stub return values with linux code Sascha Hauer
3 siblings, 0 replies; 5+ messages in thread
From: Marco Felsch @ 2021-01-18 20:55 UTC (permalink / raw)
To: barebox
Those functions already export their symbols so make it public
available. Compared to the nvmem_device_cell_read/write() APIs these
functions are a bit easier to use.
Signed-off-by: Marco Felsch <m.felsch@pengutronix.de>
---
drivers/nvmem/core.c | 6 ------
include/linux/nvmem-consumer.h | 19 +++++++++++++++++++
2 files changed, 19 insertions(+), 6 deletions(-)
diff --git a/drivers/nvmem/core.c b/drivers/nvmem/core.c
index 06e1414769..b9af31f4b5 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)
{
diff --git a/include/linux/nvmem-consumer.h b/include/linux/nvmem-consumer.h
index d86377bfda..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,
@@ -98,6 +102,21 @@ static inline int nvmem_device_cell_write(struct nvmem_device *nvmem,
{
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)
--
2.20.1
_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox
^ permalink raw reply [flat|nested] 5+ messages in thread
* [PATCH 4/4] nvmem: make id optional for of_nvmem_device_get()
2021-01-18 20:55 [PATCH 1/4] nvmem: sync stub return values with linux code Marco Felsch
2021-01-18 20:55 ` [PATCH 2/4] nvmem: add missing stubs Marco Felsch
2021-01-18 20:55 ` [PATCH 3/4] nvmem: make nvmem_device_write/read public Marco Felsch
@ 2021-01-18 20:55 ` Marco Felsch
2021-01-19 10:15 ` [PATCH 1/4] nvmem: sync stub return values with linux code Sascha Hauer
3 siblings, 0 replies; 5+ messages in thread
From: Marco Felsch @ 2021-01-18 20:55 UTC (permalink / raw)
To: barebox
Port upstream linux commit
8<----------------------------------------------------------------------
commit d4e7fef1a9a5d2bf3f859ba9f50f4d5409a09ab0
Author: Alban Bedel <albeu@free.fr>
Date: Mon Jan 28 15:55:03 2019 +0000
nvmem: core: Properly handle connection ID in of_nvmem_device_get()
of_nvmem_device_get() would crash if NULL was passed as a connection
ID. Rework this to use the usual sementic of assuming the first
connection when no connection ID is given.
Furthermore of_nvmem_device_get() would return -EINVAL when it failed
to resolve the connection, making it impossible to properly implement
an optional connection. Return -ENOENT instead to let the caller know
that the connection doesn't exists.
Signed-off-by: Alban Bedel <albeu@free.fr>
Signed-off-by: Srinivas Kandagatla <srinivas.kandagatla@linaro.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
8<----------------------------------------------------------------------
Signed-off-by: Marco Felsch <m.felsch@pengutronix.de>
---
drivers/nvmem/core.c | 7 ++++---
1 file changed, 4 insertions(+), 3 deletions(-)
diff --git a/drivers/nvmem/core.c b/drivers/nvmem/core.c
index b9af31f4b5..9b55f47b4c 100644
--- a/drivers/nvmem/core.c
+++ b/drivers/nvmem/core.c
@@ -284,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);
}
--
2.20.1
_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH 1/4] nvmem: sync stub return values with linux code
2021-01-18 20:55 [PATCH 1/4] nvmem: sync stub return values with linux code Marco Felsch
` (2 preceding siblings ...)
2021-01-18 20:55 ` [PATCH 4/4] nvmem: make id optional for of_nvmem_device_get() Marco Felsch
@ 2021-01-19 10:15 ` Sascha Hauer
3 siblings, 0 replies; 5+ messages in thread
From: Sascha Hauer @ 2021-01-19 10:15 UTC (permalink / raw)
To: Marco Felsch; +Cc: barebox
On Mon, Jan 18, 2021 at 09:55:25PM +0100, Marco Felsch wrote:
> Based on linux commit:
> 8<------------------------------------------------------------------------
> commit 20167b70c894f20cd01e2579fad206de440816ef
> Author: Bartosz Golaszewski <bgolaszewski@baylibre.com>
> Date: Fri Sep 21 06:40:22 2018 -0700
>
> nvmem: use EOPNOTSUPP instead of ENOSYS
>
> Checkpatch emits warnings when using ENOSYS. Some of the frameworks
> started using EOPNOTSUPP as return values for API functions when given
> subsystem is disabled in Kconfig.
>
> Signed-off-by: Bartosz Golaszewski <bgolaszewski@baylibre.com>
> Signed-off-by: Srinivas Kandagatla <srinivas.kandagatla@linaro.org>
> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
> 8<------------------------------------------------------------------------
>
> Signed-off-by: Marco Felsch <m.felsch@pengutronix.de>
> ---
> include/linux/nvmem-consumer.h | 10 +++++-----
> 1 file changed, 5 insertions(+), 5 deletions(-)
Applied, thanks
Sascha
>
> diff --git a/include/linux/nvmem-consumer.h b/include/linux/nvmem-consumer.h
> index 9e0fd4265e..2f79014c0f 100644
> --- a/include/linux/nvmem-consumer.h
> +++ b/include/linux/nvmem-consumer.h
> @@ -50,7 +50,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,26 +59,26 @@ 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)
> --
> 2.20.1
>
>
> _______________________________________________
> barebox mailing list
> barebox@lists.infradead.org
> http://lists.infradead.org/mailman/listinfo/barebox
>
--
Pengutronix e.K. | |
Steuerwalder Str. 21 | http://www.pengutronix.de/ |
31137 Hildesheim, Germany | Phone: +49-5121-206917-0 |
Amtsgericht Hildesheim, HRA 2686 | Fax: +49-5121-206917-5555 |
_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox
^ permalink raw reply [flat|nested] 5+ messages in thread