Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

ax88796: Add method to take MAC from platform data

Implement a way to provide the MAC address for ax88796 devices from
their platform data. Boards might decide to set the address
programmatically, taken from boot tags or other sources.

Signed-off-by: Daniel Mack <daniel@caiaq.de>
Signed-off-by: David S. Miller <davem@davemloft.net>

authored by

Daniel Mack and committed by
David S. Miller
67fca028 47cb0355

+20 -10
+12 -5
drivers/net/ax88796.c
··· 733 733 /* load the mac-address from the device if this is the 734 734 * first time we've initialised */ 735 735 736 - if (first_init && ax->plat->flags & AXFLG_MAC_FROMDEV) { 737 - ei_outb(E8390_NODMA + E8390_PAGE1 + E8390_STOP, 738 - ei_local->mem + E8390_CMD); /* 0x61 */ 736 + if (first_init) { 737 + if (ax->plat->flags & AXFLG_MAC_FROMDEV) { 738 + ei_outb(E8390_NODMA + E8390_PAGE1 + E8390_STOP, 739 + ei_local->mem + E8390_CMD); /* 0x61 */ 740 + for (i = 0; i < ETHER_ADDR_LEN; i++) 741 + dev->dev_addr[i] = 742 + ei_inb(ioaddr + EN1_PHYS_SHIFT(i)); 743 + } 739 744 740 - for (i = 0 ; i < ETHER_ADDR_LEN ; i++) 741 - dev->dev_addr[i] = ei_inb(ioaddr + EN1_PHYS_SHIFT(i)); 745 + if ((ax->plat->flags & AXFLG_MAC_FROMPLATFORM) && 746 + ax->plat->mac_addr) 747 + memcpy(dev->dev_addr, ax->plat->mac_addr, 748 + ETHER_ADDR_LEN); 742 749 } 743 750 744 751 ax_reset_8390(dev);
+8 -5
include/net/ax88796.h
··· 15 15 #define AXFLG_HAS_EEPROM (1<<0) 16 16 #define AXFLG_MAC_FROMDEV (1<<1) /* device already has MAC */ 17 17 #define AXFLG_HAS_93CX6 (1<<2) /* use eeprom_93cx6 driver */ 18 + #define AXFLG_MAC_FROMPLATFORM (1<<3) /* MAC given by platform data */ 18 19 19 20 struct ax_plat_data { 20 21 unsigned int flags; 21 - unsigned char wordlength; /* 1 or 2 */ 22 - unsigned char dcr_val; /* default value for DCR */ 23 - unsigned char rcr_val; /* default value for RCR */ 24 - unsigned char gpoc_val; /* default value for GPOC */ 25 - u32 *reg_offsets; /* register offsets */ 22 + unsigned char wordlength; /* 1 or 2 */ 23 + unsigned char dcr_val; /* default value for DCR */ 24 + unsigned char rcr_val; /* default value for RCR */ 25 + unsigned char gpoc_val; /* default value for GPOC */ 26 + u32 *reg_offsets; /* register offsets */ 27 + u8 *mac_addr; /* MAC addr (only used when 28 + AXFLG_MAC_FROMPLATFORM is used */ 26 29 }; 27 30 28 31 #endif /* __NET_AX88796_PLAT_H */