[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <20250722041051.3354121-3-superm1@kernel.org>
Date: Mon, 21 Jul 2025 23:10:51 -0500
From: Mario Limonciello <superm1@...nel.org>
To: David Airlie <airlied@...il.com>,
Bjorn Helgaas <bhelgaas@...gle.com>
Cc: Alex Deucher <alexander.deucher@....com>,
Christian König <christian.koenig@....com>,
Simona Vetter <simona@...ll.ch>,
Maarten Lankhorst <maarten.lankhorst@...ux.intel.com>,
Maxime Ripard <mripard@...nel.org>,
Thomas Zimmermann <tzimmermann@...e.de>,
dri-devel@...ts.freedesktop.org (open list:DRM DRIVERS),
linux-kernel@...r.kernel.org (open list),
linux-pci@...r.kernel.org (open list:PCI SUBSYSTEM),
Daniel Dadap <ddadap@...dia.com>,
Mario Limonciello <mario.limonciello@....com>,
Stephen Rothwell <sfr@...b.auug.org.au>
Subject: [PATCH v5 2/2] PCI: Adjust visibility of boot_display attribute instead of creation
From: Mario Limonciello <mario.limonciello@....com>
There is a desire to avoid creating new sysfs files late, so instead
of dynamically deciding to create the boot_display attribute, make
it static.
This also fixes a compilation failure when compiled without
CONFIG_VIDEO on sparc.
Reported-by: Stephen Rothwell <sfr@...b.auug.org.au>
Closes: https://lore.kernel.org/linux-next/20250718224118.5b3f22b0@canb.auug.org.au/
Signed-off-by: Mario Limonciello <mario.limonciello@....com>
---
v5
* Fixups for comma and CONFIG_VIDEO
* Drop sysfs_update_group() as it's no longer needed
* Drop pointers in pci_boot_display_visible()
v3:
* Move to pci_sysfs_init()
v2:
* Change to sysfs_update_group() instead
---
drivers/pci/pci-sysfs.c | 58 ++++++++++++++---------------------------
1 file changed, 20 insertions(+), 38 deletions(-)
diff --git a/drivers/pci/pci-sysfs.c b/drivers/pci/pci-sysfs.c
index 6b1a0ae254d3a..f5d98795a12fe 100644
--- a/drivers/pci/pci-sysfs.c
+++ b/drivers/pci/pci-sysfs.c
@@ -1059,37 +1059,6 @@ void pci_remove_legacy_files(struct pci_bus *b)
}
#endif /* HAVE_PCI_LEGACY */
-/**
- * pci_create_boot_display_file - create a file in sysfs for @dev
- * @pdev: dev in question
- *
- * Creates a file `boot_display` in sysfs for the PCI device @pdev
- * if it is the boot display device.
- */
-static int pci_create_boot_display_file(struct pci_dev *pdev)
-{
-#ifdef CONFIG_VIDEO
- if (video_is_primary_device(&pdev->dev))
- return sysfs_create_file(&pdev->dev.kobj, &dev_attr_boot_display.attr);
-#endif
- return 0;
-}
-
-/**
- * pci_remove_boot_display_file - remove the boot display file for @dev
- * @pdev: dev in question
- *
- * Removes the file `boot_display` in sysfs for the PCI device @pdev
- * if it is the boot display device.
- */
-static void pci_remove_boot_display_file(struct pci_dev *pdev)
-{
-#ifdef CONFIG_VIDEO
- if (video_is_primary_device(&pdev->dev))
- sysfs_remove_file(&pdev->dev.kobj, &dev_attr_boot_display.attr);
-#endif
-}
-
#if defined(HAVE_PCI_MMAP) || defined(ARCH_GENERIC_PCI_MMAP_RESOURCE)
/**
* pci_mmap_resource - map a PCI resource into user memory space
@@ -1691,17 +1660,30 @@ static const struct attribute_group pci_dev_resource_resize_group = {
.is_visible = resource_resize_is_visible,
};
-int __must_check pci_create_sysfs_dev_files(struct pci_dev *pdev)
+static struct attribute *pci_display_attrs[] = {
+ &dev_attr_boot_display.attr,
+ NULL
+};
+
+static umode_t pci_boot_display_visible(struct kobject *kobj,
+ struct attribute *a, int n)
{
- int retval;
+ if (video_is_primary_device(kobj_to_dev(kobj)))
+ return a->mode;
+ return 0;
+}
+
+static const struct attribute_group pci_display_attr_group = {
+ .attrs = pci_display_attrs,
+ .is_visible = pci_boot_display_visible,
+};
+
+int __must_check pci_create_sysfs_dev_files(struct pci_dev *pdev)
+{
if (!sysfs_initialized)
return -EACCES;
- retval = pci_create_boot_display_file(pdev);
- if (retval)
- return retval;
-
return pci_create_resource_files(pdev);
}
@@ -1716,7 +1698,6 @@ void pci_remove_sysfs_dev_files(struct pci_dev *pdev)
if (!sysfs_initialized)
return;
- pci_remove_boot_display_file(pdev);
pci_remove_resource_files(pdev);
}
@@ -1845,6 +1826,7 @@ static const struct attribute_group pcie_dev_attr_group = {
const struct attribute_group *pci_dev_attr_groups[] = {
&pci_dev_attr_group,
+ &pci_display_attr_group,
&pci_dev_hp_attr_group,
#ifdef CONFIG_PCI_IOV
&sriov_pf_dev_attr_group,
--
2.48.1
Powered by blists - more mailing lists