Skip to content

Commit c56436e

Browse files
Oreoluwa Babatunderobherring
authored andcommitted
of: reserved_mem: Remove the use of phandle from the reserved_mem APIs
The __find_rmem() function is the only place that references the phandle field of the reserved_mem struct. __find_rmem() is used to match a device_node object to its corresponding entry in the reserved_mem array using its phandle value. But, there is already a function called of_reserved_mem_lookup() which carries out the same action using the name of the node. Using the of_reserved_mem_lookup() function is more reliable because every node is guaranteed to have a name, but not all nodes will have a phandle. Nodes are only assigned a phandle if they are explicitly defined in the DT using "phandle = <phandle_number>", or if they are referenced by another node in the DT. Hence, If the phandle field is empty, then __find_rmem() will return a false negative. Hence, delete the __find_rmem() function and switch to using the of_reserved_mem_lookup() function to find the corresponding entry of a device_node in the reserved_mem array. Since the phandle field of the reserved_mem struct is now unused, delete that as well. Signed-off-by: Oreoluwa Babatunde <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Rob Herring (Arm) <[email protected]>
1 parent 669430b commit c56436e

File tree

2 files changed

+1
-22
lines changed

2 files changed

+1
-22
lines changed

drivers/of/of_reserved_mem.c

Lines changed: 1 addition & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -437,17 +437,10 @@ void __init fdt_init_reserved_mem(void)
437437
for (i = 0; i < reserved_mem_count; i++) {
438438
struct reserved_mem *rmem = &reserved_mem[i];
439439
unsigned long node = rmem->fdt_node;
440-
int len;
441-
const __be32 *prop;
442440
int err = 0;
443441
bool nomap;
444442

445443
nomap = of_get_flat_dt_prop(node, "no-map", NULL) != NULL;
446-
prop = of_get_flat_dt_prop(node, "phandle", &len);
447-
if (!prop)
448-
prop = of_get_flat_dt_prop(node, "linux,phandle", &len);
449-
if (prop)
450-
rmem->phandle = of_read_number(prop, len/4);
451444

452445
if (rmem->size == 0)
453446
err = __reserved_mem_alloc_size(node, rmem->name,
@@ -477,19 +470,6 @@ void __init fdt_init_reserved_mem(void)
477470
}
478471
}
479472

480-
static inline struct reserved_mem *__find_rmem(struct device_node *node)
481-
{
482-
unsigned int i;
483-
484-
if (!node->phandle)
485-
return NULL;
486-
487-
for (i = 0; i < reserved_mem_count; i++)
488-
if (reserved_mem[i].phandle == node->phandle)
489-
return &reserved_mem[i];
490-
return NULL;
491-
}
492-
493473
struct rmem_assigned_device {
494474
struct device *dev;
495475
struct reserved_mem *rmem;
@@ -534,7 +514,7 @@ int of_reserved_mem_device_init_by_idx(struct device *dev,
534514
return 0;
535515
}
536516

537-
rmem = __find_rmem(target);
517+
rmem = of_reserved_mem_lookup(target);
538518
of_node_put(target);
539519

540520
if (!rmem || !rmem->ops || !rmem->ops->device_init)

include/linux/of_reserved_mem.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@ struct reserved_mem_ops;
1111
struct reserved_mem {
1212
const char *name;
1313
unsigned long fdt_node;
14-
unsigned long phandle;
1514
const struct reserved_mem_ops *ops;
1615
phys_addr_t base;
1716
phys_addr_t size;

0 commit comments

Comments
 (0)