linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 1/2] Fix sparse warnings by using appropriate endian types
@ 2017-03-02 20:30 Adrien Descamps
  2017-03-02 20:30 ` [PATCH 2/2] Fix endiannes error Adrien Descamps
  0 siblings, 1 reply; 8+ messages in thread
From: Adrien Descamps @ 2017-03-02 20:30 UTC (permalink / raw)
  To: gregkh; +Cc: devel, linux-kernel, Adrien Descamps

Fix some sparse warning by using correct endian types in structs and
local variables.
This patch only fix sparse warnings and do not change the logic.
Compile tested only.

Signed-off-by: Adrien Descamps <adrien.descamps@gmail.com>
---
 drivers/staging/wlan-ng/hfa384x.h     | 58 +++++++++++++++++------------------
 drivers/staging/wlan-ng/hfa384x_usb.c |  2 +-
 drivers/staging/wlan-ng/p80211conv.h  | 28 ++++++++---------
 3 files changed, 44 insertions(+), 44 deletions(-)

diff --git a/drivers/staging/wlan-ng/hfa384x.h b/drivers/staging/wlan-ng/hfa384x.h
index 60caf9c..7bcc0db 100644
--- a/drivers/staging/wlan-ng/hfa384x.h
+++ b/drivers/staging/wlan-ng/hfa384x.h
@@ -482,7 +482,7 @@ struct hfa384x_tx_frame {
 	u8 address3[6];
 	u16 sequence_control;
 	u8 address4[6];
-	u16 data_len;		/* little endian format */
+	__le16 data_len;		/* little endian format */
 
 	/*-- 802.3 Header Information --*/
 
@@ -801,41 +801,41 @@ struct hfa384x_usb_txfrm {
 } __packed;
 
 struct hfa384x_usb_cmdreq {
-	u16 type;
-	u16 cmd;
-	u16 parm0;
-	u16 parm1;
-	u16 parm2;
+	__le16 type;
+	__le16 cmd;
+	__le16 parm0;
+	__le16 parm1;
+	__le16 parm2;
 	u8 pad[54];
 } __packed;
 
 struct hfa384x_usb_wridreq {
-	u16 type;
-	u16 frmlen;
-	u16 rid;
+	__le16 type;
+	__le16 frmlen;
+	__le16 rid;
 	u8 data[HFA384x_RIDDATA_MAXLEN];
 } __packed;
 
 struct hfa384x_usb_rridreq {
-	u16 type;
-	u16 frmlen;
-	u16 rid;
+	__le16 type;
+	__le16 frmlen;
+	__le16 rid;
 	u8 pad[58];
 } __packed;
 
 struct hfa384x_usb_wmemreq {
-	u16 type;
-	u16 frmlen;
-	u16 offset;
-	u16 page;
+	__le16 type;
+	__le16 frmlen;
+	__le16 offset;
+	__le16 page;
 	u8 data[HFA384x_USB_RWMEM_MAXLEN];
 } __packed;
 
 struct hfa384x_usb_rmemreq {
-	u16 type;
-	u16 frmlen;
-	u16 offset;
-	u16 page;
+	__le16 type;
+	__le16 frmlen;
+	__le16 offset;
+	__le16 page;
 	u8 pad[56];
 } __packed;
 
@@ -854,16 +854,16 @@ struct hfa384x_usb_infofrm {
 
 struct hfa384x_usb_statusresp {
 	u16 type;
-	u16 status;
-	u16 resp0;
-	u16 resp1;
-	u16 resp2;
+	__le16 status;
+	__le16 resp0;
+	__le16 resp1;
+	__le16 resp2;
 } __packed;
 
 struct hfa384x_usb_rridresp {
 	u16 type;
-	u16 frmlen;
-	u16 rid;
+	__le16 frmlen;
+	__le16 rid;
 	u8 data[HFA384x_RIDDATA_MAXLEN];
 } __packed;
 
@@ -1388,13 +1388,13 @@ static inline int hfa384x_drvr_getconfig16(struct hfa384x *hw, u16 rid, void *va
 
 	result = hfa384x_drvr_getconfig(hw, rid, val, sizeof(u16));
 	if (result == 0)
-		*((u16 *)val) = le16_to_cpu(*((u16 *)val));
+		*((u16 *)val) = le16_to_cpu(*((__le16 *)val));
 	return result;
 }
 
 static inline int hfa384x_drvr_setconfig16(struct hfa384x *hw, u16 rid, u16 val)
 {
-	u16 value = cpu_to_le16(val);
+	__le16 value = cpu_to_le16(val);
 
 	return hfa384x_drvr_setconfig(hw, rid, &value, sizeof(value));
 }
@@ -1408,7 +1408,7 @@ hfa384x_drvr_setconfig_async(struct hfa384x *hw,
 static inline int
 hfa384x_drvr_setconfig16_async(struct hfa384x *hw, u16 rid, u16 val)
 {
-	u16 value = cpu_to_le16(val);
+	__le16 value = cpu_to_le16(val);
 
 	return hfa384x_drvr_setconfig_async(hw, rid, &value, sizeof(value),
 					    NULL, NULL);
diff --git a/drivers/staging/wlan-ng/hfa384x_usb.c b/drivers/staging/wlan-ng/hfa384x_usb.c
index 4fe037a..f26cc19 100644
--- a/drivers/staging/wlan-ng/hfa384x_usb.c
+++ b/drivers/staging/wlan-ng/hfa384x_usb.c
@@ -2316,7 +2316,7 @@ int hfa384x_drvr_ramdl_write(struct hfa384x *hw, u32 daddr, void *buf, u32 len)
 int hfa384x_drvr_readpda(struct hfa384x *hw, void *buf, unsigned int len)
 {
 	int result = 0;
-	u16 *pda = buf;
+	__le16 *pda = buf;
 	int pdaok = 0;
 	int morepdrs = 1;
 	int currpdr = 0;	/* word offset of the current pdr */
diff --git a/drivers/staging/wlan-ng/p80211conv.h b/drivers/staging/wlan-ng/p80211conv.h
index ed70d98..bd66826 100644
--- a/drivers/staging/wlan-ng/p80211conv.h
+++ b/drivers/staging/wlan-ng/p80211conv.h
@@ -101,20 +101,20 @@ void p80211skb_rxmeta_detach(struct sk_buff *skb);
  * Frame capture header.  (See doc/capturefrm.txt)
  */
 struct p80211_caphdr {
-	u32 version;
-	u32 length;
-	u64 mactime;
-	u64 hosttime;
-	u32 phytype;
-	u32 channel;
-	u32 datarate;
-	u32 antenna;
-	u32 priority;
-	u32 ssi_type;
-	s32 ssi_signal;
-	s32 ssi_noise;
-	u32 preamble;
-	u32 encoding;
+	__be32 version;
+	__be32 length;
+	__be64 mactime;
+	__be64 hosttime;
+	__be32 phytype;
+	__be32 channel;
+	__be32 datarate;
+	__be32 antenna;
+	__be32 priority;
+	__be32 ssi_type;
+	__be32 ssi_signal;
+	__be32 ssi_noise;
+	__be32 preamble;
+	__be32 encoding;
 };
 
 /* buffer free method pointer type */
-- 
2.1.4

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

* [PATCH 2/2] Fix endiannes error
  2017-03-02 20:30 [PATCH 1/2] Fix sparse warnings by using appropriate endian types Adrien Descamps
@ 2017-03-02 20:30 ` Adrien Descamps
  2017-03-03 11:29   ` Dan Carpenter
  0 siblings, 1 reply; 8+ messages in thread
From: Adrien Descamps @ 2017-03-02 20:30 UTC (permalink / raw)
  To: gregkh; +Cc: devel, linux-kernel, Adrien Descamps

sparse report fixed:
drivers/staging//wlan-ng//hfa384x_usb.c:3517:35: warning: restricted __be64 degrades to integer
drivers/staging//wlan-ng//hfa384x_usb.c:3517:33: warning: incorrect type in assignment (different base types)
drivers/staging//wlan-ng//hfa384x_usb.c:3517:33:    expected restricted __be64 [usertype] mactime
drivers/staging//wlan-ng//hfa384x_usb.c:3517:33:    got unsigned long long

Computation on the value should be done when in machine format, not in big endian format.
Compile tested only.

Signed-off-by: Adrien Descamps <adrien.descamps@gmail.com>
---
 drivers/staging/wlan-ng/hfa384x_usb.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/staging/wlan-ng/hfa384x_usb.c b/drivers/staging/wlan-ng/hfa384x_usb.c
index f26cc19..29b059f 100644
--- a/drivers/staging/wlan-ng/hfa384x_usb.c
+++ b/drivers/staging/wlan-ng/hfa384x_usb.c
@@ -3514,7 +3514,7 @@ static void hfa384x_int_rxmonitor(struct wlandevice *wlandev,
 
 		caphdr->version = htonl(P80211CAPTURE_VERSION);
 		caphdr->length = htonl(sizeof(struct p80211_caphdr));
-		caphdr->mactime = __cpu_to_be64(rxdesc->time) * 1000;
+		caphdr->mactime = __cpu_to_be64(rxdesc->time * 1000);
 		caphdr->hosttime = __cpu_to_be64(jiffies);
 		caphdr->phytype = htonl(4);	/* dss_dot11_b */
 		caphdr->channel = htonl(hw->sniff_channel);
-- 
2.1.4

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

* Re: [PATCH 2/2] Fix endiannes error
  2017-03-02 20:30 ` [PATCH 2/2] Fix endiannes error Adrien Descamps
