Received: by 2002:a05:6a10:17d3:0:0:0:0 with SMTP id hz19csp147859pxb; Fri, 16 Apr 2021 01:52:33 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzXj4D64H6SVzei+bbHGFIlqdXkgIzd0WkKIYRi41680yCLrJuFETXJja20lqfjXIvVFqj3 X-Received: by 2002:a17:906:b1d9:: with SMTP id bv25mr7103585ejb.230.1618563153050; Fri, 16 Apr 2021 01:52:33 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1618563153; cv=none; d=google.com; s=arc-20160816; b=zPDoD99Bk8HqvGBvzc0Z9f0Ca4sWwEHfB06ut0KRhqQ+KNSpGRjNrpJN0GhsIsTjzi ZivqxRk/ImryGUPFupY3b+AxM2wte6PXmTRF+gC701tLJrZZAAzK9b18scVPxEPs8kus OqKygFFsTjisFf3KWh7bSZ4LnsCvbiCbdhoq7rMHJsPdY0Zw3rie8mW/AUD5ElDaT3VU fJZvLnm5H+Li1bcRrVUy5cSTNOkKKzU8LQ7yaFyKwWUdJDEMgCNXa/uvV3z7yHyxwP8K AMxFXkbjf87UuQ2Jd+BdBE9ghWY1t7YR945B29umrF1oYrqN6K6n4FX2pey6VHxKq5Ti o/xw== 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=ixG2Nzplv8UZkJsZWa0qHSWsKnKLMWYe29Wnml3TztYUwrQA6RO7JfsNpB7Wlwqh4Z ymTNIMWhV7lt4yQOmL8T492duWiJGcYgSFtjqaYQ55Niw6gsv+Pu4nitTiXhSSmEMO4C FsKtFBDNk9A7mEF5EDuJM8+Hpr/7Xn9N0vFVsp38VsOvllv80JfyWrQoFzgKkqIEPKmJ 31m6PfvoaW4CbuVG50V43kgC7SroH2MAN//H7xW1YSvy8tDt7wj4fYKq+g2EKJRez2gY c79lxOFzTDKAohVuigC04ctAdBJx7sp3dmS0mXwxQ29ejPwleY4HcLT6nzb2e/1fq2Ap lobQ== 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 t20si4594035edr.560.2021.04.16.01.52.10; Fri, 16 Apr 2021 01:52:33 -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 S241271AbhDPIsf (ORCPT + 99 others); Fri, 16 Apr 2021 04:48:35 -0400 Received: from mx2.suse.de ([195.135.220.15]:46126 "EHLO mx2.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S240890AbhDPIrn (ORCPT ); Fri, 16 Apr 2021 04:47:43 -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 EE527AE86; Fri, 16 Apr 2021 08:47:16 +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 v4 net-next 07/10] net: korina: Add support for device tree Date: Fri, 16 Apr 2021 10:47:08 +0200 Message-Id: <20210416084712.62561-8-tsbogend@alpha.franken.de> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20210416084712.62561-1-tsbogend@alpha.franken.de> References: <20210416084712.62561-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