| .. | .. |
|---|
| 1 | +// SPDX-License-Identifier: ISC |
|---|
| 1 | 2 | /* |
|---|
| 2 | 3 | * Copyright (C) 2016 Felix Fietkau <nbd@nbd.name> |
|---|
| 3 | | - * |
|---|
| 4 | | - * Permission to use, copy, modify, and/or distribute this software for any |
|---|
| 5 | | - * purpose with or without fee is hereby granted, provided that the above |
|---|
| 6 | | - * copyright notice and this permission notice appear in all copies. |
|---|
| 7 | | - * |
|---|
| 8 | | - * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES |
|---|
| 9 | | - * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF |
|---|
| 10 | | - * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR |
|---|
| 11 | | - * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES |
|---|
| 12 | | - * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN |
|---|
| 13 | | - * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF |
|---|
| 14 | | - * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. |
|---|
| 15 | 4 | */ |
|---|
| 16 | 5 | #include <linux/of.h> |
|---|
| 17 | 6 | #include <linux/of_net.h> |
|---|
| .. | .. |
|---|
| 75 | 64 | goto out_put_node; |
|---|
| 76 | 65 | } |
|---|
| 77 | 66 | |
|---|
| 67 | + if (of_property_read_bool(dev->dev->of_node, "big-endian")) { |
|---|
| 68 | + u8 *data = (u8 *)dev->eeprom.data; |
|---|
| 69 | + int i; |
|---|
| 70 | + |
|---|
| 71 | + /* convert eeprom data in Little Endian */ |
|---|
| 72 | + for (i = 0; i < round_down(len, 2); i += 2) |
|---|
| 73 | + put_unaligned_le16(get_unaligned_be16(&data[i]), |
|---|
| 74 | + &data[i]); |
|---|
| 75 | + } |
|---|
| 76 | + |
|---|
| 77 | +#ifdef CONFIG_NL80211_TESTMODE |
|---|
| 78 | + dev->test.mtd_name = devm_kstrdup(dev->dev, part, GFP_KERNEL); |
|---|
| 79 | + dev->test.mtd_offset = offset; |
|---|
| 80 | +#endif |
|---|
| 81 | + |
|---|
| 78 | 82 | out_put_node: |
|---|
| 79 | 83 | of_node_put(np); |
|---|
| 80 | 84 | return ret; |
|---|
| .. | .. |
|---|
| 88 | 92 | { |
|---|
| 89 | 93 | #ifdef CONFIG_OF |
|---|
| 90 | 94 | struct device_node *np = dev->dev->of_node; |
|---|
| 91 | | - const u8 *mac; |
|---|
| 95 | + const u8 *mac = NULL; |
|---|
| 92 | 96 | |
|---|
| 93 | | - if (!np) |
|---|
| 94 | | - return; |
|---|
| 95 | | - |
|---|
| 96 | | - mac = of_get_mac_address(np); |
|---|
| 97 | | - if (mac) |
|---|
| 98 | | - memcpy(dev->macaddr, mac, ETH_ALEN); |
|---|
| 97 | + if (np) |
|---|
| 98 | + mac = of_get_mac_address(np); |
|---|
| 99 | + if (!IS_ERR_OR_NULL(mac)) |
|---|
| 100 | + ether_addr_copy(dev->macaddr, mac); |
|---|
| 99 | 101 | #endif |
|---|
| 100 | 102 | |
|---|
| 101 | 103 | if (!is_valid_ether_addr(dev->macaddr)) { |
|---|