From patchwork Wed Jan 21 13:50:54 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Lespiau, Damien" X-Patchwork-Id: 5677391 Return-Path: X-Original-To: patchwork-intel-gfx@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork2.web.kernel.org (Postfix) with ESMTP id D6331C058D for ; Wed, 21 Jan 2015 13:51:28 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 4487B202F8 for ; Wed, 21 Jan 2015 13:51:24 +0000 (UTC) Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) by mail.kernel.org (Postfix) with ESMTP id 4B8F5202B8 for ; Wed, 21 Jan 2015 13:51:23 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id DA17F6E755; Wed, 21 Jan 2015 05:51:22 -0800 (PST) X-Original-To: intel-gfx@lists.freedesktop.org Delivered-To: intel-gfx@lists.freedesktop.org Received: from mga03.intel.com (mga03.intel.com [134.134.136.65]) by gabe.freedesktop.org (Postfix) with ESMTP id 736196E755 for ; Wed, 21 Jan 2015 05:51:21 -0800 (PST) Received: from orsmga001.jf.intel.com ([10.7.209.18]) by orsmga103.jf.intel.com with ESMTP; 21 Jan 2015 05:46:57 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.09,442,1418112000"; d="scan'208";a="640406621" Received: from badanowx-mobl1.ger.corp.intel.com (HELO strange.ger.corp.intel.com) ([10.252.5.103]) by orsmga001.jf.intel.com with ESMTP; 21 Jan 2015 05:50:56 -0800 From: Damien Lespiau To: intel-gfx@lists.freedesktop.org Date: Wed, 21 Jan 2015 13:50:54 +0000 Message-Id: <1421848254-586-1-git-send-email-damien.lespiau@intel.com> X-Mailer: git-send-email 1.8.3.1 Cc: kbuild@01.org, Dan Carpenter Subject: [Intel-gfx] [PATCH] drm/i915: Fix kzalloc() smatch warnings in get_initial_plane_config() X-BeenThere: intel-gfx@lists.freedesktop.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: Intel graphics driver community testing & development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: intel-gfx-bounces@lists.freedesktop.org Sender: "Intel-gfx" X-Spam-Status: No, score=-4.2 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_MED, T_RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Smatch doesn't like: struct drm_framebuffer *fb; fb = kzalloc(sizeof(struct intel_framebuffer), GFP_KERNEL); and warns with: warn: struct type mismatch 'drm_framebuffer vs intel_framebuffer' This implicit cast was correct as struct intel_framebuffer has struct drm_framebuffer as its first member, but in case someone want to reorder the fields for some reason, it's slightly safer to access the underlying drm_framebuffer through intel_fb->base. Also, having fewer static analysis warnings is a worthy goal. Cc: kbuild@01.org Cc: Dan Carpenter Signed-off-by: Damien Lespiau --- drivers/gpu/drm/i915/intel_display.c | 21 +++++++++++++++------ 1 file changed, 15 insertions(+), 6 deletions(-) diff --git a/drivers/gpu/drm/i915/intel_display.c b/drivers/gpu/drm/i915/intel_display.c index 65fce56..01dc80b 100644 --- a/drivers/gpu/drm/i915/intel_display.c +++ b/drivers/gpu/drm/i915/intel_display.c @@ -6584,13 +6584,16 @@ i9xx_get_initial_plane_config(struct intel_crtc *crtc, int fourcc, pixel_format; int aligned_height; struct drm_framebuffer *fb; + struct intel_framebuffer *intel_fb; - fb = kzalloc(sizeof(struct intel_framebuffer), GFP_KERNEL); - if (!fb) { + intel_fb = kzalloc(sizeof(struct intel_framebuffer), GFP_KERNEL); + if (!intel_fb) { DRM_DEBUG_KMS("failed to alloc fb\n"); return; } + fb = &intel_fb->base; + val = I915_READ(DSPCNTR(plane)); if (INTEL_INFO(dev)->gen >= 4) @@ -7613,13 +7616,16 @@ skylake_get_initial_plane_config(struct intel_crtc *crtc, int fourcc, pixel_format; int aligned_height; struct drm_framebuffer *fb; + struct intel_framebuffer *intel_fb; - fb = kzalloc(sizeof(struct intel_framebuffer), GFP_KERNEL); - if (!fb) { + intel_fb = kzalloc(sizeof(struct intel_framebuffer), GFP_KERNEL); + if (!intel_fb) { DRM_DEBUG_KMS("failed to alloc fb\n"); return; } + fb = &intel_fb->base; + val = I915_READ(PLANE_CTL(pipe, 0)); if (val & PLANE_CTL_TILED_MASK) plane_config->tiling = I915_TILING_X; @@ -7706,13 +7712,16 @@ ironlake_get_initial_plane_config(struct intel_crtc *crtc, int fourcc, pixel_format; int aligned_height; struct drm_framebuffer *fb; + struct intel_framebuffer *intel_fb; - fb = kzalloc(sizeof(struct intel_framebuffer), GFP_KERNEL); - if (!fb) { + intel_fb = kzalloc(sizeof(struct intel_framebuffer), GFP_KERNEL); + if (!intel_fb) { DRM_DEBUG_KMS("failed to alloc fb\n"); return; } + fb = &intel_fb->base; + val = I915_READ(DSPCNTR(pipe)); if (INTEL_INFO(dev)->gen >= 4)