mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Erick Karanja <karanja99erick@gmail.com>
To: gregkh@linuxfoundation.org, outreachy@lists.linux.dev
Cc: karanja99erick@gmail.com, philipp.g.hortmann@gmail.com,
	linux-staging@lists.linux.dev, linux-kernel@vger.kernel.org
Subject: [PATCH 5/6] staging: rtl8723bs: Initialize variables at declaration in hal_btcoex.c
Date: Thu, 10 Apr 2025 16:06:10 +0300	[thread overview]
Message-ID: <b6aeed41cce1dba2bf8a6afdbec95d4bdd789260.1744285781.git.karanja99erick@gmail.com> (raw)
In-Reply-To: <cover.1744285781.git.karanja99erick@gmail.com>

Make the code more concise and readable by integrating the initialization
directly into the variable declaration in cases where the initialization
is simple and doesn't depend on other variables or complex expressions.

Signed-off-by: Erick Karanja <karanja99erick@gmail.com>
---
 drivers/staging/rtl8723bs/hal/hal_btcoex.c | 174 ++++++---------------
 1 file changed, 45 insertions(+), 129 deletions(-)

diff --git a/drivers/staging/rtl8723bs/hal/hal_btcoex.c b/drivers/staging/rtl8723bs/hal/hal_btcoex.c
index 9105594d2dde..b29c6cdf2e21 100644
--- a/drivers/staging/rtl8723bs/hal/hal_btcoex.c
+++ b/drivers/staging/rtl8723bs/hal/hal_btcoex.c
@@ -28,10 +28,7 @@ static u8 halbtcoutsrc_IsBtCoexistAvailable(struct btc_coexist *pBtCoexist)
 
 static void halbtcoutsrc_LeaveLps(struct btc_coexist *pBtCoexist)
 {
-	struct adapter *padapter;
-
-
-	padapter = pBtCoexist->Adapter;
+	struct adapter *padapter = pBtCoexist->Adapter;
 
 	pBtCoexist->btInfo.bBtCtrlLps = true;
 	pBtCoexist->btInfo.bBtLpsOn = false;
@@ -41,10 +38,7 @@ static void halbtcoutsrc_LeaveLps(struct btc_coexist *pBtCoexist)
 
 static void halbtcoutsrc_EnterLps(struct btc_coexist *pBtCoexist)
 {
-	struct adapter *padapter;
-
-
-	padapter = pBtCoexist->Adapter;
+	struct adapter *padapter = pBtCoexist->Adapter;
 
 	pBtCoexist->btInfo.bBtCtrlLps = true;
 	pBtCoexist->btInfo.bBtLpsOn = true;
@@ -54,9 +48,7 @@ static void halbtcoutsrc_EnterLps(struct btc_coexist *pBtCoexist)
 
 static void halbtcoutsrc_NormalLps(struct btc_coexist *pBtCoexist)
 {
-	struct adapter *padapter;
-
-	padapter = pBtCoexist->Adapter;
+	struct adapter *padapter = pBtCoexist->Adapter;
 
 	if (pBtCoexist->btInfo.bBtCtrlLps) {
 		pBtCoexist->btInfo.bBtLpsOn = false;
@@ -73,15 +65,13 @@ static void halbtcoutsrc_NormalLps(struct btc_coexist *pBtCoexist)
  */
 static void halbtcoutsrc_LeaveLowPower(struct btc_coexist *pBtCoexist)
 {
-	struct adapter *padapter;
-	s32 ready;
+	struct adapter *padapter = pBtCoexist->Adapter;
+	s32 ready = _FAIL;
 	unsigned long stime;
 	unsigned long utime;
 	u32 timeout; /*  unit: ms */
 
 
-	padapter = pBtCoexist->Adapter;
-	ready = _FAIL;
 #ifdef LPS_RPWM_WAIT_MS
 	timeout = LPS_RPWM_WAIT_MS;
 #else /*  !LPS_RPWM_WAIT_MS */
@@ -108,10 +98,9 @@ static void halbtcoutsrc_LeaveLowPower(struct btc_coexist *pBtCoexist)
  */
 static void halbtcoutsrc_NormalLowPower(struct btc_coexist *pBtCoexist)
 {
-	struct adapter *padapter;
+	struct adapter *padapter = pBtCoexist->Adapter;
 
 
-	padapter = pBtCoexist->Adapter;
 	rtw_unregister_task_alive(padapter, BTCOEX_ALIVE);
 }
 
@@ -126,12 +115,8 @@ static void halbtcoutsrc_DisableLowPower(struct btc_coexist *pBtCoexist, u8 bLow
 
 static void halbtcoutsrc_AggregationCheck(struct btc_coexist *pBtCoexist)
 {
-	struct adapter *padapter;
-	bool bNeedToAct;
-
-
-	padapter = pBtCoexist->Adapter;
-	bNeedToAct = false;
+	struct adapter *padapter = pBtCoexist->Adapter;
+	bool bNeedToAct = false;
 
 	if (pBtCoexist->btInfo.bRejectAggPkt) {
 		rtw_btcoex_RejectApAggregatedPacket(padapter, true);
@@ -176,14 +161,9 @@ static u8 halbtcoutsrc_IsWifiBusy(struct adapter *padapter)
 
 static u32 _halbtcoutsrc_GetWifiLinkStatus(struct adapter *padapter)
 {
-	struct mlme_priv *pmlmepriv;
-	u8 bp2p;
-	u32 portConnectedStatus;
-
-
-	pmlmepriv = &padapter->mlmepriv;
-	bp2p = false;
-	portConnectedStatus = 0;
+	struct mlme_priv *pmlmepriv = &padapter->mlmepriv;
+	u8 bp2p = false;
+	u32 portConnectedStatus = 0;
 
 	if (check_fwstate(pmlmepriv, WIFI_ASOC_STATE) == true) {
 		if (check_fwstate(pmlmepriv, WIFI_AP_STATE) == true) {
@@ -210,14 +190,9 @@ static u32 halbtcoutsrc_GetWifiLinkStatus(struct btc_coexist *pBtCoexist)
 	/*  [15:0]=> port connected bit define */
 	/*  */
 
-	struct adapter *padapter;
+	struct adapter *padapter = pBtCoexist->Adapter;
 	u32 retVal;
-	u32 portConnectedStatus, numOfConnectedPort;
-
-
-	padapter = pBtCoexist->Adapter;
-	portConnectedStatus = 0;
-	numOfConnectedPort = 0;
+	u32 portConnectedStatus = 0, numOfConnectedPort = 0;
 
 	retVal = _halbtcoutsrc_GetWifiLinkStatus(padapter);
 	if (retVal) {
@@ -244,11 +219,9 @@ static s32 halbtcoutsrc_GetWifiRssi(struct adapter *padapter)
 
 static u8 halbtcoutsrc_GetWifiScanAPNum(struct adapter *padapter)
 {
-	struct mlme_ext_priv *pmlmeext;
+	struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv;
 	static u8 scan_AP_num;
 
-	pmlmeext = &padapter->mlmeextpriv;
-
 	if (!GLBtcWiFiInScanState) {
 		if (pmlmeext->sitesurvey_res.bss_cnt > 0xFF)
 			scan_AP_num = 0xFF;
@@ -363,8 +336,7 @@ static u8 halbtcoutsrc_Get(void *pBtcContext, u8 getType, void *pOutBuf)
 
 	case BTC_GET_U4_WIFI_TRAFFIC_DIRECTION:
 		{
-			struct rt_link_detect_t *plinkinfo;
-			plinkinfo = &padapter->mlmepriv.LinkDetectInfo;
+			struct rt_link_detect_t *plinkinfo = &padapter->mlmepriv.LinkDetectInfo;
 
 			if (plinkinfo->NumTxOkInPeriod > plinkinfo->NumRxOkInPeriod)
 				*pU4Tmp = BTC_WIFI_TRAFFIC_TX;
@@ -425,16 +397,13 @@ static u8 halbtcoutsrc_Get(void *pBtcContext, u8 getType, void *pOutBuf)
 
 static u8 halbtcoutsrc_Set(void *pBtcContext, u8 setType, void *pInBuf)
 {
-	struct btc_coexist *pBtCoexist;
-	struct adapter *padapter;
-	u8 *pu8;
+	struct btc_coexist *pBtCoexist = (struct btc_coexist *)pBtcContext;
+	struct adapter *padapter = pBtCoexist->Adapter;
+	u8 *pu8 = pInBuf;
 	u32 *pU4Tmp;
 	u8 ret;
 
 
-	pBtCoexist = (struct btc_coexist *)pBtcContext;
-	padapter = pBtCoexist->Adapter;
-	pu8 = pInBuf;
 	pU4Tmp = pInBuf;
 	ret = true;
 
@@ -565,65 +534,43 @@ static u8 halbtcoutsrc_Set(void *pBtcContext, u8 setType, void *pInBuf)
 /*  */
 static u8 halbtcoutsrc_Read1Byte(void *pBtcContext, u32 RegAddr)
 {
-	struct btc_coexist *pBtCoexist;
-	struct adapter *padapter;
-
-
-	pBtCoexist = (struct btc_coexist *)pBtcContext;
-	padapter = pBtCoexist->Adapter;
+	struct btc_coexist *pBtCoexist = (struct btc_coexist *)pBtcContext;
+	struct adapter *padapter = pBtCoexist->Adapter;
 
 	return rtw_read8(padapter, RegAddr);
 }
 
 static u16 halbtcoutsrc_Read2Byte(void *pBtcContext, u32 RegAddr)
 {
-	struct btc_coexist *pBtCoexist;
-	struct adapter *padapter;
-
-
-	pBtCoexist = (struct btc_coexist *)pBtcContext;
-	padapter = pBtCoexist->Adapter;
+	struct btc_coexist *pBtCoexist = (struct btc_coexist *)pBtcContext;
+	struct adapter *padapter = pBtCoexist->Adapter;
 
 	return	rtw_read16(padapter, RegAddr);
 }
 
 static u32 halbtcoutsrc_Read4Byte(void *pBtcContext, u32 RegAddr)
 {
-	struct btc_coexist *pBtCoexist;
-	struct adapter *padapter;
-
-
-	pBtCoexist = (struct btc_coexist *)pBtcContext;
-	padapter = pBtCoexist->Adapter;
+	struct btc_coexist *pBtCoexist = (struct btc_coexist *)pBtcContext;
+	struct adapter *padapter = pBtCoexist->Adapter;
 
 	return	rtw_read32(padapter, RegAddr);
 }
 
 static void halbtcoutsrc_Write1Byte(void *pBtcContext, u32 RegAddr, u8 Data)
 {
-	struct btc_coexist *pBtCoexist;
-	struct adapter *padapter;
-
-
-	pBtCoexist = (struct btc_coexist *)pBtcContext;
-	padapter = pBtCoexist->Adapter;
+	struct btc_coexist *pBtCoexist = (struct btc_coexist *)pBtcContext;
+	struct adapter *padapter = pBtCoexist->Adapter;
 
 	rtw_write8(padapter, RegAddr, Data);
 }
 
 static void halbtcoutsrc_BitMaskWrite1Byte(void *pBtcContext, u32 regAddr, u8 bitMask, u8 data1b)
 {
-	struct btc_coexist *pBtCoexist;
-	struct adapter *padapter;
-	u8 originalValue, bitShift;
+	struct btc_coexist *pBtCoexist = (struct btc_coexist *)pBtcContext;
+	struct adapter *padapter = pBtCoexist->Adapter;
+	u8 originalValue = 0, bitShift = 0;
 	u8 i;
 
-
-	pBtCoexist = (struct btc_coexist *)pBtcContext;
-	padapter = pBtCoexist->Adapter;
-	originalValue = 0;
-	bitShift = 0;
-
 	if (bitMask != 0xFF) {
 		originalValue = rtw_read8(padapter, regAddr);
 
@@ -641,24 +588,16 @@ static void halbtcoutsrc_BitMaskWrite1Byte(void *pBtcContext, u32 regAddr, u8 bi
 
 static void halbtcoutsrc_Write2Byte(void *pBtcContext, u32 RegAddr, u16 Data)
 {
-	struct btc_coexist *pBtCoexist;
-	struct adapter *padapter;
-
-
-	pBtCoexist = (struct btc_coexist *)pBtcContext;
-	padapter = pBtCoexist->Adapter;
+	struct btc_coexist *pBtCoexist = (struct btc_coexist *)pBtcContext;
+	struct adapter *padapter = pBtCoexist->Adapter;
 
 	rtw_write16(padapter, RegAddr, Data);
 }
 
 static void halbtcoutsrc_Write4Byte(void *pBtcContext, u32 RegAddr, u32 Data)
 {
-	struct btc_coexist *pBtCoexist;
-	struct adapter *padapter;
-
-
-	pBtCoexist = (struct btc_coexist *)pBtcContext;
-	padapter = pBtCoexist->Adapter;
+	struct btc_coexist *pBtCoexist = (struct btc_coexist *)pBtcContext;
+	struct adapter *padapter = pBtCoexist->Adapter;
 
 	rtw_write32(padapter, RegAddr, Data);
 }
@@ -676,12 +615,8 @@ static void halbtcoutsrc_WriteLocalReg1Byte(void *pBtcContext, u32 RegAddr, u8 D
 
 static void halbtcoutsrc_SetBbReg(void *pBtcContext, u32 RegAddr, u32 BitMask, u32 Data)
 {
-	struct btc_coexist *pBtCoexist;
-	struct adapter *padapter;
-
-
-	pBtCoexist = (struct btc_coexist *)pBtcContext;
-	padapter = pBtCoexist->Adapter;
+	struct btc_coexist *pBtCoexist = (struct btc_coexist *)pBtcContext;
+	struct adapter *padapter = pBtCoexist->Adapter;
 
 	PHY_SetBBReg(padapter, RegAddr, BitMask, Data);
 }
@@ -689,44 +624,32 @@ static void halbtcoutsrc_SetBbReg(void *pBtcContext, u32 RegAddr, u32 BitMask, u
 
 static u32 halbtcoutsrc_GetBbReg(void *pBtcContext, u32 RegAddr, u32 BitMask)
 {
-	struct btc_coexist *pBtCoexist;
-	struct adapter *padapter;
-
-
-	pBtCoexist = (struct btc_coexist *)pBtcContext;
-	padapter = pBtCoexist->Adapter;
+	struct btc_coexist *pBtCoexist = (struct btc_coexist *)pBtcContext;
+	struct adapter *padapter = pBtCoexist->Adapter;
 
 	return PHY_QueryBBReg(padapter, RegAddr, BitMask);
 }
 
 static void halbtcoutsrc_SetRfReg(void *pBtcContext, u8 eRFPath, u32 RegAddr, u32 BitMask, u32 Data)
 {
-	struct btc_coexist *pBtCoexist;
-	struct adapter *padapter;
-
-
-	pBtCoexist = (struct btc_coexist *)pBtcContext;
-	padapter = pBtCoexist->Adapter;
+	struct btc_coexist *pBtCoexist = (struct btc_coexist *)pBtcContext;
+	struct adapter *padapter = pBtCoexist->Adapter;
 
 	PHY_SetRFReg(padapter, eRFPath, RegAddr, BitMask, Data);
 }
 
 static u32 halbtcoutsrc_GetRfReg(void *pBtcContext, u8 eRFPath, u32 RegAddr, u32 BitMask)
 {
-	struct btc_coexist *pBtCoexist;
-	struct adapter *padapter;
-
-
-	pBtCoexist = (struct btc_coexist *)pBtcContext;
-	padapter = pBtCoexist->Adapter;
+	struct btc_coexist *pBtCoexist = (struct btc_coexist *)pBtcContext;
+	struct adapter *padapter = pBtCoexist->Adapter;
 
 	return PHY_QueryRFReg(padapter, eRFPath, RegAddr, BitMask);
 }
 
 static void halbtcoutsrc_SetBtReg(void *pBtcContext, u8 RegType, u32 RegAddr, u32 Data)
 {
-	struct btc_coexist *pBtCoexist;
-	struct adapter *padapter;
+	struct btc_coexist *pBtCoexist = (struct btc_coexist *)pBtcContext;
+	struct adapter *padapter = pBtCoexist->Adapter;
 	u8 CmdBuffer1[4] = {0};
 	u8 CmdBuffer2[4] = {0};
 	u8 *AddrToSet = (u8 *)&RegAddr;
@@ -734,9 +657,6 @@ static void halbtcoutsrc_SetBtReg(void *pBtcContext, u8 RegType, u32 RegAddr, u3
 	u8 OperVer = 0;
 	u8 ReqNum = 0;
 
-	pBtCoexist = (struct btc_coexist *)pBtcContext;
-	padapter = pBtCoexist->Adapter;
-
 	CmdBuffer1[0] |= (OperVer & 0x0f);						/* Set OperVer */
 	CmdBuffer1[0] |= ((ReqNum << 4) & 0xf0);				/* Set ReqNum */
 	CmdBuffer1[1] = 0x0d;									/* Set OpCode to BT_LO_OP_WRITE_REG_VALUE */
@@ -761,12 +681,8 @@ static u32 halbtcoutsrc_GetBtReg(void *pBtcContext, u8 RegType, u32 RegAddr)
 
 static void halbtcoutsrc_FillH2cCmd(void *pBtcContext, u8 elementId, u32 cmdLen, u8 *pCmdBuffer)
 {
-	struct btc_coexist *pBtCoexist;
-	struct adapter *padapter;
-
-
-	pBtCoexist = (struct btc_coexist *)pBtcContext;
-	padapter = pBtCoexist->Adapter;
+	struct btc_coexist *pBtCoexist = (struct btc_coexist *)pBtcContext;
+	struct adapter *padapter = pBtCoexist->Adapter;
 
 	rtw_hal_fill_h2c_cmd(padapter, elementId, cmdLen, pCmdBuffer);
 }
-- 
2.43.0


  parent reply	other threads:[~2025-04-10 13:06 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-04-10 13:06 [PATCH 0/6] Improve code readability in rtl8723bs module Erick Karanja
2025-04-10 13:06 ` [PATCH 1/6] staging: rtl8723bs: Improve code readability in sdio_ops.c Erick Karanja
2025-04-10 13:06 ` [PATCH 2/6] staging: rtl8723bs: Initialize variables at declaration in odm_HWConfig.c Erick Karanja
2025-04-12 17:36   ` Dan Carpenter
2025-04-10 13:06 ` [PATCH 3/6] staging: rtl8723bs: Initialize variables at declaration in hal_com.c Erick Karanja
2025-04-10 13:06 ` [PATCH 4/6] staging: rtl8723bs: Initialize variables at declaration in sdio_halinit.c Erick Karanja
2025-04-10 13:06 ` Erick Karanja [this message]
2025-04-10 13:06 ` [PATCH 6/6] staging: rtl8723bs: Initialize variables at declaration in rtl8723bs_recv.c Erick Karanja

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=b6aeed41cce1dba2bf8a6afdbec95d4bdd789260.1744285781.git.karanja99erick@gmail.com \
    --to=karanja99erick@gmail.com \
    --cc=gregkh@linuxfoundation.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-staging@lists.linux.dev \
    --cc=outreachy@lists.linux.dev \
    --cc=philipp.g.hortmann@gmail.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®