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 9C2B9C433FE for ; Mon, 17 Oct 2022 20:32:41 +0000 (UTC) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 7BF6984F75; Mon, 17 Oct 2022 22:30:57 +0200 (CEST) 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="VtpKDFKz"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 0AE7A84F97; Mon, 17 Oct 2022 22:30:38 +0200 (CEST) Received: from mail-il1-x131.google.com (mail-il1-x131.google.com [IPv6:2607:f8b0:4864:20::131]) (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 9A94884E8C for ; Mon, 17 Oct 2022 22:30:20 +0200 (CEST) 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-il1-x131.google.com with SMTP id u2so6451350ilv.6 for ; Mon, 17 Oct 2022 13:30:20 -0700 (PDT) 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=kf82OD8MXSzbxiYwz8LvzVpGtbhZioEXTz9W4SdenU0=; b=VtpKDFKzrfr+eazBwN5VGE5EZzzobfBvBwmxq9bGrRuEz51Py79/FXU4SgKkLgBYz+ VsDIJsz+OtiaKAKXDhnKT978e6DIwSJe5sdp9prChiBNTpxq6SYezbWKMJZ8Tt4o4AUd YsK6yVErT7W0JrTCFGj03vUhCuwO6DxgtFq98= 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=kf82OD8MXSzbxiYwz8LvzVpGtbhZioEXTz9W4SdenU0=; b=0NU1icwEzEv3JPKh13kLKiNmnwOPSUseFp5CBb0dghejs+AsSmKbvTMeJCWh8kOFGb iogKmD/TphqXRIj9L9j+hpUhpLtduAoEJWeigoOjM6pJOuxubyTOlkdUrN/AvAoD4Cjh cMOB43bENZsoJISqzjdkB5x6haC9pqFE7b5ytmKe9UyEqZvFIWjQOmoJA1FCjsjXwbrm e6cAODk2GZpzq+bhKrHwYo6nZ9Xt0n2jyP5H2PrmtBFX2sZR3FFKXvv//sekWEMURXDG n/CRJI6CUkw3WFAg8qXtoFmyE6tqpMaTIMtu04ClsQI11+qvVLTf6M/H5pzgZK1eUWQY rEiA== X-Gm-Message-State: ACrzQf2k8tzDMA1jjC5CMhrJaHDTzfLRjtIgda0oyyAOBD8IpplTf+Uu KGcW1svOfFf3jlVxI96EFHO3k2VPl7/VAg== X-Google-Smtp-Source: AMsMyM4nW6VGA1FN4p68TNCcGjEaRmt+7YG+Bzx6q5xUCytTLZtVR8wCQS6hVPm1EzfK+ivAiZdBMA== X-Received: by 2002:a05:6e02:1748:b0:2fa:44c9:aba0 with SMTP id y8-20020a056e02174800b002fa44c9aba0mr5743078ill.57.1666038618530; Mon, 17 Oct 2022 13:30:18 -0700 (PDT) Received: from kea.bld.corp.google.com ([2620:15c:183:200:91e:7804:2764:d161]) by smtp.gmail.com with ESMTPSA id j9-20020a926e09000000b002e939413e83sm258071ilc.48.2022.10.17.13.30.17 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 17 Oct 2022 13:30:18 -0700 (PDT) From: Simon Glass To: u-boot@lists.denx.de Cc: Anatolij Gustschin , Tom Rini , Simon Glass , Heinrich Schuchardt , Ilias Apalodimas , Masahisa Kojima Subject: [PATCH 05/24] menu: Update bootmenu_autoboot_loop() to return the code Date: Mon, 17 Oct 2022 14:29:41 -0600 Message-Id: <20221017203000.2207887-6-sjg@chromium.org> X-Mailer: git-send-email 2.38.0.413.g74048e4d9e-goog In-Reply-To: <20221017203000.2207887-1-sjg@chromium.org> References: <20221017203000.2207887-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 --- 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 087e4c246e2..bccc104a39b 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.38.0.413.g74048e4d9e-goog