return -ENOENT;
        }
 
-       err = mesh_path_add(dst, sdata);
+       err = mesh_path_add(sdata, dst);
        if (err) {
                rcu_read_unlock();
                return err;
        }
 
-       mpath = mesh_path_lookup(dst, sdata);
+       mpath = mesh_path_lookup(sdata, dst);
        if (!mpath) {
                rcu_read_unlock();
                return -ENXIO;
 }
 
 static int ieee80211_del_mpath(struct wiphy *wiphy, struct net_device *dev,
-                                u8 *dst)
+                              u8 *dst)
 {
        struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev);
 
        if (dst)
-               return mesh_path_del(dst, sdata);
+               return mesh_path_del(sdata, dst);
 
        mesh_path_flush_by_iface(sdata);
        return 0;
                return -ENOENT;
        }
 
-       mpath = mesh_path_lookup(dst, sdata);
+       mpath = mesh_path_lookup(sdata, dst);
        if (!mpath) {
                rcu_read_unlock();
                return -ENOENT;
        sdata = IEEE80211_DEV_TO_SUB_IF(dev);
 
        rcu_read_lock();
-       mpath = mesh_path_lookup(dst, sdata);
+       mpath = mesh_path_lookup(sdata, dst);
        if (!mpath) {
                rcu_read_unlock();
                return -ENOENT;
        sdata = IEEE80211_DEV_TO_SUB_IF(dev);
 
        rcu_read_lock();
-       mpath = mesh_path_lookup_by_idx(idx, sdata);
+       mpath = mesh_path_lookup_by_idx(sdata, idx);
        if (!mpath) {
                rcu_read_unlock();
                return -ENOENT;
 
        rc80211_minstrel_ht_exit();
        rc80211_minstrel_exit();
 
-       if (mesh_allocated)
-               ieee80211s_stop();
+       ieee80211s_stop();
 
        ieee80211_iface_exit();
 
 
 #define TMR_RUNNING_MP 1
 #define TMR_RUNNING_MPR        2
 
-int mesh_allocated;
+static int mesh_allocated;
 static struct kmem_cache *rm_cache;
 
 bool mesh_action_is_path_sel(struct ieee80211_mgmt *mgmt)
 
 void ieee80211s_stop(void)
 {
+       if (!mesh_allocated)
+               return;
        mesh_pathtbl_unregister();
        kmem_cache_destroy(rm_cache);
 }
             (ifmsh->mesh_cc_id == ie->mesh_config->meshconf_congest) &&
             (ifmsh->mesh_sp_id == ie->mesh_config->meshconf_synch) &&
             (ifmsh->mesh_auth_id == ie->mesh_config->meshconf_auth)))
-               goto mismatch;
+               return false;
 
        ieee80211_sta_get_rates(local, ie, ieee80211_get_sdata_band(sdata),
                                &basic_rates);
 
        if (sdata->vif.bss_conf.basic_rates != basic_rates)
-               goto mismatch;
+               return false;
 
        ieee80211_ht_oper_to_chandef(sdata->vif.bss_conf.chandef.chan,
                                     ie->ht_operation, &sta_chan_def);
 
        if (!cfg80211_chandef_compatible(&sdata->vif.bss_conf.chandef,
                                         &sta_chan_def))
-               goto mismatch;
+               return false;
 
        return true;
-mismatch:
-       return false;
 }
 
 /**
 bool mesh_peer_accepts_plinks(struct ieee802_11_elems *ie)
 {
        return (ie->mesh_config->meshconf_cap &
-           IEEE80211_MESHCONF_CAPAB_ACCEPT_PLINKS) != 0;
+                       IEEE80211_MESHCONF_CAPAB_ACCEPT_PLINKS) != 0;
 }
 
 /**
        if (!sdata->u.mesh.rmc)
                return;
 
-       for (i = 0; i < RMC_BUCKETS; i++)
+       for (i = 0; i < RMC_BUCKETS; i++) {
                list_for_each_entry_safe(p, n, &rmc->bucket[i], list) {
                        list_del(&p->list);
                        kmem_cache_free(rm_cache, p);
                }
+       }
 
        kfree(rmc);
        sdata->u.mesh.rmc = NULL;
 /**
  * mesh_rmc_check - Check frame in recent multicast cache and add if absent.
  *
+ * @sdata:     interface
  * @sa:                source address
  * @mesh_hdr:  mesh_header
  *
  * received this frame lately. If the frame is not in the cache, it is added to
  * it.
  */
-int mesh_rmc_check(u8 *sa, struct ieee80211s_hdr *mesh_hdr,
-                  struct ieee80211_sub_if_data *sdata)
+int mesh_rmc_check(struct ieee80211_sub_if_data *sdata,
+                  const u8 *sa, struct ieee80211s_hdr *mesh_hdr)
 {
        struct mesh_rmc *rmc = sdata->u.mesh.rmc;
        u32 seqnum = 0;
        list_for_each_entry_safe(p, n, &rmc->bucket[idx], list) {
                ++entries;
                if (time_after(jiffies, p->exp_time) ||
-                               (entries == RMC_QUEUE_MAX_LEN)) {
+                   entries == RMC_QUEUE_MAX_LEN) {
                        list_del(&p->list);
                        kmem_cache_free(rm_cache, p);
                        --entries;
-               } else if ((seqnum == p->seqnum) &&
-                          (ether_addr_equal(sa, p->sa)))
+               } else if ((seqnum == p->seqnum) && ether_addr_equal(sa, p->sa))
                        return -1;
        }
 
        return 0;
 }
 
-int
-mesh_add_meshconf_ie(struct sk_buff *skb, struct ieee80211_sub_if_data *sdata)
+int mesh_add_meshconf_ie(struct ieee80211_sub_if_data *sdata,
+                        struct sk_buff *skb)
 {
        struct ieee80211_if_mesh *ifmsh = &sdata->u.mesh;
        u8 *pos, neighbors;
        /* Mesh capability */
        *pos = IEEE80211_MESHCONF_CAPAB_FORWARDING;
        *pos |= ifmsh->accepting_plinks ?
-           IEEE80211_MESHCONF_CAPAB_ACCEPT_PLINKS : 0x00;
+                       IEEE80211_MESHCONF_CAPAB_ACCEPT_PLINKS : 0x00;
        /* Mesh PS mode. See IEEE802.11-2012 8.4.2.100.8 */
        *pos |= ifmsh->ps_peers_deep_sleep ?
-           IEEE80211_MESHCONF_CAPAB_POWER_SAVE_LEVEL : 0x00;
+                       IEEE80211_MESHCONF_CAPAB_POWER_SAVE_LEVEL : 0x00;
        *pos++ |= ifmsh->adjusting_tbtt ?
-           IEEE80211_MESHCONF_CAPAB_TBTT_ADJUSTING : 0x00;
+                       IEEE80211_MESHCONF_CAPAB_TBTT_ADJUSTING : 0x00;
        *pos++ = 0x00;
 
        return 0;
 }
 
