[PATCH] Staging: rtl8723bs: Merge assignment with return

From: Shreeya Patel
Date: Sun Dec 10 2017 - 17:03:20 EST


Merge the assignment and return statements to return the value
directly. Done using the following semantic patch by coccinelle.

@@
local idexpression ret;
expression e;
@@

-ret =
+return
e;
-return ret;

Also, remove the variable declaration and some braces
that became useless after the merge.

Signed-off-by: Shreeya Patel <shreeya.patel23498@xxxxxxxxx>
---
drivers/staging/rtl8723bs/hal/sdio_ops.c | 53 +++++++++++---------------------
1 file changed, 18 insertions(+), 35 deletions(-)

diff --git a/drivers/staging/rtl8723bs/hal/sdio_ops.c b/drivers/staging/rtl8723bs/hal/sdio_ops.c
index 9a4c248..93ac083 100644
--- a/drivers/staging/rtl8723bs/hal/sdio_ops.c
+++ b/drivers/staging/rtl8723bs/hal/sdio_ops.c
@@ -157,23 +157,20 @@ static u32 _cvrt2ftaddr(const u32 addr, u8 *pdeviceId, u16 *poffset)
static u8 sdio_read8(struct intf_hdl *pintfhdl, u32 addr)
{
u32 ftaddr;
- u8 val;
-
ftaddr = _cvrt2ftaddr(addr, NULL, NULL);
- val = sd_read8(pintfhdl, ftaddr, NULL);
- return val;
+
+ return sd_read8(pintfhdl, ftaddr, NULL);
}

static u16 sdio_read16(struct intf_hdl *pintfhdl, u32 addr)
{
u32 ftaddr;
- u16 val;
__le16 le_tmp;

ftaddr = _cvrt2ftaddr(addr, NULL, NULL);
sd_cmd52_read(pintfhdl, ftaddr, 2, (u8 *)&le_tmp);
- val = le16_to_cpu(le_tmp);
- return val;
+
+ return le16_to_cpu(le_tmp);
}

static u32 sdio_read32(struct intf_hdl *pintfhdl, u32 addr)
@@ -201,8 +198,7 @@ static u32 sdio_read32(struct intf_hdl *pintfhdl, u32 addr)
#ifdef SDIO_DEBUG_IO
if (!err) {
#endif
- val = le32_to_cpu(le_tmp);
- return val;
+ return le32_to_cpu(le_tmp);
#ifdef SDIO_DEBUG_IO
}

@@ -254,10 +250,8 @@ static s32 sdio_readN(struct intf_hdl *pintfhdl, u32 addr, u32 cnt, u8 *pbuf)
((deviceId == WLAN_IOREG_DEVICE_ID) && (offset < 0x100)) ||
(false == bMacPwrCtrlOn) ||
(true == adapter_to_pwrctl(padapter)->bFwCurrentInPSMode)
- ) {
- err = sd_cmd52_read(pintfhdl, ftaddr, cnt, pbuf);
- return err;
- }
+ )
+ return sd_cmd52_read(pintfhdl, ftaddr, cnt, pbuf);

/* 4 bytes alignment */
shift = ftaddr & 0x3;
@@ -295,14 +289,11 @@ static s32 sdio_write8(struct intf_hdl *pintfhdl, u32 addr, u8 val)
static s32 sdio_write16(struct intf_hdl *pintfhdl, u32 addr, u16 val)
{
u32 ftaddr;
- s32 err;
__le16 le_tmp;

ftaddr = _cvrt2ftaddr(addr, NULL, NULL);
le_tmp = cpu_to_le16(val);
- err = sd_cmd52_write(pintfhdl, ftaddr, 2, (u8 *)&le_tmp);
-
- return err;
+ return sd_cmd52_write(pintfhdl, ftaddr, 2, (u8 *)&le_tmp);
}

static s32 sdio_write32(struct intf_hdl *pintfhdl, u32 addr, u32 val)
@@ -328,8 +319,8 @@ static s32 sdio_write32(struct intf_hdl *pintfhdl, u32 addr, u32 val)
(adapter_to_pwrctl(padapter)->bFwCurrentInPSMode)
) {
le_tmp = cpu_to_le32(val);
- err = sd_cmd52_write(pintfhdl, ftaddr, 4, (u8 *)&le_tmp);
- return err;
+
+ return sd_cmd52_write(pintfhdl, ftaddr, 4, (u8 *)&le_tmp);
}

/* 4 bytes alignment */
@@ -363,10 +354,8 @@ static s32 sdio_writeN(struct intf_hdl *pintfhdl, u32 addr, u32 cnt, u8 *pbuf)
((deviceId == WLAN_IOREG_DEVICE_ID) && (offset < 0x100)) ||
(false == bMacPwrCtrlOn) ||
(true == adapter_to_pwrctl(padapter)->bFwCurrentInPSMode)
- ) {
- err = sd_cmd52_write(pintfhdl, ftaddr, cnt, pbuf);
- return err;
- }
+ )
+ return sd_cmd52_write(pintfhdl, ftaddr, cnt, pbuf);

shift = ftaddr & 0x3;
if (shift == 0) {
@@ -588,10 +577,8 @@ static s32 _sdio_local_read(
HalSdioGetCmdAddr8723BSdio(padapter, SDIO_LOCAL_DEVICE_ID, addr, &addr);

rtw_hal_get_hwreg(padapter, HW_VAR_APFM_ON_MAC, &bMacPwrCtrlOn);
- if (false == bMacPwrCtrlOn) {
- err = _sd_cmd52_read(pintfhdl, addr, cnt, pbuf);
- return err;
- }
+ if (false == bMacPwrCtrlOn)
+ return _sd_cmd52_read(pintfhdl, addr, cnt, pbuf);

n = RND4(cnt);
ptmpbuf = rtw_malloc(n);
@@ -631,10 +618,8 @@ s32 sdio_local_read(
if (
(false == bMacPwrCtrlOn) ||
(true == adapter_to_pwrctl(padapter)->bFwCurrentInPSMode)
- ) {
- err = sd_cmd52_read(pintfhdl, addr, cnt, pbuf);
- return err;
- }
+ )
+ return sd_cmd52_read(pintfhdl, addr, cnt, pbuf);

n = RND4(cnt);
ptmpbuf = rtw_malloc(n);
@@ -679,10 +664,8 @@ s32 sdio_local_write(
if (
(false == bMacPwrCtrlOn) ||
(true == adapter_to_pwrctl(padapter)->bFwCurrentInPSMode)
- ) {
- err = sd_cmd52_write(pintfhdl, addr, cnt, pbuf);
- return err;
- }
+ )
+ return sd_cmd52_write(pintfhdl, addr, cnt, pbuf);

ptmpbuf = rtw_malloc(cnt);
if (!ptmpbuf)
--
2.7.4