tests/qtest: aspeed_smc: Introduce read_page_mem_fn for page read helpers
This to prepare for fast-read variants. No functional change. Reviewed-by: Bin Meng <bin.meng@processmission.com> Link: https://lore.kernel.org/qemu-devel/20260714124621.522948-2-clg@redhat.com Signed-off-by: Cédric Le Goater <clg@redhat.com>
Cédric Le Goater committed
Jul 14, 2026 at 14:46 UTC
7a79a76286262fa25dcdf7fe585e4a963e67ceed
1 file changed
+21
-8
tests/qtest/aspeed-smc-utils.c
+21
-8
@@ -186,6 +186,9 @@ static void read_page_mem(const AspeedSMCTestData *data, uint32_t addr,
186
}
187
}
188
189
+typedef void (*read_page_mem_fn)(const AspeedSMCTestData *data,
190
+ uint32_t addr, uint32_t *page);
191
+
192
static void write_page_mem(const AspeedSMCTestData *data, uint32_t addr,
193
uint32_t write_value)
194
{
@@ -327,9 +330,9 @@ void aspeed_smc_test_erase_all(const void *data)
330
flash_reset(test_data);
331
}
332
330
-void aspeed_smc_test_write_page(const void *data)
333
+static void test_write_page(const AspeedSMCTestData *test_data,
334
+ read_page_mem_fn reader)
335
{
332
- const AspeedSMCTestData *test_data = (const AspeedSMCTestData *)data;
336
uint32_t my_page_addr = test_data->page_addr;
337
uint32_t some_page_addr = my_page_addr + FLASH_PAGE_SIZE;
338
uint32_t page[FLASH_PAGE_SIZE / 4];
@@ -350,13 +353,13 @@ void aspeed_smc_test_write_page(const void *data)
353
spi_ctrl_stop_user(test_data);
354
355
/* Check what was written */
353
- read_page(test_data, my_page_addr, page);
356
+ reader(test_data, my_page_addr, page);
357
for (i = 0; i < FLASH_PAGE_SIZE / 4; i++) {
358
g_assert_cmphex(page[i], ==, my_page_addr + i * 4);
359
}
360
361
/* Check some other page. It should be full of 0xff */
359
- read_page(test_data, some_page_addr, page);
362
+ reader(test_data, some_page_addr, page);
363
for (i = 0; i < FLASH_PAGE_SIZE / 4; i++) {
364
g_assert_cmphex(page[i], ==, 0xffffffff);
365
}
@@ -364,9 +367,14 @@ void aspeed_smc_test_write_page(const void *data)
367
flash_reset(test_data);
368
}
369
367
-void aspeed_smc_test_read_page_mem(const void *data)
370
+void aspeed_smc_test_write_page(const void *data)
371
+{
372
+ test_write_page(data, read_page);
373
+}
374
+
375
+static void test_read_page_mem(const AspeedSMCTestData *test_data,
376
+ read_page_mem_fn reader)
377
{
369
- const AspeedSMCTestData *test_data = (const AspeedSMCTestData *)data;
378
uint32_t my_page_addr = test_data->page_addr;
379
uint32_t some_page_addr = my_page_addr + FLASH_PAGE_SIZE;
380
uint32_t page[FLASH_PAGE_SIZE / 4];
@@ -393,13 +401,13 @@ void aspeed_smc_test_read_page_mem(const void *data)
401
spi_conf_remove(test_data, 1 << (CONF_ENABLE_W0 + test_data->cs));
402
403
/* Check what was written */
396
- read_page_mem(test_data, my_page_addr, page);
404
+ reader(test_data, my_page_addr, page);
405
for (i = 0; i < FLASH_PAGE_SIZE / 4; i++) {
406
g_assert_cmphex(page[i], ==, my_page_addr + i * 4);
407
}
408
409
/* Check some other page. It should be full of 0xff */
402
- read_page_mem(test_data, some_page_addr, page);
410
+ reader(test_data, some_page_addr, page);
411
for (i = 0; i < FLASH_PAGE_SIZE / 4; i++) {
412
g_assert_cmphex(page[i], ==, 0xffffffff);
413
}
@@ -407,6 +415,11 @@ void aspeed_smc_test_read_page_mem(const void *data)
415
flash_reset(test_data);
416
}
417
418
+void aspeed_smc_test_read_page_mem(const void *data)
419
+{
420
+ test_read_page_mem(data, read_page_mem);
421
+}
422
+
423
void aspeed_smc_test_write_page_mem(const void *data)
424
{
425
const AspeedSMCTestData *test_data = (const AspeedSMCTestData *)data;