nandpsu_v1_0: Fixed triggering of assert call when block reaches max block.
Since the check for the block to have reached the end block was at the end of the loop, thus assert call triggering could happen if the block crosses the max block limit, making the driver to hang. Thus to fix the triggering of assert call, the check for the block to have reached the max block is being done at the start of the loop in XNandPsu_CalculateLength function. The u32 typecasting for the variable OffsetVar has been removed and the data type for the variable TempLen has been changed to u64 as for higher block numbers the value for these variables will require u64 datatype otherwise corrupted value will get stored which will lead to wrong calculation of block. Signed-off-by: Shakti Bhatnagar <shaktib@xilinx.com>
This commit is contained in:
parent
c61ab67a49
commit
3580a10ae2
1 changed files with 7 additions and 7 deletions
|
@ -1672,14 +1672,18 @@ static s32 XNandPsu_CalculateLength(XNandPsu *InstancePtr, u64 Offset,
|
|||
u32 BlockSize;
|
||||
u32 BlockLen;
|
||||
u32 Block;
|
||||
u32 TempLen = 0;
|
||||
u64 TempLen = 0;
|
||||
u64 OffsetVar = Offset;
|
||||
|
||||
BlockSize = InstancePtr->Geometry.BlockSize;
|
||||
|
||||
while (TempLen < Length) {
|
||||
Block = (u32) ((u32)OffsetVar/BlockSize);
|
||||
BlockLen = BlockSize - ((u32)OffsetVar % BlockSize);
|
||||
Block = (u32)(OffsetVar/BlockSize);
|
||||
BlockLen = BlockSize - (OffsetVar % BlockSize);
|
||||
if (OffsetVar >= InstancePtr->Geometry.DeviceSize) {
|
||||
Status = XST_FAILURE;
|
||||
goto Out;
|
||||
}
|
||||
/*
|
||||
* Check if the block is bad
|
||||
*/
|
||||
|
@ -1690,10 +1694,6 @@ static s32 XNandPsu_CalculateLength(XNandPsu *InstancePtr, u64 Offset,
|
|||
*/
|
||||
TempLen += BlockLen;
|
||||
}
|
||||
if (OffsetVar >= InstancePtr->Geometry.DeviceSize) {
|
||||
Status = XST_FAILURE;
|
||||
goto Out;
|
||||
}
|
||||
OffsetVar += BlockLen;
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue