Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- commit 262b374df70fdd6b3fe43945d3561e5eddc2a905
- Author: Michal Suchanek <hramrach@gmail.com>
- Date: Tue Oct 29 11:40:00 2013 +0100
- Hack to pass ethernet mac address on the commandline.
- Signed-off-by: Michal Suchanek <hramrach@gmail.com>
- diff --git a/drivers/net/ethernet/allwinner/sun4i-emac.c b/drivers/net/ethernet/allwinner/sun4i-emac.c
- index 50b853a..5b51ed8 100644
- --- a/drivers/net/ethernet/allwinner/sun4i-emac.c
- +++ b/drivers/net/ethernet/allwinner/sun4i-emac.c
- @@ -852,11 +852,30 @@ static int emac_probe(struct platform_device *pdev)
- if (mac_addr)
- memcpy(ndev->dev_addr, mac_addr, ETH_ALEN);
- - /* Check if the MAC address is valid, if not get a random one */
- + /* Check if the MAC address is valid */
- if (!is_valid_ether_addr(ndev->dev_addr)) {
- + const char * ptr;
- + char * ptr_end;
- +#define mac_len 6*2+5U
- + char eth[mac_len + 1];
- + int eth_len, mac_byte_counter;
- + ptr = strstr(boot_command_line, "eth=");
- + eth_len = min(mac_len, strlen(ptr));
- + memcpy(eth, ptr+4, eth_len);
- + eth[eth_len]=0;
- + dev_warn(&pdev->dev, "mac address given on kernel commandline: %s\n", eth);
- + ptr_end = eth;
- + for (mac_byte_counter = 0; mac_byte_counter <= 5; mac_byte_counter ++) {
- + ndev->dev_addr[mac_byte_counter] = simple_strtol(ptr_end, &ptr_end, 16) | simple_strtol(ptr_end, &ptr_end, 16) << 4;
- + if(*ptr_end == ':' || *ptr_end == '-' || *ptr_end == ' ') ptr_end++;
- + }
- + dev_warn(&pdev->dev, "MAC address %pM is %svalid.\n", ndev->dev_addr,
- + is_valid_ether_addr(ndev->dev_addr)? "" : "NOT ");
- + if(!is_valid_ether_addr(ndev->dev_addr)){
- eth_hw_addr_random(ndev);
- dev_warn(&pdev->dev, "using random MAC address %pM\n",
- ndev->dev_addr);
- + }
- }
- db->emacrx_completed_flag = 1;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement