Re: [PATCH] gpiolib: don't build HTE code with CONFIG_HTE disabled

From: Linus Walleij
Date: Thu Feb 06 2025 - 13:22:26 EST


Hi Bartosz,

On Thu, Feb 6, 2025 at 3:37 PM Bartosz Golaszewski <brgl@xxxxxxxx> wrote:

> From: Bartosz Golaszewski <bartosz.golaszewski@xxxxxxxxxx>
>
> Hardware timestamping is only used on tegra186 platforms but we include
> the code and export the symbols everywhere. Shrink the binary a bit by
> compiling the relevant functions conditionally.
>
> Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@xxxxxxxxxx>

Reviewed-by: Linus Walleij <linus.walleij@xxxxxxxxxx>

> +static inline int gpiod_enable_hw_timestamp_ns(struct gpio_desc *desc,
> + unsigned long flags)
> +{
> +#if !IS_ENABLED(CONFIG_GPIOLIB)
> + WARN_ON(desc);
> +#endif
> + return -ENOSYS;

I think you can just:

if (!IS_ENABLED(CONFIG_GPIOLIB))
WARN_ON()
else
return -ENOSYS;

here, so it's not so ifdeffy.
The compiler will eliminate the second branch.

Yours,
Linus Walleij