]> git.ipfire.org Git - thirdparty/linux.git/commit
PCI/sysfs: Split pci_llseek_resource() for device and legacy attributes
authorKrzysztof Wilczyński <kwilczynski@kernel.org>
Fri, 8 May 2026 04:35:23 +0000 (04:35 +0000)
committerBjorn Helgaas <bhelgaas@google.com>
Fri, 8 May 2026 22:56:07 +0000 (17:56 -0500)
commit77723f417199f79b011336b3922586641fff29b7
tree33d763d5e0db18d708eca3dd500a9634c1705507
parent04fbecc947ec3a2149680d29b9cdc147fc012fba
PCI/sysfs: Split pci_llseek_resource() for device and legacy attributes

Both legacy and resource attributes set .f_mapping = iomem_get_mapping, so
the default generic_file_llseek() would consult iomem_inode for the file
size, which knows nothing about the attribute.  That is why custom llseek
callbacks exist.

Currently, the legacy and resource attributes have .size set at creation
time, as such, using the attr->size is sufficient.  However, the upcoming
static resource attributes will have .size == 0 set, since they are const,
and the .bin_size() callback will be used to provide the real size to
kernfs instead.

The legacy attributes operate on a struct pci_bus, not struct pci_dev, so
calling to_pci_dev() on them would be invalid.

Thus, split pci_llseek_resource() into two functions:

  - pci_llseek_resource(), which derives the file size from the BAR using
    pci_resource_len().

  - pci_llseek_resource_legacy(), which uses attr->size directly.

Update the dynamic legacy attribute creation to use the new
pci_llseek_resource_legacy() callback.

The original pci_llseek_resource() was added in commit 24de09c16f97 ("PCI:
Implement custom llseek for sysfs resource entries").

Signed-off-by: Krzysztof Wilczyński <kwilczynski@kernel.org>
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
Tested-by: Shivaprasad G Bhat <sbhat@linux.ibm.com>
Link: https://patch.msgid.link/20260508043543.217179-5-kwilczynski@kernel.org
drivers/pci/pci-sysfs.c