diff mbox series

net: stmmac: Fix stmmac_mdio_unregister() build errors

Message ID 20230607093440.4131484-1-chenfeiyang@loongson.cn (mailing list archive)
State Rejected
Delegated to: Netdev Maintainers
Headers show
Series net: stmmac: Fix stmmac_mdio_unregister() build errors | expand

Checks

Context Check Description
netdev/series_format warning Single patches do not need cover letters; Target tree name not specified in the subject
netdev/tree_selection success Guessed tree name to be net-next
netdev/fixes_present success Fixes tag not required for -next series
netdev/header_inline success No static functions without inline keyword in header files
netdev/build_32bit success Errors and warnings before: 8 this patch: 8
netdev/cc_maintainers fail 2 blamed authors not CCed: davem@davemloft.net simon.horman@corigine.com; 8 maintainers not CCed: kuba@kernel.org mcoquelin.stm32@gmail.com davem@davemloft.net simon.horman@corigine.com linux-arm-kernel@lists.infradead.org pabeni@redhat.com edumazet@google.com linux-stm32@st-md-mailman.stormreply.com
netdev/build_clang success Errors and warnings before: 8 this patch: 8
netdev/verify_signedoff success Signed-off-by tag matches author and committer
netdev/deprecated_api success None detected
netdev/check_selftest success No net selftest shell script
netdev/verify_fixes success Fixes tag looks correct
netdev/build_allmodconfig_warn success Errors and warnings before: 8 this patch: 8
netdev/checkpatch success total: 0 errors, 0 warnings, 0 checks, 10 lines checked
netdev/kdoc success Errors and warnings before: 0 this patch: 0
netdev/source_inline success Was 0 now: 0

Commit Message

Feiyang Chen June 7, 2023, 9:34 a.m. UTC
When CONFIG_PCS_LYNX is not set, lynx_pcs_destroy() will not be
exported. Add #ifdef CONFIG_PCS_LYNX around that code to avoid
build errors like these:

ld: drivers/net/ethernet/stmicro/stmmac/stmmac_mdio.o: in function `stmmac_mdio_unregister':
stmmac_mdio.c:(.text+0x1440): undefined reference to `lynx_pcs_destroy'

Reported-by: Yanteng Si <siyanteng@loongson.cn>
Fixes: 5d1f3fe7d2d5 ("net: stmmac: dwmac-sogfpga: use the lynx pcs driver")
Signed-off-by: Feiyang Chen <chenfeiyang@loongson.cn>
---
 drivers/net/ethernet/stmicro/stmmac/stmmac_mdio.c | 2 ++
 1 file changed, 2 insertions(+)

Comments

Maciej Fijalkowski June 7, 2023, 11:55 a.m. UTC | #1
On Wed, Jun 07, 2023 at 05:34:40PM +0800, Feiyang Chen wrote:
> When CONFIG_PCS_LYNX is not set, lynx_pcs_destroy() will not be
> exported. Add #ifdef CONFIG_PCS_LYNX around that code to avoid
> build errors like these:
> 
> ld: drivers/net/ethernet/stmicro/stmmac/stmmac_mdio.o: in function `stmmac_mdio_unregister':
> stmmac_mdio.c:(.text+0x1440): undefined reference to `lynx_pcs_destroy'
> 
> Reported-by: Yanteng Si <siyanteng@loongson.cn>
> Fixes: 5d1f3fe7d2d5 ("net: stmmac: dwmac-sogfpga: use the lynx pcs driver")
> Signed-off-by: Feiyang Chen <chenfeiyang@loongson.cn>
> ---
>  drivers/net/ethernet/stmicro/stmmac/stmmac_mdio.c | 2 ++
>  1 file changed, 2 insertions(+)
> 
> diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_mdio.c b/drivers/net/ethernet/stmicro/stmmac/stmmac_mdio.c
> index c784a6731f08..c1a23846a01c 100644
> --- a/drivers/net/ethernet/stmicro/stmmac/stmmac_mdio.c
> +++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_mdio.c
> @@ -665,8 +665,10 @@ int stmmac_mdio_unregister(struct net_device *ndev)
>  	if (priv->hw->xpcs)
>  		xpcs_destroy(priv->hw->xpcs);
>  
> +#ifdef CONFIG_PCS_LYNX

