[igt-dev] [PATCH 1/3] lib/drmtest: Use module table for chipset_to_str()

Rob Clark robdclark at gmail.com
Wed Sep 27 17:32:54 UTC 2023


On Wed, Sep 27, 2023 at 9:13 AM Kamil Konieczny
<kamil.konieczny at linux.intel.com> wrote:
>
> Hi Rob,
> On 2023-09-26 at 11:47:45 -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";
> --------------- ^^^^^
> This will change into "i915" and break compatibility with older
> tests, so imho leave this function as is and add new one:

The only caller seems to be drm_open_driver() for an error msg, so I
think this will be fine

BR,
-R

> static const char *chipset_to_module_str(int chipset)
>
> Regards,
> Kamil
>
> > -     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++)
> > -             return "intel";
> > +             if (m->bit == chipset)
> > +                     return m->module;
> > +
> > +     return (chipset == DRIVER_ANY) ? "any" : "other";
> >  }
> >
> >  /**
> > --
> > 2.41.0
> >


More information about the igt-dev mailing list