From patchwork Tue Sep 26 02:58:29 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Masahiro Yamada X-Patchwork-Id: 114210 Delivered-To: patch@linaro.org Received: by 10.140.106.117 with SMTP id d108csp3325746qgf; Mon, 25 Sep 2017 19:59:37 -0700 (PDT) X-Google-Smtp-Source: AOwi7QAw/nLeX7EDARlken3rYahGSe4cYq3FwVkN1FOyAa1Ui1+920ofWLEbVPmJnPlK8J6EFjqz X-Received: by 10.80.163.248 with SMTP id t53mr15804335edb.160.1506394777150; Mon, 25 Sep 2017 19:59:37 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1506394777; cv=none; d=google.com; s=arc-20160816; b=C8O5AXwFF9drOsxo7XXAWnsVt5kJ3C86dk6oTAUTrnuFNP0w2+/EbHSJNSKJq7pt6R vSioqvk04iVBH1vf5kXdL5kwpDy+ZohmwSieFQ/W0dkqjT06ykwa9Zy6ELqOV/DxGQsC bw9+aWuMX7TvfCj/3fSl+vAWlGqfPAwAPG3FgvjMj3x9Qfc0o7Tb5UUXXKcdlfcbozj8 q2hDS0qD0L8LLYwKBelpoMJdzLxqwK5cRRRQuj+fB8OfeVOmKgY5T0prpkDUsf3457PX /1xwIc7LJ6MOwbAUWfb3/Efl8dr924zoQ2A35oiJY+kKe//pgNzj5jhHCxrfh2PmqSzx rj3Q== 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:message-id:date:to:from :dkim-signature:dkim-filter:arc-authentication-results; bh=J3qZ0cEiIUJutmmGZl5OA2s9erPPelH/l21eoaxYxuY=; b=n3PNql7dZcLS7zZ1k4Pt/6QAzoZarBTVFsu6YA7OfWNE1i7wUini8Ae9ygl2mw24+I LjCmZ/eKUEsucoYM82g7bVGzHkQ7QVup6E+7Uf3UeCX37YnGTyh3tDhKIeilg0SvnKfl k1XtACa92dQ/dRTrXnLf3TAnziYecI6AZskw00rFeDepVPgV2QLHN4CncdUi8hlPjoOd S9KeaO8qA9KGWHZnBXloRhq2yz2P51LzEP+se0Cs/qnQrTYsxndtu9BP5+ZLilJua5A6 ApOsvSEhFt0tF9bpI2nHgcq3qwhWq2QDximoWWPBha739Ve0LHaJ4VyUbBtXniCxfhAP wf5g== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@nifty.com header.s=dec2015msa header.b=Y2RQVTuf; 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 j33si6342710edb.403.2017.09.25.19.59.36; Mon, 25 Sep 2017 19:59:37 -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=Y2RQVTuf; 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 EAD54C21E68; Tue, 26 Sep 2017 02:59:35 +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 2A45DC21CA5; Tue, 26 Sep 2017 02:59:33 +0000 (UTC) Received: by lists.denx.de (Postfix, from userid 105) id DAC73C21CA5; Tue, 26 Sep 2017 02:59:31 +0000 (UTC) Received: from conuserg-12.nifty.com (conuserg-12.nifty.com [210.131.2.79]) by lists.denx.de (Postfix) with ESMTPS id 9573EC21C71 for ; Tue, 26 Sep 2017 02:59:30 +0000 (UTC) Received: from pug.e01.socionext.com (p14092-ipngnfx01kyoto.kyoto.ocn.ne.jp [153.142.97.92]) (authenticated) by conuserg-12.nifty.com with ESMTP id v8Q2wdkD000843; Tue, 26 Sep 2017 11:58:40 +0900 DKIM-Filter: OpenDKIM Filter v2.10.3 conuserg-12.nifty.com v8Q2wdkD000843 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nifty.com; s=dec2015msa; t=1506394720; bh=4nlKqfTWVA75JAcrh5sXAZGrVerBAJlj4VvcDwFkAXM=; h=From:To:Cc:Subject:Date:From; b=Y2RQVTufeY8vsLo2j2JqrcIOY7zYq2n41XAbGU+LwzQPpUVZ7cJSgyrEn27fvFffl jq6qIi6L5GLPMYn5OMNlqYBTeyYM/vYXrueSM06YNj5I26oGZsViItsO1eHmuIYeQs ugUDQ572wlrEEbo1GktOX8/WBraiztDbs9yEb45xoKIEyj0COx9TM2lPgYgzOXXye1 8F3T4IFY+GgLPrycccDBb5pBhOp3drCzbwyd09UNvgY+lxGpzOmcmnqOs+hcDde22h AxcehUQv5Uowaxg99RTAeHRyw1oKRIN+zgpTyp18J2YZWDE0MHSoPAAJo0fSeNwggL oEntQujFElatg== X-Nifty-SrcIP: [153.142.97.92] From: Masahiro Yamada To: u-boot@lists.denx.de Date: Tue, 26 Sep 2017 11:58:29 +0900 Message-Id: <1506394709-16899-1-git-send-email-yamada.masahiro@socionext.com> X-Mailer: git-send-email 2.7.4 Cc: Tom Rini Subject: [U-Boot] [PATCH v3 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 had started to use dev_err, dev_info, etc. for log functions. Currently, we are relying on , but I guess the best home is , taking into account that Linux defines them in . For now, I am leaving the ones in because lots of Linux-originated code uses dev_*(), but the first argument is not struct udevice, so we need to ignore the bogus argument. More efforts are needed to iron out the issues. Signed-off-by: Masahiro Yamada Reviewed-by: Simon Glass --- Changes in v3: - Rename dev_emerge to dev_emerg to adjust to Linux 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 4866f7c..813e49f 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_VAL(LOGLEVEL)) \ + dev_printk(dev, fmt, ##__VA_ARGS__); \ +}) + +#define dev_emerg(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 1b3f089..8711fe2 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...) \