modify cdc_ether for usb dma data align: support rtl8152B usb ethernet
authorhwg <hwg@rock-chips.com>
Sat, 8 Jun 2013 11:32:04 +0000 (19:32 +0800)
committerhwg <hwg@rock-chips.com>
Sat, 8 Jun 2013 11:32:04 +0000 (19:32 +0800)
drivers/net/usb/cdc_ether.c

index 544c309e0d9590febd679a0c561ea1bd70f7cbfd..5fe4f5bcf9177482d33dbaa5507fd42f68faefcc 100644 (file)
@@ -460,6 +460,23 @@ static int cdc_manage_power(struct usbnet *dev, int on)
        return 0;
 }
 
+static struct sk_buff *android_tx_fixup(struct usbnet *dev,
+                                       struct sk_buff *skb,
+                                       gfp_t flags)
+{
+       struct sk_buff *tx_skb;
+
+       if ((unsigned long)skb->data % 4) {
+               tx_skb = alloc_skb(skb->len + NET_IP_ALIGN, flags);
+               if (tx_skb)
+                       memcpy(skb_put(tx_skb, skb->len), skb->data, skb->len);
+               dev_kfree_skb_any(skb);
+       } else
+               tx_skb = skb;
+
+       return tx_skb;
+}
+
 static const struct driver_info        cdc_info = {
        .description =  "CDC Ethernet Device",
        .flags =        FLAG_ETHER | FLAG_POINTTOPOINT,
@@ -468,6 +485,7 @@ static const struct driver_info     cdc_info = {
        .unbind =       usbnet_cdc_unbind,
        .status =       usbnet_cdc_status,
        .manage_power = cdc_manage_power,
+        .tx_fixup =    android_tx_fixup,
 };
 
 static const struct driver_info wwan_info = {