Received: by 2002:a25:c593:0:0:0:0:0 with SMTP id v141csp2030809ybe; Sat, 14 Sep 2019 06:38:03 -0700 (PDT) X-Google-Smtp-Source: APXvYqyokj/5nRtalIVfgpFS7oh96agnQ5RBvbqjdw5arefcbWLwjMsPZOO1E1BrTt+eO/0I+iER X-Received: by 2002:a17:906:1197:: with SMTP id n23mr44908051eja.122.1568468283859; Sat, 14 Sep 2019 06:38:03 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1568468283; cv=none; d=google.com; s=arc-20160816; b=w8zDni0qm8Sfg39BEsfQiuIIBhfxRepZ9RVObPj7eUcSWy9aOU09II1lDKpZBxH/k+ BX3jMs472ge7Yj9vUooWrNUHm0kji7PcAKUO8ySj3hFRpIMHejBxjWETNHCH+yg/NLBP Rn7/rNPD4xmJKBqyHVBgA9MPn2/ooba+zj6m01tCx1PG3v+8o7s20z3knboTJ9XFLx5B fDLeUkDpZ1AkinQM8rQsqthvYOc/AxwMWWMS7j/JWLAldBnm+LNaYeBfLMa5SCcs6L9t XjC7TnyvRGGEb5cTyZsNLYKfx3bmZ8YzWFUA27hf8ecgQiuzgsTCISdKDwv767/N+6VV puKw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from; bh=7Y4/io38pcrSzNfip15Um/pMdFKYM1+0lgCJZP9WQq0=; b=PSVnBn0aBB94hnRLNU9AkgZZWTdYtWmznlhU+D6Cz/Au3ooT0OeusjJNJZkMU6Lh8i GUD/eVVVUg77+uUxai8YAtkvZAQJYO9Ke4ZlAuS9kei+C5hKeveAinOoFSjKlZ26pV2y cjaeEIlHvTdBSs5/RwZN8K0kKhRqOgzRquYtLx2tDCOmbE9lXoPbMdq3sEQ6J4n8QPgW mB1mBfEkYMNloXdogZEhUWERBvSisDqBsgftk8CxEUXoKM8iOb5+qfWydLmUYSQkPpXs AUgz7Nej3XGS791aEntjmTIm/F3PTPzQJfu/jdd22k21n9uNfGi1yJZXtUv+4/l4HeT5 zs3Q== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=collabora.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id b23si16394083eja.297.2019.09.14.06.37.07; Sat, 14 Sep 2019 06:38:03 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=collabora.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2404004AbfIMWE3 (ORCPT + 99 others); Fri, 13 Sep 2019 18:04:29 -0400 Received: from bhuna.collabora.co.uk ([46.235.227.227]:60812 "EHLO bhuna.collabora.co.uk" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2403993AbfIMWE1 (ORCPT ); Fri, 13 Sep 2019 18:04:27 -0400 Received: from turingmachine.home (unknown [IPv6:2804:431:c7f4:5bfc:5711:794d:1c68:5ed3]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) (Authenticated sender: tonyk) by bhuna.collabora.co.uk (Postfix) with ESMTPSA id 9464F28EF7B; Fri, 13 Sep 2019 23:04:22 +0100 (BST) From: =?UTF-8?q?Andr=C3=A9=20Almeida?= To: linux-block@vger.kernel.org, linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org Cc: corbet@lwn.net, axboe@kernel.dk, kernel@collabora.com, krisman@collabora.com, =?UTF-8?q?Andr=C3=A9=20Almeida?= Subject: [PATCH v2 4/4] coding-style: add explanation about pr_fmt macro Date: Fri, 13 Sep 2019 19:03:00 -0300 Message-Id: <20190913220300.422869-5-andrealmeid@collabora.com> X-Mailer: git-send-email 2.23.0 In-Reply-To: <20190913220300.422869-1-andrealmeid@collabora.com> References: <20190913220300.422869-1-andrealmeid@collabora.com> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org The pr_fmt macro is useful to format log messages printed by pr_XXXX() functions. Add text to explain the purpose of it, how to use and an example. Signed-off-by: André Almeida Cc: Jonathan Corbet --- Changes from v1: - Add Jonathan as explict Cc - Replace "include/printk.h" by "#include - Add note about #undef - Replace hardcore string by KBUILD_MODNAME at the example --- Documentation/process/coding-style.rst | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/Documentation/process/coding-style.rst b/Documentation/process/coding-style.rst index f4a2198187f9..1a33a933fbd3 100644 --- a/Documentation/process/coding-style.rst +++ b/Documentation/process/coding-style.rst @@ -819,7 +819,15 @@ which you should use to make sure messages are matched to the right device and driver, and are tagged with the right level: dev_err(), dev_warn(), dev_info(), and so forth. For messages that aren't associated with a particular device, defines pr_notice(), pr_info(), -pr_warn(), pr_err(), etc. +pr_warn(), pr_err(), etc. It's possible to format pr_XXX() messages using the +macro pr_fmt() to prevent rewriting the style of messages. It should be +defined before ``#include ``, to avoid compiler warning about +redefinitions, or just use ``#undef pr_fmt``. This is particularly useful for +adding the name of the module at the beginning of the message, for instance: + +.. code-block:: c + + #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt Coming up with good debugging messages can be quite a challenge; and once you have them, they can be a huge help for remote troubleshooting. However -- 2.23.0