[RFC PATCH 14/15] sysreset: Use device_get_uclass_ops() for adjunct support

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


Update sysreset_get_ops() to use device_get_uclass_ops() instead of
directly accessing dev->driver->ops. This resolves the correct ops
pointer for both primary sysreset drivers and adjunct registrations.

When DM_UC_ADJUNCT is disabled, device_get_uclass_ops() maps to
device_get_ops() so there is no code-size cost.

Other uclass headers with a similar xxx_get_ops() macro can adopt the
same pattern to support adjuncts.

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

 include/sysreset.h | 9 ++++++++-
 1 file changed, 8 insertions(+), 1 deletion(-)

diff --git a/include/sysreset.h b/include/sysreset.h
index ff20abdeed3..108a7af7ca5 100644
--- a/include/sysreset.h
+++ b/include/sysreset.h
@@ -7,6 +7,8 @@
 #ifndef __SYSRESET_H
 #define __SYSRESET_H
 
+#include <linux/kconfig.h>
+
 struct udevice;
 
 /**
@@ -62,7 +64,12 @@ struct sysreset_ops {
 	int (*get_last)(struct udevice *dev);
 };
 
-#define sysreset_get_ops(dev)        ((struct sysreset_ops *)(dev)->driver->ops)
+#if CONFIG_IS_ENABLED(DM_UC_ADJUNCT)
+#define sysreset_get_ops(dev) \
+	((struct sysreset_ops *)device_get_uclass_ops(dev, UCLASS_SYSRESET))
+#else
+#define sysreset_get_ops(dev)	((struct sysreset_ops *)(dev)->driver->ops)
+#endif
 
 /**
  * sysreset_request() - request a sysreset
-- 
2.43.0



More information about the U-Boot mailing list