This new dbg() macro has the following features:
o Adds a '[USBSERIAL]' prefix to every debug message, that way usbserial
debug messages are not mixed up with other debug messages like kernel
timming information
o Also prints the function name (__FUNCTION__), that way dbg() calls
doesn't need to pass __FUNCTION__ as a parameter
Aditionally, the usb-serial and pl2303 drivers are ported to the new
interface.
Signed-off-by: Luiz Fernando N. Capitulino <[EMAIL PROTECTED]>
---
drivers/usb/serial/pl2303.c | 88 ++++++++++++++++++++-------------------
drivers/usb/serial/usb-serial.c | 64 ++++++++++++++--------------
drivers/usb/serial/usb-serial.h | 8 ++--
3 files changed, 81 insertions(+), 79 deletions(-)
diff --git a/drivers/usb/serial/pl2303.c b/drivers/usb/serial/pl2303.c
index c96714b..f9300b8 100644
--- a/drivers/usb/serial/pl2303.c
+++ b/drivers/usb/serial/pl2303.c
@@ -253,7 +253,7 @@ static int set_control_lines (struct usb
retval = usb_control_msg (dev, usb_sndctrlpipe (dev, 0),
SET_CONTROL_REQUEST, SET_CONTROL_REQUEST_TYPE,
value, 0, NULL, 0, 100);
- dbg("%s - value = %d, retval = %d", __FUNCTION__, value, retval);
+ dbg("value = %d, retval = %d", value, retval);
return retval;
}
@@ -262,7 +262,7 @@ static int pl2303_write (struct usb_seri
struct pl2303_private *priv = usb_get_serial_port_data(port);
unsigned long flags;
- dbg("%s - port %d, %d bytes", __FUNCTION__, port->number, count);
+ dbg("port %d, %d bytes", port->number, count);
if (!count)
return count;
@@ -282,7 +282,7 @@ static void pl2303_send(struct usb_seria
struct pl2303_private *priv = usb_get_serial_port_data(port);
unsigned long flags;
- dbg("%s - port %d", __FUNCTION__, port->number);
+ dbg("port %d", port->number);
spin_lock_irqsave(&priv->lock, flags);
@@ -323,13 +323,13 @@ static int pl2303_write_room(struct usb_
int room = 0;
unsigned long flags;
- dbg("%s - port %d", __FUNCTION__, port->number);
+ dbg("port %d", port->number);
spin_lock_irqsave(&priv->lock, flags);
room = pl2303_buf_space_avail(priv->buf);
spin_unlock_irqrestore(&priv->lock, flags);
- dbg("%s - returns %d", __FUNCTION__, room);
+ dbg("returns %d", room);
return room;
}
@@ -339,13 +339,13 @@ static int pl2303_chars_in_buffer(struct
int chars = 0;
unsigned long flags;
- dbg("%s - port %d", __FUNCTION__, port->number);
+ dbg("port %d", port->number);
spin_lock_irqsave(&priv->lock, flags);
chars = pl2303_buf_data_avail(priv->buf);
spin_unlock_irqrestore(&priv->lock, flags);
- dbg("%s - returns %d", __FUNCTION__, chars);
+ dbg("returns %d", chars);
return chars;
}
@@ -360,10 +360,10 @@ static void pl2303_set_termios (struct u
int i;
u8 control;
- dbg("%s - port %d", __FUNCTION__, port->number);
+ dbg("port %d", port->number);
if ((!port->tty) || (!port->tty->termios)) {
- dbg("%s - no tty structures", __FUNCTION__);
+ dbg("no tty structures");
return;
}
@@ -380,7 +380,7 @@ static void pl2303_set_termios (struct u
if (old_termios) {
if ((cflag == old_termios->c_cflag) &&
(RELEVANT_IFLAG(port->tty->termios->c_iflag) ==
RELEVANT_IFLAG(old_termios->c_iflag))) {
- dbg("%s - nothing to change...", __FUNCTION__);
+ dbg("nothing to change...");
return;
}
}
@@ -406,7 +406,7 @@ static void pl2303_set_termios (struct u
default:
case CS8: buf[6] = 8; break;
}
- dbg("%s - data bits = %d", __FUNCTION__, buf[6]);
+ dbg("data bits = %d", buf[6]);
}
baud = 0;
@@ -431,7 +431,7 @@ static void pl2303_set_termios (struct u
dev_err(&port->dev, "pl2303 driver does not support the
baudrate requested (fix it)\n");
break;
}
- dbg("%s - baud = %d", __FUNCTION__, baud);
+ dbg("baud = %d", baud);
if (baud) {
buf[0] = baud & 0xff;
buf[1] = (baud >> 8) & 0xff;
@@ -444,10 +444,10 @@ static void pl2303_set_termios (struct u
/* For reference buf[4]=2 is 2 stop bits */
if (cflag & CSTOPB) {
buf[4] = 2;
- dbg("%s - stop bits = 2", __FUNCTION__);
+ dbg("stop bits = 2");
} else {
buf[4] = 0;
- dbg("%s - stop bits = 1", __FUNCTION__);
+ dbg("stop bits = 1");
}
if (cflag & PARENB) {
@@ -458,14 +458,14 @@ static void pl2303_set_termios (struct u
/* For reference buf[5]=4 is space parity */
if (cflag & PARODD) {
buf[5] = 1;
- dbg("%s - parity = odd", __FUNCTION__);
+ dbg("parity = odd");
} else {
buf[5] = 2;
- dbg("%s - parity = even", __FUNCTION__);
+ dbg("parity = even");
}
} else {
buf[5] = 0;
- dbg("%s - parity = none", __FUNCTION__);
+ dbg("parity = none");
}
i = usb_control_msg (serial->dev, usb_sndctrlpipe (serial->dev, 0),
@@ -521,7 +521,7 @@ static int pl2303_open (struct usb_seria
unsigned char *buf;
int result;
- dbg("%s - port %d", __FUNCTION__, port->number);
+ dbg("port %d", port->number);
if (priv->type != HX) {
usb_clear_halt(serial->dev, port->write_urb->pipe);
@@ -572,7 +572,7 @@ #define SOUP(a,b,c,d)
\
//FIXME: need to assert RTS and DTR if CRTSCTS off
- dbg("%s - submitting read urb", __FUNCTION__);
+ dbg("submitting read urb");
port->read_urb->dev = serial->dev;
result = usb_submit_urb (port->read_urb, GFP_KERNEL);
if (result) {
@@ -581,7 +581,7 @@ #define SOUP(a,b,c,d)
\
return -EPROTO;
}
- dbg("%s - submitting interrupt urb", __FUNCTION__);
+ dbg("submitting interrupt urb");
port->interrupt_in_urb->dev = serial->dev;
result = usb_submit_urb (port->interrupt_in_urb, GFP_KERNEL);
if (result) {
@@ -602,7 +602,7 @@ static void pl2303_close (struct usb_ser
long timeout;
wait_queue_t wait; \
- dbg("%s - port %d", __FUNCTION__, port->number);
+ dbg("port %d", port->number);
/* wait for data to drain from the buffer */
spin_lock_irqsave(&priv->lock, flags);
@@ -640,7 +640,7 @@ static void pl2303_close (struct usb_ser
schedule_timeout_interruptible(timeout);
/* shutdown our urbs */
- dbg("%s - shutting down urbs", __FUNCTION__);
+ dbg("shutting down urbs");
usb_kill_urb(port->write_urb);
usb_kill_urb(port->read_urb);
usb_kill_urb(port->interrupt_in_urb);
@@ -690,7 +690,7 @@ static int pl2303_tiocmget (struct usb_s
unsigned int status;
unsigned int result;
- dbg("%s (%d)", __FUNCTION__, port->number);
+ dbg("(%d)", port->number);
if (!usb_get_intfdata(port->serial->interface))
return -ENODEV;
@@ -707,7 +707,7 @@ static int pl2303_tiocmget (struct usb_s
| ((status & UART_RING) ? TIOCM_RI : 0)
| ((status & UART_DCD) ? TIOCM_CD : 0);
- dbg("%s - result = %x", __FUNCTION__, result);
+ dbg("result = %x", result);
return result;
}
@@ -750,15 +750,15 @@ static int wait_modem_info(struct usb_se
static int pl2303_ioctl (struct usb_serial_port *port, struct file *file,
unsigned int cmd, unsigned long arg)
{
- dbg("%s (%d) cmd = 0x%04x", __FUNCTION__, port->number, cmd);
+ dbg("(%d) cmd = 0x%04x", port->number, cmd);
switch (cmd) {
case TIOCMIWAIT:
- dbg("%s (%d) TIOCMIWAIT", __FUNCTION__, port->number);
+ dbg("(%d) TIOCMIWAIT", port->number);
return wait_modem_info(port, arg);
default:
- dbg("%s not supported = 0x%04x", __FUNCTION__, cmd);
+ dbg("not supported = 0x%04x", cmd);
break;
}
@@ -771,19 +771,19 @@ static void pl2303_break_ctl (struct usb
u16 state;
int result;
- dbg("%s - port %d", __FUNCTION__, port->number);
+ dbg("port %d", port->number);
if (break_state == 0)
state = BREAK_OFF;
else
state = BREAK_ON;
- dbg("%s - turning break %s", __FUNCTION__, state==BREAK_OFF ? "off" :
"on");
+ dbg("turning break %s", state==BREAK_OFF ? "off" : "on");
result = usb_control_msg (serial->dev, usb_sndctrlpipe (serial->dev, 0),
BREAK_REQUEST, BREAK_REQUEST_TYPE, state,
0, NULL, 0, 100);
if (result)
- dbg("%s - error sending break = %d", __FUNCTION__, result);
+ dbg("error sending break = %d", result);
}
@@ -792,7 +792,7 @@ static void pl2303_shutdown (struct usb_
int i;
struct pl2303_private *priv;
- dbg("%s", __FUNCTION__);
+ dbg("");
for (i = 0; i < serial->num_ports; ++i) {
priv = usb_get_serial_port_data(serial->port[i]);
@@ -842,7 +842,7 @@ static void pl2303_read_int_callback (st
unsigned int actual_length = urb->actual_length;
int status;
- dbg("%s (%d)", __FUNCTION__, port->number);
+ dbg("(%d)", port->number);
switch (urb->status) {
case 0:
@@ -852,10 +852,10 @@ static void pl2303_read_int_callback (st
case -ENOENT:
case -ESHUTDOWN:
/* this urb is terminated, clean up */
- dbg("%s - urb shutting down with status: %d", __FUNCTION__,
urb->status);
+ dbg("urb shutting down with status: %d", urb->status);
return;
default:
- dbg("%s - nonzero urb status received: %d", __FUNCTION__,
urb->status);
+ dbg("nonzero urb status received: %d", urb->status);
goto exit;
}
@@ -882,17 +882,17 @@ static void pl2303_read_bulk_callback (s
u8 status;
char tty_flag;
- dbg("%s - port %d", __FUNCTION__, port->number);
+ dbg("port %d", port->number);
if (urb->status) {
- dbg("%s - urb->status = %d", __FUNCTION__, urb->status);
+ dbg("urb->status = %d", urb->status);
if (!port->open_count) {
- dbg("%s - port is closed, exiting.", __FUNCTION__);
+ dbg("port is closed, exiting.");
return;
}
if (urb->status == -EPROTO) {
/* PL2303 mysteriously fails with -EPROTO reschedule
the read */
- dbg("%s - caught -EPROTO, resubmitting the urb",
__FUNCTION__);
+ dbg("caught -EPROTO, resubmitting the urb");
urb->status = 0;
urb->dev = port->serial->dev;
result = usb_submit_urb(urb, GFP_ATOMIC);
@@ -900,7 +900,7 @@ static void pl2303_read_bulk_callback (s
dev_err(&urb->dev->dev, "%s - failed
resubmitting read urb, error %d\n", __FUNCTION__, result);
return;
}
- dbg("%s - unable to handle the error, exiting.", __FUNCTION__);
+ dbg("unable to handle the error, exiting.");
return;
}
@@ -923,7 +923,7 @@ static void pl2303_read_bulk_callback (s
tty_flag = TTY_PARITY;
else if (status & UART_FRAME_ERROR)
tty_flag = TTY_FRAME;
- dbg("%s - tty_flag = %d", __FUNCTION__, tty_flag);
+ dbg("tty_flag = %d", tty_flag);
tty = port->tty;
if (tty && urb->actual_length) {
@@ -955,7 +955,7 @@ static void pl2303_write_bulk_callback (
struct pl2303_private *priv = usb_get_serial_port_data(port);
int result;
- dbg("%s - port %d", __FUNCTION__, port->number);
+ dbg("port %d", port->number);
switch (urb->status) {
case 0:
@@ -965,13 +965,13 @@ static void pl2303_write_bulk_callback (
case -ENOENT:
case -ESHUTDOWN:
/* this urb is terminated, clean up */
- dbg("%s - urb shutting down with status: %d", __FUNCTION__,
urb->status);
+ dbg("urb shutting down with status: %d", urb->status);
priv->write_urb_in_use = 0;
return;
default:
/* error in the urb, so we have to resubmit it */
- dbg("%s - Overflow in write", __FUNCTION__);
- dbg("%s - nonzero write bulk status received: %d",
__FUNCTION__, urb->status);
+ dbg("Overflow in write");
+ dbg("nonzero write bulk status received: %d", urb->status);
port->write_urb->transfer_buffer_length = 1;
port->write_urb->dev = port->serial->dev;
result = usb_submit_urb (port->write_urb, GFP_ATOMIC);
diff --git a/drivers/usb/serial/usb-serial.c b/drivers/usb/serial/usb-serial.c
index 9c36f0e..9fa08c9 100644
--- a/drivers/usb/serial/usb-serial.c
+++ b/drivers/usb/serial/usb-serial.c
@@ -74,7 +74,7 @@ static struct usb_serial *get_free_seria
unsigned int i, j;
int good_spot;
- dbg("%s %d", __FUNCTION__, num_ports);
+ dbg("%d", num_ports);
*minor = 0;
for (i = 0; i < SERIAL_TTY_MINORS; ++i) {
@@ -92,7 +92,7 @@ static struct usb_serial *get_free_seria
continue;
*minor = i;
- dbg("%s - minor base = %d", __FUNCTION__, *minor);
+ dbg("minor base = %d", *minor);
for (i = *minor; (i < (*minor + num_ports)) && (i <
SERIAL_TTY_MINORS); ++i)
serial_table[i] = serial;
return serial;
@@ -104,7 +104,7 @@ static void return_serial(struct usb_ser
{
int i;
- dbg("%s", __FUNCTION__);
+ dbg("");
if (serial == NULL)
return;
@@ -122,7 +122,7 @@ static void destroy_serial(struct kref *
serial = to_usb_serial(kref);
- dbg("%s - %s", __FUNCTION__, serial->type->description);
+ dbg("%s", serial->type->description);
serial->type->shutdown(serial);
@@ -178,7 +178,7 @@ static int serial_open (struct tty_struc
unsigned int portNumber;
int retval;
- dbg("%s", __FUNCTION__);
+ dbg("");
/* get the serial object associated with this tty pointer */
serial = usb_serial_get_by_index(tty->index);
@@ -243,7 +243,7 @@ static void serial_close(struct tty_stru
if (!port)
return;
- dbg("%s - port %d", __FUNCTION__, port->number);
+ dbg("port %d", port->number);
mutex_lock(&port->mutex);
@@ -279,10 +279,10 @@ static int serial_write (struct tty_stru
if (!port)
goto exit;
- dbg("%s - port %d, %d byte(s)", __FUNCTION__, port->number, count);
+ dbg("port %d, %d byte(s)", port->number, count);
if (!port->open_count) {
- dbg("%s - port not opened", __FUNCTION__);
+ dbg("port not opened");
goto exit;
}
@@ -301,10 +301,10 @@ static int serial_write_room (struct tty
if (!port)
goto exit;
- dbg("%s - port %d", __FUNCTION__, port->number);
+ dbg("port %d", port->number);
if (!port->open_count) {
- dbg("%s - port not open", __FUNCTION__);
+ dbg("port not open");
goto exit;
}
@@ -323,10 +323,10 @@ static int serial_chars_in_buffer (struc
if (!port)
goto exit;
- dbg("%s = port %d", __FUNCTION__, port->number);
+ dbg("port %d", port->number);
if (!port->open_count) {
- dbg("%s - port not open", __FUNCTION__);
+ dbg("port not open");
goto exit;
}
@@ -344,10 +344,10 @@ static void serial_throttle (struct tty_
if (!port)
return;
- dbg("%s - port %d", __FUNCTION__, port->number);
+ dbg("port %d", port->number);
if (!port->open_count) {
- dbg ("%s - port not open", __FUNCTION__);
+ dbg ("port not open");
return;
}
@@ -363,10 +363,10 @@ static void serial_unthrottle (struct tt
if (!port)
return;
- dbg("%s - port %d", __FUNCTION__, port->number);
+ dbg("port %d", port->number);
if (!port->open_count) {
- dbg("%s - port not open", __FUNCTION__);
+ dbg("port not open");
return;
}
@@ -383,10 +383,10 @@ static int serial_ioctl (struct tty_stru
if (!port)
goto exit;
- dbg("%s - port %d, cmd 0x%.4x", __FUNCTION__, port->number, cmd);
+ dbg("port %d, cmd 0x%.4x", port->number, cmd);
if (!port->open_count) {
- dbg ("%s - port not open", __FUNCTION__);
+ dbg ("port not open");
goto exit;
}
@@ -407,10 +407,10 @@ static void serial_set_termios (struct t
if (!port)
return;
- dbg("%s - port %d", __FUNCTION__, port->number);
+ dbg("port %d", port->number);
if (!port->open_count) {
- dbg("%s - port not open", __FUNCTION__);
+ dbg("port not open");
return;
}
@@ -426,10 +426,10 @@ static void serial_break (struct tty_str
if (!port)
return;
- dbg("%s - port %d", __FUNCTION__, port->number);
+ dbg("port %d", port->number);
if (!port->open_count) {
- dbg("%s - port not open", __FUNCTION__);
+ dbg("port not open");
return;
}
@@ -446,7 +446,7 @@ static int serial_read_proc (char *page,
off_t begin = 0;
char tmp[40];
- dbg("%s", __FUNCTION__);
+ dbg("");
length += sprintf (page, "usbserinfo:1.0 driver:2.0\n");
for (i = 0; i < SERIAL_TTY_MINORS && length < PAGE_SIZE; ++i) {
serial = usb_serial_get_by_index(i);
@@ -490,10 +490,10 @@ static int serial_tiocmget (struct tty_s
if (!port)
goto exit;
- dbg("%s - port %d", __FUNCTION__, port->number);
+ dbg("port %d", port->number);
if (!port->open_count) {
- dbg("%s - port not open", __FUNCTION__);
+ dbg("port not open");
goto exit;
}
@@ -512,10 +512,10 @@ static int serial_tiocmset (struct tty_s
if (!port)
goto exit;
- dbg("%s - port %d", __FUNCTION__, port->number);
+ dbg("port %d", port->number);
if (!port->open_count) {
- dbg("%s - port not open", __FUNCTION__);
+ dbg("port not open");
goto exit;
}
@@ -531,7 +531,7 @@ void usb_serial_port_softint(void *priva
struct usb_serial_port *port = private;
struct tty_struct *tty;
- dbg("%s - port %d", __FUNCTION__, port->number);
+ dbg("port %d", port->number);
if (!port)
return;
@@ -547,7 +547,7 @@ static void port_release(struct device *
{
struct usb_serial_port *port = to_usb_serial_port(dev);
- dbg ("%s - %s", __FUNCTION__, dev->bus_id);
+ dbg ("%s", dev->bus_id);
usb_kill_urb(port->read_urb);
usb_free_urb(port->read_urb);
usb_kill_urb(port->write_urb);
@@ -780,7 +780,7 @@ #endif
max_endpoints = max(max_endpoints, num_interrupt_out);
max_endpoints = max(max_endpoints, (int)serial->num_ports);
serial->num_port_pointers = max_endpoints;
- dbg("%s - setting up %d port structures for this device", __FUNCTION__,
max_endpoints);
+ dbg("setting up %d port structures for this device", max_endpoints);
for (i = 0; i < max_endpoints; ++i) {
port = kzalloc(sizeof(struct usb_serial_port), GFP_KERNEL);
if (!port)
@@ -923,7 +923,7 @@ #endif
port->dev.release = &port_release;
snprintf (&port->dev.bus_id[0], sizeof(port->dev.bus_id),
"ttyUSB%d", port->number);
- dbg ("%s - registering %s", __FUNCTION__, port->dev.bus_id);
+ dbg ("registering %s", port->dev.bus_id);
device_register (&port->dev);
}
@@ -985,7 +985,7 @@ void usb_serial_disconnect(struct usb_in
struct device *dev = &interface->dev;
struct usb_serial_port *port;
- dbg ("%s", __FUNCTION__);
+ dbg ("");
usb_set_intfdata (interface, NULL);
if (serial) {
diff --git a/drivers/usb/serial/usb-serial.h b/drivers/usb/serial/usb-serial.h
index dc89d87..af58879 100644
--- a/drivers/usb/serial/usb-serial.h
+++ b/drivers/usb/serial/usb-serial.h
@@ -290,9 +290,11 @@ static inline void usb_serial_debug_data
/* Use our own dbg macro */
#undef dbg
-#define dbg(format, arg...) do { if (debug) printk(KERN_DEBUG "%s: " format
"\n" , __FILE__ , ## arg); } while (0)
-
-
+#define dbg(format, arg...) do { \
+ if (debug) \
+ printk(KERN_DEBUG "[USBSERIAL] %s: " format "\n", \
+ __FUNCTION__, ##arg); \
+ } while (0)
#endif /* ifdef __LINUX_USB_SERIAL_H */
--
1.3.3.g0825d
_______________________________________________
[email protected]
To unsubscribe, use the last form field at:
https://lists.sourceforge.net/lists/listinfo/linux-usb-devel