diff options
author | Joe Perches <joe@perches.com> | 2010-12-21 05:16:09 -0500 |
---|---|---|
committer | Joe Perches <joe@perches.com> | 2010-12-21 05:16:09 -0500 |
commit | 5591c75dc345d93d353d2ab2962824648a73efe4 (patch) | |
tree | a30401fe622d24bdcc2ca8b95319fa1a31eb909d /drivers/net/usb | |
parent | b6bc765067ece933cc3dc7f5e95665a89100b1d5 (diff) |
usb: Use static const, consolidate code
Using static const generally increases object text and decreases data size.
It also generally decreases overall object size.
Consolidate duplicated code into new fix_crc_bug function
and declare data in that function static const.
Signed-off-by: Joe Perches <joe@perches.com>
Diffstat (limited to 'drivers/net/usb')
-rw-r--r-- | drivers/net/usb/hso.c | 39 |
1 files changed, 16 insertions, 23 deletions
diff --git a/drivers/net/usb/hso.c b/drivers/net/usb/hso.c index ebcaaebf6b41..bed8fcedff49 100644 --- a/drivers/net/usb/hso.c +++ b/drivers/net/usb/hso.c | |||
@@ -997,6 +997,18 @@ static void packetizeRx(struct hso_net *odev, unsigned char *ip_pkt, | |||
997 | } | 997 | } |
998 | } | 998 | } |
999 | 999 | ||
1000 | static void fix_crc_bug(struct urb *urb, __le16 max_packet_size) | ||
1001 | { | ||
1002 | static const u8 crc_check[4] = { 0xDE, 0xAD, 0xBE, 0xEF }; | ||
1003 | u32 rest = urb->actual_length % le16_to_cpu(max_packet_size); | ||
1004 | |||
1005 | if (((rest == 5) || (rest == 6)) && | ||
1006 | !memcmp(((u8 *)urb->transfer_buffer) + urb->actual_length - 4, | ||
1007 | crc_check, 4)) { | ||
1008 | urb->actual_length -= 4; | ||
1009 | } | ||
1010 | } | ||
1011 | |||
1000 | /* Moving data from usb to kernel (in interrupt state) */ | 1012 | /* Moving data from usb to kernel (in interrupt state) */ |
1001 | static void read_bulk_callback(struct urb *urb) | 1013 | static void read_bulk_callback(struct urb *urb) |
1002 | { | 1014 | { |
@@ -1025,17 +1037,8 @@ static void read_bulk_callback(struct urb *urb) | |||
1025 | return; | 1037 | return; |
1026 | } | 1038 | } |
1027 | 1039 | ||
1028 | if (odev->parent->port_spec & HSO_INFO_CRC_BUG) { | 1040 | if (odev->parent->port_spec & HSO_INFO_CRC_BUG) |
1029 | u32 rest; | 1041 | fix_crc_bug(urb, odev->in_endp->wMaxPacketSize); |
1030 | u8 crc_check[4] = { 0xDE, 0xAD, 0xBE, 0xEF }; | ||
1031 | rest = urb->actual_length % | ||
1032 | le16_to_cpu(odev->in_endp->wMaxPacketSize); | ||
1033 | if (((rest == 5) || (rest == 6)) && | ||
1034 | !memcmp(((u8 *) urb->transfer_buffer) + | ||
1035 | urb->actual_length - 4, crc_check, 4)) { | ||
1036 | urb->actual_length -= 4; | ||
1037 | } | ||
1038 | } | ||
1039 | 1042 | ||
1040 | /* do we even have a packet? */ | 1043 | /* do we even have a packet? */ |
1041 | if (urb->actual_length) { | 1044 | if (urb->actual_length) { |
@@ -1227,18 +1230,8 @@ static void hso_std_serial_read_bulk_callback(struct urb *urb) | |||
1227 | return; | 1230 | return; |
1228 | 1231 | ||
1229 | if (status == 0) { | 1232 | if (status == 0) { |
1230 | if (serial->parent->port_spec & HSO_INFO_CRC_BUG) { | 1233 | if (serial->parent->port_spec & HSO_INFO_CRC_BUG) |
1231 | u32 rest; | 1234 | fix_crc_bug(urb, serial->in_endp->wMaxPacketSize); |
1232 | u8 crc_check[4] = { 0xDE, 0xAD, 0xBE, 0xEF }; | ||
1233 | rest = | ||
1234 | urb->actual_length % | ||
1235 | le16_to_cpu(serial->in_endp->wMaxPacketSize); | ||
1236 | if (((rest == 5) || (rest == 6)) && | ||
1237 | !memcmp(((u8 *) urb->transfer_buffer) + | ||
1238 | urb->actual_length - 4, crc_check, 4)) { | ||
1239 | urb->actual_length -= 4; | ||
1240 | } | ||
1241 | } | ||
1242 | /* Valid data, handle RX data */ | 1235 | /* Valid data, handle RX data */ |
1243 | spin_lock(&serial->serial_lock); | 1236 | spin_lock(&serial->serial_lock); |
1244 | serial->rx_urb_filled[hso_urb_to_index(serial, urb)] = 1; | 1237 | serial->rx_urb_filled[hso_urb_to_index(serial, urb)] = 1; |