[PATCH i-g-t 5/6] tools/intel_reg: Add wrapper for reg access init
Lucas De Marchi
lucas.demarchi at intel.com
Wed Sep 18 16:36:28 UTC 2024
Extract helper function so it can be extended to xe.
Signed-off-by: Lucas De Marchi <lucas.demarchi at intel.com>
---
tools/intel_reg.c | 17 ++++++++++++-----
1 file changed, 12 insertions(+), 5 deletions(-)
diff --git a/tools/intel_reg.c b/tools/intel_reg.c
index c5800cf05..906ae9b84 100644
--- a/tools/intel_reg.c
+++ b/tools/intel_reg.c
@@ -800,6 +800,11 @@ static int parse_reg(struct config *config, struct reg *reg, const char *s)
return ret;
}
+static int register_access_init(struct config *config)
+{
+ return intel_register_access_init(&config->mmio_data, config->pci_dev, 0, -1);
+}
+
/* XXX: add support for register ranges, maybe REGISTER..REGISTER */
static int intel_reg_read(struct config *config, int argc, char *argv[])
{
@@ -812,8 +817,8 @@ static int intel_reg_read(struct config *config, int argc, char *argv[])
if (config->mmiofile)
intel_mmio_use_dump_file(&config->mmio_data, config->mmiofile);
- else
- intel_register_access_init(&config->mmio_data, config->pci_dev, 0, -1);
+ else if (register_access_init(config) < 0)
+ return EXIT_FAILURE;
for (i = 1; i < argc; i++) {
struct reg reg;
@@ -843,7 +848,9 @@ static int intel_reg_write(struct config *config, int argc, char *argv[])
return EXIT_FAILURE;
}
- intel_register_access_init(&config->mmio_data, config->pci_dev, 0, -1);
+
+ if (register_access_init(config) < 0)
+ return EXIT_FAILURE;
for (i = 1; i < argc; i += 2) {
struct reg reg;
@@ -880,8 +887,8 @@ static int intel_reg_dump(struct config *config, int argc, char *argv[])
if (config->mmiofile)
intel_mmio_use_dump_file(&config->mmio_data, config->mmiofile);
- else
- intel_register_access_init(&config->mmio_data, config->pci_dev, 0, -1);
+ else if (register_access_init(config) < 0)
+ return EXIT_FAILURE;
for (i = 0; i < config->regcount; i++) {
reg = &config->regs[i];
--
2.46.1
More information about the igt-dev
mailing list