Received: by 2002:a05:6a10:22f:0:0:0:0 with SMTP id 15csp550259pxk; Thu, 1 Oct 2020 08:41:09 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzEPSGslwVl5EOiTMUjfI3LEjHBbB/4XgGguF+5RY2WSMGk0aNxLdEbjMxxwDXY9b9eytFD X-Received: by 2002:a17:907:20d0:: with SMTP id qq16mr8250914ejb.65.1601566869128; Thu, 01 Oct 2020 08:41:09 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1601566869; cv=none; d=google.com; s=arc-20160816; b=A7Kj/boVNpUQMn5pFRcPcUq1/MRze08ky+GgB7pDfywQX+pDkNVZ7noYQtGwP/zKKr d/XTIdhlHy2V6RdZJtywnWeW0H0MzZ+FqCjw7wL+9ScZaoXTdKYq1IV29Vs1f8InRqlg UwWfQ+mciT6h8aAC9QAn2GTGwja+Hvg4PtxTaww2Y2VGsg2nqiFkMW3kc7RpVybFxB3d 54EfrY3zOUW/i87I0Awceb3CxHvsOn4mdEuPtJtSyR8CiX8S5hBv6veJO4dxMiAbG1Zi cH6EkOUNTcssXMtUXFg/7Q80CH3QOs8r7CSp8BNIjQ6dqeR+qhrjWdtf7042y4c+GVQo klSg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:subject:message-id:date:from:in-reply-to :references:mime-version:dkim-signature; bh=Cg3wbDR04xmJHB+TGPRHBG7JiU528nISGUy/wwYR0YA=; b=rKmratx6o/uzU5aZYMmYuLylevfI8ozip3Uj3IgKChKcGPLRi18Op1S7++W+S7O9DV T+cLtVhQJbHojsEEDYOUJA70aXtw+KmjUzpy15jB9rg4c9E9iV1/ksM9HET5JQ00zHtV InxAgXLbDQ1NqF/N1Y+0fUxMNQew+0kSHBk0cGJIGLz8qYT+Js5wFvOgBr/FrFdLxKec iZSfDLAoMnXgRXfYcWSdjLH1jEVIR/MoXtMU2WZgnFhi4UPHO5l7DUvQmzyRqWFyoEKs h6tNjoWJAJ6LSRE11mWV4EZgi8NJ6Ww3erKixwBmR0S/0nokUQ4+aA6mc9qvm6apah3s wzNA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=T2sIPs+p; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 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. [23.128.96.18]) by mx.google.com with ESMTP id u19si1826457eds.502.2020.10.01.08.40.44; Thu, 01 Oct 2020 08:41:09 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=T2sIPs+p; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 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 S1732721AbgJAPgf (ORCPT + 99 others); Thu, 1 Oct 2020 11:36:35 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40020 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1732417AbgJAPgZ (ORCPT ); Thu, 1 Oct 2020 11:36:25 -0400 Received: from mail-pf1-x441.google.com (mail-pf1-x441.google.com [IPv6:2607:f8b0:4864:20::441]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3BC08C0613D0; Thu, 1 Oct 2020 08:36:25 -0700 (PDT) Received: by mail-pf1-x441.google.com with SMTP id d6so4847171pfn.9; Thu, 01 Oct 2020 08:36:25 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=Cg3wbDR04xmJHB+TGPRHBG7JiU528nISGUy/wwYR0YA=; b=T2sIPs+pWd7e9fuAwLNDnWSPDZ6NS1gAGLWZ13W5+J9jcgYuD8w0XVIL+tqDm3r6fi HXytKiICTlyDUrvgFtgXREM/fAUvMkkcKMLxOrZHhD+4sBL74LEuw1k8K3gaVxBsjC1z LFLV+gbwHfU3OdOw8rW/Bvyt0zIyM0NfXMiqLy8aIJ4ZELGfVLOZk1ht9AQLKwxwugKi P927bAHPcG9/f9McY+3gNLck261EN1PBOyhuGPlngi2Cimp1vocgT+300xLteG3t37vu pKytFTgsijEdAm+6usLDTbV9k2UOrPkqY699buhiNKkTQBGpnWhBfylkEOj+PEOpLpaA ABKQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=Cg3wbDR04xmJHB+TGPRHBG7JiU528nISGUy/wwYR0YA=; b=r8n2f2buyadO1kTj9+LgUWAoazLbe8cwmSw9iakwELjnC3mWNbA5f+IRdPGjvyCu/Y MHws1rrcUjHWWuEe5gF4UGCLPIf1zTjGLcy19aLWQg4ON4rwnkGCD6t3oOghA/vtQ3Cv 1LVry/l7u5PVm1sNndeIpRhv7lNJsKPgK+nubKRZCXwRIvm4VMXzupRZkJfKXQnOeDlq zrUBADKG6RQ9Boaod7FZbEbGBUParftk983IU0hzmXo4m4rehiyTyOJurRIiPkvr1sZQ PK4VZKUgp3mqwPj2yC98xxByAgrYgBT6EB5AF5HTWNs5UFJrK/gzBDVbpu+OcaQYU1ny LcQA== X-Gm-Message-State: AOAM530aXnpYpvkfow4KOql/u3CXm+3GkWFaAE6waMyrgaTlgdUuNfRe Z/H9pQF8sYpCvBclAn0HEzt/5Q9npJ3W2j1MB8x0VnU+2sbftdM7 X-Received: by 2002:a62:7f0e:0:b029:152:197b:e2bd with SMTP id a14-20020a627f0e0000b0290152197be2bdmr1721683pfd.7.1601566584648; Thu, 01 Oct 2020 08:36:24 -0700 (PDT) MIME-Version: 1.0 References: <20200930160430.7908-1-calvin.johnson@oss.nxp.com> <20200930160430.7908-7-calvin.johnson@oss.nxp.com> In-Reply-To: <20200930160430.7908-7-calvin.johnson@oss.nxp.com> From: Andy Shevchenko Date: Thu, 1 Oct 2020 18:36:06 +0300 Message-ID: Subject: Re: [net-next PATCH v1 6/7] net: dpaa2-mac: Add ACPI support for DPAA2 MAC driver To: Calvin Johnson Cc: Grant Likely , "Rafael J . Wysocki" , Jeremy Linton , Andrew Lunn , Florian Fainelli , Russell King - ARM Linux admin , Cristi Sovaiala , Florin Laurentiu Chiculita , Ioana Ciornei , Madalin Bucur , Heikki Krogerus , Linux Kernel Mailing List , "linux.cj" , netdev , ACPI Devel Maling List , linux-arm Mailing List , Diana Madalina Craciun , Laurentiu Tudor , "David S. Miller" , Ioana Radulescu , Jakub Kicinski Content-Type: text/plain; charset="UTF-8" Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, Sep 30, 2020 at 7:06 PM Calvin Johnson wrote: > > Modify dpaa2_mac_connect() to support ACPI along with DT. > Modify dpaa2_mac_get_node() to get the dpmac fwnode from either > DT or ACPI. > > Replace of_get_phy_mode with fwnode_get_phy_mode to get > phy-mode for a dpmac_node. > > Use helper function phylink_fwnode_phy_connect() to find phy_dev and > connect to mac->phylink. ... > #include "dpaa2-eth.h" > #include "dpaa2-mac.h" > +#include Please, put generic headers first. > + struct acpi_buffer buffer = { ACPI_ALLOCATE_BUFFER, NULL }; > + struct fwnode_handle *dpmacs, *dpmac = NULL; > + unsigned long long adr; > + acpi_status status; > int err; > + u32 id; > > - dpmacs = of_find_node_by_name(NULL, "dpmacs"); > - if (!dpmacs) > - return NULL; > + if (is_of_node(dev->parent->fwnode)) { > + dpmacs = device_get_named_child_node(dev->parent, "dpmacs"); > + if (!dpmacs) > + return NULL; > + > + while ((dpmac = fwnode_get_next_child_node(dpmacs, dpmac))) { > + err = fwnode_property_read_u32(dpmac, "reg", &id); > + if (err) > + continue; > + if (id == dpmac_id) > + return dpmac; > + } > > + } else if (is_acpi_node(dev->parent->fwnode)) { > + device_for_each_child_node(dev->parent, dpmac) { > + status = acpi_evaluate_integer(ACPI_HANDLE_FWNODE(dpmac), > + "_ADR", NULL, &adr); > + if (ACPI_FAILURE(status)) { > + pr_debug("_ADR returned %d on %s\n", > + status, (char *)buffer.pointer); > + continue; > + } else { > + id = (u32)adr; > + if (id == dpmac_id) > + return dpmac; > + } > + } Can you rather implement generic one which will be int fwnode_get_child_id(struct fwnode_handle *fwnode, u64 *id); and put the logic of retrieving 'reg' or _ADR? Also, for the latter we have a special macro METHOD_NAME__ADR. See [1] as well. Same idea I have shared already. [1]: https://lore.kernel.org/linux-iio/20200824054347.3805-1-william.sung@advantech.com.tw/T/#m5f61921fa67a5b40522b7f7b17216e0d204647be ... > - of_node_put(dpmac_node); > + if (is_of_node(dpmac_node)) > + of_node_put(to_of_node(dpmac_node)); I'm not sure why you can't use fwnode_handle_put()? > + if (is_of_node(dpmac_node)) > + of_node_put(to_of_node(dpmac_node)); Ditto. -- With Best Regards, Andy Shevchenko