From patchwork Tue Oct 27 23:55:40 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sean Anderson X-Patchwork-Id: 1389069 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=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=H/uDOBtP; 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 4CLTGL0zrtz9s0b for ; Wed, 28 Oct 2020 10:59:54 +1100 (AEDT) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 687938255D; Wed, 28 Oct 2020 00:57:04 +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="H/uDOBtP"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id D635882523; Wed, 28 Oct 2020 00:56:22 +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-x82d.google.com (mail-qt1-x82d.google.com [IPv6:2607:f8b0:4864:20::82d]) (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 3FBB68250B for ; Wed, 28 Oct 2020 00:56:19 +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-x82d.google.com with SMTP id h19so2406629qtq.4 for ; Tue, 27 Oct 2020 16:56:19 -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=xXcPnkZVxmZGI1VhXYd5y4DJ/NfEXsGnBpSnETsGt4E=; b=H/uDOBtP1rqo4BDVpWg2gDXGpOuZkndzmlViIwQHOU4ZWh9fEKXHqTj/KKvkbIDMUv t8J4r2QYJsrdRaDIxTr/HxzSSVU8uQydkz5d+yprt40Nzk3pR5r4pH56jUcqj9JQsOmo I6qFsnUZqVK+I22pi7/w/nr7aid9VmxhiYib8dbtXpND2DEqAf4qe02hdB4f1GFdTsaR Z6M6g9EDEpCNahu44uXO7fqnQpr6cSjSmuy2xAadRSEN8H3hxEXWH049GFRlO/Jm8TOA OXyigpaDBM1kupKue3IVVsLKaEaiGna4fojHgW4n3vHbz66Ga0C3eKMuPvJ1qF+E4eSw DXnQ== 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=xXcPnkZVxmZGI1VhXYd5y4DJ/NfEXsGnBpSnETsGt4E=; b=myqxqDP6PxeCFmNAO6xF76cz+LQ9qKHnt/XHenGCQb7wqPnAKdg0URaIZcACoY3l6R soO0JSGi0+nNfmv1Kuc+3JeWGug6krtxdSoKK7PfJ1HZZZz2IPqBlywKepTdEm/LcWvz lOy7Ib4qcwspWCcjBa7muey+uCDyygUP7Wjji0Xup8PhO5ymNAvJuULluhlJh+LQ3BaP nWowrZW/osWxK74e77dB0HQaTv3KBxOKChfTZUzMRQ2q8XXR0LYdUT+Djlfe4yWWuY4a GC4fpRFZXsFvHr1BtdtSspkDeTg8GAMI7ObAK+GhwPDxYk0OUvCts7cVDL1ieRgNWa6B XLtg== X-Gm-Message-State: AOAM533GRdBlabzi4SHT+3Vtt3PtB6/kugsIA5eTnMKvGE9vizriOC41 iuyXFLBTZBEx+dHbaFJA63iaBUIAqxh6AQ== X-Google-Smtp-Source: ABdhPJx+nrObhLuO1SA+/tYYw5nqDzYoXudyvp6AhdmNin/lpLm3MSpu4yZDAJWrB6NWmo6VOD8Ypg== X-Received: by 2002:ac8:454e:: with SMTP id z14mr4858333qtn.392.1603842977671; Tue, 27 Oct 2020 16:56:17 -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.16 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 27 Oct 2020 16:56:17 -0700 (PDT) From: Sean Anderson To: u-boot@lists.denx.de Cc: Tom Rini , Heinrich Schuchardt , Simon Glass , Sean Anderson Subject: [PATCH v4 21/22] doc: Add log kerneldocs to documentation Date: Tue, 27 Oct 2020 19:55:40 -0400 Message-Id: <20201027235541.706077-22-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 The functions in log.h are already mostly documented, so add them to the generated documentation. Signed-off-by: Sean Anderson Reviewed-by: Simon Glass --- (no changes since v2) Changes in v2: - Add % before constants in kerneldocs - Document log_level_t and log_category_t members doc/develop/logging.rst | 5 ++ include/log.h | 142 +++++++++++++++++++++++++--------------- 2 files changed, 95 insertions(+), 52 deletions(-) diff --git a/doc/develop/logging.rst b/doc/develop/logging.rst index 28340a4aac..52ccd2009e 100644 --- a/doc/develop/logging.rst +++ b/doc/develop/logging.rst @@ -291,3 +291,8 @@ information Add a command to add new log records and delete existing records. Provide additional log() functions - e.g. logc() to specify the category + +Logging API +----------- +.. kernel-doc:: include/log.h + :internal: diff --git a/include/log.h b/include/log.h index 7a839d55aa..952d407068 100644 --- a/include/log.h +++ b/include/log.h @@ -17,54 +17,88 @@ struct cmd_tbl; -/** Log levels supported, ranging from most to least important */ +/** + * enum log_level_t - Log levels supported, ranging from most to least important + */ enum log_level_t { - LOGL_EMERG = 0, /* U-Boot is unstable */ - LOGL_ALERT, /* Action must be taken immediately */ - LOGL_CRIT, /* Critical conditions */ - LOGL_ERR, /* Error that prevents something from working */ - LOGL_WARNING, /* Warning may prevent optimial operation */ - LOGL_NOTICE, /* Normal but significant condition, printf() */ - LOGL_INFO, /* General information message */ - LOGL_DEBUG, /* Basic debug-level message */ - LOGL_DEBUG_CONTENT, /* Debug message showing full message content */ - LOGL_DEBUG_IO, /* Debug message showing hardware I/O access */ + /** @LOGL_EMERG: U-Boot is unstable */ + LOGL_EMERG = 0, + /** @LOGL_ALERT: Action must be taken immediately */ + LOGL_ALERT, + /** @LOGL_CRIT: Critical conditions */ + LOGL_CRIT, + /** @LOGL_ERR: Error that prevents something from working */ + LOGL_ERR, + /** @LOGL_WARNING: Warning may prevent optimial operation */ + LOGL_WARNING, + /** @LOGL_NOTICE: Normal but significant condition, printf() */ + LOGL_NOTICE, + /** @LOGL_INFO: General information message */ + LOGL_INFO, + /** @LOGL_DEBUG: Basic debug-level message */ + LOGL_DEBUG, + /** @LOGL_DEBUG_CONTENT: Debug message showing full message content */ + LOGL_DEBUG_CONTENT, + /** @LOGL_DEBUG_IO: Debug message showing hardware I/O access */ + LOGL_DEBUG_IO, + /** @LOGL_COUNT: Total number of valid log levels */ LOGL_COUNT, + /** @LOGL_NONE: Used to indicate that there is no valid log level */ LOGL_NONE, - LOGL_LEVEL_MASK = 0xf, /* Mask for valid log levels */ - LOGL_FORCE_DEBUG = 0x10, /* Mask to force output due to LOG_DEBUG */ + /** @LOGL_LEVEL_MASK: Mask for valid log levels */ + LOGL_LEVEL_MASK = 0xf, + /** @LOGL_FORCE_DEBUG: Mask to force output due to LOG_DEBUG */ + LOGL_FORCE_DEBUG = 0x10, + /** @LOGL_FIRST: The first, most-important log level */ LOGL_FIRST = LOGL_EMERG, + /** @LOGL_MAX: The last, least-important log level */ LOGL_MAX = LOGL_DEBUG_IO, }; /** - * Log categories supported. Most of these correspond to uclasses (i.e. - * enum uclass_id) but there are also some more generic categories. + * enum log_category_t - Log categories supported. + * + * Log categories between %LOGC_FIRST and %LOGC_NONE correspond to uclasses + * (i.e. &enum uclass_id), but there are also some more generic categories. * * Remember to update log_cat_name[] after adding a new category. */ enum log_category_t { + /** @LOGC_FIRST: First log category */ LOGC_FIRST = 0, /* First part mirrors UCLASS_... */ + /** @LOGC_NONE: Default log category */ LOGC_NONE = UCLASS_COUNT, /* First number is after all uclasses */ - LOGC_ARCH, /* Related to arch-specific code */ - LOGC_BOARD, /* Related to board-specific code */ - LOGC_CORE, /* Related to core features (non-driver-model) */ - LOGC_DM, /* Core driver-model */ - LOGC_DT, /* Device-tree */ - LOGC_EFI, /* EFI implementation */ - LOGC_ALLOC, /* Memory allocation */ - LOGC_SANDBOX, /* Related to the sandbox board */ - LOGC_BLOBLIST, /* Bloblist */ - LOGC_DEVRES, /* Device resources (devres_... functions) */ - /* Advanced Configuration and Power Interface (ACPI) */ + /** @LOGC_ARCH: Related to arch-specific code */ + LOGC_ARCH, + /** @LOGC_BOARD: Related to board-specific code */ + LOGC_BOARD, + /** @LOGC_CORE: Related to core features (non-driver-model) */ + LOGC_CORE, + /** @LOGC_DM: Core driver-model */ + LOGC_DM, + /** @LOGC_DT: Device-tree */ + LOGC_DT, + /** @LOGC_EFI: EFI implementation */ + LOGC_EFI, + /** @LOGC_ALLOC: Memory allocation */ + LOGC_ALLOC, + /** @LOGC_SANDBOX: Related to the sandbox board */ + LOGC_SANDBOX, + /** @LOGC_BLOBLIST: Bloblist */ + LOGC_BLOBLIST, + /** @LOGC_DEVRES: Device resources (``devres_...`` functions) */ + LOGC_DEVRES, + /** @LOGC_ACPI: Advanced Configuration and Power Interface (ACPI) */ LOGC_ACPI, - LOGC_COUNT, /* Number of log categories */ - LOGC_END, /* Sentinel value for a list of log categories */ + /** @LOGC_COUNT: Number of log categories */ + LOGC_COUNT, + /** @LOGC_END: Sentinel value for lists of log categories */ + LOGC_END, }; /* Helper to cast a uclass ID to a log category */ @@ -83,7 +117,7 @@ static inline int log_uc_cat(enum uclass_id id) * @func: Function where log record was generated * @fmt: printf() format string for log record * @...: Optional parameters, according to the format string @fmt - * @return 0 if log record was emitted, -ve on error + * Return: 0 if log record was emitted, -ve on error */ int _log(enum log_category_t cat, enum log_level_t level, const char *file, int line, const char *func, const char *fmt, ...) @@ -238,7 +272,7 @@ void __assert_fail(const char *assertion, const char *file, unsigned int line, * full pathname as it may be huge. Only use this when the user should be * warning, similar to BUG_ON() in linux. * - * @return true if assertion succeeded (condition is true), else false + * Return: true if assertion succeeded (condition is true), else false */ #define assert_noisy(x) \ ({ bool _val = (x); \ @@ -322,8 +356,9 @@ enum log_device_flags { */ struct log_driver { const char *name; + /** - * emit() - emit a log record + * @emit: emit a log record * * Called by the log system to pass a log record to a particular driver * for processing. The filter is checked before calling this function. @@ -380,11 +415,11 @@ enum log_filter_flags { * @filter_num: Sequence number of this filter. This is returned when adding a * new filter, and must be provided when removing a previously added * filter. - * @flags: Flags for this filter (LOGFF_...) + * @flags: Flags for this filter (``LOGFF_...``) * @cat_list: List of categories to allow (terminated by %LOGC_END). If empty - * then all categories are permitted. Up to LOGF_MAX_CATEGORIES entries + * then all categories are permitted. Up to %LOGF_MAX_CATEGORIES entries * can be provided - * @level: Maximum (or minimum, if LOGFF_MIN_LEVEL) log level to allow + * @level: Maximum (or minimum, if %LOGFF_MIN_LEVEL) log level to allow * @file_list: List of files to allow, separated by comma. If NULL then all * files are permitted * @sibling_node: Next filter in the list of filters for this log device @@ -409,7 +444,7 @@ 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 + * Return: category name (which may be a uclass driver name) if found, or * "" if invalid, or "" if not found. All error * responses begin with '<'. */ @@ -419,7 +454,7 @@ const char *log_get_cat_name(enum log_category_t cat); * log_get_cat_by_name() - Look up a category by name * * @name: Name to look up - * @return category ID, or LOGC_NONE if not found + * Return: Category, or %LOGC_NONE if not found */ enum log_category_t log_get_cat_by_name(const char *name); @@ -427,7 +462,7 @@ enum log_category_t log_get_cat_by_name(const char *name); * log_get_level_name() - Get the name of a log level * * @level: Log level to look up - * @return log level name (in ALL CAPS) + * Return: Log level name (in ALL CAPS) */ const char *log_get_level_name(enum log_level_t level); @@ -435,7 +470,7 @@ const char *log_get_level_name(enum log_level_t level); * log_get_level_by_name() - Look up a log level by name * * @name: Name to look up - * @return log level ID, or LOGL_NONE if not found + * Return: Log level, or %LOGL_NONE if not found */ enum log_level_t log_get_level_by_name(const char *name); @@ -443,7 +478,7 @@ enum log_level_t log_get_level_by_name(const char *name); * log_device_find_by_name() - Look up a log device by its driver's name * * @drv_name: Name of the driver - * @return the log device, or NULL if not found + * Return: the log device, or %NULL if not found */ struct log_device *log_device_find_by_name(const char *drv_name); @@ -491,15 +526,16 @@ int do_log_test(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[]); * * @drv_name: Driver name to add the filter to (since each driver only has a * single device) - * @flags: Flags for this filter (LOGFF_...) + * @flags: Flags for this filter (``LOGFF_...``) * @cat_list: List of categories to allow (terminated by %LOGC_END). If empty - * then all categories are permitted. Up to LOGF_MAX_CATEGORIES entries + * then all categories are permitted. Up to %LOGF_MAX_CATEGORIES entries * can be provided - * @level: Maximum (or minimum, if LOGFF_LEVEL_MIN) log level to allow + * @level: Maximum (or minimum, if %LOGFF_LEVEL_MIN) log level to allow * @file_list: List of files to allow, separated by comma. If NULL then all * files are permitted - * @return the sequence number of the new filter (>=0) if the filter was added, - * or a -ve value on error + * Return: + * the sequence number of the new filter (>=0) if the filter was added, or a + * -ve value on error */ int log_add_filter_flags(const char *drv_name, enum log_category_t cat_list[], enum log_level_t level, const char *file_list, @@ -511,13 +547,14 @@ int log_add_filter_flags(const char *drv_name, enum log_category_t cat_list[], * @drv_name: Driver name to add the filter to (since each driver only has a * single device) * @cat_list: List of categories to allow (terminated by %LOGC_END). If empty - * then all categories are permitted. Up to LOGF_MAX_CATEGORIES entries + * then all categories are permitted. Up to %LOGF_MAX_CATEGORIES entries * can be provided * @max_level: Maximum log level to allow - * @file_list: List of files to allow, separated by comma. If NULL then all + * @file_list: List of files to allow, separated by comma. If %NULL then all * files are permitted - * @return the sequence number of the new filter (>=0) if the filter was added, - * or a -ve value on error + * Return: + * the sequence number of the new filter (>=0) if the filter was added, or a + * -ve value on error */ static inline int log_add_filter(const char *drv_name, enum log_category_t cat_list[], @@ -534,8 +571,9 @@ static inline int log_add_filter(const char *drv_name, * @drv_name: Driver name to remove the filter from (since each driver only has * a single device) * @filter_num: Filter number to remove (as returned by log_add_filter()) - * @return 0 if the filter was removed, -ENOENT if either the driver or the - * filter number was not found + * Return: + * 0 if the filter was removed, -%ENOENT if either the driver or the filter + * number was not found */ int log_remove_filter(const char *drv_name, int filter_num); @@ -556,7 +594,7 @@ int log_device_set_enable(struct log_driver *drv, bool enable); /** * log_init() - Set up the log system ready for use * - * @return 0 if OK, -ENOMEM if out of memory + * Return: 0 if OK, -%ENOMEM if out of memory */ int log_init(void); #else @@ -570,7 +608,7 @@ static inline int log_init(void) * log_get_default_format() - get default log format * * The default log format is configurable via - * CONFIG_LOGF_FILE, CONFIG_LOGF_LINE, CONFIG_LOGF_FUNC. + * %CONFIG_LOGF_FILE, %CONFIG_LOGF_LINE, and %CONFIG_LOGF_FUNC. * * Return: default log format */