Subject: Re: [PATCH RFC net-next 3/7] net: dsa: use fwnode_get_phy_mode() to get phy interface mode

From: "Russell King (Oracle)" <[email-masked]>
Date: Thu, 23 Mar 2023 20:46:51 +0000

On Thu, Mar 23, 2023 at 08:04:45PM +0200, Andy Shevchenko wrote:
> On Thu, Mar 23, 2023 at 05:53:46PM +0000, Russell King (Oracle) wrote:
> > On Thu, Mar 23, 2023 at 05:00:08PM +0200, Andy Shevchenko wrote:
> > > On Thu, Mar 23, 2023 at 02:49:01PM +0000, Russell King (Oracle) wrote:
> > > > Let's start here. We pass this fwnode to fwnode_get_phy_mode():
> > > > 
> > > > include/linux/property.h:int fwnode_get_phy_mode(struct fwnode_handle *fwnode);
> > > > 
> > > > Does fwnode_get_phy_mode() alter the contents of the fwnode? Probably
> > > > not, but it doesn't take a const pointer. Therefore, to declare my
> > > > fwnode as const, I'd need to cast the const-ness away before calling
> > > > this.
> > > 
> > > So, fix the fwnode_get_phy_mode(). Is it a problem?
> > > 
> > > > Then there's phylink_create(). Same problem.
> > > 
> > > So, fix that. Is it a problem?
> > 
> > To do both of these creates a five patch series, because there are so
> > many things that need to be constified:
> > 
> > fwnode_get_phy_mode() is the trivial one.
> > 
> > sfp_bus_find_fwnode(), and the sfp-bus internal fwnode uses.
> > 
> > fwnode_get_phy_node().
> > 
> > phylink_create(), phylink_parse_fixedlink(), phylink_parse_mode(),
> > phylink_fwnode_phy_connect().
> > 
> > Hopefully nothing breaks as a result of changing all those - but that
> > can hardly be "tacked" on to the start of my series as a trivial
> > change - and clearly such a change should _not_ be part of this
> > series.
> 
> Thank you for doing that!
> 
> > Those five patches do not include moving fwnode_get_phy_mode(), whose
> > location remains undecided.
> 
> No problem, we like iterative work.

Oh, and what a waste of time that was.

You request that the fwnode should be declared const, but now I
realise that you never looked at patch 4, where we call
fwnode_remove_software_node() on this fwnode (so that the swnodes
returned by ->port_get_fwnode are released).

Since fwnode_remove_software_node() modifies the swnode containing
the fwnode, and therefore does not take a const fwnode pointer, we
also can't make _this_ fwnode pointer const - even with all those
changes.

So, I feel like I've been on a wild goose chase and what a needless
effort it has been to concoct patches that I don't even need for
this.

So again, rmk was right! Sigh.

-- 
RMK's Patch system: https://www.armlinux.org.uk/developer/patches/
FTTP is here! 40Mbps down 10Mbps up. Decent connectivity at last!