diff options
author | Yoichi Yuasa <yoichi_yuasa@tripeaks.co.jp> | 2007-10-15 06:06:20 -0400 |
---|---|---|
committer | Jeff Garzik <jeff@garzik.org> | 2007-10-15 14:38:24 -0400 |
commit | 2de889235d0e820a6b256b834ee6a64e12fede08 (patch) | |
tree | cb7b58e6ed74f2c6fe8479acb28ff9c50781a2d6 | |
parent | c2af68e5f550a671ac9f67f566f04e1580a103a0 (diff) |
update AU1000 get_ethernet_addr()
Update AU1000 get_ethernet_addr().
Three functions were brought together in one.
Signed-off-by: Yoichi Yuasa <yoichi_yuasa@tripeaks.co.jp>
Acked-by: Ralf Baechle <ralf@linux-mips.org>
Signed-off-by: Jeff Garzik <jeff@garzik.org>
-rw-r--r-- | arch/mips/au1000/common/prom.c | 38 | ||||
-rw-r--r-- | drivers/net/au1000_eth.c | 20 |
2 files changed, 20 insertions, 38 deletions
diff --git a/arch/mips/au1000/common/prom.c b/arch/mips/au1000/common/prom.c index a8637cdb5b4b..5d6ddf1ed7a6 100644 --- a/arch/mips/au1000/common/prom.c +++ b/arch/mips/au1000/common/prom.c | |||
@@ -98,7 +98,7 @@ char *prom_getenv(char *envname) | |||
98 | return NULL; | 98 | return NULL; |
99 | } | 99 | } |
100 | 100 | ||
101 | inline unsigned char str2hexnum(unsigned char c) | 101 | static inline unsigned char str2hexnum(unsigned char c) |
102 | { | 102 | { |
103 | if(c >= '0' && c <= '9') | 103 | if(c >= '0' && c <= '9') |
104 | return c - '0'; | 104 | return c - '0'; |
@@ -109,7 +109,7 @@ inline unsigned char str2hexnum(unsigned char c) | |||
109 | return 0; /* foo */ | 109 | return 0; /* foo */ |
110 | } | 110 | } |
111 | 111 | ||
112 | inline void str2eaddr(unsigned char *ea, unsigned char *str) | 112 | static inline void str2eaddr(unsigned char *ea, unsigned char *str) |
113 | { | 113 | { |
114 | int i; | 114 | int i; |
115 | 115 | ||
@@ -124,35 +124,29 @@ inline void str2eaddr(unsigned char *ea, unsigned char *str) | |||
124 | } | 124 | } |
125 | } | 125 | } |
126 | 126 | ||
127 | int get_ethernet_addr(char *ethernet_addr) | 127 | int prom_get_ethernet_addr(char *ethernet_addr) |
128 | { | 128 | { |
129 | char *ethaddr_str; | 129 | char *ethaddr_str; |
130 | char *argptr; | ||
130 | 131 | ||
131 | ethaddr_str = prom_getenv("ethaddr"); | 132 | /* Check the environment variables first */ |
133 | ethaddr_str = prom_getenv("ethaddr"); | ||
132 | if (!ethaddr_str) { | 134 | if (!ethaddr_str) { |
133 | printk("ethaddr not set in boot prom\n"); | 135 | /* Check command line */ |
134 | return -1; | 136 | argptr = prom_getcmdline(); |
135 | } | 137 | ethaddr_str = strstr(argptr, "ethaddr="); |
136 | str2eaddr(ethernet_addr, ethaddr_str); | 138 | if (!ethaddr_str) |
137 | 139 | return -1; | |
138 | #if 0 | ||
139 | { | ||
140 | int i; | ||
141 | 140 | ||
142 | printk("get_ethernet_addr: "); | 141 | ethaddr_str += strlen("ethaddr="); |
143 | for (i=0; i<5; i++) | ||
144 | printk("%02x:", (unsigned char)*(ethernet_addr+i)); | ||
145 | printk("%02x\n", *(ethernet_addr+i)); | ||
146 | } | 142 | } |
147 | #endif | 143 | |
144 | str2eaddr(ethernet_addr, ethaddr_str); | ||
148 | 145 | ||
149 | return 0; | 146 | return 0; |
150 | } | 147 | } |
148 | EXPORT_SYMBOL(prom_get_ethernet_addr); | ||
151 | 149 | ||
152 | void __init prom_free_prom_memory(void) | 150 | void __init prom_free_prom_memory(void) |
153 | { | 151 | { |
154 | } | 152 | } |
155 | |||
156 | EXPORT_SYMBOL(prom_getcmdline); | ||
157 | EXPORT_SYMBOL(get_ethernet_addr); | ||
158 | EXPORT_SYMBOL(str2eaddr); | ||
diff --git a/drivers/net/au1000_eth.c b/drivers/net/au1000_eth.c index b46c5d8a77bd..297e2d08d267 100644 --- a/drivers/net/au1000_eth.c +++ b/drivers/net/au1000_eth.c | |||
@@ -97,9 +97,7 @@ static void au1000_adjust_link(struct net_device *); | |||
97 | static void enable_mac(struct net_device *, int); | 97 | static void enable_mac(struct net_device *, int); |
98 | 98 | ||
99 | // externs | 99 | // externs |
100 | extern int get_ethernet_addr(char *ethernet_addr); | 100 | extern int prom_get_ethernet_addr(char *ethernet_addr); |
101 | extern void str2eaddr(unsigned char *ea, unsigned char *str); | ||
102 | extern char * prom_getcmdline(void); | ||
103 | 101 | ||
104 | /* | 102 | /* |
105 | * Theory of operation | 103 | * Theory of operation |
@@ -619,7 +617,6 @@ static struct net_device * au1000_probe(int port_num) | |||
619 | struct au1000_private *aup = NULL; | 617 | struct au1000_private *aup = NULL; |
620 | struct net_device *dev = NULL; | 618 | struct net_device *dev = NULL; |
621 | db_dest_t *pDB, *pDBfree; | 619 | db_dest_t *pDB, *pDBfree; |
622 | char *pmac, *argptr; | ||
623 | char ethaddr[6]; | 620 | char ethaddr[6]; |
624 | int irq, i, err; | 621 | int irq, i, err; |
625 | u32 base, macen; | 622 | u32 base, macen; |
@@ -677,21 +674,12 @@ static struct net_device * au1000_probe(int port_num) | |||
677 | au_macs[port_num] = aup; | 674 | au_macs[port_num] = aup; |
678 | 675 | ||
679 | if (port_num == 0) { | 676 | if (port_num == 0) { |
680 | /* Check the environment variables first */ | 677 | if (prom_get_ethernet_addr(ethaddr) == 0) |
681 | if (get_ethernet_addr(ethaddr) == 0) | ||
682 | memcpy(au1000_mac_addr, ethaddr, sizeof(au1000_mac_addr)); | 678 | memcpy(au1000_mac_addr, ethaddr, sizeof(au1000_mac_addr)); |
683 | else { | 679 | else { |
684 | /* Check command line */ | 680 | printk(KERN_INFO "%s: No MAC address found\n", |
685 | argptr = prom_getcmdline(); | 681 | dev->name); |
686 | if ((pmac = strstr(argptr, "ethaddr=")) == NULL) | ||
687 | printk(KERN_INFO "%s: No MAC address found\n", | ||
688 | dev->name); | ||
689 | /* Use the hard coded MAC addresses */ | 682 | /* Use the hard coded MAC addresses */ |
690 | else { | ||
691 | str2eaddr(ethaddr, pmac + strlen("ethaddr=")); | ||
692 | memcpy(au1000_mac_addr, ethaddr, | ||
693 | sizeof(au1000_mac_addr)); | ||
694 | } | ||
695 | } | 683 | } |
696 | 684 | ||
697 | setup_hw_rings(aup, MAC0_RX_DMA_ADDR, MAC0_TX_DMA_ADDR); | 685 | setup_hw_rings(aup, MAC0_RX_DMA_ADDR, MAC0_TX_DMA_ADDR); |