18
18
#include <linux/of_fdt.h>
19
19
#include <linux/libfdt.h>
20
20
#include <linux/of.h>
21
+ #include <linux/of_address.h>
21
22
#include <linux/memblock.h>
22
23
#include <linux/slab.h>
23
24
#include <linux/vmalloc.h>
@@ -376,11 +377,10 @@ static int kdump_setup_usable_lmb(struct drmem_lmb *lmb, const __be32 **usm,
376
377
static int add_usable_mem_property (void * fdt , struct device_node * dn ,
377
378
struct umem_info * um_info )
378
379
{
379
- int n_mem_addr_cells , n_mem_size_cells , node ;
380
+ int node ;
380
381
char path [NODE_PATH_LEN ];
381
- int i , len , ranges , ret ;
382
- const __be32 * prop ;
383
- u64 base , end ;
382
+ int i , ret ;
383
+ u64 base , size ;
384
384
385
385
of_node_get (dn );
386
386
@@ -399,41 +399,30 @@ static int add_usable_mem_property(void *fdt, struct device_node *dn,
399
399
goto out ;
400
400
}
401
401
402
- /* Get the address & size cells */
403
- n_mem_addr_cells = of_n_addr_cells (dn );
404
- n_mem_size_cells = of_n_size_cells (dn );
405
- kexec_dprintk ("address cells: %d, size cells: %d\n" , n_mem_addr_cells ,
406
- n_mem_size_cells );
407
-
408
402
um_info -> idx = 0 ;
409
403
if (!check_realloc_usable_mem (um_info , 2 )) {
410
404
ret = - ENOMEM ;
411
405
goto out ;
412
406
}
413
407
414
- prop = of_get_property (dn , "reg" , & len );
415
- if (!prop || len <= 0 ) {
416
- ret = 0 ;
417
- goto out ;
418
- }
419
-
420
408
/*
421
409
* "reg" property represents sequence of (addr,size) tuples
422
410
* each representing a memory range.
423
411
*/
424
- ranges = (len >> 2 ) / (n_mem_addr_cells + n_mem_size_cells );
425
-
426
- for (i = 0 ; i < ranges ; i ++ ) {
427
- base = of_read_number (prop , n_mem_addr_cells );
428
- prop += n_mem_addr_cells ;
429
- end = base + of_read_number (prop , n_mem_size_cells ) - 1 ;
430
- prop += n_mem_size_cells ;
412
+ for (i = 0 ; ; i ++ ) {
413
+ ret = of_property_read_reg (dn , i , & base , & size );
414
+ if (ret )
415
+ break ;
431
416
432
- ret = add_usable_mem (um_info , base , end );
417
+ ret = add_usable_mem (um_info , base , base + size - 1 );
433
418
if (ret )
434
419
goto out ;
435
420
}
436
421
422
+ // No reg or empty reg? Skip this node.
423
+ if (i == 0 )
424
+ goto out ;
425
+
437
426
/*
438
427
* No kdump kernel usable memory found in this memory node.
439
428
* Write (0,0) tuple in linux,usable-memory property for
0 commit comments