From patchwork Wed Nov 16 10:28:16 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Masahisa Kojima X-Patchwork-Id: 625086 Delivered-To: patch@linaro.org Received: by 2002:a17:522:c983:b0:460:3032:e3c4 with SMTP id kr3csp187058pvb; Wed, 16 Nov 2022 02:26:53 -0800 (PST) X-Google-Smtp-Source: AA0mqf7pnnOp6UE5MnuZD97o33WbaJUUxfzOtuUd+dE55b0/+N2VBbHEzRicSGC/CqnQAY5ICX8Y X-Received: by 2002:a17:906:b30d:b0:799:a731:b44d with SMTP id n13-20020a170906b30d00b00799a731b44dmr17133554ejz.405.1668594413152; Wed, 16 Nov 2022 02:26:53 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1668594413; cv=none; d=google.com; s=arc-20160816; b=bhpe5rH37dHyWhMIdDRGBHG/QS0m0QkFjnQop1A0Xx5c2Vy2h3RIRDZALeI4fdp8Ag CdL2T/ogD+NfjqCnPgujWFCysSkfeowLSTfr6yFgUHSL4YVPy1svoUcxqU+CP/xR7Vvb Ap/m0Fu1YCrbjThethi0OmSiRmLFbfgHb2MHaBZ60F00jXTUJG+PP2tfSkLDHcudisnO PovTXgY9qTVr+ZCXTPKwRLenhErtMgvprvGdMA9q83sY6+allKoJBuOTTMoIxHNYdPtg od2WytK+T2/GBeOjtOcEGDcE2Yr0ayf8P0wtc0qeb5j3sPZOsDXZtnRysgmXzDmA29sC l3yQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:references:in-reply-to :message-id:date:subject:cc:to:from:dkim-signature; bh=hR9bGrO+zYvfLdWABU8jdk1REtDhHq9ZaStcbcnoXgk=; b=qh1QJgBes43x/+9nmFOHiFPBYF3aYfD2H+sxX/yrW14H2C/rp9La8pQNm87FzST30H ad2MBSBj0f0hJyj8A9J+b45EaBtzTwqnHFn4MrszBGXR2w2A69BzfOWk0mQdbv4J2urY sycueR6W29kINjewPsbul1ELu+FOZ4rh491SNcBMURQFMRkvSRYGpYNNUDrsrOgePfMf M4hMiA2FVVSZqHRiDl7VICsihfxN6d+qrI4PPQMFNBv+rPHdAMygpT8yJXaoJvhEvpfE jm9ez2xX6Ie0pqznW23+bxFeja30OuXi7kgv9z9tKgYrA0d269gYulK24VQvlzD/0cRA qjiw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=oY3o2zAb; spf=pass (google.com: domain of u-boot-bounces@lists.denx.de designates 2a01:238:438b:c500:173d:9f52:ddab:ee01 as permitted sender) smtp.mailfrom=u-boot-bounces@lists.denx.de; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from phobos.denx.de (phobos.denx.de. [2a01:238:438b:c500:173d:9f52:ddab:ee01]) by mx.google.com with ESMTPS id oz43-20020a1709077dab00b007a96e504c7esi15662433ejc.753.2022.11.16.02.26.52 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 16 Nov 2022 02:26:53 -0800 (PST) Received-SPF: pass (google.com: domain of u-boot-bounces@lists.denx.de designates 2a01:238:438b:c500:173d:9f52:ddab:ee01 as permitted sender) client-ip=2a01:238:438b:c500:173d:9f52:ddab:ee01; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=oY3o2zAb; spf=pass (google.com: domain of u-boot-bounces@lists.denx.de designates 2a01:238:438b:c500:173d:9f52:ddab:ee01 as permitted sender) smtp.mailfrom=u-boot-bounces@lists.denx.de; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 06665851C1; Wed, 16 Nov 2022 11:26:45 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=pass (2048-bit key; unprotected) header.d=linaro.org header.i=@linaro.org header.b="oY3o2zAb"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id B8227851C9; Wed, 16 Nov 2022 11:26:43 +0100 (CET) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on phobos.denx.de X-Spam-Level: X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.2 Received: from mail-pj1-x102d.google.com (mail-pj1-x102d.google.com [IPv6:2607:f8b0:4864:20::102d]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id E92EE851B1 for ; Wed, 16 Nov 2022 11:26:39 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=masahisa.kojima@linaro.org Received: by mail-pj1-x102d.google.com with SMTP id v3-20020a17090ac90300b00218441ac0f6so3455505pjt.0 for ; Wed, 16 Nov 2022 02:26:39 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=references:in-reply-to:message-id:date:subject:cc:to:from:from:to :cc:subject:date:message-id:reply-to; bh=hR9bGrO+zYvfLdWABU8jdk1REtDhHq9ZaStcbcnoXgk=; b=oY3o2zAbRJI/Tl0z5iLuhS2rtsHfQbuqK6WaPQaxtfGfnvL7cUZdasiCOCwPidv2FU iQ6ehZH84wZjzYbEAryU/ygbFFSGjuyxUyVStuBNAGgCrmIfXRarVzJA2wVi3qxdSkfw j23N8taMnHgHYpH6wpymqubIilLIJ4VSXOncYSkvFKzCNLakEtydn+dUjCOrHsOMo/nc 18jIlOkESOuP11gQuPJO+b3xqf2y64vzDx07MrPHE+pRPKzwbrWS5fuoqY9D85CYoJjg bvskFPEscbPGdnKdqFU6R0yZVhQ7+C1S+PCtQk38HLfzl2LCu1jV5EXwJDtwbRWVxmqw lzqA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=references:in-reply-to:message-id:date:subject:cc:to:from :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=hR9bGrO+zYvfLdWABU8jdk1REtDhHq9ZaStcbcnoXgk=; b=KcpkVNb5DllwiV18aU5f1NlSatAK2+t0NxbsSWF1iSgnCSlGs84gLJ/HI9TMIS2GnA 4eL3CZNJCOAdP21Ld+t2wj2isc6Hy/1wGI90V+Sn6WcoCjJA917GOTnC7mYuV+GRpuMF zX/P879efcOccLknFPF/XK4uLV0Y+OCn0KlqUJaLupq1hRssJc9dSW6TCdVdZVDHhJna phAjxdH26XC8N0WJRFy+r7wL2JOzABW8pvKG5hulc5BTxA+3PamuEeg4B/9LNLYsVYHz 96lU2NODP0e+YKlUjCKGggXtWTUEoKBriUfOZNHWLCVxheGWO2oi5IIrfNV2874KjrJs DkyA== X-Gm-Message-State: ANoB5pmaoO2tYzKPZUP1mOv1od/bwdbiR73e0rl+6foYTcdjWmlAGAYW oXaDKmfhhM1ytyYlutkaRvcnI9NK/ppfJQ== X-Received: by 2002:a17:902:8a84:b0:188:5242:3b00 with SMTP id p4-20020a1709028a8400b0018852423b00mr8331483plo.68.1668594397884; Wed, 16 Nov 2022 02:26:37 -0800 (PST) Received: from localhost.localdomain ([240d:1a:cf7:5800:82fa:5bff:fe4b:26b1]) by smtp.gmail.com with ESMTPSA id h7-20020a170902f7c700b00186b945c0d1sm11763994plw.2.2022.11.16.02.26.35 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 16 Nov 2022 02:26:37 -0800 (PST) From: Masahisa Kojima To: u-boot@lists.denx.de Cc: Heinrich Schuchardt , Ilias Apalodimas , Simon Glass , Takahiro Akashi , Etienne Carriere , Masahisa Kojima Subject: [PATCH v9 1/5] eficonfig: refactor file selection handling Date: Wed, 16 Nov 2022 19:28:16 +0900 Message-Id: <20221116102820.21021-2-masahisa.kojima@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20221116102820.21021-1-masahisa.kojima@linaro.org> References: <20221116102820.21021-1-masahisa.kojima@linaro.org> X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.39 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" X-Virus-Scanned: clamav-milter 0.103.6 at phobos.denx.de X-Virus-Status: Clean eficonfig_select_file_handler() is commonly used to select the file. eficonfig_display_select_file_option() adds an additional menu to clear the selected file. eficonfig_display_select_file_option() is not always necessary for the file selection process, so it must be outside of eficonfig_select_file_handler(). This commit also renames the following functions to avoid confusion. eficonfig_select_file_handler() -> eficonfig_process_select_file() eficonfig_select_file() -> eficonfig_show_file_selection() eficonfig_display_select_file_option() -> eficonfig_process_show_file_option() Finally, test_eficonfig.py need to be updated to get aligned with the above modification. Signed-off-by: Masahisa Kojima Reviewed-by: Ilias Apalodimas --- No update since v7 Changes in v7: - rename functio name to avoid confusion - remove unused function - update commit message newly created in v2 cmd/eficonfig.c | 37 ++++++------------- include/efi_config.h | 2 +- .../py/tests/test_eficonfig/test_eficonfig.py | 1 + 3 files changed, 13 insertions(+), 27 deletions(-) diff --git a/cmd/eficonfig.c b/cmd/eficonfig.c index 2595dd9563..571e2b9ac0 100644 --- a/cmd/eficonfig.c +++ b/cmd/eficonfig.c @@ -756,14 +756,14 @@ out: } /** - * eficonfig_select_file() - construct the file selection menu + * eficonfig_show_file_selection() - construct the file selection menu * * @file_info: pointer to the file selection structure * @root: pointer to the file handle * Return: status code */ -static efi_status_t eficonfig_select_file(struct eficonfig_select_file_info *file_info, - struct efi_file_handle *root) +static efi_status_t eficonfig_show_file_selection(struct eficonfig_select_file_info *file_info, + struct efi_file_handle *root) { u32 count = 0, i; efi_uintn_t len; @@ -938,17 +938,6 @@ static efi_status_t eficonfig_boot_edit_save(void *data) return EFI_SUCCESS; } -/** - * eficonfig_process_select_file() - callback function for "Select File" entry - * - * @data: pointer to the data - * Return: status code - */ -efi_status_t eficonfig_process_select_file(void *data) -{ - return EFI_SUCCESS; -} - /** * eficonfig_process_clear_file_selection() - callback function for "Clear" entry * @@ -973,19 +962,19 @@ static struct eficonfig_item select_file_menu_items[] = { {"Quit", eficonfig_process_quit}, }; - /** - * eficonfig_display_select_file_option() - display select file option + * eficonfig_process_show_file_option() - display select file option * * @file_info: pointer to the file information structure * Return: status code */ -efi_status_t eficonfig_display_select_file_option(struct eficonfig_select_file_info *file_info) +efi_status_t eficonfig_process_show_file_option(void *data) { efi_status_t ret; struct efimenu *efi_menu; - select_file_menu_items[1].data = file_info; + select_file_menu_items[0].data = data; + select_file_menu_items[1].data = data; efi_menu = eficonfig_create_fixed_menu(select_file_menu_items, ARRAY_SIZE(select_file_menu_items)); if (!efi_menu) @@ -1001,12 +990,12 @@ efi_status_t eficonfig_display_select_file_option(struct eficonfig_select_file_i } /** - * eficonfig_select_file_handler() - handle user file selection + * eficonfig_process_select_file() - handle user file selection * * @data: pointer to the data * Return: status code */ -efi_status_t eficonfig_select_file_handler(void *data) +efi_status_t eficonfig_process_select_file(void *data) { size_t len; efi_status_t ret; @@ -1016,10 +1005,6 @@ efi_status_t eficonfig_select_file_handler(void *data) struct eficonfig_select_file_info *tmp = NULL; struct eficonfig_select_file_info *file_info = data; - ret = eficonfig_display_select_file_option(file_info); - if (ret != EFI_SUCCESS) - return ret; - tmp = calloc(1, sizeof(struct eficonfig_select_file_info)); if (!tmp) return EFI_OUT_OF_RESOURCES; @@ -1046,7 +1031,7 @@ efi_status_t eficonfig_select_file_handler(void *data) if (ret != EFI_SUCCESS) goto out; - ret = eficonfig_select_file(tmp, root); + ret = eficonfig_show_file_selection(tmp, root); if (ret == EFI_ABORTED) continue; if (ret != EFI_SUCCESS) @@ -1284,7 +1269,7 @@ static efi_status_t prepare_file_selection_entry(struct efimenu *efi_menu, char utf8_utf16_strcpy(&p, devname); u16_strlcat(file_name, file_info->current_path, len); ret = create_boot_option_entry(efi_menu, title, file_name, - eficonfig_select_file_handler, file_info); + eficonfig_process_show_file_option, file_info); out: free(devname); free(file_name); diff --git a/include/efi_config.h b/include/efi_config.h index 098cac2115..cc6aa51393 100644 --- a/include/efi_config.h +++ b/include/efi_config.h @@ -89,7 +89,7 @@ void eficonfig_print_msg(char *msg); void eficonfig_destroy(struct efimenu *efi_menu); efi_status_t eficonfig_process_quit(void *data); efi_status_t eficonfig_process_common(struct efimenu *efi_menu, char *menu_header); -efi_status_t eficonfig_select_file_handler(void *data); +efi_status_t eficonfig_process_select_file(void *data); efi_status_t eficonfig_get_unused_bootoption(u16 *buf, efi_uintn_t buf_size, u32 *index); efi_status_t eficonfig_append_bootorder(u16 index); diff --git a/test/py/tests/test_eficonfig/test_eficonfig.py b/test/py/tests/test_eficonfig/test_eficonfig.py index 99606d9c4b..102bfd7541 100644 --- a/test/py/tests/test_eficonfig/test_eficonfig.py +++ b/test/py/tests/test_eficonfig/test_eficonfig.py @@ -349,6 +349,7 @@ def test_efi_eficonfig(u_boot_console, efi_eficonfig_data): press_up_down_enter_and_wait(0, 1, True, 'Quit') press_up_down_enter_and_wait(0, 0, True, 'No block device found!') press_escape_key(False) + press_escape_key(False) check_current_is_maintenance_menu() # Return to U-Boot console press_escape_key(True)