GCC Code Coverage Report


Directory: common/src/
Coverage: low: ≥ 0% medium: ≥ 75.0% high: ≥ 90.0%
Coverage Exec / Excl / Total
Lines: 100.0% 2 / 0 / 2
Functions: 100.0% 1 / 0 / 1
Branches: -% 0 / 0 / 0

lx_nand_flash_defragment.c
Line Branch Exec Source
1 /***************************************************************************
2 * Copyright (c) 2024 Microsoft Corporation
3 * Copyright (c) 2026-present Eclipse ThreadX contributors
4 *
5 * This program and the accompanying materials are made available under the
6 * terms of the MIT License which is available at
7 * https://opensource.org/licenses/MIT.
8 *
9 * SPDX-License-Identifier: MIT
10 **************************************************************************/
11
12 // Portions of this file were generated with AI assistance.
13
14 /**************************************************************************/
15 /**************************************************************************/
16 /** */
17 /** LevelX Component */
18 /** */
19 /** NAND Flash */
20 /** */
21 /**************************************************************************/
22 /**************************************************************************/
23
24 #define LX_SOURCE_CODE
25
26
27 /* Disable ThreadX error checking. */
28
29 #ifndef LX_DISABLE_ERROR_CHECKING
30 #define LX_DISABLE_ERROR_CHECKING
31 #endif
32
33
34 /* Include necessary system files. */
35
36 #include "lx_api.h"
37
38
39 /**************************************************************************/
40 /* */
41 /* FUNCTION RELEASE */
42 /* */
43 /* _lx_nand_flash_defragment PORTABLE C */
44 /* 6.2.1 */
45 /* AUTHOR */
46 /* */
47 /* William E. Lamie, Microsoft Corporation */
48 /* */
49 /* DESCRIPTION */
50 /* */
51 /* This function defragments the NAND flash. */
52 /* */
53 /* INPUT */
54 /* */
55 /* nand_flash NAND flash instance */
56 /* */
57 /* OUTPUT */
58 /* */
59 /* return status */
60 /* */
61 /* CALLS */
62 /* */
63 /* _lx_nand_flash_block_reclaim Reclaim a NAND flash block */
64 /* tx_mutex_get Get thread protection */
65 /* tx_mutex_put Release thread protection */
66 /* */
67 /* CALLED BY */
68 /* */
69 /* Application Code */
70 /* Internal LevelX */
71 /* */
72 /**************************************************************************/
73 20 UINT _lx_nand_flash_defragment(LX_NAND_FLASH *nand_flash)
74 {
75
76 #ifdef LX_NAND_FLASH_ENABLE_LAZY_SECTOR_RELEASE
77
78 UINT status;
79 ULONG lg;
80
81 /* Compact every logical group that has a deferred compaction pending. */
82 for (lg = 0; lg < nand_flash -> lx_nand_flash_total_blocks; lg++)
83 {
84
85 if (nand_flash -> lx_nand_flash_block_compaction_table[lg] != (USHORT)LX_NAND_BLOCK_UNMAPPED)
86 {
87
88 status = _lx_nand_flash_logical_group_compact(nand_flash, lg);
89
90 /* On error, continue to compact remaining groups. */
91 if (status)
92 {
93 _lx_nand_flash_system_error(nand_flash, status, lg, 0);
94 }
95 }
96 }
97
98 return(LX_SUCCESS);
99
100 #else
101
102 LX_PARAMETER_NOT_USED(nand_flash);
103
104 /* Return not supported. */
105 20 return(LX_NOT_SUPPORTED);
106
107 #endif /* LX_NAND_FLASH_ENABLE_LAZY_SECTOR_RELEASE */
108 }
109
110
111