Commit 01ce7446 authored by Jani Nikula's avatar Jani Nikula

drm/i915/params: use generics for parameter debugfs file creation

Replace the __builtin_strcmp() if ladder with generics.
Signed-off-by: default avatarJani Nikula <jani.nikula@intel.com>
Reviewed-by: default avatarLuca Coelho <luciano.coelho@intel.com>
Link: https://patchwork.freedesktop.org/patch/msgid/20230118151800.3669913-4-jani.nikula@intel.com
parent 7448d336
...@@ -230,27 +230,16 @@ i915_debugfs_create_charp(const char *name, umode_t mode, ...@@ -230,27 +230,16 @@ i915_debugfs_create_charp(const char *name, umode_t mode,
&i915_param_charp_fops); &i915_param_charp_fops);
} }
static __always_inline void #define _i915_param_create_file(parent, name, mode, valp) \
_i915_param_create_file(struct dentry *parent, const char *name, do { \
const char *type, int mode, void *value) if (mode) \
{ _Generic(valp, \
if (!mode) bool *: debugfs_create_bool, \
return; int *: i915_debugfs_create_int, \
unsigned int *: i915_debugfs_create_uint, \
if (!__builtin_strcmp(type, "bool")) unsigned long *: debugfs_create_ulong, \
debugfs_create_bool(name, mode, parent, value); char **: i915_debugfs_create_charp)(name, mode, parent, valp); \
else if (!__builtin_strcmp(type, "int")) } while(0)
i915_debugfs_create_int(name, mode, parent, value);
else if (!__builtin_strcmp(type, "unsigned int"))
i915_debugfs_create_uint(name, mode, parent, value);
else if (!__builtin_strcmp(type, "unsigned long"))
debugfs_create_ulong(name, mode, parent, value);
else if (!__builtin_strcmp(type, "char *"))
i915_debugfs_create_charp(name, mode, parent, value);
else
WARN(1, "no debugfs fops defined for param type %s (i915.%s)\n",
type, name);
}
/* add a subdirectory with files for each i915 param */ /* add a subdirectory with files for each i915 param */
struct dentry *i915_debugfs_params(struct drm_i915_private *i915) struct dentry *i915_debugfs_params(struct drm_i915_private *i915)
...@@ -269,7 +258,7 @@ struct dentry *i915_debugfs_params(struct drm_i915_private *i915) ...@@ -269,7 +258,7 @@ struct dentry *i915_debugfs_params(struct drm_i915_private *i915)
* just let the generic create file fail silently with -EEXIST. * just let the generic create file fail silently with -EEXIST.
*/ */
#define REGISTER(T, x, unused, mode, ...) _i915_param_create_file(dir, #x, #T, mode, &params->x); #define REGISTER(T, x, unused, mode, ...) _i915_param_create_file(dir, #x, mode, &params->x);
I915_PARAMS_FOR_EACH(REGISTER); I915_PARAMS_FOR_EACH(REGISTER);
#undef REGISTER #undef REGISTER
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment