Merge branch 'master' of git://git.kernel.org/pub/scm/linux/kernel/git/linville/wirel...
authorJohn W. Linville <linville@tuxdriver.com>
Wed, 18 Apr 2012 18:17:13 +0000 (14:17 -0400)
committerJohn W. Linville <linville@tuxdriver.com>
Wed, 18 Apr 2012 18:27:48 +0000 (14:27 -0400)
Conflicts:
drivers/net/wireless/iwlwifi/iwl-testmode.c
include/net/nfc/nfc.h
net/nfc/netlink.c
net/wireless/nl80211.c

1  2 
MAINTAINERS
drivers/net/wireless/ipw2x00/ipw2100.c
drivers/net/wireless/ipw2x00/ipw2200.c
drivers/net/wireless/iwlwifi/iwl-testmode.c
drivers/net/wireless/mac80211_hwsim.c
drivers/net/wireless/ti/wlcore/testmode.c
include/net/nfc/nfc.h
net/nfc/core.c
net/nfc/netlink.c
net/nfc/nfc.h
net/wireless/nl80211.c

diff --cc MAINTAINERS
Simple merge
index f31a0629c6c672bf2c3c8f5502d2ec18d7299e4a,c8e89cac7ea32a06e574cc118418accef16dbf0f..bb275098bb108869085b414dccf9b06e9dc96b49
@@@ -543,12 -539,11 +543,12 @@@ static int iwl_testmode_driver(struct i
                                IWL_ERR(priv, "Memory allocation fail\n");
                                return -ENOMEM;
                        }
 -                      NLA_PUT_U32(skb, IWL_TM_ATTR_COMMAND,
 -                              IWL_TM_CMD_DEV2APP_EEPROM_RSP);
 -                      NLA_PUT(skb, IWL_TM_ATTR_EEPROM,
 -                              cfg(priv)->base_params->eeprom_size,
 -                              priv->eeprom);
 +                      if (nla_put_u32(skb, IWL_TM_ATTR_COMMAND,
 +                                      IWL_TM_CMD_DEV2APP_EEPROM_RSP) ||
 +                          nla_put(skb, IWL_TM_ATTR_EEPROM,
 +                                  cfg(priv)->base_params->eeprom_size,
-                                   priv->shrd->eeprom))
++                                  priv->eeprom))
 +                              goto nla_put_failure;
                        status = cfg80211_testmode_reply(skb);
                        if (status < 0)
                                IWL_ERR(priv, "Error sending msg : %d\n",
Simple merge
index 0000000000000000000000000000000000000000,9cda706e4e3f83bf107e1889b2a12873aa4000ac..0e59ea2cdd39ea59376347ec03103167f4bf7349
mode 000000,100644..100644
--- /dev/null
@@@ -1,0 -1,343 +1,346 @@@
 -              NLA_PUT(skb, WL1271_TM_ATTR_DATA, buf_len, buf);
+ /*
+  * This file is part of wl1271
+  *
+  * Copyright (C) 2010 Nokia Corporation
+  *
+  * Contact: Luciano Coelho <luciano.coelho@nokia.com>
+  *
+  * This program is free software; you can redistribute it and/or
+  * modify it under the terms of the GNU General Public License
+  * version 2 as published by the Free Software Foundation.
+  *
+  * This program is distributed in the hope that it will be useful, but
+  * WITHOUT ANY WARRANTY; without even the implied warranty of
+  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+  * General Public License for more details.
+  *
+  * You should have received a copy of the GNU General Public License
+  * along with this program; if not, write to the Free Software
+  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+  * 02110-1301 USA
+  *
+  */
+ #include "testmode.h"
+ #include <linux/slab.h>
+ #include <net/genetlink.h>
+ #include "wlcore.h"
+ #include "debug.h"
+ #include "acx.h"
+ #include "ps.h"
+ #include "io.h"
+ #define WL1271_TM_MAX_DATA_LENGTH 1024
+ enum wl1271_tm_commands {
+       WL1271_TM_CMD_UNSPEC,
+       WL1271_TM_CMD_TEST,
+       WL1271_TM_CMD_INTERROGATE,
+       WL1271_TM_CMD_CONFIGURE,
+       WL1271_TM_CMD_NVS_PUSH,         /* Not in use. Keep to not break ABI */
+       WL1271_TM_CMD_SET_PLT_MODE,
+       WL1271_TM_CMD_RECOVER,
+       WL1271_TM_CMD_GET_MAC,
+       __WL1271_TM_CMD_AFTER_LAST
+ };
+ #define WL1271_TM_CMD_MAX (__WL1271_TM_CMD_AFTER_LAST - 1)
+ enum wl1271_tm_attrs {
+       WL1271_TM_ATTR_UNSPEC,
+       WL1271_TM_ATTR_CMD_ID,
+       WL1271_TM_ATTR_ANSWER,
+       WL1271_TM_ATTR_DATA,
+       WL1271_TM_ATTR_IE_ID,
+       WL1271_TM_ATTR_PLT_MODE,
+       __WL1271_TM_ATTR_AFTER_LAST
+ };
+ #define WL1271_TM_ATTR_MAX (__WL1271_TM_ATTR_AFTER_LAST - 1)
+ static struct nla_policy wl1271_tm_policy[WL1271_TM_ATTR_MAX + 1] = {
+       [WL1271_TM_ATTR_CMD_ID] =       { .type = NLA_U32 },
+       [WL1271_TM_ATTR_ANSWER] =       { .type = NLA_U8 },
+       [WL1271_TM_ATTR_DATA] =         { .type = NLA_BINARY,
+                                         .len = WL1271_TM_MAX_DATA_LENGTH },
+       [WL1271_TM_ATTR_IE_ID] =        { .type = NLA_U32 },
+       [WL1271_TM_ATTR_PLT_MODE] =     { .type = NLA_U32 },
+ };
+ static int wl1271_tm_cmd_test(struct wl1271 *wl, struct nlattr *tb[])
+ {
+       int buf_len, ret, len;
+       struct sk_buff *skb;
+       void *buf;
+       u8 answer = 0;
+       wl1271_debug(DEBUG_TESTMODE, "testmode cmd test");
+       if (!tb[WL1271_TM_ATTR_DATA])
+               return -EINVAL;
+       buf = nla_data(tb[WL1271_TM_ATTR_DATA]);
+       buf_len = nla_len(tb[WL1271_TM_ATTR_DATA]);
+       if (tb[WL1271_TM_ATTR_ANSWER])
+               answer = nla_get_u8(tb[WL1271_TM_ATTR_ANSWER]);
+       if (buf_len > sizeof(struct wl1271_command))
+               return -EMSGSIZE;
+       mutex_lock(&wl->mutex);
+       if (wl->state == WL1271_STATE_OFF) {
+               ret = -EINVAL;
+               goto out;
+       }
+       ret = wl1271_ps_elp_wakeup(wl);
+       if (ret < 0)
+               goto out;
+       ret = wl1271_cmd_test(wl, buf, buf_len, answer);
+       if (ret < 0) {
+               wl1271_warning("testmode cmd test failed: %d", ret);
+               goto out_sleep;
+       }
+       if (answer) {
+               len = nla_total_size(buf_len);
+               skb = cfg80211_testmode_alloc_reply_skb(wl->hw->wiphy, len);
+               if (!skb) {
+                       ret = -ENOMEM;
+                       goto out_sleep;
+               }
 -      NLA_PUT(skb, WL1271_TM_ATTR_DATA, sizeof(*cmd), cmd);
++              if (nla_put(skb, WL1271_TM_ATTR_DATA, buf_len, buf))
++                      goto nla_put_failure;
+               ret = cfg80211_testmode_reply(skb);
+               if (ret < 0)
+                       goto out_sleep;
+       }
+ out_sleep:
+       wl1271_ps_elp_sleep(wl);
+ out:
+       mutex_unlock(&wl->mutex);
+       return ret;
+ nla_put_failure:
+       kfree_skb(skb);
+       ret = -EMSGSIZE;
+       goto out_sleep;
+ }
+ static int wl1271_tm_cmd_interrogate(struct wl1271 *wl, struct nlattr *tb[])
+ {
+       int ret;
+       struct wl1271_command *cmd;
+       struct sk_buff *skb;
+       u8 ie_id;
+       wl1271_debug(DEBUG_TESTMODE, "testmode cmd interrogate");
+       if (!tb[WL1271_TM_ATTR_IE_ID])
+               return -EINVAL;
+       ie_id = nla_get_u8(tb[WL1271_TM_ATTR_IE_ID]);
+       mutex_lock(&wl->mutex);
+       if (wl->state == WL1271_STATE_OFF) {
+               ret = -EINVAL;
+               goto out;
+       }
+       ret = wl1271_ps_elp_wakeup(wl);
+       if (ret < 0)
+               goto out;
+       cmd = kzalloc(sizeof(*cmd), GFP_KERNEL);
+       if (!cmd) {
+               ret = -ENOMEM;
+               goto out_sleep;
+       }
+       ret = wl1271_cmd_interrogate(wl, ie_id, cmd, sizeof(*cmd));
+       if (ret < 0) {
+               wl1271_warning("testmode cmd interrogate failed: %d", ret);
+               goto out_free;
+       }
+       skb = cfg80211_testmode_alloc_reply_skb(wl->hw->wiphy, sizeof(*cmd));
+       if (!skb) {
+               ret = -ENOMEM;
+               goto out_free;
+       }
 -      NLA_PUT(skb, WL1271_TM_ATTR_DATA, ETH_ALEN, mac_addr);
++      if (nla_put(skb, WL1271_TM_ATTR_DATA, sizeof(*cmd), cmd))
++              goto nla_put_failure;
+       ret = cfg80211_testmode_reply(skb);
+       if (ret < 0)
+               goto out_free;
+ out_free:
+       kfree(cmd);
+ out_sleep:
+       wl1271_ps_elp_sleep(wl);
+ out:
+       mutex_unlock(&wl->mutex);
+       return ret;
+ nla_put_failure:
+       kfree_skb(skb);
+       ret = -EMSGSIZE;
+       goto out_free;
+ }
+ static int wl1271_tm_cmd_configure(struct wl1271 *wl, struct nlattr *tb[])
+ {
+       int buf_len, ret;
+       void *buf;
+       u8 ie_id;
+       wl1271_debug(DEBUG_TESTMODE, "testmode cmd configure");
+       if (!tb[WL1271_TM_ATTR_DATA])
+               return -EINVAL;
+       if (!tb[WL1271_TM_ATTR_IE_ID])
+               return -EINVAL;
+       ie_id = nla_get_u8(tb[WL1271_TM_ATTR_IE_ID]);
+       buf = nla_data(tb[WL1271_TM_ATTR_DATA]);
+       buf_len = nla_len(tb[WL1271_TM_ATTR_DATA]);
+       if (buf_len > sizeof(struct wl1271_command))
+               return -EMSGSIZE;
+       mutex_lock(&wl->mutex);
+       ret = wl1271_cmd_configure(wl, ie_id, buf, buf_len);
+       mutex_unlock(&wl->mutex);
+       if (ret < 0) {
+               wl1271_warning("testmode cmd configure failed: %d", ret);
+               return ret;
+       }
+       return 0;
+ }
+ static int wl1271_tm_cmd_set_plt_mode(struct wl1271 *wl, struct nlattr *tb[])
+ {
+       u32 val;
+       int ret;
+       wl1271_debug(DEBUG_TESTMODE, "testmode cmd set plt mode");
+       if (!tb[WL1271_TM_ATTR_PLT_MODE])
+               return -EINVAL;
+       val = nla_get_u32(tb[WL1271_TM_ATTR_PLT_MODE]);
+       switch (val) {
+       case 0:
+               ret = wl1271_plt_stop(wl);
+               break;
+       case 1:
+               ret = wl1271_plt_start(wl);
+               break;
+       default:
+               ret = -EINVAL;
+               break;
+       }
+       return ret;
+ }
+ static int wl1271_tm_cmd_recover(struct wl1271 *wl, struct nlattr *tb[])
+ {
+       wl1271_debug(DEBUG_TESTMODE, "testmode cmd recover");
+       wl12xx_queue_recovery_work(wl);
+       return 0;
+ }
+ static int wl12xx_tm_cmd_get_mac(struct wl1271 *wl, struct nlattr *tb[])
+ {
+       struct sk_buff *skb;
+       u8 mac_addr[ETH_ALEN];
+       int ret = 0;
+       mutex_lock(&wl->mutex);
+       if (!wl->plt) {
+               ret = -EINVAL;
+               goto out;
+       }
+       if (wl->fuse_oui_addr == 0 && wl->fuse_nic_addr == 0) {
+               ret = -EOPNOTSUPP;
+               goto out;
+       }
+       mac_addr[0] = (u8)(wl->fuse_oui_addr >> 16);
+       mac_addr[1] = (u8)(wl->fuse_oui_addr >> 8);
+       mac_addr[2] = (u8) wl->fuse_oui_addr;
+       mac_addr[3] = (u8)(wl->fuse_nic_addr >> 16);
+       mac_addr[4] = (u8)(wl->fuse_nic_addr >> 8);
+       mac_addr[5] = (u8) wl->fuse_nic_addr;
+       skb = cfg80211_testmode_alloc_reply_skb(wl->hw->wiphy, ETH_ALEN);
+       if (!skb) {
+               ret = -ENOMEM;
+               goto out;
+       }
++      if (nla_put(skb, WL1271_TM_ATTR_DATA, ETH_ALEN, mac_addr))
++              goto nla_put_failure;
+       ret = cfg80211_testmode_reply(skb);
+       if (ret < 0)
+               goto out;
+ out:
+       mutex_unlock(&wl->mutex);
+       return ret;
+ nla_put_failure:
+       kfree_skb(skb);
+       ret = -EMSGSIZE;
+       goto out;
+ }
+ int wl1271_tm_cmd(struct ieee80211_hw *hw, void *data, int len)
+ {
+       struct wl1271 *wl = hw->priv;
+       struct nlattr *tb[WL1271_TM_ATTR_MAX + 1];
+       int err;
+       err = nla_parse(tb, WL1271_TM_ATTR_MAX, data, len, wl1271_tm_policy);
+       if (err)
+               return err;
+       if (!tb[WL1271_TM_ATTR_CMD_ID])
+               return -EINVAL;
+       switch (nla_get_u32(tb[WL1271_TM_ATTR_CMD_ID])) {
+       case WL1271_TM_CMD_TEST:
+               return wl1271_tm_cmd_test(wl, tb);
+       case WL1271_TM_CMD_INTERROGATE:
+               return wl1271_tm_cmd_interrogate(wl, tb);
+       case WL1271_TM_CMD_CONFIGURE:
+               return wl1271_tm_cmd_configure(wl, tb);
+       case WL1271_TM_CMD_SET_PLT_MODE:
+               return wl1271_tm_cmd_set_plt_mode(wl, tb);
+       case WL1271_TM_CMD_RECOVER:
+               return wl1271_tm_cmd_recover(wl, tb);
+       case WL1271_TM_CMD_GET_MAC:
+               return wl12xx_tm_cmd_get_mac(wl, tb);
+       default:
+               return -EOPNOTSUPP;
+       }
+ }
index 79955a238ccc14f87ae6ce56e873e3e6b86fa1a5,313d00fac2762dbc9ca9815760d26c9842dd3da6..9a2505a5b8de7687aa266f6f631b0b4a7396021e
@@@ -86,7 -90,8 +90,8 @@@ struct nfc_genl_data 
  };
  
  struct nfc_dev {
 -      unsigned idx;
 +      unsigned int idx;
+       u32 target_next_idx;
        struct nfc_target *targets;
        int n_targets;
        int targets_generation;
diff --cc net/nfc/core.c
Simple merge
index 8937664674fae623f4ec8e27fad62e5d2e8c9ec4,ebdb605f8dbd16f40e8028309340d46d18e75bee..f1829f6ae9c552fab7b2090fddb2283511b7f4d5
@@@ -188,6 -183,36 +188,37 @@@ free_msg
        return -EMSGSIZE;
  }
  
 -      NLA_PUT_STRING(msg, NFC_ATTR_DEVICE_NAME, nfc_device_name(dev));
 -      NLA_PUT_U32(msg, NFC_ATTR_TARGET_INDEX, target_idx);
