diff mbox series

rtc: bd70528: fix BD71815 watchdog dependency

Message ID 20210422133307.1710832-1-arnd@kernel.org
State Superseded
Headers show
Series rtc: bd70528: fix BD71815 watchdog dependency | expand

Commit Message

Arnd Bergmann April 22, 2021, 1:32 p.m. UTC
From: Arnd Bergmann <arnd@arndb.de>

The added Kconfig dependency is slightly incorrect, which can
lead to a link failure when the watchdog is a loadable module:

arm-linux-gnueabi-ld: drivers/rtc/rtc-bd70528.o: in function `bd70528_set_rtc_based_timers':
rtc-bd70528.c:(.text+0x6cc): undefined reference to `bd70528_wdt_set'
arm-linux-gnueabi-ld: drivers/rtc/rtc-bd70528.o: in function `bd70528_set_time':
rtc-bd70528.c:(.text+0xaa0): undefined reference to `bd70528_wdt_lock'
arm-linux-gnueabi-ld: rtc-bd70528.c:(.text+0xab8): undefined reference to `bd70528_wdt_unlock'
arm-linux-gnueabi-ld: drivers/rtc/rtc-bd70528.o: in function `bd70528_alm_enable':
rtc-bd70528.c:(.text+0xfc0): undefined reference to `bd70528_wdt_lock'
arm-linux-gnueabi-ld: rtc-bd70528.c:(.text+0x1030): undefined reference to `bd70528_wdt_unlock'

The problem is that it allows to be built-in if any of the other
drivers are built-in, even when the watchdog is a loadable module.

Rework this so that having the watchdog as a loadable module always
forces the rtc to be a module as well instead of built-in, regardless
of the other ones.

Fixes: c56dc069f268 ("rtc: bd70528: Support RTC on ROHM BD71815")
Signed-off-by: Arnd Bergmann <arnd@arndb.de>
---
 drivers/rtc/Kconfig | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

Comments

Guenter Roeck April 22, 2021, 2:22 p.m. UTC | #1
On 4/22/21 6:32 AM, Arnd Bergmann wrote:
> From: Arnd Bergmann <arnd@arndb.de>
> 
> The added Kconfig dependency is slightly incorrect, which can
> lead to a link failure when the watchdog is a loadable module:
> 
> arm-linux-gnueabi-ld: drivers/rtc/rtc-bd70528.o: in function `bd70528_set_rtc_based_timers':
> rtc-bd70528.c:(.text+0x6cc): undefined reference to `bd70528_wdt_set'
> arm-linux-gnueabi-ld: drivers/rtc/rtc-bd70528.o: in function `bd70528_set_time':
> rtc-bd70528.c:(.text+0xaa0): undefined reference to `bd70528_wdt_lock'
> arm-linux-gnueabi-ld: rtc-bd70528.c:(.text+0xab8): undefined reference to `bd70528_wdt_unlock'
> arm-linux-gnueabi-ld: drivers/rtc/rtc-bd70528.o: in function `bd70528_alm_enable':
> rtc-bd70528.c:(.text+0xfc0): undefined reference to `bd70528_wdt_lock'
> arm-linux-gnueabi-ld: rtc-bd70528.c:(.text+0x1030): undefined reference to `bd70528_wdt_unlock'
> 
> The problem is that it allows to be built-in if any of the other
> drivers are built-in, even when the watchdog is a loadable module.
> 
> Rework this so that having the watchdog as a loadable module always
> forces the rtc to be a module as well instead of built-in, regardless
> of the other ones.
> 
> Fixes: c56dc069f268 ("rtc: bd70528: Support RTC on ROHM BD71815")
> Signed-off-by: Arnd Bergmann <arnd@arndb.de>
> ---
>  drivers/rtc/Kconfig | 3 ++-
>  1 file changed, 2 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/rtc/Kconfig b/drivers/rtc/Kconfig
> index d8c13fded164..91cc106e2bf6 100644
> --- a/drivers/rtc/Kconfig
> +++ b/drivers/rtc/Kconfig
> @@ -502,7 +502,8 @@ config RTC_DRV_M41T80_WDT
>  
>  config RTC_DRV_BD70528
>  	tristate "ROHM BD70528, BD71815 and BD71828 PMIC RTC"
> -	depends on MFD_ROHM_BD71828 || MFD_ROHM_BD70528 && (BD70528_WATCHDOG || !BD70528_WATCHDOG)
> +	depends on MFD_ROHM_BD71828 || MFD_ROHM_BD70528 || BD70528_WATCHDOG

Is the "|| BD70528_WATCHDOG" above correct ? Seems odd to me, since
it makes the depend statement true even if neither MFD_ROHM_BD71828
nor MFD_ROHM_BD70528 is enabled.

I think the condition needs to be something like
	depends on (MFD_ROHM_BD71828 || MFD_ROHM_BD70528) && (BD70528_WATCHDOG || !BD70528_WATCHDOG)
or, in two lines,
	depends on MFD_ROHM_BD71828 || MFD_ROHM_BD70528
	depends on BD70528_WATCHDOG || !BD70528_WATCHDOG

Thanks,
Guenter

> +	depends on BD70528_WATCHDOG || !BD70528_WATCHDOG
>  	help
>  	  If you say Y here you will get support for the RTC
>  	  block on ROHM BD70528, BD71815 and BD71828 Power Management IC.
>
Arnd Bergmann April 22, 2021, 3:16 p.m. UTC | #2
On Thu, Apr 22, 2021 at 4:23 PM Guenter Roeck <linux@roeck-us.net> wrote:

> >
> >  config RTC_DRV_BD70528
> >       tristate "ROHM BD70528, BD71815 and BD71828 PMIC RTC"
> > -     depends on MFD_ROHM_BD71828 || MFD_ROHM_BD70528 && (BD70528_WATCHDOG || !BD70528_WATCHDOG)
> > +     depends on MFD_ROHM_BD71828 || MFD_ROHM_BD70528 || BD70528_WATCHDOG
>
> Is the "|| BD70528_WATCHDOG" above correct ? Seems odd to me, since
> it makes the depend statement true even if neither MFD_ROHM_BD71828
> nor MFD_ROHM_BD70528 is enabled.
>
> I think the condition needs to be something like
>         depends on (MFD_ROHM_BD71828 || MFD_ROHM_BD70528) && (BD70528_WATCHDOG || !BD70528_WATCHDOG)
> or, in two lines,
>         depends on MFD_ROHM_BD71828 || MFD_ROHM_BD70528
>         depends on BD70528_WATCHDOG || !BD70528_WATCHDOG

Indeed, I misread this as being used on any of three drivers, but
MFD_ROHM_BD70528/BD70528_WATCHDOG is really the same
thing.

I sent an updated patch.

        Arnd
diff mbox series

Patch

diff --git a/drivers/rtc/Kconfig b/drivers/rtc/Kconfig
index d8c13fded164..91cc106e2bf6 100644
--- a/drivers/rtc/Kconfig
+++ b/drivers/rtc/Kconfig
@@ -502,7 +502,8 @@  config RTC_DRV_M41T80_WDT
 
 config RTC_DRV_BD70528
 	tristate "ROHM BD70528, BD71815 and BD71828 PMIC RTC"
-	depends on MFD_ROHM_BD71828 || MFD_ROHM_BD70528 && (BD70528_WATCHDOG || !BD70528_WATCHDOG)
+	depends on MFD_ROHM_BD71828 || MFD_ROHM_BD70528 || BD70528_WATCHDOG
+	depends on BD70528_WATCHDOG || !BD70528_WATCHDOG
 	help
 	  If you say Y here you will get support for the RTC
 	  block on ROHM BD70528, BD71815 and BD71828 Power Management IC.