From mboxrd@z Thu Jan 1 00:00:00 1970 From: Ville =?iso-8859-1?Q?Syrj=E4l=E4?= Subject: Re: [PATCH v3 1/9] drm: Make drm_num_cea_modes unsigned Date: Fri, 18 Jan 2013 12:51:11 +0200 Message-ID: <20130118105111.GX3503@intel.com> References: <1358173828-31674-1-git-send-email-thierry.reding@avionic-design.de> <1358173828-31674-2-git-send-email-thierry.reding@avionic-design.de> <20130114144239.GF3867@intel.com> <20130114150613.GB24129@avionic-0098.adnet.avionic-design.de> <20130114154713.GB3489@intel.com> <20130118103004.GA14129@avionic-0098.adnet.avionic-design.de> Mime-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable Return-path: Received: from mga02.intel.com (mga02.intel.com [134.134.136.20]) by gabe.freedesktop.org (Postfix) with ESMTP id 9F6D4E682B for ; Fri, 18 Jan 2013 02:51:26 -0800 (PST) Content-Disposition: inline In-Reply-To: <20130118103004.GA14129@avionic-0098.adnet.avionic-design.de> List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: dri-devel-bounces+sf-dri-devel=m.gmane.org@lists.freedesktop.org Errors-To: dri-devel-bounces+sf-dri-devel=m.gmane.org@lists.freedesktop.org To: Thierry Reding Cc: Paulo Zanoni , dri-devel@lists.freedesktop.org List-Id: dri-devel@lists.freedesktop.org On Fri, Jan 18, 2013 at 11:30:04AM +0100, Thierry Reding wrote: > On Mon, Jan 14, 2013 at 05:47:13PM +0200, Ville Syrj=E4l=E4 wrote: > > 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=E4l=E4 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 > > > > > --- > > > > > 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/d= rm_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[] =3D { > > > > > 2492, 2640, 0, 1080, 1084, 1094, 1125, 0, > > > > > DRM_MODE_FLAG_PHSYNC | DRM_MODE_FLAG_PVSYNC) }, > > > > > }; > > > > > -static const int drm_num_cea_modes =3D ARRAY_SIZE(edid_cea_modes= ); > > > > > +static const unsigned int drm_num_cea_modes =3D ARRAY_SIZE(edid_= cea_modes); > > > > = > > > > Why do we even have these num_foo things? I think it would be clear= er 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. > = > There's also the possibility to put the tables along with the functions > that access them into a drm_edid_modes.c. > = > > Too bad cpp doesn't support this kind of thing: > > #if __BASE_FILE__ !=3D "drm_edid.c" > > #error ... > > #endif > = > We could fake that by protecting the tables using #ifdef NEED_CEA_MODES > and define NEED_CEA_MODES in drm_edid.c before the drm_edid_modes.h file > is included. Yeah, I suppose there's no better way to do that. It's a bit ugly though. -- = Ville Syrj=E4l=E4 Intel OTC