8f64d0c28b8599ee55346c42531f89eebdf5754a
[openwrt/staging/xback.git] /
1 From 6c7f48ea2e663b679aa8e60d8d8e1e6306a644f9 Mon Sep 17 00:00:00 2001
2 From: Miquel Raynal <miquel.raynal@bootlin.com>
3 Date: Tue, 8 Aug 2023 08:29:27 +0200
4 Subject: [PATCH] nvmem: core: Return NULL when no nvmem layout is found
5
6 Currently, of_nvmem_layout_get_container() returns NULL on error, or an
7 error pointer if either CONFIG_NVMEM or CONFIG_OF is turned off. We
8 should likely avoid this kind of mix for two reasons: to clarify the
9 intend and anyway fix the !CONFIG_OF which will likely always if we use
10 this helper somewhere else. Let's just return NULL when no layout is
11 found, we don't need an error value here.
12
13 Link: https://staticthinking.wordpress.com/2022/08/01/mixing-error-pointers-and-null/
14 Fixes: 266570f496b9 ("nvmem: core: introduce NVMEM layouts")
15 Reported-by: kernel test robot <lkp@intel.com>
16 Reported-by: Dan Carpenter <dan.carpenter@linaro.org>
17 Closes: https://lore.kernel.org/r/202308030002.DnSFOrMB-lkp@intel.com/
18 Signed-off-by: Miquel Raynal <miquel.raynal@bootlin.com>
19 Reviewed-by: Michael Walle <michael@walle.cc>
20 Signed-off-by: Srinivas Kandagatla <srinivas.kandagatla@linaro.org>
21 ---
22 include/linux/nvmem-consumer.h | 2 +-
23 1 file changed, 1 insertion(+), 1 deletion(-)
24
25 --- a/include/linux/nvmem-consumer.h
26 +++ b/include/linux/nvmem-consumer.h
27 @@ -256,7 +256,7 @@ static inline struct nvmem_device *of_nv
28 static inline struct device_node *
29 of_nvmem_layout_get_container(struct nvmem_device *nvmem)
30 {
31 - return ERR_PTR(-EOPNOTSUPP);
32 + return NULL;
33 }
34 #endif /* CONFIG_NVMEM && CONFIG_OF */
35