* [PATCH] staging: r8188eu: convert rtw_writeN() to common error logic
@ 2023-01-08 12:38 Michael Straube
2023-01-08 16:43 ` Philipp Hortmann
0 siblings, 1 reply; 2+ messages in thread
From: Michael Straube @ 2023-01-08 12:38 UTC (permalink / raw)
To: gregkh; +Cc: Larry.Finger, phil, linux-staging, linux-kernel, Michael Straube
Convert the function rtw_writeN() away from returning _FAIL or
_SUCCESS which uses inverted error logic. Use the common error logic
instead. Return 0 for success and negative values for failure.
Signed-off-by: Michael Straube <straube.linux@gmail.com>
---
Tested on x86_64 with Inter-Tech DMG-02.
drivers/staging/r8188eu/core/rtw_fw.c | 10 ++++------
drivers/staging/r8188eu/hal/usb_ops_linux.c | 7 ++-----
2 files changed, 6 insertions(+), 11 deletions(-)
diff --git a/drivers/staging/r8188eu/core/rtw_fw.c b/drivers/staging/r8188eu/core/rtw_fw.c
index 682c65b1e04c..1e4baf74ecd5 100644
--- a/drivers/staging/r8188eu/core/rtw_fw.c
+++ b/drivers/staging/r8188eu/core/rtw_fw.c
@@ -89,9 +89,8 @@ static int block_write(struct adapter *padapter, u8 *buffer, u32 size)
addr = FW_8188E_START_ADDRESS + i * block_size;
data = buffer + i * block_size;
- ret = rtw_writeN(padapter, addr, block_size, data);
- if (ret == _FAIL)
- goto exit;
+ if (rtw_writeN(padapter, addr, block_size, data))
+ return _FAIL;
}
if (remain) {
@@ -105,9 +104,8 @@ static int block_write(struct adapter *padapter, u8 *buffer, u32 size)
addr = FW_8188E_START_ADDRESS + offset + i * block_size;
data = buffer + offset + i * block_size;
- ret = rtw_writeN(padapter, addr, block_size, data);
- if (ret == _FAIL)
- goto exit;
+ if (rtw_writeN(padapter, addr, block_size, data))
+ return _FAIL;
}
}
diff --git a/drivers/staging/r8188eu/hal/usb_ops_linux.c b/drivers/staging/r8188eu/hal/usb_ops_linux.c
index 7c72f5e04d9b..f02f8568cdcf 100644
--- a/drivers/staging/r8188eu/hal/usb_ops_linux.c
+++ b/drivers/staging/r8188eu/hal/usb_ops_linux.c
@@ -179,14 +179,11 @@ int rtw_writeN(struct adapter *adapter, u32 addr, u32 length, u8 *data)
struct io_priv *io_priv = &adapter->iopriv;
struct intf_hdl *intf = &io_priv->intf;
u16 value = addr & 0xffff;
- int ret;
if (length > VENDOR_CMD_MAX_DATA_LEN)
- return _FAIL;
+ return -EINVAL;
- ret = usb_write(intf, value, data, length);
-
- return RTW_STATUS_CODE(ret);
+ return usb_write(intf, value, data, length);
}
static void handle_txrpt_ccx_88e(struct adapter *adapter, u8 *buf)
--
2.39.0
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH] staging: r8188eu: convert rtw_writeN() to common error logic
2023-01-08 12:38 [PATCH] staging: r8188eu: convert rtw_writeN() to common error logic Michael Straube
@ 2023-01-08 16:43 ` Philipp Hortmann
0 siblings, 0 replies; 2+ messages in thread
From: Philipp Hortmann @ 2023-01-08 16:43 UTC (permalink / raw)
To: Michael Straube, gregkh; +Cc: Larry.Finger, phil, linux-staging, linux-kernel
On 1/8/23 13:38, Michael Straube wrote:
> Convert the function rtw_writeN() away from returning _FAIL or
> _SUCCESS which uses inverted error logic. Use the common error logic
> instead. Return 0 for success and negative values for failure.
>
> Signed-off-by: Michael Straube <straube.linux@gmail.com>
> ---
> Tested on x86_64 with Inter-Tech DMG-02.
>
> drivers/staging/r8188eu/core/rtw_fw.c | 10 ++++------
> drivers/staging/r8188eu/hal/usb_ops_linux.c | 7 ++-----
> 2 files changed, 6 insertions(+), 11 deletions(-)
>
> diff --git a/drivers/staging/r8188eu/core/rtw_fw.c b/drivers/staging/r8188eu/core/rtw_fw.c
> index 682c65b1e04c..1e4baf74ecd5 100644
> --- a/drivers/staging/r8188eu/core/rtw_fw.c
> +++ b/drivers/staging/r8188eu/core/rtw_fw.c
> @@ -89,9 +89,8 @@ static int block_write(struct adapter *padapter, u8 *buffer, u32 size)
> addr = FW_8188E_START_ADDRESS + i * block_size;
> data = buffer + i * block_size;
>
> - ret = rtw_writeN(padapter, addr, block_size, data);
> - if (ret == _FAIL)
> - goto exit;
> + if (rtw_writeN(padapter, addr, block_size, data))
> + return _FAIL;
> }
>
> if (remain) {
> @@ -105,9 +104,8 @@ static int block_write(struct adapter *padapter, u8 *buffer, u32 size)
> addr = FW_8188E_START_ADDRESS + offset + i * block_size;
> data = buffer + offset + i * block_size;
>
> - ret = rtw_writeN(padapter, addr, block_size, data);
> - if (ret == _FAIL)
> - goto exit;
> + if (rtw_writeN(padapter, addr, block_size, data))
> + return _FAIL;
> }
> }
>
> diff --git a/drivers/staging/r8188eu/hal/usb_ops_linux.c b/drivers/staging/r8188eu/hal/usb_ops_linux.c
> index 7c72f5e04d9b..f02f8568cdcf 100644
> --- a/drivers/staging/r8188eu/hal/usb_ops_linux.c
> +++ b/drivers/staging/r8188eu/hal/usb_ops_linux.c
> @@ -179,14 +179,11 @@ int rtw_writeN(struct adapter *adapter, u32 addr, u32 length, u8 *data)
> struct io_priv *io_priv = &adapter->iopriv;
> struct intf_hdl *intf = &io_priv->intf;
> u16 value = addr & 0xffff;
> - int ret;
>
> if (length > VENDOR_CMD_MAX_DATA_LEN)
> - return _FAIL;
> + return -EINVAL;
>
> - ret = usb_write(intf, value, data, length);
> -
> - return RTW_STATUS_CODE(ret);
> + return usb_write(intf, value, data, length);
> }
>
> static void handle_txrpt_ccx_88e(struct adapter *adapter, u8 *buf)
Tested-by: Philipp Hortmann <philipp.g.hortmann@gmail.com> # Edimax N150
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2023-01-08 16:44 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-01-08 12:38 [PATCH] staging: r8188eu: convert rtw_writeN() to common error logic Michael Straube
2023-01-08 16:43 ` Philipp Hortmann
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox