]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
spi: change of_find_spi_controller_by_node() gating to CONFIG_OF
authorOder Chiou <oder_chiou@realtek.com>
Wed, 31 Dec 2025 02:36:49 +0000 (10:36 +0800)
committerMark Brown <broonie@kernel.org>
Mon, 5 Jan 2026 13:18:50 +0000 (13:18 +0000)
Currently, the helper of_find_spi_controller_by_node() is gated under
CONFIG_OF_DYNAMIC. This prevents drivers from using it in all CONFIG_OF
configurations.

This patch moves the gating to CONFIG_OF, keeping the inline fallback
returning NULL when Device Tree support is disabled.

Signed-off-by: Oder Chiou <oder_chiou@realtek.com>
Link: https://patch.msgid.link/6d8ae977d9f4726ea23ad5382638750593f9a2e4.1767148150.git.oder_chiou@realtek.com
Signed-off-by: Mark Brown <broonie@kernel.org>
drivers/spi/spi.c
include/linux/spi/spi.h

index ecb5281b04a25b22be53744a560749d0efdc67f3..2badacc7a91ce688dd8655f454e699683d5355f5 100644 (file)
@@ -4761,15 +4761,7 @@ EXPORT_SYMBOL_GPL(spi_write_then_read);
 
 /*-------------------------------------------------------------------------*/
 
-#if IS_ENABLED(CONFIG_OF_DYNAMIC)
-/* Must call put_device() when done with returned spi_device device */
-static struct spi_device *of_find_spi_device_by_node(struct device_node *node)
-{
-       struct device *dev = bus_find_device_by_of_node(&spi_bus_type, node);
-
-       return dev ? to_spi_device(dev) : NULL;
-}
-
+#if IS_ENABLED(CONFIG_OF)
 /* The spi controllers are not using spi_bus, so we find it with another way */
 struct spi_controller *of_find_spi_controller_by_node(struct device_node *node)
 {
@@ -4785,6 +4777,16 @@ struct spi_controller *of_find_spi_controller_by_node(struct device_node *node)
        return container_of(dev, struct spi_controller, dev);
 }
 EXPORT_SYMBOL_GPL(of_find_spi_controller_by_node);
+#endif
+
+#if IS_ENABLED(CONFIG_OF_DYNAMIC)
+/* Must call put_device() when done with returned spi_device device */
+static struct spi_device *of_find_spi_device_by_node(struct device_node *node)
+{
+       struct device *dev = bus_find_device_by_of_node(&spi_bus_type, node);
+
+       return dev ? to_spi_device(dev) : NULL;
+}
 
 static int of_spi_notify(struct notifier_block *nb, unsigned long action,
                         void *arg)
index e6fdaf02386c8d5e28a3225f07b159e22c2741da..8bc616b003432bf542a80a7f65cd748832ae7f19 100644 (file)
@@ -882,7 +882,7 @@ extern int devm_spi_register_controller(struct device *dev,
                                        struct spi_controller *ctlr);
 extern void spi_unregister_controller(struct spi_controller *ctlr);
 
-#if IS_ENABLED(CONFIG_OF_DYNAMIC)
+#if IS_ENABLED(CONFIG_OF)
 extern struct spi_controller *of_find_spi_controller_by_node(struct device_node *node);
 #else
 static inline struct spi_controller *of_find_spi_controller_by_node(struct device_node *node)