From: Greg KH <greg@kroah.com>
To: Marcelo Moreira <marcelomoreira1905@gmail.com>
Cc: Andrzej Hajda <andrzej.hajda@intel.com>,
skhan@linuxfoundation.org,
linux-kernel-mentees@lists.linuxfoundation.org,
~lkcamp/patches@lists.sr.ht,
Neil Armstrong <neil.armstrong@linaro.org>,
Robert Foss <rfoss@kernel.org>,
Laurent Pinchart <Laurent.pinchart@ideasonboard.com>,
Jonas Karlman <jonas@kwiboo.se>,
Jernej Skrabec <jernej.skrabec@gmail.com>,
Maarten Lankhorst <maarten.lankhorst@linux.intel.com>,
Maxime Ripard <mripard@kernel.org>,
Thomas Zimmermann <tzimmermann@suse.de>,
David Airlie <airlied@gmail.com>, Simona Vetter <simona@ffwll.ch>,
dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH] drm/bridge: it6505: replace scnprintf with sysfs_emit_at in debugfs show
Date: Mon, 30 Jun 2025 07:09:50 +0200 [thread overview]
Message-ID: <2025063006-recopy-playmaker-562d@gregkh> (raw)
In-Reply-To: <20250629233509.291786-1-marcelomoreira1905@gmail.com>
On Sun, Jun 29, 2025 at 08:35:09PM -0300, Marcelo Moreira wrote:
> Update the receive_timing_debugfs_show() function to utilize
> sysfs_emit_at() for formatting output to the debugfs buffer.
> This change adheres to the recommendation outlined
> in Documentation/filesystems/sysfs.rst.
>
> This modification aligns with current sysfs guidelines.
But this isn't a sysfs file, it's a debugfs file, so why are you calling
sysfs_emit_at()?
>
> Signed-off-by: Marcelo Moreira <marcelomoreira1905@gmail.com>
> ---
> drivers/gpu/drm/bridge/ite-it6505.c | 46 ++++++++++++++---------------
> 1 file changed, 22 insertions(+), 24 deletions(-)
>
> diff --git a/drivers/gpu/drm/bridge/ite-it6505.c b/drivers/gpu/drm/bridge/ite-it6505.c
> index 1383d1e21afe..98bea08a14e4 100644
> --- a/drivers/gpu/drm/bridge/ite-it6505.c
> +++ b/drivers/gpu/drm/bridge/ite-it6505.c
> @@ -3427,37 +3427,35 @@ static ssize_t receive_timing_debugfs_show(struct file *file, char __user *buf,
> struct it6505 *it6505 = file->private_data;
> struct drm_display_mode *vid;
> u8 read_buf[READ_BUFFER_SIZE];
> - u8 *str = read_buf, *end = read_buf + READ_BUFFER_SIZE;
> - ssize_t ret, count;
> + ssize_t ret;
> + ssize_t count = 0;
>
> if (!it6505)
> return -ENODEV;
>
> it6505_calc_video_info(it6505);
> vid = &it6505->video_info;
> - str += scnprintf(str, end - str, "---video timing---\n");
> - str += scnprintf(str, end - str, "PCLK:%d.%03dMHz\n",
> - vid->clock / 1000, vid->clock % 1000);
> - str += scnprintf(str, end - str, "HTotal:%d\n", vid->htotal);
> - str += scnprintf(str, end - str, "HActive:%d\n", vid->hdisplay);
> - str += scnprintf(str, end - str, "HFrontPorch:%d\n",
> - vid->hsync_start - vid->hdisplay);
> - str += scnprintf(str, end - str, "HSyncWidth:%d\n",
> - vid->hsync_end - vid->hsync_start);
> - str += scnprintf(str, end - str, "HBackPorch:%d\n",
> - vid->htotal - vid->hsync_end);
> - str += scnprintf(str, end - str, "VTotal:%d\n", vid->vtotal);
> - str += scnprintf(str, end - str, "VActive:%d\n", vid->vdisplay);
> - str += scnprintf(str, end - str, "VFrontPorch:%d\n",
> - vid->vsync_start - vid->vdisplay);
> - str += scnprintf(str, end - str, "VSyncWidth:%d\n",
> - vid->vsync_end - vid->vsync_start);
> - str += scnprintf(str, end - str, "VBackPorch:%d\n",
> - vid->vtotal - vid->vsync_end);
> -
> - count = str - read_buf;
> + count += sysfs_emit_at(read_buf, count, "---video timing---\n");
> + count += sysfs_emit_at(read_buf, count, "PCLK:%d.%03dMHz\n",
> + vid->clock / 1000, vid->clock % 1000);
> + count += sysfs_emit_at(read_buf, count, "HTotal:%d\n", vid->htotal);
> + count += sysfs_emit_at(read_buf, count, "HActive:%d\n", vid->hdisplay);
> + count += sysfs_emit_at(read_buf, count, "HFrontPorch:%d\n",
> + vid->hsync_start - vid->hdisplay);
> + count += sysfs_emit_at(read_buf, count, "HSyncWidth:%d\n",
> + vid->hsync_end - vid->hsync_start);
> + count += sysfs_emit_at(read_buf, count, "HBackPorch:%d\n",
> + vid->htotal - vid->hsync_end);
> + count += sysfs_emit_at(read_buf, count, "VTotal:%d\n", vid->vtotal);
> + count += sysfs_emit_at(read_buf, count, "VActive:%d\n", vid->vdisplay);
> + count += sysfs_emit_at(read_buf, count, "VFrontPorch:%d\n",
> + vid->vsync_start - vid->vdisplay);
> + count += sysfs_emit_at(read_buf, count, "VSyncWidth:%d\n",
> + vid->vsync_end - vid->vsync_start);
> + count += sysfs_emit_at(read_buf, count, "VBackPorch:%d\n",
> + vid->vtotal - vid->vsync_end);
> +
> ret = simple_read_from_buffer(buf, len, ppos, read_buf, count);
> -
Shouldn't this all be using seq_print() instead?
Again, don't use sysfs_emit*() functions for non-sysfs files, as you do
NOT know the size of the buffer here (hint, it's not the same).
And, your patch added trailing whitespace, did you forget to run it
through checkpatch.pl before sending it?
thanks,
greg k-h
next prev parent reply other threads:[~2025-06-30 5:21 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-06-29 23:35 [PATCH] drm/bridge: it6505: replace scnprintf with sysfs_emit_at in debugfs show Marcelo Moreira
2025-06-30 5:09 ` Greg KH [this message]
2025-07-01 0:35 ` Marcelo Moreira
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=2025063006-recopy-playmaker-562d@gregkh \
--to=greg@kroah.com \
--cc=Laurent.pinchart@ideasonboard.com \
--cc=airlied@gmail.com \
--cc=andrzej.hajda@intel.com \
--cc=dri-devel@lists.freedesktop.org \
--cc=jernej.skrabec@gmail.com \
--cc=jonas@kwiboo.se \
--cc=linux-kernel-mentees@lists.linuxfoundation.org \
--cc=linux-kernel@vger.kernel.org \
--cc=maarten.lankhorst@linux.intel.com \
--cc=marcelomoreira1905@gmail.com \
--cc=mripard@kernel.org \
--cc=neil.armstrong@linaro.org \
--cc=rfoss@kernel.org \
--cc=simona@ffwll.ch \
--cc=skhan@linuxfoundation.org \
--cc=tzimmermann@suse.de \
--cc=~lkcamp/patches@lists.sr.ht \
/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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).