[v2] pwm: fix pwm-rz-mtu3.c build errors

Message ID ac8d6190-06ae-b538-1293-07efedbfe94e@gmail.com
State New
Headers
Series [v2] pwm: fix pwm-rz-mtu3.c build errors |

Commit Message

Randy Dunlap July 18, 2023, 6:41 a.m. UTC
  From: Randy Dunlap <rd.dunlab@gmail.com>

When (MFD) RZ_MTU3=m and PWM_RZ_MTU3=y, there are numerous build errors:

ld: vmlinux.o: in function `rz_mtu3_pwm_config':
drivers/pwm/pwm-rz-mtu3.c:374: undefined reference to `rz_mtu3_disable'
ld: drivers/pwm/pwm-rz-mtu3.c:377: undefined reference to `rz_mtu3_8bit_ch_write'
ld: vmlinux.o: in function `rz_mtu3_pwm_write_tgr_registers':
drivers/pwm/pwm-rz-mtu3.c:110: undefined reference to `rz_mtu3_16bit_ch_write'
ld: vmlinux.o: in function `rz_mtu3_pwm_config':
drivers/pwm/pwm-rz-mtu3.c:382: undefined reference to `rz_mtu3_8bit_ch_write'
ld: vmlinux.o: in function `rz_mtu3_pwm_write_tgr_registers':
drivers/pwm/pwm-rz-mtu3.c:110: undefined reference to `rz_mtu3_16bit_ch_write'
ld: drivers/pwm/pwm-rz-mtu3.c:111: undefined reference to `rz_mtu3_16bit_ch_write'
ld: vmlinux.o: in function `rz_mtu3_pwm_config':
drivers/pwm/pwm-rz-mtu3.c:397: undefined reference to `rz_mtu3_enable'
ld: vmlinux.o: in function `rz_mtu3_pwm_disable':
drivers/pwm/pwm-rz-mtu3.c:259: undefined reference to `rz_mtu3_8bit_ch_write'
ld: drivers/pwm/pwm-rz-mtu3.c:264: undefined reference to `rz_mtu3_disable'
ld: vmlinux.o: in function `rz_mtu3_pwm_enable':
drivers/pwm/pwm-rz-mtu3.c:230: undefined reference to `rz_mtu3_8bit_ch_write'
ld: drivers/pwm/pwm-rz-mtu3.c:234: undefined reference to `rz_mtu3_8bit_ch_write'
ld: drivers/pwm/pwm-rz-mtu3.c:238: undefined reference to `rz_mtu3_enable'
ld: vmlinux.o: in function `rz_mtu3_pwm_is_ch_enabled':
drivers/pwm/pwm-rz-mtu3.c:155: undefined reference to `rz_mtu3_is_enabled'
ld: drivers/pwm/pwm-rz-mtu3.c:162: undefined reference to `rz_mtu3_8bit_ch_read'
ld: vmlinux.o: in function `rz_mtu3_pwm_read_tgr_registers':
drivers/pwm/pwm-rz-mtu3.c:102: undefined reference to `rz_mtu3_16bit_ch_read'
ld: drivers/pwm/pwm-rz-mtu3.c:102: undefined reference to `rz_mtu3_16bit_ch_read'
ld: drivers/pwm/pwm-rz-mtu3.c:103: undefined reference to `rz_mtu3_16bit_ch_read'
ld: vmlinux.o: in function `rz_mtu3_pwm_get_state':
drivers/pwm/pwm-rz-mtu3.c:296: undefined reference to `rz_mtu3_8bit_ch_read'

Modify the dependencies of PWM_RZ_MTU3 so that COMPILE_TEST is
still allowed but PWM_RZ_MTU3 depends on RZ_MTU3 if it is being built
but also allow the latter not to be built.

Fixes: 254d3a727421 ("pwm: Add Renesas RZ/G2L MTU3a PWM driver")
Signed-off-by: Randy Dunlap <rd.dunlab@gmail.com
Cc: Biju Das <biju.das.jz@bp.renesas.com>
Cc: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
Cc: Thierry Reding <thierry.reding@gmail.com>
Cc: linux-pwm@vger.kernel.org
---
v2: fix typo in Subject;
    correct my email address while infradead.org is down;

 drivers/pwm/Kconfig |    3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
  

Comments

Uwe Kleine-König July 18, 2023, 9:03 a.m. UTC | #1
On Mon, Jul 17, 2023 at 11:41:06PM -0700, Randy Dunlap wrote:
> From: Randy Dunlap <rd.dunlab@gmail.com>
> 
> When (MFD) RZ_MTU3=m and PWM_RZ_MTU3=y, there are numerous build errors:
> 
> ld: vmlinux.o: in function `rz_mtu3_pwm_config':
> drivers/pwm/pwm-rz-mtu3.c:374: undefined reference to `rz_mtu3_disable'
> ld: drivers/pwm/pwm-rz-mtu3.c:377: undefined reference to `rz_mtu3_8bit_ch_write'
> ld: vmlinux.o: in function `rz_mtu3_pwm_write_tgr_registers':
> drivers/pwm/pwm-rz-mtu3.c:110: undefined reference to `rz_mtu3_16bit_ch_write'
> ld: vmlinux.o: in function `rz_mtu3_pwm_config':
> drivers/pwm/pwm-rz-mtu3.c:382: undefined reference to `rz_mtu3_8bit_ch_write'
> ld: vmlinux.o: in function `rz_mtu3_pwm_write_tgr_registers':
> drivers/pwm/pwm-rz-mtu3.c:110: undefined reference to `rz_mtu3_16bit_ch_write'
> ld: drivers/pwm/pwm-rz-mtu3.c:111: undefined reference to `rz_mtu3_16bit_ch_write'
> ld: vmlinux.o: in function `rz_mtu3_pwm_config':
> drivers/pwm/pwm-rz-mtu3.c:397: undefined reference to `rz_mtu3_enable'
> ld: vmlinux.o: in function `rz_mtu3_pwm_disable':
> drivers/pwm/pwm-rz-mtu3.c:259: undefined reference to `rz_mtu3_8bit_ch_write'
> ld: drivers/pwm/pwm-rz-mtu3.c:264: undefined reference to `rz_mtu3_disable'
> ld: vmlinux.o: in function `rz_mtu3_pwm_enable':
> drivers/pwm/pwm-rz-mtu3.c:230: undefined reference to `rz_mtu3_8bit_ch_write'
> ld: drivers/pwm/pwm-rz-mtu3.c:234: undefined reference to `rz_mtu3_8bit_ch_write'
> ld: drivers/pwm/pwm-rz-mtu3.c:238: undefined reference to `rz_mtu3_enable'
> ld: vmlinux.o: in function `rz_mtu3_pwm_is_ch_enabled':
> drivers/pwm/pwm-rz-mtu3.c:155: undefined reference to `rz_mtu3_is_enabled'
> ld: drivers/pwm/pwm-rz-mtu3.c:162: undefined reference to `rz_mtu3_8bit_ch_read'
> ld: vmlinux.o: in function `rz_mtu3_pwm_read_tgr_registers':
> drivers/pwm/pwm-rz-mtu3.c:102: undefined reference to `rz_mtu3_16bit_ch_read'
> ld: drivers/pwm/pwm-rz-mtu3.c:102: undefined reference to `rz_mtu3_16bit_ch_read'
> ld: drivers/pwm/pwm-rz-mtu3.c:103: undefined reference to `rz_mtu3_16bit_ch_read'
> ld: vmlinux.o: in function `rz_mtu3_pwm_get_state':
> drivers/pwm/pwm-rz-mtu3.c:296: undefined reference to `rz_mtu3_8bit_ch_read'
> 
> Modify the dependencies of PWM_RZ_MTU3 so that COMPILE_TEST is
> still allowed but PWM_RZ_MTU3 depends on RZ_MTU3 if it is being built
> but also allow the latter not to be built.
> 
> Fixes: 254d3a727421 ("pwm: Add Renesas RZ/G2L MTU3a PWM driver")
> Signed-off-by: Randy Dunlap <rd.dunlab@gmail.com
> Cc: Biju Das <biju.das.jz@bp.renesas.com>
> Cc: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
> Cc: Thierry Reding <thierry.reding@gmail.com>
> Cc: linux-pwm@vger.kernel.org

