Received: by 2002:a25:1985:0:0:0:0:0 with SMTP id 127csp439944ybz; Fri, 24 Apr 2020 03:08:52 -0700 (PDT) X-Google-Smtp-Source: APiQypIM4DgIe2pkQrLPvPJ/sU2TvGK/JOMPU8PZc1ZIyFxOxljuwLRPDYO85l0Yd/LYAQ5N4qeA X-Received: by 2002:a50:cb84:: with SMTP id k4mr6623438edi.89.1587722932230; Fri, 24 Apr 2020 03:08:52 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1587722932; cv=none; d=google.com; s=arc-20160816; b=JQXlSNIG9Y5qsFLqB53CXrat4bLojS+BJAJujTxHj2EQBYtLHnnlqBLEYWsJTU7Wjh tGyhEVFWfjmITsuNVwIYGH4rrwcP9XlHEFZ15Jq7UU0Ly7jYZ7CDM/cyRQg3CRSZYcp8 7rycobAcqtbrIQRQ50q1ynPpARQmv/uPLpccx2k4280CtyBuaWU4aZhtPUU9ZVu3gowJ VpeJyV1uqU/kRJ2SdNYq5PBA3y0A0RWtFDJzxeYCbOUxJy+lLCYaSqVtP8HpIKnux+7y bCAypehuu35WnzyQu8BqoGEvyunhX9zCGcydSSBWMezf4nLjvhOaqCYr66R6S8NEUG9t kYKw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:in-reply-to:content-disposition :mime-version:references:message-id:subject:cc:to:from:date :ironport-sdr:ironport-sdr; bh=PFgrGdzQKSJrb5lLhxlIsFHanDJ9WPYkQGD03ptutiI=; b=U5gM4Uc3QXnUtxxGWLzcAaWHHVQI/5U2/fLJWwZrnXcg+EmWQLOp0WgmbW5cgJple7 M51SiTLwu5VHRKA3ck9lTvKMsumVi9yJDWlBh8xs+A8kr9xbVwberSSFDP5GA0NDU9Dv o4DEFcgQMrjzRVQw1hvYjd9slDylwNXYIzqPIVMyElyiBbYYgBEZVHF9k80mE6kKAJ5h TZKQH8z4ymO10wNgi8IclInsCs0ZA3FDhUjV1Bb0rIsyzs/UzDj6IrWKtpm9VsvWloJP UH64UbCq4gcmkqKC+fV0x1iZzfNHj7AppqXyHNqT9QK92plLEAMXZQPIKQ99lf1ubJAS A1+Q== ARC-Authentication-Results: i=1; mx.google.com; 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=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id h14si3145213ejd.424.2020.04.24.03.08.27; Fri, 24 Apr 2020 03:08:52 -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; 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=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726884AbgDXKEX (ORCPT + 99 others); Fri, 24 Apr 2020 06:04:23 -0400 Received: from mga18.intel.com ([134.134.136.126]:16160 "EHLO mga18.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726489AbgDXKEX (ORCPT ); Fri, 24 Apr 2020 06:04:23 -0400 IronPort-SDR: lQNevgnSAYdpCRG7u5HvZw6CJRI9+B4RSG5cUKXCutorunxqVf/6ShU8VIIbDlLaLXpxuW+5Ks +Z8u5G8iaR9g== X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga001.fm.intel.com ([10.253.24.23]) by orsmga106.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 24 Apr 2020 03:04:22 -0700 IronPort-SDR: 0rZ8bHp+me5uUBc2xp4wacOWeGz9KMvj9xxyBNfUJ9cPDNC6hHi/MaFgNt6E34vFpUvmg9UlRC +YWwO73fwrWQ== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.73,311,1583222400"; d="scan'208";a="366299723" Received: from kuha.fi.intel.com ([10.237.72.162]) by fmsmga001.fm.intel.com with SMTP; 24 Apr 2020 03:04:15 -0700 Received: by kuha.fi.intel.com (sSMTP sendmail emulation); Fri, 24 Apr 2020 13:04:15 +0300 Date: Fri, 24 Apr 2020 13:04:15 +0300 From: Heikki Krogerus To: Calvin Johnson Cc: linux.cj@gmail.com, Jeremy Linton , Andrew Lunn , Andy Shevchenko , Florian Fainelli , Russell King - ARM Linux admin , Cristi Sovaiala , Florin Laurentiu Chiculita , Ioana Ciornei , Madalin Bucur , Laurentiu Tudor , linux-acpi@vger.kernel.org, Diana Madalina Craciun , linux-arm-kernel@lists.infradead.org, Pankaj Bansal , linux-kernel@vger.kernel.org, netdev@vger.kernel.org, Varun Sethi , Marcin Wojtas , Makarand Pawagi , "Rajesh V . Bikkina" , Andy Shevchenko , Dmitry Torokhov , Greg Kroah-Hartman , "Rafael J. Wysocki" , Sakari Ailus , Thomas Gleixner Subject: Re: [net-next PATCH v1 1/2] device property: Introduce fwnode_phy_find_device() Message-ID: <20200424100415.GA1575367@kuha.fi.intel.com> References: <20200424031617.24033-1-calvin.johnson@oss.nxp.com> <20200424031617.24033-2-calvin.johnson@oss.nxp.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20200424031617.24033-2-calvin.johnson@oss.nxp.com> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, Apr 24, 2020 at 08:46:16AM +0530, Calvin Johnson wrote: > Define fwnode_phy_find_device() to iterate an mdiobus and find the > phy device of the provided phy fwnode. > > Signed-off-by: Calvin Johnson > --- > > drivers/base/property.c | 41 ++++++++++++++++++++++++++++++++++++++++ > include/linux/property.h | 5 +++++ > 2 files changed, 46 insertions(+) > > diff --git a/drivers/base/property.c b/drivers/base/property.c > index 5f35c0ccf5e0..7c0c14c800b7 100644 > --- a/drivers/base/property.c > +++ b/drivers/base/property.c > @@ -870,6 +870,47 @@ int device_get_phy_mode(struct device *dev) > } > EXPORT_SYMBOL_GPL(device_get_phy_mode); > > +/** > + * fwnode_phy_find_device - Give a phy fwnode to find the corresponding > + * phy_device on the mdiobus. > + * @phy_fwnode: Pointer to the phy's fwnode. > + * > + * If successful, returns a pointer to the phy_device with the embedded > + * struct device refcount incremented by one, or NULL on failure. > + */ > +struct phy_device *fwnode_phy_find_device(struct fwnode_handle *phy_fwnode) > +{ > + struct device *d; > + struct mdio_device *mdiodev; > + > + if (!phy_fwnode) > + return NULL; > + > + d = bus_find_device_by_fwnode(&mdio_bus_type, phy_fwnode); > + if (d) { > + mdiodev = to_mdio_device(d); > + if (mdiodev->flags & MDIO_DEVICE_FLAG_PHY) > + return to_phy_device(d); > + put_device(d); > + } > + > + return NULL; > +} > +EXPORT_SYMBOL(fwnode_phy_find_device); > + > +/** > + * device_phy_find_device - For the given device, get the phy_device > + * @dev: Pointer to the given device > + * > + * If successful, returns a pointer to the phy_device with the embedded > + * struct device refcount incremented by one, or NULL on failure. > + */ > +struct phy_device *device_phy_find_device(struct device *dev) > +{ > + return fwnode_phy_find_device(dev_fwnode(dev)); > +} > +EXPORT_SYMBOL_GPL(device_phy_find_device); Let's not put any more subsystem specific functions into property.c. thanks, -- heikki