diff mbox

[v2] drm/debugfs: fix plain echo to connector "force" attribute

Message ID 20170817104307.17124-1-m.tretter@pengutronix.de (mailing list archive)
State New, archived
Headers show

Commit Message

Michael Tretter Aug. 17, 2017, 10:43 a.m. UTC
Using plain echo to set the "force" connector attribute fails with
-EINVAL, because echo appends a newline to the output.

Replace strcmp with sysfs_streq to also accept strings that end with a
newline.

v2: use sysfs_streq instead of stripping trailing whitespace

Signed-off-by: Michael Tretter <m.tretter@pengutronix.de>
---
 drivers/gpu/drm/drm_debugfs.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

Comments

Jani Nikula Aug. 17, 2017, 11:39 a.m. UTC | #1
On Thu, 17 Aug 2017, Michael Tretter <m.tretter@pengutronix.de> wrote:
> Using plain echo to set the "force" connector attribute fails with
> -EINVAL, because echo appends a newline to the output.
>
> Replace strcmp with sysfs_streq to also accept strings that end with a
> newline.
>
> v2: use sysfs_streq instead of stripping trailing whitespace
>
> Signed-off-by: Michael Tretter <m.tretter@pengutronix.de>

Reviewed-by: Jani Nikula <jani.nikula@intel.com>

> ---
>  drivers/gpu/drm/drm_debugfs.c | 8 ++++----
>  1 file changed, 4 insertions(+), 4 deletions(-)
>
> diff --git a/drivers/gpu/drm/drm_debugfs.c b/drivers/gpu/drm/drm_debugfs.c
> index c1807d5754b2..454deba13ee5 100644
> --- a/drivers/gpu/drm/drm_debugfs.c
> +++ b/drivers/gpu/drm/drm_debugfs.c
> @@ -250,13 +250,13 @@ static ssize_t connector_write(struct file *file, const char __user *ubuf,
>  
>  	buf[len] = '\0';
>  
> -	if (!strcmp(buf, "on"))
> +	if (sysfs_streq(buf, "on"))
>  		connector->force = DRM_FORCE_ON;
> -	else if (!strcmp(buf, "digital"))
> +	else if (sysfs_streq(buf, "digital"))
>  		connector->force = DRM_FORCE_ON_DIGITAL;
> -	else if (!strcmp(buf, "off"))
> +	else if (sysfs_streq(buf, "off"))
>  		connector->force = DRM_FORCE_OFF;
> -	else if (!strcmp(buf, "unspecified"))
> +	else if (sysfs_streq(buf, "unspecified"))
>  		connector->force = DRM_FORCE_UNSPECIFIED;
>  	else
>  		return -EINVAL;
Emil Velikov May 17, 2020, 8:49 p.m. UTC | #2
On Thu, 17 Aug 2017 at 12:34, Jani Nikula <jani.nikula@linux.intel.com> wrote:
>
> On Thu, 17 Aug 2017, Michael Tretter <m.tretter@pengutronix.de> wrote:
> > Using plain echo to set the "force" connector attribute fails with
> > -EINVAL, because echo appends a newline to the output.
> >
> > Replace strcmp with sysfs_streq to also accept strings that end with a
> > newline.
> >
> > v2: use sysfs_streq instead of stripping trailing whitespace
> >
> > Signed-off-by: Michael Tretter <m.tretter@pengutronix.de>
>
> Reviewed-by: Jani Nikula <jani.nikula@intel.com>
>
Seems like this fell through the cracks. Pushed to drm-misc-next.

Thanks
Emil
Jani Nikula May 18, 2020, 9:22 a.m. UTC | #3
On Sun, 17 May 2020, Emil Velikov <emil.l.velikov@gmail.com> wrote:
> On Thu, 17 Aug 2017 at 12:34, Jani Nikula <jani.nikula@linux.intel.com> wrote:
>>
>> On Thu, 17 Aug 2017, Michael Tretter <m.tretter@pengutronix.de> wrote:
>> > Using plain echo to set the "force" connector attribute fails with
>> > -EINVAL, because echo appends a newline to the output.
>> >
>> > Replace strcmp with sysfs_streq to also accept strings that end with a
>> > newline.
>> >
>> > v2: use sysfs_streq instead of stripping trailing whitespace
>> >
>> > Signed-off-by: Michael Tretter <m.tretter@pengutronix.de>
>>
>> Reviewed-by: Jani Nikula <jani.nikula@intel.com>
>>
> Seems like this fell through the cracks. Pushed to drm-misc-next.

From 2017? How'd you find it? :o

My bad, thanks.


BR,
Jani.
Emil Velikov May 18, 2020, 10:39 a.m. UTC | #4
On Mon, 18 May 2020 at 10:22, Jani Nikula <jani.nikula@linux.intel.com> wrote:
>
> On Sun, 17 May 2020, Emil Velikov <emil.l.velikov@gmail.com> wrote:
> > On Thu, 17 Aug 2017 at 12:34, Jani Nikula <jani.nikula@linux.intel.com> wrote:
> >>
> >> On Thu, 17 Aug 2017, Michael Tretter <m.tretter@pengutronix.de> wrote:
> >> > Using plain echo to set the "force" connector attribute fails with
> >> > -EINVAL, because echo appends a newline to the output.
> >> >
> >> > Replace strcmp with sysfs_streq to also accept strings that end with a
> >> > newline.
> >> >
> >> > v2: use sysfs_streq instead of stripping trailing whitespace
> >> >
> >> > Signed-off-by: Michael Tretter <m.tretter@pengutronix.de>
> >>
> >> Reviewed-by: Jani Nikula <jani.nikula@intel.com>
> >>
> > Seems like this fell through the cracks. Pushed to drm-misc-next.
>
> From 2017? How'd you find it? :o
>
> My bad, thanks.
>
A colleague mentioned about their experiences with \n, so I remembered
seeing something.
From a quick grep, we have have handful of other cases mostly in
amdgpu and radeon. Will see it I can prep a patch later on today.

-Emil
diff mbox

Patch

diff --git a/drivers/gpu/drm/drm_debugfs.c b/drivers/gpu/drm/drm_debugfs.c
index c1807d5754b2..454deba13ee5 100644
--- a/drivers/gpu/drm/drm_debugfs.c
+++ b/drivers/gpu/drm/drm_debugfs.c
@@ -250,13 +250,13 @@  static ssize_t connector_write(struct file *file, const char __user *ubuf,
 
 	buf[len] = '\0';
 
-	if (!strcmp(buf, "on"))
+	if (sysfs_streq(buf, "on"))
 		connector->force = DRM_FORCE_ON;
-	else if (!strcmp(buf, "digital"))
+	else if (sysfs_streq(buf, "digital"))
 		connector->force = DRM_FORCE_ON_DIGITAL;
-	else if (!strcmp(buf, "off"))
+	else if (sysfs_streq(buf, "off"))
 		connector->force = DRM_FORCE_OFF;
-	else if (!strcmp(buf, "unspecified"))
+	else if (sysfs_streq(buf, "unspecified"))
 		connector->force = DRM_FORCE_UNSPECIFIED;
 	else
 		return -EINVAL;