Received: by 2002:ac0:a5a6:0:0:0:0:0 with SMTP id m35-v6csp774287imm; Fri, 31 Aug 2018 12:56:10 -0700 (PDT) X-Google-Smtp-Source: ANB0VdYN9V0bPVMFcxTR4lnU3vWIJbjT5Msg30IM2YBa+5Fs/ymKQn5C6vt6QLGnPlrfHfS6xsUl X-Received: by 2002:a63:d20e:: with SMTP id a14-v6mr13591845pgg.226.1535745369970; Fri, 31 Aug 2018 12:56:09 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1535745369; cv=none; d=google.com; s=arc-20160816; b=aMdhh+RMeDzLUrjrjoXwRfGgHIkst6hsPGBlHgzxOUFFk7UuseJkF3dL9qfZSe8Emx AinqxnV6d+IrHgkUZ5PT16uzO0OhSsCccI/xCqE5nkS/ErWMwHJrvRLQC0ulT6r29k4D AE9SjVs03L3LCqud2Ph6sSnyoYnRLLt1KGsjT4RxNn5OrRpIQIAHpFyvbHVCUNcTtNAj HzW1w9wYRlf3qM8UrBQvn0N7ldN070bJYgNhIedoVOnSCVPIwDmvH7qb7kdzB1YMrAp3 u6VYLyp5LbQpKYRq/MuV9/2hT1IbidtPDkpZrdgeMyBMOSQv155appHNOjh+Z9jXnaDI ceIw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:dkim-signature:arc-authentication-results; bh=O2+RyoXwP1vFHEXqc+YrucjUc4oPR7efDkfHldZt5TM=; b=ST0DcJkLtMwj1sTg2QnjBH1k+77ikFk+OwbPFYcWn9z86KU5vrlxyTErrblJWTqs0f mLqmnsfdQHmSUai8iCfjto7xQUfW7L0hoINc7ne8hQZaJtMk+VsVeHuNQ1IPKqtPubvi 1/pe3zG+KWapq8Ho8Om+QDJ8xAMoJr5O/4BElLK4NABLJdJu7ywAeqJDFoTQ/9+rUAyd /maYvdDG8J67TaE37HyPKUi9tSPSTjrhhUL6AF6VRvH4GlN42w/wzJ9QLI47Y7dfGRa8 53Yn5nmrMGcLzNDQsd+1ls9iWWadpdOK524gzf3sHmv4JivetTAmvee/caodnANI9gE7 My3g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=lR9tMH7w; 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 j12-v6si1481609pgi.352.2018.08.31.12.55.53; Fri, 31 Aug 2018 12:56:09 -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=lR9tMH7w; 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 S1727282AbeIAADo (ORCPT + 99 others); Fri, 31 Aug 2018 20:03:44 -0400 Received: from mail-pl1-f193.google.com ([209.85.214.193]:36044 "EHLO mail-pl1-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726791AbeIAADo (ORCPT ); Fri, 31 Aug 2018 20:03:44 -0400 Received: by mail-pl1-f193.google.com with SMTP id e11-v6so5930516plb.3; Fri, 31 Aug 2018 12:54:43 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to:user-agent; bh=O2+RyoXwP1vFHEXqc+YrucjUc4oPR7efDkfHldZt5TM=; b=lR9tMH7wpDejLio/+R0E9VZCb6BceDPmAiL8C7ZBwYnDsPLOEkZ8YdVCO0xBBkdipi ckxh16xGx94g2qhF5oQbXhZVbqZIVrRy3hIs9ETp7V7Z2INxW7vvqnYUOymGstfQP7EI AjLC9ctJyXbYZgT0iMufVJsv3IxOHN6rAXfOGqz6UOzs4AWtqbUMe1Isfpy6oT31igtk IRnx3ceLnuXCPH9gyr86VDOJmvkXD5EaROIzAwcdf/k8xrIIZg9OQnLMh7x3bGlSuLLm 2bb/SVrf2RcAf25ce8M1LcentHObTio9MdPorAx5rPHdqYDyYV3WolhxJS/mlktnyiB0 I60w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to:user-agent; bh=O2+RyoXwP1vFHEXqc+YrucjUc4oPR7efDkfHldZt5TM=; b=ecl1BLBEFTJPmPRzEtOY/x2QaEukTwgi2OmUpzuuhpzZBYgEEHK+qXXNumKmnrcAGy +FSbWv3w90c5CJf7zWNigJLVanD9RY34011zhZ5PC3v1pr6pTZp34kDHHCRHEfxKDsjR k2qfCMPWA3qeTP18qru+p3ks+WrCxXr9wQ0U/TdZ5x1racKvPZtAhADKhcfaUg8Gn2GX Tr09D6Ks702wWE1HlrskHREsZORrVpSFgxeciRb5+F00kaAZ72LsHYYkwzjXuo4U3IOR rv71gsAMO4L3O9QzwBZ3yG14f+WPUxVojYsI4u3abxCYGa3UQAjvgPmfvWwV3BWX79gL 7Isw== X-Gm-Message-State: APzg51Df+nu5qlAeqxyzMyd7RRNl3zxPJqNcUsqUNwqNX6wslq6sVp4N Zw5VpO1DoC5exCu7HXoS2oE= X-Received: by 2002:a17:902:ac8f:: with SMTP id h15-v6mr16850921plr.161.1535745283381; Fri, 31 Aug 2018 12:54:43 -0700 (PDT) Received: from ban.mtv.corp.google.com ([2620:15c:202:1:299d:6b87:5478:d28a]) by smtp.gmail.com with ESMTPSA id u13-v6sm14094929pfn.59.2018.08.31.12.54.41 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Fri, 31 Aug 2018 12:54:42 -0700 (PDT) Date: Fri, 31 Aug 2018 12:54:39 -0700 From: Brian Norris To: Bartosz Golaszewski Cc: Jonathan Corbet , Sekhar Nori , Kevin Hilman , Russell King , Arnd Bergmann , Greg Kroah-Hartman , David Woodhouse , Boris Brezillon , Marek Vasut , Richard Weinberger , Grygorii Strashko , "David S . Miller" , Srinivas Kandagatla , Naren , Mauro Carvalho Chehab , Andrew Morton , Lukas Wunner , Dan Carpenter , Florian Fainelli , Ivan Khoronzhuk , Sven Van Asbroeck , Paolo Abeni , Alban Bedel , Rob Herring , David Lechner , Andrew Lunn , linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-i2c@vger.kernel.org, linux-mtd@lists.infradead.org, linux-omap@vger.kernel.org, netdev@vger.kernel.org, Bartosz Golaszewski , briannorris@chromium.org Subject: Re: [PATCH v2 15/29] net: split eth_platform_get_mac_address() into subroutines Message-ID: <20180831195439.GB62862@ban.mtv.corp.google.com> References: <20180810080526.27207-1-brgl@bgdev.pl> <20180810080526.27207-16-brgl@bgdev.pl> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20180810080526.27207-16-brgl@bgdev.pl> User-Agent: Mutt/1.10.1+48 (1f3a9df87d11) (2018-07-22) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi, I responded to the cover letter, but I'll put some notes here too. On Fri, Aug 10, 2018 at 10:05:12AM +0200, Bartosz Golaszewski wrote: > From: Bartosz Golaszewski > > We want do add more sources from which to read the MAC address. In > order to avoid bloating this function too much, start by splitting it > into subroutines, each of which takes care of reading the MAC from > one source. > > Signed-off-by: Bartosz Golaszewski > --- > net/ethernet/eth.c | 44 ++++++++++++++++++++++++++++++++++++-------- > 1 file changed, 36 insertions(+), 8 deletions(-) > > diff --git a/net/ethernet/eth.c b/net/ethernet/eth.c > index 7f08105402c8..d01dd55de037 100644 > --- a/net/ethernet/eth.c > +++ b/net/ethernet/eth.c > @@ -525,22 +525,50 @@ unsigned char * __weak arch_get_platform_mac_address(void) > return NULL; > } > > -int eth_platform_get_mac_address(struct device *dev, u8 *mac_addr) > +static int mac_address_from_of(struct device *dev, u8 *mac_addr) > { > const unsigned char *addr; > - struct device_node *dp; > + struct device_node *np; > > - dp = dev->of_node; > - addr = NULL; > - if (dp) > - addr = of_get_mac_address(dp); > - if (!addr) > - addr = arch_get_platform_mac_address(); > + np = dev->of_node; > + if (!np) > + return -ENODEV; > > + addr = of_get_mac_address(np); > if (!addr) > return -ENODEV; > > + if (!addr || !is_valid_ether_addr(addr)) > + return -ENODEV; > + > ether_addr_copy(mac_addr, addr); > return 0; > } > + > +static int mac_address_from_arch(u8 *mac_addr) > +{ > + const unsigned char *addr; > + > + addr = arch_get_platform_mac_address(); > + if (!addr || !is_valid_ether_addr(addr)) > + return -ENODEV; > + > + ether_addr_copy(mac_addr, addr); > + return 0; > +} > + > +int eth_platform_get_mac_address(struct device *dev, u8 *mac_addr) > +{ > + int rv; > + > + rv = mac_address_from_of(dev, mac_addr); This could just be replaced with device_get_mac_address(). Then you should be extending either fwnode_get_device_mac_address() or device_get_mac_addres() in the next patch, not eth_platform_get_mac_address(). Regards, Brian > + if (!rv) > + return 0; > + > + rv = mac_address_from_arch(mac_addr); > + if (!rv) > + return 0; > + > + return -ENODEV; > +} > EXPORT_SYMBOL(eth_platform_get_mac_address); > -- > 2.18.0 >