Skip to content

Commit

Permalink
powerpc: Stop using of_root
Browse files Browse the repository at this point in the history
Replace all usages of of_root by of_find_node_by_path("/")

Signed-off-by: Christophe Leroy <christophe.leroy@csgroup.eu>
  • Loading branch information
chleroy committed Dec 6, 2023
1 parent ea47a30 commit 83550c9
Show file tree
Hide file tree
Showing 8 changed files with 40 additions and 18 deletions.
8 changes: 6 additions & 2 deletions arch/powerpc/kernel/secure_boot.c
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,10 @@ bool is_ppc_secureboot_enabled(void)
if (enabled)
goto out;

if (!of_property_read_u32(of_root, "ibm,secure-boot", &secureboot))
node = of_find_node_by_path("/");
if (!of_property_read_u32(node, "ibm,secure-boot", &secureboot))
enabled = (secureboot > 1);
of_node_put(node);

out:
pr_info("Secure boot mode %s\n", enabled ? "enabled" : "disabled");
Expand All @@ -54,8 +56,10 @@ bool is_ppc_trustedboot_enabled(void)
if (enabled)
goto out;

if (!of_property_read_u32(of_root, "ibm,trusted-boot", &trustedboot))
node = of_find_node_by_path("/");
if (!of_property_read_u32(node, "ibm,trusted-boot", &trustedboot))
enabled = (trustedboot > 0);
of_node_put(node);

