Skip to content

Commit f3c7b40

Browse files
nunojsacseci
authored andcommitted
jesd204: core: fix dts overlay handling
When handling the notifications sent by dts overlays, the code was calling 'of_find_node_with_property()' to look for jesd204 devices. The typical way to call this is: ``` for (dn = of_find_node_with_property(NULL, prop_name); dn; \ dn = of_find_node_with_property(dn, prop_name)) ``` So when we are done with the loop, all nodes are properly handled (i.e: of_node_put() was called). The problem here is that we first call 'of_find_node_with_property()' with a non NULL 'from' and so 'of_node_put()' will be wrongly called on it (since that node is not something we really hold a reference for) leading to the following dump when releasing a dt overlay: [ 8590.192388] OF: ERROR: Bad of_node_put() on /fragment@0/__overlay__ [ 8590.192410] CPU: 0 PID: 1352 Comm: dtoverlay Tainted: G WC 5.10.63-v7l+ #3 [ 8590.192420] Hardware name: BCM2711 [ 8590.192429] Backtrace: [ 8590.192468] [<c0ffcedc>] (dump_backtrace) from [<c0ffd250>] (show_stack+0x20/0x24) [ 8590.192483] r7:ffffffff r6:00000000 r5:60000013 r4:c1ee76fc [ 8590.192501] [<c0ffd230>] (show_stack) from [<c1001a80>] (dump_stack+0xc4/0xf0) [ 8590.192519] [<c10019bc>] (dump_stack) from [<c0b9dae8>] (of_node_release+0x120/0x124) [ 8590.192533] r9:c49b1100 r8:c4fe3020 r7:c5fb0190 r6:c5fb01bc r5:00000000 r4:c5fb01bc [ 8590.192553] [<c0b9d9c8>] (of_node_release) from [<c07a1470>] (kobject_put+0xb8/0xf8) [ 8590.192565] r7:00000000 r6:c1f30748 r5:00000000 r4:c5fb01bc [ 8590.192580] [<c07a13b8>] (kobject_put) from [<c0b9cd40>] (of_node_put+0x24/0x28) [ 8590.192592] r7:c1f3097c r6:c4fe3000 r5:c4fe3000 r4:00000001 [ 8590.192609] [<c0b9cd1c>] (of_node_put) from [<c0ba2580>] (free_overlay_changeset+0x68/0xa8) [ 8590.192626] [<c0ba2518>] (free_overlay_changeset) from [<c0ba27f8>] (of_overlay_remove+0x1b8/0x2b8) ... This change fixes it by refactoring the way we detect jesd204 devices. Note that with this, the following dts overlay example won't work: ``` __overlay__ { node1 { node2 { jesd204_device; }; }; }; ``` For now this should not be a problem as we don't really have jesd devices defined in child nodes of a device. Fixes: b61aebb ("jesd204: jesd204-core: Support for dynamic dt changes") Signed-off-by: Nuno Sá <[email protected]> (cherry picked from commit e6f48d8)
1 parent 9bf1ca8 commit f3c7b40

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

drivers/jesd204/jesd204-core.c

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1082,9 +1082,10 @@ static int jesd204_overlay_has_device(struct device_node *node)
10821082
struct device_node *dn;
10831083
int i = 0;
10841084

1085-
for (dn = of_find_node_with_property(node, "jesd204-device"); dn;
1086-
dn = of_find_node_with_property(dn, "jesd204-device"))
1087-
i++;
1085+
for_each_available_child_of_node(node, dn) {
1086+
if (of_property_read_bool(dn, "jesd204-device"))
1087+
i++;
1088+
}
10881089

10891090
return i;
10901091
}

0 commit comments

Comments
 (0)