[igt-dev] [PATCH 2/3] lib/drmtest: Add drm_find_chipset()

Rob Clark robdclark at gmail.com
Wed Sep 27 17:41:24 UTC 2023


On Wed, Sep 27, 2023 at 7:21 AM Zbigniew Kempczyński
<zbigniew.kempczynski at intel.com> wrote:
>
> On Tue, Sep 26, 2023 at 11:47:46AM -0700, Rob Clark wrote:
> > From: Rob Clark <robdclark at chromium.org>
> >
> > Add helper to map driver name to chipset.
> >
> > Signed-off-by: Rob Clark <robdclark at chromium.org>
> > ---
> >  lib/drmtest.c | 14 ++++++++++++++
> >  lib/drmtest.h |  1 +
> >  2 files changed, 15 insertions(+)
> >
> > diff --git a/lib/drmtest.c b/lib/drmtest.c
> > index 2cfa8a899d53..4d826df744ae 100644
> > --- a/lib/drmtest.c
> > +++ b/lib/drmtest.c
> > @@ -608,6 +608,20 @@ static const char *chipset_to_str(int chipset)
> >       return (chipset == DRIVER_ANY) ? "any" : "other";
> >  }
> >
> > +/**
> > + * drm_find_chipset:
> > + * @name: The driver name
> > + *
> > + * Map the driver name to DRIVER_xyz value.
> > + */
> > +int drm_find_chipset(const char *name)
> > +{
> > +     for (const struct module *m = modules; m->module; m++)
> > +             if (!strcmp(name, m->module))
> > +                     return m->bit;
>
> I would add likely igt_warn() or at least igt_debug() to emphasize
> there's likely invalid driver name passed to this function.

done, thx

> Apart of this patch seems to correct:
>
> Reviewed-by: Zbigniew Kempczyński <zbigniew.kempczynski at intel.com>
> --
> Zbigniew
>
> > +     return 0;
> > +}
> > +
> >  /**
> >   * drm_open_driver:
> >   * @chipset: OR'd flags for each chipset to search, eg. #DRIVER_INTEL
> > diff --git a/lib/drmtest.h b/lib/drmtest.h
> > index 97ab6e759edf..9a71e1041ce8 100644
> > --- a/lib/drmtest.h
> > +++ b/lib/drmtest.h
> > @@ -99,6 +99,7 @@ void __set_forced_driver(const char *name);
> >  #define ALIGN_DOWN(x, a)     ALIGN((x) - ((a) - 1), (a))
> >
> >  void drm_load_module(unsigned int chipset);
> > +int drm_find_chipset(const char *name);
> >  int drm_open_driver(int chipset);
> >  int drm_open_driver_master(int chipset);
> >  int drm_open_driver_render(int chipset);
> > --
> > 2.41.0
> >


More information about the igt-dev mailing list