All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] resource: add WARN_ON_ONCE for resource_size() and document misusage
@ 2025-12-08 20:29 Christian Marangi
  2025-12-09  9:54 ` kernel test robot
  2025-12-09 10:25 ` Ilpo Järvinen
  0 siblings, 2 replies; 7+ messages in thread
From: Christian Marangi @ 2025-12-08 20:29 UTC (permalink / raw)
  To: Christian Marangi, Andy Shevchenko, Andrew Morton, linux-kernel
  Cc: Ilpo Järvinen

To catch any possible misusage of resource_size() helper, emit a WARN if
we detect the passed resource descriptor have zeroed flags. This would
signal the resource descriptor is not correctly inizialized and will
probably result in resource_size() returning unexpected values. (for
example returning 1 if the resource descriptor is all set to zero)

Historically, it was assumed that resource_size was ALWAYS used AFTER
correct API fill the data of the resource descriptor (or errors out)

But lack of comments might have introduced some logic error and
confusion in any user of resource_size() with it used on resource
description initialized to all zero.

The normal way to inizialize an "uninizialized" resource descriptor
would be to use DEFINE_RES macro or resource_set_range() ideally with a
proper flag set to it.

Hence initializing a resource descriptor to all zero and passing it to
resource_size() would actually produce a size of 1.

Correct comments on the usage of this helper in conjunction of WARN
should prevent from now on any possible misusage of this and permit
to catch and fix any possible BUG caused by this logic confusion.

Link: https://lore.kernel.org/all/20251207215359.28895-1-ansuelsmth@gmail.com/T/#m990492684913c5a158ff0e5fc90697d8ad95351b
Suggested-by: Ilpo Järvinen <ilpo.jarvinen@linux.intel.com>
Signed-off-by: Christian Marangi <ansuelsmth@gmail.com>
---
 include/linux/ioport.h | 12 ++++++++++++
 1 file changed, 12 insertions(+)

diff --git a/include/linux/ioport.h b/include/linux/ioport.h
index e8b2d6aa4013..8b60f820993c 100644
--- a/include/linux/ioport.h
+++ b/include/linux/ioport.h
@@ -286,8 +286,20 @@ static inline void resource_set_range(struct resource *res,
 	resource_set_size(res, size);
 }
 
+/**
+ * resource_size - Get the size of the resource
+ * @res: Resource descriptor
+ *
+ * This MUST be used ONLY with correctly inizialized resource descriptor.
+ * Passing a resource descriptor with zeroed flags will produce a WARN
+ * signaling a misusage of this helper and probably a BUG in the user
+ * of this helper.
+ *
+ * Return: Size of the resource calculated from resource end - start + 1.
+ */
 static inline resource_size_t resource_size(const struct resource *res)
 {
+	WARN_ON_ONCE(!res->flags);
 	return res->end - res->start + 1;
 }
 static inline unsigned long resource_type(const struct resource *res)
-- 
2.51.0


^ permalink raw reply related	[flat|nested] 7+ messages in thread
* Re: [PATCH] resource: add WARN_ON_ONCE for resource_size() and document misusage
@ 2025-12-09 12:08 kernel test robot
  0 siblings, 0 replies; 7+ messages in thread
From: kernel test robot @ 2025-12-09 12:08 UTC (permalink / raw)
  Cc: oe-kbuild-all, llvm

In-Reply-To: <20251208202921.16819-1-ansuelsmth@gmail.com>
References: <20251208202921.16819-1-ansuelsmth@gmail.com>
TO: Christian Marangi <ansuelsmth@gmail.com>
TO: Christian Marangi <ansuelsmth@gmail.com>
TO: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
TO: Andrew Morton <akpm@linux-foundation.org>
CC: Linux Memory Management List <linux-mm@kvack.org>
TO: linux-kernel@vger.kernel.org
CC: "Ilpo Järvinen" <ilpo.jarvinen@linux.intel.com>

Hi Christian,

kernel test robot noticed the following build errors:

[auto build test ERROR on akpm-mm/mm-everything]
[also build test ERROR on linus/master v6.18 next-20251209]
[If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch#_base_tree_information]

url:    https://github.com/intel-lab-lkp/linux/commits/Christian-Marangi/resource-add-WARN_ON_ONCE-for-resource_size-and-document-misusage/20251209-043037
base:   https://git.kernel.org/pub/scm/linux/kernel/git/akpm/mm.git mm-everything
patch link:    https://lore.kernel.org/r/20251208202921.16819-1-ansuelsmth%40gmail.com
patch subject: [PATCH] resource: add WARN_ON_ONCE for resource_size() and document misusage
config: x86_64-rhel-9.4-rust (https://download.01.org/0day-ci/archive/20251209/202512091956.PFGPNOBR-lkp@intel.com/config)
compiler: clang version 20.1.8 (https://github.com/llvm/llvm-project 87f0227cb60147a26a1eeb4fb06e3b505e9c7261)
rustc: rustc 1.88.0 (6b00bc388 2025-06-23)
reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20251209/202512091956.PFGPNOBR-lkp@intel.com/reproduce)

If you fix the issue in a separate patch/commit (i.e. not just a new version of
the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <lkp@intel.com>
| Closes: https://lore.kernel.org/oe-kbuild-all/202512091956.PFGPNOBR-lkp@intel.com/

All errors (new ones prefixed by >>):

>> include/linux/ioport.h:302:2: error: call to undeclared function 'WARN_ON_ONCE'; ISO C99 and later do not support implicit function declarations [-Wimplicit-function-declaration]
   include/linux/signal.h:98:11: warning: array index 3 is past the end of the array (that has type 'unsigned long[1]') [-Warray-bounds]
   arch/x86/include/asm/signal.h:24:2: note: array 'sig' declared here
   include/linux/signal.h:98:25: warning: array index 2 is past the end of the array (that has type 'unsigned long[1]') [-Warray-bounds]
   arch/x86/include/asm/signal.h:24:2: note: array 'sig' declared here
   include/linux/signal.h:99:4: warning: array index 1 is past the end of the array (that has type 'unsigned long[1]') [-Warray-bounds]
   arch/x86/include/asm/signal.h:24:2: note: array 'sig' declared here
   include/linux/signal.h:101:11: warning: array index 1 is past the end of the array (that has type 'unsigned long[1]') [-Warray-bounds]
   arch/x86/include/asm/signal.h:24:2: note: array 'sig' declared here
   include/linux/signal.h:114:11: warning: array index 3 is past the end of the array (that has type 'const unsigned long[1]') [-Warray-bounds]
   arch/x86/include/asm/signal.h:24:2: note: array 'sig' declared here
   include/linux/signal.h:114:27: warning: array index 3 is past the end of the array (that has type 'const unsigned long[1]') [-Warray-bounds]
   arch/x86/include/asm/signal.h:24:2: note: array 'sig' declared here
   include/linux/signal.h:115:5: warning: array index 2 is past the end of the array (that has type 'const unsigned long[1]') [-Warray-bounds]
   arch/x86/include/asm/signal.h:24:2: note: array 'sig' declared here
   include/linux/signal.h:115:21: warning: array index 2 is past the end of the array (that has type 'const unsigned long[1]') [-Warray-bounds]
   arch/x86/include/asm/signal.h:24:2: note: array 'sig' declared here
   include/linux/signal.h:116:5: warning: array index 1 is past the end of the array (that has type 'const unsigned long[1]') [-Warray-bounds]
   arch/x86/include/asm/signal.h:24:2: note: array 'sig' declared here
   include/linux/signal.h:116:21: warning: array index 1 is past the end of the array (that has type 'const unsigned long[1]') [-Warray-bounds]
   arch/x86/include/asm/signal.h:24:2: note: array 'sig' declared here
   include/linux/signal.h:119:11: warning: array index 1 is past the end of the array (that has type 'const unsigned long[1]') [-Warray-bounds]
   arch/x86/include/asm/signal.h:24:2: note: array 'sig' declared here
   include/linux/signal.h:119:27: warning: array index 1 is past the end of the array (that has type 'const unsigned long[1]') [-Warray-bounds]
   arch/x86/include/asm/signal.h:24:2: note: array 'sig' declared here
   include/linux/signal.h:138:8: warning: array index 3 is past the end of the array (that has type 'const unsigned long[1]') [-Warray-bounds]
   arch/x86/include/asm/signal.h:24:2: note: array 'sig' declared here
   include/linux/signal.h:138:24: warning: array index 2 is past the end of the array (that has type 'const unsigned long[1]') [-Warray-bounds]
   arch/x86/include/asm/signal.h:24:2: note: array 'sig' declared here
   include/linux/signal.h:139:8: warning: array index 3 is past the end of the array (that has type 'const unsigned long[1]') [-Warray-bounds]
   arch/x86/include/asm/signal.h:24:2: note: array 'sig' declared here
   include/linux/signal.h:139:24: warning: array index 2 is past the end of the array (that has type 'const unsigned long[1]') [-Warray-bounds]
   arch/x86/include/asm/signal.h:24:2: note: array 'sig' declared here
   include/linux/signal.h:140:3: warning: array index 3 is past the end of the array (that has type 'unsigned long[1]') [-Warray-bounds]
   arch/x86/include/asm/signal.h:24:2: note: array 'sig' declared here
   include/linux/signal.h:141:3: warning: array index 2 is past the end of the array (that has type 'unsigned long[1]') [-Warray-bounds]
   arch/x86/include/asm/signal.h:24:2: note: array 'sig' declared here
   include/linux/signal.h:144:8: warning: array index 1 is past the end of the array (that has type 'const unsigned long[1]') [-Warray-bounds]
   arch/x86/include/asm/signal.h:24:2: note: array 'sig' declared here
   include/linux/signal.h:144:24: warning: array index 1 is past the end of the array (that has type 'const unsigned long[1]') [-Warray-bounds]
   arch/x86/include/asm/signal.h:24:2: note: array 'sig' declared here
   include/linux/signal.h:145:3: warning: array index 1 is past the end of the array (that has type 'unsigned long[1]') [-Warray-bounds]
   arch/x86/include/asm/signal.h:24:2: note: array 'sig' declared here
   include/linux/signal.h:138:8: warning: array index 3 is past the end of the array (that has type 'const unsigned long[1]') [-Warray-bounds]
   arch/x86/include/asm/signal.h:24:2: note: array 'sig' declared here
   include/linux/signal.h:138:24: warning: array index 2 is past the end of the array (that has type 'const unsigned long[1]') [-Warray-bounds]
   arch/x86/include/asm/signal.h:24:2: note: array 'sig' declared here
   include/linux/signal.h:139:8: warning: array index 3 is past the end of the array (that has type 'const unsigned long[1]') [-Warray-bounds]
   arch/x86/include/asm/signal.h:24:2: note: array 'sig' declared here
   include/linux/signal.h:139:24: warning: array index 2 is past the end of the array (that has type 'const unsigned long[1]') [-Warray-bounds]
   arch/x86/include/asm/signal.h:24:2: note: array 'sig' declared here
   include/linux/signal.h:140:3: warning: array index 3 is past the end of the array (that has type 'unsigned long[1]') [-Warray-bounds]
   arch/x86/include/asm/signal.h:24:2: note: array 'sig' declared here
   include/linux/signal.h:141:3: warning: array index 2 is past the end of the array (that has type 'unsigned long[1]') [-Warray-bounds]
   arch/x86/include/asm/signal.h:24:2: note: array 'sig' declared here
   include/linux/signal.h:144:8: warning: array index 1 is past the end of the array (that has type 'const unsigned long[1]') [-Warray-bounds]
   arch/x86/include/asm/signal.h:24:2: note: array 'sig' declared here
   include/linux/signal.h:144:24: warning: array index 1 is past the end of the array (that has type 'const unsigned long[1]') [-Warray-bounds]
   arch/x86/include/asm/signal.h:24:2: note: array 'sig' declared here
   include/linux/signal.h:145:3: warning: array index 1 is past the end of the array (that has type 'unsigned long[1]') [-Warray-bounds]
   arch/x86/include/asm/signal.h:24:2: note: array 'sig' declared here
   include/linux/signal.h:138:8: warning: array index 3 is past the end of the array (that has type 'const unsigned long[1]') [-Warray-bounds]
   arch/x86/include/asm/signal.h:24:2: note: array 'sig' declared here
   include/linux/signal.h:138:24: warning: array index 2 is past the end of the array (that has type 'const unsigned long[1]') [-Warray-bounds]
   arch/x86/include/asm/signal.h:24:2: note: array 'sig' declared here
   include/linux/signal.h:139:8: warning: array index 3 is past the end of the array (that has type 'const unsigned long[1]') [-Warray-bounds]
   arch/x86/include/asm/signal.h:24:2: note: array 'sig' declared here
   include/linux/signal.h:139:24: warning: array index 2 is past the end of the array (that has type 'const unsigned long[1]') [-Warray-bounds]
   arch/x86/include/asm/signal.h:24:2: note: array 'sig' declared here
   include/linux/signal.h:140:3: warning: array index 3 is past the end of the array (that has type 'unsigned long[1]') [-Warray-bounds]
   arch/x86/include/asm/signal.h:24:2: note: array 'sig' declared here
   include/linux/signal.h:141:3: warning: array index 2 is past the end of the array (that has type 'unsigned long[1]') [-Warray-bounds]
   arch/x86/include/asm/signal.h:24:2: note: array 'sig' declared here
   include/linux/signal.h:144:8: warning: array index 1 is past the end of the array (that has type 'const unsigned long[1]') [-Warray-bounds]
   arch/x86/include/asm/signal.h:24:2: note: array 'sig' declared here
   include/linux/signal.h:144:24: warning: array index 1 is past the end of the array (that has type 'const unsigned long[1]') [-Warray-bounds]
   arch/x86/include/asm/signal.h:24:2: note: array 'sig' declared here
   include/linux/signal.h:145:3: warning: array index 1 is past the end of the array (that has type 'unsigned long[1]') [-Warray-bounds]
   arch/x86/include/asm/signal.h:24:2: note: array 'sig' declared here
   include/linux/signal.h:174:27: warning: array index 3 is past the end of the array (that has type 'unsigned long[1]') [-Warray-bounds]
   arch/x86/include/asm/signal.h:24:2: note: array 'sig' declared here
   include/linux/signal.h:174:10: warning: array index 3 is past the end of the array (that has type 'unsigned long[1]') [-Warray-bounds]
   arch/x86/include/asm/signal.h:24:2: note: array 'sig' declared here
   include/linux/signal.h:175:20: warning: array index 2 is past the end of the array (that has type 'unsigned long[1]') [-Warray-bounds]
   arch/x86/include/asm/signal.h:24:2: note: array 'sig' declared here
   include/linux/signal.h:175:3: warning: array index 2 is past the end of the array (that has type 'unsigned long[1]') [-Warray-bounds]
   arch/x86/include/asm/signal.h:24:2: note: array 'sig' declared here
   include/linux/signal.h:177:27: warning: array index 1 is past the end of the array (that has type 'unsigned long[1]') [-Warray-bounds]
   arch/x86/include/asm/signal.h:24:2: note: array 'sig' declared here
   include/linux/signal.h:177:10: warning: array index 1 is past the end of the array (that has type 'unsigned long[1]') [-Warray-bounds]
   arch/x86/include/asm/signal.h:24:2: note: array 'sig' declared here
   include/linux/signal.h:198:10: warning: array index 1 is past the end of the array (that has type 'unsigned long[1]') [-Warray-bounds]
   arch/x86/include/asm/signal.h:24:2: note: array 'sig' declared here
   include/linux/signal.h:211:10: warning: array index 1 is past the end of the array (that has type 'unsigned long[1]') [-Warray-bounds]
   arch/x86/include/asm/signal.h:24:2: note: array 'sig' declared here
   include/linux/signal.h:242:10: warning: array index 1 is past the end of the array (that has type 'unsigned long[1]') [-Warray-bounds]
   arch/x86/include/asm/signal.h:24:2: note: array 'sig' declared here
   include/linux/signal.h:255:10: warning: array index 1 is past the end of the array (that has type 'unsigned long[1]') [-Warray-bounds]
   arch/x86/include/asm/signal.h:24:2: note: array 'sig' declared here
   clang diag: include/linux/signal.h:98:11: warning: array index 3 is past the end of the array (that has type 'unsigned long[1]') [-Warray-bounds]
   clang diag: include/linux/signal.h:98:25: warning: array index 2 is past the end of the array (that has type 'unsigned long[1]') [-Warray-bounds]
   clang diag: include/linux/signal.h:99:4: warning: array index 1 is past the end of the array (that has type 'unsigned long[1]') [-Warray-bounds]
   clang diag: include/linux/signal.h:101:11: warning: array index 1 is past the end of the array (that has type 'unsigned long[1]') [-Warray-bounds]
   clang diag: include/linux/signal.h:114:11: warning: array index 3 is past the end of the array (that has type 'const unsigned long[1]') [-Warray-bounds]
   clang diag: include/linux/signal.h:114:27: warning: array index 3 is past the end of the array (that has type 'const unsigned long[1]') [-Warray-bounds]
   clang diag: include/linux/signal.h:115:5: warning: array index 2 is past the end of the array (that has type 'const unsigned long[1]') [-Warray-bounds]
   clang diag: include/linux/signal.h:115:21: warning: array index 2 is past the end of the array (that has type 'const unsigned long[1]') [-Warray-bounds]
   clang diag: include/linux/signal.h:116:5: warning: array index 1 is past the end of the array (that has type 'const unsigned long[1]') [-Warray-bounds]
   clang diag: include/linux/signal.h:116:21: warning: array index 1 is past the end of the array (that has type 'const unsigned long[1]') [-Warray-bounds]
   clang diag: include/linux/signal.h:119:11: warning: array index 1 is past the end of the array (that has type 'const unsigned long[1]') [-Warray-bounds]
   clang diag: include/linux/signal.h:119:27: warning: array index 1 is past the end of the array (that has type 'const unsigned long[1]') [-Warray-bounds]
   clang diag: include/linux/signal.h:138:8: warning: array index 3 is past the end of the array (that has type 'const unsigned long[1]') [-Warray-bounds]
   clang diag: include/linux/signal.h:138:24: warning: array index 2 is past the end of the array (that has type 'const unsigned long[1]') [-Warray-bounds]
   clang diag: include/linux/signal.h:139:8: warning: array index 3 is past the end of the array (that has type 'const unsigned long[1]') [-Warray-bounds]
   clang diag: include/linux/signal.h:139:24: warning: array index 2 is past the end of the array (that has type 'const unsigned long[1]') [-Warray-bounds]
   clang diag: include/linux/signal.h:140:3: warning: array index 3 is past the end of the array (that has type 'unsigned long[1]') [-Warray-bounds]
   clang diag: include/linux/signal.h:141:3: warning: array index 2 is past the end of the array (that has type 'unsigned long[1]') [-Warray-bounds]
   clang diag: include/linux/signal.h:144:8: warning: array index 1 is past the end of the array (that has type 'const unsigned long[1]') [-Warray-bounds]
   clang diag: include/linux/signal.h:144:24: warning: array index 1 is past the end of the array (that has type 'const unsigned long[1]') [-Warray-bounds]
   clang diag: include/linux/signal.h:145:3: warning: array index 1 is past the end of the array (that has type 'unsigned long[1]') [-Warray-bounds]
   clang diag: include/linux/signal.h:138:8: warning: array index 3 is past the end of the array (that has type 'const unsigned long[1]') [-Warray-bounds]
   clang diag: include/linux/signal.h:138:24: warning: array index 2 is past the end of the array (that has type 'const unsigned long[1]') [-Warray-bounds]
   clang diag: include/linux/signal.h:139:8: warning: array index 3 is past the end of the array (that has type 'const unsigned long[1]') [-Warray-bounds]
   clang diag: include/linux/signal.h:139:24: warning: array index 2 is past the end of the array (that has type 'const unsigned long[1]') [-Warray-bounds]
   clang diag: include/linux/signal.h:140:3: warning: array index 3 is past the end of the array (that has type 'unsigned long[1]') [-Warray-bounds]
   clang diag: include/linux/signal.h:141:3: warning: array index 2 is past the end of the array (that has type 'unsigned long[1]') [-Warray-bounds]
   clang diag: include/linux/signal.h:144:8: warning: array index 1 is past the end of the array (that has type 'const unsigned long[1]') [-Warray-bounds]
   clang diag: include/linux/signal.h:144:24: warning: array index 1 is past the end of the array (that has type 'const unsigned long[1]') [-Warray-bounds]
   clang diag: include/linux/signal.h:145:3: warning: array index 1 is past the end of the array (that has type 'unsigned long[1]') [-Warray-bounds]
   clang diag: include/linux/signal.h:138:8: warning: array index 3 is past the end of the array (that has type 'const unsigned long[1]') [-Warray-bounds]
   clang diag: include/linux/signal.h:138:24: warning: array index 2 is past the end of the array (that has type 'const unsigned long[1]') [-Warray-bounds]
   clang diag: include/linux/signal.h:139:8: warning: array index 3 is past the end of the array (that has type 'const unsigned long[1]') [-Warray-bounds]
   clang diag: include/linux/signal.h:139:24: warning: array index 2 is past the end of the array (that has type 'const unsigned long[1]') [-Warray-bounds]
   clang diag: include/linux/signal.h:140:3: warning: array index 3 is past the end of the array (that has type 'unsigned long[1]') [-Warray-bounds]
   clang diag: include/linux/signal.h:141:3: warning: array index 2 is past the end of the array (that has type 'unsigned long[1]') [-Warray-bounds]
   clang diag: include/linux/signal.h:144:8: warning: array index 1 is past the end of the array (that has type 'const unsigned long[1]') [-Warray-bounds]
   clang diag: include/linux/signal.h:144:24: warning: array index 1 is past the end of the array (that has type 'const unsigned long[1]') [-Warray-bounds]
   clang diag: include/linux/signal.h:145:3: warning: array index 1 is past the end of the array (that has type 'unsigned long[1]') [-Warray-bounds]
   clang diag: include/linux/signal.h:174:27: warning: array index 3 is past the end of the array (that has type 'unsigned long[1]') [-Warray-bounds]
   clang diag: include/linux/signal.h:174:10: warning: array index 3 is past the end of the array (that has type 'unsigned long[1]') [-Warray-bounds]
   clang diag: include/linux/signal.h:175:20: warning: array index 2 is past the end of the array (that has type 'unsigned long[1]') [-Warray-bounds]
   clang diag: include/linux/signal.h:175:3: warning: array index 2 is past the end of the array (that has type 'unsigned long[1]') [-Warray-bounds]
   clang diag: include/linux/signal.h:177:27: warning: array index 1 is past the end of the array (that has type 'unsigned long[1]') [-Warray-bounds]
   clang diag: include/linux/signal.h:177:10: warning: array index 1 is past the end of the array (that has type 'unsigned long[1]') [-Warray-bounds]
   clang diag: include/linux/signal.h:198:10: warning: array index 1 is past the end of the array (that has type 'unsigned long[1]') [-Warray-bounds]
   clang diag: include/linux/signal.h:211:10: warning: array index 1 is past the end of the array (that has type 'unsigned long[1]') [-Warray-bounds]
   clang diag: include/linux/signal.h:242:10: warning: array index 1 is past the end of the array (that has type 'unsigned long[1]') [-Warray-bounds]
   clang diag: include/linux/signal.h:255:10: warning: array index 1 is past the end of the array (that has type 'unsigned long[1]') [-Warray-bounds]
>> Unable to generate bindings: clang diagnosed error: include/linux/ioport.h:302:2: error: call to undeclared function 'WARN_ON_ONCE'; ISO C99 and later do not support implicit function declarations [-Wimplicit-function-declaration]


vim +/WARN_ON_ONCE +302 include/linux/ioport.h

   288	
   289	/**
   290	 * resource_size - Get the size of the resource
   291	 * @res: Resource descriptor
   292	 *
   293	 * This MUST be used ONLY with correctly inizialized resource descriptor.
   294	 * Passing a resource descriptor with zeroed flags will produce a WARN
   295	 * signaling a misusage of this helper and probably a BUG in the user
   296	 * of this helper.
   297	 *
   298	 * Return: Size of the resource calculated from resource end - start + 1.
   299	 */
   300	static inline resource_size_t resource_size(const struct resource *res)
   301	{
 > 302		WARN_ON_ONCE(!res->flags);
   303		return res->end - res->start + 1;
   304	}
   305	static inline unsigned long resource_type(const struct resource *res)
   306	{
   307		return res->flags & IORESOURCE_TYPE_BITS;
   308	}
   309	static inline unsigned long resource_ext_type(const struct resource *res)
   310	{
   311		return res->flags & IORESOURCE_EXT_TYPE_BITS;
   312	}
   313	/* True iff r1 completely contains r2 */
   314	static inline bool resource_contains(const struct resource *r1, const struct resource *r2)
   315	{
   316		if (resource_type(r1) != resource_type(r2))
   317			return false;
   318		if (r1->flags & IORESOURCE_UNSET || r2->flags & IORESOURCE_UNSET)
   319			return false;
   320		return r1->start <= r2->start && r1->end >= r2->end;
   321	}
   322	

-- 
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki

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

end of thread, other threads:[~2025-12-09 15:40 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-12-08 20:29 [PATCH] resource: add WARN_ON_ONCE for resource_size() and document misusage Christian Marangi
2025-12-09  9:54 ` kernel test robot
2025-12-09 10:25 ` Ilpo Järvinen
2025-12-09 15:07   ` Andy Shevchenko
2025-12-09 15:09     ` Christian Marangi
2025-12-09 15:40       ` Andy Shevchenko
  -- strict thread matches above, loose matches on Subject: below --
2025-12-09 12:08 kernel test robot

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.