diff mbox series

[v1] vfio: platform: use platform_get_resource()

Message ID 20200804135622.11952-1-andriy.shevchenko@linux.intel.com (mailing list archive)
State New, archived
Headers show
Series [v1] vfio: platform: use platform_get_resource() | expand

Commit Message

Andy Shevchenko Aug. 4, 2020, 1:56 p.m. UTC
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(-)

Comments

Cornelia Huck Aug. 5, 2020, 11:06 a.m. UTC | #1
On Tue,  4 Aug 2020 16:56:22 +0300
Andy Shevchenko <andriy.shevchenko@linux.intel.com> wrote:

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

Reviewed-by: Cornelia Huck <cohuck@redhat.com>
Andy Shevchenko Aug. 5, 2020, 11:57 a.m. UTC | #2
On Wed, Aug 05, 2020 at 01:06:35PM +0200, Cornelia Huck wrote:
> On Tue,  4 Aug 2020 16:56:22 +0300
> Andy Shevchenko <andriy.shevchenko@linux.intel.com> wrote:
> 
> > Use platform_get_resource() to fetch the memory resource
> > instead of open-coded variant.

> Reviewed-by: Cornelia Huck <cohuck@redhat.com>

Thanks! I have better approach now, please, postpone this one.
I'll send it after v5.9-rc1.
Andy Shevchenko Dec. 3, 2020, 12:38 p.m. UTC | #3
On Wed, Aug 05, 2020 at 02:57:59PM +0300, Andy Shevchenko wrote:
> On Wed, Aug 05, 2020 at 01:06:35PM +0200, Cornelia Huck wrote:
> > On Tue,  4 Aug 2020 16:56:22 +0300
> > Andy Shevchenko <andriy.shevchenko@linux.intel.com> wrote:
> > 
> > > Use platform_get_resource() to fetch the memory resource
> > > instead of open-coded variant.
> 
> > Reviewed-by: Cornelia Huck <cohuck@redhat.com>
> 
> 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/20201028162727.GX4077@smile.fi.intel.com/T/
diff mbox series

Patch

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)