From patchwork Mon Jul 17 14:37:16 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Rob Herring (Arm)" X-Patchwork-Id: 1808780 Return-Path: X-Original-To: incoming-dt@patchwork.ozlabs.org Delivered-To: patchwork-incoming-dt@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=vger.kernel.org (client-ip=2620:137:e000::1:20; helo=out1.vger.email; envelope-from=devicetree-owner@vger.kernel.org; receiver=) Authentication-Results: legolas.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20201202 header.b=AwfuVLCa; dkim-atps=neutral Received: from out1.vger.email (out1.vger.email [IPv6:2620:137:e000::1:20]) by legolas.ozlabs.org (Postfix) with ESMTP id 4R4Pn34C55z20FK for ; Tue, 18 Jul 2023 00:37:27 +1000 (AEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229471AbjGQOhZ (ORCPT ); Mon, 17 Jul 2023 10:37:25 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58400 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229956AbjGQOhY (ORCPT ); Mon, 17 Jul 2023 10:37:24 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 42A97E3; Mon, 17 Jul 2023 07:37:23 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id C7089610A2; Mon, 17 Jul 2023 14:37:22 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id C77E7C433C8; Mon, 17 Jul 2023 14:37:21 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1689604642; bh=9pC2imQJgAfczabA7SVAkkQZ10wRCzLbSNn3X5leRmY=; h=From:To:Cc:Subject:Date:From; b=AwfuVLCaBpYGBMQ2tq8oG+vIoN/xhHuy0rqoixqNcCiDUL/MESYTWJ4EL+95UAS/P yS4XYe81JLSg2ENGrQm9y0A4s83gAq3L6m5bTv3ja5N1Sg6Zagkftg2GjLLyzwpZsu hCgY++XMIliKcblIRWOgf5IZyeALgV1ASkp+HMUMsGGvBVtlZMiDJm+6Ec0Bk507CC E3i8EHK9kyO3cFJbTbD5ni4Eb9/x+j65sw0OD+xn9uN+330iYRfPTvHeasPjsvSmef XkBA515O2vVsmNf8hgJYq0SmlcN85aydYVuvCHO+nSkTXa+ZWXkJxT4mE+OTxInECh rpOfOzQHQpTxQ== Received: (nullmailer pid 1715843 invoked by uid 1000); Mon, 17 Jul 2023 14:37:20 -0000 From: Rob Herring To: Greg Kroah-Hartman , "Rafael J. Wysocki" , Frank Rowand Cc: linux-kernel@vger.kernel.org, devicetree@vger.kernel.org Subject: [PATCH 1/2] of: Move of_platform_register_reconfig_notifier() into DT core Date: Mon, 17 Jul 2023 08:37:16 -0600 Message-Id: <20230717143718.1715773-1-robh@kernel.org> X-Mailer: git-send-email 2.40.1 MIME-Version: 1.0 X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF, RCVD_IN_DNSWL_BLOCKED,SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham 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: devicetree@vger.kernel.org There's no reason the generic platform bus code needs to call of_platform_register_reconfig_notifier(). The notifier can be setup before the platform bus is. Let's move it into of_core_init() which is called just before platform_bus_init() instead to keep more of the DT bits in the DT code. Signed-off-by: Rob Herring Reviewed-by: Greg Kroah-Hartman --- drivers/base/platform.c | 2 +- drivers/of/base.c | 1 + drivers/of/of_private.h | 6 ++++++ drivers/of/platform.c | 2 ++ include/linux/of_platform.h | 6 ------ 5 files changed, 10 insertions(+), 7 deletions(-) diff --git a/drivers/base/platform.c b/drivers/base/platform.c index 77510e4f47de..76bfcba25003 100644 --- a/drivers/base/platform.c +++ b/drivers/base/platform.c @@ -1528,6 +1528,6 @@ int __init platform_bus_init(void) error = bus_register(&platform_bus_type); if (error) device_unregister(&platform_bus); - of_platform_register_reconfig_notifier(); + return error; } diff --git a/drivers/of/base.c b/drivers/of/base.c index 166fb7d75337..e235f3a57ea8 100644 --- a/drivers/of/base.c +++ b/drivers/of/base.c @@ -167,6 +167,7 @@ void __init of_core_init(void) { struct device_node *np; + of_platform_register_reconfig_notifier(); /* Create the kset, and register existing nodes */ mutex_lock(&of_mutex); diff --git a/drivers/of/of_private.h b/drivers/of/of_private.h index b57f1014e419..f38397c7b582 100644 --- a/drivers/of/of_private.h +++ b/drivers/of/of_private.h @@ -60,6 +60,12 @@ static inline int of_property_notify(int action, struct device_node *np, } #endif /* CONFIG_OF_DYNAMIC */ +#if defined(CONFIG_OF_DYNAMIC) && defined(CONFIG_OF_ADDRESS) +void of_platform_register_reconfig_notifier(void); +#else +static inline void of_platform_register_reconfig_notifier(void) { } +#endif + #if defined(CONFIG_OF_KOBJ) int of_node_is_attached(const struct device_node *node); int __of_add_property_sysfs(struct device_node *np, struct property *pp); diff --git a/drivers/of/platform.c b/drivers/of/platform.c index 051e29b7ad2b..e71adb394b41 100644 --- a/drivers/of/platform.c +++ b/drivers/of/platform.c @@ -21,6 +21,8 @@ #include #include +#include "of_private.h" + const struct of_device_id of_default_bus_match_table[] = { { .compatible = "simple-bus", }, { .compatible = "simple-mfd", }, diff --git a/include/linux/of_platform.h b/include/linux/of_platform.h index d8045bcfc35e..fadfea575485 100644 --- a/include/linux/of_platform.h +++ b/include/linux/of_platform.h @@ -127,10 +127,4 @@ static inline int devm_of_platform_populate(struct device *dev) static inline void devm_of_platform_depopulate(struct device *dev) { } #endif -#if defined(CONFIG_OF_DYNAMIC) && defined(CONFIG_OF_ADDRESS) -extern void of_platform_register_reconfig_notifier(void); -#else -static inline void of_platform_register_reconfig_notifier(void) { } -#endif - #endif /* _LINUX_OF_PLATFORM_H */ From patchwork Mon Jul 17 14:37:17 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Rob Herring (Arm)" X-Patchwork-Id: 1808781 Return-Path: X-Original-To: incoming-dt@patchwork.ozlabs.org Delivered-To: patchwork-incoming-dt@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=vger.kernel.org (client-ip=2620:137:e000::1:20; helo=out1.vger.email; envelope-from=devicetree-owner@vger.kernel.org; receiver=) Authentication-Results: legolas.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20201202 header.b=X5C7K3P+; dkim-atps=neutral Received: from out1.vger.email (out1.vger.email [IPv6:2620:137:e000::1:20]) by legolas.ozlabs.org (Postfix) with ESMTP id 4R4Pn403vzz20FM for ; Tue, 18 Jul 2023 00:37:28 +1000 (AEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231551AbjGQOh0 (ORCPT ); Mon, 17 Jul 2023 10:37:26 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58406 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231421AbjGQOhZ (ORCPT ); Mon, 17 Jul 2023 10:37:25 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B02CCC0; Mon, 17 Jul 2023 07:37:24 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 4653A6108C; Mon, 17 Jul 2023 14:37:24 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 514ECC433C7; Mon, 17 Jul 2023 14:37:23 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1689604643; bh=3KYO7KtyLAd/pTASmKd5Z6U9SP2SvfsV9oMlmbcorRQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=X5C7K3P+yB17TMXHQ6ezLU4ZnoSU9iirM5xckLLEsKZduRFTVTUiT5bosFgfa4W1S MWKJaSybG9ds/hzk0UBtw+qEaFbDeGtE+/eKQTZwOsq11EBhntRxUsaHVmtEafkKm0 crn2MreJ1Va6Xzn4pM6mC2mgdGqHlaa2BxyvDZWIii4LTW9sBkZJGGQsePPyyTwlTO oYDxg9xUrB0cBT454ea9ftYuX4gb4Zkmq0tJKJon9fHhJ+5Dc76xIRFXq9SwOWLb7M 4Bt+nZ0hzZndqnqfzoo7/nT5/ZRorercwEHcdjLbNy0BmPhdWszjGTMviTmWW5NyoY NYuO2QdxrLNcg== Received: (nullmailer pid 1715882 invoked by uid 1000); Mon, 17 Jul 2023 14:37:20 -0000 From: Rob Herring To: Greg Kroah-Hartman , "Rafael J. Wysocki" , Frank Rowand Cc: linux-kernel@vger.kernel.org, devicetree@vger.kernel.org Subject: [PATCH 2/2] of: Move of_device_{add,register,unregister} to platform.c Date: Mon, 17 Jul 2023 08:37:17 -0600 Message-Id: <20230717143718.1715773-2-robh@kernel.org> X-Mailer: git-send-email 2.40.1 In-Reply-To: <20230717143718.1715773-1-robh@kernel.org> References: <20230717143718.1715773-1-robh@kernel.org> MIME-Version: 1.0 X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF, RCVD_IN_DNSWL_BLOCKED,SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham 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: devicetree@vger.kernel.org The declarations for of_device_{add,register,unregister} were moved into of_platform.h, so the implementations should be moved to platform.c as well. Signed-off-by: Rob Herring Reviewed-by: Greg Kroah-Hartman --- drivers/of/device.c | 32 -------------------------------- drivers/of/platform.c | 32 ++++++++++++++++++++++++++++++++ 2 files changed, 32 insertions(+), 32 deletions(-) diff --git a/drivers/of/device.c b/drivers/of/device.c index 0f00f1b80708..2319e0e73048 100644 --- a/drivers/of/device.c +++ b/drivers/of/device.c @@ -32,25 +32,6 @@ const struct of_device_id *of_match_device(const struct of_device_id *matches, } EXPORT_SYMBOL(of_match_device); -int of_device_add(struct platform_device *ofdev) -{ - BUG_ON(ofdev->dev.of_node == NULL); - - /* name and id have to be set so that the platform bus doesn't get - * confused on matching */ - ofdev->name = dev_name(&ofdev->dev); - ofdev->id = PLATFORM_DEVID_NONE; - - /* - * If this device has not binding numa node in devicetree, that is - * of_node_to_nid returns NUMA_NO_NODE. device_add will assume that this - * device is on the same node as the parent. - */ - set_dev_node(&ofdev->dev, of_node_to_nid(ofdev->dev.of_node)); - - return device_add(&ofdev->dev); -} - static void of_dma_set_restricted_buffer(struct device *dev, struct device_node *np) { @@ -221,19 +202,6 @@ int of_dma_configure_id(struct device *dev, struct device_node *np, } EXPORT_SYMBOL_GPL(of_dma_configure_id); -int of_device_register(struct platform_device *pdev) -{ - device_initialize(&pdev->dev); - return of_device_add(pdev); -} -EXPORT_SYMBOL(of_device_register); - -void of_device_unregister(struct platform_device *ofdev) -{ - device_unregister(&ofdev->dev); -} -EXPORT_SYMBOL(of_device_unregister); - const void *of_device_get_match_data(const struct device *dev) { const struct of_device_id *match; diff --git a/drivers/of/platform.c b/drivers/of/platform.c index e71adb394b41..8d03d9e65ef9 100644 --- a/drivers/of/platform.c +++ b/drivers/of/platform.c @@ -56,6 +56,38 @@ struct platform_device *of_find_device_by_node(struct device_node *np) } EXPORT_SYMBOL(of_find_device_by_node); +int of_device_add(struct platform_device *ofdev) +{ + BUG_ON(ofdev->dev.of_node == NULL); + + /* name and id have to be set so that the platform bus doesn't get + * confused on matching */ + ofdev->name = dev_name(&ofdev->dev); + ofdev->id = PLATFORM_DEVID_NONE; + + /* + * If this device has not binding numa node in devicetree, that is + * of_node_to_nid returns NUMA_NO_NODE. device_add will assume that this + * device is on the same node as the parent. + */ + set_dev_node(&ofdev->dev, of_node_to_nid(ofdev->dev.of_node)); + + return device_add(&ofdev->dev); +} + +int of_device_register(struct platform_device *pdev) +{ + device_initialize(&pdev->dev); + return of_device_add(pdev); +} +EXPORT_SYMBOL(of_device_register); + +void of_device_unregister(struct platform_device *ofdev) +{ + device_unregister(&ofdev->dev); +} +EXPORT_SYMBOL(of_device_unregister); + #ifdef CONFIG_OF_ADDRESS /* * The following routines scan a subtree and registers a device for