From nobody Sun Feb 8 01:31:23 2026 Received: from mail-pg1-f169.google.com (mail-pg1-f169.google.com [209.85.215.169]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 7C26423FC5A for ; Wed, 7 Jan 2026 03:07:48 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.215.169 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1767755270; cv=none; b=l+G8ZVS5zExxnFEYi+PD/k32/vPJaM07RtjYuxjhswP23lhrlIRjkffpQ/IP0IKXahTkK96Fg+zA7t+LejdYaHS3lkclEQW0zFX655BMfVw8RBYr4DceJ+yg49Rc5gFA5TyTDTJ6MI83OSdz3pFWyrlGp99qjJlHPShKN+I1mhs= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1767755270; c=relaxed/simple; bh=pv9Ul14Hhl3C/6tp4wzR+hrKRSItog/0e3CBoNlER7o=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=H6K4cmI9oYDEol6iJdh/IiDW6sKs4TRUHOKH1lYCBEKge1/8JESvqQtUUTQd+KH/0CYWdSNE0zEjs5LQIuLcLlLN13DwA2Zsxc+yLN8YQl/HWFUD4kJ9+zIZJr4PvEfGLzpyNC2e2mr+VmF3S+cOxNcHzj40zYnf+IvhM7/I3Q0= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=thingy.jp; spf=pass smtp.mailfrom=0x0f.com; dkim=pass (1024-bit key) header.d=thingy.jp header.i=@thingy.jp header.b=AvtUVP/T; arc=none smtp.client-ip=209.85.215.169 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=thingy.jp Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=0x0f.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=thingy.jp header.i=@thingy.jp header.b="AvtUVP/T" Received: by mail-pg1-f169.google.com with SMTP id 41be03b00d2f7-c4464dfeae8so1119865a12.3 for ; Tue, 06 Jan 2026 19:07:48 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=thingy.jp; s=google; t=1767755268; x=1768360068; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=u8iCc64Rjmu7gwf6ybOiip/8D2NfZmfyUw4QOx0iSAQ=; b=AvtUVP/TmSpeeB7k0Dl4mX3dYLflcknmJSfNVHblYMTUZXfafaKmxWhLLKhzIQok7A +sh2o8qtYHRLEkBS5JET3IPxB4daTBnSHtBunUG49mGYhq+MPZSMTdfTybnJgW8RXs5S 4clpv/YtBgojFa9RvBKaAHdbB7VDCPA2/5zqI= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1767755268; x=1768360068; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to; bh=u8iCc64Rjmu7gwf6ybOiip/8D2NfZmfyUw4QOx0iSAQ=; b=eo6bGZnV7MhyZliQTEyhXMooxeEhfYDa+EmH18CFtSKp/0EcK7ZB0fEonFIsEQl/17 yn3TnA0Lno6e+21Ip2TXk3gstg0X3mhniFRWyGuggi65OiKyByea1V+yUiGGHK1YDS6p BXS7QEmLGLfmwL06dU2qn/sNzSQPTY/mqcnShvaWit5fD6j0NRZ91MzRG7su3EVUWkxp rt++/C0/bk9+KZJwW58NznKLm8VMH21XawsaDhBQKLbIDLWxer/AkkOhX5HIPT2oT4zF d8poFa8KWoBiMI5KN4fNtg0u6cOI3euBL4GgFy2HCW2O+RGdkrp/1LxOALmR++TGrTCF k0kg== X-Gm-Message-State: AOJu0YwMHbsx/BJYrku5gPDHP7MKp9nqSpSZMkjBxg/nQ7G3xilL3Yyi LEQEhn/TEKcxV3TPGht8sW0QPx+IHT8BrKAnB3KsWNXw8oiTX31MU3x1BGBFloVdPkE= X-Gm-Gg: AY/fxX6Ac62nTRMUOkopEnClWOZIEX8KIvAyvZeqcg5lrJ9WJYEAPWgM8Zaf7SQH3OM L+W9Bwd57Aur/PTfB9/mxMGsc076ZB2qAkS71WYV0XT9TLDR574azU0eyLBzM1G58OpUC+l/GNr SZzK3PvCJyNO1Sd+OTV0+PBs8zo7Jc2d+lsciH26JSU0moIYCK9fjRuL1iCtMsBPC/+K1uYvdcs AIYy1oy2ldSfFz3vrF0rPgiOI/j7VKk+njZTelTd27eS+QfXO+iCHbw/EBT61eDthbwOFPp5bLi 7HpSOGLAE5kJslOiP7D5K2tYEcGnry5BFl6d+kyuYN58FDmW6k5vT6fYc/EvwaHMhT/mbDb5zia UB7Z/BnI9LUYUwTL0Ds+GwYirzuL6LlYD1gCAsTJFhWwPFOPiHyheevtjjD33N0Tmcc43f5H7Ex IrydNe2tSEVAAJ9/4L+oP6A4E1YITcUda6e0p+yPlFFf0Qs7W+IK8C7b2N0j3oDfh7/Tgj2HWCf Iw= X-Google-Smtp-Source: AGHT+IGszkSXtL7GhVTTV5pPCscn1qVDfJim0T8bRvyNHJT7IeORevR9ZW/WKb1oqJD5skkQqiz3Ew== X-Received: by 2002:a17:902:ce88:b0:298:6a79:397b with SMTP id d9443c01a7336-2a3ee4b8d62mr8864915ad.56.1767755267806; Tue, 06 Jan 2026 19:07:47 -0800 (PST) Received: from kinako.work.home.arpa (p1536247-ipxg00c01sizuokaden.shizuoka.ocn.ne.jp. [122.26.212.247]) by smtp.googlemail.com with ESMTPSA id d9443c01a7336-2a3e3cd4bd8sm33694165ad.102.2026.01.06.19.07.45 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 06 Jan 2026 19:07:47 -0800 (PST) From: Daniel Palmer 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 Subject: [RFC PATCH 1/2] of: Add a variant of of_device_is_compatible() that can be build time culled Date: Wed, 7 Jan 2026 12:07:30 +0900 Message-ID: <20260107030731.1838823-2-daniel@thingy.jp> X-Mailer: git-send-email 2.51.0 In-Reply-To: <20260107030731.1838823-1-daniel@thingy.jp> References: <20260107030731.1838823-1-daniel@thingy.jp> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" In a lot of places we are using of_device_is_compatible() to check for quir= ks etc that are simply not possible on some targets, i.e. a piece of hardware that needs special handling is only on one specific ARM machine and your target isn't even ARM. Add of_device_is_possible_and_compatible() that also takes a Kconfig symbol and checks if that is enabled before calling of_device_is_compatible= (). The Kconfig symbol is build time constant and the compiler should remove the call to of_device_is_compatible() if it is unneeded and also remove the data for the compatible string. Another merit of this is that in places were we are checking for quirks outside of drivers themselves, i.e. in the gpio and spi subsystems where some legacy devicetree handling is being handled for specific devices is in the core code, when the drivers that need the quirks are removed their Kconfig symbol should also be removed and it'll be easier to spot that the quirk handling can also go. Signed-off-by: Daniel Palmer --- include/linux/of.h | 2 ++ 1 file changed, 2 insertions(+) diff --git a/include/linux/of.h b/include/linux/of.h index 9bbdcf25a2b4..70be20b0be22 100644 --- a/include/linux/of.h +++ b/include/linux/of.h @@ -358,6 +358,8 @@ extern int of_property_read_string_helper(const struct = device_node *np, const char **out_strs, size_t sz, int index); extern int of_device_is_compatible(const struct device_node *device, const char *); +#define of_device_is_possible_and_compatible(symbol, device, string) \ + (IS_ENABLED(symbol) && of_device_is_compatible(device, string)) extern int of_device_compatible_match(const struct device_node *device, const char *const *compat); extern bool of_device_is_available(const struct device_node *device); --=20 2.51.0 From nobody Sun Feb 8 01:31:23 2026 Received: from mail-pl1-f169.google.com (mail-pl1-f169.google.com [209.85.214.169]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id DD3FB25D53C for ; Wed, 7 Jan 2026 03:07:51 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.214.169 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1767755274; cv=none; b=MaUMvWT869Ay5aZxS85nnMhxdKu2JP/wGux2eDM6B5RGcB2s0+qFCDviNgahWpwLbcJ4KgNApUyPV1+hQ1gGgYFA0RalE8jp93AHn48364wooDYLN80ushXDT2s/KHbGP8ACs9FuQSCxvuceTAxy7DZSBHqaV3SQGjbseY/qB10= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1767755274; c=relaxed/simple; bh=YCtL7XIQ2elQSXG/uJJP3S0gGTQbILzmG4WP4VYHMLY=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=mAANHEEZldKNIiPnnfDYJuert6gQ1v2wuqwPNzdnoWb/41j5VcEq6Jwew3DZpWbjHMt8RNdRij+OLGht7loIUQvd79w6A9hOtXxqqF4CDwJyDAxRIO/T7CKWIhCdrJW9PjApkY2TAyldhgBO9S26vjBQJ8ACsui56Mpct20Og6A= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=thingy.jp; spf=pass smtp.mailfrom=0x0f.com; dkim=pass (1024-bit key) header.d=thingy.jp header.i=@thingy.jp header.b=Qfv24pqE; arc=none smtp.client-ip=209.85.214.169 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=thingy.jp Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=0x0f.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=thingy.jp header.i=@thingy.jp header.b="Qfv24pqE" Received: by mail-pl1-f169.google.com with SMTP id d9443c01a7336-29f0f875bc5so17751845ad.3 for ; Tue, 06 Jan 2026 19:07:51 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=thingy.jp; s=google; t=1767755271; x=1768360071; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=R7ZFdLTnDvnIrydUNeznKuyxON1SPga3Daneut3hK8I=; b=Qfv24pqEWgseRlnjw4P1mHrXUDrBpTvLmsenXQiyWWzG22HUvMRrurXJBzybeyo7bq /TPNkH8vSWsVnQdjDoKIvyaM3w7OTplNWXt0RBSBbPz65/nvPOGskK+h0bYzG7PMFlmg jwrxyDMSGwnJ6pICFK8Gs2wS9hFJ9kpUcCX6o= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1767755271; x=1768360071; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to; bh=R7ZFdLTnDvnIrydUNeznKuyxON1SPga3Daneut3hK8I=; b=TX8T9Se1XDHXysOiHfenbfayNRzpMze247IoAKC1YyzhSh6ZI6dgZ8UU9zdAiXtdy+ F5jsd86tSPyilTWsZZ7toU7b0K2o4rYaD5MyYiCjh1LPhuWHAkoxxnSbx7JWoJyC6ZFM 726OtHijZ5RMhb7WHHgEiKKqvKG14eytx4LP5+DsNj5VTVxZkhG/QVDZCOdqKPxrxntg tmTQsv7I3joPc1qg0fs1g4akrFUdrLWuXh7LWbVBVz7gmZM10B6BZt9TmgQbCnvm00k5 1UshMhOBj96ZJVpEL1Hk6/q+o+QyhpSj3LQotRTEZ3yc9vcQMr7vPIgDJTEIFRizhrUi hbeQ== X-Gm-Message-State: AOJu0YyJSZ9TM3roZSbBQhzBR1UdCk9YcK2IPStnGCjHXc0xBvDXBHu8 40ZCS4FeRm/cFH4HNh9lIkFwz8kg6Omem6yVwacOVqCjL9QD40QYDWVP5mR/IPU6EfA= X-Gm-Gg: AY/fxX7fb04PzVA7Ibvc5k8PzDzvpAyG1XqolHV/6ozrU2hzm/KSUGtvp2f+n6B2s8W wZ0+7y/EmioYVSJIFdziUUMbDsJWh38EygtKVeFseBEGsBImmFBqsjwwflEjJGxP4v5goHIozEl CmNdg2DJOCzuJDt/BvP/GIUGUNw+w379ISPNLR2chN+Xi4Mkee6fGWizh1dfS2sJ41gnoikwAoB BJ0zNArhL/ln4S9euAKe2J9/4fcbLZc1sZ4Vsr/WTwnV9ookW4lLgSIqXjLTYuNjXRBk6zIY5tX hiwRtdS7K4TW8U5XgD5yBgxj9zUXfBdy3bd0ETh5DxGViC8HmO7J5WxqgO7hhVHCs16eA9QHord 5JgCKmg/s0fRgwg/fY0VHVCOzPc0XGosvKyRZ3/pTuz2ed5w9YfznLXXb13kbBzRefTO3fuAWFJ uYOym+IaRJuoBY/TXeLJ2mDmQQux7ybYLtGqFacknU+dj/q6qoLsad6IdaOnik2LvALkdfbYTI1 8w= X-Google-Smtp-Source: AGHT+IEdpj9FBlTpGGiP4vWM+VPJOIFZzgRKvhnaBLXZwRM5iwazxSKJvIV2JHH5i9DicVEy3eXR5Q== X-Received: by 2002:a17:902:f60d:b0:2a0:daa7:8a3d with SMTP id d9443c01a7336-2a3ee47f15amr10294815ad.23.1767755271138; Tue, 06 Jan 2026 19:07:51 -0800 (PST) Received: from kinako.work.home.arpa (p1536247-ipxg00c01sizuokaden.shizuoka.ocn.ne.jp. [122.26.212.247]) by smtp.googlemail.com with ESMTPSA id d9443c01a7336-2a3e3cd4bd8sm33694165ad.102.2026.01.06.19.07.48 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 06 Jan 2026 19:07:50 -0800 (PST) From: Daniel Palmer 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 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 Message-ID: <20260107030731.1838823-3-daniel@thingy.jp> X-Mailer: git-send-email 2.51.0 In-Reply-To: <20260107030731.1838823-1-daniel@thingy.jp> References: <20260107030731.1838823-1-daniel@thingy.jp> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Use of_device_is_possible_and_compatible() + The kconfig symbols that shoul= d 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 --- 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_n= ode *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,sp= i") && + !of_device_is_possible_and_compatible(CONFIG_SPI_FSL_SPI, np, "aerofl= exgaisler,spictrl") && + !of_device_is_possible_and_compatible(CONFIG_SPI_PPC4xx, np, "ibm,ppc= 4xx-spi")) return 0; return of_gpio_named_count(np, "gpios"); } --=20 2.51.0