From: Jani Nikula <jani.nikula@linux.intel.com>
To: dri-devel@lists.freedesktop.org
Cc: Daniel Vetter <daniel.vetter@intel.com>,
Michael Tretter <m.tretter@pengutronix.de>,
kernel@pengutronix.de
Subject: Re: [PATCH] drm/debugfs: accept trailing whitespace in "force" attribute
Date: Thu, 17 Aug 2017 12:59:14 +0300 [thread overview]
Message-ID: <87shgq8qh9.fsf@nikula.org> (raw)
In-Reply-To: <20170816153930.15623-1-m.tretter@pengutronix.de>
On Wed, 16 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.
>
> Strip trailing whitespace in the input before checking the value to
> accept "off\n" or "off ".
Please replace the strcmp() calls with sysfs_streq() instead.
BR,
Jani.
>
> Signed-off-by: Michael Tretter <m.tretter@pengutronix.de>
> ---
> drivers/gpu/drm/drm_debugfs.c | 5 +++++
> 1 file changed, 5 insertions(+)
>
> diff --git a/drivers/gpu/drm/drm_debugfs.c b/drivers/gpu/drm/drm_debugfs.c
> index c1807d5754b2..10dd89d3f28e 100644
> --- a/drivers/gpu/drm/drm_debugfs.c
> +++ b/drivers/gpu/drm/drm_debugfs.c
> @@ -241,6 +241,7 @@ static ssize_t connector_write(struct file *file, const char __user *ubuf,
> struct seq_file *m = file->private_data;
> struct drm_connector *connector = m->private;
> char buf[12];
> + int i;
>
> if (len > sizeof(buf) - 1)
> return -EINVAL;
> @@ -250,6 +251,10 @@ static ssize_t connector_write(struct file *file, const char __user *ubuf,
>
> buf[len] = '\0';
>
> + /* strip trailing whitespace */
> + for (i = len - 1; i > 0 && isspace(buf[i]); i--)
> + buf[i] = '\0';
> +
> if (!strcmp(buf, "on"))
> connector->force = DRM_FORCE_ON;
> else if (!strcmp(buf, "digital"))
--
Jani Nikula, Intel Open Source Technology Center
_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel
next prev parent reply other threads:[~2017-08-17 9:54 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-08-16 15:39 [PATCH] drm/debugfs: accept trailing whitespace in "force" attribute Michael Tretter
2017-08-17 9:59 ` Jani Nikula [this message]
2017-08-17 10:43 ` [PATCH v2] drm/debugfs: fix plain echo to connector " Michael Tretter
2017-08-17 11:39 ` Jani Nikula
2020-05-17 20:49 ` Emil Velikov
2020-05-18 9:22 ` Jani Nikula
2020-05-18 10:39 ` Emil Velikov
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=87shgq8qh9.fsf@nikula.org \
--to=jani.nikula@linux.intel.com \
--cc=daniel.vetter@intel.com \
--cc=dri-devel@lists.freedesktop.org \
--cc=kernel@pengutronix.de \
--cc=m.tretter@pengutronix.de \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.