From mboxrd@z Thu Jan 1 00:00:00 1970 From: Jesse Barnes Subject: Re: [PATCH 06/24] drm/i915: properly check for pipe count Date: Mon, 30 Apr 2012 16:57:51 -0700 Message-ID: <20120430165751.74aa3f41@jbarnes-desktop> References: <1335464479-648-1-git-send-email-eugeni.dodonov@intel.com> <1335464479-648-7-git-send-email-eugeni.dodonov@intel.com> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Return-path: Received: from oproxy7-pub.bluehost.com (oproxy7-pub.bluehost.com [67.222.55.9]) by gabe.freedesktop.org (Postfix) with SMTP id 2F8439E82D for ; Mon, 30 Apr 2012 16:57:54 -0700 (PDT) In-Reply-To: <1335464479-648-7-git-send-email-eugeni.dodonov@intel.com> List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: intel-gfx-bounces+gcfxdi-intel-gfx=m.gmane.org@lists.freedesktop.org Errors-To: intel-gfx-bounces+gcfxdi-intel-gfx=m.gmane.org@lists.freedesktop.org To: Eugeni Dodonov Cc: Daniel Vetter , intel-gfx@lists.freedesktop.org List-Id: intel-gfx@lists.freedesktop.org On Thu, 26 Apr 2012 15:21:01 -0300 Eugeni Dodonov wrote: > As suggested by Chris Wilson and Daniel Vetter, this chunk of code can be > simplified with a more simple check. > > CC: Daniel Vetter > CC: Chris Wilson > Signed-off-by: Eugeni Dodonov > --- > drivers/gpu/drm/i915/intel_display.c | 14 ++++---------- > 1 file changed, 4 insertions(+), 10 deletions(-) > > diff --git a/drivers/gpu/drm/i915/intel_display.c b/drivers/gpu/drm/i915/intel_display.c > index 8262ec6..27f384d 100644 > --- a/drivers/gpu/drm/i915/intel_display.c > +++ b/drivers/gpu/drm/i915/intel_display.c > @@ -1981,16 +1981,10 @@ intel_pipe_set_base(struct drm_crtc *crtc, int x, int y, > return 0; > } > > - switch (intel_crtc->plane) { > - case 0: > - case 1: > - break; > - case 2: > - if (IS_IVYBRIDGE(dev)) > - break; > - /* fall through otherwise */ > - default: > - DRM_ERROR("no plane for crtc\n"); > + if(intel_crtc->plane > dev_priv->num_pipe) { > + DRM_ERROR("no plane for crtc: plane %d, num_pipes %d\n", > + intel_crtc->plane, > + dev_priv->num_pipe); > return -EINVAL; > } > plane is an enum and num_pipe is an int, so we could be more paranoid here about signs and < 0. But meh. These are purely driver internal, so we don't have to validate them too hard. Reviewed-by: Jesse Barnes -- Jesse Barnes, Intel Open Source Technology Center