From: Tommaso Merciai <tommaso.merciai@amarulasolutions.com>
To: ye.xingchen@zte.com.cn
Cc: isely@pobox.com, mchehab@kernel.org, linux-media@vger.kernel.org,
linux-kernel@vger.kernel.org
Subject: Re: [PATCH] media: pvrusb2: use sysfs_emit() to instead of scnprintf()
Date: Thu, 1 Dec 2022 12:49:46 +0100 [thread overview]
Message-ID: <20221201114946.GA1289482@tom-ThinkPad-T14s-Gen-2i> (raw)
In-Reply-To: <202212011927592559291@zte.com.cn>
Hi,
On Thu, Dec 01, 2022 at 07:27:59PM +0800, ye.xingchen@zte.com.cn wrote:
> From: ye xingchen <ye.xingchen@zte.com.cn>
>
> Follow the advice of the Documentation/filesystems/sysfs.rst and show()
> should only use sysfs_emit() or sysfs_emit_at() when formatting the
> value to be returned to user space.
>
> Signed-off-by: ye xingchen <ye.xingchen@zte.com.cn>
> ---
> drivers/media/usb/pvrusb2/pvrusb2-sysfs.c | 20 ++++++++++----------
> 1 file changed, 10 insertions(+), 10 deletions(-)
>
> diff --git a/drivers/media/usb/pvrusb2/pvrusb2-sysfs.c b/drivers/media/usb/pvrusb2/pvrusb2-sysfs.c
> index 3e42e209be37..81c8b65bd9ef 100644
> --- a/drivers/media/usb/pvrusb2/pvrusb2-sysfs.c
> +++ b/drivers/media/usb/pvrusb2/pvrusb2-sysfs.c
> @@ -81,7 +81,7 @@ static ssize_t show_name(struct device *class_dev,
> pvr2_sysfs_trace("pvr2_sysfs(%p) show_name(cid=%d) is %s",
> cip->chptr, cip->ctl_id, name);
> if (!name) return -EINVAL;
> - return scnprintf(buf, PAGE_SIZE, "%s\n", name);
> + return sysfs_emit(buf, "%s\n", name);
> }
>
> static ssize_t show_type(struct device *class_dev,
> @@ -102,7 +102,7 @@ static ssize_t show_type(struct device *class_dev,
> }
> pvr2_sysfs_trace("pvr2_sysfs(%p) show_type(cid=%d) is %s",
> cip->chptr, cip->ctl_id, name);
> - return scnprintf(buf, PAGE_SIZE, "%s\n", name);
> + return sysfs_emit(buf, "%s\n", name);
> }
>
> static ssize_t show_min(struct device *class_dev,
> @@ -115,7 +115,7 @@ static ssize_t show_min(struct device *class_dev,
> val = pvr2_ctrl_get_min(cip->cptr);
> pvr2_sysfs_trace("pvr2_sysfs(%p) show_min(cid=%d) is %ld",
> cip->chptr, cip->ctl_id, val);
> - return scnprintf(buf, PAGE_SIZE, "%ld\n", val);
> + return sysfs_emit(buf, "%ld\n", val);
> }
>
> static ssize_t show_max(struct device *class_dev,
> @@ -128,7 +128,7 @@ static ssize_t show_max(struct device *class_dev,
> val = pvr2_ctrl_get_max(cip->cptr);
> pvr2_sysfs_trace("pvr2_sysfs(%p) show_max(cid=%d) is %ld",
> cip->chptr, cip->ctl_id, val);
> - return scnprintf(buf, PAGE_SIZE, "%ld\n", val);
> + return sysfs_emit(buf, "%ld\n", val);
> }
>
> static ssize_t show_def(struct device *class_dev,
> @@ -551,7 +551,7 @@ static ssize_t v4l_minor_number_show(struct device *class_dev,
> struct pvr2_sysfs *sfp;
> sfp = dev_get_drvdata(class_dev);
> if (!sfp) return -EINVAL;
> - return scnprintf(buf,PAGE_SIZE,"%d\n",
> + return sysfs_emit(buf, "%d\n",
> pvr2_hdw_v4l_get_minor_number(sfp->channel.hdw,
> pvr2_v4l_type_video));
> }
> @@ -563,7 +563,7 @@ static ssize_t bus_info_show(struct device *class_dev,
> struct pvr2_sysfs *sfp;
> sfp = dev_get_drvdata(class_dev);
> if (!sfp) return -EINVAL;
> - return scnprintf(buf,PAGE_SIZE,"%s\n",
> + return sysfs_emit(buf, "%s\n",
> pvr2_hdw_get_bus_info(sfp->channel.hdw));
> }
>
> @@ -574,7 +574,7 @@ static ssize_t hdw_name_show(struct device *class_dev,
> struct pvr2_sysfs *sfp;
> sfp = dev_get_drvdata(class_dev);
> if (!sfp) return -EINVAL;
> - return scnprintf(buf,PAGE_SIZE,"%s\n",
> + return sysfs_emit(buf, "%s\n",
> pvr2_hdw_get_type(sfp->channel.hdw));
> }
>
> @@ -585,7 +585,7 @@ static ssize_t hdw_desc_show(struct device *class_dev,
> struct pvr2_sysfs *sfp;
> sfp = dev_get_drvdata(class_dev);
> if (!sfp) return -EINVAL;
> - return scnprintf(buf,PAGE_SIZE,"%s\n",
> + return sysfs_emit(buf, "%s\n",
> pvr2_hdw_get_desc(sfp->channel.hdw));
> }
>
> @@ -597,7 +597,7 @@ static ssize_t v4l_radio_minor_number_show(struct device *class_dev,
> struct pvr2_sysfs *sfp;
> sfp = dev_get_drvdata(class_dev);
> if (!sfp) return -EINVAL;
> - return scnprintf(buf,PAGE_SIZE,"%d\n",
> + return sysfs_emit(buf, "%d\n",
> pvr2_hdw_v4l_get_minor_number(sfp->channel.hdw,
> pvr2_v4l_type_radio));
> }
> @@ -609,7 +609,7 @@ static ssize_t unit_number_show(struct device *class_dev,
> struct pvr2_sysfs *sfp;
> sfp = dev_get_drvdata(class_dev);
> if (!sfp) return -EINVAL;
> - return scnprintf(buf,PAGE_SIZE,"%d\n",
> + return sysfs_emit(buf, "%d\n",
> pvr2_hdw_get_unit_number(sfp->channel.hdw));
> }
>
> --
> 2.25.1
Looks good to me.
Reviewed-by: Tommaso Merciai <tommaso.merciai@amarulasolutions.com>
--
Tommaso Merciai
Embedded Linux Engineer
tommaso.merciai@amarulasolutions.com
__________________________________
Amarula Solutions SRL
Via Le Canevare 30, 31100 Treviso, Veneto, IT
T. +39 042 243 5310
info@amarulasolutions.com
www.amarulasolutions.com
prev parent reply other threads:[~2022-12-01 11:49 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-12-01 11:27 ye.xingchen
2022-12-01 11:49 ` Tommaso Merciai [this message]
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=20221201114946.GA1289482@tom-ThinkPad-T14s-Gen-2i \
--to=tommaso.merciai@amarulasolutions.com \
--cc=isely@pobox.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-media@vger.kernel.org \
--cc=mchehab@kernel.org \
--cc=ye.xingchen@zte.com.cn \
/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
all inboxes | Powered by JetHome®