[PATCH v2 5/6] pbl: compressed-dtb: use flexible array member to access data

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

 



While data = compressed_dtb + 1 has the equivalent effect of skipping
over the struct barebox_boarddata_compressed_dtb header, using a
flexible array member aids code readability, so use that instead.

Signed-off-by: Ahmad Fatoum <a.fatoum@xxxxxxxxxxxxxx>
---
v1 -> v2:
  - new patch
---
 arch/arm/cpu/start.c     | 7 ++-----
 arch/riscv/boot/start.c  | 6 ++----
 include/compressed-dtb.h | 1 +
 3 files changed, 5 insertions(+), 9 deletions(-)

diff --git a/arch/arm/cpu/start.c b/arch/arm/cpu/start.c
index 14cc310312ab..755d48851956 100644
--- a/arch/arm/cpu/start.c
+++ b/arch/arm/cpu/start.c
@@ -52,7 +52,6 @@ u32 barebox_arm_machine(void)
 void *barebox_arm_boot_dtb(void)
 {
 	void *dtb;
-	void *data;
 	int ret;
 	struct barebox_boarddata_compressed_dtb *compressed_dtb;
 	static void *boot_dtb;
@@ -76,10 +75,8 @@ void *barebox_arm_boot_dtb(void)
 	if (!dtb)
 		return NULL;
 
-	data = compressed_dtb + 1;
-
-	ret = uncompress(data, compressed_dtb->datalen, NULL, NULL,
-			dtb, NULL, NULL);
+	ret = uncompress(compressed_dtb->data, compressed_dtb->datalen,
+			 NULL, NULL, dtb, NULL, NULL);
 	if (ret) {
 		pr_err("uncompressing dtb failed\n");
 		free(dtb);
diff --git a/arch/riscv/boot/start.c b/arch/riscv/boot/start.c
index 72ab93cb7691..8b4c8bb2f019 100644
--- a/arch/riscv/boot/start.c
+++ b/arch/riscv/boot/start.c
@@ -32,7 +32,6 @@ unsigned barebox_riscv_pbl_flags;
 void *barebox_riscv_boot_dtb(void)
 {
 	void *dtb;
-	void *data;
 	int ret;
 	struct barebox_boarddata_compressed_dtb *compressed_dtb;
 	static void *boot_dtb;
@@ -56,9 +55,8 @@ void *barebox_riscv_boot_dtb(void)
 	if (!dtb)
 		return NULL;
 
-	data = compressed_dtb + 1;
-
-	ret = uncompress(data, compressed_dtb->datalen, NULL, NULL, dtb, NULL, NULL);
+	ret = uncompress(compressed_dtb->data, compressed_dtb->datalen,
+			 NULL, NULL, dtb, NULL, NULL);
 	if (ret) {
 		pr_err("uncompressing dtb failed\n");
 		free(dtb);
diff --git a/include/compressed-dtb.h b/include/compressed-dtb.h
index 1ba98a7e2b92..3359d1ee115d 100644
--- a/include/compressed-dtb.h
+++ b/include/compressed-dtb.h
@@ -10,6 +10,7 @@ struct barebox_boarddata_compressed_dtb {
 	u32 magic;
 	u32 datalen;
 	u32 datalen_uncompressed;
+	u8 data[];
 };
 
 static inline bool blob_is_compressed_fdt(const void *blob)
-- 
2.30.2





[Index of Archives]     [Linux Embedded]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]     [XFree86]

  Powered by Linux