diff mbox series

[2/2] PCI/sysfs: Pass iomem_get_mapping() as a function pointer

Message ID 20210625233118.2814915-3-kw@linux.com (mailing list archive)
State Superseded
Delegated to: Bjorn Helgaas
Headers show
Series Allow deferred execution of iomem_get_mapping() | expand

Commit Message

Krzysztof Wilczyński June 25, 2021, 11:31 p.m. UTC
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(-)

Comments

Dan Williams June 25, 2021, 11:56 p.m. UTC | #1
On Fri, Jun 25, 2021 at 4:31 PM Krzysztof Wilczyński <kw@linux.com> wrote:
>
> 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.
>

Looks good. Since I did not write any of the below go ahead and change
the "Co-authored-by"  to:

Reviewed-by: Dan Williams <dan.j.williams@intel.com>

Thanks for picking this up and carrying it through.
Krzysztof Wilczyński June 26, 2021, 1:07 p.m. UTC | #2
Hi Dan,

[...]
> Looks good. Since I did not write any of the below go ahead and change
> the "Co-authored-by"  to:
> 
> Reviewed-by: Dan Williams <dan.j.williams@intel.com>

Thank you!

> Thanks for picking this up and carrying it through.

Of course, any time!  Also, thank you for suggesting how to solve the
problem we've had and for sending the initial patch!

	Krzysztof
Christoph Hellwig June 28, 2021, 10:15 a.m. UTC | #3
Doesn't this need to be merged into the previous patch to prevent
a compile failure after just the previous patch is applied?
Krzysztof Wilczyński June 28, 2021, 10:24 a.m. UTC | #4
Hi Christoph,

> Doesn't this need to be merged into the previous patch to prevent
> a compile failure after just the previous patch is applied?

Yes, it does.  I kept it separate for the sake of review, since we have
sysfs and PCI involved.  I wasn't sure if Bjorn would prefer to have
this done as separate patches or not, to be honest.

Bjorn said that he can squash this when applying, thus I left it as-is
for now - which means that the entire series has to be applied for
everything to build cleanly.

I will send v3 that merges first two patches.  Sorry for troubles!

	Krzysztof
Greg KH June 28, 2021, 11:09 a.m. UTC | #5
On Mon, Jun 28, 2021 at 12:24:53PM +0200, Krzysztof Wilczy??ski wrote:
> Hi Christoph,
> 
> > Doesn't this need to be merged into the previous patch to prevent
> > a compile failure after just the previous patch is applied?
> 
> Yes, it does.  I kept it separate for the sake of review, since we have
> sysfs and PCI involved.  I wasn't sure if Bjorn would prefer to have
> this done as separate patches or not, to be honest.
> 
> Bjorn said that he can squash this when applying, thus I left it as-is
> for now - which means that the entire series has to be applied for
> everything to build cleanly.
> 
> I will send v3 that merges first two patches.  Sorry for troubles!

This all needs to wait until after 5.14-rc1 is out anyway, so no rush.

greg k-h
diff mbox series

Patch

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);