From mboxrd@z Thu Jan 1 00:00:00 1970 Return-path: Received: from metis.ext.pengutronix.de ([2001:67c:670:201:290:27ff:fe1d:cc33]) by merlin.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1k6DVV-0003mK-EH for barebox@lists.infradead.org; Thu, 13 Aug 2020 13:43:05 +0000 From: Sascha Hauer Date: Thu, 13 Aug 2020 15:42:55 +0200 Message-Id: <20200813134257.24627-19-s.hauer@pengutronix.de> In-Reply-To: <20200813134257.24627-1-s.hauer@pengutronix.de> References: <20200813134257.24627-1-s.hauer@pengutronix.de> MIME-Version: 1.0 List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "barebox" Errors-To: barebox-bounces+u.kleine-koenig=pengutronix.de@lists.infradead.org Subject: [PATCH 18/20] Add WARN_ONCE() macro To: Barebox List Cc: Edmund Henniges , =?UTF-8?q?Daniel=20Gl=C3=B6ckner?= This adds WARN_ONCE from the Linux Kernel. It is useful to warn only once when we would otherwise spam the log. Signed-off-by: Sascha Hauer --- include/asm-generic/bug.h | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/include/asm-generic/bug.h b/include/asm-generic/bug.h index 8583d2425f..82b78261fc 100644 --- a/include/asm-generic/bug.h +++ b/include/asm-generic/bug.h @@ -34,4 +34,17 @@ unlikely(__ret_warn_on); \ }) #endif + +#define WARN_ONCE(condition, format...) ({ \ + static int __warned; \ + int __ret_warn_once = !!(condition); \ + \ + if (unlikely(__ret_warn_once)) { \ + if (WARN(!__warned, format)) { \ + __warned = 1; \ + dump_stack(); \ + } \ + } \ + unlikely(__ret_warn_once); \ +}) #endif -- 2.28.0 _______________________________________________ barebox mailing list barebox@lists.infradead.org http://lists.infradead.org/mailman/listinfo/barebox