@ 2017-03-03 11:29   ` Dan Carpenter
  2017-03-03 18:58     ` [PATCH 1/2] Staging: wlan-ng: Fix sparse warnings by using appropriate endian types Adrien Descamps
  0 siblings, 1 reply; 8+ messages in thread
From: Dan Carpenter @ 2017-03-03 11:29 UTC (permalink / raw)
  To: Adrien Descamps; +Cc: gregkh, devel, linux-kernel


These patches look good but you need to resend with a correct subsystem
prefix in the subject.  It should be:

[PATCH 2/2] Staging: wlan-ng: Fix endiannes error

Hm...  Also "endiannes" doesn't look like correct spelling.  Just say
"endian".

On Thu, Mar 02, 2017 at 09:30:12PM +0100, Adrien Descamps wrote:
> sparse report fixed:
> drivers/staging//wlan-ng//hfa384x_usb.c:3517:35: warning: restricted __be64 degrades to integer
> drivers/staging//wlan-ng//hfa384x_usb.c:3517:33: warning: incorrect type in assignment (different base types)
> drivers/staging//wlan-ng//hfa384x_usb.c:3517:33:    expected restricted __be64 [usertype] mactime
> drivers/staging//wlan-ng//hfa384x_usb.c:3517:33:    got unsigned long long
> 
> Computation on the value should be done when in machine format, not in big endian format.
> Compile tested only.