-int
-mesh_add_meshid_ie(struct sk_buff *skb, struct ieee80211_sub_if_data *sdata)
+int mesh_add_meshid_ie(struct ieee80211_sub_if_data *sdata, struct sk_buff *skb)
 {
        struct ieee80211_if_mesh *ifmsh = &sdata->u.mesh;
        u8 *pos;
        return 0;
 }
 
-int mesh_add_awake_window_ie(struct sk_buff *skb,
-                            struct ieee80211_sub_if_data *sdata)
+static int mesh_add_awake_window_ie(struct ieee80211_sub_if_data *sdata,
+                                   struct sk_buff *skb)
 {
        struct ieee80211_if_mesh *ifmsh = &sdata->u.mesh;
        u8 *pos;
        return 0;
 }
 
-int
-mesh_add_vendor_ies(struct sk_buff *skb, struct ieee80211_sub_if_data *sdata)
+int mesh_add_vendor_ies(struct ieee80211_sub_if_data *sdata,
+                       struct sk_buff *skb)
 {
        struct ieee80211_if_mesh *ifmsh = &sdata->u.mesh;
        u8 offset, len;
        return 0;
 }
 
-int
-mesh_add_rsn_ie(struct sk_buff *skb, struct ieee80211_sub_if_data *sdata)
+int mesh_add_rsn_ie(struct ieee80211_sub_if_data *sdata, struct sk_buff *skb)
 {
        struct ieee80211_if_mesh *ifmsh = &sdata->u.mesh;
        u8 len = 0;
        return 0;
 }
 
-int mesh_add_ds_params_ie(struct sk_buff *skb,
-                         struct ieee80211_sub_if_data *sdata)
+static int mesh_add_ds_params_ie(struct ieee80211_sub_if_data *sdata,
+                                struct sk_buff *skb)
 {
        struct ieee80211_chanctx_conf *chanctx_conf;
        struct ieee80211_channel *chan;
        return 0;
 }
 
-int mesh_add_ht_cap_ie(struct sk_buff *skb,
-                      struct ieee80211_sub_if_data *sdata)
+int mesh_add_ht_cap_ie(struct ieee80211_sub_if_data *sdata,
+                      struct sk_buff *skb)
 {
        struct ieee80211_local *local = sdata->local;
        enum ieee80211_band band = ieee80211_get_sdata_band(sdata);
        return 0;
 }
 
-int mesh_add_ht_oper_ie(struct sk_buff *skb,
-                       struct ieee80211_sub_if_data *sdata)
+int mesh_add_ht_oper_ie(struct ieee80211_sub_if_data *sdata,
+                       struct sk_buff *skb)
 {
        struct ieee80211_local *local = sdata->local;
        struct ieee80211_chanctx_conf *chanctx_conf;
 
        return 0;
 }
+
 static void ieee80211_mesh_path_timer(unsigned long data)
 {
        struct ieee80211_sub_if_data *sdata =
 
 /**
  * ieee80211_fill_mesh_addresses - fill addresses of a locally originated mesh frame
- * @hdr:       802.11 frame header
+ * @hdr:       802.11 frame header
  * @fc:                frame control field
  * @meshda:    destination address in the mesh
  * @meshsa:    source address address in the mesh.  Same as TA, as frame is
 
 /**
  * ieee80211_new_mesh_header - create a new mesh header
- * @meshhdr:    uninitialized mesh header
  * @sdata:     mesh interface to be used
+ * @meshhdr:    uninitialized mesh header
  * @addr4or5:   1st address in the ae header, which may correspond to address 4
  *              (if addr6 is NULL) or address 5 (if addr6 is present). It may
  *              be NULL.
  *
  * Return the header length.
  */
-int ieee80211_new_mesh_header(struct ieee80211s_hdr *meshhdr,
-               struct ieee80211_sub_if_data *sdata, char *addr4or5,
-               char *addr6)
+int ieee80211_new_mesh_header(struct ieee80211_sub_if_data *sdata,
+                             struct ieee80211s_hdr *meshhdr,
+                             const char *addr4or5, const char *addr6)
 {
-       int aelen = 0;
-       BUG_ON(!addr4or5 && addr6);
+       if (WARN_ON(!addr4or5 && addr6))
+               return 0;
+
        memset(meshhdr, 0, sizeof(*meshhdr));
+
        meshhdr->ttl = sdata->u.mesh.mshcfg.dot11MeshTTL;
+
+       /* FIXME: racy -- TX on multiple queues can be concurrent */
        put_unaligned(cpu_to_le32(sdata->u.mesh.mesh_seqnum), &meshhdr->seqnum);
        sdata->u.mesh.mesh_seqnum++;
+
        if (addr4or5 && !addr6) {
                meshhdr->flags |= MESH_FLAGS_AE_A4;
-               aelen += ETH_ALEN;
                memcpy(meshhdr->eaddr1, addr4or5, ETH_ALEN);
+               return 2 * ETH_ALEN;
        } else if (addr4or5 && addr6) {
                meshhdr->flags |= MESH_FLAGS_AE_A5_A6;
-               aelen += 2 * ETH_ALEN;
                memcpy(meshhdr->eaddr1, addr4or5, ETH_ALEN);
                memcpy(meshhdr->eaddr2, addr6, ETH_ALEN);
+               return 3 * ETH_ALEN;
        }
-       return 6 + aelen;
+
+       return ETH_ALEN;
 }
 
-static void ieee80211_mesh_housekeeping(struct ieee80211_sub_if_data *sdata,
-                          struct ieee80211_if_mesh *ifmsh)
+static void ieee80211_mesh_housekeeping(struct ieee80211_sub_if_data *sdata)
 {
+       struct ieee80211_if_mesh *ifmsh = &sdata->u.mesh;
        u32 changed;
 
        ieee80211_sta_expire(sdata, IEEE80211_MESH_PEER_INACTIVITY_LIMIT);
        ieee80211_mbss_info_change_notify(sdata, changed);
 
        mod_timer(&ifmsh->housekeeping_timer,
-                 round_jiffies(jiffies + IEEE80211_MESH_HOUSEKEEPING_INTERVAL));
+                 round_jiffies(jiffies +
+                               IEEE80211_MESH_HOUSEKEEPING_INTERVAL));
 }
 
 static void ieee80211_mesh_rootpath(struct ieee80211_sub_if_data *sdata)
        *pos++ = 0x0;
 
        if (ieee80211_add_srates_ie(sdata, skb, true, band) ||
-           mesh_add_ds_params_ie(skb, sdata))
+           mesh_add_ds_params_ie(sdata, skb))
                goto out_free;
 
        bcn->head_len = skb->len;
        bcn->tail = bcn->head + bcn->head_len;
 
        if (ieee80211_add_ext_srates_ie(sdata, skb, true, band) ||
-           mesh_add_rsn_ie(skb, sdata) ||
-           mesh_add_ht_cap_ie(skb, sdata) ||
-           mesh_add_ht_oper_ie(skb, sdata) ||
-           mesh_add_meshid_ie(skb, sdata) ||
-           mesh_add_meshconf_ie(skb, sdata) ||
-           mesh_add_awake_window_ie(skb, sdata) ||
-           mesh_add_vendor_ies(skb, sdata))
+           mesh_add_rsn_ie(sdata, skb) ||
+           mesh_add_ht_cap_ie(sdata, skb) ||
+           mesh_add_ht_oper_ie(sdata, skb) ||
+           mesh_add_meshid_ie(sdata, skb) ||
+           mesh_add_meshconf_ie(sdata, skb) ||
+           mesh_add_awake_window_ie(sdata, skb) ||
+           mesh_add_vendor_ies(sdata, skb))
                goto out_free;
 
        bcn->tail_len = skb->len;
                mesh_mpp_table_grow();
 
        if (test_and_clear_bit(MESH_WORK_HOUSEKEEPING, &ifmsh->wrkq_flags))
