mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git
synced 2024-08-23 09:19:51 +00:00
drm/i915/params: use generics for parameter free
Replace the __builtin_strcmp() if ladder with generics. Signed-off-by: Jani Nikula <jani.nikula@intel.com> Reviewed-by: Luca Coelho <luciano.coelho@intel.com> Link: https://patchwork.freedesktop.org/patch/msgid/20230118151800.3669913-3-jani.nikula@intel.com
This commit is contained in:
parent
7ce59bcf67
commit
7448d336bc
1 changed files with 9 additions and 6 deletions
|
@ -296,18 +296,21 @@ void i915_params_copy(struct i915_params *dest, const struct i915_params *src)
|
|||
#undef DUP
|
||||
}
|
||||
|
||||
static __always_inline void free_param(const char *type, void *x)
|
||||
static void _param_free_charp(char **valp)
|
||||
{
|
||||
if (!__builtin_strcmp(type, "char *")) {
|
||||
kfree(*(void **)x);
|
||||
*(void **)x = NULL;
|
||||
}
|
||||
kfree(*valp);
|
||||
*valp = NULL;
|
||||
}
|
||||
|
||||
#define _param_free(valp) \
|
||||
_Generic(valp, \
|
||||
char **: _param_free_charp, \
|
||||
default: _param_nop)(valp)
|
||||
|
||||
/* free the allocated members, *not* the passed in params itself */
|
||||
void i915_params_free(struct i915_params *params)
|
||||
{
|
||||
#define FREE(T, x, ...) free_param(#T, ¶ms->x);
|
||||
#define FREE(T, x, ...) _param_free(¶ms->x);
|
||||
I915_PARAMS_FOR_EACH(FREE);
|
||||
#undef FREE
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue