Re: [PATCH] include: mdio: Guard inline function with CONFIG_MDIO

From: Alistair Francis
Date: Mon Nov 04 2024 - 19:22:18 EST


On Mon, Nov 4, 2024 at 11:49 PM Andrew Lunn <andrew@xxxxxxx> wrote:
>
> On Mon, Nov 04, 2024 at 05:09:50PM +1000, Alistair Francis wrote:
> > The static inline functions mdio45_ethtool_gset() and
> > mdio45_ethtool_ksettings_get() call mdio45_ethtool_gset_npage() and
> > mdio45_ethtool_ksettings_get_npage() which are both guarded by
> > CONFIG_MDIO. So let's only expose mdio45_ethtool_gset() and
> > mdio45_ethtool_ksettings_get() if CONFIG_MDIO is defined.
>
> Why? Are you fixing a linker error? A compiler error?

I'm investigating generating Rust bindings for static inline functions
(like mdio45_ethtool_gset() for example). But it fails to build when
there are functions defined in header files that call C functions that
aren't built due to Kconfig options.

This is one of those cases where mdio45_ethtool_gset() is always
included, but mdio45_ethtool_gset_npage() is conditionally built.

Alistair

>
> In general, we don't want #ifdef if they are not necessary, because
> they reduce the effectiveness of build testing.
>
> Andrew