Migrate CompuLab imx8mm-cl-iot-gate board extension detection from legacy implementation to the new UCLASS-based extension board framework.
Signed-off-by: Kory Maincent <[email protected]> --- arch/arm/mach-imx/imx8m/Kconfig | 4 +- .../imx8mm-cl-iot-gate/imx8mm-cl-iot-gate.c | 60 ++++++++++------------ 2 files changed, 30 insertions(+), 34 deletions(-) diff --git a/arch/arm/mach-imx/imx8m/Kconfig b/arch/arm/mach-imx/imx8m/Kconfig index e7bc154b805..5324eff3084 100644 --- a/arch/arm/mach-imx/imx8m/Kconfig +++ b/arch/arm/mach-imx/imx8m/Kconfig @@ -359,14 +359,14 @@ config TARGET_IMX8MM_CL_IOT_GATE select IMX8MM select SUPPORT_SPL select IMX8M_LPDDR4 - select SUPPORT_EXTENSION_SCAN + select SUPPORT_DM_EXTENSION_SCAN config TARGET_IMX8MM_CL_IOT_GATE_OPTEE bool "CompuLab iot-gate-imx8 with optee support" select IMX8MM select SUPPORT_SPL select IMX8M_LPDDR4 - select SUPPORT_EXTENSION_SCAN + select SUPPORT_DM_EXTENSION_SCAN config TARGET_IMX8MP_RSB3720A1_4G bool "Support i.MX8MP RSB3720A1 4G" diff --git a/board/compulab/imx8mm-cl-iot-gate/imx8mm-cl-iot-gate.c b/board/compulab/imx8mm-cl-iot-gate/imx8mm-cl-iot-gate.c index bda7aac5be4..4fc87944810 100644 --- a/board/compulab/imx8mm-cl-iot-gate/imx8mm-cl-iot-gate.c +++ b/board/compulab/imx8mm-cl-iot-gate/imx8mm-cl-iot-gate.c @@ -434,9 +434,9 @@ static int iot_gate_imx8_update_ext_ied(void) return 0; } -int extension_board_scan(struct list_head *extension_list) +static int iot_gate_imx8_extension_board_scan(struct list_head *extension_list) { - struct extension *extension = NULL; + struct extension extension = {0}, *_extension = NULL; int i; int ret = 0; @@ -446,25 +446,21 @@ int extension_board_scan(struct list_head *extension_list) case IOT_GATE_EXT_EMPTY: break; case IOT_GATE_EXT_CAN: - extension = calloc(1, sizeof(struct extension)); - snprintf(extension->name, sizeof(extension->name), + snprintf(extension.name, sizeof(extension.name), "IOT_GATE_EXT_CAN"); break; case IOT_GATE_EXT_IED: - extension = calloc(1, sizeof(struct extension)); - snprintf(extension->name, sizeof(extension->name), + snprintf(extension.name, sizeof(extension.name), "IOT_GATE_EXT_IED"); - snprintf(extension->overlay, sizeof(extension->overlay), + snprintf(extension.overlay, sizeof(extension.overlay), "imx8mm-cl-iot-gate-ied.dtbo"); break; case IOT_GATE_EXT_POE: - extension = calloc(1, sizeof(struct extension)); - snprintf(extension->name, sizeof(extension->name), + snprintf(extension.name, sizeof(extension.name), "IOT_GATE_EXT_POE"); break; case IOT_GATE_EXT_POEV2: - extension = calloc(1, sizeof(struct extension)); - snprintf(extension->name, sizeof(extension->name), + snprintf(extension.name, sizeof(extension.name), "IOT_GATE_EXT_POEV2"); break; default: @@ -473,9 +469,11 @@ int extension_board_scan(struct list_head *extension_list) } if (extension) { - snprintf(extension->owner, sizeof(extension->owner), + snprintf(extension.owner, sizeof(extension.owner), "Compulab"); - list_add_tail(&extension->list, extension_list); + _estension = alist_add(extension_list, extension); + if (!_extension) + return -ENOMEM; ret = 1; } else return ret; @@ -484,44 +482,38 @@ int extension_board_scan(struct list_head *extension_list) iot_gate_imx8_update_ext_ied(); for (i=0; i<ARRAY_SIZE(iot_gate_imx8_ext_ied_id); i++) { - extension = NULL; + memset(&extension, 0, sizeof(extension)); switch (iot_gate_imx8_ext_ied_id[i]) { case IOT_GATE_IMX8_CARD_ID_EMPTY: break; case IOT_GATE_IMX8_CARD_ID_RS_485: - extension = calloc(1, sizeof(struct extension)); - snprintf(extension->name, sizeof(extension->name), + snprintf(extension.name, sizeof(extension.name), "IOT_GATE_IMX8_CARD_ID_RS_485"); break; case IOT_GATE_IMX8_CARD_ID_RS_232: - extension = calloc(1, sizeof(struct extension)); - snprintf(extension->name, sizeof(extension->name), + snprintf(extension.name, sizeof(extension.name), "IOT_GATE_IMX8_CARD_ID_RS_232"); break; case IOT_GATE_IMX8_CARD_ID_CAN: - extension = calloc(1, sizeof(struct extension)); - snprintf(extension->name, sizeof(extension->name), + snprintf(extension.name, sizeof(extension.name), "IOT_GATE_IMX8_CARD_ID_CAN"); - snprintf(extension->overlay, sizeof(extension->overlay), + snprintf(extension.overlay, sizeof(extension.overlay), "imx8mm-cl-iot-gate-ied-can%d.dtbo", i); break; case IOT_GATE_IMX8_CARD_ID_TPM: - extension = calloc(1, sizeof(struct extension)); - snprintf(extension->name, sizeof(extension->name), + snprintf(extension.name, sizeof(extension.name), "IOT_GATE_IMX8_CARD_ID_TPM"); - snprintf(extension->overlay, sizeof(extension->overlay), + snprintf(extension.overlay, sizeof(extension.overlay), "imx8mm-cl-iot-gate-ied-tpm%d.dtbo", i); break; case IOT_GATE_IMX8_CARD_ID_CL420: - extension = calloc(1, sizeof(struct extension)); - snprintf(extension->name, sizeof(extension->name), + snprintf(extension.name, sizeof(extension.name), "IOT_GATE_IMX8_CARD_ID_CL420"); - snprintf(extension->overlay, sizeof(extension->overlay), + snprintf(extension.overlay, sizeof(extension.overlay), "imx8mm-cl-iot-gate-ied-can%d.dtbo", i); break; case IOT_GATE_IMX8_CARD_ID_DI4O4: - extension = calloc(1, sizeof(struct extension)); - snprintf(extension->name, sizeof(extension->name), + snprintf(extension.name, sizeof(extension.name), "IOT_GATE_IMX8_CARD_ID_DI4O4"); break; default: @@ -530,11 +522,13 @@ int extension_board_scan(struct list_head *extension_list) break; } if (extension) { - snprintf(extension->owner, sizeof(extension->owner), + snprintf(extension.owner, sizeof(extension.owner), "Compulab"); - snprintf(extension->other, sizeof(extension->other), + snprintf(extension.other, sizeof(extension.other), "On slot %d", i); - list_add_tail(&extension->list, extension_list); + _extension = alist_add(extension_list, extension); + if (!_extension) + return -ENOMEM; ret = ret + 1; } } @@ -542,6 +536,8 @@ int extension_board_scan(struct list_head *extension_list) return ret; } +U_BOOT_EXTENSION(iot_gate_imx8_extension, iot_gate_imx8_extension_board_scan); + static int setup_mac_address(void) { unsigned char enetaddr[6]; -- 2.43.0

