From: Niklas Schnelle <schnelle@linux.ibm.com>
To: Bjorn Helgaas <bhelgaas@google.com>
Cc: Arnd Bergmann <arnd@arndb.de>,
linux-pci@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: [PATCH v6 2/2] PCI/sysfs: Make I/O resource depend on HAS_IOPORT
Date: Mon, 3 Jul 2023 15:52:55 +0200 [thread overview]
Message-ID: <20230703135255.2202721-3-schnelle@linux.ibm.com> (raw)
In-Reply-To: <20230703135255.2202721-1-schnelle@linux.ibm.com>
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>
Signed-off-by: Arnd Bergmann <arnd@kernel.org>
Acked-by: Bjorn Helgaas <bhelgaas@google.com>
Signed-off-by: Niklas Schnelle <schnelle@linux.ibm.com>
---
drivers/pci/pci-sysfs.c | 4 ++++
1 file changed, 4 insertions(+)
diff --git a/drivers/pci/pci-sysfs.c b/drivers/pci/pci-sysfs.c
index ab32a91f287b..d9eede2dbc0e 100644
--- a/drivers/pci/pci-sysfs.c
+++ b/drivers/pci/pci-sysfs.c
@@ -1083,6 +1083,7 @@ static ssize_t pci_resource_io(struct file *filp, struct kobject *kobj,
struct bin_attribute *attr, char *buf,
loff_t off, size_t count, bool write)
{
+#ifdef CONFIG_HAS_IOPORT
struct pci_dev *pdev = to_pci_dev(kobj_to_dev(kobj));
int bar = (unsigned long)attr->private;
unsigned long port = off;
@@ -1116,6 +1117,9 @@ static ssize_t pci_resource_io(struct file *filp, struct kobject *kobj,
return 4;
}
return -EINVAL;
+#else
+ return -ENXIO;
+#endif
}
static ssize_t pci_read_resource_io(struct file *filp, struct kobject *kobj,
--
2.39.2
next prev parent reply other threads:[~2023-07-03 13:53 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-07-03 13:52 [PATCH v6 0/2] PCI: Handle HAS_IOPORT dependencies Niklas Schnelle
2023-07-03 13:52 ` [PATCH v6 1/2] PCI: Make quirk using inw() depend on HAS_IOPORT Niklas Schnelle
2023-07-03 13:52 ` Niklas Schnelle [this message]
2023-07-03 17:42 ` [PATCH v6 0/2] PCI: Handle HAS_IOPORT dependencies Bjorn Helgaas
2023-07-03 18:02 ` Niklas Schnelle
2023-07-18 21:12 ` Bjorn Helgaas
2023-07-18 21:58 ` Bjorn Helgaas
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20230703135255.2202721-3-schnelle@linux.ibm.com \
--to=schnelle@linux.ibm.com \
--cc=arnd@arndb.de \
--cc=bhelgaas@google.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-pci@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).