wouldn't it be better to provide a stub of lynx_pcs_destroy() for
!CONFIG_PCS_LYNX ? otherwise all of the users will have to surrounded with
this ifdef.

>  	if (priv->hw->lynx_pcs)
>  		lynx_pcs_destroy(priv->hw->lynx_pcs);
> +#endif
>  
>  	mdiobus_unregister(priv->mii);
>  	priv->mii->priv = NULL;
> -- 
> 2.39.3
> 
>
Maxime Chevallier June 7, 2023, 1:48 p.m. UTC | #2
Hello,

On Wed,  7 Jun 2023 17:34:40 +0800
Feiyang Chen <chenfeiyang@loongson.cn> wrote:

> When CONFIG_PCS_LYNX is not set, lynx_pcs_destroy() will not be
> exported. Add #ifdef CONFIG_PCS_LYNX around that code to avoid
> build errors like these:
> 
> ld: drivers/net/ethernet/stmicro/stmmac/stmmac_mdio.o: in function `stmmac_mdio_unregister':
> stmmac_mdio.c:(.text+0x1440): undefined reference to `lynx_pcs_destroy'

I have sent a series aiming to fix this yesterday [1], which I'll followup today
addressing the last pieces for the fix. Sorry about this,

Maxime

> Reported-by: Yanteng Si <siyanteng@loongson.cn>
> Fixes: 5d1f3fe7d2d5 ("net: stmmac: dwmac-sogfpga: use the lynx pcs driver")
> Signed-off-by: Feiyang Chen <chenfeiyang@loongson.cn>
> ---
>  drivers/net/ethernet/stmicro/stmmac/stmmac_mdio.c | 2 ++
>  1 file changed, 2 insertions(+)
> 
> diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_mdio.c b/drivers/net/ethernet/stmicro/stmmac/stmmac_mdio.c
> index c784a6731f08..c1a23846a01c 100644
> --- a/drivers/net/ethernet/stmicro/stmmac/stmmac_mdio.c
> +++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_mdio.c
> @@ -665,8 +665,10 @@ int stmmac_mdio_unregister(struct net_device *ndev)
>  	if (priv->hw->xpcs)
>  		xpcs_destroy(priv->hw->xpcs);
>  
> +#ifdef CONFIG_PCS_LYNX
>  	if (priv->hw->lynx_pcs)
>  		lynx_pcs_destroy(priv->hw->lynx_pcs);
> +#endif
>  
>  	mdiobus_unregister(priv->mii);
>  	priv->mii->priv = NULL;
Maxime Chevallier June 7, 2023, 2:02 p.m. UTC | #3
Hello,

On Wed, 7 Jun 2023 13:55:41 +0200
Maciej Fijalkowski <maciej.fijalkowski@intel.com> wrote:

> On Wed, Jun 07, 2023 at 05:34:40PM +0800, Feiyang Chen wrote:
> > When CONFIG_PCS_LYNX is not set, lynx_pcs_destroy() will not be
> > exported. Add #ifdef CONFIG_PCS_LYNX around that code to avoid
> > build errors like these:
> > 
> > ld: drivers/net/ethernet/stmicro/stmmac/stmmac_mdio.o: in function `stmmac_mdio_unregister':
> > stmmac_mdio.c:(.text+0x1440): undefined reference to `lynx_pcs_destroy'
> > 
> > Reported-by: Yanteng Si <siyanteng@loongson.cn>
> > Fixes: 5d1f3fe7d2d5 ("net: stmmac: dwmac-sogfpga: use the lynx pcs driver")
> > Signed-off-by: Feiyang Chen <chenfeiyang@loongson.cn>
> > ---
> >  drivers/net/ethernet/stmicro/stmmac/stmmac_mdio.c | 2 ++
> >  1 file changed, 2 insertions(+)
> > 
> > diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_mdio.c b/drivers/net/ethernet/stmicro/stmmac/stmmac_mdio.c
> > index c784a6731f08..c1a23846a01c 100644
> > --- a/drivers/net/ethernet/stmicro/stmmac/stmmac_mdio.c
> > +++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_mdio.c
> > @@ -665,8 +665,10 @@ int stmmac_mdio_unregister(struct net_device *ndev)
> >  	if (priv->hw->xpcs)
> >  		xpcs_destroy(priv->hw->xpcs);
> >  
> > +#ifdef CONFIG_PCS_LYNX  
> 
> wouldn't it be better to provide a stub of lynx_pcs_destroy() for
> !CONFIG_PCS_LYNX ? otherwise all of the users will have to surrounded with
> this ifdef.

