All of lore.kernel.org
 help / color / mirror / Atom feed
From: Damien Lespiau <damien.lespiau@gmail.com>
To: intel-gfx@lists.freedesktop.org
Subject: [PATCH 3/4] intel_reg_dumper: Allow partial register names on the command line
Date: Mon,  3 Sep 2012 16:16:28 +0100	[thread overview]
Message-ID: <1346685389-26198-3-git-send-email-damien.lespiau@gmail.com> (raw)
In-Reply-To: <1346685389-26198-1-git-send-email-damien.lespiau@gmail.com>

From: Damien Lespiau <damien.lespiau@intel.com>

Let people give just a part of the register name. Handy when not
remembering the exact name or if the register is defined with a
different name than the one in the spec being looked at.

Signed-off-by: Damien Lespiau <damien.lespiau@intel.com>
---
 tools/intel_reg_dumper.c |   41 ++++++++++++++++-------------------------
 1 files changed, 16 insertions(+), 25 deletions(-)

diff --git a/tools/intel_reg_dumper.c b/tools/intel_reg_dumper.c
index 5bc47b6..0b40f58 100644
--- a/tools/intel_reg_dumper.c
+++ b/tools/intel_reg_dumper.c
@@ -26,6 +26,7 @@
  */
 
 #define _GNU_SOURCE
+#include <ctype.h>
 #include <stdlib.h>
 #include <stdio.h>
 #include <string.h>
@@ -1982,39 +1983,29 @@ static struct {
 };
 #undef DECLARE_REGS
 
-static struct reg_debug *
-find_register_by_name(struct reg_debug *regs, int count,
-		      const char *name)
+static void
+str_to_upper(char *str)
 {
-	int i;
-
-	for (i = 0; i < count; i++)
-		if (strcasecmp(name, regs[i].name) == 0)
-			return &regs[i];
-
-	return NULL;
+	while(*str) {
+		*str = toupper(*str);
+		str++;
+	}
 }
 
 static void
-decode_register_name(const char *name, uint32_t val)
+decode_register_name(char *name, uint32_t val)
 {
-	int i;
-	struct reg_debug *reg = NULL;
+	int i, j;
+
+	str_to_upper(name);
 
 	for (i = 0; i < ARRAY_SIZE(known_registers); i++) {
-		reg = find_register_by_name(known_registers[i].regs,
-					    known_registers[i].count,
-					    name);
-		if (reg)
-			break;
-	}
+		struct reg_debug *regs = known_registers[i].regs;
 
-	if (!reg) {
-		fprintf(stderr, "Unknown register: %s\n", name);
-		return;
+		for (j = 0; j < known_registers[i].count; j++)
+			if (strstr(regs[j].name, name))
+				_intel_dump_reg(&regs[j], val);
 	}
-
-	_intel_dump_reg(reg, val);
 }
 
 static void
@@ -2032,7 +2023,7 @@ decode_register_address(int address, uint32_t val)
 }
 
 static void
-decode_register(const char *name, uint32_t val)
+decode_register(char *name, uint32_t val)
 {
 	long int address;
 	char *end;
-- 
1.7.7.5

  parent reply	other threads:[~2012-09-03 15:16 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-09-03 15:16 [PATCH 1/4] intel_reg_dumper: Add a single register decode mode Damien Lespiau
2012-09-03 15:16 ` [PATCH 2/4] intel_reg_dumper: Also decode registers given by address Damien Lespiau
2012-09-03 15:16 ` Damien Lespiau [this message]
2012-09-03 15:16 ` [PATCH 4/4] intel_reg_dumper: Add more information when dumping single registers Damien Lespiau
2012-09-04  8:11 ` [PATCH 1/4] intel_reg_dumper: Add a single register decode mode Jani Nikula
2012-09-04 11:57   ` Daniel Vetter

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1346685389-26198-3-git-send-email-damien.lespiau@gmail.com \
    --to=damien.lespiau@gmail.com \
    --cc=intel-gfx@lists.freedesktop.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.