* [PATCH 1/2] staging: rtl8188eu: refactor rtw_macaddr_cfg()
@ 2018-07-08 11:58 Michael Straube
2018-07-08 11:58 ` [PATCH 2/2] staging: rtl8188eu: replace tabs with spaces Michael Straube
0 siblings, 1 reply; 2+ messages in thread
From: Michael Straube @ 2018-07-08 11:58 UTC (permalink / raw)
To: gregkh; +Cc: devel, linux-kernel, Michael Straube
Use ether_addr_copy() instead of memcpy() to copy the mac address.
Using is_broadcast_ether_addr() and is_zero_ether_addr() instead of
testing each byte of the mac[] array for 0xff and 0x00 shortens the
code and improves readability.
Instead of a fixed default mac address use a random one to reduce the
likelihood of mac address collision.
Signed-off-by: Michael Straube <straube.linux@gmail.com>
---
.../staging/rtl8188eu/core/rtw_ieee80211.c | 20 +++++--------------
1 file changed, 5 insertions(+), 15 deletions(-)
diff --git a/drivers/staging/rtl8188eu/core/rtw_ieee80211.c b/drivers/staging/rtl8188eu/core/rtw_ieee80211.c
index 711ebb0ad640..e6dff44e00fd 100644
--- a/drivers/staging/rtl8188eu/core/rtw_ieee80211.c
+++ b/drivers/staging/rtl8188eu/core/rtw_ieee80211.c
@@ -917,25 +917,15 @@ void rtw_macaddr_cfg(u8 *mac_addr)
if (rtw_initmac && mac_pton(rtw_initmac, mac)) {
/* Users specify the mac address */
- memcpy(mac_addr, mac, ETH_ALEN);
+ ether_addr_copy(mac_addr, mac);
} else {
/* Use the mac address stored in the Efuse */
- memcpy(mac, mac_addr, ETH_ALEN);
+ ether_addr_copy(mac, mac_addr);
}
- if (((mac[0] == 0xff) && (mac[1] == 0xff) && (mac[2] == 0xff) &&
- (mac[3] == 0xff) && (mac[4] == 0xff) && (mac[5] == 0xff)) ||
- ((mac[0] == 0x0) && (mac[1] == 0x0) && (mac[2] == 0x0) &&
- (mac[3] == 0x0) && (mac[4] == 0x0) && (mac[5] == 0x0))) {
- mac[0] = 0x00;
- mac[1] = 0xe0;
- mac[2] = 0x4c;
- mac[3] = 0x87;
- mac[4] = 0x00;
- mac[5] = 0x00;
- /* use default mac address */
- memcpy(mac_addr, mac, ETH_ALEN);
- DBG_88E("MAC Address from efuse error, assign default one !!!\n");
+ if (is_broadcast_ether_addr(mac) || is_zero_ether_addr(mac)) {
+ eth_random_addr(mac_addr);
+ DBG_88E("MAC Address from efuse error, assign random one !!!\n");
}
DBG_88E("%s MAC Address = %pM\n", __func__, (mac_addr));
--
2.18.0
^ permalink raw reply related [flat|nested] 2+ messages in thread
* [PATCH 2/2] staging: rtl8188eu: replace tabs with spaces
2018-07-08 11:58 [PATCH 1/2] staging: rtl8188eu: refactor rtw_macaddr_cfg() Michael Straube
@ 2018-07-08 11:58 ` Michael Straube
0 siblings, 0 replies; 2+ messages in thread
From: Michael Straube @ 2018-07-08 11:58 UTC (permalink / raw)
To: gregkh; +Cc: devel, linux-kernel, Michael Straube
Replace tabs with spaces in some function definitions and variable
declarations.
Signed-off-by: Michael Straube <straube.linux@gmail.com>
---
drivers/staging/rtl8188eu/core/rtw_ieee80211.c | 12 ++++++------
1 file changed, 6 insertions(+), 6 deletions(-)
diff --git a/drivers/staging/rtl8188eu/core/rtw_ieee80211.c b/drivers/staging/rtl8188eu/core/rtw_ieee80211.c
index e6dff44e00fd..fed33d9acf60 100644
--- a/drivers/staging/rtl8188eu/core/rtw_ieee80211.c
+++ b/drivers/staging/rtl8188eu/core/rtw_ieee80211.c
@@ -73,9 +73,9 @@ int rtw_get_bit_value_from_ieee_value(u8 val)
return 0;
}
-uint rtw_is_cckrates_included(u8 *rate)
+uint rtw_is_cckrates_included(u8 *rate)
{
- u32 i = 0;
+ u32 i = 0;
while (rate[i] != 0) {
if ((((rate[i]) & 0x7f) == 2) || (((rate[i]) & 0x7f) == 4) ||
@@ -86,7 +86,7 @@ uint rtw_is_cckrates_included(u8 *rate)
return false;
}
-uint rtw_is_cckratesonly_included(u8 *rate)
+uint rtw_is_cckratesonly_included(u8 *rate)
{
u32 i = 0;
@@ -212,9 +212,9 @@ uint rtw_get_rateset_len(u8 *rateset)
int rtw_generate_ie(struct registry_priv *pregistrypriv)
{
- u8 wireless_mode;
- int rateLen;
- uint sz = 0;
+ u8 wireless_mode;
+ int rateLen;
+ uint sz = 0;
struct wlan_bssid_ex *pdev_network = &pregistrypriv->dev_network;
u8 *ie = pdev_network->ies;
--
2.18.0
^ permalink raw reply related [flat|nested] 2+ messages in thread
end of thread, other threads:[~2018-07-08 11:58 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-07-08 11:58 [PATCH 1/2] staging: rtl8188eu: refactor rtw_macaddr_cfg() Michael Straube
2018-07-08 11:58 ` [PATCH 2/2] staging: rtl8188eu: replace tabs with spaces Michael Straube
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).