Larry Finger <[email protected]> writes:
> From: Ping-Ke Shih <[email protected]>
>
> We use H2C to ask BT's status, and C2H will return the status.
>
> Signed-off-by: Ping-Ke Shih <[email protected]>
> Signed-off-by: Larry Finger <[email protected]>
> Cc: Yan-Hsuan Chuang <[email protected]>
> Cc: Birming Chiu <[email protected]>
> Cc: Shaofu <[email protected]>
> Cc: Steven Ting <[email protected]>
[...]
> --- a/drivers/net/wireless/realtek/rtlwifi/btcoexist/halbtcoutsrc.c
> +++ b/drivers/net/wireless/realtek/rtlwifi/btcoexist/halbtcoutsrc.c
> @@ -327,7 +327,22 @@ static void halbtc_aggregation_check(struct btc_coexist
> *btcoexist)
>
> static u32 halbtc_get_bt_patch_version(struct btc_coexist *btcoexist)
> {
> - return 0;
> + struct rtl_priv *rtlpriv = btcoexist->adapter;
> + u8 cmd_buffer[4] = {0};
> + u8 oper_ver = 0;
> + u8 req_num = 0x0E;
> +
> + if (btcoexist->bt_info.bt_real_fw_ver)
> + goto label_done;
> +
> + cmd_buffer[0] |= (oper_ver & 0x0f); /* Set OperVer */
> + cmd_buffer[0] |= ((req_num << 4) & 0xf0); /* Set ReqNum */
> + cmd_buffer[1] = 0; /* BT_OP_GET_BT_VERSION = 0 */
> + rtlpriv->cfg->ops->fill_h2c_cmd(rtlpriv->mac80211.hw, 0x67, 4,
> + &cmd_buffer[0]);
> +
> +label_done:
> + return btcoexist->bt_info.bt_real_fw_ver;
> }
I don't remember if I have mentioned before but there's way too much
magic numbers. There should an enum for all req_num values and
cmd_buffer should be a struct so that is serves as documentation at the
same time. No need to resend because of this but take this into account
in the future.
As an example rsi driver is having similar problems and Prameela is
fixing those:
https://patchwork.kernel.org/patch/9832895/
--
Kalle Valo