[Intel-gfx] [PATCH i-g-t 10/10] rename global mmio variable to igt_global_mmio

Jani Nikula jani.nikula at intel.com
Tue Apr 28 05:04:35 PDT 2015


Global variable names should reflect the fact that they are indeed
global, and at the very least they should not be as short as just
"mmio". Rename mmio to igt_global_mmio.

Signed-off-by: Jani Nikula <jani.nikula at intel.com>
---
 lib/intel_io.h             |  2 +-
 lib/intel_mmio.c           | 44 +++++++++++++++++++++-----------------------
 tools/intel_reg.c          |  2 +-
 tools/intel_reg_snapshot.c |  2 +-
 4 files changed, 24 insertions(+), 26 deletions(-)

diff --git a/lib/intel_io.h b/lib/intel_io.h
index 1c3b4445cd5b..e2d6b4705be3 100644
--- a/lib/intel_io.h
+++ b/lib/intel_io.h
@@ -32,7 +32,7 @@
 #include <pciaccess.h>
 
 /* register access helpers from intel_mmio.c */
-extern void *mmio;
+extern void *igt_global_mmio;
 void intel_mmio_use_pci_bar(struct pci_device *pci_dev);
 void intel_mmio_use_dump_file(char *file);
 
diff --git a/lib/intel_mmio.c b/lib/intel_mmio.c
index 40ce94c8f600..3a7631417df7 100644
--- a/lib/intel_mmio.c
+++ b/lib/intel_mmio.c
@@ -69,7 +69,7 @@
  *
  * Pointer to the register range. It is not recommended to use this directly.
  */
-void *mmio;
+void *igt_global_mmio;
 
 static struct _mmio_data {
 	int inited;
@@ -83,9 +83,9 @@ static struct _mmio_data {
  * intel_mmio_use_dump_file:
  * @file: name of the register dump file to open
  *
- * Sets up #mmio to point at the data contained in @file. This allows the same
- * code to get reused for dumping and decoding from running hardware as from
- * register dumps.
+ * Sets up #igt_global_mmio to point at the data contained in @file. This allows
+ * the same code to get reused for dumping and decoding from running hardware as
+ * from register dumps.
  */
 void
 intel_mmio_use_dump_file(char *file)
@@ -98,8 +98,8 @@ intel_mmio_use_dump_file(char *file)
 		      "Couldn't open %s\n", file);
 
 	fstat(fd, &st);
-	mmio = mmap(NULL, st.st_size, PROT_READ|PROT_WRITE, MAP_PRIVATE, fd, 0);
-	igt_fail_on_f(mmio == MAP_FAILED,
+	igt_global_mmio = mmap(NULL, st.st_size, PROT_READ|PROT_WRITE, MAP_PRIVATE, fd, 0);
+	igt_fail_on_f(igt_global_mmio == MAP_FAILED,
 		      "Couldn't mmap %s\n", file);
 	close(fd);
 }
@@ -108,9 +108,7 @@ intel_mmio_use_dump_file(char *file)
  * intel_mmio_use_pci_bar:
  * @pci_dev: intel gracphis pci device
  *
- * Sets up #mmio to point at the data contained in @file. This allows the same
- * code to get reused for dumping and decoding from running hardware as from
- * register dumps.
+ * Sets up #igt_global_mmio to point at the mmio bar.
  *
  * @pci_dev can be obtained from intel_get_pci_device().
  */
@@ -139,7 +137,7 @@ intel_mmio_use_pci_bar(struct pci_device *pci_dev)
 				      pci_dev->regions[mmio_bar].base_addr,
 				      mmio_size,
 				      PCI_DEV_MAP_FLAG_WRITABLE,
-				      &mmio);
+				      &igt_global_mmio);
 
 	igt_fail_on_f(error != 0,
 		      "Couldn't map MMIO region\n");
@@ -160,7 +158,7 @@ release_forcewake_lock(int fd)
  * handling and also allows register access to be checked with an explicit
  * whitelist.
  *
- * It also initializes #mmio like intel_mmio_use_pci_bar().
+ * It also initializes #igt_global_mmio like intel_mmio_use_pci_bar().
  *
  * @pci_dev can be obtained from intel_get_pci_device().
  */
@@ -170,10 +168,10 @@ intel_register_access_init(struct pci_device *pci_dev, int safe)
 	int ret;
 
 	/* after old API is deprecated, remove this */
-	if (mmio == NULL)
+	if (igt_global_mmio == NULL)
 		intel_mmio_use_pci_bar(pci_dev);
 
