summaryrefslogtreecommitdiff
path: root/drivers/gpu/drm/xe/xe_gt.h
diff options
context:
space:
mode:
authorLucas De Marchi <lucas.demarchi@intel.com>2023-03-04 09:26:55 +0300
committerRodrigo Vivi <rodrigo.vivi@intel.com>2023-12-20 02:29:45 +0300
commit8846ffb457587e5d393a83ce977c3db7c800fe58 (patch)
tree021f0b1bd4cc91df2c70605d481f600ac2b0af9d /drivers/gpu/drm/xe/xe_gt.h
parent6b980aa88d403db3e4cf5b58965dfa9a5f27c740 (diff)
downloadlinux-8846ffb457587e5d393a83ce977c3db7c800fe58.tar.xz
drm/xe: Allow const propagation in gt_to_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 <lucas.demarchi@intel.com> Reviewed-by: Matt Roper <matthew.d.roper@intel.com> Signed-off-by: Rodrigo Vivi <rodrigo.vivi@intel.com>
Diffstat (limited to 'drivers/gpu/drm/xe/xe_gt.h')
-rw-r--r--drivers/gpu/drm/xe/xe_gt.h8
1 files 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)
{