Commit 7f966ac7 authored by Johan Hovold's avatar Johan Hovold Committed by Greg Kroah-Hartman

USB: pl2303: clean up type handling

Merge types 0 and 1, whose differences are unknown and have always been
treated the same.
Add TYPE_-prefix to both types.
Test for TYPE_01 (rather than !TYPE_HX) for legacy device quirks.
Signed-off-by: default avatarJohan Hovold <jhovold@gmail.com>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
parent f84ee3b2
...@@ -129,9 +129,8 @@ MODULE_DEVICE_TABLE(usb, id_table); ...@@ -129,9 +129,8 @@ MODULE_DEVICE_TABLE(usb, id_table);
enum pl2303_type { enum pl2303_type {
type_0, /* don't know the difference between type 0 and */ TYPE_01, /* Type 0 and 1 (difference unknown) */
type_1, /* type 1, until someone from prolific tells us... */ TYPE_HX, /* HX version of the pl2303 chip */
HX, /* HX version of the pl2303 chip */
}; };
struct pl2303_serial_private { struct pl2303_serial_private {
...@@ -200,7 +199,7 @@ static int pl2303_probe(struct usb_serial *serial, ...@@ -200,7 +199,7 @@ static int pl2303_probe(struct usb_serial *serial,
static int pl2303_startup(struct usb_serial *serial) static int pl2303_startup(struct usb_serial *serial)
{ {
struct pl2303_serial_private *spriv; struct pl2303_serial_private *spriv;
enum pl2303_type type = type_0; enum pl2303_type type = TYPE_01;
unsigned char *buf; unsigned char *buf;
spriv = kzalloc(sizeof(*spriv), GFP_KERNEL); spriv = kzalloc(sizeof(*spriv), GFP_KERNEL);
...@@ -214,13 +213,13 @@ static int pl2303_startup(struct usb_serial *serial) ...@@ -214,13 +213,13 @@ static int pl2303_startup(struct usb_serial *serial)
} }
if (serial->dev->descriptor.bDeviceClass == 0x02) if (serial->dev->descriptor.bDeviceClass == 0x02)
type = type_0; type = TYPE_01; /* type 0 */
else if (serial->dev->descriptor.bMaxPacketSize0 == 0x40) else if (serial->dev->descriptor.bMaxPacketSize0 == 0x40)
type = HX; type = TYPE_HX;
else if (serial->dev->descriptor.bDeviceClass == 0x00) else if (serial->dev->descriptor.bDeviceClass == 0x00)
type = type_1; type = TYPE_01; /* type 1 */
else if (serial->dev->descriptor.bDeviceClass == 0xFF) else if (serial->dev->descriptor.bDeviceClass == 0xFF)
type = type_1; type = TYPE_01; /* type 1 */
dev_dbg(&serial->interface->dev, "device type: %d\n", type); dev_dbg(&serial->interface->dev, "device type: %d\n", type);
spriv->type = type; spriv->type = type;
...@@ -238,10 +237,10 @@ static int pl2303_startup(struct usb_serial *serial) ...@@ -238,10 +237,10 @@ static int pl2303_startup(struct usb_serial *serial)
pl2303_vendor_read(serial, 0x8383, buf); pl2303_vendor_read(serial, 0x8383, buf);
pl2303_vendor_write(serial, 0, 1); pl2303_vendor_write(serial, 0, 1);
pl2303_vendor_write(serial, 1, 0); pl2303_vendor_write(serial, 1, 0);
if (type == HX) if (type == TYPE_01)
pl2303_vendor_write(serial, 2, 0x44);
else
pl2303_vendor_write(serial, 2, 0x24); pl2303_vendor_write(serial, 2, 0x24);
else
pl2303_vendor_write(serial, 2, 0x44);
kfree(buf); kfree(buf);
...@@ -335,7 +334,7 @@ static void pl2303_encode_baudrate(struct tty_struct *tty, ...@@ -335,7 +334,7 @@ static void pl2303_encode_baudrate(struct tty_struct *tty,
baud = baud_sup[i]; baud = baud_sup[i];
/* type_0, type_1 only support up to 1228800 baud */ /* type_0, type_1 only support up to 1228800 baud */
if (spriv->type != HX) if (spriv->type == TYPE_01)
baud = min_t(speed_t, baud, 1228800); baud = min_t(speed_t, baud, 1228800);
if (baud <= 115200) { if (baud <= 115200) {
...@@ -532,10 +531,10 @@ static void pl2303_set_termios(struct tty_struct *tty, ...@@ -532,10 +531,10 @@ static void pl2303_set_termios(struct tty_struct *tty,
} }
if (C_CRTSCTS(tty)) { if (C_CRTSCTS(tty)) {
if (spriv->type == HX) if (spriv->type == TYPE_01)
pl2303_vendor_write(serial, 0x0, 0x61);
else
pl2303_vendor_write(serial, 0x0, 0x41); pl2303_vendor_write(serial, 0x0, 0x41);
else
pl2303_vendor_write(serial, 0x0, 0x61);
} else { } else {
pl2303_vendor_write(serial, 0x0, 0x0); pl2303_vendor_write(serial, 0x0, 0x0);
} }
...@@ -572,7 +571,7 @@ static int pl2303_open(struct tty_struct *tty, struct usb_serial_port *port) ...@@ -572,7 +571,7 @@ static int pl2303_open(struct tty_struct *tty, struct usb_serial_port *port)
struct pl2303_serial_private *spriv = usb_get_serial_data(serial); struct pl2303_serial_private *spriv = usb_get_serial_data(serial);
int result; int result;
if (spriv->type != HX) { if (spriv->type == TYPE_01) {
usb_clear_halt(serial->dev, port->write_urb->pipe); usb_clear_halt(serial->dev, port->write_urb->pipe);
usb_clear_halt(serial->dev, port->read_urb->pipe); usb_clear_halt(serial->dev, port->read_urb->pipe);
} else { } else {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment