Merge tag 'fixes-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/arm...
[firefly-linux-kernel-4.4.55.git] / lib / dma-debug.c
index 13ef2338be4150d1345a80a510d67f410a7c2c73..66ce414891330964aacb48dee8079138034cad3d 100644 (file)
@@ -78,7 +78,7 @@ static LIST_HEAD(free_entries);
 static DEFINE_SPINLOCK(free_entries_lock);
 
 /* Global disable flag - will be set in case of an error */
-static bool global_disable __read_mostly;
+static u32 global_disable __read_mostly;
 
 /* Global error count */
 static u32 error_count;
@@ -430,7 +430,7 @@ static struct dma_debug_entry *__dma_entry_alloc(void)
  */
 static struct dma_debug_entry *dma_entry_alloc(void)
 {
-       struct dma_debug_entry *entry = NULL;
+       struct dma_debug_entry *entry;
        unsigned long flags;
 
        spin_lock_irqsave(&free_entries_lock, flags);
@@ -438,11 +438,14 @@ static struct dma_debug_entry *dma_entry_alloc(void)
        if (list_empty(&free_entries)) {
                pr_err("DMA-API: debugging out of memory - disabling\n");
                global_disable = true;
-               goto out;
+               spin_unlock_irqrestore(&free_entries_lock, flags);
+               return NULL;
        }
 
        entry = __dma_entry_alloc();
 
+       spin_unlock_irqrestore(&free_entries_lock, flags);
+
 #ifdef CONFIG_STACKTRACE
        entry->stacktrace.max_entries = DMA_DEBUG_STACKTRACE_ENTRIES;
        entry->stacktrace.entries = entry->st_entries;
@@ -450,9 +453,6 @@ static struct dma_debug_entry *dma_entry_alloc(void)
        save_stack_trace(&entry->stacktrace);
 #endif
 
-out:
-       spin_unlock_irqrestore(&free_entries_lock, flags);
-
        return entry;
 }
 
@@ -657,7 +657,7 @@ static int dma_debug_fs_init(void)
 
        global_disable_dent = debugfs_create_bool("disabled", 0444,
                        dma_debug_dent,
-                       (u32 *)&global_disable);
+                       &global_disable);
        if (!global_disable_dent)
                goto out_err;