out:
pr_info("Trusted boot mode %s\n", enabled ? "enabled" : "disabled");
Expand Down
8 changes: 5 additions & 3 deletions arch/powerpc/kexec/ranges.c
Original file line number Diff line number Diff line change
Expand Up @@ -385,14 +385,16 @@ int add_opal_mem_range(struct crash_mem **mem_ranges)
int add_reserved_mem_ranges(struct crash_mem **mem_ranges)
{
int n_mem_addr_cells, n_mem_size_cells, i, len, cells, ret = 0;
struct device_node *root = of_find_node_by_path("/");
const __be32 *prop;

prop = of_get_property(of_root, "reserved-ranges", &len);
prop = of_get_property(root, "reserved-ranges", &len);
n_mem_addr_cells = of_n_addr_cells(root);
n_mem_size_cells = of_n_size_cells(root);
of_node_put(root);
if (!prop)
return 0;

n_mem_addr_cells = of_n_addr_cells(of_root);
n_mem_size_cells = of_n_size_cells(of_root);
cells = n_mem_addr_cells + n_mem_size_cells;

/* Each reserved range is an (address,size) pair */
Expand Down
10 changes: 5 additions & 5 deletions arch/powerpc/mm/drmem.c
Original file line number Diff line number Diff line change
Expand Up @@ -393,17 +393,17 @@ static const __be32 *of_get_usable_memory(struct device_node *dn)
int walk_drmem_lmbs(struct device_node *dn, void *data,
int (*func)(struct drmem_lmb *, const __be32 **, void *))
{
struct device_node *root = of_find_node_by_path("/");
const __be32 *prop, *usm;
int ret = -ENODEV;

if (!of_root)
if (!root)
return ret;

/* Get the address & size cells */
of_node_get(of_root);
n_root_addr_cells = of_n_addr_cells(of_root);
n_root_size_cells = of_n_size_cells(of_root);
of_node_put(of_root);
n_root_addr_cells = of_n_addr_cells(root);
n_root_size_cells = of_n_size_cells(root);
of_node_put(root);

if (init_drmem_lmb_size(dn))
return ret;
Expand Down
6 changes: 4 additions & 2 deletions arch/powerpc/mm/numa.c
Original file line number Diff line number Diff line change
Expand Up @@ -1111,7 +1111,7 @@ static void __init setup_node_data(int nid, u64 start_pfn, u64 end_pfn)

static void __init find_possible_nodes(void)
{
struct device_node *rtas;
struct device_node *rtas, *root;
const __be32 *domains = NULL;
int prop_length, max_nodes;
u32 i;
Expand All @@ -1132,10 +1132,12 @@ static void __init find_possible_nodes(void)
* If the LPAR is migratable, new nodes might be activated after a LPM,
* so we should consider the max number in that case.
*/
if (!of_get_property(of_root, "ibm,migratable-partition", NULL))
root = of_find_node_by_path("/");
if (!of_get_property(root, "ibm,migratable-partition", NULL))
domains = of_get_property(rtas,
"ibm,current-associativity-domains",
&prop_length);
of_node_put(root);
if (!domains) {
domains = of_get_property(rtas, "ibm,max-associativity-domains",
&prop_length);
Expand Down
4 changes: 3 additions & 1 deletion arch/powerpc/platforms/52xx/efika.c
Original file line number Diff line number Diff line change
Expand Up @@ -195,8 +195,10 @@ static void __init efika_setup_arch(void)

static int __init efika_probe(void)
{
const char *model = of_get_property(of_root, "model", NULL);
struct device_node *root = of_find_node_by_path("/");
const char *model = of_get_property(root, "model", NULL);

of_node_put(root);
if (model == NULL)
return 0;
if (strcmp(model, "EFIKA5K2"))
Expand Down
4 changes: 3 additions & 1 deletion arch/powerpc/platforms/pasemi/pci.c
Original file line number Diff line number Diff line change
Expand Up @@ -270,16 +270,18 @@ static int __init pas_add_bridge(struct device_node *dev)

void __init pas_pci_init(void)
{
struct device_node *root = of_find_node_by_path("/");
struct device_node *np;
int res;

pci_set_flags(PCI_SCAN_ALL_PCIE_DEVS);

np = of_find_compatible_node(of_root, NULL, "pasemi,rootbus");
np = of_find_compatible_node(root, NULL, "pasemi,rootbus");
if (np) {
res = pas_add_bridge(np);
of_node_put(np);
}
of_node_put(root);
}

void __iomem *__init pasemi_pci_getcfgaddr(struct pci_dev *dev, int offset)
Expand Down
6 changes: 5 additions & 1 deletion arch/powerpc/platforms/pseries/lparcfg.c
Original file line number Diff line number Diff line change
Expand Up @@ -346,9 +346,13 @@ static int read_rtas_lpar_name(struct seq_file *m)
*/
static int read_dt_lpar_name(struct seq_file *m)
{
struct device_node *root = of_find_node_by_path("/");
const char *name;
int ret;

if (of_property_read_string(of_root, "ibm,partition-name", &name))
ret = of_property_read_string(root, "ibm,partition-name", &name);
of_node_put(root);
if (ret)
return -ENOENT;

seq_printf(m, "partition_name=%s\n", name);
Expand Down
12 changes: 9 additions & 3 deletions arch/powerpc/platforms/pseries/setup.c
Original file line number Diff line number Diff line change
Expand Up @@ -1029,9 +1029,11 @@ static void __init pseries_add_hw_description(void)
return;
}

if (of_property_read_bool(of_root, "ibm,powervm-partition") ||
of_property_read_bool(of_root, "ibm,fw-net-version"))
dn = of_find_node_by_path("/");
if (of_property_read_bool(dn, "ibm,powervm-partition") ||
of_property_read_bool(dn, "ibm,fw-net-version"))
seq_buf_printf(&ppc_hw_desc, "hv:phyp ");
of_node_put(dn);
}

/*
Expand Down Expand Up @@ -1091,7 +1093,11 @@ static void pseries_power_off(void)

static int __init pSeries_probe(void)
{
if (!of_node_is_type(of_root, "chrp"))
struct device_node *root = of_find_node_by_path("/");
bool ret = of_node_is_type(root, "chrp");

of_node_put(root);
if (!ret)
return 0;

/* Cell blades firmware claims to be chrp while it's not. Until this
Expand Down

0 comments on commit 83550c9

Please sign in to comment.