public inbox for linux-staging@lists.linux.dev
 help / color / mirror / Atom feed
* [PATCH] staging: r8188eu: make c2h_evt_read() static
@ 2022-09-09 10:02 Michael Straube
  2022-09-09 17:39 ` Philipp Hortmann
  0 siblings, 1 reply; 2+ messages in thread
From: Michael Straube @ 2022-09-09 10:02 UTC (permalink / raw)
  To: gregkh; +Cc: Larry.Finger, phil, linux-staging, linux-kernel, Michael Straube

The function c2h_evt_read() is only used in rtw_cmd.c.
Make it static.

This addresses the TODO item:
* Remove the HAL layer and migrate its functionality into the relevant
  parts of the driver.

Signed-off-by: Michael Straube <straube.linux@gmail.com>
---
 drivers/staging/r8188eu/core/rtw_cmd.c    | 60 +++++++++++++++++++++
 drivers/staging/r8188eu/hal/hal_com.c     | 63 -----------------------
 drivers/staging/r8188eu/include/hal_com.h |  2 -
 3 files changed, 60 insertions(+), 65 deletions(-)

diff --git a/drivers/staging/r8188eu/core/rtw_cmd.c b/drivers/staging/r8188eu/core/rtw_cmd.c
index 4be83807405c..ca1f2cc52470 100644
--- a/drivers/staging/r8188eu/core/rtw_cmd.c
+++ b/drivers/staging/r8188eu/core/rtw_cmd.c
@@ -1277,6 +1277,66 @@ u8 rtw_c2h_wk_cmd(struct adapter *padapter, u8 *c2h_evt)
 	return res;
 }
 
+/* C2H event format:
+ * Field    TRIGGER      CONTENT     CMD_SEQ    CMD_LEN    CMD_ID
+ * BITS     [127:120]    [119:16]    [15:8]     [7:4]      [3:0]
+ */
+static s32 c2h_evt_read(struct adapter *adapter, u8 *buf)
+{
+	s32 ret = _FAIL;
+	struct c2h_evt_hdr *c2h_evt;
+	int i;
+	u8 trigger;
+
+	if (!buf)
+		goto exit;
+
+	ret = rtw_read8(adapter, REG_C2HEVT_CLEAR, &trigger);
+	if (ret)
+		return _FAIL;
+
+	if (trigger == C2H_EVT_HOST_CLOSE)
+		goto exit; /* Not ready */
+	else if (trigger != C2H_EVT_FW_CLOSE)
+		goto clear_evt; /* Not a valid value */
+
+	c2h_evt = (struct c2h_evt_hdr *)buf;
+
+	memset(c2h_evt, 0, 16);
+
+	ret = rtw_read8(adapter, REG_C2HEVT_MSG_NORMAL, buf);
+	if (ret) {
+		ret = _FAIL;
+		goto clear_evt;
+	}
+
+	ret = rtw_read8(adapter, REG_C2HEVT_MSG_NORMAL + 1, buf + 1);
+	if (ret) {
+		ret = _FAIL;
+		goto clear_evt;
+	}
+	/* Read the content */
+	for (i = 0; i < c2h_evt->plen; i++) {
+		ret = rtw_read8(adapter, REG_C2HEVT_MSG_NORMAL +
+				sizeof(*c2h_evt) + i, c2h_evt->payload + i);
+		if (ret) {
+			ret = _FAIL;
+			goto clear_evt;
+		}
+	}
+
+	ret = _SUCCESS;
+
+clear_evt:
+	/* Clear event to notify FW we have read the command.
+	 * If this field isn't clear, the FW won't update the next
+	 * command message.
+	 */
+	rtw_write8(adapter, REG_C2HEVT_CLEAR, C2H_EVT_HOST_CLOSE);
+exit:
+	return ret;
+}
+
 static void c2h_evt_hdl(struct adapter *adapter, struct c2h_evt_hdr *c2h_evt, c2h_id_filter filter)
 {
 	u8 buf[16];
diff --git a/drivers/staging/r8188eu/hal/hal_com.c b/drivers/staging/r8188eu/hal/hal_com.c
index 8416a65ba47b..33967eb3c0d0 100644
--- a/drivers/staging/r8188eu/hal/hal_com.c
+++ b/drivers/staging/r8188eu/hal/hal_com.c
@@ -137,66 +137,3 @@ void HalSetBrateCfg(struct adapter *adapt, u8 *brates, u16 *rate_cfg)
 		}
 	}
 }
-
-/*
-* C2H event format:
-* Field	 TRIGGER		CONTENT	   CMD_SEQ	CMD_LEN		 CMD_ID
-* BITS	 [127:120]	[119:16]      [15:8]		  [7:4]		   [3:0]
-*/
-
-s32 c2h_evt_read(struct adapter *adapter, u8 *buf)
-{
-	s32 ret = _FAIL;
-	struct c2h_evt_hdr *c2h_evt;
-	int i;
-	u8 trigger;
-
-	if (!buf)
-		goto exit;
-
-	ret = rtw_read8(adapter, REG_C2HEVT_CLEAR, &trigger);
-	if (ret)
-		return _FAIL;
-
-	if (trigger == C2H_EVT_HOST_CLOSE)
-		goto exit; /* Not ready */
-	else if (trigger != C2H_EVT_FW_CLOSE)
-		goto clear_evt; /* Not a valid value */
-
-	c2h_evt = (struct c2h_evt_hdr *)buf;
-
-	memset(c2h_evt, 0, 16);
-
-	ret = rtw_read8(adapter, REG_C2HEVT_MSG_NORMAL, buf);
-	if (ret) {
-		ret = _FAIL;
-		goto clear_evt;
-	}
-
-	ret = rtw_read8(adapter, REG_C2HEVT_MSG_NORMAL + 1, buf + 1);
-	if (ret) {
-		ret = _FAIL;
-		goto clear_evt;
-	}
-	/* Read the content */
-	for (i = 0; i < c2h_evt->plen; i++) {
-		ret = rtw_read8(adapter, REG_C2HEVT_MSG_NORMAL +
-						sizeof(*c2h_evt) + i, c2h_evt->payload + i);
-		if (ret) {
-			ret = _FAIL;
-			goto clear_evt;
-		}
-	}
-
-	ret = _SUCCESS;
-
-clear_evt:
-	/*
-	* Clear event to notify FW we have read the command.
-	* If this field isn't clear, the FW won't update the next
-	* command message.
-	*/
-	rtw_write8(adapter, REG_C2HEVT_CLEAR, C2H_EVT_HOST_CLOSE);
-exit:
-	return ret;
-}
diff --git a/drivers/staging/r8188eu/include/hal_com.h b/drivers/staging/r8188eu/include/hal_com.h
index e8007295cd79..cd3f845e146a 100644
--- a/drivers/staging/r8188eu/include/hal_com.h
+++ b/drivers/staging/r8188eu/include/hal_com.h
@@ -143,6 +143,4 @@ u8 MRateToHwRate(u8 rate);
 
 void HalSetBrateCfg(struct adapter *Adapter, u8 *mBratesOS, u16 *pBrateCfg);
 
-s32 c2h_evt_read(struct adapter *adapter, u8 *buf);
-
 #endif /* __HAL_COMMON_H__ */
-- 
2.37.3


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

* Re: [PATCH] staging: r8188eu: make c2h_evt_read() static
  2022-09-09 10:02 [PATCH] staging: r8188eu: make c2h_evt_read() static Michael Straube
@ 2022-09-09 17:39 ` Philipp Hortmann
  0 siblings, 0 replies; 2+ messages in thread
