From patchwork Mon Sep 28 16:51:51 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Liviu Dudau X-Patchwork-Id: 54207 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-la0-f72.google.com (mail-la0-f72.google.com [209.85.215.72]) by patches.linaro.org (Postfix) with ESMTPS id 91DAD22B1E for ; Mon, 28 Sep 2015 16:52:13 +0000 (UTC) Received: by laer8 with SMTP id r8sf26277020lae.2 for ; Mon, 28 Sep 2015 09:52:12 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:delivered-to:from:to:cc:subject :date:message-id:sender:precedence:list-id:x-original-sender :x-original-authentication-results:mailing-list:list-post:list-help :list-archive:list-unsubscribe; bh=hj0g/FB9JxXMAFJTV5fhfEPqwM5C2/9JZ4GeJiB5jy8=; b=aAYXVct7YJYlITWqYFO2KbmGHm8h6LQP0IZz8PVfk1zBK8CVUihTYllD3kl0mdu1m7 TbLIzLUgFBwZfIk2fWYEkvIZydgrjAiWh1FUe9hthMhikI/RxJNRANpKGoaXmBXioUn3 AOhu+lkX675OT9M5pdmLFFn7eYzIugXb0FR8iKLsezE95wUUxz3rKleN2OJLdeheWyUv k7BinVcOl+oes/YwG2ZJ78U4yl4VnMpbtiJjfRjVBIXJ1RVct9liCLVXbi/qKsok6ZVC JT3gQGIKacd0S2RsvWL9XMyx9aedH7gvFfCErnIORoQIsJsrsjKcxW3a2PVP4kTkDlD9 il/w== X-Gm-Message-State: ALoCoQmjRvmoczZbUlUKbx/5mlEJVDgd7+OzxDZzbRwzXHuGGAqWfQHYmbyW6jUntJYVvB0hIx2R X-Received: by 10.25.149.203 with SMTP id x194mr83696lfd.6.1443459132154; Mon, 28 Sep 2015 09:52:12 -0700 (PDT) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.25.16.92 with SMTP id f89ls321466lfi.25.gmail; Mon, 28 Sep 2015 09:52:11 -0700 (PDT) X-Received: by 10.152.5.233 with SMTP id v9mr5931304lav.65.1443459131981; Mon, 28 Sep 2015 09:52:11 -0700 (PDT) Received: from mail-la0-f44.google.com (mail-la0-f44.google.com. [209.85.215.44]) by mx.google.com with ESMTPS id pq6si8678777lbb.61.2015.09.28.09.52.11 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 28 Sep 2015 09:52:11 -0700 (PDT) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.215.44 as permitted sender) client-ip=209.85.215.44; Received: by laer8 with SMTP id r8so38262613lae.2 for ; Mon, 28 Sep 2015 09:52:11 -0700 (PDT) X-Received: by 10.112.139.201 with SMTP id ra9mr895960lbb.29.1443459131340; Mon, 28 Sep 2015 09:52:11 -0700 (PDT) X-Forwarded-To: patchwork-forward@linaro.org X-Forwarded-For: patch@linaro.org patchwork-forward@linaro.org Delivered-To: patch@linaro.org Received: by 10.112.59.35 with SMTP id w3csp1658119lbq; Mon, 28 Sep 2015 09:52:10 -0700 (PDT) X-Received: by 10.107.15.170 with SMTP id 42mr23975901iop.137.1443459130135; Mon, 28 Sep 2015 09:52:10 -0700 (PDT) Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id u97si13098100ioi.41.2015.09.28.09.52.09; Mon, 28 Sep 2015 09:52:10 -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; Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S934394AbbI1QwI (ORCPT + 30 others); Mon, 28 Sep 2015 12:52:08 -0400 Received: from fw-tnat.cambridge.arm.com ([217.140.96.140]:54906 "EHLO cam-smtp0.cambridge.arm.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S934088AbbI1QwE (ORCPT ); Mon, 28 Sep 2015 12:52:04 -0400 Received: from e106497-lin.cambridge.arm.com (e106497-lin.cambridge.arm.com [10.2.131.158]) by cam-smtp0.cambridge.arm.com (8.13.8/8.13.8) with ESMTP id t8SGppB0021025; Mon, 28 Sep 2015 17:51:51 +0100 From: Liviu Dudau To: Stephen Hemminger , Mirko Lindner , Florian Fainelli , Ryan Harkin , Sergei Shtylyov Cc: netdev , lkml , David Miller Subject: RESEND: [PATCH v3 net-next] sky2: use random address if EEPROM is bad Date: Mon, 28 Sep 2015 17:51:51 +0100 Message-Id: <1443459111-15595-1-git-send-email-Liviu.Dudau@arm.com> X-Mailer: git-send-email 2.5.1 Sender: linux-kernel-owner@vger.kernel.org Precedence: list List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Removed-Original-Auth: Dkim didn't pass. X-Original-Sender: liviu.dudau@arm.com X-Original-Authentication-Results: mx.google.com; spf=pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.215.44 as permitted sender) smtp.mailfrom=patch+caf_=patchwork-forward=linaro.org@linaro.org Mailing-list: list patchwork-forward@linaro.org; contact patchwork-forward+owners@linaro.org X-Google-Group-Id: 836684582541 List-Post: , List-Help: , List-Archive: List-Unsubscribe: , On some embedded systems the EEPROM does not contain a valid MAC address. In that case it is better to fallback to a generated mac address and let init scripts fix the value later. Reported-by: Liviu Dudau Signed-off-by: Stephen Hemminger [Changed handcoded setup to use eth_hw_addr_random() and to save new address into HW] Signed-off-by: Liviu Dudau --- drivers/net/ethernet/marvell/sky2.c | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/drivers/net/ethernet/marvell/sky2.c b/drivers/net/ethernet/marvell/sky2.c index d9f4498..5606a04 100644 --- a/drivers/net/ethernet/marvell/sky2.c +++ b/drivers/net/ethernet/marvell/sky2.c @@ -4819,6 +4819,18 @@ static struct net_device *sky2_init_netdev(struct sky2_hw *hw, unsigned port, memcpy_fromio(dev->dev_addr, hw->regs + B2_MAC_1 + port * 8, ETH_ALEN); + /* if the address is invalid, use a random value */ + if (!is_valid_ether_addr(dev->dev_addr)) { + struct sockaddr sa = { AF_UNSPEC }; + + netdev_warn(dev, + "Invalid MAC address, defaulting to random\n"); + eth_hw_addr_random(dev); + memcpy(sa.sa_data, dev->dev_addr, ETH_ALEN); + if (sky2_set_mac_address(dev, &sa)) + netdev_warn(dev, "Failed to set MAC address.\n"); + } + return dev; }