Received: by 2002:a05:6902:102b:0:0:0:0 with SMTP id x11csp490114ybt; Wed, 1 Jul 2020 03:26:13 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzW7c70lx5J8FHKG/h/1dOpGK8fSFo39X7WTkHnuoKpOL50MAbrsEvoQu4pMP1HWWK0xnrT X-Received: by 2002:a17:906:5c05:: with SMTP id e5mr20473979ejq.203.1593599173731; Wed, 01 Jul 2020 03:26:13 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1593599173; cv=none; d=google.com; s=arc-20160816; b=JL6dojmOdIf6+O7HCerW19onGl5iZGtwwiiUgXahmQEDuAFP/uXf3XDYCNV/RW3vlB f4q0NbqlvdN1qshRBnOcXhtBWJB0SFkc4k4fjyZ3+V3dHkScBeojPalqz7KoUm26POO/ NrO7vgDN8Va3nFiKoAEShLxq7K8n0iUVkILWOCToy2q+0FIyItiTCcAGql6HS6oQmTUM zP/OrNToeJ81b2JOHSi5ejII1lSn/dmntuqK95M9nplGX9Hx3xl/M+qrwXtG2T8Vuo09 fm2LIX3z9s2gPUD2U5nX0Fkcx+n8XkjykIA/2xWFLo27aZSfE6I+OVqBPcNWoE51+XP9 A6Bg== 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 :in-reply-to:references:mime-version:dkim-signature; bh=XlyOreYcq7l3PbaTN7d7mPxu6E5D6MEe46NhFAGwU6E=; b=Uo/wxjvrzOaEUO75tMp0ia5eOfzNebI+WSwMcLA1vgKYwZBQG6Vu/Q1VrbDxDfZwfY bzddpxbxvdoC7a2mfoujcdVv+aAe6Lwpf8q4c264KbBfeRLVFFHrCdBMOsUa3Qeo+ndV 3lr64vDoTL5KQb1m0pf0USrv2GjpjeaJ+RxVLYQv9ywTLOKQJqLL2MwNuDvvQEifXj1a 5Q1YaL9x0oM1ULHmrAa/k/RIJOHamv3BYAqUg5BLFdkKXEaSnavYNZip926gmqN3RaPr 7ZXo/JejF2yliP6N8/Yg7incJMmGrr+Ws29NdCqpM4GuNxB6Qwa7fvfZX7mQLK3yxdj5 Z5Wg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=Hv3t7+iu; 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 d4si3521062edv.535.2020.07.01.03.25.50; Wed, 01 Jul 2020 03:26:13 -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=Hv3t7+iu; 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 S1729915AbgGAKXo (ORCPT + 99 others); Wed, 1 Jul 2020 06:23:44 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40620 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729781AbgGAKXm (ORCPT ); Wed, 1 Jul 2020 06:23:42 -0400 Received: from mail-pg1-x543.google.com (mail-pg1-x543.google.com [IPv6:2607:f8b0:4864:20::543]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7D919C061755; Wed, 1 Jul 2020 03:23:42 -0700 (PDT) Received: by mail-pg1-x543.google.com with SMTP id j19so4628361pgm.11; Wed, 01 Jul 2020 03:23: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=XlyOreYcq7l3PbaTN7d7mPxu6E5D6MEe46NhFAGwU6E=; b=Hv3t7+iuMbkQLI/nvjRpT8LkUq23BXDfCK9qAIxtbwGDzsm27zbq6qFP8dofmINNVe KKEPgdIceIfx7gsmAn9SQi/UUWWKZwo+DjvYnn7/5C/yeLCJ4rDPgPvBJfNwFOHtybxZ XShxPE39LUaQ0fRe+ahUp/yn+IsriZJWpvw/9w3gERmxozRAsmpNZ08kwK2xvxaGyxww zwmwlgsv5JLPoyBmDm04n5BQajIAgjboGLr/SD63PycmODS6rwb3g/sVbYWCED4Ng9IO /x16kmrkmBt1s2drY7QFf1odm1rfgVMyZMWDNHAZHPlKx/MwA773XfFMnXtFDeTAz3xg jIHg== 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=XlyOreYcq7l3PbaTN7d7mPxu6E5D6MEe46NhFAGwU6E=; b=bSsiEBq/FH0eDw1jWgWm3mXIdrt10hlvKSAhbLzX1QHtyL2y0Yz5f2Udn6YaNfOoOn yHWw3kSY9Og6lor6oTxTaiFU7dZNW4byIu9aA3Ohv9I6UZ3ZRe+E8aW3a6WYqZ1kvn7W L6aZ2ui4zDgFaB5AA15Vlas3NvgR9yRx4ZAIeYxFFUNQatqLNBGN2d4udGfIk6IOqoI3 J/YIRgoVo/e9i3ph5OvKiifMjgbfB9LKOIPB51emuWNHGgOMChMPDPb6QpRpARH/9/RN Sx54NBFSB+y61GMuHlB0z9GPR8oUAvoaioexEwwk7GkEBB+HOcFA8nhFURqUICRm4mpp yYNQ== X-Gm-Message-State: AOAM531KnMLMttqt2QsfmzYWKaGkmTPUAEIrx9CZuCOiwRmxx8zpHjQa CuHxS3P/3MuNh8+BCrtj0aqLM1Zg+bIERBYlK3M= X-Received: by 2002:a63:a05f:: with SMTP id u31mr13486486pgn.4.1593599021934; Wed, 01 Jul 2020 03:23:41 -0700 (PDT) MIME-Version: 1.0 References: <20200701061233.31120-1-calvin.johnson@oss.nxp.com> <20200701061233.31120-2-calvin.johnson@oss.nxp.com> In-Reply-To: <20200701061233.31120-2-calvin.johnson@oss.nxp.com> From: Andy Shevchenko Date: Wed, 1 Jul 2020 13:23:28 +0300 Message-ID: Subject: Re: [net-next PATCH v2 1/3] net: phy: introduce find_phy_device() To: Calvin Johnson Cc: Jeremy Linton , Russell King - ARM Linux admin , Jon , Cristi Sovaiala , Ioana Ciornei , Andrew Lunn , Florian Fainelli , Madalin Bucur , netdev , ACPI Devel Maling List , linux.cj@gmail.com, "David S. Miller" , Heiner Kallweit , Jakub Kicinski , Linux Kernel Mailing List 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 Wed, Jul 1, 2020 at 9:13 AM Calvin Johnson wrote: > > The PHYs on a mdiobus are probed and registered using mdiobus_register(). > Later, for connecting these PHYs to MAC, the PHYs registered on the > mdiobus have to be referenced. > > For each MAC node, a property "mdio-handle" is used to reference the > MDIO bus on which the PHYs are registered. On getting hold of the MDIO > bus, use find_phy_device() to get the PHY connected to the MAC. ... > + struct platform_device *pdev; This... > + fwnode_mdio = fwnode_find_reference(fwnode, "mdio-handle", 0); > + dev = bus_find_device_by_fwnode(&platform_bus_type, fwnode_mdio); > + if (IS_ERR_OR_NULL(dev)) IS_ERR()?! > + return NULL; > + pdev = to_platform_device(dev); > + mdio = platform_get_drvdata(pdev); ...and this can be simple: mdio = dev_get_drvdata(dev); > + err = fwnode_property_read_u32(fwnode, "phy-channel", &addr); > + if (err < 0 || addr < 0 || addr >= PHY_MAX_ADDR) > + return NULL; -- With Best Regards, Andy Shevchenko