From mboxrd@z Thu Jan 1 00:00:00 1970 From: Andrew Lunn Subject: Re: [PATCHv2] gianfar: Add gfar_change_carrier() for Fixed PHYs Date: Wed, 12 Dec 2018 15:51:54 +0100 Message-ID: <20181212145154.GC1549@lunn.ch> References: <20181212123308.20100-1-joakim.tjernlund@infinera.com> <20181212124232.GB1549@lunn.ch> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Cc: "claudiu.manoil@nxp.com" , "netdev@vger.kernel.org" , "f.fainelli@gmail.com" To: Joakim Tjernlund Return-path: Received: from vps0.lunn.ch ([185.16.172.187]:44545 "EHLO vps0.lunn.ch" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726223AbeLLOwA (ORCPT ); Wed, 12 Dec 2018 09:52:00 -0500 Content-Disposition: inline In-Reply-To: Sender: netdev-owner@vger.kernel.org List-ID: > fast check, would you be happy with this in fixed PHY: > --- a/drivers/net/phy/fixed_phy.c > +++ b/drivers/net/phy/fixed_phy.c > @@ -25,6 +25,7 @@ > #include > #include > #include > +#include > > #include "swphy.h" > > @@ -38,6 +39,7 @@ struct fixed_phy { > struct phy_device *phydev; > seqcount_t seqcount; > struct fixed_phy_status status; > + bool no_carrier; > int (*link_update)(struct net_device *, struct fixed_phy_status *); > struct list_head node; > int link_gpio; > @@ -48,6 +50,24 @@ static struct fixed_mdio_bus platform_fmb = { > .phys = LIST_HEAD_INIT(platform_fmb.phys), > }; > > +int > +fixed_phy_change_carrier(struct net_device *dev, bool new_carrier) > +{ > + struct fixed_mdio_bus *fmb = &platform_fmb; > + struct phy_device *phydev = dev->phydev; > + struct fixed_phy *fp; > + > + if (!phydev || !phydev->mdio.bus) > + return -EINVAL; > + > + list_for_each_entry(fp, &fmb->phys, node) { > + if (fp->addr == phydev->mdio.addr) { > + fp->no_carrier = !new_carrier; Why is no_carrier needed? You can directly change fp->status.link, so long as you take care of locking. > + return 0; > + } > + } > + return -EINVAL; > +} You need to export the function. Andrew