devicetree.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] of_mdio: select fixed phy support unconditionally
@ 2016-06-24  9:24 Arnd Bergmann
       [not found] ` <20160624092450.1507991-1-arnd-r2nGTMty4D4@public.gmane.org>
  2016-06-28  9:43 ` David Miller
  0 siblings, 2 replies; 5+ messages in thread
From: Arnd Bergmann @ 2016-06-24  9:24 UTC (permalink / raw)
  To: Florian Fainelli
  Cc: Arnd Bergmann, Rob Herring, Frank Rowand, David Daney,
	David S. Miller, Andrew Lunn, Sergei Shtylyov, Ben Hutchings,
	devicetree-u79uwXL29TY76Z2rM5mHXA,
	linux-kernel-u79uwXL29TY76Z2rM5mHXA,
	netdev-u79uwXL29TY76Z2rM5mHXA

Calling the fixed-phy functions when CONFIG_FIXED_PHY=m as a previous
change tried cannot work if the caller is in built-in code:

drivers/of/built-in.o: In function `of_phy_register_fixed_link':
of_reserved_mem.c:(.text+0x85e0): undefined reference to `fixed_phy_register'

Making of_mdio depend on 'FIXED_PHY || !FIXED_PHY' would solve this
dependency by enforcing that OF_MDIO itself becomes a loadable module
when FIXED_PHY=y, but that creates a different dependency as it
breaks any built-in ethernet driver that uses of_mdio.

Making FIXED_PHY a bool option also cannot work, since it depends on
PHYLIB, which again is tristate.

This version now uses 'select FIXED_PHY' to ensure that the fixed-phy
portion of of_mdio is not optional. The main downside of this is
a small increase in code size for cases that do not need fixed phy
support, but it should avoid all of the link-time problems.

Signed-off-by: Arnd Bergmann <arnd-r2nGTMty4D4@public.gmane.org>
Fixes: d1bd330a229f ("of_mdio: Enable fixed PHY support if driver is a module")
---
 drivers/of/Kconfig      | 1 +
 drivers/of/of_mdio.c    | 2 --
 include/linux/of_mdio.h | 8 ++------
 3 files changed, 3 insertions(+), 8 deletions(-)

diff --git a/drivers/of/Kconfig b/drivers/of/Kconfig
index b3bec3aaa45d..bc07ad30c9bf 100644
--- a/drivers/of/Kconfig
+++ b/drivers/of/Kconfig
@@ -74,6 +74,7 @@ config OF_NET
 config OF_MDIO
 	def_tristate PHYLIB
 	depends on PHYLIB
+	select FIXED_PHY
 	help
 	  OpenFirmware MDIO bus (Ethernet PHY) accessors
 
diff --git a/drivers/of/of_mdio.c b/drivers/of/of_mdio.c
index de68707a99c7..e2b50bc12f23 100644
--- a/drivers/of/of_mdio.c
+++ b/drivers/of/of_mdio.c
@@ -361,7 +361,6 @@ struct phy_device *of_phy_attach(struct net_device *dev,
 }
 EXPORT_SYMBOL(of_phy_attach);
 
-#if IS_ENABLED(CONFIG_FIXED_PHY)
 /*
  * of_phy_is_fixed_link() and of_phy_register_fixed_link() must
  * support two DT bindings:
@@ -451,4 +450,3 @@ int of_phy_register_fixed_link(struct device_node *np)
 	return -ENODEV;
 }
 EXPORT_SYMBOL(of_phy_register_fixed_link);
-#endif
diff --git a/include/linux/of_mdio.h b/include/linux/of_mdio.h
index 6c8cb9aa4c00..4b04587d0441 100644
--- a/include/linux/of_mdio.h
+++ b/include/linux/of_mdio.h
@@ -25,6 +25,8 @@ struct phy_device *of_phy_attach(struct net_device *dev,
 
 extern struct mii_bus *of_mdio_find_bus(struct device_node *mdio_np);
 extern int of_mdio_parse_addr(struct device *dev, const struct device_node *np);
+extern int of_phy_register_fixed_link(struct device_node *np);
+extern bool of_phy_is_fixed_link(struct device_node *np);
 
 #else /* CONFIG_OF */
 static inline int of_mdiobus_register(struct mii_bus *mdio, struct device_node *np)
