mail archive of the barebox mailing list
 help / color / mirror / Atom feed
From: Sascha Hauer <s.hauer@pengutronix.de>
To: barebox@lists.infradead.org
Subject: [PATCH 4/5] driver: rewrite dev_printf as a function
Date: Tue, 11 Sep 2012 15:31:52 +0200	[thread overview]
Message-ID: <1347370313-15184-5-git-send-email-s.hauer@pengutronix.de> (raw)
In-Reply-To: <1347370313-15184-1-git-send-email-s.hauer@pengutronix.de>

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>
---
 drivers/base/driver.c |   19 +++++++++++++++++++
 include/driver.h      |    6 +++---
 2 files changed, 22 insertions(+), 3 deletions(-)

diff --git a/drivers/base/driver.c b/drivers/base/driver.c
index 6cd4286..47d3803 100644
--- a/drivers/base/driver.c
+++ b/drivers/base/driver.c
@@ -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;
diff --git a/include/driver.h b/include/driver.h
index 0fecc7a..c74f245 100644
--- a/include/driver.h
+++ b/include/driver.h
@@ -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)
-- 
1.7.10.4


_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

  parent reply	other threads:[~2012-09-11 13:32 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-09-11 13:31 [PATCH] device/driver work Sascha Hauer
2012-09-11 13:31 ` [PATCH 1/5] mfd mc13xxx: Separate I2C and SPI probe Sascha Hauer
2012-09-11 13:31 ` [PATCH 2/5] SPI: Put SPI devices on their own bus bus Sascha Hauer
2012-09-11 14:03   ` Jean-Christophe PLAGNIOL-VILLARD
2012-09-11 14:26     ` Sascha Hauer
2012-09-11 13:31 ` [PATCH 3/5] I2C: Put I2C devices on their own bus Sascha Hauer
2012-09-11 14:04   ` Jean-Christophe PLAGNIOL-VILLARD
2012-09-11 14:27     ` Sascha Hauer
2012-09-11 15:56       ` Jean-Christophe PLAGNIOL-VILLARD
2012-09-11 16:10         ` Sascha Hauer
2012-09-11 17:24           ` Jean-Christophe PLAGNIOL-VILLARD
2012-09-12  6:47             ` Sascha Hauer
2012-09-11 13:31 ` Sascha Hauer [this message]
2012-09-11 13:31 ` [PATCH 5/5] driver: Add platform_device_id mechanism Sascha Hauer

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1347370313-15184-5-git-send-email-s.hauer@pengutronix.de \
    --to=s.hauer@pengutronix.de \
    --cc=barebox@lists.infradead.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox