Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id A4A8FC64EC4 for ; Mon, 6 Mar 2023 17:50:52 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 28CA088EFE; Mon, 6 Mar 2023 17:50:52 +0000 (UTC) Received: from mga03.intel.com (mga03.intel.com [134.134.136.65]) by gabe.freedesktop.org (Postfix) with ESMTPS id 8DAAE10E40D for ; Mon, 6 Mar 2023 17:50:50 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1678125050; x=1709661050; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=Sto5wQv8ixV/MQXohx0ae3xxcdrhsfM04MEo8+9o4k4=; b=EQNvj/p+Q55zXTpiAJ9slxSkWlJbvA8Xrw2okQFQs8hQUa/5l2M/FiuG Hl0pXs25IZr9jfkLsRbM3++KTAVaE4v9c2dZIbaG7UdTcKSjl+Z0rZsRJ V5ahxQ8nPk0nkn9I6CDYeWu3d7QPVUUbu+yQdT3A9oHVdfAmoNxMTZCLo mjgipSgkPXAHf26PzvTgkU4ppsbRt6H9+pZteQxapoWFkm/rcM/Djx4+7 IYM6tFNi+OPeGzC2D3fIMItCA4JFo6Y8hkTJKLwfW92DRjf2DpnKgAK1p hiiK1+OBV7wMc8SeSjn4QFO1a9QXmWgSTjwQbDNsUBHAPsGx1D7UQhcQk Q==; X-IronPort-AV: E=McAfee;i="6500,9779,10641"; a="337949797" X-IronPort-AV: E=Sophos;i="5.98,238,1673942400"; d="scan'208";a="337949797" Received: from orsmga002.jf.intel.com ([10.7.209.21]) by orsmga103.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 06 Mar 2023 09:50:48 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6500,9779,10641"; a="676241564" X-IronPort-AV: E=Sophos;i="5.98,238,1673942400"; d="scan'208";a="676241564" Received: from lucas-s2600cw.jf.intel.com ([10.165.21.196]) by orsmga002-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 06 Mar 2023 09:50:48 -0800 From: Lucas De Marchi To: intel-xe@lists.freedesktop.org Date: Mon, 6 Mar 2023 09:50:23 -0800 Message-Id: <20230306175025.720323-2-lucas.demarchi@intel.com> X-Mailer: git-send-email 2.39.0 In-Reply-To: <20230306175025.720323-1-lucas.demarchi@intel.com> References: <20230306175025.720323-1-lucas.demarchi@intel.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Subject: [Intel-xe] [PATCH 1/3] drm/xe: Allow const propagation in gt_to_xe() X-BeenThere: intel-xe@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Intel Xe graphics driver List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Lucas De Marchi , Matt Roper Errors-To: intel-xe-bounces@lists.freedesktop.org Sender: "Intel-xe" Replace the inline function with a _Generic() so gt_to_xe() can work with a const struct xe_gt*, which leads to a const struct xe *. This allows a const gt being passed around and when the xe device is needed, compiler won't issue a warning that calling gt_to_xe() would discard the const. Rather, just propagate the const to the xe pointer being returned. Signed-off-by: Lucas De Marchi --- drivers/gpu/drm/xe/xe_gt.h | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/drivers/gpu/drm/xe/xe_gt.h b/drivers/gpu/drm/xe/xe_gt.h index 5635f2803170..086369f7ee6d 100644 --- a/drivers/gpu/drm/xe/xe_gt.h +++ b/drivers/gpu/drm/xe/xe_gt.h @@ -49,10 +49,10 @@ static inline bool xe_gt_is_media_type(struct xe_gt *gt) return gt->info.type == XE_GT_TYPE_MEDIA; } -static inline struct xe_device * gt_to_xe(struct xe_gt *gt) -{ - return gt->xe; -} +#define gt_to_xe(gt__) \ + _Generic(gt__, \ + const struct xe_gt *: (const struct xe_device *)((gt__)->xe), \ + struct xe_gt *: (gt__)->xe) static inline bool xe_gt_is_usm_hwe(struct xe_gt *gt, struct xe_hw_engine *hwe) { -- 2.39.0