Skip to content

Commit 3a761e5

Browse files
author
DongShiLei
committed
perf: skip unnecessary main data read in _lx_nand_flash_sector_read
1 parent 1751446 commit 3a761e5

File tree

1 file changed

+22
-2
lines changed

1 file changed

+22
-2
lines changed

common/src/lx_nand_flash_sector_read.c

Lines changed: 22 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -143,9 +143,9 @@ LONG page;
143143

144144
/* Read a page. */
145145
#ifdef LX_NAND_ENABLE_CONTROL_BLOCK_FOR_DRIVER_INTERFACE
146-
status = (nand_flash -> lx_nand_flash_driver_pages_read)(nand_flash, block, (ULONG)page, (UCHAR*)buffer, spare_buffer_ptr, 1);
146+
status = (nand_flash -> lx_nand_flash_driver_pages_read)(nand_flash, block, (ULONG)page, (UCHAR*)NULL, spare_buffer_ptr, 1);
147147
#else
148-
status = (nand_flash -> lx_nand_flash_driver_pages_read)(block, (ULONG)page, (UCHAR*)buffer, spare_buffer_ptr, 1);
148+
status = (nand_flash -> lx_nand_flash_driver_pages_read)(block, (ULONG)page, (UCHAR*)NULL, spare_buffer_ptr, 1);
149149
#endif
150150

151151
/* Check for an error from flash driver. */
@@ -166,6 +166,26 @@ LONG page;
166166
/* Get the logical sector number from spare bytes, and check if it matches the addressed sector number. */
167167
if ((LX_UTILITY_LONG_GET(&spare_buffer_ptr[nand_flash -> lx_nand_flash_spare_data1_offset]) & LX_NAND_PAGE_TYPE_USER_DATA_MASK) == logical_sector)
168168
{
169+
#ifdef LX_NAND_ENABLE_CONTROL_BLOCK_FOR_DRIVER_INTERFACE
170+
status = (nand_flash -> lx_nand_flash_driver_pages_read)(nand_flash, block, (ULONG)page, (UCHAR*)buffer, NULL, 1);
171+
#else
172+
status = (nand_flash -> lx_nand_flash_driver_pages_read)(block, (ULONG)page, (UCHAR*)buffer, NULL, 1);
173+
#endif
174+
175+
/* Check for an error from flash driver. */
176+
if (status)
177+
{
178+
179+
/* Call system error handler. */
180+
_lx_nand_flash_system_error(nand_flash, status, block, 0);
181+
#ifdef LX_THREAD_SAFE_ENABLE
182+
183+
/* Release the thread safe mutex. */
184+
tx_mutex_put(&nand_flash -> lx_nand_flash_mutex);
185+
#endif
186+
/* Return an error. */
187+
return(LX_ERROR);
188+
}
169189
#ifdef LX_THREAD_SAFE_ENABLE
170190

171191
/* Release the thread safe mutex. */

0 commit comments

Comments
 (0)