On Wed, Jan 7, 2026 at 4:07 AM Daniel Palmer <daniel@thingy.jp> wrote:
>
> I like devicetree but I dislike the way it removes the compiler's ability
> to remove dead code because the compiler can't know what is in the runtime
> devicetree.
>
> One common pattern is checking if a node is compatible with some compatible
> string that should never happen on the target machine. i.e checking for
> something that only exists on a very specific PPC platform on ARM etc.
>
> For weird people like me that want to run Linux on FPGA softcores, processors
> from 1979 etc it is better to have the most minimal kernel config possible and
> for the compiler to strip out as much unneeded code and data as possible.
>
> The following is my quick hack to add a way to hint to the compiler whether
> a specific compatible check is even possible or not so it can remove deadcode
> and then an example usecase.
>
> I think this is cleaner than #ifdef..#endif all over the place but maybe
> someone has a nicer way to do it.
>
> Daniel Palmer (2):
> of: Add a variant of of_device_is_compatible() that can be build time
> culled
> gpiolib: of: Remove a bunch of compatible checks for spi controllers
> you don't have
>
> drivers/gpio/gpiolib-of.c | 6 +++---
> include/linux/of.h | 2 ++
> 2 files changed, 5 insertions(+), 3 deletions(-)
>
> --
> 2.51.0
>
That is an awesome idea, let's hear what Rob says but for GPIO I'll be
happy to take it.
Bart