[PATCH 5/5] ath10k: Removed unused 'dev' in ath10k_ahb_resource_init

2016-11-24 Thread Kirtika Ruchandani
Commit 704dc4e36769 introduced ath10k_ahb_resource_init() which
defines and sets 'struct device* dev' but does not use it.
Compiling with W=1 gives the following warning, fix it.

drivers/net/wireless/ath/ath10k/ahb.c: In function ‘ath10k_ahb_resource_init’:
drivers/net/wireless/ath/ath10k/ahb.c:449:17: warning: variable ‘dev’ set but 
not used [-Wunused-but-set-variable]

This is a harmless warning, and is only being fixed to reduce the
noise with W=1 in the kernel.

Fixes: 704dc4e36769 ("ath10k: add resource init and deinit in ahb")
Cc: Raja Mani <rm...@qti.qualcomm.com>
Cc: Kalle Valo <kv...@qca.qualcomm.com>
Signed-off-by: Kirtika Ruchandani <kirt...@chromium.org>
---
 drivers/net/wireless/ath/ath10k/ahb.c | 2 --
 1 file changed, 2 deletions(-)

diff --git a/drivers/net/wireless/ath/ath10k/ahb.c 
b/drivers/net/wireless/ath/ath10k/ahb.c
index 8078d64..19507fe 100644
--- a/drivers/net/wireless/ath/ath10k/ahb.c
+++ b/drivers/net/wireless/ath/ath10k/ahb.c
@@ -443,12 +443,10 @@ static int ath10k_ahb_resource_init(struct ath10k *ar)
 {
struct ath10k_ahb *ar_ahb = ath10k_ahb_priv(ar);
struct platform_device *pdev;
-   struct device *dev;
struct resource *res;
int ret;

pdev = ar_ahb->pdev;
-   dev = >dev;

res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
if (!res) {
--
2.8.0.rc3.226.g39d4020


[PATCH 3/5] ath10k: Remove unused wmi_p2p_noa_descriptor 'noa' in wmi-tlv

2016-11-24 Thread Kirtika Ruchandani
Commit ca996ec56608 (ath10k: implement wmi-tlv backend)
introduced ath10k_wmi_tlv_op_gen_vdev_start() where
'struct wmi_p2p_noa_descriptor *noa' is defined and set but not used.
Compiling with W=1 gives the following warning, fix it.
drivers/net/wireless/ath/ath10k/wmi-tlv.c: In function 
‘ath10k_wmi_tlv_op_gen_vdev_start’:
drivers/net/wireless/ath/ath10k/wmi-tlv.c:1647:33: warning: variable ‘noa’ set 
but not used [-Wunused-but-set-variable]

Fixes: ca996ec56608 ("ath10k: implement wmi-tlv backend")
Cc: Michal Kazior <michal.kaz...@tieto.com>
Cc: Kalle Valo <kv...@qca.qualcomm.com>
Signed-off-by: Kirtika Ruchandani <kirt...@chromium.org>
---
 drivers/net/wireless/ath/ath10k/wmi-tlv.c | 2 --
 1 file changed, 2 deletions(-)

diff --git a/drivers/net/wireless/ath/ath10k/wmi-tlv.c 
b/drivers/net/wireless/ath/ath10k/wmi-tlv.c
index e64f593..0e4bd29 100644
--- a/drivers/net/wireless/ath/ath10k/wmi-tlv.c
+++ b/drivers/net/wireless/ath/ath10k/wmi-tlv.c
@@ -1644,7 +1644,6 @@ ath10k_wmi_tlv_op_gen_vdev_start(struct ath10k *ar,
 {
struct wmi_tlv_vdev_start_cmd *cmd;
struct wmi_channel *ch;
-   struct wmi_p2p_noa_descriptor *noa;
struct wmi_tlv *tlv;
struct sk_buff *skb;
size_t len;
@@ -1702,7 +1701,6 @@ ath10k_wmi_tlv_op_gen_vdev_start(struct ath10k *ar,
tlv = ptr;
tlv->tag = __cpu_to_le16(WMI_TLV_TAG_ARRAY_STRUCT);
tlv->len = 0;
-   noa = (void *)tlv->value;

/* Note: This is a nested TLV containing:
 * [wmi_tlv][wmi_p2p_noa_descriptor][wmi_tlv]..
--
2.8.0.rc3.226.g39d4020


[PATCH 2/5] ath10k: Remove unused 'num_vdev_stats' variable

2016-11-24 Thread Kirtika Ruchandani
Several functions for wmi stats parsing define and set num_vdev_stats
but do not use it. Compiling with W=1 gives the following warnings,
fix them.

drivers/net/wireless/ath/ath10k/wmi.c: In function 
‘ath10k_wmi_main_op_pull_fw_stats’:
drivers/net/wireless/ath/ath10k/wmi.c:2680:22: warning: variable 
‘num_vdev_stats’ set but not used [-Wunused-but-set-variable]
  u32 num_pdev_stats, num_vdev_stats, num_peer_stats;
  ^
drivers/net/wireless/ath/ath10k/wmi.c: In function 
‘ath10k_wmi_10x_op_pull_fw_stats’:
drivers/net/wireless/ath/ath10k/wmi.c:2735:22: warning: variable 
‘num_vdev_stats’ set but not used [-Wunused-but-set-variable]
  u32 num_pdev_stats, num_vdev_stats, num_peer_stats;
  ^
drivers/net/wireless/ath/ath10k/wmi.c: In function 
‘ath10k_wmi_10_2_op_pull_fw_stats’:
drivers/net/wireless/ath/ath10k/wmi.c:2796:6: warning: variable 
‘num_vdev_stats’ set but not used [-Wunused-but-set-variable]
  u32 num_vdev_stats;
  ^
drivers/net/wireless/ath/ath10k/wmi.c: In function 
‘ath10k_wmi_10_2_4_op_pull_fw_stats’:
drivers/net/wireless/ath/ath10k/wmi.c:2875:6: warning: variable 
‘num_vdev_stats’ set but not used [-Wunused-but-set-variable]
  u32 num_vdev_stats;
  ^
drivers/net/wireless/ath/ath10k/wmi.c: In function 
‘ath10k_wmi_10_4_op_pull_fw_stats’:
drivers/net/wireless/ath/ath10k/wmi.c:2963:6: warning: variable 
‘num_vdev_stats’ set but not used [-Wunused-but-set-variable]
  u32 num_vdev_stats;
  ^

These are harmless warnings and are only being fixed to reduce the
noise with W=1 in the kernel.

Fixes: d15fb5200664 ("ath10k: split wmi stats parsing")
Fixes: 20de2229c634 ("ath10k: fix 10.2 fw stats parsing")
Cc: Michal Kazior <michal.kaz...@tieto.com>
Cc: Kalle Valo <kv...@qca.qualcomm.com>
Signed-off-by: Kirtika Ruchandani <kirt...@chromium.org>
---
 drivers/net/wireless/ath/ath10k/wmi.c | 12 ++--
 1 file changed, 2 insertions(+), 10 deletions(-)

diff --git a/drivers/net/wireless/ath/ath10k/wmi.c 
b/drivers/net/wireless/ath/ath10k/wmi.c
index 1f28187..10ec5a5 100644
--- a/drivers/net/wireless/ath/ath10k/wmi.c
+++ b/drivers/net/wireless/ath/ath10k/wmi.c
@@ -2675,14 +2675,13 @@ static int ath10k_wmi_main_op_pull_fw_stats(struct 
ath10k *ar,
struct ath10k_fw_stats *stats)
 {
const struct wmi_stats_event *ev = (void *)skb->data;
-   u32 num_pdev_stats, num_vdev_stats, num_peer_stats;
+   u32 num_pdev_stats, num_peer_stats;
int i;

if (!skb_pull(skb, sizeof(*ev)))
return -EPROTO;

num_pdev_stats = __le32_to_cpu(ev->num_pdev_stats);
-   num_vdev_stats = __le32_to_cpu(ev->num_vdev_stats);
num_peer_stats = __le32_to_cpu(ev->num_peer_stats);

for (i = 0; i < num_pdev_stats; i++) {
@@ -2730,14 +2729,13 @@ static int ath10k_wmi_10x_op_pull_fw_stats(struct 
ath10k *ar,
   struct ath10k_fw_stats *stats)
 {
const struct wmi_stats_event *ev = (void *)skb->data;
-   u32 num_pdev_stats, num_vdev_stats, num_peer_stats;
+   u32 num_pdev_stats, num_peer_stats;
int i;

if (!skb_pull(skb, sizeof(*ev)))
return -EPROTO;

num_pdev_stats = __le32_to_cpu(ev->num_pdev_stats);
-   num_vdev_stats = __le32_to_cpu(ev->num_vdev_stats);
num_peer_stats = __le32_to_cpu(ev->num_peer_stats);

for (i = 0; i < num_pdev_stats; i++) {
@@ -2791,7 +2789,6 @@ static int ath10k_wmi_10_2_op_pull_fw_stats(struct ath10k 
*ar,
const struct wmi_10_2_stats_event *ev = (void *)skb->data;
u32 num_pdev_stats;
u32 num_pdev_ext_stats;
-   u32 num_vdev_stats;
u32 num_peer_stats;
int i;

@@ -2800,7 +2797,6 @@ static int ath10k_wmi_10_2_op_pull_fw_stats(struct ath10k 
*ar,

num_pdev_stats = __le32_to_cpu(ev->num_pdev_stats);
num_pdev_ext_stats = __le32_to_cpu(ev->num_pdev_ext_stats);
-   num_vdev_stats = __le32_to_cpu(ev->num_vdev_stats);
num_peer_stats = __le32_to_cpu(ev->num_peer_stats);

for (i = 0; i < num_pdev_stats; i++) {
@@ -2870,7 +2866,6 @@ static int ath10k_wmi_10_2_4_op_pull_fw_stats(struct 
ath10k *ar,
const struct wmi_10_2_stats_event *ev = (void *)skb->data;
u32 num_pdev_stats;
u32 num_pdev_ext_stats;
-   u32 num_vdev_stats;
u32 num_peer_stats;
int i;

@@ -2879,7 +2874,6 @@ static int ath10k_wmi_10_2_4_op_pull_fw_stats(struct 
ath10k *ar,

num_pdev_stats = __le32_to_cpu(ev->num_pdev_stats);
num_pdev_ext_stats = __le32_to_cpu(ev->num_pdev_ext_stats);
-   num_vdev_stats = __le32_to_cpu(ev->num_vdev_stats);
num_peer_stats = __le32_to_cpu(ev->num_peer_stats);

for (i = 0; i < num_pdev_stats; i++) {
@@ -2958,7 +2952,6 @@ static int ath10k_wmi_10_4_op_pull_fw_stats(struct ath10k 
*ar,
const struct 

[PATCH 4/5] ath10k: Removed unused 'dev' in ath10k_ahb_clock_enable()

2016-11-24 Thread Kirtika Ruchandani
Commit 8beff219c528 introduced ath10k_ahb_clock_enable() which
defines and sets 'struct device* dev' but does not use it.
Compiling with W=1 gives the following warning, fix it.
drivers/net/wireless/ath/ath10k/ahb.c: In function ‘ath10k_ahb_clock_enable’:
drivers/net/wireless/ath/ath10k/ahb.c:133:17: warning: variable ‘dev’ set but 
not used [-Wunused-but-set-variable]

This is a harmless warning, and is only being fixed to reduce the
noise with W=1 in the kernel.

Fixes: 8beff219c528("ath10k: add clock ctrl related functions in ahb")
Cc: Raja Mani <rm...@qti.qualcomm.com>
Cc: Kalle Valo <kv...@qca.qualcomm.com>
Signed-off-by: Kirtika Ruchandani <kirt...@chromium.org>
---
 drivers/net/wireless/ath/ath10k/ahb.c | 3 ---
 1 file changed, 3 deletions(-)

diff --git a/drivers/net/wireless/ath/ath10k/ahb.c 
b/drivers/net/wireless/ath/ath10k/ahb.c
index 766c63b..8078d64 100644
--- a/drivers/net/wireless/ath/ath10k/ahb.c
+++ b/drivers/net/wireless/ath/ath10k/ahb.c
@@ -130,11 +130,8 @@ static void ath10k_ahb_clock_deinit(struct ath10k *ar)
 static int ath10k_ahb_clock_enable(struct ath10k *ar)
 {
struct ath10k_ahb *ar_ahb = ath10k_ahb_priv(ar);
-   struct device *dev;
int ret;

-   dev = _ahb->pdev->dev;
-
if (IS_ERR_OR_NULL(ar_ahb->cmd_clk) ||
IS_ERR_OR_NULL(ar_ahb->ref_clk) ||
IS_ERR_OR_NULL(ar_ahb->rtc_clk)) {
--
2.8.0.rc3.226.g39d4020


[PATCH 0/5] Fix -Wunused-but-set-variable in ath10k/

2016-11-24 Thread Kirtika Ruchandani
This patchset is part of the effort led by Arnd Bergmann to clean up
warnings in the kernel. This and following patchsets will focus on
"-Wunused-but-set-variable" as it among the noisier ones. These were
found compiling with W=1.

Kirtika Ruchandani (5):
  ath10k: Remove unused 'buf_len' variable
  ath10k: Remove unused 'num_vdev_stats' variable
  ath10k: Remove unused wmi_p2p_noa_descriptor 'noa' in wmi-tlv
  ath10k: Removed unused 'dev' in ath10k_ahb_clock_enable()
  ath10k: Removed unused 'dev' in ath10k_ahb_resource_init

 drivers/net/wireless/ath/ath10k/ahb.c |  5 -
 drivers/net/wireless/ath/ath10k/wmi-tlv.c |  2 --
 drivers/net/wireless/ath/ath10k/wmi.c | 14 ++
 3 files changed, 2 insertions(+), 19 deletions(-)

--
2.8.0.rc3.226.g39d4020


[PATCH 1/5] ath10k: Remove unused 'buf_len' variable

2016-11-24 Thread Kirtika Ruchandani
Commit 32653cf19554 removed the call to 'skb_trim(skb, buf_len)'
in ath10k_wmi_event_mgmt_rx(), leaving the buf_len variable set but
unused. Compiling with W=1 gives the following warning, fix it.
drivers/net/wireless/ath/ath10k/wmi.c: In function ‘ath10k_wmi_event_mgmt_rx’:
drivers/net/wireless/ath/ath10k/wmi.c:2280:6: warning: variable ‘buf_len’ set 
but not used [-Wunused-but-set-variable]

This is a harmless warning, and is only being fixed to reduce the
noise with W=1 in the kernel.

Fixes: 32653cf19554 ("ath10k: implement intermediate event args")
Cc: Michal Kazior <michal.kaz...@tieto.com>
Cc: Kalle Valo <kv...@qca.qualcomm.com>
Signed-off-by: Kirtika Ruchandani <kirt...@chromium.org>
---
 drivers/net/wireless/ath/ath10k/wmi.c | 2 --
 1 file changed, 2 deletions(-)

diff --git a/drivers/net/wireless/ath/ath10k/wmi.c 
b/drivers/net/wireless/ath/ath10k/wmi.c
index 387c4ee..1f28187 100644
--- a/drivers/net/wireless/ath/ath10k/wmi.c
+++ b/drivers/net/wireless/ath/ath10k/wmi.c
@@ -2277,7 +2277,6 @@ int ath10k_wmi_event_mgmt_rx(struct ath10k *ar, struct 
sk_buff *skb)
u32 phy_mode;
u32 snr;
u32 rate;
-   u32 buf_len;
u16 fc;
int ret;

@@ -2289,7 +2288,6 @@ int ath10k_wmi_event_mgmt_rx(struct ath10k *ar, struct 
sk_buff *skb)
}

channel = __le32_to_cpu(arg.channel);
-   buf_len = __le32_to_cpu(arg.buf_len);
rx_status = __le32_to_cpu(arg.status);
snr = __le32_to_cpu(arg.snr);
phy_mode = __le32_to_cpu(arg.phy_mode);
--
2.8.0.rc3.226.g39d4020


[PATCH] adm80211: Removed unused 'io_addr' 'mem_addr' variables

2016-11-23 Thread Kirtika Ruchandani
Initial commit cc0b88cf5ecf ([PATCH] Add adm8211 802.11b wireless driver)
introduced variables mem_addr and io_addr in adm80211_probe() that are
set but not used. Compiling with W=1 gives the following warnings,
fix them.

drivers/net/wireless/admtek/adm8211.c: In function ‘adm8211_probe’:
drivers/net/wireless/admtek/adm8211.c:1769:15: warning: variable ‘io_addr’ set 
but not used [-Wunused-but-set-variable]
  unsigned int io_addr, io_len;
   ^
drivers/net/wireless/admtek/adm8211.c:1768:16: warning: variable ‘mem_addr’ set 
but not used [-Wunused-but-set-variable]
  unsigned long mem_addr, mem_len;
^

These are harmless warnings and are only being fixed to reduce the
noise with W=1 in the kernel. The calls to pci_resource_start do not
have any side-effects and are safe to remove.

Fixes: cc0b88cf5ecf ("[PATCH] Add adm8211 802.11b wireless driver")
Cc: Michael Wu <flaming...@sourmilk.net>
Cc: John W. Linville <linvi...@tuxdriver.com>
Signed-off-by: Kirtika Ruchandani <kirt...@chromium.org>
---
 drivers/net/wireless/admtek/adm8211.c | 6 ++
 1 file changed, 2 insertions(+), 4 deletions(-)

diff --git a/drivers/net/wireless/admtek/adm8211.c 
b/drivers/net/wireless/admtek/adm8211.c
index 70ecd82..70b4da0 100644
--- a/drivers/net/wireless/admtek/adm8211.c
+++ b/drivers/net/wireless/admtek/adm8211.c
@@ -1765,8 +1765,8 @@ static int adm8211_probe(struct pci_dev *pdev,
 {
struct ieee80211_hw *dev;
struct adm8211_priv *priv;
-   unsigned long mem_addr, mem_len;
-   unsigned int io_addr, io_len;
+   unsigned long mem_len;
+   unsigned int io_len;
int err;
u32 reg;
u8 perm_addr[ETH_ALEN];
@@ -1778,9 +1778,7 @@ static int adm8211_probe(struct pci_dev *pdev,
return err;
}

-   io_addr = pci_resource_start(pdev, 0);
io_len = pci_resource_len(pdev, 0);
-   mem_addr = pci_resource_start(pdev, 1);
mem_len = pci_resource_len(pdev, 1);
if (io_len < 256 || mem_len < 1024) {
printk(KERN_ERR "%s (adm8211): Too short PCI resources\n",
--
2.8.0.rc3.226.g39d4020


[PATCH 3/4] mac80211: Removed unused 'struct ieee80211_supported_band*' variable

2016-11-23 Thread Kirtika Ruchandani
Commit b1bce14a7954 (mac80211: update opmode when adding new station)
refactored ieee80211_vht_handle_opmode into __ieee80211_vht_handle_opmode
and ieee80211_vht_handle_opmode leaving a set but unused variable
(sband) in the former. Compiling with W=1 gives the following warning,
fix it.

net/mac80211/vht.c: In function ‘__ieee80211_vht_handle_opmode’:
net/mac80211/vht.c:424:35: warning: variable ‘sband’ set but not used 
[-Wunused-but-set-variable]

Remove 'struct ieee80211_local* local' as well, it was only used to
set sband.

This is a harmless warning, and is only being fixed to reduce the
noise with W=1 in the kernel.

Fixes: b1bce14a7954 ("mac80211: update opmode when adding new station")
Cc: Marek Kwaczynski <marek.kwaczyn...@tieto.com>
Cc: Johannes Berg <johannes.b...@intel.com>
Signed-off-by: Kirtika Ruchandani <kirt...@chromium.org>
---
 net/mac80211/vht.c | 4 
 1 file changed, 4 deletions(-)

diff --git a/net/mac80211/vht.c b/net/mac80211/vht.c
index ee71576..14920e3 100644
--- a/net/mac80211/vht.c
+++ b/net/mac80211/vht.c
@@ -420,14 +420,10 @@ u32 __ieee80211_vht_handle_opmode(struct 
ieee80211_sub_if_data *sdata,
  struct sta_info *sta, u8 opmode,
  enum nl80211_band band)
 {
-   struct ieee80211_local *local = sdata->local;
-   struct ieee80211_supported_band *sband;
enum ieee80211_sta_rx_bandwidth new_bw;
u32 changed = 0;
u8 nss;
 
-   sband = local->hw.wiphy->bands[band];
-
/* ignore - no support for BF yet */
if (opmode & IEEE80211_OPMODE_NOTIF_RX_NSS_TYPE_BF)
return 0;
-- 
2.8.0.rc3.226.g39d4020



[PATCH 4/4] mac80211: Remove unused 'beaconint_us' variable

2016-11-23 Thread Kirtika Ruchandani
Commit 4a733ef1bea7 (mac80211: remove PM-QoS listener) removed all use
of 'beaconint_us' from ieee80211_recalc_ps() but left the variable
intact. Compiling with W=1 gives the following warning, fix it.
net/mac80211/mlme.c: In function ‘ieee80211_recalc_ps’:
net/mac80211/mlme.c:1481:7: warning: variable ‘beaconint_us’ set but not used 
[-Wunused-but-set-variable]

iee80211_tu_to_usec has no side-effects and is safe to remove.

Fixes: 4a733ef1bea7 ("mac80211: remove PM-QoS listener")
Cc: Johannes Berg <johannes.b...@intel.com>
Signed-off-by: Kirtika Ruchandani <kirt...@chromium.org>
---
 net/mac80211/mlme.c | 4 
 1 file changed, 4 deletions(-)

diff --git a/net/mac80211/mlme.c b/net/mac80211/mlme.c
index 7486f2d..e883345 100644
--- a/net/mac80211/mlme.c
+++ b/net/mac80211/mlme.c
@@ -1478,10 +1478,6 @@ void ieee80211_recalc_ps(struct ieee80211_local *local)
 
if (count == 1 && ieee80211_powersave_allowed(found)) {
u8 dtimper = found->u.mgd.dtim_period;
-   s32 beaconint_us;
-
-   beaconint_us = ieee80211_tu_to_usec(
-   found->vif.bss_conf.beacon_int);
 
timeout = local->dynamic_ps_forced_timeout;
if (timeout < 0)
-- 
2.8.0.rc3.226.g39d4020



[PATCH 2/4] mac80211: Remove unused 'len' variable

2016-11-23 Thread Kirtika Ruchandani
Commit 633e27132625 (mac80211: split sched scan IEs) introduced the
len variable to keep track of the return value of
ieee80211_build_preq_ies() but did not use it. Compiling with W=1
gives the following warning, fix it.

net/mac80211/scan.c: In function ‘__ieee80211_request_sched_scan_start’:
net/mac80211/scan.c:1123:9: warning: variable ‘len’ set but not used 
[-Wunused-but-set-variable]

This is a harmless warning and is only being fixed to reduce the noise
with W=1 in the kernel.

Fixes: 633e27132625 ("mac80211: split sched scan IEs")
Cc: David Spinadel <david.spina...@intel.com>
Cc: Alexander Bondar <alexander.bon...@intel.com>
Cc: Johannes Berg <johannes.b...@intel.com>
Signed-off-by: Kirtika Ruchandani <kirt...@chromium.org>
---
 net/mac80211/scan.c | 8 +++-
 1 file changed, 3 insertions(+), 5 deletions(-)

diff --git a/net/mac80211/scan.c b/net/mac80211/scan.c
index 23d8ac8..faab3c4 100644
--- a/net/mac80211/scan.c
+++ b/net/mac80211/scan.c
@@ -1120,7 +1120,6 @@ int __ieee80211_request_sched_scan_start(struct 
ieee80211_sub_if_data *sdata,
u32 rate_masks[NUM_NL80211_BANDS] = {};
u8 bands_used = 0;
u8 *ie;
-   size_t len;
 
iebufsz = local->scan_ies_len + req->ie_len;
 
@@ -1145,10 +1144,9 @@ int __ieee80211_request_sched_scan_start(struct 
ieee80211_sub_if_data *sdata,
 
ieee80211_prepare_scan_chandef(, req->scan_width);
 
-   len = ieee80211_build_preq_ies(local, ie, num_bands * iebufsz,
-  _scan_ies, req->ie,
-  req->ie_len, bands_used,
-  rate_masks, );
+   ieee80211_build_preq_ies(local, ie, num_bands * iebufsz,
+_scan_ies, req->ie,
+req->ie_len, bands_used, rate_masks, );
 
ret = drv_sched_scan_start(local, sdata, req, _scan_ies);
if (ret == 0) {
-- 
2.8.0.rc3.226.g39d4020



[PATCH 1/4] mac80211: Removed unused 'i' variable

2016-11-23 Thread Kirtika Ruchandani
Commit 5bcae31d9 (mac80211: implement multi-vif in-place reservations)
introduced ieee80211_vif_use_reserved_switch() with a counter variable
'i' that is set but not used. Compiling with W=1 gives the following
warning, fix it.
net/mac80211/chan.c: In function ‘ieee80211_vif_use_reserved_switch’:
net/mac80211/chan.c:1273:6: warning: variable ‘i’ set but not used 
[-Wunused-but-set-variable]

This is a harmless warning, and is only being fixed to reduce the
noise obtained with W=1 in the kernel.

Fixes: 5bcae31d9 ("mac80211: implement multi-vif in-place reservations")
Cc: Michal Kazior <michal.kaz...@tieto.com>
Cc: Johannes Berg <johannes.b...@intel.com>
Signed-off-by: Kirtika Ruchandani <kirt...@chromium.org>
---
 net/mac80211/chan.c | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)

diff --git a/net/mac80211/chan.c b/net/mac80211/chan.c
index e75cbf6..7550fd2 100644
--- a/net/mac80211/chan.c
+++ b/net/mac80211/chan.c
@@ -1270,7 +1270,7 @@ static int ieee80211_vif_use_reserved_switch(struct 
ieee80211_local *local)
struct ieee80211_sub_if_data *sdata, *sdata_tmp;
struct ieee80211_chanctx *ctx, *ctx_tmp, *old_ctx;
struct ieee80211_chanctx *new_ctx = NULL;
-   int i, err, n_assigned, n_reserved, n_ready;
+   int err, n_assigned, n_reserved, n_ready;
int n_ctx = 0, n_vifs_switch = 0, n_vifs_assign = 0, n_vifs_ctxless = 0;
 
lockdep_assert_held(>mtx);
@@ -1391,8 +1391,6 @@ static int ieee80211_vif_use_reserved_switch(struct 
ieee80211_local *local)
 * Update all structures, values and pointers to point to new channel
 * context(s).
 */
-
-   i = 0;
list_for_each_entry(ctx, >chanctx_list, list) {
if (ctx->replace_state != IEEE80211_CHANCTX_REPLACES_OTHER)
continue;
-- 
2.8.0.rc3.226.g39d4020



[PATCH 0/4] Fix -Wunused-but-set-variable in net/mac80211/

2016-11-23 Thread Kirtika Ruchandani
This patchset is part of the effort led by Arnd Bergmann to clean up
warnings in the kernel. This and following patchsets will focus on
"-Wunused-but-set-variable" as it among the noisier ones. These were
found compiling with W=1.

Kirtika Ruchandani (4):
  mac80211: Removed unused 'i' variable
  mac80211: Remove unused 'len' variable
  mac80211: Removed unused 'struct ieee80211_supported_band*' variable
  mac80211: Remove unused 'beaconint_us' variable

 net/mac80211/chan.c | 4 +---
 net/mac80211/mlme.c | 4 
 net/mac80211/scan.c | 8 +++-
 net/mac80211/vht.c  | 4 
 4 files changed, 4 insertions(+), 16 deletions(-)

-- 
2.8.0.rc3.226.g39d4020



[PATCH] mac80211: Remove unused 'struct rate_control_ref' variable

2016-11-21 Thread Kirtika Ruchandani
Commit 3b17fbf87d5d introduced sta_get_expected_throughput()
leaving variable 'struct rate_control_ref* ref' set but unused.
Compiling with W=1 gives the following warning, fix it.

net/mac80211/sta_info.c: In function ‘sta_set_sinfo’:
net/mac80211/sta_info.c:2052:27: warning: variable ‘ref’ set but not used 
[-Wunused-but-set-variable]

Fixes: 3b17fbf87d5d ("mac80211: mesh: Add support for HW RC implementation")
Cc: Johannes Berg <johannes.b...@intel.com>
Cc: Maxim Altshul <maxim.alts...@ti.com>
Signed-off-by: Kirtika Ruchandani <kirt...@google.com>
---
 net/mac80211/sta_info.c | 4 
 1 file changed, 4 deletions(-)

diff --git a/net/mac80211/sta_info.c b/net/mac80211/sta_info.c
index 1711bae..4ab75a9 100644
--- a/net/mac80211/sta_info.c
+++ b/net/mac80211/sta_info.c
@@ -2049,16 +2049,12 @@ void sta_set_sinfo(struct sta_info *sta, struct 
station_info *sinfo)
 {
struct ieee80211_sub_if_data *sdata = sta->sdata;
struct ieee80211_local *local = sdata->local;
-   struct rate_control_ref *ref = NULL;
u32 thr = 0;
int i, ac, cpu;
struct ieee80211_sta_rx_stats *last_rxstats;

last_rxstats = sta_get_last_rx_stats(sta);

-   if (test_sta_flag(sta, WLAN_STA_RATE_CONTROL))
-   ref = local->rate_ctrl;
-
sinfo->generation = sdata->local->sta_generation;

/* do before driver, so beacon filtering drivers have a
--
2.8.0.rc3.226.g39d4020



[PATCH] mac80211: Remove unused 'rates_idx' variable

2016-11-21 Thread Kirtika Ruchandani
Commit f027c2aca0cf introduced 'rates_idx' in
ieee80211_tx_status_noskb but did not use it. Compiling with W=1
gives the following warning, fix it.

mac80211/status.c: In function ‘ieee80211_tx_status_noskb’:
mac80211/status.c:636:6: warning: variable ‘rates_idx’ set but not used 
[-Wunused-but-set-variable]

This is a harmless warning, and is only being fixed to reduce the
noise generated with W=1.

Fixes: f027c2aca0cf ("mac80211: add ieee80211_tx_status_noskb")
Cc: Johannes Berg <johannes.b...@intel.com>
Cc: Felix Fietkau <n...@openwrt.org>
Signed-off-by: Kirtika Ruchandani <kirt...@google.com>
---
 net/mac80211/status.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/net/mac80211/status.c b/net/mac80211/status.c
index ddf71c6..f7c5ae5 100644
--- a/net/mac80211/status.c
+++ b/net/mac80211/status.c
@@ -633,10 +633,9 @@ void ieee80211_tx_status_noskb(struct ieee80211_hw *hw,
struct ieee80211_local *local = hw_to_local(hw);
struct ieee80211_supported_band *sband;
int retry_count;
-   int rates_idx;
bool acked, noack_success;

-   rates_idx = ieee80211_tx_get_rates(hw, info, _count);
+   ieee80211_tx_get_rates(hw, info, _count);

sband = hw->wiphy->bands[info->band];

--
2.8.0.rc3.226.g39d4020



[PATCH] mac80211: Remove unused 'struct ieee80211_rx_status' ptr

2016-11-21 Thread Kirtika Ruchandani
Commit 554891e63a29 introduced 'struct ieee80211_rx_status' in
ieee80211_rx_h_defragment but did not use it. Compiling with W=1
gives the following warning, fix it.

net/mac80211/rx.c: In function ‘ieee80211_rx_h_defragment’:
net/mac80211/rx.c:1911:30: warning: variable ‘status’ set but not used 
[-Wunused-but-set-variable]

Fixes: 554891e63a29 ("mac80211: move packet flags into packet")
Cc: Johannes Berg <johannes.b...@intel.com>
Cc: John W. Linville <linvi...@tuxdriver.com>
Signed-off-by: Kirtika Ruchandani <kirt...@google.com>
---
 net/mac80211/rx.c | 4 
 1 file changed, 4 deletions(-)

diff --git a/net/mac80211/rx.c b/net/mac80211/rx.c
index eeab725..d2a00f2 100644
--- a/net/mac80211/rx.c
+++ b/net/mac80211/rx.c
@@ -1908,7 +1908,6 @@ ieee80211_rx_h_defragment(struct ieee80211_rx_data *rx)
unsigned int frag, seq;
struct ieee80211_fragment_entry *entry;
struct sk_buff *skb;
-   struct ieee80211_rx_status *status;

hdr = (struct ieee80211_hdr *)rx->skb->data;
fc = hdr->frame_control;
@@ -2034,9 +2033,6 @@ ieee80211_rx_h_defragment(struct ieee80211_rx_data *rx)
dev_kfree_skb(skb);
}

-   /* Complete frame has been reassembled - process it now */
-   status = IEEE80211_SKB_RXCB(rx->skb);
-
  out:
ieee80211_led_rx(rx->local);
  out_no_led:
--
2.8.0.rc3.226.g39d4020



[PATCH] net/wireless: Fix 'multiple blank lines' check

2016-05-31 Thread Kirtika Ruchandani
This patch fixes the checkpatch.pl check "Please don't use multiple
blank lines" for all files in net/wireless, except nl80211.c which
is covered in a separated patch.

Signed-off-by: Kirtika Ruchandani <kirtika.ruchand...@gmail.com>
---
 net/wireless/ap.c  | 1 -
 net/wireless/chan.c| 3 ---
 net/wireless/core.h| 2 --
 net/wireless/ibss.c| 1 -
 net/wireless/mlme.c| 2 --
 net/wireless/radiotap.c| 2 --
 net/wireless/rdev-ops.h| 2 --
 net/wireless/reg.c | 3 ---
 net/wireless/scan.c| 1 -
 net/wireless/sme.c | 1 -
 net/wireless/util.c| 2 --
 net/wireless/wext-compat.c | 3 ---
 net/wireless/wext-compat.h | 2 --
 net/wireless/wext-core.c   | 6 --
 net/wireless/wext-proc.c   | 1 -
 net/wireless/wext-sme.c| 1 -
 16 files changed, 33 deletions(-)

diff --git a/net/wireless/ap.c b/net/wireless/ap.c
index bdad1f9..23acf58 100644
--- a/net/wireless/ap.c
+++ b/net/wireless/ap.c
@@ -5,7 +5,6 @@
 #include "core.h"
 #include "rdev-ops.h"

-
 int __cfg80211_stop_ap(struct cfg80211_registered_device *rdev,
   struct net_device *dev, bool notify)
 {
diff --git a/net/wireless/chan.c b/net/wireless/chan.c
index da49c0b..34cec73d 100644
--- a/net/wireless/chan.c
+++ b/net/wireless/chan.c
@@ -325,7 +325,6 @@ static int cfg80211_get_chans_dfs_required(struct wiphy 
*wiphy,
return 0;
 }

-
 int cfg80211_chandef_dfs_required(struct wiphy *wiphy,
  const struct cfg80211_chan_def *chandef,
  enum nl80211_iftype iftype)
@@ -455,7 +454,6 @@ bool cfg80211_chandef_dfs_usable(struct wiphy *wiphy,
return (r1 + r2 > 0);
 }

-
 static bool cfg80211_get_chans_dfs_available(struct wiphy *wiphy,
 u32 center_freq,
 u32 bandwidth)
@@ -685,7 +683,6 @@ bool cfg80211_chandef_usable(struct wiphy *wiphy,
if (width < 20)
prohibited_flags |= IEEE80211_CHAN_NO_OFDM;

-
if (!cfg80211_secondary_chans_ok(wiphy, chandef->center_freq1,
 width, prohibited_flags))
return false;
diff --git a/net/wireless/core.h b/net/wireless/core.h
index 025b7a5..5c54a1e 100644
--- a/net/wireless/core.h
+++ b/net/wireless/core.h
@@ -16,7 +16,6 @@
 #include 
 #include "reg.h"

-
 #define WIPHY_IDX_INVALID  -1

 struct cfg80211_registered_device {
@@ -161,7 +160,6 @@ static inline void cfg80211_unhold_bss(struct 
cfg80211_internal_bss *bss)
WARN_ON(r < 0);
 }

-
 struct cfg80211_registered_device *cfg80211_rdev_by_wiphy_idx(int wiphy_idx);
 int get_wiphy_idx(struct wiphy *wiphy);

diff --git a/net/wireless/ibss.c b/net/wireless/ibss.c
index 4a4dda5..67b4f9b 100644
--- a/net/wireless/ibss.c
+++ b/net/wireless/ibss.c
@@ -13,7 +13,6 @@
 #include "nl80211.h"
 #include "rdev-ops.h"

-
 void __cfg80211_ibss_joined(struct net_device *dev, const u8 *bssid,
struct ieee80211_channel *channel)
 {
diff --git a/net/wireless/mlme.c b/net/wireless/mlme.c
index c284d88..332a143 100644
--- a/net/wireless/mlme.c
+++ b/net/wireless/mlme.c
@@ -18,7 +18,6 @@
 #include "nl80211.h"
 #include "rdev-ops.h"

-
 void cfg80211_rx_assoc_resp(struct net_device *dev, struct cfg80211_bss *bss,
const u8 *buf, size_t len, int uapsd_queues)
 {
@@ -768,7 +767,6 @@ void cfg80211_dfs_channels_update_work(struct work_struct 
*work)
   next_time);
 }

-
 void cfg80211_radar_event(struct wiphy *wiphy,
  struct cfg80211_chan_def *chandef,
  gfp_t gfp)
diff --git a/net/wireless/radiotap.c b/net/wireless/radiotap.c
index 6582d15..f193b88 100644
--- a/net/wireless/radiotap.c
+++ b/net/wireless/radiotap.c
@@ -184,8 +184,6 @@ static void find_ns(struct ieee80211_radiotap_iterator 
*iterator,
}
 }

-
-
 /**
  * ieee80211_radiotap_iterator_next - return next radiotap parser iterator arg
  * @iterator: radiotap_iterator to move to next arg (if any)
diff --git a/net/wireless/rdev-ops.h b/net/wireless/rdev-ops.h
index 85ff30b..9ad56db 100644
--- a/net/wireless/rdev-ops.h
+++ b/net/wireless/rdev-ops.h
@@ -338,7 +338,6 @@ static inline int rdev_join_mesh(struct 
cfg80211_registered_device *rdev,
return ret;
 }

-
 static inline int rdev_leave_mesh(struct cfg80211_registered_device *rdev,
  struct net_device *dev)
 {
@@ -569,7 +568,6 @@ static inline void rdev_rfkill_poll(struct 
cfg80211_registered_device *rdev)
trace_rdev_return_void(>wiphy);
 }

-
 #ifdef CONFIG_NL80211_TESTMODE
 static inline int rdev_testmode_cmd(struct cfg80211_registered_device *rdev,
struct wireless_dev *wdev,
diff --git a/net/wireless/reg.c b/net/wireless

Re: [PATCH v2 03/10] nl80211: Prefer ether_addr_copy

2016-05-30 Thread Kirtika Ruchandani
> This looks right to me, but doesn't ether_addr_copy() have alignment
> requirements? Could someone more familiar with that review these
> changes to ensure they're met?

Thanks for catching this.
The requirement is to be __aligned(2). I've added 4 instances of
ether_addr_copy with 8 addresses as arguments.  Of these, the 4
src arguments are really the same type (i.e. nla_data acting on a
const nlattr*), so I'll try to reason about the 5 total cases below -
1. cfg->dst_mac should be 16-bit aligned due to the layout of
struct cfg80211_wowlan_tcp. Its offset is 10 or 12 bytes in the
structure depending on the system.
2 and 3. For mac_addr and mac_addr_mask, nl80211_parse_random_mac
takes these in as u8* (and hence does not guarantee alignment?)
Both the callers of this function today pass in arguments that are
explicitly __aligned(2). But this cannot be said of future potential callers
- so perhaps my patch introduces a bug?
4. Based on struct cfg80211_acl_data, acl->mac_addrs[i] should be not
guaranteed to be __aligned(2).
5. For all the nla_data src arguments, the nla_data function returns
((char*) foo + 5) for pointer foo. So likely not __aligned(2).

Based on 3, 4 and 5, this patch should be revoked, but it would be nice
to have a confirmation from someone else.


Re: [PATCH v2 06/10] nl80211: Various checkpatch.pl spacing fixes

2016-05-30 Thread Kirtika Ruchandani
> Adding the brackets around the & expression doesn't look spacing
> related to me. What's the exact warning this is fixing?

>From the commit message - "This patch also contains two hunks to fix
'line over 80 characters',
that are spacing related". This is the second hunk, the first being
the comments in the nl80211_fam
definition. Should I resend with these two hunks omitted, or fix my wording?


[PATCH v2 08/10] nl80211: Fix spelling

2016-05-29 Thread Kirtika Ruchandani
Fix 'implementation' spelling, reported by checkpatch.pl

Signed-off-by: Kirtika Ruchandani <kirtika.ruchand...@gmail.com>
---
 net/wireless/nl80211.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/net/wireless/nl80211.c b/net/wireless/nl80211.c
index 6f8e2a7..c6d870e 100644
--- a/net/wireless/nl80211.c
+++ b/net/wireless/nl80211.c
@@ -6492,7 +6492,7 @@ nl80211_parse_sched_scan(struct wiphy *wiphy, struct 
wireless_dev *wdev,
   nla_data(ssid), nla_len(ssid));
request->match_sets[i].ssid.ssid_len =
nla_len(ssid);
-   /* special attribute - old implemenation w/a */
+   /* special attribute - old implementation w/a */
request->match_sets[i].rssi_thold =
default_match_rssi;
rssi = tb[NL80211_SCHED_SCAN_MATCH_ATTR_RSSI];
--
2.8.0.rc3.226.g39d4020



[PATCH v2 10/10] nl80211: Prefer kcalloc over kzalloc

2016-05-29 Thread Kirtika Ruchandani
This patch fixes the checkpatch.pl warning -
"prefer kcalloc over kzalloc with multiply"

Signed-off-by: Kirtika Ruchandani <kirtika.ruchand...@gmail.com>
---
 net/wireless/nl80211.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/net/wireless/nl80211.c b/net/wireless/nl80211.c
index 46757af..2964406 100644
--- a/net/wireless/nl80211.c
+++ b/net/wireless/nl80211.c
@@ -9482,7 +9482,7 @@ static int nl80211_parse_wowlan_nd(struct 
cfg80211_registered_device *rdev,
struct nlattr **tb;
int err;

-   tb = kzalloc(NUM_NL80211_ATTR * sizeof(*tb), GFP_KERNEL);
+   tb = kcalloc(NUM_NL80211_ATTR, sizeof(*tb), GFP_KERNEL);
if (!tb)
return -ENOMEM;

--
2.8.0.rc3.226.g39d4020



[PATCH v2 09/10] nl80211: Fix checkpatch.pl warning

2016-05-29 Thread Kirtika Ruchandani
This patch fixes the checkpatch.pl warning "foo * bar should be
foo *bar"

Signed-off-by: Kirtika Ruchandani <kirtika.ruchand...@gmail.com>
---
 net/wireless/nl80211.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/net/wireless/nl80211.c b/net/wireless/nl80211.c
index c6d870e..46757af 100644
--- a/net/wireless/nl80211.c
+++ b/net/wireless/nl80211.c
@@ -12214,7 +12214,7 @@ void nl80211_send_ibss_bssid(struct 
cfg80211_registered_device *rdev,
 }

 void cfg80211_notify_new_peer_candidate(struct net_device *dev, const u8 *addr,
-   const u8* ie, u8 ie_len, gfp_t gfp)
+   const u8 *ie, u8 ie_len, gfp_t gfp)
 {
struct wireless_dev *wdev = dev->ieee80211_ptr;
struct cfg80211_registered_device *rdev = wiphy_to_rdev(wdev->wiphy);
@@ -13362,7 +13362,7 @@ void cfg80211_tdls_oper_request(struct net_device *dev, 
const u8 *peer,
 }
 EXPORT_SYMBOL(cfg80211_tdls_oper_request);

-static int nl80211_netlink_notify(struct notifier_block * nb,
+static int nl80211_netlink_notify(struct notifier_block *nb,
  unsigned long state,
  void *_notify)
 {
--
2.8.0.rc3.226.g39d4020



[PATCH v2 07/10] nl80211: Avoid multiple assignments on same line

2016-05-29 Thread Kirtika Ruchandani
This patch fixes the checkpatch.pl warning "multiple assignments
should be avoided."

Signed-off-by: Kirtika Ruchandani <kirtika.ruchand...@gmail.com>
---
 net/wireless/nl80211.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/net/wireless/nl80211.c b/net/wireless/nl80211.c
index ad7cdce..6f8e2a7 100644
--- a/net/wireless/nl80211.c
+++ b/net/wireless/nl80211.c
@@ -2603,7 +2603,8 @@ static int nl80211_set_interface(struct sk_buff *skb, 
struct genl_info *info)

memset(, 0, sizeof(params));

-   otype = ntype = dev->ieee80211_ptr->iftype;
+   otype = dev->ieee80211_ptr->iftype;
+   ntype = dev->ieee80211_ptr->iftype;

if (info->attrs[NL80211_ATTR_IFTYPE]) {
ntype = nla_get_u32(info->attrs[NL80211_ATTR_IFTYPE]);
--
2.8.0.rc3.226.g39d4020



[PATCH v2 06/10] nl80211: Various checkpatch.pl spacing fixes

2016-05-29 Thread Kirtika Ruchandani
This patch fixes the following spacing issues reported
by checkpatch.pl -
- space preferred around that 
- no space needed after cast.
- Alignment should match open parenthesis
- suspect code indent for conditional statements
- Statements should start on a tabstop

This patch also contains two hunks to fix 'line over 80 characters',
that are spacing related.
All other instances of that warning have been ignored.

Signed-off-by: Kirtika Ruchandani <kirtika.ruchand...@gmail.com>
---
 net/wireless/nl80211.c | 103 ++---
 1 file changed, 54 insertions(+), 49 deletions(-)

diff --git a/net/wireless/nl80211.c b/net/wireless/nl80211.c
index 11cbf0b..ad7cdce 100644
--- a/net/wireless/nl80211.c
+++ b/net/wireless/nl80211.c
@@ -39,10 +39,10 @@ static void nl80211_post_doit(const struct genl_ops *ops, 
struct sk_buff *skb,

 /* the netlink family */
 static struct genl_family nl80211_fam = {
-   .id = GENL_ID_GENERATE, /* don't bother with a hardcoded ID */
-   .name = NL80211_GENL_NAME,  /* have users key off the name instead 
*/
-   .hdrsize = 0,   /* no private header */
-   .version = 1,   /* no particular meaning now */
+   .id = GENL_ID_GENERATE, /* don't bother with a hardcoded ID */
+   .name = NL80211_GENL_NAME,  /* have users key off the name instead */
+   .hdrsize = 0,   /* no private header */
+   .version = 1,   /* no particular meaning now */
.maxattr = NL80211_ATTR_MAX,
.netnsok = true,
.pre_doit = nl80211_pre_doit,
@@ -213,7 +213,7 @@ cfg80211_get_dev_from_info(struct net *netns, struct 
genl_info *info)
 static const struct nla_policy nl80211_policy[NUM_NL80211_ATTR] = {
[NL80211_ATTR_WIPHY] = { .type = NLA_U32 },
[NL80211_ATTR_WIPHY_NAME] = { .type = NLA_NUL_STRING,
- .len = 20-1 },
+ .len = 20 - 1 },
[NL80211_ATTR_WIPHY_TXQ_PARAMS] = { .type = NLA_NESTED },

[NL80211_ATTR_WIPHY_FREQ] = { .type = NLA_U32 },
@@ -231,7 +231,7 @@ static const struct nla_policy 
nl80211_policy[NUM_NL80211_ATTR] = {

[NL80211_ATTR_IFTYPE] = { .type = NLA_U32 },
[NL80211_ATTR_IFINDEX] = { .type = NLA_U32 },
-   [NL80211_ATTR_IFNAME] = { .type = NLA_NUL_STRING, .len = IFNAMSIZ-1 },
+   [NL80211_ATTR_IFNAME] = { .type = NLA_NUL_STRING, .len = IFNAMSIZ - 1 },

[NL80211_ATTR_MAC] = { .len = ETH_ALEN },
[NL80211_ATTR_PREV_BSSID] = { .len = ETH_ALEN },
@@ -967,7 +967,7 @@ static int nl80211_put_iface_combinations(struct wiphy 
*wiphy,
int i, j;

nl_combis = nla_nest_start(msg,
-   NL80211_ATTR_INTERFACE_COMBINATIONS);
+  NL80211_ATTR_INTERFACE_COMBINATIONS);
if (!nl_combis)
goto nla_put_failure;

@@ -1012,9 +1012,9 @@ static int nl80211_put_iface_combinations(struct wiphy 
*wiphy,
goto nla_put_failure;
if (large &&
(nla_put_u32(msg, NL80211_IFACE_COMB_RADAR_DETECT_WIDTHS,
-   c->radar_detect_widths) ||
+c->radar_detect_widths) ||
 nla_put_u32(msg, NL80211_IFACE_COMB_RADAR_DETECT_REGIONS,
-   c->radar_detect_regions)))
+c->radar_detect_regions)))
goto nla_put_failure;

nla_nest_end(msg, nl_combi);
@@ -1493,7 +1493,7 @@ static int nl80211_send_wiphy(struct 
cfg80211_registered_device *rdev,

i = 0;
 #define CMD(op, n) \
-do {   \
+   do {\
if (rdev->ops->op) {\
i++;\
if (nla_put_u32(msg, i, NL80211_CMD_ ## n)) \
@@ -1735,8 +1735,9 @@ static int nl80211_send_wiphy(struct 
cfg80211_registered_device *rdev,
   rdev->wiphy.max_num_csa_counters))
goto nla_put_failure;

-   if (rdev->wiphy.regulatory_flags & 
REGULATORY_WIPHY_SELF_MANAGED &&
-   nla_put_flag(msg, NL80211_ATTR_WIPHY_SELF_MANAGED_REG))
+   if ((rdev->wiphy.regulatory_flags &
+REGULATORY_WIPHY_SELF_MANAGED) &&
+nla_put_flag(msg, NL80211_ATTR_WIPHY_SELF_MANAGED_REG))
goto nla_put_failure;

if (nla_put(msg, NL80211_ATTR_EXT_FEATURES,
@@ -2299,7 +2300,7 @@ static int nl80211_set_wiphy(struct sk_buff *skb, struct 
genl_info *info)
   

[PATCH v2 05/10] nl80211: Fix checkpatch.pl NULL comparison warning

2016-05-29 Thread Kirtika Ruchandani
This patch fixes the warning - "comparison to NULL (foo == NULL)
could be written as (!foo)"

Signed-off-by: Kirtika Ruchandani <kirtika.ruchand...@gmail.com>
---
 net/wireless/nl80211.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/net/wireless/nl80211.c b/net/wireless/nl80211.c
index 945405d..11cbf0b 100644
--- a/net/wireless/nl80211.c
+++ b/net/wireless/nl80211.c
@@ -928,7 +928,7 @@ static struct ieee80211_channel 
*nl80211_get_valid_chan(struct wiphy *wiphy,
 {
struct ieee80211_channel *chan;

-   if (tb == NULL)
+   if (!tb)
return NULL;
chan = ieee80211_get_channel(wiphy, nla_get_u32(tb));
if (!chan || chan->flags & IEEE80211_CHAN_DISABLED)
@@ -8575,7 +8575,7 @@ static int nl80211_set_tx_bitrate_mask(struct sk_buff 
*skb,
if (band < 0 || band >= NUM_NL80211_BANDS)
return -EINVAL;
sband = rdev->wiphy.bands[band];
-   if (sband == NULL)
+   if (!sband)
return -EINVAL;
err = nla_parse(tb, NL80211_TXRATE_MAX, nla_data(tx_rates),
nla_len(tx_rates), nl80211_txattr_policy);
--
2.8.0.rc3.226.g39d4020



[PATCH v2 03/10] nl80211: Prefer ether_addr_copy

2016-05-29 Thread Kirtika Ruchandani
This patch fixes the checkpatch,pl to prefer ether_addr_copy
over memcpy.

Signed-off-by: Kirtika Ruchandani <kirtika.ruchand...@gmail.com>
---
 net/wireless/nl80211.c | 9 -
 1 file changed, 4 insertions(+), 5 deletions(-)

diff --git a/net/wireless/nl80211.c b/net/wireless/nl80211.c
index cd422bd..34b8fbe 100644
--- a/net/wireless/nl80211.c
+++ b/net/wireless/nl80211.c
@@ -3194,7 +3194,7 @@ static struct cfg80211_acl_data *parse_acl_data(struct 
wiphy *wiphy,
return ERR_PTR(-ENOMEM);

nla_for_each_nested(attr, info->attrs[NL80211_ATTR_MAC_ADDRS], tmp) {
-   memcpy(acl->mac_addrs[i].addr, nla_data(attr), ETH_ALEN);
+   ether_addr_copy(acl->mac_addrs[i].addr, nla_data(attr));
i++;
}

@@ -5892,8 +5892,8 @@ static int nl80211_parse_random_mac(struct nlattr **attrs,
if (!attrs[NL80211_ATTR_MAC] || !attrs[NL80211_ATTR_MAC_MASK])
return -EINVAL;

-   memcpy(mac_addr, nla_data(attrs[NL80211_ATTR_MAC]), ETH_ALEN);
-   memcpy(mac_addr_mask, nla_data(attrs[NL80211_ATTR_MAC_MASK]), ETH_ALEN);
+   ether_addr_copy(mac_addr, nla_data(attrs[NL80211_ATTR_MAC]));
+   ether_addr_copy(mac_addr_mask, nla_data(attrs[NL80211_ATTR_MAC_MASK]));

/* don't allow or configure an mcast address */
if (!is_multicast_ether_addr(mac_addr_mask) ||
@@ -9405,8 +9405,7 @@ static int nl80211_parse_wowlan_tcp(struct 
cfg80211_registered_device *rdev,
return -ENOMEM;
cfg->src = nla_get_in_addr(tb[NL80211_WOWLAN_TCP_SRC_IPV4]);
cfg->dst = nla_get_in_addr(tb[NL80211_WOWLAN_TCP_DST_IPV4]);
-   memcpy(cfg->dst_mac, nla_data(tb[NL80211_WOWLAN_TCP_DST_MAC]),
-  ETH_ALEN);
+   ether_addr_copy(cfg->dst_mac, nla_data(tb[NL80211_WOWLAN_TCP_DST_MAC]));
if (tb[NL80211_WOWLAN_TCP_SRC_PORT])
port = nla_get_u16(tb[NL80211_WOWLAN_TCP_SRC_PORT]);
else
--
2.8.0.rc3.226.g39d4020



[PATCH v2 04/10] nl80211: Fix checkpatch.pl warning about braces

2016-05-29 Thread Kirtika Ruchandani
This patch fixes the following checkpatch,pl warning -
- braces {} should be used on all arms of this statement.

Signed-off-by: Kirtika Ruchandani <kirtika.ruchand...@gmail.com>
---
 net/wireless/nl80211.c | 23 +++
 1 file changed, 15 insertions(+), 8 deletions(-)

diff --git a/net/wireless/nl80211.c b/net/wireless/nl80211.c
index 34b8fbe..945405d 100644
--- a/net/wireless/nl80211.c
+++ b/net/wireless/nl80211.c
@@ -870,8 +870,9 @@ nl80211_parse_connkeys(struct cfg80211_registered_device 
*rdev,
result->def = parse.idx;
if (!parse.def_uni || !parse.def_multi)
goto error;
-   } else if (parse.defmgmt)
+   } else if (parse.defmgmt) {
goto error;
+   }
err = cfg80211_validate_key_settings(rdev, ,
 parse.idx, false, NULL);
if (err)
@@ -1401,8 +1402,9 @@ static int nl80211_send_wiphy(struct 
cfg80211_registered_device *rdev,
break;
case 2:
if (nl80211_put_iftypes(msg, NL80211_ATTR_SUPPORTED_IFTYPES,
-   rdev->wiphy.interface_modes))
-   goto nla_put_failure;
+   rdev->wiphy.interface_modes)) {
+   goto nla_put_failure;
+   }
state->split_start++;
if (state->split)
break;
@@ -2155,8 +2157,9 @@ static int nl80211_set_wiphy(struct sk_buff *skb, struct 
genl_info *info)
wdev = NULL;
netdev = NULL;
result = 0;
-   } else
+   } else {
wdev = netdev->ieee80211_ptr;
+   }

/* end workaround code, by now the rdev is available
 * and locked, and wdev may or may not be NULL.
@@ -3403,8 +3406,9 @@ static int nl80211_start_ap(struct sk_buff *skb, struct 
genl_info *info)
if (!nl80211_valid_auth_type(rdev, params.auth_type,
 NL80211_CMD_START_AP))
return -EINVAL;
-   } else
+   } else {
params.auth_type = NL80211_AUTHTYPE_AUTOMATIC;
+   }

err = nl80211_crypto_settings(rdev, info, ,
  NL80211_MAX_NR_CIPHER_SUITES);
@@ -3450,8 +3454,9 @@ static int nl80211_start_ap(struct sk_buff *skb, struct 
genl_info *info)
return err;
} else if (wdev->preset_chandef.chan) {
params.chandef = wdev->preset_chandef;
-   } else if (!nl80211_get_ap_channel(rdev, ))
+   } else if (!nl80211_get_ap_channel(rdev, )) {
return -EINVAL;
+   }

if (!cfg80211_reg_can_beacon_relax(>wiphy, ,
   wdev->iftype))
@@ -7262,8 +7267,9 @@ static int nl80211_crypto_settings(struct 
cfg80211_registered_device *rdev,
return -EINVAL;
if (info->attrs[NL80211_ATTR_CONTROL_PORT_NO_ENCRYPT])
settings->control_port_no_encrypt = true;
-   } else
+   } else {
settings->control_port_ethertype = cpu_to_be16(ETH_P_PAE);
+   }

if (info->attrs[NL80211_ATTR_CIPHER_SUITES_PAIRWISE]) {
void *data;
@@ -7997,8 +8003,9 @@ static int nl80211_connect(struct sk_buff *skb, struct 
genl_info *info)
if (!nl80211_valid_auth_type(rdev, connect.auth_type,
 NL80211_CMD_CONNECT))
return -EINVAL;
-   } else
+   } else {
connect.auth_type = NL80211_AUTHTYPE_AUTOMATIC;
+   }

connect.privacy = info->attrs[NL80211_ATTR_PRIVACY];

--
2.8.0.rc3.226.g39d4020



[PATCH v2 02/10] nl80211: Fix checkpatch warnings about blank lines

2016-05-29 Thread Kirtika Ruchandani
This patch fixes the following checkpatch.pl issues -
- Please don't use multiple blank lines
- Blank lines aren't necessary before a close brace
- Missing a blank line after declarations

Reviewed-by: Julian Calaby <julian.cal...@gmail.com>
Signed-off-by: Kirtika Ruchandani <kirtika.ruchand...@gmail.com>
---
 net/wireless/nl80211.c | 22 ++
 1 file changed, 10 insertions(+), 12 deletions(-)

diff --git a/net/wireless/nl80211.c b/net/wireless/nl80211.c
index 50a0de0..cd422bd 100644
--- a/net/wireless/nl80211.c
+++ b/net/wireless/nl80211.c
@@ -167,6 +167,7 @@ __cfg80211_rdev_from_attrs(struct net *netns, struct nlattr 
**attrs)

if (attrs[NL80211_ATTR_IFINDEX]) {
int ifindex = nla_get_u32(attrs[NL80211_ATTR_IFINDEX]);
+
netdev = __dev_get_by_index(netns, ifindex);
if (netdev) {
if (netdev->ieee80211_ptr)
@@ -730,6 +731,7 @@ static int nl80211_parse_key_new(struct nlattr *key, struct 
key_parse *k)

if (tb[NL80211_KEY_DEFAULT_TYPES]) {
struct nlattr *kdt[NUM_NL80211_KEY_DEFAULT_TYPES];
+
err = nla_parse_nested(kdt, NUM_NL80211_KEY_DEFAULT_TYPES - 1,
   tb[NL80211_KEY_DEFAULT_TYPES],
   nl80211_key_default_policy);
@@ -1381,6 +1383,7 @@ static int nl80211_send_wiphy(struct 
cfg80211_registered_device *rdev,
rdev->ops->get_antenna) {
u32 tx_ant = 0, rx_ant = 0;
int res;
+
res = rdev_get_antenna(rdev, _ant, _ant);
if (!res) {
if (nla_put_u32(msg,
@@ -2111,7 +2114,6 @@ static int nl80211_set_wds_peer(struct sk_buff *skb, 
struct genl_info *info)
return rdev_set_wds_peer(rdev, dev, bssid);
 }

-
 static int nl80211_set_wiphy(struct sk_buff *skb, struct genl_info *info)
 {
struct cfg80211_registered_device *rdev;
@@ -2244,6 +2246,7 @@ static int nl80211_set_wiphy(struct sk_buff *skb, struct 
genl_info *info)
if (info->attrs[NL80211_ATTR_WIPHY_ANTENNA_TX] &&
info->attrs[NL80211_ATTR_WIPHY_ANTENNA_RX]) {
u32 tx_ant, rx_ant;
+
if ((!rdev->wiphy.available_antennas_tx &&
 !rdev->wiphy.available_antennas_rx) ||
!rdev->ops->set_antenna)
@@ -2910,6 +2913,7 @@ static int nl80211_get_key(struct sk_buff *skb, struct 
genl_info *info)
pairwise = !!mac_addr;
if (info->attrs[NL80211_ATTR_KEY_TYPE]) {
u32 kt = nla_get_u32(info->attrs[NL80211_ATTR_KEY_TYPE]);
+
if (kt >= NUM_NL80211_KEYTYPES)
return -EINVAL;
if (kt != NL80211_KEYTYPE_GROUP &&
@@ -3949,7 +3953,6 @@ static int nl80211_dump_station(struct sk_buff *skb,
sta_idx++;
}

-
  out:
cb->args[2] = sta_idx;
err = skb->len;
@@ -4742,7 +4745,6 @@ static int nl80211_dump_mpath(struct sk_buff *skb,
path_idx++;
}

-
  out:
cb->args[2] = path_idx;
err = skb->len;
@@ -5032,7 +5034,6 @@ static int nl80211_req_set_reg(struct sk_buff *skb, 
struct genl_info *info)
enum nl80211_user_reg_hint_type user_reg_hint_type;
u32 owner_nlportid;

-
/* You should only get this when cfg80211 hasn't yet initialized
 * completely when built-in to the kernel right between the time
 * window between nl80211_init() and regulatory_init(), if that is
@@ -5240,7 +5241,6 @@ do {  
\
}   \
 } while (0)

-
if (!info->attrs[NL80211_ATTR_MESH_CONFIG])
return -EINVAL;
if (nla_parse_nested(tb, NL80211_MESHCONF_ATTR_MAX,
@@ -5388,7 +5388,6 @@ static int nl80211_parse_mesh_setup(struct genl_info 
*info,
 IEEE80211_PATH_METRIC_VENDOR :
 IEEE80211_PATH_METRIC_AIRTIME;

-
if (tb[NL80211_MESH_SETUP_IE]) {
struct nlattr *ieattr =
tb[NL80211_MESH_SETUP_IE];
@@ -6009,6 +6008,7 @@ static int nl80211_trigger_scan(struct sk_buff *skb, 
struct genl_info *info)
/* all channels */
for (band = 0; band < NUM_NL80211_BANDS; band++) {
int j;
+
if (!wiphy->bands[band])
continue;
for (j = 0; j < wiphy->bands[band]->n_channels; j++) {
@@ -6412,6 +6412,7 @@ nl80211_parse_sched_scan(struct wiphy *wiphy, struct 
wireless_dev *wdev,
/* all channels */
for (band = 0; band < NUM_NL80211_BANDS; band++) {
int j;
+
   

[PATCH v2 01/10] nl80211: Fix checkpatch warnings

2016-05-29 Thread Kirtika Ruchandani
This patch fixes the following checkpatch.pl warnings about
comments in nl80211.c :
- networking block comments don't use an empty '/*' line
- block comments use a trailing '*/' on a separate line

Reviewed-by: Julian Calaby <julian.cal...@gmail.com>
Signed-off-by: Kirtika Ruchandani <kirtika.ruchand...@gmail.com>
---
 net/wireless/nl80211.c | 129 +
 1 file changed, 45 insertions(+), 84 deletions(-)

diff --git a/net/wireless/nl80211.c b/net/wireless/nl80211.c
index d759901..50a0de0 100644
--- a/net/wireless/nl80211.c
+++ b/net/wireless/nl80211.c
@@ -196,8 +196,7 @@ __cfg80211_rdev_from_attrs(struct net *netns, struct nlattr 
**attrs)
return rdev;
 }

-/*
- * This function returns a pointer to the driver
+/* This function returns a pointer to the driver
  * that the genl_info item that is passed refers to.
  *
  * The result of this can be a PTR_ERR and hence must
@@ -1624,8 +1623,7 @@ static int nl80211_send_wiphy(struct 
cfg80211_registered_device *rdev,
goto nla_put_failure;

features = rdev->wiphy.features;
-   /*
-* We can only add the per-channel limit information if the
+   /* We can only add the per-channel limit information if the
 * dump is split, otherwise it makes it too big. Therefore
 * only advertise it in that case.
 */
@@ -1646,8 +1644,7 @@ static int nl80211_send_wiphy(struct 
cfg80211_registered_device *rdev,
rdev->wiphy.max_acl_mac_addrs))
goto nla_put_failure;

-   /*
-* Any information below this point is only available to
+   /* Any information below this point is only available to
 * applications that can deal with it being split. This
 * helps ensure that newly added capabilities don't break
 * older tools by overrunning their buffers.
@@ -1847,8 +1844,7 @@ static int nl80211_dump_wiphy(struct sk_buff *skb, struct 
netlink_callback *cb)
 cb->nlh->nlmsg_seq,
 NLM_F_MULTI, state);
if (ret < 0) {
-   /*
-* If sending the wiphy data didn't fit (ENOBUFS
+   /* If sending the wiphy data didn't fit (ENOBUFS
 * or EMSGSIZE returned), this SKB is still
 * empty (so it's not too big because another
 * wiphy dataset is already in the skb) and
@@ -1937,8 +1933,7 @@ static int parse_txq_params(struct nlattr *tb[],

 static bool nl80211_can_set_dev_channel(struct wireless_dev *wdev)
 {
-   /*
-* You can only set the channel explicitly for WDS interfaces,
+   /* You can only set the channel explicitly for WDS interfaces,
 * all others have their channel managed via their respective
 * "establish a connection" command (connect, join, ...)
 *
@@ -2131,8 +2126,7 @@ static int nl80211_set_wiphy(struct sk_buff *skb, struct 
genl_info *info)

ASSERT_RTNL();

-   /*
-* Try to find the wiphy and netdev. Normally this
+   /* Try to find the wiphy and netdev. Normally this
 * function shouldn't need the netdev, but this is
 * done for backward compatibility -- previously
 * setting the channel was done per wiphy, but now
@@ -2162,8 +2156,7 @@ static int nl80211_set_wiphy(struct sk_buff *skb, struct 
genl_info *info)
} else
wdev = netdev->ieee80211_ptr;

-   /*
-* end workaround code, by now the rdev is available
+   /* end workaround code, by now the rdev is available
 * and locked, and wdev may or may not be NULL.
 */

@@ -2260,7 +2253,8 @@ static int nl80211_set_wiphy(struct sk_buff *skb, struct 
genl_info *info)
rx_ant = 
nla_get_u32(info->attrs[NL80211_ATTR_WIPHY_ANTENNA_RX]);

/* reject antenna configurations which don't match the
-* available antenna masks, except for the "all" mask */
+* available antenna masks, except for the "all" mask
+*/
if ((~tx_ant && (tx_ant & ~rdev->wiphy.available_antennas_tx)) 
||
(~rx_ant && (rx_ant & ~rdev->wiphy.available_antennas_rx)))
return -EINVAL;
@@ -2300,8 +2294,7 @@ static int nl80211_set_wiphy(struct sk_buff *skb, struct 
genl_info *info)
return -EINVAL;

if (frag_threshold != (u32) -1) {
-   /*
-* Fragments (apart from the last one) are required to
+   /* Fragment

[PATCH v2 00/10] nl80211: Fix checkpatch.pl issues

2016-05-29 Thread Kirtika Ruchandani
This patch-set attempts to fix checkpatch.pl issues found in nl80211.c.
Each patch describes the specific warnings/checks/errors it addresses.
This patch-set ignores 'line over 80 chars' warnings, except for 2 cases.
Please check for issues with the 'fixes' for 'alignment should match
open parenthesis'. Some of them do not display correctly with git diff.
This patch-set removes 3 errors, 66 warnings and 46 checks.

Kirtika Ruchandani (10):
  nl80211: Fix checkpatch warnings
  nl80211: Fix checkpatch warnings about blank lines
  nl80211: Prefer ether_addr_copy
  nl80211: Fix checkpatch.pl warning about braces
  nl80211: Fix checkpatch.pl NULL comparison warning
  nl80211: Various checkpatch.pl spacing fixes
  nl80211: Avoid multiple assignments on same line
  nl80211: Fix spelling
  nl80211: Fix checkpatch.pl warning
  nl80211: Prefer kcalloc over kzalloc

Changes in v2:
- Break down patch into smaller independent patches as suggested by Julian 
  Calaby.This breaks down patch 3/3 in set v1 into patches 3-10 of v2.

 net/wireless/nl80211.c | 301 ++---
 1 file changed, 136 insertions(+), 165 deletions(-)

-- 
2.8.0.rc3.226.g39d4020



Re: [PATCH 3/3] nl80211: Various checkpatch.pl fixes

2016-05-29 Thread Kirtika Ruchandani
>> There's too much stuff here to quickly review, it'd be nice if you
>> could split this up into patches that do the following:

Is it preferable to resend the whole patch-set or just patch 3/3 in
this one as a separate set?


Re: [PATCH 3/3] nl80211: Various checkpatch.pl fixes

2016-05-29 Thread Kirtika Ruchandani
> There's too much stuff here to quickly review, it'd be nice if you
> could split this up into patches that do the following:

Thanks, I will send out a v2 with the split you suggested.


[PATCH 3/3] nl80211: Various checkpatch.pl fixes

2016-05-28 Thread Kirtika Ruchandani
This patch fixes the following checkpatch.pl issues -
- space preferred around that 
- no space needed after cast.
- braces {} should be used on all arms of this statement
- Alignment should match open parenthesis
- suspect code indent for conditional statements
- Statements should start on a tabstop
- multiple assignments should be avoided
- prefer ether_addr_copy over memcpy
- correct spelling - 'implementation'
- comparison to NULL could be written as !foo
- prefer kcalloc over kzalloc with multiply

Signed-off-by: Kirtika Ruchandani <kirtika.ruchand...@gmail.com>
---
 net/wireless/nl80211.c | 152 ++---
 1 file changed, 82 insertions(+), 70 deletions(-)

diff --git a/net/wireless/nl80211.c b/net/wireless/nl80211.c
index cd422bd..9f7eb16 100644
--- a/net/wireless/nl80211.c
+++ b/net/wireless/nl80211.c
@@ -39,10 +39,10 @@ static void nl80211_post_doit(const struct genl_ops *ops, 
struct sk_buff *skb,
 
 /* the netlink family */
 static struct genl_family nl80211_fam = {
-   .id = GENL_ID_GENERATE, /* don't bother with a hardcoded ID */
-   .name = NL80211_GENL_NAME,  /* have users key off the name instead 
*/
-   .hdrsize = 0,   /* no private header */
-   .version = 1,   /* no particular meaning now */
+   .id = GENL_ID_GENERATE, /* don't bother with a hardcoded ID */
+   .name = NL80211_GENL_NAME,  /* have users key off the name instead */
+   .hdrsize = 0,   /* no private header */
+   .version = 1,   /* no particular meaning now */
.maxattr = NL80211_ATTR_MAX,
.netnsok = true,
.pre_doit = nl80211_pre_doit,
@@ -213,7 +213,7 @@ cfg80211_get_dev_from_info(struct net *netns, struct 
genl_info *info)
 static const struct nla_policy nl80211_policy[NUM_NL80211_ATTR] = {
[NL80211_ATTR_WIPHY] = { .type = NLA_U32 },
[NL80211_ATTR_WIPHY_NAME] = { .type = NLA_NUL_STRING,
- .len = 20-1 },
+ .len = 20 - 1 },
[NL80211_ATTR_WIPHY_TXQ_PARAMS] = { .type = NLA_NESTED },
 
[NL80211_ATTR_WIPHY_FREQ] = { .type = NLA_U32 },
@@ -231,7 +231,7 @@ static const struct nla_policy 
nl80211_policy[NUM_NL80211_ATTR] = {
 
[NL80211_ATTR_IFTYPE] = { .type = NLA_U32 },
[NL80211_ATTR_IFINDEX] = { .type = NLA_U32 },
-   [NL80211_ATTR_IFNAME] = { .type = NLA_NUL_STRING, .len = IFNAMSIZ-1 },
+   [NL80211_ATTR_IFNAME] = { .type = NLA_NUL_STRING, .len = IFNAMSIZ - 1 },
 
[NL80211_ATTR_MAC] = { .len = ETH_ALEN },
[NL80211_ATTR_PREV_BSSID] = { .len = ETH_ALEN },
@@ -870,8 +870,9 @@ nl80211_parse_connkeys(struct cfg80211_registered_device 
*rdev,
result->def = parse.idx;
if (!parse.def_uni || !parse.def_multi)
goto error;
-   } else if (parse.defmgmt)
+   } else if (parse.defmgmt) {
goto error;
+   }
err = cfg80211_validate_key_settings(rdev, ,
 parse.idx, false, NULL);
if (err)
@@ -927,7 +928,7 @@ static struct ieee80211_channel 
*nl80211_get_valid_chan(struct wiphy *wiphy,
 {
struct ieee80211_channel *chan;
 
-   if (tb == NULL)
+   if (!tb)
return NULL;
chan = ieee80211_get_channel(wiphy, nla_get_u32(tb));
if (!chan || chan->flags & IEEE80211_CHAN_DISABLED)
@@ -966,7 +967,7 @@ static int nl80211_put_iface_combinations(struct wiphy 
*wiphy,
int i, j;
 
nl_combis = nla_nest_start(msg,
-   NL80211_ATTR_INTERFACE_COMBINATIONS);
+  NL80211_ATTR_INTERFACE_COMBINATIONS);
if (!nl_combis)
goto nla_put_failure;
 
@@ -1011,9 +1012,9 @@ static int nl80211_put_iface_combinations(struct wiphy 
*wiphy,
goto nla_put_failure;
if (large &&
(nla_put_u32(msg, NL80211_IFACE_COMB_RADAR_DETECT_WIDTHS,
-   c->radar_detect_widths) ||
+c->radar_detect_widths) ||
 nla_put_u32(msg, NL80211_IFACE_COMB_RADAR_DETECT_REGIONS,
-   c->radar_detect_regions)))
+c->radar_detect_regions)))
goto nla_put_failure;
 
nla_nest_end(msg, nl_combi);
@@ -1401,8 +1402,9 @@ static int nl80211_send_wiphy(struct 
cfg80211_registered_device *rdev,
break;
case 2:
if (nl80211_put_iftypes(msg, NL80211_ATTR_SUPPORTED_IFTYPES,
-   rdev->wiphy.interface_modes))
-   goto nla_put_failure;
+   

[PATCH 1/3] nl80211: Fix checkpatch warnings

2016-05-28 Thread Kirtika Ruchandani
This patch fixes the following checkpatch.pl warnings about
comments in nl80211.c :
- networking block comments don't use an empty '/*' line
- block comments use a trailing '*/' on a separate line

Signed-off-by: Kirtika Ruchandani <kirtika.ruchand...@gmail.com>
---
 net/wireless/nl80211.c | 129 +
 1 file changed, 45 insertions(+), 84 deletions(-)

diff --git a/net/wireless/nl80211.c b/net/wireless/nl80211.c
index d759901..50a0de0 100644
--- a/net/wireless/nl80211.c
+++ b/net/wireless/nl80211.c
@@ -196,8 +196,7 @@ __cfg80211_rdev_from_attrs(struct net *netns, struct nlattr 
**attrs)
return rdev;
 }
 
-/*
- * This function returns a pointer to the driver
+/* This function returns a pointer to the driver
  * that the genl_info item that is passed refers to.
  *
  * The result of this can be a PTR_ERR and hence must
@@ -1624,8 +1623,7 @@ static int nl80211_send_wiphy(struct 
cfg80211_registered_device *rdev,
goto nla_put_failure;
 
features = rdev->wiphy.features;
-   /*
-* We can only add the per-channel limit information if the
+   /* We can only add the per-channel limit information if the
 * dump is split, otherwise it makes it too big. Therefore
 * only advertise it in that case.
 */
@@ -1646,8 +1644,7 @@ static int nl80211_send_wiphy(struct 
cfg80211_registered_device *rdev,
rdev->wiphy.max_acl_mac_addrs))
goto nla_put_failure;
 
-   /*
-* Any information below this point is only available to
+   /* Any information below this point is only available to
 * applications that can deal with it being split. This
 * helps ensure that newly added capabilities don't break
 * older tools by overrunning their buffers.
@@ -1847,8 +1844,7 @@ static int nl80211_dump_wiphy(struct sk_buff *skb, struct 
netlink_callback *cb)
 cb->nlh->nlmsg_seq,
 NLM_F_MULTI, state);
if (ret < 0) {
-   /*
-* If sending the wiphy data didn't fit (ENOBUFS
+   /* If sending the wiphy data didn't fit (ENOBUFS
 * or EMSGSIZE returned), this SKB is still
 * empty (so it's not too big because another
 * wiphy dataset is already in the skb) and
@@ -1937,8 +1933,7 @@ static int parse_txq_params(struct nlattr *tb[],
 
 static bool nl80211_can_set_dev_channel(struct wireless_dev *wdev)
 {
-   /*
-* You can only set the channel explicitly for WDS interfaces,
+   /* You can only set the channel explicitly for WDS interfaces,
 * all others have their channel managed via their respective
 * "establish a connection" command (connect, join, ...)
 *
@@ -2131,8 +2126,7 @@ static int nl80211_set_wiphy(struct sk_buff *skb, struct 
genl_info *info)
 
ASSERT_RTNL();
 
-   /*
-* Try to find the wiphy and netdev. Normally this
+   /* Try to find the wiphy and netdev. Normally this
 * function shouldn't need the netdev, but this is
 * done for backward compatibility -- previously
 * setting the channel was done per wiphy, but now
@@ -2162,8 +2156,7 @@ static int nl80211_set_wiphy(struct sk_buff *skb, struct 
genl_info *info)
} else
wdev = netdev->ieee80211_ptr;
 
-   /*
-* end workaround code, by now the rdev is available
+   /* end workaround code, by now the rdev is available
 * and locked, and wdev may or may not be NULL.
 */
 
@@ -2260,7 +2253,8 @@ static int nl80211_set_wiphy(struct sk_buff *skb, struct 
genl_info *info)
rx_ant = 
nla_get_u32(info->attrs[NL80211_ATTR_WIPHY_ANTENNA_RX]);
 
/* reject antenna configurations which don't match the
-* available antenna masks, except for the "all" mask */
+* available antenna masks, except for the "all" mask
+*/
if ((~tx_ant && (tx_ant & ~rdev->wiphy.available_antennas_tx)) 
||
(~rx_ant && (rx_ant & ~rdev->wiphy.available_antennas_rx)))
return -EINVAL;
@@ -2300,8 +2294,7 @@ static int nl80211_set_wiphy(struct sk_buff *skb, struct 
genl_info *info)
return -EINVAL;
 
if (frag_threshold != (u32) -1) {
-   /*
-* Fragments (apart from the last one) are required to
+   /* Fragments (apart from the last one) a

[PATCH 2/3] nl80211: Fix checkpatch warnings about blank lines

2016-05-28 Thread Kirtika Ruchandani
This patch fixes the following checkpatch.pl issues -
- Please don't use multiple blank lines
- Blank lines aren't necessary before a close brace
- Missing a blank line after declarations

Signed-off-by: Kirtika Ruchandani <kirtika.ruchand...@gmail.com>
---
 net/wireless/nl80211.c | 22 ++
 1 file changed, 10 insertions(+), 12 deletions(-)

diff --git a/net/wireless/nl80211.c b/net/wireless/nl80211.c
index 50a0de0..cd422bd 100644
--- a/net/wireless/nl80211.c
+++ b/net/wireless/nl80211.c
@@ -167,6 +167,7 @@ __cfg80211_rdev_from_attrs(struct net *netns, struct nlattr 
**attrs)
 
if (attrs[NL80211_ATTR_IFINDEX]) {
int ifindex = nla_get_u32(attrs[NL80211_ATTR_IFINDEX]);
+
netdev = __dev_get_by_index(netns, ifindex);
if (netdev) {
if (netdev->ieee80211_ptr)
@@ -730,6 +731,7 @@ static int nl80211_parse_key_new(struct nlattr *key, struct 
key_parse *k)
 
if (tb[NL80211_KEY_DEFAULT_TYPES]) {
struct nlattr *kdt[NUM_NL80211_KEY_DEFAULT_TYPES];
+
err = nla_parse_nested(kdt, NUM_NL80211_KEY_DEFAULT_TYPES - 1,
   tb[NL80211_KEY_DEFAULT_TYPES],
   nl80211_key_default_policy);
@@ -1381,6 +1383,7 @@ static int nl80211_send_wiphy(struct 
cfg80211_registered_device *rdev,
rdev->ops->get_antenna) {
u32 tx_ant = 0, rx_ant = 0;
int res;
+
res = rdev_get_antenna(rdev, _ant, _ant);
if (!res) {
if (nla_put_u32(msg,
@@ -2111,7 +2114,6 @@ static int nl80211_set_wds_peer(struct sk_buff *skb, 
struct genl_info *info)
return rdev_set_wds_peer(rdev, dev, bssid);
 }
 
-
 static int nl80211_set_wiphy(struct sk_buff *skb, struct genl_info *info)
 {
struct cfg80211_registered_device *rdev;
@@ -2244,6 +2246,7 @@ static int nl80211_set_wiphy(struct sk_buff *skb, struct 
genl_info *info)
if (info->attrs[NL80211_ATTR_WIPHY_ANTENNA_TX] &&
info->attrs[NL80211_ATTR_WIPHY_ANTENNA_RX]) {
u32 tx_ant, rx_ant;
+
if ((!rdev->wiphy.available_antennas_tx &&
 !rdev->wiphy.available_antennas_rx) ||
!rdev->ops->set_antenna)
@@ -2910,6 +2913,7 @@ static int nl80211_get_key(struct sk_buff *skb, struct 
genl_info *info)
pairwise = !!mac_addr;
if (info->attrs[NL80211_ATTR_KEY_TYPE]) {
u32 kt = nla_get_u32(info->attrs[NL80211_ATTR_KEY_TYPE]);
+
if (kt >= NUM_NL80211_KEYTYPES)
return -EINVAL;
if (kt != NL80211_KEYTYPE_GROUP &&
@@ -3949,7 +3953,6 @@ static int nl80211_dump_station(struct sk_buff *skb,
sta_idx++;
}
 
-
  out:
cb->args[2] = sta_idx;
err = skb->len;
@@ -4742,7 +4745,6 @@ static int nl80211_dump_mpath(struct sk_buff *skb,
path_idx++;
}
 
-
  out:
cb->args[2] = path_idx;
err = skb->len;
@@ -5032,7 +5034,6 @@ static int nl80211_req_set_reg(struct sk_buff *skb, 
struct genl_info *info)
enum nl80211_user_reg_hint_type user_reg_hint_type;
u32 owner_nlportid;
 
-
/* You should only get this when cfg80211 hasn't yet initialized
 * completely when built-in to the kernel right between the time
 * window between nl80211_init() and regulatory_init(), if that is
@@ -5240,7 +5241,6 @@ do {  
\
}   \
 } while (0)
 
-
if (!info->attrs[NL80211_ATTR_MESH_CONFIG])
return -EINVAL;
if (nla_parse_nested(tb, NL80211_MESHCONF_ATTR_MAX,
@@ -5388,7 +5388,6 @@ static int nl80211_parse_mesh_setup(struct genl_info 
*info,
 IEEE80211_PATH_METRIC_VENDOR :
 IEEE80211_PATH_METRIC_AIRTIME;
 
-
if (tb[NL80211_MESH_SETUP_IE]) {
struct nlattr *ieattr =
tb[NL80211_MESH_SETUP_IE];
@@ -6009,6 +6008,7 @@ static int nl80211_trigger_scan(struct sk_buff *skb, 
struct genl_info *info)
/* all channels */
for (band = 0; band < NUM_NL80211_BANDS; band++) {
int j;
+
if (!wiphy->bands[band])
continue;
for (j = 0; j < wiphy->bands[band]->n_channels; j++) {
@@ -6412,6 +6412,7 @@ nl80211_parse_sched_scan(struct wiphy *wiphy, struct 
wireless_dev *wdev,
/* all channels */
for (band = 0; band < NUM_NL80211_BANDS; band++) {
int j;
+
if (!wiphy->bands[band])
 

[PATCH 0/3] nl80211: Fix checkpatch.pl issues

2016-05-28 Thread Kirtika Ruchandani
This patch-set attempts to fix checkpatch.pl issues found in nl80211.c. 
Each patch describes the specific warnings/checks/errors it addresses. 
This patch-set ignores 'line over 80 chars' warnings.
Please check for issues with the 'fixes' for 'alignment should match 
open parenthesis'. Some of them do not display correctly with git diff.
This patch-set removes 3 errors, 66 warnings and 46 checks. 

Kirtika Ruchandani (3):
  nl80211: Fix checkpatch warnings
  nl80211: Fix checkpatch warnings about blank lines
  nl80211:  Various checkpatch.pl fixes

 net/wireless/nl80211.c | 303 ++---
 1 file changed, 137 insertions(+), 166 deletions(-)

-- 
2.8.0.rc3.226.g39d4020



[PATCH] cfg80211: Fix checkpatch issues

2016-05-28 Thread Kirtika Ruchandani
Fix the following issues reported by checkpatch.pl -
- document spinlock_t where needed/possible
- do not use multiple blank lines
- add blank line after a declaration
- use a trailing '*/' on a separate line in block comments
- don't use empty '/*' lines
- use ether_addr_copy instead of memcpy
- fix line over 80 chars
- match alignment of function arguments to open parentheses

Signed-off-by: Kirtika Ruchandani <kirtika.ruchand...@gmail.com>
---
 net/wireless/core.c | 73 +++--
 net/wireless/core.h | 33 +---
 2 files changed, 49 insertions(+), 57 deletions(-)

diff --git a/net/wireless/core.c b/net/wireless/core.c
index d25c82b..f7b14af 100644
--- a/net/wireless/core.c
+++ b/net/wireless/core.c
@@ -102,8 +102,7 @@ static int cfg80211_dev_check_name(struct 
cfg80211_registered_device *rdev,
digits = 1;
while (wiphy_idx /= 10)
digits++;
-   /*
-* deny the name if it is phy where  is printed
+   /* deny the name if it is phy where  is printed
 * without leading zeroes. taken == strlen(newname) here
 */
if (taken == strlen(PHY_NAME) + digits)
@@ -179,7 +178,7 @@ int cfg80211_switch_netns(struct cfg80211_registered_device 
*rdev,
continue;
wdev->netdev->features &= ~NETIF_F_NETNS_LOCAL;
err = dev_change_net_namespace(wdev->netdev, net,
-   "wlan%d");
+  "wlan%d");
WARN_ON(err);
wdev->netdev->features |= NETIF_F_NETNS_LOCAL;
}
@@ -267,7 +266,8 @@ static void cfg80211_rfkill_sync_work(struct work_struct 
*work)
 {
struct cfg80211_registered_device *rdev;

-   rdev = container_of(work, struct cfg80211_registered_device, 
rfkill_sync);
+   rdev = container_of(work, struct cfg80211_registered_device,
+   rfkill_sync);
cfg80211_rfkill_set_block(rdev, rfkill_blocked(rdev->rfkill));
 }

@@ -328,7 +328,7 @@ static void cfg80211_sched_scan_stop_wk(struct work_struct 
*work)
struct cfg80211_registered_device *rdev;

rdev = container_of(work, struct cfg80211_registered_device,
-  sched_scan_stop_wk);
+   sched_scan_stop_wk);

rtnl_lock();

@@ -461,15 +461,14 @@ use_default_name:

init_waitqueue_head(>dev_wait);

-   /*
-* Initialize wiphy parameters to IEEE 802.11 MIB default values.
+   /* Initialize wiphy parameters to IEEE 802.11 MIB default values.
 * Fragmentation and RTS threshold are disabled by default with the
 * special -1 value.
 */
rdev->wiphy.retry_short = 7;
rdev->wiphy.retry_long = 4;
-   rdev->wiphy.frag_threshold = (u32) -1;
-   rdev->wiphy.rts_threshold = (u32) -1;
+   rdev->wiphy.frag_threshold = (u32)-1;
+   rdev->wiphy.rts_threshold = (u32)-1;
rdev->wiphy.coverage_class = 0;

rdev->wiphy.max_num_csa_counters = 1;
@@ -492,8 +491,7 @@ static int wiphy_verify_combinations(struct wiphy *wiphy)

c = >iface_combinations[i];

-   /*
-* Combinations with just one interface aren't real,
+   /* Combinations with just one interface aren't real,
 * however we make an exception for DFS.
 */
if (WARN_ON((c->max_interfaces < 2) && !c->radar_detect_widths))
@@ -503,8 +501,7 @@ static int wiphy_verify_combinations(struct wiphy *wiphy)
if (WARN_ON(!c->num_different_channels))
return -EINVAL;

-   /*
-* Put a sane limit on maximum number of different
+   /* Put a sane limit on maximum number of different
 * channels to simplify channel accounting code.
 */
if (WARN_ON(c->num_different_channels >
@@ -540,8 +537,7 @@ static int wiphy_verify_combinations(struct wiphy *wiphy)
return -EINVAL;

cnt += c->limits[j].max;
-   /*
-* Don't advertise an unsupported type
+   /* Don't advertise an unsupported type
 * in a combination.
 */
if (WARN_ON((wiphy->interface_modes & types) != types))
@@ -581,8 +577,7 @@ int wiphy_register(struct wiphy *wiphy)
 !rdev->ops->tdls_cancel_channel_switch)))
return -EINVAL;

-   /*
-* if a wiphy has unsupported modes for regulatory channel enforc

[PATCH] cfg80211: Fix checkpatch issues

2016-05-28 Thread Kirtika Ruchandani
Fix the following issues reported by checkpatch.pl -
- document spinlock_t where needed/possible
- do not use multiple blank lines
- add blank line after a declaration
- use a trailing '*/' on a separate line in block comments
- don't use empty '/*' lines
- use ether_addr_copy instead of memcpy
- fix line over 80 chars
- match alignment of function arguments to open parentheses

Signed-off-by: Kirtika Ruchandani <kirtika.ruchand...@gmail.com>
---
 net/wireless/core.c | 73 +++--
 net/wireless/core.h | 33 +---
 2 files changed, 49 insertions(+), 57 deletions(-)

diff --git a/net/wireless/core.c b/net/wireless/core.c
index d25c82b..f7b14af 100644
--- a/net/wireless/core.c
+++ b/net/wireless/core.c
@@ -102,8 +102,7 @@ static int cfg80211_dev_check_name(struct 
cfg80211_registered_device *rdev,
digits = 1;
while (wiphy_idx /= 10)
digits++;
-   /*
-* deny the name if it is phy where  is printed
+   /* deny the name if it is phy where  is printed
 * without leading zeroes. taken == strlen(newname) here
 */
if (taken == strlen(PHY_NAME) + digits)
@@ -179,7 +178,7 @@ int cfg80211_switch_netns(struct cfg80211_registered_device 
*rdev,
continue;
wdev->netdev->features &= ~NETIF_F_NETNS_LOCAL;
err = dev_change_net_namespace(wdev->netdev, net,
-   "wlan%d");
+  "wlan%d");
WARN_ON(err);
wdev->netdev->features |= NETIF_F_NETNS_LOCAL;
}
@@ -267,7 +266,8 @@ static void cfg80211_rfkill_sync_work(struct work_struct 
*work)
 {
struct cfg80211_registered_device *rdev;

-   rdev = container_of(work, struct cfg80211_registered_device, 
rfkill_sync);
+   rdev = container_of(work, struct cfg80211_registered_device,
+   rfkill_sync);
cfg80211_rfkill_set_block(rdev, rfkill_blocked(rdev->rfkill));
 }

@@ -328,7 +328,7 @@ static void cfg80211_sched_scan_stop_wk(struct work_struct 
*work)
struct cfg80211_registered_device *rdev;

rdev = container_of(work, struct cfg80211_registered_device,
-  sched_scan_stop_wk);
+   sched_scan_stop_wk);

rtnl_lock();

@@ -461,15 +461,14 @@ use_default_name:

init_waitqueue_head(>dev_wait);

-   /*
-* Initialize wiphy parameters to IEEE 802.11 MIB default values.
+   /* Initialize wiphy parameters to IEEE 802.11 MIB default values.
 * Fragmentation and RTS threshold are disabled by default with the
 * special -1 value.
 */
rdev->wiphy.retry_short = 7;
rdev->wiphy.retry_long = 4;
-   rdev->wiphy.frag_threshold = (u32) -1;
-   rdev->wiphy.rts_threshold = (u32) -1;
+   rdev->wiphy.frag_threshold = (u32)-1;
+   rdev->wiphy.rts_threshold = (u32)-1;
rdev->wiphy.coverage_class = 0;

rdev->wiphy.max_num_csa_counters = 1;
@@ -492,8 +491,7 @@ static int wiphy_verify_combinations(struct wiphy *wiphy)

c = >iface_combinations[i];

-   /*
-* Combinations with just one interface aren't real,
+   /* Combinations with just one interface aren't real,
 * however we make an exception for DFS.
 */
if (WARN_ON((c->max_interfaces < 2) && !c->radar_detect_widths))
@@ -503,8 +501,7 @@ static int wiphy_verify_combinations(struct wiphy *wiphy)
if (WARN_ON(!c->num_different_channels))
return -EINVAL;

-   /*
-* Put a sane limit on maximum number of different
+   /* Put a sane limit on maximum number of different
 * channels to simplify channel accounting code.
 */
if (WARN_ON(c->num_different_channels >
@@ -540,8 +537,7 @@ static int wiphy_verify_combinations(struct wiphy *wiphy)
return -EINVAL;

cnt += c->limits[j].max;
-   /*
-* Don't advertise an unsupported type
+   /* Don't advertise an unsupported type
 * in a combination.
 */
if (WARN_ON((wiphy->interface_modes & types) != types))
@@ -581,8 +577,7 @@ int wiphy_register(struct wiphy *wiphy)
 !rdev->ops->tdls_cancel_channel_switch)))
return -EINVAL;

-   /*
-* if a wiphy has unsupported modes for regulatory channel enforc