Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1578173 > unrolled thread

[PATCH] staging: r8712u: remove unnecessary le32_to_cpu

Started byPerry Hooker <perry.hooker@gmail.com>
First post2017-02-10 05:30 +0100
Last post2017-02-11 20:10 +0100
Articles 9 — 3 participants

Back to article view | Back to linux.kernel


Contents

  [PATCH] staging: r8712u: remove unnecessary le32_to_cpu Perry Hooker <perry.hooker@gmail.com> - 2017-02-10 05:30 +0100
    Re: [PATCH] staging: r8712u: remove unnecessary le32_to_cpu Greg KH <gregkh@linuxfoundation.org> - 2017-02-10 15:10 +0100
      Re: [PATCH] staging: r8712u: remove unnecessary le32_to_cpu Larry Finger <Larry.Finger@lwfinger.net> - 2017-02-10 16:00 +0100
        Re: [PATCH] staging: r8712u: remove unnecessary le32_to_cpu Greg KH <gregkh@linuxfoundation.org> - 2017-02-10 16:00 +0100
          Re: [PATCH] staging: r8712u: remove unnecessary le32_to_cpu Larry Finger <Larry.Finger@lwfinger.net> - 2017-02-10 16:10 +0100
            Re: [PATCH] staging: r8712u: remove unnecessary le32_to_cpu Perry Hooker <perry.hooker@gmail.com> - 2017-02-10 20:00 +0100
        [PATCH] staging: r8712u: use __le32 type for little-endian data Perry Hooker <perry.hooker@gmail.com> - 2017-02-10 20:30 +0100
          Re: [PATCH] staging: r8712u: use __le32 type for little-endian data Larry Finger <Larry.Finger@lwfinger.net> - 2017-02-10 22:00 +0100
            Re: [PATCH] staging: r8712u: use __le32 type for little-endian data Perry Hooker <perry.hooker@gmail.com> - 2017-02-11 20:10 +0100

#1578173 — [PATCH] staging: r8712u: remove unnecessary le32_to_cpu

FromPerry Hooker <perry.hooker@gmail.com>
Date2017-02-10 05:30 +0100
Subject[PATCH] staging: r8712u: remove unnecessary le32_to_cpu
Message-ID<t9b0m-71o-13@gated-at.bofh.it>
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

[toc] | [next] | [standalone]


#1578472

FromGreg KH <gregkh@linuxfoundation.org>
Date2017-02-10 15:10 +0100
Message-ID<t9k3E-4oZ-9@gated-at.bofh.it>
In reply to#1578173
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 :(

[toc] | [prev] | [next] | [standalone]


#1578534

FromLarry Finger <Larry.Finger@lwfinger.net>
Date2017-02-10 16:00 +0100
Message-ID<t9kQ2-4Jf-23@gated-at.bofh.it>
In reply to#1578472
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

[toc] | [prev] | [next] | [standalone]


#1578535

FromGreg KH <gregkh@linuxfoundation.org>
Date2017-02-10 16:00 +0100
Message-ID<t9kQ3-4Jf-31@gated-at.bofh.it>
In reply to#1578534
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

[toc] | [prev] | [next] | [standalone]


#1578539

FromLarry Finger <Larry.Finger@lwfinger.net>
Date2017-02-10 16:10 +0100
Message-ID<t9kZI-52n-23@gated-at.bofh.it>
In reply to#1578535
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

[toc] | [prev] | [next] | [standalone]


#1578717

FromPerry Hooker <perry.hooker@gmail.com>
Date2017-02-10 20:00 +0100
Message-ID<t9oAj-7fF-33@gated-at.bofh.it>
In reply to#1578539
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
>
>

[toc] | [prev] | [next] | [standalone]


#1578749 — [PATCH] staging: r8712u: use __le32 type for little-endian data

FromPerry Hooker <perry.hooker@gmail.com>
Date2017-02-10 20:30 +0100
Subject[PATCH] staging: r8712u: use __le32 type for little-endian data
Message-ID<t9p3k-7EV-17@gated-at.bofh.it>
In reply to#1578534
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

[toc] | [prev] | [next] | [standalone]


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

FromLarry Finger <Larry.Finger@lwfinger.net>
Date2017-02-10 22:00 +0100
SubjectRe: [PATCH] staging: r8712u: use __le32 type for little-endian data
Message-ID<t9qsq-8pJ-25@gated-at.bofh.it>
In reply to#1578749
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);
>

[toc] | [prev] | [next] | [standalone]


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

FromPerry Hooker <perry.hooker@gmail.com>
Date2017-02-11 20:10 +0100
SubjectRe: [PATCH] staging: r8712u: use __le32 type for little-endian data
Message-ID<t9Ldv-4xd-15@gated-at.bofh.it>
In reply to#1578798
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);
>>
>

[toc] | [prev] | [standalone]


Back to top | Article view | linux.kernel


csiph-web