]> git.ipfire.org Git - thirdparty/linux.git/commitdiff
alpha/PCI: Add static PCI resource attribute macros
authorKrzysztof Wilczyński <kwilczynski@kernel.org>
Fri, 8 May 2026 04:35:35 +0000 (04:35 +0000)
committerBjorn Helgaas <bhelgaas@google.com>
Tue, 23 Jun 2026 20:19:09 +0000 (15:19 -0500)
Add macros for declaring static binary attributes for Alpha's PCI resource
files:

  - pci_dev_resource_attr(),        for dense/BWX systems (mmap dense)
  - pci_dev_resource_sparse_attr(), for sparse systems (mmap sparse)
  - pci_dev_resource_dense_attr(),  for dense companion files (mmap dense)

Each macro creates a const bin_attribute with the BAR index stored in the
.private property and the appropriate .mmap() callback.

Signed-off-by: Krzysztof Wilczyński <kwilczynski@kernel.org>
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
Tested-by: Magnus Lindholm <linmag7@gmail.com>
Tested-by: Shivaprasad G Bhat <sbhat@linux.ibm.com>
Acked-by: Magnus Lindholm <linmag7@gmail.com>
Link: https://patch.msgid.link/20260508043543.217179-17-kwilczynski@kernel.org
arch/alpha/kernel/pci-sysfs.c

index 6cf688621ea96f3a28dd82172193488ddef81b28..e1a4546ac2db9d7d21f224fff70bc4627848a0ca 100644 (file)
@@ -104,6 +104,26 @@ static int pci_mmap_resource_dense(struct file *filp, struct kobject *kobj,
        return pci_mmap_resource(kobj, attr, vma, 0);
 }
 
+#define __pci_dev_resource_attr(_bar, _name, _suffix, _mmap)           \
+static const struct bin_attribute                                      \
+pci_dev_resource##_bar##_suffix##_attr = {                             \
+       .attr = { .name = __stringify(_name), .mode = 0600 },           \
+       .private = (void *)(unsigned long)(_bar),                       \
+       .mmap = (_mmap),                                                \
+}
+
+#define pci_dev_resource_attr(_bar)                                    \
+       __pci_dev_resource_attr(_bar, resource##_bar,,                  \
+                           pci_mmap_resource_dense)
+
+#define pci_dev_resource_sparse_attr(_bar)                             \
+       __pci_dev_resource_attr(_bar, resource##_bar##_sparse, _sparse, \
+                           pci_mmap_resource_sparse)
+
+#define pci_dev_resource_dense_attr(_bar)                              \
+       __pci_dev_resource_attr(_bar, resource##_bar##_dense, _dense,   \
+                           pci_mmap_resource_dense)
+
 /**
  * pci_remove_resource_files - cleanup resource files
  * @pdev: pci_dev to cleanup