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:
parent
75265ae527
commit
08a7d5a625
|
@ -313,6 +313,25 @@ const char *dev_id(const struct device_d *dev)
|
||||||
return buf;
|
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)
|
void devices_shutdown(void)
|
||||||
{
|
{
|
||||||
struct device_d *dev;
|
struct device_d *dev;
|
||||||
|
|
|
@ -333,9 +333,9 @@ static inline int dev_close_default(struct device_d *dev, struct filep *f)
|
||||||
|
|
||||||
/* debugging and troubleshooting/diagnostic helpers. */
|
/* debugging and troubleshooting/diagnostic helpers. */
|
||||||
|
|
||||||
#define dev_printf(dev, format, arg...) \
|
int dev_printf(const struct device_d *dev, const char *format, ...)
|
||||||
printf("%s@%s: " format , (dev)->name , \
|
__attribute__ ((format(__printf__, 2, 3)));
|
||||||
dev_name(dev) , ## arg)
|
|
||||||
|
|
||||||
#define dev_emerg(dev, format, arg...) \
|
#define dev_emerg(dev, format, arg...) \
|
||||||
dev_printf((dev) , format , ## arg)
|
dev_printf((dev) , format , ## arg)
|
||||||
|
|
Loading…
Reference in New Issue