I missed this v2 while I still looked at (implicit) v1. The things I
said there still apply for v2. I don't repeat my writings, but here is a
link to the archive with what I wrote:

	https://lore.kernel.org/linux-pwm/20230718090023.wo6m6ffzaifgctkj@pengutronix.de/

Best regards
Uwe
  
Biju Das July 18, 2023, 11:26 a.m. UTC | #2
Hi Randy,

> -----Original Message-----
> From: Randy Dunlap <rd.dunlab@gmail.com>
> Sent: Tuesday, July 18, 2023 7:41 AM
> To: linux-kernel@vger.kernel.org; linux-pwm@vger.kernel.org
> Cc: Biju Das <biju.das.jz@bp.renesas.com>; Thierry Reding
> <thierry.reding@gmail.com>; Uwe Kleine-König <u.kleine-
> koenig@pengutronix.de>
> Subject: [PATCH v2] pwm: fix pwm-rz-mtu3.c build errors
> 
> From: Randy Dunlap <rd.dunlab@gmail.com>
> 
> When (MFD) RZ_MTU3=m and PWM_RZ_MTU3=y, there are numerous build errors:
> 
> ld: vmlinux.o: in function `rz_mtu3_pwm_config':
> drivers/pwm/pwm-rz-mtu3.c:374: undefined reference to `rz_mtu3_disable'
> ld: drivers/pwm/pwm-rz-mtu3.c:377: undefined reference to
> `rz_mtu3_8bit_ch_write'
> ld: vmlinux.o: in function `rz_mtu3_pwm_write_tgr_registers':
> drivers/pwm/pwm-rz-mtu3.c:110: undefined reference to
> `rz_mtu3_16bit_ch_write'
> ld: vmlinux.o: in function `rz_mtu3_pwm_config':
> drivers/pwm/pwm-rz-mtu3.c:382: undefined reference to
> `rz_mtu3_8bit_ch_write'
> ld: vmlinux.o: in function `rz_mtu3_pwm_write_tgr_registers':
> drivers/pwm/pwm-rz-mtu3.c:110: undefined reference to
> `rz_mtu3_16bit_ch_write'
> ld: drivers/pwm/pwm-rz-mtu3.c:111: undefined reference to
> `rz_mtu3_16bit_ch_write'
> ld: vmlinux.o: in function `rz_mtu3_pwm_config':
> drivers/pwm/pwm-rz-mtu3.c:397: undefined reference to `rz_mtu3_enable'
> ld: vmlinux.o: in function `rz_mtu3_pwm_disable':
> drivers/pwm/pwm-rz-mtu3.c:259: undefined reference to
> `rz_mtu3_8bit_ch_write'
> ld: drivers/pwm/pwm-rz-mtu3.c:264: undefined reference to
> `rz_mtu3_disable'
> ld: vmlinux.o: in function `rz_mtu3_pwm_enable':
> drivers/pwm/pwm-rz-mtu3.c:230: undefined reference to
> `rz_mtu3_8bit_ch_write'
> ld: drivers/pwm/pwm-rz-mtu3.c:234: undefined reference to
> `rz_mtu3_8bit_ch_write'
> ld: drivers/pwm/pwm-rz-mtu3.c:238: undefined reference to `rz_mtu3_enable'
> ld: vmlinux.o: in function `rz_mtu3_pwm_is_ch_enabled':
> drivers/pwm/pwm-rz-mtu3.c:155: undefined reference to `rz_mtu3_is_enabled'
> ld: drivers/pwm/pwm-rz-mtu3.c:162: undefined reference to
> `rz_mtu3_8bit_ch_read'
> ld: vmlinux.o: in function `rz_mtu3_pwm_read_tgr_registers':
> drivers/pwm/pwm-rz-mtu3.c:102: undefined reference to
> `rz_mtu3_16bit_ch_read'
> ld: drivers/pwm/pwm-rz-mtu3.c:102: undefined reference to
> `rz_mtu3_16bit_ch_read'
> ld: drivers/pwm/pwm-rz-mtu3.c:103: undefined reference to
> `rz_mtu3_16bit_ch_read'
> ld: vmlinux.o: in function `rz_mtu3_pwm_get_state':
> drivers/pwm/pwm-rz-mtu3.c:296: undefined reference to
> `rz_mtu3_8bit_ch_read'
> 
> Modify the dependencies of PWM_RZ_MTU3 so that COMPILE_TEST is still
> allowed but PWM_RZ_MTU3 depends on RZ_MTU3 if it is being built but also
> allow the latter not to be built.
> 
> Fixes: 254d3a727421 ("pwm: Add Renesas RZ/G2L MTU3a PWM driver")
> Signed-off-by: Randy Dunlap <rd.dunlab@gmail.com
> Cc: Biju Das <biju.das.jz@bp.renesas.com>
> Cc: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
> Cc: Thierry Reding <thierry.reding@gmail.com>
> Cc: linux-pwm@vger.kernel.org
> ---
> v2: fix typo in Subject;
>     correct my email address while infradead.org is down;
> 
>  drivers/pwm/Kconfig |    3 ++-
>  1 file changed, 2 insertions(+), 1 deletion(-)
> 
> diff -- a/drivers/pwm/Kconfig b/drivers/pwm/Kconfig
> --- a/drivers/pwm/Kconfig
> +++ b/drivers/pwm/Kconfig
> @@ -505,7 +505,8 @@ config PWM_ROCKCHIP
> 
>  config PWM_RZ_MTU3
>  	tristate "Renesas RZ/G2L MTU3a PWM Timer support"
> -	depends on RZ_MTU3 || COMPILE_TEST
> +	depends on COMPILE_TEST
> +	depends on RZ_MTU3 || RZ_MTU3=n
>  	depends on HAS_IOMEM
>  	help
>  	  This driver exposes the MTU3a PWM Timer controller found in


The below patch also works fine,

diff --git a/drivers/pwm/Kconfig b/drivers/pwm/Kconfig
index 1c8dbb064ee5..56ab2f4b91fe 100644
--- a/drivers/pwm/Kconfig
+++ b/drivers/pwm/Kconfig
@@ -505,7 +505,7 @@ config PWM_ROCKCHIP
 
 config PWM_RZ_MTU3
        tristate "Renesas RZ/G2L MTU3a PWM Timer support"
-       depends on RZ_MTU3 || COMPILE_TEST
+       depends on RZ_MTU3 || (COMPILE_TEST && RZ_MTU3)
        depends on HAS_IOMEM
        help
          This driver exposes the MTU3a PWM Timer controller found in Renesas


So shall I send this fix instead.

Cheers,
Biju
  
Thierry Reding July 18, 2023, 11:43 a.m. UTC | #3
On Tue, Jul 18, 2023 at 11:26:28AM +0000, Biju Das wrote:
> Hi Randy,
> 
> > -----Original Message-----
> > From: Randy Dunlap <rd.dunlab@gmail.com>
> > Sent: Tuesday, July 18, 2023 7:41 AM
> > To: linux-kernel@vger.kernel.org; linux-pwm@vger.kernel.org
> > Cc: Biju Das <biju.das.jz@bp.renesas.com>; Thierry Reding
> > <thierry.reding@gmail.com>; Uwe Kleine-König <u.kleine-
> > koenig@pengutronix.de>
> > Subject: [PATCH v2] pwm: fix pwm-rz-mtu3.c build errors
> > 
> > From: Randy Dunlap <rd.dunlab@gmail.com>
> > 
> > When (MFD) RZ_MTU3=m and PWM_RZ_MTU3=y, there are numerous build errors:
> > 
> > ld: vmlinux.o: in function `rz_mtu3_pwm_config':
> > drivers/pwm/pwm-rz-mtu3.c:374: undefined reference to `rz_mtu3_disable'
> > ld: drivers/pwm/pwm-rz-mtu3.c:377: undefined reference to
> > `rz_mtu3_8bit_ch_write'
> > ld: vmlinux.o: in function `rz_mtu3_pwm_write_tgr_registers':
> > drivers/pwm/pwm-rz-mtu3.c:110: undefined reference to
> > `rz_mtu3_16bit_ch_write'
> > ld: vmlinux.o: in function `rz_mtu3_pwm_config':
> > drivers/pwm/pwm-rz-mtu3.c:382: undefined reference to
> > `rz_mtu3_8bit_ch_write'
> > ld: vmlinux.o: in function `rz_mtu3_pwm_write_tgr_registers':
> > drivers/pwm/pwm-rz-mtu3.c:110: undefined reference to
> > `rz_mtu3_16bit_ch_write'
> > ld: drivers/pwm/pwm-rz-mtu3.c:111: undefined reference to
> > `rz_mtu3_16bit_ch_write'
> > ld: vmlinux.o: in function `rz_mtu3_pwm_config':
> > drivers/pwm/pwm-rz-mtu3.c:397: undefined reference to `rz_mtu3_enable'
> > ld: vmlinux.o: in function `rz_mtu3_pwm_disable':
> > drivers/pwm/pwm-rz-mtu3.c:259: undefined reference to
> > `rz_mtu3_8bit_ch_write'
> > ld: drivers/pwm/pwm-rz-mtu3.c:264: undefined reference to
> > `rz_mtu3_disable'
> > ld: vmlinux.o: in function `rz_mtu3_pwm_enable':
> > drivers/pwm/pwm-rz-mtu3.c:230: undefined reference to
> > `rz_mtu3_8bit_ch_write'
> > ld: drivers/pwm/pwm-rz-mtu3.c:234: undefined reference to
> > `rz_mtu3_8bit_ch_write'
> > ld: drivers/pwm/pwm-rz-mtu3.c:238: undefined reference to `rz_mtu3_enable'
> > ld: vmlinux.o: in function `rz_mtu3_pwm_is_ch_enabled':
> > drivers/pwm/pwm-rz-mtu3.c:155: undefined reference to `rz_mtu3_is_enabled'
> > ld: drivers/pwm/pwm-rz-mtu3.c:162: undefined reference to
> > `rz_mtu3_8bit_ch_read'
> > ld: vmlinux.o: in function `rz_mtu3_pwm_read_tgr_registers':
> > drivers/pwm/pwm-rz-mtu3.c:102: undefined reference to
> > `rz_mtu3_16bit_ch_read'
> > ld: drivers/pwm/pwm-rz-mtu3.c:102: undefined reference to
> > `rz_mtu3_16bit_ch_read'
> > ld: drivers/pwm/pwm-rz-mtu3.c:103: undefined reference to
> > `rz_mtu3_16bit_ch_read'
> > ld: vmlinux.o: in function `rz_mtu3_pwm_get_state':
> > drivers/pwm/pwm-rz-mtu3.c:296: undefined reference to
> > `rz_mtu3_8bit_ch_read'
> > 
> > Modify the dependencies of PWM_RZ_MTU3 so that COMPILE_TEST is still
> > allowed but PWM_RZ_MTU3 depends on RZ_MTU3 if it is being built but also
> > allow the latter not to be built.
> > 
> > Fixes: 254d3a727421 ("pwm: Add Renesas RZ/G2L MTU3a PWM driver")
> > Signed-off-by: Randy Dunlap <rd.dunlab@gmail.com
> > Cc: Biju Das <biju.das.jz@bp.renesas.com>
> > Cc: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
> > Cc: Thierry Reding <thierry.reding@gmail.com>
> > Cc: linux-pwm@vger.kernel.org
> > ---
> > v2: fix typo in Subject;
> >     correct my email address while infradead.org is down;
> > 
> >  drivers/pwm/Kconfig |    3 ++-
> >  1 file changed, 2 insertions(+), 1 deletion(-)
> > 
> > diff -- a/drivers/pwm/Kconfig b/drivers/pwm/Kconfig
> > --- a/drivers/pwm/Kconfig
> > +++ b/drivers/pwm/Kconfig
> > @@ -505,7 +505,8 @@ config PWM_ROCKCHIP
> > 
> >  config PWM_RZ_MTU3
> >  	tristate "Renesas RZ/G2L MTU3a PWM Timer support"
> > -	depends on RZ_MTU3 || COMPILE_TEST
> > +	depends on COMPILE_TEST
> > +	depends on RZ_MTU3 || RZ_MTU3=n
> >  	depends on HAS_IOMEM
> >  	help
> >  	  This driver exposes the MTU3a PWM Timer controller found in
> 
> 
> The below patch also works fine,
> 
> diff --git a/drivers/pwm/Kconfig b/drivers/pwm/Kconfig
> index 1c8dbb064ee5..56ab2f4b91fe 100644
> --- a/drivers/pwm/Kconfig
> +++ b/drivers/pwm/Kconfig
> @@ -505,7 +505,7 @@ config PWM_ROCKCHIP
>  
>  config PWM_RZ_MTU3
>         tristate "Renesas RZ/G2L MTU3a PWM Timer support"
> -       depends on RZ_MTU3 || COMPILE_TEST
> +       depends on RZ_MTU3 || (COMPILE_TEST && RZ_MTU3)

That's a bit pointless, isn't it? That effectively reduces to just:

	depends on RZ_MTU3

Thierry
  
Geert Uytterhoeven July 18, 2023, 12:05 p.m. UTC | #4
Hi Randy,

On Tue, Jul 18, 2023 at 8:44 AM Randy Dunlap <rd.dunlab@gmail.com> wrote:
> From: Randy Dunlap <rd.dunlab@gmail.com>
>
> When (MFD) RZ_MTU3=m and PWM_RZ_MTU3=y, there are numerous build errors:
>
> ld: vmlinux.o: in function `rz_mtu3_pwm_config':
> drivers/pwm/pwm-rz-mtu3.c:374: undefined reference to `rz_mtu3_disable'
> ld: drivers/pwm/pwm-rz-mtu3.c:377: undefined reference to `rz_mtu3_8bit_ch_write'
> ld: vmlinux.o: in function `rz_mtu3_pwm_write_tgr_registers':
> drivers/pwm/pwm-rz-mtu3.c:110: undefined reference to `rz_mtu3_16bit_ch_write'
> ld: vmlinux.o: in function `rz_mtu3_pwm_config':
> drivers/pwm/pwm-rz-mtu3.c:382: undefined reference to `rz_mtu3_8bit_ch_write'
> ld: vmlinux.o: in function `rz_mtu3_pwm_write_tgr_registers':
> drivers/pwm/pwm-rz-mtu3.c:110: undefined reference to `rz_mtu3_16bit_ch_write'
> ld: drivers/pwm/pwm-rz-mtu3.c:111: undefined reference to `rz_mtu3_16bit_ch_write'
> ld: vmlinux.o: in function `rz_mtu3_pwm_config':
> drivers/pwm/pwm-rz-mtu3.c:397: undefined reference to `rz_mtu3_enable'
> ld: vmlinux.o: in function `rz_mtu3_pwm_disable':
> drivers/pwm/pwm-rz-mtu3.c:259: undefined reference to `rz_mtu3_8bit_ch_write'
> ld: drivers/pwm/pwm-rz-mtu3.c:264: undefined reference to `rz_mtu3_disable'
> ld: vmlinux.o: in function `rz_mtu3_pwm_enable':
> drivers/pwm/pwm-rz-mtu3.c:230: undefined reference to `rz_mtu3_8bit_ch_write'
> ld: drivers/pwm/pwm-rz-mtu3.c:234: undefined reference to `rz_mtu3_8bit_ch_write'
> ld: drivers/pwm/pwm-rz-mtu3.c:238: undefined reference to `rz_mtu3_enable'
> ld: vmlinux.o: in function `rz_mtu3_pwm_is_ch_enabled':
> drivers/pwm/pwm-rz-mtu3.c:155: undefined reference to `rz_mtu3_is_enabled'
> ld: drivers/pwm/pwm-rz-mtu3.c:162: undefined reference to `rz_mtu3_8bit_ch_read'
> ld: vmlinux.o: in function `rz_mtu3_pwm_read_tgr_registers':
> drivers/pwm/pwm-rz-mtu3.c:102: undefined reference to `rz_mtu3_16bit_ch_read'
> ld: drivers/pwm/pwm-rz-mtu3.c:102: undefined reference to `rz_mtu3_16bit_ch_read'
> ld: drivers/pwm/pwm-rz-mtu3.c:103: undefined reference to `rz_mtu3_16bit_ch_read'
> ld: vmlinux.o: in function `rz_mtu3_pwm_get_state':
> drivers/pwm/pwm-rz-mtu3.c:296: undefined reference to `rz_mtu3_8bit_ch_read'
>
> Modify the dependencies of PWM_RZ_MTU3 so that COMPILE_TEST is
> still allowed but PWM_RZ_MTU3 depends on RZ_MTU3 if it is being built
> but also allow the latter not to be built.
>
> Fixes: 254d3a727421 ("pwm: Add Renesas RZ/G2L MTU3a PWM driver")
> Signed-off-by: Randy Dunlap <rd.dunlab@gmail.com

