From patchwork Tue Oct 27 23:55:34 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sean Anderson X-Patchwork-Id: 1389063 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=2a01:238:438b:c500:173d:9f52:ddab:ee01; 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=gmail.com Authentication-Results: ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20161025 header.b=BnzRN9PT; dkim-atps=neutral Received: from phobos.denx.de (phobos.denx.de [IPv6:2a01:238:438b:c500:173d:9f52:ddab:ee01]) (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 4CLTFL56HPz9s0b for ; Wed, 28 Oct 2020 10:59:02 +1100 (AEDT) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id D3AEB82540; Wed, 28 Oct 2020 00:56:52 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=pass (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="BnzRN9PT"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 8A69C82505; Wed, 28 Oct 2020 00:56:15 +0100 (CET) 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,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FROM,SPF_HELO_NONE,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.2 Received: from mail-qt1-x833.google.com (mail-qt1-x833.google.com [IPv6:2607:f8b0:4864:20::833]) (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 A8E4B824C5 for ; Wed, 28 Oct 2020 00:56:12 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=seanga2@gmail.com Received: by mail-qt1-x833.google.com with SMTP id h12so2402864qtc.9 for ; Tue, 27 Oct 2020 16:56:12 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=E/IyPiO+MlPxGluujQH1SnoRn5gjuqYoimEW6S2BRkc=; b=BnzRN9PTHWYNfNV3DCEyMQ45iQKJFKifefJKL+pY2O4hIBKSf7IAymDT81PGzEKigJ ms4ZapbUKLoYW06JzFGE7skX65xur96CqFvaZjmgE/CLUk1skmc0gTYDxmB5YpE70yqZ EK4LjWFX5P+da6vDwf4kFHVeNJmo578sblbWAll3Cnj5xN3hy9PVsOwbrCxe8BhNgh5C 5FdkXMI2/+hxF9Ad0LCPUQuBtqidJbyKog2qxXYomTgVvlQ0lrfAMqeHNmSSDVjzKeeB Oeb0YA8MCmdF6RMUMKh11pOFipK+awOGpHf+UK7BExcsnESx0nv+eLRppUm/6gbFbo6o 1zEg== 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=E/IyPiO+MlPxGluujQH1SnoRn5gjuqYoimEW6S2BRkc=; b=B4VPYtTLaAI2CVhxKgoJ/hUvsZSU4qWntJfCUJaI/CHXw/sA3AccLpfD/RMjttHTox Y3kn9Z2/kU9IaBLnp9U2gGFyTIo6/heMSJ01JDOB4MLeslW7LNNPjofYQbN2Ov8mCis/ kjzp9Pe1QuLGHb1AIYDX8rmfLY8CKFxAdwlKizndIIYUCiRrsm/ccIPhRpn+W3ew5kNe idiLy4/l2K0jyXAPshig263ctz2OBOanjYeqbU5j/ikXgyZ24/tUnieVLL0xiQh5jqZd NQwFDyEPeXgDeBL68hHpwn4T7BzNwG5VBuJJMYpPCtFHo4QcjtLkAIsnyDwxRuZZNrJb tTgg== X-Gm-Message-State: AOAM531zt8avEthLrEeWfbPS3FC/0dQffzovyrdUatvD+eJ8VkjVgd3z t8/uDxHPjQyKgIqTIVCkfuOLEVJWuoB15Q== X-Google-Smtp-Source: ABdhPJyWSoOJUx+hqbNjc/ahG8JztkjMOen9FntGnhu/UzM3JKm91FQHiOshFpRk65ULLqFA/tJHxg== X-Received: by 2002:aed:237c:: with SMTP id i57mr4721513qtc.324.1603842971402; Tue, 27 Oct 2020 16:56:11 -0700 (PDT) Received: from godwin.fios-router.home (pool-108-51-35-162.washdc.fios.verizon.net. [108.51.35.162]) by smtp.gmail.com with ESMTPSA id 69sm1907543qko.48.2020.10.27.16.56.10 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 27 Oct 2020 16:56:10 -0700 (PDT) From: Sean Anderson To: u-boot@lists.denx.de Cc: Tom Rini , Heinrich Schuchardt , Simon Glass , Sean Anderson Subject: [PATCH v4 15/22] cmd: log: Add commands to list categories and drivers Date: Tue, 27 Oct 2020 19:55:34 -0400 Message-Id: <20201027235541.706077-16-seanga2@gmail.com> X-Mailer: git-send-email 2.28.0 In-Reply-To: <20201027235541.706077-1-seanga2@gmail.com> References: <20201027235541.706077-1-seanga2@gmail.com> 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 This allows users to query which categories and drivers are available on their system. This allows them to construct filter-add commands without (e.g.) adjusting the log format to show categories and drivers. Signed-off-by: Sean Anderson Reviewed-by: Simon Glass --- (no changes since v3) Changes in v3: - Document assumption that erroneous results from log_get_cat_name begin with '<' Changes in v2: - New cmd/log.c | 35 +++++++++++++++++++++++++++++++++++ common/log.c | 1 + include/log.h | 5 +++-- 3 files changed, 39 insertions(+), 2 deletions(-) diff --git a/cmd/log.c b/cmd/log.c index 651e50358c..8d8d8a8172 100644 --- a/cmd/log.c +++ b/cmd/log.c @@ -47,6 +47,37 @@ static int do_log_level(struct cmd_tbl *cmdtp, int flag, int argc, return CMD_RET_SUCCESS; } +static int do_log_categories(struct cmd_tbl *cmdtp, int flag, int argc, + char *const argv[]) +{ + enum log_category_t cat; + const char *name; + + for (cat = LOGC_FIRST; cat < LOGC_COUNT; cat++) { + name = log_get_cat_name(cat); + /* + * Invalid category names (e.g. or ) begin + * with '<'. + */ + if (name[0] == '<') + continue; + printf("%s\n", name); + } + + return CMD_RET_SUCCESS; +} + +static int do_log_drivers(struct cmd_tbl *cmdtp, int flag, int argc, + char *const argv[]) +{ + struct log_device *ldev; + + list_for_each_entry(ldev, &gd->log_head, sibling_node) + printf("%s\n", ldev->drv->name); + + return CMD_RET_SUCCESS; +} + static int do_log_format(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[]) { @@ -123,6 +154,8 @@ static int do_log_rec(struct cmd_tbl *cmdtp, int flag, int argc, #ifdef CONFIG_SYS_LONGHELP static char log_help_text[] = "level - get/set log level\n" + "categories - list log categories\n" + "drivers - list log drivers\n" "log format - set log output format. is a string where\n" "\teach letter indicates something that should be displayed:\n" "\tc=category, l=level, F=file, L=line number, f=function, m=msg\n" @@ -134,6 +167,8 @@ static char log_help_text[] = U_BOOT_CMD_WITH_SUBCMDS(log, "log system", log_help_text, U_BOOT_SUBCMD_MKENT(level, 2, 1, do_log_level), + U_BOOT_SUBCMD_MKENT(categories, 1, 1, do_log_categories), + U_BOOT_SUBCMD_MKENT(drivers, 1, 1, do_log_drivers), U_BOOT_SUBCMD_MKENT(format, 2, 1, do_log_format), U_BOOT_SUBCMD_MKENT(rec, 7, 1, do_log_rec), ); diff --git a/common/log.c b/common/log.c index 9a79b95a95..95ba8350c6 100644 --- a/common/log.c +++ b/common/log.c @@ -41,6 +41,7 @@ static const char *const log_level_name[LOGL_COUNT] = { "IO", }; +/* All error responses MUST begin with '<' */ const char *log_get_cat_name(enum log_category_t cat) { const char *name; diff --git a/include/log.h b/include/log.h index ec2d6fdb01..7a839d55aa 100644 --- a/include/log.h +++ b/include/log.h @@ -409,8 +409,9 @@ struct log_filter { * log_get_cat_name() - Get the name of a category * * @cat: Category to look up - * @return category name (which may be a uclass driver name) if found, or - * "" if invalid, or "" if not found + * @return: category name (which may be a uclass driver name) if found, or + * "" if invalid, or "" if not found. All error + * responses begin with '<'. */ const char *log_get_cat_name(enum log_category_t cat);