Received: by 2002:a5b:505:0:0:0:0:0 with SMTP id o5csp5217866ybp; Mon, 14 Oct 2019 17:51:54 -0700 (PDT) X-Google-Smtp-Source: APXvYqwid/gCAQIBxNNUHUPVuqmYyN1np3f+1OjZSKbMjWwC4/JeHXvJmwRuZ+qVXDhSe9A7n4sZ X-Received: by 2002:a50:fa8e:: with SMTP id w14mr31313188edr.285.1571100714618; Mon, 14 Oct 2019 17:51:54 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1571100714; cv=none; d=google.com; s=arc-20160816; b=fJbFxa5mRt7ATHZZEITLP0EZE/QyBRbIPiA1K3euhn+omxmV7XX4Wl1BHol8Gx5SUc OgbjKCFlue6f/NGshwDrAu3wnRK/GGZUKXfilpyW2/V/+/7WG4g94NRg41AhrwcBylmf zCvMaC/4RrPPYjTGwoW89PDmPIbmbBJbzh7w3vE++PoVdRPVnx1u2Q/jzfBgbHpTjvlk bnVD/q3Mihb4RL/5je1BP5V7R96mss2+c0gSyy9j94B34hEkECVwfv92JsUuJTSpFZv3 CaoDG15NlhJF6IZ9r3LOgcGdZWzXvHssk0BYAF+GbWQ1SDr2CMuFH4BnXHTPwBJWvD93 DNtg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:message-id:date:subject:cc:to:from :dkim-signature; bh=6hnKN1qn6JLpTqGZTLDM/rpkhCTaFPjWHHLh+2/f/Ls=; b=S9j+VoyM9sV3ZrgxyK8j+dl57LA/gwllx2JscWuG7wtpa027rfDeYJBWInRh8LS/6p pO9bbIv1wrI0URP1DudpnjpjdPeLc7uBWYhFS/0gUWIAsnDgmCp9G/moRnZLaT/ynqw/ gN18S8/IBKR+dHOP+ewExC2EJJW9+A+IPc9pfsyxSYdr6Qv6OvoXrJ2ZhN6/QWsH822+ qu4/2Qibu37q5BmY6IWamoOLnGDLPQCEnTJ1Xu9KOwgc8zLETkk0f9CxeD2H4LKSZYNF DEdNk3uSVO3zwm3knAE8fhijH5qePYrDk7DYyX8+OjntzY8/5/wJCEByzFtr4hq2OADh aHcQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=MVcxx5lE; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id f17si14281427eda.232.2019.10.14.17.51.31; Mon, 14 Oct 2019 17:51:54 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=MVcxx5lE; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2387696AbfJNVUZ (ORCPT + 99 others); Mon, 14 Oct 2019 17:20:25 -0400 Received: from mail-pg1-f195.google.com ([209.85.215.195]:37165 "EHLO mail-pg1-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1731044AbfJNVUY (ORCPT ); Mon, 14 Oct 2019 17:20:24 -0400 Received: by mail-pg1-f195.google.com with SMTP id p1so10784235pgi.4; Mon, 14 Oct 2019 14:20:24 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id; bh=6hnKN1qn6JLpTqGZTLDM/rpkhCTaFPjWHHLh+2/f/Ls=; b=MVcxx5lEPiPXy0DHx260IoTJwTaCJ6QPc7Arebc7m+Hk1VlzFGhyl01W/WYXQl0wmS dH65hOmAds130pc5TI7O/K/iuc4d6K7hVEJrlo0QleOR63G3X2mub+pRTcTcL1T0CAJ7 W5xFbnQWJ6yTX8gNWThqzLQdN5JGZS3ZMthdqCEgeqBbnZnjiahYXfierXrhzPnmKh80 SfV/1xOORL+YR6MPGbz4gL1sd+EWi8TJcAkyekyldLrtNZPNCdJU/+jEEBLEk/r7vqpW 9aYt/kwrpy5CS01LQkY6zzS4rvBbOXuhC522FXfXkYT9iHDVmfHCScH+tEM8qeWWDjd3 cKOQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=6hnKN1qn6JLpTqGZTLDM/rpkhCTaFPjWHHLh+2/f/Ls=; b=GC3zwxhvw10QI6/Q9+yEb19gQV5NGCFxnIPcLJ9zAS6QPX6yKhapxYigkJ4PMdjNKl X5o/aE0G66heODyYQijVez2gf6p9b1fYVTWR2FbBaq0Q5X5xdWAADboylFsTtaC+RT7E cnMZvoakquUfbJzwLY2aCaFYyD6WlIzB/A4KRomaY4HjV9ApcLJ9IgYRiZxe6Pmxt8hc 6tlQpyJUrtk5Y8i7mydfieOGWkRMC3ToCnbXt+SucJ608W+xkp0dM8x/mcAKQLqeuTGo Bf0Q1od6LFVLjmT02zQYn6wqhAIw12dC4mcea2aXJxeRcBdE5CcTbgjJGnZpxGweUYxy F8hA== X-Gm-Message-State: APjAAAWW16QpyQfbivsANO43QS1ljju02ConVthTp1j/KU8RnfCSZQaU OESZfjkwjOeE+a2E+bt8rwlxkmmu X-Received: by 2002:a17:90a:8592:: with SMTP id m18mr38885129pjn.118.1571088023647; Mon, 14 Oct 2019 14:20:23 -0700 (PDT) Received: from fainelli-desktop.igp.broadcom.net ([192.19.223.252]) by smtp.gmail.com with ESMTPSA id c69sm1286528pga.69.2019.10.14.14.20.20 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 14 Oct 2019 14:20:21 -0700 (PDT) From: Florian Fainelli To: netdev@vger.kernel.org Cc: phil@raspberrypi.org, jonathan@raspberrypi.org, matthias.bgg@kernel.org, linux-rpi-kernel@lists.infradead.org, wahrenst@gmx.net, nsaenzjulienne@suse.de, Florian Fainelli , Doug Berger , "David S. Miller" , bcm-kernel-feedback-list@broadcom.com (open list:BROADCOM GENET ETHERNET DRIVER), linux-kernel@vger.kernel.org (open list) Subject: [PATCH net-next v2] net: bcmgenet: Generate a random MAC if none is valid Date: Mon, 14 Oct 2019 14:20:00 -0700 Message-Id: <20191014212000.27712-1-f.fainelli@gmail.com> X-Mailer: git-send-email 2.17.1 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Instead of having a hard failure and stopping the driver's probe routine, generate a random Ethernet MAC address to keep going. Signed-off-by: Florian Fainelli --- Changes in v2: - provide a message that a random MAC is used, the same message that bcmsysport.c uses drivers/net/ethernet/broadcom/genet/bcmgenet.c | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) diff --git a/drivers/net/ethernet/broadcom/genet/bcmgenet.c b/drivers/net/ethernet/broadcom/genet/bcmgenet.c index 12cb77ef1081..dd4e4f1dd384 100644 --- a/drivers/net/ethernet/broadcom/genet/bcmgenet.c +++ b/drivers/net/ethernet/broadcom/genet/bcmgenet.c @@ -3461,16 +3461,10 @@ static int bcmgenet_probe(struct platform_device *pdev) goto err; } - if (dn) { + if (dn) macaddr = of_get_mac_address(dn); - if (IS_ERR(macaddr)) { - dev_err(&pdev->dev, "can't find MAC address\n"); - err = -EINVAL; - goto err; - } - } else { + else macaddr = pd->mac_address; - } priv->base = devm_platform_ioremap_resource(pdev, 0); if (IS_ERR(priv->base)) { @@ -3482,7 +3476,12 @@ static int bcmgenet_probe(struct platform_device *pdev) SET_NETDEV_DEV(dev, &pdev->dev); dev_set_drvdata(&pdev->dev, dev); - ether_addr_copy(dev->dev_addr, macaddr); + if (IS_ERR_OR_NULL(macaddr) || !is_valid_ether_addr(macaddr)) { + dev_warn(&pdev->dev, "using random Ethernet MAC\n"); + eth_hw_addr_random(dev); + } else { + ether_addr_copy(dev->dev_addr, macaddr); + } dev->watchdog_timeo = 2 * HZ; dev->ethtool_ops = &bcmgenet_ethtool_ops; dev->netdev_ops = &bcmgenet_netdev_ops; -- 2.17.1