-               ieee80211_mesh_housekeeping(sdata, ifmsh);
+               ieee80211_mesh_housekeeping(sdata);
 
        if (test_and_clear_bit(MESH_WORK_ROOT, &ifmsh->wrkq_flags))
                ieee80211_mesh_rootpath(sdata);
 
  * @MESH_PATH_ACTIVE: the mesh path can be used for forwarding
  * @MESH_PATH_RESOLVING: the discovery process is running for this mesh path
  * @MESH_PATH_SN_VALID: the mesh path contains a valid destination sequence
- *     number
+ *     number
  * @MESH_PATH_FIXED: the mesh path has been manually set and should not be
- *     modified
+ *     modified
  * @MESH_PATH_RESOLVED: the mesh path can has been resolved
  * @MESH_PATH_REQ_QUEUED: there is an unsent path request for this destination
- * already queued up, waiting for the discovery process to start.
+ *     already queued up, waiting for the discovery process to start.
  *
  * MESH_PATH_RESOLVED is used by the mesh path timer to
  * decide when to stop or cancel the mesh path discovery.
  * @dst: mesh path destination mac address
  * @sdata: mesh subif
  * @next_hop: mesh neighbor to which frames for this destination will be
- *     forwarded
+ *     forwarded
  * @timer: mesh path discovery timer
  * @frame_queue: pending queue for frames sent to this destination while the
- *     path is unresolved
+ *     path is unresolved
  * @sn: target sequence number
  * @metric: current metric to this destination
  * @hop_count: hops to destination
  * @exp_time: in jiffies, when the path will expire or when it expired
  * @discovery_timeout: timeout (lapse in jiffies) used for the last discovery
- *     retry
+ *     retry
  * @discovery_retries: number of discovery retries
  * @flags: mesh path flags, as specified on &enum mesh_path_flags
  * @state_lock: mesh path state lock used to protect changes to the
 /* Various */
 int ieee80211_fill_mesh_addresses(struct ieee80211_hdr *hdr, __le16 *fc,
                                  const u8 *da, const u8 *sa);
-int ieee80211_new_mesh_header(struct ieee80211s_hdr *meshhdr,
-               struct ieee80211_sub_if_data *sdata, char *addr4or5,
-               char *addr6);
-int mesh_rmc_check(u8 *addr, struct ieee80211s_hdr *mesh_hdr,
-               struct ieee80211_sub_if_data *sdata);
+int ieee80211_new_mesh_header(struct ieee80211_sub_if_data *sdata,
+                             struct ieee80211s_hdr *meshhdr,
+                             const char *addr4or5, const char *addr6);
+int mesh_rmc_check(struct ieee80211_sub_if_data *sdata,
+                  const u8 *addr, struct ieee80211s_hdr *mesh_hdr);
 bool mesh_matches_local(struct ieee80211_sub_if_data *sdata,
                        struct ieee802_11_elems *ie);
 void mesh_ids_set_default(struct ieee80211_if_mesh *mesh);
-void mesh_mgmt_ies_add(struct sk_buff *skb,
-               struct ieee80211_sub_if_data *sdata);
-int mesh_add_meshconf_ie(struct sk_buff *skb,
-                        struct ieee80211_sub_if_data *sdata);
-int mesh_add_meshid_ie(struct sk_buff *skb,
-                      struct ieee80211_sub_if_data *sdata);
-int mesh_add_rsn_ie(struct sk_buff *skb,
-                   struct ieee80211_sub_if_data *sdata);
-int mesh_add_awake_window_ie(struct sk_buff *skb,
-                            struct ieee80211_sub_if_data *sdata);
-int mesh_add_vendor_ies(struct sk_buff *skb,
-                       struct ieee80211_sub_if_data *sdata);
-int mesh_add_ds_params_ie(struct sk_buff *skb,
-                         struct ieee80211_sub_if_data *sdata);
-int mesh_add_ht_cap_ie(struct sk_buff *skb,
-                      struct ieee80211_sub_if_data *sdata);
-int mesh_add_ht_oper_ie(struct sk_buff *skb,
-                       struct ieee80211_sub_if_data *sdata);
+void mesh_mgmt_ies_add(struct ieee80211_sub_if_data *sdata,
+                      struct sk_buff *skb);
+int mesh_add_meshconf_ie(struct ieee80211_sub_if_data *sdata,
+                        struct sk_buff *skb);
+int mesh_add_meshid_ie(struct ieee80211_sub_if_data *sdata,
+                      struct sk_buff *skb);
+int mesh_add_rsn_ie(struct ieee80211_sub_if_data *sdata,
+                   struct sk_buff *skb);
+int mesh_add_vendor_ies(struct ieee80211_sub_if_data *sdata,
+                       struct sk_buff *skb);
+int mesh_add_ht_cap_ie(struct ieee80211_sub_if_data *sdata,
+                      struct sk_buff *skb);
+int mesh_add_ht_oper_ie(struct ieee80211_sub_if_data *sdata,
+                       struct sk_buff *skb);
 void mesh_rmc_free(struct ieee80211_sub_if_data *sdata);
 int mesh_rmc_init(struct ieee80211_sub_if_data *sdata);
 void ieee80211s_init(void);
 void ieee80211s_update_metric(struct ieee80211_local *local,
-               struct sta_info *sta, struct sk_buff *skb);
-void ieee80211s_stop(void);
+                             struct sta_info *sta, struct sk_buff *skb);
 void ieee80211_mesh_init_sdata(struct ieee80211_sub_if_data *sdata);
 int ieee80211_start_mesh(struct ieee80211_sub_if_data *sdata);
 void ieee80211_stop_mesh(struct ieee80211_sub_if_data *sdata);
                                 struct ieee802_11_elems *elems);
 
 /* Mesh paths */
-int mesh_nexthop_lookup(struct sk_buff *skb,
-               struct ieee80211_sub_if_data *sdata);
-int mesh_nexthop_resolve(struct sk_buff *skb,
-                        struct ieee80211_sub_if_data *sdata);
+int mesh_nexthop_lookup(struct ieee80211_sub_if_data *sdata,
+                       struct sk_buff *skb);
+int mesh_nexthop_resolve(struct ieee80211_sub_if_data *sdata,
+                        struct sk_buff *skb);
 void mesh_path_start_discovery(struct ieee80211_sub_if_data *sdata);
