diff options
author | Jani Nikula <jani.nikula@intel.com> | 2018-12-27 16:33:37 +0200 |
---|---|---|
committer | Jani Nikula <jani.nikula@intel.com> | 2018-12-31 15:26:39 +0200 |
commit | 4081cef923e0ac0bb4dbc24da838c91f2ea8d737 (patch) | |
tree | 6322ac05b1597fcb8448506859797a54802dca26 /drivers/gpu/drm/i915/i915_params.c | |
parent | caa5915bb3c1e61bd895383364011a8921fee053 (diff) |
drm/i915: add a helper to make a copy of i915_params
Abstract the one user in anticipation of more.
Reviewed-by: Chris Wilson <chris@chris-wilson.co.uk>
Signed-off-by: Jani Nikula <jani.nikula@intel.com>
Link: https://patchwork.freedesktop.org/patch/msgid/c6a94b4da8dc723df025b1f602fe46d76d00d53f.1545920737.git.jani.nikula@intel.com
Diffstat (limited to 'drivers/gpu/drm/i915/i915_params.c')
-rw-r--r-- | drivers/gpu/drm/i915/i915_params.c | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/drivers/gpu/drm/i915/i915_params.c b/drivers/gpu/drm/i915/i915_params.c index 2e0356561839..ae3ece4ec7ab 100644 --- a/drivers/gpu/drm/i915/i915_params.c +++ b/drivers/gpu/drm/i915/i915_params.c @@ -203,3 +203,17 @@ void i915_params_dump(const struct i915_params *params, struct drm_printer *p) I915_PARAMS_FOR_EACH(PRINT); #undef PRINT } + +static __always_inline void dup_param(const char *type, void *x) +{ + if (!__builtin_strcmp(type, "char *")) + *(void **)x = kstrdup(*(void **)x, GFP_ATOMIC); +} + +void i915_params_copy(struct i915_params *dest, const struct i915_params *src) +{ + *dest = *src; +#define DUP(T, x, ...) dup_param(#T, &dest->x); + I915_PARAMS_FOR_EACH(DUP); +#undef DUP +} |