public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Joe Perches <joe@perches.com>
To: Christophe JAILLET <christophe.jaillet@wanadoo.fr>,
	akarwar@marvell.com, nishants@marvell.com, kvalo@codeaurora.org
Cc: linux-wireless@vger.kernel.org, netdev@vger.kernel.org,
	linux-kernel@vger.kernel.org, kernel-janitors@vger.kernel.org
Subject: Re: [PATCH] mwifiex: scan: Simplify code
Date: Wed, 31 Aug 2016 08:09:10 -0700	[thread overview]
Message-ID: <1472656150.4176.7.camel@perches.com> (raw)
In-Reply-To: <1472644259-15605-1-git-send-email-christophe.jaillet@wanadoo.fr>

On Wed, 2016-08-31 at 13:50 +0200, Christophe JAILLET wrote:
> This patch:
>    - improves code layout
>    - removes a useless memset(0) for some memory allocated with kzalloc
>    - removes a useless if. We know that 'if (chan_band_tlv)' will succeed
>      because it has been tested a few lines above

True, the code above it is also confusing as it's

#ifdef CONFIG_PM
	if (priv->wdev.wiphy->wowlan_config)
		nd_config = priv->wdev.wiphy->wowlan_config->nd_config;
#endif

	if (nd_config) {
		adapter->nd_info =
			kzalloc(sizeof(struct cfg80211_wowlan_nd_match) +
				sizeof(struct cfg80211_wowlan_nd_match *) *
				scan_rsp->number_of_sets, GFP_ATOMIC);

		if (adapter->nd_info)
			adapter->nd_info->n_matches = scan_rsp->number_of_sets;
	}
where nd_config is a pointer already initialized to NULL
so the #endif seems misplaced.

> diff --git a/drivers/net/wireless/marvell/mwifiex/scan.c b/drivers/net/wireless/marvell/mwifiex/scan.c
[]
> @@ -2179,18 +2179,14 @@ int mwifiex_ret_802_11_scan(struct mwifiex_private *priv,

>  
>  		if (chan_band_tlv && adapter->nd_info) {
>  			adapter->nd_info->matches[idx] =
> -				kzalloc(sizeof(*pmatch) +
> -				sizeof(u32), GFP_ATOMIC);
> +				kzalloc(sizeof(*pmatch) + sizeof(u32),
> +					GFP_ATOMIC);
>  
>  			pmatch = adapter->nd_info->matches[idx];
>  
>  			if (pmatch) {
> -				memset(pmatch, 0, sizeof(*pmatch));
> -				if (chan_band_tlv) {
> -					pmatch->n_channels = 1;
> -					pmatch->channels[0] =
> -						chan_band->chan_number;
> -				}
> +				pmatch->n_channels = 1;
> +				pmatch->channels[0] = chan_band->chan_number;
>  			}
>  		}

Maybe it'd be better to move the pmatch declaration to this block
and alloc to pmatch then assign adapter->nd_info->matches[idx]
later.

I think the #ifdef CONFIG_PM use in this routine is incomplete.

  reply	other threads:[~2016-08-31 15:09 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-08-31 11:50 [PATCH] mwifiex: scan: Simplify code Christophe JAILLET
2016-08-31 15:09 ` Joe Perches [this message]
2016-09-09  9:21 ` Kalle Valo

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=1472656150.4176.7.camel@perches.com \
    --to=joe@perches.com \
    --cc=akarwar@marvell.com \
    --cc=christophe.jaillet@wanadoo.fr \
    --cc=kernel-janitors@vger.kernel.org \
    --cc=kvalo@codeaurora.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-wireless@vger.kernel.org \
    --cc=netdev@vger.kernel.org \
    --cc=nishants@marvell.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