Commit 2de88923 authored by Yoichi Yuasa's avatar Yoichi Yuasa Committed by Jeff Garzik

update AU1000 get_ethernet_addr()

Update AU1000 get_ethernet_addr().
Three functions were brought together in one.
Signed-off-by: default avatarYoichi Yuasa <yoichi_yuasa@tripeaks.co.jp>
Acked-by: default avatarRalf Baechle <ralf@linux-mips.org>
Signed-off-by: default avatarJeff Garzik <jeff@garzik.org>
parent c2af68e5
...@@ -98,7 +98,7 @@ char *prom_getenv(char *envname) ...@@ -98,7 +98,7 @@ char *prom_getenv(char *envname)
return NULL; return NULL;
} }
inline unsigned char str2hexnum(unsigned char c) static inline unsigned char str2hexnum(unsigned char c)
{ {
if(c >= '0' && c <= '9') if(c >= '0' && c <= '9')
return c - '0'; return c - '0';
...@@ -109,7 +109,7 @@ inline unsigned char str2hexnum(unsigned char c) ...@@ -109,7 +109,7 @@ inline unsigned char str2hexnum(unsigned char c)
return 0; /* foo */ return 0; /* foo */
} }
inline void str2eaddr(unsigned char *ea, unsigned char *str) static inline void str2eaddr(unsigned char *ea, unsigned char *str)
{ {
int i; int i;
...@@ -124,35 +124,29 @@ inline void str2eaddr(unsigned char *ea, unsigned char *str) ...@@ -124,35 +124,29 @@ inline void str2eaddr(unsigned char *ea, unsigned char *str)
} }
} }
int get_ethernet_addr(char *ethernet_addr) int prom_get_ethernet_addr(char *ethernet_addr)
{ {
char *ethaddr_str; char *ethaddr_str;
char *argptr;
ethaddr_str = prom_getenv("ethaddr"); /* Check the environment variables first */
ethaddr_str = prom_getenv("ethaddr");
if (!ethaddr_str) { if (!ethaddr_str) {
printk("ethaddr not set in boot prom\n"); /* Check command line */
return -1; argptr = prom_getcmdline();
} ethaddr_str = strstr(argptr, "ethaddr=");
str2eaddr(ethernet_addr, ethaddr_str); if (!ethaddr_str)
return -1;
#if 0
{
int i;
printk("get_ethernet_addr: "); ethaddr_str += strlen("ethaddr=");
for (i=0; i<5; i++)
printk("%02x:", (unsigned char)*(ethernet_addr+i));
printk("%02x\n", *(ethernet_addr+i));
} }
#endif
str2eaddr(ethernet_addr, ethaddr_str);
return 0; return 0;
} }
EXPORT_SYMBOL(prom_get_ethernet_addr);
void __init prom_free_prom_memory(void) void __init prom_free_prom_memory(void)
{ {
} }
EXPORT_SYMBOL(prom_getcmdline);
EXPORT_SYMBOL(get_ethernet_addr);
EXPORT_SYMBOL(str2eaddr);
...@@ -97,9 +97,7 @@ static void au1000_adjust_link(struct net_device *); ...@@ -97,9 +97,7 @@ static void au1000_adjust_link(struct net_device *);
static void enable_mac(struct net_device *, int); static void enable_mac(struct net_device *, int);
// externs // externs
extern int get_ethernet_addr(char *ethernet_addr); extern int prom_get_ethernet_addr(char *ethernet_addr);
extern void str2eaddr(unsigned char *ea, unsigned char *str);
extern char * prom_getcmdline(void);
/* /*
* Theory of operation * Theory of operation
...@@ -619,7 +617,6 @@ static struct net_device * au1000_probe(int port_num) ...@@ -619,7 +617,6 @@ static struct net_device * au1000_probe(int port_num)
struct au1000_private *aup = NULL; struct au1000_private *aup = NULL;
struct net_device *dev = NULL; struct net_device *dev = NULL;
db_dest_t *pDB, *pDBfree; db_dest_t *pDB, *pDBfree;
char *pmac, *argptr;
char ethaddr[6]; char ethaddr[6];
int irq, i, err; int irq, i, err;
u32 base, macen; u32 base, macen;
...@@ -677,21 +674,12 @@ static struct net_device * au1000_probe(int port_num) ...@@ -677,21 +674,12 @@ static struct net_device * au1000_probe(int port_num)
au_macs[port_num] = aup; au_macs[port_num] = aup;
if (port_num == 0) { if (port_num == 0) {
/* Check the environment variables first */ if (prom_get_ethernet_addr(ethaddr) == 0)
if (get_ethernet_addr(ethaddr) == 0)
memcpy(au1000_mac_addr, ethaddr, sizeof(au1000_mac_addr)); memcpy(au1000_mac_addr, ethaddr, sizeof(au1000_mac_addr));
else { else {
/* Check command line */ printk(KERN_INFO "%s: No MAC address found\n",
argptr = prom_getcmdline(); dev->name);
if ((pmac = strstr(argptr, "ethaddr=")) == NULL)
printk(KERN_INFO "%s: No MAC address found\n",
dev->name);
/* Use the hard coded MAC addresses */ /* Use the hard coded MAC addresses */
else {
str2eaddr(ethaddr, pmac + strlen("ethaddr="));
memcpy(au1000_mac_addr, ethaddr,
sizeof(au1000_mac_addr));
}
} }
setup_hw_rings(aup, MAC0_RX_DMA_ADDR, MAC0_TX_DMA_ADDR); setup_hw_rings(aup, MAC0_RX_DMA_ADDR, MAC0_TX_DMA_ADDR);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment