mail archive of the barebox mailing list
 help / color / mirror / Atom feed
* [PATCH master 1/3] resource: return NULL for error in request_barebox_region
@ 2024-07-22 17:06 Ahmad Fatoum
  2024-07-22 17:06 ` [PATCH master 2/3] ARM: i.MX8M: scratch: fix initcall return code on request_barebox_region error Ahmad Fatoum
                   ` (3 more replies)
  0 siblings, 4 replies; 6+ messages in thread
From: Ahmad Fatoum @ 2024-07-22 17:06 UTC (permalink / raw)
  To: barebox; +Cc: Ahmad Fatoum

The function currently returns NULL for error if the range is in SDRAM
and couldn't be requested or an error pointer if the range is outside.

Reduce the confusion by using only one way to indicate error. As
request_barebox_region is used to replace request_sdram_region calls and
that returns NULL on error, follow suit.

Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de>
---
 common/memory.c | 9 ++++++---
 1 file changed, 6 insertions(+), 3 deletions(-)

diff --git a/common/memory.c b/common/memory.c
index eb7838d03613..c155cb317f25 100644
--- a/common/memory.c
+++ b/common/memory.c
@@ -84,9 +84,12 @@ struct resource *request_barebox_region(const char *name,
 	resource_size_t end = start + size - 1;
 
 	if (barebox_res && barebox_res->start <= start &&
-	    end <= barebox_res->end)
-		return __request_region(barebox_res, start, end,
-					name, IORESOURCE_MEM);
+	    end <= barebox_res->end) {
+		struct resource *iores;
+		iores = __request_region(barebox_res, start, end,
+					 name, IORESOURCE_MEM);
+		return !IS_ERR(iores) ? iores : NULL;
+	}
 
 	return request_sdram_region(name, start, size);
 }
-- 
2.39.2




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

end of thread, other threads:[~2024-07-24  8:09 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-07-22 17:06 [PATCH master 1/3] resource: return NULL for error in request_barebox_region Ahmad Fatoum
2024-07-22 17:06 ` [PATCH master 2/3] ARM: i.MX8M: scratch: fix initcall return code on request_barebox_region error Ahmad Fatoum
2024-07-22 17:06 ` [PATCH master 3/3] RISC-V: cpu: " Ahmad Fatoum
2024-07-22 17:49 ` [PATCH master 1/3] resource: return NULL for error in request_barebox_region Marco Felsch
2024-07-23  6:07   ` Ahmad Fatoum
2024-07-24  8:08 ` Sascha Hauer

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