pwm: fi pwm-rz-mtu3.c build errors

Message ID 8a4de6c6-8d7c-a115-2a14-d264d6d28ccf@gmail.com
State New
Headers
Series pwm: fi pwm-rz-mtu3.c build errors |

Commit Message

Randy Dunlap July 18, 2023, 5:59 a.m. UTC
  From: Randy Dunlap <rdunlap@infradead.org>

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 <rdunlap@infradead.org>
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
---
 drivers/pwm/Kconfig |    3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
  

Comments

Biju Das July 18, 2023, 6:37 a.m. UTC | #1
Hi Randy Dunlap,

Thanks for the feedback.

> Subject: [PATCH] pwm: fi pwm-rz-mtu3.c build errors
> 
> From: Randy Dunlap <rdunlap@infradead.org>
> 
> When (MFD) RZ_MTU3=m and PWM_RZ_MTU3=y, there are numerous build errors:

Recently added module support for RZ_MTU3[1]. ie, after adding PWM support. 

[1] https://git.kernel.org/pub/scm/linux/kernel/git/next/linux-next.git/commit/?h=next-20230718&id=b8b28b718ddd56e546d44107cf7c57f3a07d7efd

> 
> 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 <rdunlap@infradead.org>
> 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

Reviewed-by: Biju Das <biju.das.jz@bp.renesas.com>

Cheers,
Biju

> ---
>  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
> Renesas
  
Randy Dunlap July 18, 2023, 6:37 a.m. UTC | #2
On 7/17/23 22:59, Randy Dunlap wrote:
> From: Randy Dunlap <rdunlap@infradead.org>
> 
> 
> Fixes: 254d3a727421 ("pwm: Add Renesas RZ/G2L MTU3a PWM driver")
> Signed-off-by: Randy Dunlap <rdunlap@infradead.org>

Oops, I should resend that with corrected email addresses. Sorry.
  
Biju Das July 18, 2023, 6:42 a.m. UTC | #3
> -----Original Message-----
> From: Randy Dunlap <rd.dunlab@gmail.com>
> Sent: Tuesday, July 18, 2023 7:38 AM
> To: linux-kernel@vger.kernel.org; linux-pwm@vger.kernel.org
> Cc: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>; Thierry Reding
> <thierry.reding@gmail.com>; Biju Das <biju.das.jz@bp.renesas.com>
> Subject: Re: [PATCH] pwm: fi pwm-rz-mtu3.c build errors
> 
> On 7/17/23 22:59, Randy Dunlap wrote:
> > From: Randy Dunlap <rdunlap@infradead.org>
> >
> >
> > Fixes: 254d3a727421 ("pwm: Add Renesas RZ/G2L MTU3a PWM driver")
> > Signed-off-by: Randy Dunlap <rdunlap@infradead.org>
> 
> Oops, I should resend that with corrected email addresses. Sorry.

Also typo in patch header "pwm: fi pwm-rz-mtu3.c build errors" ??

Not sure fixes tag should be
b8b28b718ddd ("mfd: Add module build support for RZ/G2L MTU3a")
or
254d3a727421 ("pwm: Add Renesas RZ/G2L MTU3a PWM driver")

Cheers,
Biju
  
Randy Dunlap July 18, 2023, 6:44 a.m. UTC | #4
On 7/17/23 23:42, Biju Das wrote:
> 
> 
>> -----Original Message-----
>> From: Randy Dunlap <rd.dunlab@gmail.com>
>> Sent: Tuesday, July 18, 2023 7:38 AM
>> To: linux-kernel@vger.kernel.org; linux-pwm@vger.kernel.org
>> Cc: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>; Thierry Reding
>> <thierry.reding@gmail.com>; Biju Das <biju.das.jz@bp.renesas.com>
>> Subject: Re: [PATCH] pwm: fi pwm-rz-mtu3.c build errors
>>
>> On 7/17/23 22:59, Randy Dunlap wrote:
>>> From: Randy Dunlap <rdunlap@infradead.org>
>>>
>>>
>>> Fixes: 254d3a727421 ("pwm: Add Renesas RZ/G2L MTU3a PWM driver")
>>> Signed-off-by: Randy Dunlap <rdunlap@infradead.org>
>>
>> Oops, I should resend that with corrected email addresses. Sorry.
> 
> Also typo in patch header "pwm: fi pwm-rz-mtu3.c build errors" ??

