Merge tag 'fbdev-v5.1' of git://github.com/bzolnier/linux
[platform/kernel/linux-starfive.git] / drivers / of / of_reserved_mem.c
index e773063..6a36bc0 100644 (file)
@@ -31,28 +31,18 @@ static int __init early_init_dt_alloc_reserved_memory_arch(phys_addr_t size,
        phys_addr_t *res_base)
 {
        phys_addr_t base;
-       /*
-        * We use __memblock_alloc_base() because memblock_alloc_base()
-        * panic()s on allocation failure.
-        */
+
        end = !end ? MEMBLOCK_ALLOC_ANYWHERE : end;
        align = !align ? SMP_CACHE_BYTES : align;
-       base = __memblock_alloc_base(size, align, end);
+       base = memblock_find_in_range(start, end, size, align);
        if (!base)
                return -ENOMEM;
 
-       /*
-        * Check if the allocated region fits in to start..end window
-        */
-       if (base < start) {
-               memblock_free(base, size);
-               return -ENOMEM;
-       }
-
        *res_base = base;
        if (nomap)
                return memblock_remove(base, size);
-       return 0;
+
+       return memblock_reserve(base, size);
 }
 
 /**