[RFC PATCH 03/15] dm: Add a way to write the internal seq_ member

Simon Glass sjg at chromium.org
Thu Mar 19 22:35:33 CET 2026


Add a dev_int_set_seq() inline in device-internal.h to wrap writes to
dev->seq_ from outside the driver-model core. This is the write side of
dev_seq() and should be used only when absolutely necessary.

Use it in pci-uclass.c which is the only external caller that sets
seq_ directly.

Signed-off-by: Simon Glass <sjg at chromium.org>
---

 drivers/core/device.c        | 5 +++++
 drivers/pci/pci-uclass.c     | 2 +-
 include/dm/device-internal.h | 3 +++
 3 files changed, 9 insertions(+), 1 deletion(-)

diff --git a/drivers/core/device.c b/drivers/core/device.c
index 779f371b9d5..a55fdb1628f 100644
--- a/drivers/core/device.c
+++ b/drivers/core/device.c
@@ -1179,6 +1179,11 @@ void dev_set_uclass_plat(struct udevice *dev, void *uclass_plat)
 	dev->uclass_plat_ = uclass_plat;
 }
 
+void dev_int_set_seq(struct udevice *dev, int seq)
+{
+	dev->seq_ = seq;
+}
+
 #if CONFIG_IS_ENABLED(OF_REAL)
 bool device_is_compatible(const struct udevice *dev, const char *compat)
 {
diff --git a/drivers/pci/pci-uclass.c b/drivers/pci/pci-uclass.c
index 83b76d01f24..016a3c79220 100644
--- a/drivers/pci/pci-uclass.c
+++ b/drivers/pci/pci-uclass.c
@@ -1161,7 +1161,7 @@ static int pci_uclass_pre_probe(struct udevice *bus)
 		ret = uclass_get(UCLASS_PCI, &uc);
 		if (ret)
 			return ret;
-		bus->seq_ = uclass_find_next_free_seq(uc);
+		dev_int_set_seq(bus, uclass_find_next_free_seq(uc));
 	}
 
 	/* For bridges, use the top-level PCI controller */
diff --git a/include/dm/device-internal.h b/include/dm/device-internal.h
index f31c4702086..4f86ab5c8ed 100644
--- a/include/dm/device-internal.h
+++ b/include/dm/device-internal.h
@@ -437,4 +437,7 @@ static inline int device_notify(const struct udevice *dev, enum event_t type)
 	return 0;
 #endif
 }
+
+void dev_int_set_seq(struct udevice *dev, int seq);
+
 #endif
-- 
2.43.0



More information about the U-Boot mailing list