mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH v1 1/1] resource: Replace open coded resource_overlaps()
@ 2026-09-15  8:53 Andy Shevchenko
  2026-09-15 18:25 ` Bradley Morgan
  0 siblings, 1 reply; 4+ messages in thread
From: Andy Shevchenko @ 2026-09-15  8:53 UTC (permalink / raw)
  To: linux-kernel; +Cc: Andy Shevchenko, Andrew Morton, Andy Shevchenko

In iomem_map_sanity_check() a piece of code resembles the content of
the resource_overlaps(). Replace open coded piece with the call to
the existing helper.

Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
---
 kernel/resource.c | 14 ++++++--------
 1 file changed, 6 insertions(+), 8 deletions(-)

diff --git a/kernel/resource.c b/kernel/resource.c
index 54d7199695fb..cfc1a00e86aa 100644
--- a/kernel/resource.c
+++ b/kernel/resource.c
@@ -1833,7 +1833,7 @@ __setup("reserve=", reserve_setup);
  */
 int iomem_map_sanity_check(resource_size_t addr, unsigned long size)
 {
-	resource_size_t end = addr + size - 1;
+	struct resource mem = DEFINE_RES_MEM(addr, size);
 	struct resource *p;
 	int err = 0;
 
@@ -1843,12 +1843,10 @@ int iomem_map_sanity_check(resource_size_t addr, unsigned long size)
 		 * We can probably skip the resources without
 		 * IORESOURCE_IO attribute?
 		 */
-		if (p->start > end)
+		if (!resource_overlaps(p, &mem))
 			continue;
-		if (p->end < addr)
-			continue;
-		if (PFN_DOWN(p->start) <= PFN_DOWN(addr) &&
-		    PFN_DOWN(p->end) >= PFN_DOWN(end))
+		if (PFN_DOWN(p->start) <= PFN_DOWN(mem.start) &&
+		    PFN_DOWN(p->end) >= PFN_DOWN(mem.end))
 			continue;
 		/*
 		 * if a resource is "BUSY", it's not a hardware resource
@@ -1859,8 +1857,8 @@ int iomem_map_sanity_check(resource_size_t addr, unsigned long size)
 		if (p->flags & IORESOURCE_BUSY)
 			continue;
 
-		pr_debug("resource sanity check: requesting [mem %pa-%pa], which spans more than %s %pR\n",
-			&addr, &end, p->name, p);
+		pr_debug("resource sanity check: requesting %pR, which spans more than %s %pR\n",
+			 &mem, p->name, p);
 		err = -1;
 		break;
 	}
-- 
2.50.1


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

* Re: [PATCH v1 1/1] resource: Replace open coded resource_overlaps()
  2026-09-15  8:53 [PATCH v1 1/1] resource: Replace open coded resource_overlaps() Andy Shevchenko
@ 2026-09-15 18:25 ` Bradley Morgan
  2026-09-16  7:10   ` Andy Shevchenko
  0 siblings, 1 reply; 4+ messages in thread
From: Bradley Morgan @ 2026-09-15 18:25 UTC (permalink / raw)
  To: andriy.shevchenko; +Cc: akpm, andy, linux-kernel

On 15 September 2026 09:53:53 BST, Andy Shevchenko
<andriy.shevchenko@linux.intel.com> wrote:
>In iomem_map_sanity_check() a piece of code resembles the content of
>the resource_overlaps(). Replace open coded piece with the call to
>the existing helper.
>
>Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
>---
> kernel/resource.c | 14 ++++++--------
> 1 file changed, 6 insertions(+), 8 deletions(-)
>
>diff --git a/kernel/resource.c b/kernel/resource.c
>index 54d7199695fb..cfc1a00e86aa 100644
>--- a/kernel/resource.c
>+++ b/kernel/resource.c
>@@ -1833,7 +1833,7 @@ __setup("reserve=", reserve_setup);
>  */
> int iomem_map_sanity_check(resource_size_t addr, unsigned long size)
> {
>-	resource_size_t end = addr + size - 1;
>+	struct resource mem = DEFINE_RES_MEM(addr, size);
> 	struct resource *p;
> 	int err = 0;
> 
>@@ -1843,12 +1843,10 @@ int iomem_map_sanity_check(resource_size_t addr, unsigned long size)
> 		 * We can probably skip the resources without
> 		 * IORESOURCE_IO attribute?
> 		 */
>-		if (p->start > end)
>+		if (!resource_overlaps(p, &mem))
> 			continue;
>-		if (p->end < addr)
>-			continue;
>-		if (PFN_DOWN(p->start) <= PFN_DOWN(addr) &&
>-		    PFN_DOWN(p->end) >= PFN_DOWN(end))
>+		if (PFN_DOWN(p->start) <= PFN_DOWN(mem.start) &&
>+		    PFN_DOWN(p->end) >= PFN_DOWN(mem.end))
> 			continue;
> 		/*
> 		 * if a resource is "BUSY", it's not a hardware resource
>@@ -1859,8 +1857,8 @@ int iomem_map_sanity_check(resource_size_t addr, unsigned long size)
> 		if (p->flags & IORESOURCE_BUSY)
> 			continue;
> 
>-		pr_debug("resource sanity check: requesting [mem %pa-%pa], which spans more than %s %pR\n",
>-			&addr, &end, p->name, p);
>+		pr_debug("resource sanity check: requesting %pR, which spans more than %s %pR\n",
>+			 &mem, p->name, p);


This swap is not mentioned in the changelog and it does change the
output a bit: %pa prints 0x1000, %pR pads the numbers to 10 hex digits,
so the debug line gains a bunch of zeros. Debug only, so I don't care
much, but a line in the changelog saying the print changed with it
would be good?

Other than that, LGTM

Reviewed-by: Bradley Morgan <brads@mainlining.org>


> 		err = -1;
> 		break;
> 	}
>

--- Thanks!
https://lore.kernel.org/all/EE579805-42F2-4C58-B752-F28779EEB717@grrlz.net/

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

* Re: [PATCH v1 1/1] resource: Replace open coded resource_overlaps()
  2026-09-15 18:25 ` Bradley Morgan
@ 2026-09-16  7:10   ` Andy Shevchenko
  2026-09-17 14:03     ` Andy Shevchenko
  0 siblings, 1 reply; 4+ messages in thread
From: Andy Shevchenko @ 2026-09-16  7:10 UTC (permalink / raw)
  To: Bradley Morgan; +Cc: akpm, andy, linux-kernel

On Tue, Sep 15, 2026 at 07:25:33PM +0100, Bradley Morgan wrote:
> On 15 September 2026 09:53:53 BST, Andy Shevchenko
> <andriy.shevchenko@linux.intel.com> wrote:

...

> >+		pr_debug("resource sanity check: requesting %pR, which spans more than %s %pR\n",
> >+			 &mem, p->name, p);
> 
> This swap is not mentioned in the changelog and it does change the
> output a bit: %pa prints 0x1000, %pR pads the numbers to 10 hex digits,
> so the debug line gains a bunch of zeros. Debug only, so I don't care
> much, but a line in the changelog saying the print changed with it
> would be good?

Sure, Will do in v2.

> Other than that, LGTM
> 
> Reviewed-by: Bradley Morgan <brads@mainlining.org>

Thanks!

-- 
With Best Regards,
Andy Shevchenko



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

* Re: [PATCH v1 1/1] resource: Replace open coded resource_overlaps()
  2026-09-16  7:10   ` Andy Shevchenko
@ 2026-09-17 14:03     ` Andy Shevchenko
  0 siblings, 0 replies; 4+ messages in thread
From: Andy Shevchenko @ 2026-09-17 14:03 UTC (permalink / raw)
  To: Bradley Morgan; +Cc: akpm, andy, linux-kernel

On Wed, Sep 16, 2026 at 10:10:31AM +0300, Andy Shevchenko wrote:
> On Tue, Sep 15, 2026 at 07:25:33PM +0100, Bradley Morgan wrote:
> > On 15 September 2026 09:53:53 BST, Andy Shevchenko
> > <andriy.shevchenko@linux.intel.com> wrote:

...

> > >+		pr_debug("resource sanity check: requesting %pR, which spans more than %s %pR\n",
> > >+			 &mem, p->name, p);
> > 
> > This swap is not mentioned in the changelog and it does change the
> > output a bit: %pa prints 0x1000, %pR pads the numbers to 10 hex digits,
> > so the debug line gains a bunch of zeros. Debug only, so I don't care
> > much, but a line in the changelog saying the print changed with it
> > would be good?
> 
> Sure, Will do in v2.

Andrew already applied that, but if you can suggest the text, he might amend it
there. In any case it's not a big deal, I think.

-- 
With Best Regards,
Andy Shevchenko



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

end of thread, other threads:[~2026-09-17 14:03 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-09-15  8:53 [PATCH v1 1/1] resource: Replace open coded resource_overlaps() Andy Shevchenko
2026-09-15 18:25 ` Bradley Morgan
2026-09-16  7:10   ` Andy Shevchenko
2026-09-17 14:03     ` Andy Shevchenko

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®