powerpc: Stop using of_root

Replace all usages of of_root by of_find_node_by_path("/")

Signed-off-by: Christophe Leroy <christophe.leroy@csgroup.eu>
Reviewed-by: Rob Herring <robh@kernel.org>
Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
Link: https://msgid.link/20231214103152.12269-5-mpe@ellerman.id.au
This commit is contained in:
Christophe Leroy 2023-12-14 21:31:52 +11:00 committed by Michael Ellerman
parent 28da734d58
commit 2a066ae118
8 changed files with 40 additions and 18 deletions

View File

@ -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");
@ -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");

View File

@ -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 */

View File

@ -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;

View File

@ -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;
@ -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);

View File

@ -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"))

View File

@ -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)

View File

@ -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);

View File

@ -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);
}
/*
@ -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