Received: by 10.223.176.46 with SMTP id f43csp3515070wra; Mon, 22 Jan 2018 16:04:18 -0800 (PST) X-Google-Smtp-Source: AH8x225S6a6cNQ50yh1072ShEYpbzDbShlUD5O5IaqB1Kqd7EYwTgs2ox6AWwC04Mn4CuYSk+BNZ X-Received: by 10.107.38.21 with SMTP id m21mr1112318iom.69.1516665858334; Mon, 22 Jan 2018 16:04:18 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1516665858; cv=none; d=google.com; s=arc-20160816; b=elSgXEbnKnK5oyA8TTKLULtFlf1W8JX3wzsYf+GG4/XucFCY8fR+I6awBhDi0HCPAc 0Vo53jHZbQ/9cEuu9Ln23clz1Uur90J3GIwyinfPGJa0sBuZMBUhASzO788UMy5JvGi4 oPdgxqSldH7OTMhSO+gT4aab4bunnODm7gPNsTe/c7YkhEQ3zgtjY8JN5bmIiTQyyg9h JW6ncGz/pZLwYs9DZaYe+Komu0naSLGuCkesU51LPgy60mZE6GSZ4r7AyU3jk2nRGGvK hoxg4Y3wr+NCr+ZwmFjP9c3V94XSoSwpi0RId+EuNVPfhA6y9JWxWnOKby4AqwjfwVG5 HHbw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :references:in-reply-to:mime-version:dkim-signature :arc-authentication-results; bh=IpqUsaER3JCDutpJFXmC/QI6UJ+NDOQA9vPx73vf3Fc=; b=o6PzeCtedLmcOHRzdWKkL6SqVWX+OX4fStpE0u2DBPBPfkb3y2gi8ZNB39vKB5dSc/ aRefDUccFeUyWw5hammqwx8wXWCh3d83v67uQGIKdHmq9LdgvtOLDkJxfk9/kWfjgYYB JWd4U29UF91AJOq4JRZVmwsVwH7pseC/ezIW9kmTMjSNzbyGeDvv9MIsw7Pq1E/TdbH/ 6DddOGopxcTZLSZ8pBsMwX0DivMf74685KSrnkQdpgs8JRHR27abH10Bl/ZBKcYEIox7 RAE79srWy9K5mYK7SA+z5Xz+6MMFEj6XRwFHYSirp7v5orbM2VOQW4hEJTRgAQZ/c9Ns pxSQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@gmail.com header.s=20161025 header.b=bB0UrIFo; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id x63si6928642itf.48.2018.01.22.16.04.05; Mon, 22 Jan 2018 16:04:18 -0800 (PST) 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=fail header.i=@gmail.com header.s=20161025 header.b=bB0UrIFo; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751288AbeAWADn (ORCPT + 99 others); Mon, 22 Jan 2018 19:03:43 -0500 Received: from mail-oi0-f66.google.com ([209.85.218.66]:41670 "EHLO mail-oi0-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751059AbeAWADk (ORCPT ); Mon, 22 Jan 2018 19:03:40 -0500 Received: by mail-oi0-f66.google.com with SMTP id m83so4806236oik.8; Mon, 22 Jan 2018 16:03:40 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:sender:in-reply-to:references:from:date:message-id :subject:to:cc; bh=IpqUsaER3JCDutpJFXmC/QI6UJ+NDOQA9vPx73vf3Fc=; b=bB0UrIFoXQ3B+QFuJhCYHXomGlDVlT/MWGDz8ZO0idWg9/ZqpxG7gTfGJIDNOTdiw5 oMJ9k9tm1zc3gtLKMX/NkfPi/e9nsb1sJi9DtHoKNANNEhborIClvGTkJIkc4+AIfaWI xlHYaOggHpOqheZS+hTQ6if2E6RNAAL2b+nlEAbic5g0EqwL49ZvhuIeFJqnwx36nGL/ t4Tqkutj7Vdf0uZd+9/BfQIF9NU0ErZliez2130mSjCl9Od4b7ndJEvwkeYKvQHZ1Dju oCl71ifHA8Ofl37L1m0OHcWM1jqJdL8GY1pZnBfvB2N4cmYH91XRBPmcs2mQSS481l05 KNYQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:sender:in-reply-to:references:from :date:message-id:subject:to:cc; bh=IpqUsaER3JCDutpJFXmC/QI6UJ+NDOQA9vPx73vf3Fc=; b=sGm2RggotyeiTRj/og2Ku8wd8li5d0rtQSQGpeG+s3GN55z+0wMVX84TRkNXP3BUnR VbFNeP/cH2FqWPncyUCSvlebjVxtw3cIwIm44tFXUhuSH1vHNLxyVcE/3Vt37jwdSnG0 ebU0pU5SK3QrIEWTXMQyDnPCdTYY/WiD2GN9LzdvxWymDciirD2TP+EcvpKbfKkJeC9W R5gs2tvvT0WQ8+JRMEmwb22Wn0Z2o8HLNce8zqyssn4C+N3b8zRtS7+g/ye0MEUmXscN oSrB7jzcXmhP8ayCDBLk1ig3tDVDOSF4aBsIBfgCmOpK8wwqWebaFDGMPoIX+MBIaJS2 /83w== X-Gm-Message-State: AKwxytdHzRhqXHoCvg4uNd5smhezjRYj8449L0ZhaeBE2y9kLXd6o4Cr XTAsb3eISdzP8XcSDD0IQiAkv9Svwx3AmNzs+1Y= X-Received: by 10.202.190.70 with SMTP id o67mr4837385oif.257.1516665820026; Mon, 22 Jan 2018 16:03:40 -0800 (PST) MIME-Version: 1.0 Received: by 10.157.11.88 with HTTP; Mon, 22 Jan 2018 16:03:39 -0800 (PST) In-Reply-To: <1516278704-17141-2-git-send-email-mw@semihalf.com> References: <1516278704-17141-1-git-send-email-mw@semihalf.com> <1516278704-17141-2-git-send-email-mw@semihalf.com> From: "Rafael J. Wysocki" Date: Tue, 23 Jan 2018 01:03:39 +0100 X-Google-Sender-Auth: t8UAQ5MFAXocQ7tW-sSA3Yj9O6c Message-ID: Subject: Re: [net-next: PATCH v4 1/7] device property: Introduce fwnode_get_mac_address() To: Marcin Wojtas Cc: Linux Kernel Mailing List , linux-arm-kernel@lists.infradead.org, netdev@vger.kernel.org, ACPI Devel Maling List , Graeme Gregory , David Miller , Russell King - ARM Linux , Rafael Wysocki , Andrew Lunn , Florian Fainelli , Antoine Tenart , Thomas Petazzoni , Gregory Clement , stefanc@marvell.com, Nadav Haklai , Neta Zur Hershkovits , Ard Biesheuvel , jaz@semihalf.com, Tomasz Nowicki Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, Jan 18, 2018 at 1:31 PM, Marcin Wojtas wrote: > Until now there were two almost identical functions for > obtaining MAC address - of_get_mac_address() and, more generic, > device_get_mac_address(). However it is not uncommon, > that the network interface is represented as a child > of the actual controller, hence it is not associated > directly to any struct device, required by the latter > routine. > > This commit allows for getting the MAC address for > children nodes in the ACPI world by introducing a new function - > fwnode_get_mac_address(). This commit also changes > device_get_mac_address() routine to be its wrapper, in order > to prevent unnecessary duplication. > > Signed-off-by: Marcin Wojtas > Acked-by: Rafael J. Wysocki > --- > drivers/base/property.c | 28 ++++++++++++++------ > include/linux/property.h | 2 ++ > 2 files changed, 22 insertions(+), 8 deletions(-) > > diff --git a/drivers/base/property.c b/drivers/base/property.c > index 851b1b6..f261d1a 100644 > --- a/drivers/base/property.c > +++ b/drivers/base/property.c > @@ -1153,11 +1153,11 @@ int device_get_phy_mode(struct device *dev) > } > EXPORT_SYMBOL_GPL(device_get_phy_mode); > > -static void *device_get_mac_addr(struct device *dev, > +static void *fwnode_get_mac_addr(struct fwnode_handle *fwnode, > const char *name, char *addr, > int alen) > { > - int ret = device_property_read_u8_array(dev, name, addr, alen); > + int ret = fwnode_property_read_u8_array(fwnode, name, addr, alen); > > if (ret == 0 && alen == ETH_ALEN && is_valid_ether_addr(addr)) > return addr; > @@ -1165,8 +1165,8 @@ static void *device_get_mac_addr(struct device *dev, > } > > /** > - * device_get_mac_address - Get the MAC for a given device > - * @dev: Pointer to the device > + * fwnode_get_mac_address - Get the MAC from the firmware node > + * @fwnode: Pointer to the firmware node > * @addr: Address of buffer to store the MAC in > * @alen: Length of the buffer pointed to by addr, should be ETH_ALEN > * > @@ -1187,19 +1187,31 @@ static void *device_get_mac_addr(struct device *dev, > * In this case, the real MAC is in 'local-mac-address', and 'mac-address' > * exists but is all zeros. > */ > -void *device_get_mac_address(struct device *dev, char *addr, int alen) > +void *fwnode_get_mac_address(struct fwnode_handle *fwnode, char *addr, int alen) > { > char *res; > > - res = device_get_mac_addr(dev, "mac-address", addr, alen); > + res = fwnode_get_mac_addr(fwnode, "mac-address", addr, alen); > if (res) > return res; > > - res = device_get_mac_addr(dev, "local-mac-address", addr, alen); > + res = fwnode_get_mac_addr(fwnode, "local-mac-address", addr, alen); > if (res) > return res; > > - return device_get_mac_addr(dev, "address", addr, alen); > + return fwnode_get_mac_addr(fwnode, "address", addr, alen); > +} > +EXPORT_SYMBOL(fwnode_get_mac_address); That should be EXPORT_SYMBOL_GPL(). I have overlooked that previously, sorry about that. > + > +/** > + * device_get_mac_address - Get the MAC for a given device > + * @dev: Pointer to the device > + * @addr: Address of buffer to store the MAC in > + * @alen: Length of the buffer pointed to by addr, should be ETH_ALEN > + */ > +void *device_get_mac_address(struct device *dev, char *addr, int alen) > +{ > + return fwnode_get_mac_address(dev_fwnode(dev), addr, alen); > } > EXPORT_SYMBOL(device_get_mac_address); Same here. Generally speaking, you should use EXPORT_SYMBOL_GPL() everywhere unless there's a specific reason for not doing that in which cases that specific reason has to be clearly spelled out at least in the changelog of the patch, but really better in a code comment. > > diff --git a/include/linux/property.h b/include/linux/property.h > index f6189a3..35620e0 100644 > --- a/include/linux/property.h > +++ b/include/linux/property.h > @@ -279,6 +279,8 @@ int device_get_phy_mode(struct device *dev); > > void *device_get_mac_address(struct device *dev, char *addr, int alen); > > +void *fwnode_get_mac_address(struct fwnode_handle *fwnode, > + char *addr, int alen); > struct fwnode_handle *fwnode_graph_get_next_endpoint( > const struct fwnode_handle *fwnode, struct fwnode_handle *prev); > struct fwnode_handle * > --