Message ID | c945ac7b08e0eb0827cf647609885f4abdb84f1d.1575560168.git.jani.nikula@intel.com (mailing list archive) |
---|---|
State | New, archived |
Headers | show |
Series | drm/i915: debugfs device parameters | expand |
Quoting Jani Nikula (2019-12-05 15:43:41) > 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@intel.com> Reviewed-by: Chris Wilson <chris@chris-wilson.co.uk> But play nice with checkpatch, no point fighting with it over a line of whitespace. -Chris
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; }
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@intel.com> --- drivers/gpu/drm/i915/i915_debugfs_params.c | 14 ++++++++++++++ 1 file changed, 14 insertions(+)