kernel: backport upstream nvmem fix for "fixed-layout"
[openwrt/openwrt.git] / target / linux / generic / backport-5.15 / 820-v6.7-0005-nvmem-Do-not-expect-fixed-layouts-to-grab-a-layout-d.patch
1 From b7c1e53751cb3990153084f31c41f25fde3b629c Mon Sep 17 00:00:00 2001
2 From: Miquel Raynal <miquel.raynal@bootlin.com>
3 Date: Fri, 24 Nov 2023 20:38:14 +0100
4 Subject: [PATCH] nvmem: Do not expect fixed layouts to grab a layout driver
5 MIME-Version: 1.0
6 Content-Type: text/plain; charset=UTF-8
7 Content-Transfer-Encoding: 8bit
8
9 Two series lived in parallel for some time, which led to this situation:
10 - The nvmem-layout container is used for dynamic layouts
11 - We now expect fixed layouts to also use the nvmem-layout container but
12 this does not require any additional driver, the support is built-in the
13 nvmem core.
14
15 Ensure we don't refuse to probe for wrong reasons.
16
17 Fixes: 27f699e578b1 ("nvmem: core: add support for fixed cells *layout*")
18 Cc: stable@vger.kernel.org
19 Reported-by: Luca Ceresoli <luca.ceresoli@bootlin.com>
20 Signed-off-by: Miquel Raynal <miquel.raynal@bootlin.com>
21 Tested-by: Rafał Miłecki <rafal@milecki.pl>
22 Tested-by: Luca Ceresoli <luca.ceresoli@bootlin.com>
23 Reviewed-by: Luca Ceresoli <luca.ceresoli@bootlin.com>
24
25 Link: https://lore.kernel.org/r/20231124193814.360552-1-miquel.raynal@bootlin.com
26 Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
27 ---
28 drivers/nvmem/core.c | 6 ++++++
29 1 file changed, 6 insertions(+)
30
31 --- a/drivers/nvmem/core.c
32 +++ b/drivers/nvmem/core.c
33 @@ -797,6 +797,12 @@ static struct nvmem_layout *nvmem_layout
34 if (!layout_np)
35 return NULL;
36
37 + /* Fixed layouts don't have a matching driver */
38 + if (of_device_is_compatible(layout_np, "fixed-layout")) {
39 + of_node_put(layout_np);
40 + return NULL;
41 + }
42 +
43 /*
44 * In case the nvmem device was built-in while the layout was built as a
45 * module, we shall manually request the layout driver loading otherwise