From: Ahmad Fatoum <a.fatoum@barebox.org>
To: barebox@lists.infradead.org
Cc: Ahmad Fatoum <a.fatoum@barebox.org>
Subject: [PATCH v2 4/6] drivers: tee: optee: separate local variables for each resource
Date: Mon, 26 May 2025 16:19:12 +0200 [thread overview]
Message-ID: <20250526141914.185212-5-a.fatoum@barebox.org> (raw)
In-Reply-To: <20250526141914.185212-1-a.fatoum@barebox.org>
Not reusing the same local variable makes the code arguably clearer and
ensures we don't inherit flags by mistake from the previous use of the
variable.
Signed-off-by: Ahmad Fatoum <a.fatoum@barebox.org>
---
drivers/tee/optee/of_fixup.c | 30 +++++++++++++++---------------
1 file changed, 15 insertions(+), 15 deletions(-)
diff --git a/drivers/tee/optee/of_fixup.c b/drivers/tee/optee/of_fixup.c
index 045b5a0bb754..e801c4c95070 100644
--- a/drivers/tee/optee/of_fixup.c
+++ b/drivers/tee/optee/of_fixup.c
@@ -10,7 +10,7 @@ int of_optee_fixup(struct device_node *root, void *_data)
{
struct of_optee_fixup_data *fixup_data = _data;
const char *optee_of_path = "/firmware/optee";
- struct resource res = {};
+ struct resource res_core = {}, res_shm = {};
struct device_node *node;
u64 optee_membase;
int ret;
@@ -31,16 +31,16 @@ int of_optee_fixup(struct device_node *root, void *_data)
return ret;
if (!optee_get_membase(&optee_membase)) {
- res.start = optee_membase;
- res.end = optee_membase + OPTEE_SIZE - fixup_data->shm_size - 1;
+ res_core.start = optee_membase;
+ res_core.end = optee_membase + OPTEE_SIZE - fixup_data->shm_size - 1;
} else {
- res.start = arm_mem_endmem_get() - OPTEE_SIZE;
- res.end = arm_mem_endmem_get() - fixup_data->shm_size - 1;
+ res_core.start = arm_mem_endmem_get() - OPTEE_SIZE;
+ res_core.end = arm_mem_endmem_get() - fixup_data->shm_size - 1;
}
- res.flags = IORESOURCE_BUSY;
- res.name = "optee_core";
+ res_core.flags = IORESOURCE_MEM | IORESOURCE_BUSY;
+ res_core.name = "optee_core";
- ret = of_fixup_reserved_memory(root, &res);
+ ret = of_fixup_reserved_memory(root, &res_core);
if (ret)
return ret;
@@ -48,14 +48,14 @@ int of_optee_fixup(struct device_node *root, void *_data)
return 0;
if (!optee_get_membase(&optee_membase)) {
- res.start = optee_membase + OPTEE_SIZE - fixup_data->shm_size;
- res.end = optee_membase + OPTEE_SIZE - 1;
+ res_shm.start = optee_membase + OPTEE_SIZE - fixup_data->shm_size;
+ res_shm.end = optee_membase + OPTEE_SIZE - 1;
} else {
- res.start = arm_mem_endmem_get() - fixup_data->shm_size;
- res.end = arm_mem_endmem_get() - 1;
+ res_shm.start = arm_mem_endmem_get() - fixup_data->shm_size;
+ res_shm.end = arm_mem_endmem_get() - 1;
}
- res.flags &= ~IORESOURCE_BUSY;
- res.name = "optee_shm";
+ res_shm.flags = IORESOURCE_MEM;
+ res_shm.name = "optee_shm";
- return of_fixup_reserved_memory(root, &res);
+ return of_fixup_reserved_memory(root, &res_shm);
}
--
2.39.5
next prev parent reply other threads:[~2025-05-26 14:19 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-05-26 14:19 [PATCH v2 0/6] resource: record memory type/attrs on all SDRAM Ahmad Fatoum
2025-05-26 14:19 ` [PATCH v2 1/6] memory: export inside_barebox_area Ahmad Fatoum
2025-05-26 14:19 ` [PATCH v2 2/6] resource: record EFI memory type and attributes Ahmad Fatoum
2025-05-26 14:19 ` [PATCH v2 3/6] resource: add MEMATTRS_ definitions for common attribute sets Ahmad Fatoum
2025-05-26 14:19 ` Ahmad Fatoum [this message]
2025-05-26 14:19 ` [PATCH v2 5/6] resource: supply memory type/attrs on all SDRAM requests Ahmad Fatoum
2025-05-26 14:19 ` [PATCH v2 6/6] resource: retire IORESOURCE_BUSY in favor of resource::type Ahmad Fatoum
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20250526141914.185212-5-a.fatoum@barebox.org \
--to=a.fatoum@barebox.org \
--cc=barebox@lists.infradead.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox