Add two macros for declaring static binary attributes for PCI legacy
I/O port and ISA memory space files:

  - pci_legacy_resource_io_attr(), for legacy I/O port space (read/write)
  - pci_legacy_resource_mem_attr(), for legacy memory space (mmap)

Each macro sets the fixed attribute size.

Signed-off-by: Krzysztof Wilczyński <[email protected]>
---
 drivers/pci/pci-sysfs.c | 21 +++++++++++++++++++++
 1 file changed, 21 insertions(+)

diff --git a/drivers/pci/pci-sysfs.c b/drivers/pci/pci-sysfs.c
index a861484ac0c0..7f1d8e07924f 100644
--- a/drivers/pci/pci-sysfs.c
+++ b/drivers/pci/pci-sysfs.c
@@ -893,6 +893,27 @@ pci_llseek_resource_legacy(struct file *filep,
 }
 
 #ifdef HAVE_PCI_LEGACY
+
+#define pci_legacy_resource_io_attr(_suffix, _size)                            
\
+static const struct bin_attribute pci_legacy_io##_suffix##_attr = {            
\
+       .attr = { .name = "legacy_io" __stringify(_suffix), .mode = 0600 },     
\
+       .size = (_size),                                                        
\
+       .read = pci_read_legacy_io,                                             
\
+       .write = pci_write_legacy_io,                                           
\
+       .f_mapping = iomem_get_mapping,                                         
\
+       .llseek = pci_llseek_resource_legacy,                                   
\
+       .mmap = pci_mmap_legacy_io,                                             
\
+}
+
+#define pci_legacy_resource_mem_attr(_suffix, _size)                           
\
+static const struct bin_attribute pci_legacy_mem##_suffix##_attr = {           
\
+       .attr = { .name = "legacy_mem" __stringify(_suffix), .mode = 0600 },    
\
+       .size = (_size),                                                        
\
+       .f_mapping = iomem_get_mapping,                                         
\
+       .llseek = pci_llseek_resource_legacy,                                   
\
+       .mmap = pci_mmap_legacy_mem,                                            
\
+}
+
 /**
  * pci_read_legacy_io - read byte(s) from legacy I/O port space
  * @filp: open sysfs file
-- 
2.54.0


Reply via email to