Re: [PATCH v3] Add limited read-only support for older (V2 and V3) device tree to libfdt.

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]





On 01/21/18 01:40, David Gibson wrote:
On Fri, Jan 19, 2018 at 09:48:03PM +0000, nwhitehorn@xxxxxxxxxxx wrote:
From: Nathan Whitehorn <nwhitehorn@xxxxxxxxxxx>

This can be useful in particular in the kernel when booting on systems
with FDT-emitting firmware that is out of date. Releases of kexec-tools
on ppc64 prior to the end of 2014 are notable examples of such.

Signed-off-by: Nathan Whitehorn <nwhitehorn@xxxxxxxxxxx>
---

This version of the patch fixes a number of style issues and removes some
unnecessary redundant code noted in review.
As suggested, please implement the change to use
fdt_get_property_namelen_() in fdt_getprop_namelen().  Plus I spotted
one other bug..

The reason for the duplication was that fdt_getprop_namelen() needs to know the offset of the property as well as its contents to decide whether it needs to realign the property data to 8-byte boundaries. That's pretty easily fixed by adding a final argument to fdt_get_property_namelen_() to return the offset. Is there a better way to get the offset from an fdt_property than that?

[snip]
+	if (fdt_version(fdt) < 0x10) {
+		/*
+		 * For old FDT versions, match the naming conventions of V16:
+		 * give only the leaf name (after all /). The actual tree
+		 * contents are loosely checked.
+		 */
+		const char *leaf;
+		leaf = strrchr(nameptr, '/');
+		if (leaf == NULL) {
+			err = FDT_ERR_BADVALUE;
The error codes are defined positive, but used negative, so this needs
to be err = -FDT_ERR_BADVAULE,  Except, actually, I think BADSTRUCTURE
would be a better option.

Whoops! Thanks for catching. I have a revised patch that I will send tonight after testing.
-Nathan
--
To unsubscribe from this list: send the line "unsubscribe devicetree-compiler" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html



[Index of Archives]     [Device Tree]     [Device Tree Spec]     [Linux Driver Backports]     [Video for Linux]     [Linux USB Devel]     [Linux Audio Users]     [Linux Kernel]     [Linux SCSI]     [Yosemite Backpacking]

  Powered by Linux