[PATCH 3/7] MIPS: csrc-r4k: Replace CONFIG_GENERIC_GETTIMEOFDAY ifdeffery with IS_ENABLED()

Thomas Weißschuh thomas.weissschuh at linutronix.de
Wed Jul 15 01:43:57 PDT 2026


On Wed, Jul 15, 2026 at 10:25:19AM +0200, Thomas Gleixner wrote:
> On Thu, Jul 09 2026 at 13:32, Thomas Weißschuh wrote:
> > Now that there is a dummy declaration of VDSO_CLOCKMODE_R4K, even if no
> > vDSO is built, the ugly ifdeffery can be replaced with a cleaner
> > IS_ENABLED() check.
> 
> Duh. This stuff is really obfuscated. I just realized that the previous
> one actually expands the architecture defines to non-defined integer
> variable declarations.
> 
> Smart, but seriously?
> 
> I just double checked and it turns out that none of this ifdeffery is
> required. If CONFIG_GENERIC_GETTIMEOFDAY is disabled, then it does not
> matter at all whether the actual ARCH_CLOCK_VDSO_MODE is set in
> clocksource::vdso_mode or not.
> 
> Nothing uses the vdso mode field outside of update_vsyscall and that's
> compiled out when CONFIG_GENERIC_GETTIMEOFDAY=n.

__clocksource_register_scale() does.

> So all what's required is:
> 
> --- a/include/vdso/clocksource.h
> +++ b/include/vdso/clocksource.h
> @@ -3,14 +3,11 @@
>  #define __VDSO_CLOCKSOURCE_H
>  
>  #include <vdso/limits.h>
> -
> -#ifdef CONFIG_GENERIC_GETTIMEOFDAY
>  #include <asm/vdso/clocksource.h>
> -#endif /* CONFIG_GENERIC_GETTIMEOFDAY */
>  enum vdso_clock_mode {
>  	VDSO_CLOCKMODE_NONE,
> -#ifdef CONFIG_GENERIC_GETTIMEOFDAY
> +#ifdef VDSO_ARCH_CLOCKMODES
>  	VDSO_ARCH_CLOCKMODES,
>  #endif
>  	VDSO_CLOCKMODE_MAX,
> 
> and then you can just unconditionally set clocksource::vdso_clock_mode
> in all drivers.
> 
> No?

It will weaken the sanity check in __clocksouce_register_scale() if
CONFIG_GENERIC_GETTIMEOFDAY=n. I am not sure what that sanity check
is supposed to protect against, so I left it as is.
If we can weaken the check, or maybe even remove it,
I'm all for your simpler aproach.


Thomas



More information about the linux-riscv mailing list