[Intel-gfx] [PATCH 2/2] drm/i915/params: support bool values for int and uint params
Jani Nikula
jani.nikula at intel.com
Thu Dec 5 15:43:41 UTC 2019
It's not uncommon for us to switch param types between bools and ints,
often having otherwise bool semantics but -1 value for platform
default. Allow bool values (such as YyNn) for ints.
Signed-off-by: Jani Nikula <jani.nikula at intel.com>
---
drivers/gpu/drm/i915/i915_debugfs_params.c | 14 ++++++++++++++
1 file changed, 14 insertions(+)
diff --git a/drivers/gpu/drm/i915/i915_debugfs_params.c b/drivers/gpu/drm/i915/i915_debugfs_params.c
index 7f1af5a35ca1..9acb755714cf 100644
--- a/drivers/gpu/drm/i915/i915_debugfs_params.c
+++ b/drivers/gpu/drm/i915/i915_debugfs_params.c
@@ -32,6 +32,13 @@ static ssize_t i915_param_int_write(struct file *file,
int ret;
ret = kstrtoint_from_user(ubuf, len, 0, value);
+ if (ret) {
+ /* support boolean values too */
+ bool b;
+ ret = kstrtobool_from_user(ubuf, len, &b);
+ if (!ret)
+ *value = b;
+ }
return ret ?: len;
}
@@ -77,6 +84,13 @@ static ssize_t i915_param_uint_write(struct file *file,
int ret;
ret = kstrtouint_from_user(ubuf, len, 0, value);
+ if (ret) {
+ /* support boolean values too */
+ bool b;
+ ret = kstrtobool_from_user(ubuf, len, &b);
+ if (!ret)
+ *value = b;
+ }
return ret ?: len;
}
--
2.20.1
More information about the Intel-gfx
mailing list