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: 137171 Delivered-To: patch@linaro.org Received: by 2002:a2e:9706:0:0:0:0:0 with SMTP id r6-v6csp4010085lji; Tue, 29 May 2018 05:50:31 -0700 (PDT) X-Google-Smtp-Source: AB8JxZrn1TtrfyDeGirNcND9Cy+uMwnfxSTclXCyaje4dD9vaM8DggFYtkc1UKFwC7b0oQPHarV7 X-Received: by 2002:a50:94ce:: with SMTP id t14-v6mr19216026eda.146.1527598231259; Tue, 29 May 2018 05:50:31 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1527598231; cv=none; d=google.com; s=arc-20160816; b=r4D/wOITn9HLZrtvhWwX589Il93H5g0382DZqpfVRAKwi0uzYYul7oqTeJwEKaI8MD /UXSVdr+j92u2LRwLbkRkaOqRGIQfTojCJ7UTDhLgQdzLY6PY4O/hBQWugiuXuH1ze2P kfy5u/rl1Sj6obAYU4LyNsoCfa1f+8dBxi7VZQLUP12b81Ryc3JWMxh/Pyg4qEn8qNIj FKfwNEMqpr79mSIFhPF1+VJEyZVGD6nDF49Ec/L6/VL6fLLrfP+J/iTKegebGiqVZLBT c/vEvloxm7XInIKFfqvSFYv4eT8Rk4+9t6IDvn2COrXFnRWAEwtJA3AEvW5IgfMIjfIY rOsQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:content-transfer-encoding:mime-version :list-subscribe:list-help:list-post:list-archive:list-unsubscribe :list-id:precedence:subject:message-id:date:to:from:dkim-signature :arc-authentication-results; bh=21cg5RRX40GBXOZb0goD6t5qFDwr8HGcfxSmojw9o70=; b=aPdSZShJ/ZasceoFU2nv6GPoVqKwSpej7w2+sF6mBwmbusUTbXaNeoFp/0/83jX+bT OSUG9dIKqtGiOFObdVPt3gAxrAhUXy5yPPL2G+IaHQ46Foxu2PMvsbzNMYaMbKqTeqo5 ylDHki+mZ6bMbIluOUP2BYjgq9KRY+lnEUcxpgEV3lpE5hs57uRpMpvcbSZFn8mEnDnu oimB/ap/CEM/mC+Jl5BZgmHedGQHyWfBuxTba0W8S4hh1nP+fKeml9uiK6rsfLIUJV8H B6xTFxJuAil6xN7GmmYVU/kAiBjxFIRUeJNIZ4MGhe5/Q8R9q1+7ahCmZ/aRnuCk8+vS zrQw== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@gmail.com header.s=20161025 header.b=CRU4Vlrs; spf=pass (google.com: best guess record for domain of u-boot-bounces@lists.denx.de designates 81.169.180.215 as permitted sender) smtp.mailfrom=u-boot-bounces@lists.denx.de; dmarc=fail (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from lists.denx.de (dione.denx.de. [81.169.180.215]) by mx.google.com with ESMTP id u3-v6si2082168edi.93.2018.05.29.05.50.30; Tue, 29 May 2018 05:50:31 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of u-boot-bounces@lists.denx.de designates 81.169.180.215 as permitted sender) client-ip=81.169.180.215; Authentication-Results: mx.google.com; dkim=neutral (body hash did not verify) header.i=@gmail.com header.s=20161025 header.b=CRU4Vlrs; spf=pass (google.com: best guess record for domain of u-boot-bounces@lists.denx.de designates 81.169.180.215 as permitted sender) smtp.mailfrom=u-boot-bounces@lists.denx.de; dmarc=fail (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: by lists.denx.de (Postfix, from userid 105) id D84C1C21E47; Tue, 29 May 2018 12:48:55 +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-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 */