From nobody Mon Feb 9 05:52:19 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