All of lore.kernel.org
 help / color / mirror / Atom feed
From: Joe Perches <joe@perches.com>
To: Don Fry <pcnet32@frontier.com>
Cc: linux-kernel@vger.kernel.org, netdev@vger.kernel.org
Subject: [PATCH] amd: Neaten and remove unnecessary OOM messages
Date: Mon, 23 Jun 2014 14:36:35 -0700	[thread overview]
Message-ID: <1403559395.20657.8.camel@joe-AO725> (raw)
In-Reply-To: <1403557507.20657.3.camel@joe-AO725>

Make the code flow a little better for 80 columns.

Use a consistent style for the RX and TX rings allocation.
Use BIT macro.
Use a temporary unsiged int entries for (1<<size).
Remove the OOM messages as they duplicate the generic
OOM and dump_stack() provided by the memory subsystem.
Reflow allocs to 80 columns.

Signed-off-by: Joe Perches <joe@perches.com>
---
 drivers/net/ethernet/amd/pcnet32.c | 43 ++++++++++++++++----------------------
 1 file changed, 18 insertions(+), 25 deletions(-)

diff --git a/drivers/net/ethernet/amd/pcnet32.c b/drivers/net/ethernet/amd/pcnet32.c
index 8099fdc..4a8fdc4 100644
--- a/drivers/net/ethernet/amd/pcnet32.c
+++ b/drivers/net/ethernet/amd/pcnet32.c
@@ -481,36 +481,32 @@ static void pcnet32_realloc_tx_ring(struct net_device *dev,
 	dma_addr_t *new_dma_addr_list;
 	struct pcnet32_tx_head *new_tx_ring;
 	struct sk_buff **new_skb_list;
+	unsigned int entries = BIT(size);
 
 	pcnet32_purge_tx_ring(dev);
 
-	new_tx_ring = pci_zalloc_consistent(lp->pci_dev,
-					    sizeof(struct pcnet32_tx_head) *
-					    (1 << size),
-					    &new_ring_dma_addr);
-	if (new_tx_ring == NULL) {
-		netif_err(lp, drv, dev, "Consistent memory allocation failed\n");
+	new_tx_ring =
+		pci_zalloc_consistent(lp->pci_dev,
+				      sizeof(struct pcnet32_tx_head) * entries,
+				      &new_ring_dma_addr);
+	if (new_tx_ring == NULL)
 		return;
-	}
 
-	new_dma_addr_list = kcalloc(1 << size, sizeof(dma_addr_t),
-				    GFP_ATOMIC);
+	new_dma_addr_list = kcalloc(entries, sizeof(dma_addr_t), GFP_ATOMIC);
 	if (!new_dma_addr_list)
 		goto free_new_tx_ring;
 
-	new_skb_list = kcalloc(1 << size, sizeof(struct sk_buff *),
-			       GFP_ATOMIC);
+	new_skb_list = kcalloc(entries, sizeof(struct sk_buff *), GFP_ATOMIC);
 	if (!new_skb_list)
 		goto free_new_lists;
 
 	kfree(lp->tx_skbuff);
 	kfree(lp->tx_dma_addr);
 	pci_free_consistent(lp->pci_dev,
-			    sizeof(struct pcnet32_tx_head) *
-			    lp->tx_ring_size, lp->tx_ring,
-			    lp->tx_ring_dma_addr);
+			    sizeof(struct pcnet32_tx_head) * lp->tx_ring_size,
+			    lp->tx_ring, lp->tx_ring_dma_addr);
 
-	lp->tx_ring_size = (1 << size);
+	lp->tx_ring_size = entries;
 	lp->tx_mod_mask = lp->tx_ring_size - 1;
 	lp->tx_len_bits = (size << 12);
 	lp->tx_ring = new_tx_ring;
@@ -523,8 +519,7 @@ free_new_lists:
 	kfree(new_dma_addr_list);
 free_new_tx_ring:
 	pci_free_consistent(lp->pci_dev,
-			    sizeof(struct pcnet32_tx_head) *
-			    (1 << size),
+			    sizeof(struct pcnet32_tx_head) * entries,
 			    new_tx_ring,
 			    new_ring_dma_addr);
 }
