aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/pci/pci-sysfs.c
diff options
context:
space:
mode:
authorKrzysztof Wilczyński <kw@linux.com>2021-04-16 20:58:40 +0000
committerBjorn Helgaas <bhelgaas@google.com>2021-04-29 10:07:31 -0500
commitd93f8399053dcf117ff56a3029ff08c0e36f4b75 (patch)
treeebd1e7ae946864b9a68804c50c3223aaa715262a /drivers/pci/pci-sysfs.c
parentPCI/sysfs: Rename "vpd" attribute accessors (diff)
downloadlinux-dev-d93f8399053dcf117ff56a3029ff08c0e36f4b75.tar.xz
linux-dev-d93f8399053dcf117ff56a3029ff08c0e36f4b75.zip
PCI/sysfs: Convert "vpd" to static attribute
The "vpd" sysfs attribute allows access to Vital Product Data (VPD). Previously it was dynamically created either by pci_bus_add_device() or the pci_sysfs_init() initcall, but since it doesn't need to be created or removed dynamically, we can use a static attribute so the device model takes care of addition and removal automatically. Convert "vpd" to a static attribute and use the .is_bin_visible() callback to check whether the device supports VPD. Remove pcie_vpd_create_sysfs_dev_files(), pcie_vpd_remove_sysfs_dev_files(), pci_create_capabilities_sysfs(), and pci_create_capabilities_sysfs(), which are no longer needed. [bhelgaas: This is substantially the same as the earlier patch from Heiner Kallweit <hkallweit1@gmail.com>. I included Krzysztof's change here so all the "convert to static attribute" changes are together.] [bhelgaas: rename to vpd_read()/vpd_write() and pci_dev_vpd_attr_group] Suggested-by: Oliver O'Halloran <oohall@gmail.com> Based-on: https://lore.kernel.org/r/7703024f-8882-9eec-a122-599871728a89@gmail.com Based-on-patch-by: Heiner Kallweit <hkallweit1@gmail.com> Link: https://lore.kernel.org/r/20210416205856.3234481-5-kw@linux.com Signed-off-by: Krzysztof Wilczyński <kw@linux.com> Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
Diffstat (limited to 'drivers/pci/pci-sysfs.c')
-rw-r--r--drivers/pci/pci-sysfs.c15
1 files changed, 1 insertions, 14 deletions
diff --git a/drivers/pci/pci-sysfs.c b/drivers/pci/pci-sysfs.c
index c469d9cad0a8..6dc01fe21fd2 100644
--- a/drivers/pci/pci-sysfs.c
+++ b/drivers/pci/pci-sysfs.c
@@ -1378,12 +1378,6 @@ static const struct attribute_group pci_dev_reset_attr_group = {
.is_visible = pci_dev_reset_attr_is_visible,
};
-
-static void pci_create_capabilities_sysfs(struct pci_dev *dev)
-{
- pcie_vpd_create_sysfs_dev_files(dev);
-}
-
int __must_check pci_create_sysfs_dev_files(struct pci_dev *pdev)
{
int retval;
@@ -1395,18 +1389,11 @@ int __must_check pci_create_sysfs_dev_files(struct pci_dev *pdev)
if (retval)
return retval;
- /* add sysfs entries for various capabilities */
- pci_create_capabilities_sysfs(pdev);
pci_create_firmware_label_files(pdev);
return 0;
}
-static void pci_remove_capabilities_sysfs(struct pci_dev *dev)
-{
- pcie_vpd_remove_sysfs_dev_files(dev);
-}
-
/**
* pci_remove_sysfs_dev_files - cleanup PCI specific sysfs files
* @pdev: device whose entries we should free
@@ -1418,7 +1405,6 @@ void pci_remove_sysfs_dev_files(struct pci_dev *pdev)
if (!sysfs_initialized)
return;
- pci_remove_capabilities_sysfs(pdev);
pci_remove_resource_files(pdev);
pci_remove_firmware_label_files(pdev);
}
@@ -1514,6 +1500,7 @@ const struct attribute_group *pci_dev_groups[] = {
&pci_dev_config_attr_group,
&pci_dev_rom_attr_group,
&pci_dev_reset_attr_group,
+ &pci_dev_vpd_attr_group,
NULL,
};