Skip to content

Commit d8298d2

Browse files
committed
Merge tag 'devicetree-fixes-for-4.8' of git://git.kernel.org/pub/scm/linux/kernel/git/robh/linux
Pull DeviceTree fixes from Rob Herring: - a couple of DT node ref counting fixes - fix __unflatten_device_tree for PPC PCI hotplug case - rework marking irq controllers as OF_POPULATED in cases where real driver is used. - disable of_platform_default_populate_init on PPC. The change in initcall order causes problems which need to be sorted out later. * tag 'devicetree-fixes-for-4.8' of git://git.kernel.org/pub/scm/linux/kernel/git/robh/linux: of: fix reference counting in of_graph_get_endpoint_by_regs of/platform: disable the of_platform_default_populate_init() for all the ppc boards ARM: imx6: mark GPC node as not populated after irq init to probe pm domain driver of/irq: Mark interrupt controllers as populated before initialisation drivers/of: Validate device node in __unflatten_device_tree() of: Delete an unnecessary check before the function call "of_node_put"
2 parents 5cae6fe + 34276bb commit d8298d2

File tree

5 files changed

+15
-14
lines changed

5 files changed

+15
-14
lines changed

arch/arm/mach-imx/gpc.c

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -271,6 +271,12 @@ static int __init imx_gpc_init(struct device_node *node,
271271
for (i = 0; i < IMR_NUM; i++)
272272
writel_relaxed(~0, gpc_base + GPC_IMR1 + i * 4);
273273

274+
/*
275+
* Clear the OF_POPULATED flag set in of_irq_init so that
276+
* later the GPC power domain driver will not be skipped.
277+
*/
278+
of_node_clear_flag(node, OF_POPULATED);
279+
274280
return 0;
275281
}
276282
IRQCHIP_DECLARE(imx_gpc, "fsl,imx6q-gpc", imx_gpc_init);

drivers/of/base.c

Lines changed: 3 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1631,8 +1631,7 @@ static int __of_parse_phandle_with_args(const struct device_node *np,
16311631
*/
16321632

16331633
err:
1634-
if (it.node)
1635-
of_node_put(it.node);
1634+
of_node_put(it.node);
16361635
return rc;
16371636
}
16381637

@@ -2343,20 +2342,13 @@ struct device_node *of_graph_get_endpoint_by_regs(
23432342
const struct device_node *parent, int port_reg, int reg)
23442343
{
23452344
struct of_endpoint endpoint;
2346-
struct device_node *node, *prev_node = NULL;
2347-
2348-
while (1) {
2349-
node = of_graph_get_next_endpoint(parent, prev_node);
2350-
of_node_put(prev_node);
2351-
if (!node)
2352-
break;
2345+
struct device_node *node = NULL;
23532346

2347+
for_each_endpoint_of_node(parent, node) {
23542348
of_graph_parse_endpoint(node, &endpoint);
23552349
if (((port_reg == -1) || (endpoint.port == port_reg)) &&
23562350
((reg == -1) || (endpoint.id == reg)))
23572351
return node;
2358-
2359-
prev_node = node;
23602352
}
23612353

23622354
return NULL;

drivers/of/fdt.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -517,7 +517,7 @@ static void *__unflatten_device_tree(const void *blob,
517517
pr_warning("End of tree marker overwritten: %08x\n",
518518
be32_to_cpup(mem + size));
519519

520-
if (detached) {
520+
if (detached && mynodes) {
521521
of_node_set_flag(*mynodes, OF_DETACHED);
522522
pr_debug("unflattened tree is detached\n");
523523
}

drivers/of/irq.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -544,12 +544,15 @@ void __init of_irq_init(const struct of_device_id *matches)
544544

545545
list_del(&desc->list);
546546

547+
of_node_set_flag(desc->dev, OF_POPULATED);
548+
547549
pr_debug("of_irq_init: init %s (%p), parent %p\n",
548550
desc->dev->full_name,
549551
desc->dev, desc->interrupt_parent);
550552
ret = desc->irq_init_cb(desc->dev,
551553
desc->interrupt_parent);
552554
if (ret) {
555+
of_node_clear_flag(desc->dev, OF_POPULATED);
553556
kfree(desc);
554557
continue;
555558
}
@@ -559,8 +562,6 @@ void __init of_irq_init(const struct of_device_id *matches)
559562
* its children can get processed in a subsequent pass.
560563
*/
561564
list_add_tail(&desc->list, &intc_parent_list);
562-
563-
of_node_set_flag(desc->dev, OF_POPULATED);
564565
}
565566

566567
/* Get the next pending parent that might have children */

drivers/of/platform.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -497,6 +497,7 @@ int of_platform_default_populate(struct device_node *root,
497497
}
498498
EXPORT_SYMBOL_GPL(of_platform_default_populate);
499499

500+
#ifndef CONFIG_PPC
500501
static int __init of_platform_default_populate_init(void)
501502
{
502503
struct device_node *node;
@@ -521,6 +522,7 @@ static int __init of_platform_default_populate_init(void)
521522
return 0;
522523
}
523524
arch_initcall_sync(of_platform_default_populate_init);
525+
#endif
524526

525527
static int of_platform_device_destroy(struct device *dev, void *data)
526528
{

0 commit comments

Comments
 (0)