I just sent another fix that has been in the works since yesterday :

https://lore.kernel.org/netdev/20230607135941.407054-1-maxime.chevallier@bootlin.com/T/#t

It uses a better solution of only using pcs_lynx-related helpers on dwmac_socfpga,
as this is the only stmmac variant that needs this PCS.

Sorry for the mess,

Maxime

> >  	if (priv->hw->lynx_pcs)
> >  		lynx_pcs_destroy(priv->hw->lynx_pcs);
> > +#endif
> >  
> >  	mdiobus_unregister(priv->mii);
> >  	priv->mii->priv = NULL;
> > -- 
> > 2.39.3
> > 
> >
Simon Horman June 7, 2023, 3:34 p.m. UTC | #4
On Wed, Jun 07, 2023 at 04:02:19PM +0200, Maxime Chevallier wrote:
> Hello,
> 
> On Wed, 7 Jun 2023 13:55:41 +0200
> Maciej Fijalkowski <maciej.fijalkowski@intel.com> wrote:
> 
> > On Wed, Jun 07, 2023 at 05:34:40PM +0800, Feiyang Chen wrote:
> > > When CONFIG_PCS_LYNX is not set, lynx_pcs_destroy() will not be
> > > exported. Add #ifdef CONFIG_PCS_LYNX around that code to avoid
> > > build errors like these:
> > > 
> > > ld: drivers/net/ethernet/stmicro/stmmac/stmmac_mdio.o: in function `stmmac_mdio_unregister':
> > > stmmac_mdio.c:(.text+0x1440): undefined reference to `lynx_pcs_destroy'
> > > 
> > > Reported-by: Yanteng Si <siyanteng@loongson.cn>
> > > Fixes: 5d1f3fe7d2d5 ("net: stmmac: dwmac-sogfpga: use the lynx pcs driver")
> > > Signed-off-by: Feiyang Chen <chenfeiyang@loongson.cn>
> > > ---
> > >  drivers/net/ethernet/stmicro/stmmac/stmmac_mdio.c | 2 ++
> > >  1 file changed, 2 insertions(+)
> > > 
> > > diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_mdio.c b/drivers/net/ethernet/stmicro/stmmac/stmmac_mdio.c
> > > index c784a6731f08..c1a23846a01c 100644
> > > --- a/drivers/net/ethernet/stmicro/stmmac/stmmac_mdio.c
> > > +++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_mdio.c
> > > @@ -665,8 +665,10 @@ int stmmac_mdio_unregister(struct net_device *ndev)
> > >  	if (priv->hw->xpcs)
> > >  		xpcs_destroy(priv->hw->xpcs);
> > >  
> > > +#ifdef CONFIG_PCS_LYNX  
> > 
> > wouldn't it be better to provide a stub of lynx_pcs_destroy() for
> > !CONFIG_PCS_LYNX ? otherwise all of the users will have to surrounded with
> > this ifdef.
> 
> I just sent another fix that has been in the works since yesterday :
> 
> https://lore.kernel.org/netdev/20230607135941.407054-1-maxime.chevallier@bootlin.com/T/#t
> 
> It uses a better solution of only using pcs_lynx-related helpers on dwmac_socfpga,
> as this is the only stmmac variant that needs this PCS.
> 
> Sorry for the mess,
> 
> Maxime

Thanks everyone, and sorry for my part in this mess.
Let's keep working on the solution at the thread above.
diff mbox series

Patch

diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_mdio.c b/drivers/net/ethernet/stmicro/stmmac/stmmac_mdio.c
index c784a6731f08..c1a23846a01c 100644
--- a/drivers/net/ethernet/stmicro/stmmac/stmmac_mdio.c
+++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_mdio.c
@@ -665,8 +665,10 @@  int stmmac_mdio_unregister(struct net_device *ndev)
 	if (priv->hw->xpcs)
 		xpcs_destroy(priv->hw->xpcs);
 
+#ifdef CONFIG_PCS_LYNX
 	if (priv->hw->lynx_pcs)
 		lynx_pcs_destroy(priv->hw->lynx_pcs);
+#endif
 
 	mdiobus_unregister(priv->mii);
 	priv->mii->priv = NULL;