Thanks for your patch!

> --- a/drivers/pwm/Kconfig
> +++ b/drivers/pwm/Kconfig
> @@ -505,7 +505,8 @@ config PWM_ROCKCHIP
>
>  config PWM_RZ_MTU3
>         tristate "Renesas RZ/G2L MTU3a PWM Timer support"
> -       depends on RZ_MTU3 || COMPILE_TEST
> +       depends on COMPILE_TEST

This makes the driver always depend on COMPILE_TEST,
which is definitely not what we want.

> +       depends on RZ_MTU3 || RZ_MTU3=n
>         depends on HAS_IOMEM
>         help
>           This driver exposes the MTU3a PWM Timer controller found in Renesas

Gr{oetje,eeting}s,

                        Geert
  
Biju Das July 18, 2023, 12:07 p.m. UTC | #5
Hi Thierry,

Thanks for the feedback.

> -----Original Message-----
> From: Thierry Reding <thierry.reding@gmail.com>
> Sent: Tuesday, July 18, 2023 12:44 PM
> To: Biju Das <biju.das.jz@bp.renesas.com>
> Cc: Randy Dunlap <rd.dunlab@gmail.com>; linux-kernel@vger.kernel.org;
> linux-pwm@vger.kernel.org; Uwe Kleine-König <u.kleine-
> koenig@pengutronix.de>; Fabrizio Castro
> <fabrizio.castro.jz@renesas.com>; lee.jones@linaro.org; Geert
> Uytterhoeven <geert+renesas@glider.be>
> Subject: Re: [PATCH v2] pwm: fix pwm-rz-mtu3.c build errors
> 
> On Tue, Jul 18, 2023 at 11:26:28AM +0000, Biju Das wrote:
> > Hi Randy,
> >
> > > -----Original Message-----
> > > From: Randy Dunlap <rd.dunlab@gmail.com>
> > > Sent: Tuesday, July 18, 2023 7:41 AM
> > > To: linux-kernel@vger.kernel.org; linux-pwm@vger.kernel.org
> > > Cc: Biju Das <biju.das.jz@bp.renesas.com>; Thierry Reding
> > > <thierry.reding@gmail.com>; Uwe Kleine-König <u.kleine-
> > > koenig@pengutronix.de>
> > > Subject: [PATCH v2] pwm: fix pwm-rz-mtu3.c build errors
> > >
> > > From: Randy Dunlap <rd.dunlab@gmail.com>
> > >
> > > When (MFD) RZ_MTU3=m and PWM_RZ_MTU3=y, there are numerous build
> errors:
> > >
> > > ld: vmlinux.o: in function `rz_mtu3_pwm_config':
> > > drivers/pwm/pwm-rz-mtu3.c:374: undefined reference to
> `rz_mtu3_disable'
> > > ld: drivers/pwm/pwm-rz-mtu3.c:377: undefined reference to
> > > `rz_mtu3_8bit_ch_write'
> > > ld: vmlinux.o: in function `rz_mtu3_pwm_write_tgr_registers':
> > > drivers/pwm/pwm-rz-mtu3.c:110: undefined reference to
> > > `rz_mtu3_16bit_ch_write'
> > > ld: vmlinux.o: in function `rz_mtu3_pwm_config':
> > > drivers/pwm/pwm-rz-mtu3.c:382: undefined reference to
> > > `rz_mtu3_8bit_ch_write'
> > > ld: vmlinux.o: in function `rz_mtu3_pwm_write_tgr_registers':
> > > drivers/pwm/pwm-rz-mtu3.c:110: undefined reference to
> > > `rz_mtu3_16bit_ch_write'
> > > ld: drivers/pwm/pwm-rz-mtu3.c:111: undefined reference to
> > > `rz_mtu3_16bit_ch_write'
> > > ld: vmlinux.o: in function `rz_mtu3_pwm_config':
> > > drivers/pwm/pwm-rz-mtu3.c:397: undefined reference to
> `rz_mtu3_enable'
> > > ld: vmlinux.o: in function `rz_mtu3_pwm_disable':
> > > drivers/pwm/pwm-rz-mtu3.c:259: undefined reference to
> > > `rz_mtu3_8bit_ch_write'
> > > ld: drivers/pwm/pwm-rz-mtu3.c:264: undefined reference to
> > > `rz_mtu3_disable'
> > > ld: vmlinux.o: in function `rz_mtu3_pwm_enable':
> > > drivers/pwm/pwm-rz-mtu3.c:230: undefined reference to
> > > `rz_mtu3_8bit_ch_write'
> > > ld: drivers/pwm/pwm-rz-mtu3.c:234: undefined reference to
> > > `rz_mtu3_8bit_ch_write'
> > > ld: drivers/pwm/pwm-rz-mtu3.c:238: undefined reference to
> `rz_mtu3_enable'
> > > ld: vmlinux.o: in function `rz_mtu3_pwm_is_ch_enabled':
> > > drivers/pwm/pwm-rz-mtu3.c:155: undefined reference to
> `rz_mtu3_is_enabled'
> > > ld: drivers/pwm/pwm-rz-mtu3.c:162: undefined reference to
> > > `rz_mtu3_8bit_ch_read'
> > > ld: vmlinux.o: in function `rz_mtu3_pwm_read_tgr_registers':
> > > drivers/pwm/pwm-rz-mtu3.c:102: undefined reference to
> > > `rz_mtu3_16bit_ch_read'
> > > ld: drivers/pwm/pwm-rz-mtu3.c:102: undefined reference to
> > > `rz_mtu3_16bit_ch_read'
> > > ld: drivers/pwm/pwm-rz-mtu3.c:103: undefined reference to
> > > `rz_mtu3_16bit_ch_read'
> > > ld: vmlinux.o: in function `rz_mtu3_pwm_get_state':
> > > drivers/pwm/pwm-rz-mtu3.c:296: undefined reference to
> > > `rz_mtu3_8bit_ch_read'
> > >
> > > Modify the dependencies of PWM_RZ_MTU3 so that COMPILE_TEST is still
> > > allowed but PWM_RZ_MTU3 depends on RZ_MTU3 if it is being built but
> > > also allow the latter not to be built.
> > >
> > > Fixes: 254d3a727421 ("pwm: Add Renesas RZ/G2L MTU3a PWM driver")
> > > Signed-off-by: Randy Dunlap <rd.dunlab@gmail.com
> > > Cc: Biju Das <biju.das.jz@bp.renesas.com>
> > > Cc: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
> > > Cc: Thierry Reding <thierry.reding@gmail.com>
> > > Cc: linux-pwm@vger.kernel.org
> > > ---
> > > v2: fix typo in Subject;
> > >     correct my email address while infradead.org is down;
> > >
> > >  drivers/pwm/Kconfig |    3 ++-
> > >  1 file changed, 2 insertions(+), 1 deletion(-)
> > >
> > > diff -- a/drivers/pwm/Kconfig b/drivers/pwm/Kconfig
> > > --- a/drivers/pwm/Kconfig
> > > +++ b/drivers/pwm/Kconfig
> > > @@ -505,7 +505,8 @@ config PWM_ROCKCHIP
> > >
> > >  config PWM_RZ_MTU3
> > >  	tristate "Renesas RZ/G2L MTU3a PWM Timer support"
> > > -	depends on RZ_MTU3 || COMPILE_TEST
> > > +	depends on COMPILE_TEST
> > > +	depends on RZ_MTU3 || RZ_MTU3=n
> > >  	depends on HAS_IOMEM
> > >  	help
> > >  	  This driver exposes the MTU3a PWM Timer controller found in
> >
> >
> > The below patch also works fine,
> >
> > diff --git a/drivers/pwm/Kconfig b/drivers/pwm/Kconfig index
> > 1c8dbb064ee5..56ab2f4b91fe 100644
> > --- a/drivers/pwm/Kconfig
> > +++ b/drivers/pwm/Kconfig
> > @@ -505,7 +505,7 @@ config PWM_ROCKCHIP
> >
> >  config PWM_RZ_MTU3
> >         tristate "Renesas RZ/G2L MTU3a PWM Timer support"
> > -       depends on RZ_MTU3 || COMPILE_TEST
> > +       depends on RZ_MTU3 || (COMPILE_TEST && RZ_MTU3)
> 
> That's a bit pointless, isn't it? That effectively reduces to just:
> 
> 	depends on RZ_MTU3

