Received: by 2002:a05:6358:11c7:b0:104:8066:f915 with SMTP id i7csp830805rwl; Fri, 24 Mar 2023 02:34:20 -0700 (PDT) X-Google-Smtp-Source: AKy350bEESlf/fixvelrrq/2ZOAZ8+LEuo012uvJppSYRXcaa0zEGU/Cv32wqmUBkn10p025hDBw X-Received: by 2002:a17:906:2a1a:b0:92f:ab75:1605 with SMTP id j26-20020a1709062a1a00b0092fab751605mr1495831eje.73.1679650460163; Fri, 24 Mar 2023 02:34:20 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1679650460; cv=none; d=google.com; s=arc-20160816; b=f1P8/40X44e8mQq4bBEXZZKoy1PypcMzBxQA8jNhdvafSTW+UorN73TpBJF4i3m9ef HB2i7vpVhZBvSwDvoKvPvuV4H5KQVAplmiLX4zWEP5Tj3ctc9t8zNjQDZ9qsy3JtWLnt XNxHfBt29XMwTlw0pN8rjkLIUzbUSgAN2rWcaSfkmcYcUbZHfR7EpMgZ7LVycrPpTXdB EhGKpbjYOtsddeJicAJod/k+ViEGVJQw1DZ3KZ+pWAkeKkGLVitTlzN/HMqbp7sLoM0N jel1PiSMx92cwFqE4/6tMrw98gvPr4j/aH2JZf4sAgnC5zdZioWH1npROKIF0kwfvgXO MBaA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from; bh=d+IHOIe8tQ8g4SumOCK+KEiP2uyVzufDChJ2KdpHyN4=; b=NJ55DRgl7NtF+A7QwSHVs5gdpFNFQyOxjVsCSmUf8R0bUgB/WwyFsI9YZAeLgnUMad QAg0Swz9UCXGEgMAg4QG38CQRFf1AMU+1tV20HYUlb63+Uq430/xxbw2+Dl+m2IUBGh3 fl9rFS20X7mXmrKCvykTx8emBTrmXVZCghX6oXKC1e6+rmElEH6mPNyKpDDRAmNXwkHr qXNtAxPqFndYAVhJlbro8mumOhv5uku7p1Y5Ter48LxO9CtJDLG4rctUAxXLoOlqEtTo 7/vpfBul/ZwgeMC/wlgDVNDtKxCriUoe7o6iegy8eMLtfP479LQfVc5Yfk3py8kMxRQ4 rwvQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id g22-20020aa7d1d6000000b004bf976a1b56si20521532edp.627.2023.03.24.02.33.56; Fri, 24 Mar 2023 02:34:20 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230455AbjCXJa6 (ORCPT + 99 others); Fri, 24 Mar 2023 05:30:58 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37536 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229734AbjCXJa4 (ORCPT ); Fri, 24 Mar 2023 05:30:56 -0400 Received: from michel.telenet-ops.be (michel.telenet-ops.be [IPv6:2a02:1800:110:4::f00:18]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B82592365E for ; Fri, 24 Mar 2023 02:30:53 -0700 (PDT) Received: from ramsan.of.borg ([84.195.187.55]) by michel.telenet-ops.be with bizsmtp id c9Wh290031C8whw069Whz3; Fri, 24 Mar 2023 10:30:50 +0100 Received: from rox.of.borg ([192.168.97.57]) by ramsan.of.borg with esmtp (Exim 4.95) (envelope-from ) id 1pfdkD-00EQQI-Tm; Fri, 24 Mar 2023 10:30:41 +0100 Received: from geert by rox.of.borg with local (Exim 4.95) (envelope-from ) id 1pfdkv-00CQVy-0d; Fri, 24 Mar 2023 10:30:41 +0100 From: Geert Uytterhoeven To: Greg Kroah-Hartman , Saravana Kannan Cc: Shawn Guo , Sascha Hauer , Pengutronix Kernel Team , Fabio Estevam , NXP Linux Team , Wolfram Sang , Rob Herring , Frank Rowand , Mark Brown , linux-arm-kernel@lists.infradead.org, linux-i2c@vger.kernel.org, devicetree@vger.kernel.org, linux-spi@vger.kernel.org, linux-renesas-soc@vger.kernel.org, linux-kernel@vger.kernel.org, Geert Uytterhoeven Subject: [PATCH v2] treewide: Fix instantiation of devices in DT overlays Date: Fri, 24 Mar 2023 10:30:39 +0100 Message-Id: <240155f20aae47e9f7461e2b7416120ba6238886.1679650087.git.geert+renesas@glider.be> X-Mailer: git-send-email 2.34.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-0.4 required=5.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, RCVD_IN_DNSWL_LOW,SPF_HELO_NONE,SPF_NONE autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org When loading a DT overlay that creates a device, the device is not instantiated, unless the DT overlay is unloaded and reloaded again. Saravana explains: Basically for all overlays (I hope the function is only used for overlays) we assume all nodes are NOT devices until they actually get added as a device. Based on a patch by Saravana Kannan, which covered only platform and spi devices. Fixes: 4a032827daa89350 ("of: property: Simplify of_link_to_phandle()") Link: https://lore.kernel.org/r/CAGETcx_+rhHvaC_HJXGrr5_WAd2+k5f=rWYnkCZ6z5bGX-wj4w@mail.gmail.com Signed-off-by: Geert Uytterhoeven Acked-by: Mark Brown --- v2: - Add Acked-by, - Drop RFC. --- drivers/bus/imx-weim.c | 1 + drivers/i2c/i2c-core-of.c | 1 + drivers/of/dynamic.c | 1 + drivers/of/platform.c | 1 + drivers/spi/spi.c | 1 + 5 files changed, 5 insertions(+) diff --git a/drivers/bus/imx-weim.c b/drivers/bus/imx-weim.c index 36d42484142aede2..898e23a4231400fa 100644 --- a/drivers/bus/imx-weim.c +++ b/drivers/bus/imx-weim.c @@ -329,6 +329,7 @@ static int of_weim_notify(struct notifier_block *nb, unsigned long action, "Failed to setup timing for '%pOF'\n", rd->dn); if (!of_node_check_flag(rd->dn, OF_POPULATED)) { + rd->dn->fwnode.flags &= ~FWNODE_FLAG_NOT_DEVICE; if (!of_platform_device_create(rd->dn, NULL, &pdev->dev)) { dev_err(&pdev->dev, "Failed to create child device '%pOF'\n", diff --git a/drivers/i2c/i2c-core-of.c b/drivers/i2c/i2c-core-of.c index aa93467784c29c89..303f9003562eed3d 100644 --- a/drivers/i2c/i2c-core-of.c +++ b/drivers/i2c/i2c-core-of.c @@ -178,6 +178,7 @@ static int of_i2c_notify(struct notifier_block *nb, unsigned long action, return NOTIFY_OK; } + rd->dn->fwnode.flags &= ~FWNODE_FLAG_NOT_DEVICE; client = of_i2c_register_device(adap, rd->dn); if (IS_ERR(client)) { dev_err(&adap->dev, "failed to create client for '%pOF'\n", diff --git a/drivers/of/dynamic.c b/drivers/of/dynamic.c index 07d93753b12f5f4d..e311d406b1705306 100644 --- a/drivers/of/dynamic.c +++ b/drivers/of/dynamic.c @@ -226,6 +226,7 @@ static void __of_attach_node(struct device_node *np) np->sibling = np->parent->child; np->parent->child = np; of_node_clear_flag(np, OF_DETACHED); + np->fwnode.flags |= FWNODE_FLAG_NOT_DEVICE; } /** diff --git a/drivers/of/platform.c b/drivers/of/platform.c index b2bd2e783445dd78..17c92cbfb62ee3ef 100644 --- a/drivers/of/platform.c +++ b/drivers/of/platform.c @@ -737,6 +737,7 @@ static int of_platform_notify(struct notifier_block *nb, if (of_node_check_flag(rd->dn, OF_POPULATED)) return NOTIFY_OK; + 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 = of_platform_device_create(rd->dn, NULL, diff --git a/drivers/spi/spi.c b/drivers/spi/spi.c index 8e8af148b1dc371e..66ac67580d2a473b 100644 --- a/drivers/spi/spi.c +++ b/drivers/spi/spi.c @@ -4527,6 +4527,7 @@ static int of_spi_notify(struct notifier_block *nb, unsigned long action, return NOTIFY_OK; } + rd->dn->fwnode.flags &= ~FWNODE_FLAG_NOT_DEVICE; spi = of_register_spi_device(ctlr, rd->dn); put_device(&ctlr->dev); -- 2.34.1