login
Header Space

 
 

[PATCH 1/6] sis190: use the allocated buffer as a status code in sis190_alloc_rx_skb

Score:
Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]
To: <jeff@...>
Cc: <netdev@...>, <akpm@...>, Stephen Hemminger <shemminger@...>
Date: Sunday, April 27, 2008 - 1:01 pm

The local status code does not carry mory information.

Signed-off-by: Stephen Hemminger <shemminger@vyatta.com>
Acked-by: Francois Romieu <romieu@fr.zoreil.com>
---
 drivers/net/sis190.c |   37 +++++++++++++++----------------------
 1 files changed, 15 insertions(+), 22 deletions(-)

diff --git a/drivers/net/sis190.c b/drivers/net/sis190.c
index 20745fd..0d6aa1f 100644
--- a/drivers/net/sis190.c
+++ b/drivers/net/sis190.c
@@ -480,30 +480,22 @@ static inline void sis190_make_unusable_by_asic(struct RxDesc *desc)
 	desc->status = 0x0;
 }
 
-static int sis190_alloc_rx_skb(struct pci_dev *pdev, struct sk_buff **sk_buff,
-			       struct RxDesc *desc, u32 rx_buf_sz)
+static struct sk_buff *sis190_alloc_rx_skb(struct pci_dev *pdev,
+					   struct RxDesc *desc, u32 rx_buf_sz)
 {
 	struct sk_buff *skb;
-	dma_addr_t mapping;
-	int ret = 0;
 
 	skb = dev_alloc_skb(rx_buf_sz);
-	if (!skb)
-		goto err_out;
-
-	*sk_buff = skb;
-
-	mapping = pci_map_single(pdev, skb->data, rx_buf_sz,
-				 PCI_DMA_FROMDEVICE);
+	if (likely(skb)) {
+		dma_addr_t mapping;
 
-	sis190_map_to_asic(desc, mapping, rx_buf_sz);
-out:
-	return ret;
+		mapping = pci_map_single(pdev, skb->data, rx_buf_sz,
+					 PCI_DMA_FROMDEVICE);
+		sis190_map_to_asic(desc, mapping, rx_buf_sz);
+	} else
+		sis190_make_unusable_by_asic(desc);
 
-err_out:
-	ret = -ENOMEM;
-	sis190_make_unusable_by_asic(desc);
-	goto out;
+	return skb;
 }
 
 static u32 sis190_rx_fill(struct sis190_private *tp, struct net_device *dev,
@@ -512,14 +504,15 @@ static u32 sis190_rx_fill(struct sis190_private *tp, struct net_device *dev,
 	u32 cur;
 
 	for (cur = start; cur < end; cur++) {
-		int ret, i = cur % NUM_RX_DESC;
+		unsigned int i = cur % NUM_RX_DESC;
 
 		if (tp->Rx_skbuff[i])
 			continue;
 
-		ret = sis190_alloc_rx_skb(tp->pci_dev, tp->Rx_skbuff + i,
-					  tp->RxDescRing + i, tp->rx_buf_sz);
-		if (ret < 0)
+		tp->Rx_skbuff[i] = sis190_alloc_rx_skb(tp->pci_dev,
+						       tp->RxDescRing + i,
+						       tp->rx_buf_sz);
+		if (!tp->Rx_skbuff[i])
 			break;
 	}
 	return cur - start;
-- 
1.5.3.3

--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]

Messages in current thread:
[RFT 0/6] sis190 branch info, Francois Romieu, (Sun Apr 27, 1:00 pm)
Re: [RFT 0/6] sis190 branch info, Andrew Morton, (Thu May 1, 7:10 pm)
Re: [RFT 0/6] sis190 branch info, Jeff Garzik, (Tue Apr 29, 1:47 am)
[PATCH 6/6] sis190: account for Tx errors, Francois Romieu, (Sun Apr 27, 1:06 pm)
Re: [PATCH 6/6] sis190: account for Tx errors, Andrew Morton, (Thu May 1, 7:16 pm)
[PATCH 5/6] sis190: remove needless MII reset, Francois Romieu, (Sun Apr 27, 1:05 pm)
[PATCH 4/6] sis190: Rx path update, Francois Romieu, (Sun Apr 27, 1:04 pm)
[PATCH 3/6] sis190: use netdev_alloc_skb, Francois Romieu, (Sun Apr 27, 1:03 pm)
[PATCH 2/6] sis190: hard-code the alignment of tiny packets, Francois Romieu, (Sun Apr 27, 1:02 pm)
[PATCH 1/6] sis190: use the allocated buffer as a status cod..., Francois Romieu, (Sun Apr 27, 1:01 pm)
speck-geostationary