Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

resource: provide 0args DEFINE_RES variant for unset resource desc

Provide a variant of DEFINE_RES that takes 0 arguments to initialize an
"unset" resource descriptor.

This should be used for the improper case of

struct resource res = {};

where DEFINE_RES() should be used.

With this new helper variant, it would result in:

struct resource res = DEFINE_RES();

instead of having to define the full 3 arguments:

struct resource res = DEFINE_RES(0, 0, IORESOURCE_UNSET);

DEFINE_RES() with no args, will set the flags to IORESOURCE_UNSET
signaling the resource descriptor is UNSET and doesn't reflect an actual
resource currently.

Link: https://lkml.kernel.org/r/20251213115314.16700-1-ansuelsmth@gmail.com
Signed-off-by: Christian Marangi <ansuelsmth@gmail.com>
Suggested-by: Ilpo Järvinen <ilpo.jarvinen@linux.intel.com>
Reviewed-by: Bjorn Helgaas <bhelgaas@google.com>
Reviewed-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>

authored by

Christian Marangi and committed by
Andrew Morton
ad533a74 1965bbb8

+6 -1
+6 -1
include/linux/ioport.h
··· 10 10 #define _LINUX_IOPORT_H 11 11 12 12 #ifndef __ASSEMBLY__ 13 + #include <linux/args.h> 13 14 #include <linux/bits.h> 14 15 #include <linux/compiler.h> 15 16 #include <linux/minmax.h> ··· 166 165 167 166 #define DEFINE_RES_NAMED(_start, _size, _name, _flags) \ 168 167 DEFINE_RES_NAMED_DESC(_start, _size, _name, _flags, IORES_DESC_NONE) 169 - #define DEFINE_RES(_start, _size, _flags) \ 168 + #define __DEFINE_RES0() \ 169 + DEFINE_RES_NAMED(0, 0, NULL, IORESOURCE_UNSET) 170 + #define __DEFINE_RES3(_start, _size, _flags) \ 170 171 DEFINE_RES_NAMED(_start, _size, NULL, _flags) 172 + #define DEFINE_RES(...) \ 173 + CONCATENATE(__DEFINE_RES, COUNT_ARGS(__VA_ARGS__))(__VA_ARGS__) 171 174 172 175 #define DEFINE_RES_IO_NAMED(_start, _size, _name) \ 173 176 DEFINE_RES_NAMED((_start), (_size), (_name), IORESOURCE_IO)