Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 15204ab1 authored by Pantelis Antoniou's avatar Pantelis Antoniou Committed by Grant Likely
Browse files

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: default avatarPantelis Antoniou <pantelis.antoniou@konsulko.com>
Signed-off-by: default avatarGrant Likely <grant.likely@linaro.org>
parent 3e7f7626
Loading
Loading
Loading
Loading
+9 −0
Original line number Diff line number Diff line
@@ -566,6 +566,10 @@ static int of_platform_notify(struct notifier_block *nb,
		if (!of_node_check_flag(rd->dn->parent, OF_POPULATED_BUS))
			return NOTIFY_OK;	/* not for us */

		/* already populated? (driver using of_populate manually) */
		if (of_node_check_flag(rd->dn, OF_POPULATED))
			return NOTIFY_OK;

		/* pdev_parent may be NULL when no bus platform device */
		pdev_parent = of_find_device_by_node(rd->dn->parent);
		pdev = of_platform_device_create(rd->dn, NULL,
@@ -581,6 +585,11 @@ static int of_platform_notify(struct notifier_block *nb,
		break;

	case OF_RECONFIG_CHANGE_REMOVE:

		/* already depopulated? */
		if (!of_node_check_flag(rd->dn, OF_POPULATED))
			return NOTIFY_OK;

		/* find our device by node */
		pdev = of_find_device_by_node(rd->dn);
		if (pdev == NULL)