[PATCH v2 2/5] drm/xe/sriov: Prepare IS_SRIOV_PF to accept const pointer
Michal Wajdeczko
michal.wajdeczko at intel.com
Mon Feb 24 15:06:57 UTC 2025
For builds without CONFIG_PCI_IOV we have an optimized variant
of the IS_SRIOV_PF(xe) macro that always evaluates to false,
but we still try to validate corectness of the xe argument.
Unfortunately typecheck() alone doesn't work well for cases
where xe could be a const pointer. Try use _Generic() instead.
Signed-off-by: Michal Wajdeczko <michal.wajdeczko at intel.com>
---
drivers/gpu/drm/xe/xe_sriov.h | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/gpu/drm/xe/xe_sriov.h b/drivers/gpu/drm/xe/xe_sriov.h
index 688fbabf08f1..cba6a608bf27 100644
--- a/drivers/gpu/drm/xe/xe_sriov.h
+++ b/drivers/gpu/drm/xe/xe_sriov.h
@@ -38,7 +38,7 @@ static inline bool xe_device_is_sriov_vf(const struct xe_device *xe)
#ifdef CONFIG_PCI_IOV
#define IS_SRIOV_PF(xe) xe_device_is_sriov_pf(xe)
#else
-#define IS_SRIOV_PF(xe) (typecheck(struct xe_device *, (xe)) && false)
+#define IS_SRIOV_PF(xe) _Generic((xe), const struct xe_device * : false, struct xe_device * : false)
#endif
#define IS_SRIOV_VF(xe) xe_device_is_sriov_vf(xe)
--
2.47.1
More information about the Intel-xe
mailing list