Received: by 2002:a05:6a10:17d3:0:0:0:0 with SMTP id hz19csp148472pxb; Fri, 16 Apr 2021 01:54:12 -0700 (PDT) X-Google-Smtp-Source: ABdhPJx3JIguUPqG4qdPwdYe95UF+5dMIsptHZYfTN+S7LAgkVfYS96PnfzQV8S1zcU52Vsimfu5 X-Received: by 2002:a17:906:5383:: with SMTP id g3mr7508152ejo.185.1618563252424; Fri, 16 Apr 2021 01:54:12 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1618563252; cv=none; d=google.com; s=arc-20160816; b=kYQLbGZ3wJS4yEExtK7gi6sMoSfHpn4Spw1WfNefdjJWNELpFJrCWr8ysohWLUieSS 6o1gFnpqAZgf+9W+kzsUGVhOzKU676LuOCLzLJwrdnUBaWji54miqgs3H+3hoExRxzcD dQIbfgN+Z85JBadlafibSuCYbXThkeE6MriUtjYjrc5Es3GFE1HDKTlprsHXXiiLFwg3 KezY4L2BsIjX1rDJY5FmcEtQtaW9H7LdkXeMtDCeaL2WqaqRTBMFmt0LVFKhyJrWP+r5 JULnMl0Ps9Zusu7o4Jys4XFpSiSZa6i20JDF8zXiSLqeduqcBIc4mWi85xbJ/HO3/R3f mfxw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:to:from; bh=xCS2BQxPhY3B5bqxx6b0gpktD/K0Eh6C4tGzgfy8e6I=; b=XHisSvnbyvjT+/RrP+9zbp6JYz6bCEE2z+8MX3qRyzILqqRl/MxNnFKgriERmRO6nN LUjG2nhXCrYHejk9TnC6G3pYaeVFI/sYuTxgeek+U0Si5N4i4SSdxV7MsCTyZWNqaKvw x2GluukSlvBNH5YeNFT9bXxRF11+2tNLCnQZaO/9dIJfe94QqYEdwDjV/RT02slNnhKc RbDusSdbPwFfkLrKmdPxcGDCpB8iQngdg5ysZ0eoxkQXQvarE/qBPfxOhPL85G/Y373b JdOlSoROq0UyhascWagmce1sRchRsy+ONovim7PVORiRIPewCd8tufAK0NFJ2NDTWWFq vCdQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id ay17si4659984ejb.426.2021.04.16.01.53.50; Fri, 16 Apr 2021 01:54:12 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S241532AbhDPIw6 (ORCPT + 99 others); Fri, 16 Apr 2021 04:52:58 -0400 Received: from mx2.suse.de ([195.135.220.15]:54116 "EHLO mx2.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S240920AbhDPIwj (ORCPT ); Fri, 16 Apr 2021 04:52:39 -0400 X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay2.suse.de (unknown [195.135.221.27]) by mx2.suse.de (Postfix) with ESMTP id 63311AF38; Fri, 16 Apr 2021 08:52:13 +0000 (UTC) From: Thomas Bogendoerfer To: "David S. Miller" , Jakub Kicinski , Rob Herring , netdev@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, linux-mips@vger.kernel.org Subject: [PATCH v5 net-next 07/10] net: korina: Add support for device tree Date: Fri, 16 Apr 2021 10:52:03 +0200 Message-Id: <20210416085207.63181-8-tsbogend@alpha.franken.de> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20210416085207.63181-1-tsbogend@alpha.franken.de> References: <20210416085207.63181-1-tsbogend@alpha.franken.de> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org If there is no mac address passed via platform data try to get it via device tree and fall back to a random mac address, if all fail. Signed-off-by: Thomas Bogendoerfer --- drivers/net/ethernet/korina.c | 24 ++++++++++++++++++++++-- 1 file changed, 22 insertions(+), 2 deletions(-) diff --git a/drivers/net/ethernet/korina.c b/drivers/net/ethernet/korina.c index d6dbbdd43d7c..cd078a5c679b 100644 --- a/drivers/net/ethernet/korina.c +++ b/drivers/net/ethernet/korina.c @@ -43,6 +43,8 @@ #include #include #include +#include +#include #include #include #include @@ -1068,7 +1070,12 @@ static int korina_probe(struct platform_device *pdev) SET_NETDEV_DEV(dev, &pdev->dev); lp = netdev_priv(dev); - memcpy(dev->dev_addr, mac_addr, ETH_ALEN); + if (mac_addr) { + ether_addr_copy(dev->dev_addr, mac_addr); + } else { + if (of_get_mac_address(pdev->dev.of_node, dev->dev_addr)) + eth_hw_addr_random(dev); + } lp->rx_irq = platform_get_irq_byname(pdev, "korina_rx"); lp->tx_irq = platform_get_irq_byname(pdev, "korina_tx"); @@ -1148,8 +1155,21 @@ static int korina_remove(struct platform_device *pdev) return 0; } +#ifdef CONFIG_OF +static const struct of_device_id korina_match[] = { + { + .compatible = "idt,3243x-emac", + }, + { } +}; +MODULE_DEVICE_TABLE(of, korina_match); +#endif + static struct platform_driver korina_driver = { - .driver.name = "korina", + .driver = { + .name = "korina", + .of_match_table = of_match_ptr(korina_match), + }, .probe = korina_probe, .remove = korina_remove, }; -- 2.29.2