[Intel-gfx] [PATCH 13/14] drm/i915: Use binary search when looking for shadowed registers
Joonas Lahtinen
joonas.lahtinen at linux.intel.com
Mon Oct 3 08:05:35 UTC 2016
On pe, 2016-09-30 at 19:08 +0100, Chris Wilson wrote:
> On Fri, Sep 30, 2016 at 06:48:48PM +0100, Tvrtko Ursulin wrote:
> > +static int mmio_reg_cmp(const void *key, const void *elt)
> > +{
> > + u32 offset = (u32)(unsigned long)key;
> > + i915_reg_t *reg = (i915_reg_t *)elt;
> > +
> > + if (offset < i915_mmio_reg_offset(*reg))
> > + return -1;
> > + else if (offset > i915_mmio_reg_offset(*reg))
> > + return 1;
> > + else
> > + return 0;
>
> There's no issue with using
>
> return offset - i915_mmio_reg_offset(*reg)
>
> here.
>
Why not?
> > + reg = bsearch((void *)(unsigned long)offset,
> > + (const void *)gen8_shadowed_regs,
> > + ARRAY_SIZE(gen8_shadowed_regs),
> > + sizeof(i915_reg_t),
> > + mmio_reg_cmp);
> > +
> > + return reg;
>
> Or just return bseearch() ? (Probably like this for easing future
> patches.)
Suggested that too, but obviously he has something in mind.
Regards, Joonas
--
Joonas Lahtinen
Open Source Technology Center
Intel Corporation
More information about the Intel-gfx
mailing list