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=-8.3 required=3.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH,MAILING_LIST_MULTI, SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS,USER_AGENT_SANE_1 autolearn=unavailable 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 73EA5C55199 for ; Mon, 27 Apr 2020 13:56:53 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 23302206BF for ; Mon, 27 Apr 2020 13:56:53 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="iRE5fUed"; dkim=fail reason="signature verification failed" (2048-bit key) header.d=armlinux.org.uk header.i=@armlinux.org.uk header.b="T0rTi2zv" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 23302206BF Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=armlinux.org.uk Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+infradead-linux-arm-kernel=archiver.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:Cc:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:In-Reply-To:MIME-Version:References: Message-ID:Subject:To:From:Date:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=3+lYlcZc66Rys2S2xE/9HmYYPHVuyHnU31kCPeObmuE=; b=iRE5fUedZZNdRu d5aPRULvqDAfmMNpNxM3PciCQpyAUrUJbCPPpxP21Q66oKhR4CJWA7nin++E4WDZtfPGdQNgOriza ncdxb8DhEMlAY7s4vjNnnzumkCshzF33aT34w/AdStXQ8GmQKOoeMFf4rjz8osrXn3+xsfqy7F8gC t9FhlY7R2Eo4VJ+WwTRcgcFufI0ZyJOG38lxe/Q9xA5l+OvfXUpPonY5v+2N07/E/yG0SXmQOtDW1 GD6W2dUHxMNouheNytE37yKU/Gge/M+eHpa1Otilm4H7Ftb2jQ1sPr6hagsUU4FHnd1eA/KgQ8Q8U PILp3tnOIy5r04zKxWJA==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1jT4Fg-00082O-MJ; Mon, 27 Apr 2020 13:56:52 +0000 Received: from pandora.armlinux.org.uk ([2001:4d48:ad52:3201:214:fdff:fe10:1be6]) by bombadil.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1jT4Fc-00081Y-RX for linux-arm-kernel@lists.infradead.org; Mon, 27 Apr 2020 13:56:50 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=armlinux.org.uk; s=pandora-2019; h=Sender:In-Reply-To:Content-Type: MIME-Version:References:Message-ID:Subject:Cc:To:From:Date:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Id: List-Help:List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=X25jyGvf8DYeBAr/a+VcEJFJMS/q5ACVY5cjQsA4fy0=; b=T0rTi2zvQXK8xCQhYxuQfs54m i9rr/1cdUrZyGp0FIw7aRsnPGwlKrO/mdlcOYG+Nd1bhApf/6T2kn9TIrba98S2XhVbymjcOCoU1/ 9pDbAZoA41MEeIQh0uefD+IJR3z6Hfv8E/AkqRWXztRA9iZttbgJK6iy3RMXIO42lgcZ4ETxw7E0J Km3X1ohVjHNNyT1A1BwQtZq+mo4Zav8NB7YjZt5TqSlcrdrjgmdXWNlaL6FmXzjmDN5rUASFhg45c 00Qlf7hYRbyOAUx57fNjm2ciWmkOZGP5MxSkUeKJBzT+4K9qFBi3XEsfcRNjRC2+iMuUF5QTiPHve PlmhtgqGg==; Received: from shell.armlinux.org.uk ([2002:4e20:1eda:1:5054:ff:fe00:4ec]:52154) by pandora.armlinux.org.uk with esmtpsa (TLSv1.2:ECDHE-RSA-AES256-GCM-SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jT4FI-0003DY-TO; Mon, 27 Apr 2020 14:56:29 +0100 Received: from linux by shell.armlinux.org.uk with local (Exim 4.92) (envelope-from ) id 1jT4FD-0006i8-Qk; Mon, 27 Apr 2020 14:56:23 +0100 Date: Mon, 27 Apr 2020 14:56:23 +0100 From: Russell King - ARM Linux admin To: Calvin Johnson Subject: Re: [net-next PATCH v2 3/3] phylink: Introduce phylink_fwnode_phy_connect() Message-ID: <20200427135623.GG25745@shell.armlinux.org.uk> References: <20200427132409.23664-1-calvin.johnson@oss.nxp.com> <20200427132409.23664-4-calvin.johnson@oss.nxp.com> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <20200427132409.23664-4-calvin.johnson@oss.nxp.com> User-Agent: Mutt/1.10.1 (2018-07-13) X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20200427_065648_895545_C91A43A6 X-CRM114-Status: GOOD ( 21.28 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Andrew Lunn , Heikki Krogerus , Cristi Sovaiala , Ioana Ciornei , Florian Fainelli , "Rajesh V . Bikkina" , Pankaj Bansal , Diana Madalina Craciun , linux-acpi@vger.kernel.org, Andy Shevchenko , Florin Laurentiu Chiculita , Madalin Bucur , Makarand Pawagi , Varun Sethi , Marcin Wojtas , linux-arm-kernel@lists.infradead.org, Laurentiu Tudor , Greg Kroah-Hartman , linux-kernel@vger.kernel.org, Jeremy Linton , linux.cj@gmail.com, netdev@vger.kernel.org, "David S. Miller" , Heiner Kallweit Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+infradead-linux-arm-kernel=archiver.kernel.org@lists.infradead.org On Mon, Apr 27, 2020 at 06:54:09PM +0530, Calvin Johnson wrote: > Define phylink_fwnode_phy_connect() to connect phy specified by > a fwnode to a phylink instance. Additionally, > phylink_device_phy_connect() is defined to connect phy specified > by a device to a phylink instance. > > Signed-off-by: Calvin Johnson > --- > > Changes in v2: > replace of_ and acpi_ code with generic fwnode to get phy-handle. > > drivers/net/phy/phylink.c | 68 +++++++++++++++++++++++++++++++++++++++ > include/linux/phylink.h | 6 ++++ > 2 files changed, 74 insertions(+) > > diff --git a/drivers/net/phy/phylink.c b/drivers/net/phy/phylink.c > index 0f23bec431c1..5eab1eadded7 100644 > --- a/drivers/net/phy/phylink.c > +++ b/drivers/net/phy/phylink.c > @@ -961,6 +961,74 @@ int phylink_connect_phy(struct phylink *pl, struct phy_device *phy) > } > EXPORT_SYMBOL_GPL(phylink_connect_phy); > > +/** > + * phylink_fwnode_phy_connect() - connect the PHY specified in the fwnode. > + * @pl: a pointer to a &struct phylink returned from phylink_create() > + * @fwnode: a pointer to a &struct fwnode_handle. > + * @flags: PHY-specific flags to communicate to the PHY device driver > + * > + * Connect the phy specified @fwnode to the phylink instance specified > + * by @pl. Actions specified in phylink_connect_phy() will be > + * performed. > + * > + * Returns 0 on success or a negative errno. > + */ > +int phylink_fwnode_phy_connect(struct phylink *pl, > + struct fwnode_handle *fwnode, > + u32 flags) > +{ > + struct fwnode_handle *phy_fwnode; > + struct phy_device *phy_dev; > + int ret = 0; > + > + /* Fixed links and 802.3z are handled without needing a PHY */ > + if (pl->cfg_link_an_mode == MLO_AN_FIXED || > + (pl->cfg_link_an_mode == MLO_AN_INBAND && > + phy_interface_mode_is_8023z(pl->link_interface))) > + return 0; > + > + phy_fwnode = fwnode_get_phy_node(fwnode); > + if ((IS_ERR_OR_NULL(phy_fwnode)) && (pl->cfg_link_an_mode == MLO_AN_PHY)) According to your documentation for fwnode_get_phy_node(), it can't return NULL. So, use of IS_ERR_OR_NULL() is incorrect here. Please also eliminate the unnecessary parens to match the style in the rest of this file. > + return -ENODEV; If fwnode_get_phy_node() returns an error pointer, shouldn't you be propagating that error here? > + > + phy_dev = fwnode_phy_find_device(phy_fwnode); > + fwnode_handle_put(phy_fwnode); > + if (!phy_dev) > + return -ENODEV; > + > + ret = phy_attach_direct(pl->netdev, phy_dev, flags, > + pl->link_interface); > + if (ret) > + return ret; > + > + ret = phylink_bringup_phy(pl, phy_dev, pl->link_config.interface); > + if (ret) > + phy_detach(phy_dev); > + > + return ret; > +} > +EXPORT_SYMBOL_GPL(phylink_fwnode_phy_connect); > + > +/** > + * phylink_device_phy_connect() - connect the PHY specified by the device. > + * @pl: a pointer to a &struct phylink returned from phylink_create() > + * @dev: a pointer to a &struct device. > + * @flags: PHY-specific flags to communicate to the PHY device driver > + * > + * Connect the phy specified by the device to the phylink instance specified > + * by @pl. Actions specified in phylink_connect_phy() will be > + * performed. > + * > + * Returns 0 on success or a negative errno. > + */ > +int phylink_device_phy_connect(struct phylink *pl, > + struct device *dev, > + u32 flags) > +{ > + return phylink_fwnode_phy_connect(pl, dev_fwnode(dev), flags); > +} > +EXPORT_SYMBOL_GPL(phylink_device_phy_connect); If this has any users, I think this should be an inline function in phylink.h - it's just a helper after all. If it doesn't then it should just be dropped. Thanks. -- RMK's Patch system: https://www.armlinux.org.uk/developer/patches/ FTTC broadband for 0.8mile line in suburbia: sync at 10.2Mbps down 587kbps up _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel