From: "Krzysztof Wilczyński" <kw@linux.com>
To: Bjorn Helgaas <bhelgaas@google.com>
Cc: "Dan Williams" <dan.j.williams@intel.com>,
"Greg Kroah-Hartman" <gregkh@linuxfoundation.org>,
"Daniel Vetter" <daniel.vetter@ffwll.ch>,
"Kees Cook" <keescook@chromium.org>,
"Pali Rohár" <pali@kernel.org>,
"Oliver O'Halloran" <oohall@gmail.com>,
linux-pci@vger.kernel.org
Subject: [PATCH 2/2] PCI/sysfs: Pass iomem_get_mapping() as a function pointer
Date: Fri, 25 Jun 2021 23:31:18 +0000 [thread overview]
Message-ID: <20210625233118.2814915-3-kw@linux.com> (raw)
In-Reply-To: <20210625233118.2814915-1-kw@linux.com>
The struct bin_attribute requires the "mapping" member to be a function
pointer with a signature requiring the return type to be a pointer to
the struct address_space.
Thus, convert every invocation of iomem_get_mapping() into a function
pointer assignment, therefore allowing for the iomem_get_mapping()
invocation to be deferred to when the sysfs open callback runs.
Co-authored-by: Dan Williams <dan.j.williams@intel.com>
Suggested-by: Dan Williams <dan.j.williams@intel.com>
Signed-off-by: Krzysztof Wilczyński <kw@linux.com>
---
drivers/pci/pci-sysfs.c | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/drivers/pci/pci-sysfs.c b/drivers/pci/pci-sysfs.c
index beb8d1f4fafe..cff1c121eb08 100644
--- a/drivers/pci/pci-sysfs.c
+++ b/drivers/pci/pci-sysfs.c
@@ -965,7 +965,7 @@ void pci_create_legacy_files(struct pci_bus *b)
b->legacy_io->read = pci_read_legacy_io;
b->legacy_io->write = pci_write_legacy_io;
b->legacy_io->mmap = pci_mmap_legacy_io;
- b->legacy_io->mapping = iomem_get_mapping();
+ b->legacy_io->mapping = iomem_get_mapping;
pci_adjust_legacy_attr(b, pci_mmap_io);
error = device_create_bin_file(&b->dev, b->legacy_io);
if (error)
@@ -978,7 +978,7 @@ void pci_create_legacy_files(struct pci_bus *b)
b->legacy_mem->size = 1024*1024;
b->legacy_mem->attr.mode = 0600;
b->legacy_mem->mmap = pci_mmap_legacy_mem;
- b->legacy_io->mapping = iomem_get_mapping();
+ b->legacy_io->mapping = iomem_get_mapping;
pci_adjust_legacy_attr(b, pci_mmap_mem);
error = device_create_bin_file(&b->dev, b->legacy_mem);
if (error)
@@ -1195,7 +1195,7 @@ static int pci_create_attr(struct pci_dev *pdev, int num, int write_combine)
}
}
if (res_attr->mmap)
- res_attr->mapping = iomem_get_mapping();
+ res_attr->mapping = iomem_get_mapping;
res_attr->attr.name = res_attr_name;
res_attr->attr.mode = 0600;
res_attr->size = pci_resource_len(pdev, num);
--
2.32.0
next prev parent reply other threads:[~2021-06-25 23:31 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-06-25 23:31 [PATCH 0/2] Allow deferred execution of iomem_get_mapping() Krzysztof Wilczyński
2021-06-25 23:31 ` [PATCH 1/2] sysfs: Invoke iomem_get_mapping() from the sysfs open callback Krzysztof Wilczyński
2021-06-25 23:53 ` Dan Williams
2021-06-28 10:09 ` Christoph Hellwig
2021-06-28 10:41 ` Krzysztof Wilczy??ski
2021-06-28 17:36 ` Dan Williams
2021-06-28 18:06 ` Krzysztof Wilczyński
2021-06-28 18:29 ` Dan Williams
2021-06-25 23:31 ` Krzysztof Wilczyński [this message]
2021-06-25 23:56 ` [PATCH 2/2] PCI/sysfs: Pass iomem_get_mapping() as a function pointer Dan Williams
2021-06-26 13:07 ` Krzysztof Wilczyński
2021-06-28 10:15 ` Christoph Hellwig
2021-06-28 10:24 ` Krzysztof Wilczy??ski
2021-06-28 11:09 ` Greg Kroah-Hartman
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=20210625233118.2814915-3-kw@linux.com \
--to=kw@linux.com \
--cc=bhelgaas@google.com \
--cc=dan.j.williams@intel.com \
--cc=daniel.vetter@ffwll.ch \
--cc=gregkh@linuxfoundation.org \
--cc=keescook@chromium.org \
--cc=linux-pci@vger.kernel.org \
--cc=oohall@gmail.com \
--cc=pali@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