[PATCH 27/36] usb: serial: ti_usb_3410_5052: Standardize debug and error messages

From: Mathieu OTHACEHE
Date: Thu May 12 2016 - 04:54:43 EST


Use the format "error text: error value\n" when possible.
Drop redundant function names from error messages.
Also move a couple err messages to dbg messages.

Signed-off-by: Mathieu OTHACEHE <m.othacehe@xxxxxxxxx>
---
drivers/usb/serial/ti_usb_3410_5052.c | 83 +++++++++++++++++------------------
1 file changed, 41 insertions(+), 42 deletions(-)

diff --git a/drivers/usb/serial/ti_usb_3410_5052.c b/drivers/usb/serial/ti_usb_3410_5052.c
index 85f66f0..1b62ffb 100644
--- a/drivers/usb/serial/ti_usb_3410_5052.c
+++ b/drivers/usb/serial/ti_usb_3410_5052.c
@@ -539,7 +539,7 @@ static int ti_write_byte(struct usb_serial_port *port, u32 addr,
status = ti_send_ctrl_data_urb(port->serial, TI_WRITE_DATA, 0,
TI_RAM_PORT, data, size);
if (status < 0)
- dev_err(&port->dev, "%s - failed, %d\n", __func__, status);
+ dev_err(&port->dev, "%s - failed: %d\n", __func__, status);

kfree(data);

@@ -571,7 +571,7 @@ static int ti_startup(struct usb_serial *serial)
/* determine device type */
if (serial->type == &ti_1port_device)
tdev->td_is_3410 = 1;
- dev_dbg(&dev->dev, "%s - device type is %s\n", __func__,
+ dev_dbg(&dev->dev, "%s - device type is: %s\n", __func__,
tdev->td_is_3410 ? "3410" : "5052");

vid = le16_to_cpu(dev->descriptor.idVendor);
@@ -698,13 +698,14 @@ static int ti_open(struct tty_struct *tty, struct usb_serial_port *port)
dev_dbg(&port->dev, "%s - start interrupt in urb\n", __func__);
urb = serial->port[0]->interrupt_in_urb;
if (!urb) {
- dev_err(&port->dev, "%s - no interrupt urb\n", __func__);
+ dev_err(&port->dev, "no interrupt endpoint\n");
status = -EINVAL;
goto release_lock;
}
status = usb_submit_urb(urb, GFP_KERNEL);
if (status) {
- dev_err(&port->dev, "%s - submit interrupt urb failed, %d\n", __func__, status);
+ dev_err(&port->dev, "failed to submit interrupt urb: %d\n",
+ status);
goto release_lock;
}
}
@@ -715,32 +716,29 @@ static int ti_open(struct tty_struct *tty, struct usb_serial_port *port)
status = ti_send_ctrl_urb(serial, TI_OPEN_PORT, open_settings,
TI_UART1_PORT + port_number);
if (status) {
- dev_err(&port->dev, "%s - cannot send open command, %d\n",
- __func__, status);
+ dev_err(&port->dev, "cannot send open command: %d\n", status);
goto unlink_int_urb;
}

status = ti_send_ctrl_urb(serial, TI_START_PORT, 0,
TI_UART1_PORT + port_number);
if (status) {
- dev_err(&port->dev, "%s - cannot send start command, %d\n",
- __func__, status);
+ dev_err(&port->dev, "cannot send start command: %d\n", status);
goto unlink_int_urb;
}

status = ti_send_ctrl_urb(serial, TI_PURGE_PORT, TI_PURGE_INPUT,
TI_UART1_PORT + port_number);
if (status) {
- dev_err(&port->dev, "%s - cannot clear input buffers, %d\n",
- __func__, status);
+ dev_err(&port->dev, "cannot clear input buffers: %d\n", status);
goto unlink_int_urb;
}

status = ti_send_ctrl_urb(serial, TI_PURGE_PORT, TI_PURGE_OUTPUT,
TI_UART1_PORT + port_number);
if (status) {
- dev_err(&port->dev, "%s - cannot clear output buffers, %d\n",
- __func__, status);
+ dev_err(&port->dev, "cannot clear output buffers: %d\n",
+ status);
goto unlink_int_urb;
}

@@ -755,16 +753,16 @@ static int ti_open(struct tty_struct *tty, struct usb_serial_port *port)
status = ti_send_ctrl_urb(serial, TI_OPEN_PORT, open_settings,
TI_UART1_PORT + port_number);
if (status) {
- dev_err(&port->dev, "%s - cannot send open command (2), %d\n",
- __func__, status);
+ dev_err(&port->dev, "cannot send open command (2): %d\n",
+ status);
goto unlink_int_urb;
}

status = ti_send_ctrl_urb(serial, TI_START_PORT, 0,
TI_UART1_PORT + port_number);
if (status) {
- dev_err(&port->dev, "%s - cannot send start command (2), %d\n",
- __func__, status);
+ dev_err(&port->dev, "cannot send start command (2): %d\n",
+ status);
goto unlink_int_urb;
}

@@ -799,10 +797,10 @@ static void ti_close(struct usb_serial_port *port)

status = ti_send_ctrl_urb(port->serial, TI_CLOSE_PORT, 0,
TI_UART1_PORT + port->port_number);
- if (status)
- dev_err(&port->dev,
- "%s - cannot send close port command, %d\n"
- , __func__, status);
+ if (status) {
+ dev_err(&port->dev, "failed to send close port command: %d\n",
+ status);
+ }

/* if mutex_lock is interrupted, continue anyway */
do_unlock = !mutex_lock_interruptible(&tdev->td_open_close_lock);
@@ -1018,9 +1016,10 @@ static void ti_set_termios(struct tty_struct *tty,
status = ti_send_ctrl_data_urb(port->serial, TI_SET_CONFIG, 0,
TI_UART1_PORT + port_number, config,
sizeof(*config));
- if (status)
- dev_err(&port->dev, "%s - cannot set config on port %d, %d\n",
- __func__, port_number, status);
+ if (status) {
+ dev_err(&port->dev, "cannot set config on port %d: %d\n",
+ port_number, status);
+ }

/* SET_CONFIG asserts RTS and DTR, reset them correctly */
mcr = tport->tp_shadow_mcr;
@@ -1031,10 +1030,11 @@ static void ti_set_termios(struct tty_struct *tty,
mcr |= TI_MCR_DTR | TI_MCR_RTS;

status = ti_set_mcr(tport, mcr);
- if (status)
+ if (status) {
dev_err(&port->dev,
- "%s - cannot set modem control on port %d, %d\n",
- __func__, port_number, status);
+ "cannot set modem control on port %d: %d\n",
+ port_number, status);
+ }

kfree(config);
}
@@ -1108,7 +1108,7 @@ static void ti_break(struct tty_struct *tty, int break_state)
tport->tp_uart_base_addr + TI_UART_OFFSET_LCR,
TI_LCR_BREAK, break_state == -1 ? TI_LCR_BREAK : 0);
if (status)
- dev_dbg(&port->dev, "%s - error setting break, %d\n", __func__, status);
+ dev_dbg(&port->dev, "failed to set break: %d\n", status);
}


