diff mbox series

sunxi: fix build when CONFIG_UART0_PORT_F is selected

Message ID 20220304160601.181155-1-icenowy@aosc.io
State Superseded
Delegated to: Andre Przywara
Headers show
Series sunxi: fix build when CONFIG_UART0_PORT_F is selected | expand

Commit Message

Icenowy Zheng March 4, 2022, 4:06 p.m. UTC
Currently CONFIG_UART0_PORT_F will forbid the build of sunxi-mmc driver,
which leads calls to it in board/sunxi/board.c a undefined reference.

Guard that code in #ifndef to fix build.

Signed-off-by: Icenowy Zheng <icenowy@aosc.io>
---
 board/sunxi/board.c | 2 ++
 1 file changed, 2 insertions(+)

Comments

Andre Przywara March 5, 2022, 9:33 p.m. UTC | #1
On Sat,  5 Mar 2022 00:06:01 +0800
Icenowy Zheng <icenowy@aosc.io> wrote:

Hi Icenowy,

> Currently CONFIG_UART0_PORT_F will forbid the build of sunxi-mmc driver,
> which leads calls to it in board/sunxi/board.c a undefined reference.
> 
> Guard that code in #ifndef to fix build.

That's indeed a problem.

> Signed-off-by: Icenowy Zheng <icenowy@aosc.io>
> ---
>  board/sunxi/board.c | 2 ++
>  1 file changed, 2 insertions(+)
> 
> diff --git a/board/sunxi/board.c b/board/sunxi/board.c
> index 82c52b28f8..8a003d8559 100644
> --- a/board/sunxi/board.c
> +++ b/board/sunxi/board.c
> @@ -539,6 +539,7 @@ int board_mmc_init(struct bd_info *bis)
>  {
>  	__maybe_unused struct mmc *mmc0, *mmc1;
>  
> +#ifndef CONFIG_UART0_PORT_F

Shouldn't it be "#ifdef CONFIG_MMC_SUNXI" instead, which is the actual
reason for the build fail?
And furthermore, this is just a link failure, and I think we rely on
toolchain garbage collection anyway, so I managed with:

	if (!CONFIG_IS_ENABLED(MMC_SUNXI))
		return 0;

which avoids the nested #ifdef.
Shall we go with this instead?

>  	mmc_pinmux_setup(CONFIG_MMC_SUNXI_SLOT);
>  	mmc0 = sunxi_mmc_init(CONFIG_MMC_SUNXI_SLOT);
>  	if (!mmc0)
> @@ -549,6 +550,7 @@ int board_mmc_init(struct bd_info *bis)
>  	mmc1 = sunxi_mmc_init(CONFIG_MMC_SUNXI_SLOT_EXTRA);
>  	if (!mmc1)
>  		return -1;
> +#endif
>  #endif
>  
>  	return 0;
Icenowy Zheng March 6, 2022, 2:29 p.m. UTC | #2
在 2022-03-05星期六的 21:33 +0000,Andre Przywara写道:
> On Sat,  5 Mar 2022 00:06:01 +0800
> Icenowy Zheng <icenowy@aosc.io> wrote:
> 
> Hi Icenowy,
> 
> > Currently CONFIG_UART0_PORT_F will forbid the build of sunxi-mmc
> > driver,
> > which leads calls to it in board/sunxi/board.c a undefined
> > reference.
> > 
> > Guard that code in #ifndef to fix build.
> 
> That's indeed a problem.
> 
> > Signed-off-by: Icenowy Zheng <icenowy@aosc.io>
> > ---
> >  board/sunxi/board.c | 2 ++
> >  1 file changed, 2 insertions(+)
> > 
> > diff --git a/board/sunxi/board.c b/board/sunxi/board.c
> > index 82c52b28f8..8a003d8559 100644
> > --- a/board/sunxi/board.c
> > +++ b/board/sunxi/board.c
> > @@ -539,6 +539,7 @@ int board_mmc_init(struct bd_info *bis)
> >  {
> >         __maybe_unused struct mmc *mmc0, *mmc1;
> >  
> > +#ifndef CONFIG_UART0_PORT_F
> 
> Shouldn't it be "#ifdef CONFIG_MMC_SUNXI" instead, which is the
> actual
> reason for the build fail?
> And furthermore, this is just a link failure, and I think we rely on
> toolchain garbage collection anyway, so I managed with:

Well I think we finally shouldn't let CONFIG_UART0_PORT_F conflicts
with CONFIG_MMC_SUNXI, because we should be able to at least use
CONFIG_MMC_SUNXI_SLOT_EXTRA when CONFIG_UART0_PORT_F.

In addition, I don't think toolchain GC is smart enough to remove a
reference.

> 
>         if (!CONFIG_IS_ENABLED(MMC_SUNXI))
>                 return 0;
> 
> which avoids the nested #ifdef.
> Shall we go with this instead?
> 
> >         mmc_pinmux_setup(CONFIG_MMC_SUNXI_SLOT);
> >         mmc0 = sunxi_mmc_init(CONFIG_MMC_SUNXI_SLOT);
> >         if (!mmc0)
> > @@ -549,6 +550,7 @@ int board_mmc_init(struct bd_info *bis)
> >         mmc1 = sunxi_mmc_init(CONFIG_MMC_SUNXI_SLOT_EXTRA);
> >         if (!mmc1)
> >                 return -1;
> > +#endif
> >  #endif
> >  
> >         return 0;
>
diff mbox series

Patch

diff --git a/board/sunxi/board.c b/board/sunxi/board.c
index 82c52b28f8..8a003d8559 100644
--- a/board/sunxi/board.c
+++ b/board/sunxi/board.c
@@ -539,6 +539,7 @@  int board_mmc_init(struct bd_info *bis)
 {
 	__maybe_unused struct mmc *mmc0, *mmc1;
 
+#ifndef CONFIG_UART0_PORT_F
 	mmc_pinmux_setup(CONFIG_MMC_SUNXI_SLOT);
 	mmc0 = sunxi_mmc_init(CONFIG_MMC_SUNXI_SLOT);
 	if (!mmc0)
@@ -549,6 +550,7 @@  int board_mmc_init(struct bd_info *bis)
 	mmc1 = sunxi_mmc_init(CONFIG_MMC_SUNXI_SLOT_EXTRA);
 	if (!mmc1)
 		return -1;
+#endif
 #endif
 
 	return 0;