public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] usb: gadget: s3c2410_udc: Remove static char buffer, use vsprintf extension %pV
@ 2015-03-27  5:43 Joe Perches
  0 siblings, 0 replies; only message in thread
From: Joe Perches @ 2015-03-27  5:43 UTC (permalink / raw)
  To: Arnaud Patard; +Cc: Felipe Balbi, Greg Kroah-Hartman, linux-usb, linux-kernel

Using unnecessary static char buffers isn't good.
Use the %pV extension instead.

Miscellanea:

o the dprintk return value is unused, make it void
o add __printf format and argument verification

Signed-off-by: Joe Perches <joe@perches.com>
---
This doesn't matter much as it is pretty unusual to enable
printk support and CONFIG_USB_S3C2410_DEBUG for this board.

This is just for completeness.

Compiled with and without printk support, but otherwise untested.

 drivers/usb/gadget/udc/s3c2410_udc.c | 28 +++++++++++++---------------
 1 file changed, 13 insertions(+), 15 deletions(-)

diff --git a/drivers/usb/gadget/udc/s3c2410_udc.c b/drivers/usb/gadget/udc/s3c2410_udc.c
index b808951..2979575 100644
--- a/drivers/usb/gadget/udc/s3c2410_udc.c
+++ b/drivers/usb/gadget/udc/s3c2410_udc.c
@@ -92,40 +92,38 @@ static struct s3c2410_udc_mach_info *udc_info;
 
 static uint32_t s3c2410_ticks = 0;
 
-static int dprintk(int level, const char *fmt, ...)
+__printf(2, 3)
+static void dprintk(int level, const char *fmt, ...)
 {
-	static char printk_buf[1024];
 	static long prevticks;
 	static int invocation;
+	struct va_format vaf;
 	va_list args;
-	int len;
 
 	if (level > USB_S3C2410_DEBUG_LEVEL)
-		return 0;
+		return;
+
+	va_start(args, fmt);
+
+	vaf.fmt = fmt;
+	vaf.va = &args;
 
 	if (s3c2410_ticks != prevticks) {
 		prevticks = s3c2410_ticks;
 		invocation = 0;
 	}
 
-	len = scnprintf(printk_buf,
-			sizeof(printk_buf), "%1lu.%02d USB: ",
-			prevticks, invocation++);
+	pr_debug("%1lu.%02d USB: %pV", prevticks, invocation++, &vaf);
 
-	va_start(args, fmt);
-	len = vscnprintf(printk_buf+len,
-			sizeof(printk_buf)-len, fmt, args);
 	va_end(args);
-
-	pr_debug("%s", printk_buf);
-	return len;
 }
 #else
-static int dprintk(int level, const char *fmt, ...)
+__printf(2, 3)
+static void dprintk(int level, const char *fmt, ...)
 {
-	return 0;
 }
 #endif
+
 static int s3c2410_udc_debugfs_seq_show(struct seq_file *m, void *p)
 {
 	u32 addr_reg, pwr_reg, ep_int_reg, usb_int_reg;



^ permalink raw reply related	[flat|nested] only message in thread

only message in thread, other threads:[~2015-03-27  5:43 UTC | newest]

Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-03-27  5:43 [PATCH] usb: gadget: s3c2410_udc: Remove static char buffer, use vsprintf extension %pV Joe Perches

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox