[Intel-gfx] [PATCH] drm/i915: Make for_each_intel_* macros typesafe
Chris Wilson
chris at chris-wilson.co.uk
Mon Mar 16 03:42:18 PDT 2015
On Mon, Mar 16, 2015 at 12:00:35PM +0200, Jani Nikula wrote:
> On Mon, 16 Mar 2015, Ander Conselvan de Oliveira <ander.conselvan.de.oliveira at intel.com> wrote:
> > So that the compiler warns if we get something wrong.
> >
> > Signed-off-by: Ander Conselvan de Oliveira <ander.conselvan.de.oliveira at intel.com>
> > ---
> > drivers/gpu/drm/i915/i915_drv.h | 39 ++++++++++++++++++++++++++-------------
> > 1 file changed, 26 insertions(+), 13 deletions(-)
> >
> > diff --git a/drivers/gpu/drm/i915/i915_drv.h b/drivers/gpu/drm/i915/i915_drv.h
> > index ae4ba6a..871d77a 100644
> > --- a/drivers/gpu/drm/i915/i915_drv.h
> > +++ b/drivers/gpu/drm/i915/i915_drv.h
> > @@ -232,30 +232,43 @@ enum hpd_pin {
> > (__s) < INTEL_INFO(__dev_priv)->num_sprites[(__p)]; \
> > (__s)++)
> >
> > -#define for_each_crtc(dev, crtc) \
> > +#define type_check(variable, type) \
> > + { \
> > + typeof(variable) __dummy_ptr = NULL; \
> > + const type *__type_check = __dummy_ptr; \
> > + (void) __type_check; \
> > + }
> > +
> > +#define for_each_crtc(dev, crtc) \
> > + type_check(crtc, struct drm_crtc) \
> > list_for_each_entry(crtc, &dev->mode_config.crtc_list, head)
#define __list_for_each_entry_type(pos, head, type, member) \
for (pos = list_first_entry(head, type, member); \
&pos->member != (head); \
pos = list_next_entry(pos, member))
#define for_each_crtc(dev, crtc) \
__list_for_each_entry_type(crtc, \
&dev->mode_config.crtc_list, \
struct drm_crtc, \
head)
-Chris
--
Chris Wilson, Intel Open Source Technology Centre
More information about the Intel-gfx
mailing list