diff options
author | Bjorn Helgaas <bhelgaas@google.com> | 2021-05-04 10:43:23 -0500 |
---|---|---|
committer | Bjorn Helgaas <bhelgaas@google.com> | 2021-05-04 10:43:23 -0500 |
commit | bac66f8f9751b432773b48b7c6baf92b036adaae (patch) | |
tree | bd04f948fb74c61c93ba37e1ccee4979e4377d81 /drivers/pci/vpd.c | |
parent | 3c5b307a1ee241cd69ad4e1f045863da593d8f6f (diff) | |
parent | ad025f8e46f3dbf09b1bf8d7a5b4ce858df74544 (diff) | |
download | linux-bac66f8f9751b432773b48b7c6baf92b036adaae.tar.bz2 |
Merge branch 'pci/sysfs'
- Convert sysfs "config", "rom", "reset", "label", "index", "acpi_index" to
static attributes to fix races in device enumeration (Krzysztof
Wilczyński)
- Convert sysfs "vpd" to static attribute (Heiner Kallweit, Krzysztof
Wilczyński)
- Use sysfs_emit() in "show" functions (Krzysztof Wilczyński)
* pci/sysfs:
PCI/sysfs: Use sysfs_emit() and sysfs_emit_at() in "show" functions
PCI/sysfs: Rearrange smbios_attr_group and acpi_attr_group
PCI/sysfs: Tidy SMBIOS & ACPI label attributes
PCI/sysfs: Convert "index", "acpi_index", "label" to static attributes
PCI/sysfs: Define SMBIOS label attributes with DEVICE_ATTR*()
PCI/sysfs: Define ACPI label attributes with DEVICE_ATTR*()
PCI/sysfs: Rename device_has_dsm() to device_has_acpi_name()
PCI/sysfs: Convert "vpd" to static attribute
PCI/sysfs: Rename "vpd" attribute accessors
PCI/sysfs: Convert "reset" to static attribute
PCI/sysfs: Convert "rom" to static attribute
PCI/sysfs: Convert "config" to static attribute
Diffstat (limited to 'drivers/pci/vpd.c')
-rw-r--r-- | drivers/pci/vpd.c | 58 |
1 files changed, 22 insertions, 36 deletions
diff --git a/drivers/pci/vpd.c b/drivers/pci/vpd.c index 8af31c5eec2d..26bf7c877de5 100644 --- a/drivers/pci/vpd.c +++ b/drivers/pci/vpd.c @@ -20,7 +20,6 @@ struct pci_vpd_ops { struct pci_vpd { const struct pci_vpd_ops *ops; - struct bin_attribute *attr; /* Descriptor for sysfs VPD entry */ struct mutex lock; unsigned int len; u16 flag; @@ -360,58 +359,45 @@ void pci_vpd_release(struct pci_dev *dev) kfree(dev->vpd); } -static ssize_t read_vpd_attr(struct file *filp, struct kobject *kobj, - struct bin_attribute *bin_attr, char *buf, - loff_t off, size_t count) +static ssize_t vpd_read(struct file *filp, struct kobject *kobj, + struct bin_attribute *bin_attr, char *buf, loff_t off, + size_t count) { struct pci_dev *dev = to_pci_dev(kobj_to_dev(kobj)); return pci_read_vpd(dev, off, count, buf); } -static ssize_t write_vpd_attr(struct file *filp, struct kobject *kobj, - struct bin_attribute *bin_attr, char *buf, - loff_t off, size_t count) +static ssize_t vpd_write(struct file *filp, struct kobject *kobj, + struct bin_attribute *bin_attr, char *buf, loff_t off, + size_t count) { struct pci_dev *dev = to_pci_dev(kobj_to_dev(kobj)); return pci_write_vpd(dev, off, count, buf); } +static BIN_ATTR(vpd, 0600, vpd_read, vpd_write, 0); -void pcie_vpd_create_sysfs_dev_files(struct pci_dev *dev) -{ - int retval; - struct bin_attribute *attr; - - if (!dev->vpd) - return; +static struct bin_attribute *vpd_attrs[] = { + &bin_attr_vpd, + NULL, +}; - attr = kzalloc(sizeof(*attr), GFP_ATOMIC); - if (!attr) - return; +static umode_t vpd_attr_is_visible(struct kobject *kobj, + struct bin_attribute *a, int n) +{ + struct pci_dev *pdev = to_pci_dev(kobj_to_dev(kobj)); - sysfs_bin_attr_init(attr); - attr->size = 0; - attr->attr.name = "vpd"; - attr->attr.mode = S_IRUSR | S_IWUSR; - attr->read = read_vpd_attr; - attr->write = write_vpd_attr; - retval = sysfs_create_bin_file(&dev->dev.kobj, attr); - if (retval) { - kfree(attr); - return; - } + if (!pdev->vpd) + return 0; - dev->vpd->attr = attr; + return a->attr.mode; } -void pcie_vpd_remove_sysfs_dev_files(struct pci_dev *dev) -{ - if (dev->vpd && dev->vpd->attr) { - sysfs_remove_bin_file(&dev->dev.kobj, dev->vpd->attr); - kfree(dev->vpd->attr); - } -} +const struct attribute_group pci_dev_vpd_attr_group = { + .bin_attrs = vpd_attrs, + .is_bin_visible = vpd_attr_is_visible, +}; int pci_vpd_find_tag(const u8 *buf, unsigned int len, u8 rdt) { |