]> git.ipfire.org Git - thirdparty/linux.git/commitdiff
powerpc: fadump: use lock guard for mutex
authorShrikanth Hegde <sshegde@linux.ibm.com>
Mon, 5 May 2025 07:53:30 +0000 (13:23 +0530)
committerMadhavan Srinivasan <maddy@linux.ibm.com>
Mon, 23 Jun 2025 04:27:10 +0000 (09:57 +0530)
use scoped_guard for scope based resource management of mutex.
This would make the code simpler and easier to maintain.

More details on lock guards can be found at
https://lore.kernel.org/all/20230612093537.614161713@infradead.org/T/#u

Reviewed-by: Srikar Dronamraju <srikar@linux.ibm.com>
Signed-off-by: Shrikanth Hegde <sshegde@linux.ibm.com>
Tested-by: Venkat Rao Bagalkote <venkat88@linux.ibm.com>
Reviewed-by: Sourabh Jain <sourabhjain@linux.ibm.com>
Signed-off-by: Madhavan Srinivasan <maddy@linux.ibm.com>
Link: https://patch.msgid.link/20250505075333.184463-4-sshegde@linux.ibm.com
arch/powerpc/kernel/fadump.c

index 8ca49e40c473ede2cce82bba2acbd3b29886c408..8a050f30e6d960cdeb654f6eec198a19fc4e8f3d 100644 (file)
@@ -1373,15 +1373,12 @@ static void fadump_free_elfcorehdr_buf(void)
 
 static void fadump_invalidate_release_mem(void)
 {
-       mutex_lock(&fadump_mutex);
-       if (!fw_dump.dump_active) {
-               mutex_unlock(&fadump_mutex);
-               return;
+       scoped_guard(mutex, &fadump_mutex) {
+               if (!fw_dump.dump_active)
+                       return;
+               fadump_cleanup();
        }
 
-       fadump_cleanup();
-       mutex_unlock(&fadump_mutex);
-
        fadump_free_elfcorehdr_buf();
        fadump_release_memory(fw_dump.boot_mem_top, memblock_end_of_DRAM());
        fadump_free_cpu_notes_buf();