[RFCv4 12/24] fotg210: dbg_status() rewrite for dynamic debug

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



From: Oliver Neukum <oneukum@xxxxxxx>

The expensive evaluation should be done only if a message is
actually to be printed.

Signed-off-by: Oliver Neukum <oneukum2suse.de>
---
 drivers/usb/host/fotg210-hcd.c | 12 ++++++------
 1 file changed, 6 insertions(+), 6 deletions(-)

diff --git a/drivers/usb/host/fotg210-hcd.c b/drivers/usb/host/fotg210-hcd.c
index 4b3922d..e0f2c33 100644
--- a/drivers/usb/host/fotg210-hcd.c
+++ b/drivers/usb/host/fotg210-hcd.c
@@ -199,10 +199,10 @@ dbg_itd(const char *label, struct fotg210_hcd *fotg210, struct fotg210_itd *itd)
 		itd->index[6], itd->index[7]);
 }
 
-static int __maybe_unused
-dbg_status_buf(char *buf, unsigned len, const char *label, u32 status)
+static char
+*dbg_status_buf(char *buf, unsigned len, const char *label, u32 status)
 {
-	return scnprintf(buf, len,
+	scnprintf(buf, len,
 		"%s%sstatus %04x%s%s%s%s%s%s%s%s%s%s",
 		label, label[0] ? " " : "", status,
 		(status & STS_ASS) ? " Async" : "",
@@ -216,6 +216,7 @@ dbg_status_buf(char *buf, unsigned len, const char *label, u32 status)
 		(status & STS_ERR) ? " ERR" : "",
 		(status & STS_INT) ? " INT" : ""
 		);
+	return buf;
 }
 
 static int __maybe_unused
@@ -294,8 +295,7 @@ static char
 /* functions have the "wrong" filename when they're output... */
 #define dbg_status(fotg210, label, status) { \
 	char _buf[80]; \
-	dbg_status_buf(_buf, sizeof(_buf), label, status); \
-	fotg210_dbg(fotg210, "%s\n", _buf); \
+	fotg210_dbg(fotg210, "%s\n", dbg_status_buf(_buf, sizeof(_buf), label, status)); \
 }
 
 #define dbg_cmd(fotg210, label, command) { \
@@ -722,7 +722,7 @@ static ssize_t fill_registers_buffer(struct debug_buffer *buf)
 	next += temp;
 
 	/* Operational Registers */
-	temp = dbg_status_buf(scratch, sizeof(scratch), label,
+	dbg_status_buf(scratch, sizeof(scratch), label,
 			fotg210_readl(fotg210, &fotg210->regs->status));
 	temp = scnprintf(next, size, fmt, temp, scratch);
 	size -= temp;
-- 
1.8.3.1

--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html




[Index of Archives]     [Linux Media]     [Linux Input]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]     [Old Linux USB Devel Archive]

  Powered by Linux