From patchwork Mon Aug 31 19:47:17 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Emil Velikov X-Patchwork-Id: 7101251 Return-Path: X-Original-To: patchwork-dri-devel@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 D9134BEEC1 for ; Mon, 31 Aug 2015 19:43:06 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 0497C20534 for ; Mon, 31 Aug 2015 19:43:06 +0000 (UTC) Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) by mail.kernel.org (Postfix) with ESMTP id 0F34A204E7 for ; Mon, 31 Aug 2015 19:43:05 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id F13EC6E0A5; Mon, 31 Aug 2015 12:43:03 -0700 (PDT) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from mail-wi0-f179.google.com (mail-wi0-f179.google.com [209.85.212.179]) by gabe.freedesktop.org (Postfix) with ESMTPS id ED6E96E0A5 for ; Mon, 31 Aug 2015 12:43:01 -0700 (PDT) Received: by wibz8 with SMTP id z8so10572302wib.1 for ; Mon, 31 Aug 2015 12:43:00 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=PwDzfXC/BPzl4Cb6rkabSc+0GKUc6bI7dCBtt748Pzw=; b=bsZFVhz/xMzFWj+8Z8ZsHcz30eff1sQ2y5tqCVvbpqfHIrrwkrC2JO6uDjg+ABWy/u wCuLG3wFGjqexlktuImlW6+bUDWj+PyoDVVEbRm24BHp9ZmTgii7CId0FoRHIIGOje98 8O5yUTyqXDbTP6A6SoAkBLwzA0IoxGZP2C7PZ2P2903oLeVwm6KenGnd2M0KfZwVdmy2 oObFrQifvceZGpyHisisU5aAXMIxw7ELqnJO+WJxiFjLe2Uzs4zP7PW5QoxyVjbZOxxn XfN1WQhiqrJ9KrM7EkMzrNqGV/ZjsgJi+jNyt2m3hRNaOtdp3CWThO0TvTM9XzqZqA/W UqpA== X-Received: by 10.194.121.131 with SMTP id lk3mr27921703wjb.77.1441050180227; Mon, 31 Aug 2015 12:43:00 -0700 (PDT) Received: from arch-x220.localdomain (cpc12-croy20-2-0-cust52.croy.cable.virginm.net. [82.44.54.53]) by smtp.gmail.com with ESMTPSA id c3sm23716419wja.3.2015.08.31.12.42.58 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Mon, 31 Aug 2015 12:42:59 -0700 (PDT) From: Emil Velikov To: dri-devel@lists.freedesktop.org Subject: [PATCH libdrm 4.1/17] intel: introduce to_bo_gem() helper Date: Mon, 31 Aug 2015 20:47:17 +0100 Message-Id: <1441050437-1626-1-git-send-email-emil.l.velikov@gmail.com> X-Mailer: git-send-email 2.5.0 In-Reply-To: <20150831190955.GY17184@nuc-i3427.alporthouse.com> References: <20150831190955.GY17184@nuc-i3427.alporthouse.com> Cc: emil.l.velikov@gmail.com X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" X-Spam-Status: No, score=-4.1 required=5.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, RCVD_IN_DNSWL_MED, T_DKIM_INVALID, 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 ...to minimise misuse of bo_gem. If the variable is declared at the top of the function and then used for two (or more) different contexts this can cause confusion and errors. Just introduce a wrapper, which can be used in a once off situations. Suggested-by: Chris Wilson Cc: Chris Wilson Signed-off-by: Emil Velikov --- intel/intel_bufmgr_gem.c | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/intel/intel_bufmgr_gem.c b/intel/intel_bufmgr_gem.c index 5287419..63122d0 100644 --- a/intel/intel_bufmgr_gem.c +++ b/intel/intel_bufmgr_gem.c @@ -276,6 +276,11 @@ static void drm_intel_gem_bo_unreference(drm_intel_bo *bo); static void drm_intel_gem_bo_free(drm_intel_bo *bo); +static inline drm_intel_bo_gem *to_bo_gem(drm_intel_bo *bo) +{ + return (drm_intel_bo_gem *)bo; +} + static unsigned long drm_intel_gem_bo_tile_size(drm_intel_bufmgr_gem *bufmgr_gem, unsigned long size, uint32_t *tiling_mode) @@ -2116,11 +2121,10 @@ drm_intel_gem_bo_exec(drm_intel_bo *bo, int used, drm_clip_rect_t * cliprects, int num_cliprects, int DR4) { drm_intel_bufmgr_gem *bufmgr_gem = (drm_intel_bufmgr_gem *) bo->bufmgr; - drm_intel_bo_gem *bo_gem = (drm_intel_bo_gem *) bo; struct drm_i915_gem_execbuffer execbuf; int ret, i; - if (bo_gem->has_error) + if (to_bo_gem(bo)->has_error) return -ENOMEM; pthread_mutex_lock(&bufmgr_gem->lock); @@ -2165,7 +2169,7 @@ drm_intel_gem_bo_exec(drm_intel_bo *bo, int used, drm_intel_gem_dump_validation_list(bufmgr_gem); for (i = 0; i < bufmgr_gem->exec_count; i++) { - bo_gem = (drm_intel_bo_gem *) bufmgr_gem->exec_bos[i]; + drm_intel_bo_gem *bo_gem = to_bo_gem(bufmgr_gem->exec_bos[i]); bo_gem->idle = false; @@ -2185,12 +2189,11 @@ do_exec2(drm_intel_bo *bo, int used, drm_intel_context *ctx, unsigned int flags) { drm_intel_bufmgr_gem *bufmgr_gem = (drm_intel_bufmgr_gem *)bo->bufmgr; - drm_intel_bo_gem *bo_gem = (drm_intel_bo_gem *) bo; struct drm_i915_gem_execbuffer2 execbuf; int ret = 0; int i; - if (bo_gem->has_error) + if (to_bo_gem(bo)->has_error) return -ENOMEM; switch (flags & 0x7) { @@ -2263,7 +2266,7 @@ skip_execution: drm_intel_gem_dump_validation_list(bufmgr_gem); for (i = 0; i < bufmgr_gem->exec_count; i++) { - bo_gem = (drm_intel_bo_gem *) bufmgr_gem->exec_bos[i]; + drm_intel_bo_gem *bo_gem = to_bo_gem(bufmgr_gem->exec_bos[i]); bo_gem->idle = false;