* [PATCH v3] Staging: wilc1000: coreconfigurator: Drop unneeded wrapper functions
@ 2015-10-22 13:07 Shivani Bhardwaj
2015-10-25 1:23 ` [Outreachy kernel] " Greg KH
0 siblings, 1 reply; 3+ messages in thread
From: Shivani Bhardwaj @ 2015-10-22 13:07 UTC (permalink / raw)
To: outreachy-kernel
Replace the wrapper functions get_address1(), get_address2() and get_address3()
with the standard kernel function ether_addr_copy().
Semantic patch used to identify the issue:
@@
identifier f,g;
@@
*f(...) {
g(...); }
Signed-off-by: Shivani Bhardwaj <shivanib134@gmail.com>
---
drivers/staging/wilc1000/coreconfigurator.c | 48 ++++++++++++++---------------
1 file changed, 23 insertions(+), 25 deletions(-)
diff --git a/drivers/staging/wilc1000/coreconfigurator.c b/drivers/staging/wilc1000/coreconfigurator.c
index 427adfd..6dfe26d 100644
--- a/drivers/staging/wilc1000/coreconfigurator.c
+++ b/drivers/staging/wilc1000/coreconfigurator.c
@@ -13,8 +13,12 @@
#include "wilc_wlan.h"
#include <linux/errno.h>
#include <linux/slab.h>
+#include <linux/etherdevice.h>
#define TAG_PARAM_OFFSET (MAC_HDR_LEN + TIME_STAMP_LEN + \
BEACON_INTERVAL_LEN + CAP_INFO_LEN)
+#define ADDR1 4
+#define ADDR2 10
+#define ADDR3 16
/* Basic Frame Type Codes (2-bit) */
enum basic_frame_type {
@@ -171,38 +175,32 @@ static inline u8 get_from_ds(u8 *header)
return ((header[1] & 0x02) >> 1);
}
-/* This function extracts the MAC Address in 'address1' field of the MAC */
-/* header and updates the MAC Address in the allocated 'addr' variable. */
-static inline void get_address1(u8 *pu8msa, u8 *addr)
-{
- memcpy(addr, pu8msa + 4, 6);
-}
-
-/* This function extracts the MAC Address in 'address2' field of the MAC */
-/* header and updates the MAC Address in the allocated 'addr' variable. */
-static inline void get_address2(u8 *pu8msa, u8 *addr)
-{
- memcpy(addr, pu8msa + 10, 6);
-}
-
-/* This function extracts the MAC Address in 'address3' field of the MAC */
-/* header and updates the MAC Address in the allocated 'addr' variable. */
-static inline void get_address3(u8 *pu8msa, u8 *addr)
-{
- memcpy(addr, pu8msa + 16, 6);
-}
-
/* This function extracts the BSSID from the incoming WLAN packet based on */
-/* the 'from ds' bit, and updates the MAC Address in the allocated 'addr' */
+/* the 'from ds' bit, and updates the MAC Address in the allocated 'data' */
/* variable. */
static inline void get_BSSID(u8 *data, u8 *bssid)
{
if (get_from_ds(data) == 1)
- get_address2(data, bssid);
+ /*
+ * Extract the MAC Address in 'address2' field of the MAC
+ * header and update the MAC Address in the allocated 'data'
+ * variable.
+ */
+ ether_addr_copy(data, bssid + ADDR2);
else if (get_to_ds(data) == 1)
- get_address1(data, bssid);
+ /*
+ * Extract the MAC Address in 'address1' field of the MAC
+ * header and update the MAC Address in the allocated 'data'
+ * variable.
+ */
+ ether_addr_copy(data, bssid + ADDR1);
else
- get_address3(data, bssid);
+ /*
+ * Extract the MAC Address in 'address3' field of the MAC
+ * header and update the MAC Address in the allocated 'data'
+ * variable.
+ */
+ ether_addr_copy(data, bssid + ADDR3);
}
/* This function extracts the SSID from a beacon/probe response frame */
--
2.1.0
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [Outreachy kernel] [PATCH v3] Staging: wilc1000: coreconfigurator: Drop unneeded wrapper functions
2015-10-22 13:07 [PATCH v3] Staging: wilc1000: coreconfigurator: Drop unneeded wrapper functions Shivani Bhardwaj
@ 2015-10-25 1:23 ` Greg KH
0 siblings, 0 replies; 3+ messages in thread
From: Greg KH @ 2015-10-25 1:23 UTC (permalink / raw)
To: Shivani Bhardwaj; +Cc: outreachy-kernel
On Thu, Oct 22, 2015 at 06:37:51PM +0530, Shivani Bhardwaj wrote:
> Replace the wrapper functions get_address1(), get_address2() and get_address3()
> with the standard kernel function ether_addr_copy().
> Semantic patch used to identify the issue:
>
> @@
> identifier f,g;
> @@
>
> *f(...) {
> g(...); }
>
> Signed-off-by: Shivani Bhardwaj <shivanib134@gmail.com>
> ---
> drivers/staging/wilc1000/coreconfigurator.c | 48 ++++++++++++++---------------
> 1 file changed, 23 insertions(+), 25 deletions(-)
What changed from v2? Please be specific here to give maintainers a
chance to understand what is happening.
thanks,
greg k-h
^ permalink raw reply [flat|nested] 3+ messages in thread
* [PATCH v3] Staging: wilc1000: coreconfigurator: Drop unneeded wrapper functions
[not found] <cover.1445607608.git.shivanib134@gmail.com>
@ 2015-10-26 14:46 ` Shivani Bhardwaj
0 siblings, 0 replies; 3+ messages in thread
From: Shivani Bhardwaj @ 2015-10-26 14:46 UTC (permalink / raw)
To: outreachy-kernel; +Cc: outreachy-kernel
Replace the wrapper functions get_address1(), get_address2() and get_address3()
with the standard kernel function ether_addr_copy().
Semantic patch used to identify the issue:
@@
identifier f,g;
@@
*f(...) {
g(...); }
Signed-off-by: Shivani Bhardwaj <shivanib134@gmail.com>
---
Changes in v3:
-Make commit message better
Changes in v2:
-Use standard linux function and hide the offset
drivers/staging/wilc1000/coreconfigurator.c | 48 ++++++++++++++---------------
1 file changed, 23 insertions(+), 25 deletions(-)
diff --git a/drivers/staging/wilc1000/coreconfigurator.c b/drivers/staging/wilc1000/coreconfigurator.c
index 427adfd..6dfe26d 100644
--- a/drivers/staging/wilc1000/coreconfigurator.c
+++ b/drivers/staging/wilc1000/coreconfigurator.c
@@ -13,8 +13,12 @@
#include "wilc_wlan.h"
#include <linux/errno.h>
#include <linux/slab.h>
+#include <linux/etherdevice.h>
#define TAG_PARAM_OFFSET (MAC_HDR_LEN + TIME_STAMP_LEN + \
BEACON_INTERVAL_LEN + CAP_INFO_LEN)
+#define ADDR1 4
+#define ADDR2 10
+#define ADDR3 16
/* Basic Frame Type Codes (2-bit) */
enum basic_frame_type {
@@ -171,38 +175,32 @@ static inline u8 get_from_ds(u8 *header)
return ((header[1] & 0x02) >> 1);
}
-/* This function extracts the MAC Address in 'address1' field of the MAC */
-/* header and updates the MAC Address in the allocated 'addr' variable. */
-static inline void get_address1(u8 *pu8msa, u8 *addr)
-{
- memcpy(addr, pu8msa + 4, 6);
-}
-
-/* This function extracts the MAC Address in 'address2' field of the MAC */
-/* header and updates the MAC Address in the allocated 'addr' variable. */
-static inline void get_address2(u8 *pu8msa, u8 *addr)
-{
- memcpy(addr, pu8msa + 10, 6);
-}
-
-/* This function extracts the MAC Address in 'address3' field of the MAC */
-/* header and updates the MAC Address in the allocated 'addr' variable. */
-static inline void get_address3(u8 *pu8msa, u8 *addr)
-{
- memcpy(addr, pu8msa + 16, 6);
-}
-
/* This function extracts the BSSID from the incoming WLAN packet based on */
-/* the 'from ds' bit, and updates the MAC Address in the allocated 'addr' */
+/* the 'from ds' bit, and updates the MAC Address in the allocated 'data' */
/* variable. */
static inline void get_BSSID(u8 *data, u8 *bssid)
{
if (get_from_ds(data) == 1)
- get_address2(data, bssid);
+ /*
+ * Extract the MAC Address in 'address2' field of the MAC
+ * header and update the MAC Address in the allocated 'data'
+ * variable.
+ */
+ ether_addr_copy(data, bssid + ADDR2);
else if (get_to_ds(data) == 1)
- get_address1(data, bssid);
+ /*
+ * Extract the MAC Address in 'address1' field of the MAC
+ * header and update the MAC Address in the allocated 'data'
+ * variable.
+ */
+ ether_addr_copy(data, bssid + ADDR1);
else
- get_address3(data, bssid);
+ /*
+ * Extract the MAC Address in 'address3' field of the MAC
+ * header and update the MAC Address in the allocated 'data'
+ * variable.
+ */
+ ether_addr_copy(data, bssid + ADDR3);
}
/* This function extracts the SSID from a beacon/probe response frame */
--
2.1.0
^ permalink raw reply related [flat|nested] 3+ messages in thread
end of thread, other threads:[~2015-10-26 14:46 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-10-22 13:07 [PATCH v3] Staging: wilc1000: coreconfigurator: Drop unneeded wrapper functions Shivani Bhardwaj
2015-10-25 1:23 ` [Outreachy kernel] " Greg KH
[not found] <cover.1445607608.git.shivanib134@gmail.com>
2015-10-26 14:46 ` Shivani Bhardwaj
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.