diff mbox series

[12/18] htm: Cleanup reset

Message ID 20180619052535.24043-12-mikey@neuling.org
State Accepted
Headers show
Series [01/18] Make -a the default for probe | expand

Commit Message

Michael Neuling June 19, 2018, 5:25 a.m. UTC
Simplify the code.

Signed-off-by: Michael Neuling <mikey@neuling.org>
---
 libpdbg/htm.c | 25 ++++++++++---------------
 1 file changed, 10 insertions(+), 15 deletions(-)
diff mbox series

Patch

diff --git a/libpdbg/htm.c b/libpdbg/htm.c
index dedf0e1938..790ca4feef 100644
--- a/libpdbg/htm.c
+++ b/libpdbg/htm.c
@@ -430,6 +430,9 @@  static int configure_chtm(struct htm *htm)
 {
 	uint64_t hid0, ncu;
 
+	if (!pdbg_target_is_class(&htm->target, "chtm"))
+		return 0;
+
 	if (HTM_ERR(configure_debugfs_memtrace(htm)))
 		return -1;
 
@@ -484,6 +487,9 @@  static int configure_nhtm(struct htm *htm)
 {
 	uint64_t val;
 
+	if (!pdbg_target_is_class(&htm->target, "nhtm"))
+		return 0;
+
 	if (HTM_ERR(configure_debugfs_memtrace(htm)))
 		return -1;
 
@@ -702,21 +708,10 @@  static int do_htm_reset(struct htm *htm)
 		return -1;
 
 	if (!is_resetable(&status) || !is_configured(htm)) {
-		if (pdbg_target_is_class(&htm->target, "nhtm")) {
-			if (HTM_ERR(configure_nhtm(htm))) {
-				PR_ERROR("Couldn't setup Nest HTM during reset\n");
-				return -1;
-			}
-		} else if (pdbg_target_is_class(&htm->target, "chtm")) {
-			if (HTM_ERR(configure_chtm(htm))) {
-				PR_ERROR("Couldn't setup Core HTM during reset\n");
-				return -1;
-			}
-		} else { /* Well... */
-			PR_ERROR("Unknown HTM class! %s\n",
-				pdbg_target_class_name(&htm->target));
-		}
-
+		if (configure_nhtm(htm) < 0)
+			return -1;
+		if (configure_chtm(htm) < 0)
+			return -1;
 	}
 
 	if (HTM_ERR(configure_memory(htm)))