9
0
Fork 0

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>
This commit is contained in:
Sascha Hauer 2008-10-31 14:02:25 +01:00
parent dff84a5422
commit c3fc1364d9
4 changed files with 56 additions and 9 deletions

View File

@ -33,13 +33,21 @@
#include <linux/kernel.h>
#include <asm/common.h>
#ifdef DEBUG
#define debug(fmt,args...) printf (fmt ,##args)
#define debugX(level,fmt,args...) if (DEBUG>=level) printf(fmt,##args);
#define pr_info(fmt, arg...) printf(fmt, ##arg)
#define pr_notice(fmt, arg...) printf(fmt, ##arg)
#define pr_err(fmt, arg...) printf(fmt, ##arg)
#define pr_warning(fmt, arg...) printf(fmt, ##arg)
#define pr_crit(fmt, arg...) printf(fmt, ##arg)
#define pr_alert(fmt, arg...) printf(fmt, ##arg)
#define pr_emerg(fmt, arg...) printf(fmt, ##arg)
#ifdef DEBUG
#define pr_debug(fmt, arg...) printf(UBOOT_DEBUG, fmt, ##arg)
#else
#define debug(fmt,args...)
#define debugX(level,fmt,args...)
#endif /* DEBUG */
#define pr_debug(fmt, arg...) do {} while(0)
#endif
#define debug(fmt, arg...) pr_debug(fmt, ##arg)
#define BUG() do { \
printf("BUG: failure at %s:%d/%s()!\n", __FILE__, __LINE__, __FUNCTION__); \

View File

@ -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 */

View File

@ -19,7 +19,6 @@
#define KERN_DEBUG "" /* debug-level messages */
#define printk printf
#define dev_dbg(x...)
#define __init
@ -27,6 +26,4 @@
#define MODULE_DESCRIPTION(x)
#define MODULE_LICENSE(x)
#define pr_info printf
#endif /* __INCLUDE_LINUX_U_BOOT_WRAPPER_H */

View File

@ -314,6 +314,18 @@ static int do_devinfo_subtree(struct device_d *dev, int depth, char edge)
return 0;
}
const char *dev_id(const struct device_d *dev)
{
static char buf[sizeof(unsigned long) * 2];
if (strlen(dev->id))
return dev->id;
sprintf(buf, "0x%08x", dev->map_base);
return buf;
}
#ifdef CONFIG_CMD_DEVINFO
static int do_devinfo ( cmd_tbl_t *cmdtp, int argc, char *argv[])