-struct mesh_path *mesh_path_lookup(const u8 *dst,
-                                  struct ieee80211_sub_if_data *sdata);
-struct mesh_path *mpp_path_lookup(u8 *dst,
-                                 struct ieee80211_sub_if_data *sdata);
-int mpp_path_add(u8 *dst, u8 *mpp, struct ieee80211_sub_if_data *sdata);
-struct mesh_path *mesh_path_lookup_by_idx(int idx,
-               struct ieee80211_sub_if_data *sdata);
+struct mesh_path *mesh_path_lookup(struct ieee80211_sub_if_data *sdata,
+                                  const u8 *dst);
+struct mesh_path *mpp_path_lookup(struct ieee80211_sub_if_data *sdata,
+                                 const u8 *dst);
+int mpp_path_add(struct ieee80211_sub_if_data *sdata,
+                const u8 *dst, const u8 *mpp);
+struct mesh_path *
+mesh_path_lookup_by_idx(struct ieee80211_sub_if_data *sdata, int idx);
 void mesh_path_fix_nexthop(struct mesh_path *mpath, struct sta_info *next_hop);
 void mesh_path_expire(struct ieee80211_sub_if_data *sdata);
 void mesh_rx_path_sel_frame(struct ieee80211_sub_if_data *sdata,
-               struct ieee80211_mgmt *mgmt, size_t len);
-int mesh_path_add(const u8 *dst, struct ieee80211_sub_if_data *sdata);
+                           struct ieee80211_mgmt *mgmt, size_t len);
+int mesh_path_add(struct ieee80211_sub_if_data *sdata, const u8 *dst);
 
 int mesh_path_add_gate(struct mesh_path *mpath);
 int mesh_path_send_to_gates(struct mesh_path *mpath);
 int mesh_gate_num(struct ieee80211_sub_if_data *sdata);
+
 /* Mesh plinks */
 void mesh_neighbour_update(struct ieee80211_sub_if_data *sdata,
-                          u8 *hw_addr,
-                          struct ieee802_11_elems *ie);
+                          u8 *hw_addr, struct ieee802_11_elems *ie);
 bool mesh_peer_accepts_plinks(struct ieee802_11_elems *ie);
 u32 mesh_accept_plinks_update(struct ieee80211_sub_if_data *sdata);
 void mesh_plink_broken(struct sta_info *sta);
 void mesh_mpath_table_grow(void);
 void mesh_mpp_table_grow(void);
 /* Mesh paths */
-int mesh_path_error_tx(u8 ttl, const u8 *target, __le32 target_sn,
-                      __le16 target_rcode, const u8 *ra,
-                      struct ieee80211_sub_if_data *sdata);
+int mesh_path_error_tx(struct ieee80211_sub_if_data *sdata,
+                      u8 ttl, const u8 *target, __le32 target_sn,
+                      __le16 target_rcode, const u8 *ra);
 void mesh_path_assign_nexthop(struct mesh_path *mpath, struct sta_info *sta);
 void mesh_path_flush_pending(struct mesh_path *mpath);
 void mesh_path_tx_pending(struct mesh_path *mpath);
 int mesh_pathtbl_init(void);
 void mesh_pathtbl_unregister(void);
-int mesh_path_del(u8 *addr, struct ieee80211_sub_if_data *sdata);
+int mesh_path_del(struct ieee80211_sub_if_data *sdata, const u8 *addr);
 void mesh_path_timer(unsigned long data);
 void mesh_path_flush_by_nexthop(struct sta_info *sta);
-void mesh_path_discard_frame(struct sk_buff *skb,
-               struct ieee80211_sub_if_data *sdata);
+void mesh_path_discard_frame(struct ieee80211_sub_if_data *sdata,
+                            struct sk_buff *skb);
 void mesh_path_quiesce(struct ieee80211_sub_if_data *sdata);
 void mesh_path_restart(struct ieee80211_sub_if_data *sdata);
 void mesh_path_tx_root_frame(struct ieee80211_sub_if_data *sdata);
 extern int mesh_paths_generation;
 
 #ifdef CONFIG_MAC80211_MESH