From: Philipp Hortmann @ 2022-09-09 17:39 UTC (permalink / raw)
  To: Michael Straube, gregkh; +Cc: Larry.Finger, phil, linux-staging, linux-kernel

On 9/9/22 12:02, Michael Straube wrote:
> The function c2h_evt_read() is only used in rtw_cmd.c.
> Make it static.
> 
> This addresses the TODO item:
> * Remove the HAL layer and migrate its functionality into the relevant
>    parts of the driver.
> 
> Signed-off-by: Michael Straube <straube.linux@gmail.com>
> ---
>   drivers/staging/r8188eu/core/rtw_cmd.c    | 60 +++++++++++++++++++++
>   drivers/staging/r8188eu/hal/hal_com.c     | 63 -----------------------
>   drivers/staging/r8188eu/include/hal_com.h |  2 -
>   3 files changed, 60 insertions(+), 65 deletions(-)
> 
> diff --git a/drivers/staging/r8188eu/core/rtw_cmd.c b/drivers/staging/r8188eu/core/rtw_cmd.c
> index 4be83807405c..ca1f2cc52470 100644
> --- a/drivers/staging/r8188eu/core/rtw_cmd.c
> +++ b/drivers/staging/r8188eu/core/rtw_cmd.c
> @@ -1277,6 +1277,66 @@ u8 rtw_c2h_wk_cmd(struct adapter *padapter, u8 *c2h_evt)
>   	return res;
>   }
>   
> +/* C2H event format:
> + * Field    TRIGGER      CONTENT     CMD_SEQ    CMD_LEN    CMD_ID
> + * BITS     [127:120]    [119:16]    [15:8]     [7:4]      [3:0]
> + */
> +static s32 c2h_evt_read(struct adapter *adapter, u8 *buf)
> +{
> +	s32 ret = _FAIL;
> +	struct c2h_evt_hdr *c2h_evt;
> +	int i;
> +	u8 trigger;
> +
> +	if (!buf)
> +		goto exit;
> +
> +	ret = rtw_read8(adapter, REG_C2HEVT_CLEAR, &trigger);
> +	if (ret)
> +		return _FAIL;
> +
> +	if (trigger == C2H_EVT_HOST_CLOSE)
> +		goto exit; /* Not ready */
> +	else if (trigger != C2H_EVT_FW_CLOSE)
> +		goto clear_evt; /* Not a valid value */
> +
> +	c2h_evt = (struct c2h_evt_hdr *)buf;
> +
> +	memset(c2h_evt, 0, 16);
> +
> +	ret = rtw_read8(adapter, REG_C2HEVT_MSG_NORMAL, buf);
> +	if (ret) {
> +		ret = _FAIL;
> +		goto clear_evt;
> +	}
> +
> +	ret = rtw_read8(adapter, REG_C2HEVT_MSG_NORMAL + 1, buf + 1);
> +	if (ret) {
> +		ret = _FAIL;
> +		goto clear_evt;
> +	}
> +	/* Read the content */
> +	for (i = 0; i < c2h_evt->plen; i++) {
> +		ret = rtw_read8(adapter, REG_C2HEVT_MSG_NORMAL +
> +				sizeof(*c2h_evt) + i, c2h_evt->payload + i);
> +		if (ret) {
> +			ret = _FAIL;
> +			goto clear_evt;
> +		}
> +	}
> +
> +	ret = _SUCCESS;
> +
> +clear_evt:
> +	/* Clear event to notify FW we have read the command.
> +	 * If this field isn't clear, the FW won't update the next
> +	 * command message.
> +	 */
> +	rtw_write8(adapter, REG_C2HEVT_CLEAR, C2H_EVT_HOST_CLOSE);
> +exit:
> +	return ret;
> +}
> +
>   static void c2h_evt_hdl(struct adapter *adapter, struct c2h_evt_hdr *c2h_evt, c2h_id_filter filter)
>   {
>   	u8 buf[16];
> diff --git a/drivers/staging/r8188eu/hal/hal_com.c b/drivers/staging/r8188eu/hal/hal_com.c
> index 8416a65ba47b..33967eb3c0d0 100644
> --- a/drivers/staging/r8188eu/hal/hal_com.c
> +++ b/drivers/staging/r8188eu/hal/hal_com.c
> @@ -137,66 +137,3 @@ void HalSetBrateCfg(struct adapter *adapt, u8 *brates, u16 *rate_cfg)
>   		}
>   	}
>   }
> -
> -/*
> -* C2H event format:
> -* Field	 TRIGGER		CONTENT	   CMD_SEQ	CMD_LEN		 CMD_ID
> -* BITS	 [127:120]	[119:16]      [15:8]		  [7:4]		   [3:0]
> -*/
> -
> -s32 c2h_evt_read(struct adapter *adapter, u8 *buf)
> -{
> -	s32 ret = _FAIL;
> -	struct c2h_evt_hdr *c2h_evt;
> -	int i;
> -	u8 trigger;
> -
> -	if (!buf)
> -		goto exit;
> -
> -	ret = rtw_read8(adapter, REG_C2HEVT_CLEAR, &trigger);
> -	if (ret)
> -		return _FAIL;
> -
> -	if (trigger == C2H_EVT_HOST_CLOSE)
> -		goto exit; /* Not ready */
> -	else if (trigger != C2H_EVT_FW_CLOSE)
> -		goto clear_evt; /* Not a valid value */
> -
> -	c2h_evt = (struct c2h_evt_hdr *)buf;
> -
> -	memset(c2h_evt, 0, 16);
> -
> -	ret = rtw_read8(adapter, REG_C2HEVT_MSG_NORMAL, buf);
> -	if (ret) {
> -		ret = _FAIL;
> -		goto clear_evt;
> -	}
> -
> -	ret = rtw_read8(adapter, REG_C2HEVT_MSG_NORMAL + 1, buf + 1);
> -	if (ret) {
> -		ret = _FAIL;
> -		goto clear_evt;
> -	}
> -	/* Read the content */
> -	for (i = 0; i < c2h_evt->plen; i++) {
> -		ret = rtw_read8(adapter, REG_C2HEVT_MSG_NORMAL +
> -						sizeof(*c2h_evt) + i, c2h_evt->payload + i);
> -		if (ret) {
> -			ret = _FAIL;
> -			goto clear_evt;
> -		}
> -	}
> -
> -	ret = _SUCCESS;
> -
> -clear_evt:
> -	/*
> -	* Clear event to notify FW we have read the command.
> -	* If this field isn't clear, the FW won't update the next
> -	* command message.
> -	*/
> -	rtw_write8(adapter, REG_C2HEVT_CLEAR, C2H_EVT_HOST_CLOSE);
> -exit:
> -	return ret;
> -}
> diff --git a/drivers/staging/r8188eu/include/hal_com.h b/drivers/staging/r8188eu/include/hal_com.h
> index e8007295cd79..cd3f845e146a 100644
> --- a/drivers/staging/r8188eu/include/hal_com.h
> +++ b/drivers/staging/r8188eu/include/hal_com.h
> @@ -143,6 +143,4 @@ u8 MRateToHwRate(u8 rate);
>   
>   void HalSetBrateCfg(struct adapter *Adapter, u8 *mBratesOS, u16 *pBrateCfg);
>   
> -s32 c2h_evt_read(struct adapter *adapter, u8 *buf);
> -
>   #endif /* __HAL_COMMON_H__ */

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:[~2022-09-09 17:39 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2022-09-09 10:02 [PATCH] staging: r8188eu: make c2h_evt_read() static Michael Straube
2022-09-09 17:39 ` Philipp Hortmann

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