From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from phobos.denx.de (phobos.denx.de [85.214.62.61]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 9B94CC4167B for ; Tue, 27 Dec 2022 14:41:42 +0000 (UTC) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 1B729852F8; Tue, 27 Dec 2022 15:41:40 +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="XqH5cQCj"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 7A4D5852F0; Tue, 27 Dec 2022 15:41:38 +0100 (CET) Received: from mail-ed1-x535.google.com (mail-ed1-x535.google.com [IPv6:2a00:1450:4864:20::535]) (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 385FA85286 for ; Tue, 27 Dec 2022 15:41:36 +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=ilias.apalodimas@linaro.org Received: by mail-ed1-x535.google.com with SMTP id u28so14407038edd.10 for ; Tue, 27 Dec 2022 06:41:36 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:from:to:cc:subject:date:message-id:reply-to; bh=jWguV58gUNMeLnF/JNidzTkQDLtc/PoX9zBxOeMLcPs=; b=XqH5cQCjIjkrSkp5HixEtiquZBghmpPU9ySs/dX6PbE5F0vdlY/F3cyUEHV+ztq7sh RO+vO7fuA0v83N4EQ4cjFCbLgtAOYnaRHbCeitmx/lAK4mqLp5qDx7wSWSeTW7ujGu7X TvhMzKmuhCkf71+qaNzyRnJg4hIyi9X0QAknRhRoUVbsreh4KSn63GIzxIC9lFvFj9+K t9KNK88CoFGR1Q8gw4J+EiTQSGYmQQKt+QQBJ732Vs1NVELDusZgHtvh9VKOc/EaTgqH ox120PTAO1qpipvh842ng8UkWAtQ/nTx8nr9Ta8FqC/jV2HZ2JGLxAdtx+R2cYvqcyvT 2hDA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=jWguV58gUNMeLnF/JNidzTkQDLtc/PoX9zBxOeMLcPs=; b=NavUx3sP/guMBI8YAgypZU1zPFU28wqsk04faRfdVsJeFQQo5hfpHvyFuSW3FcL7bI 7lppXtkrdkQ9cIVpzy/y5sV3caG1S64Q4J4ezIE5gWWoM9NXfRu2jry3UCRPQQjPRxJv 683LpKhjdu5eSXOPC+SCox3fZQ3pff8JoXp1J3ER43zEzKfVdlsz/KkherdYnYkBfzoD IkBGZxeAeI/lQNs4Q43C5BII3Y9CkbhLe7HHm/EdnxHpr+lKxUansJvI+9yMo144EUvJ yG/G3v9eRht8Ddd9U3WuVJgA+vY4MOmhHp/7LGZJMOq1heOfCA3L+mRl3SykLHt7MAUh gNhw== X-Gm-Message-State: AFqh2kqhVfnjKe1zcI6CLy3eJi7TKs6B1jQSU/PQLjewERWVUquy0fOZ OAlB5fiXwp6gPnd2kZTDq35OcA== X-Google-Smtp-Source: AMrXdXvg+FLb+pfFTyS33ze13Mj4u1kvVvQr/dOT+AYoxOfXT+f1m4dJs3s4uwrCgmDAzrFVEPwUxA== X-Received: by 2002:aa7:d513:0:b0:462:9baa:7507 with SMTP id y19-20020aa7d513000000b004629baa7507mr18934255edq.8.1672152095738; Tue, 27 Dec 2022 06:41:35 -0800 (PST) Received: from hera (ppp079167090036.access.hol.gr. [79.167.90.36]) by smtp.gmail.com with ESMTPSA id u24-20020aa7d0d8000000b0046776f98d0csm5936108edo.79.2022.12.27.06.41.34 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 27 Dec 2022 06:41:35 -0800 (PST) Date: Tue, 27 Dec 2022 16:41:32 +0200 From: Ilias Apalodimas To: Masahisa Kojima Cc: u-boot@lists.denx.de, Heinrich Schuchardt Subject: Re: [PATCH v2 1/3] eficonfig: refactor eficonfig_process_common function Message-ID: References: <20221223225745.16985-1-masahisa.kojima@linaro.org> <20221223225745.16985-2-masahisa.kojima@linaro.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20221223225745.16985-2-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 Hi Kojima-san Overall I think the cleanup is nice and easier to maintain in the long run. On Sat, Dec 24, 2022 at 07:57:42AM +0900, Masahisa Kojima wrote: > Current change boot order implementation does not call > eficonfig_process_common() and call own menu functions > for display_statusline, item_data_print and item_choice. > Change boot order functionality should call > eficonfig_process_common() to improve maintenanceability. > > This commit is a preparation to remove the change boot > order specific implementation. The menu functions > (display_statusline, item_data_print and item_choice) are > added as argument of eficonfig_process_common(). > The menu description string displayed at the bottom of > the menu is also added as argument. > > Signed-off-by: Masahisa Kojima > --- > Changes in v2: > - add const qualifier to eficonfig_menu_desc, change it to pointer > > cmd/eficonfig.c | 69 +++++++++++++++++++++++++++++++++---------- > cmd/eficonfig_sbkey.c | 18 +++++++++-- > include/efi_config.h | 13 +++++++- > 3 files changed, 81 insertions(+), 19 deletions(-) > > diff --git a/cmd/eficonfig.c b/cmd/eficonfig.c > index ce7175a566..2fc486dac2 100644 > --- a/cmd/eficonfig.c > +++ b/cmd/eficonfig.c > @@ -21,6 +21,8 @@ > #include > > static struct efi_simple_text_input_protocol *cin; > +const char *eficonfig_menu_desc = > + " Press UP/DOWN to move, ENTER to select, ESC/CTRL+C to quit"; > > #define EFICONFIG_DESCRIPTION_MAX 32 > #define EFICONFIG_OPTIONAL_DATA_MAX 64 > @@ -133,7 +135,7 @@ void eficonfig_print_msg(char *msg) > * > * @data: pointer to the data associated with each menu entry > */ > -static void eficonfig_print_entry(void *data) > +void eficonfig_print_entry(void *data) > { > struct eficonfig_entry *entry = data; > int reverse = (entry->efi_menu->active == entry->num); > @@ -160,7 +162,7 @@ static void eficonfig_print_entry(void *data) > * > * @m: pointer to the menu structure > */ > -static void eficonfig_display_statusline(struct menu *m) > +void eficonfig_display_statusline(struct menu *m) > { > struct eficonfig_entry *entry; > > @@ -170,10 +172,11 @@ static void eficonfig_display_statusline(struct menu *m) > printf(ANSI_CURSOR_POSITION > "\n%s\n" > ANSI_CURSOR_POSITION ANSI_CLEAR_LINE ANSI_CURSOR_POSITION > - " Press UP/DOWN to move, ENTER to select, ESC/CTRL+C to quit" > + "%s" > ANSI_CLEAR_LINE_TO_END ANSI_CURSOR_POSITION ANSI_CLEAR_LINE, > 1, 1, entry->efi_menu->menu_header, entry->efi_menu->count + 5, 1, > - entry->efi_menu->count + 6, 1, entry->efi_menu->count + 7, 1); > + entry->efi_menu->count + 6, 1, entry->efi_menu->menu_desc, > + entry->efi_menu->count + 7, 1); > } > > /** > @@ -182,7 +185,7 @@ static void eficonfig_display_statusline(struct menu *m) > * @data: pointer to the efimenu structure > * Return: key string to identify the selected entry > */ > -static char *eficonfig_choice_entry(void *data) > +char *eficonfig_choice_entry(void *data) > { > int esc = 0; > struct list_head *pos, *n; > @@ -358,9 +361,17 @@ out: > * > * @efi_menu: pointer to the efimenu structure > * @menu_header: pointer to the menu header string > + * @menu_desc: pointer to the menu description > + * @display_statusline: function pointer to draw statusline > + * @item_data_print: function pointer to draw the menu item > + * @item_choice: function pointer to handle the key press > * Return: status code > */ > -efi_status_t eficonfig_process_common(struct efimenu *efi_menu, char *menu_header) > +efi_status_t eficonfig_process_common(struct efimenu *efi_menu, > + char *menu_header, const char *menu_desc, > + void (*display_statusline)(struct menu *), > + void (*item_data_print)(void *), > + char *(*item_choice)(void *)) > { > struct menu *menu; > void *choice = NULL; > @@ -379,10 +390,11 @@ efi_status_t eficonfig_process_common(struct efimenu *efi_menu, char *menu_heade > if (!efi_menu->menu_header) > return EFI_OUT_OF_RESOURCES; > } > + if (menu_desc) > + efi_menu->menu_desc = menu_desc; > > - menu = menu_create(NULL, 0, 1, eficonfig_display_statusline, > - eficonfig_print_entry, eficonfig_choice_entry, > - efi_menu); > + menu = menu_create(NULL, 0, 1, display_statusline, item_data_print, > + item_choice, efi_menu); menu_create doesn't check any pointers for item_data_print, item_choice, efi_menu Should we check any of these here? > if (!menu) > return EFI_INVALID_PARAMETER; [...] Regards /Ilias