From patchwork Wed Jul 29 01:41:11 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 1338095 X-Patchwork-Delegate: trini@ti.com Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.denx.de (client-ip=85.214.62.61; helo=phobos.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=) Authentication-Results: ozlabs.org; dmarc=pass (p=none dis=none) header.from=chromium.org Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=chromium.org header.i=@chromium.org header.a=rsa-sha256 header.s=google header.b=WZAo8KCv; dkim-atps=neutral Received: from phobos.denx.de (phobos.denx.de [85.214.62.61]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 4BGbqz1mRgz9sRK for ; Wed, 29 Jul 2020 11:41:51 +1000 (AEST) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 0645F824D1; Wed, 29 Jul 2020 03:41:36 +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="WZAo8KCv"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 3FF46824B6; Wed, 29 Jul 2020 03:41:25 +0200 (CEST) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on phobos.denx.de X-Spam-Level: X-Spam-Status: No, score=-2.0 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,SPF_HELO_NONE,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.2 Received: from mail-ot1-x342.google.com (mail-ot1-x342.google.com [IPv6:2607:f8b0:4864:20::342]) (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 0F0D782488 for ; Wed, 29 Jul 2020 03:41:21 +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-ot1-x342.google.com with SMTP id w17so16392533otl.4 for ; Tue, 28 Jul 2020 18:41:21 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=JyVMiVml4Bpd9nXtnVEVx8+WBHXJug5uIV5f2bzcj+8=; b=WZAo8KCvGIyYoHeId+cQyh3Toz1ITV+ebbHbXIUb9kNJfoN3c56eLKEQsBXS3PQW8Y C7LBf3MuWYOlFGIuBbXiQosLykZW9Hgu54jp2mUsJglyK180XnFZffk/dZopDsVY9Jss +itmUTXg17VSJHRtZheZmXOrdLCGqNr1lEZPk= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=JyVMiVml4Bpd9nXtnVEVx8+WBHXJug5uIV5f2bzcj+8=; b=ORz4rES2Yu9OWqp0mMSJuHT78bRR7/b/FMzNDT1F4efxnR4RmbN0CGJ6306HBnv2U3 bmU5bm7EqFU5ZNbBQHX+pDKqycOSSGs50M37mhTp7spQ7efnkMbMMiSFsfXcz3VervEh l9QViLbv1+fUJEJ03OPplWNVSVR/Tb111c1iVJ0aHG7t817jbbKKsr2aWrVul/sSw1gD gsB28CzkdmprHjdq11S5HbCaMYUZhLu6Jk8oWy8bua9vfd4go/phL91EmmgX8pp+kD81 PuerI9sgwjtMH/GlJQbX3YenvzJMVV+tLBcfsHU8XXpF5hbD0kphA22AThXTgYJl5CYa kQJg== X-Gm-Message-State: AOAM533jzAA4xOawrcxsc8E500iZfBmFHJFoVvwTRvKhz0S4aYzJXtsN ya+Iq83IvzoWoBydideutDLKuevKFYCCeQ== X-Google-Smtp-Source: ABdhPJzFFL21jSgf0TLNPq7GqiHNg7ibKtRAE17C54HP8EE0fWV/tOZQI2PsCYygX9FexRyV8BGTfQ== X-Received: by 2002:a9d:4d83:: with SMTP id u3mr27077376otk.183.1595986879445; Tue, 28 Jul 2020 18:41:19 -0700 (PDT) Received: from localhost.localdomain (c-73-14-175-90.hsd1.co.comcast.net. [73.14.175.90]) by smtp.gmail.com with ESMTPSA id j35sm88029ota.23.2020.07.28.18.41.18 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 28 Jul 2020 18:41:19 -0700 (PDT) From: Simon Glass To: U-Boot Mailing List Cc: Tom Rini , Simon Glass Subject: [PATCH v2 2/5] console: Always define the console-recording functions Date: Tue, 28 Jul 2020 19:41:11 -0600 Message-Id: <20200729014114.1960556-2-sjg@chromium.org> X-Mailer: git-send-email 2.28.0.rc0.142.g3c755180ce-goog In-Reply-To: <20200729014114.1960556-1-sjg@chromium.org> References: <20200729014114.1960556-1-sjg@chromium.org> MIME-Version: 1.0 X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.34 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.102.3 at phobos.denx.de X-Virus-Status: Clean On boards without console recording these function are currently missing. It is more convenient for them to be present but to return dummy values. That way if we know that a test needs recording, we can check if it is available, and skip the test if not, while avoiding #ifdefs. Update the header file according and adjust console_record_reset_enable() to return an error if recording is not available. Signed-off-by: Simon Glass --- (no changes since v1) common/console.c | 4 +++- include/console.h | 40 +++++++++++++++++++++++++++++++++++++++- 2 files changed, 42 insertions(+), 2 deletions(-) diff --git a/common/console.c b/common/console.c index 07c483f820e..8e50af1f9d2 100644 --- a/common/console.c +++ b/common/console.c @@ -635,10 +635,12 @@ void console_record_reset(void) membuff_purge((struct membuff *)&gd->console_in); } -void console_record_reset_enable(void) +int console_record_reset_enable(void) { console_record_reset(); gd->flags |= GD_FLG_RECORD; + + return 0; } int console_record_readline(char *str, int maxlen) diff --git a/include/console.h b/include/console.h index 4c6b8f2614c..432f892b6cc 100644 --- a/include/console.h +++ b/include/console.h @@ -8,6 +8,7 @@ #define __CONSOLE_H #include +#include extern char console_buffer[]; @@ -21,11 +22,14 @@ void clear_ctrlc(void); /* clear the Control-C condition */ int disable_ctrlc(int); /* 1 to disable, 0 to enable Control-C detect */ int confirm_yesno(void); /* 1 if input is "y", "Y", "yes" or "YES" */ +#ifdef CONFIG_CONSOLE_RECORD /** * console_record_init() - set up the console recording buffers * * This should be called as soon as malloc() is available so that the maximum * amount of console output can be recorded. + * + * @return 0 if OK, -ENOMEM if out of memory */ int console_record_init(void); @@ -40,8 +44,10 @@ void console_record_reset(void); * console_record_reset_enable() - reset and enable the console buffers * * This should be called to enable the console buffer. + * + * @return 0 (always) */ -void console_record_reset_enable(void); +int console_record_reset_enable(void); /** * console_record_readline() - Read a line from the console output @@ -61,6 +67,38 @@ int console_record_readline(char *str, int maxlen); * @return available bytes (0 if empty) */ int console_record_avail(void); +#else +static inline int console_record_init(void) +{ + /* Always succeed, since it is not enabled */ + + return 0; +} + +static inline void console_record_reset(void) +{ + /* Nothing to do here */ +} + +static inline int console_record_reset_enable(void) +{ + /* Cannot enable it as it is not supported */ + return -ENOSYS; +} + +static inline int console_record_readline(char *str, int maxlen) +{ + /* Nothing to read */ + return 0; +} + +static inline int console_record_avail(void) +{ + /* There is never anything available */ + return 0; +} + +#endif /* !CONFIG_CONSOLE_RECORD */ /** * console_announce_r() - print a U-Boot console on non-serial consoles