-extern int mesh_allocated;
-
 static inline
 u32 mesh_plink_inc_estab_count(struct ieee80211_sub_if_data *sdata)
 {
 void mesh_plink_restart(struct sta_info *sta);
 void mesh_path_flush_by_iface(struct ieee80211_sub_if_data *sdata);
 void mesh_sync_adjust_tbtt(struct ieee80211_sub_if_data *sdata);
+void ieee80211s_stop(void);
 #else
-#define mesh_allocated 0
 static inline void
 ieee80211_mesh_notify_scan_completed(struct ieee80211_local *local) {}
 static inline void ieee80211_mesh_quiesce(struct ieee80211_sub_if_data *sdata)
 { return false; }
 static inline void mesh_path_flush_by_iface(struct ieee80211_sub_if_data *sdata)
 {}
+static inline void ieee80211s_stop(void) {}
 #endif
 
 #endif /* IEEE80211S_H */
 
  * also acquires in the TX path.  To avoid a deadlock we don't transmit the
  * frame directly but add it to the pending queue instead.
  */
-int mesh_path_error_tx(u8 ttl, const u8 *target, __le32 target_sn,
-                      __le16 target_rcode, const u8 *ra,
-                      struct ieee80211_sub_if_data *sdata)
+int mesh_path_error_tx(struct ieee80211_sub_if_data *sdata,
+                      u8 ttl, const u8 *target, __le32 target_sn,
+                      __le16 target_rcode, const u8 *ra)
 {
        struct ieee80211_local *local = sdata->local;
        struct sk_buff *skb;
                process = false;
                fresh_info = false;
        } else {
-               mpath = mesh_path_lookup(orig_addr, sdata);
+               mpath = mesh_path_lookup(sdata, orig_addr);
                if (mpath) {
                        spin_lock_bh(&mpath->state_lock);
                        if (mpath->flags & MESH_PATH_FIXED)
                                }
                        }
                } else {
-                       mesh_path_add(orig_addr, sdata);
-                       mpath = mesh_path_lookup(orig_addr, sdata);
+                       mesh_path_add(sdata, orig_addr);
+                       mpath = mesh_path_lookup(sdata, orig_addr);
                        if (!mpath) {
                                rcu_read_unlock();
                                return 0;
        else {
                fresh_info = true;
 
-               mpath = mesh_path_lookup(ta, sdata);
+               mpath = mesh_path_lookup(sdata, ta);
                if (mpath) {
                        spin_lock_bh(&mpath->state_lock);
                        if ((mpath->flags & MESH_PATH_FIXED) ||
                                        (last_hop_metric > mpath->metric)))
                                fresh_info = false;
                } else {
-                       mesh_path_add(ta, sdata);
-                       mpath = mesh_path_lookup(ta, sdata);
+                       mesh_path_add(sdata, ta);
+                       mpath = mesh_path_lookup(sdata, ta);
                        if (!mpath) {
                                rcu_read_unlock();
                                return 0;
        } else if (is_broadcast_ether_addr(target_addr) &&
                   (target_flags & IEEE80211_PREQ_TO_FLAG)) {
                rcu_read_lock();
-               mpath = mesh_path_lookup(orig_addr, sdata);
+               mpath = mesh_path_lookup(sdata, orig_addr);
                if (mpath) {
                        if (flags & IEEE80211_PREQ_PROACTIVE_PREP_FLAG) {
                                reply = true;
                rcu_read_unlock();
        } else {
                rcu_read_lock();
-               mpath = mesh_path_lookup(target_addr, sdata);
+               mpath = mesh_path_lookup(sdata, target_addr);
                if (mpath) {
                        if ((!(mpath->flags & MESH_PATH_SN_VALID)) ||
                                        SN_LT(mpath->sn, target_sn)) {
        }
 
        rcu_read_lock();
-       mpath = mesh_path_lookup(orig_addr, sdata);
+       mpath = mesh_path_lookup(sdata, orig_addr);
        if (mpath)
                spin_lock_bh(&mpath->state_lock);
        else
        target_rcode = PERR_IE_TARGET_RCODE(perr_elem);
 
        rcu_read_lock();
-       mpath = mesh_path_lookup(target_addr, sdata);
+       mpath = mesh_path_lookup(sdata, target_addr);
        if (mpath) {
                struct sta_info *sta;
 
                        spin_unlock_bh(&mpath->state_lock);
                        if (!ifmsh->mshcfg.dot11MeshForwarding)
                                goto endperr;
-                       mesh_path_error_tx(ttl, target_addr, cpu_to_le32(target_sn),
+                       mesh_path_error_tx(sdata, ttl, target_addr,
+                                          cpu_to_le32(target_sn),
                                           cpu_to_le16(target_rcode),
-                                          broadcast_addr, sdata);
+                                          broadcast_addr);
                } else
                        spin_unlock_bh(&mpath->state_lock);
        }
 
        metric_txsta = airtime_link_metric_get(local, sta);
 
-       mpath = mesh_path_lookup(orig_addr, sdata);
+       mpath = mesh_path_lookup(sdata, orig_addr);
        if (!mpath) {
-               mesh_path_add(orig_addr, sdata);
-               mpath = mesh_path_lookup(orig_addr, sdata);
+               mesh_path_add(sdata, orig_addr);
+               mpath = mesh_path_lookup(sdata, orig_addr);
                if (!mpath) {
                        rcu_read_unlock();
                        sdata->u.mesh.mshstats.dropped_frames_no_route++;
 
 
 void mesh_rx_path_sel_frame(struct ieee80211_sub_if_data *sdata,
-                           struct ieee80211_mgmt *mgmt,
-                           size_t len)
+                           struct ieee80211_mgmt *mgmt, size_t len)
 {
        struct ieee802_11_elems elems;
        size_t baselen;
        spin_unlock_bh(&ifmsh->mesh_preq_queue_lock);
 
        rcu_read_lock();
-       mpath = mesh_path_lookup(preq_node->dst, sdata);
+       mpath = mesh_path_lookup(sdata, preq_node->dst);
        if (!mpath)
                goto enddiscovery;
 
  * Returns: 0 if the next hop was found and -ENOENT if the frame was queued.
  * skb is freeed here if no mpath could be allocated.
  */
-int mesh_nexthop_resolve(struct sk_buff *skb,
-                        struct ieee80211_sub_if_data *sdata)
+int mesh_nexthop_resolve(struct ieee80211_sub_if_data *sdata,
+                        struct sk_buff *skb)
 {
        struct ieee80211_hdr *hdr = (struct ieee80211_hdr *) skb->data;
        struct ieee80211_tx_info *info = IEEE80211_SKB_CB(skb);
                return 0;
 
        rcu_read_lock();
-       err = mesh_nexthop_lookup(skb, sdata);
+       err = mesh_nexthop_lookup(sdata, skb);
        if (!err)
                goto endlookup;
 
        /* no nexthop found, start resolving */
-       mpath = mesh_path_lookup(target_addr, sdata);
+       mpath = mesh_path_lookup(sdata, target_addr);
        if (!mpath) {
-               mesh_path_add(target_addr, sdata);
-               mpath = mesh_path_lookup(target_addr, sdata);
+               mesh_path_add(sdata, target_addr);
+               mpath = mesh_path_lookup(sdata, target_addr);
                if (!mpath) {
-                       mesh_path_discard_frame(skb, sdata);
+                       mesh_path_discard_frame(sdata, skb);
                        err = -ENOSPC;
                        goto endlookup;
                }
        skb_queue_tail(&mpath->frame_queue, skb);
        err = -ENOENT;
        if (skb_to_free)
-               mesh_path_discard_frame(skb_to_free, sdata);
+               mesh_path_discard_frame(sdata, skb_to_free);
 
 endlookup:
        rcu_read_unlock();
        return err;
 }
+
 /**
  * mesh_nexthop_lookup - put the appropriate next hop on a mesh frame. Calling
  * this function is considered "using" the associated mpath, so preempt a path
  *
  * Returns: 0 if the next hop was found. Nonzero otherwise.
  */
-int mesh_nexthop_lookup(struct sk_buff *skb,
-                       struct ieee80211_sub_if_data *sdata)
+int mesh_nexthop_lookup(struct ieee80211_sub_if_data *sdata,
+                       struct sk_buff *skb)
 {
        struct mesh_path *mpath;
        struct sta_info *next_hop;
        int err = -ENOENT;
 
        rcu_read_lock();
-       mpath = mesh_path_lookup(target_addr, sdata);
+       mpath = mesh_path_lookup(sdata, target_addr);
 
        if (!mpath || !(mpath->flags & MESH_PATH_ACTIVE))
                goto endlookup;
        }
 }
 
-void
-mesh_path_tx_root_frame(struct ieee80211_sub_if_data *sdata)
+void mesh_path_tx_root_frame(struct ieee80211_sub_if_data *sdata)
 {
        struct ieee80211_if_mesh *ifmsh = &sdata->u.mesh;
        u32 interval = ifmsh->mshcfg.dot11MeshHWMPRannInterval;
 
 /* Keep the mean chain length below this constant */
 #define MEAN_CHAIN_LEN         2
 
-#define MPATH_EXPIRED(mpath) ((mpath->flags & MESH_PATH_ACTIVE) && \
-                               time_after(jiffies, mpath->exp_time) && \
-                               !(mpath->flags & MESH_PATH_FIXED))
+static inline bool mpath_expired(struct mesh_path *mpath)
+{
+       return (mpath->flags & MESH_PATH_ACTIVE) &&
+              time_after(jiffies, mpath->exp_time) &&
+              !(mpath->flags & MESH_PATH_FIXED);
+}
 
 struct mpath_node {
        struct hlist_node list;
                           struct mesh_table *tbl)
 {
        /* Use last four bytes of hw addr and interface index as hash index */
-       return jhash_2words(*(u32 *)(addr+2), sdata->dev->ifindex, tbl->hash_rnd)
-               & tbl->hash_mask;
+       return jhash_2words(*(u32 *)(addr+2), sdata->dev->ifindex,
+                           tbl->hash_rnd) & tbl->hash_mask;
 }
 
 
                mpath = node->mpath;
                if (mpath->sdata == sdata &&
                    ether_addr_equal(dst, mpath->dst)) {
-                       if (MPATH_EXPIRED(mpath)) {
+                       if (mpath_expired(mpath)) {
                                spin_lock_bh(&mpath->state_lock);
                                mpath->flags &= ~MESH_PATH_ACTIVE;
                                spin_unlock_bh(&mpath->state_lock);
 
 /**
  * mesh_path_lookup - look up a path in the mesh path table
- * @dst: hardware address (ETH_ALEN length) of destination
  * @sdata: local subif
+ * @dst: hardware address (ETH_ALEN length) of destination
  *
  * Returns: pointer to the mesh path structure, or NULL if not found
  *
  * Locking: must be called within a read rcu section.
  */
-struct mesh_path *mesh_path_lookup(const u8 *dst,
-                                  struct ieee80211_sub_if_data *sdata)
+struct mesh_path *
+mesh_path_lookup(struct ieee80211_sub_if_data *sdata, const u8 *dst)
 {
        return mpath_lookup(rcu_dereference(mesh_paths), dst, sdata);
 }
 
-struct mesh_path *mpp_path_lookup(u8 *dst, struct ieee80211_sub_if_data *sdata)
+struct mesh_path *
+mpp_path_lookup(struct ieee80211_sub_if_data *sdata, const u8 *dst)
 {
        return mpath_lookup(rcu_dereference(mpp_paths), dst, sdata);
 }
  *
  * Locking: must be called within a read rcu section.
  */
-struct mesh_path *mesh_path_lookup_by_idx(int idx, struct ieee80211_sub_if_data *sdata)
+struct mesh_path *
+mesh_path_lookup_by_idx(struct ieee80211_sub_if_data *sdata, int idx)
 {
        struct mesh_table *tbl = rcu_dereference(mesh_paths);
        struct mpath_node *node;
                if (sdata && node->mpath->sdata != sdata)
                        continue;
                if (j++ == idx) {
-                       if (MPATH_EXPIRED(node->mpath)) {
+                       if (mpath_expired(node->mpath)) {
                                spin_lock_bh(&node->mpath->state_lock);
                                node->mpath->flags &= ~MESH_PATH_ACTIVE;
                                spin_unlock_bh(&node->mpath->state_lock);
        spin_lock_bh(&tbl->gates_lock);
        hlist_add_head_rcu(&new_gate->list, tbl->known_gates);
        spin_unlock_bh(&tbl->gates_lock);
-       rcu_read_unlock();
        mpath_dbg(mpath->sdata,
                  "Mesh path: Recorded new gate: %pM. %d known gates\n",
                  mpath->dst, mpath->sdata->u.mesh.num_gates);
-       return 0;
+       err = 0;
 err_rcu:
        rcu_read_unlock();
        return err;
  * @tbl: table which holds our list of known gates
  * @mpath: gate mpath
  *
- * Returns: 0 on success
- *
  * Locking: must be called inside rcu_read_lock() section
  */
-static int mesh_gate_del(struct mesh_table *tbl, struct mesh_path *mpath)
+static void mesh_gate_del(struct mesh_table *tbl, struct mesh_path *mpath)
 {
        struct mpath_node *gate;
        struct hlist_node *p, *q;
 
-       hlist_for_each_entry_safe(gate, p, q, tbl->known_gates, list)
-               if (gate->mpath == mpath) {
-                       spin_lock_bh(&tbl->gates_lock);
-                       hlist_del_rcu(&gate->list);
-                       kfree_rcu(gate, rcu);
-                       spin_unlock_bh(&tbl->gates_lock);
-                       mpath->sdata->u.mesh.num_gates--;
-                       mpath->is_gate = false;
-                       mpath_dbg(mpath->sdata,
-                                 "Mesh path: Deleted gate: %pM. %d known gates\n",
-                                 mpath->dst, mpath->sdata->u.mesh.num_gates);
-                       break;
-               }
-
-       return 0;
+       hlist_for_each_entry_safe(gate, p, q, tbl->known_gates, list) {
+               if (gate->mpath != mpath)
+                       continue;
+               spin_lock_bh(&tbl->gates_lock);
+               hlist_del_rcu(&gate->list);
+               kfree_rcu(gate, rcu);
+               spin_unlock_bh(&tbl->gates_lock);
+               mpath->sdata->u.mesh.num_gates--;
+               mpath->is_gate = false;
+               mpath_dbg(mpath->sdata,
+                         "Mesh path: Deleted gate: %pM. %d known gates\n",
+                         mpath->dst, mpath->sdata->u.mesh.num_gates);
+               break;
+       }
 }
 
 /**
 
 /**
  * mesh_path_add - allocate and add a new path to the mesh path table
- * @addr: destination address of the path (ETH_ALEN length)
+ * @dst: destination address of the path (ETH_ALEN length)
  * @sdata: local subif
  *
  * Returns: 0 on success
  *
  * State: the initial state of the new path is set to 0
  */
-int mesh_path_add(const u8 *dst, struct ieee80211_sub_if_data *sdata)
+int mesh_path_add(struct ieee80211_sub_if_data *sdata, const u8 *dst)
 {
        struct ieee80211_if_mesh *ifmsh = &sdata->u.mesh;
        struct ieee80211_local *local = sdata->local;
        write_unlock_bh(&pathtbl_resize_lock);
 }
 
-int mpp_path_add(u8 *dst, u8 *mpp, struct ieee80211_sub_if_data *sdata)
+int mpp_path_add(struct ieee80211_sub_if_data *sdata,
+                const u8 *dst, const u8 *mpp)
 {
        struct ieee80211_if_mesh *ifmsh = &sdata->u.mesh;
        struct ieee80211_local *local = sdata->local;
                        mpath->flags &= ~MESH_PATH_ACTIVE;
                        ++mpath->sn;
                        spin_unlock_bh(&mpath->state_lock);
-                       mesh_path_error_tx(sdata->u.mesh.mshcfg.element_ttl,
-                                       mpath->dst, cpu_to_le32(mpath->sn),
-                                       reason, bcast, sdata);
+                       mesh_path_error_tx(sdata,
+                                          sdata->u.mesh.mshcfg.element_ttl,
+                                          mpath->dst, cpu_to_le32(mpath->sn),
+                                          reason, bcast);
                }
        }
        rcu_read_unlock();
  *
  * Returns: 0 if successful
  */
-int mesh_path_del(u8 *addr, struct ieee80211_sub_if_data *sdata)
+int mesh_path_del(struct ieee80211_sub_if_data *sdata, const u8 *addr)
 {
        struct mesh_table *tbl;
        struct mesh_path *mpath;
  *
  * Locking: the function must me called within a rcu_read_lock region
  */
-void mesh_path_discard_frame(struct sk_buff *skb,
-                            struct ieee80211_sub_if_data *sdata)
+void mesh_path_discard_frame(struct ieee80211_sub_if_data *sdata,
+                            struct sk_buff *skb)
 {
        kfree_skb(skb);
        sdata->u.mesh.mshstats.dropped_frames_no_route++;
        struct sk_buff *skb;
 
        while ((skb = skb_dequeue(&mpath->frame_queue)) != NULL)
-               mesh_path_discard_frame(skb, mpath->sdata);
+               mesh_path_discard_frame(mpath->sdata, skb);
 }
 
 /**
                if ((!(mpath->flags & MESH_PATH_RESOLVING)) &&
                    (!(mpath->flags & MESH_PATH_FIXED)) &&
                     time_after(jiffies, mpath->exp_time + MESH_PATH_EXPIRE))
-                       mesh_path_del(mpath->dst, mpath->sdata);
+                       mesh_path_del(mpath->sdata, mpath->dst);
        }
        rcu_read_unlock();
 }
 
 };
 
 static int mesh_plink_frame_tx(struct ieee80211_sub_if_data *sdata,
-               enum ieee80211_self_protected_actioncode action,
-               u8 *da, __le16 llid, __le16 plid, __le16 reason);
+                              enum ieee80211_self_protected_actioncode action,
+                              u8 *da, __le16 llid, __le16 plid, __le16 reason);
 
 /**
  * mesh_plink_fsm_restart - restart a mesh peer link finite state machine
 }
 
 static int mesh_plink_frame_tx(struct ieee80211_sub_if_data *sdata,
-               enum ieee80211_self_protected_actioncode action,
-               u8 *da, __le16 llid, __le16 plid, __le16 reason) {
+                              enum ieee80211_self_protected_actioncode action,
+                              u8 *da, __le16 llid, __le16 plid, __le16 reason)
+{
        struct ieee80211_local *local = sdata->local;
        struct sk_buff *skb;
        struct ieee80211_tx_info *info;
                }
                if (ieee80211_add_srates_ie(sdata, skb, true, band) ||
                    ieee80211_add_ext_srates_ie(sdata, skb, true, band) ||
-                   mesh_add_rsn_ie(skb, sdata) ||
-                   mesh_add_meshid_ie(skb, sdata) ||
-                   mesh_add_meshconf_ie(skb, sdata))
+                   mesh_add_rsn_ie(sdata, skb) ||
+                   mesh_add_meshid_ie(sdata, skb) ||
+                   mesh_add_meshconf_ie(sdata, skb))
                        goto free;
        } else {        /* WLAN_SP_MESH_PEERING_CLOSE */
                info->flags |= IEEE80211_TX_CTL_NO_ACK;
-               if (mesh_add_meshid_ie(skb, sdata))
+               if (mesh_add_meshid_ie(sdata, skb))
                        goto free;
        }
 
        }
 
        if (action != WLAN_SP_MESH_PEERING_CLOSE) {
-               if (mesh_add_ht_cap_ie(skb, sdata) ||
-                   mesh_add_ht_oper_ie(skb, sdata))
+               if (mesh_add_ht_cap_ie(sdata, skb) ||
+                   mesh_add_ht_oper_ie(sdata, skb))
                        goto free;
        }
 
-       if (mesh_add_vendor_ies(skb, sdata))
+       if (mesh_add_vendor_ies(sdata, skb))
                goto free;
 
        ieee80211_tx_skb(sdata, skb);
 }
 
 
-void mesh_rx_plink_frame(struct ieee80211_sub_if_data *sdata, struct ieee80211_mgmt *mgmt,
-                        size_t len, struct ieee80211_rx_status *rx_status)
+void mesh_rx_plink_frame(struct ieee80211_sub_if_data *sdata,
+                        struct ieee80211_mgmt *mgmt, size_t len,
+                        struct ieee80211_rx_status *rx_status)
 {
        struct mesh_config *mshcfg = &sdata->u.mesh.mshcfg;
        struct ieee802_11_elems elems;
        u8 *baseaddr;
        u32 changed = 0;
        __le16 plid, llid, reason;
-       static const char *mplstates[] = {
+       static const char * const mplstates[] = {
                [NL80211_PLINK_LISTEN] = "LISTEN",
                [NL80211_PLINK_OPN_SNT] = "OPN-SNT",
                [NL80211_PLINK_OPN_RCVD] = "OPN-RCVD",
                baselen += 4;
        }
        ieee802_11_parse_elems(baseaddr, len - baselen, &elems);
+
        if (!elems.peering) {
                mpl_dbg(sdata,
                        "Mesh plink: missing necessary peer link ie\n");
                return;
        }
+
        if (elems.rsn_len &&
-                       sdata->u.mesh.security == IEEE80211_MESH_SEC_NONE) {
+           sdata->u.mesh.security == IEEE80211_MESH_SEC_NONE) {
                mpl_dbg(sdata,
                        "Mesh plink: can't establish link with secure peer\n");
                return;
        }
 
        if (ftype != WLAN_SP_MESH_PEERING_CLOSE &&
-                               (!elems.mesh_id || !elems.mesh_config)) {
+           (!elems.mesh_id || !elems.mesh_config)) {
                mpl_dbg(sdata, "Mesh plink: missing necessary ie\n");
                return;
        }
 
 static bool mesh_peer_tbtt_adjusting(struct ieee802_11_elems *ie)
 {
        return (ie->mesh_config->meshconf_cap &
-           IEEE80211_MESHCONF_CAPAB_TBTT_ADJUSTING) != 0;
+                       IEEE80211_MESHCONF_CAPAB_TBTT_ADJUSTING) != 0;
 }
 
 void mesh_sync_adjust_tbtt(struct ieee80211_sub_if_data *sdata)
 
        if (elems->mesh_config && mesh_peer_tbtt_adjusting(elems)) {
                clear_sta_flag(sta, WLAN_STA_TOFFSET_KNOWN);
-               msync_dbg(sdata, "STA %pM : is adjusting TBTT\n", sta->sta.addr);
+               msync_dbg(sdata, "STA %pM : is adjusting TBTT\n",
+                         sta->sta.addr);
                goto no_sync;
        }
 
        sta->t_offset = t_t - t_r;
 
        if (test_sta_flag(sta, WLAN_STA_TOFFSET_KNOWN)) {
-               s64 t_clockdrift = sta->t_offset_setpoint
-                                  - sta->t_offset;
+               s64 t_clockdrift = sta->t_offset_setpoint - sta->t_offset;
                msync_dbg(sdata,
                          "STA %pM : sta->t_offset=%lld, sta->t_offset_setpoint=%lld, t_clockdrift=%lld\n",
-                         sta->sta.addr,
-                         (long long) sta->t_offset,
-                         (long long)
-                         sta->t_offset_setpoint,
+                         sta->sta.addr, (long long) sta->t_offset,
+                         (long long) sta->t_offset_setpoint,
                          (long long) t_clockdrift);
 
                if (t_clockdrift > TOFFSET_MAXIMUM_ADJUSTMENT ||
-                       t_clockdrift < -TOFFSET_MAXIMUM_ADJUSTMENT) {
+                   t_clockdrift < -TOFFSET_MAXIMUM_ADJUSTMENT) {
                        msync_dbg(sdata,
                                  "STA %pM : t_clockdrift=%lld too large, setpoint reset\n",
                                  sta->sta.addr,
                        goto no_sync;
                }
 
-               rcu_read_unlock();
-
                spin_lock_bh(&ifmsh->sync_offset_lock);
-               if (t_clockdrift >
-                   ifmsh->sync_offset_clockdrift_max)
-                       ifmsh->sync_offset_clockdrift_max
-                               = t_clockdrift;
+               if (t_clockdrift > ifmsh->sync_offset_clockdrift_max)
+                       ifmsh->sync_offset_clockdrift_max = t_clockdrift;
                spin_unlock_bh(&ifmsh->sync_offset_lock);
-
        } else {
                sta->t_offset_setpoint = sta->t_offset - TOFFSET_SET_MARGIN;
                set_sta_flag(sta, WLAN_STA_TOFFSET_KNOWN);
                          "STA %pM : offset was invalid, sta->t_offset=%lld\n",
                          sta->sta.addr,
                          (long long) sta->t_offset);
-               rcu_read_unlock();
        }
-       return;
 
 no_sync:
        rcu_read_unlock();
 {
        struct ieee80211_if_mesh *ifmsh = &sdata->u.mesh;
 
-       WARN_ON(ifmsh->mesh_sp_id
-               != IEEE80211_SYNC_METHOD_NEIGHBOR_OFFSET);
+       WARN_ON(ifmsh->mesh_sp_id != IEEE80211_SYNC_METHOD_NEIGHBOR_OFFSET);
        BUG_ON(!rcu_read_lock_held());
 
        spin_lock_bh(&ifmsh->sync_offset_lock);
 
-       if (ifmsh->sync_offset_clockdrift_max >
-               TOFFSET_MINIMUM_ADJUSTMENT) {
+       if (ifmsh->sync_offset_clockdrift_max > TOFFSET_MINIMUM_ADJUSTMENT) {
                /* Since ajusting the tsf here would
                 * require a possibly blocking call
                 * to the driver tsf setter, we punt
                msync_dbg(sdata,
                          "TBTT : kicking off TBTT adjustment with clockdrift_max=%lld\n",
                          ifmsh->sync_offset_clockdrift_max);
-               set_bit(MESH_WORK_DRIFT_ADJUST,
-                       &ifmsh->wrkq_flags);
+               set_bit(MESH_WORK_DRIFT_ADJUST, &ifmsh->wrkq_flags);
 
                ifmsh->adjusting_tbtt = true;
        } else {
 
 const struct ieee80211_mesh_sync_ops *ieee80211_mesh_sync_ops_get(u8 method)
 {
-       const struct ieee80211_mesh_sync_ops *ops = NULL;
-       u8 i;
+       int i;
 
        for (i = 0 ; i < ARRAY_SIZE(sync_methods); ++i) {
-               if (sync_methods[i].method == method) {
-                       ops = &sync_methods[i].ops;
-                       break;
-               }
+               if (sync_methods[i].method == method)
+                       return &sync_methods[i].ops;
        }
-       return ops;
+       return NULL;
 }
 
        /* frame is in RMC, don't forward */
        if (ieee80211_is_data(hdr->frame_control) &&
            is_multicast_ether_addr(hdr->addr1) &&
-           mesh_rmc_check(hdr->addr3, mesh_hdr, rx->sdata))
+           mesh_rmc_check(rx->sdata, hdr->addr3, mesh_hdr))
                return RX_DROP_MONITOR;
 
        if (!ieee80211_is_data(hdr->frame_control) ||
                }
 
                rcu_read_lock();
-               mppath = mpp_path_lookup(proxied_addr, sdata);
+               mppath = mpp_path_lookup(sdata, proxied_addr);
                if (!mppath) {
-                       mpp_path_add(proxied_addr, mpp_addr, sdata);
+                       mpp_path_add(sdata, proxied_addr, mpp_addr);
                } else {
                        spin_lock_bh(&mppath->state_lock);
                        if (!ether_addr_equal(mppath->mpp, mpp_addr))
                memcpy(fwd_hdr->addr2, sdata->vif.addr, ETH_ALEN);
                /* update power mode indication when forwarding */
                ieee80211_mps_set_frame_flags(sdata, NULL, fwd_hdr);
-       } else if (!mesh_nexthop_lookup(fwd_skb, sdata)) {
+       } else if (!mesh_nexthop_lookup(sdata, fwd_skb)) {
                /* mesh power mode flags updated in mesh_nexthop_lookup */
                IEEE80211_IFSTA_MESH_CTR_INC(ifmsh, fwded_unicast);
        } else {
                /* unable to resolve next hop */
-               mesh_path_error_tx(ifmsh->mshcfg.element_ttl, fwd_hdr->addr3,
-                                  0, reason, fwd_hdr->addr2, sdata);
+               mesh_path_error_tx(sdata, ifmsh->mshcfg.element_ttl,
+                                  fwd_hdr->addr3, 0, reason, fwd_hdr->addr2);
                IEEE80211_IFSTA_MESH_CTR_INC(ifmsh, dropped_frames_no_route);
                kfree_skb(fwd_skb);
                return RX_DROP_MONITOR;
 
        if (ieee80211_vif_is_mesh(&sdata->vif)) {
                if (ieee80211_is_data(hdr->frame_control) &&
                    is_unicast_ether_addr(hdr->addr1)) {
-                       if (mesh_nexthop_resolve(skb, sdata))
+                       if (mesh_nexthop_resolve(sdata, skb))
                                return; /* skb queued: don't free */
                } else {
                        ieee80211_mps_set_frame_flags(sdata, NULL, hdr);
                }
 
                if (!is_multicast_ether_addr(skb->data)) {
-                       mpath = mesh_path_lookup(skb->data, sdata);
+                       mpath = mesh_path_lookup(sdata, skb->data);
                        if (!mpath)
-                               mppath = mpp_path_lookup(skb->data, sdata);
+                               mppath = mpp_path_lookup(sdata, skb->data);
                }
 
                /*
                    !(mppath && !ether_addr_equal(mppath->mpp, skb->data))) {
                        hdrlen = ieee80211_fill_mesh_addresses(&hdr, &fc,
                                        skb->data, skb->data + ETH_ALEN);
-                       meshhdrlen = ieee80211_new_mesh_header(&mesh_hdr,
-                                       sdata, NULL, NULL);
+                       meshhdrlen = ieee80211_new_mesh_header(sdata, &mesh_hdr,
+                                                              NULL, NULL);
                } else {
                        /* DS -> MBSS (802.11-2012 13.11.3.3).
                         * For unicast with unknown forwarding information,
                                        mesh_da, sdata->vif.addr);
                        if (is_multicast_ether_addr(mesh_da))
                                /* DA TA mSA AE:SA */
-                               meshhdrlen =
-                                       ieee80211_new_mesh_header(&mesh_hdr,
-                                                       sdata,
-                                                       skb->data + ETH_ALEN,
-                                                       NULL);
+                               meshhdrlen = ieee80211_new_mesh_header(
+                                               sdata, &mesh_hdr,
+                                               skb->data + ETH_ALEN, NULL);
                        else
                                /* RA TA mDA mSA AE:DA SA */
-                               meshhdrlen =
-                                       ieee80211_new_mesh_header(&mesh_hdr,
-                                                       sdata,
-                                                       skb->data,
-                                                       skb->data + ETH_ALEN);
+                               meshhdrlen = ieee80211_new_mesh_header(
+                                               sdata, &mesh_hdr, skb->data,
+                                               skb->data + ETH_ALEN);
 
                }
                chanctx_conf = rcu_dereference(sdata->vif.chanctx_conf);