Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1946635AbbHHAcr (ORCPT ); Fri, 7 Aug 2015 20:32:47 -0400 Received: from mail-wi0-f182.google.com ([209.85.212.182]:35832 "EHLO mail-wi0-f182.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1946549AbbHHAco (ORCPT ); Fri, 7 Aug 2015 20:32:44 -0400 MIME-Version: 1.0 In-Reply-To: <55C4F597.50103@caviumnetworks.com> References: <1438907590-29649-1-git-send-email-ddaney.cavm@gmail.com> <1438907590-29649-3-git-send-email-ddaney.cavm@gmail.com> <20150807145414.GA5468@xora-haswell.xora.org.uk> <55C4F597.50103@caviumnetworks.com> Date: Sat, 8 Aug 2015 02:32:42 +0200 X-Google-Sender-Auth: UMGyuIkjP4sFFoYU17kDXIOgN7g Message-ID: Subject: Re: [PATCH 2/2] net, thunder, bgx: Add support for ACPI binding. From: "Rafael J. Wysocki" To: David Daney Cc: Graeme Gregory , David Daney , netdev@vger.kernel.org, "David S. Miller" , Linux Kernel Mailing List , linux-mips@linux-mips.org, Robert Richter , Tomasz Nowicki , Sunil Goutham , "linux-arm-kernel@lists.infradead.org" , ACPI Devel Maling List , David Daney Content-Type: text/plain; charset=UTF-8 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 3456 Lines: 87 Hi David, On Fri, Aug 7, 2015 at 8:14 PM, David Daney wrote: > On 08/07/2015 07:54 AM, Graeme Gregory wrote: >> >> On Thu, Aug 06, 2015 at 05:33:10PM -0700, David Daney wrote: >>> >>> From: David Daney >>> >>> Find out which PHYs belong to which BGX instance in the ACPI way. >>> >>> Set the MAC address of the device as provided by ACPI tables. This is >>> similar to the implementation for devicetree in >>> of_get_mac_address(). The table is searched for the device property >>> entries "mac-address", "local-mac-address" and "address" in that >>> order. The address is provided in a u64 variable and must contain a >>> valid 6 bytes-len mac addr. >>> >>> Based on code from: Narinder Dhillon >>> Tomasz Nowicki >>> Robert Richter >>> >>> Signed-off-by: Tomasz Nowicki >>> Signed-off-by: Robert Richter >>> Signed-off-by: David Daney >>> --- >>> drivers/net/ethernet/cavium/thunder/thunder_bgx.c | 137 >>> +++++++++++++++++++++- >>> 1 file changed, 135 insertions(+), 2 deletions(-) >>> >>> diff --git a/drivers/net/ethernet/cavium/thunder/thunder_bgx.c >>> b/drivers/net/ethernet/cavium/thunder/thunder_bgx.c >>> index 615b2af..2056583 100644 >>> --- a/drivers/net/ethernet/cavium/thunder/thunder_bgx.c >>> +++ b/drivers/net/ethernet/cavium/thunder/thunder_bgx.c > > [...] >>> >>> + >>> +static int acpi_get_mac_address(struct acpi_device *adev, u8 *dst) >>> +{ >>> + const union acpi_object *prop; >>> + u64 mac_val; >>> + u8 mac[ETH_ALEN]; >>> + int i, j; >>> + int ret; >>> + >>> + for (i = 0; i < ARRAY_SIZE(addr_propnames); i++) { >>> + ret = acpi_dev_get_property(adev, addr_propnames[i], >>> + ACPI_TYPE_INTEGER, &prop); >> >> >> Shouldn't this be trying to use device_property_read_* API and making >> the DT/ACPI path the same where possible? >> > > Ideally, something like you suggest would be possible. However, there are a > couple of problems trying to do it in the kernel as it exists today: > > 1) There is no 'struct device *' here, so device_property_read_* is not > applicable. > > 2) There is no standard ACPI binding for MAC addresses, so it is impossible > to create a hypothetical fw_get_mac_address(), which would be analogous to > of_get_mac_address(). > > Other e-mail threads have suggested that the path to an elegant solution is > to inter-mix a bunch of calls to acpi_dev_get_property*() and > fwnode_property_read*() as to use these more generic fwnode_property_read*() > functions whereever possible. I rejected this approach as it seems cleaner > to me to consistently use a single set of APIs. Actually, that wasn't my intention. I wanted to say that once you'd got an ACPI device pointer (struct acpi_device), you could easly convert it to a struct fwnode_handle pointer and operate that going forward when accessing properties. That at least would help with the properties that do not differ between DT and ACPI. Thanks, Rafael -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/