Linux kernel staging patches
 help / color / mirror / Atom feed
* [PATCH RFC 00/11] staging: rtl8723bs: remove struct _io_ops
@ 2026-05-08 19:38 Nikolay Kulikov
  2026-05-08 19:38 ` [PATCH RFC 01/11] staging: rtl8723bs: remove unused sdio_local_read() Nikolay Kulikov
                   ` (10 more replies)
  0 siblings, 11 replies; 12+ messages in thread
From: Nikolay Kulikov @ 2026-05-08 19:38 UTC (permalink / raw)
  To: Greg Kroah-Hartman; +Cc: linux-staging, Nikolay Kulikov

I don't have hardware. Tested only by compiling.

So, in this series I've attempted to simplify a bunch of abstractions in
core/rtw_io.c (and hal/sdio_ops.c and os_dep/sdio_ops_linux.c files).

In general, the logic is as follows:

	1. Functions from core/rtw_io.c (with the 'rtw_*' prefix) call
	   functions from hal/sdio_ops.c (with the 'sdio_*' prefix),
	   obtaining them from a pointer in 'struct _io_ops'.
	2. Functions from hal/sdio_ops.c convert the passed address
	   (call _cvrt2ftaddr()) and call functions from
	   os_dep/sdio_ops_linux.c (with the 'sd_*' prefix).
	3. Only functions from os_dep/sdio_ops_linux.c perform the work
	   we're interested in - they call other functions from the
	   kernel MMC subsystem (sdio_readb(), sdio_writeb(), and so on)

For the rtw_read8() (rtw_write8()) functions, I was able to remove all
these abstraction layers (this is the only place where this happens) by
directly calling sdio_readb() (sdio_writeb()).

For the rtw_read16() (rtw_write16()) functions, I had to retain the
sd_cmd52_read() (sd_cmd52_write()) calls from os_dep/sdio_ops_linux.c,
since there are no equivalents for them.

rtw_read32() (rtw_write32()) calls differet read (write) functions
depending on the address alignment. I simply pasted everything from
sdio_read32() (sdio_write32()) into them.

I described some details in the comments to the corresponding patches.

I also slightly formatted the modified code to avoid creating new
checkpatch.pl warnings.


In any case, this will completely eliminate the 'struct _io_ops'
and consolidate the reading (writing) code in one place so that
error hadling can be found and corrected.

This series is marked as RFC because I need your opinion on it and also
maybe someone wants to test it?


Nikolay Kulikov (11):
  staging: rtl8723bs: remove unused sdio_local_read()
  staging: rtl8723bs: declare helper sdio functions in .h files
  staging: rtl8723bs: inline sd_read8() and sdio_read8() into
    rtw_read8()
  staging: rtl8723bs: inline sdio_read16() into rtw_read16()
  staging: rtl8723bs: inline sdio_read32() into rtw_read32()
  staging: rtl8723bs: inline sd_write8() and sdio_write8() in
    rtw_write8()
  staging: rtl8723bs: inline sdio_write16() into rtw_write16()
  staging: rtl8723bs: inline sdio_write32() into rtw_write32()
  staging: rtl8723bs: inline sdio_write_port() into rtw_write_port()
  staging: rtl8723bs: remove the empty function set_intf_ops()
  staging: rtl8723bs: remove empty struct _io_ops

 drivers/staging/rtl8723bs/core/rtw_io.c       | 208 +++++++++++-----
 drivers/staging/rtl8723bs/hal/sdio_ops.c      | 235 +-----------------
 drivers/staging/rtl8723bs/include/rtw_io.h    |  16 +-
 drivers/staging/rtl8723bs/include/sdio_hal.h  |   3 +
 drivers/staging/rtl8723bs/include/sdio_ops.h  |   3 -
 .../rtl8723bs/include/sdio_ops_linux.h        |   2 +
 drivers/staging/rtl8723bs/os_dep/sdio_intf.c  |   2 +-
 .../staging/rtl8723bs/os_dep/sdio_ops_linux.c |  55 +---
 8 files changed, 162 insertions(+), 362 deletions(-)


base-commit: 81f55766523e5293604cb96c5e98d10da345ff33
-- 
2.54.0


^ permalink raw reply	[flat|nested] 12+ messages in thread

* [PATCH RFC 01/11] staging: rtl8723bs: remove unused sdio_local_read()
  2026-05-08 19:38 [PATCH RFC 00/11] staging: rtl8723bs: remove struct _io_ops Nikolay Kulikov
@ 2026-05-08 19:38 ` Nikolay Kulikov
  2026-05-08 19:38 ` [PATCH RFC 02/11] staging: rtl8723bs: declare helper sdio functions in .h files Nikolay Kulikov
                   ` (9 subsequent siblings)
  10 siblings, 0 replies; 12+ messages in thread
From: Nikolay Kulikov @ 2026-05-08 19:38 UTC (permalink / raw)
  To: Greg Kroah-Hartman; +Cc: linux-staging, Nikolay Kulikov

This function is never called in the driver, so remove it to get rid of
dead code.

Signed-off-by: Nikolay Kulikov <nikolayof23@gmail.com>
---
 drivers/staging/rtl8723bs/hal/sdio_ops.c     | 41 --------------------
 drivers/staging/rtl8723bs/include/sdio_ops.h |  1 -
 2 files changed, 42 deletions(-)

diff --git a/drivers/staging/rtl8723bs/hal/sdio_ops.c b/drivers/staging/rtl8723bs/hal/sdio_ops.c
index 5d74913be573..bfe8ac5d2bfe 100644
--- a/drivers/staging/rtl8723bs/hal/sdio_ops.c
+++ b/drivers/staging/rtl8723bs/hal/sdio_ops.c
@@ -396,47 +396,6 @@ static s32 _sdio_local_read(
 	return err;
 }
 
-/*
- * Todo: align address to 4 bytes.
- */
-s32 sdio_local_read(
-	struct adapter *adapter,
-	u32 addr,
-	u32 cnt,
-	u8 *buf
-)
-{
-	struct intf_hdl *intfhdl;
-	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);
-	if (
-		(!mac_pwr_ctrl_on) ||
-		(adapter_to_pwrctl(adapter)->fw_current_in_ps_mode)
-	)
-		return sd_cmd52_read(intfhdl, addr, cnt, buf);
-
-	n = round_up(cnt, 4);
-	tmpbuf = kmalloc(n, GFP_ATOMIC);
-	if (!tmpbuf)
-		return -ENOMEM;
-
-	err = sd_read(intfhdl, addr, n, tmpbuf);
-	if (!err)
-		memcpy(buf, tmpbuf, cnt);
-
-	kfree(tmpbuf);
-
-	return err;
-}
-
 /*
  * Todo: align address to 4 bytes.
  */
diff --git a/drivers/staging/rtl8723bs/include/sdio_ops.h b/drivers/staging/rtl8723bs/include/sdio_ops.h
index 13f13076bc16..0be763631873 100644
--- a/drivers/staging/rtl8723bs/include/sdio_ops.h
+++ b/drivers/staging/rtl8723bs/include/sdio_ops.h
@@ -16,7 +16,6 @@ extern void sdio_set_intf_ops(struct adapter *padapter, struct _io_ops *pops);
 /* extern void sdio_func1cmd52_write(struct intf_hdl *pintfhdl, u32 addr, u32 cnt, u8 *wmem); */
 extern u8 SdioLocalCmd52Read1Byte(struct adapter *padapter, u32 addr);
 extern void SdioLocalCmd52Write1Byte(struct adapter *padapter, u32 addr, u8 v);
-extern s32 sdio_local_read(struct adapter *padapter, u32 addr, u32 cnt, u8 *pbuf);
 extern s32 sdio_local_write(struct adapter *padapter, u32 addr, u32 cnt, u8 *pbuf);
 
 u32 _sdio_read32(struct adapter *padapter, u32 addr);
-- 
2.54.0


^ permalink raw reply related	[flat|nested] 12+ messages in thread

* [PATCH RFC 02/11] staging: rtl8723bs: declare helper sdio functions in .h files
  2026-05-08 19:38 [PATCH RFC 00/11] staging: rtl8723bs: remove struct _io_ops Nikolay Kulikov
  2026-05-08 19:38 ` [PATCH RFC 01/11] staging: rtl8723bs: remove unused sdio_local_read() Nikolay Kulikov
