[PATCH v3 1/9] drm: Make drm_num_cea_modes unsigned

Ville Syrjälä ville.syrjala at linux.intel.com
Mon Jan 14 07:47:13 PST 2013


On Mon, Jan 14, 2013 at 04:06:13PM +0100, Thierry Reding wrote:
> On Mon, Jan 14, 2013 at 04:42:39PM +0200, Ville Syrjälä wrote:
> > On Mon, Jan 14, 2013 at 03:30:20PM +0100, Thierry Reding wrote:
> > > Since the variable's value is the size of an array, we can assume that
> > > it will never be negative.
> > > 
> > > Signed-off-by: Thierry Reding <thierry.reding at avionic-design.de>
> > > ---
> > >  drivers/gpu/drm/drm_edid_modes.h | 2 +-
> > >  1 file changed, 1 insertion(+), 1 deletion(-)
> > > 
> > > diff --git a/drivers/gpu/drm/drm_edid_modes.h b/drivers/gpu/drm/drm_edid_modes.h
> > > index 5dbf7d2..d65d863 100644
> > > --- a/drivers/gpu/drm/drm_edid_modes.h
> > > +++ b/drivers/gpu/drm/drm_edid_modes.h
> > > @@ -771,4 +771,4 @@ static const struct drm_display_mode edid_cea_modes[] = {
> > >  		   2492, 2640, 0, 1080, 1084, 1094, 1125, 0,
> > >  		   DRM_MODE_FLAG_PHSYNC | DRM_MODE_FLAG_PVSYNC) },
> > >  };
> > > -static const int drm_num_cea_modes = ARRAY_SIZE(edid_cea_modes);
> > > +static const unsigned int drm_num_cea_modes = ARRAY_SIZE(edid_cea_modes);
> > 
> > Why do we even have these num_foo things? I think it would be clearer to
> > use ARRAY_SIZE(foo) directly where appropriate.
> 
> Actually I was thinking about maybe writing a patch to move the table
> out of the header and into drm_edid.c (or drm_cea.c?) to make it less
> easy to create duplicates of the table. In that case, using the
> ARRAY_SIZE macro directly wouldn't be an option.

Well drm_edid.c is the only one accessing these tables anyway, so it
they would be in drm_edid.c and static, you could still use
ARRAY_SIZE().

Not that I really like the idea of polluting drm_edid.c with all these
massive tables.

Too bad cpp doesn't support this kind of thing:
#if __BASE_FILE__ != "drm_edid.c"
#error ...
#endif

-- 
Ville Syrjälä
Intel OTC


More information about the dri-devel mailing list