[igt-dev] [PATCH 1/3] lib/drmtest: Use module table for chipset_to_str()
Zbigniew Kempczyński
zbigniew.kempczynski at intel.com
Wed Sep 27 14:01:28 UTC 2023
On Tue, Sep 26, 2023 at 11:47:45AM -0700, Rob Clark wrote:
> From: Rob Clark <robdclark at chromium.org>
>
> Use the existing table, so there is one fewer place to update to add
> support for a new driver.
>
> Signed-off-by: Rob Clark <robdclark at chromium.org>
> ---
> lib/drmtest.c | 29 +++++------------------------
> 1 file changed, 5 insertions(+), 24 deletions(-)
>
> diff --git a/lib/drmtest.c b/lib/drmtest.c
> index e1da66c877e9..2cfa8a899d53 100644
> --- a/lib/drmtest.c
> +++ b/lib/drmtest.c
> @@ -601,30 +601,11 @@ static void cancel_work_at_exit_render(int sig)
>
> static const char *chipset_to_str(int chipset)
> {
> - switch (chipset) {
> - case 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 (const struct module *m = modules; m->module; m++)
> + if (m->bit == chipset)
> + return m->module;
> +
> + return (chipset == DRIVER_ANY) ? "any" : "other";
Nice, thanks for simplifying this.
Reviewed-by: Zbigniew Kempczyński <zbigniew.kempczynski at intel.com>
--
Zbigniew
> }
>
> /**
> --
> 2.41.0
>
More information about the igt-dev
mailing list