nl80211: use nla_put_u64_64bit() for the remaining u64 attributes
authorJohannes Berg <johannes.berg@intel.com>
Tue, 26 Apr 2016 07:54:11 +0000 (09:54 +0200)
committerJohannes Berg <johannes.berg@intel.com>
Wed, 27 Apr 2016 09:01:13 +0000 (11:01 +0200)
Nicolas converted most users, but didn't realize some were generated
by macros. Convert those over as well.

Signed-off-by: Johannes Berg <johannes.berg@intel.com>
Acked-by: Nicolas Dichtel <nicolas.dichtel@6wind.com>
Signed-off-by: Johannes Berg <johannes.berg@intel.com>
include/uapi/linux/nl80211.h
net/wireless/nl80211.c

index f958a7173eb419875b8833e9fdd0f9db066be6fc..e23d78685a015973be72999be6a91c7f71eeb2af 100644 (file)
@@ -2517,6 +2517,7 @@ enum nl80211_sta_bss_param {
  *     attributes carrying the actual values.
  * @NL80211_STA_INFO_RX_DURATION: aggregate PPDU duration for all frames
  *     received from the station (u64, usec)
+ * @NL80211_STA_INFO_PAD: attribute used for padding for 64-bit alignment
  * @__NL80211_STA_INFO_AFTER_LAST: internal
  * @NL80211_STA_INFO_MAX: highest possible station info attribute
  */
@@ -2554,6 +2555,7 @@ enum nl80211_sta_info {
        NL80211_STA_INFO_BEACON_SIGNAL_AVG,
        NL80211_STA_INFO_TID_STATS,
        NL80211_STA_INFO_RX_DURATION,
+       NL80211_STA_INFO_PAD,
 
        /* keep last */
        __NL80211_STA_INFO_AFTER_LAST,
@@ -2570,6 +2572,7 @@ enum nl80211_sta_info {
  *     transmitted MSDUs (not counting the first attempt; u64)
  * @NL80211_TID_STATS_TX_MSDU_FAILED: number of failed transmitted
  *     MSDUs (u64)
+ * @NL80211_TID_STATS_PAD: attribute used for padding for 64-bit alignment
  * @NUM_NL80211_TID_STATS: number of attributes here
  * @NL80211_TID_STATS_MAX: highest numbered attribute here
  */
@@ -2579,6 +2582,7 @@ enum nl80211_tid_stats {
        NL80211_TID_STATS_TX_MSDU,
        NL80211_TID_STATS_TX_MSDU_RETRIES,
        NL80211_TID_STATS_TX_MSDU_FAILED,
+       NL80211_TID_STATS_PAD,
 
        /* keep last */
        NUM_NL80211_TID_STATS,
index 5b0d2c8c2165d439ac0cb8bc05aa0a533f0f1c66..9bc84a2ddd340c85c355a76d61d35e908f45f25e 100644 (file)
@@ -3755,11 +3755,18 @@ static int nl80211_send_station(struct sk_buff *msg, u32 cmd, u32 portid,
                goto nla_put_failure;
 
 #define PUT_SINFO(attr, memb, type) do {                               \
+       BUILD_BUG_ON(sizeof(type) == sizeof(u64));                      \
        if (sinfo->filled & (1ULL << NL80211_STA_INFO_ ## attr) &&      \
            nla_put_ ## type(msg, NL80211_STA_INFO_ ## attr,            \
                             sinfo->memb))                              \
                goto nla_put_failure;                                   \
        } while (0)
+#define PUT_SINFO_U64(attr, memb) do {                                 \
+       if (sinfo->filled & (1ULL << NL80211_STA_INFO_ ## attr) &&      \
+           nla_put_u64_64bit(msg, NL80211_STA_INFO_ ## attr,           \
+                             sinfo->memb, NL80211_STA_INFO_PAD))       \
+               goto nla_put_failure;                                   \
+       } while (0)
 
        PUT_SINFO(CONNECTED_TIME, connected_time, u32);
        PUT_SINFO(INACTIVE_TIME, inactive_time, u32);
@@ -3776,12 +3783,12 @@ static int nl80211_send_station(struct sk_buff *msg, u32 cmd, u32 portid,
                        (u32)sinfo->tx_bytes))
                goto nla_put_failure;
 
-       PUT_SINFO(RX_BYTES64, rx_bytes, u64);
-       PUT_SINFO(TX_BYTES64, tx_bytes, u64);
+       PUT_SINFO_U64(RX_BYTES64, rx_bytes);
+       PUT_SINFO_U64(TX_BYTES64, tx_bytes);
        PUT_SINFO(LLID, llid, u16);
        PUT_SINFO(PLID, plid, u16);
        PUT_SINFO(PLINK_STATE, plink_state, u8);
-       PUT_SINFO(RX_DURATION, rx_duration, u64);
+       PUT_SINFO_U64(RX_DURATION, rx_duration);
 
        switch (rdev->wiphy.signal_type) {
        case CFG80211_SIGNAL_TYPE_MBM:
@@ -3849,12 +3856,13 @@ static int nl80211_send_station(struct sk_buff *msg, u32 cmd, u32 portid,
                    &sinfo->sta_flags))
                goto nla_put_failure;
 
-       PUT_SINFO(T_OFFSET, t_offset, u64);
-       PUT_SINFO(RX_DROP_MISC, rx_dropped_misc, u64);
-       PUT_SINFO(BEACON_RX, rx_beacon, u64);
+       PUT_SINFO_U64(T_OFFSET, t_offset);
+       PUT_SINFO_U64(RX_DROP_MISC, rx_dropped_misc);
+       PUT_SINFO_U64(BEACON_RX, rx_beacon);
        PUT_SINFO(BEACON_SIGNAL_AVG, rx_beacon_signal_avg, u8);
 
 #undef PUT_SINFO
+#undef PUT_SINFO_U64
 
        if (sinfo->filled & BIT(NL80211_STA_INFO_TID_STATS)) {
                struct nlattr *tidsattr;
@@ -3877,19 +3885,19 @@ static int nl80211_send_station(struct sk_buff *msg, u32 cmd, u32 portid,
                        if (!tidattr)
                                goto nla_put_failure;
 
-#define PUT_TIDVAL(attr, memb, type) do {                              \
+#define PUT_TIDVAL_U64(attr, memb) do {                                        \
        if (tidstats->filled & BIT(NL80211_TID_STATS_ ## attr) &&       \
-           nla_put_ ## type(msg, NL80211_TID_STATS_ ## attr,           \
-                            tidstats->memb))                           \
+           nla_put_u64_64bit(msg, NL80211_TID_STATS_ ## attr,          \
+                             tidstats->memb, NL80211_TID_STATS_PAD))   \
                goto nla_put_failure;                                   \
        } while (0)
 
-                       PUT_TIDVAL(RX_MSDU, rx_msdu, u64);
-                       PUT_TIDVAL(TX_MSDU, tx_msdu, u64);
-                       PUT_TIDVAL(TX_MSDU_RETRIES, tx_msdu_retries, u64);
-                       PUT_TIDVAL(TX_MSDU_FAILED, tx_msdu_failed, u64);
+                       PUT_TIDVAL_U64(RX_MSDU, rx_msdu);
+                       PUT_TIDVAL_U64(TX_MSDU, tx_msdu);
+                       PUT_TIDVAL_U64(TX_MSDU_RETRIES, tx_msdu_retries);
+                       PUT_TIDVAL_U64(TX_MSDU_FAILED, tx_msdu_failed);
 
-#undef PUT_TIDVAL
+#undef PUT_TIDVAL_U64
                        nla_nest_end(msg, tidattr);
                }