[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <CAMRc=Me4HTLTVDG8Z3iZhep3hi+_1C8=mwDG5Rpnq+zAX1HG+g@mail.gmail.com>
Date: Wed, 7 Jan 2026 09:17:26 +0100
From: Bartosz Golaszewski <brgl@...nel.org>
To: Daniel Palmer <daniel@...ngy.jp>
Cc: linusw@...nel.org, robh@...nel.org, saravanak@...nel.org,
linux-gpio@...r.kernel.org, devicetree@...r.kernel.org,
linux-kernel@...r.kernel.org
Subject: Re: [RFC PATCH 0/2] Let the compiler remove unneeded compatible checks.
On Wed, Jan 7, 2026 at 4:07 AM Daniel Palmer <daniel@...ngy.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
Powered by blists - more mailing lists