atheros: update ether addresses handling
authorJohn Crispin <john@openwrt.org>
Fri, 12 Sep 2014 06:52:21 +0000 (06:52 +0000)
committerJohn Crispin <john@openwrt.org>
Fri, 12 Sep 2014 06:52:21 +0000 (06:52 +0000)
- use ether_foo() routines to work with addresses
 - use ETH_ALEN inplace of magic '6'

Signed-off-by: Sergey Ryazanov <ryazanov.s.a@gmail.com>
SVN-Revision: 42494

target/linux/atheros/patches-3.14/100-board.patch

index a19e4b36b310150ba4dcb6a28b7c4b6792695587..57831fa9add79d6bdf5b414a8723eafa9518ca4a 100644 (file)
@@ -84,7 +84,7 @@
 +obj-$(CONFIG_ATHEROS_AR2315) += ar2315.o
 --- /dev/null
 +++ b/arch/mips/ar231x/board.c
 +obj-$(CONFIG_ATHEROS_AR2315) += ar2315.o
 --- /dev/null
 +++ b/arch/mips/ar231x/board.c
-@@ -0,0 +1,263 @@
+@@ -0,0 +1,260 @@
 +/*
 + * This file is subject to the terms and conditions of the GNU General Public
 + * License.  See the file "COPYING" in the main directory of this archive
 +/*
 + * This file is subject to the terms and conditions of the GNU General Public
 + * License.  See the file "COPYING" in the main directory of this archive
 +      if (broken_boarddata) {
 +              pr_warn("WARNING: broken board data detected\n");
 +              config = ar231x_board.config;
 +      if (broken_boarddata) {
 +              pr_warn("WARNING: broken board data detected\n");
 +              config = ar231x_board.config;
-+              if (!memcmp(config->enet0_mac, "\x00\x00\x00\x00\x00\x00", 6)) {
++              if (is_zero_ether_addr(config->enet0_mac)) {
 +                      pr_info("Fixing up empty mac addresses\n");
 +                      config->reset_config_gpio = 0xffff;
 +                      config->sys_led_gpio = 0xffff;
 +                      pr_info("Fixing up empty mac addresses\n");
 +                      config->reset_config_gpio = 0xffff;
 +                      config->sys_led_gpio = 0xffff;
 +              }
 +      }
 +
 +              }
 +      }
 +
-+
 +      /* Radio config starts 0x100 bytes after board config, regardless
 +       * of what the physical layout on the flash chip looks like */
 +
 +      /* Radio config starts 0x100 bytes after board config, regardless
 +       * of what the physical layout on the flash chip looks like */
 +
 +      mac_addr = &radio_data[0x1d * 2];
 +      if (is_broadcast_ether_addr(mac_addr)) {
 +              pr_info("Radio MAC is blank; using board-data\n");
 +      mac_addr = &radio_data[0x1d * 2];
 +      if (is_broadcast_ether_addr(mac_addr)) {
 +              pr_info("Radio MAC is blank; using board-data\n");
-+              memcpy(mac_addr, ar231x_board.config->wlan0_mac, ETH_ALEN);
++              ether_addr_copy(mac_addr, ar231x_board.config->wlan0_mac);
 +      }
 +
 +      return 0;
 +      }
 +
 +      return 0;
 +      write_c0_watchlo0(0);
 +}
 +
 +      write_c0_watchlo0(0);
 +}
 +
-+
 +asmlinkage void
 +plat_irq_dispatch(void)
 +{
 +asmlinkage void
 +plat_irq_dispatch(void)
 +{
 +      ar2315_irq_init();
 +}
 +
 +      ar2315_irq_init();
 +}
 +
-+
 --- /dev/null
 +++ b/arch/mips/ar231x/prom.c
 @@ -0,0 +1,37 @@
 --- /dev/null
 +++ b/arch/mips/ar231x/prom.c
 @@ -0,0 +1,37 @@
 +}
 --- /dev/null
 +++ b/arch/mips/include/asm/mach-ar231x/ar231x_platform.h
 +}
 --- /dev/null
 +++ b/arch/mips/include/asm/mach-ar231x/ar231x_platform.h
-@@ -0,0 +1,83 @@
+@@ -0,0 +1,85 @@
 +#ifndef __ASM_MACH_AR231X_PLATFORM_H
 +#define __ASM_MACH_AR231X_PLATFORM_H
 +
 +#ifndef __ASM_MACH_AR231X_PLATFORM_H
 +#define __ASM_MACH_AR231X_PLATFORM_H
 +
++#include <linux/etherdevice.h>
++
 +/*
 + * This is board-specific data that is stored in a "fixed" location in flash.
 + * It is shared across operating systems, so it should not be changed lightly.
 +/*
 + * This is board-specific data that is stored in a "fixed" location in flash.
 + * It is shared across operating systems, so it should not be changed lightly.
 +      u32 sys_freq;                /* System frequency in Hz */
 +      u32 cnt_freq;                /* Calculated C0_COUNT frequency */
 +
 +      u32 sys_freq;                /* System frequency in Hz */
 +      u32 cnt_freq;                /* Calculated C0_COUNT frequency */
 +
-+      u8  wlan0_mac[6];
-+      u8  enet0_mac[6];
-+      u8  enet1_mac[6];
++      u8  wlan0_mac[ETH_ALEN];
++      u8  enet0_mac[ETH_ALEN];
++      u8  enet1_mac[ETH_ALEN];
 +
 +      u16 pci_id;                  /* Pseudo PCIID for common code */
 +      u16 mem_cap;                 /* cap bank1 in MB */
 +
 +      /* version 3 */
 +
 +      u16 pci_id;                  /* Pseudo PCIID for common code */
 +      u16 mem_cap;                 /* cap bank1 in MB */
 +
 +      /* version 3 */
-+      u8  wlan1_mac[6];            /* (ar5212) */
++      u8  wlan1_mac[ETH_ALEN];     /* (ar5212) */
 +};
 +
 +#define BOARD_CONFIG_BUFSZ            0x1000
 +};
 +
 +#define BOARD_CONFIG_BUFSZ            0x1000
 +#endif
 +
 +      /* Fix up MAC addresses if necessary */
 +#endif
 +
 +      /* Fix up MAC addresses if necessary */
-+      if (!memcmp(config->enet0_mac, "\xff\xff\xff\xff\xff\xff", 6))
-+              memcpy(config->enet0_mac, config->enet1_mac, 6);
++      if (is_broadcast_ether_addr(config->enet0_mac))
++              ether_addr_copy(config->enet0_mac, config->enet1_mac);
 +
 +      /* If ENET0 and ENET1 have the same mac address,
 +       * increment the one from ENET1 */
 +
 +      /* If ENET0 and ENET1 have the same mac address,
 +       * increment the one from ENET1 */
-+      if (memcmp(config->enet0_mac, config->enet1_mac, 6) == 0) {
++      if (ether_addr_equal(config->enet0_mac, config->enet1_mac)) {
 +              c = config->enet1_mac + 5;
 +              while ((c >= config->enet1_mac) && !(++(*c)))
 +                      c--;
 +              c = config->enet1_mac + 5;
 +              while ((c >= config->enet1_mac) && !(++(*c)))
 +                      c--;