GCC Code Coverage Report


Directory: common/src/
Coverage: low: ≥ 0% medium: ≥ 75.0% high: ≥ 90.0%
Coverage Exec / Excl / Total
Lines: 64.7% 11 / 0 / 17
Functions: 100.0% 1 / 0 / 1
Branches: 37.5% 6 / 0 / 16

lx_nor_flash_close.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
13 /**************************************************************************/
14 /**************************************************************************/
15 /** */
16 /** LevelX Component */
17 /** */
18 /** NOR Flash */
19 /** */
20 /**************************************************************************/
21 /**************************************************************************/
22
23 #define LX_SOURCE_CODE
24
25
26 /* Disable ThreadX error checking. */
27
28 #ifndef LX_DISABLE_ERROR_CHECKING
29 #define LX_DISABLE_ERROR_CHECKING
30 #endif
31
32
33 /* Include necessary system files. */
34
35 #include "lx_api.h"
36
37
38 /**************************************************************************/
39 /* */
40 /* FUNCTION RELEASE */
41 /* */
42 /* _lx_nor_flash_close PORTABLE C */
43 /* 6.1.7 */
44 /* AUTHOR */
45 /* */
46 /* William E. Lamie, Microsoft Corporation */
47 /* */
48 /* DESCRIPTION */
49 /* */
50 /* This function closes a NOR flash instance. */
51 /* */
52 /* INPUT */
53 /* */
54 /* nor_flash NOR flash instance */
55 /* */
56 /* OUTPUT */
57 /* */
58 /* return status */
59 /* */
60 /* CALLS */
61 /* */
62 /* tx_mutex_delete Delete thread-safe mutex */
63 /* */
64 /* CALLED BY */
65 /* */
66 /* Application Code */
67 /* */
68 /**************************************************************************/
69 180 UINT _lx_nor_flash_close(LX_NOR_FLASH *nor_flash)
70 {
71
72 LX_INTERRUPT_SAVE_AREA
73
74
75 /* Lockout interrupts for NOR flash close. */
76 126 LX_DISABLE
77
78 /* See if the media is the only one on the media opened list. */
79
2/4
✓ Branch 2 → 3 taken 54 times.
✗ Branch 2 → 6 not taken.
✓ Branch 3 → 4 taken 126 times.
✗ Branch 3 → 7 not taken.
180 if ((_lx_nor_flash_opened_ptr == nor_flash) &&
80
2/4
✓ Branch 3 → 4 taken 54 times.
✗ Branch 3 → 6 not taken.
✓ Branch 4 → 5 taken 126 times.
✗ Branch 4 → 7 not taken.
180 (_lx_nor_flash_opened_ptr == nor_flash -> lx_nor_flash_open_next) &&
81
2/4
✓ Branch 4 → 5 taken 54 times.
✗ Branch 4 → 6 not taken.
✓ Branch 5 → 6 taken 126 times.
✗ Branch 5 → 7 not taken.
180 (_lx_nor_flash_opened_ptr == nor_flash -> lx_nor_flash_open_previous))
82 {
83
84 /* Only opened NOR flash, just set the opened list to NULL. */
85 180 _lx_nor_flash_opened_ptr = LX_NULL;
86 }
87 else
88 {
89
90 /* Otherwise, not the only opened NOR flash, link-up the neighbors. */
91 ✗ (nor_flash -> lx_nor_flash_open_next) -> lx_nor_flash_open_previous =
92 ✗ nor_flash -> lx_nor_flash_open_previous;
93 ✗ (nor_flash -> lx_nor_flash_open_previous) -> lx_nor_flash_open_next =
94 ✗ nor_flash -> lx_nor_flash_open_next;
95
96 /* See if we have to update the opened list head pointer. */
97 ✗ if (_lx_nor_flash_opened_ptr == nor_flash)
98 {
99
100 /* Yes, move the head pointer to the next opened NOR flash. */
101 ✗ _lx_nor_flash_opened_ptr = nor_flash -> lx_nor_flash_open_next;
102 }
103 }
104
105 /* Decrement the opened NOR flash counter. */
106 180 _lx_nor_flash_opened_count--;
107
108 /* Finally, indicate that this NOR flash is closed. */
109 180 nor_flash -> lx_nor_flash_state = LX_NOR_FLASH_CLOSED;
110
111 /* Restore interrupt posture. */
112 126 LX_RESTORE
113
114 #ifdef LX_THREAD_SAFE_ENABLE
115
116 /* Delete the thread safe mutex. */
117 18 tx_mutex_delete(&nor_flash -> lx_nor_flash_mutex);
118 #endif
119 /* Return success. */
120 180 return(LX_SUCCESS);
121 }
122
123
124