Re: [Intel-gfx] [RFC PATCH 08/11] drm/i915/debugfs: support bool values for int and uint params

2018-12-21 Thread Jani Nikula

Argh, stray file accidentally sent, ignore.

On Fri, 21 Dec 2018, Jani Nikula  wrote:
> 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 for ints.
>
> Signed-off-by: Jani Nikula 
> ---
>  drivers/gpu/drm/i915/i915_debugfs.c | 14 ++
>  1 file changed, 14 insertions(+)
>
> diff --git a/drivers/gpu/drm/i915/i915_debugfs.c 
> b/drivers/gpu/drm/i915/i915_debugfs.c
> index 33375cf79713..c9e2cf8e071a 100644
> --- a/drivers/gpu/drm/i915/i915_debugfs.c
> +++ b/drivers/gpu/drm/i915/i915_debugfs.c
> @@ -61,6 +61,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, );
> + if (!ret)
> + *value = b;
> + }
>  
>   return ret ?: len;
>  }
> @@ -106,6 +113,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, );
> + if (!ret)
> + *value = b;
> + }
>  
>   return ret ?: len;
>  }

-- 
Jani Nikula, Intel Open Source Graphics Center
___
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx


[Intel-gfx] [RFC PATCH 08/11] drm/i915/debugfs: support bool values for int and uint params

2018-12-21 Thread Jani Nikula
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 for ints.

Signed-off-by: Jani Nikula 
---
 drivers/gpu/drm/i915/i915_debugfs.c | 14 ++
 1 file changed, 14 insertions(+)

diff --git a/drivers/gpu/drm/i915/i915_debugfs.c 
b/drivers/gpu/drm/i915/i915_debugfs.c
index 33375cf79713..c9e2cf8e071a 100644
--- a/drivers/gpu/drm/i915/i915_debugfs.c
+++ b/drivers/gpu/drm/i915/i915_debugfs.c
@@ -61,6 +61,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, );
+   if (!ret)
+   *value = b;
+   }
 
return ret ?: len;
 }
@@ -106,6 +113,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, );
+   if (!ret)
+   *value = b;
+   }
 
return ret ?: len;
 }
-- 
2.11.0

___
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx