Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp493447pxj; Fri, 11 Jun 2021 04:30:15 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxpkK3u588G2z/osM2liKlx6G3egWhwqqtRxgCjX/zAJQ8fAc/wGb5ggy6HMGYe8LKMBEJU X-Received: by 2002:a05:6402:520c:: with SMTP id s12mr3228187edd.304.1623411015236; Fri, 11 Jun 2021 04:30:15 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1623411015; cv=none; d=google.com; s=arc-20160816; b=MhKImx7mLkeYT0m6/CGx1aEqqtPE9hoFYfqw2zb3PXtaCVa6xusgcUg4+VvaTbaRaW qeIpoaKfLoZe+Jo1TsU6qnFPWPwdQzqvDtb1YhKt1H/Z0XIqFpJGNZcpKE8NPyWcvvv3 XwFIas1k6FQADmM4ehXWYhKgENyPEQBvX4eYexcvkulBim+F/Vye7hguDeqih/t7EjNQ CDQbQDqqzPW42tTehQJtIP0RjXVmnE2hKTrDV8riwpC8+Lo9yle8TbGDbr7hO51GNBml IR7NH2WeNv3RevIy+b+CuHP/viYLn4UT+48c3lF0a740l9XCfKNcZ7iClIaISyYwNiNX Suyg== 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=h4XBx6hy/8HemTestI8gx5CVIEJQPh5SHNT2c3CXnb4=; b=DZPlhHIr0acUayFY58oDr1ELhNXIoGP5oDtb7foyu+DvunspSIZaz2aa9fmPoZ1gVC BvIwweOi9SCwek1lnjDEJr3uFpUIoUNSPsVzxrEf04M4AGdhXwrRalJBCim0xzuXd2Hw fQuLrYLtuNiheCupdPHJVr1517oc/zhXZlUlBqzt1910/xHSbotZWMH6acL+UfA1F/SN Ym8sJiyuY4o/lN7ALF8XxZJR48xdKNeKJGGqBGZUEdhh1bqUDr7KHd/vnCqQtaJi29Th oo8uLkBkg4zq7QwtyzX8CK7c4LtJiwwG0ora8uicLy3BC17WphzNOOV8RKTbkHXo0cGs /6Mw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=rcciTaLn; 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 wn12si4706895ejb.563.2021.06.11.04.29.52; Fri, 11 Jun 2021 04:30:15 -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=rcciTaLn; 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 S231497AbhFKL3k (ORCPT + 99 others); Fri, 11 Jun 2021 07:29:40 -0400 Received: from mail-pj1-f54.google.com ([209.85.216.54]:38735 "EHLO mail-pj1-f54.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230248AbhFKL3k (ORCPT ); Fri, 11 Jun 2021 07:29:40 -0400 Received: by mail-pj1-f54.google.com with SMTP id m13-20020a17090b068db02901656cc93a75so5672025pjz.3; Fri, 11 Jun 2021 04:27:42 -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=h4XBx6hy/8HemTestI8gx5CVIEJQPh5SHNT2c3CXnb4=; b=rcciTaLnGKf0bY+pPO8FwxoOXt0lVZm79aIo1gkrehaurfpJDOI9ugW/6rpoprP2p0 eR/c/rDamGM2HF4c0TNczIAXWs7O9JyvxdCPnkBGndSC0i767zSjoV+BmvfHVBSqQWyV iFlBuXhampJ7t8Cb7+xV3/yCngTtHrPHnmeqY7OCasqUjntyocJljMWz1CTpzHNnTzpb LVx6xMLL1nB4S/kpUW/NJ9s6Zysk3DvGmYCA7bXvEqXmQqRkn6Lc9tnp3WIZbRd7vFRI oWbbq5BXntVc/zufWP6Lz0wJhvzSivys4gB6sPnbseSYghKvWidvHxifW9jRBajTumSr qn4A== 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=h4XBx6hy/8HemTestI8gx5CVIEJQPh5SHNT2c3CXnb4=; b=mFuJr2jNjg56fuqQouxJkqGDxTM8UNeTFMV5RkHgDr2A8CQPH90OaoBHTaxB91zPEu T+ZllQ1weay6zU7+toMBC+dvVNsf3Oz3BxBCSSw50W44yEmhEgZaU+A0CMkux79iB5Ow kuX38SlvRuqXUcgkzNlQw79873zKMnzN0zForW+K+0htd1GdF+e+nlbDqQQMbMR7njXL uGhZfzGO1Fb3o587YZINb9fhPtUUvb3FnC41jXUvKIbDfmoXVCBNfmE+8xr3U+Vj1DY/ ZOZ8kYo1lUwIZ9aiAExeZ1vGBrV5G4Ib//7PyvyCC7KmuCWGH/SNIYc3rnVXk48agNnE X7Ng== X-Gm-Message-State: AOAM532T/AcTkuLs1mjS9kAD6rZJxeHhzX5+c3taSKpGa2tDshiYw2cd aoC2gJoGu/iSbSt7W6liOTJz7ukC2JkS5mSXSOY= X-Received: by 2002:a17:90a:80c5:: with SMTP id k5mr8780907pjw.129.1623410802452; Fri, 11 Jun 2021 04:26:42 -0700 (PDT) MIME-Version: 1.0 References: <20210611105401.270673-1-ciorneiioana@gmail.com> <20210611105401.270673-4-ciorneiioana@gmail.com> In-Reply-To: <20210611105401.270673-4-ciorneiioana@gmail.com> From: Andy Shevchenko Date: Fri, 11 Jun 2021 14:26:26 +0300 Message-ID: Subject: Re: [PATCH net-next v9 03/15] net: phy: Introduce phy related fwnode functions To: Ioana Ciornei Cc: "David S. Miller" , Jakub Kicinski , Heiner Kallweit , netdev , Grant Likely , "Rafael J . Wysocki" , Jeremy Linton , Andrew Lunn , Florian Fainelli , Russell King - ARM Linux admin , Heikki Krogerus , Marcin Wojtas , Pieter Jansen Van Vuuren , Jon , Saravana Kannan , Randy Dunlap , Calvin Johnson , Cristi Sovaiala , Florin Laurentiu Chiculita , Madalin Bucur , linux-arm Mailing List , Diana Madalina Craciun , ACPI Devel Maling List , Linux Kernel Mailing List , "linux.cj" , Laurentiu Tudor , Len Brown , "Rafael J . Wysocki" , Ioana Ciornei Content-Type: text/plain; charset="UTF-8" Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, Jun 11, 2021 at 1:54 PM Ioana Ciornei wrote: > > From: Calvin Johnson > > Define fwnode_phy_find_device() to iterate an mdiobus and find the > phy device of the provided phy fwnode. Additionally define > device_phy_find_device() to find phy device of provided device. > > Define fwnode_get_phy_node() to get phy_node using named reference. using a named ... > +struct fwnode_handle *fwnode_get_phy_node(struct fwnode_handle *fwnode) > +{ > + struct fwnode_handle *phy_node; > + > + /* Only phy-handle is used for ACPI */ > + phy_node = fwnode_find_reference(fwnode, "phy-handle", 0); > + if (is_acpi_node(fwnode) || !IS_ERR(phy_node)) > + return phy_node; > + phy_node = fwnode_find_reference(fwnode, "phy", 0); > + if (IS_ERR(phy_node)) > + phy_node = fwnode_find_reference(fwnode, "phy-device", 0); > + return phy_node; Looking into the patterns in this code I would perhaps refactor it the following way: /* First try "phy-handle" as most common in use */ phy_node = fwnode_find_reference(fwnode, "phy-handle", 0); /* Only phy-handle is used for ACPI */ if (is_acpi_node(fwnode)) return phy_node; if (!IS_ERR(phy_node)) return phy_node; /* Try "phy" reference */ phy_node = fwnode_find_reference(fwnode, "phy", 0); if (!IS_ERR(phy_node)) return phy_node; /* At last try "phy-device" reference */ return fwnode_find_reference(fwnode, "phy-device", 0); > +} -- With Best Regards, Andy Shevchenko