From: Michal Wajdeczko Date: Sat, 20 Jul 2024 14:25:22 +0000 (+0200) Subject: drm/xe: Introduce const cast helper X-Git-Tag: v6.12-rc1~126^2~25^2~35 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=bd40536ae33911bc74df5ba3b29b573dcb72f904;p=thirdparty%2Fkernel%2Flinux.git drm/xe: Introduce const cast helper Typically we want to preserve pointer constness when converting from one xe pointer to another, but in some rare cases, like kunit parameter conversions, we might want to discard this constness. Add a helper that we will use to clearly indicate our intention. Signed-off-by: Michal Wajdeczko Reviewed-by: Jonathan Cavitt #v1 Cc: Lucas De Marchi Reviewed-by: Lucas De Marchi Link: https://patchwork.freedesktop.org/patch/msgid/20240720142528.530-2-michal.wajdeczko@intel.com --- diff --git a/drivers/gpu/drm/xe/xe_device.h b/drivers/gpu/drm/xe/xe_device.h index 533ccfb2567a2..db6cc8d0d6b87 100644 --- a/drivers/gpu/drm/xe/xe_device.h +++ b/drivers/gpu/drm/xe/xe_device.h @@ -20,6 +20,11 @@ static inline struct xe_device *pdev_to_xe_device(struct pci_dev *pdev) return pci_get_drvdata(pdev); } +static inline struct xe_device *xe_device_const_cast(const struct xe_device *xe) +{ + return (struct xe_device *)xe; +} + static inline struct xe_device *ttm_to_xe_device(struct ttm_device *ttm) { return container_of(ttm, struct xe_device, ttm);