summaryrefslogtreecommitdiff
path: root/flash.c
diff options
context:
space:
mode:
Diffstat (limited to 'flash.c')
-rw-r--r--flash.c21
1 files changed, 12 insertions, 9 deletions
diff --git a/flash.c b/flash.c
index 1282eff..6379d3b 100644
--- a/flash.c
+++ b/flash.c
@@ -31,7 +31,7 @@
// flash writing queue bits
#define MAXQUEUEDJOBS 1 // This makes the queue a little bit pointless
- // but you might want to queue a few more
+// but you might want to queue a few more
typedef struct {
FlashStruct *mem;
@@ -347,7 +347,8 @@ void writeUserBlockNow(FlashStruct *mem, int addr, int numbytes)
g_static_mutex_unlock (&mutex);
}
-void writeUserBlock(FlashStruct *mem, int addr, int numbytes) {
+void writeUserBlock(FlashStruct *mem, int addr, int numbytes)
+{
if (alive) {
g_mutex_lock(&writermutex);
if (g_async_queue_length(userflashwritequeue) >= MAXQUEUEDJOBS) {
@@ -770,7 +771,7 @@ static void initFlashValues(FlashStruct *mem)
mem->use_high_ampl_ranges_for_high_pw_ranges[i]=0;
mem->couple_first_N_pw_ranges_to_ampl_ranges[i]=0;
- for (j=0;j<max_attens;j++) {
+ for (j=0; j<max_attens; j++) {
mem->attenuators[i][j] = 0.0;
}
@@ -817,16 +818,16 @@ static void initFlashValues(FlashStruct *mem)
}
-static gpointer userflashwritethreadfunc(gpointer data) {
+static gpointer userflashwritethreadfunc(gpointer data)
+{
//printf("userflash write thread start\n");
while (alive || g_async_queue_length(userflashwritequeue) > 0) { // make sure the last job in the queue gets written
- if (g_async_queue_length(userflashwritequeue) == 0){ // go into a sleep
+ if (g_async_queue_length(userflashwritequeue) == 0) { // go into a sleep
g_mutex_lock(&writermutex);
g_cond_wait(&writerwakeup, &writermutex);
g_mutex_unlock(&writermutex);
- }
- else {
+ } else {
userflashjob* job = (userflashjob*) g_async_queue_pop(userflashwritequeue);
if (job != NULL ) {
// process job
@@ -850,7 +851,8 @@ static gpointer userflashwritethreadfunc(gpointer data) {
return NULL ;
}
-void startFlashWriterThread(){
+void startFlashWriterThread()
+{
alive= true;
userflashwritequeue = g_async_queue_new();
userflashwritethread = g_thread_create(userflashwritethreadfunc, NULL, true, NULL);
@@ -890,7 +892,8 @@ void initFlash(FlashStruct *mem, gboolean reset_to_defaults, int starting_locati
}
}
-void stopFlashWriterThread(){
+void stopFlashWriterThread()
+{
alive = false;
g_cond_broadcast(&writerwakeup);
g_thread_join(userflashwritethread); // block until the write thread is totally finished.