kernel: nvmem: fix "fixed-layout" & support "mac-base"
[openwrt/staging/hauke.git] / target / linux / generic / pending-6.1 / 803-nvmem-core-fix-support-for-fixed-cells-NVMEM-layout.patch
1 From: =?UTF-8?q?Rafa=C5=82=20Mi=C5=82ecki?= <rafal@milecki.pl>
2 Date: Thu, 13 Jul 2023 17:30:59 +0200
3 Subject: [PATCH] nvmem: core: fix support for fixed cells NVMEM layout
4 MIME-Version: 1.0
5 Content-Type: text/plain; charset=UTF-8
6 Content-Transfer-Encoding: 8bit
7
8 Returning -EPROBE_DEFER for "fixed-layout" makes nvmem_register() always
9 fail (that layout is supported internally with no external module). That
10 makes callers (e.g. mtd_nvmem_add()) fail as well and prevents booting
11 on devices with "fixed-layout" in DT.
12
13 Add a quick workaround for it.
14
15 Fixes: 6468a6f45148 ("nvmem: core: handle the absence of expected layouts")
16 Signed-off-by: Rafał Miłecki <rafal@milecki.pl>
17 ---
18
19 --- a/drivers/nvmem/core.c
20 +++ b/drivers/nvmem/core.c
21 @@ -794,6 +794,19 @@ static struct nvmem_layout *nvmem_layout
22 return NULL;
23
24 /*
25 + * We should return -EPROBE_DEFER only when layout driver is expected to
26 + * become available later. Otherwise NVMEM will never probe successfully
27 + * for unsupported layouts. There is no known solution for that right
28 + * now.
29 + *
30 + * This problem also affects "fixed-layout". It's supported in NVMEM
31 + * core code so there never will be layout for it. We shouldn't return
32 + * -EPROBE_DEFER in such case. Add a quick workaround for that.
33 + */
34 + if (of_device_is_compatible(layout_np, "fixed-layout"))
35 + return NULL;
36 +
37 + /*
38 * In case the nvmem device was built-in while the layout was built as a
39 * module, we shall manually request the layout driver loading otherwise
40 * we'll never have any match.