Skip to content

Commit f5c50dd

Browse files
committed
fix(core): remove unnecessary exit handlers
[no changelog]
1 parent 4e7de9f commit f5c50dd

File tree

5 files changed

+14
-18
lines changed

5 files changed

+14
-18
lines changed

core/embed/io/display/unix/display_driver.c

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -98,10 +98,6 @@ static display_driver_t g_display_driver = {
9898
int sdl_display_res_x = DISPLAY_RESX, sdl_display_res_y = DISPLAY_RESY;
9999
int sdl_touch_offset_x, sdl_touch_offset_y;
100100

101-
static void display_exit_handler(void) {
102-
display_deinit(DISPLAY_RESET_CONTENT);
103-
}
104-
105101
bool display_init(display_content_mode_t mode) {
106102
display_driver_t *drv = &g_display_driver;
107103

@@ -113,7 +109,6 @@ bool display_init(display_content_mode_t mode) {
113109
printf("%s\n", SDL_GetError());
114110
error_shutdown("SDL_Init error");
115111
}
116-
atexit(display_exit_handler);
117112

118113
char *window_title = NULL;
119114
char *window_title_alloc = NULL;

core/embed/io/sdcard/inc/io/sdcard.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,9 @@
5454
#ifdef KERNEL_MODE
5555

5656
void sdcard_init(void);
57+
58+
void sdcard_deinit(void);
59+
5760
secbool __wur sdcard_power_on_unchecked(bool low_speed);
5861

5962
#endif

core/embed/io/sdcard/unix/sdcard.c

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -39,12 +39,6 @@
3939
static uint8_t *sdcard_buffer = NULL;
4040
static secbool sdcard_powered = secfalse;
4141

42-
static void sdcard_exit(void) {
43-
int r = munmap(sdcard_buffer, SDCARD_SIZE);
44-
ensure(sectrue * (r == 0), "munmap failed");
45-
sdcard_buffer = NULL;
46-
}
47-
4842
void sdcard_init(void) {
4943
if (sdcard_buffer != NULL) {
5044
return;
@@ -81,8 +75,12 @@ void sdcard_init(void) {
8175
}
8276

8377
sdcard_powered = secfalse;
78+
}
8479

85-
atexit(sdcard_exit);
80+
void sdcard_deinit(void) {
81+
int r = munmap(sdcard_buffer, SDCARD_SIZE);
82+
ensure(sectrue * (r == 0), "munmap failed");
83+
sdcard_buffer = NULL;
8684
}
8785

8886
secbool sdcard_is_present(void) { return sectrue; }

core/embed/util/flash/inc/util/flash.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,8 @@
3030

3131
void flash_init(void);
3232

33+
void flash_deinit(void);
34+
3335
extern const flash_area_t BOARDLOADER_AREA;
3436
extern const flash_area_t SECRET_AREA;
3537
extern const flash_area_t BHK_AREA;

core/embed/util/flash/unix/flash.c

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -82,11 +82,6 @@ static uint32_t FLASH_SECTOR_TABLE[FLASH_SECTOR_COUNT + 1] = {
8282
static uint8_t *FLASH_BUFFER = NULL;
8383
static uint32_t FLASH_SIZE;
8484

85-
static void flash_exit(void) {
86-
int r = munmap(FLASH_BUFFER, FLASH_SIZE);
87-
ensure(sectrue * (r == 0), "munmap failed");
88-
}
89-
9085
void flash_init(void) {
9186
if (FLASH_BUFFER) return;
9287

@@ -126,8 +121,11 @@ void flash_init(void) {
126121
ensure(sectrue * (map != MAP_FAILED), "mmap failed");
127122

128123
FLASH_BUFFER = (uint8_t *)map;
124+
}
129125

130-
atexit(flash_exit);
126+
void flash_deinit(void) {
127+
int r = munmap(FLASH_BUFFER, FLASH_SIZE);
128+
ensure(sectrue * (r == 0), "munmap failed");
131129
}
132130

133131
secbool flash_unlock_write(void) { return sectrue; }

0 commit comments

Comments
 (0)