summaryrefslogtreecommitdiffstats
path: root/include/driver.h
diff options
context:
space:
mode:
authorSascha Hauer <s.hauer@pengutronix.de>2008-10-31 14:02:25 +0100
committerSascha Hauer <s.hauer@pengutronix.de>2008-10-31 14:02:25 +0100
commitc3fc1364d9ed508a59bc2127c04d7239e30d148a (patch)
tree44b43ff8a77ae69ff4ec98e3216de54d79dec6c8 /include/driver.h
parentdff84a542281c46076a0c8c5f589b1df4777ade8 (diff)
downloadbarebox-c3fc1364d9ed508a59bc2127c04d7239e30d148a.tar.gz
barebox-c3fc1364d9ed508a59bc2127c04d7239e30d148a.tar.xz
Introduce dev_* and pr_* functions
Proven to be useful in linux kernel, U-Boot should have such a thing aswell. We do not distinguish between the various print levels others than debug and not debug. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
Diffstat (limited to 'include/driver.h')
-rw-r--r--include/driver.h30
1 files changed, 30 insertions, 0 deletions
diff --git a/include/driver.h b/include/driver.h
index d4e7c132c9..45097a3c05 100644
--- a/include/driver.h
+++ b/include/driver.h
@@ -263,5 +263,35 @@ static inline int dev_close_default(struct device_d *dev, struct filep *f)
return 0;
}
+/* debugging and troubleshooting/diagnostic helpers. */
+extern const char *dev_id(const struct device_d *dev);
+
+#define dev_printf(dev, format, arg...) \
+ printf("%s@%s: " format , dev->name , \
+ dev_id(dev) , ## arg)
+
+#define dev_emerg(dev, format, arg...) \
+ dev_printf(dev , format , ## arg)
+#define dev_alert(dev, format, arg...) \
+ dev_printf(dev , format , ## arg)
+#define dev_crit(dev, format, arg...) \
+ dev_printf(dev , format , ## arg)
+#define dev_err(dev, format, arg...) \
+ dev_printf(dev , format , ## arg)
+#define dev_warn(dev, format, arg...) \
+ dev_printf(dev , format , ## arg)
+#define dev_notice(dev, format, arg...) \
+ dev_printf(dev , format , ## arg)
+#define dev_info(dev, format, arg...) \
+ dev_printf(dev , format , ## arg)
+
+#if defined(DEBUG)
+#define dev_dbg(dev, format, arg...) \
+ dev_printf(dev , format , ## arg)
+#else
+#define dev_dbg(dev, format, arg...) \
+ ({ if (0) dev_printf(dev, format, ##arg); 0; })
+#endif
+
#endif /* DRIVER_H */