From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.7 required=3.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH,MAILING_LIST_MULTI,SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS, URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id A1BE6C2BA1A for ; Fri, 24 Apr 2020 10:04:24 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 862C52071E for ; Fri, 24 Apr 2020 10:04:24 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726890AbgDXKEX (ORCPT ); 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