* [PATCH 0/6] Improve code readability in rtl8723bs module
@ 2025-04-10 13:06 Erick Karanja
2025-04-10 13:06 ` [PATCH 1/6] staging: rtl8723bs: Improve code readability in sdio_ops.c Erick Karanja
` (5 more replies)
0 siblings, 6 replies; 8+ messages in thread
From: Erick Karanja @ 2025-04-10 13:06 UTC (permalink / raw)
To: gregkh, outreachy
Cc: karanja99erick, philipp.g.hortmann, linux-staging, linux-kernel
The patchset aims at improving code readability by initializing
variables at declaration.
The patches can be applied in any sequence.
found by coccinelle.
Erick Karanja (6):
staging: rtl8723bs: Improve code readability in sdio_ops.c
staging: rtl8723bs: Initialize variables at declaration in
odm_HWConfig.c
staging: rtl8723bs: Initialize variables at declaration in hal_com.c
staging: rtl8723bs: Initialize variables at declaration in
sdio_halinit.c
staging: rtl8723bs: Initialize variables at declaration in
hal_btcoex.c
staging: rtl8723bs: Initialize variables at declaration in
rtl8723bs_recv.c
drivers/staging/rtl8723bs/hal/hal_btcoex.c | 174 +++++-------------
drivers/staging/rtl8723bs/hal/hal_com.c | 6 +-
drivers/staging/rtl8723bs/hal/odm_HWConfig.c | 3 +-
.../staging/rtl8723bs/hal/rtl8723bs_recv.c | 11 +-
drivers/staging/rtl8723bs/hal/sdio_halinit.c | 11 +-
drivers/staging/rtl8723bs/hal/sdio_ops.c | 59 ++----
6 files changed, 71 insertions(+), 193 deletions(-)
--
2.43.0
^ permalink raw reply [flat|nested] 8+ messages in thread
* [PATCH 1/6] staging: rtl8723bs: Improve code readability in sdio_ops.c
2025-04-10 13:06 [PATCH 0/6] Improve code readability in rtl8723bs module Erick Karanja
@ 2025-04-10 13:06 ` Erick Karanja
2025-04-10 13:06 ` [PATCH 2/6] staging: rtl8723bs: Initialize variables at declaration in odm_HWConfig.c Erick Karanja
` (4 subsequent siblings)
5 siblings, 0 replies; 8+ messages in thread
From: Erick Karanja @ 2025-04-10 13:06 UTC (permalink / raw)
To: gregkh, outreachy
Cc: karanja99erick, philipp.g.hortmann, linux-staging, linux-kernel
Make the code more readable by moving trivial
initializations up with the declarations instead
of wasting a line on that.
Signed-off-by: Erick Karanja <karanja99erick@gmail.com>
---
drivers/staging/rtl8723bs/hal/sdio_ops.c | 59 +++++++-----------------
1 file changed, 17 insertions(+), 42 deletions(-)
diff --git a/drivers/staging/rtl8723bs/hal/sdio_ops.c b/drivers/staging/rtl8723bs/hal/sdio_ops.c
index 8736c124f857..1e03413e242c 100644
--- a/drivers/staging/rtl8723bs/hal/sdio_ops.c
+++ b/drivers/staging/rtl8723bs/hal/sdio_ops.c
@@ -53,9 +53,8 @@ static void hal_sdio_get_cmd_addr_8723b(
static u8 get_deviceid(u32 addr)
{
u8 devide_id;
- u16 pseudo_id;
+ u16 pseudo_id = (u16)(addr >> 16);
- pseudo_id = (u16)(addr >> 16);
switch (pseudo_id) {
case 0x1025:
devide_id = SDIO_LOCAL_DEVICE_ID;
@@ -150,7 +149,7 @@ static u16 sdio_read16(struct intf_hdl *intfhdl, u32 addr)
static u32 sdio_read32(struct intf_hdl *intfhdl, u32 addr)
{
- struct adapter *adapter;
+ struct adapter *adapter = intfhdl->padapter;
u8 mac_pwr_ctrl_on;
u8 device_id;
u16 offset;
@@ -160,7 +159,6 @@ static u32 sdio_read32(struct intf_hdl *intfhdl, u32 addr)
s32 __maybe_unused err;
__le32 le_tmp;
- adapter = intfhdl->padapter;
ftaddr = _cvrt2ftaddr(addr, &device_id, &offset);
rtw_hal_get_hwreg(adapter, HW_VAR_APFM_ON_MAC, &mac_pwr_ctrl_on);
@@ -196,16 +194,13 @@ static u32 sdio_read32(struct intf_hdl *intfhdl, u32 addr)
static s32 sdio_readN(struct intf_hdl *intfhdl, u32 addr, u32 cnt, u8 *buf)
{
- struct adapter *adapter;
+ struct adapter *adapter = intfhdl->padapter;
u8 mac_pwr_ctrl_on;
u8 device_id;
u16 offset;
u32 ftaddr;
u8 shift;
- s32 err;
-
- adapter = intfhdl->padapter;
- err = 0;
+ s32 err = 0;
ftaddr = _cvrt2ftaddr(addr, &device_id, &offset);
@@ -262,18 +257,15 @@ static s32 sdio_write16(struct intf_hdl *intfhdl, u32 addr, u16 val)
static s32 sdio_write32(struct intf_hdl *intfhdl, u32 addr, u32 val)
{
- struct adapter *adapter;
+ struct adapter *adapter = intfhdl->padapter;
u8 mac_pwr_ctrl_on;
u8 device_id;
u16 offset;
u32 ftaddr;
u8 shift;
- s32 err;
+ s32 err = 0;
__le32 le_tmp;
- adapter = intfhdl->padapter;
- err = 0;
-
ftaddr = _cvrt2ftaddr(addr, &device_id, &offset);
rtw_hal_get_hwreg(adapter, HW_VAR_APFM_ON_MAC, &mac_pwr_ctrl_on);
@@ -300,16 +292,13 @@ static s32 sdio_write32(struct intf_hdl *intfhdl, u32 addr, u32 val)
static s32 sdio_writeN(struct intf_hdl *intfhdl, u32 addr, u32 cnt, u8 *buf)
{
- struct adapter *adapter;
+ struct adapter *adapter = intfhdl->padapter;
u8 mac_pwr_ctrl_on;
u8 device_id;
u16 offset;
u32 ftaddr;
u8 shift;
- s32 err;
-
- adapter = intfhdl->padapter;
- err = 0;
+ s32 err = 0;
ftaddr = _cvrt2ftaddr(addr, &device_id, &offset);
@@ -388,13 +377,11 @@ static u32 sdio_read_port(
u8 *mem
)
{
- struct adapter *adapter;
- struct sdio_data *psdio;
+ struct adapter *adapter = intfhdl->padapter;
+ struct sdio_data *psdio = &adapter_to_dvobj(adapter)->intf_data;
struct hal_com_data *hal;
s32 err;
- adapter = intfhdl->padapter;
- psdio = &adapter_to_dvobj(adapter)->intf_data;
hal = GET_HAL_DATA(adapter);
hal_sdio_get_cmd_addr_8723b(adapter, addr, hal->SdioRxFIFOCnt++, &addr);
@@ -432,14 +419,11 @@ static u32 sdio_write_port(
u8 *mem
)
{
- struct adapter *adapter;
- struct sdio_data *psdio;
+ struct adapter *adapter = intfhdl->padapter;
+ struct sdio_data *psdio = &adapter_to_dvobj(adapter)->intf_data;
s32 err;
struct xmit_buf *xmitbuf = (struct xmit_buf *)mem;
- adapter = intfhdl->padapter;
- psdio = &adapter_to_dvobj(adapter)->intf_data;
-
if (!adapter->hw_init_completed)
return _FAIL;
@@ -487,14 +471,12 @@ static s32 _sdio_local_read(
u8 *buf
)
{
- struct intf_hdl *intfhdl;
+ struct intf_hdl *intfhdl = &adapter->iopriv.intf;
u8 mac_pwr_ctrl_on;
s32 err;
u8 *tmpbuf;
u32 n;
- intfhdl = &adapter->iopriv.intf;
-
hal_sdio_get_cmd_addr_8723b(adapter, SDIO_LOCAL_DEVICE_ID, addr, &addr);
rtw_hal_get_hwreg(adapter, HW_VAR_APFM_ON_MAC, &mac_pwr_ctrl_on);
@@ -525,14 +507,12 @@ s32 sdio_local_read(
u8 *buf
)
{
- struct intf_hdl *intfhdl;
+ struct intf_hdl *intfhdl = &adapter->iopriv.intf;
u8 mac_pwr_ctrl_on;
s32 err;
u8 *tmpbuf;
u32 n;
- intfhdl = &adapter->iopriv.intf;
-
hal_sdio_get_cmd_addr_8723b(adapter, SDIO_LOCAL_DEVICE_ID, addr, &addr);
rtw_hal_get_hwreg(adapter, HW_VAR_APFM_ON_MAC, &mac_pwr_ctrl_on);
@@ -566,13 +546,11 @@ s32 sdio_local_write(
u8 *buf
)
{
- struct intf_hdl *intfhdl;
+ struct intf_hdl *intfhdl = &adapter->iopriv.intf;
u8 mac_pwr_ctrl_on;
s32 err;
u8 *tmpbuf;
- intfhdl = &adapter->iopriv.intf;
-
hal_sdio_get_cmd_addr_8723b(adapter, SDIO_LOCAL_DEVICE_ID, addr, &addr);
rtw_hal_get_hwreg(adapter, HW_VAR_APFM_ON_MAC, &mac_pwr_ctrl_on);
@@ -839,11 +817,8 @@ static struct recv_buf *sd_recv_rxfifo(struct adapter *adapter, u32 size)
static void sd_rxhandler(struct adapter *adapter, struct recv_buf *recvbuf)
{
- struct recv_priv *recv_priv;
- struct __queue *pending_queue;
-
- recv_priv = &adapter->recvpriv;
- pending_queue = &recv_priv->recv_buf_pending_queue;
+ struct recv_priv *recv_priv = &adapter->recvpriv;
+ struct __queue *pending_queue = &recv_priv->recv_buf_pending_queue;
/* 3 1. enqueue recvbuf */
rtw_enqueue_recvbuf(recvbuf, pending_queue);
--
2.43.0
^ permalink raw reply related [flat|nested] 8+ messages in thread
* [PATCH 2/6] staging: rtl8723bs: Initialize variables at declaration in odm_HWConfig.c
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 ` 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
` (3 subsequent siblings)
5 siblings, 1 reply; 8+ messages in thread
From: Erick Karanja @ 2025-04-10 13:06 UTC (permalink / raw)
To: gregkh, outreachy
Cc: karanja99erick, philipp.g.hortmann, linux-staging, linux-kernel
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/odm_HWConfig.c | 3 +--
1 file changed, 1 insertion(+), 2 deletions(-)
diff --git a/drivers/staging/rtl8723bs/hal/odm_HWConfig.c b/drivers/staging/rtl8723bs/hal/odm_HWConfig.c
index 994b8c578e7a..85cda5c3a5b5 100644
--- a/drivers/staging/rtl8723bs/hal/odm_HWConfig.c
+++ b/drivers/staging/rtl8723bs/hal/odm_HWConfig.c
@@ -52,9 +52,8 @@ static u8 odm_evm_db_to_percentage(s8 value)
/* */
/* -33dB~0dB to 0%~99% */
/* */
- s8 ret_val;
+ s8 ret_val = value;
- ret_val = value;
ret_val /= 2;
if (ret_val >= 0)
--
2.43.0
^ permalink raw reply related [flat|nested] 8+ messages in thread
* [PATCH 3/6] staging: rtl8723bs: Initialize variables at declaration in hal_com.c
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-10 13:06 ` Erick Karanja
2025-04-10 13:06 ` [PATCH 4/6] staging: rtl8723bs: Initialize variables at declaration in sdio_halinit.c Erick Karanja
` (2 subsequent siblings)
5 siblings, 0 replies; 8+ messages in thread
From: Erick Karanja @ 2025-04-10 13:06 UTC (permalink / raw)
To: gregkh, outreachy
Cc: karanja99erick, philipp.g.hortmann, linux-staging, linux-kernel
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_com.c | 6 ++----
1 file changed, 2 insertions(+), 4 deletions(-)
diff --git a/drivers/staging/rtl8723bs/hal/hal_com.c b/drivers/staging/rtl8723bs/hal/hal_com.c
index 1213a91cffff..7f4dbd5c5d33 100644
--- a/drivers/staging/rtl8723bs/hal/hal_com.c
+++ b/drivers/staging/rtl8723bs/hal/hal_com.c
@@ -745,12 +745,10 @@ u8 GetHalDefVar(
switch (variable) {
case HAL_DEF_UNDERCORATEDSMOOTHEDPWDB:
{
- struct mlme_priv *pmlmepriv;
- struct sta_priv *pstapriv;
+ struct mlme_priv *pmlmepriv = &adapter->mlmepriv;
+ struct sta_priv *pstapriv = &adapter->stapriv;
struct sta_info *psta;
- pmlmepriv = &adapter->mlmepriv;
- pstapriv = &adapter->stapriv;
psta = rtw_get_stainfo(pstapriv, pmlmepriv->cur_network.network.mac_address);
if (psta)
*((int *)value) = psta->rssi_stat.UndecoratedSmoothedPWDB;
--
2.43.0
^ permalink raw reply related [flat|nested] 8+ messages in thread
* [PATCH 4/6] staging: rtl8723bs: Initialize variables at declaration in sdio_halinit.c
2025-04-10 13:06 [PATCH 0/6] Improve code readability in rtl8723bs module Erick Karanja
` (2 preceding siblings ...)
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 ` Erick Karanja
2025-04-10 13:06 ` [PATCH 5/6] staging: rtl8723bs: Initialize variables at declaration in hal_btcoex.c Erick Karanja
2025-04-10 13:06 ` [PATCH 6/6] staging: rtl8723bs: Initialize variables at declaration in rtl8723bs_recv.c Erick Karanja
5 siblings, 0 replies; 8+ messages in thread
From: Erick Karanja @ 2025-04-10 13:06 UTC (permalink / raw)
To: gregkh, outreachy
Cc: karanja99erick, philipp.g.hortmann, linux-staging, linux-kernel
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/sdio_halinit.c | 11 +++--------
1 file changed, 3 insertions(+), 8 deletions(-)
diff --git a/drivers/staging/rtl8723bs/hal/sdio_halinit.c b/drivers/staging/rtl8723bs/hal/sdio_halinit.c
index af9a2b068796..cfc4cace6bb9 100644
--- a/drivers/staging/rtl8723bs/hal/sdio_halinit.c
+++ b/drivers/staging/rtl8723bs/hal/sdio_halinit.c
@@ -453,11 +453,8 @@ static void _InitRetryFunction(struct adapter *padapter)
static void HalRxAggr8723BSdio(struct adapter *padapter)
{
- u8 valueDMATimeout;
- u8 valueDMAPageCount;
-
- valueDMATimeout = 0x06;
- valueDMAPageCount = 0x06;
+ u8 valueDMATimeout = 0x06;
+ u8 valueDMAPageCount = 0x06;
rtw_write8(padapter, REG_RXDMA_AGG_PG_TH + 1, valueDMATimeout);
rtw_write8(padapter, REG_RXDMA_AGG_PG_TH, valueDMAPageCount);
@@ -498,11 +495,9 @@ static void _initSdioAggregationSetting(struct adapter *padapter)
static void _InitOperationMode(struct adapter *padapter)
{
- struct mlme_ext_priv *pmlmeext;
+ struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv;
u8 regBwOpMode = 0;
- pmlmeext = &padapter->mlmeextpriv;
-
/* 1 This part need to modified according to the rate set we filtered!! */
/* */
/* Set RRSR, RATR, and REG_BWOPMODE registers */
--
2.43.0
^ permalink raw reply related [flat|nested] 8+ messages in thread
* [PATCH 5/6] staging: rtl8723bs: Initialize variables at declaration in hal_btcoex.c
2025-04-10 13:06 [PATCH 0/6] Improve code readability in rtl8723bs module Erick Karanja
` (3 preceding siblings ...)
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
2025-04-10 13:06 ` [PATCH 6/6] staging: rtl8723bs: Initialize variables at declaration in rtl8723bs_recv.c Erick Karanja
5 siblings, 0 replies; 8+ messages in thread
From: Erick Karanja @ 2025-04-10 13:06 UTC (permalink / raw)
To: gregkh, outreachy
Cc: karanja99erick, philipp.g.hortmann, linux-staging, linux-kernel
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
^ permalink raw reply related [flat|nested] 8+ messages in thread
* [PATCH 6/6] staging: rtl8723bs: Initialize variables at declaration in rtl8723bs_recv.c
2025-04-10 13:06 [PATCH 0/6] Improve code readability in rtl8723bs module Erick Karanja
` (4 preceding siblings ...)
2025-04-10 13:06 ` [PATCH 5/6] staging: rtl8723bs: Initialize variables at declaration in hal_btcoex.c Erick Karanja
@ 2025-04-10 13:06 ` Erick Karanja
5 siblings, 0 replies; 8+ messages in thread
From: Erick Karanja @ 2025-04-10 13:06 UTC (permalink / raw)
To: gregkh, outreachy
Cc: karanja99erick, philipp.g.hortmann, linux-staging, linux-kernel
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/rtl8723bs_recv.c | 11 +++--------
1 file changed, 3 insertions(+), 8 deletions(-)
diff --git a/drivers/staging/rtl8723bs/hal/rtl8723bs_recv.c b/drivers/staging/rtl8723bs/hal/rtl8723bs_recv.c
index 28c914ec2604..8d0d8e8e837e 100644
--- a/drivers/staging/rtl8723bs/hal/rtl8723bs_recv.c
+++ b/drivers/staging/rtl8723bs/hal/rtl8723bs_recv.c
@@ -367,14 +367,11 @@ static void rtl8723bs_recv_tasklet(struct tasklet_struct *t)
*/
s32 rtl8723bs_init_recv_priv(struct adapter *padapter)
{
- s32 res;
+ s32 res = _SUCCESS;
u32 i, n;
- struct recv_priv *precvpriv;
+ struct recv_priv *precvpriv = &padapter->recvpriv;
struct recv_buf *precvbuf;
- res = _SUCCESS;
- precvpriv = &padapter->recvpriv;
-
/* 3 1. init recv buffer */
INIT_LIST_HEAD(&precvpriv->free_recv_buf_queue.queue);
spin_lock_init(&precvpriv->free_recv_buf_queue.lock);
@@ -453,11 +450,9 @@ s32 rtl8723bs_init_recv_priv(struct adapter *padapter)
void rtl8723bs_free_recv_priv(struct adapter *padapter)
{
u32 i;
- struct recv_priv *precvpriv;
+ struct recv_priv *precvpriv = &padapter->recvpriv;
struct recv_buf *precvbuf;
- precvpriv = &padapter->recvpriv;
-
/* 3 1. kill tasklet */
tasklet_kill(&precvpriv->recv_tasklet);
--
2.43.0
^ permalink raw reply related [flat|nested] 8+ messages in thread
* Re: [PATCH 2/6] staging: rtl8723bs: Initialize variables at declaration in odm_HWConfig.c
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
0 siblings, 0 replies; 8+ messages in thread
From: Dan Carpenter @ 2025-04-12 17:36 UTC (permalink / raw)
To: Erick Karanja
Cc: gregkh, outreachy, philipp.g.hortmann, linux-staging,
linux-kernel
On Thu, Apr 10, 2025 at 04:06:07PM +0300, Erick Karanja wrote:
> 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/odm_HWConfig.c | 3 +--
> 1 file changed, 1 insertion(+), 2 deletions(-)
>
> diff --git a/drivers/staging/rtl8723bs/hal/odm_HWConfig.c b/drivers/staging/rtl8723bs/hal/odm_HWConfig.c
> index 994b8c578e7a..85cda5c3a5b5 100644
> --- a/drivers/staging/rtl8723bs/hal/odm_HWConfig.c
> +++ b/drivers/staging/rtl8723bs/hal/odm_HWConfig.c
> @@ -52,9 +52,8 @@ static u8 odm_evm_db_to_percentage(s8 value)
> /* */
> /* -33dB~0dB to 0%~99% */
> /* */
> - s8 ret_val;
> + s8 ret_val = value;
>
> - ret_val = value;
> ret_val /= 2;
Better to write this one as:
s8 ret_val = value / 2;
regards,
dan carpenter
>
> if (ret_val >= 0)
> --
> 2.43.0
>
^ permalink raw reply [flat|nested] 8+ messages in thread
end of thread, other threads:[~2025-04-12 17:36 UTC | newest]
Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
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 ` [PATCH 5/6] staging: rtl8723bs: Initialize variables at declaration in hal_btcoex.c Erick Karanja
2025-04-10 13:06 ` [PATCH 6/6] staging: rtl8723bs: Initialize variables at declaration in rtl8723bs_recv.c Erick Karanja
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).