Linux kernel staging patches
 help / color / mirror / Atom feed
From: Nikolay Kulikov <nikolayof23@gmail.com>
To: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Cc: linux-staging@lists.linux.dev, Nikolay Kulikov <nikolayof23@gmail.com>
Subject: [PATCH RFC 05/11] staging: rtl8723bs: inline sdio_read32() into rtw_read32()
Date: Fri,  8 May 2026 22:38:34 +0300	[thread overview]
Message-ID: <20260508193909.16015-6-nikolayof23@gmail.com> (raw)
In-Reply-To: <20260508193909.16015-1-nikolayof23@gmail.com>

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


  parent reply	other threads:[~2026-05-08 19:39 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
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 ` Nikolay Kulikov [this message]
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

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=20260508193909.16015-6-nikolayof23@gmail.com \
    --to=nikolayof23@gmail.com \
    --cc=gregkh@linuxfoundation.org \
    --cc=linux-staging@lists.linux.dev \
    /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