Advertisement
Guest User

Untitled

a guest
Oct 31st, 2013
172
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.09 KB | None | 0 0
  1. commit 262b374df70fdd6b3fe43945d3561e5eddc2a905
  2. Author: Michal Suchanek <hramrach@gmail.com>
  3. Date: Tue Oct 29 11:40:00 2013 +0100
  4.  
  5. Hack to pass ethernet mac address on the commandline.
  6.  
  7. Signed-off-by: Michal Suchanek <hramrach@gmail.com>
  8.  
  9. diff --git a/drivers/net/ethernet/allwinner/sun4i-emac.c b/drivers/net/ethernet/allwinner/sun4i-emac.c
  10. index 50b853a..5b51ed8 100644
  11. --- a/drivers/net/ethernet/allwinner/sun4i-emac.c
  12. +++ b/drivers/net/ethernet/allwinner/sun4i-emac.c
  13. @@ -852,11 +852,30 @@ static int emac_probe(struct platform_device *pdev)
  14. if (mac_addr)
  15. memcpy(ndev->dev_addr, mac_addr, ETH_ALEN);
  16.  
  17. - /* Check if the MAC address is valid, if not get a random one */
  18. + /* Check if the MAC address is valid */
  19. if (!is_valid_ether_addr(ndev->dev_addr)) {
  20. + const char * ptr;
  21. + char * ptr_end;
  22. +#define mac_len 6*2+5U
  23. + char eth[mac_len + 1];
  24. + int eth_len, mac_byte_counter;
  25. + ptr = strstr(boot_command_line, "eth=");
  26. + eth_len = min(mac_len, strlen(ptr));
  27. + memcpy(eth, ptr+4, eth_len);
  28. + eth[eth_len]=0;
  29. + dev_warn(&pdev->dev, "mac address given on kernel commandline: %s\n", eth);
  30. + ptr_end = eth;
  31. + for (mac_byte_counter = 0; mac_byte_counter <= 5; mac_byte_counter ++) {
  32. + ndev->dev_addr[mac_byte_counter] = simple_strtol(ptr_end, &ptr_end, 16) | simple_strtol(ptr_end, &ptr_end, 16) << 4;
  33. + if(*ptr_end == ':' || *ptr_end == '-' || *ptr_end == ' ') ptr_end++;
  34. + }
  35. + dev_warn(&pdev->dev, "MAC address %pM is %svalid.\n", ndev->dev_addr,
  36. + is_valid_ether_addr(ndev->dev_addr)? "" : "NOT ");
  37. + if(!is_valid_ether_addr(ndev->dev_addr)){
  38. eth_hw_addr_random(ndev);
  39. dev_warn(&pdev->dev, "using random MAC address %pM\n",
  40. ndev->dev_addr);
  41. + }
  42. }
  43.  
  44. db->emacrx_completed_flag = 1;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement