[PATCH 2/2] bsps/xnandpsu: Always wrap page to device size

Kinsey Moore kinsey.moore at oarcorp.com
Fri Oct 20 21:59:45 UTC 2023


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 */
-- 
2.39.2



More information about the devel mailing list