Skip to content

Commit 7240bf6

Browse files
Shravya Kumbhamdavem330
authored andcommitted
net: emaclite: Remove custom BUFFER_ALIGN macro
BUFFER_ALIGN macro is used to calculate the number of bytes required for the next alignment. Instead of this, we can directly use the skb_reserve(skb, NET_IP_ALIGN) to make the protocol header buffer aligned on at least a 4-byte boundary, where the NET_IP_ALIGN is by default defined as 2. So removing the BUFFER_ALIGN and its related defines which it can be done by the skb_reserve() itself. Signed-off-by: Shravya Kumbham <[email protected]> Signed-off-by: Radhey Shyam Pandey <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent 7ae7d49 commit 7240bf6

File tree

1 file changed

+2
-16
lines changed

1 file changed

+2
-16
lines changed

drivers/net/ethernet/xilinx/xilinx_emaclite.c

Lines changed: 2 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -91,10 +91,6 @@
9191
#define XEL_HEADER_IP_LENGTH_OFFSET 16 /* IP Length Offset */
9292

9393
#define TX_TIMEOUT (60 * HZ) /* Tx timeout is 60 seconds. */
94-
#define ALIGNMENT 4
95-
96-
/* BUFFER_ALIGN(adr) calculates the number of bytes to the next alignment. */
97-
#define BUFFER_ALIGN(adr) ((ALIGNMENT - ((uintptr_t)adr)) % ALIGNMENT)
9894

9995
#ifdef __BIG_ENDIAN
10096
#define xemaclite_readl ioread32be
@@ -595,28 +591,18 @@ static void xemaclite_rx_handler(struct net_device *dev)
595591
{
596592
struct net_local *lp = netdev_priv(dev);
597593
struct sk_buff *skb;
598-
unsigned int align;
599594
u32 len;
600595

601596
len = ETH_FRAME_LEN + ETH_FCS_LEN;
602-
skb = netdev_alloc_skb(dev, len + ALIGNMENT);
597+
skb = netdev_alloc_skb(dev, len + NET_IP_ALIGN);
603598
if (!skb) {
604599
/* Couldn't get memory. */
605600
dev->stats.rx_dropped++;
606601
dev_err(&lp->ndev->dev, "Could not allocate receive buffer\n");
607602
return;
608603
}
609604

610-
/* A new skb should have the data halfword aligned, but this code is
611-
* here just in case that isn't true. Calculate how many
612-
* bytes we should reserve to get the data to start on a word
613-
* boundary
614-
*/
615-
align = BUFFER_ALIGN(skb->data);
616-
if (align)
617-
skb_reserve(skb, align);
618-
619-
skb_reserve(skb, 2);
605+
skb_reserve(skb, NET_IP_ALIGN);
620606

621607
len = xemaclite_recv_data(lp, (u8 *)skb->data, len);
622608

0 commit comments

Comments
 (0)