* [PATCH] staging: r8712u: remove unnecessary le32_to_cpu @ 2017-02-10 3:51 Perry Hooker 2017-02-10 14:08 ` Greg KH 0 siblings, 1 reply; 9+ messages in thread From: Perry Hooker @ 2017-02-10 3:51 UTC (permalink / raw) To: gregkh Cc: Larry.Finger, florian.c.schilhabel, devel, linux-kernel, Perry Hooker This patch fixes the following sparse warning: drivers/staging/rtl8712/usb_ops_linux.c:212:33: warning: cast to restricted __le32 Signed-off-by: Perry Hooker <perry.hooker@gmail.com> --- drivers/staging/rtl8712/usb_ops_linux.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/staging/rtl8712/usb_ops_linux.c b/drivers/staging/rtl8712/usb_ops_linux.c index fc6bb0b..259ef8f 100644 --- a/drivers/staging/rtl8712/usb_ops_linux.c +++ b/drivers/staging/rtl8712/usb_ops_linux.c @@ -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); -- 2.4.11 ^ permalink raw reply related [flat|nested] 9+ messages in thread
* Re: [PATCH] staging: r8712u: remove unnecessary le32_to_cpu 2017-02-10 3:51 [PATCH] staging: r8712u: remove unnecessary le32_to_cpu Perry Hooker @ 2017-02-10 14:08 ` Greg KH 2017-02-10 14:52 ` Larry Finger 0 siblings, 1 reply; 9+ messages in thread From: Greg KH @ 2017-02-10 14:08 UTC (permalink / raw) To: Perry Hooker; +Cc: devel, florian.c.schilhabel, linux-kernel, Larry.Finger On Thu, Feb 09, 2017 at 08:51:55PM -0700, Perry Hooker wrote: > This patch fixes the following sparse warning: > drivers/staging/rtl8712/usb_ops_linux.c:212:33: warning: cast to restricted __le32 > > Signed-off-by: Perry Hooker <perry.hooker@gmail.com> > --- > drivers/staging/rtl8712/usb_ops_linux.c | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) Does not apply to my tree :( ^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [PATCH] staging: r8712u: remove unnecessary le32_to_cpu 2017-02-10 14:08 ` Greg KH @ 2017-02-10 14:52 ` Larry Finger 2017-02-10 14:58 ` Greg KH 2017-02-10 18:23 ` [PATCH] staging: r8712u: use __le32 type for little-endian data Perry Hooker 0 siblings, 2 replies; 9+ messages in thread From: Larry Finger @ 2017-02-10 14:52 UTC (permalink / raw) To: Greg KH, Perry Hooker; +Cc: devel, florian.c.schilhabel, linux-kernel On 02/10/2017 08:08 AM, Greg KH wrote: > On Thu, Feb 09, 2017 at 08:51:55PM -0700, Perry Hooker wrote: >> This patch fixes the following sparse warning: >> drivers/staging/rtl8712/usb_ops_linux.c:212:33: warning: cast to restricted __le32 >> >> Signed-off-by: Perry Hooker <perry.hooker@gmail.com> >> --- >> 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 ^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [PATCH] staging: r8712u: remove unnecessary le32_to_cpu 2017-02-10 14:52 ` Larry Finger @ 2017-02-10 14:58 ` Greg KH 2017-02-10 15:07 ` Larry Finger 2017-02-10 18:23 ` [PATCH] staging: r8712u: use __le32 type for little-endian data Perry Hooker 1 sibling, 1 reply; 9+ messages in thread From: Greg KH @ 2017-02-10 14:58 UTC (permalink / raw) To: Larry Finger; +Cc: Perry Hooker, devel, florian.c.schilhabel, linux-kernel On Fri, Feb 10, 2017 at 08:52:12AM -0600, Larry Finger wrote: > On 02/10/2017 08:08 AM, Greg KH wrote: > > On Thu, Feb 09, 2017 at 08:51:55PM -0700, Perry Hooker wrote: > > > This patch fixes the following sparse warning: > > > drivers/staging/rtl8712/usb_ops_linux.c:212:33: warning: cast to restricted __le32 > > > > > > Signed-off-by: Perry Hooker <perry.hooker@gmail.com> > > > --- > > > 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. Care to comment this somehow so that I don't accidentally take a patch for this in the future? thanks, greg k-h ^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [PATCH] staging: r8712u: remove unnecessary le32_to_cpu 2017-02-10 14:58 ` Greg KH @ 2017-02-10 15:07 ` Larry Finger 2017-02-10 18:24 ` Perry Hooker 0 siblings, 1 reply; 9+ messages in thread From: Larry Finger @ 2017-02-10 15:07 UTC (permalink / raw) To: Greg KH; +Cc: Perry Hooker, devel, florian.c.schilhabel, linux-kernel On 02/10/2017 08:58 AM, Greg KH wrote: > On Fri, Feb 10, 2017 at 08:52:12AM -0600, Larry Finger wrote: >> On 02/10/2017 08:08 AM, Greg KH wrote: >>> On Thu, Feb 09, 2017 at 08:51:55PM -0700, Perry Hooker wrote: >>>> This patch fixes the following sparse warning: >>>> drivers/staging/rtl8712/usb_ops_linux.c:212:33: warning: cast to restricted __le32 >>>> >>>> Signed-off-by: Perry Hooker <perry.hooker@gmail.com> >>>> --- >>>> 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. > > 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 ^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [PATCH] staging: r8712u: remove unnecessary le32_to_cpu 2017-02-10 15:07 ` Larry Finger @ 2017-02-10 18:24 ` Perry Hooker 0 siblings, 0 replies; 9+ messages in thread From: Perry Hooker @ 2017-02-10 18:24 UTC (permalink / raw) To: Larry Finger; +Cc: Greg KH, devel, Florian Schilhabel, linux-kernel Ouch. My apologies. I'll take more care next time. I've supplied an updated patch that uses the __le32 type for *(pbuf + 1). On Fri, Feb 10, 2017 at 8:07 AM, Larry Finger <Larry.Finger@lwfinger.net> wrote: > On 02/10/2017 08:58 AM, Greg KH wrote: >> >> On Fri, Feb 10, 2017 at 08:52:12AM -0600, Larry Finger wrote: >>> >>> On 02/10/2017 08:08 AM, Greg KH wrote: >>>> >>>> On Thu, Feb 09, 2017 at 08:51:55PM -0700, Perry Hooker wrote: >>>>> >>>>> This patch fixes the following sparse warning: >>>>> drivers/staging/rtl8712/usb_ops_linux.c:212:33: warning: cast to >>>>> restricted __le32 >>>>> >>>>> Signed-off-by: Perry Hooker <perry.hooker@gmail.com> >>>>> --- >>>>> 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. >> >> >> 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 > > ^ permalink raw reply [flat|nested] 9+ messages in thread
* [PATCH] staging: r8712u: use __le32 type for little-endian data 2017-02-10 14:52 ` Larry Finger 2017-02-10 14:58 ` Greg KH @ 2017-02-10 18:23 ` Perry Hooker 2017-02-10 20:55 ` Larry Finger 1 sibling, 1 reply; 9+ messages in thread From: Perry Hooker @ 2017-02-10 18:23 UTC (permalink / raw) To: Larry.Finger; +Cc: gregkh, devel, linux-kernel, Perry Hooker This patch fixes the following sparse warning: drivers/staging/rtl8712/usb_ops_linux.c:212:33: warning: cast to restricted __le32 Signed-off-by: Perry Hooker <perry.hooker@gmail.com> --- drivers/staging/rtl8712/usb_ops_linux.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/drivers/staging/rtl8712/usb_ops_linux.c b/drivers/staging/rtl8712/usb_ops_linux.c index fc6bb0b..df7c1aa 100644 --- a/drivers/staging/rtl8712/usb_ops_linux.c +++ b/drivers/staging/rtl8712/usb_ops_linux.c @@ -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); -- 2.4.11 ^ permalink raw reply related [flat|nested] 9+ messages in thread
* Re: [PATCH] staging: r8712u: use __le32 type for little-endian data 2017-02-10 18:23 ` [PATCH] staging: r8712u: use __le32 type for little-endian data Perry Hooker @ 2017-02-10 20:55 ` Larry Finger 2017-02-11 19:04 ` Perry Hooker 0 siblings, 1 reply; 9+ messages in thread From: Larry Finger @ 2017-02-10 20:55 UTC (permalink / raw) To: Perry Hooker; +Cc: gregkh, devel, linux-kernel On 02/10/2017 12:23 PM, Perry Hooker wrote: > This patch fixes the following sparse warning: > drivers/staging/rtl8712/usb_ops_linux.c:212:33: warning: cast to restricted __le32 > > Signed-off-by: Perry Hooker <perry.hooker@gmail.com> > --- > 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 <becher.jannik@gmail.com>. 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 > > diff --git a/drivers/staging/rtl8712/usb_ops_linux.c b/drivers/staging/rtl8712/usb_ops_linux.c > index fc6bb0b..df7c1aa 100644 > --- a/drivers/staging/rtl8712/usb_ops_linux.c > +++ b/drivers/staging/rtl8712/usb_ops_linux.c > @@ -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); > ^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [PATCH] staging: r8712u: use __le32 type for little-endian data 2017-02-10 20:55 ` Larry Finger @ 2017-02-11 19:04 ` Perry Hooker 0 siblings, 0 replies; 9+ messages in thread From: Perry Hooker @ 2017-02-11 19:04 UTC (permalink / raw) To: Larry Finger; +Cc: Greg KH, devel, linux-kernel 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 On Fri, Feb 10, 2017 at 1:55 PM, Larry Finger <Larry.Finger@lwfinger.net> wrote: > On 02/10/2017 12:23 PM, Perry Hooker wrote: >> >> This patch fixes the following sparse warning: >> drivers/staging/rtl8712/usb_ops_linux.c:212:33: warning: cast to >> restricted __le32 >> >> Signed-off-by: Perry Hooker <perry.hooker@gmail.com> >> --- >> 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 <becher.jannik@gmail.com>. 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 > > >> >> diff --git a/drivers/staging/rtl8712/usb_ops_linux.c >> b/drivers/staging/rtl8712/usb_ops_linux.c >> index fc6bb0b..df7c1aa 100644 >> --- a/drivers/staging/rtl8712/usb_ops_linux.c >> +++ b/drivers/staging/rtl8712/usb_ops_linux.c >> @@ -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); >> > ^ permalink raw reply [flat|nested] 9+ messages in thread
end of thread, other threads:[~2017-02-11 19:05 UTC | newest] Thread overview: 9+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- 2017-02-10 3:51 [PATCH] staging: r8712u: remove unnecessary le32_to_cpu Perry Hooker 2017-02-10 14:08 ` Greg KH 2017-02-10 14:52 ` Larry Finger 2017-02-10 14:58 ` Greg KH 2017-02-10 15:07 ` Larry Finger 2017-02-10 18:24 ` Perry Hooker 2017-02-10 18:23 ` [PATCH] staging: r8712u: use __le32 type for little-endian data Perry Hooker 2017-02-10 20:55 ` Larry Finger 2017-02-11 19:04 ` Perry Hooker
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox