public inbox for devicetree@vger.kernel.org
 help / color / mirror / Atom feed
From: Daniel Palmer <daniel@thingy.jp>
To: linusw@kernel.org, brgl@kernel.org, robh@kernel.org,
	saravanak@kernel.org, linux-gpio@vger.kernel.org,
	devicetree@vger.kernel.org
Cc: linux-kernel@vger.kernel.org, Daniel Palmer <daniel@thingy.jp>
Subject: [RFC PATCH 2/2] gpiolib: of: Remove a bunch of compatible checks for spi controllers you don't have
Date: Wed,  7 Jan 2026 12:07:31 +0900	[thread overview]
Message-ID: <20260107030731.1838823-3-daniel@thingy.jp> (raw)
In-Reply-To: <20260107030731.1838823-1-daniel@thingy.jp>

Use of_device_is_possible_and_compatible() + The kconfig symbols that should indicate
if the compatibles being checked are even possible to allow the compiler to totally
remove the code for most users.

Signed-off-by: Daniel Palmer <daniel@thingy.jp>
---
 drivers/gpio/gpiolib-of.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/drivers/gpio/gpiolib-of.c b/drivers/gpio/gpiolib-of.c
index 8657379e9165..2c87f1fa1f95 100644
--- a/drivers/gpio/gpiolib-of.c
+++ b/drivers/gpio/gpiolib-of.c
@@ -93,9 +93,9 @@ static int of_gpio_spi_cs_get_count(const struct device_node *np,
 		return 0;
 	if (!con_id || strcmp(con_id, "cs"))
 		return 0;
-	if (!of_device_is_compatible(np, "fsl,spi") &&
-	    !of_device_is_compatible(np, "aeroflexgaisler,spictrl") &&
-	    !of_device_is_compatible(np, "ibm,ppc4xx-spi"))
+	if (!of_device_is_possible_and_compatible(CONFIG_SPI_FSL_SPI, np, "fsl,spi") &&
+	    !of_device_is_possible_and_compatible(CONFIG_SPI_FSL_SPI, np, "aeroflexgaisler,spictrl") &&
+	    !of_device_is_possible_and_compatible(CONFIG_SPI_PPC4xx, np, "ibm,ppc4xx-spi"))
 		return 0;
 	return of_gpio_named_count(np, "gpios");
 }
-- 
2.51.0


  parent reply	other threads:[~2026-01-07  3:07 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-01-07  3:07 [RFC PATCH 0/2] Let the compiler remove unneeded compatible checks Daniel Palmer
2026-01-07  3:07 ` [RFC PATCH 1/2] of: Add a variant of of_device_is_compatible() that can be build time culled Daniel Palmer
2026-01-08 23:38   ` Rob Herring
2026-01-09  2:51     ` Daniel Palmer
2026-01-09 14:29       ` Rob Herring
2026-01-12  2:32         ` Saravana Kannan
2026-01-12  3:10           ` Daniel Palmer
2026-01-11 10:59       ` Linus Walleij
2026-01-07  3:07 ` Daniel Palmer [this message]
2026-01-07  8:17 ` [RFC PATCH 0/2] Let the compiler remove unneeded compatible checks Bartosz Golaszewski

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20260107030731.1838823-3-daniel@thingy.jp \
    --to=daniel@thingy.jp \
    --cc=brgl@kernel.org \
    --cc=devicetree@vger.kernel.org \
    --cc=linusw@kernel.org \
    --cc=linux-gpio@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=robh@kernel.org \
    --cc=saravanak@kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox