From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-pl1-f171.google.com (mail-pl1-f171.google.com [209.85.214.171]) (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 932271DE89A for ; Wed, 7 Jan 2026 03:07:45 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.214.171 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1767755267; cv=none; b=KYc38T5wx9f3F232wPw9nEPhPOPHIbaL4RtwrRV6aZWZ0XqMjeXMk+rlIteJ9DLmBhj8ZTh5z3xjN+1vOcctlfRR81h1HPR5Tgw4oar3zPVKEMPDEngeCOFEAJTaDTcOo1cfFpaDgaVjf8KCPwFqNavf+iBDLL45iBi8d2Qjtbs= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1767755267; c=relaxed/simple; bh=A0Sb/c1+3nyw7j95RoY40IXeaUFjCzQ8wLUD/WKWUhI=; h=From:To:Cc:Subject:Date:Message-ID:MIME-Version; b=dNj9B9Y6mcgMkID5BAeOTcU/0lQJHNXiBYdxeHdduNKQam3+hFYYeMnR0zslKlt5RTs5O5bDlcevFx1DZVpn9s7hfOewrp3/XF7Heog8eIDz6LuQeg6dnf5p32utSSogqrRwgx+rRrPfnuYXUsBn20BLaekJC/d6r5A0jHXtIkg= 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=PwkMHhty; arc=none smtp.client-ip=209.85.214.171 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="PwkMHhty" Received: by mail-pl1-f171.google.com with SMTP id d9443c01a7336-2a0a33d0585so12611215ad.1 for ; Tue, 06 Jan 2026 19:07:45 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=thingy.jp; s=google; t=1767755265; x=1768360065; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=a6Wp5tqQ2i9bGT22Xc5qD8OYwZmiFUbdcsOrP4/XS+c=; b=PwkMHhty09WwvMXPNrbeJ4v4BaOvVJbOOiB8NFy2WpffWg4fLBO9kZZZ07nbfa4MGo 965cgpFvx1tSlfYtHUfdW+TefccBKnwSWm4tVSyPJRNiOs79040qxOGp/SuuMiKmYUV6 T5xuLjCKwANkMICTQO7VDXzTeiRV1mWUakuRQ= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1767755265; x=1768360065; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-gg:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=a6Wp5tqQ2i9bGT22Xc5qD8OYwZmiFUbdcsOrP4/XS+c=; b=BFR9C0Jb7wtEOhbOSyBwnRGqiZTJSQayLcTwxiuxFoZsCQiSPl1ZPJvH4hTYeaXq7j a+VQ7nRjP1+H8cEns8Nf0ido+lq+gw28wWwZMkH4kl31Dgwc59fE4POLom5hcOTRNWS0 8jFBMmdG8pNcWUscV2Nh0frAK8bGDm2bixqcqxiDHpmnSx4zClJCD7y6ARUerF3519pY +VYqvuqP7p4fQEci+DXMF3yVqW1coehBdosG2YNvh8DQ/YYkLhxdnqTuvnbMmmNt63Ip GO3LfubHMQK7ldn7FWnvwK5DEYk+4T9jyHFsXHIjSgOuH8VioWrkqJKDkfrUfaqP9TL2 snrQ== X-Gm-Message-State: AOJu0YwZP9NY/6e7p5SYTFRU1NXuptfRnaOkTrx9pzaqwwexG1OC4hXM +DSesGYzxwezS2r9or83rwwaZwb4LocDYBM89rgUStCe+4A1/nskHxiwM5u9H/7ICNo= X-Gm-Gg: AY/fxX4UzwKZGlF3Uz2ORcBDMKqCOGloQ8LK/yMOcg/fw2u6BBl+NZLiDLloF4t7njs BSrVEHZTWzelxiTdnUQpt12b4vtMypiRWrMT+2hfkSi4r0LZq0+G3dbQRkptyZKsAtqBaujmeZS 9xmF7nWgq5FPoe2jTWTAk85xKhtFO+W97eqTXwrn6LLn69AnhSy6ZBASyA+1aPu+7jg9OS1bcqk q1gmjudTv/QgtL/YX1mHSPC0y0lAbOS7xEngojY0xX2JkYbXTs3jdSMmAmKEQZumxz1IrXMf/Uh mvkVsnnGXJpantsrldyxvLpqDDX3yQ+zQlep/mMaMRY/eEm/FjvDW6YzNyvaiw611th1czYrBix teeIay6BTm81ECk+/WYJ9vFulgkN4sE8B+X/TB8wuJulickHfYzVkI4wIfUDrNSfA86Auadz/jO FN+C7rbA7J0Gm63+KlLBYRprnExxh7iqIRG1Qp2luS+3X3F/CDut76RdEnyd8l2sins7UMpCC/9 7VGuSJCkk2lqA== X-Google-Smtp-Source: AGHT+IG+sB+HojVoVOexYxe9/ikvcdN1H43dWusvFZ8jXjOgBaiHrSIaofUJWLWvSYbf3jeY2d+Z5Q== X-Received: by 2002:a17:902:f547:b0:295:8a21:155a with SMTP id d9443c01a7336-2a3ee48ff6cmr8697855ad.35.1767755264788; Tue, 06 Jan 2026 19:07:44 -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.41 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 06 Jan 2026 19:07:44 -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 0/2] Let the compiler remove unneeded compatible checks. Date: Wed, 7 Jan 2026 12:07:29 +0900 Message-ID: <20260107030731.1838823-1-daniel@thingy.jp> X-Mailer: git-send-email 2.51.0 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 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