Received: by 2002:ab2:7903:0:b0:1fb:b500:807b with SMTP id a3csp1254223lqj; Mon, 3 Jun 2024 15:38:26 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCWQ8zsHvfVuMDGy/X2tmjWPvWytpyVHSBe/L3YSwkikrZSMtRCjKAx+GsjO/1T2Q+RinswV5ya19Tk8nBp+b9BBpx6c8tsNLZRq228tWg== X-Google-Smtp-Source: AGHT+IEOk44mwpMGlD0J1EBcZDeDahXDr4SZzy4DG3h2RPo9nHa1XBMs4XW0CxlJix/aYW8gVO3x X-Received: by 2002:a37:e10b:0:b0:790:945e:6f0 with SMTP id af79cd13be357-794f5cc6a55mr1129012785a.55.1717454306227; Mon, 03 Jun 2024 15:38:26 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1717454306; cv=pass; d=google.com; s=arc-20160816; b=1BRfU/HfYUDXpSKaVQhcFHSXysKq5E+d5NtYh3FcGAeOvzGY3Qq16UTncPMiUMUzze 05JlLZTHUmbmdQ8+y5UbiR8gY+WtSrWcUaesmX4cl5ky+9bffdYi70semNJjFT9uTGBO 5OM6e7suL53y84mjVQhDDMJ+iNtmVyXJvvlhmpWeCh7rNEnv0pMZdNVzUozYoD48OJCA NdEOEG/Oh1+yNNrMWRjGHLKMpluc3C4dFErwBBmw6U+LFYR11uOR19azDqI++3GO8x82 MBya5cfp8kxlYaZsJQfH4HCWTiiy2ZDZWdZGwlpRGAQ3aIiLi3Ft0Qdqq6no2moHX04k HlbA== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from:dkim-signature; bh=aJ9B6+GR/xC7Eq+5wVqBH2zWEK0GZ6mrdoDH7XsO4IU=; fh=V3q660E7jJuFePuHUOWKHHu4ulEp8NjGRgFgZbQSOmw=; b=NjJ85lGMIfoP3KJVsdkSheto5lFWjQtLsuqo6ap+juAZvVZL3ja6eknTwhQ+vOqwHL TPpLX5Ccvz6Rrlp62gov+gsE3xM2MJ8liQ2i+EgQ7UiQWxxirQPrP7SoaKdMevzCh/3S qxl2A9/lODQU5ULbvCJBj6H7jOiaxF8CKLFYj5C6Bba01tGyCDHU4beitkVjLYipw7L8 mfOpmkFbpUF7HQ1ibcWx5WvVMrPV6DEIivFdM2Sv0F8D0zzkDKyDLmRf2KVVs2O1J3UT becGjkTSuf74ikHjJuceb7MmlxyrPTKEOXlh9H4g4ZgXdFgG5uvgh2BYZeUvqrE5cydG o1lg==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=k5hA0ee+; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-199769-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-199769-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [147.75.199.223]) by mx.google.com with ESMTPS id af79cd13be357-794f3063dadsi1069808785a.361.2024.06.03.15.38.25 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 03 Jun 2024 15:38:26 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-199769-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) client-ip=147.75.199.223; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=k5hA0ee+; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-199769-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-199769-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ny.mirrors.kernel.org (Postfix) with ESMTPS id BC17E1C234BB for ; Mon, 3 Jun 2024 22:38:25 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 10A6713CFA4; Mon, 3 Jun 2024 22:38:15 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="k5hA0ee+" Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 2776D13CAB8; Mon, 3 Jun 2024 22:38:13 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717454294; cv=none; b=e/NlyGyEaUsT913TocEphdSHY6BbMebogPHNGb18cryFrE/Dgp74+RuSzzTzlBV0nuaMkB7dObDb9F2HfPbcUsKvGFnOQqGab4QpirMDUrBnt2wbLfpzAmmTxeGs12ZSBQgp3wmSCREFd3GKngHCyCIVnRMSBiYnd3nufIiJL+c= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717454294; c=relaxed/simple; bh=B0v2xIJko44NFxcAkJF3hOkV1yBox9EJRkSOKT1AxsE=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=sByDFt1Vyccr18iiiEcualjRQVYJSCwj5o68/VUo9ZQBd3lQtpk04EFzqPAvpCE+p/ZzU/J+FPDmXMzKS1BQFqC+tlOb0OI1BElwZL758Acqn+BzQL5bVLkRTa8MIDW5PNu0X8pO6y7rejOUgqBLi96hqsgAsM5litXFqLEIcfM= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=k5hA0ee+; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPSA id CE4A7C4AF0A; Mon, 3 Jun 2024 22:38:12 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1717454293; bh=B0v2xIJko44NFxcAkJF3hOkV1yBox9EJRkSOKT1AxsE=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=k5hA0ee+3x+T1lL31FP9be1PVlkBcFeiA95+Pr9JAIM+lWR5phAqWag/ONX7JBDs6 RwUulF2tQGpSd7i+fnSYWcqrVllQJBqkBnqIeC6xWUc3gwaBCjKUie2y12dBiS4jbc iG8y+MXcsvOeIYSOuvAnnswch3P2cCBGrp4J9+zuGXW4n0huG81V+529xkpHl2XriH AtZAh3sXG3F0X1TEGVsYeFQV/Ns2N/EY+FEdC4DtytuvRR595e86aGJ7cOYwkyy5e1 5LCOu6E9NL+O5cVJoCXkZ3Q+XUUwDlbBmFudvPFcO8eqmmX5RG3LqqOpLhBsuoWjEq PJjvkMCo97P+g== From: Stephen Boyd To: Michael Turquette , Stephen Boyd Cc: linux-kernel@vger.kernel.org, linux-clk@vger.kernel.org, patches@lists.linux.dev, kunit-dev@googlegroups.com, linux-kselftest@vger.kernel.org, devicetree@vger.kernel.org, Brendan Higgins , David Gow , Rae Moar , Greg Kroah-Hartman , "Rafael J . Wysocki" , Rob Herring , Saravana Kannan , Daniel Latypov , Christian Marangi , Krzysztof Kozlowski , Conor Dooley , Maxime Ripard Subject: [PATCH v5 01/11] of/platform: Allow overlays to create platform devices from the root node Date: Mon, 3 Jun 2024 15:37:58 -0700 Message-ID: <20240603223811.3815762-2-sboyd@kernel.org> X-Mailer: git-send-email 2.45.1.288.g0e0cd299f1-goog In-Reply-To: <20240603223811.3815762-1-sboyd@kernel.org> References: <20240603223811.3815762-1-sboyd@kernel.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit We'd like to apply overlays to the root node in KUnit so we can test platform devices created as children of the root node. On some architectures (powerpc), the root node isn't marked with OF_POPULATED_BUS. If an overlay tries to modify the root node on these platforms it will fail, while on other platforms, such as ARM, it will succeed. This is because the root node is marked with OF_POPULATED_BUS by of_platform_default_populate_init() calling of_platform_default_populate() with NULL as the first argument. Loosen the requirement here so that platform devices can be created for nodes created as children of the root node via DT overlays even if the platform bus wasn't populated for the root node. Cc: Rob Herring Cc: Saravana Kannan Signed-off-by: Stephen Boyd --- drivers/of/platform.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/drivers/of/platform.c b/drivers/of/platform.c index 389d4ea6bfc1..bda6da866cc8 100644 --- a/drivers/of/platform.c +++ b/drivers/of/platform.c @@ -732,11 +732,14 @@ static int of_platform_notify(struct notifier_block *nb, struct of_reconfig_data *rd = arg; struct platform_device *pdev_parent, *pdev; bool children_left; + struct device_node *parent; switch (of_reconfig_get_state_change(action, rd)) { case OF_RECONFIG_CHANGE_ADD: - /* verify that the parent is a bus */ - if (!of_node_check_flag(rd->dn->parent, OF_POPULATED_BUS)) + parent = rd->dn->parent; + /* verify that the parent is a bus (or the root node) */ + if (!of_node_is_root(parent) && + of_node_check_flag(parent, OF_POPULATED_BUS)) return NOTIFY_OK; /* not for us */ /* already populated? (driver using of_populate manually) */ @@ -749,7 +752,7 @@ static int of_platform_notify(struct notifier_block *nb, */ rd->dn->fwnode.flags &= ~FWNODE_FLAG_NOT_DEVICE; /* pdev_parent may be NULL when no bus platform device */ - pdev_parent = of_find_device_by_node(rd->dn->parent); + pdev_parent = of_find_device_by_node(parent); pdev = of_platform_device_create(rd->dn, NULL, pdev_parent ? &pdev_parent->dev : NULL); platform_device_put(pdev_parent); -- https://git.kernel.org/pub/scm/linux/kernel/git/clk/linux.git/ https://git.kernel.org/pub/scm/linux/kernel/git/sboyd/spmi.git