lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <9c8473662caa96a8d312415e9006f74f48098f98.1744285781.git.karanja99erick@gmail.com>
Date: Thu, 10 Apr 2025 16:06:06 +0300
From: Erick Karanja <karanja99erick@...il.com>
To: gregkh@...uxfoundation.org,
	outreachy@...ts.linux.dev
Cc: karanja99erick@...il.com,
	philipp.g.hortmann@...il.com,
	linux-staging@...ts.linux.dev,
	linux-kernel@...r.kernel.org
Subject: [PATCH 1/6] staging: rtl8723bs: Improve code readability in sdio_ops.c

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@...il.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


Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