| .. | .. |
|---|
| 1 | +// SPDX-License-Identifier: GPL-2.0-or-later |
|---|
| 1 | 2 | /*************************************************************************** |
|---|
| 2 | 3 | * |
|---|
| 3 | 4 | * Copyright (C) 2007-2010 SMSC |
|---|
| 4 | | - * |
|---|
| 5 | | - * This program is free software; you can redistribute it and/or |
|---|
| 6 | | - * modify it under the terms of the GNU General Public License |
|---|
| 7 | | - * as published by the Free Software Foundation; either version 2 |
|---|
| 8 | | - * of the License, or (at your option) any later version. |
|---|
| 9 | | - * |
|---|
| 10 | | - * This program is distributed in the hope that it will be useful, |
|---|
| 11 | | - * but WITHOUT ANY WARRANTY; without even the implied warranty of |
|---|
| 12 | | - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|---|
| 13 | | - * GNU General Public License for more details. |
|---|
| 14 | | - * |
|---|
| 15 | | - * You should have received a copy of the GNU General Public License |
|---|
| 16 | | - * along with this program; if not, see <http://www.gnu.org/licenses/>. |
|---|
| 17 | 5 | * |
|---|
| 18 | 6 | *****************************************************************************/ |
|---|
| 19 | 7 | |
|---|
| .. | .. |
|---|
| 673 | 661 | return; |
|---|
| 674 | 662 | } |
|---|
| 675 | 663 | |
|---|
| 676 | | - memcpy(&intdata, urb->transfer_buffer, 4); |
|---|
| 677 | | - le32_to_cpus(&intdata); |
|---|
| 664 | + intdata = get_unaligned_le32(urb->transfer_buffer); |
|---|
| 678 | 665 | |
|---|
| 679 | 666 | netif_dbg(dev, link, dev->net, "intdata: 0x%08X\n", intdata); |
|---|
| 680 | 667 | |
|---|
| .. | .. |
|---|
| 770 | 757 | |
|---|
| 771 | 758 | static void smsc75xx_init_mac_address(struct usbnet *dev) |
|---|
| 772 | 759 | { |
|---|
| 773 | | - const u8 *mac_addr; |
|---|
| 774 | | - |
|---|
| 775 | 760 | /* maybe the boot loader passed the MAC address in devicetree */ |
|---|
| 776 | | - mac_addr = of_get_mac_address(dev->udev->dev.of_node); |
|---|
| 777 | | - if (mac_addr) { |
|---|
| 778 | | - memcpy(dev->net->dev_addr, mac_addr, ETH_ALEN); |
|---|
| 779 | | - return; |
|---|
| 761 | + if (!eth_platform_get_mac_address(&dev->udev->dev, |
|---|
| 762 | + dev->net->dev_addr)) { |
|---|
| 763 | + if (is_valid_ether_addr(dev->net->dev_addr)) { |
|---|
| 764 | + /* device tree values are valid so use them */ |
|---|
| 765 | + netif_dbg(dev, ifup, dev->net, "MAC address read from the device tree\n"); |
|---|
| 766 | + return; |
|---|
| 767 | + } |
|---|
| 780 | 768 | } |
|---|
| 781 | 769 | |
|---|
| 782 | 770 | /* try reading mac address from EEPROM */ |
|---|
| .. | .. |
|---|
| 2199 | 2187 | struct sk_buff *ax_skb; |
|---|
| 2200 | 2188 | unsigned char *packet; |
|---|
| 2201 | 2189 | |
|---|
| 2202 | | - memcpy(&rx_cmd_a, skb->data, sizeof(rx_cmd_a)); |
|---|
| 2203 | | - le32_to_cpus(&rx_cmd_a); |
|---|
| 2190 | + rx_cmd_a = get_unaligned_le32(skb->data); |
|---|
| 2204 | 2191 | skb_pull(skb, 4); |
|---|
| 2205 | 2192 | |
|---|
| 2206 | | - memcpy(&rx_cmd_b, skb->data, sizeof(rx_cmd_b)); |
|---|
| 2207 | | - le32_to_cpus(&rx_cmd_b); |
|---|
| 2193 | + rx_cmd_b = get_unaligned_le32(skb->data); |
|---|
| 2208 | 2194 | skb_pull(skb, 4 + RXW_PADDING); |
|---|
| 2209 | 2195 | |
|---|
| 2210 | 2196 | packet = skb->data; |
|---|
| .. | .. |
|---|
| 2276 | 2262 | struct sk_buff *skb, gfp_t flags) |
|---|
| 2277 | 2263 | { |
|---|
| 2278 | 2264 | u32 tx_cmd_a, tx_cmd_b; |
|---|
| 2265 | + void *ptr; |
|---|
| 2279 | 2266 | |
|---|
| 2280 | 2267 | if (skb_cow_head(skb, SMSC75XX_TX_OVERHEAD)) { |
|---|
| 2281 | 2268 | dev_kfree_skb_any(skb); |
|---|
| .. | .. |
|---|
| 2296 | 2283 | tx_cmd_b = 0; |
|---|
| 2297 | 2284 | } |
|---|
| 2298 | 2285 | |
|---|
| 2299 | | - skb_push(skb, 4); |
|---|
| 2300 | | - cpu_to_le32s(&tx_cmd_b); |
|---|
| 2301 | | - memcpy(skb->data, &tx_cmd_b, 4); |
|---|
| 2302 | | - |
|---|
| 2303 | | - skb_push(skb, 4); |
|---|
| 2304 | | - cpu_to_le32s(&tx_cmd_a); |
|---|
| 2305 | | - memcpy(skb->data, &tx_cmd_a, 4); |
|---|
| 2286 | + ptr = skb_push(skb, 8); |
|---|
| 2287 | + put_unaligned_le32(tx_cmd_a, ptr); |
|---|
| 2288 | + put_unaligned_le32(tx_cmd_b, ptr + 4); |
|---|
| 2306 | 2289 | |
|---|
| 2307 | 2290 | return skb; |
|---|
| 2308 | 2291 | } |
|---|