Skip to contentSkip to conversation

staging: wilc1000: Merge memcpy + le32_to_cpus to get_unaligned_le32

PATCH In review Chuhong Yuan 3 participants 6 messages Jul 19, 2019 Staging

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 staging: wilc1000: Merge memcpy + le32_to_cpus to get_unaligned_le32

Merge the combo use of memcpy and le32_to_cpus.
Use get_unaligned_le32 instead.
This simplifies the code.

---
 drivers/staging/wilc1000/wilc_wfi_cfgoperations.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)
drivers/staging/wilc1000/wilc_wfi_cfgoperations.c +1 -2
index d72fdd333050..12fb4add05ec 100644
@@ -1038,8 +1038,7 @@ void wilc_wfi_p2p_rx(struct wilc_vif *vif, u8 *buff, u32 size)
 	s32 freq;
 	__le16 fc;
 
-	memcpy(&header, (buff - HOST_HDR_OFFSET), HOST_HDR_OFFSET);
-	le32_to_cpus(&header);
+	header = get_unaligned_le32(buff - HOST_HDR_OFFSET);
 	pkt_offset = GET_PKT_OFFSET(header);
 
 	if (pkt_offset & IS_MANAGMEMENT_CALLBACK) {
Signature · 1 line
2.20.1
#1 lore raw
Quoted 16 lines · Chuhong Yuan

Merge the combo use of memcpy and le32_to_cpus.
Use get_unaligned_le32 instead.
This simplifies the code.

---
 drivers/staging/wilc1000/wilc_wfi_cfgoperations.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)
drivers/staging/wilc1000/wilc_wfi_cfgoperations.c +0 -0
index d72fdd333050..12fb4add05ec 100644

drivers/staging/wilc1000/wilc_wfi_cfgoperations.c void wilc_wfi_p2p_rx(struct wilc_vif *vif, u8 *buff, u32 size) · line 1044

Quoted 9 lines
drivers/staging/wilc1000/wilc_wfi_cfgoperations.c +1 -2
@@ -1038,8 +1038,7 @@ void wilc_wfi_p2p_rx(struct wilc_vif *vif, u8 *buff, u32 size)
 	s32 freq;
 	__le16 fc;
 
-	memcpy(&header, (buff - HOST_HDR_OFFSET), HOST_HDR_OFFSET);
-	le32_to_cpus(&header);
+	header = get_unaligned_le32(buff - HOST_HDR_OFFSET);
 	pkt_offset = GET_PKT_OFFSET(header);
 
 	if (pkt_offset & IS_MANAGMEMENT_CALLBACK) {

Thanks for sending the patches.

The code change looks okay to me. Just a minor comment, avoid the use of same subject line for different patches.

Regards,
Ajay

#2 lore raw
Quoted 25 lines · <[email protected]> 于2019年7月19日周五 下午7:34写道:
Quoted 23 lines · Chuhong Yuan

Merge the combo use of memcpy and le32_to_cpus.
Use get_unaligned_le32 instead.
This simplifies the code.

---
 drivers/staging/wilc1000/wilc_wfi_cfgoperations.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)
drivers/staging/wilc1000/wilc_wfi_cfgoperations.c +1 -2
index d72fdd333050..12fb4add05ec 100644
@@ -1038,8 +1038,7 @@ void wilc_wfi_p2p_rx(struct wilc_vif *vif, u8 *buff, u32 size)
      s32 freq;
      __le16 fc;
 
-     memcpy(&header, (buff - HOST_HDR_OFFSET), HOST_HDR_OFFSET);
-     le32_to_cpus(&header);
+     header = get_unaligned_le32(buff - HOST_HDR_OFFSET);
      pkt_offset = GET_PKT_OFFSET(header);
 
Quoted 7 lines

drivers/staging/wilc1000/wilc_wfi_cfgoperations.c void wilc_wfi_p2p_rx(struct wilc_vif *vif, u8 *buff, u32 size) · line 1044

Quoted 2 lines
drivers/staging/wilc1000/wilc_wfi_cfgoperations.c +0 -0
      if (pkt_offset & IS_MANAGMEMENT_CALLBACK) {

Thanks for sending the patches.

The code change looks okay to me. Just a minor comment, avoid the use of same subject line for different patches.

These two patches are in the same subsystem and solve the same problem. I splitted them into two patches by mistake since I did not notice the problems in the second patch when I sent the first one.
Should I merge the two patches and resend?

Quoted 3 lines

Regards,
Ajay

#3 lore raw
Quoted 32 lines · Chuhong Yuan
Quoted 30 lines · <[email protected]> 于2019年7月19日周五 下午7:34写道:
Quoted 16 lines · Chuhong Yuan

Merge the combo use of memcpy and le32_to_cpus.
Use get_unaligned_le32 instead.
This simplifies the code.

---
 drivers/staging/wilc1000/wilc_wfi_cfgoperations.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)
drivers/staging/wilc1000/wilc_wfi_cfgoperations.c +0 -0
index d72fdd333050..12fb4add05ec 100644

drivers/staging/wilc1000/wilc_wfi_cfgoperations.c void wilc_wfi_p2p_rx(struct wilc_vif *vif, u8 *buff, u32 size) · line 1044

Quoted 9 lines
drivers/staging/wilc1000/wilc_wfi_cfgoperations.c +1 -2
@@ -1038,8 +1038,7 @@ void wilc_wfi_p2p_rx(struct wilc_vif *vif, u8 *buff, u32 size)
      s32 freq;
      __le16 fc;
 