-	igt_assert(mmio != NULL);
+	igt_assert(igt_global_mmio != NULL);
 
 	if (mmio_data.inited)
 		return -1;
@@ -266,7 +264,7 @@ intel_register_read(uint32_t reg)
 	}
 
 read_out:
-	ret = *(volatile uint32_t *)((volatile char *)mmio + reg);
+	ret = *(volatile uint32_t *)((volatile char *)igt_global_mmio + reg);
 out:
 	return ret;
 }
@@ -303,7 +301,7 @@ intel_register_write(uint32_t reg, uint32_t val)
 		      "Register write blocked for safety ""(*0x%08x = 0x%x)\n", reg, val);
 
 write_out:
-	*(volatile uint32_t *)((volatile char *)mmio + reg) = val;
+	*(volatile uint32_t *)((volatile char *)igt_global_mmio + reg) = val;
 }
 
 
@@ -314,26 +312,26 @@ write_out:
  * 32-bit read of the register at @offset. This function only works when the new
  * register access helper is initialized with intel_register_access_init().
  *
- * This function directly accesses the #mmio without safety checks.
+ * This function directly accesses the #igt_global_mmio without safety checks.
  *
  * Returns:
  * The value read from the register.
  */
 uint32_t INREG(uint32_t reg)
 {
-	return *(volatile uint32_t *)((volatile char *)mmio + reg);
+	return *(volatile uint32_t *)((volatile char *)igt_global_mmio + reg);
 }
 
 /* 16-bit version of INREG */
 uint16_t INREG16(uint32_t reg)
 {
-	return *(volatile uint16_t *)((volatile char *)mmio + reg);
+	return *(volatile uint16_t *)((volatile char *)igt_global_mmio + reg);
 }
 
 /* 8-bit version of INREG */
 uint8_t INREG8(uint32_t reg)
 {
-	return *((volatile uint8_t *)mmio + reg);
+	return *((volatile uint8_t *)igt_global_mmio + reg);
 }
 
 /**
@@ -344,21 +342,21 @@ uint8_t INREG8(uint32_t reg)
  * 32-bit write to the register at @offset. This function only works when the new
  * register access helper is initialized with intel_register_access_init().
  *
- * This function directly accesses the #mmio without safety checks.
+ * This function directly accesses the #igt_global_mmio without safety checks.
  */
 void OUTREG(uint32_t reg, uint32_t val)
 {
-	*(volatile uint32_t *)((volatile char *)mmio + reg) = val;
+	*(volatile uint32_t *)((volatile char *)igt_global_mmio + reg) = val;
 }
 
 /* 16-bit version of OUTREG */
 void OUTREG16(uint32_t reg, uint16_t val)
 {
-	*(volatile uint16_t *)((volatile char *)mmio + reg) = val;
+	*(volatile uint16_t *)((volatile char *)igt_global_mmio + reg) = val;
 }
 
 /* 8-bit version of OUTREG */
 void OUTREG8(uint32_t reg, uint8_t val)
 {
-	*((volatile uint8_t *)mmio + reg) = val;
+	*((volatile uint8_t *)igt_global_mmio + reg) = val;
 }
diff --git a/tools/intel_reg.c b/tools/intel_reg.c
index 0f98266932e5..090cc25613b9 100644
--- a/tools/intel_reg.c
+++ b/tools/intel_reg.c
@@ -491,7 +491,7 @@ static int intel_reg_snapshot(struct config *config, int argc, char *argv[])
 	intel_mmio_use_pci_bar(config->pci_dev);
 
 	/* XXX: error handling */
-	write(1, mmio, config->pci_dev->regions[mmio_bar].size);
+	write(1, igt_global_mmio, config->pci_dev->regions[mmio_bar].size);
 
 	if (config->verbosity > 0)
 		printf("use this with --mmio=FILE --devid=0x%04X\n",
diff --git a/tools/intel_reg_snapshot.c b/tools/intel_reg_snapshot.c
index b756bf690217..50dafd6a6ac4 100644
--- a/tools/intel_reg_snapshot.c
+++ b/tools/intel_reg_snapshot.c
@@ -45,7 +45,7 @@ int main(int argc, char** argv)
 	else
 		mmio_bar = 0;
 
-	ret = write(1, mmio, pci_dev->regions[mmio_bar].size);
+	ret = write(1, igt_global_mmio, pci_dev->regions[mmio_bar].size);
 	assert(ret > 0);
 
 	return 0;
-- 
2.1.4



More information about the Intel-gfx mailing list