Skip to content

Commit 5da1b58

Browse files
niklas88bjorn-helgaas
authored andcommitted
PCI/sysfs: Make I/O resource depend on HAS_IOPORT
If legacy I/O spaces are not supported simply return an error when trying to access them via pci_resource_io(). This allows inb() and friends to become undefined when they are known at compile time to be non-functional in a later patch. Co-developed-by: Arnd Bergmann <arnd@kernel.org> Link: https://lore.kernel.org/r/20230703135255.2202721-3-schnelle@linux.ibm.com Signed-off-by: Arnd Bergmann <arnd@kernel.org> Signed-off-by: Niklas Schnelle <schnelle@linux.ibm.com> Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
1 parent f768c75 commit 5da1b58

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

drivers/pci/pci-sysfs.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1083,6 +1083,7 @@ static ssize_t pci_resource_io(struct file *filp, struct kobject *kobj,
10831083
struct bin_attribute *attr, char *buf,
10841084
loff_t off, size_t count, bool write)
10851085
{
1086+
#ifdef CONFIG_HAS_IOPORT
10861087
struct pci_dev *pdev = to_pci_dev(kobj_to_dev(kobj));
10871088
int bar = (unsigned long)attr->private;
10881089
unsigned long port = off;
@@ -1116,6 +1117,9 @@ static ssize_t pci_resource_io(struct file *filp, struct kobject *kobj,
11161117
return 4;
11171118
}
11181119
return -EINVAL;
1120+
#else
1121+
return -ENXIO;
1122+
#endif
11191123
}
11201124

11211125
static ssize_t pci_read_resource_io(struct file *filp, struct kobject *kobj,

0 commit comments

Comments
 (0)