Yes, I saw & fixed that one.

> Not sure fixes tag should be
> b8b28b718ddd ("mfd: Add module build support for RZ/G2L MTU3a")
> or
> 254d3a727421 ("pwm: Add Renesas RZ/G2L MTU3a PWM driver")

It's the PWM Kconfig entry that is incorrect AFAICT.

thanks.
  
Biju Das July 18, 2023, 6:52 a.m. UTC | #5
Hi Randy Dunlap,

> -----Original Message-----
> From: Randy Dunlap <rd.dunlab@gmail.com>
> Sent: Tuesday, July 18, 2023 7:45 AM
> To: Biju Das <biju.das.jz@bp.renesas.com>; linux-kernel@vger.kernel.org;
> linux-pwm@vger.kernel.org
> Cc: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>; Thierry Reding
> <thierry.reding@gmail.com>
> Subject: Re: [PATCH] pwm: fi pwm-rz-mtu3.c build errors
> 
> On 7/17/23 23:42, Biju Das wrote:
> >
> >
> >> -----Original Message-----
> >> From: Randy Dunlap <rd.dunlab@gmail.com>
> >> Sent: Tuesday, July 18, 2023 7:38 AM
> >> To: linux-kernel@vger.kernel.org; linux-pwm@vger.kernel.org
> >> Cc: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>; Thierry Reding
> >> <thierry.reding@gmail.com>; Biju Das <biju.das.jz@bp.renesas.com>
> >> Subject: Re: [PATCH] pwm: fi pwm-rz-mtu3.c build errors
> >>
> >> On 7/17/23 22:59, Randy Dunlap wrote:
> >>> From: Randy Dunlap <rdunlap@infradead.org>
> >>>
> >>>
> >>> Fixes: 254d3a727421 ("pwm: Add Renesas RZ/G2L MTU3a PWM driver")
> >>> Signed-off-by: Randy Dunlap <rdunlap@infradead.org>
> >>
> >> Oops, I should resend that with corrected email addresses. Sorry.
> >
> > Also typo in patch header "pwm: fi pwm-rz-mtu3.c build errors" ??
> 
> Yes, I saw & fixed that one.
> 
> > Not sure fixes tag should be
> > b8b28b718ddd ("mfd: Add module build support for RZ/G2L MTU3a") or
> > 254d3a727421 ("pwm: Add Renesas RZ/G2L MTU3a PWM driver")
> 
> It's the PWM Kconfig entry that is incorrect AFAICT.

OK got it.

Cheers,
Biju
  
Uwe Kleine-König July 18, 2023, 9 a.m. UTC | #6
Hello,

On Mon, Jul 17, 2023 at 10:59:02PM -0700, Randy Dunlap wrote:
> From: Randy Dunlap <rdunlap@infradead.org>
> 
> 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 <rdunlap@infradead.org>
> 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

While testing here I hit another (unrelated) problem:

drivers/pinctrl/renesas/pinctrl-rzg2l.c: In function ‘rzg2l_gpio_free’:
drivers/pinctrl/renesas/pinctrl-rzg2l.c:917:37: error: ‘struct gpio_chip’ has no member named ‘irq’
  917 |         virq = irq_find_mapping(chip->irq.domain, offset);
      |                                     ^~

Did someone address that one already? I guess PINCTRL_RZG2L should
select GPIOLIB_IRQCHIP. Also RZ_MTU3 should select MFD_CORE as I hit:

	aarch64-linux-gnu-ld: rz-mtu3.c:(.text+0x544): undefined reference to `mfd_remove_devices'

Commit 654c293e1687b31819f9bf1ac71b5a85a8053210 added RZ_MTU3 as bool,
and it's still bool in 254d3a72742. I think the problem started only
with b8b28b718ddd ("mfd: Add module build support for RZ/G2L MTU3a").

The patch looks fine, but the commit log needs some adaption.

The following patch would fix the build failure, too:

diff --git a/include/linux/mfd/rz-mtu3.h b/include/linux/mfd/rz-mtu3.h
index c5173bc06270..4f15c0dead60 100644
--- a/include/linux/mfd/rz-mtu3.h
+++ b/include/linux/mfd/rz-mtu3.h
@@ -151,7 +151,7 @@ struct rz_mtu3 {
 	void *priv_data;
 };
 
-#if IS_ENABLED(CONFIG_RZ_MTU3)
+#if IS_REACHABLE(CONFIG_RZ_MTU3)
 static inline bool rz_mtu3_request_channel(struct rz_mtu3_channel *ch)
 {
 	mutex_lock(&ch->lock);


maybe doing that additionally is a good idea? (Well, not entirely sure
as the above setting then would result in a non-functioning PWM driver.
Maybe that's worse than a build failure?)

Best regards
Uwe
  
Biju Das July 18, 2023, 9:22 a.m. UTC | #7
HI Uwe and Randy,

> -----Original Message-----
> From: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
> Sent: Tuesday, July 18, 2023 10:00 AM
> To: Randy Dunlap <rd.dunlab@gmail.com>
> Cc: linux-kernel@vger.kernel.org; linux-pwm@vger.kernel.org; Thierry
> Reding <thierry.reding@gmail.com>; Biju Das <biju.das.jz@bp.renesas.com>;
> Lee Jones <lee@kernel.org>
> Subject: Re: [PATCH] pwm: fi pwm-rz-mtu3.c build errors
> 
> Hello,
> 
> On Mon, Jul 17, 2023 at 10:59:02PM -0700, Randy Dunlap wrote:
> > From: Randy Dunlap <rdunlap@infradead.org>
> >
> > 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 <rdunlap@infradead.org>
> > 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
> 
> While testing here I hit another (unrelated) problem:
> 
> drivers/pinctrl/renesas/pinctrl-rzg2l.c: In function ‘rzg2l_gpio_free’:
> drivers/pinctrl/renesas/pinctrl-rzg2l.c:917:37: error: ‘struct gpio_chip’
> has no member named ‘irq’
>   917 |         virq = irq_find_mapping(chip->irq.domain, offset);
>       |                                     ^~
> 
> Did someone address that one already? I guess PINCTRL_RZG2L should select
> GPIOLIB_IRQCHIP. Also RZ_MTU3 should select MFD_CORE as I hit:
> 
> 	aarch64-linux-gnu-ld: rz-mtu3.c:(.text+0x544): undefined reference
> to `mfd_remove_devices'
> 
> Commit 654c293e1687b31819f9bf1ac71b5a85a8053210 added RZ_MTU3 as bool, and
> it's still bool in 254d3a72742. I think the problem started only with
> b8b28b718ddd ("mfd: Add module build support for RZ/G2L MTU3a").

So far PWM is build tested with 

RZ_MTU3=y ,  PWM_RZ_MTU3=y and m, RZ_MTU3_CNT = y, m

RZ_MTU3=m ,  PWM_RZ_MTU3=m, RZ_MTU3_CNT = y

But I have n't build tested this configuration
RZ_MTU3=m ,  PWM_RZ_MTU3=y, RZ_MTU3_CNT =y 

This is invalid configuration, as MTU is core driver and PWM/Counter drivers depend upon that

Maybe any one of PWM_RZ_MTU3 or RZ_MTU3_CNT =y, RZ_MTU3 should be selected as y.

Cheers,
Biju

> 
> The patch looks fine, but the commit log needs some adaption.
> 
> The following patch would fix the build failure, too:
> 
> diff --git a/include/linux/mfd/rz-mtu3.h b/include/linux/mfd/rz-mtu3.h
> index c5173bc06270..4f15c0dead60 100644
> --- a/include/linux/mfd/rz-mtu3.h
> +++ b/include/linux/mfd/rz-mtu3.h
> @@ -151,7 +151,7 @@ struct rz_mtu3 {
>  	void *priv_data;
>  };
> 
> -#if IS_ENABLED(CONFIG_RZ_MTU3)
> +#if IS_REACHABLE(CONFIG_RZ_MTU3)
>  static inline bool rz_mtu3_request_channel(struct rz_mtu3_channel *ch)  {
>  	mutex_lock(&ch->lock);
> 
> 
> maybe doing that additionally is a good idea? (Well, not entirely sure as
> the above setting then would result in a non-functioning PWM driver.
> Maybe that's worse than a build failure?)
> 
> Best regards
> Uwe
> 
> --
> Pengutronix e.K.                           | Uwe Kleine-König            |
> Industrial Linux Solutions                 | https://www.pengutronix.de/ |
  
Biju Das July 18, 2023, 11:35 a.m. UTC | #8
Hi Uwe,

Thanks for the feedback.

> -----Original Message-----
> From: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
> Sent: Tuesday, July 18, 2023 10:00 AM
> To: Randy Dunlap <rd.dunlab@gmail.com>
> Cc: linux-kernel@vger.kernel.org; linux-pwm@vger.kernel.org; Thierry
> Reding <thierry.reding@gmail.com>; Biju Das <biju.das.jz@bp.renesas.com>;
> Lee Jones <lee@kernel.org>
> Subject: Re: [PATCH] pwm: fi pwm-rz-mtu3.c build errors
> 
> Hello,
> 
> On Mon, Jul 17, 2023 at 10:59:02PM -0700, Randy Dunlap wrote:
> > From: Randy Dunlap <rdunlap@infradead.org>
> >
> > 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 <rdunlap@infradead.org>
> > 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
> 
> While testing here I hit another (unrelated) problem:
> 
> drivers/pinctrl/renesas/pinctrl-rzg2l.c: In function ‘rzg2l_gpio_free’:
> drivers/pinctrl/renesas/pinctrl-rzg2l.c:917:37: error: ‘struct gpio_chip’
> has no member named ‘irq’
>   917 |         virq = irq_find_mapping(chip->irq.domain, offset);
>       |                                     ^~
> 
> Did someone address that one already? I guess PINCTRL_RZG2L should select
> GPIOLIB_IRQCHIP. Also RZ_MTU3 should select MFD_CORE as I hit:
> 
> 	aarch64-linux-gnu-ld: rz-mtu3.c:(.text+0x544): undefined reference
> to `mfd_remove_devices'


OK, will add "select MFD_CORE" as pointed out.

> 
> Commit 654c293e1687b31819f9bf1ac71b5a85a8053210 added RZ_MTU3 as bool, and
> it's still bool in 254d3a72742. I think the problem started only with
> b8b28b718ddd ("mfd: Add module build support for RZ/G2L MTU3a").
> 
> The patch looks fine, but the commit log needs some adaption.
> 
> The following patch would fix the build failure, too:
> 
> diff --git a/include/linux/mfd/rz-mtu3.h b/include/linux/mfd/rz-mtu3.h
> index c5173bc06270..4f15c0dead60 100644
> --- a/include/linux/mfd/rz-mtu3.h
> +++ b/include/linux/mfd/rz-mtu3.h
> @@ -151,7 +151,7 @@ struct rz_mtu3 {
>  	void *priv_data;
>  };
> 
> -#if IS_ENABLED(CONFIG_RZ_MTU3)
> +#if IS_REACHABLE(CONFIG_RZ_MTU3)
>  static inline bool rz_mtu3_request_channel(struct rz_mtu3_channel *ch)  {
>  	mutex_lock(&ch->lock);
> 
> 
> maybe doing that additionally is a good idea? (Well, not entirely sure as
> the above setting then would result in a non-functioning PWM driver.
> Maybe that's worse than a build failure?)

It makes sense to use IS_REACHABLE over IS_ENABLED in this context.


Also what is your preference for the KConfig solution?

+       depends on RZ_MTU3 || (COMPILE_TEST && RZ_MTU3)

Or

+	depends on COMPILE_TEST
+	depends on RZ_MTU3 || RZ_MTU3=n


Cheers,
Biju
  

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