@ 2026-05-08 19:38 ` Nikolay Kulikov
  2026-05-08 19:38 ` [PATCH RFC 03/11] staging: rtl8723bs: inline sd_read8() and sdio_read8() into rtw_read8() Nikolay Kulikov
                   ` (8 subsequent siblings)
  10 siblings, 0 replies; 12+ messages in thread
From: Nikolay Kulikov @ 2026-05-08 19:38 UTC (permalink / raw)
  To: Greg Kroah-Hartman; +Cc: linux-staging, Nikolay Kulikov

These functions may be needed in the future in other files when fixing a
large numbrer of abstractions over SDIO in this driver.

Signed-off-by: Nikolay Kulikov <nikolayof23@gmail.com>
---
 drivers/staging/rtl8723bs/hal/sdio_ops.c           | 5 ++---
 drivers/staging/rtl8723bs/include/sdio_hal.h       | 3 +++
 drivers/staging/rtl8723bs/include/sdio_ops_linux.h | 2 ++
 drivers/staging/rtl8723bs/os_dep/sdio_ops_linux.c  | 2 +-
 4 files changed, 8 insertions(+), 4 deletions(-)

diff --git a/drivers/staging/rtl8723bs/hal/sdio_ops.c b/drivers/staging/rtl8723bs/hal/sdio_ops.c
index bfe8ac5d2bfe..a0b5d36d3b02 100644
--- a/drivers/staging/rtl8723bs/hal/sdio_ops.c
+++ b/drivers/staging/rtl8723bs/hal/sdio_ops.c
@@ -13,8 +13,7 @@
 /*  */
 /*  Creadted by Roger, 2011.01.31. */
 /*  */
-static void hal_sdio_get_cmd_addr_8723b(struct adapter *adapter, u8 device_id,
-					u32 addr, u32 *cmdaddr)
+void hal_sdio_get_cmd_addr_8723b(struct adapter *adapter, u8 device_id, u32 addr, u32 *cmdaddr)
 {
 	switch (device_id) {
 	case SDIO_LOCAL_DEVICE_ID:
@@ -85,7 +84,7 @@ static u8 get_deviceid(u32 addr)
 	return devide_id;
 }
 
-static u32 _cvrt2ftaddr(const u32 addr, u8 *pdevice_id, u16 *poffset)
+u32 _cvrt2ftaddr(const u32 addr, u8 *pdevice_id, u16 *poffset)
 {
 	u8 device_id;
 	u16 offset;
diff --git a/drivers/staging/rtl8723bs/include/sdio_hal.h b/drivers/staging/rtl8723bs/include/sdio_hal.h
index 6538253765f1..96f494dd1bc5 100644
--- a/drivers/staging/rtl8723bs/include/sdio_hal.h
+++ b/drivers/staging/rtl8723bs/include/sdio_hal.h
@@ -7,6 +7,9 @@
 #ifndef __SDIO_HAL_H__
 #define __SDIO_HAL_H__
 
+u32 _cvrt2ftaddr(const u32 addr, u8 *pdevice_id, u16 *poffset);
+void hal_sdio_get_cmd_addr_8723b(struct adapter *adapter, u8 device_id, u32 addr, u32 *cmdaddr);
+
 u8 sd_int_isr(struct adapter *padapter);
 void sd_int_dpc(struct adapter *padapter);
 void rtw_set_hal_ops(struct adapter *padapter);
diff --git a/drivers/staging/rtl8723bs/include/sdio_ops_linux.h b/drivers/staging/rtl8723bs/include/sdio_ops_linux.h
index 18830dd18372..ab8b58acfe4b 100644
--- a/drivers/staging/rtl8723bs/include/sdio_ops_linux.h
+++ b/drivers/staging/rtl8723bs/include/sdio_ops_linux.h
@@ -11,6 +11,8 @@
 #define SDIO_ERR_VAL16	0xEAEA
 #define SDIO_ERR_VAL32	0xEAEAEAEA
 
+bool rtw_sdio_claim_host_needed(struct sdio_func *func);
+
 s32 _sd_cmd52_read(struct intf_hdl *pintfhdl, u32 addr, u32 cnt, u8 *pdata);
 s32 _sd_cmd52_write(struct intf_hdl *pintfhdl, u32 addr, u32 cnt, u8 *pdata);
 s32 sd_cmd52_read(struct intf_hdl *pintfhdl, u32 addr, u32 cnt, u8 *pdata);
diff --git a/drivers/staging/rtl8723bs/os_dep/sdio_ops_linux.c b/drivers/staging/rtl8723bs/os_dep/sdio_ops_linux.c
index e9a2f3f7ec74..33bf826679f1 100644
--- a/drivers/staging/rtl8723bs/os_dep/sdio_ops_linux.c
+++ b/drivers/staging/rtl8723bs/os_dep/sdio_ops_linux.c
@@ -7,7 +7,7 @@
 
 #include <drv_types.h>
 
-static bool rtw_sdio_claim_host_needed(struct sdio_func *func)
+bool rtw_sdio_claim_host_needed(struct sdio_func *func)
 {
 	struct dvobj_priv *dvobj = sdio_get_drvdata(func);
 	struct sdio_data *sdio_data = &dvobj->intf_data;
-- 
2.54.0


^ permalink raw reply related	[flat|nested] 12+ messages in thread

* [PATCH RFC 03/11] staging: rtl8723bs: inline sd_read8() and sdio_read8() into rtw_read8()
  2026-05-08 19:38 [PATCH RFC 00/11] staging: rtl8723bs: remove struct _io_ops Nikolay Kulikov
  2026-05-08 19:38 ` [PATCH RFC 01/11] staging: rtl8723bs: remove unused sdio_local_read() Nikolay Kulikov
  2026-05-08 19:38 ` [PATCH RFC 02/11] staging: rtl8723bs: declare helper sdio functions in .h files Nikolay Kulikov
@ 2026-05-08 19:38 ` Nikolay Kulikov
  2026-05-08 19:38 ` [PATCH RFC 04/11] staging: rtl8723bs: inline sdio_read16() into rtw_read16() Nikolay Kulikov
                   ` (7 subsequent siblings)
  10 siblings, 0 replies; 12+ messages in thread
From: Nikolay Kulikov @ 2026-05-08 19:38 UTC (permalink / raw)
  To: Greg Kroah-Hartman; +Cc: linux-staging, Nikolay Kulikov

The rtw_read8() func calls sdio_read8(), which performs address
conversation and calls sd_read8(), which calls sdio_readb()

Remove this deep level of indirection by directly handling the address
translation and the sdio_readb() call from rtw_read8() to significantly
reduce the number of abstractions and simplify the code.

Signed-off-by: Nikolay Kulikov <nikolayof23@gmail.com>
---
 drivers/staging/rtl8723bs/core/rtw_io.c       | 22 +++++++++++----
 drivers/staging/rtl8723bs/hal/sdio_ops.c      | 10 -------
 drivers/staging/rtl8723bs/include/rtw_io.h    |  1 -
 .../staging/rtl8723bs/os_dep/sdio_ops_linux.c | 28 -------------------
 4 files changed, 17 insertions(+), 44 deletions(-)

diff --git a/drivers/staging/rtl8723bs/core/rtw_io.c b/drivers/staging/rtl8723bs/core/rtw_io.c
index c793ae7ea5c4..838e5336ea18 100644
--- a/drivers/staging/rtl8723bs/core/rtw_io.c
+++ b/drivers/staging/rtl8723bs/core/rtw_io.c
@@ -27,13 +27,25 @@
 
 u8 rtw_read8(struct adapter *adapter, u32 addr)
 {
-	struct io_priv *pio_priv = &adapter->iopriv;
-	struct intf_hdl *pintfhdl = &pio_priv->intf;
-	u8 (*_read8)(struct intf_hdl *pintfhdl, u32 addr);
+	struct sdio_data *sdio = &adapter->dvobj->intf_data;
+	struct sdio_func *func = sdio->func;
+	bool claim_needed;
+	u32 ftaddr;
+	u8 ret = 0;
+
+	if (adapter->bSurpriseRemoved)
+		return ret;
+
+	ftaddr = _cvrt2ftaddr(addr, NULL, NULL);
+	claim_needed = rtw_sdio_claim_host_needed(func);
 
-	_read8 = pintfhdl->io_ops._read8;
+	if (claim_needed)
+		sdio_claim_host(func);
+	ret = sdio_readb(func, addr, NULL);
+	if (claim_needed)
+		sdio_release_host(func);
 
-	return _read8(pintfhdl, addr);
+	return ret;
 }
 
 u16 rtw_read16(struct adapter *adapter, u32 addr)
diff --git a/drivers/staging/rtl8723bs/hal/sdio_ops.c b/drivers/staging/rtl8723bs/hal/sdio_ops.c
index a0b5d36d3b02..2d442a8db586 100644
--- a/drivers/staging/rtl8723bs/hal/sdio_ops.c
+++ b/drivers/staging/rtl8723bs/hal/sdio_ops.c
@@ -124,15 +124,6 @@ u32 _cvrt2ftaddr(const u32 addr, u8 *pdevice_id, u16 *poffset)
 	return ftaddr;
 }
 