OK, then Uwe's solution is better.

ie, use the existing "depends on RZ_MTU3 || COMPILE_TEST"

and use

-#if IS_ENABLED(CONFIG_RZ_MTU3)

+#if IS_REACHABLE(CONFIG_RZ_MTU3) in include/linux/mfd/rz-mtu3.h

Cheers,
Biju
  
Fabrizio Castro July 18, 2023, 12:13 p.m. UTC | #6
Hi Randy,

> From: Randy Dunlap <rd.dunlab@gmail.com>
> Subject: [PATCH v2] pwm: fix pwm-rz-mtu3.c build errors
> 
> From: Randy Dunlap <rd.dunlab@gmail.com>
> 
> When (MFD) RZ_MTU3=m and PWM_RZ_MTU3=y, there are numerous build
> errors:
> 
> ld: vmlinux.o: in function `rz_mtu3_pwm_config':
> drivers/pwm/pwm-rz-mtu3.c:374: undefined reference to
> `rz_mtu3_disable'
> ld: drivers/pwm/pwm-rz-mtu3.c:377: undefined reference to
> `rz_mtu3_8bit_ch_write'
> ld: vmlinux.o: in function `rz_mtu3_pwm_write_tgr_registers':
> drivers/pwm/pwm-rz-mtu3.c:110: undefined reference to
> `rz_mtu3_16bit_ch_write'
> ld: vmlinux.o: in function `rz_mtu3_pwm_config':
> drivers/pwm/pwm-rz-mtu3.c:382: undefined reference to
> `rz_mtu3_8bit_ch_write'
> ld: vmlinux.o: in function `rz_mtu3_pwm_write_tgr_registers':
> drivers/pwm/pwm-rz-mtu3.c:110: undefined reference to
> `rz_mtu3_16bit_ch_write'
> ld: drivers/pwm/pwm-rz-mtu3.c:111: undefined reference to
> `rz_mtu3_16bit_ch_write'
> ld: vmlinux.o: in function `rz_mtu3_pwm_config':
> drivers/pwm/pwm-rz-mtu3.c:397: undefined reference to `rz_mtu3_enable'
> ld: vmlinux.o: in function `rz_mtu3_pwm_disable':
> drivers/pwm/pwm-rz-mtu3.c:259: undefined reference to
> `rz_mtu3_8bit_ch_write'
> ld: drivers/pwm/pwm-rz-mtu3.c:264: undefined reference to
> `rz_mtu3_disable'
> ld: vmlinux.o: in function `rz_mtu3_pwm_enable':
> drivers/pwm/pwm-rz-mtu3.c:230: undefined reference to
> `rz_mtu3_8bit_ch_write'
> ld: drivers/pwm/pwm-rz-mtu3.c:234: undefined reference to
> `rz_mtu3_8bit_ch_write'
> ld: drivers/pwm/pwm-rz-mtu3.c:238: undefined reference to
> `rz_mtu3_enable'
> ld: vmlinux.o: in function `rz_mtu3_pwm_is_ch_enabled':
> drivers/pwm/pwm-rz-mtu3.c:155: undefined reference to
> `rz_mtu3_is_enabled'
> ld: drivers/pwm/pwm-rz-mtu3.c:162: undefined reference to
> `rz_mtu3_8bit_ch_read'
> ld: vmlinux.o: in function `rz_mtu3_pwm_read_tgr_registers':
> drivers/pwm/pwm-rz-mtu3.c:102: undefined reference to
> `rz_mtu3_16bit_ch_read'
> ld: drivers/pwm/pwm-rz-mtu3.c:102: undefined reference to
> `rz_mtu3_16bit_ch_read'
> ld: drivers/pwm/pwm-rz-mtu3.c:103: undefined reference to
> `rz_mtu3_16bit_ch_read'
> ld: vmlinux.o: in function `rz_mtu3_pwm_get_state':
> drivers/pwm/pwm-rz-mtu3.c:296: undefined reference to
> `rz_mtu3_8bit_ch_read'
> 
> Modify the dependencies of PWM_RZ_MTU3 so that COMPILE_TEST is
> still allowed but PWM_RZ_MTU3 depends on RZ_MTU3 if it is being built
> but also allow the latter not to be built.
> 
> Fixes: 254d3a727421 ("pwm: Add Renesas RZ/G2L MTU3a PWM driver")
> Signed-off-by: Randy Dunlap <rd.dunlab@gmail.com
> Cc: Biju Das <biju.das.jz@bp.renesas.com>
> Cc: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
> Cc: Thierry Reding <thierry.reding@gmail.com>
> Cc: linux-pwm@vger.kernel.org
> ---
> v2: fix typo in Subject;
>     correct my email address while infradead.org is down;
> 
>  drivers/pwm/Kconfig |    3 ++-
>  1 file changed, 2 insertions(+), 1 deletion(-)
> 
> diff -- a/drivers/pwm/Kconfig b/drivers/pwm/Kconfig
> --- a/drivers/pwm/Kconfig
> +++ b/drivers/pwm/Kconfig
> @@ -505,7 +505,8 @@ config PWM_ROCKCHIP
> 
>  config PWM_RZ_MTU3
>  	tristate "Renesas RZ/G2L MTU3a PWM Timer support"
> -	depends on RZ_MTU3 || COMPILE_TEST
> +	depends on COMPILE_TEST
> +	depends on RZ_MTU3 || RZ_MTU3=n

Isn't this a tautology?

Cheers,
Fab

>  	depends on HAS_IOMEM
>  	help
>  	  This driver exposes the MTU3a PWM Timer controller found in
> Renesas
  
Thierry Reding July 18, 2023, 1:24 p.m. UTC | #7
On Tue, Jul 18, 2023 at 02:05:42PM +0200, Geert Uytterhoeven wrote:
> Hi Randy,
> 
> On Tue, Jul 18, 2023 at 8:44 AM Randy Dunlap <rd.dunlab@gmail.com> wrote:
> > From: Randy Dunlap <rd.dunlab@gmail.com>
> >
> > When (MFD) RZ_MTU3=m and PWM_RZ_MTU3=y, there are numerous build errors:
> >
> > ld: vmlinux.o: in function `rz_mtu3_pwm_config':
> > drivers/pwm/pwm-rz-mtu3.c:374: undefined reference to `rz_mtu3_disable'
> > ld: drivers/pwm/pwm-rz-mtu3.c:377: undefined reference to `rz_mtu3_8bit_ch_write'
> > ld: vmlinux.o: in function `rz_mtu3_pwm_write_tgr_registers':
> > drivers/pwm/pwm-rz-mtu3.c:110: undefined reference to `rz_mtu3_16bit_ch_write'
> > ld: vmlinux.o: in function `rz_mtu3_pwm_config':
> > drivers/pwm/pwm-rz-mtu3.c:382: undefined reference to `rz_mtu3_8bit_ch_write'
> > ld: vmlinux.o: in function `rz_mtu3_pwm_write_tgr_registers':
> > drivers/pwm/pwm-rz-mtu3.c:110: undefined reference to `rz_mtu3_16bit_ch_write'
> > ld: drivers/pwm/pwm-rz-mtu3.c:111: undefined reference to `rz_mtu3_16bit_ch_write'
> > ld: vmlinux.o: in function `rz_mtu3_pwm_config':
> > drivers/pwm/pwm-rz-mtu3.c:397: undefined reference to `rz_mtu3_enable'
> > ld: vmlinux.o: in function `rz_mtu3_pwm_disable':
> > drivers/pwm/pwm-rz-mtu3.c:259: undefined reference to `rz_mtu3_8bit_ch_write'
> > ld: drivers/pwm/pwm-rz-mtu3.c:264: undefined reference to `rz_mtu3_disable'
> > ld: vmlinux.o: in function `rz_mtu3_pwm_enable':
> > drivers/pwm/pwm-rz-mtu3.c:230: undefined reference to `rz_mtu3_8bit_ch_write'
> > ld: drivers/pwm/pwm-rz-mtu3.c:234: undefined reference to `rz_mtu3_8bit_ch_write'
> > ld: drivers/pwm/pwm-rz-mtu3.c:238: undefined reference to `rz_mtu3_enable'
> > ld: vmlinux.o: in function `rz_mtu3_pwm_is_ch_enabled':
> > drivers/pwm/pwm-rz-mtu3.c:155: undefined reference to `rz_mtu3_is_enabled'
> > ld: drivers/pwm/pwm-rz-mtu3.c:162: undefined reference to `rz_mtu3_8bit_ch_read'
> > ld: vmlinux.o: in function `rz_mtu3_pwm_read_tgr_registers':
> > drivers/pwm/pwm-rz-mtu3.c:102: undefined reference to `rz_mtu3_16bit_ch_read'
> > ld: drivers/pwm/pwm-rz-mtu3.c:102: undefined reference to `rz_mtu3_16bit_ch_read'
> > ld: drivers/pwm/pwm-rz-mtu3.c:103: undefined reference to `rz_mtu3_16bit_ch_read'
> > ld: vmlinux.o: in function `rz_mtu3_pwm_get_state':
> > drivers/pwm/pwm-rz-mtu3.c:296: undefined reference to `rz_mtu3_8bit_ch_read'
> >
> > Modify the dependencies of PWM_RZ_MTU3 so that COMPILE_TEST is
> > still allowed but PWM_RZ_MTU3 depends on RZ_MTU3 if it is being built
> > but also allow the latter not to be built.
> >
> > Fixes: 254d3a727421 ("pwm: Add Renesas RZ/G2L MTU3a PWM driver")
> > Signed-off-by: Randy Dunlap <rd.dunlab@gmail.com
> 
> Thanks for your patch!
> 
> > --- a/drivers/pwm/Kconfig
> > +++ b/drivers/pwm/Kconfig
> > @@ -505,7 +505,8 @@ config PWM_ROCKCHIP
> >
> >  config PWM_RZ_MTU3
> >         tristate "Renesas RZ/G2L MTU3a PWM Timer support"
> > -       depends on RZ_MTU3 || COMPILE_TEST
> > +       depends on COMPILE_TEST
> 
> This makes the driver always depend on COMPILE_TEST,
> which is definitely not what we want.

