Received: by 2002:a5b:505:0:0:0:0:0 with SMTP id o5csp1549862ybp; Fri, 11 Oct 2019 16:23:27 -0700 (PDT) X-Google-Smtp-Source: APXvYqxL6m+xCjRoKR1PvNgGR6mA784gSCnInVHXguF6+6tA4Uxm+HyB3Cqzfhw1EPKfj6IHyo1z X-Received: by 2002:aa7:ca59:: with SMTP id j25mr16091784edt.78.1570836207618; Fri, 11 Oct 2019 16:23:27 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1570836207; cv=none; d=google.com; s=arc-20160816; b=Jj/dcMmelWTQGE0YMrX/TMdd/ATH0XTTzfnFqU6oCuQtQIeUpuQkmejuCk9eEycofN 5etEnyhnHH198OHX9iJebGGPpPWvyMvyo8W+QKAnqm/DC1CNOYxq/u8EDwILL3+uB8o+ GszEdTjbGZsEG2bo53qUfOxExG02ydTYenEhmhRgRt+zDCeC8r/D7m2ztb6kX4moc0q2 80+KEzXD7HpKYGd331mDwCfEX2bpfYurDiZR+APHvSRUqCVbx3IzZYchIyRfdMriH7tL p/MJfh4IiXvWUyKFZ0Y92zNWP2ZY2U3Iyth2+KSZ64oYFzR2GraeA9KOsylU/rI1FtJt KWEQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-language :content-transfer-encoding:in-reply-to:mime-version:user-agent:date :message-id:from:references:cc:to:subject:dkim-signature; bh=T5gcsIEKN7fGZ7H7m6feYOoRGQFlbeIl7NkVUQv4he4=; b=ishHFkEosW89qf75B0shWQ1dRR9Qp6FU7AO27pL5KFnQq6NgCeYb0XVLjIzFLe7REy ty4pvquoZiT7MSBJfw5mKJ2gmzfH3h3htkBUONrtr7ouTWZah1H5lvolAJQxYZTkVYaG jd9Fl/PIcAGBe5FFR1lIV46KoAvRsW5OMyOqJlQS7jgtWOv5i8F6uwbQR8DyiWqvYdG/ KTSaWvPHl/dJklXPaTgyk+SIRVUw97q9yJ9OXzVx5KhKWKuqvi2pvMct+UAdmHw8CWRG UytdI/JRqktKR6HqSSJ5boAX7jxMJyoB3ls5xxxFKrD8ogP4Oa9aCIjj7nhuueZofY0d 3IQg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@broadcom.com header.s=google header.b=Ksu7qQFH; 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=QUARANTINE sp=QUARANTINE dis=NONE) header.from=broadcom.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id l15si6332456ejz.74.2019.10.11.16.23.03; Fri, 11 Oct 2019 16:23:27 -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=@broadcom.com header.s=google header.b=Ksu7qQFH; 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=QUARANTINE sp=QUARANTINE dis=NONE) header.from=broadcom.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726891AbfJKXWd (ORCPT + 99 others); Fri, 11 Oct 2019 19:22:33 -0400 Received: from mail-pf1-f196.google.com ([209.85.210.196]:41969 "EHLO mail-pf1-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726345AbfJKXWc (ORCPT ); Fri, 11 Oct 2019 19:22:32 -0400 Received: by mail-pf1-f196.google.com with SMTP id q7so6928109pfh.8 for ; Fri, 11 Oct 2019 16:22:32 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=broadcom.com; s=google; h=subject:to:cc:references:from:message-id:date:user-agent :mime-version:in-reply-to:content-transfer-encoding:content-language; bh=T5gcsIEKN7fGZ7H7m6feYOoRGQFlbeIl7NkVUQv4he4=; b=Ksu7qQFHWBMhWinL77/TQbc+vSKoTq2TIhAH2e2tUs3ppJnmql4AfILW2RwbAubDOl chO4usBGOBBH8HDljDNj7ouDLAsMHLaYcN5/ags2Q9i6Is4L5wltQxZNW2yKsGj9HTDB EesFgnTZP8oj1M1CPdB/6+vfgQ8jka2FPcm6A= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:to:cc:references:from:message-id:date :user-agent:mime-version:in-reply-to:content-transfer-encoding :content-language; bh=T5gcsIEKN7fGZ7H7m6feYOoRGQFlbeIl7NkVUQv4he4=; b=c+ca+5wdAwS5rW3jWmg+Ls5kcGZD2kJSFCLQ7qWGVX3nDU70KJN90/BhwJaUdPpOy+ r7AgizMJkKPK4UOQnlbYO8um/2kNH2ZnsLYxZiQQaFqXzKPezum0j8PIRTatnxc+IDzC lr9ft5hgMsC93qUePjO7x/vZiac/0JDfhIi9rAG6duF/EVF0dR1aofiyhQ7HP/gsg2TS RHVK8g8idiz2Jj7qYOGnAD/aD/oEU0yj5P3e41q6IWlT4DPTiRhaS8bdOI5I70Mu0fAh LC/0vuYWL8kpVZ/PuanGQhPgpMlnKbBE+NVFOtD5CtFwNr1jLuiVeMiiiGGvU7WFavgq BH9Q== X-Gm-Message-State: APjAAAXE1A9LF7SKj76+fQHl5hOBElqslVgQBUt5PmJO+vgJfWsnFweI cv+jSs1PsOUtRUQ44jWhJMTuzDnL7ecq644v3bGMJw4MuCPXWiT16zlce9ZGckoPs7K+acEESER LegUpOXGuZQlQaB4zNq4KTTVpgqPUCDa7D+yNqhDhofyExpgOIMJkM5HFV8d/IWl7omWBj5WJzN rdHmtCR7ho X-Received: by 2002:a62:ac02:: with SMTP id v2mr18619372pfe.97.1570836151751; Fri, 11 Oct 2019 16:22:31 -0700 (PDT) Received: from [10.136.13.65] ([192.19.228.250]) by smtp.gmail.com with ESMTPSA id z13sm12486111pfq.121.2019.10.11.16.22.29 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 11 Oct 2019 16:22:31 -0700 (PDT) Subject: Re: [PATCH net-next] net: bcmgenet: Generate a random MAC if none is valid To: Florian Fainelli , 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, Doug Berger , "David S. Miller" , "open list:BROADCOM GENET ETHERNET DRIVER" , open list References: <20191011231915.9347-1-f.fainelli@gmail.com> From: Scott Branden Message-ID: <7fe7796f-c98e-3c7c-3683-505a0e643eda@broadcom.com> Date: Fri, 11 Oct 2019 16:22:28 -0700 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.9.0 MIME-Version: 1.0 In-Reply-To: <20191011231915.9347-1-f.fainelli@gmail.com> Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit Content-Language: en-US Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 2019-10-11 4:19 p.m., Florian Fainelli wrote: > 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 > --- > drivers/net/ethernet/broadcom/genet/bcmgenet.c | 15 ++++++--------- > 1 file changed, 6 insertions(+), 9 deletions(-) > > diff --git a/drivers/net/ethernet/broadcom/genet/bcmgenet.c b/drivers/net/ethernet/broadcom/genet/bcmgenet.c > index 12cb77ef1081..5c20829ffa0f 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"); We shouldn't hide the error that the MAC address wasn't found. We should continue to print some kind of error as generating a mac address is a stop-gap measure and a proper MAC address should be used for the board. > - 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,10 @@ 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)) > + 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;