public inbox for netdev@vger.kernel.org
 help / color / mirror / Atom feed
From: Amitoj Kaur Chawla <amitoj1606@gmail.com>
To: derek.chickles@caviumnetworks.com,
	satananda.burla@caviumnetworks.com,
	felix.manlunas@caviumnetworks.com,
	raghu.vatsavayi@caviumnetworks.com, netdev@vger.kernel.org,
	linux-kernel@vger.kernel.org
Cc: julia.lawall@lip6.fr
Subject: [PATCH] net: cavium: liquidio: Use vzalloc instead of vmalloc
Date: Sat, 18 Jun 2016 12:23:20 +0530	[thread overview]
Message-ID: <20160618065320.GA1906@amitoj-Inspiron-3542> (raw)

vzalloc combines vmalloc and memset 0.

The Coccinelle semantic patch used to make this change is as follows:
@@
type T;
T *d;
expression e;
statement S;
@@

        d =
-            vmalloc
+            vzalloc
             (...);
        if (!d) S
-       memset(d, 0, sizeof(T));

Signed-off-by: Amitoj Kaur Chawla <amitoj1606@gmail.com>
---
 drivers/net/ethernet/cavium/liquidio/octeon_device.c | 9 ++-------
 1 file changed, 2 insertions(+), 7 deletions(-)

diff --git a/drivers/net/ethernet/cavium/liquidio/octeon_device.c b/drivers/net/ethernet/cavium/liquidio/octeon_device.c
index f67641a..2bf90c1 100644
--- a/drivers/net/ethernet/cavium/liquidio/octeon_device.c
+++ b/drivers/net/ethernet/cavium/liquidio/octeon_device.c
@@ -759,13 +759,10 @@ int octeon_setup_instr_queues(struct octeon_device *oct)
 
 	for (i = 0; i < num_iqs; i++) {
 		oct->instr_queue[i] =
-			vmalloc(sizeof(struct octeon_instr_queue));
+			vzalloc(sizeof(struct octeon_instr_queue));
 		if (!oct->instr_queue[i])
 			return 1;
 
-		memset(oct->instr_queue[i], 0,
-		       sizeof(struct octeon_instr_queue));
-
 		oct->instr_queue[i]->app_ctx = (void *)(size_t)i;
 		if (octeon_init_instr_queue(oct, i, num_descs))
 			return 1;
@@ -795,12 +792,10 @@ int octeon_setup_output_queues(struct octeon_device *oct)
 	oct->num_oqs = 0;
 
 	for (i = 0; i < num_oqs; i++) {
-		oct->droq[i] = vmalloc(sizeof(*oct->droq[i]));
+		oct->droq[i] = vzalloc(sizeof(*oct->droq[i]));
 		if (!oct->droq[i])
 			return 1;
 
-		memset(oct->droq[i], 0, sizeof(struct octeon_droq));
-
 		if (octeon_init_droq(oct, i, num_descs, desc_size, NULL))
 			return 1;
 
-- 
1.9.1

             reply	other threads:[~2016-06-18  6:53 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-06-18  6:53 Amitoj Kaur Chawla [this message]
2016-06-22 20:20 ` [PATCH] net: cavium: liquidio: Use vzalloc instead of vmalloc 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=20160618065320.GA1906@amitoj-Inspiron-3542 \
    --to=amitoj1606@gmail.com \
    --cc=derek.chickles@caviumnetworks.com \
    --cc=felix.manlunas@caviumnetworks.com \
    --cc=julia.lawall@lip6.fr \
    --cc=linux-kernel@vger.kernel.org \
    --cc=netdev@vger.kernel.org \
    --cc=raghu.vatsavayi@caviumnetworks.com \
    --cc=satananda.burla@caviumnetworks.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