Generally we like to put the "Compile tested only" bit under the ---
cut off so that our patches look more confident and authoritative.  ;)

> 
> Signed-off-by: Adrien Descamps <adrien.descamps@gmail.com>
> ---

Put it here.

>  drivers/staging/wlan-ng/hfa384x_usb.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 


regards,
dan carpenter

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

* [PATCH 1/2] Staging: wlan-ng: Fix sparse warnings by using appropriate endian types
  2017-03-03 11:29   ` Dan Carpenter
@ 2017-03-03 18:58     ` Adrien Descamps
  2017-03-03 18:58       ` [PATCH 2/2] Staging: wlan-ng: Fix endian error Adrien Descamps
  2017-03-09 18:05       ` [PATCH 1/2] Staging: wlan-ng: Fix sparse warnings by using appropriate endian types Greg KH
  0 siblings, 2 replies; 8+ messages in thread
From: Adrien Descamps @ 2017-03-03 18:58 UTC (permalink / raw)
  To: gregkh; +Cc: devel, linux-kernel, Adrien Descamps

Fix some sparse warning by using correct endian types in structs and
local variables.
This patch only fix sparse warnings and do not change the logic.

Signed-off-by: Adrien Descamps <adrien.descamps@gmail.com>
---
Compile tested only
 drivers/staging/wlan-ng/hfa384x.h     | 58 +++++++++++++++++------------------
 drivers/staging/wlan-ng/hfa384x_usb.c |  2 +-
 drivers/staging/wlan-ng/p80211conv.h  | 28 ++++++++---------
 3 files changed, 44 insertions(+), 44 deletions(-)

