Merge tag 'mac80211-next-for-davem-2015-01-19' of git://git.kernel.org/pub/scm/linux...
[cascardo/linux.git] / net / wireless / nl80211.c
index 8998484..4fc812f 100644 (file)
@@ -1721,7 +1721,8 @@ static int nl80211_send_wiphy(struct cfg80211_registered_device *rdev,
                break;
        }
  finish:
-       return genlmsg_end(msg, hdr);
+       genlmsg_end(msg, hdr);
+       return 0;
 
  nla_put_failure:
        genlmsg_cancel(msg, hdr);
@@ -2404,7 +2405,8 @@ static int nl80211_send_iface(struct sk_buff *msg, u32 portid, u32 seq, int flag
                        goto nla_put_failure;
        }
 
-       return genlmsg_end(msg, hdr);
+       genlmsg_end(msg, hdr);
+       return 0;
 
  nla_put_failure:
        genlmsg_cancel(msg, hdr);
@@ -3578,6 +3580,7 @@ static bool nl80211_put_sta_rate(struct sk_buff *msg, struct rate_info *info,
        struct nlattr *rate;
        u32 bitrate;
        u16 bitrate_compat;
+       enum nl80211_attrs rate_flg;
 
        rate = nla_nest_start(msg, attr);
        if (!rate)
@@ -3594,12 +3597,36 @@ static bool nl80211_put_sta_rate(struct sk_buff *msg, struct rate_info *info,
            nla_put_u16(msg, NL80211_RATE_INFO_BITRATE, bitrate_compat))
                return false;
 
+       switch (info->bw) {
+       case RATE_INFO_BW_5:
+               rate_flg = NL80211_RATE_INFO_5_MHZ_WIDTH;
+               break;
+       case RATE_INFO_BW_10:
+               rate_flg = NL80211_RATE_INFO_10_MHZ_WIDTH;
+               break;
+       default:
+               WARN_ON(1);
+               /* fall through */
+       case RATE_INFO_BW_20:
+               rate_flg = 0;
+               break;
+       case RATE_INFO_BW_40:
+               rate_flg = NL80211_RATE_INFO_40_MHZ_WIDTH;
+               break;
+       case RATE_INFO_BW_80:
+               rate_flg = NL80211_RATE_INFO_80_MHZ_WIDTH;
+               break;
+       case RATE_INFO_BW_160:
+               rate_flg = NL80211_RATE_INFO_160_MHZ_WIDTH;
+               break;
+       }
+
+       if (rate_flg && nla_put_flag(msg, rate_flg))
+               return false;
+
        if (info->flags & RATE_INFO_FLAGS_MCS) {
                if (nla_put_u8(msg, NL80211_RATE_INFO_MCS, info->mcs))
                        return false;
-               if (info->flags & RATE_INFO_FLAGS_40_MHZ_WIDTH &&
-                   nla_put_flag(msg, NL80211_RATE_INFO_40_MHZ_WIDTH))
-                       return false;
                if (info->flags & RATE_INFO_FLAGS_SHORT_GI &&
                    nla_put_flag(msg, NL80211_RATE_INFO_SHORT_GI))
                        return false;
@@ -3608,15 +3635,6 @@ static bool nl80211_put_sta_rate(struct sk_buff *msg, struct rate_info *info,
                        return false;
                if (nla_put_u8(msg, NL80211_RATE_INFO_VHT_NSS, info->nss))
                        return false;
-               if (info->flags & RATE_INFO_FLAGS_40_MHZ_WIDTH &&
-                   nla_put_flag(msg, NL80211_RATE_INFO_40_MHZ_WIDTH))
-                       return false;
-               if (info->flags & RATE_INFO_FLAGS_80_MHZ_WIDTH &&
-                   nla_put_flag(msg, NL80211_RATE_INFO_80_MHZ_WIDTH))
-                       return false;
-               if (info->flags & RATE_INFO_FLAGS_160_MHZ_WIDTH &&
-                   nla_put_flag(msg, NL80211_RATE_INFO_160_MHZ_WIDTH))
-                       return false;
                if (info->flags & RATE_INFO_FLAGS_SHORT_GI &&
                    nla_put_flag(msg, NL80211_RATE_INFO_SHORT_GI))
                        return false;
@@ -3822,7 +3840,8 @@ static int nl80211_send_station(struct sk_buff *msg, u32 cmd, u32 portid,
                    sinfo->assoc_req_ies))
                goto nla_put_failure;
 
-       return genlmsg_end(msg, hdr);
+       genlmsg_end(msg, hdr);
+       return 0;
 
  nla_put_failure:
        genlmsg_cancel(msg, hdr);
@@ -4552,7 +4571,8 @@ static int nl80211_send_mpath(struct sk_buff *msg, u32 portid, u32 seq,
 
        nla_nest_end(msg, pinfoattr);
 
-       return genlmsg_end(msg, hdr);
+       genlmsg_end(msg, hdr);
+       return 0;
 
  nla_put_failure:
        genlmsg_cancel(msg, hdr);
@@ -5504,7 +5524,8 @@ static int nl80211_send_regdom(struct sk_buff *msg, struct netlink_callback *cb,
            nla_put_flag(msg, NL80211_ATTR_WIPHY_SELF_MANAGED_REG))
                goto nla_put_failure;
 
-       return genlmsg_end(msg, hdr);
+       genlmsg_end(msg, hdr);
+       return 0;
 
 nla_put_failure:
        genlmsg_cancel(msg, hdr);
@@ -6574,7 +6595,8 @@ static int nl80211_send_bss(struct sk_buff *msg, struct netlink_callback *cb,
 
        nla_nest_end(msg, bss);
 
-       return genlmsg_end(msg, hdr);
+       genlmsg_end(msg, hdr);
+       return 0;
 
  fail_unlock_rcu:
        rcu_read_unlock();
@@ -6683,7 +6705,8 @@ static int nl80211_send_survey(struct sk_buff *msg, u32 portid, u32 seq,
 
        nla_nest_end(msg, infoattr);
 
-       return genlmsg_end(msg, hdr);
+       genlmsg_end(msg, hdr);
+       return 0;
 
  nla_put_failure:
        genlmsg_cancel(msg, hdr);
@@ -11022,7 +11045,8 @@ static int nl80211_send_scan_msg(struct sk_buff *msg,
        /* ignore errors and send incomplete event anyway */
        nl80211_add_scan_req(msg, rdev);
 
-       return genlmsg_end(msg, hdr);
+       genlmsg_end(msg, hdr);
+       return 0;
 
  nla_put_failure:
        genlmsg_cancel(msg, hdr);
@@ -11045,7 +11069,8 @@ nl80211_send_sched_scan_msg(struct sk_buff *msg,
            nla_put_u32(msg, NL80211_ATTR_IFINDEX, netdev->ifindex))
                goto nla_put_failure;
 
-       return genlmsg_end(msg, hdr);
+       genlmsg_end(msg, hdr);
+       return 0;
 
  nla_put_failure:
        genlmsg_cancel(msg, hdr);
@@ -11772,7 +11797,7 @@ void cfg80211_del_sta_sinfo(struct net_device *dev, const u8 *mac_addr,
                return;
 
        if (nl80211_send_station(msg, NL80211_CMD_DEL_STATION, 0, 0, 0,
-                                rdev, dev, mac_addr, sinfo)) {
+                                rdev, dev, mac_addr, sinfo) < 0) {
                nlmsg_free(msg);
                return;
        }