Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp4008712pxj; Tue, 15 Jun 2021 13:23:11 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxHVtvDDdGA9MDWvQn5kOFl1cYzOXCTVCf5ddzIzwjoYCyxC+qAd4/3ROIoersd79fD39HI X-Received: by 2002:a50:cb8a:: with SMTP id k10mr1642145edi.267.1623788590857; Tue, 15 Jun 2021 13:23:10 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1623788590; cv=none; d=google.com; s=arc-20160816; b=HHhoC0KXP2AeoFCxMCCGAZMr6CPvuXnIMIGruK4fMnL+7cvpUzo/CxPGSnBJ9ktULJ NxrxrANvWfrWSLRBPxef1MDm/7ZsJ+kmD8YEuICzkfrQJUr3Es2llo9HHxVoAl2q1CLu p6Qq1sT7phG8fudKS9gVnfyZ5VVPs/wn15bh587QeqYr2VFUDQYz6poLo6/gRUcnPRrW c9OKNDj8AZ9RY3MA/DxvxpOl50aYrpqsL6hTAuJ2uZT1PEngZiDQUKGJq54LX01+dpVG JY5MgJ/pcsFXXDq9i+FdlPESRLA1Jh9sxj4AixggzgLLTyu47aObrCOzh/teVAxYLrRA j2MA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date; bh=ixclheoUrJ7BmNWEkUqeufanVz3+h7XDzH0hfeCCMqo=; b=xUE7mPpztunf6RpzYtYBB5eEvctLxzz2ydlWQzWLvnxL1LIiTd9FJ3fXePyaygo71K jSKK4lnL2VMuWPM0NQFTRzMYxlNI0199pt+XalbW8W5oVTR6ZjF7uyCLqq1FP6qd4NiP AMAIdfxgBSbtJRO0mVNeiETRr7TeqYWt8/HVPcAJUxTtgO+cS/pIbOM5lWrvi750Nn/4 FcFYp52BIvAu/nIXOnlk9AqafjC2zyCSgZG+3f7kC3XTBmx5A6f+h6OmMhJEhWk/exSy bRuyh6LkWE6duedVNCcVtAhuSK61pp6RkG3O6ItkJSciqvGx6S5rx/N7EN76buTDZxZV Xjmw== 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id m3si33281ejl.38.2021.06.15.13.22.31; Tue, 15 Jun 2021 13:23:10 -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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229965AbhFOUU6 (ORCPT + 99 others); Tue, 15 Jun 2021 16:20:58 -0400 Received: from fgw21-7.mail.saunalahti.fi ([62.142.5.82]:45329 "EHLO fgw21-7.mail.saunalahti.fi" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229931AbhFOUU6 (ORCPT ); Tue, 15 Jun 2021 16:20:58 -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: linux-kernel@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