static int wfx_get_hw_rate(struct wfx_dev *wdev,
                           const struct ieee80211_tx_rate *rate)
 {
+       struct ieee80211_supported_band *band;
+
        if (rate->idx < 0)
                return -1;
        if (rate->flags & IEEE80211_TX_RC_MCS) {
        }
        // WFx only support 2GHz, else band information should be retrieved
        // from ieee80211_tx_info
-       return wdev->hw->wiphy->bands[NL80211_BAND_2GHZ]->bitrates[rate->idx].hw_value;
+       band = wdev->hw->wiphy->bands[NL80211_BAND_2GHZ];
+       return band->bitrates[rate->idx].hw_value;
 }
 
 /* TX policy cache implementation */
 {
        struct tx_policy *policies = wvif->tx_policy_cache.cache;
        u8 tmp_rates[12];
-       int i;
+       int i, is_used;
 
        do {
                spin_lock_bh(&wvif->tx_policy_cache.lock);
-               for (i = 0; i < HIF_TX_RETRY_POLICY_MAX; ++i)
-                       if (!policies[i].uploaded &&
-                           memzcmp(policies[i].rates, sizeof(policies[i].rates)))
+               for (i = 0; i < HIF_TX_RETRY_POLICY_MAX; ++i) {
+                       is_used = memzcmp(policies[i].rates,
+                                         sizeof(policies[i].rates));
+                       if (!policies[i].uploaded && is_used)
                                break;
+               }
                if (i < HIF_TX_RETRY_POLICY_MAX) {
                        policies[i].uploaded = true;
                        memcpy(tmp_rates, policies[i].rates, sizeof(tmp_rates));
                if (rates[i].idx == -1) {
                        rates[i].idx = 0;
                        rates[i].count = 8; // == hw->max_rate_tries
-                       rates[i].flags = rates[i - 1].flags & IEEE80211_TX_RC_MCS;
+                       rates[i].flags = rates[i - 1].flags &
+                                        IEEE80211_TX_RC_MCS;
                        break;
                }
        }
        return rate_id;
 }
 
-static struct hif_ht_tx_parameters wfx_tx_get_tx_parms(struct wfx_dev *wdev, struct ieee80211_tx_info *tx_info)
+static struct hif_ht_tx_parameters wfx_tx_get_tx_parms(struct wfx_dev *wdev,
+                                                      struct ieee80211_tx_info *tx_info)
 {
        struct ieee80211_tx_rate *rate = &tx_info->driver_rates[0];
        struct hif_ht_tx_parameters ret = { };
        hif_msg->id = HIF_REQ_ID_TX;
        hif_msg->interface = wvif->id;
        if (skb->len > wvif->wdev->hw_caps.size_inp_ch_buf) {
-               dev_warn(wvif->wdev->dev, "requested frame size (%d) is larger than maximum supported (%d)\n",
+               dev_warn(wvif->wdev->dev,
+                        "requested frame size (%d) is larger than maximum supported (%d)\n",
                         skb->len, wvif->wdev->hw_caps.size_inp_ch_buf);
                skb_pull(skb, wmsg_len);
                return -EIO;
        // packet_id just need to be unique on device. 32bits are more than
        // necessary for that task, so we tae advantage of it to add some extra
        // data for debug.
-       req->packet_id = queue_id << 28 |
-                        IEEE80211_SEQ_TO_SN(le16_to_cpu(hdr->seq_ctrl)) << 16 |
-                        (atomic_add_return(1, &wvif->wdev->packet_id) & 0xFFFF);
+       req->packet_id = atomic_add_return(1, &wvif->wdev->packet_id) & 0xFFFF;
+       req->packet_id |= IEEE80211_SEQ_TO_SN(le16_to_cpu(hdr->seq_ctrl)) << 16;
+       req->packet_id |= queue_id << 28;
+
        req->data_flags.fc_offset = offset;
        if (tx_info->flags & IEEE80211_TX_CTL_SEND_AFTER_DTIM)
                req->data_flags.after_dtim = 1;
                if (tx_count < rate->count &&
                    arg->status == HIF_STATUS_RETRY_EXCEEDED &&
                    arg->ack_failures)
-                       dev_dbg(wvif->wdev->dev, "all retries were not consumed: %d != %d\n",
+                       dev_dbg(wvif->wdev->dev,
+                               "all retries were not consumed: %d != %d\n",
                                rate->count, tx_count);
                if (tx_count <= rate->count && tx_count &&
                    arg->txed_rate != wfx_get_hw_rate(wvif->wdev, rate))
                else
                        tx_info->flags |= IEEE80211_TX_STAT_ACK;
        } else if (arg->status == HIF_REQUEUE) {
-               WARN(!arg->tx_result_flags.requeue, "incoherent status and result_flags");
+               WARN(!arg->tx_result_flags.requeue,
+                    "incoherent status and result_flags");
                if (tx_info->flags & IEEE80211_TX_CTL_SEND_AFTER_DTIM) {
                        wvif->after_dtim_tx_allowed = false; // DTIM period elapsed
                        schedule_work(&wvif->update_tim_work);
                if (wait_event_timeout(wdev->tx_dequeue,
                                       wfx_tx_queue_empty(wdev, queue, vif_id),
                                       msecs_to_jiffies(1000)) <= 0)
-                       dev_warn(wdev->dev, "frames queued while flushing tx queues?");
+                       dev_warn(wdev->dev,
+                                "frames queued while flushing tx queues?");
        }
        wfx_tx_flush(wdev);
        if (wdev->chip_frozen)