Skip to contentSkip to conversation

staging: r8712u: remove unnecessary le32_to_cpu

PATCH NAK Perry Hooker 3 participants 9 messages Feb 10, 2017 – Feb 11, 2017 Staging

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 staging: r8712u: remove unnecessary le32_to_cpu

This patch fixes the following sparse warning:
drivers/staging/rtl8712/usb_ops_linux.c:212:33: warning: cast to restricted __le32

---
 drivers/staging/rtl8712/usb_ops_linux.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/staging/rtl8712/usb_ops_linux.c +1 -1
index fc6bb0b..259ef8f 100644
@@ -209,7 +209,7 @@ static void r8712_usb_read_port_complete(struct urb *purb)
 
 			precvbuf->transfer_len = purb->actual_length;
 			pbuf = (uint *)precvbuf->pbuf;
-			isevt = le32_to_cpu(*(pbuf + 1)) & 0x1ff;
+			isevt = *(pbuf + 1) & 0x1ff;
 			if ((isevt & 0x1ff) == 0x1ff) {
 				r8712_rxcmd_event_hdl(padapter, pbuf);
 				skb_queue_tail(&precvpriv->rx_skb_queue, pskb);
Signature · 1 line
2.4.11
maintainer
#1 lore raw
Quoted 7 lines · Perry Hooker

This patch fixes the following sparse warning:
drivers/staging/rtl8712/usb_ops_linux.c:212:33: warning: cast to restricted __le32

---
 drivers/staging/rtl8712/usb_ops_linux.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Does not apply to my tree :(

#2 lore raw
Quoted 10 lines · Greg KH
Quoted 7 lines · Perry Hooker

This patch fixes the following sparse warning:
drivers/staging/rtl8712/usb_ops_linux.c:212:33: warning: cast to restricted __le32

---
 drivers/staging/rtl8712/usb_ops_linux.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Does not apply to my tree :(

That is good. Yes the patch silenced the Sparse warning, but it would BREAK the driver on every big-endian machine. Variable pbuf is a pointer to a string of bytes *in little-endian order* that is to be converted into a cpu-ordered 32-bit quantity. The correct way to silence the warning is to make sure the compiler understands what *(pbuf + 1) really is.

BTW, that driver has been tested on BE hardware. Please be careful about endian changes.

NACK.

Larry

maintainer
#3 lore raw
Quoted 18 lines · Larry Finger
Quoted 10 lines · Greg KH
Quoted 7 lines · Perry Hooker

This patch fixes the following sparse warning:
drivers/staging/rtl8712/usb_ops_linux.c:212:33: warning: cast to restricted __le32

---
 drivers/staging/rtl8712/usb_ops_linux.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Does not apply to my tree :(

That is good. Yes the patch silenced the Sparse warning, but it would BREAK the driver on every big-endian machine. Variable pbuf is a pointer to a string of bytes *in little-endian order* that is to be converted into a cpu-ordered 32-bit quantity. The correct way to silence the warning is to make sure the compiler understands what *(pbuf + 1) really is.

Quoted 4 lines

BTW, that driver has been tested on BE hardware. Please be careful about endian changes.

NACK.

Care to comment this somehow so that I don't accidentally take a patch for this in the future?

thanks,

greg k-h

#4 lore raw
Quoted 19 lines · Greg KH
Quoted 18 lines · Larry Finger
Quoted 10 lines · Greg KH
Quoted 7 lines · Perry Hooker

This patch fixes the following sparse warning:
drivers/staging/rtl8712/usb_ops_linux.c:212:33: warning: cast to restricted __le32

---
 drivers/staging/rtl8712/usb_ops_linux.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Does not apply to my tree :(

That is good. Yes the patch silenced the Sparse warning, but it would BREAK the driver on every big-endian machine. Variable pbuf is a pointer to a string of bytes *in little-endian order* that is to be converted into a cpu-ordered 32-bit quantity. The correct way to silence the warning is to make sure the compiler understands what *(pbuf + 1) really is.

Quoted 7 lines
Quoted 4 lines

BTW, that driver has been tested on BE hardware. Please be careful about endian changes.

NACK.

Care to comment this somehow so that I don't accidentally take a patch for this in the future?

My recollection is that a number of patches had been submitted to clean up the endian warnings, but I do not remember the details.

I will try to reproduce those again, and get them resubmitted to clean up the warnings in a manner that does not break the driver. I do have a BE machine for testing.

Larry

#5 lore raw

Ouch. My apologies. I'll take more care next time. I've supplied an updated patch that uses the __le32 type for *(pbuf + 1).

Quoted 48 lines · Larry Finger
Quoted 27 lines · Greg KH
Quoted 25 lines · Larry Finger
Quoted 7 lines · Greg KH
Quoted 5 lines · Perry Hooker

This patch fixes the following sparse warning:
drivers/staging/rtl8712/usb_ops_linux.c:212:33: warning: cast to restricted __le32

Quoted 7 lines
Quoted 4 lines
---
 drivers/staging/rtl8712/usb_ops_linux.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Does not apply to my tree :(

That is good. Yes the patch silenced the Sparse warning, but it would BREAK
the driver on every big-endian machine. Variable pbuf is a pointer to a string of bytes *in little-endian order* that is to be converted into a cpu-ordered 32-bit quantity. The correct way to silence the warning is to make sure the compiler understands what *(pbuf + 1) really is.

Quoted 8 lines
Quoted 4 lines

BTW, that driver has been tested on BE hardware. Please be careful about endian changes.

NACK.

Care to comment this somehow so that I don't accidentally take a patch for this in the future?

My recollection is that a number of patches had been submitted to clean up the endian warnings, but I do not remember the details.

I will try to reproduce those again, and get them resubmitted to clean up the warnings in a manner that does not break the driver. I do have a BE machine for testing.

Larry

#6 lore raw

PATCH 1/1 staging: r8712u: use __le32 type for little-endian data

In reply to Larry Finger

This patch fixes the following sparse warning:
drivers/staging/rtl8712/usb_ops_linux.c:212:33: warning: cast to restricted __le32

---
 drivers/staging/rtl8712/usb_ops_linux.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)
drivers/staging/rtl8712/usb_ops_linux.c +3 -2
index fc6bb0b..df7c1aa 100644
@@ -192,7 +192,8 @@ void r8712_usb_write_mem(struct intf_hdl *pintfhdl, u32 addr, u32 cnt, u8 *wmem)
 
 static void r8712_usb_read_port_complete(struct urb *purb)
 {
-	uint isevt, *pbuf;
+	__le32 *pbuf;
+	uint isevt;
 	struct recv_buf	*precvbuf = (struct recv_buf *)purb->context;
 	struct _adapter *padapter = (struct _adapter *)precvbuf->adapter;
 	struct recv_priv *precvpriv = &padapter->recvpriv;
@@ -208,7 +209,7 @@ static void r8712_usb_read_port_complete(struct urb *purb)
 			_pkt *pskb = precvbuf->pskb;
 
 			precvbuf->transfer_len = purb->actual_length;
-			pbuf = (uint *)precvbuf->pbuf;
+			pbuf = (__le32 *)precvbuf->pbuf;
 			isevt = le32_to_cpu(*(pbuf + 1)) & 0x1ff;
 			if ((isevt & 0x1ff) == 0x1ff) {
 				r8712_rxcmd_event_hdl(padapter, pbuf);
Signature · 1 line
2.4.11
#7 lore raw

Re: [PATCH] staging: r8712u: use __le32 type for little-endian data

Quoted 7 lines · Perry Hooker

This patch fixes the following sparse warning:
drivers/staging/rtl8712/usb_ops_linux.c:212:33: warning: cast to restricted __le32

---
 drivers/staging/rtl8712/usb_ops_linux.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

Are you using the staging branch of Greg's tree? If so, you should be using staging-next. The exact patch that you submitted has already been applied as commit 6839bc81478f entitled "staging: rtl8712: changed uint to __le32" and authored by Jannik Becher <[email protected]>. The patch was applied on Tue Dec 20.

Sorry that I did not remember about that earlier patch with the first reply; however, you did get the fix right this time. Congratulations as these endian issues can be difficult.

In a quick look at the code, I see that there are a number of endian problems in the headers for the 802.11 packets, and in the macros that read and write the TX and RX descriptors. It is surprising that the driver actually works on big-endian hardware. I do not know how much experience you have, but the macros are tricky. I will try to get them cleaned up.

Larry

staging: rtl8712: changed uint to __le32

Quoted 25 lines
drivers/staging/rtl8712/usb_ops_linux.c +3 -2
index fc6bb0b..df7c1aa 100644
@@ -192,7 +192,8 @@ void r8712_usb_write_mem(struct intf_hdl *pintfhdl, u32 addr, u32 cnt, u8 *wmem)
 
 static void r8712_usb_read_port_complete(struct urb *purb)
 {
-	uint isevt, *pbuf;
+	__le32 *pbuf;
+	uint isevt;
 	struct recv_buf	*precvbuf = (struct recv_buf *)purb->context;
 	struct _adapter *padapter = (struct _adapter *)precvbuf->adapter;
 	struct recv_priv *precvpriv = &padapter->recvpriv;
@@ -208,7 +209,7 @@ static void r8712_usb_read_port_complete(struct urb *purb)
 			_pkt *pskb = precvbuf->pskb;
 
 			precvbuf->transfer_len = purb->actual_length;
-			pbuf = (uint *)precvbuf->pbuf;
+			pbuf = (__le32 *)precvbuf->pbuf;
 			isevt = le32_to_cpu(*(pbuf + 1)) & 0x1ff;
 			if ((isevt & 0x1ff) == 0x1ff) {
 				r8712_rxcmd_event_hdl(padapter, pbuf);
#8 lore raw

Re: [PATCH] staging: r8712u: use __le32 type for little-endian data

Thank you all for taking the time to look at this. I'm sorry for filling your inboxes with my mistakes - as you probably guessed, I'm new to kernel development, so I really appreciate the feedback.

Perry

Quoted 63 lines · Larry Finger
Quoted 9 lines · Perry Hooker

This patch fixes the following sparse warning:
drivers/staging/rtl8712/usb_ops_linux.c:212:33: warning: cast to restricted __le32

---
 drivers/staging/rtl8712/usb_ops_linux.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

Are you using the staging branch of Greg's tree? If so, you should be using staging-next. The exact patch that you submitted has already been applied as commit 6839bc81478f entitled "staging: rtl8712: changed uint to __le32" and authored by Jannik Becher <[email protected]>. The patch was applied on Tue Dec 20.

Sorry that I did not remember about that earlier patch with the first reply; however, you did get the fix right this time. Congratulations as these endian issues can be difficult.

In a quick look at the code, I see that there are a number of endian problems in the headers for the 802.11 packets, and in the macros that read and write the TX and RX descriptors. It is surprising that the driver actually works on big-endian hardware. I do not know how much experience you have, but the macros are tricky. I will try to get them cleaned up.

Larry

staging: rtl8712: changed uint to __le32

Quoted 28 lines
drivers/staging/rtl8712/usb_ops_linux.c +2 -1
index fc6bb0b..df7c1aa 100644
@@ -192,7 +192,8 @@ void r8712_usb_write_mem(struct intf_hdl *pintfhdl,
 u32 addr, u32 cnt, u8 *wmem)
 
 static void r8712_usb_read_port_complete(struct urb *purb)
 {
-       uint isevt, *pbuf;
+       __le32 *pbuf;
+       uint isevt;
        struct recv_buf *precvbuf = (struct recv_buf *)purb->context;
        struct _adapter *padapter = (struct _adapter *)precvbuf->adapter;
        struct recv_priv *precvpriv = &padapter->recvpriv;
drivers/staging/rtl8712/usb_ops_linux.c +1 -1
@@ -208,7 +209,7 @@ static void r8712_usb_read_port_complete(struct urb
 *purb)
                        _pkt *pskb = precvbuf->pskb;
 
                        precvbuf->transfer_len = purb->actual_length;
-                       pbuf = (uint *)precvbuf->pbuf;
+                       pbuf = (__le32 *)precvbuf->pbuf;
                        isevt = le32_to_cpu(*(pbuf + 1)) & 0x1ff;
                        if ((isevt & 0x1ff) == 0x1ff) {
                                r8712_rxcmd_event_hdl(padapter, pbuf);