From patchwork Tue May 29 12:46:39 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ramon Fried X-Patchwork-Id: 922071 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=none (mailfrom) smtp.mailfrom=lists.denx.de (client-ip=81.169.180.215; helo=lists.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="CRU4Vlrs"; dkim-atps=neutral Received: from lists.denx.de (dione.denx.de [81.169.180.215]) by ozlabs.org (Postfix) with ESMTP id 40wD8k2p6Lz9s0y for ; Tue, 29 May 2018 22:50:14 +1000 (AEST) Received: by lists.denx.de (Postfix, from userid 105) id F3773C21EA8; Tue, 29 May 2018 12:48:56 +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=FREEMAIL_FROM, RCVD_IN_MSPIKE_H3, RCVD_IN_MSPIKE_WL, 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 BAFD1C21EA1; Tue, 29 May 2018 12:48:53 +0000 (UTC) Received: by lists.denx.de (Postfix, from userid 105) id E205BC21EA7; Tue, 29 May 2018 12:46:49 +0000 (UTC) Received: from mail-wm0-f68.google.com (mail-wm0-f68.google.com [74.125.82.68]) by lists.denx.de (Postfix) with ESMTPS id E1613C21E88 for ; Tue, 29 May 2018 12:46:48 +0000 (UTC) Received: by mail-wm0-f68.google.com with SMTP id 18-v6so34638492wml.2 for ; Tue, 29 May 2018 05:46:48 -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; bh=ANP0FmVVPK3yPqlup92LTOFwX+C2e7t9VCE9F+gewPc=; b=CRU4VlrsG7tr+QRGqyycelfcM4oPd2eaTKzkUFS2716GZ6zi/SXAekvfg2xvgxuGfF ACrMQYiSty9X+JKmOyI/UEGhB4pmu0DZqcLX4LiegMJW0f5IdsF+qrJrLshsYqp1aZ3v Tzj8Q/FQb4SviHJvFOy3j/wy/v1cmwsWV2wsynCdRTSY4XjRs7IuH3IdsH5NiRlwUvxW Q8faZvmTMWjEK6FHacW/aA9iUZ9DTz8V0KOTzcNK9RnvWOOhagNMBq7oJc0tkMepN8gB qLT7dI57yPHsJ5pT66N/JJcFSy2OzJ2JWLCJf+cmHXpPZ31wJfYvJEmp4lehEhXr3B4u UMLg== 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; bh=ANP0FmVVPK3yPqlup92LTOFwX+C2e7t9VCE9F+gewPc=; b=cqGE1nrrD3HTgTlOAUaZHi7xmYV5SvbMLhMSEil1IinM/+Z5P9pkpex/hnnfdW7yMp o9zAI7108zyrRATLBGqNdtLOhQ2T0EkVhiojegHuNkzwecfowJSYM7I+ipNxapH8hX5Q aOEYycrLDOsfxMmTjssbO+JuRa8LBtyXJ4xBt/ujXodjFRMx9S5uOu7X6NgaNi1NraOM 60Dm/3D0sKGpLDHRfqQ++lc+y7BcFjVUudbZnd2jWQhik+rFxHj4PEFhr1SUDbhKL59Y u+dcWWCwqY1CJWIbDgq9FS+W8/9wHEdjGnO2C/tfnTxaMwk0syU0upk7K0kwAQd/wsgI pw+A== X-Gm-Message-State: ALKqPwdjOuUz6v65kr9vLjV01262nuuZ+SOmbi7jZe2AsXlntc3U3BI/ K3h91T2KZGwzO156+WA3k7o= X-Google-Smtp-Source: AB8JxZrQ/Tycu+OcnwOVC9BiHGjOlnR3GWipkUk/bLBmhY45aqjgjGG0sqjyJx7YGSCaqmrZK8O/Cg== X-Received: by 2002:a50:a94d:: with SMTP id m13-v6mr19372933edc.180.1527598008606; Tue, 29 May 2018 05:46:48 -0700 (PDT) Received: from lx-rfried.mea.qualcomm.com ([185.23.60.4]) by smtp.gmail.com with ESMTPSA id s25-v6sm8967330edm.86.2018.05.29.05.46.47 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 29 May 2018 05:46:47 -0700 (PDT) From: Ramon Fried To: yamada.masahiro@socionext.com, sjg@chromium.org, u-boot@lists.denx.de Date: Tue, 29 May 2018 15:46:39 +0300 Message-Id: <20180529124639.13172-1-ramon.fried@gmail.com> X-Mailer: git-send-email 2.17.0 Subject: [U-Boot] [PATCH v2] bug.h: introduce WARN_ONCE 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" From: Ramon Fried Add WARN_ONCE definition to allow single time notification of warnings to the user. Change-Id: If14d878dba04f3c976c0c2ae079a0f7642047006 --- v2: accidently commited the wrong file. noticed by Masahiro Yamada include/linux/bug.h | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/include/linux/bug.h b/include/linux/bug.h index f07bb716fc0..e43871dee44 100644 --- a/include/linux/bug.h +++ b/include/linux/bug.h @@ -20,6 +20,13 @@ unlikely(__ret_warn_on); \ }) +#define WARN(condition, format...) ({ \ + int __ret_warn_on = !!(condition); \ + if (unlikely(__ret_warn_on)) \ + printf(format); \ + unlikely(__ret_warn_on); \ +}) + #define WARN_ON_ONCE(condition) ({ \ static bool __warned; \ int __ret_warn_once = !!(condition); \ @@ -31,4 +38,15 @@ unlikely(__ret_warn_once); \ }) +#define WARN_ONCE(condition, format...) ({ \ + static bool __warned; \ + int __ret_warn_once = !!(condition); \ + \ + if (unlikely(__ret_warn_once && !__warned)) { \ + __warned = true; \ + WARN(1, format); \ + } \ + unlikely(__ret_warn_once); \ +}) + #endif /* _LINUX_BUG_H */