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 4/6] netxen_nic: use pci_zalloc_consistent
Date: Tue, 5 Jun 2018 20:28:49 +0800 [thread overview]
Message-ID: <20180605122851.23912-5-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 'void *addr'.
Signed-off-by: YueHaibing <yuehaibing@huawei.com>
---
.../net/ethernet/qlogic/netxen/netxen_nic_ctx.c | 26 +++++++++-------------
1 file changed, 10 insertions(+), 16 deletions(-)
diff --git a/drivers/net/ethernet/qlogic/netxen/netxen_nic_ctx.c b/drivers/net/ethernet/qlogic/netxen/netxen_nic_ctx.c
index 7503aa2..096047e 100644
--- a/drivers/net/ethernet/qlogic/netxen/netxen_nic_ctx.c
+++ b/drivers/net/ethernet/qlogic/netxen/netxen_nic_ctx.c
@@ -267,7 +267,6 @@ nx_fw_cmd_set_gbe_port(struct netxen_adapter *adapter,
static int
nx_fw_cmd_create_rx_ctx(struct netxen_adapter *adapter)
{
- void *addr;
nx_hostrq_rx_ctx_t *prq;
nx_cardrsp_rx_ctx_t *prsp;
nx_hostrq_rds_ring_t *prq_rds;
@@ -297,19 +296,17 @@ nx_fw_cmd_create_rx_ctx(struct netxen_adapter *adapter)
rsp_size =
SIZEOF_CARDRSP_RX(nx_cardrsp_rx_ctx_t, nrds_rings, nsds_rings);
- addr = pci_alloc_consistent(adapter->pdev,
- rq_size, &hostrq_phys_addr);
- if (addr == NULL)
+ prq = pci_alloc_consistent(adapter->pdev,
+ rq_size, &hostrq_phys_addr);
+ if (!prq)
return -ENOMEM;
- prq = addr;
- addr = pci_alloc_consistent(adapter->pdev,
- rsp_size, &cardrsp_phys_addr);
- if (addr == NULL) {
+ prsp = pci_alloc_consistent(adapter->pdev,
+ rsp_size, &cardrsp_phys_addr);
+ if (!prsp) {
err = -ENOMEM;
goto out_free_rq;
}
- prsp = addr;
prq->host_rsp_dma_addr = cpu_to_le64(cardrsp_phys_addr);
@@ -445,23 +442,20 @@ nx_fw_cmd_create_tx_ctx(struct netxen_adapter *adapter)
struct netxen_cmd_args cmd;
rq_size = SIZEOF_HOSTRQ_TX(nx_hostrq_tx_ctx_t);
- rq_addr = pci_alloc_consistent(adapter->pdev,
- rq_size, &rq_phys_addr);
+ rq_addr = pci_zalloc_consistent(adapter->pdev,
+ rq_size, &rq_phys_addr);
if (!rq_addr)
return -ENOMEM;
rsp_size = SIZEOF_CARDRSP_TX(nx_cardrsp_tx_ctx_t);
- rsp_addr = pci_alloc_consistent(adapter->pdev,
- rsp_size, &rsp_phys_addr);
+ rsp_addr = pci_zalloc_consistent(adapter->pdev,
+ rsp_size, &rsp_phys_addr);
if (!rsp_addr) {
err = -ENOMEM;
goto out_free_rq;
}
- memset(rq_addr, 0, rq_size);
prq = rq_addr;
-
- memset(rsp_addr, 0, rsp_size);
prsp = rsp_addr;
prq->host_rsp_dma_addr = cpu_to_le64(rsp_phys_addr);
--
2.7.0
next prev parent 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 ` [PATCH net-next 1/6] net: hippi: " YueHaibing
2018-06-06 9:53 ` 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 ` YueHaibing [this message]
2018-06-06 9:56 ` [PATCH net-next 4/6] netxen_nic: " 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-5-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®