From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 9452EC83F34 for ; Thu, 17 Jul 2025 17:38:28 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id DB63910E86F; Thu, 17 Jul 2025 17:38:27 +0000 (UTC) Authentication-Results: gabe.freedesktop.org; dkim=pass (2048-bit key; unprotected) header.d=kernel.org header.i=@kernel.org header.b="MqPopQVr"; dkim-atps=neutral Received: from sea.source.kernel.org (sea.source.kernel.org [172.234.252.31]) by gabe.freedesktop.org (Postfix) with ESMTPS id B8AED10E86F for ; Thu, 17 Jul 2025 17:38:24 +0000 (UTC) Received: from smtp.kernel.org (transwarp.subspace.kernel.org [100.75.92.58]) by sea.source.kernel.org (Postfix) with ESMTP id 9EDDC4461E; Thu, 17 Jul 2025 17:38:24 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 46F35C4CEF0; Thu, 17 Jul 2025 17:38:22 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1752773904; bh=cHj3h7hBxwKQAm75Z7A1SPHl3XQrv92gk4AeXACN+L4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=MqPopQVrVeeNhmUHNU9q1gFwPPBy3S8G4cqfCt2/qWCddAkWLCU5ctEj+5LKEabxF 7jnFn9yJ7HvQCx+6+N9t2U9D/4QxAu6bUAxd6tR6t+iATbUlqZOAzi/jp00s4N1iQB 4cyITolFpE5AXqXP/mekzeBZfSPSIzfRDApWkGvjQmjtg5v1+MBUyCIr2CBaSvPTcg F6iHw6gCsk5Z5Z1fbMPSNu4s8eJQqdc/16KbVOr60mbniCD5I8DDonG4mtjRZ7Jsbp TMZAGlGCJqd9pn/qNGC3+8EFr4JdM8La3mTyR35BRVehFZmSEgc6Pd9c22LdD9X2EC 8RlHAXSL+Esaw== From: Mario Limonciello To: David Airlie , Bjorn Helgaas Cc: Alex Deucher , =?UTF-8?q?Christian=20K=C3=B6nig?= , Simona Vetter , Lukas Wunner , Maarten Lankhorst , Maxime Ripard , Thomas Zimmermann , David Woodhouse , Lu Baolu , Joerg Roedel , Will Deacon , Robin Murphy , Alex Williamson , Jaroslav Kysela , Takashi Iwai , dri-devel@lists.freedesktop.org (open list:DRM DRIVERS), linux-kernel@vger.kernel.org (open list), iommu@lists.linux.dev (open list:INTEL IOMMU (VT-d)), linux-pci@vger.kernel.org (open list:PCI SUBSYSTEM), kvm@vger.kernel.org (open list:VFIO DRIVER), linux-sound@vger.kernel.org (open list:SOUND), Daniel Dadap , Mario Limonciello , Simona Vetter Subject: [PATCH v9 1/9] PCI: Add helper for checking if a PCI device is a display controller Date: Thu, 17 Jul 2025 12:38:04 -0500 Message-ID: <20250717173812.3633478-2-superm1@kernel.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20250717173812.3633478-1-superm1@kernel.org> References: <20250717173812.3633478-1-superm1@kernel.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" From: Mario Limonciello Several places in the kernel do class shifting to match whether a PCI device is display class. Introduce a helper for those places to use. Acked-by: Bjorn Helgaas Reviewed-by: Daniel Dadap Reviewed-by: Simona Vetter Signed-off-by: Mario Limonciello --- include/linux/pci.h | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/include/linux/pci.h b/include/linux/pci.h index 05e68f35f3923..e77754e43c629 100644 --- a/include/linux/pci.h +++ b/include/linux/pci.h @@ -744,6 +744,21 @@ static inline bool pci_is_vga(struct pci_dev *pdev) return false; } +/** + * pci_is_display - Check if a PCI device is a display controller + * @pdev: Pointer to the PCI device structure + * + * This function determines whether the given PCI device corresponds + * to a display controller. Display controllers are typically used + * for graphical output and are identified based on their class code. + * + * Return: true if the PCI device is a display controller, false otherwise. + */ +static inline bool pci_is_display(struct pci_dev *pdev) +{ + return (pdev->class >> 16) == PCI_BASE_CLASS_DISPLAY; +} + #define for_each_pci_bridge(dev, bus) \ list_for_each_entry(dev, &bus->devices, bus_list) \ if (!pci_is_bridge(dev)) {} else -- 2.43.0