linux-wireless.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] staging: r8188eu: Fix some endian problems
@ 2023-01-19 19:12 Larry Finger
  2023-01-19 23:31 ` Philipp Hortmann
  2023-01-20  5:07 ` Dan Carpenter
  0 siblings, 2 replies; 3+ messages in thread
From: Larry Finger @ 2023-01-19 19:12 UTC (permalink / raw)
  To: gregkh
  Cc: phil, linux-staging, linux-kernel, linux-wireless, Larry Finger,
	Gaurav Pathak

Sparse lists the following warnings:

  CHECK   drivers/staging/r8188eu/core/rtw_mlme.c
drivers/staging/r8188eu/core/rtw_mlme.c:1197:49: warning: incorrect type in
					 argument 2 (different base types)
drivers/staging/r8188eu/core/rtw_mlme.c:1197:49:    expected restricted
					 __le16 [usertype] mstatus_rpt
drivers/staging/r8188eu/core/rtw_mlme.c:1197:49:    got unsigned short
					 [assigned] [usertype] media_status_rpt
drivers/staging/r8188eu/core/rtw_mlme.c:1275:57: warning: incorrect type in
					 argument 2 (different base types)
drivers/staging/r8188eu/core/rtw_mlme.c:1275:57:    expected restricted
					 __le16 [usertype] mstatus_rpt
drivers/staging/r8188eu/core/rtw_mlme.c:1275:57:    got unsigned short
					 [assigned] [usertype] media_status
  CHECK   drivers/staging/r8188eu/core/rtw_mlme_ext.c
drivers/staging/r8188eu/core/rtw_mlme_ext.c:6842:58: warning: incorrect type
					 in argument 2 (different base types)
drivers/staging/r8188eu/core/rtw_mlme_ext.c:6842:58:    expected restricted
					 __le16 [usertype] mstatus_rpt
drivers/staging/r8188eu/core/rtw_mlme_ext.c:6842:58:    got unsigned short
					 [assigned] [usertype] media_status

The second argument of rtl8188e_set_FwMediaStatus_cmd() needs to be in CPU
order, not little-endian; however, when it uses that value to call
FillH2CCmd_88E() the parameter must be in little-endian order as that
value will be sent to the firmware. Note that the conversion from LE to CPU
order was le16_to_cpu() rather than the correct cpu_to_le16.

The definition of FillH2CCmd_88E() is revised, and the proper conversion
routine is used.

Note that the original code performed one byte swap on the secong argument
of FillH2CCmd_88E(), and got the correct answer even though the semantics
were very wrong.

Signed-off-by: Larry Finger <Larry.Finger@lwfinger.net>
Reportewd-by: Gaurav Pathak <gauravpathak129@gmail.com>
---
Greg,

I intended this patch as an example for Gaurav, but as it has not been
resubmitted, I am sending it to you. If you thing he deserves to be the
author, then please edit the patch before applying. Thanks, Larry
---

 drivers/staging/r8188eu/hal/rtl8188e_cmd.c     | 4 ++--
 drivers/staging/r8188eu/include/rtl8188e_cmd.h | 2 +-
 2 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/drivers/staging/r8188eu/hal/rtl8188e_cmd.c b/drivers/staging/r8188eu/hal/rtl8188e_cmd.c
index 8310d7f53982..788904d4655c 100644
--- a/drivers/staging/r8188eu/hal/rtl8188e_cmd.c
+++ b/drivers/staging/r8188eu/hal/rtl8188e_cmd.c
@@ -193,9 +193,9 @@ void rtl8188e_set_FwPwrMode_cmd(struct adapter *adapt, u8 Mode)
 
 }
 
-void rtl8188e_set_FwMediaStatus_cmd(struct adapter *adapt, __le16 mstatus_rpt)
+void rtl8188e_set_FwMediaStatus_cmd(struct adapter *adapt, u16 mstatus_rpt)
 {
-	u16 mst_rpt = le16_to_cpu(mstatus_rpt);
+	__le16 mst_rpt = cpu_to_le16(mstatus_rpt);
 
 	FillH2CCmd_88E(adapt, H2C_COM_MEDIA_STATUS_RPT, sizeof(mst_rpt), (u8 *)&mst_rpt);
 }
diff --git a/drivers/staging/r8188eu/include/rtl8188e_cmd.h b/drivers/staging/r8188eu/include/rtl8188e_cmd.h
index 1e01c1662f9a..c785cf8ed683 100644
--- a/drivers/staging/r8188eu/include/rtl8188e_cmd.h
+++ b/drivers/staging/r8188eu/include/rtl8188e_cmd.h
@@ -85,6 +85,6 @@ void rtl8188e_Add_RateATid(struct adapter *padapter, u32 bitmap, u8 arg,
 void rtl8188e_set_p2p_ps_offload_cmd(struct adapter *adapt, u8 p2p_ps_state);
 
 void CheckFwRsvdPageContent(struct adapter *adapt);
-void rtl8188e_set_FwMediaStatus_cmd(struct adapter *adapt, __le16 mstatus_rpt);
+void rtl8188e_set_FwMediaStatus_cmd(struct adapter *adapt, u16 mstatus_rpt);
 
 #endif/* __RTL8188E_CMD_H__ */
-- 
2.39.0


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

* Re: [PATCH] staging: r8188eu: Fix some endian problems
  2023-01-19 19:12 [PATCH] staging: r8188eu: Fix some endian problems Larry Finger
@ 2023-01-19 23:31 ` Philipp Hortmann
  2023-01-20  5:07 ` Dan Carpenter
  1 sibling, 0 replies; 3+ messages in thread
From: Philipp Hortmann @ 2023-01-19 23:31 UTC (permalink / raw)
  To: Larry Finger, gregkh
  Cc: phil, linux-staging, linux-kernel, linux-wireless, Gaurav Pathak

On 1/19/23 20:12, Larry Finger wrote:
> Sparse lists the following warnings:
> 
>    CHECK   drivers/staging/r8188eu/core/rtw_mlme.c
> drivers/staging/r8188eu/core/rtw_mlme.c:1197:49: warning: incorrect type in
> 					 argument 2 (different base types)
> drivers/staging/r8188eu/core/rtw_mlme.c:1197:49:    expected restricted
> 					 __le16 [usertype] mstatus_rpt
> drivers/staging/r8188eu/core/rtw_mlme.c:1197:49:    got unsigned short
> 					 [assigned] [usertype] media_status_rpt
> drivers/staging/r8188eu/core/rtw_mlme.c:1275:57: warning: incorrect type in
> 					 argument 2 (different base types)
> drivers/staging/r8188eu/core/rtw_mlme.c:1275:57:    expected restricted
> 					 __le16 [usertype] mstatus_rpt
> drivers/staging/r8188eu/core/rtw_mlme.c:1275:57:    got unsigned short
> 					 [assigned] [usertype] media_status
>    CHECK   drivers/staging/r8188eu/core/rtw_mlme_ext.c
> drivers/staging/r8188eu/core/rtw_mlme_ext.c:6842:58: warning: incorrect type
> 					 in argument 2 (different base types)
> drivers/staging/r8188eu/core/rtw_mlme_ext.c:6842:58:    expected restricted
> 					 __le16 [usertype] mstatus_rpt
> drivers/staging/r8188eu/core/rtw_mlme_ext.c:6842:58:    got unsigned short
> 					 [assigned] [usertype] media_status
> 
> The second argument of rtl8188e_set_FwMediaStatus_cmd() needs to be in CPU
> order, not little-endian; however, when it uses that value to call
> FillH2CCmd_88E() the parameter must be in little-endian order as that
> value will be sent to the firmware. Note that the conversion from LE to CPU
> order was le16_to_cpu() rather than the correct cpu_to_le16.
> 
> The definition of FillH2CCmd_88E() is revised, and the proper conversion
> routine is used.
> 
> Note that the original code performed one byte swap on the secong argument
> of FillH2CCmd_88E(), and got the correct answer even though the semantics
> were very wrong.
> 
> Signed-off-by: Larry Finger<Larry.Finger@lwfinger.net>
> Reportewd-by: Gaurav Pathak<gauravpathak129@gmail.com>


Checkpatch does not like the "w" in "Reportewd-by:".

Tested on x86_64
Tested-by: Philipp Hortmann <philipp.g.hortmann@gmail.com> # Edimax N150




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

* Re: [PATCH] staging: r8188eu: Fix some endian problems
  2023-01-19 19:12 [PATCH] staging: r8188eu: Fix some endian problems Larry Finger
  2023-01-19 23:31 ` Philipp Hortmann
@ 2023-01-20  5:07 ` Dan Carpenter
  1 sibling, 0 replies; 3+ messages in thread
From: Dan Carpenter @ 2023-01-20  5:07 UTC (permalink / raw)
  To: Larry Finger
  Cc: gregkh, phil, linux-staging, linux-kernel, linux-wireless, Gaurav Pathak

On Thu, Jan 19, 2023 at 01:12:19PM -0600, Larry Finger wrote:
> Sparse lists the following warnings:
> 
>   CHECK   drivers/staging/r8188eu/core/rtw_mlme.c
> drivers/staging/r8188eu/core/rtw_mlme.c:1197:49: warning: incorrect type in
> 					 argument 2 (different base types)
> drivers/staging/r8188eu/core/rtw_mlme.c:1197:49:    expected restricted
> 					 __le16 [usertype] mstatus_rpt
> drivers/staging/r8188eu/core/rtw_mlme.c:1197:49:    got unsigned short
> 					 [assigned] [usertype] media_status_rpt
> drivers/staging/r8188eu/core/rtw_mlme.c:1275:57: warning: incorrect type in
> 					 argument 2 (different base types)
> drivers/staging/r8188eu/core/rtw_mlme.c:1275:57:    expected restricted
> 					 __le16 [usertype] mstatus_rpt
> drivers/staging/r8188eu/core/rtw_mlme.c:1275:57:    got unsigned short
> 					 [assigned] [usertype] media_status
>   CHECK   drivers/staging/r8188eu/core/rtw_mlme_ext.c
> drivers/staging/r8188eu/core/rtw_mlme_ext.c:6842:58: warning: incorrect type
> 					 in argument 2 (different base types)
> drivers/staging/r8188eu/core/rtw_mlme_ext.c:6842:58:    expected restricted
> 					 __le16 [usertype] mstatus_rpt
> drivers/staging/r8188eu/core/rtw_mlme_ext.c:6842:58:    got unsigned short
> 					 [assigned] [usertype] media_status
> 
> The second argument of rtl8188e_set_FwMediaStatus_cmd() needs to be in CPU
> order, not little-endian; however, when it uses that value to call
> FillH2CCmd_88E() the parameter must be in little-endian order as that
> value will be sent to the firmware. Note that the conversion from LE to CPU
> order was le16_to_cpu() rather than the correct cpu_to_le16.
> 
> The definition of FillH2CCmd_88E() is revised, and the proper conversion
> routine is used.
> 
> Note that the original code performed one byte swap on the secong argument
> of FillH2CCmd_88E(), and got the correct answer even though the semantics
> were very wrong.
> 
> Signed-off-by: Larry Finger <Larry.Finger@lwfinger.net>
> Reportewd-by: Gaurav Pathak <gauravpathak129@gmail.com>
         ^
Extra 'w'.

Reviewed-by: Dan Carpenter <error27@gmail.com>

regards,
dan carpenter


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

end of thread, other threads:[~2023-01-20  5:18 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-01-19 19:12 [PATCH] staging: r8188eu: Fix some endian problems Larry Finger
2023-01-19 23:31 ` Philipp Hortmann
2023-01-20  5:07 ` Dan Carpenter

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).