diff options
author | Johan Hovold <jhovold@gmail.com> | 2013-12-29 13:23:07 -0500 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@linuxfoundation.org> | 2014-01-03 15:31:47 -0500 |
commit | 7f966ac7a939633ff6fa8cec58982676c243b4f8 (patch) | |
tree | 66886015e52ce580028b38032253737cc1fbc51e /drivers/usb/serial | |
parent | f84ee3b2f5e5e39041c39268a9eab5046a050d44 (diff) |
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: Johan Hovold <jhovold@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'drivers/usb/serial')
-rw-r--r-- | drivers/usb/serial/pl2303.c | 31 |
1 files changed, 15 insertions, 16 deletions
diff --git a/drivers/usb/serial/pl2303.c b/drivers/usb/serial/pl2303.c index 40f7b80b3601..52f0c96cd98d 100644 --- a/drivers/usb/serial/pl2303.c +++ b/drivers/usb/serial/pl2303.c | |||
@@ -129,9 +129,8 @@ MODULE_DEVICE_TABLE(usb, id_table); | |||
129 | 129 | ||
130 | 130 | ||
131 | enum pl2303_type { | 131 | enum pl2303_type { |
132 | type_0, /* don't know the difference between type 0 and */ | 132 | TYPE_01, /* Type 0 and 1 (difference unknown) */ |
133 | type_1, /* type 1, until someone from prolific tells us... */ | 133 | TYPE_HX, /* HX version of the pl2303 chip */ |
134 | HX, /* HX version of the pl2303 chip */ | ||
135 | }; | 134 | }; |
136 | 135 | ||
137 | struct pl2303_serial_private { | 136 | struct pl2303_serial_private { |
@@ -200,7 +199,7 @@ static int pl2303_probe(struct usb_serial *serial, | |||
200 | static int pl2303_startup(struct usb_serial *serial) | 199 | static int pl2303_startup(struct usb_serial *serial) |
201 | { | 200 | { |
202 | struct pl2303_serial_private *spriv; | 201 | struct pl2303_serial_private *spriv; |
203 | enum pl2303_type type = type_0; | 202 | enum pl2303_type type = TYPE_01; |
204 | unsigned char *buf; | 203 | unsigned char *buf; |
205 | 204 | ||
206 | spriv = kzalloc(sizeof(*spriv), GFP_KERNEL); | 205 | spriv = kzalloc(sizeof(*spriv), GFP_KERNEL); |
@@ -214,13 +213,13 @@ static int pl2303_startup(struct usb_serial *serial) | |||
214 | } | 213 | } |
215 | 214 | ||
216 | if (serial->dev->descriptor.bDeviceClass == 0x02) | 215 | if (serial->dev->descriptor.bDeviceClass == 0x02) |
217 | type = type_0; | 216 | type = TYPE_01; /* type 0 */ |
218 | else if (serial->dev->descriptor.bMaxPacketSize0 == 0x40) | 217 | else if (serial->dev->descriptor.bMaxPacketSize0 == 0x40) |
219 | type = HX; | 218 | type = TYPE_HX; |
220 | else if (serial->dev->descriptor.bDeviceClass == 0x00) | 219 | else if (serial->dev->descriptor.bDeviceClass == 0x00) |
221 | type = type_1; | 220 | type = TYPE_01; /* type 1 */ |
222 | else if (serial->dev->descriptor.bDeviceClass == 0xFF) | 221 | else if (serial->dev->descriptor.bDeviceClass == 0xFF) |
223 | type = type_1; | 222 | type = TYPE_01; /* type 1 */ |
224 | dev_dbg(&serial->interface->dev, "device type: %d\n", type); | 223 | dev_dbg(&serial->interface->dev, "device type: %d\n", type); |
225 | 224 | ||
226 | spriv->type = type; | 225 | spriv->type = type; |
@@ -238,10 +237,10 @@ static int pl2303_startup(struct usb_serial *serial) | |||
238 | pl2303_vendor_read(serial, 0x8383, buf); | 237 | pl2303_vendor_read(serial, 0x8383, buf); |
239 | pl2303_vendor_write(serial, 0, 1); | 238 | pl2303_vendor_write(serial, 0, 1); |
240 | pl2303_vendor_write(serial, 1, 0); | 239 | pl2303_vendor_write(serial, 1, 0); |
241 | if (type == HX) | 240 | if (type == TYPE_01) |
242 | pl2303_vendor_write(serial, 2, 0x44); | ||
243 | else | ||
244 | pl2303_vendor_write(serial, 2, 0x24); | 241 | pl2303_vendor_write(serial, 2, 0x24); |
242 | else | ||
243 | pl2303_vendor_write(serial, 2, 0x44); | ||
245 | 244 | ||
246 | kfree(buf); | 245 | kfree(buf); |
247 | 246 | ||
@@ -335,7 +334,7 @@ static void pl2303_encode_baudrate(struct tty_struct *tty, | |||
335 | baud = baud_sup[i]; | 334 | baud = baud_sup[i]; |
336 | 335 | ||
337 | /* type_0, type_1 only support up to 1228800 baud */ | 336 | /* type_0, type_1 only support up to 1228800 baud */ |
338 | if (spriv->type != HX) | 337 | if (spriv->type == TYPE_01) |
339 | baud = min_t(speed_t, baud, 1228800); | 338 | baud = min_t(speed_t, baud, 1228800); |
340 | 339 | ||
341 | if (baud <= 115200) { | 340 | if (baud <= 115200) { |
@@ -532,10 +531,10 @@ static void pl2303_set_termios(struct tty_struct *tty, | |||
532 | } | 531 | } |
533 | 532 | ||
534 | if (C_CRTSCTS(tty)) { | 533 | if (C_CRTSCTS(tty)) { |
535 | if (spriv->type == HX) | 534 | if (spriv->type == TYPE_01) |
536 | pl2303_vendor_write(serial, 0x0, 0x61); | ||
537 | else | ||
538 | pl2303_vendor_write(serial, 0x0, 0x41); | 535 | pl2303_vendor_write(serial, 0x0, 0x41); |
536 | else | ||
537 | pl2303_vendor_write(serial, 0x0, 0x61); | ||
539 | } else { | 538 | } else { |
540 | pl2303_vendor_write(serial, 0x0, 0x0); | 539 | pl2303_vendor_write(serial, 0x0, 0x0); |
541 | } | 540 | } |
@@ -572,7 +571,7 @@ static int pl2303_open(struct tty_struct *tty, struct usb_serial_port *port) | |||
572 | struct pl2303_serial_private *spriv = usb_get_serial_data(serial); | 571 | struct pl2303_serial_private *spriv = usb_get_serial_data(serial); |
573 | int result; | 572 | int result; |
574 | 573 | ||
575 | if (spriv->type != HX) { | 574 | if (spriv->type == TYPE_01) { |
576 | usb_clear_halt(serial->dev, port->write_urb->pipe); | 575 | usb_clear_halt(serial->dev, port->write_urb->pipe); |
577 | usb_clear_halt(serial->dev, port->read_urb->pipe); | 576 | usb_clear_halt(serial->dev, port->read_urb->pipe); |
578 | } else { | 577 | } else { |