-     memcpy(&header, (buff - HOST_HDR_OFFSET), HOST_HDR_OFFSET);
-     le32_to_cpus(&header);
+     header = get_unaligned_le32(buff - HOST_HDR_OFFSET);
      pkt_offset = GET_PKT_OFFSET(header);
 
      if (pkt_offset & IS_MANAGMEMENT_CALLBACK) {

Thanks for sending the patches.

Quoted 8 lines
Quoted 2 lines

The code change looks okay to me. Just a minor comment, avoid the use of same subject line for different patches.

These two patches are in the same subsystem and solve the same problem. I splitted them into two patches by mistake since I did not notice the problems in the second patch when I sent the first one.
Should I merge the two patches and resend?

Yes, please go ahead, merge the patches and send the updated version.

Regards,
Ajay

#4 lore raw
Quoted 37 lines · On Fri, Jul 19, 2019 at 12:05:07PM +0000, [email protected] wrote:
Quoted 35 lines · Chuhong Yuan
Quoted 32 lines · <[email protected]> 于2019年7月19日周五 下午7:34写道:
Quoted 16 lines · Chuhong Yuan

Merge the combo use of memcpy and le32_to_cpus.
Use get_unaligned_le32 instead.
This simplifies the code.

---
 drivers/staging/wilc1000/wilc_wfi_cfgoperations.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)
drivers/staging/wilc1000/wilc_wfi_cfgoperations.c +0 -0
index d72fdd333050..12fb4add05ec 100644

drivers/staging/wilc1000/wilc_wfi_cfgoperations.c void wilc_wfi_p2p_rx(struct wilc_vif *vif, u8 *buff, u32 size) · line 1044

Quoted 9 lines
drivers/staging/wilc1000/wilc_wfi_cfgoperations.c +1 -2
@@ -1038,8 +1038,7 @@ void wilc_wfi_p2p_rx(struct wilc_vif *vif, u8 *buff, u32 size)
      s32 freq;
      __le16 fc;
 
-     memcpy(&header, (buff - HOST_HDR_OFFSET), HOST_HDR_OFFSET);
-     le32_to_cpus(&header);
+     header = get_unaligned_le32(buff - HOST_HDR_OFFSET);
      pkt_offset = GET_PKT_OFFSET(header);
 
      if (pkt_offset & IS_MANAGMEMENT_CALLBACK) {

Thanks for sending the patches.

The code change looks okay to me. Just a minor comment, avoid the use of same subject line for different patches.

Quoted 8 lines
Quoted 5 lines

These two patches are in the same subsystem and solve the same problem. I splitted them into two patches by mistake since I did not notice the problems in the second patch when I sent the first one.
Should I merge the two patches and resend?

Yes, please go ahead, merge the patches and send the updated version.

This is wrong advice. Don't merge the patches because they are for different drivers. The original subjects are fine because the subsystems are different so that's okay.

regards,
dan carpenter

#5 lore raw
Quoted 44 lines · Dan Carpenter
Quoted 43 lines · On Fri, Jul 19, 2019 at 12:05:07PM +0000, [email protected] wrote:
Quoted 40 lines · Chuhong Yuan
Quoted 25 lines · <[email protected]> 于2019年7月19日周五 下午7:34写道:
Quoted 23 lines · Chuhong Yuan

Merge the combo use of memcpy and le32_to_cpus.
Use get_unaligned_le32 instead.
This simplifies the code.

---
 drivers/staging/wilc1000/wilc_wfi_cfgoperations.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)
drivers/staging/wilc1000/wilc_wfi_cfgoperations.c +1 -2
index d72fdd333050..12fb4add05ec 100644
@@ -1038,8 +1038,7 @@ void wilc_wfi_p2p_rx(struct wilc_vif *vif, u8 *buff, u32 size)
      s32 freq;
      __le16 fc;
 
-     memcpy(&header, (buff - HOST_HDR_OFFSET), HOST_HDR_OFFSET);
-     le32_to_cpus(&header);
+     header = get_unaligned_le32(buff - HOST_HDR_OFFSET);
      pkt_offset = GET_PKT_OFFSET(header);
 
Quoted 7 lines

drivers/staging/wilc1000/wilc_wfi_cfgoperations.c void wilc_wfi_p2p_rx(struct wilc_vif *vif, u8 *buff, u32 size) · line 1044

Quoted 2 lines
drivers/staging/wilc1000/wilc_wfi_cfgoperations.c +0 -0
      if (pkt_offset & IS_MANAGMEMENT_CALLBACK) {

Thanks for sending the patches.

The code change looks okay to me. Just a minor comment, avoid the use of same subject line for different patches.

These two patches are in the same subsystem and solve the same problem. I splitted them into two patches by mistake since I did not notice the problems in the second patch when I sent the first one.
Should I merge the two patches and resend?

Quoted 7 lines
Quoted 2 lines

Yes, please go ahead, merge the patches and send the updated version.

This is wrong advice. Don't merge the patches because they are for different drivers. The original subjects are fine because the subsystems are different so that's okay.

Oh... My bad... I was looking at the wrong patches. :P You are 100% correct Ajay. Merge the two patches and always make sure to not send multiple patches with the same subject.

regards,
dan carpenter