@@ -548,16 +543,14 @@ static void pcnet32_realloc_rx_ring(struct net_device *dev,
 	struct pcnet32_rx_head *new_rx_ring;
 	struct sk_buff **new_skb_list;
 	int new, overlap;
-	unsigned int entries = 1 << size;
+	unsigned int entries = BIT(size);
 
-	new_rx_ring = pci_zalloc_consistent(lp->pci_dev,
-					    sizeof(struct pcnet32_rx_head) *
-					    entries,
-					    &new_ring_dma_addr);
-	if (new_rx_ring == NULL) {
-		netif_err(lp, drv, dev, "Consistent memory allocation failed\n");
+	new_rx_ring =
+		pci_zalloc_consistent(lp->pci_dev,
+				      sizeof(struct pcnet32_rx_head) * entries,
+				      &new_ring_dma_addr);
+	if (new_rx_ring == NULL)
 		return;
-	}
 
 	new_dma_addr_list = kcalloc(entries, sizeof(dma_addr_t), GFP_ATOMIC);
 	if (!new_dma_addr_list)



  reply	other threads:[~2014-06-23 21:36 UTC|newest]

Thread overview: 68+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-06-23 13:41 [PATCH 00/22] Add and use pci_zalloc_consistent Joe Perches
2014-06-23 13:41 ` Joe Perches
2014-06-23 13:41 ` [PATCH 01/22] pci-dma-compat: Add pci_zalloc_consistent helper Joe Perches
2014-06-23 13:53   ` Arnd Bergmann
2014-06-23 14:03     ` Joe Perches
2014-06-25 19:27   ` Andrew Morton
2014-06-25 21:51     ` Joe Perches
2014-06-25 21:57       ` Andrew Morton
2014-06-25 22:14         ` Joe Perches
2014-06-25 22:31       ` David Miller
2014-06-23 13:41 ` [PATCH 02/22] atm: Use pci_zalloc_consistent Joe Perches
2014-06-23 13:41 ` [PATCH 03/22] block: " Joe Perches
2014-06-23 13:41 ` [PATCH 04/22] crypto: " Joe Perches
2014-06-23 13:41 ` [PATCH 05/22] infiniband: " Joe Perches
     [not found]   ` <ed5fb1adbe665a8e4a4e18bc316bab261bc55556.1403530604.git.joe-6d6DIl74uiNBDgjK7y7TUQ@public.gmane.org>
2014-06-23 13:57     ` Steve Wise
2014-06-23 13:57       ` Steve Wise
2014-06-23 13:41 ` [PATCH 06/22] i810: " Joe Perches
2014-06-23 13:41   ` Joe Perches
2014-07-08 10:13   ` Daniel Vetter
2014-06-23 13:41 ` [PATCH 07/22] media: " Joe Perches
2014-06-27  8:20   ` Hans Verkuil
2014-06-27 10:55     ` Mauro Carvalho Chehab
2014-06-23 13:41 ` [PATCH 08/22] amd: " Joe Perches
2014-06-23 18:02   ` Don Fry
2014-06-23 19:15     ` Joe Perches
2014-06-23 21:05       ` [PATCH V2 " Joe Perches
2014-06-23 21:36         ` Joe Perches [this message]
2014-06-23 22:42           ` [PATCH] amd: Neaten and remove unnecessary OOM messages Don Fry
2014-06-25 23:32           ` David Miller
     [not found]           ` <20140625123523.b00c71c3a3f0a9129f9e6f3d@linux-foundation.org>
2014-06-25 23:40             ` [PATCH V2] checkpatch: Add test for blank lines after function/struct/union/enum declarations Joe Perches
2014-06-23 22:22         ` [PATCH V2 08/22] amd: Use pci_zalloc_consistent Don Fry
2014-06-25  4:49         ` Guenter Roeck
2014-06-25  4:59           ` Joe Perches
2014-06-25 23:55         ` [PATCH V2] pcnet32: Neaten and remove unnecessary OOM messages Joe Perches
2014-07-01 19:19           ` David Miller
2014-07-01 19:26             ` Joe Perches
2014-06-25 23:51       ` [PATCH V3 08/22] pcnet32: Use pci_zalloc_consistent Joe Perches
2014-06-23 13:41 ` [PATCH 09/22] atl1e: " Joe Perches
2014-06-23 13:41 ` [PATCH 10/22] enic: " Joe Perches
2014-06-26  6:27   ` Govindarajulu Varadarajan
2014-06-23 13:41 ` [PATCH 11/22] sky2: " Joe Perches
2014-06-23 13:41 ` [PATCH 12/22] micrel: " Joe Perches
2014-06-23 13:41 ` [PATCH 13/22] qlogic: " Joe Perches
2014-06-23 13:41 ` [PATCH 14/22] irda: " Joe Perches
2014-06-23 13:41 ` [PATCH 15/22] ipw2100: " Joe Perches
2014-06-23 13:41 ` [PATCH 16/22] mwl8k: " Joe Perches
2014-06-23 13:41 ` [PATCH 17/22] rtl818x: " Joe Perches
2014-06-23 13:41 ` [PATCH 18/22] rtlwifi: " Joe Perches
2014-06-23 13:41 ` [PATCH 19/22] scsi: " Joe Perches
2014-06-23 13:41 ` [PATCH 20/22] staging: " Joe Perches
2014-06-23 16:14   ` Greg Kroah-Hartman
2014-06-23 13:41 ` [PATCH 21/22] synclink_gt: " Joe Perches
2014-06-23 16:15   ` Greg Kroah-Hartman
2014-06-23 13:41 ` [PATCH 22/22] vme: bridges: " Joe Perches
2014-06-23 16:15   ` Greg Kroah-Hartman
2014-06-23 17:25 ` [PATCH 00/22] Add and use pci_zalloc_consistent Luis R. Rodriguez
2014-06-23 17:25   ` Luis R. Rodriguez
2014-06-23 19:13   ` Joe Perches
2014-06-23 19:13     ` Joe Perches
2014-06-23 23:27     ` Julian Calaby
2014-06-23 23:48       ` Joe Perches
2014-06-24  5:24         ` Julia Lawall
2014-06-24  7:15           ` Joe Perches
2014-06-24 12:11             ` Julia Lawall
2014-06-24 11:32       ` Johannes Berg
2014-06-23 21:49 ` David Miller
2014-06-23 21:49   ` David Miller
2014-06-25 19:41 ` John W. Linville

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1403559395.20657.8.camel@joe-AO725 \
    --to=joe@perches.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=netdev@vger.kernel.org \
    --cc=pcnet32@frontier.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.