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 89A53C4708D for ; Fri, 6 Jan 2023 14:55:00 +0000 (UTC) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id D7A6285604; Fri, 6 Jan 2023 15:53:17 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=chromium.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=pass (1024-bit key; unprotected) header.d=chromium.org header.i=@chromium.org header.b="VUxd/btw"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 17152854C9; Fri, 6 Jan 2023 15:53:12 +0100 (CET) Received: from mail-io1-xd2b.google.com (mail-io1-xd2b.google.com [IPv6:2607:f8b0:4864:20::d2b]) (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 768A485601 for ; Fri, 6 Jan 2023 15:52:56 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=chromium.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=sjg@chromium.org Received: by mail-io1-xd2b.google.com with SMTP id i83so760430ioa.11 for ; Fri, 06 Jan 2023 06:52:56 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=GtDtGjd1skF7e6kPUaExrDl0abEU7VbyxzKEDhv7MQo=; b=VUxd/btwMUcNl4NKUTFltqemcWeVjYJwcqVof8b1SffdP4iFQjHOVBbuKLxhT0eDNg VzxTujnLt1nOBFN0IlZtWr2O77++5dK2N5HXsE1prr42I0HBf292jTGI5G7S2rDwxMyh gZN+vo26SxX8MVdxmOw7gMURKZ4PjwoUzxGls= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version: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=GtDtGjd1skF7e6kPUaExrDl0abEU7VbyxzKEDhv7MQo=; b=ftXhTBDT3pSkG1a49AlmiFP4wtMEBpraiFYcjyEMvVff7feXbzxRcpSKUDC+yrg9im 7IwkhMhxTnBwM+Ym26b+kSELpAJwqhXlIuxdfI3Wajt9vD7uPejz3z196caUCevfOlOb 9RGIwERiYqVpXx5osp5P0z4dFoJJupFeGsB4TZM9neN9ksNkzWg1DRz6Peo0zIySpGaK F1UrzZBZvvJr2GigO6SKFZqlbSgF/I5UQIHhfWyjreT+ISa68LOW/nlWNQ6YWSL44n4i 6hWFxn6BJINEtGAltN9ARUXQTG+/y1ueyeltvFQLpQvVjj8eMJk0Y0i4BsvNYpLC9mpd flbw== X-Gm-Message-State: AFqh2kqG6browwuC1MotEz7UefbCVlJGOxRiplGBNAnZJbRNwkAJ9ypP GaHS+mjkV89U2gACkWwUws3V4IwBFllA406YfgE= X-Google-Smtp-Source: AMrXdXvfrkU4b1GJm/ywUG4lRxu3yf3maz7qQES23eaFRqHaA5YXuoBeppTeFmd/hl3jCMVqIQlVXA== X-Received: by 2002:a5d:8414:0:b0:6e2:d84f:8905 with SMTP id i20-20020a5d8414000000b006e2d84f8905mr46206420ion.7.1673016774865; Fri, 06 Jan 2023 06:52:54 -0800 (PST) Received: from sjg1.lan (c-71-56-217-229.hsd1.co.comcast.net. [71.56.217.229]) by smtp.gmail.com with ESMTPSA id w20-20020a05663800d400b00375783003fcsm360273jao.136.2023.01.06.06.52.54 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 06 Jan 2023 06:52:54 -0800 (PST) From: Simon Glass To: U-Boot Mailing List Cc: Anatolij Gustschin , Tom Rini , Heinrich Schuchardt , Simon Glass Subject: [PATCH v3 05/25] menu: Update bootmenu_autoboot_loop() to return the code Date: Fri, 6 Jan 2023 08:52:23 -0600 Message-Id: <20230106145243.411626-6-sjg@chromium.org> X-Mailer: git-send-email 2.39.0.314.g84b9a713c41-goog In-Reply-To: <20230106145243.411626-1-sjg@chromium.org> References: <20230106145243.411626-1-sjg@chromium.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 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 Use the return value to save having to pass around a pointer. This also resolves any ambiguity about what *key contains when the function is called. Signed-off-by: Simon Glass --- (no changes since v1) cmd/bootmenu.c | 2 +- common/menu.c | 16 +++++++++------- include/menu.h | 7 +++---- 3 files changed, 13 insertions(+), 12 deletions(-) diff --git a/cmd/bootmenu.c b/cmd/bootmenu.c index c80004c54dc..0e22f504fe4 100644 --- a/cmd/bootmenu.c +++ b/cmd/bootmenu.c @@ -93,7 +93,7 @@ static char *bootmenu_choice_entry(void *data) while (1) { if (menu->delay >= 0) { /* Autoboot was not stopped */ - bootmenu_autoboot_loop(menu, &key, &esc); + key = bootmenu_autoboot_loop(menu, &esc); } else { /* Some key was pressed, so autoboot was stopped */ bootmenu_loop(menu, &key, &esc); diff --git a/common/menu.c b/common/menu.c index a245c5a9c6c..bafc8470d7d 100644 --- a/common/menu.c +++ b/common/menu.c @@ -425,9 +425,9 @@ int menu_destroy(struct menu *m) return 1; } -void bootmenu_autoboot_loop(struct bootmenu_data *menu, - enum bootmenu_key *key, int *esc) +enum bootmenu_key bootmenu_autoboot_loop(struct bootmenu_data *menu, int *esc) { + enum bootmenu_key key = BKEY_NONE; int i, c; while (menu->delay > 0) { @@ -446,16 +446,16 @@ void bootmenu_autoboot_loop(struct bootmenu_data *menu, switch (c) { case '\e': *esc = 1; - *key = BKEY_NONE; + key = BKEY_NONE; break; case '\r': - *key = BKEY_SELECT; + key = BKEY_SELECT; break; case 0x3: /* ^C */ - *key = BKEY_QUIT; + key = BKEY_QUIT; break; default: - *key = BKEY_NONE; + key = BKEY_NONE; break; } @@ -471,7 +471,9 @@ void bootmenu_autoboot_loop(struct bootmenu_data *menu, printf(ANSI_CURSOR_POSITION ANSI_CLEAR_LINE, menu->count + 5, 1); if (menu->delay == 0) - *key = BKEY_SELECT; + key = BKEY_SELECT; + + return key; } void bootmenu_loop(struct bootmenu_data *menu, diff --git a/include/menu.h b/include/menu.h index 29b457921e9..9f30a3c1acd 100644 --- a/include/menu.h +++ b/include/menu.h @@ -65,14 +65,13 @@ enum bootmenu_key { * indicating that the current option should be chosen. * * @menu: Menu being processed - * @key: Returns the code for the key the user pressed: + * @esc: Set to 1 if the escape key is pressed, otherwise not updated + * Returns: code for the key the user pressed: * enter: KEY_SELECT * Ctrl-C: KEY_QUIT * anything else: KEY_NONE - * @esc: Set to 1 if the escape key is pressed, otherwise not updated */ -void bootmenu_autoboot_loop(struct bootmenu_data *menu, - enum bootmenu_key *key, int *esc); +enum bootmenu_key bootmenu_autoboot_loop(struct bootmenu_data *menu, int *esc); /** * bootmenu_loop() - handle waiting for a keypress when autoboot is disabled -- 2.39.0.314.g84b9a713c41-goog