[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <5A122A378F3E53A7+20260120141129.8262-1-2023060904@ycu.edu.cn>
Date: Tue, 20 Jan 2026 22:11:25 +0800
From: 2023060904@....edu.cn
To: linux-staging@...ts.linux.dev
Cc: gregkh@...uxfoundation.org,
dan.carpenter@...aro.org,
2023060904@....edu.cn,
guagua210311@...com,
linux-kernel@...r.kernel.org
Subject: [PATCH v2 1/2] rtl8723bs: Refactor continual_io_error check
From: Changjun Zheng <guagua210311@...com>
Refactor the error count check logic to follow kernel 'single responsibility' principle:
1. Move the increment logic (atomic_inc) from rtw_inc_and_chk_continual_io_error() to its callers in sdio_ops_linux.c (line 226/302)
2. Keep only the check logic in rtw_inc_and_chk_continual_io_error() (use atomic_read to get current count)
This change addresses Greg KH's feedback to move increment to callers, while keeping atomic operations to ensure no compilation/run-time errors.
Signed-off-by: Changjun Zheng <guagua210311@...com>
---
Changes in v2:
No functional logic change, only refactored increment to caller side
drivers/staging/rtl8723bs/core/rtw_io.c | 3 +--
drivers/staging/rtl8723bs/os_dep/sdio_ops_linux.c | 4 ++--
2 files changed, 3 insertions(+), 4 deletions(-)
diff --git a/drivers/staging/rtl8723bs/core/rtw_io.c b/drivers/staging/rtl8723bs/core/rtw_io.c
index fe9f94001eed..0c450d6cd14b 100644
--- a/drivers/staging/rtl8723bs/core/rtw_io.c
+++ b/drivers/staging/rtl8723bs/core/rtw_io.c
@@ -139,8 +139,7 @@ int rtw_init_io_priv(struct adapter *padapter, void (*set_intf_ops)(struct adapt
*/
int rtw_inc_and_chk_continual_io_error(struct dvobj_priv *dvobj)
{
- int error_count = atomic_inc_return(&dvobj->continual_io_error);
-
+ int error_count = atomic_read(&dvobj->continual_io_error);
if (error_count > MAX_CONTINUAL_IO_ERR)
return true;
diff --git a/drivers/staging/rtl8723bs/os_dep/sdio_ops_linux.c b/drivers/staging/rtl8723bs/os_dep/sdio_ops_linux.c
index 5dc00e9117ae..026fb4963d06 100644
--- a/drivers/staging/rtl8723bs/os_dep/sdio_ops_linux.c
+++ b/drivers/staging/rtl8723bs/os_dep/sdio_ops_linux.c
@@ -222,7 +222,7 @@ u32 sd_read32(struct intf_hdl *pintfhdl, u32 addr, s32 *err)
} else {
if ((-ESHUTDOWN == *err) || (-ENODEV == *err))
padapter->bSurpriseRemoved = true;
-
+ atomic_inc(&psdiodev->continual_io_error);
if (rtw_inc_and_chk_continual_io_error(psdiodev) == true) {
padapter->bSurpriseRemoved = true;
break;
@@ -298,7 +298,7 @@ void sd_write32(struct intf_hdl *pintfhdl, u32 addr, u32 v, s32 *err)
} else {
if ((-ESHUTDOWN == *err) || (-ENODEV == *err))
padapter->bSurpriseRemoved = true;
-
+ atomic_inc(&psdiodev->continual_io_error);
if (rtw_inc_and_chk_continual_io_error(psdiodev) == true) {
padapter->bSurpriseRemoved = true;
break;
--
2.43.0
Powered by blists - more mailing lists