[PATCH] bsps/aarch64/zynqmp/nand: Erase using offset

Kinsey Moore kinsey.moore at oarcorp.com
Wed Oct 18 20:40:18 UTC 2023


Prefer use of XNandPsu_Erase instead of XNandPsu_EraseBlock since the
XNandPsu driver does not expose the primitives necessary to ensure
device readiness after the operation is complete.
---
 bsps/aarch64/xilinx-zynqmp/jffs2_xnandpsu.c | 8 +-------
 1 file changed, 1 insertion(+), 7 deletions(-)

diff --git a/bsps/aarch64/xilinx-zynqmp/jffs2_xnandpsu.c b/bsps/aarch64/xilinx-zynqmp/jffs2_xnandpsu.c
index ab0eb1ccd5..b8c5140436 100644
--- a/bsps/aarch64/xilinx-zynqmp/jffs2_xnandpsu.c
+++ b/bsps/aarch64/xilinx-zynqmp/jffs2_xnandpsu.c
@@ -106,20 +106,14 @@ static int flash_erase(
   XNandPsu *nandpsu = get_flash_control(super)->nandpsu;
   rtems_status_code sc;
   uint32_t BlockSize = nandpsu->Geometry.BlockSize;
-  uint32_t DeviceSize = nandpsu->Geometry.DeviceSize;
-  uint32_t BlockIndex;
-  uint32_t DeviceIndex;
 
   if (offset > nandpsu->Geometry.DeviceSize) {
     return -EIO;
   }
 
-  DeviceIndex = offset / DeviceSize;
-  BlockIndex = (offset % DeviceSize) / BlockSize;
-
   /* Perform erase operation. */
   rtems_mutex_lock(&(get_flash_control(super)->access_lock));
-  sc = XNandPsu_EraseBlock(nandpsu, DeviceIndex, BlockIndex);
+  sc = XNandPsu_Erase(nandpsu, RTEMS_ALIGN_DOWN(offset, BlockSize), BlockSize);
   rtems_mutex_unlock(&(get_flash_control(super)->access_lock));
   if (sc ) {
     return -EIO;
-- 
2.39.2



More information about the devel mailing list