Skip to contentSkip to conversation

Staging: rtl8723au: Use put_unaligned_le32

PATCH Superseded Shraddha Barke 3 participants 5 messages Oct 23, 2015 Staging

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 Staging: rtl8723au: Use put_unaligned_le32

Introduce the use of function put_unaligned_le32.

Coccinelle semantic patch used -

@@ identifier tmp; expression ptr; expression y,e; type T; @@

- tmp = cpu_to_le32(y);

<+... when != tmp
- memcpy(ptr, (T)&tmp, ...);
+ put_unaligned_le32(y,ptr);
...+>
? tmp = e

@@ type T; identifier tmp; @@

- T tmp;
...when != tmp

---
 drivers/staging/rtl8723au/hal/rtl8723a_cmd.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)
drivers/staging/rtl8723au/hal/rtl8723a_cmd.c +1 -2
index 9733aa6..1662c03c 100644
@@ -127,8 +127,7 @@ int rtl8723a_set_raid_cmd(struct rtw_adapter *padapter, u32 mask, u8 arg)
 	u8 buf[5];
 
 	memset(buf, 0, 5);
-	mask = cpu_to_le32(mask);
-	memcpy(buf, &mask, 4);
+	put_unaligned_le32(mask, buf);
 	buf[4]  = arg;
 
 	FillH2CCmd(padapter, MACID_CONFIG_EID, 5, buf);
Signature · 1 line
2.1.4
#1 lore raw
Quoted 4 lines · Shraddha Barke

Introduce the use of function put_unaligned_le32.

Coccinelle semantic patch used -

This is not whole patch which I wrote. So, it could be good to write 'simplified semantic patch'.

Also, you can check the whole patch in my github account if you are interested. :)

Quoted 15 lines

@@ identifier tmp; expression ptr; expression y,e; type T; @@

- tmp = cpu_to_le32(y);

<+... when != tmp
- memcpy(ptr, (T)&tmp, ...);
+ put_unaligned_le32(y,ptr);
...+>
? tmp = e

@@ type T; identifier tmp; @@

- T tmp;
...when != tmp

Review

Quoted 6 lines
---
 drivers/staging/rtl8723au/hal/rtl8723a_cmd.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)
(quoted diff) +0 -0

b/drivers/staging/rtl8723au/hal/rtl8723a_cmd.c

drivers/staging/rtl8723au/hal/rtl8723a_cmd.c int rtl8723a_set_raid_cmd(struct rtw_adapter

Quoted 4 lines

index 9733aa6..1662c03c 100644

drivers/staging/rtl8723au/hal/rtl8723a_cmd.c +0 -0
@@ -127,8 +127,7 @@ int rtl8723a_set_raid_cmd(struct rtw_adapter

*padapter, u32 mask, u8 arg)

Quoted 12 lines
drivers/staging/rtl8723au/hal/rtl8723a_cmd.c +1 -3
        u8 buf[5];
 
        memset(buf, 0, 5);
-       mask = cpu_to_le32(mask);
-       memcpy(buf, &mask, 4);
+       put_unaligned_le32(mask, buf);
        buf[4]  = arg;
 
        FillH2CCmd(padapter, MACID_CONFIG_EID, 5, buf);
--

2.1.4

Quoted 2 lines

--
You received this message because you are subscribed to the Google Groups

"outreachy-kernel" group.

Quoted 1 line

To unsubscribe from this group and stop receiving emails from it, send an

email to [email protected].

Quoted 2 lines

To post to this group, send email to [email protected]. To view this discussion on the web visit

https://groups.google.com/d/msgid/outreachy-kernel/1445605588-16640-1-git-send-email-shraddha.6596%40gmail.com
.

Quoted 1 line

For more options, visit https://groups.google.com/d/optout.

#2 lore raw
Quoted 6 lines · Vaishali Thakkar
Quoted 3 lines · Shraddha Barke

Introduce the use of function put_unaligned_le32.

Quoted 7 lines
Quoted 1 line

Coccinelle semantic patch used -

This is not whole patch which I wrote. So, it could be good to write 'simplified semantic patch'.

Also, you can check the whole patch in my github account if you are interested. :)

