diff mbox series

[net-next,v2,1/2] lib8390: Use eth_skb_pad()

Message ID 20201118165107.12419-2-W_Armin@gmx.de (mailing list archive)
State Changes Requested
Delegated to: Netdev Maintainers
Headers show
Series lib8390: Remove custom padding solution | expand

Checks

Context Check Description
netdev/cover_letter success Link
netdev/fixes_present success Link
netdev/patch_count success Link
netdev/tree_selection success Clearly marked for net-next
netdev/subject_prefix success Link
netdev/source_inline success Was 0 now: 0
netdev/verify_signedoff success Link
netdev/module_param success Was 0 now: 0
netdev/build_32bit success Errors and warnings before: 0 this patch: 0
netdev/kdoc success Errors and warnings before: 1 this patch: 1
netdev/verify_fixes success Link
netdev/checkpatch warning WARNING: drivers/net/ethernet/8390/lib8390.c is marked as 'obsolete' in the MAINTAINERS hierarchy. No unnecessary modifications please.
netdev/build_allmodconfig_warn success Errors and warnings before: 0 this patch: 0
netdev/header_inline success Link
netdev/stable success Stable not CCed

Commit Message

Armin Wolf Nov. 18, 2020, 4:51 p.m. UTC
According to Joe Perches, this bit seems less than optimal
because it overwrites already zeroed content. But instead of
fixing the custom padding solution, replace them entirely
with generic eth_skb_pad().

Signed-off-by: Armin Wolf <W_Armin@gmx.de>
---
 drivers/net/ethernet/8390/lib8390.c | 18 +++++++++---------
 1 file changed, 9 insertions(+), 9 deletions(-)

--
2.20.1
diff mbox series

Patch

diff --git a/drivers/net/ethernet/8390/lib8390.c b/drivers/net/ethernet/8390/lib8390.c
index e84021282edf..b3499714f7e0 100644
--- a/drivers/net/ethernet/8390/lib8390.c
+++ b/drivers/net/ethernet/8390/lib8390.c
@@ -305,17 +305,17 @@  static netdev_tx_t __ei_start_xmit(struct sk_buff *skb,
 {
 	unsigned long e8390_base = dev->base_addr;
 	struct ei_device *ei_local = netdev_priv(dev);
-	int send_length = skb->len, output_page;
+	int send_length, output_page;
 	unsigned long flags;
-	char buf[ETH_ZLEN];
-	char *data = skb->data;
-
-	if (skb->len < ETH_ZLEN) {
-		memset(buf, 0, ETH_ZLEN);	/* more efficient than doing just the needed bits */
-		memcpy(buf, data, skb->len);
-		send_length = ETH_ZLEN;
-		data = buf;
+	char *data;
+
+	/* The Hardware does not pad undersized frames */
+	if (eth_skb_pad(skb)) {
+		dev->stats.tx_dropped++;
+		return NETDEV_TX_OK;
 	}
+	data = skb->data;
+	send_length = skb->len;

 	/* Mask interrupts from the ethercard.
 	   SMP: We have to grab the lock here otherwise the IRQ handler