Commit 15204ab1ebc5aba608cd19c83c37b98438b938b0

Authored by Pantelis Antoniou
Committed by Grant Likely
1 parent 3e7f7626fd

of/platform: Handle of_populate drivers in notifier

When using overlays with drivers calling of_populate the notifier
will try to create the device twice. Using the populated bit
before proceeding protects against this.

Signed-off-by: Pantelis Antoniou <pantelis.antoniou@konsulko.com>
Signed-off-by: Grant Likely <grant.likely@linaro.org>

Showing 1 changed file with 9 additions and 0 deletions Side-by-side Diff

drivers/of/platform.c
... ... @@ -566,6 +566,10 @@
566 566 if (!of_node_check_flag(rd->dn->parent, OF_POPULATED_BUS))
567 567 return NOTIFY_OK; /* not for us */
568 568  
  569 + /* already populated? (driver using of_populate manually) */
  570 + if (of_node_check_flag(rd->dn, OF_POPULATED))
  571 + return NOTIFY_OK;
  572 +
569 573 /* pdev_parent may be NULL when no bus platform device */
570 574 pdev_parent = of_find_device_by_node(rd->dn->parent);
571 575 pdev = of_platform_device_create(rd->dn, NULL,
... ... @@ -581,6 +585,11 @@
581 585 break;
582 586  
583 587 case OF_RECONFIG_CHANGE_REMOVE:
  588 +
  589 + /* already depopulated? */
  590 + if (!of_node_check_flag(rd->dn, OF_POPULATED))
  591 + return NOTIFY_OK;
  592 +
584 593 /* find our device by node */
585 594 pdev = of_find_device_by_node(rd->dn);
586 595 if (pdev == NULL)