From patchwork Mon Jul 17 04:08:32 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Masahiro Yamada X-Patchwork-Id: 107866 Delivered-To: patch@linaro.org Received: by 10.140.101.44 with SMTP id t41csp4045694qge; Sun, 16 Jul 2017 21:09:23 -0700 (PDT) X-Received: by 10.80.165.104 with SMTP id z37mr15978748edb.60.1500264563877; Sun, 16 Jul 2017 21:09:23 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1500264563; cv=none; d=google.com; s=arc-20160816; b=f8O6gvdB4qybF99pSpE/w0x/x7obfnVDHjRg7R4nWZi1Iilo5cEdoYqoTK8uw8SA5C 1e9/lsjSewfBdJkLEcA0yZHhQZKAQzpBDJ3TuGQa2ud9XNV1EjBjJCTRC+jHtMLNZ+og pkLM2SRHI6/LMVcjCd8eOtHT7/PtK0HQ64yKl2nAjpber48KPtw5NK86cQAcKfpdUeoA H6kawiuU/aWgrLVpv5aJckCLY8Q0ixV4pJ1KeUzxORhTie7KbpMMs2tSMOmFIR8HstSv X4daakLiTrPAUp6vyXMnsOKiQiC1RL+RbBXKtyNWzlvhTRvfpkyESSUXh3HA0U8sCqtS iq3g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:content-transfer-encoding:mime-version :list-subscribe:list-help:list-post:list-archive:list-unsubscribe :list-id:precedence:subject:cc:references:in-reply-to:message-id :date:to:from:dkim-signature:dkim-filter:arc-authentication-results; bh=sKxrU0wbF7fCJcOuMZa5tPqmnC2Csfdm/FirdGYaMws=; b=v0USlzCUYrLSfSG6uaLgGHh46T9O0HiE9zbIAKtoEAjei1B/2fCVprfWKDANztja72 tTjSOZhdWwjRzqeK7hkJCtT6DOWQRYihvba2rRgfw9p8Ui/X+F6/+Lbi4XIBI/miqgDT 6+J2vUQifEahQhDAPG5aexEwnQl7xqm+afBjEFsTW2tp5qFRJCWqAaa274BlzW56RM3s KE0aQ2CIww2XGoUDoKXNf0Lna0YItUNHuyP0KP3LsNyOh6t/BJbxyuMDKfE0Zd7sKetQ ajCMamypnNmN9a2QA2VRzT7ZpWrBvZy5B3g5YTZu7nKG30URKWLxgz2smdjcxF8+zK2u yz2A== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@nifty.com header.b=p+O4O84l; spf=pass (google.com: best guess record for domain of u-boot-bounces@lists.denx.de designates 81.169.180.215 as permitted sender) smtp.mailfrom=u-boot-bounces@lists.denx.de Return-Path: Received: from lists.denx.de (dione.denx.de. [81.169.180.215]) by mx.google.com with ESMTP id a53si13292546edc.280.2017.07.16.21.09.23; Sun, 16 Jul 2017 21:09:23 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of u-boot-bounces@lists.denx.de designates 81.169.180.215 as permitted sender) client-ip=81.169.180.215; Authentication-Results: mx.google.com; dkim=neutral (body hash did not verify) header.i=@nifty.com header.b=p+O4O84l; spf=pass (google.com: best guess record for domain of u-boot-bounces@lists.denx.de designates 81.169.180.215 as permitted sender) smtp.mailfrom=u-boot-bounces@lists.denx.de Received: by lists.denx.de (Postfix, from userid 105) id 66FFCC21DBC; Mon, 17 Jul 2017 04:09:21 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on lists.denx.de X-Spam-Level: X-Spam-Status: No, score=0.0 required=5.0 tests=T_DKIM_INVALID autolearn=unavailable autolearn_force=no version=3.4.0 Received: from lists.denx.de (localhost [IPv6:::1]) by lists.denx.de (Postfix) with ESMTP id C4675C21C39; Mon, 17 Jul 2017 04:09:19 +0000 (UTC) Received: by lists.denx.de (Postfix, from userid 105) id 8476EC21C4C; Mon, 17 Jul 2017 04:09:17 +0000 (UTC) Received: from conuserg-08.nifty.com (conuserg-08.nifty.com [210.131.2.75]) by lists.denx.de (Postfix) with ESMTPS id A1A19C21C39 for ; Mon, 17 Jul 2017 04:09:16 +0000 (UTC) Received: from grover.sesame (FL1-122-131-185-176.osk.mesh.ad.jp [122.131.185.176]) (authenticated) by conuserg-08.nifty.com with ESMTP id v6H48a6u030374; Mon, 17 Jul 2017 13:08:37 +0900 DKIM-Filter: OpenDKIM Filter v2.10.3 conuserg-08.nifty.com v6H48a6u030374 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nifty.com; s=dec2015msa; t=1500264517; bh=Y650+JJoabpYSHIa9Qk9Spokg18WhWUTg7dj2Lyr27Y=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=p+O4O84lPU8mF18sQLRTAYpF1LX+p4atyAS6OJ3GO5WRFGjlnDzs8z9eREvEwHQwk osGyd6bLdoMT2Kmm020u/njQ7mQiT8H4yXUqb3+yC7ck4T+YWVDOB8Rpsa60Hai5aF EJwNXPcpwsg1Y3dBdhRtWoibaoZxMZVaqyYcka6kAP/PiK6kcWkvPrBCtwI9d843OH GvZKvJBQEiYPcsL1qgx/gbwgb0x+F9Ev/Q9x5uMsj2mLvo8rhwP7I++EiHC3vkC0Qj rRQv97f1eS8meeKTpXVwlbDzZIYwCj4DubU2P0UcxwdAWIEqnjc920qI6Ray0XTr5B Bac2ilyeaolQQ== X-Nifty-SrcIP: [122.131.185.176] From: Masahiro Yamada To: u-boot@lists.denx.de Date: Mon, 17 Jul 2017 13:08:32 +0900 Message-Id: <1500264512-30507-2-git-send-email-yamada.masahiro@socionext.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1500264512-30507-1-git-send-email-yamada.masahiro@socionext.com> References: <1500264512-30507-1-git-send-email-yamada.masahiro@socionext.com> Cc: Stephen Warren , Jan Kiszka , "Andreas J. Reichel" , Jagan Teki , Chris Packham Subject: [U-Boot] [PATCH 2/2] console: simplify puts() X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.18 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" Current puts() and putc() have similar #ifdef / if() conditionals. Make puts() iterate over putc() to avoid code duplication. Signed-off-by: Masahiro Yamada Reviewed-by: Simon Glass --- common/console.c | 44 ++------------------------------------------ 1 file changed, 2 insertions(+), 42 deletions(-) diff --git a/common/console.c b/common/console.c index c6156f33bbbe..01eef5594fcb 100644 --- a/common/console.c +++ b/common/console.c @@ -426,12 +426,6 @@ static void pre_console_putc(const char c) unmap_sysmem(buffer); } -static void pre_console_puts(const char *s) -{ - while (*s) - pre_console_putc(*s++); -} - static void print_pre_console_buffer(int flushpoint) { unsigned long in = 0, out = 0; @@ -459,7 +453,6 @@ static void print_pre_console_buffer(int flushpoint) } #else static inline void pre_console_putc(const char c) {} -static inline void pre_console_puts(const char *s) {} static inline void print_pre_console_buffer(int flushpoint) {} #endif @@ -501,41 +494,8 @@ void putc(const char c) void puts(const char *s) { -#ifdef CONFIG_DEBUG_UART - if (!gd || !(gd->flags & GD_FLG_SERIAL_READY)) { - while (*s) { - int ch = *s++; - - printch(ch); - } - return; - } -#endif -#ifdef CONFIG_CONSOLE_RECORD - if (gd && (gd->flags & GD_FLG_RECORD) && gd->console_out.start) - membuff_put(&gd->console_out, s, strlen(s)); -#endif -#ifdef CONFIG_SILENT_CONSOLE - if (gd->flags & GD_FLG_SILENT) - return; -#endif - -#ifdef CONFIG_DISABLE_CONSOLE - if (gd->flags & GD_FLG_DISABLE_CONSOLE) - return; -#endif - - if (!gd->have_console) - return pre_console_puts(s); - - if (gd->flags & GD_FLG_DEVINIT) { - /* Send to the standard output */ - fputs(stdout, s); - } else { - /* Send directly to the handler */ - pre_console_puts(s); - serial_puts(s); - } + while (*s) + putc(*s++); } #ifdef CONFIG_CONSOLE_RECORD