From: Jani Nikula Date: Wed, 18 Jan 2023 15:17:58 +0000 (+0200) Subject: drm/i915/params: use generics for parameter dup X-Git-Tag: v6.6.7~1918^2~17^2~643 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=7ce59bcf6750fb797451020f8d4db9822b58b1b5;p=platform%2Fkernel%2Flinux-starfive.git drm/i915/params: use generics for parameter dup Replace the __builtin_strcmp() if ladder with generics. Signed-off-by: Jani Nikula Reviewed-by: Luca Coelho Link: https://patchwork.freedesktop.org/patch/msgid/20230118151800.3669913-2-jani.nikula@intel.com --- diff --git a/drivers/gpu/drm/i915/i915_params.c b/drivers/gpu/drm/i915/i915_params.c index 6482e87..f9d92d0 100644 --- a/drivers/gpu/drm/i915/i915_params.c +++ b/drivers/gpu/drm/i915/i915_params.c @@ -274,16 +274,24 @@ void i915_params_dump(const struct i915_params *params, struct drm_printer *p) #undef PRINT } -static __always_inline void dup_param(const char *type, void *x) +static void _param_dup_charp(char **valp) { - if (!__builtin_strcmp(type, "char *")) - *(void **)x = kstrdup(*(void **)x, GFP_ATOMIC); + *valp = kstrdup(*valp, GFP_ATOMIC); } +static void _param_nop(void *valp) +{ +} + +#define _param_dup(valp) \ + _Generic(valp, \ + char **: _param_dup_charp, \ + default: _param_nop)(valp) + void i915_params_copy(struct i915_params *dest, const struct i915_params *src) { *dest = *src; -#define DUP(T, x, ...) dup_param(#T, &dest->x); +#define DUP(T, x, ...) _param_dup(&dest->x); I915_PARAMS_FOR_EACH(DUP); #undef DUP }