* [PATCH v2 0/4] resource: Split and use DEFINE_RES*() macros
@ 2025-03-17 18:11 Andy Shevchenko
2025-03-17 18:11 ` [PATCH v2 1/4] resource: Split DEFINE_RES_NAMED_DESC() out of DEFINE_RES_NAMED() Andy Shevchenko
` (3 more replies)
0 siblings, 4 replies; 5+ messages in thread
From: Andy Shevchenko @ 2025-03-17 18:11 UTC (permalink / raw)
To: Andy Shevchenko, Ilpo Järvinen, linux-kernel
Cc: Andy Shevchenko, Andrew Morton
Mini-series to replaces open coded variants of DEFINE_RES*() macros.
Note, there are much more possibilities over the kernel and even in
the reources.c, however the latter contains not so trivial leftovers.
That's why the examples cover only straightforward conversions.
In v2:
- added examples of the conversion (Andrew)
Andy Shevchenko (4):
resource: Split DEFINE_RES_NAMED_DESC() out of DEFINE_RES_NAMED()
resource: Replace open coded variant of DEFINE_RES_NAMED_DESC()
resource: Replace open coded variants of DEFINE_RES_*_NAMED()
resource: Replace open coded variant of DEFINE_RES()
include/linux/ioport.h | 9 +++++++--
kernel/resource.c | 18 ++++--------------
2 files changed, 11 insertions(+), 16 deletions(-)
--
2.47.2
^ permalink raw reply [flat|nested] 5+ messages in thread
* [PATCH v2 1/4] resource: Split DEFINE_RES_NAMED_DESC() out of DEFINE_RES_NAMED()
2025-03-17 18:11 [PATCH v2 0/4] resource: Split and use DEFINE_RES*() macros Andy Shevchenko
@ 2025-03-17 18:11 ` Andy Shevchenko
2025-03-17 18:11 ` [PATCH v2 2/4] resource: Replace open coded variant of DEFINE_RES_NAMED_DESC() Andy Shevchenko
` (2 subsequent siblings)
3 siblings, 0 replies; 5+ messages in thread
From: Andy Shevchenko @ 2025-03-17 18:11 UTC (permalink / raw)
To: Andy Shevchenko, Ilpo Järvinen, linux-kernel
Cc: Andy Shevchenko, Andrew Morton
In some cases it would be useful to supply predefined descriptor
of the resource. For this, introduce DEFINE_RES_NAMED_DESC() macro.
While at it, provide DEFINE_RES() that takes only start, size,
and flags.
Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
---
include/linux/ioport.h | 9 +++++++--
1 file changed, 7 insertions(+), 2 deletions(-)
diff --git a/include/linux/ioport.h b/include/linux/ioport.h
index f437502224cd..a740aebc372d 100644
--- a/include/linux/ioport.h
+++ b/include/linux/ioport.h
@@ -157,15 +157,20 @@ enum {
};
/* helpers to define resources */
-#define DEFINE_RES_NAMED(_start, _size, _name, _flags) \
+#define DEFINE_RES_NAMED_DESC(_start, _size, _name, _flags, _desc) \
(struct resource) { \
.start = (_start), \
.end = (_start) + (_size) - 1, \
.name = (_name), \
.flags = (_flags), \
- .desc = IORES_DESC_NONE, \
+ .desc = (_desc), \
}
+#define DEFINE_RES_NAMED(_start, _size, _name, _flags) \
+ DEFINE_RES_NAMED_DESC(_start, _size, _name, _flags, IORES_DESC_NONE)
+#define DEFINE_RES(_start, _size, _flags) \
+ DEFINE_RES_NAMED(_start, _size, NULL, _flags)
+
#define DEFINE_RES_IO_NAMED(_start, _size, _name) \
DEFINE_RES_NAMED((_start), (_size), (_name), IORESOURCE_IO)
#define DEFINE_RES_IO(_start, _size) \
--
2.47.2
^ permalink raw reply [flat|nested] 5+ messages in thread
* [PATCH v2 2/4] resource: Replace open coded variant of DEFINE_RES_NAMED_DESC()
2025-03-17 18:11 [PATCH v2 0/4] resource: Split and use DEFINE_RES*() macros Andy Shevchenko
2025-03-17 18:11 ` [PATCH v2 1/4] resource: Split DEFINE_RES_NAMED_DESC() out of DEFINE_RES_NAMED() Andy Shevchenko
@ 2025-03-17 18:11 ` Andy Shevchenko
2025-03-17 18:11 ` [PATCH v2 3/4] resource: Replace open coded variants of DEFINE_RES_*_NAMED() Andy Shevchenko
2025-03-17 18:11 ` [PATCH v2 4/4] resource: Replace open coded variant of DEFINE_RES() Andy Shevchenko
3 siblings, 0 replies; 5+ messages in thread
From: Andy Shevchenko @ 2025-03-17 18:11 UTC (permalink / raw)
To: Andy Shevchenko, Ilpo Järvinen, linux-kernel
Cc: Andy Shevchenko, Andrew Morton
Replace open coded variant of DEFINE_RES_NAMED_DESC().
Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
---
kernel/resource.c | 6 +-----
1 file changed, 1 insertion(+), 5 deletions(-)
diff --git a/kernel/resource.c b/kernel/resource.c
index 80d10714cb38..dc9031267942 100644
--- a/kernel/resource.c
+++ b/kernel/resource.c
@@ -1957,11 +1957,7 @@ __get_free_mem_region(struct resource *base, resource_size_t size,
*/
revoke_iomem(res);
} else {
- res->start = addr;
- res->end = addr + size - 1;
- res->name = name;
- res->desc = desc;
- res->flags = IORESOURCE_MEM;
+ *res = DEFINE_RES_NAMED_DESC(addr, size, name, IORESOURCE_MEM, desc);
/*
* Only succeed if the resource hosts an exclusive
--
2.47.2
^ permalink raw reply [flat|nested] 5+ messages in thread
* [PATCH v2 3/4] resource: Replace open coded variants of DEFINE_RES_*_NAMED()
2025-03-17 18:11 [PATCH v2 0/4] resource: Split and use DEFINE_RES*() macros Andy Shevchenko
2025-03-17 18:11 ` [PATCH v2 1/4] resource: Split DEFINE_RES_NAMED_DESC() out of DEFINE_RES_NAMED() Andy Shevchenko
2025-03-17 18:11 ` [PATCH v2 2/4] resource: Replace open coded variant of DEFINE_RES_NAMED_DESC() Andy Shevchenko
@ 2025-03-17 18:11 ` Andy Shevchenko
2025-03-17 18:11 ` [PATCH v2 4/4] resource: Replace open coded variant of DEFINE_RES() Andy Shevchenko
3 siblings, 0 replies; 5+ messages in thread
From: Andy Shevchenko @ 2025-03-17 18:11 UTC (permalink / raw)
To: Andy Shevchenko, Ilpo Järvinen, linux-kernel
Cc: Andy Shevchenko, Andrew Morton
Replace open coded variants of DEFINE_RES_*_NAMED().
Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
---
kernel/resource.c | 9 ++-------
1 file changed, 2 insertions(+), 7 deletions(-)
diff --git a/kernel/resource.c b/kernel/resource.c
index dc9031267942..a30a32b47e0e 100644
--- a/kernel/resource.c
+++ b/kernel/resource.c
@@ -1728,18 +1728,13 @@ static int __init reserve_setup(char *str)
* I/O port space; otherwise assume it's memory.
*/
if (io_start < 0x10000) {
- res->flags = IORESOURCE_IO;
+ *res = DEFINE_RES_IO_NAMED(io_start, io_num, "reserved");
parent = &ioport_resource;
} else {
- res->flags = IORESOURCE_MEM;
+ *res = DEFINE_RES_MEM_NAMED(io_start, io_num, "reserved");
parent = &iomem_resource;
}
- res->name = "reserved";
- res->start = io_start;
- res->end = io_start + io_num - 1;
res->flags |= IORESOURCE_BUSY;
- res->desc = IORES_DESC_NONE;
- res->child = NULL;
if (request_resource(parent, res) == 0)
reserved = x+1;
}
--
2.47.2
^ permalink raw reply [flat|nested] 5+ messages in thread
* [PATCH v2 4/4] resource: Replace open coded variant of DEFINE_RES()
2025-03-17 18:11 [PATCH v2 0/4] resource: Split and use DEFINE_RES*() macros Andy Shevchenko
` (2 preceding siblings ...)
2025-03-17 18:11 ` [PATCH v2 3/4] resource: Replace open coded variants of DEFINE_RES_*_NAMED() Andy Shevchenko
@ 2025-03-17 18:11 ` Andy Shevchenko
3 siblings, 0 replies; 5+ messages in thread
From: Andy Shevchenko @ 2025-03-17 18:11 UTC (permalink / raw)
To: Andy Shevchenko, Ilpo Järvinen, linux-kernel
Cc: Andy Shevchenko, Andrew Morton
Replace open coded variant of DEFINE_RES(). No functional changes intended.
Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
---
kernel/resource.c | 3 +--
1 file changed, 1 insertion(+), 2 deletions(-)
diff --git a/kernel/resource.c b/kernel/resource.c
index a30a32b47e0e..8ff2f8953a4a 100644
--- a/kernel/resource.c
+++ b/kernel/resource.c
@@ -563,8 +563,7 @@ static int __region_intersects(struct resource *parent, resource_size_t start,
struct resource res, o;
bool covered;
- res.start = start;
- res.end = start + size - 1;
+ res = DEFINE_RES(start, size, 0);
for (p = parent->child; p ; p = p->sibling) {
if (!resource_intersection(p, &res, &o))
--
2.47.2
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2025-03-17 18:14 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2025-03-17 18:11 [PATCH v2 0/4] resource: Split and use DEFINE_RES*() macros Andy Shevchenko
2025-03-17 18:11 ` [PATCH v2 1/4] resource: Split DEFINE_RES_NAMED_DESC() out of DEFINE_RES_NAMED() Andy Shevchenko
2025-03-17 18:11 ` [PATCH v2 2/4] resource: Replace open coded variant of DEFINE_RES_NAMED_DESC() Andy Shevchenko
2025-03-17 18:11 ` [PATCH v2 3/4] resource: Replace open coded variants of DEFINE_RES_*_NAMED() Andy Shevchenko
2025-03-17 18:11 ` [PATCH v2 4/4] resource: Replace open coded variant of DEFINE_RES() 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®