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 06/11] staging: rtl8723bs: inline sd_write8() and sdio_write8() in rtw_write8()
Date: Fri, 8 May 2026 22:38:35 +0300 [thread overview]
Message-ID: <20260508193909.16015-7-nikolayof23@gmail.com> (raw)
In-Reply-To: <20260508193909.16015-1-nikolayof23@gmail.com>
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
next prev 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 ` [PATCH RFC 05/11] staging: rtl8723bs: inline sdio_read32() into rtw_read32() Nikolay Kulikov
2026-05-08 19:38 ` Nikolay Kulikov [this message]
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-7-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