]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
wifi: ath9k: Use swap() to improve ath9k_hw_get_nf_hist_mid()
authorThorsten Blum <thorsten.blum@toblux.com>
Wed, 10 Jul 2024 18:57:44 +0000 (20:57 +0200)
committerKalle Valo <quic_kvalo@quicinc.com>
Thu, 1 Aug 2024 14:59:20 +0000 (17:59 +0300)
Use the swap() macro to simplify the ath9k_hw_get_nf_hist_mid() function
and improve its readability.

Fixes the following Coccinelle/coccicheck warning reported by
swap.cocci:

  WARNING opportunity for swap()

Compile-tested only.

Signed-off-by: Thorsten Blum <thorsten.blum@toblux.com>
Acked-by: Toke Høiland-Jørgensen <toke@toke.dk>
Signed-off-by: Kalle Valo <quic_kvalo@quicinc.com>
Link: https://patch.msgid.link/20240710185743.709742-2-thorsten.blum@toblux.com
drivers/net/wireless/ath/ath9k/calib.c

index fb270df75eb2d3c486ba040edffe2b4dad07d9b4..4b331c85509cf6148b2b2d9415b2eaf9b393d40d 100644 (file)
@@ -32,11 +32,8 @@ static int16_t ath9k_hw_get_nf_hist_mid(int16_t *nfCalBuffer)
 
        for (i = 0; i < ATH9K_NF_CAL_HIST_MAX - 1; i++) {
                for (j = 1; j < ATH9K_NF_CAL_HIST_MAX - i; j++) {
-                       if (sort[j] > sort[j - 1]) {
-                               nfval = sort[j];
-                               sort[j] = sort[j - 1];
-                               sort[j - 1] = nfval;
-                       }
+                       if (sort[j] > sort[j - 1])
+                               swap(sort[j], sort[j - 1]);
                }
        }
        nfval = sort[(ATH9K_NF_CAL_HIST_MAX - 1) >> 1];