From 53e14e9c0c606f0684a3ddb09afebe4b5eb89926 Mon Sep 17 00:00:00 2001 From: "Kory Maincent (TI.com)" Date: Thu, 30 Oct 2025 17:45:05 +0100 Subject: [PATCH] board: sunxi: Convert extension support to UCLASS framework Migrate sunxi board extension detection from legacy implementation to the new UCLASS-based extension board framework. Signed-off-by: Kory Maincent (TI.com) --- arch/arm/mach-sunxi/Kconfig | 2 +- board/sunxi/chip.c | 26 ++++++++++++++------------ 2 files changed, 15 insertions(+), 13 deletions(-) diff --git a/arch/arm/mach-sunxi/Kconfig b/arch/arm/mach-sunxi/Kconfig index b04ec671696..f5696199516 100644 --- a/arch/arm/mach-sunxi/Kconfig +++ b/arch/arm/mach-sunxi/Kconfig @@ -1223,7 +1223,7 @@ config BLUETOOTH_DT_DEVICE_FIXUP config CHIP_DIP_SCAN bool "Enable DIPs detection for CHIP board" - select SUPPORT_EXTENSION_SCAN + select SUPPORT_DM_EXTENSION_SCAN select W1 select W1_GPIO select W1_EEPROM diff --git a/board/sunxi/chip.c b/board/sunxi/chip.c index 5e5ec0d1d89..b60a739df41 100644 --- a/board/sunxi/chip.c +++ b/board/sunxi/chip.c @@ -40,7 +40,8 @@ struct dip_w1_header { u8 data[16]; /* user data, per-dip specific */ } __packed; -int extension_board_scan(struct list_head *extension_list) +static int sunxi_extension_board_scan(struct udevice *udev, + struct alist *extension_list) { struct udevice *bus, *dev; int num_dip = 0; @@ -55,8 +56,8 @@ int extension_board_scan(struct list_head *extension_list) } for_each_w1_device(bus, &dev) { + struct extension dip = {0}; struct dip_w1_header w1_header; - struct extension *dip; u32 vid; u16 pid; @@ -82,18 +83,19 @@ int extension_board_scan(struct list_head *extension_list) w1_header.product_name, pid, w1_header.vendor_name, vid); - dip = calloc(1, sizeof(struct extension)); - if (!dip) { - printf("Error in memory allocation\n"); - return num_dip; - } - - snprintf(dip->overlay, sizeof(dip->overlay), "dip-%x-%x.dtbo", + snprintf(dip.overlay, sizeof(dip.overlay), "dip-%x-%x.dtbo", vid, pid); - strlcpy(dip->name, w1_header.product_name, sizeof(dip->name)); - strlcpy(dip->owner, w1_header.vendor_name, sizeof(dip->owner)); - list_add_tail(&dip->list, extension_list); + strlcpy(dip.name, w1_header.product_name, sizeof(dip.name)); + strlcpy(dip.owner, w1_header.vendor_name, sizeof(dip.owner)); + if (!alist_add(extension_list, dip)) + return -ENOMEM; num_dip++; } return num_dip; } + +U_BOOT_EXTENSION(dip, sunxi_extension_board_scan); + +U_BOOT_DRVINFO(dip) = { + .name = "dip", +}; -- 2.47.3