From: Arsenii Pashchenko <ulijg308@gmail.com>
To: pkshih@realtek.com
Cc: linux-wireless@vger.kernel.org, linux-kernel@vger.kernel.org,
Arsenii Pashchenko <ulijg308@gmail.com>
Subject: [PATCH wireless-next v2 3/4] wifi: rtw88: rtw8822c: switch to the kernel's sort() library
Date: Thu, 13 Aug 2026 12:47:31 +0700 [thread overview]
Message-ID: <4a0b85003aac26b23fcfc6e414e00b39e0d2aa45.1786599645.git.ulijg308@gmail.com> (raw)
In-Reply-To: <cover.1786599645.git.ulijg308@gmail.com>
Replace the custom, nested bubble-sort logic in rtw8822c_dac_iq_sort()
and __rtw8822c_dac_iq_sort() with a call to the kernel's optimized
heapsort implementation.
Implement a concise, localized s32 comparator. Since the previous
patch already guarantees that input values are properly sign-extended
into signed arrays, the custom circular index sorting rules completely
disappear, trimming down lines of code.
Signed-off-by: Arsenii Pashchenko <ulijg308@gmail.com>
---
drivers/net/wireless/realtek/rtw88/rtw8822c.c | 28 ++++++-------------
1 file changed, 8 insertions(+), 20 deletions(-)
diff --git a/drivers/net/wireless/realtek/rtw88/rtw8822c.c b/drivers/net/wireless/realtek/rtw88/rtw8822c.c
index d06986d09..642ac2e2b 100644
--- a/drivers/net/wireless/realtek/rtw88/rtw8822c.c
+++ b/drivers/net/wireless/realtek/rtw88/rtw8822c.c
@@ -4,6 +4,7 @@
#include <linux/module.h>
#include <linux/bitops.h>
+#include <linux/sort.h>
#include "main.h"
#include "coex.h"
#include "fw.h"
@@ -186,31 +187,18 @@ static void rtw8822c_rf_minmax_cmp(struct rtw_dev *rtwdev, s32 value_s32,
}
}
-static void __rtw8822c_dac_iq_sort(struct rtw_dev *rtwdev, s32 *v1_s32, s32 *v2_s32)
+static int rtw8822c_dac_iq_cmp_s32(const void *a, const void *b)
{
- u32 *v1 = (u32 *)v1_s32;
- u32 *v2 = (u32 *)v2_s32;
- if (*v1 >= 0x200 && *v2 >= 0x200) {
- if (*v1 > *v2)
- swap(*v1, *v2);
- } else if (*v1 < 0x200 && *v2 < 0x200) {
- if (*v1 > *v2)
- swap(*v1, *v2);
- } else if (*v1 < 0x200 && *v2 >= 0x200) {
- swap(*v1, *v2);
- }
+ s32 va = *(const s32 *)a;
+ s32 vb = *(const s32 *)b;
+
+ return (va > vb) - (va < vb);
}
static void rtw8822c_dac_iq_sort(struct rtw_dev *rtwdev, s32 *iv, s32 *qv)
{
- u32 i, j;
-
- for (i = 0; i < DACK_SN_8822C - 1; i++) {
- for (j = 0; j < (DACK_SN_8822C - 1 - i) ; j++) {
- __rtw8822c_dac_iq_sort(rtwdev, &iv[j], &iv[j + 1]);
- __rtw8822c_dac_iq_sort(rtwdev, &qv[j], &qv[j + 1]);
- }
- }
+ sort(iv, DACK_SN_8822C, sizeof(s32), rtw8822c_dac_iq_cmp_s32, NULL);
+ sort(qv, DACK_SN_8822C, sizeof(s32), rtw8822c_dac_iq_cmp_s32, NULL);
}
static void rtw8822c_dac_iq_offset(struct rtw_dev *rtwdev, s32 *vec_s32, u32 *val)
--
2.55.0
next prev parent reply other threads:[~2026-08-13 5:48 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-08-13 5:47 [PATCH wireless-next v2 0/4] wifi: rtw88: rtw8822c: refactor DAC IQ calibration to s32 Arsenii Pashchenko
2026-08-13 5:47 ` [PATCH wireless-next v2 1/4] wifi: rtw88: rtw8822c: convert DAC IQ buffers and signatures " Arsenii Pashchenko
2026-08-13 5:47 ` [PATCH wireless-next v2 2/4] wifi: rtw88: rtw8822c: use sign_extend32 for DAC IQ validation Arsenii Pashchenko
2026-08-13 5:47 ` Arsenii Pashchenko [this message]
2026-08-13 5:47 ` [PATCH wireless-next v2 4/4] wifi: rtw88: rtw8822c: simplify amplitude search and offset via s32 Arsenii Pashchenko
2026-08-13 5:54 ` [PATCH wireless-next v2 0/4] wifi: rtw88: rtw8822c: refactor DAC IQ calibration to s32 Ping-Ke Shih
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=4a0b85003aac26b23fcfc6e414e00b39e0d2aa45.1786599645.git.ulijg308@gmail.com \
--to=ulijg308@gmail.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-wireless@vger.kernel.org \
--cc=pkshih@realtek.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®