summaryrefslogtreecommitdiffstats
path: root/drivers/gpu/drm/i915/i915_params.c
diff options
context:
space:
mode:
authorJani Nikula2018-12-27 15:33:38 +0100
committerJani Nikula2018-12-31 14:27:00 +0100
commit16cabb12f2cc40304dfce8c8eba169f044b64f02 (patch)
tree271d06cc89ec46f5d0a1f2d5d24eee712dad1c7d /drivers/gpu/drm/i915/i915_params.c
parentdrm/i915: add a helper to make a copy of i915_params (diff)
downloadkernel-qcow2-linux-16cabb12f2cc40304dfce8c8eba169f044b64f02.tar.gz
kernel-qcow2-linux-16cabb12f2cc40304dfce8c8eba169f044b64f02.tar.xz
kernel-qcow2-linux-16cabb12f2cc40304dfce8c8eba169f044b64f02.zip
drm/i915: add a helper to free the members of i915_params
Abstract the one user in anticipation of more. Set the dangling pointers to NULL while at it. Reviewed-by: Tvrtko Ursulin <tvrtko.ursulin@intel.com> Signed-off-by: Jani Nikula <jani.nikula@intel.com> Link: https://patchwork.freedesktop.org/patch/msgid/8637d1e5049dc003718772f19d664aeaf9540856.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.c16
1 files changed, 16 insertions, 0 deletions
diff --git a/drivers/gpu/drm/i915/i915_params.c b/drivers/gpu/drm/i915/i915_params.c
index ae3ece4ec7ab..81c73bfc7991 100644
--- a/drivers/gpu/drm/i915/i915_params.c
+++ b/drivers/gpu/drm/i915/i915_params.c
@@ -217,3 +217,19 @@ void i915_params_copy(struct i915_params *dest, const struct i915_params *src)
I915_PARAMS_FOR_EACH(DUP);
#undef DUP
}
+
+static __always_inline void free_param(const char *type, void *x)
+{
+ if (!__builtin_strcmp(type, "char *")) {
+ kfree(*(void **)x);
+ *(void **)x = NULL;
+ }
+}
+
+/* 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, &params->x);
+ I915_PARAMS_FOR_EACH(FREE);
+#undef FREE
+}