Signed-off-by: Sarah Sharp <[EMAIL PROTECTED]>
---
drivers/usb/serial/pl2303.c | 64 ++++++++++++++++++++++++-------------------
1 files changed, 36 insertions(+), 28 deletions(-)
diff --git a/drivers/usb/serial/pl2303.c b/drivers/usb/serial/pl2303.c
index eaf6655..8a36981 100644
--- a/drivers/usb/serial/pl2303.c
+++ b/drivers/usb/serial/pl2303.c
@@ -310,6 +310,28 @@ static unsigned int pl2303_buf_get(struct pl2303_buf *pb,
char *buf,
return count;
}
+static int pl2303_vendor_read(__u16 value, __u16 index,
+ struct usb_serial *serial, unsigned char *buf)
+{
+ int res = usb_control_msg(serial->dev, usb_rcvctrlpipe(serial->dev, 0),
+ VENDOR_READ_REQUEST, VENDOR_READ_REQUEST_TYPE,
+ value, index, buf, 1, 100);
+ dbg("0x%x:0x%x:0x%x:0x%x %d - %x", VENDOR_READ_REQUEST_TYPE,
+ VENDOR_READ_REQUEST, value, index, res, buf[0]);
+ return res;
+}
+
+static int pl2303_vendor_write(__u16 value, __u16 index,
+ struct usb_serial *serial)
+{
+ int res = usb_control_msg(serial->dev, usb_sndctrlpipe(serial->dev, 0),
+ VENDOR_WRITE_REQUEST, VENDOR_WRITE_REQUEST_TYPE,
+ value, index, NULL, 0, 100);
+ dbg("0x%x:0x%x:0x%x:0x%x %d", VENDOR_WRITE_REQUEST_TYPE,
+ VENDOR_WRITE_REQUEST, value, index, res);
+ return res;
+}
+
static int pl2303_startup(struct usb_serial *serial)
{
struct pl2303_private *priv;
@@ -685,39 +707,25 @@ static int pl2303_open(struct usb_serial_port *port,
struct file *filp)
if (buf==NULL)
return -ENOMEM;
-#define FISH(c, d, result, serial, buf)
\
- *result=usb_control_msg(serial->dev, usb_rcvctrlpipe(serial->dev,0),
\
- VENDOR_READ_REQUEST, VENDOR_READ_REQUEST_TYPE,
\
- c, d, buf, 1, 100);
\
- dbg("0x%x:0x%x:0x%x:0x%x %d - %x", VENDOR_READ_REQUEST_TYPE,
\
- VENDOR_READ_REQUEST, c, d, *result, buf[0]);
-
-#define SOUP(c, d, result, serial)
\
- *result=usb_control_msg(serial->dev, usb_sndctrlpipe(serial->dev,0),
\
- VENDOR_WRITE_REQUEST, VENDOR_WRITE_REQUEST_TYPE,
\
- c, d, NULL, 0, 100);
\
- dbg("0x%x:0x%x:0x%x:0x%x %d", VENDOR_WRITE_REQUEST_TYPE,
\
- VENDOR_WRITE_REQUEST, c, d, *result);
-
- FISH (0x8484, 0, &result, serial, buf);
- SOUP (0x0404, 0, &result, serial);
- FISH (0x8484, 0, &result, serial, buf);
- FISH (0x8383, 0, &result, serial, buf);
- FISH (0x8484, 0, &result, serial, buf);
- SOUP (0x0404, 1, &result, serial);
- FISH (0x8484, 0, &result, serial, buf);
- FISH (0x8383, 0, &result, serial, buf);
- SOUP (0, 1, &result, serial);
- SOUP (1, 0, &result, serial);
+ pl2303_vendor_read(0x8484, 0, serial, buf);
+ pl2303_vendor_write(0x0404, 0, serial);
+ pl2303_vendor_read(0x8484, 0, serial, buf);
+ pl2303_vendor_read(0x8383, 0, serial, buf);
+ pl2303_vendor_read(0x8484, 0, serial, buf);
+ pl2303_vendor_write(0x0404, 1, serial);
+ pl2303_vendor_read(0x8484, 0, serial, buf);
+ pl2303_vendor_read(0x8383, 0, serial, buf);
+ pl2303_vendor_write(0, 1, serial);
+ pl2303_vendor_write(1, 0, serial);
if (priv->type == HX) {
/* HX chip */
- SOUP (2, 0x44, &result, serial);
+ pl2303_vendor_write(2, 0x44, serial);
/* reset upstream data pipes */
- SOUP (8, 0, &result, serial);
- SOUP (9, 0, &result, serial);
+ pl2303_vendor_write(8, 0, serial);
+ pl2303_vendor_write(9, 0, serial);
} else {
- SOUP (2, 0x24, &result, serial);
+ pl2303_vendor_write(2, 0x24, serial);
}
kfree(buf);
--
1.5.3.1
-
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at http://vger.kernel.org/majordomo-info.html