1616#include "util/sdcard.h"
1717#include "util/system.h"
1818
19- extern void (* sdcard_ready_cb )(void ( * )() );
19+ extern void (* sdcard_ready_cb )();
2020
2121/**
2222 * Types
@@ -551,6 +551,14 @@ static void page_storage_on_click(uint8_t key, int sel) {
551551static void page_storage_on_right_button (bool is_short ) {
552552}
553553
554+ static void page_storage_post_bootup_action (void (* complete_callback )()) {
555+ page_storage_init_auto_sd_repair ();
556+
557+ if (complete_callback != NULL ) {
558+ complete_callback ();
559+ }
560+ }
561+
554562/**
555563 * Main Menu page data structure, notice max is set to zero
556564 * in order to allow us to override default user input logic.
@@ -570,14 +578,13 @@ page_pack_t pp_storage = {
570578 .on_click = page_storage_on_click ,
571579 .on_right_button = page_storage_on_right_button ,
572580 .post_bootup_run_priority = 50 ,
573- .post_bootup_run_function = page_storage_init_auto_sd_repair ,
581+ .post_bootup_run_function = page_storage_post_bootup_action ,
574582};
575583
576584/**
577585 * Worker thread for repairing SD Card.
578586 */
579587static void * page_storage_repair_thread (void * arg ) {
580- void (* complete_callback )() = arg ;
581588 char buf [128 ];
582589 if (!page_storage .disable_controls ) {
583590 page_storage .is_auto_sd_repair_active = true;
@@ -592,9 +599,6 @@ static void *page_storage_repair_thread(void *arg) {
592599 page_storage .is_sd_repair_complete = true;
593600 sdcard_ready_cb = page_storage_init_auto_sd_repair ;
594601
595- if (complete_callback != NULL ) {
596- complete_callback ();
597- }
598602 pthread_exit (NULL );
599603}
600604
@@ -608,11 +612,11 @@ bool page_storage_is_sd_repair_active() {
608612/**
609613 * Once initialized detach until completed.
610614 */
611- void page_storage_init_auto_sd_repair (void ( * complete_callback )() ) {
615+ void page_storage_init_auto_sd_repair () {
612616 page_storage .is_sd_repair_complete = false;
613617 if (!page_storage .is_auto_sd_repair_active ) {
614618 pthread_t tid ;
615- if (!pthread_create (& tid , NULL , page_storage_repair_thread , complete_callback )) {
619+ if (!pthread_create (& tid , NULL , page_storage_repair_thread , NULL )) {
616620 pthread_detach (tid );
617621 }
618622 } else {
0 commit comments