Module Name: src
Committed By: ryo
Date: Sat Aug 6 20:16:43 UTC 2022
Modified Files:
src/sys/dev/fdt: fdt_memory.c
Log Message:
In my previous change, it was necessary to consider the case where the first
block size is zero.
To generate a diff of this commit:
cvs rdiff -u -r1.5 -r1.6 src/sys/dev/fdt/fdt_memory.c
Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.
Modified files:
Index: src/sys/dev/fdt/fdt_memory.c
diff -u src/sys/dev/fdt/fdt_memory.c:1.5 src/sys/dev/fdt/fdt_memory.c:1.6
--- src/sys/dev/fdt/fdt_memory.c:1.5 Thu Aug 4 11:58:55 2022
+++ src/sys/dev/fdt/fdt_memory.c Sat Aug 6 20:16:42 2022
@@ -1,4 +1,4 @@
-/* $NetBSD: fdt_memory.c,v 1.5 2022/08/04 11:58:55 ryo Exp $ */
+/* $NetBSD: fdt_memory.c,v 1.6 2022/08/06 20:16:42 ryo Exp $ */
/*-
* Copyright (c) 2018 The NetBSD Foundation, Inc.
@@ -32,7 +32,7 @@
#include "opt_fdt.h"
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: fdt_memory.c,v 1.5 2022/08/04 11:58:55 ryo Exp $");
+__KERNEL_RCSID(0, "$NetBSD: fdt_memory.c,v 1.6 2022/08/06 20:16:42 ryo Exp $");
#include <sys/param.h>
#include <sys/queue.h>
@@ -83,16 +83,16 @@ fdt_memory_get(uint64_t *pstart, uint64_
{
const int memory = OF_finddevice("/memory");
uint64_t cur_addr, cur_size;
- int index;
+ int index, nadd;
- for (index = 0;
+ for (index = 0, nadd = 0;
fdtbus_get_reg64(memory, index, &cur_addr, &cur_size) == 0;
index++) {
if (cur_size == 0)
continue;
fdt_memory_add_range(cur_addr, cur_size);
- if (index == 0) {
+ if (nadd++ == 0) {
*pstart = cur_addr;
*pend = cur_addr + cur_size;
continue;
@@ -102,7 +102,7 @@ fdt_memory_get(uint64_t *pstart, uint64_
if (cur_addr + cur_size > *pend)
*pend = cur_addr + cur_size;
}
- if (index == 0)
+ if (nadd == 0)
panic("Cannot determine memory size");
}