Honestly, do we really need all of this complexity? I have specific
configurations to test all of the PWM drivers to make sure they build.
There's probably edge cases that don't get tested, but sooner or later I
expect some build bot will encounter those and then we can rectify
things. But in many cases that I've seen COMPILE_TEST just happens to do
more harm than good.

Thierry
  
Randy Dunlap July 18, 2023, 2:39 p.m. UTC | #8
On 7/18/23 05:13, Fabrizio Castro wrote:
> Hi Randy,
> 
>> From: Randy Dunlap <rd.dunlab@gmail.com>
>> Subject: [PATCH v2] pwm: fix pwm-rz-mtu3.c build errors
>>
>> From: Randy Dunlap <rd.dunlab@gmail.com>
>>
>> When (MFD) RZ_MTU3=m and PWM_RZ_MTU3=y, there are numerous build
>> errors:
>>
>>
>> Modify the dependencies of PWM_RZ_MTU3 so that COMPILE_TEST is
>> still allowed but PWM_RZ_MTU3 depends on RZ_MTU3 if it is being built
>> but also allow the latter not to be built.
>>
>>  drivers/pwm/Kconfig |    3 ++-
>>  1 file changed, 2 insertions(+), 1 deletion(-)
>>
>> diff -- a/drivers/pwm/Kconfig b/drivers/pwm/Kconfig
>> --- a/drivers/pwm/Kconfig
>> +++ b/drivers/pwm/Kconfig
>> @@ -505,7 +505,8 @@ config PWM_ROCKCHIP
>>
>>  config PWM_RZ_MTU3
>>  	tristate "Renesas RZ/G2L MTU3a PWM Timer support"
>> -	depends on RZ_MTU3 || COMPILE_TEST
>> +	depends on COMPILE_TEST
>> +	depends on RZ_MTU3 || RZ_MTU3=n
> 
> Isn't this a tautology?

Not at all. It's used in Kconfig quite a bit.
This is tristate logic.

It says that if RZ_MTU3 is y/m, PWM_RZ_MTU3 is limited by that.
But if RZ_MTU3 is n, PWM_RZ_MTU3 can be y or m.

Is that clearer?
  
Fabrizio Castro July 18, 2023, 3:07 p.m. UTC | #9
Hi Randy,

> From: Randy Dunlap <rd.dunlab@gmail.com>
> Subject: Re: [PATCH v2] pwm: fix pwm-rz-mtu3.c build errors
> 
> On 7/18/23 05:13, Fabrizio Castro wrote:
> > Hi Randy,
> >
> >> From: Randy Dunlap <rd.dunlab@gmail.com>
> >> Subject: [PATCH v2] pwm: fix pwm-rz-mtu3.c build errors
> >>
> >> From: Randy Dunlap <rd.dunlab@gmail.com>
> >>
> >> When (MFD) RZ_MTU3=m and PWM_RZ_MTU3=y, there are numerous build
> >> errors:
> >>
> >>
> >> Modify the dependencies of PWM_RZ_MTU3 so that COMPILE_TEST is
> >> still allowed but PWM_RZ_MTU3 depends on RZ_MTU3 if it is being
> built
> >> but also allow the latter not to be built.
> >>
> >>  drivers/pwm/Kconfig |    3 ++-
> >>  1 file changed, 2 insertions(+), 1 deletion(-)
> >>
> >> diff -- a/drivers/pwm/Kconfig b/drivers/pwm/Kconfig
> >> --- a/drivers/pwm/Kconfig
> >> +++ b/drivers/pwm/Kconfig
> >> @@ -505,7 +505,8 @@ config PWM_ROCKCHIP
> >>
> >>  config PWM_RZ_MTU3
> >>  	tristate "Renesas RZ/G2L MTU3a PWM Timer support"
> >> -	depends on RZ_MTU3 || COMPILE_TEST
> >> +	depends on COMPILE_TEST
> >> +	depends on RZ_MTU3 || RZ_MTU3=n
> >
> > Isn't this a tautology?
> 
> Not at all. It's used in Kconfig quite a bit.
> This is tristate logic.
> 
> It says that if RZ_MTU3 is y/m, PWM_RZ_MTU3 is limited by that.
> But if RZ_MTU3 is n, PWM_RZ_MTU3 can be y or m.
> 
> Is that clearer?

It is, thanks for the explanation!

Cheers,
Fab

> 
> --
> ~Randy
  
Uwe Kleine-König July 18, 2023, 4:57 p.m. UTC | #10
On Tue, Jul 18, 2023 at 03:24:58PM +0200, Thierry Reding wrote:
> On Tue, Jul 18, 2023 at 02:05:42PM +0200, Geert Uytterhoeven wrote:
> > Hi Randy,
> > 
> > On Tue, Jul 18, 2023 at 8:44 AM Randy Dunlap <rd.dunlab@gmail.com> wrote:
> > > From: Randy Dunlap <rd.dunlab@gmail.com>
> > >
> > > When (MFD) RZ_MTU3=m and PWM_RZ_MTU3=y, there are numerous build errors:
> > >
> > > ld: vmlinux.o: in function `rz_mtu3_pwm_config':
> > > drivers/pwm/pwm-rz-mtu3.c:374: undefined reference to `rz_mtu3_disable'
> > > ld: drivers/pwm/pwm-rz-mtu3.c:377: undefined reference to `rz_mtu3_8bit_ch_write'
> > > ld: vmlinux.o: in function `rz_mtu3_pwm_write_tgr_registers':
> > > drivers/pwm/pwm-rz-mtu3.c:110: undefined reference to `rz_mtu3_16bit_ch_write'
> > > ld: vmlinux.o: in function `rz_mtu3_pwm_config':
> > > drivers/pwm/pwm-rz-mtu3.c:382: undefined reference to `rz_mtu3_8bit_ch_write'
> > > ld: vmlinux.o: in function `rz_mtu3_pwm_write_tgr_registers':
> > > drivers/pwm/pwm-rz-mtu3.c:110: undefined reference to `rz_mtu3_16bit_ch_write'
> > > ld: drivers/pwm/pwm-rz-mtu3.c:111: undefined reference to `rz_mtu3_16bit_ch_write'
> > > ld: vmlinux.o: in function `rz_mtu3_pwm_config':
> > > drivers/pwm/pwm-rz-mtu3.c:397: undefined reference to `rz_mtu3_enable'
> > > ld: vmlinux.o: in function `rz_mtu3_pwm_disable':
> > > drivers/pwm/pwm-rz-mtu3.c:259: undefined reference to `rz_mtu3_8bit_ch_write'
> > > ld: drivers/pwm/pwm-rz-mtu3.c:264: undefined reference to `rz_mtu3_disable'
> > > ld: vmlinux.o: in function `rz_mtu3_pwm_enable':
> > > drivers/pwm/pwm-rz-mtu3.c:230: undefined reference to `rz_mtu3_8bit_ch_write'
> > > ld: drivers/pwm/pwm-rz-mtu3.c:234: undefined reference to `rz_mtu3_8bit_ch_write'
> > > ld: drivers/pwm/pwm-rz-mtu3.c:238: undefined reference to `rz_mtu3_enable'
> > > ld: vmlinux.o: in function `rz_mtu3_pwm_is_ch_enabled':
> > > drivers/pwm/pwm-rz-mtu3.c:155: undefined reference to `rz_mtu3_is_enabled'
> > > ld: drivers/pwm/pwm-rz-mtu3.c:162: undefined reference to `rz_mtu3_8bit_ch_read'
> > > ld: vmlinux.o: in function `rz_mtu3_pwm_read_tgr_registers':
> > > drivers/pwm/pwm-rz-mtu3.c:102: undefined reference to `rz_mtu3_16bit_ch_read'
> > > ld: drivers/pwm/pwm-rz-mtu3.c:102: undefined reference to `rz_mtu3_16bit_ch_read'
> > > ld: drivers/pwm/pwm-rz-mtu3.c:103: undefined reference to `rz_mtu3_16bit_ch_read'
> > > ld: vmlinux.o: in function `rz_mtu3_pwm_get_state':
> > > drivers/pwm/pwm-rz-mtu3.c:296: undefined reference to `rz_mtu3_8bit_ch_read'
> > >
> > > Modify the dependencies of PWM_RZ_MTU3 so that COMPILE_TEST is
> > > still allowed but PWM_RZ_MTU3 depends on RZ_MTU3 if it is being built
> > > but also allow the latter not to be built.
> > >
> > > Fixes: 254d3a727421 ("pwm: Add Renesas RZ/G2L MTU3a PWM driver")
> > > Signed-off-by: Randy Dunlap <rd.dunlab@gmail.com
> > 
> > Thanks for your patch!
> > 
> > > --- a/drivers/pwm/Kconfig
> > > +++ b/drivers/pwm/Kconfig
> > > @@ -505,7 +505,8 @@ config PWM_ROCKCHIP
> > >
> > >  config PWM_RZ_MTU3
> > >         tristate "Renesas RZ/G2L MTU3a PWM Timer support"
> > > -       depends on RZ_MTU3 || COMPILE_TEST
> > > +       depends on COMPILE_TEST
> > 
> > This makes the driver always depend on COMPILE_TEST,
> > which is definitely not what we want.
> 
> Honestly, do we really need all of this complexity? I have specific
> configurations to test all of the PWM drivers to make sure they build.
> There's probably edge cases that don't get tested, but sooner or later I
> expect some build bot will encounter those and then we can rectify
> things. But in many cases that I've seen COMPILE_TEST just happens to do
> more harm than good.

Without COMPILE_TEST you'd need to build at least for the following
archs to build all pwm drivers:

	armv4+5
	armv7
	armv7m
	arm64
	mips
	riscv
	shmobile
	x86

I personally like COMPILE_TEST as it reduces the number of needed test
builds to 1 (I think).

Best regards
Uwe
  
Thierry Reding July 19, 2023, 7:40 a.m. UTC | #11
On Tue, Jul 18, 2023 at 06:57:16PM +0200, Uwe Kleine-König wrote:
> On Tue, Jul 18, 2023 at 03:24:58PM +0200, Thierry Reding wrote:
> > On Tue, Jul 18, 2023 at 02:05:42PM +0200, Geert Uytterhoeven wrote:
> > > Hi Randy,
> > > 
> > > On Tue, Jul 18, 2023 at 8:44 AM Randy Dunlap <rd.dunlab@gmail.com> wrote:
> > > > From: Randy Dunlap <rd.dunlab@gmail.com>
> > > >
> > > > When (MFD) RZ_MTU3=m and PWM_RZ_MTU3=y, there are numerous build errors:
> > > >
> > > > ld: vmlinux.o: in function `rz_mtu3_pwm_config':
> > > > drivers/pwm/pwm-rz-mtu3.c:374: undefined reference to `rz_mtu3_disable'
> > > > ld: drivers/pwm/pwm-rz-mtu3.c:377: undefined reference to `rz_mtu3_8bit_ch_write'
> > > > ld: vmlinux.o: in function `rz_mtu3_pwm_write_tgr_registers':
> > > > drivers/pwm/pwm-rz-mtu3.c:110: undefined reference to `rz_mtu3_16bit_ch_write'
> > > > ld: vmlinux.o: in function `rz_mtu3_pwm_config':
> > > > drivers/pwm/pwm-rz-mtu3.c:382: undefined reference to `rz_mtu3_8bit_ch_write'
> > > > ld: vmlinux.o: in function `rz_mtu3_pwm_write_tgr_registers':
> > > > drivers/pwm/pwm-rz-mtu3.c:110: undefined reference to `rz_mtu3_16bit_ch_write'
> > > > ld: drivers/pwm/pwm-rz-mtu3.c:111: undefined reference to `rz_mtu3_16bit_ch_write'
> > > > ld: vmlinux.o: in function `rz_mtu3_pwm_config':
> > > > drivers/pwm/pwm-rz-mtu3.c:397: undefined reference to `rz_mtu3_enable'
> > > > ld: vmlinux.o: in function `rz_mtu3_pwm_disable':
> > > > drivers/pwm/pwm-rz-mtu3.c:259: undefined reference to `rz_mtu3_8bit_ch_write'
> > > > ld: drivers/pwm/pwm-rz-mtu3.c:264: undefined reference to `rz_mtu3_disable'
> > > > ld: vmlinux.o: in function `rz_mtu3_pwm_enable':
> > > > drivers/pwm/pwm-rz-mtu3.c:230: undefined reference to `rz_mtu3_8bit_ch_write'
> > > > ld: drivers/pwm/pwm-rz-mtu3.c:234: undefined reference to `rz_mtu3_8bit_ch_write'
> > > > ld: drivers/pwm/pwm-rz-mtu3.c:238: undefined reference to `rz_mtu3_enable'
> > > > ld: vmlinux.o: in function `rz_mtu3_pwm_is_ch_enabled':
> > > > drivers/pwm/pwm-rz-mtu3.c:155: undefined reference to `rz_mtu3_is_enabled'
> > > > ld: drivers/pwm/pwm-rz-mtu3.c:162: undefined reference to `rz_mtu3_8bit_ch_read'
> > > > ld: vmlinux.o: in function `rz_mtu3_pwm_read_tgr_registers':
> > > > drivers/pwm/pwm-rz-mtu3.c:102: undefined reference to `rz_mtu3_16bit_ch_read'
> > > > ld: drivers/pwm/pwm-rz-mtu3.c:102: undefined reference to `rz_mtu3_16bit_ch_read'
> > > > ld: drivers/pwm/pwm-rz-mtu3.c:103: undefined reference to `rz_mtu3_16bit_ch_read'
> > > > ld: vmlinux.o: in function `rz_mtu3_pwm_get_state':
> > > > drivers/pwm/pwm-rz-mtu3.c:296: undefined reference to `rz_mtu3_8bit_ch_read'
> > > >
> > > > Modify the dependencies of PWM_RZ_MTU3 so that COMPILE_TEST is
> > > > still allowed but PWM_RZ_MTU3 depends on RZ_MTU3 if it is being built
> > > > but also allow the latter not to be built.
> > > >
> > > > Fixes: 254d3a727421 ("pwm: Add Renesas RZ/G2L MTU3a PWM driver")
> > > > Signed-off-by: Randy Dunlap <rd.dunlab@gmail.com
> > > 
> > > Thanks for your patch!
> > > 
> > > > --- a/drivers/pwm/Kconfig
> > > > +++ b/drivers/pwm/Kconfig
> > > > @@ -505,7 +505,8 @@ config PWM_ROCKCHIP
> > > >
> > > >  config PWM_RZ_MTU3
> > > >         tristate "Renesas RZ/G2L MTU3a PWM Timer support"
> > > > -       depends on RZ_MTU3 || COMPILE_TEST
> > > > +       depends on COMPILE_TEST
> > > 
> > > This makes the driver always depend on COMPILE_TEST,
> > > which is definitely not what we want.
> > 
> > Honestly, do we really need all of this complexity? I have specific
> > configurations to test all of the PWM drivers to make sure they build.
> > There's probably edge cases that don't get tested, but sooner or later I
> > expect some build bot will encounter those and then we can rectify
> > things. But in many cases that I've seen COMPILE_TEST just happens to do
> > more harm than good.
> 
> Without COMPILE_TEST you'd need to build at least for the following
> archs to build all pwm drivers:
> 
> 	armv4+5
> 	armv7
> 	armv7m
> 	arm64
> 	mips
> 	riscv
> 	shmobile

