All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v1] vfio: platform: use platform_get_resource()
@ 2020-08-04 13:56 Andy Shevchenko
  2020-08-05 11:06 ` Cornelia Huck
  0 siblings, 1 reply; 4+ messages in thread
From: Andy Shevchenko @ 2020-08-04 13:56 UTC (permalink / raw)
  To: Eric Auger, Alex Williamson, kvm, Cornelia Huck; +Cc: Andy Shevchenko

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

Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
---
 drivers/vfio/platform/vfio_platform.c | 16 +++++-----------
 1 file changed, 5 insertions(+), 11 deletions(-)

diff --git a/drivers/vfio/platform/vfio_platform.c b/drivers/vfio/platform/vfio_platform.c
index 1e2769010089..d216126a31c4 100644
--- a/drivers/vfio/platform/vfio_platform.c
+++ b/drivers/vfio/platform/vfio_platform.c
@@ -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)
-- 
2.27.0


^ permalink raw reply related	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2020-12-03 12:39 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-08-04 13:56 [PATCH v1] vfio: platform: use platform_get_resource() Andy Shevchenko
2020-08-05 11:06 ` Cornelia Huck
2020-08-05 11:57   ` Andy Shevchenko
2020-12-03 12:38     ` Andy Shevchenko

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.