diff --git a/drivers/staging/wlan-ng/hfa384x.h b/drivers/staging/wlan-ng/hfa384x.h
index 60caf9c..7bcc0db 100644
--- a/drivers/staging/wlan-ng/hfa384x.h
+++ b/drivers/staging/wlan-ng/hfa384x.h
@@ -482,7 +482,7 @@ struct hfa384x_tx_frame {
 	u8 address3[6];
 	u16 sequence_control;
 	u8 address4[6];
-	u16 data_len;		/* little endian format */
+	__le16 data_len;		/* little endian format */
 
 	/*-- 802.3 Header Information --*/
 
@@ -801,41 +801,41 @@ struct hfa384x_usb_txfrm {
 } __packed;
 
 struct hfa384x_usb_cmdreq {
-	u16 type;
-	u16 cmd;
-	u16 parm0;
-	u16 parm1;
-	u16 parm2;
+	__le16 type;
+	__le16 cmd;
+	__le16 parm0;
+	__le16 parm1;
+	__le16 parm2;
 	u8 pad[54];
 } __packed;
 
 struct hfa384x_usb_wridreq {
-	u16 type;
-	u16 frmlen;
-	u16 rid;
+	__le16 type;
+	__le16 frmlen;
+	__le16 rid;
 	u8 data[HFA384x_RIDDATA_MAXLEN];
 } __packed;
 
 struct hfa384x_usb_rridreq {
-	u16 type;
-	u16 frmlen;
-	u16 rid;
+	__le16 type;
+	__le16 frmlen;
+	__le16 rid;
 	u8 pad[58];
 } __packed;
 
 struct hfa384x_usb_wmemreq {
-	u16 type;
-	u16 frmlen;
-	u16 offset;
-	u16 page;
+	__le16 type;
+	__le16 frmlen;
+	__le16 offset;
+	__le16 page;
 	u8 data[HFA384x_USB_RWMEM_MAXLEN];
 } __packed;
 
 struct hfa384x_usb_rmemreq {
-	u16 type;
-	u16 frmlen;
-	u16 offset;
-	u16 page;
+	__le16 type;
+	__le16 frmlen;
+	__le16 offset;
+	__le16 page;
 	u8 pad[56];
 } __packed;
 
@@ -854,16 +854,16 @@ struct hfa384x_usb_infofrm {
 
 struct hfa384x_usb_statusresp {
 	u16 type;
-	u16 status;
-	u16 resp0;
-	u16 resp1;
-	u16 resp2;
+	__le16 status;
+	__le16 resp0;
+	__le16 resp1;
+	__le16 resp2;
 } __packed;
 
 struct hfa384x_usb_rridresp {
 	u16 type;
-	u16 frmlen;
-	u16 rid;
+	__le16 frmlen;
+	__le16 rid;
 	u8 data[HFA384x_RIDDATA_MAXLEN];
 } __packed;
 
@@ -1388,13 +1388,13 @@ static inline int hfa384x_drvr_getconfig16(struct hfa384x *hw, u16 rid, void *va
 
 	result = hfa384x_drvr_getconfig(hw, rid, val, sizeof(u16));
 	if (result == 0)
-		*((u16 *)val) = le16_to_cpu(*((u16 *)val));
+		*((u16 *)val) = le16_to_cpu(*((__le16 *)val));
 	return result;
 }
 
 static inline int hfa384x_drvr_setconfig16(struct hfa384x *hw, u16 rid, u16 val)
 {
-	u16 value = cpu_to_le16(val);
+	__le16 value = cpu_to_le16(val);
 
 	return hfa384x_drvr_setconfig(hw, rid, &value, sizeof(value));
 }
@@ -1408,7 +1408,7 @@ hfa384x_drvr_setconfig_async(struct hfa384x *hw,
 static inline int
 hfa384x_drvr_setconfig16_async(struct hfa384x *hw, u16 rid, u16 val)
 {
-	u16 value = cpu_to_le16(val);
+	__le16 value = cpu_to_le16(val);
 
 	return hfa384x_drvr_setconfig_async(hw, rid, &value, sizeof(value),
 					    NULL, NULL);
diff --git a/drivers/staging/wlan-ng/hfa384x_usb.c b/drivers/staging/wlan-ng/hfa384x_usb.c
index 4fe037a..f26cc19 100644
--- a/drivers/staging/wlan-ng/hfa384x_usb.c
+++ b/drivers/staging/wlan-ng/hfa384x_usb.c
@@ -2316,7 +2316,7 @@ int hfa384x_drvr_ramdl_write(struct hfa384x *hw, u32 daddr, void *buf, u32 len)
 int hfa384x_drvr_readpda(struct hfa384x *hw, void *buf, unsigned int len)
 {
 	int result = 0;
-	u16 *pda = buf;
+	__le16 *pda = buf;
 	int pdaok = 0;
 	int morepdrs = 1;
 	int currpdr = 0;	/* word offset of the current pdr */
diff --git a/drivers/staging/wlan-ng/p80211conv.h b/drivers/staging/wlan-ng/p80211conv.h
index ed70d98..bd66826 100644
--- a/drivers/staging/wlan-ng/p80211conv.h
+++ b/drivers/staging/wlan-ng/p80211conv.h
@@ -101,20 +101,20 @@ void p80211skb_rxmeta_detach(struct sk_buff *skb);
  * Frame capture header.  (See doc/capturefrm.txt)
  */
 struct p80211_caphdr {
-	u32 version;
-	u32 length;
-	u64 mactime;
-	u64 hosttime;
-	u32 phytype;
-	u32 channel;
-	u32 datarate;
-	u32 antenna;
-	u32 priority;
-	u32 ssi_type;
-	s32 ssi_signal;
-	s32 ssi_noise;
-	u32 preamble;
-	u32 encoding;
+	__be32 version;
+	__be32 length;
+	__be64 mactime;
+	__be64 hosttime;
+	__be32 phytype;
+	__be32 channel;
+	__be32 datarate;
+	__be32 antenna;
+	__be32 priority;
+	__be32 ssi_type;
+	__be32 ssi_signal;
+	__be32 ssi_noise;
+	__be32 preamble;
+	__be32 encoding;
 };
 
 /* buffer free method pointer type */
-- 
2.1.4

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

* [PATCH 2/2] Staging: wlan-ng: Fix endian error
  2017-03-03 18:58     ` [PATCH 1/2] Staging: wlan-ng: Fix sparse warnings by using appropriate endian types Adrien Descamps
@ 2017-03-03 18:58       ` Adrien Descamps
  2017-03-09 18:05       ` [PATCH 1/2] Staging: wlan-ng: Fix sparse warnings by using appropriate endian types Greg KH
  1 sibling, 0 replies; 8+ messages in thread
From: Adrien Descamps @ 2017-03-03 18:58 UTC (permalink / raw)
  To: gregkh; +Cc: devel, linux-kernel, Adrien Descamps

sparse report fixed:
drivers/staging//wlan-ng//hfa384x_usb.c:3517:35: warning: restricted __be64 degrades to integer
drivers/staging//wlan-ng//hfa384x_usb.c:3517:33: warning: incorrect type in assignment (different base types)
drivers/staging//wlan-ng//hfa384x_usb.c:3517:33:    expected restricted __be64 [usertype] mactime
drivers/staging//wlan-ng//hfa384x_usb.c:3517:33:    got unsigned long long

Computation on the value should be done when in machine format, not in big endian format.

Signed-off-by: Adrien Descamps <adrien.descamps@gmail.com>
---
Compile tested only
 drivers/staging/wlan-ng/hfa384x_usb.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/staging/wlan-ng/hfa384x_usb.c b/drivers/staging/wlan-ng/hfa384x_usb.c
index f26cc19..29b059f 100644
--- a/drivers/staging/wlan-ng/hfa384x_usb.c
+++ b/drivers/staging/wlan-ng/hfa384x_usb.c
@@ -3514,7 +3514,7 @@ static void hfa384x_int_rxmonitor(struct wlandevice *wlandev,
 
 		caphdr->version = htonl(P80211CAPTURE_VERSION);
 		caphdr->length = htonl(sizeof(struct p80211_caphdr));
-		caphdr->mactime = __cpu_to_be64(rxdesc->time) * 1000;
+		caphdr->mactime = __cpu_to_be64(rxdesc->time * 1000);
 		caphdr->hosttime = __cpu_to_be64(jiffies);
 		caphdr->phytype = htonl(4);	/* dss_dot11_b */
 		caphdr->channel = htonl(hw->sniff_channel);
-- 
2.1.4

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

* Re: [PATCH 1/2] Staging: wlan-ng: Fix sparse warnings by using appropriate endian types
  2017-03-03 18:58     ` [PATCH 1/2] Staging: wlan-ng: Fix sparse warnings by using appropriate endian types Adrien Descamps
  2017-03-03 18:58       ` [PATCH 2/2] Staging: wlan-ng: Fix endian error Adrien Descamps
@ 2017-03-09 18:05       ` Greg KH
  2017-03-09 20:15         ` Adrien Descamps
  1 sibling, 1 reply; 8+ messages in thread
From: Greg KH @ 2017-03-09 18:05 UTC (permalink / raw)
  To: Adrien Descamps; +Cc: devel, linux-kernel

On Fri, Mar 03, 2017 at 07:58:30PM +0100, Adrien Descamps wrote:
> Fix some sparse warning by using correct endian types in structs and
> local variables.
> This patch only fix sparse warnings and do not change the logic.
> 
> Signed-off-by: Adrien Descamps <adrien.descamps@gmail.com>
> ---
> Compile tested only
>  drivers/staging/wlan-ng/hfa384x.h     | 58 +++++++++++++++++------------------
>  drivers/staging/wlan-ng/hfa384x_usb.c |  2 +-
>  drivers/staging/wlan-ng/p80211conv.h  | 28 ++++++++---------
>  3 files changed, 44 insertions(+), 44 deletions(-)

Patch does not apply to my staging-next branch.  Can you rebase it and
resend?

thanks,

greg k-h

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

* [PATCH 1/2] Staging: wlan-ng: Fix sparse warnings by using appropriate endian types
  2017-03-09 18:05       ` [PATCH 1/2] Staging: wlan-ng: Fix sparse warnings by using appropriate endian types Greg KH
@ 2017-03-09 20:15         ` Adrien Descamps
  2017-03-09 20:15           ` [PATCH 2/2] Staging: wlan-ng: Fix endian error Adrien Descamps
  0 siblings, 1 reply; 8+ messages in thread
From: Adrien Descamps @ 2017-03-09 20:15 UTC (permalink / raw)
  To: gregkh; +Cc: devel, linux-kernel, Adrien Descamps

Fix some sparse warning by using correct endian types in structs and
local variables.
This patch only fix sparse warnings and do not change the logic.

Signed-off-by: Adrien Descamps <adrien.descamps@gmail.com>
---
Compile tested only
 drivers/staging/wlan-ng/hfa384x.h     | 54 +++++++++++++++++------------------
 drivers/staging/wlan-ng/hfa384x_usb.c |  2 +-
 drivers/staging/wlan-ng/p80211conv.h  | 28 +++++++++---------
 3 files changed, 42 insertions(+), 42 deletions(-)

diff --git a/drivers/staging/wlan-ng/hfa384x.h b/drivers/staging/wlan-ng/hfa384x.h
index 5f1851c..ba67b7a 100644
--- a/drivers/staging/wlan-ng/hfa384x.h
+++ b/drivers/staging/wlan-ng/hfa384x.h
@@ -482,7 +482,7 @@ struct hfa384x_tx_frame {
 	u8 address3[6];
 	u16 sequence_control;
 	u8 address4[6];
-	u16 data_len;		/* little endian format */
+	__le16 data_len;		/* little endian format */
 
 	/*-- 802.3 Header Information --*/
 
@@ -801,41 +801,41 @@ struct hfa384x_usb_txfrm {
 } __packed;
 
 struct hfa384x_usb_cmdreq {
-	u16 type;
-	u16 cmd;
-	u16 parm0;
-	u16 parm1;
-	u16 parm2;
+	__le16 type;
+	__le16 cmd;
+	__le16 parm0;
+	__le16 parm1;
+	__le16 parm2;
 	u8 pad[54];
 } __packed;
 
 struct hfa384x_usb_wridreq {
-	u16 type;
-	u16 frmlen;
-	u16 rid;
+	__le16 type;
+	__le16 frmlen;
+	__le16 rid;
 	u8 data[HFA384x_RIDDATA_MAXLEN];
 } __packed;
 
 struct hfa384x_usb_rridreq {
-	u16 type;
-	u16 frmlen;
-	u16 rid;
+	__le16 type;
+	__le16 frmlen;
+	__le16 rid;
 	u8 pad[58];
 } __packed;
 
 struct hfa384x_usb_wmemreq {
-	u16 type;
-	u16 frmlen;
-	u16 offset;
-	u16 page;
+	__le16 type;
+	__le16 frmlen;
+	__le16 offset;
+	__le16 page;
 	u8 data[HFA384x_USB_RWMEM_MAXLEN];
 } __packed;
 
 struct hfa384x_usb_rmemreq {
-	u16 type;
-	u16 frmlen;
-	u16 offset;
-	u16 page;
+	__le16 type;
+	__le16 frmlen;
+	__le16 offset;
+	__le16 page;
 	u8 pad[56];
 } __packed;
 
@@ -854,16 +854,16 @@ struct hfa384x_usb_infofrm {
 
 struct hfa384x_usb_statusresp {
 	u16 type;
-	u16 status;
-	u16 resp0;
-	u16 resp1;
-	u16 resp2;
+	__le16 status;
+	__le16 resp0;
+	__le16 resp1;
+	__le16 resp2;
 } __packed;
 
 struct hfa384x_usb_rridresp {
 	u16 type;
-	u16 frmlen;
-	u16 rid;
+	__le16 frmlen;
+	__le16 rid;
 	u8 data[HFA384x_RIDDATA_MAXLEN];
 } __packed;
 
@@ -1408,7 +1408,7 @@ hfa384x_drvr_setconfig_async(struct hfa384x *hw,
 static inline int
 hfa384x_drvr_setconfig16_async(struct hfa384x *hw, u16 rid, u16 val)
 {
-	u16 value = cpu_to_le16(val);
+	__le16 value = cpu_to_le16(val);
 
 	return hfa384x_drvr_setconfig_async(hw, rid, &value, sizeof(value),
 					    NULL, NULL);
diff --git a/drivers/staging/wlan-ng/hfa384x_usb.c b/drivers/staging/wlan-ng/hfa384x_usb.c
index 6134eba..6484877 100644
--- a/drivers/staging/wlan-ng/hfa384x_usb.c
+++ b/drivers/staging/wlan-ng/hfa384x_usb.c
@@ -2316,7 +2316,7 @@ int hfa384x_drvr_ramdl_write(struct hfa384x *hw, u32 daddr, void *buf, u32 len)
 int hfa384x_drvr_readpda(struct hfa384x *hw, void *buf, unsigned int len)
 {
 	int result = 0;
-	u16 *pda = buf;
+	__le16 *pda = buf;
 	int pdaok = 0;
 	int morepdrs = 1;
 	int currpdr = 0;	/* word offset of the current pdr */
diff --git a/drivers/staging/wlan-ng/p80211conv.h b/drivers/staging/wlan-ng/p80211conv.h
index 04bac2e..66332b1 100644
--- a/drivers/staging/wlan-ng/p80211conv.h
+++ b/drivers/staging/wlan-ng/p80211conv.h
@@ -101,20 +101,20 @@ void p80211skb_rxmeta_detach(struct sk_buff *skb);
  * Frame capture header.  (See doc/capturefrm.txt)
  */
 struct p80211_caphdr {
-	u32 version;
-	u32 length;
-	u64 mactime;
-	u64 hosttime;
-	u32 phytype;
-	u32 channel;
-	u32 datarate;
-	u32 antenna;
-	u32 priority;
-	u32 ssi_type;
-	s32 ssi_signal;
-	s32 ssi_noise;
-	u32 preamble;
-	u32 encoding;
+	__be32 version;
+	__be32 length;
+	__be64 mactime;
+	__be64 hosttime;
+	__be32 phytype;
+	__be32 channel;
+	__be32 datarate;
+	__be32 antenna;
+	__be32 priority;
+	__be32 ssi_type;
+	__be32 ssi_signal;
+	__be32 ssi_noise;
+	__be32 preamble;
+	__be32 encoding;
 };
 
 /* buffer free method pointer type */
-- 
2.1.4

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

* [PATCH 2/2] Staging: wlan-ng: Fix endian error
  2017-03-09 20:15         ` Adrien Descamps
@ 2017-03-09 20:15           ` Adrien Descamps
  0 siblings, 0 replies; 8+ messages in thread
From: Adrien Descamps @ 2017-03-09 20:15 UTC (permalink / raw)
  To: gregkh; +Cc: devel, linux-kernel, Adrien Descamps

sparse report fixed:
drivers/staging//wlan-ng//hfa384x_usb.c:3517:35: warning: restricted __be64 degrades to integer
drivers/staging//wlan-ng//hfa384x_usb.c:3517:33: warning: incorrect type in assignment (different base types)
drivers/staging//wlan-ng//hfa384x_usb.c:3517:33:    expected restricted __be64 [usertype] mactime
drivers/staging//wlan-ng//hfa384x_usb.c:3517:33:    got unsigned long long

Computation on the value should be done when in machine format, not in big endian format.

Signed-off-by: Adrien Descamps <adrien.descamps@gmail.com>
---
Compile tested only
 drivers/staging/wlan-ng/hfa384x_usb.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/staging/wlan-ng/hfa384x_usb.c b/drivers/staging/wlan-ng/hfa384x_usb.c
index 6484877..a812e55 100644
--- a/drivers/staging/wlan-ng/hfa384x_usb.c
+++ b/drivers/staging/wlan-ng/hfa384x_usb.c
@@ -3513,7 +3513,7 @@ static void hfa384x_int_rxmonitor(struct wlandevice *wlandev,
 
 		caphdr->version = htonl(P80211CAPTURE_VERSION);
 		caphdr->length = htonl(sizeof(struct p80211_caphdr));
-		caphdr->mactime = __cpu_to_be64(rxdesc->time) * 1000;
+		caphdr->mactime = __cpu_to_be64(rxdesc->time * 1000);
 		caphdr->hosttime = __cpu_to_be64(jiffies);
 		caphdr->phytype = htonl(4);	/* dss_dot11_b */
 		caphdr->channel = htonl(hw->sniff_channel);
-- 
2.1.4

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

end of thread, other threads:[~2017-03-09 20:15 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-03-02 20:30 [PATCH 1/2] Fix sparse warnings by using appropriate endian types Adrien Descamps
2017-03-02 20:30 ` [PATCH 2/2] Fix endiannes error Adrien Descamps
2017-03-03 11:29   ` Dan Carpenter
2017-03-03 18:58     ` [PATCH 1/2] Staging: wlan-ng: Fix sparse warnings by using appropriate endian types Adrien Descamps
2017-03-03 18:58       ` [PATCH 2/2] Staging: wlan-ng: Fix endian error Adrien Descamps
2017-03-09 18:05       ` [PATCH 1/2] Staging: wlan-ng: Fix sparse warnings by using appropriate endian types Greg KH
2017-03-09 20:15         ` Adrien Descamps
2017-03-09 20:15           ` [PATCH 2/2] Staging: wlan-ng: Fix endian error Adrien Descamps

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).