Skip to content

Commit

Permalink
net: ethernet: cortina: permit to set mac address in DT
Browse files Browse the repository at this point in the history
Add ability of setting mac address in DT for cortina ethernet driver.

Signed-off-by: Corentin Labbe <clabbe@baylibre.com>
Reviewed-by: Linus Walleij <linus.walleij@linaro.org>
Link: https://lore.kernel.org/r/20220125210811.54350-1-clabbe@baylibre.com
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
  • Loading branch information
Corentin Labbe authored and Jakub Kicinski committed Jan 27, 2022
1 parent 40cd4f1 commit 15f75fd
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions drivers/net/ethernet/cortina/gemini.c
Original file line number Diff line number Diff line change
Expand Up @@ -2363,11 +2363,13 @@ static void gemini_port_save_mac_addr(struct gemini_ethernet_port *port)
static int gemini_ethernet_port_probe(struct platform_device *pdev)
{
char *port_names[2] = { "ethernet0", "ethernet1" };
struct device_node *np = pdev->dev.of_node;
struct gemini_ethernet_port *port;
struct device *dev = &pdev->dev;
struct gemini_ethernet *geth;
struct net_device *netdev;
struct device *parent;
u8 mac[ETH_ALEN];
unsigned int id;
int irq;
int ret;
Expand Down Expand Up @@ -2473,6 +2475,12 @@ static int gemini_ethernet_port_probe(struct platform_device *pdev)
netif_napi_add(netdev, &port->napi, gmac_napi_poll,
DEFAULT_NAPI_WEIGHT);

ret = of_get_mac_address(np, mac);
if (!ret) {
dev_info(dev, "Setting macaddr from DT %pM\n", mac);
memcpy(port->mac_addr, mac, ETH_ALEN);
}

if (is_valid_ether_addr((void *)port->mac_addr)) {
eth_hw_addr_set(netdev, (u8 *)port->mac_addr);
} else {
Expand Down

0 comments on commit 15f75fd

Please sign in to comment.