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

Linus Walleij <[email protected]> Thu, 6 Feb 2025 19:17:05 +0100
Newsgroups dev.linux.lists.timestamp,org.kernel.vger.linux-gpio,org.kernel.vger.linux-kernel
Message-ID <CACRpkdYKY-fZED=ZCjuXD5s0TYYxBsgFwJ2ga-rHkx4k6FE5Bg@mail.gmail.com>
Hi Bartosz,

On Thu, Feb 6, 2025 at 3:37=E2=80=AFPM Bartosz Golaszewski <[email protected]> =
wrote:

> From: Bartosz Golaszewski <[email protected]>
>
> 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 <[email protected]>

Reviewed-by: Linus Walleij <[email protected]>

> +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