netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Souptick Joarder <jrdr.linux@gmail.com>
To: Nicholas Mc Guire <hofrat@osadl.org>
Cc: Kalle Valo <kvalo@codeaurora.org>,
	Eliad Peller <eliad@wizery.com>,
	Johannes Berg <johannes.berg@intel.com>,
	Arik Nemtsov <arik@wizery.com>, Tony Lindgren <tony@atomide.com>,
	Luciano Coelho <luca@coelho.fi>,
	Eyal Reizer <eyalreizer@gmail.com>,
	Emmanuel Grumbach <emmanuel.grumbach@intel.com>,
	linux-wireless@vger.kernel.org, netdev@vger.kernel.org,
	linux-kernel@vger.kernel.org
Subject: Re: [PATCH] wlcore: consolidate kmalloc + memset 0 into kzalloc
Date: Tue, 22 Dec 2015 12:36:43 +0530	[thread overview]
Message-ID: <CAFqt6zaYfbLqUDjcJ36TKMCXpy5_swjZQDj_75topDsMtfBRFA@mail.gmail.com> (raw)
In-Reply-To: <1450716464-20759-1-git-send-email-hofrat@osadl.org>

On Mon, Dec 21, 2015 at 10:17 PM, Nicholas Mc Guire <hofrat@osadl.org> wrote:
> This is an API consolidation only. The use of kmalloc + memset to 0
> is equivalent to kzalloc.
>
> Signed-off-by: Nicholas Mc Guire <hofrat@osadl.org>
> ---
>
> Found by coccinelle script (relaxed version of
> scripts/coccinelle/api/alloc/kzalloc-simple.cocci)
>
> Patch was compile tested with: x86_64_defconfig +
> CONFIG_WL12XX=m (implies CONFIG_WLCORE=m)
>
> Patch is against linux-next (localversion-next is -next-20151221)
>
>  drivers/net/wireless/ti/wlcore/main.c | 3 +--
>  1 file changed, 1 insertion(+), 2 deletions(-)
>
> diff --git a/drivers/net/wireless/ti/wlcore/main.c b/drivers/net/wireless/ti/wlcore/main.c
> index ec7f6af..dfc49bf 100644
> --- a/drivers/net/wireless/ti/wlcore/main.c
> +++ b/drivers/net/wireless/ti/wlcore/main.c
> @@ -838,7 +838,7 @@ static void wl12xx_read_fwlog_panic(struct wl1271 *wl)
>
>         wl1271_info("Reading FW panic log");
>
> -       block = kmalloc(wl->fw_mem_block_size, GFP_KERNEL);
> +       block = kzalloc(wl->fw_mem_block_size, GFP_KERNEL);
>         if (!block)
>                 return;
>
> @@ -885,7 +885,6 @@ static void wl12xx_read_fwlog_panic(struct wl1271 *wl)
>                         goto out;
>                 }
>
> -               memset(block, 0, wl->fw_mem_block_size);

Current code is reseting the block value to 0 in each iterations and
perform some operations.
But if you are using kzalloc as mentioned above it will memset 0 to
block pointer only once.
So both are not equivalent operations.

>                 ret = wlcore_read_hwaddr(wl, addr, block,
>                                         wl->fw_mem_block_size, false);
>
> --
> 2.1.4
>
> --
> To unsubscribe from this list: send the line "unsubscribe linux-wireless" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html

-Souptick

      parent reply	other threads:[~2015-12-22  7:06 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-12-21 16:47 [PATCH] wlcore: consolidate kmalloc + memset 0 into kzalloc Nicholas Mc Guire
2015-12-21 22:56 ` Julian Calaby
2015-12-22  7:29   ` Nicholas Mc Guire
2015-12-22  7:52     ` Julian Calaby
2015-12-22  7:06 ` Souptick Joarder [this message]

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=CAFqt6zaYfbLqUDjcJ36TKMCXpy5_swjZQDj_75topDsMtfBRFA@mail.gmail.com \
    --to=jrdr.linux@gmail.com \
    --cc=arik@wizery.com \
    --cc=eliad@wizery.com \
    --cc=emmanuel.grumbach@intel.com \
    --cc=eyalreizer@gmail.com \
    --cc=hofrat@osadl.org \
    --cc=johannes.berg@intel.com \
    --cc=kvalo@codeaurora.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-wireless@vger.kernel.org \
    --cc=luca@coelho.fi \
    --cc=netdev@vger.kernel.org \
    --cc=tony@atomide.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;
as well as URLs for NNTP newsgroup(s).