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=-2.9 required=3.0 tests=BAYES_00,DKIM_ADSP_NXDOMAIN, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS autolearn=no 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 25CDFC48BE8 for ; Tue, 15 Jun 2021 20:34:58 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id F3E856109E for ; Tue, 15 Jun 2021 20:34:57 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230298AbhFOUhC (ORCPT ); Tue, 15 Jun 2021 16:37:02 -0400 Received: from fgw21-7.mail.saunalahti.fi ([62.142.5.82]:54717 "EHLO fgw21-7.mail.saunalahti.fi" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229979AbhFOUhA (ORCPT ); Tue, 15 Jun 2021 16:37:00 -0400 Received: from localhost (88-115-248-186.elisa-laajakaista.fi [88.115.248.186]) by fgw21.mail.saunalahti.fi (Halon) with ESMTP id e5ba8ddc-ce16-11eb-9eb8-005056bdd08f; Tue, 15 Jun 2021 23:18:51 +0300 (EEST) Date: Tue, 15 Jun 2021 23:18:50 +0300 From: andy@surfacebook.localdomain To: Ioana Ciornei Cc: davem@davemloft.net, kuba@kernel.org, hkallweit1@gmail.com, netdev@vger.kernel.org, Grant Likely , "Rafael J . Wysocki" , Jeremy Linton , Andrew Lunn , Andy Shevchenko , Florian Fainelli , Russell King - ARM Linux admin , Heikki Krogerus , Marcin Wojtas , Pieter Jansen Van Vuuren , Jon , Saravana Kannan , Randy Dunlap , calvin.johnson@oss.nxp.com, Cristi Sovaiala , Florin Laurentiu Chiculita , Madalin Bucur , linux-arm-kernel@lists.infradead.org, Diana Madalina Craciun , linux-acpi@vger.kernel.org, linux-kernel@vger.kernel.org, linux.cj@gmail.com, Laurentiu Tudor , Len Brown , "Rafael J . Wysocki" , Ioana Ciornei Subject: Re: [PATCH net-next v9 13/15] net: phylink: introduce phylink_fwnode_phy_connect() Message-ID: References: <20210611105401.270673-1-ciorneiioana@gmail.com> <20210611105401.270673-14-ciorneiioana@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20210611105401.270673-14-ciorneiioana@gmail.com> Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org Fri, Jun 11, 2021 at 01:53:59PM +0300, Ioana Ciornei kirjoitti: > From: Calvin Johnson > > Define phylink_fwnode_phy_connect() to connect phy specified by > a fwnode to a phylink instance. ... > +/** > + * 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. > + * > + * 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; > + > + /* 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(phy_fwnode)) { > + if (pl->cfg_link_an_mode == MLO_AN_PHY) > + return -ENODEV; > + return 0; > + } > + > + phy_dev = fwnode_phy_find_device(phy_fwnode); > + /* We're done with the phy_node handle */ > + fwnode_handle_put(phy_fwnode); As per previous mail, who and when acquire this reference counting? Can it be possible that caller will never call phylink_fwnode_phy_connect() and hence reference counting will become disbalances? We need to fix all this before the release. > + if (!phy_dev) > + return -ENODEV; > + > + ret = phy_attach_direct(pl->netdev, phy_dev, flags, > + pl->link_interface); > + if (ret) { > + phy_device_free(phy_dev); > + return ret; > + } > + > + ret = phylink_bringup_phy(pl, phy_dev, pl->link_config.interface); > + if (ret) > + phy_detach(phy_dev); > + > + return ret; > +} -- With Best Regards, Andy Shevchenko