soc: fsl: qe: make cpm_muram_free() ignore a negative offset
authorRasmus Villemoes <linux@rasmusvillemoes.dk>
Thu, 28 Nov 2019 14:55:42 +0000 (15:55 +0100)
committerLi Yang <leoyang.li@nxp.com>
Mon, 9 Dec 2019 19:54:36 +0000 (13:54 -0600)
This allows one to simplify callers since they can store a negative
value as a sentinel to indicate "this was never allocated" (or store
the -ENOMEM from an allocation failure) and then call cpm_muram_free()
unconditionally.

Reviewed-by: Timur Tabi <timur@kernel.org>
Signed-off-by: Rasmus Villemoes <linux@rasmusvillemoes.dk>
Signed-off-by: Li Yang <leoyang.li@nxp.com>
drivers/soc/fsl/qe/qe_common.c

index 9628354..48c77bb 100644 (file)
@@ -176,6 +176,9 @@ void cpm_muram_free(s32 offset)
        int size;
        struct muram_block *tmp;
 
+       if (offset < 0)
+               return;
+
        size = 0;
        spin_lock_irqsave(&cpm_muram_lock, flags);
        list_for_each_entry(tmp, &muram_block_list, head) {