Was there someone who had a problem with this in some cases? I don't remember...

julia

Quoted 60 lines
Quoted 15 lines

@@ identifier tmp; expression ptr; expression y,e; type T; @@

- tmp = cpu_to_le32(y);

  <+... when != tmp
- memcpy(ptr, (T)&tmp, ...);
+ put_unaligned_le32(y,ptr);
  ...+>
? tmp = e

@@ type T; identifier tmp; @@

- T tmp;
...when != tmp

Review

Quoted 6 lines

---
 drivers/staging/rtl8723au/hal/rtl8723a_cmd.c | 3 +--

 1 file changed, 1 insertion(+), 2 deletions(-)
(quoted diff) +0 -0

b/drivers/staging/rtl8723au/hal/rtl8723a_cmd.c

drivers/staging/rtl8723au/hal/rtl8723a_cmd.c int rtl8723a_set_raid_cmd(struct rtw_adapter

Quoted 4 lines

index 9733aa6..1662c03c 100644

drivers/staging/rtl8723au/hal/rtl8723a_cmd.c +0 -0
@@ -127,8 +127,7 @@ int rtl8723a_set_raid_cmd(struct rtw_adapter

*padapter, u32 mask, u8 arg)

Quoted 12 lines
drivers/staging/rtl8723au/hal/rtl8723a_cmd.c +1 -3
         u8 buf[5];
 
         memset(buf, 0, 5);
-       mask = cpu_to_le32(mask);
-       memcpy(buf, &mask, 4);
+       put_unaligned_le32(mask, buf);
         buf[4]  = arg;
 
         FillH2CCmd(padapter, MACID_CONFIG_EID, 5, buf);
--

2.1.4

Quoted 2 lines

--
You received this message because you are subscribed to the Google Groups

"outreachy-kernel" group.

Quoted 1 line

To unsubscribe from this group and stop receiving emails from it, send an

email to [email protected].

Quoted 2 lines

To post to this group, send email to [email protected].
To view this discussion on the web visithttps://groups.google.com/d/msgid/outreachy-kernel/1445605588-16640-1-git-s

end-email-shraddha.6596%40gmail.com.

Quoted 1 line

For more options, visit https://groups.google.com/d/optout.

--
You received this message because you are subscribed to the Google Groups
"outreachy-kernel" group.
To unsubscribe from this group and stop receiving emails from it, send an
email to [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visithttps://groups.google.com/d/msgid/outreachy-kernel/CAK-LDb%2B8RnwEbL95WiS0e dnY3NCENOe%3DtnCoRekkJKEoEjOa0w%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

#3 lore raw
Quoted 11 lines · Julia Lawall
Quoted 8 lines · Vaishali Thakkar
Quoted 4 lines · Shraddha Barke

Introduce the use of function put_unaligned_le32.

Coccinelle semantic patch used -

Quoted 8 lines
Quoted 5 lines

This is not whole patch which I wrote. So, it could be good to write 'simplified semantic patch'.

Also, you can check the whole patch in my github account if you are interested. :)

Was there someone who had a problem with this in some cases? I don't remember...

Yes. I don't remember the name of person but the point was one need to check if data is aligned from the start. If so then it's not good to use put_unaligned_xxxx.

Quoted 43 lines

julia

Quoted 41 lines
Quoted 15 lines

@@ identifier tmp; expression ptr; expression y,e; type T; @@

- tmp = cpu_to_le32(y);

<+... when != tmp
- memcpy(ptr, (T)&tmp, ...);
+ put_unaligned_le32(y,ptr);
...+>
? tmp = e

@@ type T; identifier tmp; @@

- T tmp;
...when != tmp

Review

Quoted 6 lines
---
 drivers/staging/rtl8723au/hal/rtl8723a_cmd.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)
(quoted diff) +0 -0

b/drivers/staging/rtl8723au/hal/rtl8723a_cmd.c

drivers/staging/rtl8723au/hal/rtl8723a_cmd.c int rtl8723a_set_raid_cmd(struct rtw_adapter

Quoted 4 lines

index 9733aa6..1662c03c 100644

drivers/staging/rtl8723au/hal/rtl8723a_cmd.c +0 -0
@@ -127,8 +127,7 @@ int rtl8723a_set_raid_cmd(struct rtw_adapter

*padapter, u32 mask, u8 arg)

Quoted 14 lines
drivers/staging/rtl8723au/hal/rtl8723a_cmd.c +1 -3
        u8 buf[5];
 
        memset(buf, 0, 5);
-       mask = cpu_to_le32(mask);
-       memcpy(buf, &mask, 4);
+       put_unaligned_le32(mask, buf);
        buf[4]  = arg;
 
        FillH2CCmd(padapter, MACID_CONFIG_EID, 5, buf);
--

2.1.4

--
You received this message because you are subscribed to the Google

Groups

Quoted 2 lines
Quoted 2 lines

"outreachy-kernel" group.

Quoted 1 line

To unsubscribe from this group and stop receiving emails from it,

send an

Quoted 2 lines
Quoted 2 lines

email to [email protected].

Quoted 1 line

To post to this group, send email to [email protected]

.

Quoted 1 line
Quoted 1 line
Quoted 1 line

To view this discussion on the web visithttps://

groups.google.com/d/msgid/outreachy-kernel/1445605588-16640-1-git-s

Quoted 5 lines
Quoted 5 lines

end-email-shraddha.6596%40gmail.com.

Quoted 1 line

For more options, visit https://groups.google.com/d/optout.

--
You received this message because you are subscribed to the Google

Groups

Quoted 2 lines
Quoted 2 lines

"outreachy-kernel" group.
To unsubscribe from this group and stop receiving emails from it, send

an

Quoted 3 lines
Quoted 3 lines

email to [email protected].
To post to this group, send email to [email protected]. To view this discussion on the web visithttps://

groups.google.com/d/msgid/outreachy-kernel/CAK-LDb%2B8RnwEbL95WiS0e

Quoted 4 lines
Quoted 4 lines

dnY3NCENOe%3DtnCoRekkJKEoEjOa0w%40mail.gmail.com. For more options, visit https://groups.google.com/d/optout.

#4 lore raw
In reply to Vaishali Thakkar
Quoted 9 lines · Vaishali Thakkar
Quoted 4 lines · Shraddha Barke

Introduce the use of function put_unaligned_le32.

Coccinelle semantic patch used -

This is not whole patch which I wrote. So, it could be good to write 'simplified semantic patch'.

Yes I did check that. This patch is based on the whole patch you wrote. It's brilliant :) I'll send a v2.

Quoted 50 lines

Also, you can check the whole patch in my github account if you are interested. :)

Quoted 37 lines

@@ identifier tmp; expression ptr; expression y,e; type T; @@

- tmp = cpu_to_le32(y);

  <+... when != tmp
- memcpy(ptr, (T)&tmp, ...);
+ put_unaligned_le32(y,ptr);
  ...+>
? tmp = e

@@ type T; identifier tmp; @@

- T tmp;
...when != tmp

---
 drivers/staging/rtl8723au/hal/rtl8723a_cmd.c | 3 +--

 1 file changed, 1 insertion(+), 2 deletions(-)
drivers/staging/rtl8723au/hal/rtl8723a_cmd.c +1 -3
index 9733aa6..1662c03c 100644
@@ -127,8 +127,7 @@ int rtl8723a_set_raid_cmd(struct rtw_adapter *padapter, u32 mask, u8 arg)
         u8 buf[5];
 
         memset(buf, 0, 5);
-       mask = cpu_to_le32(mask);
-       memcpy(buf, &mask, 4);
+       put_unaligned_le32(mask, buf);
         buf[4]  = arg;
 
         FillH2CCmd(padapter, MACID_CONFIG_EID, 5, buf);
--

2.1.4

Quoted 5 lines

--
You received this message because you are subscribed to the Google Groups "outreachy-kernel" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To post to this group, send email to [email protected].
To view this discussion on the web visit

https://groups.google.com/d/msgid/outreachy-kernel/1445605588-16640-1-git-send-email-shraddha.6596%40gmail.com.

Quoted 1 line

For more options, visit https://groups.google.com/d/optout.