@@ -1128,23 +1128,23 @@ static void ti_interrupt_callback(struct urb *urb)
case -ECONNRESET:
case -ENOENT:
case -ESHUTDOWN:
- dev_dbg(&port->dev, "%s - urb shutting down, %d\n",
+ dev_dbg(&port->dev, "%s - urb shutting down: %d\n",
__func__, status);
return;
default:
- dev_err(&port->dev, "%s - nonzero urb status, %d\n",
+ dev_dbg(&port->dev, "%s - nonzero urb status: %d\n",
__func__, status);
goto exit;
}

if (length != 2) {
- dev_dbg(&port->dev, "%s - bad packet size, %d\n",
+ dev_dbg(&port->dev, "%s - bad packet size: %d\n",
__func__, length);
goto exit;
}

if (data[0] == TI_CODE_HARDWARE_ERROR) {
- dev_err(&port->dev, "%s - hardware error, %d\n",
+ dev_err(&port->dev, "%s - hardware error: %d\n",
__func__, data[1]);
goto exit;
}
@@ -1156,14 +1156,13 @@ static void ti_interrupt_callback(struct urb *urb)
__func__, port_number, function, data[1]);

if (port_number >= port->serial->num_ports) {
- dev_err(&port->dev, "%s - bad port number, %d\n",
- __func__, port_number);
+ dev_err(&port->dev, "bad port number: %d\n", port_number);
goto exit;
}

switch (function) {
case TI_CODE_DATA_ERROR:
- dev_err(&port->dev, "%s - DATA ERROR, port %d, data 0x%02X\n",
+ dev_dbg(&port->dev, "%s - DATA ERROR, port %d, data 0x%02X\n",
__func__, port_number, data[1]);
break;

@@ -1173,16 +1172,16 @@ static void ti_interrupt_callback(struct urb *urb)
break;

default:
- dev_err(&port->dev, "%s - unknown interrupt code, 0x%02X\n",
- __func__, data[1]);
+ dev_err(&port->dev, "unknown interrupt code: 0x%02X\n",
+ data[1]);
break;
}

exit:
status = usb_submit_urb(urb, GFP_ATOMIC);
if (status)
- dev_err(&port->dev, "%s - resubmit interrupt urb failed, %d\n",
- __func__, status);
+ dev_err(&port->dev, "resubmit interrupt urb failed: %d\n",
+ status);
}

static int ti_set_mcr(struct ti_port *tport, unsigned int mcr)
@@ -1219,8 +1218,8 @@ static int ti_get_lsr(struct ti_port *tport, u8 *lsr)
TI_UART1_PORT + port_number, data, size);
if (status) {
dev_err(&port->dev,
- "%s - get port status command failed, %d\n",
- __func__, status);
+ "get port status command failed: %d\n",
+ status);
goto free_data;
}

@@ -1369,12 +1368,12 @@ static int ti_download_firmware(struct usb_serial *serial)

check_firmware:
if (status) {
- dev_err(&dev->dev, "%s - firmware not found\n", __func__);
+ dev_err(&dev->dev, "failed to request firmware: %d\n", status);
return -ENOENT;
}

if (fw_p->size > TI_FIRMWARE_BUF_SIZE) {
- dev_err(&dev->dev, "%s - firmware too large %zu\n", __func__, fw_p->size);
+ dev_err(&dev->dev, "firmware too large: %zu\n", fw_p->size);
release_firmware(fw_p);
return -ENOENT;
}
--
2.8.2