Received: by 2002:a25:683:0:0:0:0:0 with SMTP id 125csp286976ybg; Wed, 3 Jun 2020 00:24:54 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzqrty6fA9opvGB5+hGTOaeEFqRmBY+LRlQZUiK9+FvD+YlqgkiKHgR4eQh1YeHqfkipQyj X-Received: by 2002:a05:6402:17ce:: with SMTP id s14mr13196439edy.53.1591169094095; Wed, 03 Jun 2020 00:24:54 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1591169094; cv=none; d=google.com; s=arc-20160816; b=t690aBtiOclmmCm5SQXp0IOyB+bGl7dJOaYnLQraXYtn+uTMP5C5xm/f0Vg+P205Pq OUJSUw50yQBqPh52QQUA/TIOVgBqvsemoHKUty3fArDf+kp9OsbhXCX/Ip0AHLrhCV30 RUyFb4bMnQbpU7Z2m1Gjn0LMskOQET18gZEjV/ui3/dD25ia0g6ZYbrsNfQHF2LHMjii pad26u23I73FtMnZIFmZKM7TlG+lvpZtm4aovDHn5HCRWHxVPgEeLFHSHrs3T/cUdiay nwqcNm7JdbQP7ffGTtTWgrXQ5Ocf9xGKhE/ief8ctUiwFhqJE7iiZtC0QO+UG/sAtmQc R/Rg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:dkim-signature; bh=nS87rNXwinnHDsGB1oC64mLmKOn8axqbhCBxaNZelVE=; b=sImwJN/Bbb7HbEZXv+vXsBDb4+XlALYKm6ISHSyoJLKWIOKMm48siig2Zqmuiz0WjI y7fnVROKBS7WaZByhsFBsqtj6YO96B3y9RT3IuQgLWzhwtwBney2UWTqOvWJVW7zqbHi 2qye/eJ8bDA51YIfy/EWz/lcjEWkILFA9IQKpxcjOkzVtmwMYdpPiZnmXswb2fZ5UaPI RJg4CBZAHevWBaDacqziOdUWsA3foAxISJfeZ9J+W6IEYt/OCKVZq64DBrnC4yoJ+wNX /ZHxWJmEQQMb6KqeXyItPJCluc9QUP7OHw3Hvkv01rXaqME/ZZn/gu3Gi905AVPEQI9I Jckg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b="bUg/amR6"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id q27si654413edb.205.2020.06.03.00.24.31; Wed, 03 Jun 2020 00:24:54 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b="bUg/amR6"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726042AbgFCHWn (ORCPT + 99 others); Wed, 3 Jun 2020 03:22:43 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46380 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725993AbgFCHWl (ORCPT ); Wed, 3 Jun 2020 03:22:41 -0400 Received: from mail-pg1-x541.google.com (mail-pg1-x541.google.com [IPv6:2607:f8b0:4864:20::541]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B29A2C05BD43 for ; Wed, 3 Jun 2020 00:22:40 -0700 (PDT) Received: by mail-pg1-x541.google.com with SMTP id e9so1134707pgo.9 for ; Wed, 03 Jun 2020 00:22:40 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=nS87rNXwinnHDsGB1oC64mLmKOn8axqbhCBxaNZelVE=; b=bUg/amR6dUGFEel35oo/78r5Yt5+WBc6ZWXun66sFPubpQg6pHyd3IcxzKPe139OrB 00IAwmsdkfpsic3xI7r7pVSqJ5zkop0ag9pKt1ZR98hL8SaiyFMZg+aunIdAlnYiAApH W8zgHMe/XNv1qlr3EzsOoA8NT7IPxKbsanzhFVkj1nWuycfvcQAUvRJSpwVUTj+XGdRd YaoBvmPoQhRcVi6IHElQXrazKZa/2YztF9rM2FA6ea+BET5gHz+tT216iVm7aWut4+PE xBXtZhTgy9xaPCsrvfLsBd1PZocQI1357oPPjGgaoMJKZCXMhNgsYMzhiHkVYrqNjdb4 nOKQ== 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; bh=nS87rNXwinnHDsGB1oC64mLmKOn8axqbhCBxaNZelVE=; b=I9+sl3ieayBSZmNX1A75H1TpMfyTPESdxmaNXn4yrlySKEM7b0ZWahB50VV+FkJr7i wo3XI9GlF7vY9Ie96ShPeaDdKKX8dCk5PYkSFBfYsArCDxAHdPsFGMXV0mBga92SOEN4 Sur78bQ49ZnapchOkfAxMdrZ6aVsUwmTdfkotI0oZ8vVw89uSfUJJDn9HsHrPB03g3YL lkuTEEPKb6YvZzjoKBHgWLuhwN5Ocd6CnESBTjVYb5IJrcH19YwNABooeN5lvhWab56D xSSyCPZhwaA17c9oMtaNdxNwt5g2ubScrhvR0eJRtbjZlRwm/Br8INTqGAsOtEi/vMPv f0iw== X-Gm-Message-State: AOAM533rbrWVOMcYF+fDwRNoceDUcHPIWyOfkHc9zv7ljMIU0f4alq5h 2Hn0Haiz5h47pNBl7X2nAdzEeg== X-Received: by 2002:a62:7e8d:: with SMTP id z135mr6428446pfc.251.1591168960181; Wed, 03 Jun 2020 00:22:40 -0700 (PDT) Received: from localhost.localdomain ([117.252.66.248]) by smtp.gmail.com with ESMTPSA id j17sm1407272pjy.22.2020.06.03.00.22.35 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Wed, 03 Jun 2020 00:22:39 -0700 (PDT) From: Sumit Garg To: daniel.thompson@linaro.org Cc: kgdb-bugreport@lists.sourceforge.net, jason.wessel@windriver.com, dianders@chromium.org, pmladek@suse.com, sergey.senozhatsky@gmail.com, gregkh@linuxfoundation.org, jslaby@suse.com, linux-kernel@vger.kernel.org, Sumit Garg Subject: [PATCH v5 1/4] kdb: Re-factor kdb_printf() message write code Date: Wed, 3 Jun 2020 12:52:12 +0530 Message-Id: <1591168935-6382-2-git-send-email-sumit.garg@linaro.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1591168935-6382-1-git-send-email-sumit.garg@linaro.org> References: <1591168935-6382-1-git-send-email-sumit.garg@linaro.org> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Re-factor kdb_printf() message write code in order to avoid duplication of code and thereby increase readability. Signed-off-by: Sumit Garg Reviewed-by: Douglas Anderson --- kernel/debug/kdb/kdb_io.c | 57 +++++++++++++++++++++++------------------------ 1 file changed, 28 insertions(+), 29 deletions(-) diff --git a/kernel/debug/kdb/kdb_io.c b/kernel/debug/kdb/kdb_io.c index 924bc92..2d42a02 100644 --- a/kernel/debug/kdb/kdb_io.c +++ b/kernel/debug/kdb/kdb_io.c @@ -542,6 +542,29 @@ static int kdb_search_string(char *searched, char *searchfor) return 0; } +static void kdb_msg_write(const char *msg, int msg_len) +{ + struct console *c; + + if (msg_len == 0) + return; + + if (dbg_io_ops && !dbg_io_ops->is_console) { + const char *cp = msg; + int len = msg_len; + + while (len--) { + dbg_io_ops->write_char(*cp); + cp++; + } + } + + for_each_console(c) { + c->write(c, msg, msg_len); + touch_nmi_watchdog(); + } +} + int vkdb_printf(enum kdb_msgsrc src, const char *fmt, va_list ap) { int diag; @@ -553,7 +576,6 @@ int vkdb_printf(enum kdb_msgsrc src, const char *fmt, va_list ap) int this_cpu, old_cpu; char *cp, *cp2, *cphold = NULL, replaced_byte = ' '; char *moreprompt = "more> "; - struct console *c; unsigned long uninitialized_var(flags); /* Serialize kdb_printf if multiple cpus try to write at once. @@ -687,22 +709,11 @@ int vkdb_printf(enum kdb_msgsrc src, const char *fmt, va_list ap) */ retlen = strlen(kdb_buffer); cp = (char *) printk_skip_headers(kdb_buffer); - if (!dbg_kdb_mode && kgdb_connected) { + if (!dbg_kdb_mode && kgdb_connected) gdbstub_msg_write(cp, retlen - (cp - kdb_buffer)); - } else { - if (dbg_io_ops && !dbg_io_ops->is_console) { - len = retlen - (cp - kdb_buffer); - cp2 = cp; - while (len--) { - dbg_io_ops->write_char(*cp2); - cp2++; - } - } - for_each_console(c) { - c->write(c, cp, retlen - (cp - kdb_buffer)); - touch_nmi_watchdog(); - } - } + else + kdb_msg_write(cp, retlen - (cp - kdb_buffer)); + if (logging) { saved_loglevel = console_loglevel; console_loglevel = CONSOLE_LOGLEVEL_SILENT; @@ -751,19 +762,7 @@ int vkdb_printf(enum kdb_msgsrc src, const char *fmt, va_list ap) moreprompt = "more> "; kdb_input_flush(); - - if (dbg_io_ops && !dbg_io_ops->is_console) { - len = strlen(moreprompt); - cp = moreprompt; - while (len--) { - dbg_io_ops->write_char(*cp); - cp++; - } - } - for_each_console(c) { - c->write(c, moreprompt, strlen(moreprompt)); - touch_nmi_watchdog(); - } + kdb_msg_write(moreprompt, strlen(moreprompt)); if (logging) printk("%s", moreprompt); -- 2.7.4