mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: YueHaibing <yuehaibing@huawei.com>
To: <davem@davemloft.net>
Cc: <netdev@vger.kernel.org>, <linux-kernel@vger.kernel.org>,
	<jcliburn@gmail.com>, <chris.snook@gmail.com>, <benve@cisco.com>,
	<jdmason@kudzu.us>, <chessman@tux.org>, <jes@trained-monkey.org>,
	<rahul.verma@cavium.com>, YueHaibing <yuehaibing@huawei.com>
Subject: [PATCH net-next 1/6] net: hippi: use pci_zalloc_consistent
Date: Tue, 5 Jun 2018 20:28:46 +0800	[thread overview]
Message-ID: <20180605122851.23912-2-yuehaibing@huawei.com> (raw)
In-Reply-To: <20180605122851.23912-1-yuehaibing@huawei.com>

use pci_zalloc_consistent to remove unnecessary memset.
Also remove a local intermediate pointer 'tmpptr'.

Signed-off-by: YueHaibing <yuehaibing@huawei.com>
---
 drivers/net/hippi/rrunner.c | 28 +++++++++++-----------------
 1 file changed, 11 insertions(+), 17 deletions(-)

diff --git a/drivers/net/hippi/rrunner.c b/drivers/net/hippi/rrunner.c
index f411164..9de7d2a 100644
--- a/drivers/net/hippi/rrunner.c
+++ b/drivers/net/hippi/rrunner.c
@@ -93,7 +93,6 @@ static int rr_init_one(struct pci_dev *pdev, const struct pci_device_id *ent)
 	static int version_disp;
 	u8 pci_latency;
 	struct rr_private *rrpriv;
-	void *tmpptr;
 	dma_addr_t ring_dma;
 	int ret = -ENOMEM;
 
@@ -155,29 +154,26 @@ static int rr_init_one(struct pci_dev *pdev, const struct pci_device_id *ent)
 		goto out;
 	}
 
-	tmpptr = pci_alloc_consistent(pdev, TX_TOTAL_SIZE, &ring_dma);
-	rrpriv->tx_ring = tmpptr;
+	rrpriv->tx_ring = pci_alloc_consistent(pdev, TX_TOTAL_SIZE, &ring_dma);
 	rrpriv->tx_ring_dma = ring_dma;
 
-	if (!tmpptr) {
+	if (!rrpriv->tx_ring) {
 		ret = -ENOMEM;
 		goto out;
 	}
 
-	tmpptr = pci_alloc_consistent(pdev, RX_TOTAL_SIZE, &ring_dma);
-	rrpriv->rx_ring = tmpptr;
+	rrpriv->rx_ring = pci_alloc_consistent(pdev, RX_TOTAL_SIZE, &ring_dma);
 	rrpriv->rx_ring_dma = ring_dma;
 
-	if (!tmpptr) {
+	if (!rrpriv->rx_ring) {
 		ret = -ENOMEM;
 		goto out;
 	}
 
-	tmpptr = pci_alloc_consistent(pdev, EVT_RING_SIZE, &ring_dma);
-	rrpriv->evt_ring = tmpptr;
+	rrpriv->evt_ring = pci_alloc_consistent(pdev, EVT_RING_SIZE, &ring_dma);
 	rrpriv->evt_ring_dma = ring_dma;
 
-	if (!tmpptr) {
+	if (!trrpriv->evt_ring) {
 		ret = -ENOMEM;
 		goto out;
 	}
@@ -1192,24 +1188,22 @@ static int rr_open(struct net_device *dev)
 		goto error;
 	}
 
-	rrpriv->rx_ctrl = pci_alloc_consistent(pdev,
-					       256 * sizeof(struct ring_ctrl),
-					       &dma_addr);
+	rrpriv->rx_ctrl = pci_zalloc_consistent(pdev,
+						256 * sizeof(struct ring_ctrl),
+						&dma_addr);
 	if (!rrpriv->rx_ctrl) {
 		ecode = -ENOMEM;
 		goto error;
 	}
 	rrpriv->rx_ctrl_dma = dma_addr;
-	memset(rrpriv->rx_ctrl, 0, 256*sizeof(struct ring_ctrl));
 
-	rrpriv->info = pci_alloc_consistent(pdev, sizeof(struct rr_info),
-					    &dma_addr);
+	rrpriv->info = pci_zalloc_consistent(pdev, sizeof(struct rr_info),
+					     &dma_addr);
 	if (!rrpriv->info) {
 		ecode = -ENOMEM;
 		goto error;
 	}
 	rrpriv->info_dma = dma_addr;
-	memset(rrpriv->info, 0, sizeof(struct rr_info));
 	wmb();
 
 	spin_lock_irqsave(&rrpriv->lock, flags);
-- 
2.7.0

  reply	other threads:[~2018-06-05 12:32 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-06-05 12:28 [PATCH net-next 0/6] " YueHaibing
2018-06-05 12:28 ` YueHaibing [this message]
2018-06-06  9:53   ` [PATCH net-next 1/6] net: hippi: " Sergei Shtylyov
2018-06-06 15:04   ` kbuild test robot
2018-06-05 12:28 ` [PATCH net-next 2/6] net: atheros: " YueHaibing
2018-06-05 12:28 ` [PATCH net-next 3/6] net: neterion: " YueHaibing
2018-06-05 12:28 ` [PATCH net-next 4/6] netxen_nic: " YueHaibing
2018-06-06  9:56   ` Sergei Shtylyov
2018-06-05 12:28 ` [PATCH net-next 5/6] net: tlan: " YueHaibing
2018-06-05 12:28 ` [PATCH net-next 6/6] enic: " YueHaibing
2018-06-05 12:39 ` [PATCH net-next 0/6] " Andy Shevchenko
2018-06-05 12:49   ` Christoph Hellwig
2018-06-05 12:46     ` Andy Shevchenko
2018-06-05 13:04       ` YueHaibing
2018-06-05 13:00     ` David Miller

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=20180605122851.23912-2-yuehaibing@huawei.com \
    --to=yuehaibing@huawei.com \
    --cc=benve@cisco.com \
    --cc=chessman@tux.org \
    --cc=chris.snook@gmail.com \
    --cc=davem@davemloft.net \
    --cc=jcliburn@gmail.com \
    --cc=jdmason@kudzu.us \
    --cc=jes@trained-monkey.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=netdev@vger.kernel.org \
    --cc=rahul.verma@cavium.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®