[PATCH v2] core: devres: optionally build devres into the SPL

Angus Ainslie angus at akkea.ca
Mon Feb 28 21:33:07 CET 2022


Add a CONFIG_SPL_DEVRES option

Signed-off-by: Angus Ainslie <angus at akkea.ca>
---

Changes since v1:

Instead of gaurding the source add an SPL_DEVRES option

 drivers/core/Kconfig  | 13 +++++++++++++
 drivers/core/Makefile |  2 +-
 2 files changed, 14 insertions(+), 1 deletion(-)

diff --git a/drivers/core/Kconfig b/drivers/core/Kconfig
index 8f7703c8b5..7e666708fe 100644
--- a/drivers/core/Kconfig
+++ b/drivers/core/Kconfig
@@ -206,6 +206,19 @@ config DEVRES
 	  non-managed variants.  For example, devres_alloc() to kzalloc(),
 	  devm_kmalloc() to kmalloc(), etc.
 
+config SPL_DEVRES
+	bool "Managed device resources in the SPL"
+	depends on DM
+	help
+	  This option enables the Managed device resources core support.
+	  Device resources managed by the devres framework are automatically
+	  released whether initialization fails half-way or the device gets
+	  detached.
+
+	  If this option is disabled, devres functions fall back to
+	  non-managed variants.  For example, devres_alloc() to kzalloc(),
+	  devm_kmalloc() to kmalloc(), etc.
+
 config DEBUG_DEVRES
 	bool "Managed device resources debugging functions"
 	depends on DEVRES
diff --git a/drivers/core/Makefile b/drivers/core/Makefile
index 5edd4e4135..0cbc3ab217 100644
--- a/drivers/core/Makefile
+++ b/drivers/core/Makefile
@@ -4,7 +4,7 @@
 
 obj-y	+= device.o fdtaddr.o lists.o root.o uclass.o util.o
 obj-$(CONFIG_$(SPL_TPL_)ACPIGEN) += acpi.o
-obj-$(CONFIG_DEVRES) += devres.o
+obj-$(CONFIG_$(SPL_TPL_)DEVRES) += devres.o
 obj-$(CONFIG_$(SPL_)DM_DEVICE_REMOVE)	+= device-remove.o
 obj-$(CONFIG_$(SPL_)SIMPLE_BUS)	+= simple-bus.o
 obj-$(CONFIG_SIMPLE_PM_BUS)	+= simple-pm-bus.o
-- 
2.25.1



More information about the U-Boot mailing list