+ int nfc_genl_target_lost(struct nfc_dev *dev, u32 target_idx)
+ {
+       struct sk_buff *msg;
+       void *hdr;
+       msg = nlmsg_new(NLMSG_GOODSIZE, GFP_KERNEL);
+       if (!msg)
+               return -ENOMEM;
+       hdr = genlmsg_put(msg, 0, 0, &nfc_genl_family, 0,
+                         NFC_EVENT_TARGET_LOST);
+       if (!hdr)
+               goto free_msg;
++      if (nla_put_string(msg, NFC_ATTR_DEVICE_NAME, nfc_device_name(dev)) ||
++          nla_put_u32(msg, NFC_ATTR_TARGET_INDEX, target_idx))
++              goto nla_put_failure;
+       genlmsg_end(msg, hdr);
+       genlmsg_multicast(msg, 0, nfc_genl_event_mcgrp.id, GFP_KERNEL);
+       return 0;
+ nla_put_failure:
+       genlmsg_cancel(msg, hdr);
+ free_msg:
+       nlmsg_free(msg);
+       return -EMSGSIZE;
+ }
  int nfc_genl_device_added(struct nfc_dev *dev)
  {
        struct sk_buff *msg;
diff --cc net/nfc/nfc.h
Simple merge
index ff1a6c7fbe3392d17860d866399606449b9270d4,bcf6f70e518db6654349fcaf852fb33720c76179..83d71d6b63a45570dbdceea6a4fdb82c70c93d21
@@@ -1530,16 -1492,28 +1530,29 @@@ static int nl80211_send_iface(struct sk
        if (!hdr)
                return -1;
  
 -      NLA_PUT_U32(msg, NL80211_ATTR_IFINDEX, dev->ifindex);
 -      NLA_PUT_U32(msg, NL80211_ATTR_WIPHY, rdev->wiphy_idx);
 -      NLA_PUT_STRING(msg, NL80211_ATTR_IFNAME, dev->name);
 -      NLA_PUT_U32(msg, NL80211_ATTR_IFTYPE, dev->ieee80211_ptr->iftype);
 -
 -      NLA_PUT_U32(msg, NL80211_ATTR_GENERATION,
 -                  rdev->devlist_generation ^
 -                      (cfg80211_rdev_list_generation << 2));
 +      if (nla_put_u32(msg, NL80211_ATTR_IFINDEX, dev->ifindex) ||
 +          nla_put_u32(msg, NL80211_ATTR_WIPHY, rdev->wiphy_idx) ||
 +          nla_put_string(msg, NL80211_ATTR_IFNAME, dev->name) ||
 +          nla_put_u32(msg, NL80211_ATTR_IFTYPE,
 +                      dev->ieee80211_ptr->iftype) ||
 +          nla_put_u32(msg, NL80211_ATTR_GENERATION,
 +                      rdev->devlist_generation ^
 +                      (cfg80211_rdev_list_generation << 2)))
 +              goto nla_put_failure;
  
 -              if (chan) {
 -                      NLA_PUT_U32(msg, NL80211_ATTR_WIPHY_FREQ,
 -                                  chan->center_freq);
 -                      NLA_PUT_U32(msg, NL80211_ATTR_WIPHY_CHANNEL_TYPE,
 -                                  channel_type);
 -              }
+       if (rdev->ops->get_channel) {
+               struct ieee80211_channel *chan;
+               enum nl80211_channel_type channel_type;
+               chan = rdev->ops->get_channel(&rdev->wiphy, &channel_type);
++              if (chan &&
++                  (nla_put_u32(msg, NL80211_ATTR_WIPHY_FREQ,
++                                  chan->center_freq) ||
++                   nla_put_u32(msg, NL80211_ATTR_WIPHY_CHANNEL_TYPE,
++                                  channel_type)))
++                      goto nla_put_failure;
+       }
        return genlmsg_end(msg, hdr);
  
   nla_put_failure: