[rtems commit] bsps/xnandpsu: Always wrap page to device size

Joel Sherrill joel at rtems.org
Fri Oct 27 16:07:23 UTC 2023


Module:    rtems
Branch:    master
Commit:    bb6ed3bed7927e9a56f2a6569f3e24c8669afba2
Changeset: http://git.rtems.org/rtems/commit/?id=bb6ed3bed7927e9a56f2a6569f3e24c8669afba2

Author:    Kinsey Moore <kinsey.moore at oarcorp.com>
Date:      Thu Oct 19 14:20:25 2023 -0500

bsps/xnandpsu: Always wrap page to device size

The xnandpsu driver conditionally tries to wrap page index to NAND chip
size causing an off-by-one error where the first page of the second chip
is not wrapped correctly. This removes the conditional so that page
index is always wrapped.

---

 bsps/shared/dev/nand/xnandpsu.c | 8 ++++++++
 1 file changed, 8 insertions(+)

diff --git a/bsps/shared/dev/nand/xnandpsu.c b/bsps/shared/dev/nand/xnandpsu.c
index 5aeee90084..db4e625e5a 100644
--- a/bsps/shared/dev/nand/xnandpsu.c
+++ b/bsps/shared/dev/nand/xnandpsu.c
@@ -1482,7 +1482,11 @@ s32 XNandPsu_Write(XNandPsu *InstancePtr, u64 Offset, u64 Length, u8 *SrcBuf)
 		}
 
 		Target = (u32) (OffsetVar/InstancePtr->Geometry.TargetSize);
+#ifdef __rtems__
+		{
+#else
 		if (Page > InstancePtr->Geometry.NumTargetPages) {
+#endif
 			Page %= InstancePtr->Geometry.NumTargetPages;
 		}
 
@@ -1597,7 +1601,11 @@ s32 XNandPsu_Read(XNandPsu *InstancePtr, u64 Offset, u64 Length, u8 *DestBuf)
 		}
 
 		Target = (u32) (OffsetVar/InstancePtr->Geometry.TargetSize);
+#ifdef __rtems__
+		{
+#else
 		if (Page > InstancePtr->Geometry.NumTargetPages) {
+#endif
 			Page %= InstancePtr->Geometry.NumTargetPages;
 		}
 		/* Check if partial read */



More information about the vc mailing list