summaryrefslogtreecommitdiff
path: root/arch/alpha/kernel
diff options
context:
space:
mode:
authorKrzysztof Wilczyński <kwilczynski@kernel.org>2026-05-08 04:35:41 +0000
committerBjorn Helgaas <bhelgaas@google.com>2026-06-23 15:19:09 -0500
commit4e14b965a625f2c2813bec0a6a7530426ae508fb (patch)
treec35d390315989921b994a29db3b9d6230e9e75a8 /arch/alpha/kernel
parent574b5470f8d43c85bf3dcb8c48efc2788a2bfb0c (diff)
PCI/sysfs: Convert legacy I/O and memory attributes to static definitions
Currently, legacy_io and legacy_mem are dynamically allocated and created by pci_create_legacy_files(), with pci_adjust_legacy_attr() updating the attributes at runtime on Alpha to rename them and shift the size for sparse addressing. Convert to four static const attributes (legacy_io, legacy_io_sparse, legacy_mem, legacy_mem_sparse) with .is_bin_visible() callbacks that use pci_legacy_has_sparse() to select the appropriate variant per bus. The sizes are compile-time constants and .size is set directly on each attribute. Register the groups in pcibus_groups[] under a HAVE_PCI_LEGACY guard so the driver model handles creation and removal automatically. Stub out pci_create_legacy_files() and pci_remove_legacy_files() as the dynamic creation is no longer needed. Remove the __weak pci_adjust_legacy_attr(), Alpha's override, and its declaration from both Alpha and PowerPC asm/pci.h headers. 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-23-kwilczynski@kernel.org
Diffstat (limited to 'arch/alpha/kernel')
-rw-r--r--arch/alpha/kernel/pci-sysfs.c38
1 files changed, 7 insertions, 31 deletions
diff --git a/arch/alpha/kernel/pci-sysfs.c b/arch/alpha/kernel/pci-sysfs.c
index 20736a0c1a39..94dbc470cd6c 100644
--- a/arch/alpha/kernel/pci-sysfs.c
+++ b/arch/alpha/kernel/pci-sysfs.c
@@ -191,30 +191,6 @@ bool pci_legacy_has_sparse(struct pci_bus *bus, enum pci_mmap_state type)
return has_sparse(hose, type);
}
-/**
- * pci_adjust_legacy_attr - adjustment of legacy file attributes
- * @bus: bus to create files under
- * @mmap_type: I/O port or memory
- *
- * Adjust file name and size for sparse mappings.
- */
-void pci_adjust_legacy_attr(struct pci_bus *bus, enum pci_mmap_state mmap_type)
-{
- struct pci_controller *hose = bus->sysdata;
-
- if (!has_sparse(hose, mmap_type))
- return;
-
- if (mmap_type == pci_mmap_mem) {
- bus->legacy_mem->attr.name = "legacy_mem_sparse";
- bus->legacy_mem->size <<= 5;
- } else {
- bus->legacy_io->attr.name = "legacy_io_sparse";
- bus->legacy_io->size <<= 5;
- }
- return;
-}
-
/* Legacy I/O bus read/write functions */
int pci_legacy_read(struct pci_bus *bus, loff_t port, u32 *val, size_t size)
{
@@ -291,9 +267,9 @@ static inline enum pci_mmap_state pci_bar_mmap_type(struct pci_dev *pdev,
return pci_resource_is_mem(pdev, bar) ? pci_mmap_mem : pci_mmap_io;
}
-static inline umode_t __pci_dev_resource_is_visible(struct kobject *kobj,
- const struct bin_attribute *a,
- int bar)
+static inline umode_t __pci_resource_attr_is_visible(struct kobject *kobj,
+ const struct bin_attribute *a,
+ int bar)
{
struct pci_dev *pdev = to_pci_dev(kobj_to_dev(kobj));
@@ -313,7 +289,7 @@ static umode_t pci_dev_resource_is_visible(struct kobject *kobj,
if (has_sparse(hose, pci_bar_mmap_type(pdev, bar)))
return 0;
- return __pci_dev_resource_is_visible(kobj, a, bar);
+ return __pci_resource_attr_is_visible(kobj, a, bar);
}
static umode_t pci_dev_resource_sparse_is_visible(struct kobject *kobj,
@@ -330,7 +306,7 @@ static umode_t pci_dev_resource_sparse_is_visible(struct kobject *kobj,
if (type == pci_mmap_mem && !sparse_mem_mmap_fits(pdev, bar))
return 0;
- return __pci_dev_resource_is_visible(kobj, a, bar);
+ return __pci_resource_attr_is_visible(kobj, a, bar);
}
static umode_t pci_dev_resource_dense_is_visible(struct kobject *kobj,
@@ -346,14 +322,14 @@ static umode_t pci_dev_resource_dense_is_visible(struct kobject *kobj,
return 0;
if (type == pci_mmap_mem && !sparse_mem_mmap_fits(pdev, bar))
- return __pci_dev_resource_is_visible(kobj, a, bar);
+ return __pci_resource_attr_is_visible(kobj, a, bar);
dense_base = (type == pci_mmap_mem) ? hose->dense_mem_base :
hose->dense_io_base;
if (!dense_base)
return 0;
- return __pci_dev_resource_is_visible(kobj, a, bar);
+ return __pci_resource_attr_is_visible(kobj, a, bar);
}
static inline size_t __pci_dev_resource_bin_size(struct kobject *kobj,