1
0
mirror of https://github.com/aircrack-ng/rtl8812au.git synced 2024-11-10 08:07:05 +00:00

Add support for getting mac-address from devicetree

This commit is contained in:
kimocoder 2019-09-19 15:49:01 +00:00
parent 1f42fba64c
commit 72555281a8
2 changed files with 26 additions and 17 deletions

View File

@ -1577,10 +1577,13 @@ extern char *rtw_initmac;
* @out: buf to store mac address decided
* @hw_mac_addr: mac address from efuse/epprom
*/
void rtw_macaddr_cfg(u8 *out, const u8 *hw_mac_addr)
void rtw_macaddr_cfg(struct device *dev, u8 *out, const u8 *hw_mac_addr)
{
#define DEFAULT_RANDOM_MACADDR 1
u8 mac[ETH_ALEN];
struct device_node *np = dev->of_node;
const unsigned char *addr;
int len;
if (out == NULL) {
rtw_warn_on(1);
@ -1611,21 +1614,27 @@ void rtw_macaddr_cfg(u8 *out, const u8 *hw_mac_addr)
err_chk:
if (rtw_check_invalid_mac_address(mac, _TRUE) == _TRUE) {
#if DEFAULT_RANDOM_MACADDR
RTW_ERR("invalid mac addr:"MAC_FMT", assign random MAC\n", MAC_ARG(mac));
if (np &&
(addr = of_get_property(np, "local-mac-address", &len)) &&
len == ETH_ALEN) {
memcpy(mac, addr, ETH_ALEN);
} else {
#if DEFAULT_RANDOM_MACADDR
DBG_871X_LEVEL(_drv_err_, "invalid mac addr:"MAC_FMT", assign random MAC\n", MAC_ARG(mac));
*((u32 *)(&mac[2])) = rtw_random32();
mac[0] = 0x00;
mac[1] = 0xe0;
mac[2] = 0x4c;
#else
RTW_ERR("invalid mac addr:"MAC_FMT", assign default one\n", MAC_ARG(mac));
#else
DBG_871X_LEVEL(_drv_err_, "invalid mac addr:"MAC_FMT", assign default one\n", MAC_ARG(mac));
mac[0] = 0x00;
mac[1] = 0xe0;
mac[2] = 0x4c;
mac[3] = 0x87;
mac[4] = 0x00;
mac[5] = 0x00;
#endif
#endif
}
}
_rtw_memcpy(out, mac, ETH_ALEN);

View File

@ -2176,7 +2176,7 @@ uint rtw_get_cckrate_size(u8 *rate,u32 rate_length);
int rtw_check_network_type(unsigned char *rate, int ratelen, int channel);
u8 rtw_check_invalid_mac_address(u8 *mac_addr, u8 check_local_bit);
void rtw_macaddr_cfg(u8 *out, const u8 *hw_mac_addr);
void rtw_macaddr_cfg(struct device *dev, u8 *out, const u8 *hw_mac_addr);
u16 rtw_mcs_rate(u8 rf_type, u8 bw_40MHz, u8 short_GI, unsigned char *MCS_rate);
u8 rtw_ht_mcsset_to_nss(u8 *supp_mcs_set);