This one is actually ARCH_RENESAS and is armv7.

> 	x86

But yeah, those are the platforms that I build for. It's not terribly
complicated to do since all of the above have publicly available cross-
compilers that are easy to install. Also, most of the time I do
incremental builds, so these are quite quick.

> I personally like COMPILE_TEST as it reduces the number of needed test
> builds to 1 (I think).

Anyway, I wasn't arguing that we should get rid of COMPILE_TEST
altogether, just that for cases like this it doesn't seem worth the
extra complexity. RZ_MTU3 is an MFD and already || COMPILE_TEST, so
we can easily always enable it.

Thierry
  
Uwe Kleine-König July 19, 2023, 10:13 a.m. UTC | #12
Hello,

On Wed, Jul 19, 2023 at 09:40:22AM +0200, Thierry Reding wrote:
> On Tue, Jul 18, 2023 at 06:57:16PM +0200, Uwe Kleine-König wrote:
> > On Tue, Jul 18, 2023 at 03:24:58PM +0200, Thierry Reding wrote:
> > > Honestly, do we really need all of this complexity? I have specific
> > > configurations to test all of the PWM drivers to make sure they build.
> > > There's probably edge cases that don't get tested, but sooner or later I
> > > expect some build bot will encounter those and then we can rectify
> > > things. But in many cases that I've seen COMPILE_TEST just happens to do
> > > more harm than good.
> > 
> > Without COMPILE_TEST you'd need to build at least for the following
> > archs to build all pwm drivers:
> > 
> > 	armv4+5
> > 	armv7
> > 	armv7m
> > 	arm64
> > 	mips
> > 	riscv
> > 	shmobile
> 
> This one is actually ARCH_RENESAS and is armv7.

Oh indeed. ARCH_RENESAS exists for both arm and shmobile. TIL

> > 	x86
> 
> But yeah, those are the platforms that I build for. It's not terribly
> complicated to do since all of the above have publicly available cross-
> compilers that are easy to install. Also, most of the time I do
> incremental builds, so these are quite quick.
> 
> > I personally like COMPILE_TEST as it reduces the number of needed test
> > builds to 1 (I think).
> 
> Anyway, I wasn't arguing that we should get rid of COMPILE_TEST
> altogether, just that for cases like this it doesn't seem worth the
> extra complexity. RZ_MTU3 is an MFD and already || COMPILE_TEST, so
> we can easily always enable it.

Ah, I got that wrong then. I can life with this one.

Best regards
Uwe
  
Biju Das July 19, 2023, 10:18 a.m. UTC | #13
> -----Original Message-----
> From: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
> Sent: Wednesday, July 19, 2023 11:14 AM
> To: Thierry Reding <thierry.reding@gmail.com>
> Cc: Geert Uytterhoeven <geert@linux-m68k.org>; Randy Dunlap
> <rd.dunlab@gmail.com>; linux-kernel@vger.kernel.org; linux-
> pwm@vger.kernel.org; Biju Das <biju.das.jz@bp.renesas.com>
> Subject: Re: [PATCH v2] pwm: fix pwm-rz-mtu3.c build errors
> 
> Hello,
> 
> On Wed, Jul 19, 2023 at 09:40:22AM +0200, Thierry Reding wrote:
> > On Tue, Jul 18, 2023 at 06:57:16PM +0200, Uwe Kleine-König wrote:
> > > On Tue, Jul 18, 2023 at 03:24:58PM +0200, Thierry Reding wrote:
> > > > Honestly, do we really need all of this complexity? I have
> > > > specific configurations to test all of the PWM drivers to make
> sure they build.
> > > > There's probably edge cases that don't get tested, but sooner or
> > > > later I expect some build bot will encounter those and then we can
> > > > rectify things. But in many cases that I've seen COMPILE_TEST just
> > > > happens to do more harm than good.
> > >
> > > Without COMPILE_TEST you'd need to build at least for the following
> > > archs to build all pwm drivers:
> > >
> > > 	armv4+5
> > > 	armv7
> > > 	armv7m
> > > 	arm64
> > > 	mips
> > > 	riscv
> > > 	shmobile
> >
> > This one is actually ARCH_RENESAS and is armv7.
> 
> Oh indeed. ARCH_RENESAS exists for both arm and shmobile. TIL

arm64 and risc-v too. This MTU3 driver should work on RISC-V(RZ/Five) as well(need to test at some point).

Cheers,
Biju

> 
> > > 	x86
> >
> > But yeah, those are the platforms that I build for. It's not terribly
> > complicated to do since all of the above have publicly available
> > cross- compilers that are easy to install. Also, most of the time I do
> > incremental builds, so these are quite quick.
> >
> > > I personally like COMPILE_TEST as it reduces the number of needed
> > > test builds to 1 (I think).
> >
> > Anyway, I wasn't arguing that we should get rid of COMPILE_TEST
> > altogether, just that for cases like this it doesn't seem worth the
> > extra complexity. RZ_MTU3 is an MFD and already || COMPILE_TEST, so we
> > can easily always enable it.
> 
> Ah, I got that wrong then. I can life with this one.
> 
> Best regards
> Uwe
> 
> --
> Pengutronix e.K.                           | Uwe Kleine-König
> |
> Industrial Linux Solutions                 | https://www.pengutronix.de/
> |
  
Geert Uytterhoeven July 19, 2023, 10:20 a.m. UTC | #14
Hi Uwe,

On Wed, Jul 19, 2023 at 12:13 PM Uwe Kleine-König
<u.kleine-koenig@pengutronix.de> wrote:
> On Wed, Jul 19, 2023 at 09:40:22AM +0200, Thierry Reding wrote:
> > On Tue, Jul 18, 2023 at 06:57:16PM +0200, Uwe Kleine-König wrote:
> > > On Tue, Jul 18, 2023 at 03:24:58PM +0200, Thierry Reding wrote:
> > > > Honestly, do we really need all of this complexity? I have specific
> > > > configurations to test all of the PWM drivers to make sure they build.
> > > > There's probably edge cases that don't get tested, but sooner or later I
> > > > expect some build bot will encounter those and then we can rectify
> > > > things. But in many cases that I've seen COMPILE_TEST just happens to do
> > > > more harm than good.
> > >
> > > Without COMPILE_TEST you'd need to build at least for the following
> > > archs to build all pwm drivers:
> > >
> > >     armv4+5
> > >     armv7
> > >     armv7m
> > >     arm64
> > >     mips
> > >     riscv
> > >     shmobile
> >
> > This one is actually ARCH_RENESAS and is armv7.
>
> Oh indeed. ARCH_RENESAS exists for both arm and shmobile. TIL

No, SH-Mobile can be either sh, arm, or both ;-)

ARCH_SHMOBILE is sh.
ARCH_RENESAS is arm, arm64, or riscv.

The Renesas/arm defconfig is called shmobile_defconfig for
historical reasons.

Gr{oetje,eeting}s,

                        Geert
  

Patch

diff -- a/drivers/pwm/Kconfig b/drivers/pwm/Kconfig
--- a/drivers/pwm/Kconfig
+++ b/drivers/pwm/Kconfig
@@ -505,7 +505,8 @@  config PWM_ROCKCHIP
 
 config PWM_RZ_MTU3
 	tristate "Renesas RZ/G2L MTU3a PWM Timer support"
-	depends on RZ_MTU3 || COMPILE_TEST
+	depends on COMPILE_TEST
+	depends on RZ_MTU3 || RZ_MTU3=n
 	depends on HAS_IOMEM
 	help
 	  This driver exposes the MTU3a PWM Timer controller found in Renesas