Skip to contentSkip to conversation

vfio: platform: use platform_get_resource()

PATCH In review Andy Shevchenko 2 participants 4 messages Aug 4, 2020 – Dec 3, 2020

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 vfio: platform: use platform_get_resource()

Use platform_get_resource() to fetch the memory resource instead of open-coded variant.

---
 drivers/vfio/platform/vfio_platform.c | 16 +++++-----------
 1 file changed, 5 insertions(+), 11 deletions(-)
drivers/vfio/platform/vfio_platform.c +5 -11
index 1e2769010089..d216126a31c4 100644
@@ -25,19 +25,13 @@ static struct resource *get_platform_resource(struct vfio_platform_device *vdev,
 					      int num)
 {
 	struct platform_device *dev = (struct platform_device *) vdev->opaque;
-	int i;
+	struct resource *res;
 
-	for (i = 0; i < dev->num_resources; i++) {
-		struct resource *r = &dev->resource[i];
+	res = platform_get_resource(dev, IORESOURCE_MEM, num);
+	if (res)
+		return res;
 
-		if (resource_type(r) & (IORESOURCE_MEM|IORESOURCE_IO)) {
-			if (!num)
-				return r;
-
-			num--;
-		}
-	}
-	return NULL;
+	return platform_get_resource(dev, IORESOURCE_IO, num);
 }
 
 static int get_platform_irq(struct vfio_platform_device *vdev, int i)
Signature · 1 line
2.27.0
#2 lore raw
Quoted 7 lines · Cornelia Huck
Quoted 2 lines · On Tue, 4 Aug 2020 16:56:22 +0300 Andy Shevchenko…

Use platform_get_resource() to fetch the memory resource instead of open-coded variant.

Thanks! I have better approach now, please, postpone this one. I'll send it after v5.9-rc1.

Signature · 2 lines
With Best Regards,
Andy Shevchenko
#3 lore raw
Quoted 11 lines · Andy Shevchenko
Quoted 7 lines · Cornelia Huck
Quoted 2 lines · On Tue, 4 Aug 2020 16:56:22 +0300 Andy Shevchenko…

Use platform_get_resource() to fetch the memory resource instead of open-coded variant.

Thanks! I have better approach now, please, postpone this one. I'll send it after v5.9-rc1.

FYI: It's part of the series [1].

[1]: https://lore.kernel.org/lkml/[email protected]/T/

Signature · 2 lines
With Best Regards,
Andy Shevchenko