Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 24 May 2019 02:10:16 +0000 (UTC)
From:      Kyle Evans <kevans@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-vendor@freebsd.org
Subject:   svn commit: r348220 - vendor-sys/libfdt/dist
Message-ID:  <201905240210.x4O2AGLJ014733@repo.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: kevans
Date: Fri May 24 02:10:16 2019
New Revision: 348220
URL: https://svnweb.freebsd.org/changeset/base/348220

Log:
  Import libfdt from dtc 1.5.0

Modified:
  vendor-sys/libfdt/dist/Makefile.libfdt
  vendor-sys/libfdt/dist/fdt_addresses.c
  vendor-sys/libfdt/dist/libfdt.h

Modified: vendor-sys/libfdt/dist/Makefile.libfdt
==============================================================================
--- vendor-sys/libfdt/dist/Makefile.libfdt	Fri May 24 01:53:45 2019	(r348219)
+++ vendor-sys/libfdt/dist/Makefile.libfdt	Fri May 24 02:10:16 2019	(r348220)
@@ -9,3 +9,7 @@ LIBFDT_VERSION = version.lds
 LIBFDT_SRCS = fdt.c fdt_ro.c fdt_wip.c fdt_sw.c fdt_rw.c fdt_strerror.c fdt_empty_tree.c \
 	fdt_addresses.c fdt_overlay.c
 LIBFDT_OBJS = $(LIBFDT_SRCS:%.c=%.o)
+
+libfdt_clean:
+	@$(VECHO) CLEAN "(libfdt)"
+	rm -f $(STD_CLEANFILES:%=$(LIBFDT_dir)/%)

Modified: vendor-sys/libfdt/dist/fdt_addresses.c
==============================================================================
--- vendor-sys/libfdt/dist/fdt_addresses.c	Fri May 24 01:53:45 2019	(r348219)
+++ vendor-sys/libfdt/dist/fdt_addresses.c	Fri May 24 02:10:16 2019	(r348220)
@@ -64,7 +64,7 @@ static int fdt_cells(const void *fdt, int nodeoffset, 
 
 	c = fdt_getprop(fdt, nodeoffset, name, &len);
 	if (!c)
-		return 2;
+		return len;
 
 	if (len != sizeof(*c))
 		return -FDT_ERR_BADNCELLS;
@@ -78,10 +78,20 @@ static int fdt_cells(const void *fdt, int nodeoffset, 
 
 int fdt_address_cells(const void *fdt, int nodeoffset)
 {
-	return fdt_cells(fdt, nodeoffset, "#address-cells");
+	int val;
+
+	val = fdt_cells(fdt, nodeoffset, "#address-cells");
+	if (val == -FDT_ERR_NOTFOUND)
+		return 2;
+	return val;
 }
 
 int fdt_size_cells(const void *fdt, int nodeoffset)
 {
-	return fdt_cells(fdt, nodeoffset, "#size-cells");
+	int val;
+
+	val = fdt_cells(fdt, nodeoffset, "#size-cells");
+	if (val == -FDT_ERR_NOTFOUND)
+		return 1;
+	return val;
 }

Modified: vendor-sys/libfdt/dist/libfdt.h
==============================================================================
--- vendor-sys/libfdt/dist/libfdt.h	Fri May 24 01:53:45 2019	(r348219)
+++ vendor-sys/libfdt/dist/libfdt.h	Fri May 24 02:10:16 2019	(r348220)
@@ -163,18 +163,26 @@ uint32_t fdt_next_tag(const void *fdt, int offset, int
 
 static inline uint32_t fdt32_ld(const fdt32_t *p)
 {
-	fdt32_t v;
+	const uint8_t *bp = (const uint8_t *)p;
 
-	memcpy(&v, p, sizeof(v));
-	return fdt32_to_cpu(v);
+	return ((uint32_t)bp[0] << 24)
+		| ((uint32_t)bp[1] << 16)
+		| ((uint32_t)bp[2] << 8)
+		| bp[3];
 }
 
 static inline uint64_t fdt64_ld(const fdt64_t *p)
 {
-	fdt64_t v;
+	const uint8_t *bp = (const uint8_t *)p;
 
-	memcpy(&v, p, sizeof(v));
-	return fdt64_to_cpu(v);
+	return ((uint64_t)bp[0] << 56)
+		| ((uint64_t)bp[1] << 48)
+		| ((uint64_t)bp[2] << 40)
+		| ((uint64_t)bp[3] << 32)
+		| ((uint64_t)bp[4] << 24)
+		| ((uint64_t)bp[5] << 16)
+		| ((uint64_t)bp[6] << 8)
+		| bp[7];
 }
 
 /**********************************************************************/
@@ -219,7 +227,7 @@ int fdt_next_subnode(const void *fdt, int offset);
  *		...
  *	}
  *
- *	if ((node < 0) && (node != -FDT_ERR_NOT_FOUND)) {
+ *	if ((node < 0) && (node != -FDT_ERR_NOTFOUND)) {
  *		Error handling
  *	}
  *
@@ -558,7 +566,7 @@ int fdt_next_property_offset(const void *fdt, int offs
  *		...
  *	}
  *
- *	if ((property < 0) && (property != -FDT_ERR_NOT_FOUND)) {
+ *	if ((property < 0) && (property != -FDT_ERR_NOTFOUND)) {
  *		Error handling
  *	}
  *
@@ -661,7 +669,7 @@ static inline struct fdt_property *fdt_get_property_w(
 /**
  * fdt_getprop_by_offset - retrieve the value of a property at a given offset
  * @fdt: pointer to the device tree blob
- * @ffset: offset of the property to read
+ * @offset: offset of the property to read
  * @namep: pointer to a string variable (will be overwritten) or NULL
  * @lenp: pointer to an integer variable (will be overwritten) or NULL
  *
@@ -1145,7 +1153,7 @@ int fdt_address_cells(const void *fdt, int nodeoffset)
  *
  * returns:
  *	0 <= n < FDT_MAX_NCELLS, on success
- *      2, if the node has no #size-cells property
+ *      1, if the node has no #size-cells property
  *      -FDT_ERR_BADNCELLS, if the node has a badly formatted or invalid
  *		#size-cells property
  *	-FDT_ERR_BADMAGIC,



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201905240210.x4O2AGLJ014733>