rtw88: make rtw_chip_ops::set_antenna return int
authorYan-Hsuan Chuang <yhchuang@realtek.com>
Fri, 10 Apr 2020 10:09:49 +0000 (18:09 +0800)
committerKalle Valo <kvalo@codeaurora.org>
Wed, 15 Apr 2020 08:40:02 +0000 (11:40 +0300)
To support ieee80211_ops::set_antenna, the driver can decide if the
antenna mask is accepted, otherwise it can return an error code.
Because each chip could have different limitations, let the chip
check the mask and return.

Also the antenna mask for TRX from upper space is 32-bit long.
Change the antenna mask for rtw_chip_ops::set_antenna from u8 to u32.

Signed-off-by: Yan-Hsuan Chuang <yhchuang@realtek.com>
Signed-off-by: Kalle Valo <kvalo@codeaurora.org>
Link: https://lore.kernel.org/r/20200410100950.3199-2-yhchuang@realtek.com
drivers/net/wireless/realtek/rtw88/main.h
drivers/net/wireless/realtek/rtw88/rtw8822b.c

index c6b590fdb573b459d013fb85380ae028fb55ca5e..c9edcabd7c42ab77baaa4dac1f4fd76ca2454af1 100644 (file)
@@ -798,8 +798,9 @@ struct rtw_chip_ops {
        void (*set_tx_power_index)(struct rtw_dev *rtwdev);
        int (*rsvd_page_dump)(struct rtw_dev *rtwdev, u8 *buf, u32 offset,
                              u32 size);
-       void (*set_antenna)(struct rtw_dev *rtwdev, u8 antenna_tx,
-                           u8 antenna_rx);
+       int (*set_antenna)(struct rtw_dev *rtwdev,
+                          u32 antenna_tx,
+                          u32 antenna_rx);
        void (*cfg_ldo25)(struct rtw_dev *rtwdev, bool enable);
        void (*false_alarm_statistics)(struct rtw_dev *rtwdev);
        void (*phy_calibration)(struct rtw_dev *rtwdev);
@@ -1567,8 +1568,8 @@ struct rtw_hal {
        u8 sec_ch_offset;
        u8 rf_type;
        u8 rf_path_num;
-       u8 antenna_tx;
-       u8 antenna_rx;
+       u32 antenna_tx;
+       u32 antenna_rx;
        u8 bfee_sts_cap;
 
        /* protect tx power section */
index 4dd7d4143b045522001632795c5ed298aa619abf..c02f3a73036914dc4db38946803c9d04d9c68f3e 100644 (file)
@@ -998,8 +998,9 @@ static bool rtw8822b_check_rf_path(u8 antenna)
        }
 }
 
-static void rtw8822b_set_antenna(struct rtw_dev *rtwdev, u8 antenna_tx,
-                                u8 antenna_rx)
+static int rtw8822b_set_antenna(struct rtw_dev *rtwdev,
+                               u32 antenna_tx,
+                               u32 antenna_rx)
 {
        struct rtw_hal *hal = &rtwdev->hal;
 
@@ -1007,16 +1008,21 @@ static void rtw8822b_set_antenna(struct rtw_dev *rtwdev, u8 antenna_tx,
                antenna_tx, antenna_rx);
 
        if (!rtw8822b_check_rf_path(antenna_tx)) {
-               rtw_info(rtwdev, "unsupport tx path, set to default path ab\n");
-               antenna_tx = BB_PATH_AB;
+               rtw_info(rtwdev, "unsupport tx path 0x%x\n", antenna_tx);
+               return -EINVAL;
        }
+
        if (!rtw8822b_check_rf_path(antenna_rx)) {
-               rtw_info(rtwdev, "unsupport rx path, set to default path ab\n");
-               antenna_rx = BB_PATH_AB;
+               rtw_info(rtwdev, "unsupport rx path 0x%x\n", antenna_rx);
+               return -EINVAL;
        }
+
        hal->antenna_tx = antenna_tx;
        hal->antenna_rx = antenna_rx;
+
        rtw8822b_config_trx_mode(rtwdev, antenna_tx, antenna_rx, false);
+
+       return 0;
 }
 
 static void rtw8822b_cfg_ldo25(struct rtw_dev *rtwdev, bool enable)