9
0
Fork 0

driver: rewrite dev_printf as a function

Printing device context normally should be "driver instance:",
but instead we printed the device name twice. This patch fixes
this and as a bonus makes the binary a bit smaller. Instead of
a '@' between driver and instance this function now prints a
whitespace which is a bit more like Linux.

Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
This commit is contained in:
Sascha Hauer 2012-09-09 11:37:16 +02:00
parent 75265ae527
commit 08a7d5a625
2 changed files with 22 additions and 3 deletions

View File

@ -313,6 +313,25 @@ const char *dev_id(const struct device_d *dev)
return buf;
}
int dev_printf(const struct device_d *dev, const char *format, ...)
{
va_list args;
int ret = 0;
if (dev->driver && dev->driver->name)
ret += printf("%s ", dev->driver->name);
ret += printf("%s: ", dev_name(dev));
va_start(args, format);
ret += vprintf(format, args);
va_end(args);
return ret;
}
void devices_shutdown(void)
{
struct device_d *dev;

View File

@ -333,9 +333,9 @@ static inline int dev_close_default(struct device_d *dev, struct filep *f)
/* debugging and troubleshooting/diagnostic helpers. */
#define dev_printf(dev, format, arg...) \
printf("%s@%s: " format , (dev)->name , \
dev_name(dev) , ## arg)
int dev_printf(const struct device_d *dev, const char *format, ...)
__attribute__ ((format(__printf__, 2, 3)));
#define dev_emerg(dev, format, arg...) \
dev_printf((dev) , format , ## arg)