diff options
author | Sarah Sharp <saharabeara@gmail.com> | 2007-12-14 17:08:00 -0500 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@suse.de> | 2008-02-01 17:34:55 -0500 |
commit | eb44da0b3aa0105cb38d81c5747a8feae64834be (patch) | |
tree | 7907396d7a749fa5d2fb0b2d4d2421eb75b3517e /drivers/usb/serial/pl2303.c | |
parent | caf29f62655e7aa57996821535d11fa3b0537b6b (diff) |
USB: pl2303: Cleanup FISH and SOUP macros in pl2303 driver.
Replace the FISH and SOUP macros that violated the macro guidelines in CodingStyle.
Turn them into function calls with clearer variable names.
Signed-off-by: Sarah Sharp <saharabeara@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
Diffstat (limited to 'drivers/usb/serial/pl2303.c')
-rw-r--r-- | drivers/usb/serial/pl2303.c | 78 |
1 files changed, 39 insertions, 39 deletions
diff --git a/drivers/usb/serial/pl2303.c b/drivers/usb/serial/pl2303.c index b7da8b5c3a86..fd8c09fd3288 100644 --- a/drivers/usb/serial/pl2303.c +++ b/drivers/usb/serial/pl2303.c | |||
@@ -312,6 +312,28 @@ static unsigned int pl2303_buf_get(struct pl2303_buf *pb, char *buf, | |||
312 | return count; | 312 | return count; |
313 | } | 313 | } |
314 | 314 | ||
315 | static int pl2303_vendor_read(__u16 value, __u16 index, | ||
316 | struct usb_serial *serial, unsigned char *buf) | ||
317 | { | ||
318 | int res = usb_control_msg(serial->dev, usb_rcvctrlpipe(serial->dev, 0), | ||
319 | VENDOR_READ_REQUEST, VENDOR_READ_REQUEST_TYPE, | ||
320 | value, index, buf, 1, 100); | ||
321 | dbg("0x%x:0x%x:0x%x:0x%x %d - %x", VENDOR_READ_REQUEST_TYPE, | ||
322 | VENDOR_READ_REQUEST, value, index, res, buf[0]); | ||
323 | return res; | ||
324 | } | ||
325 | |||
326 | static int pl2303_vendor_write(__u16 value, __u16 index, | ||
327 | struct usb_serial *serial) | ||
328 | { | ||
329 | int res = usb_control_msg(serial->dev, usb_sndctrlpipe(serial->dev, 0), | ||
330 | VENDOR_WRITE_REQUEST, VENDOR_WRITE_REQUEST_TYPE, | ||
331 | value, index, NULL, 0, 100); | ||
332 | dbg("0x%x:0x%x:0x%x:0x%x %d", VENDOR_WRITE_REQUEST_TYPE, | ||
333 | VENDOR_WRITE_REQUEST, value, index, res); | ||
334 | return res; | ||
335 | } | ||
336 | |||
315 | static int pl2303_startup(struct usb_serial *serial) | 337 | static int pl2303_startup(struct usb_serial *serial) |
316 | { | 338 | { |
317 | struct pl2303_private *priv; | 339 | struct pl2303_private *priv; |
@@ -584,24 +606,12 @@ static void pl2303_set_termios(struct usb_serial_port *port, | |||
584 | buf[0], buf[1], buf[2], buf[3], buf[4], buf[5], buf[6]); | 606 | buf[0], buf[1], buf[2], buf[3], buf[4], buf[5], buf[6]); |
585 | 607 | ||
586 | if (cflag & CRTSCTS) { | 608 | if (cflag & CRTSCTS) { |
587 | __u16 index; | ||
588 | if (priv->type == HX) | 609 | if (priv->type == HX) |
589 | index = 0x61; | 610 | pl2303_vendor_write(0x0, 0x61, serial); |
590 | else | 611 | else |
591 | index = 0x41; | 612 | pl2303_vendor_write(0x0, 0x41, serial); |
592 | i = usb_control_msg(serial->dev, | ||
593 | usb_sndctrlpipe(serial->dev, 0), | ||
594 | VENDOR_WRITE_REQUEST, | ||
595 | VENDOR_WRITE_REQUEST_TYPE, | ||
596 | 0x0, index, NULL, 0, 100); | ||
597 | dbg("0x40:0x1:0x0:0x%x %d", index, i); | ||
598 | } else { | 613 | } else { |
599 | i = usb_control_msg(serial->dev, | 614 | pl2303_vendor_write(0x0, 0x0, serial); |
600 | usb_sndctrlpipe(serial->dev, 0), | ||
601 | VENDOR_WRITE_REQUEST, | ||
602 | VENDOR_WRITE_REQUEST_TYPE, | ||
603 | 0x0, 0x0, NULL, 0, 100); | ||
604 | dbg ("0x40:0x1:0x0:0x0 %d", i); | ||
605 | } | 615 | } |
606 | 616 | ||
607 | /* FIXME: Need to read back resulting baud rate */ | 617 | /* FIXME: Need to read back resulting baud rate */ |
@@ -694,35 +704,25 @@ static int pl2303_open(struct usb_serial_port *port, struct file *filp) | |||
694 | if (buf==NULL) | 704 | if (buf==NULL) |
695 | return -ENOMEM; | 705 | return -ENOMEM; |
696 | 706 | ||
697 | #define FISH(a,b,c,d) \ | 707 | pl2303_vendor_read(0x8484, 0, serial, buf); |
698 | result=usb_control_msg(serial->dev, usb_rcvctrlpipe(serial->dev,0), \ | 708 | pl2303_vendor_write(0x0404, 0, serial); |
699 | b, a, c, d, buf, 1, 100); \ | 709 | pl2303_vendor_read(0x8484, 0, serial, buf); |
700 | dbg("0x%x:0x%x:0x%x:0x%x %d - %x",a,b,c,d,result,buf[0]); | 710 | pl2303_vendor_read(0x8383, 0, serial, buf); |
701 | 711 | pl2303_vendor_read(0x8484, 0, serial, buf); | |
702 | #define SOUP(a,b,c,d) \ | 712 | pl2303_vendor_write(0x0404, 1, serial); |
703 | result=usb_control_msg(serial->dev, usb_sndctrlpipe(serial->dev,0), \ | 713 | pl2303_vendor_read(0x8484, 0, serial, buf); |
704 | b, a, c, d, NULL, 0, 100); \ | 714 | pl2303_vendor_read(0x8383, 0, serial, buf); |
705 | dbg("0x%x:0x%x:0x%x:0x%x %d",a,b,c,d,result); | 715 | pl2303_vendor_write(0, 1, serial); |
706 | 716 | pl2303_vendor_write(1, 0, serial); | |
707 | FISH (VENDOR_READ_REQUEST_TYPE, VENDOR_READ_REQUEST, 0x8484, 0); | ||
708 | SOUP (VENDOR_WRITE_REQUEST_TYPE, VENDOR_WRITE_REQUEST, 0x0404, 0); | ||
709 | FISH (VENDOR_READ_REQUEST_TYPE, VENDOR_READ_REQUEST, 0x8484, 0); | ||
710 | FISH (VENDOR_READ_REQUEST_TYPE, VENDOR_READ_REQUEST, 0x8383, 0); | ||
711 | FISH (VENDOR_READ_REQUEST_TYPE, VENDOR_READ_REQUEST, 0x8484, 0); | ||
712 | SOUP (VENDOR_WRITE_REQUEST_TYPE, VENDOR_WRITE_REQUEST, 0x0404, 1); | ||
713 | FISH (VENDOR_READ_REQUEST_TYPE, VENDOR_READ_REQUEST, 0x8484, 0); | ||
714 | FISH (VENDOR_READ_REQUEST_TYPE, VENDOR_READ_REQUEST, 0x8383, 0); | ||
715 | SOUP (VENDOR_WRITE_REQUEST_TYPE, VENDOR_WRITE_REQUEST, 0, 1); | ||
716 | SOUP (VENDOR_WRITE_REQUEST_TYPE, VENDOR_WRITE_REQUEST, 1, 0); | ||
717 | 717 | ||
718 | if (priv->type == HX) { | 718 | if (priv->type == HX) { |
719 | /* HX chip */ | 719 | /* HX chip */ |
720 | SOUP (VENDOR_WRITE_REQUEST_TYPE, VENDOR_WRITE_REQUEST, 2, 0x44); | 720 | pl2303_vendor_write(2, 0x44, serial); |
721 | /* reset upstream data pipes */ | 721 | /* reset upstream data pipes */ |
722 | SOUP (VENDOR_WRITE_REQUEST_TYPE, VENDOR_WRITE_REQUEST, 8, 0); | 722 | pl2303_vendor_write(8, 0, serial); |
723 | SOUP (VENDOR_WRITE_REQUEST_TYPE, VENDOR_WRITE_REQUEST, 9, 0); | 723 | pl2303_vendor_write(9, 0, serial); |
724 | } else { | 724 | } else { |
725 | SOUP (VENDOR_WRITE_REQUEST_TYPE, VENDOR_WRITE_REQUEST, 2, 0x24); | 725 | pl2303_vendor_write(2, 0x24, serial); |
726 | } | 726 | } |
727 | 727 | ||
728 | kfree(buf); | 728 | kfree(buf); |