[PATCH i-g-t v1] lib/drmtest: Refactor chipset to string
Kamil Konieczny
kamil.konieczny at linux.intel.com
Fri Aug 29 15:34:53 UTC 2025
Currently chipset names are in modules array and almost all of
them are duplicated in function chipset_to_str(). Refactor this
function and remove duplication.
Cc: Karthik B S <karthik.b.s at intel.com>
Cc: "Zbigniew Kempczyński" <zbigniew.kempczynski at intel.com>
Signed-off-by: Kamil Konieczny <kamil.konieczny at linux.intel.com>
---
lib/drmtest.c | 30 +++++++-----------------------
1 file changed, 7 insertions(+), 23 deletions(-)
diff --git a/lib/drmtest.c b/lib/drmtest.c
index 436b6de78..1b871fd1b 100644
--- a/lib/drmtest.c
+++ b/lib/drmtest.c
@@ -276,30 +276,14 @@ unsigned int drm_get_chipset(int fd)
static const char *chipset_to_str(int chipset)
{
- switch (chipset) {
- case DRIVER_INTEL:
+ if (chipset == DRIVER_INTEL)
return "intel";
- case DRIVER_V3D:
- return "v3d";
- case DRIVER_VC4:
- return "vc4";
- case DRIVER_VGEM:
- return "vgem";
- case DRIVER_AMDGPU:
- return "amdgpu";
- case DRIVER_PANFROST:
- return "panfrost";
- case DRIVER_MSM:
- return "msm";
- case DRIVER_XE:
- return "xe";
- case DRIVER_VMWGFX:
- return "vmwgfx";
- case DRIVER_ANY:
- return "any";
- default:
- return "other";
- }
+
+ for (int i = 0, end = ARRAY_SIZE(modules); i < end; i++)
+ if (modules[i].bit == chipset)
+ return modules[i].module;
+
+ return chipset == DRIVER_ANY ? "any" : "other";
}
--
2.51.0
More information about the igt-dev
mailing list