aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJoe Perches <joe@perches.com>2014-05-20 17:05:50 -0400
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2014-05-28 15:27:22 -0400
commite4ac92df2791c1a3912643e9547941f430fda726 (patch)
tree35972365d5a1bc21456bce200ddae728ab90a831
parent10389e66231f1abdf27caa61b822b59dc2fd86b8 (diff)
serial: samsung: Neaten dbg uses
Add format and argument checking and fix misuses in the dbg macro. Add __printf Use %pR for resource Add #include guard to samsung.h Move static functions from .h to .c Use vscnprintf instead of length unguarded vsprintf Signed-off-by: Joe Perches <joe@perches.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
-rw-r--r--drivers/tty/serial/samsung.c35
-rw-r--r--drivers/tty/serial/samsung.h23
2 files changed, 32 insertions, 26 deletions
diff --git a/drivers/tty/serial/samsung.c b/drivers/tty/serial/samsung.c
index 1f5505e7f90d..329337711bb0 100644
--- a/drivers/tty/serial/samsung.c
+++ b/drivers/tty/serial/samsung.c
@@ -53,6 +53,29 @@
53 53
54#include "samsung.h" 54#include "samsung.h"
55 55
56#if defined(CONFIG_SERIAL_SAMSUNG_DEBUG) && \
57 defined(CONFIG_DEBUG_LL) && \
58 !defined(MODULE)
59
60extern void printascii(const char *);
61
62__printf(1, 2)
63static void dbg(const char *fmt, ...)
64{
65 va_list va;
66 char buff[256];
67
68 va_start(va, fmt);
69 vscnprintf(buff, sizeof(buf), fmt, va);
70 va_end(va);
71
72 printascii(buff);
73}
74
75#else
76#define dbg(fmt, ...) do { if (0) no_printk(fmt, ##__VA_ARGS__); } while (0)
77#endif
78
56/* UART name and device definitions */ 79/* UART name and device definitions */
57 80
58#define S3C24XX_SERIAL_NAME "ttySAC" 81#define S3C24XX_SERIAL_NAME "ttySAC"
@@ -468,8 +491,8 @@ static int s3c24xx_serial_startup(struct uart_port *port)
468 struct s3c24xx_uart_port *ourport = to_ourport(port); 491 struct s3c24xx_uart_port *ourport = to_ourport(port);
469 int ret; 492 int ret;
470 493
471 dbg("s3c24xx_serial_startup: port=%p (%08lx,%p)\n", 494 dbg("s3c24xx_serial_startup: port=%p (%08llx,%p)\n",
472 port->mapbase, port->membase); 495 port, (unsigned long long)port->mapbase, port->membase);
473 496
474 rx_enabled(port) = 1; 497 rx_enabled(port) = 1;
475 498
@@ -514,8 +537,8 @@ static int s3c64xx_serial_startup(struct uart_port *port)
514 struct s3c24xx_uart_port *ourport = to_ourport(port); 537 struct s3c24xx_uart_port *ourport = to_ourport(port);
515 int ret; 538 int ret;
516 539
517 dbg("s3c64xx_serial_startup: port=%p (%08lx,%p)\n", 540 dbg("s3c64xx_serial_startup: port=%p (%08llx,%p)\n",
518 port->mapbase, port->membase); 541 port, (unsigned long long)port->mapbase, port->membase);
519 542
520 wr_regl(port, S3C64XX_UINTM, 0xf); 543 wr_regl(port, S3C64XX_UINTM, 0xf);
521 544
@@ -1160,7 +1183,7 @@ static int s3c24xx_serial_init_port(struct s3c24xx_uart_port *ourport,
1160 return -EINVAL; 1183 return -EINVAL;
1161 } 1184 }
1162 1185
1163 dbg("resource %p (%lx..%lx)\n", res, res->start, res->end); 1186 dbg("resource %pR)\n", res);
1164 1187
1165 port->membase = devm_ioremap(port->dev, res->start, resource_size(res)); 1188 port->membase = devm_ioremap(port->dev, res->start, resource_size(res));
1166 if (!port->membase) { 1189 if (!port->membase) {
@@ -1203,7 +1226,7 @@ static int s3c24xx_serial_init_port(struct s3c24xx_uart_port *ourport,
1203 wr_regl(port, S3C64XX_UINTSP, 0xf); 1226 wr_regl(port, S3C64XX_UINTSP, 0xf);
1204 } 1227 }
1205 1228
1206 dbg("port: map=%08x, mem=%08x, irq=%d (%d,%d), clock=%ld\n", 1229 dbg("port: map=%08x, mem=%p, irq=%d (%d,%d), clock=%u\n",
1207 port->mapbase, port->membase, port->irq, 1230 port->mapbase, port->membase, port->irq,
1208 ourport->rx_irq, ourport->tx_irq, port->uartclk); 1231 ourport->rx_irq, ourport->tx_irq, port->uartclk);
1209 1232
diff --git a/drivers/tty/serial/samsung.h b/drivers/tty/serial/samsung.h
index 8827e5424cef..eb071dd19b2d 100644
--- a/drivers/tty/serial/samsung.h
+++ b/drivers/tty/serial/samsung.h
@@ -1,3 +1,6 @@
1#ifndef __SAMSUNG_H
2#define __SAMSUNG_H
3
1/* 4/*
2 * Driver for Samsung SoC onboard UARTs. 5 * Driver for Samsung SoC onboard UARTs.
3 * 6 *
@@ -77,24 +80,4 @@ struct s3c24xx_uart_port {
77#define wr_regb(port, reg, val) __raw_writeb(val, portaddr(port, reg)) 80#define wr_regb(port, reg, val) __raw_writeb(val, portaddr(port, reg))
78#define wr_regl(port, reg, val) __raw_writel(val, portaddr(port, reg)) 81#define wr_regl(port, reg, val) __raw_writel(val, portaddr(port, reg))
79 82
80#if defined(CONFIG_SERIAL_SAMSUNG_DEBUG) && \
81 defined(CONFIG_DEBUG_LL) && \
82 !defined(MODULE)
83
84extern void printascii(const char *);
85
86static void dbg(const char *fmt, ...)
87{
88 va_list va;
89 char buff[256];
90
91 va_start(va, fmt);
92 vsprintf(buff, fmt, va);
93 va_end(va);
94
95 printascii(buff);
96}
97
98#else
99#define dbg(x...) do { } while (0)
100#endif 83#endif