From patchwork Sat Sep 16 05:10:46 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Masahiro Yamada X-Patchwork-Id: 112777 Delivered-To: patch@linaro.org Received: by 10.140.106.117 with SMTP id d108csp1391091qgf; Fri, 15 Sep 2017 22:13:38 -0700 (PDT) X-Google-Smtp-Source: ADKCNb44n/1mreR5c6f2WapqOZe2jDWSryVW1c7kQORAEUxaC9UOAqA1xIP/o5pmLF0kolUVreT7 X-Received: by 10.80.193.146 with SMTP id m18mr23644311edf.110.1505538818482; Fri, 15 Sep 2017 22:13:38 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1505538818; cv=none; d=google.com; s=arc-20160816; b=bSMr8xUlBN3X9gSbAGh259LeJiQPJGVQE/9j5S4kisfDZt9MvGxmVM9BG74bZ9t4FN +ihibv3i6fxyYRPvwI7kF+bhtGyhfzH9TqegWK+fTEVXa24s7p2rKPbSeVcyA1A9rAKG eRC47c2gAQsxrroXg9ebWghw68s1fgzqBo6A49QtsTXZd6paOdNWTEvljT848PdZ71Pg RxjVUYKNEBOHga8fuhptrFbQkSsJAVPaRydDlmUTvWC9D3gf9+VjJJhjfuwqE5xqX1zN 64cAa4NQ7bcrce5kPbBiQGC9W2n+39zaD+TSWmCUkEjWVkAi+4nSXKJWoU8ZS4Sj/pTh vCnA== 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:references:in-reply-to:message-id:date :to:from:dkim-signature:dkim-filter:arc-authentication-results; bh=qgO596d2/3gJKXSuuRiEGSbETX39aLEoCty/zpIi4mU=; b=uN1FODLKgi9eKKNamkuNwmTqh5kFi5jX2bWo5q0faR2Q5K1UHC+vsSduoDOOOgcgQE +QixsywTXJYVTgeHP2gJb+4tfnJCdf3L3FeEKHOSm9oSa29xA+p3Gh9+W+/C4Yhmk4dx gO35wnz3EgNKe29gpHpsgKRnrIxEnmOz9MRzLpjwHzpq4KKvFpBmo65aUaGifExOJaTP mAmdRWbeHNF8aP7GG2f5SLlmA8CfJ6SLvCiSZOZBUQ96rD51qPTA2Uvghfr58n9jWLYL +eZKoxPLDQBJCVChIczAPnqDUz++dnN4h7XOeh1b//6/IDKXTgauj66cdQGWU7Gy6Hfv UC+g== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@nifty.com header.s=dec2015msa header.b=yngVqRMt; 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 b14si2590490edd.163.2017.09.15.22.13.38; Fri, 15 Sep 2017 22:13:38 -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=yngVqRMt; 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 16CF8C21F5B; Sat, 16 Sep 2017 05:12:50 +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 4C9B4C21F77; Sat, 16 Sep 2017 05:11:40 +0000 (UTC) Received: by lists.denx.de (Postfix, from userid 105) id 38DECC21FD4; Sat, 16 Sep 2017 05:11:32 +0000 (UTC) Received: from conuserg-09.nifty.com (conuserg-09.nifty.com [210.131.2.76]) by lists.denx.de (Postfix) with ESMTPS id 9DB57C21F92 for ; Sat, 16 Sep 2017 05:11:27 +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 v8G5Asos028761; Sat, 16 Sep 2017 14:10:59 +0900 DKIM-Filter: OpenDKIM Filter v2.10.3 conuserg-09.nifty.com v8G5Asos028761 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nifty.com; s=dec2015msa; t=1505538660; bh=AYeozuhoNOpQYKSVFS8NvnkYBU+utfvaBBytcrX7L50=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=yngVqRMtffU7k6sVY0z/zEnDSUOmTOu+Nd+MxWNl+vhWBDGbnWZhwoYHDJDO30ZHe W/oDH7SllimaIJnVQE3/smjcmEShEMuDEXQS6vnxmaKcER2ZKdbiucwZIaCoFvI8T+ Z2StkWTvWaZytZGbyN4yxNF4XQV7bVFAGZHk7XGboQU9MmIY9hL+pBMFZcR7VG+TK0 OjqgHn/8cH2hCPaW/H98yWi+dG7upFiXpS7SFuOJgW8Csxbh+UFD8M+Qj4Buo38sGt NbZwpA15isIqJPNnwMyB4VBmz8ET7ePsk0hrRPRry64U30Sw2BBNkAKRANfuo+RQKU ZL5tXRK5nWdUQ== X-Nifty-SrcIP: [122.131.185.176] From: Masahiro Yamada To: u-boot@lists.denx.de Date: Sat, 16 Sep 2017 14:10:46 +0900 Message-Id: <1505538646-19191-9-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> Subject: [U-Boot] [PATCH v2 8/8] dm: define dev_*() log functions in DM header 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" Many drivers use dev_err, dev_info, etc. for logging. Currently, we are relying on , but I guess the best home is , taking into account that Linux defines them in . For now, I am keeping the ones in because lots of Linux-originated code uses dev_*() just for the purpose of syncing, but the first argument is not struct udevice, so we need to ignore it. Once this issue is ironed out, it would be possible to prefix log messages with a device name that emitted it, like Linux. Signed-off-by: Masahiro Yamada Reviewed-by: Simon Glass --- Changes in v2: - newly added include/dm/device.h | 72 ++++++++++++++++++++++++++++++++++++++++++++++++++ include/linux/compat.h | 17 ++++++++++++ 2 files changed, 89 insertions(+) diff --git a/include/dm/device.h b/include/dm/device.h index 4866f7c0028b..cce60b7ed3fd 100644 --- a/include/dm/device.h +++ b/include/dm/device.h @@ -18,6 +18,7 @@ #include #include #include +#include struct driver_info; @@ -879,4 +880,75 @@ static inline void devm_kfree(struct udevice *dev, void *ptr) #endif /* ! CONFIG_DEVRES */ +/* + * REVISIT: + * remove the following after resolving conflicts with + */ +#ifdef dev_dbg +#undef dev_dbg +#endif +#ifdef dev_vdbg +#undef dev_vdbg +#endif +#ifdef dev_info +#undef dev_info +#endif +#ifdef dev_err +#undef dev_err +#endif +#ifdef dev_warn +#undef dev_warn +#endif + +/* + * REVISIT: + * print device name like Linux + */ +#define dev_printk(dev, fmt, ...) \ +({ \ + printk(fmt, ##__VA_ARGS__); \ +}) + +#define __dev_printk(level, dev, fmt, ...) \ +({ \ + if (level < CONFIG_LOGLEVEL) \ + dev_printk(dev, fmt, ##__VA_ARGS__); \ +}) + +#define dev_emerge(dev, fmt, ...) \ + __dev_printk(0, dev, fmt, ##__VA_ARGS__) +#define dev_alert(dev, fmt, ...) \ + __dev_printk(1, dev, fmt, ##__VA_ARGS__) +#define dev_crit(dev, fmt, ...) \ + __dev_printk(2, dev, fmt, ##__VA_ARGS__) +#define dev_err(dev, fmt, ...) \ + __dev_printk(3, dev, fmt, ##__VA_ARGS__) +#define dev_warn(dev, fmt, ...) \ + __dev_printk(4, dev, fmt, ##__VA_ARGS__) +#define dev_notice(dev, fmt, ...) \ + __dev_printk(5, dev, fmt, ##__VA_ARGS__) +#define dev_info(dev, fmt, ...) \ + __dev_printk(6, dev, fmt, ##__VA_ARGS__) + +#ifdef DEBUG +#define dev_dbg(dev, fmt, ...) \ + __dev_printk(7, dev, fmt, ##__VA_ARGS__) +#else +#define dev_dbg(dev, fmt, ...) \ +({ \ + if (0) \ + __dev_printk(7, dev, fmt, ##__VA_ARGS__); \ +}) +#endif + +#ifdef VERBOSE_DEBUG +#define dev_vdbg dev_dbg +#else +#define dev_vdbg(dev, fmt, ...) \ +({ \ + if (0) \ + __dev_printk(7, dev, fmt, ##__VA_ARGS__); \ +}) +#endif + #endif diff --git a/include/linux/compat.h b/include/linux/compat.h index 1b3f089687e4..8711fe2b48c4 100644 --- a/include/linux/compat.h +++ b/include/linux/compat.h @@ -15,6 +15,23 @@ struct p_current{ extern struct p_current *current; +/* avoid conflict with */ +#ifdef dev_dbg +#undef dev_dbg +#endif +#ifdef dev_vdbg +#undef dev_vdbg +#endif +#ifdef dev_info +#undef dev_info +#endif +#ifdef dev_err +#undef dev_err +#endif +#ifdef dev_warn +#undef dev_warn +#endif + #define dev_dbg(dev, fmt, args...) \ debug(fmt, ##args) #define dev_vdbg(dev, fmt, args...) \