@@ -67,12 +69,6 @@ static inline int of_mdio_parse_addr(struct device *dev,
 {
 	return -ENOSYS;
 }
-#endif /* CONFIG_OF */
-
-#if defined(CONFIG_OF) && IS_ENABLED(CONFIG_FIXED_PHY)
-extern int of_phy_register_fixed_link(struct device_node *np);
-extern bool of_phy_is_fixed_link(struct device_node *np);
-#else
 static inline int of_phy_register_fixed_link(struct device_node *np)
 {
 	return -ENOSYS;
-- 
2.9.0

--
To unsubscribe from this list: send the line "unsubscribe devicetree" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

^ permalink raw reply related	[flat|nested] 5+ messages in thread

* Re: [PATCH] of_mdio: select fixed phy support unconditionally
       [not found] ` <20160624092450.1507991-1-arnd-r2nGTMty4D4@public.gmane.org>
@ 2016-06-25 17:55   ` Randy Dunlap
  2016-06-27  8:17     ` Ben Hutchings
  0 siblings, 1 reply; 5+ messages in thread
From: Randy Dunlap @ 2016-06-25 17:55 UTC (permalink / raw)
  To: Arnd Bergmann, Florian Fainelli
  Cc: Rob Herring, Frank Rowand, David Daney, David S. Miller,
	Andrew Lunn, Sergei Shtylyov, Ben Hutchings,
	devicetree-u79uwXL29TY76Z2rM5mHXA,
	linux-kernel-u79uwXL29TY76Z2rM5mHXA,
	netdev-u79uwXL29TY76Z2rM5mHXA

On 06/24/16 02:24, Arnd Bergmann wrote:
> Calling the fixed-phy functions when CONFIG_FIXED_PHY=m as a previous
> change tried cannot work if the caller is in built-in code:
> 
> drivers/of/built-in.o: In function `of_phy_register_fixed_link':
> of_reserved_mem.c:(.text+0x85e0): undefined reference to `fixed_phy_register'
> 
> Making of_mdio depend on 'FIXED_PHY || !FIXED_PHY' would solve this
> dependency by enforcing that OF_MDIO itself becomes a loadable module
> when FIXED_PHY=y, but that creates a different dependency as it
> breaks any built-in ethernet driver that uses of_mdio.
> 
> Making FIXED_PHY a bool option also cannot work, since it depends on
> PHYLIB, which again is tristate.
> 
> This version now uses 'select FIXED_PHY' to ensure that the fixed-phy
> portion of of_mdio is not optional. The main downside of this is
> a small increase in code size for cases that do not need fixed phy
> support, but it should avoid all of the link-time problems.
> 
> Signed-off-by: Arnd Bergmann <arnd-r2nGTMty4D4@public.gmane.org>
> Fixes: d1bd330a229f ("of_mdio: Enable fixed PHY support if driver is a module")

Fixes the build errors that I was seeing.  Thanks.

Acked-by: Randy Dunlap <rdunlap-wEGCiKHe2LqWVfeAwA7xHQ@public.gmane.org>


> ---
>  drivers/of/Kconfig      | 1 +
>  drivers/of/of_mdio.c    | 2 --
>  include/linux/of_mdio.h | 8 ++------
>  3 files changed, 3 insertions(+), 8 deletions(-)
> 
> diff --git a/drivers/of/Kconfig b/drivers/of/Kconfig
> index b3bec3aaa45d..bc07ad30c9bf 100644
> --- a/drivers/of/Kconfig
> +++ b/drivers/of/Kconfig
> @@ -74,6 +74,7 @@ config OF_NET
>  config OF_MDIO
>  	def_tristate PHYLIB
>  	depends on PHYLIB
> +	select FIXED_PHY
>  	help
>  	  OpenFirmware MDIO bus (Ethernet PHY) accessors
>  
> diff --git a/drivers/of/of_mdio.c b/drivers/of/of_mdio.c
> index de68707a99c7..e2b50bc12f23 100644
> --- a/drivers/of/of_mdio.c
> +++ b/drivers/of/of_mdio.c
> @@ -361,7 +361,6 @@ struct phy_device *of_phy_attach(struct net_device *dev,
>  }
>  EXPORT_SYMBOL(of_phy_attach);
>  
> -#if IS_ENABLED(CONFIG_FIXED_PHY)
>  /*
>   * of_phy_is_fixed_link() and of_phy_register_fixed_link() must
>   * support two DT bindings:
> @@ -451,4 +450,3 @@ int of_phy_register_fixed_link(struct device_node *np)
>  	return -ENODEV;
>  }
>  EXPORT_SYMBOL(of_phy_register_fixed_link);
> -#endif
> diff --git a/include/linux/of_mdio.h b/include/linux/of_mdio.h
> index 6c8cb9aa4c00..4b04587d0441 100644
> --- a/include/linux/of_mdio.h
> +++ b/include/linux/of_mdio.h
> @@ -25,6 +25,8 @@ struct phy_device *of_phy_attach(struct net_device *dev,
>  
>  extern struct mii_bus *of_mdio_find_bus(struct device_node *mdio_np);
>  extern int of_mdio_parse_addr(struct device *dev, const struct device_node *np);
> +extern int of_phy_register_fixed_link(struct device_node *np);
> +extern bool of_phy_is_fixed_link(struct device_node *np);
>  
>  #else /* CONFIG_OF */
>  static inline int of_mdiobus_register(struct mii_bus *mdio, struct device_node *np)
> @@ -67,12 +69,6 @@ static inline int of_mdio_parse_addr(struct device *dev,
>  {
>  	return -ENOSYS;
>  }
> -#endif /* CONFIG_OF */
> -
> -#if defined(CONFIG_OF) && IS_ENABLED(CONFIG_FIXED_PHY)
> -extern int of_phy_register_fixed_link(struct device_node *np);
> -extern bool of_phy_is_fixed_link(struct device_node *np);
> -#else
>  static inline int of_phy_register_fixed_link(struct device_node *np)
>  {
>  	return -ENOSYS;
> 


-- 
~Randy
--
To unsubscribe from this list: send the line "unsubscribe devicetree" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] of_mdio: select fixed phy support unconditionally
  2016-06-25 17:55   ` Randy Dunlap
@ 2016-06-27  8:17     ` Ben Hutchings
  0 siblings, 0 replies; 5+ messages in thread
From: Ben Hutchings @ 2016-06-27  8:17 UTC (permalink / raw)
  To: Randy Dunlap, Arnd Bergmann, Florian Fainelli
  Cc: Rob Herring, Frank Rowand, David Daney, David S. Miller,
	Andrew Lunn, Sergei Shtylyov, devicetree, linux-kernel, netdev

[-- Attachment #1: Type: text/plain, Size: 165 bytes --]

Acked-by: Ben Hutchings <ben. hutchings@codethink.co.uk>

Thanks for sorting this out.

Ben.
-- 
Sent from my Android device with K-9 Mail. Please excuse my brevity.

[-- Attachment #2: Type: text/html, Size: 195 bytes --]

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] of_mdio: select fixed phy support unconditionally
  2016-06-24  9:24 [PATCH] of_mdio: select fixed phy support unconditionally Arnd Bergmann
       [not found] ` <20160624092450.1507991-1-arnd-r2nGTMty4D4@public.gmane.org>
@ 2016-06-28  9:43 ` David Miller
       [not found]   ` <20160628.054342.1681185612913979373.davem-fT/PcQaiUtIeIZ0/mPfg9Q@public.gmane.org>
  1 sibling, 1 reply; 5+ messages in thread
From: David Miller @ 2016-06-28  9:43 UTC (permalink / raw)
  To: arnd
  Cc: f.fainelli, robh+dt, frowand.list, david.daney, andrew,
	sergei.shtylyov, ben.hutchings, devicetree, linux-kernel, netdev

From: Arnd Bergmann <arnd@arndb.de>
Date: Fri, 24 Jun 2016 11:24:08 +0200

> Calling the fixed-phy functions when CONFIG_FIXED_PHY=m as a previous
> change tried cannot work if the caller is in built-in code:
> 
> drivers/of/built-in.o: In function `of_phy_register_fixed_link':
> of_reserved_mem.c:(.text+0x85e0): undefined reference to `fixed_phy_register'
> 
> Making of_mdio depend on 'FIXED_PHY || !FIXED_PHY' would solve this
> dependency by enforcing that OF_MDIO itself becomes a loadable module
> when FIXED_PHY=y, but that creates a different dependency as it
> breaks any built-in ethernet driver that uses of_mdio.
> 
> Making FIXED_PHY a bool option also cannot work, since it depends on
> PHYLIB, which again is tristate.
> 
> This version now uses 'select FIXED_PHY' to ensure that the fixed-phy
> portion of of_mdio is not optional. The main downside of this is
> a small increase in code size for cases that do not need fixed phy
> support, but it should avoid all of the link-time problems.
> 
> Signed-off-by: Arnd Bergmann <arnd@arndb.de>
> Fixes: d1bd330a229f ("of_mdio: Enable fixed PHY support if driver is a module")

Applied to net-next, thanks Arnd.

In the future, please be explicit about what tree a patch is
targetting by specifying it in your Subject line, as:

	[PATCH net-next] ...

or similar.

Thanks.

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] of_mdio: select fixed phy support unconditionally
       [not found]   ` <20160628.054342.1681185612913979373.davem-fT/PcQaiUtIeIZ0/mPfg9Q@public.gmane.org>
@ 2016-06-28  9:48     ` Arnd Bergmann
  0 siblings, 0 replies; 5+ messages in thread
From: Arnd Bergmann @ 2016-06-28  9:48 UTC (permalink / raw)
  To: David Miller
  Cc: f.fainelli-Re5JQEeQqe8AvxtiuMwx3w,
	robh+dt-DgEjT+Ai2ygdnm+yROfE0A,
	frowand.list-Re5JQEeQqe8AvxtiuMwx3w,
	david.daney-YGCgFSpz5w/QT0dZR+AlfA, andrew-g2DYL2Zd6BY,
	sergei.shtylyov-M4DtvfQ/ZS1MRgGoP+s0PdBPR1lH4CV8,
	ben.hutchings-4yDnlxn2s6sWdaTGBSpHTA,
	devicetree-u79uwXL29TY76Z2rM5mHXA,
	linux-kernel-u79uwXL29TY76Z2rM5mHXA,
	netdev-u79uwXL29TY76Z2rM5mHXA

On Tuesday, June 28, 2016 5:43:42 AM CEST David Miller wrote:
> Applied to net-next, thanks Arnd.
> 
> In the future, please be explicit about what tree a patch is
> targetting by specifying it in your Subject line, as:
> 
>         [PATCH net-next] ...
> 

Sure, will do.

	Arnd

--
To unsubscribe from this list: send the line "unsubscribe devicetree" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2016-06-28  9:48 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-06-24  9:24 [PATCH] of_mdio: select fixed phy support unconditionally Arnd Bergmann
     [not found] ` <20160624092450.1507991-1-arnd-r2nGTMty4D4@public.gmane.org>
2016-06-25 17:55   ` Randy Dunlap
2016-06-27  8:17     ` Ben Hutchings
2016-06-28  9:43 ` David Miller
     [not found]   ` <20160628.054342.1681185612913979373.davem-fT/PcQaiUtIeIZ0/mPfg9Q@public.gmane.org>
2016-06-28  9:48     ` Arnd Bergmann

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).