[PATCH 27/67] upl: Init serial and graphics alists in upl_init()

Simon Glass sjg at chromium.org
Wed Jan 1 23:09:13 CET 2025


It is better and simpler to do this at the start, so that an uninited
data structure doesn't cause problems. Update upl_init() to set up the
remaining two alists and remove this from the reading/test code.

Signed-off-by: Simon Glass <sjg at chromium.org>
---

 boot/upl_common.c    | 2 ++
 common/spl/spl_upl.c | 2 --
 test/boot/upl.c      | 2 --
 3 files changed, 2 insertions(+), 4 deletions(-)

diff --git a/boot/upl_common.c b/boot/upl_common.c
index 3924423abd5..69a6673a9bf 100644
--- a/boot/upl_common.c
+++ b/boot/upl_common.c
@@ -57,4 +57,6 @@ void upl_init(struct upl *upl)
 	alist_init_struct(&upl->mem, struct upl_mem);
 	alist_init_struct(&upl->memmap, struct upl_memmap);
 	alist_init_struct(&upl->memres, struct upl_memres);
+	alist_init_struct(&upl->serial.reg, struct memregion);
+	alist_init_struct(&upl->graphics.reg, struct memregion);
 }
diff --git a/common/spl/spl_upl.c b/common/spl/spl_upl.c
index 067d437150f..81a106570b8 100644
--- a/common/spl/spl_upl.c
+++ b/common/spl/spl_upl.c
@@ -75,7 +75,6 @@ static int write_serial(struct upl_serial *ser)
 	ser->current_speed = gd->baudrate;
 	region.base = info.addr;
 	region.size = info.size;
-	alist_init_struct(&ser->reg, struct memregion);
 	if (!alist_add(&ser->reg, region))
 		return -ENOMEM;
 	ser->reg_io_shift = info.reg_shift;
@@ -94,7 +93,6 @@ static int write_graphics(struct upl_graphics *gra)
 	struct memregion region;
 	struct udevice *dev;
 
-	alist_init_struct(&gra->reg, struct memregion);
 	uclass_find_first_device(UCLASS_VIDEO, &dev);
 	if (!dev || !device_active(dev))
 		return log_msg_ret("vid", -ENOENT);
diff --git a/test/boot/upl.c b/test/boot/upl.c
index c2b571e06c4..89201e445ff 100644
--- a/test/boot/upl.c
+++ b/test/boot/upl.c
@@ -136,7 +136,6 @@ int upl_get_test_data(struct unit_test_state *uts, struct upl *upl)
 	upl->serial.compatible = "ns16550a";
 	upl->serial.clock_frequency = 1843200;
 	upl->serial.current_speed = 115200;
-	alist_init_struct(&upl->serial.reg, struct memregion);
 	ut_assertok(add_region(uts, &upl->serial.reg, 0xf1de0000, 0x100));
 	upl->serial.reg_io_shift = 2;
 	upl->serial.reg_offset = 0x40;
@@ -144,7 +143,6 @@ int upl_get_test_data(struct unit_test_state *uts, struct upl *upl)
 	upl->serial.virtual_reg = 0x20000000;
 	upl->serial.access_type = UPLAT_MMIO;
 
-	alist_init_struct(&upl->graphics.reg, struct memregion);
 	ut_assertok(add_region(uts, &upl->graphics.reg, 0xd0000000, 0x10000000));
 	upl->graphics.width = 1280;
 	upl->graphics.height = 1280;
-- 
2.43.0



More information about the U-Boot mailing list