Browse Source

USB: serial: iuu_phoenix.c: remove dbg() usage

dbg() was a very old USB-serial-specific macro.
This patch removes it from being used in the
driver and uses dev_dbg() instead.

CC: Rusty Russell <rusty@rustcorp.com.au>
CC: Johan Hovold <jhovold@gmail.com>
CC: Alan Stern <stern@rowland.harvard.edu>
CC: Mauro Carvalho Chehab <mchehab@redhat.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Greg Kroah-Hartman 12 years ago
parent
commit
2621cee19a
1 changed files with 58 additions and 67 deletions
  1. 58 67
      drivers/usb/serial/iuu_phoenix.c

+ 58 - 67
drivers/usb/serial/iuu_phoenix.c

@@ -72,7 +72,6 @@ struct iuu_private {
 	u8 *writebuf;		/* buffer for writing to device */
 	int writelen;		/* num of byte to write to device */
 	u8 *buf;		/* used for initialize speed */
-	u8 *dbgbuf;		/* debug buffer */
 	u8 len;
 	int vcc;		/* vcc (either 3 or 5 V) */
 	u32 baud;
@@ -84,32 +83,31 @@ struct iuu_private {
 static void iuu_free_buf(struct iuu_private *priv)
 {
 	kfree(priv->buf);
-	kfree(priv->dbgbuf);
 	kfree(priv->writebuf);
 }
 
-static int iuu_alloc_buf(struct iuu_private *priv)
+static int iuu_alloc_buf(struct usb_serial *serial, struct iuu_private *priv)
 {
 	priv->buf = kzalloc(256, GFP_KERNEL);
-	priv->dbgbuf = kzalloc(256, GFP_KERNEL);
 	priv->writebuf = kzalloc(256, GFP_KERNEL);
-	if (!priv->buf || !priv->dbgbuf || !priv->writebuf) {
+	if (!priv->buf || !priv->writebuf) {
 		iuu_free_buf(priv);
-		dbg("%s problem allocation buffer", __func__);
+		dev_dbg(&serial->dev->dev, "%s problem allocation buffer\n", __func__);
 		return -ENOMEM;
 	}
-	dbg("%s - Privates buffers allocation success", __func__);
+	dev_dbg(&serial->dev->dev, "%s - Privates buffers allocation success\n", __func__);
 	return 0;
 }
 
 static int iuu_startup(struct usb_serial *serial)
 {
 	struct iuu_private *priv;
+
 	priv = kzalloc(sizeof(struct iuu_private), GFP_KERNEL);
-	dbg("%s- priv allocation success", __func__);
+	dev_dbg(&serial->dev->dev, "%s- priv allocation success\n", __func__);
 	if (!priv)
 		return -ENOMEM;
-	if (iuu_alloc_buf(priv)) {
+	if (iuu_alloc_buf(serial, priv)) {
 		kfree(priv);
 		return -ENOMEM;
 	}
@@ -130,13 +128,13 @@ static void iuu_release(struct usb_serial *serial)
 
 	if (priv) {
 		iuu_free_buf(priv);
-		dbg("%s - I will free all", __func__);
+		dev_dbg(&port->dev, "%s - I will free all\n", __func__);
 		usb_set_serial_port_data(port, NULL);
 
-		dbg("%s - priv is not anymore in port structure", __func__);
+		dev_dbg(&port->dev, "%s - priv is not anymore in port structure\n", __func__);
 		kfree(priv);
 
-		dbg("%s priv is now kfree", __func__);
+		dev_dbg(&port->dev, "%s priv is now kfree\n", __func__);
 	}
 }
 
@@ -148,13 +146,13 @@ static int iuu_tiocmset(struct tty_struct *tty,
 	unsigned long flags;
 
 	/* FIXME: locking on tiomstatus */
-	dbg("%s (%d) msg : SET = 0x%04x, CLEAR = 0x%04x ", __func__,
-	    port->number, set, clear);
+	dev_dbg(&port->dev, "%s msg : SET = 0x%04x, CLEAR = 0x%04x\n",
+		__func__, set, clear);
 
 	spin_lock_irqsave(&priv->lock, flags);
 
 	if ((set & TIOCM_RTS) && !(priv->tiostatus == TIOCM_RTS)) {
-		dbg("%s TIOCMSET RESET called !!!", __func__);
+		dev_dbg(&port->dev, "%s TIOCMSET RESET called !!!\n", __func__);
 		priv->reset = 1;
 	}
 	if (set & TIOCM_RTS)
@@ -190,7 +188,7 @@ static void iuu_rxcmd(struct urb *urb)
 	int status = urb->status;
 
 	if (status) {
-		dbg("%s - status = %d", __func__, status);
+		dev_dbg(&port->dev, "%s - status = %d\n", __func__, status);
 		/* error stop all */
 		return;
 	}
@@ -244,13 +242,13 @@ static void iuu_update_status_callback(struct urb *urb)
 	int status = urb->status;
 
 	if (status) {
-		dbg("%s - status = %d", __func__, status);
+		dev_dbg(&port->dev, "%s - status = %d\n", __func__, status);
 		/* error stop all */
 		return;
 	}
 
 	st = urb->transfer_buffer;
-	dbg("%s - enter", __func__);
+	dev_dbg(&port->dev, "%s - enter\n", __func__);
 	if (urb->actual_length == 1) {
 		switch (st[0]) {
 		case 0x1:
@@ -272,7 +270,7 @@ static void iuu_status_callback(struct urb *urb)
 	int result;
 	int status = urb->status;
 
-	dbg("%s - status = %d", __func__, status);
+	dev_dbg(&port->dev, "%s - status = %d\n", __func__, status);
 	usb_fill_bulk_urb(port->read_urb, port->serial->dev,
 			  usb_rcvbulkpipe(port->serial->dev,
 					  port->bulk_in_endpointAddress),
@@ -311,9 +309,9 @@ static int bulk_immediate(struct usb_serial_port *port, u8 *buf, u8 count)
 			 count, &actual, HZ * 1);
 
 	if (status != IUU_OPERATION_OK)
-		dbg("%s - error = %2x", __func__, status);
+		dev_dbg(&port->dev, "%s - error = %2x\n", __func__, status);
 	else
-		dbg("%s - write OK !", __func__);
+		dev_dbg(&port->dev, "%s - write OK !\n", __func__);
 	return status;
 }
 
@@ -331,9 +329,9 @@ static int read_immediate(struct usb_serial_port *port, u8 *buf, u8 count)
 			 count, &actual, HZ * 1);
 
 	if (status != IUU_OPERATION_OK)
-		dbg("%s - error = %2x", __func__, status);
+		dev_dbg(&port->dev, "%s - error = %2x\n", __func__, status);
 	else
-		dbg("%s - read OK !", __func__);
+		dev_dbg(&port->dev, "%s - read OK !\n", __func__);
 	return status;
 }
 
@@ -357,9 +355,9 @@ static int iuu_led(struct usb_serial_port *port, unsigned int R,
 	status = bulk_immediate(port, buf, 8);
 	kfree(buf);
 	if (status != IUU_OPERATION_OK)
-		dbg("%s - led error status = %2x", __func__, status);
+		dev_dbg(&port->dev, "%s - led error status = %2x\n", __func__, status);
 	else
-		dbg("%s - led OK !", __func__);
+		dev_dbg(&port->dev, "%s - led OK !\n", __func__);
 	return IUU_OPERATION_OK;
 }
 
@@ -445,7 +443,7 @@ static int iuu_clk(struct usb_serial_port *port, int dwFrq)
 
 		status = bulk_immediate(port, (u8 *) priv->buf, Count);
 		if (status != 0) {
-			dbg("%s - write error ", __func__);
+			dev_dbg(&port->dev, "%s - write error\n", __func__);
 			return status;
 		}
 	} else if (frq == 3579000) {
@@ -554,12 +552,13 @@ static int iuu_clk(struct usb_serial_port *port, int dwFrq)
 
 	status = bulk_immediate(port, (u8 *) priv->buf, Count);
 	if (status != IUU_OPERATION_OK)
-		dbg("%s - write error ", __func__);
+		dev_dbg(&port->dev, "%s - write error\n", __func__);
 	return status;
 }
 
 static int iuu_uart_flush(struct usb_serial_port *port)
 {
+	struct device *dev = &port->dev;
 	int i;
 	int status;
 	u8 rxcmd = IUU_UART_RX;
@@ -571,27 +570,26 @@ static int iuu_uart_flush(struct usb_serial_port *port)
 	for (i = 0; i < 2; i++) {
 		status = bulk_immediate(port, &rxcmd, 1);
 		if (status != IUU_OPERATION_OK) {
-			dbg("%s - uart_flush_write error", __func__);
+			dev_dbg(dev, "%s - uart_flush_write error\n", __func__);
 			return status;
 		}
 
 		status = read_immediate(port, &priv->len, 1);
 		if (status != IUU_OPERATION_OK) {
-			dbg("%s - uart_flush_read error", __func__);
+			dev_dbg(dev, "%s - uart_flush_read error\n", __func__);
 			return status;
 		}
 
 		if (priv->len > 0) {
-			dbg("%s - uart_flush datalen is : %i ", __func__,
-			    priv->len);
+			dev_dbg(dev, "%s - uart_flush datalen is : %i\n", __func__, priv->len);
 			status = read_immediate(port, priv->buf, priv->len);
 			if (status != IUU_OPERATION_OK) {
-				dbg("%s - uart_flush_read error", __func__);
+				dev_dbg(dev, "%s - uart_flush_read error\n", __func__);
 				return status;
 			}
 		}
 	}
-	dbg("%s - uart_flush_read OK!", __func__);
+	dev_dbg(dev, "%s - uart_flush_read OK!\n", __func__);
 	iuu_led(port, 0, 0xF000, 0, 0xFF);
 	return status;
 }
@@ -610,10 +608,10 @@ static void read_buf_callback(struct urb *urb)
 		return;
 	}
 
-	dbg("%s - %i chars to write", __func__, urb->actual_length);
+	dev_dbg(&port->dev, "%s - %i chars to write\n", __func__, urb->actual_length);
 	tty = tty_port_tty_get(&port->port);
 	if (data == NULL)
-		dbg("%s - data is NULL !!!", __func__);
+		dev_dbg(&port->dev, "%s - data is NULL !!!\n", __func__);
 	if (tty && urb->actual_length && data) {
 		tty_insert_flip_string(tty, data, urb->actual_length);
 		tty_flip_buffer_push(tty);
@@ -627,7 +625,6 @@ static int iuu_bulk_write(struct usb_serial_port *port)
 	struct iuu_private *priv = usb_get_serial_port_data(port);
 	unsigned long flags;
 	int result;
-	int i;
 	int buf_len;
 	char *buf_ptr = port->write_urb->transfer_buffer;
 
@@ -640,14 +637,8 @@ static int iuu_bulk_write(struct usb_serial_port *port)
 	buf_len = priv->writelen;
 	priv->writelen = 0;
 	spin_unlock_irqrestore(&priv->lock, flags);
-	if (debug == 1) {
-		for (i = 0; i < buf_len; i++)
-			sprintf(priv->dbgbuf + i*2 ,
-				"%02X", priv->writebuf[i]);
-		priv->dbgbuf[buf_len+i*2] = 0;
-		dbg("%s - writing %i chars : %s", __func__,
-		    buf_len, priv->dbgbuf);
-	}
+	dev_dbg(&port->dev, "%s - writing %i chars : %*ph\n", __func__,
+		buf_len, buf_len, buf_ptr);
 	usb_fill_bulk_urb(port->write_urb, port->serial->dev,
 			  usb_sndbulkpipe(port->serial->dev,
 					  port->bulk_out_endpointAddress),
@@ -683,18 +674,18 @@ static void iuu_uart_read_callback(struct urb *urb)
 	priv->poll++;
 
 	if (status) {
-		dbg("%s - status = %d", __func__, status);
+		dev_dbg(&port->dev, "%s - status = %d\n", __func__, status);
 		/* error stop all */
 		return;
 	}
 	if (data == NULL)
-		dbg("%s - data is NULL !!!", __func__);
+		dev_dbg(&port->dev, "%s - data is NULL !!!\n", __func__);
 
 	if (urb->actual_length == 1  && data != NULL)
 		len = (int) data[0];
 
 	if (urb->actual_length > 1) {
-		dbg("%s - urb->actual_length = %i", __func__,
+		dev_dbg(&port->dev, "%s - urb->actual_length = %i\n", __func__,
 		    urb->actual_length);
 		error = 1;
 		return;
@@ -702,7 +693,7 @@ static void iuu_uart_read_callback(struct urb *urb)
 	/* if len > 0 call readbuf */
 
 	if (len > 0 && error == 0) {
-		dbg("%s - call read buf - len to read is %i ",
+		dev_dbg(&port->dev, "%s - call read buf - len to read is %i\n",
 			__func__, len);
 		status = iuu_read_buf(port, len);
 		return;
@@ -729,7 +720,7 @@ static void iuu_uart_read_callback(struct urb *urb)
 	}
 	spin_unlock_irqrestore(&priv->lock, flags);
 	/* if nothing to write call again rxcmd */
-	dbg("%s - rxcmd recall", __func__);
+	dev_dbg(&port->dev, "%s - rxcmd recall\n", __func__);
 	iuu_led_activity_off(urb);
 }
 
@@ -769,7 +760,7 @@ static void read_rxcmd_callback(struct urb *urb)
 			  port->read_urb->transfer_buffer, 256,
 			  iuu_uart_read_callback, port);
 	result = usb_submit_urb(port->read_urb, GFP_ATOMIC);
-	dbg("%s - submit result = %d", __func__, result);
+	dev_dbg(&port->dev, "%s - submit result = %d\n", __func__, result);
 }
 
 static int iuu_uart_on(struct usb_serial_port *port)
@@ -789,13 +780,13 @@ static int iuu_uart_on(struct usb_serial_port *port)
 
 	status = bulk_immediate(port, buf, 4);
 	if (status != IUU_OPERATION_OK) {
-		dbg("%s - uart_on error", __func__);
+		dev_dbg(&port->dev, "%s - uart_on error\n", __func__);
 		goto uart_enable_failed;
 	}
 	/*  iuu_reset() the card after iuu_uart_on() */
 	status = iuu_uart_flush(port);
 	if (status != IUU_OPERATION_OK)
-		dbg("%s - uart_flush error", __func__);
+		dev_dbg(&port->dev, "%s - uart_flush error\n", __func__);
 uart_enable_failed:
 	kfree(buf);
 	return status;
@@ -813,7 +804,7 @@ static int iuu_uart_off(struct usb_serial_port *port)
 
 	status = bulk_immediate(port, buf, 1);
 	if (status != IUU_OPERATION_OK)
-		dbg("%s - uart_off error", __func__);
+		dev_dbg(&port->dev, "%s - uart_off error\n", __func__);
 
 	kfree(buf);
 	return status;
@@ -830,7 +821,7 @@ static int iuu_uart_baud(struct usb_serial_port *port, u32 baud_base,
 	u8 T1reload = 0;
 	unsigned int T1FrekvensHZ = 0;
 
-	dbg("%s - enter baud_base=%d", __func__, baud_base);
+	dev_dbg(&port->dev, "%s - enter baud_base=%d\n", __func__, baud_base);
 	dataout = kmalloc(sizeof(u8) * 5, GFP_KERNEL);
 
 	if (!dataout)
@@ -911,7 +902,7 @@ static int iuu_uart_baud(struct usb_serial_port *port, u32 baud_base,
 
 	status = bulk_immediate(port, dataout, DataCount);
 	if (status != IUU_OPERATION_OK)
-		dbg("%s - uart_off error", __func__);
+		dev_dbg(&port->dev, "%s - uart_off error\n", __func__);
 	kfree(dataout);
 	return status;
 }
@@ -932,7 +923,7 @@ static void iuu_set_termios(struct tty_struct *tty,
 	/* Just use the ospeed. ispeed should be the same. */
 	baud = tty->termios->c_ospeed;
 
-	dbg("%s - enter c_ospeed or baud=%d", __func__, baud);
+	dev_dbg(&port->dev, "%s - enter c_ospeed or baud=%d\n", __func__, baud);
 
 	/* compute the parity parameter */
 	parity = 0;
@@ -983,7 +974,7 @@ static void iuu_close(struct usb_serial_port *port)
 	if (serial->dev) {
 		/* free writebuf */
 		/* shutdown our urbs */
-		dbg("%s - shutting down urbs", __func__);
+		dev_dbg(&port->dev, "%s - shutting down urbs\n", __func__);
 		usb_kill_urb(port->write_urb);
 		usb_kill_urb(port->read_urb);
 		usb_kill_urb(port->interrupt_in_urb);
@@ -1006,6 +997,7 @@ static void iuu_init_termios(struct tty_struct *tty)
 static int iuu_open(struct tty_struct *tty, struct usb_serial_port *port)
 {
 	struct usb_serial *serial = port->serial;
+	struct device *dev = &port->dev;
 	u8 *buf;
 	int result;
 	int baud;
@@ -1017,7 +1009,7 @@ static int iuu_open(struct tty_struct *tty, struct usb_serial_port *port)
 	/* Re-encode speed */
 	tty_encode_baud_rate(tty, baud, baud);
 
-	dbg("%s -  port %d, baud %d", __func__, port->number, baud);
+	dev_dbg(dev, "%s - baud %d\n", __func__, baud);
 	usb_clear_halt(serial->dev, port->write_urb->pipe);
 	usb_clear_halt(serial->dev, port->read_urb->pipe);
 
@@ -1032,14 +1024,14 @@ static int iuu_open(struct tty_struct *tty, struct usb_serial_port *port)
 	result = usb_control_msg(port->serial->dev,	\
 				usb_rcvctrlpipe(port->serial->dev, 0),	\
 				b, a, c, d, buf, 1, 1000); \
-	dbg("0x%x:0x%x:0x%x:0x%x  %d - %x", a, b, c, d, result, \
+	dev_dbg(dev, "0x%x:0x%x:0x%x:0x%x  %d - %x\n", a, b, c, d, result, \
 				buf[0]); } while (0);
 
 #define SOUP(a, b, c, d)  do { \
 	result = usb_control_msg(port->serial->dev,	\
 				usb_sndctrlpipe(port->serial->dev, 0),	\
 				b, a, c, d, NULL, 0, 1000); \
-	dbg("0x%x:0x%x:0x%x:0x%x  %d", a, b, c, d, result); } while (0)
+	dev_dbg(dev, "0x%x:0x%x:0x%x:0x%x  %d\n", a, b, c, d, result); } while (0)
 
 	/*  This is not UART related but IUU USB driver related or something */
 	/*  like that. Basically no IUU will accept any commands from the USB */
@@ -1119,7 +1111,7 @@ static int iuu_open(struct tty_struct *tty, struct usb_serial_port *port)
 
 	iuu_uart_flush(port);
 
-	dbg("%s - initialization done", __func__);
+	dev_dbg(dev, "%s - initialization done\n", __func__);
 
 	memset(port->write_urb->transfer_buffer, IUU_UART_RX, 1);
 	usb_fill_bulk_urb(port->write_urb, port->serial->dev,
@@ -1129,11 +1121,10 @@ static int iuu_open(struct tty_struct *tty, struct usb_serial_port *port)
 			  read_rxcmd_callback, port);
 	result = usb_submit_urb(port->write_urb, GFP_KERNEL);
 	if (result) {
-		dev_err(&port->dev, "%s - failed submitting read urb,"
-			" error %d\n", __func__, result);
+		dev_err(dev, "%s - failed submitting read urb, error %d\n", __func__, result);
 		iuu_close(port);
 	} else {
-		dbg("%s - rxcmd OK", __func__);
+		dev_dbg(dev, "%s - rxcmd OK\n", __func__);
 	}
 
 	return result;
@@ -1159,9 +1150,9 @@ static int iuu_vcc_set(struct usb_serial_port *port, unsigned int vcc)
 	kfree(buf);
 
 	if (status != IUU_OPERATION_OK)
-		dbg("%s - vcc error status = %2x", __func__, status);
+		dev_dbg(&port->dev, "%s - vcc error status = %2x\n", __func__, status);
 	else
-		dbg("%s - vcc OK !", __func__);
+		dev_dbg(&port->dev, "%s - vcc OK !\n", __func__);
 
 	return status;
 }
@@ -1192,7 +1183,7 @@ static ssize_t store_vcc_mode(struct device *dev,
 		goto fail_store_vcc_mode;
 	}
 
-	dbg("%s: setting vcc_mode = %ld", __func__, v);
+	dev_dbg(dev, "%s: setting vcc_mode = %ld", __func__, v);
 
 	if ((v != 3) && (v != 5)) {
 		dev_err(dev, "%s - vcc_mode %ld is invalid\n", __func__, v);