hdlc: Simplify code in 'pvc_xmit()'
diff mbox series

Message ID 20190921061738.25326-1-christophe.jaillet@wanadoo.fr
State Changes Requested
Delegated to: David Miller
Headers show
Series
  • hdlc: Simplify code in 'pvc_xmit()'
Related show

Commit Message

Christophe JAILLET Sept. 21, 2019, 6:17 a.m. UTC
Use __skb_pad instead of rewriting it, this saves some LoC.

Signed-off-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr>
---
Compile tested only.
---
 drivers/net/wan/hdlc_fr.c | 14 +++++---------
 1 file changed, 5 insertions(+), 9 deletions(-)

Comments

David Miller Sept. 25, 2019, 11:43 a.m. UTC | #1
From: Christophe JAILLET <christophe.jaillet@wanadoo.fr>
Date: Sat, 21 Sep 2019 08:17:38 +0200

> Use __skb_pad instead of rewriting it, this saves some LoC.
> 
> Signed-off-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr>
> ---
> Compile tested only.

Please test this code and resubmit for net-next, thank you.

Patch
diff mbox series

diff --git a/drivers/net/wan/hdlc_fr.c b/drivers/net/wan/hdlc_fr.c
index 9acad651ea1f..30f20b667c8b 100644
--- a/drivers/net/wan/hdlc_fr.c
+++ b/drivers/net/wan/hdlc_fr.c
@@ -414,16 +414,12 @@  static netdev_tx_t pvc_xmit(struct sk_buff *skb, struct net_device *dev)
 		if (dev->type == ARPHRD_ETHER) {
 			int pad = ETH_ZLEN - skb->len;
 			if (pad > 0) { /* Pad the frame with zeros */
-				int len = skb->len;
-				if (skb_tailroom(skb) < pad)
-					if (pskb_expand_head(skb, 0, pad,
-							     GFP_ATOMIC)) {
-						dev->stats.tx_dropped++;
-						dev_kfree_skb(skb);
-						return NETDEV_TX_OK;
-					}
+				if (__skb_pad(skb, pad, false) < 0) {
+					dev->stats.tx_dropped++;
+					dev_kfree_skb(skb);
+					return NETDEV_TX_OK;
+				}
 				skb_put(skb, pad);
-				memset(skb->data + len, 0, pad);
 			}
 			skb->protocol = cpu_to_be16(ETH_P_802_3);
 		}