Linux wireless drivers development
 help / color / mirror / Atom feed
From: cjz <guagua210311@qq.com>
To: linux-staging@vger.kernel.org
Cc: gregkh@linuxfoundation.org, linux-wireless@vger.kernel.org,
	linux-kernel@vger.kernel.org, changjunzheng <guagua210311@qq.com>
Subject: [PATCH v3] rtl8723bs: v3 - Remove global continual_io_error, use local count
Date: Fri, 19 Dec 2025 17:39:47 +0800	[thread overview]
Message-ID: <tencent_453BB45207600CD663A5957789EB5CEC1608@qq.com> (raw)

From: changjunzheng <guagua210311@qq.com>

1. Remove global 'continual_io_error' variable from struct dvobj_priv (eliminate cross-function dependency)
2. Replace global count logic with local 'error_count' in sd_read32/sd_write32
3. Delete redundant rtw_inc_and_chk/rtw_reset_continual_io_error functions
4. Add independent bool rtw_check_continual_io_error() (single responsibility)
5. Comply with kernel coding style (whitespace, indentation, variable declaration)

Signed-off-by: changjunzheng <guagua210311@qq.com>
---
 drivers/staging/rtl8723bs/core/rtw_io.c         | 17 ++---------------
 drivers/staging/rtl8723bs/include/drv_types.h   |  1 -
 drivers/staging/rtl8723bs/include/rtw_io.h      |  3 +--
 .../staging/rtl8723bs/os_dep/sdio_ops_linux.c   | 16 +++++++++-------
 4 files changed, 12 insertions(+), 25 deletions(-)