-static u8 sdio_read8(struct intf_hdl *intfhdl, u32 addr)
-{
-	u32 ftaddr;
-
-	ftaddr = _cvrt2ftaddr(addr, NULL, NULL);
-
-	return sd_read8(intfhdl, ftaddr, NULL);
-}
-
 static u16 sdio_read16(struct intf_hdl *intfhdl, u32 addr)
 {
 	u32 ftaddr;
@@ -347,7 +338,6 @@ static u32 sdio_write_port(
 
 void sdio_set_intf_ops(struct adapter *adapter, struct _io_ops *ops)
 {
-	ops->_read8 = &sdio_read8;
 	ops->_read16 = &sdio_read16;
 	ops->_read32 = &sdio_read32;
 
diff --git a/drivers/staging/rtl8723bs/include/rtw_io.h b/drivers/staging/rtl8723bs/include/rtw_io.h
index 3c99a2bc19bd..f58cf740f099 100644
--- a/drivers/staging/rtl8723bs/include/rtw_io.h
+++ b/drivers/staging/rtl8723bs/include/rtw_io.h
@@ -11,7 +11,6 @@
 struct intf_hdl;
 
 struct _io_ops {
-		u8 (*_read8)(struct intf_hdl *pintfhdl, u32 addr);
 		u16 (*_read16)(struct intf_hdl *pintfhdl, u32 addr);
 		u32 (*_read32)(struct intf_hdl *pintfhdl, u32 addr);
 
diff --git a/drivers/staging/rtl8723bs/os_dep/sdio_ops_linux.c b/drivers/staging/rtl8723bs/os_dep/sdio_ops_linux.c
index 33bf826679f1..33d0d87051fa 100644
--- a/drivers/staging/rtl8723bs/os_dep/sdio_ops_linux.c
+++ b/drivers/staging/rtl8723bs/os_dep/sdio_ops_linux.c
@@ -152,34 +152,6 @@ s32 sd_cmd52_write(struct intf_hdl *pintfhdl, u32 addr, u32 cnt, u8 *pdata)
 	return err;
 }
 
-u8 sd_read8(struct intf_hdl *pintfhdl, u32 addr, s32 *err)
-{
-	struct adapter *padapter;
-	struct dvobj_priv *psdiodev;
-	struct sdio_data *psdio;
-
-	u8 v = 0;
-	struct sdio_func *func;
-	bool claim_needed;
-
-	padapter = pintfhdl->padapter;
-	psdiodev = pintfhdl->pintf_dev;
-	psdio = &psdiodev->intf_data;
-
-	if (padapter->bSurpriseRemoved)
-		return v;
-
-	func = psdio->func;
-	claim_needed = rtw_sdio_claim_host_needed(func);
-
-	if (claim_needed)
-		sdio_claim_host(func);
-	v = sdio_readb(func, addr, err);
-	if (claim_needed)
-		sdio_release_host(func);
-	return v;
-}
-
 u32 sd_read32(struct intf_hdl *pintfhdl, u32 addr, s32 *err)
 {
 	struct adapter *padapter;
-- 
2.54.0


^ permalink raw reply related	[flat|nested] 12+ messages in thread

* [PATCH RFC 04/11] staging: rtl8723bs: inline sdio_read16() into rtw_read16()
  2026-05-08 19:38 [PATCH RFC 00/11] staging: rtl8723bs: remove struct _io_ops Nikolay Kulikov
                   ` (2 preceding siblings ...)
  2026-05-08 19:38 ` [PATCH RFC 03/11] staging: rtl8723bs: inline sd_read8() and sdio_read8() into rtw_read8() Nikolay Kulikov
@ 2026-05-08 19:38 ` Nikolay Kulikov
  2026-05-08 19:38 ` [PATCH RFC 05/11] staging: rtl8723bs: inline sdio_read32() into rtw_read32() Nikolay Kulikov
                   ` (6 subsequent siblings)
  10 siblings, 0 replies; 12+ messages in thread
From: Nikolay Kulikov @ 2026-05-08 19:38 UTC (permalink / raw)
  To: Greg Kroah-Hartman; +Cc: linux-staging, Nikolay Kulikov

rtw_read16() is just a wrapper around sdio_read16(), combining them will
simplify the code and reduce the number of indirect calls.

Signed-off-by: Nikolay Kulikov <nikolayof23@gmail.com>
---
 drivers/staging/rtl8723bs/core/rtw_io.c    | 11 ++++++-----
 drivers/staging/rtl8723bs/hal/sdio_ops.c   | 12 ------------
 drivers/staging/rtl8723bs/include/rtw_io.h |  1 -
 3 files changed, 6 insertions(+), 18 deletions(-)

diff --git a/drivers/staging/rtl8723bs/core/rtw_io.c b/drivers/staging/rtl8723bs/core/rtw_io.c
index 838e5336ea18..85a3ff441f84 100644
--- a/drivers/staging/rtl8723bs/core/rtw_io.c
+++ b/drivers/staging/rtl8723bs/core/rtw_io.c
@@ -50,13 +50,14 @@ u8 rtw_read8(struct adapter *adapter, u32 addr)
 
 u16 rtw_read16(struct adapter *adapter, u32 addr)
 {
-	struct io_priv *pio_priv = &adapter->iopriv;
-	struct intf_hdl *pintfhdl = &pio_priv->intf;
-	u16 (*_read16)(struct intf_hdl *pintfhdl, u32 addr);
+	struct intf_hdl *intfhdl = &adapter->iopriv.intf;
+	__le16 le_tmp;
+	u32 ftaddr;
 
-	_read16 = pintfhdl->io_ops._read16;
+	ftaddr = _cvrt2ftaddr(addr, NULL, NULL);
+	sd_cmd52_read(intfhdl, ftaddr, 2, (u8 *)&le_tmp);
 
-	return _read16(pintfhdl, addr);
+	return le16_to_cpu(le_tmp);
 }
 
 u32 rtw_read32(struct adapter *adapter, u32 addr)
diff --git a/drivers/staging/rtl8723bs/hal/sdio_ops.c b/drivers/staging/rtl8723bs/hal/sdio_ops.c
index 2d442a8db586..230817f79b61 100644
--- a/drivers/staging/rtl8723bs/hal/sdio_ops.c
+++ b/drivers/staging/rtl8723bs/hal/sdio_ops.c
@@ -124,17 +124,6 @@ u32 _cvrt2ftaddr(const u32 addr, u8 *pdevice_id, u16 *poffset)
 	return ftaddr;
 }
 
-static u16 sdio_read16(struct intf_hdl *intfhdl, u32 addr)
-{
-	u32 ftaddr;
-	__le16 le_tmp;
-
-	ftaddr = _cvrt2ftaddr(addr, NULL, NULL);
-	sd_cmd52_read(intfhdl, ftaddr, 2, (u8 *)&le_tmp);
-
-	return le16_to_cpu(le_tmp);
-}
-
 static u32 sdio_read32(struct intf_hdl *intfhdl, u32 addr)
 {
 	struct adapter *adapter;
@@ -338,7 +327,6 @@ static u32 sdio_write_port(
 
 void sdio_set_intf_ops(struct adapter *adapter, struct _io_ops *ops)
 {
-	ops->_read16 = &sdio_read16;
 	ops->_read32 = &sdio_read32;
 
 	ops->_write8 = &sdio_write8;
diff --git a/drivers/staging/rtl8723bs/include/rtw_io.h b/drivers/staging/rtl8723bs/include/rtw_io.h
index f58cf740f099..aaf9ef27cfb7 100644
--- a/drivers/staging/rtl8723bs/include/rtw_io.h
+++ b/drivers/staging/rtl8723bs/include/rtw_io.h
@@ -11,7 +11,6 @@
 struct intf_hdl;
 
 struct _io_ops {
-		u16 (*_read16)(struct intf_hdl *pintfhdl, u32 addr);
 		u32 (*_read32)(struct intf_hdl *pintfhdl, u32 addr);
 
 		int (*_write8)(struct intf_hdl *pintfhdl, u32 addr, u8 val);
-- 
2.54.0


^ permalink raw reply related	[flat|nested] 12+ messages in thread

* [PATCH RFC 05/11] staging: rtl8723bs: inline sdio_read32() into rtw_read32()
  2026-05-08 19:38 [PATCH RFC 00/11] staging: rtl8723bs: remove struct _io_ops Nikolay Kulikov
                   ` (3 preceding siblings ...)
  2026-05-08 19:38 ` [PATCH RFC 04/11] staging: rtl8723bs: inline sdio_read16() into rtw_read16() Nikolay Kulikov
@ 2026-05-08 19:38 ` Nikolay Kulikov
  2026-05-08 19:38 ` [PATCH RFC 06/11] staging: rtl8723bs: inline sd_write8() and sdio_write8() in rtw_write8() Nikolay Kulikov
                   ` (5 subsequent siblings)
  10 siblings, 0 replies; 12+ messages in thread
From: Nikolay Kulikov @ 2026-05-08 19:38 UTC (permalink / raw)
  To: Greg Kroah-Hartman; +Cc: linux-staging, Nikolay Kulikov

rtw_read32() is just a wrapper around sdio_read32(), combining them will
simplify the code and reduce the number of indirect calls.

Signed-off-by: Nikolay Kulikov <nikolayof23@gmail.com>
---
 drivers/staging/rtl8723bs/core/rtw_io.c    | 45 ++++++++++++++++----
 drivers/staging/rtl8723bs/hal/sdio_ops.c   | 48 ----------------------
 drivers/staging/rtl8723bs/include/rtw_io.h |  2 -
 3 files changed, 38 insertions(+), 57 deletions(-)

diff --git a/drivers/staging/rtl8723bs/core/rtw_io.c b/drivers/staging/rtl8723bs/core/rtw_io.c
index 85a3ff441f84..04b07b281186 100644
--- a/drivers/staging/rtl8723bs/core/rtw_io.c
+++ b/drivers/staging/rtl8723bs/core/rtw_io.c
@@ -62,13 +62,44 @@ u16 rtw_read16(struct adapter *adapter, u32 addr)
 
 u32 rtw_read32(struct adapter *adapter, u32 addr)
 {
-	struct io_priv *pio_priv = &adapter->iopriv;
-	struct intf_hdl *pintfhdl = &pio_priv->intf;
-	u32 (*_read32)(struct intf_hdl *pintfhdl, u32 addr);
-
-	_read32 = pintfhdl->io_ops._read32;
-
-	return _read32(pintfhdl, addr);
+	struct intf_hdl *intfhdl = &adapter->iopriv.intf;
+	s32 __maybe_unused err;
+	u8 device_id, shift;
+	u8 mac_pwr_ctrl_on;
+	u32 ftaddr, val;
+	__le32 le_tmp;
+	u16 offset;
+
+	ftaddr = _cvrt2ftaddr(addr, &device_id, &offset);
+
+	rtw_hal_get_hwreg(adapter, HW_VAR_APFM_ON_MAC, &mac_pwr_ctrl_on);
+	if (((device_id == WLAN_IOREG_DEVICE_ID) && (offset < 0x100)) ||
+	    (!mac_pwr_ctrl_on) ||
+	    (adapter_to_pwrctl(adapter)->fw_current_in_ps_mode)) {
+		err = sd_cmd52_read(intfhdl, ftaddr, 4, (u8 *)&le_tmp);
+		return le32_to_cpu(le_tmp);
+	}
+
+	/*  4 bytes alignment */
+	shift = ftaddr & 0x3;
+	if (shift == 0) {
+		val = sd_read32(intfhdl, ftaddr, NULL);
+	} else {
+		u8 *tmpbuf;
+
+		tmpbuf = kmalloc(8, GFP_ATOMIC);
+		if (!tmpbuf)
+			return SDIO_ERR_VAL32;
+
+		ftaddr &= ~(u16)0x3;
+		sd_read(intfhdl, ftaddr, 8, tmpbuf);
+		memcpy(&le_tmp, tmpbuf + shift, 4);
+		val = le32_to_cpu(le_tmp);
+
+		kfree(tmpbuf);
+	}
+
+	return val;
 }
 
 int rtw_write8(struct adapter *adapter, u32 addr, u8 val)
diff --git a/drivers/staging/rtl8723bs/hal/sdio_ops.c b/drivers/staging/rtl8723bs/hal/sdio_ops.c
index 230817f79b61..32ea7dd07711 100644
--- a/drivers/staging/rtl8723bs/hal/sdio_ops.c
+++ b/drivers/staging/rtl8723bs/hal/sdio_ops.c
@@ -124,52 +124,6 @@ u32 _cvrt2ftaddr(const u32 addr, u8 *pdevice_id, u16 *poffset)
 	return ftaddr;
 }
 
-static u32 sdio_read32(struct intf_hdl *intfhdl, u32 addr)
-{
-	struct adapter *adapter;
-	u8 mac_pwr_ctrl_on;
-	u8 device_id;
-	u16 offset;
-	u32 ftaddr;
-	u8 shift;
-	u32 val;
-	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);
-	if (
-		((device_id == WLAN_IOREG_DEVICE_ID) && (offset < 0x100)) ||
-		(!mac_pwr_ctrl_on) ||
-		(adapter_to_pwrctl(adapter)->fw_current_in_ps_mode)
-	) {
-		err = sd_cmd52_read(intfhdl, ftaddr, 4, (u8 *)&le_tmp);
-		return le32_to_cpu(le_tmp);
-	}
-
-	/*  4 bytes alignment */
-	shift = ftaddr & 0x3;
-	if (shift == 0) {
-		val = sd_read32(intfhdl, ftaddr, NULL);
-	} else {
-		u8 *tmpbuf;
-
-		tmpbuf = kmalloc(8, GFP_ATOMIC);
-		if (!tmpbuf)
-			return SDIO_ERR_VAL32;
-
-		ftaddr &= ~(u16)0x3;
-		sd_read(intfhdl, ftaddr, 8, tmpbuf);
-		memcpy(&le_tmp, tmpbuf + shift, 4);
-		val = le32_to_cpu(le_tmp);
-
-		kfree(tmpbuf);
-	}
-	return val;
-}
-
 static s32 sdio_write8(struct intf_hdl *intfhdl, u32 addr, u8 val)
 {
 	u32 ftaddr;
@@ -327,8 +281,6 @@ static u32 sdio_write_port(
 
 void sdio_set_intf_ops(struct adapter *adapter, struct _io_ops *ops)
 {
-	ops->_read32 = &sdio_read32;
-
 	ops->_write8 = &sdio_write8;
 	ops->_write16 = &sdio_write16;
 	ops->_write32 = &sdio_write32;
diff --git a/drivers/staging/rtl8723bs/include/rtw_io.h b/drivers/staging/rtl8723bs/include/rtw_io.h
index aaf9ef27cfb7..bf7e26fa7bed 100644
--- a/drivers/staging/rtl8723bs/include/rtw_io.h
+++ b/drivers/staging/rtl8723bs/include/rtw_io.h
@@ -11,8 +11,6 @@
 struct intf_hdl;
 
 struct _io_ops {
-		u32 (*_read32)(struct intf_hdl *pintfhdl, u32 addr);
-
 		int (*_write8)(struct intf_hdl *pintfhdl, u32 addr, u8 val);
 		int (*_write16)(struct intf_hdl *pintfhdl, u32 addr, u16 val);
 		int (*_write32)(struct intf_hdl *pintfhdl, u32 addr, u32 val);
-- 
2.54.0


^ permalink raw reply related	[flat|nested] 12+ messages in thread

* [PATCH RFC 06/11] staging: rtl8723bs: inline sd_write8() and sdio_write8() in rtw_write8()
  2026-05-08 19:38 [PATCH RFC 00/11] staging: rtl8723bs: remove struct _io_ops Nikolay Kulikov
                   ` (4 preceding siblings ...)
  2026-05-08 19:38 ` [PATCH RFC 05/11] staging: rtl8723bs: inline sdio_read32() into rtw_read32() Nikolay Kulikov
@ 2026-05-08 19:38 ` Nikolay Kulikov
  2026-05-08 19:38 ` [PATCH RFC 07/11] staging: rtl8723bs: inline sdio_write16() into rtw_write16() Nikolay Kulikov
                   ` (4 subsequent siblings)
  10 siblings, 0 replies; 12+ messages in thread
From: Nikolay Kulikov @ 2026-05-08 19:38 UTC (permalink / raw)
  To: Greg Kroah-Hartman; +Cc: linux-staging, Nikolay Kulikov

The rtw_write8() function calls sdio_write8(), which performs address
conversion and call sd_write8(), which calls sdio_writeb()

Remove this large number of indirect calls by combining the address
conversion and the sdio_writeb() call, which will make the code much
easier to understand.

Signed-off-by: Nikolay Kulikov <nikolayof23@gmail.com>
---

I left the RTW_STATUS_CODE() calls for the return value here so as not
to change the call site of this function (_SUCCESS/_FAIL are expected
there).

This function now returns an error when the condition:
	if (adapter->bSurpriseRemoved)
		return RTW_STATUS_CODE(-ENODEV);

Initially, sd_write8() didn't have this; it returned an uninitialized
variable.


 drivers/staging/rtl8723bs/core/rtw_io.c       | 24 ++++++++++++------
 drivers/staging/rtl8723bs/hal/sdio_ops.c      | 12 ---------
 drivers/staging/rtl8723bs/include/rtw_io.h    |  1 -
 .../staging/rtl8723bs/os_dep/sdio_ops_linux.c | 25 -------------------
 4 files changed, 17 insertions(+), 45 deletions(-)

diff --git a/drivers/staging/rtl8723bs/core/rtw_io.c b/drivers/staging/rtl8723bs/core/rtw_io.c
index 04b07b281186..1a7988a376ec 100644
--- a/drivers/staging/rtl8723bs/core/rtw_io.c
+++ b/drivers/staging/rtl8723bs/core/rtw_io.c
@@ -104,16 +104,26 @@ u32 rtw_read32(struct adapter *adapter, u32 addr)
 
 int rtw_write8(struct adapter *adapter, u32 addr, u8 val)
 {
-	struct io_priv *pio_priv = &adapter->iopriv;
-	struct intf_hdl *pintfhdl = &pio_priv->intf;
-	int (*_write8)(struct intf_hdl *pintfhdl, u32 addr, u8 val);
-	int ret;
+	struct sdio_data *sdio = &adapter->dvobj->intf_data;
+	struct sdio_func *func;
+	bool claim_needed;
+	u32 ftaddr;
+	s32 err;
 
-	_write8 = pintfhdl->io_ops._write8;
+	if (adapter->bSurpriseRemoved)
+		return RTW_STATUS_CODE(-ENODEV);
 
-	ret = _write8(pintfhdl, addr, val);
+	ftaddr = _cvrt2ftaddr(addr, NULL, NULL);
+	func = sdio->func;
+	claim_needed = rtw_sdio_claim_host_needed(func);
 
-	return RTW_STATUS_CODE(ret);
+	if (claim_needed)
+		sdio_claim_host(func);
+	sdio_writeb(func, val, addr, &err);
+	if (claim_needed)
+		sdio_release_host(func);
+
+	return RTW_STATUS_CODE(err);
 }
 
 int rtw_write16(struct adapter *adapter, u32 addr, u16 val)
diff --git a/drivers/staging/rtl8723bs/hal/sdio_ops.c b/drivers/staging/rtl8723bs/hal/sdio_ops.c
index 32ea7dd07711..672b577016ac 100644
--- a/drivers/staging/rtl8723bs/hal/sdio_ops.c
+++ b/drivers/staging/rtl8723bs/hal/sdio_ops.c
@@ -124,17 +124,6 @@ u32 _cvrt2ftaddr(const u32 addr, u8 *pdevice_id, u16 *poffset)
 	return ftaddr;
 }
 
-static s32 sdio_write8(struct intf_hdl *intfhdl, u32 addr, u8 val)
-{
-	u32 ftaddr;
-	s32 err;
-
-	ftaddr = _cvrt2ftaddr(addr, NULL, NULL);
-	sd_write8(intfhdl, ftaddr, val, &err);
-
-	return err;
-}
-
 static s32 sdio_write16(struct intf_hdl *intfhdl, u32 addr, u16 val)
 {
 	u32 ftaddr;
@@ -281,7 +270,6 @@ static u32 sdio_write_port(
 
 void sdio_set_intf_ops(struct adapter *adapter, struct _io_ops *ops)
 {
-	ops->_write8 = &sdio_write8;
 	ops->_write16 = &sdio_write16;
 	ops->_write32 = &sdio_write32;
 	ops->_write_port = &sdio_write_port;
diff --git a/drivers/staging/rtl8723bs/include/rtw_io.h b/drivers/staging/rtl8723bs/include/rtw_io.h
index bf7e26fa7bed..363c91b213f6 100644
--- a/drivers/staging/rtl8723bs/include/rtw_io.h
+++ b/drivers/staging/rtl8723bs/include/rtw_io.h
@@ -11,7 +11,6 @@
 struct intf_hdl;
 
 struct _io_ops {
-		int (*_write8)(struct intf_hdl *pintfhdl, u32 addr, u8 val);
 		int (*_write16)(struct intf_hdl *pintfhdl, u32 addr, u16 val);
 		int (*_write32)(struct intf_hdl *pintfhdl, u32 addr, u32 val);
 
diff --git a/drivers/staging/rtl8723bs/os_dep/sdio_ops_linux.c b/drivers/staging/rtl8723bs/os_dep/sdio_ops_linux.c
index 33d0d87051fa..2d6bcdb13492 100644
--- a/drivers/staging/rtl8723bs/os_dep/sdio_ops_linux.c
+++ b/drivers/staging/rtl8723bs/os_dep/sdio_ops_linux.c
@@ -205,31 +205,6 @@ u32 sd_read32(struct intf_hdl *pintfhdl, u32 addr, s32 *err)
 	return  v;
 }
 
-void sd_write8(struct intf_hdl *pintfhdl, u32 addr, u8 v, s32 *err)
-{
-	struct adapter *padapter;
-	struct dvobj_priv *psdiodev;
-	struct sdio_data *psdio;
-	struct sdio_func *func;
-	bool claim_needed;
-
-	padapter = pintfhdl->padapter;
-	psdiodev = pintfhdl->pintf_dev;
-	psdio = &psdiodev->intf_data;
-
-	if (padapter->bSurpriseRemoved)
-		return;
-
-	func = psdio->func;
-	claim_needed = rtw_sdio_claim_host_needed(func);
-
-	if (claim_needed)
-		sdio_claim_host(func);
-	sdio_writeb(func, v, addr, err);
-	if (claim_needed)
-		sdio_release_host(func);
-}
-
 void sd_write32(struct intf_hdl *pintfhdl, u32 addr, u32 v, s32 *err)
 {
 	struct adapter *padapter;
-- 
2.54.0


^ permalink raw reply related	[flat|nested] 12+ messages in thread

* [PATCH RFC 07/11] staging: rtl8723bs: inline sdio_write16() into rtw_write16()
  2026-05-08 19:38 [PATCH RFC 00/11] staging: rtl8723bs: remove struct _io_ops Nikolay Kulikov
                   ` (5 preceding siblings ...)
  2026-05-08 19:38 ` [PATCH RFC 06/11] staging: rtl8723bs: inline sd_write8() and sdio_write8() in rtw_write8() Nikolay Kulikov
@ 2026-05-08 19:38 ` Nikolay Kulikov
  2026-05-08 19:38 ` [PATCH RFC 08/11] staging: rtl8723bs: inline sdio_write32() into rtw_write32() Nikolay Kulikov
                   ` (3 subsequent siblings)
  10 siblings, 0 replies; 12+ messages in thread
From: Nikolay Kulikov @ 2026-05-08 19:38 UTC (permalink / raw)
  To: Greg Kroah-Hartman; +Cc: linux-staging, Nikolay Kulikov

rtw_write16() is just a wrapper around sdio_write16(), so combine them
to simplify the code.

Signed-off-by: Nikolay Kulikov <nikolayof23@gmail.com>
---

The return value of this function is never read (I checked with commands
	git grep -rn -C2 "\brtw_write16\b"
	git grep -rn -C2 "= \brtw_write16\b"
from the drivers/staging/rtl8723bs/ directory), so perhaps normal error
handling can be done here?

 drivers/staging/rtl8723bs/core/rtw_io.c    | 12 ++++++------
 drivers/staging/rtl8723bs/hal/sdio_ops.c   | 11 -----------
 drivers/staging/rtl8723bs/include/rtw_io.h |  1 -
 3 files changed, 6 insertions(+), 18 deletions(-)

diff --git a/drivers/staging/rtl8723bs/core/rtw_io.c b/drivers/staging/rtl8723bs/core/rtw_io.c
index 1a7988a376ec..38c4bdd918b8 100644
--- a/drivers/staging/rtl8723bs/core/rtw_io.c
+++ b/drivers/staging/rtl8723bs/core/rtw_io.c
@@ -128,14 +128,14 @@ int rtw_write8(struct adapter *adapter, u32 addr, u8 val)
 
 int rtw_write16(struct adapter *adapter, u32 addr, u16 val)
 {
-	struct io_priv *pio_priv = &adapter->iopriv;
-	struct intf_hdl *pintfhdl = &pio_priv->intf;
-	int (*_write16)(struct intf_hdl *pintfhdl, u32 addr, u16 val);
+	struct intf_hdl *intfhdl = &adapter->iopriv.intf;
+	__le16 le_tmp;
+	u32 ftaddr;
 	int ret;
 
-	_write16 = pintfhdl->io_ops._write16;
-
-	ret = _write16(pintfhdl, addr, val);
+	ftaddr = _cvrt2ftaddr(addr, NULL, NULL);
+	le_tmp = cpu_to_le16(val);
+	ret = sd_cmd52_write(intfhdl, ftaddr, 2, (u8 *)&le_tmp);
 	return RTW_STATUS_CODE(ret);
 }
 
diff --git a/drivers/staging/rtl8723bs/hal/sdio_ops.c b/drivers/staging/rtl8723bs/hal/sdio_ops.c
index 672b577016ac..b6d0774652dc 100644
--- a/drivers/staging/rtl8723bs/hal/sdio_ops.c
+++ b/drivers/staging/rtl8723bs/hal/sdio_ops.c
@@ -124,16 +124,6 @@ u32 _cvrt2ftaddr(const u32 addr, u8 *pdevice_id, u16 *poffset)
 	return ftaddr;
 }
 
-static s32 sdio_write16(struct intf_hdl *intfhdl, u32 addr, u16 val)
-{
-	u32 ftaddr;
-	__le16 le_tmp;
-
-	ftaddr = _cvrt2ftaddr(addr, NULL, NULL);
-	le_tmp = cpu_to_le16(val);
-	return sd_cmd52_write(intfhdl, ftaddr, 2, (u8 *)&le_tmp);
-}
-
 static s32 sdio_write32(struct intf_hdl *intfhdl, u32 addr, u32 val)
 {
 	struct adapter *adapter;
@@ -270,7 +260,6 @@ static u32 sdio_write_port(
 
 void sdio_set_intf_ops(struct adapter *adapter, struct _io_ops *ops)
 {
-	ops->_write16 = &sdio_write16;
 	ops->_write32 = &sdio_write32;
 	ops->_write_port = &sdio_write_port;
 }
diff --git a/drivers/staging/rtl8723bs/include/rtw_io.h b/drivers/staging/rtl8723bs/include/rtw_io.h
index 363c91b213f6..db2e00554aff 100644
--- a/drivers/staging/rtl8723bs/include/rtw_io.h
+++ b/drivers/staging/rtl8723bs/include/rtw_io.h
@@ -11,7 +11,6 @@
 struct intf_hdl;
 
 struct _io_ops {
-		int (*_write16)(struct intf_hdl *pintfhdl, u32 addr, u16 val);
 		int (*_write32)(struct intf_hdl *pintfhdl, u32 addr, u32 val);
 
 		u32 (*_write_port)(struct intf_hdl *pintfhdl, u32 addr, u32 cnt, u8 *pmem);
-- 
2.54.0


^ permalink raw reply related	[flat|nested] 12+ messages in thread

* [PATCH RFC 08/11] staging: rtl8723bs: inline sdio_write32() into rtw_write32()
  2026-05-08 19:38 [PATCH RFC 00/11] staging: rtl8723bs: remove struct _io_ops Nikolay Kulikov
                   ` (6 preceding siblings ...)
  2026-05-08 19:38 ` [PATCH RFC 07/11] staging: rtl8723bs: inline sdio_write16() into rtw_write16() Nikolay Kulikov
@ 2026-05-08 19:38 ` Nikolay Kulikov
  2026-05-08 19:38 ` [PATCH RFC 09/11] staging: rtl8723bs: inline sdio_write_port() into rtw_write_port() Nikolay Kulikov
                   ` (2 subsequent siblings)
  10 siblings, 0 replies; 12+ messages in thread
From: Nikolay Kulikov @ 2026-05-08 19:38 UTC (permalink / raw)
  To: Greg Kroah-Hartman; +Cc: linux-staging, Nikolay Kulikov

rtw_write32() is a wrapper around sdio_write32(), combining them will
simplify the code and reduce the number of indirect calls.

Signed-off-by: Nikolay Kulikov <nikolayof23@gmail.com>
---

The call sites of rtw_write32() also require _SUCCESS/_FAIL, so we need
to use RTW_STATUS_CODE().

 drivers/staging/rtl8723bs/core/rtw_io.c    | 32 ++++++++++++++----
 drivers/staging/rtl8723bs/hal/sdio_ops.c   | 39 ----------------------
 drivers/staging/rtl8723bs/include/rtw_io.h |  2 --
 3 files changed, 25 insertions(+), 48 deletions(-)

diff --git a/drivers/staging/rtl8723bs/core/rtw_io.c b/drivers/staging/rtl8723bs/core/rtw_io.c
index 38c4bdd918b8..f1f3ca46bd15 100644
--- a/drivers/staging/rtl8723bs/core/rtw_io.c
+++ b/drivers/staging/rtl8723bs/core/rtw_io.c
@@ -141,16 +141,34 @@ int rtw_write16(struct adapter *adapter, u32 addr, u16 val)
 
 int rtw_write32(struct adapter *adapter, u32 addr, u32 val)
 {
-	struct io_priv *pio_priv = &adapter->iopriv;
-	struct intf_hdl *pintfhdl = &pio_priv->intf;
-	int (*_write32)(struct intf_hdl *pintfhdl, u32 addr, u32 val);
-	int ret;
+	struct intf_hdl *intfhdl = &adapter->iopriv.intf;
+	u8 mac_pwr_ctrl_on, device_id, shift;
+	__le32 le_tmp;
+	s32 err = 0;
+	u16 offset;
+	u32 ftaddr;
 
-	_write32 = pintfhdl->io_ops._write32;
+	ftaddr = _cvrt2ftaddr(addr, &device_id, &offset);
 
-	ret = _write32(pintfhdl, addr, val);
+	rtw_hal_get_hwreg(adapter, HW_VAR_APFM_ON_MAC, &mac_pwr_ctrl_on);
+	if (((device_id == WLAN_IOREG_DEVICE_ID) && (offset < 0x100)) ||
+	    (!mac_pwr_ctrl_on) ||
+	    (adapter_to_pwrctl(adapter)->fw_current_in_ps_mode)) {
+		le_tmp = cpu_to_le32(val);
+		err = sd_cmd52_write(intfhdl, ftaddr, 4, (u8 *)&le_tmp);
+		return RTW_STATUS_CODE(err);
+	}
 
-	return RTW_STATUS_CODE(ret);
+	/*  4 bytes alignment */
+	shift = ftaddr & 0x3;
+	if (shift == 0) {
+		sd_write32(intfhdl, ftaddr, val, &err);
+	} else {
+		le_tmp = cpu_to_le32(val);
+		err = sd_cmd52_write(intfhdl, ftaddr, 4, (u8 *)&le_tmp);
+	}
+
+	return RTW_STATUS_CODE(err);
 }
 
 u32 rtw_write_port(struct adapter *adapter, u32 addr, u32 cnt, u8 *pmem)
diff --git a/drivers/staging/rtl8723bs/hal/sdio_ops.c b/drivers/staging/rtl8723bs/hal/sdio_ops.c
index b6d0774652dc..a162815e24a4 100644
--- a/drivers/staging/rtl8723bs/hal/sdio_ops.c
+++ b/drivers/staging/rtl8723bs/hal/sdio_ops.c
@@ -124,44 +124,6 @@ u32 _cvrt2ftaddr(const u32 addr, u8 *pdevice_id, u16 *poffset)
 	return ftaddr;
 }
 
-static s32 sdio_write32(struct intf_hdl *intfhdl, u32 addr, u32 val)
-{
-	struct adapter *adapter;
-	u8 mac_pwr_ctrl_on;
-	u8 device_id;
-	u16 offset;
-	u32 ftaddr;
-	u8 shift;
-	s32 err;
-	__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);
-	if (
-		((device_id == WLAN_IOREG_DEVICE_ID) && (offset < 0x100)) ||
-		(!mac_pwr_ctrl_on) ||
-		(adapter_to_pwrctl(adapter)->fw_current_in_ps_mode)
-	) {
-		le_tmp = cpu_to_le32(val);
-
-		return sd_cmd52_write(intfhdl, ftaddr, 4, (u8 *)&le_tmp);
-	}
-
-	/*  4 bytes alignment */
-	shift = ftaddr & 0x3;
-	if (shift == 0) {
-		sd_write32(intfhdl, ftaddr, val, &err);
-	} else {
-		le_tmp = cpu_to_le32(val);
-		err = sd_cmd52_write(intfhdl, ftaddr, 4, (u8 *)&le_tmp);
-	}
-	return err;
-}
-
 /*
  * Description:
  *Read from RX FIFO
@@ -260,7 +222,6 @@ static u32 sdio_write_port(
 
 void sdio_set_intf_ops(struct adapter *adapter, struct _io_ops *ops)
 {
-	ops->_write32 = &sdio_write32;
 	ops->_write_port = &sdio_write_port;
 }
 
diff --git a/drivers/staging/rtl8723bs/include/rtw_io.h b/drivers/staging/rtl8723bs/include/rtw_io.h
index db2e00554aff..9fc2f7413543 100644
--- a/drivers/staging/rtl8723bs/include/rtw_io.h
+++ b/drivers/staging/rtl8723bs/include/rtw_io.h
@@ -11,8 +11,6 @@
 struct intf_hdl;
 
 struct _io_ops {
-		int (*_write32)(struct intf_hdl *pintfhdl, u32 addr, u32 val);
-
 		u32 (*_write_port)(struct intf_hdl *pintfhdl, u32 addr, u32 cnt, u8 *pmem);
 };
 
-- 
2.54.0


^ permalink raw reply related	[flat|nested] 12+ messages in thread

* [PATCH RFC 09/11] staging: rtl8723bs: inline sdio_write_port() into rtw_write_port()
  2026-05-08 19:38 [PATCH RFC 00/11] staging: rtl8723bs: remove struct _io_ops Nikolay Kulikov
                   ` (7 preceding siblings ...)
  2026-05-08 19:38 ` [PATCH RFC 08/11] staging: rtl8723bs: inline sdio_write32() into rtw_write32() Nikolay Kulikov
@ 2026-05-08 19:38 ` Nikolay Kulikov
  2026-05-08 19:38 ` [PATCH RFC 10/11] staging: rtl8723bs: remove the empty function set_intf_ops() Nikolay Kulikov
  2026-05-08 19:38 ` [PATCH RFC 11/11] staging: rtl8723bs: remove empty struct _io_ops Nikolay Kulikov
  10 siblings, 0 replies; 12+ messages in thread
From: Nikolay Kulikov @ 2026-05-08 19:38 UTC (permalink / raw)
  To: Greg Kroah-Hartman; +Cc: linux-staging, Nikolay Kulikov

rtw_write_port() is just a wrapper around sdio_write_port(). Combine
them to reduce the number of abstractions and simplify the code.

Update the function description to match the actual parameters.

Signed-off-by: Nikolay Kulikov <nikolayof23@gmail.com>
---
 drivers/staging/rtl8723bs/core/rtw_io.c    | 41 ++++++++++++++--
 drivers/staging/rtl8723bs/hal/sdio_ops.c   | 54 +---------------------
 drivers/staging/rtl8723bs/include/rtw_io.h |  1 -
 3 files changed, 37 insertions(+), 59 deletions(-)

diff --git a/drivers/staging/rtl8723bs/core/rtw_io.c b/drivers/staging/rtl8723bs/core/rtw_io.c
index f1f3ca46bd15..2f99e5e6e2ac 100644
--- a/drivers/staging/rtl8723bs/core/rtw_io.c
+++ b/drivers/staging/rtl8723bs/core/rtw_io.c
@@ -171,15 +171,46 @@ int rtw_write32(struct adapter *adapter, u32 addr, u32 val)
 	return RTW_STATUS_CODE(err);
 }
 
+/*
+ * Description:
+ * Write to TX FIFO
+ * Align write size block size,
+ * and make sure data could be written in one command.
+ *
+ * Parameters:
+ * @adapter: adapter
+ * @addr: port ID
+ * @cnt: size to write
+ * @pmem: pointer to struct xmit_buf
+ *
+ * Return:
+ * _SUCCESS(1)		Success
+ * _FAIL(0)		Fail
+ */
 u32 rtw_write_port(struct adapter *adapter, u32 addr, u32 cnt, u8 *pmem)
 {
-	u32 (*_write_port)(struct intf_hdl *pintfhdl, u32 addr, u32 cnt, u8 *pmem);
-	struct io_priv *pio_priv = &adapter->iopriv;
-	struct intf_hdl *pintfhdl = &pio_priv->intf;
+	struct sdio_data *sdio = &adapter->dvobj->intf_data;
+	struct xmit_buf *xmitbuf = (struct xmit_buf *)pmem;
+	struct intf_hdl *intfhdl = &adapter->iopriv.intf;
+	s32 err;
 
-	_write_port = pintfhdl->io_ops._write_port;
+	if (!adapter->hw_init_completed || !xmitbuf)
+		return _FAIL;
+
+	cnt = round_up(cnt, 4);
+	hal_sdio_get_cmd_addr_8723b(adapter, addr, cnt >> 2, &addr);
+
+	if (cnt > sdio->block_transfer_len)
+		cnt = _RND(cnt, sdio->block_transfer_len);
+
+	err = sd_write(intfhdl, addr, cnt, xmitbuf->pdata);
 
-	return _write_port(pintfhdl, addr, cnt, pmem);
+	rtw_sctx_done_err(&xmitbuf->sctx,
+			  err ? RTW_SCTX_DONE_WRITE_PORT_ERR : RTW_SCTX_DONE_SUCCESS);
+
+	if (err)
+		return _FAIL;
+	return _SUCCESS;
 }
 
 int rtw_init_io_priv(struct adapter *padapter,
diff --git a/drivers/staging/rtl8723bs/hal/sdio_ops.c b/drivers/staging/rtl8723bs/hal/sdio_ops.c
index a162815e24a4..3b90bab3b92f 100644
--- a/drivers/staging/rtl8723bs/hal/sdio_ops.c
+++ b/drivers/staging/rtl8723bs/hal/sdio_ops.c
@@ -168,61 +168,9 @@ static u32 sdio_read_port(
 	return _SUCCESS;
 }
 
-/*
- * Description:
- *Write to TX FIFO
- *Align write size block size,
- *and make sure data could be written in one command.
- *
- * Parameters:
- *intfhdl	a pointer of intf_hdl
- *addr		port ID
- *cnt			size to write
- *wmem		data pointer to write
- *
- * Return:
- *_SUCCESS(1)		Success
- *_FAIL(0)		Fail
- */
-static u32 sdio_write_port(
-	struct intf_hdl *intfhdl,
-	u32 addr,
-	u32 cnt,
-	u8 *mem
-)
-{
-	struct adapter *adapter;
-	struct sdio_data *psdio;
-	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;
-
-	cnt = round_up(cnt, 4);
-	hal_sdio_get_cmd_addr_8723b(adapter, addr, cnt >> 2, &addr);
-
-	if (cnt > psdio->block_transfer_len)
-		cnt = _RND(cnt, psdio->block_transfer_len);
-
-	err = sd_write(intfhdl, addr, cnt, xmitbuf->pdata);
-
-	rtw_sctx_done_err(
-		&xmitbuf->sctx,
-		err ? RTW_SCTX_DONE_WRITE_PORT_ERR : RTW_SCTX_DONE_SUCCESS
-	);
-
-	if (err)
-		return _FAIL;
-	return _SUCCESS;
-}
-
 void sdio_set_intf_ops(struct adapter *adapter, struct _io_ops *ops)
 {
-	ops->_write_port = &sdio_write_port;
+	return;
 }
 
 /*
diff --git a/drivers/staging/rtl8723bs/include/rtw_io.h b/drivers/staging/rtl8723bs/include/rtw_io.h
index 9fc2f7413543..4e3504260bbc 100644
--- a/drivers/staging/rtl8723bs/include/rtw_io.h
+++ b/drivers/staging/rtl8723bs/include/rtw_io.h
@@ -11,7 +11,6 @@
 struct intf_hdl;
 
 struct _io_ops {
-		u32 (*_write_port)(struct intf_hdl *pintfhdl, u32 addr, u32 cnt, u8 *pmem);
 };
 
 struct	intf_hdl {
-- 
2.54.0


^ permalink raw reply related	[flat|nested] 12+ messages in thread

* [PATCH RFC 10/11] staging: rtl8723bs: remove the empty function set_intf_ops()
  2026-05-08 19:38 [PATCH RFC 00/11] staging: rtl8723bs: remove struct _io_ops Nikolay Kulikov
                   ` (8 preceding siblings ...)
  2026-05-08 19:38 ` [PATCH RFC 09/11] staging: rtl8723bs: inline sdio_write_port() into rtw_write_port() Nikolay Kulikov
@ 2026-05-08 19:38 ` Nikolay Kulikov
  2026-05-08 19:38 ` [PATCH RFC 11/11] staging: rtl8723bs: remove empty struct _io_ops Nikolay Kulikov
  10 siblings, 0 replies; 12+ messages in thread
From: Nikolay Kulikov @ 2026-05-08 19:38 UTC (permalink / raw)
  To: Greg Kroah-Hartman; +Cc: linux-staging, Nikolay Kulikov

The body of this function was removed earlier, so remove it to get rid
of dead code.

This also updates the rtw_init_io_priv() function, as it receives a
pointer to set_intf_ops(), which is no longer neede.

Signed-off-by: Nikolay Kulikov <nikolayof23@gmail.com>
---
 drivers/staging/rtl8723bs/core/rtw_io.c      | 9 +--------
 drivers/staging/rtl8723bs/hal/sdio_ops.c     | 5 -----
 drivers/staging/rtl8723bs/include/rtw_io.h   | 2 +-
 drivers/staging/rtl8723bs/include/sdio_ops.h | 2 --
 drivers/staging/rtl8723bs/os_dep/sdio_intf.c | 2 +-
 5 files changed, 3 insertions(+), 17 deletions(-)

diff --git a/drivers/staging/rtl8723bs/core/rtw_io.c b/drivers/staging/rtl8723bs/core/rtw_io.c
index 2f99e5e6e2ac..63653f6230e5 100644
--- a/drivers/staging/rtl8723bs/core/rtw_io.c
+++ b/drivers/staging/rtl8723bs/core/rtw_io.c
@@ -213,22 +213,15 @@ u32 rtw_write_port(struct adapter *adapter, u32 addr, u32 cnt, u8 *pmem)
 	return _SUCCESS;
 }
 
-int rtw_init_io_priv(struct adapter *padapter,
-		     void (*set_intf_ops)(struct adapter *padapter,
-					  struct _io_ops *pops))
+int rtw_init_io_priv(struct adapter *padapter)
 {
 	struct io_priv *piopriv = &padapter->iopriv;
 	struct intf_hdl *pintf = &piopriv->intf;
 
-	if (!set_intf_ops)
-		return _FAIL;
-
 	piopriv->padapter = padapter;
 	pintf->padapter = padapter;
 	pintf->pintf_dev = adapter_to_dvobj(padapter);
 
-	set_intf_ops(padapter, &pintf->io_ops);
-
 	return _SUCCESS;
 }
 
diff --git a/drivers/staging/rtl8723bs/hal/sdio_ops.c b/drivers/staging/rtl8723bs/hal/sdio_ops.c
index 3b90bab3b92f..8cd8e42c85e4 100644
--- a/drivers/staging/rtl8723bs/hal/sdio_ops.c
+++ b/drivers/staging/rtl8723bs/hal/sdio_ops.c
@@ -168,11 +168,6 @@ static u32 sdio_read_port(
 	return _SUCCESS;
 }
 
-void sdio_set_intf_ops(struct adapter *adapter, struct _io_ops *ops)
-{
-	return;
-}
-
 /*
  * Todo: align address to 4 bytes.
  */
diff --git a/drivers/staging/rtl8723bs/include/rtw_io.h b/drivers/staging/rtl8723bs/include/rtw_io.h
index 4e3504260bbc..f86ad3fa46cc 100644
--- a/drivers/staging/rtl8723bs/include/rtw_io.h
+++ b/drivers/staging/rtl8723bs/include/rtw_io.h
@@ -44,6 +44,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));
+int rtw_init_io_priv(struct adapter *padapter);
 
 #endif	/* _RTL8711_IO_H_ */
diff --git a/drivers/staging/rtl8723bs/include/sdio_ops.h b/drivers/staging/rtl8723bs/include/sdio_ops.h
index 0be763631873..e084df499457 100644
--- a/drivers/staging/rtl8723bs/include/sdio_ops.h
+++ b/drivers/staging/rtl8723bs/include/sdio_ops.h
@@ -10,8 +10,6 @@
 
 #include <sdio_ops_linux.h>
 
-extern void sdio_set_intf_ops(struct adapter *padapter, struct _io_ops *pops);
-
 /* extern void sdio_func1cmd52_read(struct intf_hdl *pintfhdl, u32 addr, u32 cnt, u8 *rmem); */
 /* extern void sdio_func1cmd52_write(struct intf_hdl *pintfhdl, u32 addr, u32 cnt, u8 *wmem); */
 extern u8 SdioLocalCmd52Read1Byte(struct adapter *padapter, u32 addr);
diff --git a/drivers/staging/rtl8723bs/os_dep/sdio_intf.c b/drivers/staging/rtl8723bs/os_dep/sdio_intf.c
index c43a0391a5ca..c0bd991321a7 100644
--- a/drivers/staging/rtl8723bs/os_dep/sdio_intf.c
+++ b/drivers/staging/rtl8723bs/os_dep/sdio_intf.c
@@ -258,7 +258,7 @@ static struct adapter *rtw_sdio_if1_init(struct dvobj_priv *dvobj, const struct
 	padapter->intf_alloc_irq = &sdio_alloc_irq;
 	padapter->intf_free_irq = &sdio_free_irq;
 
-	if (rtw_init_io_priv(padapter, sdio_set_intf_ops) == _FAIL)
+	if (rtw_init_io_priv(padapter) == _FAIL)
 		goto free_hal_data;
 
 	rtl8723b_read_chip_version(padapter);
-- 
2.54.0


^ permalink raw reply related	[flat|nested] 12+ messages in thread

* [PATCH RFC 11/11] staging: rtl8723bs: remove empty struct _io_ops
  2026-05-08 19:38 [PATCH RFC 00/11] staging: rtl8723bs: remove struct _io_ops Nikolay Kulikov
                   ` (9 preceding siblings ...)
  2026-05-08 19:38 ` [PATCH RFC 10/11] staging: rtl8723bs: remove the empty function set_intf_ops() Nikolay Kulikov
@ 2026-05-08 19:38 ` Nikolay Kulikov
  10 siblings, 0 replies; 12+ messages in thread
From: Nikolay Kulikov @ 2026-05-08 19:38 UTC (permalink / raw)
  To: Greg Kroah-Hartman; +Cc: linux-staging, Nikolay Kulikov

All fields of this structure were removed earlier, so remove this
unused struct.

Signed-off-by: Nikolay Kulikov <nikolayof23@gmail.com>
---
 drivers/staging/rtl8723bs/include/rtw_io.h | 5 -----
 1 file changed, 5 deletions(-)

diff --git a/drivers/staging/rtl8723bs/include/rtw_io.h b/drivers/staging/rtl8723bs/include/rtw_io.h
index f86ad3fa46cc..cb26e74162da 100644
--- a/drivers/staging/rtl8723bs/include/rtw_io.h
+++ b/drivers/staging/rtl8723bs/include/rtw_io.h
@@ -10,14 +10,9 @@
 
 struct intf_hdl;
 
-struct _io_ops {
-};
-
 struct	intf_hdl {
 	struct adapter *padapter;
 	struct dvobj_priv *pintf_dev;/* 	pointer to &(padapter->dvobjpriv); */
-
-	struct _io_ops	io_ops;
 };
 
 #define SD_IO_TRY_CNT (8)
-- 
2.54.0


^ permalink raw reply related	[flat|nested] 12+ messages in thread

end of thread, other threads:[~2026-05-08 19:39 UTC | newest]

Thread overview: 12+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-05-08 19:38 [PATCH RFC 00/11] staging: rtl8723bs: remove struct _io_ops Nikolay Kulikov
2026-05-08 19:38 ` [PATCH RFC 01/11] staging: rtl8723bs: remove unused sdio_local_read() Nikolay Kulikov
2026-05-08 19:38 ` [PATCH RFC 02/11] staging: rtl8723bs: declare helper sdio functions in .h files Nikolay Kulikov
2026-05-08 19:38 ` [PATCH RFC 03/11] staging: rtl8723bs: inline sd_read8() and sdio_read8() into rtw_read8() Nikolay Kulikov
2026-05-08 19:38 ` [PATCH RFC 04/11] staging: rtl8723bs: inline sdio_read16() into rtw_read16() Nikolay Kulikov
2026-05-08 19:38 ` [PATCH RFC 05/11] staging: rtl8723bs: inline sdio_read32() into rtw_read32() Nikolay Kulikov
2026-05-08 19:38 ` [PATCH RFC 06/11] staging: rtl8723bs: inline sd_write8() and sdio_write8() in rtw_write8() Nikolay Kulikov
2026-05-08 19:38 ` [PATCH RFC 07/11] staging: rtl8723bs: inline sdio_write16() into rtw_write16() Nikolay Kulikov
2026-05-08 19:38 ` [PATCH RFC 08/11] staging: rtl8723bs: inline sdio_write32() into rtw_write32() Nikolay Kulikov
2026-05-08 19:38 ` [PATCH RFC 09/11] staging: rtl8723bs: inline sdio_write_port() into rtw_write_port() Nikolay Kulikov
2026-05-08 19:38 ` [PATCH RFC 10/11] staging: rtl8723bs: remove the empty function set_intf_ops() Nikolay Kulikov
2026-05-08 19:38 ` [PATCH RFC 11/11] staging: rtl8723bs: remove empty struct _io_ops Nikolay Kulikov

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox