From 3c91233f38837fe42430c2426abdf0d636fa33cf Mon Sep 17 00:00:00 2001
From: =?utf8?q?Frank=20Sch=C3=A4fer?= <fschaefer.oss@googlemail.com>
Date: Wed, 14 Aug 2013 20:09:10 +0200
Subject: [PATCH] pl2303: improve the chip type information output on startup
MIME-Version: 1.0
Content-Type: text/plain; charset=utf8
Content-Transfer-Encoding: 8bit

The chip type distinction is getting more and more relevant and
complicating, so always print the chip type.
Printing a name string is also much better than just printing an
internal index number.

Signed-off-by: Frank Schäfer <fschaefer.oss@googlemail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
---
 drivers/usb/serial/pl2303.c | 15 ++++++++++-----
 1 file changed, 10 insertions(+), 5 deletions(-)

diff --git a/drivers/usb/serial/pl2303.c b/drivers/usb/serial/pl2303.c
index 7efb39cd6f74b..409000a836ddb 100644
--- a/drivers/usb/serial/pl2303.c
+++ b/drivers/usb/serial/pl2303.c
@@ -177,6 +177,7 @@ static int pl2303_startup(struct usb_serial *serial)
 {
 	struct pl2303_serial_private *spriv;
 	enum pl2303_type type = type_0;
+	char *type_str = "unknown (treating as type_0)";
 	unsigned char *buf;
 
 	spriv = kzalloc(sizeof(*spriv), GFP_KERNEL);
@@ -189,14 +190,18 @@ static int pl2303_startup(struct usb_serial *serial)
 		return -ENOMEM;
 	}
 
-	if (serial->dev->descriptor.bDeviceClass == 0x02)
+	if (serial->dev->descriptor.bDeviceClass == 0x02) {
 		type = type_0;
-	else if (serial->dev->descriptor.bMaxPacketSize0 == 0x40)
+		type_str = "type_0";
+	} else if (serial->dev->descriptor.bMaxPacketSize0 == 0x40) {
 		type = HX;
-	else if (serial->dev->descriptor.bDeviceClass == 0x00
-		 || serial->dev->descriptor.bDeviceClass == 0xFF)
+		type_str = "X/HX";
+	} else if (serial->dev->descriptor.bDeviceClass == 0x00
+		   || serial->dev->descriptor.bDeviceClass == 0xFF) {
 		type = type_1;
-	dev_dbg(&serial->interface->dev, "device type: %d\n", type);
+		type_str = "type_1";
+	}
+	dev_dbg(&serial->interface->dev, "device type: %s\n", type_str);
 
 	spriv->type = type;
 	usb_set_serial_data(serial, spriv);
-- 
2.39.5