From patchwork Sat Sep 16 05:10:45 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Masahiro Yamada X-Patchwork-Id: 112774 Delivered-To: patch@linaro.org Received: by 10.140.106.117 with SMTP id d108csp1389827qgf; Fri, 15 Sep 2017 22:11:36 -0700 (PDT) X-Google-Smtp-Source: ADKCNb5Zb/LZYbqk1nDKteR/Ackdt7sHorgpsaTQDiiUwbEzt4n1CR9uiZ4fo+5STC9VLUyxT0tV X-Received: by 10.80.204.151 with SMTP id q23mr21912583edi.104.1505538696186; Fri, 15 Sep 2017 22:11:36 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1505538696; cv=none; d=google.com; s=arc-20160816; b=02R8reJN7oC7Ie2lgkUdZBFIp1ypVAKlLzvr0EWeQsWx4gZFz4cyAdrSrSFrhyYl9L YCLq4r6Mz65ACo4aY4fqUtCoYzoYq0+TADAujdShnkDhi2Yh7YWBIocDdcd2JiPww31h Qvl4X6SnOMoO5og4OiF17xIE673U2cUp6rITfTabbsBnFSH4fSghNvHAQA8NiKY9zusU iGlWY0YCpVx0zP6GxFE4FS4cxShFCCTAOqNH4C0MmHByW/FBMSEk2GlxaNcvVLj+zoIe V6SDquhP4Np6SIJS0ewV1Aby5oEaKoDsaW1o8lMfxCfXaMx1u6QsQCwMF02MDg++OXnB NgvA== 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:cc:references:in-reply-to:message-id :date:to:from:dkim-signature:dkim-filter:arc-authentication-results; bh=CHft9mSOcTSd23r6ZLNnLbaRzRee2zwaWOk7a3H1ta8=; b=EURZ31LqFsyUkKOedqzqTxhyxo8jNBmns+ap3LdEMzQwke0MRIfH1Zn1691vMBRZqm 1RshSAIQcAobkuforiN+befRkPN0mCCKDxLc0ksDci33iLStd5WRPj7I3jG6lFWmWnnO tY82cn1JQzjMDfXrrWW+x13Hp/z1meGp4MbY2bL0vWJ0vJKJy7TIlvjvn2lQkSq4xuDP E9ns9aWRT5JUJN9gXAC0GOgArVh82PienyZK7tXDiXAKx4wxqP+nD3cLqxOLwduV1jyM NlshdKCKjbexConDzbjJqzwACFZK1uAPNZYFjD3dO05lAB6DQvEb5hM8nqZ298eFkLib Gwjw== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@nifty.com header.s=dec2015msa header.b=gI4WSdFf; 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 Return-Path: Received: from lists.denx.de (dione.denx.de. [81.169.180.215]) by mx.google.com with ESMTP id l92si2986925edl.554.2017.09.15.22.11.34; Fri, 15 Sep 2017 22:11:36 -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=@nifty.com header.s=dec2015msa header.b=gI4WSdFf; 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 Received: by lists.denx.de (Postfix, from userid 105) id B2382C21EE5; Sat, 16 Sep 2017 05:11:21 +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=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 8BD88C21C8F; Sat, 16 Sep 2017 05:11:19 +0000 (UTC) Received: by lists.denx.de (Postfix, from userid 105) id 720D8C21E3A; Sat, 16 Sep 2017 05:11:18 +0000 (UTC) Received: from conuserg-09.nifty.com (conuserg-09.nifty.com [210.131.2.76]) by lists.denx.de (Postfix) with ESMTPS id B83FEC21C8F for ; Sat, 16 Sep 2017 05:11:16 +0000 (UTC) Received: from grover.sesame (FL1-122-131-185-176.osk.mesh.ad.jp [122.131.185.176]) (authenticated) by conuserg-09.nifty.com with ESMTP id v8G5Asor028761; Sat, 16 Sep 2017 14:10:59 +0900 DKIM-Filter: OpenDKIM Filter v2.10.3 conuserg-09.nifty.com v8G5Asor028761 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nifty.com; s=dec2015msa; t=1505538659; bh=A63E+oN4bdOzQW6ervG8jDMF1APDB6VdHqCymxPHA2k=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=gI4WSdFf1JJaICwRJT8ietKt4vl3PuDIvNawXi/puGBj4U8BsdD6ttjlLd+7lxDVW nzoJLQZVWb2VILu/I3Qzj5m73U4g30jFsNV4z3eaqpLpcRO8A6VLlWZIjIBVeg4RTE /PWygn4r9dtQ6twv1dqUP1DSo/6Dlg72Bt8gD9snshWq8vHxbM2gOM/NIH8u8ap5Kj Vx+grHcMZuWDR57p/GxOpRbXGhC4OjEaTWpisj98PmiS7kO9XkpF++UZt+dTwn2dNh 883Nc/Tl49rPNrcN6apAzEv1UGrcwb4iEbfXVJ5/95VAEFir02b1sHZUuwd3s/D854 JYZdCicUC0pyA== X-Nifty-SrcIP: [122.131.185.176] From: Masahiro Yamada To: u-boot@lists.denx.de Date: Sat, 16 Sep 2017 14:10:45 +0900 Message-Id: <1505538646-19191-8-git-send-email-yamada.masahiro@socionext.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1505538646-19191-1-git-send-email-yamada.masahiro@socionext.com> References: <1505538646-19191-1-git-send-email-yamada.masahiro@socionext.com> Cc: Marek Vasut Subject: [U-Boot] [PATCH v2 7/8] bug.h: move runtime BUG/WARN macros into 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" Collect runtime BUG/WARN into a self-contained header to make these macros easier to use. Signed-off-by: Masahiro Yamada --- Changes in v2: None drivers/usb/dwc3/linux-compat.h | 1 - include/common.h | 9 +-------- include/linux/bug.h | 28 ++++++++++++++++++++++++++++ include/linux/compat.h | 15 --------------- 4 files changed, 29 insertions(+), 24 deletions(-) diff --git a/drivers/usb/dwc3/linux-compat.h b/drivers/usb/dwc3/linux-compat.h index 64db4ecc3c6f..5cbe377e3cd9 100644 --- a/drivers/usb/dwc3/linux-compat.h +++ b/drivers/usb/dwc3/linux-compat.h @@ -14,7 +14,6 @@ #define WARN(val, format, arg...) debug(format, ##arg) #define dev_WARN(dev, format, arg...) debug(format, ##arg) -#define WARN_ON_ONCE(val) debug("Error %d\n", val) static inline size_t strlcat(char *dest, const char *src, size_t n) { diff --git a/include/common.h b/include/common.h index 7ea78bde83f7..18963355840d 100644 --- a/include/common.h +++ b/include/common.h @@ -23,6 +23,7 @@ typedef volatile unsigned char vu_char; #include #include #include +#include #include #include #include @@ -90,14 +91,6 @@ void __assert_fail(const char *assertion, const char *file, unsigned line, ({ if (!(x) && _DEBUG) \ __assert_fail(#x, __FILE__, __LINE__, __func__); }) -#ifndef BUG -#define BUG() do { \ - printf("BUG: failure at %s:%d/%s()!\n", __FILE__, __LINE__, __FUNCTION__); \ - panic("BUG!"); \ -} while (0) -#define BUG_ON(condition) do { if (unlikely((condition)!=0)) BUG(); } while(0) -#endif /* BUG */ - typedef void (interrupt_handler_t)(void *); #include /* boot information for Linux kernel */ diff --git a/include/linux/bug.h b/include/linux/bug.h index 133544ca46f0..f07bb716fc04 100644 --- a/include/linux/bug.h +++ b/include/linux/bug.h @@ -1,6 +1,34 @@ #ifndef _LINUX_BUG_H #define _LINUX_BUG_H +#include /* for panic() */ #include +#include +#include + +#define BUG() do { \ + printk("BUG at %s:%d/%s()!\n", __FILE__, __LINE__, __func__); \ + panic("BUG!"); \ +} while (0) + +#define BUG_ON(condition) do { if (unlikely(condition)) BUG(); } while (0) + +#define WARN_ON(condition) ({ \ + int __ret_warn_on = !!(condition); \ + if (unlikely(__ret_warn_on)) \ + printk("WARNING at %s:%d/%s()!\n", __FILE__, __LINE__, __func__); \ + unlikely(__ret_warn_on); \ +}) + +#define WARN_ON_ONCE(condition) ({ \ + static bool __warned; \ + int __ret_warn_once = !!(condition); \ + \ + if (unlikely(__ret_warn_once && !__warned)) { \ + __warned = true; \ + WARN_ON(1); \ + } \ + unlikely(__ret_warn_once); \ +}) #endif /* _LINUX_BUG_H */ diff --git a/include/linux/compat.h b/include/linux/compat.h index bc027adcb936..1b3f089687e4 100644 --- a/include/linux/compat.h +++ b/include/linux/compat.h @@ -87,21 +87,6 @@ static inline void kmem_cache_destroy(struct kmem_cache *cachep) #define KERNEL_VERSION(a,b,c) (((a) << 16) + ((b) << 8) + (c)) -#ifndef BUG -#define BUG() do { \ - printf("U-Boot BUG at %s:%d!\n", __FILE__, __LINE__); \ -} while (0) - -#define BUG_ON(condition) do { if (condition) BUG(); } while(0) -#endif /* BUG */ - -#define WARN_ON(condition) ({ \ - int __ret_warn_on = !!(condition); \ - if (unlikely(__ret_warn_on)) \ - printf("WARNING in %s line %d\n", __FILE__, __LINE__); \ - unlikely(__ret_warn_on); \ -}) - #define PAGE_SIZE 4096 /* drivers/char/random.c */