From patchwork Mon May 28 09:44:30 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ramon Fried X-Patchwork-Id: 137068 Delivered-To: patch@linaro.org Received: by 2002:a2e:9706:0:0:0:0:0 with SMTP id r6-v6csp2608020lji; Mon, 28 May 2018 02:44:43 -0700 (PDT) X-Google-Smtp-Source: ADUXVKKUDgNXdch06v3xVDLLmgB1SfkRb3L9+I6oKimMIP/GWleb0ppD2PMSH3qoSR9U9dCZMphP X-Received: by 2002:aa7:c147:: with SMTP id r7-v6mr5335044edp.143.1527500683083; Mon, 28 May 2018 02:44:43 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1527500683; cv=none; d=google.com; s=arc-20160816; b=D2WynOKsVhANJ3d5zkAFRlm8t11E2MLx3QBNikk+fNUuWpnw6/J+0K39QxZKgmz5Jw L9bOuV67JFK1EqAg7tn9rXp6Z0cfYDPZjHMx9Lef33uYJQj6SKHj6RjHoiettejaPaii fvcPuHW81t1rXvDXjz/SEFqTuFBc1YVhTXT6oo4kS4Qfv4Q5iOc7P4K516QAO4UdmK+e o5EtBwyoK/a6GI3nEIrv52lyRMaNQNXdPmIx0aF0HaQPHnrwU1hMvoDyfGlbx1uX+ne1 i5p7sDwamtooELGz7X+MIhGcchihh0DMXtFQLeMCkdB/9lTyY9kzThYrshf9ZITeg+J3 hfdw== 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=h20vnRKzgn3+TLFhoVDsuCgMTOQgC9n/VqaVXEspZ2Q=; b=TcpdvViWUadUYAKd3qiuaN7Sg0WUcNhWnVPIQhGd1X0yzcLozbapp1zJ07LNXcqJ2K YgvfxCn3L3piY9AsPFQqC565zua58tQGLXb+/ekwGCKMnOe5ZXX3igspV8iaYXeEwJ7m XX7ntQBHdHAYV1jB5iWqEkFMnatrnPi7vxhRF3ZrQJX6k4PLvI8Lv7irNV85Gn65UOQr JpiTYLOdT6082qKiXJW/Dcg6IP4USFTLTOjCHepbKmqlNUVIZZfRoD38OlsUPPFgYnfK ea2LOiS7OE4RnM1vp79TMS5bLNoCQVJy/piWTNRDCbsg9iq8mOYVSI2IdcxQ6SALKEd9 yY4g== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org header.s=google header.b=i3OuA/nB; 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=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.denx.de (dione.denx.de. [81.169.180.215]) by mx.google.com with ESMTP id d7-v6si2900468eda.458.2018.05.28.02.44.42; Mon, 28 May 2018 02:44:43 -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=@linaro.org header.s=google header.b=i3OuA/nB; 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=NONE dis=NONE) header.from=linaro.org Received: by lists.denx.de (Postfix, from userid 105) id 990D0C21D65; Mon, 28 May 2018 09:44:41 +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=RCVD_IN_DNSWL_NONE, 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 16763C21C27; Mon, 28 May 2018 09:44:39 +0000 (UTC) Received: by lists.denx.de (Postfix, from userid 105) id ABF13C21C27; Mon, 28 May 2018 09:44:37 +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 5C32EC21BE5 for ; Mon, 28 May 2018 09:44:37 +0000 (UTC) Received: by mail-wm0-f68.google.com with SMTP id x2-v6so23030627wmh.5 for ; Mon, 28 May 2018 02:44:37 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id; bh=nZ++7JvpirMZ9Ab8IKp4r+olmv0H/3RP7phTxqhRwdM=; b=i3OuA/nBs752JlF3+d7Pu/0kEb5rNCtOi/QR/UypktV5XdxIPPiy0Qmj6d71cf04la fQBW6wSswLcCkwY+GLIPB6L8JWip4F4JvW9/PSS6BSaTN3oLRM1GRc6rdON9/pSph/Hi lgTCiXBBfpKCJ/Ro+6dI1VDkXZan0iurXi3ZU= 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=nZ++7JvpirMZ9Ab8IKp4r+olmv0H/3RP7phTxqhRwdM=; b=HAc03WAbUegnJcVmLfx6GoN31r/1YXCM4zJzNIn478ntSzNq8t3hjf1fKkn0g+B+hh 8U58FRCbPWkWaKZR7DSIkRO1wsbJe9UwUZTDF7j6ay7f47eutIM2Jze7iQsX19UyKWl0 I2/9aXWiUjPQ6eHEuYjGMt8higQ38u6uWegsJGk8n4ABB5JAozX6gYWzCdABDzl+1UJC Fxs/1RysXD7IyE4SkkvCZHQYsSumxHV0InB2xWV3ORu6NtVduJQAhuNbO43dFumPHWw0 3S/Pjq8zffljpjZFQ81jB68CNyTiHqaRV/Oj6v/0lSus/wckcEHmNa8aAARez0QzzEgo Kp9w== X-Gm-Message-State: ALKqPwfOFJctuvrcUIrZM5radhQQhFCS1Mdy+MWxuVvuNonRgJxIxJAE Ja0GxXXltyOHzqmrQCcc2EcFRA== X-Received: by 2002:a50:9176:: with SMTP id f51-v6mr14259121eda.29.1527500677001; Mon, 28 May 2018 02:44:37 -0700 (PDT) Received: from lx-rfried.mea.qualcomm.com ([185.23.60.4]) by smtp.gmail.com with ESMTPSA id o47-v6sm17054540edc.95.2018.05.28.02.44.35 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Mon, 28 May 2018 02:44:36 -0700 (PDT) From: Ramon Fried X-Google-Original-From: Ramon Fried To: yamada.masahiro@socionext.com, u-boot@lists.denx.de Date: Mon, 28 May 2018 12:44:30 +0300 Message-Id: <20180528094430.2440-1-ramon.fried@gmail.com> X-Mailer: git-send-email 2.17.0 Subject: [U-Boot] [PATCH] 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" Add WARN_ONCE definition to allow single time notification of warnings to the user. Signed-off-by: Ramon Fried --- include/linux/bug.h | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/include/linux/bug.h b/include/linux/bug.h index f07bb716fc0..67b6057a22a 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)) \ + __WARN_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 */