diff options
Diffstat (limited to 'drivers/net/irda/irda-usb.c')
-rw-r--r-- | drivers/net/irda/irda-usb.c | 45 |
1 files changed, 20 insertions, 25 deletions
diff --git a/drivers/net/irda/irda-usb.c b/drivers/net/irda/irda-usb.c index 3ca1082ec776..340ee99652eb 100644 --- a/drivers/net/irda/irda-usb.c +++ b/drivers/net/irda/irda-usb.c | |||
@@ -441,25 +441,13 @@ static int irda_usb_hard_xmit(struct sk_buff *skb, struct net_device *netdev) | |||
441 | goto drop; | 441 | goto drop; |
442 | } | 442 | } |
443 | 443 | ||
444 | /* Make sure there is room for IrDA-USB header. The actual | 444 | memcpy(self->tx_buff + self->header_length, skb->data, skb->len); |
445 | * allocation will be done lower in skb_push(). | ||
446 | * Also, we don't use directly skb_cow(), because it require | ||
447 | * headroom >= 16, which force unnecessary copies - Jean II */ | ||
448 | if (skb_headroom(skb) < self->header_length) { | ||
449 | IRDA_DEBUG(0, "%s(), Insuficient skb headroom.\n", __FUNCTION__); | ||
450 | if (skb_cow(skb, self->header_length)) { | ||
451 | IRDA_WARNING("%s(), failed skb_cow() !!!\n", __FUNCTION__); | ||
452 | goto drop; | ||
453 | } | ||
454 | } | ||
455 | 445 | ||
456 | /* Change setting for next frame */ | 446 | /* Change setting for next frame */ |
457 | |||
458 | if (self->capability & IUC_STIR421X) { | 447 | if (self->capability & IUC_STIR421X) { |
459 | __u8 turnaround_time; | 448 | __u8 turnaround_time; |
460 | __u8* frame; | 449 | __u8* frame = self->tx_buff; |
461 | turnaround_time = get_turnaround_time( skb ); | 450 | turnaround_time = get_turnaround_time( skb ); |
462 | frame= skb_push(skb, self->header_length); | ||
463 | irda_usb_build_header(self, frame, 0); | 451 | irda_usb_build_header(self, frame, 0); |
464 | frame[2] = turnaround_time; | 452 | frame[2] = turnaround_time; |
465 | if ((skb->len != 0) && | 453 | if ((skb->len != 0) && |
@@ -472,17 +460,17 @@ static int irda_usb_hard_xmit(struct sk_buff *skb, struct net_device *netdev) | |||
472 | frame[1] = 0; | 460 | frame[1] = 0; |
473 | } | 461 | } |
474 | } else { | 462 | } else { |
475 | irda_usb_build_header(self, skb_push(skb, self->header_length), 0); | 463 | irda_usb_build_header(self, self->tx_buff, 0); |
476 | } | 464 | } |
477 | 465 | ||
478 | /* FIXME: Make macro out of this one */ | 466 | /* FIXME: Make macro out of this one */ |
479 | ((struct irda_skb_cb *)skb->cb)->context = self; | 467 | ((struct irda_skb_cb *)skb->cb)->context = self; |
480 | 468 | ||
481 | usb_fill_bulk_urb(urb, self->usbdev, | 469 | usb_fill_bulk_urb(urb, self->usbdev, |
482 | usb_sndbulkpipe(self->usbdev, self->bulk_out_ep), | 470 | usb_sndbulkpipe(self->usbdev, self->bulk_out_ep), |
483 | skb->data, IRDA_SKB_MAX_MTU, | 471 | self->tx_buff, skb->len + self->header_length, |
484 | write_bulk_callback, skb); | 472 | write_bulk_callback, skb); |
485 | urb->transfer_buffer_length = skb->len; | 473 | |
486 | /* This flag (URB_ZERO_PACKET) indicates that what we send is not | 474 | /* This flag (URB_ZERO_PACKET) indicates that what we send is not |
487 | * a continuous stream of data but separate packets. | 475 | * a continuous stream of data but separate packets. |
488 | * In this case, the USB layer will insert an empty USB frame (TD) | 476 | * In this case, the USB layer will insert an empty USB frame (TD) |
@@ -1455,6 +1443,9 @@ static inline void irda_usb_close(struct irda_usb_cb *self) | |||
1455 | /* Remove the speed buffer */ | 1443 | /* Remove the speed buffer */ |
1456 | kfree(self->speed_buff); | 1444 | kfree(self->speed_buff); |
1457 | self->speed_buff = NULL; | 1445 | self->speed_buff = NULL; |
1446 | |||
1447 | kfree(self->tx_buff); | ||
1448 | self->tx_buff = NULL; | ||
1458 | } | 1449 | } |
1459 | 1450 | ||
1460 | /********************** USB CONFIG SUBROUTINES **********************/ | 1451 | /********************** USB CONFIG SUBROUTINES **********************/ |
@@ -1524,8 +1515,6 @@ static inline int irda_usb_parse_endpoints(struct irda_usb_cb *self, struct usb_ | |||
1524 | 1515 | ||
1525 | IRDA_DEBUG(0, "%s(), And our endpoints are : in=%02X, out=%02X (%d), int=%02X\n", | 1516 | IRDA_DEBUG(0, "%s(), And our endpoints are : in=%02X, out=%02X (%d), int=%02X\n", |
1526 | __FUNCTION__, self->bulk_in_ep, self->bulk_out_ep, self->bulk_out_mtu, self->bulk_int_ep); | 1517 | __FUNCTION__, self->bulk_in_ep, self->bulk_out_ep, self->bulk_out_mtu, self->bulk_int_ep); |
1527 | /* Should be 8, 16, 32 or 64 bytes */ | ||
1528 | IRDA_ASSERT(self->bulk_out_mtu == 64, ;); | ||
1529 | 1518 | ||
1530 | return((self->bulk_in_ep != 0) && (self->bulk_out_ep != 0)); | 1519 | return((self->bulk_in_ep != 0) && (self->bulk_out_ep != 0)); |
1531 | } | 1520 | } |
@@ -1753,9 +1742,14 @@ static int irda_usb_probe(struct usb_interface *intf, | |||
1753 | 1742 | ||
1754 | memset(self->speed_buff, 0, IRDA_USB_SPEED_MTU); | 1743 | memset(self->speed_buff, 0, IRDA_USB_SPEED_MTU); |
1755 | 1744 | ||
1745 | self->tx_buff = kzalloc(IRDA_SKB_MAX_MTU + self->header_length, | ||
1746 | GFP_KERNEL); | ||
1747 | if (self->tx_buff == NULL) | ||
1748 | goto err_out_4; | ||
1749 | |||
1756 | ret = irda_usb_open(self); | 1750 | ret = irda_usb_open(self); |
1757 | if (ret) | 1751 | if (ret) |
1758 | goto err_out_4; | 1752 | goto err_out_5; |
1759 | 1753 | ||
1760 | IRDA_MESSAGE("IrDA: Registered device %s\n", net->name); | 1754 | IRDA_MESSAGE("IrDA: Registered device %s\n", net->name); |
1761 | usb_set_intfdata(intf, self); | 1755 | usb_set_intfdata(intf, self); |
@@ -1766,14 +1760,14 @@ static int irda_usb_probe(struct usb_interface *intf, | |||
1766 | self->needspatch = (ret < 0); | 1760 | self->needspatch = (ret < 0); |
1767 | if (self->needspatch) { | 1761 | if (self->needspatch) { |
1768 | IRDA_ERROR("STIR421X: Couldn't upload patch\n"); | 1762 | IRDA_ERROR("STIR421X: Couldn't upload patch\n"); |
1769 | goto err_out_5; | 1763 | goto err_out_6; |
1770 | } | 1764 | } |
1771 | 1765 | ||
1772 | /* replace IrDA class descriptor with what patched device is now reporting */ | 1766 | /* replace IrDA class descriptor with what patched device is now reporting */ |
1773 | irda_desc = irda_usb_find_class_desc (self->usbintf); | 1767 | irda_desc = irda_usb_find_class_desc (self->usbintf); |
1774 | if (irda_desc == NULL) { | 1768 | if (irda_desc == NULL) { |
1775 | ret = -ENODEV; | 1769 | ret = -ENODEV; |
1776 | goto err_out_5; | 1770 | goto err_out_6; |
1777 | } | 1771 | } |
1778 | if (self->irda_desc) | 1772 | if (self->irda_desc) |
1779 | kfree (self->irda_desc); | 1773 | kfree (self->irda_desc); |
@@ -1782,9 +1776,10 @@ static int irda_usb_probe(struct usb_interface *intf, | |||
1782 | } | 1776 | } |
1783 | 1777 | ||
1784 | return 0; | 1778 | return 0; |
1785 | 1779 | err_out_6: | |
1786 | err_out_5: | ||
1787 | unregister_netdev(self->netdev); | 1780 | unregister_netdev(self->netdev); |
1781 | err_out_5: | ||
1782 | kfree(self->tx_buff); | ||
1788 | err_out_4: | 1783 | err_out_4: |
1789 | kfree(self->speed_buff); | 1784 | kfree(self->speed_buff); |
1790 | err_out_3: | 1785 | err_out_3: |