diff options
author | Gabor Juhos <juhosg@openwrt.org> | 2012-02-15 18:33:42 +0000 |
---|---|---|
committer | Gabor Juhos <juhosg@openwrt.org> | 2012-02-15 18:33:42 +0000 |
commit | 92b44035cbccf853dafd91c07511ba51a0eef8a2 (patch) | |
tree | 0f2cc74e6b5bb76e7941bca07b63f469122462b3 /target/linux/ramips/files/drivers/net | |
parent | 4a3dcaa55d80781c65fbb8020218765bef97fd2f (diff) | |
download | master-187ad058-92b44035cbccf853dafd91c07511ba51a0eef8a2.tar.gz master-187ad058-92b44035cbccf853dafd91c07511ba51a0eef8a2.tar.bz2 master-187ad058-92b44035cbccf853dafd91c07511ba51a0eef8a2.zip |
ramips: raeth: add a helper function for skb allocation
git-svn-id: svn://svn.openwrt.org/openwrt/trunk@30555 3c298f89-4303-0410-b956-a3cf2f4a3e73
Diffstat (limited to 'target/linux/ramips/files/drivers/net')
-rw-r--r-- | target/linux/ramips/files/drivers/net/ramips.c | 22 |
1 files changed, 16 insertions, 6 deletions
diff --git a/target/linux/ramips/files/drivers/net/ramips.c b/target/linux/ramips/files/drivers/net/ramips.c index f9864500f7..7f0f8c469e 100644 --- a/target/linux/ramips/files/drivers/net/ramips.c +++ b/target/linux/ramips/files/drivers/net/ramips.c @@ -88,6 +88,20 @@ ramips_hw_set_macaddr(unsigned char *mac) RAMIPS_GDMA1_MAC_ADRL); } +static struct sk_buff * +ramips_alloc_skb(struct raeth_priv *re) +{ + struct sk_buff *skb; + + skb = netdev_alloc_skb(re->netdev, MAX_RX_LENGTH + NET_IP_ALIGN); + if (!skb) + return NULL; + + skb_reserve(skb, NET_IP_ALIGN); + + return skb; +} + #if defined(CONFIG_RALINK_RT288X) || defined(CONFIG_RALINK_RT3883) #define RAMIPS_MDIO_RETRY 1000 @@ -522,13 +536,10 @@ ramips_alloc_dma(struct raeth_priv *re) dma_addr_t dma_addr; struct sk_buff *new_skb; - new_skb = netdev_alloc_skb(re->netdev, - MAX_RX_LENGTH + NET_IP_ALIGN); + new_skb = ramips_alloc_skb(re); if (!new_skb) goto err_cleanup; - skb_reserve(new_skb, NET_IP_ALIGN); - dma_addr = dma_map_single(&re->netdev->dev, new_skb->data, MAX_RX_LENGTH, DMA_FROM_DEVICE); re->rx_dma[i] = dma_addr; @@ -629,7 +640,7 @@ ramips_eth_rx_hw(unsigned long ptr) rx_skb = re->rx_skb[rx]; pktlen = RX_DMA_PLEN0(re->rx[rx].rxd2); - new_skb = netdev_alloc_skb(dev, MAX_RX_LENGTH + NET_IP_ALIGN); + new_skb = ramips_alloc_skb(re); /* Reuse the buffer on allocation failures */ if (new_skb) { dma_addr_t dma_addr; @@ -646,7 +657,6 @@ ramips_eth_rx_hw(unsigned long ptr) netif_rx(rx_skb); re->rx_skb[rx] = new_skb; - skb_reserve(new_skb, NET_IP_ALIGN); dma_addr = dma_map_single(&re->netdev->dev, new_skb->data, |