]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
wifi: mt76: mt7925: refactor CLC support check flow
authorMing Yen Hsieh <mingyen.hsieh@mediatek.com>
Fri, 31 Oct 2025 09:03:48 +0000 (17:03 +0800)
committerFelix Fietkau <nbd@nbd.name>
Mon, 24 Nov 2025 13:37:55 +0000 (14:37 +0100)
Move the disable_clc module parameter to regd.c and introduce
mt7925_regd_clc_supported() to centralize CLC support checks.

Signed-off-by: Ming Yen Hsieh <mingyen.hsieh@mediatek.com>
Link: https://patch.msgid.link/20251031090352.1400079-3-mingyen.hsieh@mediatek.com
Signed-off-by: Felix Fietkau <nbd@nbd.name>
drivers/net/wireless/mediatek/mt76/mt7925/mcu.c
drivers/net/wireless/mediatek/mt76/mt7925/regd.c
drivers/net/wireless/mediatek/mt76/mt7925/regd.h

index 620f61abee0b793c1bfcc01c35c6d040ecccc553..983766faa9725024f43d70e60f018027aa4f76e1 100644 (file)
@@ -4,16 +4,13 @@
 #include <linux/fs.h>
 #include <linux/firmware.h>
 #include "mt7925.h"
+#include "regd.h"
 #include "mcu.h"
 #include "mac.h"
 
 #define MT_STA_BFER                    BIT(0)
 #define MT_STA_BFEE                    BIT(1)
 
-static bool mt7925_disable_clc;
-module_param_named(disable_clc, mt7925_disable_clc, bool, 0644);
-MODULE_PARM_DESC(disable_clc, "disable CLC support");
-
 int mt7925_mcu_parse_response(struct mt76_dev *mdev, int cmd,
                              struct sk_buff *skb, int seq)
 {
@@ -688,8 +685,7 @@ static int mt7925_load_clc(struct mt792x_dev *dev, const char *fw_name)
        int ret, i, len, offset = 0;
 
        dev->phy.clc_chan_conf = 0xff;
-       if (mt7925_disable_clc ||
-           mt76_is_usb(&dev->mt76))
+       if (!mt7925_regd_clc_supported(dev))
                return 0;
 
        if (mt76_is_mmio(&dev->mt76)) {
@@ -3383,6 +3379,9 @@ int mt7925_mcu_set_clc(struct mt792x_dev *dev, u8 *alpha2,
        struct mt792x_phy *phy = (struct mt792x_phy *)&dev->phy;
        int i, ret;
 
+       if (!ARRAY_SIZE(phy->clc))
+               return -ESRCH;
+
        /* submit all clc config */
        for (i = 0; i < ARRAY_SIZE(phy->clc); i++) {
                if (i == MT792x_CLC_BE_CTRL)
index 8d7ce274adcd4acde6321300c0ade3423d3e5703..9e7b468a82289a6cbbd527cde0c09de3ede2388e 100644 (file)
@@ -5,6 +5,19 @@
 #include "regd.h"
 #include "mcu.h"
 
+static bool mt7925_disable_clc;
+module_param_named(disable_clc, mt7925_disable_clc, bool, 0644);
+MODULE_PARM_DESC(disable_clc, "disable CLC support");
+
+bool mt7925_regd_clc_supported(struct mt792x_dev *dev)
+{
+       if (mt7925_disable_clc ||
+           mt76_is_usb(&dev->mt76))
+               return false;
+
+       return true;
+}
+
 void mt7925_regd_be_ctrl(struct mt792x_dev *dev, u8 *alpha2)
 {
        struct mt792x_phy *phy = &dev->phy;
index a504e71472fdbc05ba84cf937a85c2f226abf467..5977e068c1c61b0516138e919b90e2b9c1d82c39 100644 (file)
@@ -9,6 +9,7 @@
 void mt7925_regd_be_ctrl(struct mt792x_dev *dev, u8 *alpha2);
 void mt7925_regd_update(struct mt792x_dev *dev);
 void mt7925_regd_notifier(struct wiphy *wiphy, struct regulatory_request *req);
+bool mt7925_regd_clc_supported(struct mt792x_dev *dev);
 
 #endif