diff --git a/drivers/staging/rtl8723bs/core/rtw_io.c b/drivers/staging/rtl8723bs/core/rtw_io.c
index 0f52710e6d3a..33023ae45196 100644
--- a/drivers/staging/rtl8723bs/core/rtw_io.c
+++ b/drivers/staging/rtl8723bs/core/rtw_io.c
@@ -131,20 +131,7 @@ int rtw_init_io_priv(struct adapter *padapter, void (*set_intf_ops)(struct adapt
 
 	return _SUCCESS;
 }
-
-/*
- * Increase and check if the continual_io_error of this @param dvobjprive is larger than MAX_CONTINUAL_IO_ERR
- * @return true:
- * @return false:
- */
-int rtw_inc_and_chk_continual_io_error(struct dvobj_priv *dvobj)
-{
-	dvobj->continual_io_error++;
-	return (dvobj->continual_io_error > MAX_CONTINUAL_IO_ERR);
-}
-
-/* Set the continual_io_error of this @param dvobjprive to 0 */
-void rtw_reset_continual_io_error(struct dvobj_priv *dvobj)
+bool rtw_check_continual_io_error(int error_count)
 {
-	dvobj->continual_io_error = 0;
+    return (error_count > MAX_CONTINUAL_IO_ERR) ? true : false;
 }
diff --git a/drivers/staging/rtl8723bs/include/drv_types.h b/drivers/staging/rtl8723bs/include/drv_types.h
index bd7bb5828d56..de4bec961671 100644
--- a/drivers/staging/rtl8723bs/include/drv_types.h
+++ b/drivers/staging/rtl8723bs/include/drv_types.h
@@ -279,7 +279,6 @@ struct dvobj_priv {
 	u8 Queue2Pipe[HW_QUEUE_ENTRY];/* for out pipe mapping */
 
 	u8 irq_alloc;
-	int continual_io_error;
 
 	atomic_t disable_func;
 
diff --git a/drivers/staging/rtl8723bs/include/rtw_io.h b/drivers/staging/rtl8723bs/include/rtw_io.h
index adf1de4d7924..8ae8849f5fd9 100644
--- a/drivers/staging/rtl8723bs/include/rtw_io.h
+++ b/drivers/staging/rtl8723bs/include/rtw_io.h
@@ -48,8 +48,6 @@ struct	intf_hdl {
 #define SD_IO_TRY_CNT (8)
 #define MAX_CONTINUAL_IO_ERR SD_IO_TRY_CNT
 
-int rtw_inc_and_chk_continual_io_error(struct dvobj_priv *dvobj);
-void rtw_reset_continual_io_error(struct dvobj_priv *dvobj);
 
 struct io_priv {
 
@@ -70,5 +68,6 @@ extern int rtw_write32(struct adapter *adapter, u32 addr, u32 val);
 extern u32 rtw_write_port(struct adapter *adapter, u32 addr, u32 cnt, u8 *pmem);
 
 int rtw_init_io_priv(struct adapter *padapter, void (*set_intf_ops)(struct adapter *padapter, struct _io_ops *pops));
+bool rtw_check_continual_io_error(int error_count);
 
 #endif	/* _RTL8711_IO_H_ */
diff --git a/drivers/staging/rtl8723bs/os_dep/sdio_ops_linux.c b/drivers/staging/rtl8723bs/os_dep/sdio_ops_linux.c
index 5dc00e9117ae..571a2c6fc37a 100644
--- a/drivers/staging/rtl8723bs/os_dep/sdio_ops_linux.c
+++ b/drivers/staging/rtl8723bs/os_dep/sdio_ops_linux.c
@@ -207,7 +207,7 @@ u32 sd_read32(struct intf_hdl *pintfhdl, u32 addr, s32 *err)
 
 	if (err && *err) {
 		int i;
-
+		int error_count = 0;
 		*err = 0;
 		for (i = 0; i < SD_IO_TRY_CNT; i++) {
 			if (claim_needed)
@@ -217,13 +217,13 @@ u32 sd_read32(struct intf_hdl *pintfhdl, u32 addr, s32 *err)
 				sdio_release_host(func);
 
 			if (*err == 0) {
-				rtw_reset_continual_io_error(psdiodev);
+				error_count=0;
 				break;
 			} else {
 				if ((-ESHUTDOWN == *err) || (-ENODEV == *err))
 					padapter->bSurpriseRemoved = true;
-
-				if (rtw_inc_and_chk_continual_io_error(psdiodev) == true) {
+				error_count++; 
+				if (rtw_check_continual_io_error(error_count) == true) {
 					padapter->bSurpriseRemoved = true;
 					break;
 				}
@@ -284,7 +284,7 @@ void sd_write32(struct intf_hdl *pintfhdl, u32 addr, u32 v, s32 *err)
 
 	if (err && *err) {
 		int i;
-
+		int error_count = 0; 
 		*err = 0;
 		for (i = 0; i < SD_IO_TRY_CNT; i++) {
 			if (claim_needed)
@@ -292,14 +292,16 @@ void sd_write32(struct intf_hdl *pintfhdl, u32 addr, u32 v, s32 *err)
 			sdio_writel(func, v, addr, err);
 			if (claim_needed)
 				sdio_release_host(func);
+
 			if (*err == 0) {
-				rtw_reset_continual_io_error(psdiodev);
+				error_count = 0; 
 				break;
 			} else {
 				if ((-ESHUTDOWN == *err) || (-ENODEV == *err))
 					padapter->bSurpriseRemoved = true;
 
-				if (rtw_inc_and_chk_continual_io_error(psdiodev) == true) {
+				error_count++; 
+				if (rtw_check_continual_io_error(error_count) == true) { 
 					padapter->bSurpriseRemoved = true;
 					break;
 				}
-- 
2.43.0


             reply	other threads:[~2025-12-19  9:39 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-12-19  9:39 cjz [this message]
2025-12-21 16:07 ` [PATCH v3] rtl8723bs: v3 - Remove global continual_io_error, use local count Greg KH

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=tencent_453BB45207600CD663A5957789EB5CEC1608@qq.com \
    --to=guagua210311@qq.com \
    --cc=gregkh@linuxfoundation.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-staging@vger.kernel.org \
    --cc=linux-wireless@vger.kernel.org \
    /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