]> www.infradead.org Git - users/dwmw2/linux.git/commitdiff
drm/debugfs: fix plain echo to connector "force" attribute
authorMichael Tretter <m.tretter@pengutronix.de>
Thu, 17 Aug 2017 10:43:07 +0000 (12:43 +0200)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Fri, 21 Aug 2020 07:48:05 +0000 (09:48 +0200)
[ Upstream commit c704b17071c4dc571dca3af4e4151dac51de081a ]

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>
Signed-off-by: Emil Velikov <emil.l.velikov@gmail.com>
Link: https://patchwork.freedesktop.org/patch/msgid/20170817104307.17124-1-m.tretter@pengutronix.de
Signed-off-by: Sasha Levin <sashal@kernel.org>
drivers/gpu/drm/drm_debugfs.c

index c1807d5754b2a865c39a6540f5911a524014dbc3..454deba13ee5b50be9d7400267229a212d4adc8c 100644 (file)
@@ -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;