of/flattree: Fix unhandled OF_DT_NOP tag when unflattening the device tree
PATCH v2 1/1 of/flattree: Fix unhandled OF_DT_NOP tag when unflattening the device tree
From: Jason Gunthorpe <[email protected]>
NOPs within the property section are skipped, but NOPs between OF_DT_END_NODE and OF_DT_BEGIN_NODE were not. My firmware NOPs out entire nodes depending on various environment parameters.
of_scan_flat_dt already handles NOP more generally.
---
v2 - adapted to new location of unflatten_dt_node().
Jason, please test against 2.6.34-rc1
drivers/of/fdt.c | 7 +++++-- 1 files changed, 5 insertions(+), 2 deletions(-)
drivers/of/fdt.c +5 -2
@@ -376,8 +376,11 @@ unsigned long __init unflatten_dt_node(unsigned long mem,if (!np->type) np->type ="<NULL>" ; } -while (tag ==OF_DT_BEGIN_NODE ) { - mem =unflatten_dt_node (mem, p, np, allnextpp, fpsize); +while (tag ==OF_DT_BEGIN_NODE || tag ==OF_DT_NOP ) { +if (tag ==OF_DT_NOP ) + *p +=4 ; +else + mem =unflatten_dt_node (mem, p, np, allnextpp, fpsize); tag =be32_to_cpup ((__be32 *)(*p)); }if (tag !=OF_DT_END_NODE ) {
Quoted 7 lines · Grant Likely
From: Jason Gunthorpe <jgunthorpe-ePGOBjL8dl3ta4EC/59zMFaTQe2KTcn/@public.gmane.org>
NOPs within the property section are skipped, but NOPs between
OF_DT_END_NODEandOF_DT_BEGIN_NODEwere not. My firmware NOPs out entire nodes depending on various environment parameters.
of_scan_flat_dtalready handles NOP more generally.
Fwiw, there's a test program in the libfdt/dtc tree called "nopulate" which will liberally spread NOPs through a device tree blob (one between every other tag), which might be useful for testing this
Signature · 4 lines
David Gibson | I'll have my music baroque, and my code david AT gibson.dropbear.id.au | minimalist, thank you. NOT _the_ _other_ | _way_ _around_! http://www.ozlabs.org/~dgibson