netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Andrew Lunn <andrew@lunn.ch>
To: Florian Fainelli <f.fainelli@gmail.com>
Cc: netdev <netdev@vger.kernel.org>
Subject: Re: [RFC PATCH net-next 0/2] DT MDIO bus of fixed phys
Date: Mon, 14 Mar 2016 20:04:30 +0100	[thread overview]
Message-ID: <20160314190430.GA10040@lunn.ch> (raw)
In-Reply-To: <56E6EC23.9080301@gmail.com>

On Mon, Mar 14, 2016 at 09:51:47AM -0700, Florian Fainelli wrote:
> On 11/03/16 16:12, Andrew Lunn wrote:
> >>>> Humm, if that's the problem we want to solve, we could introduce a
> >>>> helper function which tries to locate the phy using a 'phy-handle'
> >>>> property
> >>>
> >>> I don't follow you. Where do you get a phandle from to use with
> >>> phy-handle?
> >>
> >> >From the caller of the function: the consumer of that phy-handle and/or
> >> fixed-link property which is either an Ethernet MAC driver or a DSA's
> >> switch port node.
> > 
> > I still don't get it. Lets take a real example. I currently have this
> > in one of my dts files:
> > 
> > &fec1 {
> >        phy-mode = "rmii";
> >        pinctrl-names = "default";
> >        pinctrl-0 = <&pinctrl_fec1>;
> >        status = "okay";
> > 
> >        fixed-link {
> >                   speed = <100>;
> >                   full-duplex;
> >        };
> > };
> 
> All drivers have this exact same structure:
> 
> &fec1 {
> 	phy-handle = <XYZ>;
> 	or
> 	fixed-link {
> 		speed = <100>;
> 		full-duplex;
> 	};
> };
> 
> In both cases, the argument that this proposed helper function would
> take is a struct device_node pointing to &fec1 here. You could therefore
> imagine having something along these lines:
> 
> struct device_node *of_get_phy_by_phandle(struct device_node *dn, bool
> try_fixed_link)

I don't particularly like this name. It suggests it is using the
phandle, when it might not.

> {
> 	struct device_node *phy_dn;
> 	int ret;
> 
> 	phy_dn = of_parse_phandle(dn, "phy-handle", 0);
> 	if (!phy_dn && !try_fixed_link)
> 		return -ENODEV;
> 
> 	if (of_phy_is_fixed_link(dn)) {
> 		ret  = of_phy_register_fixed_link(dn);
> 		if (ret)
> 			return PTR_ERR(-ret);
> 
> 		phy_dn = of_node_get(dn);
> 	}
> 
> 	return phy_dn;		
> }

To make release work, i think you need to hack something into
phy_disconnect() or phy_detach() so that the fixed_phy registered
above gets freed.

I don't particularly like these special cases. What i suggested does
not require any special cases, because they act just like phys on an
mdio bus.

     Andrew

      reply	other threads:[~2016-03-14 19:04 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-03-11 23:08 [RFC PATCH net-next 0/2] DT MDIO bus of fixed phys Andrew Lunn
2016-03-11 23:08 ` [RFC PATCH net-next 1/2] of: of_mdio: Factor out fixed-link parsing Andrew Lunn
2016-03-11 23:08 ` [RFC PATCH net-next 2/2] phy: fixed-phy: Allow DT description of an MDIO bus and PHYs Andrew Lunn
2016-03-11 23:30   ` Florian Fainelli
2016-03-12  0:05     ` Andrew Lunn
2016-03-12 17:32     ` Andrew Lunn
2016-03-11 23:26 ` [RFC PATCH net-next 0/2] DT MDIO bus of fixed phys Florian Fainelli
2016-03-11 23:36   ` Andrew Lunn
2016-03-11 23:38     ` Florian Fainelli
2016-03-12  0:12       ` Andrew Lunn
2016-03-14 16:51         ` Florian Fainelli
2016-03-14 19:04           ` Andrew Lunn [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20160314190430.GA10040@lunn.ch \
    --to=andrew@lunn.ch \
    --cc=f.fainelli@gmail.com \
    --cc=netdev@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).